@valbuild/core 0.141.0 → 0.144.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/CHANGELOG.md +67 -0
- package/dist/declarations/src/index.d.ts +13 -4
- package/dist/declarations/src/initSchema.d.ts +108 -18
- package/dist/declarations/src/initVal.d.ts +2 -2
- package/dist/declarations/src/mimeType/font.d.ts +36 -0
- package/dist/declarations/src/mimeType/index.d.ts +1 -0
- package/dist/declarations/src/render.d.ts +1 -1
- package/dist/declarations/src/schema/file.d.ts +4 -4
- package/dist/declarations/src/schema/filedir.d.ts +83 -0
- package/dist/declarations/src/schema/font.d.ts +16 -0
- package/dist/declarations/src/schema/fontdir.d.ts +63 -0
- package/dist/declarations/src/schema/hasRemoteFileSchema.d.ts +3 -3
- package/dist/declarations/src/schema/image.d.ts +4 -4
- package/dist/declarations/src/schema/{imageset.d.ts → imagedir.d.ts} +63 -29
- package/dist/declarations/src/schema/record.d.ts +17 -6
- package/dist/declarations/src/schema/video.d.ts +7 -7
- package/dist/declarations/src/schema/{videoset.d.ts → videodir.d.ts} +55 -27
- package/dist/declarations/src/source/media.d.ts +26 -3
- package/dist/{index-13cf45b1.cjs.prod.js → index-2d194c90.cjs.prod.js} +504 -79
- package/dist/{index-fae161b5.cjs.dev.js → index-8b22b2c1.cjs.dev.js} +504 -79
- package/dist/{index-a6c53286.esm.js → index-aa16dd90.esm.js} +503 -80
- 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
- package/dist/declarations/src/schema/fileset.d.ts +0 -57
|
@@ -2846,7 +2846,7 @@ var _excluded = ["poster", "captions"];
|
|
|
2846
2846
|
* What a video FIELD authors, on top of the file it names: the description,
|
|
2847
2847
|
* the crop, the poster, the trim and the caption tracks.
|
|
2848
2848
|
*
|
|
2849
|
-
* This is the whole value of a field picked from an `s.
|
|
2849
|
+
* This is the whole value of a field picked from an `s.videodir()`
|
|
2850
2850
|
* (`s.video(videosetVal)`) — the mime type, size and length live in the set,
|
|
2851
2851
|
* keyed by `path`, and repeating them here is how two copies of one fact get
|
|
2852
2852
|
* to disagree. The poster, captions and times stay with the FIELD: one video
|
|
@@ -2858,7 +2858,7 @@ var _excluded = ["poster", "captions"];
|
|
|
2858
2858
|
/**
|
|
2859
2859
|
* What one page chooses about a video — as opposed to what is true of the
|
|
2860
2860
|
* file. A field (`s.video()`) carries these for itself; the entry of a set
|
|
2861
|
-
* (`s.
|
|
2861
|
+
* (`s.videodir()`) carries them as DEFAULTS, which every field picked from the
|
|
2862
2862
|
* set starts from and may override key by key. See {@link fillFromGallery}.
|
|
2863
2863
|
*/
|
|
2864
2864
|
|
|
@@ -3000,6 +3000,42 @@ function isMediaSchema(schema) {
|
|
|
3000
3000
|
return _typeof(schema) === "object" && schema !== null && "type" in schema && (schema.type === "image" || schema.type === "file" || schema.type === "video");
|
|
3001
3001
|
}
|
|
3002
3002
|
|
|
3003
|
+
/**
|
|
3004
|
+
* The key of a gallery (an `s.imagedir()`, `s.filedir()` or `s.videodir()`)
|
|
3005
|
+
* that a field's `path` names, or `null` when it names none.
|
|
3006
|
+
*
|
|
3007
|
+
* Usually the path IS the key. It is not for an image uploaded THROUGH an
|
|
3008
|
+
* `s.image(remoteGallery)` field in the Studio, which stores the remote ref in
|
|
3009
|
+
* the field and keys the entry by the local path inside it — so a path that is
|
|
3010
|
+
* not a key falls back to that embedded path. Exact first, because a gallery
|
|
3011
|
+
* can hold both shapes for one file, and the field then names the entry that
|
|
3012
|
+
* IS its path.
|
|
3013
|
+
*
|
|
3014
|
+
* One implementation of the question, asked by everything that has to agree on
|
|
3015
|
+
* the answer: reading a field (`galleryEntryOf`), validating it (`ImageSchema`
|
|
3016
|
+
* and `FileSchema` ask whether the gallery has it), the Studio's reference
|
|
3017
|
+
* scans and renames, and `val validate --fix` when it renames a key and has to
|
|
3018
|
+
* find the fields that hold it.
|
|
3019
|
+
*
|
|
3020
|
+
* The embedded path is tried with its leading slash (how a key is written) and
|
|
3021
|
+
* without (how `splitRemoteRef` returns it).
|
|
3022
|
+
*/
|
|
3023
|
+
function galleryKeyOf(path, isKey) {
|
|
3024
|
+
if (isKey(path)) {
|
|
3025
|
+
return path;
|
|
3026
|
+
}
|
|
3027
|
+
var split = splitRemoteRef(path);
|
|
3028
|
+
if (split.status === "success") {
|
|
3029
|
+
for (var _i = 0, _arr = ["/".concat(split.filePath), split.filePath]; _i < _arr.length; _i++) {
|
|
3030
|
+
var embedded = _arr[_i];
|
|
3031
|
+
if (isKey(embedded)) {
|
|
3032
|
+
return embedded;
|
|
3033
|
+
}
|
|
3034
|
+
}
|
|
3035
|
+
}
|
|
3036
|
+
return null;
|
|
3037
|
+
}
|
|
3038
|
+
|
|
3003
3039
|
/**
|
|
3004
3040
|
* What a gallery entry holds as a DEFAULT for the fields picked from it, in
|
|
3005
3041
|
* the groups a field overrides together.
|
|
@@ -3019,7 +3055,9 @@ var GALLERY_FILE_FACTS = ["width", "height", "mimeType", "duration"];
|
|
|
3019
3055
|
* gallery-backed or the gallery has no such entry.
|
|
3020
3056
|
*
|
|
3021
3057
|
* The double lookup is load-bearing: a remote gallery keys its entries by the
|
|
3022
|
-
* remote URL while the file itself stays on disk under its local path
|
|
3058
|
+
* remote URL while the file itself stays on disk under its local path, and an
|
|
3059
|
+
* upload through the field does it the other way round (see
|
|
3060
|
+
* {@link galleryKeyOf}).
|
|
3023
3061
|
*/
|
|
3024
3062
|
function galleryEntryOf(src, schema, getModuleSource) {
|
|
3025
3063
|
if (!isMediaSchema(schema) || !schema.referencedModule) {
|
|
@@ -3029,13 +3067,9 @@ function galleryEntryOf(src, schema, getModuleSource) {
|
|
|
3029
3067
|
if (!isPlainObject(moduleSource)) {
|
|
3030
3068
|
return null;
|
|
3031
3069
|
}
|
|
3032
|
-
var key = src.path
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
if (splitRemoteRefRes.status === "success" && splitRemoteRefRes.filePath in moduleSource) {
|
|
3036
|
-
key = splitRemoteRefRes.filePath;
|
|
3037
|
-
}
|
|
3038
|
-
}
|
|
3070
|
+
var key = galleryKeyOf(src.path, function (candidate) {
|
|
3071
|
+
return candidate in moduleSource;
|
|
3072
|
+
});
|
|
3039
3073
|
if (key === null) {
|
|
3040
3074
|
return null;
|
|
3041
3075
|
}
|
|
@@ -3604,7 +3638,7 @@ var EXT_TO_MIME_TYPES = {
|
|
|
3604
3638
|
sxw: "application/vnd.sun.xml.writer",
|
|
3605
3639
|
sxg: "application/vnd.sun.xml.writer.global",
|
|
3606
3640
|
stw: "application/vnd.sun.xml.writer.template",
|
|
3607
|
-
otf: "
|
|
3641
|
+
otf: "font/otf",
|
|
3608
3642
|
osfpvg: "application/vnd.yamaha.openscoreformat.osfpvg+xml",
|
|
3609
3643
|
dp: "application/vnd.osgi.dp",
|
|
3610
3644
|
pdb: "application/vnd.palm",
|
|
@@ -3754,7 +3788,8 @@ var EXT_TO_MIME_TYPES = {
|
|
|
3754
3788
|
mxs: "application/vnd.triscape.mxs",
|
|
3755
3789
|
t: "text/troff",
|
|
3756
3790
|
tra: "application/vnd.trueapp",
|
|
3757
|
-
ttf: "
|
|
3791
|
+
ttf: "font/ttf",
|
|
3792
|
+
ttc: "font/collection",
|
|
3758
3793
|
ttl: "text/turtle",
|
|
3759
3794
|
umj: "application/vnd.umajin",
|
|
3760
3795
|
uoml: "application/vnd.uoml+xml",
|
|
@@ -3781,7 +3816,8 @@ var EXT_TO_MIME_TYPES = {
|
|
|
3781
3816
|
wbmp: "image/vnd.wap.wbmp",
|
|
3782
3817
|
wav: "audio/x-wav",
|
|
3783
3818
|
davmount: "application/davmount+xml",
|
|
3784
|
-
woff: "
|
|
3819
|
+
woff: "font/woff",
|
|
3820
|
+
woff2: "font/woff2",
|
|
3785
3821
|
wspolicy: "application/wspolicy+xml",
|
|
3786
3822
|
webp: "image/webp",
|
|
3787
3823
|
wtb: "application/vnd.webturbo",
|
|
@@ -3883,6 +3919,93 @@ function mimeTypeMatchesAccept(mimeType, accept) {
|
|
|
3883
3919
|
});
|
|
3884
3920
|
}
|
|
3885
3921
|
|
|
3922
|
+
/**
|
|
3923
|
+
* Fonts, as far as a mime type can tell.
|
|
3924
|
+
*
|
|
3925
|
+
* The four web formats have IANA types under `font/` (RFC 8081), and those are
|
|
3926
|
+
* what Val stores. Browsers and operating systems disagree about them: a file
|
|
3927
|
+
* picker reports `.woff2` as `font/woff2`, `application/font-woff2` or nothing
|
|
3928
|
+
* at all depending on the platform, and nothing at all reads as
|
|
3929
|
+
* `application/octet-stream` once the file is a data URL. That is why an upload
|
|
3930
|
+
* asks the BYTES ({@link sniffFontMimeType}) rather than trusting the picker.
|
|
3931
|
+
*/
|
|
3932
|
+
|
|
3933
|
+
/** The formats `s.fontdir()` accepts unless told otherwise, best first. */
|
|
3934
|
+
var FONT_MIME_TYPES = ["font/woff2", "font/woff", "font/ttf", "font/otf"];
|
|
3935
|
+
|
|
3936
|
+
/** `s.fontdir()`'s `accept` when none is given. */
|
|
3937
|
+
var DEFAULT_FONT_ACCEPT = FONT_MIME_TYPES.join(",");
|
|
3938
|
+
|
|
3939
|
+
/**
|
|
3940
|
+
* The extension of each font type, for a file input: a picker matches an
|
|
3941
|
+
* `accept` of mime types through the operating system's own table, and where
|
|
3942
|
+
* that table does not know `font/woff2` the file is greyed out.
|
|
3943
|
+
*/
|
|
3944
|
+
var FONT_MIME_TYPE_EXTENSIONS = {
|
|
3945
|
+
"font/woff2": ".woff2",
|
|
3946
|
+
"font/woff": ".woff",
|
|
3947
|
+
"font/ttf": ".ttf",
|
|
3948
|
+
"font/otf": ".otf",
|
|
3949
|
+
"font/collection": ".ttc"
|
|
3950
|
+
};
|
|
3951
|
+
|
|
3952
|
+
/**
|
|
3953
|
+
* The names the extension table used for fonts before it used RFC 8081's.
|
|
3954
|
+
* Content written then still carries them, and it is the same file.
|
|
3955
|
+
*/
|
|
3956
|
+
var LEGACY_FONT_MIME_TYPES = {
|
|
3957
|
+
"application/x-font-ttf": "font/ttf",
|
|
3958
|
+
"application/x-font-otf": "font/otf",
|
|
3959
|
+
"application/x-font-woff": "font/woff"
|
|
3960
|
+
};
|
|
3961
|
+
|
|
3962
|
+
/** `mimeType`, with a legacy font name read as its `font/` type. */
|
|
3963
|
+
function canonicalFontMimeType(mimeType) {
|
|
3964
|
+
var _LEGACY_FONT_MIME_TYP;
|
|
3965
|
+
return (_LEGACY_FONT_MIME_TYP = LEGACY_FONT_MIME_TYPES[mimeType]) !== null && _LEGACY_FONT_MIME_TYP !== void 0 ? _LEGACY_FONT_MIME_TYP : mimeType;
|
|
3966
|
+
}
|
|
3967
|
+
|
|
3968
|
+
/**
|
|
3969
|
+
* Whether a file of `mimeType` is a font a browser can draw: the `font/` types,
|
|
3970
|
+
* and the pre-RFC 8081 names still found in older data.
|
|
3971
|
+
*/
|
|
3972
|
+
function isFontMimeType(mimeType) {
|
|
3973
|
+
if (!mimeType) {
|
|
3974
|
+
return false;
|
|
3975
|
+
}
|
|
3976
|
+
return mimeType.startsWith("font/") || mimeType.startsWith("application/x-font-") || mimeType === "application/font-woff" || mimeType === "application/font-woff2" || mimeType === "application/font-sfnt" || mimeType === "application/vnd.ms-opentype";
|
|
3977
|
+
}
|
|
3978
|
+
|
|
3979
|
+
/**
|
|
3980
|
+
* The font type of `bytes`, read from the signature every font format starts
|
|
3981
|
+
* with, or `null` when they are not a font.
|
|
3982
|
+
*
|
|
3983
|
+
* Only the first four bytes are needed: the WOFF signatures (`wOFF`, `wOF2`),
|
|
3984
|
+
* the SFNT versions of TrueType (`0x00010000`, or `true` from old Apple fonts)
|
|
3985
|
+
* and of CFF-flavoured OpenType (`OTTO`), and a collection's tag (`ttcf`).
|
|
3986
|
+
*/
|
|
3987
|
+
function sniffFontMimeType(bytes) {
|
|
3988
|
+
if (bytes.length < 4) {
|
|
3989
|
+
return null;
|
|
3990
|
+
}
|
|
3991
|
+
var tag = String.fromCharCode(bytes[0], bytes[1], bytes[2], bytes[3]);
|
|
3992
|
+
switch (tag) {
|
|
3993
|
+
case "wOF2":
|
|
3994
|
+
return "font/woff2";
|
|
3995
|
+
case "wOFF":
|
|
3996
|
+
return "font/woff";
|
|
3997
|
+
case "OTTO":
|
|
3998
|
+
return "font/otf";
|
|
3999
|
+
case "true":
|
|
4000
|
+
case "\0\x01\0\0":
|
|
4001
|
+
return "font/ttf";
|
|
4002
|
+
case "ttcf":
|
|
4003
|
+
return "font/collection";
|
|
4004
|
+
default:
|
|
4005
|
+
return null;
|
|
4006
|
+
}
|
|
4007
|
+
}
|
|
4008
|
+
|
|
3886
4009
|
/**
|
|
3887
4010
|
* How an uploaded image is re-encoded in the browser, before it is uploaded.
|
|
3888
4011
|
*
|
|
@@ -4049,24 +4172,31 @@ var ImageSchema = /*#__PURE__*/function (_Schema) {
|
|
|
4049
4172
|
value: src
|
|
4050
4173
|
}]));
|
|
4051
4174
|
}
|
|
4175
|
+
// A field picked from a gallery holds the gallery's KEY, and whether that
|
|
4176
|
+
// key is a local path or a remote ref is the gallery's to decide — and its
|
|
4177
|
+
// to fix: uploading an entry renames its key, and the fields that hold it
|
|
4178
|
+
// with it. So such a field only asks whether the gallery has it, below.
|
|
4179
|
+
// Asking here as well reported every image picked from a `.remote()`
|
|
4180
|
+
// gallery as one to download, because the field itself is never remote.
|
|
4181
|
+
var galleryEntries = this.galleryEntries();
|
|
4052
4182
|
// Remote-ness is a property of the path, not of a marker on the value:
|
|
4053
4183
|
// anything outside /public is remote.
|
|
4054
4184
|
var isRemotePath = isRemoteMediaPath(src.path);
|
|
4055
|
-
if (this.isRemote && !isRemotePath) {
|
|
4185
|
+
if (!galleryEntries && this.isRemote && !isRemotePath) {
|
|
4056
4186
|
return _defineProperty({}, path, [].concat(_toConsumableArray(customValidationErrors), [{
|
|
4057
4187
|
message: "Expected a remote image, but got a local image.",
|
|
4058
4188
|
value: src,
|
|
4059
4189
|
fixes: ["image:upload-remote"]
|
|
4060
4190
|
}]));
|
|
4061
4191
|
}
|
|
4062
|
-
if (this.isRemote && isRemotePath) {
|
|
4192
|
+
if (!galleryEntries && this.isRemote && isRemotePath) {
|
|
4063
4193
|
return _defineProperty({}, path, [].concat(_toConsumableArray(customValidationErrors), [{
|
|
4064
4194
|
message: "Remote image was not checked.",
|
|
4065
4195
|
value: src,
|
|
4066
4196
|
fixes: ["image:check-remote"]
|
|
4067
4197
|
}]));
|
|
4068
4198
|
}
|
|
4069
|
-
if (!this.isRemote && isRemotePath) {
|
|
4199
|
+
if (!galleryEntries && !this.isRemote && isRemotePath) {
|
|
4070
4200
|
return _defineProperty({}, path, [].concat(_toConsumableArray(customValidationErrors), [{
|
|
4071
4201
|
message: "Expected local image, but found remote.",
|
|
4072
4202
|
value: src,
|
|
@@ -4081,7 +4211,6 @@ var ImageSchema = /*#__PURE__*/function (_Schema) {
|
|
|
4081
4211
|
}]));
|
|
4082
4212
|
}
|
|
4083
4213
|
}
|
|
4084
|
-
var galleryEntries = this.galleryEntries();
|
|
4085
4214
|
if (galleryEntries) {
|
|
4086
4215
|
// The dimensions and mime type of a gallery image are stored once, in the
|
|
4087
4216
|
// gallery. Repeating them on the field is how the two get to disagree.
|
|
@@ -4094,7 +4223,11 @@ var ImageSchema = /*#__PURE__*/function (_Schema) {
|
|
|
4094
4223
|
value: src
|
|
4095
4224
|
}]));
|
|
4096
4225
|
}
|
|
4097
|
-
|
|
4226
|
+
// The same match reading the field makes (`fillFromGallery`): the key,
|
|
4227
|
+
// or the local path inside a ref an upload through the field stored.
|
|
4228
|
+
if (galleryKeyOf(src.path, function (key) {
|
|
4229
|
+
return key in galleryEntries;
|
|
4230
|
+
}) === null) {
|
|
4098
4231
|
return _defineProperty({}, path, [].concat(_toConsumableArray(customValidationErrors), [{
|
|
4099
4232
|
message: "The gallery does not have an image at '".concat(src.path, "'."),
|
|
4100
4233
|
value: src
|
|
@@ -5711,7 +5844,7 @@ function missingDeclaredKeys(declared, present) {
|
|
|
5711
5844
|
/**
|
|
5712
5845
|
* The checks of what one page chose about a video — its times, focal point,
|
|
5713
5846
|
* poster and captions — shared by the two places those choices are made: a
|
|
5714
|
-
* field (`s.video()`) and the entry of a set (`s.
|
|
5847
|
+
* field (`s.video()`) and the entry of a set (`s.videodir()`), which holds the
|
|
5715
5848
|
* same choices as the defaults every field picked from it starts from.
|
|
5716
5849
|
*/
|
|
5717
5850
|
|
|
@@ -5889,7 +6022,25 @@ function isObject(value) {
|
|
|
5889
6022
|
return _typeof(value) === "object" && value !== null && !Array.isArray(value);
|
|
5890
6023
|
}
|
|
5891
6024
|
|
|
5892
|
-
/** What a media collection (`s.
|
|
6025
|
+
/** What a media collection (`s.imagedir`, `s.filedir`, `s.videodir`) holds. */
|
|
6026
|
+
|
|
6027
|
+
/**
|
|
6028
|
+
* Where a media collection keeps its files: the first argument of
|
|
6029
|
+
* `s.imagedir()`, `s.filedir()`, `s.fontdir()` and `s.videodir()`.
|
|
6030
|
+
*
|
|
6031
|
+
* Required, and deliberately so: it decides where every uploaded file in the
|
|
6032
|
+
* collection lands. It used to default to "/public/val", which meant a
|
|
6033
|
+
* collection that had simply not said where it wanted its files silently
|
|
6034
|
+
* shared a directory with every other one. It is the first argument rather
|
|
6035
|
+
* than an option because it is the one thing every collection has to say.
|
|
6036
|
+
*/
|
|
6037
|
+
|
|
6038
|
+
/** The factory that builds a media collection of each type, for messages. */
|
|
6039
|
+
var mediaDirFactory = {
|
|
6040
|
+
images: "imagedir",
|
|
6041
|
+
files: "filedir",
|
|
6042
|
+
videos: "videodir"
|
|
6043
|
+
};
|
|
5893
6044
|
|
|
5894
6045
|
/**
|
|
5895
6046
|
* The fix code a media collection of `type` reports for `check`.
|
|
@@ -5924,7 +6075,7 @@ function assertRenderable(router, mediaOptions, render) {
|
|
|
5924
6075
|
throw new Error("`.render(...)` is not supported on `s.router(...)`: a router's entries are pages, which have their own UI.");
|
|
5925
6076
|
}
|
|
5926
6077
|
if (mediaOptions) {
|
|
5927
|
-
throw new Error("`.render(...)` is not supported on `s.".concat(mediaOptions.type
|
|
6078
|
+
throw new Error("`.render(...)` is not supported on `s.".concat(mediaDirFactory[mediaOptions.type], "(...)`: media galleries have their own UI."));
|
|
5928
6079
|
}
|
|
5929
6080
|
}
|
|
5930
6081
|
|
|
@@ -6641,7 +6792,7 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
6641
6792
|
* Allow the files in this gallery to be stored on Val's remote content host
|
|
6642
6793
|
* instead of in your repository.
|
|
6643
6794
|
*
|
|
6644
|
-
* For `s.
|
|
6795
|
+
* For `s.imagedir()` and `s.filedir()`, which are records of media. Remote is off
|
|
6645
6796
|
* until this is called.
|
|
6646
6797
|
*
|
|
6647
6798
|
* Each entry is then keyed by its URL on the content host rather than by a
|
|
@@ -6650,7 +6801,7 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
6650
6801
|
* upload it and rewrite the key.
|
|
6651
6802
|
*
|
|
6652
6803
|
* @example
|
|
6653
|
-
* const schema = s.
|
|
6804
|
+
* const schema = s.imagedir("/public/val/images").remote();
|
|
6654
6805
|
* export default c.define("/content/images.val.ts", schema, {
|
|
6655
6806
|
* "https://remote.val.build/file/p/my-project/b/01/v/1.0.0/h/8f2a1c/f/3b9d70/p/public/val/images/hero.webp":
|
|
6656
6807
|
* {
|
|
@@ -6676,7 +6827,7 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
6676
6827
|
* which lets the runtime, the Studio and validation work one entry at a time
|
|
6677
6828
|
* so a record/router can scale to many thousands of entries.
|
|
6678
6829
|
*
|
|
6679
|
-
* Not supported on image/file galleries (`s.
|
|
6830
|
+
* Not supported on image/file galleries (`s.imagedir()` / `s.filedir()`).
|
|
6680
6831
|
*
|
|
6681
6832
|
* Only supported on a module's ROOT record/router — a `.jsonValues()` record
|
|
6682
6833
|
* nested inside an object/array/record is rejected at startup with a module
|
|
@@ -6701,7 +6852,7 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
6701
6852
|
key: "jsonValues",
|
|
6702
6853
|
value: function jsonValues() {
|
|
6703
6854
|
if (this.mediaOptions) {
|
|
6704
|
-
throw new Error(".jsonValues() cannot be used with image/file galleries (s.
|
|
6855
|
+
throw new Error(".jsonValues() cannot be used with image/file galleries (s.imagedir()/s.filedir())");
|
|
6705
6856
|
}
|
|
6706
6857
|
if (this.customValidateFunctions.length > 0) {
|
|
6707
6858
|
// `.jsonValues()` changes the source shape to JsonSource entries, so a
|
|
@@ -6730,7 +6881,7 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
6730
6881
|
* bucket — instead of in the module.
|
|
6731
6882
|
*
|
|
6732
6883
|
* Available on every record-derived schema, which is `s.record()`,
|
|
6733
|
-
* `s.router()`, `s.
|
|
6884
|
+
* `s.router()`, `s.imagedir()` and `s.filedir()` alike: a router is a
|
|
6734
6885
|
* `RecordSchema` with a `ValRouter`, a gallery one with media options, so all
|
|
6735
6886
|
* four get external storage from this one method.
|
|
6736
6887
|
*
|
|
@@ -7060,7 +7211,7 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
7060
7211
|
* draws each entry's own editor in place, labelled by its key, instead of a
|
|
7061
7212
|
* preview row that navigates to it. It reaches the direct entries only.
|
|
7062
7213
|
*
|
|
7063
|
-
* Not for `s.router(...)`, `s.
|
|
7214
|
+
* Not for `s.router(...)`, `s.imagedir(...)` or `s.filedir(...)`: pages and
|
|
7064
7215
|
* media have UIs of their own, so this throws on them.
|
|
7065
7216
|
*
|
|
7066
7217
|
* Static configuration, not a callback — see `render.ts`.
|
|
@@ -10833,31 +10984,37 @@ var FileSchema = /*#__PURE__*/function (_Schema) {
|
|
|
10833
10984
|
value: src
|
|
10834
10985
|
}]));
|
|
10835
10986
|
}
|
|
10987
|
+
// A field picked from a gallery holds the gallery's KEY, and whether that
|
|
10988
|
+
// key is a local path or a remote ref is the gallery's to decide — and its
|
|
10989
|
+
// to fix: uploading an entry renames its key, and the fields that hold it
|
|
10990
|
+
// with it. So such a field only asks whether the gallery has it, below.
|
|
10991
|
+
// Asking here as well reported every file picked from a `.remote()`
|
|
10992
|
+
// gallery as one to download, because the field itself is never remote.
|
|
10993
|
+
var galleryEntries = this.galleryEntries();
|
|
10836
10994
|
// Remote-ness is a property of the path, not of a marker on the value:
|
|
10837
10995
|
// anything outside /public is remote.
|
|
10838
10996
|
var isRemotePath = isRemoteMediaPath(src.path);
|
|
10839
|
-
if (this.isRemote && !isRemotePath) {
|
|
10997
|
+
if (!galleryEntries && this.isRemote && !isRemotePath) {
|
|
10840
10998
|
return _defineProperty({}, path, [].concat(_toConsumableArray(customValidationErrors), [{
|
|
10841
10999
|
message: "Expected a remote file, but got a local file.",
|
|
10842
11000
|
value: src,
|
|
10843
11001
|
fixes: ["file:upload-remote"]
|
|
10844
11002
|
}]));
|
|
10845
11003
|
}
|
|
10846
|
-
if (this.isRemote && isRemotePath) {
|
|
11004
|
+
if (!galleryEntries && this.isRemote && isRemotePath) {
|
|
10847
11005
|
return _defineProperty({}, path, [].concat(_toConsumableArray(customValidationErrors), [{
|
|
10848
11006
|
message: "Remote file was not checked.",
|
|
10849
11007
|
value: src,
|
|
10850
11008
|
fixes: ["file:check-remote"]
|
|
10851
11009
|
}]));
|
|
10852
11010
|
}
|
|
10853
|
-
if (!this.isRemote && isRemotePath) {
|
|
11011
|
+
if (!galleryEntries && !this.isRemote && isRemotePath) {
|
|
10854
11012
|
return _defineProperty({}, path, [].concat(_toConsumableArray(customValidationErrors), [{
|
|
10855
11013
|
message: "Expected local file, but found remote.",
|
|
10856
11014
|
value: src,
|
|
10857
11015
|
fixes: ["file:download-remote"]
|
|
10858
11016
|
}]));
|
|
10859
11017
|
}
|
|
10860
|
-
var galleryEntries = this.galleryEntries();
|
|
10861
11018
|
if (galleryEntries) {
|
|
10862
11019
|
if (src.mimeType !== undefined) {
|
|
10863
11020
|
return _defineProperty({}, path, [].concat(_toConsumableArray(customValidationErrors), [{
|
|
@@ -10865,7 +11022,11 @@ var FileSchema = /*#__PURE__*/function (_Schema) {
|
|
|
10865
11022
|
value: src
|
|
10866
11023
|
}]));
|
|
10867
11024
|
}
|
|
10868
|
-
|
|
11025
|
+
// The same match reading the field makes (`fillFromGallery`): the key,
|
|
11026
|
+
// or the local path inside a ref an upload through the field stored.
|
|
11027
|
+
if (galleryKeyOf(src.path, function (key) {
|
|
11028
|
+
return key in galleryEntries;
|
|
11029
|
+
}) === null) {
|
|
10869
11030
|
return _defineProperty({}, path, [].concat(_toConsumableArray(customValidationErrors), [{
|
|
10870
11031
|
message: "The gallery does not have a file at '".concat(src.path, "'."),
|
|
10871
11032
|
value: src
|
|
@@ -10904,7 +11065,9 @@ var FileSchema = /*#__PURE__*/function (_Schema) {
|
|
|
10904
11065
|
// fix was offered -- and the `file:add-metadata` branch below could never be
|
|
10905
11066
|
// reached for any file whose extension is recognized, which is all of them
|
|
10906
11067
|
// that get this far.
|
|
10907
|
-
|
|
11068
|
+
// A legacy font name (`application/x-font-ttf`) is what the extension
|
|
11069
|
+
// table itself used to say, so it is not a mismatch.
|
|
11070
|
+
if (mimeType && fileMimeType !== canonicalFontMimeType(mimeType)) {
|
|
10908
11071
|
return _defineProperty({}, path, [].concat(_toConsumableArray(customValidationErrors), [{
|
|
10909
11072
|
message: "Mime type and file extension not matching. Mime type is '".concat(mimeType, "' but file extension is '").concat(fileMimeType, "'"),
|
|
10910
11073
|
value: src
|
|
@@ -11098,6 +11261,38 @@ function fileOf(remote, options) {
|
|
|
11098
11261
|
return new FileSchema(options, false, remote);
|
|
11099
11262
|
}
|
|
11100
11263
|
|
|
11264
|
+
/**
|
|
11265
|
+
* A font picked from an `s.fontdir()`.
|
|
11266
|
+
*
|
|
11267
|
+
* The same field `s.file(fontsVal)` is — it stores `{ path }` and serializes
|
|
11268
|
+
* identically — with one thing more: it refuses a set that is not a font set,
|
|
11269
|
+
* at definition, so a field called a font cannot end up offering PDFs. What the
|
|
11270
|
+
* Studio does with it (a specimen in its parent, the set to pick from when
|
|
11271
|
+
* opened) it does for any file field backed by a font set.
|
|
11272
|
+
*/
|
|
11273
|
+
function font(fontsetModule) {
|
|
11274
|
+
assertFontset(fontsetModule);
|
|
11275
|
+
return file(fontsetModule);
|
|
11276
|
+
}
|
|
11277
|
+
|
|
11278
|
+
/** `s.font()` with `.remote()` applied: see `files.remote` in `initSchema`. */
|
|
11279
|
+
function remoteFont(fontsetModule) {
|
|
11280
|
+
assertFontset(fontsetModule);
|
|
11281
|
+
return remoteFile(fontsetModule);
|
|
11282
|
+
}
|
|
11283
|
+
function assertFontset(fontsetModule) {
|
|
11284
|
+
var _getSchema;
|
|
11285
|
+
var modulePath = getValPath(fontsetModule);
|
|
11286
|
+
var serialized = (_getSchema = getSchema(fontsetModule)) === null || _getSchema === void 0 ? void 0 : _getSchema["executeSerialize"]();
|
|
11287
|
+
var accept = (serialized === null || serialized === void 0 ? void 0 : serialized.type) === "record" && serialized.mediaType === "files" ? serialized.accept : undefined;
|
|
11288
|
+
var isFontset = !!accept && accept.split(",").every(function (type) {
|
|
11289
|
+
return isFontMimeType(type.trim());
|
|
11290
|
+
});
|
|
11291
|
+
if (!isFontset) {
|
|
11292
|
+
throw new Error("s.font(".concat(modulePath !== null && modulePath !== void 0 ? modulePath : "?", "): the module must be an s.fontdir(). Use s.file() to pick from a set of other files."));
|
|
11293
|
+
}
|
|
11294
|
+
}
|
|
11295
|
+
|
|
11101
11296
|
/**
|
|
11102
11297
|
* Turn an upload into an HLS stream, in the browser, before it is uploaded.
|
|
11103
11298
|
*
|
|
@@ -11633,7 +11828,7 @@ function stripQuery(path) {
|
|
|
11633
11828
|
}
|
|
11634
11829
|
|
|
11635
11830
|
/**
|
|
11636
|
-
* A video picked from a set (`s.
|
|
11831
|
+
* A video picked from a set (`s.videodir()`). What is true of the file —
|
|
11637
11832
|
* its type, size and length — lives in the set; the field carries what one
|
|
11638
11833
|
* page chose about it.
|
|
11639
11834
|
*/
|
|
@@ -11668,7 +11863,7 @@ function videoOf(options, galleryOptions) {
|
|
|
11668
11863
|
var setSchema = (_options$GetSchema = options[GetSchema]) === null || _options$GetSchema === void 0 ? void 0 : _options$GetSchema["executeSerialize"]();
|
|
11669
11864
|
if ((setSchema === null || setSchema === void 0 ? void 0 : setSchema.type) !== "record" || setSchema.mediaType !== "videos") {
|
|
11670
11865
|
var _setSchema$mediaType, _setSchema$type;
|
|
11671
|
-
throw new Error("s.video(".concat(modulePath, "): the module must be an s.
|
|
11866
|
+
throw new Error("s.video(".concat(modulePath, "): the module must be an s.videodir(). Got ").concat((setSchema === null || setSchema === void 0 ? void 0 : setSchema.type) === "record" ? "a record of ".concat((_setSchema$mediaType = setSchema.mediaType) !== null && _setSchema$mediaType !== void 0 ? _setSchema$mediaType : "values") : (_setSchema$type = setSchema === null || setSchema === void 0 ? void 0 : setSchema.type) !== null && _setSchema$type !== void 0 ? _setSchema$type : "no schema", "."));
|
|
11672
11867
|
}
|
|
11673
11868
|
return new VideoSchema((galleryOptions === null || galleryOptions === void 0 ? void 0 : galleryOptions.stream) !== undefined ? {
|
|
11674
11869
|
stream: galleryOptions.stream
|
|
@@ -11683,23 +11878,37 @@ function isVideosetModule(value) {
|
|
|
11683
11878
|
}
|
|
11684
11879
|
|
|
11685
11880
|
/**
|
|
11686
|
-
* Options for s.
|
|
11881
|
+
* Options for `s.filedir(dir, options)`: everything but the directory, which
|
|
11882
|
+
* is the first argument.
|
|
11883
|
+
*/
|
|
11884
|
+
|
|
11885
|
+
/**
|
|
11886
|
+
* Options for the deprecated `s.fileset(options)`, which took the directory
|
|
11887
|
+
* as `dir`.
|
|
11888
|
+
*
|
|
11889
|
+
* @deprecated Use `s.filedir(dir, options)` and `FiledirOptions`.
|
|
11687
11890
|
*/
|
|
11688
11891
|
|
|
11689
11892
|
/**
|
|
11690
11893
|
* Metadata for a file entry in the files record
|
|
11691
11894
|
*/
|
|
11692
11895
|
|
|
11896
|
+
/** @deprecated Use `FiledirEntryMetadata`. */
|
|
11897
|
+
|
|
11898
|
+
/** @deprecated Use `SerializedFiledirSchema`. */
|
|
11899
|
+
|
|
11693
11900
|
/**
|
|
11694
|
-
* Define a
|
|
11901
|
+
* Define a directory of files: a whole module that holds many files, keyed by
|
|
11902
|
+
* their file path, that fields pick from with `s.file(filesVal)`.
|
|
11695
11903
|
*
|
|
11696
|
-
*
|
|
11904
|
+
* The directory is the first argument and is required — it decides where
|
|
11905
|
+
* uploads land. Remote is off by default: call `.remote()` on the result to
|
|
11906
|
+
* allow remote files.
|
|
11697
11907
|
*
|
|
11698
11908
|
* @example
|
|
11699
11909
|
* ```typescript
|
|
11700
|
-
* const schema = s.
|
|
11910
|
+
* const schema = s.filedir("/public/val/documents", {
|
|
11701
11911
|
* accept: "application/pdf",
|
|
11702
|
-
* dir: "/public/val/documents",
|
|
11703
11912
|
* });
|
|
11704
11913
|
* export default c.define("/content/documents.val.ts", schema, {
|
|
11705
11914
|
* "/public/val/documents/report.pdf": {
|
|
@@ -11708,8 +11917,7 @@ function isVideosetModule(value) {
|
|
|
11708
11917
|
* });
|
|
11709
11918
|
* ```
|
|
11710
11919
|
*/
|
|
11711
|
-
var
|
|
11712
|
-
var dir = options.dir;
|
|
11920
|
+
var filedir = function filedir(dir, options) {
|
|
11713
11921
|
var itemSchema = new ObjectSchema({
|
|
11714
11922
|
mimeType: new StringSchema({}, false)
|
|
11715
11923
|
}, false);
|
|
@@ -11721,6 +11929,91 @@ var fileset = function fileset(options) {
|
|
|
11721
11929
|
});
|
|
11722
11930
|
};
|
|
11723
11931
|
|
|
11932
|
+
/**
|
|
11933
|
+
* Define a collection of files.
|
|
11934
|
+
*
|
|
11935
|
+
* @deprecated Use `s.filedir(dir, options)`: the directory moved out of the
|
|
11936
|
+
* options and into the first argument, and nothing else changed.
|
|
11937
|
+
*
|
|
11938
|
+
* @example
|
|
11939
|
+
* ```typescript
|
|
11940
|
+
* // was: s.fileset({ dir: "/public/val/documents", accept: "application/pdf" })
|
|
11941
|
+
* const schema = s.filedir("/public/val/documents", {
|
|
11942
|
+
* accept: "application/pdf",
|
|
11943
|
+
* });
|
|
11944
|
+
* ```
|
|
11945
|
+
*/
|
|
11946
|
+
var fileset = function fileset(options) {
|
|
11947
|
+
return filedir(options.dir, options);
|
|
11948
|
+
};
|
|
11949
|
+
|
|
11950
|
+
/**
|
|
11951
|
+
* Options for `s.fontdir(dir, options)`: everything but the directory, which
|
|
11952
|
+
* is the first argument.
|
|
11953
|
+
*/
|
|
11954
|
+
|
|
11955
|
+
/**
|
|
11956
|
+
* Options for the deprecated `s.fontset(options)`, which took the directory
|
|
11957
|
+
* as `dir`.
|
|
11958
|
+
*
|
|
11959
|
+
* @deprecated Use `s.fontdir(dir, options)` and `FontdirOptions`.
|
|
11960
|
+
*/
|
|
11961
|
+
|
|
11962
|
+
/**
|
|
11963
|
+
* Define a directory of fonts.
|
|
11964
|
+
*
|
|
11965
|
+
* A fontdir IS a filedir — the same source, the same `s.font(fontsVal)` field
|
|
11966
|
+
* to pick from it, the same checks and fixes — with `accept` defaulting to the
|
|
11967
|
+
* web font formats. What a font gets that any other file does not is decided
|
|
11968
|
+
* by its mime type rather than by the directory: the Studio previews any file
|
|
11969
|
+
* it knows is a font, wherever it is shown.
|
|
11970
|
+
*
|
|
11971
|
+
* Remote is off by default: call `.remote()` on the result to allow remote files.
|
|
11972
|
+
*
|
|
11973
|
+
* @example
|
|
11974
|
+
* ```typescript
|
|
11975
|
+
* const schema = s.fontdir("/public/val/fonts");
|
|
11976
|
+
* export default c.define("/content/fonts.val.ts", schema, {
|
|
11977
|
+
* "/public/val/fonts/inter_a1b2c.woff2": {
|
|
11978
|
+
* mimeType: "font/woff2",
|
|
11979
|
+
* },
|
|
11980
|
+
* });
|
|
11981
|
+
* ```
|
|
11982
|
+
*/
|
|
11983
|
+
var fontdir = function fontdir(dir, options) {
|
|
11984
|
+
var _options$accept;
|
|
11985
|
+
var accept = (_options$accept = options === null || options === void 0 ? void 0 : options.accept) !== null && _options$accept !== void 0 ? _options$accept : DEFAULT_FONT_ACCEPT;
|
|
11986
|
+
var notFonts = accept.split(",").map(function (type) {
|
|
11987
|
+
return type.trim();
|
|
11988
|
+
}).filter(function (type) {
|
|
11989
|
+
return !isFontMimeType(type);
|
|
11990
|
+
});
|
|
11991
|
+
if (notFonts.length > 0) {
|
|
11992
|
+
// A fontdir that took a PDF would be a filedir under a name that says
|
|
11993
|
+
// otherwise, and the Studio would draw a specimen of nothing.
|
|
11994
|
+
throw new Error("s.fontdir(): 'accept' may only name font types (font/woff2, font/woff, font/ttf, font/otf or font/*). Got: ".concat(notFonts.join(", "), ". Use s.filedir() for other files."));
|
|
11995
|
+
}
|
|
11996
|
+
return filedir(dir, {
|
|
11997
|
+
accept: accept
|
|
11998
|
+
});
|
|
11999
|
+
};
|
|
12000
|
+
|
|
12001
|
+
/**
|
|
12002
|
+
* Define a collection of fonts.
|
|
12003
|
+
*
|
|
12004
|
+
* @deprecated Use `s.fontdir(dir, options)`: the directory moved out of the
|
|
12005
|
+
* options and into the first argument, and nothing else changed.
|
|
12006
|
+
*
|
|
12007
|
+
* @example
|
|
12008
|
+
* ```typescript
|
|
12009
|
+
* // was: s.fontset({ dir: "/public/val/fonts" })
|
|
12010
|
+
* const schema = s.fontdir("/public/val/fonts");
|
|
12011
|
+
* ```
|
|
12012
|
+
*/
|
|
12013
|
+
var fontset = function fontset(options) {
|
|
12014
|
+
return fontdir(options.dir, options);
|
|
12015
|
+
};
|
|
12016
|
+
|
|
11724
12017
|
var DateSchema = /*#__PURE__*/function (_Schema) {
|
|
11725
12018
|
function DateSchema(options) {
|
|
11726
12019
|
var _this;
|
|
@@ -12587,39 +12880,58 @@ function router(router, keyOrItem, maybeItem) {
|
|
|
12587
12880
|
/** Every `alt` value any `AltSchema` can produce. */
|
|
12588
12881
|
|
|
12589
12882
|
/**
|
|
12590
|
-
* Options for s.
|
|
12883
|
+
* Options for `s.imagedir(dir, options)`: everything but the directory, which
|
|
12884
|
+
* is the first argument.
|
|
12885
|
+
*/
|
|
12886
|
+
|
|
12887
|
+
/**
|
|
12888
|
+
* Options for the deprecated `s.imageset(options)`, which took the directory
|
|
12889
|
+
* as `dir`.
|
|
12890
|
+
*
|
|
12891
|
+
* @deprecated Use `s.imagedir(dir, options)` and `ImagedirOptions`.
|
|
12591
12892
|
*/
|
|
12592
12893
|
|
|
12593
12894
|
/**
|
|
12594
12895
|
* `alt` is optional only when it is the default schema.
|
|
12595
12896
|
*
|
|
12596
12897
|
* Naming a different `Alt` and then leaving `alt` out would make the fallback
|
|
12597
|
-
* in `
|
|
12898
|
+
* in `imagedir()` a lie — `Alt` would say `s.string()` while the value was a
|
|
12598
12899
|
* nullable one. Requiring it in that case is what makes the fallback sound:
|
|
12599
12900
|
* the branch that uses it is reachable only when `Alt` IS the default.
|
|
12600
12901
|
*/
|
|
12601
12902
|
|
|
12903
|
+
/**
|
|
12904
|
+
* The options argument of `s.imagedir()`: optional only when `alt` is, for
|
|
12905
|
+
* the reason `ImagedirAltOption` gives — leaving the whole object out leaves
|
|
12906
|
+
* `alt` out with it.
|
|
12907
|
+
*/
|
|
12908
|
+
|
|
12602
12909
|
/**
|
|
12603
12910
|
* Metadata for an image entry in the images record.
|
|
12604
12911
|
*
|
|
12605
12912
|
* `alt` follows the schema's `alt` option, so it defaults to `string | null`
|
|
12606
12913
|
* and becomes `string` under `s.string()` or `Record<string, string>` under
|
|
12607
|
-
* `s.record(s.string())`. Write `
|
|
12914
|
+
* `s.record(s.string())`. Write `ImagedirEntryMetadata<AltSource>` where a
|
|
12608
12915
|
* gallery of any alt shape is acceptable.
|
|
12609
12916
|
*/
|
|
12610
12917
|
|
|
12918
|
+
/** @deprecated Use `ImagedirEntryMetadata`. */
|
|
12919
|
+
|
|
12920
|
+
/** @deprecated Use `SerializedImagedirSchema`. */
|
|
12921
|
+
|
|
12611
12922
|
/**
|
|
12612
|
-
* Define a
|
|
12923
|
+
* Define a directory of images: a whole module that holds many images, keyed
|
|
12924
|
+
* by their file path, that fields pick from with `s.image(galleryVal)`.
|
|
12613
12925
|
*
|
|
12614
|
-
*
|
|
12615
|
-
* to be inferred. The rest defaults: any
|
|
12616
|
-
*
|
|
12926
|
+
* The directory is the first argument and is required — it decides where
|
|
12927
|
+
* uploads land, so it is not something to be inferred. The rest defaults: any
|
|
12928
|
+
* image type (`"image/*"`), nullable alt text, remote disabled. Call
|
|
12929
|
+
* `.remote()` on the result to allow remote images.
|
|
12617
12930
|
*
|
|
12618
12931
|
* @example
|
|
12619
12932
|
* ```typescript
|
|
12620
|
-
* const schema = s.
|
|
12933
|
+
* const schema = s.imagedir("/public/val/images", {
|
|
12621
12934
|
* accept: "image/webp",
|
|
12622
|
-
* dir: "/public/val/images",
|
|
12623
12935
|
* alt: s.string().minLength(4),
|
|
12624
12936
|
* });
|
|
12625
12937
|
* export default c.define("/content/images.val.ts", schema, {
|
|
@@ -12632,19 +12944,26 @@ function router(router, keyOrItem, maybeItem) {
|
|
|
12632
12944
|
* });
|
|
12633
12945
|
* ```
|
|
12634
12946
|
*/
|
|
12635
|
-
var
|
|
12947
|
+
var imagedir = function imagedir(dir) {
|
|
12948
|
+
for (var _len = arguments.length, _ref = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
12949
|
+
_ref[_key - 1] = arguments[_key];
|
|
12950
|
+
}
|
|
12951
|
+
var options = _ref[0];
|
|
12952
|
+
return imagedirOf(dir, options);
|
|
12953
|
+
};
|
|
12954
|
+
function imagedirOf(dir, options) {
|
|
12636
12955
|
var _options$alt, _options$accept;
|
|
12637
|
-
|
|
12638
|
-
// `options.alt` is `Alt | undefined`, and the fallback is exactly the schema
|
|
12956
|
+
// `options?.alt` is `Alt | undefined`, and the fallback is exactly the schema
|
|
12639
12957
|
// `Alt` defaults to when `alt` is omitted. TypeScript will not narrow a type
|
|
12640
12958
|
// parameter from the absence of a value, so it cannot see that the two agree,
|
|
12641
12959
|
// and the fallback is asserted here.
|
|
12642
12960
|
//
|
|
12643
|
-
// Sound, not merely convenient: `
|
|
12644
|
-
// unless `Alt` is the default,
|
|
12961
|
+
// Sound, not merely convenient: `ImagedirAltOption` makes `alt` REQUIRED
|
|
12962
|
+
// unless `Alt` is the default, and `ImagedirOptionsArg` makes the options
|
|
12963
|
+
// object required with it, so this branch is unreachable for any other
|
|
12645
12964
|
// `Alt`. The one assertion in this file, and it replaces the wider one that
|
|
12646
12965
|
// used to sit on the ObjectSchema below.
|
|
12647
|
-
var altSchema = (_options$alt = options.alt) !== null && _options$alt !== void 0 ? _options$alt : string().nullable();
|
|
12966
|
+
var altSchema = (_options$alt = options === null || options === void 0 ? void 0 : options.alt) !== null && _options$alt !== void 0 ? _options$alt : string().nullable();
|
|
12648
12967
|
var itemSchema = new ObjectSchema({
|
|
12649
12968
|
width: new NumberSchema(undefined, false),
|
|
12650
12969
|
height: new NumberSchema(undefined, false),
|
|
@@ -12653,19 +12972,57 @@ var imageset = function imageset(options) {
|
|
|
12653
12972
|
}, false);
|
|
12654
12973
|
return new RecordSchema(itemSchema, false, [], null, null, {
|
|
12655
12974
|
type: "images",
|
|
12656
|
-
accept: (_options$accept = options.accept) !== null && _options$accept !== void 0 ? _options$accept : "image/*",
|
|
12975
|
+
accept: (_options$accept = options === null || options === void 0 ? void 0 : options.accept) !== null && _options$accept !== void 0 ? _options$accept : "image/*",
|
|
12657
12976
|
dir: dir,
|
|
12658
12977
|
remote: false,
|
|
12659
12978
|
altSchema: altSchema,
|
|
12660
|
-
encode: options.encode
|
|
12979
|
+
encode: options === null || options === void 0 ? void 0 : options.encode
|
|
12661
12980
|
});
|
|
12981
|
+
}
|
|
12982
|
+
|
|
12983
|
+
/**
|
|
12984
|
+
* `s.imagedir()` with `.remote()` applied: what `s.imagedir` is under
|
|
12985
|
+
* `files: { remote: true }`.
|
|
12986
|
+
*/
|
|
12987
|
+
var remoteImagedir = function remoteImagedir(dir) {
|
|
12988
|
+
for (var _len2 = arguments.length, _ref2 = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
12989
|
+
_ref2[_key2 - 1] = arguments[_key2];
|
|
12990
|
+
}
|
|
12991
|
+
var options = _ref2[0];
|
|
12992
|
+
return imagedirOf(dir, options).remote();
|
|
12662
12993
|
};
|
|
12663
12994
|
|
|
12664
12995
|
/**
|
|
12665
|
-
*
|
|
12996
|
+
* Define a collection of images.
|
|
12997
|
+
*
|
|
12998
|
+
* @deprecated Use `s.imagedir(dir, options)`: the directory moved out of the
|
|
12999
|
+
* options and into the first argument, and nothing else changed.
|
|
13000
|
+
*
|
|
13001
|
+
* @example
|
|
13002
|
+
* ```typescript
|
|
13003
|
+
* // was: s.imageset({ dir: "/public/val/images", accept: "image/webp" })
|
|
13004
|
+
* const schema = s.imagedir("/public/val/images", { accept: "image/webp" });
|
|
13005
|
+
* ```
|
|
12666
13006
|
*/
|
|
13007
|
+
var imageset = function imageset(options) {
|
|
13008
|
+
return imagedirOf(options.dir, options);
|
|
13009
|
+
};
|
|
12667
13010
|
|
|
12668
|
-
/**
|
|
13011
|
+
/**
|
|
13012
|
+
* Options for `s.videodir(dir, options)`: everything but the directory, which
|
|
13013
|
+
* is the first argument.
|
|
13014
|
+
*/
|
|
13015
|
+
|
|
13016
|
+
/**
|
|
13017
|
+
* Options for the deprecated `s.videoset(options)`, which took the directory
|
|
13018
|
+
* as `dir`.
|
|
13019
|
+
*
|
|
13020
|
+
* @deprecated Use `s.videodir(dir, options)` and `VideodirOptions`.
|
|
13021
|
+
*/
|
|
13022
|
+
|
|
13023
|
+
/** See `ImagedirAltOption`: `alt` is optional only when it is the default. */
|
|
13024
|
+
|
|
13025
|
+
/** See `ImagedirOptionsArg`: the options are optional only when `alt` is. */
|
|
12669
13026
|
|
|
12670
13027
|
/**
|
|
12671
13028
|
* One video of a set, keyed by its file path (an HLS stream by its master
|
|
@@ -12683,19 +13040,22 @@ var imageset = function imageset(options) {
|
|
|
12683
13040
|
* still for the gallery, because two stills of one video would disagree.
|
|
12684
13041
|
*/
|
|
12685
13042
|
|
|
13043
|
+
/** @deprecated Use `VideodirEntryMetadata`. */
|
|
13044
|
+
|
|
13045
|
+
/** @deprecated Use `SerializedVideodirSchema`. */
|
|
13046
|
+
|
|
12686
13047
|
/**
|
|
12687
|
-
* Define a
|
|
13048
|
+
* Define a directory of videos — the video twin of `s.imagedir()`.
|
|
12688
13049
|
*
|
|
12689
13050
|
* A field picks from it with `s.video(videosVal)`. An entry may hold the
|
|
12690
13051
|
* description, poster, start and end, focal point and captions as defaults,
|
|
12691
13052
|
* and a field overrides any of them by setting its own. Uploading in such a
|
|
12692
|
-
* field adds to the
|
|
12693
|
-
*
|
|
13053
|
+
* field adds to the directory. Call `.remote()` on the result to store the
|
|
13054
|
+
* videos on Val Remote.
|
|
12694
13055
|
*
|
|
12695
13056
|
* @example
|
|
12696
13057
|
* ```typescript
|
|
12697
|
-
* const schema = s.
|
|
12698
|
-
* dir: "/public/val/videos",
|
|
13058
|
+
* const schema = s.videodir("/public/val/videos", {
|
|
12699
13059
|
* stream: { type: "hls" },
|
|
12700
13060
|
* });
|
|
12701
13061
|
* export default c.define("/content/videos.val.ts", schema, {
|
|
@@ -12710,11 +13070,46 @@ var imageset = function imageset(options) {
|
|
|
12710
13070
|
* });
|
|
12711
13071
|
* ```
|
|
12712
13072
|
*/
|
|
13073
|
+
var videodir = function videodir(dir) {
|
|
13074
|
+
for (var _len = arguments.length, _ref = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
13075
|
+
_ref[_key - 1] = arguments[_key];
|
|
13076
|
+
}
|
|
13077
|
+
var options = _ref[0];
|
|
13078
|
+
return videodirOf(dir, options);
|
|
13079
|
+
};
|
|
13080
|
+
|
|
13081
|
+
/**
|
|
13082
|
+
* `s.videodir()` with `.remote()` applied: what `s.videodir` is under
|
|
13083
|
+
* `files: { remote: true }`.
|
|
13084
|
+
*/
|
|
13085
|
+
var remoteVideodir = function remoteVideodir(dir) {
|
|
13086
|
+
for (var _len2 = arguments.length, _ref2 = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
13087
|
+
_ref2[_key2 - 1] = arguments[_key2];
|
|
13088
|
+
}
|
|
13089
|
+
var options = _ref2[0];
|
|
13090
|
+
return videodirOf(dir, options).remote();
|
|
13091
|
+
};
|
|
13092
|
+
|
|
13093
|
+
/**
|
|
13094
|
+
* Define a collection of videos.
|
|
13095
|
+
*
|
|
13096
|
+
* @deprecated Use `s.videodir(dir, options)`: the directory moved out of the
|
|
13097
|
+
* options and into the first argument, and nothing else changed.
|
|
13098
|
+
*
|
|
13099
|
+
* @example
|
|
13100
|
+
* ```typescript
|
|
13101
|
+
* // was: s.videoset({ dir: "/public/val/videos", stream: { type: "hls" } })
|
|
13102
|
+
* const schema = s.videodir("/public/val/videos", { stream: { type: "hls" } });
|
|
13103
|
+
* ```
|
|
13104
|
+
*/
|
|
12713
13105
|
var videoset = function videoset(options) {
|
|
13106
|
+
return videodirOf(options.dir, options);
|
|
13107
|
+
};
|
|
13108
|
+
function videodirOf(dir, options) {
|
|
12714
13109
|
var _options$alt, _options$accept;
|
|
12715
|
-
// The same assertion as in `
|
|
12716
|
-
// `
|
|
12717
|
-
var altSchema = (_options$alt = options.alt) !== null && _options$alt !== void 0 ? _options$alt : string().nullable();
|
|
13110
|
+
// The same assertion as in `imagedir()`, and sound for the same reason:
|
|
13111
|
+
// `VideodirAltOption` makes `alt` required unless `Alt` is the default.
|
|
13112
|
+
var altSchema = (_options$alt = options === null || options === void 0 ? void 0 : options.alt) !== null && _options$alt !== void 0 ? _options$alt : string().nullable();
|
|
12718
13113
|
var itemSchema = new ObjectSchema({
|
|
12719
13114
|
mimeType: new StringSchema({}, false),
|
|
12720
13115
|
width: new NumberSchema(undefined, false),
|
|
@@ -12724,13 +13119,13 @@ var videoset = function videoset(options) {
|
|
|
12724
13119
|
}, false);
|
|
12725
13120
|
return new RecordSchema(itemSchema, false, [], null, null, {
|
|
12726
13121
|
type: "videos",
|
|
12727
|
-
accept: (_options$accept = options.accept) !== null && _options$accept !== void 0 ? _options$accept : DEFAULT_VIDEO_ACCEPT,
|
|
12728
|
-
dir:
|
|
13122
|
+
accept: (_options$accept = options === null || options === void 0 ? void 0 : options.accept) !== null && _options$accept !== void 0 ? _options$accept : DEFAULT_VIDEO_ACCEPT,
|
|
13123
|
+
dir: dir,
|
|
12729
13124
|
remote: false,
|
|
12730
13125
|
altSchema: altSchema,
|
|
12731
|
-
stream: options.stream
|
|
13126
|
+
stream: options === null || options === void 0 ? void 0 : options.stream
|
|
12732
13127
|
});
|
|
12733
|
-
}
|
|
13128
|
+
}
|
|
12734
13129
|
|
|
12735
13130
|
/**
|
|
12736
13131
|
* The video schema a set's entry is hashed against, for a remote ref.
|
|
@@ -12766,24 +13161,42 @@ function initSchema(options) {
|
|
|
12766
13161
|
var media = (options === null || options === void 0 ? void 0 : options.remote) === true ? {
|
|
12767
13162
|
image: remoteImage,
|
|
12768
13163
|
file: remoteFile,
|
|
13164
|
+
font: remoteFont,
|
|
12769
13165
|
video: remoteVideo,
|
|
12770
13166
|
richtext: remoteRichtext,
|
|
13167
|
+
imagedir: remoteImagedir,
|
|
13168
|
+
filedir: function (dir, options) {
|
|
13169
|
+
return filedir(dir, options).remote();
|
|
13170
|
+
},
|
|
13171
|
+
fontdir: function (dir, options) {
|
|
13172
|
+
return fontdir(dir, options).remote();
|
|
13173
|
+
},
|
|
13174
|
+
videodir: remoteVideodir,
|
|
12771
13175
|
imageset: function (options) {
|
|
12772
13176
|
return imageset(options).remote();
|
|
12773
13177
|
},
|
|
12774
13178
|
fileset: function (options) {
|
|
12775
13179
|
return fileset(options).remote();
|
|
12776
13180
|
},
|
|
13181
|
+
fontset: function (options) {
|
|
13182
|
+
return fontset(options).remote();
|
|
13183
|
+
},
|
|
12777
13184
|
videoset: function (options) {
|
|
12778
13185
|
return videoset(options).remote();
|
|
12779
13186
|
}
|
|
12780
13187
|
} : {
|
|
12781
13188
|
image: image,
|
|
12782
13189
|
file: file,
|
|
13190
|
+
font: font,
|
|
12783
13191
|
video: video,
|
|
12784
13192
|
richtext: richtext,
|
|
13193
|
+
imagedir: imagedir,
|
|
13194
|
+
filedir: filedir,
|
|
13195
|
+
fontdir: fontdir,
|
|
13196
|
+
videodir: videodir,
|
|
12785
13197
|
imageset: imageset,
|
|
12786
13198
|
fileset: fileset,
|
|
13199
|
+
fontset: fontset,
|
|
12787
13200
|
videoset: videoset
|
|
12788
13201
|
};
|
|
12789
13202
|
// locales: F.Narrow<Locales>
|
|
@@ -12804,8 +13217,12 @@ function initSchema(options) {
|
|
|
12804
13217
|
view: view,
|
|
12805
13218
|
record: record,
|
|
12806
13219
|
file: media.file,
|
|
13220
|
+
font: media.font,
|
|
12807
13221
|
video: media.video,
|
|
13222
|
+
filedir: media.filedir,
|
|
13223
|
+
fontdir: media.fontdir,
|
|
12808
13224
|
fileset: media.fileset,
|
|
13225
|
+
fontset: media.fontset,
|
|
12809
13226
|
date: date,
|
|
12810
13227
|
datetime: datetime,
|
|
12811
13228
|
color: color,
|
|
@@ -12813,6 +13230,8 @@ function initSchema(options) {
|
|
|
12813
13230
|
locale: locale,
|
|
12814
13231
|
route: route,
|
|
12815
13232
|
router: router,
|
|
13233
|
+
imagedir: media.imagedir,
|
|
13234
|
+
videodir: media.videodir,
|
|
12816
13235
|
imageset: media.imageset,
|
|
12817
13236
|
videoset: media.videoset,
|
|
12818
13237
|
settings: settings
|
|
@@ -13909,7 +14328,7 @@ function _extractValModules() {
|
|
|
13909
14328
|
* The one answer to that question. There used to be two — `hasRemoteFileSchema`
|
|
13910
14329
|
* in the server, gating whether `/save` demands remote credentials, and
|
|
13911
14330
|
* `findRequiredRemoteFiles` in the Studio, gating the `/remote/settings` fetch —
|
|
13912
|
-
* and they disagreed about `s.
|
|
14331
|
+
* and they disagreed about `s.imagedir(dir, { ... }).remote()`: the Studio's version
|
|
13913
14332
|
* counted a remote media record, the server's did not, because a media
|
|
13914
14333
|
* collection serializes as a `record` of metadata rather than as an image
|
|
13915
14334
|
* schema.
|
|
@@ -13949,7 +14368,7 @@ function hasRemoteFileSchema(schema) {
|
|
|
13949
14368
|
return hasRemoteFileSchema(schema.item);
|
|
13950
14369
|
} else if (schema.type === "record") {
|
|
13951
14370
|
/**
|
|
13952
|
-
* A media collection — `s.
|
|
14371
|
+
* A media collection — `s.imagedir()` / `s.filedir()` — is the case both of the
|
|
13953
14372
|
* old functions were written around, and the one they disagreed on.
|
|
13954
14373
|
*
|
|
13955
14374
|
* It has no file or image schema inside it to find: `item` is an object of
|
|
@@ -14009,8 +14428,8 @@ function hasRemoteFileSchema(schema) {
|
|
|
14009
14428
|
*
|
|
14010
14429
|
* It is a walk over the SERIALIZED schema for the reasons given above, and for
|
|
14011
14430
|
* one more that is specific to this question: the two cases most likely to be
|
|
14012
|
-
* missed are invisible to a value type. A media collection (`s.
|
|
14013
|
-
* `s.
|
|
14431
|
+
* missed are invisible to a value type. A media collection (`s.imagedir()` /
|
|
14432
|
+
* `s.filedir()`) serializes as a record of metadata with no image schema inside
|
|
14014
14433
|
* it, and a richtext inline image lives in a constructor argument. A check
|
|
14015
14434
|
* written against the item TYPE would silently pass both — and the gallery case
|
|
14016
14435
|
* already has a data-loss incident attached to it (see above).
|
|
@@ -14891,7 +15310,7 @@ function deserializeSchemaImpl(serialized) {
|
|
|
14891
15310
|
* `s.array(s.object({ tags: s.array(s.string()) })).render({ as: "inline" })`
|
|
14892
15311
|
* the objects are inline and `tags` keeps its own default.
|
|
14893
15312
|
*
|
|
14894
|
-
* Not available on `s.router(...)`, `s.
|
|
15313
|
+
* Not available on `s.router(...)`, `s.imagedir(...)` or `s.filedir(...)`:
|
|
14895
15314
|
* pages and media have UIs of their own, and `RecordSchema.render` throws there.
|
|
14896
15315
|
*
|
|
14897
15316
|
* On `s.keyOf(...)` the same value means something else: the selected entry's
|
|
@@ -15484,7 +15903,7 @@ function isPageRouter(routerId) {
|
|
|
15484
15903
|
|
|
15485
15904
|
var corePackageJson = {
|
|
15486
15905
|
name: "@valbuild/core",
|
|
15487
|
-
version: "0.
|
|
15906
|
+
version: "0.144.0",
|
|
15488
15907
|
"private": false,
|
|
15489
15908
|
description: "Val - supercharged hard-coded content",
|
|
15490
15909
|
repository: {
|
|
@@ -15590,6 +16009,7 @@ var Internal = {
|
|
|
15590
16009
|
fillFromGallery: fillFromGallery,
|
|
15591
16010
|
galleriesOf: galleriesOf,
|
|
15592
16011
|
galleryEntryOf: galleryEntryOf,
|
|
16012
|
+
galleryKeyOf: galleryKeyOf,
|
|
15593
16013
|
GALLERY_DEFAULT_GROUPS: GALLERY_DEFAULT_GROUPS,
|
|
15594
16014
|
isHlsVideo: isHlsVideo,
|
|
15595
16015
|
HLS_MIME_TYPE: HLS_MIME_TYPE
|
|
@@ -15654,6 +16074,9 @@ var Internal = {
|
|
|
15654
16074
|
mimeTypeMatchesAccept: mimeTypeMatchesAccept,
|
|
15655
16075
|
EXT_TO_MIME_TYPES: EXT_TO_MIME_TYPES,
|
|
15656
16076
|
MIME_TYPES_TO_EXT: MIME_TYPES_TO_EXT,
|
|
16077
|
+
FONT_MIME_TYPE_EXTENSIONS: FONT_MIME_TYPE_EXTENSIONS,
|
|
16078
|
+
isFontMimeType: isFontMimeType,
|
|
16079
|
+
sniffFontMimeType: sniffFontMimeType,
|
|
15657
16080
|
ModuleFilePathSep: ModuleFilePathSep,
|
|
15658
16081
|
notFileOp: function notFileOp(op) {
|
|
15659
16082
|
return op.op !== "file";
|
|
@@ -15715,6 +16138,7 @@ exports.ColorSchema = ColorSchema;
|
|
|
15715
16138
|
exports.DEFAULT_APP_HOST = DEFAULT_APP_HOST;
|
|
15716
16139
|
exports.DEFAULT_COLOR_FORMAT = DEFAULT_COLOR_FORMAT;
|
|
15717
16140
|
exports.DEFAULT_CONTENT_HOST = DEFAULT_CONTENT_HOST;
|
|
16141
|
+
exports.DEFAULT_FONT_ACCEPT = DEFAULT_FONT_ACCEPT;
|
|
15718
16142
|
exports.DEFAULT_STATIC_HOST = DEFAULT_STATIC_HOST;
|
|
15719
16143
|
exports.DEFAULT_VAL_REMOTE_HOST = DEFAULT_VAL_REMOTE_HOST;
|
|
15720
16144
|
exports.DEFAULT_VIDEO_ACCEPT = DEFAULT_VIDEO_ACCEPT;
|
|
@@ -15725,6 +16149,7 @@ exports.DateTimeSchema = DateTimeSchema;
|
|
|
15725
16149
|
exports.DiscriminatedUnionSchema = DiscriminatedUnionSchema;
|
|
15726
16150
|
exports.EnumSchema = EnumSchema;
|
|
15727
16151
|
exports.FATAL_ERROR_TYPES = FATAL_ERROR_TYPES;
|
|
16152
|
+
exports.FONT_MIME_TYPES = FONT_MIME_TYPES;
|
|
15728
16153
|
exports.FileSchema = FileSchema;
|
|
15729
16154
|
exports.GenericSelector = GenericSelector;
|
|
15730
16155
|
exports.ImageSchema = ImageSchema;
|