@plasmicapp/react-web 0.2.201 → 0.2.202
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/all.d.ts +1926 -1925
- package/dist/auth/PlasmicPageGuard.d.ts +11 -11
- package/dist/common.d.ts +10 -10
- package/dist/data-sources/index.d.ts +1 -1
- package/dist/host/index.d.ts +1 -1
- package/dist/index-common.d.ts +18 -18
- package/dist/index-skinny.d.ts +1 -1
- package/dist/index.cjs.js +3495 -3495
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +11 -11
- package/dist/plume/button/index.d.ts +36 -36
- package/dist/plume/checkbox/index.d.ts +47 -47
- package/dist/plume/collection-utils.d.ts +191 -191
- package/dist/plume/collection-utils.spec.d.ts +1 -1
- package/dist/plume/menu/context.d.ts +8 -8
- package/dist/plume/menu/index.d.ts +3 -3
- package/dist/plume/menu/menu-group.d.ts +23 -23
- package/dist/plume/menu/menu-item.d.ts +23 -23
- package/dist/plume/menu/menu.d.ts +39 -39
- package/dist/plume/menu-button/DropdownMenu.d.ts +34 -34
- package/dist/plume/menu-button/index.d.ts +2 -2
- package/dist/plume/menu-button/menu-button.d.ts +72 -72
- package/dist/plume/menu-button/menu-trigger.d.ts +21 -21
- package/dist/plume/plume-utils.d.ts +41 -41
- package/dist/plume/props-utils.d.ts +15 -15
- package/dist/plume/select/context.d.ts +3 -3
- package/dist/plume/select/index.d.ts +4 -4
- package/dist/plume/select/select-option-group.d.ts +23 -23
- package/dist/plume/select/select-option.d.ts +23 -23
- package/dist/plume/select/select.d.ts +111 -111
- package/dist/plume/switch/index.d.ts +39 -39
- package/dist/plume/text-input/index.d.ts +36 -36
- package/dist/plume/triggered-overlay/context.d.ts +14 -14
- package/dist/plume/triggered-overlay/index.d.ts +2 -2
- package/dist/plume/triggered-overlay/triggered-overlay.d.ts +24 -24
- package/dist/query/index.d.ts +1 -1
- package/dist/react-utils.d.ts +21 -21
- package/dist/react-utils.spec.d.ts +1 -1
- package/dist/react-web.esm.js +3496 -3496
- package/dist/react-web.esm.js.map +1 -1
- package/dist/render/PlasmicHead/index.d.ts +37 -37
- package/dist/render/PlasmicIcon.d.ts +4 -4
- package/dist/render/PlasmicImg/index.d.ts +81 -81
- package/dist/render/PlasmicLink.d.ts +2 -2
- package/dist/render/PlasmicSlot.d.ts +11 -11
- package/dist/render/Stack.d.ts +51 -51
- package/dist/render/elements.d.ts +74 -74
- package/dist/render/global-variants.d.ts +1 -1
- package/dist/render/screen-variants.d.ts +5 -5
- package/dist/render/ssr.d.ts +21 -21
- package/dist/render/translation.d.ts +19 -19
- package/dist/render/triggers.d.ts +39 -39
- package/dist/states/errors.d.ts +13 -13
- package/dist/states/graph.d.ts +25 -25
- package/dist/states/helpers.d.ts +43 -43
- package/dist/states/index.d.ts +4 -4
- package/dist/states/types.d.ts +66 -66
- package/dist/states/valtio.d.ts +10 -10
- package/dist/states/vanilla.d.ts +3 -3
- package/dist/stories/PlasmicImg.stories.d.ts +6 -6
- package/dist/stories/UseDollarState.stories.d.ts +78 -78
- package/lib/data-sources/index.d.ts +1 -1
- package/lib/host/index.d.ts +1 -1
- package/lib/query/index.d.ts +1 -1
- package/package.json +8 -9
- package/skinny/dist/auth/PlasmicPageGuard.d.ts +11 -11
- package/skinny/dist/{collection-utils-0967eaf0.js → collection-utils-2f28e4eb.js} +297 -297
- package/skinny/dist/{collection-utils-0967eaf0.js.map → collection-utils-2f28e4eb.js.map} +1 -1
- package/skinny/dist/{common-9d6d348d.js → common-ed411407.js} +130 -130
- package/skinny/dist/{common-9d6d348d.js.map → common-ed411407.js.map} +1 -1
- package/skinny/dist/common.d.ts +10 -10
- package/skinny/dist/data-sources/index.d.ts +1 -1
- package/skinny/dist/host/index.d.ts +1 -1
- package/skinny/dist/index-common.d.ts +18 -18
- package/skinny/dist/index-skinny.d.ts +1 -1
- package/skinny/dist/index.d.ts +11 -11
- package/skinny/dist/index.js +1559 -1559
- package/skinny/dist/index.js.map +1 -1
- package/skinny/dist/plume/button/index.d.ts +36 -36
- package/skinny/dist/plume/button/index.js +21 -21
- package/skinny/dist/plume/checkbox/index.d.ts +47 -47
- package/skinny/dist/plume/checkbox/index.js +64 -64
- package/skinny/dist/plume/collection-utils.d.ts +191 -191
- package/skinny/dist/plume/collection-utils.spec.d.ts +1 -1
- package/skinny/dist/plume/menu/context.d.ts +8 -8
- package/skinny/dist/plume/menu/index.d.ts +3 -3
- package/skinny/dist/plume/menu/index.js +165 -165
- package/skinny/dist/plume/menu/menu-group.d.ts +23 -23
- package/skinny/dist/plume/menu/menu-item.d.ts +23 -23
- package/skinny/dist/plume/menu/menu.d.ts +39 -39
- package/skinny/dist/plume/menu-button/DropdownMenu.d.ts +34 -34
- package/skinny/dist/plume/menu-button/index.d.ts +2 -2
- package/skinny/dist/plume/menu-button/index.js +125 -125
- package/skinny/dist/plume/menu-button/index.js.map +1 -1
- package/skinny/dist/plume/menu-button/menu-button.d.ts +72 -72
- package/skinny/dist/plume/menu-button/menu-trigger.d.ts +21 -21
- package/skinny/dist/plume/plume-utils.d.ts +41 -41
- package/skinny/dist/plume/props-utils.d.ts +15 -15
- package/skinny/dist/plume/select/context.d.ts +3 -3
- package/skinny/dist/plume/select/index.d.ts +4 -4
- package/skinny/dist/plume/select/index.js +250 -250
- package/skinny/dist/plume/select/index.js.map +1 -1
- package/skinny/dist/plume/select/select-option-group.d.ts +23 -23
- package/skinny/dist/plume/select/select-option.d.ts +23 -23
- package/skinny/dist/plume/select/select.d.ts +111 -111
- package/skinny/dist/plume/switch/index.d.ts +39 -39
- package/skinny/dist/plume/switch/index.js +61 -61
- package/skinny/dist/plume/text-input/index.d.ts +36 -36
- package/skinny/dist/plume/text-input/index.js +45 -45
- package/skinny/dist/plume/triggered-overlay/context.d.ts +14 -14
- package/skinny/dist/plume/triggered-overlay/index.d.ts +2 -2
- package/skinny/dist/plume/triggered-overlay/index.js +100 -100
- package/skinny/dist/plume/triggered-overlay/index.js.map +1 -1
- package/skinny/dist/plume/triggered-overlay/triggered-overlay.d.ts +24 -24
- package/skinny/dist/{plume-utils-7d68bcc0.js → plume-utils-e699cd08.js} +30 -30
- package/skinny/dist/{plume-utils-7d68bcc0.js.map → plume-utils-e699cd08.js.map} +1 -1
- package/skinny/dist/{props-utils-9f9c761a.js → props-utils-9d74371f.js} +4 -4
- package/skinny/dist/{props-utils-9f9c761a.js.map → props-utils-9d74371f.js.map} +1 -1
- package/skinny/dist/query/index.d.ts +1 -1
- package/skinny/dist/{react-utils-ee4e03ba.js → react-utils-5ff031c2.js} +195 -195
- package/skinny/dist/{react-utils-ee4e03ba.js.map → react-utils-5ff031c2.js.map} +1 -1
- package/skinny/dist/react-utils.d.ts +21 -21
- package/skinny/dist/react-utils.spec.d.ts +1 -1
- package/skinny/dist/render/PlasmicHead/index.d.ts +37 -37
- package/skinny/dist/render/PlasmicHead/index.js +54 -54
- package/skinny/dist/render/PlasmicIcon.d.ts +4 -4
- package/skinny/dist/render/PlasmicImg/index.d.ts +81 -81
- package/skinny/dist/render/PlasmicImg/index.js +297 -297
- package/skinny/dist/render/PlasmicLink.d.ts +2 -2
- package/skinny/dist/render/PlasmicSlot.d.ts +11 -11
- package/skinny/dist/render/Stack.d.ts +51 -51
- package/skinny/dist/render/elements.d.ts +74 -74
- package/skinny/dist/render/global-variants.d.ts +1 -1
- package/skinny/dist/render/screen-variants.d.ts +5 -5
- package/skinny/dist/render/ssr.d.ts +21 -21
- package/skinny/dist/render/translation.d.ts +19 -19
- package/skinny/dist/render/triggers.d.ts +39 -39
- package/skinny/dist/{ssr-c9834f50.js → ssr-8625df04.js} +107 -107
- package/skinny/dist/{ssr-c9834f50.js.map → ssr-8625df04.js.map} +1 -1
- package/skinny/dist/states/errors.d.ts +13 -13
- package/skinny/dist/states/graph.d.ts +25 -25
- package/skinny/dist/states/helpers.d.ts +43 -43
- package/skinny/dist/states/index.d.ts +4 -4
- package/skinny/dist/states/types.d.ts +66 -66
- package/skinny/dist/states/valtio.d.ts +10 -10
- package/skinny/dist/states/vanilla.d.ts +3 -3
- package/skinny/dist/stories/PlasmicImg.stories.d.ts +6 -6
- package/skinny/dist/stories/UseDollarState.stories.d.ts +78 -78
|
@@ -4,115 +4,115 @@ import * as React from 'react';
|
|
|
4
4
|
import React__default from 'react';
|
|
5
5
|
import { PlasmicHeadContext } from './render/PlasmicHead/index.js';
|
|
6
6
|
|
|
7
|
-
var PlasmicTranslatorContext = React__default.createContext(undefined);
|
|
8
|
-
function isIterable(val) {
|
|
9
|
-
return val != null && typeof val[Symbol.iterator] === "function";
|
|
10
|
-
}
|
|
11
|
-
function genTranslatableString(elt) {
|
|
12
|
-
var components = {};
|
|
13
|
-
var componentsCount = 0;
|
|
14
|
-
var getText = function (node) {
|
|
15
|
-
if (!node) {
|
|
16
|
-
return "";
|
|
17
|
-
}
|
|
18
|
-
if (typeof node === "number" ||
|
|
19
|
-
typeof node === "boolean" ||
|
|
20
|
-
typeof node === "string") {
|
|
21
|
-
return node.toString();
|
|
22
|
-
}
|
|
23
|
-
if (typeof node !== "object") {
|
|
24
|
-
return "";
|
|
25
|
-
}
|
|
26
|
-
if (Array.isArray(node) || isIterable(node)) {
|
|
27
|
-
return Array.from(node)
|
|
28
|
-
.map(function (child) { return getText(child); })
|
|
29
|
-
.filter(function (child) { return !!child; })
|
|
30
|
-
.join("");
|
|
31
|
-
}
|
|
32
|
-
var nodeChildren = (hasKey(node, "props") &&
|
|
33
|
-
hasKey(node.props, "children") &&
|
|
34
|
-
node.props.children) ||
|
|
35
|
-
(hasKey(node, "children") && node.children) ||
|
|
36
|
-
[];
|
|
37
|
-
var contents = "".concat(React__default.Children.toArray(nodeChildren)
|
|
38
|
-
.map(function (child) { return getText(child); })
|
|
39
|
-
.filter(function (child) { return !!child; })
|
|
40
|
-
.join(""));
|
|
41
|
-
if (React__default.isValidElement(node) && node.type === React__default.Fragment) {
|
|
42
|
-
return contents;
|
|
43
|
-
}
|
|
44
|
-
var componentId = componentsCount + 1;
|
|
45
|
-
componentsCount++;
|
|
46
|
-
components[componentId] = React__default.isValidElement(node)
|
|
47
|
-
? React__default.cloneElement(node, {
|
|
48
|
-
key: componentId,
|
|
49
|
-
children: undefined
|
|
50
|
-
})
|
|
51
|
-
: node;
|
|
52
|
-
return "<".concat(componentId, ">").concat(contents, "</").concat(componentId, ">");
|
|
53
|
-
};
|
|
54
|
-
var str = getText(elt);
|
|
55
|
-
return {
|
|
56
|
-
str: str,
|
|
57
|
-
components: components,
|
|
58
|
-
componentsCount: componentsCount
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
function Trans(_a) {
|
|
62
|
-
var transKey = _a.transKey, children = _a.children;
|
|
63
|
-
var _t = React__default.useContext(PlasmicTranslatorContext);
|
|
64
|
-
if (!_t) {
|
|
65
|
-
warnNoTranslationFunctionAtMostOnce();
|
|
66
|
-
return children;
|
|
67
|
-
}
|
|
68
|
-
var _b = genTranslatableString(children), str = _b.str, components = _b.components, componentsCount = _b.componentsCount;
|
|
69
|
-
return _t(transKey !== null && transKey !== void 0 ? transKey : str, componentsCount > 0 ? { components: components } : undefined);
|
|
70
|
-
}
|
|
71
|
-
var hasWarned = false;
|
|
72
|
-
function warnNoTranslationFunctionAtMostOnce() {
|
|
73
|
-
if (!hasWarned) {
|
|
74
|
-
console.warn("Using Plasmic Translation but no translation function has been provided");
|
|
75
|
-
hasWarned = true;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
function hasKey(v, key) {
|
|
79
|
-
return typeof v === "object" && v !== null && key in v;
|
|
7
|
+
var PlasmicTranslatorContext = React__default.createContext(undefined);
|
|
8
|
+
function isIterable(val) {
|
|
9
|
+
return val != null && typeof val[Symbol.iterator] === "function";
|
|
10
|
+
}
|
|
11
|
+
function genTranslatableString(elt) {
|
|
12
|
+
var components = {};
|
|
13
|
+
var componentsCount = 0;
|
|
14
|
+
var getText = function (node) {
|
|
15
|
+
if (!node) {
|
|
16
|
+
return "";
|
|
17
|
+
}
|
|
18
|
+
if (typeof node === "number" ||
|
|
19
|
+
typeof node === "boolean" ||
|
|
20
|
+
typeof node === "string") {
|
|
21
|
+
return node.toString();
|
|
22
|
+
}
|
|
23
|
+
if (typeof node !== "object") {
|
|
24
|
+
return "";
|
|
25
|
+
}
|
|
26
|
+
if (Array.isArray(node) || isIterable(node)) {
|
|
27
|
+
return Array.from(node)
|
|
28
|
+
.map(function (child) { return getText(child); })
|
|
29
|
+
.filter(function (child) { return !!child; })
|
|
30
|
+
.join("");
|
|
31
|
+
}
|
|
32
|
+
var nodeChildren = (hasKey(node, "props") &&
|
|
33
|
+
hasKey(node.props, "children") &&
|
|
34
|
+
node.props.children) ||
|
|
35
|
+
(hasKey(node, "children") && node.children) ||
|
|
36
|
+
[];
|
|
37
|
+
var contents = "".concat(React__default.Children.toArray(nodeChildren)
|
|
38
|
+
.map(function (child) { return getText(child); })
|
|
39
|
+
.filter(function (child) { return !!child; })
|
|
40
|
+
.join(""));
|
|
41
|
+
if (React__default.isValidElement(node) && node.type === React__default.Fragment) {
|
|
42
|
+
return contents;
|
|
43
|
+
}
|
|
44
|
+
var componentId = componentsCount + 1;
|
|
45
|
+
componentsCount++;
|
|
46
|
+
components[componentId] = React__default.isValidElement(node)
|
|
47
|
+
? React__default.cloneElement(node, {
|
|
48
|
+
key: componentId,
|
|
49
|
+
children: undefined,
|
|
50
|
+
})
|
|
51
|
+
: node;
|
|
52
|
+
return "<".concat(componentId, ">").concat(contents, "</").concat(componentId, ">");
|
|
53
|
+
};
|
|
54
|
+
var str = getText(elt);
|
|
55
|
+
return {
|
|
56
|
+
str: str,
|
|
57
|
+
components: components,
|
|
58
|
+
componentsCount: componentsCount,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function Trans(_a) {
|
|
62
|
+
var transKey = _a.transKey, children = _a.children;
|
|
63
|
+
var _t = React__default.useContext(PlasmicTranslatorContext);
|
|
64
|
+
if (!_t) {
|
|
65
|
+
warnNoTranslationFunctionAtMostOnce();
|
|
66
|
+
return children;
|
|
67
|
+
}
|
|
68
|
+
var _b = genTranslatableString(children), str = _b.str, components = _b.components, componentsCount = _b.componentsCount;
|
|
69
|
+
return _t(transKey !== null && transKey !== void 0 ? transKey : str, componentsCount > 0 ? { components: components } : undefined);
|
|
70
|
+
}
|
|
71
|
+
var hasWarned = false;
|
|
72
|
+
function warnNoTranslationFunctionAtMostOnce() {
|
|
73
|
+
if (!hasWarned) {
|
|
74
|
+
console.warn("Using Plasmic Translation but no translation function has been provided");
|
|
75
|
+
hasWarned = true;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function hasKey(v, key) {
|
|
79
|
+
return typeof v === "object" && v !== null && key in v;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
var PlasmicRootContext = React.createContext(undefined);
|
|
83
|
-
function PlasmicRootProvider(props) {
|
|
84
|
-
var platform = props.platform, children = props.children, userAuthToken = props.userAuthToken, isUserLoading = props.isUserLoading, authRedirectUri = props.authRedirectUri, user = props.user;
|
|
85
|
-
var context = React.useMemo(function () { return ({
|
|
86
|
-
platform: platform
|
|
87
|
-
}); }, [platform]);
|
|
88
|
-
var dataSourceContextValue = React.useMemo(function () { return ({
|
|
89
|
-
userAuthToken: userAuthToken,
|
|
90
|
-
user: user,
|
|
91
|
-
isUserLoading: isUserLoading,
|
|
92
|
-
authRedirectUri: authRedirectUri
|
|
93
|
-
}); }, [userAuthToken, isUserLoading, user, authRedirectUri]);
|
|
94
|
-
return (React.createElement(PlasmicRootContext.Provider, { value: context },
|
|
95
|
-
React.createElement(SSRProvider, null,
|
|
96
|
-
React.createElement(PlasmicDataSourceContextProvider, { value: dataSourceContextValue },
|
|
97
|
-
React.createElement(PlasmicTranslatorContext.Provider, { value: props.translator },
|
|
98
|
-
React.createElement(PlasmicHeadContext.Provider, { value: props.Head }, children))))));
|
|
99
|
-
}
|
|
100
|
-
var useIsSSR = useIsSSR$1;
|
|
101
|
-
function useHasPlasmicRoot() {
|
|
102
|
-
return !!React.useContext(PlasmicRootContext);
|
|
103
|
-
}
|
|
104
|
-
var hasWarnedSSR = false;
|
|
105
|
-
/**
|
|
106
|
-
* Warns the user if PlasmicRootProvider is not used
|
|
107
|
-
*/
|
|
108
|
-
function useEnsureSSRProvider() {
|
|
109
|
-
var hasRoot = useHasPlasmicRoot();
|
|
110
|
-
if (hasRoot || hasWarnedSSR || process.env.NODE_ENV !== "development") {
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
hasWarnedSSR = true;
|
|
114
|
-
console.warn("Plasmic: To ensure your components work correctly with server-side rendering, please use PlasmicRootProvider at the root of your application. See https://docs.plasmic.app/learn/ssr");
|
|
82
|
+
var PlasmicRootContext = React.createContext(undefined);
|
|
83
|
+
function PlasmicRootProvider(props) {
|
|
84
|
+
var platform = props.platform, children = props.children, userAuthToken = props.userAuthToken, isUserLoading = props.isUserLoading, authRedirectUri = props.authRedirectUri, user = props.user;
|
|
85
|
+
var context = React.useMemo(function () { return ({
|
|
86
|
+
platform: platform,
|
|
87
|
+
}); }, [platform]);
|
|
88
|
+
var dataSourceContextValue = React.useMemo(function () { return ({
|
|
89
|
+
userAuthToken: userAuthToken,
|
|
90
|
+
user: user,
|
|
91
|
+
isUserLoading: isUserLoading,
|
|
92
|
+
authRedirectUri: authRedirectUri,
|
|
93
|
+
}); }, [userAuthToken, isUserLoading, user, authRedirectUri]);
|
|
94
|
+
return (React.createElement(PlasmicRootContext.Provider, { value: context },
|
|
95
|
+
React.createElement(SSRProvider, null,
|
|
96
|
+
React.createElement(PlasmicDataSourceContextProvider, { value: dataSourceContextValue },
|
|
97
|
+
React.createElement(PlasmicTranslatorContext.Provider, { value: props.translator },
|
|
98
|
+
React.createElement(PlasmicHeadContext.Provider, { value: props.Head }, children))))));
|
|
99
|
+
}
|
|
100
|
+
var useIsSSR = useIsSSR$1;
|
|
101
|
+
function useHasPlasmicRoot() {
|
|
102
|
+
return !!React.useContext(PlasmicRootContext);
|
|
103
|
+
}
|
|
104
|
+
var hasWarnedSSR = false;
|
|
105
|
+
/**
|
|
106
|
+
* Warns the user if PlasmicRootProvider is not used
|
|
107
|
+
*/
|
|
108
|
+
function useEnsureSSRProvider() {
|
|
109
|
+
var hasRoot = useHasPlasmicRoot();
|
|
110
|
+
if (hasRoot || hasWarnedSSR || process.env.NODE_ENV !== "development") {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
hasWarnedSSR = true;
|
|
114
|
+
console.warn("Plasmic: To ensure your components work correctly with server-side rendering, please use PlasmicRootProvider at the root of your application. See https://docs.plasmic.app/learn/ssr");
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
export { PlasmicRootProvider as P, Trans as T, useEnsureSSRProvider as a, genTranslatableString as g, useIsSSR as u };
|
|
118
|
-
//# sourceMappingURL=ssr-
|
|
118
|
+
//# sourceMappingURL=ssr-8625df04.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ssr-
|
|
1
|
+
{"version":3,"file":"ssr-8625df04.js","sources":["../../src/render/translation.tsx","../../src/render/ssr.tsx"],"sourcesContent":["import React from \"react\";\n\nexport type PlasmicTranslator = (\n str: string,\n opts?: {\n components?: {\n [key: string]: React.ReactElement;\n };\n }\n) => React.ReactNode;\n\nexport const PlasmicTranslatorContext = React.createContext<\n PlasmicTranslator | undefined\n>(undefined);\n\nexport interface TransProps {\n transKey?: string;\n children?: React.ReactNode;\n}\n\nfunction isIterable(val: any): val is Iterable<any> {\n return val != null && typeof val[Symbol.iterator] === \"function\";\n}\n\nexport function genTranslatableString(elt: React.ReactNode) {\n const components: {\n [key: string]: React.ReactElement;\n } = {};\n let componentsCount = 0;\n\n const getText = (node: React.ReactNode): string => {\n if (!node) {\n return \"\";\n }\n if (\n typeof node === \"number\" ||\n typeof node === \"boolean\" ||\n typeof node === \"string\"\n ) {\n return node.toString();\n }\n if (typeof node !== \"object\") {\n return \"\";\n }\n if (Array.isArray(node) || isIterable(node)) {\n return Array.from(node)\n .map((child) => getText(child))\n .filter((child) => !!child)\n .join(\"\");\n }\n const nodeChildren: React.ReactNode =\n (hasKey(node, \"props\") &&\n hasKey(node.props, \"children\") &&\n (node.props.children as React.ReactNode | undefined)) ||\n (hasKey(node, \"children\") && node.children) ||\n [];\n const contents = `${React.Children.toArray(nodeChildren)\n .map((child) => getText(child))\n .filter((child) => !!child)\n .join(\"\")}`;\n if (React.isValidElement(node) && node.type === React.Fragment) {\n return contents;\n }\n const componentId = componentsCount + 1;\n componentsCount++;\n components[componentId] = React.isValidElement(node)\n ? React.cloneElement(node as any, {\n key: componentId,\n children: undefined,\n })\n : (node as never);\n return `<${componentId}>${contents}</${componentId}>`;\n };\n\n const str = getText(elt);\n return {\n str,\n components,\n componentsCount,\n };\n}\n\nexport function Trans({ transKey, children }: TransProps) {\n const _t = React.useContext(PlasmicTranslatorContext);\n if (!_t) {\n warnNoTranslationFunctionAtMostOnce();\n return children;\n }\n\n const { str, components, componentsCount } = genTranslatableString(children);\n return _t(transKey ?? str, componentsCount > 0 ? { components } : undefined);\n}\n\nlet hasWarned = false;\nfunction warnNoTranslationFunctionAtMostOnce() {\n if (!hasWarned) {\n console.warn(\n \"Using Plasmic Translation but no translation function has been provided\"\n );\n hasWarned = true;\n }\n}\n\nfunction hasKey<K extends string>(v: any, key: K): v is Record<K, any> {\n return typeof v === \"object\" && v !== null && key in v;\n}\n","import {\n PlasmicDataSourceContextProvider,\n PlasmicDataSourceContextValue,\n} from \"@plasmicapp/data-sources-context\";\nimport { SSRProvider, useIsSSR as useAriaIsSSR } from \"@react-aria/ssr\";\nimport * as React from \"react\";\nimport { PlasmicHeadContext } from \"./PlasmicHead\";\nimport { PlasmicTranslator, PlasmicTranslatorContext } from \"./translation\";\nexport {\n PlasmicDataSourceContextProvider,\n useCurrentUser,\n} from \"@plasmicapp/data-sources-context\";\n\nexport interface PlasmicRootContextValue {\n platform?: \"nextjs\" | \"gatsby\";\n}\n\nconst PlasmicRootContext = React.createContext<\n PlasmicRootContextValue | undefined\n>(undefined);\n\nexport interface PlasmicRootProviderProps\n extends PlasmicDataSourceContextValue {\n platform?: \"nextjs\" | \"gatsby\";\n children?: React.ReactNode;\n translator?: PlasmicTranslator;\n Head?: React.ComponentType<any>;\n}\n\nexport function PlasmicRootProvider(props: PlasmicRootProviderProps) {\n const {\n platform,\n children,\n userAuthToken,\n isUserLoading,\n authRedirectUri,\n user,\n } = props;\n const context = React.useMemo(\n () => ({\n platform,\n }),\n [platform]\n );\n const dataSourceContextValue = React.useMemo(\n () => ({\n userAuthToken,\n user,\n isUserLoading,\n authRedirectUri,\n }),\n [userAuthToken, isUserLoading, user, authRedirectUri]\n );\n return (\n <PlasmicRootContext.Provider value={context}>\n <SSRProvider>\n <PlasmicDataSourceContextProvider value={dataSourceContextValue}>\n <PlasmicTranslatorContext.Provider value={props.translator}>\n <PlasmicHeadContext.Provider value={props.Head}>\n {children}\n </PlasmicHeadContext.Provider>\n </PlasmicTranslatorContext.Provider>\n </PlasmicDataSourceContextProvider>\n </SSRProvider>\n </PlasmicRootContext.Provider>\n );\n}\n\nexport const useIsSSR = useAriaIsSSR;\n\nexport function useHasPlasmicRoot() {\n return !!React.useContext(PlasmicRootContext);\n}\n\nlet hasWarnedSSR = false;\n/**\n * Warns the user if PlasmicRootProvider is not used\n */\nexport function useEnsureSSRProvider() {\n const hasRoot = useHasPlasmicRoot();\n if (hasRoot || hasWarnedSSR || process.env.NODE_ENV !== \"development\") {\n return;\n }\n\n hasWarnedSSR = true;\n console.warn(\n `Plasmic: To ensure your components work correctly with server-side rendering, please use PlasmicRootProvider at the root of your application. See https://docs.plasmic.app/learn/ssr`\n );\n}\n"],"names":["React","useAriaIsSSR"],"mappings":";;;;;;AAWO,IAAM,wBAAwB,GAAGA,cAAK,CAAC,aAAa,CAEzD,SAAS,CAAC,CAAC;AAOb,SAAS,UAAU,CAAC,GAAQ;IAC1B,OAAO,GAAG,IAAI,IAAI,IAAI,OAAO,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,UAAU,CAAC;AACnE,CAAC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Aa;SAErB,iBAAiB;IAC/B,OAAO,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAC;AAChD,CAAC;AAED,IAAI,YAAY,GAAG,KAAK,CAAC;AACzB;;;SAGgB,oBAAoB;IAClC,IAAM,OAAO,GAAG,iBAAiB,EAAE,CAAC;IACpC,IAAI,OAAO,IAAI,YAAY,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,EAAE;QACrE,OAAO;KACR;IAED,YAAY,GAAG,IAAI,CAAC;IACpB,OAAO,CAAC,IAAI,CACV,uLAAuL,CACxL,CAAC;AACJ;;;;"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export declare class CustomError extends Error {
|
|
2
|
-
name: string;
|
|
3
|
-
constructor(msg?: string);
|
|
4
|
-
}
|
|
5
|
-
export declare class CyclicStatesReferencesError extends Error {
|
|
6
|
-
constructor(stateAccessCycle: string[]);
|
|
7
|
-
}
|
|
8
|
-
export declare class InvalidOperation extends Error {
|
|
9
|
-
constructor(msg: string);
|
|
10
|
-
}
|
|
11
|
-
export declare class UnknownError extends Error {
|
|
12
|
-
constructor(msg: string);
|
|
13
|
-
}
|
|
1
|
+
export declare class CustomError extends Error {
|
|
2
|
+
name: string;
|
|
3
|
+
constructor(msg?: string);
|
|
4
|
+
}
|
|
5
|
+
export declare class CyclicStatesReferencesError extends Error {
|
|
6
|
+
constructor(stateAccessCycle: string[]);
|
|
7
|
+
}
|
|
8
|
+
export declare class InvalidOperation extends Error {
|
|
9
|
+
constructor(msg: string);
|
|
10
|
+
}
|
|
11
|
+
export declare class UnknownError extends Error {
|
|
12
|
+
constructor(msg: string);
|
|
13
|
+
}
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { $StateSpec, Internal$StateSpec, ObjectPath } from "./types";
|
|
2
|
-
export declare class StateSpecNode<T> {
|
|
3
|
-
private _specs;
|
|
4
|
-
private _edges;
|
|
5
|
-
constructor(specs: Internal$StateSpec<T>[]);
|
|
6
|
-
setSpecs(specs: Internal$StateSpec<T>[]): void;
|
|
7
|
-
edges(): Map<string | symbol, StateSpecNode<any>>;
|
|
8
|
-
hasEdge(key: string | symbol): boolean;
|
|
9
|
-
addEdge(key: string | symbol, node: StateSpecNode<any>): void;
|
|
10
|
-
clearEdges(): void;
|
|
11
|
-
children(): IterableIterator<StateSpecNode<any>>;
|
|
12
|
-
makeTransition(key: string | symbol | number): StateSpecNode<any> | undefined;
|
|
13
|
-
isLeaf(): boolean;
|
|
14
|
-
hasArrayTransition(): boolean;
|
|
15
|
-
getSpec(): Internal$StateSpec<T>;
|
|
16
|
-
getAllSpecs(): Internal$StateSpec<T>[];
|
|
17
|
-
}
|
|
18
|
-
export declare const transformPathStringToObj: (str: string) => (string | symbol)[];
|
|
19
|
-
export declare function buildTree(specs: $StateSpec<any>[]): StateSpecNode<any>;
|
|
20
|
-
export declare function updateTree(root: StateSpecNode<any>, specs: $StateSpec<any>[]): StateSpecNode<any>;
|
|
21
|
-
export declare function getSpecTreeLeaves(root: StateSpecNode<any>): StateSpecNode<any>[];
|
|
22
|
-
export declare function findStateCell(root: StateSpecNode<any>, pathStr: string, repetitionIndex?: number[]): {
|
|
23
|
-
node: StateSpecNode<any>;
|
|
24
|
-
realPath: ObjectPath;
|
|
25
|
-
};
|
|
1
|
+
import { $StateSpec, Internal$StateSpec, ObjectPath } from "./types";
|
|
2
|
+
export declare class StateSpecNode<T> {
|
|
3
|
+
private _specs;
|
|
4
|
+
private _edges;
|
|
5
|
+
constructor(specs: Internal$StateSpec<T>[]);
|
|
6
|
+
setSpecs(specs: Internal$StateSpec<T>[]): void;
|
|
7
|
+
edges(): Map<string | symbol, StateSpecNode<any>>;
|
|
8
|
+
hasEdge(key: string | symbol): boolean;
|
|
9
|
+
addEdge(key: string | symbol, node: StateSpecNode<any>): void;
|
|
10
|
+
clearEdges(): void;
|
|
11
|
+
children(): IterableIterator<StateSpecNode<any>>;
|
|
12
|
+
makeTransition(key: string | symbol | number): StateSpecNode<any> | undefined;
|
|
13
|
+
isLeaf(): boolean;
|
|
14
|
+
hasArrayTransition(): boolean;
|
|
15
|
+
getSpec(): Internal$StateSpec<T>;
|
|
16
|
+
getAllSpecs(): Internal$StateSpec<T>[];
|
|
17
|
+
}
|
|
18
|
+
export declare const transformPathStringToObj: (str: string) => (string | symbol)[];
|
|
19
|
+
export declare function buildTree(specs: $StateSpec<any>[]): StateSpecNode<any>;
|
|
20
|
+
export declare function updateTree(root: StateSpecNode<any>, specs: $StateSpec<any>[]): StateSpecNode<any>;
|
|
21
|
+
export declare function getSpecTreeLeaves(root: StateSpecNode<any>): StateSpecNode<any>[];
|
|
22
|
+
export declare function findStateCell(root: StateSpecNode<any>, pathStr: string, repetitionIndex?: number[]): {
|
|
23
|
+
node: StateSpecNode<any>;
|
|
24
|
+
realPath: ObjectPath;
|
|
25
|
+
};
|
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
import type { ComponentHelpers } from "@plasmicapp/host";
|
|
2
|
-
import { useLayoutEffect } from "react";
|
|
3
|
-
import { StateSpecNode } from "./graph";
|
|
4
|
-
import { $State, InitFunc, ObjectPath, StateCell } from "./types";
|
|
5
|
-
export declare function initializeCodeComponentStates($state: $State, states: {
|
|
6
|
-
name: string;
|
|
7
|
-
plasmicStateName: string;
|
|
8
|
-
}[], repetitionIndex: number[], componentHelpers: ComponentHelpers<any>, child$Props: Record<string, any>): void;
|
|
9
|
-
export declare function initializePlasmicStates($state: $State, states: {
|
|
10
|
-
name: string;
|
|
11
|
-
initFunc: InitFunc<any>;
|
|
12
|
-
}[], repetitionIndex: number[]): void;
|
|
13
|
-
export declare function generateStateOnChangeProp($state: $State, path: ObjectPath): (val: any) => void;
|
|
14
|
-
export declare function generateStateOnChangePropForCodeComponents($state: $State, stateName: string, plasmicStatePath: ObjectPath, componentHelpers: ComponentHelpers<any>): (val: any) => void;
|
|
15
|
-
export declare function generateStateValueProp($state: $State, path: ObjectPath): any;
|
|
16
|
-
export declare const useIsomorphicLayoutEffect: typeof useLayoutEffect;
|
|
17
|
-
export declare function isPlasmicStateProxy(obj: any): boolean;
|
|
18
|
-
export declare function is$StateProxy(obj: any): number | boolean | undefined;
|
|
19
|
-
export declare function getStateCells($state: $State, root: StateSpecNode<any>): StateCell<any>[];
|
|
20
|
-
export declare function getStateCellsInPlasmicProxy(obj: any): {
|
|
21
|
-
realPath: ObjectPath;
|
|
22
|
-
path: string;
|
|
23
|
-
}[];
|
|
24
|
-
export declare function getStateSpecInPlasmicProxy(obj: any, path: ObjectPath): {
|
|
25
|
-
spec: import("./types").Internal$StateSpec<any>;
|
|
26
|
-
isImplicitStateArray: boolean;
|
|
27
|
-
} | undefined;
|
|
28
|
-
export declare function getCurrentInitialValue(obj: any, path: ObjectPath): any;
|
|
29
|
-
export declare function resetToInitialValue(obj: any, path: ObjectPath): void;
|
|
30
|
-
export declare function shallowEqual<T>(a1: T[], a2: T[]): boolean;
|
|
31
|
-
/**
|
|
32
|
-
* Shallow comparison of arrays.
|
|
33
|
-
*/
|
|
34
|
-
export declare function arrayEq(xs: ReadonlyArray<any>, ys: ReadonlyArray<any>): boolean;
|
|
35
|
-
export declare function isNum(value: string | number | symbol): value is number;
|
|
36
|
-
type StringGen = string | (() => string);
|
|
37
|
-
export declare function assert<T>(cond: T, msg?: StringGen): asserts cond;
|
|
38
|
-
/**
|
|
39
|
-
* Forked from https://github.com/lukeed/dset
|
|
40
|
-
* Changes: fixed setting a deep value to a proxy object
|
|
41
|
-
*/
|
|
42
|
-
export declare function set(obj: any, keys: any, val: any): void;
|
|
43
|
-
export {};
|
|
1
|
+
import type { ComponentHelpers } from "@plasmicapp/host";
|
|
2
|
+
import { useLayoutEffect } from "react";
|
|
3
|
+
import { StateSpecNode } from "./graph";
|
|
4
|
+
import { $State, InitFunc, ObjectPath, StateCell } from "./types";
|
|
5
|
+
export declare function initializeCodeComponentStates($state: $State, states: {
|
|
6
|
+
name: string;
|
|
7
|
+
plasmicStateName: string;
|
|
8
|
+
}[], repetitionIndex: number[], componentHelpers: ComponentHelpers<any>, child$Props: Record<string, any>): void;
|
|
9
|
+
export declare function initializePlasmicStates($state: $State, states: {
|
|
10
|
+
name: string;
|
|
11
|
+
initFunc: InitFunc<any>;
|
|
12
|
+
}[], repetitionIndex: number[]): void;
|
|
13
|
+
export declare function generateStateOnChangeProp($state: $State, path: ObjectPath): (val: any) => void;
|
|
14
|
+
export declare function generateStateOnChangePropForCodeComponents($state: $State, stateName: string, plasmicStatePath: ObjectPath, componentHelpers: ComponentHelpers<any>): (val: any) => void;
|
|
15
|
+
export declare function generateStateValueProp($state: $State, path: ObjectPath): any;
|
|
16
|
+
export declare const useIsomorphicLayoutEffect: typeof useLayoutEffect;
|
|
17
|
+
export declare function isPlasmicStateProxy(obj: any): boolean;
|
|
18
|
+
export declare function is$StateProxy(obj: any): number | boolean | undefined;
|
|
19
|
+
export declare function getStateCells($state: $State, root: StateSpecNode<any>): StateCell<any>[];
|
|
20
|
+
export declare function getStateCellsInPlasmicProxy(obj: any): {
|
|
21
|
+
realPath: ObjectPath;
|
|
22
|
+
path: string;
|
|
23
|
+
}[];
|
|
24
|
+
export declare function getStateSpecInPlasmicProxy(obj: any, path: ObjectPath): {
|
|
25
|
+
spec: import("./types").Internal$StateSpec<any>;
|
|
26
|
+
isImplicitStateArray: boolean;
|
|
27
|
+
} | undefined;
|
|
28
|
+
export declare function getCurrentInitialValue(obj: any, path: ObjectPath): any;
|
|
29
|
+
export declare function resetToInitialValue(obj: any, path: ObjectPath): void;
|
|
30
|
+
export declare function shallowEqual<T>(a1: T[], a2: T[]): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Shallow comparison of arrays.
|
|
33
|
+
*/
|
|
34
|
+
export declare function arrayEq(xs: ReadonlyArray<any>, ys: ReadonlyArray<any>): boolean;
|
|
35
|
+
export declare function isNum(value: string | number | symbol): value is number;
|
|
36
|
+
type StringGen = string | (() => string);
|
|
37
|
+
export declare function assert<T>(cond: T, msg?: StringGen): asserts cond;
|
|
38
|
+
/**
|
|
39
|
+
* Forked from https://github.com/lukeed/dset
|
|
40
|
+
* Changes: fixed setting a deep value to a proxy object
|
|
41
|
+
*/
|
|
42
|
+
export declare function set(obj: any, keys: any, val: any): void;
|
|
43
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { default as get } from "dlv";
|
|
2
|
-
export { generateStateOnChangeProp, generateStateOnChangePropForCodeComponents, generateStateValueProp, getCurrentInitialValue, getStateCellsInPlasmicProxy, getStateSpecInPlasmicProxy, initializeCodeComponentStates, initializePlasmicStates, is$StateProxy, isPlasmicStateProxy, resetToInitialValue, set, } from "./helpers";
|
|
3
|
-
export { $State, $StateSpec } from "./types";
|
|
4
|
-
export { useDollarState } from "./valtio";
|
|
1
|
+
export { default as get } from "dlv";
|
|
2
|
+
export { generateStateOnChangeProp, generateStateOnChangePropForCodeComponents, generateStateValueProp, getCurrentInitialValue, getStateCellsInPlasmicProxy, getStateSpecInPlasmicProxy, initializeCodeComponentStates, initializePlasmicStates, is$StateProxy, isPlasmicStateProxy, resetToInitialValue, set, } from "./helpers";
|
|
3
|
+
export { $State, $StateSpec } from "./types";
|
|
4
|
+
export { useDollarState } from "./valtio";
|
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
import { StateSpecNode } from "./graph";
|
|
2
|
-
export type InitFuncEnv = {
|
|
3
|
-
$props: Record<string, any>;
|
|
4
|
-
$state: Record<string, any>;
|
|
5
|
-
$queries?: Record<string, any>;
|
|
6
|
-
$ctx?: Record<string, any>;
|
|
7
|
-
};
|
|
8
|
-
export type DollarStateEnv = Omit<InitFuncEnv, "$state">;
|
|
9
|
-
export type NoUndefinedField<T> = {
|
|
10
|
-
[P in keyof T]-?: T[P];
|
|
11
|
-
};
|
|
12
|
-
export type InitFunc<T> = (env: NoUndefinedField<InitFuncEnv>) => T;
|
|
13
|
-
export type DeprecatedInitFunc<T> = ($props: Record<string, any>, $state: $State, $ctx: Record<string, any>) => T;
|
|
14
|
-
export type ObjectPath = (string | number)[];
|
|
15
|
-
export interface $StateSpec<T> {
|
|
16
|
-
path: string;
|
|
17
|
-
initFunc?: InitFunc<T>;
|
|
18
|
-
initVal?: T;
|
|
19
|
-
type: "private" | "readonly" | "writable";
|
|
20
|
-
valueProp?: string;
|
|
21
|
-
onChangeProp?: string;
|
|
22
|
-
isImmutable?: boolean;
|
|
23
|
-
variableType: "text" | "number" | "boolean" | "array" | "object" | "variant";
|
|
24
|
-
initFuncHash?: string;
|
|
25
|
-
}
|
|
26
|
-
export interface $State {
|
|
27
|
-
[key: string]: any;
|
|
28
|
-
registerInitFunc?: (path: string, f: InitFunc<any>, repetitonIndex?: number[], overrideEnv?: DollarStateEnv) => any;
|
|
29
|
-
}
|
|
30
|
-
export declare const ARRAY_SYMBOL: unique symbol;
|
|
31
|
-
export declare const PLASMIC_STATE_PROXY_SYMBOL: unique symbol;
|
|
32
|
-
export declare const UNINITIALIZED: unique symbol;
|
|
33
|
-
export interface Internal$StateSpec<T> extends $StateSpec<T> {
|
|
34
|
-
isRepeated: boolean;
|
|
35
|
-
pathObj: (string | symbol)[];
|
|
36
|
-
}
|
|
37
|
-
export interface Internal$StateInstance {
|
|
38
|
-
path: ObjectPath;
|
|
39
|
-
specKey: string;
|
|
40
|
-
}
|
|
41
|
-
export interface StateCell<T> {
|
|
42
|
-
initialValue?: T | Symbol;
|
|
43
|
-
node: StateSpecNode<any>;
|
|
44
|
-
path: ObjectPath;
|
|
45
|
-
initFunc?: InitFunc<T>;
|
|
46
|
-
listeners: (() => void)[];
|
|
47
|
-
initFuncHash: string;
|
|
48
|
-
overrideEnv?: NoUndefinedField<DollarStateEnv>;
|
|
49
|
-
}
|
|
50
|
-
export interface Internal$State {
|
|
51
|
-
registrationsQueue: {
|
|
52
|
-
node: StateSpecNode<any>;
|
|
53
|
-
path: ObjectPath;
|
|
54
|
-
f: InitFunc<any>;
|
|
55
|
-
overrideEnv?: NoUndefinedField<DollarStateEnv>;
|
|
56
|
-
}[];
|
|
57
|
-
stateValues: Record<string, any>;
|
|
58
|
-
env: NoUndefinedField<DollarStateEnv>;
|
|
59
|
-
rootSpecTree: StateSpecNode<any>;
|
|
60
|
-
specTreeLeaves: StateSpecNode<any>[];
|
|
61
|
-
specs: $StateSpec<any>[];
|
|
62
|
-
stateInitializationEnv: {
|
|
63
|
-
stack: string[];
|
|
64
|
-
visited: Set<string>;
|
|
65
|
-
};
|
|
66
|
-
}
|
|
1
|
+
import { StateSpecNode } from "./graph";
|
|
2
|
+
export type InitFuncEnv = {
|
|
3
|
+
$props: Record<string, any>;
|
|
4
|
+
$state: Record<string, any>;
|
|
5
|
+
$queries?: Record<string, any>;
|
|
6
|
+
$ctx?: Record<string, any>;
|
|
7
|
+
};
|
|
8
|
+
export type DollarStateEnv = Omit<InitFuncEnv, "$state">;
|
|
9
|
+
export type NoUndefinedField<T> = {
|
|
10
|
+
[P in keyof T]-?: T[P];
|
|
11
|
+
};
|
|
12
|
+
export type InitFunc<T> = (env: NoUndefinedField<InitFuncEnv>) => T;
|
|
13
|
+
export type DeprecatedInitFunc<T> = ($props: Record<string, any>, $state: $State, $ctx: Record<string, any>) => T;
|
|
14
|
+
export type ObjectPath = (string | number)[];
|
|
15
|
+
export interface $StateSpec<T> {
|
|
16
|
+
path: string;
|
|
17
|
+
initFunc?: InitFunc<T>;
|
|
18
|
+
initVal?: T;
|
|
19
|
+
type: "private" | "readonly" | "writable";
|
|
20
|
+
valueProp?: string;
|
|
21
|
+
onChangeProp?: string;
|
|
22
|
+
isImmutable?: boolean;
|
|
23
|
+
variableType: "text" | "number" | "boolean" | "array" | "object" | "variant";
|
|
24
|
+
initFuncHash?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface $State {
|
|
27
|
+
[key: string]: any;
|
|
28
|
+
registerInitFunc?: (path: string, f: InitFunc<any>, repetitonIndex?: number[], overrideEnv?: DollarStateEnv) => any;
|
|
29
|
+
}
|
|
30
|
+
export declare const ARRAY_SYMBOL: unique symbol;
|
|
31
|
+
export declare const PLASMIC_STATE_PROXY_SYMBOL: unique symbol;
|
|
32
|
+
export declare const UNINITIALIZED: unique symbol;
|
|
33
|
+
export interface Internal$StateSpec<T> extends $StateSpec<T> {
|
|
34
|
+
isRepeated: boolean;
|
|
35
|
+
pathObj: (string | symbol)[];
|
|
36
|
+
}
|
|
37
|
+
export interface Internal$StateInstance {
|
|
38
|
+
path: ObjectPath;
|
|
39
|
+
specKey: string;
|
|
40
|
+
}
|
|
41
|
+
export interface StateCell<T> {
|
|
42
|
+
initialValue?: T | Symbol;
|
|
43
|
+
node: StateSpecNode<any>;
|
|
44
|
+
path: ObjectPath;
|
|
45
|
+
initFunc?: InitFunc<T>;
|
|
46
|
+
listeners: (() => void)[];
|
|
47
|
+
initFuncHash: string;
|
|
48
|
+
overrideEnv?: NoUndefinedField<DollarStateEnv>;
|
|
49
|
+
}
|
|
50
|
+
export interface Internal$State {
|
|
51
|
+
registrationsQueue: {
|
|
52
|
+
node: StateSpecNode<any>;
|
|
53
|
+
path: ObjectPath;
|
|
54
|
+
f: InitFunc<any>;
|
|
55
|
+
overrideEnv?: NoUndefinedField<DollarStateEnv>;
|
|
56
|
+
}[];
|
|
57
|
+
stateValues: Record<string, any>;
|
|
58
|
+
env: NoUndefinedField<DollarStateEnv>;
|
|
59
|
+
rootSpecTree: StateSpecNode<any>;
|
|
60
|
+
specTreeLeaves: StateSpecNode<any>[];
|
|
61
|
+
specs: $StateSpec<any>[];
|
|
62
|
+
stateInitializationEnv: {
|
|
63
|
+
stack: string[];
|
|
64
|
+
visited: Set<string>;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { StateSpecNode } from "./graph";
|
|
2
|
-
import { $State, $StateSpec, Internal$State, ObjectPath, StateCell } from "./types";
|
|
3
|
-
export declare const proxyObjToStateCell: WeakMap<object, Record<string | number | symbol, StateCell<any>>>;
|
|
4
|
-
export declare const valtioSubscriptions: WeakMap<object, (() => boolean)[]>;
|
|
5
|
-
export declare function tryGetStateCellFrom$StateRoot($state: $State, path: ObjectPath): StateCell<any> | undefined;
|
|
6
|
-
export declare function getStateCellFrom$StateRoot($state: $State, path: ObjectPath): StateCell<any>;
|
|
7
|
-
export declare function unsubscribeToValtio($$state: Internal$State, statePath: ObjectPath): void;
|
|
8
|
-
export declare function subscribeToValtio($$state: Internal$State, statePath: ObjectPath, node: StateSpecNode<any>): void;
|
|
9
|
-
export declare function useDollarState(specs: $StateSpec<any>[], ...rest: any[]): $State;
|
|
10
|
-
export default useDollarState;
|
|
1
|
+
import { StateSpecNode } from "./graph";
|
|
2
|
+
import { $State, $StateSpec, Internal$State, ObjectPath, StateCell } from "./types";
|
|
3
|
+
export declare const proxyObjToStateCell: WeakMap<object, Record<string | number | symbol, StateCell<any>>>;
|
|
4
|
+
export declare const valtioSubscriptions: WeakMap<object, (() => boolean)[]>;
|
|
5
|
+
export declare function tryGetStateCellFrom$StateRoot($state: $State, path: ObjectPath): StateCell<any> | undefined;
|
|
6
|
+
export declare function getStateCellFrom$StateRoot($state: $State, path: ObjectPath): StateCell<any>;
|
|
7
|
+
export declare function unsubscribeToValtio($$state: Internal$State, statePath: ObjectPath): void;
|
|
8
|
+
export declare function subscribeToValtio($$state: Internal$State, statePath: ObjectPath, node: StateSpecNode<any>): void;
|
|
9
|
+
export declare function useDollarState(specs: $StateSpec<any>[], ...rest: any[]): $State;
|
|
10
|
+
export default useDollarState;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { $State, $StateSpec } from ".";
|
|
2
|
-
declare function useVanillaDollarState(_specs: $StateSpec<any>[], props: Record<string, any>): $State;
|
|
3
|
-
export default useVanillaDollarState;
|
|
1
|
+
import { $State, $StateSpec } from ".";
|
|
2
|
+
declare function useVanillaDollarState(_specs: $StateSpec<any>[], props: Record<string, any>): $State;
|
|
3
|
+
export default useVanillaDollarState;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ComponentMeta, ComponentStory } from "@storybook/react";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import "../styles/plasmic.css";
|
|
4
|
-
export declare const Base: ComponentStory<React.ForwardRefExoticComponent<import("../render/PlasmicImg").PlasmicImgProps & React.RefAttributes<HTMLElement>>>;
|
|
5
|
-
declare const _default: ComponentMeta<React.ForwardRefExoticComponent<import("../render/PlasmicImg").PlasmicImgProps & React.RefAttributes<HTMLElement>>>;
|
|
6
|
-
export default _default;
|
|
1
|
+
import { ComponentMeta, ComponentStory } from "@storybook/react";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import "../styles/plasmic.css";
|
|
4
|
+
export declare const Base: ComponentStory<React.ForwardRefExoticComponent<import("../render/PlasmicImg").PlasmicImgProps & React.RefAttributes<HTMLElement>>>;
|
|
5
|
+
declare const _default: ComponentMeta<React.ForwardRefExoticComponent<import("../render/PlasmicImg").PlasmicImgProps & React.RefAttributes<HTMLElement>>>;
|
|
6
|
+
export default _default;
|