@valbuild/core 0.15.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.
Files changed (133) hide show
  1. package/ROADMAP.md +106 -0
  2. package/dist/declarations/src/ValApi.d.ts +26 -0
  3. package/dist/declarations/src/expr/eval.d.ts +1 -1
  4. package/dist/declarations/src/future/fetchVal.d.ts +5 -0
  5. package/dist/declarations/src/index.d.ts +38 -9
  6. package/dist/declarations/src/initSchema.d.ts +2 -10
  7. package/dist/declarations/src/initVal.d.ts +3 -21
  8. package/dist/declarations/src/module.d.ts +2 -14
  9. package/dist/declarations/src/patch/index.d.ts +1 -1
  10. package/dist/declarations/src/patch/util.d.ts +2 -0
  11. package/dist/declarations/src/schema/array.d.ts +3 -2
  12. package/dist/declarations/src/schema/boolean.d.ts +3 -2
  13. package/dist/declarations/src/schema/image.d.ts +4 -3
  14. package/dist/declarations/src/schema/index.d.ts +8 -7
  15. package/dist/declarations/src/schema/keyOf.d.ts +23 -0
  16. package/dist/declarations/src/schema/literal.d.ts +3 -2
  17. package/dist/declarations/src/schema/number.d.ts +3 -2
  18. package/dist/declarations/src/schema/object.d.ts +3 -2
  19. package/dist/declarations/src/schema/record.d.ts +19 -0
  20. package/dist/declarations/src/schema/richtext.d.ts +3 -2
  21. package/dist/declarations/src/schema/string.d.ts +3 -2
  22. package/dist/declarations/src/schema/union.d.ts +4 -2
  23. package/dist/declarations/src/schema/validation/ValidationError.d.ts +14 -0
  24. package/dist/declarations/src/schema/validation/ValidationFix.d.ts +2 -0
  25. package/dist/declarations/src/selector/SelectorProxy.d.ts +7 -0
  26. package/dist/declarations/src/selector/array.d.ts +2 -13
  27. package/dist/declarations/src/selector/file.d.ts +1 -4
  28. package/dist/declarations/src/selector/future/array.d.ts +17 -0
  29. package/dist/declarations/src/selector/future/boolean.d.ts +2 -0
  30. package/dist/declarations/src/selector/future/file.d.ts +9 -0
  31. package/dist/declarations/src/selector/{i18n.d.ts → future/i18n.d.ts} +2 -2
  32. package/dist/declarations/src/selector/future/index.d.ts +81 -0
  33. package/dist/declarations/src/selector/future/number.d.ts +2 -0
  34. package/dist/declarations/src/selector/future/object.d.ts +10 -0
  35. package/dist/declarations/src/selector/future/primitive.d.ts +9 -0
  36. package/dist/declarations/src/selector/{remote.d.ts → future/remote.d.ts} +1 -1
  37. package/dist/declarations/src/selector/future/string.d.ts +2 -0
  38. package/dist/declarations/src/selector/index.d.ts +5 -32
  39. package/dist/declarations/src/selector/object.d.ts +2 -9
  40. package/dist/declarations/src/selector/primitive.d.ts +3 -9
  41. package/dist/declarations/src/source/{i18n.d.ts → future/i18n.d.ts} +2 -2
  42. package/dist/declarations/src/source/{remote.d.ts → future/remote.d.ts} +3 -3
  43. package/dist/declarations/src/source/index.d.ts +4 -3
  44. package/dist/declarations/src/val/index.d.ts +2 -2
  45. package/dist/index-369caccf.esm.js +550 -0
  46. package/dist/{index-06df0a5b.esm.js → index-3e3e839e.esm.js} +190 -555
  47. package/dist/{index-9663f28a.cjs.dev.js → index-486c7fbf.cjs.dev.js} +224 -617
  48. package/dist/{index-b2270f8f.cjs.prod.js → index-601a7d73.cjs.prod.js} +224 -617
  49. package/dist/index-8706c87e.cjs.prod.js +582 -0
  50. package/dist/index-a6e642dd.cjs.dev.js +582 -0
  51. package/dist/ops-0d09f8ee.cjs.prod.js +684 -0
  52. package/dist/ops-23a5abb2.esm.js +671 -0
  53. package/dist/ops-f3015423.cjs.dev.js +684 -0
  54. package/dist/valbuild-core.cjs.dev.js +640 -633
  55. package/dist/valbuild-core.cjs.prod.js +640 -633
  56. package/dist/valbuild-core.esm.js +578 -572
  57. package/expr/dist/valbuild-core-expr.cjs.dev.js +8 -8
  58. package/expr/dist/valbuild-core-expr.cjs.prod.js +8 -8
  59. package/expr/dist/valbuild-core-expr.esm.js +2 -2
  60. package/package.json +2 -2
  61. package/patch/dist/valbuild-core-patch.cjs.dev.js +32 -23
  62. package/patch/dist/valbuild-core-patch.cjs.prod.js +32 -23
  63. package/patch/dist/valbuild-core-patch.esm.js +12 -4
  64. package/src/ValApi.ts +85 -0
  65. package/src/expr/eval.test.ts +2 -2
  66. package/src/expr/eval.ts +2 -2
  67. package/src/expr/repl.ts +2 -2
  68. package/src/{fetchVal.test.ts → future/fetchVal.test.ts} +57 -57
  69. package/src/{fetchVal.ts → future/fetchVal.ts} +17 -22
  70. package/src/index.ts +51 -14
  71. package/src/initSchema.ts +11 -12
  72. package/src/initVal.ts +42 -52
  73. package/src/module.test.ts +40 -40
  74. package/src/module.ts +53 -43
  75. package/src/patch/deref.test.ts +1 -1
  76. package/src/patch/deref.ts +1 -1
  77. package/src/patch/index.ts +1 -0
  78. package/src/patch/json.test.ts +0 -1
  79. package/src/patch/util.ts +7 -0
  80. package/src/schema/array.ts +45 -4
  81. package/src/schema/boolean.ts +14 -3
  82. package/src/schema/{i18n.ts → future/i18n.ts} +15 -11
  83. package/src/schema/{oneOf.ts → future/oneOf.ts} +21 -18
  84. package/src/schema/image.ts +66 -6
  85. package/src/schema/index.ts +37 -13
  86. package/src/schema/keyOf.ts +167 -0
  87. package/src/schema/literal.ts +24 -3
  88. package/src/schema/number.ts +14 -3
  89. package/src/schema/object.ts +50 -7
  90. package/src/schema/record.ts +103 -0
  91. package/src/schema/richtext.ts +63 -3
  92. package/src/schema/string.ts +14 -3
  93. package/src/schema/union.ts +4 -3
  94. package/src/schema/validation/ValidationError.ts +16 -0
  95. package/src/schema/validation/ValidationFix.ts +6 -0
  96. package/src/schema/validation.test.ts +291 -0
  97. package/src/selector/SelectorProxy.ts +16 -16
  98. package/src/selector/array.ts +2 -26
  99. package/src/selector/file.ts +1 -9
  100. package/src/selector/{ExprProxy.test.ts → future/ExprProxy.test.ts} +2 -2
  101. package/src/selector/{ExprProxy.ts → future/ExprProxy.ts} +9 -2
  102. package/src/selector/{SelectorProxy.test.ts → future/SelectorProxy.test.ts} +4 -4
  103. package/src/selector/future/SelectorProxy.ts +238 -0
  104. package/src/selector/future/array.ts +37 -0
  105. package/src/selector/future/boolean.ts +4 -0
  106. package/src/selector/future/file.ts +14 -0
  107. package/src/selector/{i18n.ts → future/i18n.ts} +2 -2
  108. package/src/selector/future/index.ts +165 -0
  109. package/src/selector/future/number.ts +4 -0
  110. package/src/selector/future/object.ts +22 -0
  111. package/src/selector/future/primitive.ts +17 -0
  112. package/src/selector/{remote.ts → future/remote.ts} +1 -1
  113. package/src/selector/{selector.test.ts → future/selector.test.ts} +8 -28
  114. package/src/selector/{selectorOf.ts → future/selectorOf.ts} +1 -1
  115. package/src/selector/future/string.ts +4 -0
  116. package/src/selector/index.ts +4 -46
  117. package/src/selector/object.ts +2 -19
  118. package/src/selector/primitive.ts +3 -16
  119. package/src/source/{i18n.ts → future/i18n.ts} +2 -2
  120. package/src/source/{remote.ts → future/remote.ts} +3 -3
  121. package/src/source/index.ts +3 -2
  122. package/src/val/array.ts +1 -1
  123. package/src/val/index.ts +2 -2
  124. package/src/val/object.ts +1 -1
  125. package/dist/createClass-012eebbf.esm.js +0 -109
  126. package/dist/createClass-a436dbfe.cjs.dev.js +0 -116
  127. package/dist/createClass-de7426aa.cjs.prod.js +0 -116
  128. package/dist/declarations/src/fetchVal.d.ts +0 -5
  129. package/dist/declarations/src/schema/i18n.d.ts +0 -21
  130. package/dist/declarations/src/schema/oneOf.d.ts +0 -22
  131. package/dist/ops-6fae92a1.esm.js +0 -12
  132. package/dist/ops-87cdbafc.cjs.dev.js +0 -14
  133. package/dist/ops-ae4d1bc2.cjs.prod.js +0 -14
