@decaf-ts/injectable-decorators 1.3.0
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/LICENSE.md +19 -0
- package/README.md +160 -0
- package/dist/esm/injectable-decorators.bundle.min.esm.js +2 -0
- package/dist/esm/injectable-decorators.bundle.min.esm.js.LICENSE.txt +14 -0
- package/dist/injectable-decorators.bundle.min.js +2 -0
- package/dist/injectable-decorators.bundle.min.js.LICENSE.txt +14 -0
- package/lib/Injectables.cjs +1 -0
- package/lib/Injectables.d.ts +41 -0
- package/lib/constants.cjs +1 -0
- package/lib/constants.d.ts +15 -0
- package/lib/decorators.cjs +1 -0
- package/lib/decorators.d.ts +51 -0
- package/lib/esm/Injectables.d.ts +41 -0
- package/lib/esm/Injectables.js +1 -0
- package/lib/esm/constants.d.ts +15 -0
- package/lib/esm/constants.js +1 -0
- package/lib/esm/decorators.d.ts +51 -0
- package/lib/esm/decorators.js +1 -0
- package/lib/esm/index.d.ts +20 -0
- package/lib/esm/index.js +1 -0
- package/lib/esm/registry.d.ts +61 -0
- package/lib/esm/registry.js +1 -0
- package/lib/esm/utils.d.ts +18 -0
- package/lib/esm/utils.js +1 -0
- package/lib/index.cjs +1 -0
- package/lib/index.d.ts +20 -0
- package/lib/registry.cjs +1 -0
- package/lib/registry.d.ts +61 -0
- package/lib/utils.cjs +1 -0
- package/lib/utils.d.ts +18 -0
- package/package.json +96 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+

|
|
2
|
+
## Simple Injectables engine
|
|
3
|
+
|
|
4
|
+
Simple implementation of injectables
|
|
5
|
+
|
|
6
|
+

|
|
7
|
+

|
|
8
|
+

