@valbuild/next 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 (35) hide show
  1. package/CHANGELOG.md +66 -0
  2. package/dist/{ValCanvasBridge-85e75bdb.cjs.dev.js → ValCanvasBridge-194bfcc3.cjs.dev.js} +21 -2
  3. package/dist/{ValCanvasBridge-d18c2be6.esm.js → ValCanvasBridge-aa626997.esm.js} +22 -3
  4. package/dist/ValCanvasBridge-cefe83f7.cjs.js +7 -0
  5. package/dist/{ValCanvasBridge-fc476670.cjs.prod.js → ValCanvasBridge-cefe83f7.cjs.prod.js} +21 -2
  6. package/dist/ValNextProvider-27242758.esm.js +1 -1
  7. package/dist/ValNextProvider-4838fed0.cjs.dev.js +1 -1
  8. package/dist/ValNextProvider-9343dc1e.cjs.prod.js +1 -1
  9. package/dist/ValPreviewBridge-2d09c5a9.cjs.dev.js +38 -0
  10. package/dist/ValPreviewBridge-81f717c7.cjs.js +7 -0
  11. package/dist/ValPreviewBridge-81f717c7.cjs.prod.js +38 -0
  12. package/dist/ValPreviewBridge-c635208d.esm.js +34 -0
  13. package/dist/ValPreviewError-137b27f8.cjs.dev.js +59 -0
  14. package/dist/ValPreviewError-37a42fdf.esm.js +55 -0
  15. package/dist/ValPreviewError-cc0aef49.cjs.js +7 -0
  16. package/dist/ValPreviewError-cc0aef49.cjs.prod.js +59 -0
  17. package/dist/declarations/src/ValComponentPreview.d.ts +58 -0
  18. package/dist/declarations/src/ValPreviewBridge.d.ts +21 -0
  19. package/dist/declarations/src/ValPreviewError.d.ts +25 -0
  20. package/dist/declarations/src/external_exempt_from_val_quickjs.d.ts +4 -0
  21. package/dist/declarations/src/rsc/initValRsc.d.ts +4 -4
  22. package/dist/valbuild-next.cjs.dev.js +96 -1
  23. package/dist/valbuild-next.cjs.prod.js +96 -1
  24. package/dist/valbuild-next.esm.js +86 -3
  25. package/dist/{version-d945c1eb.esm.js → version-281feaf7.esm.js} +1 -1
  26. package/dist/{version-2a0df4d8.cjs.dev.js → version-c40f4d2d.cjs.prod.js} +1 -1
  27. package/dist/{version-48aba9c6.cjs.prod.js → version-f62ea496.cjs.dev.js} +1 -1
  28. package/package.json +8 -8
  29. package/rsc/dist/valbuild-next-rsc.cjs.dev.js +30 -21
  30. package/rsc/dist/valbuild-next-rsc.cjs.prod.js +30 -21
  31. package/rsc/dist/valbuild-next-rsc.esm.js +20 -11
  32. package/server/dist/valbuild-next-server.cjs.dev.js +1 -1
  33. package/server/dist/valbuild-next-server.cjs.prod.js +1 -1
  34. package/server/dist/valbuild-next-server.esm.js +1 -1
  35. package/dist/ValCanvasBridge-fc476670.cjs.js +0 -7
