@valbuild/core 0.48.1 → 0.50.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/declarations/src/index.d.ts +4 -0
- package/dist/declarations/src/initSchema.d.ts +3 -0
- package/dist/declarations/src/schema/file.d.ts +23 -0
- package/dist/declarations/src/schema/index.d.ts +2 -1
- package/dist/declarations/src/schema/richtext.d.ts +2 -1
- package/dist/declarations/src/schema/validation/ValidationFix.d.ts +1 -1
- package/dist/declarations/src/selector/SelectorProxy.d.ts +2 -2
- package/dist/declarations/src/source/richtext.d.ts +1 -1
- package/dist/{index-7b467ee6.cjs.prod.js → index-0391a11a.cjs.prod.js} +133 -71
- package/dist/{index-799bcf49.esm.js → index-14edbcc8.esm.js} +1 -1
- package/dist/{index-5750c299.esm.js → index-a038a0f3.esm.js} +131 -71
- package/dist/{index-d23e237a.cjs.dev.js → index-b14b0d9c.cjs.dev.js} +133 -71
- package/dist/{index-db60fc1d.cjs.prod.js → index-df01e42d.cjs.prod.js} +1 -1
- package/dist/{index-00276955.cjs.dev.js → index-f66c449e.cjs.dev.js} +1 -1
- package/dist/{ops-ffed3406.esm.js → ops-2029f7c3.esm.js} +11 -17
- package/dist/{ops-74e62ffe.cjs.dev.js → ops-2b3f01fb.cjs.dev.js} +11 -17
- package/dist/{ops-c0e7e3a8.cjs.prod.js → ops-cff2b7c2.cjs.prod.js} +11 -17
- package/dist/valbuild-core.cjs.dev.js +18 -13
- package/dist/valbuild-core.cjs.prod.js +18 -13
- package/dist/valbuild-core.esm.js +19 -15
- package/expr/dist/valbuild-core-expr.cjs.dev.js +2 -2
- package/expr/dist/valbuild-core-expr.cjs.prod.js +2 -2
- package/expr/dist/valbuild-core-expr.esm.js +2 -2
- package/package.json +1 -1
- package/patch/dist/valbuild-core-patch.cjs.dev.js +2 -2
- package/patch/dist/valbuild-core-patch.cjs.prod.js +2 -2
- package/patch/dist/valbuild-core-patch.esm.js +3 -3
@@ -26,24 +26,24 @@ function _typeof(o) {
|
|
26
26
|
}, _typeof(o);
|
27
27
|
}
|
28
28
|
|
29
|
-
function
|
30
|
-
if (
|
31
|
-
var
|
32
|
-
if (
|
33
|
-
var
|
34
|
-
if (
|
29
|
+
function toPrimitive(t, r) {
|
30
|
+
if ("object" != typeof t || !t) return t;
|
31
|
+
var e = t[Symbol.toPrimitive];
|
32
|
+
if (void 0 !== e) {
|
33
|
+
var i = e.call(t, r || "default");
|
34
|
+
if ("object" != typeof i) return i;
|
35
35
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
36
36
|
}
|
37
|
-
return (
|
37
|
+
return ("string" === r ? String : Number)(t);
|
38
38
|
}
|
39
39
|
|
40
|
-
function
|
41
|
-
var
|
42
|
-
return
|
40
|
+
function toPropertyKey(t) {
|
41
|
+
var i = toPrimitive(t, "string");
|
42
|
+
return "symbol" == typeof i ? i : String(i);
|
43
43
|
}
|
44
44
|
|
45
45
|
function _defineProperty(obj, key, value) {
|
46
|
-
key =
|
46
|
+
key = toPropertyKey(key);
|
47
47
|
if (key in obj) {
|
48
48
|
Object.defineProperty(obj, key, {
|
49
49
|
value: value,
|
@@ -131,7 +131,7 @@ function _defineProperties(target, props) {
|
|
131
131
|
descriptor.enumerable = descriptor.enumerable || false;
|
132
132
|
descriptor.configurable = true;
|
133
133
|
if ("value" in descriptor) descriptor.writable = true;
|
134
|
-
Object.defineProperty(target,
|
134
|
+
Object.defineProperty(target, toPropertyKey(descriptor.key), descriptor);
|
135
135
|
}
|
136
136
|
}
|
137
137
|
function _createClass(Constructor, protoProps, staticProps) {
|
@@ -143,31 +143,6 @@ function _createClass(Constructor, protoProps, staticProps) {
|
|
143
143
|
return Constructor;
|
144
144
|
}
|
145
145
|
|
146
|
-
function _setPrototypeOf(o, p) {
|
147
|
-
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
148
|
-
o.__proto__ = p;
|
149
|
-
return o;
|
150
|
-
};
|
151
|
-
return _setPrototypeOf(o, p);
|
152
|
-
}
|
153
|
-
|
154
|
-
function _inherits(subClass, superClass) {
|
155
|
-
if (typeof superClass !== "function" && superClass !== null) {
|
156
|
-
throw new TypeError("Super expression must either be null or a function");
|
157
|
-
}
|
158
|
-
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
159
|
-
constructor: {
|
160
|
-
value: subClass,
|
161
|
-
writable: true,
|
162
|
-
configurable: true
|
163
|
-
}
|
164
|
-
});
|
165
|
-
Object.defineProperty(subClass, "prototype", {
|
166
|
-
writable: false
|
167
|
-
});
|
168
|
-
if (superClass) _setPrototypeOf(subClass, superClass);
|
169
|
-
}
|
170
|
-
|
171
146
|
function _getPrototypeOf(o) {
|
172
147
|
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
173
148
|
return o.__proto__ || Object.getPrototypeOf(o);
|
@@ -176,15 +151,12 @@ function _getPrototypeOf(o) {
|
|
176
151
|
}
|
177
152
|
|
178
153
|
function _isNativeReflectConstruct() {
|
179
|
-
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
180
|
-
if (Reflect.construct.sham) return false;
|
181
|
-
if (typeof Proxy === "function") return true;
|
182
154
|
try {
|
183
|
-
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
184
|
-
|
185
|
-
|
186
|
-
return
|
187
|
-
}
|
155
|
+
var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
156
|
+
} catch (t) {}
|
157
|
+
return (_isNativeReflectConstruct = function () {
|
158
|
+
return !!t;
|
159
|
+
})();
|
188
160
|
}
|
189
161
|
|
190
162
|
function _assertThisInitialized(self) {
|
@@ -203,25 +175,40 @@ function _possibleConstructorReturn(self, call) {
|
|
203
175
|
return _assertThisInitialized(self);
|
204
176
|
}
|
205
177
|
|
206
|
-
function
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
} else {
|
215
|
-
result = Super.apply(this, arguments);
|
216
|
-
}
|
217
|
-
return _possibleConstructorReturn(this, result);
|
178
|
+
function _callSuper(t, o, e) {
|
179
|
+
return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));
|
180
|
+
}
|
181
|
+
|
182
|
+
function _setPrototypeOf(o, p) {
|
183
|
+
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
184
|
+
o.__proto__ = p;
|
185
|
+
return o;
|
218
186
|
};
|
187
|
+
return _setPrototypeOf(o, p);
|
188
|
+
}
|
189
|
+
|
190
|
+
function _inherits(subClass, superClass) {
|
191
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
192
|
+
throw new TypeError("Super expression must either be null or a function");
|
193
|
+
}
|
194
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
195
|
+
constructor: {
|
196
|
+
value: subClass,
|
197
|
+
writable: true,
|
198
|
+
configurable: true
|
199
|
+
}
|
200
|
+
});
|
201
|
+
Object.defineProperty(subClass, "prototype", {
|
202
|
+
writable: false
|
203
|
+
});
|
204
|
+
if (superClass) _setPrototypeOf(subClass, superClass);
|
219
205
|
}
|
220
206
|
|
221
207
|
// import { RemoteCompatibleSource, RemoteSource } from "../source/remote";
|
222
208
|
|
223
209
|
// import { SerializedI18nSchema } from "./future/i18n";
|
224
210
|
// import { SerializedOneOfSchema } from "./future/oneOf";
|
211
|
+
|
225
212
|
var Schema = /*#__PURE__*/function () {
|
226
213
|
function Schema() {
|
227
214
|
_classCallCheck(this, Schema);
|
@@ -307,11 +294,10 @@ var Expr = /*#__PURE__*/_createClass(function Expr(span) {
|
|
307
294
|
});
|
308
295
|
var StringLiteral = /*#__PURE__*/function (_Expr) {
|
309
296
|
_inherits(StringLiteral, _Expr);
|
310
|
-
var _super = _createSuper(StringLiteral);
|
311
297
|
function StringLiteral(value, span) {
|
312
298
|
var _this;
|
313
299
|
_classCallCheck(this, StringLiteral);
|
314
|
-
_this =
|
300
|
+
_this = _callSuper(this, StringLiteral, [span]);
|
315
301
|
_defineProperty(_assertThisInitialized(_this), "type", "StringLiteral");
|
316
302
|
_this.value = value;
|
317
303
|
return _this;
|
@@ -326,11 +312,10 @@ var StringLiteral = /*#__PURE__*/function (_Expr) {
|
|
326
312
|
}(Expr);
|
327
313
|
var Sym = /*#__PURE__*/function (_Expr2) {
|
328
314
|
_inherits(Sym, _Expr2);
|
329
|
-
var _super2 = _createSuper(Sym);
|
330
315
|
function Sym(value, span) {
|
331
316
|
var _this2;
|
332
317
|
_classCallCheck(this, Sym);
|
333
|
-
_this2 =
|
318
|
+
_this2 = _callSuper(this, Sym, [span]);
|
334
319
|
_defineProperty(_assertThisInitialized(_this2), "type", "Sym");
|
335
320
|
_this2.value = value;
|
336
321
|
return _this2;
|
@@ -346,11 +331,10 @@ var Sym = /*#__PURE__*/function (_Expr2) {
|
|
346
331
|
var NilSym = new Sym("()");
|
347
332
|
var StringTemplate = /*#__PURE__*/function (_Expr3) {
|
348
333
|
_inherits(StringTemplate, _Expr3);
|
349
|
-
var _super3 = _createSuper(StringTemplate);
|
350
334
|
function StringTemplate(children, span) {
|
351
335
|
var _this3;
|
352
336
|
_classCallCheck(this, StringTemplate);
|
353
|
-
_this3 =
|
337
|
+
_this3 = _callSuper(this, StringTemplate, [span]);
|
354
338
|
_defineProperty(_assertThisInitialized(_this3), "type", "StringTemplate");
|
355
339
|
_this3.children = children;
|
356
340
|
return _this3;
|
@@ -371,11 +355,10 @@ var StringTemplate = /*#__PURE__*/function (_Expr3) {
|
|
371
355
|
}(Expr);
|
372
356
|
var Call = /*#__PURE__*/function (_Expr4) {
|
373
357
|
_inherits(Call, _Expr4);
|
374
|
-
var _super4 = _createSuper(Call);
|
375
358
|
function Call(children, isAnon, span) {
|
376
359
|
var _this4;
|
377
360
|
_classCallCheck(this, Call);
|
378
|
-
_this4 =
|
361
|
+
_this4 = _callSuper(this, Call, [span]);
|
379
362
|
_defineProperty(_assertThisInitialized(_this4), "type", "Call");
|
380
363
|
_this4.children = children;
|
381
364
|
_this4.isAnon = isAnon;
|
@@ -420,25 +403,102 @@ var FILE_REF_PROP = "_ref";
|
|
420
403
|
*
|
421
404
|
*/
|
422
405
|
|
423
|
-
function file(ref, metadata) {
|
406
|
+
function file$1(ref, metadata) {
|
424
407
|
return _defineProperty(_defineProperty(_defineProperty({}, FILE_REF_PROP, ref), VAL_EXTENSION, "file"), "metadata", metadata);
|
425
408
|
}
|
426
409
|
function isFile(obj) {
|
427
410
|
return _typeof(obj) === "object" && obj !== null && VAL_EXTENSION in obj && obj[VAL_EXTENSION] === "file" && FILE_REF_PROP in obj && typeof obj[FILE_REF_PROP] === "string";
|
428
411
|
}
|
429
412
|
|
413
|
+
var FileSchema = /*#__PURE__*/function (_Schema) {
|
414
|
+
_inherits(FileSchema, _Schema);
|
415
|
+
function FileSchema(options) {
|
416
|
+
var _this;
|
417
|
+
var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
418
|
+
_classCallCheck(this, FileSchema);
|
419
|
+
_this = _callSuper(this, FileSchema);
|
420
|
+
_this.options = options;
|
421
|
+
_this.opt = opt;
|
422
|
+
return _this;
|
423
|
+
}
|
424
|
+
_createClass(FileSchema, [{
|
425
|
+
key: "validate",
|
426
|
+
value: function validate(path, src) {
|
427
|
+
if (this.opt && (src === null || src === undefined)) {
|
428
|
+
return false;
|
429
|
+
}
|
430
|
+
if (src === null || src === undefined) {
|
431
|
+
return _defineProperty({}, path, [{
|
432
|
+
message: "Non-optional file was null or undefined.",
|
433
|
+
value: src
|
434
|
+
}]);
|
435
|
+
}
|
436
|
+
if (typeof src[FILE_REF_PROP] !== "string") {
|
437
|
+
return _defineProperty({}, path, [{
|
438
|
+
message: "File did not have a file reference string. Got: ".concat(_typeof(src[FILE_REF_PROP])),
|
439
|
+
value: src
|
440
|
+
}]);
|
441
|
+
}
|
442
|
+
if (src[VAL_EXTENSION] !== "file") {
|
443
|
+
return _defineProperty({}, path, [{
|
444
|
+
message: "File did not have the valid file extension type. Got: ".concat(src[VAL_EXTENSION]),
|
445
|
+
value: src
|
446
|
+
}]);
|
447
|
+
}
|
448
|
+
if (src.metadata) {
|
449
|
+
return _defineProperty({}, path, [{
|
450
|
+
message: "Found metadata, but it could not be validated. File metadata must be an object with the required props: width (positive number), height (positive number) and sha256 (string of length 64 of the base16 hash).",
|
451
|
+
// These validation errors will have to be picked up by logic outside of this package and revalidated. Reasons: 1) we have to read files to verify the metadata, which is handled differently in different runtimes (Browser, QuickJS, Node.js); 2) we want to keep this package dependency free.
|
452
|
+
value: src,
|
453
|
+
fixes: ["file:check-metadata"]
|
454
|
+
}]);
|
455
|
+
}
|
456
|
+
return _defineProperty({}, path, [{
|
457
|
+
message: "Missing File metadata.",
|
458
|
+
value: src,
|
459
|
+
fixes: ["file:add-metadata"]
|
460
|
+
}]);
|
461
|
+
}
|
462
|
+
}, {
|
463
|
+
key: "assert",
|
464
|
+
value: function assert(src) {
|
465
|
+
if (this.opt && (src === null || src === undefined)) {
|
466
|
+
return true;
|
467
|
+
}
|
468
|
+
return (src === null || src === void 0 ? void 0 : src[FILE_REF_PROP]) === "file" && (src === null || src === void 0 ? void 0 : src[VAL_EXTENSION]) === "file";
|
469
|
+
}
|
470
|
+
}, {
|
471
|
+
key: "optional",
|
472
|
+
value: function optional() {
|
473
|
+
return new FileSchema(this.options, true);
|
474
|
+
}
|
475
|
+
}, {
|
476
|
+
key: "serialize",
|
477
|
+
value: function serialize() {
|
478
|
+
return {
|
479
|
+
type: "file",
|
480
|
+
options: this.options,
|
481
|
+
opt: this.opt
|
482
|
+
};
|
483
|
+
}
|
484
|
+
}]);
|
485
|
+
return FileSchema;
|
486
|
+
}(Schema);
|
487
|
+
var file = function file(options) {
|
488
|
+
return new FileSchema(options);
|
489
|
+
};
|
430
490
|
function convertFileSource(src) {
|
431
|
-
var _src$
|
491
|
+
var _src$metadata3, _src$metadata4;
|
432
492
|
// TODO: /public should be configurable
|
433
493
|
if (!src[FILE_REF_PROP].startsWith("/public")) {
|
434
|
-
var _src$metadata;
|
494
|
+
var _src$metadata, _src$metadata2;
|
435
495
|
return {
|
436
|
-
url: src[FILE_REF_PROP] + "?sha256=".concat((_src$
|
496
|
+
url: src[FILE_REF_PROP] + ((_src$metadata = src.metadata) !== null && _src$metadata !== void 0 && _src$metadata.sha256 ? "?sha256=".concat((_src$metadata2 = src.metadata) === null || _src$metadata2 === void 0 ? void 0 : _src$metadata2.sha256) : ""),
|
437
497
|
metadata: src.metadata
|
438
498
|
};
|
439
499
|
}
|
440
500
|
return {
|
441
|
-
url: src[FILE_REF_PROP].slice("/public".length) + "?sha256=".concat((_src$
|
501
|
+
url: src[FILE_REF_PROP].slice("/public".length) + ((_src$metadata3 = src.metadata) !== null && _src$metadata3 !== void 0 && _src$metadata3.sha256 ? "?sha256=".concat((_src$metadata4 = src.metadata) === null || _src$metadata4 === void 0 ? void 0 : _src$metadata4.sha256) : ""),
|
442
502
|
metadata: src.metadata
|
443
503
|
};
|
444
504
|
}
|
@@ -475,4 +535,4 @@ function getValPath(valOrSelector) {
|
|
475
535
|
return valOrSelector[Path];
|
476
536
|
}
|
477
537
|
|
478
|
-
export { Call as C, Expr as E, FILE_REF_PROP as F, GetSchema as G, NilSym as N, Path as P, Schema as S, VAL_EXTENSION as V, _inherits as _,
|
538
|
+
export { Call as C, Expr as E, FILE_REF_PROP as F, GetSchema as G, NilSym as N, Path as P, Schema as S, VAL_EXTENSION as V, _inherits as _, _classCallCheck as a, _callSuper as b, _createClass as c, _defineProperty as d, _typeof as e, file as f, getValPath as g, file$1 as h, _slicedToArray as i, isFile as j, GetSource as k, isSerializedVal as l, convertFileSource as m, getSchema as n, isVal as o, GenericSelector as p, FileSchema as q, _objectSpread2 as r, Sym as s, StringLiteral as t, StringTemplate as u, _toConsumableArray as v };
|
@@ -28,24 +28,24 @@ function _typeof(o) {
|
|
28
28
|
}, _typeof(o);
|
29
29
|
}
|
30
30
|
|
31
|
-
function
|
32
|
-
if (
|
33
|
-
var
|
34
|
-
if (
|
35
|
-
var
|
36
|
-
if (
|
31
|
+
function toPrimitive(t, r) {
|
32
|
+
if ("object" != typeof t || !t) return t;
|
33
|
+
var e = t[Symbol.toPrimitive];
|
34
|
+
if (void 0 !== e) {
|
35
|
+
var i = e.call(t, r || "default");
|
36
|
+
if ("object" != typeof i) return i;
|
37
37
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
38
38
|
}
|
39
|
-
return (
|
39
|
+
return ("string" === r ? String : Number)(t);
|
40
40
|
}
|
41
41
|
|
42
|
-
function
|
43
|
-
var
|
44
|
-
return
|
42
|
+
function toPropertyKey(t) {
|
43
|
+
var i = toPrimitive(t, "string");
|
44
|
+
return "symbol" == typeof i ? i : String(i);
|
45
45
|
}
|
46
46
|
|
47
47
|
function _defineProperty(obj, key, value) {
|
48
|
-
key =
|
48
|
+
key = toPropertyKey(key);
|
49
49
|
if (key in obj) {
|
50
50
|
Object.defineProperty(obj, key, {
|
51
51
|
value: value,
|
@@ -133,7 +133,7 @@ function _defineProperties(target, props) {
|
|
133
133
|
descriptor.enumerable = descriptor.enumerable || false;
|
134
134
|
descriptor.configurable = true;
|
135
135
|
if ("value" in descriptor) descriptor.writable = true;
|
136
|
-
Object.defineProperty(target,
|
136
|
+
Object.defineProperty(target, toPropertyKey(descriptor.key), descriptor);
|
137
137
|
}
|
138
138
|
}
|
139
139
|
function _createClass(Constructor, protoProps, staticProps) {
|
@@ -145,31 +145,6 @@ function _createClass(Constructor, protoProps, staticProps) {
|
|
145
145
|
return Constructor;
|
146
146
|
}
|
147
147
|
|
148
|
-
function _setPrototypeOf(o, p) {
|
149
|
-
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
150
|
-
o.__proto__ = p;
|
151
|
-
return o;
|
152
|
-
};
|
153
|
-
return _setPrototypeOf(o, p);
|
154
|
-
}
|
155
|
-
|
156
|
-
function _inherits(subClass, superClass) {
|
157
|
-
if (typeof superClass !== "function" && superClass !== null) {
|
158
|
-
throw new TypeError("Super expression must either be null or a function");
|
159
|
-
}
|
160
|
-
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
161
|
-
constructor: {
|
162
|
-
value: subClass,
|
163
|
-
writable: true,
|
164
|
-
configurable: true
|
165
|
-
}
|
166
|
-
});
|
167
|
-
Object.defineProperty(subClass, "prototype", {
|
168
|
-
writable: false
|
169
|
-
});
|
170
|
-
if (superClass) _setPrototypeOf(subClass, superClass);
|
171
|
-
}
|
172
|
-
|
173
148
|
function _getPrototypeOf(o) {
|
174
149
|
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
175
150
|
return o.__proto__ || Object.getPrototypeOf(o);
|
@@ -178,15 +153,12 @@ function _getPrototypeOf(o) {
|
|
178
153
|
}
|
179
154
|
|
180
155
|
function _isNativeReflectConstruct() {
|
181
|
-
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
182
|
-
if (Reflect.construct.sham) return false;
|
183
|
-
if (typeof Proxy === "function") return true;
|
184
156
|
try {
|
185
|
-
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
186
|
-
|
187
|
-
|
188
|
-
return
|
189
|
-
}
|
157
|
+
var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
158
|
+
} catch (t) {}
|
159
|
+
return (_isNativeReflectConstruct = function () {
|
160
|
+
return !!t;
|
161
|
+
})();
|
190
162
|
}
|
191
163
|
|
192
164
|
function _assertThisInitialized(self) {
|
@@ -205,25 +177,40 @@ function _possibleConstructorReturn(self, call) {
|
|
205
177
|
return _assertThisInitialized(self);
|
206
178
|
}
|
207
179
|
|
208
|
-
function
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
} else {
|
217
|
-
result = Super.apply(this, arguments);
|
218
|
-
}
|
219
|
-
return _possibleConstructorReturn(this, result);
|
180
|
+
function _callSuper(t, o, e) {
|
181
|
+
return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));
|
182
|
+
}
|
183
|
+
|
184
|
+
function _setPrototypeOf(o, p) {
|
185
|
+
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
186
|
+
o.__proto__ = p;
|
187
|
+
return o;
|
220
188
|
};
|
189
|
+
return _setPrototypeOf(o, p);
|
190
|
+
}
|
191
|
+
|
192
|
+
function _inherits(subClass, superClass) {
|
193
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
194
|
+
throw new TypeError("Super expression must either be null or a function");
|
195
|
+
}
|
196
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
197
|
+
constructor: {
|
198
|
+
value: subClass,
|
199
|
+
writable: true,
|
200
|
+
configurable: true
|
201
|
+
}
|
202
|
+
});
|
203
|
+
Object.defineProperty(subClass, "prototype", {
|
204
|
+
writable: false
|
205
|
+
});
|
206
|
+
if (superClass) _setPrototypeOf(subClass, superClass);
|
221
207
|
}
|
222
208
|
|
223
209
|
// import { RemoteCompatibleSource, RemoteSource } from "../source/remote";
|
224
210
|
|
225
211
|
// import { SerializedI18nSchema } from "./future/i18n";
|
226
212
|
// import { SerializedOneOfSchema } from "./future/oneOf";
|
213
|
+
|
227
214
|
var Schema = /*#__PURE__*/function () {
|
228
215
|
function Schema() {
|
229
216
|
_classCallCheck(this, Schema);
|
@@ -309,11 +296,10 @@ var Expr = /*#__PURE__*/_createClass(function Expr(span) {
|
|
309
296
|
});
|
310
297
|
var StringLiteral = /*#__PURE__*/function (_Expr) {
|
311
298
|
_inherits(StringLiteral, _Expr);
|
312
|
-
var _super = _createSuper(StringLiteral);
|
313
299
|
function StringLiteral(value, span) {
|
314
300
|
var _this;
|
315
301
|
_classCallCheck(this, StringLiteral);
|
316
|
-
_this =
|
302
|
+
_this = _callSuper(this, StringLiteral, [span]);
|
317
303
|
_defineProperty(_assertThisInitialized(_this), "type", "StringLiteral");
|
318
304
|
_this.value = value;
|
319
305
|
return _this;
|
@@ -328,11 +314,10 @@ var StringLiteral = /*#__PURE__*/function (_Expr) {
|
|
328
314
|
}(Expr);
|
329
315
|
var Sym = /*#__PURE__*/function (_Expr2) {
|
330
316
|
_inherits(Sym, _Expr2);
|
331
|
-
var _super2 = _createSuper(Sym);
|
332
317
|
function Sym(value, span) {
|
333
318
|
var _this2;
|
334
319
|
_classCallCheck(this, Sym);
|
335
|
-
_this2 =
|
320
|
+
_this2 = _callSuper(this, Sym, [span]);
|
336
321
|
_defineProperty(_assertThisInitialized(_this2), "type", "Sym");
|
337
322
|
_this2.value = value;
|
338
323
|
return _this2;
|
@@ -348,11 +333,10 @@ var Sym = /*#__PURE__*/function (_Expr2) {
|
|
348
333
|
var NilSym = new Sym("()");
|
349
334
|
var StringTemplate = /*#__PURE__*/function (_Expr3) {
|
350
335
|
_inherits(StringTemplate, _Expr3);
|
351
|
-
var _super3 = _createSuper(StringTemplate);
|
352
336
|
function StringTemplate(children, span) {
|
353
337
|
var _this3;
|
354
338
|
_classCallCheck(this, StringTemplate);
|
355
|
-
_this3 =
|
339
|
+
_this3 = _callSuper(this, StringTemplate, [span]);
|
356
340
|
_defineProperty(_assertThisInitialized(_this3), "type", "StringTemplate");
|
357
341
|
_this3.children = children;
|
358
342
|
return _this3;
|
@@ -373,11 +357,10 @@ var StringTemplate = /*#__PURE__*/function (_Expr3) {
|
|
373
357
|
}(Expr);
|
374
358
|
var Call = /*#__PURE__*/function (_Expr4) {
|
375
359
|
_inherits(Call, _Expr4);
|
376
|
-
var _super4 = _createSuper(Call);
|
377
360
|
function Call(children, isAnon, span) {
|
378
361
|
var _this4;
|
379
362
|
_classCallCheck(this, Call);
|
380
|
-
_this4 =
|
363
|
+
_this4 = _callSuper(this, Call, [span]);
|
381
364
|
_defineProperty(_assertThisInitialized(_this4), "type", "Call");
|
382
365
|
_this4.children = children;
|
383
366
|
_this4.isAnon = isAnon;
|
@@ -422,25 +405,102 @@ var FILE_REF_PROP = "_ref";
|
|
422
405
|
*
|
423
406
|
*/
|
424
407
|
|
425
|
-
function file(ref, metadata) {
|
408
|
+
function file$1(ref, metadata) {
|
426
409
|
return _defineProperty(_defineProperty(_defineProperty({}, FILE_REF_PROP, ref), VAL_EXTENSION, "file"), "metadata", metadata);
|
427
410
|
}
|
428
411
|
function isFile(obj) {
|
429
412
|
return _typeof(obj) === "object" && obj !== null && VAL_EXTENSION in obj && obj[VAL_EXTENSION] === "file" && FILE_REF_PROP in obj && typeof obj[FILE_REF_PROP] === "string";
|
430
413
|
}
|
431
414
|
|
415
|
+
var FileSchema = /*#__PURE__*/function (_Schema) {
|
416
|
+
_inherits(FileSchema, _Schema);
|
417
|
+
function FileSchema(options) {
|
418
|
+
var _this;
|
419
|
+
var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
420
|
+
_classCallCheck(this, FileSchema);
|
421
|
+
_this = _callSuper(this, FileSchema);
|
422
|
+
_this.options = options;
|
423
|
+
_this.opt = opt;
|
424
|
+
return _this;
|
425
|
+
}
|
426
|
+
_createClass(FileSchema, [{
|
427
|
+
key: "validate",
|
428
|
+
value: function validate(path, src) {
|
429
|
+
if (this.opt && (src === null || src === undefined)) {
|
430
|
+
return false;
|
431
|
+
}
|
432
|
+
if (src === null || src === undefined) {
|
433
|
+
return _defineProperty({}, path, [{
|
434
|
+
message: "Non-optional file was null or undefined.",
|
435
|
+
value: src
|
436
|
+
}]);
|
437
|
+
}
|
438
|
+
if (typeof src[FILE_REF_PROP] !== "string") {
|
439
|
+
return _defineProperty({}, path, [{
|
440
|
+
message: "File did not have a file reference string. Got: ".concat(_typeof(src[FILE_REF_PROP])),
|
441
|
+
value: src
|
442
|
+
}]);
|
443
|
+
}
|
444
|
+
if (src[VAL_EXTENSION] !== "file") {
|
445
|
+
return _defineProperty({}, path, [{
|
446
|
+
message: "File did not have the valid file extension type. Got: ".concat(src[VAL_EXTENSION]),
|
447
|
+
value: src
|
448
|
+
}]);
|
449
|
+
}
|
450
|
+
if (src.metadata) {
|
451
|
+
return _defineProperty({}, path, [{
|
452
|
+
message: "Found metadata, but it could not be validated. File metadata must be an object with the required props: width (positive number), height (positive number) and sha256 (string of length 64 of the base16 hash).",
|
453
|
+
// These validation errors will have to be picked up by logic outside of this package and revalidated. Reasons: 1) we have to read files to verify the metadata, which is handled differently in different runtimes (Browser, QuickJS, Node.js); 2) we want to keep this package dependency free.
|
454
|
+
value: src,
|
455
|
+
fixes: ["file:check-metadata"]
|
456
|
+
}]);
|
457
|
+
}
|
458
|
+
return _defineProperty({}, path, [{
|
459
|
+
message: "Missing File metadata.",
|
460
|
+
value: src,
|
461
|
+
fixes: ["file:add-metadata"]
|
462
|
+
}]);
|
463
|
+
}
|
464
|
+
}, {
|
465
|
+
key: "assert",
|
466
|
+
value: function assert(src) {
|
467
|
+
if (this.opt && (src === null || src === undefined)) {
|
468
|
+
return true;
|
469
|
+
}
|
470
|
+
return (src === null || src === void 0 ? void 0 : src[FILE_REF_PROP]) === "file" && (src === null || src === void 0 ? void 0 : src[VAL_EXTENSION]) === "file";
|
471
|
+
}
|
472
|
+
}, {
|
473
|
+
key: "optional",
|
474
|
+
value: function optional() {
|
475
|
+
return new FileSchema(this.options, true);
|
476
|
+
}
|
477
|
+
}, {
|
478
|
+
key: "serialize",
|
479
|
+
value: function serialize() {
|
480
|
+
return {
|
481
|
+
type: "file",
|
482
|
+
options: this.options,
|
483
|
+
opt: this.opt
|
484
|
+
};
|
485
|
+
}
|
486
|
+
}]);
|
487
|
+
return FileSchema;
|
488
|
+
}(Schema);
|
489
|
+
var file = function file(options) {
|
490
|
+
return new FileSchema(options);
|
491
|
+
};
|
432
492
|
function convertFileSource(src) {
|
433
|
-
var _src$
|
493
|
+
var _src$metadata3, _src$metadata4;
|
434
494
|
// TODO: /public should be configurable
|
435
495
|
if (!src[FILE_REF_PROP].startsWith("/public")) {
|
436
|
-
var _src$metadata;
|
496
|
+
var _src$metadata, _src$metadata2;
|
437
497
|
return {
|
438
|
-
url: src[FILE_REF_PROP] + "?sha256=".concat((_src$
|
498
|
+
url: src[FILE_REF_PROP] + ((_src$metadata = src.metadata) !== null && _src$metadata !== void 0 && _src$metadata.sha256 ? "?sha256=".concat((_src$metadata2 = src.metadata) === null || _src$metadata2 === void 0 ? void 0 : _src$metadata2.sha256) : ""),
|
439
499
|
metadata: src.metadata
|
440
500
|
};
|
441
501
|
}
|
442
502
|
return {
|
443
|
-
url: src[FILE_REF_PROP].slice("/public".length) + "?sha256=".concat((_src$
|
503
|
+
url: src[FILE_REF_PROP].slice("/public".length) + ((_src$metadata3 = src.metadata) !== null && _src$metadata3 !== void 0 && _src$metadata3.sha256 ? "?sha256=".concat((_src$metadata4 = src.metadata) === null || _src$metadata4 === void 0 ? void 0 : _src$metadata4.sha256) : ""),
|
444
504
|
metadata: src.metadata
|
445
505
|
};
|
446
506
|
}
|
@@ -480,6 +540,7 @@ function getValPath(valOrSelector) {
|
|
480
540
|
exports.Call = Call;
|
481
541
|
exports.Expr = Expr;
|
482
542
|
exports.FILE_REF_PROP = FILE_REF_PROP;
|
543
|
+
exports.FileSchema = FileSchema;
|
483
544
|
exports.GenericSelector = GenericSelector;
|
484
545
|
exports.GetSchema = GetSchema;
|
485
546
|
exports.GetSource = GetSource;
|
@@ -490,9 +551,9 @@ exports.StringLiteral = StringLiteral;
|
|
490
551
|
exports.StringTemplate = StringTemplate;
|
491
552
|
exports.Sym = Sym;
|
492
553
|
exports.VAL_EXTENSION = VAL_EXTENSION;
|
554
|
+
exports._callSuper = _callSuper;
|
493
555
|
exports._classCallCheck = _classCallCheck;
|
494
556
|
exports._createClass = _createClass;
|
495
|
-
exports._createSuper = _createSuper;
|
496
557
|
exports._defineProperty = _defineProperty;
|
497
558
|
exports._inherits = _inherits;
|
498
559
|
exports._objectSpread2 = _objectSpread2;
|
@@ -501,6 +562,7 @@ exports._toConsumableArray = _toConsumableArray;
|
|
501
562
|
exports._typeof = _typeof;
|
502
563
|
exports.convertFileSource = convertFileSource;
|
503
564
|
exports.file = file;
|
565
|
+
exports.file$1 = file$1;
|
504
566
|
exports.getSchema = getSchema;
|
505
567
|
exports.getValPath = getValPath;
|
506
568
|
exports.isFile = isFile;
|