@valbuild/shared 0.140.2 → 0.141.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 CHANGED
@@ -1,5 +1,73 @@
1
1
  # @valbuild/shared
2
2
 
3
+ ## 0.141.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#802](https://github.com/valbuild/val/pull/802) [`199e214`](https://github.com/valbuild/val/commit/199e21471d98806fb34c579cb876560078c928b9) Thanks [@freekh](https://github.com/freekh)! - New: `files: { remote: true }` in `val.config.ts` stores every image, file and video on Val's remote content host.
8
+
9
+ ```ts
10
+ const { s, c, val, config } = initVal({
11
+ project: "myorg/myproject",
12
+ files: { remote: true },
13
+ });
14
+ ```
15
+
16
+ With it, `s.image()`, `s.file()`, `s.video()`, `s.imageset()`, `s.fileset()`, `s.videoset()` and `s.richtext({ img: true })` behave as though `.remote()` had been written on them. Images already in the project are reported as `image:upload-remote` until they are uploaded; `npx val validate --fix` does that.
17
+
18
+ **Required in the Val app.** A project running there (`VAL_ENV=app`) refuses to start without it, with an error that says what to add, and `val publish` refuses before it builds.
19
+
20
+ **Breaking:** `files.directory` has been removed from `val.config.ts`. Local files that have no `dir` of their own are stored in `/public/val`, which was the default.
21
+
22
+ - [#779](https://github.com/valbuild/val/pull/779) [`ba3f330`](https://github.com/valbuild/val/commit/ba3f3300a3dd8649e154097cdfca3b64db209d89) Thanks [@freekh](https://github.com/freekh)! - New: `s.video()`, for mp4/WebM files and HLS streams.
23
+
24
+ ```ts
25
+ const schema = s.object({
26
+ intro: s.video({ stream: { type: "hls" } }),
27
+ });
28
+ ```
29
+
30
+ - **Upload and play in the Studio.** A video field shows a player, the file's size and length, and progress while it uploads.
31
+ - **HLS streaming without a video service.** With `stream: { type: "hls" }`, the Studio converts an upload to an HLS stream in the editor's browser before it uploads it. It makes one H.264 rendition per height (1080p, 720p and 480p by default, and never larger than the upload) and stores them as a folder of files next to your other uploads. Nothing is installed in your app for this: the converter ships inside the Studio and is only downloaded when someone uploads to a streaming field. A browser that can't convert (no WebCodecs, or a non-https address) uploads the original file and says so.
32
+ - **Poster:** pause on a frame and choose "Use current frame". The frame is saved as an image, and `posterTime` records where it was taken.
33
+ - **Start and end:** play part of a video without cutting the file.
34
+ - **Focal point:** marks what must stay in frame when the page crops the video.
35
+ - **Description:** text for people who can't see the video.
36
+ - **Captions:** one WebVTT file per language. `.srt` files are converted on upload.
37
+ - **`<ValVideo>`** in `@valbuild/next` and `@valbuild/tanstack` renders all of the above and is click-to-edit. For HLS in browsers that can't play it natively, pass `hls={() => import("hls.js")}`. It is only loaded when it's needed.
38
+ - **Rename** a video in the Studio. An HLS stream is renamed as a whole: every playlist and segment moves to the new folder.
39
+ - `npx val validate --fix` fills in `mimeType`, `width`, `height` and `duration` for a hand-written `.mp4`, `.mov`, `.webm`, `.mkv` or HLS video, on disk or on Val Remote. A remote video is not downloaded: only its headers are read, usually in one to three small requests.
40
+ - `.remote()` works for videos. `npx val validate --fix` moves a video to Val Remote, or back into the project, together with its poster, captions and every file of an HLS stream.
41
+
42
+ A video value always has a `mimeType`: it is how a page knows whether it has an `.mp4` or an `.m3u8`.
43
+
44
+ New: `s.videoset()`, a collection of videos, like `s.imageset()` for images.
45
+
46
+ ```ts
47
+ const videosVal = c.define(
48
+ "/content/videos.val.ts",
49
+ s.videoset({ dir: "/public/val/videos", stream: { type: "hls" } }),
50
+ {},
51
+ );
52
+ const schema = s.object({ intro: s.video(videosVal) });
53
+ ```
54
+
55
+ - **Upload once, set it up once, use anywhere.** A set's entry holds what is true of the file (its type, size and length) and, as defaults, a description, poster, start and end, focal point and captions. A field that picks from the set (`s.video(videosVal)`) gets all of those, and can override any of them on its own. For example, the same clip can open one page at 0:02 and every other page where the set says.
56
+ - **Media in the Studio.** A set is listed under Media and opens as a gallery of videos, with each video's poster as its thumbnail. Hovering a video previews it, and the selected video plays in a real player (HLS streams too) beside the poster, times, focal point and captions you edit for it. You can upload into the set (with `stream`, uploads become HLS streams, and each upload gets a poster), rename a video, and delete a video that nothing uses. Renaming a video updates every field that uses it. An HLS stream is one entry, and renaming or deleting it moves or removes all of its files.
57
+ - **Picking.** A set-backed field picks from the set, or uploads into it. Each value the set provides is marked "From gallery · Override", and once overridden, "Overridden · Use gallery's".
58
+ - `useVal` and `fetchVal` fill in what the set holds (`mimeType`, `width`, `height`, `duration`, and every default the field does not override), so `<ValVideo>` works the same either way.
59
+ - `.remote()` works for sets. `npx val validate --fix` fills in missing metadata for an entry, adds untracked videos found in the set's directory, and moves a set's videos to Val Remote.
60
+
61
+ Image and file galleries use the same new gallery layout: a grid or list of entries, with the selected one open in a panel beside it.
62
+
63
+ - An `s.imageset()` entry can hold a default focal point, as well as its description. An `s.image(galleryVal)` field shows both, and can override either.
64
+ - Fixed: outside draft mode, `useVal` and `fetchVal` now fill a gallery-backed image or file from its gallery (dimensions, mime type, description). Before, a published page got only the `path`.
65
+
66
+ ### Patch Changes
67
+
68
+ - Updated dependencies [[`199e214`](https://github.com/valbuild/val/commit/199e21471d98806fb34c579cb876560078c928b9), [`ba3f330`](https://github.com/valbuild/val/commit/ba3f3300a3dd8649e154097cdfca3b64db209d89)]:
69
+ - @valbuild/core@0.141.0
70
+
3
71
  ## 0.140.2
4
72
 
5
73
  ### Patch Changes
@@ -422,7 +422,7 @@ export declare const Api: {
422
422
  project: z.ZodOptional<z.ZodString>;
423
423
  root: z.ZodOptional<z.ZodString>;
424
424
  files: z.ZodOptional<z.ZodObject<{
425
- directory: z.ZodString;
425
+ remote: z.ZodOptional<z.ZodBoolean>;
426
426
  }, z.core.$strip>>;
427
427
  gitCommit: z.ZodOptional<z.ZodString>;
428
428
  gitBranch: z.ZodOptional<z.ZodString>;
@@ -478,7 +478,7 @@ export declare const Api: {
478
478
  project: z.ZodOptional<z.ZodString>;
479
479
  root: z.ZodOptional<z.ZodString>;
480
480
  files: z.ZodOptional<z.ZodObject<{
481
- directory: z.ZodString;
481
+ remote: z.ZodOptional<z.ZodBoolean>;
482
482
  }, z.core.$strip>>;
483
483
  gitCommit: z.ZodOptional<z.ZodString>;
484
484
  gitBranch: z.ZodOptional<z.ZodString>;
@@ -1090,7 +1090,7 @@ export declare const Api: {
1090
1090
  message: z.ZodString;
1091
1091
  value: z.ZodOptional<z.ZodUnknown>;
1092
1092
  fatal: z.ZodOptional<z.ZodBoolean>;
1093
- fixes: z.ZodOptional<z.ZodArray<z.ZodType<"image:add-metadata" | "image:check-metadata" | "image:upload-remote" | "image:download-remote" | "image:check-remote" | "images:check-remote" | "images:upload-remote" | "file:add-metadata" | "file:check-metadata" | "file:upload-remote" | "file:download-remote" | "file:check-remote" | "files:check-remote" | "files:upload-remote" | "keyof:check-keys" | "router:check-route" | "locale:check-locale" | "images:check-unique-folder" | "files:check-unique-folder" | "images:check-all-files" | "files:check-all-files" | "jsonValues:extract-entry" | "record:fill-keys" | "external:upload" | "view:check-module", unknown, z.core.$ZodTypeInternals<"image:add-metadata" | "image:check-metadata" | "image:upload-remote" | "image:download-remote" | "image:check-remote" | "images:check-remote" | "images:upload-remote" | "file:add-metadata" | "file:check-metadata" | "file:upload-remote" | "file:download-remote" | "file:check-remote" | "files:check-remote" | "files:upload-remote" | "keyof:check-keys" | "router:check-route" | "locale:check-locale" | "images:check-unique-folder" | "files:check-unique-folder" | "images:check-all-files" | "files:check-all-files" | "jsonValues:extract-entry" | "record:fill-keys" | "external:upload" | "view:check-module", unknown>>>>;
1093
+ fixes: z.ZodOptional<z.ZodArray<z.ZodType<"image:add-metadata" | "image:check-metadata" | "image:upload-remote" | "image:download-remote" | "image:check-remote" | "images:check-remote" | "images:upload-remote" | "file:add-metadata" | "file:check-metadata" | "file:upload-remote" | "file:download-remote" | "file:check-remote" | "files:check-remote" | "files:upload-remote" | "video:add-metadata" | "video:upload-remote" | "video:download-remote" | "videos:add-metadata" | "videos:check-remote" | "videos:upload-remote" | "keyof:check-keys" | "router:check-route" | "locale:check-locale" | "images:check-unique-folder" | "files:check-unique-folder" | "images:check-all-files" | "files:check-all-files" | "videos:check-unique-folder" | "videos:check-all-files" | "jsonValues:extract-entry" | "record:fill-keys" | "external:upload" | "view:check-module", unknown, z.core.$ZodTypeInternals<"image:add-metadata" | "image:check-metadata" | "image:upload-remote" | "image:download-remote" | "image:check-remote" | "images:check-remote" | "images:upload-remote" | "file:add-metadata" | "file:check-metadata" | "file:upload-remote" | "file:download-remote" | "file:check-remote" | "files:check-remote" | "files:upload-remote" | "video:add-metadata" | "video:upload-remote" | "video:download-remote" | "videos:add-metadata" | "videos:check-remote" | "videos:upload-remote" | "keyof:check-keys" | "router:check-route" | "locale:check-locale" | "images:check-unique-folder" | "files:check-unique-folder" | "images:check-all-files" | "files:check-all-files" | "videos:check-unique-folder" | "videos:check-all-files" | "jsonValues:extract-entry" | "record:fill-keys" | "external:upload" | "view:check-module", unknown>>>>;
1094
1094
  }, z.core.$strip>>>>;
1095
1095
  }, z.core.$strip>>;
1096
1096
  }, z.core.$strip>;
@@ -1668,6 +1668,9 @@ export declare const Api: {
1668
1668
  })[]>>>;
1669
1669
  remote: z.ZodOptional<z.ZodPipe<z.ZodArray<z.ZodString>, z.ZodTransform<string, string[]>>>;
1670
1670
  };
1671
+ headers: {
1672
+ range: z.ZodOptional<z.ZodString>;
1673
+ };
1671
1674
  };