@@ -0,0 +1,21 @@
1
+ import type { ReactNode } from "react";
2
+ /**
3
+ * EXPERIMENTAL: the preview route's side of its conversation with the Studio.
4
+ * Wrap what `unstable_renderValComponent` returns in it.
5
+ *
6
+ * It keeps the frame as tall as the component, sends a click on content to
7
+ * the Studio so it can open that field, and re-runs the Server Component with
8
+ * the new content (`router.refresh()`) when an edit is made. See
9
+ * `ValPreviewBridgeCore` in `@valbuild/react/internal` for the details.
10
+ *
11
+ * @example
12
+ * // app/val-preview/page.tsx
13
+ * return (
14
+ * <ValPreviewBridge>
15
+ * {await unstable_renderValComponent({ valModules, sourcePath, fetchVal })}
16
+ * </ValPreviewBridge>
17
+ * );
18
+ */
19
+ export declare function ValPreviewBridge({ children }: {
20
+ children: ReactNode;
21
+ }): import("react").JSX.Element;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * EXPERIMENTAL: the error UI of the component preview route.
3
+ *
4
+ * Component code is rewritten outside of Val, so a preview will regularly be
5
+ * asked to render code that throws. Without a boundary the route answers 500
6
+ * and the editor sees a blank iframe (and in production, no message at all).
7
+ * This keeps the failure inside the preview, and readable.
8
+ *
9
+ * Use it as the `error.tsx` of the preview route segment:
10
+ *
11
+ * @example
12
+ * // app/val-preview/error.tsx
13
+ * "use client";
14
+ * export { ValPreviewError as default } from "@valbuild/next";
15
+ *
16
+ * NOTE: this catches errors thrown while rendering. A component that does not
17
+ * compile is a build error, which no React boundary can catch - the app's own
18
+ * build/dev error output is the only thing that can report those.
19
+ */
20
+ export declare function ValPreviewError({ error, reset, }: {
21
+ error: Error & {
22
+ digest?: string;
23
+ };
24
+ reset: () => void;
25
+ }): import("react").JSX.Element;
@@ -20,6 +20,10 @@ export { ValImage, type ValImageProps } from "./ValImage.js";
20
20
  export { ValVideo, type ValVideoProps } from "./ValVideo.js";
21
21
  export { ValApp } from "./ValApp.js";
22
22
  export { ValModulesClient, useRegisterValModules } from "./ValModulesClient.js";
23
+ export { unstable_renderValComponent, type ValComponentPreviewOptions, } from "./ValComponentPreview.js";
24
+ export { ValPreviewBridge } from "./ValPreviewBridge.js";
25
+ export { ValComponentEditor, type ValComponentEditorProps, } from "@valbuild/react/internal";
26
+ export { ValPreviewError } from "./ValPreviewError.js";
23
27
  import { Internal as InternalCore } from "@valbuild/core";
24
28
  import { VERSION } from "./version.js";
25
29
  export type * as t from "./ValTypes.js";
@@ -2,13 +2,14 @@ import { type JsonEntryContentOf, type Resolvable, type ResolvedVal, type RouteV
2
2
  import { type ValDraft } from "@valbuild/react/internal";
3
3
  import { ValConfig, ValModules, type ResolvableModule } from "@valbuild/core";
4
4
  import { cookies, draftMode, headers } from "next/headers";
5
- import { type ValRuntime } from "@valbuild/server/internal";
5
+ import { type ReaderRuntime } from "@valbuild/server/internal";
6
6
  /**
7
7
  * What the readers read: this process's runtime for the app's `val.modules`
8
8
  * (`createValRuntime`), the same one the API route's server is built on.
9
- * Its head is the draft, read with the request's session.
9
+ * Its head is the draft, read with the request's session. Asked for by the
10
+ * first draft read, never by a visitor's.
10
11
  */
11
- export type ReaderRuntime = Promise<ValRuntime>;
12
+ export type { ReaderRuntime };
12
13
  /** What a reader needs from the app and the request. */
13
14
  export type ReaderDeps = {
14
15
  runtime: ReaderRuntime;
@@ -78,4 +79,3 @@ export declare function initValRsc(config: ValConfig, valModules: ValModules, rs
78
79
  */
79
80
  fetchValDraft: ReturnType<typeof initFetchValDraft>;
80
81
  };
81
- export {};
@@ -14,7 +14,9 @@ var jsxRuntime = require('react/jsx-runtime');
14
14
  var ValVideo = require('./ValVideo-15e5c4fa.cjs.dev.js');
15
15
  var ValApp = require('./ValApp-826dca6c.cjs.dev.js');
16
16
  var ValModulesClient = require('./ValModulesClient-4ecabf99.cjs.dev.js');
17
- var version = require('./version-2a0df4d8.cjs.dev.js');
17
+ var ValPreviewBridge = require('./ValPreviewBridge-2d09c5a9.cjs.dev.js');
18
+ var ValPreviewError = require('./ValPreviewError-137b27f8.cjs.dev.js');
19
+ var version = require('./version-f62ea496.cjs.dev.js');
18
20
  var createForOfIteratorHelper = require('./createForOfIteratorHelper-9c6aa3c7.cjs.dev.js');
19
21
  require('./unsupportedIterableToArray-20a9209f.cjs.dev.js');
20
22
 
@@ -169,6 +171,86 @@ function ValImage(props) {
169
171
  }));
