@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.
Files changed (29) hide show
  1. package/CHANGELOG.md +67 -0
  2. package/dist/declarations/src/index.d.ts +13 -4
  3. package/dist/declarations/src/initSchema.d.ts +108 -18
  4. package/dist/declarations/src/initVal.d.ts +2 -2
  5. package/dist/declarations/src/mimeType/font.d.ts +36 -0
  6. package/dist/declarations/src/mimeType/index.d.ts +1 -0
  7. package/dist/declarations/src/render.d.ts +1 -1
  8. package/dist/declarations/src/schema/file.d.ts +4 -4
  9. package/dist/declarations/src/schema/filedir.d.ts +83 -0
  10. package/dist/declarations/src/schema/font.d.ts +16 -0
  11. package/dist/declarations/src/schema/fontdir.d.ts +63 -0
  12. package/dist/declarations/src/schema/hasRemoteFileSchema.d.ts +3 -3
  13. package/dist/declarations/src/schema/image.d.ts +4 -4
  14. package/dist/declarations/src/schema/{imageset.d.ts → imagedir.d.ts} +63 -29
  15. package/dist/declarations/src/schema/record.d.ts +17 -6
  16. package/dist/declarations/src/schema/video.d.ts +7 -7
  17. package/dist/declarations/src/schema/{videoset.d.ts → videodir.d.ts} +55 -27
  18. package/dist/declarations/src/source/media.d.ts +26 -3
  19. package/dist/{index-13cf45b1.cjs.prod.js → index-2d194c90.cjs.prod.js} +504 -79
  20. package/dist/{index-fae161b5.cjs.dev.js → index-8b22b2c1.cjs.dev.js} +504 -79
  21. package/dist/{index-a6c53286.esm.js → index-aa16dd90.esm.js} +503 -80
  22. package/dist/valbuild-core.cjs.dev.js +3 -1
  23. package/dist/valbuild-core.cjs.prod.js +3 -1
  24. package/dist/valbuild-core.esm.js +1 -1
  25. package/package.json +1 -1
  26. package/patch/dist/valbuild-core-patch.cjs.dev.js +1 -1
  27. package/patch/dist/valbuild-core-patch.cjs.prod.js +1 -1
  28. package/patch/dist/valbuild-core-patch.esm.js +2 -2
  29. package/dist/declarations/src/schema/fileset.d.ts +0 -57
@@ -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.videoset()`
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.videoset()`) carries them as DEFAULTS, which every field picked from the
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 in moduleSource ? src.path : null;
3031
- if (key === null) {
3032
- var splitRemoteRefRes = splitRemoteRef(src.path);
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
  }
@@ -3602,7 +3636,7 @@ var EXT_TO_MIME_TYPES = {
3602
3636
  sxw: "application/vnd.sun.xml.writer",
3603
3637
  sxg: "application/vnd.sun.xml.writer.global",
3604
3638
  stw: "application/vnd.sun.xml.writer.template",
3605
- otf: "application/x-font-otf",
3639
+ otf: "font/otf",
3606
3640
  osfpvg: "application/vnd.yamaha.openscoreformat.osfpvg+xml",
3607
3641
  dp: "application/vnd.osgi.dp",
3608
3642
  pdb: "application/vnd.palm",
@@ -3752,7 +3786,8 @@ var EXT_TO_MIME_TYPES = {
3752
3786
  mxs: "application/vnd.triscape.mxs",
3753
3787
  t: "text/troff",
3754
3788
  tra: "application/vnd.trueapp",
3755
- ttf: "application/x-font-ttf",
3789
+ ttf: "font/ttf",
3790
+ ttc: "font/collection",
3756
3791
  ttl: "text/turtle",
3757
3792
  umj: "application/vnd.umajin",
3758
3793
  uoml: "application/vnd.uoml+xml",
@@ -3779,7 +3814,8 @@ var EXT_TO_MIME_TYPES = {
3779
3814
  wbmp: "image/vnd.wap.wbmp",
3780
3815
  wav: "audio/x-wav",
3781
3816
  davmount: "application/davmount+xml",
3782
- woff: "application/x-font-woff",
3817
+ woff: "font/woff",
3818
+ woff2: "font/woff2",
3783
3819
  wspolicy: "application/wspolicy+xml",
3784
3820
  webp: "image/webp",
3785
3821
  wtb: "application/vnd.webturbo",
@@ -3881,6 +3917,93 @@ function mimeTypeMatchesAccept(mimeType, accept) {
3881
3917
  });
3882
3918
  }
3883
3919
 
3920
+ /**
3921
+ * Fonts, as far as a mime type can tell.
3922
+ *
3923
+ * The four web formats have IANA types under `font/` (RFC 8081), and those are
3924
+ * what Val stores. Browsers and operating systems disagree about them: a file
3925
+ * picker reports `.woff2` as `font/woff2`, `application/font-woff2` or nothing
3926
+ * at all depending on the platform, and nothing at all reads as
3927
+ * `application/octet-stream` once the file is a data URL. That is why an upload
3928
+ * asks the BYTES ({@link sniffFontMimeType}) rather than trusting the picker.
3929
+ */
3930
+
3931
+ /** The formats `s.fontdir()` accepts unless told otherwise, best first. */
3932
+ var FONT_MIME_TYPES = ["font/woff2", "font/woff", "font/ttf", "font/otf"];
3933
+
3934
+ /** `s.fontdir()`'s `accept` when none is given. */
3935
+ var DEFAULT_FONT_ACCEPT = FONT_MIME_TYPES.join(",");
3936
+
3937
+ /**
3938
+ * The extension of each font type, for a file input: a picker matches an
3939
+ * `accept` of mime types through the operating system's own table, and where
3940
+ * that table does not know `font/woff2` the file is greyed out.
3941
+ */
3942
+ var FONT_MIME_TYPE_EXTENSIONS = {
3943
+ "font/woff2": ".woff2",
3944
+ "font/woff": ".woff",
3945
+ "font/ttf": ".ttf",
3946
+ "font/otf": ".otf",
3947
+ "font/collection": ".ttc"
3948
+ };
3949
+
3950
+ /**
3951
+ * The names the extension table used for fonts before it used RFC 8081's.
3952
+ * Content written then still carries them, and it is the same file.
3953
+ */
3954
+ var LEGACY_FONT_MIME_TYPES = {
3955
+ "application/x-font-ttf": "font/ttf",
3956
+ "application/x-font-otf": "font/otf",
3957
+ "application/x-font-woff": "font/woff"
3958
+ };
3959
+
3960
+ /** `mimeType`, with a legacy font name read as its `font/` type. */
3961
+ function canonicalFontMimeType(mimeType) {
3962
+ var _LEGACY_FONT_MIME_TYP;
3963
+ return (_LEGACY_FONT_MIME_TYP = LEGACY_FONT_MIME_TYPES[mimeType]) !== null && _LEGACY_FONT_MIME_TYP !== void 0 ? _LEGACY_FONT_MIME_TYP : mimeType;
3964
+ }
3965
+
3966
+ /**
3967
+ * Whether a file of `mimeType` is a font a browser can draw: the `font/` types,
3968
+ * and the pre-RFC 8081 names still found in older data.
3969
+ */
3970
+ function isFontMimeType(mimeType) {
3971
+ if (!mimeType) {
3972
+ return false;
3973
+ }
3974
+ 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";
3975
+ }
3976
+
3977
+ /**
3978
+ * The font type of `bytes`, read from the signature every font format starts
3979
+ * with, or `null` when they are not a font.
3980
+ *
3981
+ * Only the first four bytes are needed: the WOFF signatures (`wOFF`, `wOF2`),
3982
+ * the SFNT versions of TrueType (`0x00010000`, or `true` from old Apple fonts)
3983
+ * and of CFF-flavoured OpenType (`OTTO`), and a collection's tag (`ttcf`).
3984
+ */
3985
+ function sniffFontMimeType(bytes) {
3986
+ if (bytes.length < 4) {
3987
+ return null;
3988
+ }
3989
+ var tag = String.fromCharCode(bytes[0], bytes[1], bytes[2], bytes[3]);
3990
+ switch (tag) {
3991
+ case "wOF2":
3992
+ return "font/woff2";
3993
+ case "wOFF":
3994
+ return "font/woff";
3995
+ case "OTTO":
3996
+ return "font/otf";
3997
+ case "true":
3998
+ case "\0\x01\0\0":
3999
+ return "font/ttf";
4000
+ case "ttcf":
4001
+ return "font/collection";
4002
+ default:
4003
+ return null;
4004
+ }
4005
+ }
4006
+
3884
4007
  /**
3885
4008
  * How an uploaded image is re-encoded in the browser, before it is uploaded.
3886
4009
  *
@@ -4047,24 +4170,31 @@ var ImageSchema = /*#__PURE__*/function (_Schema) {
4047
4170
  value: src
4048
4171
  }]));
