@valbuild/next 0.123.0 → 0.123.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 (41) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/client/dist/valbuild-next-client.cjs.dev.js +2 -2
  3. package/client/dist/valbuild-next-client.cjs.prod.js +2 -2
  4. package/client/dist/valbuild-next-client.esm.js +2 -2
  5. package/dist/{ValApp-2bdb460a.cjs.dev.js → ValApp-18ec7215.cjs.dev.js} +2 -2
  6. package/dist/{ValApp-074c8289.esm.js → ValApp-6d5f5c82.esm.js} +2 -2
  7. package/dist/ValApp-b852b147.cjs.js +7 -0
  8. package/dist/{ValApp-17eb6e93.cjs.prod.js → ValApp-b852b147.cjs.prod.js} +2 -2
  9. package/dist/ValCanvasBridge-5fc49440.cjs.js +7 -0
  10. package/dist/{ValCanvasBridge-e62125f8.cjs.prod.js → ValCanvasBridge-5fc49440.cjs.prod.js} +10 -10
  11. package/dist/{ValCanvasBridge-9d148bdd.cjs.dev.js → ValCanvasBridge-b918d991.cjs.dev.js} +10 -10
  12. package/dist/{ValCanvasBridge-d9948526.esm.js → ValCanvasBridge-e5931ea4.esm.js} +1 -1
  13. package/dist/{ValNextProvider-016a494b.cjs.dev.js → ValNextProvider-062a8dc9.cjs.dev.js} +64 -12
  14. package/dist/{ValNextProvider-32156acd.esm.js → ValNextProvider-3d2cd7e4.esm.js} +43 -9
  15. package/dist/ValNextProvider-da189afe.cjs.js +7 -0
  16. package/dist/{ValNextProvider-72d3561b.cjs.prod.js → ValNextProvider-da189afe.cjs.prod.js} +64 -12
  17. package/dist/{version-4d7b692c.esm.js → asyncToGenerator-500f022f.esm.js} +1 -10
  18. package/dist/{version-c311d818.cjs.dev.js → asyncToGenerator-8e5c36c8.cjs.prod.js} +0 -10
  19. package/dist/{version-0e6da9a7.cjs.prod.js → asyncToGenerator-c3823d62.cjs.dev.js} +0 -10
  20. package/dist/{fallbackColors-a491e700.cjs.dev.js → fallbackColors-080c1bbc.cjs.dev.js} +2 -2
  21. package/dist/{fallbackColors-77aeedf8.esm.js → fallbackColors-149dfbc9.esm.js} +1 -1
  22. package/dist/{fallbackColors-8842243c.cjs.prod.js → fallbackColors-e1d73b36.cjs.prod.js} +2 -2
  23. package/dist/{routeFromVal-263eec96.esm.js → routeFromVal-544e8318.esm.js} +1 -1
  24. package/dist/{routeFromVal-b48a454a.cjs.dev.js → routeFromVal-d53d5ffb.cjs.dev.js} +4 -4
  25. package/dist/{routeFromVal-8ac2f984.cjs.prod.js → routeFromVal-e0995830.cjs.prod.js} +4 -4
  26. package/dist/valbuild-next.cjs.dev.js +6 -5
  27. package/dist/valbuild-next.cjs.prod.js +6 -5
  28. package/dist/valbuild-next.esm.js +4 -3
  29. package/dist/version-16f6b0ce.esm.js +10 -0
  30. package/dist/version-d034b2fc.cjs.dev.js +12 -0
  31. package/dist/version-d2061026.cjs.prod.js +12 -0
  32. package/package.json +7 -7
  33. package/rsc/dist/valbuild-next-rsc.cjs.dev.js +46 -44
  34. package/rsc/dist/valbuild-next-rsc.cjs.prod.js +46 -44
  35. package/rsc/dist/valbuild-next-rsc.esm.js +4 -2
  36. package/server/dist/valbuild-next-server.cjs.dev.js +8 -7
  37. package/server/dist/valbuild-next-server.cjs.prod.js +8 -7
  38. package/server/dist/valbuild-next-server.esm.js +2 -1
  39. package/dist/ValApp-17eb6e93.cjs.js +0 -7
  40. package/dist/ValCanvasBridge-e62125f8.cjs.js +0 -7
  41. package/dist/ValNextProvider-72d3561b.cjs.js +0 -7
