cnhis-design-vue 3.1.17-beta.0 → 3.1.17-beta.3
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/components/separate.js +1 -1
- package/es/packages/big-table/src/hooks/useSeparateRow.js +2 -2
- package/es/packages/fabric-chart/index.d.ts +2 -0
- package/es/packages/fabric-chart/src/FabricChart.js +20 -5
- package/es/packages/fabric-chart/src/FabricChart.vue.d.ts +2 -0
- package/es/packages/fabric-chart/src/hooks/useCenter.js +19 -18
- 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/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 +115 -1
- package/es/packages/form-config/src/FormConfig.js +11 -17
- package/es/packages/form-config/src/FormConfig.vue.d.ts +115 -1
- package/es/packages/form-config/src/components/CloseButton.js +45 -0
- package/es/packages/form-config/src/components/CloseButton.vue.d.ts +1499 -0
- package/es/packages/form-config/src/components/ComplexNode.js +45 -0
- package/es/packages/form-config/src/components/ComplexNode.vue.d.ts +1661 -0
- package/es/packages/form-config/src/components/DefaultNode.js +54 -0
- package/es/packages/form-config/src/components/DefaultNode.vue.d.ts +1543 -0
- package/es/packages/form-config/src/components/FormConfigCreator.js +3 -1
- package/es/packages/form-config/src/components/FormConfigDragDisplay.js +43 -0
- package/es/packages/form-config/src/components/FormConfigDragDisplay.vue.d.ts +114 -0
- package/es/packages/form-config/src/components/FormConfigEdit.js +1 -0
- package/es/packages/form-config/src/components/FormConfigEdit.vue.d.ts +2 -0
- package/es/packages/form-config/src/constants/index.d.ts +2 -0
- package/es/packages/form-config/src/constants/index.js +5 -2
- package/es/packages/form-config/src/hooks/useConfigurationField.js +9 -9
- package/es/packages/form-config/src/hooks/usePresetRenderer.d.ts +2 -2
- package/es/packages/form-config/src/hooks/usePresetRenderer.js +6 -84
- package/es/packages/form-config/src/hooks/useSortable.js +3 -7
- package/es/packages/form-config/src/types/index.d.ts +2 -1
- package/es/packages/form-config/src/utils/index.d.ts +8 -1
- package/es/packages/form-config/src/utils/index.js +23 -9
- package/es/packages/form-config/style/index.css +26 -5
- package/es/packages/form-render/index.js +1 -1
- package/es/packages/form-render/src/hooks/index.d.ts +1 -1
- package/es/packages/form-render/src/hooks/index.js +1 -1
- 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.js +4 -4
- 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 +1 -5
- package/es/packages/index.css +26 -5
- package/es/packages/index.js +1 -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 +1 -1
- package/es/packages/form-render/src/hooks/useTypeNormalize.d.ts +0 -4
- package/es/packages/form-render/src/hooks/useTypeNormalize.js +0 -46
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isObject } from '@vueuse/core';
|
|
2
|
-
import { pick } from 'lodash-es';
|
|
3
|
-
import { useFormValidator,
|
|
2
|
+
import { cloneDeep, pick } from 'lodash-es';
|
|
3
|
+
import { useFormValidator, useFieldNormalize } from '../../../../packages/form-render';
|
|
4
4
|
import { arrayed, parseNumberFromMaybeString, formRenderLog } from '../utils/index.js';
|
|
5
5
|
import { fieldKeyEscape, createLinebarId } from '../utils/schema.js';
|
|
6
6
|
import { transformDateFormat } from '../utils/business.js';
|
|
@@ -208,12 +208,12 @@ function useFieldListAdaptor(collector) {
|
|
|
208
208
|
properties: schemaAdaptor(fieldList)
|
|
209
209
|
};
|
|
210
210
|
};
|
|
211
|
-
const {
|
|
211
|
+
const { FieldNormalizeWaterfallHook } = useFieldNormalize();
|
|
212
212
|
function schemaAdaptor(fieldList) {
|
|
213
213
|
let prevLinebar = null;
|
|
214
214
|
return fieldList.reduce((fin, cur, idx) => {
|
|
215
215
|
var _a;
|
|
216
|
-
|
|
216
|
+
cur = FieldNormalizeWaterfallHook.call(cloneDeep(cur));
|
|
217
217
|
const obj_type = (_a = cur.validate) == null ? void 0 : _a.obj_type;
|
|
218
218
|
obj_type && collector.collect(obj_type, cur.val_key);
|
|
219
219
|
if (cur.html_type === "LINEBAR") {
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { SyncWaterfallHook } from '../../../../../es/src/utils/tapable';
|
|
2
|
+
import { FieldItem } from '../types';
|
|
3
|
+
export declare function useFieldNormalize(): {
|
|
4
|
+
FieldNormalizeWaterfallHook: SyncWaterfallHook<FieldItem, import("../../../../../es/src/utils/tapable").UnsetAdditionalOptions>;
|
|
5
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { SyncWaterfallHook } from '../../../../src/utils/tapable';
|
|
2
|
+
import { FIELD_BUSINESS_TYPE } from '../../../../packages/form-render/src/constants';
|
|
3
|
+
|
|
4
|
+
function useFieldNormalize() {
|
|
5
|
+
const FieldNormalizeWaterfallHook = new SyncWaterfallHook(["fieldItem"]);
|
|
6
|
+
FieldNormalizeWaterfallHook.tap("__block", (fieldItem) => {
|
|
7
|
+
if (["CHECKBOX_BLOCK", "RADIO_BLOCK"].includes(fieldItem.html_type)) {
|
|
8
|
+
fieldItem.__vertical = true;
|
|
9
|
+
}
|
|
10
|
+
return fieldItem;
|
|
11
|
+
});
|
|
12
|
+
FieldNormalizeWaterfallHook.tap("__line", (fieldItem) => {
|
|
13
|
+
if (["LINE_BREAKS"].includes(fieldItem.html_type)) {
|
|
14
|
+
fieldItem.__line = true;
|
|
15
|
+
fieldItem.is_show = "1";
|
|
16
|
+
}
|
|
17
|
+
return fieldItem;
|
|
18
|
+
});
|
|
19
|
+
FieldNormalizeWaterfallHook.tap("__age", (fieldItem) => {
|
|
20
|
+
if (fieldItem.html_type === "AGE") {
|
|
21
|
+
fieldItem.html_type = "INPUT_NUMBER";
|
|
22
|
+
fieldItem.suffixConfig = [
|
|
23
|
+
{
|
|
24
|
+
validate: { obj_type: FIELD_BUSINESS_TYPE.AGE_UNIT },
|
|
25
|
+
val_key: fieldItem.val_key_unit,
|
|
26
|
+
html_type: "SELECT",
|
|
27
|
+
option: fieldItem.option,
|
|
28
|
+
urlConfig: fieldItem.urlConfig
|
|
29
|
+
}
|
|
30
|
+
];
|
|
31
|
+
}
|
|
32
|
+
return fieldItem;
|
|
33
|
+
});
|
|
34
|
+
const types = [
|
|
35
|
+
[["SEARCH", "PHONE_TYPE", "IDCARD_TYPE"], "SELECT"],
|
|
36
|
+
["DIGITAL", "INPUT_NUMBER"],
|
|
37
|
+
["CHECKBOX_BLOCK", "CHECKBOX"],
|
|
38
|
+
["RADIO_BLOCK", "RADIO"],
|
|
39
|
+
[["DATE-INPUT", "DATETIME-INPUT"], "DATE"],
|
|
40
|
+
["SWITCH_COMPONENT", "SWITCH"],
|
|
41
|
+
["SLIDER_COMPONENT", "SLIDER"],
|
|
42
|
+
["LINE_BREAKS", "LINEBAR"]
|
|
43
|
+
];
|
|
44
|
+
FieldNormalizeWaterfallHook.tap("__normalize", (fieldItem) => {
|
|
45
|
+
types.some(([rule, target]) => {
|
|
46
|
+
const match = Array.isArray(rule) ? rule.includes(fieldItem.html_type) : rule === fieldItem.html_type;
|
|
47
|
+
return match && (fieldItem.html_type = target);
|
|
48
|
+
});
|
|
49
|
+
return fieldItem;
|
|
50
|
+
});
|
|
51
|
+
FieldNormalizeWaterfallHook.tap("__elem_width", (fieldItem) => {
|
|
52
|
+
fieldItem.elem_width = ~~((fieldItem.elem_width || 3) * 2);
|
|
53
|
+
return fieldItem;
|
|
54
|
+
});
|
|
55
|
+
return { FieldNormalizeWaterfallHook };
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export { useFieldNormalize };
|
|
@@ -29,13 +29,9 @@ function useFieldVisitor() {
|
|
|
29
29
|
after.push(...arrayed(field2));
|
|
30
30
|
}
|
|
31
31
|
});
|
|
32
|
-
return fin.concat([...before, current, ...after]
|
|
32
|
+
return fin.concat([...before, current, ...after]);
|
|
33
33
|
}, []);
|
|
34
34
|
}
|
|
35
|
-
function defaultTransfer(field) {
|
|
36
|
-
field.elem_width = ~~((field.elem_width || 3) * 2);
|
|
37
|
-
return field;
|
|
38
|
-
}
|
|
39
35
|
return { traverse };
|
|
40
36
|
}
|
|
41
37
|
|
package/es/packages/index.css
CHANGED
|
@@ -3212,6 +3212,7 @@ body > .vxe-table--tooltip-wrapper {
|
|
|
3212
3212
|
display: flex;
|
|
3213
3213
|
align-items: center;
|
|
3214
3214
|
padding: 8px;
|
|
3215
|
+
cursor: move;
|
|
3215
3216
|
border: 1px dashed #d9d9d9;
|
|
3216
3217
|
box-sizing: border-box;
|
|
3217
3218
|
background-color: #fafafa;
|
|
@@ -3240,8 +3241,8 @@ body > .vxe-table--tooltip-wrapper {
|
|
|
3240
3241
|
height: fit-content;
|
|
3241
3242
|
background: #eeeeee;
|
|
3242
3243
|
display: grid !important;
|
|
3243
|
-
grid-template-columns: repeat(
|
|
3244
|
-
gap: 8px
|
|
3244
|
+
grid-template-columns: repeat(24, minmax(0px, 1fr));
|
|
3245
|
+
gap: 8px;
|
|
3245
3246
|
}
|
|
3246
3247
|
.form-config__displayContentItem {
|
|
3247
3248
|
grid-column: span var(--item-column) / span var(--item-column);
|
|
@@ -3267,6 +3268,9 @@ body > .vxe-table--tooltip-wrapper {
|
|
|
3267
3268
|
overflow-y: auto;
|
|
3268
3269
|
max-height: var(--max-height);
|
|
3269
3270
|
}
|
|
3271
|
+
.form-config__renderer {
|
|
3272
|
+
cursor: move;
|
|
3273
|
+
}
|
|
3270
3274
|
.form-config__renderer--default {
|
|
3271
3275
|
display: flex;
|
|
3272
3276
|
align-items: center;
|
|
@@ -3279,13 +3283,21 @@ body > .vxe-table--tooltip-wrapper {
|
|
|
3279
3283
|
width: 100%;
|
|
3280
3284
|
}
|
|
3281
3285
|
.form-config__renderer--complex {
|
|
3282
|
-
border: 1px dashed
|
|
3286
|
+
border: 1px dashed skyblue;
|
|
3287
|
+
border-radius: 8px;
|
|
3283
3288
|
padding: 8px;
|
|
3284
3289
|
}
|
|
3290
|
+
.form-config__renderer--complexHeader {
|
|
3291
|
+
display: flex;
|
|
3292
|
+
justify-content: center;
|
|
3293
|
+
padding: 8px;
|
|
3294
|
+
margin-top: -8px;
|
|
3295
|
+
position: relative;
|
|
3296
|
+
}
|
|
3285
3297
|
.form-config__renderer--complex--grid {
|
|
3286
3298
|
display: grid !important;
|
|
3287
|
-
grid-template-columns: repeat(
|
|
3288
|
-
gap: 8px
|
|
3299
|
+
grid-template-columns: repeat(24, minmax(0px, 1fr));
|
|
3300
|
+
gap: 8px;
|
|
3289
3301
|
grid-column: span var(--item-column) / span var(--item-column);
|
|
3290
3302
|
}
|
|
3291
3303
|
.form-config__renderer--complex--flex {
|
|
@@ -3312,3 +3324,12 @@ body > .vxe-table--tooltip-wrapper {
|
|
|
3312
3324
|
.form-config .is-choosing-area {
|
|
3313
3325
|
background: #f0f7ff;
|
|
3314
3326
|
}
|
|
3327
|
+
.form-config [is-hovering='true'] > .form-config__renderer--closeButton {
|
|
3328
|
+
visibility: visible;
|
|
3329
|
+
}
|
|
3330
|
+
.form-config .form-config__renderer--closeButton {
|
|
3331
|
+
position: absolute;
|
|
3332
|
+
visibility: hidden;
|
|
3333
|
+
top: 12px;
|
|
3334
|
+
right: 5px;
|
|
3335
|
+
}
|
package/es/packages/index.js
CHANGED
|
@@ -46,7 +46,7 @@ export { useCommonLog } from './form-render/src/hooks/useCommonLog.js';
|
|
|
46
46
|
export { useFormField } from './form-render/src/hooks/useFormField.js';
|
|
47
47
|
export { AsyncQueue, useAsyncQueue } from './form-render/src/hooks/useAsyncQueue.js';
|
|
48
48
|
export { useFieldVisitor } from './form-render/src/hooks/useFieldVisitor.js';
|
|
49
|
-
export {
|
|
49
|
+
export { useFieldNormalize } from './form-render/src/hooks/useFieldNormalize.js';
|
|
50
50
|
export { useFormValidator } from './form-render/src/hooks/useFormValidator.js';
|
|
51
51
|
export { BusinessCollector, useBusinessBinding } from './form-render/src/hooks/useBusinessBinding.js';
|
|
52
52
|
export { ContextCollector, useChangeContext } from './form-render/src/hooks/useChangeContext.js';
|
|
@@ -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 };
|