1672
1675
  res: z.ZodUnion<readonly [z.ZodObject<{
1673
1676
  status: z.ZodLiteral<401>;
@@ -1682,6 +1685,14 @@ export declare const Api: {
1682
1685
  }, z.core.$strip>, z.ZodObject<{
1683
1686
  status: z.ZodLiteral<200>;
1684
1687
  body: z.ZodCustom<import("node:stream/web").ReadableStream<unknown>, import("node:stream/web").ReadableStream<unknown>>;
1688
+ }, z.core.$strip>, z.ZodObject<{
1689
+ status: z.ZodLiteral<206>;
1690
+ body: z.ZodCustom<import("node:stream/web").ReadableStream<unknown>, import("node:stream/web").ReadableStream<unknown>>;
1691
+ }, z.core.$strip>, z.ZodObject<{
1692
+ status: z.ZodLiteral<416>;
1693
+ json: z.ZodObject<{
1694
+ message: z.ZodString;
1695
+ }, z.core.$strip>;
1685
1696
  }, z.core.$strip>]>;
1686
1697
  };
1687
1698
  };
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- import { type SerializedSchema as SerializedSchemaT, type SerializedStringSchema as SerializedStringSchemaT, type SerializedLiteralSchema as SerializedLiteralSchemaT, type SerializedBooleanSchema as SerializedBooleanSchemaT, type SerializedNumberSchema as SerializedNumberSchemaT, type SerializedObjectSchema as SerializedObjectSchemaT, type SerializedArraySchema as SerializedArraySchemaT, type SerializedDiscriminatedUnionSchema as SerializedDiscriminatedUnionSchemaT, type SerializedEnumSchema as SerializedEnumSchemaT, type SerializedRichTextSchema as SerializedRichTextSchemaT, type SerializedRichTextOptions as SerializedRichTextOptionsT, type SerializedRecordSchema as SerializedRecordSchemaT, type SerializedKeyOfSchema as SerializedKeyOfSchemaT, type SerializedLocaleSchema as SerializedLocaleSchemaT, type SerializedRouteSchema as SerializedRouteSchemaT, type SerializedFileSchema as SerializedFileSchemaT, type SerializedDateSchema as SerializedDateSchemaT, type SerializedDateTimeSchema as SerializedDateTimeSchemaT, type SerializedColorSchema as SerializedColorSchemaT, type SerializedCodeSchema as SerializedCodeSchemaT, type SerializedImageSchema as SerializedImageSchemaT, type SerializedSettingsSchema as SerializedSettingsSchemaT } from "@valbuild/core";
2
+ import { type SerializedSchema as SerializedSchemaT, type SerializedStringSchema as SerializedStringSchemaT, type SerializedLiteralSchema as SerializedLiteralSchemaT, type SerializedBooleanSchema as SerializedBooleanSchemaT, type SerializedNumberSchema as SerializedNumberSchemaT, type SerializedObjectSchema as SerializedObjectSchemaT, type SerializedArraySchema as SerializedArraySchemaT, type SerializedDiscriminatedUnionSchema as SerializedDiscriminatedUnionSchemaT, type SerializedEnumSchema as SerializedEnumSchemaT, type SerializedRichTextSchema as SerializedRichTextSchemaT, type SerializedRichTextOptions as SerializedRichTextOptionsT, type SerializedRecordSchema as SerializedRecordSchemaT, type SerializedKeyOfSchema as SerializedKeyOfSchemaT, type SerializedLocaleSchema as SerializedLocaleSchemaT, type SerializedRouteSchema as SerializedRouteSchemaT, type SerializedFileSchema as SerializedFileSchemaT, type SerializedDateSchema as SerializedDateSchemaT, type SerializedDateTimeSchema as SerializedDateTimeSchemaT, type SerializedColorSchema as SerializedColorSchemaT, type SerializedCodeSchema as SerializedCodeSchemaT, type SerializedImageSchema as SerializedImageSchemaT, type SerializedVideoSchema as SerializedVideoSchemaT, type SerializedSettingsSchema as SerializedSettingsSchemaT } from "@valbuild/core";
3
3
  export declare const SerializedStringSchema: z.ZodType<SerializedStringSchemaT>;
4
4
  export declare const SerializedLiteralSchema: z.ZodType<SerializedLiteralSchemaT>;
5
5
  export declare const SerializedBooleanSchema: z.ZodType<SerializedBooleanSchemaT>;
@@ -33,6 +33,21 @@ export declare const FileOptions: z.ZodObject<{
33
33
  accept: z.ZodOptional<z.ZodString>;
34
34
  }, z.core.$strip>;
35
35
  export declare const SerializedFileSchema: z.ZodType<SerializedFileSchemaT>;
36
+ export declare const VideoStreamOption: z.ZodUnion<readonly [z.ZodLiteral<false>, z.ZodObject<{
37
+ type: z.ZodLiteral<"hls">;
38
+ renditions: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
39
+ segmentDuration: z.ZodOptional<z.ZodNumber>;
40
+ }, z.core.$strip>]>;
41
+ export declare const VideoOptions: z.ZodObject<{
42
+ dir: z.ZodOptional<z.ZodString>;
43
+ accept: z.ZodOptional<z.ZodString>;
44
+ stream: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<false>, z.ZodObject<{
45
+ type: z.ZodLiteral<"hls">;
46
+ renditions: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
47
+ segmentDuration: z.ZodOptional<z.ZodNumber>;
48
+ }, z.core.$strip>]>>;
49
+ }, z.core.$strip>;
50
+ export declare const SerializedVideoSchema: z.ZodType<SerializedVideoSchemaT>;
36
51
  export declare const DateOptions: z.ZodObject<{
37
52
  from: z.ZodOptional<z.ZodString>;
38
53
  to: z.ZodOptional<z.ZodString>;
@@ -1165,13 +1165,16 @@ var SerializedRecordSchema = zod.z.lazy(function () {
1165
1165
  type: zod.z.literal("record"),
1166
1166
  item: SerializedSchema,
1167
1167
  opt: zod.z["boolean"](),
1168
- // Optional gallery marker for files/images
1169
- mediaType: zod.z.union([zod.z.literal("files"), zod.z.literal("images")]).optional(),
1168
+ // Optional gallery marker for files/images/videos
1169
+ mediaType: zod.z.union([zod.z.literal("files"), zod.z.literal("images"), zod.z.literal("videos")]).optional(),
1170
1170
  // Optional legacy gallery metadata
1171
1171
  accept: zod.z.string().optional(),
1172
1172
  dir: zod.z.string().optional(),
1173
1173
  remote: zod.z["boolean"]().optional(),
1174
1174
  encode: ImageEncodeOption.optional(),
1175
+ // A videoset's: see `VideoStreamOption` below for why it is spelled
1176
+ // out rather than passed through.
1177
+ stream: VideoStreamOption.optional(),
1175
1178
  alt: SerializedSchema.optional(),
1176
1179
  moduleMetadata: zod.z.record(zod.z.string(), zod.z.record(zod.z.string(), zod.z.any())).optional()
1177
1180
  })).passthrough());
@@ -1205,6 +1208,29 @@ var SerializedFileSchema = zod.z.object(getSitemapTree._objectSpread2(getSitemap
1205
1208
  remote: zod.z["boolean"]().optional(),
1206
1209
  referencedModule: zod.z.string().optional()
1207
1210
  }));
