@valbuild/react 0.154.1 → 0.154.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/analytics/dist/valbuild-react-analytics.browser.esm.js +2 -1
  3. package/analytics/dist/valbuild-react-analytics.cjs.dev.js +6 -5
  4. package/analytics/dist/valbuild-react-analytics.cjs.prod.js +6 -5
  5. package/analytics/dist/valbuild-react-analytics.esm.js +2 -1
  6. package/analytics/dist/valbuild-react-analytics.worker.esm.js +2 -1
  7. package/dist/ValComponentEditorChrome-440d086a.cjs.dev.js +966 -0
  8. package/dist/ValComponentEditorChrome-4ac9dc79.worker.esm.js +952 -0
  9. package/dist/ValComponentEditorChrome-93321513.esm.js +952 -0
  10. package/dist/ValComponentEditorChrome-bf2fefc6.browser.esm.js +952 -0
  11. package/dist/ValComponentEditorChrome-c0b30556.cjs.js +7 -0
  12. package/dist/ValComponentEditorChrome-c0b30556.cjs.prod.js +966 -0
  13. package/dist/ValPreviewBridgeCore-00015d00.esm.js +157 -0
  14. package/dist/ValPreviewBridgeCore-023ffffb.browser.esm.js +157 -0
  15. package/dist/ValPreviewBridgeCore-9b984cb0.cjs.js +7 -0
  16. package/dist/ValPreviewBridgeCore-9b984cb0.cjs.prod.js +161 -0
  17. package/dist/ValPreviewBridgeCore-bbedf957.cjs.dev.js +161 -0
  18. package/dist/ValPreviewBridgeCore-e0d5a840.worker.esm.js +157 -0
  19. package/dist/{createForOfIteratorHelper-598a2f85.cjs.prod.js → createForOfIteratorHelper-6f9dc6fa.cjs.prod.js} +0 -17
  20. package/dist/{createForOfIteratorHelper-522d616d.cjs.dev.js → createForOfIteratorHelper-8a871dc3.cjs.dev.js} +0 -17
  21. package/dist/{createForOfIteratorHelper-595d57b7.esm.js → createForOfIteratorHelper-8bd0009a.browser.esm.js} +2 -18
  22. package/dist/{createForOfIteratorHelper-548f1578.worker.esm.js → createForOfIteratorHelper-93215c75.worker.esm.js} +2 -18
  23. package/dist/{createForOfIteratorHelper-3316a633.browser.esm.js → createForOfIteratorHelper-9b22d0cd.esm.js} +2 -18
  24. package/dist/declarations/src/internal/ValComponentEditor.d.ts +54 -0
  25. package/dist/declarations/src/internal/ValPreviewBridgeCore.d.ts +22 -0
  26. package/dist/declarations/src/internal/componentPreview.d.ts +39 -0
  27. package/dist/declarations/src/internal/index.d.ts +3 -0
  28. package/dist/declarations/src/read/jsonValues.d.ts +2 -0
  29. package/dist/declarations/src/stega/stegaEncode.d.ts +9 -218
  30. package/dist/objectSpread2-3c87fb4f.cjs.prod.js +52 -0
  31. package/dist/objectSpread2-69569a13.worker.esm.js +48 -0
  32. package/dist/objectSpread2-792eb2c2.cjs.dev.js +52 -0
  33. package/dist/objectSpread2-af6b2a44.browser.esm.js +48 -0
  34. package/dist/objectSpread2-be6bfc61.esm.js +48 -0
  35. package/dist/{raw-15ce77ae.browser.esm.js → raw-0561be8e.browser.esm.js} +81 -90
  36. package/dist/{raw-d504f4fd.cjs.prod.js → raw-a69a8d13.cjs.prod.js} +80 -92
  37. package/dist/{raw-534fcde0.esm.js → raw-aa7a3ac4.esm.js} +81 -90
  38. package/dist/{raw-67d24dd6.cjs.dev.js → raw-de032c12.cjs.dev.js} +80 -92
  39. package/dist/{raw-645a854a.worker.esm.js → raw-f32dca84.worker.esm.js} +81 -90
  40. package/dist/toConsumableArray-203e636a.cjs.prod.js +21 -0
  41. package/dist/toConsumableArray-257d6741.esm.js +19 -0
  42. package/dist/toConsumableArray-2fc46f85.browser.esm.js +19 -0
  43. package/dist/toConsumableArray-d7cf1601.cjs.dev.js +21 -0
  44. package/dist/toConsumableArray-e4f48095.worker.esm.js +19 -0
  45. package/internal/dist/valbuild-react-internal.browser.esm.js +405 -7
  46. package/internal/dist/valbuild-react-internal.cjs.dev.js +430 -24
  47. package/internal/dist/valbuild-react-internal.cjs.prod.js +430 -24
  48. package/internal/dist/valbuild-react-internal.esm.js +405 -7
  49. package/internal/dist/valbuild-react-internal.worker.esm.js +405 -7
  50. package/package.json +4 -4
  51. package/stega/dist/valbuild-react-stega.browser.esm.js +5 -3
  52. package/stega/dist/valbuild-react-stega.cjs.dev.js +11 -9
  53. package/stega/dist/valbuild-react-stega.cjs.prod.js +11 -9
  54. package/stega/dist/valbuild-react-stega.esm.js +5 -3
  55. package/stega/dist/valbuild-react-stega.worker.esm.js +5 -3