4049
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();
4050
4180
  // Remote-ness is a property of the path, not of a marker on the value:
4051
4181
  // anything outside /public is remote.
4052
4182
  var isRemotePath = isRemoteMediaPath(src.path);
4053
- if (this.isRemote && !isRemotePath) {
4183
+ if (!galleryEntries && this.isRemote && !isRemotePath) {
4054
4184
  return _defineProperty({}, path, [].concat(_toConsumableArray(customValidationErrors), [{
4055
4185
  message: "Expected a remote image, but got a local image.",
4056
4186
  value: src,
4057
4187
  fixes: ["image:upload-remote"]
4058
4188
  }]));
4059
4189
  }
4060
- if (this.isRemote && isRemotePath) {
4190
+ if (!galleryEntries && this.isRemote && isRemotePath) {
4061
4191
  return _defineProperty({}, path, [].concat(_toConsumableArray(customValidationErrors), [{
4062
4192
  message: "Remote image was not checked.",
4063
4193
  value: src,
4064
4194
  fixes: ["image:check-remote"]
4065
4195
  }]));
4066
4196
  }
4067
- if (!this.isRemote && isRemotePath) {
4197
+ if (!galleryEntries && !this.isRemote && isRemotePath) {
4068
4198
  return _defineProperty({}, path, [].concat(_toConsumableArray(customValidationErrors), [{
4069
4199
  message: "Expected local image, but found remote.",
4070
4200
  value: src,
@@ -4079,7 +4209,6 @@ var ImageSchema = /*#__PURE__*/function (_Schema) {
4079
4209
  }]));
4080
4210
  }
4081
4211
  }
4082
- var galleryEntries = this.galleryEntries();
4083
4212
  if (galleryEntries) {
4084
4213
  // The dimensions and mime type of a gallery image are stored once, in the
4085
4214
  // gallery. Repeating them on the field is how the two get to disagree.
@@ -4092,7 +4221,11 @@ var ImageSchema = /*#__PURE__*/function (_Schema) {
4092
4221
  value: src
4093
4222
  }]));
4094
4223
  }