170
172
  }
171
173
 
174
+ /**
175
+ * EXPERIMENTAL: renders the value at a source path with the component its
176
+ * schema declares - `s.object(...).component(() => import(...))`.
177
+ *
178
+ * Meant to be called from a Server Component behind a route that the Val UI
179
+ * loads in an iframe, so an editor sees the section they are editing, rendered
180
+ * by the app itself: its own React, CSS, fonts and providers.
181
+ *
182
+ * This is a plain async function rather than a component because React 18
183
+ * types do not allow async components in JSX. Call it and return the result:
184
+ *
185
+ * @example
186
+ * // app/val-preview/page.tsx
187
+ * export default async function ValPreviewPage({ searchParams }) {
188
+ * const { p, example } = await searchParams;
189
+ * return unstable_renderValComponent({
190
+ * valModules,
191
+ * sourcePath: p,
192
+ * example: example === "1",
193
+ * fetchVal,
194
+ * });
195
+ * }
196
+ */
197
+ function unstable_renderValComponent(_x) {
198
+ return _unstable_renderValComponent.apply(this, arguments);
199
+ }
200
+ function _unstable_renderValComponent() {
201
+ _unstable_renderValComponent = asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regenerator().m(function _callee(_ref) {
202
+ var valModules, sourcePath, example, props, fetchVal, valModule, resolution, Component, _t, _t2, _t3, _t4, _t5, _t6;
203
+ return asyncToGenerator._regenerator().w(function (_context) {
204
+ while (1) switch (_context.n) {
205
+ case 0:
206
+ valModules = _ref.valModules, sourcePath = _ref.sourcePath, example = _ref.example, props = _ref.props, fetchVal = _ref.fetchVal;
207
+ _context.n = 1;
208
+ return internal.findValModule(valModules, sourcePath);
209
+ case 1:
210
+ valModule = _context.v;
211
+ if (valModule) {
212
+ _context.n = 2;
213
+ break;
214
+ }
215
+ return _context.a(2, /*#__PURE__*/jsxRuntime.jsx(internal.ValPreviewMessage, {
216
+ children: "No module for '".concat(sourcePath, "' in val.modules.")
217
+ }));
218
+ case 2:
219
+ _t = internal.resolveValComponentPreview;
220
+ _t2 = valModule;
221
+ _t3 = sourcePath;
222
+ _context.n = 3;
223
+ return fetchVal(valModule);
224
+ case 3:
225
+ _t4 = _context.v;
226
+ _t5 = example;
227
+ _t6 = props;
228
+ _context.n = 4;
229
+ return _t({
230
+ valModule: _t2,
231
+ sourcePath: _t3,
232
+ moduleValue: _t4,
233
+ example: _t5,
234
+ props: _t6
235
+ });
236
+ case 4:
237
+ resolution = _context.v;
238
+ if (!(resolution.status === "error")) {
239
+ _context.n = 5;
240
+ break;
241
+ }
242
+ return _context.a(2, /*#__PURE__*/jsxRuntime.jsx(internal.ValPreviewMessage, {
243
+ children: resolution.message
244
+ }));
245
+ case 5:
246
+ Component = resolution.Component;
247
+ return _context.a(2, /*#__PURE__*/jsxRuntime.jsx(Component, objectSpread2._objectSpread2({}, resolution.props)));
248
+ }
249
+ }, _callee);
250
+ }));
251
+ return _unstable_renderValComponent.apply(this, arguments);
252
+ }
253
+
172
254
  // NOTE! Side effects:
173
255
  stega.autoTagJSX();
174
256
 
@@ -213,6 +295,10 @@ Object.defineProperty(exports, 'modules', {
213
295
  enumerable: true,
214
296
  get: function () { return core.modules; }
215
297
  });