@@ -0,0 +1,157 @@
1
+ 'use client';
2
+ import { _ as _slicedToArray } from './slicedToArray-106ca5f3.worker.esm.js';
3
+ import { VAL_PREVIEW_MESSAGES, Internal } from '@valbuild/core';
4
+ import { DEFAULT_CANVAS_SELECTION } from '@valbuild/shared/client';
5
+ import { useRef, useState, useEffect } from 'react';
6
+ import { ValComponentControlsOff } from './ValComponentEditorChrome-4ac9dc79.worker.esm.js';
7
+ import { jsxs, jsx } from 'react/jsx-runtime';
8
+
9
+ var HOVER_ATTRIBUTE = "data-val-preview-hover";
10
+
11
+ /**
12
+ * EXPERIMENTAL: the preview route's side of its conversation with the Studio,
13
+ * without the framework. `@valbuild/next` and `@valbuild/tanstack` each wrap it
14
+ * with what a refresh means in their router.
15
+ *
16
+ * - **Refresh.** The Studio runs in the parent frame, so an edit is applied
17
+ * there and the preview has no way of knowing about it. The Studio posts a
18
+ * message, and this calls `onRefresh`, which reads the content again.
19
+ * - **Size.** The Studio cannot see into the frame to measure it, so this
20
+ * reports how tall the component is whenever that changes, and the Studio
21
+ * sizes the frame to fit.
22
+ * - **Pick.** Content read with stega carries its source path (Val tags the
23
+ * element with `data-val-path`), so a click on it says which field it came
24
+ * from. While the Studio has picking on - it is by default - a click on
25
+ * tagged content is sent to the Studio, which opens that field, instead of
26
+ * doing what it does on the site.
27
+ */
28
+ function ValPreviewBridgeCore(_ref) {
29
+ var onRefresh = _ref.onRefresh,
30
+ children = _ref.children;
31
+ var ref = useRef(null);
32
+ // A ref, so a new `onRefresh` - a router can hand out a new one after every
33
+ // refresh - does not re-subscribe and announce `ready` all over again.
34
+ var onRefreshRef = useRef(onRefresh);
35
+ onRefreshRef.current = onRefresh;
36
+ // On until the Studio says otherwise: it says so as soon as it hears `ready`.
37
+ var _useState = useState(true),
38
+ _useState2 = _slicedToArray(_useState, 2),
39
+ picking = _useState2[0],
40
+ setPicking = _useState2[1];
41
+ useEffect(function () {
42
+ if (window.parent === window) {
43
+ return;
44
+ }
45
+ var listener = function listener(event) {
46
+ var _event$data, _event$data2;
47
+ if (event.origin !== window.location.origin) {
48
+ return;
49
+ }
50
+ if (((_event$data = event.data) === null || _event$data === void 0 ? void 0 : _event$data.type) === VAL_PREVIEW_MESSAGES.refresh) {
51
+ onRefreshRef.current();
52
+ } else if (((_event$data2 = event.data) === null || _event$data2 === void 0 ? void 0 : _event$data2.type) === VAL_PREVIEW_MESSAGES.picking && typeof event.data.enabled === "boolean") {
53
+ setPicking(event.data.enabled);
54
+ }
55
+ };
56
+ window.addEventListener("message", listener);
57
+ window.parent.postMessage({
58
+ type: VAL_PREVIEW_MESSAGES.ready
59
+ }, window.location.origin);
60
+ return function () {
61
+ window.removeEventListener("message", listener);
62
+ };
63
+ }, []);
64
+ useEffect(function () {
65
+ var element = ref.current;
66
+ if (!element || window.parent === window) {
67
+ return;
68
+ }
69
+ var post = function post() {
70
+ // The wrapper rather than the document: a layout that gives the body a
71
+ // `min-height: 100vh` makes the document exactly as tall as the frame,
72
+ // so measuring it could only ever confirm the frame's height and never
73
+ // shrink it. Down to the wrapper's bottom edge, plus the body's own
74
+ // margin below it, is everything the component takes up.
75
+ var height = element.getBoundingClientRect().bottom + window.scrollY + (parseFloat(getComputedStyle(document.body).marginBottom) || 0);
76
+ window.parent.postMessage({
77
+ type: VAL_PREVIEW_MESSAGES.size,
78
+ height: Math.ceil(height)
79
+ }, window.location.origin);
80
+ };
81
+ var observer = new ResizeObserver(post);
82
+ observer.observe(element);
83
+ post();
84
+ return function () {
85
+ observer.disconnect();
86
+ };
87
+ }, []);
88
+ useEffect(function () {
89
+ if (!picking || window.parent === window) {
90
+ return;
91
+ }
92
+ var hovered = null;
93
+ var setHovered = function setHovered(next) {
94
+ var _hovered, _hovered2;
95
+ (_hovered = hovered) === null || _hovered === void 0 || _hovered.removeAttribute(HOVER_ATTRIBUTE);
96
+ hovered = next;
97
+ (_hovered2 = hovered) === null || _hovered2 === void 0 || _hovered2.setAttribute(HOVER_ATTRIBUTE, "");
98
+ };
99
+ var taggedAt = function taggedAt(target) {
100
+ return target instanceof Element ? target.closest("[data-val-path]") : null;
101
+ };
102
+ var onOver = function onOver(event) {
103
+ return setHovered(taggedAt(event.target));
104
+ };
105
+ var onLeave = function onLeave() {
106
+ return setHovered(null);
107
+ };
108
+ // Capture, so the component's own handlers - a link, a button - never
109
+ // see a click that was a pick.
110
+ var onClick = function onClick(event) {
111
+ var _taggedAt;
112
+ var attribute = (_taggedAt = taggedAt(event.target)) === null || _taggedAt === void 0 ? void 0 : _taggedAt.getAttribute("data-val-path");
113
+ if (!attribute) {
114
+ return;
115
+ }
116
+ event.preventDefault();
117
+ event.stopPropagation();
118
+ window.parent.postMessage({
119
+ type: VAL_PREVIEW_MESSAGES.pick,
120
+ paths: Internal.splitJoinedSourcePaths(attribute)
121
+ }, window.location.origin);
122
+ };
123
+ document.addEventListener("mouseover", onOver);
124
+ document.documentElement.addEventListener("mouseleave", onLeave);
125
+ document.addEventListener("click", onClick, {
126
+ capture: true
127
+ });
128
+ return function () {
129
+ setHovered(null);
130
+ document.removeEventListener("mouseover", onOver);
131
+ document.documentElement.removeEventListener("mouseleave", onLeave);
132
+ document.removeEventListener("click", onClick, {
133
+ capture: true
134
+ });
135
+ };
136
+ }, [picking]);
137
+
138
+ // `flow-root` so the first and last child's margins stay inside the box
139
+ // being measured, rather than collapsing through it.
140
+ return /*#__PURE__*/jsxs("div", {
141
+ ref: ref,
142
+ style: {
143
+ display: "flow-root"
144
+ },
145
+ children: [picking &&
146
+ /*#__PURE__*/
147
+ // The canvas's outline colour, so a pick looks the same in both
148
+ jsx("style", {
149
+ children: "[".concat(HOVER_ATTRIBUTE, "] { outline: 2px solid ").concat(DEFAULT_CANVAS_SELECTION, "; outline-offset: 2px; cursor: pointer; }")
150
+ }), /*#__PURE__*/jsx(ValComponentControlsOff.Provider, {
151
+ value: true,
152
+ children: children
153
+ })]
154
+ });
155
+ }
156
+
157
+ export { ValPreviewBridgeCore };
@@ -2,22 +2,6 @@
2
2
 
