@valbuild/react 0.15.0 → 0.17.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 (82) hide show
  1. package/dist/ValUI-3e00aae3.cjs.prod.js +104 -0
  2. package/dist/ValUI-64e3e5f2.browser.esm.js +102 -0
  3. package/dist/ValUI-9ac161d2.cjs.dev.js +104 -0
  4. package/dist/ValUI-d33998d0.esm.js +102 -0
  5. package/dist/declarations/src/ValProvider.d.ts +1 -1
  6. package/dist/declarations/src/ValStore.d.ts +8 -9
  7. package/dist/declarations/src/index.d.ts +1 -2
  8. package/dist/declarations/src/stega/index.d.ts +1 -3
  9. package/dist/declarations/src/stega/{stegaEncode.d.ts → transform.d.ts} +8 -5
  10. package/dist/{defineProperty-12b5bd29.esm.js → defineProperty-034d0378.browser.esm.js} +1 -1
  11. package/dist/{defineProperty-a4bf59bc.worker.esm.js → defineProperty-18559492.worker.esm.js} +1 -1
  12. package/dist/{defineProperty-f319cb47.browser.esm.js → defineProperty-b209a901.esm.js} +1 -1
  13. package/dist/{slicedToArray-d846e1d2.esm.js → slicedToArray-0cbb3d34.browser.esm.js} +13 -10
  14. package/dist/{slicedToArray-9e7d1407.worker.esm.js → slicedToArray-5a51fd33.worker.esm.js} +13 -10
  15. package/dist/{slicedToArray-b7cf26e0.cjs.dev.js → slicedToArray-5bddfa58.cjs.prod.js} +14 -11
  16. package/dist/slicedToArray-7b1713a7.cjs.dev.js +59 -0
  17. package/dist/{slicedToArray-1a246338.browser.esm.js → slicedToArray-b4fb91fa.esm.js} +13 -10
  18. package/dist/typeof-16c77f45.cjs.prod.js +13 -0
  19. package/dist/typeof-1de657a3.cjs.dev.js +13 -0
  20. package/dist/typeof-52fabea9.browser.esm.js +11 -0
  21. package/dist/typeof-5c86a240.esm.js +11 -0
  22. package/dist/typeof-8854ace1.worker.esm.js +11 -0
  23. package/dist/valbuild-react.browser.esm.js +618 -24
  24. package/dist/valbuild-react.cjs.dev.js +621 -28
  25. package/dist/valbuild-react.cjs.prod.js +621 -28
  26. package/dist/valbuild-react.esm.js +618 -24
  27. package/dist/valbuild-react.worker.esm.js +616 -24
  28. package/jsx-dev-runtime/dist/valbuild-react-jsx-dev-runtime.browser.esm.js +2 -2
  29. package/jsx-dev-runtime/dist/valbuild-react-jsx-dev-runtime.cjs.dev.js +3 -3
  30. package/jsx-dev-runtime/dist/valbuild-react-jsx-dev-runtime.cjs.prod.js +3 -3
  31. package/jsx-dev-runtime/dist/valbuild-react-jsx-dev-runtime.esm.js +2 -2
  32. package/jsx-dev-runtime/dist/valbuild-react-jsx-dev-runtime.worker.esm.js +2 -2
  33. package/jsx-runtime/dist/valbuild-react-jsx-runtime.browser.esm.js +2 -2
  34. package/jsx-runtime/dist/valbuild-react-jsx-runtime.cjs.dev.js +3 -3
  35. package/jsx-runtime/dist/valbuild-react-jsx-runtime.cjs.prod.js +3 -3
  36. package/jsx-runtime/dist/valbuild-react-jsx-runtime.esm.js +2 -2
  37. package/jsx-runtime/dist/valbuild-react-jsx-runtime.worker.esm.js +2 -2
  38. package/package.json +3 -3
  39. package/src/ValProvider.tsx +2 -3
  40. package/src/ValStore.ts +90 -40
  41. package/src/ValUI.tsx +49 -338
  42. package/src/index.ts +1 -2
  43. package/src/stega/autoTagJSX.ts +1 -1
  44. package/src/stega/index.ts +6 -3
  45. package/src/stega/transform.test.ts +145 -0
  46. package/src/stega/transform.ts +220 -0
  47. package/stega/dist/valbuild-react-stega.browser.esm.js +131 -46
  48. package/stega/dist/valbuild-react-stega.cjs.dev.js +134 -49
  49. package/stega/dist/valbuild-react-stega.cjs.prod.js +134 -49
  50. package/stega/dist/valbuild-react-stega.esm.js +131 -46
  51. package/stega/dist/valbuild-react-stega.worker.esm.js +109 -45
  52. package/dist/ValProvider-2eb6c2f2.esm.js +0 -701
  53. package/dist/ValProvider-74eef393.cjs.js +0 -7
  54. package/dist/ValProvider-74eef393.cjs.prod.js +0 -715
  55. package/dist/ValProvider-c677e164.browser.esm.js +0 -701
  56. package/dist/ValProvider-cb5a2161.worker.esm.js +0 -696
  57. package/dist/ValProvider-f647e355.cjs.dev.js +0 -715
  58. package/dist/ValUI-0c2671a7.cjs.prod.js +0 -382
  59. package/dist/ValUI-334ef1d0.cjs.dev.js +0 -382
  60. package/dist/ValUI-bb1d1ed6.browser.esm.js +0 -380
  61. package/dist/ValUI-bf82178a.esm.js +0 -380
  62. package/dist/declarations/src/ValApi.d.ts +0 -12
  63. package/dist/declarations/src/hooks/useVal.d.ts +0 -3
  64. package/dist/declarations/src/stega/fetchVal.d.ts +0 -3
  65. package/dist/declarations/src/stega/hooks/useVal.d.ts +0 -3
  66. package/dist/objectSpread2-30cc2856.browser.esm.js +0 -25
  67. package/dist/objectSpread2-61fbd9a9.cjs.dev.js +0 -27
  68. package/dist/objectSpread2-7b752a35.cjs.prod.js +0 -27
  69. package/dist/objectSpread2-d5a1fe1c.esm.js +0 -25
  70. package/dist/slicedToArray-0eb0bcdb.cjs.prod.js +0 -56
  71. package/dist/unsupportedIterableToArray-51bb61c2.esm.js +0 -16
  72. package/dist/unsupportedIterableToArray-738344ef.worker.esm.js +0 -16
  73. package/dist/unsupportedIterableToArray-9e97e24a.cjs.dev.js +0 -18
  74. package/dist/unsupportedIterableToArray-afbea1dd.cjs.prod.js +0 -18
  75. package/dist/unsupportedIterableToArray-d3087ed5.browser.esm.js +0 -16
  76. package/src/AuthStatus.tsx +0 -13
  77. package/src/ValApi.ts +0 -65
  78. package/src/hooks/useVal.test.tsx +0 -57
  79. package/src/hooks/useVal.ts +0 -35
  80. package/src/stega/fetchVal.ts +0 -16
  81. package/src/stega/hooks/useVal.ts +0 -14
  82. package/src/stega/stegaEncode.ts +0 -84