@@ -2,519 +2,40 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var expr_dist_valbuildCoreExpr = require('./index-9663f28a.cjs.dev.js');
6
- var createClass = require('./createClass-a436dbfe.cjs.dev.js');
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');
7
8
  var result = require('./result-48320acd.cjs.dev.js');
8
- var ops = require('./ops-87cdbafc.cjs.dev.js');
9
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) {
10
+ var NumberSchema = /*#__PURE__*/function (_Schema) {
11
+ index._inherits(NumberSchema, _Schema);
12
+ var _super = index._createSuper(NumberSchema);
13
+ function NumberSchema(options) {
71
14
  var _this;
72
15
  var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
73
- createClass._classCallCheck(this, ArraySchema);
16
+ index._classCallCheck(this, NumberSchema);
74
17
  _this = _super.call(this);
75
- _this.item = item;
18
+ _this.options = options;
76
19
  _this.opt = opt;
77
20
  return _this;
78
21
  }
79
- createClass._createClass(ArraySchema, [{
22
+ index._createClass(NumberSchema, [{
80
23
  key: "validate",
81
- value: function validate(src) {
82
- throw new Error("Method not implemented.");
83
- }
84
- }, {
85
- key: "match",
86
- value: function match(src) {
24
+ value: function validate(path, src) {
87
25
  if (this.opt && (src === null || src === undefined)) {
88
- return true;
89
- }
90
- if (!src) {
91
26
  return false;
92
27
  }
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
-
215
- var OneOfSchema = /*#__PURE__*/function (_Schema) {
216
- expr_dist_valbuildCoreExpr._inherits(OneOfSchema, _Schema);
217
- var _super = expr_dist_valbuildCoreExpr._createSuper(OneOfSchema);
218
- function OneOfSchema(selector) {
219
- var _this;
220
- var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
221
- createClass._classCallCheck(this, OneOfSchema);
222
- _this = _super.call(this);
223
- _this.selector = selector;
224
- _this.opt = opt;
225
- return _this;
226
- }
227
- createClass._createClass(OneOfSchema, [{
228
- key: "validate",
229
- value: function validate(src) {
230
- throw new Error("Method not implemented.");
231
- }
232
- }, {
233
- key: "match",
234
- value: function match(src) {
235
- throw new Error("Method not implemented.");
236
- }
237
- }, {
238
- key: "optional",
239
- value: function optional() {
240
- return new OneOfSchema(this.selector, true);
241
- }
242
- }, {
243
- key: "serialize",
244
- value: function serialize() {
245
- var path = expr_dist_valbuildCoreExpr.getValPath(this.selector);
246
- if (!path) {
247
- throw new Error("Cannot serialize oneOf schema with empty selector. Make sure a Val module is used.");
248
- }
249
- return {
250
- type: "oneOf",
251
- selector: path,
252
- opt: this.opt
253
- };
254
- }
255
- }]);
256
- return OneOfSchema;
257
- }(expr_dist_valbuildCoreExpr.Schema);
258
- var oneOf = function oneOf(valModule) {
259
- return new OneOfSchema(valModule);
260
- };
261
-
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++;
28
+ if (typeof src !== "number") {
29
+ return index._defineProperty({}, path, [{
30
+ message: "Expected 'number', got '".concat(index._typeof(src), "'"),
31
+ value: src
32
+ }]);
469
33
  }
470
- }
471
- if (part !== "") {
472
- result.push(part);
473
- }
474
- i++;
475
- }
476
- return result;
477
- }
478
-
479
- /**
480
- * I18n sources cannot have nested remote sources.
481
- */
482
-
483
- /**
484
- * An i18n source is a map of locales to sources.
485
- *
486
- * 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
487
- *
488
- */
489
-
490
- function i18n(
491
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
492
- locales) {
493
- return function (source) {
494
- return expr_dist_valbuildCoreExpr._objectSpread2(expr_dist_valbuildCoreExpr._objectSpread2({}, source), {}, expr_dist_valbuildCoreExpr._defineProperty({}, expr_dist_valbuildCoreExpr.VAL_EXTENSION, "i18n"));
495
- };
496
- }
497
-
498
- var NumberSchema = /*#__PURE__*/function (_Schema) {
499
- expr_dist_valbuildCoreExpr._inherits(NumberSchema, _Schema);
500
- var _super = expr_dist_valbuildCoreExpr._createSuper(NumberSchema);
501
- function NumberSchema(options) {
502
- var _this;
503
- var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
504
- createClass._classCallCheck(this, NumberSchema);
505
- _this = _super.call(this);
506
- _this.options = options;
507
- _this.opt = opt;
508
- return _this;
509
- }
510
- createClass._createClass(NumberSchema, [{
511
- key: "validate",
512
- value: function validate(src) {
513
- throw new Error("Method not implemented.");
34
+ return false;
514
35
  }
515
36
  }, {
516
- key: "match",
517
- value: function match(src) {
37
+ key: "assert",
38
+ value: function assert(src) {
518
39
  if (this.opt && (src === null || src === undefined)) {
519
40
  return true;
520
41
  }
@@ -536,31 +57,40 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
536
57
  }
537
58
  }]);
538
59
  return NumberSchema;
539
- }(expr_dist_valbuildCoreExpr.Schema);
60
+ }(index.Schema);
540
61
  var number = function number(options) {
541
62
  return new NumberSchema(options);
542
63
  };
543
64
 
544
65
  var StringSchema = /*#__PURE__*/function (_Schema) {
545
- expr_dist_valbuildCoreExpr._inherits(StringSchema, _Schema);
546
- var _super = expr_dist_valbuildCoreExpr._createSuper(StringSchema);
66
+ index._inherits(StringSchema, _Schema);
67
+ var _super = index._createSuper(StringSchema);
547
68
  function StringSchema(options) {
548
69
  var _this;
549
70
  var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
550
- createClass._classCallCheck(this, StringSchema);
71
+ index._classCallCheck(this, StringSchema);
551
72
  _this = _super.call(this);
552
73
  _this.options = options;
553
74
  _this.opt = opt;
554
75
  return _this;
555
76
  }
556
- createClass._createClass(StringSchema, [{
77
+ index._createClass(StringSchema, [{
557
78
  key: "validate",
558
- value: function validate(src) {
559
- throw new Error("Method not implemented.");
79
+ value: function validate(path, src) {
80
+ if (this.opt && (src === null || src === undefined)) {
81
+ return false;
82
+ }
83
+ if (typeof src !== "string") {
84
+ return index._defineProperty({}, path, [{
85
+ message: "Expected 'string', got '".concat(index._typeof(src), "'"),
86
+ value: src
87
+ }]);
88
+ }
89
+ return false;
560
90
  }
561
91
  }, {
562
- key: "match",
563
- value: function match(src) {
92
+ key: "assert",
93
+ value: function assert(src) {
564
94
  if (this.opt && (src === null || src === undefined)) {
565
95
  return true;
566
96
  }
@@ -582,30 +112,39 @@ var StringSchema = /*#__PURE__*/function (_Schema) {
582
112
  }
583
113
  }]);
584
114
  return StringSchema;
585
- }(expr_dist_valbuildCoreExpr.Schema);
115
+ }(index.Schema);
586
116
  var string = function string(options) {
587
117
  return new StringSchema(options);
588
118
  };
589
119
 
590
120
  var BooleanSchema = /*#__PURE__*/function (_Schema) {
591
- expr_dist_valbuildCoreExpr._inherits(BooleanSchema, _Schema);
592
- var _super = expr_dist_valbuildCoreExpr._createSuper(BooleanSchema);
121
+ index._inherits(BooleanSchema, _Schema);
122
+ var _super = index._createSuper(BooleanSchema);
593
123
  function BooleanSchema() {
594
124
  var _this;
595
125
  var opt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
596
- createClass._classCallCheck(this, BooleanSchema);
126
+ index._classCallCheck(this, BooleanSchema);
597
127
  _this = _super.call(this);
598
128
  _this.opt = opt;
599
129
  return _this;
600
130
  }
601
- createClass._createClass(BooleanSchema, [{
131
+ index._createClass(BooleanSchema, [{
602
132
  key: "validate",
603
- value: function validate(src) {
604
- throw new Error("Method not implemented.");
133
+ value: function validate(path, src) {
134
+ if (this.opt && (src === null || src === undefined)) {
135
+ return false;
136
+ }
137
+ if (typeof src !== "boolean") {
138
+ return index._defineProperty({}, path, [{
139
+ message: "Expected 'boolean', got '".concat(index._typeof(src), "'"),
140
+ value: src
141
+ }]);
142
+ }
143
+ return false;
605
144
  }
606
145
  }, {
607
- key: "match",
608
- value: function match(src) {
146
+ key: "assert",
147
+ value: function assert(src) {
609
148
  if (this.opt && (src === null || src === undefined)) {
610
149
  return true;
611
150
  }
@@ -626,31 +165,46 @@ var BooleanSchema = /*#__PURE__*/function (_Schema) {
626
165
  }
627
166
  }]);
628
167
  return BooleanSchema;
629
- }(expr_dist_valbuildCoreExpr.Schema);
168
+ }(index.Schema);
630
169
  var _boolean = function _boolean() {
631
170
  return new BooleanSchema();
632
171
  };
633
172
 
634
173
  var LiteralSchema = /*#__PURE__*/function (_Schema) {
635
- expr_dist_valbuildCoreExpr._inherits(LiteralSchema, _Schema);
636
- var _super = expr_dist_valbuildCoreExpr._createSuper(LiteralSchema);
174
+ index._inherits(LiteralSchema, _Schema);
175
+ var _super = index._createSuper(LiteralSchema);
637
176
  function LiteralSchema(value) {
638
177
  var _this;
639
178
  var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
640
- createClass._classCallCheck(this, LiteralSchema);
179
+ index._classCallCheck(this, LiteralSchema);
641
180
  _this = _super.call(this);
642
181
  _this.value = value;
643
182
  _this.opt = opt;
644
183
  return _this;
645
184
  }
646
- createClass._createClass(LiteralSchema, [{
185
+ index._createClass(LiteralSchema, [{
647
186
  key: "validate",
648
- value: function validate(src) {
649
- throw new Error("Method not implemented.");
187
+ value: function validate(path, src) {
188
+ if (this.opt && (src === null || src === undefined)) {
189
+ return false;
190
+ }
191
+ if (typeof src !== "string") {
192
+ return index._defineProperty({}, path, [{
193
+ message: "Expected 'string', got '".concat(index._typeof(src), "'"),
194
+ value: src
195
+ }]);
196
+ }
197
+ if (src !== this.value) {
198
+ return index._defineProperty({}, path, [{
199
+ message: "Expected literal '".concat(this.value, "', got '").concat(src, "'"),
200
+ value: src
201
+ }]);
202
+ }
203
+ return false;
650
204
  }
651
205
  }, {
652
- key: "match",
653
- value: function match(src) {
206
+ key: "assert",
207
+ value: function assert(src) {
654
208
  if (this.opt && (src === null || src === undefined)) {
655
209
  return true;
656
210
  }
@@ -672,51 +226,38 @@ var LiteralSchema = /*#__PURE__*/function (_Schema) {
672
226
  }
673
227
  }]);
674
228
  return LiteralSchema;
675
- }(expr_dist_valbuildCoreExpr.Schema);
229
+ }(index.Schema);
676
230
  var literal = function literal(value) {
677
231
  return new LiteralSchema(value);
678
232
  };
679
233
 
680
- function initSchema(locales) {
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>
681
242
  return {
682
243
  string: string,
683
244
  "boolean": _boolean,
684
- array: array,
685
- object: object,
245
+ array: ops.array,
246
+ object: ops.object,
686
247
  number: number,
687
- union: union,
688
- oneOf: oneOf,
689
- richtext: richtext$1,
690
- image: expr_dist_valbuildCoreExpr.image,
691
- literal: literal,
692
- i18n: i18n$1(locales)
248
+ union: ops.union,
249
+ // oneOf,
250
+ richtext: ops.richtext,
251
+ image: index.image,
252
+ literal: literal
253
+ // i18n: i18n(locales),
693
254
  };
694
255
  }
695
256
 
696
- /**
697
- * Remote sources cannot include other remote sources.
698
- */
699
-
700
- var REMOTE_REF_PROP = "_ref"; // TODO: same as FILE_REF_PROP so use same prop?
701
-
702
- /**
703
- * A remote source is a hash that represents a remote object.
704
- *
705
- * It will be resolved into a ValRemote object.
706
- */
707
-
708
- function remote(ref) {
709
- var _ref;
710
- return _ref = {}, expr_dist_valbuildCoreExpr._defineProperty(_ref, REMOTE_REF_PROP, ref), expr_dist_valbuildCoreExpr._defineProperty(_ref, expr_dist_valbuildCoreExpr.VAL_EXTENSION, "remote"), _ref;
711
- }
712
- function isRemote(obj) {
713
- return createClass._typeof(obj) === "object" && obj !== null && expr_dist_valbuildCoreExpr.VAL_EXTENSION in obj && obj[expr_dist_valbuildCoreExpr.VAL_EXTENSION] === "remote" && REMOTE_REF_PROP in obj && typeof obj[REMOTE_REF_PROP] === "string";
714
- }
715
-
716
257
  function richtext(data) {
717
258
  if (typeof data === "string") {
718
259
  var _ref;
719
- return _ref = {}, expr_dist_valbuildCoreExpr._defineProperty(_ref, expr_dist_valbuildCoreExpr.VAL_EXTENSION, "richtext"), expr_dist_valbuildCoreExpr._defineProperty(_ref, "type", "root"), expr_dist_valbuildCoreExpr._defineProperty(_ref, "children", [{
260
+ return _ref = {}, index._defineProperty(_ref, index.VAL_EXTENSION, "richtext"), index._defineProperty(_ref, "type", "root"), index._defineProperty(_ref, "children", [{
720
261
  type: "paragraph",
721
262
  children: [{
722
263
  type: "text",
@@ -724,43 +265,58 @@ function richtext(data) {
724
265
  }]
725
266
  }]), _ref;
726
267
  }
727
- return expr_dist_valbuildCoreExpr._objectSpread2(expr_dist_valbuildCoreExpr._objectSpread2({}, data), {}, expr_dist_valbuildCoreExpr._defineProperty({}, expr_dist_valbuildCoreExpr.VAL_EXTENSION, "richtext"));
268
+ return index._objectSpread2(index._objectSpread2({}, data), {}, index._defineProperty({}, index.VAL_EXTENSION, "richtext"));
728
269
  }
729
270
 
730
- var initVal = function initVal(options) {
731
- var locales = options === null || options === void 0 ? void 0 : options.locales;
732
- var s = initSchema(locales === null || locales === void 0 ? void 0 : locales.required);
733
- if (locales !== null && locales !== void 0 && locales.required) {
734
- console.error("Locales / i18n currently not implemented");
735
- return {
736
- val: {
737
- content: content,
738
- i18n: i18n,
739
- remote: remote,
740
- getPath: expr_dist_valbuildCoreExpr.getValPath,
741
- file: expr_dist_valbuildCoreExpr.file,
742
- richtext: richtext
743
- },
744
- s: s
745
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
746
- };
747
- }
748
-
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
+ // }
749
298
  return {
750
299
  val: {
751
- content: content,
752
- remote: remote,
753
- getPath: expr_dist_valbuildCoreExpr.getValPath,
754
- file: expr_dist_valbuildCoreExpr.file,
300
+ content: ops.content,
301
+ // remote,
302
+ getPath: index.getValPath,
303
+ file: index.file,
755
304
  richtext: richtext
756
305
  },
757
- s: expr_dist_valbuildCoreExpr._objectSpread2(expr_dist_valbuildCoreExpr._objectSpread2({}, s), {}, {
758
- i18n: undefined
759
- })
306
+ s: index._objectSpread2({}, s)
760
307
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
761
308
  };
762
309
  };
763
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
+
764
320
  function derefPath(path) {
765
321
  var dereffedPath = [];
766
322
  var referencedPath = null;
@@ -814,21 +370,21 @@ function derefPatch(patch, document, ops$1) {
814
370
  if (result.isErr(maybeDerefRes)) {
815
371
  return maybeDerefRes;
816
372
  }
817
- var _maybeDerefRes$value = createClass._slicedToArray(maybeDerefRes.value, 2),
373
+ var _maybeDerefRes$value = index._slicedToArray(maybeDerefRes.value, 2),
818
374
  dereffedPath = _maybeDerefRes$value[0],
819
375
  referencedPath = _maybeDerefRes$value[1];
820
376
  if (referencedPath) {
821
377
  var maybeValue = ops$1.get(document, dereffedPath);
822
378
  if (result.isOk(maybeValue)) {
823
379
  var value = maybeValue.value;
824
- if (expr_dist_valbuildCoreExpr.isFile(value)) {
380
+ if (index.isFile(value)) {
825
381
  if (referencedPath.length > 0) {
826
382
  return result.err(new ops.PatchError("Cannot sub-reference file reference at path: ".concat(dereffedPath.join("/"))));
827
383
  }
828
384
  if (typeof op.value !== "string") {
829
385
  return result.err(new ops.PatchError("Expected base64 encoded string value for file reference, got ".concat(JSON.stringify(op.value))));
830
386
  }
831
- fileUpdates[value[expr_dist_valbuildCoreExpr.FILE_REF_PROP]] = op.value;
387
+ fileUpdates[value[index.FILE_REF_PROP]] = op.value;
832
388
  } else if (isRemote(value)) {
833
389
  if (!remotePatches[value[REMOTE_REF_PROP]]) {
834
390
  remotePatches[value[REMOTE_REF_PROP]] = [];
@@ -852,7 +408,7 @@ function derefPatch(patch, document, ops$1) {
852
408
  if (result.isErr(_maybeDerefRes)) {
853
409
  return _maybeDerefRes;
854
410
  }
855
- var _maybeDerefRes$value2 = createClass._slicedToArray(_maybeDerefRes.value, 2),
411
+ var _maybeDerefRes$value2 = index._slicedToArray(_maybeDerefRes.value, 2),
856
412
  _referencedPath = _maybeDerefRes$value2[1];
857
413
  if (_referencedPath) {
858
414
  throw new Error("Unimplemented operation: ".concat(JSON.stringify(op)));
@@ -872,63 +428,58 @@ function derefPatch(patch, document, ops$1) {
872
428
  });
873
429
  }
874
430
 
875
- function fetchVal(selector, locale) {
876
- return Promise.resolve(getVal(selector));
877
- }
878
- function getVal(selector,
879
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
880
- locale) {
431
+ function getVal(selector) {
881
432
  return newValProxy(serializedValOfSelectorSource(selector));
882
433
  }
883
434
 
884
435
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
885
436
  function isArrayOrArraySelector(child) {
886
- if (expr_dist_valbuildCoreExpr.isSelector(child)) {
887
- return createClass._typeof(child[expr_dist_valbuildCoreExpr.SourceOrExpr]) === "object" && createClass._typeof(child[expr_dist_valbuildCoreExpr.SourceOrExpr]) !== null && Array.isArray(child[expr_dist_valbuildCoreExpr.SourceOrExpr]);
437
+ if (ops.isSelector(child)) {
438
+ return index._typeof(child[index.GetSource]) === "object" && index._typeof(child[index.GetSource]) !== null && Array.isArray(child[index.GetSource]);
888
439
  }
889
440
  return Array.isArray(child);
890
441
  }
891
442
 
892
443
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
893
444
  function isObjectOrObjectSelector(child) {
894
- if (expr_dist_valbuildCoreExpr.isSelector(child)) {
895
- return createClass._typeof(child[expr_dist_valbuildCoreExpr.SourceOrExpr]) === "object" && createClass._typeof(child[expr_dist_valbuildCoreExpr.SourceOrExpr]) !== null && !Array.isArray(child[expr_dist_valbuildCoreExpr.SourceOrExpr]);
445
+ if (ops.isSelector(child)) {
446
+ return index._typeof(child[index.GetSource]) === "object" && index._typeof(child[index.GetSource]) !== null && !Array.isArray(child[index.GetSource]);
896
447
  }
897
- return createClass._typeof(child) === "object";
448
+ return index._typeof(child) === "object";
898
449
  }
899
450
  function serializedValOfSelectorSource(selector) {
900
- var wrappedSelector = expr_dist_valbuildCoreExpr.newSelectorProxy(selector); // NOTE: we do this if call-site uses a literal with selectors inside
451
+ var wrappedSelector = ops.newSelectorProxy(selector); // NOTE: we do this if call-site uses a literal with selectors inside
901
452
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
902
453
  function rec(child) {
903
454
  var isArray = isArrayOrArraySelector(child);
904
455
  var isObject = isObjectOrObjectSelector(child);
905
456
  if (isArray) {
906
- var array = expr_dist_valbuildCoreExpr.SourceOrExpr in child ? child[expr_dist_valbuildCoreExpr.SourceOrExpr] : child;
907
- var valPath = expr_dist_valbuildCoreExpr.Path in child ? child[expr_dist_valbuildCoreExpr.Path] : undefined;
457
+ var array = index.GetSource in child ? child[index.GetSource] : child;
458
+ var valPath = index.Path in child ? child[index.Path] : undefined;
908
459
  return {
909
460
  val: array.map(function (item, i) {
910
- return rec(expr_dist_valbuildCoreExpr.isSelector(item) // NOTE: We do this since selectors currently do not create selectors of items unless specifically required.
911
- ? item : expr_dist_valbuildCoreExpr.newSelectorProxy(item, expr_dist_valbuildCoreExpr.createValPathOfItem(valPath, i)));
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)));
912
463
  }),
913
464
  valPath: valPath
914
465
  };
915
466
  } else if (isObject) {
916
- var obj = expr_dist_valbuildCoreExpr.SourceOrExpr in child ? child[expr_dist_valbuildCoreExpr.SourceOrExpr] : child;
917
- var _valPath = expr_dist_valbuildCoreExpr.Path in child ? child[expr_dist_valbuildCoreExpr.Path] : undefined;
467
+ var obj = index.GetSource in child ? child[index.GetSource] : child;
468
+ var _valPath = index.Path in child ? child[index.Path] : undefined;
918
469
  return {
919
470
  val: obj !== null && Object.fromEntries(Object.entries(obj).map(function (_ref) {
920
- var _ref2 = createClass._slicedToArray(_ref, 2),
471
+ var _ref2 = index._slicedToArray(_ref, 2),
921
472
  key = _ref2[0],
922
473
  value = _ref2[1];
923
- return [key, rec(expr_dist_valbuildCoreExpr.isSelector(value) // NOTE: We do this since selectors currently do not create selectors of items unless specifically required.
924
- ? value : expr_dist_valbuildCoreExpr.newSelectorProxy(value, expr_dist_valbuildCoreExpr.createValPathOfItem(_valPath, key)))];
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)))];
925
476
  })),
926
477
  valPath: _valPath
927
478
  };
928
- } else if (expr_dist_valbuildCoreExpr.isSelector(child)) {
479
+ } else if (ops.isSelector(child)) {
929
480
  return {
930
- val: rec(child[expr_dist_valbuildCoreExpr.SourceOrExpr]),
931
- valPath: child[expr_dist_valbuildCoreExpr.Path]
481
+ val: rec(child[index.GetSource]),
482
+ valPath: child[index.Path]
932
483
  };
933
484
  } else {
934
485
  return child;
@@ -937,11 +488,11 @@ function serializedValOfSelectorSource(selector) {
937
488
  return rec(wrappedSelector);
938
489
  }
939
490
  function strip(value) {
940
- var val = expr_dist_valbuildCoreExpr.isSerializedVal(value) ? value.val : value;
941
- switch (createClass._typeof(val)) {
491
+ var val = index.isSerializedVal(value) ? value.val : value;
492
+ switch (index._typeof(val)) {
942
493
  case "function":
943
494
  case "symbol":
944
- throw Error("Invalid val type: ".concat(createClass._typeof(val)));
495
+ throw Error("Invalid val type: ".concat(index._typeof(val)));
945
496
  case "object":
946
497
  if (val === null) {
947
498
  return null;
@@ -949,7 +500,7 @@ function strip(value) {
949
500
  return val.map(strip);
950
501
  } else {
951
502
  return Object.fromEntries(Object.entries(val).map(function (_ref3) {
952
- var _ref4 = createClass._slicedToArray(_ref3, 2),
503
+ var _ref4 = index._slicedToArray(_ref3, 2),
953
504
  key = _ref4[0],
954
505
  value = _ref4[1];
955
506
  return [key, value && strip(value)];
@@ -964,10 +515,10 @@ function strip(value) {
964
515
  function newValProxy(val) {
965
516
  var _ref5;
966
517
  var source = val.val;
967
- switch (createClass._typeof(source)) {
518
+ switch (index._typeof(source)) {
968
519
  case "function":
969
520
  case "symbol":
970
- throw Error("Invalid val type: ".concat(createClass._typeof(source)));
521
+ throw Error("Invalid val type: ".concat(index._typeof(source)));
971
522
  case "object":
972
523
  if (source !== null) {
973
524
  // Handles both objects and arrays!
@@ -976,13 +527,13 @@ function newValProxy(val) {
976
527
  if (prop === "val") {
977
528
  return true;
978
529
  }
979
- if (prop === expr_dist_valbuildCoreExpr.Path) {
530
+ if (prop === index.Path) {
980
531
  return true;
981
532
  }
982
533
  return hasOwn(target, prop);
983
534
  },
984
535
  get: function get(target, prop) {
985
- if (prop === expr_dist_valbuildCoreExpr.Path) {
536
+ if (prop === index.Path) {
986
537
  return val.valPath;
987
538
  }
988
539
  if (prop === "val") {
@@ -995,7 +546,7 @@ function newValProxy(val) {
995
546
  var _Reflect$get$valPath, _Reflect$get;
996
547
  return newValProxy({
997
548
  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 : expr_dist_valbuildCoreExpr.createValPathOfItem(val.valPath, Array.isArray(target) ? Number(prop) : prop)
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)
999
550
  });
1000
551
  }
1001
552
  return Reflect.get(target, prop);
@@ -1005,30 +556,486 @@ function newValProxy(val) {
1005
556
  // intentional fallthrough
1006
557
  // eslint-disable-next-line no-fallthrough
1007
558
  default:
1008
- return _ref5 = {}, expr_dist_valbuildCoreExpr._defineProperty(_ref5, expr_dist_valbuildCoreExpr.Path, val.valPath), expr_dist_valbuildCoreExpr._defineProperty(_ref5, "val", val.val), _ref5;
559
+ return _ref5 = {}, index._defineProperty(_ref5, index.Path, val.valPath), index._defineProperty(_ref5, "val", val.val), _ref5;
1009
560
  }
1010
561
  }
1011
562
  function hasOwn(obj, prop) {
1012
563
  return Object.prototype.hasOwnProperty.call(obj, prop);
1013
564
  }
1014
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
+
1015
1006
  var Internal = {
1016
- convertImageSource: expr_dist_valbuildCoreExpr.convertImageSource,
1017
- getSchema: expr_dist_valbuildCoreExpr.getSchema,
1018
- getValPath: expr_dist_valbuildCoreExpr.getValPath,
1007
+ convertFileSource: index.convertFileSource,
1008
+ getSchema: index.getSchema,
1009
+ getValPath: index.getValPath,
1019
1010
  getVal: getVal,
1020
- getRawSource: getRawSource,
1021
- resolvePath: resolvePath,
1022
- splitModuleIdAndModulePath: splitModuleIdAndModulePath,
1023
- fetchVal: fetchVal,
1024
- isVal: expr_dist_valbuildCoreExpr.isVal
1011
+ getSource: ops.getSource,
1012
+ resolvePath: ops.resolvePath,
1013
+ splitModuleIdAndModulePath: ops.splitModuleIdAndModulePath,
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"
1025
1031
  };
1026
1032
 
1027
- exports.FILE_REF_PROP = expr_dist_valbuildCoreExpr.FILE_REF_PROP;
1028
- exports.GenericSelector = expr_dist_valbuildCoreExpr.GenericSelector;
1029
- exports.Schema = expr_dist_valbuildCoreExpr.Schema;
1030
- exports.VAL_EXTENSION = expr_dist_valbuildCoreExpr.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;
1031
1037
  exports.expr = expr_dist_valbuildCoreExpr.index;
1032
1038
  exports.Internal = Internal;
1039
+ exports.ValApi = ValApi;
1033
1040
  exports.derefPatch = derefPatch;
1034
1041
  exports.initVal = initVal;