298
+ Object.defineProperty(exports, 'ValComponentEditor', {
299
+ enumerable: true,
300
+ get: function () { return internal.ValComponentEditor; }
301
+ });
216
302
  Object.defineProperty(exports, 'ValRichText', {
217
303
  enumerable: true,
218
304
  get: function () { return internal.ValRichText; }
@@ -233,7 +319,16 @@ Object.defineProperty(exports, 'useRegisterValModules', {
233
319
  enumerable: true,
234
320
  get: function () { return ValModulesClient.useRegisterValModules; }
235
321
  });
322
+ Object.defineProperty(exports, 'ValPreviewBridge', {
323
+ enumerable: true,
324
+ get: function () { return ValPreviewBridge.ValPreviewBridge; }
325
+ });
326
+ Object.defineProperty(exports, 'ValPreviewError', {
327
+ enumerable: true,
328
+ get: function () { return ValPreviewError.ValPreviewError; }
329
+ });
236
330
  exports.Internal = Internal;
237
331
  exports.ValImage = ValImage;
238
332
  exports.ValProvider = ValProvider;
239
333
  exports.initVal = initVal;
334
+ exports.unstable_renderValComponent = unstable_renderValComponent;
@@ -14,7 +14,9 @@ var jsxRuntime = require('react/jsx-runtime');
14
14
  var ValVideo = require('./ValVideo-02f43a7c.cjs.prod.js');
15
15
  var ValApp = require('./ValApp-866089f6.cjs.prod.js');
16
16
  var ValModulesClient = require('./ValModulesClient-10c0721c.cjs.prod.js');
17
- var version = require('./version-48aba9c6.cjs.prod.js');
17
+ var ValPreviewBridge = require('./ValPreviewBridge-81f717c7.cjs.prod.js');
18
+ var ValPreviewError = require('./ValPreviewError-cc0aef49.cjs.prod.js');
19
+ var version = require('./version-c40f4d2d.cjs.prod.js');
18
20
  var createForOfIteratorHelper = require('./createForOfIteratorHelper-8459fbc7.cjs.prod.js');
19
21
  require('./unsupportedIterableToArray-1aadf9fb.cjs.prod.js');
20
22
 
@@ -169,6 +171,86 @@ function ValImage(props) {
169
171
  }));
170
172
  }
171
173
 
174
+ /**
175
+ * EXPERIMENTAL: renders the value at a source path with the component its
176
+ * schema declares - `s.object(...).component(() => import(...))`.
177
+ *
178
+ * Meant to be called from a Server Component behind a route that the Val UI
179
+ * loads in an iframe, so an editor sees the section they are editing, rendered
180
+ * by the app itself: its own React, CSS, fonts and providers.
181
+ *
182
+ * This is a plain async function rather than a component because React 18
183
+ * types do not allow async components in JSX. Call it and return the result:
184
+ *
185
+ * @example
186
+ * // app/val-preview/page.tsx
187
+ * export default async function ValPreviewPage({ searchParams }) {
188
+ * const { p, example } = await searchParams;
189
+ * return unstable_renderValComponent({
190
+ * valModules,
191
+ * sourcePath: p,
192
+ * example: example === "1",
193
+ * fetchVal,
194
+ * });
195
+ * }
196
+ */
197
+ function unstable_renderValComponent(_x) {
198
+ return _unstable_renderValComponent.apply(this, arguments);
199
+ }
200
+ function _unstable_renderValComponent() {
201
+ _unstable_renderValComponent = asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regenerator().m(function _callee(_ref) {
202
+ var valModules, sourcePath, example, props, fetchVal, valModule, resolution, Component, _t, _t2, _t3, _t4, _t5, _t6;
203
+ return asyncToGenerator._regenerator().w(function (_context) {
204
+ while (1) switch (_context.n) {
205
+ case 0:
206
+ valModules = _ref.valModules, sourcePath = _ref.sourcePath, example = _ref.example, props = _ref.props, fetchVal = _ref.fetchVal;
207
+ _context.n = 1;
208
+ return internal.findValModule(valModules, sourcePath);
209
+ case 1:
210
+ valModule = _context.v;
211
+ if (valModule) {
212
+ _context.n = 2;
213
+ break;
214
+ }
215
+ return _context.a(2, /*#__PURE__*/jsxRuntime.jsx(internal.ValPreviewMessage, {
216
+ children: "No module for '".concat(sourcePath, "' in val.modules.")
217
+ }));
218
+ case 2:
219
+ _t = internal.resolveValComponentPreview;
220
+ _t2 = valModule;
221
+ _t3 = sourcePath;
222
+ _context.n = 3;
223
+ return fetchVal(valModule);
224
+ case 3:
225
+ _t4 = _context.v;
226
+ _t5 = example;
227
+ _t6 = props;
228
+ _context.n = 4;
229
+ return _t({
230
+ valModule: _t2,
231
+ sourcePath: _t3,
232
+ moduleValue: _t4,
233
+ example: _t5,
234
+ props: _t6
235
+ });
236
+ case 4:
237
+ resolution = _context.v;
238
+ if (!(resolution.status === "error")) {
239
+ _context.n = 5;
240
+ break;
241
+ }
242
+ return _context.a(2, /*#__PURE__*/jsxRuntime.jsx(internal.ValPreviewMessage, {
243
+ children: resolution.message
244
+ }));
245
+ case 5:
246
+ Component = resolution.Component;
247
+ return _context.a(2, /*#__PURE__*/jsxRuntime.jsx(Component, objectSpread2._objectSpread2({}, resolution.props)));
248
+ }
249
+ }, _callee);
250
+ }));
251
+ return _unstable_renderValComponent.apply(this, arguments);
252
+ }
253
+
172
254
  // NOTE! Side effects:
