@valbuild/next 0.154.0 → 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.
- package/CHANGELOG.md +78 -0
- package/dist/{ValCanvasBridge-9b2df334.cjs.dev.js → ValCanvasBridge-194bfcc3.cjs.dev.js} +21 -2
- package/dist/{ValCanvasBridge-719e6efe.esm.js → ValCanvasBridge-aa626997.esm.js} +22 -3
- package/dist/ValCanvasBridge-cefe83f7.cjs.js +7 -0
- package/dist/{ValCanvasBridge-063ad333.cjs.prod.js → ValCanvasBridge-cefe83f7.cjs.prod.js} +21 -2
- package/dist/ValNextProvider-27242758.esm.js +1 -1
- package/dist/ValNextProvider-4838fed0.cjs.dev.js +1 -1
- package/dist/ValNextProvider-9343dc1e.cjs.prod.js +1 -1
- package/dist/ValPreviewBridge-2d09c5a9.cjs.dev.js +38 -0
- package/dist/ValPreviewBridge-81f717c7.cjs.js +7 -0
- package/dist/ValPreviewBridge-81f717c7.cjs.prod.js +38 -0
- package/dist/ValPreviewBridge-c635208d.esm.js +34 -0
- package/dist/ValPreviewError-137b27f8.cjs.dev.js +59 -0
- package/dist/ValPreviewError-37a42fdf.esm.js +55 -0
- package/dist/ValPreviewError-cc0aef49.cjs.js +7 -0
- package/dist/ValPreviewError-cc0aef49.cjs.prod.js +59 -0
- package/dist/declarations/src/ValComponentPreview.d.ts +58 -0
- package/dist/declarations/src/ValPreviewBridge.d.ts +21 -0
- package/dist/declarations/src/ValPreviewError.d.ts +25 -0
- package/dist/declarations/src/external_exempt_from_val_quickjs.d.ts +4 -0
- package/dist/declarations/src/rsc/initValRsc.d.ts +4 -4
- package/dist/valbuild-next.cjs.dev.js +96 -1
- package/dist/valbuild-next.cjs.prod.js +96 -1
- package/dist/valbuild-next.esm.js +86 -3
- package/dist/{version-9adeab58.esm.js → version-281feaf7.esm.js} +1 -1
- package/dist/{version-4d44d9cd.cjs.prod.js → version-c40f4d2d.cjs.prod.js} +1 -1
- package/dist/{version-93ae5f54.cjs.dev.js → version-f62ea496.cjs.dev.js} +1 -1
- package/package.json +8 -8
- package/rsc/dist/valbuild-next-rsc.cjs.dev.js +30 -21
- package/rsc/dist/valbuild-next-rsc.cjs.prod.js +30 -21
- package/rsc/dist/valbuild-next-rsc.esm.js +20 -11
- package/server/dist/valbuild-next-server.cjs.dev.js +1 -1
- package/server/dist/valbuild-next-server.cjs.prod.js +1 -1
- package/server/dist/valbuild-next-server.esm.js +1 -1
- package/dist/ValCanvasBridge-063ad333.cjs.js +0 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,83 @@
|
|
|
1
1
|
# @valbuild/next
|
|
2
2
|
|
|
3
|
+
## 0.154.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1087](https://github.com/valbuild/val/pull/1087) [`9e085bc`](https://github.com/valbuild/val/commit/9e085bc2b2104ce2644b4a14948288c799a2ce82) Thanks [@freekh](https://github.com/freekh)! - **A published page no longer loads the Studio, TypeScript, sucrase or prettier.** A site's first request in a fresh server process (on Val's hosting, every request a cold isolate answers) used to evaluate all of Val's server: the Studio's embedded assets (about 22 MB), TypeScript (9 MB), sucrase and the MCP tools. A page only needs that when someone edits it. These now load when they are first used, by the Val API, a draft read, a save or an MCP call, and a visitor's page never loads them.
|
|
8
|
+
|
|
9
|
+
We measured this in a fresh Node process, with the TanStack example app built the way a deployed app is built and running as a deployed site does (`http` mode). The first request for a public page used to load 38.8 MB of modules, take about 1.06 s and leave 170 MB of heap in use. It now loads 5.3 MB, takes about 0.23 s and leaves 38 MB of heap. An isolate counts more than Node does, so treat these heap figures as a lower bound.
|
|
10
|
+
|
|
11
|
+
What changed for an app:
|
|
12
|
+
|
|
13
|
+
- `initValContent` (and `initValRsc` in `@valbuild/next`) no longer start Val's server when they are created. They start it on the first draft read.
|
|
14
|
+
- With TanStack Start, `initValServer` loads the server on its first request in `http` mode, which is what a deployed site runs in. In local development (`fs` mode) and memory mode it still starts with the app. Those modes need the newest build in a process to exist before the previous build answers a request.
|
|
15
|
+
- `initValMcp` from `@valbuild/tanstack/server` loads the MCP tools on the first MCP request. Its `valMcpMetadata` comes from the new `@valbuild/mcp/metadata` entry, which is small.
|
|
16
|
+
- `createPrettierFormatter` now also accepts a loader. **Update your `val.server.ts`** so prettier is loaded by the first save rather than by every page:
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
// before
|
|
20
|
+
import prettier from "prettier";
|
|
21
|
+
formatter: createPrettierFormatter(prettier, { projectRoot: process.cwd() }),
|
|
22
|
+
|
|
23
|
+
// after
|
|
24
|
+
formatter: createPrettierFormatter(() => import("prettier"), {
|
|
25
|
+
projectRoot: process.cwd(),
|
|
26
|
+
}),
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Passing `prettier` itself still works.
|
|
30
|
+
|
|
31
|
+
- If your app serves MCP from a TanStack Start route, import the MCP SDK inside the handler (`await import("@modelcontextprotocol/server")`), not at the top of the file. TanStack Start's route tree imports every server route's module on every cold start.
|
|
32
|
+
|
|
33
|
+
- [#1049](https://github.com/valbuild/val/pull/1049) [`d90b9e2`](https://github.com/valbuild/val/commit/d90b9e2f856d4023821698cd22b4fbbab046c2ff) Thanks [@freekh](https://github.com/freekh)! - Experimental: link an object to the component that renders it, and let Val render and arrange it
|
|
34
|
+
|
|
35
|
+
`s.object(...).component(() => import("./Hero"))` links an object schema to a component. The link is type checked against the component's own props: when the object's fields are the props nothing else is needed, and for any other component a `props` function says how to make them.
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
export const heroFields = s.object({
|
|
39
|
+
type: s.literal("hero"),
|
|
40
|
+
title: s.string(),
|
|
41
|
+
});
|
|
42
|
+
export const hero = heroFields.component(() => import("../components/Hero"));
|
|
43
|
+
|
|
44
|
+
export const note = s
|
|
45
|
+
.object({ type: s.literal("note"), title: s.string(), urgent: s.boolean() })
|
|
46
|
+
.component(() => import("../components/Callout"), {
|
|
47
|
+
props: (note) => ({
|
|
48
|
+
heading: note.title,
|
|
49
|
+
tone: note.urgent ? "warning" : "info",
|
|
50
|
+
}),
|
|
51
|
+
});
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
`<ValComponentEditor value={page.sections} />`, from `@valbuild/tanstack` and `@valbuild/next`, renders a list of linked objects (or a single one) with their components, with no map from a `type` to a component to keep. It only accepts values that are linked: a list with a variant that has no component is a type error. It is optional, and a component can use it for a list of components of its own.
|
|
55
|
+
|
|
56
|
+
In Val Studio, a list rendered this way can be arranged on the page itself: drag a section to another place, add one between two others, or remove one.
|
|
57
|
+
|
|
58
|
+
This replaces the experimental `.render({ as: "component", component })` on objects. Move its `component` to the first argument of `.component()` and the rest of its options to the second.
|
|
59
|
+
|
|
60
|
+
- Updated dependencies [[`9e085bc`](https://github.com/valbuild/val/commit/9e085bc2b2104ce2644b4a14948288c799a2ce82), [`d90b9e2`](https://github.com/valbuild/val/commit/d90b9e2f856d4023821698cd22b4fbbab046c2ff), [`180b6b7`](https://github.com/valbuild/val/commit/180b6b7513226009e7eb6a768282d70685ccf436), [`a52c184`](https://github.com/valbuild/val/commit/a52c184687849ba9c2c2a4929871b60502a6ee55), [`6c26409`](https://github.com/valbuild/val/commit/6c2640966779e20931672dc78ff6e3c0d19e4183), [`d90b9e2`](https://github.com/valbuild/val/commit/d90b9e2f856d4023821698cd22b4fbbab046c2ff)]:
|
|
61
|
+
- @valbuild/server@0.154.2
|
|
62
|
+
- @valbuild/mcp@0.154.2
|
|
63
|
+
- @valbuild/core@0.154.2
|
|
64
|
+
- @valbuild/react@0.154.2
|
|
65
|
+
- @valbuild/shared@0.154.2
|
|
66
|
+
- @valbuild/ui@0.154.2
|
|
67
|
+
- @valbuild/language-server@0.154.2
|
|
68
|
+
|
|
69
|
+
## 0.154.1
|
|
70
|
+
|
|
71
|
+
### Patch Changes
|
|
72
|
+
|
|
73
|
+
- Updated dependencies [[`37e4f39`](https://github.com/valbuild/val/commit/37e4f390d1fd6a930488c9487de43f8c1a390122), [`245843e`](https://github.com/valbuild/val/commit/245843ec527212dc31c6e1da1f0bd5f9d99cf8d3), [`d4e514f`](https://github.com/valbuild/val/commit/d4e514f9eac2f014fc07aa768787d637898dc744), [`def1434`](https://github.com/valbuild/val/commit/def1434324a0b3e26202148cb11726e02bd5bffe), [`82c641c`](https://github.com/valbuild/val/commit/82c641ca00ddfe1ed5b07b9ccb5ee39b0c6f102e)]:
|
|
74
|
+
- @valbuild/ui@0.154.1
|
|
75
|
+
- @valbuild/server@0.154.1
|
|
76
|
+
- @valbuild/shared@0.154.1
|
|
77
|
+
- @valbuild/react@0.154.1
|
|
78
|
+
- @valbuild/language-server@0.154.1
|
|
79
|
+
- @valbuild/mcp@0.154.1
|
|
80
|
+
|
|
3
81
|
## 0.154.0
|
|
4
82
|
|
|
5
83
|
### Patch Changes
|
|
@@ -11,7 +11,7 @@ var slicedToArray = require('./slicedToArray-ed812733.cjs.dev.js');
|
|
|
11
11
|
var React = require('react');
|
|
12
12
|
var core = require('@valbuild/core');
|
|
13
13
|
var client = require('@valbuild/shared/client');
|
|
14
|
-
var version = require('./version-
|
|
14
|
+
var version = require('./version-f62ea496.cjs.dev.js');
|
|
15
15
|
var jsxRuntime = require('react/jsx-runtime');
|
|
16
16
|
|
|
17
17
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
@@ -98,6 +98,15 @@ function ValCanvasBridge(_ref) {
|
|
|
98
98
|
// installed once and would otherwise close over the first value forever.
|
|
99
99
|
var pickingRef = React__default["default"].useRef(false);
|
|
100
100
|
pickingRef.current = picking;
|
|
101
|
+
// Said on the document too, for the controls `ValComponentEditor` draws:
|
|
102
|
+
// they are shown only while Select is on.
|
|
103
|
+
React__default["default"].useEffect(function () {
|
|
104
|
+
var root = document.documentElement;
|
|
105
|
+
root.toggleAttribute(client.VAL_CANVAS_EDITING_ATTRIBUTE, picking);
|
|
106
|
+
return function () {
|
|
107
|
+
return root.removeAttribute(client.VAL_CANVAS_EDITING_ATTRIBUTE);
|
|
108
|
+
};
|
|
109
|
+
}, [picking]);
|
|
101
110
|
/**
|
|
102
111
|
* Picking ANY element (`pickElements`), as the studio last said. `null`
|
|
103
112
|
* until it says.
|
|
@@ -758,6 +767,9 @@ function ValCanvasBridge(_ref) {
|
|
|
758
767
|
var _heldKeys$current2;
|
|
759
768
|
var target = event.target;
|
|
760
769
|
if (!(target instanceof Element)) return;
|
|
770
|
+
// Val's own controls on a list of components, not the page's content:
|
|
771
|
+
// the click is theirs, wherever in the page they are drawn.
|
|
772
|
+
if (client.isOnValCanvasControls(target)) return;
|
|
761
773
|
// A click in the field being typed in places the caret, and that is
|
|
762
774
|
// all it does: it is neither a pick nor a click on the link or button
|
|
763
775
|
// the text happens to be in. (The caret is the mousedown's, so
|
|
@@ -1064,7 +1076,14 @@ function ValCanvasBridge(_ref) {
|
|
|
1064
1076
|
// CSS string. A path contains quotes (`?p="/"`) and would otherwise
|
|
1065
1077
|
// close the selector early.
|
|
1066
1078
|
dangerouslySetInnerHTML: {
|
|
1067
|
-
__html: [
|
|
1079
|
+
__html: [":root { ".concat(client.VAL_CANVAS_SELECTION_PROPERTY, ": ").concat(selectionColors.selection, "; }"),
|
|
1080
|
+
// Not around a component's item: its controls outline it, and two
|
|
1081
|
+
// boxes on one element is one too many. The conditions are in
|
|
1082
|
+
// `:where()`, which counts for nothing: this rule must stay as
|
|
1083
|
+
// weak as `[data-val-path]` alone, or it beats the outline of the
|
|
1084
|
+
// field the Studio is on (`highlightRule`, below) and that field
|
|
1085
|
+
// looks like every other one while Select is on.
|
|
1086
|
+
picking ? ":where(:root:not([".concat(client.VAL_COMPONENT_DRAGGING_ATTRIBUTE, "])) [data-val-path]:where(:not([").concat(client.VAL_COMPONENT_ATTRIBUTE, "])) { outline: 1px solid ").concat(selectionColors.selectionSoft, "; outline-offset: 1px; cursor: pointer; }\n:where(:root:not([").concat(client.VAL_COMPONENT_DRAGGING_ATTRIBUTE, "])) [data-val-path]:where(:not([").concat(client.VAL_COMPONENT_ATTRIBUTE, "])):hover { outline: 2px solid ").concat(selectionColors.selection, "; }") : "",
|
|
1068
1087
|
// The one rule here that moves the page, and only while Select is
|
|
1069
1088
|
// on: an emptied text's line of room, without which it cannot be
|
|
1070
1089
|
// pointed at. See `emptyTextFields.ts` for why, and how narrowly.
|
|
@@ -6,8 +6,8 @@ import { _ as _objectSpread2 } from './objectSpread2-f1f0d77a.esm.js';
|
|
|
6
6
|
import { _ as _slicedToArray } from './slicedToArray-5ff32315.esm.js';
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import { Internal } from '@valbuild/core';
|
|
9
|
-
import { markEmptyTextFields, VAL_CANVAS_MESSAGE, watchPageLocation, startElementPicking, EMPTY_TEXT_RULES, installPageLog, DEFAULT_CANVAS_SELECTION, DEFAULT_CANVAS_SELECTION_SOFT, isValCanvasStudioMessage, restoreScroll, interactWithPage, storeQuickPreview, QUICK_PREVIEW_SERVICE_WORKER_PATH, replayKeys, isCodeChangedDetail, holdKeys, startInlineEditing, screenshotPage, readPageSnapshot, BRIDGE_CAPABILITIES } from '@valbuild/shared/client';
|
|
10
|
-
import { V as VERSION } from './version-
|
|
9
|
+
import { VAL_CANVAS_EDITING_ATTRIBUTE, markEmptyTextFields, VAL_CANVAS_MESSAGE, watchPageLocation, startElementPicking, VAL_CANVAS_SELECTION_PROPERTY, VAL_COMPONENT_DRAGGING_ATTRIBUTE, VAL_COMPONENT_ATTRIBUTE, EMPTY_TEXT_RULES, installPageLog, DEFAULT_CANVAS_SELECTION, DEFAULT_CANVAS_SELECTION_SOFT, isValCanvasStudioMessage, restoreScroll, interactWithPage, storeQuickPreview, QUICK_PREVIEW_SERVICE_WORKER_PATH, replayKeys, isCodeChangedDetail, isOnValCanvasControls, holdKeys, startInlineEditing, screenshotPage, readPageSnapshot, BRIDGE_CAPABILITIES } from '@valbuild/shared/client';
|
|
10
|
+
import { V as VERSION } from './version-281feaf7.esm.js';
|
|
11
11
|
import { jsx } from 'react/jsx-runtime';
|
|
12
12
|
|
|
13
13
|
function _arrayWithoutHoles(r) {
|
|
@@ -90,6 +90,15 @@ function ValCanvasBridge(_ref) {
|
|
|
90
90
|
// installed once and would otherwise close over the first value forever.
|
|
91
91
|
var pickingRef = React.useRef(false);
|
|
92
92
|
pickingRef.current = picking;
|
|
93
|
+
// Said on the document too, for the controls `ValComponentEditor` draws:
|
|
94
|
+
// they are shown only while Select is on.
|
|
95
|
+
React.useEffect(function () {
|
|
96
|
+
var root = document.documentElement;
|
|
97
|
+
root.toggleAttribute(VAL_CANVAS_EDITING_ATTRIBUTE, picking);
|
|
98
|
+
return function () {
|
|
99
|
+
return root.removeAttribute(VAL_CANVAS_EDITING_ATTRIBUTE);
|
|
100
|
+
};
|
|
101
|
+
}, [picking]);
|
|
93
102
|
/**
|
|
94
103
|
* Picking ANY element (`pickElements`), as the studio last said. `null`
|
|
95
104
|
* until it says.
|
|
@@ -750,6 +759,9 @@ function ValCanvasBridge(_ref) {
|
|
|
750
759
|
var _heldKeys$current2;
|
|
751
760
|
var target = event.target;
|
|
752
761
|
if (!(target instanceof Element)) return;
|
|
762
|
+
// Val's own controls on a list of components, not the page's content:
|
|
763
|
+
// the click is theirs, wherever in the page they are drawn.
|
|
764
|
+
if (isOnValCanvasControls(target)) return;
|
|
753
765
|
// A click in the field being typed in places the caret, and that is
|
|
754
766
|
// all it does: it is neither a pick nor a click on the link or button
|
|
755
767
|
// the text happens to be in. (The caret is the mousedown's, so
|
|
@@ -1056,7 +1068,14 @@ function ValCanvasBridge(_ref) {
|
|
|
1056
1068
|
// CSS string. A path contains quotes (`?p="/"`) and would otherwise
|
|
1057
1069
|
// close the selector early.
|
|
1058
1070
|
dangerouslySetInnerHTML: {
|
|
1059
|
-
__html: [
|
|
1071
|
+
__html: [":root { ".concat(VAL_CANVAS_SELECTION_PROPERTY, ": ").concat(selectionColors.selection, "; }"),
|
|
1072
|
+
// Not around a component's item: its controls outline it, and two
|
|
1073
|
+
// boxes on one element is one too many. The conditions are in
|
|
1074
|
+
// `:where()`, which counts for nothing: this rule must stay as
|
|
1075
|
+
// weak as `[data-val-path]` alone, or it beats the outline of the
|
|
1076
|
+
// field the Studio is on (`highlightRule`, below) and that field
|
|
1077
|
+
// looks like every other one while Select is on.
|
|
1078
|
+
picking ? ":where(:root:not([".concat(VAL_COMPONENT_DRAGGING_ATTRIBUTE, "])) [data-val-path]:where(:not([").concat(VAL_COMPONENT_ATTRIBUTE, "])) { outline: 1px solid ").concat(selectionColors.selectionSoft, "; outline-offset: 1px; cursor: pointer; }\n:where(:root:not([").concat(VAL_COMPONENT_DRAGGING_ATTRIBUTE, "])) [data-val-path]:where(:not([").concat(VAL_COMPONENT_ATTRIBUTE, "])):hover { outline: 2px solid ").concat(selectionColors.selection, "; }") : "",
|
|
1060
1079
|
// The one rule here that moves the page, and only while Select is
|
|
1061
1080
|
// on: an emptied text's line of room, without which it cannot be
|
|
1062
1081
|
// pointed at. See `emptyTextFields.ts` for why, and how narrowly.
|
|
@@ -11,7 +11,7 @@ var slicedToArray = require('./slicedToArray-0fc63719.cjs.prod.js');
|
|
|
11
11
|
var React = require('react');
|
|
12
12
|
var core = require('@valbuild/core');
|
|
13
13
|
var client = require('@valbuild/shared/client');
|
|
14
|
-
var version = require('./version-
|
|
14
|
+
var version = require('./version-c40f4d2d.cjs.prod.js');
|
|
15
15
|
var jsxRuntime = require('react/jsx-runtime');
|
|
16
16
|
|
|
17
17
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
@@ -98,6 +98,15 @@ function ValCanvasBridge(_ref) {
|
|
|
98
98
|
// installed once and would otherwise close over the first value forever.
|
|
99
99
|
var pickingRef = React__default["default"].useRef(false);
|
|
100
100
|
pickingRef.current = picking;
|
|
101
|
+
// Said on the document too, for the controls `ValComponentEditor` draws:
|
|
102
|
+
// they are shown only while Select is on.
|
|
103
|
+
React__default["default"].useEffect(function () {
|
|
104
|
+
var root = document.documentElement;
|
|
105
|
+
root.toggleAttribute(client.VAL_CANVAS_EDITING_ATTRIBUTE, picking);
|
|
106
|
+
return function () {
|
|
107
|
+
return root.removeAttribute(client.VAL_CANVAS_EDITING_ATTRIBUTE);
|
|
108
|
+
};
|
|
109
|
+
}, [picking]);
|
|
101
110
|
/**
|
|
102
111
|
* Picking ANY element (`pickElements`), as the studio last said. `null`
|
|
103
112
|
* until it says.
|
|
@@ -758,6 +767,9 @@ function ValCanvasBridge(_ref) {
|
|
|
758
767
|
var _heldKeys$current2;
|
|
759
768
|
var target = event.target;
|
|
760
769
|
if (!(target instanceof Element)) return;
|
|
770
|
+
// Val's own controls on a list of components, not the page's content:
|
|
771
|
+
// the click is theirs, wherever in the page they are drawn.
|
|
772
|
+
if (client.isOnValCanvasControls(target)) return;
|
|
761
773
|
// A click in the field being typed in places the caret, and that is
|
|
762
774
|
// all it does: it is neither a pick nor a click on the link or button
|
|
763
775
|
// the text happens to be in. (The caret is the mousedown's, so
|
|
@@ -1064,7 +1076,14 @@ function ValCanvasBridge(_ref) {
|
|
|
1064
1076
|
// CSS string. A path contains quotes (`?p="/"`) and would otherwise
|
|
1065
1077
|
// close the selector early.
|
|
1066
1078
|
dangerouslySetInnerHTML: {
|
|
1067
|
-
__html: [
|
|
1079
|
+
__html: [":root { ".concat(client.VAL_CANVAS_SELECTION_PROPERTY, ": ").concat(selectionColors.selection, "; }"),
|
|
1080
|
+
// Not around a component's item: its controls outline it, and two
|
|
1081
|
+
// boxes on one element is one too many. The conditions are in
|
|
1082
|
+
// `:where()`, which counts for nothing: this rule must stay as
|
|
1083
|
+
// weak as `[data-val-path]` alone, or it beats the outline of the
|
|
1084
|
+
// field the Studio is on (`highlightRule`, below) and that field
|
|
1085
|
+
// looks like every other one while Select is on.
|
|
1086
|
+
picking ? ":where(:root:not([".concat(client.VAL_COMPONENT_DRAGGING_ATTRIBUTE, "])) [data-val-path]:where(:not([").concat(client.VAL_COMPONENT_ATTRIBUTE, "])) { outline: 1px solid ").concat(selectionColors.selectionSoft, "; outline-offset: 1px; cursor: pointer; }\n:where(:root:not([").concat(client.VAL_COMPONENT_DRAGGING_ATTRIBUTE, "])) [data-val-path]:where(:not([").concat(client.VAL_COMPONENT_ATTRIBUTE, "])):hover { outline: 2px solid ").concat(selectionColors.selection, "; }") : "",
|
|
1068
1087
|
// The one rule here that moves the page, and only while Select is
|
|
1069
1088
|
// on: an emptied text's line of room, without which it cannot be
|
|
1070
1089
|
// pointed at. See `emptyTextFields.ts` for why, and how narrowly.
|
|
@@ -13,7 +13,7 @@ import { isDraft, windowCodeChangedReporter, createDraftStore, draftHolds, draft
|
|
|
13
13
|
import { p as prefixStyles, u as useConfigStorageSave, f as floatDarkBg, d as floatLightBg, v as valPrefixedClass, c as cn } from './fallbackColors-0d915c59.esm.js';
|
|
14
14
|
import { VAL_THEME_SESSION_STORAGE_KEY, installPageLogInCanvasFrame, isValCanvasFrame } from '@valbuild/shared/client';
|
|
15
15
|
import { _ as _createForOfIteratorHelper } from './createForOfIteratorHelper-9209e9dd.esm.js';
|
|
16
|
-
import { ValCanvasBridge } from './ValCanvasBridge-
|
|
16
|
+
import { ValCanvasBridge } from './ValCanvasBridge-aa626997.esm.js';
|
|
17
17
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
18
18
|
import './unsupportedIterableToArray-f57eb659.esm.js';
|
|
19
19
|
|
|
@@ -17,7 +17,7 @@ var internal = require('@valbuild/react/internal');
|
|
|
17
17
|
var fallbackColors = require('./fallbackColors-38f01ad2.cjs.dev.js');
|
|
18
18
|
var client = require('@valbuild/shared/client');
|
|
19
19
|
var createForOfIteratorHelper = require('./createForOfIteratorHelper-9c6aa3c7.cjs.dev.js');
|
|
20
|
-
var ValCanvasBridge = require('./ValCanvasBridge-
|
|
20
|
+
var ValCanvasBridge = require('./ValCanvasBridge-194bfcc3.cjs.dev.js');
|
|
21
21
|
var jsxRuntime = require('react/jsx-runtime');
|
|
22
22
|
require('./unsupportedIterableToArray-20a9209f.cjs.dev.js');
|
|
23
23
|
|
|
@@ -17,7 +17,7 @@ var internal = require('@valbuild/react/internal');
|
|
|
17
17
|
var fallbackColors = require('./fallbackColors-d9a7b81e.cjs.prod.js');
|
|
18
18
|
var client = require('@valbuild/shared/client');
|
|
19
19
|
var createForOfIteratorHelper = require('./createForOfIteratorHelper-8459fbc7.cjs.prod.js');
|
|
20
|
-
var ValCanvasBridge = require('./ValCanvasBridge-
|
|
20
|
+
var ValCanvasBridge = require('./ValCanvasBridge-cefe83f7.cjs.prod.js');
|
|
21
21
|
var jsxRuntime = require('react/jsx-runtime');
|
|
22
22
|
require('./unsupportedIterableToArray-1aadf9fb.cjs.prod.js');
|
|
23
23
|
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var internal = require('@valbuild/react/internal');
|
|
7
|
+
var navigation = require('next/navigation');
|
|
8
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* EXPERIMENTAL: the preview route's side of its conversation with the Studio.
|
|
12
|
+
* Wrap what `unstable_renderValComponent` returns in it.
|
|
13
|
+
*
|
|
14
|
+
* It keeps the frame as tall as the component, sends a click on content to
|
|
15
|
+
* the Studio so it can open that field, and re-runs the Server Component with
|
|
16
|
+
* the new content (`router.refresh()`) when an edit is made. See
|
|
17
|
+
* `ValPreviewBridgeCore` in `@valbuild/react/internal` for the details.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* // app/val-preview/page.tsx
|
|
21
|
+
* return (
|
|
22
|
+
* <ValPreviewBridge>
|
|
23
|
+
* {await unstable_renderValComponent({ valModules, sourcePath, fetchVal })}
|
|
24
|
+
* </ValPreviewBridge>
|
|
25
|
+
* );
|
|
26
|
+
*/
|
|
27
|
+
function ValPreviewBridge(_ref) {
|
|
28
|
+
var children = _ref.children;
|
|
29
|
+
var router = navigation.useRouter();
|
|
30
|
+
return /*#__PURE__*/jsxRuntime.jsx(internal.ValPreviewBridgeCore, {
|
|
31
|
+
onRefresh: function onRefresh() {
|
|
32
|
+
return router.refresh();
|
|
33
|
+
},
|
|
34
|
+
children: children
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
exports.ValPreviewBridge = ValPreviewBridge;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var internal = require('@valbuild/react/internal');
|
|
7
|
+
var navigation = require('next/navigation');
|
|
8
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* EXPERIMENTAL: the preview route's side of its conversation with the Studio.
|
|
12
|
+
* Wrap what `unstable_renderValComponent` returns in it.
|
|
13
|
+
*
|
|
14
|
+
* It keeps the frame as tall as the component, sends a click on content to
|
|
15
|
+
* the Studio so it can open that field, and re-runs the Server Component with
|
|
16
|
+
* the new content (`router.refresh()`) when an edit is made. See
|
|
17
|
+
* `ValPreviewBridgeCore` in `@valbuild/react/internal` for the details.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* // app/val-preview/page.tsx
|
|
21
|
+
* return (
|
|
22
|
+
* <ValPreviewBridge>
|
|
23
|
+
* {await unstable_renderValComponent({ valModules, sourcePath, fetchVal })}
|
|
24
|
+
* </ValPreviewBridge>
|
|
25
|
+
* );
|
|
26
|
+
*/
|
|
27
|
+
function ValPreviewBridge(_ref) {
|
|
28
|
+
var children = _ref.children;
|
|
29
|
+
var router = navigation.useRouter();
|
|
30
|
+
return /*#__PURE__*/jsxRuntime.jsx(internal.ValPreviewBridgeCore, {
|
|
31
|
+
onRefresh: function onRefresh() {
|
|
32
|
+
return router.refresh();
|
|
33
|
+
},
|
|
34
|
+
children: children
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
exports.ValPreviewBridge = ValPreviewBridge;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { ValPreviewBridgeCore } from '@valbuild/react/internal';
|
|
3
|
+
import { useRouter } from 'next/navigation';
|
|
4
|
+
import { jsx } from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* EXPERIMENTAL: the preview route's side of its conversation with the Studio.
|
|
8
|
+
* Wrap what `unstable_renderValComponent` returns in it.
|
|
9
|
+
*
|
|
10
|
+
* It keeps the frame as tall as the component, sends a click on content to
|
|
11
|
+
* the Studio so it can open that field, and re-runs the Server Component with
|
|
12
|
+
* the new content (`router.refresh()`) when an edit is made. See
|
|
13
|
+
* `ValPreviewBridgeCore` in `@valbuild/react/internal` for the details.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* // app/val-preview/page.tsx
|
|
17
|
+
* return (
|
|
18
|
+
* <ValPreviewBridge>
|
|
19
|
+
* {await unstable_renderValComponent({ valModules, sourcePath, fetchVal })}
|
|
20
|
+
* </ValPreviewBridge>
|
|
21
|
+
* );
|
|
22
|
+
*/
|
|
23
|
+
function ValPreviewBridge(_ref) {
|
|
24
|
+
var children = _ref.children;
|
|
25
|
+
var router = useRouter();
|
|
26
|
+
return /*#__PURE__*/jsx(ValPreviewBridgeCore, {
|
|
27
|
+
onRefresh: function onRefresh() {
|
|
28
|
+
return router.refresh();
|
|
29
|
+
},
|
|
30
|
+
children: children
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export { ValPreviewBridge };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* EXPERIMENTAL: the error UI of the component preview route.
|
|
10
|
+
*
|
|
11
|
+
* Component code is rewritten outside of Val, so a preview will regularly be
|
|
12
|
+
* asked to render code that throws. Without a boundary the route answers 500
|
|
13
|
+
* and the editor sees a blank iframe (and in production, no message at all).
|
|
14
|
+
* This keeps the failure inside the preview, and readable.
|
|
15
|
+
*
|
|
16
|
+
* Use it as the `error.tsx` of the preview route segment:
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* // app/val-preview/error.tsx
|
|
20
|
+
* "use client";
|
|
21
|
+
* export { ValPreviewError as default } from "@valbuild/next";
|
|
22
|
+
*
|
|
23
|
+
* NOTE: this catches errors thrown while rendering. A component that does not
|
|
24
|
+
* compile is a build error, which no React boundary can catch - the app's own
|
|
25
|
+
* build/dev error output is the only thing that can report those.
|
|
26
|
+
*/
|
|
27
|
+
function ValPreviewError(_ref) {
|
|
28
|
+
var _error$digest;
|
|
29
|
+
var error = _ref.error,
|
|
30
|
+
reset = _ref.reset;
|
|
31
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
32
|
+
style: {
|
|
33
|
+
fontFamily: "ui-monospace, monospace",
|
|
34
|
+
fontSize: "13px",
|
|
35
|
+
lineHeight: 1.5,
|
|
36
|
+
padding: "1rem",
|
|
37
|
+
display: "grid",
|
|
38
|
+
gap: "0.75rem",
|
|
39
|
+
justifyItems: "start"
|
|
40
|
+
},
|
|
41
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("strong", {
|
|
42
|
+
children: "This component threw while rendering."
|
|
43
|
+
}), /*#__PURE__*/jsxRuntime.jsx("pre", {
|
|
44
|
+
style: {
|
|
45
|
+
margin: 0,
|
|
46
|
+
whiteSpace: "pre-wrap",
|
|
47
|
+
wordBreak: "break-word",
|
|
48
|
+
maxWidth: "100%"
|
|
49
|
+
},
|
|
50
|
+
children: error.message || "Error digest: ".concat((_error$digest = error.digest) !== null && _error$digest !== void 0 ? _error$digest : "unknown")
|
|
51
|
+
}), /*#__PURE__*/jsxRuntime.jsx("button", {
|
|
52
|
+
type: "button",
|
|
53
|
+
onClick: reset,
|
|
54
|
+
children: "Try again"
|
|
55
|
+
})]
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
exports.ValPreviewError = ValPreviewError;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* EXPERIMENTAL: the error UI of the component preview route.
|
|
6
|
+
*
|
|
7
|
+
* Component code is rewritten outside of Val, so a preview will regularly be
|
|
8
|
+
* asked to render code that throws. Without a boundary the route answers 500
|
|
9
|
+
* and the editor sees a blank iframe (and in production, no message at all).
|
|
10
|
+
* This keeps the failure inside the preview, and readable.
|
|
11
|
+
*
|
|
12
|
+
* Use it as the `error.tsx` of the preview route segment:
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* // app/val-preview/error.tsx
|
|
16
|
+
* "use client";
|
|
17
|
+
* export { ValPreviewError as default } from "@valbuild/next";
|
|
18
|
+
*
|
|
19
|
+
* NOTE: this catches errors thrown while rendering. A component that does not
|
|
20
|
+
* compile is a build error, which no React boundary can catch - the app's own
|
|
21
|
+
* build/dev error output is the only thing that can report those.
|
|
22
|
+
*/
|
|
23
|
+
function ValPreviewError(_ref) {
|
|
24
|
+
var _error$digest;
|
|
25
|
+
var error = _ref.error,
|
|
26
|
+
reset = _ref.reset;
|
|
27
|
+
return /*#__PURE__*/jsxs("div", {
|
|
28
|
+
style: {
|
|
29
|
+
fontFamily: "ui-monospace, monospace",
|
|
30
|
+
fontSize: "13px",
|
|
31
|
+
lineHeight: 1.5,
|
|
32
|
+
padding: "1rem",
|
|
33
|
+
display: "grid",
|
|
34
|
+
gap: "0.75rem",
|
|
35
|
+
justifyItems: "start"
|
|
36
|
+
},
|
|
37
|
+
children: [/*#__PURE__*/jsx("strong", {
|
|
38
|
+
children: "This component threw while rendering."
|
|
39
|
+
}), /*#__PURE__*/jsx("pre", {
|
|
40
|
+
style: {
|
|
41
|
+
margin: 0,
|
|
42
|
+
whiteSpace: "pre-wrap",
|
|
43
|
+
wordBreak: "break-word",
|
|
44
|
+
maxWidth: "100%"
|
|
45
|
+
},
|
|
46
|
+
children: error.message || "Error digest: ".concat((_error$digest = error.digest) !== null && _error$digest !== void 0 ? _error$digest : "unknown")
|
|
47
|
+
}), /*#__PURE__*/jsx("button", {
|
|
48
|
+
type: "button",
|
|
49
|
+
onClick: reset,
|
|
50
|
+
children: "Try again"
|
|
51
|
+
})]
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export { ValPreviewError };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* EXPERIMENTAL: the error UI of the component preview route.
|
|
10
|
+
*
|
|
11
|
+
* Component code is rewritten outside of Val, so a preview will regularly be
|
|
12
|
+
* asked to render code that throws. Without a boundary the route answers 500
|
|
13
|
+
* and the editor sees a blank iframe (and in production, no message at all).
|
|
14
|
+
* This keeps the failure inside the preview, and readable.
|
|
15
|
+
*
|
|
16
|
+
* Use it as the `error.tsx` of the preview route segment:
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* // app/val-preview/error.tsx
|
|
20
|
+
* "use client";
|
|
21
|
+
* export { ValPreviewError as default } from "@valbuild/next";
|
|
22
|
+
*
|
|
23
|
+
* NOTE: this catches errors thrown while rendering. A component that does not
|
|
24
|
+
* compile is a build error, which no React boundary can catch - the app's own
|
|
25
|
+
* build/dev error output is the only thing that can report those.
|
|
26
|
+
*/
|
|
27
|
+
function ValPreviewError(_ref) {
|
|
28
|
+
var _error$digest;
|
|
29
|
+
var error = _ref.error,
|
|
30
|
+
reset = _ref.reset;
|
|
31
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
32
|
+
style: {
|
|
33
|
+
fontFamily: "ui-monospace, monospace",
|
|
34
|
+
fontSize: "13px",
|
|
35
|
+
lineHeight: 1.5,
|
|
36
|
+
padding: "1rem",
|
|
37
|
+
display: "grid",
|
|
38
|
+
gap: "0.75rem",
|
|
39
|
+
justifyItems: "start"
|
|
40
|
+
},
|
|
41
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("strong", {
|
|
42
|
+
children: "This component threw while rendering."
|
|
43
|
+
}), /*#__PURE__*/jsxRuntime.jsx("pre", {
|
|
44
|
+
style: {
|
|
45
|
+
margin: 0,
|
|
46
|
+
whiteSpace: "pre-wrap",
|
|
47
|
+
wordBreak: "break-word",
|
|
48
|
+
maxWidth: "100%"
|
|
49
|
+
},
|
|
50
|
+
children: error.message || "Error digest: ".concat((_error$digest = error.digest) !== null && _error$digest !== void 0 ? _error$digest : "unknown")
|
|
51
|
+
}), /*#__PURE__*/jsxRuntime.jsx("button", {
|
|
52
|
+
type: "button",
|
|
53
|
+
onClick: reset,
|
|
54
|
+
children: "Try again"
|
|
55
|
+
})]
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
exports.ValPreviewError = ValPreviewError;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { ReactElement } from "react";
|
|
2
|
+
import type { SelectorSource, ValModule, ValModules } from "@valbuild/core";
|
|
3
|
+
export type ValComponentPreviewOptions = {
|
|
4
|
+
/** The app's `val.modules` registry (the default export of val.modules.ts). */
|
|
5
|
+
valModules: ValModules;
|
|
6
|
+
/**
|
|
7
|
+
* Source path of the value to render, e.g.
|
|
8
|
+
* `/content/pages.val.ts?p="landing"."sections".0`.
|
|
9
|
+
*
|
|
10
|
+
* The schema at this path says which component renders it: an object with
|
|
11
|
+
* `.component(() => import(...))`, or a discriminated union whose
|
|
12
|
+
* variant at this path is one.
|
|
13
|
+
*/
|
|
14
|
+
sourcePath: string;
|
|
15
|
+
/**
|
|
16
|
+
* Render the `example` of the render instead of the content at `sourcePath`.
|
|
17
|
+
*/
|
|
18
|
+
example?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Props to render with, overriding both the content and the example. For
|
|
21
|
+
* trying out values without changing any content.
|
|
22
|
+
*
|
|
23
|
+
* Converted the way content is (an image source gains its `url`), so they
|
|
24
|
+
* are written as SOURCE, the same shape as in a `.val.ts`.
|
|
25
|
+
*/
|
|
26
|
+
props?: unknown;
|
|
27
|
+
/**
|
|
28
|
+
* The app's own `fetchVal` (from `initValRsc`).
|
|
29
|
+
*
|
|
30
|
+
* Passed in rather than created here because it is bound to the app's config
|
|
31
|
+
* and to the Next.js `headers` / `cookies` / `draftMode` of the app.
|
|
32
|
+
*/
|
|
33
|
+
fetchVal: (module: ValModule<SelectorSource>) => Promise<unknown>;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* EXPERIMENTAL: renders the value at a source path with the component its
|
|
37
|
+
* schema declares - `s.object(...).component(() => import(...))`.
|
|
38
|
+
*
|
|
39
|
+
* Meant to be called from a Server Component behind a route that the Val UI
|
|
40
|
+
* loads in an iframe, so an editor sees the section they are editing, rendered
|
|
41
|
+
* by the app itself: its own React, CSS, fonts and providers.
|
|
42
|
+
*
|
|
43
|
+
* This is a plain async function rather than a component because React 18
|
|
44
|
+
* types do not allow async components in JSX. Call it and return the result:
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* // app/val-preview/page.tsx
|
|
48
|
+
* export default async function ValPreviewPage({ searchParams }) {
|
|
49
|
+
* const { p, example } = await searchParams;
|
|
50
|
+
* return unstable_renderValComponent({
|
|
51
|
+
* valModules,
|
|
52
|
+
* sourcePath: p,
|
|
53
|
+
* example: example === "1",
|
|
54
|
+
* fetchVal,
|
|
55
|
+
* });
|
|
56
|
+
* }
|
|
57
|
+
*/
|
|
58
|
+
export declare function unstable_renderValComponent({ valModules, sourcePath, example, props, fetchVal, }: ValComponentPreviewOptions): Promise<ReactElement>;
|