@valbuild/react 0.150.5 → 0.150.7

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 (23) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/analytics/dist/valbuild-react-analytics.browser.esm.js +1 -1
  3. package/analytics/dist/valbuild-react-analytics.esm.js +1 -1
  4. package/analytics/dist/valbuild-react-analytics.worker.esm.js +1 -1
  5. package/dist/{createForOfIteratorHelper-36020cf7.browser.esm.js → createForOfIteratorHelper-3316a633.browser.esm.js} +1 -1
  6. package/dist/{createForOfIteratorHelper-02fbe55e.worker.esm.js → createForOfIteratorHelper-548f1578.worker.esm.js} +1 -1
  7. package/dist/{createForOfIteratorHelper-8a8caaf6.esm.js → createForOfIteratorHelper-595d57b7.esm.js} +1 -1
  8. package/dist/{raw-c9cc9df6.esm.js → raw-1b40484b.esm.js} +25 -25
  9. package/dist/{raw-4d8c9599.worker.esm.js → raw-43f9221a.worker.esm.js} +25 -25
  10. package/dist/{raw-d34abe21.browser.esm.js → raw-be4b57fa.browser.esm.js} +25 -25
  11. package/internal/dist/valbuild-react-internal.browser.esm.js +2 -2
  12. package/internal/dist/valbuild-react-internal.cjs.dev.js +1 -1
  13. package/internal/dist/valbuild-react-internal.cjs.prod.js +1 -1
  14. package/internal/dist/valbuild-react-internal.esm.js +2 -2
  15. package/internal/dist/valbuild-react-internal.worker.esm.js +2 -2
  16. package/package.json +2 -2
  17. package/stega/dist/valbuild-react-stega.browser.esm.js +87 -10
  18. package/stega/dist/valbuild-react-stega.cjs.dev.js +85 -8
  19. package/stega/dist/valbuild-react-stega.cjs.prod.js +85 -8
  20. package/stega/dist/valbuild-react-stega.esm.js +87 -10
  21. package/stega/dist/valbuild-react-stega.worker.esm.js +87 -10
  22. package/dist/{raw-1617ec66.cjs.prod.js → raw-b3745603.cjs.prod.js} +24 -24
  23. package/dist/{raw-a62618f3.cjs.dev.js → raw-ff060f24.cjs.dev.js} +24 -24
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @valbuild/react
2
2
 
