@amplifyup/sdk 0.1.32 → 0.1.33

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.
@@ -4,10 +4,15 @@
4
4
  */
5
5
  /** True when `preview=true` (or legacy visualEditor) is in request search params. */
6
6
  declare function isPreviewRequest(searchParams: Record<string, string | string[] | undefined> | URLSearchParams): boolean;
7
+ /**
8
+ * Composer Edit (not Preview toggle): overlay unpublished CMS docs.
9
+ * Live visitors and Composer Preview omit this.
10
+ */
11
+ declare function isWorkingContentRequest(searchParams: Record<string, string | string[] | undefined> | URLSearchParams): boolean;
7
12
  /**
8
13
  * Client-only: true when the page is loaded inside AmplifyUp Composer.
9
14
  * Does NOT treat every iframe as preview — only Composer referrers / query flags.
10
15
  */
11
16
  declare function isComposerPreview(): boolean;
12
17
 
13
- export { isPreviewRequest as a, isComposerPreview as i };
18
+ export { isPreviewRequest as a, isWorkingContentRequest as b, isComposerPreview as i };
@@ -4,10 +4,15 @@
4
4
  */
5
5
  /** True when `preview=true` (or legacy visualEditor) is in request search params. */
6
6
  declare function isPreviewRequest(searchParams: Record<string, string | string[] | undefined> | URLSearchParams): boolean;
7
+ /**
8
+ * Composer Edit (not Preview toggle): overlay unpublished CMS docs.
9
+ * Live visitors and Composer Preview omit this.
10
+ */
11
+ declare function isWorkingContentRequest(searchParams: Record<string, string | string[] | undefined> | URLSearchParams): boolean;
7
12
  /**
8
13
  * Client-only: true when the page is loaded inside AmplifyUp Composer.
9
14
  * Does NOT treat every iframe as preview — only Composer referrers / query flags.
10
15
  */
11
16
  declare function isComposerPreview(): boolean;
12
17
 
13
- export { isPreviewRequest as a, isComposerPreview as i };
18
+ export { isPreviewRequest as a, isWorkingContentRequest as b, isComposerPreview as i };
package/dist/react.d.mts CHANGED
@@ -3,7 +3,7 @@ import React, { ReactNode } from 'react';
3
3
  import { P as PageConfig, b as AmplifyUpConfig, C as ContentSource, A as AmplifyContentMeta } from './types-npF_lNoq.mjs';
4
4
  export { Z as ZoneConfig } from './types-npF_lNoq.mjs';
5
5
  export { AmplifyRenderer } from './AmplifyRenderer.mjs';
6
- export { i as isComposerPreview, a as isPreviewRequest } from './preview-BMrIgUvp.mjs';
6
+ export { i as isComposerPreview, a as isPreviewRequest, b as isWorkingContentRequest } from './preview-_vHmzRen.mjs';
7
7
  export { fetchPageConfigServer } from './server.mjs';
8
8
 
9
9
  type RenderComponentContext = {
package/dist/react.d.ts CHANGED
@@ -3,7 +3,7 @@ import React, { ReactNode } from 'react';
3
3
  import { P as PageConfig, b as AmplifyUpConfig, C as ContentSource, A as AmplifyContentMeta } from './types-npF_lNoq.js';
4
4
  export { Z as ZoneConfig } from './types-npF_lNoq.js';
5
5
  export { AmplifyRenderer } from './AmplifyRenderer.js';
6
- export { i as isComposerPreview, a as isPreviewRequest } from './preview-BMrIgUvp.js';
6
+ export { i as isComposerPreview, a as isPreviewRequest, b as isWorkingContentRequest } from './preview-_vHmzRen.js';
7
7
  export { fetchPageConfigServer } from './server.js';
8
8
 
9
9
  type RenderComponentContext = {
package/dist/react.js CHANGED
@@ -325,12 +325,17 @@ function resolveAmplifyUpUrls(target) {
325
325
 
326
326
  // src/preview.ts
327
327
  function isPreviewRequest(searchParams) {
328
+ return paramIsTrue(searchParams, "preview") || paramIsTrue(searchParams, "visualEditor");
329
+ }
330
+ function isWorkingContentRequest(searchParams) {
331
+ return paramIsTrue(searchParams, "working");
332
+ }
333
+ function paramIsTrue(searchParams, key) {
328
334
  if (searchParams instanceof URLSearchParams) {
329
- return searchParams.get("preview") === "true" || searchParams.get("visualEditor") === "true";
335
+ return searchParams.get(key) === "true";
330
336
  }
331
- const preview = searchParams.preview;
332
- const visualEditor = searchParams.visualEditor;
333
- return preview === "true" || visualEditor === "true";
337
+ const value = searchParams[key];
338
+ return value === "true" || Array.isArray(value) && value[0] === "true";
334
339
  }
335
340
  function isComposerPreview() {
336
341
  if (typeof window === "undefined") return false;
@@ -1466,6 +1471,9 @@ Available Console Commands:
1466
1471
  });
1467
1472
  if (preview) {
1468
1473
  params.set("preview", "true");
1474
+ if (typeof window !== "undefined" && isWorkingContentRequest(new URLSearchParams(window.location.search))) {
1475
+ params.set("working", "true");
1476
+ }
1469
1477
  }
1470
1478
  if (isOnOrchestratorOrigin) {
1471
1479
  return `/api/layout/provider?${params.toString()}`;
@@ -3828,12 +3836,14 @@ async function fetchPageConfigServer(route, trackingId, preview = false, options
3828
3836
  });
3829
3837
  const { orchestratorUrl, edgeUrl } = resolveAmplifyUpUrls(target);
3830
3838
  const previewFlag = preview || (options?.searchParams ? isPreviewRequest(options.searchParams) : false);
3839
+ const workingFlag = options?.searchParams ? isWorkingContentRequest(options.searchParams) : false;
3831
3840
  const fetchOrchestratorPage = async (pageRoute, isPreview) => {
3832
3841
  const params = new URLSearchParams({
3833
3842
  route: pageRoute,
3834
3843
  trackingId
3835
3844
  });
3836
3845
  if (isPreview) params.set("preview", "true");
3846
+ if (workingFlag) params.set("working", "true");
3837
3847
  const url = `${orchestratorUrl}/api/layout/provider?${params.toString()}`;
3838
3848
  try {
3839
3849
  const res = await fetch(url, {
@@ -4027,6 +4037,7 @@ exports.Slot = Slot;
4027
4037
  exports.fetchPageConfigServer = fetchPageConfigServer;
4028
4038
  exports.isComposerPreview = isComposerPreview;
4029
4039
  exports.isPreviewRequest = isPreviewRequest;
4040
+ exports.isWorkingContentRequest = isWorkingContentRequest;
4030
4041
  exports.useAmplifyUp = useAmplifyUp;
4031
4042
  exports.useComponentProps = useComponentProps;
4032
4043
  exports.useLiveComposerProps = useLiveComposerProps;