@valbuild/react 0.57.0 → 0.59.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ValProvider-09e313e2.worker.esm.js +87 -0
- package/dist/ValProvider-461fa48b.cjs.js +7 -0
- package/dist/ValProvider-461fa48b.cjs.prod.js +115 -0
- package/dist/ValProvider-a3b1e699.esm.js +92 -0
- package/dist/ValProvider-b34afe68.browser.esm.js +92 -0
- package/dist/ValProvider-d17e4d13.cjs.dev.js +121 -0
- package/dist/{ValUI-891df000.cjs.dev.js → ValUI-1922d8db.cjs.dev.js} +3 -2
- package/dist/ValUI-23e2422b.cjs.js +7 -0
- package/dist/{ValUI-323cc3ff.cjs.prod.js → ValUI-23e2422b.cjs.prod.js} +3 -2
- package/dist/{ValUI-b82ca977.browser.esm.js → ValUI-7d39a3f6.browser.esm.js} +3 -2
- package/dist/{ValUI-29f95099.worker.esm.js → ValUI-84a9cc93.worker.esm.js} +3 -2
- package/dist/{ValUI-04c66635.esm.js → ValUI-8775ef5c.esm.js} +3 -2
- package/dist/declarations/src/internal/ValProvider.d.ts +1 -1
- package/dist/declarations/src/internal/ValRichText.d.ts +67 -14
- package/dist/{slicedToArray-a2a426c7.cjs.prod.js → slicedToArray-11a666de.cjs.dev.js} +3 -17
- package/dist/{slicedToArray-d4c4a4ed.worker.esm.js → slicedToArray-1dc7d2d6.esm.js} +3 -16
- package/dist/{slicedToArray-331bebbb.esm.js → slicedToArray-7b69258f.browser.esm.js} +3 -16
- package/dist/{slicedToArray-a9d0d9cd.cjs.dev.js → slicedToArray-c405fbf0.cjs.prod.js} +3 -17
- package/dist/{slicedToArray-85f6bb43.browser.esm.js → slicedToArray-e7da2c5e.worker.esm.js} +3 -16
- package/dist/toConsumableArray-0a75a603.worker.esm.js +19 -0
- package/dist/toConsumableArray-0ccd58b7.esm.js +19 -0
- package/dist/toConsumableArray-5a71fbb3.browser.esm.js +19 -0
- package/dist/toConsumableArray-b2d28ffa.cjs.dev.js +21 -0
- package/dist/toConsumableArray-b5e3b83f.cjs.prod.js +21 -0
- package/dist/unsupportedIterableToArray-42309462.cjs.prod.js +19 -0
- package/dist/unsupportedIterableToArray-50359a05.worker.esm.js +16 -0
- package/dist/unsupportedIterableToArray-7c30dadf.esm.js +16 -0
- package/dist/unsupportedIterableToArray-ac28611a.cjs.dev.js +19 -0
- package/dist/unsupportedIterableToArray-cce3cb41.browser.esm.js +16 -0
- package/internal/dist/valbuild-react-internal.browser.esm.js +95 -131
- package/internal/dist/valbuild-react-internal.cjs.dev.js +95 -131
- package/internal/dist/valbuild-react-internal.cjs.prod.js +95 -131
- package/internal/dist/valbuild-react-internal.esm.js +95 -131
- package/internal/dist/valbuild-react-internal.worker.esm.js +95 -131
- package/jsx-dev-runtime/dist/valbuild-react-jsx-dev-runtime.browser.esm.js +2 -1
- package/jsx-dev-runtime/dist/valbuild-react-jsx-dev-runtime.cjs.dev.js +2 -1
- package/jsx-dev-runtime/dist/valbuild-react-jsx-dev-runtime.cjs.prod.js +2 -1
- package/jsx-dev-runtime/dist/valbuild-react-jsx-dev-runtime.esm.js +2 -1
- package/jsx-dev-runtime/dist/valbuild-react-jsx-dev-runtime.worker.esm.js +2 -1
- package/jsx-runtime/dist/valbuild-react-jsx-runtime.browser.esm.js +2 -1
- package/jsx-runtime/dist/valbuild-react-jsx-runtime.cjs.dev.js +2 -1
- package/jsx-runtime/dist/valbuild-react-jsx-runtime.cjs.prod.js +2 -1
- package/jsx-runtime/dist/valbuild-react-jsx-runtime.esm.js +2 -1
- package/jsx-runtime/dist/valbuild-react-jsx-runtime.worker.esm.js +2 -1
- package/package.json +4 -4
- package/stega/dist/valbuild-react-stega.browser.esm.js +54 -7
- package/stega/dist/valbuild-react-stega.cjs.dev.js +55 -8
- package/stega/dist/valbuild-react-stega.cjs.prod.js +55 -8
- package/stega/dist/valbuild-react-stega.esm.js +54 -7
- package/stega/dist/valbuild-react-stega.worker.esm.js +54 -7
- package/dist/ValProvider-1009cb51.cjs.dev.js +0 -717
- package/dist/ValProvider-6a12fd8e.browser.esm.js +0 -688
- package/dist/ValProvider-8ec03a73.esm.js +0 -688
- package/dist/ValProvider-c7d7067b.cjs.js +0 -7
- package/dist/ValProvider-c7d7067b.cjs.prod.js +0 -711
- package/dist/ValProvider-ecf57703.worker.esm.js +0 -683
- package/dist/ValUI-323cc3ff.cjs.js +0 -7
- package/dist/declarations/src/internal/ValStore.d.ts +0 -16
- package/dist/defineProperty-6ed7deb7.browser.esm.js +0 -32
- package/dist/defineProperty-82fbeafc.worker.esm.js +0 -32
- package/dist/defineProperty-9bf3d0c0.esm.js +0 -32
- package/dist/defineProperty-c84f9aba.cjs.dev.js +0 -35
- package/dist/defineProperty-f8fe5660.cjs.prod.js +0 -35
@@ -0,0 +1,87 @@
|
|
1
|
+
'use client';
|
2
|
+
import { _ as _slicedToArray } from './slicedToArray-e7da2c5e.worker.esm.js';
|
3
|
+
import { useMemo, useState, useEffect, lazy } from 'react';
|
4
|
+
import { ValApi, Internal } from '@valbuild/core';
|
5
|
+
import { ValStore } from '@valbuild/shared/internal';
|
6
|
+
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
7
|
+
import './unsupportedIterableToArray-50359a05.worker.esm.js';
|
8
|
+
|
9
|
+
var useValStore = function useValStore() {
|
10
|
+
{
|
11
|
+
return undefined;
|
12
|
+
}
|
13
|
+
};
|
14
|
+
var useValApi = function useValApi() {
|
15
|
+
{
|
16
|
+
return undefined;
|
17
|
+
}
|
18
|
+
};
|
19
|
+
var ValContext = undefined;
|
20
|
+
var ValUI = /*#__PURE__*/lazy(function () {
|
21
|
+
return import('./ValUI-84a9cc93.worker.esm.js');
|
22
|
+
});
|
23
|
+
function ValProvider(_ref) {
|
24
|
+
var children = _ref.children,
|
25
|
+
onSubmit = _ref.onSubmit;
|
26
|
+
var host = "/api/val";
|
27
|
+
var api = useMemo(function () {
|
28
|
+
return new ValApi(host);
|
29
|
+
}, [host]);
|
30
|
+
var store = useMemo(function () {
|
31
|
+
return new ValStore(api);
|
32
|
+
}, [api]);
|
33
|
+
var _useState = useState(false),
|
34
|
+
_useState2 = _slicedToArray(_useState, 2),
|
35
|
+
isClient = _useState2[0],
|
36
|
+
setIsClient = _useState2[1];
|
37
|
+
var _useState3 = useState(),
|
38
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
39
|
+
enabled = _useState4[0],
|
40
|
+
setEnabled = _useState4[1];
|
41
|
+
useEffect(function () {
|
42
|
+
setIsClient(true);
|
43
|
+
try {
|
44
|
+
var _document$cookie, _document$cookie2;
|
45
|
+
var valEnabled = (_document$cookie = document.cookie) === null || _document$cookie === void 0 ? void 0 : _document$cookie.includes("".concat(Internal.VAL_ENABLE_COOKIE_NAME, "=true"));
|
46
|
+
if (valEnabled) {
|
47
|
+
setEnabled(true);
|
48
|
+
}
|
49
|
+
var valDisabled = (_document$cookie2 = document.cookie) === null || _document$cookie2 === void 0 ? void 0 : _document$cookie2.includes("".concat(Internal.VAL_ENABLE_COOKIE_NAME, "=false"));
|
50
|
+
if (valDisabled) {
|
51
|
+
setEnabled(false);
|
52
|
+
}
|
53
|
+
// If we are in development and Val is not enabled or disabled, enable Val
|
54
|
+
if (process.env.NODE_ENV === "development" && !valEnabled && !valDisabled) {
|
55
|
+
window.location.href = "".concat(window.origin).concat(host, "/enable?redirect_to=").concat(encodeURIComponent(window.location.href));
|
56
|
+
}
|
57
|
+
} catch (e) {
|
58
|
+
console.warn("Could not read Val enabled state", e);
|
59
|
+
}
|
60
|
+
}, []);
|
61
|
+
if (isClient && !enabled) {
|
62
|
+
if (!api) {
|
63
|
+
console.warn("Val does not seem to be configured properly! Please check that you have wrapper your root layout (or _app) with the ValProvider.");
|
64
|
+
} else {
|
65
|
+
if (process.env.NODE_ENV === "development") {
|
66
|
+
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."));
|
67
|
+
}
|
68
|
+
}
|
69
|
+
}
|
70
|
+
if (!isClient || !enabled || !store || !api || !ValContext) {
|
71
|
+
return /*#__PURE__*/jsx(Fragment, {
|
72
|
+
children: children
|
73
|
+
});
|
74
|
+
}
|
75
|
+
return /*#__PURE__*/jsxs(ValContext.Provider, {
|
76
|
+
value: {
|
77
|
+
valApi: api,
|
78
|
+
valStore: store
|
79
|
+
},
|
80
|
+
children: [children, /*#__PURE__*/jsx(ValUI, {
|
81
|
+
host: host,
|
82
|
+
onSubmit: onSubmit
|
83
|
+
})]
|
84
|
+
});
|
85
|
+
}
|
86
|
+
|
87
|
+
export { ValContext, ValProvider, useValApi, useValStore };
|
@@ -0,0 +1,115 @@
|
|
1
|
+
'use client';
|
2
|
+
'use strict';
|
3
|
+
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
5
|
+
|
6
|
+
var slicedToArray = require('./slicedToArray-c405fbf0.cjs.prod.js');
|
7
|
+
var React = require('react');
|
8
|
+
var core = require('@valbuild/core');
|
9
|
+
var internal = require('@valbuild/shared/internal');
|
10
|
+
var ReactJSXRuntime = require('react/jsx-runtime');
|
11
|
+
require('./unsupportedIterableToArray-42309462.cjs.prod.js');
|
12
|
+
|
13
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
14
|
+
|
15
|
+
function _interopNamespace(e) {
|
16
|
+
if (e && e.__esModule) return e;
|
17
|
+
var n = Object.create(null);
|
18
|
+
if (e) {
|
19
|
+
Object.keys(e).forEach(function (k) {
|
20
|
+
if (k !== 'default') {
|
21
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
22
|
+
Object.defineProperty(n, k, d.get ? d : {
|
23
|
+
enumerable: true,
|
24
|
+
get: function () { return e[k]; }
|
25
|
+
});
|
26
|
+
}
|
27
|
+
});
|
28
|
+
}
|
29
|
+
n["default"] = e;
|
30
|
+
return Object.freeze(n);
|
31
|
+
}
|
32
|
+
|
33
|
+
var React__default = /*#__PURE__*/_interopDefault(React);
|
34
|
+
|
35
|
+
var useValStore = function useValStore() {
|
36
|
+
if (!ValContext) {
|
37
|
+
return undefined;
|
38
|
+
}
|
39
|
+
return React.useContext(ValContext).valStore;
|
40
|
+
};
|
41
|
+
var useValApi = function useValApi() {
|
42
|
+
if (!ValContext) {
|
43
|
+
return undefined;
|
44
|
+
}
|
45
|
+
return React.useContext(ValContext).valApi;
|
46
|
+
};
|
47
|
+
var ValContext = typeof window !== "undefined" ? /*#__PURE__*/React__default["default"].createContext({
|
48
|
+
valStore: undefined,
|
49
|
+
valApi: undefined
|
50
|
+
}) : undefined;
|
51
|
+
var ValUI = /*#__PURE__*/React.lazy(function () {
|
52
|
+
return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('./ValUI-23e2422b.cjs.prod.js')); });
|
53
|
+
});
|
54
|
+
function ValProvider(_ref) {
|
55
|
+
var children = _ref.children,
|
56
|
+
onSubmit = _ref.onSubmit;
|
57
|
+
var host = "/api/val";
|
58
|
+
var api = React.useMemo(function () {
|
59
|
+
return new core.ValApi(host);
|
60
|
+
}, [host]);
|
61
|
+
var store = React.useMemo(function () {
|
62
|
+
return new internal.ValStore(api);
|
63
|
+
}, [api]);
|
64
|
+
var _useState = React.useState(false),
|
65
|
+
_useState2 = slicedToArray._slicedToArray(_useState, 2),
|
66
|
+
isClient = _useState2[0],
|
67
|
+
setIsClient = _useState2[1];
|
68
|
+
var _useState3 = React.useState(),
|
69
|
+
_useState4 = slicedToArray._slicedToArray(_useState3, 2),
|
70
|
+
enabled = _useState4[0],
|
71
|
+
setEnabled = _useState4[1];
|
72
|
+
React.useEffect(function () {
|
73
|
+
setIsClient(true);
|
74
|
+
try {
|
75
|
+
var _document$cookie, _document$cookie2;
|
76
|
+
var valEnabled = (_document$cookie = document.cookie) === null || _document$cookie === void 0 ? void 0 : _document$cookie.includes("".concat(core.Internal.VAL_ENABLE_COOKIE_NAME, "=true"));
|
77
|
+
if (valEnabled) {
|
78
|
+
setEnabled(true);
|
79
|
+
}
|
80
|
+
var valDisabled = (_document$cookie2 = document.cookie) === null || _document$cookie2 === void 0 ? void 0 : _document$cookie2.includes("".concat(core.Internal.VAL_ENABLE_COOKIE_NAME, "=false"));
|
81
|
+
if (valDisabled) {
|
82
|
+
setEnabled(false);
|
83
|
+
}
|
84
|
+
// If we are in development and Val is not enabled or disabled, enable Val
|
85
|
+
if ( "production" === "development" && !valEnabled && !valDisabled) ;
|
86
|
+
} catch (e) {
|
87
|
+
console.warn("Could not read Val enabled state", e);
|
88
|
+
}
|
89
|
+
}, []);
|
90
|
+
if (isClient && !enabled) {
|
91
|
+
if (!api) {
|
92
|
+
console.warn("Val does not seem to be configured properly! Please check that you have wrapper your root layout (or _app) with the ValProvider.");
|
93
|
+
}
|
94
|
+
}
|
95
|
+
if (!isClient || !enabled || !store || !api || !ValContext) {
|
96
|
+
return /*#__PURE__*/ReactJSXRuntime.jsx(ReactJSXRuntime.Fragment, {
|
97
|
+
children: children
|
98
|
+
});
|
99
|
+
}
|
100
|
+
return /*#__PURE__*/ReactJSXRuntime.jsxs(ValContext.Provider, {
|
101
|
+
value: {
|
102
|
+
valApi: api,
|
103
|
+
valStore: store
|
104
|
+
},
|
105
|
+
children: [children, /*#__PURE__*/ReactJSXRuntime.jsx(ValUI, {
|
106
|
+
host: host,
|
107
|
+
onSubmit: onSubmit
|
108
|
+
})]
|
109
|
+
});
|
110
|
+
}
|
111
|
+
|
112
|
+
exports.ValContext = ValContext;
|
113
|
+
exports.ValProvider = ValProvider;
|
114
|
+
exports.useValApi = useValApi;
|
115
|
+
exports.useValStore = useValStore;
|
@@ -0,0 +1,92 @@
|
|
1
|
+
'use client';
|
2
|
+
import { _ as _slicedToArray } from './slicedToArray-1dc7d2d6.esm.js';
|
3
|
+
import React, { useContext, useMemo, useState, useEffect, lazy } from 'react';
|
4
|
+
import { ValApi, Internal } from '@valbuild/core';
|
5
|
+
import { ValStore } from '@valbuild/shared/internal';
|
6
|
+
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
7
|
+
import './unsupportedIterableToArray-7c30dadf.esm.js';
|
8
|
+
|
9
|
+
var useValStore = function useValStore() {
|
10
|
+
if (!ValContext) {
|
11
|
+
return undefined;
|
12
|
+
}
|
13
|
+
return useContext(ValContext).valStore;
|
14
|
+
};
|
15
|
+
var useValApi = function useValApi() {
|
16
|
+
if (!ValContext) {
|
17
|
+
return undefined;
|
18
|
+
}
|
19
|
+
return useContext(ValContext).valApi;
|
20
|
+
};
|
21
|
+
var ValContext = typeof window !== "undefined" ? /*#__PURE__*/React.createContext({
|
22
|
+
valStore: undefined,
|
23
|
+
valApi: undefined
|
24
|
+
}) : undefined;
|
25
|
+
var ValUI = /*#__PURE__*/lazy(function () {
|
26
|
+
return import('./ValUI-8775ef5c.esm.js');
|
27
|
+
});
|
28
|
+
function ValProvider(_ref) {
|
29
|
+
var children = _ref.children,
|
30
|
+
onSubmit = _ref.onSubmit;
|
31
|
+
var host = "/api/val";
|
32
|
+
var api = useMemo(function () {
|
33
|
+
return new ValApi(host);
|
34
|
+
}, [host]);
|
35
|
+
var store = useMemo(function () {
|
36
|
+
return new ValStore(api);
|
37
|
+
}, [api]);
|
38
|
+
var _useState = useState(false),
|
39
|
+
_useState2 = _slicedToArray(_useState, 2),
|
40
|
+
isClient = _useState2[0],
|
41
|
+
setIsClient = _useState2[1];
|
42
|
+
var _useState3 = useState(),
|
43
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
44
|
+
enabled = _useState4[0],
|
45
|
+
setEnabled = _useState4[1];
|
46
|
+
useEffect(function () {
|
47
|
+
setIsClient(true);
|
48
|
+
try {
|
49
|
+
var _document$cookie, _document$cookie2;
|
50
|
+
var valEnabled = (_document$cookie = document.cookie) === null || _document$cookie === void 0 ? void 0 : _document$cookie.includes("".concat(Internal.VAL_ENABLE_COOKIE_NAME, "=true"));
|
51
|
+
if (valEnabled) {
|
52
|
+
setEnabled(true);
|
53
|
+
}
|
54
|
+
var valDisabled = (_document$cookie2 = document.cookie) === null || _document$cookie2 === void 0 ? void 0 : _document$cookie2.includes("".concat(Internal.VAL_ENABLE_COOKIE_NAME, "=false"));
|
55
|
+
if (valDisabled) {
|
56
|
+
setEnabled(false);
|
57
|
+
}
|
58
|
+
// If we are in development and Val is not enabled or disabled, enable Val
|
59
|
+
if (process.env.NODE_ENV === "development" && !valEnabled && !valDisabled) {
|
60
|
+
window.location.href = "".concat(window.origin).concat(host, "/enable?redirect_to=").concat(encodeURIComponent(window.location.href));
|
61
|
+
}
|
62
|
+
} catch (e) {
|
63
|
+
console.warn("Could not read Val enabled state", e);
|
64
|
+
}
|
65
|
+
}, []);
|
66
|
+
if (isClient && !enabled) {
|
67
|
+
if (!api) {
|
68
|
+
console.warn("Val does not seem to be configured properly! Please check that you have wrapper your root layout (or _app) with the ValProvider.");
|
69
|
+
} else {
|
70
|
+
if (process.env.NODE_ENV === "development") {
|
71
|
+
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."));
|
72
|
+
}
|
73
|
+
}
|
74
|
+
}
|
75
|
+
if (!isClient || !enabled || !store || !api || !ValContext) {
|
76
|
+
return /*#__PURE__*/jsx(Fragment, {
|
77
|
+
children: children
|
78
|
+
});
|
79
|
+
}
|
80
|
+
return /*#__PURE__*/jsxs(ValContext.Provider, {
|
81
|
+
value: {
|
82
|
+
valApi: api,
|
83
|
+
valStore: store
|
84
|
+
},
|
85
|
+
children: [children, /*#__PURE__*/jsx(ValUI, {
|
86
|
+
host: host,
|
87
|
+
onSubmit: onSubmit
|
88
|
+
})]
|
89
|
+
});
|
90
|
+
}
|
91
|
+
|
92
|
+
export { ValContext, ValProvider, useValApi, useValStore };
|
@@ -0,0 +1,92 @@
|
|
1
|
+
'use client';
|
2
|
+
import { _ as _slicedToArray } from './slicedToArray-7b69258f.browser.esm.js';
|
3
|
+
import React, { useContext, useMemo, useState, useEffect, lazy } from 'react';
|
4
|
+
import { ValApi, Internal } from '@valbuild/core';
|
5
|
+
import { ValStore } from '@valbuild/shared/internal';
|
6
|
+
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
7
|
+
import './unsupportedIterableToArray-cce3cb41.browser.esm.js';
|
8
|
+
|
9
|
+
var useValStore = function useValStore() {
|
10
|
+
if (!ValContext) {
|
11
|
+
return undefined;
|
12
|
+
}
|
13
|
+
return useContext(ValContext).valStore;
|
14
|
+
};
|
15
|
+
var useValApi = function useValApi() {
|
16
|
+
if (!ValContext) {
|
17
|
+
return undefined;
|
18
|
+
}
|
19
|
+
return useContext(ValContext).valApi;
|
20
|
+
};
|
21
|
+
var ValContext = /*#__PURE__*/React.createContext({
|
22
|
+
valStore: undefined,
|
23
|
+
valApi: undefined
|
24
|
+
}) ;
|
25
|
+
var ValUI = /*#__PURE__*/lazy(function () {
|
26
|
+
return import('./ValUI-7d39a3f6.browser.esm.js');
|
27
|
+
});
|
28
|
+
function ValProvider(_ref) {
|
29
|
+
var children = _ref.children,
|
30
|
+
onSubmit = _ref.onSubmit;
|
31
|
+
var host = "/api/val";
|
32
|
+
var api = useMemo(function () {
|
33
|
+
return new ValApi(host);
|
34
|
+
}, [host]);
|
35
|
+
var store = useMemo(function () {
|
36
|
+
return new ValStore(api);
|
37
|
+
}, [api]);
|
38
|
+
var _useState = useState(false),
|
39
|
+
_useState2 = _slicedToArray(_useState, 2),
|
40
|
+
isClient = _useState2[0],
|
41
|
+
setIsClient = _useState2[1];
|
42
|
+
var _useState3 = useState(),
|
43
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
44
|
+
enabled = _useState4[0],
|
45
|
+
setEnabled = _useState4[1];
|
46
|
+
useEffect(function () {
|
47
|
+
setIsClient(true);
|
48
|
+
try {
|
49
|
+
var _document$cookie, _document$cookie2;
|
50
|
+
var valEnabled = (_document$cookie = document.cookie) === null || _document$cookie === void 0 ? void 0 : _document$cookie.includes("".concat(Internal.VAL_ENABLE_COOKIE_NAME, "=true"));
|
51
|
+
if (valEnabled) {
|
52
|
+
setEnabled(true);
|
53
|
+
}
|
54
|
+
var valDisabled = (_document$cookie2 = document.cookie) === null || _document$cookie2 === void 0 ? void 0 : _document$cookie2.includes("".concat(Internal.VAL_ENABLE_COOKIE_NAME, "=false"));
|
55
|
+
if (valDisabled) {
|
56
|
+
setEnabled(false);
|
57
|
+
}
|
58
|
+
// If we are in development and Val is not enabled or disabled, enable Val
|
59
|
+
if (process.env.NODE_ENV === "development" && !valEnabled && !valDisabled) {
|
60
|
+
window.location.href = "".concat(window.origin).concat(host, "/enable?redirect_to=").concat(encodeURIComponent(window.location.href));
|
61
|
+
}
|
62
|
+
} catch (e) {
|
63
|
+
console.warn("Could not read Val enabled state", e);
|
64
|
+
}
|
65
|
+
}, []);
|
66
|
+
if (isClient && !enabled) {
|
67
|
+
if (!api) {
|
68
|
+
console.warn("Val does not seem to be configured properly! Please check that you have wrapper your root layout (or _app) with the ValProvider.");
|
69
|
+
} else {
|
70
|
+
if (process.env.NODE_ENV === "development") {
|
71
|
+
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."));
|
72
|
+
}
|
73
|
+
}
|
74
|
+
}
|
75
|
+
if (!isClient || !enabled || !store || !api || !ValContext) {
|
76
|
+
return /*#__PURE__*/jsx(Fragment, {
|
77
|
+
children: children
|
78
|
+
});
|
79
|
+
}
|
80
|
+
return /*#__PURE__*/jsxs(ValContext.Provider, {
|
81
|
+
value: {
|
82
|
+
valApi: api,
|
83
|
+
valStore: store
|
84
|
+
},
|
85
|
+
children: [children, /*#__PURE__*/jsx(ValUI, {
|
86
|
+
host: host,
|
87
|
+
onSubmit: onSubmit
|
88
|
+
})]
|
89
|
+
});
|
90
|
+
}
|
91
|
+
|
92
|
+
export { ValContext, ValProvider, useValApi, useValStore };
|
@@ -0,0 +1,121 @@
|
|
1
|
+
'use client';
|
2
|
+
'use strict';
|
3
|
+
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
5
|
+
|
6
|
+
var slicedToArray = require('./slicedToArray-11a666de.cjs.dev.js');
|
7
|
+
var React = require('react');
|
8
|
+
var core = require('@valbuild/core');
|
9
|
+
var internal = require('@valbuild/shared/internal');
|
10
|
+
var ReactJSXRuntime = require('react/jsx-runtime');
|
11
|
+
require('./unsupportedIterableToArray-ac28611a.cjs.dev.js');
|
12
|
+
|
13
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
14
|
+
|
15
|
+
function _interopNamespace(e) {
|
16
|
+
if (e && e.__esModule) return e;
|
17
|
+
var n = Object.create(null);
|
18
|
+
if (e) {
|
19
|
+
Object.keys(e).forEach(function (k) {
|
20
|
+
if (k !== 'default') {
|
21
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
22
|
+
Object.defineProperty(n, k, d.get ? d : {
|
23
|
+
enumerable: true,
|
24
|
+
get: function () { return e[k]; }
|
25
|
+
});
|
26
|
+
}
|
27
|
+
});
|
28
|
+
}
|
29
|
+
n["default"] = e;
|
30
|
+
return Object.freeze(n);
|
31
|
+
}
|
32
|
+
|
33
|
+
var React__default = /*#__PURE__*/_interopDefault(React);
|
34
|
+
|
35
|
+
var useValStore = function useValStore() {
|
36
|
+
if (!ValContext) {
|
37
|
+
return undefined;
|
38
|
+
}
|
39
|
+
return React.useContext(ValContext).valStore;
|
40
|
+
};
|
41
|
+
var useValApi = function useValApi() {
|
42
|
+
if (!ValContext) {
|
43
|
+
return undefined;
|
44
|
+
}
|
45
|
+
return React.useContext(ValContext).valApi;
|
46
|
+
};
|
47
|
+
var ValContext = typeof window !== "undefined" ? /*#__PURE__*/React__default["default"].createContext({
|
48
|
+
valStore: undefined,
|
49
|
+
valApi: undefined
|
50
|
+
}) : undefined;
|
51
|
+
var ValUI = /*#__PURE__*/React.lazy(function () {
|
52
|
+
return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('./ValUI-1922d8db.cjs.dev.js')); });
|
53
|
+
});
|
54
|
+
function ValProvider(_ref) {
|
55
|
+
var children = _ref.children,
|
56
|
+
onSubmit = _ref.onSubmit;
|
57
|
+
var host = "/api/val";
|
58
|
+
var api = React.useMemo(function () {
|
59
|
+
return new core.ValApi(host);
|
60
|
+
}, [host]);
|
61
|
+
var store = React.useMemo(function () {
|
62
|
+
return new internal.ValStore(api);
|
63
|
+
}, [api]);
|
64
|
+
var _useState = React.useState(false),
|
65
|
+
_useState2 = slicedToArray._slicedToArray(_useState, 2),
|
66
|
+
isClient = _useState2[0],
|
67
|
+
setIsClient = _useState2[1];
|
68
|
+
var _useState3 = React.useState(),
|
69
|
+
_useState4 = slicedToArray._slicedToArray(_useState3, 2),
|
70
|
+
enabled = _useState4[0],
|
71
|
+
setEnabled = _useState4[1];
|
72
|
+
React.useEffect(function () {
|
73
|
+
setIsClient(true);
|
74
|
+
try {
|
75
|
+
var _document$cookie, _document$cookie2;
|
76
|
+
var valEnabled = (_document$cookie = document.cookie) === null || _document$cookie === void 0 ? void 0 : _document$cookie.includes("".concat(core.Internal.VAL_ENABLE_COOKIE_NAME, "=true"));
|
77
|
+
if (valEnabled) {
|
78
|
+
setEnabled(true);
|
79
|
+
}
|
80
|
+
var valDisabled = (_document$cookie2 = document.cookie) === null || _document$cookie2 === void 0 ? void 0 : _document$cookie2.includes("".concat(core.Internal.VAL_ENABLE_COOKIE_NAME, "=false"));
|
81
|
+
if (valDisabled) {
|
82
|
+
setEnabled(false);
|
83
|
+
}
|
84
|
+
// If we are in development and Val is not enabled or disabled, enable Val
|
85
|
+
if (process.env.NODE_ENV === "development" && !valEnabled && !valDisabled) {
|
86
|
+
window.location.href = "".concat(window.origin).concat(host, "/enable?redirect_to=").concat(encodeURIComponent(window.location.href));
|
87
|
+
}
|
88
|
+
} catch (e) {
|
89
|
+
console.warn("Could not read Val enabled state", e);
|
90
|
+
}
|
91
|
+
}, []);
|
92
|
+
if (isClient && !enabled) {
|
93
|
+
if (!api) {
|
94
|
+
console.warn("Val does not seem to be configured properly! Please check that you have wrapper your root layout (or _app) with the ValProvider.");
|
95
|
+
} else {
|
96
|
+
if (process.env.NODE_ENV === "development") {
|
97
|
+
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."));
|
98
|
+
}
|
99
|
+
}
|
100
|
+
}
|
101
|
+
if (!isClient || !enabled || !store || !api || !ValContext) {
|
102
|
+
return /*#__PURE__*/ReactJSXRuntime.jsx(ReactJSXRuntime.Fragment, {
|
103
|
+
children: children
|
104
|
+
});
|
105
|
+
}
|
106
|
+
return /*#__PURE__*/ReactJSXRuntime.jsxs(ValContext.Provider, {
|
107
|
+
value: {
|
108
|
+
valApi: api,
|
109
|
+
valStore: store
|
110
|
+
},
|
111
|
+
children: [children, /*#__PURE__*/ReactJSXRuntime.jsx(ValUI, {
|
112
|
+
host: host,
|
113
|
+
onSubmit: onSubmit
|
114
|
+
})]
|
115
|
+
});
|
116
|
+
}
|
117
|
+
|
118
|
+
exports.ValContext = ValContext;
|
119
|
+
exports.ValProvider = ValProvider;
|
120
|
+
exports.useValApi = useValApi;
|
121
|
+
exports.useValStore = useValStore;
|
@@ -4,11 +4,12 @@
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
5
5
|
|
6
6
|
var ui = require('@valbuild/ui');
|
7
|
-
var slicedToArray = require('./slicedToArray-
|
7
|
+
var slicedToArray = require('./slicedToArray-11a666de.cjs.dev.js');
|
8
8
|
var React = require('react');
|
9
9
|
var reactDom = require('react-dom');
|
10
10
|
var ReactJSXRuntime = require('react/jsx-runtime');
|
11
|
-
var ValProvider = require('./ValProvider-
|
11
|
+
var ValProvider = require('./ValProvider-d17e4d13.cjs.dev.js');
|
12
|
+
require('./unsupportedIterableToArray-ac28611a.cjs.dev.js');
|
12
13
|
|
13
14
|
function ShadowContent(_ref) {
|
14
15
|
var root = _ref.root,
|
@@ -4,11 +4,12 @@
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
5
5
|
|
6
6
|
var ui = require('@valbuild/ui');
|
7
|
-
var slicedToArray = require('./slicedToArray-
|
7
|
+
var slicedToArray = require('./slicedToArray-c405fbf0.cjs.prod.js');
|
8
8
|
var React = require('react');
|
9
9
|
var reactDom = require('react-dom');
|
10
10
|
var ReactJSXRuntime = require('react/jsx-runtime');
|
11
|
-
var ValProvider = require('./ValProvider-
|
11
|
+
var ValProvider = require('./ValProvider-461fa48b.cjs.prod.js');
|
12
|
+
require('./unsupportedIterableToArray-42309462.cjs.prod.js');
|
12
13
|
|
13
14
|
function ShadowContent(_ref) {
|
14
15
|
var root = _ref.root,
|
@@ -1,10 +1,11 @@
|
|
1
1
|
'use client';
|
2
2
|
import { VAL_CSS_PATH, ValOverlay } from '@valbuild/ui';
|
3
|
-
import { _ as _slicedToArray } from './slicedToArray-
|
3
|
+
import { _ as _slicedToArray } from './slicedToArray-7b69258f.browser.esm.js';
|
4
4
|
import { useRef, useState, useLayoutEffect } from 'react';
|
5
5
|
import { createPortal } from 'react-dom';
|
6
6
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
7
|
-
import { useValApi, useValStore } from './ValProvider-
|
7
|
+
import { useValApi, useValStore } from './ValProvider-b34afe68.browser.esm.js';
|
8
|
+
import './unsupportedIterableToArray-cce3cb41.browser.esm.js';
|
8
9
|
|
9
10
|
function ShadowContent(_ref) {
|
10
11
|
var root = _ref.root,
|
@@ -1,10 +1,11 @@
|
|
1
1
|
'use client';
|
2
2
|
import { VAL_CSS_PATH, ValOverlay } from '@valbuild/ui';
|
3
|
-
import { _ as _slicedToArray } from './slicedToArray-
|
3
|
+
import { _ as _slicedToArray } from './slicedToArray-e7da2c5e.worker.esm.js';
|
4
4
|
import { useRef, useState, useLayoutEffect } from 'react';
|
5
5
|
import { createPortal } from 'react-dom';
|
6
6
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
7
|
-
import { useValApi, useValStore } from './ValProvider-
|
7
|
+
import { useValApi, useValStore } from './ValProvider-09e313e2.worker.esm.js';
|
8
|
+
import './unsupportedIterableToArray-50359a05.worker.esm.js';
|
8
9
|
|
9
10
|
function ShadowContent(_ref) {
|
10
11
|
var root = _ref.root,
|
@@ -1,10 +1,11 @@
|
|
1
1
|
'use client';
|
2
2
|
import { VAL_CSS_PATH, ValOverlay } from '@valbuild/ui';
|
3
|
-
import { _ as _slicedToArray } from './slicedToArray-
|
3
|
+
import { _ as _slicedToArray } from './slicedToArray-1dc7d2d6.esm.js';
|
4
4
|
import { useRef, useState, useLayoutEffect } from 'react';
|
5
5
|
import { createPortal } from 'react-dom';
|
6
6
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
7
|
-
import { useValApi, useValStore } from './ValProvider-
|
7
|
+
import { useValApi, useValStore } from './ValProvider-a3b1e699.esm.js';
|
8
|
+
import './unsupportedIterableToArray-7c30dadf.esm.js';
|
8
9
|
|
9
10
|
function ShadowContent(_ref) {
|
10
11
|
var root = _ref.root,
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import React from "react";
|
2
|
-
import { ValStore } from "./ValStore.js";
|
3
2
|
import { ValApi } from "@valbuild/core";
|
3
|
+
import { ValStore } from "@valbuild/shared/internal";
|
4
4
|
export declare const useValStore: () => ValStore | undefined;
|
5
5
|
export type UseValStore = typeof useValStore;
|
6
6
|
export declare const useValApi: () => any;
|