@valbuild/react 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.
@@ -1,6 +1,6 @@
1
1
  export { autoTagJSX } from "./autoTagJSX.js";
2
2
  export { stegaEncode, getModuleIds, stegaClean, type ValEncodedString, type StegaOfSource, type StegaOfRichTextSource, type File, type Image, type RichText, } from "./stegaEncode.js";
3
- export { stegaDecodeString } from "./stegaDecodeString.js";
3
+ export { stegaDecodeStrings } from "./stegaDecodeStrings.js";
4
4
  export declare function IS_AUTO_TAG_JSX_ENABLED(): boolean;
5
5
  export declare function SET_AUTO_TAG_JSX_ENABLED(enabled: boolean): void;
6
6
  export declare function IS_RSC(): boolean;
@@ -0,0 +1 @@
1
+ export declare function stegaDecodeStrings(encodedString: unknown): string[] | undefined;
@@ -160,10 +160,7 @@ export type StegaOfRichTextSource<T extends Source> = Json extends T ? Json : T
160
160
  /**
161
161
  * RichText is accessible by users (after conversion via useVal / fetchVal)
162
162
  **/
163
- export type RichText<O extends RichTextOptions> = StegaOfRichTextSource<RichTextSource<O>> & {
164
- /** This path is used internally by Val to identify where this RichText source is defined */
165
- valPath?: string;
166
- };
163
+ export type RichText<O extends RichTextOptions> = StegaOfRichTextSource<RichTextSource<O>>;
167
164
  export type StegaOfSource<T extends Source> = Json extends T ? Json : T extends RichTextSource<infer O> ? RichText<O> : T extends ImageSource ? Image : T extends FileSource<infer M> ? M extends FileMetadata ? File<M> : never : T extends SourceObject ? {
168
165
  [key in keyof T]: StegaOfSource<T[key]>;
169
166
  } : T extends SourceArray ? StegaOfSource<T[number]>[] : T extends RawString ? string : string extends T ? ValEncodedString : T extends JsonPrimitive ? T : never;
@@ -99,7 +99,6 @@ function ValRichText(_ref) {
99
99
  return /*#__PURE__*/jsx("div", {
100
100
  className: className,
101
101
  style: style,
102
- "data-val-path": root === null || root === void 0 ? void 0 : root.valPath,
103
102
  children: root === null || root === void 0 ? void 0 : root.map(build)
104
103
  });
105
104
  }
@@ -107,7 +107,6 @@ function ValRichText(_ref) {
107
107
  return /*#__PURE__*/ReactJSXRuntime.jsx("div", {
108
108
  className: className,
109
109
  style: style,
110
- "data-val-path": root === null || root === void 0 ? void 0 : root.valPath,
111
110
  children: root === null || root === void 0 ? void 0 : root.map(build)
112
111
  });
113
112
  }
@@ -107,7 +107,6 @@ function ValRichText(_ref) {
107
107
  return /*#__PURE__*/ReactJSXRuntime.jsx("div", {
108
108
  className: className,
109
109
  style: style,
110
- "data-val-path": root === null || root === void 0 ? void 0 : root.valPath,
111
110
  children: root === null || root === void 0 ? void 0 : root.map(build)
112
111
  });
113
112
  }
@@ -99,7 +99,6 @@ function ValRichText(_ref) {
99
99
  return /*#__PURE__*/jsx("div", {
100
100
  className: className,
101
101
  style: style,
102
- "data-val-path": root === null || root === void 0 ? void 0 : root.valPath,
103
102
  children: root === null || root === void 0 ? void 0 : root.map(build)
104
103
  });
105
104
  }
@@ -99,7 +99,6 @@ function ValRichText(_ref) {
99
99
  return /*#__PURE__*/jsx("div", {
100
100
  className: className,
101
101
  style: style,
102
- "data-val-path": root === null || root === void 0 ? void 0 : root.valPath,
103
102
  children: root === null || root === void 0 ? void 0 : root.map(build)
104
103
  });
105
104
  }
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@valbuild/react",
3
- "version": "0.87.5",
3
+ "version": "0.89.0",
4
4
  "private": false,
5
5
  "description": "Val - React internal helpers",
6
6
  "repository": {
7
7
  "type": "git",
8
- "url": "https://github.com/valbuild/val.git"
8
+ "url": "git+https://github.com/valbuild/val.git"
9
9
  },
10
10
  "sideEffects": false,
11
11
  "scripts": {
@@ -13,9 +13,9 @@
13
13
  "test": "jest"
14
14
  },
15
15
  "dependencies": {
16
- "@valbuild/core": "~0.87.5",
17
- "@valbuild/shared": "~0.87.5",
18
- "@valbuild/ui": "~0.87.5",
16
+ "@valbuild/core": "~0.89.0",
17
+ "@valbuild/shared": "~0.89.0",
18
+ "@valbuild/ui": "~0.89.0",
19
19
  "@vercel/stega": "^0.1.0",
20
20
  "base64-arraybuffer": "^1.0.2"
21
21
  },
@@ -1,20 +1,83 @@
1
1
  import { a as _typeof, _ as _slicedToArray } from '../../dist/slicedToArray-9ebce1ca.browser.esm.js';
2
+ import { _ as _unsupportedIterableToArray } from '../../dist/unsupportedIterableToArray-0ac4ac41.browser.esm.js';
2
3
  import ReactJSXRuntime__default from 'react/jsx-runtime';
3
4
  import jsxRuntimeDev__default from 'react/jsx-dev-runtime';
4
5
  import React from 'react';
5
- import { vercelStegaDecode, VERCEL_STEGA_REGEX, vercelStegaSplit, vercelStegaCombine } from '@vercel/stega';
6
+ import { vercelStegaDecodeAll, VERCEL_STEGA_REGEX, vercelStegaSplit, vercelStegaCombine } from '@vercel/stega';
6
7
  import { _ as _toConsumableArray } from '../../dist/toConsumableArray-5ba6766a.browser.esm.js';
7
8
  import { Internal, VAL_EXTENSION, FILE_REF_PROP } from '@valbuild/core';
8
- import '../../dist/unsupportedIterableToArray-0ac4ac41.browser.esm.js';
9
9
 
