Giter Club home page Giter Club logo

plug-modules's Introduction

plug-modules

Maps plug.dj defined modules to reasonable names, so you can more easily access internal plug.dj javascript.

Warning - Usage - API - How It Works - License

NPM

Warning!

plug-modules makes it easy to use plug.dj's client-side internals. Remember that plug.dj's internal JavaScript is not meant to be a public API. It changes a lot! Modules that you used yesterday, may not exist tomorrow, so make sure to code very defensively and to fall back gracefully.

Usage

If you're writing an extension for use on plug.dj, the easiest way to use plug-modules is using the require.js loader plugin. First, configure require.js to load plug-modules correctly, and then simply require() the stuff you need:

requirejs.config({
  paths: {
    'plug-modules': 'https://unpkg.com/plug-modules@6'
  }
});

require(['plug-modules!plug/core/Events'], function (Events) {
  Events.trigger('notify', 'icon-plug-dj', 'plug-modules works!');
});

If you don't like require.js, plug-modules is available on npm so you can bundle something yourself:

$ npm install plug-modules

You can then use it as a CommonJS module, or an AMD module, or just as window.plugModules when loaded in a <script> tag.

After loading plug-modules, you can access plug.dj modules like:

var SubClass = plugModules.require('plug/core/Class').extend({
  /* class definition */
});

plugModules.require('plug/core/Events')
  .trigger('notify', 'icon-plug-dj', 'Notification text');

Or make yourself an admin locally: (Fun fact! This will make plug.dj log some more debug info to the console ๐Ÿ˜„ )

var currentUser = plugModules.require('plug/models/currentUser');
currentUser.set('gRole', 5);

See the Wiki for more examples!

plugModules.require() modules in your browser's developer console or use replug to figure out what the different modules are for, and what you can do with/to them.

API

require.js plugin

plug-modules can be used as a require.js plugin:

require([ 'plug-modules!plug/core/Events' ], function (Events) {
  Events.trigger('notify', 'icon-plug-dj', 'Hello from plug-modules!');
});

plugModules.run()

Initialises plug-modules and computes all the module name mappings. You need to run this before using plugModules.register. It's done for you if you're using the require.js plugin.

plugModules.require(modulename)

Returns a plug.dj module. You can use any of the remapped module names, as well as original (obfuscated) names.

plugModules.register()

Defines all the remapped names on the global require() object, so you can use require() to access modules via the remapped names, too. In general, it's better to use plugModules.require instead.

plugModules.isDefined(modulename)

Checks if a module with the given name has been defined. Accepts both remapped and original module names. Note that a module that actually equals undefined also returns false:

define('module', function () { return undefined })
plugModules.isDefined('module') === false

plugModules.getUnknownModules()

Returns an array of original module names that were not remapped. This is mostly useful for finding more modules to reverse-engineer. Note that this is only useful if you've run all resolvers, otherwise modules that haven't yet been used won't be remapped.

How It Works

plug-modules contains several hundred resolver functions that find different modules by duck-typing. They then associate those modules with a descriptive and readable name each. You can call plugModules.register() to inject all those names back into require.js, so you can use the global require() function on plug.dj. Or better, you can use plugModules.require() if you don't want to contaminate the global module-space.

License

MIT

plug-modules's People

Contributors

goto-bus-stop avatar reannannanna avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

plug-modules's Issues

Missing modules

Currently can't find:

  • "plug/core/EventHandler"
  • "plug/collections/restrictedMediaAlternatives"
  • "plug/collections/transactions"
  • "plug/collections/youTubePlaylist"
  • "plug/views/playlists/media/headers/YouTubePlaylistsHeader"
  • "plug/views/playlists/media/panels/SoundCloudSetPanelView"
  • "plug/views/playlists/media/panels/YouTubePlaylistPanelView"
  • "plug/views/playlists/media/panels/YouTubePlaylistRowView"
  • "plug/views/playlists/media/panels/RestrictedMediaAlternativesPanelView"
  • "plug/views/playlists/media/panels/RestrictedMediaAlternativesRowView"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.