|
|
9
|
+
[](http://www.pdmfc.com)
|
|
10
|
+
[](https://github.com/decaf-ts/injectable-decorators/actions?query=workflow%3ACodeQL)
|
|
11
|
+
|
|
12
|
+

|
|
13
|
+

|
|
14
|
+

|
|
15
|
+

|
|
16
|
+
|
|
17
|
+

|
|
18
|
+

|
|
19
|
+

|
|
20
|
+

|
|
21
|
+
|
|
22
|
+
|
|
23
|
+

|
|
24
|
+

|
|
25
|
+

|
|
26
|
+
|
|
27
|
+

|
|
28
|
+

|
|
29
|
+
|
|
30
|
+
### Decorator based
|
|
31
|
+
|
|
32
|
+
Simple implementation of a Typescript decorator based injectable system.
|
|
33
|
+
## Considerations
|
|
34
|
+
|
|
35
|
+
#### Typescript Compilation options
|
|
36
|
+
|
|
37
|
+
Even though all code is exported in both CommonJS and ESM format, and the default is ES2022
|
|
38
|
+
in order to take advantage to all the latest Typescript and JS features,
|
|
39
|
+
when importing these libraries the following flag in `tsconfig.compilerOptions` is mandatory:
|
|
40
|
+
```json
|
|
41
|
+
{
|
|
42
|
+
"experimentalDecorators": true,
|
|
43
|
+
"emitDecoratorMetadata": true,
|
|
44
|
+
"useDefineForClassFields": false
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
### Related
|
|
48
|
+
|
|
49
|
+
[](https://github.com/decaf-ts/decorator-validation)
|
|
50
|
+
[](https://github.com/decaf-ts/db-decorators)
|
|
51
|
+
### Social
|
|
52
|
+
|
|
53
|
+
[](https://www.linkedin.com/in/decaf-ts/)
|
|
54
|
+
### Scripts
|
|
55
|
+
|
|
56
|
+
The following npm scripts are available for development:
|
|
57
|
+
|
|
58
|
+
- `preinstall` - will run only on the first install to trigger the dep update. will self delete;
|
|
59
|
+
- `do-install` - sets a `TOKEN` environment variable to the contents of `.token` and runs npm install (useful when you
|
|
60
|
+
have private dependencies);
|
|
61
|
+
- `flash-forward` - updates all dependencies. Take care, This may not be desirable is some cases;
|
|
62
|
+
- `reset` - updates all dependencies. Take care, This may not be desirable is some cases;
|
|
63
|
+
- `build` - builds the code (via gulp `gulpfile.js`) in development mode (generates `lib` and `dist` folder);
|
|
64
|
+
- `build:prod` - builds the code (via gulp `gulpfile.js`) in production mode (generates `lib` and `dist` folder);
|
|
65
|
+
- `test` - runs unit tests;
|
|
66
|
+
- `test:integration` - runs it tests;
|
|
67
|
+
- `test:all` - runs all tests;
|
|
68
|
+
- `lint` - runs es lint on the code folder;
|
|
69
|
+
- `lint-fix` - tries to auto-fix the code folder;
|
|
70
|
+
- `prepare-release` - defines the commands to run prior to a new tag (defaults to linting, building production code,
|
|
71
|
+
running tests and documentation generation);
|
|
72
|
+
- `release` - triggers a new tag being pushed to master (via `./bin/tag_release.sh`);
|
|
73
|
+
- `clean-publish` - cleans the package.json for publishing;
|
|
74
|
+
- `coverage` - runs all test, calculates coverage and generates badges for readme;
|
|
75
|
+
- `drawings` - compiles all DrawIO `*.drawio` files in the `workdocs/drawings` folder to png and moves them to
|
|
76
|
+
the `workdocs/resources` folder;
|
|
77
|
+
- `uml` - compiles all PlantUML `*.puml` files in the `workdocs/uml` folder to png and moves them to
|
|
78
|
+
the `workdocs/resources` folder;
|
|
79
|
+
- `docs` - compiles all the coverage, drawings, uml, jsdocs and md docs into a readable web page under `./docs`;
|
|
80
|
+
|
|
81
|
+
### Repository Structure
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
injectable-decorators
|
|
85
|
+
│
|
|
86
|
+
│ .gitignore <-- Defines files ignored to git
|
|
87
|
+
│ .npmignore <-- Defines files ignored by npm
|
|
88
|
+
│ .nmprc <-- Defines the Npm registry for this package
|
|
89
|
+
│ .eslintrc.cjs <-- linting for the project
|
|
90
|
+
│ .prettier.config.cjs <-- Code style for the project
|
|
91
|
+
│ .gitlab-ci.yml <-- Gillab CI/CD file
|
|
92
|
+
│ gulpfile.js <-- Gulp build scripts. used for building na other features (eg docs)
|
|
93
|
+
│ jest.config.ts <-- Tests Configuration file
|
|
94
|
+
│ mdCompile.json <-- md Documentation generation configuration file
|
|
95
|
+
│ jsdocs.json <-- jsdoc Documentation generation configuration file
|
|
96
|
+
│ Dockerfile <-- minimal example of a node service Dockerfile
|
|
97
|
+
│ LICENCE.md <-- Licence disclamer
|
|
98
|
+
│ package.json
|
|
99
|
+
│ package-lock.json
|
|
100
|
+
│ README.md <-- Readme File dynamically compiled from 'workdocs' via the 'docs' npm script
|
|
101
|
+
│ tsconfig.json <-- Typescript config file. Is overriden in 'gulpfile.js'
|
|
102
|
+
│
|
|
103
|
+
└───bin
|
|
104
|
+
│ │ tag_release.sh <-- Script to help with releases
|
|
105
|
+
│
|
|
106
|
+
└───docs
|
|
107
|
+
│ │ ... <-- Dinamically generated folder, containing the compiled documentation for this repository. generated via the 'docs' npm script
|
|
108
|
+
│
|
|
109
|
+
└───src
|
|
110
|
+
│ │ ... <-- Source code for this repository
|
|
111
|
+
│
|
|
112
|
+
└───tests
|
|
113
|
+
│ │───unit <-- Unit tests
|
|
114
|
+
│ └───integration <-- Integration tests
|
|
115
|
+
│
|
|
116
|
+
└───workdocs <-- Folder with all pre-compiled documentation
|
|
117
|
+
│ │───assets <-- Documentation asset folder
|
|
118
|
+
│ │───badges <-- Auto generated coverage badges folder
|
|
119
|
+
│ │───coverage <-- Auto generated coverage results
|
|
120
|
+
│ │───drawings <-- DrawIO folder. Drawings (*.drawio) here will be processed to generate documentation (requires docker)
|
|
121
|
+
│ │───uml <-- PlantUML folder. Diagrams (*.puml) here will be processed to generate documentation (requires docker)
|
|
122
|
+
│ │───tutorials <-- Tutorial folder
|
|
123
|
+
│ │ ... <-- Categorized *.md files that are merged to generate the final readme (via md compile)
|
|
124
|
+
│ │ Readme.md <-- Entry point to the README.md
|
|
125
|
+
│
|
|
126
|
+
└───dist
|
|
127
|
+
│ │ ... <-- Dinamically generated folder containing the bundles for distribution
|
|
128
|
+
│
|
|
129
|
+
└───lib
|
|
130
|
+
| ... <-- Dinamically generated folder containing the compiled code
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+

|
|
134
|
+

|
|
135
|
+

|
|
136
|
+

|
|
137
|
+
|
|
138
|
+
## Getting help
|
|
139
|
+
|
|
140
|
+
If you have bug reports, questions or suggestions please [create a new issue](https://github.com/decaf-ts/decorator-validation/issues/new/choose).
|
|
141
|
+
|
|
142
|
+
## Contributing
|
|
143
|
+
|
|
144
|
+
I am grateful for any contributions made to this project. Please read [this](./workdocs/98-Contributing.md) to get started.
|
|
145
|
+
|
|
146
|
+
## Supporting
|
|
147
|
+
|
|
148
|
+
The first and easiest way you can support it is by [Contributing](./workdocs/98-Contributing.md). Even just finding a typo in the documentation is important.
|
|
149
|
+
|
|
150
|
+
Financial support is always welcome and helps keep the both me and the project alive and healthy.
|
|
151
|
+
|
|
152
|
+
So if you can, if this project in any way. either by learning something or simply by helping you save precious time, please consider donating.
|
|
153
|
+
|
|
154
|
+
## License
|
|
155
|
+
|
|
156
|
+
This project is released under the [MIT License](LICENSE.md).
|
|
157
|
+
|
|
158
|
+
#### Disclaimer:
|
|
159
|
+
|
|
160
|
+
badges found [here](https://dev.to/envoy_/150-badges-for-github-pnk), [here](https://github.com/alexandresanlim/Badges4-README.md-Profile#-social-) and [here](https://github.com/Ileriayo/markdown-badges)
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see injectable-decorators.bundle.min.esm.js.LICENSE.txt */
|
|
2
|
+
var e={323:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Injectables=void 0;const n=r(426);class i{static{this.actingInjectablesRegistry=void 0}constructor(){}static get(e,...t){return i.getRegistry().get(e,...t)}static register(e,...t){return i.getRegistry().register(e,...t)}static build(e,...t){return i.getRegistry().build(e,...t)}static setRegistry(e){i.actingInjectablesRegistry=e}static getRegistry(){return i.actingInjectablesRegistry||(i.actingInjectablesRegistry=new n.InjectableRegistryImp),i.actingInjectablesRegistry}}t.Injectables=i},640:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.InjectablesKeys=void 0,t.InjectablesKeys={REFLECT:"inject.db.",INJECTABLE:"injectable",INJECT:"inject"}},503:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.inject=t.injectable=void 0;const n=r(640),i=r(323),o=r(552),a=e=>n.InjectablesKeys.REFLECT+e;t.injectable=(e=void 0,t=!1,...r)=>o=>{const u=e||o.name,c=function(...e){let c=i.Injectables.get(u,...e);if(!c&&(i.Injectables.register(o,u,!0,t),c=i.Injectables.get(u,...e),!c))return;const s=Object.assign({},{class:u},r||{});return Reflect.defineMetadata(a(n.InjectablesKeys.INJECTABLE),s,c.constructor),c};return c.prototype=o.prototype,Object.defineProperty(c,"name",{writable:!1,enumerable:!0,configurable:!1,value:o.prototype.constructor.name}),c},t.inject=(e,t)=>(r,u)=>{const c=new WeakMap,s=e||(0,o.getTypeFromDecorator)(r,u);if(!s)throw new Error("Could not get Type from decorator");Reflect.defineMetadata(a(n.InjectablesKeys.INJECT),{injectable:s},r,u),Object.defineProperty(r,u,{configurable:!0,get(){if(Object.getOwnPropertyDescriptor(r,u).configurable)return Object.defineProperty(this,u,{enumerable:!0,configurable:!1,get(){let e=c.get(this);if(!e){if(e=i.Injectables.get(s),!e)throw new Error(`Could not get Injectable ${s} to inject in ${r.constructor?r.constructor.name:r.name}'s ${u}`);if(t)try{e=t(e,r)}catch(e){console.error(e)}c.set(this,e)}return e}}),this[u]}})}},729:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),t.VERSION=void 0,i(r(640),t),i(r(503),t),i(r(426),t),t.VERSION="##VERSION##"},426:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.InjectableRegistryImp=void 0,t.InjectableRegistryImp=class{constructor(){this.cache={}}get(e,...t){try{const r=this.cache[e],n={name:e};return(r.isSingleton||r.instance)&&r.instance||this.build(n,...t)}catch(e){return}}register(e,t=void 0,r=!0,n=!1){const i=e,o=!i.name&&i.constructor;if("function"!=typeof i&&!o)throw new Error("Injectable registering failed. Missing Class name or constructor");const a=t||(o&&o.name&&"Function"!==o.name?o.name:i.name);this.cache[a]&&!n||(this.cache[a]={instance:o?e:void 0,constructor:o?void 0:e,singleton:r})}build(e,...t){const{constructor:r,singleton:n}=this.cache[e.name],i=new r(...t);return this.cache[e.name]={instance:i,constructor:r,singleton:n},i}}},552:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TypeKey=void 0,t.getTypeFromDecorator=function(e,r){const n=Reflect.getMetadata(t.TypeKey,e,r);return"Function"!==n.name?n.name:void 0},r(630),t.TypeKey="design:type"},630:(e,t,r)=>{var n;!function(e){!function(){var t="object"==typeof globalThis?globalThis:"object"==typeof r.g?r.g:"object"==typeof self?self:"object"==typeof this?this:function(){try{return Function("return this;")()}catch(e){}}()||function(){try{return(0,eval)("(function() { return this; })()")}catch(e){}}(),n=i(e);function i(e,t){return function(r,n){Object.defineProperty(e,r,{configurable:!0,writable:!0,value:n}),t&&t(r,n)}}void 0!==t.Reflect&&(n=i(t.Reflect,n)),function(e,t){var r=Object.prototype.hasOwnProperty,n="function"==typeof Symbol,i=n&&void 0!==Symbol.toPrimitive?Symbol.toPrimitive:"@@toPrimitive",o=n&&void 0!==Symbol.iterator?Symbol.iterator:"@@iterator",a="function"==typeof Object.create,u={__proto__:[]}instanceof Array,c=!a&&!u,s={create:a?function(){return W(Object.create(null))}:u?function(){return W({__proto__:null})}:function(){return W({})},has:c?function(e,t){return r.call(e,t)}:function(e,t){return t in e},get:c?function(e,t){return r.call(e,t)?e[t]:void 0}:function(e,t){return e[t]}},f=Object.getPrototypeOf(Function),l="function"==typeof Map&&"function"==typeof Map.prototype.entries?Map:function(){var e={},t=[],r=function(){function e(e,t,r){this._index=0,this._keys=e,this._values=t,this._selector=r}return e.prototype["@@iterator"]=function(){return this},e.prototype[o]=function(){return this},e.prototype.next=function(){var e=this._index;if(e>=0&&e<this._keys.length){var r=this._selector(this._keys[e],this._values[e]);return e+1>=this._keys.length?(this._index=-1,this._keys=t,this._values=t):this._index++,{value:r,done:!1}}return{value:void 0,done:!0}},e.prototype.throw=function(e){throw this._index>=0&&(this._index=-1,this._keys=t,this._values=t),e},e.prototype.return=function(e){return this._index>=0&&(this._index=-1,this._keys=t,this._values=t),{value:e,done:!0}},e}();return function(){function t(){this._keys=[],this._values=[],this._cacheKey=e,this._cacheIndex=-2}return Object.defineProperty(t.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),t.prototype.has=function(e){return this._find(e,!1)>=0},t.prototype.get=function(e){var t=this._find(e,!1);return t>=0?this._values[t]:void 0},t.prototype.set=function(e,t){var r=this._find(e,!0);return this._values[r]=t,this},t.prototype.delete=function(t){var r=this._find(t,!1);if(r>=0){for(var n=this._keys.length,i=r+1;i<n;i++)this._keys[i-1]=this._keys[i],this._values[i-1]=this._values[i];return this._keys.length--,this._values.length--,F(t,this._cacheKey)&&(this._cacheKey=e,this._cacheIndex=-2),!0}return!1},t.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=e,this._cacheIndex=-2},t.prototype.keys=function(){return new r(this._keys,this._values,n)},t.prototype.values=function(){return new r(this._keys,this._values,i)},t.prototype.entries=function(){return new r(this._keys,this._values,a)},t.prototype["@@iterator"]=function(){return this.entries()},t.prototype[o]=function(){return this.entries()},t.prototype._find=function(e,t){if(!F(this._cacheKey,e)){this._cacheIndex=-1;for(var r=0;r<this._keys.length;r++)if(F(this._keys[r],e)){this._cacheIndex=r;break}}return this._cacheIndex<0&&t&&(this._cacheIndex=this._keys.length,this._keys.push(e),this._values.push(void 0)),this._cacheIndex},t}();function n(e,t){return e}function i(e,t){return t}function a(e,t){return[e,t]}}(),y="function"==typeof Set&&"function"==typeof Set.prototype.entries?Set:function(){function e(){this._map=new l}return Object.defineProperty(e.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),e.prototype.has=function(e){return this._map.has(e)},e.prototype.add=function(e){return this._map.set(e,e),this},e.prototype.delete=function(e){return this._map.delete(e)},e.prototype.clear=function(){this._map.clear()},e.prototype.keys=function(){return this._map.keys()},e.prototype.values=function(){return this._map.keys()},e.prototype.entries=function(){return this._map.entries()},e.prototype["@@iterator"]=function(){return this.keys()},e.prototype[o]=function(){return this.keys()},e}(),h="function"==typeof WeakMap?WeakMap:function(){var e=s.create(),t=n();return function(){function e(){this._key=n()}return e.prototype.has=function(e){var t=i(e,!1);return void 0!==t&&s.has(t,this._key)},e.prototype.get=function(e){var t=i(e,!1);return void 0!==t?s.get(t,this._key):void 0},e.prototype.set=function(e,t){return i(e,!0)[this._key]=t,this},e.prototype.delete=function(e){var t=i(e,!1);return void 0!==t&&delete t[this._key]},e.prototype.clear=function(){this._key=n()},e}();function n(){var t;do{t="@@WeakMap@@"+a()}while(s.has(e,t));return e[t]=!0,t}function i(e,n){if(!r.call(e,t)){if(!n)return;Object.defineProperty(e,t,{value:s.create()})}return e[t]}function o(e,t){for(var r=0;r<t;++r)e[r]=255*Math.random()|0;return e}function a(){var e=function(e){if("function"==typeof Uint8Array){var t=new Uint8Array(e);return"undefined"!=typeof crypto?crypto.getRandomValues(t):"undefined"!=typeof msCrypto?msCrypto.getRandomValues(t):o(t,e),t}return o(new Array(e),e)}(16);e[6]=79&e[6]|64,e[8]=191&e[8]|128;for(var t="",r=0;r<16;++r){var n=e[r];4!==r&&6!==r&&8!==r||(t+="-"),n<16&&(t+="0"),t+=n.toString(16).toLowerCase()}return t}}(),d=n?Symbol.for("@reflect-metadata:registry"):void 0,p=function(){var e;return!E(d)&&I(t.Reflect)&&Object.isExtensible(t.Reflect)&&(e=t.Reflect[d]),E(e)&&(e=function(){var e,r,n,i;E(d)||void 0===t.Reflect||d in t.Reflect||"function"!=typeof t.Reflect.defineMetadata||(e=function(e){var t=e.defineMetadata,r=e.hasOwnMetadata,n=e.getOwnMetadata,i=e.getOwnMetadataKeys,o=e.deleteMetadata,a=new h;return{isProviderFor:function(e,t){var r=a.get(e);return!(E(r)||!r.has(t))||!!i(e,t).length&&(E(r)&&(r=new y,a.set(e,r)),r.add(t),!0)},OrdinaryDefineOwnMetadata:t,OrdinaryHasOwnMetadata:r,OrdinaryGetOwnMetadata:n,OrdinaryOwnMetadataKeys:i,OrdinaryDeleteMetadata:o}}(t.Reflect));var o=new h,a={registerProvider:u,getProvider:s,setProvider:p};return a;function u(t){if(!Object.isExtensible(a))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case e===t:break;case E(r):r=t;break;case r===t:break;case E(n):n=t;break;case n===t:break;default:void 0===i&&(i=new y),i.add(t)}}function c(t,o){if(!E(r)){if(r.isProviderFor(t,o))return r;if(!E(n)){if(n.isProviderFor(t,o))return r;if(!E(i))for(var a=A(i);;){var u=N(a);if(!u)return;var c=D(u);if(c.isProviderFor(t,o))return z(a),c}}}if(!E(e)&&e.isProviderFor(t,o))return e}function s(e,t){var r,n=o.get(e);return E(n)||(r=n.get(t)),E(r)?(E(r=c(e,t))||(E(n)&&(n=new l,o.set(e,n)),n.set(t,r)),r):r}function f(e){if(E(e))throw new TypeError;return r===e||n===e||!E(i)&&i.has(e)}function p(e,t,r){if(!f(r))throw new Error("Metadata provider not registered.");var n=s(e,t);if(n!==r){if(!E(n))return!1;var i=o.get(e);E(i)&&(i=new l,o.set(e,i)),i.set(t,r)}return!0}}()),!E(d)&&I(t.Reflect)&&Object.isExtensible(t.Reflect)&&Object.defineProperty(t.Reflect,d,{enumerable:!1,configurable:!1,writable:!1,value:e}),e}(),v=function(e){var t=new h,r={isProviderFor:function(e,r){var n=t.get(e);return!E(n)&&n.has(r)},OrdinaryDefineOwnMetadata:function(e,t,r,i){n(r,i,!0).set(e,t)},OrdinaryHasOwnMetadata:function(e,t,r){var i=n(t,r,!1);return!E(i)&&P(i.has(e))},OrdinaryGetOwnMetadata:function(e,t,r){var i=n(t,r,!1);if(!E(i))return i.get(e)},OrdinaryOwnMetadataKeys:function(e,t){var r=[],i=n(e,t,!1);if(E(i))return r;for(var o=A(i.keys()),a=0;;){var u=N(o);if(!u)return r.length=a,r;var c=D(u);try{r[a]=c}catch(e){try{z(o)}finally{throw e}}a++}},OrdinaryDeleteMetadata:function(e,r,i){var o=n(r,i,!1);if(E(o))return!1;if(!o.delete(e))return!1;if(0===o.size){var a=t.get(r);E(a)||(a.delete(i),0===a.size&&t.delete(a))}return!0}};return p.registerProvider(r),r;function n(n,i,o){var a=t.get(n),u=!1;if(E(a)){if(!o)return;a=new l,t.set(n,a),u=!0}var c=a.get(i);if(E(c)){if(!o)return;if(c=new l,a.set(i,c),!e.setProvider(n,i,r))throw a.delete(i),u&&t.delete(n),new Error("Wrong provider for target.")}return c}}(p);function g(e,t,r){if(w(e,t,r))return!0;var n=L(t);return!k(n)&&g(e,n,r)}function w(e,t,r){var n=V(t,r,!1);return!E(n)&&P(n.OrdinaryHasOwnMetadata(e,t,r))}function b(e,t,r){if(w(e,t,r))return _(e,t,r);var n=L(t);return k(n)?void 0:b(e,n,r)}function _(e,t,r){var n=V(t,r,!1);if(!E(n))return n.OrdinaryGetOwnMetadata(e,t,r)}function O(e,t,r,n){V(r,n,!0).OrdinaryDefineOwnMetadata(e,t,r,n)}function j(e,t){var r=m(e,t),n=L(e);if(null===n)return r;var i=j(n,t);if(i.length<=0)return r;if(r.length<=0)return i;for(var o=new y,a=[],u=0,c=r;u<c.length;u++){var s=c[u];o.has(s)||(o.add(s),a.push(s))}for(var f=0,l=i;f<l.length;f++)s=l[f],o.has(s)||(o.add(s),a.push(s));return a}function m(e,t){var r=V(e,t,!1);return r?r.OrdinaryOwnMetadataKeys(e,t):[]}function M(e){if(null===e)return 1;switch(typeof e){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return null===e?1:6;default:return 6}}function E(e){return void 0===e}function k(e){return null===e}function I(e){return"object"==typeof e?null!==e:"function"==typeof e}function T(e,t){switch(M(e)){case 0:case 1:case 2:case 3:case 4:case 5:return e}var r=3===t?"string":5===t?"number":"default",n=C(e,i);if(void 0!==n){var o=n.call(e,r);if(I(o))throw new TypeError;return o}return function(e,t){if("string"===t){var r=e.toString;if(K(r)&&!I(i=r.call(e)))return i;if(K(n=e.valueOf)&&!I(i=n.call(e)))return i}else{var n;if(K(n=e.valueOf)&&!I(i=n.call(e)))return i;var i,o=e.toString;if(K(o)&&!I(i=o.call(e)))return i}throw new TypeError}(e,"default"===r?"number":r)}function P(e){return!!e}function R(e){var t=T(e,3);return"symbol"==typeof t?t:function(e){return""+e}(t)}function x(e){return Array.isArray?Array.isArray(e):e instanceof Object?e instanceof Array:"[object Array]"===Object.prototype.toString.call(e)}function K(e){return"function"==typeof e}function S(e){return"function"==typeof e}function F(e,t){return e===t||e!=e&&t!=t}function C(e,t){var r=e[t];if(null!=r){if(!K(r))throw new TypeError;return r}}function A(e){var t=C(e,o);if(!K(t))throw new TypeError;var r=t.call(e);if(!I(r))throw new TypeError;return r}function D(e){return e.value}function N(e){var t=e.next();return!t.done&&t}function z(e){var t=e.return;t&&t.call(e)}function L(e){var t=Object.getPrototypeOf(e);if("function"!=typeof e||e===f)return t;if(t!==f)return t;var r=e.prototype,n=r&&Object.getPrototypeOf(r);if(null==n||n===Object.prototype)return t;var i=n.constructor;return"function"!=typeof i||i===e?t:i}function V(e,t,r){var n=p.getProvider(e,t);if(!E(n))return n;if(r){if(p.setProvider(e,t,v))return v;throw new Error("Illegal state.")}}function W(e){return e.__=void 0,delete e.__,e}e("decorate",(function(e,t,r,n){if(E(r)){if(!x(e))throw new TypeError;if(!S(t))throw new TypeError;return function(e,t){for(var r=e.length-1;r>=0;--r){var n=(0,e[r])(t);if(!E(n)&&!k(n)){if(!S(n))throw new TypeError;t=n}}return t}(e,t)}if(!x(e))throw new TypeError;if(!I(t))throw new TypeError;if(!I(n)&&!E(n)&&!k(n))throw new TypeError;return k(n)&&(n=void 0),function(e,t,r,n){for(var i=e.length-1;i>=0;--i){var o=(0,e[i])(t,r,n);if(!E(o)&&!k(o)){if(!I(o))throw new TypeError;n=o}}return n}(e,t,r=R(r),n)})),e("metadata",(function(e,t){return function(r,n){if(!I(r))throw new TypeError;if(!E(n)&&!function(e){switch(M(e)){case 3:case 4:return!0;default:return!1}}(n))throw new TypeError;O(e,t,r,n)}})),e("defineMetadata",(function(e,t,r,n){if(!I(r))throw new TypeError;return E(n)||(n=R(n)),O(e,t,r,n)})),e("hasMetadata",(function(e,t,r){if(!I(t))throw new TypeError;return E(r)||(r=R(r)),g(e,t,r)})),e("hasOwnMetadata",(function(e,t,r){if(!I(t))throw new TypeError;return E(r)||(r=R(r)),w(e,t,r)})),e("getMetadata",(function(e,t,r){if(!I(t))throw new TypeError;return E(r)||(r=R(r)),b(e,t,r)})),e("getOwnMetadata",(function(e,t,r){if(!I(t))throw new TypeError;return E(r)||(r=R(r)),_(e,t,r)})),e("getMetadataKeys",(function(e,t){if(!I(e))throw new TypeError;return E(t)||(t=R(t)),j(e,t)})),e("getOwnMetadataKeys",(function(e,t){if(!I(e))throw new TypeError;return E(t)||(t=R(t)),m(e,t)})),e("deleteMetadata",(function(e,t,r){if(!I(t))throw new TypeError;if(E(r)||(r=R(r)),!I(t))throw new TypeError;E(r)||(r=R(r));var n=V(t,r,!1);return!E(n)&&n.OrdinaryDeleteMetadata(e,t,r)}))}(n,t),void 0===t.Reflect&&(t.Reflect=e)}()}(n||(n={}))}},t={};function r(n){var i=t[n];if(void 0!==i)return i.exports;var o=t[n]={exports:{}};return e[n].call(o.exports,o,o.exports,r),o.exports}r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r(729);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/*! *****************************************************************************
|
|
2
|
+
Copyright (C) Microsoft. All rights reserved.
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
4
|
+
this file except in compliance with the License. You may obtain a copy of the
|
|
5
|
+
License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
8
|
+
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
|
9
|
+
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
|
10
|
+
MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
11
|
+
|
|
12
|
+
See the Apache Version 2.0 License for specific language governing permissions
|
|
13
|
+
and limitations under the License.
|
|
14
|
+
***************************************************************************** */
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see injectable-decorators.bundle.min.js.LICENSE.txt */
|
|
2
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("injectable-decorators",[],t):"object"==typeof exports?exports["injectable-decorators"]=t():e["injectable-decorators"]=t()}(this,(()=>(()=>{var e={323:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Injectables=void 0;const n=r(426);class i{static{this.actingInjectablesRegistry=void 0}constructor(){}static get(e,...t){return i.getRegistry().get(e,...t)}static register(e,...t){return i.getRegistry().register(e,...t)}static build(e,...t){return i.getRegistry().build(e,...t)}static setRegistry(e){i.actingInjectablesRegistry=e}static getRegistry(){return i.actingInjectablesRegistry||(i.actingInjectablesRegistry=new n.InjectableRegistryImp),i.actingInjectablesRegistry}}t.Injectables=i},640:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InjectablesKeys=void 0,t.InjectablesKeys={REFLECT:"inject.db.",INJECTABLE:"injectable",INJECT:"inject"}},503:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.inject=t.injectable=void 0;const n=r(640),i=r(323),o=r(552),a=e=>n.InjectablesKeys.REFLECT+e;t.injectable=(e=void 0,t=!1,...r)=>o=>{const u=e||o.name,c=function(...e){let c=i.Injectables.get(u,...e);if(!c&&(i.Injectables.register(o,u,!0,t),c=i.Injectables.get(u,...e),!c))return;const s=Object.assign({},{class:u},r||{});return Reflect.defineMetadata(a(n.InjectablesKeys.INJECTABLE),s,c.constructor),c};return c.prototype=o.prototype,Object.defineProperty(c,"name",{writable:!1,enumerable:!0,configurable:!1,value:o.prototype.constructor.name}),c},t.inject=(e,t)=>(r,u)=>{const c=new WeakMap,s=e||(0,o.getTypeFromDecorator)(r,u);if(!s)throw new Error("Could not get Type from decorator");Reflect.defineMetadata(a(n.InjectablesKeys.INJECT),{injectable:s},r,u),Object.defineProperty(r,u,{configurable:!0,get(){if(Object.getOwnPropertyDescriptor(r,u).configurable)return Object.defineProperty(this,u,{enumerable:!0,configurable:!1,get(){let e=c.get(this);if(!e){if(e=i.Injectables.get(s),!e)throw new Error(`Could not get Injectable ${s} to inject in ${r.constructor?r.constructor.name:r.name}'s ${u}`);if(t)try{e=t(e,r)}catch(e){console.error(e)}c.set(this,e)}return e}}),this[u]}})}},729:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),t.VERSION=void 0,i(r(640),t),i(r(503),t),i(r(426),t),t.VERSION="##VERSION##"},426:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InjectableRegistryImp=void 0,t.InjectableRegistryImp=class{constructor(){this.cache={}}get(e,...t){try{const r=this.cache[e],n={name:e};return(r.isSingleton||r.instance)&&r.instance||this.build(n,...t)}catch(e){return}}register(e,t=void 0,r=!0,n=!1){const i=e,o=!i.name&&i.constructor;if("function"!=typeof i&&!o)throw new Error("Injectable registering failed. Missing Class name or constructor");const a=t||(o&&o.name&&"Function"!==o.name?o.name:i.name);this.cache[a]&&!n||(this.cache[a]={instance:o?e:void 0,constructor:o?void 0:e,singleton:r})}build(e,...t){const{constructor:r,singleton:n}=this.cache[e.name],i=new r(...t);return this.cache[e.name]={instance:i,constructor:r,singleton:n},i}}},552:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TypeKey=void 0,t.getTypeFromDecorator=function(e,r){const n=Reflect.getMetadata(t.TypeKey,e,r);return"Function"!==n.name?n.name:void 0},r(630),t.TypeKey="design:type"},630:(e,t,r)=>{var n;!function(e){!function(){var t="object"==typeof globalThis?globalThis:"object"==typeof r.g?r.g:"object"==typeof self?self:"object"==typeof this?this:function(){try{return Function("return this;")()}catch(e){}}()||function(){try{return(0,eval)("(function() { return this; })()")}catch(e){}}(),n=i(e);function i(e,t){return function(r,n){Object.defineProperty(e,r,{configurable:!0,writable:!0,value:n}),t&&t(r,n)}}void 0!==t.Reflect&&(n=i(t.Reflect,n)),function(e,t){var r=Object.prototype.hasOwnProperty,n="function"==typeof Symbol,i=n&&void 0!==Symbol.toPrimitive?Symbol.toPrimitive:"@@toPrimitive",o=n&&void 0!==Symbol.iterator?Symbol.iterator:"@@iterator",a="function"==typeof Object.create,u={__proto__:[]}instanceof Array,c=!a&&!u,s={create:a?function(){return W(Object.create(null))}:u?function(){return W({__proto__:null})}:function(){return W({})},has:c?function(e,t){return r.call(e,t)}:function(e,t){return t in e},get:c?function(e,t){return r.call(e,t)?e[t]:void 0}:function(e,t){return e[t]}},f=Object.getPrototypeOf(Function),l="function"==typeof Map&&"function"==typeof Map.prototype.entries?Map:function(){var e={},t=[],r=function(){function e(e,t,r){this._index=0,this._keys=e,this._values=t,this._selector=r}return e.prototype["@@iterator"]=function(){return this},e.prototype[o]=function(){return this},e.prototype.next=function(){var e=this._index;if(e>=0&&e<this._keys.length){var r=this._selector(this._keys[e],this._values[e]);return e+1>=this._keys.length?(this._index=-1,this._keys=t,this._values=t):this._index++,{value:r,done:!1}}return{value:void 0,done:!0}},e.prototype.throw=function(e){throw this._index>=0&&(this._index=-1,this._keys=t,this._values=t),e},e.prototype.return=function(e){return this._index>=0&&(this._index=-1,this._keys=t,this._values=t),{value:e,done:!0}},e}();return function(){function t(){this._keys=[],this._values=[],this._cacheKey=e,this._cacheIndex=-2}return Object.defineProperty(t.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),t.prototype.has=function(e){return this._find(e,!1)>=0},t.prototype.get=function(e){var t=this._find(e,!1);return t>=0?this._values[t]:void 0},t.prototype.set=function(e,t){var r=this._find(e,!0);return this._values[r]=t,this},t.prototype.delete=function(t){var r=this._find(t,!1);if(r>=0){for(var n=this._keys.length,i=r+1;i<n;i++)this._keys[i-1]=this._keys[i],this._values[i-1]=this._values[i];return this._keys.length--,this._values.length--,F(t,this._cacheKey)&&(this._cacheKey=e,this._cacheIndex=-2),!0}return!1},t.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=e,this._cacheIndex=-2},t.prototype.keys=function(){return new r(this._keys,this._values,n)},t.prototype.values=function(){return new r(this._keys,this._values,i)},t.prototype.entries=function(){return new r(this._keys,this._values,a)},t.prototype["@@iterator"]=function(){return this.entries()},t.prototype[o]=function(){return this.entries()},t.prototype._find=function(e,t){if(!F(this._cacheKey,e)){this._cacheIndex=-1;for(var r=0;r<this._keys.length;r++)if(F(this._keys[r],e)){this._cacheIndex=r;break}}return this._cacheIndex<0&&t&&(this._cacheIndex=this._keys.length,this._keys.push(e),this._values.push(void 0)),this._cacheIndex},t}();function n(e,t){return e}function i(e,t){return t}function a(e,t){return[e,t]}}(),y="function"==typeof Set&&"function"==typeof Set.prototype.entries?Set:function(){function e(){this._map=new l}return Object.defineProperty(e.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),e.prototype.has=function(e){return this._map.has(e)},e.prototype.add=function(e){return this._map.set(e,e),this},e.prototype.delete=function(e){return this._map.delete(e)},e.prototype.clear=function(){this._map.clear()},e.prototype.keys=function(){return this._map.keys()},e.prototype.values=function(){return this._map.keys()},e.prototype.entries=function(){return this._map.entries()},e.prototype["@@iterator"]=function(){return this.keys()},e.prototype[o]=function(){return this.keys()},e}(),h="function"==typeof WeakMap?WeakMap:function(){var e=s.create(),t=n();return function(){function e(){this._key=n()}return e.prototype.has=function(e){var t=i(e,!1);return void 0!==t&&s.has(t,this._key)},e.prototype.get=function(e){var t=i(e,!1);return void 0!==t?s.get(t,this._key):void 0},e.prototype.set=function(e,t){return i(e,!0)[this._key]=t,this},e.prototype.delete=function(e){var t=i(e,!1);return void 0!==t&&delete t[this._key]},e.prototype.clear=function(){this._key=n()},e}();function n(){var t;do{t="@@WeakMap@@"+a()}while(s.has(e,t));return e[t]=!0,t}function i(e,n){if(!r.call(e,t)){if(!n)return;Object.defineProperty(e,t,{value:s.create()})}return e[t]}function o(e,t){for(var r=0;r<t;++r)e[r]=255*Math.random()|0;return e}function a(){var e=function(e){if("function"==typeof Uint8Array){var t=new Uint8Array(e);return"undefined"!=typeof crypto?crypto.getRandomValues(t):"undefined"!=typeof msCrypto?msCrypto.getRandomValues(t):o(t,e),t}return o(new Array(e),e)}(16);e[6]=79&e[6]|64,e[8]=191&e[8]|128;for(var t="",r=0;r<16;++r){var n=e[r];4!==r&&6!==r&&8!==r||(t+="-"),n<16&&(t+="0"),t+=n.toString(16).toLowerCase()}return t}}(),d=n?Symbol.for("@reflect-metadata:registry"):void 0,p=function(){var e;return!E(d)&&I(t.Reflect)&&Object.isExtensible(t.Reflect)&&(e=t.Reflect[d]),E(e)&&(e=function(){var e,r,n,i;E(d)||void 0===t.Reflect||d in t.Reflect||"function"!=typeof t.Reflect.defineMetadata||(e=function(e){var t=e.defineMetadata,r=e.hasOwnMetadata,n=e.getOwnMetadata,i=e.getOwnMetadataKeys,o=e.deleteMetadata,a=new h;return{isProviderFor:function(e,t){var r=a.get(e);return!(E(r)||!r.has(t))||!!i(e,t).length&&(E(r)&&(r=new y,a.set(e,r)),r.add(t),!0)},OrdinaryDefineOwnMetadata:t,OrdinaryHasOwnMetadata:r,OrdinaryGetOwnMetadata:n,OrdinaryOwnMetadataKeys:i,OrdinaryDeleteMetadata:o}}(t.Reflect));var o=new h,a={registerProvider:u,getProvider:s,setProvider:p};return a;function u(t){if(!Object.isExtensible(a))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case e===t:break;case E(r):r=t;break;case r===t:break;case E(n):n=t;break;case n===t:break;default:void 0===i&&(i=new y),i.add(t)}}function c(t,o){if(!E(r)){if(r.isProviderFor(t,o))return r;if(!E(n)){if(n.isProviderFor(t,o))return r;if(!E(i))for(var a=A(i);;){var u=N(a);if(!u)return;var c=D(u);if(c.isProviderFor(t,o))return z(a),c}}}if(!E(e)&&e.isProviderFor(t,o))return e}function s(e,t){var r,n=o.get(e);return E(n)||(r=n.get(t)),E(r)?(E(r=c(e,t))||(E(n)&&(n=new l,o.set(e,n)),n.set(t,r)),r):r}function f(e){if(E(e))throw new TypeError;return r===e||n===e||!E(i)&&i.has(e)}function p(e,t,r){if(!f(r))throw new Error("Metadata provider not registered.");var n=s(e,t);if(n!==r){if(!E(n))return!1;var i=o.get(e);E(i)&&(i=new l,o.set(e,i)),i.set(t,r)}return!0}}()),!E(d)&&I(t.Reflect)&&Object.isExtensible(t.Reflect)&&Object.defineProperty(t.Reflect,d,{enumerable:!1,configurable:!1,writable:!1,value:e}),e}(),v=function(e){var t=new h,r={isProviderFor:function(e,r){var n=t.get(e);return!E(n)&&n.has(r)},OrdinaryDefineOwnMetadata:function(e,t,r,i){n(r,i,!0).set(e,t)},OrdinaryHasOwnMetadata:function(e,t,r){var i=n(t,r,!1);return!E(i)&&P(i.has(e))},OrdinaryGetOwnMetadata:function(e,t,r){var i=n(t,r,!1);if(!E(i))return i.get(e)},OrdinaryOwnMetadataKeys:function(e,t){var r=[],i=n(e,t,!1);if(E(i))return r;for(var o=A(i.keys()),a=0;;){var u=N(o);if(!u)return r.length=a,r;var c=D(u);try{r[a]=c}catch(e){try{z(o)}finally{throw e}}a++}},OrdinaryDeleteMetadata:function(e,r,i){var o=n(r,i,!1);if(E(o))return!1;if(!o.delete(e))return!1;if(0===o.size){var a=t.get(r);E(a)||(a.delete(i),0===a.size&&t.delete(a))}return!0}};return p.registerProvider(r),r;function n(n,i,o){var a=t.get(n),u=!1;if(E(a)){if(!o)return;a=new l,t.set(n,a),u=!0}var c=a.get(i);if(E(c)){if(!o)return;if(c=new l,a.set(i,c),!e.setProvider(n,i,r))throw a.delete(i),u&&t.delete(n),new Error("Wrong provider for target.")}return c}}(p);function g(e,t,r){if(b(e,t,r))return!0;var n=L(t);return!k(n)&&g(e,n,r)}function b(e,t,r){var n=V(t,r,!1);return!E(n)&&P(n.OrdinaryHasOwnMetadata(e,t,r))}function w(e,t,r){if(b(e,t,r))return _(e,t,r);var n=L(t);return k(n)?void 0:w(e,n,r)}function _(e,t,r){var n=V(t,r,!1);if(!E(n))return n.OrdinaryGetOwnMetadata(e,t,r)}function j(e,t,r,n){V(r,n,!0).OrdinaryDefineOwnMetadata(e,t,r,n)}function O(e,t){var r=m(e,t),n=L(e);if(null===n)return r;var i=O(n,t);if(i.length<=0)return r;if(r.length<=0)return i;for(var o=new y,a=[],u=0,c=r;u<c.length;u++){var s=c[u];o.has(s)||(o.add(s),a.push(s))}for(var f=0,l=i;f<l.length;f++)s=l[f],o.has(s)||(o.add(s),a.push(s));return a}function m(e,t){var r=V(e,t,!1);return r?r.OrdinaryOwnMetadataKeys(e,t):[]}function M(e){if(null===e)return 1;switch(typeof e){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return null===e?1:6;default:return 6}}function E(e){return void 0===e}function k(e){return null===e}function I(e){return"object"==typeof e?null!==e:"function"==typeof e}function T(e,t){switch(M(e)){case 0:case 1:case 2:case 3:case 4:case 5:return e}var r=3===t?"string":5===t?"number":"default",n=C(e,i);if(void 0!==n){var o=n.call(e,r);if(I(o))throw new TypeError;return o}return function(e,t){if("string"===t){var r=e.toString;if(K(r)&&!I(i=r.call(e)))return i;if(K(n=e.valueOf)&&!I(i=n.call(e)))return i}else{var n;if(K(n=e.valueOf)&&!I(i=n.call(e)))return i;var i,o=e.toString;if(K(o)&&!I(i=o.call(e)))return i}throw new TypeError}(e,"default"===r?"number":r)}function P(e){return!!e}function R(e){var t=T(e,3);return"symbol"==typeof t?t:function(e){return""+e}(t)}function x(e){return Array.isArray?Array.isArray(e):e instanceof Object?e instanceof Array:"[object Array]"===Object.prototype.toString.call(e)}function K(e){return"function"==typeof e}function S(e){return"function"==typeof e}function F(e,t){return e===t||e!=e&&t!=t}function C(e,t){var r=e[t];if(null!=r){if(!K(r))throw new TypeError;return r}}function A(e){var t=C(e,o);if(!K(t))throw new TypeError;var r=t.call(e);if(!I(r))throw new TypeError;return r}function D(e){return e.value}function N(e){var t=e.next();return!t.done&&t}function z(e){var t=e.return;t&&t.call(e)}function L(e){var t=Object.getPrototypeOf(e);if("function"!=typeof e||e===f)return t;if(t!==f)return t;var r=e.prototype,n=r&&Object.getPrototypeOf(r);if(null==n||n===Object.prototype)return t;var i=n.constructor;return"function"!=typeof i||i===e?t:i}function V(e,t,r){var n=p.getProvider(e,t);if(!E(n))return n;if(r){if(p.setProvider(e,t,v))return v;throw new Error("Illegal state.")}}function W(e){return e.__=void 0,delete e.__,e}e("decorate",(function(e,t,r,n){if(E(r)){if(!x(e))throw new TypeError;if(!S(t))throw new TypeError;return function(e,t){for(var r=e.length-1;r>=0;--r){var n=(0,e[r])(t);if(!E(n)&&!k(n)){if(!S(n))throw new TypeError;t=n}}return t}(e,t)}if(!x(e))throw new TypeError;if(!I(t))throw new TypeError;if(!I(n)&&!E(n)&&!k(n))throw new TypeError;return k(n)&&(n=void 0),function(e,t,r,n){for(var i=e.length-1;i>=0;--i){var o=(0,e[i])(t,r,n);if(!E(o)&&!k(o)){if(!I(o))throw new TypeError;n=o}}return n}(e,t,r=R(r),n)})),e("metadata",(function(e,t){return function(r,n){if(!I(r))throw new TypeError;if(!E(n)&&!function(e){switch(M(e)){case 3:case 4:return!0;default:return!1}}(n))throw new TypeError;j(e,t,r,n)}})),e("defineMetadata",(function(e,t,r,n){if(!I(r))throw new TypeError;return E(n)||(n=R(n)),j(e,t,r,n)})),e("hasMetadata",(function(e,t,r){if(!I(t))throw new TypeError;return E(r)||(r=R(r)),g(e,t,r)})),e("hasOwnMetadata",(function(e,t,r){if(!I(t))throw new TypeError;return E(r)||(r=R(r)),b(e,t,r)})),e("getMetadata",(function(e,t,r){if(!I(t))throw new TypeError;return E(r)||(r=R(r)),w(e,t,r)})),e("getOwnMetadata",(function(e,t,r){if(!I(t))throw new TypeError;return E(r)||(r=R(r)),_(e,t,r)})),e("getMetadataKeys",(function(e,t){if(!I(e))throw new TypeError;return E(t)||(t=R(t)),O(e,t)})),e("getOwnMetadataKeys",(function(e,t){if(!I(e))throw new TypeError;return E(t)||(t=R(t)),m(e,t)})),e("deleteMetadata",(function(e,t,r){if(!I(t))throw new TypeError;if(E(r)||(r=R(r)),!I(t))throw new TypeError;E(r)||(r=R(r));var n=V(t,r,!1);return!E(n)&&n.OrdinaryDeleteMetadata(e,t,r)}))}(n,t),void 0===t.Reflect&&(t.Reflect=e)}()}(n||(n={}))}},t={};function r(n){var i=t[n];if(void 0!==i)return i.exports;var o=t[n]={exports:{}};return e[n].call(o.exports,o,o.exports,r),o.exports}return r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r(729)})()));
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/*! *****************************************************************************
|
|
2
|
+
Copyright (C) Microsoft. All rights reserved.
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
4
|
+
this file except in compliance with the License. You may obtain a copy of the
|
|
5
|
+
License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
8
|
+
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
|
9
|
+
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
|
10
|
+
MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
11
|
+
|
|
12
|
+
See the Apache Version 2.0 License for specific language governing permissions
|
|
13
|
+
and limitations under the License.
|
|
14
|
+
***************************************************************************** */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:!0}),exports.Injectables=void 0;let registry_1=require("./registry.cjs");class Injectables{static{this.actingInjectablesRegistry=void 0}constructor(){}static get(e,...t){return Injectables.getRegistry().get(e,...t)}static register(e,...t){return Injectables.getRegistry().register(e,...t)}static build(e,...t){return Injectables.getRegistry().build(e,...t)}static setRegistry(e){Injectables.actingInjectablesRegistry=e}static getRegistry(){return Injectables.actingInjectablesRegistry||(Injectables.actingInjectablesRegistry=new registry_1.InjectableRegistryImp),Injectables.actingInjectablesRegistry}}exports.Injectables=Injectables;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Injectable, InjectablesRegistry } from "./registry";
|
|
2
|
+
/**
|
|
3
|
+
* @summary Static class Holding the access to the injectables functions
|
|
4
|
+
*
|
|
5
|
+
* @class Injectables
|
|
6
|
+
* @static
|
|
7
|
+
*/
|
|
8
|
+
export declare class Injectables {
|
|
9
|
+
private static actingInjectablesRegistry?;
|
|
10
|
+
private constructor();
|
|
11
|
+
/**
|
|
12
|
+
* @summary Retrieves the named {@link Injectable} from the registry
|
|
13
|
+
* @param {string} name
|
|
14
|
+
* @param {any[]} args
|
|
15
|
+
*/
|
|
16
|
+
static get<T>(name: string, ...args: any[]): Injectable<T> | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* @summary registers an injectable constructor
|
|
19
|
+
* @param {Injectable} constructor
|
|
20
|
+
* @param {any[]} args
|
|
21
|
+
*
|
|
22
|
+
*/
|
|
23
|
+
static register<T>(constructor: Injectable<T>, ...args: any[]): void;
|
|
24
|
+
/**
|
|
25
|
+
* @summary Instantiates an Injectable
|
|
26
|
+
* @param {Record<string, any>} obj
|
|
27
|
+
* @param {any[]} args
|
|
28
|
+
* @return T
|
|
29
|
+
*
|
|
30
|
+
*/
|
|
31
|
+
static build<T>(obj: Record<string, any>, ...args: any[]): T;
|
|
32
|
+
/**
|
|
33
|
+
* @summary Sets a new {@link InjectablesRegistry}
|
|
34
|
+
* @param {InjectablesRegistry} operationsRegistry the new implementation of Registry
|
|
35
|
+
*/
|
|
36
|
+
static setRegistry(operationsRegistry: InjectablesRegistry): void;
|
|
37
|
+
/**
|
|
38
|
+
* @summary Returns the current {@link InjectablesRegistry}
|
|
39
|
+
*/
|
|
40
|
+
private static getRegistry;
|
|
41
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:!0}),exports.InjectablesKeys=void 0,exports.InjectablesKeys={REFLECT:"inject.db.",INJECTABLE:"injectable",INJECT:"inject"};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @summary Injectables Reflection keys
|
|
3
|
+
* @const InjectablesKeys
|
|
4
|
+
*
|
|
5
|
+
* @property {string} REFLECT Reflection injectables base key
|
|
6
|
+
* @property {string} INJECTABLE Reflection injectable key
|
|
7
|
+
* @property {string} INJECT Reflection inject key
|
|
8
|
+
*
|
|
9
|
+
* @memberOf injectable-decorators
|
|
10
|
+
*/
|
|
11
|
+
export declare const InjectablesKeys: {
|
|
12
|
+
REFLECT: string;
|
|
13
|
+
INJECTABLE: string;
|
|
14
|
+
INJECT: string;
|
|
15
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:!0}),exports.inject=exports.injectable=void 0;let constants_1=require("./constants.cjs"),Injectables_1=require("./Injectables.cjs"),utils_1=require("./utils.cjs"),getInjectKey=e=>constants_1.InjectablesKeys.REFLECT+e,injectable=(t=void 0,c=!1,...o)=>n=>{let r=t||n.name;function e(...e){let t=Injectables_1.Injectables.get(r,...e);if(t||(Injectables_1.Injectables.register(n,r,!0,c),t=Injectables_1.Injectables.get(r,...e)))return e=Object.assign({},{class:r},o||{}),Reflect.defineMetadata(getInjectKey(constants_1.InjectablesKeys.INJECTABLE),e,t.constructor),t}return e.prototype=n.prototype,Object.defineProperty(e,"name",{writable:!1,enumerable:!0,configurable:!1,value:n.prototype.constructor.name}),e},inject=(exports.injectable=injectable,(e,o)=>(t,n)=>{let r=new WeakMap,c=e||(0,utils_1.getTypeFromDecorator)(t,n);if(!c)throw new Error("Could not get Type from decorator");Reflect.defineMetadata(getInjectKey(constants_1.InjectablesKeys.INJECT),{injectable:c},t,n),Object.defineProperty(t,n,{configurable:!0,get(){if(Object.getOwnPropertyDescriptor(t,n).configurable)return Object.defineProperty(this,n,{enumerable:!0,configurable:!1,get(){let e=r.get(this);if(!e){if(!(e=Injectables_1.Injectables.get(c)))throw new Error(`Could not get Injectable ${c} to inject in ${(t.constructor||t).name}'s `+n);if(o)try{e=o(e,t)}catch(e){console.error(e)}r.set(this,e)}return e}}),this[n]}})});exports.inject=inject;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @summary Defines a class as an injectable
|
|
3
|
+
*
|
|
4
|
+
* @param {string} [category] defaults to the class Name. (Useful when minification occours and names are changed so we can no longer rely on the class name, or when we want to upcast the Object)
|
|
5
|
+
* @param {boolean} [force] defines if the injectable should override the already existing instance (if any). (only meant for extending decorators
|
|
6
|
+
* @param {any[]} [props] additional properties to pass for the decorator metadata. (only meant for 'extending' classes)
|
|
7
|
+
*
|
|
8
|
+
* @function injectable
|
|
9
|
+
*
|
|
10
|
+
* @memberOf module:injectable-decorators.Decorators
|
|
11
|
+
*/
|
|
12
|
+
export declare const injectable: (category?: string | undefined, force?: boolean, ...props: any[]) => (original: any) => any;
|
|
13
|
+
/**
|
|
14
|
+
* @summary function witch transforms a cached {@link injectable}
|
|
15
|
+
*
|
|
16
|
+
* @param {any} injectable
|
|
17
|
+
* @param {any} obj the obj the injectable will be injected on
|
|
18
|
+
*
|
|
19
|
+
* @memberOf module:injectable-decorators
|
|
20
|
+
*/
|
|
21
|
+
export type InstanceTransformer = (injectable: any, obj: any) => any;
|
|
22
|
+
/**
|
|
23
|
+
* @summary Allows for the injection of an {@link injectable} decorated dependency
|
|
24
|
+
* @description the property must be typed for the requested dependency.
|
|
25
|
+
*
|
|
26
|
+
* Only concrete classes. No generics are supported
|
|
27
|
+
*
|
|
28
|
+
* Injected properties should be described like so:
|
|
29
|
+
* <pre>
|
|
30
|
+
* class ClassName {
|
|
31
|
+
* ...
|
|
32
|
+
*
|
|
33
|
+
* @inject()
|
|
34
|
+
* propertyName!: InjectableClass;
|
|
35
|
+
*
|
|
36
|
+
* ...
|
|
37
|
+
* }
|
|
38
|
+
* </pre>
|
|
39
|
+
*
|
|
40
|
+
* where InjectableClass is the class you want to inject.
|
|
41
|
+
* Notice the use of '!:' to ensure the transpiler the property will be set outside the constructor but will always be defined
|
|
42
|
+
* For project where minification occours, you should use the category param to ensure the name is the same throughout
|
|
43
|
+
*
|
|
44
|
+
* @param {string} [category] defaults to the class Name. (Useful when minification occours and names are changed so we can no longer rely on the class name, or when we want to upcast the Object)
|
|
45
|
+
* @param {InstanceTransformer} [transformer]
|
|
46
|
+
*
|
|
47
|
+
* @function inject
|
|
48
|
+
*
|
|
49
|
+
* @memberOf module:injectable-decorators.Decorators
|
|
50
|
+
*/
|
|
51
|
+
export declare const inject: (category?: string, transformer?: InstanceTransformer) => (target: any, propertyKey: string) => void;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Injectable, InjectablesRegistry } from "./registry";
|
|
2
|
+
/**
|
|
3
|
+
* @summary Static class Holding the access to the injectables functions
|
|
4
|
+
*
|
|
5
|
+
* @class Injectables
|
|
6
|
+
* @static
|
|
7
|
+
*/
|
|
8
|
+
export declare class Injectables {
|
|
9
|
+
private static actingInjectablesRegistry?;
|
|
10
|
+
private constructor();
|
|
11
|
+
/**
|
|
12
|
+
* @summary Retrieves the named {@link Injectable} from the registry
|
|
13
|
+
* @param {string} name
|
|
14
|
+
* @param {any[]} args
|
|
15
|
+
*/
|
|
16
|
+
static get<T>(name: string, ...args: any[]): Injectable<T> | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* @summary registers an injectable constructor
|
|
19
|
+
* @param {Injectable} constructor
|
|
20
|
+
* @param {any[]} args
|
|
21
|
+
*
|
|
22
|
+
*/
|
|
23
|
+
static register<T>(constructor: Injectable<T>, ...args: any[]): void;
|
|
24
|
+
/**
|
|
25
|
+
* @summary Instantiates an Injectable
|
|
26
|
+
* @param {Record<string, any>} obj
|
|
27
|
+
* @param {any[]} args
|
|
28
|
+
* @return T
|
|
29
|
+
*
|
|
30
|
+
*/
|
|
31
|
+
static build<T>(obj: Record<string, any>, ...args: any[]): T;
|
|
32
|
+
/**
|
|
33
|
+
* @summary Sets a new {@link InjectablesRegistry}
|
|
34
|
+
* @param {InjectablesRegistry} operationsRegistry the new implementation of Registry
|
|
35
|
+
*/
|
|
36
|
+
static setRegistry(operationsRegistry: InjectablesRegistry): void;
|
|
37
|
+
/**
|
|
38
|
+
* @summary Returns the current {@link InjectablesRegistry}
|
|
39
|
+
*/
|
|
40
|
+
private static getRegistry;
|
|
41
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{InjectableRegistryImp}from"./registry";class Injectables{static{this.actingInjectablesRegistry=void 0}constructor(){}static get(t,...e){return Injectables.getRegistry().get(t,...e)}static register(t,...e){return Injectables.getRegistry().register(t,...e)}static build(t,...e){return Injectables.getRegistry().build(t,...e)}static setRegistry(t){Injectables.actingInjectablesRegistry=t}static getRegistry(){return Injectables.actingInjectablesRegistry||(Injectables.actingInjectablesRegistry=new InjectableRegistryImp),Injectables.actingInjectablesRegistry}}export{Injectables};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @summary Injectables Reflection keys
|
|
3
|
+
* @const InjectablesKeys
|
|
4
|
+
*
|
|
5
|
+
* @property {string} REFLECT Reflection injectables base key
|
|
6
|
+
* @property {string} INJECTABLE Reflection injectable key
|
|
7
|
+
* @property {string} INJECT Reflection inject key
|
|
8
|
+
*
|
|
9
|
+
* @memberOf injectable-decorators
|
|
10
|
+
*/
|
|
11
|
+
export declare const InjectablesKeys: {
|
|
12
|
+
REFLECT: string;
|
|
13
|
+
INJECTABLE: string;
|
|
14
|
+
INJECT: string;
|
|
15
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
let InjectablesKeys={REFLECT:"inject.db.",INJECTABLE:"injectable",INJECT:"inject"};export{InjectablesKeys};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @summary Defines a class as an injectable
|
|
3
|
+
*
|
|
4
|
+
* @param {string} [category] defaults to the class Name. (Useful when minification occours and names are changed so we can no longer rely on the class name, or when we want to upcast the Object)
|
|
5
|
+
* @param {boolean} [force] defines if the injectable should override the already existing instance (if any). (only meant for extending decorators
|
|
6
|
+
* @param {any[]} [props] additional properties to pass for the decorator metadata. (only meant for 'extending' classes)
|
|
7
|
+
*
|
|
8
|
+
* @function injectable
|
|
9
|
+
*
|
|
10
|
+
* @memberOf module:injectable-decorators.Decorators
|
|
11
|
+
*/
|
|
12
|
+
export declare const injectable: (category?: string | undefined, force?: boolean, ...props: any[]) => (original: any) => any;
|
|
13
|
+
/**
|
|
14
|
+
* @summary function witch transforms a cached {@link injectable}
|
|
15
|
+
*
|
|
16
|
+
* @param {any} injectable
|
|
17
|
+
* @param {any} obj the obj the injectable will be injected on
|
|
18
|
+
*
|
|
19
|
+
* @memberOf module:injectable-decorators
|
|
20
|
+
*/
|
|
21
|
+
export type InstanceTransformer = (injectable: any, obj: any) => any;
|
|
22
|
+
/**
|
|
23
|
+
* @summary Allows for the injection of an {@link injectable} decorated dependency
|
|
24
|
+
* @description the property must be typed for the requested dependency.
|
|
25
|
+
*
|
|
26
|
+
* Only concrete classes. No generics are supported
|
|
27
|
+
*
|
|
28
|
+
* Injected properties should be described like so:
|
|
29
|
+
* <pre>
|
|
30
|
+
* class ClassName {
|
|
31
|
+
* ...
|
|
32
|
+
*
|
|
33
|
+
* @inject()
|
|
34
|
+
* propertyName!: InjectableClass;
|
|
35
|
+
*
|
|
36
|
+
* ...
|
|
37
|
+
* }
|
|
38
|
+
* </pre>
|
|
39
|
+
*
|
|
40
|
+
* where InjectableClass is the class you want to inject.
|
|
41
|
+
* Notice the use of '!:' to ensure the transpiler the property will be set outside the constructor but will always be defined
|
|
42
|
+
* For project where minification occours, you should use the category param to ensure the name is the same throughout
|
|
43
|
+
*
|
|
44
|
+
* @param {string} [category] defaults to the class Name. (Useful when minification occours and names are changed so we can no longer rely on the class name, or when we want to upcast the Object)
|
|
45
|
+
* @param {InstanceTransformer} [transformer]
|
|
46
|
+
*
|
|
47
|
+
* @function inject
|
|
48
|
+
*
|
|
49
|
+
* @memberOf module:injectable-decorators.Decorators
|
|
50
|
+
*/
|
|
51
|
+
export declare const inject: (category?: string, transformer?: InstanceTransformer) => (target: any, propertyKey: string) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{InjectablesKeys}from"./constants";import{Injectables}from"./Injectables";import{getTypeFromDecorator}from"./utils";let getInjectKey=e=>InjectablesKeys.REFLECT+e,injectable=(t=void 0,o=!1,...c)=>r=>{let n=t||r.name;function e(...e){let t=Injectables.get(n,...e);if(t||(Injectables.register(r,n,!0,o),t=Injectables.get(n,...e)))return e=Object.assign({},{class:n},c||{}),Reflect.defineMetadata(getInjectKey(InjectablesKeys.INJECTABLE),e,t.constructor),t}return e.prototype=r.prototype,Object.defineProperty(e,"name",{writable:!1,enumerable:!0,configurable:!1,value:r.prototype.constructor.name}),e},inject=(e,c)=>(t,r)=>{let n=new WeakMap,o=e||getTypeFromDecorator(t,r);if(!o)throw new Error("Could not get Type from decorator");Reflect.defineMetadata(getInjectKey(InjectablesKeys.INJECT),{injectable:o},t,r),Object.defineProperty(t,r,{configurable:!0,get(){if(Object.getOwnPropertyDescriptor(t,r).configurable)return Object.defineProperty(this,r,{enumerable:!0,configurable:!1,get(){let e=n.get(this);if(!e){if(!(e=Injectables.get(o)))throw new Error(`Could not get Injectable ${o} to inject in ${(t.constructor||t).name}'s `+r);if(c)try{e=c(e,t)}catch(e){console.error(e)}n.set(this,e)}return e}}),this[r]}})};export{injectable,inject};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @summary Adds a simple Injectables implementation to create singleton instances of an object
|
|
3
|
+
* and easily inject it into other objects
|
|
4
|
+
*
|
|
5
|
+
* @module injectable-decorators
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* @summary functions that decorate classes or class properties
|
|
9
|
+
* @namespace Decorators
|
|
10
|
+
* @memberOf module:injectable-decorators
|
|
11
|
+
*/
|
|
12
|
+
export * from "./constants";
|
|
13
|
+
export * from "./decorators";
|
|
14
|
+
export * from "./registry";
|
|
15
|
+
/**
|
|
16
|
+
* @summary Defined on library build. holds the library current version
|
|
17
|
+
* @const VERSION
|
|
18
|
+
* @memberOf module:injectable-decorators
|
|
19
|
+
*/
|
|
20
|
+
export declare const VERSION = "1.2.0";
|
package/lib/esm/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from"./constants";export*from"./decorators";export*from"./registry";let VERSION="1.2.0";export{VERSION};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @summary defines an Injectable type
|
|
3
|
+
* @memberOf module:injectable-decorators
|
|
4
|
+
*/
|
|
5
|
+
export type Injectable<T> = {
|
|
6
|
+
new (...args: any[]): T;
|
|
7
|
+
} | T;
|
|
8
|
+
/**
|
|
9
|
+
* @summary Interface for an injectable registry
|
|
10
|
+
* @interface InjectableRegistry
|
|
11
|
+
*/
|
|
12
|
+
export interface InjectablesRegistry {
|
|
13
|
+
/**
|
|
14
|
+
* @summary retrieves an {@link Injectable}
|
|
15
|
+
* @param {string} name
|
|
16
|
+
* @param {any[]} args
|
|
17
|
+
* @return {Injectable | undefined}
|
|
18
|
+
*
|
|
19
|
+
* @method
|
|
20
|
+
*/
|
|
21
|
+
get<T>(name: string, ...args: any[]): Injectable<T> | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* @summary registers an injectable constructor
|
|
24
|
+
* @param {Injectable} constructor
|
|
25
|
+
* @param {any[]} args
|
|
26
|
+
*
|
|
27
|
+
* @method
|
|
28
|
+
*/
|
|
29
|
+
register<T>(constructor: Injectable<T>, ...args: any[]): void;
|
|
30
|
+
/**
|
|
31
|
+
* @summary Instantiates an Injectable
|
|
32
|
+
* @param {Record<string, any>} obj
|
|
33
|
+
* @param {any[]} args
|
|
34
|
+
* @return T
|
|
35
|
+
*
|
|
36
|
+
* @method
|
|
37
|
+
*/
|
|
38
|
+
build<T>(obj: Record<string, any>, ...args: any[]): T;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* @summary Holds the vairous {@link Injectable}s
|
|
42
|
+
* @class InjectableRegistryImp
|
|
43
|
+
* @implements InjectablesRegistry
|
|
44
|
+
*/
|
|
45
|
+
export declare class InjectableRegistryImp implements InjectablesRegistry {
|
|
46
|
+
private cache;
|
|
47
|
+
/**
|
|
48
|
+
* @inheritDoc
|
|
49
|
+
*/
|
|
50
|
+
get<T>(name: string, ...args: any[]): T | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* @inheritDoc
|
|
53
|
+
*/
|
|
54
|
+
register<T>(obj: Injectable<T>, category?: string | undefined, isSingleton?: boolean, force?: boolean): void;
|
|
55
|
+
/**
|
|
56
|
+
* @inheritDoc
|
|
57
|
+
*/
|
|
58
|
+
build<T>(defs: {
|
|
59
|
+
name: string;
|
|
60
|
+
}, ...args: any[]): T;
|
|
61
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
class InjectableRegistryImp{constructor(){this.cache={}}get(t,...n){try{var e=this.cache[t],c={name:t};return e.isSingleton||e.instance?e.instance||this.build(c,...n):this.build(c,...n)}catch(t){}}register(t,n=void 0,e=!0,c=!1){var i=t,r=!i.name&&i.constructor;if("function"!=typeof i&&!r)throw new Error("Injectable registering failed. Missing Class name or constructor");n=n||(r&&r.name&&"Function"!==r.name?r:i).name;this.cache[n]&&!c||(this.cache[n]={instance:r?t:void 0,constructor:r?void 0:t,singleton:e})}build(t,...n){var{constructor:e,singleton:c}=this.cache[t.name],n=new e(...n);return this.cache[t.name]={instance:n,constructor:e,singleton:c},n}}export{InjectableRegistryImp};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
/**
|
|
3
|
+
* @summary holds the key for the design type
|
|
4
|
+
* @const TypeKey
|
|
5
|
+
* @memberOf module:injectable-decorators
|
|
6
|
+
*/
|
|
7
|
+
export declare const TypeKey = "design:type";
|
|
8
|
+
/**
|
|
9
|
+
* @summary Retrieves the type from the decorators
|
|
10
|
+
* @param {any} model
|
|
11
|
+
* @param {string | symbol} propKey
|
|
12
|
+
* @return {string | undefined}
|
|
13
|
+
*
|
|
14
|
+
* @function geTypeFromDecorators
|
|
15
|
+
*
|
|
16
|
+
* @memberOf module:injectable-decorators
|
|
17
|
+
*/
|
|
18
|
+
export declare function getTypeFromDecorator(model: any, propKey: string | symbol): string | undefined;
|
package/lib/esm/utils.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"reflect-metadata";let TypeKey="design:type";function getTypeFromDecorator(e,t){e=Reflect.getMetadata(TypeKey,e,t);return"Function"!==e.name?e.name:void 0}export{TypeKey,getTypeFromDecorator};
|
package/lib/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var __createBinding=this&&this.__createBinding||(Object.create?function(e,r,t,o){void 0===o&&(o=t);var i=Object.getOwnPropertyDescriptor(r,t);i&&("get"in i?r.__esModule:!i.writable&&!i.configurable)||(i={enumerable:!0,get:function(){return r[t]}}),Object.defineProperty(e,o,i)}:function(e,r,t,o){e[o=void 0===o?t:o]=r[t]}),__exportStar=this&&this.__exportStar||function(e,r){for(var t in e)"default"===t||Object.prototype.hasOwnProperty.call(r,t)||__createBinding(r,e,t)};Object.defineProperty(exports,"__esModule",{value:!0}),exports.VERSION=void 0,__exportStar(require("./constants.cjs"),exports),__exportStar(require("./decorators.cjs"),exports),__exportStar(require("./registry.cjs"),exports),exports.VERSION="1.2.0";
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @summary Adds a simple Injectables implementation to create singleton instances of an object
|
|
3
|
+
* and easily inject it into other objects
|
|
4
|
+
*
|
|
5
|
+
* @module injectable-decorators
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* @summary functions that decorate classes or class properties
|
|
9
|
+
* @namespace Decorators
|
|
10
|
+
* @memberOf module:injectable-decorators
|
|
11
|
+
*/
|
|
12
|
+
export * from "./constants";
|
|
13
|
+
export * from "./decorators";
|
|
14
|
+
export * from "./registry";
|
|
15
|
+
/**
|
|
16
|
+
* @summary Defined on library build. holds the library current version
|
|
17
|
+
* @const VERSION
|
|
18
|
+
* @memberOf module:injectable-decorators
|
|
19
|
+
*/
|
|
20
|
+
export declare const VERSION = "1.2.0";
|
package/lib/registry.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:!0}),exports.InjectableRegistryImp=void 0;class InjectableRegistryImp{constructor(){this.cache={}}get(e,...t){try{var n=this.cache[e],c={name:e};return n.isSingleton||n.instance?n.instance||this.build(c,...t):this.build(c,...t)}catch(e){}}register(e,t=void 0,n=!0,c=!1){var i=e,r=!i.name&&i.constructor;if("function"!=typeof i&&!r)throw new Error("Injectable registering failed. Missing Class name or constructor");t=t||(r&&r.name&&"Function"!==r.name?r:i).name;this.cache[t]&&!c||(this.cache[t]={instance:r?e:void 0,constructor:r?void 0:e,singleton:n})}build(e,...t){var{constructor:n,singleton:c}=this.cache[e.name],t=new n(...t);return this.cache[e.name]={instance:t,constructor:n,singleton:c},t}}exports.InjectableRegistryImp=InjectableRegistryImp;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @summary defines an Injectable type
|
|
3
|
+
* @memberOf module:injectable-decorators
|
|
4
|
+
*/
|
|
5
|
+
export type Injectable<T> = {
|
|
6
|
+
new (...args: any[]): T;
|
|
7
|
+
} | T;
|
|
8
|
+
/**
|
|
9
|
+
* @summary Interface for an injectable registry
|
|
10
|
+
* @interface InjectableRegistry
|
|
11
|
+
*/
|
|
12
|
+
export interface InjectablesRegistry {
|
|
13
|
+
/**
|
|
14
|
+
* @summary retrieves an {@link Injectable}
|
|
15
|
+
* @param {string} name
|
|
16
|
+
* @param {any[]} args
|
|
17
|
+
* @return {Injectable | undefined}
|
|
18
|
+
*
|
|
19
|
+
* @method
|
|
20
|
+
*/
|
|
21
|
+
get<T>(name: string, ...args: any[]): Injectable<T> | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* @summary registers an injectable constructor
|
|
24
|
+
* @param {Injectable} constructor
|
|
25
|
+
* @param {any[]} args
|
|
26
|
+
*
|
|
27
|
+
* @method
|
|
28
|
+
*/
|
|
29
|
+
register<T>(constructor: Injectable<T>, ...args: any[]): void;
|
|
30
|
+
/**
|
|
31
|
+
* @summary Instantiates an Injectable
|
|
32
|
+
* @param {Record<string, any>} obj
|
|
33
|
+
* @param {any[]} args
|
|
34
|
+
* @return T
|
|
35
|
+
*
|
|
36
|
+
* @method
|
|
37
|
+
*/
|
|
38
|
+
build<T>(obj: Record<string, any>, ...args: any[]): T;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* @summary Holds the vairous {@link Injectable}s
|
|
42
|
+
* @class InjectableRegistryImp
|
|
43
|
+
* @implements InjectablesRegistry
|
|
44
|
+
*/
|
|
45
|
+
export declare class InjectableRegistryImp implements InjectablesRegistry {
|
|
46
|
+
private cache;
|
|
47
|
+
/**
|
|
48
|
+
* @inheritDoc
|
|
49
|
+
*/
|
|
50
|
+
get<T>(name: string, ...args: any[]): T | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* @inheritDoc
|
|
53
|
+
*/
|
|
54
|
+
register<T>(obj: Injectable<T>, category?: string | undefined, isSingleton?: boolean, force?: boolean): void;
|
|
55
|
+
/**
|
|
56
|
+
* @inheritDoc
|
|
57
|
+
*/
|
|
58
|
+
build<T>(defs: {
|
|
59
|
+
name: string;
|
|
60
|
+
}, ...args: any[]): T;
|
|
61
|
+
}
|
package/lib/utils.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function getTypeFromDecorator(e,t){e=Reflect.getMetadata(exports.TypeKey,e,t);return"Function"!==e.name?e.name:void 0}Object.defineProperty(exports,"__esModule",{value:!0}),exports.TypeKey=void 0,exports.getTypeFromDecorator=getTypeFromDecorator,require("reflect-metadata"),exports.TypeKey="design:type";
|
package/lib/utils.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
/**
|
|
3
|
+
* @summary holds the key for the design type
|
|
4
|
+
* @const TypeKey
|
|
5
|
+
* @memberOf module:injectable-decorators
|
|
6
|
+
*/
|
|
7
|
+
export declare const TypeKey = "design:type";
|
|
8
|
+
/**
|
|
9
|
+
* @summary Retrieves the type from the decorators
|
|
10
|
+
* @param {any} model
|
|
11
|
+
* @param {string | symbol} propKey
|
|
12
|
+
* @return {string | undefined}
|
|
13
|
+
*
|
|
14
|
+
* @function geTypeFromDecorators
|
|
15
|
+
*
|
|
16
|
+
* @memberOf module:injectable-decorators
|
|
17
|
+
*/
|
|
18
|
+
export declare function getTypeFromDecorator(model: any, propKey: string | symbol): string | undefined;
|
package/package.json
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@decaf-ts/injectable-decorators",
|
|
3
|
+
"version": "1.3.0",
|
|
4
|
+
"description": "injectable decorators extension for decorator validation",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
"require": "./lib/index.js",
|
|
8
|
+
"import": "./lib/esm/index.js"
|
|
9
|
+
},
|
|
10
|
+
"main": "lib/index.js",
|
|
11
|
+
"scripts": {
|
|
12
|
+
"do-install": "TOKEN=$(cat .token) npm install",
|
|
13
|
+
"update-dependencies": "rimraf node_modules/@decaf-ts package-lock.json && npm run do-install",
|
|
14
|
+
"flash-forward": "npx npm-check-updates -u && npm run do-install",
|
|
15
|
+
"reset": "rm -rf * && git checkout . && git pull && npm run do-install",
|
|
16
|
+
"build": "rimraf ./lib && rimraf ./dist && gulp dev",
|
|
17
|
+
"build:prod": "rimraf ./lib && rimraf ./dist && gulp prod",
|
|
18
|
+
"test": "jest --coverage --testPathPattern=\"/tests/unit\" --passWithNoTests --detectOpenHandles",
|
|
19
|
+
"test:integration": "jest --coverage --testPathPattern=\"/tests/(integration)\" --passWithNoTests --detectOpenHandles",
|
|
20
|
+
"test:all": "jest --coverage --testPathPattern=\"/tests/(unit|integration)\" --passWithNoTests --detectOpenHandles",
|
|
21
|
+
"lint": "eslint .",
|
|
22
|
+
"lint-fix": "eslint . && eslint --fix ./src/*",
|
|
23
|
+
"prepare-release": "npm run lint-fix && npm run build:prod && npm run test && npm run docs",
|
|
24
|
+
"release": "./bin/tag-release.sh",
|
|
25
|
+
"clean-publish": "npx clean-publish",
|
|
26
|
+
"coverage": "npm run test:all && jest-coverage-badges --input \"./workdocs/coverage/coverage-summary.json\" --output \"./workdocs/badges\"",
|
|
27
|
+
"docs": "npx rimraf ./docs && mkdir docs && npm run do-install -- better-docs taffydb && gulp docs; npm remove better-docs taffydb"
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"dist/",
|
|
31
|
+
"lib/"
|
|
32
|
+
],
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "git+https://github.com/decaf-ts/injectable-decorators.git"
|
|
36
|
+
},
|
|
37
|
+
"engines": {
|
|
38
|
+
"node": ">=20.0.0",
|
|
39
|
+
"npm": ">=10.0.0"
|
|
40
|
+
},
|
|
41
|
+
"keywords": [
|
|
42
|
+
"typescript",
|
|
43
|
+
"decorators",
|
|
44
|
+
"database",
|
|
45
|
+
"create",
|
|
46
|
+
"transactions",
|
|
47
|
+
"update",
|
|
48
|
+
"read",
|
|
49
|
+
"delete",
|
|
50
|
+
"CRUD",
|
|
51
|
+
"id",
|
|
52
|
+
"timestamp"
|
|
53
|
+
],
|
|
54
|
+
"author": "decaf-ts",
|
|
55
|
+
"license": "MIT",
|
|
56
|
+
"bugs": {
|
|
57
|
+
"url": "https://github.com/decaf-ts/injectable-decorators/issues"
|
|
58
|
+
},
|
|
59
|
+
"homepage": "https://github.com/decaf-ts/injectable-decorators#readme",
|
|
60
|
+
"devDependencies": {
|
|
61
|
+
"@types/jest": "^29.5.12",
|
|
62
|
+
"@typescript-eslint/eslint-plugin": "^7.1.1",
|
|
63
|
+
"clean-publish": "^4.3.0",
|
|
64
|
+
"eslint": "^8.57.0",
|
|
65
|
+
"eslint-config-prettier": "^9.1.0",
|
|
66
|
+
"eslint-plugin-prettier": "^5.1.3",
|
|
67
|
+
"gulp": "^4.0.2",
|
|
68
|
+
"gulp-if": "^3.0.0",
|
|
69
|
+
"gulp-rename": "^2.0.0",
|
|
70
|
+
"gulp-replace": "^1.1.4",
|
|
71
|
+
"gulp-run-command": "^0.0.10",
|
|
72
|
+
"gulp-sourcemaps": "^3.0.0",
|
|
73
|
+
"gulp-typescript": "^6.0.0-alpha.1",
|
|
74
|
+
"gulp-uglify": "^3.0.2",
|
|
75
|
+
"jest": "^29.7.0",
|
|
76
|
+
"jest-coverage-badges": "^1.1.2",
|
|
77
|
+
"jest-junit": "^16.0.0",
|
|
78
|
+
"jsdoc": "^4.0.2",
|
|
79
|
+
"jsdoc-mermaid": "^1.0.0",
|
|
80
|
+
"markdown-include": "^0.4.3",
|
|
81
|
+
"merge-stream": "^2.0.0",
|
|
82
|
+
"nodemon": "^3.1.0",
|
|
83
|
+
"npm-check-updates": "^16.14.15",
|
|
84
|
+
"prettier": "^3.2.5",
|
|
85
|
+
"rimraf": "^5.0.5",
|
|
86
|
+
"ts-jest": "^29.1.2",
|
|
87
|
+
"ts-loader": "^9.5.1",
|
|
88
|
+
"ts-node": "^10.9.2",
|
|
89
|
+
"typescript": "^5.4.2",
|
|
90
|
+
"vinyl-named": "^1.1.0",
|
|
91
|
+
"webpack-stream": "^7.0.0"
|
|
92
|
+
},
|
|
93
|
+
"peerDependencies": {
|
|
94
|
+
"reflect-metadata": "^0.2.1"
|
|
95
|
+
}
|
|
96
|
+
}
|