@teqfw/di 0.12.1 → 0.20.1

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.
Files changed (41) hide show
  1. package/.eslintrc.mjs +0 -0
  2. package/README.md +27 -0
  3. package/RELEASE.md +11 -1
  4. package/bin/release/clean.sh +2 -1
  5. package/dist/di.cjs.js +205 -0
  6. package/dist/di.esm.js +206 -0
  7. package/index.cjs +5 -0
  8. package/index.mjs +6 -0
  9. package/package.json +14 -4
  10. package/src/Api/ObjectKey.js +35 -0
  11. package/src/Composer.js +68 -0
  12. package/src/Container.js +142 -0
  13. package/src/Defs.js +25 -0
  14. package/src/DepId/Parser.mjs +68 -0
  15. package/src/Parser/Def.js +63 -0
  16. package/src/Parser/Old.js +108 -0
  17. package/src/Parser.js +65 -0
  18. package/src/PreProcessor/Replace.js +48 -0
  19. package/src/PreProcessor.js +45 -0
  20. package/src/Resolver.js +65 -0
  21. package/src/Spec/Parser.mjs +101 -0
  22. package/src/SpecAnalyser.js +82 -0
  23. package/teqfw.json +2 -1
  24. package/webpack.config.mjs +15 -0
  25. package/src/Back/Api/Dto/Plugin/Desc.mjs +0 -70
  26. package/src/Back/Api/Dto/Scanned.mjs +0 -12
  27. package/src/Back/Api/README.md +0 -1
  28. package/src/Back/Defaults.mjs +0 -11
  29. package/src/Back/Plugin/Scanner.mjs +0 -154
  30. package/src/Back/README.md +0 -1
  31. package/src/Shared/Api/Dto/Plugin/Desc/Autoload.mjs +0 -50
  32. package/src/Shared/Api/IProxy.mjs +0 -11
  33. package/src/Shared/Container.mjs +0 -333
  34. package/src/Shared/IdParser/Dto.mjs +0 -96
  35. package/src/Shared/IdParser.mjs +0 -187
  36. package/src/Shared/ModuleLoader.mjs +0 -38
  37. package/src/Shared/README.md +0 -1
  38. package/src/Shared/Resolver/FilepathNs.mjs +0 -51
  39. package/src/Shared/Resolver/LogicalNs.mjs +0 -136
  40. package/src/Shared/Resolver.mjs +0 -74
  41. package/src/Shared/SpecProxy.mjs +0 -110
package/.eslintrc.mjs ADDED
File without changes
package/README.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @teqfw/di
2
2
 
3
+ * Главная цель этого функционала - позднее связывание с минимальным ручным конфигурированием контейнера. Все инструкции
4
+ для связывания заложены в идентификаторах зависимостей.
5
+ * Этот DI нужен для того, чтобы связывать runtime-объекты на этапе кодирования без дополнительных конфигурационных
6
+ файлов. Конфигурационные файлы могут понадобиться при изменении связывания на этапе выполнения.
7
+ * "раннее связывание" - для изменения связности исходный код должен быть изменён и перекомпилирован. При позднем
8
+ связывании изменения можно вносить на этапе выполнения программы через конфигурацию контейнера.
9
+ * DI позволяет перехватывать создание зависимостей и адаптировать их под конкретный контекст. Если перехват создания
10
+ невозможен - это не DI.
11
+
3
12
  "_DI_" means both "_Dynamic Import_" and "_Dependency Injection_" here. This package allows defining logical namespaces
4
13
  in your projects, dynamically importing ES6-modules from these namespaces, creating new objects from imported
5
14
  functions/classes and resolving dependencies in constructors. It uses pure ECMAScript 2015+ (ES6+) and works both for