173
255
  stega.autoTagJSX();
174
256
 
@@ -213,6 +295,10 @@ Object.defineProperty(exports, 'modules', {
213
295
  enumerable: true,
214
296
  get: function () { return core.modules; }
215
297
  });
298
+ Object.defineProperty(exports, 'ValComponentEditor', {
299
+ enumerable: true,
300
+ get: function () { return internal.ValComponentEditor; }
301
+ });
216
302
  Object.defineProperty(exports, 'ValRichText', {
217
303
  enumerable: true,
218
304
  get: function () { return internal.ValRichText; }
@@ -233,7 +319,16 @@ Object.defineProperty(exports, 'useRegisterValModules', {
233
319
  enumerable: true,
234
320
  get: function () { return ValModulesClient.useRegisterValModules; }
235
321
  });
322
+ Object.defineProperty(exports, 'ValPreviewBridge', {
323
+ enumerable: true,
324
+ get: function () { return ValPreviewBridge.ValPreviewBridge; }
325
+ });
326
+ Object.defineProperty(exports, 'ValPreviewError', {
327
+ enumerable: true,
328
+ get: function () { return ValPreviewError.ValPreviewError; }
329
+ });
236
330
  exports.Internal = Internal;
237
331
  exports.ValImage = ValImage;
238
332
  exports.ValProvider = ValProvider;
239
333
  exports.initVal = initVal;
334
+ exports.unstable_renderValComponent = unstable_renderValComponent;
@@ -6,14 +6,17 @@ export { core as expr };
6
6
  export { GenericSelector, Schema, VAL_EXTENSION, derefPatch, modules } from '@valbuild/core';
7
7
  import { stegaEncode, attrs, raw, autoTagJSX } from '@valbuild/react/stega';
8
8
  import { d as decodeValPathsOfString, _ as _objectWithoutProperties } from './objectWithoutProperties-2daec22c.esm.js';
9
- export { ValRichText } from '@valbuild/react/internal';
9
+ import { ValPreviewMessage, resolveValComponentPreview, findValModule } from '@valbuild/react/internal';
10
+ export { ValComponentEditor, ValRichText } from '@valbuild/react/internal';
10
11
  import { ValNextProvider } from './ValNextProvider-27242758.esm.js';
11
12
  import NextImage from 'next/image';
12
13
  import { jsx } from 'react/jsx-runtime';
13
14
  export { ValVideo } from './ValVideo-8acf31b6.esm.js';
14
15
  export { ValApp } from './ValApp-69cd599c.esm.js';
15
16
  export { ValModulesClient, useRegisterValModules } from './ValModulesClient-0dd601a1.esm.js';
16
- import { V as VERSION } from './version-d945c1eb.esm.js';
17
+ export { ValPreviewBridge } from './ValPreviewBridge-c635208d.esm.js';
18
+ export { ValPreviewError } from './ValPreviewError-37a42fdf.esm.js';
19
+ import { V as VERSION } from './version-281feaf7.esm.js';
17
20
  import { _ as _createForOfIteratorHelper } from './createForOfIteratorHelper-9209e9dd.esm.js';
18
21
  import './unsupportedIterableToArray-f57eb659.esm.js';
19
22
 
@@ -145,6 +148,86 @@ function ValImage(props) {
145
148
  }));
