@valbuild/core 0.16.0 → 0.17.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/ROADMAP.md +106 -0
- package/dist/declarations/src/ValApi.d.ts +26 -0
- package/dist/declarations/src/expr/eval.d.ts +1 -1
- package/dist/declarations/src/future/fetchVal.d.ts +5 -0
- package/dist/declarations/src/index.d.ts +36 -9
- package/dist/declarations/src/initSchema.d.ts +2 -10
- package/dist/declarations/src/initVal.d.ts +3 -21
- package/dist/declarations/src/module.d.ts +2 -14
- package/dist/declarations/src/schema/image.d.ts +1 -1
- package/dist/declarations/src/schema/index.d.ts +3 -5
- package/dist/declarations/src/schema/keyOf.d.ts +23 -0
- package/dist/declarations/src/schema/record.d.ts +19 -0
- package/dist/declarations/src/schema/union.d.ts +1 -0
- package/dist/declarations/src/selector/SelectorProxy.d.ts +7 -0
- package/dist/declarations/src/selector/array.d.ts +2 -13
- package/dist/declarations/src/selector/file.d.ts +1 -4
- package/dist/declarations/src/selector/future/array.d.ts +17 -0
- package/dist/declarations/src/selector/future/boolean.d.ts +2 -0
- package/dist/declarations/src/selector/future/file.d.ts +9 -0
- package/dist/declarations/src/selector/{i18n.d.ts → future/i18n.d.ts} +2 -2
- package/dist/declarations/src/selector/future/index.d.ts +81 -0
- package/dist/declarations/src/selector/future/number.d.ts +2 -0
- package/dist/declarations/src/selector/future/object.d.ts +10 -0
- package/dist/declarations/src/selector/future/primitive.d.ts +9 -0
- package/dist/declarations/src/selector/{remote.d.ts → future/remote.d.ts} +1 -1
- package/dist/declarations/src/selector/future/string.d.ts +2 -0
- package/dist/declarations/src/selector/index.d.ts +5 -32
- package/dist/declarations/src/selector/object.d.ts +2 -9
- package/dist/declarations/src/selector/primitive.d.ts +3 -9
- package/dist/declarations/src/source/{i18n.d.ts → future/i18n.d.ts} +2 -2
- package/dist/declarations/src/source/{remote.d.ts → future/remote.d.ts} +3 -3
- package/dist/declarations/src/source/index.d.ts +4 -3
- package/dist/declarations/src/val/index.d.ts +2 -2
- package/dist/{SelectorProxy-63c2d0e2.esm.js → index-369caccf.esm.js} +23 -195
- package/dist/{index-af761363.esm.js → index-3e3e839e.esm.js} +189 -1
- package/dist/{index-2fff5ca8.cjs.dev.js → index-486c7fbf.cjs.dev.js} +242 -54
- package/dist/{index-cac9ecbd.cjs.prod.js → index-601a7d73.cjs.prod.js} +242 -54
- package/dist/{SelectorProxy-2af1b2b8.cjs.prod.js → index-8706c87e.cjs.prod.js} +25 -199
- package/dist/{SelectorProxy-873782a5.cjs.dev.js → index-a6e642dd.cjs.dev.js} +25 -199
- package/dist/{ops-1b6e0e35.cjs.prod.js → ops-0d09f8ee.cjs.prod.js} +258 -126
- package/dist/{ops-74661336.esm.js → ops-23a5abb2.esm.js} +195 -65
- package/dist/{ops-ea4827fc.cjs.dev.js → ops-f3015423.cjs.dev.js} +258 -126
- package/dist/valbuild-core.cjs.dev.js +585 -198
- package/dist/valbuild-core.cjs.prod.js +585 -198
- package/dist/valbuild-core.esm.js +520 -134
- 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 -3
- package/patch/dist/valbuild-core-patch.cjs.dev.js +24 -24
- package/patch/dist/valbuild-core-patch.cjs.prod.js +24 -24
- package/patch/dist/valbuild-core-patch.esm.js +3 -3
- package/src/ValApi.ts +85 -0
- package/src/expr/eval.test.ts +2 -2
- package/src/expr/eval.ts +2 -2
- package/src/{fetchVal.test.ts → future/fetchVal.test.ts} +57 -57
- package/src/{fetchVal.ts → future/fetchVal.ts} +17 -22
- package/src/index.ts +46 -14
- package/src/initSchema.ts +11 -12
- package/src/initVal.ts +42 -52
- package/src/module.test.ts +40 -40
- package/src/module.ts +53 -43
- package/src/patch/deref.test.ts +1 -1
- package/src/patch/deref.ts +1 -1
- package/src/patch/json.test.ts +0 -1
- package/src/schema/{i18n.ts → future/i18n.ts} +12 -10
- package/src/schema/{oneOf.ts → future/oneOf.ts} +19 -17
- package/src/schema/image.ts +1 -1
- package/src/schema/index.ts +16 -13
- package/src/schema/keyOf.ts +167 -0
- package/src/schema/record.ts +103 -0
- package/src/schema/union.ts +1 -1
- package/src/schema/validation.test.ts +195 -130
- package/src/selector/SelectorProxy.ts +15 -15
- package/src/selector/array.ts +2 -26
- package/src/selector/file.ts +1 -9
- package/src/selector/{ExprProxy.test.ts → future/ExprProxy.test.ts} +2 -2
- package/src/selector/{ExprProxy.ts → future/ExprProxy.ts} +9 -2
- package/src/selector/{SelectorProxy.test.ts → future/SelectorProxy.test.ts} +4 -4
- package/src/selector/future/SelectorProxy.ts +238 -0
- package/src/selector/future/array.ts +37 -0
- package/src/selector/future/boolean.ts +4 -0
- package/src/selector/future/file.ts +14 -0
- package/src/selector/{i18n.ts → future/i18n.ts} +2 -2
- package/src/selector/future/index.ts +165 -0
- package/src/selector/future/number.ts +4 -0
- package/src/selector/future/object.ts +22 -0
- package/src/selector/future/primitive.ts +17 -0
- package/src/selector/{remote.ts → future/remote.ts} +1 -1
- package/src/selector/{selector.test.ts → future/selector.test.ts} +8 -28
- package/src/selector/{selectorOf.ts → future/selectorOf.ts} +1 -1
- package/src/selector/future/string.ts +4 -0
- package/src/selector/index.ts +4 -46
- package/src/selector/object.ts +2 -19
- package/src/selector/primitive.ts +3 -16
- package/src/source/{i18n.ts → future/i18n.ts} +2 -2
- package/src/source/{remote.ts → future/remote.ts} +3 -3
- package/src/source/index.ts +3 -2
- package/src/val/array.ts +1 -1
- package/src/val/index.ts +2 -2
- package/src/val/object.ts +1 -1
- package/dist/declarations/src/fetchVal.d.ts +0 -5
- package/dist/declarations/src/schema/i18n.d.ts +0 -22
- package/dist/declarations/src/schema/oneOf.d.ts +0 -23
@@ -2,98 +2,32 @@
|
|
2
2
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
|
-
var
|
6
|
-
var ops = require('./ops-
|
7
|
-
var expr_dist_valbuildCoreExpr = require('./index-
|
5
|
+
var index = require('./index-a6e642dd.cjs.dev.js');
|
6
|
+
var ops = require('./ops-f3015423.cjs.dev.js');
|
7
|
+
var expr_dist_valbuildCoreExpr = require('./index-486c7fbf.cjs.dev.js');
|
8
8
|
var result = require('./result-48320acd.cjs.dev.js');
|
9
9
|
|
10
|
-
var OneOfSchema = /*#__PURE__*/function (_Schema) {
|
11
|
-
SelectorProxy._inherits(OneOfSchema, _Schema);
|
12
|
-
var _super = SelectorProxy._createSuper(OneOfSchema);
|
13
|
-
function OneOfSchema(selector) {
|
14
|
-
var _this;
|
15
|
-
var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
16
|
-
SelectorProxy._classCallCheck(this, OneOfSchema);
|
17
|
-
_this = _super.call(this);
|
18
|
-
_this.selector = selector;
|
19
|
-
_this.opt = opt;
|
20
|
-
return _this;
|
21
|
-
}
|
22
|
-
SelectorProxy._createClass(OneOfSchema, [{
|
23
|
-
key: "validate",
|
24
|
-
value: function validate(path, src) {
|
25
|
-
throw new Error("Method not implemented.");
|
26
|
-
}
|
27
|
-
}, {
|
28
|
-
key: "assert",
|
29
|
-
value: function assert(src) {
|
30
|
-
throw new Error("Method not implemented.");
|
31
|
-
}
|
32
|
-
}, {
|
33
|
-
key: "optional",
|
34
|
-
value: function optional() {
|
35
|
-
return new OneOfSchema(this.selector, true);
|
36
|
-
}
|
37
|
-
}, {
|
38
|
-
key: "serialize",
|
39
|
-
value: function serialize() {
|
40
|
-
var path = SelectorProxy.getValPath(this.selector);
|
41
|
-
if (!path) {
|
42
|
-
throw new Error("Cannot serialize oneOf schema with empty selector. Make sure a Val module is used.");
|
43
|
-
}
|
44
|
-
return {
|
45
|
-
type: "oneOf",
|
46
|
-
selector: path,
|
47
|
-
opt: this.opt
|
48
|
-
};
|
49
|
-
}
|
50
|
-
}]);
|
51
|
-
return OneOfSchema;
|
52
|
-
}(SelectorProxy.Schema);
|
53
|
-
var oneOf = function oneOf(valModule) {
|
54
|
-
return new OneOfSchema(valModule);
|
55
|
-
};
|
56
|
-
|
57
|
-
/**
|
58
|
-
* I18n sources cannot have nested remote sources.
|
59
|
-
*/
|
60
|
-
|
61
|
-
/**
|
62
|
-
* An i18n source is a map of locales to sources.
|
63
|
-
*
|
64
|
-
* Its selector will default to the underlying source. It is possible to call `.all` on i18n sources, which returns an object with all the locales
|
65
|
-
*
|
66
|
-
*/
|
67
|
-
|
68
|
-
function i18n(
|
69
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
70
|
-
locales) {
|
71
|
-
return function (source) {
|
72
|
-
return SelectorProxy._objectSpread2(SelectorProxy._objectSpread2({}, source), {}, SelectorProxy._defineProperty({}, SelectorProxy.VAL_EXTENSION, "i18n"));
|
73
|
-
};
|
74
|
-
}
|
75
|
-
|
76
10
|
var NumberSchema = /*#__PURE__*/function (_Schema) {
|
77
|
-
|
78
|
-
var _super =
|
11
|
+
index._inherits(NumberSchema, _Schema);
|
12
|
+
var _super = index._createSuper(NumberSchema);
|
79
13
|
function NumberSchema(options) {
|
80
14
|
var _this;
|
81
15
|
var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
82
|
-
|
16
|
+
index._classCallCheck(this, NumberSchema);
|
83
17
|
_this = _super.call(this);
|
84
18
|
_this.options = options;
|
85
19
|
_this.opt = opt;
|
86
20
|
return _this;
|
87
21
|
}
|
88
|
-
|
22
|
+
index._createClass(NumberSchema, [{
|
89
23
|
key: "validate",
|
90
24
|
value: function validate(path, src) {
|
91
25
|
if (this.opt && (src === null || src === undefined)) {
|
92
26
|
return false;
|
93
27
|
}
|
94
28
|
if (typeof src !== "number") {
|
95
|
-
return
|
96
|
-
message: "Expected 'number', got '".concat(
|
29
|
+
return index._defineProperty({}, path, [{
|
30
|
+
message: "Expected 'number', got '".concat(index._typeof(src), "'"),
|
97
31
|
value: src
|
98
32
|
}]);
|
99
33
|
}
|
@@ -123,32 +57,32 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
|
|
123
57
|
}
|
124
58
|
}]);
|
125
59
|
return NumberSchema;
|
126
|
-
}(
|
60
|
+
}(index.Schema);
|
127
61
|
var number = function number(options) {
|
128
62
|
return new NumberSchema(options);
|
129
63
|
};
|
130
64
|
|
131
65
|
var StringSchema = /*#__PURE__*/function (_Schema) {
|
132
|
-
|
133
|
-
var _super =
|
66
|
+
index._inherits(StringSchema, _Schema);
|
67
|
+
var _super = index._createSuper(StringSchema);
|
134
68
|
function StringSchema(options) {
|
135
69
|
var _this;
|
136
70
|
var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
137
|
-
|
71
|
+
index._classCallCheck(this, StringSchema);
|
138
72
|
_this = _super.call(this);
|
139
73
|
_this.options = options;
|
140
74
|
_this.opt = opt;
|
141
75
|
return _this;
|
142
76
|
}
|
143
|
-
|
77
|
+
index._createClass(StringSchema, [{
|
144
78
|
key: "validate",
|
145
79
|
value: function validate(path, src) {
|
146
80
|
if (this.opt && (src === null || src === undefined)) {
|
147
81
|
return false;
|
148
82
|
}
|
149
83
|
if (typeof src !== "string") {
|
150
|
-
return
|
151
|
-
message: "Expected 'string', got '".concat(
|
84
|
+
return index._defineProperty({}, path, [{
|
85
|
+
message: "Expected 'string', got '".concat(index._typeof(src), "'"),
|
152
86
|
value: src
|
153
87
|
}]);
|
154
88
|
}
|
@@ -178,31 +112,31 @@ var StringSchema = /*#__PURE__*/function (_Schema) {
|
|
178
112
|
}
|
179
113
|
}]);
|
180
114
|
return StringSchema;
|
181
|
-
}(
|
115
|
+
}(index.Schema);
|
182
116
|
var string = function string(options) {
|
183
117
|
return new StringSchema(options);
|
184
118
|
};
|
185
119
|
|
186
120
|
var BooleanSchema = /*#__PURE__*/function (_Schema) {
|
187
|
-
|
188
|
-
var _super =
|
121
|
+
index._inherits(BooleanSchema, _Schema);
|
122
|
+
var _super = index._createSuper(BooleanSchema);
|
189
123
|
function BooleanSchema() {
|
190
124
|
var _this;
|
191
125
|
var opt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
192
|
-
|
126
|
+
index._classCallCheck(this, BooleanSchema);
|
193
127
|
_this = _super.call(this);
|
194
128
|
_this.opt = opt;
|
195
129
|
return _this;
|
196
130
|
}
|
197
|
-
|
131
|
+
index._createClass(BooleanSchema, [{
|
198
132
|
key: "validate",
|
199
133
|
value: function validate(path, src) {
|
200
134
|
if (this.opt && (src === null || src === undefined)) {
|
201
135
|
return false;
|
202
136
|
}
|
203
137
|
if (typeof src !== "boolean") {
|
204
|
-
return
|
205
|
-
message: "Expected 'boolean', got '".concat(
|
138
|
+
return index._defineProperty({}, path, [{
|
139
|
+
message: "Expected 'boolean', got '".concat(index._typeof(src), "'"),
|
206
140
|
value: src
|
207
141
|
}]);
|
208
142
|
}
|
@@ -231,37 +165,37 @@ var BooleanSchema = /*#__PURE__*/function (_Schema) {
|
|
231
165
|
}
|
232
166
|
}]);
|
233
167
|
return BooleanSchema;
|
234
|
-
}(
|
168
|
+
}(index.Schema);
|
235
169
|
var _boolean = function _boolean() {
|
236
170
|
return new BooleanSchema();
|
237
171
|
};
|
238
172
|
|
239
173
|
var LiteralSchema = /*#__PURE__*/function (_Schema) {
|
240
|
-
|
241
|
-
var _super =
|
174
|
+
index._inherits(LiteralSchema, _Schema);
|
175
|
+
var _super = index._createSuper(LiteralSchema);
|
242
176
|
function LiteralSchema(value) {
|
243
177
|
var _this;
|
244
178
|
var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
245
|
-
|
179
|
+
index._classCallCheck(this, LiteralSchema);
|
246
180
|
_this = _super.call(this);
|
247
181
|
_this.value = value;
|
248
182
|
_this.opt = opt;
|
249
183
|
return _this;
|
250
184
|
}
|
251
|
-
|
185
|
+
index._createClass(LiteralSchema, [{
|
252
186
|
key: "validate",
|
253
187
|
value: function validate(path, src) {
|
254
188
|
if (this.opt && (src === null || src === undefined)) {
|
255
189
|
return false;
|
256
190
|
}
|
257
191
|
if (typeof src !== "string") {
|
258
|
-
return
|
259
|
-
message: "Expected 'string', got '".concat(
|
192
|
+
return index._defineProperty({}, path, [{
|
193
|
+
message: "Expected 'string', got '".concat(index._typeof(src), "'"),
|
260
194
|
value: src
|
261
195
|
}]);
|
262
196
|
}
|
263
197
|
if (src !== this.value) {
|
264
|
-
return
|
198
|
+
return index._defineProperty({}, path, [{
|
265
199
|
message: "Expected literal '".concat(this.value, "', got '").concat(src, "'"),
|
266
200
|
value: src
|
267
201
|
}]);
|
@@ -292,12 +226,19 @@ var LiteralSchema = /*#__PURE__*/function (_Schema) {
|
|
292
226
|
}
|
293
227
|
}]);
|
294
228
|
return LiteralSchema;
|
295
|
-
}(
|
229
|
+
}(index.Schema);
|
296
230
|
var literal = function literal(value) {
|
297
231
|
return new LiteralSchema(value);
|
298
232
|
};
|
299
233
|
|
300
|
-
|
234
|
+
// import type { F } from "ts-toolbelt";
|
235
|
+
// import { i18n, I18n } from "./schema/future/i18n";
|
236
|
+
// import { oneOf } from "./schema/future/oneOf";
|
237
|
+
// export type InitSchemaLocalized<Locales extends readonly string[]> = {
|
238
|
+
// readonly i18n: I18n<Locales>;
|
239
|
+
// };
|
240
|
+
function initSchema() {
|
241
|
+
// locales: F.Narrow<Locales>
|
301
242
|
return {
|
302
243
|
string: string,
|
303
244
|
"boolean": _boolean,
|
@@ -305,38 +246,18 @@ function initSchema(locales) {
|
|
305
246
|
object: ops.object,
|
306
247
|
number: number,
|
307
248
|
union: ops.union,
|
308
|
-
|
249
|
+
// oneOf,
|
309
250
|
richtext: ops.richtext,
|
310
|
-
image:
|
311
|
-
literal: literal
|
312
|
-
i18n:
|
251
|
+
image: index.image,
|
252
|
+
literal: literal
|
253
|
+
// i18n: i18n(locales),
|
313
254
|
};
|
314
255
|
}
|
315
256
|
|
316
|
-
/**
|
317
|
-
* Remote sources cannot include other remote sources.
|
318
|
-
*/
|
319
|
-
|
320
|
-
var REMOTE_REF_PROP = "_ref"; // TODO: same as FILE_REF_PROP so use same prop?
|
321
|
-
|
322
|
-
/**
|
323
|
-
* A remote source is a hash that represents a remote object.
|
324
|
-
*
|
325
|
-
* It will be resolved into a ValRemote object.
|
326
|
-
*/
|
327
|
-
|
328
|
-
function remote(ref) {
|
329
|
-
var _ref;
|
330
|
-
return _ref = {}, SelectorProxy._defineProperty(_ref, REMOTE_REF_PROP, ref), SelectorProxy._defineProperty(_ref, SelectorProxy.VAL_EXTENSION, "remote"), _ref;
|
331
|
-
}
|
332
|
-
function isRemote(obj) {
|
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";
|
334
|
-
}
|
335
|
-
|
336
257
|
function richtext(data) {
|
337
258
|
if (typeof data === "string") {
|
338
259
|
var _ref;
|
339
|
-
return _ref = {},
|
260
|
+
return _ref = {}, index._defineProperty(_ref, index.VAL_EXTENSION, "richtext"), index._defineProperty(_ref, "type", "root"), index._defineProperty(_ref, "children", [{
|
340
261
|
type: "paragraph",
|
341
262
|
children: [{
|
342
263
|
type: "text",
|
@@ -344,43 +265,58 @@ function richtext(data) {
|
|
344
265
|
}]
|
345
266
|
}]), _ref;
|
346
267
|
}
|
347
|
-
return
|
268
|
+
return index._objectSpread2(index._objectSpread2({}, data), {}, index._defineProperty({}, index.VAL_EXTENSION, "richtext"));
|
348
269
|
}
|
349
270
|
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
271
|
+
// import { i18n, I18n } from "./source/future/i18n";
|
272
|
+
// import { remote } from "./source/future/remote";
|
273
|
+
// type NarrowStrings<A> =
|
274
|
+
// | (A extends [] ? [] : never)
|
275
|
+
// | (A extends string ? A : never)
|
276
|
+
// | {
|
277
|
+
// [K in keyof A]: NarrowStrings<A[K]>;
|
278
|
+
// };
|
279
|
+
// TODO: Rename to createValSystem (only to be used by internal things), we can then export * from '@valbuild/core' in the next package then.
|
280
|
+
var initVal = function initVal() {
|
281
|
+
// const locales = options?.locales;
|
282
|
+
var s = initSchema();
|
283
|
+
// if (locales?.required) {
|
284
|
+
// console.error("Locales / i18n currently not implemented");
|
285
|
+
// return {
|
286
|
+
// val: {
|
287
|
+
// content,
|
288
|
+
// i18n,
|
289
|
+
// remote,
|
290
|
+
// getPath,
|
291
|
+
// file,
|
292
|
+
// richtext,
|
293
|
+
// },
|
294
|
+
// s,
|
295
|
+
// // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
296
|
+
// } as any;
|
297
|
+
// }
|
369
298
|
return {
|
370
299
|
val: {
|
371
300
|
content: ops.content,
|
372
|
-
|
373
|
-
getPath:
|
374
|
-
file:
|
301
|
+
// remote,
|
302
|
+
getPath: index.getValPath,
|
303
|
+
file: index.file,
|
375
304
|
richtext: richtext
|
376
305
|
},
|
377
|
-
s:
|
378
|
-
i18n: undefined
|
379
|
-
})
|
306
|
+
s: index._objectSpread2({}, s)
|
380
307
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
381
308
|
};
|
382
309
|
};
|
383
310
|
|
311
|
+
/**
|
312
|
+
* Remote sources cannot include other remote sources.
|
313
|
+
*/
|
314
|
+
|
315
|
+
var REMOTE_REF_PROP = "_ref"; // TODO: same as FILE_REF_PROP so use same prop?
|
316
|
+
function isRemote(obj) {
|
317
|
+
return index._typeof(obj) === "object" && obj !== null && index.VAL_EXTENSION in obj && obj[index.VAL_EXTENSION] === "remote" && REMOTE_REF_PROP in obj && typeof obj[REMOTE_REF_PROP] === "string";
|
318
|
+
}
|
319
|
+
|
384
320
|
function derefPath(path) {
|
385
321
|
var dereffedPath = [];
|
386
322
|
var referencedPath = null;
|
@@ -434,21 +370,21 @@ function derefPatch(patch, document, ops$1) {
|
|
434
370
|
if (result.isErr(maybeDerefRes)) {
|
435
371
|
return maybeDerefRes;
|
436
372
|
}
|
437
|
-
var _maybeDerefRes$value =
|
373
|
+
var _maybeDerefRes$value = index._slicedToArray(maybeDerefRes.value, 2),
|
438
374
|
dereffedPath = _maybeDerefRes$value[0],
|
439
375
|
referencedPath = _maybeDerefRes$value[1];
|
440
376
|
if (referencedPath) {
|
441
377
|
var maybeValue = ops$1.get(document, dereffedPath);
|
442
378
|
if (result.isOk(maybeValue)) {
|
443
379
|
var value = maybeValue.value;
|
444
|
-
if (
|
380
|
+
if (index.isFile(value)) {
|
445
381
|
if (referencedPath.length > 0) {
|
446
382
|
return result.err(new ops.PatchError("Cannot sub-reference file reference at path: ".concat(dereffedPath.join("/"))));
|
447
383
|
}
|
448
384
|
if (typeof op.value !== "string") {
|
449
385
|
return result.err(new ops.PatchError("Expected base64 encoded string value for file reference, got ".concat(JSON.stringify(op.value))));
|
450
386
|
}
|
451
|
-
fileUpdates[value[
|
387
|
+
fileUpdates[value[index.FILE_REF_PROP]] = op.value;
|
452
388
|
} else if (isRemote(value)) {
|
453
389
|
if (!remotePatches[value[REMOTE_REF_PROP]]) {
|
454
390
|
remotePatches[value[REMOTE_REF_PROP]] = [];
|
@@ -472,7 +408,7 @@ function derefPatch(patch, document, ops$1) {
|
|
472
408
|
if (result.isErr(_maybeDerefRes)) {
|
473
409
|
return _maybeDerefRes;
|
474
410
|
}
|
475
|
-
var _maybeDerefRes$value2 =
|
411
|
+
var _maybeDerefRes$value2 = index._slicedToArray(_maybeDerefRes.value, 2),
|
476
412
|
_referencedPath = _maybeDerefRes$value2[1];
|
477
413
|
if (_referencedPath) {
|
478
414
|
throw new Error("Unimplemented operation: ".concat(JSON.stringify(op)));
|
@@ -492,63 +428,58 @@ function derefPatch(patch, document, ops$1) {
|
|
492
428
|
});
|
493
429
|
}
|
494
430
|
|
495
|
-
function
|
496
|
-
return Promise.resolve(getVal(selector));
|
497
|
-
}
|
498
|
-
function getVal(selector,
|
499
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
500
|
-
locale) {
|
431
|
+
function getVal(selector) {
|
501
432
|
return newValProxy(serializedValOfSelectorSource(selector));
|
502
433
|
}
|
503
434
|
|
504
435
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
505
436
|
function isArrayOrArraySelector(child) {
|
506
|
-
if (
|
507
|
-
return
|
437
|
+
if (ops.isSelector(child)) {
|
438
|
+
return index._typeof(child[index.GetSource]) === "object" && index._typeof(child[index.GetSource]) !== null && Array.isArray(child[index.GetSource]);
|
508
439
|
}
|
509
440
|
return Array.isArray(child);
|
510
441
|
}
|
511
442
|
|
512
443
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
513
444
|
function isObjectOrObjectSelector(child) {
|
514
|
-
if (
|
515
|
-
return
|
445
|
+
if (ops.isSelector(child)) {
|
446
|
+
return index._typeof(child[index.GetSource]) === "object" && index._typeof(child[index.GetSource]) !== null && !Array.isArray(child[index.GetSource]);
|
516
447
|
}
|
517
|
-
return
|
448
|
+
return index._typeof(child) === "object";
|
518
449
|
}
|
519
450
|
function serializedValOfSelectorSource(selector) {
|
520
|
-
var wrappedSelector =
|
451
|
+
var wrappedSelector = ops.newSelectorProxy(selector); // NOTE: we do this if call-site uses a literal with selectors inside
|
521
452
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
522
453
|
function rec(child) {
|
523
454
|
var isArray = isArrayOrArraySelector(child);
|
524
455
|
var isObject = isObjectOrObjectSelector(child);
|
525
456
|
if (isArray) {
|
526
|
-
var array =
|
527
|
-
var valPath =
|
457
|
+
var array = index.GetSource in child ? child[index.GetSource] : child;
|
458
|
+
var valPath = index.Path in child ? child[index.Path] : undefined;
|
528
459
|
return {
|
529
460
|
val: array.map(function (item, i) {
|
530
|
-
return rec(
|
531
|
-
? item :
|
461
|
+
return rec(ops.isSelector(item) // NOTE: We do this since selectors currently do not create selectors of items unless specifically required.
|
462
|
+
? item : ops.newSelectorProxy(item, ops.createValPathOfItem(valPath, i)));
|
532
463
|
}),
|
533
464
|
valPath: valPath
|
534
465
|
};
|
535
466
|
} else if (isObject) {
|
536
|
-
var obj =
|
537
|
-
var _valPath =
|
467
|
+
var obj = index.GetSource in child ? child[index.GetSource] : child;
|
468
|
+
var _valPath = index.Path in child ? child[index.Path] : undefined;
|
538
469
|
return {
|
539
470
|
val: obj !== null && Object.fromEntries(Object.entries(obj).map(function (_ref) {
|
540
|
-
var _ref2 =
|
471
|
+
var _ref2 = index._slicedToArray(_ref, 2),
|
541
472
|
key = _ref2[0],
|
542
473
|
value = _ref2[1];
|
543
|
-
return [key, rec(
|
544
|
-
? value :
|
474
|
+
return [key, rec(ops.isSelector(value) // NOTE: We do this since selectors currently do not create selectors of items unless specifically required.
|
475
|
+
? value : ops.newSelectorProxy(value, ops.createValPathOfItem(_valPath, key)))];
|
545
476
|
})),
|
546
477
|
valPath: _valPath
|
547
478
|
};
|
548
|
-
} else if (
|
479
|
+
} else if (ops.isSelector(child)) {
|
549
480
|
return {
|
550
|
-
val: rec(child[
|
551
|
-
valPath: child[
|
481
|
+
val: rec(child[index.GetSource]),
|
482
|
+
valPath: child[index.Path]
|
552
483
|
};
|
553
484
|
} else {
|
554
485
|
return child;
|
@@ -557,11 +488,11 @@ function serializedValOfSelectorSource(selector) {
|
|
557
488
|
return rec(wrappedSelector);
|
558
489
|
}
|
559
490
|
function strip(value) {
|
560
|
-
var val =
|
561
|
-
switch (
|
491
|
+
var val = index.isSerializedVal(value) ? value.val : value;
|
492
|
+
switch (index._typeof(val)) {
|
562
493
|
case "function":
|
563
494
|
case "symbol":
|
564
|
-
throw Error("Invalid val type: ".concat(
|
495
|
+
throw Error("Invalid val type: ".concat(index._typeof(val)));
|
565
496
|
case "object":
|
566
497
|
if (val === null) {
|
567
498
|
return null;
|
@@ -569,7 +500,7 @@ function strip(value) {
|
|
569
500
|
return val.map(strip);
|
570
501
|
} else {
|
571
502
|
return Object.fromEntries(Object.entries(val).map(function (_ref3) {
|
572
|
-
var _ref4 =
|
503
|
+
var _ref4 = index._slicedToArray(_ref3, 2),
|
573
504
|
key = _ref4[0],
|
574
505
|
value = _ref4[1];
|
575
506
|
return [key, value && strip(value)];
|
@@ -584,10 +515,10 @@ function strip(value) {
|
|
584
515
|
function newValProxy(val) {
|
585
516
|
var _ref5;
|
586
517
|
var source = val.val;
|
587
|
-
switch (
|
518
|
+
switch (index._typeof(source)) {
|
588
519
|
case "function":
|
589
520
|
case "symbol":
|
590
|
-
throw Error("Invalid val type: ".concat(
|
521
|
+
throw Error("Invalid val type: ".concat(index._typeof(source)));
|
591
522
|
case "object":
|
592
523
|
if (source !== null) {
|
593
524
|
// Handles both objects and arrays!
|
@@ -596,13 +527,13 @@ function newValProxy(val) {
|
|
596
527
|
if (prop === "val") {
|
597
528
|
return true;
|
598
529
|
}
|
599
|
-
if (prop ===
|
530
|
+
if (prop === index.Path) {
|
600
531
|
return true;
|
601
532
|
}
|
602
533
|
return hasOwn(target, prop);
|
603
534
|
},
|
604
535
|
get: function get(target, prop) {
|
605
|
-
if (prop ===
|
536
|
+
if (prop === index.Path) {
|
606
537
|
return val.valPath;
|
607
538
|
}
|
608
539
|
if (prop === "val") {
|
@@ -615,7 +546,7 @@ function newValProxy(val) {
|
|
615
546
|
var _Reflect$get$valPath, _Reflect$get;
|
616
547
|
return newValProxy({
|
617
548
|
val: Reflect.get(target, prop).val,
|
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 :
|
549
|
+
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 : ops.createValPathOfItem(val.valPath, Array.isArray(target) ? Number(prop) : prop)
|
619
550
|
});
|
620
551
|
}
|
621
552
|
return Reflect.get(target, prop);
|
@@ -625,30 +556,486 @@ function newValProxy(val) {
|
|
625
556
|
// intentional fallthrough
|
626
557
|
// eslint-disable-next-line no-fallthrough
|
627
558
|
default:
|
628
|
-
return _ref5 = {},
|
559
|
+
return _ref5 = {}, index._defineProperty(_ref5, index.Path, val.valPath), index._defineProperty(_ref5, "val", val.val), _ref5;
|
629
560
|
}
|
630
561
|
}
|
631
562
|
function hasOwn(obj, prop) {
|
632
563
|
return Object.prototype.hasOwnProperty.call(obj, prop);
|
633
564
|
}
|
634
565
|
|
566
|
+
function _regeneratorRuntime() {
|
567
|
+
_regeneratorRuntime = function () {
|
568
|
+
return exports;
|
569
|
+
};
|
570
|
+
var exports = {},
|
571
|
+
Op = Object.prototype,
|
572
|
+
hasOwn = Op.hasOwnProperty,
|
573
|
+
defineProperty = Object.defineProperty || function (obj, key, desc) {
|
574
|
+
obj[key] = desc.value;
|
575
|
+
},
|
576
|
+
$Symbol = "function" == typeof Symbol ? Symbol : {},
|
577
|
+
iteratorSymbol = $Symbol.iterator || "@@iterator",
|
578
|
+
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
|
579
|
+
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
580
|
+
function define(obj, key, value) {
|
581
|
+
return Object.defineProperty(obj, key, {
|
582
|
+
value: value,
|
583
|
+
enumerable: !0,
|
584
|
+
configurable: !0,
|
585
|
+
writable: !0
|
586
|
+
}), obj[key];
|
587
|
+
}
|
588
|
+
try {
|
589
|
+
define({}, "");
|
590
|
+
} catch (err) {
|
591
|
+
define = function (obj, key, value) {
|
592
|
+
return obj[key] = value;
|
593
|
+
};
|
594
|
+
}
|
595
|
+
function wrap(innerFn, outerFn, self, tryLocsList) {
|
596
|
+
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
|
597
|
+
generator = Object.create(protoGenerator.prototype),
|
598
|
+
context = new Context(tryLocsList || []);
|
599
|
+
return defineProperty(generator, "_invoke", {
|
600
|
+
value: makeInvokeMethod(innerFn, self, context)
|
601
|
+
}), generator;
|
602
|
+
}
|
603
|
+
function tryCatch(fn, obj, arg) {
|
604
|
+
try {
|
605
|
+
return {
|
606
|
+
type: "normal",
|
607
|
+
arg: fn.call(obj, arg)
|
608
|
+
};
|
609
|
+
} catch (err) {
|
610
|
+
return {
|
611
|
+
type: "throw",
|
612
|
+
arg: err
|
613
|
+
};
|
614
|
+
}
|
615
|
+
}
|
616
|
+
exports.wrap = wrap;
|
617
|
+
var ContinueSentinel = {};
|
618
|
+
function Generator() {}
|
619
|
+
function GeneratorFunction() {}
|
620
|
+
function GeneratorFunctionPrototype() {}
|
621
|
+
var IteratorPrototype = {};
|
622
|
+
define(IteratorPrototype, iteratorSymbol, function () {
|
623
|
+
return this;
|
624
|
+
});
|
625
|
+
var getProto = Object.getPrototypeOf,
|
626
|
+
NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
627
|
+
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
|
628
|
+
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
629
|
+
function defineIteratorMethods(prototype) {
|
630
|
+
["next", "throw", "return"].forEach(function (method) {
|
631
|
+
define(prototype, method, function (arg) {
|
632
|
+
return this._invoke(method, arg);
|
633
|
+
});
|
634
|
+
});
|
635
|
+
}
|
636
|
+
function AsyncIterator(generator, PromiseImpl) {
|
637
|
+
function invoke(method, arg, resolve, reject) {
|
638
|
+
var record = tryCatch(generator[method], generator, arg);
|
639
|
+
if ("throw" !== record.type) {
|
640
|
+
var result = record.arg,
|
641
|
+
value = result.value;
|
642
|
+
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
643
|
+
invoke("next", value, resolve, reject);
|
644
|
+
}, function (err) {
|
645
|
+
invoke("throw", err, resolve, reject);
|
646
|
+
}) : PromiseImpl.resolve(value).then(function (unwrapped) {
|
647
|
+
result.value = unwrapped, resolve(result);
|
648
|
+
}, function (error) {
|
649
|
+
return invoke("throw", error, resolve, reject);
|
650
|
+
});
|
651
|
+
}
|
652
|
+
reject(record.arg);
|
653
|
+
}
|
654
|
+
var previousPromise;
|
655
|
+
defineProperty(this, "_invoke", {
|
656
|
+
value: function (method, arg) {
|
657
|
+
function callInvokeWithMethodAndArg() {
|
658
|
+
return new PromiseImpl(function (resolve, reject) {
|
659
|
+
invoke(method, arg, resolve, reject);
|
660
|
+
});
|
661
|
+
}
|
662
|
+
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
663
|
+
}
|
664
|
+
});
|
665
|
+
}
|
666
|
+
function makeInvokeMethod(innerFn, self, context) {
|
667
|
+
var state = "suspendedStart";
|
668
|
+
return function (method, arg) {
|
669
|
+
if ("executing" === state) throw new Error("Generator is already running");
|
670
|
+
if ("completed" === state) {
|
671
|
+
if ("throw" === method) throw arg;
|
672
|
+
return doneResult();
|
673
|
+
}
|
674
|
+
for (context.method = method, context.arg = arg;;) {
|
675
|
+
var delegate = context.delegate;
|
676
|
+
if (delegate) {
|
677
|
+
var delegateResult = maybeInvokeDelegate(delegate, context);
|
678
|
+
if (delegateResult) {
|
679
|
+
if (delegateResult === ContinueSentinel) continue;
|
680
|
+
return delegateResult;
|
681
|
+
}
|
682
|
+
}
|
683
|
+
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
|
684
|
+
if ("suspendedStart" === state) throw state = "completed", context.arg;
|
685
|
+
context.dispatchException(context.arg);
|
686
|
+
} else "return" === context.method && context.abrupt("return", context.arg);
|
687
|
+
state = "executing";
|
688
|
+
var record = tryCatch(innerFn, self, context);
|
689
|
+
if ("normal" === record.type) {
|
690
|
+
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
|
691
|
+
return {
|
692
|
+
value: record.arg,
|
693
|
+
done: context.done
|
694
|
+
};
|
695
|
+
}
|
696
|
+
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
|
697
|
+
}
|
698
|
+
};
|
699
|
+
}
|
700
|
+
function maybeInvokeDelegate(delegate, context) {
|
701
|
+
var methodName = context.method,
|
702
|
+
method = delegate.iterator[methodName];
|
703
|
+
if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel;
|
704
|
+
var record = tryCatch(method, delegate.iterator, context.arg);
|
705
|
+
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
|
706
|
+
var info = record.arg;
|
707
|
+
return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
|
708
|
+
}
|
709
|
+
function pushTryEntry(locs) {
|
710
|
+
var entry = {
|
711
|
+
tryLoc: locs[0]
|
712
|
+
};
|
713
|
+
1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
|
714
|
+
}
|
715
|
+
function resetTryEntry(entry) {
|
716
|
+
var record = entry.completion || {};
|
717
|
+
record.type = "normal", delete record.arg, entry.completion = record;
|
718
|
+
}
|
719
|
+
function Context(tryLocsList) {
|
720
|
+
this.tryEntries = [{
|
721
|
+
tryLoc: "root"
|
722
|
+
}], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
|
723
|
+
}
|
724
|
+
function values(iterable) {
|
725
|
+
if (iterable) {
|
726
|
+
var iteratorMethod = iterable[iteratorSymbol];
|
727
|
+
if (iteratorMethod) return iteratorMethod.call(iterable);
|
728
|
+
if ("function" == typeof iterable.next) return iterable;
|
729
|
+
if (!isNaN(iterable.length)) {
|
730
|
+
var i = -1,
|
731
|
+
next = function next() {
|
732
|
+
for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
|
733
|
+
return next.value = undefined, next.done = !0, next;
|
734
|
+
};
|
735
|
+
return next.next = next;
|
736
|
+
}
|
737
|
+
}
|
738
|
+
return {
|
739
|
+
next: doneResult
|
740
|
+
};
|
741
|
+
}
|
742
|
+
function doneResult() {
|
743
|
+
return {
|
744
|
+
value: undefined,
|
745
|
+
done: !0
|
746
|
+
};
|
747
|
+
}
|
748
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", {
|
749
|
+
value: GeneratorFunctionPrototype,
|
750
|
+
configurable: !0
|
751
|
+
}), defineProperty(GeneratorFunctionPrototype, "constructor", {
|
752
|
+
value: GeneratorFunction,
|
753
|
+
configurable: !0
|
754
|
+
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
|
755
|
+
var ctor = "function" == typeof genFun && genFun.constructor;
|
756
|
+
return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
|
757
|
+
}, exports.mark = function (genFun) {
|
758
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
|
759
|
+
}, exports.awrap = function (arg) {
|
760
|
+
return {
|
761
|
+
__await: arg
|
762
|
+
};
|
763
|
+
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
|
764
|
+
return this;
|
765
|
+
}), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
766
|
+
void 0 === PromiseImpl && (PromiseImpl = Promise);
|
767
|
+
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
768
|
+
return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
|
769
|
+
return result.done ? result.value : iter.next();
|
770
|
+
});
|
771
|
+
}, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
|
772
|
+
return this;
|
773
|
+
}), define(Gp, "toString", function () {
|
774
|
+
return "[object Generator]";
|
775
|
+
}), exports.keys = function (val) {
|
776
|
+
var object = Object(val),
|
777
|
+
keys = [];
|
778
|
+
for (var key in object) keys.push(key);
|
779
|
+
return keys.reverse(), function next() {
|
780
|
+
for (; keys.length;) {
|
781
|
+
var key = keys.pop();
|
782
|
+
if (key in object) return next.value = key, next.done = !1, next;
|
783
|
+
}
|
784
|
+
return next.done = !0, next;
|
785
|
+
};
|
786
|
+
}, exports.values = values, Context.prototype = {
|
787
|
+
constructor: Context,
|
788
|
+
reset: function (skipTempReset) {
|
789
|
+
if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
|
790
|
+
},
|
791
|
+
stop: function () {
|
792
|
+
this.done = !0;
|
793
|
+
var rootRecord = this.tryEntries[0].completion;
|
794
|
+
if ("throw" === rootRecord.type) throw rootRecord.arg;
|
795
|
+
return this.rval;
|
796
|
+
},
|
797
|
+
dispatchException: function (exception) {
|
798
|
+
if (this.done) throw exception;
|
799
|
+
var context = this;
|
800
|
+
function handle(loc, caught) {
|
801
|
+
return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
|
802
|
+
}
|
803
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
804
|
+
var entry = this.tryEntries[i],
|
805
|
+
record = entry.completion;
|
806
|
+
if ("root" === entry.tryLoc) return handle("end");
|
807
|
+
if (entry.tryLoc <= this.prev) {
|
808
|
+
var hasCatch = hasOwn.call(entry, "catchLoc"),
|
809
|
+
hasFinally = hasOwn.call(entry, "finallyLoc");
|
810
|
+
if (hasCatch && hasFinally) {
|
811
|
+
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
812
|
+
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
813
|
+
} else if (hasCatch) {
|
814
|
+
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
815
|
+
} else {
|
816
|
+
if (!hasFinally) throw new Error("try statement without catch or finally");
|
817
|
+
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
818
|
+
}
|
819
|
+
}
|
820
|
+
}
|
821
|
+
},
|
822
|
+
abrupt: function (type, arg) {
|
823
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
824
|
+
var entry = this.tryEntries[i];
|
825
|
+
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
826
|
+
var finallyEntry = entry;
|
827
|
+
break;
|
828
|
+
}
|
829
|
+
}
|
830
|
+
finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
|
831
|
+
var record = finallyEntry ? finallyEntry.completion : {};
|
832
|
+
return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
|
833
|
+
},
|
834
|
+
complete: function (record, afterLoc) {
|
835
|
+
if ("throw" === record.type) throw record.arg;
|
836
|
+
return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
|
837
|
+
},
|
838
|
+
finish: function (finallyLoc) {
|
839
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
840
|
+
var entry = this.tryEntries[i];
|
841
|
+
if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
|
842
|
+
}
|
843
|
+
},
|
844
|
+
catch: function (tryLoc) {
|
845
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
846
|
+
var entry = this.tryEntries[i];
|
847
|
+
if (entry.tryLoc === tryLoc) {
|
848
|
+
var record = entry.completion;
|
849
|
+
if ("throw" === record.type) {
|
850
|
+
var thrown = record.arg;
|
851
|
+
resetTryEntry(entry);
|
852
|
+
}
|
853
|
+
return thrown;
|
854
|
+
}
|
855
|
+
}
|
856
|
+
throw new Error("illegal catch attempt");
|
857
|
+
},
|
858
|
+
delegateYield: function (iterable, resultName, nextLoc) {
|
859
|
+
return this.delegate = {
|
860
|
+
iterator: values(iterable),
|
861
|
+
resultName: resultName,
|
862
|
+
nextLoc: nextLoc
|
863
|
+
}, "next" === this.method && (this.arg = undefined), ContinueSentinel;
|
864
|
+
}
|
865
|
+
}, exports;
|
866
|
+
}
|
867
|
+
|
868
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
869
|
+
try {
|
870
|
+
var info = gen[key](arg);
|
871
|
+
var value = info.value;
|
872
|
+
} catch (error) {
|
873
|
+
reject(error);
|
874
|
+
return;
|
875
|
+
}
|
876
|
+
if (info.done) {
|
877
|
+
resolve(value);
|
878
|
+
} else {
|
879
|
+
Promise.resolve(value).then(_next, _throw);
|
880
|
+
}
|
881
|
+
}
|
882
|
+
function _asyncToGenerator(fn) {
|
883
|
+
return function () {
|
884
|
+
var self = this,
|
885
|
+
args = arguments;
|
886
|
+
return new Promise(function (resolve, reject) {
|
887
|
+
var gen = fn.apply(self, args);
|
888
|
+
function _next(value) {
|
889
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
890
|
+
}
|
891
|
+
function _throw(err) {
|
892
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
893
|
+
}
|
894
|
+
_next(undefined);
|
895
|
+
});
|
896
|
+
};
|
897
|
+
}
|
898
|
+
|
899
|
+
// TODO: move this to internal, only reason this is here is that react, ui and server all depend on it
|
900
|
+
var ValApi = /*#__PURE__*/function () {
|
901
|
+
function ValApi(host) {
|
902
|
+
index._classCallCheck(this, ValApi);
|
903
|
+
this.host = host;
|
904
|
+
}
|
905
|
+
index._createClass(ValApi, [{
|
906
|
+
key: "getDisableUrl",
|
907
|
+
value: function getDisableUrl() {
|
908
|
+
return "".concat(this.host, "/disable");
|
909
|
+
}
|
910
|
+
}, {
|
911
|
+
key: "postPatches",
|
912
|
+
value: function postPatches(moduleId, patches, commit, headers) {
|
913
|
+
var params = "";
|
914
|
+
if (commit) {
|
915
|
+
var p = new URLSearchParams();
|
916
|
+
p.set("commit", commit);
|
917
|
+
params = "?".concat(p.toString());
|
918
|
+
}
|
919
|
+
return fetch("".concat(this.host, "/patches/~").concat(moduleId).concat(params), {
|
920
|
+
headers: headers || {
|
921
|
+
"Content-Type": "application/json"
|
922
|
+
},
|
923
|
+
method: "POST",
|
924
|
+
body: JSON.stringify(patches)
|
925
|
+
}).then(parse);
|
926
|
+
}
|
927
|
+
}, {
|
928
|
+
key: "getSession",
|
929
|
+
value: function getSession() {
|
930
|
+
return fetch("".concat(this.host, "/session")).then(parse);
|
931
|
+
}
|
932
|
+
}, {
|
933
|
+
key: "getModules",
|
934
|
+
value: function getModules(_ref) {
|
935
|
+
var _ref$patch = _ref.patch,
|
936
|
+
patch = _ref$patch === void 0 ? false : _ref$patch,
|
937
|
+
_ref$includeSchema = _ref.includeSchema,
|
938
|
+
includeSchema = _ref$includeSchema === void 0 ? false : _ref$includeSchema,
|
939
|
+
_ref$includeSource = _ref.includeSource,
|
940
|
+
includeSource = _ref$includeSource === void 0 ? false : _ref$includeSource,
|
941
|
+
_ref$treePath = _ref.treePath,
|
942
|
+
treePath = _ref$treePath === void 0 ? "/" : _ref$treePath,
|
943
|
+
headers = _ref.headers;
|
944
|
+
var params = new URLSearchParams();
|
945
|
+
params.set("patch", patch.toString());
|
946
|
+
params.set("schema", includeSchema.toString());
|
947
|
+
params.set("source", includeSource.toString());
|
948
|
+
return fetch("".concat(this.host, "/tree/~").concat(treePath, "?").concat(params.toString()), {
|
949
|
+
headers: headers
|
950
|
+
}).then(parse);
|
951
|
+
}
|
952
|
+
}]);
|
953
|
+
return ValApi;
|
954
|
+
}();
|
955
|
+
|
956
|
+
// TODO: validate
|
957
|
+
function parse(_x) {
|
958
|
+
return _parse.apply(this, arguments);
|
959
|
+
}
|
960
|
+
function _parse() {
|
961
|
+
_parse = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(res) {
|
962
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
963
|
+
while (1) switch (_context.prev = _context.next) {
|
964
|
+
case 0:
|
965
|
+
_context.prev = 0;
|
966
|
+
if (!res.ok) {
|
967
|
+
_context.next = 9;
|
968
|
+
break;
|
969
|
+
}
|
970
|
+
_context.t0 = result.result;
|
971
|
+
_context.next = 5;
|
972
|
+
return res.json();
|
973
|
+
case 5:
|
974
|
+
_context.t1 = _context.sent;
|
975
|
+
return _context.abrupt("return", _context.t0.ok.call(_context.t0, _context.t1));
|
976
|
+
case 9:
|
977
|
+
_context.t2 = result.result;
|
978
|
+
_context.t3 = res.status;
|
979
|
+
_context.next = 13;
|
980
|
+
return res.text();
|
981
|
+
case 13:
|
982
|
+
_context.t4 = _context.sent;
|
983
|
+
_context.t5 = {
|
984
|
+
statusCode: _context.t3,
|
985
|
+
message: _context.t4
|
986
|
+
};
|
987
|
+
return _context.abrupt("return", _context.t2.err.call(_context.t2, _context.t5));
|
988
|
+
case 16:
|
989
|
+
_context.next = 21;
|
990
|
+
break;
|
991
|
+
case 18:
|
992
|
+
_context.prev = 18;
|
993
|
+
_context.t6 = _context["catch"](0);
|
994
|
+
return _context.abrupt("return", result.err({
|
995
|
+
message: _context.t6 instanceof Error ? _context.t6.message : "Unknown error"
|
996
|
+
}));
|
997
|
+
case 21:
|
998
|
+
case "end":
|
999
|
+
return _context.stop();
|
1000
|
+
}
|
1001
|
+
}, _callee, null, [[0, 18]]);
|
1002
|
+
}));
|
1003
|
+
return _parse.apply(this, arguments);
|
1004
|
+
}
|
1005
|
+
|
635
1006
|
var Internal = {
|
636
|
-
|
637
|
-
getSchema:
|
638
|
-
getValPath:
|
1007
|
+
convertFileSource: index.convertFileSource,
|
1008
|
+
getSchema: index.getSchema,
|
1009
|
+
getValPath: index.getValPath,
|
639
1010
|
getVal: getVal,
|
640
|
-
|
1011
|
+
getSource: ops.getSource,
|
641
1012
|
resolvePath: ops.resolvePath,
|
642
1013
|
splitModuleIdAndModulePath: ops.splitModuleIdAndModulePath,
|
643
|
-
|
644
|
-
|
1014
|
+
isVal: index.isVal,
|
1015
|
+
createValPathOfItem: ops.createValPathOfItem,
|
1016
|
+
createPatchJSONPath: function createPatchJSONPath(modulePath) {
|
1017
|
+
return "/".concat(modulePath.split(".").map(function (segment) {
|
1018
|
+
return JSON.parse(segment);
|
1019
|
+
}).join("/"));
|
1020
|
+
},
|
1021
|
+
/**
|
1022
|
+
* Enables draft mode: updates all Val modules with patches
|
1023
|
+
*/
|
1024
|
+
VAL_DRAFT_MODE_COOKIE: "val_draft_mode",
|
1025
|
+
/**
|
1026
|
+
* Enables Val: show the overlay / menu
|
1027
|
+
*/
|
1028
|
+
VAL_ENABLE_COOKIE_NAME: "val_enable",
|
1029
|
+
VAL_STATE_COOKIE: "val_state",
|
1030
|
+
VAL_SESSION_COOKIE: "val_session"
|
645
1031
|
};
|
646
1032
|
|
647
|
-
exports.FILE_REF_PROP =
|
648
|
-
exports.GenericSelector =
|
649
|
-
exports.Schema =
|
650
|
-
exports.VAL_EXTENSION =
|
1033
|
+
exports.FILE_REF_PROP = index.FILE_REF_PROP;
|
1034
|
+
exports.GenericSelector = index.GenericSelector;
|
1035
|
+
exports.Schema = index.Schema;
|
1036
|
+
exports.VAL_EXTENSION = index.VAL_EXTENSION;
|
651
1037
|
exports.expr = expr_dist_valbuildCoreExpr.index;
|
652
1038
|
exports.Internal = Internal;
|
1039
|
+
exports.ValApi = ValApi;
|
653
1040
|
exports.derefPatch = derefPatch;
|
654
1041
|
exports.initVal = initVal;
|