cnhis-design-vue 3.1.14-beta.14 → 3.1.14-beta.15
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/node_modules/@formily/path/esm/contexts.js +22 -0
- package/es/node_modules/@formily/path/esm/destructor.js +124 -0
- package/es/node_modules/@formily/path/esm/index.js +579 -0
- package/es/node_modules/@formily/path/esm/matcher.js +199 -0
- package/es/node_modules/@formily/path/esm/parser.js +402 -0
- package/es/node_modules/@formily/path/esm/shared.js +73 -0
- package/es/node_modules/@formily/path/esm/tokenizer.js +287 -0
- package/es/node_modules/@formily/path/esm/tokens.js +240 -0
- package/es/node_modules/@formily/path/esm/types.js +17 -0
- package/es/packages/form-render/src/components/renderer/combination.d.ts +6 -0
- package/es/packages/form-render/src/components/renderer/combination.js +53 -16
- package/es/packages/form-render/src/components/renderer/select.js +1 -2
- package/es/packages/form-render/src/components/renderer/simpleComponent.d.ts +1 -0
- package/es/packages/form-render/src/components/renderer/simpleComponent.js +4 -3
- package/es/packages/form-render/src/hooks/useFieldListAdaptor.js +1 -0
- package/es/packages/form-render/src/types/fieldItem.d.ts +1 -0
- package/es/packages/shortcut-provider/src/types/index.d.ts +11 -9
- package/es/packages/shortcut-provider/src/utils/index.js +5 -5
- package/es/packages/shortcut-setter/index.d.ts +3248 -1486
- package/es/packages/shortcut-setter/src/ShortcutSetter.js +9 -5
- package/es/packages/shortcut-setter/src/ShortcutSetter.vue.d.ts +3248 -1486
- package/es/packages/shortcut-setter/src/ShortcutSetterItem.js +24 -11
- package/es/packages/shortcut-setter/src/ShortcutSetterItem.vue.d.ts +1700 -1661
- package/global.d.ts +8 -8
- package/package.json +1 -1
|
@@ -0,0 +1,579 @@
|
|
|
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 };
|