@@ -71,5 +80,23 @@ PHP [Zend 1](https://framework.zend.com/manual/2.4/en/migration/namespacing-old-
71
80
 
72
81
 
73
82
  ## More
83
+ <script type="module">
84
+ const baseUrl = location.href;
85
+ // load DI container as ES6 module (w/o namespaces)
86
+ import(baseUrl + 'node_modules/@teqfw/di/src/Container.mjs').then(async (modContainer) => {
87
+ // init container and setup namespaces mapping
88
+ /** @type {TeqFw_Di_Container} */
89
+ const container = new modContainer.default();
90
+ const pathMain = baseUrl + 'node_modules/@flancer64/demo_teqfw_di_mod_main/src';
91
+ const pathPlugin = baseUrl + 'node_modules/@flancer64/demo_teqfw_di_mod_plugin/src';
92
+ container.addSourceMapping('Vnd_Pkg', pathMain, true, 'mjs');
93
+ container.addSourceMapping('Vnd_Pkg_Plugin', pathPlugin, true, 'mjs');
94
+ // get main front as singleton
95
+ /** @type {Vnd_Pkg_Front} */
96
+ const frontMain = await container.get('Vnd_Pkg_Front$');
97
+ frontMain.run();
98
+ });
99
+ </script>
100
+ ```
74
101
 
75
102
  [See more here.](https://github.com/teqfw/di/blob/main/README.md#namespaces)
package/RELEASE.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @teqfw/di releases
2
2
 
3
+ ## 0.20.1
4
+
5
+ * Changed regex for parameter extraction in the Spec Analyzer.
6
+ * Removed leading namespace separator in the Resolver.
7
+ * Added `teqfw.json` descriptor to add npm-package to DI container as a sources root in `teqfw/web`.
8
+
9
+ ## 0.20.0
10
+
11
+ * Fully redesigned package with simplified composition of objects in the container. Spec Analyzer is used instead of a
12
+ proxy object.
3
13
 
4
14
  ## 0.12.1
5
15
 
@@ -30,4 +40,4 @@
30
40
  * docs for plugin's teq-descriptor (see in `main` branch);
31
41
  * use object notation instead of array notation in namespace replacement statements of
32
42
  teq-descriptor (`@teqfw/di.replace` node format is changed in `./teqfw.json`);
33
- * array is used as a container for upline dependencies in [SpecProxy](./src/Shared/SpecProxy.mjs) (object was);
43
+ * array is used as a container for upline dependencies in the 'SpecProxy' (object was);
@@ -4,8 +4,9 @@
4
4
  ##
5
5
  DIR_ROOT=${DIR_ROOT:-$(cd "$(dirname "$0")/../../" && pwd)}
6
6
 
7
+ rm -fr "${DIR_ROOT}/demo/"
7
8
  rm -fr "${DIR_ROOT}/doc/"
9
+ rm -fr "${DIR_ROOT}/example/"
8
10
  rm -fr "${DIR_ROOT}/node_modules/"
9
- rm -fr "${DIR_ROOT}/package-lock.json"
10
11
  rm -fr "${DIR_ROOT}/test/"
11
12
  rm -fr "${DIR_ROOT}/tmp/"
package/dist/di.cjs.js ADDED
@@ -0,0 +1,205 @@
1
+ /*
2
+ * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
3
+ * This devtool is neither made for production nor for readable output files.
4
+ * It uses "eval()" calls to create a separate source file in the browser devtools.
5
+ * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
6
+ * or disable the default devtool with "devtool: false".
7
+ * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
8
+ */
9
+ /******/ (() => { // webpackBootstrap
10
+ /******/ var __webpack_modules__ = ({
11
+
12
+ /***/ "./src lazy recursive":
13
+ /*!*******************************************!*\
14
+ !*** ./src/ lazy strict namespace object ***!
15
+ \*******************************************/
16
+ /***/ ((module) => {
17
+
18
+ eval("function webpackEmptyAsyncContext(req) {\n\t// Here Promise.resolve().then() is used instead of new Promise() to prevent\n\t// uncaught exception popping up in devtools\n\treturn Promise.resolve().then(() => {\n\t\tvar e = new Error(\"Cannot find module '\" + req + \"'\");\n\t\te.code = 'MODULE_NOT_FOUND';\n\t\tthrow e;\n\t});\n}\nwebpackEmptyAsyncContext.keys = () => ([]);\nwebpackEmptyAsyncContext.resolve = webpackEmptyAsyncContext;\nwebpackEmptyAsyncContext.id = \"./src lazy recursive\";\nmodule.exports = webpackEmptyAsyncContext;\n\n//# sourceURL=webpack://@teqfw/di/./src/_lazy_strict_namespace_object?");
19
+
20
+ /***/ }),
21
+
22
+ /***/ "./index.cjs":
23
+ /*!*******************!*\
24
+ !*** ./index.cjs ***!
25
+ \*******************/
26
+ /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
27
+
28
+ eval("/**\n * Entry point to build web bundle (Common JS).\n */\nconst {default: Container} = __webpack_require__(/*! ./src/Container.js */ \"./src/Container.js\");\nwindow.TeqFwDi = Container;\n\n\n//# sourceURL=webpack://@teqfw/di/./index.cjs?");
29
+
30
+ /***/ }),
31
+
32
+ /***/ "./src/Api/ObjectKey.js":
33
+ /*!******************************!*\
34
+ !*** ./src/Api/ObjectKey.js ***!
35
+ \******************************/
36
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
37
+
38
+ "use strict";
39
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ TeqFw_Di_Api_ObjectKey)\n/* harmony export */ });\n/**\n * This is a DTO that represents the structure of an ID for a runtime dependency.\n */\nclass TeqFw_Di_Api_ObjectKey {\n /**\n * The name of an export of the module.\n * @type {string}\n */\n exportName;\n /**\n * Composition type (see Defs.COMPOSE_): use the export as Factory (F) or return as-is (A).\n * @type {string}\n */\n composition;\n /**\n * Lifestyle type (see Defs.LIFE_): singleton (S) or instance (I).\n * @type {string}\n */\n life;\n /**\n * The code for ES6 module that can be converted to the path to this es6 module.\n * @type {string}\n */\n moduleName;\n /**\n * Object key value.\n * @type {string}\n */\n value;\n /**\n * List of wrappers to decorate the result.\n * @type {string[]}\n */\n wrappers = [];\n}\n\n//# sourceURL=webpack://@teqfw/di/./src/Api/ObjectKey.js?");
40
+
41
+ /***/ }),
42
+
43
+ /***/ "./src/Composer.js":
44
+ /*!*************************!*\
45
+ !*** ./src/Composer.js ***!
46
+ \*************************/
47
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
48
+
49
+ "use strict";
50
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ TeqFw_Di_Composer)\n/* harmony export */ });\n/* harmony import */ var _Defs_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Defs.js */ \"./src/Defs.js\");\n/* harmony import */ var _SpecAnalyser_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./SpecAnalyser.js */ \"./src/SpecAnalyser.js\");\n/**\n *\n */\n\n\n\n// FUNCS\n\n// MAIN\nclass TeqFw_Di_Composer {\n\n constructor() {\n // VARS\n let _debug = false;\n\n // FUNCS\n function log(msg) {\n if (_debug) console.log(msg);\n }\n\n // INSTANCE METHODS\n\n /**\n *\n * @param {TeqFw_Di_Api_ObjectKey} key\n * @param {Object} module\n * @param {string[]} stack array of the parent objects to prevent dependency loop\n * @param {TeqFw_Di_Container} container\n * @return {Promise<*>}\n */\n this.create = async function (key, module, stack, container) {\n if (stack.includes(key.value))\n throw new Error(`Circular dependency for '${key.value}'. Parents are: ${JSON.stringify(stack)}`);\n if (key.exportName) {\n // use export from the es6-module\n const stackNew = [...stack, key.value];\n const {[key.exportName]: exp} = module;\n if (key.composition === _Defs_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].COMPOSE_FACTORY) {\n if (typeof exp === 'function') {\n // create deps for factory function\n const deps = (0,_SpecAnalyser_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(exp);\n if (deps.length) log(`Deps for object '${key.value}' are: ${JSON.stringify(deps)}`);\n const spec = {};\n for (const dep of deps)\n spec[dep] = await container.get(dep, stackNew);\n // create a new object with the factory function\n const res = (_Defs_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isClass(exp)) ? new exp(spec) : exp(spec);\n if (res instanceof Promise)\n return await res;\n else\n return res;\n } else\n // just clone the export\n return Object.assign({}, exp);\n } else\n return exp;\n } else {\n return module;\n }\n };\n\n this.setDebug = function (data) {\n _debug = data;\n };\n\n // MAIN\n }\n};\n\n//# sourceURL=webpack://@teqfw/di/./src/Composer.js?");
51
+
52
+ /***/ }),
53
+
54
+ /***/ "./src/Container.js":
55
+ /*!**************************!*\
56
+ !*** ./src/Container.js ***!
57
+ \**************************/
58
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
59
+
60
+ "use strict";
61
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ TeqFw_Di_Container)\n/* harmony export */ });\n/* harmony import */ var _Composer_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Composer.js */ \"./src/Composer.js\");\n/* harmony import */ var _Defs_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Defs.js */ \"./src/Defs.js\");\n/* harmony import */ var _Parser_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Parser.js */ \"./src/Parser.js\");\n/* harmony import */ var _PreProcessor_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./PreProcessor.js */ \"./src/PreProcessor.js\");\n/* harmony import */ var _PreProcessor_Replace_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./PreProcessor/Replace.js */ \"./src/PreProcessor/Replace.js\");\n/* harmony import */ var _Resolver_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Resolver.js */ \"./src/Resolver.js\");\n/**\n * The Object Container (composition root).\n */\n\n\n\n\n\n\n\n// VARS\n\n// FUNCS\n/**\n * ID to store singletons in the internal registry.\n * @param {TeqFw_Di_Api_ObjectKey} key\n * @return {string}\n */\nfunction getSingletonId(key) {\n return `${key.moduleName}#${key.exportName}`;\n}\n\n// MAIN\nclass TeqFw_Di_Container {\n\n constructor() {\n // VARS\n let _composer = new _Composer_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"]();\n let _debug = false;\n let _parser = new _Parser_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"]();\n let _preProcessor = new _PreProcessor_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"]();\n _preProcessor.addHandler((0,_PreProcessor_Replace_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"])()); // create new instance of the replacement handler\n\n /**\n * Registry for loaded es6 modules.\n * @type {Object<string, Module>}\n */\n const _regModules = {};\n /**\n * Registry to store singletons.\n * @type {Object<string, *>}\n */\n const _regSingles = {};\n let _resolver = new _Resolver_js__WEBPACK_IMPORTED_MODULE_5__[\"default\"]();\n\n // FUNCS\n function error() {\n console.error(...arguments);\n }\n\n function log() {\n if (_debug) console.log(...arguments);\n }\n\n\n // INSTANCE METHODS\n\n this.get = async function (objectKey, stack = []) {\n log(`Object '${objectKey}' is requested.`);\n // return container itself if requested\n if (\n (objectKey === _Defs_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].KEY_CONTAINER) ||\n (objectKey === _Defs_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].KEY_CONTAINER_NS)\n ) {\n log(`Container itself is returned.`);\n return _regSingles[_Defs_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].KEY_CONTAINER];\n }\n // parse the `objectKey` and get the structured DTO\n const parsed = _parser.parse(objectKey);\n // modify original key according to some rules (replacements, etc.)\n const key = _preProcessor.process(parsed);\n // return existing singleton\n if (key.life === _Defs_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].LIFE_SINGLETON) {\n const singleId = getSingletonId(key);\n if (_regSingles[singleId]) {\n log(`Existing singleton '${singleId}' is returned.`);\n return _regSingles[singleId];\n }\n }\n // load es6 module if not loaded before\n if (!_regModules[key.moduleName]) {\n log(`ES6 module '${key.moduleName}' is not loaded yet`);\n // convert module name to the path to es6-module file with a sources\n const path = _resolver.resolve(key.moduleName);\n try {\n _regModules[key.moduleName] = await __webpack_require__(\"./src lazy recursive\")(path);\n log(`ES6 module '${key.moduleName}' is loaded from '${path}'.`);\n } catch (e) {\n console.error(\n e?.message,\n `Object key: \"${objectKey}\".`,\n `Path: \"${path}\".`,\n `Stack: ${JSON.stringify(stack)}`\n );\n throw e;\n }\n\n }\n // create object using the composer\n let res = await _composer.create(key, _regModules[key.moduleName], stack, this);\n log(`Object '${objectKey}' is created.`);\n\n // TODO: refactor this code to use wrappers w/o hardcode\n if (key.wrappers.includes(_Defs_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].WRAP_PROXY)) {\n const me = this;\n res = new Proxy({dep: undefined, objectKey}, {\n get: async function (base, name) {\n if (name === 'create') base.dep = await me.get(base.objectKey);\n return base.dep;\n }\n });\n }\n\n if (key.life === _Defs_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].LIFE_SINGLETON) {\n const singleId = getSingletonId(key);\n _regSingles[singleId] = res;\n log(`Object '${objectKey}' is saved as singleton.`);\n }\n return res;\n };\n\n this.getParser = () => _parser;\n\n this.getPreProcessor = () => _preProcessor\n ;\n this.getResolver = () => _resolver;\n\n this.setDebug = function (data) {\n _debug = data;\n _composer.setDebug(data);\n };\n\n this.setParser = (data) => _parser = data;\n\n this.setPreProcessor = (data) => _preProcessor = data;\n\n this.setResolver = (data) => _resolver = data;\n\n // MAIN\n _regSingles[_Defs_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].KEY_CONTAINER] = this;\n }\n};\n\n//# sourceURL=webpack://@teqfw/di/./src/Container.js?");
62
+
63
+ /***/ }),
64
+
65
+ /***/ "./src/Defs.js":
66
+ /*!*********************!*\
67
+ !*** ./src/Defs.js ***!
68
+ \*********************/
69
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
70
+
71
+ "use strict";
72
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/**\n * Hardcoded constants for the package.\n */\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({\n COMPOSE_AS_IS: 'A',\n COMPOSE_FACTORY: 'F',\n EXT: 'js',\n KEY_CONTAINER: 'container',\n KEY_CONTAINER_NS: 'TeqFw_Di_Container$',\n LIFE_INSTANCE: 'I',\n LIFE_SINGLETON: 'S',\n WRAP_PROXY: 'proxy',\n\n /**\n * Return 'true' if function is a class definition.\n * See: https://stackoverflow.com/a/29094018/4073821\n *\n * @param {function} fn\n * @return {boolean}\n */\n isClass(fn) {\n const proto = Object.getOwnPropertyDescriptor(fn, 'prototype');\n return proto && !proto.writable;\n },\n});\n\n//# sourceURL=webpack://@teqfw/di/./src/Defs.js?");
73
+
74
+ /***/ }),
75
+
76
+ /***/ "./src/Parser.js":
77
+ /*!***********************!*\
78
+ !*** ./src/Parser.js ***!
79
+ \***********************/
80
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
81
+
82
+ "use strict";
83
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ TeqFw_Di_Parser)\n/* harmony export */ });\n/* harmony import */ var _Parser_Def_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Parser/Def.js */ \"./src/Parser/Def.js\");\n/**\n * The root parser for `objectKeys` contains all other parsers.\n * It calls the other parser one by one to parse the object key as a structure.\n * Every npm package can have its own format for an `objectKey`.\n */\n\n\n// VARS\nconst KEY_PARSER = 'parser';\nconst KEY_VALIDATOR = 'validator';\n\n// MAIN\nclass TeqFw_Di_Parser {\n\n constructor() {\n // VARS\n /**\n * Default parsing function.\n * @type {(function(string): TeqFw_Di_Api_ObjectKey)}\n */\n let _defaultParser = _Parser_Def_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"];\n /**\n * The array of the pairs {validator, parser} to parse objectKeys.\n * @type {Object<validator:function, parser:function>[]}\n */\n const _parsers = [];\n\n // INSTANCE METHODS\n\n /**\n *\n * @param {function(string):boolean} validator\n * @param {function(string):TeqFw_Di_Api_ObjectKey} parser\n */\n this.addParser = function (validator, parser) {\n _parsers.push({[KEY_VALIDATOR]: validator, [KEY_PARSER]: parser});\n };\n\n /**\n * @param {string} objectKey\n * @return {TeqFw_Di_Api_ObjectKey}\n */\n this.parse = function (objectKey) {\n let res;\n for (const one of _parsers) {\n if (one[KEY_VALIDATOR](objectKey)) {\n res = one[KEY_PARSER](objectKey);\n break;\n }\n }\n if (!res)\n res = _defaultParser(objectKey);\n return res;\n };\n\n /**\n * @param {function(string):TeqFw_Di_Api_ObjectKey} parser\n */\n this.setDefaultParser = function (parser) {\n _defaultParser = parser;\n };\n\n // MAIN\n }\n};\n\n//# sourceURL=webpack://@teqfw/di/./src/Parser.js?");
84
+
85
+ /***/ }),
86
+
87
+ /***/ "./src/Parser/Def.js":
88
+ /*!***************************!*\
89
+ !*** ./src/Parser/Def.js ***!
90
+ \***************************/
91
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
92
+
93
+ "use strict";
94
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ TeqFw_Di_Parser_Def)\n/* harmony export */ });\n/* harmony import */ var _Api_ObjectKey_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Api/ObjectKey.js */ \"./src/Api/ObjectKey.js\");\n/* harmony import */ var _Defs_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Defs.js */ \"./src/Defs.js\");\n/**\n * Default parser for object keys in format:\n * - Vnd_Pkg_Prj_Mod$FA\n */\n\n\n\n// VARS\n/** @type {RegExp} expression for default object key (Ns_Module[.|#]export$[F|A][S|I]) */\nconst REGEXP = /^((([A-Z])[A-Za-z0-9_]*)((#|\\.)?([A-Za-z0-9]*)((\\$)([F|A])?([S|I])?)?)?)$/;\n\n\n// MAIN\n/**\n * @param {string} objectKey\n * @return {TeqFw_Di_Api_ObjectKey}\n */\nfunction TeqFw_Di_Parser_Def(objectKey) {\n const res = new _Api_ObjectKey_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"]();\n res.value = objectKey;\n const parts = REGEXP.exec(objectKey);\n if (parts) {\n res.moduleName = parts[2];\n if (parts[5] === '.') {\n // App_Service.export...\n if (parts[8] === '$') {\n // App_Service.export$...\n res.composition = _Defs_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].COMPOSE_FACTORY;\n res.exportName = parts[6];\n res.life = (parts[10] === _Defs_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].LIFE_INSTANCE)\n ? _Defs_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].LIFE_INSTANCE : _Defs_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].LIFE_SINGLETON;\n } else {\n res.composition = ((parts[8] === undefined) || (parts[8] === _Defs_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].COMPOSE_AS_IS))\n ? _Defs_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].COMPOSE_AS_IS : _Defs_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].COMPOSE_FACTORY;\n res.exportName = parts[6];\n res.life = ((parts[8] === undefined) || (parts[10] === _Defs_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].LIFE_SINGLETON))\n ? _Defs_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].LIFE_SINGLETON : _Defs_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].LIFE_INSTANCE;\n }\n\n\n } else if (parts[8] === '$') {\n // App_Logger$FS\n res.composition = ((parts[9] === undefined) || (parts[9] === _Defs_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].COMPOSE_FACTORY))\n ? _Defs_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].COMPOSE_FACTORY : _Defs_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].COMPOSE_AS_IS;\n res.exportName = 'default';\n if (parts[10]) {\n res.life = (parts[10] === _Defs_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].LIFE_SINGLETON) ? _Defs_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].LIFE_SINGLETON : _Defs_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].LIFE_INSTANCE;\n } else {\n res.life = (res.composition === _Defs_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].COMPOSE_FACTORY) ? _Defs_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].LIFE_SINGLETON : _Defs_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].LIFE_INSTANCE;\n }\n } else {\n // App_Service\n res.composition = _Defs_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].COMPOSE_AS_IS;\n res.exportName = 'default';\n res.life = _Defs_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].LIFE_SINGLETON;\n }\n }\n\n // we should always use singletons for as-is exports\n if ((res.composition === _Defs_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].COMPOSE_AS_IS) && (res.life === _Defs_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].LIFE_INSTANCE))\n throw new Error(`Export is not a function and should be used as a singleton only: '${res.value}'.`);\n return res;\n}\n\n//# sourceURL=webpack://@teqfw/di/./src/Parser/Def.js?");
95
+
96
+ /***/ }),
97
+
98
+ /***/ "./src/PreProcessor.js":
99
+ /*!*****************************!*\
100
+ !*** ./src/PreProcessor.js ***!
101
+ \*****************************/
102
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
103
+
104
+ "use strict";
105
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ TeqFw_Di_PreProcessor)\n/* harmony export */ });\n/**\n * The preprocessor handles object keys after the parsing but before creating any objects.\n * A replacement rules can be implemented here.\n * Every handler is a function with 2 arguments:\n * - objectKey: current key after processing with other handlers;\n * - originalKey: the key before any processing;\n */\nclass TeqFw_Di_PreProcessor {\n\n constructor() {\n // VARS\n /**\n * The array of handlers in the dependency order (from the basic (di) up to the app).\n * @type {Array<function(TeqFw_Di_Api_ObjectKey, TeqFw_Di_Api_ObjectKey):TeqFw_Di_Api_ObjectKey>}\n */\n const _handlers = [];\n\n // INSTANCE METHODS\n\n /**\n *\n * @param {function(TeqFw_Di_Api_ObjectKey, TeqFw_Di_Api_ObjectKey):TeqFw_Di_Api_ObjectKey} hndl\n */\n this.addHandler = function (hndl) {\n _handlers.push(hndl);\n };\n\n /**\n * Get all pre-processing handlers.\n * @return {Array<function(TeqFw_Di_Api_ObjectKey, TeqFw_Di_Api_ObjectKey): TeqFw_Di_Api_ObjectKey>}\n */\n this.getHandlers = () => _handlers;\n\n /**\n * @param {TeqFw_Di_Api_ObjectKey} objectKey\n * @return {TeqFw_Di_Api_ObjectKey}\n */\n this.process = function (objectKey) {\n let res = objectKey;\n for (const one of _handlers)\n res = one(res, objectKey);\n return res;\n };\n }\n};\n\n//# sourceURL=webpack://@teqfw/di/./src/PreProcessor.js?");
106
+
107
+ /***/ }),
108
+
109
+ /***/ "./src/PreProcessor/Replace.js":
110
+ /*!*************************************!*\
111
+ !*** ./src/PreProcessor/Replace.js ***!
112
+ \*************************************/
113
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
114
+
115
+ "use strict";
116
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* export default binding */ __WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/**\n * Pre-processor handler to replace one object key with another.\n * @namespace TeqFw_Di_PreProcessor_Replace\n */\n\n/**\n * Factory function to create pre-processor handler.\n * @return {function(*): *}\n */\n/* harmony default export */ function __WEBPACK_DEFAULT_EXPORT__() {\n // VARS\n /**\n * Storage for ES modules replacements (interface => implementation).\n * Sample: {['Vnd_Plug_Interface']:'Vnd_Plug_Impl', ...}\n * @type {Object<string, string>}\n */\n const replacements = {};\n\n // FUNCS\n /**\n * @param {TeqFw_Di_Api_ObjectKey} objectKey\n * @param {TeqFw_Di_Api_ObjectKey} originalKey\n * @return {TeqFw_Di_Api_ObjectKey}\n */\n function TeqFw_Di_PreProcessor_Replace(objectKey, originalKey) {\n let module = objectKey.moduleName;\n while (replacements[module]) module = replacements[module];\n if (module !== objectKey.moduleName) {\n const res = Object.assign({}, objectKey);\n res.moduleName = module;\n return res;\n } else\n return objectKey;\n }\n\n /**\n * Add replacement for ES6 modules.\n *\n * @param {string} orig ('Vnd_Plug_Interface')\n * @param {string} alter ('Vnd_Plug_Impl')\n */\n TeqFw_Di_PreProcessor_Replace.add = function (orig, alter) {\n replacements[orig] = alter;\n };\n\n // MAIN\n return TeqFw_Di_PreProcessor_Replace;\n}\n\n//# sourceURL=webpack://@teqfw/di/./src/PreProcessor/Replace.js?");
117
+
118
+ /***/ }),
119
+
120
+ /***/ "./src/Resolver.js":
121
+ /*!*************************!*\
122
+ !*** ./src/Resolver.js ***!
123
+ \*************************/
124
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
125
+
126
+ "use strict";
127
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ TeqFw_Di_Resolver)\n/* harmony export */ });\n/* harmony import */ var _Defs_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Defs.js */ \"./src/Defs.js\");\n/**\n * The Resolver should convert ES6 module name into the path to the sources (file path or URL).\n *\n * This is a base resolver that considers that:\n * - module name is Zend1-compatible ('Vendor_Package_Module')\n * - every namespace is bound to some real path ('Vendor_Package_' => '.../node_modules/@vendor/package/src/...)\n * - every package has sources with the same extensions (*.js, *.mjs, *.es6, ...)\n * - namespaces can be nested (App_Web_ => ./@app/web/..., App_Web_Api_ => ./@app/web_api/...)\n */\n\n\n// VARS\nconst KEY_EXT = 'ext';\nconst KEY_NS = 'ns';\nconst KEY_PATH = 'root';\n/**\n * Namespace parts separator.\n *\n * @type {string}\n */\nconst NSS = '_';\n\n// MAIN\nclass TeqFw_Di_Resolver {\n\n constructor() {\n // VARS\n const _regNs = {};\n let _namespaces = [];\n let _ps = '/'; // web & unix path separator\n\n // INSTANCE METHODS\n\n this.addNamespaceRoot = function (ns, path, ext) {\n _regNs[ns] = {\n [KEY_EXT]: ext ?? _Defs_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].EXT,\n [KEY_NS]: ns,\n [KEY_PATH]: path,\n };\n _namespaces = Object.keys(_regNs).sort((a, b) => b.localeCompare(a));\n };\n\n /**\n * Convert the module name to the path of the source files .\n * @param {string} moduleName 'Vendor_Package_Module'\n * @return {string} '/home/user/app/node_modules/@vendor/package/src/Module.js'\n */\n this.resolve = function (moduleName) {\n let root, ext, ns;\n for (ns of _namespaces) {\n if (moduleName.startsWith(ns)) {\n root = _regNs[ns][KEY_PATH];\n ext = _regNs[ns][KEY_EXT];\n break;\n }\n }\n if (root && ext) {\n let tail = moduleName.replace(ns, '');\n if (tail.indexOf(NSS) === 0) tail = tail.replace(NSS, '');\n const file = tail.replaceAll(NSS, _ps);\n return `${root}${_ps}${file}.${ext}`;\n } else return moduleName;\n };\n }\n};\n\n//# sourceURL=webpack://@teqfw/di/./src/Resolver.js?");
128
+
129
+ /***/ }),
130
+
131
+ /***/ "./src/SpecAnalyser.js":
132
+ /*!*****************************!*\
133
+ !*** ./src/SpecAnalyser.js ***!
134
+ \*****************************/
135
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
136
+
137
+ "use strict";
138
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* export default binding */ __WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var _Defs_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Defs.js */ \"./src/Defs.js\");\n/**\n * This function analyzes specification of dependencies extracted from the text definition of the function itself.\n */\n\n\n// VARS\nconst FUNC = /function\\s*\\w*\\s*\\(\\s*\\{([^\\}]*)\\}/s;\nconst CLASS = /constructor\\s*\\(\\s*\\{([^\\}]*)\\}/s;\n\n// FUNCS\n\n/**\n * Internal function to analyze extracted parameters.\n *\n * @param {string} params\n * @return {string[]}\n * @private\n */\nfunction _analyze(params) {\n const res = [];\n // create wrapper for arguments and collect dependencies using Proxy\n try {\n const fn = new Function(`{${params}}`, 'return');\n const spec = new Proxy({}, {\n get: (target, prop) => res.push(prop),\n });\n // run wrapper and return dependencies\n fn(spec);\n } catch (e) {\n const msg = `Cannot analyze the deps specification:${params}\\n`\n + `\\nPlease, be sure that spec does not contain extra ')' in a comments.`\n + `\\n\\nError: ${e}`;\n throw new Error(msg);\n }\n return res;\n}\n\n/**\n * @param {Function|Object} exp\n * @return {string[]}\n */\nfunction _analyzeClass(exp) {\n const res = [];\n // extract arguments from constructor\n const def = exp.toString();\n const parts = CLASS.exec(def);\n if (parts) {\n res.push(..._analyze(parts[1]));\n } // else: constructor does not have arguments\n return res;\n}\n\n/**\n * @param {Function|Object} exp\n * @return {string[]}\n */\nfunction _analyzeFunc(exp) {\n const res = [];\n // extract arguments from factory function\n const def = exp.toString();\n const parts = FUNC.exec(def);\n if (parts) {\n res.push(..._analyze(parts[1]));\n } // else: constructor does not have arguments\n return res;\n}\n\n// MAIN\n/**\n * @param {Function|Object} exp\n * @return {string[]}\n */\n/* harmony default export */ function __WEBPACK_DEFAULT_EXPORT__(exp) {\n if (typeof exp === 'function') {\n if (_Defs_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isClass(exp)) {\n return _analyzeClass(exp);\n } else {\n return _analyzeFunc(exp);\n }\n } else\n return [];\n}\n\n//# sourceURL=webpack://@teqfw/di/./src/SpecAnalyser.js?");
139
+
140
+ /***/ })
141
+
142
+ /******/ });
143
+ /************************************************************************/
144
+ /******/ // The module cache
145
+ /******/ var __webpack_module_cache__ = {};
146
+ /******/
147
+ /******/ // The require function
148
+ /******/ function __webpack_require__(moduleId) {
149
+ /******/ // Check if module is in cache
150
+ /******/ var cachedModule = __webpack_module_cache__[moduleId];
151
+ /******/ if (cachedModule !== undefined) {
152
+ /******/ return cachedModule.exports;
153
+ /******/ }
154
+ /******/ // Create a new module (and put it into the cache)
155
+ /******/ var module = __webpack_module_cache__[moduleId] = {
156
+ /******/ // no module.id needed
157
+ /******/ // no module.loaded needed
158
+ /******/ exports: {}
159
+ /******/ };
160
+ /******/
161
+ /******/ // Execute the module function
162
+ /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
163
+ /******/
164
+ /******/ // Return the exports of the module
165
+ /******/ return module.exports;
166
+ /******/ }
167
+ /******/
168
+ /************************************************************************/
169
+ /******/ /* webpack/runtime/define property getters */
170
+ /******/ (() => {
171
+ /******/ // define getter functions for harmony exports
172
+ /******/ __webpack_require__.d = (exports, definition) => {
173
+ /******/ for(var key in definition) {
174
+ /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
175
+ /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
176
+ /******/ }
177
+ /******/ }
178
+ /******/ };
179
+ /******/ })();
180
+ /******/
181
+ /******/ /* webpack/runtime/hasOwnProperty shorthand */
182
+ /******/ (() => {
183
+ /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
184
+ /******/ })();
185
+ /******/
186
+ /******/ /* webpack/runtime/make namespace object */
187
+ /******/ (() => {
188
+ /******/ // define __esModule on exports
189
+ /******/ __webpack_require__.r = (exports) => {
190
+ /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
191
+ /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
192
+ /******/ }
193
+ /******/ Object.defineProperty(exports, '__esModule', { value: true });
194
+ /******/ };
195
+ /******/ })();
196
+ /******/
197
+ /************************************************************************/
198
+ /******/
199
+ /******/ // startup
200
+ /******/ // Load entry module and return exports
201
+ /******/ // This entry module can't be inlined because the eval devtool is used.
202
+ /******/ var __webpack_exports__ = __webpack_require__("./index.cjs");
203
+ /******/
204
+ /******/ })()
205
+ ;
package/dist/di.esm.js ADDED
@@ -0,0 +1,206 @@
1
+ /*
2
+ * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
3
+ * This devtool is neither made for production nor for readable output files.
4
+ * It uses "eval()" calls to create a separate source file in the browser devtools.
5
+ * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
6
+ * or disable the default devtool with "devtool: false".
7
+ * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
8
+ */
9
+ /******/ (() => { // webpackBootstrap
10
+ /******/ var __webpack_modules__ = ({
11
+
12
+ /***/ "./src lazy recursive":
13
+ /*!*******************************************!*\
14
+ !*** ./src/ lazy strict namespace object ***!
15
+ \*******************************************/
16
+ /***/ ((module) => {
17
+
18
+ eval("function webpackEmptyAsyncContext(req) {\n\t// Here Promise.resolve().then() is used instead of new Promise() to prevent\n\t// uncaught exception popping up in devtools\n\treturn Promise.resolve().then(() => {\n\t\tvar e = new Error(\"Cannot find module '\" + req + \"'\");\n\t\te.code = 'MODULE_NOT_FOUND';\n\t\tthrow e;\n\t});\n}\nwebpackEmptyAsyncContext.keys = () => ([]);\nwebpackEmptyAsyncContext.resolve = webpackEmptyAsyncContext;\nwebpackEmptyAsyncContext.id = \"./src lazy recursive\";\nmodule.exports = webpackEmptyAsyncContext;\n\n//# sourceURL=webpack://@teqfw/di/./src/_lazy_strict_namespace_object?");
19
+
20
+ /***/ }),
21
+
22
+ /***/ "./index.mjs":
23
+ /*!*******************!*\
24
+ !*** ./index.mjs ***!
25
+ \*******************/
26
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
27
+
28
+ "use strict";
29
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _src_Container_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./src/Container.js */ \"./src/Container.js\");\n/**\n * Entry point to build web bundle (ES6 modules).\n */\n\n\nwindow.TeqFwDi = _src_Container_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"];\n\n\n//# sourceURL=webpack://@teqfw/di/./index.mjs?");
30
+
31
+ /***/ }),
32
+
33
+ /***/ "./src/Api/ObjectKey.js":
34
+ /*!******************************!*\
35
+ !*** ./src/Api/ObjectKey.js ***!
36
+ \******************************/
37
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
38
+
39
+ "use strict";
40
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ TeqFw_Di_Api_ObjectKey)\n/* harmony export */ });\n/**\n * This is a DTO that represents the structure of an ID for a runtime dependency.\n */\nclass TeqFw_Di_Api_ObjectKey {\n /**\n * The name of an export of the module.\n * @type {string}\n */\n exportName;\n /**\n * Composition type (see Defs.COMPOSE_): use the export as Factory (F) or return as-is (A).\n * @type {string}\n */\n composition;\n /**\n * Lifestyle type (see Defs.LIFE_): singleton (S) or instance (I).\n * @type {string}\n */\n life;\n /**\n * The code for ES6 module that can be converted to the path to this es6 module.\n * @type {string}\n */\n moduleName;\n /**\n * Object key value.\n * @type {string}\n */\n value;\n /**\n * List of wrappers to decorate the result.\n * @type {string[]}\n */\n wrappers = [];\n}\n\n//# sourceURL=webpack://@teqfw/di/./src/Api/ObjectKey.js?");
41
+
42
+ /***/ }),
43
+
44
+ /***/ "./src/Composer.js":
45
+ /*!*************************!*\
46
+ !*** ./src/Composer.js ***!
47
+ \*************************/
48
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
49
+
50
+ "use strict";
51
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ TeqFw_Di_Composer)\n/* harmony export */ });\n/* harmony import */ var _Defs_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Defs.js */ \"./src/Defs.js\");\n/* harmony import */ var _SpecAnalyser_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./SpecAnalyser.js */ \"./src/SpecAnalyser.js\");\n/**\n *\n */\n\n\n\n// FUNCS\n\n// MAIN\nclass TeqFw_Di_Composer {\n\n constructor() {\n // VARS\n let _debug = false;\n\n // FUNCS\n function log(msg) {\n if (_debug) console.log(msg);\n }\n\n // INSTANCE METHODS\n\n /**\n *\n * @param {TeqFw_Di_Api_ObjectKey} key\n * @param {Object} module\n * @param {string[]} stack array of the parent objects to prevent dependency loop\n * @param {TeqFw_Di_Container} container\n * @return {Promise<*>}\n */\n this.create = async function (key, module, stack, container) {\n if (stack.includes(key.value))\n throw new Error(`Circular dependency for '${key.value}'. Parents are: ${JSON.stringify(stack)}`);\n if (key.exportName) {\n // use export from the es6-module\n const stackNew = [...stack, key.value];\n const {[key.exportName]: exp} = module;\n if (key.composition === _Defs_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].COMPOSE_FACTORY) {\n if (typeof exp === 'function') {\n // create deps for factory function\n const deps = (0,_SpecAnalyser_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(exp);\n if (deps.length) log(`Deps for object '${key.value}' are: ${JSON.stringify(deps)}`);\n const spec = {};\n for (const dep of deps)\n spec[dep] = await container.get(dep, stackNew);\n // create a new object with the factory function\n const res = (_Defs_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isClass(exp)) ? new exp(spec) : exp(spec);\n if (res instanceof Promise)\n return await res;\n else\n return res;\n } else\n // just clone the export\n return Object.assign({}, exp);\n } else\n return exp;\n } else {\n return module;\n }\n };\n\n this.setDebug = function (data) {\n _debug = data;\n };\n\n // MAIN\n }\n};\n\n//# sourceURL=webpack://@teqfw/di/./src/Composer.js?");
52
+
53
+ /***/ }),
54
+
55
+ /***/ "./src/Container.js":
56
+ /*!**************************!*\
57
+ !*** ./src/Container.js ***!
58
+ \**************************/
59
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
60
+
61
+ "use strict";
62
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ TeqFw_Di_Container)\n/* harmony export */ });\n/* harmony import */ var _Composer_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Composer.js */ \"./src/Composer.js\");\n/* harmony import */ var _Defs_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Defs.js */ \"./src/Defs.js\");\n/* harmony import */ var _Parser_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Parser.js */ \"./src/Parser.js\");\n/* harmony import */ var _PreProcessor_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./PreProcessor.js */ \"./src/PreProcessor.js\");\n/* harmony import */ var _PreProcessor_Replace_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./PreProcessor/Replace.js */ \"./src/PreProcessor/Replace.js\");\n/* harmony import */ var _Resolver_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Resolver.js */ \"./src/Resolver.js\");\n/**\n * The Object Container (composition root).\n */\n\n\n\n\n\n\n\n// VARS\n\n// FUNCS\n/**\n * ID to store singletons in the internal registry.\n * @param {TeqFw_Di_Api_ObjectKey} key\n * @return {string}\n */\nfunction getSingletonId(key) {\n return `${key.moduleName}#${key.exportName}`;\n}\n\n// MAIN\nclass TeqFw_Di_Container {\n\n constructor() {\n // VARS\n let _composer = new _Composer_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"]();\n let _debug = false;\n let _parser = new _Parser_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"]();\n let _preProcessor = new _PreProcessor_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"]();\n _preProcessor.addHandler((0,_PreProcessor_Replace_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"])()); // create new instance of the replacement handler\n\n /**\n * Registry for loaded es6 modules.\n * @type {Object<string, Module>}\n */\n const _regModules = {};\n /**\n * Registry to store singletons.\n * @type {Object<string, *>}\n */\n const _regSingles = {};\n let _resolver = new _Resolver_js__WEBPACK_IMPORTED_MODULE_5__[\"default\"]();\n\n // FUNCS\n function error() {\n console.error(...arguments);\n }\n\n function log() {\n if (_debug) console.log(...arguments);\n }\n\n\n // INSTANCE METHODS\n\n this.get = async function (objectKey, stack = []) {\n log(`Object '${objectKey}' is requested.`);\n // return container itself if requested\n if (\n (objectKey === _Defs_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].KEY_CONTAINER) ||\n (objectKey === _Defs_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].KEY_CONTAINER_NS)\n ) {\n log(`Container itself is returned.`);\n return _regSingles[_Defs_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].KEY_CONTAINER];\n }\n // parse the `objectKey` and get the structured DTO\n const parsed = _parser.parse(objectKey);\n // modify original key according to some rules (replacements, etc.)\n const key = _preProcessor.process(parsed);\n // return existing singleton\n if (key.life === _Defs_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].LIFE_SINGLETON) {\n const singleId = getSingletonId(key);\n if (_regSingles[singleId]) {\n log(`Existing singleton '${singleId}' is returned.`);\n return _regSingles[singleId];\n }\n }\n // load es6 module if not loaded before\n if (!_regModules[key.moduleName]) {\n log(`ES6 module '${key.moduleName}' is not loaded yet`);\n // convert module name to the path to es6-module file with a sources\n const path = _resolver.resolve(key.moduleName);\n try {\n _regModules[key.moduleName] = await __webpack_require__(\"./src lazy recursive\")(path);\n log(`ES6 module '${key.moduleName}' is loaded from '${path}'.`);\n } catch (e) {\n console.error(\n e?.message,\n `Object key: \"${objectKey}\".`,\n `Path: \"${path}\".`,\n `Stack: ${JSON.stringify(stack)}`\n );\n throw e;\n }\n\n }\n // create object using the composer\n let res = await _composer.create(key, _regModules[key.moduleName], stack, this);\n log(`Object '${objectKey}' is created.`);\n\n // TODO: refactor this code to use wrappers w/o hardcode\n if (key.wrappers.includes(_Defs_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].WRAP_PROXY)) {\n const me = this;\n res = new Proxy({dep: undefined, objectKey}, {\n get: async function (base, name) {\n if (name === 'create') base.dep = await me.get(base.objectKey);\n return base.dep;\n }\n });\n }\n\n if (key.life === _Defs_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].LIFE_SINGLETON) {\n const singleId = getSingletonId(key);\n _regSingles[singleId] = res;\n log(`Object '${objectKey}' is saved as singleton.`);\n }\n return res;\n };\n\n this.getParser = () => _parser;\n\n this.getPreProcessor = () => _preProcessor\n ;\n this.getResolver = () => _resolver;\n\n this.setDebug = function (data) {\n _debug = data;\n _composer.setDebug(data);\n };\n\n this.setParser = (data) => _parser = data;\n\n this.setPreProcessor = (data) => _preProcessor = data;\n\n this.setResolver = (data) => _resolver = data;\n\n // MAIN\n _regSingles[_Defs_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].KEY_CONTAINER] = this;\n }\n};\n\n//# sourceURL=webpack://@teqfw/di/./src/Container.js?");
63
+
64
+ /***/ }),
65
+
66
+ /***/ "./src/Defs.js":
67
+ /*!*********************!*\
68
+ !*** ./src/Defs.js ***!
69
+ \*********************/
70
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
71
+
72
+ "use strict";
73
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/**\n * Hardcoded constants for the package.\n */\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({\n COMPOSE_AS_IS: 'A',\n COMPOSE_FACTORY: 'F',\n EXT: 'js',\n KEY_CONTAINER: 'container',\n KEY_CONTAINER_NS: 'TeqFw_Di_Container$',\n LIFE_INSTANCE: 'I',\n LIFE_SINGLETON: 'S',\n WRAP_PROXY: 'proxy',\n\n /**\n * Return 'true' if function is a class definition.\n * See: https://stackoverflow.com/a/29094018/4073821\n *\n * @param {function} fn\n * @return {boolean}\n */\n isClass(fn) {\n const proto = Object.getOwnPropertyDescriptor(fn, 'prototype');\n return proto && !proto.writable;\n },\n});\n\n//# sourceURL=webpack://@teqfw/di/./src/Defs.js?");
74
+
75
+ /***/ }),
76
+
77
+ /***/ "./src/Parser.js":
78
+ /*!***********************!*\
79
+ !*** ./src/Parser.js ***!
80
+ \***********************/
81
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
82
+
83
+ "use strict";
84
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ TeqFw_Di_Parser)\n/* harmony export */ });\n/* harmony import */ var _Parser_Def_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Parser/Def.js */ \"./src/Parser/Def.js\");\n/**\n * The root parser for `objectKeys` contains all other parsers.\n * It calls the other parser one by one to parse the object key as a structure.\n * Every npm package can have its own format for an `objectKey`.\n */\n\n\n// VARS\nconst KEY_PARSER = 'parser';\nconst KEY_VALIDATOR = 'validator';\n\n// MAIN\nclass TeqFw_Di_Parser {\n\n constructor() {\n // VARS\n /**\n * Default parsing function.\n * @type {(function(string): TeqFw_Di_Api_ObjectKey)}\n */\n let _defaultParser = _Parser_Def_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"];\n /**\n * The array of the pairs {validator, parser} to parse objectKeys.\n * @type {Object<validator:function, parser:function>[]}\n */\n const _parsers = [];\n\n // INSTANCE METHODS\n\n /**\n *\n * @param {function(string):boolean} validator\n * @param {function(string):TeqFw_Di_Api_ObjectKey} parser\n */\n this.addParser = function (validator, parser) {\n _parsers.push({[KEY_VALIDATOR]: validator, [KEY_PARSER]: parser});\n };\n\n /**\n * @param {string} objectKey\n * @return {TeqFw_Di_Api_ObjectKey}\n */\n this.parse = function (objectKey) {\n let res;\n for (const one of _parsers) {\n if (one[KEY_VALIDATOR](objectKey)) {\n res = one[KEY_PARSER](objectKey);\n break;\n }\n }\n if (!res)\n res = _defaultParser(objectKey);\n return res;\n };\n\n /**\n * @param {function(string):TeqFw_Di_Api_ObjectKey} parser\n */\n this.setDefaultParser = function (parser) {\n _defaultParser = parser;\n };\n\n // MAIN\n }\n};\n\n//# sourceURL=webpack://@teqfw/di/./src/Parser.js?");
85
+
86
+ /***/ }),
87
+
88
+ /***/ "./src/Parser/Def.js":
89
+ /*!***************************!*\
90
+ !*** ./src/Parser/Def.js ***!
91
+ \***************************/
92
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
93
+
94
+ "use strict";
95
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ TeqFw_Di_Parser_Def)\n/* harmony export */ });\n/* harmony import */ var _Api_ObjectKey_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Api/ObjectKey.js */ \"./src/Api/ObjectKey.js\");\n/* harmony import */ var _Defs_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Defs.js */ \"./src/Defs.js\");\n/**\n * Default parser for object keys in format:\n * - Vnd_Pkg_Prj_Mod$FA\n */\n\n\n\n// VARS\n/** @type {RegExp} expression for default object key (Ns_Module[.|#]export$[F|A][S|I]) */\nconst REGEXP = /^((([A-Z])[A-Za-z0-9_]*)((#|\\.)?([A-Za-z0-9]*)((\\$)([F|A])?([S|I])?)?)?)$/;\n\n\n// MAIN\n/**\n * @param {string} objectKey\n * @return {TeqFw_Di_Api_ObjectKey}\n */\nfunction TeqFw_Di_Parser_Def(objectKey) {\n const res = new _Api_ObjectKey_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"]();\n res.value = objectKey;\n const parts = REGEXP.exec(objectKey);\n if (parts) {\n res.moduleName = parts[2];\n if (parts[5] === '.') {\n // App_Service.export...\n if (parts[8] === '$') {\n // App_Service.export$...\n res.composition = _Defs_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].COMPOSE_FACTORY;\n res.exportName = parts[6];\n res.life = (parts[10] === _Defs_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].LIFE_INSTANCE)\n ? _Defs_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].LIFE_INSTANCE : _Defs_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].LIFE_SINGLETON;\n } else {\n res.composition = ((parts[8] === undefined) || (parts[8] === _Defs_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].COMPOSE_AS_IS))\n ? _Defs_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].COMPOSE_AS_IS : _Defs_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].COMPOSE_FACTORY;\n res.exportName = parts[6];\n res.life = ((parts[8] === undefined) || (parts[10] === _Defs_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].LIFE_SINGLETON))\n ? _Defs_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].LIFE_SINGLETON : _Defs_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].LIFE_INSTANCE;\n }\n\n\n } else if (parts[8] === '$') {\n // App_Logger$FS\n res.composition = ((parts[9] === undefined) || (parts[9] === _Defs_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].COMPOSE_FACTORY))\n ? _Defs_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].COMPOSE_FACTORY : _Defs_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].COMPOSE_AS_IS;\n res.exportName = 'default';\n if (parts[10]) {\n res.life = (parts[10] === _Defs_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].LIFE_SINGLETON) ? _Defs_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].LIFE_SINGLETON : _Defs_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].LIFE_INSTANCE;\n } else {\n res.life = (res.composition === _Defs_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].COMPOSE_FACTORY) ? _Defs_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].LIFE_SINGLETON : _Defs_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].LIFE_INSTANCE;\n }\n } else {\n // App_Service\n res.composition = _Defs_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].COMPOSE_AS_IS;\n res.exportName = 'default';\n res.life = _Defs_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].LIFE_SINGLETON;\n }\n }\n\n // we should always use singletons for as-is exports\n if ((res.composition === _Defs_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].COMPOSE_AS_IS) && (res.life === _Defs_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].LIFE_INSTANCE))\n throw new Error(`Export is not a function and should be used as a singleton only: '${res.value}'.`);\n return res;\n}\n\n//# sourceURL=webpack://@teqfw/di/./src/Parser/Def.js?");
96
+
97
+ /***/ }),
98
+
99
+ /***/ "./src/PreProcessor.js":
100
+ /*!*****************************!*\
101
+ !*** ./src/PreProcessor.js ***!
102
+ \*****************************/
103
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
104
+
105
+ "use strict";
106
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ TeqFw_Di_PreProcessor)\n/* harmony export */ });\n/**\n * The preprocessor handles object keys after the parsing but before creating any objects.\n * A replacement rules can be implemented here.\n * Every handler is a function with 2 arguments:\n * - objectKey: current key after processing with other handlers;\n * - originalKey: the key before any processing;\n */\nclass TeqFw_Di_PreProcessor {\n\n constructor() {\n // VARS\n /**\n * The array of handlers in the dependency order (from the basic (di) up to the app).\n * @type {Array<function(TeqFw_Di_Api_ObjectKey, TeqFw_Di_Api_ObjectKey):TeqFw_Di_Api_ObjectKey>}\n */\n const _handlers = [];\n\n // INSTANCE METHODS\n\n /**\n *\n * @param {function(TeqFw_Di_Api_ObjectKey, TeqFw_Di_Api_ObjectKey):TeqFw_Di_Api_ObjectKey} hndl\n */\n this.addHandler = function (hndl) {\n _handlers.push(hndl);\n };\n\n /**\n * Get all pre-processing handlers.\n * @return {Array<function(TeqFw_Di_Api_ObjectKey, TeqFw_Di_Api_ObjectKey): TeqFw_Di_Api_ObjectKey>}\n */\n this.getHandlers = () => _handlers;\n\n /**\n * @param {TeqFw_Di_Api_ObjectKey} objectKey\n * @return {TeqFw_Di_Api_ObjectKey}\n */\n this.process = function (objectKey) {\n let res = objectKey;\n for (const one of _handlers)\n res = one(res, objectKey);\n return res;\n };\n }\n};\n\n//# sourceURL=webpack://@teqfw/di/./src/PreProcessor.js?");
107
+
108
+ /***/ }),
109
+
110
+ /***/ "./src/PreProcessor/Replace.js":
111
+ /*!*************************************!*\
112
+ !*** ./src/PreProcessor/Replace.js ***!
113
+ \*************************************/
114
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
115
+
116
+ "use strict";
117
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* export default binding */ __WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/**\n * Pre-processor handler to replace one object key with another.\n * @namespace TeqFw_Di_PreProcessor_Replace\n */\n\n/**\n * Factory function to create pre-processor handler.\n * @return {function(*): *}\n */\n/* harmony default export */ function __WEBPACK_DEFAULT_EXPORT__() {\n // VARS\n /**\n * Storage for ES modules replacements (interface => implementation).\n * Sample: {['Vnd_Plug_Interface']:'Vnd_Plug_Impl', ...}\n * @type {Object<string, string>}\n */\n const replacements = {};\n\n // FUNCS\n /**\n * @param {TeqFw_Di_Api_ObjectKey} objectKey\n * @param {TeqFw_Di_Api_ObjectKey} originalKey\n * @return {TeqFw_Di_Api_ObjectKey}\n */\n function TeqFw_Di_PreProcessor_Replace(objectKey, originalKey) {\n let module = objectKey.moduleName;\n while (replacements[module]) module = replacements[module];\n if (module !== objectKey.moduleName) {\n const res = Object.assign({}, objectKey);\n res.moduleName = module;\n return res;\n } else\n return objectKey;\n }\n\n /**\n * Add replacement for ES6 modules.\n *\n * @param {string} orig ('Vnd_Plug_Interface')\n * @param {string} alter ('Vnd_Plug_Impl')\n */\n TeqFw_Di_PreProcessor_Replace.add = function (orig, alter) {\n replacements[orig] = alter;\n };\n\n // MAIN\n return TeqFw_Di_PreProcessor_Replace;\n}\n\n//# sourceURL=webpack://@teqfw/di/./src/PreProcessor/Replace.js?");
118
+
119
+ /***/ }),
120
+
121
+ /***/ "./src/Resolver.js":
122
+ /*!*************************!*\
123
+ !*** ./src/Resolver.js ***!
124
+ \*************************/
125
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
126
+
127
+ "use strict";
128
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ TeqFw_Di_Resolver)\n/* harmony export */ });\n/* harmony import */ var _Defs_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Defs.js */ \"./src/Defs.js\");\n/**\n * The Resolver should convert ES6 module name into the path to the sources (file path or URL).\n *\n * This is a base resolver that considers that:\n * - module name is Zend1-compatible ('Vendor_Package_Module')\n * - every namespace is bound to some real path ('Vendor_Package_' => '.../node_modules/@vendor/package/src/...)\n * - every package has sources with the same extensions (*.js, *.mjs, *.es6, ...)\n * - namespaces can be nested (App_Web_ => ./@app/web/..., App_Web_Api_ => ./@app/web_api/...)\n */\n\n\n// VARS\nconst KEY_EXT = 'ext';\nconst KEY_NS = 'ns';\nconst KEY_PATH = 'root';\n/**\n * Namespace parts separator.\n *\n * @type {string}\n */\nconst NSS = '_';\n\n// MAIN\nclass TeqFw_Di_Resolver {\n\n constructor() {\n // VARS\n const _regNs = {};\n let _namespaces = [];\n let _ps = '/'; // web & unix path separator\n\n // INSTANCE METHODS\n\n this.addNamespaceRoot = function (ns, path, ext) {\n _regNs[ns] = {\n [KEY_EXT]: ext ?? _Defs_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].EXT,\n [KEY_NS]: ns,\n [KEY_PATH]: path,\n };\n _namespaces = Object.keys(_regNs).sort((a, b) => b.localeCompare(a));\n };\n\n /**\n * Convert the module name to the path of the source files .\n * @param {string} moduleName 'Vendor_Package_Module'\n * @return {string} '/home/user/app/node_modules/@vendor/package/src/Module.js'\n */\n this.resolve = function (moduleName) {\n let root, ext, ns;\n for (ns of _namespaces) {\n if (moduleName.startsWith(ns)) {\n root = _regNs[ns][KEY_PATH];\n ext = _regNs[ns][KEY_EXT];\n break;\n }\n }\n if (root && ext) {\n let tail = moduleName.replace(ns, '');\n if (tail.indexOf(NSS) === 0) tail = tail.replace(NSS, '');\n const file = tail.replaceAll(NSS, _ps);\n return `${root}${_ps}${file}.${ext}`;\n } else return moduleName;\n };\n }\n};\n\n//# sourceURL=webpack://@teqfw/di/./src/Resolver.js?");
129
+
130
+ /***/ }),
131
+
132
+ /***/ "./src/SpecAnalyser.js":
133
+ /*!*****************************!*\
134
+ !*** ./src/SpecAnalyser.js ***!
135
+ \*****************************/
136
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
137
+
138
+ "use strict";
139
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* export default binding */ __WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var _Defs_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Defs.js */ \"./src/Defs.js\");\n/**\n * This function analyzes specification of dependencies extracted from the text definition of the function itself.\n */\n\n\n// VARS\nconst FUNC = /function\\s*\\w*\\s*\\(\\s*\\{([^\\}]*)\\}/s;\nconst CLASS = /constructor\\s*\\(\\s*\\{([^\\}]*)\\}/s;\n\n// FUNCS\n\n/**\n * Internal function to analyze extracted parameters.\n *\n * @param {string} params\n * @return {string[]}\n * @private\n */\nfunction _analyze(params) {\n const res = [];\n // create wrapper for arguments and collect dependencies using Proxy\n try {\n const fn = new Function(`{${params}}`, 'return');\n const spec = new Proxy({}, {\n get: (target, prop) => res.push(prop),\n });\n // run wrapper and return dependencies\n fn(spec);\n } catch (e) {\n const msg = `Cannot analyze the deps specification:${params}\\n`\n + `\\nPlease, be sure that spec does not contain extra ')' in a comments.`\n + `\\n\\nError: ${e}`;\n throw new Error(msg);\n }\n return res;\n}\n\n/**\n * @param {Function|Object} exp\n * @return {string[]}\n */\nfunction _analyzeClass(exp) {\n const res = [];\n // extract arguments from constructor\n const def = exp.toString();\n const parts = CLASS.exec(def);\n if (parts) {\n res.push(..._analyze(parts[1]));\n } // else: constructor does not have arguments\n return res;\n}\n\n/**\n * @param {Function|Object} exp\n * @return {string[]}\n */\nfunction _analyzeFunc(exp) {\n const res = [];\n // extract arguments from factory function\n const def = exp.toString();\n const parts = FUNC.exec(def);\n if (parts) {\n res.push(..._analyze(parts[1]));\n } // else: constructor does not have arguments\n return res;\n}\n\n// MAIN\n/**\n * @param {Function|Object} exp\n * @return {string[]}\n */\n/* harmony default export */ function __WEBPACK_DEFAULT_EXPORT__(exp) {\n if (typeof exp === 'function') {\n if (_Defs_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isClass(exp)) {\n return _analyzeClass(exp);\n } else {\n return _analyzeFunc(exp);\n }\n } else\n return [];\n}\n\n//# sourceURL=webpack://@teqfw/di/./src/SpecAnalyser.js?");
140
+
141
+ /***/ })
142
+
143
+ /******/ });
144
+ /************************************************************************/
145
+ /******/ // The module cache
146
+ /******/ var __webpack_module_cache__ = {};
147
+ /******/
148
+ /******/ // The require function
149
+ /******/ function __webpack_require__(moduleId) {
150
+ /******/ // Check if module is in cache
151
+ /******/ var cachedModule = __webpack_module_cache__[moduleId];
152
+ /******/ if (cachedModule !== undefined) {
153
+ /******/ return cachedModule.exports;
154
+ /******/ }
155
+ /******/ // Create a new module (and put it into the cache)
156
+ /******/ var module = __webpack_module_cache__[moduleId] = {
157
+ /******/ // no module.id needed
158
+ /******/ // no module.loaded needed
159
+ /******/ exports: {}
160
+ /******/ };
161
+ /******/
162
+ /******/ // Execute the module function
163
+ /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
164
+ /******/
165
+ /******/ // Return the exports of the module
166
+ /******/ return module.exports;
167
+ /******/ }
168
+ /******/
169
+ /************************************************************************/
170
+ /******/ /* webpack/runtime/define property getters */
171
+ /******/ (() => {
172
+ /******/ // define getter functions for harmony exports
173
+ /******/ __webpack_require__.d = (exports, definition) => {
174
+ /******/ for(var key in definition) {
175
+ /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
176
+ /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
177
+ /******/ }
178
+ /******/ }
179
+ /******/ };
180
+ /******/ })();
181
+ /******/
182
+ /******/ /* webpack/runtime/hasOwnProperty shorthand */
183
+ /******/ (() => {
184
+ /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
185
+ /******/ })();
186
+ /******/
187
+ /******/ /* webpack/runtime/make namespace object */
188
+ /******/ (() => {
189
+ /******/ // define __esModule on exports
190
+ /******/ __webpack_require__.r = (exports) => {
191
+ /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
192
+ /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
193
+ /******/ }
194
+ /******/ Object.defineProperty(exports, '__esModule', { value: true });
195
+ /******/ };
196
+ /******/ })();
197
+ /******/
198
+ /************************************************************************/
199
+ /******/
200
+ /******/ // startup
201
+ /******/ // Load entry module and return exports
202
+ /******/ // This entry module can't be inlined because the eval devtool is used.
203
+ /******/ var __webpack_exports__ = __webpack_require__("./index.mjs");
204
+ /******/
205
+ /******/ })()
206
+ ;
package/index.cjs ADDED
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Entry point to build web bundle (Common JS).
3
+ */
4
+ const {default: Container} = require('./src/Container.js');
5
+ window.TeqFwDi = Container;
package/index.mjs ADDED
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Entry point to build web bundle (ES6 modules).
3
+ */
4
+ import Container from './src/Container.js';
5
+
6
+ window.TeqFwDi = Container;