cnhis-design-vue 3.1.16-beta.9 → 3.1.17-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/packages/big-table/src/BigTable.vue.d.ts +6 -1
- package/es/packages/big-table/src/BigTable.vue_vue_type_script_setup_true_lang.js +2 -2
- package/es/packages/big-table/src/components/edit-form/edit-date.js +13 -3
- package/es/packages/big-table/src/components/edit-form/edit-time.js +1 -0
- package/es/packages/big-table/src/components/separate.js +1 -1
- package/es/packages/big-table/src/hooks/useSeparateRow.js +7 -4
- package/es/packages/button-print/index.d.ts +4 -1
- package/es/packages/button-print/src/ButtonPrint.vue.d.ts +4 -1
- package/es/packages/button-print/src/components/IdentityVerification.js +5 -7
- package/es/packages/button-print/src/components/IdentityVerification.vue.d.ts +4 -1
- package/es/packages/fabric-chart/index.d.ts +2 -0
- package/es/packages/fabric-chart/src/FabricChart.js +21 -6
- package/es/packages/fabric-chart/src/FabricChart.vue.d.ts +2 -0
- package/es/packages/fabric-chart/src/components/PopupTip.js +2 -2
- package/es/packages/fabric-chart/src/hooks/constant.js +1 -1
- package/es/packages/fabric-chart/src/hooks/useCenter.js +30 -20
- package/es/packages/fabric-chart/src/hooks/useLeft.d.ts +3 -1
- package/es/packages/fabric-chart/src/hooks/useLeft.js +30 -12
- package/es/packages/fabric-chart/src/hooks/useOther.js +63 -13
- package/es/packages/fabric-chart/src/hooks/useRight.d.ts +1 -1
- package/es/packages/fabric-chart/src/hooks/useRight.js +11 -69
- package/es/packages/fabric-chart/src/interface.d.ts +3 -0
- package/es/packages/form-config/index.d.ts +14 -9
- package/es/packages/form-config/src/FormConfig.vue.d.ts +14 -9
- package/es/packages/form-config/src/components/FormConfigCreator.js +2 -0
- package/es/packages/form-config/src/components/FormConfigCreator.vue.d.ts +6 -4
- package/es/packages/form-config/src/components/FormConfigEdit.js +1 -0
- package/es/packages/form-config/src/components/FormConfigEdit.vue.d.ts +8 -5
- package/es/packages/form-config/src/constants/index.d.ts +2 -2
- package/es/packages/form-config/src/hooks/useConfigurationField.js +9 -9
- package/es/packages/form-config/src/types/index.d.ts +1 -0
- package/es/packages/form-config/style/index.css +1 -1
- package/es/packages/form-render/index.d.ts +6 -4
- package/es/packages/form-render/index.js +1 -2
- package/es/packages/form-render/src/FormRender.js +8 -9
- package/es/packages/form-render/src/FormRender.vue.d.ts +6 -4
- package/es/packages/form-render/src/components/renderer/{combination/index.d.ts → combination.d.ts} +3 -3
- package/es/packages/form-render/src/components/renderer/combination.js +92 -0
- package/es/packages/form-render/src/components/renderer/date.js +12 -4
- package/es/packages/form-render/src/components/renderer/formItem.js +12 -5
- package/es/packages/form-render/src/components/renderer/index.d.ts +1 -0
- package/es/packages/form-render/src/components/renderer/index.js +2 -1
- package/es/packages/form-render/src/components/renderer/inputGroup.js +1 -1
- package/es/packages/form-render/src/components/renderer/{combination → jsonCombination}/hooks/useDeepValidate.d.ts +0 -0
- package/es/packages/form-render/src/components/renderer/{combination → jsonCombination}/hooks/useDeepValidate.js +0 -0
- package/es/packages/form-render/src/components/renderer/jsonCombination/index.d.ts +44 -0
- package/es/packages/form-render/src/components/renderer/{combination → jsonCombination}/index.js +29 -14
- package/es/packages/form-render/src/components/renderer/select.js +11 -8
- package/es/packages/form-render/src/constants/index.d.ts +2 -2
- package/es/packages/form-render/src/hooks/index.d.ts +1 -2
- package/es/packages/form-render/src/hooks/index.js +1 -2
- package/es/packages/form-render/src/hooks/useAnchor.d.ts +3 -3
- package/es/packages/form-render/src/hooks/useAsyncQueue.d.ts +2 -2
- package/es/packages/form-render/src/hooks/useBusinessBinding.d.ts +5 -6
- package/es/packages/form-render/src/hooks/useBusinessBinding.js +22 -20
- package/es/packages/form-render/src/hooks/useFieldListAdaptor.d.ts +1 -1
- package/es/packages/form-render/src/hooks/useFieldListAdaptor.js +11 -7
- package/es/packages/form-render/src/hooks/useFieldNormalize.d.ts +5 -0
- package/es/packages/form-render/src/hooks/useFieldNormalize.js +58 -0
- package/es/packages/form-render/src/hooks/useFieldVisitor.js +2 -5
- package/es/packages/form-render/src/hooks/useFormRenderLifeCycle.d.ts +4 -4
- package/es/packages/form-render/src/hooks/useFormRequest.d.ts +2 -2
- package/es/packages/form-render/src/types/fieldItem.d.ts +4 -0
- package/es/packages/form-render/src/types/index.d.ts +4 -4
- package/es/packages/form-render/src/utils/dom.d.ts +2 -2
- package/es/packages/form-render/src/utils/index.js +3 -2
- package/es/packages/form-render/src/utils/schema.d.ts +62 -2
- package/es/packages/form-render/src/utils/schema.js +5 -2
- package/es/packages/form-render/style/index.css +11 -8
- package/es/packages/index.css +12 -9
- package/es/packages/index.js +1 -2
- package/es/packages/shortcut-provider/src/hooks/useShortcuts.js +1 -0
- package/es/packages/shortcut-setter/index.d.ts +7 -4
- package/es/packages/shortcut-setter/src/ShortcutSetter.vue.d.ts +7 -4
- package/es/src/types/index.d.ts +2 -2
- package/es/src/utils/index.d.ts +1 -0
- package/es/src/utils/index.js +11 -1
- package/es/src/utils/tapable/AsyncParallelBailHook.d.ts +3 -0
- package/es/src/utils/tapable/AsyncParallelBailHook.js +78 -0
- package/es/src/utils/tapable/AsyncParallelHook.d.ts +3 -0
- package/es/src/utils/tapable/AsyncParallelHook.js +27 -0
- package/es/src/utils/tapable/AsyncSeriesBailHook.d.ts +3 -0
- package/es/src/utils/tapable/AsyncSeriesBailHook.js +33 -0
- package/es/src/utils/tapable/AsyncSeriesHook.d.ts +3 -0
- package/es/src/utils/tapable/AsyncSeriesHook.js +27 -0
- package/es/src/utils/tapable/AsyncSeriesLoopHook.d.ts +3 -0
- package/es/src/utils/tapable/AsyncSeriesLoopHook.js +27 -0
- package/es/src/utils/tapable/AsyncSeriesWaterfallHook.d.ts +3 -0
- package/es/src/utils/tapable/AsyncSeriesWaterfallHook.js +40 -0
- package/es/src/utils/tapable/Hook.d.ts +50 -0
- package/es/src/utils/tapable/Hook.js +140 -0
- package/es/src/utils/tapable/HookCodeFactory.d.ts +58 -0
- package/es/src/utils/tapable/HookCodeFactory.js +444 -0
- package/es/src/utils/tapable/HookMap.d.ts +11 -0
- package/es/src/utils/tapable/HookMap.js +32 -0
- package/es/src/utils/tapable/MultiHook.d.ts +12 -0
- package/es/src/utils/tapable/MultiHook.js +38 -0
- package/es/src/utils/tapable/SyncBailHook.d.ts +3 -0
- package/es/src/utils/tapable/SyncBailHook.js +40 -0
- package/es/src/utils/tapable/SyncHook.d.ts +3 -0
- package/es/src/utils/tapable/SyncHook.js +34 -0
- package/es/src/utils/tapable/SyncLoopHook.d.ts +3 -0
- package/es/src/utils/tapable/SyncLoopHook.js +34 -0
- package/es/src/utils/tapable/SyncWaterfallHook.d.ts +3 -0
- package/es/src/utils/tapable/SyncWaterfallHook.js +48 -0
- package/es/src/utils/tapable/index.d.ts +139 -0
- package/es/src/utils/tapable/index.js +12 -0
- package/package.json +4 -4
- package/es/packages/form-render/src/hooks/useInitialData.d.ts +0 -5
- package/es/packages/form-render/src/hooks/useInitialData.js +0 -16
- package/es/packages/form-render/src/hooks/useTypeNormalize.d.ts +0 -4
- package/es/packages/form-render/src/hooks/useTypeNormalize.js +0 -45
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import Hook from './Hook.js';
|
|
2
|
+
import HookCodeFactory from './HookCodeFactory.js';
|
|
3
|
+
|
|
4
|
+
class AsyncParallelBailHookCodeFactory extends HookCodeFactory {
|
|
5
|
+
content({ onError, onResult, onDone }) {
|
|
6
|
+
let code = "";
|
|
7
|
+
code += `var _results = new Array(${this.options.taps.length});
|
|
8
|
+
`;
|
|
9
|
+
code += "var _checkDone = function() {\n";
|
|
10
|
+
code += "for(var i = 0; i < _results.length; i++) {\n";
|
|
11
|
+
code += "var item = _results[i];\n";
|
|
12
|
+
code += "if(item === undefined) return false;\n";
|
|
13
|
+
code += "if(item.result !== undefined) {\n";
|
|
14
|
+
code += onResult("item.result");
|
|
15
|
+
code += "return true;\n";
|
|
16
|
+
code += "}\n";
|
|
17
|
+
code += "if(item.error) {\n";
|
|
18
|
+
code += onError("item.error");
|
|
19
|
+
code += "return true;\n";
|
|
20
|
+
code += "}\n";
|
|
21
|
+
code += "}\n";
|
|
22
|
+
code += "return false;\n";
|
|
23
|
+
code += "}\n";
|
|
24
|
+
code += this.callTapsParallel({
|
|
25
|
+
onError: (i, err, done, doneBreak) => {
|
|
26
|
+
let code2 = "";
|
|
27
|
+
code2 += `if(${i} < _results.length && ((_results.length = ${i + 1}), (_results[${i}] = { error: ${err} }), _checkDone())) {
|
|
28
|
+
`;
|
|
29
|
+
code2 += doneBreak(true);
|
|
30
|
+
code2 += "} else {\n";
|
|
31
|
+
code2 += done();
|
|
32
|
+
code2 += "}\n";
|
|
33
|
+
return code2;
|
|
34
|
+
},
|
|
35
|
+
onResult: (i, result, done, doneBreak) => {
|
|
36
|
+
let code2 = "";
|
|
37
|
+
code2 += `if(${i} < _results.length && (${result} !== undefined && (_results.length = ${i + 1}), (_results[${i}] = { result: ${result} }), _checkDone())) {
|
|
38
|
+
`;
|
|
39
|
+
code2 += doneBreak(true);
|
|
40
|
+
code2 += "} else {\n";
|
|
41
|
+
code2 += done();
|
|
42
|
+
code2 += "}\n";
|
|
43
|
+
return code2;
|
|
44
|
+
},
|
|
45
|
+
onTap: (i, run, done, doneBreak) => {
|
|
46
|
+
let code2 = "";
|
|
47
|
+
if (i > 0) {
|
|
48
|
+
code2 += `if(${i} >= _results.length) {
|
|
49
|
+
`;
|
|
50
|
+
code2 += done();
|
|
51
|
+
code2 += "} else {\n";
|
|
52
|
+
}
|
|
53
|
+
code2 += run();
|
|
54
|
+
if (i > 0)
|
|
55
|
+
code2 += "}\n";
|
|
56
|
+
return code2;
|
|
57
|
+
},
|
|
58
|
+
onDone
|
|
59
|
+
});
|
|
60
|
+
return code;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
const factory = new AsyncParallelBailHookCodeFactory();
|
|
64
|
+
const COMPILE = function(options) {
|
|
65
|
+
factory.setup(this, options);
|
|
66
|
+
return factory.create(options);
|
|
67
|
+
};
|
|
68
|
+
function AsyncParallelBailHook(args = [], name = void 0) {
|
|
69
|
+
const hook = new Hook(args, name);
|
|
70
|
+
hook.constructor = AsyncParallelBailHook;
|
|
71
|
+
hook.compile = COMPILE;
|
|
72
|
+
hook._call = void 0;
|
|
73
|
+
hook.call = void 0;
|
|
74
|
+
return hook;
|
|
75
|
+
}
|
|
76
|
+
AsyncParallelBailHook.prototype = null;
|
|
77
|
+
|
|
78
|
+
export { AsyncParallelBailHook as default };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import Hook from './Hook.js';
|
|
2
|
+
import HookCodeFactory from './HookCodeFactory.js';
|
|
3
|
+
|
|
4
|
+
class AsyncParallelHookCodeFactory extends HookCodeFactory {
|
|
5
|
+
content({ onError, onDone }) {
|
|
6
|
+
return this.callTapsParallel({
|
|
7
|
+
onError: (i, err, done, doneBreak) => onError(err) + doneBreak(true),
|
|
8
|
+
onDone
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
const factory = new AsyncParallelHookCodeFactory();
|
|
13
|
+
const COMPILE = function(options) {
|
|
14
|
+
factory.setup(this, options);
|
|
15
|
+
return factory.create(options);
|
|
16
|
+
};
|
|
17
|
+
function AsyncParallelHook(args = [], name = void 0) {
|
|
18
|
+
const hook = new Hook(args, name);
|
|
19
|
+
hook.constructor = AsyncParallelHook;
|
|
20
|
+
hook.compile = COMPILE;
|
|
21
|
+
hook._call = void 0;
|
|
22
|
+
hook.call = void 0;
|
|
23
|
+
return hook;
|
|
24
|
+
}
|
|
25
|
+
AsyncParallelHook.prototype = null;
|
|
26
|
+
|
|
27
|
+
export { AsyncParallelHook as default };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import Hook from './Hook.js';
|
|
2
|
+
import HookCodeFactory from './HookCodeFactory.js';
|
|
3
|
+
|
|
4
|
+
class AsyncSeriesBailHookCodeFactory extends HookCodeFactory {
|
|
5
|
+
content({ onError, onResult, resultReturns, onDone }) {
|
|
6
|
+
return this.callTapsSeries({
|
|
7
|
+
onError: (i, err, next, doneBreak) => onError(err) + doneBreak(true),
|
|
8
|
+
onResult: (i, result, next) => `if(${result} !== undefined) {
|
|
9
|
+
${onResult(result)}
|
|
10
|
+
} else {
|
|
11
|
+
${next()}}
|
|
12
|
+
`,
|
|
13
|
+
resultReturns,
|
|
14
|
+
onDone
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
const factory = new AsyncSeriesBailHookCodeFactory();
|
|
19
|
+
const COMPILE = function(options) {
|
|
20
|
+
factory.setup(this, options);
|
|
21
|
+
return factory.create(options);
|
|
22
|
+
};
|
|
23
|
+
function AsyncSeriesBailHook(args = [], name = void 0) {
|
|
24
|
+
const hook = new Hook(args, name);
|
|
25
|
+
hook.constructor = AsyncSeriesBailHook;
|
|
26
|
+
hook.compile = COMPILE;
|
|
27
|
+
hook._call = void 0;
|
|
28
|
+
hook.call = void 0;
|
|
29
|
+
return hook;
|
|
30
|
+
}
|
|
31
|
+
AsyncSeriesBailHook.prototype = null;
|
|
32
|
+
|
|
33
|
+
export { AsyncSeriesBailHook as default };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import Hook from './Hook.js';
|
|
2
|
+
import HookCodeFactory from './HookCodeFactory.js';
|
|
3
|
+
|
|
4
|
+
class AsyncSeriesHookCodeFactory extends HookCodeFactory {
|
|
5
|
+
content({ onError, onDone }) {
|
|
6
|
+
return this.callTapsSeries({
|
|
7
|
+
onError: (i, err, next, doneBreak) => onError(err) + doneBreak(true),
|
|
8
|
+
onDone
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
const factory = new AsyncSeriesHookCodeFactory();
|
|
13
|
+
const COMPILE = function(options) {
|
|
14
|
+
factory.setup(this, options);
|
|
15
|
+
return factory.create(options);
|
|
16
|
+
};
|
|
17
|
+
function AsyncSeriesHook(args = [], name = void 0) {
|
|
18
|
+
const hook = new Hook(args, name);
|
|
19
|
+
hook.constructor = AsyncSeriesHook;
|
|
20
|
+
hook.compile = COMPILE;
|
|
21
|
+
hook._call = void 0;
|
|
22
|
+
hook.call = void 0;
|
|
23
|
+
return hook;
|
|
24
|
+
}
|
|
25
|
+
AsyncSeriesHook.prototype = null;
|
|
26
|
+
|
|
27
|
+
export { AsyncSeriesHook as default };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import Hook from './Hook.js';
|
|
2
|
+
import HookCodeFactory from './HookCodeFactory.js';
|
|
3
|
+
|
|
4
|
+
class AsyncSeriesLoopHookCodeFactory extends HookCodeFactory {
|
|
5
|
+
content({ onError, onDone }) {
|
|
6
|
+
return this.callTapsLooping({
|
|
7
|
+
onError: (i, err, next, doneBreak) => onError(err) + doneBreak(true),
|
|
8
|
+
onDone
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
const factory = new AsyncSeriesLoopHookCodeFactory();
|
|
13
|
+
const COMPILE = function(options) {
|
|
14
|
+
factory.setup(this, options);
|
|
15
|
+
return factory.create(options);
|
|
16
|
+
};
|
|
17
|
+
function AsyncSeriesLoopHook(args = [], name = void 0) {
|
|
18
|
+
const hook = new Hook(args, name);
|
|
19
|
+
hook.constructor = AsyncSeriesLoopHook;
|
|
20
|
+
hook.compile = COMPILE;
|
|
21
|
+
hook._call = void 0;
|
|
22
|
+
hook.call = void 0;
|
|
23
|
+
return hook;
|
|
24
|
+
}
|
|
25
|
+
AsyncSeriesLoopHook.prototype = null;
|
|
26
|
+
|
|
27
|
+
export { AsyncSeriesLoopHook as default };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import Hook from './Hook.js';
|
|
2
|
+
import HookCodeFactory from './HookCodeFactory.js';
|
|
3
|
+
|
|
4
|
+
class AsyncSeriesWaterfallHookCodeFactory extends HookCodeFactory {
|
|
5
|
+
content({ onError, onResult, onDone }) {
|
|
6
|
+
return this.callTapsSeries({
|
|
7
|
+
onError: (i, err, next, doneBreak) => onError(err) + doneBreak(true),
|
|
8
|
+
onResult: (i, result, next) => {
|
|
9
|
+
let code = "";
|
|
10
|
+
code += `if(${result} !== undefined) {
|
|
11
|
+
`;
|
|
12
|
+
code += `${this._args[0]} = ${result};
|
|
13
|
+
`;
|
|
14
|
+
code += `}
|
|
15
|
+
`;
|
|
16
|
+
code += next();
|
|
17
|
+
return code;
|
|
18
|
+
},
|
|
19
|
+
onDone: () => onResult(this._args[0])
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
const factory = new AsyncSeriesWaterfallHookCodeFactory();
|
|
24
|
+
const COMPILE = function(options) {
|
|
25
|
+
factory.setup(this, options);
|
|
26
|
+
return factory.create(options);
|
|
27
|
+
};
|
|
28
|
+
function AsyncSeriesWaterfallHook(args = [], name = void 0) {
|
|
29
|
+
if (args.length < 1)
|
|
30
|
+
throw new Error("Waterfall hooks must have at least one argument");
|
|
31
|
+
const hook = new Hook(args, name);
|
|
32
|
+
hook.constructor = AsyncSeriesWaterfallHook;
|
|
33
|
+
hook.compile = COMPILE;
|
|
34
|
+
hook._call = void 0;
|
|
35
|
+
hook.call = void 0;
|
|
36
|
+
return hook;
|
|
37
|
+
}
|
|
38
|
+
AsyncSeriesWaterfallHook.prototype = null;
|
|
39
|
+
|
|
40
|
+
export { AsyncSeriesWaterfallHook as default };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export default Hook;
|
|
2
|
+
declare class Hook {
|
|
3
|
+
constructor(args?: any[], name?: undefined);
|
|
4
|
+
_args: any[];
|
|
5
|
+
name: any;
|
|
6
|
+
taps: any[];
|
|
7
|
+
interceptors: any[];
|
|
8
|
+
_call: typeof CALL_DELEGATE;
|
|
9
|
+
call: typeof CALL_DELEGATE;
|
|
10
|
+
_callAsync: typeof CALL_ASYNC_DELEGATE;
|
|
11
|
+
callAsync: typeof CALL_ASYNC_DELEGATE;
|
|
12
|
+
_promise: typeof PROMISE_DELEGATE;
|
|
13
|
+
promise: typeof PROMISE_DELEGATE;
|
|
14
|
+
_x: any;
|
|
15
|
+
compile(options: any): void;
|
|
16
|
+
_createCall(type: any): void;
|
|
17
|
+
_tap(type: any, options: any, fn: any): void;
|
|
18
|
+
tap(options: any, fn: any): void;
|
|
19
|
+
tapAsync(options: any, fn: any): void;
|
|
20
|
+
tapPromise(options: any, fn: any): void;
|
|
21
|
+
_runRegisterInterceptors(options: any): any;
|
|
22
|
+
withOptions(options: any): {
|
|
23
|
+
name: any;
|
|
24
|
+
tap: (opt: any, fn: any) => void;
|
|
25
|
+
tapAsync: (opt: any, fn: any) => void;
|
|
26
|
+
tapPromise: (opt: any, fn: any) => void;
|
|
27
|
+
intercept: (interceptor: any) => void;
|
|
28
|
+
isUsed: () => boolean;
|
|
29
|
+
withOptions: (opt: any) => any;
|
|
30
|
+
};
|
|
31
|
+
isUsed(): boolean;
|
|
32
|
+
intercept(interceptor: any): void;
|
|
33
|
+
_resetCompilation(): void;
|
|
34
|
+
_insert(item: any): void;
|
|
35
|
+
}
|
|
36
|
+
declare function CALL_DELEGATE(...args: any[]): any;
|
|
37
|
+
declare class CALL_DELEGATE {
|
|
38
|
+
constructor(...args: any[]);
|
|
39
|
+
call: any;
|
|
40
|
+
}
|
|
41
|
+
declare function CALL_ASYNC_DELEGATE(...args: any[]): any;
|
|
42
|
+
declare class CALL_ASYNC_DELEGATE {
|
|
43
|
+
constructor(...args: any[]);
|
|
44
|
+
callAsync: any;
|
|
45
|
+
}
|
|
46
|
+
declare function PROMISE_DELEGATE(...args: any[]): any;
|
|
47
|
+
declare class PROMISE_DELEGATE {
|
|
48
|
+
constructor(...args: any[]);
|
|
49
|
+
promise: any;
|
|
50
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
function CALL_DELEGATE(...args) {
|
|
2
|
+
this.call = this._createCall("sync");
|
|
3
|
+
return this.call(...args);
|
|
4
|
+
}
|
|
5
|
+
function CALL_ASYNC_DELEGATE(...args) {
|
|
6
|
+
this.callAsync = this._createCall("async");
|
|
7
|
+
return this.callAsync(...args);
|
|
8
|
+
}
|
|
9
|
+
function PROMISE_DELEGATE(...args) {
|
|
10
|
+
this.promise = this._createCall("promise");
|
|
11
|
+
return this.promise(...args);
|
|
12
|
+
}
|
|
13
|
+
class Hook {
|
|
14
|
+
constructor(args = [], name = void 0) {
|
|
15
|
+
this._args = args;
|
|
16
|
+
this.name = name;
|
|
17
|
+
this.taps = [];
|
|
18
|
+
this.interceptors = [];
|
|
19
|
+
this._call = CALL_DELEGATE;
|
|
20
|
+
this.call = CALL_DELEGATE;
|
|
21
|
+
this._callAsync = CALL_ASYNC_DELEGATE;
|
|
22
|
+
this.callAsync = CALL_ASYNC_DELEGATE;
|
|
23
|
+
this._promise = PROMISE_DELEGATE;
|
|
24
|
+
this.promise = PROMISE_DELEGATE;
|
|
25
|
+
this._x = void 0;
|
|
26
|
+
}
|
|
27
|
+
compile(options) {
|
|
28
|
+
throw new Error("Abstract: should be overridden");
|
|
29
|
+
}
|
|
30
|
+
_createCall(type) {
|
|
31
|
+
return this.compile({
|
|
32
|
+
taps: this.taps,
|
|
33
|
+
interceptors: this.interceptors,
|
|
34
|
+
args: this._args,
|
|
35
|
+
type
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
_tap(type, options, fn) {
|
|
39
|
+
if (typeof options === "string") {
|
|
40
|
+
options = {
|
|
41
|
+
name: options.trim()
|
|
42
|
+
};
|
|
43
|
+
} else if (typeof options !== "object" || options === null) {
|
|
44
|
+
throw new Error("Invalid tap options");
|
|
45
|
+
}
|
|
46
|
+
if (typeof options.name !== "string" || options.name === "") {
|
|
47
|
+
throw new Error("Missing name for tap");
|
|
48
|
+
}
|
|
49
|
+
options = Object.assign({ type, fn }, options);
|
|
50
|
+
options = this._runRegisterInterceptors(options);
|
|
51
|
+
this._insert(options);
|
|
52
|
+
}
|
|
53
|
+
tap(options, fn) {
|
|
54
|
+
this._tap("sync", options, fn);
|
|
55
|
+
}
|
|
56
|
+
tapAsync(options, fn) {
|
|
57
|
+
this._tap("async", options, fn);
|
|
58
|
+
}
|
|
59
|
+
tapPromise(options, fn) {
|
|
60
|
+
this._tap("promise", options, fn);
|
|
61
|
+
}
|
|
62
|
+
_runRegisterInterceptors(options) {
|
|
63
|
+
for (const interceptor of this.interceptors) {
|
|
64
|
+
if (interceptor.register) {
|
|
65
|
+
const newOptions = interceptor.register(options);
|
|
66
|
+
if (newOptions !== void 0) {
|
|
67
|
+
options = newOptions;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return options;
|
|
72
|
+
}
|
|
73
|
+
withOptions(options) {
|
|
74
|
+
const mergeOptions = (opt) => Object.assign({}, options, typeof opt === "string" ? { name: opt } : opt);
|
|
75
|
+
return {
|
|
76
|
+
name: this.name,
|
|
77
|
+
tap: (opt, fn) => this.tap(mergeOptions(opt), fn),
|
|
78
|
+
tapAsync: (opt, fn) => this.tapAsync(mergeOptions(opt), fn),
|
|
79
|
+
tapPromise: (opt, fn) => this.tapPromise(mergeOptions(opt), fn),
|
|
80
|
+
intercept: (interceptor) => this.intercept(interceptor),
|
|
81
|
+
isUsed: () => this.isUsed(),
|
|
82
|
+
withOptions: (opt) => this.withOptions(mergeOptions(opt))
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
isUsed() {
|
|
86
|
+
return this.taps.length > 0 || this.interceptors.length > 0;
|
|
87
|
+
}
|
|
88
|
+
intercept(interceptor) {
|
|
89
|
+
this._resetCompilation();
|
|
90
|
+
this.interceptors.push(Object.assign({}, interceptor));
|
|
91
|
+
if (interceptor.register) {
|
|
92
|
+
for (let i = 0; i < this.taps.length; i++) {
|
|
93
|
+
this.taps[i] = interceptor.register(this.taps[i]);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
_resetCompilation() {
|
|
98
|
+
this.call = this._call;
|
|
99
|
+
this.callAsync = this._callAsync;
|
|
100
|
+
this.promise = this._promise;
|
|
101
|
+
}
|
|
102
|
+
_insert(item) {
|
|
103
|
+
this._resetCompilation();
|
|
104
|
+
let before;
|
|
105
|
+
if (typeof item.before === "string") {
|
|
106
|
+
before = /* @__PURE__ */ new Set([item.before]);
|
|
107
|
+
} else if (Array.isArray(item.before)) {
|
|
108
|
+
before = new Set(item.before);
|
|
109
|
+
}
|
|
110
|
+
let stage = 0;
|
|
111
|
+
if (typeof item.stage === "number") {
|
|
112
|
+
stage = item.stage;
|
|
113
|
+
}
|
|
114
|
+
let i = this.taps.length;
|
|
115
|
+
while (i > 0) {
|
|
116
|
+
i--;
|
|
117
|
+
const x = this.taps[i];
|
|
118
|
+
this.taps[i + 1] = x;
|
|
119
|
+
const xStage = x.stage || 0;
|
|
120
|
+
if (before) {
|
|
121
|
+
if (before.has(x.name)) {
|
|
122
|
+
before.delete(x.name);
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
if (before.size > 0) {
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if (xStage > stage) {
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
i++;
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
this.taps[i] = item;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
Object.setPrototypeOf(Hook.prototype, null);
|
|
139
|
+
|
|
140
|
+
export { Hook as default };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export default HookCodeFactory;
|
|
2
|
+
declare class HookCodeFactory {
|
|
3
|
+
constructor(config: any);
|
|
4
|
+
config: any;
|
|
5
|
+
options: {
|
|
6
|
+
type: "sync" | "promise" | "async";
|
|
7
|
+
taps: Array<Tap>;
|
|
8
|
+
interceptors: Array<Interceptor>;
|
|
9
|
+
} | undefined;
|
|
10
|
+
_args: any;
|
|
11
|
+
create(options: any): Function;
|
|
12
|
+
setup(instance: any, options: any): void;
|
|
13
|
+
/**
|
|
14
|
+
* @param {{ type: "sync" | "promise" | "async", taps: Array<Tap>, interceptors: Array<Interceptor> }} options
|
|
15
|
+
*/
|
|
16
|
+
init(options: {
|
|
17
|
+
type: "sync" | "promise" | "async";
|
|
18
|
+
taps: Array<Tap>;
|
|
19
|
+
interceptors: Array<Interceptor>;
|
|
20
|
+
}): void;
|
|
21
|
+
deinit(): void;
|
|
22
|
+
contentWithInterceptors(options: any): any;
|
|
23
|
+
header(): string;
|
|
24
|
+
needContext(): boolean;
|
|
25
|
+
callTap(tapIndex: any, { onError, onResult, onDone, rethrowIfPossible }: {
|
|
26
|
+
onError: any;
|
|
27
|
+
onResult: any;
|
|
28
|
+
onDone: any;
|
|
29
|
+
rethrowIfPossible: any;
|
|
30
|
+
}): string;
|
|
31
|
+
callTapsSeries({ onError, onResult, resultReturns, onDone, doneReturns, rethrowIfPossible }: {
|
|
32
|
+
onError: any;
|
|
33
|
+
onResult: any;
|
|
34
|
+
resultReturns: any;
|
|
35
|
+
onDone: any;
|
|
36
|
+
doneReturns: any;
|
|
37
|
+
rethrowIfPossible: any;
|
|
38
|
+
}): any;
|
|
39
|
+
callTapsLooping({ onError, onDone, rethrowIfPossible }: {
|
|
40
|
+
onError: any;
|
|
41
|
+
onDone: any;
|
|
42
|
+
rethrowIfPossible: any;
|
|
43
|
+
}): any;
|
|
44
|
+
callTapsParallel({ onError, onResult, onDone, rethrowIfPossible, onTap }: {
|
|
45
|
+
onError: any;
|
|
46
|
+
onResult: any;
|
|
47
|
+
onDone: any;
|
|
48
|
+
rethrowIfPossible: any;
|
|
49
|
+
onTap?: ((i: any, run: any) => any) | undefined;
|
|
50
|
+
}): any;
|
|
51
|
+
args({ before, after }?: {
|
|
52
|
+
before: any;
|
|
53
|
+
after: any;
|
|
54
|
+
}): any;
|
|
55
|
+
getTapFn(idx: any): string;
|
|
56
|
+
getTap(idx: any): string;
|
|
57
|
+
getInterceptor(idx: any): string;
|
|
58
|
+
}
|