**********************
modules/module/plugins.js
**********************
435179
function (module) {
        "use strict";
    
        var plugins = {};
    
        var order;
        Object.defineProperty(this, 'order', {
            'get': function () {
                return order;
            },
            'set': function (value) {
                order = value;
            }
        });
    
        this.register = function (ID, plugin, group) {
    
            if (!group) group = 'default';
            if (!plugins[group]) plugins[group] = {};
    
            plugins[group][ID] = plugin;
    
        };
    
        this.get = function (group) {
    
            if (!group) group = 'default';
            var group = plugins[group];
    
            var ordered = [];
            for (var i in order) {
    
                var name = order[i];
                if (group[name]) ordered.push(group[name]);
    
            }
    
            // set all the plugins not in the ordered list
            for (var name in group) {
    
                if (!order || order.indexOf(name) === -1) ordered.push(group[name]);
    
            }
    
            return ordered;
    
        };
    
    }
592790
function plugin( _options ) {
  let options = _options || {};
  return ( files, metalsmith, done ) => {
    let app = new Youtube( options, files );
    app.parse( function() {
      done();
    });
  };
}
413935
function loadIncludes() {
  for ( var module in reqModules ) {
    if ( module && module != 'pong-tableXX' ) { // just to exclude modules, for debugging it's better to include them hardcoded in index.html

      // extra CSS files
      if ( moduleMap[ module ] ) {
        if ( moduleMap[ module ].css ) {
          for ( var i = 0; i < moduleMap[ module ].css.length; i++ ) {
            log( 'loadModules', module+' add extra CSS: '+modulesPath+module+'/'+moduleMap[ module ].css[i]  );
            jQuery('head').append('<link rel="stylesheet" rel="nofollow" href="'+modulesPath+module+'/'+moduleMap[ module ].css[i] +'" type="text/css" />');
          }
        }
      
        // include files
        if ( moduleMap[ module ].include ) {
          for ( var i = 0; i < moduleMap[ module ].include.length; i++ ) {
            //for ( var includeJS in moduleMap[ module ].include ) {
            var includeJS = moduleMap[ module ].include[i];
            log( 'loadModules', module+' load include: '+modulesPath+module+'/'+includeJS );
            ajaxOngoing++;
              $.getScript( modulesPath+module+'/'+includeJS )
              .done( function( script, textStatus, jqxhr ) { 
                log( 'loadModules', this.url+' '+textStatus ); ajaxOngoing--; } )
              .fail( function( jqxhr, settings, exception ) { 
                log( 'loadModules', this.url+' '+exception ); ajaxOngoing--; }  );
          }
        }
      }
    }
  }
  ajaxOngoing--;
}
382422
function withOptions(defaults) {

  // closure for a @use/it instance with provided `defaults`.
  // `plugin` is a string (path or package name), function, or an array of either.
  // `options` is an object.
  // `root` is the location (__dirname) of the script calling use()
  // allowing us to determine the correct path for require()'ing
  // a local plugin path.
  return function use(plugin, options, root) {

    // this holds the combined options/defaults.
    var opts

    // if we received an array then flatten it and call ourself on each.
    if (Array.isArray(plugin)) {

      plugin = flatten([plugin])

      for (var el of plugin) {
        this.use(el, options, root)
      }

      // return because we called this function on each array element.
      return
    }

    // if there are `options` then try to combine them with `defaults`
    // or create a copy of it.
    if (options) {
      if (defaults) {
        opts = Object.assign({}, defaults, options)
      }

      else {
        opts = Object.create(options)
      }
    }

    // otherwise, copy the defaults (which may be null).
    else {
      opts = Object.create(defaults)
    }

    // if the plugin is a package name or path to a file then we require() it.
    if (typeof(plugin) === 'string') {

      // if it starts with a dot and there's a `root` then join them
      if (plugin[0] === '.' && root) {
        plugin = join(root, plugin)
      }

      // now try to require the plugin function and call it with this @use/it
      // instance and the options (`opts`).
      try {
        // also, return the result which may contain an error result.
        return require(plugin).call(this, opts, this)
      } catch(error) {
        return {error: 'failed to require and call plugin', plugin: plugin, opts: opts}
      }
    }

    // otherwise, if it's a function then skip the require() and call it.
    else if (typeof(plugin) === 'function') {
      return plugin.call(this, opts, this)
    }

    // lastly, we didn't get a string or function so return an error.
    else {
      return { error: 'plugin must be string, function, or array', plugin: plugin }
    }
  }
}
604861
function importPlugin(pluginRules, pluginName) {
		Object.keys(pluginRules).forEach(function(ruleId) {
			var qualifiedRuleId = pluginName + "/" + ruleId,
				rule = pluginRules[ruleId];

			define(qualifiedRuleId, rule);
		});
	}
