@valbuild/react 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 +55 -0
- package/dist/declarations/src/stega/index.d.ts +1 -1
- package/dist/declarations/src/stega/stegaEncode.d.ts +37 -2
- package/dist/{raw-ec62616c.cjs.dev.js → raw-1fce8756.cjs.dev.js} +65 -15
- package/dist/{raw-1280c322.worker.esm.js → raw-26e85a34.esm.js} +66 -16
- package/dist/{raw-bd3105cd.esm.js → raw-55a21edc.worker.esm.js} +66 -16
- package/dist/{raw-3ae44ab5.cjs.prod.js → raw-68a490e6.cjs.prod.js} +65 -15
- package/dist/{raw-d6f65f06.browser.esm.js → raw-be2fd916.browser.esm.js} +65 -15
- package/internal/dist/valbuild-react-internal.browser.esm.js +1 -1
- package/internal/dist/valbuild-react-internal.cjs.dev.js +1 -1
- package/internal/dist/valbuild-react-internal.cjs.prod.js +1 -1
- package/internal/dist/valbuild-react-internal.esm.js +1 -1
- package/internal/dist/valbuild-react-internal.worker.esm.js +1 -1
- package/package.json +4 -4
- package/stega/dist/valbuild-react-stega.browser.esm.js +2 -2
- package/stega/dist/valbuild-react-stega.cjs.dev.js +1 -1
- package/stega/dist/valbuild-react-stega.cjs.prod.js +1 -1
- package/stega/dist/valbuild-react-stega.esm.js +2 -2
- package/stega/dist/valbuild-react-stega.worker.esm.js +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,60 @@
|
|
|
1
1
|
# @valbuild/react
|
|
2
2
|
|
|
3
|
+
## 0.141.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#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.
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
const schema = s.object({
|
|
11
|
+
intro: s.video({ stream: { type: "hls" } }),
|
|
12
|
+
});
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
- **Upload and play in the Studio.** A video field shows a player, the file's size and length, and progress while it uploads.
|
|
16
|
+
- **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.
|
|
17
|
+
- **Poster:** pause on a frame and choose "Use current frame". The frame is saved as an image, and `posterTime` records where it was taken.
|
|
18
|
+
- **Start and end:** play part of a video without cutting the file.
|
|
19
|
+
- **Focal point:** marks what must stay in frame when the page crops the video.
|
|
20
|
+
- **Description:** text for people who can't see the video.
|
|
21
|
+
- **Captions:** one WebVTT file per language. `.srt` files are converted on upload.
|
|
22
|
+
- **`<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.
|
|
23
|
+
- **Rename** a video in the Studio. An HLS stream is renamed as a whole: every playlist and segment moves to the new folder.
|
|
24
|
+
- `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.
|
|
25
|
+
- `.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.
|
|
26
|
+
|
|
27
|
+
A video value always has a `mimeType`: it is how a page knows whether it has an `.mp4` or an `.m3u8`.
|
|
28
|
+
|
|
29
|
+
New: `s.videoset()`, a collection of videos, like `s.imageset()` for images.
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
const videosVal = c.define(
|
|
33
|
+
"/content/videos.val.ts",
|
|
34
|
+
s.videoset({ dir: "/public/val/videos", stream: { type: "hls" } }),
|
|
35
|
+
{},
|
|
36
|
+
);
|
|
37
|
+
const schema = s.object({ intro: s.video(videosVal) });
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
- **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.
|
|
41
|
+
- **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.
|
|
42
|
+
- **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".
|
|
43
|
+
- `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.
|
|
44
|
+
- `.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.
|
|
45
|
+
|
|
46
|
+
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.
|
|
47
|
+
|
|
48
|
+
- 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.
|
|
49
|
+
- 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`.
|
|
50
|
+
|
|
51
|
+
### Patch Changes
|
|
52
|
+
|
|
53
|
+
- Updated dependencies [[`199e214`](https://github.com/valbuild/val/commit/199e21471d98806fb34c579cb876560078c928b9), [`9cbe428`](https://github.com/valbuild/val/commit/9cbe42895d006d55c3d993dc27f0779808b85306), [`fb5f097`](https://github.com/valbuild/val/commit/fb5f09721ac07f4d90b8502fdbee3fb3884d9688), [`6473a2e`](https://github.com/valbuild/val/commit/6473a2efe874f1749b27ed6f8ac4e0d19805edb1), [`ba3f330`](https://github.com/valbuild/val/commit/ba3f3300a3dd8649e154097cdfca3b64db209d89)]:
|
|
54
|
+
- @valbuild/core@0.141.0
|
|
55
|
+
- @valbuild/shared@0.141.0
|
|
56
|
+
- @valbuild/ui@0.141.0
|
|
57
|
+
|
|
3
58
|
## 0.140.2
|
|
4
59
|
|
|
5
60
|
### Patch Changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { autoTagJSX } from "./autoTagJSX.js";
|
|
2
|
-
export { stegaEncode, getModuleIds, stegaClean, type ValEncodedString, type StegaOfSource, type ResolvedVal, type Resolvable, type JsonEntryContentOf, type RouteValueOf, type StegaOfRichTextSource, type File, type Image, type RichText, } from "./stegaEncode.js";
|
|
2
|
+
export { stegaEncode, getModuleIds, stegaClean, type ValEncodedString, type StegaOfSource, type ResolvedVal, type Resolvable, type JsonEntryContentOf, type RouteValueOf, type StegaOfRichTextSource, type File, type Image, type Video, type RichText, } from "./stegaEncode.js";
|
|
3
3
|
export { stegaDecodeStrings } from "./stegaDecodeStrings.js";
|
|
4
4
|
export { attrs } from "./attrs.js";
|
|
5
5
|
export { raw, type DecodeVal } from "./raw.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Json, RichTextSource, MediaHotspot, RichTextOptions, ImageSource } from "@valbuild/core";
|
|
1
|
+
import { Json, RichTextSource, IsVideoSource, VideoCaptionSource, MediaHotspot, RichTextOptions, ImageSource } from "@valbuild/core";
|
|
2
2
|
import { FileSource, Source, SourceObject } from "@valbuild/core";
|
|
3
3
|
import type { ValView, ValViewSource } from "@valbuild/core";
|
|
4
4
|
import { JsonPrimitive } from "@valbuild/core";
|
|
@@ -168,6 +168,41 @@ export type File = {
|
|
|
168
168
|
readonly url: ValEncodedString;
|
|
169
169
|
readonly mimeType?: string;
|
|
170
170
|
};
|
|
171
|
+
/**
|
|
172
|
+
* A video as a consumer sees it: what was authored, plus a generated `url` on
|
|
173
|
+
* the video, on its poster and on each caption track.
|
|
174
|
+
*
|
|
175
|
+
* Only the video's own `url` carries the edit tag — a click on the player
|
|
176
|
+
* reaches the field. The poster and the captions are parts of the same field,
|
|
177
|
+
* not fields of their own, so their URLs are plain.
|
|
178
|
+
*
|
|
179
|
+
* An HLS stream (`mimeType` `application/vnd.apple.mpegurl`) plays natively in
|
|
180
|
+
* Safari and needs a library such as hls.js everywhere else; `url` is then the
|
|
181
|
+
* master playlist.
|
|
182
|
+
*/
|
|
183
|
+
export type Video = {
|
|
184
|
+
readonly path: string;
|
|
185
|
+
readonly url: ValEncodedString;
|
|
186
|
+
readonly mimeType: string;
|
|
187
|
+
readonly width?: number;
|
|
188
|
+
readonly height?: number;
|
|
189
|
+
readonly duration?: number;
|
|
190
|
+
readonly alt?: string;
|
|
191
|
+
readonly hotspot?: MediaHotspot;
|
|
192
|
+
readonly posterTime?: number;
|
|
193
|
+
readonly poster?: {
|
|
194
|
+
readonly path: string;
|
|
195
|
+
readonly url: string;
|
|
196
|
+
readonly width?: number;
|
|
197
|
+
readonly height?: number;
|
|
198
|
+
readonly mimeType?: string;
|
|
199
|
+
};
|
|
200
|
+
readonly startTime?: number;
|
|
201
|
+
readonly endTime?: number;
|
|
202
|
+
readonly captions?: readonly (Omit<VideoCaptionSource, "patch_id"> & {
|
|
203
|
+
readonly url: string;
|
|
204
|
+
})[];
|
|
205
|
+
};
|
|
171
206
|
export type StegaOfRichTextSource<T extends Source> = Json extends T ? Json : T extends ImageSource ? Image : T extends SourceObject ? {
|
|
172
207
|
[key in keyof T]: StegaOfRichTextSource<T[key]>;
|
|
173
208
|
} : T extends SourceArray ? StegaOfRichTextSource<T[number]>[] : T extends JsonPrimitive ? T : never;
|
|
@@ -177,7 +212,7 @@ export type StegaOfRichTextSource<T extends Source> = Json extends T ? Json : T
|
|
|
177
212
|
export type RichText<O extends RichTextOptions> = StegaOfRichTextSource<RichTextSource<O>> & {
|
|
178
213
|
readonly __brand?: "RichText";
|
|
179
214
|
};
|
|
180
|
-
export type StegaOfSource<T extends Source> = Json extends T ? Json : T extends RichTextSource<infer O> ? RichText<O> : T extends ImageSource ? Image : T extends FileSource ? File : T extends ValViewSource<string, infer Target> ? ValView<Target> : T extends SourceObject ? {
|
|
215
|
+
export type StegaOfSource<T extends Source> = Json extends T ? Json : T extends RichTextSource<infer O> ? RichText<O> : IsVideoSource<T> extends true ? Video : T extends ImageSource ? Image : T extends FileSource ? File : T extends ValViewSource<string, infer Target> ? ValView<Target> : T extends SourceObject ? {
|
|
181
216
|
[key in keyof T]: StegaOfSource<T[key]>;
|
|
182
217
|
} : T extends SourceArray ? StegaOfSource<T[number]>[] : T extends RawString ? string : string extends T ? ValEncodedString : T extends JsonPrimitive ? T : never;
|
|
183
218
|
/**
|
|
@@ -140,6 +140,19 @@ function _objectSpread2(e) {
|
|
|
140
140
|
* would corrupt every URL built from it.
|
|
141
141
|
*/
|
|
142
142
|
|
|
143
|
+
/**
|
|
144
|
+
* A video as a consumer sees it: what was authored, plus a generated `url` on
|
|
145
|
+
* the video, on its poster and on each caption track.
|
|
146
|
+
*
|
|
147
|
+
* Only the video's own `url` carries the edit tag — a click on the player
|
|
148
|
+
* reaches the field. The poster and the captions are parts of the same field,
|
|
149
|
+
* not fields of their own, so their URLs are plain.
|
|
150
|
+
*
|
|
151
|
+
* An HLS stream (`mimeType` `application/vnd.apple.mpegurl`) plays natively in
|
|
152
|
+
* Safari and needs a library such as hls.js everywhere else; `url` is then the
|
|
153
|
+
* master playlist.
|
|
154
|
+
*/
|
|
155
|
+
|
|
143
156
|
/**
|
|
144
157
|
* RichText is accessible by users (after conversion via useVal / fetchVal)
|
|
145
158
|
**/
|
|
@@ -286,6 +299,16 @@ function handleRichTextSchema(sourceOrSelector, recOpts, rec) {
|
|
|
286
299
|
}
|
|
287
300
|
function stegaEncode(input, opts) {
|
|
288
301
|
var viewModules = new Map();
|
|
302
|
+
/**
|
|
303
|
+
* The published entries of the galleries the module's fields pick from, for
|
|
304
|
+
* when there is no draft source to fill a gallery-backed value from — every
|
|
305
|
+
* read outside draft mode. See `Internal.media.galleriesOf`.
|
|
306
|
+
*/
|
|
307
|
+
var galleries = new Map();
|
|
308
|
+
var getGallery = function getGallery(modulePath) {
|
|
309
|
+
var _opts$getModule, _opts$getModule2;
|
|
310
|
+
return (_opts$getModule = (_opts$getModule2 = opts.getModule) === null || _opts$getModule2 === void 0 ? void 0 : _opts$getModule2.call(opts, modulePath)) !== null && _opts$getModule !== void 0 ? _opts$getModule : galleries.get(modulePath);
|
|
311
|
+
};
|
|
289
312
|
// Handed a view handle rather than a module: resolve it and encode what it
|
|
290
313
|
// points at. This is what makes `useVal(page.header)` read the header.
|
|
291
314
|
var resolved = core.Internal.viewHandleModule(input);
|
|
@@ -381,12 +404,22 @@ function stegaEncode(input, opts) {
|
|
|
381
404
|
if (recOpts !== null && recOpts !== void 0 && recOpts.schema && isRichTextSchema(recOpts.schema)) {
|
|
382
405
|
return handleRichTextSchema(sourceOrSelector, recOpts, rec);
|
|
383
406
|
}
|
|
407
|
+
if (recOpts && isVideoSchema(recOpts.schema) && sourceOrSelector && slicedToArray._typeof(sourceOrSelector) === "object") {
|
|
408
|
+
// A set-backed video gets its mimeType, size and length from the set
|
|
409
|
+
// first — `Video` promises a `mimeType`, and the field has none — and
|
|
410
|
+
// every choice it did not make itself: the set's poster, times,
|
|
411
|
+
// description, focal point and captions.
|
|
412
|
+
var src = core.Internal.media.fillFromGallery(sourceOrSelector, recOpts.schema, getGallery);
|
|
413
|
+
return core.Internal.resolveVideo(src, function (video) {
|
|
414
|
+
return rec(core.Internal.mediaUrl(video), recOpts);
|
|
415
|
+
});
|
|
416
|
+
}
|
|
384
417
|
if (recOpts && (isImageSchema(recOpts.schema) || isFileSchema(recOpts.schema)) && sourceOrSelector && slicedToArray._typeof(sourceOrSelector) === "object") {
|
|
385
|
-
var
|
|
418
|
+
var _src = core.Internal.media.fillFromGallery(sourceOrSelector, recOpts.schema, getGallery);
|
|
386
419
|
// `url` carries the edit tag, so a click on an image reaches its field.
|
|
387
420
|
// `path` must stay raw: it is what the URL was derived from.
|
|
388
|
-
return _objectSpread2(_objectSpread2({},
|
|
389
|
-
url: rec(core.Internal.mediaUrl(
|
|
421
|
+
return _objectSpread2(_objectSpread2({}, _src), {}, {
|
|
422
|
+
url: rec(core.Internal.mediaUrl(_src), recOpts)
|
|
390
423
|
});
|
|
391
424
|
}
|
|
392
425
|
if (slicedToArray._typeof(sourceOrSelector) === "object") {
|
|
@@ -415,6 +448,20 @@ function stegaEncode(input, opts) {
|
|
|
415
448
|
} finally {
|
|
416
449
|
_iterator.f();
|
|
417
450
|
}
|
|
451
|
+
var _iterator2 = _createForOfIteratorHelper(core.Internal.media.galleriesOf(newSchema)),
|
|
452
|
+
_step2;
|
|
453
|
+
try {
|
|
454
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
455
|
+
var _step2$value = slicedToArray._slicedToArray(_step2.value, 2),
|
|
456
|
+
_path = _step2$value[0],
|
|
457
|
+
entries = _step2$value[1];
|
|
458
|
+
galleries.set(_path, entries);
|
|
459
|
+
}
|
|
460
|
+
} catch (err) {
|
|
461
|
+
_iterator2.e(err);
|
|
462
|
+
} finally {
|
|
463
|
+
_iterator2.f();
|
|
464
|
+
}
|
|
418
465
|
return rec(opts.getModule && opts.getModule(selectorPath) !== undefined ? opts.getModule(selectorPath) : core.Internal.getSource(sourceOrSelector), {
|
|
419
466
|
path: selectorPath,
|
|
420
467
|
schema: newSchema === null || newSchema === void 0 ? void 0 : newSchema["executeSerialize"]()
|
|
@@ -430,11 +477,11 @@ function stegaEncode(input, opts) {
|
|
|
430
477
|
}
|
|
431
478
|
if (!Array.isArray(sourceOrSelector)) {
|
|
432
479
|
var res = {};
|
|
433
|
-
var
|
|
434
|
-
for (var _i = 0,
|
|
435
|
-
var
|
|
436
|
-
_key =
|
|
437
|
-
value =
|
|
480
|
+
var _entries = Object.entries(sourceOrSelector);
|
|
481
|
+
for (var _i = 0, _entries2 = _entries; _i < _entries2.length; _i++) {
|
|
482
|
+
var _entries2$_i = slicedToArray._slicedToArray(_entries2[_i], 2),
|
|
483
|
+
_key = _entries2$_i[0],
|
|
484
|
+
value = _entries2$_i[1];
|
|
438
485
|
res[_key] = rec(value, (recOpts === null || recOpts === void 0 ? void 0 : recOpts.schema) && {
|
|
439
486
|
path: core.Internal.createValPathOfItem(recOpts.path, _key),
|
|
440
487
|
schema: isRecordSchema(recOpts.schema) ? recOpts.schema.item : isObjectSchema(recOpts.schema) ? recOpts.schema.items[_key] : unknownSchema(recOpts.schema)
|
|
@@ -516,11 +563,14 @@ function isObjectSchema(schema) {
|
|
|
516
563
|
function isFileSchema(schema) {
|
|
517
564
|
return (schema === null || schema === void 0 ? void 0 : schema.type) === "file";
|
|
518
565
|
}
|
|
566
|
+
function isVideoSchema(schema) {
|
|
567
|
+
return (schema === null || schema === void 0 ? void 0 : schema.type) === "video";
|
|
568
|
+
}
|
|
519
569
|
function isImageSchema(schema) {
|
|
520
570
|
return (schema === null || schema === void 0 ? void 0 : schema.type) === "image";
|
|
521
571
|
}
|
|
522
572
|
function collectReferencedModulesFromSchema(schema, acc) {
|
|
523
|
-
if (isFileSchema(schema) || isImageSchema(schema)) {
|
|
573
|
+
if (isFileSchema(schema) || isImageSchema(schema) || isVideoSchema(schema)) {
|
|
524
574
|
if (schema.referencedModule) {
|
|
525
575
|
acc.add(schema.referencedModule);
|
|
526
576
|
}
|
|
@@ -532,17 +582,17 @@ function collectReferencedModulesFromSchema(schema, acc) {
|
|
|
532
582
|
} else if (schema.type === "array" || schema.type === "record") {
|
|
533
583
|
collectReferencedModulesFromSchema(schema.item, acc);
|
|
534
584
|
} else if (schema.type === "discriminated-union") {
|
|
535
|
-
var
|
|
536
|
-
|
|
585
|
+
var _iterator3 = _createForOfIteratorHelper(schema.items),
|
|
586
|
+
_step3;
|
|
537
587
|
try {
|
|
538
|
-
for (
|
|
539
|
-
var item =
|
|
588
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
589
|
+
var item = _step3.value;
|
|
540
590
|
collectReferencedModulesFromSchema(item, acc);
|
|
541
591
|
}
|
|
542
592
|
} catch (err) {
|
|
543
|
-
|
|
593
|
+
_iterator3.e(err);
|
|
544
594
|
} finally {
|
|
545
|
-
|
|
595
|
+
_iterator3.f();
|
|
546
596
|
}
|
|
547
597
|
}
|
|
548
598
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { b as _unsupportedIterableToArray, a as _typeof, _ as _slicedToArray } from './slicedToArray-
|
|
1
|
+
import { b as _unsupportedIterableToArray, a as _typeof, _ as _slicedToArray } from './slicedToArray-0c0a3b4a.esm.js';
|
|
2
2
|
import { Internal, isValViewSource } from '@valbuild/core';
|
|
3
3
|
import { vercelStegaDecodeAll, vercelStegaSplit, vercelStegaCombine } from '@vercel/stega';
|
|
4
4
|
|
|
@@ -138,6 +138,19 @@ function _objectSpread2(e) {
|
|
|
138
138
|
* would corrupt every URL built from it.
|
|
139
139
|
*/
|
|
140
140
|
|
|
141
|
+
/**
|
|
142
|
+
* A video as a consumer sees it: what was authored, plus a generated `url` on
|
|
143
|
+
* the video, on its poster and on each caption track.
|
|
144
|
+
*
|
|
145
|
+
* Only the video's own `url` carries the edit tag — a click on the player
|
|
146
|
+
* reaches the field. The poster and the captions are parts of the same field,
|
|
147
|
+
* not fields of their own, so their URLs are plain.
|
|
148
|
+
*
|
|
149
|
+
* An HLS stream (`mimeType` `application/vnd.apple.mpegurl`) plays natively in
|
|
150
|
+
* Safari and needs a library such as hls.js everywhere else; `url` is then the
|
|
151
|
+
* master playlist.
|
|
152
|
+
*/
|
|
153
|
+
|
|
141
154
|
/**
|
|
142
155
|
* RichText is accessible by users (after conversion via useVal / fetchVal)
|
|
143
156
|
**/
|
|
@@ -284,6 +297,16 @@ function handleRichTextSchema(sourceOrSelector, recOpts, rec) {
|
|
|
284
297
|
}
|
|
285
298
|
function stegaEncode(input, opts) {
|
|
286
299
|
var viewModules = new Map();
|
|
300
|
+
/**
|
|
301
|
+
* The published entries of the galleries the module's fields pick from, for
|
|
302
|
+
* when there is no draft source to fill a gallery-backed value from — every
|
|
303
|
+
* read outside draft mode. See `Internal.media.galleriesOf`.
|
|
304
|
+
*/
|
|
305
|
+
var galleries = new Map();
|
|
306
|
+
var getGallery = function getGallery(modulePath) {
|
|
307
|
+
var _opts$getModule, _opts$getModule2;
|
|
308
|
+
return (_opts$getModule = (_opts$getModule2 = opts.getModule) === null || _opts$getModule2 === void 0 ? void 0 : _opts$getModule2.call(opts, modulePath)) !== null && _opts$getModule !== void 0 ? _opts$getModule : galleries.get(modulePath);
|
|
309
|
+
};
|
|
287
310
|
// Handed a view handle rather than a module: resolve it and encode what it
|
|
288
311
|
// points at. This is what makes `useVal(page.header)` read the header.
|
|
289
312
|
var resolved = Internal.viewHandleModule(input);
|
|
@@ -379,12 +402,22 @@ function stegaEncode(input, opts) {
|
|
|
379
402
|
if (recOpts !== null && recOpts !== void 0 && recOpts.schema && isRichTextSchema(recOpts.schema)) {
|
|
380
403
|
return handleRichTextSchema(sourceOrSelector, recOpts, rec);
|
|
381
404
|
}
|
|
405
|
+
if (recOpts && isVideoSchema(recOpts.schema) && sourceOrSelector && _typeof(sourceOrSelector) === "object") {
|
|
406
|
+
// A set-backed video gets its mimeType, size and length from the set
|
|
407
|
+
// first — `Video` promises a `mimeType`, and the field has none — and
|
|
408
|
+
// every choice it did not make itself: the set's poster, times,
|
|
409
|
+
// description, focal point and captions.
|
|
410
|
+
var src = Internal.media.fillFromGallery(sourceOrSelector, recOpts.schema, getGallery);
|
|
411
|
+
return Internal.resolveVideo(src, function (video) {
|
|
412
|
+
return rec(Internal.mediaUrl(video), recOpts);
|
|
413
|
+
});
|
|
414
|
+
}
|
|
382
415
|
if (recOpts && (isImageSchema(recOpts.schema) || isFileSchema(recOpts.schema)) && sourceOrSelector && _typeof(sourceOrSelector) === "object") {
|
|
383
|
-
var
|
|
416
|
+
var _src = Internal.media.fillFromGallery(sourceOrSelector, recOpts.schema, getGallery);
|
|
384
417
|
// `url` carries the edit tag, so a click on an image reaches its field.
|
|
385
418
|
// `path` must stay raw: it is what the URL was derived from.
|
|
386
|
-
return _objectSpread2(_objectSpread2({},
|
|
387
|
-
url: rec(Internal.mediaUrl(
|
|
419
|
+
return _objectSpread2(_objectSpread2({}, _src), {}, {
|
|
420
|
+
url: rec(Internal.mediaUrl(_src), recOpts)
|
|
388
421
|
});
|
|
389
422
|
}
|
|
390
423
|
if (_typeof(sourceOrSelector) === "object") {
|
|
@@ -413,6 +446,20 @@ function stegaEncode(input, opts) {
|
|
|
413
446
|
} finally {
|
|
414
447
|
_iterator.f();
|
|
415
448
|
}
|
|
449
|
+
var _iterator2 = _createForOfIteratorHelper(Internal.media.galleriesOf(newSchema)),
|
|
450
|
+
_step2;
|
|
451
|
+
try {
|
|
452
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
453
|
+
var _step2$value = _slicedToArray(_step2.value, 2),
|
|
454
|
+
_path = _step2$value[0],
|
|
455
|
+
entries = _step2$value[1];
|
|
456
|
+
galleries.set(_path, entries);
|
|
457
|
+
}
|
|
458
|
+
} catch (err) {
|
|
459
|
+
_iterator2.e(err);
|
|
460
|
+
} finally {
|
|
461
|
+
_iterator2.f();
|
|
462
|
+
}
|
|
416
463
|
return rec(opts.getModule && opts.getModule(selectorPath) !== undefined ? opts.getModule(selectorPath) : Internal.getSource(sourceOrSelector), {
|
|
417
464
|
path: selectorPath,
|
|
418
465
|
schema: newSchema === null || newSchema === void 0 ? void 0 : newSchema["executeSerialize"]()
|
|
@@ -428,11 +475,11 @@ function stegaEncode(input, opts) {
|
|
|
428
475
|
}
|
|
429
476
|
if (!Array.isArray(sourceOrSelector)) {
|
|
430
477
|
var res = {};
|
|
431
|
-
var
|
|
432
|
-
for (var _i = 0,
|
|
433
|
-
var
|
|
434
|
-
_key =
|
|
435
|
-
value =
|
|
478
|
+
var _entries = Object.entries(sourceOrSelector);
|
|
479
|
+
for (var _i = 0, _entries2 = _entries; _i < _entries2.length; _i++) {
|
|
480
|
+
var _entries2$_i = _slicedToArray(_entries2[_i], 2),
|
|
481
|
+
_key = _entries2$_i[0],
|
|
482
|
+
value = _entries2$_i[1];
|
|
436
483
|
res[_key] = rec(value, (recOpts === null || recOpts === void 0 ? void 0 : recOpts.schema) && {
|
|
437
484
|
path: Internal.createValPathOfItem(recOpts.path, _key),
|
|
438
485
|
schema: isRecordSchema(recOpts.schema) ? recOpts.schema.item : isObjectSchema(recOpts.schema) ? recOpts.schema.items[_key] : unknownSchema(recOpts.schema)
|
|
@@ -514,11 +561,14 @@ function isObjectSchema(schema) {
|
|
|
514
561
|
function isFileSchema(schema) {
|
|
515
562
|
return (schema === null || schema === void 0 ? void 0 : schema.type) === "file";
|
|
516
563
|
}
|
|
564
|
+
function isVideoSchema(schema) {
|
|
565
|
+
return (schema === null || schema === void 0 ? void 0 : schema.type) === "video";
|
|
566
|
+
}
|
|
517
567
|
function isImageSchema(schema) {
|
|
518
568
|
return (schema === null || schema === void 0 ? void 0 : schema.type) === "image";
|
|
519
569
|
}
|
|
520
570
|
function collectReferencedModulesFromSchema(schema, acc) {
|
|
521
|
-
if (isFileSchema(schema) || isImageSchema(schema)) {
|
|
571
|
+
if (isFileSchema(schema) || isImageSchema(schema) || isVideoSchema(schema)) {
|
|
522
572
|
if (schema.referencedModule) {
|
|
523
573
|
acc.add(schema.referencedModule);
|
|
524
574
|
}
|
|
@@ -530,17 +580,17 @@ function collectReferencedModulesFromSchema(schema, acc) {
|
|
|
530
580
|
} else if (schema.type === "array" || schema.type === "record") {
|
|
531
581
|
collectReferencedModulesFromSchema(schema.item, acc);
|
|
532
582
|
} else if (schema.type === "discriminated-union") {
|
|
533
|
-
var
|
|
534
|
-
|
|
583
|
+
var _iterator3 = _createForOfIteratorHelper(schema.items),
|
|
584
|
+
_step3;
|
|
535
585
|
try {
|
|
536
|
-
for (
|
|
537
|
-
var item =
|
|
586
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
587
|
+
var item = _step3.value;
|
|
538
588
|
collectReferencedModulesFromSchema(item, acc);
|
|
539
589
|
}
|
|
540
590
|
} catch (err) {
|
|
541
|
-
|
|
591
|
+
_iterator3.e(err);
|
|
542
592
|
} finally {
|
|
543
|
-
|
|
593
|
+
_iterator3.f();
|
|
544
594
|
}
|
|
545
595
|
}
|
|
546
596
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { b as _unsupportedIterableToArray, a as _typeof, _ as _slicedToArray } from './slicedToArray-
|
|
1
|
+
import { b as _unsupportedIterableToArray, a as _typeof, _ as _slicedToArray } from './slicedToArray-7d0170b6.worker.esm.js';
|
|
2
2
|
import { Internal, isValViewSource } from '@valbuild/core';
|
|
3
3
|
import { vercelStegaDecodeAll, vercelStegaSplit, vercelStegaCombine } from '@vercel/stega';
|
|
4
4
|
|
|
@@ -138,6 +138,19 @@ function _objectSpread2(e) {
|
|
|
138
138
|
* would corrupt every URL built from it.
|
|
139
139
|
*/
|
|
140
140
|
|
|
141
|
+
/**
|
|
142
|
+
* A video as a consumer sees it: what was authored, plus a generated `url` on
|
|
143
|
+
* the video, on its poster and on each caption track.
|
|
144
|
+
*
|
|
145
|
+
* Only the video's own `url` carries the edit tag — a click on the player
|
|
146
|
+
* reaches the field. The poster and the captions are parts of the same field,
|
|
147
|
+
* not fields of their own, so their URLs are plain.
|
|
148
|
+
*
|
|
149
|
+
* An HLS stream (`mimeType` `application/vnd.apple.mpegurl`) plays natively in
|
|
150
|
+
* Safari and needs a library such as hls.js everywhere else; `url` is then the
|
|
151
|
+
* master playlist.
|
|
152
|
+
*/
|
|
153
|
+
|
|
141
154
|
/**
|
|
142
155
|
* RichText is accessible by users (after conversion via useVal / fetchVal)
|
|
143
156
|
**/
|
|
@@ -284,6 +297,16 @@ function handleRichTextSchema(sourceOrSelector, recOpts, rec) {
|
|
|
284
297
|
}
|
|
285
298
|
function stegaEncode(input, opts) {
|
|
286
299
|
var viewModules = new Map();
|
|
300
|
+
/**
|
|
301
|
+
* The published entries of the galleries the module's fields pick from, for
|
|
302
|
+
* when there is no draft source to fill a gallery-backed value from — every
|
|
303
|
+
* read outside draft mode. See `Internal.media.galleriesOf`.
|
|
304
|
+
*/
|
|
305
|
+
var galleries = new Map();
|
|
306
|
+
var getGallery = function getGallery(modulePath) {
|
|
307
|
+
var _opts$getModule, _opts$getModule2;
|
|
308
|
+
return (_opts$getModule = (_opts$getModule2 = opts.getModule) === null || _opts$getModule2 === void 0 ? void 0 : _opts$getModule2.call(opts, modulePath)) !== null && _opts$getModule !== void 0 ? _opts$getModule : galleries.get(modulePath);
|
|
309
|
+
};
|
|
287
310
|
// Handed a view handle rather than a module: resolve it and encode what it
|
|
288
311
|
// points at. This is what makes `useVal(page.header)` read the header.
|
|
289
312
|
var resolved = Internal.viewHandleModule(input);
|
|
@@ -379,12 +402,22 @@ function stegaEncode(input, opts) {
|
|
|
379
402
|
if (recOpts !== null && recOpts !== void 0 && recOpts.schema && isRichTextSchema(recOpts.schema)) {
|
|
380
403
|
return handleRichTextSchema(sourceOrSelector, recOpts, rec);
|
|
381
404
|
}
|
|
405
|
+
if (recOpts && isVideoSchema(recOpts.schema) && sourceOrSelector && _typeof(sourceOrSelector) === "object") {
|
|
406
|
+
// A set-backed video gets its mimeType, size and length from the set
|
|
407
|
+
// first — `Video` promises a `mimeType`, and the field has none — and
|
|
408
|
+
// every choice it did not make itself: the set's poster, times,
|
|
409
|
+
// description, focal point and captions.
|
|
410
|
+
var src = Internal.media.fillFromGallery(sourceOrSelector, recOpts.schema, getGallery);
|
|
411
|
+
return Internal.resolveVideo(src, function (video) {
|
|
412
|
+
return rec(Internal.mediaUrl(video), recOpts);
|
|
413
|
+
});
|
|
414
|
+
}
|
|
382
415
|
if (recOpts && (isImageSchema(recOpts.schema) || isFileSchema(recOpts.schema)) && sourceOrSelector && _typeof(sourceOrSelector) === "object") {
|
|
383
|
-
var
|
|
416
|
+
var _src = Internal.media.fillFromGallery(sourceOrSelector, recOpts.schema, getGallery);
|
|
384
417
|
// `url` carries the edit tag, so a click on an image reaches its field.
|
|
385
418
|
// `path` must stay raw: it is what the URL was derived from.
|
|
386
|
-
return _objectSpread2(_objectSpread2({},
|
|
387
|
-
url: rec(Internal.mediaUrl(
|
|
419
|
+
return _objectSpread2(_objectSpread2({}, _src), {}, {
|
|
420
|
+
url: rec(Internal.mediaUrl(_src), recOpts)
|
|
388
421
|
});
|
|
389
422
|
}
|
|
390
423
|
if (_typeof(sourceOrSelector) === "object") {
|
|
@@ -413,6 +446,20 @@ function stegaEncode(input, opts) {
|
|
|
413
446
|
} finally {
|
|
414
447
|
_iterator.f();
|
|
415
448
|
}
|
|
449
|
+
var _iterator2 = _createForOfIteratorHelper(Internal.media.galleriesOf(newSchema)),
|
|
450
|
+
_step2;
|
|
451
|
+
try {
|
|
452
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
453
|
+
var _step2$value = _slicedToArray(_step2.value, 2),
|
|
454
|
+
_path = _step2$value[0],
|
|
455
|
+
entries = _step2$value[1];
|
|
456
|
+
galleries.set(_path, entries);
|
|
457
|
+
}
|
|
458
|
+
} catch (err) {
|
|
459
|
+
_iterator2.e(err);
|
|
460
|
+
} finally {
|
|
461
|
+
_iterator2.f();
|
|
462
|
+
}
|
|
416
463
|
return rec(opts.getModule && opts.getModule(selectorPath) !== undefined ? opts.getModule(selectorPath) : Internal.getSource(sourceOrSelector), {
|
|
417
464
|
path: selectorPath,
|
|
418
465
|
schema: newSchema === null || newSchema === void 0 ? void 0 : newSchema["executeSerialize"]()
|
|
@@ -428,11 +475,11 @@ function stegaEncode(input, opts) {
|
|
|
428
475
|
}
|
|
429
476
|
if (!Array.isArray(sourceOrSelector)) {
|
|
430
477
|
var res = {};
|
|
431
|
-
var
|
|
432
|
-
for (var _i = 0,
|
|
433
|
-
var
|
|
434
|
-
_key =
|
|
435
|
-
value =
|
|
478
|
+
var _entries = Object.entries(sourceOrSelector);
|
|
479
|
+
for (var _i = 0, _entries2 = _entries; _i < _entries2.length; _i++) {
|
|
480
|
+
var _entries2$_i = _slicedToArray(_entries2[_i], 2),
|
|
481
|
+
_key = _entries2$_i[0],
|
|
482
|
+
value = _entries2$_i[1];
|
|
436
483
|
res[_key] = rec(value, (recOpts === null || recOpts === void 0 ? void 0 : recOpts.schema) && {
|
|
437
484
|
path: Internal.createValPathOfItem(recOpts.path, _key),
|
|
438
485
|
schema: isRecordSchema(recOpts.schema) ? recOpts.schema.item : isObjectSchema(recOpts.schema) ? recOpts.schema.items[_key] : unknownSchema(recOpts.schema)
|
|
@@ -514,11 +561,14 @@ function isObjectSchema(schema) {
|
|
|
514
561
|
function isFileSchema(schema) {
|
|
515
562
|
return (schema === null || schema === void 0 ? void 0 : schema.type) === "file";
|
|
516
563
|
}
|
|
564
|
+
function isVideoSchema(schema) {
|
|
565
|
+
return (schema === null || schema === void 0 ? void 0 : schema.type) === "video";
|
|
566
|
+
}
|
|
517
567
|
function isImageSchema(schema) {
|
|
518
568
|
return (schema === null || schema === void 0 ? void 0 : schema.type) === "image";
|
|
519
569
|
}
|
|
520
570
|
function collectReferencedModulesFromSchema(schema, acc) {
|
|
521
|
-
if (isFileSchema(schema) || isImageSchema(schema)) {
|
|
571
|
+
if (isFileSchema(schema) || isImageSchema(schema) || isVideoSchema(schema)) {
|
|
522
572
|
if (schema.referencedModule) {
|
|
523
573
|
acc.add(schema.referencedModule);
|
|
524
574
|
}
|
|
@@ -530,17 +580,17 @@ function collectReferencedModulesFromSchema(schema, acc) {
|
|
|
530
580
|
} else if (schema.type === "array" || schema.type === "record") {
|
|
531
581
|
collectReferencedModulesFromSchema(schema.item, acc);
|
|
532
582
|
} else if (schema.type === "discriminated-union") {
|
|
533
|
-
var
|
|
534
|
-
|
|
583
|
+
var _iterator3 = _createForOfIteratorHelper(schema.items),
|
|
584
|
+
_step3;
|
|
535
585
|
try {
|
|
536
|
-
for (
|
|
537
|
-
var item =
|
|
586
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
587
|
+
var item = _step3.value;
|
|
538
588
|
collectReferencedModulesFromSchema(item, acc);
|
|
539
589
|
}
|
|
540
590
|
} catch (err) {
|
|
541
|
-
|
|
591
|
+
_iterator3.e(err);
|
|
542
592
|
} finally {
|
|
543
|
-
|
|
593
|
+
_iterator3.f();
|
|
544
594
|
}
|
|
545
595
|
}
|
|
546
596
|
}
|
|
@@ -140,6 +140,19 @@ function _objectSpread2(e) {
|
|
|
140
140
|
* would corrupt every URL built from it.
|
|
141
141
|
*/
|
|
142
142
|
|
|
143
|
+
/**
|
|
144
|
+
* A video as a consumer sees it: what was authored, plus a generated `url` on
|
|
145
|
+
* the video, on its poster and on each caption track.
|
|
146
|
+
*
|
|
147
|
+
* Only the video's own `url` carries the edit tag — a click on the player
|
|
148
|
+
* reaches the field. The poster and the captions are parts of the same field,
|
|
149
|
+
* not fields of their own, so their URLs are plain.
|
|
150
|
+
*
|
|
151
|
+
* An HLS stream (`mimeType` `application/vnd.apple.mpegurl`) plays natively in
|
|
152
|
+
* Safari and needs a library such as hls.js everywhere else; `url` is then the
|
|
153
|
+
* master playlist.
|
|
154
|
+
*/
|
|
155
|
+
|
|
143
156
|
/**
|
|
144
157
|
* RichText is accessible by users (after conversion via useVal / fetchVal)
|
|
145
158
|
**/
|
|
@@ -286,6 +299,16 @@ function handleRichTextSchema(sourceOrSelector, recOpts, rec) {
|
|
|
286
299
|
}
|
|
287
300
|
function stegaEncode(input, opts) {
|
|
288
301
|
var viewModules = new Map();
|
|
302
|
+
/**
|
|
303
|
+
* The published entries of the galleries the module's fields pick from, for
|
|
304
|
+
* when there is no draft source to fill a gallery-backed value from — every
|
|
305
|
+
* read outside draft mode. See `Internal.media.galleriesOf`.
|
|
306
|
+
*/
|
|
307
|
+
var galleries = new Map();
|
|
308
|
+
var getGallery = function getGallery(modulePath) {
|
|
309
|
+
var _opts$getModule, _opts$getModule2;
|
|
310
|
+
return (_opts$getModule = (_opts$getModule2 = opts.getModule) === null || _opts$getModule2 === void 0 ? void 0 : _opts$getModule2.call(opts, modulePath)) !== null && _opts$getModule !== void 0 ? _opts$getModule : galleries.get(modulePath);
|
|
311
|
+
};
|
|
289
312
|
// Handed a view handle rather than a module: resolve it and encode what it
|
|
290
313
|
// points at. This is what makes `useVal(page.header)` read the header.
|
|
291
314
|
var resolved = core.Internal.viewHandleModule(input);
|
|
@@ -381,12 +404,22 @@ function stegaEncode(input, opts) {
|
|
|
381
404
|
if (recOpts !== null && recOpts !== void 0 && recOpts.schema && isRichTextSchema(recOpts.schema)) {
|
|
382
405
|
return handleRichTextSchema(sourceOrSelector, recOpts, rec);
|
|
383
406
|
}
|
|
407
|
+
if (recOpts && isVideoSchema(recOpts.schema) && sourceOrSelector && slicedToArray._typeof(sourceOrSelector) === "object") {
|
|
408
|
+
// A set-backed video gets its mimeType, size and length from the set
|
|
409
|
+
// first — `Video` promises a `mimeType`, and the field has none — and
|
|
410
|
+
// every choice it did not make itself: the set's poster, times,
|
|
411
|
+
// description, focal point and captions.
|
|
412
|
+
var src = core.Internal.media.fillFromGallery(sourceOrSelector, recOpts.schema, getGallery);
|
|
413
|
+
return core.Internal.resolveVideo(src, function (video) {
|
|
414
|
+
return rec(core.Internal.mediaUrl(video), recOpts);
|
|
415
|
+
});
|
|
416
|
+
}
|
|
384
417
|
if (recOpts && (isImageSchema(recOpts.schema) || isFileSchema(recOpts.schema)) && sourceOrSelector && slicedToArray._typeof(sourceOrSelector) === "object") {
|
|
385
|
-
var
|
|
418
|
+
var _src = core.Internal.media.fillFromGallery(sourceOrSelector, recOpts.schema, getGallery);
|
|
386
419
|
// `url` carries the edit tag, so a click on an image reaches its field.
|
|
387
420
|
// `path` must stay raw: it is what the URL was derived from.
|
|
388
|
-
return _objectSpread2(_objectSpread2({},
|
|
389
|
-
url: rec(core.Internal.mediaUrl(
|
|
421
|
+
return _objectSpread2(_objectSpread2({}, _src), {}, {
|
|
422
|
+
url: rec(core.Internal.mediaUrl(_src), recOpts)
|
|
390
423
|
});
|
|
391
424
|
}
|
|
392
425
|
if (slicedToArray._typeof(sourceOrSelector) === "object") {
|
|
@@ -415,6 +448,20 @@ function stegaEncode(input, opts) {
|
|
|
415
448
|
} finally {
|
|
416
449
|
_iterator.f();
|
|
417
450
|
}
|
|
451
|
+
var _iterator2 = _createForOfIteratorHelper(core.Internal.media.galleriesOf(newSchema)),
|
|
452
|
+
_step2;
|
|
453
|
+
try {
|
|
454
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
455
|
+
var _step2$value = slicedToArray._slicedToArray(_step2.value, 2),
|
|
456
|
+
_path = _step2$value[0],
|
|
457
|
+
entries = _step2$value[1];
|
|
458
|
+
galleries.set(_path, entries);
|
|
459
|
+
}
|
|
460
|
+
} catch (err) {
|
|
461
|
+
_iterator2.e(err);
|
|
462
|
+
} finally {
|
|
463
|
+
_iterator2.f();
|
|
464
|
+
}
|
|
418
465
|
return rec(opts.getModule && opts.getModule(selectorPath) !== undefined ? opts.getModule(selectorPath) : core.Internal.getSource(sourceOrSelector), {
|
|
419
466
|
path: selectorPath,
|
|
420
467
|
schema: newSchema === null || newSchema === void 0 ? void 0 : newSchema["executeSerialize"]()
|
|
@@ -430,11 +477,11 @@ function stegaEncode(input, opts) {
|
|
|
430
477
|
}
|
|
431
478
|
if (!Array.isArray(sourceOrSelector)) {
|
|
432
479
|
var res = {};
|
|
433
|
-
var
|
|
434
|
-
for (var _i = 0,
|
|
435
|
-
var
|
|
436
|
-
_key =
|
|
437
|
-
value =
|
|
480
|
+
var _entries = Object.entries(sourceOrSelector);
|
|
481
|
+
for (var _i = 0, _entries2 = _entries; _i < _entries2.length; _i++) {
|
|
482
|
+
var _entries2$_i = slicedToArray._slicedToArray(_entries2[_i], 2),
|
|
483
|
+
_key = _entries2$_i[0],
|
|
484
|
+
value = _entries2$_i[1];
|
|
438
485
|
res[_key] = rec(value, (recOpts === null || recOpts === void 0 ? void 0 : recOpts.schema) && {
|
|
439
486
|
path: core.Internal.createValPathOfItem(recOpts.path, _key),
|
|
440
487
|
schema: isRecordSchema(recOpts.schema) ? recOpts.schema.item : isObjectSchema(recOpts.schema) ? recOpts.schema.items[_key] : unknownSchema(recOpts.schema)
|
|
@@ -516,11 +563,14 @@ function isObjectSchema(schema) {
|
|
|
516
563
|
function isFileSchema(schema) {
|
|
517
564
|
return (schema === null || schema === void 0 ? void 0 : schema.type) === "file";
|
|
518
565
|
}
|
|
566
|
+
function isVideoSchema(schema) {
|
|
567
|
+
return (schema === null || schema === void 0 ? void 0 : schema.type) === "video";
|
|
568
|
+
}
|
|
519
569
|
function isImageSchema(schema) {
|
|
520
570
|
return (schema === null || schema === void 0 ? void 0 : schema.type) === "image";
|
|
521
571
|
}
|
|
522
572
|
function collectReferencedModulesFromSchema(schema, acc) {
|
|
523
|
-
if (isFileSchema(schema) || isImageSchema(schema)) {
|
|
573
|
+
if (isFileSchema(schema) || isImageSchema(schema) || isVideoSchema(schema)) {
|
|
524
574
|
if (schema.referencedModule) {
|
|
525
575
|
acc.add(schema.referencedModule);
|
|
526
576
|
}
|
|
@@ -532,17 +582,17 @@ function collectReferencedModulesFromSchema(schema, acc) {
|
|
|
532
582
|
} else if (schema.type === "array" || schema.type === "record") {
|
|
533
583
|
collectReferencedModulesFromSchema(schema.item, acc);
|
|
534
584
|
} else if (schema.type === "discriminated-union") {
|
|
535
|
-
var
|
|
536
|
-
|
|
585
|
+
var _iterator3 = _createForOfIteratorHelper(schema.items),
|
|
586
|
+
_step3;
|
|
537
587
|
try {
|
|
538
|
-
for (
|
|
539
|
-
var item =
|
|
588
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
589
|
+
var item = _step3.value;
|
|
540
590
|
collectReferencedModulesFromSchema(item, acc);
|
|
541
591
|
}
|
|
542
592
|
} catch (err) {
|
|
543
|
-
|
|
593
|
+
_iterator3.e(err);
|
|
544
594
|
} finally {
|
|
545
|
-
|
|
595
|
+
_iterator3.f();
|
|
546
596
|
}
|
|
547
597
|
}
|
|
548
598
|
}
|
|
@@ -138,6 +138,19 @@ function _objectSpread2(e) {
|
|
|
138
138
|
* would corrupt every URL built from it.
|
|
139
139
|
*/
|
|
140
140
|
|
|
141
|
+
/**
|
|
142
|
+
* A video as a consumer sees it: what was authored, plus a generated `url` on
|
|
143
|
+
* the video, on its poster and on each caption track.
|
|
144
|
+
*
|
|
145
|
+
* Only the video's own `url` carries the edit tag — a click on the player
|
|
146
|
+
* reaches the field. The poster and the captions are parts of the same field,
|
|
147
|
+
* not fields of their own, so their URLs are plain.
|
|
148
|
+
*
|
|
149
|
+
* An HLS stream (`mimeType` `application/vnd.apple.mpegurl`) plays natively in
|
|
150
|
+
* Safari and needs a library such as hls.js everywhere else; `url` is then the
|
|
151
|
+
* master playlist.
|
|
152
|
+
*/
|
|
153
|
+
|
|
141
154
|
/**
|
|
142
155
|
* RichText is accessible by users (after conversion via useVal / fetchVal)
|
|
143
156
|
**/
|
|
@@ -284,6 +297,16 @@ function handleRichTextSchema(sourceOrSelector, recOpts, rec) {
|
|
|
284
297
|
}
|
|
285
298
|
function stegaEncode(input, opts) {
|
|
286
299
|
var viewModules = new Map();
|
|
300
|
+
/**
|
|
301
|
+
* The published entries of the galleries the module's fields pick from, for
|
|
302
|
+
* when there is no draft source to fill a gallery-backed value from — every
|
|
303
|
+
* read outside draft mode. See `Internal.media.galleriesOf`.
|
|
304
|
+
*/
|
|
305
|
+
var galleries = new Map();
|
|
306
|
+
var getGallery = function getGallery(modulePath) {
|
|
307
|
+
var _opts$getModule, _opts$getModule2;
|
|
308
|
+
return (_opts$getModule = (_opts$getModule2 = opts.getModule) === null || _opts$getModule2 === void 0 ? void 0 : _opts$getModule2.call(opts, modulePath)) !== null && _opts$getModule !== void 0 ? _opts$getModule : galleries.get(modulePath);
|
|
309
|
+
};
|
|
287
310
|
// Handed a view handle rather than a module: resolve it and encode what it
|
|
288
311
|
// points at. This is what makes `useVal(page.header)` read the header.
|
|
289
312
|
var resolved = Internal.viewHandleModule(input);
|
|
@@ -379,12 +402,22 @@ function stegaEncode(input, opts) {
|
|
|
379
402
|
if (recOpts !== null && recOpts !== void 0 && recOpts.schema && isRichTextSchema(recOpts.schema)) {
|
|
380
403
|
return handleRichTextSchema(sourceOrSelector, recOpts, rec);
|
|
381
404
|
}
|
|
405
|
+
if (recOpts && isVideoSchema(recOpts.schema) && sourceOrSelector && _typeof(sourceOrSelector) === "object") {
|
|
406
|
+
// A set-backed video gets its mimeType, size and length from the set
|
|
407
|
+
// first — `Video` promises a `mimeType`, and the field has none — and
|
|
408
|
+
// every choice it did not make itself: the set's poster, times,
|
|
409
|
+
// description, focal point and captions.
|
|
410
|
+
var src = Internal.media.fillFromGallery(sourceOrSelector, recOpts.schema, getGallery);
|
|
411
|
+
return Internal.resolveVideo(src, function (video) {
|
|
412
|
+
return rec(Internal.mediaUrl(video), recOpts);
|
|
413
|
+
});
|
|
414
|
+
}
|
|
382
415
|
if (recOpts && (isImageSchema(recOpts.schema) || isFileSchema(recOpts.schema)) && sourceOrSelector && _typeof(sourceOrSelector) === "object") {
|
|
383
|
-
var
|
|
416
|
+
var _src = Internal.media.fillFromGallery(sourceOrSelector, recOpts.schema, getGallery);
|
|
384
417
|
// `url` carries the edit tag, so a click on an image reaches its field.
|
|
385
418
|
// `path` must stay raw: it is what the URL was derived from.
|
|
386
|
-
return _objectSpread2(_objectSpread2({},
|
|
387
|
-
url: rec(Internal.mediaUrl(
|
|
419
|
+
return _objectSpread2(_objectSpread2({}, _src), {}, {
|
|
420
|
+
url: rec(Internal.mediaUrl(_src), recOpts)
|
|
388
421
|
});
|
|
389
422
|
}
|
|
390
423
|
if (_typeof(sourceOrSelector) === "object") {
|
|
@@ -413,6 +446,20 @@ function stegaEncode(input, opts) {
|
|
|
413
446
|
} finally {
|
|
414
447
|
_iterator.f();
|
|
415
448
|
}
|
|
449
|
+
var _iterator2 = _createForOfIteratorHelper(Internal.media.galleriesOf(newSchema)),
|
|
450
|
+
_step2;
|
|
451
|
+
try {
|
|
452
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
453
|
+
var _step2$value = _slicedToArray(_step2.value, 2),
|
|
454
|
+
_path = _step2$value[0],
|
|
455
|
+
entries = _step2$value[1];
|
|
456
|
+
galleries.set(_path, entries);
|
|
457
|
+
}
|
|
458
|
+
} catch (err) {
|
|
459
|
+
_iterator2.e(err);
|
|
460
|
+
} finally {
|
|
461
|
+
_iterator2.f();
|
|
462
|
+
}
|
|
416
463
|
return rec(opts.getModule && opts.getModule(selectorPath) !== undefined ? opts.getModule(selectorPath) : Internal.getSource(sourceOrSelector), {
|
|
417
464
|
path: selectorPath,
|
|
418
465
|
schema: newSchema === null || newSchema === void 0 ? void 0 : newSchema["executeSerialize"]()
|
|
@@ -428,11 +475,11 @@ function stegaEncode(input, opts) {
|
|
|
428
475
|
}
|
|
429
476
|
if (!Array.isArray(sourceOrSelector)) {
|
|
430
477
|
var res = {};
|
|
431
|
-
var
|
|
432
|
-
for (var _i = 0,
|
|
433
|
-
var
|
|
434
|
-
_key =
|
|
435
|
-
value =
|
|
478
|
+
var _entries = Object.entries(sourceOrSelector);
|
|
479
|
+
for (var _i = 0, _entries2 = _entries; _i < _entries2.length; _i++) {
|
|
480
|
+
var _entries2$_i = _slicedToArray(_entries2[_i], 2),
|
|
481
|
+
_key = _entries2$_i[0],
|
|
482
|
+
value = _entries2$_i[1];
|
|
436
483
|
res[_key] = rec(value, (recOpts === null || recOpts === void 0 ? void 0 : recOpts.schema) && {
|
|
437
484
|
path: Internal.createValPathOfItem(recOpts.path, _key),
|
|
438
485
|
schema: isRecordSchema(recOpts.schema) ? recOpts.schema.item : isObjectSchema(recOpts.schema) ? recOpts.schema.items[_key] : unknownSchema(recOpts.schema)
|
|
@@ -514,11 +561,14 @@ function isObjectSchema(schema) {
|
|
|
514
561
|
function isFileSchema(schema) {
|
|
515
562
|
return (schema === null || schema === void 0 ? void 0 : schema.type) === "file";
|
|
516
563
|
}
|
|
564
|
+
function isVideoSchema(schema) {
|
|
565
|
+
return (schema === null || schema === void 0 ? void 0 : schema.type) === "video";
|
|
566
|
+
}
|
|
517
567
|
function isImageSchema(schema) {
|
|
518
568
|
return (schema === null || schema === void 0 ? void 0 : schema.type) === "image";
|
|
519
569
|
}
|
|
520
570
|
function collectReferencedModulesFromSchema(schema, acc) {
|
|
521
|
-
if (isFileSchema(schema) || isImageSchema(schema)) {
|
|
571
|
+
if (isFileSchema(schema) || isImageSchema(schema) || isVideoSchema(schema)) {
|
|
522
572
|
if (schema.referencedModule) {
|
|
523
573
|
acc.add(schema.referencedModule);
|
|
524
574
|
}
|
|
@@ -530,17 +580,17 @@ function collectReferencedModulesFromSchema(schema, acc) {
|
|
|
530
580
|
} else if (schema.type === "array" || schema.type === "record") {
|
|
531
581
|
collectReferencedModulesFromSchema(schema.item, acc);
|
|
532
582
|
} else if (schema.type === "discriminated-union") {
|
|
533
|
-
var
|
|
534
|
-
|
|
583
|
+
var _iterator3 = _createForOfIteratorHelper(schema.items),
|
|
584
|
+
_step3;
|
|
535
585
|
try {
|
|
536
|
-
for (
|
|
537
|
-
var item =
|
|
586
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
587
|
+
var item = _step3.value;
|
|
538
588
|
collectReferencedModulesFromSchema(item, acc);
|
|
539
589
|
}
|
|
540
590
|
} catch (err) {
|
|
541
|
-
|
|
591
|
+
_iterator3.e(err);
|
|
542
592
|
} finally {
|
|
543
|
-
|
|
593
|
+
_iterator3.f();
|
|
544
594
|
}
|
|
545
595
|
}
|
|
546
596
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { c as _arrayLikeToArray, b as _unsupportedIterableToArray } from '../../dist/slicedToArray-9cce0d9f.browser.esm.js';
|
|
2
|
-
import { d as _objectSpread2, r as raw, c as attrs } from '../../dist/raw-
|
|
2
|
+
import { d as _objectSpread2, r as raw, c as attrs } from '../../dist/raw-be2fd916.browser.esm.js';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { jsx } from 'react/jsx-runtime';
|
|
5
5
|
import '@valbuild/core';
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var slicedToArray = require('../../dist/slicedToArray-e9e8e991.cjs.dev.js');
|
|
6
|
-
var raw = require('../../dist/raw-
|
|
6
|
+
var raw = require('../../dist/raw-1fce8756.cjs.dev.js');
|
|
7
7
|
var React = require('react');
|
|
8
8
|
var ReactJSXRuntime = require('react/jsx-runtime');
|
|
9
9
|
require('@valbuild/core');
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var slicedToArray = require('../../dist/slicedToArray-86004d59.cjs.prod.js');
|
|
6
|
-
var raw = require('../../dist/raw-
|
|
6
|
+
var raw = require('../../dist/raw-68a490e6.cjs.prod.js');
|
|
7
7
|
var React = require('react');
|
|
8
8
|
var ReactJSXRuntime = require('react/jsx-runtime');
|
|
9
9
|
require('@valbuild/core');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { c as _arrayLikeToArray, b as _unsupportedIterableToArray } from '../../dist/slicedToArray-0c0a3b4a.esm.js';
|
|
2
|
-
import { d as _objectSpread2, r as raw, c as attrs } from '../../dist/raw-
|
|
2
|
+
import { d as _objectSpread2, r as raw, c as attrs } from '../../dist/raw-26e85a34.esm.js';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { jsx } from 'react/jsx-runtime';
|
|
5
5
|
import '@valbuild/core';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { c as _arrayLikeToArray, b as _unsupportedIterableToArray } from '../../dist/slicedToArray-7d0170b6.worker.esm.js';
|
|
2
|
-
import { d as _objectSpread2, r as raw, c as attrs } from '../../dist/raw-
|
|
2
|
+
import { d as _objectSpread2, r as raw, c as attrs } from '../../dist/raw-55a21edc.worker.esm.js';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { jsx } from 'react/jsx-runtime';
|
|
5
5
|
import '@valbuild/core';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@valbuild/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.141.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Val - React internal helpers",
|
|
6
6
|
"repository": {
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@vercel/stega": "^1.1.0",
|
|
13
13
|
"base64-arraybuffer": "^1.0.2",
|
|
14
|
-
"@valbuild/
|
|
15
|
-
"@valbuild/
|
|
16
|
-
"@valbuild/ui": "0.
|
|
14
|
+
"@valbuild/shared": "0.141.0",
|
|
15
|
+
"@valbuild/core": "0.141.0",
|
|
16
|
+
"@valbuild/ui": "0.141.0"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@testing-library/react": "^16.3.3",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as _typeof, _ as _slicedToArray } from '../../dist/slicedToArray-9cce0d9f.browser.esm.js';
|
|
2
|
-
import { s as stegaDecodeStrings, _ as _createForOfIteratorHelper } from '../../dist/raw-
|
|
3
|
-
export { c as attrs, g as getModuleIds, r as raw, b as stegaClean, s as stegaDecodeStrings, a as stegaEncode } from '../../dist/raw-
|
|
2
|
+
import { s as stegaDecodeStrings, _ as _createForOfIteratorHelper } from '../../dist/raw-be2fd916.browser.esm.js';
|
|
3
|
+
export { c as attrs, g as getModuleIds, r as raw, b as stegaClean, s as stegaDecodeStrings, a as stegaEncode } from '../../dist/raw-be2fd916.browser.esm.js';
|
|
4
4
|
import ReactJSXRuntime__default from 'react/jsx-runtime';
|
|
5
5
|
import jsxRuntimeDev__default from 'react/jsx-dev-runtime';
|
|
6
6
|
import React from 'react';
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var slicedToArray = require('../../dist/slicedToArray-e9e8e991.cjs.dev.js');
|
|
6
|
-
var raw = require('../../dist/raw-
|
|
6
|
+
var raw = require('../../dist/raw-1fce8756.cjs.dev.js');
|
|
7
7
|
var ReactJSXRuntime = require('react/jsx-runtime');
|
|
8
8
|
var jsxRuntimeDev = require('react/jsx-dev-runtime');
|
|
9
9
|
var React = require('react');
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var slicedToArray = require('../../dist/slicedToArray-86004d59.cjs.prod.js');
|
|
6
|
-
var raw = require('../../dist/raw-
|
|
6
|
+
var raw = require('../../dist/raw-68a490e6.cjs.prod.js');
|
|
7
7
|
var ReactJSXRuntime = require('react/jsx-runtime');
|
|
8
8
|
var jsxRuntimeDev = require('react/jsx-dev-runtime');
|
|
9
9
|
var React = require('react');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as _typeof, _ as _slicedToArray } from '../../dist/slicedToArray-0c0a3b4a.esm.js';
|
|
2
|
-
import { s as stegaDecodeStrings, _ as _createForOfIteratorHelper } from '../../dist/raw-
|
|
3
|
-
export { c as attrs, g as getModuleIds, r as raw, b as stegaClean, s as stegaDecodeStrings, a as stegaEncode } from '../../dist/raw-
|
|
2
|
+
import { s as stegaDecodeStrings, _ as _createForOfIteratorHelper } from '../../dist/raw-26e85a34.esm.js';
|
|
3
|
+
export { c as attrs, g as getModuleIds, r as raw, b as stegaClean, s as stegaDecodeStrings, a as stegaEncode } from '../../dist/raw-26e85a34.esm.js';
|
|
4
4
|
import ReactJSXRuntime__default from 'react/jsx-runtime';
|
|
5
5
|
import jsxRuntimeDev__default from 'react/jsx-dev-runtime';
|
|
6
6
|
import React from 'react';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as _typeof, _ as _slicedToArray } from '../../dist/slicedToArray-7d0170b6.worker.esm.js';
|
|
2
|
-
import { s as stegaDecodeStrings, _ as _createForOfIteratorHelper } from '../../dist/raw-
|
|
3
|
-
export { c as attrs, g as getModuleIds, r as raw, b as stegaClean, s as stegaDecodeStrings, a as stegaEncode } from '../../dist/raw-
|
|
2
|
+
import { s as stegaDecodeStrings, _ as _createForOfIteratorHelper } from '../../dist/raw-55a21edc.worker.esm.js';
|
|
3
|
+
export { c as attrs, g as getModuleIds, r as raw, b as stegaClean, s as stegaDecodeStrings, a as stegaEncode } from '../../dist/raw-55a21edc.worker.esm.js';
|
|
4
4
|
import ReactJSXRuntime__default from 'react/jsx-runtime';
|
|
5
5
|
import jsxRuntimeDev__default from 'react/jsx-dev-runtime';
|
|
6
6
|
import React from 'react';
|