web-node 1.0.607 → 1.0.609
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/index.js +32 -21
- package/main.js +29 -21
- package/package.json +1 -1
- package/pluginAPI.d.ts +13 -0
package/index.js
CHANGED
|
@@ -24,6 +24,7 @@ __webpack_require__.a(module, async (__webpack_handle_async_dependencies__, __we
|
|
|
24
24
|
/* harmony export */ Oy: () => (/* binding */ createNativeAPIFactory),
|
|
25
25
|
/* harmony export */ Vx: () => (/* binding */ hotReloadConfigurationFile),
|
|
26
26
|
/* harmony export */ ZN: () => (/* binding */ loadFile),
|
|
27
|
+
/* harmony export */ c0: () => (/* binding */ combinePluginConfigurations),
|
|
27
28
|
/* harmony export */ dw: () => (/* binding */ hotReloadAPIFile),
|
|
28
29
|
/* harmony export */ gh: () => (/* binding */ loadAll),
|
|
29
30
|
/* harmony export */ gl: () => (/* binding */ callStackSynchronous),
|
|
@@ -147,6 +148,20 @@ for(_i3=0,_Object$entries3=Object.entries(pluginChange.oldScope);_i3<_Object$ent
|
|
|
147
148
|
* @param plugins - List of plugins to search for updates in.
|
|
148
149
|
* @returns A list with plugin changes.
|
|
149
150
|
*/var hotReloadFiles=/*#__PURE__*/function(){var _hotReloadFiles=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(type,target,plugins){var pluginChanges,_iterator5,_step5,plugin,index,_iterator6,_step6,filePath,timestamp,oldScope,_t3,_t4;return _regenerator().w(function(_context5){while(1)switch(_context5.p=_context5.n){case 0:pluginChanges=[];_iterator5=_createForOfIteratorHelper(plugins);_context5.p=1;_iterator5.s();case 2:if((_step5=_iterator5.n()).done){_context5.n=13;break}plugin=_step5.value;if(!plugin[target]){_context5.n=12;break}index=0;_iterator6=_createForOfIteratorHelper(plugin["".concat(type,"FilePaths")]);_context5.p=3;_iterator6.s();case 4:if((_step6=_iterator6.n()).done){_context5.n=9;break}filePath=_step6.value;_context5.n=5;return (0,fs_promises__WEBPACK_IMPORTED_MODULE_4__.stat)(filePath);case 5:timestamp=_context5.v.mtime.getTime();if(!(plugin["".concat(type,"FileLoadTimestamps")][index]<timestamp)){_context5.n=7;break}log.info("Determined updated file \"".concat(filePath,"\"."),"Doing a reload.");oldScope=plugin[target];_context5.n=6;return loadFile(filePath,plugin.name,plugin[target]);case 6:plugin[target]=_context5.v;log.info("File \"".concat(filePath,"\" reloaded."));pluginChanges.push({newScope:plugin[target],oldScope:oldScope,plugin:plugin,target:target});case 7:plugin["".concat(type,"FileLoadTimestamps")][index]=timestamp;index+=1;case 8:_context5.n=4;break;case 9:_context5.n=11;break;case 10:_context5.p=10;_t3=_context5.v;_iterator6.e(_t3);case 11:_context5.p=11;_iterator6.f();return _context5.f(11);case 12:_context5.n=2;break;case 13:_context5.n=15;break;case 14:_context5.p=14;_t4=_context5.v;_iterator5.e(_t4);case 15:_context5.p=15;_iterator5.f();return _context5.f(15);case 16:return _context5.a(2,pluginChanges)}},_callee5,null,[[3,10,11,12],[1,14,15,16]])}));function hotReloadFiles(_x6,_x7,_x8){return _hotReloadFiles.apply(this,arguments)}return hotReloadFiles}();/**
|
|
151
|
+
* Combines given plugin configurations into one and returns a plugin specific
|
|
152
|
+
* meta information object.
|
|
153
|
+
* @param name - Name of the plugin.
|
|
154
|
+
* @param configurations - Array of plugin configurations to combine.
|
|
155
|
+
* @param propertyNames - Array of property names to consider in the
|
|
156
|
+
* configuration.
|
|
157
|
+
* @returns An object of plugin specific meta information.
|
|
158
|
+
*/var combinePluginConfigurations=function combinePluginConfigurations(name,configurations,propertyNames){if(propertyNames===void 0){propertyNames=["webNode"]}var packageConfiguration={};var _iterator7=_createForOfIteratorHelper(configurations),_step7;try{for(_iterator7.s();!(_step7=_iterator7.n()).done;){var configuration=_step7.value;(0,clientnode__WEBPACK_IMPORTED_MODULE_2__.extend)(true,/*
|
|
159
|
+
NOTE: Source and target configuration got modified. While the
|
|
160
|
+
target configuration receives the modifications the source
|
|
161
|
+
configuration will lose their modification expressions
|
|
162
|
+
therefore we can use the source configuration afterward to
|
|
163
|
+
extend the target configuration.
|
|
164
|
+
*/(0,clientnode__WEBPACK_IMPORTED_MODULE_2__.modifyObject)(packageConfiguration,configuration),configuration)}}catch(err){_iterator7.e(err)}finally{_iterator7.f()}name=packageConfiguration.webNodeInternalName||name;return{name:name,configuration:loadConfiguration(packageConfiguration.webNodeInternalName||name,packageConfiguration,propertyNames)}};/**
|
|
150
165
|
* Extends given configuration object with given plugin specific ones and
|
|
151
166
|
* returns a plugin specific meta information object.
|
|
152
167
|
* @param name - Name of plugin to extend.
|
|
@@ -156,13 +171,7 @@ for(_i3=0,_Object$entries3=Object.entries(pluginChange.oldScope);_i3<_Object$ent
|
|
|
156
171
|
* @param pluginPath - Path to given plugin.
|
|
157
172
|
* @param encoding - Encoding to use to read and write from child process's.
|
|
158
173
|
* @returns An object of plugin specific meta information.
|
|
159
|
-
*/var load=/*#__PURE__*/function(){var _load=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(name,internalName,plugins,metaConfiguration,pluginPath,encoding){var configurationFilePaths,
|
|
160
|
-
NOTE: Source and target configuration got modified.
|
|
161
|
-
While the target configuration receives the modifications
|
|
162
|
-
the source configuration will lose their modification
|
|
163
|
-
expressions therefore we can use the source configuration
|
|
164
|
-
afterward to extend the target configuration.
|
|
165
|
-
*/(0,clientnode__WEBPACK_IMPORTED_MODULE_2__.modifyObject)(packageConfiguration,sourceConfiguration),sourceConfiguration);configurationFilePaths.push(filePath);case 5:_context6.n=2;break;case 6:_context6.n=8;break;case 7:_context6.p=7;_t5=_context6.v;_iterator7.e(_t5);case 8:_context6.p=8;_iterator7.f();return _context6.f(8);case 9:apiFilePaths=["index.js"];if(!Object.keys(packageConfiguration).length){_context6.n=11;break}internalName=packageConfiguration.webNodeInternalName||internalName;configuration=loadConfiguration(internalName,packageConfiguration,metaConfiguration.propertyNames);if(configuration[internalName].package.main)apiFilePaths[0]=configuration[internalName].package.main;_context6.n=10;return loadAPI(apiFilePaths,pluginPath,name,internalName,plugins,encoding,configuration,configurationFilePaths);case 10:return _context6.a(2,_context6.v);case 11:_context6.n=12;return loadAPI(apiFilePaths,pluginPath,name,internalName,plugins,encoding);case 12:return _context6.a(2,_context6.v)}},_callee6,null,[[1,7,8,9]])}));function load(_x9,_x0,_x1,_x10,_x11,_x12){return _load.apply(this,arguments)}return load}();/**
|
|
174
|
+
*/var load=/*#__PURE__*/function(){var _load=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(name,internalName,plugins,metaConfiguration,pluginPath,encoding){var configurationFilePaths,sourceConfigurations,_iterator8,_step8,fileName,filePath,_combinePluginConfigu,resolvedInternalName,configuration,apiFilePaths,_t5,_t6;return _regenerator().w(function(_context6){while(1)switch(_context6.p=_context6.n){case 0:if(encoding===void 0){encoding="utf8"}configurationFilePaths=[];sourceConfigurations=[];_iterator8=_createForOfIteratorHelper(metaConfiguration.fileNames);_context6.p=1;_iterator8.s();case 2:if((_step8=_iterator8.n()).done){_context6.n=6;break}fileName=_step8.value;filePath=(0,path__WEBPACK_IMPORTED_MODULE_5__.resolve)(pluginPath,fileName);_context6.n=3;return (0,clientnode__WEBPACK_IMPORTED_MODULE_2__.isFile)(filePath);case 3:if(!_context6.v){_context6.n=5;break}_t5=sourceConfigurations;_context6.n=4;return loadFile(filePath,name);case 4:_t5.push.call(_t5,_context6.v);configurationFilePaths.push(filePath);case 5:_context6.n=2;break;case 6:_context6.n=8;break;case 7:_context6.p=7;_t6=_context6.v;_iterator8.e(_t6);case 8:_context6.p=8;_iterator8.f();return _context6.f(8);case 9:_combinePluginConfigu=combinePluginConfigurations(internalName,sourceConfigurations,metaConfiguration.propertyNames),resolvedInternalName=_combinePluginConfigu.name,configuration=_combinePluginConfigu.configuration;apiFilePaths=["index.js"];if(!Object.keys(configuration[resolvedInternalName].package).length){_context6.n=11;break}if(configuration[resolvedInternalName].package.main)apiFilePaths[0]=configuration[resolvedInternalName].package.main;_context6.n=10;return loadAPI(apiFilePaths,pluginPath,name,resolvedInternalName,plugins,encoding,configuration,configurationFilePaths);case 10:return _context6.a(2,_context6.v);case 11:_context6.n=12;return loadAPI(apiFilePaths,pluginPath,name,resolvedInternalName,plugins,encoding);case 12:return _context6.a(2,_context6.v)}},_callee6,null,[[1,7,8,9]])}));function load(_x9,_x0,_x1,_x10,_x11,_x12){return _load.apply(this,arguments)}return load}();/**
|
|
166
175
|
* Creates a function callable by plugin api which calls the corresponding
|
|
167
176
|
* plugin scope method.
|
|
168
177
|
* @param plugins - To search for plugin scope in.
|
|
@@ -181,14 +190,14 @@ for(_i3=0,_Object$entries3=Object.entries(pluginChange.oldScope);_i3<_Object$ent
|
|
|
181
190
|
* @param configuration - Plugin specific configurations.
|
|
182
191
|
* @param configurationFilePaths - Plugin specific configuration file paths.
|
|
183
192
|
* @returns Plugin meta information object.
|
|
184
|
-
*/var loadAPI=/*#__PURE__*/function(){var _loadAPI=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(relativeFilePaths,pluginPath,name,internalName,plugins,encoding,configuration,configurationFilePaths){var filePath,
|
|
193
|
+
*/var loadAPI=/*#__PURE__*/function(){var _loadAPI=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(relativeFilePaths,pluginPath,name,internalName,plugins,encoding,configuration,configurationFilePaths){var filePath,_iterator9,_step9,fileName,api,nativeAPI,pluginConfiguration,_t7,_t8,_t9,_t0,_t1,_t10,_t11,_t12,_t13,_t14,_t15,_t16,_t17,_t18,_t19,_t20,_t21,_t22,_t23;return _regenerator().w(function(_context8){while(1)switch(_context8.p=_context8.n){case 0:if(encoding===void 0){encoding="utf8"}if(configuration===void 0){configuration=null}if(configurationFilePaths===void 0){configurationFilePaths=[]}filePath=(0,path__WEBPACK_IMPORTED_MODULE_5__.resolve)(pluginPath,relativeFilePaths[0]);_context8.n=1;return (0,clientnode__WEBPACK_IMPORTED_MODULE_2__.isFile)(filePath);case 1:if(_context8.v){_context8.n=11;break}_t7=_createForOfIteratorHelper;_context8.n=2;return (0,fs_promises__WEBPACK_IMPORTED_MODULE_4__.readdir)(pluginPath);case 2:_iterator9=_t7(_context8.v);_context8.p=3;_iterator9.s();case 4:if((_step9=_iterator9.n()).done){_context8.n=8;break}fileName=_step9.value;_t8=!configurationFilePaths.map(function(filePath){return (0,path__WEBPACK_IMPORTED_MODULE_5__.basename)(filePath)}).includes(fileName);if(!_t8){_context8.n=6;break}_context8.n=5;return (0,clientnode__WEBPACK_IMPORTED_MODULE_2__.isFile)((0,path__WEBPACK_IMPORTED_MODULE_5__.resolve)(pluginPath,fileName));case 5:_t8=_context8.v;case 6:if(!_t8){_context8.n=7;break}filePath=(0,path__WEBPACK_IMPORTED_MODULE_5__.resolve)(pluginPath,filePath);if(!["index","main"].includes((0,path__WEBPACK_IMPORTED_MODULE_5__.basename)(filePath,(0,path__WEBPACK_IMPORTED_MODULE_5__.extname)(fileName)))){_context8.n=7;break}return _context8.a(3,8);case 7:_context8.n=4;break;case 8:_context8.n=10;break;case 9:_context8.p=9;_t9=_context8.v;_iterator9.e(_t9);case 10:_context8.p=10;_iterator9.f();return _context8.f(10);case 11:api=null;nativeAPI=false;_t0=configuration&&(/*
|
|
185
194
|
NOTE: Check if a webNode plugin configuration is available
|
|
186
195
|
indicating a backend responsibility for api file.
|
|
187
196
|
|
|
188
197
|
NOTE: One key is always there representing the whole package
|
|
189
198
|
configuration.
|
|
190
|
-
*/Object.keys(configuration).length>1||Object.prototype.hasOwnProperty.call(configuration,internalName)&&Object.keys(configuration[internalName]).length>1);if(!
|
|
191
|
-
api=function api(_ref2){var hook=_ref2.hook,data=_ref2.data;for(var _len4=arguments.length,parameters=new Array(_len4>1?_len4-1:0),_key4=1;_key4<_len4;_key4++){parameters[_key4-1]=arguments[_key4]}var childProcessResult=(0,child_process__WEBPACK_IMPORTED_MODULE_1__.spawnSync)(filePath,[hook].concat(_toConsumableArray(parameters.map(function(item){return JSON.stringify(item)}))),{cwd:process.cwd(),encoding:encoding,env:process.env,input:JSON.stringify(data),shell:true,stdio:"inherit"});if(childProcessResult.status===404)return data;var jsonIndicatorPrefix="##!JSON!##";if(childProcessResult.stdout.startsWith(jsonIndicatorPrefix))return JSON.parse(childProcessResult.stdout.substring(jsonIndicatorPrefix.length));return data};case 14:pluginConfiguration=configuration!==null&&configuration!==void 0?configuration:_defineProperty({},internalName,{package:{}});
|
|
199
|
+
*/Object.keys(configuration).length>1||Object.prototype.hasOwnProperty.call(configuration,internalName)&&Object.keys(configuration[internalName]).length>1);if(!_t0){_context8.n=13;break}_context8.n=12;return (0,clientnode__WEBPACK_IMPORTED_MODULE_2__.isFile)(filePath);case 12:_t0=_context8.v;case 13:if(!_t0){_context8.n=14;break}if(filePath.endsWith(".js")){nativeAPI=true;api=createNativeAPIFactory(plugins,name)}else// NOTE: Any executable file can represent an api.
|
|
200
|
+
api=function api(_ref2){var hook=_ref2.hook,data=_ref2.data;for(var _len4=arguments.length,parameters=new Array(_len4>1?_len4-1:0),_key4=1;_key4<_len4;_key4++){parameters[_key4-1]=arguments[_key4]}var childProcessResult=(0,child_process__WEBPACK_IMPORTED_MODULE_1__.spawnSync)(filePath,[hook].concat(_toConsumableArray(parameters.map(function(item){return JSON.stringify(item)}))),{cwd:process.cwd(),encoding:encoding,env:process.env,input:JSON.stringify(data),shell:true,stdio:"inherit"});if(childProcessResult.status===404)return data;var jsonIndicatorPrefix="##!JSON!##";if(childProcessResult.stdout.startsWith(jsonIndicatorPrefix))return JSON.parse(childProcessResult.stdout.substring(jsonIndicatorPrefix.length));return data};case 14:pluginConfiguration=configuration!==null&&configuration!==void 0?configuration:_defineProperty({},internalName,{package:{}});_t1=api;if(!api){_context8.n=16;break}_context8.n=15;return (0,fs_promises__WEBPACK_IMPORTED_MODULE_4__.stat)(filePath);case 15:_t11=_context8.v.mtime.getTime();_t10=[_t11];_context8.n=17;break;case 16:_t10=[];case 17:_t12=_t10;_t13=api?[filePath]:[];_t14=pluginConfiguration;_t15=configurationFilePaths;_context8.n=18;return Promise.all(configurationFilePaths.map(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(filePath){return _regenerator().w(function(_context7){while(1)switch(_context7.n){case 0:_context7.n=1;return (0,fs_promises__WEBPACK_IMPORTED_MODULE_4__.stat)(filePath);case 1:return _context7.a(2,_context7.v.mtime.getTime())}},_callee7)}))));case 18:_t16=_context8.v;_t17=Object.prototype.hasOwnProperty.call(pluginConfiguration,internalName)&&pluginConfiguration[internalName].dependencies?pluginConfiguration[internalName].dependencies:[];_t18=internalName;_t19=name;_t20=pluginConfiguration[internalName].package;_t21=pluginPath;if(!nativeAPI){_context8.n=20;break}_context8.n=19;return loadFile(filePath,name);case 19:_t22=_context8.v;_context8.n=21;break;case 20:_t22=null;case 21:_t23=_t22;return _context8.a(2,{api:_t1,apiFileLoadTimestamps:_t12,apiFilePaths:_t13,configuration:_t14,configurationFilePaths:_t15,configurationFileLoadTimestamps:_t16,dependencies:_t17,internalName:_t18,name:_t19,packageConfiguration:_t20,path:_t21,scope:_t23})}},_callee8,null,[[3,9,10,11]])}));function loadAPI(_x13,_x14,_x15,_x16,_x17,_x18,_x19,_x20){return _loadAPI.apply(this,arguments)}return loadAPI}();/**
|
|
192
201
|
* Loads plugin specific configuration object.
|
|
193
202
|
* @param name - Property name where to inject resolved configuration into
|
|
194
203
|
* global one.
|
|
@@ -200,10 +209,10 @@ api=function api(_ref2){var hook=_ref2.hook,data=_ref2.data;for(var _len4=argume
|
|
|
200
209
|
No plugin specific configuration found. Only provide package
|
|
201
210
|
configuration.
|
|
202
211
|
Removing comments (default key prefix to delete is "#").
|
|
203
|
-
*/var packageConfigurationCopy=(0,clientnode__WEBPACK_IMPORTED_MODULE_2__.removeKeyPrefixes)((0,clientnode__WEBPACK_IMPORTED_MODULE_2__.copy)(packageConfiguration));var result=_defineProperty({},name,{package:packageConfigurationCopy});var
|
|
212
|
+
*/var packageConfigurationCopy=(0,clientnode__WEBPACK_IMPORTED_MODULE_2__.removeKeyPrefixes)((0,clientnode__WEBPACK_IMPORTED_MODULE_2__.copy)(packageConfiguration));var result=_defineProperty({},name,{package:packageConfigurationCopy});var _iterator0=_createForOfIteratorHelper(configurationPropertyNames),_step0;try{for(_iterator0.s();!(_step0=_iterator0.n()).done;){var propertyName=_step0.value;if(packageConfiguration[propertyName]){(0,clientnode__WEBPACK_IMPORTED_MODULE_2__.extend)(true,result,packageConfiguration[propertyName]);/*
|
|
204
213
|
NOTE: We should break the cycle here to avoid endless loops
|
|
205
214
|
when traversing this data structure.
|
|
206
|
-
*/delete result[name].package[propertyName];break}}}catch(err){
|
|
215
|
+
*/delete result[name].package[propertyName];break}}}catch(err){_iterator0.e(err)}finally{_iterator0.f()}return result};/**
|
|
207
216
|
* Loads given plugin configurations into global configuration.
|
|
208
217
|
* @param plugins - Topological sorted list of plugins to check for
|
|
209
218
|
* configurations.
|
|
@@ -212,7 +221,7 @@ api=function api(_ref2){var hook=_ref2.hook,data=_ref2.data;for(var _len4=argume
|
|
|
212
221
|
*/var loadConfigurations=function loadConfigurations(plugins,configuration){/*
|
|
213
222
|
First clear current configuration content key by key to let old top
|
|
214
223
|
level configuration object instance untouched.
|
|
215
|
-
*/for(var _i4=0,_Object$keys=Object.keys(configuration);_i4<_Object$keys.length;_i4++){var key=_Object$keys[_i4];delete configuration[key]};(0,clientnode__WEBPACK_IMPORTED_MODULE_2__.extend)(configuration,(0,clientnode__WEBPACK_IMPORTED_MODULE_2__.copy)(_configurator_js__WEBPACK_IMPORTED_MODULE_6__/* ["default"] */ .A));var
|
|
224
|
+
*/for(var _i4=0,_Object$keys=Object.keys(configuration);_i4<_Object$keys.length;_i4++){var key=_Object$keys[_i4];delete configuration[key]};(0,clientnode__WEBPACK_IMPORTED_MODULE_2__.extend)(configuration,(0,clientnode__WEBPACK_IMPORTED_MODULE_2__.copy)(_configurator_js__WEBPACK_IMPORTED_MODULE_6__/* ["default"] */ .A));var _iterator1=_createForOfIteratorHelper(plugins),_step1;try{for(_iterator1.s();!(_step1=_iterator1.n()).done;){var plugin=_step1.value;if(Object.prototype.hasOwnProperty.call(plugin,"configuration")){var pluginConfiguration=(0,clientnode__WEBPACK_IMPORTED_MODULE_2__.copy)(plugin.configuration);(0,clientnode__WEBPACK_IMPORTED_MODULE_2__.extend)(true,(0,clientnode__WEBPACK_IMPORTED_MODULE_2__.modifyObject)(configuration,pluginConfiguration),/*
|
|
216
225
|
NOTE: Should be resolved via preceding
|
|
217
226
|
"object.modifyObject" call.
|
|
218
227
|
*/pluginConfiguration);/*
|
|
@@ -220,7 +229,7 @@ api=function api(_ref2){var hook=_ref2.hook,data=_ref2.data;for(var _len4=argume
|
|
|
220
229
|
specific configuration set to give runtime configuration always
|
|
221
230
|
the highest priority when resolving intermediate configuration
|
|
222
231
|
states.
|
|
223
|
-
*/if(configuration.core.runtimeConfiguration)(0,clientnode__WEBPACK_IMPORTED_MODULE_2__.extend)(true,configuration,configuration.core.runtimeConfiguration)}}}catch(err){
|
|
232
|
+
*/if(configuration.core.runtimeConfiguration)(0,clientnode__WEBPACK_IMPORTED_MODULE_2__.extend)(true,configuration,configuration.core.runtimeConfiguration)}}}catch(err){_iterator1.e(err)}finally{_iterator1.f()}return evaluateConfiguration(configuration)};/**
|
|
224
233
|
* Load given api file path and returns exported scope.
|
|
225
234
|
* @param filePath - Path to file to load.
|
|
226
235
|
* @param name - Plugin name to use for proper error messages.
|
|
@@ -228,7 +237,7 @@ api=function api(_ref2){var hook=_ref2.hook,data=_ref2.data;for(var _len4=argume
|
|
|
228
237
|
* If a "null" is given an error will be thrown.
|
|
229
238
|
* @param doLogging - Enables logging.
|
|
230
239
|
* @returns Exported api file scope.
|
|
231
|
-
*/var loadFile=/*#__PURE__*/function(){var _loadFile=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(filePath,name,fallbackScope,doLogging){var options,scope,
|
|
240
|
+
*/var loadFile=/*#__PURE__*/function(){var _loadFile=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(filePath,name,fallbackScope,doLogging){var options,scope,_t24;return _regenerator().w(function(_context9){while(1)switch(_context9.p=_context9.n){case 0:if(fallbackScope===void 0){fallbackScope=null}if(doLogging===void 0){doLogging=true}// Clear module cache if possible in the future.
|
|
232
241
|
/*
|
|
233
242
|
let reference: string | undefined
|
|
234
243
|
try {
|
|
@@ -239,17 +248,17 @@ api=function api(_ref2){var hook=_ref2.hook,data=_ref2.data;for(var _len4=argume
|
|
|
239
248
|
|
|
240
249
|
if (reference)
|
|
241
250
|
// Clear the module cache.
|
|
242
|
-
*/options={};if((0,path__WEBPACK_IMPORTED_MODULE_5__.extname)(filePath)===".json")options.with={type:"json"};_context9.p=1;_context9.n=2;return import(/* webpackIgnore: true */"".concat(filePath,"?timestamp=").concat(String(Date.now())),options);case 2:scope=_context9.v;_context9.n=5;break;case 3:_context9.p=3;
|
|
251
|
+
*/options={};if((0,path__WEBPACK_IMPORTED_MODULE_5__.extname)(filePath)===".json")options.with={type:"json"};_context9.p=1;_context9.n=2;return import(/* webpackIgnore: true */"".concat(filePath,"?timestamp=").concat(String(Date.now())),options);case 2:scope=_context9.v;_context9.n=5;break;case 3:_context9.p=3;_t24=_context9.v;if(!fallbackScope){_context9.n=4;break}scope=fallbackScope;if(doLogging)log.warn("Couldn't load new api plugin file \"".concat(filePath,"\" for"),"plugin \"".concat(name,"\": ").concat((0,clientnode__WEBPACK_IMPORTED_MODULE_2__.represent)(_t24),". Using"),"fallback one.");_context9.n=5;break;case 4:throw new Error("Couldn't load plugin file \"".concat(filePath,"\" for plugin ")+"\"".concat(name,"\": ").concat((0,clientnode__WEBPACK_IMPORTED_MODULE_2__.represent)(_t24)),{cause:_t24});case 5:if(!(Object.prototype.hasOwnProperty.call(scope,"default")&&scope.default)){_context9.n=6;break}return _context9.a(2,scope.default);case 6:return _context9.a(2,scope)}},_callee9,null,[[1,3]])}));function loadFile(_x22,_x23,_x24,_x25){return _loadFile.apply(this,arguments)}return loadFile}();/**
|
|
243
252
|
* Extends given configuration object with all plugin specific ones and returns
|
|
244
253
|
* a topological sorted list of plugins with plugins specific meta information
|
|
245
254
|
* stored.
|
|
246
255
|
* @param configuration - Configuration object to extend and use.
|
|
247
256
|
* @returns A topological sorted list of plugins objects.
|
|
248
|
-
*/var loadAll=/*#__PURE__*/function(){var _loadAll=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(configuration){var _configuration$core$p;var plugins,_i5,_Object$values,directory,_directory$nameRegula,compiledRegularExpression,
|
|
257
|
+
*/var loadAll=/*#__PURE__*/function(){var _loadAll=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(configuration){var _configuration$core$p;var plugins,_i5,_Object$values,directory,_directory$nameRegula,compiledRegularExpression,_iterator10,_step10,pluginName,currentPluginPath,internalName,_i6,_Object$entries4,_Object$entries4$_i,name,plugin,pluginConfiguration,scope,_internalName,temporaryPlugins,_i7,_Object$values2,_plugin,_iterator11,_step11,_name2,sortedPlugins,_iterator12,_step12,_pluginName,_i8,_Object$entries5,_Object$entries5$_i,_name3,_plugin2,_t25,_t26,_t27,_t28,_t29;return _regenerator().w(function(_context0){while(1)switch(_context0.p=_context0.n){case 0:plugins={};/*
|
|
249
258
|
Load main plugin configuration at first.
|
|
250
259
|
|
|
251
260
|
NOTE: If application's main is this itself avoid loading it twice.
|
|
252
|
-
*/if(!(configuration.name!=="web-node")){_context0.n=2;break}_context0.n=1;return load(configuration.name,determineInternalName(configuration.name,new RegExp((_configuration$core$p=configuration.core.plugin.directories.external.nameRegularExpressionPattern)!==null&&_configuration$core$p!==void 0?_configuration$core$p:configuration.core.plugin.nameRegularExpressionPattern)),plugins,configuration.core.plugin.configuration,configuration.core.context.path,configuration.core.encoding);case 1:plugins[configuration.name]=_context0.v;case 2:_i5=0,_Object$values=Object.values(configuration.core.plugin.directories);case 3:if(!(_i5<_Object$values.length)){_context0.n=15;break}directory=_Object$values[_i5];_context0.n=4;return (0,clientnode__WEBPACK_IMPORTED_MODULE_2__.isDirectory)(directory.path);case 4:if(!_context0.v){_context0.n=14;break}compiledRegularExpression=new RegExp((_directory$nameRegula=directory.nameRegularExpressionPattern)!==null&&_directory$nameRegula!==void 0?_directory$nameRegula:configuration.core.plugin.nameRegularExpressionPattern);
|
|
261
|
+
*/if(!(configuration.name!=="web-node")){_context0.n=2;break}_context0.n=1;return load(configuration.name,determineInternalName(configuration.name,new RegExp((_configuration$core$p=configuration.core.plugin.directories.external.nameRegularExpressionPattern)!==null&&_configuration$core$p!==void 0?_configuration$core$p:configuration.core.plugin.nameRegularExpressionPattern)),plugins,configuration.core.plugin.configuration,configuration.core.context.path,configuration.core.encoding);case 1:plugins[configuration.name]=_context0.v;case 2:_i5=0,_Object$values=Object.values(configuration.core.plugin.directories);case 3:if(!(_i5<_Object$values.length)){_context0.n=15;break}directory=_Object$values[_i5];_context0.n=4;return (0,clientnode__WEBPACK_IMPORTED_MODULE_2__.isDirectory)(directory.path);case 4:if(!_context0.v){_context0.n=14;break}compiledRegularExpression=new RegExp((_directory$nameRegula=directory.nameRegularExpressionPattern)!==null&&_directory$nameRegula!==void 0?_directory$nameRegula:configuration.core.plugin.nameRegularExpressionPattern);_t25=_createForOfIteratorHelper;_context0.n=5;return (0,fs_promises__WEBPACK_IMPORTED_MODULE_4__.readdir)(directory.path);case 5:_iterator10=_t25(_context0.v);_context0.p=6;_iterator10.s();case 7:if((_step10=_iterator10.n()).done){_context0.n=11;break}pluginName=_step10.value;if(compiledRegularExpression.test(pluginName)){_context0.n=8;break}return _context0.a(3,10);case 8:currentPluginPath=(0,path__WEBPACK_IMPORTED_MODULE_5__.resolve)(directory.path,pluginName);internalName=determineInternalName(pluginName,compiledRegularExpression);_context0.n=9;return load(pluginName,internalName,plugins,configuration.core.plugin.configuration,currentPluginPath,configuration.core.encoding);case 9:plugins[pluginName]=_context0.v;case 10:_context0.n=7;break;case 11:_context0.n=13;break;case 12:_context0.p=12;_t26=_context0.v;_iterator10.e(_t26);case 13:_context0.p=13;_iterator10.f();return _context0.f(13);case 14:_i5++;_context0.n=3;break;case 15:_i6=0,_Object$entries4=Object.entries(PLUGIN_LOADER);case 16:if(!(_i6<_Object$entries4.length)){_context0.n=20;break}_Object$entries4$_i=_slicedToArray(_Object$entries4[_i6],2),name=_Object$entries4$_i[0],plugin=_Object$entries4$_i[1];_context0.n=17;return plugin.loadConfiguration();case 17:pluginConfiguration=_context0.v;_context0.n=18;return plugin.loadScope();case 18:scope=_context0.v;_internalName=determineInternalName(name,new RegExp(configuration.core.plugin.nameRegularExpressionPattern));plugins[name]={api:createNativeAPIFactory(plugins,name),apiFileLoadTimestamps:[],apiFilePaths:[],configuration:pluginConfiguration,configurationFilePaths:[],configurationFileLoadTimestamps:[],dependencies:Object.prototype.hasOwnProperty.call(pluginConfiguration,_internalName)&&pluginConfiguration[_internalName].dependencies?pluginConfiguration[_internalName].dependencies:[],internalName:_internalName,name:name,packageConfiguration:pluginConfiguration[_internalName].package,path:"",scope:scope};case 19:_i6++;_context0.n=16;break;case 20:temporaryPlugins={};for(_i7=0,_Object$values2=Object.values(plugins);_i7<_Object$values2.length;_i7++){_plugin=_Object$values2[_i7];temporaryPlugins[_plugin.internalName]=_plugin.dependencies;if(Object.prototype.hasOwnProperty.call(configuration.core.interDependencies,_plugin.internalName)){_iterator11=_createForOfIteratorHelper([].concat(configuration.core.interDependencies[_plugin.internalName]));try{for(_iterator11.s();!(_step11=_iterator11.n()).done;){_name2=_step11.value;if(!temporaryPlugins[_plugin.internalName].includes(_name2))temporaryPlugins[_plugin.internalName].push(_name2)}}catch(err){_iterator11.e(err)}finally{_iterator11.f()}}}sortedPlugins=[];_iterator12=_createForOfIteratorHelper((0,clientnode__WEBPACK_IMPORTED_MODULE_2__.sortTopological)(temporaryPlugins));_context0.p=21;_iterator12.s();case 22:if((_step12=_iterator12.n()).done){_context0.n=26;break}_pluginName=_step12.value;_i8=0,_Object$entries5=Object.entries(plugins);case 23:if(!(_i8<_Object$entries5.length)){_context0.n=25;break}_Object$entries5$_i=_slicedToArray(_Object$entries5[_i8],2),_name3=_Object$entries5$_i[0],_plugin2=_Object$entries5$_i[1];if(![_plugin2.internalName,_name3].includes(_pluginName)){_context0.n=24;break}sortedPlugins.push(_plugin2);return _context0.a(3,25);case 24:_i8++;_context0.n=23;break;case 25:_context0.n=22;break;case 26:_context0.n=28;break;case 27:_context0.p=27;_t27=_context0.v;_iterator12.e(_t27);case 28:_context0.p=28;_iterator12.f();return _context0.f(28);case 29:_context0.n=30;return loadConfigurations(sortedPlugins,configuration);case 30:_t28=_context0.v;_t29=sortedPlugins;return _context0.a(2,{configuration:_t28,plugins:_t29})}},_callee0,null,[[21,27,28,29],[6,12,13,14]])}));function loadAll(_x26){return _loadAll.apply(this,arguments)}return loadAll}();/**
|
|
253
262
|
* Transform a list of absolute paths respecting the application context.
|
|
254
263
|
* @param configuration - Configuration object.
|
|
255
264
|
* @param configuration.core - Sub configuration web-node.
|
|
@@ -265,7 +274,7 @@ api=function api(_ref2){var hook=_ref2.hook,data=_ref2.data;for(var _len4=argume
|
|
|
265
274
|
* @param locations - Locations to search in.
|
|
266
275
|
* @returns A boolean indicating whether given file path is in provided
|
|
267
276
|
* locations.
|
|
268
|
-
*/var isInLocations=function isInLocations(configuration,plugins,filePath,locations){var pluginPaths=plugins.map(function(plugin){return plugin.path});var
|
|
277
|
+
*/var isInLocations=function isInLocations(configuration,plugins,filePath,locations){var pluginPaths=plugins.map(function(plugin){return plugin.path});var _iterator13=_createForOfIteratorHelper([].concat(locations)),_step13;try{for(_iterator13.s();!(_step13=_iterator13.n()).done;){var location=_step13.value;if(location.startsWith("/")){if(filePath.startsWith((0,path__WEBPACK_IMPORTED_MODULE_5__.join)(configuration.core.context.path,location)))return true}else{var _iterator14=_createForOfIteratorHelper(pluginPaths),_step14;try{for(_iterator14.s();!(_step14=_iterator14.n()).done;){var pluginPath=_step14.value;if(filePath.startsWith((0,path__WEBPACK_IMPORTED_MODULE_5__.resolve)(pluginPath,location)))return true}}catch(err){_iterator14.e(err)}finally{_iterator14.f()}}}}catch(err){_iterator13.e(err)}finally{_iterator13.f()}return false};var pluginAPI={callStack:_callStack,callStackSynchronous:callStackSynchronous,determineInternalName:determineInternalName,determineLocations:determineLocations,evaluateConfiguration:evaluateConfiguration,hotReloadAPIFile:hotReloadAPIFile,hotReloadConfigurationFile:hotReloadConfigurationFile,hotReloadFiles:hotReloadFiles,isInLocations:isInLocations,load:load,loadAll:loadAll,loadAPI:loadAPI,loadConfiguration:loadConfiguration,loadConfigurations:loadConfigurations,loadFile:loadFile};/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (pluginAPI);
|
|
269
278
|
__webpack_async_result__();
|
|
270
279
|
} catch(e) { __webpack_async_result__(e); } }, 1);
|
|
271
280
|
|
|
@@ -380,6 +389,7 @@ __webpack_require__.a(module, async (__webpack_handle_async_dependencies__, __we
|
|
|
380
389
|
/* harmony export */ Rm: () => (/* binding */ log),
|
|
381
390
|
/* harmony export */ Vx: () => (/* reexport safe */ _pluginAPI_js__WEBPACK_IMPORTED_MODULE_1__.Vx),
|
|
382
391
|
/* harmony export */ ZN: () => (/* reexport safe */ _pluginAPI_js__WEBPACK_IMPORTED_MODULE_1__.ZN),
|
|
392
|
+
/* harmony export */ c0: () => (/* reexport safe */ _pluginAPI_js__WEBPACK_IMPORTED_MODULE_1__.c0),
|
|
383
393
|
/* harmony export */ dw: () => (/* reexport safe */ _pluginAPI_js__WEBPACK_IMPORTED_MODULE_1__.dw),
|
|
384
394
|
/* harmony export */ eQ: () => (/* binding */ isMainModule),
|
|
385
395
|
/* harmony export */ gh: () => (/* reexport safe */ _pluginAPI_js__WEBPACK_IMPORTED_MODULE_1__.gh),
|
|
@@ -448,7 +458,7 @@ __webpack_async_result__();
|
|
|
448
458
|
/* 7 */
|
|
449
459
|
/***/ ((module) => {
|
|
450
460
|
|
|
451
|
-
module.exports = /*#__PURE__*/JSON.parse('{"name":"web-node","version":"1.0.
|
|
461
|
+
module.exports = /*#__PURE__*/JSON.parse('{"name":"web-node","version":"1.0.609","description":"High level javaScript backend plugin system and configuration merger.","keywords":["api","backend","management","plugin","web"],"homepage":"https://torben.website/web-node","bugs":{"email":"info@torben.website","url":"https://github.com/thaibault/web-node/issues"},"license":"CC-BY-3.0","author":{"email":"info@torben.website","name":"Torben Sickert","url":"https://torben.website"},"repository":{"type":"git","url":"https://github.com/thaibault/web-node.git"},"type":"module","bin":"main.js","exports":{".":"./index.js","./main":"./main.js","./main.js":"./main.js","./package.json":"./package.json","./unixCrypt":"./unixCrypt.js","./unixCrypt.js":"./unixCrypt.js","./type":"./type.d.ts"},"files":["configurator.d.ts","index.d.ts","index.js","main.js","pluginAPI.d.ts","type.d.ts","unixCrypt.d.ts","unixCrypt.js"],"sideEffects":true,"scripts":{"build":"yarn build:types; yarn build:plain","build:plain":"weboptimizer build","build:types":"weboptimizer build:types","check":"yarn check:types; yarn lint","check:types":"weboptimizer check:types","clear":"weboptimizer clear","document":"weboptimizer document","lint":"weboptimizer lint","prepare":"yarn build","prepare:test":"yarn clear && cd dummyPlugin && shx touch yarn.lock && yarn build && cd ..","serve":"yarn build:plain && yarn start","start":"./main.js \'{plugin: {hotReloading: true}}\'","test":"yarn prepare:test && weboptimizer test","test:coverage":"yarn prepare:test && weboptimizer test:coverage","test:coverage:report":"yarn prepare:test && weboptimizer test:coverage:report","update:documentation":"web-documentation","watch":"weboptimizer build --watch"},"devDependencies":{"@babel/cli":"^8.0.4","@babel/eslint-parser":"^8.0.1","@eslint/js":"^10.0.1","@stylistic/eslint-plugin":"^5.10.0","@types/node":"^26.4.1","@types/webpack-env":"^1.18.8","@typescript-eslint/eslint-plugin":"^8.69.0","@typescript-eslint/parser":"^8.69.0","clientnode":"^4.0.1512","eslint":"^10.10.0","eslint-config-google":"^0.14.0","eslint-plugin-jsdoc":"^64.3.6","jest":"^30.5.1","jsdoc":"^4.0.5","shx":"^0.4.0","typescript-eslint":"^8.69.0","web-documentation":"^1.0.52","weboptimizer":"^4.0.78"},"peerDependencies":{"clientnode":"*"},"resolutions":{"colors":"1.4.0","globals@npm:^11.1.0":"patch:globals@npm%3A11.12.0#~/.yarn/patches/globals-npm-11.12.0-1fa7f41a6c.patch","globals@npm:^14.0.0":"patch:globals@npm%3A11.12.0#~/.yarn/patches/globals-npm-11.12.0-1fa7f41a6c.patch","globals@npm:^9.18.0":"patch:globals@npm%3A11.12.0#~/.yarn/patches/globals-npm-11.12.0-1fa7f41a6c.patch"},"engines":{"node":">=26","npm":">=12","yarn":">=4"},"webDocumentation":{"trackingCode":"UA-40192634-9"},"webNode":{"core":{"context":{"path":"./","type":"relative"},"debug":false,"encoding":"utf8","interDependencies":{},"name":"web-node","plugin":{"configuration":{"fileNames":["package.json","private-package.json"],"propertyNames":["webNode","webnode","web-node"]},"nameRegularExpressionPattern":"^([a-zA-Z0-9-]+?)-?[wW]eb-?[nN]ode-?[pP]lugin$","directories":{"external":{"path":{"__evaluate__":"`${currentPath}/node_modules/`"}},"internal":{"nameRegularExpressionPattern":"^([a-zA-Z0-9-_].*)$","path":{"__evaluate__":"`${currentPath}/plugins/`"}}},"hotReloading":false}}},"webOptimizer":{"assetPattern":{"javaScript":{"includeFilePathRegularExpression":"^(.+/)?main\\\\.js$","pattern":{"#":"This is how we can make our main exported artefact executable.","__evaluate__":"`#!/usr/bin/env node\\n// -*- coding: utf-8 -*-\\n${self.generic.assetPattern?.javaScript?.pattern ?? \'\'}\\n{1}`"}}},"injection":{"entry":{"__evaluate__":"2 < self.givenCommandLineArguments.length && self.givenCommandLineArguments[2].startsWith(\'test\') ? {testBundle: \'test\'} : {index: \'./index.ts\', main: \'./main.ts\', unixCrypt: \'./unixCrypt.ts\'}"}},"module":{"optimizer":{"terser":{"terserOptions":{"compress":{"#":"To provide a logging output we need to exclude this feature.","drop_console":{"__evaluate__":"false"},"drop_debugger":{"__evaluate__":"false"}}}}}},"targetTechnology":{"boilerplate":"node","payload":"node"}},"packageManager":"yarn@4.18.0"}');
|
|
452
462
|
|
|
453
463
|
/***/ }),
|
|
454
464
|
/* 8 */
|
|
@@ -643,6 +653,7 @@ module.exports = x({ ["fileURLToPath"]: () => (__WEBPACK_EXTERNAL_MODULE_node_ur
|
|
|
643
653
|
/******/ const __webpack_exports__PLUGIN_LOADER = __webpack_exports__.GU;
|
|
644
654
|
/******/ const __webpack_exports__callStack = __webpack_exports__.lT;
|
|
645
655
|
/******/ const __webpack_exports__callStackSynchronous = __webpack_exports__.gl;
|
|
656
|
+
/******/ const __webpack_exports__combinePluginConfigurations = __webpack_exports__.c0;
|
|
646
657
|
/******/ const __webpack_exports__configuration = __webpack_exports__.HF;
|
|
647
658
|
/******/ const __webpack_exports__createNativeAPIFactory = __webpack_exports__.Oy;
|
|
648
659
|
/******/ const __webpack_exports__default = __webpack_exports__.Ay;
|
|
@@ -664,5 +675,5 @@ module.exports = x({ ["fileURLToPath"]: () => (__WEBPACK_EXTERNAL_MODULE_node_ur
|
|
|
664
675
|
/******/ const __webpack_exports__log = __webpack_exports__.Rm;
|
|
665
676
|
/******/ const __webpack_exports__main = __webpack_exports__.iW;
|
|
666
677
|
/******/ const __webpack_exports__pluginAPI = __webpack_exports__.MM;
|
|
667
|
-
/******/ export { __webpack_exports__PLUGIN_LOADER as PLUGIN_LOADER, __webpack_exports__callStack as callStack, __webpack_exports__callStackSynchronous as callStackSynchronous, __webpack_exports__configuration as configuration, __webpack_exports__createNativeAPIFactory as createNativeAPIFactory, __webpack_exports__default as default, __webpack_exports__determineInternalName as determineInternalName, __webpack_exports__determineLocations as determineLocations, __webpack_exports__evaluateConfiguration as evaluateConfiguration, __webpack_exports__hotReloadAPIFile as hotReloadAPIFile, __webpack_exports__hotReloadConfigurationFile as hotReloadConfigurationFile, __webpack_exports__hotReloadFiles as hotReloadFiles, __webpack_exports__isInLocations as isInLocations, __webpack_exports__isMainModule as isMainModule, __webpack_exports__isMainModulePositiveCalls as isMainModulePositiveCalls, __webpack_exports__load as load, __webpack_exports__loadAPI as loadAPI, __webpack_exports__loadAll as loadAll, __webpack_exports__loadConfiguration as loadConfiguration, __webpack_exports__loadConfigurations as loadConfigurations, __webpack_exports__loadFile as loadFile, __webpack_exports__log as log, __webpack_exports__main as main, __webpack_exports__pluginAPI as pluginAPI };
|
|
678
|
+
/******/ export { __webpack_exports__PLUGIN_LOADER as PLUGIN_LOADER, __webpack_exports__callStack as callStack, __webpack_exports__callStackSynchronous as callStackSynchronous, __webpack_exports__combinePluginConfigurations as combinePluginConfigurations, __webpack_exports__configuration as configuration, __webpack_exports__createNativeAPIFactory as createNativeAPIFactory, __webpack_exports__default as default, __webpack_exports__determineInternalName as determineInternalName, __webpack_exports__determineLocations as determineLocations, __webpack_exports__evaluateConfiguration as evaluateConfiguration, __webpack_exports__hotReloadAPIFile as hotReloadAPIFile, __webpack_exports__hotReloadConfigurationFile as hotReloadConfigurationFile, __webpack_exports__hotReloadFiles as hotReloadFiles, __webpack_exports__isInLocations as isInLocations, __webpack_exports__isMainModule as isMainModule, __webpack_exports__isMainModulePositiveCalls as isMainModulePositiveCalls, __webpack_exports__load as load, __webpack_exports__loadAPI as loadAPI, __webpack_exports__loadAll as loadAll, __webpack_exports__loadConfiguration as loadConfiguration, __webpack_exports__loadConfigurations as loadConfigurations, __webpack_exports__loadFile as loadFile, __webpack_exports__log as log, __webpack_exports__main as main, __webpack_exports__pluginAPI as pluginAPI };
|
|
668
679
|
/******/
|
package/main.js
CHANGED
|
@@ -23,7 +23,7 @@ __webpack_require__.a(module, async (__webpack_handle_async_dependencies__, __we
|
|
|
23
23
|
/* harmony export */ gl: () => (/* binding */ callStackSynchronous),
|
|
24
24
|
/* harmony export */ lT: () => (/* binding */ _callStack)
|
|
25
25
|
/* harmony export */ });
|
|
26
|
-
/* unused harmony exports log, determineInternalName, evaluateConfiguration, hotReloadAPIFile, hotReloadConfigurationFile, hotReloadFiles, load, createNativeAPIFactory, loadAPI, loadConfiguration, loadConfigurations, loadFile, determineLocations, isInLocations, pluginAPI */
|
|
26
|
+
/* unused harmony exports log, determineInternalName, evaluateConfiguration, hotReloadAPIFile, hotReloadConfigurationFile, hotReloadFiles, combinePluginConfigurations, load, createNativeAPIFactory, loadAPI, loadConfiguration, loadConfigurations, loadFile, determineLocations, isInLocations, pluginAPI */
|
|
27
27
|
/* harmony import */ var core_js_modules_es_array_includes_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8);
|
|
28
28
|
/* harmony import */ var child_process__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9);
|
|
29
29
|
/* harmony import */ var clientnode__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1);
|
|
@@ -136,6 +136,20 @@ for(_i3=0,_Object$entries3=Object.entries(pluginChange.oldScope);_i3<_Object$ent
|
|
|
136
136
|
* @param plugins - List of plugins to search for updates in.
|
|
137
137
|
* @returns A list with plugin changes.
|
|
138
138
|
*/var hotReloadFiles=/*#__PURE__*/function(){var _hotReloadFiles=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(type,target,plugins){var pluginChanges,_iterator5,_step5,plugin,index,_iterator6,_step6,filePath,timestamp,oldScope,_t3,_t4;return _regenerator().w(function(_context5){while(1)switch(_context5.p=_context5.n){case 0:pluginChanges=[];_iterator5=_createForOfIteratorHelper(plugins);_context5.p=1;_iterator5.s();case 2:if((_step5=_iterator5.n()).done){_context5.n=13;break}plugin=_step5.value;if(!plugin[target]){_context5.n=12;break}index=0;_iterator6=_createForOfIteratorHelper(plugin["".concat(type,"FilePaths")]);_context5.p=3;_iterator6.s();case 4:if((_step6=_iterator6.n()).done){_context5.n=9;break}filePath=_step6.value;_context5.n=5;return (0,fs_promises__WEBPACK_IMPORTED_MODULE_4__.stat)(filePath);case 5:timestamp=_context5.v.mtime.getTime();if(!(plugin["".concat(type,"FileLoadTimestamps")][index]<timestamp)){_context5.n=7;break}log.info("Determined updated file \"".concat(filePath,"\"."),"Doing a reload.");oldScope=plugin[target];_context5.n=6;return loadFile(filePath,plugin.name,plugin[target]);case 6:plugin[target]=_context5.v;log.info("File \"".concat(filePath,"\" reloaded."));pluginChanges.push({newScope:plugin[target],oldScope:oldScope,plugin:plugin,target:target});case 7:plugin["".concat(type,"FileLoadTimestamps")][index]=timestamp;index+=1;case 8:_context5.n=4;break;case 9:_context5.n=11;break;case 10:_context5.p=10;_t3=_context5.v;_iterator6.e(_t3);case 11:_context5.p=11;_iterator6.f();return _context5.f(11);case 12:_context5.n=2;break;case 13:_context5.n=15;break;case 14:_context5.p=14;_t4=_context5.v;_iterator5.e(_t4);case 15:_context5.p=15;_iterator5.f();return _context5.f(15);case 16:return _context5.a(2,pluginChanges)}},_callee5,null,[[3,10,11,12],[1,14,15,16]])}));function hotReloadFiles(_x6,_x7,_x8){return _hotReloadFiles.apply(this,arguments)}return hotReloadFiles}();/**
|
|
139
|
+
* Combines given plugin configurations into one and returns a plugin specific
|
|
140
|
+
* meta information object.
|
|
141
|
+
* @param name - Name of the plugin.
|
|
142
|
+
* @param configurations - Array of plugin configurations to combine.
|
|
143
|
+
* @param propertyNames - Array of property names to consider in the
|
|
144
|
+
* configuration.
|
|
145
|
+
* @returns An object of plugin specific meta information.
|
|
146
|
+
*/var combinePluginConfigurations=function combinePluginConfigurations(name,configurations,propertyNames){if(propertyNames===void 0){propertyNames=["webNode"]}var packageConfiguration={};var _iterator7=_createForOfIteratorHelper(configurations),_step7;try{for(_iterator7.s();!(_step7=_iterator7.n()).done;){var configuration=_step7.value;(0,clientnode__WEBPACK_IMPORTED_MODULE_2__.extend)(true,/*
|
|
147
|
+
NOTE: Source and target configuration got modified. While the
|
|
148
|
+
target configuration receives the modifications the source
|
|
149
|
+
configuration will lose their modification expressions
|
|
150
|
+
therefore we can use the source configuration afterward to
|
|
151
|
+
extend the target configuration.
|
|
152
|
+
*/(0,clientnode__WEBPACK_IMPORTED_MODULE_2__.modifyObject)(packageConfiguration,configuration),configuration)}}catch(err){_iterator7.e(err)}finally{_iterator7.f()}name=packageConfiguration.webNodeInternalName||name;return{name:name,configuration:loadConfiguration(packageConfiguration.webNodeInternalName||name,packageConfiguration,propertyNames)}};/**
|
|
139
153
|
* Extends given configuration object with given plugin specific ones and
|
|
140
154
|
* returns a plugin specific meta information object.
|
|
141
155
|
* @param name - Name of plugin to extend.
|
|
@@ -145,13 +159,7 @@ for(_i3=0,_Object$entries3=Object.entries(pluginChange.oldScope);_i3<_Object$ent
|
|
|
145
159
|
* @param pluginPath - Path to given plugin.
|
|
146
160
|
* @param encoding - Encoding to use to read and write from child process's.
|
|
147
161
|
* @returns An object of plugin specific meta information.
|
|
148
|
-
*/var load=/*#__PURE__*/function(){var _load=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(name,internalName,plugins,metaConfiguration,pluginPath,encoding){var configurationFilePaths,
|
|
149
|
-
NOTE: Source and target configuration got modified.
|
|
150
|
-
While the target configuration receives the modifications
|
|
151
|
-
the source configuration will lose their modification
|
|
152
|
-
expressions therefore we can use the source configuration
|
|
153
|
-
afterward to extend the target configuration.
|
|
154
|
-
*/(0,clientnode__WEBPACK_IMPORTED_MODULE_2__.modifyObject)(packageConfiguration,sourceConfiguration),sourceConfiguration);configurationFilePaths.push(filePath);case 5:_context6.n=2;break;case 6:_context6.n=8;break;case 7:_context6.p=7;_t5=_context6.v;_iterator7.e(_t5);case 8:_context6.p=8;_iterator7.f();return _context6.f(8);case 9:apiFilePaths=["index.js"];if(!Object.keys(packageConfiguration).length){_context6.n=11;break}internalName=packageConfiguration.webNodeInternalName||internalName;configuration=loadConfiguration(internalName,packageConfiguration,metaConfiguration.propertyNames);if(configuration[internalName].package.main)apiFilePaths[0]=configuration[internalName].package.main;_context6.n=10;return loadAPI(apiFilePaths,pluginPath,name,internalName,plugins,encoding,configuration,configurationFilePaths);case 10:return _context6.a(2,_context6.v);case 11:_context6.n=12;return loadAPI(apiFilePaths,pluginPath,name,internalName,plugins,encoding);case 12:return _context6.a(2,_context6.v)}},_callee6,null,[[1,7,8,9]])}));function load(_x9,_x0,_x1,_x10,_x11,_x12){return _load.apply(this,arguments)}return load}();/**
|
|
162
|
+
*/var load=/*#__PURE__*/function(){var _load=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(name,internalName,plugins,metaConfiguration,pluginPath,encoding){var configurationFilePaths,sourceConfigurations,_iterator8,_step8,fileName,filePath,_combinePluginConfigu,resolvedInternalName,configuration,apiFilePaths,_t5,_t6;return _regenerator().w(function(_context6){while(1)switch(_context6.p=_context6.n){case 0:if(encoding===void 0){encoding="utf8"}configurationFilePaths=[];sourceConfigurations=[];_iterator8=_createForOfIteratorHelper(metaConfiguration.fileNames);_context6.p=1;_iterator8.s();case 2:if((_step8=_iterator8.n()).done){_context6.n=6;break}fileName=_step8.value;filePath=(0,path__WEBPACK_IMPORTED_MODULE_5__.resolve)(pluginPath,fileName);_context6.n=3;return (0,clientnode__WEBPACK_IMPORTED_MODULE_2__.isFile)(filePath);case 3:if(!_context6.v){_context6.n=5;break}_t5=sourceConfigurations;_context6.n=4;return loadFile(filePath,name);case 4:_t5.push.call(_t5,_context6.v);configurationFilePaths.push(filePath);case 5:_context6.n=2;break;case 6:_context6.n=8;break;case 7:_context6.p=7;_t6=_context6.v;_iterator8.e(_t6);case 8:_context6.p=8;_iterator8.f();return _context6.f(8);case 9:_combinePluginConfigu=combinePluginConfigurations(internalName,sourceConfigurations,metaConfiguration.propertyNames),resolvedInternalName=_combinePluginConfigu.name,configuration=_combinePluginConfigu.configuration;apiFilePaths=["index.js"];if(!Object.keys(configuration[resolvedInternalName].package).length){_context6.n=11;break}if(configuration[resolvedInternalName].package.main)apiFilePaths[0]=configuration[resolvedInternalName].package.main;_context6.n=10;return loadAPI(apiFilePaths,pluginPath,name,resolvedInternalName,plugins,encoding,configuration,configurationFilePaths);case 10:return _context6.a(2,_context6.v);case 11:_context6.n=12;return loadAPI(apiFilePaths,pluginPath,name,resolvedInternalName,plugins,encoding);case 12:return _context6.a(2,_context6.v)}},_callee6,null,[[1,7,8,9]])}));function load(_x9,_x0,_x1,_x10,_x11,_x12){return _load.apply(this,arguments)}return load}();/**
|
|
155
163
|
* Creates a function callable by plugin api which calls the corresponding
|
|
156
164
|
* plugin scope method.
|
|
157
165
|
* @param plugins - To search for plugin scope in.
|
|
@@ -170,14 +178,14 @@ for(_i3=0,_Object$entries3=Object.entries(pluginChange.oldScope);_i3<_Object$ent
|
|
|
170
178
|
* @param configuration - Plugin specific configurations.
|
|
171
179
|
* @param configurationFilePaths - Plugin specific configuration file paths.
|
|
172
180
|
* @returns Plugin meta information object.
|
|
173
|
-
*/var loadAPI=/*#__PURE__*/function(){var _loadAPI=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(relativeFilePaths,pluginPath,name,internalName,plugins,encoding,configuration,configurationFilePaths){var filePath,
|
|
181
|
+
*/var loadAPI=/*#__PURE__*/function(){var _loadAPI=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(relativeFilePaths,pluginPath,name,internalName,plugins,encoding,configuration,configurationFilePaths){var filePath,_iterator9,_step9,fileName,api,nativeAPI,pluginConfiguration,_t7,_t8,_t9,_t0,_t1,_t10,_t11,_t12,_t13,_t14,_t15,_t16,_t17,_t18,_t19,_t20,_t21,_t22,_t23;return _regenerator().w(function(_context8){while(1)switch(_context8.p=_context8.n){case 0:if(encoding===void 0){encoding="utf8"}if(configuration===void 0){configuration=null}if(configurationFilePaths===void 0){configurationFilePaths=[]}filePath=(0,path__WEBPACK_IMPORTED_MODULE_5__.resolve)(pluginPath,relativeFilePaths[0]);_context8.n=1;return (0,clientnode__WEBPACK_IMPORTED_MODULE_2__.isFile)(filePath);case 1:if(_context8.v){_context8.n=11;break}_t7=_createForOfIteratorHelper;_context8.n=2;return (0,fs_promises__WEBPACK_IMPORTED_MODULE_4__.readdir)(pluginPath);case 2:_iterator9=_t7(_context8.v);_context8.p=3;_iterator9.s();case 4:if((_step9=_iterator9.n()).done){_context8.n=8;break}fileName=_step9.value;_t8=!configurationFilePaths.map(function(filePath){return (0,path__WEBPACK_IMPORTED_MODULE_5__.basename)(filePath)}).includes(fileName);if(!_t8){_context8.n=6;break}_context8.n=5;return (0,clientnode__WEBPACK_IMPORTED_MODULE_2__.isFile)((0,path__WEBPACK_IMPORTED_MODULE_5__.resolve)(pluginPath,fileName));case 5:_t8=_context8.v;case 6:if(!_t8){_context8.n=7;break}filePath=(0,path__WEBPACK_IMPORTED_MODULE_5__.resolve)(pluginPath,filePath);if(!["index","main"].includes((0,path__WEBPACK_IMPORTED_MODULE_5__.basename)(filePath,(0,path__WEBPACK_IMPORTED_MODULE_5__.extname)(fileName)))){_context8.n=7;break}return _context8.a(3,8);case 7:_context8.n=4;break;case 8:_context8.n=10;break;case 9:_context8.p=9;_t9=_context8.v;_iterator9.e(_t9);case 10:_context8.p=10;_iterator9.f();return _context8.f(10);case 11:api=null;nativeAPI=false;_t0=configuration&&(/*
|
|
174
182
|
NOTE: Check if a webNode plugin configuration is available
|
|
175
183
|
indicating a backend responsibility for api file.
|
|
176
184
|
|
|
177
185
|
NOTE: One key is always there representing the whole package
|
|
178
186
|
configuration.
|
|
179
|
-
*/Object.keys(configuration).length>1||Object.prototype.hasOwnProperty.call(configuration,internalName)&&Object.keys(configuration[internalName]).length>1);if(!
|
|
180
|
-
api=function api(_ref2){var hook=_ref2.hook,data=_ref2.data;for(var _len4=arguments.length,parameters=new Array(_len4>1?_len4-1:0),_key4=1;_key4<_len4;_key4++){parameters[_key4-1]=arguments[_key4]}var childProcessResult=(0,child_process__WEBPACK_IMPORTED_MODULE_1__.spawnSync)(filePath,[hook].concat(_toConsumableArray(parameters.map(function(item){return JSON.stringify(item)}))),{cwd:process.cwd(),encoding:encoding,env:process.env,input:JSON.stringify(data),shell:true,stdio:"inherit"});if(childProcessResult.status===404)return data;var jsonIndicatorPrefix="##!JSON!##";if(childProcessResult.stdout.startsWith(jsonIndicatorPrefix))return JSON.parse(childProcessResult.stdout.substring(jsonIndicatorPrefix.length));return data};case 14:pluginConfiguration=configuration!==null&&configuration!==void 0?configuration:_defineProperty({},internalName,{package:{}});
|
|
187
|
+
*/Object.keys(configuration).length>1||Object.prototype.hasOwnProperty.call(configuration,internalName)&&Object.keys(configuration[internalName]).length>1);if(!_t0){_context8.n=13;break}_context8.n=12;return (0,clientnode__WEBPACK_IMPORTED_MODULE_2__.isFile)(filePath);case 12:_t0=_context8.v;case 13:if(!_t0){_context8.n=14;break}if(filePath.endsWith(".js")){nativeAPI=true;api=createNativeAPIFactory(plugins,name)}else// NOTE: Any executable file can represent an api.
|
|
188
|
+
api=function api(_ref2){var hook=_ref2.hook,data=_ref2.data;for(var _len4=arguments.length,parameters=new Array(_len4>1?_len4-1:0),_key4=1;_key4<_len4;_key4++){parameters[_key4-1]=arguments[_key4]}var childProcessResult=(0,child_process__WEBPACK_IMPORTED_MODULE_1__.spawnSync)(filePath,[hook].concat(_toConsumableArray(parameters.map(function(item){return JSON.stringify(item)}))),{cwd:process.cwd(),encoding:encoding,env:process.env,input:JSON.stringify(data),shell:true,stdio:"inherit"});if(childProcessResult.status===404)return data;var jsonIndicatorPrefix="##!JSON!##";if(childProcessResult.stdout.startsWith(jsonIndicatorPrefix))return JSON.parse(childProcessResult.stdout.substring(jsonIndicatorPrefix.length));return data};case 14:pluginConfiguration=configuration!==null&&configuration!==void 0?configuration:_defineProperty({},internalName,{package:{}});_t1=api;if(!api){_context8.n=16;break}_context8.n=15;return (0,fs_promises__WEBPACK_IMPORTED_MODULE_4__.stat)(filePath);case 15:_t11=_context8.v.mtime.getTime();_t10=[_t11];_context8.n=17;break;case 16:_t10=[];case 17:_t12=_t10;_t13=api?[filePath]:[];_t14=pluginConfiguration;_t15=configurationFilePaths;_context8.n=18;return Promise.all(configurationFilePaths.map(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(filePath){return _regenerator().w(function(_context7){while(1)switch(_context7.n){case 0:_context7.n=1;return (0,fs_promises__WEBPACK_IMPORTED_MODULE_4__.stat)(filePath);case 1:return _context7.a(2,_context7.v.mtime.getTime())}},_callee7)}))));case 18:_t16=_context8.v;_t17=Object.prototype.hasOwnProperty.call(pluginConfiguration,internalName)&&pluginConfiguration[internalName].dependencies?pluginConfiguration[internalName].dependencies:[];_t18=internalName;_t19=name;_t20=pluginConfiguration[internalName].package;_t21=pluginPath;if(!nativeAPI){_context8.n=20;break}_context8.n=19;return loadFile(filePath,name);case 19:_t22=_context8.v;_context8.n=21;break;case 20:_t22=null;case 21:_t23=_t22;return _context8.a(2,{api:_t1,apiFileLoadTimestamps:_t12,apiFilePaths:_t13,configuration:_t14,configurationFilePaths:_t15,configurationFileLoadTimestamps:_t16,dependencies:_t17,internalName:_t18,name:_t19,packageConfiguration:_t20,path:_t21,scope:_t23})}},_callee8,null,[[3,9,10,11]])}));function loadAPI(_x13,_x14,_x15,_x16,_x17,_x18,_x19,_x20){return _loadAPI.apply(this,arguments)}return loadAPI}();/**
|
|
181
189
|
* Loads plugin specific configuration object.
|
|
182
190
|
* @param name - Property name where to inject resolved configuration into
|
|
183
191
|
* global one.
|
|
@@ -189,10 +197,10 @@ api=function api(_ref2){var hook=_ref2.hook,data=_ref2.data;for(var _len4=argume
|
|
|
189
197
|
No plugin specific configuration found. Only provide package
|
|
190
198
|
configuration.
|
|
191
199
|
Removing comments (default key prefix to delete is "#").
|
|
192
|
-
*/var packageConfigurationCopy=(0,clientnode__WEBPACK_IMPORTED_MODULE_2__.removeKeyPrefixes)((0,clientnode__WEBPACK_IMPORTED_MODULE_2__.copy)(packageConfiguration));var result=_defineProperty({},name,{package:packageConfigurationCopy});var
|
|
200
|
+
*/var packageConfigurationCopy=(0,clientnode__WEBPACK_IMPORTED_MODULE_2__.removeKeyPrefixes)((0,clientnode__WEBPACK_IMPORTED_MODULE_2__.copy)(packageConfiguration));var result=_defineProperty({},name,{package:packageConfigurationCopy});var _iterator0=_createForOfIteratorHelper(configurationPropertyNames),_step0;try{for(_iterator0.s();!(_step0=_iterator0.n()).done;){var propertyName=_step0.value;if(packageConfiguration[propertyName]){(0,clientnode__WEBPACK_IMPORTED_MODULE_2__.extend)(true,result,packageConfiguration[propertyName]);/*
|
|
193
201
|
NOTE: We should break the cycle here to avoid endless loops
|
|
194
202
|
when traversing this data structure.
|
|
195
|
-
*/delete result[name].package[propertyName];break}}}catch(err){
|
|
203
|
+
*/delete result[name].package[propertyName];break}}}catch(err){_iterator0.e(err)}finally{_iterator0.f()}return result};/**
|
|
196
204
|
* Loads given plugin configurations into global configuration.
|
|
197
205
|
* @param plugins - Topological sorted list of plugins to check for
|
|
198
206
|
* configurations.
|
|
@@ -201,7 +209,7 @@ api=function api(_ref2){var hook=_ref2.hook,data=_ref2.data;for(var _len4=argume
|
|
|
201
209
|
*/var loadConfigurations=function loadConfigurations(plugins,configuration){/*
|
|
202
210
|
First clear current configuration content key by key to let old top
|
|
203
211
|
level configuration object instance untouched.
|
|
204
|
-
*/for(var _i4=0,_Object$keys=Object.keys(configuration);_i4<_Object$keys.length;_i4++){var key=_Object$keys[_i4];delete configuration[key]};(0,clientnode__WEBPACK_IMPORTED_MODULE_2__.extend)(configuration,(0,clientnode__WEBPACK_IMPORTED_MODULE_2__.copy)(_configurator_js__WEBPACK_IMPORTED_MODULE_6__/* ["default"] */ .A));var
|
|
212
|
+
*/for(var _i4=0,_Object$keys=Object.keys(configuration);_i4<_Object$keys.length;_i4++){var key=_Object$keys[_i4];delete configuration[key]};(0,clientnode__WEBPACK_IMPORTED_MODULE_2__.extend)(configuration,(0,clientnode__WEBPACK_IMPORTED_MODULE_2__.copy)(_configurator_js__WEBPACK_IMPORTED_MODULE_6__/* ["default"] */ .A));var _iterator1=_createForOfIteratorHelper(plugins),_step1;try{for(_iterator1.s();!(_step1=_iterator1.n()).done;){var plugin=_step1.value;if(Object.prototype.hasOwnProperty.call(plugin,"configuration")){var pluginConfiguration=(0,clientnode__WEBPACK_IMPORTED_MODULE_2__.copy)(plugin.configuration);(0,clientnode__WEBPACK_IMPORTED_MODULE_2__.extend)(true,(0,clientnode__WEBPACK_IMPORTED_MODULE_2__.modifyObject)(configuration,pluginConfiguration),/*
|
|
205
213
|
NOTE: Should be resolved via preceding
|
|
206
214
|
"object.modifyObject" call.
|
|
207
215
|
*/pluginConfiguration);/*
|
|
@@ -209,7 +217,7 @@ api=function api(_ref2){var hook=_ref2.hook,data=_ref2.data;for(var _len4=argume
|
|
|
209
217
|
specific configuration set to give runtime configuration always
|
|
210
218
|
the highest priority when resolving intermediate configuration
|
|
211
219
|
states.
|
|
212
|
-
*/if(configuration.core.runtimeConfiguration)(0,clientnode__WEBPACK_IMPORTED_MODULE_2__.extend)(true,configuration,configuration.core.runtimeConfiguration)}}}catch(err){
|
|
220
|
+
*/if(configuration.core.runtimeConfiguration)(0,clientnode__WEBPACK_IMPORTED_MODULE_2__.extend)(true,configuration,configuration.core.runtimeConfiguration)}}}catch(err){_iterator1.e(err)}finally{_iterator1.f()}return evaluateConfiguration(configuration)};/**
|
|
213
221
|
* Load given api file path and returns exported scope.
|
|
214
222
|
* @param filePath - Path to file to load.
|
|
215
223
|
* @param name - Plugin name to use for proper error messages.
|
|
@@ -217,7 +225,7 @@ api=function api(_ref2){var hook=_ref2.hook,data=_ref2.data;for(var _len4=argume
|
|
|
217
225
|
* If a "null" is given an error will be thrown.
|
|
218
226
|
* @param doLogging - Enables logging.
|
|
219
227
|
* @returns Exported api file scope.
|
|
220
|
-
*/var loadFile=/*#__PURE__*/function(){var _loadFile=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(filePath,name,fallbackScope,doLogging){var options,scope,
|
|
228
|
+
*/var loadFile=/*#__PURE__*/function(){var _loadFile=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(filePath,name,fallbackScope,doLogging){var options,scope,_t24;return _regenerator().w(function(_context9){while(1)switch(_context9.p=_context9.n){case 0:if(fallbackScope===void 0){fallbackScope=null}if(doLogging===void 0){doLogging=true}// Clear module cache if possible in the future.
|
|
221
229
|
/*
|
|
222
230
|
let reference: string | undefined
|
|
223
231
|
try {
|
|
@@ -228,17 +236,17 @@ api=function api(_ref2){var hook=_ref2.hook,data=_ref2.data;for(var _len4=argume
|
|
|
228
236
|
|
|
229
237
|
if (reference)
|
|
230
238
|
// Clear the module cache.
|
|
231
|
-
*/options={};if((0,path__WEBPACK_IMPORTED_MODULE_5__.extname)(filePath)===".json")options.with={type:"json"};_context9.p=1;_context9.n=2;return import(/* webpackIgnore: true */"".concat(filePath,"?timestamp=").concat(String(Date.now())),options);case 2:scope=_context9.v;_context9.n=5;break;case 3:_context9.p=3;
|
|
239
|
+
*/options={};if((0,path__WEBPACK_IMPORTED_MODULE_5__.extname)(filePath)===".json")options.with={type:"json"};_context9.p=1;_context9.n=2;return import(/* webpackIgnore: true */"".concat(filePath,"?timestamp=").concat(String(Date.now())),options);case 2:scope=_context9.v;_context9.n=5;break;case 3:_context9.p=3;_t24=_context9.v;if(!fallbackScope){_context9.n=4;break}scope=fallbackScope;if(doLogging)log.warn("Couldn't load new api plugin file \"".concat(filePath,"\" for"),"plugin \"".concat(name,"\": ").concat((0,clientnode__WEBPACK_IMPORTED_MODULE_2__.represent)(_t24),". Using"),"fallback one.");_context9.n=5;break;case 4:throw new Error("Couldn't load plugin file \"".concat(filePath,"\" for plugin ")+"\"".concat(name,"\": ").concat((0,clientnode__WEBPACK_IMPORTED_MODULE_2__.represent)(_t24)),{cause:_t24});case 5:if(!(Object.prototype.hasOwnProperty.call(scope,"default")&&scope.default)){_context9.n=6;break}return _context9.a(2,scope.default);case 6:return _context9.a(2,scope)}},_callee9,null,[[1,3]])}));function loadFile(_x22,_x23,_x24,_x25){return _loadFile.apply(this,arguments)}return loadFile}();/**
|
|
232
240
|
* Extends given configuration object with all plugin specific ones and returns
|
|
233
241
|
* a topological sorted list of plugins with plugins specific meta information
|
|
234
242
|
* stored.
|
|
235
243
|
* @param configuration - Configuration object to extend and use.
|
|
236
244
|
* @returns A topological sorted list of plugins objects.
|
|
237
|
-
*/var loadAll=/*#__PURE__*/function(){var _loadAll=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(configuration){var _configuration$core$p;var plugins,_i5,_Object$values,directory,_directory$nameRegula,compiledRegularExpression,
|
|
245
|
+
*/var loadAll=/*#__PURE__*/function(){var _loadAll=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(configuration){var _configuration$core$p;var plugins,_i5,_Object$values,directory,_directory$nameRegula,compiledRegularExpression,_iterator10,_step10,pluginName,currentPluginPath,internalName,_i6,_Object$entries4,_Object$entries4$_i,name,plugin,pluginConfiguration,scope,_internalName,temporaryPlugins,_i7,_Object$values2,_plugin,_iterator11,_step11,_name2,sortedPlugins,_iterator12,_step12,_pluginName,_i8,_Object$entries5,_Object$entries5$_i,_name3,_plugin2,_t25,_t26,_t27,_t28,_t29;return _regenerator().w(function(_context0){while(1)switch(_context0.p=_context0.n){case 0:plugins={};/*
|
|
238
246
|
Load main plugin configuration at first.
|
|
239
247
|
|
|
240
248
|
NOTE: If application's main is this itself avoid loading it twice.
|
|
241
|
-
*/if(!(configuration.name!=="web-node")){_context0.n=2;break}_context0.n=1;return load(configuration.name,determineInternalName(configuration.name,new RegExp((_configuration$core$p=configuration.core.plugin.directories.external.nameRegularExpressionPattern)!==null&&_configuration$core$p!==void 0?_configuration$core$p:configuration.core.plugin.nameRegularExpressionPattern)),plugins,configuration.core.plugin.configuration,configuration.core.context.path,configuration.core.encoding);case 1:plugins[configuration.name]=_context0.v;case 2:_i5=0,_Object$values=Object.values(configuration.core.plugin.directories);case 3:if(!(_i5<_Object$values.length)){_context0.n=15;break}directory=_Object$values[_i5];_context0.n=4;return (0,clientnode__WEBPACK_IMPORTED_MODULE_2__.isDirectory)(directory.path);case 4:if(!_context0.v){_context0.n=14;break}compiledRegularExpression=new RegExp((_directory$nameRegula=directory.nameRegularExpressionPattern)!==null&&_directory$nameRegula!==void 0?_directory$nameRegula:configuration.core.plugin.nameRegularExpressionPattern);
|
|
249
|
+
*/if(!(configuration.name!=="web-node")){_context0.n=2;break}_context0.n=1;return load(configuration.name,determineInternalName(configuration.name,new RegExp((_configuration$core$p=configuration.core.plugin.directories.external.nameRegularExpressionPattern)!==null&&_configuration$core$p!==void 0?_configuration$core$p:configuration.core.plugin.nameRegularExpressionPattern)),plugins,configuration.core.plugin.configuration,configuration.core.context.path,configuration.core.encoding);case 1:plugins[configuration.name]=_context0.v;case 2:_i5=0,_Object$values=Object.values(configuration.core.plugin.directories);case 3:if(!(_i5<_Object$values.length)){_context0.n=15;break}directory=_Object$values[_i5];_context0.n=4;return (0,clientnode__WEBPACK_IMPORTED_MODULE_2__.isDirectory)(directory.path);case 4:if(!_context0.v){_context0.n=14;break}compiledRegularExpression=new RegExp((_directory$nameRegula=directory.nameRegularExpressionPattern)!==null&&_directory$nameRegula!==void 0?_directory$nameRegula:configuration.core.plugin.nameRegularExpressionPattern);_t25=_createForOfIteratorHelper;_context0.n=5;return (0,fs_promises__WEBPACK_IMPORTED_MODULE_4__.readdir)(directory.path);case 5:_iterator10=_t25(_context0.v);_context0.p=6;_iterator10.s();case 7:if((_step10=_iterator10.n()).done){_context0.n=11;break}pluginName=_step10.value;if(compiledRegularExpression.test(pluginName)){_context0.n=8;break}return _context0.a(3,10);case 8:currentPluginPath=(0,path__WEBPACK_IMPORTED_MODULE_5__.resolve)(directory.path,pluginName);internalName=determineInternalName(pluginName,compiledRegularExpression);_context0.n=9;return load(pluginName,internalName,plugins,configuration.core.plugin.configuration,currentPluginPath,configuration.core.encoding);case 9:plugins[pluginName]=_context0.v;case 10:_context0.n=7;break;case 11:_context0.n=13;break;case 12:_context0.p=12;_t26=_context0.v;_iterator10.e(_t26);case 13:_context0.p=13;_iterator10.f();return _context0.f(13);case 14:_i5++;_context0.n=3;break;case 15:_i6=0,_Object$entries4=Object.entries(PLUGIN_LOADER);case 16:if(!(_i6<_Object$entries4.length)){_context0.n=20;break}_Object$entries4$_i=_slicedToArray(_Object$entries4[_i6],2),name=_Object$entries4$_i[0],plugin=_Object$entries4$_i[1];_context0.n=17;return plugin.loadConfiguration();case 17:pluginConfiguration=_context0.v;_context0.n=18;return plugin.loadScope();case 18:scope=_context0.v;_internalName=determineInternalName(name,new RegExp(configuration.core.plugin.nameRegularExpressionPattern));plugins[name]={api:createNativeAPIFactory(plugins,name),apiFileLoadTimestamps:[],apiFilePaths:[],configuration:pluginConfiguration,configurationFilePaths:[],configurationFileLoadTimestamps:[],dependencies:Object.prototype.hasOwnProperty.call(pluginConfiguration,_internalName)&&pluginConfiguration[_internalName].dependencies?pluginConfiguration[_internalName].dependencies:[],internalName:_internalName,name:name,packageConfiguration:pluginConfiguration[_internalName].package,path:"",scope:scope};case 19:_i6++;_context0.n=16;break;case 20:temporaryPlugins={};for(_i7=0,_Object$values2=Object.values(plugins);_i7<_Object$values2.length;_i7++){_plugin=_Object$values2[_i7];temporaryPlugins[_plugin.internalName]=_plugin.dependencies;if(Object.prototype.hasOwnProperty.call(configuration.core.interDependencies,_plugin.internalName)){_iterator11=_createForOfIteratorHelper([].concat(configuration.core.interDependencies[_plugin.internalName]));try{for(_iterator11.s();!(_step11=_iterator11.n()).done;){_name2=_step11.value;if(!temporaryPlugins[_plugin.internalName].includes(_name2))temporaryPlugins[_plugin.internalName].push(_name2)}}catch(err){_iterator11.e(err)}finally{_iterator11.f()}}}sortedPlugins=[];_iterator12=_createForOfIteratorHelper((0,clientnode__WEBPACK_IMPORTED_MODULE_2__.sortTopological)(temporaryPlugins));_context0.p=21;_iterator12.s();case 22:if((_step12=_iterator12.n()).done){_context0.n=26;break}_pluginName=_step12.value;_i8=0,_Object$entries5=Object.entries(plugins);case 23:if(!(_i8<_Object$entries5.length)){_context0.n=25;break}_Object$entries5$_i=_slicedToArray(_Object$entries5[_i8],2),_name3=_Object$entries5$_i[0],_plugin2=_Object$entries5$_i[1];if(![_plugin2.internalName,_name3].includes(_pluginName)){_context0.n=24;break}sortedPlugins.push(_plugin2);return _context0.a(3,25);case 24:_i8++;_context0.n=23;break;case 25:_context0.n=22;break;case 26:_context0.n=28;break;case 27:_context0.p=27;_t27=_context0.v;_iterator12.e(_t27);case 28:_context0.p=28;_iterator12.f();return _context0.f(28);case 29:_context0.n=30;return loadConfigurations(sortedPlugins,configuration);case 30:_t28=_context0.v;_t29=sortedPlugins;return _context0.a(2,{configuration:_t28,plugins:_t29})}},_callee0,null,[[21,27,28,29],[6,12,13,14]])}));function loadAll(_x26){return _loadAll.apply(this,arguments)}return loadAll}();/**
|
|
242
250
|
* Transform a list of absolute paths respecting the application context.
|
|
243
251
|
* @param configuration - Configuration object.
|
|
244
252
|
* @param configuration.core - Sub configuration web-node.
|
|
@@ -254,7 +262,7 @@ api=function api(_ref2){var hook=_ref2.hook,data=_ref2.data;for(var _len4=argume
|
|
|
254
262
|
* @param locations - Locations to search in.
|
|
255
263
|
* @returns A boolean indicating whether given file path is in provided
|
|
256
264
|
* locations.
|
|
257
|
-
*/var isInLocations=function isInLocations(configuration,plugins,filePath,locations){var pluginPaths=plugins.map(function(plugin){return plugin.path});var
|
|
265
|
+
*/var isInLocations=function isInLocations(configuration,plugins,filePath,locations){var pluginPaths=plugins.map(function(plugin){return plugin.path});var _iterator13=_createForOfIteratorHelper([].concat(locations)),_step13;try{for(_iterator13.s();!(_step13=_iterator13.n()).done;){var location=_step13.value;if(location.startsWith("/")){if(filePath.startsWith((0,path__WEBPACK_IMPORTED_MODULE_5__.join)(configuration.core.context.path,location)))return true}else{var _iterator14=_createForOfIteratorHelper(pluginPaths),_step14;try{for(_iterator14.s();!(_step14=_iterator14.n()).done;){var pluginPath=_step14.value;if(filePath.startsWith((0,path__WEBPACK_IMPORTED_MODULE_5__.resolve)(pluginPath,location)))return true}}catch(err){_iterator14.e(err)}finally{_iterator14.f()}}}}catch(err){_iterator13.e(err)}finally{_iterator13.f()}return false};var pluginAPI={callStack:_callStack,callStackSynchronous:callStackSynchronous,determineInternalName:determineInternalName,determineLocations:determineLocations,evaluateConfiguration:evaluateConfiguration,hotReloadAPIFile:hotReloadAPIFile,hotReloadConfigurationFile:hotReloadConfigurationFile,hotReloadFiles:hotReloadFiles,isInLocations:isInLocations,load:load,loadAll:loadAll,loadAPI:loadAPI,loadConfiguration:loadConfiguration,loadConfigurations:loadConfigurations,loadFile:loadFile};/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (pluginAPI);
|
|
258
266
|
__webpack_async_result__();
|
|
259
267
|
} catch(e) { __webpack_async_result__(e); } }, 1);
|
|
260
268
|
|
|
@@ -416,7 +424,7 @@ __webpack_async_result__();
|
|
|
416
424
|
/* 7 */
|
|
417
425
|
/***/ ((module) => {
|
|
418
426
|
|
|
419
|
-
module.exports = /*#__PURE__*/JSON.parse('{"name":"web-node","version":"1.0.
|
|
427
|
+
module.exports = /*#__PURE__*/JSON.parse('{"name":"web-node","version":"1.0.609","description":"High level javaScript backend plugin system and configuration merger.","keywords":["api","backend","management","plugin","web"],"homepage":"https://torben.website/web-node","bugs":{"email":"info@torben.website","url":"https://github.com/thaibault/web-node/issues"},"license":"CC-BY-3.0","author":{"email":"info@torben.website","name":"Torben Sickert","url":"https://torben.website"},"repository":{"type":"git","url":"https://github.com/thaibault/web-node.git"},"type":"module","bin":"main.js","exports":{".":"./index.js","./main":"./main.js","./main.js":"./main.js","./package.json":"./package.json","./unixCrypt":"./unixCrypt.js","./unixCrypt.js":"./unixCrypt.js","./type":"./type.d.ts"},"files":["configurator.d.ts","index.d.ts","index.js","main.js","pluginAPI.d.ts","type.d.ts","unixCrypt.d.ts","unixCrypt.js"],"sideEffects":true,"scripts":{"build":"yarn build:types; yarn build:plain","build:plain":"weboptimizer build","build:types":"weboptimizer build:types","check":"yarn check:types; yarn lint","check:types":"weboptimizer check:types","clear":"weboptimizer clear","document":"weboptimizer document","lint":"weboptimizer lint","prepare":"yarn build","prepare:test":"yarn clear && cd dummyPlugin && shx touch yarn.lock && yarn build && cd ..","serve":"yarn build:plain && yarn start","start":"./main.js \'{plugin: {hotReloading: true}}\'","test":"yarn prepare:test && weboptimizer test","test:coverage":"yarn prepare:test && weboptimizer test:coverage","test:coverage:report":"yarn prepare:test && weboptimizer test:coverage:report","update:documentation":"web-documentation","watch":"weboptimizer build --watch"},"devDependencies":{"@babel/cli":"^8.0.4","@babel/eslint-parser":"^8.0.1","@eslint/js":"^10.0.1","@stylistic/eslint-plugin":"^5.10.0","@types/node":"^26.4.1","@types/webpack-env":"^1.18.8","@typescript-eslint/eslint-plugin":"^8.69.0","@typescript-eslint/parser":"^8.69.0","clientnode":"^4.0.1512","eslint":"^10.10.0","eslint-config-google":"^0.14.0","eslint-plugin-jsdoc":"^64.3.6","jest":"^30.5.1","jsdoc":"^4.0.5","shx":"^0.4.0","typescript-eslint":"^8.69.0","web-documentation":"^1.0.52","weboptimizer":"^4.0.78"},"peerDependencies":{"clientnode":"*"},"resolutions":{"colors":"1.4.0","globals@npm:^11.1.0":"patch:globals@npm%3A11.12.0#~/.yarn/patches/globals-npm-11.12.0-1fa7f41a6c.patch","globals@npm:^14.0.0":"patch:globals@npm%3A11.12.0#~/.yarn/patches/globals-npm-11.12.0-1fa7f41a6c.patch","globals@npm:^9.18.0":"patch:globals@npm%3A11.12.0#~/.yarn/patches/globals-npm-11.12.0-1fa7f41a6c.patch"},"engines":{"node":">=26","npm":">=12","yarn":">=4"},"webDocumentation":{"trackingCode":"UA-40192634-9"},"webNode":{"core":{"context":{"path":"./","type":"relative"},"debug":false,"encoding":"utf8","interDependencies":{},"name":"web-node","plugin":{"configuration":{"fileNames":["package.json","private-package.json"],"propertyNames":["webNode","webnode","web-node"]},"nameRegularExpressionPattern":"^([a-zA-Z0-9-]+?)-?[wW]eb-?[nN]ode-?[pP]lugin$","directories":{"external":{"path":{"__evaluate__":"`${currentPath}/node_modules/`"}},"internal":{"nameRegularExpressionPattern":"^([a-zA-Z0-9-_].*)$","path":{"__evaluate__":"`${currentPath}/plugins/`"}}},"hotReloading":false}}},"webOptimizer":{"assetPattern":{"javaScript":{"includeFilePathRegularExpression":"^(.+/)?main\\\\.js$","pattern":{"#":"This is how we can make our main exported artefact executable.","__evaluate__":"`#!/usr/bin/env node\\n// -*- coding: utf-8 -*-\\n${self.generic.assetPattern?.javaScript?.pattern ?? \'\'}\\n{1}`"}}},"injection":{"entry":{"__evaluate__":"2 < self.givenCommandLineArguments.length && self.givenCommandLineArguments[2].startsWith(\'test\') ? {testBundle: \'test\'} : {index: \'./index.ts\', main: \'./main.ts\', unixCrypt: \'./unixCrypt.ts\'}"}},"module":{"optimizer":{"terser":{"terserOptions":{"compress":{"#":"To provide a logging output we need to exclude this feature.","drop_console":{"__evaluate__":"false"},"drop_debugger":{"__evaluate__":"false"}}}}}},"targetTechnology":{"boilerplate":"node","payload":"node"}},"packageManager":"yarn@4.18.0"}');
|
|
420
428
|
|
|
421
429
|
/***/ }),
|
|
422
430
|
/* 8 */
|
package/package.json
CHANGED
package/pluginAPI.d.ts
CHANGED
|
@@ -60,6 +60,19 @@ export declare const hotReloadConfigurationFile: (plugins: Array<Plugin>, config
|
|
|
60
60
|
* @returns A list with plugin changes.
|
|
61
61
|
*/
|
|
62
62
|
export declare const hotReloadFiles: (type: 'api' | 'configuration', target: 'packageConfiguration' | 'scope', plugins: Array<Plugin>) => Promise<Array<PluginChange>>;
|
|
63
|
+
/**
|
|
64
|
+
* Combines given plugin configurations into one and returns a plugin specific
|
|
65
|
+
* meta information object.
|
|
66
|
+
* @param name - Name of the plugin.
|
|
67
|
+
* @param configurations - Array of plugin configurations to combine.
|
|
68
|
+
* @param propertyNames - Array of property names to consider in the
|
|
69
|
+
* configuration.
|
|
70
|
+
* @returns An object of plugin specific meta information.
|
|
71
|
+
*/
|
|
72
|
+
export declare const combinePluginConfigurations: (name: string, configurations: Array<object>, propertyNames?: Array<string>) => {
|
|
73
|
+
name: string;
|
|
74
|
+
configuration: EvaluateablePartialConfiguration;
|
|
75
|
+
};
|
|
63
76
|
/**
|
|
64
77
|
* Extends given configuration object with given plugin specific ones and
|
|
65
78
|
* returns a plugin specific meta information object.
|