@valbuild/next 0.97.0 → 0.97.1

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.
@@ -18,7 +18,8 @@ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e };
18
18
  var Script__default = /*#__PURE__*/_interopDefault(Script);
19
19
 
20
20
  var ValApp = function ValApp(_ref) {
21
- var config = _ref.config;
21
+ var config = _ref.config,
22
+ children = _ref.children;
22
23
  var route = "/api/val"; // TODO: make configurable
23
24
  var _useState = React.useState(),
24
25
  _useState2 = slicedToArray._slicedToArray(_useState, 2),
@@ -134,7 +135,7 @@ var ValApp = function ValApp(_ref) {
134
135
  }), /*#__PURE__*/jsxRuntime.jsx("div", {
135
136
  id: ui.VAL_APP_ID,
136
137
  ref: container
137
- })]
138
+ }), children]
138
139
  });
139
140
  };
140
141
 
@@ -10,7 +10,8 @@ import '@valbuild/shared/internal';
10
10
  import '@valbuild/core';
11
11
 
12
12
  var ValApp = function ValApp(_ref) {
13
- var config = _ref.config;
13
+ var config = _ref.config,
14
+ children = _ref.children;
14
15
  var route = "/api/val"; // TODO: make configurable
15
16
  var _useState = useState(),
16
17
  _useState2 = _slicedToArray(_useState, 2),
@@ -126,7 +127,7 @@ var ValApp = function ValApp(_ref) {
126
127
  }), /*#__PURE__*/jsx("div", {
127
128
  id: VAL_APP_ID,
128
129
  ref: container
129
- })]
130
+ }), children]
130
131
  });
131
132
  };
132
133
 
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ if (process.env.NODE_ENV === "production") {
4
+ module.exports = require("./ValApp-bb207e96.cjs.prod.js");
5
+ } else {
6
+ module.exports = require("./ValApp-bb207e96.cjs.dev.js");
7
+ }
@@ -18,7 +18,8 @@ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e };
18
18
  var Script__default = /*#__PURE__*/_interopDefault(Script);
19
19
 
20
20
  var ValApp = function ValApp(_ref) {
21
- var config = _ref.config;
21
+ var config = _ref.config,
22
+ children = _ref.children;
22
23
  var route = "/api/val"; // TODO: make configurable
23
24
  var _useState = React.useState(),
24
25
  _useState2 = slicedToArray._slicedToArray(_useState, 2),
@@ -134,7 +135,7 @@ var ValApp = function ValApp(_ref) {
134
135
  }), /*#__PURE__*/jsxRuntime.jsx("div", {
135
136
  id: ui.VAL_APP_ID,
136
137
  ref: container
137
- })]
138
+ }), children]
138
139
  });
139
140
  };
140
141
 
