@amplifyup/sdk 0.1.4 → 0.1.6
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 +46 -8
- package/dist/AmplifyRenderer.d.mts +1 -1
- package/dist/AmplifyRenderer.d.ts +1 -1
- package/dist/AmplifyRenderer.js +52 -34
- package/dist/AmplifyRenderer.js.map +1 -1
- package/dist/AmplifyRenderer.mjs +52 -34
- package/dist/AmplifyRenderer.mjs.map +1 -1
- package/dist/index.d.mts +10 -2
- package/dist/index.d.ts +10 -2
- package/dist/index.js +80 -34
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +79 -35
- package/dist/index.mjs.map +1 -1
- package/dist/preview-BMrIgUvp.d.mts +13 -0
- package/dist/preview-BMrIgUvp.d.ts +13 -0
- package/dist/react.d.mts +29 -3
- package/dist/react.d.ts +29 -3
- package/dist/react.js +139 -53
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +137 -54
- package/dist/react.mjs.map +1 -1
- package/dist/server.d.mts +2 -2
- package/dist/server.d.ts +2 -2
- package/dist/server.js +0 -6
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +0 -6
- package/dist/server.mjs.map +1 -1
- package/dist/{types-Xv9P55Dj.d.mts → types-B2Swk8BW.d.mts} +10 -7
- package/dist/{types-Xv9P55Dj.d.ts → types-B2Swk8BW.d.ts} +10 -7
- package/package.json +1 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Composer / visual-editor preview detection.
|
|
3
|
+
* Shared by AmplifyPageContent, AmplifyUpProvider, and AmplifyRenderer.
|
|
4
|
+
*/
|
|
5
|
+
/** True when `preview=true` (or legacy visualEditor) is in request search params. */
|
|
6
|
+
declare function isPreviewRequest(searchParams: Record<string, string | string[] | undefined> | URLSearchParams): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Client-only: true when the page is loaded inside AmplifyUp Composer.
|
|
9
|
+
* Does NOT treat every iframe as preview — only Composer referrers / query flags.
|
|
10
|
+
*/
|
|
11
|
+
declare function isComposerPreview(): boolean;
|
|
12
|
+
|
|
13
|
+
export { isPreviewRequest as a, isComposerPreview as i };
|
package/dist/react.d.mts
CHANGED
|
@@ -1,10 +1,36 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import {
|
|
4
|
-
export { Z as ZoneConfig } from './types-
|
|
3
|
+
import { P as PageConfig, A as AmplifyUpConfig } from './types-B2Swk8BW.mjs';
|
|
4
|
+
export { Z as ZoneConfig } from './types-B2Swk8BW.mjs';
|
|
5
5
|
export { AmplifyRenderer } from './AmplifyRenderer.mjs';
|
|
6
|
+
export { i as isComposerPreview, a as isPreviewRequest } from './preview-BMrIgUvp.mjs';
|
|
6
7
|
export { fetchPageConfigServer } from './server.mjs';
|
|
7
8
|
|
|
9
|
+
type RenderComponentFn = (componentId: string, props: Record<string, any>, slots?: Record<string, ReactNode>) => ReactNode;
|
|
10
|
+
interface AmplifyPageContentProps {
|
|
11
|
+
/**
|
|
12
|
+
* Native page content shown to visitors when no AmplifyUp layout is configured.
|
|
13
|
+
* Never rendered in Composer preview — only the layout canvas is shown there.
|
|
14
|
+
*/
|
|
15
|
+
fallback?: ReactNode;
|
|
16
|
+
/** Maps AmplifyUp component IDs to your React components. */
|
|
17
|
+
renderComponent: RenderComponentFn;
|
|
18
|
+
/** Optional pre-fetched layout (e.g. from server in preview mode). */
|
|
19
|
+
pageConfig?: PageConfig | null;
|
|
20
|
+
/** Shown while layout loads in Composer (default: empty main canvas). */
|
|
21
|
+
previewLoadingComponent?: ReactNode;
|
|
22
|
+
/** Shown when no layout components exist yet in Composer (default: empty main canvas). */
|
|
23
|
+
previewEmptyComponent?: ReactNode;
|
|
24
|
+
loadingComponent?: ReactNode;
|
|
25
|
+
emptyComponent?: ReactNode;
|
|
26
|
+
errorComponent?: (error: string) => ReactNode;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Hybrid page wrapper: Composer shows only the AmplifyUp layout canvas;
|
|
30
|
+
* normal visits show the configured layout or your native `fallback`.
|
|
31
|
+
*/
|
|
32
|
+
declare function AmplifyPageContent({ fallback, renderComponent, pageConfig: pageConfigProp, previewLoadingComponent, previewEmptyComponent, loadingComponent, emptyComponent, errorComponent, }: AmplifyPageContentProps): react_jsx_runtime.JSX.Element | null;
|
|
33
|
+
|
|
8
34
|
/**
|
|
9
35
|
* ComponentContextProvider - Provides slots and props to child components
|
|
10
36
|
* This should wrap each component when rendering
|
|
@@ -86,4 +112,4 @@ interface AmplifyUpProviderProps {
|
|
|
86
112
|
declare function AmplifyUpProvider({ children, config }: AmplifyUpProviderProps): react_jsx_runtime.JSX.Element;
|
|
87
113
|
declare function useAmplifyUp(): AmplifyUpContextType;
|
|
88
114
|
|
|
89
|
-
export { AmplifyUpProvider, ComponentContextProvider, Field, PageConfig, Slot, useAmplifyUp };
|
|
115
|
+
export { AmplifyPageContent, type AmplifyPageContentProps, AmplifyUpProvider, ComponentContextProvider, Field, PageConfig, Slot, useAmplifyUp };
|
package/dist/react.d.ts
CHANGED
|
@@ -1,10 +1,36 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import {
|
|
4
|
-
export { Z as ZoneConfig } from './types-
|
|
3
|
+
import { P as PageConfig, A as AmplifyUpConfig } from './types-B2Swk8BW.js';
|
|
4
|
+
export { Z as ZoneConfig } from './types-B2Swk8BW.js';
|
|
5
5
|
export { AmplifyRenderer } from './AmplifyRenderer.js';
|
|
6
|
+
export { i as isComposerPreview, a as isPreviewRequest } from './preview-BMrIgUvp.js';
|
|
6
7
|
export { fetchPageConfigServer } from './server.js';
|
|
7
8
|
|
|
9
|
+
type RenderComponentFn = (componentId: string, props: Record<string, any>, slots?: Record<string, ReactNode>) => ReactNode;
|
|
10
|
+
interface AmplifyPageContentProps {
|
|
11
|
+
/**
|
|
12
|
+
* Native page content shown to visitors when no AmplifyUp layout is configured.
|
|
13
|
+
* Never rendered in Composer preview — only the layout canvas is shown there.
|
|
14
|
+
*/
|
|
15
|
+
fallback?: ReactNode;
|
|
16
|
+
/** Maps AmplifyUp component IDs to your React components. */
|
|
17
|
+
renderComponent: RenderComponentFn;
|
|
18
|
+
/** Optional pre-fetched layout (e.g. from server in preview mode). */
|
|
19
|
+
pageConfig?: PageConfig | null;
|
|
20
|
+
/** Shown while layout loads in Composer (default: empty main canvas). */
|
|
21
|
+
previewLoadingComponent?: ReactNode;
|
|
22
|
+
/** Shown when no layout components exist yet in Composer (default: empty main canvas). */
|
|
23
|
+
previewEmptyComponent?: ReactNode;
|
|
24
|
+
loadingComponent?: ReactNode;
|
|
25
|
+
emptyComponent?: ReactNode;
|
|
26
|
+
errorComponent?: (error: string) => ReactNode;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Hybrid page wrapper: Composer shows only the AmplifyUp layout canvas;
|
|
30
|
+
* normal visits show the configured layout or your native `fallback`.
|
|
31
|
+
*/
|
|
32
|
+
declare function AmplifyPageContent({ fallback, renderComponent, pageConfig: pageConfigProp, previewLoadingComponent, previewEmptyComponent, loadingComponent, emptyComponent, errorComponent, }: AmplifyPageContentProps): react_jsx_runtime.JSX.Element | null;
|
|
33
|
+
|
|
8
34
|
/**
|
|
9
35
|
* ComponentContextProvider - Provides slots and props to child components
|
|
10
36
|
* This should wrap each component when rendering
|
|
@@ -86,4 +112,4 @@ interface AmplifyUpProviderProps {
|
|
|
86
112
|
declare function AmplifyUpProvider({ children, config }: AmplifyUpProviderProps): react_jsx_runtime.JSX.Element;
|
|
87
113
|
declare function useAmplifyUp(): AmplifyUpContextType;
|
|
88
114
|
|
|
89
|
-
export { AmplifyUpProvider, ComponentContextProvider, Field, PageConfig, Slot, useAmplifyUp };
|
|
115
|
+
export { AmplifyPageContent, type AmplifyPageContentProps, AmplifyUpProvider, ComponentContextProvider, Field, PageConfig, Slot, useAmplifyUp };
|
package/dist/react.js
CHANGED
|
@@ -242,14 +242,16 @@ function resolveAmplifyUpTarget(options) {
|
|
|
242
242
|
if (isAmplifyUpTarget(envTarget)) {
|
|
243
243
|
return normalizeAmplifyUpTarget(envTarget);
|
|
244
244
|
}
|
|
245
|
-
if (typeof window !== "undefined") {
|
|
246
|
-
const host = window.location.hostname;
|
|
247
|
-
if (host === "localhost" || host === "127.0.0.1") {
|
|
248
|
-
return "local";
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
245
|
return "production";
|
|
252
246
|
}
|
|
247
|
+
function isRemoteOrchestratorUrl(orchestratorUrl) {
|
|
248
|
+
try {
|
|
249
|
+
const host = new URL(orchestratorUrl).hostname.toLowerCase();
|
|
250
|
+
return host !== "localhost" && host !== "127.0.0.1" && host !== "::1";
|
|
251
|
+
} catch {
|
|
252
|
+
return false;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
253
255
|
function localOrchestratorUrl() {
|
|
254
256
|
const fromEnv = typeof process !== "undefined" ? process.env.NEXT_PUBLIC_ORCHESTRATOR_URL : void 0;
|
|
255
257
|
return (fromEnv || "http://localhost:5001").replace(/\/$/, "");
|
|
@@ -283,6 +285,32 @@ function resolveAmplifyUpUrls(target) {
|
|
|
283
285
|
};
|
|
284
286
|
}
|
|
285
287
|
|
|
288
|
+
// src/preview.ts
|
|
289
|
+
function isPreviewRequest(searchParams) {
|
|
290
|
+
if (searchParams instanceof URLSearchParams) {
|
|
291
|
+
return searchParams.get("preview") === "true" || searchParams.get("visualEditor") === "true";
|
|
292
|
+
}
|
|
293
|
+
const preview = searchParams.preview;
|
|
294
|
+
const visualEditor = searchParams.visualEditor;
|
|
295
|
+
return preview === "true" || visualEditor === "true";
|
|
296
|
+
}
|
|
297
|
+
function isComposerPreview() {
|
|
298
|
+
if (typeof window === "undefined") return false;
|
|
299
|
+
if (window.__AMPLIFYUP_PREVIEW_MODE__ === true) return true;
|
|
300
|
+
const params = new URLSearchParams(window.location.search);
|
|
301
|
+
if (isPreviewRequest(params)) return true;
|
|
302
|
+
if (window.self !== window.top && document.referrer) {
|
|
303
|
+
try {
|
|
304
|
+
const refUrl = new URL(document.referrer);
|
|
305
|
+
if (refUrl.hostname === "amplifyup.ai" || refUrl.hostname.endsWith(".amplifyup.ai") || refUrl.hostname === "localhost" && refUrl.port === "5001" || refUrl.pathname.includes("/dashboard/composer") || refUrl.pathname.includes("/dashboard/routes/")) {
|
|
306
|
+
return true;
|
|
307
|
+
}
|
|
308
|
+
} catch {
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
return false;
|
|
312
|
+
}
|
|
313
|
+
|
|
286
314
|
// src/index.ts
|
|
287
315
|
function readPreviewQueryOverrides() {
|
|
288
316
|
if (typeof window === "undefined") return {};
|
|
@@ -405,6 +433,7 @@ var AmplifyUpSDK = class {
|
|
|
405
433
|
*/
|
|
406
434
|
async init(config) {
|
|
407
435
|
if (this.initialized && this.adapter?.isInitialized()) {
|
|
436
|
+
this.ensureWindowBridge();
|
|
408
437
|
return;
|
|
409
438
|
}
|
|
410
439
|
if (this.initPromise) {
|
|
@@ -417,6 +446,32 @@ var AmplifyUpSDK = class {
|
|
|
417
446
|
this.initPromise = null;
|
|
418
447
|
}
|
|
419
448
|
}
|
|
449
|
+
/** Attach console helpers to window (idempotent; survives Fast Refresh). */
|
|
450
|
+
ensureWindowBridge() {
|
|
451
|
+
if (typeof window === "undefined") return;
|
|
452
|
+
window.AmplifyUp = {
|
|
453
|
+
getInstanceId: () => this.getInstanceId(),
|
|
454
|
+
getUserId: () => this.getUserId(),
|
|
455
|
+
getTrackingId: () => this.getTrackingId(),
|
|
456
|
+
getTarget: () => this.getTarget(),
|
|
457
|
+
getDiagnostics: () => this.getDiagnostics(),
|
|
458
|
+
getStatus: () => {
|
|
459
|
+
console.log(this.getStatus());
|
|
460
|
+
return this.getDiagnostics();
|
|
461
|
+
},
|
|
462
|
+
testTracking: () => this.testTracking(),
|
|
463
|
+
verifyAWSConnection: () => {
|
|
464
|
+
const result = this.verifyAWSConnection();
|
|
465
|
+
console.log("AWS Connection Verification:", result.message);
|
|
466
|
+
console.log("Full details:", result);
|
|
467
|
+
return result;
|
|
468
|
+
},
|
|
469
|
+
isInitialized: () => this.isInitialized(),
|
|
470
|
+
page: (url, properties) => this.page(url, properties),
|
|
471
|
+
track: (eventName, properties) => this.track(eventName, properties),
|
|
472
|
+
identify: (userId, traits) => this.identify(userId, traits)
|
|
473
|
+
};
|
|
474
|
+
}
|
|
420
475
|
async performInit(config) {
|
|
421
476
|
if (!this.adapter) {
|
|
422
477
|
this.adapter = new AWSAdapter();
|
|
@@ -432,6 +487,12 @@ var AmplifyUpSDK = class {
|
|
|
432
487
|
const previewOverrides = readPreviewQueryOverrides();
|
|
433
488
|
if (previewOverrides.orchestratorUrl) {
|
|
434
489
|
this.orchestratorUrl = previewOverrides.orchestratorUrl;
|
|
490
|
+
if (isRemoteOrchestratorUrl(previewOverrides.orchestratorUrl)) {
|
|
491
|
+
const prodUrls = resolveAmplifyUpUrls("production");
|
|
492
|
+
this.target = "production";
|
|
493
|
+
this.apiGatewayUrl = prodUrls.apiGatewayUrl;
|
|
494
|
+
this.decisionApiUrl = prodUrls.decisionApiUrl;
|
|
495
|
+
}
|
|
435
496
|
}
|
|
436
497
|
this.config = {
|
|
437
498
|
trackingId: previewOverrides.trackingId || config.trackingId,
|
|
@@ -449,34 +510,10 @@ var AmplifyUpSDK = class {
|
|
|
449
510
|
};
|
|
450
511
|
await this.adapter.init(adapterConfig);
|
|
451
512
|
this.initialized = this.adapter.isInitialized();
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
getTrackingId: () => this.getTrackingId(),
|
|
457
|
-
getTarget: () => this.getTarget(),
|
|
458
|
-
getDiagnostics: () => this.getDiagnostics(),
|
|
459
|
-
getStatus: () => {
|
|
460
|
-
console.log(this.getStatus());
|
|
461
|
-
return this.getDiagnostics();
|
|
462
|
-
},
|
|
463
|
-
testTracking: () => this.testTracking(),
|
|
464
|
-
verifyAWSConnection: () => {
|
|
465
|
-
const result = this.verifyAWSConnection();
|
|
466
|
-
console.log("AWS Connection Verification:", result.message);
|
|
467
|
-
console.log("Full details:", result);
|
|
468
|
-
return result;
|
|
469
|
-
},
|
|
470
|
-
isInitialized: () => this.isInitialized(),
|
|
471
|
-
// Re-export main tracking methods for convenience
|
|
472
|
-
page: (url, properties) => this.page(url, properties),
|
|
473
|
-
track: (eventName, properties) => this.track(eventName, properties),
|
|
474
|
-
identify: (userId, traits) => this.identify(userId, traits)
|
|
475
|
-
};
|
|
476
|
-
if (this.config?.debug) {
|
|
477
|
-
console.log("AmplifyUp SDK: Diagnostic methods available on window.AmplifyUp");
|
|
478
|
-
console.log("Try: AmplifyUp.getStatus() or AmplifyUp.testTracking()");
|
|
479
|
-
}
|
|
513
|
+
this.ensureWindowBridge();
|
|
514
|
+
if (this.config?.debug) {
|
|
515
|
+
console.log("AmplifyUp SDK: Diagnostic methods available on window.AmplifyUp");
|
|
516
|
+
console.log("Try: AmplifyUp.getStatus() or AmplifyUp.testTracking()");
|
|
480
517
|
}
|
|
481
518
|
this.clearTrackingIntervals();
|
|
482
519
|
if (this.isPreviewMode()) {
|
|
@@ -1487,10 +1524,17 @@ Available Console Commands:
|
|
|
1487
1524
|
}
|
|
1488
1525
|
};
|
|
1489
1526
|
var sdkInstance = null;
|
|
1527
|
+
if (typeof window !== "undefined" && window.__AMPLIFYUP_SDK__) {
|
|
1528
|
+
sdkInstance = window.__AMPLIFYUP_SDK__;
|
|
1529
|
+
}
|
|
1490
1530
|
function getSDK(adapter) {
|
|
1491
1531
|
if (!sdkInstance) {
|
|
1492
1532
|
sdkInstance = new AmplifyUpSDK(adapter);
|
|
1533
|
+
if (typeof window !== "undefined") {
|
|
1534
|
+
window.__AMPLIFYUP_SDK__ = sdkInstance;
|
|
1535
|
+
}
|
|
1493
1536
|
}
|
|
1537
|
+
sdkInstance.ensureWindowBridge();
|
|
1494
1538
|
return sdkInstance;
|
|
1495
1539
|
}
|
|
1496
1540
|
var trackContentView = (contentId, contentType, properties) => getSDK().trackContentView(contentId, contentType, properties);
|
|
@@ -1793,6 +1837,62 @@ function AmplifyRenderer({
|
|
|
1793
1837
|
}
|
|
1794
1838
|
return /* @__PURE__ */ jsxRuntime.jsx("main", { children: layoutTree.map((node) => /* @__PURE__ */ jsxRuntime.jsx("div", { children: renderNode(node) }, node.id)) });
|
|
1795
1839
|
}
|
|
1840
|
+
function defaultPreviewCanvas() {
|
|
1841
|
+
return /* @__PURE__ */ jsxRuntime.jsx("main", { className: "min-h-[50vh]", "data-amplifyup-composer-canvas": true });
|
|
1842
|
+
}
|
|
1843
|
+
function hasAmplifyLayout(pageConfig) {
|
|
1844
|
+
return !!(pageConfig && pageConfig.id !== "default" && Array.isArray(pageConfig.layoutTree) && pageConfig.layoutTree.length > 0);
|
|
1845
|
+
}
|
|
1846
|
+
function AmplifyPageContent({
|
|
1847
|
+
fallback,
|
|
1848
|
+
renderComponent,
|
|
1849
|
+
pageConfig: pageConfigProp,
|
|
1850
|
+
previewLoadingComponent,
|
|
1851
|
+
previewEmptyComponent,
|
|
1852
|
+
loadingComponent,
|
|
1853
|
+
emptyComponent,
|
|
1854
|
+
errorComponent
|
|
1855
|
+
}) {
|
|
1856
|
+
const client = useAmplifyUp();
|
|
1857
|
+
const preview = isComposerPreview();
|
|
1858
|
+
const pageConfig = pageConfigProp ?? client.pageConfig;
|
|
1859
|
+
const loading = pageConfigProp ? false : client.loading;
|
|
1860
|
+
const error = pageConfigProp ? null : client.error;
|
|
1861
|
+
const previewCanvas = previewEmptyComponent ?? defaultPreviewCanvas();
|
|
1862
|
+
const previewLoading = previewLoadingComponent ?? previewCanvas;
|
|
1863
|
+
if (preview) {
|
|
1864
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1865
|
+
AmplifyRenderer,
|
|
1866
|
+
{
|
|
1867
|
+
pageConfig: pageConfig ?? void 0,
|
|
1868
|
+
renderComponent,
|
|
1869
|
+
loadingComponent: loadingComponent ?? previewLoading,
|
|
1870
|
+
emptyComponent: emptyComponent ?? previewCanvas,
|
|
1871
|
+
errorComponent: errorComponent ?? (() => previewCanvas)
|
|
1872
|
+
}
|
|
1873
|
+
);
|
|
1874
|
+
}
|
|
1875
|
+
if (loading) {
|
|
1876
|
+
return loadingComponent ? /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: loadingComponent }) : null;
|
|
1877
|
+
}
|
|
1878
|
+
if (error) {
|
|
1879
|
+
if (errorComponent) return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: errorComponent(error) });
|
|
1880
|
+
return fallback ? /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: fallback }) : null;
|
|
1881
|
+
}
|
|
1882
|
+
if (!hasAmplifyLayout(pageConfig)) {
|
|
1883
|
+
return fallback ? /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: fallback }) : null;
|
|
1884
|
+
}
|
|
1885
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1886
|
+
AmplifyRenderer,
|
|
1887
|
+
{
|
|
1888
|
+
pageConfig: pageConfig ?? void 0,
|
|
1889
|
+
renderComponent,
|
|
1890
|
+
loadingComponent,
|
|
1891
|
+
emptyComponent,
|
|
1892
|
+
errorComponent
|
|
1893
|
+
}
|
|
1894
|
+
);
|
|
1895
|
+
}
|
|
1796
1896
|
|
|
1797
1897
|
// src/server.tsx
|
|
1798
1898
|
async function fetchPageConfigServer(route, trackingId, preview = false, options) {
|
|
@@ -2022,7 +2122,7 @@ function AmplifyUpProvider({ children, config }) {
|
|
|
2022
2122
|
return () => {
|
|
2023
2123
|
cancelled = true;
|
|
2024
2124
|
};
|
|
2025
|
-
}, []);
|
|
2125
|
+
}, [config.trackingId, config.target, config.debug, config.dev]);
|
|
2026
2126
|
react.useEffect(() => {
|
|
2027
2127
|
if (!initialized) return;
|
|
2028
2128
|
const fetchConfig = async () => {
|
|
@@ -2035,24 +2135,7 @@ function AmplifyUpProvider({ children, config }) {
|
|
|
2035
2135
|
return;
|
|
2036
2136
|
}
|
|
2037
2137
|
const sdk = getSDK();
|
|
2038
|
-
const isPreviewContext = (
|
|
2039
|
-
if (typeof window === "undefined") return false;
|
|
2040
|
-
if (window.__AMPLIFYUP_PREVIEW_MODE__ === true) return true;
|
|
2041
|
-
const params = new URLSearchParams(window.location.search);
|
|
2042
|
-
if (params.get("preview") === "true" || params.get("visualEditor") === "true") return true;
|
|
2043
|
-
if (window.self !== window.top) {
|
|
2044
|
-
if (document.referrer) {
|
|
2045
|
-
try {
|
|
2046
|
-
const refUrl = new URL(document.referrer);
|
|
2047
|
-
if (refUrl.hostname === "localhost" && refUrl.port === "5001" || refUrl.pathname.includes("/dashboard/composer") || refUrl.pathname.includes("/dashboard/routes/")) {
|
|
2048
|
-
return true;
|
|
2049
|
-
}
|
|
2050
|
-
} catch {
|
|
2051
|
-
}
|
|
2052
|
-
}
|
|
2053
|
-
}
|
|
2054
|
-
return false;
|
|
2055
|
-
})();
|
|
2138
|
+
const isPreviewContext = isComposerPreview();
|
|
2056
2139
|
const page = await sdk.fetchPageConfig(actualRoute, isPreviewContext);
|
|
2057
2140
|
if (!page) {
|
|
2058
2141
|
setPageConfig({
|
|
@@ -2084,12 +2167,15 @@ function useAmplifyUp() {
|
|
|
2084
2167
|
return context;
|
|
2085
2168
|
}
|
|
2086
2169
|
|
|
2170
|
+
exports.AmplifyPageContent = AmplifyPageContent;
|
|
2087
2171
|
exports.AmplifyRenderer = AmplifyRenderer;
|
|
2088
2172
|
exports.AmplifyUpProvider = AmplifyUpProvider;
|
|
2089
2173
|
exports.ComponentContextProvider = ComponentContextProvider;
|
|
2090
2174
|
exports.Field = Field;
|
|
2091
2175
|
exports.Slot = Slot;
|
|
2092
2176
|
exports.fetchPageConfigServer = fetchPageConfigServer;
|
|
2177
|
+
exports.isComposerPreview = isComposerPreview;
|
|
2178
|
+
exports.isPreviewRequest = isPreviewRequest;
|
|
2093
2179
|
exports.useAmplifyUp = useAmplifyUp;
|
|
2094
2180
|
//# sourceMappingURL=react.js.map
|
|
2095
2181
|
//# sourceMappingURL=react.js.map
|