146
149
  }
147
150
 
151
+ /**
152
+ * EXPERIMENTAL: renders the value at a source path with the component its
153
+ * schema declares - `s.object(...).component(() => import(...))`.
154
+ *
155
+ * Meant to be called from a Server Component behind a route that the Val UI
156
+ * loads in an iframe, so an editor sees the section they are editing, rendered
157
+ * by the app itself: its own React, CSS, fonts and providers.
158
+ *
159
+ * This is a plain async function rather than a component because React 18
160
+ * types do not allow async components in JSX. Call it and return the result:
161
+ *
162
+ * @example
163
+ * // app/val-preview/page.tsx
164
+ * export default async function ValPreviewPage({ searchParams }) {
165
+ * const { p, example } = await searchParams;
166
+ * return unstable_renderValComponent({
167
+ * valModules,
168
+ * sourcePath: p,
169
+ * example: example === "1",
170
+ * fetchVal,
171
+ * });
172
+ * }
173
+ */
174
+ function unstable_renderValComponent(_x) {
175
+ return _unstable_renderValComponent.apply(this, arguments);
176
+ }
177
+ function _unstable_renderValComponent() {
178
+ _unstable_renderValComponent = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
179
+ var valModules, sourcePath, example, props, fetchVal, valModule, resolution, Component, _t, _t2, _t3, _t4, _t5, _t6;
180
+ return _regenerator().w(function (_context) {
181
+ while (1) switch (_context.n) {
182
+ case 0:
183
+ valModules = _ref.valModules, sourcePath = _ref.sourcePath, example = _ref.example, props = _ref.props, fetchVal = _ref.fetchVal;
184
+ _context.n = 1;
185
+ return findValModule(valModules, sourcePath);
186
+ case 1:
187
+ valModule = _context.v;
188
+ if (valModule) {
189
+ _context.n = 2;
190
+ break;
191
+ }
192
+ return _context.a(2, /*#__PURE__*/jsx(ValPreviewMessage, {
193
+ children: "No module for '".concat(sourcePath, "' in val.modules.")
194
+ }));
195
+ case 2:
196
+ _t = resolveValComponentPreview;
197
+ _t2 = valModule;
198
+ _t3 = sourcePath;
199
+ _context.n = 3;
200
+ return fetchVal(valModule);
201
+ case 3:
202
+ _t4 = _context.v;
203
+ _t5 = example;
204
+ _t6 = props;
205
+ _context.n = 4;
206
+ return _t({
207
+ valModule: _t2,
208
+ sourcePath: _t3,
209
+ moduleValue: _t4,
210
+ example: _t5,
211
+ props: _t6
212
+ });
213
+ case 4:
214
+ resolution = _context.v;
215
+ if (!(resolution.status === "error")) {
216
+ _context.n = 5;
217
+ break;
218
+ }
219
+ return _context.a(2, /*#__PURE__*/jsx(ValPreviewMessage, {
220
+ children: resolution.message
221
+ }));
222
+ case 5:
223
+ Component = resolution.Component;
224
+ return _context.a(2, /*#__PURE__*/jsx(Component, _objectSpread2({}, resolution.props)));
225
+ }
226
+ }, _callee);
227
+ }));
228
+ return _unstable_renderValComponent.apply(this, arguments);
229
+ }
230
+
148
231
  // NOTE! Side effects:
149
232
  autoTagJSX();
150
233
 
@@ -168,4 +251,4 @@ var Internal = _objectSpread2(_objectSpread2({}, Internal$1), {}, {
168
251
  })
169
252
  });
170
253
 
171
- export { Internal, ValImage, ValProvider, initVal };
254
+ export { Internal, ValImage, ValProvider, initVal, unstable_renderValComponent };
@@ -12,7 +12,7 @@ var packageJson = {
12
12
  "next",
13
13
  "react"
14
14
  ],