@@ -0,0 +1,48 @@
1
+ 'use client';
2
+ import { useEffect } from 'react';
3
+
4
+ // Keep in sync with VAL_MODULES_UPDATED_EVENT in @valbuild/ui (useValModules.ts).
5
+ var VAL_MODULES_UPDATED_EVENT = "val-modules-updated";
6
+
7
+ /**
8
+ * Registers the user's `val.modules` registry on `window.__VAL_MODULES__` so
9
+ * the Val editor SPA (both the `/val` app and the on-page overlay) can read it.
10
+ *
11
+ * Must be called from a Client Component that statically imports `val.modules`:
12
+ * the module `def` entries are function closures, so the registry cannot be
13
+ * passed as a prop across the Server → Client Component boundary and must be
14
+ * pulled into the client bundle and registered via the window global instead.
15
+ *
16
+ * Re-runs when the `modules` reference changes (e.g. on HMR) and dispatches
17
+ * `val-modules-updated` so the SPA picks up the new registry.
18
+ */
19
+ function useRegisterValModules(modules) {
20
+ useEffect(function () {
21
+ window.__VAL_MODULES__ = modules;
22
+ window.dispatchEvent(new CustomEvent(VAL_MODULES_UPDATED_EVENT));
23
+ }, [modules]);
24
+ }
25
+
26
+ /**
27
+ * Registers the user's `val.modules` registry for the Val editor SPA.
28
+ *
29
+ * Render this inside both `<ValProvider>` (root layout) and `<ValApp>` (the
30
+ * `/val` page), passing your `val.modules` default export. Use it from a
31
+ * Client Component so the registry ends up in the client bundle:
32
+ *
33
+ * @example
34
+ * "use client";
35
+ * import { ValModulesClient } from "@valbuild/next";
36
+ * import valModules from "../../val.modules";
37
+ *
38
+ * export function RegisterValModules() {
39
+ * return <ValModulesClient modules={valModules} />;
40
+ * }
41
+ */
42
+ function ValModulesClient(_ref) {
43
+ var modules = _ref.modules;
44
+ useRegisterValModules(modules);
45
+ return null;
46
+ }
47
+
48
+ export { ValModulesClient, useRegisterValModules };
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ if (process.env.NODE_ENV === "production") {
4
+ module.exports = require("./ValModulesClient-10c0721c.cjs.prod.js");
5
+ } else {
6
+ module.exports = require("./ValModulesClient-10c0721c.cjs.dev.js");
7
+ }
@@ -0,0 +1,53 @@
1
+ 'use client';
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var React = require('react');
7
+
8
+ // Keep in sync with VAL_MODULES_UPDATED_EVENT in @valbuild/ui (useValModules.ts).
9
+ var VAL_MODULES_UPDATED_EVENT = "val-modules-updated";
10
+
11
+ /**
12
+ * Registers the user's `val.modules` registry on `window.__VAL_MODULES__` so
13
+ * the Val editor SPA (both the `/val` app and the on-page overlay) can read it.
14
+ *
15
+ * Must be called from a Client Component that statically imports `val.modules`:
16
+ * the module `def` entries are function closures, so the registry cannot be
17
+ * passed as a prop across the Server → Client Component boundary and must be
18
+ * pulled into the client bundle and registered via the window global instead.
19
+ *
20
+ * Re-runs when the `modules` reference changes (e.g. on HMR) and dispatches
21
+ * `val-modules-updated` so the SPA picks up the new registry.
22
+ */
23
+ function useRegisterValModules(modules) {
24
+ React.useEffect(function () {
25
+ window.__VAL_MODULES__ = modules;
26
+ window.dispatchEvent(new CustomEvent(VAL_MODULES_UPDATED_EVENT));
27
+ }, [modules]);
28
+ }
29
+
30
+ /**
31
+ * Registers the user's `val.modules` registry for the Val editor SPA.
32
+ *
33
+ * Render this inside both `<ValProvider>` (root layout) and `<ValApp>` (the
34
+ * `/val` page), passing your `val.modules` default export. Use it from a
35
+ * Client Component so the registry ends up in the client bundle:
36
+ *
37
+ * @example
38
+ * "use client";
39
+ * import { ValModulesClient } from "@valbuild/next";
40
+ * import valModules from "../../val.modules";
41
+ *
42
+ * export function RegisterValModules() {
43
+ * return <ValModulesClient modules={valModules} />;
44
+ * }
45
+ */
46
+ function ValModulesClient(_ref) {
47
+ var modules = _ref.modules;
48
+ useRegisterValModules(modules);
49
+ return null;
50
+ }
51
+
52
+ exports.ValModulesClient = ValModulesClient;
53
+ exports.useRegisterValModules = useRegisterValModules;
@@ -0,0 +1,53 @@
1
+ 'use client';
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var React = require('react');
7
+
8
+ // Keep in sync with VAL_MODULES_UPDATED_EVENT in @valbuild/ui (useValModules.ts).
9
+ var VAL_MODULES_UPDATED_EVENT = "val-modules-updated";
10
+
11
+ /**
12
+ * Registers the user's `val.modules` registry on `window.__VAL_MODULES__` so
13
+ * the Val editor SPA (both the `/val` app and the on-page overlay) can read it.
14
+ *
15
+ * Must be called from a Client Component that statically imports `val.modules`:
16
+ * the module `def` entries are function closures, so the registry cannot be
17
+ * passed as a prop across the Server → Client Component boundary and must be
18
+ * pulled into the client bundle and registered via the window global instead.
19
+ *
20
+ * Re-runs when the `modules` reference changes (e.g. on HMR) and dispatches
21
+ * `val-modules-updated` so the SPA picks up the new registry.
22
+ */
23
+ function useRegisterValModules(modules) {
24
+ React.useEffect(function () {
25
+ window.__VAL_MODULES__ = modules;
26
+ window.dispatchEvent(new CustomEvent(VAL_MODULES_UPDATED_EVENT));
27
+ }, [modules]);
28
+ }
29
+
30
+ /**
31
+ * Registers the user's `val.modules` registry for the Val editor SPA.
32
+ *
33
+ * Render this inside both `<ValProvider>` (root layout) and `<ValApp>` (the
34
+ * `/val` page), passing your `val.modules` default export. Use it from a
35
+ * Client Component so the registry ends up in the client bundle:
36
+ *
37
+ * @example
38
+ * "use client";
39
+ * import { ValModulesClient } from "@valbuild/next";
40
+ * import valModules from "../../val.modules";
41
+ *
42
+ * export function RegisterValModules() {
43
+ * return <ValModulesClient modules={valModules} />;
44
+ * }
45
+ */
46
+ function ValModulesClient(_ref) {
47
+ var modules = _ref.modules;
48
+ useRegisterValModules(modules);
49
+ return null;
50
+ }
51
+
52
+ exports.ValModulesClient = ValModulesClient;
53
+ exports.useRegisterValModules = useRegisterValModules;
@@ -1,4 +1,6 @@
1
1
  import { ValConfig } from "@valbuild/core";
