@valbuild/core 0.101.0 → 0.102.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/extractValModules.d.ts +1 -1
- package/dist/declarations/src/index.d.ts +2 -1
- package/dist/declarations/src/initSchema.d.ts +1 -1
- package/dist/declarations/src/render.d.ts +56 -5
- package/dist/declarations/src/schema/array.d.ts +12 -2
- package/dist/declarations/src/schema/files.d.ts +6 -2
- package/dist/declarations/src/schema/hasRemoteFileSchema.d.ts +34 -0
- package/dist/declarations/src/schema/images.d.ts +10 -5
- package/dist/declarations/src/schema/index.d.ts +9 -2
- package/dist/declarations/src/schema/object.d.ts +2 -2
- package/dist/declarations/src/schema/record.d.ts +4 -2
- package/dist/declarations/src/schema/string.d.ts +4 -2
- package/dist/declarations/src/schema/union.d.ts +2 -2
- package/dist/{index-3e2d700e.cjs.dev.js → index-30ecb49c.cjs.dev.js} +278 -46
- package/dist/{index-a18c24c2.esm.js → index-796fd204.esm.js} +277 -47
- package/dist/{index-049780fa.cjs.prod.js → index-ca1bbeb2.cjs.prod.js} +278 -46
- package/dist/valbuild-core.cjs.dev.js +3 -1
- package/dist/valbuild-core.cjs.prod.js +3 -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
|
@@ -920,6 +920,7 @@ var StringSchema = /*#__PURE__*/function (_Schema) {
|
|
|
920
920
|
var _this$options4, _this$options5, _this$options6, _this$customValidateF, _this$customValidateF2;
|
|
921
921
|
return {
|
|
922
922
|
type: "string",
|
|
923
|
+
render: this.renderInput ? true : undefined,
|
|
923
924
|
options: {
|
|
924
925
|
maxLength: (_this$options4 = this.options) === null || _this$options4 === void 0 ? void 0 : _this$options4.maxLength,
|
|
925
926
|
minLength: (_this$options5 = this.options) === null || _this$options5 === void 0 ? void 0 : _this$options5.minLength,
|
|
@@ -945,7 +946,12 @@ var StringSchema = /*#__PURE__*/function (_Schema) {
|
|
|
945
946
|
}
|
|
946
947
|
}, {
|
|
947
948
|
key: "executeRender",
|
|
948
|
-
value: function executeRender(sourcePath, src
|
|
949
|
+
value: function executeRender(sourcePath, src,
|
|
950
|
+
// Accepted and unused: a string's render is a static layout hint
|
|
951
|
+
// (`{as:"textarea"}` / `{as:"code",language}`) with no closure behind it, so
|
|
952
|
+
// there is nothing a scope could prune. Declared so the signature is uniform
|
|
953
|
+
// across every schema rather than something a reader has to check.
|
|
954
|
+
_scope) {
|
|
949
955
|
if (this.renderInput) {
|
|
950
956
|
if (this.renderInput.as === "code") {
|
|
951
957
|
return _defineProperty({}, sourcePath, {
|
|
@@ -1158,7 +1164,7 @@ var ObjectSchema = /*#__PURE__*/function (_Schema) {
|
|
|
1158
1164
|
}
|
|
1159
1165
|
}, {
|
|
1160
1166
|
key: "executeRender",
|
|
1161
|
-
value: function executeRender(sourcePath, src) {
|
|
1167
|
+
value: function executeRender(sourcePath, src, scope) {
|
|
1162
1168
|
var res = {};
|
|
1163
1169
|
if (src === null) {
|
|
1164
1170
|
return res;
|
|
@@ -1169,7 +1175,13 @@ var ObjectSchema = /*#__PURE__*/function (_Schema) {
|
|
|
1169
1175
|
continue;
|
|
1170
1176
|
}
|
|
1171
1177
|
var subPath = unsafeCreateSourcePath(sourcePath, _key3);
|
|
1172
|
-
|
|
1178
|
+
// An object produces no render of its own, so it is pure recursion — and
|
|
1179
|
+
// pruning it is the whole contribution: a field deep in one branch stops
|
|
1180
|
+
// paying for every sibling branch's renders.
|
|
1181
|
+
if (scope !== undefined && !scope.wantsUnder(subPath)) {
|
|
1182
|
+
continue;
|
|
1183
|
+
}
|
|
1184
|
+
var itemResult = this.items[_key3]["executeRender"](subPath, itemSrc, scope);
|
|
1173
1185
|
for (var keyS in itemResult) {
|
|
1174
1186
|
var _key4 = keyS;
|
|
1175
1187
|
res[_key4] = itemResult[_key4];
|
|
@@ -1311,6 +1323,7 @@ var ArraySchema = /*#__PURE__*/function (_Schema) {
|
|
|
1311
1323
|
type: "array",
|
|
1312
1324
|
item: this.item["executeSerialize"](),
|
|
1313
1325
|
opt: this.opt,
|
|
1326
|
+
render: this.renderInput ? true : undefined,
|
|
1314
1327
|
customValidate: this.customValidateFunctions && ((_this$customValidateF = this.customValidateFunctions) === null || _this$customValidateF === void 0 ? void 0 : _this$customValidateF.length) > 0,
|
|
1315
1328
|
readonly: this.isReadonly,
|
|
1316
1329
|
hidden: this.isHidden,
|
|
@@ -1319,7 +1332,7 @@ var ArraySchema = /*#__PURE__*/function (_Schema) {
|
|
|
1319
1332
|
}
|
|
1320
1333
|
}, {
|
|
1321
1334
|
key: "executeRender",
|
|
1322
|
-
value: function executeRender(sourcePath, src) {
|
|
1335
|
+
value: function executeRender(sourcePath, src, scope) {
|
|
1323
1336
|
var res = {};
|
|
1324
1337
|
if (src === null) {
|
|
1325
1338
|
return res;
|
|
@@ -1331,7 +1344,10 @@ var ArraySchema = /*#__PURE__*/function (_Schema) {
|
|
|
1331
1344
|
continue;
|
|
1332
1345
|
}
|
|
1333
1346
|
var subPath = unsafeCreateSourcePath(sourcePath, key);
|
|
1334
|
-
|
|
1347
|
+
if (scope !== undefined && !scope.wantsUnder(subPath)) {
|
|
1348
|
+
continue;
|
|
1349
|
+
}
|
|
1350
|
+
var itemResult = this.item["executeRender"](subPath, itemSrc, scope);
|
|
1335
1351
|
for (var keyS in itemResult) {
|
|
1336
1352
|
var _key = keyS;
|
|
1337
1353
|
res[_key] = itemResult[_key];
|
|
@@ -1347,34 +1363,51 @@ var ArraySchema = /*#__PURE__*/function (_Schema) {
|
|
|
1347
1363
|
message: "Unknown layout type: " + layout
|
|
1348
1364
|
};
|
|
1349
1365
|
}
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1366
|
+
// The whole list when the LIST is what is being shown; only the wanted
|
|
1367
|
+
// rows when it is not. `select` is the user's closure and the real expense
|
|
1368
|
+
// — a list view asks for the container and gets every row, a single field
|
|
1369
|
+
// asks for its own path and costs one call.
|
|
1370
|
+
// Non-null once, as a value, rather than a boolean the compiler cannot
|
|
1371
|
+
// tie back to `scope`: no scope and a scope that wants this exact path
|
|
1372
|
+
// both mean the whole list, and anything else is a window.
|
|
1373
|
+
var window = scope !== undefined && !scope.wants(sourcePath) ? scope : null;
|
|
1374
|
+
var items = [];
|
|
1375
|
+
for (var index = 0; index < src.length; index++) {
|
|
1376
|
+
if (window !== null && !window.wantsUnder(unsafeCreateSourcePath(sourcePath, index))) {
|
|
1377
|
+
continue;
|
|
1378
|
+
}
|
|
1379
|
+
// Per ITEM, not per list, matching what `record` already does: `select`
|
|
1380
|
+
// is user code, and one row whose data trips it up must not take out the
|
|
1381
|
+
// whole list. Before scoping, one throwing row produced an error at the
|
|
1382
|
+
// container and no items at all.
|
|
1383
|
+
try {
|
|
1384
|
+
// NB NB: display is actually defined by the user
|
|
1385
|
+
var _select = select({
|
|
1386
|
+
val: src[index]
|
|
1387
|
+
}),
|
|
1388
|
+
title = _select.title,
|
|
1389
|
+
subtitle = _select.subtitle,
|
|
1390
|
+
image = _select.image;
|
|
1391
|
+
items.push([index, {
|
|
1392
|
+
title: title,
|
|
1393
|
+
subtitle: subtitle,
|
|
1394
|
+
image: image
|
|
1395
|
+
}]);
|
|
1396
|
+
} catch (e) {
|
|
1397
|
+
res[unsafeCreateSourcePath(sourcePath, index)] = {
|
|
1398
|
+
status: "error",
|
|
1399
|
+
message: e instanceof Error ? e.message : "Unknown error"
|
|
1400
|
+
};
|
|
1401
|
+
}
|
|
1377
1402
|
}
|
|
1403
|
+
res[sourcePath] = {
|
|
1404
|
+
status: "success",
|
|
1405
|
+
data: {
|
|
1406
|
+
layout: "list",
|
|
1407
|
+
parent: "array",
|
|
1408
|
+
items: items
|
|
1409
|
+
}
|
|
1410
|
+
};
|
|
1378
1411
|
}
|
|
1379
1412
|
return res;
|
|
1380
1413
|
}
|
|
@@ -1948,7 +1981,7 @@ var UnionSchema = /*#__PURE__*/function (_Schema) {
|
|
|
1948
1981
|
}
|
|
1949
1982
|
}, {
|
|
1950
1983
|
key: "executeRender",
|
|
1951
|
-
value: function executeRender(sourcePath, src) {
|
|
1984
|
+
value: function executeRender(sourcePath, src, scope) {
|
|
1952
1985
|
var res = {};
|
|
1953
1986
|
if (src === null) {
|
|
1954
1987
|
return res;
|
|
@@ -1970,7 +2003,7 @@ var UnionSchema = /*#__PURE__*/function (_Schema) {
|
|
|
1970
2003
|
return false;
|
|
1971
2004
|
});
|
|
1972
2005
|
if (thisSchema) {
|
|
1973
|
-
var itemResult = thisSchema["executeRender"](sourcePath, src);
|
|
2006
|
+
var itemResult = thisSchema["executeRender"](sourcePath, src, scope);
|
|
1974
2007
|
for (var keyS in itemResult) {
|
|
1975
2008
|
var _key3 = keyS;
|
|
1976
2009
|
res[_key3] = itemResult[_key3];
|
|
@@ -3857,6 +3890,7 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
3857
3890
|
item: this.item["executeSerialize"](),
|
|
3858
3891
|
key: (_this$keySchema = this.keySchema) === null || _this$keySchema === void 0 ? void 0 : _this$keySchema["executeSerialize"](),
|
|
3859
3892
|
opt: this.opt,
|
|
3893
|
+
render: this.renderInput ? true : undefined,
|
|
3860
3894
|
router: (_this$currentRouter = this.currentRouter) === null || _this$currentRouter === void 0 ? void 0 : _this$currentRouter.getRouterId(),
|
|
3861
3895
|
customValidate: this.customValidateFunctions && ((_this$customValidateF = this.customValidateFunctions) === null || _this$customValidateF === void 0 ? void 0 : _this$customValidateF.length) > 0,
|
|
3862
3896
|
jsonValues: this.isJsonValues ? true : undefined,
|
|
@@ -3889,7 +3923,7 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
3889
3923
|
}
|
|
3890
3924
|
}, {
|
|
3891
3925
|
key: "executeRender",
|
|
3892
|
-
value: function executeRender(sourcePath, src) {
|
|
3926
|
+
value: function executeRender(sourcePath, src, scope) {
|
|
3893
3927
|
var res = {};
|
|
3894
3928
|
if (src === null) {
|
|
3895
3929
|
return res;
|
|
@@ -3907,7 +3941,10 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
3907
3941
|
continue;
|
|
3908
3942
|
}
|
|
3909
3943
|
var subPath = unsafeCreateSourcePath(sourcePath, _key);
|
|
3910
|
-
|
|
3944
|
+
if (scope !== undefined && !scope.wantsUnder(subPath)) {
|
|
3945
|
+
continue;
|
|
3946
|
+
}
|
|
3947
|
+
var itemResult = this.item["executeRender"](subPath, itemSrc, scope);
|
|
3911
3948
|
for (var keyS in itemResult) {
|
|
3912
3949
|
var _key2 = keyS;
|
|
3913
3950
|
res[_key2] = itemResult[_key2];
|
|
@@ -3923,6 +3960,9 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
3923
3960
|
message: "Unknown layout type: " + layout
|
|
3924
3961
|
};
|
|
3925
3962
|
}
|
|
3963
|
+
// See the same block in `array`: the whole record when the record is what
|
|
3964
|
+
// is being shown, only the wanted entries when it is not.
|
|
3965
|
+
var window = scope !== undefined && !scope.wants(sourcePath) ? scope : null;
|
|
3926
3966
|
var items = [];
|
|
3927
3967
|
for (var _i = 0, _Object$entries = Object.entries(src); _i < _Object$entries.length; _i++) {
|
|
3928
3968
|
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
|
@@ -3931,6 +3971,9 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
3931
3971
|
if (isJson(val)) {
|
|
3932
3972
|
continue; // as above: nothing to select from an un-loaded entry
|
|
3933
3973
|
}
|
|
3974
|
+
if (window !== null && !window.wantsUnder(unsafeCreateSourcePath(sourcePath, _key3))) {
|
|
3975
|
+
continue;
|
|
3976
|
+
}
|
|
3934
3977
|
// Per KEY, not per record: `select` is user code, and one entry whose
|
|
3935
3978
|
// data trips it up must not take out the whole list.
|
|
3936
3979
|
try {
|
|
@@ -5063,8 +5106,8 @@ var keyOf = function keyOf(valModule) {
|
|
|
5063
5106
|
* ```
|
|
5064
5107
|
*/
|
|
5065
5108
|
var files = function files(options) {
|
|
5066
|
-
var _options$
|
|
5067
|
-
var directory =
|
|
5109
|
+
var _options$remote;
|
|
5110
|
+
var directory = options.directory;
|
|
5068
5111
|
var itemSchema = new ObjectSchema({
|
|
5069
5112
|
mimeType: new StringSchema({}, false)
|
|
5070
5113
|
}, false);
|
|
@@ -6117,8 +6160,9 @@ function router(router, keyOrItem, maybeItem) {
|
|
|
6117
6160
|
/**
|
|
6118
6161
|
* Define a collection of images.
|
|
6119
6162
|
*
|
|
6120
|
-
*
|
|
6121
|
-
*
|
|
6163
|
+
* `directory` is required — it decides where uploads land, so it is not something
|
|
6164
|
+
* to be inferred. The rest defaults: any image type (`"image/*"`), nullable alt
|
|
6165
|
+
* text, remote disabled.
|
|
6122
6166
|
*
|
|
6123
6167
|
* @example
|
|
6124
6168
|
* ```typescript
|
|
@@ -6138,9 +6182,9 @@ function router(router, keyOrItem, maybeItem) {
|
|
|
6138
6182
|
* ```
|
|
6139
6183
|
*/
|
|
6140
6184
|
var images = function images(options) {
|
|
6141
|
-
var _options$
|
|
6142
|
-
var directory =
|
|
6143
|
-
var altSchema = (_options$alt = options
|
|
6185
|
+
var _options$alt, _options$accept, _options$remote;
|
|
6186
|
+
var directory = options.directory;
|
|
6187
|
+
var altSchema = (_options$alt = options.alt) !== null && _options$alt !== void 0 ? _options$alt : string().nullable();
|
|
6144
6188
|
var itemSchema = new ObjectSchema({
|
|
6145
6189
|
width: new NumberSchema(undefined, false),
|
|
6146
6190
|
height: new NumberSchema(undefined, false),
|
|
@@ -6149,9 +6193,9 @@ var images = function images(options) {
|
|
|
6149
6193
|
}, false);
|
|
6150
6194
|
return new RecordSchema(itemSchema, false, [], null, null, {
|
|
6151
6195
|
type: "images",
|
|
6152
|
-
accept: (_options$accept = options
|
|
6196
|
+
accept: (_options$accept = options.accept) !== null && _options$accept !== void 0 ? _options$accept : "image/*",
|
|
6153
6197
|
directory: directory,
|
|
6154
|
-
remote: (_options$remote = options
|
|
6198
|
+
remote: (_options$remote = options.remote) !== null && _options$remote !== void 0 ? _options$remote : false,
|
|
6155
6199
|
altSchema: altSchema
|
|
6156
6200
|
});
|
|
6157
6201
|
};
|
|
@@ -6752,7 +6796,7 @@ function collectObjectRecursive(item, collector) {
|
|
|
6752
6796
|
* Extracts schemas and sources from a ValModules registry and computes the
|
|
6753
6797
|
* deterministic SHAs that the server and client both use to detect changes.
|
|
6754
6798
|
*
|
|
6755
|
-
* Used by ValOps on the server and by
|
|
6799
|
+
* Used by ValOps on the server and by `HostStore` on the client so the
|
|
6756
6800
|
* hash algorithm has a single source of truth.
|
|
6757
6801
|
*/
|
|
6758
6802
|
function extractValModules(_x) {
|
|
@@ -6928,6 +6972,104 @@ function _extractValModules() {
|
|
|
6928
6972
|
return _extractValModules.apply(this, arguments);
|
|
6929
6973
|
}
|
|
6930
6974
|
|
|
6975
|
+
/**
|
|
6976
|
+
* Does this schema store any file remotely?
|
|
6977
|
+
*
|
|
6978
|
+
* The one answer to that question. There used to be two — `hasRemoteFileSchema`
|
|
6979
|
+
* in the server, gating whether `/save` demands remote credentials, and
|
|
6980
|
+
* `findRequiredRemoteFiles` in the Studio, gating the `/remote/settings` fetch —
|
|
6981
|
+
* and they disagreed about `s.images({ remote: true })`: the Studio's counted a
|
|
6982
|
+
* remote media record, the server's did not, because a media collection
|
|
6983
|
+
* serializes as a `record` of metadata rather than as an image schema.
|
|
6984
|
+
*
|
|
6985
|
+
* The server's answer was the wrong one, and silently so. With it false,
|
|
6986
|
+
* `/save` runs `saveOrUploadFiles` in `skip-remote` mode, and that mode does not
|
|
6987
|
+
* merely skip the upload — it drops every remote descriptor without an error. The
|
|
6988
|
+
* commit then lands a remote ref with no bytes behind it: a broken image, in the
|
|
6989
|
+
* repository, with nothing anywhere saying why.
|
|
6990
|
+
*
|
|
6991
|
+
* ## Why it stays a walk over the SERIALIZED schema
|
|
6992
|
+
*
|
|
6993
|
+
* Both callers have a `SerializedSchema` and not a `Schema`: the server reads
|
|
6994
|
+
* them out of `getSchemas()`, and the Studio is handed them by `host.receive`.
|
|
6995
|
+
* Asking the schema classes directly would mean a method on every one of them,
|
|
6996
|
+
* and the two places that need the answer cannot call it.
|
|
6997
|
+
*
|
|
6998
|
+
* ## Throwing
|
|
6999
|
+
*
|
|
7000
|
+
* The `never` assignment at the end is the point of the default branch: adding a
|
|
7001
|
+
* schema type without teaching this function about it must not compile. The throw
|
|
7002
|
+
* is what happens if one arrives anyway — which for a caller reading schemas out
|
|
7003
|
+
* of its own process should be impossible. A caller that cannot afford to throw
|
|
7004
|
+
* (the Studio, whose whole UI is downstream of this) catches it; returning `false`
|
|
7005
|
+
* instead would reintroduce exactly the silent skip described above.
|
|
7006
|
+
*/
|
|
7007
|
+
function hasRemoteFileSchema(schema) {
|
|
7008
|
+
if (schema.type === "file" || schema.type === "image") {
|
|
7009
|
+
return !!schema.remote;
|
|
7010
|
+
} else if (schema.type === "richtext") {
|
|
7011
|
+
var _schema$options;
|
|
7012
|
+
if (_typeof((_schema$options = schema.options) === null || _schema$options === void 0 || (_schema$options = _schema$options.inline) === null || _schema$options === void 0 ? void 0 : _schema$options.img) === "object") {
|
|
7013
|
+
return hasRemoteFileSchema(schema.options.inline.img);
|
|
7014
|
+
}
|
|
7015
|
+
return false;
|
|
7016
|
+
} else if (schema.type === "array") {
|
|
7017
|
+
return hasRemoteFileSchema(schema.item);
|
|
7018
|
+
} else if (schema.type === "record") {
|
|
7019
|
+
/**
|
|
7020
|
+
* A media collection — `s.images()` / `s.files()` — is the case both of the
|
|
7021
|
+
* old functions were written around, and the one they disagreed on.
|
|
7022
|
+
*
|
|
7023
|
+
* It has no file or image schema inside it to find: `item` is an object of
|
|
7024
|
+
* width/height/mimeType/alt, and the file itself is named by the record's
|
|
7025
|
+
* KEY. So `remote` on the record is the only place the answer is written
|
|
7026
|
+
* down, and recursing into `item` can only ever say no.
|
|
7027
|
+
*/
|
|
7028
|
+
if (schema.mediaType && schema.remote) {
|
|
7029
|
+
return true;
|
|
7030
|
+
}
|
|
7031
|
+
return hasRemoteFileSchema(schema.item);
|
|
7032
|
+
} else if (schema.type === "object") {
|
|
7033
|
+
for (var key in schema.items) {
|
|
7034
|
+
var hasRemoteFile = hasRemoteFileSchema(schema.items[key]);
|
|
7035
|
+
if (hasRemoteFile) {
|
|
7036
|
+
return true;
|
|
7037
|
+
}
|
|
7038
|
+
}
|
|
7039
|
+
return false;
|
|
7040
|
+
} else if (schema.type === "union") {
|
|
7041
|
+
var unionStringSchema = _typeof(schema.key) === "object" && schema.key.type === "literal" ? schema : undefined;
|
|
7042
|
+
var unionObjectSchema = typeof schema.key === "string" ? schema : undefined;
|
|
7043
|
+
if (unionStringSchema) {
|
|
7044
|
+
// A string union's items are literals, so there is nothing to look inside.
|
|
7045
|
+
return false;
|
|
7046
|
+
}
|
|
7047
|
+
if (unionObjectSchema) {
|
|
7048
|
+
var _iterator = _createForOfIteratorHelper(unionObjectSchema.items),
|
|
7049
|
+
_step;
|
|
7050
|
+
try {
|
|
7051
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
7052
|
+
var item = _step.value;
|
|
7053
|
+
var _hasRemoteFile = hasRemoteFileSchema(item);
|
|
7054
|
+
if (_hasRemoteFile) {
|
|
7055
|
+
return true;
|
|
7056
|
+
}
|
|
7057
|
+
}
|
|
7058
|
+
} catch (err) {
|
|
7059
|
+
_iterator.e(err);
|
|
7060
|
+
} finally {
|
|
7061
|
+
_iterator.f();
|
|
7062
|
+
}
|
|
7063
|
+
}
|
|
7064
|
+
return false;
|
|
7065
|
+
} else if (schema.type === "boolean" || schema.type === "number" || schema.type === "string" || schema.type === "literal" || schema.type === "date" || schema.type === "dateTime" || schema.type === "color" || schema.type === "keyOf" || schema.type === "route") {
|
|
7066
|
+
return false;
|
|
7067
|
+
} else {
|
|
7068
|
+
var exhaustiveCheck = schema;
|
|
7069
|
+
throw new Error("Unexpected schema: ".concat(JSON.stringify(exhaustiveCheck)));
|
|
7070
|
+
}
|
|
7071
|
+
}
|
|
7072
|
+
|
|
6931
7073
|
var DEFAULT_VAL_REMOTE_HOST = "https://remote.val.build";
|
|
6932
7074
|
function convertRemoteSource(src) {
|
|
6933
7075
|
if (src !== null && src !== void 0 && src.patch_id) {
|
|
@@ -7920,6 +8062,94 @@ function deserializeSchemaImpl(serialized) {
|
|
|
7920
8062
|
}
|
|
7921
8063
|
}
|
|
7922
8064
|
|
|
8065
|
+
// TODO: we want to change layout -> as to be more consistent across the board
|
|
8066
|
+
|
|
8067
|
+
// Main render type:
|
|
8068
|
+
|
|
8069
|
+
//
|
|
8070
|
+
|
|
8071
|
+
/**
|
|
8072
|
+
* Which paths a render is being computed FOR.
|
|
8073
|
+
*
|
|
8074
|
+
* `executeRender` takes a whole module, so one request has always walked every
|
|
8075
|
+
* node in it and run every `select` closure — for `handboka`, with `select` at
|
|
8076
|
+
* two nested array levels, that is every chapter and every section to serve one
|
|
8077
|
+
* visible row. A scope is what makes the walk proportional to what is being
|
|
8078
|
+
* looked at instead of to the project.
|
|
8079
|
+
*
|
|
8080
|
+
* Two questions, because a container and its items need different answers:
|
|
8081
|
+
*
|
|
8082
|
+
* - {@link RenderScope.wants} — is a render AT this exact path wanted? A
|
|
8083
|
+
* container answers `true` here when the whole of it is being shown, and its
|
|
8084
|
+
* list render is then computed in full.
|
|
8085
|
+
* - {@link RenderScope.wantsUnder} — could anything at or below this path be
|
|
8086
|
+
* wanted? Recursion is pruned where this is `false`, and a container whose own
|
|
8087
|
+
* path is not wanted but which has wanted descendants renders a WINDOW: only
|
|
8088
|
+
* the items that were asked for. That is the case a single visible row is, and
|
|
8089
|
+
* it is why {@link ListArrayRender} carries indices.
|
|
8090
|
+
*
|
|
8091
|
+
* Absent scope means the whole module, which is what every existing caller
|
|
8092
|
+
* passes and what every existing caller got.
|
|
8093
|
+
*/
|
|
8094
|
+
|
|
8095
|
+
/**
|
|
8096
|
+
* A scope covering exactly `paths` and their subtrees.
|
|
8097
|
+
*
|
|
8098
|
+
* Compares SEGMENTS rather than string prefixes. A source path's module path is
|
|
8099
|
+
* a quoted, dot-joined encoding (`?p="a".1."b"`), so `startsWith` gets the
|
|
8100
|
+
* ancestor test wrong wherever a key is a prefix of a sibling key or contains a
|
|
8101
|
+
* dot or a quote — `"title"` against `"titles"` being the cheapest example.
|
|
8102
|
+
* Segments are parsed once here, not per comparison.
|
|
8103
|
+
*/
|
|
8104
|
+
function renderScope(paths) {
|
|
8105
|
+
var wanted = paths.map(function (path) {
|
|
8106
|
+
var _splitModuleFilePathA = splitModuleFilePathAndModulePath(path),
|
|
8107
|
+
_splitModuleFilePathA2 = _slicedToArray(_splitModuleFilePathA, 2),
|
|
8108
|
+
moduleFilePath = _splitModuleFilePathA2[0],
|
|
8109
|
+
modulePath = _splitModuleFilePathA2[1];
|
|
8110
|
+
return {
|
|
8111
|
+
moduleFilePath: moduleFilePath,
|
|
8112
|
+
segments: modulePath === "" ? [] : splitModulePath(modulePath)
|
|
8113
|
+
};
|
|
8114
|
+
});
|
|
8115
|
+
var parse = function parse(path) {
|
|
8116
|
+
var _splitModuleFilePathA3 = splitModuleFilePathAndModulePath(path),
|
|
8117
|
+
_splitModuleFilePathA4 = _slicedToArray(_splitModuleFilePathA3, 2),
|
|
8118
|
+
moduleFilePath = _splitModuleFilePathA4[0],
|
|
8119
|
+
modulePath = _splitModuleFilePathA4[1];
|
|
8120
|
+
return {
|
|
8121
|
+
moduleFilePath: moduleFilePath,
|
|
8122
|
+
segments: modulePath === "" ? [] : splitModulePath(modulePath)
|
|
8123
|
+
};
|
|
8124
|
+
};
|
|
8125
|
+
var isPrefix = function isPrefix(prefix, of) {
|
|
8126
|
+
if (prefix.length > of.length) return false;
|
|
8127
|
+
for (var i = 0; i < prefix.length; i++) {
|
|
8128
|
+
if (prefix[i] !== of[i]) return false;
|
|
8129
|
+
}
|
|
8130
|
+
return true;
|
|
8131
|
+
};
|
|
8132
|
+
return {
|
|
8133
|
+
wants: function wants(path) {
|
|
8134
|
+
var at = parse(path);
|
|
8135
|
+
return wanted.some(function (entry) {
|
|
8136
|
+
return entry.moduleFilePath === at.moduleFilePath && entry.segments.length === at.segments.length && isPrefix(entry.segments, at.segments);
|
|
8137
|
+
});
|
|
8138
|
+
},
|
|
8139
|
+
wantsUnder: function wantsUnder(path) {
|
|
8140
|
+
var at = parse(path);
|
|
8141
|
+
return wanted.some(function (entry) {
|
|
8142
|
+
return entry.moduleFilePath === at.moduleFilePath && (
|
|
8143
|
+
// Either direction: a wanted path below `path` means recurse into it,
|
|
8144
|
+
// and a wanted path ABOVE it means the whole subtree was asked for.
|
|
8145
|
+
isPrefix(at.segments, entry.segments) || isPrefix(entry.segments, at.segments));
|
|
8146
|
+
});
|
|
8147
|
+
}
|
|
8148
|
+
};
|
|
8149
|
+
}
|
|
8150
|
+
|
|
8151
|
+
// TODO: improve this so that we do not get RawString and string, only string. Are there other things?
|
|
8152
|
+
|
|
7923
8153
|
var externalPageRouter = {
|
|
7924
8154
|
getRouterId: function getRouterId() {
|
|
7925
8155
|
return "external-url-router";
|
|
@@ -8280,4 +8510,4 @@ function tryJsonParse(str) {
|
|
|
8280
8510
|
}
|
|
8281
8511
|
}
|
|
8282
8512
|
|
|
8283
|
-
export { ArraySchema as A, BooleanSchema as B, ColorSchema as C, DEFAULT_CONTENT_HOST as D, FATAL_ERROR_TYPES as F, GenericSelector as G, Internal as I, KeyOfSchema as K, LiteralSchema as L, ModuleFilePathSep as M, NumberSchema as N, ObjectSchema as O, PatchError as P, RecordSchema as R, Schema as S, UnionSchema as U, VAL_EXTENSION as V, _typeof as _, _slicedToArray as a, _createClass as b, _classCallCheck as c, _toConsumableArray as d, DEFAULT_APP_HOST as e, extractValModules as f, DEFAULT_VAL_REMOTE_HOST as g,
|
|
8513
|
+
export { ArraySchema as A, BooleanSchema as B, ColorSchema as C, DEFAULT_CONTENT_HOST as D, FATAL_ERROR_TYPES as F, GenericSelector as G, Internal as I, KeyOfSchema as K, LiteralSchema as L, ModuleFilePathSep as M, NumberSchema as N, ObjectSchema as O, PatchError as P, RecordSchema as R, Schema as S, UnionSchema as U, VAL_EXTENSION as V, _typeof as _, _slicedToArray as a, _createClass as b, _classCallCheck as c, _toConsumableArray as d, DEFAULT_APP_HOST as e, extractValModules as f, DEFAULT_VAL_REMOTE_HOST as g, hasRemoteFileSchema as h, initVal as i, FILE_REF_PROP as j, FILE_REF_SUBTYPE_TAG as k, derefPatch as l, modules as m, StringSchema as n, ImageSchema as o, FileSchema as p, DateSchema as q, COLOR_FORMATS as r, splitModuleFilePathAndModulePath as s, DEFAULT_COLOR_FORMAT as t, DateTimeSchema as u, RouteSchema as v, RichTextSchema as w, deserializeSchema as x, renderScope as y, getSourcePathFromRoute as z };
|