@valbuild/next 0.87.5 → 0.89.0

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/README.md CHANGED
@@ -55,10 +55,12 @@ Join us on [discord](https://discord.gg/cZzqPvaX8k) to get help or give us feedb
55
55
  - [Nullable](#nullable)
56
56
  - [Array](#array)
57
57
  - [Record](#record)
58
+ - [Router](#router)
58
59
  - [Object](#object)
59
60
  - [Rich text](#richtext)
60
61
  - [Image](#image)
61
62
  - [keyOf](#keyof)
63
+ - [Route](#route)
62
64
 
63
65
  ## Installation
64
66
 
@@ -355,6 +357,42 @@ It is similar to an array, in that editors can add and remove items in it, howev
355
357
  s.record(t.number()); // <- Schema<Record<string, number>>
356
358
  ```
357
359
 
360
+ ## Router
361
+
362
+ The `router` schema is a convenient shorthand for creating a record with router configuration. It combines `s.record()` and `.router()` into a single call.
363
+
364
+ ```ts
365
+ import { s, c, nextAppRouter } from "../val.config";
366
+
367
+ const pageSchema = s.object({ title: s.string() });
368
+
369
+ // Using s.router() - shorthand
370
+ const pagesSchema = s.router(nextAppRouter, pageSchema);
371
+
372
+ // Equivalent to:
373
+ const pagesSchema = s.record(pageSchema).router(nextAppRouter);
374
+ ```
375
+
376
+ ### Example:
377
+
378
+ ```ts
379
+ import { s, c, nextAppRouter } from "../val.config";
380
+
381
+ const pageSchema = s.object({ title: s.string() });
382
+
383
+ // NOTE: to use router(nextAppRouter) - the module must be a sibling of the page.tsx
384
+ export default c.define(
385
+ "/app/[slug]/page.val.ts",
386
+ s.router(nextAppRouter, pageSchema),
387
+ {
388
+ "/test-page": {
389
+ // This is the full pathname of the page - it must match the pattern of the Next JS route
390
+ title: "Test page",
391
+ },
392
+ },
393
+ );
394
+ ```
395
+
358
396
  ## Object
359
397
 
360
398
  ```ts
@@ -363,7 +401,7 @@ s.object({
363
401
  });
364
402
  ```
365
403
 
366
- #### Page router
404
+ #### Page router (using .router() method)
367
405
 
368
406
  You can configure Val to track your page structure and display content as navigable web pages in the editor interface.
369
407
 
@@ -774,6 +812,57 @@ const authors = useVal(otherVal); // s.record(s.object({ name: s.string() }))
774
812
  const nameOfAuthor = authors[articleVal.author].name;
775
813
  ```
776
814
 
815
+ ## Route
816
+
817
+ The `route` schema represents a string that references a route path in your application. It can be used with `include` and `exclude` patterns to constrain which routes are valid.
818
+
819
+ ### Route Schema
820
+
821
+ ```ts
822
+ s.route(); // <- Schema<string>
823
+ ```
824
+
825
+ ### Route with patterns
826
+
827
+ You can use `include` and `exclude` to constrain valid routes using regular expressions:
828
+
829
+ ```ts
830
+ // Only allow API routes
831
+ s.route().include(/^\/api\//);
832
+
833
+ // Exclude admin routes
834
+ s.route().exclude(/^\/admin\//);
835
+
836
+ // Combine both: API routes except internal ones
837
+ s.route()
838
+ .include(/^\/api\//)
839
+ .exclude(/^\/api\/internal\//);
840
+ ```
841
+
842
+ **Pattern semantics:**
843
+
844
+ - If only `include` is set: route must match the include pattern
845
+ - If only `exclude` is set: route must NOT match the exclude pattern
846
+ - If both are set: route must match include AND must NOT match exclude
847
+
848
+ ### Using routes
849
+
850
+ Routes are validated against router modules (records with `.router()` or `s.router()`). The route value must exist as a key in one of your router modules.
851
+
852
+ ```ts
853
+ import { s, c } from "../val.config";
854
+
855
+ const linkSchema = s.object({
856
+ label: s.string(),
857
+ href: s.route().include(/^\//), // Only allow routes starting with /
858
+ });
859
+
860
+ export default c.define("/components/link.val.ts", linkSchema, {
861
+ label: "Home",
862
+ href: "/", // This must exist in a router module
863
+ });
864
+ ```
865
+
777
866
  # Custom validation
778
867
 
779
868
  All schema can use the `validate` method to show custom validation errors to editors.
@@ -22,6 +22,25 @@ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e };
22
22
  var Script__default = /*#__PURE__*/_interopDefault(Script);
23
23
  var React__default = /*#__PURE__*/_interopDefault(React);
24
24
 
25
+ function initSessionTheme(config) {
26
+ if (typeof window === "undefined") {
27
+ return null;
28
+ }
29
+ var existingSessionTheme = sessionStorage.getItem(internal.VAL_THEME_SESSION_STORAGE_KEY);
30
+ if (existingSessionTheme && (existingSessionTheme === "dark" || existingSessionTheme === "light")) {
31
+ return existingSessionTheme;
32
+ }
33
+ var storedTheme = localStorage.getItem("val-theme-" + ((config === null || config === void 0 ? void 0 : config.project) || "unknown"));
34
+ var theme = "dark";
35
+ if (storedTheme === "light" || storedTheme === "dark") {
36
+ theme = storedTheme;
37
+ } else if ((config === null || config === void 0 ? void 0 : config.defaultTheme) === "dark" || (config === null || config === void 0 ? void 0 : config.defaultTheme) === "light") {
38
+ theme = config.defaultTheme;
39
+ }
40
+ sessionStorage.setItem(internal.VAL_THEME_SESSION_STORAGE_KEY, theme);
41
+ return theme;
42
+ }
43
+
25
44
  var ValNextProvider = function ValNextProvider(props) {
26
45
  // TODO: use config:
27
46
  var route = "/api/val";
@@ -263,6 +282,9 @@ var ValNextProvider = function ValNextProvider(props) {
263
282
  }
264
283
  }, []);
265
284
  cssUtils.useConfigStorageSave(props.config);
285
+ var initTheme = React__default["default"].useMemo(function () {
286
+ return initSessionTheme(props.config);
287
+ }, [props.config]);
266
288
  var _React$useState1 = React__default["default"].useState(false),
267
289
  _React$useState10 = slicedToArray._slicedToArray(_React$useState1, 2),
268
290
  spaLoaded = _React$useState10[0],
@@ -276,11 +298,21 @@ var ValNextProvider = function ValNextProvider(props) {
276
298
  window.removeEventListener("val-ui-created", listener);
277
299
  };
278
300
  }, []);
301
+ var _React$useMemo = React__default["default"].useMemo(function () {
302
+ if (initTheme !== "light") {
303
+ return ["#0c111d", "white"];
304
+ } else {
305
+ return ["white", "black"];
306
+ }
307
+ }, [initTheme]),
308
+ _React$useMemo2 = slicedToArray._slicedToArray(_React$useMemo, 2),
309
+ backgroundColor = _React$useMemo2[0],
310
+ textColor = _React$useMemo2[1];
279
311
  var commonStyles = React__default["default"].useMemo(function () {
280
312
  return {
281
313
  "backdrop-blur": "backdrop-filter: blur(10px);",
282
- "text-white": "color: white;",
283
- "bg-bg-primary": "background: #0c111d;",
314
+ "text-text-primary": "color: ".concat(textColor, ";"),
315
+ "bg-bg-primary": "background: ".concat(backgroundColor, ";"),
284
316
  rounded: "border-radius: 0.25rem;",
285
317
  fixed: "position: fixed;",
286
318
  "bottom-4": "bottom: 1rem;",
@@ -297,13 +329,13 @@ var ValNextProvider = function ValNextProvider(props) {
297
329
  return /*#__PURE__*/jsxRuntime.jsxs(ValOverlayContext.ValOverlayProvider, {
298
330
  draftMode: draftMode,
299
331
  store: valStore,
300
- children: [props.children, dropZone !== null && !spaLoaded && mountOverlay && /*#__PURE__*/jsxRuntime.jsxs(React__default["default"].Fragment, {
332
+ children: [props.children, dropZone !== null && !spaLoaded && mountOverlay && initTheme !== null && /*#__PURE__*/jsxRuntime.jsxs(React__default["default"].Fragment, {
301
333
  children: [/*#__PURE__*/jsxRuntime.jsx("style", {
302
334
  children: "\n".concat(positionStyles, "\n").concat(cssUtils.prefixStyles(commonStyles), "\n@keyframes rotate-clock {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n}\n")
303
335
  }), /*#__PURE__*/jsxRuntime.jsx("div", {
304
336
  className: "".concat(getPositionClassName(dropZone), " ").concat(cssUtils.cn(["p-4"])),
305
337
  children: /*#__PURE__*/jsxRuntime.jsx("div", {
306
- className: "".concat(cssUtils.cn(["flex", "justify-center", "items-center", "p-2"]), " ") + "".concat(cssUtils.cn(["text-white", "bg-bg-primary", "rounded", "backdrop-blur"])),
338
+ className: "".concat(cssUtils.cn(["flex", "justify-center", "items-center", "p-2"]), " ") + "".concat(cssUtils.cn(["text-text-primary", "bg-bg-primary", "rounded", "backdrop-blur"])),
307
339
  children: /*#__PURE__*/jsxRuntime.jsxs("svg", {
308
340
  xmlns: "http://www.w3.org/2000/svg",
309
341
  width: "16",
@@ -8,11 +8,30 @@ import Script from 'next/script';
8
8
  import React from 'react';
9
9
  import { ValExternalStore, ValOverlayProvider } from './ValOverlayContext-6635a4d7.esm.js';
10
10
  import { SET_AUTO_TAG_JSX_ENABLED } from '@valbuild/react/stega';
11
- import { createValClient } from '@valbuild/shared/internal';
11
+ import { VAL_THEME_SESSION_STORAGE_KEY, createValClient } from '@valbuild/shared/internal';
12
12
  import { p as prefixStyles, u as useConfigStorageSave, v as valPrefixedClass, c as cn } from './cssUtils-b5651c03.esm.js';
13
13
  import { jsxs, jsx } from 'react/jsx-runtime';
14
14
  import './unsupportedIterableToArray-5baabfdc.esm.js';
15
15
 
16
+ function initSessionTheme(config) {
17
+ if (typeof window === "undefined") {
18
+ return null;
19
+ }
20
+ var existingSessionTheme = sessionStorage.getItem(VAL_THEME_SESSION_STORAGE_KEY);
21
+ if (existingSessionTheme && (existingSessionTheme === "dark" || existingSessionTheme === "light")) {
22
+ return existingSessionTheme;
23
+ }
24
+ var storedTheme = localStorage.getItem("val-theme-" + ((config === null || config === void 0 ? void 0 : config.project) || "unknown"));
25
+ var theme = "dark";
26
+ if (storedTheme === "light" || storedTheme === "dark") {
27
+ theme = storedTheme;
28
+ } else if ((config === null || config === void 0 ? void 0 : config.defaultTheme) === "dark" || (config === null || config === void 0 ? void 0 : config.defaultTheme) === "light") {
29
+ theme = config.defaultTheme;
30
+ }
31
+ sessionStorage.setItem(VAL_THEME_SESSION_STORAGE_KEY, theme);
32
+ return theme;
33
+ }
34
+
16
35
  var ValNextProvider = function ValNextProvider(props) {
17
36
  // TODO: use config:
18
37
  var route = "/api/val";
@@ -254,6 +273,9 @@ var ValNextProvider = function ValNextProvider(props) {
254
273
  }
255
274
  }, []);
256
275
  useConfigStorageSave(props.config);
276
+ var initTheme = React.useMemo(function () {
277
+ return initSessionTheme(props.config);
278
+ }, [props.config]);
257
279
  var _React$useState1 = React.useState(false),
258
280
  _React$useState10 = _slicedToArray(_React$useState1, 2),
259
281
  spaLoaded = _React$useState10[0],
@@ -267,11 +289,21 @@ var ValNextProvider = function ValNextProvider(props) {
267
289
  window.removeEventListener("val-ui-created", listener);
268
290
  };
269
291
  }, []);
292
+ var _React$useMemo = React.useMemo(function () {
293
+ if (initTheme !== "light") {
294
+ return ["#0c111d", "white"];
295
+ } else {
296
+ return ["white", "black"];
297
+ }
298
+ }, [initTheme]),
299
+ _React$useMemo2 = _slicedToArray(_React$useMemo, 2),
300
+ backgroundColor = _React$useMemo2[0],
301
+ textColor = _React$useMemo2[1];
270
302
  var commonStyles = React.useMemo(function () {
271
303
  return {
272
304
  "backdrop-blur": "backdrop-filter: blur(10px);",
273
- "text-white": "color: white;",
274
- "bg-bg-primary": "background: #0c111d;",
305
+ "text-text-primary": "color: ".concat(textColor, ";"),
306
+ "bg-bg-primary": "background: ".concat(backgroundColor, ";"),
275
307
  rounded: "border-radius: 0.25rem;",
276
308
  fixed: "position: fixed;",
277
309
  "bottom-4": "bottom: 1rem;",
@@ -288,13 +320,13 @@ var ValNextProvider = function ValNextProvider(props) {
288
320
  return /*#__PURE__*/jsxs(ValOverlayProvider, {
289
321
  draftMode: draftMode,
290
322
  store: valStore,
291
- children: [props.children, dropZone !== null && !spaLoaded && mountOverlay && /*#__PURE__*/jsxs(React.Fragment, {
323
+ children: [props.children, dropZone !== null && !spaLoaded && mountOverlay && initTheme !== null && /*#__PURE__*/jsxs(React.Fragment, {
292
324
  children: [/*#__PURE__*/jsx("style", {
293
325
  children: "\n".concat(positionStyles, "\n").concat(prefixStyles(commonStyles), "\n@keyframes rotate-clock {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n}\n")
294
326
  }), /*#__PURE__*/jsx("div", {
295
327
  className: "".concat(getPositionClassName(dropZone), " ").concat(cn(["p-4"])),
296
328
  children: /*#__PURE__*/jsx("div", {
297
- className: "".concat(cn(["flex", "justify-center", "items-center", "p-2"]), " ") + "".concat(cn(["text-white", "bg-bg-primary", "rounded", "backdrop-blur"])),
329
+ className: "".concat(cn(["flex", "justify-center", "items-center", "p-2"]), " ") + "".concat(cn(["text-text-primary", "bg-bg-primary", "rounded", "backdrop-blur"])),
298
330
  children: /*#__PURE__*/jsxs("svg", {
299
331
  xmlns: "http://www.w3.org/2000/svg",
300
332
  width: "16",
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ if (process.env.NODE_ENV === "production") {
4
+ module.exports = require("./ValNextProvider-96d1c795.cjs.prod.js");
5
+ } else {
6
+ module.exports = require("./ValNextProvider-96d1c795.cjs.dev.js");
7
+ }
@@ -22,6 +22,25 @@ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e };
22
22
  var Script__default = /*#__PURE__*/_interopDefault(Script);
23
23
  var React__default = /*#__PURE__*/_interopDefault(React);
24
24
 
25
+ function initSessionTheme(config) {
26
+ if (typeof window === "undefined") {
27
+ return null;
28
+ }
29
+ var existingSessionTheme = sessionStorage.getItem(internal.VAL_THEME_SESSION_STORAGE_KEY);
30
+ if (existingSessionTheme && (existingSessionTheme === "dark" || existingSessionTheme === "light")) {
31
+ return existingSessionTheme;
32
+ }
33
+ var storedTheme = localStorage.getItem("val-theme-" + ((config === null || config === void 0 ? void 0 : config.project) || "unknown"));
34
+ var theme = "dark";
35
+ if (storedTheme === "light" || storedTheme === "dark") {
36
+ theme = storedTheme;
37
+ } else if ((config === null || config === void 0 ? void 0 : config.defaultTheme) === "dark" || (config === null || config === void 0 ? void 0 : config.defaultTheme) === "light") {
38
+ theme = config.defaultTheme;
39
+ }
40
+ sessionStorage.setItem(internal.VAL_THEME_SESSION_STORAGE_KEY, theme);
41
+ return theme;
42
+ }
43
+
25
44
  var ValNextProvider = function ValNextProvider(props) {
26
45
  // TODO: use config:
27
46
  var route = "/api/val";
@@ -263,6 +282,9 @@ var ValNextProvider = function ValNextProvider(props) {
263
282
  }
264
283
  }, []);
265
284
  cssUtils.useConfigStorageSave(props.config);
285
+ var initTheme = React__default["default"].useMemo(function () {
286
+ return initSessionTheme(props.config);
287
+ }, [props.config]);
266
288
  var _React$useState1 = React__default["default"].useState(false),
267
289
  _React$useState10 = slicedToArray._slicedToArray(_React$useState1, 2),
268
290
  spaLoaded = _React$useState10[0],
@@ -276,11 +298,21 @@ var ValNextProvider = function ValNextProvider(props) {
276
298
  window.removeEventListener("val-ui-created", listener);
277
299
  };
278
300
  }, []);
301
+ var _React$useMemo = React__default["default"].useMemo(function () {
302
+ if (initTheme !== "light") {
303
+ return ["#0c111d", "white"];
304
+ } else {
305
+ return ["white", "black"];
306
+ }
307
+ }, [initTheme]),
308
+ _React$useMemo2 = slicedToArray._slicedToArray(_React$useMemo, 2),
309
+ backgroundColor = _React$useMemo2[0],
310
+ textColor = _React$useMemo2[1];
279
311
  var commonStyles = React__default["default"].useMemo(function () {
280
312
  return {
281
313
  "backdrop-blur": "backdrop-filter: blur(10px);",
282
- "text-white": "color: white;",
283
- "bg-bg-primary": "background: #0c111d;",
314
+ "text-text-primary": "color: ".concat(textColor, ";"),
315
+ "bg-bg-primary": "background: ".concat(backgroundColor, ";"),
284
316
  rounded: "border-radius: 0.25rem;",
285
317
  fixed: "position: fixed;",
286
318
  "bottom-4": "bottom: 1rem;",
@@ -297,13 +329,13 @@ var ValNextProvider = function ValNextProvider(props) {
297
329
  return /*#__PURE__*/jsxRuntime.jsxs(ValOverlayContext.ValOverlayProvider, {
298
330
  draftMode: draftMode,
299
331
  store: valStore,
300
- children: [props.children, dropZone !== null && !spaLoaded && mountOverlay && /*#__PURE__*/jsxRuntime.jsxs(React__default["default"].Fragment, {
332
+ children: [props.children, dropZone !== null && !spaLoaded && mountOverlay && initTheme !== null && /*#__PURE__*/jsxRuntime.jsxs(React__default["default"].Fragment, {
301
333
  children: [/*#__PURE__*/jsxRuntime.jsx("style", {
302
334
  children: "\n".concat(positionStyles, "\n").concat(cssUtils.prefixStyles(commonStyles), "\n@keyframes rotate-clock {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n}\n")
303
335
  }), /*#__PURE__*/jsxRuntime.jsx("div", {
304
336
  className: "".concat(getPositionClassName(dropZone), " ").concat(cssUtils.cn(["p-4"])),
305
337
  children: /*#__PURE__*/jsxRuntime.jsx("div", {
306
- className: "".concat(cssUtils.cn(["flex", "justify-center", "items-center", "p-2"]), " ") + "".concat(cssUtils.cn(["text-white", "bg-bg-primary", "rounded", "backdrop-blur"])),
338
+ className: "".concat(cssUtils.cn(["flex", "justify-center", "items-center", "p-2"]), " ") + "".concat(cssUtils.cn(["text-text-primary", "bg-bg-primary", "rounded", "backdrop-blur"])),
307
339
  children: /*#__PURE__*/jsxRuntime.jsxs("svg", {
308
340
  xmlns: "http://www.w3.org/2000/svg",
309
341
  width: "16",
@@ -0,0 +1,4 @@
1
+ export type ValAttrs = {
2
+ "data-val-path"?: string;
3
+ };
4
+ export declare function attrs(target: unknown): ValAttrs;
@@ -0,0 +1,2 @@
1
+ import { ValEncodedString } from "@valbuild/react/stega";
2
+ export declare function decodeValPathsOfString(encodedString: ValEncodedString): string[] | undefined;
@@ -1,10 +1,8 @@
1
- import { type ValConfig, type InitVal, type ValConstructor, ValModule, SelectorSource, Json, ValRouter } from "@valbuild/core";
1
+ import { type ValConfig, type InitVal, type ValConstructor, ValRouter } from "@valbuild/core";
2
2
  import { raw } from "./raw.js";
3
3
  import { getUnpatchedUnencodedVal } from "./getUnpatchedUnencodedVal.js";
4
- import { decodeValPathOfString } from "./decodeValPathOfString.js";
5
- type ValAttrs = {
6
- "data-val-path"?: string;
7
- };
4
+ import { decodeValPathsOfString } from "./decodeValPathsOfString.js";
5
+ import { attrs } from "./attrs.js";
8
6
  declare const nextAppRouter: ValRouter;
9
7
  export declare const initVal: (config?: ValConfig) => InitVal & {
10
8
  val: ValConstructor & {
@@ -21,10 +19,36 @@ export declare const initVal: (config?: ValConfig) => InitVal & {
21
19
  * outside of the actual application.
22
20
  */
23
21
  unstable_getUnpatchedUnencodedVal: typeof getUnpatchedUnencodedVal;
22
+ /**
23
+ * Convert any object that is encoded with Val stega encoding back to the original values
24
+ */
24
25
  raw: typeof raw;
25
- attrs: <T extends ValModule<SelectorSource> | Json>(target: T) => ValAttrs;
26
- unstable_decodeValPathOfString: typeof decodeValPathOfString;
26
+ /**
27
+ * Get the Val paths of attributes for any object.
28
+ *
29
+ * This is typically used to manually set the data-val-path attribute for visual editing on any element.
30
+ *
31
+ * @example
32
+ * const page = useVal(pageVal)
33
+ * <a href={page.url.href} {...val.attrs(page)}>
34
+ * {page.url.label}
35
+ * </a>
36
+ */
37
+ attrs: typeof attrs;
38
+ unstable_decodeValPathsOfString: typeof decodeValPathsOfString;
27
39
  };
40
+ /**
41
+ * The Next.js App Router for use on s.record().router(...)
42
+ *
43
+ * @see https://val.build/docs/page-router
44
+ *
45
+ * @example
46
+ * const pages = s.record(s.object({ title: s.string() })).router(nextAppRouter);
47
+ * export default c.define("/pages/[slug].val.ts", pages, {
48
+ * "/about": { title: "About" },
49
+ * "/contact": { title: "Contact" },
50
+ * });
51
+ */
28
52
  nextAppRouter: ValRouter;
29
53
  };
30
54
  export {};
@@ -2,16 +2,18 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var _typeof = require('./typeof-b568f48f.cjs.dev.js');
6
5
  var objectSpread2 = require('./objectSpread2-792eb2c2.cjs.dev.js');
7
6
  var core = require('@valbuild/core');
7
+ var _typeof = require('./typeof-b568f48f.cjs.dev.js');
8
8
  var stega = require('@valbuild/react/stega');
9
+ var createForOfIteratorHelper = require('./createForOfIteratorHelper-0445603c.cjs.dev.js');
9
10
  var internal = require('@valbuild/react/internal');
10
- var ValNextProvider = require('./ValNextProvider-579b1e3d.cjs.dev.js');
11
+ var ValNextProvider = require('./ValNextProvider-145cfd3a.cjs.dev.js');
11
12
  var NextImage = require('next/image');
12
13
  var jsxRuntime = require('react/jsx-runtime');
13
14
  var ValApp = require('./ValApp-3df36e0d.cjs.dev.js');
14
15
  var version = require('./version-82faa1d0.cjs.dev.js');
16
+ require('./unsupportedIterableToArray-c8ab77c9.cjs.dev.js');
15
17
 
16
18
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
17
19
 
@@ -65,8 +67,45 @@ function getUnpatchedUnencodedVal(selector) {
65
67
  });
66
68
  }
67
69
 
68
- function decodeValPathOfString(encodedString) {
69
- return stega.stegaDecodeString(encodedString);
70
+ function decodeValPathsOfString(encodedString) {
71
+ return stega.stegaDecodeStrings(encodedString);
72
+ }
73
+
74
+ function attrs(target) {
75
+ var allPaths = new Set();
76
+ function addPath(target) {
77
+ if (typeof target === "string") {
78
+ var paths = decodeValPathsOfString(target);
79
+ if (paths) {
80
+ var _iterator = createForOfIteratorHelper._createForOfIteratorHelper(paths),
81
+ _step;
82
+ try {
83
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
84
+ var path = _step.value;
85
+ allPaths.add(path);
86
+ }
87
+ } catch (err) {
88
+ _iterator.e(err);
89
+ } finally {
90
+ _iterator.f();
91
+ }
92
+ }
93
+ }
94
+ if (_typeof._typeof(target) === "object" && target !== null) {
95
+ var _path = core.Internal.getValPath(target);
96
+ if (_path) {
97
+ allPaths.add(_path);
98
+ }
99
+ Object.values(target).forEach(addPath);
100
+ }
101
+ }
102
+ addPath(target);
103
+ if (allPaths.size === 0) {
104
+ return {};
105
+ }
106
+ return {
107
+ "data-val-path": Array.from(allPaths).join(",")
108
+ };
70
109
  }
71
110
 
72
111
  var nextAppRouter = core.Internal.nextAppRouter;
@@ -82,28 +121,8 @@ var initVal = function initVal(config) {
82
121
  c: c,
83
122
  nextAppRouter: nextAppRouter,
84
123
  val: objectSpread2._objectSpread2(objectSpread2._objectSpread2({}, val), {}, {
85
- attrs: function attrs(target) {
86
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
87
- var anyTarget = target;
88
- var path;
89
- if (target === null) {
90
- return {};
91
- }
92
- path = core.Internal.getValPath(anyTarget);
93
- if (!path && _typeof._typeof(anyTarget) === "object") {
94
- path = anyTarget["valPath"];
95
- }
96
- if (typeof anyTarget === "string") {
97
- path = decodeValPathOfString(anyTarget);
98
- }
99
- if (path) {
100
- return {
101
- "data-val-path": path
102
- };
103
- }
104
- return {};
105
- },
106
- unstable_decodeValPathOfString: decodeValPathOfString,
124
+ attrs: attrs,
125
+ unstable_decodeValPathsOfString: decodeValPathsOfString,
107
126
  raw: raw,
108
127
  unstable_getUnpatchedUnencodedVal: getUnpatchedUnencodedVal
109
128
  }),
@@ -145,11 +164,22 @@ function ValImage(props) {
145
164
  disableHotspot = props.disableHotspot,
146
165
  height = props.height,
147
166
  rest = _objectWithoutProperties(props, _excluded);
148
- var valPathOfUrl = (src === null || src === void 0 ? void 0 : src.url) && decodeValPathOfString(src.url);
149
- var valPaths = [valPathOfUrl];
150
- var maybeValPathOfAlt = decodeValPathOfString(alt);
167
+ var valPathsOfUrl = src !== null && src !== void 0 && src.url ? decodeValPathsOfString(src.url) : undefined;
168
+ var valPaths = valPathsOfUrl ? valPathsOfUrl : [];
169
+ var maybeValPathOfAlt = alt ? decodeValPathsOfString(alt) : undefined;
151
170
  if (maybeValPathOfAlt) {
152
- valPaths.push(maybeValPathOfAlt);
171
+ var _iterator = createForOfIteratorHelper._createForOfIteratorHelper(maybeValPathOfAlt),
172
+ _step;
173
+ try {
174
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
175
+ var valPath = _step.value;
176
+ valPaths.push(valPath);
177
+ }
178
+ } catch (err) {
179
+ _iterator.e(err);
180
+ } finally {
181
+ _iterator.f();
182
+ }
153
183
  }
154
184
  var hotspot = src === null || src === void 0 || (_src$metadata = src.metadata) === null || _src$metadata === void 0 ? void 0 : _src$metadata.hotspot;
155
185
  var imageStyle = hotspot && !disableHotspot ? objectSpread2._objectSpread2(objectSpread2._objectSpread2({}, style), {}, {
@@ -164,10 +194,10 @@ function ValImage(props) {
164
194
  lazyBoundary: undefined,
165
195
  lazyRoot: undefined
166
196
  })), {}, {
167
- src: valPathOfUrl ? raw(src === null || src === void 0 ? void 0 : src.url) : src === null || src === void 0 ? void 0 : src.url,
197
+ src: valPathsOfUrl && valPathsOfUrl.length > 0 ? raw(src === null || src === void 0 ? void 0 : src.url) : src === null || src === void 0 ? void 0 : src.url,
168
198
  "data-val-path": valPaths.join(","),
169
199
  "data-val-attr-alt": maybeValPathOfAlt,
170
- "data-val-attr-src": valPathOfUrl,
200
+ "data-val-attr-src": valPathsOfUrl && valPathsOfUrl.length > 0 ? valPathsOfUrl.join(",") : undefined,
171
201
  style: imageStyle,
172
202
  alt: alt ? raw(alt) : src !== null && src !== void 0 && (_src$metadata3 = src.metadata) !== null && _src$metadata3 !== void 0 && _src$metadata3.alt ? raw(src === null || src === void 0 || (_src$metadata4 = src.metadata) === null || _src$metadata4 === void 0 ? void 0 : _src$metadata4.alt) : "",
173
203
  fill: rest.fill,
@@ -2,16 +2,18 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var _typeof = require('./typeof-16428c61.cjs.prod.js');
6
5
  var objectSpread2 = require('./objectSpread2-3c87fb4f.cjs.prod.js');
7
6
  var core = require('@valbuild/core');
7
+ var _typeof = require('./typeof-16428c61.cjs.prod.js');
8
8
  var stega = require('@valbuild/react/stega');
9
+ var createForOfIteratorHelper = require('./createForOfIteratorHelper-d4afcad8.cjs.prod.js');
9
10
  var internal = require('@valbuild/react/internal');
10
- var ValNextProvider = require('./ValNextProvider-af07de36.cjs.prod.js');
11
+ var ValNextProvider = require('./ValNextProvider-96d1c795.cjs.prod.js');
11
12
  var NextImage = require('next/image');
12
13
  var jsxRuntime = require('react/jsx-runtime');
13
14
  var ValApp = require('./ValApp-22147086.cjs.prod.js');
14
15
  var version = require('./version-a9a6a619.cjs.prod.js');
16
+ require('./unsupportedIterableToArray-0d2087a2.cjs.prod.js');
15
17
 
16
18
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
17
19
 
@@ -65,8 +67,45 @@ function getUnpatchedUnencodedVal(selector) {
65
67
  });
66
68
  }
67
69
 
68
- function decodeValPathOfString(encodedString) {
69
- return stega.stegaDecodeString(encodedString);
70
+ function decodeValPathsOfString(encodedString) {
71
+ return stega.stegaDecodeStrings(encodedString);
72
+ }
73
+
74
+ function attrs(target) {
75
+ var allPaths = new Set();
76
+ function addPath(target) {
77
+ if (typeof target === "string") {
78
+ var paths = decodeValPathsOfString(target);
79
+ if (paths) {
80
+ var _iterator = createForOfIteratorHelper._createForOfIteratorHelper(paths),
81
+ _step;
82
+ try {
83
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
84
+ var path = _step.value;
85
+ allPaths.add(path);
86
+ }
87
+ } catch (err) {
88
+ _iterator.e(err);
89
+ } finally {
90
+ _iterator.f();
91
+ }
92
+ }
93
+ }
94
+ if (_typeof._typeof(target) === "object" && target !== null) {
95
+ var _path = core.Internal.getValPath(target);
96
+ if (_path) {
97
+ allPaths.add(_path);
98
+ }
99
+ Object.values(target).forEach(addPath);
100
+ }
101
+ }
102
+ addPath(target);
103
+ if (allPaths.size === 0) {
104
+ return {};
105
+ }
106
+ return {
107
+ "data-val-path": Array.from(allPaths).join(",")
108
+ };
70
109
  }
71
110
 
72
111
  var nextAppRouter = core.Internal.nextAppRouter;
@@ -82,28 +121,8 @@ var initVal = function initVal(config) {
82
121
  c: c,
83
122
  nextAppRouter: nextAppRouter,
84
123
  val: objectSpread2._objectSpread2(objectSpread2._objectSpread2({}, val), {}, {
85
- attrs: function attrs(target) {
86
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
87
- var anyTarget = target;
88
- var path;
89
- if (target === null) {
90
- return {};
91
- }
92
- path = core.Internal.getValPath(anyTarget);
93
- if (!path && _typeof._typeof(anyTarget) === "object") {
94
- path = anyTarget["valPath"];
95
- }
96
- if (typeof anyTarget === "string") {
97
- path = decodeValPathOfString(anyTarget);
98
- }
99
- if (path) {
100
- return {
101
- "data-val-path": path
102
- };
103
- }
104
- return {};
105
- },
106
- unstable_decodeValPathOfString: decodeValPathOfString,
124
+ attrs: attrs,
125
+ unstable_decodeValPathsOfString: decodeValPathsOfString,
107
126
  raw: raw,
108
127
  unstable_getUnpatchedUnencodedVal: getUnpatchedUnencodedVal
109
128
  }),
@@ -145,11 +164,22 @@ function ValImage(props) {
145
164
  disableHotspot = props.disableHotspot,
146
165
  height = props.height,
147
166
  rest = _objectWithoutProperties(props, _excluded);
148
- var valPathOfUrl = (src === null || src === void 0 ? void 0 : src.url) && decodeValPathOfString(src.url);
149
- var valPaths = [valPathOfUrl];
150
- var maybeValPathOfAlt = decodeValPathOfString(alt);
167
+ var valPathsOfUrl = src !== null && src !== void 0 && src.url ? decodeValPathsOfString(src.url) : undefined;
168
+ var valPaths = valPathsOfUrl ? valPathsOfUrl : [];
169
+ var maybeValPathOfAlt = alt ? decodeValPathsOfString(alt) : undefined;
151
170
  if (maybeValPathOfAlt) {
152
- valPaths.push(maybeValPathOfAlt);
171
+ var _iterator = createForOfIteratorHelper._createForOfIteratorHelper(maybeValPathOfAlt),
172
+ _step;
173
+ try {
174
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
175
+ var valPath = _step.value;
176
+ valPaths.push(valPath);
177
+ }
178
+ } catch (err) {
179
+ _iterator.e(err);
180
+ } finally {
181
+ _iterator.f();
182
+ }
153
183
  }
154
184
  var hotspot = src === null || src === void 0 || (_src$metadata = src.metadata) === null || _src$metadata === void 0 ? void 0 : _src$metadata.hotspot;
155
185
  var imageStyle = hotspot && !disableHotspot ? objectSpread2._objectSpread2(objectSpread2._objectSpread2({}, style), {}, {
@@ -164,10 +194,10 @@ function ValImage(props) {
164
194
  lazyBoundary: undefined,
165
195
  lazyRoot: undefined
166
196
  })), {}, {
167
- src: valPathOfUrl ? raw(src === null || src === void 0 ? void 0 : src.url) : src === null || src === void 0 ? void 0 : src.url,
197
+ src: valPathsOfUrl && valPathsOfUrl.length > 0 ? raw(src === null || src === void 0 ? void 0 : src.url) : src === null || src === void 0 ? void 0 : src.url,
168
198
  "data-val-path": valPaths.join(","),
169
199
  "data-val-attr-alt": maybeValPathOfAlt,
170
- "data-val-attr-src": valPathOfUrl,
200
+ "data-val-attr-src": valPathsOfUrl && valPathsOfUrl.length > 0 ? valPathsOfUrl.join(",") : undefined,
171
201
  style: imageStyle,
172
202
  alt: alt ? raw(alt) : src !== null && src !== void 0 && (_src$metadata3 = src.metadata) !== null && _src$metadata3 !== void 0 && _src$metadata3.alt ? raw(src === null || src === void 0 || (_src$metadata4 = src.metadata) === null || _src$metadata4 === void 0 ? void 0 : _src$metadata4.alt) : "",
173
203
  fill: rest.fill,
@@ -1,16 +1,18 @@
1
- import { _ as _typeof } from './typeof-a1531d8f.esm.js';
2
1
  import { _ as _objectSpread2 } from './objectSpread2-c1340c1c.esm.js';
3
2
  import { Internal as Internal$1, initVal as initVal$1 } from '@valbuild/core';
4
3
  import * as core from '@valbuild/core';
5
4
  export { core as expr };
6
5
  export { FILE_REF_PROP, GenericSelector, Schema, VAL_EXTENSION, derefPatch, modules } from '@valbuild/core';
7
- import { stegaClean, stegaEncode, stegaDecodeString, autoTagJSX } from '@valbuild/react/stega';
6
+ import { _ as _typeof } from './typeof-a1531d8f.esm.js';
7
+ import { stegaClean, stegaEncode, stegaDecodeStrings, autoTagJSX } from '@valbuild/react/stega';
8
+ import { _ as _createForOfIteratorHelper } from './createForOfIteratorHelper-5758a730.esm.js';
8
9
  export { ValRichText } from '@valbuild/react/internal';
9
- import { ValNextProvider } from './ValNextProvider-abf09691.esm.js';
10
+ import { ValNextProvider } from './ValNextProvider-25a03cab.esm.js';
10
11
  import NextImage from 'next/image';
11
12
  import { jsx } from 'react/jsx-runtime';
12
13
  export { ValApp } from './ValApp-e2e1dfed.esm.js';
13
14
  import { V as VERSION } from './version-98ec5c7a.esm.js';
15
+ import './unsupportedIterableToArray-5baabfdc.esm.js';
14
16
 
15
17
  function raw(val) {
16
18
  if (typeof val === "string") {
@@ -41,8 +43,45 @@ function getUnpatchedUnencodedVal(selector) {
41
43
  });
42
44
  }
43
45
 
44
- function decodeValPathOfString(encodedString) {
45
- return stegaDecodeString(encodedString);
46
+ function decodeValPathsOfString(encodedString) {
47
+ return stegaDecodeStrings(encodedString);
48
+ }
49
+
50
+ function attrs(target) {
51
+ var allPaths = new Set();
52
+ function addPath(target) {
53
+ if (typeof target === "string") {
54
+ var paths = decodeValPathsOfString(target);
55
+ if (paths) {
56
+ var _iterator = _createForOfIteratorHelper(paths),
57
+ _step;
58
+ try {
59
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
60
+ var path = _step.value;
61
+ allPaths.add(path);
62
+ }
63
+ } catch (err) {
64
+ _iterator.e(err);
65
+ } finally {
66
+ _iterator.f();
67
+ }
68
+ }
69
+ }
70
+ if (_typeof(target) === "object" && target !== null) {
71
+ var _path = Internal$1.getValPath(target);
72
+ if (_path) {
73
+ allPaths.add(_path);
74
+ }
75
+ Object.values(target).forEach(addPath);
76
+ }
77
+ }
78
+ addPath(target);
79
+ if (allPaths.size === 0) {
80
+ return {};
81
+ }
82
+ return {
83
+ "data-val-path": Array.from(allPaths).join(",")
84
+ };
46
85
  }
47
86
 
48
87
  var nextAppRouter = Internal$1.nextAppRouter;
@@ -58,28 +97,8 @@ var initVal = function initVal(config) {
58
97
  c: c,
59
98
  nextAppRouter: nextAppRouter,
60
99
  val: _objectSpread2(_objectSpread2({}, val), {}, {
61
- attrs: function attrs(target) {
62
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
63
- var anyTarget = target;
64
- var path;
65
- if (target === null) {
66
- return {};
67
- }
68
- path = Internal$1.getValPath(anyTarget);
69
- if (!path && _typeof(anyTarget) === "object") {
70
- path = anyTarget["valPath"];
71
- }
72
- if (typeof anyTarget === "string") {
73
- path = decodeValPathOfString(anyTarget);
74
- }
75
- if (path) {
76
- return {
77
- "data-val-path": path
78
- };
79
- }
80
- return {};
81
- },
82
- unstable_decodeValPathOfString: decodeValPathOfString,
100
+ attrs: attrs,
101
+ unstable_decodeValPathsOfString: decodeValPathsOfString,
83
102
  raw: raw,
84
103
  unstable_getUnpatchedUnencodedVal: getUnpatchedUnencodedVal
85
104
  }),
@@ -121,11 +140,22 @@ function ValImage(props) {
121
140
  disableHotspot = props.disableHotspot,
122
141
  height = props.height,
123
142
  rest = _objectWithoutProperties(props, _excluded);
124
- var valPathOfUrl = (src === null || src === void 0 ? void 0 : src.url) && decodeValPathOfString(src.url);
125
- var valPaths = [valPathOfUrl];
126
- var maybeValPathOfAlt = decodeValPathOfString(alt);
143
+ var valPathsOfUrl = src !== null && src !== void 0 && src.url ? decodeValPathsOfString(src.url) : undefined;
144
+ var valPaths = valPathsOfUrl ? valPathsOfUrl : [];
145
+ var maybeValPathOfAlt = alt ? decodeValPathsOfString(alt) : undefined;
127
146
  if (maybeValPathOfAlt) {
128
- valPaths.push(maybeValPathOfAlt);
147
+ var _iterator = _createForOfIteratorHelper(maybeValPathOfAlt),
148
+ _step;
149
+ try {
150
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
151
+ var valPath = _step.value;
152
+ valPaths.push(valPath);
153
+ }
154
+ } catch (err) {
155
+ _iterator.e(err);
156
+ } finally {
157
+ _iterator.f();
158
+ }
129
159
  }
130
160
  var hotspot = src === null || src === void 0 || (_src$metadata = src.metadata) === null || _src$metadata === void 0 ? void 0 : _src$metadata.hotspot;
131
161
  var imageStyle = hotspot && !disableHotspot ? _objectSpread2(_objectSpread2({}, style), {}, {
@@ -140,10 +170,10 @@ function ValImage(props) {
140
170
  lazyBoundary: undefined,
141
171
  lazyRoot: undefined
142
172
  })), {}, {
143
- src: valPathOfUrl ? raw(src === null || src === void 0 ? void 0 : src.url) : src === null || src === void 0 ? void 0 : src.url,
173
+ src: valPathsOfUrl && valPathsOfUrl.length > 0 ? raw(src === null || src === void 0 ? void 0 : src.url) : src === null || src === void 0 ? void 0 : src.url,
144
174
  "data-val-path": valPaths.join(","),
145
175
  "data-val-attr-alt": maybeValPathOfAlt,
146
- "data-val-attr-src": valPathOfUrl,
176
+ "data-val-attr-src": valPathsOfUrl && valPathsOfUrl.length > 0 ? valPathsOfUrl.join(",") : undefined,
147
177
  style: imageStyle,
148
178
  alt: alt ? raw(alt) : src !== null && src !== void 0 && (_src$metadata3 = src.metadata) !== null && _src$metadata3 !== void 0 && _src$metadata3.alt ? raw(src === null || src === void 0 || (_src$metadata4 = src.metadata) === null || _src$metadata4 === void 0 ? void 0 : _src$metadata4.alt) : "",
149
179
  fill: rest.fill,
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",
7
- "url": "https://github.com/valbuild/val.git"
7
+ "url": "git+https://github.com/valbuild/val.git"
8
8
  },
9
9
  "sideEffects": true,
10
10
  "keywords": [
@@ -12,7 +12,7 @@
12
12
  "next",
13
13
  "react"
14
14
  ],
15
- "version": "0.87.5",
15
+ "version": "0.89.0",
16
16
  "scripts": {
17
17
  "typecheck": "tsc --noEmit",
18
18
  "test": "jest"
@@ -49,11 +49,11 @@
49
49
  "exports": true
50
50
  },
51
51
  "dependencies": {
52
- "@valbuild/core": "~0.87.5",
53
- "@valbuild/react": "~0.87.5",
54
- "@valbuild/server": "~0.87.5",
55
- "@valbuild/shared": "~0.87.5",
56
- "@valbuild/ui": "~0.87.5",
52
+ "@valbuild/core": "~0.89.0",
53
+ "@valbuild/react": "~0.89.0",
54
+ "@valbuild/server": "~0.89.0",
55
+ "@valbuild/shared": "~0.89.0",
56
+ "@valbuild/ui": "~0.89.0",
57
57
  "client-only": "^0.0.1",
58
58
  "server-only": "^0.0.1"
59
59
  },
@@ -1,7 +0,0 @@
1
- 'use strict';
2
-
3
- if (process.env.NODE_ENV === "production") {
4
- module.exports = require("./ValNextProvider-af07de36.cjs.prod.js");
5
- } else {
6
- module.exports = require("./ValNextProvider-af07de36.cjs.dev.js");
7
- }
@@ -1,2 +0,0 @@
1
- import { ValEncodedString } from "@valbuild/react/stega";
2
- export declare function decodeValPathOfString(encodedString: ValEncodedString): string | undefined;