@nmtjs/core 0.6.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 +7 -0
- package/README.md +9 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/constants.js +9 -0
- package/dist/lib/constants.js.map +1 -0
- package/dist/lib/container.js +275 -0
- package/dist/lib/container.js.map +1 -0
- package/dist/lib/enums.js +20 -0
- package/dist/lib/enums.js.map +1 -0
- package/dist/lib/hooks.js +37 -0
- package/dist/lib/hooks.js.map +1 -0
- package/dist/lib/injectables.js +6 -0
- package/dist/lib/injectables.js.map +1 -0
- package/dist/lib/logger.js +72 -0
- package/dist/lib/logger.js.map +1 -0
- package/dist/lib/plugin.js +6 -0
- package/dist/lib/plugin.js.map +1 -0
- package/dist/lib/registry.js +25 -0
- package/dist/lib/registry.js.map +1 -0
- package/dist/lib/types.js +1 -0
- package/dist/lib/types.js.map +1 -0
- package/dist/lib/utils/functions.js +32 -0
- package/dist/lib/utils/functions.js.map +1 -0
- package/dist/lib/utils/index.js +3 -0
- package/dist/lib/utils/index.js.map +1 -0
- package/dist/lib/utils/pool.js +100 -0
- package/dist/lib/utils/pool.js.map +1 -0
- package/dist/lib/utils/semaphore.js +52 -0
- package/dist/lib/utils/semaphore.js.map +1 -0
- package/index.ts +11 -0
- package/lib/constants.ts +36 -0
- package/lib/container.ts +482 -0
- package/lib/enums.ts +19 -0
- package/lib/hooks.ts +70 -0
- package/lib/injectables.ts +7 -0
- package/lib/logger.ts +99 -0
- package/lib/plugin.ts +25 -0
- package/lib/registry.ts +44 -0
- package/lib/types.ts +13 -0
- package/lib/utils/functions.ts +31 -0
- package/lib/utils/index.ts +3 -0
- package/lib/utils/pool.ts +111 -0
- package/lib/utils/semaphore.ts +63 -0
- package/package.json +33 -0
- package/tsconfig.json +3 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../lib/utils/functions.ts"],"sourcesContent":["import type { Pattern } from '../types.ts'\n\n/**\n * Very simple pattern matching function.\n */\nexport function match(value: string, pattern: Pattern) {\n if (typeof pattern === 'function') {\n return pattern(value)\n } else if (typeof pattern === 'string') {\n if (pattern === '*' || pattern === '**') {\n return true\n } else if (pattern.at(0) === '*' && pattern.at(-1) === '*') {\n return value.includes(pattern.slice(1, -1))\n } else if (pattern.at(-1) === '*') {\n return value.startsWith(pattern.slice(0, -1))\n } else if (pattern.at(0) === '*') {\n return value.endsWith(pattern.slice(1))\n } else {\n return value === pattern\n }\n } else {\n return pattern.test(value)\n }\n}\n\nexport function isJsFile(name: string) {\n if (name.endsWith('.d.ts')) return false\n const leading = name.split('.').slice(1)\n const ext = leading.join('.')\n return ['js', 'mjs', 'cjs', 'ts', 'mts', 'cts'].includes(ext)\n}\n"],"names":["match","value","pattern","at","includes","slice","startsWith","endsWith","test","isJsFile","name","leading","split","ext","join"],"mappings":"AAKA,OAAO,SAASA,MAAMC,KAAa,EAAEC,OAAgB;IACnD,IAAI,OAAOA,YAAY,YAAY;QACjC,OAAOA,QAAQD;IACjB,OAAO,IAAI,OAAOC,YAAY,UAAU;QACtC,IAAIA,YAAY,OAAOA,YAAY,MAAM;YACvC,OAAO;QACT,OAAO,IAAIA,QAAQC,EAAE,CAAC,OAAO,OAAOD,QAAQC,EAAE,CAAC,CAAC,OAAO,KAAK;YAC1D,OAAOF,MAAMG,QAAQ,CAACF,QAAQG,KAAK,CAAC,GAAG,CAAC;QAC1C,OAAO,IAAIH,QAAQC,EAAE,CAAC,CAAC,OAAO,KAAK;YACjC,OAAOF,MAAMK,UAAU,CAACJ,QAAQG,KAAK,CAAC,GAAG,CAAC;QAC5C,OAAO,IAAIH,QAAQC,EAAE,CAAC,OAAO,KAAK;YAChC,OAAOF,MAAMM,QAAQ,CAACL,QAAQG,KAAK,CAAC;QACtC,OAAO;YACL,OAAOJ,UAAUC;QACnB;IACF,OAAO;QACL,OAAOA,QAAQM,IAAI,CAACP;IACtB;AACF;AAEA,OAAO,SAASQ,SAASC,IAAY;IACnC,IAAIA,KAAKH,QAAQ,CAAC,UAAU,OAAO;IACnC,MAAMI,UAAUD,KAAKE,KAAK,CAAC,KAAKP,KAAK,CAAC;IACtC,MAAMQ,MAAMF,QAAQG,IAAI,CAAC;IACzB,OAAO;QAAC;QAAM;QAAO;QAAO;QAAM;QAAO;KAAM,CAACV,QAAQ,CAACS;AAC3D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../lib/utils/index.ts"],"sourcesContent":["export * from './functions.ts'\nexport * from './pool.ts'\nexport * from './semaphore.ts'\n"],"names":[],"mappings":"AAAA,cAAc,iBAAgB;AAC9B,cAAc,YAAW;AACzB,cAAc,iBAAgB"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
export class PoolError extends Error {
|
|
2
|
+
}
|
|
3
|
+
export class Pool {
|
|
4
|
+
options;
|
|
5
|
+
#items;
|
|
6
|
+
#free;
|
|
7
|
+
#queue;
|
|
8
|
+
#current;
|
|
9
|
+
#size;
|
|
10
|
+
#available;
|
|
11
|
+
constructor(options = {}){
|
|
12
|
+
this.options = options;
|
|
13
|
+
this.#items = [];
|
|
14
|
+
this.#free = [];
|
|
15
|
+
this.#queue = [];
|
|
16
|
+
this.#current = 0;
|
|
17
|
+
this.#size = 0;
|
|
18
|
+
this.#available = 0;
|
|
19
|
+
}
|
|
20
|
+
add(item) {
|
|
21
|
+
if (this.#items.includes(item)) throw new PoolError('Item already exists');
|
|
22
|
+
this.#size++;
|
|
23
|
+
this.#available++;
|
|
24
|
+
this.#items.push(item);
|
|
25
|
+
this.#free.push(true);
|
|
26
|
+
}
|
|
27
|
+
remove(item) {
|
|
28
|
+
if (this.#size === 0) throw new PoolError('Pool is empty');
|
|
29
|
+
const index = this.#items.indexOf(item);
|
|
30
|
+
if (index < 0) throw new PoolError('Item is not in the pool');
|
|
31
|
+
const isCaptured = this.isFree(item);
|
|
32
|
+
if (isCaptured) this.#available--;
|
|
33
|
+
this.#size--;
|
|
34
|
+
this.#current--;
|
|
35
|
+
this.#items.splice(index, 1);
|
|
36
|
+
this.#free.splice(index, 1);
|
|
37
|
+
}
|
|
38
|
+
capture(timeout = this.options.timeout) {
|
|
39
|
+
return this.next(true, timeout);
|
|
40
|
+
}
|
|
41
|
+
async next(exclusive = false, timeout = this.options.timeout) {
|
|
42
|
+
if (this.#size === 0) throw new PoolError('Pool is empty');
|
|
43
|
+
if (this.#available === 0) {
|
|
44
|
+
return new Promise((resolve, reject)=>{
|
|
45
|
+
const waiting = {
|
|
46
|
+
resolve: (item)=>{
|
|
47
|
+
if (exclusive) this.#capture(item);
|
|
48
|
+
resolve(item);
|
|
49
|
+
},
|
|
50
|
+
timer: undefined
|
|
51
|
+
};
|
|
52
|
+
if (timeout) {
|
|
53
|
+
waiting.timer = setTimeout(()=>{
|
|
54
|
+
waiting.resolve = undefined;
|
|
55
|
+
this.#queue.shift();
|
|
56
|
+
reject(new PoolError('Next item timeout'));
|
|
57
|
+
}, timeout);
|
|
58
|
+
}
|
|
59
|
+
this.#queue.push(waiting);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
let item = undefined;
|
|
63
|
+
let free = false;
|
|
64
|
+
do {
|
|
65
|
+
item = this.#items[this.#current];
|
|
66
|
+
free = this.#free[this.#current];
|
|
67
|
+
this.#current++;
|
|
68
|
+
if (this.#current >= this.#size) this.#current = 0;
|
|
69
|
+
}while (typeof item === 'undefined' || !free)
|
|
70
|
+
if (exclusive) this.#capture(item);
|
|
71
|
+
return item;
|
|
72
|
+
}
|
|
73
|
+
release(item) {
|
|
74
|
+
const index = this.#items.indexOf(item);
|
|
75
|
+
if (index < 0) throw new PoolError('Unexpected item');
|
|
76
|
+
if (this.#free[index]) throw new PoolError('Unable to release not captured item');
|
|
77
|
+
this.#free[index] = true;
|
|
78
|
+
this.#available++;
|
|
79
|
+
if (this.#queue.length > 0) {
|
|
80
|
+
const { resolve, timer } = this.#queue.shift();
|
|
81
|
+
clearTimeout(timer);
|
|
82
|
+
if (resolve) setTimeout(resolve, 0, item);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
isFree(item) {
|
|
86
|
+
const index = this.#items.indexOf(item);
|
|
87
|
+
if (index < 0) return false;
|
|
88
|
+
return this.#free[index];
|
|
89
|
+
}
|
|
90
|
+
get items() {
|
|
91
|
+
return [
|
|
92
|
+
...this.#items
|
|
93
|
+
];
|
|
94
|
+
}
|
|
95
|
+
#capture(item) {
|
|
96
|
+
const index = this.#items.indexOf(item);
|
|
97
|
+
this.#free[index] = false;
|
|
98
|
+
this.#available--;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../lib/utils/pool.ts"],"sourcesContent":["import type { Callback } from '@nmtjs/common'\n\ninterface PoolOptions {\n timeout?: number\n}\n\ninterface PoolQueueItem {\n resolve?: Callback\n timer?: ReturnType<typeof setTimeout>\n}\n\nexport class PoolError extends Error {}\n\n// Fixed pool from https://github.com/metarhia/metautil\nexport class Pool<T = unknown> {\n #items: Array<T> = []\n #free: Array<boolean> = []\n #queue: PoolQueueItem[] = []\n #current: number = 0\n #size: number = 0\n #available: number = 0\n\n constructor(private readonly options: PoolOptions = {}) {}\n\n add(item: T) {\n if (this.#items.includes(item)) throw new PoolError('Item already exists')\n this.#size++\n this.#available++\n this.#items.push(item)\n this.#free.push(true)\n }\n\n remove(item: T) {\n if (this.#size === 0) throw new PoolError('Pool is empty')\n const index = this.#items.indexOf(item)\n if (index < 0) throw new PoolError('Item is not in the pool')\n const isCaptured = this.isFree(item)\n if (isCaptured) this.#available--\n this.#size--\n this.#current--\n this.#items.splice(index, 1)\n this.#free.splice(index, 1)\n }\n\n capture(timeout = this.options.timeout) {\n return this.next(true, timeout)\n }\n\n async next(exclusive = false, timeout = this.options.timeout): Promise<T> {\n if (this.#size === 0) throw new PoolError('Pool is empty')\n if (this.#available === 0) {\n return new Promise((resolve, reject) => {\n const waiting: PoolQueueItem = {\n resolve: (item: T) => {\n if (exclusive) this.#capture(item)\n resolve(item)\n },\n timer: undefined,\n }\n if (timeout) {\n waiting.timer = setTimeout(() => {\n waiting.resolve = undefined\n this.#queue.shift()\n reject(new PoolError('Next item timeout'))\n }, timeout)\n }\n this.#queue.push(waiting)\n })\n }\n let item: T | undefined = undefined\n let free = false\n do {\n item = this.#items[this.#current]\n free = this.#free[this.#current]\n this.#current++\n if (this.#current >= this.#size) this.#current = 0\n } while (typeof item === 'undefined' || !free)\n if (exclusive) this.#capture(item)\n return item\n }\n\n release(item: T) {\n const index = this.#items.indexOf(item)\n if (index < 0) throw new PoolError('Unexpected item')\n if (this.#free[index])\n throw new PoolError('Unable to release not captured item')\n this.#free[index] = true\n this.#available++\n if (this.#queue.length > 0) {\n const { resolve, timer } = this.#queue.shift()!\n clearTimeout(timer)\n if (resolve) setTimeout(resolve, 0, item)\n }\n }\n\n isFree(item: T) {\n const index = this.#items.indexOf(item)\n if (index < 0) return false\n return this.#free[index]\n }\n\n get items() {\n return [...this.#items]\n }\n\n #capture(item: T) {\n const index = this.#items.indexOf(item)\n this.#free[index] = false\n this.#available--\n }\n}\n"],"names":["PoolError","Error","Pool","constructor","options","add","item","includes","push","remove","index","indexOf","isCaptured","isFree","splice","capture","timeout","next","exclusive","Promise","resolve","reject","waiting","timer","undefined","setTimeout","shift","free","release","length","clearTimeout","items"],"mappings":"AAWA,OAAO,MAAMA,kBAAkBC;AAAO;AAGtC,OAAO,MAAMC;;IACX,CAAA,KAAM,CAAe;IACrB,CAAA,IAAK,CAAqB;IAC1B,CAAA,KAAM,CAAsB;IAC5B,CAAA,OAAQ,CAAY;IACpB,CAAA,IAAK,CAAY;IACjB,CAAA,SAAU,CAAY;IAEtBC,YAAY,AAAiBC,UAAuB,CAAC,CAAC,CAAE;aAA3BA,UAAAA;aAP7B,CAAA,KAAM,GAAa,EAAE;aACrB,CAAA,IAAK,GAAmB,EAAE;aAC1B,CAAA,KAAM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b,IAAIH,SAASK,WAAWL,SAAS,GAAGd;QACtC;IACF;IAEAO,OAAOP,IAAO,EAAE;QACd,MAAMI,QAAQ,IAAI,CAAC,CAAA,KAAM,CAACC,OAAO,CAACL;QAClC,IAAII,QAAQ,GAAG,OAAO;QACtB,OAAO,IAAI,CAAC,CAAA,IAAK,CAACA,MAAM;IAC1B;IAEA,IAAIqB,QAAQ;QACV,OAAO;eAAI,IAAI,CAAC,CAAA,KAAM;SAAC;IACzB;IAEA,CAAA,OAAQ,CAACzB,IAAO;QACd,MAAMI,QAAQ,IAAI,CAAC,CAAA,KAAM,CAACC,OAAO,CAACL;QAClC,IAAI,CAAC,CAAA,IAAK,CAACI,MAAM,GAAG;QACpB,IAAI,CAAC,CAAA,SAAU;IACjB;AACF"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export class SemaphoreError extends Error {
|
|
2
|
+
}
|
|
3
|
+
export class Semaphore {
|
|
4
|
+
size;
|
|
5
|
+
timeout;
|
|
6
|
+
counter;
|
|
7
|
+
queue;
|
|
8
|
+
constructor(concurrency, size = 0, timeout = 0){
|
|
9
|
+
this.size = size;
|
|
10
|
+
this.timeout = timeout;
|
|
11
|
+
this.queue = [];
|
|
12
|
+
this.counter = concurrency;
|
|
13
|
+
}
|
|
14
|
+
enter() {
|
|
15
|
+
if (this.counter > 0) {
|
|
16
|
+
this.counter--;
|
|
17
|
+
return Promise.resolve();
|
|
18
|
+
} else if (this.queue.length >= this.size) {
|
|
19
|
+
return Promise.reject(new SemaphoreError('Queue is full'));
|
|
20
|
+
} else {
|
|
21
|
+
return new Promise((resolve, reject)=>{
|
|
22
|
+
const waiting = {
|
|
23
|
+
resolve
|
|
24
|
+
};
|
|
25
|
+
waiting.timer = setTimeout(()=>{
|
|
26
|
+
waiting.resolve = undefined;
|
|
27
|
+
this.queue.shift();
|
|
28
|
+
reject(new SemaphoreError('Timeout'));
|
|
29
|
+
}, this.timeout);
|
|
30
|
+
this.queue.push(waiting);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
leave() {
|
|
35
|
+
if (this.queue.length === 0) {
|
|
36
|
+
this.counter++;
|
|
37
|
+
} else {
|
|
38
|
+
const item = this.queue.shift();
|
|
39
|
+
if (item) {
|
|
40
|
+
const { resolve, timer } = item;
|
|
41
|
+
if (timer) clearTimeout(timer);
|
|
42
|
+
if (resolve) setTimeout(resolve, 0);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
get isEmpty() {
|
|
47
|
+
return this.queue.length === 0;
|
|
48
|
+
}
|
|
49
|
+
get queueLength() {
|
|
50
|
+
return this.queue.length;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../lib/utils/semaphore.ts"],"sourcesContent":["import type { Callback } from '@nmtjs/common'\n\ninterface SemaphoreQueueItem {\n resolve?: Callback\n timer?: ReturnType<typeof setTimeout>\n}\n\nexport class SemaphoreError extends Error {}\n\n// Semaphore from https://github.com/metarhia/metautil\nexport class Semaphore {\n private counter: number\n\n private readonly queue: SemaphoreQueueItem[] = []\n\n constructor(\n concurrency: number,\n private readonly size: number = 0,\n private readonly timeout: number = 0,\n ) {\n this.counter = concurrency\n }\n\n enter(): Promise<void> {\n if (this.counter > 0) {\n this.counter--\n return Promise.resolve()\n } else if (this.queue.length >= this.size) {\n return Promise.reject(new SemaphoreError('Queue is full'))\n } else {\n return new Promise((resolve, reject) => {\n const waiting: SemaphoreQueueItem = { resolve }\n waiting.timer = setTimeout(() => {\n waiting.resolve = undefined\n this.queue.shift()\n reject(new SemaphoreError('Timeout'))\n }, this.timeout)\n this.queue.push(waiting)\n })\n }\n }\n\n leave() {\n if (this.queue.length === 0) {\n this.counter++\n } else {\n const item = this.queue.shift()\n if (item) {\n const { resolve, timer } = item\n if (timer) clearTimeout(timer)\n if (resolve) setTimeout(resolve, 0)\n }\n }\n }\n\n get isEmpty() {\n return this.queue.length === 0\n }\n\n get queueLength() {\n return this.queue.length\n }\n}\n"],"names":["SemaphoreError","Error","Semaphore","counter","queue","constructor","concurrency","size","timeout","enter","Promise","resolve","length","reject","waiting","timer","setTimeout","undefined","shift","push","leave","item","clearTimeout","isEmpty","queueLength"],"mappings":"AAOA,OAAO,MAAMA,uBAAuBC;AAAO;AAG3C,OAAO,MAAMC;;;IACHC,QAAe;IAENC,MAAgC;IAEjDC,YACEC,WAAmB,EACnB,AAAiBC,OAAe,CAAC,EACjC,AAAiBC,UAAkB,CAAC,CACpC;aAFiBD,OAAAA;aACAC,UAAAA;aALFJ,QAA8B,EAAE;QAO/C,IAAI,CAACD,OAAO,GAAGG;IACjB;IAEAG,QAAuB;QACrB,IAAI,IAAI,CAACN,OAAO,GAAG,GAAG;YACpB,IAAI,CAACA,OAAO;YACZ,OAAOO,QAAQC,OAAO;QACxB,OAAO,IAAI,IAAI,CAACP,KAAK,CAACQ,MAAM,IAAI,IAAI,CAACL,IAAI,EAAE;YACzC,OAAOG,QAAQG,MAAM,CAAC,IAAIb,eAAe;QAC3C,OAAO;YACL,OAAO,IAAIU,QAAQ,CAACC,SAASE;gBAC3B,MAAMC,UAA8B;oBAAEH;gBAAQ;gBAC9CG,QAAQC,KAAK,GAAGC,WAAW;oBACzBF,QAAQH,OAAO,GAAGM;oBAClB,IAAI,CAACb,KAAK,CAACc,KAAK;oBAChBL,OAAO,IAAIb,eAAe;gBAC5B,GAAG,IAAI,CAACQ,OAAO;gBACf,IAAI,CAACJ,KAAK,CAACe,IAAI,CAACL;YAClB;QACF;IACF;IAEAM,QAAQ;QACN,IAAI,IAAI,CAAChB,KAAK,CAACQ,MAAM,KAAK,GAAG;YAC3B,IAAI,CAACT,OAAO;QACd,OAAO;YACL,MAAMkB,OAAO,IAAI,CAACjB,KAAK,CAACc,KAAK;YAC7B,IAAIG,MAAM;gBACR,MAAM,EAAEV,OAAO,EAAEI,KAAK,EAAE,GAAGM;gBAC3B,IAAIN,OAAOO,aAAaP;gBACxB,IAAIJ,SAASK,WAAWL,SAAS;YACnC;QACF;IACF;IAEA,IAAIY,UAAU;QACZ,OAAO,IAAI,CAACnB,KAAK,CAACQ,MAAM,KAAK;IAC/B;IAEA,IAAIY,cAAc;QAChB,OAAO,IAAI,CAACpB,KAAK,CAACQ,MAAM;IAC1B;AACF"}
|
package/index.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './lib/constants.ts'
|
|
2
|
+
export * from './lib/types.ts'
|
|
3
|
+
export * from './lib/enums.ts'
|
|
4
|
+
export * from './lib/hooks.ts'
|
|
5
|
+
export * from './lib/logger.ts'
|
|
6
|
+
export * from './lib/registry.ts'
|
|
7
|
+
export * from './lib/container.ts'
|
|
8
|
+
export * from './lib/injectables.ts'
|
|
9
|
+
export * from './lib/types.ts'
|
|
10
|
+
export * from './lib/plugin.ts'
|
|
11
|
+
export * from './lib/utils/index.ts'
|
package/lib/constants.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Plugin } from './plugin.ts'
|
|
2
|
+
|
|
3
|
+
export const kOptionalDependency: unique symbol = Symbol.for(
|
|
4
|
+
'neemata:OptionalDependencyKey',
|
|
5
|
+
)
|
|
6
|
+
export type kOptionalDependency = typeof kOptionalDependency
|
|
7
|
+
|
|
8
|
+
export const kInjectable: unique symbol = Symbol.for('neemata:InjectableKey')
|
|
9
|
+
export type kInjectable = typeof kInjectable
|
|
10
|
+
|
|
11
|
+
export const kLazyInjectable: unique symbol = Symbol.for(
|
|
12
|
+
'neemata:LazyInjectableKey',
|
|
13
|
+
)
|
|
14
|
+
export type kLazyInjectable = typeof kLazyInjectable
|
|
15
|
+
|
|
16
|
+
export const kValueInjectable: unique symbol = Symbol.for(
|
|
17
|
+
'neemata:ValueInjectableKey',
|
|
18
|
+
)
|
|
19
|
+
export type kValueInjectable = typeof kValueInjectable
|
|
20
|
+
|
|
21
|
+
export const kFactoryInjectable: unique symbol = Symbol.for(
|
|
22
|
+
'neemata:FactoryInjectableKey',
|
|
23
|
+
)
|
|
24
|
+
export type kFactoryInjectable = typeof kFactoryInjectable
|
|
25
|
+
|
|
26
|
+
export const kProvider: unique symbol = Symbol.for('neemata:ProviderKey')
|
|
27
|
+
export type kProvider = typeof kProvider
|
|
28
|
+
|
|
29
|
+
export const kHookCollection: unique symbol = Symbol.for(
|
|
30
|
+
'neemata:HookCollectionKey',
|
|
31
|
+
)
|
|
32
|
+
export type kHookCollection = typeof kHookCollection
|
|
33
|
+
|
|
34
|
+
export const kPlugin: unique symbol = Symbol.for('neemata:PluginKey')
|
|
35
|
+
export type kPlugin = typeof kPlugin
|
|
36
|
+
export const isPlugin = (value: any): value is Plugin => kPlugin in value
|