@valbuild/react 0.13.4 → 0.14.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.
Files changed (63) hide show
  1. package/README.md +11 -0
  2. package/dist/{ValProvider-07551558.esm.js → ValProvider-2eb6c2f2.esm.js} +3 -33
  3. package/dist/ValProvider-74eef393.cjs.js +7 -0
  4. package/dist/{ValProvider-d8fe7dc4.cjs.prod.js → ValProvider-74eef393.cjs.prod.js} +6 -37
  5. package/dist/{ValProvider-11be7088.browser.esm.js → ValProvider-c677e164.browser.esm.js} +3 -33
  6. package/dist/{ValProvider-50aa4ba8.worker.esm.js → ValProvider-cb5a2161.worker.esm.js} +1 -31
  7. package/dist/{ValProvider-7b9d888e.cjs.dev.js → ValProvider-f647e355.cjs.dev.js} +6 -37
  8. package/dist/{ValUI-5e993a19.cjs.prod.js → ValUI-0c2671a7.cjs.prod.js} +12 -28
  9. package/dist/{ValUI-ac6ae690.cjs.dev.js → ValUI-334ef1d0.cjs.dev.js} +12 -28
  10. package/dist/{ValUI-4844450a.browser.esm.js → ValUI-bb1d1ed6.browser.esm.js} +11 -27
  11. package/dist/{ValUI-599818da.esm.js → ValUI-bf82178a.esm.js} +11 -27
  12. package/dist/declarations/src/ValProvider.d.ts +2 -2
  13. package/dist/declarations/src/ValRichText.d.ts +5 -0
  14. package/dist/declarations/src/ValStore.d.ts +1 -1
  15. package/dist/declarations/src/index.d.ts +3 -2
  16. package/dist/declarations/src/jsx-runtime.d.ts +1 -1
  17. package/dist/declarations/src/stega/autoTagJSX.d.ts +1 -0
  18. package/dist/declarations/src/stega/fetchVal.d.ts +3 -0
  19. package/dist/declarations/src/stega/hooks/useVal.d.ts +3 -0
  20. package/dist/declarations/src/stega/index.d.ts +4 -0
  21. package/dist/declarations/src/stega/stegaEncode.d.ts +24 -0
  22. package/dist/defineProperty-12b5bd29.esm.js +32 -0
  23. package/dist/defineProperty-36ed93cd.cjs.prod.js +35 -0
  24. package/dist/defineProperty-a4bf59bc.worker.esm.js +32 -0
  25. package/dist/defineProperty-c82a49b0.cjs.dev.js +35 -0
  26. package/dist/defineProperty-f319cb47.browser.esm.js +32 -0
  27. package/dist/objectSpread2-30cc2856.browser.esm.js +25 -0
  28. package/dist/objectSpread2-61fbd9a9.cjs.dev.js +27 -0
  29. package/dist/objectSpread2-7b752a35.cjs.prod.js +27 -0
  30. package/dist/objectSpread2-d5a1fe1c.esm.js +25 -0
  31. package/dist/valbuild-react.browser.esm.js +138 -2
  32. package/dist/valbuild-react.cjs.dev.js +142 -1
  33. package/dist/valbuild-react.cjs.prod.js +142 -1
  34. package/dist/valbuild-react.esm.js +138 -2
  35. package/dist/valbuild-react.worker.esm.js +138 -2
  36. package/jsx-dev-runtime/dist/valbuild-react-jsx-dev-runtime.browser.esm.js +2 -2
  37. package/jsx-dev-runtime/dist/valbuild-react-jsx-dev-runtime.cjs.dev.js +5 -5
  38. package/jsx-dev-runtime/dist/valbuild-react-jsx-dev-runtime.cjs.prod.js +5 -5
  39. package/jsx-dev-runtime/dist/valbuild-react-jsx-dev-runtime.esm.js +2 -2
  40. package/jsx-dev-runtime/dist/valbuild-react-jsx-dev-runtime.worker.esm.js +2 -2
  41. package/package.json +14 -4
  42. package/src/ShadowRoot.tsx +8 -4
  43. package/src/ValRichText.tsx +177 -0
  44. package/src/index.ts +2 -3
  45. package/src/stega/autoTagJSX.ts +80 -0
  46. package/src/stega/fetchVal.ts +16 -0
  47. package/src/stega/hooks/useVal.ts +14 -0
  48. package/src/stega/index.ts +5 -0
  49. package/src/stega/stegaEncode.ts +84 -0
  50. package/stega/README.md +3 -0
  51. package/stega/dist/valbuild-react-stega.browser.esm.js +126 -0
  52. package/stega/dist/valbuild-react-stega.cjs.d.ts +2 -0
  53. package/stega/dist/valbuild-react-stega.cjs.d.ts.map +1 -0
  54. package/stega/dist/valbuild-react-stega.cjs.dev.js +138 -0
  55. package/stega/dist/valbuild-react-stega.cjs.js +7 -0
  56. package/stega/dist/valbuild-react-stega.cjs.prod.js +138 -0
  57. package/stega/dist/valbuild-react-stega.esm.js +126 -0
  58. package/stega/dist/valbuild-react-stega.worker.esm.js +147 -0
  59. package/stega/package.json +7 -0
  60. package/dist/ValProvider-d8fe7dc4.cjs.js +0 -7
  61. package/dist/declarations/src/AuthStatus.d.ts +0 -6
  62. package/dist/declarations/src/ShadowRoot.d.ts +0 -4
  63. package/dist/declarations/src/ValUI.d.ts +0 -8