566895
function plugin(opts) {
  opts = objectAssign({
    modulesDirectory: 'dist/node_modules',
    modulesManifestPath: 'dist/require-modules.json',
    dist: true,
    fromDirectory: 'src',
    distDirectory: 'dist'
  }, opts);

  return through.obj(function (file, enc, cb) {
    if (file.isStream()) {
      this.emit('error', new PluginError(PLUGIN_NAME, 'Streams are not supported!'));
      return cb();
    }
    if (file.isBuffer()) {
      var modulesDirectory = path.join(process.cwd(), opts.modulesDirectory);
      var modulesManifestPath = path.join(process.cwd(), opts.modulesManifestPath);
      var distDirectory = opts.distDirectory;

      // get old modulesManifest
      if (fs.existsSync(modulesManifestPath)) {
        var data = fs.readFileSync(modulesManifestPath, 'utf8');
        modulesManifest = JSON.parse(data);
      } else {
        dirname = path.dirname(modulesManifestPath);
        fs.mkdirsSync(dirname);
      }

      var filePath = file.path;
      var contents = file.contents.toString();

      // the path where this file will be disted to
      var distFilePath = filePath;
      if (distDirectory) {
        var cwd = path.join(process.cwd());
        var relativePath = path.relative(path.join(cwd, opts.fromDirectory || ''), filePath);
        var distFilePath = path.join(process.cwd(), distDirectory, relativePath);
      }
      var distFileDirname = path.dirname(distFilePath);

      // modules
      var modules = getModules(contents);
      for (var index in modules) {
        var module = modules[index];

        var modulePath = path_util.modulePath(module, node_modules);
        if (modulePath === null) {
          continue;
        }
        var targetPath = path_util.targetPath(modulePath, node_modules, modulesDirectory);

        if (!modulesManifest.hasOwnProperty(module)) {
          var relativePath = path.relative(process.cwd(), targetPath);
          modulesManifest[module] = relativePath;

          if (!fs.existsSync(targetPath)) {
            transformFile(modulePath, targetPath, modulesDirectory);
          }
        }

        if (opts.dist) { // replace modules with path
          var relativePath = path_util.relativePath(distFileDirname, targetPath);
          var re = eval('\/require\\\(\[\'\"\]' + module + '\[\'\"\]\\\)\/ig');
          contents = contents.replace(re, 'require(\'' + relativePath + '\')');
        }
      }

      // subModules
      var subModules = getSubModules(contents);
      for (var index in subModules) {
        var subModule = subModules[index];
        var subModulePath = path_util.subModulePath(subModule, node_modules);
        if (subModulePath === null) {
          continue;
        }
        var targetPath = path_util.targetPath(subModulePath, node_modules, modulesDirectory);

        if (!modulesManifest.hasOwnProperty(subModule)) {
          var relativePath = path.relative(process.cwd(), targetPath);
          modulesManifest[subModule] = relativePath;

          if (!fs.existsSync(targetPath)) {
            transformFile(subModulePath, targetPath, modulesDirectory);
          }
        }

        if (opts.dist) { // replace modules with path
          var relativePath = path_util.relativePath(distFileDirname, targetPath);
          var subModuleRegex = subModule.replace('/', '\\\/');
          var subModuleRegex = subModuleRegex.replace('.', '\\\.');
          var re = 'require\\\(\[\'\"\]' + subModuleRegex + '\[\'\"\]\\\)';
          var regex = new RegExp(re, 'ig');
          contents = contents.replace(regex, 'require(\'' + relativePath + '\')');
        }
      }
      file.contents = Buffer.from(contents);
      fs.writeFileSync(modulesManifestPath, JSON.stringify(modulesManifest, null, 2), 'utf8');
    }

    // go to next gulp plugin
    this.push(file);
    cb();
  });
}
813227
function (plugin) {
    /* global module:false, define:false */

    if (typeof require === "function" &&
        typeof exports === "object" &&
        typeof module === "object") {
      // NodeJS
      module.exports = plugin;

    } else if (typeof define === "function" && define.amd) {
      // AMD: Assumes importing `chai` and `jquery`. Returns a function to
      //      inject with `chai.use()`.
      //
      // See: https://github.com/chaijs/chai-jquery/issues/27
      define(["jquery"], function ($) {
        return function (chai, utils) {
          return plugin(chai, utils, $);
        };
      });

    } else {
      // Other environment (usually <script> tag): plug in to global chai
      // instance directly.
      root.chai.use(function (chai, utils) {
        return plugin(chai, utils, root.jQuery);
      });
    }
  }
