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