2
- export declare const ValApp: ({ config }: {
2
+ import { type ReactNode } from "react";
3
+ export declare const ValApp: ({ config, children, }: {
3
4
  config: ValConfig;
5
+ children?: ReactNode;
4
6
  }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,38 @@
1
+ import type { ValModules } from "@valbuild/core";
2
+ declare global {
3
+ interface Window {
4
+ __VAL_MODULES__?: ValModules;
5
+ }
6
+ }
7
+ /**
8
+ * Registers the user's `val.modules` registry on `window.__VAL_MODULES__` so
9
+ * the Val editor SPA (both the `/val` app and the on-page overlay) can read it.
10
+ *
11
+ * Must be called from a Client Component that statically imports `val.modules`:
12
+ * the module `def` entries are function closures, so the registry cannot be
13
+ * passed as a prop across the Server → Client Component boundary and must be
14
+ * pulled into the client bundle and registered via the window global instead.
15
+ *
16
+ * Re-runs when the `modules` reference changes (e.g. on HMR) and dispatches
17
+ * `val-modules-updated` so the SPA picks up the new registry.
18
+ */
19
+ export declare function useRegisterValModules(modules: ValModules): void;
20
+ /**
21
+ * Registers the user's `val.modules` registry for the Val editor SPA.
22
+ *
23
+ * Render this inside both `<ValProvider>` (root layout) and `<ValApp>` (the
24
+ * `/val` page), passing your `val.modules` default export. Use it from a
25
+ * Client Component so the registry ends up in the client bundle:
26
+ *
27
+ * @example
28
+ * "use client";
29
+ * import { ValModulesClient } from "@valbuild/next";
30
+ * import valModules from "../../val.modules";
31
+ *
32
+ * export function RegisterValModules() {
33
+ * return <ValModulesClient modules={valModules} />;
34
+ * }
35
+ */
36
+ export declare function ValModulesClient({ modules }: {
37
+ modules: ValModules;
38
+ }): null;
@@ -18,6 +18,7 @@ export { type ValEncodedString, type File, type Image, type RichText, } from "@v
18
18
  export { ValProvider } from "./ValProvider.js";
19
19
  export { ValImage, type ValImageProps } from "./ValImage.js";
20
20
  export { ValApp } from "./ValApp.js";
21
+ export { ValModulesClient, useRegisterValModules } from "./ValModulesClient.js";
21
22
  export type * as t from "./ValTypes.js";
22
23
  export type { DecodeVal } from "@valbuild/react/stega";
23
24
  export declare const Internal: {
@@ -10,7 +10,8 @@ var internal = require('@valbuild/react/internal');
10
10
  var ValNextProvider = require('./ValNextProvider-03a9f8fd.cjs.dev.js');
11
11
  var NextImage = require('next/image');
12
12
  var jsxRuntime = require('react/jsx-runtime');
13
- var ValApp = require('./ValApp-3df36e0d.cjs.dev.js');
13
+ var ValApp = require('./ValApp-1992d8b3.cjs.dev.js');
14
+ var ValModulesClient = require('./ValModulesClient-4ecabf99.cjs.dev.js');
14
15
  var createForOfIteratorHelper = require('./createForOfIteratorHelper-0445603c.cjs.dev.js');
15
16
  require('./defineProperty-f90345d7.cjs.dev.js');
16
17
  require('./unsupportedIterableToArray-c8ab77c9.cjs.dev.js');
@@ -237,6 +238,14 @@ Object.defineProperty(exports, 'ValApp', {
237
238
  enumerable: true,
238
239
  get: function () { return ValApp.ValApp; }
239
240
  });
241
+ Object.defineProperty(exports, 'ValModulesClient', {
242
+ enumerable: true,
243
+ get: function () { return ValModulesClient.ValModulesClient; }
244
+ });
245
+ Object.defineProperty(exports, 'useRegisterValModules', {
246
+ enumerable: true,
247
+ get: function () { return ValModulesClient.useRegisterValModules; }
248
+ });
240
249
  exports.Internal = Internal;
241
250
  exports.ValImage = ValImage;
242
251
  exports.ValProvider = ValProvider;
@@ -10,7 +10,8 @@ var internal = require('@valbuild/react/internal');
10
10
  var ValNextProvider = require('./ValNextProvider-6103cb74.cjs.prod.js');
11
11
  var NextImage = require('next/image');
12
12
  var jsxRuntime = require('react/jsx-runtime');
13
- var ValApp = require('./ValApp-22147086.cjs.prod.js');
13
+ var ValApp = require('./ValApp-bb207e96.cjs.prod.js');
14
+ var ValModulesClient = require('./ValModulesClient-10c0721c.cjs.prod.js');
14
15
  var createForOfIteratorHelper = require('./createForOfIteratorHelper-d4afcad8.cjs.prod.js');
15
16
  require('./defineProperty-8951f469.cjs.prod.js');
16
17
  require('./unsupportedIterableToArray-0d2087a2.cjs.prod.js');
@@ -237,6 +238,14 @@ Object.defineProperty(exports, 'ValApp', {
237
238
  enumerable: true,
238
239
  get: function () { return ValApp.ValApp; }
239
240
  });
241
+ Object.defineProperty(exports, 'ValModulesClient', {
242
+ enumerable: true,
243
+ get: function () { return ValModulesClient.ValModulesClient; }
244
+ });
245
+ Object.defineProperty(exports, 'useRegisterValModules', {
246
+ enumerable: true,
247
+ get: function () { return ValModulesClient.useRegisterValModules; }
248
+ });
240
249
  exports.Internal = Internal;
241
250
  exports.ValImage = ValImage;
242
251
  exports.ValProvider = ValProvider;
@@ -9,7 +9,8 @@ export { ValRichText } from '@valbuild/react/internal';
9
9
  import { ValNextProvider } from './ValNextProvider-7302b8af.esm.js';
10
10
  import NextImage from 'next/image';
11
11
  import { jsx } from 'react/jsx-runtime';
12
- export { ValApp } from './ValApp-e2e1dfed.esm.js';
12
+ export { ValApp } from './ValApp-8912fc8b.esm.js';
13
+ export { ValModulesClient, useRegisterValModules } from './ValModulesClient-0dd601a1.esm.js';
13
14
  import { _ as _createForOfIteratorHelper } from './createForOfIteratorHelper-5758a730.esm.js';
14
15
  import './defineProperty-cca5affa.esm.js';
15
16
  import './unsupportedIterableToArray-5baabfdc.esm.js';
package/package.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "next",
13
13
  "react"
14
14
  ],
15
- "version": "0.97.0",
15
+ "version": "0.97.1",
16
16
  "main": "dist/valbuild-next.cjs.js",
17
17
  "module": "dist/valbuild-next.esm.js",
18
18
  "exports": {
@@ -47,11 +47,11 @@
47
47
  "dependencies": {
48
48
  "client-only": "^0.0.1",
49
49
  "server-only": "^0.0.1",
50
- "@valbuild/core": "0.97.0",
51
- "@valbuild/react": "0.97.0",
52
- "@valbuild/server": "0.97.0",
53
- "@valbuild/shared": "0.97.0",
54
- "@valbuild/ui": "0.97.0"
50
+ "@valbuild/core": "0.97.1",
51
+ "@valbuild/react": "0.97.1",
52
+ "@valbuild/server": "0.97.1",
53
+ "@valbuild/shared": "0.97.1",
54
+ "@valbuild/ui": "0.97.1"
55
55
  },
56
56
  "devDependencies": {
57
57
  "@testing-library/react": "^14.0.0",
@@ -89,7 +89,9 @@ var initFetchValStega = function initFetchValStega(config, valApiEndpoints, valS
89
89
  query: {
90
90
  validate_sources: true,
91
91
  validate_binary_files: false,
92
- exclude_patches: false
92
+ exclude_patches: false,
93
+ // RSC pre-render uses the legacy "server applies patches" path.
94
+ apply_patches: undefined
93
95
  },
94
96
  cookies: defineProperty._defineProperty({}, internal.VAL_SESSION_COOKIE, (_cookies = cookies) === null || _cookies === void 0 || (_cookies = _cookies.get(internal.VAL_SESSION_COOKIE)) === null || _cookies === void 0 ? void 0 : _cookies.value)
95
97
  });
@@ -89,7 +89,9 @@ var initFetchValStega = function initFetchValStega(config, valApiEndpoints, valS
89
89
  query: {
90
90
  validate_sources: true,
91
91
  validate_binary_files: false,
92
- exclude_patches: false
92
+ exclude_patches: false,
93
+ // RSC pre-render uses the legacy "server applies patches" path.
94
+ apply_patches: undefined
93
95
  },
94
96
  cookies: defineProperty._defineProperty({}, internal.VAL_SESSION_COOKIE, (_cookies = cookies) === null || _cookies === void 0 || (_cookies = _cookies.get(internal.VAL_SESSION_COOKIE)) === null || _cookies === void 0 ? void 0 : _cookies.value)
95
97
  });
@@ -85,7 +85,9 @@ var initFetchValStega = function initFetchValStega(config, valApiEndpoints, valS
85
85
  query: {
86
86
  validate_sources: true,
87
87
  validate_binary_files: false,
88
- exclude_patches: false
88
+ exclude_patches: false,
89
+ // RSC pre-render uses the legacy "server applies patches" path.
90
+ apply_patches: undefined
89
91
  },
90
92
  cookies: _defineProperty({}, VAL_SESSION_COOKIE, (_cookies = cookies) === null || _cookies === void 0 || (_cookies = _cookies.get(VAL_SESSION_COOKIE)) === null || _cookies === void 0 ? void 0 : _cookies.value)
91
93
  });
@@ -1,7 +0,0 @@
1
- 'use strict';
2
-
3
- if (process.env.NODE_ENV === "production") {
4
- module.exports = require("./ValApp-22147086.cjs.prod.js");
5
- } else {
6
- module.exports = require("./ValApp-22147086.cjs.dev.js");
7
- }