web-node 1.0.606 → 1.0.608
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 +25 -22
- package/main.js +22 -22
- package/package.json +2 -2
- package/pluginAPI.d.ts +4 -0
- package/type.d.ts +2 -2
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),
|
|
@@ -146,7 +147,13 @@ for(_i3=0,_Object$entries3=Object.entries(pluginChange.oldScope);_i3<_Object$ent
|
|
|
146
147
|
* which should be updated.
|
|
147
148
|
* @param plugins - List of plugins to search for updates in.
|
|
148
149
|
* @returns A list with plugin changes.
|
|
149
|
-
*/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}()
|
|
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}();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,/*
|
|
151
|
+
NOTE: Source and target configuration got modified. While the
|
|
152
|
+
target configuration receives the modifications the source
|
|
153
|
+
configuration will lose their modification expressions
|
|
154
|
+
therefore we can use the source configuration afterward to
|
|
155
|
+
extend the target configuration.
|
|
156
|
+
*/(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
157
|
* Extends given configuration object with given plugin specific ones and
|
|
151
158
|
* returns a plugin specific meta information object.
|
|
152
159
|
* @param name - Name of plugin to extend.
|
|
@@ -156,13 +163,7 @@ for(_i3=0,_Object$entries3=Object.entries(pluginChange.oldScope);_i3<_Object$ent
|
|
|
156
163
|
* @param pluginPath - Path to given plugin.
|
|
157
164
|
* @param encoding - Encoding to use to read and write from child process's.
|
|
158
165
|
* @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}();/**
|
|
166
|
+
*/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
167
|
* Creates a function callable by plugin api which calls the corresponding
|
|
167
168
|
* plugin scope method.
|
|
168
169
|
* @param plugins - To search for plugin scope in.
|
|
@@ -181,14 +182,14 @@ for(_i3=0,_Object$entries3=Object.entries(pluginChange.oldScope);_i3<_Object$ent
|
|
|
181
182
|
* @param configuration - Plugin specific configurations.
|
|
182
183
|
* @param configurationFilePaths - Plugin specific configuration file paths.
|
|
183
184
|
* @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,
|
|
185
|
+
*/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
186
|
NOTE: Check if a webNode plugin configuration is available
|
|
186
187
|
indicating a backend responsibility for api file.
|
|
187
188
|
|
|
188
189
|
NOTE: One key is always there representing the whole package
|
|
189
190
|
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:{}});
|
|
191
|
+
*/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.
|
|
192
|
+
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
193
|
* Loads plugin specific configuration object.
|
|
193
194
|
* @param name - Property name where to inject resolved configuration into
|
|
194
195
|
* global one.
|
|
@@ -200,10 +201,10 @@ api=function api(_ref2){var hook=_ref2.hook,data=_ref2.data;for(var _len4=argume
|
|
|
200
201
|
No plugin specific configuration found. Only provide package
|
|
201
202
|
configuration.
|
|
202
203
|
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
|
|
204
|
+
*/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
205
|
NOTE: We should break the cycle here to avoid endless loops
|
|
205
206
|
when traversing this data structure.
|
|
206
|
-
*/delete result[name].package[propertyName];break}}}catch(err){
|
|
207
|
+
*/delete result[name].package[propertyName];break}}}catch(err){_iterator0.e(err)}finally{_iterator0.f()}return result};/**
|
|
207
208
|
* Loads given plugin configurations into global configuration.
|
|
208
209
|
* @param plugins - Topological sorted list of plugins to check for
|
|
209
210
|
* configurations.
|
|
@@ -212,7 +213,7 @@ api=function api(_ref2){var hook=_ref2.hook,data=_ref2.data;for(var _len4=argume
|
|
|
212
213
|
*/var loadConfigurations=function loadConfigurations(plugins,configuration){/*
|
|
213
214
|
First clear current configuration content key by key to let old top
|
|
214
215
|
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
|
|
216
|
+
*/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
217
|
NOTE: Should be resolved via preceding
|
|
217
218
|
"object.modifyObject" call.
|
|
218
219
|
*/pluginConfiguration);/*
|
|
@@ -220,7 +221,7 @@ api=function api(_ref2){var hook=_ref2.hook,data=_ref2.data;for(var _len4=argume
|
|
|
220
221
|
specific configuration set to give runtime configuration always
|
|
221
222
|
the highest priority when resolving intermediate configuration
|
|
222
223
|
states.
|
|
223
|
-
*/if(configuration.core.runtimeConfiguration)(0,clientnode__WEBPACK_IMPORTED_MODULE_2__.extend)(true,configuration,configuration.core.runtimeConfiguration)}}}catch(err){
|
|
224
|
+
*/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
225
|
* Load given api file path and returns exported scope.
|
|
225
226
|
* @param filePath - Path to file to load.
|
|
226
227
|
* @param name - Plugin name to use for proper error messages.
|
|
@@ -228,7 +229,7 @@ api=function api(_ref2){var hook=_ref2.hook,data=_ref2.data;for(var _len4=argume
|
|
|
228
229
|
* If a "null" is given an error will be thrown.
|
|
229
230
|
* @param doLogging - Enables logging.
|
|
230
231
|
* @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,
|
|
232
|
+
*/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
233
|
/*
|
|
233
234
|
let reference: string | undefined
|
|
234
235
|
try {
|
|
@@ -239,17 +240,17 @@ api=function api(_ref2){var hook=_ref2.hook,data=_ref2.data;for(var _len4=argume
|
|
|
239
240
|
|
|
240
241
|
if (reference)
|
|
241
242
|
// 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;
|
|
243
|
+
*/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
244
|
* Extends given configuration object with all plugin specific ones and returns
|
|
244
245
|
* a topological sorted list of plugins with plugins specific meta information
|
|
245
246
|
* stored.
|
|
246
247
|
* @param configuration - Configuration object to extend and use.
|
|
247
248
|
* @returns A topological sorted list of plugins objects.
|
|
248
|
-
*/var loadAll=/*#__PURE__*/function(){var _loadAll=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(configuration){var plugins,_i5,_Object$values,directory,compiledRegularExpression,
|
|
249
|
+
*/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
250
|
Load main plugin configuration at first.
|
|
250
251
|
|
|
251
252
|
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.plugin.directories.external.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.nameRegularExpressionPattern);
|
|
253
|
+
*/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
254
|
* Transform a list of absolute paths respecting the application context.
|
|
254
255
|
* @param configuration - Configuration object.
|
|
255
256
|
* @param configuration.core - Sub configuration web-node.
|
|
@@ -265,7 +266,7 @@ api=function api(_ref2){var hook=_ref2.hook,data=_ref2.data;for(var _len4=argume
|
|
|
265
266
|
* @param locations - Locations to search in.
|
|
266
267
|
* @returns A boolean indicating whether given file path is in provided
|
|
267
268
|
* locations.
|
|
268
|
-
*/var isInLocations=function isInLocations(configuration,plugins,filePath,locations){var pluginPaths=plugins.map(function(plugin){return plugin.path});var
|
|
269
|
+
*/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
270
|
__webpack_async_result__();
|
|
270
271
|
} catch(e) { __webpack_async_result__(e); } }, 1);
|
|
271
272
|
|
|
@@ -380,6 +381,7 @@ __webpack_require__.a(module, async (__webpack_handle_async_dependencies__, __we
|
|
|
380
381
|
/* harmony export */ Rm: () => (/* binding */ log),
|
|
381
382
|
/* harmony export */ Vx: () => (/* reexport safe */ _pluginAPI_js__WEBPACK_IMPORTED_MODULE_1__.Vx),
|
|
382
383
|
/* harmony export */ ZN: () => (/* reexport safe */ _pluginAPI_js__WEBPACK_IMPORTED_MODULE_1__.ZN),
|
|
384
|
+
/* harmony export */ c0: () => (/* reexport safe */ _pluginAPI_js__WEBPACK_IMPORTED_MODULE_1__.c0),
|
|
383
385
|
/* harmony export */ dw: () => (/* reexport safe */ _pluginAPI_js__WEBPACK_IMPORTED_MODULE_1__.dw),
|
|
384
386
|
/* harmony export */ eQ: () => (/* binding */ isMainModule),
|
|
385
387
|
/* harmony export */ gh: () => (/* reexport safe */ _pluginAPI_js__WEBPACK_IMPORTED_MODULE_1__.gh),
|
|
@@ -448,7 +450,7 @@ __webpack_async_result__();
|
|
|
448
450
|
/* 7 */
|
|
449
451
|
/***/ ((module) => {
|
|
450
452
|
|
|
451
|
-
module.exports = /*#__PURE__*/JSON.parse('{"name":"web-node","version":"1.0.
|
|
453
|
+
module.exports = /*#__PURE__*/JSON.parse('{"name":"web-node","version":"1.0.608","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
454
|
|
|
453
455
|
/***/ }),
|
|
454
456
|
/* 8 */
|
|
@@ -643,6 +645,7 @@ module.exports = x({ ["fileURLToPath"]: () => (__WEBPACK_EXTERNAL_MODULE_node_ur
|
|
|
643
645
|
/******/ const __webpack_exports__PLUGIN_LOADER = __webpack_exports__.GU;
|
|
644
646
|
/******/ const __webpack_exports__callStack = __webpack_exports__.lT;
|
|
645
647
|
/******/ const __webpack_exports__callStackSynchronous = __webpack_exports__.gl;
|
|
648
|
+
/******/ const __webpack_exports__combinePluginConfigurations = __webpack_exports__.c0;
|
|
646
649
|
/******/ const __webpack_exports__configuration = __webpack_exports__.HF;
|
|
647
650
|
/******/ const __webpack_exports__createNativeAPIFactory = __webpack_exports__.Oy;
|
|
648
651
|
/******/ const __webpack_exports__default = __webpack_exports__.Ay;
|
|
@@ -664,5 +667,5 @@ module.exports = x({ ["fileURLToPath"]: () => (__WEBPACK_EXTERNAL_MODULE_node_ur
|
|
|
664
667
|
/******/ const __webpack_exports__log = __webpack_exports__.Rm;
|
|
665
668
|
/******/ const __webpack_exports__main = __webpack_exports__.iW;
|
|
666
669
|
/******/ 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 };
|
|
670
|
+
/******/ 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
671
|
/******/
|
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);
|
|
@@ -135,7 +135,13 @@ for(_i3=0,_Object$entries3=Object.entries(pluginChange.oldScope);_i3<_Object$ent
|
|
|
135
135
|
* which should be updated.
|
|
136
136
|
* @param plugins - List of plugins to search for updates in.
|
|
137
137
|
* @returns A list with plugin changes.
|
|
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}()
|
|
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}();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,/*
|
|
139
|
+
NOTE: Source and target configuration got modified. While the
|
|
140
|
+
target configuration receives the modifications the source
|
|
141
|
+
configuration will lose their modification expressions
|
|
142
|
+
therefore we can use the source configuration afterward to
|
|
143
|
+
extend the target configuration.
|
|
144
|
+
*/(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
145
|
* Extends given configuration object with given plugin specific ones and
|
|
140
146
|
* returns a plugin specific meta information object.
|
|
141
147
|
* @param name - Name of plugin to extend.
|
|
@@ -145,13 +151,7 @@ for(_i3=0,_Object$entries3=Object.entries(pluginChange.oldScope);_i3<_Object$ent
|
|
|
145
151
|
* @param pluginPath - Path to given plugin.
|
|
146
152
|
* @param encoding - Encoding to use to read and write from child process's.
|
|
147
153
|
* @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}();/**
|
|
154
|
+
*/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
155
|
* Creates a function callable by plugin api which calls the corresponding
|
|
156
156
|
* plugin scope method.
|
|
157
157
|
* @param plugins - To search for plugin scope in.
|
|
@@ -170,14 +170,14 @@ for(_i3=0,_Object$entries3=Object.entries(pluginChange.oldScope);_i3<_Object$ent
|
|
|
170
170
|
* @param configuration - Plugin specific configurations.
|
|
171
171
|
* @param configurationFilePaths - Plugin specific configuration file paths.
|
|
172
172
|
* @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,
|
|
173
|
+
*/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
174
|
NOTE: Check if a webNode plugin configuration is available
|
|
175
175
|
indicating a backend responsibility for api file.
|
|
176
176
|
|
|
177
177
|
NOTE: One key is always there representing the whole package
|
|
178
178
|
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:{}});
|
|
179
|
+
*/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.
|
|
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:{}});_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
181
|
* Loads plugin specific configuration object.
|
|
182
182
|
* @param name - Property name where to inject resolved configuration into
|
|
183
183
|
* global one.
|
|
@@ -189,10 +189,10 @@ api=function api(_ref2){var hook=_ref2.hook,data=_ref2.data;for(var _len4=argume
|
|
|
189
189
|
No plugin specific configuration found. Only provide package
|
|
190
190
|
configuration.
|
|
191
191
|
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
|
|
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 _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
193
|
NOTE: We should break the cycle here to avoid endless loops
|
|
194
194
|
when traversing this data structure.
|
|
195
|
-
*/delete result[name].package[propertyName];break}}}catch(err){
|
|
195
|
+
*/delete result[name].package[propertyName];break}}}catch(err){_iterator0.e(err)}finally{_iterator0.f()}return result};/**
|
|
196
196
|
* Loads given plugin configurations into global configuration.
|
|
197
197
|
* @param plugins - Topological sorted list of plugins to check for
|
|
198
198
|
* configurations.
|
|
@@ -201,7 +201,7 @@ api=function api(_ref2){var hook=_ref2.hook,data=_ref2.data;for(var _len4=argume
|
|
|
201
201
|
*/var loadConfigurations=function loadConfigurations(plugins,configuration){/*
|
|
202
202
|
First clear current configuration content key by key to let old top
|
|
203
203
|
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
|
|
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 _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
205
|
NOTE: Should be resolved via preceding
|
|
206
206
|
"object.modifyObject" call.
|
|
207
207
|
*/pluginConfiguration);/*
|
|
@@ -209,7 +209,7 @@ api=function api(_ref2){var hook=_ref2.hook,data=_ref2.data;for(var _len4=argume
|
|
|
209
209
|
specific configuration set to give runtime configuration always
|
|
210
210
|
the highest priority when resolving intermediate configuration
|
|
211
211
|
states.
|
|
212
|
-
*/if(configuration.core.runtimeConfiguration)(0,clientnode__WEBPACK_IMPORTED_MODULE_2__.extend)(true,configuration,configuration.core.runtimeConfiguration)}}}catch(err){
|
|
212
|
+
*/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
213
|
* Load given api file path and returns exported scope.
|
|
214
214
|
* @param filePath - Path to file to load.
|
|
215
215
|
* @param name - Plugin name to use for proper error messages.
|
|
@@ -217,7 +217,7 @@ api=function api(_ref2){var hook=_ref2.hook,data=_ref2.data;for(var _len4=argume
|
|
|
217
217
|
* If a "null" is given an error will be thrown.
|
|
218
218
|
* @param doLogging - Enables logging.
|
|
219
219
|
* @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,
|
|
220
|
+
*/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
221
|
/*
|
|
222
222
|
let reference: string | undefined
|
|
223
223
|
try {
|
|
@@ -228,17 +228,17 @@ api=function api(_ref2){var hook=_ref2.hook,data=_ref2.data;for(var _len4=argume
|
|
|
228
228
|
|
|
229
229
|
if (reference)
|
|
230
230
|
// 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;
|
|
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;_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
232
|
* Extends given configuration object with all plugin specific ones and returns
|
|
233
233
|
* a topological sorted list of plugins with plugins specific meta information
|
|
234
234
|
* stored.
|
|
235
235
|
* @param configuration - Configuration object to extend and use.
|
|
236
236
|
* @returns A topological sorted list of plugins objects.
|
|
237
|
-
*/var loadAll=/*#__PURE__*/function(){var _loadAll=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(configuration){var plugins,_i5,_Object$values,directory,compiledRegularExpression,
|
|
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,_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
238
|
Load main plugin configuration at first.
|
|
239
239
|
|
|
240
240
|
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.plugin.directories.external.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.nameRegularExpressionPattern);
|
|
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);_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
242
|
* Transform a list of absolute paths respecting the application context.
|
|
243
243
|
* @param configuration - Configuration object.
|
|
244
244
|
* @param configuration.core - Sub configuration web-node.
|
|
@@ -254,7 +254,7 @@ api=function api(_ref2){var hook=_ref2.hook,data=_ref2.data;for(var _len4=argume
|
|
|
254
254
|
* @param locations - Locations to search in.
|
|
255
255
|
* @returns A boolean indicating whether given file path is in provided
|
|
256
256
|
* locations.
|
|
257
|
-
*/var isInLocations=function isInLocations(configuration,plugins,filePath,locations){var pluginPaths=plugins.map(function(plugin){return plugin.path});var
|
|
257
|
+
*/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
258
|
__webpack_async_result__();
|
|
259
259
|
} catch(e) { __webpack_async_result__(e); } }, 1);
|
|
260
260
|
|
|
@@ -416,7 +416,7 @@ __webpack_async_result__();
|
|
|
416
416
|
/* 7 */
|
|
417
417
|
/***/ ((module) => {
|
|
418
418
|
|
|
419
|
-
module.exports = /*#__PURE__*/JSON.parse('{"name":"web-node","version":"1.0.
|
|
419
|
+
module.exports = /*#__PURE__*/JSON.parse('{"name":"web-node","version":"1.0.608","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
420
|
|
|
421
421
|
/***/ }),
|
|
422
422
|
/* 8 */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "web-node",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.608",
|
|
4
4
|
"description": "High level javaScript backend plugin system and configuration merger.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"api",
|
|
@@ -124,9 +124,9 @@
|
|
|
124
124
|
"web-node"
|
|
125
125
|
]
|
|
126
126
|
},
|
|
127
|
+
"nameRegularExpressionPattern": "^([a-zA-Z0-9-]+?)-?[wW]eb-?[nN]ode-?[pP]lugin$",
|
|
127
128
|
"directories": {
|
|
128
129
|
"external": {
|
|
129
|
-
"nameRegularExpressionPattern": "^([a-zA-Z0-9-]+?)-?[wW]eb-?[nN]ode-?[pP]lugin$",
|
|
130
130
|
"path": {
|
|
131
131
|
"__evaluate__": "`${currentPath}/node_modules/`"
|
|
132
132
|
}
|
package/pluginAPI.d.ts
CHANGED
|
@@ -60,6 +60,10 @@ 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
|
+
export declare const combinePluginConfigurations: (name: string, configurations: Array<object>, propertyNames?: Array<string>) => {
|
|
64
|
+
name: string;
|
|
65
|
+
configuration: EvaluateablePartialConfiguration;
|
|
66
|
+
};
|
|
63
67
|
/**
|
|
64
68
|
* Extends given configuration object with given plugin specific ones and
|
|
65
69
|
* returns a plugin specific meta information object.
|
package/type.d.ts
CHANGED
|
@@ -35,8 +35,9 @@ export interface WebNodeConfiguration extends PluginConfiguration {
|
|
|
35
35
|
name: string;
|
|
36
36
|
plugin: {
|
|
37
37
|
configuration: MetaPluginConfiguration;
|
|
38
|
+
nameRegularExpressionPattern: string;
|
|
38
39
|
directories: Mapping<{
|
|
39
|
-
nameRegularExpressionPattern
|
|
40
|
+
nameRegularExpressionPattern?: string;
|
|
40
41
|
path: string;
|
|
41
42
|
}>;
|
|
42
43
|
hotReloading: boolean;
|
|
@@ -85,7 +86,6 @@ export type HookPromiseResult<Type> = Promise<Type | {
|
|
|
85
86
|
}>;
|
|
86
87
|
export type PluginPromises<Type extends Promise<unknown> = Promise<unknown>> = Mapping<null | Type>;
|
|
87
88
|
export type PluginLoaderMapping = Mapping<{
|
|
88
|
-
name?: string;
|
|
89
89
|
loadConfiguration: () => Promise<EvaluateablePartialConfiguration>;
|
|
90
90
|
loadScope: () => Promise<object>;
|
|
91
91
|
}>;
|