fable 3.0.54 → 3.0.56
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/fable.compatible.js +4 -3
- package/dist/fable.compatible.min.js +2 -2
- package/dist/fable.compatible.min.js.map +1 -1
- package/dist/fable.js +4 -3
- package/dist/fable.min.js +1 -1
- package/dist/fable.min.js.map +1 -1
- package/package.json +2 -2
- package/source/Fable-ServiceManager.js +12 -0
- package/test/FableServiceManager_tests.js +219 -200
package/dist/fable.compatible.js
CHANGED
|
@@ -2390,7 +2390,8 @@ module.exports=wrappy;function wrappy(fn,cb){if(fn&&cb)return wrappy(fn)(cb);if(
|
|
|
2390
2390
|
*/var libFableServiceBase=require('fable-serviceproviderbase');var FableService=/*#__PURE__*/function(_libFableServiceBase$){_inherits(FableService,_libFableServiceBase$);var _super8=_createSuper(FableService);function FableService(pSettings,pServiceHash){var _this16;_classCallCheck2(this,FableService);_this16=_super8.call(this,pSettings,pServiceHash);_this16.serviceType='ServiceManager';_this16.serviceTypes=[];// A map of instantiated services
|
|
2391
2391
|
_this16.services={};// A map of the default instantiated service by type
|
|
2392
2392
|
_this16.defaultServices={};// A map of class constructors for services
|
|
2393
|
-
_this16.serviceClasses={}
|
|
2393
|
+
_this16.serviceClasses={};// If we need extra service initialization capabilities
|
|
2394
|
+
_this16.extraServiceInitialization=false;return _this16;}_createClass2(FableService,[{key:"addServiceType",value:function addServiceType(pServiceType,pServiceClass){// Add the type to the list of types
|
|
2394
2395
|
this.serviceTypes.push(pServiceType);// Add the container for instantiated services to go in
|
|
2395
2396
|
this.services[pServiceType]={};// Using the static member of the class is a much more reliable way to check if it is a service class than instanceof
|
|
2396
2397
|
if(typeof pServiceClass=='function'&&pServiceClass.isFableService){// Add the class to the list of classes
|
|
@@ -2398,14 +2399,14 @@ this.serviceClasses[pServiceType]=pServiceClass;}else{// Add the base class to t
|
|
|
2398
2399
|
this.fable.log.error("Attempted to add service type [".concat(pServiceType,"] with an invalid class. Using base service class, which will not crash but won't provide meaningful services."));this.serviceClasses[pServiceType]=libFableServiceBase;}}// This is for the services that are meant to run mostly single-instance so need a default at initialization
|
|
2399
2400
|
},{key:"addAndInstantiateServiceType",value:function addAndInstantiateServiceType(pServiceType,pServiceClass){this.addServiceType(pServiceType,pServiceClass);this.instantiateServiceProvider(pServiceType,{},"".concat(pServiceType,"-Default"));}// Some services expect to be overloaded / customized class.
|
|
2400
2401
|
},{key:"instantiateServiceProviderFromPrototype",value:function instantiateServiceProviderFromPrototype(pServiceType,pOptions,pCustomServiceHash,pServicePrototype){// Instantiate the service
|
|
2401
|
-
var tmpService=new pServicePrototype(this.fable,pOptions,pCustomServiceHash)
|
|
2402
|
+
var tmpService=new pServicePrototype(this.fable,pOptions,pCustomServiceHash);if(this.extraServiceInitialization){tmpService=this.extraServiceInitialization(tmpService);}// Add the service to the service map
|
|
2402
2403
|
this.services[pServiceType][tmpService.Hash]=tmpService;// If this is the first service of this type, make it the default
|
|
2403
2404
|
if(!this.defaultServices.hasOwnProperty(pServiceType)){this.setDefaultServiceInstantiation(pServiceType,tmpService.Hash);}return tmpService;}},{key:"instantiateServiceProvider",value:function instantiateServiceProvider(pServiceType,pOptions,pCustomServiceHash){// Instantiate the service
|
|
2404
2405
|
var tmpService=this.instantiateServiceProviderWithoutRegistration(pServiceType,pOptions,pCustomServiceHash);// Add the service to the service map
|
|
2405
2406
|
this.services[pServiceType][tmpService.Hash]=tmpService;// If this is the first service of this type, make it the default
|
|
2406
2407
|
if(!this.defaultServices.hasOwnProperty(pServiceType)){this.setDefaultServiceInstantiation(pServiceType,tmpService.Hash);}return tmpService;}// Create a service provider but don't register it to live forever in fable.services
|
|
2407
2408
|
},{key:"instantiateServiceProviderWithoutRegistration",value:function instantiateServiceProviderWithoutRegistration(pServiceType,pOptions,pCustomServiceHash){// Instantiate the service
|
|
2408
|
-
var tmpService=new this.serviceClasses[pServiceType](this.fable,pOptions,pCustomServiceHash);return tmpService;}// Connect an initialized service provider that came before Fable was initialized
|
|
2409
|
+
var tmpService=new this.serviceClasses[pServiceType](this.fable,pOptions,pCustomServiceHash);if(this.extraServiceInitialization){tmpService=this.extraServiceInitialization(tmpService);}return tmpService;}// Connect an initialized service provider that came before Fable was initialized
|
|
2409
2410
|
},{key:"connectPreinitServiceProviderInstance",value:function connectPreinitServiceProviderInstance(pServiceInstance){var tmpServiceType=pServiceInstance.serviceType;var tmpServiceHash=pServiceInstance.Hash;// The service should already be instantiated, so just connect it to fable
|
|
2410
2411
|
pServiceInstance.connectFable(this.fable);if(!this.services.hasOwnProperty(tmpServiceType)){// If the core service hasn't registered itself yet, create the service container for it.
|
|
2411
2412
|
// This means you couldn't register another with this type unless it was later registered with a constructor class.
|