@payloadcms/next 3.0.0-beta.25 → 3.0.0-beta.27

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.
@@ -1,3 +1,3 @@
1
1
  export { GRAPHQL_PLAYGROUND_GET, GRAPHQL_POST } from './graphql/index.js';
2
- export { DELETE as REST_DELETE, GET as REST_GET, PATCH as REST_PATCH, POST as REST_POST, } from './rest/index.js';
2
+ export { DELETE as REST_DELETE, GET as REST_GET, OPTIONS as REST_OPTIONS, PATCH as REST_PATCH, POST as REST_POST, } from './rest/index.js';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/routes/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEzE,OAAO,EACL,MAAM,IAAI,WAAW,EACrB,GAAG,IAAI,QAAQ,EACf,KAAK,IAAI,UAAU,EACnB,IAAI,IAAI,SAAS,GAClB,MAAM,iBAAiB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/routes/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEzE,OAAO,EACL,MAAM,IAAI,WAAW,EACrB,GAAG,IAAI,QAAQ,EACf,OAAO,IAAI,YAAY,EACvB,KAAK,IAAI,UAAU,EACnB,IAAI,IAAI,SAAS,GAClB,MAAM,iBAAiB,CAAA"}
@@ -1,4 +1,4 @@
1
1
  export { GRAPHQL_PLAYGROUND_GET, GRAPHQL_POST } from './graphql/index.js';
2
- export { DELETE as REST_DELETE, GET as REST_GET, PATCH as REST_PATCH, POST as REST_POST } from './rest/index.js';
2
+ export { DELETE as REST_DELETE, GET as REST_GET, OPTIONS as REST_OPTIONS, PATCH as REST_PATCH, POST as REST_POST } from './rest/index.js';
3
3
 
4
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/routes/index.ts"],"sourcesContent":["export { GRAPHQL_PLAYGROUND_GET, GRAPHQL_POST } from './graphql/index.js'\n\nexport {\n DELETE as REST_DELETE,\n GET as REST_GET,\n PATCH as REST_PATCH,\n POST as REST_POST,\n} from './rest/index.js'\n"],"names":["GRAPHQL_PLAYGROUND_GET","GRAPHQL_POST","DELETE","REST_DELETE","GET","REST_GET","PATCH","REST_PATCH","POST","REST_POST"],"rangeMappings":";","mappings":"AAAA,SAASA,sBAAsB,EAAEC,YAAY,QAAQ,qBAAoB;AAEzE,SACEC,UAAUC,WAAW,EACrBC,OAAOC,QAAQ,EACfC,SAASC,UAAU,EACnBC,QAAQC,SAAS,QACZ,kBAAiB"}
1
+ {"version":3,"sources":["../../src/routes/index.ts"],"sourcesContent":["export { GRAPHQL_PLAYGROUND_GET, GRAPHQL_POST } from './graphql/index.js'\n\nexport {\n DELETE as REST_DELETE,\n GET as REST_GET,\n OPTIONS as REST_OPTIONS,\n PATCH as REST_PATCH,\n POST as REST_POST,\n} from './rest/index.js'\n"],"names":["GRAPHQL_PLAYGROUND_GET","GRAPHQL_POST","DELETE","REST_DELETE","GET","REST_GET","OPTIONS","REST_OPTIONS","PATCH","REST_PATCH","POST","REST_POST"],"rangeMappings":";","mappings":"AAAA,SAASA,sBAAsB,EAAEC,YAAY,QAAQ,qBAAoB;AAEzE,SACEC,UAAUC,WAAW,EACrBC,OAAOC,QAAQ,EACfC,WAAWC,YAAY,EACvBC,SAASC,UAAU,EACnBC,QAAQC,SAAS,QACZ,kBAAiB"}
@@ -7,6 +7,6 @@ type GetRequestLanguageArgs = {
7
7
  defaultLanguage?: AcceptedLanguages;
8
8
  headers: Request['headers'];
9
9
  };
10
- export declare const getRequestLanguage: ({ config, cookies, defaultLanguage, headers, }: GetRequestLanguageArgs) => AcceptedLanguages;
10
+ export declare const getRequestLanguage: ({ config, cookies, headers, }: GetRequestLanguageArgs) => AcceptedLanguages;
11
11
  export {};
