@valbuild/core 0.99.1 → 0.101.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 +15 -0
- package/dist/declarations/src/initSchema.d.ts +21 -0
- package/dist/declarations/src/initVal.d.ts +2 -0
- package/dist/declarations/src/schema/array.d.ts +2 -1
- package/dist/declarations/src/schema/boolean.d.ts +2 -1
- package/dist/declarations/src/schema/color.d.ts +57 -0
- package/dist/declarations/src/schema/colorFormat.d.ts +83 -0
- package/dist/declarations/src/schema/date.d.ts +2 -1
- package/dist/declarations/src/schema/datetime.d.ts +2 -1
- package/dist/declarations/src/schema/file.d.ts +2 -1
- package/dist/declarations/src/schema/image.d.ts +2 -1
- package/dist/declarations/src/schema/index.d.ts +24 -1
- package/dist/declarations/src/schema/keyOf.d.ts +2 -1
- package/dist/declarations/src/schema/literal.d.ts +2 -1
- package/dist/declarations/src/schema/number.d.ts +2 -1
- package/dist/declarations/src/schema/object.d.ts +2 -1
- package/dist/declarations/src/schema/record.d.ts +46 -3
- package/dist/declarations/src/schema/richtext.d.ts +2 -1
- package/dist/declarations/src/schema/route.d.ts +2 -1
- package/dist/declarations/src/schema/string.d.ts +2 -1
- package/dist/declarations/src/schema/union.d.ts +9 -1
- package/dist/declarations/src/schema/validation/ValidationFix.d.ts +1 -1
- package/dist/declarations/src/selector/index.d.ts +3 -2
- package/dist/declarations/src/source/index.d.ts +3 -2
- package/dist/declarations/src/source/json.d.ts +73 -0
- package/dist/{index-28d99c34.cjs.prod.js → index-049780fa.cjs.prod.js} +1238 -181
- package/dist/{index-b2601ac3.cjs.dev.js → index-3e2d700e.cjs.dev.js} +1238 -181
- package/dist/{index-204b5d78.esm.js → index-a18c24c2.esm.js} +1236 -182
- package/dist/valbuild-core.cjs.dev.js +4 -1
- package/dist/valbuild-core.cjs.prod.js +4 -1
- package/dist/valbuild-core.esm.js +1 -1
- package/package.json +1 -1
- package/patch/dist/valbuild-core-patch.cjs.dev.js +1 -1
- package/patch/dist/valbuild-core-patch.cjs.prod.js +1 -1
- package/patch/dist/valbuild-core-patch.esm.js +2 -2
|
@@ -654,6 +654,13 @@ var FileSchema = /*#__PURE__*/function (_Schema) {
|
|
|
654
654
|
value: function hidden() {
|
|
655
655
|
return new FileSchema(this.options, this.opt, this.isRemote, this.customValidateFunctions, this.moduleMetadata, this.isReadonly, true, this.description);
|
|
656
656
|
}
|
|
657
|
+
}, {
|
|
658
|
+
key: "executeCustomValidateAt",
|
|
659
|
+
value: function executeCustomValidateAt(path, src) {
|
|
660
|
+
return this.executeCustomValidateFunctions(src, this.customValidateFunctions, {
|
|
661
|
+
path: path
|
|
662
|
+
});
|
|
663
|
+
}
|
|
657
664
|
}, {
|
|
658
665
|
key: "executeSerialize",
|
|
659
666
|
value: function executeSerialize() {
|
|
@@ -902,6 +909,13 @@ var StringSchema = /*#__PURE__*/function (_Schema) {
|
|
|
902
909
|
value: function raw() {
|
|
903
910
|
return new StringSchema(this.options, this.opt, true, this.customValidateFunctions, this.renderInput, this.isReadonly, this.isHidden, this.description);
|
|
904
911
|
}
|
|
912
|
+
}, {
|
|
913
|
+
key: "executeCustomValidateAt",
|
|
914
|
+
value: function executeCustomValidateAt(path, src) {
|
|
915
|
+
return this.executeCustomValidateFunctions(src, this.customValidateFunctions, {
|
|
916
|
+
path: path
|
|
917
|
+
});
|
|
918
|
+
}
|
|
905
919
|
}, {
|
|
906
920
|
key: "executeSerialize",
|
|
907
921
|
value: function executeSerialize() {
|
|
@@ -1118,6 +1132,13 @@ var ObjectSchema = /*#__PURE__*/function (_Schema) {
|
|
|
1118
1132
|
value: function hidden() {
|
|
1119
1133
|
return new ObjectSchema(this.items, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description);
|
|
1120
1134
|
}
|
|
1135
|
+
}, {
|
|
1136
|
+
key: "executeCustomValidateAt",
|
|
1137
|
+
value: function executeCustomValidateAt(path, src) {
|
|
1138
|
+
return this.executeCustomValidateFunctions(src, this.customValidateFunctions, {
|
|
1139
|
+
path: path
|
|
1140
|
+
});
|
|
1141
|
+
}
|
|
1121
1142
|
}, {
|
|
1122
1143
|
key: "executeSerialize",
|
|
1123
1144
|
value: function executeSerialize() {
|
|
@@ -1277,6 +1298,13 @@ var ArraySchema = /*#__PURE__*/function (_Schema) {
|
|
|
1277
1298
|
value: function hidden() {
|
|
1278
1299
|
return new ArraySchema(this.item, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description, this.renderInput);
|
|
1279
1300
|
}
|
|
1301
|
+
}, {
|
|
1302
|
+
key: "executeCustomValidateAt",
|
|
1303
|
+
value: function executeCustomValidateAt(path, src) {
|
|
1304
|
+
return this.executeCustomValidateFunctions(src, this.customValidateFunctions, {
|
|
1305
|
+
path: path
|
|
1306
|
+
});
|
|
1307
|
+
}
|
|
1280
1308
|
}, {
|
|
1281
1309
|
key: "executeSerialize",
|
|
1282
1310
|
value: function executeSerialize() {
|
|
@@ -1465,6 +1493,13 @@ var LiteralSchema = /*#__PURE__*/function (_Schema) {
|
|
|
1465
1493
|
value: function hidden() {
|
|
1466
1494
|
return new LiteralSchema(this.value, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description);
|
|
1467
1495
|
}
|
|
1496
|
+
}, {
|
|
1497
|
+
key: "executeCustomValidateAt",
|
|
1498
|
+
value: function executeCustomValidateAt(path, src) {
|
|
1499
|
+
return this.executeCustomValidateFunctions(src, this.customValidateFunctions, {
|
|
1500
|
+
path: path
|
|
1501
|
+
});
|
|
1502
|
+
}
|
|
1468
1503
|
}, {
|
|
1469
1504
|
key: "executeSerialize",
|
|
1470
1505
|
value: function executeSerialize() {
|
|
@@ -1823,6 +1858,64 @@ var UnionSchema = /*#__PURE__*/function (_Schema) {
|
|
|
1823
1858
|
value: function hidden() {
|
|
1824
1859
|
return new UnionSchema(this.key, this.items, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description);
|
|
1825
1860
|
}
|
|
1861
|
+
}, {
|
|
1862
|
+
key: "executeCustomValidateAt",
|
|
1863
|
+
value: function executeCustomValidateAt(path, src) {
|
|
1864
|
+
var errors = this.executeCustomValidateFunctions(src, this.customValidateFunctions, {
|
|
1865
|
+
path: path
|
|
1866
|
+
});
|
|
1867
|
+
// A tagged union's variants share the union's path, so `Internal.resolvePath`
|
|
1868
|
+
// stops here and a variant's OWN validator would never be reached. Dispatch
|
|
1869
|
+
// into the variant this value takes — the union is the only node that knows
|
|
1870
|
+
// which one that is.
|
|
1871
|
+
var matched = this.matchedVariant(src);
|
|
1872
|
+
if (matched) {
|
|
1873
|
+
errors.push.apply(errors, _toConsumableArray(matched["executeCustomValidateAt"](path, src)));
|
|
1874
|
+
}
|
|
1875
|
+
return errors;
|
|
1876
|
+
}
|
|
1877
|
+
|
|
1878
|
+
/**
|
|
1879
|
+
* The variant schema a value takes, for a TAGGED union (string `key`). `null`
|
|
1880
|
+
* for a literal union (its variants are leaves with nothing to descend into) or
|
|
1881
|
+
* when the value matches none of them — a structural error `executeValidate`
|
|
1882
|
+
* already reports.
|
|
1883
|
+
*/
|
|
1884
|
+
}, {
|
|
1885
|
+
key: "matchedVariant",
|
|
1886
|
+
value: function matchedVariant(src) {
|
|
1887
|
+
var key = this.key;
|
|
1888
|
+
if (typeof key !== "string" || !Array.isArray(this.items)) {
|
|
1889
|
+
return null;
|
|
1890
|
+
}
|
|
1891
|
+
if (src === null || _typeof(src) !== "object" || Array.isArray(src)) {
|
|
1892
|
+
return null;
|
|
1893
|
+
}
|
|
1894
|
+
var tag = src[key];
|
|
1895
|
+
if (typeof tag !== "string") {
|
|
1896
|
+
return null;
|
|
1897
|
+
}
|
|
1898
|
+
var objectSchemas = this.items;
|
|
1899
|
+
var _iterator4 = result._createForOfIteratorHelper(objectSchemas),
|
|
1900
|
+
_step4;
|
|
1901
|
+
try {
|
|
1902
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
1903
|
+
var item = _step4.value;
|
|
1904
|
+
if (!(item instanceof ObjectSchema)) {
|
|
1905
|
+
continue;
|
|
1906
|
+
}
|
|
1907
|
+
var tagSchema = item["items"][key];
|
|
1908
|
+
if (tagSchema instanceof LiteralSchema && tagSchema["value"] === tag) {
|
|
1909
|
+
return item;
|
|
1910
|
+
}
|
|
1911
|
+
}
|
|
1912
|
+
} catch (err) {
|
|
1913
|
+
_iterator4.e(err);
|
|
1914
|
+
} finally {
|
|
1915
|
+
_iterator4.f();
|
|
1916
|
+
}
|
|
1917
|
+
return null;
|
|
1918
|
+
}
|
|
1826
1919
|
}, {
|
|
1827
1920
|
key: "executeSerialize",
|
|
1828
1921
|
value: function executeSerialize() {
|
|
@@ -2134,6 +2227,13 @@ var ImageSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2134
2227
|
value: function hidden() {
|
|
2135
2228
|
return new ImageSchema(this.options, this.opt, this.isRemote, this.customValidateFunctions, this.moduleMetadata, this.isReadonly, true, this.description);
|
|
2136
2229
|
}
|
|
2230
|
+
}, {
|
|
2231
|
+
key: "executeCustomValidateAt",
|
|
2232
|
+
value: function executeCustomValidateAt(path, src) {
|
|
2233
|
+
return this.executeCustomValidateFunctions(src, this.customValidateFunctions, {
|
|
2234
|
+
path: path
|
|
2235
|
+
});
|
|
2236
|
+
}
|
|
2137
2237
|
}, {
|
|
2138
2238
|
key: "executeSerialize",
|
|
2139
2239
|
value: function executeSerialize() {
|
|
@@ -2309,6 +2409,13 @@ var RouteSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2309
2409
|
value: function hidden() {
|
|
2310
2410
|
return new RouteSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description);
|
|
2311
2411
|
}
|
|
2412
|
+
}, {
|
|
2413
|
+
key: "executeCustomValidateAt",
|
|
2414
|
+
value: function executeCustomValidateAt(path, src) {
|
|
2415
|
+
return this.executeCustomValidateFunctions(src, this.customValidateFunctions, {
|
|
2416
|
+
path: path
|
|
2417
|
+
});
|
|
2418
|
+
}
|
|
2312
2419
|
}, {
|
|
2313
2420
|
key: "executeSerialize",
|
|
2314
2421
|
value: function executeSerialize() {
|
|
@@ -2847,6 +2954,13 @@ var RichTextSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2847
2954
|
value: function hidden() {
|
|
2848
2955
|
return new RichTextSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description);
|
|
2849
2956
|
}
|
|
2957
|
+
}, {
|
|
2958
|
+
key: "executeCustomValidateAt",
|
|
2959
|
+
value: function executeCustomValidateAt(path, src) {
|
|
2960
|
+
return this.executeCustomValidateFunctions(src, this.customValidateFunctions, {
|
|
2961
|
+
path: path
|
|
2962
|
+
});
|
|
2963
|
+
}
|
|
2850
2964
|
}, {
|
|
2851
2965
|
key: "executeSerialize",
|
|
2852
2966
|
value: function executeSerialize() {
|
|
@@ -2896,6 +3010,290 @@ var richtext = function richtext(options) {
|
|
|
2896
3010
|
return new RichTextSchema(options !== null && options !== void 0 ? options : {});
|
|
2897
3011
|
};
|
|
2898
3012
|
|
|
3013
|
+
function _regeneratorDefine(e, r, n, t) {
|
|
3014
|
+
var i = Object.defineProperty;
|
|
3015
|
+
try {
|
|
3016
|
+
i({}, "", {});
|
|
3017
|
+
} catch (e) {
|
|
3018
|
+
i = 0;
|
|
3019
|
+
}
|
|
3020
|
+
_regeneratorDefine = function (e, r, n, t) {
|
|
3021
|
+
function o(r, n) {
|
|
3022
|
+
_regeneratorDefine(e, r, function (e) {
|
|
3023
|
+
return this._invoke(r, n, e);
|
|
3024
|
+
});
|
|
3025
|
+
}
|
|
3026
|
+
r ? i ? i(e, r, {
|
|
3027
|
+
value: n,
|
|
3028
|
+
enumerable: !t,
|
|
3029
|
+
configurable: !t,
|
|
3030
|
+
writable: !t
|
|
3031
|
+
}) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
|
|
3032
|
+
}, _regeneratorDefine(e, r, n, t);
|
|
3033
|
+
}
|
|
3034
|
+
|
|
3035
|
+
function _regenerator() {
|
|
3036
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
|
|
3037
|
+
var e,
|
|
3038
|
+
t,
|
|
3039
|
+
r = "function" == typeof Symbol ? Symbol : {},
|
|
3040
|
+
n = r.iterator || "@@iterator",
|
|
3041
|
+
o = r.toStringTag || "@@toStringTag";
|
|
3042
|
+
function i(r, n, o, i) {
|
|
3043
|
+
var c = n && n.prototype instanceof Generator ? n : Generator,
|
|
3044
|
+
u = Object.create(c.prototype);
|
|
3045
|
+
return _regeneratorDefine(u, "_invoke", function (r, n, o) {
|
|
3046
|
+
var i,
|
|
3047
|
+
c,
|
|
3048
|
+
u,
|
|
3049
|
+
f = 0,
|
|
3050
|
+
p = o || [],
|
|
3051
|
+
y = !1,
|
|
3052
|
+
G = {
|
|
3053
|
+
p: 0,
|
|
3054
|
+
n: 0,
|
|
3055
|
+
v: e,
|
|
3056
|
+
a: d,
|
|
3057
|
+
f: d.bind(e, 4),
|
|
3058
|
+
d: function (t, r) {
|
|
3059
|
+
return i = t, c = 0, u = e, G.n = r, a;
|
|
3060
|
+
}
|
|
3061
|
+
};
|
|
3062
|
+
function d(r, n) {
|
|
3063
|
+
for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
|
|
3064
|
+
var o,
|
|
3065
|
+
i = p[t],
|
|
3066
|
+
d = G.p,
|
|
3067
|
+
l = i[2];
|
|
3068
|
+
r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0));
|
|
3069
|
+
}
|
|
3070
|
+
if (o || r > 1) return a;
|
|
3071
|
+
throw y = !0, n;
|
|
3072
|
+
}
|
|
3073
|
+
return function (o, p, l) {
|
|
3074
|
+
if (f > 1) throw TypeError("Generator is already running");
|
|
3075
|
+
for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
|
|
3076
|
+
i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
|
|
3077
|
+
try {
|
|
3078
|
+
if (f = 2, i) {
|
|
3079
|
+
if (c || (o = "next"), t = i[o]) {
|
|
3080
|
+
if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
|
|
3081
|
+
if (!t.done) return t;
|
|
3082
|
+
u = t.value, c < 2 && (c = 0);
|
|
3083
|
+
} else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
|
|
3084
|
+
i = e;
|
|
3085
|
+
} else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
|
|
3086
|
+
} catch (t) {
|
|
3087
|
+
i = e, c = 1, u = t;
|
|
3088
|
+
} finally {
|
|
3089
|
+
f = 1;
|
|
3090
|
+
}
|
|
3091
|
+
}
|
|
3092
|
+
return {
|
|
3093
|
+
value: t,
|
|
3094
|
+
done: y
|
|
3095
|
+
};
|
|
3096
|
+
};
|
|
3097
|
+
}(r, o, i), !0), u;
|
|
3098
|
+
}
|
|
3099
|
+
var a = {};
|
|
3100
|
+
function Generator() {}
|
|
3101
|
+
function GeneratorFunction() {}
|
|
3102
|
+
function GeneratorFunctionPrototype() {}
|
|
3103
|
+
t = Object.getPrototypeOf;
|
|
3104
|
+
var c = [][n] ? t(t([][n]())) : (_regeneratorDefine(t = {}, n, function () {
|
|
3105
|
+
return this;
|
|
3106
|
+
}), t),
|
|
3107
|
+
u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
|
|
3108
|
+
function f(e) {
|
|
3109
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
|
|
3110
|
+
}
|
|
3111
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine(u), _regeneratorDefine(u, o, "Generator"), _regeneratorDefine(u, n, function () {
|
|
3112
|
+
return this;
|
|
3113
|
+
}), _regeneratorDefine(u, "toString", function () {
|
|
3114
|
+
return "[object Generator]";
|
|
3115
|
+
}), (_regenerator = function () {
|
|
3116
|
+
return {
|
|
3117
|
+
w: i,
|
|
3118
|
+
m: f
|
|
3119
|
+
};
|
|
3120
|
+
})();
|
|
3121
|
+
}
|
|
3122
|
+
|
|
3123
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
3124
|
+
try {
|
|
3125
|
+
var i = n[a](c),
|
|
3126
|
+
u = i.value;
|
|
3127
|
+
} catch (n) {
|
|
3128
|
+
return void e(n);
|
|
3129
|
+
}
|
|
3130
|
+
i.done ? t(u) : Promise.resolve(u).then(r, o);
|
|
3131
|
+
}
|
|
3132
|
+
function _asyncToGenerator(n) {
|
|
3133
|
+
return function () {
|
|
3134
|
+
var t = this,
|
|
3135
|
+
e = arguments;
|
|
3136
|
+
return new Promise(function (r, o) {
|
|
3137
|
+
var a = n.apply(t, e);
|
|
3138
|
+
function _next(n) {
|
|
3139
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
|
|
3140
|
+
}
|
|
3141
|
+
function _throw(n) {
|
|
3142
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
|
|
3143
|
+
}
|
|
3144
|
+
_next(void 0);
|
|
3145
|
+
});
|
|
3146
|
+
};
|
|
3147
|
+
}
|
|
3148
|
+
|
|
3149
|
+
/**
|
|
3150
|
+
* The string used as the `_type` discriminator of a {@link JsonSource}.
|
|
3151
|
+
*/
|
|
3152
|
+
var JSON_VAL_EXTENSION_TAG = "json";
|
|
3153
|
+
|
|
3154
|
+
/**
|
|
3155
|
+
* The lazy import thunk a {@link JsonSource} carries at runtime. It is NOT part
|
|
3156
|
+
* of the {@link JsonSource} type because `Source` must stay JSON-serializable
|
|
3157
|
+
* (it is sent over the wire as `Json`); the thunk is a runtime-only detail,
|
|
3158
|
+
* read via {@link getJsonImport}.
|
|
3159
|
+
*/
|
|
3160
|
+
|
|
3161
|
+
/**
|
|
3162
|
+
* A JSON source represents a record/router entry whose value is stored in a
|
|
3163
|
+
* separate `*.val.json` file and loaded lazily via a dynamic `import()` thunk.
|
|
3164
|
+
*
|
|
3165
|
+
* This is what `c.json(() => import("./entry.val.json"))` returns.
|
|
3166
|
+
*
|
|
3167
|
+
* The *type* is a pure-JSON marker (`{ _type: "json", patch_id? }`) so that
|
|
3168
|
+
* `Source` stays JSON-serializable. At runtime the value additionally carries a
|
|
3169
|
+
* lazy import thunk (read via {@link getJsonImport}); over the wire only the
|
|
3170
|
+
* marker is sent.
|
|
3171
|
+
*
|
|
3172
|
+
* The phantom type parameter `T` is the (loosened, see {@link JsonOf}) type of
|
|
3173
|
+
* the value the JSON file resolves to. It is covariant: a `JsonSource` of a
|
|
3174
|
+
* narrower value type is assignable to a `JsonSource` of a wider one.
|
|
3175
|
+
*/
|
|
3176
|
+
|
|
3177
|
+
function json(importThunk) {
|
|
3178
|
+
return _defineProperty(_defineProperty({}, VAL_EXTENSION, JSON_VAL_EXTENSION_TAG), "_import", importThunk);
|
|
3179
|
+
}
|
|
3180
|
+
function isJson(obj) {
|
|
3181
|
+
return _typeof(obj) === "object" && obj !== null && VAL_EXTENSION in obj && obj[VAL_EXTENSION] === JSON_VAL_EXTENSION_TAG;
|
|
3182
|
+
}
|
|
3183
|
+
|
|
3184
|
+
/**
|
|
3185
|
+
* Reads the runtime-only lazy import thunk from a {@link JsonSource}. Returns
|
|
3186
|
+
* `undefined` for a transport marker (sent over the wire without the thunk).
|
|
3187
|
+
*/
|
|
3188
|
+
function getJsonImport(source) {
|
|
3189
|
+
var candidate = source._import;
|
|
3190
|
+
return typeof candidate === "function" ? candidate : undefined;
|
|
3191
|
+
}
|
|
3192
|
+
|
|
3193
|
+
/**
|
|
3194
|
+
* Recursively resolves every {@link JsonSource} marker in a source tree by
|
|
3195
|
+
* invoking its lazy import thunk, returning a fully-inlined source. This backs
|
|
3196
|
+
* the eager `fetchVal`/`useVal` path (load everything).
|
|
3197
|
+
*
|
|
3198
|
+
* Markers without a runtime thunk (transport markers received over the wire)
|
|
3199
|
+
* are left as-is — there is nothing to load from them locally. Other branded
|
|
3200
|
+
* leaf sources (file/image/remote/richtext) are returned untouched.
|
|
3201
|
+
*/
|
|
3202
|
+
function resolveJsonValues(_x) {
|
|
3203
|
+
return _resolveJsonValues.apply(this, arguments);
|
|
3204
|
+
}
|
|
3205
|
+
|
|
3206
|
+
/**
|
|
3207
|
+
* Loosens a (strict) schema source type `T` into the type that a
|
|
3208
|
+
* `resolveJsonModule` import of the backing `*.val.json` can actually satisfy.
|
|
3209
|
+
*
|
|
3210
|
+
* Why this is needed: TypeScript widens literals when it infers the type of a
|
|
3211
|
+
* JSON module (e.g. `"a"` becomes `string`, `1` becomes `number`, and a branded
|
|
3212
|
+
* `_type: "file"` becomes `_type: string`). A strict schema type (with literal
|
|
3213
|
+
* unions, `RawString` brands, etc.) would therefore reject a perfectly valid
|
|
3214
|
+
* JSON file. `JsonOf<T>` performs the same widening at the type level so the
|
|
3215
|
+
* JSON content typechecks against the schema as strictly as JSON allows. Runtime
|
|
3216
|
+
* validation enforces the rest.
|
|
3217
|
+
*
|
|
3218
|
+
* The transform distributes over unions and recurses through objects/arrays,
|
|
3219
|
+
* preserving structure while widening every leaf literal. Val object-unions are
|
|
3220
|
+
* always discriminated, so distribute-and-recurse is sufficient (the discriminant
|
|
3221
|
+
* literal widens to its base type, but the per-variant shape stays distinct and a
|
|
3222
|
+
* concrete JSON value still matches exactly one variant).
|
|
3223
|
+
*/
|
|
3224
|
+
function _resolveJsonValues() {
|
|
3225
|
+
_resolveJsonValues = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(source) {
|
|
3226
|
+
var thunk, loaded, entries;
|
|
3227
|
+
return _regenerator().w(function (_context2) {
|
|
3228
|
+
while (1) switch (_context2.n) {
|
|
3229
|
+
case 0:
|
|
3230
|
+
if (!isJson(source)) {
|
|
3231
|
+
_context2.n = 3;
|
|
3232
|
+
break;
|
|
3233
|
+
}
|
|
3234
|
+
thunk = getJsonImport(source);
|
|
3235
|
+
if (thunk) {
|
|
3236
|
+
_context2.n = 1;
|
|
3237
|
+
break;
|
|
3238
|
+
}
|
|
3239
|
+
return _context2.a(2, source);
|
|
3240
|
+
case 1:
|
|
3241
|
+
_context2.n = 2;
|
|
3242
|
+
return thunk();
|
|
3243
|
+
case 2:
|
|
3244
|
+
loaded = _context2.v["default"];
|
|
3245
|
+
return _context2.a(2, resolveJsonValues(loaded));
|
|
3246
|
+
case 3:
|
|
3247
|
+
if (!Array.isArray(source)) {
|
|
3248
|
+
_context2.n = 4;
|
|
3249
|
+
break;
|
|
3250
|
+
}
|
|
3251
|
+
return _context2.a(2, Promise.all(source.map(function (item) {
|
|
3252
|
+
return resolveJsonValues(item);
|
|
3253
|
+
})));
|
|
3254
|
+
case 4:
|
|
3255
|
+
if (!(source !== null && _typeof(source) === "object")) {
|
|
3256
|
+
_context2.n = 7;
|
|
3257
|
+
break;
|
|
3258
|
+
}
|
|
3259
|
+
if (!(VAL_EXTENSION in source)) {
|
|
3260
|
+
_context2.n = 5;
|
|
3261
|
+
break;
|
|
3262
|
+
}
|
|
3263
|
+
return _context2.a(2, source);
|
|
3264
|
+
case 5:
|
|
3265
|
+
_context2.n = 6;
|
|
3266
|
+
return Promise.all(Object.entries(source).map(/*#__PURE__*/function () {
|
|
3267
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref2) {
|
|
3268
|
+
var _ref4, key, value, _t, _t2;
|
|
3269
|
+
return _regenerator().w(function (_context) {
|
|
3270
|
+
while (1) switch (_context.n) {
|
|
3271
|
+
case 0:
|
|
3272
|
+
_ref4 = _slicedToArray(_ref2, 2), key = _ref4[0], value = _ref4[1];
|
|
3273
|
+
_t = key;
|
|
3274
|
+
_context.n = 1;
|
|
3275
|
+
return resolveJsonValues(value);
|
|
3276
|
+
case 1:
|
|
3277
|
+
_t2 = _context.v;
|
|
3278
|
+
return _context.a(2, [_t, _t2]);
|
|
3279
|
+
}
|
|
3280
|
+
}, _callee);
|
|
3281
|
+
}));
|
|
3282
|
+
return function (_x2) {
|
|
3283
|
+
return _ref3.apply(this, arguments);
|
|
3284
|
+
};
|
|
3285
|
+
}()));
|
|
3286
|
+
case 6:
|
|
3287
|
+
entries = _context2.v;
|
|
3288
|
+
return _context2.a(2, Object.fromEntries(entries));
|
|
3289
|
+
case 7:
|
|
3290
|
+
return _context2.a(2, source);
|
|
3291
|
+
}
|
|
3292
|
+
}, _callee2);
|
|
3293
|
+
}));
|
|
3294
|
+
return _resolveJsonValues.apply(this, arguments);
|
|
3295
|
+
}
|
|
3296
|
+
|
|
2899
3297
|
var RegEx = /^(https?:\/\/[^/]+)\/file\/p\/([^/]+)\/b\/([^/]+)\/v\/([^/]+)\/h\/([^/]+)\/f\/([^/]+)\/p\/(.+)$/;
|
|
2900
3298
|
function splitRemoteRef(ref) {
|
|
2901
3299
|
if (ref[0] === "/") {
|
|
@@ -2937,6 +3335,20 @@ function splitRemoteRef(ref) {
|
|
|
2937
3335
|
};
|
|
2938
3336
|
}
|
|
2939
3337
|
|
|
3338
|
+
/**
|
|
3339
|
+
* The source type of a `.jsonValues()` record: every entry value is EITHER a
|
|
3340
|
+
* lazily loaded {@link JsonSource} whose resolved content is the (loosened, see
|
|
3341
|
+
* {@link JsonOf}) item type, OR the item value written inline.
|
|
3342
|
+
*
|
|
3343
|
+
* Inline values are accepted by the TYPE on purpose: hand-authoring an entry
|
|
3344
|
+
* directly in the `.val.ts` (or copying one in from a non-jsonValues record) is
|
|
3345
|
+
* the natural first thing to write, and a type error there is a dead end — the
|
|
3346
|
+
* author cannot see what to write instead. Validation reports the inline entry
|
|
3347
|
+
* (`jsonValues:extract-entry`) and `val validate --fix` moves it into its own
|
|
3348
|
+
* `*.val.json`, so the mistake is caught and repaired instead of blocking
|
|
3349
|
+
* authoring.
|
|
3350
|
+
*/
|
|
3351
|
+
|
|
2940
3352
|
var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
2941
3353
|
function RecordSchema(item) {
|
|
2942
3354
|
var _this;
|
|
@@ -2948,7 +3360,8 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2948
3360
|
var isReadonly = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
|
|
2949
3361
|
var isHidden = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : false;
|
|
2950
3362
|
var description = arguments.length > 8 ? arguments[8] : undefined;
|
|
2951
|
-
var
|
|
3363
|
+
var isJsonValues = arguments.length > 9 && arguments[9] !== undefined ? arguments[9] : false;
|
|
3364
|
+
var renderInput = arguments.length > 10 && arguments[10] !== undefined ? arguments[10] : null;
|
|
2952
3365
|
_classCallCheck(this, RecordSchema);
|
|
2953
3366
|
_this = _callSuper(this, RecordSchema);
|
|
2954
3367
|
_this.item = item;
|
|
@@ -2960,6 +3373,7 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2960
3373
|
_this.isReadonly = isReadonly;
|
|
2961
3374
|
_this.isHidden = isHidden;
|
|
2962
3375
|
_this.description = description;
|
|
3376
|
+
_this.isJsonValues = isJsonValues;
|
|
2963
3377
|
_this.renderInput = renderInput;
|
|
2964
3378
|
return _this;
|
|
2965
3379
|
}
|
|
@@ -2967,12 +3381,12 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2967
3381
|
return _createClass(RecordSchema, [{
|
|
2968
3382
|
key: "describe",
|
|
2969
3383
|
value: function describe(description) {
|
|
2970
|
-
return new RecordSchema(this.item, this.opt, this.customValidateFunctions, this.currentRouter, this.keySchema, this.mediaOptions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined, this.renderInput);
|
|
3384
|
+
return new RecordSchema(this.item, this.opt, this.customValidateFunctions, this.currentRouter, this.keySchema, this.mediaOptions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined, this.isJsonValues, this.renderInput);
|
|
2971
3385
|
}
|
|
2972
3386
|
}, {
|
|
2973
3387
|
key: "validate",
|
|
2974
3388
|
value: function validate(validationFunction) {
|
|
2975
|
-
return new RecordSchema(this.item, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.currentRouter, this.keySchema, this.mediaOptions, this.isReadonly, this.isHidden, this.description, this.renderInput);
|
|
3389
|
+
return new RecordSchema(this.item, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.currentRouter, this.keySchema, this.mediaOptions, this.isReadonly, this.isHidden, this.description, this.isJsonValues, this.renderInput);
|
|
2976
3390
|
}
|
|
2977
3391
|
}, {
|
|
2978
3392
|
key: "executeValidate",
|
|
@@ -3087,7 +3501,10 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
3087
3501
|
_this2.markKeyErrorsAtPath(entryErr, subPath);
|
|
3088
3502
|
}
|
|
3089
3503
|
error = _this2.mergeValidationErrors(error, entryErr);
|
|
3090
|
-
} else {
|
|
3504
|
+
} else if (_this2.isJsonValues && isJson(elem)) ; else {
|
|
3505
|
+
// Falls through for a jsonValues record whose entry content is inlined
|
|
3506
|
+
// (loaded in the UI, or hand-authored): same as a plain record — validate
|
|
3507
|
+
// the value against the item schema.
|
|
3091
3508
|
var subError = _this2.item["executeValidate"](subPath, elem);
|
|
3092
3509
|
error = _this2.mergeValidationErrors(error, subError);
|
|
3093
3510
|
}
|
|
@@ -3328,32 +3745,64 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
3328
3745
|
}, {
|
|
3329
3746
|
key: "nullable",
|
|
3330
3747
|
value: function nullable() {
|
|
3331
|
-
return new RecordSchema(this.item, true, this.customValidateFunctions, this.currentRouter, this.keySchema, this.mediaOptions, this.isReadonly, this.isHidden, this.description, this.renderInput);
|
|
3748
|
+
return new RecordSchema(this.item, true, this.customValidateFunctions, this.currentRouter, this.keySchema, this.mediaOptions, this.isReadonly, this.isHidden, this.description, this.isJsonValues, this.renderInput);
|
|
3332
3749
|
}
|
|
3333
3750
|
}, {
|
|
3334
3751
|
key: "readonly",
|
|
3335
3752
|
value: function readonly() {
|
|
3336
|
-
return new RecordSchema(this.item, this.opt, this.customValidateFunctions, this.currentRouter, this.keySchema, this.mediaOptions, true, this.isHidden, this.description, this.renderInput);
|
|
3753
|
+
return new RecordSchema(this.item, this.opt, this.customValidateFunctions, this.currentRouter, this.keySchema, this.mediaOptions, true, this.isHidden, this.description, this.isJsonValues, this.renderInput);
|
|
3337
3754
|
}
|
|
3338
3755
|
}, {
|
|
3339
3756
|
key: "hidden",
|
|
3340
3757
|
value: function hidden() {
|
|
3341
|
-
return new RecordSchema(this.item, this.opt, this.customValidateFunctions, this.currentRouter, this.keySchema, this.mediaOptions, this.isReadonly, true, this.description, this.renderInput);
|
|
3758
|
+
return new RecordSchema(this.item, this.opt, this.customValidateFunctions, this.currentRouter, this.keySchema, this.mediaOptions, this.isReadonly, true, this.description, this.isJsonValues, this.renderInput);
|
|
3342
3759
|
}
|
|
3343
3760
|
}, {
|
|
3344
3761
|
key: "router",
|
|
3345
3762
|
value: function router(_router) {
|
|
3346
|
-
return new RecordSchema(this.item, this.opt, this.customValidateFunctions, _router, this.keySchema, this.mediaOptions, this.isReadonly, this.isHidden, this.description, this.renderInput);
|
|
3763
|
+
return new RecordSchema(this.item, this.opt, this.customValidateFunctions, _router, this.keySchema, this.mediaOptions, this.isReadonly, this.isHidden, this.description, this.isJsonValues, this.renderInput);
|
|
3347
3764
|
}
|
|
3348
3765
|
}, {
|
|
3349
3766
|
key: "remote",
|
|
3350
3767
|
value: function remote() {
|
|
3351
3768
|
return new RecordSchema(this.item, this.opt, this.customValidateFunctions, this.currentRouter, this.keySchema, this.mediaOptions ? _objectSpread2(_objectSpread2({}, this.mediaOptions), {}, {
|
|
3352
3769
|
remote: true
|
|
3353
|
-
}) : undefined, this.isReadonly, this.isHidden, this.description, this.renderInput);
|
|
3770
|
+
}) : undefined, this.isReadonly, this.isHidden, this.description, this.isJsonValues, this.renderInput);
|
|
3354
3771
|
}
|
|
3772
|
+
|
|
3773
|
+
/**
|
|
3774
|
+
* Store each entry's value in its own lazily-loaded `*.val.json` file instead
|
|
3775
|
+
* of inlining it in the `.val.ts` module. Entry values become
|
|
3776
|
+
* {@link JsonSource} thunks (`c.json(() => import("./entry.val.json"))`),
|
|
3777
|
+
* which lets the runtime, the Studio and validation work one entry at a time
|
|
3778
|
+
* so a record/router can scale to many thousands of entries.
|
|
3779
|
+
*
|
|
3780
|
+
* Not supported on image/file galleries (`s.images()` / `s.files()`).
|
|
3781
|
+
*
|
|
3782
|
+
* Only supported on a module's ROOT record/router — a `.jsonValues()` record
|
|
3783
|
+
* nested inside an object/array/record is rejected at startup with a module
|
|
3784
|
+
* error, because the single-entry fetch endpoint, the Studio's content
|
|
3785
|
+
* substitution and content validation are all root-only.
|
|
3786
|
+
*/
|
|
3355
3787
|
}, {
|
|
3356
|
-
key: "
|
|
3788
|
+
key: "jsonValues",
|
|
3789
|
+
value: function jsonValues() {
|
|
3790
|
+
if (this.mediaOptions) {
|
|
3791
|
+
throw new Error(".jsonValues() cannot be used with image/file galleries (s.images()/s.files())");
|
|
3792
|
+
}
|
|
3793
|
+
if (this.customValidateFunctions.length > 0) {
|
|
3794
|
+
// `.jsonValues()` changes the source shape to JsonSource entries, so a
|
|
3795
|
+
// validator typed against the previous Src cannot be carried over. Refusing
|
|
3796
|
+
// is the point: silently dropping it left the developer looking at a
|
|
3797
|
+
// `.validate(...)` in their source file that never ran anywhere.
|
|
3798
|
+
throw new Error(".jsonValues() must come BEFORE .validate(): a validator added first is typed against the un-lazy source shape and cannot be carried over. Write s.record(...).jsonValues().validate(...) instead.");
|
|
3799
|
+
}
|
|
3800
|
+
return new RecordSchema(this.item, this.opt,
|
|
3801
|
+
// Empty by construction: the guard above rejects any that were registered.
|
|
3802
|
+
[], this.currentRouter, this.keySchema, this.mediaOptions, this.isReadonly, this.isHidden, this.description, true, this.renderInput);
|
|
3803
|
+
}
|
|
3804
|
+
}, {
|
|
3805
|
+
key: "getRouterValidations",
|
|
3357
3806
|
value: function getRouterValidations(path, src) {
|
|
3358
3807
|
if (!this.currentRouter) {
|
|
3359
3808
|
return false;
|
|
@@ -3394,6 +3843,13 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
3394
3843
|
}
|
|
3395
3844
|
return false;
|
|
3396
3845
|
}
|
|
3846
|
+
}, {
|
|
3847
|
+
key: "executeCustomValidateAt",
|
|
3848
|
+
value: function executeCustomValidateAt(path, src) {
|
|
3849
|
+
return this.executeCustomValidateFunctions(src, this.customValidateFunctions, {
|
|
3850
|
+
path: path
|
|
3851
|
+
});
|
|
3852
|
+
}
|
|
3397
3853
|
}, {
|
|
3398
3854
|
key: "executeSerialize",
|
|
3399
3855
|
value: function executeSerialize() {
|
|
@@ -3405,6 +3861,7 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
3405
3861
|
opt: this.opt,
|
|
3406
3862
|
router: (_this$currentRouter = this.currentRouter) === null || _this$currentRouter === void 0 ? void 0 : _this$currentRouter.getRouterId(),
|
|
3407
3863
|
customValidate: this.customValidateFunctions && ((_this$customValidateF = this.customValidateFunctions) === null || _this$customValidateF === void 0 ? void 0 : _this$customValidateF.length) > 0,
|
|
3864
|
+
jsonValues: this.isJsonValues ? true : undefined,
|
|
3408
3865
|
readonly: this.isReadonly,
|
|
3409
3866
|
hidden: this.isHidden,
|
|
3410
3867
|
description: this.description
|
|
@@ -3420,6 +3877,18 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
3420
3877
|
}
|
|
3421
3878
|
return result;
|
|
3422
3879
|
}
|
|
3880
|
+
|
|
3881
|
+
/**
|
|
3882
|
+
* Validate the loaded content of a single `.jsonValues()` entry against the
|
|
3883
|
+
* item schema. The server calls this once it has loaded the backing
|
|
3884
|
+
* `*.val.json` for an entry (the deep validation that `executeValidate`
|
|
3885
|
+
* defers).
|
|
3886
|
+
*/
|
|
3887
|
+
}, {
|
|
3888
|
+
key: "validateJsonEntryContent",
|
|
3889
|
+
value: function validateJsonEntryContent(path, content) {
|
|
3890
|
+
return this.item["executeValidate"](path, content);
|
|
3891
|
+
}
|
|
3423
3892
|
}, {
|
|
3424
3893
|
key: "executeRender",
|
|
3425
3894
|
value: function executeRender(sourcePath, src) {
|
|
@@ -3432,6 +3901,13 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
3432
3901
|
if (itemSrc === null || itemSrc === undefined) {
|
|
3433
3902
|
continue;
|
|
3434
3903
|
}
|
|
3904
|
+
if (isJson(itemSrc)) {
|
|
3905
|
+
// An un-loaded `.jsonValues()` entry: an opaque marker, not the item this
|
|
3906
|
+
// schema describes. Skipping it is what makes rendering a partially
|
|
3907
|
+
// loaded record work — the result comes out covering exactly the loaded
|
|
3908
|
+
// keys, and the caller renders a placeholder for the rest.
|
|
3909
|
+
continue;
|
|
3910
|
+
}
|
|
3435
3911
|
var subPath = unsafeCreateSourcePath(sourcePath, _key);
|
|
3436
3912
|
var itemResult = this.item["executeRender"](subPath, itemSrc);
|
|
3437
3913
|
for (var keyS in itemResult) {
|
|
@@ -3449,45 +3925,52 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
3449
3925
|
message: "Unknown layout type: " + layout
|
|
3450
3926
|
};
|
|
3451
3927
|
}
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
};
|
|
3928
|
+
var items = [];
|
|
3929
|
+
for (var _i = 0, _Object$entries = Object.entries(src); _i < _Object$entries.length; _i++) {
|
|
3930
|
+
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
|
3931
|
+
_key3 = _Object$entries$_i[0],
|
|
3932
|
+
val = _Object$entries$_i[1];
|
|
3933
|
+
if (isJson(val)) {
|
|
3934
|
+
continue; // as above: nothing to select from an un-loaded entry
|
|
3935
|
+
}
|
|
3936
|
+
// Per KEY, not per record: `select` is user code, and one entry whose
|
|
3937
|
+
// data trips it up must not take out the whole list.
|
|
3938
|
+
try {
|
|
3939
|
+
// NB NB: display is actually defined by the user
|
|
3940
|
+
var _prepare = prepare({
|
|
3941
|
+
key: _key3,
|
|
3942
|
+
val: val
|
|
3943
|
+
}),
|
|
3944
|
+
title = _prepare.title,
|
|
3945
|
+
subtitle = _prepare.subtitle,
|
|
3946
|
+
image = _prepare.image;
|
|
3947
|
+
items.push([_key3, {
|
|
3948
|
+
title: title,
|
|
3949
|
+
subtitle: subtitle,
|
|
3950
|
+
image: image
|
|
3951
|
+
}]);
|
|
3952
|
+
} catch (e) {
|
|
3953
|
+
res[unsafeCreateSourcePath(sourcePath, _key3)] = {
|
|
3954
|
+
status: "error",
|
|
3955
|
+
message: e instanceof Error ? e.message : "Unknown error"
|
|
3956
|
+
};
|
|
3957
|
+
}
|
|
3483
3958
|
}
|
|
3959
|
+
res[sourcePath] = {
|
|
3960
|
+
status: "success",
|
|
3961
|
+
data: {
|
|
3962
|
+
layout: "list",
|
|
3963
|
+
parent: "record",
|
|
3964
|
+
items: items
|
|
3965
|
+
}
|
|
3966
|
+
};
|
|
3484
3967
|
}
|
|
3485
3968
|
return res;
|
|
3486
3969
|
}
|
|
3487
3970
|
}, {
|
|
3488
3971
|
key: "render",
|
|
3489
3972
|
value: function render(input) {
|
|
3490
|
-
return new RecordSchema(this.item, this.opt, this.customValidateFunctions, this.currentRouter, this.keySchema, this.mediaOptions, this.isReadonly, this.isHidden, this.description, {
|
|
3973
|
+
return new RecordSchema(this.item, this.opt, this.customValidateFunctions, this.currentRouter, this.keySchema, this.mediaOptions, this.isReadonly, this.isHidden, this.description, this.isJsonValues, {
|
|
3491
3974
|
layout: input.as,
|
|
3492
3975
|
select: input.select
|
|
3493
3976
|
});
|
|
@@ -3605,6 +4088,13 @@ function resolvePath(path, valModule, schema) {
|
|
|
3605
4088
|
}
|
|
3606
4089
|
resolvedSource = resolvedSource[part];
|
|
3607
4090
|
resolvedSchema = resolvedSchema instanceof RecordSchema ? (_resolvedSchema2 = resolvedSchema) === null || _resolvedSchema2 === void 0 ? void 0 : _resolvedSchema2["item"] : resolvedSchema.item;
|
|
4091
|
+
// A `.jsonValues()` entry value is a lazily-loaded JsonSource marker. We
|
|
4092
|
+
// can resolve the entry itself (schema is now `item`), but we cannot
|
|
4093
|
+
// descend deeper until the backing `*.val.json` content has been loaded
|
|
4094
|
+
// and substituted into the source tree (done by the UI/server layer).
|
|
4095
|
+
if (isJson(resolvedSource) && parts.length > 0) {
|
|
4096
|
+
throw Error("Cannot resolve path into a jsonValues entry until its content is loaded. Path: ".concat(path));
|
|
4097
|
+
}
|
|
3608
4098
|
} else if (isObjectSchema(resolvedSchema)) {
|
|
3609
4099
|
if (_typeof(resolvedSource) !== "object") {
|
|
3610
4100
|
throw Error("Schema type error: expected source to be type of object, but got ".concat(_typeof(resolvedSource)));
|
|
@@ -3809,6 +4299,16 @@ function safeResolvePath(path, valModule, schema) {
|
|
|
3809
4299
|
}
|
|
3810
4300
|
resolvedSource = resolvedSource[part];
|
|
3811
4301
|
resolvedSchema = resolvedSchema instanceof RecordSchema ? (_resolvedSchema4 = resolvedSchema) === null || _resolvedSchema4 === void 0 ? void 0 : _resolvedSchema4["item"] : resolvedSchema.item;
|
|
4302
|
+
// jsonValues entry: cannot descend deeper until the backing `*.val.json`
|
|
4303
|
+
// content is loaded into the source tree.
|
|
4304
|
+
if (isJson(resolvedSource) && parts.length > 0) {
|
|
4305
|
+
return {
|
|
4306
|
+
v: {
|
|
4307
|
+
status: "error",
|
|
4308
|
+
message: "Cannot resolve path into a jsonValues entry until its content is loaded. Path: ".concat(path)
|
|
4309
|
+
}
|
|
4310
|
+
};
|
|
4311
|
+
}
|
|
3812
4312
|
} else if (isObjectSchema(resolvedSchema)) {
|
|
3813
4313
|
if (resolvedSource === undefined) {
|
|
3814
4314
|
return {
|
|
@@ -4144,6 +4644,13 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
|
|
|
4144
4644
|
min: _min
|
|
4145
4645
|
}), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description);
|
|
4146
4646
|
}
|
|
4647
|
+
}, {
|
|
4648
|
+
key: "executeCustomValidateAt",
|
|
4649
|
+
value: function executeCustomValidateAt(path, src) {
|
|
4650
|
+
return this.executeCustomValidateFunctions(src, this.customValidateFunctions, {
|
|
4651
|
+
path: path
|
|
4652
|
+
});
|
|
4653
|
+
}
|
|
4147
4654
|
}, {
|
|
4148
4655
|
key: "executeSerialize",
|
|
4149
4656
|
value: function executeSerialize() {
|
|
@@ -4258,6 +4765,13 @@ var BooleanSchema = /*#__PURE__*/function (_Schema) {
|
|
|
4258
4765
|
value: function hidden() {
|
|
4259
4766
|
return new BooleanSchema(this.opt, this.customValidateFunctions, this.isReadonly, true, this.description);
|
|
4260
4767
|
}
|
|
4768
|
+
}, {
|
|
4769
|
+
key: "executeCustomValidateAt",
|
|
4770
|
+
value: function executeCustomValidateAt(path, src) {
|
|
4771
|
+
return this.executeCustomValidateFunctions(src, this.customValidateFunctions, {
|
|
4772
|
+
path: path
|
|
4773
|
+
});
|
|
4774
|
+
}
|
|
4261
4775
|
}, {
|
|
4262
4776
|
key: "executeSerialize",
|
|
4263
4777
|
value: function executeSerialize() {
|
|
@@ -4452,6 +4966,13 @@ var KeyOfSchema = /*#__PURE__*/function (_Schema) {
|
|
|
4452
4966
|
value: function hidden() {
|
|
4453
4967
|
return new KeyOfSchema(this.schema, this.sourcePath, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description);
|
|
4454
4968
|
}
|
|
4969
|
+
}, {
|
|
4970
|
+
key: "executeCustomValidateAt",
|
|
4971
|
+
value: function executeCustomValidateAt(path, src) {
|
|
4972
|
+
return this.executeCustomValidateFunctions(src, this.customValidateFunctions, {
|
|
4973
|
+
path: path
|
|
4974
|
+
});
|
|
4975
|
+
}
|
|
4455
4976
|
}, {
|
|
4456
4977
|
key: "executeSerialize",
|
|
4457
4978
|
value: function executeSerialize() {
|
|
@@ -4697,6 +5218,13 @@ var DateSchema = /*#__PURE__*/function (_Schema) {
|
|
|
4697
5218
|
value: function hidden() {
|
|
4698
5219
|
return new DateSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description);
|
|
4699
5220
|
}
|
|
5221
|
+
}, {
|
|
5222
|
+
key: "executeCustomValidateAt",
|
|
5223
|
+
value: function executeCustomValidateAt(path, src) {
|
|
5224
|
+
return this.executeCustomValidateFunctions(src, this.customValidateFunctions, {
|
|
5225
|
+
path: path
|
|
5226
|
+
});
|
|
5227
|
+
}
|
|
4700
5228
|
}, {
|
|
4701
5229
|
key: "executeSerialize",
|
|
4702
5230
|
value: function executeSerialize() {
|
|
@@ -4894,6 +5422,13 @@ var DateTimeSchema = /*#__PURE__*/function (_Schema) {
|
|
|
4894
5422
|
value: function hidden() {
|
|
4895
5423
|
return new DateTimeSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description);
|
|
4896
5424
|
}
|
|
5425
|
+
}, {
|
|
5426
|
+
key: "executeCustomValidateAt",
|
|
5427
|
+
value: function executeCustomValidateAt(path, src) {
|
|
5428
|
+
return this.executeCustomValidateFunctions(src, this.customValidateFunctions, {
|
|
5429
|
+
path: path
|
|
5430
|
+
});
|
|
5431
|
+
}
|
|
4897
5432
|
}, {
|
|
4898
5433
|
key: "executeSerialize",
|
|
4899
5434
|
value: function executeSerialize() {
|
|
@@ -4919,6 +5454,647 @@ var datetime = function datetime(options) {
|
|
|
4919
5454
|
return new DateTimeSchema(options);
|
|
4920
5455
|
};
|
|
4921
5456
|
|
|
5457
|
+
/**
|
|
5458
|
+
* Parsing / formatting of the CSS color strings stored by `s.color()`.
|
|
5459
|
+
*
|
|
5460
|
+
* Colors are stored as plain CSS strings so that they can be used directly in
|
|
5461
|
+
* `style` attributes and CSS custom properties. The schema decides which family
|
|
5462
|
+
* (`hex`, `rgb`, `hsl` or `oklch`) the string is written in, this module does
|
|
5463
|
+
* the conversion between them.
|
|
5464
|
+
*
|
|
5465
|
+
* All colors are sRGB: `oklch` is only used as an output notation, so any
|
|
5466
|
+
* `oklch` value that falls outside the sRGB gamut is clipped when converted
|
|
5467
|
+
* back to the other formats.
|
|
5468
|
+
*/
|
|
5469
|
+
|
|
5470
|
+
var COLOR_FORMATS = ["hex", "rgb", "hsl", "oklch"];
|
|
5471
|
+
var DEFAULT_COLOR_FORMAT = "hsl";
|
|
5472
|
+
|
|
5473
|
+
/**
|
|
5474
|
+
* A color, normalized to sRGB.
|
|
5475
|
+
*
|
|
5476
|
+
* `r`, `g` and `b` are 0-255 (not rounded), `a` is 0-1.
|
|
5477
|
+
*/
|
|
5478
|
+
|
|
5479
|
+
/**
|
|
5480
|
+
* Which color notation a string uses, or `null` if it is not a notation we
|
|
5481
|
+
* recognize. This looks at the syntax only: `detectColorFormat` says nothing
|
|
5482
|
+
* about whether the value actually parses (`hsl(nope)` is still `"hsl"`).
|
|
5483
|
+
*/
|
|
5484
|
+
function detectColorFormat(value) {
|
|
5485
|
+
var trimmed = value.trim().toLowerCase();
|
|
5486
|
+
if (trimmed.startsWith("#")) {
|
|
5487
|
+
return "hex";
|
|
5488
|
+
}
|
|
5489
|
+
if (trimmed.startsWith("rgb(") || trimmed.startsWith("rgba(")) {
|
|
5490
|
+
return "rgb";
|
|
5491
|
+
}
|
|
5492
|
+
if (trimmed.startsWith("hsl(") || trimmed.startsWith("hsla(")) {
|
|
5493
|
+
return "hsl";
|
|
5494
|
+
}
|
|
5495
|
+
if (trimmed.startsWith("oklch(")) {
|
|
5496
|
+
return "oklch";
|
|
5497
|
+
}
|
|
5498
|
+
return null;
|
|
5499
|
+
}
|
|
5500
|
+
function clamp(value, min, max) {
|
|
5501
|
+
if (Number.isNaN(value)) {
|
|
5502
|
+
return min;
|
|
5503
|
+
}
|
|
5504
|
+
return Math.min(max, Math.max(min, value));
|
|
5505
|
+
}
|
|
5506
|
+
|
|
5507
|
+
/**
|
|
5508
|
+
* Splits the inside of a CSS color function into components.
|
|
5509
|
+
*
|
|
5510
|
+
* Handles both the legacy comma syntax (`rgb(1, 2, 3, 0.5)`) and the modern
|
|
5511
|
+
* space syntax (`rgb(1 2 3 / 0.5)`), returning the alpha (if any) separately.
|
|
5512
|
+
*/
|
|
5513
|
+
function splitComponents(args) {
|
|
5514
|
+
var slashParts = args.split("/");
|
|
5515
|
+
if (slashParts.length > 2) {
|
|
5516
|
+
return null;
|
|
5517
|
+
}
|
|
5518
|
+
var alpha = slashParts.length === 2 ? slashParts[1].trim() : null;
|
|
5519
|
+
var head = slashParts[0].trim();
|
|
5520
|
+
if (head === "") {
|
|
5521
|
+
return null;
|
|
5522
|
+
}
|
|
5523
|
+
var components;
|
|
5524
|
+
if (head.includes(",")) {
|
|
5525
|
+
if (alpha !== null) {
|
|
5526
|
+
// Mixing the comma and the slash syntax is not valid CSS
|
|
5527
|
+
return null;
|
|
5528
|
+
}
|
|
5529
|
+
components = head.split(",").map(function (part) {
|
|
5530
|
+
return part.trim();
|
|
5531
|
+
});
|
|
5532
|
+
if (components.length === 4) {
|
|
5533
|
+
alpha = components[3];
|
|
5534
|
+
components = components.slice(0, 3);
|
|
5535
|
+
}
|
|
5536
|
+
} else {
|
|
5537
|
+
components = head.split(/\s+/);
|
|
5538
|
+
}
|
|
5539
|
+
if (components.length !== 3 || components.some(function (part) {
|
|
5540
|
+
return part === "";
|
|
5541
|
+
})) {
|
|
5542
|
+
return null;
|
|
5543
|
+
}
|
|
5544
|
+
if (alpha === "") {
|
|
5545
|
+
return null;
|
|
5546
|
+
}
|
|
5547
|
+
return {
|
|
5548
|
+
components: components,
|
|
5549
|
+
alpha: alpha
|
|
5550
|
+
};
|
|
5551
|
+
}
|
|
5552
|
+
function parseNumber(value) {
|
|
5553
|
+
if (!/^[+-]?(\d+\.?\d*|\.\d+)$/.test(value)) {
|
|
5554
|
+
return null;
|
|
5555
|
+
}
|
|
5556
|
+
var parsed = Number(value);
|
|
5557
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
5558
|
+
}
|
|
5559
|
+
|
|
5560
|
+
/**
|
|
5561
|
+
* A `<number>` or a `<percentage>`, where 100% maps to `percentageBasis`.
|
|
5562
|
+
*/
|
|
5563
|
+
function parseNumberOrPercentage(value, percentageBasis) {
|
|
5564
|
+
if (value.endsWith("%")) {
|
|
5565
|
+
var percentage = parseNumber(value.slice(0, -1));
|
|
5566
|
+
return percentage === null ? null : percentage / 100 * percentageBasis;
|
|
5567
|
+
}
|
|
5568
|
+
return parseNumber(value);
|
|
5569
|
+
}
|
|
5570
|
+
function parsePercentage(value) {
|
|
5571
|
+
if (!value.endsWith("%")) {
|
|
5572
|
+
return null;
|
|
5573
|
+
}
|
|
5574
|
+
return parseNumber(value.slice(0, -1));
|
|
5575
|
+
}
|
|
5576
|
+
function parseAlpha(value) {
|
|
5577
|
+
if (value === null) {
|
|
5578
|
+
return 1;
|
|
5579
|
+
}
|
|
5580
|
+
if (value === "none") {
|
|
5581
|
+
return 0;
|
|
5582
|
+
}
|
|
5583
|
+
var parsed = parseNumberOrPercentage(value, 1);
|
|
5584
|
+
return parsed === null ? null : clamp(parsed, 0, 1);
|
|
5585
|
+
}
|
|
5586
|
+
function parseHue(value) {
|
|
5587
|
+
var match = /^([+-]?(?:\d+\.?\d*|\.\d+))(deg|grad|rad|turn)?$/.exec(value);
|
|
5588
|
+
if (!match) {
|
|
5589
|
+
return null;
|
|
5590
|
+
}
|
|
5591
|
+
var amount = Number(match[1]);
|
|
5592
|
+
switch (match[2]) {
|
|
5593
|
+
case "grad":
|
|
5594
|
+
return amount / 400 * 360;
|
|
5595
|
+
case "rad":
|
|
5596
|
+
return amount * 180 / Math.PI;
|
|
5597
|
+
case "turn":
|
|
5598
|
+
return amount * 360;
|
|
5599
|
+
default:
|
|
5600
|
+
return amount;
|
|
5601
|
+
}
|
|
5602
|
+
}
|
|
5603
|
+
function normalizeHue(hue) {
|
|
5604
|
+
var wrapped = hue % 360;
|
|
5605
|
+
return wrapped < 0 ? wrapped + 360 : wrapped;
|
|
5606
|
+
}
|
|
5607
|
+
function parseHex(value) {
|
|
5608
|
+
var hex = value.slice(1);
|
|
5609
|
+
if (!/^[0-9a-f]+$/i.test(hex)) {
|
|
5610
|
+
return null;
|
|
5611
|
+
}
|
|
5612
|
+
var expand = function expand(_char) {
|
|
5613
|
+
return parseInt(_char + _char, 16);
|
|
5614
|
+
};
|
|
5615
|
+
var pair = function pair(index) {
|
|
5616
|
+
return parseInt(hex.slice(index, index + 2), 16);
|
|
5617
|
+
};
|
|
5618
|
+
if (hex.length === 3 || hex.length === 4) {
|
|
5619
|
+
return {
|
|
5620
|
+
r: expand(hex[0]),
|
|
5621
|
+
g: expand(hex[1]),
|
|
5622
|
+
b: expand(hex[2]),
|
|
5623
|
+
a: hex.length === 4 ? expand(hex[3]) / 255 : 1
|
|
5624
|
+
};
|
|
5625
|
+
}
|
|
5626
|
+
if (hex.length === 6 || hex.length === 8) {
|
|
5627
|
+
return {
|
|
5628
|
+
r: pair(0),
|
|
5629
|
+
g: pair(2),
|
|
5630
|
+
b: pair(4),
|
|
5631
|
+
a: hex.length === 8 ? pair(6) / 255 : 1
|
|
5632
|
+
};
|
|
5633
|
+
}
|
|
5634
|
+
return null;
|
|
5635
|
+
}
|
|
5636
|
+
function extractFunctionArgs(value, name) {
|
|
5637
|
+
if (!value.startsWith(name + "(") || !value.endsWith(")")) {
|
|
5638
|
+
return null;
|
|
5639
|
+
}
|
|
5640
|
+
return value.slice(name.length + 1, -1);
|
|
5641
|
+
}
|
|
5642
|
+
function parseRgb(value) {
|
|
5643
|
+
var _extractFunctionArgs;
|
|
5644
|
+
var args = (_extractFunctionArgs = extractFunctionArgs(value, "rgba")) !== null && _extractFunctionArgs !== void 0 ? _extractFunctionArgs : extractFunctionArgs(value, "rgb");
|
|
5645
|
+
if (args === null) {
|
|
5646
|
+
return null;
|
|
5647
|
+
}
|
|
5648
|
+
var split = splitComponents(args);
|
|
5649
|
+
if (!split) {
|
|
5650
|
+
return null;
|
|
5651
|
+
}
|
|
5652
|
+
var channels = split.components.map(function (component) {
|
|
5653
|
+
return component === "none" ? 0 : parseNumberOrPercentage(component, 255);
|
|
5654
|
+
});
|
|
5655
|
+
var alpha = parseAlpha(split.alpha);
|
|
5656
|
+
if (channels.some(function (channel) {
|
|
5657
|
+
return channel === null;
|
|
5658
|
+
}) || alpha === null) {
|
|
5659
|
+
return null;
|
|
5660
|
+
}
|
|
5661
|
+
return {
|
|
5662
|
+
r: clamp(channels[0], 0, 255),
|
|
5663
|
+
g: clamp(channels[1], 0, 255),
|
|
5664
|
+
b: clamp(channels[2], 0, 255),
|
|
5665
|
+
a: alpha
|
|
5666
|
+
};
|
|
5667
|
+
}
|
|
5668
|
+
function parseHsl(value) {
|
|
5669
|
+
var _extractFunctionArgs2, _parsePercentage, _parsePercentage2;
|
|
5670
|
+
var args = (_extractFunctionArgs2 = extractFunctionArgs(value, "hsla")) !== null && _extractFunctionArgs2 !== void 0 ? _extractFunctionArgs2 : extractFunctionArgs(value, "hsl");
|
|
5671
|
+
if (args === null) {
|
|
5672
|
+
return null;
|
|
5673
|
+
}
|
|
5674
|
+
var split = splitComponents(args);
|
|
5675
|
+
if (!split) {
|
|
5676
|
+
return null;
|
|
5677
|
+
}
|
|
5678
|
+
var _split$components = _slicedToArray(split.components, 3),
|
|
5679
|
+
rawHue = _split$components[0],
|
|
5680
|
+
rawSaturation = _split$components[1],
|
|
5681
|
+
rawLightness = _split$components[2];
|
|
5682
|
+
var hue = rawHue === "none" ? 0 : parseHue(rawHue);
|
|
5683
|
+
// CSS requires percentages for s/l in hsl(), but the modern syntax also
|
|
5684
|
+
// allows bare numbers, so accept both.
|
|
5685
|
+
var saturation = rawSaturation === "none" ? 0 : (_parsePercentage = parsePercentage(rawSaturation)) !== null && _parsePercentage !== void 0 ? _parsePercentage : parseNumber(rawSaturation);
|
|
5686
|
+
var lightness = rawLightness === "none" ? 0 : (_parsePercentage2 = parsePercentage(rawLightness)) !== null && _parsePercentage2 !== void 0 ? _parsePercentage2 : parseNumber(rawLightness);
|
|
5687
|
+
var alpha = parseAlpha(split.alpha);
|
|
5688
|
+
if (hue === null || saturation === null || lightness === null || alpha === null) {
|
|
5689
|
+
return null;
|
|
5690
|
+
}
|
|
5691
|
+
return _objectSpread2(_objectSpread2({}, hslToRgb(normalizeHue(hue), clamp(saturation, 0, 100), clamp(lightness, 0, 100))), {}, {
|
|
5692
|
+
a: alpha
|
|
5693
|
+
});
|
|
5694
|
+
}
|
|
5695
|
+
function parseOklch(value) {
|
|
5696
|
+
var args = extractFunctionArgs(value, "oklch");
|
|
5697
|
+
if (args === null) {
|
|
5698
|
+
return null;
|
|
5699
|
+
}
|
|
5700
|
+
var split = splitComponents(args);
|
|
5701
|
+
if (!split) {
|
|
5702
|
+
return null;
|
|
5703
|
+
}
|
|
5704
|
+
var _split$components2 = _slicedToArray(split.components, 3),
|
|
5705
|
+
rawLightness = _split$components2[0],
|
|
5706
|
+
rawChroma = _split$components2[1],
|
|
5707
|
+
rawHue = _split$components2[2];
|
|
5708
|
+
// Lightness is a <number> in 0-1 or a <percentage>, chroma is a <number>
|
|
5709
|
+
// where 0.4 is roughly the maximum, or a <percentage> where 100% = 0.4.
|
|
5710
|
+
var lightness = rawLightness === "none" ? 0 : parseNumberOrPercentage(rawLightness, 1);
|
|
5711
|
+
var chroma = rawChroma === "none" ? 0 : parseNumberOrPercentage(rawChroma, 0.4);
|
|
5712
|
+
var hue = rawHue === "none" ? 0 : parseHue(rawHue);
|
|
5713
|
+
var alpha = parseAlpha(split.alpha);
|
|
5714
|
+
if (lightness === null || chroma === null || hue === null || alpha === null) {
|
|
5715
|
+
return null;
|
|
5716
|
+
}
|
|
5717
|
+
return _objectSpread2(_objectSpread2({}, oklchToRgb(clamp(lightness, 0, 1), Math.max(0, chroma), normalizeHue(hue))), {}, {
|
|
5718
|
+
a: alpha
|
|
5719
|
+
});
|
|
5720
|
+
}
|
|
5721
|
+
|
|
5722
|
+
/**
|
|
5723
|
+
* Parses a CSS color string into sRGB channels.
|
|
5724
|
+
*
|
|
5725
|
+
* Accepts hex (3, 4, 6 and 8 digits), `rgb()` / `rgba()`, `hsl()` / `hsla()`
|
|
5726
|
+
* and `oklch()`, in both the legacy comma and the modern space syntax. Returns
|
|
5727
|
+
* `null` if the value is not a color we can parse - notably: named colors
|
|
5728
|
+
* (`red`), `color()`, `lab()` and `color-mix()` are not supported.
|
|
5729
|
+
*/
|
|
5730
|
+
function parseColor(value) {
|
|
5731
|
+
var normalized = value.trim().toLowerCase();
|
|
5732
|
+
if (normalized === "") {
|
|
5733
|
+
return null;
|
|
5734
|
+
}
|
|
5735
|
+
switch (detectColorFormat(normalized)) {
|
|
5736
|
+
case "hex":
|
|
5737
|
+
return parseHex(normalized);
|
|
5738
|
+
case "rgb":
|
|
5739
|
+
return parseRgb(normalized);
|
|
5740
|
+
case "hsl":
|
|
5741
|
+
return parseHsl(normalized);
|
|
5742
|
+
case "oklch":
|
|
5743
|
+
return parseOklch(normalized);
|
|
5744
|
+
default:
|
|
5745
|
+
return null;
|
|
5746
|
+
}
|
|
5747
|
+
}
|
|
5748
|
+
|
|
5749
|
+
/**
|
|
5750
|
+
* Rounds to at most `decimals` decimals, without trailing zeros.
|
|
5751
|
+
*/
|
|
5752
|
+
function round(value, decimals) {
|
|
5753
|
+
var factor = Math.pow(10, decimals);
|
|
5754
|
+
// `|| 0` normalizes -0 to 0
|
|
5755
|
+
return Math.round(value * factor) / factor || 0;
|
|
5756
|
+
}
|
|
5757
|
+
function toHexPair(value) {
|
|
5758
|
+
return clamp(Math.round(value), 0, 255).toString(16).padStart(2, "0");
|
|
5759
|
+
}
|
|
5760
|
+
function rgbToHsl(r, g, b) {
|
|
5761
|
+
var red = r / 255;
|
|
5762
|
+
var green = g / 255;
|
|
5763
|
+
var blue = b / 255;
|
|
5764
|
+
var max = Math.max(red, green, blue);
|
|
5765
|
+
var min = Math.min(red, green, blue);
|
|
5766
|
+
var delta = max - min;
|
|
5767
|
+
var l = (max + min) / 2;
|
|
5768
|
+
if (delta === 0) {
|
|
5769
|
+
return {
|
|
5770
|
+
h: 0,
|
|
5771
|
+
s: 0,
|
|
5772
|
+
l: l * 100
|
|
5773
|
+
};
|
|
5774
|
+
}
|
|
5775
|
+
var s = delta / (1 - Math.abs(2 * l - 1));
|
|
5776
|
+
var h;
|
|
5777
|
+
if (max === red) {
|
|
5778
|
+
h = (green - blue) / delta % 6;
|
|
5779
|
+
} else if (max === green) {
|
|
5780
|
+
h = (blue - red) / delta + 2;
|
|
5781
|
+
} else {
|
|
5782
|
+
h = (red - green) / delta + 4;
|
|
5783
|
+
}
|
|
5784
|
+
return {
|
|
5785
|
+
h: normalizeHue(h * 60),
|
|
5786
|
+
s: s * 100,
|
|
5787
|
+
l: l * 100
|
|
5788
|
+
};
|
|
5789
|
+
}
|
|
5790
|
+
function hslToRgb(h, s, l) {
|
|
5791
|
+
var saturation = s / 100;
|
|
5792
|
+
var lightness = l / 100;
|
|
5793
|
+
var c = (1 - Math.abs(2 * lightness - 1)) * saturation;
|
|
5794
|
+
var hPrime = normalizeHue(h) / 60;
|
|
5795
|
+
var x = c * (1 - Math.abs(hPrime % 2 - 1));
|
|
5796
|
+
var m = lightness - c / 2;
|
|
5797
|
+
var rgb;
|
|
5798
|
+
if (hPrime < 1) {
|
|
5799
|
+
rgb = [c, x, 0];
|
|
5800
|
+
} else if (hPrime < 2) {
|
|
5801
|
+
rgb = [x, c, 0];
|
|
5802
|
+
} else if (hPrime < 3) {
|
|
5803
|
+
rgb = [0, c, x];
|
|
5804
|
+
} else if (hPrime < 4) {
|
|
5805
|
+
rgb = [0, x, c];
|
|
5806
|
+
} else if (hPrime < 5) {
|
|
5807
|
+
rgb = [x, 0, c];
|
|
5808
|
+
} else {
|
|
5809
|
+
rgb = [c, 0, x];
|
|
5810
|
+
}
|
|
5811
|
+
return {
|
|
5812
|
+
r: (rgb[0] + m) * 255,
|
|
5813
|
+
g: (rgb[1] + m) * 255,
|
|
5814
|
+
b: (rgb[2] + m) * 255
|
|
5815
|
+
};
|
|
5816
|
+
}
|
|
5817
|
+
function srgbToLinear(channel) {
|
|
5818
|
+
var c = channel / 255;
|
|
5819
|
+
return c <= 0.04045 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4);
|
|
5820
|
+
}
|
|
5821
|
+
function linearToSrgb(channel) {
|
|
5822
|
+
var c = channel <= 0.0031308 ? channel * 12.92 : 1.055 * Math.pow(channel, 1 / 2.4) - 0.055;
|
|
5823
|
+
return clamp(c * 255, 0, 255);
|
|
5824
|
+
}
|
|
5825
|
+
|
|
5826
|
+
/**
|
|
5827
|
+
* sRGB to Oklch, using Björn Ottosson's Oklab matrices.
|
|
5828
|
+
*/
|
|
5829
|
+
function rgbToOklch(r, g, b) {
|
|
5830
|
+
var lr = srgbToLinear(r);
|
|
5831
|
+
var lg = srgbToLinear(g);
|
|
5832
|
+
var lb = srgbToLinear(b);
|
|
5833
|
+
var _long = Math.cbrt(0.4122214708 * lr + 0.5363325363 * lg + 0.0514459929 * lb);
|
|
5834
|
+
var medium = Math.cbrt(0.2119034982 * lr + 0.6806995451 * lg + 0.1073969566 * lb);
|
|
5835
|
+
var _short = Math.cbrt(0.0883024619 * lr + 0.2817188376 * lg + 0.6299787005 * lb);
|
|
5836
|
+
var lightness = 0.2104542553 * _long + 0.793617785 * medium - 0.0040720468 * _short;
|
|
5837
|
+
var a = 1.9779984951 * _long - 2.428592205 * medium + 0.4505937099 * _short;
|
|
5838
|
+
var bComponent = 0.0259040371 * _long + 0.7827717662 * medium - 0.808675766 * _short;
|
|
5839
|
+
var chroma = Math.sqrt(a * a + bComponent * bComponent);
|
|
5840
|
+
// Achromatic colors have an undefined hue: report 0 rather than the noise
|
|
5841
|
+
// that atan2 of two near-zero numbers produces.
|
|
5842
|
+
var hue = chroma < 1e-6 ? 0 : normalizeHue(Math.atan2(bComponent, a) * 180 / Math.PI);
|
|
5843
|
+
return {
|
|
5844
|
+
l: clamp(lightness, 0, 1),
|
|
5845
|
+
c: chroma,
|
|
5846
|
+
h: hue
|
|
5847
|
+
};
|
|
5848
|
+
}
|
|
5849
|
+
|
|
5850
|
+
/**
|
|
5851
|
+
* Oklch to sRGB. Out of gamut colors are clipped per channel.
|
|
5852
|
+
*/
|
|
5853
|
+
function oklchToRgb(l, c, h) {
|
|
5854
|
+
var hueRadians = normalizeHue(h) * Math.PI / 180;
|
|
5855
|
+
var a = c * Math.cos(hueRadians);
|
|
5856
|
+
var bComponent = c * Math.sin(hueRadians);
|
|
5857
|
+
var _long2 = Math.pow(l + 0.3963377774 * a + 0.2158037573 * bComponent, 3);
|
|
5858
|
+
var medium = Math.pow(l - 0.1055613458 * a - 0.0638541728 * bComponent, 3);
|
|
5859
|
+
var _short2 = Math.pow(l - 0.0894841775 * a - 1.291485548 * bComponent, 3);
|
|
5860
|
+
return {
|
|
5861
|
+
r: linearToSrgb(4.0767416621 * _long2 - 3.3077115913 * medium + 0.2309699292 * _short2),
|
|
5862
|
+
g: linearToSrgb(-1.2684380046 * _long2 + 2.6097574011 * medium - 0.3413193965 * _short2),
|
|
5863
|
+
b: linearToSrgb(-0.0041960863 * _long2 - 0.7034186147 * medium + 1.707614701 * _short2)
|
|
5864
|
+
};
|
|
5865
|
+
}
|
|
5866
|
+
|
|
5867
|
+
/**
|
|
5868
|
+
* Serializes a color to the canonical string of the given format.
|
|
5869
|
+
*
|
|
5870
|
+
* The modern, space separated CSS syntax is used for the color functions
|
|
5871
|
+
* (`rgb(255 0 0 / 0.5)`). Alpha is only included when it is not fully opaque.
|
|
5872
|
+
*/
|
|
5873
|
+
function formatColor(color, format) {
|
|
5874
|
+
var alpha = clamp(color.a, 0, 1);
|
|
5875
|
+
var alphaSuffix = alpha >= 1 ? "" : " / ".concat(round(alpha, 4));
|
|
5876
|
+
switch (format) {
|
|
5877
|
+
case "hex":
|
|
5878
|
+
{
|
|
5879
|
+
var hex = "#".concat(toHexPair(color.r)).concat(toHexPair(color.g)).concat(toHexPair(color.b));
|
|
5880
|
+
return alpha >= 1 ? hex : "".concat(hex).concat(toHexPair(alpha * 255));
|
|
5881
|
+
}
|
|
5882
|
+
case "rgb":
|
|
5883
|
+
{
|
|
5884
|
+
var r = clamp(Math.round(color.r), 0, 255);
|
|
5885
|
+
var g = clamp(Math.round(color.g), 0, 255);
|
|
5886
|
+
var b = clamp(Math.round(color.b), 0, 255);
|
|
5887
|
+
return "rgb(".concat(r, " ").concat(g, " ").concat(b).concat(alphaSuffix, ")");
|
|
5888
|
+
}
|
|
5889
|
+
case "hsl":
|
|
5890
|
+
{
|
|
5891
|
+
var _rgbToHsl = rgbToHsl(color.r, color.g, color.b),
|
|
5892
|
+
h = _rgbToHsl.h,
|
|
5893
|
+
s = _rgbToHsl.s,
|
|
5894
|
+
l = _rgbToHsl.l;
|
|
5895
|
+
return "hsl(".concat(round(h, 2), " ").concat(round(s, 2), "% ").concat(round(l, 2), "%").concat(alphaSuffix, ")");
|
|
5896
|
+
}
|
|
5897
|
+
case "oklch":
|
|
5898
|
+
{
|
|
5899
|
+
var _rgbToOklch = rgbToOklch(color.r, color.g, color.b),
|
|
5900
|
+
_l = _rgbToOklch.l,
|
|
5901
|
+
c = _rgbToOklch.c,
|
|
5902
|
+
_h = _rgbToOklch.h;
|
|
5903
|
+
return "oklch(".concat(round(_l, 4), " ").concat(round(c, 4), " ").concat(round(_h, 2)).concat(alphaSuffix, ")");
|
|
5904
|
+
}
|
|
5905
|
+
}
|
|
5906
|
+
}
|
|
5907
|
+
|
|
5908
|
+
/**
|
|
5909
|
+
* Converts a color string to the canonical string of the given format, or
|
|
5910
|
+
* `null` if the input cannot be parsed.
|
|
5911
|
+
*/
|
|
5912
|
+
function convertColor(value, format) {
|
|
5913
|
+
var parsed = parseColor(value);
|
|
5914
|
+
if (parsed === null) {
|
|
5915
|
+
return null;
|
|
5916
|
+
}
|
|
5917
|
+
return formatColor(parsed, format);
|
|
5918
|
+
}
|
|
5919
|
+
|
|
5920
|
+
/**
|
|
5921
|
+
* `#rrggbb`, which is what `<input type="color">` uses as its value.
|
|
5922
|
+
*/
|
|
5923
|
+
function colorToHex(color) {
|
|
5924
|
+
return "#".concat(toHexPair(color.r)).concat(toHexPair(color.g)).concat(toHexPair(color.b));
|
|
5925
|
+
}
|
|
5926
|
+
|
|
5927
|
+
/**
|
|
5928
|
+
* An example of the canonical output of each format, used in error messages so
|
|
5929
|
+
* that the expected syntax is obvious from the error alone.
|
|
5930
|
+
*/
|
|
5931
|
+
var FORMAT_EXAMPLES = {
|
|
5932
|
+
hex: "#3b82f6",
|
|
5933
|
+
rgb: "rgb(59 130 246)",
|
|
5934
|
+
hsl: "hsl(217.22 91.22% 59.8%)",
|
|
5935
|
+
oklch: "oklch(0.6231 0.188 259.81)"
|
|
5936
|
+
};
|
|
5937
|
+
var ColorSchema = /*#__PURE__*/function (_Schema) {
|
|
5938
|
+
function ColorSchema(options) {
|
|
5939
|
+
var _this;
|
|
5940
|
+
var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
5941
|
+
var customValidateFunctions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
5942
|
+
var isReadonly = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
5943
|
+
var isHidden = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
5944
|
+
var description = arguments.length > 5 ? arguments[5] : undefined;
|
|
5945
|
+
_classCallCheck(this, ColorSchema);
|
|
5946
|
+
_this = _callSuper(this, ColorSchema);
|
|
5947
|
+
_this.options = options;
|
|
5948
|
+
_this.opt = opt;
|
|
5949
|
+
_this.customValidateFunctions = customValidateFunctions;
|
|
5950
|
+
_this.isReadonly = isReadonly;
|
|
5951
|
+
_this.isHidden = isHidden;
|
|
5952
|
+
_this.description = description;
|
|
5953
|
+
return _this;
|
|
5954
|
+
}
|
|
5955
|
+
_inherits(ColorSchema, _Schema);
|
|
5956
|
+
return _createClass(ColorSchema, [{
|
|
5957
|
+
key: "describe",
|
|
5958
|
+
value: function describe(description) {
|
|
5959
|
+
return new ColorSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined);
|
|
5960
|
+
}
|
|
5961
|
+
}, {
|
|
5962
|
+
key: "validate",
|
|
5963
|
+
value: function validate(validationFunction) {
|
|
5964
|
+
return new ColorSchema(this.options, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description);
|
|
5965
|
+
}
|
|
5966
|
+
}, {
|
|
5967
|
+
key: "executeCustomValidateAt",
|
|
5968
|
+
value: function executeCustomValidateAt(path, src) {
|
|
5969
|
+
return this.executeCustomValidateFunctions(src, this.customValidateFunctions, {
|
|
5970
|
+
path: path
|
|
5971
|
+
});
|
|
5972
|
+
}
|
|
5973
|
+
}, {
|
|
5974
|
+
key: "executeValidate",
|
|
5975
|
+
value: function executeValidate(path, src) {
|
|
5976
|
+
var _this$options$format, _this$options;
|
|
5977
|
+
var errors = this.executeCustomValidateFunctions(src, this.customValidateFunctions, {
|
|
5978
|
+
path: path
|
|
5979
|
+
});
|
|
5980
|
+
if (this.opt && (src === null || src === undefined)) {
|
|
5981
|
+
return errors.length > 0 ? _defineProperty({}, path, errors) : false;
|
|
5982
|
+
}
|
|
5983
|
+
if (typeof src !== "string") {
|
|
5984
|
+
errors.push({
|
|
5985
|
+
message: "Expected 'string', got '".concat(_typeof(src), "'"),
|
|
5986
|
+
value: src
|
|
5987
|
+
});
|
|
5988
|
+
return _defineProperty({}, path, errors);
|
|
5989
|
+
}
|
|
5990
|
+
var expectedFormat = (_this$options$format = (_this$options = this.options) === null || _this$options === void 0 ? void 0 : _this$options.format) !== null && _this$options$format !== void 0 ? _this$options$format : DEFAULT_COLOR_FORMAT;
|
|
5991
|
+
var parsed = parseColor(src);
|
|
5992
|
+
if (parsed === null) {
|
|
5993
|
+
errors.push({
|
|
5994
|
+
message: "Invalid color: '".concat(src, "'. Expected a CSS color in the '").concat(expectedFormat, "' format (e.g. '").concat(FORMAT_EXAMPLES[expectedFormat], "')"),
|
|
5995
|
+
value: src
|
|
5996
|
+
});
|
|
5997
|
+
} else {
|
|
5998
|
+
var _this$options3;
|
|
5999
|
+
var actualFormat = detectColorFormat(src);
|
|
6000
|
+
if (actualFormat !== expectedFormat) {
|
|
6001
|
+
var _this$options2;
|
|
6002
|
+
// Drop alpha from the SUGGESTION when alpha is not enabled, the same way
|
|
6003
|
+
// the field's commit does. Keeping it would suggest a value that fails
|
|
6004
|
+
// the alpha check immediately below, so following the advice would not
|
|
6005
|
+
// clear the error.
|
|
6006
|
+
var suggestion = formatColor((_this$options2 = this.options) !== null && _this$options2 !== void 0 && _this$options2.alpha ? parsed : _objectSpread2(_objectSpread2({}, parsed), {}, {
|
|
6007
|
+
a: 1
|
|
6008
|
+
}), expectedFormat);
|
|
6009
|
+
errors.push({
|
|
6010
|
+
message: "Expected a color in the '".concat(expectedFormat, "' format (e.g. '").concat(FORMAT_EXAMPLES[expectedFormat], "'), got '").concat(src, "'. Did you mean '").concat(suggestion, "'?"),
|
|
6011
|
+
value: src
|
|
6012
|
+
});
|
|
6013
|
+
}
|
|
6014
|
+
if (!((_this$options3 = this.options) !== null && _this$options3 !== void 0 && _this$options3.alpha) && parsed.a < 1) {
|
|
6015
|
+
errors.push({
|
|
6016
|
+
message: "Color '".concat(src, "' has an alpha channel, but alpha is not enabled. Use s.color({ alpha: true }) to allow transparency"),
|
|
6017
|
+
value: src
|
|
6018
|
+
});
|
|
6019
|
+
}
|
|
6020
|
+
}
|
|
6021
|
+
if (errors.length > 0) {
|
|
6022
|
+
return _defineProperty({}, path, errors);
|
|
6023
|
+
}
|
|
6024
|
+
return false;
|
|
6025
|
+
}
|
|
6026
|
+
}, {
|
|
6027
|
+
key: "executeAssert",
|
|
6028
|
+
value: function executeAssert(path, src) {
|
|
6029
|
+
if (this.opt && src === null) {
|
|
6030
|
+
return {
|
|
6031
|
+
success: true,
|
|
6032
|
+
data: src
|
|
6033
|
+
};
|
|
6034
|
+
}
|
|
6035
|
+
if (src === null) {
|
|
6036
|
+
return {
|
|
6037
|
+
success: false,
|
|
6038
|
+
errors: _defineProperty({}, path, [{
|
|
6039
|
+
message: "Expected 'string', got 'null'",
|
|
6040
|
+
typeError: true
|
|
6041
|
+
}])
|
|
6042
|
+
};
|
|
6043
|
+
}
|
|
6044
|
+
if (typeof src !== "string") {
|
|
6045
|
+
return {
|
|
6046
|
+
success: false,
|
|
6047
|
+
errors: _defineProperty({}, path, [{
|
|
6048
|
+
message: "Expected 'string', got '".concat(_typeof(src), "'"),
|
|
6049
|
+
typeError: true
|
|
6050
|
+
}])
|
|
6051
|
+
};
|
|
6052
|
+
}
|
|
6053
|
+
return {
|
|
6054
|
+
success: true,
|
|
6055
|
+
data: src
|
|
6056
|
+
};
|
|
6057
|
+
}
|
|
6058
|
+
}, {
|
|
6059
|
+
key: "nullable",
|
|
6060
|
+
value: function nullable() {
|
|
6061
|
+
return new ColorSchema(this.options, true, [], this.isReadonly, this.isHidden, this.description);
|
|
6062
|
+
}
|
|
6063
|
+
}, {
|
|
6064
|
+
key: "readonly",
|
|
6065
|
+
value: function readonly() {
|
|
6066
|
+
return new ColorSchema(this.options, this.opt, this.customValidateFunctions, true, this.isHidden, this.description);
|
|
6067
|
+
}
|
|
6068
|
+
}, {
|
|
6069
|
+
key: "hidden",
|
|
6070
|
+
value: function hidden() {
|
|
6071
|
+
return new ColorSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description);
|
|
6072
|
+
}
|
|
6073
|
+
}, {
|
|
6074
|
+
key: "executeSerialize",
|
|
6075
|
+
value: function executeSerialize() {
|
|
6076
|
+
var _this$customValidateF;
|
|
6077
|
+
return {
|
|
6078
|
+
type: "color",
|
|
6079
|
+
opt: this.opt,
|
|
6080
|
+
options: this.options,
|
|
6081
|
+
customValidate: this.customValidateFunctions && ((_this$customValidateF = this.customValidateFunctions) === null || _this$customValidateF === void 0 ? void 0 : _this$customValidateF.length) > 0,
|
|
6082
|
+
readonly: this.isReadonly,
|
|
6083
|
+
hidden: this.isHidden,
|
|
6084
|
+
description: this.description
|
|
6085
|
+
};
|
|
6086
|
+
}
|
|
6087
|
+
}, {
|
|
6088
|
+
key: "executeRender",
|
|
6089
|
+
value: function executeRender() {
|
|
6090
|
+
return {};
|
|
6091
|
+
}
|
|
6092
|
+
}]);
|
|
6093
|
+
}(Schema);
|
|
6094
|
+
var color = function color(options) {
|
|
6095
|
+
return new ColorSchema(options);
|
|
6096
|
+
};
|
|
6097
|
+
|
|
4922
6098
|
function router(router, keyOrItem, maybeItem) {
|
|
4923
6099
|
if (maybeItem) {
|
|
4924
6100
|
return new RecordSchema(maybeItem, false, [], router, keyOrItem);
|
|
@@ -5008,6 +6184,7 @@ function initSchema() {
|
|
|
5008
6184
|
files: files,
|
|
5009
6185
|
date: date,
|
|
5010
6186
|
datetime: datetime,
|
|
6187
|
+
color: color,
|
|
5011
6188
|
route: route,
|
|
5012
6189
|
router: router,
|
|
5013
6190
|
images: images
|
|
@@ -5135,7 +6312,8 @@ var initVal = function initVal(config) {
|
|
|
5135
6312
|
define: define,
|
|
5136
6313
|
remote: initRemote(),
|
|
5137
6314
|
file: initFile(config),
|
|
5138
|
-
image: initImage(config)
|
|
6315
|
+
image: initImage(config),
|
|
6316
|
+
json: json
|
|
5139
6317
|
},
|
|
5140
6318
|
s: s,
|
|
5141
6319
|
config: config
|
|
@@ -5162,142 +6340,6 @@ function modules(config, modules) {
|
|
|
5162
6340
|
};
|
|
5163
6341
|
}
|
|
5164
6342
|
|
|
5165
|
-
function _regeneratorDefine(e, r, n, t) {
|
|
5166
|
-
var i = Object.defineProperty;
|
|
5167
|
-
try {
|
|
5168
|
-
i({}, "", {});
|
|
5169
|
-
} catch (e) {
|
|
5170
|
-
i = 0;
|
|
5171
|
-
}
|
|
5172
|
-
_regeneratorDefine = function (e, r, n, t) {
|
|
5173
|
-
function o(r, n) {
|
|
5174
|
-
_regeneratorDefine(e, r, function (e) {
|
|
5175
|
-
return this._invoke(r, n, e);
|
|
5176
|
-
});
|
|
5177
|
-
}
|
|
5178
|
-
r ? i ? i(e, r, {
|
|
5179
|
-
value: n,
|
|
5180
|
-
enumerable: !t,
|
|
5181
|
-
configurable: !t,
|
|
5182
|
-
writable: !t
|
|
5183
|
-
}) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
|
|
5184
|
-
}, _regeneratorDefine(e, r, n, t);
|
|
5185
|
-
}
|
|
5186
|
-
|
|
5187
|
-
function _regenerator() {
|
|
5188
|
-
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
|
|
5189
|
-
var e,
|
|
5190
|
-
t,
|
|
5191
|
-
r = "function" == typeof Symbol ? Symbol : {},
|
|
5192
|
-
n = r.iterator || "@@iterator",
|
|
5193
|
-
o = r.toStringTag || "@@toStringTag";
|
|
5194
|
-
function i(r, n, o, i) {
|
|
5195
|
-
var c = n && n.prototype instanceof Generator ? n : Generator,
|
|
5196
|
-
u = Object.create(c.prototype);
|
|
5197
|
-
return _regeneratorDefine(u, "_invoke", function (r, n, o) {
|
|
5198
|
-
var i,
|
|
5199
|
-
c,
|
|
5200
|
-
u,
|
|
5201
|
-
f = 0,
|
|
5202
|
-
p = o || [],
|
|
5203
|
-
y = !1,
|
|
5204
|
-
G = {
|
|
5205
|
-
p: 0,
|
|
5206
|
-
n: 0,
|
|
5207
|
-
v: e,
|
|
5208
|
-
a: d,
|
|
5209
|
-
f: d.bind(e, 4),
|
|
5210
|
-
d: function (t, r) {
|
|
5211
|
-
return i = t, c = 0, u = e, G.n = r, a;
|
|
5212
|
-
}
|
|
5213
|
-
};
|
|
5214
|
-
function d(r, n) {
|
|
5215
|
-
for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
|
|
5216
|
-
var o,
|
|
5217
|
-
i = p[t],
|
|
5218
|
-
d = G.p,
|
|
5219
|
-
l = i[2];
|
|
5220
|
-
r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0));
|
|
5221
|
-
}
|
|
5222
|
-
if (o || r > 1) return a;
|
|
5223
|
-
throw y = !0, n;
|
|
5224
|
-
}
|
|
5225
|
-
return function (o, p, l) {
|
|
5226
|
-
if (f > 1) throw TypeError("Generator is already running");
|
|
5227
|
-
for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
|
|
5228
|
-
i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
|
|
5229
|
-
try {
|
|
5230
|
-
if (f = 2, i) {
|
|
5231
|
-
if (c || (o = "next"), t = i[o]) {
|
|
5232
|
-
if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
|
|
5233
|
-
if (!t.done) return t;
|
|
5234
|
-
u = t.value, c < 2 && (c = 0);
|
|
5235
|
-
} else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
|
|
5236
|
-
i = e;
|
|
5237
|
-
} else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
|
|
5238
|
-
} catch (t) {
|
|
5239
|
-
i = e, c = 1, u = t;
|
|
5240
|
-
} finally {
|
|
5241
|
-
f = 1;
|
|
5242
|
-
}
|
|
5243
|
-
}
|
|
5244
|
-
return {
|
|
5245
|
-
value: t,
|
|
5246
|
-
done: y
|
|
5247
|
-
};
|
|
5248
|
-
};
|
|
5249
|
-
}(r, o, i), !0), u;
|
|
5250
|
-
}
|
|
5251
|
-
var a = {};
|
|
5252
|
-
function Generator() {}
|
|
5253
|
-
function GeneratorFunction() {}
|
|
5254
|
-
function GeneratorFunctionPrototype() {}
|
|
5255
|
-
t = Object.getPrototypeOf;
|
|
5256
|
-
var c = [][n] ? t(t([][n]())) : (_regeneratorDefine(t = {}, n, function () {
|
|
5257
|
-
return this;
|
|
5258
|
-
}), t),
|
|
5259
|
-
u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
|
|
5260
|
-
function f(e) {
|
|
5261
|
-
return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
|
|
5262
|
-
}
|
|
5263
|
-
return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine(u), _regeneratorDefine(u, o, "Generator"), _regeneratorDefine(u, n, function () {
|
|
5264
|
-
return this;
|
|
5265
|
-
}), _regeneratorDefine(u, "toString", function () {
|
|
5266
|
-
return "[object Generator]";
|
|
5267
|
-
}), (_regenerator = function () {
|
|
5268
|
-
return {
|
|
5269
|
-
w: i,
|
|
5270
|
-
m: f
|
|
5271
|
-
};
|
|
5272
|
-
})();
|
|
5273
|
-
}
|
|
5274
|
-
|
|
5275
|
-
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
5276
|
-
try {
|
|
5277
|
-
var i = n[a](c),
|
|
5278
|
-
u = i.value;
|
|
5279
|
-
} catch (n) {
|
|
5280
|
-
return void e(n);
|
|
5281
|
-
}
|
|
5282
|
-
i.done ? t(u) : Promise.resolve(u).then(r, o);
|
|
5283
|
-
}
|
|
5284
|
-
function _asyncToGenerator(n) {
|
|
5285
|
-
return function () {
|
|
5286
|
-
var t = this,
|
|
5287
|
-
e = arguments;
|
|
5288
|
-
return new Promise(function (r, o) {
|
|
5289
|
-
var a = n.apply(t, e);
|
|
5290
|
-
function _next(n) {
|
|
5291
|
-
asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
|
|
5292
|
-
}
|
|
5293
|
-
function _throw(n) {
|
|
5294
|
-
asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
|
|
5295
|
-
}
|
|
5296
|
-
_next(void 0);
|
|
5297
|
-
});
|
|
5298
|
-
};
|
|
5299
|
-
}
|
|
5300
|
-
|
|
5301
6343
|
/**
|
|
5302
6344
|
* From: https://github.com/kawanet/sha256-uint8array/commit/a035f83824c319d01ca1e7559fdcf1632c0cd6c4
|
|
5303
6345
|
*
|
|
@@ -6797,7 +7839,7 @@ function deserializeSchema(serialized) {
|
|
|
6797
7839
|
return schema;
|
|
6798
7840
|
}
|
|
6799
7841
|
function deserializeSchemaImpl(serialized) {
|
|
6800
|
-
var _serialized$options, _serialized$options2, _serialized$accept, _serialized$directory, _serialized$remote;
|
|
7842
|
+
var _serialized$options, _serialized$options2, _serialized$accept, _serialized$directory, _serialized$remote, _serialized$jsonValue;
|
|
6801
7843
|
switch (serialized.type) {
|
|
6802
7844
|
case "string":
|
|
6803
7845
|
return new StringSchema(_objectSpread2(_objectSpread2({}, serialized.options), {}, {
|
|
@@ -6846,7 +7888,7 @@ function deserializeSchemaImpl(serialized) {
|
|
|
6846
7888
|
directory: (_serialized$directory = serialized.directory) !== null && _serialized$directory !== void 0 ? _serialized$directory : "/public/val",
|
|
6847
7889
|
remote: (_serialized$remote = serialized.remote) !== null && _serialized$remote !== void 0 ? _serialized$remote : false,
|
|
6848
7890
|
altSchema: serialized.alt ? deserializeSchema(serialized.alt) : undefined
|
|
6849
|
-
} : undefined, false, false, serialized.description);
|
|
7891
|
+
} : undefined, false, false, serialized.description, (_serialized$jsonValue = serialized.jsonValues) !== null && _serialized$jsonValue !== void 0 ? _serialized$jsonValue : false);
|
|
6850
7892
|
case "keyOf":
|
|
6851
7893
|
return new KeyOfSchema(serialized.schema, serialized.path, serialized.opt, [], false, false, serialized.description);
|
|
6852
7894
|
case "route":
|
|
@@ -6865,6 +7907,8 @@ function deserializeSchemaImpl(serialized) {
|
|
|
6865
7907
|
return new DateSchema(serialized.options, serialized.opt, [], false, false, serialized.description);
|
|
6866
7908
|
case "dateTime":
|
|
6867
7909
|
return new DateTimeSchema(serialized.options, serialized.opt, [], false, false, serialized.description);
|
|
7910
|
+
case "color":
|
|
7911
|
+
return new ColorSchema(serialized.options, serialized.opt, [], false, false, serialized.description);
|
|
6868
7912
|
default:
|
|
6869
7913
|
{
|
|
6870
7914
|
var exhaustiveCheck = serialized;
|
|
@@ -7151,6 +8195,13 @@ var Internal = {
|
|
|
7151
8195
|
joinModuleFilePathAndModulePath: joinModuleFilePathAndModulePath,
|
|
7152
8196
|
nextAppRouter: nextAppRouter,
|
|
7153
8197
|
externalPageRouter: externalPageRouter,
|
|
8198
|
+
color: {
|
|
8199
|
+
parseColor: parseColor,
|
|
8200
|
+
formatColor: formatColor,
|
|
8201
|
+
convertColor: convertColor,
|
|
8202
|
+
detectColorFormat: detectColorFormat,
|
|
8203
|
+
colorToHex: colorToHex
|
|
8204
|
+
},
|
|
7154
8205
|
remote: {
|
|
7155
8206
|
createRemoteRef: createRemoteRef,
|
|
7156
8207
|
getValidationBasis: getValidationBasis,
|
|
@@ -7165,6 +8216,9 @@ var Internal = {
|
|
|
7165
8216
|
},
|
|
7166
8217
|
isVal: isVal,
|
|
7167
8218
|
isFile: isFile,
|
|
8219
|
+
isJson: isJson,
|
|
8220
|
+
getJsonImport: getJsonImport,
|
|
8221
|
+
resolveJsonValues: resolveJsonValues,
|
|
7168
8222
|
createValPathOfItem: createValPathOfItem,
|
|
7169
8223
|
getSHA256Hash: getSHA256Hash,
|
|
7170
8224
|
initSchema: initSchema,
|
|
@@ -7230,7 +8284,10 @@ function tryJsonParse(str) {
|
|
|
7230
8284
|
|
|
7231
8285
|
exports.ArraySchema = ArraySchema;
|
|
7232
8286
|
exports.BooleanSchema = BooleanSchema;
|
|
8287
|
+
exports.COLOR_FORMATS = COLOR_FORMATS;
|
|
8288
|
+
exports.ColorSchema = ColorSchema;
|
|
7233
8289
|
exports.DEFAULT_APP_HOST = DEFAULT_APP_HOST;
|
|
8290
|
+
exports.DEFAULT_COLOR_FORMAT = DEFAULT_COLOR_FORMAT;
|
|
7234
8291
|
exports.DEFAULT_CONTENT_HOST = DEFAULT_CONTENT_HOST;
|
|
7235
8292
|
exports.DEFAULT_VAL_REMOTE_HOST = DEFAULT_VAL_REMOTE_HOST;
|
|
7236
8293
|
exports.DateSchema = DateSchema;
|