@tachybase/schema 0.23.41 → 0.23.47
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/lib/core/effects/index.d.ts +2 -0
- package/lib/core/effects/index.js +23 -0
- package/lib/core/effects/onFieldEffects.d.ts +27 -0
- package/lib/core/effects/onFieldEffects.js +158 -0
- package/lib/core/effects/onFormEffects.d.ts +24 -0
- package/lib/core/effects/onFormEffects.js +117 -0
- package/lib/core/global.d.js +0 -0
- package/lib/core/index.d.ts +4 -0
- package/lib/core/index.js +27 -0
- package/lib/core/models/ArrayField.d.ts +17 -0
- package/lib/core/models/ArrayField.js +145 -0
- package/lib/core/models/BaseField.d.ts +72 -0
- package/lib/core/models/BaseField.js +285 -0
- package/lib/core/models/Field.d.ts +70 -0
- package/lib/core/models/Field.js +426 -0
- package/lib/core/models/Form.d.ts +102 -0
- package/lib/core/models/Form.js +483 -0
- package/lib/core/models/Graph.d.ts +8 -0
- package/lib/core/models/Graph.js +77 -0
- package/lib/core/models/Heart.d.ts +16 -0
- package/lib/core/models/Heart.js +91 -0
- package/lib/core/models/LifeCycle.d.ts +14 -0
- package/lib/core/models/LifeCycle.js +64 -0
- package/lib/core/models/ObjectField.d.ts +12 -0
- package/lib/core/models/ObjectField.js +64 -0
- package/lib/core/models/Query.d.ts +18 -0
- package/lib/core/models/Query.js +105 -0
- package/lib/core/models/VoidField.d.ts +14 -0
- package/lib/core/models/VoidField.js +117 -0
- package/lib/core/models/index.d.ts +9 -0
- package/lib/core/models/index.js +37 -0
- package/lib/core/models/types.d.ts +9 -0
- package/lib/core/models/types.js +15 -0
- package/lib/core/shared/checkers.d.ts +117 -0
- package/lib/core/shared/checkers.js +109 -0
- package/lib/core/shared/constants.d.ts +48 -0
- package/lib/core/shared/constants.js +86 -0
- package/lib/core/shared/effective.d.ts +9 -0
- package/lib/core/shared/effective.js +91 -0
- package/lib/core/shared/externals.d.ts +8 -0
- package/lib/core/shared/externals.js +87 -0
- package/lib/core/shared/internals.d.ts +54 -0
- package/lib/core/shared/internals.js +956 -0
- package/lib/core/types.d.ts +275 -0
- package/lib/core/types.js +76 -0
- package/lib/grid/index.d.ts +67 -0
- package/lib/grid/index.js +378 -0
- package/lib/grid/observer.d.ts +19 -0
- package/lib/grid/observer.js +107 -0
- package/lib/index.d.ts +12 -24
- package/lib/index.js +27 -244
- package/lib/json-schema/compiler.d.ts +8 -0
- package/lib/json-schema/compiler.js +129 -0
- package/lib/json-schema/global.d.js +0 -0
- package/lib/json-schema/index.d.ts +2 -0
- package/lib/json-schema/index.js +23 -0
- package/lib/json-schema/patches.d.ts +5 -0
- package/lib/json-schema/patches.js +68 -0
- package/lib/json-schema/polyfills/SPECIFICATION_1_0.d.ts +2 -0
- package/lib/json-schema/polyfills/SPECIFICATION_1_0.js +132 -0
- package/lib/json-schema/polyfills/index.d.ts +1 -0
- package/lib/json-schema/polyfills/index.js +21 -0
- package/lib/json-schema/schema.d.ts +88 -0
- package/lib/json-schema/schema.js +231 -0
- package/lib/json-schema/shared.d.ts +62 -0
- package/lib/json-schema/shared.js +232 -0
- package/lib/json-schema/transformer.d.ts +4 -0
- package/lib/json-schema/transformer.js +238 -0
- package/lib/json-schema/types.d.ts +119 -0
- package/lib/json-schema/types.js +15 -0
- package/lib/path/contexts.d.ts +10 -0
- package/lib/path/contexts.js +49 -0
- package/lib/path/destructor.d.ts +15 -0
- package/lib/path/destructor.js +151 -0
- package/lib/path/index.d.ts +51 -0
- package/lib/path/index.js +513 -0
- package/lib/path/matcher.d.ts +33 -0
- package/lib/path/matcher.js +197 -0
- package/lib/path/parser.d.ts +33 -0
- package/lib/path/parser.js +379 -0
- package/lib/path/shared.d.ts +13 -0
- package/lib/path/shared.js +121 -0
- package/lib/path/tokenizer.d.ts +27 -0
- package/lib/path/tokenizer.js +269 -0
- package/lib/path/tokens.d.ts +27 -0
- package/lib/path/tokens.js +216 -0
- package/lib/path/types.d.ts +88 -0
- package/lib/path/types.js +63 -0
- package/lib/react/components/ArrayField.d.ts +6 -0
- package/lib/react/components/ArrayField.js +44 -0
- package/lib/react/components/ExpressionScope.d.ts +2 -0
- package/lib/react/components/ExpressionScope.js +35 -0
- package/lib/react/components/Field.d.ts +5 -0
- package/lib/react/components/Field.js +45 -0
- package/lib/react/components/FormConsumer.d.ts +2 -0
- package/lib/react/components/FormConsumer.js +36 -0
- package/lib/react/components/FormProvider.d.ts +2 -0
- package/lib/react/components/FormProvider.js +35 -0
- package/lib/react/components/ObjectField.d.ts +6 -0
- package/lib/react/components/ObjectField.js +39 -0
- package/lib/react/components/ReactiveField.d.ts +11 -0
- package/lib/react/components/ReactiveField.js +115 -0
- package/lib/react/components/RecordScope.d.ts +2 -0
- package/lib/react/components/RecordScope.js +65 -0
- package/lib/react/components/RecordsScope.d.ts +2 -0
- package/lib/react/components/RecordsScope.js +43 -0
- package/lib/react/components/RecursionField.d.ts +2 -0
- package/lib/react/components/RecursionField.js +105 -0
- package/lib/react/components/SchemaField.d.ts +41 -0
- package/lib/react/components/SchemaField.js +154 -0
- package/lib/react/components/VoidField.d.ts +5 -0
- package/lib/react/components/VoidField.js +39 -0
- package/lib/react/components/index.d.ts +11 -0
- package/lib/react/components/index.js +41 -0
- package/lib/react/global.d.js +0 -0
- package/lib/react/hooks/index.d.ts +6 -0
- package/lib/react/hooks/index.js +31 -0
- package/lib/react/hooks/useAttach.d.ts +6 -0
- package/lib/react/hooks/useAttach.js +35 -0
- package/lib/react/hooks/useExpressionScope.d.ts +1 -0
- package/lib/react/hooks/useExpressionScope.js +30 -0
- package/lib/react/hooks/useField.d.ts +2 -0
- package/lib/react/hooks/useField.js +32 -0
- package/lib/react/hooks/useFieldSchema.d.ts +2 -0
- package/lib/react/hooks/useFieldSchema.js +32 -0
- package/lib/react/hooks/useForm.d.ts +2 -0
- package/lib/react/hooks/useForm.js +32 -0
- package/lib/react/hooks/useFormEffects.d.ts +2 -0
- package/lib/react/hooks/useFormEffects.js +42 -0
- package/lib/react/hooks/useParentForm.d.ts +2 -0
- package/lib/react/hooks/useParentForm.js +40 -0
- package/lib/react/index.d.ts +5 -0
- package/lib/react/index.js +29 -0
- package/lib/react/shared/connect.d.ts +9 -0
- package/lib/react/shared/connect.js +118 -0
- package/lib/react/shared/context.d.ts +14 -0
- package/lib/react/shared/context.js +74 -0
- package/lib/react/shared/index.d.ts +2 -0
- package/lib/react/shared/index.js +23 -0
- package/lib/react/shared/render.d.ts +2 -0
- package/lib/react/shared/render.js +69 -0
- package/lib/react/types.d.ts +84 -0
- package/lib/react/types.js +15 -0
- package/lib/reactive/action.d.ts +2 -0
- package/lib/reactive/action.js +48 -0
- package/lib/reactive/annotations/box.d.ts +7 -0
- package/lib/reactive/annotations/box.js +76 -0
- package/lib/reactive/annotations/computed.d.ts +12 -0
- package/lib/reactive/annotations/computed.js +154 -0
- package/lib/reactive/annotations/index.d.ts +5 -0
- package/lib/reactive/annotations/index.js +29 -0
- package/lib/reactive/annotations/observable.d.ts +4 -0
- package/lib/reactive/annotations/observable.js +67 -0
- package/lib/reactive/annotations/ref.d.ts +6 -0
- package/lib/reactive/annotations/ref.js +78 -0
- package/lib/reactive/annotations/shallow.d.ts +2 -0
- package/lib/reactive/annotations/shallow.js +67 -0
- package/lib/reactive/array.d.ts +12 -0
- package/lib/reactive/array.js +83 -0
- package/lib/reactive/autorun.d.ts +7 -0
- package/lib/reactive/autorun.js +155 -0
- package/lib/reactive/batch.d.ts +2 -0
- package/lib/reactive/batch.js +40 -0
- package/lib/reactive/checkers.d.ts +10 -0
- package/lib/reactive/checkers.js +60 -0
- package/lib/reactive/environment.d.ts +28 -0
- package/lib/reactive/environment.js +76 -0
- package/lib/reactive/externals.d.ts +10 -0
- package/lib/reactive/externals.js +156 -0
- package/lib/reactive/global.d.js +0 -0
- package/lib/reactive/handlers.d.ts +4 -0
- package/lib/reactive/handlers.js +246 -0
- package/lib/reactive/index.d.ts +10 -0
- package/lib/reactive/index.js +39 -0
- package/lib/reactive/internals.d.ts +17 -0
- package/lib/reactive/internals.js +139 -0
- package/lib/reactive/model.d.ts +3 -0
- package/lib/reactive/model.js +68 -0
- package/lib/reactive/observable.d.ts +9 -0
- package/lib/reactive/observable.js +50 -0
- package/lib/reactive/observe.d.ts +2 -0
- package/lib/reactive/observe.js +58 -0
- package/lib/reactive/reaction.d.ts +21 -0
- package/lib/reactive/reaction.js +278 -0
- package/lib/reactive/tracker.d.ts +7 -0
- package/lib/reactive/tracker.js +63 -0
- package/lib/reactive/tree.d.ts +25 -0
- package/lib/reactive/tree.js +106 -0
- package/lib/reactive/types.d.ts +79 -0
- package/lib/reactive/types.js +21 -0
- package/lib/reactive/untracked.d.ts +4 -0
- package/lib/reactive/untracked.js +29 -0
- package/lib/reactive-react/hooks/index.d.ts +9 -0
- package/lib/reactive-react/hooks/index.js +48 -0
- package/lib/reactive-react/hooks/useCompatEffect.d.ts +2 -0
- package/lib/reactive-react/hooks/useCompatEffect.js +60 -0
- package/lib/reactive-react/hooks/useCompatFactory.d.ts +3 -0
- package/lib/reactive-react/hooks/useCompatFactory.js +74 -0
- package/lib/reactive-react/hooks/useDidUpdate.d.ts +1 -0
- package/lib/reactive-react/hooks/useDidUpdate.js +38 -0
- package/lib/reactive-react/hooks/useForceUpdate.d.ts +1 -0
- package/lib/reactive-react/hooks/useForceUpdate.js +76 -0
- package/lib/reactive-react/hooks/useLayoutEffect.d.ts +2 -0
- package/lib/reactive-react/hooks/useLayoutEffect.js +28 -0
- package/lib/reactive-react/hooks/useObserver.d.ts +2 -0
- package/lib/reactive-react/hooks/useObserver.js +43 -0
- package/lib/reactive-react/index.d.ts +3 -0
- package/lib/reactive-react/index.js +25 -0
- package/lib/reactive-react/observer.d.ts +8 -0
- package/lib/reactive-react/observer.js +64 -0
- package/lib/reactive-react/shared/gc.d.ts +8 -0
- package/lib/reactive-react/shared/gc.js +59 -0
- package/lib/reactive-react/shared/global.d.ts +1 -0
- package/lib/reactive-react/shared/global.js +50 -0
- package/lib/reactive-react/shared/immediate.d.ts +1 -0
- package/lib/reactive-react/shared/immediate.js +40 -0
- package/lib/reactive-react/shared/index.d.ts +2 -0
- package/lib/reactive-react/shared/index.js +23 -0
- package/lib/reactive-react/types.d.ts +14 -0
- package/lib/reactive-react/types.js +15 -0
- package/lib/shared/array.d.ts +35 -0
- package/lib/shared/array.js +189 -0
- package/lib/shared/case.d.ts +6 -0
- package/lib/shared/case.js +39 -0
- package/lib/shared/checkers.d.ts +21 -0
- package/lib/shared/checkers.js +77 -0
- package/lib/shared/clone.d.ts +2 -0
- package/lib/shared/clone.js +97 -0
- package/lib/shared/compare.d.ts +1 -0
- package/lib/shared/compare.js +129 -0
- package/lib/shared/defaults.d.ts +6 -0
- package/lib/shared/defaults.js +63 -0
- package/lib/shared/deprecate.d.ts +1 -0
- package/lib/shared/deprecate.js +42 -0
- package/lib/shared/global.d.ts +1 -0
- package/lib/shared/global.js +50 -0
- package/lib/shared/index.d.ts +16 -0
- package/lib/shared/index.js +51 -0
- package/lib/shared/instanceof.d.ts +1 -0
- package/lib/shared/instanceof.js +36 -0
- package/lib/shared/isEmpty.d.ts +3 -0
- package/lib/shared/isEmpty.js +94 -0
- package/lib/shared/merge.d.ts +12 -0
- package/lib/shared/merge.js +214 -0
- package/lib/shared/middleware.d.ts +4 -0
- package/lib/shared/middleware.js +41 -0
- package/lib/shared/path.d.ts +3 -0
- package/lib/shared/path.js +27 -0
- package/lib/shared/string.d.ts +1 -0
- package/lib/shared/string.js +38 -0
- package/lib/shared/subscribable.d.ts +11 -0
- package/lib/shared/subscribable.js +74 -0
- package/lib/shared/uid.d.ts +1 -0
- package/lib/shared/uid.js +35 -0
- package/lib/validator/formats.d.ts +16 -0
- package/lib/validator/formats.js +40 -0
- package/lib/validator/index.d.ts +4 -0
- package/lib/validator/index.js +27 -0
- package/lib/validator/locale.d.ts +219 -0
- package/lib/validator/locale.js +240 -0
- package/lib/validator/parser.d.ts +5 -0
- package/lib/validator/parser.js +153 -0
- package/lib/validator/registry.d.ts +15 -0
- package/lib/validator/registry.js +116 -0
- package/lib/validator/rules.d.ts +3 -0
- package/lib/validator/rules.js +154 -0
- package/lib/validator/template.d.ts +2 -0
- package/lib/validator/template.js +42 -0
- package/lib/validator/types.d.ts +62 -0
- package/lib/validator/types.js +28 -0
- package/lib/validator/validator.d.ts +2 -0
- package/lib/validator/validator.js +63 -0
- package/package.json +16 -10
|
@@ -0,0 +1,513 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var path_exports = {};
|
|
20
|
+
__export(path_exports, {
|
|
21
|
+
Path: () => Path
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(path_exports);
|
|
24
|
+
var import_destructor = require("./destructor");
|
|
25
|
+
var import_matcher = require("./matcher");
|
|
26
|
+
var import_parser = require("./parser");
|
|
27
|
+
var import_shared = require("./shared");
|
|
28
|
+
const pathCache = /* @__PURE__ */ new Map();
|
|
29
|
+
const isMatcher = Symbol("PATH_MATCHER");
|
|
30
|
+
const isValid = /* @__PURE__ */ __name((val) => val !== void 0 && val !== null, "isValid");
|
|
31
|
+
const isSimplePath = /* @__PURE__ */ __name((val) => val.indexOf("*") === -1 && val.indexOf("~") === -1 && val.indexOf("[") === -1 && val.indexOf("]") === -1 && val.indexOf(",") === -1 && val.indexOf(":") === -1 && val.indexOf(" ") === -1 && val[0] !== ".", "isSimplePath");
|
|
32
|
+
const isAssignable = /* @__PURE__ */ __name((val) => typeof val === "object" || typeof val === "function", "isAssignable");
|
|
33
|
+
const isNumberIndex = /* @__PURE__ */ __name((val) => (0, import_shared.isStr)(val) ? /^\d+$/.test(val) : (0, import_shared.isNum)(val), "isNumberIndex");
|
|
34
|
+
const getIn = /* @__PURE__ */ __name((segments, source) => {
|
|
35
|
+
for (let i = 0; i < segments.length; i++) {
|
|
36
|
+
const index = segments[i];
|
|
37
|
+
const rules = (0, import_destructor.getDestructor)(index);
|
|
38
|
+
if (!rules) {
|
|
39
|
+
if (!isValid(source)) return;
|
|
40
|
+
source = source[index];
|
|
41
|
+
} else {
|
|
42
|
+
source = (0, import_destructor.getInByDestructor)(source, rules, { setIn, getIn });
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return source;
|
|
47
|
+
}, "getIn");
|
|
48
|
+
const setIn = /* @__PURE__ */ __name((segments, source, value) => {
|
|
49
|
+
for (let i = 0; i < segments.length; i++) {
|
|
50
|
+
const index = segments[i];
|
|
51
|
+
const rules = (0, import_destructor.getDestructor)(index);
|
|
52
|
+
if (!rules) {
|
|
53
|
+
if (!isValid(source) || !isAssignable(source)) return;
|
|
54
|
+
if ((0, import_shared.isArr)(source) && !isNumberIndex(index)) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (!isValid(source[index])) {
|
|
58
|
+
if (value === void 0) {
|
|
59
|
+
if (source[index] === null) source[index] = value;
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (i < segments.length - 1) {
|
|
63
|
+
source[index] = (0, import_shared.isNum)(segments[i + 1]) ? [] : {};
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (i === segments.length - 1) {
|
|
67
|
+
source[index] = value;
|
|
68
|
+
}
|
|
69
|
+
source = source[index];
|
|
70
|
+
} else {
|
|
71
|
+
(0, import_destructor.setInByDestructor)(source, rules, value, { setIn, getIn });
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}, "setIn");
|
|
76
|
+
const deleteIn = /* @__PURE__ */ __name((segments, source) => {
|
|
77
|
+
for (let i = 0; i < segments.length; i++) {
|
|
78
|
+
const index = segments[i];
|
|
79
|
+
const rules = (0, import_destructor.getDestructor)(index);
|
|
80
|
+
if (!rules) {
|
|
81
|
+
if (i === segments.length - 1 && isValid(source)) {
|
|
82
|
+
delete source[index];
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
if (!isValid(source) || !isAssignable(source)) return;
|
|
86
|
+
source = source[index];
|
|
87
|
+
if (!(0, import_shared.isObj)(source)) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
} else {
|
|
91
|
+
(0, import_destructor.deleteInByDestructor)(source, rules, {
|
|
92
|
+
setIn,
|
|
93
|
+
getIn,
|
|
94
|
+
deleteIn
|
|
95
|
+
});
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}, "deleteIn");
|
|
100
|
+
const hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
101
|
+
const existIn = /* @__PURE__ */ __name((segments, source, start) => {
|
|
102
|
+
if (start instanceof Path) {
|
|
103
|
+
start = start.length;
|
|
104
|
+
}
|
|
105
|
+
for (let i = start; i < segments.length; i++) {
|
|
106
|
+
const index = segments[i];
|
|
107
|
+
const rules = (0, import_destructor.getDestructor)(index);
|
|
108
|
+
if (!rules) {
|
|
109
|
+
if (i === segments.length - 1) {
|
|
110
|
+
return hasOwnProperty.call(source, index);
|
|
111
|
+
}
|
|
112
|
+
if (!isValid(source) || !isAssignable(source)) return false;
|
|
113
|
+
source = source[index];
|
|
114
|
+
if (!(0, import_shared.isObj)(source)) {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
} else {
|
|
118
|
+
return (0, import_destructor.existInByDestructor)(source, rules, start, {
|
|
119
|
+
setIn,
|
|
120
|
+
getIn,
|
|
121
|
+
deleteIn,
|
|
122
|
+
existIn
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}, "existIn");
|
|
127
|
+
const parse = /* @__PURE__ */ __name((pattern, base) => {
|
|
128
|
+
if (pattern instanceof Path) {
|
|
129
|
+
return {
|
|
130
|
+
entire: pattern.entire,
|
|
131
|
+
segments: pattern.segments.slice(),
|
|
132
|
+
isRegExp: false,
|
|
133
|
+
haveRelativePattern: pattern.haveRelativePattern,
|
|
134
|
+
isWildMatchPattern: pattern.isWildMatchPattern,
|
|
135
|
+
isMatchPattern: pattern.isMatchPattern,
|
|
136
|
+
haveExcludePattern: pattern.haveExcludePattern,
|
|
137
|
+
tree: pattern.tree
|
|
138
|
+
};
|
|
139
|
+
} else if ((0, import_shared.isStr)(pattern)) {
|
|
140
|
+
if (!pattern) {
|
|
141
|
+
return {
|
|
142
|
+
entire: "",
|
|
143
|
+
segments: [],
|
|
144
|
+
isRegExp: false,
|
|
145
|
+
isWildMatchPattern: false,
|
|
146
|
+
haveExcludePattern: false,
|
|
147
|
+
isMatchPattern: false
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
if (isSimplePath(pattern)) {
|
|
151
|
+
return {
|
|
152
|
+
entire: pattern,
|
|
153
|
+
segments: pattern.split("."),
|
|
154
|
+
isRegExp: false,
|
|
155
|
+
isWildMatchPattern: false,
|
|
156
|
+
haveExcludePattern: false,
|
|
157
|
+
isMatchPattern: false
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
const parser = new import_parser.Parser(pattern, Path.parse(base));
|
|
161
|
+
const tree = parser.parse();
|
|
162
|
+
if (!parser.isMatchPattern) {
|
|
163
|
+
const segments = parser.data.segments;
|
|
164
|
+
return {
|
|
165
|
+
entire: segments.join("."),
|
|
166
|
+
segments,
|
|
167
|
+
tree,
|
|
168
|
+
isRegExp: false,
|
|
169
|
+
haveRelativePattern: parser.haveRelativePattern,
|
|
170
|
+
isWildMatchPattern: false,
|
|
171
|
+
haveExcludePattern: false,
|
|
172
|
+
isMatchPattern: false
|
|
173
|
+
};
|
|
174
|
+
} else {
|
|
175
|
+
return {
|
|
176
|
+
entire: pattern,
|
|
177
|
+
segments: [],
|
|
178
|
+
isRegExp: false,
|
|
179
|
+
haveRelativePattern: false,
|
|
180
|
+
isWildMatchPattern: parser.isWildMatchPattern,
|
|
181
|
+
haveExcludePattern: parser.haveExcludePattern,
|
|
182
|
+
isMatchPattern: true,
|
|
183
|
+
tree
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
} else if ((0, import_shared.isFn)(pattern) && pattern[isMatcher]) {
|
|
187
|
+
return parse(pattern["path"]);
|
|
188
|
+
} else if ((0, import_shared.isArr)(pattern)) {
|
|
189
|
+
return {
|
|
190
|
+
entire: pattern.join("."),
|
|
191
|
+
segments: pattern.reduce((buf, key) => {
|
|
192
|
+
return buf.concat(parseString(key));
|
|
193
|
+
}, []),
|
|
194
|
+
isRegExp: false,
|
|
195
|
+
haveRelativePattern: false,
|
|
196
|
+
isWildMatchPattern: false,
|
|
197
|
+
haveExcludePattern: false,
|
|
198
|
+
isMatchPattern: false
|
|
199
|
+
};
|
|
200
|
+
} else if ((0, import_shared.isRegExp)(pattern)) {
|
|
201
|
+
return {
|
|
202
|
+
entire: pattern,
|
|
203
|
+
segments: [],
|
|
204
|
+
isRegExp: true,
|
|
205
|
+
haveRelativePattern: false,
|
|
206
|
+
isWildMatchPattern: false,
|
|
207
|
+
haveExcludePattern: false,
|
|
208
|
+
isMatchPattern: true
|
|
209
|
+
};
|
|
210
|
+
} else {
|
|
211
|
+
return {
|
|
212
|
+
entire: "",
|
|
213
|
+
isRegExp: false,
|
|
214
|
+
segments: pattern !== void 0 ? [pattern] : [],
|
|
215
|
+
haveRelativePattern: false,
|
|
216
|
+
isWildMatchPattern: false,
|
|
217
|
+
haveExcludePattern: false,
|
|
218
|
+
isMatchPattern: false
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
}, "parse");
|
|
222
|
+
const parseString = /* @__PURE__ */ __name((source) => {
|
|
223
|
+
if ((0, import_shared.isStr)(source)) {
|
|
224
|
+
source = source.replace(/\s*/g, "");
|
|
225
|
+
try {
|
|
226
|
+
const { segments, isMatchPattern } = parse(source);
|
|
227
|
+
return !isMatchPattern ? segments : source;
|
|
228
|
+
} catch (e) {
|
|
229
|
+
return source;
|
|
230
|
+
}
|
|
231
|
+
} else if (source instanceof Path) {
|
|
232
|
+
return source.segments;
|
|
233
|
+
}
|
|
234
|
+
return source;
|
|
235
|
+
}, "parseString");
|
|
236
|
+
const _Path = class _Path {
|
|
237
|
+
constructor(input, base) {
|
|
238
|
+
this.concat = /* @__PURE__ */ __name((...args) => {
|
|
239
|
+
if (this.isMatchPattern || this.isRegExp) {
|
|
240
|
+
throw new Error(`${this.entire} cannot be concat`);
|
|
241
|
+
}
|
|
242
|
+
const path = new _Path("");
|
|
243
|
+
path.segments = this.segments.concat(...args.map((s) => parseString(s)));
|
|
244
|
+
path.entire = path.segments.join(".");
|
|
245
|
+
return path;
|
|
246
|
+
}, "concat");
|
|
247
|
+
this.slice = /* @__PURE__ */ __name((start, end) => {
|
|
248
|
+
if (this.isMatchPattern || this.isRegExp) {
|
|
249
|
+
throw new Error(`${this.entire} cannot be slice`);
|
|
250
|
+
}
|
|
251
|
+
const path = new _Path("");
|
|
252
|
+
path.segments = this.segments.slice(start, end);
|
|
253
|
+
path.entire = path.segments.join(".");
|
|
254
|
+
return path;
|
|
255
|
+
}, "slice");
|
|
256
|
+
this.push = /* @__PURE__ */ __name((...items) => {
|
|
257
|
+
return this.concat(...items);
|
|
258
|
+
}, "push");
|
|
259
|
+
this.pop = /* @__PURE__ */ __name(() => {
|
|
260
|
+
if (this.isMatchPattern || this.isRegExp) {
|
|
261
|
+
throw new Error(`${this.entire} cannot be pop`);
|
|
262
|
+
}
|
|
263
|
+
return new _Path(this.segments.slice(0, this.segments.length - 1));
|
|
264
|
+
}, "pop");
|
|
265
|
+
this.splice = /* @__PURE__ */ __name((start, deleteCount, ...items) => {
|
|
266
|
+
if (this.isMatchPattern || this.isRegExp) {
|
|
267
|
+
throw new Error(`${this.entire} cannot be splice`);
|
|
268
|
+
}
|
|
269
|
+
items = items.reduce((buf, item) => buf.concat(parseString(item)), []);
|
|
270
|
+
const segments_ = this.segments.slice();
|
|
271
|
+
segments_.splice(start, deleteCount, ...items);
|
|
272
|
+
return new _Path(segments_);
|
|
273
|
+
}, "splice");
|
|
274
|
+
this.forEach = /* @__PURE__ */ __name((callback) => {
|
|
275
|
+
if (this.isMatchPattern || this.isRegExp) {
|
|
276
|
+
throw new Error(`${this.entire} cannot be each`);
|
|
277
|
+
}
|
|
278
|
+
this.segments.forEach(callback);
|
|
279
|
+
}, "forEach");
|
|
280
|
+
this.map = /* @__PURE__ */ __name((callback) => {
|
|
281
|
+
if (this.isMatchPattern || this.isRegExp) {
|
|
282
|
+
throw new Error(`${this.entire} cannot be map`);
|
|
283
|
+
}
|
|
284
|
+
return this.segments.map(callback);
|
|
285
|
+
}, "map");
|
|
286
|
+
this.reduce = /* @__PURE__ */ __name((callback, initial) => {
|
|
287
|
+
if (this.isMatchPattern || this.isRegExp) {
|
|
288
|
+
throw new Error(`${this.entire} cannot be reduce`);
|
|
289
|
+
}
|
|
290
|
+
return this.segments.reduce(callback, initial);
|
|
291
|
+
}, "reduce");
|
|
292
|
+
this.parent = /* @__PURE__ */ __name(() => {
|
|
293
|
+
return this.slice(0, this.length - 1);
|
|
294
|
+
}, "parent");
|
|
295
|
+
this.includes = /* @__PURE__ */ __name((pattern) => {
|
|
296
|
+
const { entire, segments, isMatchPattern } = _Path.parse(pattern);
|
|
297
|
+
const cache = this.includesCache.get(entire);
|
|
298
|
+
if (cache !== void 0) return cache;
|
|
299
|
+
const cacheWith = /* @__PURE__ */ __name((value) => {
|
|
300
|
+
this.includesCache.set(entire, value);
|
|
301
|
+
return value;
|
|
302
|
+
}, "cacheWith");
|
|
303
|
+
if (this.isMatchPattern) {
|
|
304
|
+
if (!isMatchPattern) {
|
|
305
|
+
return cacheWith(this.match(segments));
|
|
306
|
+
} else {
|
|
307
|
+
throw new Error(`${this.entire} cannot be used to match ${entire}`);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
if (isMatchPattern) {
|
|
311
|
+
throw new Error(`${this.entire} cannot be used to match ${entire}`);
|
|
312
|
+
}
|
|
313
|
+
if (segments.length > this.segments.length) return cacheWith(false);
|
|
314
|
+
for (let i = 0; i < segments.length; i++) {
|
|
315
|
+
if (!(0, import_shared.isEqual)(String(segments[i]), String(this.segments[i]))) {
|
|
316
|
+
return cacheWith(false);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
return cacheWith(true);
|
|
320
|
+
}, "includes");
|
|
321
|
+
this.transform = /* @__PURE__ */ __name((regexp, callback) => {
|
|
322
|
+
if (!(0, import_shared.isFn)(callback)) return "";
|
|
323
|
+
if (this.isMatchPattern) {
|
|
324
|
+
throw new Error(`${this.entire} cannot be transformed`);
|
|
325
|
+
}
|
|
326
|
+
const reg = new RegExp(regexp);
|
|
327
|
+
const args = this.segments.filter((key) => reg.test(key));
|
|
328
|
+
return callback(...args);
|
|
329
|
+
}, "transform");
|
|
330
|
+
this.match = /* @__PURE__ */ __name((pattern) => {
|
|
331
|
+
var _a, _b;
|
|
332
|
+
const path = _Path.parse(pattern);
|
|
333
|
+
const cache = this.matchCache.get(path.entire);
|
|
334
|
+
if (cache !== void 0) {
|
|
335
|
+
if (cache.record && cache.record.score !== void 0) {
|
|
336
|
+
this.matchScore = cache.record.score;
|
|
337
|
+
}
|
|
338
|
+
return cache.matched;
|
|
339
|
+
}
|
|
340
|
+
const cacheWith = /* @__PURE__ */ __name((value) => {
|
|
341
|
+
this.matchCache.set(path.entire, value);
|
|
342
|
+
return value;
|
|
343
|
+
}, "cacheWith");
|
|
344
|
+
if (path.isMatchPattern) {
|
|
345
|
+
if (this.isMatchPattern) {
|
|
346
|
+
throw new Error(`${path.entire} cannot match ${this.entire}`);
|
|
347
|
+
} else {
|
|
348
|
+
this.matchScore = 0;
|
|
349
|
+
return cacheWith(path.match(this.segments));
|
|
350
|
+
}
|
|
351
|
+
} else {
|
|
352
|
+
if (this.isMatchPattern) {
|
|
353
|
+
if (this.isRegExp) {
|
|
354
|
+
try {
|
|
355
|
+
return (_b = (_a = this["entire"]) == null ? void 0 : _a["test"]) == null ? void 0 : _b.call(_a, path.entire);
|
|
356
|
+
} finally {
|
|
357
|
+
this.entire.lastIndex = 0;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
const record = {
|
|
361
|
+
score: 0
|
|
362
|
+
};
|
|
363
|
+
const result = cacheWith(new import_matcher.Matcher(this.tree, record).match(path.segments));
|
|
364
|
+
this.matchScore = record.score;
|
|
365
|
+
return result.matched;
|
|
366
|
+
} else {
|
|
367
|
+
const record = {
|
|
368
|
+
score: 0
|
|
369
|
+
};
|
|
370
|
+
const result = cacheWith(import_matcher.Matcher.matchSegments(this.segments, path.segments, record));
|
|
371
|
+
this.matchScore = record.score;
|
|
372
|
+
return result.matched;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
}, "match");
|
|
376
|
+
//别名组匹配
|
|
377
|
+
this.matchAliasGroup = /* @__PURE__ */ __name((name, alias) => {
|
|
378
|
+
const namePath = _Path.parse(name);
|
|
379
|
+
const aliasPath = _Path.parse(alias);
|
|
380
|
+
const nameMatched = this.match(namePath);
|
|
381
|
+
const nameMatchedScore = this.matchScore;
|
|
382
|
+
const aliasMatched = this.match(aliasPath);
|
|
383
|
+
const aliasMatchedScore = this.matchScore;
|
|
384
|
+
if (this.haveExcludePattern) {
|
|
385
|
+
if (nameMatchedScore >= aliasMatchedScore) {
|
|
386
|
+
return nameMatched;
|
|
387
|
+
} else {
|
|
388
|
+
return aliasMatched;
|
|
389
|
+
}
|
|
390
|
+
} else {
|
|
391
|
+
return nameMatched || aliasMatched;
|
|
392
|
+
}
|
|
393
|
+
}, "matchAliasGroup");
|
|
394
|
+
this.existIn = /* @__PURE__ */ __name((source, start = 0) => {
|
|
395
|
+
return existIn(this.segments, source, start);
|
|
396
|
+
}, "existIn");
|
|
397
|
+
this.getIn = /* @__PURE__ */ __name((source) => {
|
|
398
|
+
return getIn(this.segments, source);
|
|
399
|
+
}, "getIn");
|
|
400
|
+
this.setIn = /* @__PURE__ */ __name((source, value) => {
|
|
401
|
+
setIn(this.segments, source, value);
|
|
402
|
+
return source;
|
|
403
|
+
}, "setIn");
|
|
404
|
+
this.deleteIn = /* @__PURE__ */ __name((source) => {
|
|
405
|
+
deleteIn(this.segments, source);
|
|
406
|
+
return source;
|
|
407
|
+
}, "deleteIn");
|
|
408
|
+
this.ensureIn = /* @__PURE__ */ __name((source, defaults) => {
|
|
409
|
+
const results = this.getIn(source);
|
|
410
|
+
if (results === void 0) {
|
|
411
|
+
this.setIn(source, defaults);
|
|
412
|
+
return this.getIn(source);
|
|
413
|
+
}
|
|
414
|
+
return results;
|
|
415
|
+
}, "ensureIn");
|
|
416
|
+
const {
|
|
417
|
+
tree,
|
|
418
|
+
segments,
|
|
419
|
+
entire,
|
|
420
|
+
isRegExp: isRegExp2,
|
|
421
|
+
isMatchPattern,
|
|
422
|
+
isWildMatchPattern,
|
|
423
|
+
haveRelativePattern,
|
|
424
|
+
haveExcludePattern
|
|
425
|
+
} = parse(input, base);
|
|
426
|
+
this.entire = entire;
|
|
427
|
+
this.segments = segments;
|
|
428
|
+
this.isMatchPattern = isMatchPattern;
|
|
429
|
+
this.isWildMatchPattern = isWildMatchPattern;
|
|
430
|
+
this.haveRelativePattern = haveRelativePattern;
|
|
431
|
+
this.isRegExp = isRegExp2;
|
|
432
|
+
this.haveExcludePattern = haveExcludePattern;
|
|
433
|
+
this.tree = tree;
|
|
434
|
+
this.matchCache = /* @__PURE__ */ new Map();
|
|
435
|
+
this.includesCache = /* @__PURE__ */ new Map();
|
|
436
|
+
}
|
|
437
|
+
toString() {
|
|
438
|
+
var _a;
|
|
439
|
+
return (_a = this.entire) == null ? void 0 : _a.toString();
|
|
440
|
+
}
|
|
441
|
+
toArr() {
|
|
442
|
+
var _a;
|
|
443
|
+
return (_a = this.segments) == null ? void 0 : _a.slice();
|
|
444
|
+
}
|
|
445
|
+
get length() {
|
|
446
|
+
return this.segments.length;
|
|
447
|
+
}
|
|
448
|
+
static match(pattern) {
|
|
449
|
+
const path = _Path.parse(pattern);
|
|
450
|
+
const matcher = /* @__PURE__ */ __name((target) => {
|
|
451
|
+
return path.match(target);
|
|
452
|
+
}, "matcher");
|
|
453
|
+
matcher[isMatcher] = true;
|
|
454
|
+
matcher.path = path;
|
|
455
|
+
return matcher;
|
|
456
|
+
}
|
|
457
|
+
static isPathPattern(target) {
|
|
458
|
+
return !!((0, import_shared.isStr)(target) || (0, import_shared.isArr)(target) || (0, import_shared.isRegExp)(target) || (0, import_shared.isFn)(target) && target[isMatcher]);
|
|
459
|
+
}
|
|
460
|
+
static transform(pattern, regexp, callback) {
|
|
461
|
+
return _Path.parse(pattern).transform(regexp, callback);
|
|
462
|
+
}
|
|
463
|
+
static parse(path = "", base) {
|
|
464
|
+
if (path instanceof _Path) {
|
|
465
|
+
const found = pathCache.get(path.entire);
|
|
466
|
+
if (found) {
|
|
467
|
+
return found;
|
|
468
|
+
} else {
|
|
469
|
+
pathCache.set(path.entire, path);
|
|
470
|
+
return path;
|
|
471
|
+
}
|
|
472
|
+
} else if (path && path[isMatcher]) {
|
|
473
|
+
return _Path.parse(path["path"]);
|
|
474
|
+
} else {
|
|
475
|
+
const key_ = base ? _Path.parse(base) : "";
|
|
476
|
+
const key = `${path}:${key_}`;
|
|
477
|
+
const found = pathCache.get(key);
|
|
478
|
+
if (found) {
|
|
479
|
+
return found;
|
|
480
|
+
} else {
|
|
481
|
+
path = new _Path(path, base);
|
|
482
|
+
pathCache.set(key, path);
|
|
483
|
+
return path;
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
};
|
|
488
|
+
__name(_Path, "Path");
|
|
489
|
+
_Path.getIn = /* @__PURE__ */ __name((source, pattern) => {
|
|
490
|
+
const path = _Path.parse(pattern);
|
|
491
|
+
return path.getIn(source);
|
|
492
|
+
}, "getIn");
|
|
493
|
+
_Path.setIn = /* @__PURE__ */ __name((source, pattern, value) => {
|
|
494
|
+
const path = _Path.parse(pattern);
|
|
495
|
+
return path.setIn(source, value);
|
|
496
|
+
}, "setIn");
|
|
497
|
+
_Path.deleteIn = /* @__PURE__ */ __name((source, pattern) => {
|
|
498
|
+
const path = _Path.parse(pattern);
|
|
499
|
+
return path.deleteIn(source);
|
|
500
|
+
}, "deleteIn");
|
|
501
|
+
_Path.existIn = /* @__PURE__ */ __name((source, pattern, start) => {
|
|
502
|
+
const path = _Path.parse(pattern);
|
|
503
|
+
return path.existIn(source, start);
|
|
504
|
+
}, "existIn");
|
|
505
|
+
_Path.ensureIn = /* @__PURE__ */ __name((source, pattern, defaultValue) => {
|
|
506
|
+
const path = _Path.parse(pattern);
|
|
507
|
+
return path.ensureIn(source, defaultValue);
|
|
508
|
+
}, "ensureIn");
|
|
509
|
+
let Path = _Path;
|
|
510
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
511
|
+
0 && (module.exports = {
|
|
512
|
+
Path
|
|
513
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { DestructorExpressionNode, ExpandOperatorNode, GroupExpressionNode, IdentifierNode, IgnoreExpressionNode, Node, RangeExpressionNode, Segments, WildcardOperatorNode } from './types';
|
|
2
|
+
export interface IRecord {
|
|
3
|
+
score: number;
|
|
4
|
+
}
|
|
5
|
+
export declare class Matcher {
|
|
6
|
+
private tree;
|
|
7
|
+
private stack;
|
|
8
|
+
private record;
|
|
9
|
+
private excluding;
|
|
10
|
+
private wildcards;
|
|
11
|
+
private path;
|
|
12
|
+
constructor(tree: Node, record?: any);
|
|
13
|
+
next(node: Node, pos: number): any;
|
|
14
|
+
shot(): void;
|
|
15
|
+
take(pos: number): string;
|
|
16
|
+
matchExcludeIdentifier(matched: boolean, node: Node, pos: number): any;
|
|
17
|
+
matchIdentifier(node: IdentifierNode, pos: number): any;
|
|
18
|
+
matchIgnoreExpression(node: IgnoreExpressionNode, pos: number): any;
|
|
19
|
+
matchDestructorExpression(node: DestructorExpressionNode, pos: number): any;
|
|
20
|
+
matchExpandOperator(node: ExpandOperatorNode, pos: number): any;
|
|
21
|
+
matchWildcardOperator(node: WildcardOperatorNode, pos: number): any;
|
|
22
|
+
matchGroupExpression(node: GroupExpressionNode, pos: number): any;
|
|
23
|
+
matchRangeExpression(node: RangeExpressionNode, pos: number): any;
|
|
24
|
+
matchNode(node: Node, pos?: number): any;
|
|
25
|
+
match(path: Segments): {
|
|
26
|
+
matched: any;
|
|
27
|
+
record: IRecord;
|
|
28
|
+
};
|
|
29
|
+
static matchSegments(source: Segments, target: Segments, record?: any): {
|
|
30
|
+
matched: any;
|
|
31
|
+
record: any;
|
|
32
|
+
};
|
|
33
|
+
}
|