386203
protected function _includeComponents(): void
    {
        // for now, we just include all components
        $appComponentFolder = WWW_ROOT . 'js/app/components/';
        $folder = new Folder($appComponentFolder);
        $files = $folder->find('.*\.js');
        if (!empty($files)) {
            foreach ($files as $file) {
                $this->_dependencies[] = 'app/components/' . $file;
            }
        }

        // Add Plugin Components
        foreach (Plugin::loaded() as $pluginName) {
            $pluginJsComponentsFolder = Plugin::path($pluginName) . '/webroot/js/app/components/';
            if (is_dir($pluginJsComponentsFolder)) {
                $folder = new Folder($pluginJsComponentsFolder);
                $files = $folder->find('.*\.js');
                foreach ($files as $file) {
                    $this->_dependencies[] = '/' . Inflector::underscore($pluginName) . '/js/app/components/' . $file;
                }
            }
        }
    }
646155
function (allMods) {
            var self = this,
                comboUrls,
                timeout = Config.timeout;

            comboUrls = self.getComboUrls(allMods);

            // load css first to avoid page blink
            if (comboUrls.css) {
                loadScripts(comboUrls.css, function (success, error) {
                    if ('@DEBUG@') {
                        debugRemoteModules(success);
                    }

                    each(success, function (one) {
                        each(one.mods, function (mod) {
                            addModule(mod.name, Utils.noop);
                            // notify all loader instance
                            mod.flush();
                        });
                    });

                    each(error, function (one) {
                        each(one.mods, function (mod) {
                            var msg = mod.name + ' is not loaded! can not find module in url: ' + one.url;
                            S.log(msg, 'error');
                            mod.status = ERROR;
                            // notify all loader instance
                            mod.flush();
                        });
                    });
                }, timeout);
            }

            // jss css download in parallel
            if (comboUrls.js) {
                loadScripts(comboUrls.js, function (success) {
                    if ('@DEBUG@') {
                        debugRemoteModules(success);
                    }

                    each(comboUrls.js, function (one) {
                        each(one.mods, function (mod) {
                            // fix #111
                            // https://github.com/kissyteam/kissy/issues/111
                            if (!mod.factory) {
                                var msg = mod.name +
                                    ' is not loaded! can not find module in url: ' +
                                    one.url;
                                S.log(msg, 'error');
                                mod.status = ERROR;
                            }
                            // notify all loader instance
                            mod.flush();
                        });
                    });
                }, timeout);
            }
        }