3
+ ## 0.150.7
4
+
5
+ ### Patch Changes
6
+
7
+ - [#965](https://github.com/valbuild/val/pull/965) [`2d5ad2e`](https://github.com/valbuild/val/commit/2d5ad2e90f2a2bdd6ad8af98b21e19bc0bf6dbcc) Thanks [@freekh](https://github.com/freekh)! - In development, a component that passes its children on to a link or another element -- `<TextLink>{label} →</TextLink>` -- no longer leaves the edit tag in the text. React's development build freezes those children, and Val tagged the element without cleaning its text, so the leak warning named it. Production was not affected.
8
+
9
+ ## 0.150.6
10
+
11
+ ### Patch Changes
12
+
13
+ - [#962](https://github.com/valbuild/val/pull/962) [`f84222b`](https://github.com/valbuild/val/commit/f84222b2c902d8725b1da96f79481060fb8b9842) Thanks [@freekh](https://github.com/freekh)! - Text rendered through `React.createElement` no longer keeps Val's invisible edit tag. TanStack Router's `<Link>` renders its link that way, so with content analytics on, the text of a link built from content carried the tag on every visitor's page.
14
+
15
+ New: `import "@valbuild/tanstack/autotag"` as the first import of `src/router.tsx`. Under `vite dev`, components whose modules ran before `@valbuild/tanstack` was imported were not click-to-edit, and the leak warning named their text as leaked. A production build was not affected.
16
+
3
17
  ## 0.150.5
4
18
 
5
19
  ### Patch Changes
@@ -1,5 +1,5 @@
1
1
  import { _ as _slicedToArray } from '../../dist/slicedToArray-b66ff800.browser.esm.js';
2
- import { a as _toConsumableArray, _ as _createForOfIteratorHelper } from '../../dist/createForOfIteratorHelper-36020cf7.browser.esm.js';
2
+ import { _ as _toConsumableArray, a as _createForOfIteratorHelper } from '../../dist/createForOfIteratorHelper-3316a633.browser.esm.js';
3
3
 
4
4
  /**
5
5
  * The analytics wire format, version 1: what the browser sends to
@@ -1,5 +1,5 @@
1
1
  import { _ as _slicedToArray } from '../../dist/slicedToArray-70ecb9da.esm.js';
2
- import { a as _toConsumableArray, _ as _createForOfIteratorHelper } from '../../dist/createForOfIteratorHelper-8a8caaf6.esm.js';
2
+ import { _ as _toConsumableArray, a as _createForOfIteratorHelper } from '../../dist/createForOfIteratorHelper-595d57b7.esm.js';
3
3
 
4
4
  /**
5
5
  * The analytics wire format, version 1: what the browser sends to
@@ -1,4 +1,4 @@
1
- import { a as _toConsumableArray, _ as _createForOfIteratorHelper } from '../../dist/createForOfIteratorHelper-02fbe55e.worker.esm.js';
1
+ import { _ as _toConsumableArray, a as _createForOfIteratorHelper } from '../../dist/createForOfIteratorHelper-548f1578.worker.esm.js';
2
2
  import { _ as _slicedToArray } from '../../dist/slicedToArray-106ca5f3.worker.esm.js';
3
3
 
4
4
  /**
@@ -65,4 +65,4 @@ function _createForOfIteratorHelper(r, e) {
65
65
  };
66
66
  }
67
67
 
68
- export { _createForOfIteratorHelper as _, _toConsumableArray as a };
68
+ export { _toConsumableArray as _, _createForOfIteratorHelper as a };
@@ -65,4 +65,4 @@ function _createForOfIteratorHelper(r, e) {
65
65
  };
66
66
  }
67
67
 
68
- export { _createForOfIteratorHelper as _, _toConsumableArray as a };
68
+ export { _toConsumableArray as _, _createForOfIteratorHelper as a };
@@ -65,4 +65,4 @@ function _createForOfIteratorHelper(r, e) {
65
65
  };
66
66
  }
67
67
 
68
- export { _createForOfIteratorHelper as _, _toConsumableArray as a };
68
+ export { _toConsumableArray as _, _createForOfIteratorHelper as a };
@@ -1,33 +1,9 @@
1
- import { _ as _createForOfIteratorHelper } from './createForOfIteratorHelper-8a8caaf6.esm.js';
1
+ import { a as _createForOfIteratorHelper } from './createForOfIteratorHelper-595d57b7.esm.js';
2
2
  import { _ as _typeof } from './typeof-a1531d8f.esm.js';
3
3
  import { Internal, isValViewSource } from '@valbuild/core';
4
4
  import { vercelStegaDecodeAll, vercelStegaSplit, vercelStegaCombine } from '@vercel/stega';
5
5
  import { _ as _slicedToArray } from './slicedToArray-70ecb9da.esm.js';
6
6
 
7
- function stegaDecodeStrings(encodedString) {
8
- if (!encodedString || typeof encodedString !== "string") return;
9
- var encodedBits = vercelStegaDecodeAll(encodedString);
10
- var paths = [];
11
- if (!encodedBits) return;
12
- var _iterator = _createForOfIteratorHelper(encodedBits),
13
- _step;
14
- try {
15
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
16
- var encodedBit = _step.value;
17
- if (encodedBit && _typeof(encodedBit) === "object") {
18
- if ("origin" in encodedBit && "data" in encodedBit && _typeof(encodedBit.data) === "object" && encodedBit.data && "valPath" in encodedBit.data && typeof encodedBit.data.valPath === "string") {
19
- paths.push(encodedBit.data.valPath);
20
- }
21
- }
22
- }
23
- } catch (err) {
24
- _iterator.e(err);
25
- } finally {
26
- _iterator.f();
27
- }
28
- return paths.length > 0 ? paths : undefined;
29
- }
30
-
31
7
  function _toPrimitive(t, r) {
32
8
  if ("object" != typeof t || !t) return t;
33
9
  var e = t[Symbol.toPrimitive];
@@ -75,6 +51,30 @@ function _objectSpread2(e) {
75
51
  return e;
76
52
  }
77
53
 
54
+ function stegaDecodeStrings(encodedString) {
55
+ if (!encodedString || typeof encodedString !== "string") return;
56
+ var encodedBits = vercelStegaDecodeAll(encodedString);
57
+ var paths = [];
58
+ if (!encodedBits) return;
59
+ var _iterator = _createForOfIteratorHelper(encodedBits),
60
+ _step;
61
+ try {
62
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
63
+ var encodedBit = _step.value;
64
+ if (encodedBit && _typeof(encodedBit) === "object") {
65
+ if ("origin" in encodedBit && "data" in encodedBit && _typeof(encodedBit.data) === "object" && encodedBit.data && "valPath" in encodedBit.data && typeof encodedBit.data.valPath === "string") {
66
+ paths.push(encodedBit.data.valPath);
67
+ }
68
+ }
69
+ }
70
+ } catch (err) {
71
+ _iterator.e(err);
72
+ } finally {
73
+ _iterator.f();
74
+ }
75
+ return paths.length > 0 ? paths : undefined;
76
+ }
77
+
78
78
  /**
79
79
  * ValEncodedString is a string that is encoded using steganography.
80
80
  *
@@ -1,33 +1,9 @@
1
- import { _ as _createForOfIteratorHelper } from './createForOfIteratorHelper-02fbe55e.worker.esm.js';
1
+ import { a as _createForOfIteratorHelper } from './createForOfIteratorHelper-548f1578.worker.esm.js';
2
2
  import { _ as _typeof } from './typeof-e0c837cc.worker.esm.js';
3
3
  import { Internal, isValViewSource } from '@valbuild/core';
4
4
  import { vercelStegaDecodeAll, vercelStegaSplit, vercelStegaCombine } from '@vercel/stega';
5
5
  import { _ as _slicedToArray } from './slicedToArray-106ca5f3.worker.esm.js';
6
6
 
7
- function stegaDecodeStrings(encodedString) {
8
- if (!encodedString || typeof encodedString !== "string") return;
9
- var encodedBits = vercelStegaDecodeAll(encodedString);
10
- var paths = [];
11
- if (!encodedBits) return;
12
- var _iterator = _createForOfIteratorHelper(encodedBits),
13
- _step;
14
- try {
15
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
16
- var encodedBit = _step.value;
17
- if (encodedBit && _typeof(encodedBit) === "object") {
18
- if ("origin" in encodedBit && "data" in encodedBit && _typeof(encodedBit.data) === "object" && encodedBit.data && "valPath" in encodedBit.data && typeof encodedBit.data.valPath === "string") {
19
- paths.push(encodedBit.data.valPath);
20
- }
21
- }
22
- }
23
- } catch (err) {
24
- _iterator.e(err);
25
- } finally {
26
- _iterator.f();
27
- }
28
- return paths.length > 0 ? paths : undefined;
29
- }
30
-
31
7
  function _toPrimitive(t, r) {
32
8
  if ("object" != typeof t || !t) return t;
33
9
  var e = t[Symbol.toPrimitive];
@@ -75,6 +51,30 @@ function _objectSpread2(e) {
75
51
  return e;
76
52
  }
77
53
 
54
+ function stegaDecodeStrings(encodedString) {
55
+ if (!encodedString || typeof encodedString !== "string") return;
56
+ var encodedBits = vercelStegaDecodeAll(encodedString);
57
+ var paths = [];
58
+ if (!encodedBits) return;
59
+ var _iterator = _createForOfIteratorHelper(encodedBits),
60
+ _step;
61
+ try {
62
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
63
+ var encodedBit = _step.value;
64
+ if (encodedBit && _typeof(encodedBit) === "object") {
65
+ if ("origin" in encodedBit && "data" in encodedBit && _typeof(encodedBit.data) === "object" && encodedBit.data && "valPath" in encodedBit.data && typeof encodedBit.data.valPath === "string") {
66
+ paths.push(encodedBit.data.valPath);
67
+ }
68
+ }
69
+ }
70
+ } catch (err) {
71
+ _iterator.e(err);
72
+ } finally {
73
+ _iterator.f();
74
+ }
75
+ return paths.length > 0 ? paths : undefined;
76
+ }
77
+
78
78
  /**
79
79
  * ValEncodedString is a string that is encoded using steganography.
80
80
  *
@@ -1,33 +1,9 @@
1
- import { _ as _createForOfIteratorHelper } from './createForOfIteratorHelper-36020cf7.browser.esm.js';
1
+ import { a as _createForOfIteratorHelper } from './createForOfIteratorHelper-3316a633.browser.esm.js';
2
2
  import { _ as _typeof } from './typeof-9915e135.browser.esm.js';
3
3
  import { Internal, isValViewSource } from '@valbuild/core';
4
4
  import { vercelStegaDecodeAll, vercelStegaSplit, vercelStegaCombine } from '@vercel/stega';
5
5
  import { _ as _slicedToArray } from './slicedToArray-b66ff800.browser.esm.js';
6
6
 
7
- function stegaDecodeStrings(encodedString) {
8
- if (!encodedString || typeof encodedString !== "string") return;
9
- var encodedBits = vercelStegaDecodeAll(encodedString);
10
- var paths = [];
11
- if (!encodedBits) return;
12
- var _iterator = _createForOfIteratorHelper(encodedBits),
13
- _step;
14
- try {
15
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
16
- var encodedBit = _step.value;
17
- if (encodedBit && _typeof(encodedBit) === "object") {
18
- if ("origin" in encodedBit && "data" in encodedBit && _typeof(encodedBit.data) === "object" && encodedBit.data && "valPath" in encodedBit.data && typeof encodedBit.data.valPath === "string") {
19
- paths.push(encodedBit.data.valPath);
20
- }
21
- }
22
- }
23
- } catch (err) {
24
- _iterator.e(err);
25
- } finally {
26
- _iterator.f();
27
- }
28
- return paths.length > 0 ? paths : undefined;
29
- }
30
-
31
7
  function _toPrimitive(t, r) {
32
8
  if ("object" != typeof t || !t) return t;
33
9
  var e = t[Symbol.toPrimitive];
@@ -75,6 +51,30 @@ function _objectSpread2(e) {
75
51
  return e;
76
52
  }
77
53
 
54
+ function stegaDecodeStrings(encodedString) {
55
+ if (!encodedString || typeof encodedString !== "string") return;
56
+ var encodedBits = vercelStegaDecodeAll(encodedString);
57
+ var paths = [];
58
+ if (!encodedBits) return;
59
+ var _iterator = _createForOfIteratorHelper(encodedBits),
60
+ _step;
61
+ try {
62
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
63
+ var encodedBit = _step.value;
64
+ if (encodedBit && _typeof(encodedBit) === "object") {
65
+ if ("origin" in encodedBit && "data" in encodedBit && _typeof(encodedBit.data) === "object" && encodedBit.data && "valPath" in encodedBit.data && typeof encodedBit.data.valPath === "string") {
66
+ paths.push(encodedBit.data.valPath);
67
+ }
68
+ }
69
+ }
70
+ } catch (err) {
71
+ _iterator.e(err);
72
+ } finally {
73
+ _iterator.f();
74
+ }
75
+ return paths.length > 0 ? paths : undefined;
76
+ }
77
+
78
78
  /**
79
79
  * ValEncodedString is a string that is encoded using steganography.
80
80
  *
@@ -1,5 +1,5 @@
1
- import { a as _toConsumableArray } from '../../dist/createForOfIteratorHelper-36020cf7.browser.esm.js';
2
- import { _ as _objectSpread2, r as raw, c as attrs } from '../../dist/raw-d34abe21.browser.esm.js';
1
+ import { _ as _toConsumableArray } from '../../dist/createForOfIteratorHelper-3316a633.browser.esm.js';
2
+ import { _ as _objectSpread2, r as raw, c as attrs } from '../../dist/raw-be4b57fa.browser.esm.js';
3
3
  import React from 'react';
4
4
  import { jsx } from 'react/jsx-runtime';
5
5
  import '../../dist/slicedToArray-b66ff800.browser.esm.js';
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var createForOfIteratorHelper = require('../../dist/createForOfIteratorHelper-522d616d.cjs.dev.js');
6
- var raw = require('../../dist/raw-a62618f3.cjs.dev.js');
6
+ var raw = require('../../dist/raw-ff060f24.cjs.dev.js');
7
7
  var React = require('react');
8
8
  var ReactJSXRuntime = require('react/jsx-runtime');
9
9
  require('../../dist/slicedToArray-387314c6.cjs.dev.js');
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var createForOfIteratorHelper = require('../../dist/createForOfIteratorHelper-598a2f85.cjs.prod.js');
6
- var raw = require('../../dist/raw-1617ec66.cjs.prod.js');
6
+ var raw = require('../../dist/raw-b3745603.cjs.prod.js');
7
7
  var React = require('react');
8
8
  var ReactJSXRuntime = require('react/jsx-runtime');
9
9
  require('../../dist/slicedToArray-64c83d56.cjs.prod.js');
@@ -1,5 +1,5 @@
1
- import { a as _toConsumableArray } from '../../dist/createForOfIteratorHelper-8a8caaf6.esm.js';
2
- import { _ as _objectSpread2, r as raw, c as attrs } from '../../dist/raw-c9cc9df6.esm.js';
1
+ import { _ as _toConsumableArray } from '../../dist/createForOfIteratorHelper-595d57b7.esm.js';
2
+ import { _ as _objectSpread2, r as raw, c as attrs } from '../../dist/raw-1b40484b.esm.js';
3
3
  import React from 'react';
4
4
  import { jsx } from 'react/jsx-runtime';
5
5
  import '../../dist/slicedToArray-70ecb9da.esm.js';
@@ -1,5 +1,5 @@
1
- import { a as _toConsumableArray } from '../../dist/createForOfIteratorHelper-02fbe55e.worker.esm.js';
2
- import { _ as _objectSpread2, r as raw, c as attrs } from '../../dist/raw-4d8c9599.worker.esm.js';
1
+ import { _ as _toConsumableArray } from '../../dist/createForOfIteratorHelper-548f1578.worker.esm.js';
2
+ import { _ as _objectSpread2, r as raw, c as attrs } from '../../dist/raw-43f9221a.worker.esm.js';
3
3
  import React from 'react';
4
4
  import { jsx } from 'react/jsx-runtime';
5
5
  import '../../dist/slicedToArray-106ca5f3.worker.esm.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@valbuild/react",
3
- "version": "0.150.5",
3
+ "version": "0.150.7",
4
4
  "private": false,
5
5
  "description": "Val - React internal helpers",
6
6
  "repository": {
@@ -11,8 +11,8 @@
11
11
  "dependencies": {
12
12
  "@vercel/stega": "^1.1.0",
13
13
  "base64-arraybuffer": "^1.0.2",
14
- "@valbuild/shared": "0.150.3",
15
14
  "@valbuild/core": "0.150.3",
15
+ "@valbuild/shared": "0.150.3",
16
16
  "@valbuild/ui": "0.150.5"
17
17
  },
18
18
  "devDependencies": {
@@ -1,13 +1,13 @@
1
+ import { _ as _objectSpread2, s as stegaDecodeStrings } from '../../dist/raw-be4b57fa.browser.esm.js';
2
+ export { c as attrs, g as getModuleIds, r as raw, b as stegaClean, s as stegaDecodeStrings, a as stegaEncode } from '../../dist/raw-be4b57fa.browser.esm.js';
1
3
  import { _ as _slicedToArray } from '../../dist/slicedToArray-b66ff800.browser.esm.js';
2
- import { _ as _createForOfIteratorHelper, a as _toConsumableArray } from '../../dist/createForOfIteratorHelper-36020cf7.browser.esm.js';
4
+ import { _ as _toConsumableArray, a as _createForOfIteratorHelper } from '../../dist/createForOfIteratorHelper-3316a633.browser.esm.js';
3
5
  import { _ as _typeof } from '../../dist/typeof-9915e135.browser.esm.js';
4
6
  import { Internal } from '@valbuild/core';
5
7
  import ReactJSXRuntime__default from 'react/jsx-runtime';
6
8
  import jsxRuntimeDev__default from 'react/jsx-dev-runtime';
7
9
  import React from 'react';
8
10
  import { VERCEL_STEGA_REGEX, vercelStegaSplit } from '@vercel/stega';
9
- import { s as stegaDecodeStrings } from '../../dist/raw-d34abe21.browser.esm.js';
10
- export { c as attrs, g as getModuleIds, r as raw, b as stegaClean, s as stegaDecodeStrings, a as stegaEncode } from '../../dist/raw-d34abe21.browser.esm.js';
11
11
 
12
12
  var isIntrinsicElement = function isIntrinsicElement(type) {
13
13
  // TODO: think this is not correct, but good enough for now?
@@ -47,6 +47,28 @@ function pathsOfFragmentChildren(children) {
47
47
  return found;
48
48
  }
49
49
 
50
+ /**
51
+ * `props.children` as an array that can be written to, or null when it is
52
+ * an array that cannot and `props` cannot take another.
53
+ *
54
+ * React's development build freezes an element's static children
55
+ * (`{label} →` is `[label, " →"]`), so a component that hands its
56
+ * `children` on to an intrinsic element -- `<a>{children}</a>` -- hands on a
57
+ * frozen array: the element got its `data-val-path`, and its text kept the
58
+ * edit tag, in development only. Its props are the component's own, fresh
59
+ * object, so the cleaned copy goes there.
60
+ */
61
+ function writableChildren(props) {
62
+ if (!Object.isFrozen(props.children)) {
63
+ return props.children;
64
+ }
65
+ if (Object.isFrozen(props)) {
66
+ return null;
67
+ }
68
+ props.children = _toConsumableArray(props.children);
69
+ return props.children;
70
+ }
71
+
50
72
  /**
51
73
  * Takes the edit tags out of a fragment's text, and returns the paths they
52
74
  * named -- its own and its fragment children's -- for its parent to carry.
@@ -67,9 +89,10 @@ function cleanFragment(props) {
67
89
  return value;
68
90
  };
69
91
  if (Array.isArray(props.children)) {
70
- if (!Object.isFrozen(props.children)) {
71
- props.children.forEach(function (child, index) {
72
- props.children[index] = clean(child);
92
+ var children = writableChildren(props);
93
+ if (children) {
94
+ children.forEach(function (child, index) {
95
+ children[index] = clean(child);
73
96
  });
74
97
  }
75
98
  } else if (!Object.isFrozen(props)) {
@@ -184,12 +207,14 @@ var addValPathIfFound = function addValPathIfFound(type, props) {
184
207
  }
185
208
  }
186
209
  } else if (value instanceof Array) {
187
- for (var _i3 = 0, _Object$entries3 = Object.entries(value); _i3 < _Object$entries3.length; _i3++) {
210
+ var _writableChildren;
211
+ var container = key === "children" && isIntrinsicElement(type) ? (_writableChildren = writableChildren(props)) !== null && _writableChildren !== void 0 ? _writableChildren : value : value;
212
+ for (var _i3 = 0, _Object$entries3 = Object.entries(container); _i3 < _Object$entries3.length; _i3++) {
188
213
  var _Object$entries3$_i = _slicedToArray(_Object$entries3[_i3], 2),
189
214
  index = _Object$entries3$_i[0],
190
215
  item = _Object$entries3$_i[1];
191
216
  if (typeof item === "string" && item.match(VERCEL_STEGA_REGEX)) {
192
- updateValSources(index, item, props, value);
217
+ updateValSources(index, item, props, container);
193
218
  }
194
219
  }
195
220
  }
@@ -217,18 +242,70 @@ function WrapJsx(jsx) {
217
242
  return element;
218
243
  };
219
244
  }
245
+
246
+ /**
247
+ * `React.createElement(type, props, ...children)` takes its children as
248
+ * arguments, not in `props`, so the wrapper `jsx` gets never sees them: a
249
+ * library that renders content with it -- TanStack Router's `<Link>` does --
250
+ * put the text on the page with its edit tag still in it. Its string
251
+ * children are cleaned here, and an intrinsic element carries their paths.
252
+ */
253
+ function WrapCreateElement(createElement) {
254
+ if (typeof createElement !== "function") return createElement;
255
+ return function (type, props) {
256
+ for (var _len2 = arguments.length, children = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
257
+ children[_key2 - 2] = arguments[_key2];
258
+ }
259
+ if (!IS_AUTO_TAG_JSX_ENABLED() || children.length === 0) {
260
+ addValPathIfFound(type, props);
261
+ return createElement.call.apply(createElement, [createElement, type, props].concat(children));
262
+ }
263
+ var paths = [];
264
+ var clean = function clean(child) {
265
+ if (typeof child === "string" && child.match(VERCEL_STEGA_REGEX)) {
266
+ var found = stegaDecodeStrings(child);
267
+ if (found) {
268
+ paths.push.apply(paths, _toConsumableArray(found));
269
+ return vercelStegaSplit(child).cleaned;
270
+ }
271
+ }
272
+ return child;
273
+ };
274
+ var cleaned = isIntrinsicElement(type) ? children.map(function (child) {
275
+ return Array.isArray(child) ? child.map(clean) : clean(child);
276
+ }) : children;
277
+ var ownProps = props;
278
+ if (isIntrinsicElement(type)) {
279
+ paths.push.apply(paths, _toConsumableArray(pathsOfFragmentChildren(cleaned)));
280
+ if (paths.length > 0) {
281
+ ownProps = _objectSpread2({}, props !== null && props !== void 0 ? props : {});
282
+ if (!ownProps["data-val-path"]) {
283
+ ownProps["data-val-path"] = Array.from(new Set(paths)).join(",");
284
+ }
285
+ }
286
+ }
287
+ addValPathIfFound(type, ownProps);
288
+ return createElement.call.apply(createElement, [createElement, type, ownProps].concat(_toConsumableArray(cleaned)));
289
+ };
290
+ }
291
+ /** Whether the runtimes are wrapped already: wrapping twice cleans twice. */
292
+ var installed = false;
220
293
  function autoTagJSX() {
294
+ if (installed) {
295
+ return;
296
+ }
297
+ installed = true;
221
298
  var JsxPro = ReactJSXRuntime__default;
222
299
  var JsxDev = jsxRuntimeDev__default;
223
300
 
224
301
  /**
225
302
  * createElement _may_ be called by jsx runtime as a fallback in certain cases,
226
- * so we need to wrap it regardless.
303
+ * and libraries call it directly, so we need to wrap it regardless.
227
304
  *
228
305
  * The jsx exports depend on the `NODE_ENV` var to ensure the users' bundler doesn't
229
306
  * include both, so one of them will be set with `undefined` values.
230
307
  */
231
- React.createElement = WrapJsx(React.createElement);
308
+ React.createElement = WrapCreateElement(React.createElement);
232
309
  // eslint-disable-next-line @typescript-eslint/no-unused-expressions
233
310
  JsxDev.jsx && (/* */JsxDev.jsx = WrapJsx(JsxDev.jsx));
234
311
  // eslint-disable-next-line @typescript-eslint/no-unused-expressions
@@ -2,6 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ var raw = require('../../dist/raw-ff060f24.cjs.dev.js');
5
6
  var slicedToArray = require('../../dist/slicedToArray-387314c6.cjs.dev.js');
6
7
  var createForOfIteratorHelper = require('../../dist/createForOfIteratorHelper-522d616d.cjs.dev.js');
7
8
  var _typeof = require('../../dist/typeof-b568f48f.cjs.dev.js');
@@ -10,7 +11,6 @@ var ReactJSXRuntime = require('react/jsx-runtime');
10
11
  var jsxRuntimeDev = require('react/jsx-dev-runtime');
11
12
  var React = require('react');
12
13
  var stega = require('@vercel/stega');
13
- var raw = require('../../dist/raw-a62618f3.cjs.dev.js');
14
14
 
15
15
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
16
16
 
@@ -56,6 +56,28 @@ function pathsOfFragmentChildren(children) {
56
56
  return found;
57
57
  }
58
58
 
59
+ /**
60
+ * `props.children` as an array that can be written to, or null when it is
61
+ * an array that cannot and `props` cannot take another.
62
+ *
63
+ * React's development build freezes an element's static children
64
+ * (`{label} →` is `[label, " →"]`), so a component that hands its
65
+ * `children` on to an intrinsic element -- `<a>{children}</a>` -- hands on a
66
+ * frozen array: the element got its `data-val-path`, and its text kept the
67
+ * edit tag, in development only. Its props are the component's own, fresh
68
+ * object, so the cleaned copy goes there.
69
+ */
70
+ function writableChildren(props) {
71
+ if (!Object.isFrozen(props.children)) {
72
+ return props.children;
73
+ }
74
+ if (Object.isFrozen(props)) {
75
+ return null;
76
+ }
77
+ props.children = createForOfIteratorHelper._toConsumableArray(props.children);
78
+ return props.children;
79
+ }
80
+
59
81
  /**
60
82
  * Takes the edit tags out of a fragment's text, and returns the paths they
61
83
  * named -- its own and its fragment children's -- for its parent to carry.
@@ -76,9 +98,10 @@ function cleanFragment(props) {
76
98
  return value;
77
99
  };
78
100
  if (Array.isArray(props.children)) {
79
- if (!Object.isFrozen(props.children)) {
80
- props.children.forEach(function (child, index) {
81
- props.children[index] = clean(child);
101
+ var children = writableChildren(props);
102
+ if (children) {
103
+ children.forEach(function (child, index) {
104
+ children[index] = clean(child);
82
105
  });
83
106
  }
84
107
  } else if (!Object.isFrozen(props)) {
@@ -193,12 +216,14 @@ var addValPathIfFound = function addValPathIfFound(type, props) {
193
216
  }
194
217
  }
195
218
  } else if (value instanceof Array) {
196
- for (var _i3 = 0, _Object$entries3 = Object.entries(value); _i3 < _Object$entries3.length; _i3++) {
219
+ var _writableChildren;
220
+ var container = key === "children" && isIntrinsicElement(type) ? (_writableChildren = writableChildren(props)) !== null && _writableChildren !== void 0 ? _writableChildren : value : value;
221
+ for (var _i3 = 0, _Object$entries3 = Object.entries(container); _i3 < _Object$entries3.length; _i3++) {
197
222
  var _Object$entries3$_i = slicedToArray._slicedToArray(_Object$entries3[_i3], 2),
198
223
  index = _Object$entries3$_i[0],
199
224
  item = _Object$entries3$_i[1];
200
225
  if (typeof item === "string" && item.match(stega.VERCEL_STEGA_REGEX)) {
201
- updateValSources(index, item, props, value);
226
+ updateValSources(index, item, props, container);
202
227
  }
203
228
  }
204
229
  }
@@ -226,18 +251,70 @@ function WrapJsx(jsx) {
226
251
  return element;
227
252
  };
228
253
  }
254
+
255
+ /**
256
+ * `React.createElement(type, props, ...children)` takes its children as
257
+ * arguments, not in `props`, so the wrapper `jsx` gets never sees them: a
258
+ * library that renders content with it -- TanStack Router's `<Link>` does --
259
+ * put the text on the page with its edit tag still in it. Its string
260
+ * children are cleaned here, and an intrinsic element carries their paths.
261
+ */
262
+ function WrapCreateElement(createElement) {
263
+ if (typeof createElement !== "function") return createElement;
264
+ return function (type, props) {
265
+ for (var _len2 = arguments.length, children = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
266
+ children[_key2 - 2] = arguments[_key2];
267
+ }
268
+ if (!IS_AUTO_TAG_JSX_ENABLED() || children.length === 0) {
269
+ addValPathIfFound(type, props);
270
+ return createElement.call.apply(createElement, [createElement, type, props].concat(children));
271
+ }
272
+ var paths = [];
273
+ var clean = function clean(child) {
274
+ if (typeof child === "string" && child.match(stega.VERCEL_STEGA_REGEX)) {
275
+ var found = raw.stegaDecodeStrings(child);
276
+ if (found) {
277
+ paths.push.apply(paths, createForOfIteratorHelper._toConsumableArray(found));
278
+ return stega.vercelStegaSplit(child).cleaned;
279
+ }
280
+ }
281
+ return child;
282
+ };
283
+ var cleaned = isIntrinsicElement(type) ? children.map(function (child) {
284
+ return Array.isArray(child) ? child.map(clean) : clean(child);
285
+ }) : children;
286
+ var ownProps = props;
287
+ if (isIntrinsicElement(type)) {
288
+ paths.push.apply(paths, createForOfIteratorHelper._toConsumableArray(pathsOfFragmentChildren(cleaned)));
289
+ if (paths.length > 0) {
290
+ ownProps = raw._objectSpread2({}, props !== null && props !== void 0 ? props : {});
291
+ if (!ownProps["data-val-path"]) {
292
+ ownProps["data-val-path"] = Array.from(new Set(paths)).join(",");
293
+ }
294
+ }
295
+ }
296
+ addValPathIfFound(type, ownProps);
297
+ return createElement.call.apply(createElement, [createElement, type, ownProps].concat(createForOfIteratorHelper._toConsumableArray(cleaned)));
298
+ };
299
+ }
300
+ /** Whether the runtimes are wrapped already: wrapping twice cleans twice. */
301
+ var installed = false;
229
302
  function autoTagJSX() {
303
+ if (installed) {
304
+ return;
305
+ }
306
+ installed = true;
230
307
  var JsxPro = ReactJSXRuntime__default["default"];
231
308
  var JsxDev = jsxRuntimeDev__default["default"];
232
309
 
233
310
  /**
234
311
  * createElement _may_ be called by jsx runtime as a fallback in certain cases,
235
- * so we need to wrap it regardless.
312
+ * and libraries call it directly, so we need to wrap it regardless.
236
313
  *
237
314
  * The jsx exports depend on the `NODE_ENV` var to ensure the users' bundler doesn't
238
315
  * include both, so one of them will be set with `undefined` values.
239
316
  */
240
- React__default["default"].createElement = WrapJsx(React__default["default"].createElement);
317
+ React__default["default"].createElement = WrapCreateElement(React__default["default"].createElement);
241
318
  // eslint-disable-next-line @typescript-eslint/no-unused-expressions
242
319
  JsxDev.jsx && (/* */JsxDev.jsx = WrapJsx(JsxDev.jsx));
243
320
  // eslint-disable-next-line @typescript-eslint/no-unused-expressions
@@ -2,6 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ var raw = require('../../dist/raw-b3745603.cjs.prod.js');
5
6
  var slicedToArray = require('../../dist/slicedToArray-64c83d56.cjs.prod.js');
6
7
  var createForOfIteratorHelper = require('../../dist/createForOfIteratorHelper-598a2f85.cjs.prod.js');
7
8
  var _typeof = require('../../dist/typeof-16428c61.cjs.prod.js');
@@ -10,7 +11,6 @@ var ReactJSXRuntime = require('react/jsx-runtime');
10
11
  var jsxRuntimeDev = require('react/jsx-dev-runtime');
11
12
  var React = require('react');
12
13
  var stega = require('@vercel/stega');
13
- var raw = require('../../dist/raw-1617ec66.cjs.prod.js');
14
14
 
15
15
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
16
16
 
@@ -56,6 +56,28 @@ function pathsOfFragmentChildren(children) {
56
56
  return found;
57
57
  }
58
58
 
59
+ /**
60
+ * `props.children` as an array that can be written to, or null when it is
61
+ * an array that cannot and `props` cannot take another.
62
+ *
63
+ * React's development build freezes an element's static children
64
+ * (`{label} →` is `[label, " →"]`), so a component that hands its
65
+ * `children` on to an intrinsic element -- `<a>{children}</a>` -- hands on a
66
+ * frozen array: the element got its `data-val-path`, and its text kept the
67
+ * edit tag, in development only. Its props are the component's own, fresh
68
+ * object, so the cleaned copy goes there.
69
+ */
70
+ function writableChildren(props) {
71
+ if (!Object.isFrozen(props.children)) {
72
+ return props.children;
73
+ }
74
+ if (Object.isFrozen(props)) {
75
+ return null;
76
+ }
77
+ props.children = createForOfIteratorHelper._toConsumableArray(props.children);
78
+ return props.children;
79
+ }
80
+
59
81
  /**
60
82
  * Takes the edit tags out of a fragment's text, and returns the paths they
61
83
  * named -- its own and its fragment children's -- for its parent to carry.
@@ -76,9 +98,10 @@ function cleanFragment(props) {
76
98
  return value;
77
99
  };
78
100
  if (Array.isArray(props.children)) {
79
- if (!Object.isFrozen(props.children)) {
80
- props.children.forEach(function (child, index) {
81
- props.children[index] = clean(child);
101
+ var children = writableChildren(props);
102
+ if (children) {
103
+ children.forEach(function (child, index) {
104
+ children[index] = clean(child);
82
105
  });
83
106
  }
84
107
  } else if (!Object.isFrozen(props)) {
@@ -193,12 +216,14 @@ var addValPathIfFound = function addValPathIfFound(type, props) {
193
216
  }
194
217
  }
195
218
  } else if (value instanceof Array) {
196
- for (var _i3 = 0, _Object$entries3 = Object.entries(value); _i3 < _Object$entries3.length; _i3++) {
219
+ var _writableChildren;
220
+ var container = key === "children" && isIntrinsicElement(type) ? (_writableChildren = writableChildren(props)) !== null && _writableChildren !== void 0 ? _writableChildren : value : value;
221
+ for (var _i3 = 0, _Object$entries3 = Object.entries(container); _i3 < _Object$entries3.length; _i3++) {
197
222
  var _Object$entries3$_i = slicedToArray._slicedToArray(_Object$entries3[_i3], 2),
198
223
  index = _Object$entries3$_i[0],
199
224
  item = _Object$entries3$_i[1];
200
225
  if (typeof item === "string" && item.match(stega.VERCEL_STEGA_REGEX)) {
201
- updateValSources(index, item, props, value);
226
+ updateValSources(index, item, props, container);
202
227
  }
203
228
  }
204
229
  }
@@ -226,18 +251,70 @@ function WrapJsx(jsx) {
226
251
  return element;
227
252
  };
228
253
  }
254
+
255
+ /**
256
+ * `React.createElement(type, props, ...children)` takes its children as
257
+ * arguments, not in `props`, so the wrapper `jsx` gets never sees them: a
258
+ * library that renders content with it -- TanStack Router's `<Link>` does --
259
+ * put the text on the page with its edit tag still in it. Its string
260
+ * children are cleaned here, and an intrinsic element carries their paths.
261
+ */
262
+ function WrapCreateElement(createElement) {
263
+ if (typeof createElement !== "function") return createElement;
264
+ return function (type, props) {
265
+ for (var _len2 = arguments.length, children = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
266
+ children[_key2 - 2] = arguments[_key2];
267
+ }
268
+ if (!IS_AUTO_TAG_JSX_ENABLED() || children.length === 0) {
269
+ addValPathIfFound(type, props);
270
+ return createElement.call.apply(createElement, [createElement, type, props].concat(children));
271
+ }
272
+ var paths = [];
273
+ var clean = function clean(child) {
274
+ if (typeof child === "string" && child.match(stega.VERCEL_STEGA_REGEX)) {
275
+ var found = raw.stegaDecodeStrings(child);
276
+ if (found) {
277
+ paths.push.apply(paths, createForOfIteratorHelper._toConsumableArray(found));
278
+ return stega.vercelStegaSplit(child).cleaned;
279
+ }
280
+ }
281
+ return child;
282
+ };
283
+ var cleaned = isIntrinsicElement(type) ? children.map(function (child) {
284
+ return Array.isArray(child) ? child.map(clean) : clean(child);
285
+ }) : children;
286
+ var ownProps = props;
287
+ if (isIntrinsicElement(type)) {
288
+ paths.push.apply(paths, createForOfIteratorHelper._toConsumableArray(pathsOfFragmentChildren(cleaned)));
289
+ if (paths.length > 0) {
290
+ ownProps = raw._objectSpread2({}, props !== null && props !== void 0 ? props : {});
291
+ if (!ownProps["data-val-path"]) {
292
+ ownProps["data-val-path"] = Array.from(new Set(paths)).join(",");
293
+ }
294
+ }
295
+ }
296
+ addValPathIfFound(type, ownProps);
297
+ return createElement.call.apply(createElement, [createElement, type, ownProps].concat(createForOfIteratorHelper._toConsumableArray(cleaned)));
298
+ };
299
+ }
300
+ /** Whether the runtimes are wrapped already: wrapping twice cleans twice. */
301
+ var installed = false;
229
302
  function autoTagJSX() {
303
+ if (installed) {
304
+ return;
305
+ }
306
+ installed = true;
230
307
  var JsxPro = ReactJSXRuntime__default["default"];
231
308
  var JsxDev = jsxRuntimeDev__default["default"];
232
309
 
233
310
  /**
234
311
  * createElement _may_ be called by jsx runtime as a fallback in certain cases,
235
- * so we need to wrap it regardless.
312
+ * and libraries call it directly, so we need to wrap it regardless.
236
313
  *
237
314
  * The jsx exports depend on the `NODE_ENV` var to ensure the users' bundler doesn't
238
315
  * include both, so one of them will be set with `undefined` values.
239
316
  */
240
- React__default["default"].createElement = WrapJsx(React__default["default"].createElement);
317
+ React__default["default"].createElement = WrapCreateElement(React__default["default"].createElement);
241
318
  // eslint-disable-next-line @typescript-eslint/no-unused-expressions
242
319
  JsxDev.jsx && (/* */JsxDev.jsx = WrapJsx(JsxDev.jsx));
243
320
  // eslint-disable-next-line @typescript-eslint/no-unused-expressions
@@ -1,13 +1,13 @@
1
+ import { _ as _objectSpread2, s as stegaDecodeStrings } from '../../dist/raw-1b40484b.esm.js';
2
+ export { c as attrs, g as getModuleIds, r as raw, b as stegaClean, s as stegaDecodeStrings, a as stegaEncode } from '../../dist/raw-1b40484b.esm.js';
1
3
  import { _ as _slicedToArray } from '../../dist/slicedToArray-70ecb9da.esm.js';
2
- import { _ as _createForOfIteratorHelper, a as _toConsumableArray } from '../../dist/createForOfIteratorHelper-8a8caaf6.esm.js';
4
+ import { _ as _toConsumableArray, a as _createForOfIteratorHelper } from '../../dist/createForOfIteratorHelper-595d57b7.esm.js';
3
5
  import { _ as _typeof } from '../../dist/typeof-a1531d8f.esm.js';
4
6
  import { Internal } from '@valbuild/core';
5
7
  import ReactJSXRuntime__default from 'react/jsx-runtime';
6
8
  import jsxRuntimeDev__default from 'react/jsx-dev-runtime';
7
9
  import React from 'react';
8
10
  import { VERCEL_STEGA_REGEX, vercelStegaSplit } from '@vercel/stega';
9
- import { s as stegaDecodeStrings } from '../../dist/raw-c9cc9df6.esm.js';
10
- export { c as attrs, g as getModuleIds, r as raw, b as stegaClean, s as stegaDecodeStrings, a as stegaEncode } from '../../dist/raw-c9cc9df6.esm.js';
11
11
 
12
12
  var isIntrinsicElement = function isIntrinsicElement(type) {
13
13
  // TODO: think this is not correct, but good enough for now?
@@ -47,6 +47,28 @@ function pathsOfFragmentChildren(children) {
47
47
  return found;
48
48
  }
49
49
 
50
+ /**
51
+ * `props.children` as an array that can be written to, or null when it is
52
+ * an array that cannot and `props` cannot take another.
53
+ *
54
+ * React's development build freezes an element's static children
55
+ * (`{label} →` is `[label, " →"]`), so a component that hands its
56
+ * `children` on to an intrinsic element -- `<a>{children}</a>` -- hands on a
57
+ * frozen array: the element got its `data-val-path`, and its text kept the
58
+ * edit tag, in development only. Its props are the component's own, fresh
59
+ * object, so the cleaned copy goes there.
60
+ */
61
+ function writableChildren(props) {
62
+ if (!Object.isFrozen(props.children)) {
63
+ return props.children;
64
+ }
65
+ if (Object.isFrozen(props)) {
66
+ return null;
67
+ }
68
+ props.children = _toConsumableArray(props.children);
69
+ return props.children;
70
+ }
71
+
50
72
  /**
51
73
  * Takes the edit tags out of a fragment's text, and returns the paths they
52
74
  * named -- its own and its fragment children's -- for its parent to carry.
@@ -67,9 +89,10 @@ function cleanFragment(props) {
67
89
  return value;
68
90
  };
69
91
  if (Array.isArray(props.children)) {
70
- if (!Object.isFrozen(props.children)) {
71
- props.children.forEach(function (child, index) {
72
- props.children[index] = clean(child);
92
+ var children = writableChildren(props);
93
+ if (children) {
94
+ children.forEach(function (child, index) {
95
+ children[index] = clean(child);
73
96
  });
74
97
  }
75
98
  } else if (!Object.isFrozen(props)) {
@@ -184,12 +207,14 @@ var addValPathIfFound = function addValPathIfFound(type, props) {
184
207
  }
185
208
  }
186
209
  } else if (value instanceof Array) {
187
- for (var _i3 = 0, _Object$entries3 = Object.entries(value); _i3 < _Object$entries3.length; _i3++) {
210
+ var _writableChildren;
211
+ var container = key === "children" && isIntrinsicElement(type) ? (_writableChildren = writableChildren(props)) !== null && _writableChildren !== void 0 ? _writableChildren : value : value;
212
+ for (var _i3 = 0, _Object$entries3 = Object.entries(container); _i3 < _Object$entries3.length; _i3++) {
188
213
  var _Object$entries3$_i = _slicedToArray(_Object$entries3[_i3], 2),
189
214
  index = _Object$entries3$_i[0],
190
215
  item = _Object$entries3$_i[1];
191
216
  if (typeof item === "string" && item.match(VERCEL_STEGA_REGEX)) {
192
- updateValSources(index, item, props, value);
217
+ updateValSources(index, item, props, container);
193
218
  }
194
219
  }
195
220
  }
@@ -217,18 +242,70 @@ function WrapJsx(jsx) {
217
242
  return element;
218
243
  };
219
244
  }
245
+
246
+ /**
247
+ * `React.createElement(type, props, ...children)` takes its children as
248
+ * arguments, not in `props`, so the wrapper `jsx` gets never sees them: a
249
+ * library that renders content with it -- TanStack Router's `<Link>` does --
250
+ * put the text on the page with its edit tag still in it. Its string
251
+ * children are cleaned here, and an intrinsic element carries their paths.
252
+ */
253
+ function WrapCreateElement(createElement) {
254
+ if (typeof createElement !== "function") return createElement;
255
+ return function (type, props) {
256
+ for (var _len2 = arguments.length, children = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
257
+ children[_key2 - 2] = arguments[_key2];
258
+ }
259
+ if (!IS_AUTO_TAG_JSX_ENABLED() || children.length === 0) {
260
+ addValPathIfFound(type, props);
261
+ return createElement.call.apply(createElement, [createElement, type, props].concat(children));
262
+ }
263
+ var paths = [];
264
+ var clean = function clean(child) {
265
+ if (typeof child === "string" && child.match(VERCEL_STEGA_REGEX)) {
266
+ var found = stegaDecodeStrings(child);
267
+ if (found) {
268
+ paths.push.apply(paths, _toConsumableArray(found));
269
+ return vercelStegaSplit(child).cleaned;
270
+ }
271
+ }
272
+ return child;
273
+ };
274
+ var cleaned = isIntrinsicElement(type) ? children.map(function (child) {
275
+ return Array.isArray(child) ? child.map(clean) : clean(child);
276
+ }) : children;
277
+ var ownProps = props;
278
+ if (isIntrinsicElement(type)) {
279
+ paths.push.apply(paths, _toConsumableArray(pathsOfFragmentChildren(cleaned)));
280
+ if (paths.length > 0) {
281
+ ownProps = _objectSpread2({}, props !== null && props !== void 0 ? props : {});
282
+ if (!ownProps["data-val-path"]) {
283
+ ownProps["data-val-path"] = Array.from(new Set(paths)).join(",");
284
+ }
285
+ }
286
+ }
287
+ addValPathIfFound(type, ownProps);
288
+ return createElement.call.apply(createElement, [createElement, type, ownProps].concat(_toConsumableArray(cleaned)));
289
+ };
290
+ }
291
+ /** Whether the runtimes are wrapped already: wrapping twice cleans twice. */
292
+ var installed = false;
220
293
  function autoTagJSX() {
294
+ if (installed) {
295
+ return;
296
+ }
297
+ installed = true;
221
298
  var JsxPro = ReactJSXRuntime__default;
222
299
  var JsxDev = jsxRuntimeDev__default;
223
300
 
224
301
  /**
225
302
  * createElement _may_ be called by jsx runtime as a fallback in certain cases,
226
- * so we need to wrap it regardless.
303
+ * and libraries call it directly, so we need to wrap it regardless.
227
304
  *
228
305
  * The jsx exports depend on the `NODE_ENV` var to ensure the users' bundler doesn't
229
306
  * include both, so one of them will be set with `undefined` values.
230
307
  */
231
- React.createElement = WrapJsx(React.createElement);
308
+ React.createElement = WrapCreateElement(React.createElement);
232
309
  // eslint-disable-next-line @typescript-eslint/no-unused-expressions
233
310
  JsxDev.jsx && (/* */JsxDev.jsx = WrapJsx(JsxDev.jsx));
234
311
  // eslint-disable-next-line @typescript-eslint/no-unused-expressions
@@ -1,13 +1,13 @@
1
+ import { _ as _objectSpread2, s as stegaDecodeStrings } from '../../dist/raw-43f9221a.worker.esm.js';
2
+ export { c as attrs, g as getModuleIds, r as raw, b as stegaClean, s as stegaDecodeStrings, a as stegaEncode } from '../../dist/raw-43f9221a.worker.esm.js';
1
3
  import { _ as _slicedToArray } from '../../dist/slicedToArray-106ca5f3.worker.esm.js';
2
- import { _ as _createForOfIteratorHelper, a as _toConsumableArray } from '../../dist/createForOfIteratorHelper-02fbe55e.worker.esm.js';
4
+ import { _ as _toConsumableArray, a as _createForOfIteratorHelper } from '../../dist/createForOfIteratorHelper-548f1578.worker.esm.js';
3
5
  import { _ as _typeof } from '../../dist/typeof-e0c837cc.worker.esm.js';
4
6
  import { Internal } from '@valbuild/core';
5
7
  import ReactJSXRuntime__default from 'react/jsx-runtime';
6
8
  import jsxRuntimeDev__default from 'react/jsx-dev-runtime';
7
9
  import React from 'react';
8
10
  import { VERCEL_STEGA_REGEX, vercelStegaSplit } from '@vercel/stega';
9
- import { s as stegaDecodeStrings } from '../../dist/raw-4d8c9599.worker.esm.js';
10
- export { c as attrs, g as getModuleIds, r as raw, b as stegaClean, s as stegaDecodeStrings, a as stegaEncode } from '../../dist/raw-4d8c9599.worker.esm.js';
11
11
 
12
12
  var isIntrinsicElement = function isIntrinsicElement(type) {
13
13
  // TODO: think this is not correct, but good enough for now?
@@ -47,6 +47,28 @@ function pathsOfFragmentChildren(children) {
47
47
  return found;
48
48
  }
49
49
 
50
+ /**
51
+ * `props.children` as an array that can be written to, or null when it is
52
+ * an array that cannot and `props` cannot take another.
53
+ *
54
+ * React's development build freezes an element's static children
55
+ * (`{label} →` is `[label, " →"]`), so a component that hands its
56
+ * `children` on to an intrinsic element -- `<a>{children}</a>` -- hands on a
57
+ * frozen array: the element got its `data-val-path`, and its text kept the
58
+ * edit tag, in development only. Its props are the component's own, fresh
59
+ * object, so the cleaned copy goes there.
60
+ */
61
+ function writableChildren(props) {
62
+ if (!Object.isFrozen(props.children)) {
63
+ return props.children;
64
+ }
65
+ if (Object.isFrozen(props)) {
66
+ return null;
67
+ }
68
+ props.children = _toConsumableArray(props.children);
69
+ return props.children;
70
+ }
71
+
50
72
  /**
51
73
  * Takes the edit tags out of a fragment's text, and returns the paths they
52
74
  * named -- its own and its fragment children's -- for its parent to carry.
@@ -67,9 +89,10 @@ function cleanFragment(props) {
67
89
  return value;
68
90
  };
69
91
  if (Array.isArray(props.children)) {
70
- if (!Object.isFrozen(props.children)) {
71
- props.children.forEach(function (child, index) {
72
- props.children[index] = clean(child);
92
+ var children = writableChildren(props);
93
+ if (children) {
94
+ children.forEach(function (child, index) {
95
+ children[index] = clean(child);
73
96
  });
74
97
  }
75
98
  } else if (!Object.isFrozen(props)) {
@@ -184,12 +207,14 @@ var addValPathIfFound = function addValPathIfFound(type, props) {
184
207
  }
185
208
  }
186
209
  } else if (value instanceof Array) {
187
- for (var _i3 = 0, _Object$entries3 = Object.entries(value); _i3 < _Object$entries3.length; _i3++) {
210
+ var _writableChildren;
211
+ var container = key === "children" && isIntrinsicElement(type) ? (_writableChildren = writableChildren(props)) !== null && _writableChildren !== void 0 ? _writableChildren : value : value;
212
+ for (var _i3 = 0, _Object$entries3 = Object.entries(container); _i3 < _Object$entries3.length; _i3++) {
188
213
  var _Object$entries3$_i = _slicedToArray(_Object$entries3[_i3], 2),
189
214
  index = _Object$entries3$_i[0],
190
215
  item = _Object$entries3$_i[1];
191
216
  if (typeof item === "string" && item.match(VERCEL_STEGA_REGEX)) {
192
- updateValSources(index, item, props, value);
217
+ updateValSources(index, item, props, container);
193
218
  }
194
219
  }
195
220
  }
@@ -217,18 +242,70 @@ function WrapJsx(jsx) {
217
242
  return element;
218
243
  };
219
244
  }
245
+
246
+ /**
247
+ * `React.createElement(type, props, ...children)` takes its children as
248
+ * arguments, not in `props`, so the wrapper `jsx` gets never sees them: a
249
+ * library that renders content with it -- TanStack Router's `<Link>` does --
250
+ * put the text on the page with its edit tag still in it. Its string
251
+ * children are cleaned here, and an intrinsic element carries their paths.
252
+ */
253
+ function WrapCreateElement(createElement) {
254
+ if (typeof createElement !== "function") return createElement;
255
+ return function (type, props) {
256
+ for (var _len2 = arguments.length, children = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
257
+ children[_key2 - 2] = arguments[_key2];
258
+ }
259
+ if (!IS_AUTO_TAG_JSX_ENABLED() || children.length === 0) {
260
+ addValPathIfFound(type, props);
261
+ return createElement.call.apply(createElement, [createElement, type, props].concat(children));
262
+ }
263
+ var paths = [];
264
+ var clean = function clean(child) {
265
+ if (typeof child === "string" && child.match(VERCEL_STEGA_REGEX)) {
266
+ var found = stegaDecodeStrings(child);
267
+ if (found) {
268
+ paths.push.apply(paths, _toConsumableArray(found));
269
+ return vercelStegaSplit(child).cleaned;
270
+ }
271
+ }
272
+ return child;
273
+ };
274
+ var cleaned = isIntrinsicElement(type) ? children.map(function (child) {
275
+ return Array.isArray(child) ? child.map(clean) : clean(child);
276
+ }) : children;
277
+ var ownProps = props;
278
+ if (isIntrinsicElement(type)) {
279
+ paths.push.apply(paths, _toConsumableArray(pathsOfFragmentChildren(cleaned)));
280
+ if (paths.length > 0) {
281
+ ownProps = _objectSpread2({}, props !== null && props !== void 0 ? props : {});
282
+ if (!ownProps["data-val-path"]) {
283
+ ownProps["data-val-path"] = Array.from(new Set(paths)).join(",");
284
+ }
285
+ }
286
+ }
287
+ addValPathIfFound(type, ownProps);
288
+ return createElement.call.apply(createElement, [createElement, type, ownProps].concat(_toConsumableArray(cleaned)));
289
+ };
290
+ }
291
+ /** Whether the runtimes are wrapped already: wrapping twice cleans twice. */
292
+ var installed = false;
220
293
  function autoTagJSX() {
294
+ if (installed) {
295
+ return;
296
+ }
297
+ installed = true;
221
298
  var JsxPro = ReactJSXRuntime__default;
222
299
  var JsxDev = jsxRuntimeDev__default;
223
300
 
224
301
  /**
225
302
  * createElement _may_ be called by jsx runtime as a fallback in certain cases,
226
- * so we need to wrap it regardless.
303
+ * and libraries call it directly, so we need to wrap it regardless.
227
304
  *
228
305
  * The jsx exports depend on the `NODE_ENV` var to ensure the users' bundler doesn't
229
306
  * include both, so one of them will be set with `undefined` values.
230
307
  */
231
- React.createElement = WrapJsx(React.createElement);
308
+ React.createElement = WrapCreateElement(React.createElement);
232
309
  // eslint-disable-next-line @typescript-eslint/no-unused-expressions
233
310
  JsxDev.jsx && (/* */JsxDev.jsx = WrapJsx(JsxDev.jsx));
234
311
  // eslint-disable-next-line @typescript-eslint/no-unused-expressions
@@ -6,30 +6,6 @@ var core = require('@valbuild/core');
6
6
  var stega = require('@vercel/stega');
7
7
  var slicedToArray = require('./slicedToArray-64c83d56.cjs.prod.js');
8
8
 
9
- function stegaDecodeStrings(encodedString) {
10
- if (!encodedString || typeof encodedString !== "string") return;
11
- var encodedBits = stega.vercelStegaDecodeAll(encodedString);
12
- var paths = [];
13
- if (!encodedBits) return;
14
- var _iterator = createForOfIteratorHelper._createForOfIteratorHelper(encodedBits),
15
- _step;
16
- try {
17
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
18
- var encodedBit = _step.value;
19
- if (encodedBit && _typeof._typeof(encodedBit) === "object") {
20
- if ("origin" in encodedBit && "data" in encodedBit && _typeof._typeof(encodedBit.data) === "object" && encodedBit.data && "valPath" in encodedBit.data && typeof encodedBit.data.valPath === "string") {
21
- paths.push(encodedBit.data.valPath);
22
- }
23
- }
24
- }
25
- } catch (err) {
26
- _iterator.e(err);
27
- } finally {
28
- _iterator.f();
29
- }
30
- return paths.length > 0 ? paths : undefined;
31
- }
32
-
33
9
  function _toPrimitive(t, r) {
34
10
  if ("object" != typeof t || !t) return t;
35
11
  var e = t[Symbol.toPrimitive];
@@ -77,6 +53,30 @@ function _objectSpread2(e) {
77
53
  return e;
78
54
  }
79
55
 
56
+ function stegaDecodeStrings(encodedString) {
57
+ if (!encodedString || typeof encodedString !== "string") return;
58
+ var encodedBits = stega.vercelStegaDecodeAll(encodedString);
59
+ var paths = [];
60
+ if (!encodedBits) return;
61
+ var _iterator = createForOfIteratorHelper._createForOfIteratorHelper(encodedBits),
62
+ _step;
63
+ try {
64
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
65
+ var encodedBit = _step.value;
66
+ if (encodedBit && _typeof._typeof(encodedBit) === "object") {
67
+ if ("origin" in encodedBit && "data" in encodedBit && _typeof._typeof(encodedBit.data) === "object" && encodedBit.data && "valPath" in encodedBit.data && typeof encodedBit.data.valPath === "string") {
68
+ paths.push(encodedBit.data.valPath);
69
+ }
70
+ }
71
+ }
72
+ } catch (err) {
73
+ _iterator.e(err);
74
+ } finally {
75
+ _iterator.f();
76
+ }
77
+ return paths.length > 0 ? paths : undefined;
78
+ }
79
+
80
80
  /**
81
81
  * ValEncodedString is a string that is encoded using steganography.
82
82
  *
@@ -6,30 +6,6 @@ var core = require('@valbuild/core');
6
6
  var stega = require('@vercel/stega');
7
7
  var slicedToArray = require('./slicedToArray-387314c6.cjs.dev.js');
8
8
 
9
- function stegaDecodeStrings(encodedString) {
10
- if (!encodedString || typeof encodedString !== "string") return;
11
- var encodedBits = stega.vercelStegaDecodeAll(encodedString);
12
- var paths = [];
13
- if (!encodedBits) return;
14
- var _iterator = createForOfIteratorHelper._createForOfIteratorHelper(encodedBits),
15
- _step;
16
- try {
17
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
18
- var encodedBit = _step.value;
19
- if (encodedBit && _typeof._typeof(encodedBit) === "object") {
20
- if ("origin" in encodedBit && "data" in encodedBit && _typeof._typeof(encodedBit.data) === "object" && encodedBit.data && "valPath" in encodedBit.data && typeof encodedBit.data.valPath === "string") {
21
- paths.push(encodedBit.data.valPath);
22
- }
23
- }
24
- }
25
- } catch (err) {
26
- _iterator.e(err);
27
- } finally {
28
- _iterator.f();
29
- }
30
- return paths.length > 0 ? paths : undefined;
31
- }
32
-
33
9
  function _toPrimitive(t, r) {
34
10
  if ("object" != typeof t || !t) return t;
35
11
  var e = t[Symbol.toPrimitive];
@@ -77,6 +53,30 @@ function _objectSpread2(e) {
77
53
  return e;
78
54
  }
79
55
 
56
+ function stegaDecodeStrings(encodedString) {
57
+ if (!encodedString || typeof encodedString !== "string") return;
58
+ var encodedBits = stega.vercelStegaDecodeAll(encodedString);
59
+ var paths = [];
60
+ if (!encodedBits) return;
61
+ var _iterator = createForOfIteratorHelper._createForOfIteratorHelper(encodedBits),
62
+ _step;
63
+ try {
64
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
65
+ var encodedBit = _step.value;
66
+ if (encodedBit && _typeof._typeof(encodedBit) === "object") {
67
+ if ("origin" in encodedBit && "data" in encodedBit && _typeof._typeof(encodedBit.data) === "object" && encodedBit.data && "valPath" in encodedBit.data && typeof encodedBit.data.valPath === "string") {
68
+ paths.push(encodedBit.data.valPath);
69
+ }
70
+ }
71
+ }
72
+ } catch (err) {
73
+ _iterator.e(err);
74
+ } finally {
75
+ _iterator.f();
76
+ }
77
+ return paths.length > 0 ? paths : undefined;
78
+ }
79
+
80
80
  /**
81
81
  * ValEncodedString is a string that is encoded using steganography.
82
82
  *