@@ -0,0 +1,104 @@
1
+ 'use strict';
2
+
3
+ var slicedToArray = require('./slicedToArray-5bddfa58.cjs.prod.js');
4
+ var core = require('@valbuild/core');
5
+ var ui = require('@valbuild/ui');
6
+ var React = require('react');
7
+ var reactDom = require('react-dom');
8
+ var ReactJSXRuntime = require('react/jsx-runtime');
9
+ var dist_valbuildReact = require('./valbuild-react.cjs.prod.js');
10
+ require('./defineProperty-36ed93cd.cjs.prod.js');
11
+ require('@valbuild/core/fp');
12
+ require('style-to-object');
13
+
14
+ function ShadowContent(_ref) {
15
+ var root = _ref.root,
16
+ children = _ref.children;
17
+ return /*#__PURE__*/reactDom.createPortal(children, root);
18
+ }
19
+ var ShadowRoot = function ShadowRoot(_ref2) {
20
+ var children = _ref2.children;
21
+ var node = React.useRef(null);
22
+ var _useState = React.useState(null),
23
+ _useState2 = slicedToArray._slicedToArray(_useState, 2),
24
+ root = _useState2[0],
25
+ setRoot = _useState2[1];
26
+ React.useLayoutEffect(function () {
27
+ if (node.current) {
28
+ if (node.current.shadowRoot) {
29
+ setRoot(node.current.shadowRoot);
30
+ } else {
31
+ var _root = node.current.attachShadow({
32
+ mode: "open"
33
+ });
34
+ setRoot(_root);
35
+ }
36
+ }
37
+ }, []);
38
+ return /*#__PURE__*/ReactJSXRuntime.jsx("div", {
39
+ ref: node,
40
+ children: root && /*#__PURE__*/ReactJSXRuntime.jsx(ShadowContent, {
41
+ root: root,
42
+ children: children
43
+ })
44
+ });
45
+ };
46
+
47
+ function ValUI() {
48
+ var _useState = React.useState(false),
49
+ _useState2 = slicedToArray._slicedToArray(_useState, 2),
50
+ isClient = _useState2[0],
51
+ setIsClient = _useState2[1];
52
+ var _useState3 = React.useState(false),
53
+ _useState4 = slicedToArray._slicedToArray(_useState3, 2),
54
+ enabled = _useState4[0],
55
+ setEnabled = _useState4[1];
56
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
57
+ var _useState5 = React.useState(false),
58
+ _useState6 = slicedToArray._slicedToArray(_useState5, 2);
59
+ _useState6[0];
60
+ var setDraftMode = _useState6[1]; // TODO: if enabled, but not in draft mode: show something
61
+ var api = dist_valbuildReact.useValApi();
62
+ React.useEffect(function () {
63
+ setIsClient(true);
64
+ try {
65
+ var _document$cookie;
66
+ var valEnabled = (_document$cookie = document.cookie) === null || _document$cookie === void 0 ? void 0 : _document$cookie.includes("".concat(core.Internal.VAL_ENABLE_COOKIE_NAME, "=true"));
67
+ setEnabled(valEnabled);
68
+ } catch (e) {
69
+ console.warn("Could not read Val enabled state", e);
70
+ }
71
+ try {
72
+ var _document$cookie2;
73
+ var valDraftMode = (_document$cookie2 = document.cookie) === null || _document$cookie2 === void 0 ? void 0 : _document$cookie2.includes("".concat(core.Internal.VAL_DRAFT_MODE_COOKIE, "=true"));
74
+ setDraftMode(valDraftMode);
75
+ } catch (e) {
76
+ console.warn("Could not read Val draft mode", e);
77
+ }
78
+ }, []);
79
+ if (isClient && !enabled && "production" === "development") {
80
+ console.log("Val is disabled. Enable it by going here ".concat(window.origin).concat(api.host, "/enable?redirect_to=").concat(encodeURIComponent(window.location.href), ". NOTE: this message appears because NODE_ENV is set to development."));
81
+ }
82
+ if (!isClient || !enabled) {
83
+ return null;
84
+ }
85
+ return /*#__PURE__*/ReactJSXRuntime.jsx(ReactJSXRuntime.Fragment, {
86
+ children: /*#__PURE__*/ReactJSXRuntime.jsxs(ShadowRoot, {
87
+ children: [/*#__PURE__*/ReactJSXRuntime.jsx("link", {
88
+ rel: "preconnect",
89
+ href: "https://fonts.googleapis.com"
90
+ }), /*#__PURE__*/ReactJSXRuntime.jsx("link", {
91
+ rel: "preconnect",
92
+ href: "https://fonts.gstatic.com",
93
+ crossOrigin: "anonymous"
94
+ }), /*#__PURE__*/ReactJSXRuntime.jsx("link", {
95
+ href: "https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;1,400&family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,400;1,700&display=swap",
96
+ rel: "stylesheet"
97
+ }), /*#__PURE__*/ReactJSXRuntime.jsx(ui.Style, {}), /*#__PURE__*/ReactJSXRuntime.jsx(ui.ValOverlay, {
98
+ api: api
99
+ })]
100
+ })
101
+ });
102
+ }
103
+
104
+ exports["default"] = ValUI;
@@ -0,0 +1,102 @@
1
+ import { a as _slicedToArray } from './slicedToArray-0cbb3d34.browser.esm.js';
2
+ import { Internal } from '@valbuild/core';
3
+ import { Style, ValOverlay } from '@valbuild/ui';
4
+ import { useRef, useState, useLayoutEffect, useEffect } from 'react';
5
+ import { createPortal } from 'react-dom';
6
+ import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
7
+ import { useValApi } from './valbuild-react.browser.esm.js';
8
+ import './defineProperty-034d0378.browser.esm.js';
9
+ import '@valbuild/core/fp';
10
+ import 'style-to-object';
11
+
12
+ function ShadowContent(_ref) {
13
+ var root = _ref.root,
14
+ children = _ref.children;
15
+ return /*#__PURE__*/createPortal(children, root);
16
+ }
17
+ var ShadowRoot = function ShadowRoot(_ref2) {
18
+ var children = _ref2.children;
19
+ var node = useRef(null);
20
+ var _useState = useState(null),
21
+ _useState2 = _slicedToArray(_useState, 2),
22
+ root = _useState2[0],
23
+ setRoot = _useState2[1];
24
+ useLayoutEffect(function () {
25
+ if (node.current) {
26
+ if (node.current.shadowRoot) {
27
+ setRoot(node.current.shadowRoot);
28
+ } else {
29
+ var _root = node.current.attachShadow({
30
+ mode: "open"
31
+ });
32
+ setRoot(_root);
33
+ }
34
+ }
35
+ }, []);
36
+ return /*#__PURE__*/jsx("div", {
37
+ ref: node,
38
+ children: root && /*#__PURE__*/jsx(ShadowContent, {
39
+ root: root,
40
+ children: children
41
+ })
42
+ });
43
+ };
44
+
45
+ function ValUI() {
46
+ var _useState = useState(false),
47
+ _useState2 = _slicedToArray(_useState, 2),
48
+ isClient = _useState2[0],
49
+ setIsClient = _useState2[1];
50
+ var _useState3 = useState(false),
51
+ _useState4 = _slicedToArray(_useState3, 2),
52
+ enabled = _useState4[0],
53
+ setEnabled = _useState4[1];
54
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
55
+ var _useState5 = useState(false),
56
+ _useState6 = _slicedToArray(_useState5, 2);
57
+ _useState6[0];
58
+ var setDraftMode = _useState6[1]; // TODO: if enabled, but not in draft mode: show something
59
+ var api = useValApi();
60
+ useEffect(function () {
61
+ setIsClient(true);
62
+ try {
63
+ var _document$cookie;
64
+ var valEnabled = (_document$cookie = document.cookie) === null || _document$cookie === void 0 ? void 0 : _document$cookie.includes("".concat(Internal.VAL_ENABLE_COOKIE_NAME, "=true"));
65
+ setEnabled(valEnabled);
66
+ } catch (e) {
67
+ console.warn("Could not read Val enabled state", e);
68
+ }
69
+ try {
70
+ var _document$cookie2;
71
+ var valDraftMode = (_document$cookie2 = document.cookie) === null || _document$cookie2 === void 0 ? void 0 : _document$cookie2.includes("".concat(Internal.VAL_DRAFT_MODE_COOKIE, "=true"));
72
+ setDraftMode(valDraftMode);
73
+ } catch (e) {
74
+ console.warn("Could not read Val draft mode", e);
75
+ }
76
+ }, []);
77
+ if (isClient && !enabled && process.env.NODE_ENV === "development") {
78
+ console.log("Val is disabled. Enable it by going here ".concat(window.origin).concat(api.host, "/enable?redirect_to=").concat(encodeURIComponent(window.location.href), ". NOTE: this message appears because NODE_ENV is set to development."));
79
+ }
80
+ if (!isClient || !enabled) {
81
+ return null;
82
+ }
83
+ return /*#__PURE__*/jsx(Fragment, {
84
+ children: /*#__PURE__*/jsxs(ShadowRoot, {
85
+ children: [/*#__PURE__*/jsx("link", {
86
+ rel: "preconnect",
87
+ href: "https://fonts.googleapis.com"
88
+ }), /*#__PURE__*/jsx("link", {
89
+ rel: "preconnect",
90
+ href: "https://fonts.gstatic.com",
91
+ crossOrigin: "anonymous"
92
+ }), /*#__PURE__*/jsx("link", {
93
+ href: "https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;1,400&family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,400;1,700&display=swap",
94
+ rel: "stylesheet"
95
+ }), /*#__PURE__*/jsx(Style, {}), /*#__PURE__*/jsx(ValOverlay, {
96
+ api: api
97
+ })]
98
+ })
99
+ });
100
+ }
101
+
102
+ export { ValUI as default };
@@ -0,0 +1,104 @@
1
+ 'use strict';
2
+
3
+ var slicedToArray = require('./slicedToArray-7b1713a7.cjs.dev.js');
4
+ var core = require('@valbuild/core');
5
+ var ui = require('@valbuild/ui');
6
+ var React = require('react');
7
+ var reactDom = require('react-dom');
8
+ var ReactJSXRuntime = require('react/jsx-runtime');
9
+ var dist_valbuildReact = require('./valbuild-react.cjs.dev.js');
10
+ require('./defineProperty-c82a49b0.cjs.dev.js');
11
+ require('@valbuild/core/fp');
12
+ require('style-to-object');
13
+
14
+ function ShadowContent(_ref) {
15
+ var root = _ref.root,
16
+ children = _ref.children;
17
+ return /*#__PURE__*/reactDom.createPortal(children, root);
18
+ }
19
+ var ShadowRoot = function ShadowRoot(_ref2) {
20
+ var children = _ref2.children;
21
+ var node = React.useRef(null);
22
+ var _useState = React.useState(null),
23
+ _useState2 = slicedToArray._slicedToArray(_useState, 2),
24
+ root = _useState2[0],
25
+ setRoot = _useState2[1];
26
+ React.useLayoutEffect(function () {
27
+ if (node.current) {
28
+ if (node.current.shadowRoot) {
29
+ setRoot(node.current.shadowRoot);
30
+ } else {
31
+ var _root = node.current.attachShadow({
32
+ mode: "open"
33
+ });
34
+ setRoot(_root);
35
+ }
36
+ }
37
+ }, []);
38
+ return /*#__PURE__*/ReactJSXRuntime.jsx("div", {
39
+ ref: node,
40
+ children: root && /*#__PURE__*/ReactJSXRuntime.jsx(ShadowContent, {
41
+ root: root,
42
+ children: children
43
+ })
44
+ });
45
+ };
46
+
47
+ function ValUI() {
48
+ var _useState = React.useState(false),
49
+ _useState2 = slicedToArray._slicedToArray(_useState, 2),
50
+ isClient = _useState2[0],
51
+ setIsClient = _useState2[1];
52
+ var _useState3 = React.useState(false),
53
+ _useState4 = slicedToArray._slicedToArray(_useState3, 2),
54
+ enabled = _useState4[0],
55
+ setEnabled = _useState4[1];
56
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
57
+ var _useState5 = React.useState(false),
58
+ _useState6 = slicedToArray._slicedToArray(_useState5, 2);
59
+ _useState6[0];
60
+ var setDraftMode = _useState6[1]; // TODO: if enabled, but not in draft mode: show something
61
+ var api = dist_valbuildReact.useValApi();
62
+ React.useEffect(function () {
63
+ setIsClient(true);
64
+ try {
65
+ var _document$cookie;
66
+ var valEnabled = (_document$cookie = document.cookie) === null || _document$cookie === void 0 ? void 0 : _document$cookie.includes("".concat(core.Internal.VAL_ENABLE_COOKIE_NAME, "=true"));
67
+ setEnabled(valEnabled);
68
+ } catch (e) {
69
+ console.warn("Could not read Val enabled state", e);
70
+ }
71
+ try {
72
+ var _document$cookie2;
73
+ var valDraftMode = (_document$cookie2 = document.cookie) === null || _document$cookie2 === void 0 ? void 0 : _document$cookie2.includes("".concat(core.Internal.VAL_DRAFT_MODE_COOKIE, "=true"));
74
+ setDraftMode(valDraftMode);
75
+ } catch (e) {
76
+ console.warn("Could not read Val draft mode", e);
77
+ }
78
+ }, []);
79
+ if (isClient && !enabled && process.env.NODE_ENV === "development") {
80
+ console.log("Val is disabled. Enable it by going here ".concat(window.origin).concat(api.host, "/enable?redirect_to=").concat(encodeURIComponent(window.location.href), ". NOTE: this message appears because NODE_ENV is set to development."));
81
+ }
82
+ if (!isClient || !enabled) {
83
+ return null;
84
+ }
85
+ return /*#__PURE__*/ReactJSXRuntime.jsx(ReactJSXRuntime.Fragment, {
86
+ children: /*#__PURE__*/ReactJSXRuntime.jsxs(ShadowRoot, {
87
+ children: [/*#__PURE__*/ReactJSXRuntime.jsx("link", {
88
+ rel: "preconnect",
89
+ href: "https://fonts.googleapis.com"
90
+ }), /*#__PURE__*/ReactJSXRuntime.jsx("link", {
91
+ rel: "preconnect",
92
+ href: "https://fonts.gstatic.com",
93
+ crossOrigin: "anonymous"
94
+ }), /*#__PURE__*/ReactJSXRuntime.jsx("link", {
95
+ href: "https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;1,400&family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,400;1,700&display=swap",
96
+ rel: "stylesheet"
97
+ }), /*#__PURE__*/ReactJSXRuntime.jsx(ui.Style, {}), /*#__PURE__*/ReactJSXRuntime.jsx(ui.ValOverlay, {
98
+ api: api
99
+ })]
100
+ })
101
+ });
102
+ }
103
+
104
+ exports["default"] = ValUI;
@@ -0,0 +1,102 @@
1
+ import { a as _slicedToArray } from './slicedToArray-b4fb91fa.esm.js';
2
+ import { Internal } from '@valbuild/core';
3
+ import { Style, ValOverlay } from '@valbuild/ui';
4
+ import { useRef, useState, useLayoutEffect, useEffect } from 'react';
5
+ import { createPortal } from 'react-dom';
6
+ import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
7
+ import { useValApi } from './valbuild-react.esm.js';
8
+ import './defineProperty-b209a901.esm.js';
9
+ import '@valbuild/core/fp';
10
+ import 'style-to-object';
11
+
12
+ function ShadowContent(_ref) {
13
+ var root = _ref.root,
14
+ children = _ref.children;
15
+ return /*#__PURE__*/createPortal(children, root);
16
+ }
17
+ var ShadowRoot = function ShadowRoot(_ref2) {
18
+ var children = _ref2.children;
19
+ var node = useRef(null);
20
+ var _useState = useState(null),
21
+ _useState2 = _slicedToArray(_useState, 2),
22
+ root = _useState2[0],
23
+ setRoot = _useState2[1];
24
+ useLayoutEffect(function () {
25
+ if (node.current) {
26
+ if (node.current.shadowRoot) {
27
+ setRoot(node.current.shadowRoot);
28
+ } else {
29
+ var _root = node.current.attachShadow({
30
+ mode: "open"
31
+ });
32
+ setRoot(_root);
33
+ }
34
+ }
35
+ }, []);
36
+ return /*#__PURE__*/jsx("div", {
37
+ ref: node,
38
+ children: root && /*#__PURE__*/jsx(ShadowContent, {
39
+ root: root,
40
+ children: children
41
+ })
42
+ });
43
+ };
44
+
45
+ function ValUI() {
46
+ var _useState = useState(false),
47
+ _useState2 = _slicedToArray(_useState, 2),
48
+ isClient = _useState2[0],
49
+ setIsClient = _useState2[1];
50
+ var _useState3 = useState(false),
51
+ _useState4 = _slicedToArray(_useState3, 2),
52
+ enabled = _useState4[0],
53
+ setEnabled = _useState4[1];
54
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
55
+ var _useState5 = useState(false),
56
+ _useState6 = _slicedToArray(_useState5, 2);
57
+ _useState6[0];
58
+ var setDraftMode = _useState6[1]; // TODO: if enabled, but not in draft mode: show something
59
+ var api = useValApi();
60
+ useEffect(function () {
61
+ setIsClient(true);
62
+ try {
63
+ var _document$cookie;
64
+ var valEnabled = (_document$cookie = document.cookie) === null || _document$cookie === void 0 ? void 0 : _document$cookie.includes("".concat(Internal.VAL_ENABLE_COOKIE_NAME, "=true"));
65
+ setEnabled(valEnabled);
66
+ } catch (e) {
67
+ console.warn("Could not read Val enabled state", e);
68
+ }
69
+ try {
70
+ var _document$cookie2;
71
+ var valDraftMode = (_document$cookie2 = document.cookie) === null || _document$cookie2 === void 0 ? void 0 : _document$cookie2.includes("".concat(Internal.VAL_DRAFT_MODE_COOKIE, "=true"));
72
+ setDraftMode(valDraftMode);
73
+ } catch (e) {
74
+ console.warn("Could not read Val draft mode", e);
75
+ }
76
+ }, []);
77
+ if (isClient && !enabled && process.env.NODE_ENV === "development") {
78
+ console.log("Val is disabled. Enable it by going here ".concat(window.origin).concat(api.host, "/enable?redirect_to=").concat(encodeURIComponent(window.location.href), ". NOTE: this message appears because NODE_ENV is set to development."));
79
+ }
80
+ if (!isClient || !enabled) {
81
+ return null;
82
+ }
83
+ return /*#__PURE__*/jsx(Fragment, {
84
+ children: /*#__PURE__*/jsxs(ShadowRoot, {
85
+ children: [/*#__PURE__*/jsx("link", {
86
+ rel: "preconnect",
87
+ href: "https://fonts.googleapis.com"
88
+ }), /*#__PURE__*/jsx("link", {
89
+ rel: "preconnect",
90
+ href: "https://fonts.gstatic.com",
91
+ crossOrigin: "anonymous"
92
+ }), /*#__PURE__*/jsx("link", {
93
+ href: "https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;1,400&family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,400;1,700&display=swap",
94
+ rel: "stylesheet"
95
+ }), /*#__PURE__*/jsx(Style, {}), /*#__PURE__*/jsx(ValOverlay, {
96
+ api: api
97
+ })]
98
+ })
99
+ });
100
+ }
101
+
102
+ export { ValUI as default };
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
- import { ValApi } from "./ValApi.js";
3
2
  import { ValStore } from "./ValStore.js";