3
3
  var slicedToArray = require('./slicedToArray-64c83d56.cjs.prod.js');
4
4
 
5
- function _arrayWithoutHoles(r) {
6
- if (Array.isArray(r)) return slicedToArray._arrayLikeToArray(r);
7
- }
8
-
9
- function _iterableToArray(r) {
10
- if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
11
- }
12
-
13
- function _nonIterableSpread() {
14
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
15
- }
16
-
17
- function _toConsumableArray(r) {
18
- return _arrayWithoutHoles(r) || _iterableToArray(r) || slicedToArray._unsupportedIterableToArray(r) || _nonIterableSpread();
19
- }
20
-
21
5
  function _createForOfIteratorHelper(r, e) {
22
6
  var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
23
7
  if (!t) {
@@ -68,4 +52,3 @@ function _createForOfIteratorHelper(r, e) {
68
52
  }
69
53
 
70
54
  exports._createForOfIteratorHelper = _createForOfIteratorHelper;
71
- exports._toConsumableArray = _toConsumableArray;
@@ -2,22 +2,6 @@
2
2
 
3
3
  var slicedToArray = require('./slicedToArray-387314c6.cjs.dev.js');
4
4
 
5
- function _arrayWithoutHoles(r) {
6
- if (Array.isArray(r)) return slicedToArray._arrayLikeToArray(r);
7
- }
8
-
9
- function _iterableToArray(r) {
10
- if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
11
- }
12
-
13
- function _nonIterableSpread() {
14
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
15
- }
16
-
17
- function _toConsumableArray(r) {
18
- return _arrayWithoutHoles(r) || _iterableToArray(r) || slicedToArray._unsupportedIterableToArray(r) || _nonIterableSpread();
19
- }
20
-
21
5
  function _createForOfIteratorHelper(r, e) {
22
6
  var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
23
7
  if (!t) {
@@ -68,4 +52,3 @@ function _createForOfIteratorHelper(r, e) {
68
52
  }
69
53
 
70
54
  exports._createForOfIteratorHelper = _createForOfIteratorHelper;
71
- exports._toConsumableArray = _toConsumableArray;
@@ -1,20 +1,4 @@
1
- import { a as _arrayLikeToArray, b as _unsupportedIterableToArray } from './slicedToArray-70ecb9da.esm.js';
2
-
3
- function _arrayWithoutHoles(r) {
4
- if (Array.isArray(r)) return _arrayLikeToArray(r);
5
- }
6
-
7
- function _iterableToArray(r) {
8
- if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
9
- }
10
-
11
- function _nonIterableSpread() {
12
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
13
- }
14
-
15
- function _toConsumableArray(r) {
16
- return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
17
- }
1
+ import { b as _unsupportedIterableToArray } from './slicedToArray-b66ff800.browser.esm.js';
18
2
 
19
3
  function _createForOfIteratorHelper(r, e) {
20
4
  var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
@@ -65,4 +49,4 @@ function _createForOfIteratorHelper(r, e) {
65
49
  };
66
50
  }
67
51
 
68
- export { _toConsumableArray as _, _createForOfIteratorHelper as a };
52
+ export { _createForOfIteratorHelper as _ };
@@ -1,20 +1,4 @@
1
- import { a as _arrayLikeToArray, b as _unsupportedIterableToArray } from './slicedToArray-106ca5f3.worker.esm.js';
2
-
3
- function _arrayWithoutHoles(r) {
4
- if (Array.isArray(r)) return _arrayLikeToArray(r);
5
- }
6
-
7
- function _iterableToArray(r) {
8
- if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
9
- }
10
-
11
- function _nonIterableSpread() {
12
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
13
- }
14
-
15
- function _toConsumableArray(r) {
16
- return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
17
- }
1
+ import { b as _unsupportedIterableToArray } from './slicedToArray-106ca5f3.worker.esm.js';
18
2
 
19
3
  function _createForOfIteratorHelper(r, e) {
20
4
  var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
@@ -65,4 +49,4 @@ function _createForOfIteratorHelper(r, e) {
65
49
  };
66
50
  }
67
51
 
68
- export { _toConsumableArray as _, _createForOfIteratorHelper as a };
52
+ export { _createForOfIteratorHelper as _ };
@@ -1,20 +1,4 @@
1
- import { a as _arrayLikeToArray, b as _unsupportedIterableToArray } from './slicedToArray-b66ff800.browser.esm.js';
2
-
3
- function _arrayWithoutHoles(r) {
4
- if (Array.isArray(r)) return _arrayLikeToArray(r);
5
- }
6
-
7
- function _iterableToArray(r) {
8
- if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
9
- }
10
-
11
- function _nonIterableSpread() {
12
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
13
- }
14
-
15
- function _toConsumableArray(r) {
16
- return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
17
- }
1
+ import { b as _unsupportedIterableToArray } from './slicedToArray-70ecb9da.esm.js';
18
2
 
19
3
  function _createForOfIteratorHelper(r, e) {
20
4
  var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
@@ -65,4 +49,4 @@ function _createForOfIteratorHelper(r, e) {
65
49
  };
66
50
  }
67
51
 
68
- export { _toConsumableArray as _, _createForOfIteratorHelper as a };
52
+ export { _createForOfIteratorHelper as _ };
@@ -0,0 +1,54 @@
1
+ import { type ValComponent } from "@valbuild/core";
2
+ import { type ReactNode } from "react";
3
+ /**
4
+ * EXPERIMENTAL: see {@link ValComponentEditor}.
5
+ */
6
+ export type ValComponentEditorProps = {
7
+ /**
8
+ * What to render: an object linked to a component
9
+ * (`s.object(...).component(...)`), or a list of them - as `useVal`,
10
+ * `useValRoute` or `fetchVal` gave it back.
11
+ *
12
+ * Typed as {@link ValComponent}, which only a linked object reads as. A
13
+ * list with one kind that has no component, or an object that never had
14
+ * one, does not compile here.
15
+ */
16
+ value: ValComponent | readonly ValComponent[] | null;
17
+ /** On the element around a LIST. Not used for a single object. */
18
+ className?: string;
19
+ /** On the element around each component. */
20
+ itemClassName?: string;
21
+ /**
22
+ * Shown while a component's code is on its way: each is a lazy `import()`,
23
+ * so the first time a kind of section is shown its chunk is fetched.
24
+ * Nothing by default.
25
+ */
26
+ fallback?: ReactNode;
27
+ };
28
+ /**
29
+ * EXPERIMENTAL: renders content with the components its schema links it to.
30
+ *
31
+ * Each object is rendered by the component its own schema names
32
+ * (`.component(() => import("./Hero"))`), with the props that schema's `props`
33
+ * function makes of it - so there is no map from a `type` to a component to
34
+ * keep, and none to forget a case in. A list renders every item in order; a
35
+ * single object renders the one.
36
+ *
37
+ * In the Studio, on the page itself, a list can be arranged: a section is
38
+ * dragged to another place, one is added between two others, one is taken
39
+ * away. Outside the Studio none of that exists, and this is the components
40
+ * and an element around each.
41
+ *
42
+ * It is optional. The same content can be read and rendered by hand, with a
43
+ * `map` and a `switch`, and a page is free to use this for one list and not
44
+ * for the rest of what it shows.
45
+ *
46
+ * The component is found on the VALUE, which the reader attached it to. So
47
+ * render the value where it was read: one passed from a server component to
48
+ * a client component arrives without it, like the module behind a `s.view()`.
49
+ *
50
+ * @example
51
+ * const page = useValRoute(pageVal, {});
52
+ * return <ValComponentEditor value={page.sections} />;
53
+ */
54
+ export declare function ValComponentEditor({ value, className, itemClassName, fallback, }: ValComponentEditorProps): ReactNode;
@@ -0,0 +1,22 @@
1
+ import { type ReactNode } from "react";
2
+ /**
3
+ * EXPERIMENTAL: the preview route's side of its conversation with the Studio,
4
+ * without the framework. `@valbuild/next` and `@valbuild/tanstack` each wrap it
5
+ * with what a refresh means in their router.
6
+ *
7
+ * - **Refresh.** The Studio runs in the parent frame, so an edit is applied
8
+ * there and the preview has no way of knowing about it. The Studio posts a
9
+ * message, and this calls `onRefresh`, which reads the content again.
10
+ * - **Size.** The Studio cannot see into the frame to measure it, so this
11
+ * reports how tall the component is whenever that changes, and the Studio
12
+ * sizes the frame to fit.
13
+ * - **Pick.** Content read with stega carries its source path (Val tags the
14
+ * element with `data-val-path`), so a click on it says which field it came
15
+ * from. While the Studio has picking on - it is by default - a click on
16
+ * tagged content is sent to the Studio, which opens that field, instead of
17
+ * doing what it does on the site.
18
+ */
19
+ export declare function ValPreviewBridgeCore({ onRefresh, children, }: {
20
+ onRefresh: () => void;
21
+ children: ReactNode;
22
+ }): import("react").JSX.Element;
@@ -0,0 +1,39 @@
1
+ import { type SelectorSource, type ValModule, type ValModules } from "@valbuild/core";
2
+ import type { ComponentType, ReactNode } from "react";
3
+ /**
4
+ * EXPERIMENTAL: the module a source path is in, looked up in the app's
5
+ * `val.modules`. `null` when it is not registered.
6
+ */
7
+ export declare function findValModule(valModules: ValModules, sourcePath: string): Promise<ValModule<SelectorSource> | null>;
8
+ export type ValComponentPreviewResolution = {
9
+ status: "ok";
10
+ Component: ComponentType<Record<string, unknown>>;
11
+ props: Record<string, unknown>;
12
+ } | {
13
+ status: "error";
14
+ message: string;
15
+ };
16
+ /**
17
+ * EXPERIMENTAL: the component that renders the value at `sourcePath`, and the
18
+ * props to render it with - the framework-free half of a component preview,
19
+ * shared by `@valbuild/next` and `@valbuild/tanstack`.
20
+ *
21
+ * `moduleValue` is the module's content as the app reads it (`fetchVal`), not
22
+ * its own source: a section added in the Studio is in the former and not the
23
+ * latter, and only the content says which variant of a union a section is.
24
+ *
25
+ * With `example`, the props are the render's `example`; with `props`, those.
26
+ * Neither is content, so neither carries edit tags: a click in the preview must
27
+ * not lead to a field the value is not in.
28
+ */
29
+ export declare function resolveValComponentPreview({ valModule, sourcePath, moduleValue, example, props, }: {
30
+ valModule: ValModule<SelectorSource>;
31
+ sourcePath: string;
32
+ moduleValue: unknown;
33
+ example?: boolean;
34
+ props?: unknown;
35
+ }): Promise<ValComponentPreviewResolution>;
36
+ /** A message in place of the component, for when there is none to render. */
37
+ export declare function ValPreviewMessage({ children }: {
38
+ children: ReactNode;
39
+ }): import("react").JSX.Element;
@@ -1,2 +1,5 @@
1
1
  export { ValRichText } from "./ValRichText.js";
2
2
  export * from "../read/index.js";
3
+ export { findValModule, resolveValComponentPreview, ValPreviewMessage, type ValComponentPreviewResolution, } from "./componentPreview.js";
4
+ export { ValPreviewBridgeCore } from "./ValPreviewBridgeCore.js";
5
+ export { ValComponentEditor, type ValComponentEditorProps, } from "./ValComponentEditor.js";
@@ -1,3 +1,4 @@
1
+ import { type Schema, type SelectorSource } from "@valbuild/core";
1
2
  /**
2
3
  * True when the module's schema is a `.jsonValues()` record/router — i.e. each
3
4
  * entry value is a lazily-loaded `c.json(() => import(...))` marker. Used by the
@@ -23,4 +24,5 @@ export declare function bundledJsonEntryImport(module: any, key: string): (() =>
23
24
  export declare function getJsonEntryStegaRoot(selector: any, key: string): {
24
25
  path: any;
25
26
  schema: any;
27
+ instance: Schema<SelectorSource>;
26
28
  } | undefined;
@@ -1,220 +1,9 @@
1
- import { Json, RichTextSource, IsVideoSource, VideoCaptionSource, MediaHotspot, RichTextOptions, ImageSource } from "@valbuild/core";
2
- import { FileSource, Source, SourceObject } from "@valbuild/core";
3
- import type { ValView, ValViewSource } from "@valbuild/core";
4
- import { JsonPrimitive } from "@valbuild/core";
5
- import { SourceArray } from "@valbuild/core";
6
- import { RawString } from "@valbuild/core";
1
+ import { Source, SourceObject } from "@valbuild/core";
2
+ import type { ValView } from "@valbuild/core";
3
+ import { type Schema } from "@valbuild/core";
7
4
  import type { GenericSelector, JsonSource, SelectorOf, SelectorSource } from "@valbuild/core";
8
- declare const brand: unique symbol;
9
- /**
10
- * ValEncodedString is a string that is encoded using steganography.
11
- *
12
- * This means that there is a hidden / non-visible object embedded in the string.
13
- * This object includes a path, which is used to automatically tag
14
- * where the content comes from for contextual editing.
15
- *
16
- */
17
- export type ValEncodedString = `${string}__VAL_ENCODED_STRING_INVISIBLE_CHARS` & {
18
- /**
19
- *
20
- * NB: This is a Val ENCODED string, which means that you should not use this method.
21
- *
22
- * Instead, get the raw string using `val.raw`
23
- *
24
- * @deprecated NB: This is a Val ENCODED string, which means that you should not use this method.
25
- *
26
- * @example
27
- * val.raw(myEncodedString) // returns a normal string
28
- */
29
- substring: never;
30
- /**
31
- *
32
- * NB: This is a Val ENCODED string, which means that you should not use this method.
33
- *
34
- * Instead, get the raw string using `val.raw`
35
- *
36
- * @deprecated NB: This is a Val ENCODED string, which means that you should not use this method.
37
- *
38
- * @example
39
- * val.raw(myEncodedString) // returns a normal string
40
- */
41
- match: never;
42
- /**
43
- *
44
- * NB: This is a Val ENCODED string, which means that you should not use this method.
45
- *
46
- * Instead, get the raw string using `val.raw`
47
- *
48
- * @deprecated NB: This is a Val ENCODED string, which means that you should not use this method.
49
- *
50
- * @example
51
- * val.raw(myEncodedString) // returns a normal string
52
- */
53
- charAt: never;
54
- /**
55
- *
56
- * NB: This is a Val ENCODED string, which means that you should not use this method.
57
- *
58
- * Instead, get the raw string using `val.raw`
59
- *
60
- * @deprecated NB: This is a Val ENCODED string, which means that you should not use this method.
61
- *
62
- * @example
63
- * val.raw(myEncodedString) // returns a normal string
64
- */
65
- charCodeAt: never;
66
- /**
67
- *
68
- * NB: This is a Val ENCODED string, which means that you should not use this method.
69
- *
70
- * Instead, get the raw string using `val.raw`
71
- *
72
- * @deprecated NB: This is a Val ENCODED string, which means that you should not use this method.
73
- *
74
- * @example
75
- * val.raw(myEncodedString) // returns a normal string
76
- */
77
- concat: never;
78
- /**
79
- *
80
- * NB: This is a Val ENCODED string, which means that you should not use this method.
81
- *
82
- * Instead, get the raw string using `val.raw`
83
- *
84
- * @deprecated NB: This is a Val ENCODED string, which means that you should not use this method.
85
- *
86
- * @example
87
- * val.raw(myEncodedString) // returns a normal string
88
- */
89
- indexOf: never;
90
- /**
91
- *
92
- * NB: This is a Val ENCODED string, which means that you should not use this method.
93
- *
94
- * Instead, get the raw string using `val.raw`
95
- *
96
- * @deprecated NB: This is a Val ENCODED string, which means that you should not use this method.
97
- *
98
- * @example
99
- * val.raw(myEncodedString) // returns a normal string
100
- */
101
- lastIndexOf: never;
102
- /**
103
- *
104
- * NB: This is a Val ENCODED string, which means that you should not use this method.
105
- *
106
- * Instead, get the raw string using `val.raw`
107
- *
108
- * @deprecated NB: This is a Val ENCODED string, which means that you should not use this method.
109
- *
110
- * @example
111
- * val.raw(myEncodedString) // returns a normal string
112
- */
113
- slice: never;
114
- /**
115
- *
116
- * NB: This is a Val ENCODED string, which means that you should not use this method.
117
- *
118
- * Instead, get the raw string using `val.raw`
119
- *
120
- * @deprecated NB: This is a Val ENCODED string, which means that you should not use this method.
121
- *
122
- * @example
123
- * val.raw(myEncodedString) // returns a normal string
124
- */
125
- toString: never;
126
- /**
127
- *
128
- * NB: This is a Val ENCODED string, which means that you should not use this method.
129
- *
130
- * Instead, get the raw string using `val.raw`
131
- *
132
- * @deprecated NB: This is a Val ENCODED string, which means that you should not use this method.
133
- *
134
- * @example
135
- * val.raw(myEncodedString) // returns a normal string
136
- */
137
- /**
138
- *
139
- * NB: This is a Val ENCODED string, which means that you should not use length on it.
140
- *
141
- * Instead, get the raw string using `val.raw`
142
- *
143
- * @deprecated NB: This is a Val ENCODED string, which means that you should not use this method.
144
- *
145
- * @example
146
- * val.raw(myEncodedString) // returns a normal string
147
- */
148
- length: never;
149
- [brand]: "ValEncodedString";
150
- };
151
- /**
152
- * An image as a consumer sees it: what was authored, plus the generated `url`.
153
- *
154
- * `path` stays a plain string — it is what `url` is derived from, so encoding it
155
- * would corrupt every URL built from it.
156
- */
157
- export type Image = {
158
- readonly path: string;
159
- readonly url: ValEncodedString;
160
- readonly width?: number;
161
- readonly height?: number;
162
- readonly mimeType?: string;
163
- readonly alt?: string;
164
- readonly hotspot?: MediaHotspot;
165
- };
166
- export type File = {
167
- readonly path: string;
168
- readonly url: ValEncodedString;
169
- readonly mimeType?: string;
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
- };
206
- export type StegaOfRichTextSource<T extends Source> = Json extends T ? Json : T extends ImageSource ? Image : T extends SourceObject ? {
207
- [key in keyof T]: StegaOfRichTextSource<T[key]>;
208
- } : T extends SourceArray ? StegaOfRichTextSource<T[number]>[] : T extends JsonPrimitive ? T : never;
209
- /**
210
- * RichText is accessible by users (after conversion via useVal / fetchVal)
211
- **/
212
- export type RichText<O extends RichTextOptions> = StegaOfRichTextSource<RichTextSource<O>> & {
213
- readonly __brand?: "RichText";
214
- };
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 ? {
216
- [key in keyof T]: StegaOfSource<T[key]>;
217
- } : T extends SourceArray ? StegaOfSource<T[number]>[] : T extends RawString ? string : string extends T ? ValEncodedString : T extends JsonPrimitive ? T : never;
5
+ export type { ValEncodedString, Image, File, Video, StegaOfRichTextSource, RichText, StegaOfSource, } from "@valbuild/core";
6
+ import type { StegaOfSource } from "@valbuild/core";
218
7
  /**
219
8
  * What resolving `T` gives back — the one definition the framework readers
220
9
  * share.
@@ -272,13 +61,15 @@ export declare function stegaEncode(input: any, opts: {
272
61
  * the encoder and the whole call is an identity transform.
273
62
  *
274
63
  * `path` is the entry's path (`Internal.createValPathOfItem(modulePath, key)`)
275
- * and `schema` is the SERIALIZED item schema.
64
+ * and `schema` is the SERIALIZED item schema. `instance` is the item
65
+ * schema itself, which is where a `.component()` lives: without it the
66
+ * entry's objects are encoded and carry no component.
276
67
  */
277
68
  root?: {
278
69
  path: any;
279
70
  schema: any;
71
+ instance?: Schema<SelectorSource>;
280
72
  };
281
73
  }): any;
282
74
  export declare function stegaClean(source: string): string;
283
75
  export declare function getModuleIds(input: any): string[];
284
- export {};