12
12
  //# sourceMappingURL=getRequestLanguage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getRequestLanguage.d.ts","sourceRoot":"","sources":["../../src/utilities/getRequestLanguage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AACjE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iEAAiE,CAAA;AAC7G,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAIrD,KAAK,sBAAsB,GAAG;IAC5B,MAAM,EAAE,eAAe,CAAA;IACvB,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,sBAAsB,CAAA;IACrD,eAAe,CAAC,EAAE,iBAAiB,CAAA;IACnC,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC,CAAA;CAC5B,CAAA;AAED,eAAO,MAAM,kBAAkB,mDAK5B,sBAAsB,KAAG,iBAmB3B,CAAA"}
1
+ {"version":3,"file":"getRequestLanguage.d.ts","sourceRoot":"","sources":["../../src/utilities/getRequestLanguage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AACjE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iEAAiE,CAAA;AAC7G,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAIrD,KAAK,sBAAsB,GAAG;IAC5B,MAAM,EAAE,eAAe,CAAA;IACvB,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,sBAAsB,CAAA;IACrD,eAAe,CAAC,EAAE,iBAAiB,CAAA;IACnC,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC,CAAA;CAC5B,CAAA;AAED,eAAO,MAAM,kBAAkB,kCAI5B,sBAAsB,KAAG,iBAmB3B,CAAA"}
@@ -1,17 +1,16 @@
1
1
  import { extractHeaderLanguage } from '@payloadcms/translations';
2
- export const getRequestLanguage = ({ config, cookies, defaultLanguage = 'en', headers })=>{
2
+ export const getRequestLanguage = ({ config, cookies, headers })=>{
3
+ const supportedLanguageKeys = Object.keys(config.i18n.supportedLanguages);
3
4
  const langCookie = cookies.get(`${config.cookiePrefix || 'payload'}-lng`);
4
5
  const languageFromCookie = typeof langCookie === 'string' ? langCookie : langCookie?.value;
5
6
  const languageFromHeader = headers.get('Accept-Language') ? extractHeaderLanguage(headers.get('Accept-Language')) : undefined;
6
- const fallbackLang = config?.i18n?.fallbackLanguage || defaultLanguage;
7
- const supportedLanguageKeys = Object.keys(config?.i18n?.supportedLanguages || {});
8
7
  if (languageFromCookie && supportedLanguageKeys.includes(languageFromCookie)) {
9
8
  return languageFromCookie;
10
9
  }
11
10
  if (languageFromHeader && supportedLanguageKeys.includes(languageFromHeader)) {
12
11
  return languageFromHeader;
13
12
  }
14
- return supportedLanguageKeys.includes(fallbackLang) ? fallbackLang : 'en';
13
+ return config.i18n.fallbackLanguage;
15
14
  };
16
15
 
17
16
  //# sourceMappingURL=getRequestLanguage.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/getRequestLanguage.ts"],"sourcesContent":["import type { AcceptedLanguages } from '@payloadcms/translations'\nimport type { ReadonlyRequestCookies } from 'next/dist/server/web/spec-extension/adapters/request-cookies.js'\nimport type { SanitizedConfig } from 'payload/config'\n\nimport { extractHeaderLanguage } from '@payloadcms/translations'\n\ntype GetRequestLanguageArgs = {\n config: SanitizedConfig\n cookies: Map<string, string> | ReadonlyRequestCookies\n defaultLanguage?: AcceptedLanguages\n headers: Request['headers']\n}\n\nexport const getRequestLanguage = ({\n config,\n cookies,\n defaultLanguage = 'en',\n headers,\n}: GetRequestLanguageArgs): AcceptedLanguages => {\n const langCookie = cookies.get(`${config.cookiePrefix || 'payload'}-lng`)\n const languageFromCookie = typeof langCookie === 'string' ? langCookie : langCookie?.value\n const languageFromHeader = headers.get('Accept-Language')\n ? extractHeaderLanguage(headers.get('Accept-Language'))\n : undefined\n const fallbackLang = config?.i18n?.fallbackLanguage || defaultLanguage\n\n const supportedLanguageKeys = Object.keys(config?.i18n?.supportedLanguages || {})\n\n if (languageFromCookie && supportedLanguageKeys.includes(languageFromCookie)) {\n return languageFromCookie as AcceptedLanguages\n }\n\n if (languageFromHeader && supportedLanguageKeys.includes(languageFromHeader)) {\n return languageFromHeader\n }\n\n return supportedLanguageKeys.includes(fallbackLang) ? (fallbackLang as AcceptedLanguages) : 'en'\n}\n"],"names":["extractHeaderLanguage","getRequestLanguage","config","cookies","defaultLanguage","headers","langCookie","get","cookiePrefix","languageFromCookie","value","languageFromHeader","undefined","fallbackLang","i18n","fallbackLanguage","supportedLanguageKeys","Object","keys","supportedLanguages","includes"],"rangeMappings":";;;;;;;;;;;;;;","mappings":"AAIA,SAASA,qBAAqB,QAAQ,2BAA0B;AAShE,OAAO,MAAMC,qBAAqB,CAAC,EACjCC,MAAM,EACNC,OAAO,EACPC,kBAAkB,IAAI,EACtBC,OAAO,EACgB;IACvB,MAAMC,aAAaH,QAAQI,GAAG,CAAC,CAAC,EAAEL,OAAOM,YAAY,IAAI,UAAU,IAAI,CAAC;IACxE,MAAMC,qBAAqB,OAAOH,eAAe,WAAWA,aAAaA,YAAYI;IACrF,MAAMC,qBAAqBN,QAAQE,GAAG,CAAC,qBACnCP,sBAAsBK,QAAQE,GAAG,CAAC,sBAClCK;IACJ,MAAMC,eAAeX,QAAQY,MAAMC,oBAAoBX;IAEvD,MAAMY,wBAAwBC,OAAOC,IAAI,CAAChB,QAAQY,MAAMK,sBAAsB,CAAC;IAE/E,IAAIV,sBAAsBO,sBAAsBI,QAAQ,CAACX,qBAAqB;QAC5E,OAAOA;IACT;IAEA,IAAIE,sBAAsBK,sBAAsBI,QAAQ,CAACT,qBAAqB;QAC5E,OAAOA;IACT;IAEA,OAAOK,sBAAsBI,QAAQ,CAACP,gBAAiBA,eAAqC;AAC9F,EAAC"}
1
+ {"version":3,"sources":["../../src/utilities/getRequestLanguage.ts"],"sourcesContent":["import type { AcceptedLanguages } from '@payloadcms/translations'\nimport type { ReadonlyRequestCookies } from 'next/dist/server/web/spec-extension/adapters/request-cookies.js'\nimport type { SanitizedConfig } from 'payload/config'\n\nimport { extractHeaderLanguage } from '@payloadcms/translations'\n\ntype GetRequestLanguageArgs = {\n config: SanitizedConfig\n cookies: Map<string, string> | ReadonlyRequestCookies\n defaultLanguage?: AcceptedLanguages\n headers: Request['headers']\n}\n\nexport const getRequestLanguage = ({\n config,\n cookies,\n headers,\n}: GetRequestLanguageArgs): AcceptedLanguages => {\n const supportedLanguageKeys = <AcceptedLanguages[]>Object.keys(config.i18n.supportedLanguages)\n const langCookie = cookies.get(`${config.cookiePrefix || 'payload'}-lng`)\n const languageFromCookie: AcceptedLanguages = (\n typeof langCookie === 'string' ? langCookie : langCookie?.value\n ) as AcceptedLanguages\n const languageFromHeader = headers.get('Accept-Language')\n ? extractHeaderLanguage(headers.get('Accept-Language'))\n : undefined\n\n if (languageFromCookie && supportedLanguageKeys.includes(languageFromCookie)) {\n return languageFromCookie\n }\n\n if (languageFromHeader && supportedLanguageKeys.includes(languageFromHeader)) {\n return languageFromHeader\n }\n\n return config.i18n.fallbackLanguage\n}\n"],"names":["extractHeaderLanguage","getRequestLanguage","config","cookies","headers","supportedLanguageKeys","Object","keys","i18n","supportedLanguages","langCookie","get","cookiePrefix","languageFromCookie","value","languageFromHeader","undefined","includes","fallbackLanguage"],"rangeMappings":";;;;;;;;;;;;;","mappings":"AAIA,SAASA,qBAAqB,QAAQ,2BAA0B;AAShE,OAAO,MAAMC,qBAAqB,CAAC,EACjCC,MAAM,EACNC,OAAO,EACPC,OAAO,EACgB;IACvB,MAAMC,wBAA6CC,OAAOC,IAAI,CAACL,OAAOM,IAAI,CAACC,kBAAkB;IAC7F,MAAMC,aAAaP,QAAQQ,GAAG,CAAC,CAAC,EAAET,OAAOU,YAAY,IAAI,UAAU,IAAI,CAAC;IACxE,MAAMC,qBACJ,OAAOH,eAAe,WAAWA,aAAaA,YAAYI;IAE5D,MAAMC,qBAAqBX,QAAQO,GAAG,CAAC,qBACnCX,sBAAsBI,QAAQO,GAAG,CAAC,sBAClCK;IAEJ,IAAIH,sBAAsBR,sBAAsBY,QAAQ,CAACJ,qBAAqB;QAC5E,OAAOA;IACT;IAEA,IAAIE,sBAAsBV,sBAAsBY,QAAQ,CAACF,qBAAqB;QAC5E,OAAOA;IACT;IAEA,OAAOb,OAAOM,IAAI,CAACU,gBAAgB;AACrC,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/LivePreview/Preview/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAMlD,OAAO,KAAoB,MAAM,OAAO,CAAA;AAMxC,OAAO,cAAc,CAAA;AAIrB,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CA4F/C,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/LivePreview/Preview/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAMlD,OAAO,KAAoB,MAAM,OAAO,CAAA;AAMxC,OAAO,cAAc,CAAA;AAIrB,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CAgH/C,CAAA"}
@@ -15,6 +15,7 @@ export const LivePreview = (props)=>{
15
15
  const { breakpoint, fieldSchemaJSON } = useLivePreviewContext();
16
16
  const prevWindowType = React.useRef();
17
17
  const [fields] = useAllFormFields();
18
+ // For client-side apps, send data through `window.postMessage`
18
19
  // The preview could either be an iframe embedded on the page
19
20
  // Or it could be a separate popup window
20
21
  // We need to transmit data to both accordingly
@@ -55,6 +56,28 @@ export const LivePreview = (props)=>{
55
56
  fieldSchemaJSON,
56
57
  mostRecentUpdate
57
58
  ]);
59
+ // To support SSR, we transmit a `window.postMessage` event without a payload
60
+ // This is because the event will ultimately trigger a server-side roundtrip
61
+ // i.e., save, save draft, autosave, etc. will fire `router.refresh()`
62
+ useEffect(()=>{
63
+ const message = {
64
+ type: 'payload-document-event'
65
+ };
66
+ // Post message to external popup window
67
+ if (previewWindowType === 'popup' && popupRef.current) {
68
+ popupRef.current.postMessage(message, url);
69
+ }
70
+ // Post message to embedded iframe
71
+ if (previewWindowType === 'iframe' && iframeRef.current) {
72
+ iframeRef.current.contentWindow?.postMessage(message, url);
73
+ }
74
+ }, [
75
+ mostRecentUpdate,
76
+ iframeRef,
77
+ popupRef,
78
+ previewWindowType,
79
+ url
80
+ ]);
58
81
  if (previewWindowType === 'iframe') {
59
82
  return /*#__PURE__*/ React.createElement("div", {
60
83
  className: [
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/views/LivePreview/Preview/index.tsx"],"sourcesContent":["'use client'\n\nimport type { EditViewProps } from 'payload/types'\n\nimport { ShimmerEffect } from '@payloadcms/ui/elements/ShimmerEffect'\nimport { useAllFormFields } from '@payloadcms/ui/forms/Form'\nimport { useDocumentEvents } from '@payloadcms/ui/providers/DocumentEvents'\nimport { reduceFieldsToValues } from '@payloadcms/ui/utilities/reduceFieldsToValues'\nimport React, { useEffect } from 'react'\n\nimport { useLivePreviewContext } from '../Context/context.js'\nimport { DeviceContainer } from '../Device/index.js'\nimport { IFrame } from '../IFrame/index.js'\nimport { LivePreviewToolbar } from '../Toolbar/index.js'\nimport './index.scss'\n\nconst baseClass = 'live-preview-window'\n\nexport const LivePreview: React.FC<EditViewProps> = (props) => {\n const {\n appIsReady,\n iframeHasLoaded,\n iframeRef,\n popupRef,\n previewWindowType,\n setIframeHasLoaded,\n url,\n } = useLivePreviewContext()\n\n const { mostRecentUpdate } = useDocumentEvents()\n\n const { breakpoint, fieldSchemaJSON } = useLivePreviewContext()\n\n const prevWindowType =\n React.useRef<ReturnType<typeof useLivePreviewContext>['previewWindowType']>()\n\n const [fields] = useAllFormFields()\n\n // The preview could either be an iframe embedded on the page\n // Or it could be a separate popup window\n // We need to transmit data to both accordingly\n useEffect(() => {\n // For performance, do no reduce fields to values until after the iframe or popup has loaded\n if (fields && window && 'postMessage' in window && appIsReady) {\n const values = reduceFieldsToValues(fields, true)\n\n // To reduce on large `postMessage` payloads, only send `fieldSchemaToJSON` one time\n // To do this, the underlying JS function maintains a cache of this value\n // So we need to send it through each time the window type changes\n // But only once per window type change, not on every render, because this is a potentially large obj\n const shouldSendSchema =\n !prevWindowType.current || prevWindowType.current !== previewWindowType\n\n prevWindowType.current = previewWindowType\n\n const message = {\n type: 'payload-live-preview',\n data: values,\n externallyUpdatedRelationship: mostRecentUpdate,\n fieldSchemaJSON: shouldSendSchema ? fieldSchemaJSON : undefined,\n }\n\n // Post message to external popup window\n if (previewWindowType === 'popup' && popupRef.current) {\n popupRef.current.postMessage(message, url)\n }\n\n // Post message to embedded iframe\n if (previewWindowType === 'iframe' && iframeRef.current) {\n iframeRef.current.contentWindow?.postMessage(message, url)\n }\n }\n }, [\n fields,\n url,\n iframeHasLoaded,\n previewWindowType,\n popupRef,\n appIsReady,\n iframeRef,\n setIframeHasLoaded,\n fieldSchemaJSON,\n mostRecentUpdate,\n ])\n\n if (previewWindowType === 'iframe') {\n return (\n <div\n className={[\n baseClass,\n breakpoint && breakpoint !== 'responsive' && `${baseClass}--has-breakpoint`,\n ]\n .filter(Boolean)\n .join(' ')}\n >\n <div className={`${baseClass}__wrapper`}>\n <LivePreviewToolbar {...props} />\n <div className={`${baseClass}__main`}>\n <DeviceContainer>\n {url ? (\n <IFrame ref={iframeRef} setIframeHasLoaded={setIframeHasLoaded} url={url} />\n ) : (\n <ShimmerEffect height=\"100%\" />\n )}\n </DeviceContainer>\n </div>\n </div>\n </div>\n )\n }\n}\n"],"names":["ShimmerEffect","useAllFormFields","useDocumentEvents","reduceFieldsToValues","React","useEffect","useLivePreviewContext","DeviceContainer","IFrame","LivePreviewToolbar","baseClass","LivePreview","props","appIsReady","iframeHasLoaded","iframeRef","popupRef","previewWindowType","setIframeHasLoaded","url","mostRecentUpdate","breakpoint","fieldSchemaJSON","prevWindowType","useRef","fields","window","values","shouldSendSchema","current","message","type","data","externallyUpdatedRelationship","undefined","postMessage","contentWindow","div","className","filter","Boolean","join","ref","height"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAIA,SAASA,aAAa,QAAQ,wCAAuC;AACrE,SAASC,gBAAgB,QAAQ,4BAA2B;AAC5D,SAASC,iBAAiB,QAAQ,0CAAyC;AAC3E,SAASC,oBAAoB,QAAQ,gDAA+C;AACpF,OAAOC,SAASC,SAAS,QAAQ,QAAO;AAExC,SAASC,qBAAqB,QAAQ,wBAAuB;AAC7D,SAASC,eAAe,QAAQ,qBAAoB;AACpD,SAASC,MAAM,QAAQ,qBAAoB;AAC3C,SAASC,kBAAkB,QAAQ,sBAAqB;AAGxD,MAAMC,YAAY;AAElB,OAAO,MAAMC,cAAuC,CAACC;IACnD,MAAM,EACJC,UAAU,EACVC,eAAe,EACfC,SAAS,EACTC,QAAQ,EACRC,iBAAiB,EACjBC,kBAAkB,EAClBC,GAAG,EACJ,GAAGb;IAEJ,MAAM,EAAEc,gBAAgB,EAAE,GAAGlB;IAE7B,MAAM,EAAEmB,UAAU,EAAEC,eAAe,EAAE,GAAGhB;IAExC,MAAMiB,iBACJnB,MAAMoB,MAAM;IAEd,MAAM,CAACC,OAAO,GAAGxB;IAEjB,6DAA6D;IAC7D,yCAAyC;IACzC,+CAA+C;IAC/CI,UAAU;QACR,4FAA4F;QAC5F,IAAIoB,UAAUC,UAAU,iBAAiBA,UAAUb,YAAY;YAC7D,MAAMc,SAASxB,qBAAqBsB,QAAQ;YAE5C,oFAAoF;YACpF,yEAAyE;YACzE,kEAAkE;YAClE,qGAAqG;YACrG,MAAMG,mBACJ,CAACL,eAAeM,OAAO,IAAIN,eAAeM,OAAO,KAAKZ;YAExDM,eAAeM,OAAO,GAAGZ;YAEzB,MAAMa,UAAU;gBACdC,MAAM;gBACNC,MAAML;gBACNM,+BAA+Bb;gBAC/BE,iBAAiBM,mBAAmBN,kBAAkBY;YACxD;YAEA,wCAAwC;YACxC,IAAIjB,sBAAsB,WAAWD,SAASa,OAAO,EAAE;gBACrDb,SAASa,OAAO,CAACM,WAAW,CAACL,SAASX;YACxC;YAEA,kCAAkC;YAClC,IAAIF,sBAAsB,YAAYF,UAAUc,OAAO,EAAE;gBACvDd,UAAUc,OAAO,CAACO,aAAa,EAAED,YAAYL,SAASX;YACxD;QACF;IACF,GAAG;QACDM;QACAN;QACAL;QACAG;QACAD;QACAH;QACAE;QACAG;QACAI;QACAF;KACD;IAED,IAAIH,sBAAsB,UAAU;QAClC,qBACE,oBAACoB;YACCC,WAAW;gBACT5B;gBACAW,cAAcA,eAAe,gBAAgB,CAAC,EAAEX,UAAU,gBAAgB,CAAC;aAC5E,CACE6B,MAAM,CAACC,SACPC,IAAI,CAAC;yBAER,oBAACJ;YAAIC,WAAW,CAAC,EAAE5B,UAAU,SAAS,CAAC;yBACrC,oBAACD,oBAAuBG,sBACxB,oBAACyB;YAAIC,WAAW,CAAC,EAAE5B,UAAU,MAAM,CAAC;yBAClC,oBAACH,uBACEY,oBACC,oBAACX;YAAOkC,KAAK3B;YAAWG,oBAAoBA;YAAoBC,KAAKA;2BAErE,oBAACnB;YAAc2C,QAAO;;IAOpC;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../../src/views/LivePreview/Preview/index.tsx"],"sourcesContent":["'use client'\n\nimport type { EditViewProps } from 'payload/types'\n\nimport { ShimmerEffect } from '@payloadcms/ui/elements/ShimmerEffect'\nimport { useAllFormFields } from '@payloadcms/ui/forms/Form'\nimport { useDocumentEvents } from '@payloadcms/ui/providers/DocumentEvents'\nimport { reduceFieldsToValues } from '@payloadcms/ui/utilities/reduceFieldsToValues'\nimport React, { useEffect } from 'react'\n\nimport { useLivePreviewContext } from '../Context/context.js'\nimport { DeviceContainer } from '../Device/index.js'\nimport { IFrame } from '../IFrame/index.js'\nimport { LivePreviewToolbar } from '../Toolbar/index.js'\nimport './index.scss'\n\nconst baseClass = 'live-preview-window'\n\nexport const LivePreview: React.FC<EditViewProps> = (props) => {\n const {\n appIsReady,\n iframeHasLoaded,\n iframeRef,\n popupRef,\n previewWindowType,\n setIframeHasLoaded,\n url,\n } = useLivePreviewContext()\n\n const { mostRecentUpdate } = useDocumentEvents()\n\n const { breakpoint, fieldSchemaJSON } = useLivePreviewContext()\n\n const prevWindowType =\n React.useRef<ReturnType<typeof useLivePreviewContext>['previewWindowType']>()\n\n const [fields] = useAllFormFields()\n\n // For client-side apps, send data through `window.postMessage`\n // The preview could either be an iframe embedded on the page\n // Or it could be a separate popup window\n // We need to transmit data to both accordingly\n useEffect(() => {\n // For performance, do no reduce fields to values until after the iframe or popup has loaded\n if (fields && window && 'postMessage' in window && appIsReady) {\n const values = reduceFieldsToValues(fields, true)\n\n // To reduce on large `postMessage` payloads, only send `fieldSchemaToJSON` one time\n // To do this, the underlying JS function maintains a cache of this value\n // So we need to send it through each time the window type changes\n // But only once per window type change, not on every render, because this is a potentially large obj\n const shouldSendSchema =\n !prevWindowType.current || prevWindowType.current !== previewWindowType\n\n prevWindowType.current = previewWindowType\n\n const message = {\n type: 'payload-live-preview',\n data: values,\n externallyUpdatedRelationship: mostRecentUpdate,\n fieldSchemaJSON: shouldSendSchema ? fieldSchemaJSON : undefined,\n }\n\n // Post message to external popup window\n if (previewWindowType === 'popup' && popupRef.current) {\n popupRef.current.postMessage(message, url)\n }\n\n // Post message to embedded iframe\n if (previewWindowType === 'iframe' && iframeRef.current) {\n iframeRef.current.contentWindow?.postMessage(message, url)\n }\n }\n }, [\n fields,\n url,\n iframeHasLoaded,\n previewWindowType,\n popupRef,\n appIsReady,\n iframeRef,\n setIframeHasLoaded,\n fieldSchemaJSON,\n mostRecentUpdate,\n ])\n\n // To support SSR, we transmit a `window.postMessage` event without a payload\n // This is because the event will ultimately trigger a server-side roundtrip\n // i.e., save, save draft, autosave, etc. will fire `router.refresh()`\n useEffect(() => {\n const message = {\n type: 'payload-document-event',\n }\n\n // Post message to external popup window\n if (previewWindowType === 'popup' && popupRef.current) {\n popupRef.current.postMessage(message, url)\n }\n\n // Post message to embedded iframe\n if (previewWindowType === 'iframe' && iframeRef.current) {\n iframeRef.current.contentWindow?.postMessage(message, url)\n }\n }, [mostRecentUpdate, iframeRef, popupRef, previewWindowType, url])\n\n if (previewWindowType === 'iframe') {\n return (\n <div\n className={[\n baseClass,\n breakpoint && breakpoint !== 'responsive' && `${baseClass}--has-breakpoint`,\n ]\n .filter(Boolean)\n .join(' ')}\n >\n <div className={`${baseClass}__wrapper`}>\n <LivePreviewToolbar {...props} />\n <div className={`${baseClass}__main`}>\n <DeviceContainer>\n {url ? (\n <IFrame ref={iframeRef} setIframeHasLoaded={setIframeHasLoaded} url={url} />\n ) : (\n <ShimmerEffect height=\"100%\" />\n )}\n </DeviceContainer>\n </div>\n </div>\n </div>\n )\n }\n}\n"],"names":["ShimmerEffect","useAllFormFields","useDocumentEvents","reduceFieldsToValues","React","useEffect","useLivePreviewContext","DeviceContainer","IFrame","LivePreviewToolbar","baseClass","LivePreview","props","appIsReady","iframeHasLoaded","iframeRef","popupRef","previewWindowType","setIframeHasLoaded","url","mostRecentUpdate","breakpoint","fieldSchemaJSON","prevWindowType","useRef","fields","window","values","shouldSendSchema","current","message","type","data","externallyUpdatedRelationship","undefined","postMessage","contentWindow","div","className","filter","Boolean","join","ref","height"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAIA,SAASA,aAAa,QAAQ,wCAAuC;AACrE,SAASC,gBAAgB,QAAQ,4BAA2B;AAC5D,SAASC,iBAAiB,QAAQ,0CAAyC;AAC3E,SAASC,oBAAoB,QAAQ,gDAA+C;AACpF,OAAOC,SAASC,SAAS,QAAQ,QAAO;AAExC,SAASC,qBAAqB,QAAQ,wBAAuB;AAC7D,SAASC,eAAe,QAAQ,qBAAoB;AACpD,SAASC,MAAM,QAAQ,qBAAoB;AAC3C,SAASC,kBAAkB,QAAQ,sBAAqB;AAGxD,MAAMC,YAAY;AAElB,OAAO,MAAMC,cAAuC,CAACC;IACnD,MAAM,EACJC,UAAU,EACVC,eAAe,EACfC,SAAS,EACTC,QAAQ,EACRC,iBAAiB,EACjBC,kBAAkB,EAClBC,GAAG,EACJ,GAAGb;IAEJ,MAAM,EAAEc,gBAAgB,EAAE,GAAGlB;IAE7B,MAAM,EAAEmB,UAAU,EAAEC,eAAe,EAAE,GAAGhB;IAExC,MAAMiB,iBACJnB,MAAMoB,MAAM;IAEd,MAAM,CAACC,OAAO,GAAGxB;IAEjB,+DAA+D;IAC/D,6DAA6D;IAC7D,yCAAyC;IACzC,+CAA+C;IAC/CI,UAAU;QACR,4FAA4F;QAC5F,IAAIoB,UAAUC,UAAU,iBAAiBA,UAAUb,YAAY;YAC7D,MAAMc,SAASxB,qBAAqBsB,QAAQ;YAE5C,oFAAoF;YACpF,yEAAyE;YACzE,kEAAkE;YAClE,qGAAqG;YACrG,MAAMG,mBACJ,CAACL,eAAeM,OAAO,IAAIN,eAAeM,OAAO,KAAKZ;YAExDM,eAAeM,OAAO,GAAGZ;YAEzB,MAAMa,UAAU;gBACdC,MAAM;gBACNC,MAAML;gBACNM,+BAA+Bb;gBAC/BE,iBAAiBM,mBAAmBN,kBAAkBY;YACxD;YAEA,wCAAwC;YACxC,IAAIjB,sBAAsB,WAAWD,SAASa,OAAO,EAAE;gBACrDb,SAASa,OAAO,CAACM,WAAW,CAACL,SAASX;YACxC;YAEA,kCAAkC;YAClC,IAAIF,sBAAsB,YAAYF,UAAUc,OAAO,EAAE;gBACvDd,UAAUc,OAAO,CAACO,aAAa,EAAED,YAAYL,SAASX;YACxD;QACF;IACF,GAAG;QACDM;QACAN;QACAL;QACAG;QACAD;QACAH;QACAE;QACAG;QACAI;QACAF;KACD;IAED,6EAA6E;IAC7E,4EAA4E;IAC5E,sEAAsE;IACtEf,UAAU;QACR,MAAMyB,UAAU;YACdC,MAAM;QACR;QAEA,wCAAwC;QACxC,IAAId,sBAAsB,WAAWD,SAASa,OAAO,EAAE;YACrDb,SAASa,OAAO,CAACM,WAAW,CAACL,SAASX;QACxC;QAEA,kCAAkC;QAClC,IAAIF,sBAAsB,YAAYF,UAAUc,OAAO,EAAE;YACvDd,UAAUc,OAAO,CAACO,aAAa,EAAED,YAAYL,SAASX;QACxD;IACF,GAAG;QAACC;QAAkBL;QAAWC;QAAUC;QAAmBE;KAAI;IAElE,IAAIF,sBAAsB,UAAU;QAClC,qBACE,oBAACoB;YACCC,WAAW;gBACT5B;gBACAW,cAAcA,eAAe,gBAAgB,CAAC,EAAEX,UAAU,gBAAgB,CAAC;aAC5E,CACE6B,MAAM,CAACC,SACPC,IAAI,CAAC;yBAER,oBAACJ;YAAIC,WAAW,CAAC,EAAE5B,UAAU,SAAS,CAAC;yBACrC,oBAACD,oBAAuBG,sBACxB,oBAACyB;YAAIC,WAAW,CAAC,EAAE5B,UAAU,MAAM,CAAC;yBAClC,oBAACH,uBACEY,oBACC,oBAACX;YAAOkC,KAAK3B;YAAWG,oBAAoBA;YAAoBC,KAAKA;2BAErE,oBAACnB;YAAc2C,QAAO;;IAOpC;AACF,EAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/next",
3
- "version": "3.0.0-beta.25",
3
+ "version": "3.0.0-beta.27",
4
4
  "homepage": "https://payloadcms.com",
5
5
  "repository": {
6
6
  "type": "git",
@@ -44,9 +44,9 @@
44
44
  "react-toastify": "8.2.0",
45
45
  "sass": "^1.71.1",
46
46
  "ws": "^8.16.0",
47
- "@payloadcms/translations": "3.0.0-beta.25",
48
- "@payloadcms/ui": "3.0.0-beta.25",
49
- "@payloadcms/graphql": "3.0.0-beta.25"
47
+ "@payloadcms/graphql": "3.0.0-beta.27",
48
+ "@payloadcms/translations": "3.0.0-beta.27",
49
+ "@payloadcms/ui": "3.0.0-beta.27"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@next/eslint-plugin-next": "^14.1.0",
@@ -64,13 +64,13 @@
64
64
  "terser-webpack-plugin": "^5.3.10",
65
65
  "webpack": "^5.78.0",
66
66
  "webpack-cli": "^5.1.4",
67
- "payload": "3.0.0-beta.25",
68
- "@payloadcms/eslint-config": "1.1.1"
67
+ "@payloadcms/eslint-config": "1.1.1",
68
+ "payload": "3.0.0-beta.27"
69
69
  },
70
70
  "peerDependencies": {
71
71
  "graphql": "^16.8.1",
72
72
  "next": "^14.3.0-canary.7",
73
- "payload": "3.0.0-beta.25"
73
+ "payload": "3.0.0-beta.27"
74
74
  },
75
75
  "engines": {
76
76
  "node": ">=18.20.2"