How to use loadedPluginModules method in stryker-parent

Best JavaScript code snippet using stryker-parent

PlatformPluginRegistry.js

Source:PlatformPluginRegistry.js Github

copy

Full Screen

1define(["dojo/_base/declare",2 "dojo/_base/lang",3 "dojo/_base/array", 4 "dojo/has",5 "dojo/when",6 "dojo/aspect",7 "dojo/Deferred",8 "dojo/Stateful",9 "dojo/io-query",10 "dijit/_WidgetBase",11 "./util",12 "./string",13 "./multichannel" 14 ], function(dDeclare, dLang, dArray, dHas, dWhen, dAspect, dDeferred, dStateful, dIOQuery, dWidgetBase, iUtil, iString, iMultichannel){15 16 // bootstrap the dojo/has settings to ensure "mobile" is set if "tablet" or "phone" is set17 if ((dHas("tablet")||dHas("phone"))&&(!dHas("mobile"))) {18 dHas.add("mobile", function() { return true; } );19 }20 21 // map of all plugin registries by module name22 var registries = {};23 24 // map of module names to maps of platform names to plugin module names25 var pluginModuleNames = {};26 27 // map of module names to maps of platform names to promises for loaded plugin modules28 var pluginModules = {};29 30 // map of module names to maps of platform names to promises for created plugins31 var plugins = {};32 33 // array of all platforms34 var platforms = [ "desktop", "tablet", "phone" ];35 36 // mapping of platform names to possible plugins in precedence37 var platformFallbacks = {38 "desktop": [ "tablet", "phone" ],39 "tablet": [ "phone", "desktop" ],40 "phone": [ "tablet", "desktop" ]41 };42 43 // the "auto" platform as determined by "dojo/has" and "idx/multichannel"44 //var autoPlatform = (dHas("tablet")?"tablet":(dHas("phone")?"phone":(dHas("mobile")?"phone":"desktop")));45 //if (!dHas(autoPlatform)) dHas.add(autoPlaform, function() { return true; } );46 47 var autoPlatform = iMultichannel.getRuntimePlatform();48 49 // the default plugins for registries50 var defaultPlatforms = {};51 52 // create an internal stateful instance to maintain the platform property53 var GlobalPlatform = dDeclare([dStateful], {54 /**55 * The tartget platform.56 */57 targetPlatform: "desktop"58 });59 60 // the variable representing the selected platform (default to desktop)61 var globalPlatform = new GlobalPlatform();62 var doGlobalHas = true;63 64 // Returns the platform that will be used when a setting of "auto" is used for the65 // target platform settings.66 var getAutoPlatform = function() {67 return autoPlatform;68 };69 70 /**71 * Normalizes the specified platform. If empty or null, then null is returned.72 * If "auto" then the auto platform is returned. Otherwise, the platform is73 * checked to see if it is valid and then returned.74 * 75 * @param platform The platform to normalize.76 * @return The normalized platform.77 * @private78 */79 var normalizePlatform = function(platform) {80 // check if null81 platform = iString.nullTrim(platform);82 if (!platform) return null;83 84 // check if auto85 if (platform == "auto") return autoPlatform;86 87 // check if valid88 switch (platform) {89 case "desktop":90 case "tablet":91 case "phone":92 return platform;93 default: 94 throw "Invalid platform name: " + platform;95 }96 };97 // Returns the global default target platform.98 var getGlobalTargetPlatform = function() {99 return globalPlatform.get("targetPlatform");100 };101 102 // Sets the global target platform to the specified platform.103 // The possible values that it can be set to are "desktop", "tablet", "phone" or "auto".104 // The global target platform cannot be set to empty-string or null. By default, the 105 // global target platform is set to "desktop".106 var setGlobalTargetPlatform = function(platform) {107 // flag that widgets should be platform-plugable108 if (!dHas("platform-plugable")) dHas.add("platform-plugable", function() { return true; } );109 if (doGlobalHas) {110 doGlobalHas = false;111 var hasPlatform = normalizePlatform(platform);112 if (!dHas(hasPlatform)) dHas.add(hasPlatform, function() { return true; } );113 if ((hasPlatform == "tablet") || (hasPlatform == "phone")) {114 if (!dHas("mobile")) dHas.add("mobile", function() { return true; } );115 iMultichannel.updateGlobalTheme(["mobile"]);116 }117 118 }119 120 var targetPlatform = iString.nullTrim(platform);121 if (!targetPlatform) {122 throw "Global target platform setting cannot be empty or null: " + platform;123 }124 switch (platform) {125 case "desktop":126 case "tablet":127 case "phone":128 case "auto":129 // do nothing130 break;131 default:132 throw "Illegal platform setting for global target platform: " + platform; 133 }134 globalPlatform.set("targetPlatform", targetPlatform);135 };136 /**137 * Verifies that the specified platform is valid strips it of white space.138 * 139 * @param platform The platform to verified.140 * @return The verified platform.141 * @private142 */143 var verifyPlatform = function(platform) {144 // check if null145 platform = iString.nullTrim(platform);146 if (!platform) {147 throw "Invalid platform name: " + platform;148 }149 150 // check if auto151 if (platform == "auto") return platform;152 153 // check if valid154 switch (platform) {155 case "desktop":156 case "tablet":157 case "phone":158 return platform;159 default: 160 throw "Invalid platform name: " + platform;161 }162 };163 164 /**165 * @name idx.PlatformPluginRegistry166 * @class Provides a registry for platform-specific plugins for 167 * implementing multi-channel widgets based on a module name.168 * Plugin registries are created via the static "register" 169 * method rather than by constructing them. In fact, constructed170 * instances will not function if they were not created by the171 * "register" function.172 * @example173 * define(["idx/PlatformPluginRegistry"], function(MPR) {174 * var registry = MPR.register("idx/app/Header");175 * ...176 * }); 177 */178 var thisModule = dDeclare("idx/PlatformPluginRegistry", [dStateful], 179 /** @lends idx.PlatformPluginRegistry */180 {181 /**182 * The name of the module for which the registry exists.183 */184 moduleName: "",185 186 /**187 * The target platform to be used by all widgets that leverage this registry.188 * The order of precedence for determining the target platform is first189 * widget specific, then registry-specific, then using the global platform.190 */191 targetPlatform: "",192 193 /**194 * Constructor.195 */196 constructor: function(args) {197 dLang.mixin(this, args);198 },199 200 /**201 * Asserts that this instance was created using the "register" function.202 * @private203 */204 _assertRegistered: function() {205 if ( this !== registries[this.moduleName]) {206 throw "Must use 'register' function to create "207 + "instances of PlatformPluginRegistry: " 208 + this.moduleName;209 }210 },211 212 /**213 * Normalizes the platform name.214 * @param platform The platform name (e.g.: "desktop", "tablet", "phone", or "auto")215 * @return The normalized platform name (e.g.: "desktop", "tablet" or "phone")216 * @throws An error if the specified platform name is not recognized.217 * @private218 */219 _normalizePlatform: function(platform) {220 this._assertRegistered();221 return normalizePlatform(platform); 222 },223 224 /**225 * This is called when the target platform on this instance changes to 226 * determining if we need to notify widgets that leverage this registry.227 *228 * @param attrName This should be "targetPlatform"229 * @param oldPlatform The old value.230 * @param newPlatform The new value.231 * @private232 */233 _onTargetPlatformChange: function(attrName, oldPlatform, newPlatform) {234 // check if they normalize to the same value235 oldPlatform = this._normalizePlatform(oldPlatform);236 newPlatform = this._normalizePlatform(newPlatform);237 var globalPlatform = (!oldPlatform || !newPlatform) ? getGlobalTargetPlatform() : null;238 if (!oldPlatform) oldPlatform = globalPlatform;239 if (!newPlatform) newPlatform = globalPlatform;240 if (oldPlatform == newPlatform) return; // no change in platform241 242 // the platform has changed, get the plugin platforms243 var oldPluginPlatform = (oldPlatform ? this._getPluginPlatform(oldPlatform) : null);244 var newPluginPlatform = this._getPluginPlatform(newPlatform);245 246 // resolve the plugins247 var oldPlugin = (oldPluginPlatform ? this._getPlugin(oldPluginPlatform) : null);248 var newPlugin = this._getPlugin(newPluginPlatform);249 250 // call the onDefaultPlatformChange event handler251 this.onDefaultPlatformChange(this, oldPlatform, newPlatform, oldPlugin, newPlugin); 252 },253 /**254 * This method is called when the global platform changes.255 *256 * @param attrName This should be "targetPlatform"257 * @param oldPlatform The old value.258 * @param newPlatform The new value.259 * @private260 */261 _onGlobalTargetPlatformChange: function(attrName, oldPlatform, newPlatform) {262 // check if this registry has an overridden target platform, if so this does not matter263 var targetPlatform = this._normalizePlatform(this.targetPlatform);264 if (targetPlatform) return;265 266 this._onTargetPlatformChange(attrName, oldPlatform, newPlatform); 267 },268 269 /**270 * Tracks the specified requester for updates if it not already being tracked.271 * @param requester The requester to be tracked.272 */273 _trackRequester: function(requester) {274 if (!requester) return;275 if (requester._platformTracking === this) return;276 if (requester._platformTracking) {277 throw "A single widget cannot use more than one PlatformPluginRegistry: " + requester 278 + " / previousRegistry = " + requester._platformTracking.moduleName;279 }280 if (requester && ("_onDefaultPlatformChange" in requester) && (dLang.isFunction(requester._onDefaultPlatformChange))) {281 requester.own(dAspect.after(this, "onDefaultPlatformChange", dLang.hitch(requester, "_onDefaultPlatformChange"), true));282 } 283 },284 /**285 * Returns the actual platform that will be used when the "auto" platform setting is employed.286 * This will return one of "desktop", "tablet" or "phone".287 *288 * @return The platform that the "auto" platform resolves to.289 */290 getAutoPlatform: function() {291 return getAutoPlatform();292 },293 294 /**295 * Obtains the global default platform that is being used as the default across all registries.296 * 297 * @param requester The optional reference to the requesting widget for tracking of changes.298 */299 getGlobalTargetPlatform: function(requester) {300 this._trackRequester(requester);301 return getGlobalTargetPlatform();302 },303 304 /**305 * Sets the global default program that is used as the default across all registries.306 * 307 * @param platform The platform to set as the global default (e.g.: "desktop", "tablet",308 * "phone" or "auto")309 */310 setGlobalTargetPlatform: function(platform) {311 setGlobalTargetPlatform(platform);312 },313 314 /**315 * This method is called when the global platform changes.316 * 317 * @param registry The PlatformPluginRegistry.318 * @param oldPlatform The old platform.319 * @param newPlatform The new platform.320 * @param oldPlugin The old plugin.321 * @param newPlugin The new plugin (which may be the same).322 */323 onDefaultPlatformChange: function(registry, oldPlatform, newPlatform, oldPlugin, newPlugin) {324 // do nothing -- this is an event handler that requesters are attached to 325 },326 327 /**328 * Sets the target platform for all widgets using this registry to the specified platform.329 * If this changes the underlying plugin then an event will be fired to all widgets330 * leveraging that plugin. The platform can be set to "auto", "desktop", "tablet" or331 * "phone" or can be set to null or empty-string to indicate that the global target platform332 * setting should be used instead. Usually, the global setting is the one used.333 *334 * @param targetPlatform The new target platform.335 */336 _setTargetPlatformAttr: function(targetPlatform) {337 this._assertRegistered();338 this.targetPlatform = targetPlatform;339 targetPlatform = normalizePlatform(targetPlatform);340 this._targetPlatform = (targetPlatform ? targetPlatform : "");341 },342 343 /**344 * Returns the target platform that is set as the registry's default target platform.345 * This method returns null if the target platform is set to empty string.346 *347 * @return The target platform set as the registry default.348 */349 _getTargetPlatformAttr: function() {350 this._assertRegistered();351 return iString.nullTrim(this._targetPlatform);352 },353 354 /**355 * Determines the target platform to use given the optionally specified widget-specific356 * target platform. If the specified target platform is a valid non-empty string then it357 * is used. If not, then an attempt is made to use the 358 */359 resolveTargetPlatform: function(requester) {360 // track the requester361 this._trackRequester(requester);362 363 // normalize the platform364 var targetPlatform = (requester ? this._normalizePlatform(requester.get("targetPlatform")) : null);365 366 // if not null then use it367 if (targetPlatform) return targetPlatform;368 369 // try the registry default platform370 targetPlatform = this._normalizePlatform(this.get("targetPlatform"));371 372 // if not null then use it373 if (targetPlatform) return targetPlatform;374 375 // use the global default platform376 return this._normalizePlatform(globalPlatform.get("targetPlatform"));377 },378 379 /**380 * Returns the name for the specified requesting requester that implements381 * _PlatformPlugableMixin. If no requester is specified then the registry default382 * platform is resolved.383 *384 * @requester The optional reference to the requesting widget.385 *386 * @return The name for the plugin module. 387 *388 */389 getPluginModuleName: function(requester) {390 // normalize the platform391 var platform = this.resolveTargetPlatform(requester);392 393 // call the internal function394 return this._getPluginModuleName(platform); 395 },396 397 398 /**399 * Internal version of "getPluginModuleName" that does not normalize the platform name.400 * @private401 */402 _getPluginModuleName: function(platform) {403 var map = pluginModuleNames[this.moduleName];404 return map[platform];405 },406 407 /**408 * Returns the promise for the plugin module for the optionally specified requesting409 * widget that typically implements _PlatformPlugableMixin. If no requester is specified410 * then the registry default platform is used to resolve the plugin module.411 *412 * @requester The optional reference to the requesting widget.413 *414 * @return The promise for resolving the loaded plugin module. 415 */416 getPluginModule: function(requester) {417 // normalize the platform418 var platform = this.resolveTargetPlatform(requester);419 420 // call the internal function421 return this._getPluginModule(platform); 422 },423 424 /**425 * Determines which platform to use for resolving the426 * plugin module using fallbacks when a widget may not427 * implement plugins for every platform.428 */429 _getPluginPlatform: function(platform) { 430 // get the map of module name to plugin modules431 var map = pluginModules[this.moduleName];432 var index = 0;433 var fallback = null;434 435 // check if the platform is known436 if (! (platform in map)) {437 // not known, get the fall-back platforms438 var fallbacks = platformFallbacks[platform];439 440 // loop through fallbacks441 for (index = 0; index < fallbacks.length; index++) {442 // check if this fallback is known443 if (fallbacks[index] in map) {444 fallback = fallbacks[index];445 break;446 }447 }448 if (!fallback) {449 throw "No plugin available for specified platform: " + platform;450 }451 452 // set the platform to the fallback453 platform = fallback;454 }455 // return the platform456 return platform; 457 },458 459 /**460 * Internal version of "getPluginModule" that does not normalize the platform name.461 * @private462 */463 _getPluginModule: function(platform, sync) {464 // get the map of module name to plugin modules465 platform = this._getPluginPlatform(platform);466 467 // get the plugin modules map468 var map = pluginModules[this.moduleName];469 470 // lookup the plugin module for the platform471 var modulePromise = map[platform];472 473 // check if null474 if (!modulePromise) {475 // create a deferred476 modulePromise = new dDeferred();477 478 // record it in the module map for future use479 map[platform] = modulePromise;480 481 // get the module name482 var moduleName = this._getPluginModuleName(platform);483 484 try {485 if (sync) {486 // require the module using synchronous loading487 require({async: false}, [moduleName], function(pluginModule) {488 modulePromise.resolve(pluginModule);489 });490 } else {491 // require the module using default async setting492 require([moduleName], function(pluginModule) {493 modulePromise.resolve(pluginModule);494 }); 495 }496 } catch (e) {497 console.log("Failed to load plugin module for " + platform + " platform: " + this.moduleName);498 modulePromise.reject(e);499 }500 }501 502 // return the module promise503 return modulePromise;504 },505 506 /**507 * Returns a promise that will resolve to the global plugin instance508 * for the optionally specified requester that typically implements _PlatformPlugableMixin.509 * If no requester is specified then the registry default platform will be510 * resolved for obtaining the plugin promise.511 *512 * This method will execute synchronously if the specified requester has not yet had its513 * startup() function called (i.e.: requester._started !== true). Further, if the 514 * optional second parameter for "forceSync" is set to true, then it will be synchronous.515 *516 * @requester The optional reference to the requesting widget.517 * @forceSync The optional parameter force synchrnous behavior. This may be the only518 * parameter if the requester is not provided so long as the value provided519 * for the first parameter is true or false.520 *521 * @return The instance of the appropriate plugin to be used. 522 */523 getPlugin: function(requester, forceSync) {524 if (arguments.length === 0) {525 requester = null;526 forceSync = false;527 528 } else if ((arguments.length == 1) && (requester !== undefined) && ((requester === true) || (requester === false))) {529 forceSync = requester;530 }531 if (forceSync === undefined) forceSync = false;532 if (forceSync !== true) forceSync = false;533 534 // determing the platform535 var platform = this.resolveTargetPlatform(requester);536 537 // check if we should be making this request synchronously538 var sync = false;539 if (requester && ("instanceOf" in requester) 540 && (dLang.isFunction(requester.instanceOf)) && requester.instanceOf(dWidgetBase)) {541 sync = (!forceSync && requester._started) ? false : true;542 }543 544 // call the internal function545 return this._getPlugin(platform, sync);546 },547 548 /**549 * Internal version of "getPlugin" that does not normalize the specified platform name.550 * @private551 */552 _getPlugin: function(platform, sync) {553 // get the map of module name to plugins554 var map = plugins[this.moduleName];555 556 // lookup the plugin for the platform557 var pluginPromise = map[platform];558 559 // check if null560 if (!pluginPromise) {561 // create a deferred562 pluginPromise = new dDeferred();563 564 // record it in the plugin map for future use565 map[platform] = pluginPromise;566 567 // create the plugin568 try {569 var modulePromise = this._getPluginModule(platform, sync);570 dWhen(modulePromise, function(pluginModule) {571 var plugin = null;572 // check if we are using the inherited base class as the plugin573 // for this platform574 if (dLang.isString(pluginModule) && (pluginModule == "inherited")) {575 // an empty plugin forces inherited behavior576 plugin = {};577 } else {578 // create a plugin instance from the module579 plugin = new pluginModule();580 }581 pluginPromise.resolve(plugin);582 });583 } catch (e) {584 console.log("Failed to load plugin module for " + platform + " platform: " + this.moduleName);585 pluginPromise.reject(e);586 }587 }588 589 // return the promise590 return pluginPromise;591 }592 }); 593 594 /**595 * @public596 * @function597 * @name idx.PlatformPluginRegistry.setAutoPlatform598 * @description Returns the platform that will be used when a setting of "auto" is used for the599 * target platform settings.600 */601 thisModule.getAutoPlatform = getAutoPlatform;602 603 /**604 * @public605 * @function606 * @name idx.PlatformPluginRegistry.setGlobalPlatform607 * @description Returns the global default target platform. The possible return values are608 * "desktop", "tablet", "phone" or "auto". The global target platform will never609 * be empty-string or null. By default, the global target platform is set to "desktop".610 * @return The global default target platform.611 */612 thisModule.getGlobalTargetPlatform = getGlobalTargetPlatform;613 614 /**615 * @public616 * @function617 * @name idx.PlatformPluginRegistry.setGlobalPlatform618 * @description Sets the global target platform to the platform obtained from the URL query parameters619 * of optionally specified URL (or the current page's URL if not specified) using the620 * "platform" parameter from the query string (or the optionally specified parameter name621 * if provided).622 * @param paramName The optional parameter name for extracting the platform from the query string.623 * If not specified, then "platform" is used.624 * @param url The optional URL from which to extract the platform. If not specified then 625 * document.location.href is used.626 */627 thisModule.setGlobalTargetPlatformFromURL = function(paramName, url) {628 // default the optional parameters629 if (!paramName) paramName = "platform";630 if (!url) url = "" + document.location.href;631 632 var split = url.indexOf("?");633 var queryString = null;634 if ((split >= 0) && (split < url.length - 1)) {635 queryString = url.substring(split+1, url.length);636 }637 var params = null;638 if (queryString) {639 params = dIOQuery.queryToObject(queryString);640 }641 var platform = "auto";642 if (params && ("platform" in params) && (params.platform)) {643 switch (params.platform) {644 case "desktop":645 case "tablet":646 case "phone":647 case "auto":648 platform = params.platform;649 break;650 case "default":651 console.log("USING NON-PLUGABLE IMPLEMENTATION");652 platform = null;653 break;654 default: 655 console.log("UNRECOGNIZED PLATFORM IN URL: " + params.platform);656 break;657 }658 }659 if (platform) {660 thisModule.setGlobalTargetPlatform(platform);661 }662 };663 664 /**665 * @public666 * @function667 * @name idx.PlatformPluginRegistry.setGlobalPlatform668 * @description Sets the global target platform to the specified platform.669 * The possible values that it can be set to are "desktop", "tablet", "phone" or "auto".670 * The global target platform cannot be set to empty-string or null. By default, the 671 * global target platform is set to "desktop".672 * @param platform The platform to set as the global default target platform (i.e.: "desktop",673 * "tablet", "phone" or "auto").674 */675 thisModule.setGlobalTargetPlatform = setGlobalTargetPlatform;676 677 /**678 * @public679 * @function680 * @name idx.PlatformPluginRegistry.register681 * @description Creates a plugin registry for the specified module name. Note, when specifying682 * the "loadedPluginModules" or "customPluginNames" parameters, the psuedo-platform of "mobile"683 * can be used to set a default plugin or plugin module name (respectively) for both tablet and684 * phone platforms if not otherwise specified. 685 * @param baseModuleName The name of the master module that will use the plugins. The names686 * of the plugin modules will be inferred from this if not provided.687 * @param loadedPluginModules A map of valid platform names (e.g.: "desktop", "tablet" or "phone") to688 * plugin modules that have already been loaded. Typically this contains689 * null values for unloaded plugin modules and a real value for the default690 * platform module. If a field is missing from this object then it is 691 * assumed that such a plugin does not exist for that widget.692 * @param customPluginNames A map of valid platform names (e.g.: "desktop", "tablet" or "phone") to693 * the names for finding and loading the plugin modules. This is optional and694 * if not provided, the names are inferred from the base module name.695 * @return The PlatformPluginRegistry that was just created or previously created for the specified696 * base module name.697 */698 thisModule.register = function(baseModuleName, loadedPluginModules, customPluginNames) {699 // unset the doGlobalHas flag to prevent further "has" settings700 doGlobalHas = false;701 702 // check if the registry has already been created703 var registry = registries[baseModuleName];704 if (registry) {705 console.warn("Attempt to register a PlatformPluginRegistry that has already been "706 + "registered: " + baseModuleName);707 return registry;708 }709 // prepare to create the registry710 var registryArgs = {moduleName: baseModuleName};711 712 // determine if we already have a default platform713 if (baseModuleName in defaultPlatforms) {714 console.log("SETTING DEFAULT PLATFORM FOR " + baseModuleName + " TO " + defaultPlatforms[baseModuleName]);715 registryArgs.targetPlatform = defaultPlatforms[baseModuleName];716 }717 718 // create the registry719 registry = new thisModule(registryArgs);720 721 // save the registry722 registries[baseModuleName] = registry;723 724 // determine the plugin module names725 var names = pluginModuleNames[baseModuleName] = {};726 var modules = pluginModules[baseModuleName] = {};727 plugins[baseModuleName] = {};728 729 var index = baseModuleName.lastIndexOf("/");730 if ((index < 0) || (index == baseModuleName.length -1)) {731 throw "Invalid base module name: " + baseModuleName;732 }733 var prefix = baseModuleName.substring(0, index+1);734 var suffix = baseModuleName.substring(index+1);735 var deferred = null;736 var upperPlatformName = null;737 738 dArray.forEach(platforms, function(platform) {739 // determing the plugin name740 var pluginName = null;741 742 // mark the field so that we at least know it exists743 if (loadedPluginModules && (platform in loadedPluginModules)) {744 modules[platform] = null;745 }746 747 if ((customPluginNames) && (platform in customPluginNames) && (customPluginNames[platform])) {748 // a name is provided and it is defined and not null749 pluginName = customPluginNames[platform];750 } else if ((customPluginNames) && (platform in customPluginNames) && (!customPluginNames[platform])) {751 // a name is provided and it is either null or undefined, use the default naming752 pluginName = prefix + "/plugins/" + platform + "/" + suffix + "Plugin"; 753 754 } else if ((platform != "desktop") && (customPluginNames) && ("mobile" in customPluginNames) && (customPluginNames["mobile"])) {755 // an actual defined non-null module name is provided for mobile, use it756 pluginName = customPluginNames["mobile"];757 } else if ((platform != "desktop") && (customPluginNames) && ("mobile" in customPluginNames) && (!customPluginNames["mobile"])) {758 // an undefined or null name is provided for the mobile platform, use the default "mobile" naming759 pluginName = prefix + "/plugins/mobile/" + suffix + "Plugin";760 761 } else {762 // no custom names have been provided or at least none for this platform -- check if the763 // default name should use "mobile" naming convention for mobile platforms764 if ((platform != "desktop") && (loadedPluginModules) && ("mobile" in loadedPluginModules)765 && (!(platform in loadedPluginModules))) {766 // use the mobile module naming convention because the specific mobile platform is 767 // missing from the loaded plugin map, but the "mobile" psuedo-platform is specified768 pluginName = prefix + "/plugins/mobile/" + suffix + "Plugin";769 770 } else {771 // use the standard naming convention since either this is not a mobile platform or 772 // no "mobile" variant was specified773 pluginName = prefix + "/plugins/" + platform + "/" + suffix + "Plugin"; 774 }775 }776 names[platform] = pluginName; 777 778 // check if the module is already loaded779 if ((loadedPluginModules) && (loadedPluginModules[platform])) {780 // the platform has a specific loaded module781 deferred = modules[platform] = new dDeferred();782 deferred.resolve(loadedPluginModules[platform]);783 784 } else if ((platform != "desktop") && (loadedPluginModules) && (loadedPluginModules["mobile"])) {785 // check if using "mobile" plugin module as a default for tablet or phone platforms786 deferred = modules[platform] = new dDeferred();787 deferred.resolve(loadedPluginModules["mobile"]);788 }789 });790 globalPlatform.watch("targetPlatform", dLang.hitch(registry, "_onGlobalTargetPlatformChange"));791 registry.watch("targetPlatform", dLang.hitch(registry, "_onTargetPlatformChange"));792 793 // return the registry794 return registry;795 };796 797 /**798 * @public799 * @function800 * @name idx.PlatformPluginRegistry.setRegistryDefaultPlatform801 * @description Sets the default platform for a registry even BEFORE it is created.802 * A warning is issued if this is called AFTER the register has been created803 * and registered since this method will have no effect in such a case.804 * @param baseModuleName The name of the master module with which the registry is associated.805 * @param defaultPlatform The name of the default platform for the associated registry once806 * it becomes registered (e.g.: "desktop", "tablet", "phone" or "auto").807 */808 thisModule.setRegistryDefaultPlatform = function(baseModuleName, defaultPlatform) {809 // flag that widgets should be platform-plugable810 if (!dHas("platform-plugable")) dHas.add("platform-plugable", function() { return true; } );811 812 // verify the platform name813 defaultPlatform = verifyPlatform(defaultPlatform);814 815 // check if the registry has already been created816 var registry = registries[baseModuleName];817 if (registry) {818 console.warn("Attempt to set the default platform for a PlatformPluginRegistry "819 + "that has already been registered. This will have no effect: " + baseModuleName);820 return registry;821 }822 823 // set the default platform824 defaultPlatforms[baseModuleName] = defaultPlatform;825 826 // setup the dojo/has feature827 var featurePrefix = baseModuleName.replace(/\//g, "_") + "-";828 var featureSuffix = defaultPlatform;829 830 // add the dojo-has condition831 dHas.add(featurePrefix + defaultPlatform, function() { return true; });832 833 // add the "mobile" dojo-has for "tablet" and "phone" platforms834 if ((defaultPlatform == "tablet") || (defaultPlatform == "phone")) {835 dHas.add(featurePrefix + "mobile", function() { return true; });836 }837 };838 839 /**840 * @public841 * @function842 * @name idx.PlatformPluginRegistry.setRegistryTargetPlatform843 * @description Sets the target platform for a registry associated with the sepcified844 * module AFTER it has been created/registered by its associated module.845 * A warning is issued if this is called BEFORE the registry has been created846 * and registered since this method will have no effect in such a case.847 * @param baseModuleName The name of the master module with which the registry is associated.848 * @param targetPlatform The name of the target platform for the associated registry (e.g.: 849 * "desktop", "tablet", "phone" or "auto").850 */851 thisModule.setRegistryTargetPlatform = function(baseModuleName, targetPlatform) {852 // verify the platform name853 targetPlatform = normalizePlatform(targetPlatform);854 855 // check if the registry has already been created856 var registry = registries[baseModuleName];857 if (!registry) {858 console.warn("Attempt to set the target platform for a PlatformPluginRegistry "859 + "that has NOT yet been registered. This will have no effect: " + baseModuleName);860 return;861 }862 // set the target platform863 registry.set("targetPlatform", targetPlatform);864 };865 866 // return the module 867 return thisModule;...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var loadedPluginModules = require('stryker-parent').loadedPluginModules;2import { loadedPluginModules } from 'stryker-parent';3var loadedPluginModules = require('stryker').loadedPluginModules;4import { loadedPluginModules } from 'stryker';5var loadedPluginModules = require('stryker-api').loadedPluginModules;6import { loadedPluginModules } from 'stryker-api';7var loadedPluginModules = require('stryker').loadedPluginModules;8import { loadedPluginModules } from 'stryker';9var loadedPluginModules = require('stryker-api').loadedPluginModules;10import { loadedPluginModules } from 'stryker-api';11var loadedPluginModules = require('stryker').loadedPluginModules;

Full Screen

Using AI Code Generation

copy

Full Screen

1var loadedPluginModules = require('stryker-parent').loadedPluginModules;2var loadedModules = loadedPluginModules();3console.log('Loaded modules: ' + loadedModules.join(', '));4var plugin = {5 create: function (options) {6 return {7 init: function (done) {8 done();9 },10 run: function () {11 return Promise.resolve({12 });13 }14 };15 }16};17module.exports = plugin;18module.exports = function (config) {19 config.set({20 });21};22[Apache 2.0](LICENSE) © [Nico Jansen](

Full Screen

Using AI Code Generation

copy

Full Screen

1var loadedModules = require('stryker-parent').loadedPluginModules();2var loadedModules = require('stryker-parent').loadedPluginModules();3var loadedModules = require('stryker-parent').loadedPluginModules();4var loadedModules = require('stryker-parent').loadedPluginModules();5var loadedModules = require('stryker-parent').loadedPluginModules();6var loadedModules = require('stryker-parent').loadedPluginModules();7var loadedModules = require('stryker-parent').loadedPluginModules();8var loadedModules = require('stryker-parent').loadedPluginModules();9var loadedModules = require('stryker-parent').loadedPluginModules();10var loadedModules = require('stryker-parent').loadedPluginModules();11var loadedModules = require('stryker-parent').loadedPluginModules();12var loadedModules = require('stryker-parent').loadedPluginModules();13var loadedModules = require('stryker-parent').loadedPluginModules();14var loadedModules = require('stryker-parent

Full Screen

Using AI Code Generation

copy

Full Screen

1var loadedPluginModules = require('stryker-parent').loadedPluginModules;2var loadedPlugins = loadedPluginModules();3var loadPlugins = require('stryker-parent').loadPlugins;4var loadedPlugins = loadPlugins('stryker-*');5var loadPlugin = require('stryker-parent').loadPlugin;6var loadedPlugin = loadPlugin('stryker-jasmine');7var loadPlugin = require('stryker-parent').loadPlugin;8var loadedPlugin = loadPlugin('stryker-jasmine');9var loadPlugin = require('stryker-parent').loadPlugin;10var loadedPlugin = loadPlugin('stryker-jasmine');11var loadPlugin = require('stryker-parent').loadPlugin;12var loadedPlugin = loadPlugin('stryker-jasmine');13var loadPlugin = require('stryker-parent').loadPlugin;14var loadedPlugin = loadPlugin('stryker-jasmine');15var loadPlugin = require('stryker-parent').loadPlugin;16var loadedPlugin = loadPlugin('stryker-jasmine');17var loadPlugin = require('stryker-parent').loadPlugin;18var loadedPlugin = loadPlugin('stryker-jasmine');19var loadPlugin = require('stryker-parent').loadPlugin;20var loadedPlugin = loadPlugin('stryker-jasmine');

Full Screen

Using AI Code Generation

copy

Full Screen

1var loadedPluginModules = require('stryker-parent').loadedPluginModules;2console.log(loadedPluginModules);3var loadedPluginModules = require('stryker').loadedPluginModules;4console.log(loadedPluginModules);5var loadedPluginModules = require('stryker-html-reporter').loadedPluginModules;6console.log(loadedPluginModules);7var loadedPluginModules = require('stryker-html-reporter').loadedPluginModules;8console.log(loadedPluginModules);9var loadedPluginModules = require('stryker-html-reporter').loadedPluginModules;10console.log(loadedPluginModules);11var loadedPluginModules = require('stryker-html-reporter').loadedPluginModules;12console.log(loadedPluginModules);13var loadedPluginModules = require('stryker-html-reporter').loadedPluginModules;14console.log(loadedPluginModules);15var loadedPluginModules = require('stryker-html-reporter').loadedPluginModules;16console.log(loadedPluginModules);

Full Screen

Using AI Code Generation

copy

Full Screen

1const loadedPluginModules = require('stryker-parent').loadedPluginModules;2const loadedPlugins = loadedPluginModules('stryker-*', require);3console.log(loadedPlugins);4const loadedPluginModules = require('stryker-parent').loadedPluginModules;5const loadedPlugins = loadedPluginModules('stryker-*', require);6module.exports = function(config) {7 config.set({8 karma: {9 config: {

Full Screen

Using AI Code Generation

copy

Full Screen

1const loadedPluginModules = require('stryker-parent').loadedPluginModules;2const loadedModules = loadedPluginModules();3console.log(loadedModules);4module.exports = function (config) {5 config.set({6 });7};8module.exports = function (config) {9 config.set({10 });11};12Stryker Plugin Example Repository (with TypeScript)13Stryker Jest Runner Repository (with TypeScript)14Stryker Typescript Plugin Repository (with TypeScript)15Stryker Angular Plugin Repository (with TypeScript)16Stryker Angular Plugin Repository (with Angular 9)

Full Screen

Using AI Code Generation

copy

Full Screen

1const loadedModules = loadedPluginModules();2const loadedModules = loadedPluginModules();3const loadedModules = loadedPluginModules();4const loadedModules = loadedPluginModules();5const loadedModules = loadedPluginModules();6const loadedModules = loadedPluginModules();7const loadedModules = loadedPluginModules();8const loadedModules = loadedPluginModules();9const loadedModules = loadedPluginModules();10const loadedModules = loadedPluginModules();11const loadedModules = loadedPluginModules();12const loadedModules = loadedPluginModules();13const loadedModules = loadedPluginModules();14const loadedModules = loadedPluginModules();

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run stryker-parent automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful