cnhis-design-vue 3.1.15-beta.4 → 3.1.15-beta.7
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/bpmn-workflow/src/BpmnWorkflow.js +2 -2
- package/es/packages/bpmn-workflow/src/custom/customModeler/customBpmn/BpmnRenderer.js +8 -8
- package/es/packages/bpmn-workflow/src/custom/customModeler/customBpmn/CustomContextPadProvider.js +2 -2
- package/es/packages/bpmn-workflow/src/custom/customModeler/customBpmn/CustomPalette.js +1 -1
- package/es/packages/bpmn-workflow/src/custom/customModeler/customBpmn/CustomRenderer.js +4 -3
- package/es/packages/bpmn-workflow/src/custom/customModeler/customBpmn/CustomRules.js +2 -2
- package/es/packages/bpmn-workflow/src/custom/customModeler/index.js +1 -1
- package/es/packages/bpmn-workflow/src/custom/customOtherModule/CustomPopupMenu.js +2 -2
- package/es/packages/bpmn-workflow/src/custom/customOtherModule/zoomScroll.js +3 -3
- package/es/packages/field-set/index.d.ts +4365 -0
- package/es/packages/field-set/src/FieldSet.js +53 -54
- package/es/packages/field-set/src/FieldSet.vue.d.ts +4365 -0
- package/es/packages/field-set/style/index.css +0 -9
- package/es/packages/form-render/index.d.ts +24 -3
- package/es/packages/form-render/src/FormRender.js +10 -6
- package/es/packages/form-render/src/FormRender.vue.d.ts +24 -3
- package/es/packages/form-render/src/components/renderer/combination/hooks/useDeepValidate.d.ts +5 -0
- package/es/packages/form-render/src/components/renderer/combination/hooks/useDeepValidate.js +32 -0
- package/es/packages/form-render/src/components/renderer/{combination.d.ts → combination/index.d.ts} +7 -1
- package/es/packages/form-render/src/components/renderer/combination/index.js +157 -0
- package/es/packages/form-render/src/components/renderer/index.js +1 -1
- package/es/packages/form-render/src/components/renderer/radio.js +4 -1
- package/es/packages/form-render/src/components/renderer/select.d.ts +9 -0
- package/es/packages/form-render/src/components/renderer/select.js +6 -2
- package/es/packages/form-render/src/constants/index.d.ts +2 -1
- package/es/packages/form-render/src/hooks/useAnchor.d.ts +7 -6
- package/es/packages/form-render/src/hooks/useAnchor.js +1 -2
- package/es/packages/form-render/src/hooks/useAsyncQueue.d.ts +6 -1
- package/es/packages/form-render/src/hooks/useAsyncQueue.js +12 -3
- package/es/packages/form-render/src/hooks/useFieldListAdaptor.js +2 -4
- package/es/packages/form-render/src/hooks/useFormContext.d.ts +3 -3
- package/es/packages/form-render/src/hooks/useFormContext.js +15 -3
- package/es/packages/form-render/src/hooks/useFormRenderLifeCycle.d.ts +13 -0
- package/es/packages/form-render/src/hooks/useFormRenderLifeCycle.js +10 -0
- package/es/packages/form-render/src/types/fieldItem.d.ts +8 -0
- package/es/packages/form-render/src/types/index.d.ts +25 -1
- package/es/packages/form-render/src/utils/index.d.ts +3 -3
- package/es/packages/form-render/src/utils/index.js +1 -4
- package/es/packages/index.css +1 -10
- package/es/packages/info-header/index.d.ts +1 -3
- package/es/packages/info-header/src/HiddenContent.js +1 -1
- package/es/packages/info-header/src/HiddenContent.vue.d.ts +1 -3
- package/es/packages/info-header/src/InfoHeader.vue.d.ts +1 -3
- package/es/packages/info-header/style/index.css +1 -1
- package/es/packages/shortcut-setter/index.d.ts +25 -4
- package/es/packages/shortcut-setter/src/ShortcutSetter.vue.d.ts +25 -4
- package/es/packages/shortcut-setter/src/ShortcutSetterItem.js +2 -2
- package/es/packages/shortcut-setter/src/ShortcutSetterItem.vue.d.ts +1 -1
- package/global.d.ts +8 -8
- package/package.json +9 -1
- package/es/_virtual/_commonjsHelpers.js +0 -7
- package/es/_virtual/css.escape.js +0 -3
- package/es/_virtual/inherits.js +0 -3
- package/es/_virtual/inherits_browser.js +0 -3
- package/es/node_modules/@formily/path/esm/contexts.js +0 -22
- package/es/node_modules/@formily/path/esm/destructor.js +0 -124
- package/es/node_modules/@formily/path/esm/index.js +0 -579
- package/es/node_modules/@formily/path/esm/matcher.js +0 -199
- package/es/node_modules/@formily/path/esm/parser.js +0 -402
- package/es/node_modules/@formily/path/esm/shared.js +0 -73
- package/es/node_modules/@formily/path/esm/tokenizer.js +0 -287
- package/es/node_modules/@formily/path/esm/tokens.js +0 -240
- package/es/node_modules/@formily/path/esm/types.js +0 -17
- package/es/node_modules/css.escape/css.escape.js +0 -110
- package/es/node_modules/date-fns/esm/_lib/defaultOptions/index.js +0 -6
- package/es/node_modules/date-fns/esm/_lib/getTimezoneOffsetInMilliseconds/index.js +0 -18
- package/es/node_modules/date-fns/esm/_lib/getUTCISOWeek/index.js +0 -17
- package/es/node_modules/date-fns/esm/_lib/getUTCISOWeekYear/index.js +0 -27
- package/es/node_modules/date-fns/esm/_lib/getUTCWeek/index.js +0 -17
- package/es/node_modules/date-fns/esm/_lib/getUTCWeekYear/index.js +0 -38
- package/es/node_modules/date-fns/esm/_lib/requiredArgs/index.js +0 -7
- package/es/node_modules/date-fns/esm/_lib/setUTCDay/index.js +0 -27
- package/es/node_modules/date-fns/esm/_lib/setUTCISODay/index.js +0 -23
- package/es/node_modules/date-fns/esm/_lib/setUTCISOWeek/index.js +0 -15
- package/es/node_modules/date-fns/esm/_lib/setUTCWeek/index.js +0 -15
- package/es/node_modules/date-fns/esm/_lib/startOfUTCISOWeek/index.js +0 -15
- package/es/node_modules/date-fns/esm/_lib/startOfUTCISOWeekYear/index.js +0 -15
- package/es/node_modules/date-fns/esm/_lib/startOfUTCWeek/index.js +0 -25
- package/es/node_modules/date-fns/esm/_lib/startOfUTCWeekYear/index.js +0 -21
- package/es/node_modules/date-fns/esm/_lib/toInteger/index.js +0 -15
- package/es/node_modules/date-fns/esm/compareAsc/index.js +0 -52
- package/es/node_modules/date-fns/esm/constants/index.js +0 -40
- package/es/node_modules/date-fns/esm/differenceInCalendarDays/index.js +0 -49
- package/es/node_modules/date-fns/esm/differenceInCalendarMonths/index.js +0 -35
- package/es/node_modules/date-fns/esm/differenceInCalendarYears/index.js +0 -33
- package/es/node_modules/date-fns/esm/differenceInDays/index.js +0 -86
- package/es/node_modules/date-fns/esm/differenceInMonths/index.js +0 -59
- package/es/node_modules/date-fns/esm/differenceInYears/index.js +0 -43
- package/es/node_modules/date-fns/esm/endOfDay/index.js +0 -30
- package/es/node_modules/date-fns/esm/endOfMonth/index.js +0 -32
- package/es/node_modules/date-fns/esm/isLastDayOfMonth/index.js +0 -30
- package/es/node_modules/date-fns/esm/parse/_lib/Parser.js +0 -32
- package/es/node_modules/date-fns/esm/parse/_lib/Setter.js +0 -37
- package/es/node_modules/date-fns/esm/parse/_lib/constants.js +0 -48
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/AMPMMidnightParser.js +0 -55
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/AMPMParser.js +0 -55
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/DateParser.js +0 -55
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/DayOfYearParser.js +0 -52
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/DayParser.js +0 -80
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/DayPeriodParser.js +0 -56
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/EraParser.js +0 -53
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/ExtendedYearParser.js +0 -30
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/FractionOfSecondParser.js +0 -29
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/Hour0To11Parser.js +0 -48
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/Hour0to23Parser.js +0 -41
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/Hour1To24Parser.js +0 -42
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/Hour1to12Parser.js +0 -50
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/ISODayParser.js +0 -99
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/ISOTimezoneParser.js +0 -46
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/ISOTimezoneWithZParser.js +0 -46
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/ISOWeekParser.js +0 -43
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/ISOWeekYearParser.js +0 -33
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/LocalDayParser.js +0 -96
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/LocalWeekParser.js +0 -43
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/LocalWeekYearParser.js +0 -61
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/MinuteParser.js +0 -41
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/MonthParser.js +0 -80
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/QuarterParser.js +0 -73
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/SecondParser.js +0 -41
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/StandAloneLocalDayParser.js +0 -96
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/StandAloneMonthParser.js +0 -80
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/StandAloneQuarterParser.js +0 -73
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/TimestampMillisecondsParser.js +0 -26
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/TimestampSecondsParser.js +0 -26
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/YearParser.js +0 -66
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/index.js +0 -109
- package/es/node_modules/date-fns/esm/parse/_lib/utils.js +0 -133
- package/es/node_modules/date-fns/esm/startOfDay/index.js +0 -30
- package/es/node_modules/date-fns/esm/toDate/index.js +0 -55
- package/es/node_modules/diagram-js/lib/command/CommandInterceptor.js +0 -139
- package/es/node_modules/diagram-js/lib/draw/BaseRenderer.js +0 -88
- package/es/node_modules/diagram-js/lib/features/popup-menu/PopupMenu.js +0 -591
- package/es/node_modules/diagram-js/lib/features/rules/RuleProvider.js +0 -88
- package/es/node_modules/diagram-js/lib/navigation/movecanvas/MoveCanvas.js +0 -120
- package/es/node_modules/diagram-js/lib/navigation/movecanvas/index.js +0 -8
- package/es/node_modules/diagram-js/lib/navigation/zoomscroll/ZoomScroll.js +0 -227
- package/es/node_modules/diagram-js/lib/navigation/zoomscroll/ZoomUtil.js +0 -24
- package/es/node_modules/diagram-js/lib/util/ClickTrap.js +0 -23
- package/es/node_modules/diagram-js/lib/util/Cursor.js +0 -20
- package/es/node_modules/diagram-js/lib/util/Event.js +0 -22
- package/es/node_modules/diagram-js/lib/util/Math.js +0 -9
- package/es/node_modules/diagram-js/lib/util/Mouse.js +0 -30
- package/es/node_modules/diagram-js/lib/util/Platform.js +0 -5
- package/es/node_modules/diagram-js/lib/util/PositionUtil.js +0 -8
- package/es/node_modules/diagram-js/lib/util/RenderUtil.js +0 -25
- package/es/node_modules/diagram-js/lib/util/SvgTransformUtil.js +0 -48
- package/es/node_modules/ids/dist/index.esm.js +0 -164
- package/es/node_modules/inherits/inherits.js +0 -19
- package/es/node_modules/inherits/inherits_browser.js +0 -38
- package/es/node_modules/inherits-browser/dist/index.es.js +0 -3
- package/es/node_modules/min-dash/dist/index.esm.js +0 -169
- package/es/node_modules/min-dom/dist/index.esm.js +0 -588
- package/es/node_modules/tiny-svg/dist/index.esm.js +0 -525
- package/es/packages/form-render/src/components/renderer/combination.js +0 -171
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import { isObjectPattern, isIdentifier, isArrayPattern, isDestructorExpression } from './types.js';
|
|
2
|
-
import { isNum } from './shared.js';
|
|
3
|
-
|
|
4
|
-
var DestructorCache = new Map();
|
|
5
|
-
var isValid = function (val) { return val !== undefined && val !== null; };
|
|
6
|
-
var getDestructor = function (source) {
|
|
7
|
-
return DestructorCache.get(source);
|
|
8
|
-
};
|
|
9
|
-
var setDestructor = function (source, rules) {
|
|
10
|
-
DestructorCache.set(source, rules);
|
|
11
|
-
};
|
|
12
|
-
var parseDestructorRules = function (node) {
|
|
13
|
-
var rules = [];
|
|
14
|
-
if (isObjectPattern(node)) {
|
|
15
|
-
var index_1 = 0;
|
|
16
|
-
node.properties.forEach(function (child) {
|
|
17
|
-
rules[index_1] = {
|
|
18
|
-
path: [],
|
|
19
|
-
};
|
|
20
|
-
rules[index_1].key = child.key.value;
|
|
21
|
-
rules[index_1].path.push(child.key.value);
|
|
22
|
-
if (isIdentifier(child.value)) {
|
|
23
|
-
rules[index_1].key = child.value.value;
|
|
24
|
-
}
|
|
25
|
-
var basePath = rules[index_1].path;
|
|
26
|
-
var childRules = parseDestructorRules(child.value);
|
|
27
|
-
var k = index_1;
|
|
28
|
-
childRules.forEach(function (rule) {
|
|
29
|
-
if (rules[k]) {
|
|
30
|
-
rules[k].key = rule.key;
|
|
31
|
-
rules[k].path = basePath.concat(rule.path);
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
rules[k] = {
|
|
35
|
-
key: rule.key,
|
|
36
|
-
path: basePath.concat(rule.path),
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
k++;
|
|
40
|
-
});
|
|
41
|
-
if (k > index_1) {
|
|
42
|
-
index_1 = k;
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
index_1++;
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
return rules;
|
|
49
|
-
}
|
|
50
|
-
else if (isArrayPattern(node)) {
|
|
51
|
-
var index_2 = 0;
|
|
52
|
-
node.elements.forEach(function (child, key) {
|
|
53
|
-
rules[index_2] = {
|
|
54
|
-
path: [],
|
|
55
|
-
};
|
|
56
|
-
rules[index_2].key = key;
|
|
57
|
-
rules[index_2].path.push(key);
|
|
58
|
-
if (isIdentifier(child)) {
|
|
59
|
-
rules[index_2].key = child.value;
|
|
60
|
-
}
|
|
61
|
-
var basePath = rules[index_2].path;
|
|
62
|
-
var childRules = parseDestructorRules(child);
|
|
63
|
-
var k = index_2;
|
|
64
|
-
childRules.forEach(function (rule) {
|
|
65
|
-
if (rules[k]) {
|
|
66
|
-
rules[k].key = rule.key;
|
|
67
|
-
rules[k].path = basePath.concat(rule.path);
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
rules[k] = {
|
|
71
|
-
key: rule.key,
|
|
72
|
-
path: basePath.concat(rule.path),
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
k++;
|
|
76
|
-
});
|
|
77
|
-
if (k > index_2) {
|
|
78
|
-
index_2 = k;
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
index_2++;
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
return rules;
|
|
85
|
-
}
|
|
86
|
-
if (isDestructorExpression(node)) {
|
|
87
|
-
return parseDestructorRules(node.value);
|
|
88
|
-
}
|
|
89
|
-
return rules;
|
|
90
|
-
};
|
|
91
|
-
var setInByDestructor = function (source, rules, value, mutators) {
|
|
92
|
-
rules.forEach(function (_a) {
|
|
93
|
-
var key = _a.key, path = _a.path;
|
|
94
|
-
mutators.setIn([key], source, mutators.getIn(path, value));
|
|
95
|
-
});
|
|
96
|
-
};
|
|
97
|
-
var getInByDestructor = function (source, rules, mutators) {
|
|
98
|
-
var response = {};
|
|
99
|
-
if (rules.length) {
|
|
100
|
-
if (isNum(rules[0].path[0])) {
|
|
101
|
-
response = [];
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
source = isValid(source) ? source : {};
|
|
105
|
-
rules.forEach(function (_a) {
|
|
106
|
-
var key = _a.key, path = _a.path;
|
|
107
|
-
mutators.setIn(path, response, source[key]);
|
|
108
|
-
});
|
|
109
|
-
return response;
|
|
110
|
-
};
|
|
111
|
-
var deleteInByDestructor = function (source, rules, mutators) {
|
|
112
|
-
rules.forEach(function (_a) {
|
|
113
|
-
var key = _a.key;
|
|
114
|
-
mutators.deleteIn([key], source);
|
|
115
|
-
});
|
|
116
|
-
};
|
|
117
|
-
var existInByDestructor = function (source, rules, start, mutators) {
|
|
118
|
-
return rules.every(function (_a) {
|
|
119
|
-
var key = _a.key;
|
|
120
|
-
return mutators.existIn([key], source, start);
|
|
121
|
-
});
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
export { deleteInByDestructor, existInByDestructor, getDestructor, getInByDestructor, parseDestructorRules, setDestructor, setInByDestructor };
|
|
@@ -1,579 +0,0 @@
|
|
|
1
|
-
import { Parser } from './parser.js';
|
|
2
|
-
import { isStr, isArr, isRegExp, isFn, isEqual, isNum, isObj } from './shared.js';
|
|
3
|
-
import { getDestructor, getInByDestructor, setInByDestructor, deleteInByDestructor, existInByDestructor } from './destructor.js';
|
|
4
|
-
import { Matcher } from './matcher.js';
|
|
5
|
-
|
|
6
|
-
var __read = (undefined && undefined.__read) || function (o, n) {
|
|
7
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
8
|
-
if (!m) return o;
|
|
9
|
-
var i = m.call(o), r, ar = [], e;
|
|
10
|
-
try {
|
|
11
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
12
|
-
}
|
|
13
|
-
catch (error) { e = { error: error }; }
|
|
14
|
-
finally {
|
|
15
|
-
try {
|
|
16
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
17
|
-
}
|
|
18
|
-
finally { if (e) throw e.error; }
|
|
19
|
-
}
|
|
20
|
-
return ar;
|
|
21
|
-
};
|
|
22
|
-
var __spreadArray = (undefined && undefined.__spreadArray) || function (to, from, pack) {
|
|
23
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
24
|
-
if (ar || !(i in from)) {
|
|
25
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
26
|
-
ar[i] = from[i];
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
30
|
-
};
|
|
31
|
-
var pathCache = new Map();
|
|
32
|
-
var isMatcher = Symbol('PATH_MATCHER');
|
|
33
|
-
var isValid = function (val) { return val !== undefined && val !== null; };
|
|
34
|
-
var isSimplePath = function (val) {
|
|
35
|
-
return val.indexOf('*') === -1 &&
|
|
36
|
-
val.indexOf('~') === -1 &&
|
|
37
|
-
val.indexOf('[') === -1 &&
|
|
38
|
-
val.indexOf(']') === -1 &&
|
|
39
|
-
val.indexOf(',') === -1 &&
|
|
40
|
-
val.indexOf(':') === -1 &&
|
|
41
|
-
val.indexOf(' ') === -1 &&
|
|
42
|
-
val[0] !== '.';
|
|
43
|
-
};
|
|
44
|
-
var isAssignable = function (val) {
|
|
45
|
-
return typeof val === 'object' || typeof val === 'function';
|
|
46
|
-
};
|
|
47
|
-
var isNumberIndex = function (val) {
|
|
48
|
-
return isStr(val) ? /^\d+$/.test(val) : isNum(val);
|
|
49
|
-
};
|
|
50
|
-
var getIn = function (segments, source) {
|
|
51
|
-
for (var i = 0; i < segments.length; i++) {
|
|
52
|
-
var index = segments[i];
|
|
53
|
-
var rules = getDestructor(index);
|
|
54
|
-
if (!rules) {
|
|
55
|
-
if (!isValid(source)) {
|
|
56
|
-
if (i !== segments.length - 1) {
|
|
57
|
-
return source;
|
|
58
|
-
}
|
|
59
|
-
break;
|
|
60
|
-
}
|
|
61
|
-
source = source[index];
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
source = getInByDestructor(source, rules, { setIn: setIn, getIn: getIn });
|
|
65
|
-
break;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
return source;
|
|
69
|
-
};
|
|
70
|
-
var setIn = function (segments, source, value) {
|
|
71
|
-
for (var i = 0; i < segments.length; i++) {
|
|
72
|
-
var index = segments[i];
|
|
73
|
-
var rules = getDestructor(index);
|
|
74
|
-
if (!rules) {
|
|
75
|
-
if (!isValid(source) || !isAssignable(source))
|
|
76
|
-
return;
|
|
77
|
-
if (isArr(source) && !isNumberIndex(index)) {
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
if (!isValid(source[index])) {
|
|
81
|
-
if (value === undefined) {
|
|
82
|
-
if (source[index] === null)
|
|
83
|
-
source[index] = value;
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
if (i < segments.length - 1) {
|
|
87
|
-
source[index] = isNum(segments[i + 1]) ? [] : {};
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
if (i === segments.length - 1) {
|
|
91
|
-
source[index] = value;
|
|
92
|
-
}
|
|
93
|
-
source = source[index];
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
setInByDestructor(source, rules, value, { setIn: setIn, getIn: getIn });
|
|
97
|
-
break;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
var deleteIn = function (segments, source) {
|
|
102
|
-
for (var i = 0; i < segments.length; i++) {
|
|
103
|
-
var index = segments[i];
|
|
104
|
-
var rules = getDestructor(index);
|
|
105
|
-
if (!rules) {
|
|
106
|
-
if (i === segments.length - 1 && isValid(source)) {
|
|
107
|
-
delete source[index];
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
if (!isValid(source) || !isAssignable(source))
|
|
111
|
-
return;
|
|
112
|
-
source = source[index];
|
|
113
|
-
if (!isObj(source)) {
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
deleteInByDestructor(source, rules, {
|
|
119
|
-
setIn: setIn,
|
|
120
|
-
getIn: getIn,
|
|
121
|
-
deleteIn: deleteIn,
|
|
122
|
-
});
|
|
123
|
-
break;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
128
|
-
var existIn = function (segments, source, start) {
|
|
129
|
-
if (start instanceof Path) {
|
|
130
|
-
start = start.length;
|
|
131
|
-
}
|
|
132
|
-
for (var i = start; i < segments.length; i++) {
|
|
133
|
-
var index = segments[i];
|
|
134
|
-
var rules = getDestructor(index);
|
|
135
|
-
if (!rules) {
|
|
136
|
-
if (i === segments.length - 1) {
|
|
137
|
-
return hasOwnProperty.call(source, index);
|
|
138
|
-
}
|
|
139
|
-
if (!isValid(source) || !isAssignable(source))
|
|
140
|
-
return false;
|
|
141
|
-
source = source[index];
|
|
142
|
-
if (!isObj(source)) {
|
|
143
|
-
return false;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
else {
|
|
147
|
-
return existInByDestructor(source, rules, start, {
|
|
148
|
-
setIn: setIn,
|
|
149
|
-
getIn: getIn,
|
|
150
|
-
deleteIn: deleteIn,
|
|
151
|
-
existIn: existIn,
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
};
|
|
156
|
-
var parse = function (pattern, base) {
|
|
157
|
-
if (pattern instanceof Path) {
|
|
158
|
-
return {
|
|
159
|
-
entire: pattern.entire,
|
|
160
|
-
segments: pattern.segments.slice(),
|
|
161
|
-
isRegExp: false,
|
|
162
|
-
haveRelativePattern: pattern.haveRelativePattern,
|
|
163
|
-
isWildMatchPattern: pattern.isWildMatchPattern,
|
|
164
|
-
isMatchPattern: pattern.isMatchPattern,
|
|
165
|
-
haveExcludePattern: pattern.haveExcludePattern,
|
|
166
|
-
tree: pattern.tree,
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
else if (isStr(pattern)) {
|
|
170
|
-
if (!pattern) {
|
|
171
|
-
return {
|
|
172
|
-
entire: '',
|
|
173
|
-
segments: [],
|
|
174
|
-
isRegExp: false,
|
|
175
|
-
isWildMatchPattern: false,
|
|
176
|
-
haveExcludePattern: false,
|
|
177
|
-
isMatchPattern: false,
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
if (isSimplePath(pattern)) {
|
|
181
|
-
return {
|
|
182
|
-
entire: pattern,
|
|
183
|
-
segments: pattern.split('.'),
|
|
184
|
-
isRegExp: false,
|
|
185
|
-
isWildMatchPattern: false,
|
|
186
|
-
haveExcludePattern: false,
|
|
187
|
-
isMatchPattern: false,
|
|
188
|
-
};
|
|
189
|
-
}
|
|
190
|
-
var parser = new Parser(pattern, Path.parse(base));
|
|
191
|
-
var tree = parser.parse();
|
|
192
|
-
if (!parser.isMatchPattern) {
|
|
193
|
-
var segments = parser.data.segments;
|
|
194
|
-
return {
|
|
195
|
-
entire: segments.join('.'),
|
|
196
|
-
segments: segments,
|
|
197
|
-
tree: tree,
|
|
198
|
-
isRegExp: false,
|
|
199
|
-
haveRelativePattern: parser.haveRelativePattern,
|
|
200
|
-
isWildMatchPattern: false,
|
|
201
|
-
haveExcludePattern: false,
|
|
202
|
-
isMatchPattern: false,
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
else {
|
|
206
|
-
return {
|
|
207
|
-
entire: pattern,
|
|
208
|
-
segments: [],
|
|
209
|
-
isRegExp: false,
|
|
210
|
-
haveRelativePattern: false,
|
|
211
|
-
isWildMatchPattern: parser.isWildMatchPattern,
|
|
212
|
-
haveExcludePattern: parser.haveExcludePattern,
|
|
213
|
-
isMatchPattern: true,
|
|
214
|
-
tree: tree,
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
else if (isFn(pattern) && pattern[isMatcher]) {
|
|
219
|
-
return parse(pattern['path']);
|
|
220
|
-
}
|
|
221
|
-
else if (isArr(pattern)) {
|
|
222
|
-
return {
|
|
223
|
-
entire: pattern.join('.'),
|
|
224
|
-
segments: pattern.reduce(function (buf, key) {
|
|
225
|
-
return buf.concat(parseString(key));
|
|
226
|
-
}, []),
|
|
227
|
-
isRegExp: false,
|
|
228
|
-
haveRelativePattern: false,
|
|
229
|
-
isWildMatchPattern: false,
|
|
230
|
-
haveExcludePattern: false,
|
|
231
|
-
isMatchPattern: false,
|
|
232
|
-
};
|
|
233
|
-
}
|
|
234
|
-
else if (isRegExp(pattern)) {
|
|
235
|
-
return {
|
|
236
|
-
entire: pattern,
|
|
237
|
-
segments: [],
|
|
238
|
-
isRegExp: true,
|
|
239
|
-
haveRelativePattern: false,
|
|
240
|
-
isWildMatchPattern: false,
|
|
241
|
-
haveExcludePattern: false,
|
|
242
|
-
isMatchPattern: true,
|
|
243
|
-
};
|
|
244
|
-
}
|
|
245
|
-
else {
|
|
246
|
-
return {
|
|
247
|
-
entire: '',
|
|
248
|
-
isRegExp: false,
|
|
249
|
-
segments: pattern !== undefined ? [pattern] : [],
|
|
250
|
-
haveRelativePattern: false,
|
|
251
|
-
isWildMatchPattern: false,
|
|
252
|
-
haveExcludePattern: false,
|
|
253
|
-
isMatchPattern: false,
|
|
254
|
-
};
|
|
255
|
-
}
|
|
256
|
-
};
|
|
257
|
-
var parseString = function (source) {
|
|
258
|
-
if (isStr(source)) {
|
|
259
|
-
source = source.replace(/\s*/g, '');
|
|
260
|
-
try {
|
|
261
|
-
var _a = parse(source), segments = _a.segments, isMatchPattern = _a.isMatchPattern;
|
|
262
|
-
return !isMatchPattern ? segments : source;
|
|
263
|
-
}
|
|
264
|
-
catch (e) {
|
|
265
|
-
return source;
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
else if (source instanceof Path) {
|
|
269
|
-
return source.segments;
|
|
270
|
-
}
|
|
271
|
-
return source;
|
|
272
|
-
};
|
|
273
|
-
var Path = /** @class */ (function () {
|
|
274
|
-
function Path(input, base) {
|
|
275
|
-
var _this = this;
|
|
276
|
-
this.concat = function () {
|
|
277
|
-
var _a;
|
|
278
|
-
var args = [];
|
|
279
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
280
|
-
args[_i] = arguments[_i];
|
|
281
|
-
}
|
|
282
|
-
if (_this.isMatchPattern || _this.isRegExp) {
|
|
283
|
-
throw new Error("".concat(_this.entire, " cannot be concat"));
|
|
284
|
-
}
|
|
285
|
-
var path = new Path('');
|
|
286
|
-
path.segments = (_a = _this.segments).concat.apply(_a, __spreadArray([], __read(args.map(function (s) { return parseString(s); })), false));
|
|
287
|
-
path.entire = path.segments.join('.');
|
|
288
|
-
return path;
|
|
289
|
-
};
|
|
290
|
-
this.slice = function (start, end) {
|
|
291
|
-
if (_this.isMatchPattern || _this.isRegExp) {
|
|
292
|
-
throw new Error("".concat(_this.entire, " cannot be slice"));
|
|
293
|
-
}
|
|
294
|
-
var path = new Path('');
|
|
295
|
-
path.segments = _this.segments.slice(start, end);
|
|
296
|
-
path.entire = path.segments.join('.');
|
|
297
|
-
return path;
|
|
298
|
-
};
|
|
299
|
-
this.push = function () {
|
|
300
|
-
var items = [];
|
|
301
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
302
|
-
items[_i] = arguments[_i];
|
|
303
|
-
}
|
|
304
|
-
return _this.concat.apply(_this, __spreadArray([], __read(items), false));
|
|
305
|
-
};
|
|
306
|
-
this.pop = function () {
|
|
307
|
-
if (_this.isMatchPattern || _this.isRegExp) {
|
|
308
|
-
throw new Error("".concat(_this.entire, " cannot be pop"));
|
|
309
|
-
}
|
|
310
|
-
return new Path(_this.segments.slice(0, _this.segments.length - 1));
|
|
311
|
-
};
|
|
312
|
-
this.splice = function (start, deleteCount) {
|
|
313
|
-
var items = [];
|
|
314
|
-
for (var _i = 2; _i < arguments.length; _i++) {
|
|
315
|
-
items[_i - 2] = arguments[_i];
|
|
316
|
-
}
|
|
317
|
-
if (_this.isMatchPattern || _this.isRegExp) {
|
|
318
|
-
throw new Error("".concat(_this.entire, " cannot be splice"));
|
|
319
|
-
}
|
|
320
|
-
items = items.reduce(function (buf, item) { return buf.concat(parseString(item)); }, []);
|
|
321
|
-
var segments_ = _this.segments.slice();
|
|
322
|
-
segments_.splice.apply(segments_, __spreadArray([start, deleteCount], __read(items), false));
|
|
323
|
-
return new Path(segments_);
|
|
324
|
-
};
|
|
325
|
-
this.forEach = function (callback) {
|
|
326
|
-
if (_this.isMatchPattern || _this.isRegExp) {
|
|
327
|
-
throw new Error("".concat(_this.entire, " cannot be each"));
|
|
328
|
-
}
|
|
329
|
-
_this.segments.forEach(callback);
|
|
330
|
-
};
|
|
331
|
-
this.map = function (callback) {
|
|
332
|
-
if (_this.isMatchPattern || _this.isRegExp) {
|
|
333
|
-
throw new Error("".concat(_this.entire, " cannot be map"));
|
|
334
|
-
}
|
|
335
|
-
return _this.segments.map(callback);
|
|
336
|
-
};
|
|
337
|
-
this.reduce = function (callback, initial) {
|
|
338
|
-
if (_this.isMatchPattern || _this.isRegExp) {
|
|
339
|
-
throw new Error("".concat(_this.entire, " cannot be reduce"));
|
|
340
|
-
}
|
|
341
|
-
return _this.segments.reduce(callback, initial);
|
|
342
|
-
};
|
|
343
|
-
this.parent = function () {
|
|
344
|
-
return _this.slice(0, _this.length - 1);
|
|
345
|
-
};
|
|
346
|
-
this.includes = function (pattern) {
|
|
347
|
-
var _a = Path.parse(pattern), entire = _a.entire, segments = _a.segments, isMatchPattern = _a.isMatchPattern;
|
|
348
|
-
var cache = _this.includesCache.get(entire);
|
|
349
|
-
if (cache !== undefined)
|
|
350
|
-
return cache;
|
|
351
|
-
var cacheWith = function (value) {
|
|
352
|
-
_this.includesCache.set(entire, value);
|
|
353
|
-
return value;
|
|
354
|
-
};
|
|
355
|
-
if (_this.isMatchPattern) {
|
|
356
|
-
if (!isMatchPattern) {
|
|
357
|
-
return cacheWith(_this.match(segments));
|
|
358
|
-
}
|
|
359
|
-
else {
|
|
360
|
-
throw new Error("".concat(_this.entire, " cannot be used to match ").concat(entire));
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
if (isMatchPattern) {
|
|
364
|
-
throw new Error("".concat(_this.entire, " cannot be used to match ").concat(entire));
|
|
365
|
-
}
|
|
366
|
-
if (segments.length > _this.segments.length)
|
|
367
|
-
return cacheWith(false);
|
|
368
|
-
for (var i = 0; i < segments.length; i++) {
|
|
369
|
-
if (!isEqual(String(segments[i]), String(_this.segments[i]))) {
|
|
370
|
-
return cacheWith(false);
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
return cacheWith(true);
|
|
374
|
-
};
|
|
375
|
-
this.transform = function (regexp, callback) {
|
|
376
|
-
if (!isFn(callback))
|
|
377
|
-
return '';
|
|
378
|
-
if (_this.isMatchPattern) {
|
|
379
|
-
throw new Error("".concat(_this.entire, " cannot be transformed"));
|
|
380
|
-
}
|
|
381
|
-
var args = _this.segments.reduce(function (buf, key) {
|
|
382
|
-
return new RegExp(regexp).test(key) ? buf.concat(key) : buf;
|
|
383
|
-
}, []);
|
|
384
|
-
return callback.apply(void 0, __spreadArray([], __read(args), false));
|
|
385
|
-
};
|
|
386
|
-
this.match = function (pattern) {
|
|
387
|
-
var _a, _b;
|
|
388
|
-
var path = Path.parse(pattern);
|
|
389
|
-
var cache = _this.matchCache.get(path.entire);
|
|
390
|
-
if (cache !== undefined) {
|
|
391
|
-
if (cache.record && cache.record.score !== undefined) {
|
|
392
|
-
_this.matchScore = cache.record.score;
|
|
393
|
-
}
|
|
394
|
-
return cache.matched;
|
|
395
|
-
}
|
|
396
|
-
var cacheWith = function (value) {
|
|
397
|
-
_this.matchCache.set(path.entire, value);
|
|
398
|
-
return value;
|
|
399
|
-
};
|
|
400
|
-
if (path.isMatchPattern) {
|
|
401
|
-
if (_this.isMatchPattern) {
|
|
402
|
-
throw new Error("".concat(path.entire, " cannot match ").concat(_this.entire));
|
|
403
|
-
}
|
|
404
|
-
else {
|
|
405
|
-
_this.matchScore = 0;
|
|
406
|
-
return cacheWith(path.match(_this.segments));
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
else {
|
|
410
|
-
if (_this.isMatchPattern) {
|
|
411
|
-
if (_this.isRegExp) {
|
|
412
|
-
try {
|
|
413
|
-
return (_b = (_a = _this['entire']) === null || _a === void 0 ? void 0 : _a['test']) === null || _b === void 0 ? void 0 : _b.call(_a, path.entire);
|
|
414
|
-
}
|
|
415
|
-
finally {
|
|
416
|
-
_this.entire.lastIndex = 0;
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
var record = {
|
|
420
|
-
score: 0,
|
|
421
|
-
};
|
|
422
|
-
var result = cacheWith(new Matcher(_this.tree, record).match(path.segments));
|
|
423
|
-
_this.matchScore = record.score;
|
|
424
|
-
return result.matched;
|
|
425
|
-
}
|
|
426
|
-
else {
|
|
427
|
-
var record = {
|
|
428
|
-
score: 0,
|
|
429
|
-
};
|
|
430
|
-
var result = cacheWith(Matcher.matchSegments(_this.segments, path.segments, record));
|
|
431
|
-
_this.matchScore = record.score;
|
|
432
|
-
return result.matched;
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
};
|
|
436
|
-
//别名组匹配
|
|
437
|
-
this.matchAliasGroup = function (name, alias) {
|
|
438
|
-
var namePath = Path.parse(name);
|
|
439
|
-
var aliasPath = Path.parse(alias);
|
|
440
|
-
var nameMatched = _this.match(namePath);
|
|
441
|
-
var nameMatchedScore = _this.matchScore;
|
|
442
|
-
var aliasMatched = _this.match(aliasPath);
|
|
443
|
-
var aliasMatchedScore = _this.matchScore;
|
|
444
|
-
if (_this.haveExcludePattern) {
|
|
445
|
-
if (nameMatchedScore >= aliasMatchedScore) {
|
|
446
|
-
return nameMatched;
|
|
447
|
-
}
|
|
448
|
-
else {
|
|
449
|
-
return aliasMatched;
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
else {
|
|
453
|
-
return nameMatched || aliasMatched;
|
|
454
|
-
}
|
|
455
|
-
};
|
|
456
|
-
this.existIn = function (source, start) {
|
|
457
|
-
if (start === void 0) { start = 0; }
|
|
458
|
-
return existIn(_this.segments, source, start);
|
|
459
|
-
};
|
|
460
|
-
this.getIn = function (source) {
|
|
461
|
-
return getIn(_this.segments, source);
|
|
462
|
-
};
|
|
463
|
-
this.setIn = function (source, value) {
|
|
464
|
-
setIn(_this.segments, source, value);
|
|
465
|
-
return source;
|
|
466
|
-
};
|
|
467
|
-
this.deleteIn = function (source) {
|
|
468
|
-
deleteIn(_this.segments, source);
|
|
469
|
-
return source;
|
|
470
|
-
};
|
|
471
|
-
this.ensureIn = function (source, defaults) {
|
|
472
|
-
var results = _this.getIn(source);
|
|
473
|
-
if (results === undefined) {
|
|
474
|
-
_this.setIn(source, defaults);
|
|
475
|
-
return _this.getIn(source);
|
|
476
|
-
}
|
|
477
|
-
return results;
|
|
478
|
-
};
|
|
479
|
-
var _a = parse(input, base), tree = _a.tree, segments = _a.segments, entire = _a.entire, isRegExp = _a.isRegExp, isMatchPattern = _a.isMatchPattern, isWildMatchPattern = _a.isWildMatchPattern, haveRelativePattern = _a.haveRelativePattern, haveExcludePattern = _a.haveExcludePattern;
|
|
480
|
-
this.entire = entire;
|
|
481
|
-
this.segments = segments;
|
|
482
|
-
this.isMatchPattern = isMatchPattern;
|
|
483
|
-
this.isWildMatchPattern = isWildMatchPattern;
|
|
484
|
-
this.haveRelativePattern = haveRelativePattern;
|
|
485
|
-
this.isRegExp = isRegExp;
|
|
486
|
-
this.haveExcludePattern = haveExcludePattern;
|
|
487
|
-
this.tree = tree;
|
|
488
|
-
this.matchCache = new Map();
|
|
489
|
-
this.includesCache = new Map();
|
|
490
|
-
}
|
|
491
|
-
Path.prototype.toString = function () {
|
|
492
|
-
var _a;
|
|
493
|
-
return (_a = this.entire) === null || _a === void 0 ? void 0 : _a.toString();
|
|
494
|
-
};
|
|
495
|
-
Path.prototype.toArr = function () {
|
|
496
|
-
var _a;
|
|
497
|
-
return (_a = this.segments) === null || _a === void 0 ? void 0 : _a.slice();
|
|
498
|
-
};
|
|
499
|
-
Object.defineProperty(Path.prototype, "length", {
|
|
500
|
-
get: function () {
|
|
501
|
-
return this.segments.length;
|
|
502
|
-
},
|
|
503
|
-
enumerable: false,
|
|
504
|
-
configurable: true
|
|
505
|
-
});
|
|
506
|
-
Path.match = function (pattern) {
|
|
507
|
-
var path = Path.parse(pattern);
|
|
508
|
-
var matcher = function (target) {
|
|
509
|
-
return path.match(target);
|
|
510
|
-
};
|
|
511
|
-
matcher[isMatcher] = true;
|
|
512
|
-
matcher.path = path;
|
|
513
|
-
return matcher;
|
|
514
|
-
};
|
|
515
|
-
Path.isPathPattern = function (target) {
|
|
516
|
-
if (isStr(target) ||
|
|
517
|
-
isArr(target) ||
|
|
518
|
-
isRegExp(target) ||
|
|
519
|
-
(isFn(target) && target[isMatcher])) {
|
|
520
|
-
return true;
|
|
521
|
-
}
|
|
522
|
-
return false;
|
|
523
|
-
};
|
|
524
|
-
Path.transform = function (pattern, regexp, callback) {
|
|
525
|
-
return Path.parse(pattern).transform(regexp, callback);
|
|
526
|
-
};
|
|
527
|
-
Path.parse = function (path, base) {
|
|
528
|
-
if (path === void 0) { path = ''; }
|
|
529
|
-
if (path instanceof Path) {
|
|
530
|
-
var found = pathCache.get(path.entire);
|
|
531
|
-
if (found) {
|
|
532
|
-
return found;
|
|
533
|
-
}
|
|
534
|
-
else {
|
|
535
|
-
pathCache.set(path.entire, path);
|
|
536
|
-
return path;
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
else if (path && path[isMatcher]) {
|
|
540
|
-
return Path.parse(path['path']);
|
|
541
|
-
}
|
|
542
|
-
else {
|
|
543
|
-
var key_ = base ? Path.parse(base) : '';
|
|
544
|
-
var key = "".concat(path, ":").concat(key_);
|
|
545
|
-
var found = pathCache.get(key);
|
|
546
|
-
if (found) {
|
|
547
|
-
return found;
|
|
548
|
-
}
|
|
549
|
-
else {
|
|
550
|
-
path = new Path(path, base);
|
|
551
|
-
pathCache.set(key, path);
|
|
552
|
-
return path;
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
};
|
|
556
|
-
Path.getIn = function (source, pattern) {
|
|
557
|
-
var path = Path.parse(pattern);
|
|
558
|
-
return path.getIn(source);
|
|
559
|
-
};
|
|
560
|
-
Path.setIn = function (source, pattern, value) {
|
|
561
|
-
var path = Path.parse(pattern);
|
|
562
|
-
return path.setIn(source, value);
|
|
563
|
-
};
|
|
564
|
-
Path.deleteIn = function (source, pattern) {
|
|
565
|
-
var path = Path.parse(pattern);
|
|
566
|
-
return path.deleteIn(source);
|
|
567
|
-
};
|
|
568
|
-
Path.existIn = function (source, pattern, start) {
|
|
569
|
-
var path = Path.parse(pattern);
|
|
570
|
-
return path.existIn(source, start);
|
|
571
|
-
};
|
|
572
|
-
Path.ensureIn = function (source, pattern, defaultValue) {
|
|
573
|
-
var path = Path.parse(pattern);
|
|
574
|
-
return path.ensureIn(source, defaultValue);
|
|
575
|
-
};
|
|
576
|
-
return Path;
|
|
577
|
-
}());
|
|
578
|
-
|
|
579
|
-
export { Path };
|