15
- version: "0.154.1",
15
+ version: "0.154.2",
16
16
  scripts: {
17
17
  typecheck: "tsc --noEmit",
18
18
  test: "jest"
@@ -14,7 +14,7 @@ var packageJson = {
14
14
  "next",
15
15
  "react"
16
16
  ],
17
- version: "0.154.1",
17
+ version: "0.154.2",
18
18
  scripts: {
19
19
  typecheck: "tsc --noEmit",
20
20
  test: "jest"
@@ -14,7 +14,7 @@ var packageJson = {
14
14
  "next",
15
15
  "react"
16
16
  ],
17
- version: "0.154.1",
17
+ version: "0.154.2",
18
18
  scripts: {
19
19
  typecheck: "tsc --noEmit",
20
20
  test: "jest"
package/package.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "next",
13
13
  "react"
14
14
  ],
15
- "version": "0.154.1",
15
+ "version": "0.154.2",
16
16
  "main": "dist/valbuild-next.cjs.js",
17
17
  "module": "dist/valbuild-next.esm.js",
18
18
  "exports": {
@@ -47,13 +47,13 @@
47
47
  "dependencies": {
48
48
  "client-only": "^0.0.1",
49
49
  "server-only": "^0.0.1",
50
- "@valbuild/core": "0.153.5",
51
- "@valbuild/language-server": "0.154.1",
52
- "@valbuild/mcp": "0.154.1",
53
- "@valbuild/react": "0.154.1",
54
- "@valbuild/server": "0.154.1",
55
- "@valbuild/shared": "0.154.1",
56
- "@valbuild/ui": "0.154.1"
50
+ "@valbuild/core": "0.154.2",
51
+ "@valbuild/mcp": "0.154.2",
52
+ "@valbuild/language-server": "0.154.2",
53
+ "@valbuild/react": "0.154.2",
54
+ "@valbuild/server": "0.154.2",
55
+ "@valbuild/shared": "0.154.2",
56
+ "@valbuild/ui": "0.154.2"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@testing-library/react": "^16.3.3",
@@ -6,11 +6,11 @@ require('server-only');
6
6
  var asyncToGenerator = require('../../dist/asyncToGenerator-c3823d62.cjs.dev.js');
7
7
  var objectSpread2 = require('../../dist/objectSpread2-58726b14.cjs.dev.js');
8
8
  var stega = require('@valbuild/react/stega');
9
- var internal$1 = require('@valbuild/react/internal');
9
+ var internal = require('@valbuild/react/internal');
10
10
  var core = require('@valbuild/core');
11
11
  var internal$2 = require('@valbuild/shared/internal');
12
- var internal = require('@valbuild/server/internal');
13
- var version = require('../../dist/version-2a0df4d8.cjs.dev.js');
12
+ var internal$1 = require('@valbuild/server/internal');
13
+ var version = require('../../dist/version-f62ea496.cjs.dev.js');
14
14
  var routeFromVal = require('../../dist/routeFromVal-a1e0a8be.cjs.dev.js');
15
15
  require('../../dist/createForOfIteratorHelper-9c6aa3c7.cjs.dev.js');
16
16
  require('../../dist/unsupportedIterableToArray-20a9209f.cjs.dev.js');
@@ -30,7 +30,8 @@ stega.SET_RSC(true);
30
30
  /**
31
31
  * What the readers read: this process's runtime for the app's `val.modules`
32
32
  * (`createValRuntime`), the same one the API route's server is built on.
33
- * Its head is the draft, read with the request's session.
33
+ * Its head is the draft, read with the request's session. Asked for by the
34
+ * first draft read, never by a visitor's.
34
35
  */
35
36
 
36
37
  /** What a misuse of a reader is told, beside what went wrong. */
@@ -63,7 +64,7 @@ function fetchValWithReads(deps) {
63
64
  while (1) switch (_context.n) {
64
65
  case 0:
65
66
  _context.n = 1;
66
- return internal.draftForRequest({
67
+ return internal$1.draftForRequest({
67
68
  runtime: deps.runtime,
68
69
  isEnabled: deps.isEnabled,
69
70
  getCookies: deps.getCookies,
@@ -77,8 +78,8 @@ function fetchValWithReads(deps) {
77
78
  enabled = _yield$draftForReques.enabled;
78
79
  draft = _yield$draftForReques.draft;
79
80
  env = requestEnv(enabled, draft);
80
- return _context.a(2, internal$1.awaitResolved(function (settled) {
81
- return internal$1.resolveVal(selector, env, objectSpread2._objectSpread2({
81
+ return _context.a(2, internal.awaitResolved(function (settled) {
82
+ return internal.resolveVal(selector, env, objectSpread2._objectSpread2({
82
83
  settled: settled
83
84
  }, opts));
84
85
  }));
@@ -91,7 +92,7 @@ function fetchValWithReads(deps) {
91
92
  }();
92
93
  }
93
94
  var initFetchValStega = function initFetchValStega(deps) {
94
- return internal$1.fetchValFrom(fetchValWithReads(deps));
95
+ return internal.fetchValFrom(fetchValWithReads(deps));
95
96
  };
96
97
  var initFetchValRouteStega = function initFetchValRouteStega(deps) {
97
98
  var fetchVal = fetchValWithReads(deps);
@@ -112,7 +113,7 @@ var initFetchValRouteStega = function initFetchValRouteStega(deps) {
112
113
  path = valModule && core.Internal.getValPath(valModule);
113
114
  schema = valModule && core.Internal.getSchema(valModule); // `.jsonValues()` router: map params → the entry key and load ONLY that
114
115
  // entry, instead of the whole record.
115
- if (!internal$1.isJsonValuesRecordSchema(schema)) {
116
+ if (!internal.isJsonValuesRecordSchema(schema)) {
116
117
  _context2.n = 4;
117
118
  break;
118
119
  }
@@ -169,7 +170,7 @@ var initFetchValKeyStega = function initFetchValKeyStega(deps) {
169
170
  while (1) switch (_context3.n) {
170
171
  case 0:
171
172
  _context3.n = 1;
172
- return internal.draftForRequest({
173
+ return internal$1.draftForRequest({
173
174
  runtime: deps.runtime,
174
175
  isEnabled: deps.isEnabled,
175
176
  getCookies: deps.getCookies
@@ -180,8 +181,8 @@ var initFetchValKeyStega = function initFetchValKeyStega(deps) {
180
181
  draft = _yield$draftForReques2.draft;
181
182
  env = requestEnv(enabled, draft);
182
183
  _context3.n = 2;
183
- return internal$1.awaitResolved(function (settled) {
184
- return internal$1.resolveValEntry(selector, key, env, {
184
+ return internal.awaitResolved(function (settled) {
185
+ return internal.resolveValEntry(selector, key, env, {
185
186
  settled: settled
186
187
  });
187
188
  });
@@ -268,7 +269,7 @@ var initFetchValDraft = function initFetchValDraft(deps) {
268
269
  while (1) switch (_context5.n) {
269
270
  case 0:
270
271
  _context5.n = 1;
271
- return internal.readDraftChanges(deps);
272
+ return internal$1.readDraftChanges(deps);
272
273
  case 1:
273
274
  changes = _context5.v;
274
275
  return _context5.a(2, changes === null ? null : {
@@ -289,14 +290,22 @@ function initValRsc(config, valModules, rscNextConfig) {
289
290
  throw new Error("Could not get @valbuild/next package version");
290
291
  }
291
292
  // One runtime per process for these modules: the API route's server is
292
- // built on the same one, so a save through it moves what these read.
293
- var runtime = internal.createValRuntime(valModules, "/api/val", objectSpread2._objectSpread2({
294
- versions: {
295
- next: nextVersion,
296
- core: coreVersion,
297
- framework: "next"
298
- }
299
- }, config), config);
293
+ // built on the same one, so a save through it moves what these read. Built
294
+ // by the first draft read and not before: building it evaluates the data
295
+ // layer (TypeScript, the Studio's assets), which a visitor never needs.
296
+ var started = null;
297
+ var runtime = function runtime() {
298
+ return started !== null && started !== void 0 ? started : started = startRuntime();
299
+ };
300
+ var startRuntime = function startRuntime() {
301
+ return internal$1.createValRuntime(valModules, "/api/val", objectSpread2._objectSpread2({
302
+ versions: {
303
+ next: nextVersion,
304
+ core: coreVersion,
305
+ framework: "next"
306
+ }
307
+ }, config), config);
308
+ };
300
309
  var deps = {
301
310
  runtime: runtime,
302
311
  isEnabled: function () {