3
+ import { ValApi } from "@valbuild/core";
4
4
  export declare function useValStore(): ValStore;
5
5
  export declare function useValApi(): ValApi;
6
6
  export type ValContext = {
@@ -1,15 +1,14 @@
1
- import { ValModule, SelectorSource } from "@valbuild/core";
2
- import { ValApi } from "./ValApi.js";
1
+ import { Json, ModuleId, ValApi } from "@valbuild/core";
3
2
  export declare class ValStore {
4
3
  private readonly api;
5
- private readonly vals;
4
+ private readonly subscribers;
6
5
  private readonly listeners;
7
6
  constructor(api: ValApi);
7
+ update(moduleIds: ModuleId[]): Promise<void>;
8
8
  updateAll(): Promise<void>;
9
- subscribe: (moduleId: string) => (listener: () => void) => () => void;
10
- set(moduleId: string, val: ValModule<SelectorSource>): void;
11
- get(moduleId: string): ValModule<SelectorSource> | undefined;
12
- emitChange(moduleId: string): void;
13
- getSnapshot: (moduleId: string) => () => ValModule<SelectorSource> | undefined;
14
- getServerSnapshot: (moduleId: string) => () => ValModule<SelectorSource> | undefined;
9
+ subscribe: (moduleIds: ModuleId[]) => (listener: () => void) => () => void;
10
+ private emitChange;
11
+ getSnapshot: (moduleIds: ModuleId[]) => () => Record<ModuleId, Json> | undefined;
12
+ getServerSnapshot: (moduleIds: ModuleId[]) => () => Record<ModuleId, Json> | undefined;
13
+ get: (moduleIds: ModuleId[]) => Record<ModuleId, Json> | undefined;
15
14
  }
@@ -1,3 +1,2 @@
1
- export { ValProvider } from "./ValProvider.js";
2
- export { useVal } from "./hooks/useVal.js";
1
+ export { ValProvider, useValStore, useValApi } from "./ValProvider.js";
3
2
  export { ValRichText } from "./ValRichText.js";
@@ -1,4 +1,2 @@
1
1
  export { autoTagJSX } from "./autoTagJSX.js";
2
- export { fetchVal } from "./fetchVal.js";
3
- export { useVal } from "./hooks/useVal.js";
4
- export type { ValEncodedString } from "./stegaEncode.js";
2
+ export { transform, getModuleIds, type ValEncodedString, type StegaOfSource, } from "./transform.js";
@@ -1,8 +1,7 @@
1
- import { Json, Val, RichTextSource, RichText } from "@valbuild/core";
2
- import { FileSource, RemoteSource, Source, SourceObject } from "@valbuild/core";
1
+ import { Json, RichTextSource, RichText } from "@valbuild/core";
2
+ import { FileSource, Source, SourceObject } from "@valbuild/core";
3
3
  import { JsonPrimitive } from "@valbuild/core";
4
4
  import { SourceArray } from "@valbuild/core";
5
- import { I18nSource } from "@valbuild/core";
6
5
  declare const brand: unique symbol;
7
6
  /**
8
7
  * ValEncodedString is a string that is encoded using steganography.
@@ -15,10 +14,14 @@ declare const brand: unique symbol;
15
14
  export type ValEncodedString = string & {
16
15
  [brand]: "ValEncodedString";
17
16
  };
18
- export type StegaOfSource<T extends Source> = Json extends T ? Json : T extends I18nSource<readonly string[], infer U> ? StegaOfSource<U> : T extends RemoteSource<infer U> ? StegaOfSource<U> : T extends RichTextSource ? RichText : T extends FileSource ? {
17
+ export type StegaOfSource<T extends Source> = Json extends T ? Json : T extends RichTextSource ? RichText : T extends FileSource ? {
19
18
  url: ValEncodedString;
20
19
  } : T extends SourceObject ? {
21
20
  [key in keyof T]: StegaOfSource<T[key]>;
22
21
  } : T extends SourceArray ? StegaOfSource<T[number]>[] : T extends string ? ValEncodedString : T extends JsonPrimitive ? T : never;
23
- export declare function stegaEncodeVal<T extends Json>(val: Val<T>): T;
22
+ export declare function transform(input: any, opts: {
23
+ getModule?: (moduleId: string) => any;
24
+ disabled?: boolean;
25
+ }): any;
26
+ export declare function getModuleIds(input: any): string[];
24
27
  export {};
@@ -29,4 +29,4 @@ function _defineProperty(obj, key, value) {
29
29
  return obj;
30
30
  }
31
31
 
32
- export { _defineProperty as _, _toPropertyKey as a };
32
+ export { _toPropertyKey as _, _defineProperty as a };
@@ -29,4 +29,4 @@ function _defineProperty(obj, key, value) {
29
29
  return obj;
30
30
  }
31
31
 
32
- export { _defineProperty as _, _toPropertyKey as a };
32
+ export { _toPropertyKey as _, _defineProperty as a };
@@ -29,4 +29,4 @@ function _defineProperty(obj, key, value) {
29
29
  return obj;
30
30
  }
31
31
 
32
- export { _defineProperty as _, _toPropertyKey as a };
32
+ export { _toPropertyKey as _, _defineProperty as a };
@@ -1,13 +1,16 @@
1
- import { _ as _unsupportedIterableToArray } from './unsupportedIterableToArray-51bb61c2.esm.js';
2
-
3
- function _typeof(obj) {
4
- "@babel/helpers - typeof";
1
+ function _arrayLikeToArray(arr, len) {
2
+ if (len == null || len > arr.length) len = arr.length;
3
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
4
+ return arr2;
5
+ }
5
6
 
6
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
7
- return typeof obj;
8
- } : function (obj) {
9
- return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
10
- }, _typeof(obj);
7
+ function _unsupportedIterableToArray(o, minLen) {
8
+ if (!o) return;
9
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
10
+ var n = Object.prototype.toString.call(o).slice(8, -1);
11
+ if (n === "Object" && o.constructor) n = o.constructor.name;
12
+ if (n === "Map" || n === "Set") return Array.from(o);
13
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
11
14
  }
12
15
 
13
16
  function _arrayWithHoles(arr) {
@@ -50,4 +53,4 @@ function _slicedToArray(arr, i) {
50
53
  return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
51
54
  }
52
55
 
53
- export { _slicedToArray as _, _typeof as a };
56
+ export { _unsupportedIterableToArray as _, _slicedToArray as a };
@@ -1,13 +1,16 @@
1
- import { _ as _unsupportedIterableToArray } from './unsupportedIterableToArray-738344ef.worker.esm.js';
2
-
3
- function _typeof(obj) {
4
- "@babel/helpers - typeof";
1
+ function _arrayLikeToArray(arr, len) {
2
+ if (len == null || len > arr.length) len = arr.length;
3
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
4
+ return arr2;
5
+ }
5
6
 
6
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
7
- return typeof obj;
8
- } : function (obj) {
9
- return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
10
- }, _typeof(obj);
7
+ function _unsupportedIterableToArray(o, minLen) {
8
+ if (!o) return;
9
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
10
+ var n = Object.prototype.toString.call(o).slice(8, -1);
11
+ if (n === "Object" && o.constructor) n = o.constructor.name;
12
+ if (n === "Map" || n === "Set") return Array.from(o);
13
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
11
14
  }
12
15
 
13
16
  function _arrayWithHoles(arr) {
@@ -50,4 +53,4 @@ function _slicedToArray(arr, i) {
50
53
  return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
51
54
  }
52
55
 
53
- export { _slicedToArray as _, _typeof as a };
56
+ export { _unsupportedIterableToArray as _, _slicedToArray as a };
@@ -1,15 +1,18 @@
1
1
  'use strict';
2
2
 
3
- var unsupportedIterableToArray = require('./unsupportedIterableToArray-9e97e24a.cjs.dev.js');
4
-
5
- function _typeof(obj) {
6
- "@babel/helpers - typeof";
3
+ function _arrayLikeToArray(arr, len) {
4
+ if (len == null || len > arr.length) len = arr.length;
5
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
6
+ return arr2;
7
+ }
7
8
 
8
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
9
- return typeof obj;
10
- } : function (obj) {
11
- return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
12
- }, _typeof(obj);
9
+ function _unsupportedIterableToArray(o, minLen) {
10
+ if (!o) return;
11
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
12
+ var n = Object.prototype.toString.call(o).slice(8, -1);
13
+ if (n === "Object" && o.constructor) n = o.constructor.name;
14
+ if (n === "Map" || n === "Set") return Array.from(o);
15
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
13
16
  }
14
17
 
15
18
  function _arrayWithHoles(arr) {
@@ -49,8 +52,8 @@ function _nonIterableRest() {
49
52
  }
50
53
 
51
54
  function _slicedToArray(arr, i) {
52
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || unsupportedIterableToArray._unsupportedIterableToArray(arr, i) || _nonIterableRest();
55
+ return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
53
56
  }
54
57
 
55
58
  exports._slicedToArray = _slicedToArray;
56
- exports._typeof = _typeof;
59
+ exports._unsupportedIterableToArray = _unsupportedIterableToArray;