@amplifyup/sdk 0.1.76 → 0.1.77
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/AmplifyRenderer.js +14 -16
- package/dist/AmplifyRenderer.js.map +1 -1
- package/dist/AmplifyRenderer.mjs +15 -17
- package/dist/AmplifyRenderer.mjs.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +3 -1
- package/dist/react.d.ts +3 -1
- package/dist/react.js +23 -23
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +24 -24
- package/dist/react.mjs.map +1 -1
- package/package.json +1 -1
package/dist/react.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import React3, { createContext, memo, useState, useEffect, Fragment as Fragment$1, useContext, useRef, Component,
|
|
2
|
+
import React3, { createContext, memo, useState, useEffect, Fragment as Fragment$1, useContext, useRef, Component, useSyncExternalStore, useCallback } from 'react';
|
|
3
3
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
4
4
|
import { marked } from 'marked';
|
|
5
5
|
|
|
@@ -1089,9 +1089,8 @@ function dedupeLayoutProviderFetch(key, fetchFn) {
|
|
|
1089
1089
|
return pending;
|
|
1090
1090
|
}
|
|
1091
1091
|
function previewLayoutReady(opts) {
|
|
1092
|
-
if (opts.hasClientLayout) return true;
|
|
1093
|
-
|
|
1094
|
-
return true;
|
|
1092
|
+
if (opts.hasClientLayout || opts.hasServerLayout) return true;
|
|
1093
|
+
return !opts.clientLoading;
|
|
1095
1094
|
}
|
|
1096
1095
|
|
|
1097
1096
|
// src/edge/variantKeys.ts
|
|
@@ -4010,14 +4009,16 @@ function applyComposerPatch(store, name, value, ref, layoutNodeId) {
|
|
|
4010
4009
|
store.set(composerStoreKey(name, ref, layoutNodeId), value);
|
|
4011
4010
|
}
|
|
4012
4011
|
function ComposerProvider({
|
|
4013
|
-
children
|
|
4012
|
+
children,
|
|
4013
|
+
enabled = true
|
|
4014
4014
|
}) {
|
|
4015
4015
|
const existing = useContext(ComposerStoreContext);
|
|
4016
4016
|
const storeRef = useRef(null);
|
|
4017
4017
|
if (!storeRef.current) storeRef.current = new ComposerFieldStore();
|
|
4018
|
-
const
|
|
4018
|
+
const ownsStore = !existing && enabled;
|
|
4019
|
+
const store = existing || (enabled ? storeRef.current : null);
|
|
4019
4020
|
useEffect(() => {
|
|
4020
|
-
if (
|
|
4021
|
+
if (!ownsStore || !store) return;
|
|
4021
4022
|
const applyField = (fieldName, value, nodeId, ref) => {
|
|
4022
4023
|
if (!fieldName || typeof fieldName !== "string") return;
|
|
4023
4024
|
const fieldRef = isFieldRef(ref) ? ref : void 0;
|
|
@@ -4075,8 +4076,7 @@ function ComposerProvider({
|
|
|
4075
4076
|
window.removeEventListener("amplifyup:props-patch", onPropsPatch);
|
|
4076
4077
|
window.removeEventListener("message", onMessage);
|
|
4077
4078
|
};
|
|
4078
|
-
}, [
|
|
4079
|
-
if (existing) return /* @__PURE__ */ jsx(Fragment, { children });
|
|
4079
|
+
}, [ownsStore, store]);
|
|
4080
4080
|
return /* @__PURE__ */ jsx(ComposerStoreContext.Provider, { value: store, children });
|
|
4081
4081
|
}
|
|
4082
4082
|
function useComposerFieldValue(name, fallback, ref) {
|
|
@@ -4103,9 +4103,7 @@ function MaybeComposerProvider({
|
|
|
4103
4103
|
layoutNodeId,
|
|
4104
4104
|
children
|
|
4105
4105
|
}) {
|
|
4106
|
-
|
|
4107
|
-
if (!enabled) return /* @__PURE__ */ jsx(Fragment, { children: content });
|
|
4108
|
-
return /* @__PURE__ */ jsx(ComposerProvider, { children: /* @__PURE__ */ jsx(ComposerNodeContext.Provider, { value: layoutNodeId, children }) });
|
|
4106
|
+
return /* @__PURE__ */ jsx(ComposerProvider, { enabled, children: /* @__PURE__ */ jsx(ComposerNodeContext.Provider, { value: enabled ? layoutNodeId : void 0, children }) });
|
|
4109
4107
|
}
|
|
4110
4108
|
function nodeRenderProps(node) {
|
|
4111
4109
|
const settings = node.settings || {};
|
|
@@ -4538,17 +4536,16 @@ function AmplifyRendererInner({
|
|
|
4538
4536
|
if (layoutTree.length === 0) {
|
|
4539
4537
|
return /* @__PURE__ */ jsx("main", { children: emptyComponent || /* @__PURE__ */ jsx("div", { className: "container mx-auto px-4 py-16", children: /* @__PURE__ */ jsx("p", { className: "text-muted-foreground", children: "No content configured for this page." }) }) });
|
|
4540
4538
|
}
|
|
4541
|
-
return /* @__PURE__ */ jsx(ComposerProvider, { children: /* @__PURE__ */ jsx(
|
|
4542
|
-
"
|
|
4539
|
+
return /* @__PURE__ */ jsx(ComposerProvider, { children: /* @__PURE__ */ jsx(
|
|
4540
|
+
"main",
|
|
4543
4541
|
{
|
|
4544
|
-
"data-slot-id": "main",
|
|
4545
|
-
"data-amplifyup-slot": "main",
|
|
4546
|
-
"data-slot-source": "page",
|
|
4547
|
-
"data-slot-state":
|
|
4548
|
-
"data-slot-empty": layoutTree.length === 0 ? "true" : void 0,
|
|
4542
|
+
"data-slot-id": composerPreviewFlag ? "main" : void 0,
|
|
4543
|
+
"data-amplifyup-slot": composerPreviewFlag ? "main" : void 0,
|
|
4544
|
+
"data-slot-source": composerPreviewFlag ? "page" : void 0,
|
|
4545
|
+
"data-slot-state": composerPreviewFlag ? "filled" : void 0,
|
|
4549
4546
|
children: layoutTree.map((node) => /* @__PURE__ */ jsx(Fragment$1, { children: renderNode(node) }, node.id))
|
|
4550
4547
|
}
|
|
4551
|
-
)
|
|
4548
|
+
) });
|
|
4552
4549
|
}
|
|
4553
4550
|
var AmplifyRenderer = memo(AmplifyRendererInner);
|
|
4554
4551
|
function AddComponentIcon({ size = 28 }) {
|
|
@@ -4724,11 +4721,14 @@ function AmplifyPageContent({
|
|
|
4724
4721
|
if (preview) {
|
|
4725
4722
|
const ready = previewLayoutReady({
|
|
4726
4723
|
clientLoading: client.loading,
|
|
4727
|
-
hasClientLayout: !!clientLayout
|
|
4724
|
+
hasClientLayout: !!clientLayout,
|
|
4725
|
+
hasServerLayout: !!serverLayout
|
|
4726
|
+
});
|
|
4728
4727
|
if (!ready) {
|
|
4729
4728
|
return /* @__PURE__ */ jsx(ComposerLayoutStatusProvider, { ready: false, children: previewLoading });
|
|
4730
4729
|
}
|
|
4731
|
-
|
|
4730
|
+
const layoutSettled = !client.loading || !!clientLayout;
|
|
4731
|
+
return /* @__PURE__ */ jsx(ComposerLayoutStatusProvider, { ready: layoutSettled, children: /* @__PURE__ */ jsx(
|
|
4732
4732
|
AmplifyRenderer,
|
|
4733
4733
|
{
|
|
4734
4734
|
pageConfig: pageConfig ?? void 0,
|
|
@@ -4750,7 +4750,7 @@ function AmplifyPageContent({
|
|
|
4750
4750
|
if (!hasAmplifyLayout(pageConfig)) {
|
|
4751
4751
|
return fallback ? /* @__PURE__ */ jsx(Fragment, { children: fallback }) : null;
|
|
4752
4752
|
}
|
|
4753
|
-
return /* @__PURE__ */ jsx(
|
|
4753
|
+
return /* @__PURE__ */ jsx(ComposerLayoutStatusProvider, { ready: true, children: /* @__PURE__ */ jsx(
|
|
4754
4754
|
AmplifyRenderer,
|
|
4755
4755
|
{
|
|
4756
4756
|
pageConfig: pageConfig ?? void 0,
|
|
@@ -4759,7 +4759,7 @@ function AmplifyPageContent({
|
|
|
4759
4759
|
emptyComponent,
|
|
4760
4760
|
errorComponent
|
|
4761
4761
|
}
|
|
4762
|
-
);
|
|
4762
|
+
) });
|
|
4763
4763
|
}
|
|
4764
4764
|
|
|
4765
4765
|
// src/slot-state.ts
|