@valbuild/core 0.14.0 → 0.16.0
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/dist/SelectorProxy-2af1b2b8.cjs.prod.js +756 -0
- package/dist/SelectorProxy-63c2d0e2.esm.js +722 -0
- package/dist/SelectorProxy-873782a5.cjs.dev.js +756 -0
- package/dist/declarations/src/index.d.ts +2 -0
- package/dist/declarations/src/initVal.d.ts +1 -1
- package/dist/declarations/src/patch/index.d.ts +1 -1
- package/dist/declarations/src/patch/util.d.ts +2 -0
- package/dist/declarations/src/schema/array.d.ts +3 -2
- package/dist/declarations/src/schema/boolean.d.ts +3 -2
- package/dist/declarations/src/schema/i18n.d.ts +3 -2
- package/dist/declarations/src/schema/image.d.ts +3 -2
- package/dist/declarations/src/schema/index.d.ts +5 -2
- package/dist/declarations/src/schema/literal.d.ts +3 -2
- package/dist/declarations/src/schema/number.d.ts +3 -2
- package/dist/declarations/src/schema/object.d.ts +3 -2
- package/dist/declarations/src/schema/oneOf.d.ts +3 -2
- package/dist/declarations/src/schema/richtext.d.ts +3 -2
- package/dist/declarations/src/schema/string.d.ts +3 -2
- package/dist/declarations/src/schema/union.d.ts +3 -2
- package/dist/declarations/src/schema/validation/ValidationError.d.ts +14 -0
- package/dist/declarations/src/schema/validation/ValidationFix.d.ts +2 -0
- package/dist/index-2fff5ca8.cjs.dev.js +456 -0
- package/dist/{index-06df0a5b.esm.js → index-af761363.esm.js} +2 -555
- package/dist/index-cac9ecbd.cjs.prod.js +456 -0
- package/dist/ops-1b6e0e35.cjs.prod.js +552 -0
- package/dist/ops-74661336.esm.js +541 -0
- package/dist/ops-ea4827fc.cjs.dev.js +552 -0
- package/dist/valbuild-core.cjs.dev.js +151 -531
- package/dist/valbuild-core.cjs.prod.js +151 -531
- package/dist/valbuild-core.esm.js +65 -445
- package/expr/dist/valbuild-core-expr.cjs.dev.js +8 -8
- package/expr/dist/valbuild-core-expr.cjs.prod.js +8 -8
- package/expr/dist/valbuild-core-expr.esm.js +2 -2
- package/package.json +2 -1
- package/patch/dist/valbuild-core-patch.cjs.dev.js +30 -21
- package/patch/dist/valbuild-core-patch.cjs.prod.js +30 -21
- package/patch/dist/valbuild-core-patch.esm.js +12 -4
- package/src/expr/repl.ts +2 -2
- package/src/index.ts +5 -0
- package/src/initVal.ts +1 -1
- package/src/patch/index.ts +1 -0
- package/src/patch/util.ts +7 -0
- package/src/schema/array.ts +45 -4
- package/src/schema/boolean.ts +14 -3
- package/src/schema/i18n.ts +4 -2
- package/src/schema/image.ts +65 -5
- package/src/schema/index.ts +23 -2
- package/src/schema/literal.ts +24 -3
- package/src/schema/number.ts +14 -3
- package/src/schema/object.ts +50 -7
- package/src/schema/oneOf.ts +3 -2
- package/src/schema/richtext.ts +63 -3
- package/src/schema/string.ts +14 -3
- package/src/schema/union.ts +3 -2
- package/src/schema/validation/ValidationError.ts +16 -0
- package/src/schema/validation/ValidationFix.ts +6 -0
- package/src/schema/validation.test.ts +226 -0
- package/src/selector/SelectorProxy.ts +1 -1
- package/dist/createClass-012eebbf.esm.js +0 -109
- package/dist/createClass-a436dbfe.cjs.dev.js +0 -116
- package/dist/createClass-de7426aa.cjs.prod.js +0 -116
- package/dist/index-9663f28a.cjs.dev.js +0 -1037
- package/dist/index-b2270f8f.cjs.prod.js +0 -1037
- package/dist/ops-6fae92a1.esm.js +0 -12
- package/dist/ops-87cdbafc.cjs.dev.js +0 -14
- package/dist/ops-ae4d1bc2.cjs.prod.js +0 -14
@@ -2,236 +2,31 @@
|
|
2
2
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
|
-
var
|
6
|
-
var
|
5
|
+
var SelectorProxy = require('./SelectorProxy-2af1b2b8.cjs.prod.js');
|
6
|
+
var ops = require('./ops-1b6e0e35.cjs.prod.js');
|
7
|
+
var expr_dist_valbuildCoreExpr = require('./index-cac9ecbd.cjs.prod.js');
|
7
8
|
var result = require('./result-26f67b40.cjs.prod.js');
|
8
|
-
var ops = require('./ops-ae4d1bc2.cjs.prod.js');
|
9
|
-
|
10
|
-
var ObjectSchema = /*#__PURE__*/function (_Schema) {
|
11
|
-
expr_dist_valbuildCoreExpr._inherits(ObjectSchema, _Schema);
|
12
|
-
var _super = expr_dist_valbuildCoreExpr._createSuper(ObjectSchema);
|
13
|
-
function ObjectSchema(items) {
|
14
|
-
var _this;
|
15
|
-
var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
16
|
-
createClass._classCallCheck(this, ObjectSchema);
|
17
|
-
_this = _super.call(this);
|
18
|
-
_this.items = items;
|
19
|
-
_this.opt = opt;
|
20
|
-
return _this;
|
21
|
-
}
|
22
|
-
createClass._createClass(ObjectSchema, [{
|
23
|
-
key: "validate",
|
24
|
-
value: function validate(src) {
|
25
|
-
throw new Error("Method not implemented.");
|
26
|
-
}
|
27
|
-
}, {
|
28
|
-
key: "match",
|
29
|
-
value: function match(src) {
|
30
|
-
if (this.opt && (src === null || src === undefined)) {
|
31
|
-
return true;
|
32
|
-
}
|
33
|
-
if (!src) {
|
34
|
-
return false;
|
35
|
-
}
|
36
|
-
|
37
|
-
// TODO: checks all props
|
38
|
-
|
39
|
-
return createClass._typeof(src) === "object" && !Array.isArray(src);
|
40
|
-
}
|
41
|
-
}, {
|
42
|
-
key: "optional",
|
43
|
-
value: function optional() {
|
44
|
-
return new ObjectSchema(this.items, true);
|
45
|
-
}
|
46
|
-
}, {
|
47
|
-
key: "serialize",
|
48
|
-
value: function serialize() {
|
49
|
-
return {
|
50
|
-
type: "object",
|
51
|
-
items: Object.fromEntries(Object.entries(this.items).map(function (_ref) {
|
52
|
-
var _ref2 = createClass._slicedToArray(_ref, 2),
|
53
|
-
key = _ref2[0],
|
54
|
-
schema = _ref2[1];
|
55
|
-
return [key, schema.serialize()];
|
56
|
-
})),
|
57
|
-
opt: this.opt
|
58
|
-
};
|
59
|
-
}
|
60
|
-
}]);
|
61
|
-
return ObjectSchema;
|
62
|
-
}(expr_dist_valbuildCoreExpr.Schema);
|
63
|
-
var object = function object(schema) {
|
64
|
-
return new ObjectSchema(schema);
|
65
|
-
};
|
66
|
-
|
67
|
-
var ArraySchema = /*#__PURE__*/function (_Schema) {
|
68
|
-
expr_dist_valbuildCoreExpr._inherits(ArraySchema, _Schema);
|
69
|
-
var _super = expr_dist_valbuildCoreExpr._createSuper(ArraySchema);
|
70
|
-
function ArraySchema(item) {
|
71
|
-
var _this;
|
72
|
-
var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
73
|
-
createClass._classCallCheck(this, ArraySchema);
|
74
|
-
_this = _super.call(this);
|
75
|
-
_this.item = item;
|
76
|
-
_this.opt = opt;
|
77
|
-
return _this;
|
78
|
-
}
|
79
|
-
createClass._createClass(ArraySchema, [{
|
80
|
-
key: "validate",
|
81
|
-
value: function validate(src) {
|
82
|
-
throw new Error("Method not implemented.");
|
83
|
-
}
|
84
|
-
}, {
|
85
|
-
key: "match",
|
86
|
-
value: function match(src) {
|
87
|
-
if (this.opt && (src === null || src === undefined)) {
|
88
|
-
return true;
|
89
|
-
}
|
90
|
-
if (!src) {
|
91
|
-
return false;
|
92
|
-
}
|
93
|
-
|
94
|
-
// TODO: checks all items
|
95
|
-
return createClass._typeof(src) === "object" && Array.isArray(src);
|
96
|
-
}
|
97
|
-
}, {
|
98
|
-
key: "optional",
|
99
|
-
value: function optional() {
|
100
|
-
return new ArraySchema(this.item, true);
|
101
|
-
}
|
102
|
-
}, {
|
103
|
-
key: "serialize",
|
104
|
-
value: function serialize() {
|
105
|
-
return {
|
106
|
-
type: "array",
|
107
|
-
item: this.item.serialize(),
|
108
|
-
opt: this.opt
|
109
|
-
};
|
110
|
-
}
|
111
|
-
}]);
|
112
|
-
return ArraySchema;
|
113
|
-
}(expr_dist_valbuildCoreExpr.Schema);
|
114
|
-
var array = function array(schema) {
|
115
|
-
return new ArraySchema(schema);
|
116
|
-
};
|
117
|
-
|
118
|
-
var I18nSchema = /*#__PURE__*/function (_Schema) {
|
119
|
-
expr_dist_valbuildCoreExpr._inherits(I18nSchema, _Schema);
|
120
|
-
var _super = expr_dist_valbuildCoreExpr._createSuper(I18nSchema);
|
121
|
-
function I18nSchema(locales, item) {
|
122
|
-
var _this;
|
123
|
-
var opt = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
124
|
-
createClass._classCallCheck(this, I18nSchema);
|
125
|
-
_this = _super.call(this);
|
126
|
-
_this.locales = locales;
|
127
|
-
_this.item = item;
|
128
|
-
_this.opt = opt;
|
129
|
-
return _this;
|
130
|
-
}
|
131
|
-
createClass._createClass(I18nSchema, [{
|
132
|
-
key: "validate",
|
133
|
-
value: function validate(src) {
|
134
|
-
throw new Error("Method not implemented.");
|
135
|
-
}
|
136
|
-
}, {
|
137
|
-
key: "match",
|
138
|
-
value: function match(src) {
|
139
|
-
throw new Error("Method not implemented.");
|
140
|
-
}
|
141
|
-
}, {
|
142
|
-
key: "optional",
|
143
|
-
value: function optional() {
|
144
|
-
return new I18nSchema(this.locales, this.item, true);
|
145
|
-
}
|
146
|
-
}, {
|
147
|
-
key: "serialize",
|
148
|
-
value: function serialize() {
|
149
|
-
return {
|
150
|
-
type: "i18n",
|
151
|
-
item: this.item.serialize(),
|
152
|
-
locales: this.locales,
|
153
|
-
opt: this.opt
|
154
|
-
};
|
155
|
-
}
|
156
|
-
}]);
|
157
|
-
return I18nSchema;
|
158
|
-
}(expr_dist_valbuildCoreExpr.Schema);
|
159
|
-
var i18n$1 = function i18n(locales) {
|
160
|
-
return function (schema) {
|
161
|
-
return new I18nSchema(locales, schema);
|
162
|
-
};
|
163
|
-
};
|
164
|
-
|
165
|
-
var UnionSchema = /*#__PURE__*/function (_Schema) {
|
166
|
-
expr_dist_valbuildCoreExpr._inherits(UnionSchema, _Schema);
|
167
|
-
var _super = expr_dist_valbuildCoreExpr._createSuper(UnionSchema);
|
168
|
-
function UnionSchema(key, items) {
|
169
|
-
var _this;
|
170
|
-
var opt = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
171
|
-
createClass._classCallCheck(this, UnionSchema);
|
172
|
-
_this = _super.call(this);
|
173
|
-
_this.key = key;
|
174
|
-
_this.items = items;
|
175
|
-
_this.opt = opt;
|
176
|
-
return _this;
|
177
|
-
}
|
178
|
-
createClass._createClass(UnionSchema, [{
|
179
|
-
key: "validate",
|
180
|
-
value: function validate(src) {
|
181
|
-
throw new Error("Method not implemented.");
|
182
|
-
}
|
183
|
-
}, {
|
184
|
-
key: "match",
|
185
|
-
value: function match(src) {
|
186
|
-
throw new Error("Method not implemented.");
|
187
|
-
}
|
188
|
-
}, {
|
189
|
-
key: "optional",
|
190
|
-
value: function optional() {
|
191
|
-
throw new Error("Method not implemented.");
|
192
|
-
}
|
193
|
-
}, {
|
194
|
-
key: "serialize",
|
195
|
-
value: function serialize() {
|
196
|
-
return {
|
197
|
-
type: "union",
|
198
|
-
key: this.key,
|
199
|
-
items: this.items.map(function (o) {
|
200
|
-
return o.serialize();
|
201
|
-
}),
|
202
|
-
opt: this.opt
|
203
|
-
};
|
204
|
-
}
|
205
|
-
}]);
|
206
|
-
return UnionSchema;
|
207
|
-
}(expr_dist_valbuildCoreExpr.Schema);
|
208
|
-
var union = function union(key) {
|
209
|
-
for (var _len = arguments.length, objects = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
210
|
-
objects[_key - 1] = arguments[_key];
|
211
|
-
}
|
212
|
-
return new UnionSchema(key, objects);
|
213
|
-
};
|
214
9
|
|
215
10
|
var OneOfSchema = /*#__PURE__*/function (_Schema) {
|
216
|
-
|
217
|
-
var _super =
|
11
|
+
SelectorProxy._inherits(OneOfSchema, _Schema);
|
12
|
+
var _super = SelectorProxy._createSuper(OneOfSchema);
|
218
13
|
function OneOfSchema(selector) {
|
219
14
|
var _this;
|
220
15
|
var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
221
|
-
|
16
|
+
SelectorProxy._classCallCheck(this, OneOfSchema);
|
222
17
|
_this = _super.call(this);
|
223
18
|
_this.selector = selector;
|
224
19
|
_this.opt = opt;
|
225
20
|
return _this;
|
226
21
|
}
|
227
|
-
|
22
|
+
SelectorProxy._createClass(OneOfSchema, [{
|
228
23
|
key: "validate",
|
229
|
-
value: function validate(src) {
|
24
|
+
value: function validate(path, src) {
|
230
25
|
throw new Error("Method not implemented.");
|
231
26
|
}
|
232
27
|
}, {
|
233
|
-
key: "
|
234
|
-
value: function
|
28
|
+
key: "assert",
|
29
|
+
value: function assert(src) {
|
235
30
|
throw new Error("Method not implemented.");
|
236
31
|
}
|
237
32
|
}, {
|
@@ -242,7 +37,7 @@ var OneOfSchema = /*#__PURE__*/function (_Schema) {
|
|
242
37
|
}, {
|
243
38
|
key: "serialize",
|
244
39
|
value: function serialize() {
|
245
|
-
var path =
|
40
|
+
var path = SelectorProxy.getValPath(this.selector);
|
246
41
|
if (!path) {
|
247
42
|
throw new Error("Cannot serialize oneOf schema with empty selector. Make sure a Val module is used.");
|
248
43
|
}
|
@@ -254,228 +49,11 @@ var OneOfSchema = /*#__PURE__*/function (_Schema) {
|
|
254
49
|
}
|
255
50
|
}]);
|
256
51
|
return OneOfSchema;
|
257
|
-
}(
|
52
|
+
}(SelectorProxy.Schema);
|
258
53
|
var oneOf = function oneOf(valModule) {
|
259
54
|
return new OneOfSchema(valModule);
|
260
55
|
};
|
261
56
|
|
262
|
-
var RichTextSchema = /*#__PURE__*/function (_Schema) {
|
263
|
-
expr_dist_valbuildCoreExpr._inherits(RichTextSchema, _Schema);
|
264
|
-
var _super = expr_dist_valbuildCoreExpr._createSuper(RichTextSchema);
|
265
|
-
function RichTextSchema() {
|
266
|
-
var _this;
|
267
|
-
var opt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
268
|
-
createClass._classCallCheck(this, RichTextSchema);
|
269
|
-
_this = _super.call(this);
|
270
|
-
_this.opt = opt;
|
271
|
-
return _this;
|
272
|
-
}
|
273
|
-
createClass._createClass(RichTextSchema, [{
|
274
|
-
key: "validate",
|
275
|
-
value: function validate(src) {
|
276
|
-
throw new Error("Method not implemented.");
|
277
|
-
}
|
278
|
-
}, {
|
279
|
-
key: "match",
|
280
|
-
value: function match(src) {
|
281
|
-
// TODO:
|
282
|
-
return true;
|
283
|
-
}
|
284
|
-
}, {
|
285
|
-
key: "optional",
|
286
|
-
value: function optional() {
|
287
|
-
return new RichTextSchema(true);
|
288
|
-
}
|
289
|
-
}, {
|
290
|
-
key: "serialize",
|
291
|
-
value: function serialize() {
|
292
|
-
return {
|
293
|
-
type: "richtext",
|
294
|
-
opt: this.opt
|
295
|
-
};
|
296
|
-
}
|
297
|
-
}]);
|
298
|
-
return RichTextSchema;
|
299
|
-
}(expr_dist_valbuildCoreExpr.Schema);
|
300
|
-
var richtext$1 = function richtext() {
|
301
|
-
return new RichTextSchema();
|
302
|
-
};
|
303
|
-
|
304
|
-
function content(
|
305
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
306
|
-
id,
|
307
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
308
|
-
schema,
|
309
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
310
|
-
source) {
|
311
|
-
return expr_dist_valbuildCoreExpr.newSelectorProxy(source, id, schema);
|
312
|
-
}
|
313
|
-
function getRawSource(valModule) {
|
314
|
-
var sourceOrExpr = valModule[expr_dist_valbuildCoreExpr.SourceOrExpr];
|
315
|
-
if (sourceOrExpr instanceof expr_dist_valbuildCoreExpr.Expr) {
|
316
|
-
throw Error("Cannot get raw source of an Expr");
|
317
|
-
}
|
318
|
-
var source = sourceOrExpr;
|
319
|
-
return source;
|
320
|
-
}
|
321
|
-
function splitModuleIdAndModulePath(path) {
|
322
|
-
return [path.slice(0, path.indexOf(".")), path.slice(path.indexOf(".") + 1)];
|
323
|
-
}
|
324
|
-
function isObjectSchema(schema) {
|
325
|
-
return schema instanceof ObjectSchema || createClass._typeof(schema) === "object" && "type" in schema && schema.type === "object";
|
326
|
-
}
|
327
|
-
function isArraySchema(schema) {
|
328
|
-
return schema instanceof ArraySchema || createClass._typeof(schema) === "object" && "type" in schema && schema.type === "array";
|
329
|
-
}
|
330
|
-
function isI18nSchema(schema) {
|
331
|
-
return schema instanceof I18nSchema || createClass._typeof(schema) === "object" && "type" in schema && schema.type === "i18n";
|
332
|
-
}
|
333
|
-
function isUnionSchema(schema) {
|
334
|
-
return schema instanceof UnionSchema || createClass._typeof(schema) === "object" && "type" in schema && schema.type === "union";
|
335
|
-
}
|
336
|
-
|
337
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
338
|
-
function isRichTextSchema(schema) {
|
339
|
-
return schema instanceof RichTextSchema || createClass._typeof(schema) === "object" && "type" in schema && schema.type === "richtext";
|
340
|
-
}
|
341
|
-
function isImageSchema(schema) {
|
342
|
-
return schema instanceof expr_dist_valbuildCoreExpr.ImageSchema || createClass._typeof(schema) === "object" && "type" in schema && schema.type === "image";
|
343
|
-
}
|
344
|
-
function resolvePath(path, valModule, schema) {
|
345
|
-
var parts = parsePath(path);
|
346
|
-
var origParts = createClass._toConsumableArray(parts);
|
347
|
-
var resolvedSchema = schema;
|
348
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
349
|
-
var resolvedSource = valModule;
|
350
|
-
var _loop = function _loop() {
|
351
|
-
var part = parts.shift();
|
352
|
-
if (part === undefined) {
|
353
|
-
throw Error("Unexpected undefined part");
|
354
|
-
}
|
355
|
-
if (isArraySchema(resolvedSchema)) {
|
356
|
-
if (Number.isNaN(Number(part))) {
|
357
|
-
throw Error("Invalid path: array schema ".concat(resolvedSchema, " must have ").concat(part, " a number as path"));
|
358
|
-
}
|
359
|
-
if (createClass._typeof(resolvedSource) !== "object" && !Array.isArray(resolvedSource)) {
|
360
|
-
throw Error("Schema type error: expected source to be type of array, but got ".concat(createClass._typeof(resolvedSource)));
|
361
|
-
}
|
362
|
-
if (!resolvedSource[part]) {
|
363
|
-
var _resolvedSource;
|
364
|
-
throw Error("Invalid path: array source (length: ".concat((_resolvedSource = resolvedSource) === null || _resolvedSource === void 0 ? void 0 : _resolvedSource.length, ") did not have index ").concat(part, " from path: ").concat(path));
|
365
|
-
}
|
366
|
-
resolvedSource = resolvedSource[part];
|
367
|
-
resolvedSchema = resolvedSchema.item;
|
368
|
-
} else if (isObjectSchema(resolvedSchema)) {
|
369
|
-
if (createClass._typeof(resolvedSource) !== "object") {
|
370
|
-
throw Error("Schema type error: expected source to be type of object, but got ".concat(createClass._typeof(resolvedSource)));
|
371
|
-
}
|
372
|
-
if (!resolvedSource[part]) {
|
373
|
-
throw Error("Invalid path: object source did not have key ".concat(part, " from path: ").concat(path));
|
374
|
-
}
|
375
|
-
resolvedSource = resolvedSource[part];
|
376
|
-
resolvedSchema = resolvedSchema.items[part];
|
377
|
-
} else if (isI18nSchema(resolvedSchema)) {
|
378
|
-
if (!resolvedSchema.locales.includes(part)) {
|
379
|
-
throw Error("Invalid path: i18n schema ".concat(resolvedSchema, " supports locales ").concat(resolvedSchema.locales.join(", "), ", but found: ").concat(part));
|
380
|
-
}
|
381
|
-
if (!Object.keys(resolvedSource).includes(part)) {
|
382
|
-
throw Error("Schema type error: expected source to be type of i18n with locale ".concat(part, ", but got ").concat(JSON.stringify(Object.keys(resolvedSource))));
|
383
|
-
}
|
384
|
-
resolvedSource = resolvedSource[part];
|
385
|
-
resolvedSchema = resolvedSchema.item;
|
386
|
-
} else if (isImageSchema(resolvedSchema)) {
|
387
|
-
return {
|
388
|
-
v: {
|
389
|
-
path: origParts.slice(0, origParts.length - parts.length - 1).map(function (p) {
|
390
|
-
return JSON.stringify(p);
|
391
|
-
}).join("."),
|
392
|
-
// TODO: create a function generate path from parts (not sure if this always works)
|
393
|
-
schema: resolvedSchema,
|
394
|
-
source: resolvedSource
|
395
|
-
}
|
396
|
-
};
|
397
|
-
} else if (isUnionSchema(resolvedSchema)) {
|
398
|
-
var _key = resolvedSchema.key;
|
399
|
-
var keyValue = resolvedSource[_key];
|
400
|
-
if (!keyValue) {
|
401
|
-
throw Error("Invalid path: union source ".concat(resolvedSchema, " did not have required key ").concat(_key, " in path: ").concat(path));
|
402
|
-
}
|
403
|
-
var schemaOfUnionKey = resolvedSchema.items.find(
|
404
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
405
|
-
function (child) {
|
406
|
-
var _child$items, _child$items$_key;
|
407
|
-
return (child === null || child === void 0 ? void 0 : (_child$items = child.items) === null || _child$items === void 0 ? void 0 : (_child$items$_key = _child$items[_key]) === null || _child$items$_key === void 0 ? void 0 : _child$items$_key.value) === keyValue;
|
408
|
-
});
|
409
|
-
if (!schemaOfUnionKey) {
|
410
|
-
throw Error("Invalid path: union schema ".concat(resolvedSchema, " did not have a child object with ").concat(_key, " of value ").concat(keyValue, " in path: ").concat(path));
|
411
|
-
}
|
412
|
-
resolvedSchema = schemaOfUnionKey.items[part];
|
413
|
-
resolvedSource = resolvedSource[part];
|
414
|
-
} else if (isRichTextSchema(resolvedSchema)) {
|
415
|
-
return {
|
416
|
-
v: {
|
417
|
-
path: origParts.slice(0, origParts.length - parts.length - 1).map(function (p) {
|
418
|
-
return JSON.stringify(p);
|
419
|
-
}).join("."),
|
420
|
-
// TODO: create a function generate path from parts (not sure if this always works)
|
421
|
-
schema: resolvedSchema,
|
422
|
-
source: resolvedSource
|
423
|
-
}
|
424
|
-
};
|
425
|
-
} else {
|
426
|
-
throw Error("Invalid path: ".concat(part, " resolved to an unexpected schema ").concat(JSON.stringify(resolvedSchema)));
|
427
|
-
}
|
428
|
-
};
|
429
|
-
while (parts.length > 0) {
|
430
|
-
var _ret = _loop();
|
431
|
-
if (createClass._typeof(_ret) === "object") return _ret.v;
|
432
|
-
}
|
433
|
-
if (parts.length > 0) {
|
434
|
-
throw Error("Invalid path: ".concat(parts.join("."), " is not a valid path"));
|
435
|
-
}
|
436
|
-
return {
|
437
|
-
path: path,
|
438
|
-
schema: resolvedSchema,
|
439
|
-
source: resolvedSource
|
440
|
-
};
|
441
|
-
}
|
442
|
-
function parsePath(input) {
|
443
|
-
var result = [];
|
444
|
-
var i = 0;
|
445
|
-
while (i < input.length) {
|
446
|
-
var part = "";
|
447
|
-
if (input[i] === '"') {
|
448
|
-
// Parse a quoted string
|
449
|
-
i++;
|
450
|
-
while (i < input.length && input[i] !== '"') {
|
451
|
-
if (input[i] === "\\" && input[i + 1] === '"') {
|
452
|
-
// Handle escaped double quotes
|
453
|
-
part += '"';
|
454
|
-
i++;
|
455
|
-
} else {
|
456
|
-
part += input[i];
|
457
|
-
}
|
458
|
-
i++;
|
459
|
-
}
|
460
|
-
if (input[i] !== '"') {
|
461
|
-
var _input$i;
|
462
|
-
throw new Error("Invalid input (".concat(JSON.stringify(input), "): Missing closing double quote: ").concat((_input$i = input[i]) !== null && _input$i !== void 0 ? _input$i : "at end of string", " (char: ").concat(i, "; length: ").concat(input.length, ")"));
|
463
|
-
}
|
464
|
-
} else {
|
465
|
-
// Parse a regular string
|
466
|
-
while (i < input.length && input[i] !== ".") {
|
467
|
-
part += input[i];
|
468
|
-
i++;
|
469
|
-
}
|
470
|
-
}
|
471
|
-
if (part !== "") {
|
472
|
-
result.push(part);
|
473
|
-
}
|
474
|
-
i++;
|
475
|
-
}
|
476
|
-
return result;
|
477
|
-
}
|
478
|
-
|
479
57
|
/**
|
480
58
|
* I18n sources cannot have nested remote sources.
|
481
59
|
*/
|
@@ -491,30 +69,39 @@ function i18n(
|
|
491
69
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
492
70
|
locales) {
|
493
71
|
return function (source) {
|
494
|
-
return
|
72
|
+
return SelectorProxy._objectSpread2(SelectorProxy._objectSpread2({}, source), {}, SelectorProxy._defineProperty({}, SelectorProxy.VAL_EXTENSION, "i18n"));
|
495
73
|
};
|
496
74
|
}
|
497
75
|
|
498
76
|
var NumberSchema = /*#__PURE__*/function (_Schema) {
|
499
|
-
|
500
|
-
var _super =
|
77
|
+
SelectorProxy._inherits(NumberSchema, _Schema);
|
78
|
+
var _super = SelectorProxy._createSuper(NumberSchema);
|
501
79
|
function NumberSchema(options) {
|
502
80
|
var _this;
|
503
81
|
var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
504
|
-
|
82
|
+
SelectorProxy._classCallCheck(this, NumberSchema);
|
505
83
|
_this = _super.call(this);
|
506
84
|
_this.options = options;
|
507
85
|
_this.opt = opt;
|
508
86
|
return _this;
|
509
87
|
}
|
510
|
-
|
88
|
+
SelectorProxy._createClass(NumberSchema, [{
|
511
89
|
key: "validate",
|
512
|
-
value: function validate(src) {
|
513
|
-
|
90
|
+
value: function validate(path, src) {
|
91
|
+
if (this.opt && (src === null || src === undefined)) {
|
92
|
+
return false;
|
93
|
+
}
|
94
|
+
if (typeof src !== "number") {
|
95
|
+
return SelectorProxy._defineProperty({}, path, [{
|
96
|
+
message: "Expected 'number', got '".concat(SelectorProxy._typeof(src), "'"),
|
97
|
+
value: src
|
98
|
+
}]);
|
99
|
+
}
|
100
|
+
return false;
|
514
101
|
}
|
515
102
|
}, {
|
516
|
-
key: "
|
517
|
-
value: function
|
103
|
+
key: "assert",
|
104
|
+
value: function assert(src) {
|
518
105
|
if (this.opt && (src === null || src === undefined)) {
|
519
106
|
return true;
|
520
107
|
}
|
@@ -536,31 +123,40 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
|
|
536
123
|
}
|
537
124
|
}]);
|
538
125
|
return NumberSchema;
|
539
|
-
}(
|
126
|
+
}(SelectorProxy.Schema);
|
540
127
|
var number = function number(options) {
|
541
128
|
return new NumberSchema(options);
|
542
129
|
};
|
543
130
|
|
544
131
|
var StringSchema = /*#__PURE__*/function (_Schema) {
|
545
|
-
|
546
|
-
var _super =
|
132
|
+
SelectorProxy._inherits(StringSchema, _Schema);
|
133
|
+
var _super = SelectorProxy._createSuper(StringSchema);
|
547
134
|
function StringSchema(options) {
|
548
135
|
var _this;
|
549
136
|
var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
550
|
-
|
137
|
+
SelectorProxy._classCallCheck(this, StringSchema);
|
551
138
|
_this = _super.call(this);
|
552
139
|
_this.options = options;
|
553
140
|
_this.opt = opt;
|
554
141
|
return _this;
|
555
142
|
}
|
556
|
-
|
143
|
+
SelectorProxy._createClass(StringSchema, [{
|
557
144
|
key: "validate",
|
558
|
-
value: function validate(src) {
|
559
|
-
|
145
|
+
value: function validate(path, src) {
|
146
|
+
if (this.opt && (src === null || src === undefined)) {
|
147
|
+
return false;
|
148
|
+
}
|
149
|
+
if (typeof src !== "string") {
|
150
|
+
return SelectorProxy._defineProperty({}, path, [{
|
151
|
+
message: "Expected 'string', got '".concat(SelectorProxy._typeof(src), "'"),
|
152
|
+
value: src
|
153
|
+
}]);
|
154
|
+
}
|
155
|
+
return false;
|
560
156
|
}
|
561
157
|
}, {
|
562
|
-
key: "
|
563
|
-
value: function
|
158
|
+
key: "assert",
|
159
|
+
value: function assert(src) {
|
564
160
|
if (this.opt && (src === null || src === undefined)) {
|
565
161
|
return true;
|
566
162
|
}
|
@@ -582,30 +178,39 @@ var StringSchema = /*#__PURE__*/function (_Schema) {
|
|
582
178
|
}
|
583
179
|
}]);
|
584
180
|
return StringSchema;
|
585
|
-
}(
|
181
|
+
}(SelectorProxy.Schema);
|
586
182
|
var string = function string(options) {
|
587
183
|
return new StringSchema(options);
|
588
184
|
};
|
589
185
|
|
590
186
|
var BooleanSchema = /*#__PURE__*/function (_Schema) {
|
591
|
-
|
592
|
-
var _super =
|
187
|
+
SelectorProxy._inherits(BooleanSchema, _Schema);
|
188
|
+
var _super = SelectorProxy._createSuper(BooleanSchema);
|
593
189
|
function BooleanSchema() {
|
594
190
|
var _this;
|
595
191
|
var opt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
596
|
-
|
192
|
+
SelectorProxy._classCallCheck(this, BooleanSchema);
|
597
193
|
_this = _super.call(this);
|
598
194
|
_this.opt = opt;
|
599
195
|
return _this;
|
600
196
|
}
|
601
|
-
|
197
|
+
SelectorProxy._createClass(BooleanSchema, [{
|
602
198
|
key: "validate",
|
603
|
-
value: function validate(src) {
|
604
|
-
|
199
|
+
value: function validate(path, src) {
|
200
|
+
if (this.opt && (src === null || src === undefined)) {
|
201
|
+
return false;
|
202
|
+
}
|
203
|
+
if (typeof src !== "boolean") {
|
204
|
+
return SelectorProxy._defineProperty({}, path, [{
|
205
|
+
message: "Expected 'boolean', got '".concat(SelectorProxy._typeof(src), "'"),
|
206
|
+
value: src
|
207
|
+
}]);
|
208
|
+
}
|
209
|
+
return false;
|
605
210
|
}
|
606
211
|
}, {
|
607
|
-
key: "
|
608
|
-
value: function
|
212
|
+
key: "assert",
|
213
|
+
value: function assert(src) {
|
609
214
|
if (this.opt && (src === null || src === undefined)) {
|
610
215
|
return true;
|
611
216
|
}
|
@@ -626,31 +231,46 @@ var BooleanSchema = /*#__PURE__*/function (_Schema) {
|
|
626
231
|
}
|
627
232
|
}]);
|
628
233
|
return BooleanSchema;
|
629
|
-
}(
|
234
|
+
}(SelectorProxy.Schema);
|
630
235
|
var _boolean = function _boolean() {
|
631
236
|
return new BooleanSchema();
|
632
237
|
};
|
633
238
|
|
634
239
|
var LiteralSchema = /*#__PURE__*/function (_Schema) {
|
635
|
-
|
636
|
-
var _super =
|
240
|
+
SelectorProxy._inherits(LiteralSchema, _Schema);
|
241
|
+
var _super = SelectorProxy._createSuper(LiteralSchema);
|
637
242
|
function LiteralSchema(value) {
|
638
243
|
var _this;
|
639
244
|
var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
640
|
-
|
245
|
+
SelectorProxy._classCallCheck(this, LiteralSchema);
|
641
246
|
_this = _super.call(this);
|
642
247
|
_this.value = value;
|
643
248
|
_this.opt = opt;
|
644
249
|
return _this;
|
645
250
|
}
|
646
|
-
|
251
|
+
SelectorProxy._createClass(LiteralSchema, [{
|
647
252
|
key: "validate",
|
648
|
-
value: function validate(src) {
|
649
|
-
|
253
|
+
value: function validate(path, src) {
|
254
|
+
if (this.opt && (src === null || src === undefined)) {
|
255
|
+
return false;
|
256
|
+
}
|
257
|
+
if (typeof src !== "string") {
|
258
|
+
return SelectorProxy._defineProperty({}, path, [{
|
259
|
+
message: "Expected 'string', got '".concat(SelectorProxy._typeof(src), "'"),
|
260
|
+
value: src
|
261
|
+
}]);
|
262
|
+
}
|
263
|
+
if (src !== this.value) {
|
264
|
+
return SelectorProxy._defineProperty({}, path, [{
|
265
|
+
message: "Expected literal '".concat(this.value, "', got '").concat(src, "'"),
|
266
|
+
value: src
|
267
|
+
}]);
|
268
|
+
}
|
269
|
+
return false;
|
650
270
|
}
|
651
271
|
}, {
|
652
|
-
key: "
|
653
|
-
value: function
|
272
|
+
key: "assert",
|
273
|
+
value: function assert(src) {
|
654
274
|
if (this.opt && (src === null || src === undefined)) {
|
655
275
|
return true;
|
656
276
|
}
|
@@ -672,7 +292,7 @@ var LiteralSchema = /*#__PURE__*/function (_Schema) {
|
|
672
292
|
}
|
673
293
|
}]);
|
674
294
|
return LiteralSchema;
|
675
|
-
}(
|
295
|
+
}(SelectorProxy.Schema);
|
676
296
|
var literal = function literal(value) {
|
677
297
|
return new LiteralSchema(value);
|
678
298
|
};
|
@@ -681,15 +301,15 @@ function initSchema(locales) {
|
|
681
301
|
return {
|
682
302
|
string: string,
|
683
303
|
"boolean": _boolean,
|
684
|
-
array: array,
|
685
|
-
object: object,
|
304
|
+
array: ops.array,
|
305
|
+
object: ops.object,
|
686
306
|
number: number,
|
687
|
-
union: union,
|
307
|
+
union: ops.union,
|
688
308
|
oneOf: oneOf,
|
689
|
-
richtext: richtext
|
690
|
-
image:
|
309
|
+
richtext: ops.richtext,
|
310
|
+
image: SelectorProxy.image,
|
691
311
|
literal: literal,
|
692
|
-
i18n: i18n
|
312
|
+
i18n: ops.i18n(locales)
|
693
313
|
};
|
694
314
|
}
|
695
315
|
|
@@ -707,16 +327,16 @@ var REMOTE_REF_PROP = "_ref"; // TODO: same as FILE_REF_PROP so use same prop?
|
|
707
327
|
|
708
328
|
function remote(ref) {
|
709
329
|
var _ref;
|
710
|
-
return _ref = {},
|
330
|
+
return _ref = {}, SelectorProxy._defineProperty(_ref, REMOTE_REF_PROP, ref), SelectorProxy._defineProperty(_ref, SelectorProxy.VAL_EXTENSION, "remote"), _ref;
|
711
331
|
}
|
712
332
|
function isRemote(obj) {
|
713
|
-
return
|
333
|
+
return SelectorProxy._typeof(obj) === "object" && obj !== null && SelectorProxy.VAL_EXTENSION in obj && obj[SelectorProxy.VAL_EXTENSION] === "remote" && REMOTE_REF_PROP in obj && typeof obj[REMOTE_REF_PROP] === "string";
|
714
334
|
}
|
715
335
|
|
716
336
|
function richtext(data) {
|
717
337
|
if (typeof data === "string") {
|
718
338
|
var _ref;
|
719
|
-
return _ref = {},
|
339
|
+
return _ref = {}, SelectorProxy._defineProperty(_ref, SelectorProxy.VAL_EXTENSION, "richtext"), SelectorProxy._defineProperty(_ref, "type", "root"), SelectorProxy._defineProperty(_ref, "children", [{
|
720
340
|
type: "paragraph",
|
721
341
|
children: [{
|
722
342
|
type: "text",
|
@@ -724,7 +344,7 @@ function richtext(data) {
|
|
724
344
|
}]
|
725
345
|
}]), _ref;
|
726
346
|
}
|
727
|
-
return
|
347
|
+
return SelectorProxy._objectSpread2(SelectorProxy._objectSpread2({}, data), {}, SelectorProxy._defineProperty({}, SelectorProxy.VAL_EXTENSION, "richtext"));
|
728
348
|
}
|
729
349
|
|
730
350
|
var initVal = function initVal(options) {
|
@@ -734,11 +354,11 @@ var initVal = function initVal(options) {
|
|
734
354
|
console.error("Locales / i18n currently not implemented");
|
735
355
|
return {
|
736
356
|
val: {
|
737
|
-
content: content,
|
357
|
+
content: ops.content,
|
738
358
|
i18n: i18n,
|
739
359
|
remote: remote,
|
740
|
-
getPath:
|
741
|
-
file:
|
360
|
+
getPath: SelectorProxy.getValPath,
|
361
|
+
file: SelectorProxy.file,
|
742
362
|
richtext: richtext
|
743
363
|
},
|
744
364
|
s: s
|
@@ -748,13 +368,13 @@ var initVal = function initVal(options) {
|
|
748
368
|
|
749
369
|
return {
|
750
370
|
val: {
|
751
|
-
content: content,
|
371
|
+
content: ops.content,
|
752
372
|
remote: remote,
|
753
|
-
getPath:
|
754
|
-
file:
|
373
|
+
getPath: SelectorProxy.getValPath,
|
374
|
+
file: SelectorProxy.file,
|
755
375
|
richtext: richtext
|
756
376
|
},
|
757
|
-
s:
|
377
|
+
s: SelectorProxy._objectSpread2(SelectorProxy._objectSpread2({}, s), {}, {
|
758
378
|
i18n: undefined
|
759
379
|
})
|
760
380
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
@@ -814,21 +434,21 @@ function derefPatch(patch, document, ops$1) {
|
|
814
434
|
if (result.isErr(maybeDerefRes)) {
|
815
435
|
return maybeDerefRes;
|
816
436
|
}
|
817
|
-
var _maybeDerefRes$value =
|
437
|
+
var _maybeDerefRes$value = SelectorProxy._slicedToArray(maybeDerefRes.value, 2),
|
818
438
|
dereffedPath = _maybeDerefRes$value[0],
|
819
439
|
referencedPath = _maybeDerefRes$value[1];
|
820
440
|
if (referencedPath) {
|
821
441
|
var maybeValue = ops$1.get(document, dereffedPath);
|
822
442
|
if (result.isOk(maybeValue)) {
|
823
443
|
var value = maybeValue.value;
|
824
|
-
if (
|
444
|
+
if (SelectorProxy.isFile(value)) {
|
825
445
|
if (referencedPath.length > 0) {
|
826
446
|
return result.err(new ops.PatchError("Cannot sub-reference file reference at path: ".concat(dereffedPath.join("/"))));
|
827
447
|
}
|
828
448
|
if (typeof op.value !== "string") {
|
829
449
|
return result.err(new ops.PatchError("Expected base64 encoded string value for file reference, got ".concat(JSON.stringify(op.value))));
|
830
450
|
}
|
831
|
-
fileUpdates[value[
|
451
|
+
fileUpdates[value[SelectorProxy.FILE_REF_PROP]] = op.value;
|
832
452
|
} else if (isRemote(value)) {
|
833
453
|
if (!remotePatches[value[REMOTE_REF_PROP]]) {
|
834
454
|
remotePatches[value[REMOTE_REF_PROP]] = [];
|
@@ -852,7 +472,7 @@ function derefPatch(patch, document, ops$1) {
|
|
852
472
|
if (result.isErr(_maybeDerefRes)) {
|
853
473
|
return _maybeDerefRes;
|
854
474
|
}
|
855
|
-
var _maybeDerefRes$value2 =
|
475
|
+
var _maybeDerefRes$value2 = SelectorProxy._slicedToArray(_maybeDerefRes.value, 2),
|
856
476
|
_referencedPath = _maybeDerefRes$value2[1];
|
857
477
|
if (_referencedPath) {
|
858
478
|
throw new Error("Unimplemented operation: ".concat(JSON.stringify(op)));
|
@@ -883,52 +503,52 @@ locale) {
|
|
883
503
|
|
884
504
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
885
505
|
function isArrayOrArraySelector(child) {
|
886
|
-
if (
|
887
|
-
return
|
506
|
+
if (SelectorProxy.isSelector(child)) {
|
507
|
+
return SelectorProxy._typeof(child[SelectorProxy.SourceOrExpr]) === "object" && SelectorProxy._typeof(child[SelectorProxy.SourceOrExpr]) !== null && Array.isArray(child[SelectorProxy.SourceOrExpr]);
|
888
508
|
}
|
889
509
|
return Array.isArray(child);
|
890
510
|
}
|
891
511
|
|
892
512
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
893
513
|
function isObjectOrObjectSelector(child) {
|
894
|
-
if (
|
895
|
-
return
|
514
|
+
if (SelectorProxy.isSelector(child)) {
|
515
|
+
return SelectorProxy._typeof(child[SelectorProxy.SourceOrExpr]) === "object" && SelectorProxy._typeof(child[SelectorProxy.SourceOrExpr]) !== null && !Array.isArray(child[SelectorProxy.SourceOrExpr]);
|
896
516
|
}
|
897
|
-
return
|
517
|
+
return SelectorProxy._typeof(child) === "object";
|
898
518
|
}
|
899
519
|
function serializedValOfSelectorSource(selector) {
|
900
|
-
var wrappedSelector =
|
520
|
+
var wrappedSelector = SelectorProxy.newSelectorProxy(selector); // NOTE: we do this if call-site uses a literal with selectors inside
|
901
521
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
902
522
|
function rec(child) {
|
903
523
|
var isArray = isArrayOrArraySelector(child);
|
904
524
|
var isObject = isObjectOrObjectSelector(child);
|
905
525
|
if (isArray) {
|
906
|
-
var array =
|
907
|
-
var valPath =
|
526
|
+
var array = SelectorProxy.SourceOrExpr in child ? child[SelectorProxy.SourceOrExpr] : child;
|
527
|
+
var valPath = SelectorProxy.Path in child ? child[SelectorProxy.Path] : undefined;
|
908
528
|
return {
|
909
529
|
val: array.map(function (item, i) {
|
910
|
-
return rec(
|
911
|
-
? item :
|
530
|
+
return rec(SelectorProxy.isSelector(item) // NOTE: We do this since selectors currently do not create selectors of items unless specifically required.
|
531
|
+
? item : SelectorProxy.newSelectorProxy(item, SelectorProxy.createValPathOfItem(valPath, i)));
|
912
532
|
}),
|
913
533
|
valPath: valPath
|
914
534
|
};
|
915
535
|
} else if (isObject) {
|
916
|
-
var obj =
|
917
|
-
var _valPath =
|
536
|
+
var obj = SelectorProxy.SourceOrExpr in child ? child[SelectorProxy.SourceOrExpr] : child;
|
537
|
+
var _valPath = SelectorProxy.Path in child ? child[SelectorProxy.Path] : undefined;
|
918
538
|
return {
|
919
539
|
val: obj !== null && Object.fromEntries(Object.entries(obj).map(function (_ref) {
|
920
|
-
var _ref2 =
|
540
|
+
var _ref2 = SelectorProxy._slicedToArray(_ref, 2),
|
921
541
|
key = _ref2[0],
|
922
542
|
value = _ref2[1];
|
923
|
-
return [key, rec(
|
924
|
-
? value :
|
543
|
+
return [key, rec(SelectorProxy.isSelector(value) // NOTE: We do this since selectors currently do not create selectors of items unless specifically required.
|
544
|
+
? value : SelectorProxy.newSelectorProxy(value, SelectorProxy.createValPathOfItem(_valPath, key)))];
|
925
545
|
})),
|
926
546
|
valPath: _valPath
|
927
547
|
};
|
928
|
-
} else if (
|
548
|
+
} else if (SelectorProxy.isSelector(child)) {
|
929
549
|
return {
|
930
|
-
val: rec(child[
|
931
|
-
valPath: child[
|
550
|
+
val: rec(child[SelectorProxy.SourceOrExpr]),
|
551
|
+
valPath: child[SelectorProxy.Path]
|
932
552
|
};
|
933
553
|
} else {
|
934
554
|
return child;
|
@@ -937,11 +557,11 @@ function serializedValOfSelectorSource(selector) {
|
|
937
557
|
return rec(wrappedSelector);
|
938
558
|
}
|
939
559
|
function strip(value) {
|
940
|
-
var val =
|
941
|
-
switch (
|
560
|
+
var val = SelectorProxy.isSerializedVal(value) ? value.val : value;
|
561
|
+
switch (SelectorProxy._typeof(val)) {
|
942
562
|
case "function":
|
943
563
|
case "symbol":
|
944
|
-
throw Error("Invalid val type: ".concat(
|
564
|
+
throw Error("Invalid val type: ".concat(SelectorProxy._typeof(val)));
|
945
565
|
case "object":
|
946
566
|
if (val === null) {
|
947
567
|
return null;
|
@@ -949,7 +569,7 @@ function strip(value) {
|
|
949
569
|
return val.map(strip);
|
950
570
|
} else {
|
951
571
|
return Object.fromEntries(Object.entries(val).map(function (_ref3) {
|
952
|
-
var _ref4 =
|
572
|
+
var _ref4 = SelectorProxy._slicedToArray(_ref3, 2),
|
953
573
|
key = _ref4[0],
|
954
574
|
value = _ref4[1];
|
955
575
|
return [key, value && strip(value)];
|
@@ -964,10 +584,10 @@ function strip(value) {
|
|
964
584
|
function newValProxy(val) {
|
965
585
|
var _ref5;
|
966
586
|
var source = val.val;
|
967
|
-
switch (
|
587
|
+
switch (SelectorProxy._typeof(source)) {
|
968
588
|
case "function":
|
969
589
|
case "symbol":
|
970
|
-
throw Error("Invalid val type: ".concat(
|
590
|
+
throw Error("Invalid val type: ".concat(SelectorProxy._typeof(source)));
|
971
591
|
case "object":
|
972
592
|
if (source !== null) {
|
973
593
|
// Handles both objects and arrays!
|
@@ -976,13 +596,13 @@ function newValProxy(val) {
|
|
976
596
|
if (prop === "val") {
|
977
597
|
return true;
|
978
598
|
}
|
979
|
-
if (prop ===
|
599
|
+
if (prop === SelectorProxy.Path) {
|
980
600
|
return true;
|
981
601
|
}
|
982
602
|
return hasOwn(target, prop);
|
983
603
|
},
|
984
604
|
get: function get(target, prop) {
|
985
|
-
if (prop ===
|
605
|
+
if (prop === SelectorProxy.Path) {
|
986
606
|
return val.valPath;
|
987
607
|
}
|
988
608
|
if (prop === "val") {
|
@@ -995,7 +615,7 @@ function newValProxy(val) {
|
|
995
615
|
var _Reflect$get$valPath, _Reflect$get;
|
996
616
|
return newValProxy({
|
997
617
|
val: Reflect.get(target, prop).val,
|
998
|
-
valPath: (_Reflect$get$valPath = (_Reflect$get = Reflect.get(target, prop)) === null || _Reflect$get === void 0 ? void 0 : _Reflect$get.valPath) !== null && _Reflect$get$valPath !== void 0 ? _Reflect$get$valPath :
|
618
|
+
valPath: (_Reflect$get$valPath = (_Reflect$get = Reflect.get(target, prop)) === null || _Reflect$get === void 0 ? void 0 : _Reflect$get.valPath) !== null && _Reflect$get$valPath !== void 0 ? _Reflect$get$valPath : SelectorProxy.createValPathOfItem(val.valPath, Array.isArray(target) ? Number(prop) : prop)
|
999
619
|
});
|
1000
620
|
}
|
1001
621
|
return Reflect.get(target, prop);
|
@@ -1005,7 +625,7 @@ function newValProxy(val) {
|
|
1005
625
|
// intentional fallthrough
|
1006
626
|
// eslint-disable-next-line no-fallthrough
|
1007
627
|
default:
|
1008
|
-
return _ref5 = {},
|
628
|
+
return _ref5 = {}, SelectorProxy._defineProperty(_ref5, SelectorProxy.Path, val.valPath), SelectorProxy._defineProperty(_ref5, "val", val.val), _ref5;
|
1009
629
|
}
|
1010
630
|
}
|
1011
631
|
function hasOwn(obj, prop) {
|
@@ -1013,21 +633,21 @@ function hasOwn(obj, prop) {
|
|
1013
633
|
}
|
1014
634
|
|
1015
635
|
var Internal = {
|
1016
|
-
convertImageSource:
|
1017
|
-
getSchema:
|
1018
|
-
getValPath:
|
636
|
+
convertImageSource: SelectorProxy.convertImageSource,
|
637
|
+
getSchema: SelectorProxy.getSchema,
|
638
|
+
getValPath: SelectorProxy.getValPath,
|
1019
639
|
getVal: getVal,
|
1020
|
-
getRawSource: getRawSource,
|
1021
|
-
resolvePath: resolvePath,
|
1022
|
-
splitModuleIdAndModulePath: splitModuleIdAndModulePath,
|
640
|
+
getRawSource: ops.getRawSource,
|
641
|
+
resolvePath: ops.resolvePath,
|
642
|
+
splitModuleIdAndModulePath: ops.splitModuleIdAndModulePath,
|
1023
643
|
fetchVal: fetchVal,
|
1024
|
-
isVal:
|
644
|
+
isVal: SelectorProxy.isVal
|
1025
645
|
};
|
1026
646
|
|
1027
|
-
exports.FILE_REF_PROP =
|
1028
|
-
exports.GenericSelector =
|
1029
|
-
exports.Schema =
|
1030
|
-
exports.VAL_EXTENSION =
|
647
|
+
exports.FILE_REF_PROP = SelectorProxy.FILE_REF_PROP;
|
648
|
+
exports.GenericSelector = SelectorProxy.GenericSelector;
|
649
|
+
exports.Schema = SelectorProxy.Schema;
|
650
|
+
exports.VAL_EXTENSION = SelectorProxy.VAL_EXTENSION;
|
1031
651
|
exports.expr = expr_dist_valbuildCoreExpr.index;
|
1032
652
|
exports.Internal = Internal;
|
1033
653
|
exports.derefPatch = derefPatch;
|