@leyyo/common 1.0.4 → 1.0.6
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/dist/assertion/common-assertion.d.ts +54 -0
- package/dist/assertion/common-assertion.js +180 -0
- package/dist/assertion/common-assertion.js.map +1 -0
- package/dist/assertion/index-types.d.ts +154 -159
- package/dist/assertion/index-types.js +1 -0
- package/dist/assertion/index-types.js.map +1 -0
- package/dist/assertion/index.d.ts +0 -1
- package/dist/assertion/index.js +1 -1
- package/dist/assertion/index.js.map +1 -0
- package/dist/descriptor/common-descriptor.d.ts +19 -0
- package/dist/descriptor/common-descriptor.js +92 -0
- package/dist/descriptor/common-descriptor.js.map +1 -0
- package/dist/descriptor/index-types.d.ts +21 -0
- package/dist/{literal → descriptor}/index-types.js +1 -0
- package/dist/descriptor/index-types.js.map +1 -0
- package/dist/descriptor/index.d.ts +1 -0
- package/dist/{storage → descriptor}/index.js +1 -1
- package/dist/descriptor/index.js.map +1 -0
- package/dist/developer/common-developer.d.ts +29 -0
- package/dist/developer/common-developer.js +266 -0
- package/dist/developer/common-developer.js.map +1 -0
- package/dist/developer/index-types.d.ts +77 -0
- package/dist/{storage → developer}/index-types.js +1 -0
- package/dist/developer/index-types.js.map +1 -0
- package/dist/developer/index.d.ts +1 -0
- package/dist/developer/index.js +18 -0
- package/dist/developer/index.js.map +1 -0
- package/dist/error/{common-error-impl.d.ts → common-error.d.ts} +5 -5
- package/dist/error/common-error.js +104 -0
- package/dist/error/common-error.js.map +1 -0
- package/dist/error/index-types.d.ts +21 -2
- package/dist/error/index-types.js +1 -0
- package/dist/error/index-types.js.map +1 -0
- package/dist/error/index.d.ts +0 -1
- package/dist/error/index.js +1 -1
- package/dist/error/index.js.map +1 -0
- package/dist/exception/assertion-exception.d.ts +2 -2
- package/dist/exception/assertion-exception.js +3 -2
- package/dist/exception/assertion-exception.js.map +1 -0
- package/dist/exception/caused-exception.d.ts +2 -2
- package/dist/exception/caused-exception.js +3 -2
- package/dist/exception/caused-exception.js.map +1 -0
- package/dist/exception/developer-exception.d.ts +2 -2
- package/dist/exception/developer-exception.js +3 -2
- package/dist/exception/developer-exception.js.map +1 -0
- package/dist/exception/exception.d.ts +7 -5
- package/dist/exception/exception.js +14 -4
- package/dist/exception/exception.js.map +1 -0
- package/dist/exception/index-types.d.ts +1 -1
- package/dist/exception/index-types.js +1 -0
- package/dist/exception/index-types.js.map +1 -0
- package/dist/exception/index.d.ts +1 -0
- package/dist/exception/index.js +2 -0
- package/dist/exception/index.js.map +1 -0
- package/dist/exception/invalid-value-exception.d.ts +5 -0
- package/dist/exception/invalid-value-exception.js +12 -0
- package/dist/exception/invalid-value-exception.js.map +1 -0
- package/dist/exception/multiple-exception.js +1 -0
- package/dist/exception/multiple-exception.js.map +1 -0
- package/dist/fqn/common-fqn.d.ts +20 -0
- package/dist/fqn/common-fqn.js +116 -0
- package/dist/fqn/common-fqn.js.map +1 -0
- package/dist/fqn/index-types.d.ts +14 -5
- package/dist/fqn/index-types.js +1 -0
- package/dist/fqn/index-types.js.map +1 -0
- package/dist/fqn/index.d.ts +0 -1
- package/dist/fqn/index.js +1 -1
- package/dist/fqn/index.js.map +1 -0
- package/dist/hook/{common-hook-impl.d.ts → common-hook.d.ts} +12 -10
- package/dist/hook/{common-hook-impl.js → common-hook.js} +27 -21
- package/dist/hook/common-hook.js.map +1 -0
- package/dist/hook/index-types.d.ts +29 -14
- package/dist/hook/index-types.js +1 -0
- package/dist/hook/index-types.js.map +1 -0
- package/dist/hook/index.d.ts +0 -1
- package/dist/hook/index.js +1 -1
- package/dist/hook/index.js.map +1 -0
- package/dist/index.d.ts +27 -11
- package/dist/index.js +30 -20
- package/dist/index.js.map +1 -0
- package/dist/internal.d.ts +2 -0
- package/dist/internal.js +4 -1
- package/dist/internal.js.map +1 -0
- package/dist/is/{common-is-impl.d.ts → common-is.d.ts} +19 -5
- package/dist/is/common-is.js +136 -0
- package/dist/is/common-is.js.map +1 -0
- package/dist/is/index-types.d.ts +48 -3
- package/dist/is/index-types.js +1 -0
- package/dist/is/index-types.js.map +1 -0
- package/dist/is/index.d.ts +0 -1
- package/dist/is/index.js +1 -1
- package/dist/is/index.js.map +1 -0
- package/dist/leyyo/index-types.d.ts +30 -17
- package/dist/leyyo/index-types.js +1 -0
- package/dist/leyyo/index-types.js.map +1 -0
- package/dist/leyyo/index.d.ts +1 -1
- package/dist/leyyo/index.js +2 -1
- package/dist/leyyo/index.js.map +1 -0
- package/dist/leyyo/leyyo-common-hook.d.ts +10 -0
- package/dist/leyyo/leyyo-common-hook.js +18 -0
- package/dist/leyyo/leyyo-common-hook.js.map +1 -0
- package/dist/leyyo/leyyo.d.ts +35 -0
- package/dist/leyyo/leyyo.js +77 -0
- package/dist/leyyo/leyyo.js.map +1 -0
- package/dist/log/common-log.d.ts +14 -0
- package/dist/log/common-log.js +92 -0
- package/dist/log/common-log.js.map +1 -0
- package/dist/log/index-types.d.ts +57 -3
- package/dist/log/index-types.js +1 -0
- package/dist/log/index-types.js.map +1 -0
- package/dist/log/index.d.ts +2 -2
- package/dist/log/index.js +3 -2
- package/dist/log/index.js.map +1 -0
- package/dist/log/logger-instance.d.ts +31 -0
- package/dist/log/logger-instance.js +114 -0
- package/dist/log/logger-instance.js.map +1 -0
- package/dist/{literal → log}/severity.js +1 -0
- package/dist/log/severity.js.map +1 -0
- package/dist/repo/common-repo.d.ts +44 -0
- package/dist/repo/common-repo.js +180 -0
- package/dist/repo/common-repo.js.map +1 -0
- package/dist/repo/index-types.d.ts +104 -0
- package/dist/{shared/index-aliases.js → repo/index-types.js} +1 -2
- package/dist/repo/index-types.js.map +1 -0
- package/dist/repo/index.d.ts +2 -0
- package/dist/repo/index.js +19 -0
- package/dist/repo/index.js.map +1 -0
- package/dist/repo/repo-type.d.ts +8 -0
- package/dist/repo/repo-type.js +8 -0
- package/dist/repo/repo-type.js.map +1 -0
- package/dist/server.d.ts +1 -0
- package/dist/server.js +5 -0
- package/dist/server.js.map +1 -0
- package/dist/shared/index-types.d.ts +162 -132
- package/dist/shared/index-types.js +2 -1
- package/dist/shared/index-types.js.map +1 -0
- package/dist/shared/index.d.ts +0 -4
- package/dist/shared/index.js +1 -4
- package/dist/shared/index.js.map +1 -0
- package/dist/system/common-system.d.ts +10 -0
- package/dist/system/common-system.js +65 -0
- package/dist/system/common-system.js.map +1 -0
- package/dist/{literal → system}/country-code.js +1 -0
- package/dist/system/country-code.js.map +1 -0
- package/dist/{literal → system}/environment.js +1 -0
- package/dist/system/environment.js.map +1 -0
- package/dist/{literal → system}/http-method.js +1 -0
- package/dist/system/http-method.js.map +1 -0
- package/dist/{literal → system}/http-place.js +1 -0
- package/dist/system/http-place.js.map +1 -0
- package/dist/system/index-types.d.ts +6 -0
- package/dist/system/index-types.js +3 -0
- package/dist/system/index-types.js.map +1 -0
- package/dist/{literal → system}/index.d.ts +1 -8
- package/dist/{literal → system}/index.js +2 -8
- package/dist/system/index.js.map +1 -0
- package/dist/{literal → system}/language-code.js +1 -0
- package/dist/system/language-code.js.map +1 -0
- package/dist/{literal → system}/locale-code.js +1 -0
- package/dist/system/locale-code.js.map +1 -0
- package/dist/{literal → system}/sys-class.js +1 -0
- package/dist/system/sys-class.js.map +1 -0
- package/dist/{literal → system}/sys-function.js +1 -0
- package/dist/system/sys-function.js.map +1 -0
- package/dist/to/common-to.d.ts +45 -0
- package/dist/to/common-to.js +868 -0
- package/dist/to/common-to.js.map +1 -0
- package/dist/to/index-types.d.ts +38 -18
- package/dist/to/index-types.js +1 -0
- package/dist/to/index-types.js.map +1 -0
- package/dist/to/index.d.ts +6 -1
- package/dist/to/index.js +7 -1
- package/dist/to/index.js.map +1 -0
- package/dist/{literal → to}/key-value.js +1 -0
- package/dist/to/key-value.js.map +1 -0
- package/dist/{shared → to}/list.d.ts +1 -0
- package/dist/{shared → to}/list.js +4 -0
- package/dist/to/list.js.map +1 -0
- package/dist/{literal → to}/primitive.js +1 -0
- package/dist/to/primitive.js.map +1 -0
- package/dist/{literal → to}/real-value.js +1 -0
- package/dist/to/real-value.js.map +1 -0
- package/dist/{literal → to}/weak-false.js +1 -0
- package/dist/to/weak-false.js.map +1 -0
- package/dist/{literal → to}/weak-true.js +1 -0
- package/dist/to/weak-true.js.map +1 -0
- package/dist/wrapper/common-wrapper.d.ts +26 -0
- package/dist/wrapper/common-wrapper.js +81 -0
- package/dist/wrapper/common-wrapper.js.map +1 -0
- package/dist/wrapper/index-types.d.ts +29 -0
- package/dist/wrapper/index-types.js +3 -0
- package/dist/wrapper/index-types.js.map +1 -0
- package/dist/wrapper/index.d.ts +2 -0
- package/dist/wrapper/index.js +19 -0
- package/dist/wrapper/index.js.map +1 -0
- package/dist/wrapper/wrap.d.ts +7 -0
- package/dist/wrapper/wrap.js +11 -0
- package/dist/wrapper/wrap.js.map +1 -0
- package/package.json +13 -15
- package/dist/assertion/common-assertion-impl.d.ts +0 -65
- package/dist/assertion/common-assertion-impl.js +0 -248
- package/dist/error/common-error-impl.js +0 -92
- package/dist/fqn/common-fqn-impl.d.ts +0 -18
- package/dist/fqn/common-fqn-impl.js +0 -121
- package/dist/is/common-is-impl.js +0 -91
- package/dist/leyyo/leyyo-impl.d.ts +0 -26
- package/dist/leyyo/leyyo-impl.js +0 -94
- package/dist/literal/index-types.d.ts +0 -6
- package/dist/literal/storage-type.d.ts +0 -8
- package/dist/literal/storage-type.js +0 -7
- package/dist/log/common-log-impl.d.ts +0 -14
- package/dist/log/common-log-impl.js +0 -59
- package/dist/log/logger-impl.d.ts +0 -23
- package/dist/log/logger-impl.js +0 -77
- package/dist/shared/assert.d.ts +0 -6
- package/dist/shared/assert.js +0 -14
- package/dist/shared/index-aliases.d.ts +0 -167
- package/dist/shared/index-constants.d.ts +0 -8
- package/dist/shared/index-constants.js +0 -11
- package/dist/storage/common-storage-impl.d.ts +0 -47
- package/dist/storage/common-storage-impl.js +0 -150
- package/dist/storage/index-types.d.ts +0 -87
- package/dist/storage/index.d.ts +0 -2
- package/dist/to/common-to-impl.d.ts +0 -38
- package/dist/to/common-to-impl.js +0 -553
- /package/dist/{literal → log}/severity.d.ts +0 -0
- /package/dist/{literal → system}/country-code.d.ts +0 -0
- /package/dist/{literal → system}/environment.d.ts +0 -0
- /package/dist/{literal → system}/http-method.d.ts +0 -0
- /package/dist/{literal → system}/http-place.d.ts +0 -0
- /package/dist/{literal → system}/language-code.d.ts +0 -0
- /package/dist/{literal → system}/locale-code.d.ts +0 -0
- /package/dist/{literal → system}/sys-class.d.ts +0 -0
- /package/dist/{literal → system}/sys-function.d.ts +0 -0
- /package/dist/{literal → to}/key-value.d.ts +0 -0
- /package/dist/{literal → to}/primitive.d.ts +0 -0
- /package/dist/{literal → to}/real-value.d.ts +0 -0
- /package/dist/{literal → to}/weak-false.d.ts +0 -0
- /package/dist/{literal → to}/weak-true.d.ts +0 -0
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { Arr,
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
export declare class
|
|
1
|
+
import { Arr, ClassLike, Func } from "../shared";
|
|
2
|
+
import { LeyyoLike } from "../leyyo";
|
|
3
|
+
import { CommonHookLike, CommonHookSecure, HookDefinedProvider, HookDefinedProviderLambda } from "./index-types";
|
|
4
|
+
export declare class CommonHook implements CommonHookLike, CommonHookSecure {
|
|
5
5
|
private _waitingForCallbacks;
|
|
6
6
|
private _attachedCallbacks;
|
|
7
7
|
private _waitingForProviders;
|
|
8
8
|
private _definedProviders;
|
|
9
|
+
private assertion;
|
|
10
|
+
private dev;
|
|
9
11
|
/**
|
|
10
12
|
* Default constructor
|
|
11
13
|
*
|
|
@@ -14,7 +16,7 @@ export declare class CommonHookImpl implements CommonHook, CommonHookSecure {
|
|
|
14
16
|
* - Trigger clear pending operation
|
|
15
17
|
* */
|
|
16
18
|
constructor();
|
|
17
|
-
$init(leyyo:
|
|
19
|
+
$init(leyyo: LeyyoLike): void;
|
|
18
20
|
/**
|
|
19
21
|
* Clear jobs in the queue which channel as pending
|
|
20
22
|
*
|
|
@@ -22,9 +24,9 @@ export declare class CommonHookImpl implements CommonHook, CommonHookSecure {
|
|
|
22
24
|
* */
|
|
23
25
|
private _clearPending;
|
|
24
26
|
get $secure(): CommonHookSecure;
|
|
25
|
-
attachCallback(channel:
|
|
26
|
-
queueForCallback(channel:
|
|
27
|
-
get $back():
|
|
28
|
-
whenProviderDefined<T extends HookDefinedProvider = HookDefinedProvider>(channel:
|
|
29
|
-
defineProvider<T extends HookDefinedProvider = HookDefinedProvider>(channel:
|
|
27
|
+
attachCallback(channel: symbol, fn: Func): void;
|
|
28
|
+
queueForCallback(channel: symbol, ...args: Arr): boolean;
|
|
29
|
+
get $back(): CommonHookLike;
|
|
30
|
+
whenProviderDefined<T extends HookDefinedProvider = HookDefinedProvider>(channel: symbol, consumer: ClassLike, callback: HookDefinedProviderLambda<T>): void;
|
|
31
|
+
defineProvider<T extends HookDefinedProvider = HookDefinedProvider>(channel: symbol, producer: ClassLike, instance: T): void;
|
|
30
32
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.CommonHook = void 0;
|
|
4
|
+
const leyyo_1 = require("../leyyo");
|
|
4
5
|
const internal_1 = require("../internal");
|
|
5
|
-
const exception_1 = require("../exception");
|
|
6
6
|
// noinspection JSUnusedGlobalSymbols
|
|
7
|
-
class
|
|
7
|
+
class CommonHook {
|
|
8
8
|
/**
|
|
9
9
|
* Default constructor
|
|
10
10
|
*
|
|
@@ -17,10 +17,16 @@ class CommonHookImpl {
|
|
|
17
17
|
setTimeout(() => this._clearPending(), 60000);
|
|
18
18
|
}
|
|
19
19
|
$init(leyyo) {
|
|
20
|
-
this._waitingForCallbacks = leyyo.
|
|
21
|
-
this._attachedCallbacks = leyyo.
|
|
22
|
-
this._waitingForProviders = leyyo.
|
|
23
|
-
this._definedProviders = leyyo.
|
|
20
|
+
this._waitingForCallbacks = leyyo.repo.newMap($$waitingForCallbacks);
|
|
21
|
+
this._attachedCallbacks = leyyo.repo.newMap($$attachedCallbacks);
|
|
22
|
+
this._waitingForProviders = leyyo.repo.newMap($$waitingForProviders);
|
|
23
|
+
this._definedProviders = leyyo.repo.newMap($$definedProviders);
|
|
24
|
+
this.assertion = leyyo.assertion;
|
|
25
|
+
this.dev = leyyo.dev;
|
|
26
|
+
leyyo.$secure.$lazyRun(() => {
|
|
27
|
+
leyyo.fqn.register(null, CommonHook, 'class', internal_1.FQN_PCK);
|
|
28
|
+
leyyo.fqn.register(null, leyyo_1.LeyyoCommonHook, 'class', internal_1.FQN_PCK);
|
|
29
|
+
});
|
|
24
30
|
}
|
|
25
31
|
/**
|
|
26
32
|
* Clear jobs in the queue which channel as pending
|
|
@@ -34,16 +40,15 @@ class CommonHookImpl {
|
|
|
34
40
|
continue;
|
|
35
41
|
}
|
|
36
42
|
this._waitingForCallbacks.delete(channel);
|
|
37
|
-
console.log(`hook.cleared.pending => {channel: ${channel}}`);
|
|
43
|
+
console.log(`hook.cleared.pending => {channel: ${channel.description}}`);
|
|
38
44
|
}
|
|
39
45
|
}
|
|
40
46
|
get $secure() {
|
|
41
47
|
return this;
|
|
42
48
|
}
|
|
43
49
|
attachCallback(channel, fn) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
50
|
+
this.assertion.sym(channel, () => this.dev.opt({ field: 'channel', where: 'leyyo.common.CommonHook', method: 'attachCallback' }));
|
|
51
|
+
this.assertion.func(fn, () => this.dev.opt({ field: 'fn', where: 'leyyo.common.CommonHook', method: 'attachCallback' }));
|
|
47
52
|
// callback attached
|
|
48
53
|
this._attachedCallbacks.set(channel, { fn });
|
|
49
54
|
// check waiting records, to be called
|
|
@@ -55,9 +60,7 @@ class CommonHookImpl {
|
|
|
55
60
|
}
|
|
56
61
|
}
|
|
57
62
|
queueForCallback(channel, ...args) {
|
|
58
|
-
|
|
59
|
-
throw new Error(`hook.invalid.channel => {type: ${typeof channel}}`);
|
|
60
|
-
}
|
|
63
|
+
this.assertion.sym(channel, () => this.dev.opt({ field: 'channel', where: 'leyyo.common.CommonHook', method: 'queueForCallback' }));
|
|
61
64
|
// callback already exists
|
|
62
65
|
if (this._attachedCallbacks.has(channel)) {
|
|
63
66
|
const rec = this._attachedCallbacks.get(channel);
|
|
@@ -77,9 +80,8 @@ class CommonHookImpl {
|
|
|
77
80
|
return undefined;
|
|
78
81
|
}
|
|
79
82
|
whenProviderDefined(channel, consumer, callback) {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
+
this.assertion.sym(channel, () => this.dev.opt({ field: 'channel', where: 'leyyo.common.CommonHook', method: 'whenProviderDefined' }));
|
|
84
|
+
this.assertion.func(consumer, () => this.dev.opt({ field: 'consumer', where: 'leyyo.common.CommonHook', method: 'whenProviderDefined' }));
|
|
83
85
|
if (!this._waitingForProviders.has(channel)) {
|
|
84
86
|
this._waitingForProviders.set(channel, []);
|
|
85
87
|
}
|
|
@@ -92,9 +94,8 @@ class CommonHookImpl {
|
|
|
92
94
|
this._waitingForProviders.get(channel).push({ consumer, callback });
|
|
93
95
|
}
|
|
94
96
|
defineProvider(channel, producer, instance) {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
97
|
+
this.assertion.sym(channel, () => this.dev.opt({ field: 'channel', where: 'leyyo.common.CommonHook', method: 'defineProvider' }));
|
|
98
|
+
this.assertion.func(producer, () => this.dev.opt({ field: 'producer', where: 'leyyo.common.CommonHook', method: 'defineProvider' }));
|
|
98
99
|
const ins = Object.assign(Object.assign({}, instance), { producer });
|
|
99
100
|
this._definedProviders.set(channel, ins);
|
|
100
101
|
if (instance.proper) {
|
|
@@ -108,4 +109,9 @@ class CommonHookImpl {
|
|
|
108
109
|
}
|
|
109
110
|
}
|
|
110
111
|
}
|
|
111
|
-
exports.
|
|
112
|
+
exports.CommonHook = CommonHook;
|
|
113
|
+
const $$waitingForCallbacks = Symbol.for(`[${internal_1.FQN_PCK}#hook.waitingForCallbacks]`);
|
|
114
|
+
const $$attachedCallbacks = Symbol.for(`[${internal_1.FQN_PCK}#hook.attachedCallbacks]`);
|
|
115
|
+
const $$waitingForProviders = Symbol.for(`[${internal_1.FQN_PCK}#hook.waitingForProviders]`);
|
|
116
|
+
const $$definedProviders = Symbol.for(`[${internal_1.FQN_PCK}#hook.definedProviders]`);
|
|
117
|
+
//# sourceMappingURL=common-hook.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common-hook.js","sourceRoot":"","sources":["../../src/hook/common-hook.ts"],"names":[],"mappings":";;;AACA,oCAAoD;AACpD,0CAAoC;AAapC,qCAAqC;AACrC,MAAa,UAAU;IASnB;;;;;;SAMK;IACL;QACI,uBAAuB;QACvB,UAAU,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,aAAa,EAAE,EAAE,KAAM,CAAC,CAAC;IACnD,CAAC;IAED,KAAK,CAAC,KAAgB;QAClB,IAAI,CAAC,oBAAoB,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAqB,qBAAqB,CAAC,CAAC;QACzF,IAAI,CAAC,kBAAkB,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAA+B,mBAAmB,CAAC,CAAC;QAC/F,IAAI,CAAC,oBAAoB,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAyC,qBAAqB,CAAC,CAAC;QAC7G,IAAI,CAAC,iBAAiB,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAA+B,kBAAkB,CAAC,CAAC;QAC7F,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC;QACjC,IAAI,CAAC,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC;QAErB,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,EAAE;YACxB,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,kBAAO,CAAC,CAAC;YACvD,KAAK,CAAC,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Secure } from "../shared";
|
|
2
2
|
/**
|
|
3
3
|
* Hook interface, it collects all jobs and fire them when callback is defined
|
|
4
4
|
* */
|
|
5
|
-
export interface
|
|
5
|
+
export interface CommonHookLike extends ShiftSecure<CommonHookSecure> {
|
|
6
6
|
/**
|
|
7
7
|
* Attach a callback
|
|
8
8
|
*
|
|
9
|
-
* @param {
|
|
10
|
-
* @param {
|
|
9
|
+
* @param {symbol} channel
|
|
10
|
+
* @param {Func} fn
|
|
11
11
|
*
|
|
12
12
|
* Notes:
|
|
13
13
|
* - channel should be regular string
|
|
14
14
|
* - After attached, it should call all waiting calls in the queue
|
|
15
15
|
* */
|
|
16
|
-
attachCallback(channel:
|
|
16
|
+
attachCallback(channel: symbol, fn: Func): void;
|
|
17
17
|
/**
|
|
18
18
|
* Add a call into queue, which to be executed by appropriate callback
|
|
19
19
|
*
|
|
20
|
-
* @param {
|
|
20
|
+
* @param {symbol} channel
|
|
21
21
|
* @param {Array<any>} args
|
|
22
22
|
* @returns {boolean} - channel exists?
|
|
23
23
|
*
|
|
24
24
|
* Notes:
|
|
25
25
|
* - channel should be regular string
|
|
26
26
|
* */
|
|
27
|
-
queueForCallback(channel:
|
|
27
|
+
queueForCallback(channel: symbol, ...args: Arr): boolean;
|
|
28
28
|
/**
|
|
29
29
|
* Informs when callback is changed
|
|
30
30
|
*
|
|
31
|
-
* @param {
|
|
32
|
-
* @param {
|
|
31
|
+
* @param {symbol} channel
|
|
32
|
+
* @param {ClassLike} consumer
|
|
33
33
|
* @param {HookDefinedProviderLambda} callback
|
|
34
34
|
*
|
|
35
35
|
* Notes:
|
|
@@ -37,20 +37,35 @@ export interface CommonHook extends ShiftSecure<CommonHookSecure> {
|
|
|
37
37
|
* - callback should be regular function
|
|
38
38
|
* - channel should not be already defined
|
|
39
39
|
* */
|
|
40
|
-
whenProviderDefined<T extends HookDefinedProvider = HookDefinedProvider>(channel:
|
|
40
|
+
whenProviderDefined<T extends HookDefinedProvider = HookDefinedProvider>(channel: symbol, consumer: ClassLike, callback: HookDefinedProviderLambda<T>): void;
|
|
41
41
|
/**
|
|
42
42
|
* Defines a provider to replace temporary providers
|
|
43
43
|
*
|
|
44
|
-
* @param {
|
|
45
|
-
* @param {
|
|
44
|
+
* @param {symbol} channel
|
|
45
|
+
* @param {ClassLike} producer
|
|
46
46
|
* @param {Object} instance
|
|
47
47
|
*
|
|
48
48
|
* Notes:
|
|
49
49
|
* - channel should be regular string
|
|
50
50
|
* */
|
|
51
|
-
defineProvider<T extends HookDefinedProvider = HookDefinedProvider>(channel:
|
|
51
|
+
defineProvider<T extends HookDefinedProvider = HookDefinedProvider>(channel: symbol, producer: ClassLike, instance: T): void;
|
|
52
52
|
}
|
|
53
53
|
/**
|
|
54
54
|
* Secure hook interface
|
|
55
55
|
* */
|
|
56
|
-
export type CommonHookSecure = ShiftMain<
|
|
56
|
+
export type CommonHookSecure = ShiftMain<CommonHookLike> & InitLike;
|
|
57
|
+
export interface HookAttachedCallback {
|
|
58
|
+
initialization?: true;
|
|
59
|
+
fn: Func;
|
|
60
|
+
}
|
|
61
|
+
export interface $HookDefinedProvider extends HookDefinedProvider {
|
|
62
|
+
producer: ClassLike;
|
|
63
|
+
}
|
|
64
|
+
export interface HookDefinedProvider {
|
|
65
|
+
proper: boolean;
|
|
66
|
+
}
|
|
67
|
+
export interface HookWaitingProviderItem {
|
|
68
|
+
consumer: ClassLike;
|
|
69
|
+
callback: HookDefinedProviderLambda;
|
|
70
|
+
}
|
|
71
|
+
export type HookDefinedProviderLambda<T extends HookDefinedProvider = HookDefinedProvider> = (instance: T) => void;
|
package/dist/hook/index-types.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-types.js","sourceRoot":"","sources":["../../src/hook/index-types.ts"],"names":[],"mappings":""}
|
package/dist/hook/index.d.ts
CHANGED
package/dist/hook/index.js
CHANGED
|
@@ -15,4 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./index-types"), exports);
|
|
18
|
-
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hook/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,29 @@
|
|
|
1
|
+
import { LeyyoLike } from "./leyyo";
|
|
2
|
+
export declare const leyyo: LeyyoLike;
|
|
3
|
+
export * from './assertion';
|
|
4
|
+
export * from './developer';
|
|
5
|
+
export * from './error';
|
|
1
6
|
export * from './exception';
|
|
2
|
-
export * from './
|
|
7
|
+
export * from './fqn';
|
|
8
|
+
export * from './hook';
|
|
9
|
+
export * from './is';
|
|
10
|
+
export * from './leyyo';
|
|
11
|
+
export * from './log';
|
|
3
12
|
export * from './shared';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
declare const
|
|
10
|
-
declare const
|
|
11
|
-
declare const
|
|
12
|
-
declare const
|
|
13
|
-
export
|
|
13
|
+
export * from './repo';
|
|
14
|
+
export * from './system';
|
|
15
|
+
export * from './to';
|
|
16
|
+
export * from './wrapper';
|
|
17
|
+
export * from './descriptor';
|
|
18
|
+
export declare const $is: import("./is").CommonIsLike;
|
|
19
|
+
export declare const $hook: import("./hook").CommonHookLike;
|
|
20
|
+
export declare const $assert: import("./assertion").CommonAssertionLike;
|
|
21
|
+
export declare const $repo: import("./repo").CommonRepoLike;
|
|
22
|
+
export declare const $to: import("./to").CommonToLike;
|
|
23
|
+
export declare const $sys: import("./system").CommonSystemLike;
|
|
24
|
+
export declare const $dev: import("./developer").CommonDeveloperLike;
|
|
25
|
+
export declare const $fqn: import("./fqn").CommonFqnLike;
|
|
26
|
+
export declare const $log: import("./log").CommonLogLike;
|
|
27
|
+
export declare const $err: import("./error").CommonErrorLike;
|
|
28
|
+
export declare const $descriptor: import("./descriptor").CommonDescriptorLike;
|
|
29
|
+
export declare const $wrapper: import("./wrapper").CommonWrapperLike;
|
package/dist/index.js
CHANGED
|
@@ -15,25 +15,35 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
16
16
|
};
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports
|
|
18
|
+
exports.$wrapper = exports.$descriptor = exports.$err = exports.$log = exports.$fqn = exports.$dev = exports.$sys = exports.$to = exports.$repo = exports.$assert = exports.$hook = exports.$is = exports.leyyo = void 0;
|
|
19
|
+
const leyyo_1 = require("./leyyo/leyyo");
|
|
20
|
+
exports.leyyo = new leyyo_1.Leyyo();
|
|
21
|
+
__exportStar(require("./assertion"), exports);
|
|
22
|
+
__exportStar(require("./developer"), exports);
|
|
23
|
+
__exportStar(require("./error"), exports);
|
|
19
24
|
__exportStar(require("./exception"), exports);
|
|
20
|
-
__exportStar(require("./
|
|
25
|
+
__exportStar(require("./fqn"), exports);
|
|
26
|
+
__exportStar(require("./hook"), exports);
|
|
27
|
+
__exportStar(require("./is"), exports);
|
|
28
|
+
__exportStar(require("./leyyo"), exports);
|
|
29
|
+
__exportStar(require("./log"), exports);
|
|
21
30
|
__exportStar(require("./shared"), exports);
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
exports
|
|
26
|
-
|
|
27
|
-
exports
|
|
28
|
-
|
|
29
|
-
exports
|
|
30
|
-
|
|
31
|
-
exports
|
|
32
|
-
|
|
33
|
-
exports
|
|
34
|
-
|
|
35
|
-
exports
|
|
36
|
-
|
|
37
|
-
exports
|
|
38
|
-
|
|
39
|
-
|
|
31
|
+
__exportStar(require("./repo"), exports);
|
|
32
|
+
__exportStar(require("./system"), exports);
|
|
33
|
+
__exportStar(require("./to"), exports);
|
|
34
|
+
__exportStar(require("./wrapper"), exports);
|
|
35
|
+
__exportStar(require("./descriptor"), exports);
|
|
36
|
+
exports.$is = exports.leyyo.is;
|
|
37
|
+
exports.$hook = exports.leyyo.hook;
|
|
38
|
+
exports.$assert = exports.leyyo.assertion;
|
|
39
|
+
exports.$repo = exports.leyyo.repo;
|
|
40
|
+
exports.$to = exports.leyyo.to;
|
|
41
|
+
exports.$sys = exports.leyyo.system;
|
|
42
|
+
exports.$dev = exports.leyyo.dev;
|
|
43
|
+
exports.$fqn = exports.leyyo.fqn;
|
|
44
|
+
exports.$log = exports.leyyo.log;
|
|
45
|
+
exports.$err = exports.leyyo.error;
|
|
46
|
+
exports.$descriptor = exports.leyyo.descriptor;
|
|
47
|
+
exports.$wrapper = exports.leyyo.wrapper;
|
|
48
|
+
console.log('1');
|
|
49
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,qCAAqC;;;;;;;;;;;;;;;;;AAGrC,yCAAoC;AAEvB,QAAA,KAAK,GAAc,IAAI,aAAK,EAAE,CAAC;AAE5C,8CAA4B;AAC5B,8CAA4B;AAC5B,0CAAwB;AACxB,8CAA4B;AAC5B,wCAAsB;AACtB,yCAAuB;AACvB,uCAAqB;AACrB,0CAAwB;AACxB,wCAAsB;AACtB,2CAAyB;AACzB,yCAAuB;AACvB,2CAAyB;AACzB,uCAAqB;AACrB,4CAA0B;AAC1B,+CAA6B;AAChB,QAAA,GAAG,GAAG,aAAK,CAAC,EAAE,CAAC;AACf,QAAA,KAAK,GAAG,aAAK,CAAC,IAAI,CAAC;AACnB,QAAA,OAAO,GAAG,aAAK,CAAC,SAAS,CAAC;AAC1B,QAAA,KAAK,GAAG,aAAK,CAAC,IAAI,CAAC;AACnB,QAAA,GAAG,GAAG,aAAK,CAAC,EAAE,CAAC;AACf,QAAA,IAAI,GAAG,aAAK,CAAC,MAAM,CAAC;AACpB,QAAA,IAAI,GAAG,aAAK,CAAC,GAAG,CAAC;AACjB,QAAA,IAAI,GAAG,aAAK,CAAC,GAAG,CAAC;AACjB,QAAA,IAAI,GAAG,aAAK,CAAC,GAAG,CAAC;AACjB,QAAA,IAAI,GAAG,aAAK,CAAC,KAAK,CAAC;AACnB,QAAA,WAAW,GAAG,aAAK,CAAC,UAAU,CAAC;AAC/B,QAAA,QAAQ,GAAG,aAAK,CAAC,OAAO,CAAC;AACtC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC"}
|
package/dist/internal.d.ts
CHANGED
package/dist/internal.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FQN_PCK = void 0;
|
|
3
|
+
exports.$$FqnPending = exports.$$FuncSign = exports.FQN_PCK = void 0;
|
|
4
4
|
exports.FQN_PCK = 'leyyo.common';
|
|
5
|
+
exports.$$FuncSign = Symbol.for(`[${exports.FQN_PCK}#sign]`);
|
|
6
|
+
exports.$$FqnPending = Symbol.for(`[${exports.FQN_PCK}#fqn.pending]`);
|
|
7
|
+
//# sourceMappingURL=internal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":";;;AAAa,QAAA,OAAO,GAAG,cAAc,CAAC;AACzB,QAAA,UAAU,GAAkB,MAAM,CAAC,GAAG,CAAC,IAAI,eAAO,QAAQ,CAAC,CAAC;AAC5D,QAAA,YAAY,GAAkB,MAAM,CAAC,GAAG,CAAC,IAAI,eAAO,eAAe,CAAC,CAAC"}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { CommonIsLike, CommonIsSecure } from "./index-types";
|
|
2
|
+
import { LeyyoLike } from "../leyyo";
|
|
3
|
+
import { BasicType, EnumLiteral, EnumMap } from "../shared";
|
|
3
4
|
/** @inheritDoc */
|
|
4
|
-
export declare class
|
|
5
|
+
export declare class CommonIs implements CommonIsLike, CommonIsSecure {
|
|
6
|
+
private readonly _EMPTY;
|
|
5
7
|
/** @inheritDoc */
|
|
6
8
|
empty(value: any): boolean;
|
|
7
9
|
/** @inheritDoc */
|
|
10
|
+
typeOf(value: any, ...types: Array<BasicType>): boolean;
|
|
11
|
+
/** @inheritDoc */
|
|
8
12
|
primitive(value: any): boolean;
|
|
9
13
|
/** @inheritDoc */
|
|
10
14
|
realValue(value: any): boolean;
|
|
@@ -13,10 +17,16 @@ export declare class CommonIsImpl implements CommonIs, CommonIsSecure {
|
|
|
13
17
|
/** @inheritDoc */
|
|
14
18
|
object(value: any): boolean;
|
|
15
19
|
/** @inheritDoc */
|
|
20
|
+
bareObject(value: any): boolean;
|
|
21
|
+
/** @inheritDoc */
|
|
22
|
+
anotherObject(value: any): boolean;
|
|
23
|
+
/** @inheritDoc */
|
|
16
24
|
array(value: any): boolean;
|
|
17
25
|
/** @inheritDoc */
|
|
18
26
|
func(value: any): boolean;
|
|
19
27
|
/** @inheritDoc */
|
|
28
|
+
sym(value: any): boolean;
|
|
29
|
+
/** @inheritDoc */
|
|
20
30
|
number(value: any): boolean;
|
|
21
31
|
/** @inheritDoc */
|
|
22
32
|
integer(value: any): boolean;
|
|
@@ -29,15 +39,19 @@ export declare class CommonIsImpl implements CommonIs, CommonIsSecure {
|
|
|
29
39
|
/** @inheritDoc */
|
|
30
40
|
clazz(value: any): boolean;
|
|
31
41
|
/** @inheritDoc */
|
|
42
|
+
enumeration(value: unknown, map: EnumMap): boolean;
|
|
43
|
+
/** @inheritDoc */
|
|
44
|
+
literal(value: unknown, items: EnumLiteral): boolean;
|
|
45
|
+
/** @inheritDoc */
|
|
32
46
|
boolean(value: any): boolean;
|
|
33
47
|
/** @inheritDoc */
|
|
34
48
|
true(value: any): boolean;
|
|
35
49
|
/** @inheritDoc */
|
|
36
50
|
false(value: any): boolean;
|
|
37
51
|
/** @inheritDoc */
|
|
38
|
-
$init(leyyo:
|
|
52
|
+
$init(leyyo: LeyyoLike): void;
|
|
39
53
|
/** @inheritDoc */
|
|
40
|
-
get $back():
|
|
54
|
+
get $back(): CommonIsLike;
|
|
41
55
|
/** @inheritDoc */
|
|
42
56
|
get $secure(): CommonIsSecure;
|
|
43
57
|
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CommonIs = void 0;
|
|
4
|
+
const internal_1 = require("../internal");
|
|
5
|
+
const to_1 = require("../to");
|
|
6
|
+
// noinspection JSUnusedGlobalSymbols, JSUnusedLocalSymbols
|
|
7
|
+
/** @inheritDoc */
|
|
8
|
+
class CommonIs {
|
|
9
|
+
constructor() {
|
|
10
|
+
this._EMPTY = [null, undefined];
|
|
11
|
+
// endregion secure
|
|
12
|
+
}
|
|
13
|
+
// region is
|
|
14
|
+
/** @inheritDoc */
|
|
15
|
+
empty(value) {
|
|
16
|
+
return this._EMPTY.includes(value);
|
|
17
|
+
}
|
|
18
|
+
/** @inheritDoc */
|
|
19
|
+
typeOf(value, ...types) {
|
|
20
|
+
return !this._EMPTY.includes(value) && types.includes(typeof value);
|
|
21
|
+
}
|
|
22
|
+
/** @inheritDoc */
|
|
23
|
+
primitive(value) {
|
|
24
|
+
return !this._EMPTY.includes(value) && to_1.PrimitiveItems.includes((typeof value));
|
|
25
|
+
}
|
|
26
|
+
/** @inheritDoc */
|
|
27
|
+
realValue(value) {
|
|
28
|
+
return !this._EMPTY.includes(value) && to_1.RealValueItems.includes((typeof value));
|
|
29
|
+
}
|
|
30
|
+
/** @inheritDoc */
|
|
31
|
+
key(value) {
|
|
32
|
+
return !this._EMPTY.includes(value) && to_1.KeyValueItems.includes((typeof value));
|
|
33
|
+
}
|
|
34
|
+
/** @inheritDoc */
|
|
35
|
+
object(value) {
|
|
36
|
+
return !this._EMPTY.includes(value) && typeof value === 'object' && !Array.isArray(value);
|
|
37
|
+
}
|
|
38
|
+
/** @inheritDoc */
|
|
39
|
+
bareObject(value) {
|
|
40
|
+
return !this._EMPTY.includes(value) && typeof value === 'object' && value.constructor === Object;
|
|
41
|
+
}
|
|
42
|
+
/** @inheritDoc */
|
|
43
|
+
anotherObject(value) {
|
|
44
|
+
return !this._EMPTY.includes(value) && typeof value === 'object' && value.constructor !== Object;
|
|
45
|
+
}
|
|
46
|
+
/** @inheritDoc */
|
|
47
|
+
array(value) {
|
|
48
|
+
return !this._EMPTY.includes(value) && Array.isArray(value);
|
|
49
|
+
}
|
|
50
|
+
/** @inheritDoc */
|
|
51
|
+
func(value) {
|
|
52
|
+
return typeof value === 'function';
|
|
53
|
+
}
|
|
54
|
+
/** @inheritDoc */
|
|
55
|
+
sym(value) {
|
|
56
|
+
return typeof value === 'symbol';
|
|
57
|
+
}
|
|
58
|
+
/** @inheritDoc */
|
|
59
|
+
number(value) {
|
|
60
|
+
return (typeof value === 'number') && !isNaN(value) && isFinite(value);
|
|
61
|
+
}
|
|
62
|
+
/** @inheritDoc */
|
|
63
|
+
integer(value) {
|
|
64
|
+
return this.number(value) && Number.isInteger(value);
|
|
65
|
+
}
|
|
66
|
+
/** @inheritDoc */
|
|
67
|
+
safeInteger(value) {
|
|
68
|
+
return this.number(value) && Number.isSafeInteger(value);
|
|
69
|
+
}
|
|
70
|
+
/** @inheritDoc */
|
|
71
|
+
string(value) {
|
|
72
|
+
return typeof value === 'string';
|
|
73
|
+
}
|
|
74
|
+
/** @inheritDoc */
|
|
75
|
+
text(value) {
|
|
76
|
+
return this.string(value) && value.trim() !== '';
|
|
77
|
+
}
|
|
78
|
+
/** @inheritDoc */
|
|
79
|
+
clazz(value) {
|
|
80
|
+
return this.text(value) || this.func(value) || this.object(value);
|
|
81
|
+
}
|
|
82
|
+
/** @inheritDoc */
|
|
83
|
+
enumeration(value, map) {
|
|
84
|
+
if (!this.bareObject(map)) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
if (to_1.KeyValueItems.includes((typeof value))) {
|
|
88
|
+
return !!map[value];
|
|
89
|
+
}
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
/** @inheritDoc */
|
|
93
|
+
literal(value, items) {
|
|
94
|
+
if (!this.array(items)) {
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
if (to_1.KeyValueItems.includes((typeof value))) {
|
|
98
|
+
return items.includes(value);
|
|
99
|
+
}
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
/** @inheritDoc */
|
|
103
|
+
boolean(value) {
|
|
104
|
+
return (typeof value === 'boolean');
|
|
105
|
+
}
|
|
106
|
+
/** @inheritDoc */
|
|
107
|
+
true(value) {
|
|
108
|
+
return (value === true) ||
|
|
109
|
+
(this.text(value) && to_1.WeakTrueItems.includes(value.toLowerCase())) ||
|
|
110
|
+
(this.number(value) && value > 0);
|
|
111
|
+
}
|
|
112
|
+
/** @inheritDoc */
|
|
113
|
+
false(value) {
|
|
114
|
+
return (value === false) ||
|
|
115
|
+
(this.text(value) && to_1.WeakFalseItems.includes(value.toLowerCase())) ||
|
|
116
|
+
(this.number(value) && value <= 0);
|
|
117
|
+
}
|
|
118
|
+
// endregion is
|
|
119
|
+
// region secure
|
|
120
|
+
/** @inheritDoc */
|
|
121
|
+
$init(leyyo) {
|
|
122
|
+
leyyo.$secure.$lazyRun(() => {
|
|
123
|
+
leyyo.fqn.register(null, CommonIs, 'class', internal_1.FQN_PCK);
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
/** @inheritDoc */
|
|
127
|
+
get $back() {
|
|
128
|
+
return this;
|
|
129
|
+
}
|
|
130
|
+
/** @inheritDoc */
|
|
131
|
+
get $secure() {
|
|
132
|
+
return this;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
exports.CommonIs = CommonIs;
|
|
136
|
+
//# sourceMappingURL=common-is.js.map
|
|
@@ -0,0 +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