1002416
function parser (inputs, output, plugins, cb) {
  var data = {
    charset: 'UTF-8',
    headers: DEFAULT_HEADERS,
    translations: {
      context: {}
    }
  }

  var defaultContext = data.translations.context

  var headers = data.headers
  headers['plural-forms'] = headers['plural-forms'] || DEFAULT_HEADERS['plural-forms']
  headers['content-type'] = headers['content-type'] || DEFAULT_HEADERS['content-type']

  var nplurals = /nplurals ?= ?(\d)/.exec(headers['plural-forms'])[1]

  inputs
    .forEach(function (file) {
      var resolvedFilePath = path.join(process.cwd(), file)
      var src = fs.readFileSync(resolvedFilePath, 'utf8')

      try {
        var ast = babelParser.parse(src, {
          sourceType: 'module',
          plugins: ['jsx'].concat(plugins)
        })
      } catch (e) {
        console.error(`SyntaxError in ${file} (line: ${e.loc.line}, column: ${e.loc.column})`)
        process.exit(1)
      }

      walk.simple(ast.program, {
        CallExpression: function (node) {
          if (functionNames.hasOwnProperty(node.callee.name) ||
            node.callee.property && functionNames.hasOwnProperty(node.callee.property.name)) {
            var functionName = functionNames[node.callee.name] || functionNames[node.callee.property.name]
            var translate = {}

            var args = node.arguments
            for (var i = 0, l = args.length; i < l; i++) {
              var name = functionName[i]

              if (name && name !== 'count' && name !== 'domain') {
                var arg = args[i]
                var value = arg.value

                if (value) {
                  var line = node.loc.start.line
                  translate[name] = value
                  translate['comments'] = {
                    reference: file + ':' + line
                  }
                }

                if (name === 'msgid_plural') {
                  translate.msgstr = []
                  for (var p = 0; p < nplurals; p++) {
                    translate.msgstr[p] = ''
                  }
                }
              }
            }

            var context = defaultContext
            var msgctxt = translate.msgctxt

            if (msgctxt) {
              data.translations[msgctxt] = data.translations[msgctxt] || {}
              context = data.translations[msgctxt]
            }

            context[translate.msgid] = translate
          }
        }
      })
    })

  fs.writeFile(output, gettextParser.po.compile(data), function (err) {
    if (err) {
      cb(err)
    }
    cb(null)
  })
}
1012874
function Plugin(script, _interface, options) {
  this._script = script
  this._options = options || {}
  this._initialInterface = _interface || {}
  this._connect()
}
673302
function providePlugins(code) {
  var chunks = [];
  if (typeof code === 'string') {
    code = code.split('\n');
  }
  chunks.push("function (" + Object.keys(plugins).join(', ') + ") {");
  chunks.push("  return " + code[0]);

  code.forEach(function (line, index) {
    if (index === 0) return; // omit the first line
    chunks.push("  " + line);
  });
  chunks.push("}");
  return chunks;
}
1300214
function joinNodeModules(jsPaths){
    _.each(jsPaths, function(jsPath){
      var libPath = path.join(nodeModules, jsPath),
          flattenedLibPath = path.join(flattenedNodeModules, jsPath);

      if (fs.existsSync(libPath)) {
        defaultScripts.push(libPath);
      } else if (fs.existsSync(flattenedLibPath)) {
        defaultScripts.push(flattenedLibPath);
      } else {
        console.error('Could not find ' + jsPath);
      }
    });
  }
523984
def get_plugin_modules(plugins):
    
    if not plugins:
        raise MissingPluginNames("input plugin names are required")

    modules = []

    for plugin in plugins:
        short_name = PLUGIN_MAPPING.get(plugin.lower(), plugin.lower())
        full_path = '%s%s' % (module_prefix, short_name)
        modules.append(importlib.import_module(full_path))

    return tuple(modules)
767840
function bootstrap(bootstrapModules) {

  var modules = [],
      components = [];

  function hasModule(m) {
    return modules.indexOf(m) >= 0;
  }

  function addModule(m) {
    modules.push(m);
  }

  function visit(m) {
    if (hasModule(m)) {
      return;
    }

    (m.__depends__ || []).forEach(visit);

    if (hasModule(m)) {
      return;
    }

    addModule(m);

    (m.__init__ || []).forEach(function(c) {
      components.push(c);
    });
  }

  bootstrapModules.forEach(visit);

  var injector = new Injector(modules);

  components.forEach(function(c) {

    try {
      // eagerly resolve component (fn or string)
      injector[typeof c === 'string' ? 'get' : 'invoke'](c);
    } catch (e) {
      console.error('Failed to instantiate component');
      console.error(e.stack);

      throw e;
    }
  });

  return injector;
}
796522
function Module(id, parent) {
  this.id = id
  this.parent = parent;
  if (parent && parent.children) {
    parent.children.push(this);
  }
  this.children = [];
  
  this.filename = null;
  this.format = undefined;
  this.loaded = false;
}
351150
function plugin(params) {
	logger = params.logger;
	params.dirname = params.dirname ? _.template(params.dirname)(params) : params.event.dir.resourcesPlatform;
	logger.trace("fixing underscore in directory: " + params.dirname);

	replace_content(path.join(params.dirname, "alloy.js"))
	replace_content(path.join(params.dirname, "alloy", "sync", "properties.js"))
	replace_content(path.join(params.dirname, "alloy", "sync", "sql.js"))
}