package/CHANGELOG.md CHANGED
@@ -1,5 +1,49 @@
1
1
  # @valbuild/next
2
2
 
3
+ ## 0.123.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#629](https://github.com/valbuild/val/pull/629) [`04b6d4c`](https://github.com/valbuild/val/commit/04b6d4cbbecc131bbaf3c20633af9dad8c857310) Thanks [@freekh](https://github.com/freekh)! - Stop shipping zod to every visitor of a Val site (~113 KB)
8
+
9
+ `@valbuild/next`'s client code needed five things from
10
+ `@valbuild/shared/internal`, three of which are string constants like
11
+ `VAL_THEME_SESSION_STORAGE_KEY`. But preconstruct publishes each entrypoint as
12
+ a single bundled module, so importing a string constant pulled in the whole
13
+ entrypoint — including `ApiRoutes.ts` and its zod schemas. Measured on
14
+ val.build, that was 113 KB of zod in the initial JS of every page, for
15
+ visitors who never open the Studio.
16
+
17
+ Two changes:
18
+
19
+ - New `@valbuild/shared/client` entrypoint carrying the parts that are safe in
20
+ a browser bundle: the session-storage keys, the canvas protocol, and the
21
+ route-pattern helpers. Nothing reachable from it may import zod, and
22
+ `noZodInClientEntrypoint.test.ts` walks the source graph to enforce that —
23
+ one careless re-export would silently put the 113 KB back.
24
+ - `ValNextProvider` now imports `createValClient` on first use rather than at
25
+ module scope. It genuinely needs zod (it `safeParse`s every request and
26
+ response), but its only caller is the draft-mode poll, which returns early
27
+ unless the overlay is mounted. A visitor without the Val Enable cookie never
28
+ triggers the import.
29
+
30
+ No API change. `@valbuild/shared/internal` still exports everything it did.
31
+
32
+ - Updated dependencies [[`04b6d4c`](https://github.com/valbuild/val/commit/04b6d4cbbecc131bbaf3c20633af9dad8c857310), [`8e58c34`](https://github.com/valbuild/val/commit/8e58c3495d1bf0f221a57082cb0a3045929722a1), [`3e93508`](https://github.com/valbuild/val/commit/3e93508b05d08b0c24947a97c6141a9ad8a3931e)]:
33
+ - @valbuild/shared@0.123.2
34
+ - @valbuild/server@0.123.2
35
+ - @valbuild/ui@0.123.2
36
+ - @valbuild/language-server@0.123.2
37
+ - @valbuild/mcp@0.123.2
38
+ - @valbuild/react@0.123.2
39
+
40
+ ## 0.123.1
41
+
42
+ ### Patch Changes
43
+
44
+ - Updated dependencies [[`468f147`](https://github.com/valbuild/val/commit/468f147e62d1a96585890208921341959f118b6d)]:
45
+ - @valbuild/mcp@0.123.1
46
+
3
47
  ## 0.123.0
4
48
 
5
49
  ### Minor Changes
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  require('client-only');
6
- var routeFromVal = require('../../dist/routeFromVal-b48a454a.cjs.dev.js');
6
+ var routeFromVal = require('../../dist/routeFromVal-d53d5ffb.cjs.dev.js');
7
7
  var core = require('@valbuild/core');
8
8
  var stega = require('@valbuild/react/stega');
9
9
  var React = require('react');
@@ -13,7 +13,7 @@ require('../../dist/unsupportedIterableToArray-c8ab77c9.cjs.dev.js');
13
13
  require('../../dist/objectSpread2-58024783.cjs.dev.js');
14
14
  require('../../dist/defineProperty-f90345d7.cjs.dev.js');
15
15
  require('../../dist/slicedToArray-44036a76.cjs.dev.js');
16
- require('@valbuild/shared/internal');
16
+ require('@valbuild/shared/client');
17
17
 
18
18
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
19
19
 
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  require('client-only');
6
- var routeFromVal = require('../../dist/routeFromVal-8ac2f984.cjs.prod.js');
6
+ var routeFromVal = require('../../dist/routeFromVal-e0995830.cjs.prod.js');
7
7
  var core = require('@valbuild/core');
8
8
  var stega = require('@valbuild/react/stega');
9
9
  var React = require('react');
@@ -13,7 +13,7 @@ require('../../dist/unsupportedIterableToArray-0d2087a2.cjs.prod.js');
13
13
  require('../../dist/objectSpread2-13f847a9.cjs.prod.js');
14
14
  require('../../dist/defineProperty-8951f469.cjs.prod.js');
15
15
  require('../../dist/slicedToArray-ce613de6.cjs.prod.js');
16
- require('@valbuild/shared/internal');
16
+ require('@valbuild/shared/client');
17
17
 
18
18
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
19
19
 
@@ -1,5 +1,5 @@
1
1
  import 'client-only';
2
- import { g as getJsonEntryStegaRoot, _ as _typeof, a as isJsonValuesRecordSchema, b as getValRouteUrlFromVal, i as initValRouteFromVal } from '../../dist/routeFromVal-263eec96.esm.js';
2
+ import { g as getJsonEntryStegaRoot, _ as _typeof, a as isJsonValuesRecordSchema, b as getValRouteUrlFromVal, i as initValRouteFromVal } from '../../dist/routeFromVal-544e8318.esm.js';
3
3
  import { Internal } from '@valbuild/core';
4
4
  import { getModuleIds, stegaEncode } from '@valbuild/react/stega';
5
5
  import React from 'react';
@@ -9,7 +9,7 @@ import '../../dist/unsupportedIterableToArray-5baabfdc.esm.js';
9
9
  import '../../dist/objectSpread2-60d1bd93.esm.js';
10
10
  import '../../dist/defineProperty-cca5affa.esm.js';
11
11
  import '../../dist/slicedToArray-aa291011.esm.js';
12
- import '@valbuild/shared/internal';
12
+ import '@valbuild/shared/client';
13
13
 
14
14
  function useValStega(selector) {
15
15
  var valOverlayContext = useValOverlayContext();
@@ -7,10 +7,10 @@ var slicedToArray = require('./slicedToArray-44036a76.cjs.dev.js');
7
7
  var ui = require('@valbuild/ui');
8
8
  var Script = require('next/script');
9
9
  var React = require('react');
10
- var fallbackColors = require('./fallbackColors-a491e700.cjs.dev.js');
10
+ var fallbackColors = require('./fallbackColors-080c1bbc.cjs.dev.js');
11
11
  var jsxRuntime = require('react/jsx-runtime');
12
12
  require('./unsupportedIterableToArray-c8ab77c9.cjs.dev.js');
13
- require('@valbuild/shared/internal');
13
+ require('@valbuild/shared/client');
14
14
  require('@valbuild/core');
15
15
 
16
16
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
@@ -3,10 +3,10 @@ import { _ as _slicedToArray } from './slicedToArray-aa291011.esm.js';
3
3
  import { VERSION, VAL_APP_PATH, VAL_APP_ID } from '@valbuild/ui';
4
4
  import Script from 'next/script';
5
5
  import { useState, useRef, useEffect } from 'react';
6
- import { u as useConfigStorageSave, v as valPrefixedClass, c as cn, a as canvasDarkBg, b as canvasLightBg } from './fallbackColors-77aeedf8.esm.js';
6
+ import { u as useConfigStorageSave, v as valPrefixedClass, c as cn, a as canvasDarkBg, b as canvasLightBg } from './fallbackColors-149dfbc9.esm.js';
7
7
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
8
8
  import './unsupportedIterableToArray-5baabfdc.esm.js';
9
- import '@valbuild/shared/internal';
9
+ import '@valbuild/shared/client';
10
10
  import '@valbuild/core';
11
11
 
12
12
  var ValApp = function ValApp(_ref) {
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ if (process.env.NODE_ENV === "production") {
4
+ module.exports = require("./ValApp-b852b147.cjs.prod.js");
5
+ } else {
6
+ module.exports = require("./ValApp-b852b147.cjs.dev.js");
7
+ }
@@ -7,10 +7,10 @@ var slicedToArray = require('./slicedToArray-ce613de6.cjs.prod.js');
7
7
  var ui = require('@valbuild/ui');
8
8
  var Script = require('next/script');
9
9
  var React = require('react');
10
- var fallbackColors = require('./fallbackColors-8842243c.cjs.prod.js');
10
+ var fallbackColors = require('./fallbackColors-e1d73b36.cjs.prod.js');
11
11
  var jsxRuntime = require('react/jsx-runtime');
12
12
  require('./unsupportedIterableToArray-0d2087a2.cjs.prod.js');
13
- require('@valbuild/shared/internal');
13
+ require('@valbuild/shared/client');
14
14
  require('@valbuild/core');
15
15
 
16
16
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ if (process.env.NODE_ENV === "production") {
4
+ module.exports = require("./ValCanvasBridge-5fc49440.cjs.prod.js");
5
+ } else {
6
+ module.exports = require("./ValCanvasBridge-5fc49440.cjs.dev.js");
7
+ }
@@ -6,7 +6,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
6
6
  var slicedToArray = require('./slicedToArray-ce613de6.cjs.prod.js');
7
7
  var React = require('react');
8
8
  var core = require('@valbuild/core');
9
- var internal = require('@valbuild/shared/internal');
9
+ var client = require('@valbuild/shared/client');
10
10
  var jsxRuntime = require('react/jsx-runtime');
11
11
  require('./unsupportedIterableToArray-0d2087a2.cjs.prod.js');
12
12
 
@@ -110,7 +110,7 @@ function ValCanvasBridge(_ref) {
110
110
  });
111
111
  });
112
112
  var message = {
113
- val: internal.VAL_CANVAS_MESSAGE,
113
+ val: client.VAL_CANVAS_MESSAGE,
114
114
  type: "elements",
115
115
  elements: elements,
116
116
  pageSize: {
@@ -130,7 +130,7 @@ function ValCanvasBridge(_ref) {
130
130
  // edges, and a message per render would be a message per keystroke.
131
131
  React__default["default"].useEffect(function () {
132
132
  post({
133
- val: internal.VAL_CANVAS_MESSAGE,
133
+ val: client.VAL_CANVAS_MESSAGE,
134
134
  type: "refreshing",
135
135
  pending: isRefreshing === true
136
136
  });
@@ -139,7 +139,7 @@ function ValCanvasBridge(_ref) {
139
139
  // Announce the frame, and say whether it is actually showing draft content.
140
140
  React__default["default"].useEffect(function () {
141
141
  post({
142
- val: internal.VAL_CANVAS_MESSAGE,
142
+ val: client.VAL_CANVAS_MESSAGE,
143
143
  type: "ready",
144
144
  draftMode: draftMode,
145
145
  url: window.location.href
@@ -246,7 +246,7 @@ function ValCanvasBridge(_ref) {
246
246
  // What the studio asks for.
247
247
  React__default["default"].useEffect(function () {
248
248
  var listener = function listener(event) {
249
- if (!internal.isValCanvasStudioMessage(event.data)) return;
249
+ if (!client.isValCanvasStudioMessage(event.data)) return;
250
250
  var message = event.data;
251
251
  if (message.type === "rescan") {
252
252
  scan();
@@ -318,7 +318,7 @@ function ValCanvasBridge(_ref) {
318
318
  event.preventDefault();
319
319
  event.stopPropagation();
320
320
  post({
321
- val: internal.VAL_CANVAS_MESSAGE,
321
+ val: client.VAL_CANVAS_MESSAGE,
322
322
  type: "clicked",
323
323
  paths: core.Internal.splitJoinedSourcePaths(attribute)
324
324
  });
@@ -375,7 +375,7 @@ function ValCanvasBridge(_ref) {
375
375
  event.preventDefault();
376
376
  active = true;
377
377
  post({
378
- val: internal.VAL_CANVAS_MESSAGE,
378
+ val: client.VAL_CANVAS_MESSAGE,
379
379
  type: "pinch",
380
380
  phase: "start",
381
381
  span: span(event.touches),
@@ -386,7 +386,7 @@ function ValCanvasBridge(_ref) {
386
386
  if (event.touches.length !== 2 || !active) return;
387
387
  event.preventDefault();
388
388
  post({
389
- val: internal.VAL_CANVAS_MESSAGE,
389
+ val: client.VAL_CANVAS_MESSAGE,
390
390
  type: "pinch",
391
391
  phase: "move",
392
392
  span: span(event.touches),
@@ -397,7 +397,7 @@ function ValCanvasBridge(_ref) {
397
397
  if (!active || event.touches.length >= 2) return;
398
398
  active = false;
399
399
  post({
400
- val: internal.VAL_CANVAS_MESSAGE,
400
+ val: client.VAL_CANVAS_MESSAGE,
401
401
  type: "pinch",
402
402
  phase: "end",
403
403
  span: 0,
@@ -438,7 +438,7 @@ function ValCanvasBridge(_ref) {
438
438
  if (!event.ctrlKey && !event.metaKey) return;
439
439
  event.preventDefault();
440
440
  post({
441
- val: internal.VAL_CANVAS_MESSAGE,
441
+ val: client.VAL_CANVAS_MESSAGE,
442
442
  type: "zoom",
443
443
  // The same response curve the studio uses for a wheel on its own
444
444
  // background, so the gesture feels the same on both sides of the frame.
@@ -6,7 +6,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
6
6
  var slicedToArray = require('./slicedToArray-44036a76.cjs.dev.js');
7
7
  var React = require('react');
8
8
  var core = require('@valbuild/core');
9
- var internal = require('@valbuild/shared/internal');
9
+ var client = require('@valbuild/shared/client');
10
10
  var jsxRuntime = require('react/jsx-runtime');
11
11
  require('./unsupportedIterableToArray-c8ab77c9.cjs.dev.js');
12
12
 
@@ -110,7 +110,7 @@ function ValCanvasBridge(_ref) {
110
110
  });
111
111
  });
112
112
  var message = {
113
- val: internal.VAL_CANVAS_MESSAGE,
113
+ val: client.VAL_CANVAS_MESSAGE,
114
114
  type: "elements",
115
115
  elements: elements,
116
116
  pageSize: {
@@ -130,7 +130,7 @@ function ValCanvasBridge(_ref) {
130
130
  // edges, and a message per render would be a message per keystroke.
131
131
  React__default["default"].useEffect(function () {
132
132
  post({
133
- val: internal.VAL_CANVAS_MESSAGE,
133
+ val: client.VAL_CANVAS_MESSAGE,
134
134
  type: "refreshing",
135
135
  pending: isRefreshing === true
136
136
  });
@@ -139,7 +139,7 @@ function ValCanvasBridge(_ref) {
139
139
  // Announce the frame, and say whether it is actually showing draft content.
140
140
  React__default["default"].useEffect(function () {
141
141
  post({
142
- val: internal.VAL_CANVAS_MESSAGE,
142
+ val: client.VAL_CANVAS_MESSAGE,
143
143
  type: "ready",
144
144
  draftMode: draftMode,
145
145
  url: window.location.href
@@ -246,7 +246,7 @@ function ValCanvasBridge(_ref) {
246
246
  // What the studio asks for.
247
247
  React__default["default"].useEffect(function () {
248
248
  var listener = function listener(event) {
249
- if (!internal.isValCanvasStudioMessage(event.data)) return;
249
+ if (!client.isValCanvasStudioMessage(event.data)) return;
250
250
  var message = event.data;
251
251
  if (message.type === "rescan") {
252
252
  scan();
@@ -318,7 +318,7 @@ function ValCanvasBridge(_ref) {
318
318
  event.preventDefault();
319
319
  event.stopPropagation();
320
320
  post({
321
- val: internal.VAL_CANVAS_MESSAGE,
321
+ val: client.VAL_CANVAS_MESSAGE,
322
322
  type: "clicked",
323
323
  paths: core.Internal.splitJoinedSourcePaths(attribute)
324
324
  });
@@ -375,7 +375,7 @@ function ValCanvasBridge(_ref) {
375
375
  event.preventDefault();
376
376
  active = true;
377
377
  post({
378
- val: internal.VAL_CANVAS_MESSAGE,
378
+ val: client.VAL_CANVAS_MESSAGE,
379
379
  type: "pinch",
380
380
  phase: "start",
381
381
  span: span(event.touches),
@@ -386,7 +386,7 @@ function ValCanvasBridge(_ref) {
386
386
  if (event.touches.length !== 2 || !active) return;
387
387
  event.preventDefault();
388
388
  post({
389
- val: internal.VAL_CANVAS_MESSAGE,
389
+ val: client.VAL_CANVAS_MESSAGE,
390
390
  type: "pinch",
391
391
  phase: "move",
392
392
  span: span(event.touches),
@@ -397,7 +397,7 @@ function ValCanvasBridge(_ref) {
397
397
  if (!active || event.touches.length >= 2) return;
398
398
  active = false;
399
399
  post({
400
- val: internal.VAL_CANVAS_MESSAGE,
400
+ val: client.VAL_CANVAS_MESSAGE,
401
401
  type: "pinch",
402
402
  phase: "end",
403
403
  span: 0,
@@ -438,7 +438,7 @@ function ValCanvasBridge(_ref) {
438
438
  if (!event.ctrlKey && !event.metaKey) return;
439
439
  event.preventDefault();
440
440
  post({
441
- val: internal.VAL_CANVAS_MESSAGE,
441
+ val: client.VAL_CANVAS_MESSAGE,
442
442
  type: "zoom",
443
443
  // The same response curve the studio uses for a wheel on its own
444
444
  // background, so the gesture feels the same on both sides of the frame.
@@ -2,7 +2,7 @@
2
2
  import { _ as _slicedToArray } from './slicedToArray-aa291011.esm.js';
3
3
  import React from 'react';
4
4
  import { Internal } from '@valbuild/core';
5
- import { VAL_CANVAS_MESSAGE, isValCanvasStudioMessage } from '@valbuild/shared/internal';
5
+ import { VAL_CANVAS_MESSAGE, isValCanvasStudioMessage } from '@valbuild/shared/client';
6
6
  import { jsx } from 'react/jsx-runtime';
7
7
  import './unsupportedIterableToArray-5baabfdc.esm.js';
8
8
 
@@ -4,6 +4,7 @@
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
6
  var slicedToArray = require('./slicedToArray-44036a76.cjs.dev.js');
7
+ var asyncToGenerator = require('./asyncToGenerator-c3823d62.cjs.dev.js');
7
8
  var objectSpread2 = require('./objectSpread2-58024783.cjs.dev.js');
8
9
  var core = require('@valbuild/core');
9
10
  var ui = require('@valbuild/ui');
@@ -12,16 +13,34 @@ var Script = require('next/script');
12
13
  var React = require('react');
13
14
  var ValOverlayContext = require('./ValOverlayContext-5bd7628b.cjs.dev.js');
14
15
  var stega = require('@valbuild/react/stega');
15
- var internal = require('@valbuild/shared/internal');
16
- var fallbackColors = require('./fallbackColors-a491e700.cjs.dev.js');
16
+ var fallbackColors = require('./fallbackColors-080c1bbc.cjs.dev.js');
17
+ var client = require('@valbuild/shared/client');
17
18
  var createForOfIteratorHelper = require('./createForOfIteratorHelper-0445603c.cjs.dev.js');
18
- var ValCanvasBridge = require('./ValCanvasBridge-9d148bdd.cjs.dev.js');
19
+ var ValCanvasBridge = require('./ValCanvasBridge-b918d991.cjs.dev.js');
19
20
  var jsxRuntime = require('react/jsx-runtime');
20
21
  require('./unsupportedIterableToArray-c8ab77c9.cjs.dev.js');
21
22
  require('./defineProperty-f90345d7.cjs.dev.js');
22
23
 
23
24
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
24
25
 
26
+ function _interopNamespace(e) {
27
+ if (e && e.__esModule) return e;
28
+ var n = Object.create(null);
29
+ if (e) {
30
+ Object.keys(e).forEach(function (k) {
31
+ if (k !== 'default') {
32
+ var d = Object.getOwnPropertyDescriptor(e, k);
33
+ Object.defineProperty(n, k, d.get ? d : {
34
+ enumerable: true,
35
+ get: function () { return e[k]; }
36
+ });
37
+ }
38
+ });
39
+ }
40
+ n["default"] = e;
41
+ return Object.freeze(n);
42
+ }
43
+
25
44
  var Script__default = /*#__PURE__*/_interopDefault(Script);
26
45
  var React__default = /*#__PURE__*/_interopDefault(React);
27
46
 
@@ -29,7 +48,7 @@ function initSessionTheme(config) {
29
48
  if (typeof window === "undefined") {
30
49
  return null;
31
50
  }
32
- var existingSessionTheme = sessionStorage.getItem(internal.VAL_THEME_SESSION_STORAGE_KEY);
51
+ var existingSessionTheme = sessionStorage.getItem(client.VAL_THEME_SESSION_STORAGE_KEY);
33
52
  if (existingSessionTheme && (existingSessionTheme === "dark" || existingSessionTheme === "light")) {
34
53
  return existingSessionTheme;
35
54
  }
@@ -40,7 +59,7 @@ function initSessionTheme(config) {
40
59
  } else if ((config === null || config === void 0 ? void 0 : config.defaultTheme) === "dark" || (config === null || config === void 0 ? void 0 : config.defaultTheme) === "light") {
41
60
  theme = config.defaultTheme;
42
61
  }
43
- sessionStorage.setItem(internal.VAL_THEME_SESSION_STORAGE_KEY, theme);
62
+ sessionStorage.setItem(client.VAL_THEME_SESSION_STORAGE_KEY, theme);
44
63
  return theme;
45
64
  }
46
65
 
@@ -182,11 +201,42 @@ var ValNextProvider = function ValNextProvider(props) {
182
201
  var _draftModeReady$curre2;
183
202
  // TODO: use config:
184
203
  var route = "/api/val";
185
- var client = React__default["default"].useMemo(function () {
186
- return internal.createValClient(route, objectSpread2._objectSpread2(objectSpread2._objectSpread2({}, props.config), {}, {
187
- contentHostUrl: core.DEFAULT_CONTENT_HOST
188
- }));
189
- }, [route, props.config]);
204
+ /**
205
+ * Loaded on first use, never at import time.
206
+ *
207
+ * `createValClient` validates every request and response against the zod
208
+ * schemas in `@valbuild/shared/internal`'s `ApiRoutes`, and preconstruct
209
+ * publishes that entrypoint as one module - so importing it statically put
210
+ * ~113 KB of zod in the bundle of every page of every Val site. The only
211
+ * caller is the draft-mode poll below, which returns early unless
212
+ * `mountOverlay` is set, so a visitor without the Val Enable cookie never
213
+ * triggers this import and never downloads that chunk.
214
+ */
215
+ var clientRef = React__default["default"].useRef(null);
216
+ var configRef = React__default["default"].useRef(props.config);
217
+ configRef.current = props.config;
218
+ var getClient = React__default["default"].useCallback(/*#__PURE__*/asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regenerator().m(function _callee() {
219
+ var _yield$import, createValClient;
220
+ return asyncToGenerator._regenerator().w(function (_context) {
221
+ while (1) switch (_context.n) {
222
+ case 0:
223
+ if (clientRef.current) {
224
+ _context.n = 2;
225
+ break;
226
+ }
227
+ _context.n = 1;
228
+ return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('@valbuild/shared/internal')); });
229
+ case 1:
230
+ _yield$import = _context.v;
231
+ createValClient = _yield$import.createValClient;
232
+ clientRef.current = createValClient(route, objectSpread2._objectSpread2(objectSpread2._objectSpread2({}, configRef.current), {}, {
233
+ contentHostUrl: core.DEFAULT_CONTENT_HOST
234
+ }));
235
+ case 2:
236
+ return _context.a(2, clientRef.current);
237
+ }
238
+ }, _callee);
239
+ })), [route]);
190
240
 
191
241
  // TODO: move below into react package
192
242
  var valStore = React__default["default"].useMemo(function () {
@@ -316,7 +366,7 @@ var ValNextProvider = function ValNextProvider(props) {
316
366
  setMountOverlay(false);
317
367
  return;
318
368
  }
319
- setIsCanvas(internal.isValCanvasFrame(location.search));
369
+ setIsCanvas(client.isValCanvasFrame(location.search));
320
370
  setMountOverlay(hasValEnableCookie(document.cookie));
321
371
  }, []);
322
372
  React__default["default"].useEffect(function () {
@@ -488,7 +538,9 @@ var ValNextProvider = function ValNextProvider(props) {
488
538
  }
489
539
  }));
490
540
  var pollDraftStatId = ++pollDraftStatIdRef.current;
491
- client("/draft/stat", "GET", {}).then(function (res) {
541
+ getClient().then(function (client) {
542
+ return client("/draft/stat", "GET", {});
543
+ }).then(function (res) {
492
544
  if (pollDraftStatIdRef.current !== pollDraftStatId) {
493
545
  return;
494
546
  }
@@ -1,5 +1,6 @@
1
1
  'use client';
2
2
  import { _ as _slicedToArray } from './slicedToArray-aa291011.esm.js';
3
+ import { _ as _asyncToGenerator, a as _regenerator } from './asyncToGenerator-500f022f.esm.js';
3
4
  import { _ as _objectSpread2 } from './objectSpread2-60d1bd93.esm.js';
4
5
  import { Internal, DEFAULT_CONTENT_HOST } from '@valbuild/core';
5
6
  import { VERSION, VAL_APP_PATH, VAL_OVERLAY_ID } from '@valbuild/ui';
@@ -8,10 +9,10 @@ import Script from 'next/script';
8
9
  import React, { useEffect } from 'react';
9
10
  import { ValExternalStore, ValOverlayProvider } from './ValOverlayContext-e42a2e14.esm.js';
10
11
  import { SET_AUTO_TAG_JSX_ENABLED } from '@valbuild/react/stega';
11
- import { VAL_THEME_SESSION_STORAGE_KEY, createValClient, isValCanvasFrame } from '@valbuild/shared/internal';
12
- import { p as prefixStyles, u as useConfigStorageSave, f as floatDarkBg, d as floatLightBg, v as valPrefixedClass, c as cn } from './fallbackColors-77aeedf8.esm.js';
12
+ import { p as prefixStyles, u as useConfigStorageSave, f as floatDarkBg, d as floatLightBg, v as valPrefixedClass, c as cn } from './fallbackColors-149dfbc9.esm.js';
13
+ import { VAL_THEME_SESSION_STORAGE_KEY, isValCanvasFrame } from '@valbuild/shared/client';
13
14
  import { _ as _createForOfIteratorHelper } from './createForOfIteratorHelper-5758a730.esm.js';
14
- import { ValCanvasBridge } from './ValCanvasBridge-d9948526.esm.js';
15
+ import { ValCanvasBridge } from './ValCanvasBridge-e5931ea4.esm.js';
15
16
  import { jsxs, jsx } from 'react/jsx-runtime';
16
17
  import './unsupportedIterableToArray-5baabfdc.esm.js';
17
18
  import './defineProperty-cca5affa.esm.js';
@@ -173,11 +174,42 @@ var ValNextProvider = function ValNextProvider(props) {
173
174
  var _draftModeReady$curre2;
174
175
  // TODO: use config:
175
176
  var route = "/api/val";
176
- var client = React.useMemo(function () {
177
- return createValClient(route, _objectSpread2(_objectSpread2({}, props.config), {}, {
178
- contentHostUrl: DEFAULT_CONTENT_HOST
179
- }));
180
- }, [route, props.config]);
177
+ /**
178
+ * Loaded on first use, never at import time.
179
+ *
180
+ * `createValClient` validates every request and response against the zod
181
+ * schemas in `@valbuild/shared/internal`'s `ApiRoutes`, and preconstruct
182
+ * publishes that entrypoint as one module - so importing it statically put
183
+ * ~113 KB of zod in the bundle of every page of every Val site. The only
184
+ * caller is the draft-mode poll below, which returns early unless
185
+ * `mountOverlay` is set, so a visitor without the Val Enable cookie never
186
+ * triggers this import and never downloads that chunk.
187
+ */
188
+ var clientRef = React.useRef(null);
189
+ var configRef = React.useRef(props.config);
190
+ configRef.current = props.config;
191
+ var getClient = React.useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
192
+ var _yield$import, createValClient;
193
+ return _regenerator().w(function (_context) {
194
+ while (1) switch (_context.n) {
195
+ case 0:
196
+ if (clientRef.current) {
197
+ _context.n = 2;
198
+ break;
199
+ }
200
+ _context.n = 1;
201
+ return import('@valbuild/shared/internal');
202
+ case 1:
203
+ _yield$import = _context.v;
204
+ createValClient = _yield$import.createValClient;
205
+ clientRef.current = createValClient(route, _objectSpread2(_objectSpread2({}, configRef.current), {}, {
206
+ contentHostUrl: DEFAULT_CONTENT_HOST
207
+ }));
208
+ case 2:
209
+ return _context.a(2, clientRef.current);
210
+ }
211
+ }, _callee);
212
+ })), [route]);
181
213
 
182
214
  // TODO: move below into react package
183
215
  var valStore = React.useMemo(function () {
@@ -479,7 +511,9 @@ var ValNextProvider = function ValNextProvider(props) {
479
511
  }
480
512
  }));
481
513
  var pollDraftStatId = ++pollDraftStatIdRef.current;
482
- client("/draft/stat", "GET", {}).then(function (res) {
514
+ getClient().then(function (client) {
515
+ return client("/draft/stat", "GET", {});
516
+ }).then(function (res) {
483
517
  if (pollDraftStatIdRef.current !== pollDraftStatId) {
484
518
  return;
485
519
  }
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ if (process.env.NODE_ENV === "production") {
4
+ module.exports = require("./ValNextProvider-da189afe.cjs.prod.js");
5
+ } else {
6
+ module.exports = require("./ValNextProvider-da189afe.cjs.dev.js");
7
+ }