4095
- if (!(src.path in galleryEntries)) {
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) {
4096
4229
  return _defineProperty({}, path, [].concat(_toConsumableArray(customValidationErrors), [{
4097
4230
  message: "The gallery does not have an image at '".concat(src.path, "'."),
4098
4231
  value: src
@@ -5709,7 +5842,7 @@ function missingDeclaredKeys(declared, present) {
5709
5842
  /**
5710
5843
  * The checks of what one page chose about a video — its times, focal point,
5711
5844
  * poster and captions — shared by the two places those choices are made: a
5712
- * field (`s.video()`) and the entry of a set (`s.videoset()`), which holds the
5845
+ * field (`s.video()`) and the entry of a set (`s.videodir()`), which holds the
5713
5846
  * same choices as the defaults every field picked from it starts from.
5714
5847
  */
5715
5848
 
@@ -5887,7 +6020,25 @@ function isObject(value) {
5887
6020
  return _typeof(value) === "object" && value !== null && !Array.isArray(value);
5888
6021
  }
5889
6022
 
5890
- /** What a media collection (`s.imageset`, `s.fileset`, `s.videoset`) holds. */
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
+ };
5891
6042
 
5892
6043
  /**
5893
6044
  * The fix code a media collection of `type` reports for `check`.
@@ -5922,7 +6073,7 @@ function assertRenderable(router, mediaOptions, render) {
5922
6073
  throw new Error("`.render(...)` is not supported on `s.router(...)`: a router's entries are pages, which have their own UI.");
5923
6074
  }
5924
6075
  if (mediaOptions) {
5925
- throw new Error("`.render(...)` is not supported on `s.".concat(mediaOptions.type === "images" ? "imageset" : "fileset", "(...)`: media galleries have their own UI."));
6076
+ throw new Error("`.render(...)` is not supported on `s.".concat(mediaDirFactory[mediaOptions.type], "(...)`: media galleries have their own UI."));
5926
6077
  }
5927
6078
  }
5928
6079
 
@@ -6639,7 +6790,7 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
6639
6790
  * Allow the files in this gallery to be stored on Val's remote content host
6640
6791
  * instead of in your repository.
6641
6792
  *
6642
- * For `s.imageset()` and `s.fileset()`, which are records of media. Remote is off
6793
+ * For `s.imagedir()` and `s.filedir()`, which are records of media. Remote is off
6643
6794
  * until this is called.
6644
6795
  *
6645
6796
  * Each entry is then keyed by its URL on the content host rather than by a
@@ -6648,7 +6799,7 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
6648
6799
  * upload it and rewrite the key.
6649
6800
  *
6650
6801
  * @example
6651
- * const schema = s.imageset({ dir: "/public/val/images" }).remote();
6802
+ * const schema = s.imagedir("/public/val/images").remote();
6652
6803
  * export default c.define("/content/images.val.ts", schema, {
6653
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":
6654
6805
  * {
@@ -6674,7 +6825,7 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
6674
6825
  * which lets the runtime, the Studio and validation work one entry at a time
6675
6826
  * so a record/router can scale to many thousands of entries.
6676
6827
  *
6677
- * Not supported on image/file galleries (`s.imageset()` / `s.fileset()`).
6828
+ * Not supported on image/file galleries (`s.imagedir()` / `s.filedir()`).
6678
6829
  *
6679
6830
  * Only supported on a module's ROOT record/router — a `.jsonValues()` record
6680
6831
  * nested inside an object/array/record is rejected at startup with a module
@@ -6699,7 +6850,7 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
6699
6850
  key: "jsonValues",
6700
6851
  value: function jsonValues() {
6701
6852
  if (this.mediaOptions) {
6702
- throw new Error(".jsonValues() cannot be used with image/file galleries (s.imageset()/s.fileset())");
6853
+ throw new Error(".jsonValues() cannot be used with image/file galleries (s.imagedir()/s.filedir())");
6703
6854
  }
6704
6855
  if (this.customValidateFunctions.length > 0) {
6705
6856
  // `.jsonValues()` changes the source shape to JsonSource entries, so a
@@ -6728,7 +6879,7 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
6728
6879
  * bucket — instead of in the module.
6729
6880
  *
6730
6881
  * Available on every record-derived schema, which is `s.record()`,
6731
- * `s.router()`, `s.imageset()` and `s.fileset()` alike: a router is a
6882
+ * `s.router()`, `s.imagedir()` and `s.filedir()` alike: a router is a
6732
6883
  * `RecordSchema` with a `ValRouter`, a gallery one with media options, so all
6733
6884
  * four get external storage from this one method.
6734
6885
  *
@@ -7058,7 +7209,7 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
7058
7209
  * draws each entry's own editor in place, labelled by its key, instead of a
7059
7210
  * preview row that navigates to it. It reaches the direct entries only.
7060
7211
  *
7061
- * Not for `s.router(...)`, `s.imageset(...)` or `s.fileset(...)`: pages and
7212
+ * Not for `s.router(...)`, `s.imagedir(...)` or `s.filedir(...)`: pages and
7062
7213
  * media have UIs of their own, so this throws on them.
7063
7214
  *
7064
7215
  * Static configuration, not a callback — see `render.ts`.
@@ -10831,31 +10982,37 @@ var FileSchema = /*#__PURE__*/function (_Schema) {
10831
10982
  value: src
10832
10983
  }]));
10833
10984
  }
10985
+ // A field picked from a gallery holds the gallery's KEY, and whether that
10986
+ // key is a local path or a remote ref is the gallery's to decide — and its
10987
+ // to fix: uploading an entry renames its key, and the fields that hold it
10988
+ // with it. So such a field only asks whether the gallery has it, below.
10989
+ // Asking here as well reported every file picked from a `.remote()`
10990
+ // gallery as one to download, because the field itself is never remote.
10991
+ var galleryEntries = this.galleryEntries();
10834
10992
  // Remote-ness is a property of the path, not of a marker on the value:
10835
10993
  // anything outside /public is remote.
10836
10994
  var isRemotePath = isRemoteMediaPath(src.path);
10837
- if (this.isRemote && !isRemotePath) {
10995
+ if (!galleryEntries && this.isRemote && !isRemotePath) {
10838
10996
  return _defineProperty({}, path, [].concat(_toConsumableArray(customValidationErrors), [{
10839
10997
  message: "Expected a remote file, but got a local file.",
10840
10998
  value: src,
10841
10999
  fixes: ["file:upload-remote"]
10842
11000
  }]));
10843
11001
  }
10844
- if (this.isRemote && isRemotePath) {
11002
+ if (!galleryEntries && this.isRemote && isRemotePath) {
10845
11003
  return _defineProperty({}, path, [].concat(_toConsumableArray(customValidationErrors), [{
10846
11004
  message: "Remote file was not checked.",
10847
11005
  value: src,
10848
11006
  fixes: ["file:check-remote"]
10849
11007
  }]));
10850
11008
  }
10851
- if (!this.isRemote && isRemotePath) {
11009
+ if (!galleryEntries && !this.isRemote && isRemotePath) {
10852
11010
  return _defineProperty({}, path, [].concat(_toConsumableArray(customValidationErrors), [{
10853
11011
  message: "Expected local file, but found remote.",
10854
11012
  value: src,
10855
11013
  fixes: ["file:download-remote"]
10856
11014
  }]));
10857
11015
  }
10858
- var galleryEntries = this.galleryEntries();
10859
11016
  if (galleryEntries) {
10860
11017
  if (src.mimeType !== undefined) {
10861
11018
  return _defineProperty({}, path, [].concat(_toConsumableArray(customValidationErrors), [{
@@ -10863,7 +11020,11 @@ var FileSchema = /*#__PURE__*/function (_Schema) {
10863
11020
  value: src
10864
11021
  }]));
10865
11022
  }
10866
- if (!(src.path in galleryEntries)) {
11023
+ // The same match reading the field makes (`fillFromGallery`): the key,
11024
+ // or the local path inside a ref an upload through the field stored.
11025
+ if (galleryKeyOf(src.path, function (key) {
11026
+ return key in galleryEntries;
11027
+ }) === null) {
10867
11028
  return _defineProperty({}, path, [].concat(_toConsumableArray(customValidationErrors), [{
10868
11029
  message: "The gallery does not have a file at '".concat(src.path, "'."),
10869
11030
  value: src
@@ -10902,7 +11063,9 @@ var FileSchema = /*#__PURE__*/function (_Schema) {
10902
11063
  // fix was offered -- and the `file:add-metadata` branch below could never be
10903
11064
  // reached for any file whose extension is recognized, which is all of them
10904
11065
  // that get this far.
10905
- if (mimeType && fileMimeType !== mimeType) {
11066
+ // A legacy font name (`application/x-font-ttf`) is what the extension
11067
+ // table itself used to say, so it is not a mismatch.
11068
+ if (mimeType && fileMimeType !== canonicalFontMimeType(mimeType)) {
10906
11069
  return _defineProperty({}, path, [].concat(_toConsumableArray(customValidationErrors), [{
10907
11070
  message: "Mime type and file extension not matching. Mime type is '".concat(mimeType, "' but file extension is '").concat(fileMimeType, "'"),
10908
11071
  value: src
@@ -11096,6 +11259,38 @@ function fileOf(remote, options) {
11096
11259
  return new FileSchema(options, false, remote);
11097
11260
  }
11098
11261
 
11262
+ /**
11263
+ * A font picked from an `s.fontdir()`.
11264
+ *
11265
+ * The same field `s.file(fontsVal)` is — it stores `{ path }` and serializes
11266
+ * identically — with one thing more: it refuses a set that is not a font set,
11267
+ * at definition, so a field called a font cannot end up offering PDFs. What the
11268
+ * Studio does with it (a specimen in its parent, the set to pick from when
11269
+ * opened) it does for any file field backed by a font set.
11270
+ */
11271
+ function font(fontsetModule) {
11272
+ assertFontset(fontsetModule);
11273
+ return file(fontsetModule);
11274
+ }
11275
+
11276
+ /** `s.font()` with `.remote()` applied: see `files.remote` in `initSchema`. */
11277
+ function remoteFont(fontsetModule) {
11278
+ assertFontset(fontsetModule);
11279
+ return remoteFile(fontsetModule);
11280
+ }
11281
+ function assertFontset(fontsetModule) {
11282
+ var _getSchema;
11283
+ var modulePath = getValPath(fontsetModule);
11284
+ var serialized = (_getSchema = getSchema(fontsetModule)) === null || _getSchema === void 0 ? void 0 : _getSchema["executeSerialize"]();
11285
+ var accept = (serialized === null || serialized === void 0 ? void 0 : serialized.type) === "record" && serialized.mediaType === "files" ? serialized.accept : undefined;
11286
+ var isFontset = !!accept && accept.split(",").every(function (type) {
11287
+ return isFontMimeType(type.trim());
11288
+ });
11289
+ if (!isFontset) {
11290
+ 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."));
11291
+ }
11292
+ }
11293
+
11099
11294
  /**
11100
11295
  * Turn an upload into an HLS stream, in the browser, before it is uploaded.
11101
11296
  *
@@ -11631,7 +11826,7 @@ function stripQuery(path) {
11631
11826
  }
11632
11827
 
11633
11828
  /**
11634
- * A video picked from a set (`s.videoset()`). What is true of the file —
11829
+ * A video picked from a set (`s.videodir()`). What is true of the file —
11635
11830
  * its type, size and length — lives in the set; the field carries what one
11636
11831
  * page chose about it.
11637
11832
  */
@@ -11666,7 +11861,7 @@ function videoOf(options, galleryOptions) {
11666
11861
  var setSchema = (_options$GetSchema = options[GetSchema]) === null || _options$GetSchema === void 0 ? void 0 : _options$GetSchema["executeSerialize"]();
11667
11862
  if ((setSchema === null || setSchema === void 0 ? void 0 : setSchema.type) !== "record" || setSchema.mediaType !== "videos") {
11668
11863
  var _setSchema$mediaType, _setSchema$type;
11669
- throw new Error("s.video(".concat(modulePath, "): the module must be an s.videoset(). 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", "."));
11864
+ 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", "."));
11670
11865
  }
11671
11866
  return new VideoSchema((galleryOptions === null || galleryOptions === void 0 ? void 0 : galleryOptions.stream) !== undefined ? {
11672
11867
  stream: galleryOptions.stream
@@ -11681,23 +11876,37 @@ function isVideosetModule(value) {
11681
11876
  }
11682
11877
 
11683
11878
  /**
11684
- * Options for s.fileset()
11879
+ * Options for `s.filedir(dir, options)`: everything but the directory, which
11880
+ * is the first argument.
11881
+ */
11882
+
11883
+ /**
11884
+ * Options for the deprecated `s.fileset(options)`, which took the directory
11885
+ * as `dir`.
11886
+ *
11887
+ * @deprecated Use `s.filedir(dir, options)` and `FiledirOptions`.
11685
11888
  */
11686
11889
 
11687
11890
  /**
11688
11891
  * Metadata for a file entry in the files record
11689
11892
  */
11690
11893
 
11894
+ /** @deprecated Use `FiledirEntryMetadata`. */
11895
+
11896
+ /** @deprecated Use `SerializedFiledirSchema`. */
11897
+
11691
11898
  /**
11692
- * Define a collection of files.
11899
+ * Define a directory of files: a whole module that holds many files, keyed by
11900
+ * their file path, that fields pick from with `s.file(filesVal)`.
11693
11901
  *
11694
- * Remote is off by default: call `.remote()` on the result to allow remote files.
11902
+ * The directory is the first argument and is required — it decides where
11903
+ * uploads land. Remote is off by default: call `.remote()` on the result to
11904
+ * allow remote files.
11695
11905
  *
11696
11906
  * @example
11697
11907
  * ```typescript
11698
- * const schema = s.fileset({
11908
+ * const schema = s.filedir("/public/val/documents", {
11699
11909
  * accept: "application/pdf",
11700
- * dir: "/public/val/documents",
11701
11910
  * });
11702
11911
  * export default c.define("/content/documents.val.ts", schema, {
11703
11912
  * "/public/val/documents/report.pdf": {
@@ -11706,8 +11915,7 @@ function isVideosetModule(value) {
11706
11915
  * });
11707
11916
  * ```
11708
11917
  */
11709
- var fileset = function fileset(options) {
11710
- var dir = options.dir;
11918
+ var filedir = function filedir(dir, options) {
11711
11919
  var itemSchema = new ObjectSchema({
11712
11920
  mimeType: new StringSchema({}, false)
11713
11921
  }, false);
@@ -11719,6 +11927,91 @@ var fileset = function fileset(options) {
11719
11927
  });
11720
11928
  };
11721
11929
 
11930
+ /**
11931
+ * Define a collection of files.
11932
+ *
11933
+ * @deprecated Use `s.filedir(dir, options)`: the directory moved out of the
11934
+ * options and into the first argument, and nothing else changed.
11935
+ *
11936
+ * @example
11937
+ * ```typescript
11938
+ * // was: s.fileset({ dir: "/public/val/documents", accept: "application/pdf" })
11939
+ * const schema = s.filedir("/public/val/documents", {
11940
+ * accept: "application/pdf",
11941
+ * });
11942
+ * ```
11943
+ */
11944
+ var fileset = function fileset(options) {
11945
+ return filedir(options.dir, options);
11946
+ };
11947
+
11948
+ /**
11949
+ * Options for `s.fontdir(dir, options)`: everything but the directory, which
11950
+ * is the first argument.
11951
+ */
11952
+
11953
+ /**
11954
+ * Options for the deprecated `s.fontset(options)`, which took the directory
11955
+ * as `dir`.
11956
+ *
11957
+ * @deprecated Use `s.fontdir(dir, options)` and `FontdirOptions`.
11958
+ */
11959
+
11960
+ /**
11961
+ * Define a directory of fonts.
11962
+ *
11963
+ * A fontdir IS a filedir — the same source, the same `s.font(fontsVal)` field
11964
+ * to pick from it, the same checks and fixes — with `accept` defaulting to the
11965
+ * web font formats. What a font gets that any other file does not is decided
11966
+ * by its mime type rather than by the directory: the Studio previews any file
11967
+ * it knows is a font, wherever it is shown.
11968
+ *
11969
+ * Remote is off by default: call `.remote()` on the result to allow remote files.
11970
+ *
11971
+ * @example
11972
+ * ```typescript
11973
+ * const schema = s.fontdir("/public/val/fonts");
11974
+ * export default c.define("/content/fonts.val.ts", schema, {
11975
+ * "/public/val/fonts/inter_a1b2c.woff2": {
11976
+ * mimeType: "font/woff2",
11977
+ * },
11978
+ * });
11979
+ * ```
11980
+ */
11981
+ var fontdir = function fontdir(dir, options) {
11982
+ var _options$accept;
11983
+ var accept = (_options$accept = options === null || options === void 0 ? void 0 : options.accept) !== null && _options$accept !== void 0 ? _options$accept : DEFAULT_FONT_ACCEPT;
11984
+ var notFonts = accept.split(",").map(function (type) {
11985
+ return type.trim();
11986
+ }).filter(function (type) {
11987
+ return !isFontMimeType(type);
11988
+ });
11989
+ if (notFonts.length > 0) {
11990
+ // A fontdir that took a PDF would be a filedir under a name that says
11991
+ // otherwise, and the Studio would draw a specimen of nothing.
11992
+ 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."));
11993
+ }
11994
+ return filedir(dir, {
11995
+ accept: accept
11996
+ });
11997
+ };
11998
+
11999
+ /**
12000
+ * Define a collection of fonts.
12001
+ *
12002
+ * @deprecated Use `s.fontdir(dir, options)`: the directory moved out of the
12003
+ * options and into the first argument, and nothing else changed.
12004
+ *
12005
+ * @example
12006
+ * ```typescript
12007
+ * // was: s.fontset({ dir: "/public/val/fonts" })
12008
+ * const schema = s.fontdir("/public/val/fonts");
12009
+ * ```
12010
+ */
12011
+ var fontset = function fontset(options) {
12012
+ return fontdir(options.dir, options);
12013
+ };
12014
+
11722
12015
  var DateSchema = /*#__PURE__*/function (_Schema) {
11723
12016
  function DateSchema(options) {
11724
12017
  var _this;
@@ -12585,39 +12878,58 @@ function router(router, keyOrItem, maybeItem) {
12585
12878
  /** Every `alt` value any `AltSchema` can produce. */
12586
12879
 
12587
12880
  /**
12588
- * Options for s.imageset()
12881
+ * Options for `s.imagedir(dir, options)`: everything but the directory, which
12882
+ * is the first argument.
12883
+ */
12884
+
12885
+ /**
12886
+ * Options for the deprecated `s.imageset(options)`, which took the directory
12887
+ * as `dir`.
12888
+ *
12889
+ * @deprecated Use `s.imagedir(dir, options)` and `ImagedirOptions`.
12589
12890
  */
12590
12891
 
12591
12892
  /**
12592
12893
  * `alt` is optional only when it is the default schema.
12593
12894
  *
12594
12895
  * Naming a different `Alt` and then leaving `alt` out would make the fallback
12595
- * in `imageset()` a lie — `Alt` would say `s.string()` while the value was a
12896
+ * in `imagedir()` a lie — `Alt` would say `s.string()` while the value was a
12596
12897
  * nullable one. Requiring it in that case is what makes the fallback sound:
12597
12898
  * the branch that uses it is reachable only when `Alt` IS the default.
12598
12899
  */
12599
12900
 
12901
+ /**
12902
+ * The options argument of `s.imagedir()`: optional only when `alt` is, for
12903
+ * the reason `ImagedirAltOption` gives — leaving the whole object out leaves
12904
+ * `alt` out with it.
12905
+ */
12906
+
12600
12907
  /**
12601
12908
  * Metadata for an image entry in the images record.
12602
12909
  *
12603
12910
  * `alt` follows the schema's `alt` option, so it defaults to `string | null`
12604
12911
  * and becomes `string` under `s.string()` or `Record<string, string>` under
12605
- * `s.record(s.string())`. Write `ImagesetEntryMetadata<AltSource>` where a
12912
+ * `s.record(s.string())`. Write `ImagedirEntryMetadata<AltSource>` where a
12606
12913
  * gallery of any alt shape is acceptable.
12607
12914
  */
12608
12915
 
12916
+ /** @deprecated Use `ImagedirEntryMetadata`. */
12917
+
12918
+ /** @deprecated Use `SerializedImagedirSchema`. */
12919
+
12609
12920
  /**
12610
- * Define a collection of images.
12921
+ * Define a directory of images: a whole module that holds many images, keyed
12922
+ * by their file path, that fields pick from with `s.image(galleryVal)`.
12611
12923
  *
12612
- * `directory` is required — it decides where uploads land, so it is not something
12613
- * to be inferred. The rest defaults: any image type (`"image/*"`), nullable alt
12614
- * text, remote disabled. Call `.remote()` on the result to allow remote images.
12924
+ * The directory is the first argument and is required — it decides where
12925
+ * uploads land, so it is not something to be inferred. The rest defaults: any
12926
+ * image type (`"image/*"`), nullable alt text, remote disabled. Call
12927
+ * `.remote()` on the result to allow remote images.
12615
12928
  *
12616
12929
  * @example
12617
12930
  * ```typescript
12618
- * const schema = s.imageset({
12931
+ * const schema = s.imagedir("/public/val/images", {
12619
12932
  * accept: "image/webp",
12620
- * dir: "/public/val/images",
12621
12933
  * alt: s.string().minLength(4),
12622
12934
  * });
12623
12935
  * export default c.define("/content/images.val.ts", schema, {
@@ -12630,19 +12942,26 @@ function router(router, keyOrItem, maybeItem) {
12630
12942
  * });
12631
12943
  * ```
12632
12944
  */
12633
- var imageset = function imageset(options) {
12945
+ var imagedir = function imagedir(dir) {
12946
+ for (var _len = arguments.length, _ref = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
12947
+ _ref[_key - 1] = arguments[_key];
12948
+ }
12949
+ var options = _ref[0];
12950
+ return imagedirOf(dir, options);
12951
+ };
12952
+ function imagedirOf(dir, options) {
12634
12953
  var _options$alt, _options$accept;
12635
- var dir = options.dir;
12636
- // `options.alt` is `Alt | undefined`, and the fallback is exactly the schema
12954
+ // `options?.alt` is `Alt | undefined`, and the fallback is exactly the schema
12637
12955
  // `Alt` defaults to when `alt` is omitted. TypeScript will not narrow a type
12638
12956
  // parameter from the absence of a value, so it cannot see that the two agree,
12639
12957
  // and the fallback is asserted here.
12640
12958
  //
12641
- // Sound, not merely convenient: `ImagesetAltOption` makes `alt` REQUIRED
12642
- // unless `Alt` is the default, so this branch is unreachable for any other
12959
+ // Sound, not merely convenient: `ImagedirAltOption` makes `alt` REQUIRED
12960
+ // unless `Alt` is the default, and `ImagedirOptionsArg` makes the options
12961
+ // object required with it, so this branch is unreachable for any other
12643
12962
  // `Alt`. The one assertion in this file, and it replaces the wider one that
12644
12963
  // used to sit on the ObjectSchema below.
12645
- var altSchema = (_options$alt = options.alt) !== null && _options$alt !== void 0 ? _options$alt : string().nullable();
12964
+ var altSchema = (_options$alt = options === null || options === void 0 ? void 0 : options.alt) !== null && _options$alt !== void 0 ? _options$alt : string().nullable();
12646
12965
  var itemSchema = new ObjectSchema({
12647
12966
  width: new NumberSchema(undefined, false),
12648
12967
  height: new NumberSchema(undefined, false),
@@ -12651,19 +12970,57 @@ var imageset = function imageset(options) {
12651
12970
  }, false);
12652
12971
  return new RecordSchema(itemSchema, false, [], null, null, {
12653
12972
  type: "images",
12654
- accept: (_options$accept = options.accept) !== null && _options$accept !== void 0 ? _options$accept : "image/*",
12973
+ accept: (_options$accept = options === null || options === void 0 ? void 0 : options.accept) !== null && _options$accept !== void 0 ? _options$accept : "image/*",
12655
12974
  dir: dir,
12656
12975
  remote: false,
12657
12976
  altSchema: altSchema,
12658
- encode: options.encode
12977
+ encode: options === null || options === void 0 ? void 0 : options.encode
12659
12978
  });
12979
+ }
12980
+
12981
+ /**
12982
+ * `s.imagedir()` with `.remote()` applied: what `s.imagedir` is under
12983
+ * `files: { remote: true }`.
12984
+ */
12985
+ var remoteImagedir = function remoteImagedir(dir) {
12986
+ for (var _len2 = arguments.length, _ref2 = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
12987
+ _ref2[_key2 - 1] = arguments[_key2];
12988
+ }
12989
+ var options = _ref2[0];
12990
+ return imagedirOf(dir, options).remote();
12660
12991
  };
12661
12992
 
12662
12993
  /**
12663
- * Options for s.videoset()
12994
+ * Define a collection of images.
12995
+ *
12996
+ * @deprecated Use `s.imagedir(dir, options)`: the directory moved out of the
12997
+ * options and into the first argument, and nothing else changed.
12998
+ *
12999
+ * @example
13000
+ * ```typescript
13001
+ * // was: s.imageset({ dir: "/public/val/images", accept: "image/webp" })
13002
+ * const schema = s.imagedir("/public/val/images", { accept: "image/webp" });
13003
+ * ```
12664
13004
  */
13005
+ var imageset = function imageset(options) {
13006
+ return imagedirOf(options.dir, options);
13007
+ };
12665
13008
 
12666
- /** See `ImagesetAltOption`: `alt` is optional only when it is the default. */
13009
+ /**
13010
+ * Options for `s.videodir(dir, options)`: everything but the directory, which
13011
+ * is the first argument.
13012
+ */
13013
+
13014
+ /**
13015
+ * Options for the deprecated `s.videoset(options)`, which took the directory
13016
+ * as `dir`.
13017
+ *
13018
+ * @deprecated Use `s.videodir(dir, options)` and `VideodirOptions`.
13019
+ */
13020
+
13021
+ /** See `ImagedirAltOption`: `alt` is optional only when it is the default. */
13022
+
13023
+ /** See `ImagedirOptionsArg`: the options are optional only when `alt` is. */
12667
13024
 
12668
13025
  /**
12669
13026
  * One video of a set, keyed by its file path (an HLS stream by its master
@@ -12681,19 +13038,22 @@ var imageset = function imageset(options) {
12681
13038
  * still for the gallery, because two stills of one video would disagree.
12682
13039
  */
12683
13040
 
13041
+ /** @deprecated Use `VideodirEntryMetadata`. */
13042
+
13043
+ /** @deprecated Use `SerializedVideodirSchema`. */
13044
+
12684
13045
  /**
12685
- * Define a collection of videos — the video twin of `s.imageset()`.
13046
+ * Define a directory of videos — the video twin of `s.imagedir()`.
12686
13047
  *
12687
13048
  * A field picks from it with `s.video(videosVal)`. An entry may hold the
12688
13049
  * description, poster, start and end, focal point and captions as defaults,
12689
13050
  * and a field overrides any of them by setting its own. Uploading in such a
12690
- * field adds to the set. Call `.remote()` on the result
12691
- * to store the set on Val Remote.
13051
+ * field adds to the directory. Call `.remote()` on the result to store the
13052
+ * videos on Val Remote.
12692
13053
  *
12693
13054
  * @example
12694
13055
  * ```typescript
12695
- * const schema = s.videoset({
12696
- * dir: "/public/val/videos",
13056
+ * const schema = s.videodir("/public/val/videos", {
12697
13057
  * stream: { type: "hls" },
12698
13058
  * });
12699
13059
  * export default c.define("/content/videos.val.ts", schema, {
@@ -12708,11 +13068,46 @@ var imageset = function imageset(options) {
12708
13068
  * });
12709
13069
  * ```
12710
13070
  */
13071
+ var videodir = function videodir(dir) {
13072
+ for (var _len = arguments.length, _ref = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
13073
+ _ref[_key - 1] = arguments[_key];
13074
+ }
13075
+ var options = _ref[0];
13076
+ return videodirOf(dir, options);
13077
+ };
13078
+
13079
+ /**
13080
+ * `s.videodir()` with `.remote()` applied: what `s.videodir` is under
13081
+ * `files: { remote: true }`.
13082
+ */
13083
+ var remoteVideodir = function remoteVideodir(dir) {
13084
+ for (var _len2 = arguments.length, _ref2 = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
13085
+ _ref2[_key2 - 1] = arguments[_key2];
13086
+ }
13087
+ var options = _ref2[0];
13088
+ return videodirOf(dir, options).remote();
13089
+ };
13090
+
13091
+ /**
13092
+ * Define a collection of videos.
13093
+ *
13094
+ * @deprecated Use `s.videodir(dir, options)`: the directory moved out of the
13095
+ * options and into the first argument, and nothing else changed.
13096
+ *
13097
+ * @example
13098
+ * ```typescript
13099
+ * // was: s.videoset({ dir: "/public/val/videos", stream: { type: "hls" } })
13100
+ * const schema = s.videodir("/public/val/videos", { stream: { type: "hls" } });
13101
+ * ```
13102
+ */
12711
13103
  var videoset = function videoset(options) {
13104
+ return videodirOf(options.dir, options);
13105
+ };
13106
+ function videodirOf(dir, options) {
12712
13107
  var _options$alt, _options$accept;
12713
- // The same assertion as in `imageset()`, and sound for the same reason:
12714
- // `VideosetAltOption` makes `alt` required unless `Alt` is the default.
12715
- var altSchema = (_options$alt = options.alt) !== null && _options$alt !== void 0 ? _options$alt : string().nullable();
13108
+ // The same assertion as in `imagedir()`, and sound for the same reason:
13109
+ // `VideodirAltOption` makes `alt` required unless `Alt` is the default.
13110
+ var altSchema = (_options$alt = options === null || options === void 0 ? void 0 : options.alt) !== null && _options$alt !== void 0 ? _options$alt : string().nullable();
12716
13111
  var itemSchema = new ObjectSchema({
12717
13112
  mimeType: new StringSchema({}, false),
12718
13113
  width: new NumberSchema(undefined, false),
@@ -12722,13 +13117,13 @@ var videoset = function videoset(options) {
12722
13117
  }, false);
12723
13118
  return new RecordSchema(itemSchema, false, [], null, null, {
12724
13119
  type: "videos",
12725
- accept: (_options$accept = options.accept) !== null && _options$accept !== void 0 ? _options$accept : DEFAULT_VIDEO_ACCEPT,
12726
- dir: options.dir,
13120
+ accept: (_options$accept = options === null || options === void 0 ? void 0 : options.accept) !== null && _options$accept !== void 0 ? _options$accept : DEFAULT_VIDEO_ACCEPT,
13121
+ dir: dir,
12727
13122
  remote: false,
12728
13123
  altSchema: altSchema,
12729
- stream: options.stream
13124
+ stream: options === null || options === void 0 ? void 0 : options.stream
12730
13125
  });
12731
- };
13126
+ }
12732
13127
 
12733
13128
  /**
12734
13129
  * The video schema a set's entry is hashed against, for a remote ref.
@@ -12764,24 +13159,42 @@ function initSchema(options) {
12764
13159
  var media = (options === null || options === void 0 ? void 0 : options.remote) === true ? {
12765
13160
  image: remoteImage,
12766
13161
  file: remoteFile,
13162
+ font: remoteFont,
12767
13163
  video: remoteVideo,
12768
13164
  richtext: remoteRichtext,
13165
+ imagedir: remoteImagedir,
13166
+ filedir: function (dir, options) {
13167
+ return filedir(dir, options).remote();
13168
+ },
13169
+ fontdir: function (dir, options) {
13170
+ return fontdir(dir, options).remote();
13171
+ },
13172
+ videodir: remoteVideodir,
12769
13173
  imageset: function (options) {
12770
13174
  return imageset(options).remote();
12771
13175
  },
12772
13176
  fileset: function (options) {
12773
13177
  return fileset(options).remote();
12774
13178
  },
13179
+ fontset: function (options) {
13180
+ return fontset(options).remote();
13181
+ },
12775
13182
  videoset: function (options) {
12776
13183
  return videoset(options).remote();
12777
13184
  }
12778
13185
  } : {
12779
13186
  image: image,
12780
13187
  file: file,
13188
+ font: font,
12781
13189
  video: video,
12782
13190
  richtext: richtext,
13191
+ imagedir: imagedir,
13192
+ filedir: filedir,
13193
+ fontdir: fontdir,
13194
+ videodir: videodir,
12783
13195
  imageset: imageset,
12784
13196
  fileset: fileset,
13197
+ fontset: fontset,
12785
13198
  videoset: videoset
12786
13199
  };
12787
13200
  // locales: F.Narrow<Locales>
@@ -12802,8 +13215,12 @@ function initSchema(options) {
12802
13215
  view: view,
12803
13216
  record: record,
12804
13217
  file: media.file,
13218
+ font: media.font,
12805
13219
  video: media.video,
13220
+ filedir: media.filedir,
13221
+ fontdir: media.fontdir,
12806
13222
  fileset: media.fileset,
13223
+ fontset: media.fontset,
12807
13224
  date: date,
12808
13225
  datetime: datetime,
12809
13226
  color: color,
@@ -12811,6 +13228,8 @@ function initSchema(options) {
12811
13228
  locale: locale,
12812
13229
  route: route,
12813
13230
  router: router,
13231
+ imagedir: media.imagedir,
13232
+ videodir: media.videodir,
12814
13233
  imageset: media.imageset,
12815
13234
  videoset: media.videoset,
12816
13235
  settings: settings
@@ -13907,7 +14326,7 @@ function _extractValModules() {
13907
14326
  * The one answer to that question. There used to be two — `hasRemoteFileSchema`
13908
14327
  * in the server, gating whether `/save` demands remote credentials, and
13909
14328
  * `findRequiredRemoteFiles` in the Studio, gating the `/remote/settings` fetch —
13910
- * and they disagreed about `s.imageset({ ... }).remote()`: the Studio's version
14329
+ * and they disagreed about `s.imagedir(dir, { ... }).remote()`: the Studio's version
13911
14330
  * counted a remote media record, the server's did not, because a media
13912
14331
  * collection serializes as a `record` of metadata rather than as an image
13913
14332
  * schema.
@@ -13947,7 +14366,7 @@ function hasRemoteFileSchema(schema) {
13947
14366
  return hasRemoteFileSchema(schema.item);
13948
14367
  } else if (schema.type === "record") {
13949
14368
  /**
13950
- * A media collection — `s.imageset()` / `s.fileset()` — is the case both of the
14369
+ * A media collection — `s.imagedir()` / `s.filedir()` — is the case both of the
13951
14370
  * old functions were written around, and the one they disagreed on.
13952
14371
  *
13953
14372
  * It has no file or image schema inside it to find: `item` is an object of
@@ -14007,8 +14426,8 @@ function hasRemoteFileSchema(schema) {
14007
14426
  *
14008
14427
  * It is a walk over the SERIALIZED schema for the reasons given above, and for
14009
14428
  * one more that is specific to this question: the two cases most likely to be
14010
- * missed are invisible to a value type. A media collection (`s.imageset()` /
14011
- * `s.fileset()`) serializes as a record of metadata with no image schema inside
14429
+ * missed are invisible to a value type. A media collection (`s.imagedir()` /
14430
+ * `s.filedir()`) serializes as a record of metadata with no image schema inside
14012
14431
  * it, and a richtext inline image lives in a constructor argument. A check
14013
14432
  * written against the item TYPE would silently pass both — and the gallery case
14014
14433
  * already has a data-loss incident attached to it (see above).
@@ -14889,7 +15308,7 @@ function deserializeSchemaImpl(serialized) {
14889
15308
  * `s.array(s.object({ tags: s.array(s.string()) })).render({ as: "inline" })`
14890
15309
  * the objects are inline and `tags` keeps its own default.
14891
15310
  *
14892
- * Not available on `s.router(...)`, `s.imageset(...)` or `s.fileset(...)`:
15311
+ * Not available on `s.router(...)`, `s.imagedir(...)` or `s.filedir(...)`:
14893
15312
  * pages and media have UIs of their own, and `RecordSchema.render` throws there.
14894
15313
  *
14895
15314
  * On `s.keyOf(...)` the same value means something else: the selected entry's
@@ -15482,7 +15901,7 @@ function isPageRouter(routerId) {
15482
15901
 
15483
15902
  var corePackageJson = {
15484
15903
  name: "@valbuild/core",
15485
- version: "0.141.0",
15904
+ version: "0.144.0",
15486
15905
  "private": false,
15487
15906
  description: "Val - supercharged hard-coded content",
15488
15907
  repository: {
@@ -15588,6 +16007,7 @@ var Internal = {
15588
16007
  fillFromGallery: fillFromGallery,
15589
16008
  galleriesOf: galleriesOf,
15590
16009
  galleryEntryOf: galleryEntryOf,
16010
+ galleryKeyOf: galleryKeyOf,
15591
16011
  GALLERY_DEFAULT_GROUPS: GALLERY_DEFAULT_GROUPS,
15592
16012
  isHlsVideo: isHlsVideo,
15593
16013
  HLS_MIME_TYPE: HLS_MIME_TYPE
@@ -15652,6 +16072,9 @@ var Internal = {
15652
16072
  mimeTypeMatchesAccept: mimeTypeMatchesAccept,
15653
16073
  EXT_TO_MIME_TYPES: EXT_TO_MIME_TYPES,
15654
16074
  MIME_TYPES_TO_EXT: MIME_TYPES_TO_EXT,
16075
+ FONT_MIME_TYPE_EXTENSIONS: FONT_MIME_TYPE_EXTENSIONS,
16076
+ isFontMimeType: isFontMimeType,
16077
+ sniffFontMimeType: sniffFontMimeType,
15655
16078
  ModuleFilePathSep: ModuleFilePathSep,
15656
16079
  notFileOp: function notFileOp(op) {
15657
16080
  return op.op !== "file";
@@ -15703,4 +16126,4 @@ function tryJsonParse(str) {
15703
16126
  }
15704
16127
  }
15705
16128
 
15706
- export { discriminatedUnionBranchOf as $, ArraySchema as A, BooleanSchema as B, ASSISTANT_SETTINGS_MAX_LENGTH as C, DEFAULT_CONTENT_HOST as D, THEME_RADIUS_STEPS as E, FATAL_ERROR_TYPES as F, GenericSelector as G, THEME_RADIUS_LENGTHS as H, Internal as I, assistantAvailability as J, SETTINGS_MODULE_CONVENTION as K, isRootModuleFilePath as L, ModuleFilePathSep as M, NumberSchema as N, ObjectSchema as O, PatchError as P, resolveSettingsModule as Q, RecordSchema as R, Schema as S, THEME_LOGO_DIRECTORY as T, localeTagError as U, VAL_EXTENSION as V, localeOfValue as W, LocaleSchema as X, declaredKeySetOf as Y, missingDeclaredKeys as Z, _typeof as _, _slicedToArray as a, ColorSchema as a0, CodeSchema as a1, CODE_LANGUAGES as a2, COLOR_FORMATS as a3, DEFAULT_COLOR_FORMAT as a4, DateTimeSchema as a5, KeyOfSchema as a6, ValViewSchema as a7, isValViewSource as a8, RouteSchema as a9, RichTextSchema as aa, DiscriminatedUnionSchema as ab, EnumSchema as ac, LiteralSchema as ad, deserializeSchema as ae, previewScope as af, isInlineRender as ag, parseNextJsRoutePattern as ah, parseTanStackRoutePattern as ai, tanStackSegmentsOfRoutePath as aj, validateUrlAgainstPattern as ak, getSourcePathFromRoute as al, isPageRouter as am, describeSchemeRejection as an, isCheckableScheme as ao, rejectScheme as ap, schemeOf as aq, UNSAFE_URL_SCHEMES as ar, _createClass as b, _classCallCheck as c, _toConsumableArray as d, DEFAULT_APP_HOST as e, DEFAULT_STATIC_HOST as f, extractValModules as g, computeValModuleShas as h, initVal as i, computeSourcesSha as j, computeSchemaSha as k, hasRemoteFileSchema as l, modules as m, hasMediaSchema as n, DEFAULT_VAL_REMOTE_HOST as o, derefPatch as p, StringSchema as q, ImageSchema as r, splitModuleFilePathAndModulePath as s, FileSchema as t, VideoSchema as u, DEFAULT_VIDEO_ACCEPT as v, DEFAULT_VIDEO_RENDITIONS as w, DEFAULT_VIDEO_SEGMENT_DURATION as x, DateSchema as y, SettingsSchema as z };
16129
+ export { declaredKeySetOf as $, ArraySchema as A, BooleanSchema as B, DateSchema as C, DEFAULT_CONTENT_HOST as D, SettingsSchema as E, FATAL_ERROR_TYPES as F, GenericSelector as G, ASSISTANT_SETTINGS_MAX_LENGTH as H, Internal as I, THEME_RADIUS_STEPS as J, THEME_RADIUS_LENGTHS as K, assistantAvailability as L, ModuleFilePathSep as M, NumberSchema as N, ObjectSchema as O, PatchError as P, SETTINGS_MODULE_CONVENTION as Q, RecordSchema as R, Schema as S, THEME_LOGO_DIRECTORY as T, isRootModuleFilePath as U, VAL_EXTENSION as V, resolveSettingsModule as W, localeTagError as X, localeOfValue as Y, LocaleSchema as Z, _typeof as _, _slicedToArray as a, missingDeclaredKeys as a0, discriminatedUnionBranchOf as a1, ColorSchema as a2, CodeSchema as a3, CODE_LANGUAGES as a4, COLOR_FORMATS as a5, DEFAULT_COLOR_FORMAT as a6, DateTimeSchema as a7, KeyOfSchema as a8, ValViewSchema as a9, isValViewSource as aa, RouteSchema as ab, RichTextSchema as ac, DiscriminatedUnionSchema as ad, EnumSchema as ae, LiteralSchema as af, deserializeSchema as ag, previewScope as ah, isInlineRender as ai, parseNextJsRoutePattern as aj, parseTanStackRoutePattern as ak, tanStackSegmentsOfRoutePath as al, validateUrlAgainstPattern as am, getSourcePathFromRoute as an, isPageRouter as ao, describeSchemeRejection as ap, isCheckableScheme as aq, rejectScheme as ar, schemeOf as as, UNSAFE_URL_SCHEMES as at, _createClass as b, _classCallCheck as c, _toConsumableArray as d, DEFAULT_APP_HOST as e, DEFAULT_STATIC_HOST as f, extractValModules as g, computeValModuleShas as h, initVal as i, computeSourcesSha as j, computeSchemaSha as k, hasRemoteFileSchema as l, modules as m, hasMediaSchema as n, DEFAULT_VAL_REMOTE_HOST as o, derefPatch as p, StringSchema as q, ImageSchema as r, splitModuleFilePathAndModulePath as s, FileSchema as t, DEFAULT_FONT_ACCEPT as u, FONT_MIME_TYPES as v, VideoSchema as w, DEFAULT_VIDEO_ACCEPT as x, DEFAULT_VIDEO_RENDITIONS as y, DEFAULT_VIDEO_SEGMENT_DURATION as z };