10
- function stegaDecodeString(encodedString) {
10
+ function _createForOfIteratorHelper(r, e) {
11
+ var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
12
+ if (!t) {
13
+ if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) {
14
+ t && (r = t);
15
+ var n = 0,
16
+ F = function () {};
17
+ return {
18
+ s: F,
19
+ n: function () {
20
+ return n >= r.length ? {
21
+ done: !0
22
+ } : {
23
+ done: !1,
24
+ value: r[n++]
25
+ };
26
+ },
27
+ e: function (r) {
28
+ throw r;
29
+ },
30
+ f: F
31
+ };
32
+ }
33
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
34
+ }
35
+ var o,
36
+ a = !0,
37
+ u = !1;
38
+ return {
39
+ s: function () {
40
+ t = t.call(r);
41
+ },
42
+ n: function () {
43
+ var r = t.next();
44
+ return a = r.done, r;
45
+ },
46
+ e: function (r) {
47
+ u = !0, o = r;
48
+ },
49
+ f: function () {
50
+ try {
51
+ a || null == t.return || t.return();
52
+ } finally {
53
+ if (u) throw o;
54
+ }
55
+ }
56
+ };
57
+ }
58
+
59
+ function stegaDecodeStrings(encodedString) {
11
60
  if (!encodedString || typeof encodedString !== "string") return;
12
- var encodedBits = vercelStegaDecode(encodedString);
13
- if (encodedBits && _typeof(encodedBits) === "object") {
14
- if ("origin" in encodedBits && "data" in encodedBits && _typeof(encodedBits.data) === "object" && encodedBits.data && "valPath" in encodedBits.data && typeof encodedBits.data.valPath === "string") {
15
- return encodedBits.data.valPath;
61
+ var encodedBits = vercelStegaDecodeAll(encodedString);
62
+ var paths = [];
63
+ if (!encodedBits) return;
64
+ var _iterator = _createForOfIteratorHelper(encodedBits),
65
+ _step;
66
+ try {
67
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
68
+ var encodedBit = _step.value;
69
+ if (encodedBit && _typeof(encodedBit) === "object") {
70
+ if ("origin" in encodedBit && "data" in encodedBit && _typeof(encodedBit.data) === "object" && encodedBit.data && "valPath" in encodedBit.data && typeof encodedBit.data.valPath === "string") {
71
+ paths.push(encodedBit.data.valPath);
72
+ }
73
+ }
16
74
  }
75
+ } catch (err) {
76
+ _iterator.e(err);
77
+ } finally {
78
+ _iterator.f();
17
79
  }
80
+ return paths.length > 0 ? paths : undefined;
18
81
  }
19
82
 
20
83
  var isIntrinsicElement = function isIntrinsicElement(type) {
@@ -41,14 +104,25 @@ var addValPathIfFound = function addValPathIfFound(type, props) {
41
104
  console.error('Val: Could not auto tag. Reason: key is "__proto__" or "constructor" or "prototype".');
42
105
  return;
43
106
  }
44
- var valPath = stegaDecodeString(value);
45
- if (valPath) {
107
+ var valPaths = stegaDecodeStrings(value);
108
+ if (valPaths) {
46
109
  // Found val path - this is a stega encoded string
47
110
  // The logic below is as follows:
48
111
  // if this is an intrinsic element (a, div, etc.), add data attrs will be on the DOM element
49
112
  // always add to sources (intrinsic or not)
50
113
  // if this is not an intrinsic element, we pass the stega encoded value downwards until we hit an intrinsic element
51
- valSources.add(valPath);
114
+ var _iterator = _createForOfIteratorHelper(valPaths),
115
+ _step;
116
+ try {
117
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
118
+ var _valPath = _step.value;
119
+ valSources.add(_valPath);
120
+ }
121
+ } catch (err) {
122
+ _iterator.e(err);
123
+ } finally {
124
+ _iterator.f();
125
+ }
52
126
  if (isIntrinsicElement(type)) {
53
127
  // clean values before adding them to the props
54
128
  // we cannot do this
@@ -68,7 +142,18 @@ var addValPathIfFound = function addValPathIfFound(type, props) {
68
142
  var _cleanValue = vercelStegaSplit(value).cleaned;
69
143
  if (typeof key === "string" && !Array.isArray(container)) {
70
144
  container[key] = _cleanValue;
71
- valSources.add(valPath);
145
+ var _iterator2 = _createForOfIteratorHelper(valPaths),
146
+ _step2;
147
+ try {
148
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
149
+ var valPath = _step2.value;
150
+ valSources.add(valPath);
151
+ }
152
+ } catch (err) {
153
+ _iterator2.e(err);
154
+ } finally {
155
+ _iterator2.f();
156
+ }
72
157
  }
73
158
  }
74
159
  }
@@ -255,11 +340,35 @@ function stegaEncode(input, opts) {
255
340
  }
256
341
  }
257
342
  if (recOpts !== null && recOpts !== void 0 && recOpts.schema && isRichTextSchema(recOpts.schema)) {
258
- var res = rec(sourceOrSelector);
259
- if (_typeof(res) === "object" && res !== null) {
260
- res.valPath = recOpts.path;
343
+ if (typeof sourceOrSelector === "string") {
344
+ return rec(sourceOrSelector, {
345
+ path: recOpts.path,
346
+ schema: {
347
+ type: "string"
348
+ }
349
+ });
261
350
  }
262
- return res;
351
+ if (Array.isArray(sourceOrSelector)) {
352
+ var a = sourceOrSelector.map(function (el) {
353
+ return rec(el, {
354
+ path: recOpts.path,
355
+ schema: recOpts.schema
356
+ });
357
+ });
358
+ return a;
359
+ } else if (_typeof(sourceOrSelector) === "object") {
360
+ var _a = Object.fromEntries(Object.entries(sourceOrSelector).map(function (_ref2) {
361
+ var _ref3 = _slicedToArray(_ref2, 2),
362
+ key = _ref3[0],
363
+ value = _ref3[1];
364
+ return [key, key === "tag" || key === "styles" ? value : rec(value, {
365
+ path: recOpts.path,
366
+ schema: recOpts.schema
367
+ })];
368
+ }));
369
+ return _a;
370
+ }
371
+ return sourceOrSelector;
263
372
  }
264
373
  if (_typeof(sourceOrSelector) === "object") {
265
374
  if (!sourceOrSelector) {
@@ -299,18 +408,18 @@ function stegaEncode(input, opts) {
299
408
  });
300
409
  }
301
410
  if (!Array.isArray(sourceOrSelector)) {
302
- var _res = {};
411
+ var res = {};
303
412
  var entries = Object.entries(sourceOrSelector);
304
413
  for (var _i = 0, _entries = entries; _i < _entries.length; _i++) {
305
414
  var _entries$_i = _slicedToArray(_entries[_i], 2),
306
415
  _key2 = _entries$_i[0],
307
416
  value = _entries$_i[1];
308
- _res[_key2] = rec(value, (recOpts === null || recOpts === void 0 ? void 0 : recOpts.schema) && {
417
+ res[_key2] = rec(value, (recOpts === null || recOpts === void 0 ? void 0 : recOpts.schema) && {
309
418
  path: Internal.createValPathOfItem(recOpts.path, _key2),
310
419
  schema: isRecordSchema(recOpts.schema) ? recOpts.schema.item : isObjectSchema(recOpts.schema) ? recOpts.schema.items[_key2] : unknownSchema(recOpts.schema)
311
420
  });
312
421
  }
313
- return _res;
422
+ return res;
314
423
  }
315
424
  console.error("Could not transform source selector: ".concat(_typeof(sourceOrSelector), " (array: ").concat(Array.isArray(sourceOrSelector), ")"), sourceOrSelector);
316
425
  return sourceOrSelector;
@@ -433,4 +542,4 @@ function SET_RSC(enabled) {
433
542
  isRSC = enabled;
434
543
  }
435
544
 
436
- export { IS_AUTO_TAG_JSX_ENABLED, IS_RSC, SET_AUTO_TAG_JSX_ENABLED, SET_RSC, autoTagJSX, getModuleIds, stegaClean, stegaDecodeString, stegaEncode };
545
+ export { IS_AUTO_TAG_JSX_ENABLED, IS_RSC, SET_AUTO_TAG_JSX_ENABLED, SET_RSC, autoTagJSX, getModuleIds, stegaClean, stegaDecodeStrings, stegaEncode };
@@ -3,13 +3,13 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var slicedToArray = require('../../dist/slicedToArray-b5020f32.cjs.dev.js');
6
+ var unsupportedIterableToArray = require('../../dist/unsupportedIterableToArray-20a9209f.cjs.dev.js');
6
7
  var ReactJSXRuntime = require('react/jsx-runtime');
7
8
  var jsxRuntimeDev = require('react/jsx-dev-runtime');
8
9
  var React = require('react');
9
10
  var stega = require('@vercel/stega');
10
11
  var toConsumableArray = require('../../dist/toConsumableArray-1969d309.cjs.dev.js');
11
12
  var core = require('@valbuild/core');
12
- require('../../dist/unsupportedIterableToArray-20a9209f.cjs.dev.js');
13
13
 
14
14
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
15
15
 
@@ -17,14 +17,77 @@ var ReactJSXRuntime__default = /*#__PURE__*/_interopDefault(ReactJSXRuntime);
17
17
  var jsxRuntimeDev__default = /*#__PURE__*/_interopDefault(jsxRuntimeDev);
18
18
  var React__default = /*#__PURE__*/_interopDefault(React);
19
19
 
20
- function stegaDecodeString(encodedString) {
20
+ function _createForOfIteratorHelper(r, e) {
21
+ var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
22
+ if (!t) {
23
+ if (Array.isArray(r) || (t = unsupportedIterableToArray._unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) {
24
+ t && (r = t);
25
+ var n = 0,
26
+ F = function () {};
27
+ return {
28
+ s: F,
29
+ n: function () {
30
+ return n >= r.length ? {
31
+ done: !0
32
+ } : {
33
+ done: !1,
34
+ value: r[n++]
35
+ };
36
+ },
37
+ e: function (r) {
38
+ throw r;
39
+ },
40
+ f: F
41
+ };
42
+ }
43
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
44
+ }
45
+ var o,
46
+ a = !0,
47
+ u = !1;
48
+ return {
49
+ s: function () {
50
+ t = t.call(r);
51
+ },
52
+ n: function () {
53
+ var r = t.next();
54
+ return a = r.done, r;
55
+ },
56
+ e: function (r) {
57
+ u = !0, o = r;
58
+ },
59
+ f: function () {
60
+ try {
61
+ a || null == t.return || t.return();
62
+ } finally {
63
+ if (u) throw o;
64
+ }
65
+ }
66
+ };
67
+ }
68
+
69
+ function stegaDecodeStrings(encodedString) {
21
70
  if (!encodedString || typeof encodedString !== "string") return;
22
- var encodedBits = stega.vercelStegaDecode(encodedString);
23
- if (encodedBits && slicedToArray._typeof(encodedBits) === "object") {
24
- if ("origin" in encodedBits && "data" in encodedBits && slicedToArray._typeof(encodedBits.data) === "object" && encodedBits.data && "valPath" in encodedBits.data && typeof encodedBits.data.valPath === "string") {
25
- return encodedBits.data.valPath;
71
+ var encodedBits = stega.vercelStegaDecodeAll(encodedString);
72
+ var paths = [];
73
+ if (!encodedBits) return;
74
+ var _iterator = _createForOfIteratorHelper(encodedBits),
75
+ _step;
76
+ try {
77
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
78
+ var encodedBit = _step.value;
79
+ if (encodedBit && slicedToArray._typeof(encodedBit) === "object") {
80
+ if ("origin" in encodedBit && "data" in encodedBit && slicedToArray._typeof(encodedBit.data) === "object" && encodedBit.data && "valPath" in encodedBit.data && typeof encodedBit.data.valPath === "string") {
81
+ paths.push(encodedBit.data.valPath);
82
+ }
83
+ }
26
84
  }
85
+ } catch (err) {
86
+ _iterator.e(err);
87
+ } finally {
88
+ _iterator.f();
27
89
  }
90
+ return paths.length > 0 ? paths : undefined;
28
91
  }
29
92
 
30
93
  var isIntrinsicElement = function isIntrinsicElement(type) {
@@ -51,14 +114,25 @@ var addValPathIfFound = function addValPathIfFound(type, props) {
51
114
  console.error('Val: Could not auto tag. Reason: key is "__proto__" or "constructor" or "prototype".');
52
115
  return;
53
116
  }
54
- var valPath = stegaDecodeString(value);
55
- if (valPath) {
117
+ var valPaths = stegaDecodeStrings(value);
118
+ if (valPaths) {
56
119
  // Found val path - this is a stega encoded string
57
120
  // The logic below is as follows:
58
121
  // if this is an intrinsic element (a, div, etc.), add data attrs will be on the DOM element
59
122
  // always add to sources (intrinsic or not)
60
123
  // if this is not an intrinsic element, we pass the stega encoded value downwards until we hit an intrinsic element
61
- valSources.add(valPath);
124
+ var _iterator = _createForOfIteratorHelper(valPaths),
125
+ _step;
126
+ try {
127
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
128
+ var _valPath = _step.value;
129
+ valSources.add(_valPath);
130
+ }
131
+ } catch (err) {
132
+ _iterator.e(err);
133
+ } finally {
134
+ _iterator.f();
135
+ }
62
136
  if (isIntrinsicElement(type)) {
63
137
  // clean values before adding them to the props
64
138
  // we cannot do this
@@ -78,7 +152,18 @@ var addValPathIfFound = function addValPathIfFound(type, props) {
78
152
  var _cleanValue = stega.vercelStegaSplit(value).cleaned;
79
153
  if (typeof key === "string" && !Array.isArray(container)) {
80
154
  container[key] = _cleanValue;
81
- valSources.add(valPath);
155
+ var _iterator2 = _createForOfIteratorHelper(valPaths),
156
+ _step2;
157
+ try {
158
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
159
+ var valPath = _step2.value;
160
+ valSources.add(valPath);
161
+ }
162
+ } catch (err) {
163
+ _iterator2.e(err);
164
+ } finally {
165
+ _iterator2.f();
166
+ }
82
167
  }
83
168
  }
84
169
  }
@@ -265,11 +350,35 @@ function stegaEncode(input, opts) {
265
350
  }
266
351
  }
267
352
  if (recOpts !== null && recOpts !== void 0 && recOpts.schema && isRichTextSchema(recOpts.schema)) {
268
- var res = rec(sourceOrSelector);
269
- if (slicedToArray._typeof(res) === "object" && res !== null) {
270
- res.valPath = recOpts.path;
353
+ if (typeof sourceOrSelector === "string") {
354
+ return rec(sourceOrSelector, {
355
+ path: recOpts.path,
356
+ schema: {
357
+ type: "string"
358
+ }
359
+ });
271
360
  }
272
- return res;
361
+ if (Array.isArray(sourceOrSelector)) {
362
+ var a = sourceOrSelector.map(function (el) {
363
+ return rec(el, {
364
+ path: recOpts.path,
365
+ schema: recOpts.schema
366
+ });
367
+ });
368
+ return a;
369
+ } else if (slicedToArray._typeof(sourceOrSelector) === "object") {
370
+ var _a = Object.fromEntries(Object.entries(sourceOrSelector).map(function (_ref2) {
371
+ var _ref3 = slicedToArray._slicedToArray(_ref2, 2),
372
+ key = _ref3[0],
373
+ value = _ref3[1];
374
+ return [key, key === "tag" || key === "styles" ? value : rec(value, {
375
+ path: recOpts.path,
376
+ schema: recOpts.schema
377
+ })];
378
+ }));
379
+ return _a;
380
+ }
381
+ return sourceOrSelector;
273
382
  }
274
383
  if (slicedToArray._typeof(sourceOrSelector) === "object") {
275
384
  if (!sourceOrSelector) {
@@ -309,18 +418,18 @@ function stegaEncode(input, opts) {
309
418
  });
310
419
  }
311
420
  if (!Array.isArray(sourceOrSelector)) {
312
- var _res = {};
421
+ var res = {};
313
422
  var entries = Object.entries(sourceOrSelector);
314
423
  for (var _i = 0, _entries = entries; _i < _entries.length; _i++) {
315
424
  var _entries$_i = slicedToArray._slicedToArray(_entries[_i], 2),
316
425
  _key2 = _entries$_i[0],
317
426
  value = _entries$_i[1];
318
- _res[_key2] = rec(value, (recOpts === null || recOpts === void 0 ? void 0 : recOpts.schema) && {
427
+ res[_key2] = rec(value, (recOpts === null || recOpts === void 0 ? void 0 : recOpts.schema) && {
319
428
  path: core.Internal.createValPathOfItem(recOpts.path, _key2),
320
429
  schema: isRecordSchema(recOpts.schema) ? recOpts.schema.item : isObjectSchema(recOpts.schema) ? recOpts.schema.items[_key2] : unknownSchema(recOpts.schema)
321
430
  });
322
431
  }
323
- return _res;
432
+ return res;
324
433
  }
325
434
  console.error("Could not transform source selector: ".concat(slicedToArray._typeof(sourceOrSelector), " (array: ").concat(Array.isArray(sourceOrSelector), ")"), sourceOrSelector);
326
435
  return sourceOrSelector;
@@ -450,5 +559,5 @@ exports.SET_RSC = SET_RSC;
450
559
  exports.autoTagJSX = autoTagJSX;
451
560
  exports.getModuleIds = getModuleIds;
452
561
  exports.stegaClean = stegaClean;
453
- exports.stegaDecodeString = stegaDecodeString;
562
+ exports.stegaDecodeStrings = stegaDecodeStrings;
454
563
  exports.stegaEncode = stegaEncode;
@@ -3,13 +3,13 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var slicedToArray = require('../../dist/slicedToArray-09243dae.cjs.prod.js');
6
+ var unsupportedIterableToArray = require('../../dist/unsupportedIterableToArray-1aadf9fb.cjs.prod.js');
6
7
  var ReactJSXRuntime = require('react/jsx-runtime');
7
8
  var jsxRuntimeDev = require('react/jsx-dev-runtime');
8
9
  var React = require('react');
9
10
  var stega = require('@vercel/stega');
10
11
  var toConsumableArray = require('../../dist/toConsumableArray-b772a825.cjs.prod.js');
11
12
  var core = require('@valbuild/core');
12
- require('../../dist/unsupportedIterableToArray-1aadf9fb.cjs.prod.js');
13
13
 
14
14
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
15
15
 
@@ -17,14 +17,77 @@ var ReactJSXRuntime__default = /*#__PURE__*/_interopDefault(ReactJSXRuntime);
17
17
  var jsxRuntimeDev__default = /*#__PURE__*/_interopDefault(jsxRuntimeDev);
18
18
  var React__default = /*#__PURE__*/_interopDefault(React);
19
19
 
20
- function stegaDecodeString(encodedString) {
20
+ function _createForOfIteratorHelper(r, e) {
21
+ var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
22
+ if (!t) {
23
+ if (Array.isArray(r) || (t = unsupportedIterableToArray._unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) {
24
+ t && (r = t);
25
+ var n = 0,
26
+ F = function () {};
27
+ return {
28
+ s: F,
29
+ n: function () {
30
+ return n >= r.length ? {
31
+ done: !0
32
+ } : {
33
+ done: !1,
34
+ value: r[n++]
35
+ };
36
+ },
37
+ e: function (r) {
38
+ throw r;
39
+ },
40
+ f: F
41
+ };
42
+ }
43
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
44
+ }
45
+ var o,
46
+ a = !0,
47
+ u = !1;
48
+ return {
49
+ s: function () {
50
+ t = t.call(r);
51
+ },
52
+ n: function () {
53
+ var r = t.next();
54
+ return a = r.done, r;
55
+ },
56
+ e: function (r) {
57
+ u = !0, o = r;
58
+ },
59
+ f: function () {
60
+ try {
61
+ a || null == t.return || t.return();
62
+ } finally {
63
+ if (u) throw o;
64
+ }
65
+ }
66
+ };
67
+ }
68
+
69
+ function stegaDecodeStrings(encodedString) {
21
70
  if (!encodedString || typeof encodedString !== "string") return;
22
- var encodedBits = stega.vercelStegaDecode(encodedString);
23
- if (encodedBits && slicedToArray._typeof(encodedBits) === "object") {
24
- if ("origin" in encodedBits && "data" in encodedBits && slicedToArray._typeof(encodedBits.data) === "object" && encodedBits.data && "valPath" in encodedBits.data && typeof encodedBits.data.valPath === "string") {
25
- return encodedBits.data.valPath;
71
+ var encodedBits = stega.vercelStegaDecodeAll(encodedString);
72
+ var paths = [];
73
+ if (!encodedBits) return;
74
+ var _iterator = _createForOfIteratorHelper(encodedBits),
75
+ _step;
76
+ try {
77
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
78
+ var encodedBit = _step.value;
79
+ if (encodedBit && slicedToArray._typeof(encodedBit) === "object") {
80
+ if ("origin" in encodedBit && "data" in encodedBit && slicedToArray._typeof(encodedBit.data) === "object" && encodedBit.data && "valPath" in encodedBit.data && typeof encodedBit.data.valPath === "string") {
81
+ paths.push(encodedBit.data.valPath);
82
+ }
83
+ }
26
84
  }
85
+ } catch (err) {
86
+ _iterator.e(err);
87
+ } finally {
88
+ _iterator.f();
27
89
  }
90
+ return paths.length > 0 ? paths : undefined;
28
91
  }
29
92
 
30
93
  var isIntrinsicElement = function isIntrinsicElement(type) {
@@ -51,14 +114,25 @@ var addValPathIfFound = function addValPathIfFound(type, props) {
51
114
  console.error('Val: Could not auto tag. Reason: key is "__proto__" or "constructor" or "prototype".');
52
115
  return;
53
116
  }
54
- var valPath = stegaDecodeString(value);
55
- if (valPath) {
117
+ var valPaths = stegaDecodeStrings(value);
118
+ if (valPaths) {
56
119
  // Found val path - this is a stega encoded string
57
120
  // The logic below is as follows:
58
121
  // if this is an intrinsic element (a, div, etc.), add data attrs will be on the DOM element
59
122
  // always add to sources (intrinsic or not)
60
123
  // if this is not an intrinsic element, we pass the stega encoded value downwards until we hit an intrinsic element
61
- valSources.add(valPath);
124
+ var _iterator = _createForOfIteratorHelper(valPaths),
125
+ _step;
126
+ try {
127
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
128
+ var _valPath = _step.value;
129
+ valSources.add(_valPath);
130
+ }
131
+ } catch (err) {
132
+ _iterator.e(err);
133
+ } finally {
134
+ _iterator.f();
135
+ }
62
136
  if (isIntrinsicElement(type)) {
63
137
  // clean values before adding them to the props
64
138
  // we cannot do this
@@ -78,7 +152,18 @@ var addValPathIfFound = function addValPathIfFound(type, props) {
78
152
  var _cleanValue = stega.vercelStegaSplit(value).cleaned;
79
153
  if (typeof key === "string" && !Array.isArray(container)) {
80
154
  container[key] = _cleanValue;
81
- valSources.add(valPath);
155
+ var _iterator2 = _createForOfIteratorHelper(valPaths),
156
+ _step2;
157
+ try {
158
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
159
+ var valPath = _step2.value;
160
+ valSources.add(valPath);
161
+ }
162
+ } catch (err) {
163
+ _iterator2.e(err);
164
+ } finally {
165
+ _iterator2.f();
166
+ }
82
167
  }
83
168
  }
84
169
  }
@@ -265,11 +350,35 @@ function stegaEncode(input, opts) {
265
350
  }
266
351
  }
267
352
  if (recOpts !== null && recOpts !== void 0 && recOpts.schema && isRichTextSchema(recOpts.schema)) {
268
- var res = rec(sourceOrSelector);
269
- if (slicedToArray._typeof(res) === "object" && res !== null) {
270
- res.valPath = recOpts.path;
353
+ if (typeof sourceOrSelector === "string") {
354
+ return rec(sourceOrSelector, {
355
+ path: recOpts.path,
356
+ schema: {
357
+ type: "string"
358
+ }
359
+ });
271
360
  }
272
- return res;
361
+ if (Array.isArray(sourceOrSelector)) {
362
+ var a = sourceOrSelector.map(function (el) {
363
+ return rec(el, {
364
+ path: recOpts.path,
365
+ schema: recOpts.schema
366
+ });
367
+ });
368
+ return a;
369
+ } else if (slicedToArray._typeof(sourceOrSelector) === "object") {
370
+ var _a = Object.fromEntries(Object.entries(sourceOrSelector).map(function (_ref2) {
371
+ var _ref3 = slicedToArray._slicedToArray(_ref2, 2),
372
+ key = _ref3[0],
373
+ value = _ref3[1];
374
+ return [key, key === "tag" || key === "styles" ? value : rec(value, {
375
+ path: recOpts.path,
376
+ schema: recOpts.schema
377
+ })];
378
+ }));
379
+ return _a;
380
+ }
381
+ return sourceOrSelector;
273
382
  }
274
383
  if (slicedToArray._typeof(sourceOrSelector) === "object") {
275
384
  if (!sourceOrSelector) {
@@ -309,18 +418,18 @@ function stegaEncode(input, opts) {
309
418
  });
310
419
  }
311
420
  if (!Array.isArray(sourceOrSelector)) {
312
- var _res = {};
421
+ var res = {};
313
422
  var entries = Object.entries(sourceOrSelector);
314
423
  for (var _i = 0, _entries = entries; _i < _entries.length; _i++) {
315
424
  var _entries$_i = slicedToArray._slicedToArray(_entries[_i], 2),
316
425
  _key2 = _entries$_i[0],
317
426
  value = _entries$_i[1];
318
- _res[_key2] = rec(value, (recOpts === null || recOpts === void 0 ? void 0 : recOpts.schema) && {
427
+ res[_key2] = rec(value, (recOpts === null || recOpts === void 0 ? void 0 : recOpts.schema) && {
319
428
  path: core.Internal.createValPathOfItem(recOpts.path, _key2),
320
429
  schema: isRecordSchema(recOpts.schema) ? recOpts.schema.item : isObjectSchema(recOpts.schema) ? recOpts.schema.items[_key2] : unknownSchema(recOpts.schema)
321
430
  });
322
431
  }
323
- return _res;
432
+ return res;
324
433
  }
325
434
  console.error("Could not transform source selector: ".concat(slicedToArray._typeof(sourceOrSelector), " (array: ").concat(Array.isArray(sourceOrSelector), ")"), sourceOrSelector);
326
435
  return sourceOrSelector;
@@ -450,5 +559,5 @@ exports.SET_RSC = SET_RSC;
450
559
  exports.autoTagJSX = autoTagJSX;
451
560
  exports.getModuleIds = getModuleIds;
452
561
  exports.stegaClean = stegaClean;
453
- exports.stegaDecodeString = stegaDecodeString;
562
+ exports.stegaDecodeStrings = stegaDecodeStrings;
454
563
  exports.stegaEncode = stegaEncode;
@@ -1,20 +1,83 @@
1
1
  import { a as _typeof, _ as _slicedToArray } from '../../dist/slicedToArray-5391d3c0.esm.js';
2
+ import { _ as _unsupportedIterableToArray } from '../../dist/unsupportedIterableToArray-f57eb659.esm.js';
2
3
  import ReactJSXRuntime__default from 'react/jsx-runtime';
3
4
  import jsxRuntimeDev__default from 'react/jsx-dev-runtime';
4
5
  import React from 'react';
5
- import { vercelStegaDecode, VERCEL_STEGA_REGEX, vercelStegaSplit, vercelStegaCombine } from '@vercel/stega';
6
+ import { vercelStegaDecodeAll, VERCEL_STEGA_REGEX, vercelStegaSplit, vercelStegaCombine } from '@vercel/stega';
6
7
  import { _ as _toConsumableArray } from '../../dist/toConsumableArray-9f3cfc47.esm.js';
7
8
  import { Internal, VAL_EXTENSION, FILE_REF_PROP } from '@valbuild/core';
8
- import '../../dist/unsupportedIterableToArray-f57eb659.esm.js';
9
9
 
10
- function stegaDecodeString(encodedString) {
10
+ function _createForOfIteratorHelper(r, e) {
11
+ var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
12
+ if (!t) {
13
+ if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) {
14
+ t && (r = t);
15
+ var n = 0,
16
+ F = function () {};
17
+ return {
18
+ s: F,
19
+ n: function () {
20
+ return n >= r.length ? {
21
+ done: !0
22
+ } : {
23
+ done: !1,
24
+ value: r[n++]
25
+ };
26
+ },
27
+ e: function (r) {
28
+ throw r;
29
+ },
30
+ f: F
31
+ };
32
+ }
33
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
34
+ }
35
+ var o,
36
+ a = !0,
37
+ u = !1;
38
+ return {
39
+ s: function () {
40
+ t = t.call(r);
41
+ },
42
+ n: function () {
43
+ var r = t.next();
44
+ return a = r.done, r;
45
+ },
46
+ e: function (r) {
47
+ u = !0, o = r;
48
+ },
49
+ f: function () {
50
+ try {
51
+ a || null == t.return || t.return();
52
+ } finally {
53
+ if (u) throw o;
54
+ }
55
+ }
56
+ };
57
+ }
58
+
59
+ function stegaDecodeStrings(encodedString) {
11
60
  if (!encodedString || typeof encodedString !== "string") return;
12
- var encodedBits = vercelStegaDecode(encodedString);
13
- if (encodedBits && _typeof(encodedBits) === "object") {
14
- if ("origin" in encodedBits && "data" in encodedBits && _typeof(encodedBits.data) === "object" && encodedBits.data && "valPath" in encodedBits.data && typeof encodedBits.data.valPath === "string") {
15
- return encodedBits.data.valPath;
61
+ var encodedBits = vercelStegaDecodeAll(encodedString);
62
+ var paths = [];
63
+ if (!encodedBits) return;
64
+ var _iterator = _createForOfIteratorHelper(encodedBits),
65
+ _step;
66
+ try {
67
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
68
+ var encodedBit = _step.value;
69
+ if (encodedBit && _typeof(encodedBit) === "object") {
70
+ if ("origin" in encodedBit && "data" in encodedBit && _typeof(encodedBit.data) === "object" && encodedBit.data && "valPath" in encodedBit.data && typeof encodedBit.data.valPath === "string") {
71
+ paths.push(encodedBit.data.valPath);
72
+ }
73
+ }
16
74
  }
75
+ } catch (err) {
76
+ _iterator.e(err);
77
+ } finally {
78
+ _iterator.f();
17
79
  }
80
+ return paths.length > 0 ? paths : undefined;
18
81
  }
19
82
 
20
83
  var isIntrinsicElement = function isIntrinsicElement(type) {
@@ -41,14 +104,25 @@ var addValPathIfFound = function addValPathIfFound(type, props) {
41
104
  console.error('Val: Could not auto tag. Reason: key is "__proto__" or "constructor" or "prototype".');
42
105
  return;
43
106
  }
44
- var valPath = stegaDecodeString(value);
45
- if (valPath) {
107
+ var valPaths = stegaDecodeStrings(value);
108
+ if (valPaths) {
46
109
  // Found val path - this is a stega encoded string
47
110
  // The logic below is as follows:
48
111
  // if this is an intrinsic element (a, div, etc.), add data attrs will be on the DOM element
49
112
  // always add to sources (intrinsic or not)
50
113
  // if this is not an intrinsic element, we pass the stega encoded value downwards until we hit an intrinsic element
51
- valSources.add(valPath);
114
+ var _iterator = _createForOfIteratorHelper(valPaths),
115
+ _step;
116
+ try {
117
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
118
+ var _valPath = _step.value;
119
+ valSources.add(_valPath);
120
+ }
121
+ } catch (err) {
122
+ _iterator.e(err);
123
+ } finally {
124
+ _iterator.f();
125
+ }
52
126
  if (isIntrinsicElement(type)) {
53
127
  // clean values before adding them to the props
54
128
  // we cannot do this
@@ -68,7 +142,18 @@ var addValPathIfFound = function addValPathIfFound(type, props) {
68
142
  var _cleanValue = vercelStegaSplit(value).cleaned;
69
143
  if (typeof key === "string" && !Array.isArray(container)) {
70
144
  container[key] = _cleanValue;
71
- valSources.add(valPath);
145
+ var _iterator2 = _createForOfIteratorHelper(valPaths),
146
+ _step2;
147
+ try {
148
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
149
+ var valPath = _step2.value;
150
+ valSources.add(valPath);
151
+ }
152
+ } catch (err) {
153
+ _iterator2.e(err);
154
+ } finally {
155
+ _iterator2.f();
156
+ }
72
157
  }
73
158
  }
74
159
  }
@@ -255,11 +340,35 @@ function stegaEncode(input, opts) {
255
340
  }
256
341
  }
257
342
  if (recOpts !== null && recOpts !== void 0 && recOpts.schema && isRichTextSchema(recOpts.schema)) {
258
- var res = rec(sourceOrSelector);
259
- if (_typeof(res) === "object" && res !== null) {
260
- res.valPath = recOpts.path;
343
+ if (typeof sourceOrSelector === "string") {
344
+ return rec(sourceOrSelector, {
345
+ path: recOpts.path,
346
+ schema: {
347
+ type: "string"
348
+ }
349
+ });
261
350
  }
262
- return res;
351
+ if (Array.isArray(sourceOrSelector)) {
352
+ var a = sourceOrSelector.map(function (el) {
353
+ return rec(el, {
354
+ path: recOpts.path,
355
+ schema: recOpts.schema
356
+ });
357
+ });
358
+ return a;
359
+ } else if (_typeof(sourceOrSelector) === "object") {
360
+ var _a = Object.fromEntries(Object.entries(sourceOrSelector).map(function (_ref2) {
361
+ var _ref3 = _slicedToArray(_ref2, 2),
362
+ key = _ref3[0],
363
+ value = _ref3[1];
364
+ return [key, key === "tag" || key === "styles" ? value : rec(value, {
365
+ path: recOpts.path,
366
+ schema: recOpts.schema
367
+ })];
368
+ }));
369
+ return _a;
370
+ }
371
+ return sourceOrSelector;
263
372
  }
264
373
  if (_typeof(sourceOrSelector) === "object") {
265
374
  if (!sourceOrSelector) {
@@ -299,18 +408,18 @@ function stegaEncode(input, opts) {
299
408
  });
300
409
  }
301
410
  if (!Array.isArray(sourceOrSelector)) {
302
- var _res = {};
411
+ var res = {};
303
412
  var entries = Object.entries(sourceOrSelector);
304
413
  for (var _i = 0, _entries = entries; _i < _entries.length; _i++) {
305
414
  var _entries$_i = _slicedToArray(_entries[_i], 2),
306
415
  _key2 = _entries$_i[0],
307
416
  value = _entries$_i[1];
308
- _res[_key2] = rec(value, (recOpts === null || recOpts === void 0 ? void 0 : recOpts.schema) && {
417
+ res[_key2] = rec(value, (recOpts === null || recOpts === void 0 ? void 0 : recOpts.schema) && {
309
418
  path: Internal.createValPathOfItem(recOpts.path, _key2),
310
419
  schema: isRecordSchema(recOpts.schema) ? recOpts.schema.item : isObjectSchema(recOpts.schema) ? recOpts.schema.items[_key2] : unknownSchema(recOpts.schema)
311
420
  });
312
421
  }
313
- return _res;
422
+ return res;
314
423
  }
315
424
  console.error("Could not transform source selector: ".concat(_typeof(sourceOrSelector), " (array: ").concat(Array.isArray(sourceOrSelector), ")"), sourceOrSelector);
316
425
  return sourceOrSelector;
@@ -433,4 +542,4 @@ function SET_RSC(enabled) {
433
542
  isRSC = enabled;
434
543
  }
435
544
 
436
- export { IS_AUTO_TAG_JSX_ENABLED, IS_RSC, SET_AUTO_TAG_JSX_ENABLED, SET_RSC, autoTagJSX, getModuleIds, stegaClean, stegaDecodeString, stegaEncode };
545
+ export { IS_AUTO_TAG_JSX_ENABLED, IS_RSC, SET_AUTO_TAG_JSX_ENABLED, SET_RSC, autoTagJSX, getModuleIds, stegaClean, stegaDecodeStrings, stegaEncode };
@@ -1,20 +1,83 @@
1
1
  import { a as _typeof, _ as _slicedToArray } from '../../dist/slicedToArray-bbda5dad.worker.esm.js';
2
+ import { _ as _unsupportedIterableToArray } from '../../dist/unsupportedIterableToArray-10eaf95e.worker.esm.js';
2
3
  import ReactJSXRuntime__default from 'react/jsx-runtime';
3
4
  import jsxRuntimeDev__default from 'react/jsx-dev-runtime';
4
5
  import React from 'react';
5
- import { vercelStegaDecode, VERCEL_STEGA_REGEX, vercelStegaSplit, vercelStegaCombine } from '@vercel/stega';
6
+ import { vercelStegaDecodeAll, VERCEL_STEGA_REGEX, vercelStegaSplit, vercelStegaCombine } from '@vercel/stega';
6
7
  import { _ as _toConsumableArray } from '../../dist/toConsumableArray-299fbd28.worker.esm.js';
7
8
  import { Internal, VAL_EXTENSION, FILE_REF_PROP } from '@valbuild/core';
8
- import '../../dist/unsupportedIterableToArray-10eaf95e.worker.esm.js';
9
9
 
10
- function stegaDecodeString(encodedString) {
10
+ function _createForOfIteratorHelper(r, e) {
11
+ var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
12
+ if (!t) {
13
+ if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) {
14
+ t && (r = t);
15
+ var n = 0,
16
+ F = function () {};
17
+ return {
18
+ s: F,
19
+ n: function () {
20
+ return n >= r.length ? {
21
+ done: !0
22
+ } : {
23
+ done: !1,
24
+ value: r[n++]
25
+ };
26
+ },
27
+ e: function (r) {
28
+ throw r;
29
+ },
30
+ f: F
31
+ };
32
+ }
33
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
34
+ }
35
+ var o,
36
+ a = !0,
37
+ u = !1;
38
+ return {
39
+ s: function () {
40
+ t = t.call(r);
41
+ },
42
+ n: function () {
43
+ var r = t.next();
44
+ return a = r.done, r;
45
+ },
46
+ e: function (r) {
47
+ u = !0, o = r;
48
+ },
49
+ f: function () {
50
+ try {
51
+ a || null == t.return || t.return();
52
+ } finally {
53
+ if (u) throw o;
54
+ }
55
+ }
56
+ };
57
+ }
58
+
59
+ function stegaDecodeStrings(encodedString) {
11
60
  if (!encodedString || typeof encodedString !== "string") return;
12
- var encodedBits = vercelStegaDecode(encodedString);
13
- if (encodedBits && _typeof(encodedBits) === "object") {
14
- if ("origin" in encodedBits && "data" in encodedBits && _typeof(encodedBits.data) === "object" && encodedBits.data && "valPath" in encodedBits.data && typeof encodedBits.data.valPath === "string") {
15
- return encodedBits.data.valPath;
61
+ var encodedBits = vercelStegaDecodeAll(encodedString);
62
+ var paths = [];
63
+ if (!encodedBits) return;
64
+ var _iterator = _createForOfIteratorHelper(encodedBits),
65
+ _step;
66
+ try {
67
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
68
+ var encodedBit = _step.value;
69
+ if (encodedBit && _typeof(encodedBit) === "object") {
70
+ if ("origin" in encodedBit && "data" in encodedBit && _typeof(encodedBit.data) === "object" && encodedBit.data && "valPath" in encodedBit.data && typeof encodedBit.data.valPath === "string") {
71
+ paths.push(encodedBit.data.valPath);
72
+ }
73
+ }
16
74
  }
75
+ } catch (err) {
76
+ _iterator.e(err);
77
+ } finally {
78
+ _iterator.f();
17
79
  }
80
+ return paths.length > 0 ? paths : undefined;
18
81
  }
19
82
 
20
83
  var isIntrinsicElement = function isIntrinsicElement(type) {
@@ -41,14 +104,25 @@ var addValPathIfFound = function addValPathIfFound(type, props) {
41
104
  console.error('Val: Could not auto tag. Reason: key is "__proto__" or "constructor" or "prototype".');
42
105
  return;
43
106
  }
44
- var valPath = stegaDecodeString(value);
45
- if (valPath) {
107
+ var valPaths = stegaDecodeStrings(value);
108
+ if (valPaths) {
46
109
  // Found val path - this is a stega encoded string
47
110
  // The logic below is as follows:
48
111
  // if this is an intrinsic element (a, div, etc.), add data attrs will be on the DOM element
49
112
  // always add to sources (intrinsic or not)
50
113
  // if this is not an intrinsic element, we pass the stega encoded value downwards until we hit an intrinsic element
51
- valSources.add(valPath);
114
+ var _iterator = _createForOfIteratorHelper(valPaths),
115
+ _step;
116
+ try {
117
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
118
+ var _valPath = _step.value;
119
+ valSources.add(_valPath);
120
+ }
121
+ } catch (err) {
122
+ _iterator.e(err);
123
+ } finally {
124
+ _iterator.f();
125
+ }
52
126
  if (isIntrinsicElement(type)) {
53
127
  // clean values before adding them to the props
54
128
  // we cannot do this
@@ -68,7 +142,18 @@ var addValPathIfFound = function addValPathIfFound(type, props) {
68
142
  var _cleanValue = vercelStegaSplit(value).cleaned;
69
143
  if (typeof key === "string" && !Array.isArray(container)) {
70
144
  container[key] = _cleanValue;
71
- valSources.add(valPath);
145
+ var _iterator2 = _createForOfIteratorHelper(valPaths),
146
+ _step2;
147
+ try {
148
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
149
+ var valPath = _step2.value;
150
+ valSources.add(valPath);
151
+ }
152
+ } catch (err) {
153
+ _iterator2.e(err);
154
+ } finally {
155
+ _iterator2.f();
156
+ }
72
157
  }
73
158
  }
74
159
  }
@@ -255,11 +340,35 @@ function stegaEncode(input, opts) {
255
340
  }
256
341
  }
257
342
  if (recOpts !== null && recOpts !== void 0 && recOpts.schema && isRichTextSchema(recOpts.schema)) {
258
- var res = rec(sourceOrSelector);
259
- if (_typeof(res) === "object" && res !== null) {
260
- res.valPath = recOpts.path;
343
+ if (typeof sourceOrSelector === "string") {
344
+ return rec(sourceOrSelector, {
345
+ path: recOpts.path,
346
+ schema: {
347
+ type: "string"
348
+ }
349
+ });
261
350
  }
262
- return res;
351
+ if (Array.isArray(sourceOrSelector)) {
352
+ var a = sourceOrSelector.map(function (el) {
353
+ return rec(el, {
354
+ path: recOpts.path,
355
+ schema: recOpts.schema
356
+ });
357
+ });
358
+ return a;
359
+ } else if (_typeof(sourceOrSelector) === "object") {
360
+ var _a = Object.fromEntries(Object.entries(sourceOrSelector).map(function (_ref2) {
361
+ var _ref3 = _slicedToArray(_ref2, 2),
362
+ key = _ref3[0],
363
+ value = _ref3[1];
364
+ return [key, key === "tag" || key === "styles" ? value : rec(value, {
365
+ path: recOpts.path,
366
+ schema: recOpts.schema
367
+ })];
368
+ }));
369
+ return _a;
370
+ }
371
+ return sourceOrSelector;
263
372
  }
264
373
  if (_typeof(sourceOrSelector) === "object") {
265
374
  if (!sourceOrSelector) {
@@ -299,18 +408,18 @@ function stegaEncode(input, opts) {
299
408
  });
300
409
  }
301
410
  if (!Array.isArray(sourceOrSelector)) {
302
- var _res = {};
411
+ var res = {};
303
412
  var entries = Object.entries(sourceOrSelector);
304
413
  for (var _i = 0, _entries = entries; _i < _entries.length; _i++) {
305
414
  var _entries$_i = _slicedToArray(_entries[_i], 2),
306
415
  _key2 = _entries$_i[0],
307
416
  value = _entries$_i[1];
308
- _res[_key2] = rec(value, (recOpts === null || recOpts === void 0 ? void 0 : recOpts.schema) && {
417
+ res[_key2] = rec(value, (recOpts === null || recOpts === void 0 ? void 0 : recOpts.schema) && {
309
418
  path: Internal.createValPathOfItem(recOpts.path, _key2),
310
419
  schema: isRecordSchema(recOpts.schema) ? recOpts.schema.item : isObjectSchema(recOpts.schema) ? recOpts.schema.items[_key2] : unknownSchema(recOpts.schema)
311
420
  });
312
421
  }
313
- return _res;
422
+ return res;
314
423
  }
315
424
  console.error("Could not transform source selector: ".concat(_typeof(sourceOrSelector), " (array: ").concat(Array.isArray(sourceOrSelector), ")"), sourceOrSelector);
316
425
  return sourceOrSelector;
@@ -433,4 +542,4 @@ function SET_RSC(enabled) {
433
542
  isRSC = enabled;
434
543
  }
435
544
 
436
- export { IS_AUTO_TAG_JSX_ENABLED, IS_RSC, SET_AUTO_TAG_JSX_ENABLED, SET_RSC, autoTagJSX, getModuleIds, stegaClean, stegaDecodeString, stegaEncode };
545
+ export { IS_AUTO_TAG_JSX_ENABLED, IS_RSC, SET_AUTO_TAG_JSX_ENABLED, SET_RSC, autoTagJSX, getModuleIds, stegaClean, stegaDecodeStrings, stegaEncode };
@@ -1 +0,0 @@
1
- export declare function stegaDecodeString(encodedString: unknown): string | undefined;