1211
+
1212
+ // `stream` is the one option that changes what an upload BECOMES, so it is
1213
+ // declared field by field: these z.objects strip unknown keys, and a stream
1214
+ // dropped in transit is a Studio that uploads a 2 GB mp4 where an HLS stream
1215
+ // was asked for.
1216
+ var VideoStreamOption = zod.z.union([zod.z.literal(false), zod.z.object({
1217
+ type: zod.z.literal("hls"),
1218
+ renditions: zod.z.array(zod.z.number()).optional(),
1219
+ segmentDuration: zod.z.number().optional()
1220
+ })]);
1221
+ var VideoOptions = zod.z.object({
1222
+ dir: zod.z.string().optional(),
1223
+ accept: zod.z.string().optional(),
1224
+ stream: VideoStreamOption.optional()
1225
+ });
1226
+ var SerializedVideoSchema = zod.z.object(getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, commonSchemaFields), {}, {
1227
+ type: zod.z.literal("video"),
1228
+ options: VideoOptions.optional(),
1229
+ opt: zod.z["boolean"](),
1230
+ remote: zod.z["boolean"]().optional(),
1231
+ // The `s.videoset()` a set-backed field picks from.
1232
+ referencedModule: zod.z.string().optional()
1233
+ }));
1208
1234
  var DateOptions = zod.z.object({
1209
1235
  from: zod.z.string().optional(),
1210
1236
  to: zod.z.string().optional()
@@ -1295,7 +1321,7 @@ var SerializedValViewSchema = zod.z.object({
1295
1321
  hidden: zod.z["boolean"]().optional(),
1296
1322
  description: zod.z.string().optional()
1297
1323
  });
1298
- var SerializedSchema = zod.z.union([SerializedStringSchema, SerializedLiteralSchema, SerializedBooleanSchema, SerializedNumberSchema, SerializedObjectSchema, SerializedArraySchema, SerializedDiscriminatedUnionSchema, SerializedEnumSchema, SerializedRichTextSchema, SerializedRecordSchema, SerializedKeyOfSchema, SerializedRouteSchema, SerializedLocaleSchema, SerializedFileSchema, SerializedDateSchema, SerializedDateTimeSchema, SerializedColorSchema, SerializedCodeSchema, SerializedSettingsSchema, SerializedImageSchema, SerializedValViewSchema]);
1324
+ var SerializedSchema = zod.z.union([SerializedStringSchema, SerializedLiteralSchema, SerializedBooleanSchema, SerializedNumberSchema, SerializedObjectSchema, SerializedArraySchema, SerializedDiscriminatedUnionSchema, SerializedEnumSchema, SerializedRichTextSchema, SerializedRecordSchema, SerializedKeyOfSchema, SerializedRouteSchema, SerializedLocaleSchema, SerializedFileSchema, SerializedDateSchema, SerializedDateTimeSchema, SerializedColorSchema, SerializedCodeSchema, SerializedSettingsSchema, SerializedImageSchema, SerializedVideoSchema, SerializedValViewSchema]);
1299
1325
 
1300
1326
  var ValCommit = zod.z.object({
1301
1327
  commitSha: zod.z.string(),
@@ -1476,12 +1502,12 @@ var ValConfig = zod.z.object({
1476
1502
  project: zod.z.string().optional(),
1477
1503
  root: zod.z.string().optional(),
1478
1504
  files: zod.z.object({
1479
- directory: zod.z.string() // TODO: validate that it is prefixed by /public/
1505
+ remote: zod.z["boolean"]().optional()
1480
1506
  }).optional(),
1481
1507
  gitCommit: zod.z.string().optional(),
1482
1508
  gitBranch: zod.z.string().optional()
1483
1509
  });
1484
- var ValidationFixZ = zod.z.union([zod.z.literal("image:add-metadata"), zod.z.literal("image:check-metadata"), zod.z.literal("image:check-remote"), zod.z.literal("image:upload-remote"), zod.z.literal("image:download-remote"), zod.z.literal("images:check-remote"), zod.z.literal("images:upload-remote"), zod.z.literal("file:add-metadata"), zod.z.literal("file:check-metadata"), zod.z.literal("file:check-remote"), zod.z.literal("file:upload-remote"), zod.z.literal("file:download-remote"), zod.z.literal("files:check-remote"), zod.z.literal("files:upload-remote"), zod.z.literal("keyof:check-keys"), zod.z.literal("router:check-route"), zod.z.literal("locale:check-locale"), zod.z.literal("record:fill-keys"), zod.z.literal("images:check-unique-folder"), zod.z.literal("files:check-unique-folder"), zod.z.literal("images:check-all-files"), zod.z.literal("files:check-all-files"), zod.z.literal("jsonValues:extract-entry"), zod.z.literal("view:check-module")]);
1510
+ var ValidationFixZ = zod.z.union([zod.z.literal("image:add-metadata"), zod.z.literal("image:check-metadata"), zod.z.literal("image:check-remote"), zod.z.literal("image:upload-remote"), zod.z.literal("image:download-remote"), zod.z.literal("images:check-remote"), zod.z.literal("images:upload-remote"), zod.z.literal("file:add-metadata"), zod.z.literal("video:add-metadata"), zod.z.literal("video:upload-remote"), zod.z.literal("video:download-remote"), zod.z.literal("videos:add-metadata"), zod.z.literal("videos:check-remote"), zod.z.literal("videos:upload-remote"), zod.z.literal("file:check-metadata"), zod.z.literal("file:check-remote"), zod.z.literal("file:upload-remote"), zod.z.literal("file:download-remote"), zod.z.literal("files:check-remote"), zod.z.literal("files:upload-remote"), zod.z.literal("keyof:check-keys"), zod.z.literal("router:check-route"), zod.z.literal("locale:check-locale"), zod.z.literal("record:fill-keys"), zod.z.literal("images:check-unique-folder"), zod.z.literal("files:check-unique-folder"), zod.z.literal("images:check-all-files"), zod.z.literal("files:check-all-files"), zod.z.literal("videos:check-unique-folder"), zod.z.literal("videos:check-all-files"), zod.z.literal("jsonValues:extract-entry"), zod.z.literal("view:check-module")]);
1485
1511
  var ValidationError = zod.z.object({
1486
1512
  message: zod.z.string(),
1487
1513
  value: zod.z.unknown().optional(),
@@ -3194,11 +3220,23 @@ var Api = {
3194
3220
  return arg[0];
3195
3221
  }).optional(),
3196
3222
  remote: onlyOneStringQueryParam.optional()
3223
+ },
3224
+ // A `<video>` seeks with byte ranges, Safari will not play one from a
3225
+ // server that ignores them, and HLS segments that are byte ranges of
3226
+ // one file are fetched no other way.
3227
+ headers: {
3228
+ range: zod.z.string().optional()
3197
3229
  }
3198
3230
  },
3199
3231
  res: zod.z.union([unauthorizedResponse, notFoundResponse, zod.z.object({
3200
3232
  status: zod.z.literal(200),
3201
3233
  body: zod.z["instanceof"](ReadableStream)
3234
+ }), zod.z.object({
3235
+ status: zod.z.literal(206),
3236
+ body: zod.z["instanceof"](ReadableStream)
3237
+ }), zod.z.object({
3238
+ status: zod.z.literal(416),
3239
+ json: GenericError
3202
3240
  })])
3203
3241
  }
3204
3242
  },
@@ -5322,7 +5360,7 @@ function emptyOf(schema, context) {
5322
5360
  // language nobody chose, which is the thing this whole feature exists to
5323
5361
  // make visible.
5324
5362
  return (_context$selectedLoca = context === null || context === void 0 ? void 0 : context.selectedLocale) !== null && _context$selectedLoca !== void 0 ? _context$selectedLoca : "";
5325
- } else if (schema.type === "file" || schema.type === "image") {
5363
+ } else if (schema.type === "file" || schema.type === "image" || schema.type === "video") {
5326
5364
  return null; // returning null is the only thing we can do, however, it means that the patches cannot be applied yet since that might fail
5327
5365
  } else if (schema.type === "literal") {
5328
5366
  return schema.value;
@@ -5532,6 +5570,14 @@ function checkGallerySchema(moduleSchema) {
5532
5570
  if (moduleSchema.type === "record" && moduleSchema.mediaType === "images") {
5533
5571
  return null;
5534
5572
  }
5573
+ if (moduleSchema.type === "record" && moduleSchema.mediaType === "videos") {
5574
+ // Said outright rather than as "not an images gallery": a set of videos
5575
+ // looks like a gallery from here, and the tool can do nothing with one.
5576
+ return {
5577
+ kind: "error",
5578
+ message: "Module is a video set (s.videoset()), not an images gallery. Videos cannot be added or removed by this tool: upload them in Val Studio."
5579
+ };
5580
+ }
5535
5581
  if (moduleSchema.type === "image") {
5536
5582
  return {
5537
5583
  kind: "wrong-tool",
@@ -5626,17 +5672,32 @@ var GALLERY_REDIRECT = {
5626
5672
  reason: "Destination is a media gallery (s.imageset() / s.fileset()). Gallery entries are keyed by file path and carry a file on disk, so they cannot be created with a plain patch. Use add_session_image_to_gallery."
5627
5673
  };
5628
5674
 
5629
- /** An `s.imageset()` / `s.fileset()` record: a gallery, not an ordinary record. */
5675
+ /**
5676
+ * A video set's entries are keyed by a file too, and a stream's by a
5677
+ * directory of them — and there is no tool to send them to: a video is
5678
+ * uploaded (and, for a stream, transcoded) in the Studio.
5679
+ */
5680
+ var VIDEOSET_REFUSAL = {
5681
+ kind: "error",
5682
+ message: "Destination is a video set (s.videoset()). Its entries are keyed by file path and carry video files, so they cannot be created with a plain patch, and no tool here uploads a video: add it in Val Studio."
5683
+ };
5684
+
5685
+ /** An `s.imageset()` / `s.fileset()` / `s.videoset()` record: a gallery, not an ordinary record. */
5630
5686
  function isGallery(schema) {
5631
5687
  return schema.type === "record" && schema.mediaType !== undefined;
5632
5688
  }
5689
+
5690
+ /** Where to send someone whose destination is (in) the gallery `schema`. */
5691
+ function galleryRedirect(schema) {
5692
+ return schema.type === "record" && schema.mediaType === "videos" ? VIDEOSET_REFUSAL : GALLERY_REDIRECT;
5693
+ }
5633
5694
  function decideOp(moduleSchema, destinationPath) {
5634
5695
  // The DESTINATION itself, checked before its parent: `["gallery"]` resolves
5635
5696
  // its parent to the enclosing object and would otherwise look like an
5636
5697
  // ordinary `replace` that overwrites a whole gallery.
5637
5698
  var destination = resolveSerializedSchemaAtPath(moduleSchema, destinationPath);
5638
5699
  if (destination.kind === "gallery-traversed") {
5639
- return GALLERY_REDIRECT;
5700
+ return galleryRedirect(destination.schema);
5640
5701
  }
5641
5702
  if (destination.kind === "richtext") {
5642
5703
  return {
@@ -5647,7 +5708,7 @@ function decideOp(moduleSchema, destinationPath) {
5647
5708
  }
5648
5709
  if (destination.kind === "leaf") {
5649
5710
  if (isGallery(destination.schema)) {
5650
- return GALLERY_REDIRECT;
5711
+ return galleryRedirect(destination.schema);
5651
5712
  }
5652
5713
  // A richtext value the path lands exactly ON resolves as a leaf, not as
5653
5714
  // `kind: "richtext"` (which only fires when the walk continues INTO it).
@@ -5684,7 +5745,7 @@ function decideOp(moduleSchema, destinationPath) {
5684
5745
  // destination is a gallery entry; `isGallery` catches the case where the
5685
5746
  // parent IS the gallery and the destination is a new entry key in it.
5686
5747
  if (parent.kind === "gallery-traversed" || isGallery(parent.schema)) {
5687
- return GALLERY_REDIRECT;
5748
+ return galleryRedirect(parent.schema);
5688
5749
  }
5689
5750
  var schema = parent.schema;
5690
5751
  if (schema.type === "array" || schema.type === "record") {
@@ -6005,6 +6066,14 @@ function isSkippableFixCode(fix) {
6005
6066
  case "file:check-remote":
6006
6067
  case "files:check-remote":
6007
6068
  case "files:upload-remote":
6069
+ case "video:add-metadata": // the Studio writes it on upload; --fix for the rest
6070
+ case "video:upload-remote":
6071
+ case "video:download-remote":
6072
+ case "videos:add-metadata": // as `video:add-metadata`, for a set's entry
6073
+ case "videos:check-remote":
6074
+ case "videos:upload-remote":
6075
+ case "videos:check-unique-folder":
6076
+ case "videos:check-all-files":
6008
6077
  case "images:check-unique-folder":
6009
6078
  case "files:check-unique-folder":
6010
6079
  case "images:check-all-files":
@@ -6329,8 +6398,8 @@ function traverseSchemaSource(source, schema, path, callback) {
6329
6398
  return;
6330
6399
  }
6331
6400
 
6332
- // Handle file/image
6333
- if (schema.type === "file" || schema.type === "image") {
6401
+ // Handle file/image/video
6402
+ if (schema.type === "file" || schema.type === "image" || schema.type === "video") {
6334
6403
  if (source && getSitemapTree._typeof(source) === "object" && "path" in source && typeof source.path === "string") {
6335
6404
  callback({
6336
6405
  source: source,
@@ -6677,8 +6746,8 @@ function indexModule(searchIndex, moduleFilePath, source, schema) {
6677
6746
  // Use first 50 chars as label
6678
6747
  label = searchText.substring(0, 50) || "richtext";
6679
6748
  }
6680
- // Handle file/image
6681
- else if (schema.type === "file" || schema.type === "image") {
6749
+ // Handle file/image/video
6750
+ else if (schema.type === "file" || schema.type === "image" || schema.type === "video") {
6682
6751
  if (source !== null && getSitemapTree._typeof(source) === "object" && "path" in source && typeof source.path === "string") {
6683
6752
  // The label is the bare filename - the folder is shown separately in
6684
6753
  // the UI - but both are searchable.
@@ -7852,6 +7921,7 @@ exports.SerializedSchema = SerializedSchema;
7852
7921
  exports.SerializedSettingsSchema = SerializedSettingsSchema;
7853
7922
  exports.SerializedStringSchema = SerializedStringSchema;
7854
7923
  exports.SerializedValViewSchema = SerializedValViewSchema;
7924
+ exports.SerializedVideoSchema = SerializedVideoSchema;
7855
7925
  exports.SharedValConfig = SharedValConfig;
7856
7926
  exports.VAL_ENABLE_COOKIE_NAME = VAL_ENABLE_COOKIE_NAME;
7857
7927
  exports.VAL_GREEN_RAMP = VAL_GREEN_RAMP;
@@ -7860,6 +7930,8 @@ exports.VAL_STATE_COOKIE = VAL_STATE_COOKIE;
7860
7930
  exports.VAL_STUDIO_HEADER = VAL_STUDIO_HEADER;
7861
7931
  exports.ValCommit = ValCommit;
7862
7932
  exports.ValDeployment = ValDeployment;
7933
+ exports.VideoOptions = VideoOptions;
7934
+ exports.VideoStreamOption = VideoStreamOption;
7863
7935
  exports.accentRamp = accentRamp;
7864
7936
  exports.buildDuplicatePatch = buildDuplicatePatch;
7865
7937
  exports.buildEmptyAtPathPatch = buildEmptyAtPathPatch;
@@ -1165,13 +1165,16 @@ var SerializedRecordSchema = zod.z.lazy(function () {
1165
1165
  type: zod.z.literal("record"),
1166
1166
  item: SerializedSchema,
1167
1167
  opt: zod.z["boolean"](),
1168
- // Optional gallery marker for files/images
1169
- mediaType: zod.z.union([zod.z.literal("files"), zod.z.literal("images")]).optional(),
1168
+ // Optional gallery marker for files/images/videos
1169
+ mediaType: zod.z.union([zod.z.literal("files"), zod.z.literal("images"), zod.z.literal("videos")]).optional(),
1170
1170
  // Optional legacy gallery metadata
1171
1171
  accept: zod.z.string().optional(),
1172
1172
  dir: zod.z.string().optional(),
1173
1173
  remote: zod.z["boolean"]().optional(),
1174
1174
  encode: ImageEncodeOption.optional(),
1175
+ // A videoset's: see `VideoStreamOption` below for why it is spelled
1176
+ // out rather than passed through.
1177
+ stream: VideoStreamOption.optional(),
1175
1178
  alt: SerializedSchema.optional(),
1176
1179
  moduleMetadata: zod.z.record(zod.z.string(), zod.z.record(zod.z.string(), zod.z.any())).optional()
1177
1180
  })).passthrough());
@@ -1205,6 +1208,29 @@ var SerializedFileSchema = zod.z.object(getSitemapTree._objectSpread2(getSitemap
1205
1208
  remote: zod.z["boolean"]().optional(),
1206
1209
  referencedModule: zod.z.string().optional()
1207
1210
  }));
1211
+
1212
+ // `stream` is the one option that changes what an upload BECOMES, so it is
1213
+ // declared field by field: these z.objects strip unknown keys, and a stream
1214
+ // dropped in transit is a Studio that uploads a 2 GB mp4 where an HLS stream
1215
+ // was asked for.
1216
+ var VideoStreamOption = zod.z.union([zod.z.literal(false), zod.z.object({
1217
+ type: zod.z.literal("hls"),
1218
+ renditions: zod.z.array(zod.z.number()).optional(),
1219
+ segmentDuration: zod.z.number().optional()
1220
+ })]);
1221
+ var VideoOptions = zod.z.object({
1222
+ dir: zod.z.string().optional(),
1223
+ accept: zod.z.string().optional(),
1224
+ stream: VideoStreamOption.optional()
1225
+ });
1226
+ var SerializedVideoSchema = zod.z.object(getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, commonSchemaFields), {}, {
1227
+ type: zod.z.literal("video"),
1228
+ options: VideoOptions.optional(),
1229
+ opt: zod.z["boolean"](),
1230
+ remote: zod.z["boolean"]().optional(),
1231
+ // The `s.videoset()` a set-backed field picks from.
1232
+ referencedModule: zod.z.string().optional()
1233
+ }));
1208
1234
  var DateOptions = zod.z.object({
1209
1235
  from: zod.z.string().optional(),
1210
1236
  to: zod.z.string().optional()
@@ -1295,7 +1321,7 @@ var SerializedValViewSchema = zod.z.object({
1295
1321
  hidden: zod.z["boolean"]().optional(),
1296
1322
  description: zod.z.string().optional()
1297
1323
  });
1298
- var SerializedSchema = zod.z.union([SerializedStringSchema, SerializedLiteralSchema, SerializedBooleanSchema, SerializedNumberSchema, SerializedObjectSchema, SerializedArraySchema, SerializedDiscriminatedUnionSchema, SerializedEnumSchema, SerializedRichTextSchema, SerializedRecordSchema, SerializedKeyOfSchema, SerializedRouteSchema, SerializedLocaleSchema, SerializedFileSchema, SerializedDateSchema, SerializedDateTimeSchema, SerializedColorSchema, SerializedCodeSchema, SerializedSettingsSchema, SerializedImageSchema, SerializedValViewSchema]);
1324
+ var SerializedSchema = zod.z.union([SerializedStringSchema, SerializedLiteralSchema, SerializedBooleanSchema, SerializedNumberSchema, SerializedObjectSchema, SerializedArraySchema, SerializedDiscriminatedUnionSchema, SerializedEnumSchema, SerializedRichTextSchema, SerializedRecordSchema, SerializedKeyOfSchema, SerializedRouteSchema, SerializedLocaleSchema, SerializedFileSchema, SerializedDateSchema, SerializedDateTimeSchema, SerializedColorSchema, SerializedCodeSchema, SerializedSettingsSchema, SerializedImageSchema, SerializedVideoSchema, SerializedValViewSchema]);
1299
1325
 
1300
1326
  var ValCommit = zod.z.object({
1301
1327
  commitSha: zod.z.string(),
@@ -1476,12 +1502,12 @@ var ValConfig = zod.z.object({
1476
1502
  project: zod.z.string().optional(),
1477
1503
  root: zod.z.string().optional(),
1478
1504
  files: zod.z.object({
1479
- directory: zod.z.string() // TODO: validate that it is prefixed by /public/
1505
+ remote: zod.z["boolean"]().optional()
1480
1506
  }).optional(),
1481
1507
  gitCommit: zod.z.string().optional(),
1482
1508
  gitBranch: zod.z.string().optional()
1483
1509
  });
1484
- var ValidationFixZ = zod.z.union([zod.z.literal("image:add-metadata"), zod.z.literal("image:check-metadata"), zod.z.literal("image:check-remote"), zod.z.literal("image:upload-remote"), zod.z.literal("image:download-remote"), zod.z.literal("images:check-remote"), zod.z.literal("images:upload-remote"), zod.z.literal("file:add-metadata"), zod.z.literal("file:check-metadata"), zod.z.literal("file:check-remote"), zod.z.literal("file:upload-remote"), zod.z.literal("file:download-remote"), zod.z.literal("files:check-remote"), zod.z.literal("files:upload-remote"), zod.z.literal("keyof:check-keys"), zod.z.literal("router:check-route"), zod.z.literal("locale:check-locale"), zod.z.literal("record:fill-keys"), zod.z.literal("images:check-unique-folder"), zod.z.literal("files:check-unique-folder"), zod.z.literal("images:check-all-files"), zod.z.literal("files:check-all-files"), zod.z.literal("jsonValues:extract-entry"), zod.z.literal("view:check-module")]);
1510
+ var ValidationFixZ = zod.z.union([zod.z.literal("image:add-metadata"), zod.z.literal("image:check-metadata"), zod.z.literal("image:check-remote"), zod.z.literal("image:upload-remote"), zod.z.literal("image:download-remote"), zod.z.literal("images:check-remote"), zod.z.literal("images:upload-remote"), zod.z.literal("file:add-metadata"), zod.z.literal("video:add-metadata"), zod.z.literal("video:upload-remote"), zod.z.literal("video:download-remote"), zod.z.literal("videos:add-metadata"), zod.z.literal("videos:check-remote"), zod.z.literal("videos:upload-remote"), zod.z.literal("file:check-metadata"), zod.z.literal("file:check-remote"), zod.z.literal("file:upload-remote"), zod.z.literal("file:download-remote"), zod.z.literal("files:check-remote"), zod.z.literal("files:upload-remote"), zod.z.literal("keyof:check-keys"), zod.z.literal("router:check-route"), zod.z.literal("locale:check-locale"), zod.z.literal("record:fill-keys"), zod.z.literal("images:check-unique-folder"), zod.z.literal("files:check-unique-folder"), zod.z.literal("images:check-all-files"), zod.z.literal("files:check-all-files"), zod.z.literal("videos:check-unique-folder"), zod.z.literal("videos:check-all-files"), zod.z.literal("jsonValues:extract-entry"), zod.z.literal("view:check-module")]);
1485
1511
  var ValidationError = zod.z.object({
1486
1512
  message: zod.z.string(),
1487
1513
  value: zod.z.unknown().optional(),
@@ -3194,11 +3220,23 @@ var Api = {
3194
3220
  return arg[0];
3195
3221
  }).optional(),
3196
3222
  remote: onlyOneStringQueryParam.optional()
3223
+ },
3224
+ // A `<video>` seeks with byte ranges, Safari will not play one from a
3225
+ // server that ignores them, and HLS segments that are byte ranges of
3226
+ // one file are fetched no other way.
3227
+ headers: {
3228
+ range: zod.z.string().optional()
3197
3229
  }
3198
3230
  },
3199
3231
  res: zod.z.union([unauthorizedResponse, notFoundResponse, zod.z.object({
3200
3232
  status: zod.z.literal(200),
3201
3233
  body: zod.z["instanceof"](ReadableStream)
3234
+ }), zod.z.object({
3235
+ status: zod.z.literal(206),
3236
+ body: zod.z["instanceof"](ReadableStream)
3237
+ }), zod.z.object({
3238
+ status: zod.z.literal(416),
3239
+ json: GenericError
3202
3240
  })])
3203
3241
  }
3204
3242
  },
@@ -5322,7 +5360,7 @@ function emptyOf(schema, context) {
5322
5360
  // language nobody chose, which is the thing this whole feature exists to
5323
5361
  // make visible.
5324
5362
  return (_context$selectedLoca = context === null || context === void 0 ? void 0 : context.selectedLocale) !== null && _context$selectedLoca !== void 0 ? _context$selectedLoca : "";
5325
- } else if (schema.type === "file" || schema.type === "image") {
5363
+ } else if (schema.type === "file" || schema.type === "image" || schema.type === "video") {
5326
5364
  return null; // returning null is the only thing we can do, however, it means that the patches cannot be applied yet since that might fail
5327
5365
  } else if (schema.type === "literal") {
5328
5366
  return schema.value;
@@ -5532,6 +5570,14 @@ function checkGallerySchema(moduleSchema) {
5532
5570
  if (moduleSchema.type === "record" && moduleSchema.mediaType === "images") {
5533
5571
  return null;
5534
5572
  }
5573
+ if (moduleSchema.type === "record" && moduleSchema.mediaType === "videos") {
5574
+ // Said outright rather than as "not an images gallery": a set of videos
5575
+ // looks like a gallery from here, and the tool can do nothing with one.
5576
+ return {
5577
+ kind: "error",
5578
+ message: "Module is a video set (s.videoset()), not an images gallery. Videos cannot be added or removed by this tool: upload them in Val Studio."
5579
+ };
5580
+ }
5535
5581
  if (moduleSchema.type === "image") {
5536
5582
  return {
5537
5583
  kind: "wrong-tool",
@@ -5626,17 +5672,32 @@ var GALLERY_REDIRECT = {
5626
5672
  reason: "Destination is a media gallery (s.imageset() / s.fileset()). Gallery entries are keyed by file path and carry a file on disk, so they cannot be created with a plain patch. Use add_session_image_to_gallery."
5627
5673
  };
5628
5674
 
5629
- /** An `s.imageset()` / `s.fileset()` record: a gallery, not an ordinary record. */
5675
+ /**
5676
+ * A video set's entries are keyed by a file too, and a stream's by a
5677
+ * directory of them — and there is no tool to send them to: a video is
5678
+ * uploaded (and, for a stream, transcoded) in the Studio.
5679
+ */
5680
+ var VIDEOSET_REFUSAL = {
5681
+ kind: "error",
5682
+ message: "Destination is a video set (s.videoset()). Its entries are keyed by file path and carry video files, so they cannot be created with a plain patch, and no tool here uploads a video: add it in Val Studio."
5683
+ };
5684
+
5685
+ /** An `s.imageset()` / `s.fileset()` / `s.videoset()` record: a gallery, not an ordinary record. */
5630
5686
  function isGallery(schema) {
5631
5687
  return schema.type === "record" && schema.mediaType !== undefined;
5632
5688
  }
5689
+
5690
+ /** Where to send someone whose destination is (in) the gallery `schema`. */
5691
+ function galleryRedirect(schema) {
5692
+ return schema.type === "record" && schema.mediaType === "videos" ? VIDEOSET_REFUSAL : GALLERY_REDIRECT;
5693
+ }
5633
5694
  function decideOp(moduleSchema, destinationPath) {
5634
5695
  // The DESTINATION itself, checked before its parent: `["gallery"]` resolves
5635
5696
  // its parent to the enclosing object and would otherwise look like an
5636
5697
  // ordinary `replace` that overwrites a whole gallery.
5637
5698
  var destination = resolveSerializedSchemaAtPath(moduleSchema, destinationPath);
5638
5699
  if (destination.kind === "gallery-traversed") {
5639
- return GALLERY_REDIRECT;
5700
+ return galleryRedirect(destination.schema);
5640
5701
  }
5641
5702
  if (destination.kind === "richtext") {
5642
5703
  return {
@@ -5647,7 +5708,7 @@ function decideOp(moduleSchema, destinationPath) {
5647
5708
  }
5648
5709
  if (destination.kind === "leaf") {
5649
5710
  if (isGallery(destination.schema)) {
5650
- return GALLERY_REDIRECT;
5711
+ return galleryRedirect(destination.schema);
5651
5712
  }
5652
5713
  // A richtext value the path lands exactly ON resolves as a leaf, not as
5653
5714
  // `kind: "richtext"` (which only fires when the walk continues INTO it).
@@ -5684,7 +5745,7 @@ function decideOp(moduleSchema, destinationPath) {
5684
5745
  // destination is a gallery entry; `isGallery` catches the case where the
5685
5746
  // parent IS the gallery and the destination is a new entry key in it.
5686
5747
  if (parent.kind === "gallery-traversed" || isGallery(parent.schema)) {
5687
- return GALLERY_REDIRECT;
5748
+ return galleryRedirect(parent.schema);
5688
5749
  }
5689
5750
  var schema = parent.schema;
5690
5751
  if (schema.type === "array" || schema.type === "record") {
@@ -6005,6 +6066,14 @@ function isSkippableFixCode(fix) {
6005
6066
  case "file:check-remote":
6006
6067
  case "files:check-remote":
6007
6068
  case "files:upload-remote":
6069
+ case "video:add-metadata": // the Studio writes it on upload; --fix for the rest
6070
+ case "video:upload-remote":
6071
+ case "video:download-remote":
6072
+ case "videos:add-metadata": // as `video:add-metadata`, for a set's entry
6073
+ case "videos:check-remote":
6074
+ case "videos:upload-remote":
6075
+ case "videos:check-unique-folder":
6076
+ case "videos:check-all-files":
6008
6077
  case "images:check-unique-folder":
6009
6078
  case "files:check-unique-folder":
6010
6079
  case "images:check-all-files":
@@ -6329,8 +6398,8 @@ function traverseSchemaSource(source, schema, path, callback) {
6329
6398
  return;
6330
6399
  }
6331
6400
 
6332
- // Handle file/image
6333
- if (schema.type === "file" || schema.type === "image") {
6401
+ // Handle file/image/video
6402
+ if (schema.type === "file" || schema.type === "image" || schema.type === "video") {
6334
6403
  if (source && getSitemapTree._typeof(source) === "object" && "path" in source && typeof source.path === "string") {
6335
6404
  callback({
6336
6405
  source: source,
@@ -6677,8 +6746,8 @@ function indexModule(searchIndex, moduleFilePath, source, schema) {
6677
6746
  // Use first 50 chars as label
6678
6747
  label = searchText.substring(0, 50) || "richtext";
6679
6748
  }
6680
- // Handle file/image
6681
- else if (schema.type === "file" || schema.type === "image") {
6749
+ // Handle file/image/video
6750
+ else if (schema.type === "file" || schema.type === "image" || schema.type === "video") {
6682
6751
  if (source !== null && getSitemapTree._typeof(source) === "object" && "path" in source && typeof source.path === "string") {
6683
6752
  // The label is the bare filename - the folder is shown separately in
6684
6753
  // the UI - but both are searchable.
@@ -7852,6 +7921,7 @@ exports.SerializedSchema = SerializedSchema;
7852
7921
  exports.SerializedSettingsSchema = SerializedSettingsSchema;
7853
7922
  exports.SerializedStringSchema = SerializedStringSchema;
7854
7923
  exports.SerializedValViewSchema = SerializedValViewSchema;
7924
+ exports.SerializedVideoSchema = SerializedVideoSchema;
7855
7925
  exports.SharedValConfig = SharedValConfig;
7856
7926
  exports.VAL_ENABLE_COOKIE_NAME = VAL_ENABLE_COOKIE_NAME;
7857
7927
  exports.VAL_GREEN_RAMP = VAL_GREEN_RAMP;
@@ -7860,6 +7930,8 @@ exports.VAL_STATE_COOKIE = VAL_STATE_COOKIE;
7860
7930
  exports.VAL_STUDIO_HEADER = VAL_STUDIO_HEADER;
7861
7931
  exports.ValCommit = ValCommit;
7862
7932
  exports.ValDeployment = ValDeployment;
7933
+ exports.VideoOptions = VideoOptions;
7934
+ exports.VideoStreamOption = VideoStreamOption;
7863
7935
  exports.accentRamp = accentRamp;
7864
7936
  exports.buildDuplicatePatch = buildDuplicatePatch;
7865
7937
  exports.buildEmptyAtPathPatch = buildEmptyAtPathPatch;
@@ -1158,13 +1158,16 @@ var SerializedRecordSchema = z.lazy(function () {
1158
1158
  type: z.literal("record"),
1159
1159
  item: SerializedSchema,
1160
1160
  opt: z["boolean"](),
1161
- // Optional gallery marker for files/images
1162
- mediaType: z.union([z.literal("files"), z.literal("images")]).optional(),
1161
+ // Optional gallery marker for files/images/videos
1162
+ mediaType: z.union([z.literal("files"), z.literal("images"), z.literal("videos")]).optional(),
1163
1163
  // Optional legacy gallery metadata
1164
1164
  accept: z.string().optional(),
1165
1165
  dir: z.string().optional(),
1166
1166
  remote: z["boolean"]().optional(),
1167
1167
  encode: ImageEncodeOption.optional(),
1168
+ // A videoset's: see `VideoStreamOption` below for why it is spelled
1169
+ // out rather than passed through.
1170
+ stream: VideoStreamOption.optional(),
1168
1171
  alt: SerializedSchema.optional(),
1169
1172
  moduleMetadata: z.record(z.string(), z.record(z.string(), z.any())).optional()
1170
1173
  })).passthrough());
@@ -1198,6 +1201,29 @@ var SerializedFileSchema = z.object(_objectSpread2(_objectSpread2({}, commonSche
1198
1201
  remote: z["boolean"]().optional(),
1199
1202
  referencedModule: z.string().optional()
1200
1203
  }));
1204
+
1205
+ // `stream` is the one option that changes what an upload BECOMES, so it is
1206
+ // declared field by field: these z.objects strip unknown keys, and a stream
1207
+ // dropped in transit is a Studio that uploads a 2 GB mp4 where an HLS stream
1208
+ // was asked for.
1209
+ var VideoStreamOption = z.union([z.literal(false), z.object({
1210
+ type: z.literal("hls"),
1211
+ renditions: z.array(z.number()).optional(),
1212
+ segmentDuration: z.number().optional()
1213
+ })]);
1214
+ var VideoOptions = z.object({
1215
+ dir: z.string().optional(),
1216
+ accept: z.string().optional(),
1217
+ stream: VideoStreamOption.optional()
1218
+ });
1219
+ var SerializedVideoSchema = z.object(_objectSpread2(_objectSpread2({}, commonSchemaFields), {}, {
1220
+ type: z.literal("video"),
1221
+ options: VideoOptions.optional(),
1222
+ opt: z["boolean"](),
1223
+ remote: z["boolean"]().optional(),
1224
+ // The `s.videoset()` a set-backed field picks from.
1225
+ referencedModule: z.string().optional()
1226
+ }));
1201
1227
  var DateOptions = z.object({
1202
1228
  from: z.string().optional(),
1203
1229
  to: z.string().optional()
@@ -1288,7 +1314,7 @@ var SerializedValViewSchema = z.object({
1288
1314
  hidden: z["boolean"]().optional(),
1289
1315
  description: z.string().optional()
1290
1316
  });
1291
- var SerializedSchema = z.union([SerializedStringSchema, SerializedLiteralSchema, SerializedBooleanSchema, SerializedNumberSchema, SerializedObjectSchema, SerializedArraySchema, SerializedDiscriminatedUnionSchema, SerializedEnumSchema, SerializedRichTextSchema, SerializedRecordSchema, SerializedKeyOfSchema, SerializedRouteSchema, SerializedLocaleSchema, SerializedFileSchema, SerializedDateSchema, SerializedDateTimeSchema, SerializedColorSchema, SerializedCodeSchema, SerializedSettingsSchema, SerializedImageSchema, SerializedValViewSchema]);
1317
+ var SerializedSchema = z.union([SerializedStringSchema, SerializedLiteralSchema, SerializedBooleanSchema, SerializedNumberSchema, SerializedObjectSchema, SerializedArraySchema, SerializedDiscriminatedUnionSchema, SerializedEnumSchema, SerializedRichTextSchema, SerializedRecordSchema, SerializedKeyOfSchema, SerializedRouteSchema, SerializedLocaleSchema, SerializedFileSchema, SerializedDateSchema, SerializedDateTimeSchema, SerializedColorSchema, SerializedCodeSchema, SerializedSettingsSchema, SerializedImageSchema, SerializedVideoSchema, SerializedValViewSchema]);
1292
1318
 
1293
1319
  var ValCommit = z.object({
1294
1320
  commitSha: z.string(),
@@ -1469,12 +1495,12 @@ var ValConfig = z.object({
1469
1495
  project: z.string().optional(),
1470
1496
  root: z.string().optional(),
1471
1497
  files: z.object({
1472
- directory: z.string() // TODO: validate that it is prefixed by /public/
1498
+ remote: z["boolean"]().optional()
1473
1499
  }).optional(),
1474
1500
  gitCommit: z.string().optional(),
1475
1501
  gitBranch: z.string().optional()
1476
1502
  });
1477
- var ValidationFixZ = z.union([z.literal("image:add-metadata"), z.literal("image:check-metadata"), z.literal("image:check-remote"), z.literal("image:upload-remote"), z.literal("image:download-remote"), z.literal("images:check-remote"), z.literal("images:upload-remote"), z.literal("file:add-metadata"), z.literal("file:check-metadata"), z.literal("file:check-remote"), z.literal("file:upload-remote"), z.literal("file:download-remote"), z.literal("files:check-remote"), z.literal("files:upload-remote"), z.literal("keyof:check-keys"), z.literal("router:check-route"), z.literal("locale:check-locale"), z.literal("record:fill-keys"), z.literal("images:check-unique-folder"), z.literal("files:check-unique-folder"), z.literal("images:check-all-files"), z.literal("files:check-all-files"), z.literal("jsonValues:extract-entry"), z.literal("view:check-module")]);
1503
+ var ValidationFixZ = z.union([z.literal("image:add-metadata"), z.literal("image:check-metadata"), z.literal("image:check-remote"), z.literal("image:upload-remote"), z.literal("image:download-remote"), z.literal("images:check-remote"), z.literal("images:upload-remote"), z.literal("file:add-metadata"), z.literal("video:add-metadata"), z.literal("video:upload-remote"), z.literal("video:download-remote"), z.literal("videos:add-metadata"), z.literal("videos:check-remote"), z.literal("videos:upload-remote"), z.literal("file:check-metadata"), z.literal("file:check-remote"), z.literal("file:upload-remote"), z.literal("file:download-remote"), z.literal("files:check-remote"), z.literal("files:upload-remote"), z.literal("keyof:check-keys"), z.literal("router:check-route"), z.literal("locale:check-locale"), z.literal("record:fill-keys"), z.literal("images:check-unique-folder"), z.literal("files:check-unique-folder"), z.literal("images:check-all-files"), z.literal("files:check-all-files"), z.literal("videos:check-unique-folder"), z.literal("videos:check-all-files"), z.literal("jsonValues:extract-entry"), z.literal("view:check-module")]);
1478
1504
  var ValidationError = z.object({
1479
1505
  message: z.string(),
1480
1506
  value: z.unknown().optional(),
@@ -3187,11 +3213,23 @@ var Api = {
3187
3213
  return arg[0];
3188
3214
  }).optional(),
3189
3215
  remote: onlyOneStringQueryParam.optional()
3216
+ },
3217
+ // A `<video>` seeks with byte ranges, Safari will not play one from a
3218
+ // server that ignores them, and HLS segments that are byte ranges of
3219
+ // one file are fetched no other way.
3220
+ headers: {
3221
+ range: z.string().optional()
3190
3222
  }
3191
3223
  },
3192
3224
  res: z.union([unauthorizedResponse, notFoundResponse, z.object({
3193
3225
  status: z.literal(200),
3194
3226
  body: z["instanceof"](ReadableStream)
3227
+ }), z.object({
3228
+ status: z.literal(206),
3229
+ body: z["instanceof"](ReadableStream)
3230
+ }), z.object({
3231
+ status: z.literal(416),
3232
+ json: GenericError
3195
3233
  })])
3196
3234
  }
3197
3235
  },
@@ -5315,7 +5353,7 @@ function emptyOf(schema, context) {
5315
5353
  // language nobody chose, which is the thing this whole feature exists to
5316
5354
  // make visible.
5317
5355
  return (_context$selectedLoca = context === null || context === void 0 ? void 0 : context.selectedLocale) !== null && _context$selectedLoca !== void 0 ? _context$selectedLoca : "";
5318
- } else if (schema.type === "file" || schema.type === "image") {
5356
+ } else if (schema.type === "file" || schema.type === "image" || schema.type === "video") {
5319
5357
  return null; // returning null is the only thing we can do, however, it means that the patches cannot be applied yet since that might fail
5320
5358
  } else if (schema.type === "literal") {
5321
5359
  return schema.value;
@@ -5525,6 +5563,14 @@ function checkGallerySchema(moduleSchema) {
5525
5563
  if (moduleSchema.type === "record" && moduleSchema.mediaType === "images") {
5526
5564
  return null;
5527
5565
  }
5566
+ if (moduleSchema.type === "record" && moduleSchema.mediaType === "videos") {
5567
+ // Said outright rather than as "not an images gallery": a set of videos
5568
+ // looks like a gallery from here, and the tool can do nothing with one.
5569
+ return {
5570
+ kind: "error",
5571
+ message: "Module is a video set (s.videoset()), not an images gallery. Videos cannot be added or removed by this tool: upload them in Val Studio."
5572
+ };
5573
+ }
5528
5574
  if (moduleSchema.type === "image") {
5529
5575
  return {
5530
5576
  kind: "wrong-tool",
@@ -5619,17 +5665,32 @@ var GALLERY_REDIRECT = {
5619
5665
  reason: "Destination is a media gallery (s.imageset() / s.fileset()). Gallery entries are keyed by file path and carry a file on disk, so they cannot be created with a plain patch. Use add_session_image_to_gallery."
5620
5666
  };
5621
5667
 
5622
- /** An `s.imageset()` / `s.fileset()` record: a gallery, not an ordinary record. */
5668
+ /**
5669
+ * A video set's entries are keyed by a file too, and a stream's by a
5670
+ * directory of them — and there is no tool to send them to: a video is
5671
+ * uploaded (and, for a stream, transcoded) in the Studio.
5672
+ */
5673
+ var VIDEOSET_REFUSAL = {
5674
+ kind: "error",
5675
+ message: "Destination is a video set (s.videoset()). Its entries are keyed by file path and carry video files, so they cannot be created with a plain patch, and no tool here uploads a video: add it in Val Studio."
5676
+ };
5677
+
5678
+ /** An `s.imageset()` / `s.fileset()` / `s.videoset()` record: a gallery, not an ordinary record. */
5623
5679
  function isGallery(schema) {
5624
5680
  return schema.type === "record" && schema.mediaType !== undefined;
5625
5681
  }
5682
+
5683
+ /** Where to send someone whose destination is (in) the gallery `schema`. */
5684
+ function galleryRedirect(schema) {
5685
+ return schema.type === "record" && schema.mediaType === "videos" ? VIDEOSET_REFUSAL : GALLERY_REDIRECT;
5686
+ }
5626
5687
  function decideOp(moduleSchema, destinationPath) {
5627
5688
  // The DESTINATION itself, checked before its parent: `["gallery"]` resolves
5628
5689
  // its parent to the enclosing object and would otherwise look like an
5629
5690
  // ordinary `replace` that overwrites a whole gallery.
5630
5691
  var destination = resolveSerializedSchemaAtPath(moduleSchema, destinationPath);
5631
5692
  if (destination.kind === "gallery-traversed") {
5632
- return GALLERY_REDIRECT;
5693
+ return galleryRedirect(destination.schema);
5633
5694
  }
5634
5695
  if (destination.kind === "richtext") {
5635
5696
  return {
@@ -5640,7 +5701,7 @@ function decideOp(moduleSchema, destinationPath) {
5640
5701
  }
5641
5702
  if (destination.kind === "leaf") {
5642
5703
  if (isGallery(destination.schema)) {
5643
- return GALLERY_REDIRECT;
5704
+ return galleryRedirect(destination.schema);
5644
5705
  }
5645
5706
  // A richtext value the path lands exactly ON resolves as a leaf, not as
5646
5707
  // `kind: "richtext"` (which only fires when the walk continues INTO it).
@@ -5677,7 +5738,7 @@ function decideOp(moduleSchema, destinationPath) {
5677
5738
  // destination is a gallery entry; `isGallery` catches the case where the
5678
5739
  // parent IS the gallery and the destination is a new entry key in it.
5679
5740
  if (parent.kind === "gallery-traversed" || isGallery(parent.schema)) {
5680
- return GALLERY_REDIRECT;
5741
+ return galleryRedirect(parent.schema);
5681
5742
  }
5682
5743
  var schema = parent.schema;
5683
5744
  if (schema.type === "array" || schema.type === "record") {
@@ -5998,6 +6059,14 @@ function isSkippableFixCode(fix) {
5998
6059
  case "file:check-remote":
5999
6060
  case "files:check-remote":
6000
6061
  case "files:upload-remote":
6062
+ case "video:add-metadata": // the Studio writes it on upload; --fix for the rest
6063
+ case "video:upload-remote":
6064
+ case "video:download-remote":
6065
+ case "videos:add-metadata": // as `video:add-metadata`, for a set's entry
6066
+ case "videos:check-remote":
6067
+ case "videos:upload-remote":
6068
+ case "videos:check-unique-folder":
6069
+ case "videos:check-all-files":
6001
6070
  case "images:check-unique-folder":
6002
6071
  case "files:check-unique-folder":
6003
6072
  case "images:check-all-files":
@@ -6322,8 +6391,8 @@ function traverseSchemaSource(source, schema, path, callback) {
6322
6391
  return;
6323
6392
  }
6324
6393
 
6325
- // Handle file/image
6326
- if (schema.type === "file" || schema.type === "image") {
6394
+ // Handle file/image/video
6395
+ if (schema.type === "file" || schema.type === "image" || schema.type === "video") {
6327
6396
  if (source && _typeof(source) === "object" && "path" in source && typeof source.path === "string") {
6328
6397
  callback({
6329
6398
  source: source,
@@ -6670,8 +6739,8 @@ function indexModule(searchIndex, moduleFilePath, source, schema) {
6670
6739
  // Use first 50 chars as label
6671
6740
  label = searchText.substring(0, 50) || "richtext";
6672
6741
  }
6673
- // Handle file/image
6674
- else if (schema.type === "file" || schema.type === "image") {
6742
+ // Handle file/image/video
6743
+ else if (schema.type === "file" || schema.type === "image" || schema.type === "video") {
6675
6744
  if (source !== null && _typeof(source) === "object" && "path" in source && typeof source.path === "string") {
6676
6745
  // The label is the bare filename - the folder is shown separately in
6677
6746
  // the UI - but both are searchable.
@@ -7761,4 +7830,4 @@ function parse(schema, body, call) {
7761
7830
  return parsed.data;
7762
7831
  }
7763
7832
 
7764
- export { AA_LARGE, AA_TEXT, Api, BRAND_CONTRAST_PAIRS, BinaryFileRef, CodeOptions, ColorOptions, DEFAULT_ERROR_MESSAGE, DateOptions, ENCODE_DEFAULTS, ENCODE_MIME_TYPE_OF, FileOptions, HistoricalCommit, HistoricalModule, HistoricalPatchSet, HistoryError, ImageEncodeOption, ImageOptions, JSONValue, JSON_ENTRIES_BATCH_MAX, ModuleComparison, NEVER_ENCODED, ParentRef$1 as ParentRef, Patch, PatchBlock, PatchGroup, PatchId, PatchJSON, PublishProtocolError, RAMP_STEPS, RemirrorBr, RemirrorBulletList, RemirrorHeading, RemirrorImage, RemirrorJSON, RemirrorLinkMark, RemirrorListItem, RemirrorOrderedList, RemirrorParagraph, RemirrorText, RemirrorTextMark, RestoreVerdict, RichTextOptions, SCHEMA_SOURCE_FIXES, SerializedArraySchema, SerializedBooleanSchema, SerializedCodeSchema, SerializedColorSchema, SerializedDateSchema, SerializedDateTimeSchema, SerializedDiscriminatedUnionSchema, SerializedEnumSchema, SerializedFileSchema, SerializedImageSchema, SerializedKeyOfSchema, SerializedLiteralSchema, SerializedLocaleSchema, SerializedNumberSchema, SerializedObjectSchema, SerializedRecordSchema, SerializedRichTextSchema, SerializedRouteSchema, SerializedSchema, SerializedSettingsSchema, SerializedStringSchema, SerializedValViewSchema, SharedValConfig, VAL_ENABLE_COOKIE_NAME, VAL_GREEN_RAMP, VAL_SESSION_COOKIE, VAL_STATE_COOKIE, VAL_STUDIO_HEADER, ValCommit, ValDeployment, accentRamp, buildDuplicatePatch, buildEmptyAtPathPatch, buildFileRefValue, buildImageGalleryPatch, buildRemoveImageGalleryEntryPatch, buildSearchIndex, chainHeadOf, checkCompatibility, chooseEncoded, concatModulePath, contrastRatio, createRegExpFromPattern, createSearchIndex, createValClient, declaredLocales, describeContainerAtPath, emptyOf, explainIncompatible, filterBlockingValidationErrors, filterRoutesByPatterns, findSimilar, fitWithin, flattenRichText, getErrorMessageFromUnknownJson, getFilenameFromRef, getInlineImgInfo, getKeyOfRecordAt, getRefParts, getRoutesOf, getRoutesWithModulePaths, getSourceAt, indexModule, isMimeTypeAccepted, isRemoteSchema, isSchemaSourceFixError, isSkippedSource, keyOfRecordPath, levenshtein, localeAt, memoizePerRequest, newestCommitSha, parseArtifacts, parseBuildTarget, parseCancel, parseDeclare, parseDiscard, parseJob, parseNewestCiRun, parsePress, parseProblems, parseProjectSource, parsePromote, parsePublishToken, parseRenew, parseRequestStatus, parseStatus, parseUpdateTarget, parseVerify, partitionValidationErrors, performSearch, relativeLuminance, remirrorToRichTextSource, removeModule, resolveEncodeSettings, resolvePairGround, resolveSchemaSourceFixForError, resolveSchemaSourceFixes, resolveSerializedSchemaAtPath, richTextToRemirror, safeParsePatch, sourcePathOfChild, themeCustomProperties, toolNames, traverseSchemaSource, urlOf, validateRoutePatterns, withExtension };
7833
+ export { AA_LARGE, AA_TEXT, Api, BRAND_CONTRAST_PAIRS, BinaryFileRef, CodeOptions, ColorOptions, DEFAULT_ERROR_MESSAGE, DateOptions, ENCODE_DEFAULTS, ENCODE_MIME_TYPE_OF, FileOptions, HistoricalCommit, HistoricalModule, HistoricalPatchSet, HistoryError, ImageEncodeOption, ImageOptions, JSONValue, JSON_ENTRIES_BATCH_MAX, ModuleComparison, NEVER_ENCODED, ParentRef$1 as ParentRef, Patch, PatchBlock, PatchGroup, PatchId, PatchJSON, PublishProtocolError, RAMP_STEPS, RemirrorBr, RemirrorBulletList, RemirrorHeading, RemirrorImage, RemirrorJSON, RemirrorLinkMark, RemirrorListItem, RemirrorOrderedList, RemirrorParagraph, RemirrorText, RemirrorTextMark, RestoreVerdict, RichTextOptions, SCHEMA_SOURCE_FIXES, SerializedArraySchema, SerializedBooleanSchema, SerializedCodeSchema, SerializedColorSchema, SerializedDateSchema, SerializedDateTimeSchema, SerializedDiscriminatedUnionSchema, SerializedEnumSchema, SerializedFileSchema, SerializedImageSchema, SerializedKeyOfSchema, SerializedLiteralSchema, SerializedLocaleSchema, SerializedNumberSchema, SerializedObjectSchema, SerializedRecordSchema, SerializedRichTextSchema, SerializedRouteSchema, SerializedSchema, SerializedSettingsSchema, SerializedStringSchema, SerializedValViewSchema, SerializedVideoSchema, SharedValConfig, VAL_ENABLE_COOKIE_NAME, VAL_GREEN_RAMP, VAL_SESSION_COOKIE, VAL_STATE_COOKIE, VAL_STUDIO_HEADER, ValCommit, ValDeployment, VideoOptions, VideoStreamOption, accentRamp, buildDuplicatePatch, buildEmptyAtPathPatch, buildFileRefValue, buildImageGalleryPatch, buildRemoveImageGalleryEntryPatch, buildSearchIndex, chainHeadOf, checkCompatibility, chooseEncoded, concatModulePath, contrastRatio, createRegExpFromPattern, createSearchIndex, createValClient, declaredLocales, describeContainerAtPath, emptyOf, explainIncompatible, filterBlockingValidationErrors, filterRoutesByPatterns, findSimilar, fitWithin, flattenRichText, getErrorMessageFromUnknownJson, getFilenameFromRef, getInlineImgInfo, getKeyOfRecordAt, getRefParts, getRoutesOf, getRoutesWithModulePaths, getSourceAt, indexModule, isMimeTypeAccepted, isRemoteSchema, isSchemaSourceFixError, isSkippedSource, keyOfRecordPath, levenshtein, localeAt, memoizePerRequest, newestCommitSha, parseArtifacts, parseBuildTarget, parseCancel, parseDeclare, parseDiscard, parseJob, parseNewestCiRun, parsePress, parseProblems, parseProjectSource, parsePromote, parsePublishToken, parseRenew, parseRequestStatus, parseStatus, parseUpdateTarget, parseVerify, partitionValidationErrors, performSearch, relativeLuminance, remirrorToRichTextSource, removeModule, resolveEncodeSettings, resolvePairGround, resolveSchemaSourceFixForError, resolveSchemaSourceFixes, resolveSerializedSchemaAtPath, richTextToRemirror, safeParsePatch, sourcePathOfChild, themeCustomProperties, toolNames, traverseSchemaSource, urlOf, validateRoutePatterns, withExtension };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@valbuild/shared",
3
- "version": "0.140.2",
3
+ "version": "0.141.0",
4
4
  "private": false,
5
5
  "description": "Val shared types and utilities",
6
6
  "repository": {
@@ -37,7 +37,7 @@
37
37
  "flexsearch": "^0.8.212",
38
38
  "zod": "^4.4.3",
39
39
  "zod-validation-error": "^5.0.0",
40
- "@valbuild/core": "0.139.1"
40
+ "@valbuild/core": "0.141.0"
41
41
  },
42
42
  "files": [
43
43
  "CHANGELOG.md",