@amplifyup/sdk 0.1.76 → 0.1.78
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/README.md +2 -0
- package/dist/AmplifyRenderer.js +27 -19
- package/dist/AmplifyRenderer.js.map +1 -1
- package/dist/AmplifyRenderer.mjs +28 -20
- package/dist/AmplifyRenderer.mjs.map +1 -1
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -3
- 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 +108 -62
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +109 -63
- package/dist/react.mjs.map +1 -1
- package/package.json +1 -1
package/dist/AmplifyRenderer.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { createContext, memo, useState, useEffect, Fragment as Fragment$1, useContext, useRef, Component
|
|
2
|
+
import { createContext, memo, useState, useEffect, Fragment as Fragment$1, useContext, useRef, Component } from 'react';
|
|
3
3
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
4
4
|
import 'marked';
|
|
5
5
|
|
|
@@ -166,6 +166,7 @@ var AWSAdapter = class {
|
|
|
166
166
|
return;
|
|
167
167
|
}
|
|
168
168
|
const trackingId = eventData?.trackingId || this.config?.trackingId;
|
|
169
|
+
const debug = this.config?.debug;
|
|
169
170
|
const query = trackingId ? `?tid=${encodeURIComponent(trackingId)}` : "";
|
|
170
171
|
const url = `${this.apiGatewayUrl}${endpoint}${query}`;
|
|
171
172
|
try {
|
|
@@ -180,15 +181,15 @@ var AWSAdapter = class {
|
|
|
180
181
|
keepalive: true
|
|
181
182
|
});
|
|
182
183
|
if (!response.ok) {
|
|
183
|
-
if (
|
|
184
|
+
if (debug) {
|
|
184
185
|
console.warn(`AmplifyUp SDK: Event tracking failed: ${response.status} ${response.statusText}`);
|
|
185
186
|
}
|
|
186
|
-
} else if (
|
|
187
|
+
} else if (debug) {
|
|
187
188
|
const result = await response.json().catch(() => ({}));
|
|
188
189
|
console.log("AmplifyUp SDK: Event tracked", result);
|
|
189
190
|
}
|
|
190
191
|
} catch (error) {
|
|
191
|
-
if (
|
|
192
|
+
if (debug) {
|
|
192
193
|
console.error("AmplifyUp SDK: Event tracking error:", error);
|
|
193
194
|
}
|
|
194
195
|
}
|
|
@@ -3563,6 +3564,14 @@ function getSDK(adapter) {
|
|
|
3563
3564
|
var trackContentView = (contentId, contentType, properties) => getSDK().trackContentView(contentId, contentType, properties);
|
|
3564
3565
|
var refreshEventTracking = () => getSDK().refreshEventTracking();
|
|
3565
3566
|
getSDK();
|
|
3567
|
+
var PageContentRegistryContext = createContext(null);
|
|
3568
|
+
function useRegisterPageContent(enabled = true) {
|
|
3569
|
+
const register = useContext(PageContentRegistryContext);
|
|
3570
|
+
useEffect(() => {
|
|
3571
|
+
if (!enabled || !register) return;
|
|
3572
|
+
return register();
|
|
3573
|
+
}, [enabled, register]);
|
|
3574
|
+
}
|
|
3566
3575
|
function useInComposer(force = false) {
|
|
3567
3576
|
const [detected, setDetected] = useState(false);
|
|
3568
3577
|
useEffect(() => {
|
|
@@ -3624,14 +3633,16 @@ function applyComposerPatch(store, name, value, ref, layoutNodeId) {
|
|
|
3624
3633
|
store.set(composerStoreKey(name, ref, layoutNodeId), value);
|
|
3625
3634
|
}
|
|
3626
3635
|
function ComposerProvider({
|
|
3627
|
-
children
|
|
3636
|
+
children,
|
|
3637
|
+
enabled = true
|
|
3628
3638
|
}) {
|
|
3629
3639
|
const existing = useContext(ComposerStoreContext);
|
|
3630
3640
|
const storeRef = useRef(null);
|
|
3631
3641
|
if (!storeRef.current) storeRef.current = new ComposerFieldStore();
|
|
3632
|
-
const
|
|
3642
|
+
const ownsStore = !existing && enabled;
|
|
3643
|
+
const store = existing || (enabled ? storeRef.current : null);
|
|
3633
3644
|
useEffect(() => {
|
|
3634
|
-
if (
|
|
3645
|
+
if (!ownsStore || !store) return;
|
|
3635
3646
|
const applyField = (fieldName, value, nodeId, ref) => {
|
|
3636
3647
|
if (!fieldName || typeof fieldName !== "string") return;
|
|
3637
3648
|
const fieldRef = isFieldRef(ref) ? ref : void 0;
|
|
@@ -3689,8 +3700,7 @@ function ComposerProvider({
|
|
|
3689
3700
|
window.removeEventListener("amplifyup:props-patch", onPropsPatch);
|
|
3690
3701
|
window.removeEventListener("message", onMessage);
|
|
3691
3702
|
};
|
|
3692
|
-
}, [
|
|
3693
|
-
if (existing) return /* @__PURE__ */ jsx(Fragment, { children });
|
|
3703
|
+
}, [ownsStore, store]);
|
|
3694
3704
|
return /* @__PURE__ */ jsx(ComposerStoreContext.Provider, { value: store, children });
|
|
3695
3705
|
}
|
|
3696
3706
|
function MaybeComposerProvider({
|
|
@@ -3698,9 +3708,7 @@ function MaybeComposerProvider({
|
|
|
3698
3708
|
layoutNodeId,
|
|
3699
3709
|
children
|
|
3700
3710
|
}) {
|
|
3701
|
-
|
|
3702
|
-
if (!enabled) return /* @__PURE__ */ jsx(Fragment, { children: content });
|
|
3703
|
-
return /* @__PURE__ */ jsx(ComposerProvider, { children: /* @__PURE__ */ jsx(ComposerNodeContext.Provider, { value: layoutNodeId, children }) });
|
|
3711
|
+
return /* @__PURE__ */ jsx(ComposerProvider, { enabled, children: /* @__PURE__ */ jsx(ComposerNodeContext.Provider, { value: enabled ? layoutNodeId : void 0, children }) });
|
|
3704
3712
|
}
|
|
3705
3713
|
createContext(null);
|
|
3706
3714
|
var usePathname = null;
|
|
@@ -3805,6 +3813,7 @@ function AmplifyRendererInner({
|
|
|
3805
3813
|
composerPreview
|
|
3806
3814
|
}) {
|
|
3807
3815
|
const clientHook = useAmplifyUp();
|
|
3816
|
+
useRegisterPageContent(!serverPageConfig);
|
|
3808
3817
|
const composerPreviewFlag = useComposerPreviewFlag(!!composerPreview);
|
|
3809
3818
|
const pageConfig = serverPageConfig || clientHook.pageConfig || null;
|
|
3810
3819
|
const loading = serverPageConfig ? false : clientHook.loading;
|
|
@@ -4152,17 +4161,16 @@ function AmplifyRendererInner({
|
|
|
4152
4161
|
if (layoutTree.length === 0) {
|
|
4153
4162
|
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." }) }) });
|
|
4154
4163
|
}
|
|
4155
|
-
return /* @__PURE__ */ jsx(ComposerProvider, { children: /* @__PURE__ */ jsx(
|
|
4156
|
-
"
|
|
4164
|
+
return /* @__PURE__ */ jsx(ComposerProvider, { children: /* @__PURE__ */ jsx(
|
|
4165
|
+
"main",
|
|
4157
4166
|
{
|
|
4158
|
-
"data-slot-id": "main",
|
|
4159
|
-
"data-amplifyup-slot": "main",
|
|
4160
|
-
"data-slot-source": "page",
|
|
4161
|
-
"data-slot-state":
|
|
4162
|
-
"data-slot-empty": layoutTree.length === 0 ? "true" : void 0,
|
|
4167
|
+
"data-slot-id": composerPreviewFlag ? "main" : void 0,
|
|
4168
|
+
"data-amplifyup-slot": composerPreviewFlag ? "main" : void 0,
|
|
4169
|
+
"data-slot-source": composerPreviewFlag ? "page" : void 0,
|
|
4170
|
+
"data-slot-state": composerPreviewFlag ? "filled" : void 0,
|
|
4163
4171
|
children: layoutTree.map((node) => /* @__PURE__ */ jsx(Fragment$1, { children: renderNode(node) }, node.id))
|
|
4164
4172
|
}
|
|
4165
|
-
)
|
|
4173
|
+
) });
|
|
4166
4174
|
}
|
|
4167
4175
|
var AmplifyRenderer = memo(AmplifyRendererInner);
|
|
4168
4176
|
|