@makeswift/runtime 0.28.9 → 0.28.10-canary.1
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/cjs/api/graphql-api-client.js +1 -1
- package/dist/cjs/api/rest-api-client.js +1 -1
- package/dist/cjs/api-handler/handlers/manifest.js +1 -1
- package/dist/cjs/next/components/tests/controls/page-control-prop-rendering.js +24 -2
- package/dist/cjs/next/components/tests/controls/page-control-prop-rendering.js.map +1 -1
- package/dist/cjs/react/server/index.js +45 -0
- package/dist/cjs/react/server/index.js.map +1 -0
- package/dist/cjs/runtimes/react/components/ElementData.js +41 -8
- package/dist/cjs/runtimes/react/components/ElementData.js.map +1 -1
- package/dist/cjs/runtimes/react/components/framework-context.js.map +1 -1
- package/dist/cjs/runtimes/react/controls/rich-text/EditableText/editable-text.js +3 -1
- package/dist/cjs/runtimes/react/controls/rich-text/EditableText/editable-text.js.map +1 -1
- package/dist/cjs/runtimes/react/controls/rich-text-v2/EditableTextV2/editable-text-v2.js +3 -0
- package/dist/cjs/runtimes/react/controls/rich-text-v2/EditableTextV2/editable-text-v2.js.map +1 -1
- package/dist/cjs/runtimes/react/controls/use-slate-reset.js +37 -0
- package/dist/cjs/runtimes/react/controls/use-slate-reset.js.map +1 -0
- package/dist/cjs/runtimes/react/hooks/use-editable-element-stylesheet-factory.js +58 -0
- package/dist/cjs/runtimes/react/hooks/use-editable-element-stylesheet-factory.js.map +1 -0
- package/dist/cjs/runtimes/react/hooks/use-element-data.js +35 -0
- package/dist/cjs/runtimes/react/hooks/use-element-data.js.map +1 -0
- package/dist/cjs/runtimes/react/hooks/use-element.js +40 -0
- package/dist/cjs/runtimes/react/hooks/use-element.js.map +1 -0
- package/dist/cjs/runtimes/react/hooks/use-resolved-props.js.map +1 -1
- package/dist/cjs/runtimes/react/hooks/use-server-element-refresh.js +90 -0
- package/dist/cjs/runtimes/react/hooks/use-server-element-refresh.js.map +1 -0
- package/dist/cjs/runtimes/react/react-runtime-core.js +22 -4
- package/dist/cjs/runtimes/react/react-runtime-core.js.map +1 -1
- package/dist/cjs/runtimes/react/resource-resolver.js.map +1 -1
- package/dist/cjs/runtimes/react/server/collect-server-elements.js +74 -0
- package/dist/cjs/runtimes/react/server/collect-server-elements.js.map +1 -0
- package/dist/cjs/runtimes/react/server/components/editable-server-element.js +173 -0
- package/dist/cjs/runtimes/react/server/components/editable-server-element.js.map +1 -0
- package/dist/cjs/runtimes/react/server/components/element-data.js +76 -0
- package/dist/cjs/runtimes/react/server/components/element-data.js.map +1 -0
- package/dist/cjs/runtimes/react/server/components/element.js +59 -0
- package/dist/cjs/runtimes/react/server/components/element.js.map +1 -0
- package/dist/cjs/runtimes/react/server/components/makeswift-component.js +32 -0
- package/dist/cjs/runtimes/react/server/components/makeswift-component.js.map +1 -0
- package/dist/cjs/runtimes/react/server/components/renderer.js +54 -0
- package/dist/cjs/runtimes/react/server/components/renderer.js.map +1 -0
- package/dist/cjs/runtimes/react/server/components/server-elements-cache.js +70 -0
- package/dist/cjs/runtimes/react/server/components/server-elements-cache.js.map +1 -0
- package/dist/cjs/runtimes/react/server/components/slot.js +33 -0
- package/dist/cjs/runtimes/react/server/components/slot.js.map +1 -0
- package/dist/cjs/runtimes/react/server/components/snapshot-renderer.js +50 -0
- package/dist/cjs/runtimes/react/server/components/snapshot-renderer.js.map +1 -0
- package/dist/cjs/runtimes/react/server/css/client-css.js +112 -0
- package/dist/cjs/runtimes/react/server/css/client-css.js.map +1 -0
- package/dist/cjs/runtimes/react/server/css/css-runtime.js +102 -0
- package/dist/cjs/runtimes/react/server/css/css-runtime.js.map +1 -0
- package/dist/cjs/runtimes/react/server/css/server-css.js +71 -0
- package/dist/cjs/runtimes/react/server/css/server-css.js.map +1 -0
- package/dist/cjs/runtimes/react/server/index.js +51 -0
- package/dist/cjs/runtimes/react/server/index.js.map +1 -0
- package/dist/cjs/runtimes/react/server/render-context.js +58 -0
- package/dist/cjs/runtimes/react/server/render-context.js.map +1 -0
- package/dist/cjs/runtimes/react/server/render-element-payload.js +45 -0
- package/dist/cjs/runtimes/react/server/render-element-payload.js.map +1 -0
- package/dist/cjs/runtimes/react/server/resolve-props.js +58 -0
- package/dist/cjs/runtimes/react/server/resolve-props.js.map +1 -0
- package/dist/cjs/runtimes/react/server/resource-resolver.js +40 -0
- package/dist/cjs/runtimes/react/server/resource-resolver.js.map +1 -0
- package/dist/cjs/runtimes/react/server/update-api-resource-cache.js +32 -0
- package/dist/cjs/runtimes/react/server/update-api-resource-cache.js.map +1 -0
- package/dist/cjs/runtimes/react/testing/react-runtime.js +19 -2
- package/dist/cjs/runtimes/react/testing/react-runtime.js.map +1 -1
- package/dist/cjs/state/modules/components-meta.js.map +1 -1
- package/dist/cjs/unstable-framework-support/index.js +3 -0
- package/dist/cjs/unstable-framework-support/index.js.map +1 -1
- package/dist/cjs/utils/prop-by-path.js +35 -0
- package/dist/cjs/utils/prop-by-path.js.map +1 -0
- package/dist/cjs/utils/set.js +32 -0
- package/dist/cjs/utils/set.js.map +1 -0
- package/dist/esm/api/graphql-api-client.js +1 -1
- package/dist/esm/api/rest-api-client.js +1 -1
- package/dist/esm/api-handler/handlers/manifest.js +1 -1
- package/dist/esm/next/components/tests/controls/page-control-prop-rendering.js +24 -2
- package/dist/esm/next/components/tests/controls/page-control-prop-rendering.js.map +1 -1
- package/dist/esm/react/server/index.js +23 -0
- package/dist/esm/react/server/index.js.map +1 -0
- package/dist/esm/runtimes/react/components/ElementData.js +42 -9
- package/dist/esm/runtimes/react/components/ElementData.js.map +1 -1
- package/dist/esm/runtimes/react/components/framework-context.js.map +1 -1
- package/dist/esm/runtimes/react/controls/rich-text/EditableText/editable-text.js +3 -1
- package/dist/esm/runtimes/react/controls/rich-text/EditableText/editable-text.js.map +1 -1
- package/dist/esm/runtimes/react/controls/rich-text-v2/EditableTextV2/editable-text-v2.js +3 -0
- package/dist/esm/runtimes/react/controls/rich-text-v2/EditableTextV2/editable-text-v2.js.map +1 -1
- package/dist/esm/runtimes/react/controls/use-slate-reset.js +13 -0
- package/dist/esm/runtimes/react/controls/use-slate-reset.js.map +1 -0
- package/dist/esm/runtimes/react/hooks/use-editable-element-stylesheet-factory.js +34 -0
- package/dist/esm/runtimes/react/hooks/use-editable-element-stylesheet-factory.js.map +1 -0
- package/dist/esm/runtimes/react/hooks/use-element-data.js +11 -0
- package/dist/esm/runtimes/react/hooks/use-element-data.js.map +1 -0
- package/dist/esm/runtimes/react/hooks/use-element.js +16 -0
- package/dist/esm/runtimes/react/hooks/use-element.js.map +1 -0
- package/dist/esm/runtimes/react/hooks/use-resolved-props.js.map +1 -1
- package/dist/esm/runtimes/react/hooks/use-server-element-refresh.js +66 -0
- package/dist/esm/runtimes/react/hooks/use-server-element-refresh.js.map +1 -0
- package/dist/esm/runtimes/react/react-runtime-core.js +22 -4
- package/dist/esm/runtimes/react/react-runtime-core.js.map +1 -1
- package/dist/esm/runtimes/react/resource-resolver.js.map +1 -1
- package/dist/esm/runtimes/react/server/collect-server-elements.js +50 -0
- package/dist/esm/runtimes/react/server/collect-server-elements.js.map +1 -0
- package/dist/esm/runtimes/react/server/components/editable-server-element.js +152 -0
- package/dist/esm/runtimes/react/server/components/editable-server-element.js.map +1 -0
- package/dist/esm/runtimes/react/server/components/element-data.js +60 -0
- package/dist/esm/runtimes/react/server/components/element-data.js.map +1 -0
- package/dist/esm/runtimes/react/server/components/element.js +38 -0
- package/dist/esm/runtimes/react/server/components/element.js.map +1 -0
- package/dist/esm/runtimes/react/server/components/makeswift-component.js +8 -0
- package/dist/esm/runtimes/react/server/components/makeswift-component.js.map +1 -0
- package/dist/esm/runtimes/react/server/components/renderer.js +29 -0
- package/dist/esm/runtimes/react/server/components/renderer.js.map +1 -0
- package/dist/esm/runtimes/react/server/components/server-elements-cache.js +45 -0
- package/dist/esm/runtimes/react/server/components/server-elements-cache.js.map +1 -0
- package/dist/esm/runtimes/react/server/components/slot.js +9 -0
- package/dist/esm/runtimes/react/server/components/slot.js.map +1 -0
- package/dist/esm/runtimes/react/server/components/snapshot-renderer.js +26 -0
- package/dist/esm/runtimes/react/server/components/snapshot-renderer.js.map +1 -0
- package/dist/esm/runtimes/react/server/css/client-css.js +87 -0
- package/dist/esm/runtimes/react/server/css/client-css.js.map +1 -0
- package/dist/esm/runtimes/react/server/css/css-runtime.js +77 -0
- package/dist/esm/runtimes/react/server/css/css-runtime.js.map +1 -0
- package/dist/esm/runtimes/react/server/css/server-css.js +45 -0
- package/dist/esm/runtimes/react/server/css/server-css.js.map +1 -0
- package/dist/esm/runtimes/react/server/index.js +23 -0
- package/dist/esm/runtimes/react/server/index.js.map +1 -0
- package/dist/esm/runtimes/react/server/render-context.js +31 -0
- package/dist/esm/runtimes/react/server/render-context.js.map +1 -0
- package/dist/esm/runtimes/react/server/render-element-payload.js +21 -0
- package/dist/esm/runtimes/react/server/render-element-payload.js.map +1 -0
- package/dist/esm/runtimes/react/server/resolve-props.js +34 -0
- package/dist/esm/runtimes/react/server/resolve-props.js.map +1 -0
- package/dist/esm/runtimes/react/server/resource-resolver.js +16 -0
- package/dist/esm/runtimes/react/server/resource-resolver.js.map +1 -0
- package/dist/esm/runtimes/react/server/update-api-resource-cache.js +8 -0
- package/dist/esm/runtimes/react/server/update-api-resource-cache.js.map +1 -0
- package/dist/esm/runtimes/react/testing/react-runtime.js +19 -2
- package/dist/esm/runtimes/react/testing/react-runtime.js.map +1 -1
- package/dist/esm/state/modules/components-meta.js.map +1 -1
- package/dist/esm/unstable-framework-support/index.js +2 -0
- package/dist/esm/unstable-framework-support/index.js.map +1 -1
- package/dist/esm/utils/prop-by-path.js +10 -0
- package/dist/esm/utils/prop-by-path.js.map +1 -0
- package/dist/esm/utils/set.js +7 -0
- package/dist/esm/utils/set.js.map +1 -0
- package/dist/types/next/components/tests/controls/page-control-prop-rendering.d.ts +2 -1
- package/dist/types/next/components/tests/controls/page-control-prop-rendering.d.ts.map +1 -1
- package/dist/types/react/server/index.d.ts +2 -0
- package/dist/types/react/server/index.d.ts.map +1 -0
- package/dist/types/runtimes/react/components/ElementData.d.ts +2 -2
- package/dist/types/runtimes/react/components/ElementData.d.ts.map +1 -1
- package/dist/types/runtimes/react/components/framework-context.d.ts +6 -1
- package/dist/types/runtimes/react/components/framework-context.d.ts.map +1 -1
- package/dist/types/runtimes/react/controls/rich-text/EditableText/editable-text.d.ts.map +1 -1
- package/dist/types/runtimes/react/controls/rich-text-v2/EditableTextV2/editable-text-v2.d.ts.map +1 -1
- package/dist/types/runtimes/react/controls/use-slate-reset.d.ts +35 -0
- package/dist/types/runtimes/react/controls/use-slate-reset.d.ts.map +1 -0
- package/dist/types/runtimes/react/hooks/__tests__/use-server-element-refresh.test.d.ts +3 -0
- package/dist/types/runtimes/react/hooks/__tests__/use-server-element-refresh.test.d.ts.map +1 -0
- package/dist/types/runtimes/react/hooks/use-editable-element-stylesheet-factory.d.ts +5 -0
- package/dist/types/runtimes/react/hooks/use-editable-element-stylesheet-factory.d.ts.map +1 -0
- package/dist/types/runtimes/react/hooks/use-element-data.d.ts +5 -0
- package/dist/types/runtimes/react/hooks/use-element-data.d.ts.map +1 -0
- package/dist/types/runtimes/react/hooks/use-element.d.ts +5 -0
- package/dist/types/runtimes/react/hooks/use-element.d.ts.map +1 -0
- package/dist/types/runtimes/react/hooks/use-resolved-props.d.ts +3 -0
- package/dist/types/runtimes/react/hooks/use-resolved-props.d.ts.map +1 -1
- package/dist/types/runtimes/react/hooks/use-server-element-refresh.d.ts +14 -0
- package/dist/types/runtimes/react/hooks/use-server-element-refresh.d.ts.map +1 -0
- package/dist/types/runtimes/react/react-runtime-core.d.ts +3 -1
- package/dist/types/runtimes/react/react-runtime-core.d.ts.map +1 -1
- package/dist/types/runtimes/react/resource-resolver.d.ts +1 -0
- package/dist/types/runtimes/react/resource-resolver.d.ts.map +1 -1
- package/dist/types/runtimes/react/server/collect-server-elements.d.ts +19 -0
- package/dist/types/runtimes/react/server/collect-server-elements.d.ts.map +1 -0
- package/dist/types/runtimes/react/server/components/__tests__/editable-server-element.test.d.ts +3 -0
- package/dist/types/runtimes/react/server/components/__tests__/editable-server-element.test.d.ts.map +1 -0
- package/dist/types/runtimes/react/server/components/editable-server-element.d.ts +6 -0
- package/dist/types/runtimes/react/server/components/editable-server-element.d.ts.map +1 -0
- package/dist/types/runtimes/react/server/components/element-data.d.ts +9 -0
- package/dist/types/runtimes/react/server/components/element-data.d.ts.map +1 -0
- package/dist/types/runtimes/react/server/components/element.d.ts +9 -0
- package/dist/types/runtimes/react/server/components/element.d.ts.map +1 -0
- package/dist/types/runtimes/react/server/components/makeswift-component.d.ts +8 -0
- package/dist/types/runtimes/react/server/components/makeswift-component.d.ts.map +1 -0
- package/dist/types/runtimes/react/server/components/renderer.d.ts +23 -0
- package/dist/types/runtimes/react/server/components/renderer.d.ts.map +1 -0
- package/dist/types/runtimes/react/server/components/server-elements-cache.d.ts +22 -0
- package/dist/types/runtimes/react/server/components/server-elements-cache.d.ts.map +1 -0
- package/dist/types/runtimes/react/server/components/slot.d.ts +8 -0
- package/dist/types/runtimes/react/server/components/slot.d.ts.map +1 -0
- package/dist/types/runtimes/react/server/components/snapshot-renderer.d.ts +10 -0
- package/dist/types/runtimes/react/server/components/snapshot-renderer.d.ts.map +1 -0
- package/dist/types/runtimes/react/server/css/client-css.d.ts +10 -0
- package/dist/types/runtimes/react/server/css/client-css.d.ts.map +1 -0
- package/dist/types/runtimes/react/server/css/css-runtime.d.ts +16 -0
- package/dist/types/runtimes/react/server/css/css-runtime.d.ts.map +1 -0
- package/dist/types/runtimes/react/server/css/server-css.d.ts +14 -0
- package/dist/types/runtimes/react/server/css/server-css.d.ts.map +1 -0
- package/dist/types/runtimes/react/server/index.d.ts +8 -0
- package/dist/types/runtimes/react/server/index.d.ts.map +1 -0
- package/dist/types/runtimes/react/server/render-context.d.ts +28 -0
- package/dist/types/runtimes/react/server/render-context.d.ts.map +1 -0
- package/dist/types/runtimes/react/server/render-element-payload.d.ts +215 -0
- package/dist/types/runtimes/react/server/render-element-payload.d.ts.map +1 -0
- package/dist/types/runtimes/react/server/resolve-props.d.ts +7 -0
- package/dist/types/runtimes/react/server/resolve-props.d.ts.map +1 -0
- package/dist/types/runtimes/react/server/resource-resolver.d.ts +6 -0
- package/dist/types/runtimes/react/server/resource-resolver.d.ts.map +1 -0
- package/dist/types/runtimes/react/server/update-api-resource-cache.d.ts +4 -0
- package/dist/types/runtimes/react/server/update-api-resource-cache.d.ts.map +1 -0
- package/dist/types/runtimes/react/testing/react-runtime.d.ts +12 -2
- package/dist/types/runtimes/react/testing/react-runtime.d.ts.map +1 -1
- package/dist/types/state/modules/components-meta.d.ts +1 -0
- package/dist/types/state/modules/components-meta.d.ts.map +1 -1
- package/dist/types/unstable-framework-support/index.d.ts +1 -0
- package/dist/types/unstable-framework-support/index.d.ts.map +1 -1
- package/dist/types/utils/__tests__/prop-by-path.test.d.ts +2 -0
- package/dist/types/utils/__tests__/prop-by-path.test.d.ts.map +1 -0
- package/dist/types/utils/prop-by-path.d.ts +3 -0
- package/dist/types/utils/prop-by-path.d.ts.map +1 -0
- package/dist/types/utils/set.d.ts +3 -0
- package/dist/types/utils/set.d.ts.map +1 -0
- package/package.json +8 -3
- package/react/server/package.json +5 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { createContext, useContext, useEffect, useRef, useCallback } from "react";
|
|
4
|
+
import { MAKESWIFT_RSC_STYLE_TAG_ID_PREFIX } from "./css-runtime";
|
|
5
|
+
const ClientCSSContext = createContext({
|
|
6
|
+
updateStyle(elementKey, propName, cssString) {
|
|
7
|
+
console.error(
|
|
8
|
+
`Attempt to update client style for server component ${elementKey}'s '${propName}' prop outside of 'ClientCSSProvider'`,
|
|
9
|
+
cssString
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
function ClientCSSProvider({ children }) {
|
|
14
|
+
const styleElementsRef = useRef(/* @__PURE__ */ new Map());
|
|
15
|
+
const serverStylesRef = useRef(/* @__PURE__ */ new Map());
|
|
16
|
+
const dynamicStylesRef = useRef(/* @__PURE__ */ new Map());
|
|
17
|
+
const updateStyleElement = useCallback(
|
|
18
|
+
(elementKey, elementStyles) => {
|
|
19
|
+
const styleElement = styleElementsRef.current.get(elementKey);
|
|
20
|
+
if (styleElement == null)
|
|
21
|
+
return;
|
|
22
|
+
const serverCss = serverStylesRef.current.get(elementKey) ?? "";
|
|
23
|
+
const dynamicCss = Array.from(elementStyles.values()).join("\n");
|
|
24
|
+
const combinedStyles = dynamicCss === serverCss ? serverCss : [serverCss, dynamicCss].filter(Boolean).join("\n");
|
|
25
|
+
if (styleElement.textContent !== combinedStyles) {
|
|
26
|
+
styleElement.textContent = combinedStyles;
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
[]
|
|
30
|
+
);
|
|
31
|
+
const registerStyleElement = useCallback(
|
|
32
|
+
(styleElement) => {
|
|
33
|
+
const href = styleElement.dataset["href"];
|
|
34
|
+
if (href == null || !href.startsWith(MAKESWIFT_RSC_STYLE_TAG_ID_PREFIX))
|
|
35
|
+
return;
|
|
36
|
+
const elementKey = href.substring(MAKESWIFT_RSC_STYLE_TAG_ID_PREFIX.length);
|
|
37
|
+
if (elementKey == "") {
|
|
38
|
+
console.error("Ignoring style element with a missing element key", styleElement);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (styleElement === styleElementsRef.current.get(elementKey))
|
|
42
|
+
return;
|
|
43
|
+
styleElementsRef.current.set(elementKey, styleElement);
|
|
44
|
+
serverStylesRef.current.set(elementKey, styleElement.textContent);
|
|
45
|
+
const elementStyles = dynamicStylesRef.current.get(elementKey);
|
|
46
|
+
if (elementStyles != null) {
|
|
47
|
+
updateStyleElement(elementKey, elementStyles);
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
[updateStyleElement]
|
|
51
|
+
);
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
document.head.querySelectorAll(
|
|
54
|
+
`style[data-href^="${MAKESWIFT_RSC_STYLE_TAG_ID_PREFIX}"]`
|
|
55
|
+
).forEach(registerStyleElement);
|
|
56
|
+
const observer = new MutationObserver((mutationList) => {
|
|
57
|
+
for (const mutation of mutationList) {
|
|
58
|
+
for (const node of mutation.addedNodes) {
|
|
59
|
+
if (node instanceof HTMLStyleElement)
|
|
60
|
+
registerStyleElement(node);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
observer.observe(document.head, { childList: true });
|
|
65
|
+
return () => {
|
|
66
|
+
observer.disconnect();
|
|
67
|
+
};
|
|
68
|
+
}, [registerStyleElement]);
|
|
69
|
+
const updateStyle = useCallback(
|
|
70
|
+
(elementKey, propName, cssString) => {
|
|
71
|
+
const elementStyles = dynamicStylesRef.current.get(elementKey) ?? /* @__PURE__ */ new Map();
|
|
72
|
+
elementStyles.set(propName, cssString);
|
|
73
|
+
dynamicStylesRef.current.set(elementKey, elementStyles);
|
|
74
|
+
updateStyleElement(elementKey, elementStyles);
|
|
75
|
+
},
|
|
76
|
+
[updateStyleElement]
|
|
77
|
+
);
|
|
78
|
+
return /* @__PURE__ */ jsx(ClientCSSContext.Provider, { value: { updateStyle }, children });
|
|
79
|
+
}
|
|
80
|
+
function useClientCSS() {
|
|
81
|
+
return useContext(ClientCSSContext);
|
|
82
|
+
}
|
|
83
|
+
export {
|
|
84
|
+
ClientCSSProvider,
|
|
85
|
+
useClientCSS
|
|
86
|
+
};
|
|
87
|
+
//# sourceMappingURL=client-css.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/runtimes/react/server/css/client-css.tsx"],"sourcesContent":["'use client'\n\nimport { createContext, ReactNode, useContext, useEffect, useRef, useCallback } from 'react'\n\nimport { MAKESWIFT_RSC_STYLE_TAG_ID_PREFIX } from './css-runtime'\n\ntype ClientCSSContextValue = {\n updateStyle: (elementKey: string, propName: string, cssString: string) => void\n}\n\nconst ClientCSSContext = createContext<ClientCSSContextValue>({\n updateStyle(elementKey: string, propName: string, cssString: string) {\n console.error(\n `Attempt to update client style for server component ${elementKey}'s '${propName}' prop outside of 'ClientCSSProvider'`,\n cssString,\n )\n },\n})\n\nexport function ClientCSSProvider({ children }: { children: ReactNode }) {\n const styleElementsRef = useRef<Map<string, HTMLStyleElement>>(new Map())\n const serverStylesRef = useRef<Map<string, string>>(new Map())\n const dynamicStylesRef = useRef<Map<string, Map<string, string>>>(new Map())\n\n const updateStyleElement = useCallback(\n (elementKey: string, elementStyles: Map<string, string>) => {\n const styleElement = styleElementsRef.current.get(elementKey)\n if (styleElement == null) return\n\n const serverCss = serverStylesRef.current.get(elementKey) ?? ''\n const dynamicCss = Array.from(elementStyles.values()).join('\\n')\n const combinedStyles =\n dynamicCss === serverCss ? serverCss : [serverCss, dynamicCss].filter(Boolean).join('\\n')\n\n if (styleElement.textContent !== combinedStyles) {\n styleElement.textContent = combinedStyles\n }\n },\n [],\n )\n\n const registerStyleElement = useCallback(\n (styleElement: HTMLStyleElement) => {\n const href = styleElement.dataset['href']\n if (href == null || !href.startsWith(MAKESWIFT_RSC_STYLE_TAG_ID_PREFIX)) return\n\n const elementKey = href.substring(MAKESWIFT_RSC_STYLE_TAG_ID_PREFIX.length)\n if (elementKey == '') {\n console.error('Ignoring style element with a missing element key', styleElement)\n return\n }\n\n // don't recapture elements that we're already tracking\n if (styleElement === styleElementsRef.current.get(elementKey)) return\n\n styleElementsRef.current.set(elementKey, styleElement)\n serverStylesRef.current.set(elementKey, styleElement.textContent)\n\n const elementStyles = dynamicStylesRef.current.get(elementKey)\n if (elementStyles != null) {\n updateStyleElement(elementKey, elementStyles)\n }\n },\n [updateStyleElement],\n )\n\n useEffect(() => {\n // initialize style elements map and capture server styles for existing\n // RSC-rendered elements, if any\n document.head\n .querySelectorAll<HTMLStyleElement>(\n `style[data-href^=\"${MAKESWIFT_RSC_STYLE_TAG_ID_PREFIX}\"]`,\n )\n .forEach(registerStyleElement)\n\n // set up a `document.head` observer to capture dynamically added RSC `<style>` nodes\n const observer = new MutationObserver(mutationList => {\n for (const mutation of mutationList) {\n for (const node of mutation.addedNodes) {\n if (node instanceof HTMLStyleElement) registerStyleElement(node)\n }\n }\n })\n\n observer.observe(document.head, { childList: true })\n\n return () => {\n observer.disconnect()\n }\n }, [registerStyleElement])\n\n const updateStyle = useCallback(\n (elementKey: string, propName: string, cssString: string) => {\n const elementStyles = dynamicStylesRef.current.get(elementKey) ?? new Map()\n elementStyles.set(propName, cssString)\n dynamicStylesRef.current.set(elementKey, elementStyles)\n\n updateStyleElement(elementKey, elementStyles)\n },\n [updateStyleElement],\n )\n\n return <ClientCSSContext.Provider value={{ updateStyle }}>{children}</ClientCSSContext.Provider>\n}\n\nexport function useClientCSS(): ClientCSSContextValue {\n return useContext(ClientCSSContext)\n}\n"],"mappings":";AAsGS;AApGT,SAAS,eAA0B,YAAY,WAAW,QAAQ,mBAAmB;AAErF,SAAS,yCAAyC;AAMlD,MAAM,mBAAmB,cAAqC;AAAA,EAC5D,YAAY,YAAoB,UAAkB,WAAmB;AACnE,YAAQ;AAAA,MACN,uDAAuD,UAAU,OAAO,QAAQ;AAAA,MAChF;AAAA,IACF;AAAA,EACF;AACF,CAAC;AAEM,SAAS,kBAAkB,EAAE,SAAS,GAA4B;AACvE,QAAM,mBAAmB,OAAsC,oBAAI,IAAI,CAAC;AACxE,QAAM,kBAAkB,OAA4B,oBAAI,IAAI,CAAC;AAC7D,QAAM,mBAAmB,OAAyC,oBAAI,IAAI,CAAC;AAE3E,QAAM,qBAAqB;AAAA,IACzB,CAAC,YAAoB,kBAAuC;AAC1D,YAAM,eAAe,iBAAiB,QAAQ,IAAI,UAAU;AAC5D,UAAI,gBAAgB;AAAM;AAE1B,YAAM,YAAY,gBAAgB,QAAQ,IAAI,UAAU,KAAK;AAC7D,YAAM,aAAa,MAAM,KAAK,cAAc,OAAO,CAAC,EAAE,KAAK,IAAI;AAC/D,YAAM,iBACJ,eAAe,YAAY,YAAY,CAAC,WAAW,UAAU,EAAE,OAAO,OAAO,EAAE,KAAK,IAAI;AAE1F,UAAI,aAAa,gBAAgB,gBAAgB;AAC/C,qBAAa,cAAc;AAAA,MAC7B;AAAA,IACF;AAAA,IACA,CAAC;AAAA,EACH;AAEA,QAAM,uBAAuB;AAAA,IAC3B,CAAC,iBAAmC;AAClC,YAAM,OAAO,aAAa,QAAQ,MAAM;AACxC,UAAI,QAAQ,QAAQ,CAAC,KAAK,WAAW,iCAAiC;AAAG;AAEzE,YAAM,aAAa,KAAK,UAAU,kCAAkC,MAAM;AAC1E,UAAI,cAAc,IAAI;AACpB,gBAAQ,MAAM,qDAAqD,YAAY;AAC/E;AAAA,MACF;AAGA,UAAI,iBAAiB,iBAAiB,QAAQ,IAAI,UAAU;AAAG;AAE/D,uBAAiB,QAAQ,IAAI,YAAY,YAAY;AACrD,sBAAgB,QAAQ,IAAI,YAAY,aAAa,WAAW;AAEhE,YAAM,gBAAgB,iBAAiB,QAAQ,IAAI,UAAU;AAC7D,UAAI,iBAAiB,MAAM;AACzB,2BAAmB,YAAY,aAAa;AAAA,MAC9C;AAAA,IACF;AAAA,IACA,CAAC,kBAAkB;AAAA,EACrB;AAEA,YAAU,MAAM;AAGd,aAAS,KACN;AAAA,MACC,qBAAqB,iCAAiC;AAAA,IACxD,EACC,QAAQ,oBAAoB;AAG/B,UAAM,WAAW,IAAI,iBAAiB,kBAAgB;AACpD,iBAAW,YAAY,cAAc;AACnC,mBAAW,QAAQ,SAAS,YAAY;AACtC,cAAI,gBAAgB;AAAkB,iCAAqB,IAAI;AAAA,QACjE;AAAA,MACF;AAAA,IACF,CAAC;AAED,aAAS,QAAQ,SAAS,MAAM,EAAE,WAAW,KAAK,CAAC;AAEnD,WAAO,MAAM;AACX,eAAS,WAAW;AAAA,IACtB;AAAA,EACF,GAAG,CAAC,oBAAoB,CAAC;AAEzB,QAAM,cAAc;AAAA,IAClB,CAAC,YAAoB,UAAkB,cAAsB;AAC3D,YAAM,gBAAgB,iBAAiB,QAAQ,IAAI,UAAU,KAAK,oBAAI,IAAI;AAC1E,oBAAc,IAAI,UAAU,SAAS;AACrC,uBAAiB,QAAQ,IAAI,YAAY,aAAa;AAEtD,yBAAmB,YAAY,aAAa;AAAA,IAC9C;AAAA,IACA,CAAC,kBAAkB;AAAA,EACrB;AAEA,SAAO,oBAAC,iBAAiB,UAAjB,EAA0B,OAAO,EAAE,YAAY,GAAI,UAAS;AACtE;AAEO,SAAS,eAAsC;AACpD,SAAO,WAAW,gBAAgB;AACpC;","names":[]}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { resolvedStyleToCss } from "../../lib/resolved-style-to-css";
|
|
2
|
+
const MAKESWIFT_RSC_STYLE_TAG_ID_PREFIX = "makeswift-rsc-";
|
|
3
|
+
function cssObjectToString(cssObject, className) {
|
|
4
|
+
const cssRules = [];
|
|
5
|
+
const mediaRules = [];
|
|
6
|
+
const baseStyles = {};
|
|
7
|
+
Object.entries(cssObject).forEach(([property, value]) => {
|
|
8
|
+
if (property.startsWith("@media")) {
|
|
9
|
+
const mediaQueryStyles = value;
|
|
10
|
+
const mediaCSS = Object.entries(mediaQueryStyles).map(([prop, val]) => formatCSSProperty(prop, val)).filter(Boolean).join(" ");
|
|
11
|
+
if (mediaCSS) {
|
|
12
|
+
mediaRules.push(`${property} { .${className} { ${mediaCSS} } }`);
|
|
13
|
+
}
|
|
14
|
+
} else {
|
|
15
|
+
baseStyles[property] = value;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
const baseCSS = Object.entries(baseStyles).map(([prop, val]) => formatCSSProperty(prop, val)).filter(Boolean).join(" ");
|
|
19
|
+
if (baseCSS) {
|
|
20
|
+
cssRules.push(`.${className} { ${baseCSS} }`);
|
|
21
|
+
}
|
|
22
|
+
cssRules.push(...mediaRules);
|
|
23
|
+
return cssRules.join("\n");
|
|
24
|
+
}
|
|
25
|
+
function formatCSSProperty(property, value) {
|
|
26
|
+
if (value == null || value === "")
|
|
27
|
+
return "";
|
|
28
|
+
if (Array.isArray(value)) {
|
|
29
|
+
return value.length > 0 ? `${kebabCase(property)}: ${value.join(" ")};` : "";
|
|
30
|
+
}
|
|
31
|
+
return `${kebabCase(property)}: ${value};`;
|
|
32
|
+
}
|
|
33
|
+
function kebabCase(str) {
|
|
34
|
+
return str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);
|
|
35
|
+
}
|
|
36
|
+
function generateClassName(elementKey, propName, counter) {
|
|
37
|
+
const parts = ["makeswift-rsc"];
|
|
38
|
+
if (elementKey)
|
|
39
|
+
parts.push(elementKey);
|
|
40
|
+
if (propName)
|
|
41
|
+
parts.push(propName);
|
|
42
|
+
if (counter !== void 0)
|
|
43
|
+
parts.push(counter.toString());
|
|
44
|
+
return parts.join("-");
|
|
45
|
+
}
|
|
46
|
+
class StylesheetEngine {
|
|
47
|
+
constructor(breakpointsData, elementKey, basePropName, onStyleGenerated) {
|
|
48
|
+
this.breakpointsData = breakpointsData;
|
|
49
|
+
this.elementKey = elementKey;
|
|
50
|
+
this.basePropName = basePropName;
|
|
51
|
+
this.onStyleGenerated = onStyleGenerated;
|
|
52
|
+
}
|
|
53
|
+
styleCounter = 0;
|
|
54
|
+
breakpoints() {
|
|
55
|
+
return this.breakpointsData;
|
|
56
|
+
}
|
|
57
|
+
defineStyle(style) {
|
|
58
|
+
const className = generateClassName(this.elementKey, this.basePropName, ++this.styleCounter);
|
|
59
|
+
const cssObject = resolvedStyleToCss(this.breakpointsData, style);
|
|
60
|
+
const cssString = cssObjectToString(cssObject, className);
|
|
61
|
+
this.onStyleGenerated?.(className, cssString, this.elementKey, this.basePropName);
|
|
62
|
+
return className;
|
|
63
|
+
}
|
|
64
|
+
child(propName) {
|
|
65
|
+
return new StylesheetEngine(
|
|
66
|
+
this.breakpointsData,
|
|
67
|
+
this.elementKey,
|
|
68
|
+
[this.basePropName, propName].filter(Boolean).join("-"),
|
|
69
|
+
this.onStyleGenerated
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
export {
|
|
74
|
+
MAKESWIFT_RSC_STYLE_TAG_ID_PREFIX,
|
|
75
|
+
StylesheetEngine
|
|
76
|
+
};
|
|
77
|
+
//# sourceMappingURL=css-runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/runtimes/react/server/css/css-runtime.ts"],"sourcesContent":["import type { CSSInterpolation, CSSObject } from '@emotion/serialize'\nimport { type Breakpoints, type Stylesheet, type ResolvedStyle } from '@makeswift/controls'\nimport { resolvedStyleToCss } from '../../lib/resolved-style-to-css'\n\nexport const MAKESWIFT_RSC_STYLE_TAG_ID_PREFIX = 'makeswift-rsc-'\n\nfunction cssObjectToString(cssObject: CSSObject, className: string): string {\n const cssRules: string[] = []\n const mediaRules: string[] = []\n const baseStyles: Record<string, CSSInterpolation> = {}\n\n Object.entries(cssObject).forEach(([property, value]) => {\n if (property.startsWith('@media')) {\n const mediaQueryStyles = value as CSSObject\n const mediaCSS = Object.entries(mediaQueryStyles)\n .map(([prop, val]) => formatCSSProperty(prop, val))\n .filter(Boolean)\n .join(' ')\n\n if (mediaCSS) {\n mediaRules.push(`${property} { .${className} { ${mediaCSS} } }`)\n }\n } else {\n baseStyles[property] = value\n }\n })\n\n const baseCSS = Object.entries(baseStyles)\n .map(([prop, val]) => formatCSSProperty(prop, val))\n .filter(Boolean)\n .join(' ')\n\n if (baseCSS) {\n cssRules.push(`.${className} { ${baseCSS} }`)\n }\n\n cssRules.push(...mediaRules)\n return cssRules.join('\\n')\n}\n\nfunction formatCSSProperty(property: string, value: any): string {\n if (value == null || value === '') return ''\n\n if (Array.isArray(value)) {\n return value.length > 0 ? `${kebabCase(property)}: ${value.join(' ')};` : ''\n }\n\n return `${kebabCase(property)}: ${value};`\n}\n\nfunction kebabCase(str: string): string {\n return str.replace(/[A-Z]/g, letter => `-${letter.toLowerCase()}`)\n}\n\nfunction generateClassName(elementKey?: string, propName?: string, counter?: number): string {\n const parts = ['makeswift-rsc']\n if (elementKey) parts.push(elementKey)\n if (propName) parts.push(propName)\n if (counter !== undefined) parts.push(counter.toString())\n return parts.join('-')\n}\n\ntype OnStyleGenerated = (\n className: string,\n css: string,\n elementKey?: string,\n propName?: string,\n) => void\n\n// Unified stylesheet engine that handles both server and client modes\nexport class StylesheetEngine implements Stylesheet {\n private styleCounter = 0\n\n constructor(\n private breakpointsData: Breakpoints,\n private elementKey?: string,\n private basePropName?: string,\n private onStyleGenerated?: OnStyleGenerated,\n ) {}\n\n breakpoints(): Breakpoints {\n return this.breakpointsData\n }\n\n defineStyle(style: ResolvedStyle): string {\n const className = generateClassName(this.elementKey, this.basePropName, ++this.styleCounter)\n\n const cssObject = resolvedStyleToCss(this.breakpointsData, style)\n const cssString = cssObjectToString(cssObject, className)\n\n this.onStyleGenerated?.(className, cssString, this.elementKey, this.basePropName)\n\n return className\n }\n\n child(propName: string): Stylesheet {\n return new StylesheetEngine(\n this.breakpointsData,\n this.elementKey,\n [this.basePropName, propName].filter(Boolean).join('-'),\n this.onStyleGenerated,\n )\n }\n}\n"],"mappings":"AAEA,SAAS,0BAA0B;AAE5B,MAAM,oCAAoC;AAEjD,SAAS,kBAAkB,WAAsB,WAA2B;AAC1E,QAAM,WAAqB,CAAC;AAC5B,QAAM,aAAuB,CAAC;AAC9B,QAAM,aAA+C,CAAC;AAEtD,SAAO,QAAQ,SAAS,EAAE,QAAQ,CAAC,CAAC,UAAU,KAAK,MAAM;AACvD,QAAI,SAAS,WAAW,QAAQ,GAAG;AACjC,YAAM,mBAAmB;AACzB,YAAM,WAAW,OAAO,QAAQ,gBAAgB,EAC7C,IAAI,CAAC,CAAC,MAAM,GAAG,MAAM,kBAAkB,MAAM,GAAG,CAAC,EACjD,OAAO,OAAO,EACd,KAAK,GAAG;AAEX,UAAI,UAAU;AACZ,mBAAW,KAAK,GAAG,QAAQ,OAAO,SAAS,MAAM,QAAQ,MAAM;AAAA,MACjE;AAAA,IACF,OAAO;AACL,iBAAW,QAAQ,IAAI;AAAA,IACzB;AAAA,EACF,CAAC;AAED,QAAM,UAAU,OAAO,QAAQ,UAAU,EACtC,IAAI,CAAC,CAAC,MAAM,GAAG,MAAM,kBAAkB,MAAM,GAAG,CAAC,EACjD,OAAO,OAAO,EACd,KAAK,GAAG;AAEX,MAAI,SAAS;AACX,aAAS,KAAK,IAAI,SAAS,MAAM,OAAO,IAAI;AAAA,EAC9C;AAEA,WAAS,KAAK,GAAG,UAAU;AAC3B,SAAO,SAAS,KAAK,IAAI;AAC3B;AAEA,SAAS,kBAAkB,UAAkB,OAAoB;AAC/D,MAAI,SAAS,QAAQ,UAAU;AAAI,WAAO;AAE1C,MAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,WAAO,MAAM,SAAS,IAAI,GAAG,UAAU,QAAQ,CAAC,KAAK,MAAM,KAAK,GAAG,CAAC,MAAM;AAAA,EAC5E;AAEA,SAAO,GAAG,UAAU,QAAQ,CAAC,KAAK,KAAK;AACzC;AAEA,SAAS,UAAU,KAAqB;AACtC,SAAO,IAAI,QAAQ,UAAU,YAAU,IAAI,OAAO,YAAY,CAAC,EAAE;AACnE;AAEA,SAAS,kBAAkB,YAAqB,UAAmB,SAA0B;AAC3F,QAAM,QAAQ,CAAC,eAAe;AAC9B,MAAI;AAAY,UAAM,KAAK,UAAU;AACrC,MAAI;AAAU,UAAM,KAAK,QAAQ;AACjC,MAAI,YAAY;AAAW,UAAM,KAAK,QAAQ,SAAS,CAAC;AACxD,SAAO,MAAM,KAAK,GAAG;AACvB;AAUO,MAAM,iBAAuC;AAAA,EAGlD,YACU,iBACA,YACA,cACA,kBACR;AAJQ;AACA;AACA;AACA;AAAA,EACP;AAAA,EAPK,eAAe;AAAA,EASvB,cAA2B;AACzB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,YAAY,OAA8B;AACxC,UAAM,YAAY,kBAAkB,KAAK,YAAY,KAAK,cAAc,EAAE,KAAK,YAAY;AAE3F,UAAM,YAAY,mBAAmB,KAAK,iBAAiB,KAAK;AAChE,UAAM,YAAY,kBAAkB,WAAW,SAAS;AAExD,SAAK,mBAAmB,WAAW,WAAW,KAAK,YAAY,KAAK,YAAY;AAEhF,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,UAA8B;AAClC,WAAO,IAAI;AAAA,MACT,KAAK;AAAA,MACL,KAAK;AAAA,MACL,CAAC,KAAK,cAAc,QAAQ,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG;AAAA,MACtD,KAAK;AAAA,IACP;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { StylesheetEngine, MAKESWIFT_RSC_STYLE_TAG_ID_PREFIX } from "./css-runtime";
|
|
3
|
+
class ServerCSSCollector {
|
|
4
|
+
styles = /* @__PURE__ */ new Map();
|
|
5
|
+
collect(className, css) {
|
|
6
|
+
if (this.styles.has(className))
|
|
7
|
+
return;
|
|
8
|
+
this.styles.set(className, css);
|
|
9
|
+
}
|
|
10
|
+
hasStyles() {
|
|
11
|
+
return this.styles.size > 0;
|
|
12
|
+
}
|
|
13
|
+
getAllStyles() {
|
|
14
|
+
return Array.from(this.styles.values()).join("\n");
|
|
15
|
+
}
|
|
16
|
+
clear() {
|
|
17
|
+
this.styles.clear();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function createCollectingServerStylesheet(collector, breakpoints, elementKey) {
|
|
21
|
+
return new StylesheetEngine(breakpoints, elementKey, void 0, (className, css) => {
|
|
22
|
+
collector.collect(className, css);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
function InjectServerCSS({
|
|
26
|
+
collector,
|
|
27
|
+
elementKey
|
|
28
|
+
}) {
|
|
29
|
+
if (!collector.hasStyles())
|
|
30
|
+
return null;
|
|
31
|
+
const css = collector.getAllStyles();
|
|
32
|
+
const styleTagId = `${MAKESWIFT_RSC_STYLE_TAG_ID_PREFIX}${elementKey}`;
|
|
33
|
+
return (
|
|
34
|
+
// `precedence` and `href` props are required to opt the `<style>` element into React 19's stylesheet
|
|
35
|
+
// hoisting; `href` here serves as a unique identifier, and doesn't have to be a valid URL; React
|
|
36
|
+
// converts it to a `data-href` attribute in the actual HTML output
|
|
37
|
+
/* @__PURE__ */ jsx("style", { href: styleTagId, precedence: styleTagId, children: css })
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
export {
|
|
41
|
+
InjectServerCSS,
|
|
42
|
+
ServerCSSCollector,
|
|
43
|
+
createCollectingServerStylesheet
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=server-css.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/runtimes/react/server/css/server-css.tsx"],"sourcesContent":["import { type Breakpoints, type Stylesheet } from '@makeswift/controls'\n\nimport { StylesheetEngine, MAKESWIFT_RSC_STYLE_TAG_ID_PREFIX } from './css-runtime'\n\nexport class ServerCSSCollector {\n private styles = new Map<string, string>()\n\n collect(className: string, css: string) {\n if (this.styles.has(className)) return\n this.styles.set(className, css)\n }\n\n hasStyles(): boolean {\n return this.styles.size > 0\n }\n\n getAllStyles(): string {\n return Array.from(this.styles.values()).join('\\n')\n }\n\n clear() {\n this.styles.clear()\n }\n}\n\nexport function createCollectingServerStylesheet(\n collector: ServerCSSCollector,\n breakpoints: Breakpoints,\n elementKey?: string,\n): Stylesheet {\n return new StylesheetEngine(breakpoints, elementKey, undefined, (className, css) => {\n collector.collect(className, css)\n })\n}\n\nexport function InjectServerCSS({\n collector,\n elementKey,\n}: {\n collector: ServerCSSCollector\n elementKey: string\n}) {\n if (!collector.hasStyles()) return null\n\n const css = collector.getAllStyles()\n const styleTagId = `${MAKESWIFT_RSC_STYLE_TAG_ID_PREFIX}${elementKey}`\n\n return (\n // `precedence` and `href` props are required to opt the `<style>` element into React 19's stylesheet\n // hoisting; `href` here serves as a unique identifier, and doesn't have to be a valid URL; React\n // converts it to a `data-href` attribute in the actual HTML output\n <style href={styleTagId} precedence={styleTagId}>\n {css}\n </style>\n )\n}\n"],"mappings":"AAmDI;AAjDJ,SAAS,kBAAkB,yCAAyC;AAE7D,MAAM,mBAAmB;AAAA,EACtB,SAAS,oBAAI,IAAoB;AAAA,EAEzC,QAAQ,WAAmB,KAAa;AACtC,QAAI,KAAK,OAAO,IAAI,SAAS;AAAG;AAChC,SAAK,OAAO,IAAI,WAAW,GAAG;AAAA,EAChC;AAAA,EAEA,YAAqB;AACnB,WAAO,KAAK,OAAO,OAAO;AAAA,EAC5B;AAAA,EAEA,eAAuB;AACrB,WAAO,MAAM,KAAK,KAAK,OAAO,OAAO,CAAC,EAAE,KAAK,IAAI;AAAA,EACnD;AAAA,EAEA,QAAQ;AACN,SAAK,OAAO,MAAM;AAAA,EACpB;AACF;AAEO,SAAS,iCACd,WACA,aACA,YACY;AACZ,SAAO,IAAI,iBAAiB,aAAa,YAAY,QAAW,CAAC,WAAW,QAAQ;AAClF,cAAU,QAAQ,WAAW,GAAG;AAAA,EAClC,CAAC;AACH;AAEO,SAAS,gBAAgB;AAAA,EAC9B;AAAA,EACA;AACF,GAGG;AACD,MAAI,CAAC,UAAU,UAAU;AAAG,WAAO;AAEnC,QAAM,MAAM,UAAU,aAAa;AACnC,QAAM,aAAa,GAAG,iCAAiC,GAAG,UAAU;AAEpE;AAAA;AAAA;AAAA;AAAA,IAIE,oBAAC,WAAM,MAAM,YAAY,YAAY,YAClC,eACH;AAAA;AAEJ;","names":[]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ServerElement } from "./components/element";
|
|
2
|
+
import { MakeswiftComponent } from "./components/makeswift-component";
|
|
3
|
+
import { Slot } from "./components/slot";
|
|
4
|
+
import { RSCElementRenderer } from "./components/renderer";
|
|
5
|
+
import { ServerCSSCollector } from "./css/server-css";
|
|
6
|
+
import {
|
|
7
|
+
RenderContext,
|
|
8
|
+
setRenderContext,
|
|
9
|
+
getRenderContext
|
|
10
|
+
} from "./render-context";
|
|
11
|
+
import { RenderElementPayload } from "./render-element-payload";
|
|
12
|
+
export {
|
|
13
|
+
MakeswiftComponent,
|
|
14
|
+
RSCElementRenderer,
|
|
15
|
+
RenderContext,
|
|
16
|
+
RenderElementPayload,
|
|
17
|
+
ServerCSSCollector,
|
|
18
|
+
ServerElement,
|
|
19
|
+
Slot,
|
|
20
|
+
getRenderContext,
|
|
21
|
+
setRenderContext
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/server/index.ts"],"sourcesContent":["export { ServerElement } from './components/element'\nexport { MakeswiftComponent } from './components/makeswift-component'\nexport { Slot } from './components/slot'\nexport { RSCElementRenderer } from './components/renderer'\nexport { ServerCSSCollector } from './css/server-css'\nexport {\n type ServerRenderContext,\n RenderContext,\n setRenderContext,\n getRenderContext,\n} from './render-context'\nexport { RenderElementPayload } from './render-element-payload'\n"],"mappings":"AAAA,SAAS,qBAAqB;AAC9B,SAAS,0BAA0B;AACnC,SAAS,YAAY;AACrB,SAAS,0BAA0B;AACnC,SAAS,0BAA0B;AACnC;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,4BAA4B;","names":[]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { cache } from "react";
|
|
2
|
+
const requestContext = cache(() => ({}));
|
|
3
|
+
const setRenderContext = (context) => {
|
|
4
|
+
requestContext().current = context;
|
|
5
|
+
};
|
|
6
|
+
const getRenderContext = () => {
|
|
7
|
+
const context = requestContext().current;
|
|
8
|
+
if (!context)
|
|
9
|
+
throw Error("Makeswift render context was not set.");
|
|
10
|
+
return context;
|
|
11
|
+
};
|
|
12
|
+
const getStore = ({ runtime, siteVersion, locale }) => {
|
|
13
|
+
if (runtime.requestKey == null) {
|
|
14
|
+
throw Error("Expected a runtime instance that is bound to a specific request key");
|
|
15
|
+
}
|
|
16
|
+
return runtime.getOrCreateStore({ siteVersion, locale });
|
|
17
|
+
};
|
|
18
|
+
const RenderContext = ({
|
|
19
|
+
context,
|
|
20
|
+
children
|
|
21
|
+
}) => {
|
|
22
|
+
setRenderContext(context);
|
|
23
|
+
return children;
|
|
24
|
+
};
|
|
25
|
+
export {
|
|
26
|
+
RenderContext,
|
|
27
|
+
getRenderContext,
|
|
28
|
+
getStore,
|
|
29
|
+
setRenderContext
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=render-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/server/render-context.tsx"],"sourcesContent":["import { cache, type PropsWithChildren } from 'react'\n\nimport { ReactRuntime } from '../../react/react-runtime'\nimport { type Store } from '../../../state/store'\n\nimport { type SiteVersion } from '../../../api/site-version'\nimport { MakeswiftClient } from '../../../client'\n\n/**\n * Request-scoped dependencies used to render Makeswift server elements.\n *\n * Framework integrations create a context for each request and install it with\n * `RenderContext` or `setRenderContext` so nested renderers can access it without\n * threading it through every component. The runtime must be request-bound;\n * together with `siteVersion` and `locale`, it selects the store and API resource\n * cache used during rendering.\n */\nexport type ServerRenderContext = {\n request: Request\n runtime: ReactRuntime\n client: MakeswiftClient\n siteVersion: SiteVersion | null\n locale: string | undefined\n}\n\nconst requestContext = cache((): { current?: ServerRenderContext } => ({}))\n\nexport const setRenderContext = (context: ServerRenderContext) => {\n requestContext().current = context\n}\n\nexport const getRenderContext = (): ServerRenderContext => {\n const context = requestContext().current\n if (!context) throw Error('Makeswift render context was not set.')\n return context\n}\n\nexport const getStore = ({ runtime, siteVersion, locale }: ServerRenderContext): Store => {\n if (runtime.requestKey == null) {\n throw Error('Expected a runtime instance that is bound to a specific request key')\n }\n\n return runtime.getOrCreateStore({ siteVersion, locale })\n}\n\nexport const RenderContext = ({\n context,\n children,\n}: PropsWithChildren<{ context: ServerRenderContext }>) => {\n setRenderContext(context)\n return children\n}\n"],"mappings":"AAAA,SAAS,aAAqC;AAyB9C,MAAM,iBAAiB,MAAM,OAA0C,CAAC,EAAE;AAEnE,MAAM,mBAAmB,CAAC,YAAiC;AAChE,iBAAe,EAAE,UAAU;AAC7B;AAEO,MAAM,mBAAmB,MAA2B;AACzD,QAAM,UAAU,eAAe,EAAE;AACjC,MAAI,CAAC;AAAS,UAAM,MAAM,uCAAuC;AACjE,SAAO;AACT;AAEO,MAAM,WAAW,CAAC,EAAE,SAAS,aAAa,OAAO,MAAkC;AACxF,MAAI,QAAQ,cAAc,MAAM;AAC9B,UAAM,MAAM,qEAAqE;AAAA,EACnF;AAEA,SAAO,QAAQ,iBAAiB,EAAE,aAAa,OAAO,CAAC;AACzD;AAEO,MAAM,gBAAgB,CAAC;AAAA,EAC5B;AAAA,EACA;AACF,MAA2D;AACzD,mBAAiB,OAAO;AACxB,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { Schema } from "@makeswift/controls";
|
|
3
|
+
const documentContext = z.object({
|
|
4
|
+
key: z.string(),
|
|
5
|
+
locale: z.string().optional()
|
|
6
|
+
});
|
|
7
|
+
const cacheData = z.object({
|
|
8
|
+
apiResources: z.custom(),
|
|
9
|
+
localizedResourcesMap: z.custom()
|
|
10
|
+
});
|
|
11
|
+
const RenderElementPayload = {
|
|
12
|
+
schema: z.object({
|
|
13
|
+
elementData: Schema.elementData,
|
|
14
|
+
cacheData,
|
|
15
|
+
documentContext
|
|
16
|
+
})
|
|
17
|
+
};
|
|
18
|
+
export {
|
|
19
|
+
RenderElementPayload
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=render-element-payload.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/server/render-element-payload.ts"],"sourcesContent":["import { z } from 'zod'\n\nimport { Schema } from '@makeswift/controls'\n\nimport { type CacheData } from '../../../api/api-resources-client'\n\nconst documentContext = z.object({\n key: z.string(),\n locale: z.string().optional(),\n})\n\nconst cacheData = z.object({\n apiResources: z.custom<CacheData['apiResources']>(),\n localizedResourcesMap: z.custom<CacheData['localizedResourcesMap']>(),\n})\n\n/**\n * Client-to-server payload for rendering a single server element\n */\nexport const RenderElementPayload = {\n schema: z.object({\n elementData: Schema.elementData,\n cacheData,\n documentContext,\n }),\n}\n\nexport type RenderElementPayload = z.infer<typeof RenderElementPayload.schema>\n"],"mappings":"AAAA,SAAS,SAAS;AAElB,SAAS,cAAc;AAIvB,MAAM,kBAAkB,EAAE,OAAO;AAAA,EAC/B,KAAK,EAAE,OAAO;AAAA,EACd,QAAQ,EAAE,OAAO,EAAE,SAAS;AAC9B,CAAC;AAED,MAAM,YAAY,EAAE,OAAO;AAAA,EACzB,cAAc,EAAE,OAAkC;AAAA,EAClD,uBAAuB,EAAE,OAA2C;AACtE,CAAC;AAKM,MAAM,uBAAuB;AAAA,EAClC,QAAQ,EAAE,OAAO;AAAA,IACf,aAAa,OAAO;AAAA,IACpB;AAAA,IACA;AAAA,EACF,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { mapValues } from "@makeswift/controls";
|
|
2
|
+
import { serverResourceResolver } from "./resource-resolver";
|
|
3
|
+
import { propErrorHandlingProxy } from "../utils/prop-error-handling-proxy";
|
|
4
|
+
async function resolveProps(context, element, documentKey, propDefs, stylesheet) {
|
|
5
|
+
const resourceResolver = serverResourceResolver({ ...context, documentKey });
|
|
6
|
+
const resolveProp = (def, propName) => {
|
|
7
|
+
const data = element.props[propName];
|
|
8
|
+
const control = def.createInstance({
|
|
9
|
+
// these are top-level controls, so passing `propName` for `propPath` is appropriate
|
|
10
|
+
instanceKey: { elementKey: element.key, propPath: propName },
|
|
11
|
+
sendMessage: () => {
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
return def.resolveValue(data, resourceResolver, stylesheet.child(propName), control);
|
|
15
|
+
};
|
|
16
|
+
const resolvables = mapValues(propDefs, (def, propName) => {
|
|
17
|
+
const defaultValue = def.config?.defaultValue;
|
|
18
|
+
return propErrorHandlingProxy(resolveProp(def, propName), defaultValue, (error) => {
|
|
19
|
+
console.warn(
|
|
20
|
+
`Error reading value for prop "${propName}", falling back to \`${defaultValue}\`.`,
|
|
21
|
+
{ control: def, error }
|
|
22
|
+
);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
await Promise.all(Object.entries(resolvables).map(([_, sub]) => sub.triggerResolve()));
|
|
26
|
+
return Object.entries(resolvables).reduce(
|
|
27
|
+
(result, [propName, subscription]) => ({ ...result, [propName]: subscription.readStable() }),
|
|
28
|
+
{}
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
export {
|
|
32
|
+
resolveProps
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=resolve-props.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/server/resolve-props.ts"],"sourcesContent":["import { type ElementData, ControlDefinition, mapValues, Stylesheet } from '@makeswift/controls'\n\nimport { type ServerRenderContext } from './render-context'\nimport { serverResourceResolver } from './resource-resolver'\n\nimport { propErrorHandlingProxy } from '../utils/prop-error-handling-proxy'\n\n/**\n * Server-side counterpart of the `useResolvedProps` hook.\n */\nexport async function resolveProps(\n context: ServerRenderContext,\n element: ElementData,\n documentKey: string,\n propDefs: Record<string, ControlDefinition>,\n stylesheet: Stylesheet,\n): Promise<Record<string, unknown>> {\n const resourceResolver = serverResourceResolver({ ...context, documentKey })\n\n const resolveProp = (def: ControlDefinition, propName: string) => {\n const data = element.props[propName]\n\n // Create a \"placeholder\" control instance so that controls that resolve to\n // React nodes can use `instanceKey` to reconstruct themselves on the client\n // (see `react/controls/slot/render-slot.tsx`).\n const control = def.createInstance({\n // these are top-level controls, so passing `propName` for `propPath` is appropriate\n instanceKey: { elementKey: element.key, propPath: propName },\n sendMessage: () => {},\n })\n\n return def.resolveValue(data, resourceResolver, stylesheet.child(propName), control)\n }\n\n const resolvables = mapValues(propDefs, (def, propName) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const defaultValue = (def.config as any)?.defaultValue\n return propErrorHandlingProxy(resolveProp(def, propName), defaultValue, error => {\n console.warn(\n `Error reading value for prop \"${propName}\", falling back to \\`${defaultValue}\\`.`,\n { control: def, error },\n )\n })\n })\n\n // wait for side-effects (resource fetching, updating list child controls)\n await Promise.all(Object.entries(resolvables).map(([_, sub]) => sub.triggerResolve()))\n\n return Object.entries(resolvables).reduce<Record<string, unknown>>(\n (result, [propName, subscription]) => ({ ...result, [propName]: subscription.readStable() }),\n {},\n )\n}\n"],"mappings":"AAAA,SAA8C,iBAA6B;AAG3E,SAAS,8BAA8B;AAEvC,SAAS,8BAA8B;AAKvC,eAAsB,aACpB,SACA,SACA,aACA,UACA,YACkC;AAClC,QAAM,mBAAmB,uBAAuB,EAAE,GAAG,SAAS,YAAY,CAAC;AAE3E,QAAM,cAAc,CAAC,KAAwB,aAAqB;AAChE,UAAM,OAAO,QAAQ,MAAM,QAAQ;AAKnC,UAAM,UAAU,IAAI,eAAe;AAAA;AAAA,MAEjC,aAAa,EAAE,YAAY,QAAQ,KAAK,UAAU,SAAS;AAAA,MAC3D,aAAa,MAAM;AAAA,MAAC;AAAA,IACtB,CAAC;AAED,WAAO,IAAI,aAAa,MAAM,kBAAkB,WAAW,MAAM,QAAQ,GAAG,OAAO;AAAA,EACrF;AAEA,QAAM,cAAc,UAAU,UAAU,CAAC,KAAK,aAAa;AAEzD,UAAM,eAAgB,IAAI,QAAgB;AAC1C,WAAO,uBAAuB,YAAY,KAAK,QAAQ,GAAG,cAAc,WAAS;AAC/E,cAAQ;AAAA,QACN,iCAAiC,QAAQ,wBAAwB,YAAY;AAAA,QAC7E,EAAE,SAAS,KAAK,MAAM;AAAA,MACxB;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AAGD,QAAM,QAAQ,IAAI,OAAO,QAAQ,WAAW,EAAE,IAAI,CAAC,CAAC,GAAG,GAAG,MAAM,IAAI,eAAe,CAAC,CAAC;AAErF,SAAO,OAAO,QAAQ,WAAW,EAAE;AAAA,IACjC,CAAC,QAAQ,CAAC,UAAU,YAAY,OAAO,EAAE,GAAG,QAAQ,CAAC,QAAQ,GAAG,aAAa,WAAW,EAAE;AAAA,IAC1F,CAAC;AAAA,EACH;AACF;","names":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createResourceResolver } from "../resource-resolver";
|
|
2
|
+
import { getStore } from "./render-context";
|
|
3
|
+
function serverResourceResolver(context) {
|
|
4
|
+
const store = getStore(context);
|
|
5
|
+
const apiClient = store.apiResourcesClient;
|
|
6
|
+
return createResourceResolver({
|
|
7
|
+
store,
|
|
8
|
+
apiClient,
|
|
9
|
+
documentKey: context.documentKey,
|
|
10
|
+
locale: context.locale ?? null
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
export {
|
|
14
|
+
serverResourceResolver
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=resource-resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/server/resource-resolver.ts"],"sourcesContent":["import { type ResourceResolver, createResourceResolver } from '../resource-resolver'\n\nimport { type ServerRenderContext, getStore } from './render-context'\n\nexport function serverResourceResolver(\n context: ServerRenderContext & { documentKey: string },\n): ResourceResolver {\n const store = getStore(context)\n const apiClient = store.apiResourcesClient\n\n return createResourceResolver({\n store,\n apiClient,\n documentKey: context.documentKey,\n locale: context.locale ?? null,\n })\n}\n"],"mappings":"AAAA,SAAgC,8BAA8B;AAE9D,SAAmC,gBAAgB;AAE5C,SAAS,uBACd,SACkB;AAClB,QAAM,QAAQ,SAAS,OAAO;AAC9B,QAAM,YAAY,MAAM;AAExB,SAAO,uBAAuB;AAAA,IAC5B;AAAA,IACA;AAAA,IACA,aAAa,QAAQ;AAAA,IACrB,QAAQ,QAAQ,UAAU;AAAA,EAC5B,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { updateAPIClientCache } from "../../../state/actions/internal/read-write-actions";
|
|
2
|
+
function updateApiResourceCache(store, cacheData) {
|
|
3
|
+
store.apiResourcesClient.store.dispatch(updateAPIClientCache(cacheData));
|
|
4
|
+
}
|
|
5
|
+
export {
|
|
6
|
+
updateApiResourceCache
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=update-api-resource-cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/server/update-api-resource-cache.ts"],"sourcesContent":["import { type CacheData } from '../../../api/api-resources-client'\n\nimport { updateAPIClientCache } from '../../../state/actions/internal/read-write-actions'\n\nimport { type Store } from '../../../state/store'\n\nexport function updateApiResourceCache(store: Store, cacheData: CacheData) {\n store.apiResourcesClient.store.dispatch(updateAPIClientCache(cacheData))\n}\n"],"mappings":"AAEA,SAAS,4BAA4B;AAI9B,SAAS,uBAAuB,OAAc,WAAsB;AACzE,QAAM,mBAAmB,MAAM,SAAS,qBAAqB,SAAS,CAAC;AACzE;","names":[]}
|
|
@@ -1,11 +1,28 @@
|
|
|
1
1
|
import { TestOrigins } from "../../../testing/fixtures";
|
|
2
2
|
import { ReactRuntime } from "../react-runtime";
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
class TestReactRuntime extends ReactRuntime {
|
|
4
|
+
env;
|
|
5
|
+
constructor({
|
|
6
|
+
env,
|
|
7
|
+
...args
|
|
8
|
+
}) {
|
|
9
|
+
super(args);
|
|
10
|
+
this.env = env ?? "client";
|
|
11
|
+
}
|
|
12
|
+
isRSCEnv() {
|
|
13
|
+
return this.env === "rsc";
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function createReactRuntime({
|
|
17
|
+
breakpoints,
|
|
18
|
+
env
|
|
19
|
+
} = {}) {
|
|
20
|
+
return new TestReactRuntime({
|
|
5
21
|
// Mock Service Worker patches global `fetch` for interception; make sure our test calls go
|
|
6
22
|
// through the patched version instead of an eagerly captured reference to the original
|
|
7
23
|
fetch: (...args) => globalThis.fetch(...args),
|
|
8
24
|
breakpoints,
|
|
25
|
+
env,
|
|
9
26
|
...TestOrigins
|
|
10
27
|
});
|
|
11
28
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/runtimes/react/testing/react-runtime.tsx"],"sourcesContent":["import { type BreakpointsInput } from '../../../state/modules/breakpoints'\nimport { TestOrigins } from '../../../testing/fixtures'\nimport { ReactRuntime } from '../react-runtime'\n\nexport function createReactRuntime({
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/testing/react-runtime.tsx"],"sourcesContent":["import { type BreakpointsInput } from '../../../state/modules/breakpoints'\nimport { TestOrigins } from '../../../testing/fixtures'\nimport { ReactRuntime } from '../react-runtime'\n\ntype RuntimeEnv = 'client' | 'ssr' | 'rsc'\n\nclass TestReactRuntime extends ReactRuntime {\n readonly env: RuntimeEnv\n\n constructor({\n env,\n ...args\n }: ConstructorParameters<typeof ReactRuntime>[0] & { env?: RuntimeEnv }) {\n super(args)\n this.env = env ?? 'client'\n }\n\n protected isRSCEnv() {\n return this.env === 'rsc'\n }\n}\n\nexport function createReactRuntime({\n breakpoints,\n env,\n}: { breakpoints?: BreakpointsInput; env?: RuntimeEnv } = {}) {\n return new TestReactRuntime({\n // Mock Service Worker patches global `fetch` for interception; make sure our test calls go\n // through the patched version instead of an eagerly captured reference to the original\n fetch: (...args) => globalThis.fetch(...args),\n breakpoints,\n env,\n ...TestOrigins,\n })\n}\n"],"mappings":"AACA,SAAS,mBAAmB;AAC5B,SAAS,oBAAoB;AAI7B,MAAM,yBAAyB,aAAa;AAAA,EACjC;AAAA,EAET,YAAY;AAAA,IACV;AAAA,IACA,GAAG;AAAA,EACL,GAAyE;AACvE,UAAM,IAAI;AACV,SAAK,MAAM,OAAO;AAAA,EACpB;AAAA,EAEU,WAAW;AACnB,WAAO,KAAK,QAAQ;AAAA,EACtB;AACF;AAEO,SAAS,mBAAmB;AAAA,EACjC;AAAA,EACA;AACF,IAA0D,CAAC,GAAG;AAC5D,SAAO,IAAI,iBAAiB;AAAA;AAAA;AAAA,IAG1B,OAAO,IAAI,SAAS,WAAW,MAAM,GAAG,IAAI;AAAA,IAC5C;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,CAAC;AACH;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/state/modules/components-meta.ts"],"sourcesContent":["import { type Action, type UnknownAction, isKnownAction } from '../actions'\nimport { ReadOnlyActionTypes } from '../actions/internal/read-only-action-types'\n\nexport const ComponentIcon = {\n Accordion: 'accordion',\n Audio: 'audio',\n Billing: 'billing',\n Bolt: 'bolt',\n Button: 'button',\n Card: 'card',\n Cards: 'cards',\n Carousel: 'carousel',\n Chats: 'chats',\n Code: 'code',\n Countdown: 'countdown',\n Cube: 'cube',\n Database: 'database',\n Divider: 'divider',\n Form: 'form',\n Gallery: 'gallery',\n Grid: 'grid',\n Help: 'help',\n Image: 'image',\n Layout: 'layout',\n Lock: 'lock',\n Marker: 'marker',\n Navigation: 'navigation',\n Palette: 'palette',\n SocialLinks: 'social-links',\n Star: 'star',\n Table: 'table',\n Tabs: 'tabs',\n Text: 'text',\n Users: 'users',\n Video: 'video',\n} as const\n\nexport type ComponentIcon = (typeof ComponentIcon)[keyof typeof ComponentIcon]\n\nexport type ComponentMeta = {\n label: string\n icon: ComponentIcon\n hidden: boolean\n description?: string\n builtinSuspense?: boolean\n unstable_migration?: {\n replacementType: string\n }\n}\n\nexport type State = Map<string, ComponentMeta>\n\nexport function getInitialState({\n componentsMeta = new Map(),\n}: { componentsMeta?: Map<string, ComponentMeta> } = {}): State {\n return componentsMeta\n}\n\nexport function getComponentsMeta(state: State): Map<string, ComponentMeta> {\n return state\n}\n\nexport function getComponentMeta(state: State, type: string): ComponentMeta | null {\n return getComponentsMeta(state).get(type) ?? null\n}\n\nexport function reducer(state: State = getInitialState(), action: Action | UnknownAction): State {\n if (!isKnownAction(action)) return state\n\n switch (action.type) {\n case ReadOnlyActionTypes.REGISTER_COMPONENT:\n return new Map(state).set(action.payload.type, action.payload.meta)\n\n case ReadOnlyActionTypes.UNREGISTER_COMPONENT: {\n const nextState = new Map(state)\n\n const deleted = nextState.delete(action.payload.type)\n\n return deleted ? nextState : state\n }\n\n default:\n return state\n }\n}\n"],"mappings":"AAAA,SAA0C,qBAAqB;AAC/D,SAAS,2BAA2B;AAE7B,MAAM,gBAAgB;AAAA,EAC3B,WAAW;AAAA,EACX,OAAO;AAAA,EACP,SAAS;AAAA,EACT,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,OAAO;AAAA,EACP,UAAU;AAAA,EACV,OAAO;AAAA,EACP,MAAM;AAAA,EACN,WAAW;AAAA,EACX,MAAM;AAAA,EACN,UAAU;AAAA,EACV,SAAS;AAAA,EACT,MAAM;AAAA,EACN,SAAS;AAAA,EACT,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,SAAS;AAAA,EACT,aAAa;AAAA,EACb,MAAM;AAAA,EACN,OAAO;AAAA,EACP,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AAAA,EACP,OAAO;AACT;
|
|
1
|
+
{"version":3,"sources":["../../../../src/state/modules/components-meta.ts"],"sourcesContent":["import { type Action, type UnknownAction, isKnownAction } from '../actions'\nimport { ReadOnlyActionTypes } from '../actions/internal/read-only-action-types'\n\nexport const ComponentIcon = {\n Accordion: 'accordion',\n Audio: 'audio',\n Billing: 'billing',\n Bolt: 'bolt',\n Button: 'button',\n Card: 'card',\n Cards: 'cards',\n Carousel: 'carousel',\n Chats: 'chats',\n Code: 'code',\n Countdown: 'countdown',\n Cube: 'cube',\n Database: 'database',\n Divider: 'divider',\n Form: 'form',\n Gallery: 'gallery',\n Grid: 'grid',\n Help: 'help',\n Image: 'image',\n Layout: 'layout',\n Lock: 'lock',\n Marker: 'marker',\n Navigation: 'navigation',\n Palette: 'palette',\n SocialLinks: 'social-links',\n Star: 'star',\n Table: 'table',\n Tabs: 'tabs',\n Text: 'text',\n Users: 'users',\n Video: 'video',\n} as const\n\nexport type ComponentIcon = (typeof ComponentIcon)[keyof typeof ComponentIcon]\n\nexport type ComponentMeta = {\n label: string\n icon: ComponentIcon\n hidden: boolean\n description?: string\n builtinSuspense?: boolean\n unstable_migration?: {\n replacementType: string\n }\n server?: boolean\n}\n\nexport type State = Map<string, ComponentMeta>\n\nexport function getInitialState({\n componentsMeta = new Map(),\n}: { componentsMeta?: Map<string, ComponentMeta> } = {}): State {\n return componentsMeta\n}\n\nexport function getComponentsMeta(state: State): Map<string, ComponentMeta> {\n return state\n}\n\nexport function getComponentMeta(state: State, type: string): ComponentMeta | null {\n return getComponentsMeta(state).get(type) ?? null\n}\n\nexport function reducer(state: State = getInitialState(), action: Action | UnknownAction): State {\n if (!isKnownAction(action)) return state\n\n switch (action.type) {\n case ReadOnlyActionTypes.REGISTER_COMPONENT:\n return new Map(state).set(action.payload.type, action.payload.meta)\n\n case ReadOnlyActionTypes.UNREGISTER_COMPONENT: {\n const nextState = new Map(state)\n\n const deleted = nextState.delete(action.payload.type)\n\n return deleted ? nextState : state\n }\n\n default:\n return state\n }\n}\n"],"mappings":"AAAA,SAA0C,qBAAqB;AAC/D,SAAS,2BAA2B;AAE7B,MAAM,gBAAgB;AAAA,EAC3B,WAAW;AAAA,EACX,OAAO;AAAA,EACP,SAAS;AAAA,EACT,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,OAAO;AAAA,EACP,UAAU;AAAA,EACV,OAAO;AAAA,EACP,MAAM;AAAA,EACN,WAAW;AAAA,EACX,MAAM;AAAA,EACN,UAAU;AAAA,EACV,SAAS;AAAA,EACT,MAAM;AAAA,EACN,SAAS;AAAA,EACT,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,SAAS;AAAA,EACT,aAAa;AAAA,EACb,MAAM;AAAA,EACN,OAAO;AAAA,EACP,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AAAA,EACP,OAAO;AACT;AAkBO,SAAS,gBAAgB;AAAA,EAC9B,iBAAiB,oBAAI,IAAI;AAC3B,IAAqD,CAAC,GAAU;AAC9D,SAAO;AACT;AAEO,SAAS,kBAAkB,OAA0C;AAC1E,SAAO;AACT;AAEO,SAAS,iBAAiB,OAAc,MAAoC;AACjF,SAAO,kBAAkB,KAAK,EAAE,IAAI,IAAI,KAAK;AAC/C;AAEO,SAAS,QAAQ,QAAe,gBAAgB,GAAG,QAAuC;AAC/F,MAAI,CAAC,cAAc,MAAM;AAAG,WAAO;AAEnC,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK,oBAAoB;AACvB,aAAO,IAAI,IAAI,KAAK,EAAE,IAAI,OAAO,QAAQ,MAAM,OAAO,QAAQ,IAAI;AAAA,IAEpE,KAAK,oBAAoB,sBAAsB;AAC7C,YAAM,YAAY,IAAI,IAAI,KAAK;AAE/B,YAAM,UAAU,UAAU,OAAO,OAAO,QAAQ,IAAI;AAEpD,aAAO,UAAU,YAAY;AAAA,IAC/B;AAAA,IAEA;AACE,aAAO;AAAA,EACX;AACF;","names":[]}
|
|
@@ -18,6 +18,7 @@ import { MakeswiftComponent } from "../runtimes/react/components/MakeswiftCompon
|
|
|
18
18
|
import { Page } from "../runtimes/react/components/page";
|
|
19
19
|
import { RuntimeProvider } from "../runtimes/react/components/RuntimeProvider";
|
|
20
20
|
import { Slot } from "../runtimes/react/components/Slot";
|
|
21
|
+
import { RenderElementPayload } from "../runtimes/react/server/render-element-payload";
|
|
21
22
|
import { GoogleFontLink } from "../runtimes/react/components/GoogleFontLink";
|
|
22
23
|
import { MakeswiftFonts } from "../runtimes/react/components/MakeswiftFonts";
|
|
23
24
|
import {
|
|
@@ -39,6 +40,7 @@ export {
|
|
|
39
40
|
Page,
|
|
40
41
|
REDIRECT_SEARCH_PARAM,
|
|
41
42
|
ReactRuntime,
|
|
43
|
+
RenderElementPayload,
|
|
42
44
|
RootStyleRegistry,
|
|
43
45
|
RuntimeProvider,
|
|
44
46
|
SET_COOKIE_HEADER,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/unstable-framework-support/index.ts"],"sourcesContent":["export {\n type SiteVersion,\n serializeSiteVersion,\n deserializeSiteVersion,\n secondsUntilSiteVersionExpiration,\n} from '../api/site-version'\n\nexport {\n type ApiHandlerUserConfig,\n createApiHandler,\n type SitePublishedWebhookPayloadData,\n} from '../api-handler'\nexport { SET_COOKIE_HEADER, cookieSettingOptions } from '../api-handler/cookies'\nexport { REDIRECT_SEARCH_PARAM, redirectLiveHandler } from '../api-handler/handlers/redirect-live'\nexport { toApiRequest, pipeResponseTo } from '../api-handler/node-request-response'\nexport { MAKESWIFT_SITE_VERSION_COOKIE, SearchParams } from '../api-handler/preview'\n\nexport { MakeswiftClient } from '../client'\n\nexport { type BreakpointsInput as Breakpoints } from '../state/modules/breakpoints'\n\nexport {\n type FrameworkContext,\n FrameworkContextProvider,\n} from '../runtimes/react/components/framework-context'\n\nexport { MakeswiftComponent } from '../runtimes/react/components/MakeswiftComponent'\nexport { Page } from '../runtimes/react/components/page'\nexport { RuntimeProvider } from '../runtimes/react/components/RuntimeProvider'\nexport { Slot } from '../runtimes/react/components/Slot'\n\nexport { GoogleFontLink } from '../runtimes/react/components/GoogleFontLink'\nexport { MakeswiftFonts } from '../runtimes/react/components/MakeswiftFonts'\n\nexport {\n createRootStyleCache,\n RootStyleRegistry,\n DefaultRootStyleRegistry,\n styleTagHtml,\n StyleTagSSR,\n type RootStyleProps,\n} from '../runtimes/react/root-style-registry'\n\nexport { ReactRuntime, type StoreKey } from '../runtimes/react/react-runtime'\n"],"mappings":"AAAA;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP;AAAA,EAEE;AAAA,OAEK;AACP,SAAS,mBAAmB,4BAA4B;AACxD,SAAS,uBAAuB,2BAA2B;AAC3D,SAAS,cAAc,sBAAsB;AAC7C,SAAS,+BAA+B,oBAAoB;AAE5D,SAAS,uBAAuB;AAIhC;AAAA,EAEE;AAAA,OACK;AAEP,SAAS,0BAA0B;AACnC,SAAS,YAAY;AACrB,SAAS,uBAAuB;AAChC,SAAS,YAAY;
|
|
1
|
+
{"version":3,"sources":["../../../src/unstable-framework-support/index.ts"],"sourcesContent":["export {\n type SiteVersion,\n serializeSiteVersion,\n deserializeSiteVersion,\n secondsUntilSiteVersionExpiration,\n} from '../api/site-version'\n\nexport {\n type ApiHandlerUserConfig,\n createApiHandler,\n type SitePublishedWebhookPayloadData,\n} from '../api-handler'\nexport { SET_COOKIE_HEADER, cookieSettingOptions } from '../api-handler/cookies'\nexport { REDIRECT_SEARCH_PARAM, redirectLiveHandler } from '../api-handler/handlers/redirect-live'\nexport { toApiRequest, pipeResponseTo } from '../api-handler/node-request-response'\nexport { MAKESWIFT_SITE_VERSION_COOKIE, SearchParams } from '../api-handler/preview'\n\nexport { MakeswiftClient } from '../client'\n\nexport { type BreakpointsInput as Breakpoints } from '../state/modules/breakpoints'\n\nexport {\n type FrameworkContext,\n FrameworkContextProvider,\n} from '../runtimes/react/components/framework-context'\n\nexport { MakeswiftComponent } from '../runtimes/react/components/MakeswiftComponent'\nexport { Page } from '../runtimes/react/components/page'\nexport { RuntimeProvider } from '../runtimes/react/components/RuntimeProvider'\nexport { Slot } from '../runtimes/react/components/Slot'\nexport { RenderElementPayload } from '../runtimes/react/server/render-element-payload'\n\nexport { GoogleFontLink } from '../runtimes/react/components/GoogleFontLink'\nexport { MakeswiftFonts } from '../runtimes/react/components/MakeswiftFonts'\n\nexport {\n createRootStyleCache,\n RootStyleRegistry,\n DefaultRootStyleRegistry,\n styleTagHtml,\n StyleTagSSR,\n type RootStyleProps,\n} from '../runtimes/react/root-style-registry'\n\nexport { ReactRuntime, type StoreKey } from '../runtimes/react/react-runtime'\n"],"mappings":"AAAA;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP;AAAA,EAEE;AAAA,OAEK;AACP,SAAS,mBAAmB,4BAA4B;AACxD,SAAS,uBAAuB,2BAA2B;AAC3D,SAAS,cAAc,sBAAsB;AAC7C,SAAS,+BAA+B,oBAAoB;AAE5D,SAAS,uBAAuB;AAIhC;AAAA,EAEE;AAAA,OACK;AAEP,SAAS,0BAA0B;AACnC,SAAS,YAAY;AACrB,SAAS,uBAAuB;AAChC,SAAS,YAAY;AACrB,SAAS,4BAA4B;AAErC,SAAS,sBAAsB;AAC/B,SAAS,sBAAsB;AAE/B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AAEP,SAAS,oBAAmC;","names":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const getPropByPath = (props, [key, ...path]) => {
|
|
2
|
+
const r = Array.isArray(props) ? props[Number.parseInt(key, 10)] : props[key];
|
|
3
|
+
return path.length > 0 && r != null ? getPropByPath(r, path) : r;
|
|
4
|
+
};
|
|
5
|
+
const getProp = (props, path) => getPropByPath(props, path.split("."));
|
|
6
|
+
export {
|
|
7
|
+
getProp,
|
|
8
|
+
getPropByPath
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=prop-by-path.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/prop-by-path.ts"],"sourcesContent":["export const getPropByPath = (\n props: Record<string, unknown> | Array<unknown>,\n [key, ...path]: string[],\n): unknown => {\n const r = Array.isArray(props) ? props[Number.parseInt(key, 10)] : props[key]\n return path.length > 0 && r != null ? getPropByPath(r as typeof props, path) : r\n}\n\nexport const getProp = (props: Record<string, unknown>, path: string): unknown =>\n getPropByPath(props, path.split('.'))\n"],"mappings":"AAAO,MAAM,gBAAgB,CAC3B,OACA,CAAC,KAAQ,OAAI,MACD;AACZ,QAAM,IAAI,MAAM,QAAQ,KAAK,IAAI,MAAM,OAAO,SAAS,KAAK,EAAE,CAAC,IAAI,MAAM,GAAG;AAC5E,SAAO,KAAK,SAAS,KAAK,KAAK,OAAO,cAAc,GAAmB,IAAI,IAAI;AACjF;AAEO,MAAM,UAAU,CAAC,OAAgC,SACtD,cAAc,OAAO,KAAK,MAAM,GAAG,CAAC;","names":[]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
const setUnion = (a, b) => Set.prototype.union != null ? a.union(b) : /* @__PURE__ */ new Set([...a, ...b.keys()]);
|
|
2
|
+
const setDifference = (a, b) => Set.prototype.difference != null ? a.difference(b) : new Set([...a].filter((value) => !b.has(value)));
|
|
3
|
+
export {
|
|
4
|
+
setDifference,
|
|
5
|
+
setUnion
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=set.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/set.ts"],"sourcesContent":["// Compatibility helpers for older browsers\n\n// See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/union\nexport const setUnion = <T>(a: Set<T>, b: Set<T>) =>\n Set.prototype.union != null ? a.union(b) : new Set([...a, ...b.keys()])\n\n// See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/difference\nexport const setDifference = <T>(a: Set<T>, b: Set<T>) =>\n Set.prototype.difference != null\n ? a.difference(b)\n : new Set([...a].filter(value => !b.has(value)))\n"],"mappings":"AAGO,MAAM,WAAW,CAAI,GAAW,MACrC,IAAI,UAAU,SAAS,OAAO,EAAE,MAAM,CAAC,IAAI,oBAAI,IAAI,CAAC,GAAG,GAAG,GAAG,EAAE,KAAK,CAAC,CAAC;AAGjE,MAAM,gBAAgB,CAAI,GAAW,MAC1C,IAAI,UAAU,cAAc,OACxB,EAAE,WAAW,CAAC,IACd,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE,OAAO,WAAS,CAAC,EAAE,IAAI,KAAK,CAAC,CAAC;","names":[]}
|
|
@@ -3,7 +3,7 @@ import { type ValueType, type DataType, ControlDefinition } from '@makeswift/con
|
|
|
3
3
|
import { type CacheData } from '../../../../api/api-resources-client';
|
|
4
4
|
import { ElementData } from '../../../../state/read-only-state';
|
|
5
5
|
import { ReactRuntime } from '../../../../runtimes/react/react-runtime';
|
|
6
|
-
export declare function testPageControlPropRendering<D extends ControlDefinition>(controlDefinition: D, { toData, value, locale, cacheData, expectedRenders, registerComponents, action, rootElements, isInBuilder, }: {
|
|
6
|
+
export declare function testPageControlPropRendering<D extends ControlDefinition>(controlDefinition: D, { toData, value, locale, cacheData, expectedRenders, registerComponents, action, rootElements, isInBuilder, isReadOnly, }: {
|
|
7
7
|
toData?: (value: ValueType<D>) => DataType<D>;
|
|
8
8
|
value: ValueType<D> | undefined;
|
|
9
9
|
locale?: string | null;
|
|
@@ -13,5 +13,6 @@ export declare function testPageControlPropRendering<D extends ControlDefinition
|
|
|
13
13
|
action?: (element: HTMLElement) => Promise<void>;
|
|
14
14
|
rootElements?: ElementData[];
|
|
15
15
|
isInBuilder?: boolean;
|
|
16
|
+
isReadOnly?: boolean;
|
|
16
17
|
}): Promise<void>;
|
|
17
18
|
//# sourceMappingURL=page-control-prop-rendering.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page-control-prop-rendering.d.ts","sourceRoot":"","sources":["../../../../../../src/next/components/tests/controls/page-control-prop-rendering.tsx"],"names":[],"mappings":"AAIA,OAAO,2BAA2B,CAAA;AAGlC,OAAO,EAAa,KAAK,SAAS,EAAE,KAAK,QAAQ,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAEjG,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,sCAAsC,CAAA;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAA;AAE/D,OAAO,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAA;
|
|
1
|
+
{"version":3,"file":"page-control-prop-rendering.d.ts","sourceRoot":"","sources":["../../../../../../src/next/components/tests/controls/page-control-prop-rendering.tsx"],"names":[],"mappings":"AAIA,OAAO,2BAA2B,CAAA;AAGlC,OAAO,EAAa,KAAK,SAAS,EAAE,KAAK,QAAQ,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAEjG,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,sCAAsC,CAAA;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAA;AAE/D,OAAO,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAA;AAsFvE,wBAAsB,4BAA4B,CAAC,CAAC,SAAS,iBAAiB,EAC5E,iBAAiB,EAAE,CAAC,EACpB,EACE,MAAM,EACN,KAAK,EACL,MAAM,EACN,SAAS,EACT,eAAe,EACf,kBAAkB,EAClB,MAAM,EACN,YAAiB,EACjB,WAAmB,EACnB,UAAiB,GAClB,EAAE;IACD,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAA;IAC7C,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,CAAA;IAC/B,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,SAAS,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,CAAA;IAC9B,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,kBAAkB,CAAC,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,IAAI,CAAA;IACpD,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IAChD,YAAY,CAAC,EAAE,WAAW,EAAE,CAAA;IAC5B,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB,iBAwGF"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { type ServerRenderContext, RenderElementPayload, RenderContext as MakeswiftRenderContext, setRenderContext, getRenderContext, ServerCSSCollector, ServerElement, RSCElementRenderer, MakeswiftComponent, Slot, } from '../../runtimes/react/server';
|
|
2
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/react/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,mBAAmB,EACxB,oBAAoB,EACpB,aAAa,IAAI,sBAAsB,EACvC,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,aAAa,EACb,kBAAkB,EAClB,kBAAkB,EAClB,IAAI,GACL,MAAM,6BAA6B,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ElementData as
|
|
1
|
+
import { type ElementData as MakeswiftElementData } from '../../../state/read-only-state';
|
|
2
2
|
type ElementDataProps = {
|
|
3
|
-
elementData:
|
|
3
|
+
elementData: MakeswiftElementData;
|
|
4
4
|
};
|
|
5
5
|
export declare const ElementData: import("react").NamedExoticComponent<ElementDataProps & import("react").RefAttributes<unknown>>;
|
|
6
6
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ElementData.d.ts","sourceRoot":"","sources":["../../../../../src/runtimes/react/components/ElementData.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,IAAI,oBAAoB,EAAE,MAAM,gCAAgC,CAAA;
|
|
1
|
+
{"version":3,"file":"ElementData.d.ts","sourceRoot":"","sources":["../../../../../src/runtimes/react/components/ElementData.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,WAAW,IAAI,oBAAoB,EAAE,MAAM,gCAAgC,CAAA;AAezF,KAAK,gBAAgB,GAAG;IACtB,WAAW,EAAE,oBAAoB,CAAA;CAClC,CAAA;AAED,eAAO,MAAM,WAAW,iGAsBvB,CAAA"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type ReactNode, type PropsWithChildren, type CSSProperties, type ComponentPropsWithoutRef, type MouseEvent, type ForwardRefExoticComponent, type RefAttributes } from 'react';
|
|
2
2
|
import { type LinkData } from '@makeswift/prop-controllers';
|
|
3
|
-
import { type Snippet } from '../../../client';
|
|
3
|
+
import { type Snippet } from '../../../client/page-snapshot';
|
|
4
|
+
import { type RenderElementPayload } from '../server/render-element-payload';
|
|
4
5
|
type HeadComponent = (props: {
|
|
5
6
|
children: ReactNode;
|
|
6
7
|
}) => ReactNode;
|
|
@@ -27,6 +28,10 @@ export type FrameworkContext = {
|
|
|
27
28
|
HeadSnippet: HeadSnippet;
|
|
28
29
|
Image: ImageComponent;
|
|
29
30
|
Link: LinkComponent;
|
|
31
|
+
/**
|
|
32
|
+
* Callback to render a single RSC element on the server and return the result.
|
|
33
|
+
*/
|
|
34
|
+
renderRSCElement?: (args: RenderElementPayload) => Promise<ReactNode>;
|
|
30
35
|
};
|
|
31
36
|
export declare const FrameworkContextProvider: ({ value, children, }: PropsWithChildren<{
|
|
32
37
|
value: Partial<FrameworkContext>;
|