@@ -0,0 +1,138 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var slicedToArray = require('../../dist/slicedToArray-0eb0bcdb.cjs.prod.js');
6
+ var ReactJSXRuntime = require('react/jsx-runtime');
7
+ var jsxRuntimeDev = require('react/jsx-dev-runtime');
8
+ var React = require('react');
9
+ var stega = require('@vercel/stega');
10
+ var objectSpread2 = require('../../dist/objectSpread2-7b752a35.cjs.prod.js');
11
+ var core = require('@valbuild/core');
12
+ var react = require('@valbuild/react');
13
+ require('../../dist/unsupportedIterableToArray-afbea1dd.cjs.prod.js');
14
+ require('../../dist/defineProperty-36ed93cd.cjs.prod.js');
15
+
16
+ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
17
+
18
+ var ReactJSXRuntime__default = /*#__PURE__*/_interopDefault(ReactJSXRuntime);
19
+ var jsxRuntimeDev__default = /*#__PURE__*/_interopDefault(jsxRuntimeDev);
20
+ var React__default = /*#__PURE__*/_interopDefault(React);
21
+
22
+ var isIntrinsicElement = function isIntrinsicElement(type) {
23
+ // TODO: think this is not correct, but good enough for now?
24
+ return typeof type === "string";
25
+ };
26
+ var addValPathIfFound = function addValPathIfFound(type, props) {
27
+ var valSources = [];
28
+ if (isIntrinsicElement(type) && props && slicedToArray._typeof(props) === "object") {
29
+ for (var _i = 0, _Object$entries = Object.entries(props); _i < _Object$entries.length; _i++) {
30
+ var _Object$entries$_i = slicedToArray._slicedToArray(_Object$entries[_i], 2),
31
+ key = _Object$entries$_i[0],
32
+ value = _Object$entries$_i[1];
33
+ if (typeof value === "string" && value.match(stega.VERCEL_STEGA_REGEX)) {
34
+ var encodedBits = stega.vercelStegaDecode(value);
35
+ if (!encodedBits || slicedToArray._typeof(encodedBits) !== "object") continue;
36
+ if ("origin" in encodedBits && "data" in encodedBits && slicedToArray._typeof(encodedBits.data) === "object" && encodedBits.data && "valPath" in encodedBits.data) {
37
+ var _encodedBits$data;
38
+ var valPath = encodedBits === null || encodedBits === void 0 ? void 0 : (_encodedBits$data = encodedBits.data) === null || _encodedBits$data === void 0 ? void 0 : _encodedBits$data.valPath;
39
+ if (valPath) {
40
+ console.log("Found encoded valPath", valPath);
41
+ valSources.push(valPath);
42
+ props[key] = stega.vercelStegaSplit(value).cleaned;
43
+ }
44
+ }
45
+ }
46
+ }
47
+ if (valSources.length > 0) {
48
+ props["data-val-path"] = valSources.join(",");
49
+ }
50
+ }
51
+ };
52
+ function WrapJsx(jsx) {
53
+ if (typeof jsx !== "function") return jsx;
54
+ return function (type, props) {
55
+ addValPathIfFound(type, props);
56
+ for (var _len = arguments.length, rest = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
57
+ rest[_key - 2] = arguments[_key];
58
+ }
59
+ return jsx.call.apply(jsx, [jsx, type, props].concat(rest));
60
+ };
61
+ }
62
+ function autoTagJSX() {
63
+ var JsxPro = ReactJSXRuntime__default["default"];
64
+ var JsxDev = jsxRuntimeDev__default["default"];
65
+
66
+ /**
67
+ * createElement _may_ be called by jsx runtime as a fallback in certain cases,
68
+ * so we need to wrap it regardless.
69
+ *
70
+ * The jsx exports depend on the `NODE_ENV` var to ensure the users' bundler doesn't
71
+ * include both, so one of them will be set with `undefined` values.
72
+ */
73
+ React__default["default"].createElement = WrapJsx(React__default["default"].createElement);
74
+ JsxDev.jsx && ( /* */JsxDev.jsx = WrapJsx(JsxDev.jsx));
75
+ JsxPro.jsx && ( /* */JsxPro.jsx = WrapJsx(JsxPro.jsx));
76
+ JsxDev.jsxs && ( /* */JsxDev.jsxs = WrapJsx(JsxDev.jsxs));
77
+ JsxPro.jsxs && ( /* */JsxPro.jsxs = WrapJsx(JsxPro.jsxs));
78
+ JsxDev.jsxDEV && ( /**/JsxDev.jsxDEV = WrapJsx(JsxDev.jsxDEV));
79
+ JsxPro.jsxDEV && ( /**/JsxPro.jsxDEV = WrapJsx(JsxPro.jsxDEV));
80
+ }
81
+
82
+ /**
83
+ * ValEncodedString is a string that is encoded using steganography.
84
+ *
85
+ * This means that there is a hidden / non-visible object embedded in the string.
86
+ * This object includes a path, which is used to automatically tag
87
+ * where the content comes from for contextual editing.
88
+ *
89
+ */
90
+
91
+ function stegaEncodeVal(val) {
92
+ if (slicedToArray._typeof(val.val) === "object") {
93
+ if (Array.isArray(val)) {
94
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
95
+ return val.map(stegaEncodeVal);
96
+ }
97
+ if (slicedToArray._typeof(val.val) === "object" && val.val && "_type" in val.val && val.val["_type"] === "richtext") {
98
+ return objectSpread2._objectSpread2(objectSpread2._objectSpread2({}, val.val), {}, {
99
+ valPath: core.Internal.getValPath(val)
100
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
101
+ });
102
+ }
103
+
104
+ return Object.fromEntries(Object.entries(val).map(function (_ref) {
105
+ var _ref2 = slicedToArray._slicedToArray(_ref, 2),
106
+ key = _ref2[0],
107
+ value = _ref2[1];
108
+ return [key, stegaEncodeVal(value)];
109
+ }));
110
+ }
111
+ if (typeof val.val === "string") {
112
+ return stega.vercelStegaCombine(val.val, {
113
+ origin: "val.build",
114
+ data: {
115
+ valPath: core.Internal.getValPath(val)
116
+ }
117
+ }, !isDate(val.val)); // TODO: skip should false at least for URLs? Dates...?
118
+ }
119
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
120
+ return val.val;
121
+ }
122
+ function isDate(s) {
123
+ return Boolean(Date.parse(s));
124
+ }
125
+
126
+ function fetchVal(selector, locale) {
127
+ return core.Internal.fetchVal(selector, locale).then(function (val) {
128
+ return stegaEncodeVal(val);
129
+ });
130
+ }
131
+
132
+ function useVal(selector, locale) {
133
+ return stegaEncodeVal(react.useVal(selector, locale));
134
+ }
135
+
136
+ exports.autoTagJSX = autoTagJSX;
137
+ exports.fetchVal = fetchVal;
138
+ exports.useVal = useVal;
@@ -0,0 +1,126 @@
1
+ import { a as _typeof, _ as _slicedToArray } from '../../dist/slicedToArray-d846e1d2.esm.js';
2
+ import ReactJSXRuntime__default from 'react/jsx-runtime';
3
+ import jsxRuntimeDev__default from 'react/jsx-dev-runtime';
4
+ import React from 'react';
5
+ import { VERCEL_STEGA_REGEX, vercelStegaDecode, vercelStegaSplit, vercelStegaCombine } from '@vercel/stega';
6
+ import { _ as _objectSpread2 } from '../../dist/objectSpread2-d5a1fe1c.esm.js';
7
+ import { Internal } from '@valbuild/core';
8
+ import { useVal as useVal$1 } from '@valbuild/react';
9
+ import '../../dist/unsupportedIterableToArray-51bb61c2.esm.js';
10
+ import '../../dist/defineProperty-12b5bd29.esm.js';
11
+
12
+ var isIntrinsicElement = function isIntrinsicElement(type) {
13
+ // TODO: think this is not correct, but good enough for now?
14
+ return typeof type === "string";
15
+ };
16
+ var addValPathIfFound = function addValPathIfFound(type, props) {
17
+ var valSources = [];
18
+ if (isIntrinsicElement(type) && props && _typeof(props) === "object") {
19
+ for (var _i = 0, _Object$entries = Object.entries(props); _i < _Object$entries.length; _i++) {
20
+ var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
21
+ key = _Object$entries$_i[0],
22
+ value = _Object$entries$_i[1];
23
+ if (typeof value === "string" && value.match(VERCEL_STEGA_REGEX)) {
24
+ var encodedBits = vercelStegaDecode(value);
25
+ if (!encodedBits || _typeof(encodedBits) !== "object") continue;
26
+ if ("origin" in encodedBits && "data" in encodedBits && _typeof(encodedBits.data) === "object" && encodedBits.data && "valPath" in encodedBits.data) {
27
+ var _encodedBits$data;
28
+ var valPath = encodedBits === null || encodedBits === void 0 ? void 0 : (_encodedBits$data = encodedBits.data) === null || _encodedBits$data === void 0 ? void 0 : _encodedBits$data.valPath;
29
+ if (valPath) {
30
+ console.log("Found encoded valPath", valPath);
31
+ valSources.push(valPath);
32
+ props[key] = vercelStegaSplit(value).cleaned;
33
+ }
34
+ }
35
+ }
36
+ }
37
+ if (valSources.length > 0) {
38
+ props["data-val-path"] = valSources.join(",");
39
+ }
40
+ }
41
+ };
42
+ function WrapJsx(jsx) {
43
+ if (typeof jsx !== "function") return jsx;
44
+ return function (type, props) {
45
+ addValPathIfFound(type, props);
46
+ for (var _len = arguments.length, rest = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
47
+ rest[_key - 2] = arguments[_key];
48
+ }
49
+ return jsx.call.apply(jsx, [jsx, type, props].concat(rest));
50
+ };
51
+ }
52
+ function autoTagJSX() {
53
+ var JsxPro = ReactJSXRuntime__default;
54
+ var JsxDev = jsxRuntimeDev__default;
55
+
56
+ /**
57
+ * createElement _may_ be called by jsx runtime as a fallback in certain cases,
58
+ * so we need to wrap it regardless.
59
+ *
60
+ * The jsx exports depend on the `NODE_ENV` var to ensure the users' bundler doesn't
61
+ * include both, so one of them will be set with `undefined` values.
62
+ */
63
+ React.createElement = WrapJsx(React.createElement);
64
+ JsxDev.jsx && ( /* */JsxDev.jsx = WrapJsx(JsxDev.jsx));
65
+ JsxPro.jsx && ( /* */JsxPro.jsx = WrapJsx(JsxPro.jsx));
66
+ JsxDev.jsxs && ( /* */JsxDev.jsxs = WrapJsx(JsxDev.jsxs));
67
+ JsxPro.jsxs && ( /* */JsxPro.jsxs = WrapJsx(JsxPro.jsxs));
68
+ JsxDev.jsxDEV && ( /**/JsxDev.jsxDEV = WrapJsx(JsxDev.jsxDEV));
69
+ JsxPro.jsxDEV && ( /**/JsxPro.jsxDEV = WrapJsx(JsxPro.jsxDEV));
70
+ }
71
+
72
+ /**
73
+ * ValEncodedString is a string that is encoded using steganography.
74
+ *
75
+ * This means that there is a hidden / non-visible object embedded in the string.
76
+ * This object includes a path, which is used to automatically tag
77
+ * where the content comes from for contextual editing.
78
+ *
79
+ */
80
+
81
+ function stegaEncodeVal(val) {
82
+ if (_typeof(val.val) === "object") {
83
+ if (Array.isArray(val)) {
84
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
85
+ return val.map(stegaEncodeVal);
86
+ }
87
+ if (_typeof(val.val) === "object" && val.val && "_type" in val.val && val.val["_type"] === "richtext") {
88
+ return _objectSpread2(_objectSpread2({}, val.val), {}, {
89
+ valPath: Internal.getValPath(val)
90
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
91
+ });
92
+ }
93
+
94
+ return Object.fromEntries(Object.entries(val).map(function (_ref) {
95
+ var _ref2 = _slicedToArray(_ref, 2),
96
+ key = _ref2[0],
97
+ value = _ref2[1];
98
+ return [key, stegaEncodeVal(value)];
99
+ }));
100
+ }
101
+ if (typeof val.val === "string") {
102
+ return vercelStegaCombine(val.val, {
103
+ origin: "val.build",
104
+ data: {
105
+ valPath: Internal.getValPath(val)
106
+ }
107
+ }, !isDate(val.val)); // TODO: skip should false at least for URLs? Dates...?
108
+ }
109
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
110
+ return val.val;
111
+ }
112
+ function isDate(s) {
113
+ return Boolean(Date.parse(s));
114
+ }
115
+
116
+ function fetchVal(selector, locale) {
117
+ return Internal.fetchVal(selector, locale).then(function (val) {
118
+ return stegaEncodeVal(val);
119
+ });
120
+ }
121
+
122
+ function useVal(selector, locale) {
123
+ return stegaEncodeVal(useVal$1(selector, locale));
124
+ }
125
+
126
+ export { autoTagJSX, fetchVal, useVal };
@@ -0,0 +1,147 @@
1
+ import { a as _typeof, _ as _slicedToArray } from '../../dist/slicedToArray-9e7d1407.worker.esm.js';
2
+ import ReactJSXRuntime__default from 'react/jsx-runtime';
3
+ import jsxRuntimeDev__default from 'react/jsx-dev-runtime';
4
+ import React from 'react';
5
+ import { VERCEL_STEGA_REGEX, vercelStegaDecode, vercelStegaSplit, vercelStegaCombine } from '@vercel/stega';
6
+ import { _ as _defineProperty } from '../../dist/defineProperty-a4bf59bc.worker.esm.js';
7
+ import { Internal } from '@valbuild/core';
8
+ import { useVal as useVal$1 } from '@valbuild/react';
9
+ import '../../dist/unsupportedIterableToArray-738344ef.worker.esm.js';
10
+
11
+ var isIntrinsicElement = function isIntrinsicElement(type) {
12
+ // TODO: think this is not correct, but good enough for now?
13
+ return typeof type === "string";
14
+ };
15
+ var addValPathIfFound = function addValPathIfFound(type, props) {
16
+ var valSources = [];
17
+ if (isIntrinsicElement(type) && props && _typeof(props) === "object") {
18
+ for (var _i = 0, _Object$entries = Object.entries(props); _i < _Object$entries.length; _i++) {
19
+ var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
20
+ key = _Object$entries$_i[0],
21
+ value = _Object$entries$_i[1];
22
+ if (typeof value === "string" && value.match(VERCEL_STEGA_REGEX)) {
23
+ var encodedBits = vercelStegaDecode(value);
24
+ if (!encodedBits || _typeof(encodedBits) !== "object") continue;
25
+ if ("origin" in encodedBits && "data" in encodedBits && _typeof(encodedBits.data) === "object" && encodedBits.data && "valPath" in encodedBits.data) {
26
+ var _encodedBits$data;
27
+ var valPath = encodedBits === null || encodedBits === void 0 ? void 0 : (_encodedBits$data = encodedBits.data) === null || _encodedBits$data === void 0 ? void 0 : _encodedBits$data.valPath;
28
+ if (valPath) {
29
+ console.log("Found encoded valPath", valPath);
30
+ valSources.push(valPath);
31
+ props[key] = vercelStegaSplit(value).cleaned;
32
+ }
33
+ }
34
+ }
35
+ }
36
+ if (valSources.length > 0) {
37
+ props["data-val-path"] = valSources.join(",");
38
+ }
39
+ }
40
+ };
41
+ function WrapJsx(jsx) {
42
+ if (typeof jsx !== "function") return jsx;
43
+ return function (type, props) {
44
+ addValPathIfFound(type, props);
45
+ for (var _len = arguments.length, rest = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
46
+ rest[_key - 2] = arguments[_key];
47
+ }
48
+ return jsx.call.apply(jsx, [jsx, type, props].concat(rest));
49
+ };
50
+ }
51
+ function autoTagJSX() {
52
+ var JsxPro = ReactJSXRuntime__default;
53
+ var JsxDev = jsxRuntimeDev__default;
54
+
55
+ /**
56
+ * createElement _may_ be called by jsx runtime as a fallback in certain cases,
57
+ * so we need to wrap it regardless.
58
+ *
59
+ * The jsx exports depend on the `NODE_ENV` var to ensure the users' bundler doesn't
60
+ * include both, so one of them will be set with `undefined` values.
61
+ */
62
+ React.createElement = WrapJsx(React.createElement);
63
+ JsxDev.jsx && ( /* */JsxDev.jsx = WrapJsx(JsxDev.jsx));
64
+ JsxPro.jsx && ( /* */JsxPro.jsx = WrapJsx(JsxPro.jsx));
65
+ JsxDev.jsxs && ( /* */JsxDev.jsxs = WrapJsx(JsxDev.jsxs));
66
+ JsxPro.jsxs && ( /* */JsxPro.jsxs = WrapJsx(JsxPro.jsxs));
67
+ JsxDev.jsxDEV && ( /**/JsxDev.jsxDEV = WrapJsx(JsxDev.jsxDEV));
68
+ JsxPro.jsxDEV && ( /**/JsxPro.jsxDEV = WrapJsx(JsxPro.jsxDEV));
69
+ }
70
+
71
+ function ownKeys(object, enumerableOnly) {
72
+ var keys = Object.keys(object);
73
+ if (Object.getOwnPropertySymbols) {
74
+ var symbols = Object.getOwnPropertySymbols(object);
75
+ enumerableOnly && (symbols = symbols.filter(function (sym) {
76
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
77
+ })), keys.push.apply(keys, symbols);
78
+ }
79
+ return keys;
80
+ }
81
+ function _objectSpread2(target) {
82
+ for (var i = 1; i < arguments.length; i++) {
83
+ var source = null != arguments[i] ? arguments[i] : {};
84
+ i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
85
+ _defineProperty(target, key, source[key]);
86
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
87
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
88
+ });
89
+ }
90
+ return target;
91
+ }
92
+
93
+ /**
94
+ * ValEncodedString is a string that is encoded using steganography.
95
+ *
96
+ * This means that there is a hidden / non-visible object embedded in the string.
97
+ * This object includes a path, which is used to automatically tag
98
+ * where the content comes from for contextual editing.
99
+ *
100
+ */
101
+
102
+ function stegaEncodeVal(val) {
103
+ if (_typeof(val.val) === "object") {
104
+ if (Array.isArray(val)) {
105
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
106
+ return val.map(stegaEncodeVal);
107
+ }
108
+ if (_typeof(val.val) === "object" && val.val && "_type" in val.val && val.val["_type"] === "richtext") {
109
+ return _objectSpread2(_objectSpread2({}, val.val), {}, {
110
+ valPath: Internal.getValPath(val)
111
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
112
+ });
113
+ }
114
+
115
+ return Object.fromEntries(Object.entries(val).map(function (_ref) {
116
+ var _ref2 = _slicedToArray(_ref, 2),
117
+ key = _ref2[0],
118
+ value = _ref2[1];
119
+ return [key, stegaEncodeVal(value)];
120
+ }));
121
+ }
122
+ if (typeof val.val === "string") {
123
+ return vercelStegaCombine(val.val, {
124
+ origin: "val.build",
125
+ data: {
126
+ valPath: Internal.getValPath(val)
127
+ }
128
+ }, !isDate(val.val)); // TODO: skip should false at least for URLs? Dates...?
129
+ }
130
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
131
+ return val.val;
132
+ }
133
+ function isDate(s) {
134
+ return Boolean(Date.parse(s));
135
+ }
136
+
137
+ function fetchVal(selector, locale) {
138
+ return Internal.fetchVal(selector, locale).then(function (val) {
139
+ return stegaEncodeVal(val);
140
+ });
141
+ }
142
+
143
+ function useVal(selector, locale) {
144
+ return stegaEncodeVal(useVal$1(selector, locale));
145
+ }
146
+
147
+ export { autoTagJSX, fetchVal, useVal };
@@ -0,0 +1,7 @@
1
+ {
2
+ "main": "dist/valbuild-react-stega.cjs.js",
3
+ "module": "dist/valbuild-react-stega.esm.js",
4
+ "browser": {
5
+ "./dist/valbuild-react-stega.esm.js": "./dist/valbuild-react-stega.browser.esm.js"
6
+ }
7
+ }
@@ -1,7 +0,0 @@
1
- 'use strict';
2
-
3
- if (process.env.NODE_ENV === "production") {
4
- module.exports = require("./ValProvider-d8fe7dc4.cjs.prod.js");
5
- } else {
6
- module.exports = require("./ValProvider-d8fe7dc4.cjs.dev.js");
7
- }
@@ -1,6 +0,0 @@
1
- export type AuthStatus = {
2
- status: "not-asked" | "authenticated" | "unauthenticated" | "loading" | "local";
3
- } | {
4
- status: "error";
5
- message: string;
6
- };
@@ -1,4 +0,0 @@
1
- /// <reference types="react" />
2
- export declare const ShadowRoot: ({ children }: {
3
- children: React.ReactNode;
4
- }) => JSX.Element;
@@ -1,8 +0,0 @@
1
- /// <reference types="react" />
2
- import { ValApi } from "./ValApi";
3
- import { ValStore } from "./ValStore";
4
- export type ValUIProps = {
5
- valStore: ValStore;
6
- valApi: ValApi;
7
- };
8
- export default function ValUI({ valApi, valStore }: ValUIProps): JSX.Element | null;