@valbuild/core 0.143.0 → 0.145.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 +60 -0
- package/dist/declarations/src/index.d.ts +16 -4
- package/dist/declarations/src/initSchema.d.ts +107 -26
- package/dist/declarations/src/initVal.d.ts +2 -2
- package/dist/declarations/src/mimeType/font.d.ts +2 -2
- package/dist/declarations/src/render.d.ts +39 -6
- 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 +4 -4
- 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/number.d.ts +45 -5
- package/dist/declarations/src/schema/numberRules.d.ts +27 -0
- 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-02a1ba06.esm.js → index-307b907e.esm.js} +601 -122
- package/dist/{index-46c72f01.cjs.prod.js → index-93763025.cjs.prod.js} +601 -122
- package/dist/{index-aac8c69c.cjs.dev.js → index-ee601322.cjs.dev.js} +601 -122
- package/dist/valbuild-core.cjs.dev.js +1 -1
- package/dist/valbuild-core.cjs.prod.js +1 -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
- package/dist/declarations/src/schema/fontset.d.ts +0 -40
|
@@ -2844,7 +2844,7 @@ var _excluded = ["poster", "captions"];
|
|
|
2844
2844
|
* What a video FIELD authors, on top of the file it names: the description,
|
|
2845
2845
|
* the crop, the poster, the trim and the caption tracks.
|
|
2846
2846
|
*
|
|
2847
|
-
* This is the whole value of a field picked from an `s.
|
|
2847
|
+
* This is the whole value of a field picked from an `s.videodir()`
|
|
2848
2848
|
* (`s.video(videosetVal)`) — the mime type, size and length live in the set,
|
|
2849
2849
|
* keyed by `path`, and repeating them here is how two copies of one fact get
|
|
2850
2850
|
* to disagree. The poster, captions and times stay with the FIELD: one video
|
|
@@ -2856,7 +2856,7 @@ var _excluded = ["poster", "captions"];
|
|
|
2856
2856
|
/**
|
|
2857
2857
|
* What one page chooses about a video — as opposed to what is true of the
|
|
2858
2858
|
* file. A field (`s.video()`) carries these for itself; the entry of a set
|
|
2859
|
-
* (`s.
|
|
2859
|
+
* (`s.videodir()`) carries them as DEFAULTS, which every field picked from the
|
|
2860
2860
|
* set starts from and may override key by key. See {@link fillFromGallery}.
|
|
2861
2861
|
*/
|
|
2862
2862
|
|
|
@@ -2998,6 +2998,42 @@ function isMediaSchema(schema) {
|
|
|
2998
2998
|
return _typeof(schema) === "object" && schema !== null && "type" in schema && (schema.type === "image" || schema.type === "file" || schema.type === "video");
|
|
2999
2999
|
}
|
|
3000
3000
|
|
|
3001
|
+
/**
|
|
3002
|
+
* The key of a gallery (an `s.imagedir()`, `s.filedir()` or `s.videodir()`)
|
|
3003
|
+
* that a field's `path` names, or `null` when it names none.
|
|
3004
|
+
*
|
|
3005
|
+
* Usually the path IS the key. It is not for an image uploaded THROUGH an
|
|
3006
|
+
* `s.image(remoteGallery)` field in the Studio, which stores the remote ref in
|
|
3007
|
+
* the field and keys the entry by the local path inside it — so a path that is
|
|
3008
|
+
* not a key falls back to that embedded path. Exact first, because a gallery
|
|
3009
|
+
* can hold both shapes for one file, and the field then names the entry that
|
|
3010
|
+
* IS its path.
|
|
3011
|
+
*
|
|
3012
|
+
* One implementation of the question, asked by everything that has to agree on
|
|
3013
|
+
* the answer: reading a field (`galleryEntryOf`), validating it (`ImageSchema`
|
|
3014
|
+
* and `FileSchema` ask whether the gallery has it), the Studio's reference
|
|
3015
|
+
* scans and renames, and `val validate --fix` when it renames a key and has to
|
|
3016
|
+
* find the fields that hold it.
|
|
3017
|
+
*
|
|
3018
|
+
* The embedded path is tried with its leading slash (how a key is written) and
|
|
3019
|
+
* without (how `splitRemoteRef` returns it).
|
|
3020
|
+
*/
|
|
3021
|
+
function galleryKeyOf(path, isKey) {
|
|
3022
|
+
if (isKey(path)) {
|
|
3023
|
+
return path;
|
|
3024
|
+
}
|
|
3025
|
+
var split = splitRemoteRef(path);
|
|
3026
|
+
if (split.status === "success") {
|
|
3027
|
+
for (var _i = 0, _arr = ["/".concat(split.filePath), split.filePath]; _i < _arr.length; _i++) {
|
|
3028
|
+
var embedded = _arr[_i];
|
|
3029
|
+
if (isKey(embedded)) {
|
|
3030
|
+
return embedded;
|
|
3031
|
+
}
|
|
3032
|
+
}
|
|
3033
|
+
}
|
|
3034
|
+
return null;
|
|
3035
|
+
}
|
|
3036
|
+
|
|
3001
3037
|
/**
|
|
3002
3038
|
* What a gallery entry holds as a DEFAULT for the fields picked from it, in
|
|
3003
3039
|
* the groups a field overrides together.
|
|
@@ -3017,7 +3053,9 @@ var GALLERY_FILE_FACTS = ["width", "height", "mimeType", "duration"];
|
|
|
3017
3053
|
* gallery-backed or the gallery has no such entry.
|
|
3018
3054
|
*
|
|
3019
3055
|
* The double lookup is load-bearing: a remote gallery keys its entries by the
|
|
3020
|
-
* remote URL while the file itself stays on disk under its local path
|
|
3056
|
+
* remote URL while the file itself stays on disk under its local path, and an
|
|
3057
|
+
* upload through the field does it the other way round (see
|
|
3058
|
+
* {@link galleryKeyOf}).
|
|
3021
3059
|
*/
|
|
3022
3060
|
function galleryEntryOf(src, schema, getModuleSource) {
|
|
3023
3061
|
if (!isMediaSchema(schema) || !schema.referencedModule) {
|
|
@@ -3027,13 +3065,9 @@ function galleryEntryOf(src, schema, getModuleSource) {
|
|
|
3027
3065
|
if (!isPlainObject(moduleSource)) {
|
|
3028
3066
|
return null;
|
|
3029
3067
|
}
|
|
3030
|
-
var key = src.path
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
if (splitRemoteRefRes.status === "success" && splitRemoteRefRes.filePath in moduleSource) {
|
|
3034
|
-
key = splitRemoteRefRes.filePath;
|
|
3035
|
-
}
|
|
3036
|
-
}
|
|
3068
|
+
var key = galleryKeyOf(src.path, function (candidate) {
|
|
3069
|
+
return candidate in moduleSource;
|
|
3070
|
+
});
|
|
3037
3071
|
if (key === null) {
|
|
3038
3072
|
return null;
|
|
3039
3073
|
}
|
|
@@ -3894,10 +3928,10 @@ function mimeTypeMatchesAccept(mimeType, accept) {
|
|
|
3894
3928
|
* asks the BYTES ({@link sniffFontMimeType}) rather than trusting the picker.
|
|
3895
3929
|
*/
|
|
3896
3930
|
|
|
3897
|
-
/** The formats `s.
|
|
3931
|
+
/** The formats `s.fontdir()` accepts unless told otherwise, best first. */
|
|
3898
3932
|
var FONT_MIME_TYPES = ["font/woff2", "font/woff", "font/ttf", "font/otf"];
|
|
3899
3933
|
|
|
3900
|
-
/** `s.
|
|
3934
|
+
/** `s.fontdir()`'s `accept` when none is given. */
|
|
3901
3935
|
var DEFAULT_FONT_ACCEPT = FONT_MIME_TYPES.join(",");
|
|
3902
3936
|
|
|
3903
3937
|
/**
|
|
@@ -4136,24 +4170,31 @@ var ImageSchema = /*#__PURE__*/function (_Schema) {
|
|
|
4136
4170
|
value: src
|
|
4137
4171
|
}]));
|
|
4138
4172
|
}
|
|
4173
|
+
// A field picked from a gallery holds the gallery's KEY, and whether that
|
|
4174
|
+
// key is a local path or a remote ref is the gallery's to decide — and its
|
|
4175
|
+
// to fix: uploading an entry renames its key, and the fields that hold it
|
|
4176
|
+
// with it. So such a field only asks whether the gallery has it, below.
|
|
4177
|
+
// Asking here as well reported every image picked from a `.remote()`
|
|
4178
|
+
// gallery as one to download, because the field itself is never remote.
|
|
4179
|
+
var galleryEntries = this.galleryEntries();
|
|
4139
4180
|
// Remote-ness is a property of the path, not of a marker on the value:
|
|
4140
4181
|
// anything outside /public is remote.
|
|
4141
4182
|
var isRemotePath = isRemoteMediaPath(src.path);
|
|
4142
|
-
if (this.isRemote && !isRemotePath) {
|
|
4183
|
+
if (!galleryEntries && this.isRemote && !isRemotePath) {
|
|
4143
4184
|
return _defineProperty({}, path, [].concat(_toConsumableArray(customValidationErrors), [{
|
|
4144
4185
|
message: "Expected a remote image, but got a local image.",
|
|
4145
4186
|
value: src,
|
|
4146
4187
|
fixes: ["image:upload-remote"]
|
|
4147
4188
|
}]));
|
|
4148
4189
|
}
|
|
4149
|
-
if (this.isRemote && isRemotePath) {
|
|
4190
|
+
if (!galleryEntries && this.isRemote && isRemotePath) {
|
|
4150
4191
|
return _defineProperty({}, path, [].concat(_toConsumableArray(customValidationErrors), [{
|
|
4151
4192
|
message: "Remote image was not checked.",
|
|
4152
4193
|
value: src,
|
|
4153
4194
|
fixes: ["image:check-remote"]
|
|
4154
4195
|
}]));
|
|
4155
4196
|
}
|
|
4156
|
-
if (!this.isRemote && isRemotePath) {
|
|
4197
|
+
if (!galleryEntries && !this.isRemote && isRemotePath) {
|
|
4157
4198
|
return _defineProperty({}, path, [].concat(_toConsumableArray(customValidationErrors), [{
|
|
4158
4199
|
message: "Expected local image, but found remote.",
|
|
4159
4200
|
value: src,
|
|
@@ -4168,7 +4209,6 @@ var ImageSchema = /*#__PURE__*/function (_Schema) {
|
|
|
4168
4209
|
}]));
|
|
4169
4210
|
}
|
|
4170
4211
|
}
|
|
4171
|
-
var galleryEntries = this.galleryEntries();
|
|
4172
4212
|
if (galleryEntries) {
|
|
4173
4213
|
// The dimensions and mime type of a gallery image are stored once, in the
|
|
4174
4214
|
// gallery. Repeating them on the field is how the two get to disagree.
|
|
@@ -4181,7 +4221,11 @@ var ImageSchema = /*#__PURE__*/function (_Schema) {
|
|
|
4181
4221
|
value: src
|
|
4182
4222
|
}]));
|
|
4183
4223
|
}
|
|
4184
|
-
|
|
4224
|
+
// The same match reading the field makes (`fillFromGallery`): the key,
|
|
4225
|
+
// or the local path inside a ref an upload through the field stored.
|
|
4226
|
+
if (galleryKeyOf(src.path, function (key) {
|
|
4227
|
+
return key in galleryEntries;
|
|
4228
|
+
}) === null) {
|
|
4185
4229
|
return _defineProperty({}, path, [].concat(_toConsumableArray(customValidationErrors), [{
|
|
4186
4230
|
message: "The gallery does not have an image at '".concat(src.path, "'."),
|
|
4187
4231
|
value: src
|
|
@@ -5798,7 +5842,7 @@ function missingDeclaredKeys(declared, present) {
|
|
|
5798
5842
|
/**
|
|
5799
5843
|
* The checks of what one page chose about a video — its times, focal point,
|
|
5800
5844
|
* poster and captions — shared by the two places those choices are made: a
|
|
5801
|
-
* field (`s.video()`) and the entry of a set (`s.
|
|
5845
|
+
* field (`s.video()`) and the entry of a set (`s.videodir()`), which holds the
|
|
5802
5846
|
* same choices as the defaults every field picked from it starts from.
|
|
5803
5847
|
*/
|
|
5804
5848
|
|
|
@@ -5976,7 +6020,25 @@ function isObject(value) {
|
|
|
5976
6020
|
return _typeof(value) === "object" && value !== null && !Array.isArray(value);
|
|
5977
6021
|
}
|
|
5978
6022
|
|
|
5979
|
-
/** What a media collection (`s.
|
|
6023
|
+
/** What a media collection (`s.imagedir`, `s.filedir`, `s.videodir`) holds. */
|
|
6024
|
+
|
|
6025
|
+
/**
|
|
6026
|
+
* Where a media collection keeps its files: the first argument of
|
|
6027
|
+
* `s.imagedir()`, `s.filedir()`, `s.fontdir()` and `s.videodir()`.
|
|
6028
|
+
*
|
|
6029
|
+
* Required, and deliberately so: it decides where every uploaded file in the
|
|
6030
|
+
* collection lands. It used to default to "/public/val", which meant a
|
|
6031
|
+
* collection that had simply not said where it wanted its files silently
|
|
6032
|
+
* shared a directory with every other one. It is the first argument rather
|
|
6033
|
+
* than an option because it is the one thing every collection has to say.
|
|
6034
|
+
*/
|
|
6035
|
+
|
|
6036
|
+
/** The factory that builds a media collection of each type, for messages. */
|
|
6037
|
+
var mediaDirFactory = {
|
|
6038
|
+
images: "imagedir",
|
|
6039
|
+
files: "filedir",
|
|
6040
|
+
videos: "videodir"
|
|
6041
|
+
};
|
|
5980
6042
|
|
|
5981
6043
|
/**
|
|
5982
6044
|
* The fix code a media collection of `type` reports for `check`.
|
|
@@ -6011,7 +6073,7 @@ function assertRenderable(router, mediaOptions, render) {
|
|
|
6011
6073
|
throw new Error("`.render(...)` is not supported on `s.router(...)`: a router's entries are pages, which have their own UI.");
|
|
6012
6074
|
}
|
|
6013
6075
|
if (mediaOptions) {
|
|
6014
|
-
throw new Error("`.render(...)` is not supported on `s.".concat(mediaOptions.type
|
|
6076
|
+
throw new Error("`.render(...)` is not supported on `s.".concat(mediaDirFactory[mediaOptions.type], "(...)`: media galleries have their own UI."));
|
|
6015
6077
|
}
|
|
6016
6078
|
}
|
|
6017
6079
|
|
|
@@ -6728,7 +6790,7 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
6728
6790
|
* Allow the files in this gallery to be stored on Val's remote content host
|
|
6729
6791
|
* instead of in your repository.
|
|
6730
6792
|
*
|
|
6731
|
-
* For `s.
|
|
6793
|
+
* For `s.imagedir()` and `s.filedir()`, which are records of media. Remote is off
|
|
6732
6794
|
* until this is called.
|
|
6733
6795
|
*
|
|
6734
6796
|
* Each entry is then keyed by its URL on the content host rather than by a
|
|
@@ -6737,7 +6799,7 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
6737
6799
|
* upload it and rewrite the key.
|
|
6738
6800
|
*
|
|
6739
6801
|
* @example
|
|
6740
|
-
* const schema = s.
|
|
6802
|
+
* const schema = s.imagedir("/public/val/images").remote();
|
|
6741
6803
|
* export default c.define("/content/images.val.ts", schema, {
|
|
6742
6804
|
* "https://remote.val.build/file/p/my-project/b/01/v/1.0.0/h/8f2a1c/f/3b9d70/p/public/val/images/hero.webp":
|
|
6743
6805
|
* {
|
|
@@ -6763,7 +6825,7 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
6763
6825
|
* which lets the runtime, the Studio and validation work one entry at a time
|
|
6764
6826
|
* so a record/router can scale to many thousands of entries.
|
|
6765
6827
|
*
|
|
6766
|
-
* Not supported on image/file galleries (`s.
|
|
6828
|
+
* Not supported on image/file galleries (`s.imagedir()` / `s.filedir()`).
|
|
6767
6829
|
*
|
|
6768
6830
|
* Only supported on a module's ROOT record/router — a `.jsonValues()` record
|
|
6769
6831
|
* nested inside an object/array/record is rejected at startup with a module
|
|
@@ -6788,7 +6850,7 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
6788
6850
|
key: "jsonValues",
|
|
6789
6851
|
value: function jsonValues() {
|
|
6790
6852
|
if (this.mediaOptions) {
|
|
6791
|
-
throw new Error(".jsonValues() cannot be used with image/file galleries (s.
|
|
6853
|
+
throw new Error(".jsonValues() cannot be used with image/file galleries (s.imagedir()/s.filedir())");
|
|
6792
6854
|
}
|
|
6793
6855
|
if (this.customValidateFunctions.length > 0) {
|
|
6794
6856
|
// `.jsonValues()` changes the source shape to JsonSource entries, so a
|
|
@@ -6817,7 +6879,7 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
6817
6879
|
* bucket — instead of in the module.
|
|
6818
6880
|
*
|
|
6819
6881
|
* Available on every record-derived schema, which is `s.record()`,
|
|
6820
|
-
* `s.router()`, `s.
|
|
6882
|
+
* `s.router()`, `s.imagedir()` and `s.filedir()` alike: a router is a
|
|
6821
6883
|
* `RecordSchema` with a `ValRouter`, a gallery one with media options, so all
|
|
6822
6884
|
* four get external storage from this one method.
|
|
6823
6885
|
*
|
|
@@ -7147,7 +7209,7 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
7147
7209
|
* draws each entry's own editor in place, labelled by its key, instead of a
|
|
7148
7210
|
* preview row that navigates to it. It reaches the direct entries only.
|
|
7149
7211
|
*
|
|
7150
|
-
* Not for `s.router(...)`, `s.
|
|
7212
|
+
* Not for `s.router(...)`, `s.imagedir(...)` or `s.filedir(...)`: pages and
|
|
7151
7213
|
* media have UIs of their own, so this throws on them.
|
|
7152
7214
|
*
|
|
7153
7215
|
* Static configuration, not a callback — see `render.ts`.
|
|
@@ -10123,6 +10185,87 @@ function patchPathToModulePath(patchPath) {
|
|
|
10123
10185
|
}).join(".");
|
|
10124
10186
|
}
|
|
10125
10187
|
|
|
10188
|
+
/**
|
|
10189
|
+
* What a number schema accepts, in one place, so the validator and the
|
|
10190
|
+
* Studio's "Round to …" / "Set to …" buttons cannot disagree about it.
|
|
10191
|
+
*
|
|
10192
|
+
* A button that offers a value the validator then rejects is worse than no
|
|
10193
|
+
* button, which is exactly what two copies of this arithmetic would drift into.
|
|
10194
|
+
*/
|
|
10195
|
+
|
|
10196
|
+
/**
|
|
10197
|
+
* Division of decimals is not exact (`0.3 / 0.1` is `2.9999999999999996`), so a
|
|
10198
|
+
* value counts as on the grid when it is within this many steps of it.
|
|
10199
|
+
*/
|
|
10200
|
+
var GRID_EPSILON = 1e-9;
|
|
10201
|
+
|
|
10202
|
+
/** Where the step grid starts: the schema's `min`, or 0 when it has none. */
|
|
10203
|
+
function stepOrigin(rules) {
|
|
10204
|
+
var _rules$min;
|
|
10205
|
+
return (_rules$min = rules.min) !== null && _rules$min !== void 0 ? _rules$min : 0;
|
|
10206
|
+
}
|
|
10207
|
+
|
|
10208
|
+
/** Is `value` one of `origin + n * step`? */
|
|
10209
|
+
function isOnStep(value, origin, step) {
|
|
10210
|
+
var steps = (value - origin) / step;
|
|
10211
|
+
return Math.abs(steps - Math.round(steps)) < GRID_EPSILON;
|
|
10212
|
+
}
|
|
10213
|
+
|
|
10214
|
+
/**
|
|
10215
|
+
* The allowed value closest to `value`: inside `min`/`max`, on the step grid,
|
|
10216
|
+
* and whole when the schema is an int.
|
|
10217
|
+
*
|
|
10218
|
+
* Returns `null` when the rules leave nothing to snap to — a `min` above
|
|
10219
|
+
* `max`, or a range too narrow to hold a single step or a single whole number.
|
|
10220
|
+
*/
|
|
10221
|
+
function nearestAllowedNumber(value, rules) {
|
|
10222
|
+
var _rules$step;
|
|
10223
|
+
var step = (_rules$step = rules.step) !== null && _rules$step !== void 0 ? _rules$step : rules.integer ? 1 : undefined;
|
|
10224
|
+
var lo = rules.min;
|
|
10225
|
+
var hi = rules.max;
|
|
10226
|
+
if (lo !== undefined && hi !== undefined && lo > hi) {
|
|
10227
|
+
return null;
|
|
10228
|
+
}
|
|
10229
|
+
var clamp = function clamp(n) {
|
|
10230
|
+
return Math.min(hi !== null && hi !== void 0 ? hi : Infinity, Math.max(lo !== null && lo !== void 0 ? lo : -Infinity, n));
|
|
10231
|
+
};
|
|
10232
|
+
if (step === undefined) {
|
|
10233
|
+
return clamp(value);
|
|
10234
|
+
}
|
|
10235
|
+
var origin = rules.integer && rules.step === undefined ? 0 : stepOrigin(rules);
|
|
10236
|
+
var toGrid = function toGrid(n) {
|
|
10237
|
+
return roundToDecimals(origin + n * step);
|
|
10238
|
+
};
|
|
10239
|
+
var n = Math.round((clamp(value) - origin) / step);
|
|
10240
|
+
// Rounding can step outside the range by one; walk back in.
|
|
10241
|
+
if (lo !== undefined && toGrid(n) < lo) n += 1;
|
|
10242
|
+
if (hi !== undefined && toGrid(n) > hi) n -= 1;
|
|
10243
|
+
var snapped = toGrid(n);
|
|
10244
|
+
if (lo !== undefined && snapped < lo || hi !== undefined && snapped > hi) {
|
|
10245
|
+
return null;
|
|
10246
|
+
}
|
|
10247
|
+
if (rules.integer && !Number.isInteger(snapped)) {
|
|
10248
|
+
return null;
|
|
10249
|
+
}
|
|
10250
|
+
return snapped;
|
|
10251
|
+
}
|
|
10252
|
+
|
|
10253
|
+
/**
|
|
10254
|
+
* `0.1 + 0.2` is `0.30000000000000004`. A value offered to an editor should
|
|
10255
|
+
* read `0.3`, so grid values are rounded to 12 significant decimals — far below
|
|
10256
|
+
* any step anyone writes, far above floating point noise.
|
|
10257
|
+
*/
|
|
10258
|
+
function roundToDecimals(n) {
|
|
10259
|
+
return Number.parseFloat(n.toFixed(12));
|
|
10260
|
+
}
|
|
10261
|
+
|
|
10262
|
+
/**
|
|
10263
|
+
* What the value has to be. `integer` is what makes a number schema an
|
|
10264
|
+
* `s.int()`: the source is a number either way, so an int is a number schema
|
|
10265
|
+
* with one more rule rather than a schema type of its own (which every walk
|
|
10266
|
+
* over a schema would have had to learn).
|
|
10267
|
+
*/
|
|
10268
|
+
|
|
10126
10269
|
var NumberSchema = /*#__PURE__*/function (_Schema) {
|
|
10127
10270
|
function NumberSchema(options) {
|
|
10128
10271
|
var _this;
|
|
@@ -10132,6 +10275,7 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
|
|
|
10132
10275
|
var isHidden = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
10133
10276
|
var description = arguments.length > 5 ? arguments[5] : undefined;
|
|
10134
10277
|
var previewInput = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
|
|
10278
|
+
var renderInput = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
|
|
10135
10279
|
_classCallCheck(this, NumberSchema);
|
|
10136
10280
|
_this = _callSuper(this, NumberSchema);
|
|
10137
10281
|
_this.options = options;
|
|
@@ -10141,6 +10285,8 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
|
|
|
10141
10285
|
_this.isHidden = isHidden;
|
|
10142
10286
|
_this.description = description;
|
|
10143
10287
|
_this.previewInput = previewInput;
|
|
10288
|
+
_this.renderInput = renderInput;
|
|
10289
|
+
assertNumberSchemaIsConsistent(_this.options, _this.renderInput);
|
|
10144
10290
|
return _this;
|
|
10145
10291
|
}
|
|
10146
10292
|
|
|
@@ -10165,7 +10311,7 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
|
|
|
10165
10311
|
return _createClass(NumberSchema, [{
|
|
10166
10312
|
key: "describe",
|
|
10167
10313
|
value: function describe(description) {
|
|
10168
|
-
return new NumberSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined, this.previewInput);
|
|
10314
|
+
return new NumberSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined, this.previewInput, this.renderInput);
|
|
10169
10315
|
}
|
|
10170
10316
|
|
|
10171
10317
|
/**
|
|
@@ -10191,12 +10337,12 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
|
|
|
10191
10337
|
}, {
|
|
10192
10338
|
key: "validate",
|
|
10193
10339
|
value: function validate(validationFunction) {
|
|
10194
|
-
return new NumberSchema(this.options, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description, this.previewInput);
|
|
10340
|
+
return new NumberSchema(this.options, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description, this.previewInput, this.renderInput);
|
|
10195
10341
|
}
|
|
10196
10342
|
}, {
|
|
10197
10343
|
key: "executeValidate",
|
|
10198
10344
|
value: function executeValidate(path, src) {
|
|
10199
|
-
var _this$options
|
|
10345
|
+
var _this$options;
|
|
10200
10346
|
var customValidationErrors = this.executeCustomValidateFunctions(src, this.customValidateFunctions, {
|
|
10201
10347
|
path: path
|
|
10202
10348
|
});
|
|
@@ -10209,20 +10355,35 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
|
|
|
10209
10355
|
value: src
|
|
10210
10356
|
}]));
|
|
10211
10357
|
}
|
|
10212
|
-
|
|
10213
|
-
|
|
10214
|
-
|
|
10358
|
+
var errors = _toConsumableArray(customValidationErrors);
|
|
10359
|
+
var options = (_this$options = this.options) !== null && _this$options !== void 0 ? _this$options : {};
|
|
10360
|
+
// `!== undefined`, not truthiness: a bound of 0 is a bound. `.max(0)` and
|
|
10361
|
+
// `.min(0)` used to be ignored, which a slider from 0 makes common.
|
|
10362
|
+
if (options.max !== undefined && src > options.max) {
|
|
10363
|
+
errors.push({
|
|
10364
|
+
message: "Must be at most ".concat(options.max),
|
|
10215
10365
|
value: src
|
|
10216
|
-
}
|
|
10366
|
+
});
|
|
10217
10367
|
}
|
|
10218
|
-
if (
|
|
10219
|
-
|
|
10220
|
-
message: "
|
|
10368
|
+
if (options.min !== undefined && src < options.min) {
|
|
10369
|
+
errors.push({
|
|
10370
|
+
message: "Must be at least ".concat(options.min),
|
|
10221
10371
|
value: src
|
|
10222
|
-
}
|
|
10372
|
+
});
|
|
10223
10373
|
}
|
|
10224
|
-
if (
|
|
10225
|
-
|
|
10374
|
+
if (options.integer && !Number.isInteger(src)) {
|
|
10375
|
+
errors.push({
|
|
10376
|
+
message: "Must be a whole number",
|
|
10377
|
+
value: src
|
|
10378
|
+
});
|
|
10379
|
+
} else if (options.step !== undefined && !isOnStep(src, stepOrigin(options), options.step)) {
|
|
10380
|
+
errors.push({
|
|
10381
|
+
message: "Must be a multiple of ".concat(options.step, ", counted from ").concat(stepOrigin(options)),
|
|
10382
|
+
value: src
|
|
10383
|
+
});
|
|
10384
|
+
}
|
|
10385
|
+
if (errors.length > 0) {
|
|
10386
|
+
return _defineProperty({}, path, errors);
|
|
10226
10387
|
}
|
|
10227
10388
|
return false;
|
|
10228
10389
|
}
|
|
@@ -10261,19 +10422,19 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
|
|
|
10261
10422
|
}, {
|
|
10262
10423
|
key: "nullable",
|
|
10263
10424
|
value: function nullable() {
|
|
10264
|
-
return new NumberSchema(this.options, true, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.previewInput);
|
|
10425
|
+
return new NumberSchema(this.options, true, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.previewInput, this.renderInput);
|
|
10265
10426
|
}
|
|
10266
10427
|
}, {
|
|
10267
10428
|
key: "readonly",
|
|
10268
10429
|
value: function readonly() {
|
|
10269
10430
|
var isReadonly = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
10270
|
-
return new NumberSchema(this.options, this.opt, this.customValidateFunctions, isReadonly, this.isHidden, this.description, this.previewInput);
|
|
10431
|
+
return new NumberSchema(this.options, this.opt, this.customValidateFunctions, isReadonly, this.isHidden, this.description, this.previewInput, this.renderInput);
|
|
10271
10432
|
}
|
|
10272
10433
|
}, {
|
|
10273
10434
|
key: "hidden",
|
|
10274
10435
|
value: function hidden() {
|
|
10275
10436
|
var isHidden = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
10276
|
-
return new NumberSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, isHidden, this.description, this.previewInput);
|
|
10437
|
+
return new NumberSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, isHidden, this.description, this.previewInput, this.renderInput);
|
|
10277
10438
|
}
|
|
10278
10439
|
|
|
10279
10440
|
/**
|
|
@@ -10288,7 +10449,7 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
|
|
|
10288
10449
|
value: function max(_max) {
|
|
10289
10450
|
return new NumberSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
|
|
10290
10451
|
max: _max
|
|
10291
|
-
}), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.previewInput);
|
|
10452
|
+
}), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.previewInput, this.renderInput);
|
|
10292
10453
|
}
|
|
10293
10454
|
|
|
10294
10455
|
/**
|
|
@@ -10303,7 +10464,50 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
|
|
|
10303
10464
|
value: function min(_min) {
|
|
10304
10465
|
return new NumberSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
|
|
10305
10466
|
min: _min
|
|
10306
|
-
}), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.previewInput);
|
|
10467
|
+
}), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.previewInput, this.renderInput);
|
|
10468
|
+
}
|
|
10469
|
+
|
|
10470
|
+
/**
|
|
10471
|
+
* Validate that the number is on a grid of `step`: one of `min`, `min + step`,
|
|
10472
|
+
* `min + 2 * step` and so on, counted from 0 when there is no `.min()`.
|
|
10473
|
+
*
|
|
10474
|
+
* A slider rendered on this field moves in the same steps unless its render
|
|
10475
|
+
* says otherwise (and then its step has to be a multiple of this one).
|
|
10476
|
+
*
|
|
10477
|
+
* @example
|
|
10478
|
+
* const schema = s.int().min(0).max(100).step(5);
|
|
10479
|
+
* export default c.define("/example.val.ts", schema, 40);
|
|
10480
|
+
*/
|
|
10481
|
+
}, {
|
|
10482
|
+
key: "step",
|
|
10483
|
+
value: function step(_step) {
|
|
10484
|
+
return new NumberSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
|
|
10485
|
+
step: _step
|
|
10486
|
+
}), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.previewInput, this.renderInput);
|
|
10487
|
+
}
|
|
10488
|
+
|
|
10489
|
+
/**
|
|
10490
|
+
* Choose how this field is edited. `{ as: "slider", min, max }` edits it with
|
|
10491
|
+
* a slider from `min` to `max`, next to a box for typing an exact value.
|
|
10492
|
+
*
|
|
10493
|
+
* `min` and `max` are required — a slider without ends is not a slider — and
|
|
10494
|
+
* they are the slider's, not validation: use `.min()` / `.max()` for what the
|
|
10495
|
+
* value may be. The slider can only produce values this schema accepts, so
|
|
10496
|
+
* its range must lie inside `.min()`/`.max()`, its `step` (which defaults to
|
|
10497
|
+
* `.step()`, then 1) must be a multiple of `.step()`, and on `s.int()` all of
|
|
10498
|
+
* them must be whole numbers. A schema that breaks this throws here.
|
|
10499
|
+
*
|
|
10500
|
+
* Static configuration, not a callback — see `render.ts`. A second
|
|
10501
|
+
* `.render(...)` replaces the first.
|
|
10502
|
+
*
|
|
10503
|
+
* @example
|
|
10504
|
+
* const schema = s.int().render({ as: "slider", min: 0, max: 100, step: 5 });
|
|
10505
|
+
* export default c.define("/example.val.ts", schema, 40);
|
|
10506
|
+
*/
|
|
10507
|
+
}, {
|
|
10508
|
+
key: "render",
|
|
10509
|
+
value: function render(input) {
|
|
10510
|
+
return new NumberSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.previewInput, input);
|
|
10307
10511
|
}
|
|
10308
10512
|
}, {
|
|
10309
10513
|
key: "executeCustomValidateAt",
|
|
@@ -10327,7 +10531,7 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
|
|
|
10327
10531
|
}, {
|
|
10328
10532
|
key: "preview",
|
|
10329
10533
|
value: function preview(select) {
|
|
10330
|
-
return new NumberSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, select);
|
|
10534
|
+
return new NumberSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, select, this.renderInput);
|
|
10331
10535
|
}
|
|
10332
10536
|
}, {
|
|
10333
10537
|
key: "executePreviewItem",
|
|
@@ -10347,11 +10551,12 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
|
|
|
10347
10551
|
}, {
|
|
10348
10552
|
key: "executeSerialize",
|
|
10349
10553
|
value: function executeSerialize() {
|
|
10350
|
-
var _this$customValidateF;
|
|
10554
|
+
var _this$renderInput, _this$customValidateF;
|
|
10351
10555
|
return {
|
|
10352
10556
|
type: "number",
|
|
10353
10557
|
preview: this.previewInput ? true : undefined,
|
|
10354
10558
|
options: this.options,
|
|
10559
|
+
render: (_this$renderInput = this.renderInput) !== null && _this$renderInput !== void 0 ? _this$renderInput : undefined,
|
|
10355
10560
|
opt: this.opt,
|
|
10356
10561
|
customValidate: this.customValidateFunctions && ((_this$customValidateF = this.customValidateFunctions) === null || _this$customValidateF === void 0 ? void 0 : _this$customValidateF.length) > 0,
|
|
10357
10562
|
readonly: this.isReadonly,
|
|
@@ -10364,6 +10569,63 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
|
|
|
10364
10569
|
var number = function number(options) {
|
|
10365
10570
|
return new NumberSchema(options);
|
|
10366
10571
|
};
|
|
10572
|
+
var _int = function _int() {
|
|
10573
|
+
return new NumberSchema({
|
|
10574
|
+
integer: true
|
|
10575
|
+
});
|
|
10576
|
+
};
|
|
10577
|
+
function assertNumberSchemaIsConsistent(options, render) {
|
|
10578
|
+
var opts = options !== null && options !== void 0 ? options : {};
|
|
10579
|
+
var kind = opts.integer ? "s.int()" : "s.number()";
|
|
10580
|
+
if (opts.step !== undefined) {
|
|
10581
|
+
if (!(opts.step > 0) || !Number.isFinite(opts.step)) {
|
|
10582
|
+
throw new Error("".concat(kind, ".step(").concat(opts.step, "): the step must be above 0"));
|
|
10583
|
+
}
|
|
10584
|
+
if (opts.integer && !Number.isInteger(opts.step)) {
|
|
10585
|
+
throw new Error("".concat(kind, ".step(").concat(opts.step, "): the step of an int must be a whole number"));
|
|
10586
|
+
}
|
|
10587
|
+
}
|
|
10588
|
+
if (render === null) {
|
|
10589
|
+
return;
|
|
10590
|
+
}
|
|
10591
|
+
var where = "".concat(kind, ".render({ as: \"slider\", min: ").concat(render.min, ", max: ").concat(render.max, " })");
|
|
10592
|
+
if (!Number.isFinite(render.min) || !Number.isFinite(render.max)) {
|
|
10593
|
+
throw new Error("".concat(where, ": the slider needs a min and a max"));
|
|
10594
|
+
}
|
|
10595
|
+
if (!(render.min < render.max)) {
|
|
10596
|
+
throw new Error("".concat(where, ": the slider's min must be below its max"));
|
|
10597
|
+
}
|
|
10598
|
+
if (opts.min !== undefined && render.min < opts.min) {
|
|
10599
|
+
throw new Error("".concat(where, ": the slider's min ").concat(render.min, " is below the schema's min ").concat(opts.min));
|
|
10600
|
+
}
|
|
10601
|
+
if (opts.max !== undefined && render.max > opts.max) {
|
|
10602
|
+
throw new Error("".concat(where, ": the slider's max ").concat(render.max, " is above the schema's max ").concat(opts.max));
|
|
10603
|
+
}
|
|
10604
|
+
if (render.step !== undefined && !(render.step > 0)) {
|
|
10605
|
+
throw new Error("".concat(where, ": the slider's step must be above 0"));
|
|
10606
|
+
}
|
|
10607
|
+
if (opts.integer) {
|
|
10608
|
+
var sliderNumbers = [["min", render.min], ["max", render.max], ["step", render.step]];
|
|
10609
|
+
for (var _i = 0, _sliderNumbers = sliderNumbers; _i < _sliderNumbers.length; _i++) {
|
|
10610
|
+
var _sliderNumbers$_i = _slicedToArray(_sliderNumbers[_i], 2),
|
|
10611
|
+
name = _sliderNumbers$_i[0],
|
|
10612
|
+
value = _sliderNumbers$_i[1];
|
|
10613
|
+
if (value !== undefined && !Number.isInteger(value)) {
|
|
10614
|
+
throw new Error("".concat(where, ": the slider's ").concat(name, " ").concat(value, " must be a whole number on an int"));
|
|
10615
|
+
}
|
|
10616
|
+
}
|
|
10617
|
+
}
|
|
10618
|
+
if (opts.step !== undefined) {
|
|
10619
|
+
var _render$step;
|
|
10620
|
+
var sliderStep = (_render$step = render.step) !== null && _render$step !== void 0 ? _render$step : opts.step;
|
|
10621
|
+
if (!isOnStep(sliderStep, 0, opts.step)) {
|
|
10622
|
+
throw new Error("".concat(where, ": the slider's step ").concat(sliderStep, " must be a multiple of the schema's step ").concat(opts.step));
|
|
10623
|
+
}
|
|
10624
|
+
if (!isOnStep(render.min, stepOrigin(opts), opts.step)) {
|
|
10625
|
+
throw new Error("".concat(where, ": the slider's min ").concat(render.min, " is not one of the schema's steps (").concat(opts.step, ", counted from ").concat(stepOrigin(opts), ")"));
|
|
10626
|
+
}
|
|
10627
|
+
}
|
|
10628
|
+
}
|
|
10367
10629
|
|
|
10368
10630
|
/**
|
|
10369
10631
|
* @deprecated Use {@link SerializedDiscriminatedUnionSchema} or
|
|
@@ -10920,31 +11182,37 @@ var FileSchema = /*#__PURE__*/function (_Schema) {
|
|
|
10920
11182
|
value: src
|
|
10921
11183
|
}]));
|
|
10922
11184
|
}
|
|
11185
|
+
// A field picked from a gallery holds the gallery's KEY, and whether that
|
|
11186
|
+
// key is a local path or a remote ref is the gallery's to decide — and its
|
|
11187
|
+
// to fix: uploading an entry renames its key, and the fields that hold it
|
|
11188
|
+
// with it. So such a field only asks whether the gallery has it, below.
|
|
11189
|
+
// Asking here as well reported every file picked from a `.remote()`
|
|
11190
|
+
// gallery as one to download, because the field itself is never remote.
|
|
11191
|
+
var galleryEntries = this.galleryEntries();
|
|
10923
11192
|
// Remote-ness is a property of the path, not of a marker on the value:
|
|
10924
11193
|
// anything outside /public is remote.
|
|
10925
11194
|
var isRemotePath = isRemoteMediaPath(src.path);
|
|
10926
|
-
if (this.isRemote && !isRemotePath) {
|
|
11195
|
+
if (!galleryEntries && this.isRemote && !isRemotePath) {
|
|
10927
11196
|
return _defineProperty({}, path, [].concat(_toConsumableArray(customValidationErrors), [{
|
|
10928
11197
|
message: "Expected a remote file, but got a local file.",
|
|
10929
11198
|
value: src,
|
|
10930
11199
|
fixes: ["file:upload-remote"]
|
|
10931
11200
|
}]));
|
|
10932
11201
|
}
|
|
10933
|
-
if (this.isRemote && isRemotePath) {
|
|
11202
|
+
if (!galleryEntries && this.isRemote && isRemotePath) {
|
|
10934
11203
|
return _defineProperty({}, path, [].concat(_toConsumableArray(customValidationErrors), [{
|
|
10935
11204
|
message: "Remote file was not checked.",
|
|
10936
11205
|
value: src,
|
|
10937
11206
|
fixes: ["file:check-remote"]
|
|
10938
11207
|
}]));
|
|
10939
11208
|
}
|
|
10940
|
-
if (!this.isRemote && isRemotePath) {
|
|
11209
|
+
if (!galleryEntries && !this.isRemote && isRemotePath) {
|
|
10941
11210
|
return _defineProperty({}, path, [].concat(_toConsumableArray(customValidationErrors), [{
|
|
10942
11211
|
message: "Expected local file, but found remote.",
|
|
10943
11212
|
value: src,
|
|
10944
11213
|
fixes: ["file:download-remote"]
|
|
10945
11214
|
}]));
|
|
10946
11215
|
}
|
|
10947
|
-
var galleryEntries = this.galleryEntries();
|
|
10948
11216
|
if (galleryEntries) {
|
|
10949
11217
|
if (src.mimeType !== undefined) {
|
|
10950
11218
|
return _defineProperty({}, path, [].concat(_toConsumableArray(customValidationErrors), [{
|
|
@@ -10952,7 +11220,11 @@ var FileSchema = /*#__PURE__*/function (_Schema) {
|
|
|
10952
11220
|
value: src
|
|
10953
11221
|
}]));
|
|
10954
11222
|
}
|
|
10955
|
-
|
|
11223
|
+
// The same match reading the field makes (`fillFromGallery`): the key,
|
|
11224
|
+
// or the local path inside a ref an upload through the field stored.
|
|
11225
|
+
if (galleryKeyOf(src.path, function (key) {
|
|
11226
|
+
return key in galleryEntries;
|
|
11227
|
+
}) === null) {
|
|
10956
11228
|
return _defineProperty({}, path, [].concat(_toConsumableArray(customValidationErrors), [{
|
|
10957
11229
|
message: "The gallery does not have a file at '".concat(src.path, "'."),
|
|
10958
11230
|
value: src
|
|
@@ -11188,7 +11460,7 @@ function fileOf(remote, options) {
|
|
|
11188
11460
|
}
|
|
11189
11461
|
|
|
11190
11462
|
/**
|
|
11191
|
-
* A font picked from an `s.
|
|
11463
|
+
* A font picked from an `s.fontdir()`.
|
|
11192
11464
|
*
|
|
11193
11465
|
* The same field `s.file(fontsVal)` is — it stores `{ path }` and serializes
|
|
11194
11466
|
* identically — with one thing more: it refuses a set that is not a font set,
|
|
@@ -11215,7 +11487,7 @@ function assertFontset(fontsetModule) {
|
|
|
11215
11487
|
return isFontMimeType(type.trim());
|
|
11216
11488
|
});
|
|
11217
11489
|
if (!isFontset) {
|
|
11218
|
-
throw new Error("s.font(".concat(modulePath !== null && modulePath !== void 0 ? modulePath : "?", "): the module must be an s.
|
|
11490
|
+
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."));
|
|
11219
11491
|
}
|
|
11220
11492
|
}
|
|
11221
11493
|
|
|
@@ -11754,7 +12026,7 @@ function stripQuery(path) {
|
|
|
11754
12026
|
}
|
|
11755
12027
|
|
|
11756
12028
|
/**
|
|
11757
|
-
* A video picked from a set (`s.
|
|
12029
|
+
* A video picked from a set (`s.videodir()`). What is true of the file —
|
|
11758
12030
|
* its type, size and length — lives in the set; the field carries what one
|
|
11759
12031
|
* page chose about it.
|
|
11760
12032
|
*/
|
|
@@ -11789,7 +12061,7 @@ function videoOf(options, galleryOptions) {
|
|
|
11789
12061
|
var setSchema = (_options$GetSchema = options[GetSchema]) === null || _options$GetSchema === void 0 ? void 0 : _options$GetSchema["executeSerialize"]();
|
|
11790
12062
|
if ((setSchema === null || setSchema === void 0 ? void 0 : setSchema.type) !== "record" || setSchema.mediaType !== "videos") {
|
|
11791
12063
|
var _setSchema$mediaType, _setSchema$type;
|
|
11792
|
-
throw new Error("s.video(".concat(modulePath, "): the module must be an s.
|
|
12064
|
+
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", "."));
|
|
11793
12065
|
}
|
|
11794
12066
|
return new VideoSchema((galleryOptions === null || galleryOptions === void 0 ? void 0 : galleryOptions.stream) !== undefined ? {
|
|
11795
12067
|
stream: galleryOptions.stream
|
|
@@ -11804,23 +12076,37 @@ function isVideosetModule(value) {
|
|
|
11804
12076
|
}
|
|
11805
12077
|
|
|
11806
12078
|
/**
|
|
11807
|
-
* Options for s.
|
|
12079
|
+
* Options for `s.filedir(dir, options)`: everything but the directory, which
|
|
12080
|
+
* is the first argument.
|
|
12081
|
+
*/
|
|
12082
|
+
|
|
12083
|
+
/**
|
|
12084
|
+
* Options for the deprecated `s.fileset(options)`, which took the directory
|
|
12085
|
+
* as `dir`.
|
|
12086
|
+
*
|
|
12087
|
+
* @deprecated Use `s.filedir(dir, options)` and `FiledirOptions`.
|
|
11808
12088
|
*/
|
|
11809
12089
|
|
|
11810
12090
|
/**
|
|
11811
12091
|
* Metadata for a file entry in the files record
|
|
11812
12092
|
*/
|
|
11813
12093
|
|
|
12094
|
+
/** @deprecated Use `FiledirEntryMetadata`. */
|
|
12095
|
+
|
|
12096
|
+
/** @deprecated Use `SerializedFiledirSchema`. */
|
|
12097
|
+
|
|
11814
12098
|
/**
|
|
11815
|
-
* Define a
|
|
12099
|
+
* Define a directory of files: a whole module that holds many files, keyed by
|
|
12100
|
+
* their file path, that fields pick from with `s.file(filesVal)`.
|
|
11816
12101
|
*
|
|
11817
|
-
*
|
|
12102
|
+
* The directory is the first argument and is required — it decides where
|
|
12103
|
+
* uploads land. Remote is off by default: call `.remote()` on the result to
|
|
12104
|
+
* allow remote files.
|
|
11818
12105
|
*
|
|
11819
12106
|
* @example
|
|
11820
12107
|
* ```typescript
|
|
11821
|
-
* const schema = s.
|
|
12108
|
+
* const schema = s.filedir("/public/val/documents", {
|
|
11822
12109
|
* accept: "application/pdf",
|
|
11823
|
-
* dir: "/public/val/documents",
|
|
11824
12110
|
* });
|
|
11825
12111
|
* export default c.define("/content/documents.val.ts", schema, {
|
|
11826
12112
|
* "/public/val/documents/report.pdf": {
|
|
@@ -11829,8 +12115,7 @@ function isVideosetModule(value) {
|
|
|
11829
12115
|
* });
|
|
11830
12116
|
* ```
|
|
11831
12117
|
*/
|
|
11832
|
-
var
|
|
11833
|
-
var dir = options.dir;
|
|
12118
|
+
var filedir = function filedir(dir, options) {
|
|
11834
12119
|
var itemSchema = new ObjectSchema({
|
|
11835
12120
|
mimeType: new StringSchema({}, false)
|
|
11836
12121
|
}, false);
|
|
@@ -11843,23 +12128,49 @@ var fileset = function fileset(options) {
|
|
|
11843
12128
|
};
|
|
11844
12129
|
|
|
11845
12130
|
/**
|
|
11846
|
-
*
|
|
12131
|
+
* Define a collection of files.
|
|
12132
|
+
*
|
|
12133
|
+
* @deprecated Use `s.filedir(dir, options)`: the directory moved out of the
|
|
12134
|
+
* options and into the first argument, and nothing else changed.
|
|
12135
|
+
*
|
|
12136
|
+
* @example
|
|
12137
|
+
* ```typescript
|
|
12138
|
+
* // was: s.fileset({ dir: "/public/val/documents", accept: "application/pdf" })
|
|
12139
|
+
* const schema = s.filedir("/public/val/documents", {
|
|
12140
|
+
* accept: "application/pdf",
|
|
12141
|
+
* });
|
|
12142
|
+
* ```
|
|
11847
12143
|
*/
|
|
12144
|
+
var fileset = function fileset(options) {
|
|
12145
|
+
return filedir(options.dir, options);
|
|
12146
|
+
};
|
|
11848
12147
|
|
|
11849
12148
|
/**
|
|
11850
|
-
*
|
|
12149
|
+
* Options for `s.fontdir(dir, options)`: everything but the directory, which
|
|
12150
|
+
* is the first argument.
|
|
12151
|
+
*/
|
|
12152
|
+
|
|
12153
|
+
/**
|
|
12154
|
+
* Options for the deprecated `s.fontset(options)`, which took the directory
|
|
12155
|
+
* as `dir`.
|
|
12156
|
+
*
|
|
12157
|
+
* @deprecated Use `s.fontdir(dir, options)` and `FontdirOptions`.
|
|
12158
|
+
*/
|
|
12159
|
+
|
|
12160
|
+
/**
|
|
12161
|
+
* Define a directory of fonts.
|
|
11851
12162
|
*
|
|
11852
|
-
* A
|
|
12163
|
+
* A fontdir IS a filedir — the same source, the same `s.font(fontsVal)` field
|
|
11853
12164
|
* to pick from it, the same checks and fixes — with `accept` defaulting to the
|
|
11854
12165
|
* web font formats. What a font gets that any other file does not is decided
|
|
11855
|
-
* by its mime type rather than by the
|
|
11856
|
-
* knows is a font, wherever it is shown.
|
|
12166
|
+
* by its mime type rather than by the directory: the Studio previews any file
|
|
12167
|
+
* it knows is a font, wherever it is shown.
|
|
11857
12168
|
*
|
|
11858
12169
|
* Remote is off by default: call `.remote()` on the result to allow remote files.
|
|
11859
12170
|
*
|
|
11860
12171
|
* @example
|
|
11861
12172
|
* ```typescript
|
|
11862
|
-
* const schema = s.
|
|
12173
|
+
* const schema = s.fontdir("/public/val/fonts");
|
|
11863
12174
|
* export default c.define("/content/fonts.val.ts", schema, {
|
|
11864
12175
|
* "/public/val/fonts/inter_a1b2c.woff2": {
|
|
11865
12176
|
* mimeType: "font/woff2",
|
|
@@ -11867,25 +12178,40 @@ var fileset = function fileset(options) {
|
|
|
11867
12178
|
* });
|
|
11868
12179
|
* ```
|
|
11869
12180
|
*/
|
|
11870
|
-
var
|
|
12181
|
+
var fontdir = function fontdir(dir, options) {
|
|
11871
12182
|
var _options$accept;
|
|
11872
|
-
var accept = (_options$accept = options.accept) !== null && _options$accept !== void 0 ? _options$accept : DEFAULT_FONT_ACCEPT;
|
|
12183
|
+
var accept = (_options$accept = options === null || options === void 0 ? void 0 : options.accept) !== null && _options$accept !== void 0 ? _options$accept : DEFAULT_FONT_ACCEPT;
|
|
11873
12184
|
var notFonts = accept.split(",").map(function (type) {
|
|
11874
12185
|
return type.trim();
|
|
11875
12186
|
}).filter(function (type) {
|
|
11876
12187
|
return !isFontMimeType(type);
|
|
11877
12188
|
});
|
|
11878
12189
|
if (notFonts.length > 0) {
|
|
11879
|
-
// A
|
|
12190
|
+
// A fontdir that took a PDF would be a filedir under a name that says
|
|
11880
12191
|
// otherwise, and the Studio would draw a specimen of nothing.
|
|
11881
|
-
throw new Error("s.
|
|
12192
|
+
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."));
|
|
11882
12193
|
}
|
|
11883
|
-
return
|
|
11884
|
-
dir: options.dir,
|
|
12194
|
+
return filedir(dir, {
|
|
11885
12195
|
accept: accept
|
|
11886
12196
|
});
|
|
11887
12197
|
};
|
|
11888
12198
|
|
|
12199
|
+
/**
|
|
12200
|
+
* Define a collection of fonts.
|
|
12201
|
+
*
|
|
12202
|
+
* @deprecated Use `s.fontdir(dir, options)`: the directory moved out of the
|
|
12203
|
+
* options and into the first argument, and nothing else changed.
|
|
12204
|
+
*
|
|
12205
|
+
* @example
|
|
12206
|
+
* ```typescript
|
|
12207
|
+
* // was: s.fontset({ dir: "/public/val/fonts" })
|
|
12208
|
+
* const schema = s.fontdir("/public/val/fonts");
|
|
12209
|
+
* ```
|
|
12210
|
+
*/
|
|
12211
|
+
var fontset = function fontset(options) {
|
|
12212
|
+
return fontdir(options.dir, options);
|
|
12213
|
+
};
|
|
12214
|
+
|
|
11889
12215
|
var DateSchema = /*#__PURE__*/function (_Schema) {
|
|
11890
12216
|
function DateSchema(options) {
|
|
11891
12217
|
var _this;
|
|
@@ -12752,39 +13078,58 @@ function router(router, keyOrItem, maybeItem) {
|
|
|
12752
13078
|
/** Every `alt` value any `AltSchema` can produce. */
|
|
12753
13079
|
|
|
12754
13080
|
/**
|
|
12755
|
-
* Options for s.
|
|
13081
|
+
* Options for `s.imagedir(dir, options)`: everything but the directory, which
|
|
13082
|
+
* is the first argument.
|
|
13083
|
+
*/
|
|
13084
|
+
|
|
13085
|
+
/**
|
|
13086
|
+
* Options for the deprecated `s.imageset(options)`, which took the directory
|
|
13087
|
+
* as `dir`.
|
|
13088
|
+
*
|
|
13089
|
+
* @deprecated Use `s.imagedir(dir, options)` and `ImagedirOptions`.
|
|
12756
13090
|
*/
|
|
12757
13091
|
|
|
12758
13092
|
/**
|
|
12759
13093
|
* `alt` is optional only when it is the default schema.
|
|
12760
13094
|
*
|
|
12761
13095
|
* Naming a different `Alt` and then leaving `alt` out would make the fallback
|
|
12762
|
-
* in `
|
|
13096
|
+
* in `imagedir()` a lie — `Alt` would say `s.string()` while the value was a
|
|
12763
13097
|
* nullable one. Requiring it in that case is what makes the fallback sound:
|
|
12764
13098
|
* the branch that uses it is reachable only when `Alt` IS the default.
|
|
12765
13099
|
*/
|
|
12766
13100
|
|
|
13101
|
+
/**
|
|
13102
|
+
* The options argument of `s.imagedir()`: optional only when `alt` is, for
|
|
13103
|
+
* the reason `ImagedirAltOption` gives — leaving the whole object out leaves
|
|
13104
|
+
* `alt` out with it.
|
|
13105
|
+
*/
|
|
13106
|
+
|
|
12767
13107
|
/**
|
|
12768
13108
|
* Metadata for an image entry in the images record.
|
|
12769
13109
|
*
|
|
12770
13110
|
* `alt` follows the schema's `alt` option, so it defaults to `string | null`
|
|
12771
13111
|
* and becomes `string` under `s.string()` or `Record<string, string>` under
|
|
12772
|
-
* `s.record(s.string())`. Write `
|
|
13112
|
+
* `s.record(s.string())`. Write `ImagedirEntryMetadata<AltSource>` where a
|
|
12773
13113
|
* gallery of any alt shape is acceptable.
|
|
12774
13114
|
*/
|
|
12775
13115
|
|
|
13116
|
+
/** @deprecated Use `ImagedirEntryMetadata`. */
|
|
13117
|
+
|
|
13118
|
+
/** @deprecated Use `SerializedImagedirSchema`. */
|
|
13119
|
+
|
|
12776
13120
|
/**
|
|
12777
|
-
* Define a
|
|
13121
|
+
* Define a directory of images: a whole module that holds many images, keyed
|
|
13122
|
+
* by their file path, that fields pick from with `s.image(galleryVal)`.
|
|
12778
13123
|
*
|
|
12779
|
-
*
|
|
12780
|
-
* to be inferred. The rest defaults: any
|
|
12781
|
-
*
|
|
13124
|
+
* The directory is the first argument and is required — it decides where
|
|
13125
|
+
* uploads land, so it is not something to be inferred. The rest defaults: any
|
|
13126
|
+
* image type (`"image/*"`), nullable alt text, remote disabled. Call
|
|
13127
|
+
* `.remote()` on the result to allow remote images.
|
|
12782
13128
|
*
|
|
12783
13129
|
* @example
|
|
12784
13130
|
* ```typescript
|
|
12785
|
-
* const schema = s.
|
|
13131
|
+
* const schema = s.imagedir("/public/val/images", {
|
|
12786
13132
|
* accept: "image/webp",
|
|
12787
|
-
* dir: "/public/val/images",
|
|
12788
13133
|
* alt: s.string().minLength(4),
|
|
12789
13134
|
* });
|
|
12790
13135
|
* export default c.define("/content/images.val.ts", schema, {
|
|
@@ -12797,19 +13142,26 @@ function router(router, keyOrItem, maybeItem) {
|
|
|
12797
13142
|
* });
|
|
12798
13143
|
* ```
|
|
12799
13144
|
*/
|
|
12800
|
-
var
|
|
13145
|
+
var imagedir = function imagedir(dir) {
|
|
13146
|
+
for (var _len = arguments.length, _ref = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
13147
|
+
_ref[_key - 1] = arguments[_key];
|
|
13148
|
+
}
|
|
13149
|
+
var options = _ref[0];
|
|
13150
|
+
return imagedirOf(dir, options);
|
|
13151
|
+
};
|
|
13152
|
+
function imagedirOf(dir, options) {
|
|
12801
13153
|
var _options$alt, _options$accept;
|
|
12802
|
-
|
|
12803
|
-
// `options.alt` is `Alt | undefined`, and the fallback is exactly the schema
|
|
13154
|
+
// `options?.alt` is `Alt | undefined`, and the fallback is exactly the schema
|
|
12804
13155
|
// `Alt` defaults to when `alt` is omitted. TypeScript will not narrow a type
|
|
12805
13156
|
// parameter from the absence of a value, so it cannot see that the two agree,
|
|
12806
13157
|
// and the fallback is asserted here.
|
|
12807
13158
|
//
|
|
12808
|
-
// Sound, not merely convenient: `
|
|
12809
|
-
// unless `Alt` is the default,
|
|
13159
|
+
// Sound, not merely convenient: `ImagedirAltOption` makes `alt` REQUIRED
|
|
13160
|
+
// unless `Alt` is the default, and `ImagedirOptionsArg` makes the options
|
|
13161
|
+
// object required with it, so this branch is unreachable for any other
|
|
12810
13162
|
// `Alt`. The one assertion in this file, and it replaces the wider one that
|
|
12811
13163
|
// used to sit on the ObjectSchema below.
|
|
12812
|
-
var altSchema = (_options$alt = options.alt) !== null && _options$alt !== void 0 ? _options$alt : string().nullable();
|
|
13164
|
+
var altSchema = (_options$alt = options === null || options === void 0 ? void 0 : options.alt) !== null && _options$alt !== void 0 ? _options$alt : string().nullable();
|
|
12813
13165
|
var itemSchema = new ObjectSchema({
|
|
12814
13166
|
width: new NumberSchema(undefined, false),
|
|
12815
13167
|
height: new NumberSchema(undefined, false),
|
|
@@ -12818,19 +13170,57 @@ var imageset = function imageset(options) {
|
|
|
12818
13170
|
}, false);
|
|
12819
13171
|
return new RecordSchema(itemSchema, false, [], null, null, {
|
|
12820
13172
|
type: "images",
|
|
12821
|
-
accept: (_options$accept = options.accept) !== null && _options$accept !== void 0 ? _options$accept : "image/*",
|
|
13173
|
+
accept: (_options$accept = options === null || options === void 0 ? void 0 : options.accept) !== null && _options$accept !== void 0 ? _options$accept : "image/*",
|
|
12822
13174
|
dir: dir,
|
|
12823
13175
|
remote: false,
|
|
12824
13176
|
altSchema: altSchema,
|
|
12825
|
-
encode: options.encode
|
|
13177
|
+
encode: options === null || options === void 0 ? void 0 : options.encode
|
|
12826
13178
|
});
|
|
13179
|
+
}
|
|
13180
|
+
|
|
13181
|
+
/**
|
|
13182
|
+
* `s.imagedir()` with `.remote()` applied: what `s.imagedir` is under
|
|
13183
|
+
* `files: { remote: true }`.
|
|
13184
|
+
*/
|
|
13185
|
+
var remoteImagedir = function remoteImagedir(dir) {
|
|
13186
|
+
for (var _len2 = arguments.length, _ref2 = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
13187
|
+
_ref2[_key2 - 1] = arguments[_key2];
|
|
13188
|
+
}
|
|
13189
|
+
var options = _ref2[0];
|
|
13190
|
+
return imagedirOf(dir, options).remote();
|
|
12827
13191
|
};
|
|
12828
13192
|
|
|
12829
13193
|
/**
|
|
12830
|
-
*
|
|
13194
|
+
* Define a collection of images.
|
|
13195
|
+
*
|
|
13196
|
+
* @deprecated Use `s.imagedir(dir, options)`: the directory moved out of the
|
|
13197
|
+
* options and into the first argument, and nothing else changed.
|
|
13198
|
+
*
|
|
13199
|
+
* @example
|
|
13200
|
+
* ```typescript
|
|
13201
|
+
* // was: s.imageset({ dir: "/public/val/images", accept: "image/webp" })
|
|
13202
|
+
* const schema = s.imagedir("/public/val/images", { accept: "image/webp" });
|
|
13203
|
+
* ```
|
|
12831
13204
|
*/
|
|
13205
|
+
var imageset = function imageset(options) {
|
|
13206
|
+
return imagedirOf(options.dir, options);
|
|
13207
|
+
};
|
|
13208
|
+
|
|
13209
|
+
/**
|
|
13210
|
+
* Options for `s.videodir(dir, options)`: everything but the directory, which
|
|
13211
|
+
* is the first argument.
|
|
13212
|
+
*/
|
|
13213
|
+
|
|
13214
|
+
/**
|
|
13215
|
+
* Options for the deprecated `s.videoset(options)`, which took the directory
|
|
13216
|
+
* as `dir`.
|
|
13217
|
+
*
|
|
13218
|
+
* @deprecated Use `s.videodir(dir, options)` and `VideodirOptions`.
|
|
13219
|
+
*/
|
|
13220
|
+
|
|
13221
|
+
/** See `ImagedirAltOption`: `alt` is optional only when it is the default. */
|
|
12832
13222
|
|
|
12833
|
-
/** See `
|
|
13223
|
+
/** See `ImagedirOptionsArg`: the options are optional only when `alt` is. */
|
|
12834
13224
|
|
|
12835
13225
|
/**
|
|
12836
13226
|
* One video of a set, keyed by its file path (an HLS stream by its master
|
|
@@ -12848,19 +13238,22 @@ var imageset = function imageset(options) {
|
|
|
12848
13238
|
* still for the gallery, because two stills of one video would disagree.
|
|
12849
13239
|
*/
|
|
12850
13240
|
|
|
13241
|
+
/** @deprecated Use `VideodirEntryMetadata`. */
|
|
13242
|
+
|
|
13243
|
+
/** @deprecated Use `SerializedVideodirSchema`. */
|
|
13244
|
+
|
|
12851
13245
|
/**
|
|
12852
|
-
* Define a
|
|
13246
|
+
* Define a directory of videos — the video twin of `s.imagedir()`.
|
|
12853
13247
|
*
|
|
12854
13248
|
* A field picks from it with `s.video(videosVal)`. An entry may hold the
|
|
12855
13249
|
* description, poster, start and end, focal point and captions as defaults,
|
|
12856
13250
|
* and a field overrides any of them by setting its own. Uploading in such a
|
|
12857
|
-
* field adds to the
|
|
12858
|
-
*
|
|
13251
|
+
* field adds to the directory. Call `.remote()` on the result to store the
|
|
13252
|
+
* videos on Val Remote.
|
|
12859
13253
|
*
|
|
12860
13254
|
* @example
|
|
12861
13255
|
* ```typescript
|
|
12862
|
-
* const schema = s.
|
|
12863
|
-
* dir: "/public/val/videos",
|
|
13256
|
+
* const schema = s.videodir("/public/val/videos", {
|
|
12864
13257
|
* stream: { type: "hls" },
|
|
12865
13258
|
* });
|
|
12866
13259
|
* export default c.define("/content/videos.val.ts", schema, {
|
|
@@ -12875,11 +13268,46 @@ var imageset = function imageset(options) {
|
|
|
12875
13268
|
* });
|
|
12876
13269
|
* ```
|
|
12877
13270
|
*/
|
|
13271
|
+
var videodir = function videodir(dir) {
|
|
13272
|
+
for (var _len = arguments.length, _ref = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
13273
|
+
_ref[_key - 1] = arguments[_key];
|
|
13274
|
+
}
|
|
13275
|
+
var options = _ref[0];
|
|
13276
|
+
return videodirOf(dir, options);
|
|
13277
|
+
};
|
|
13278
|
+
|
|
13279
|
+
/**
|
|
13280
|
+
* `s.videodir()` with `.remote()` applied: what `s.videodir` is under
|
|
13281
|
+
* `files: { remote: true }`.
|
|
13282
|
+
*/
|
|
13283
|
+
var remoteVideodir = function remoteVideodir(dir) {
|
|
13284
|
+
for (var _len2 = arguments.length, _ref2 = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
13285
|
+
_ref2[_key2 - 1] = arguments[_key2];
|
|
13286
|
+
}
|
|
13287
|
+
var options = _ref2[0];
|
|
13288
|
+
return videodirOf(dir, options).remote();
|
|
13289
|
+
};
|
|
13290
|
+
|
|
13291
|
+
/**
|
|
13292
|
+
* Define a collection of videos.
|
|
13293
|
+
*
|
|
13294
|
+
* @deprecated Use `s.videodir(dir, options)`: the directory moved out of the
|
|
13295
|
+
* options and into the first argument, and nothing else changed.
|
|
13296
|
+
*
|
|
13297
|
+
* @example
|
|
13298
|
+
* ```typescript
|
|
13299
|
+
* // was: s.videoset({ dir: "/public/val/videos", stream: { type: "hls" } })
|
|
13300
|
+
* const schema = s.videodir("/public/val/videos", { stream: { type: "hls" } });
|
|
13301
|
+
* ```
|
|
13302
|
+
*/
|
|
12878
13303
|
var videoset = function videoset(options) {
|
|
13304
|
+
return videodirOf(options.dir, options);
|
|
13305
|
+
};
|
|
13306
|
+
function videodirOf(dir, options) {
|
|
12879
13307
|
var _options$alt, _options$accept;
|
|
12880
|
-
// The same assertion as in `
|
|
12881
|
-
// `
|
|
12882
|
-
var altSchema = (_options$alt = options.alt) !== null && _options$alt !== void 0 ? _options$alt : string().nullable();
|
|
13308
|
+
// The same assertion as in `imagedir()`, and sound for the same reason:
|
|
13309
|
+
// `VideodirAltOption` makes `alt` required unless `Alt` is the default.
|
|
13310
|
+
var altSchema = (_options$alt = options === null || options === void 0 ? void 0 : options.alt) !== null && _options$alt !== void 0 ? _options$alt : string().nullable();
|
|
12883
13311
|
var itemSchema = new ObjectSchema({
|
|
12884
13312
|
mimeType: new StringSchema({}, false),
|
|
12885
13313
|
width: new NumberSchema(undefined, false),
|
|
@@ -12889,13 +13317,13 @@ var videoset = function videoset(options) {
|
|
|
12889
13317
|
}, false);
|
|
12890
13318
|
return new RecordSchema(itemSchema, false, [], null, null, {
|
|
12891
13319
|
type: "videos",
|
|
12892
|
-
accept: (_options$accept = options.accept) !== null && _options$accept !== void 0 ? _options$accept : DEFAULT_VIDEO_ACCEPT,
|
|
12893
|
-
dir:
|
|
13320
|
+
accept: (_options$accept = options === null || options === void 0 ? void 0 : options.accept) !== null && _options$accept !== void 0 ? _options$accept : DEFAULT_VIDEO_ACCEPT,
|
|
13321
|
+
dir: dir,
|
|
12894
13322
|
remote: false,
|
|
12895
13323
|
altSchema: altSchema,
|
|
12896
|
-
stream: options.stream
|
|
13324
|
+
stream: options === null || options === void 0 ? void 0 : options.stream
|
|
12897
13325
|
});
|
|
12898
|
-
}
|
|
13326
|
+
}
|
|
12899
13327
|
|
|
12900
13328
|
/**
|
|
12901
13329
|
* The video schema a set's entry is hashed against, for a remote ref.
|
|
@@ -12934,6 +13362,14 @@ function initSchema(options) {
|
|
|
12934
13362
|
font: remoteFont,
|
|
12935
13363
|
video: remoteVideo,
|
|
12936
13364
|
richtext: remoteRichtext,
|
|
13365
|
+
imagedir: remoteImagedir,
|
|
13366
|
+
filedir: function (dir, options) {
|
|
13367
|
+
return filedir(dir, options).remote();
|
|
13368
|
+
},
|
|
13369
|
+
fontdir: function (dir, options) {
|
|
13370
|
+
return fontdir(dir, options).remote();
|
|
13371
|
+
},
|
|
13372
|
+
videodir: remoteVideodir,
|
|
12937
13373
|
imageset: function (options) {
|
|
12938
13374
|
return imageset(options).remote();
|
|
12939
13375
|
},
|
|
@@ -12952,6 +13388,10 @@ function initSchema(options) {
|
|
|
12952
13388
|
font: font,
|
|
12953
13389
|
video: video,
|
|
12954
13390
|
richtext: richtext,
|
|
13391
|
+
imagedir: imagedir,
|
|
13392
|
+
filedir: filedir,
|
|
13393
|
+
fontdir: fontdir,
|
|
13394
|
+
videodir: videodir,
|
|
12955
13395
|
imageset: imageset,
|
|
12956
13396
|
fileset: fileset,
|
|
12957
13397
|
fontset: fontset,
|
|
@@ -12964,6 +13404,7 @@ function initSchema(options) {
|
|
|
12964
13404
|
array: array,
|
|
12965
13405
|
object: object,
|
|
12966
13406
|
number: number,
|
|
13407
|
+
"int": _int,
|
|
12967
13408
|
discriminatedUnion: discriminatedUnion,
|
|
12968
13409
|
"enum": enumSchema,
|
|
12969
13410
|
union: union,
|
|
@@ -12977,6 +13418,8 @@ function initSchema(options) {
|
|
|
12977
13418
|
file: media.file,
|
|
12978
13419
|
font: media.font,
|
|
12979
13420
|
video: media.video,
|
|
13421
|
+
filedir: media.filedir,
|
|
13422
|
+
fontdir: media.fontdir,
|
|
12980
13423
|
fileset: media.fileset,
|
|
12981
13424
|
fontset: media.fontset,
|
|
12982
13425
|
date: date,
|
|
@@ -12986,6 +13429,8 @@ function initSchema(options) {
|
|
|
12986
13429
|
locale: locale,
|
|
12987
13430
|
route: route,
|
|
12988
13431
|
router: router,
|
|
13432
|
+
imagedir: media.imagedir,
|
|
13433
|
+
videodir: media.videodir,
|
|
12989
13434
|
imageset: media.imageset,
|
|
12990
13435
|
videoset: media.videoset,
|
|
12991
13436
|
settings: settings
|
|
@@ -14082,7 +14527,7 @@ function _extractValModules() {
|
|
|
14082
14527
|
* The one answer to that question. There used to be two — `hasRemoteFileSchema`
|
|
14083
14528
|
* in the server, gating whether `/save` demands remote credentials, and
|
|
14084
14529
|
* `findRequiredRemoteFiles` in the Studio, gating the `/remote/settings` fetch —
|
|
14085
|
-
* and they disagreed about `s.
|
|
14530
|
+
* and they disagreed about `s.imagedir(dir, { ... }).remote()`: the Studio's version
|
|
14086
14531
|
* counted a remote media record, the server's did not, because a media
|
|
14087
14532
|
* collection serializes as a `record` of metadata rather than as an image
|
|
14088
14533
|
* schema.
|
|
@@ -14122,7 +14567,7 @@ function hasRemoteFileSchema(schema) {
|
|
|
14122
14567
|
return hasRemoteFileSchema(schema.item);
|
|
14123
14568
|
} else if (schema.type === "record") {
|
|
14124
14569
|
/**
|
|
14125
|
-
* A media collection — `s.
|
|
14570
|
+
* A media collection — `s.imagedir()` / `s.filedir()` — is the case both of the
|
|
14126
14571
|
* old functions were written around, and the one they disagreed on.
|
|
14127
14572
|
*
|
|
14128
14573
|
* It has no file or image schema inside it to find: `item` is an object of
|
|
@@ -14182,8 +14627,8 @@ function hasRemoteFileSchema(schema) {
|
|
|
14182
14627
|
*
|
|
14183
14628
|
* It is a walk over the SERIALIZED schema for the reasons given above, and for
|
|
14184
14629
|
* one more that is specific to this question: the two cases most likely to be
|
|
14185
|
-
* missed are invisible to a value type. A media collection (`s.
|
|
14186
|
-
* `s.
|
|
14630
|
+
* missed are invisible to a value type. A media collection (`s.imagedir()` /
|
|
14631
|
+
* `s.filedir()`) serializes as a record of metadata with no image schema inside
|
|
14187
14632
|
* it, and a richtext inline image lives in a constructor argument. A check
|
|
14188
14633
|
* written against the item TYPE would silently pass both — and the gallery case
|
|
14189
14634
|
* already has a data-loss incident attached to it (see above).
|
|
@@ -14870,7 +15315,7 @@ function deserializeSchema(serialized) {
|
|
|
14870
15315
|
return schema;
|
|
14871
15316
|
}
|
|
14872
15317
|
function deserializeSchemaImpl(serialized) {
|
|
14873
|
-
var _serialized$options, _serialized$options2, _serialized$multiline, _serialized$render, _serialized$accept, _serialized$dir, _serialized$remote, _serialized$jsonValue, _serialized$
|
|
15318
|
+
var _serialized$options, _serialized$options2, _serialized$multiline, _serialized$render, _serialized$render2, _serialized$accept, _serialized$dir, _serialized$remote, _serialized$jsonValue, _serialized$render3, _serialized$external, _serialized$render4, _serialized$render5, _serialized$remote2, _serialized$readonly, _serialized$hidden;
|
|
14874
15319
|
switch (serialized.type) {
|
|
14875
15320
|
case "string":
|
|
14876
15321
|
return new StringSchema(_objectSpread2(_objectSpread2({}, serialized.options), {}, {
|
|
@@ -14882,7 +15327,7 @@ function deserializeSchemaImpl(serialized) {
|
|
|
14882
15327
|
case "boolean":
|
|
14883
15328
|
return new BooleanSchema(serialized.opt, [], false, false, serialized.description);
|
|
14884
15329
|
case "number":
|
|
14885
|
-
return new NumberSchema(serialized.options, serialized.opt, [], false, false, serialized.description);
|
|
15330
|
+
return new NumberSchema(serialized.options, serialized.opt, [], false, false, serialized.description, null, (_serialized$render = serialized.render) !== null && _serialized$render !== void 0 ? _serialized$render : null);
|
|
14886
15331
|
case "object":
|
|
14887
15332
|
return new ObjectSchema(Object.fromEntries(Object.entries(serialized.items).map(function (_ref) {
|
|
14888
15333
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
@@ -14905,7 +15350,7 @@ function deserializeSchemaImpl(serialized) {
|
|
|
14905
15350
|
case "array":
|
|
14906
15351
|
return new ArraySchema(deserializeSchema(serialized.item), serialized.opt, [], false, false, serialized.description,
|
|
14907
15352
|
// The preview closure cannot survive serialization; the render can.
|
|
14908
|
-
null, (_serialized$
|
|
15353
|
+
null, (_serialized$render2 = serialized.render) !== null && _serialized$render2 !== void 0 ? _serialized$render2 : null);
|
|
14909
15354
|
case "discriminated-union":
|
|
14910
15355
|
return new DiscriminatedUnionSchema(serialized.key,
|
|
14911
15356
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -14934,12 +15379,12 @@ function deserializeSchemaImpl(serialized) {
|
|
|
14934
15379
|
altSchema: serialized.alt ? deserializeSchema(serialized.alt) : undefined
|
|
14935
15380
|
} : undefined, false, false, serialized.description, (_serialized$jsonValue = serialized.jsonValues) !== null && _serialized$jsonValue !== void 0 ? _serialized$jsonValue : false,
|
|
14936
15381
|
// The preview closure cannot survive serialization; the render can.
|
|
14937
|
-
null, (_serialized$
|
|
15382
|
+
null, (_serialized$render3 = serialized.render) !== null && _serialized$render3 !== void 0 ? _serialized$render3 : null, // The external label is static data, so it survives serialization and
|
|
14938
15383
|
// must be carried back: a deserialized schema that forgot it would walk
|
|
14939
15384
|
// an external record as if its entries were local.
|
|
14940
15385
|
(_serialized$external = serialized.external) !== null && _serialized$external !== void 0 ? _serialized$external : null);
|
|
14941
15386
|
case "keyOf":
|
|
14942
|
-
return new KeyOfSchema(serialized.schema, serialized.path, serialized.opt, [], false, false, serialized.description, (_serialized$
|
|
15387
|
+
return new KeyOfSchema(serialized.schema, serialized.path, serialized.opt, [], false, false, serialized.description, (_serialized$render4 = serialized.render) !== null && _serialized$render4 !== void 0 ? _serialized$render4 : null);
|
|
14943
15388
|
case "locale":
|
|
14944
15389
|
{
|
|
14945
15390
|
return new LocaleSchema(serialized.opt, [], false, false, serialized.description);
|
|
@@ -14957,7 +15402,7 @@ function deserializeSchemaImpl(serialized) {
|
|
|
14957
15402
|
case "image":
|
|
14958
15403
|
return new ImageSchema(serialized.options, serialized.opt, serialized.remote, [], {}, false, false, serialized.description);
|
|
14959
15404
|
case "video":
|
|
14960
|
-
return new VideoSchema(serialized.options, serialized.opt, serialized.remote, [], false, false, serialized.description, (_serialized$
|
|
15405
|
+
return new VideoSchema(serialized.options, serialized.opt, serialized.remote, [], false, false, serialized.description, (_serialized$render5 = serialized.render) !== null && _serialized$render5 !== void 0 ? _serialized$render5 : null, null, serialized.referencedModule ? {
|
|
14961
15406
|
modulePath: serialized.referencedModule,
|
|
14962
15407
|
entries: null,
|
|
14963
15408
|
remote: (_serialized$remote2 = serialized.remote) !== null && _serialized$remote2 !== void 0 ? _serialized$remote2 : false
|
|
@@ -15016,11 +15461,12 @@ function deserializeSchemaImpl(serialized) {
|
|
|
15016
15461
|
*/
|
|
15017
15462
|
/**
|
|
15018
15463
|
* A RENDER is how a field is laid out in the editor, and it applies only when
|
|
15019
|
-
* you are looking at the field.
|
|
15020
|
-
* children, never by a child about itself: `s.array(item).render({ as: "inline" })`
|
|
15021
|
-
* and `s.record(item).render({ as: "inline" })`.
|
|
15022
|
-
*
|
|
15023
|
-
* `KeyOfSchema.render`).
|
|
15464
|
+
* you are looking at the field. On a list it is declared by the CONTAINER about
|
|
15465
|
+
* its children, never by a child about itself: `s.array(item).render({ as: "inline" })`
|
|
15466
|
+
* and `s.record(item).render({ as: "inline" })`. Two other schemas take a
|
|
15467
|
+
* render, each meaning something of its own: `s.keyOf(...)` (see
|
|
15468
|
+
* `KeyOfSchema.render`) and `s.number()` / `s.int()`, whose `{ as: "slider" }`
|
|
15469
|
+
* is a different input for the same value (see {@link SliderRender}).
|
|
15024
15470
|
*
|
|
15025
15471
|
* Why the container: inline is a property of the LIST — "my items are edited in
|
|
15026
15472
|
* their rows" — and the item schema is the wrong place to say it. An item can be
|
|
@@ -15064,7 +15510,7 @@ function deserializeSchemaImpl(serialized) {
|
|
|
15064
15510
|
* `s.array(s.object({ tags: s.array(s.string()) })).render({ as: "inline" })`
|
|
15065
15511
|
* the objects are inline and `tags` keeps its own default.
|
|
15066
15512
|
*
|
|
15067
|
-
* Not available on `s.router(...)`, `s.
|
|
15513
|
+
* Not available on `s.router(...)`, `s.imagedir(...)` or `s.filedir(...)`:
|
|
15068
15514
|
* pages and media have UIs of their own, and `RecordSchema.render` throws there.
|
|
15069
15515
|
*
|
|
15070
15516
|
* On `s.keyOf(...)` the same value means something else: the selected entry's
|
|
@@ -15076,6 +15522,33 @@ function deserializeSchemaImpl(serialized) {
|
|
|
15076
15522
|
* What `.render(...)` takes, and what the serialized schema carries verbatim.
|
|
15077
15523
|
*/
|
|
15078
15524
|
|
|
15525
|
+
/**
|
|
15526
|
+
* `{ as: "slider", min, max }` on `s.int()` or `s.number()`: the value is
|
|
15527
|
+
* edited with a slider from `min` to `max`, next to a box that takes a typed
|
|
15528
|
+
* value.
|
|
15529
|
+
*
|
|
15530
|
+
* `min` and `max` are REQUIRED, because a slider without ends is not a slider.
|
|
15531
|
+
* They are the slider's own and are not validation: a value outside them is
|
|
15532
|
+
* still valid content (if the schema allows it), and the field says it is out
|
|
15533
|
+
* of the slider's reach and offers to bring it back. What the schema accepts is
|
|
15534
|
+
* `.min()`, `.max()` and `.step()` on the schema itself.
|
|
15535
|
+
*
|
|
15536
|
+
* The one rule tying the two together: **the slider may only produce values
|
|
15537
|
+
* the schema accepts.** So its range has to lie inside the schema's, its step
|
|
15538
|
+
* has to be a multiple of the schema's step and its `min` on the schema's grid,
|
|
15539
|
+
* and on `s.int()` all of them have to be whole numbers. A schema that breaks
|
|
15540
|
+
* that throws where it is defined — see `NumberSchema`.
|
|
15541
|
+
*
|
|
15542
|
+
* `step` defaults to the schema's `.step()`, and to 1 when there is none.
|
|
15543
|
+
*
|
|
15544
|
+
* Unlike `inline` this is about the field itself — no list reads it, and
|
|
15545
|
+
* {@link isInlineRender} answers `false` for it.
|
|
15546
|
+
*/
|
|
15547
|
+
|
|
15548
|
+
/**
|
|
15549
|
+
* What `s.number().render(...)` and `s.int().render(...)` take.
|
|
15550
|
+
*/
|
|
15551
|
+
|
|
15079
15552
|
/**
|
|
15080
15553
|
* Does this CONTAINER edit its items inside their list rows, rather than behind
|
|
15081
15554
|
* clickable preview rows that navigate to them?
|
|
@@ -15657,7 +16130,7 @@ function isPageRouter(routerId) {
|
|
|
15657
16130
|
|
|
15658
16131
|
var corePackageJson = {
|
|
15659
16132
|
name: "@valbuild/core",
|
|
15660
|
-
version: "0.
|
|
16133
|
+
version: "0.145.0",
|
|
15661
16134
|
"private": false,
|
|
15662
16135
|
description: "Val - supercharged hard-coded content",
|
|
15663
16136
|
repository: {
|
|
@@ -15763,6 +16236,7 @@ var Internal = {
|
|
|
15763
16236
|
fillFromGallery: fillFromGallery,
|
|
15764
16237
|
galleriesOf: galleriesOf,
|
|
15765
16238
|
galleryEntryOf: galleryEntryOf,
|
|
16239
|
+
galleryKeyOf: galleryKeyOf,
|
|
15766
16240
|
GALLERY_DEFAULT_GROUPS: GALLERY_DEFAULT_GROUPS,
|
|
15767
16241
|
isHlsVideo: isHlsVideo,
|
|
15768
16242
|
HLS_MIME_TYPE: HLS_MIME_TYPE
|
|
@@ -15783,6 +16257,11 @@ var Internal = {
|
|
|
15783
16257
|
rejectScheme: rejectScheme,
|
|
15784
16258
|
schemeOf: schemeOf,
|
|
15785
16259
|
UNSAFE_URL_SCHEMES: UNSAFE_URL_SCHEMES,
|
|
16260
|
+
number: {
|
|
16261
|
+
nearestAllowedNumber: nearestAllowedNumber,
|
|
16262
|
+
isOnStep: isOnStep,
|
|
16263
|
+
stepOrigin: stepOrigin
|
|
16264
|
+
},
|
|
15786
16265
|
color: {
|
|
15787
16266
|
parseColor: parseColor,
|
|
15788
16267
|
formatColor: formatColor,
|