@payloadcms/live-preview 3.2.2 → 3.2.3-canary.2d2e7d5

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 +1 @@
1
- {"version":3,"file":"handleMessage.d.ts","sourceRoot":"","sources":["../src/handleMessage.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,aAAa,GAAU,CAAC,QAAQ;IAC3C,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,YAAY,CAAA;IACnB,WAAW,EAAE,CAAC,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;CAClB,KAAG,OAAO,CAAC,CAAC,CAmCZ,CAAA"}
1
+ {"version":3,"file":"handleMessage.d.ts","sourceRoot":"","sources":["../src/handleMessage.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,aAAa,GAAU,CAAC,QAAQ;IAC3C,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,YAAY,CAAA;IACnB,WAAW,EAAE,CAAC,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;CAClB,KAAG,OAAO,CAAC,CAAC,CAoCZ,CAAA"}
@@ -28,6 +28,7 @@ export const handleMessage = async (args)=>{
28
28
  fieldSchema: payloadLivePreviewFieldSchema,
29
29
  incomingData: data,
30
30
  initialData: payloadLivePreviewPreviousData || initialData,
31
+ locale: event.data.locale,
31
32
  serverURL
32
33
  });
33
34
  payloadLivePreviewPreviousData = mergedData;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/handleMessage.ts"],"sourcesContent":["import { isLivePreviewEvent } from './isLivePreviewEvent.js'\nimport { mergeData } from './mergeData.js'\n\n// For performance reasons, `fieldSchemaJSON` will only be sent once on the initial message\n// We need to cache this value so that it can be used across subsequent messages\n// To do this, save `fieldSchemaJSON` when it arrives as a global variable\n// Send this cached value to `mergeData`, instead of `eventData.fieldSchemaJSON` directly\nlet payloadLivePreviewFieldSchema = undefined // TODO: type this from `fieldSchemaToJSON` return type\n\n// Each time the data is merged, cache the result as a `previousData` variable\n// This will ensure changes compound overtop of each other\nlet payloadLivePreviewPreviousData = undefined\n\nexport const handleMessage = async <T>(args: {\n apiRoute?: string\n depth?: number\n event: MessageEvent\n initialData: T\n serverURL: string\n}): Promise<T> => {\n const { apiRoute, depth, event, initialData, serverURL } = args\n\n if (isLivePreviewEvent(event, serverURL)) {\n const { data, externallyUpdatedRelationship, fieldSchemaJSON } = event.data\n\n if (!payloadLivePreviewFieldSchema && fieldSchemaJSON) {\n payloadLivePreviewFieldSchema = fieldSchemaJSON\n }\n\n if (!payloadLivePreviewFieldSchema) {\n // eslint-disable-next-line no-console\n console.warn(\n 'Payload Live Preview: No `fieldSchemaJSON` was received from the parent window. Unable to merge data.',\n )\n\n return initialData\n }\n\n const mergedData = await mergeData<T>({\n apiRoute,\n depth,\n externallyUpdatedRelationship,\n fieldSchema: payloadLivePreviewFieldSchema,\n incomingData: data,\n initialData: payloadLivePreviewPreviousData || initialData,\n serverURL,\n })\n\n payloadLivePreviewPreviousData = mergedData\n\n return mergedData\n }\n\n return initialData\n}\n"],"names":["isLivePreviewEvent","mergeData","payloadLivePreviewFieldSchema","undefined","payloadLivePreviewPreviousData","handleMessage","args","apiRoute","depth","event","initialData","serverURL","data","externallyUpdatedRelationship","fieldSchemaJSON","console","warn","mergedData","fieldSchema","incomingData"],"mappings":"AAAA,SAASA,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,SAAS,QAAQ,iBAAgB;AAE1C,2FAA2F;AAC3F,gFAAgF;AAChF,0EAA0E;AAC1E,yFAAyF;AACzF,IAAIC,gCAAgCC,UAAU,uDAAuD;;AAErG,8EAA8E;AAC9E,0DAA0D;AAC1D,IAAIC,iCAAiCD;AAErC,OAAO,MAAME,gBAAgB,OAAUC;IAOrC,MAAM,EAAEC,QAAQ,EAAEC,KAAK,EAAEC,KAAK,EAAEC,WAAW,EAAEC,SAAS,EAAE,GAAGL;IAE3D,IAAIN,mBAAmBS,OAAOE,YAAY;QACxC,MAAM,EAAEC,IAAI,EAAEC,6BAA6B,EAAEC,eAAe,EAAE,GAAGL,MAAMG,IAAI;QAE3E,IAAI,CAACV,iCAAiCY,iBAAiB;YACrDZ,gCAAgCY;QAClC;QAEA,IAAI,CAACZ,+BAA+B;YAClC,sCAAsC;YACtCa,QAAQC,IAAI,CACV;YAGF,OAAON;QACT;QAEA,MAAMO,aAAa,MAAMhB,UAAa;YACpCM;YACAC;YACAK;YACAK,aAAahB;YACbiB,cAAcP;YACdF,aAAaN,kCAAkCM;YAC/CC;QACF;QAEAP,iCAAiCa;QAEjC,OAAOA;IACT;IAEA,OAAOP;AACT,EAAC"}
1
+ {"version":3,"sources":["../src/handleMessage.ts"],"sourcesContent":["import { isLivePreviewEvent } from './isLivePreviewEvent.js'\nimport { mergeData } from './mergeData.js'\n\n// For performance reasons, `fieldSchemaJSON` will only be sent once on the initial message\n// We need to cache this value so that it can be used across subsequent messages\n// To do this, save `fieldSchemaJSON` when it arrives as a global variable\n// Send this cached value to `mergeData`, instead of `eventData.fieldSchemaJSON` directly\nlet payloadLivePreviewFieldSchema = undefined // TODO: type this from `fieldSchemaToJSON` return type\n\n// Each time the data is merged, cache the result as a `previousData` variable\n// This will ensure changes compound overtop of each other\nlet payloadLivePreviewPreviousData = undefined\n\nexport const handleMessage = async <T>(args: {\n apiRoute?: string\n depth?: number\n event: MessageEvent\n initialData: T\n serverURL: string\n}): Promise<T> => {\n const { apiRoute, depth, event, initialData, serverURL } = args\n\n if (isLivePreviewEvent(event, serverURL)) {\n const { data, externallyUpdatedRelationship, fieldSchemaJSON } = event.data\n\n if (!payloadLivePreviewFieldSchema && fieldSchemaJSON) {\n payloadLivePreviewFieldSchema = fieldSchemaJSON\n }\n\n if (!payloadLivePreviewFieldSchema) {\n // eslint-disable-next-line no-console\n console.warn(\n 'Payload Live Preview: No `fieldSchemaJSON` was received from the parent window. Unable to merge data.',\n )\n\n return initialData\n }\n\n const mergedData = await mergeData<T>({\n apiRoute,\n depth,\n externallyUpdatedRelationship,\n fieldSchema: payloadLivePreviewFieldSchema,\n incomingData: data,\n initialData: payloadLivePreviewPreviousData || initialData,\n locale: event.data.locale,\n serverURL,\n })\n\n payloadLivePreviewPreviousData = mergedData\n\n return mergedData\n }\n\n return initialData\n}\n"],"names":["isLivePreviewEvent","mergeData","payloadLivePreviewFieldSchema","undefined","payloadLivePreviewPreviousData","handleMessage","args","apiRoute","depth","event","initialData","serverURL","data","externallyUpdatedRelationship","fieldSchemaJSON","console","warn","mergedData","fieldSchema","incomingData","locale"],"mappings":"AAAA,SAASA,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,SAAS,QAAQ,iBAAgB;AAE1C,2FAA2F;AAC3F,gFAAgF;AAChF,0EAA0E;AAC1E,yFAAyF;AACzF,IAAIC,gCAAgCC,UAAU,uDAAuD;;AAErG,8EAA8E;AAC9E,0DAA0D;AAC1D,IAAIC,iCAAiCD;AAErC,OAAO,MAAME,gBAAgB,OAAUC;IAOrC,MAAM,EAAEC,QAAQ,EAAEC,KAAK,EAAEC,KAAK,EAAEC,WAAW,EAAEC,SAAS,EAAE,GAAGL;IAE3D,IAAIN,mBAAmBS,OAAOE,YAAY;QACxC,MAAM,EAAEC,IAAI,EAAEC,6BAA6B,EAAEC,eAAe,EAAE,GAAGL,MAAMG,IAAI;QAE3E,IAAI,CAACV,iCAAiCY,iBAAiB;YACrDZ,gCAAgCY;QAClC;QAEA,IAAI,CAACZ,+BAA+B;YAClC,sCAAsC;YACtCa,QAAQC,IAAI,CACV;YAGF,OAAON;QACT;QAEA,MAAMO,aAAa,MAAMhB,UAAa;YACpCM;YACAC;YACAK;YACAK,aAAahB;YACbiB,cAAcP;YACdF,aAAaN,kCAAkCM;YAC/CU,QAAQX,MAAMG,IAAI,CAACQ,MAAM;YACzBT;QACF;QAEAP,iCAAiCa;QAEjC,OAAOA;IACT;IAEA,OAAOP;AACT,EAAC"}
@@ -12,6 +12,7 @@ export declare const mergeData: <T>(args: {
12
12
  fieldSchema: ReturnType<typeof fieldSchemaToJSON>;
13
13
  incomingData: Partial<T>;
14
14
  initialData: T;
15
+ locale?: string;
15
16
  returnNumberOfRequests?: boolean;
16
17
  serverURL: string;
17
18
  }) => Promise<{
@@ -1 +1 @@
1
- {"version":3,"file":"mergeData.d.ts","sourceRoot":"","sources":["../src/mergeData.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAEvD,OAAO,KAAK,EAA2B,eAAe,EAAE,MAAM,YAAY,CAAA;AAc1E,eAAO,MAAM,SAAS,GAAU,CAAC,QAAQ;IACvC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,kCAAkC,CAAC,EAAE,CAAC,EACpC,OAAO,EACP,QAAQ,EACR,SAAS,GACV,EAAE;QACD,OAAO,EAAE,MAAM,CAAA;QACf,QAAQ,EAAE,MAAM,CAAA;QAChB,SAAS,EAAE,MAAM,CAAA;KAClB,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;IACvB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,6BAA6B,CAAC,EAAE,eAAe,CAAA;IAC/C,WAAW,EAAE,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAA;IACjD,YAAY,EAAE,OAAO,CAAC,CAAC,CAAC,CAAA;IACxB,WAAW,EAAE,CAAC,CAAA;IACd,sBAAsB,CAAC,EAAE,OAAO,CAAA;IAChC,SAAS,EAAE,MAAM,CAAA;CAClB,KAAG,OAAO,CACT;IACE,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAC3B,GAAG,CAAC,CA8DN,CAAA"}
1
+ {"version":3,"file":"mergeData.d.ts","sourceRoot":"","sources":["../src/mergeData.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAEvD,OAAO,KAAK,EAA2B,eAAe,EAAE,MAAM,YAAY,CAAA;AAmB1E,eAAO,MAAM,SAAS,GAAU,CAAC,QAAQ;IACvC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,kCAAkC,CAAC,EAAE,CAAC,EACpC,OAAO,EACP,QAAQ,EACR,SAAS,GACV,EAAE;QACD,OAAO,EAAE,MAAM,CAAA;QACf,QAAQ,EAAE,MAAM,CAAA;QAChB,SAAS,EAAE,MAAM,CAAA;KAClB,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;IACvB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,6BAA6B,CAAC,EAAE,eAAe,CAAA;IAC/C,WAAW,EAAE,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAA;IACjD,YAAY,EAAE,OAAO,CAAC,CAAC,CAAC,CAAA;IACxB,WAAW,EAAE,CAAC,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,sBAAsB,CAAC,EAAE,OAAO,CAAA;IAChC,SAAS,EAAE,MAAM,CAAA;CAClB,KAAG,OAAO,CACT;IACE,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAC3B,GAAG,CAAC,CAkEN,CAAA"}
package/dist/mergeData.js CHANGED
@@ -8,8 +8,12 @@ const defaultRequestHandler = ({ apiPath, endpoint, serverURL })=>{
8
8
  }
9
9
  });
10
10
  };
11
+ // Relationships are only updated when their `id` or `relationTo` changes, by comparing the old and new values
12
+ // This needs to also happen when locale changes, except this is not not part of the API response
13
+ // Instead, we keep track of the old locale ourselves and trigger a re-population when it changes
14
+ let prevLocale;
11
15
  export const mergeData = async (args)=>{
12
- const { apiRoute, depth, externallyUpdatedRelationship, fieldSchema, incomingData, initialData, returnNumberOfRequests, serverURL } = args;
16
+ const { apiRoute, depth, externallyUpdatedRelationship, fieldSchema, incomingData, initialData, locale, returnNumberOfRequests, serverURL } = args;
13
17
  const result = {
14
18
  ...initialData
15
19
  };
@@ -18,6 +22,7 @@ export const mergeData = async (args)=>{
18
22
  externallyUpdatedRelationship,
19
23
  fieldSchema,
20
24
  incomingData,
25
+ localeChanged: prevLocale !== locale,
21
26
  populationsByCollection,
22
27
  result
23
28
  });
@@ -28,7 +33,7 @@ export const mergeData = async (args)=>{
28
33
  try {
29
34
  res = await requestHandler({
30
35
  apiPath: apiRoute || '/api',
31
- endpoint: encodeURI(`${collection}?depth=${depth}&where[id][in]=${Array.from(ids).join(',')}`),
36
+ endpoint: encodeURI(`${collection}?depth=${depth}&where[id][in]=${Array.from(ids).join(',')}${locale ? `&locale=${locale}` : ''}`),
32
37
  serverURL
33
38
  }).then((res)=>res.json());
34
39
  if (res?.docs?.length > 0) {
@@ -45,6 +50,7 @@ export const mergeData = async (args)=>{
45
50
  ;
46
51
  }
47
52
  }));
53
+ prevLocale = locale;
48
54
  return {
49
55
  ...result,
50
56
  ...returnNumberOfRequests ? {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/mergeData.ts"],"sourcesContent":["import type { PaginatedDocs } from 'payload'\nimport type { fieldSchemaToJSON } from 'payload/shared'\n\nimport type { PopulationsByCollection, UpdatedDocument } from './types.js'\n\nimport { traverseFields } from './traverseFields.js'\n\nconst defaultRequestHandler = ({ apiPath, endpoint, serverURL }) => {\n const url = `${serverURL}${apiPath}/${endpoint}`\n return fetch(url, {\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n })\n}\n\nexport const mergeData = async <T>(args: {\n apiRoute?: string\n collectionPopulationRequestHandler?: ({\n apiPath,\n endpoint,\n serverURL,\n }: {\n apiPath: string\n endpoint: string\n serverURL: string\n }) => Promise<Response>\n depth?: number\n externallyUpdatedRelationship?: UpdatedDocument\n fieldSchema: ReturnType<typeof fieldSchemaToJSON>\n incomingData: Partial<T>\n initialData: T\n returnNumberOfRequests?: boolean\n serverURL: string\n}): Promise<\n {\n _numberOfRequests?: number\n } & T\n> => {\n const {\n apiRoute,\n depth,\n externallyUpdatedRelationship,\n fieldSchema,\n incomingData,\n initialData,\n returnNumberOfRequests,\n serverURL,\n } = args\n\n const result = { ...initialData }\n\n const populationsByCollection: PopulationsByCollection = {}\n\n traverseFields({\n externallyUpdatedRelationship,\n fieldSchema,\n incomingData,\n populationsByCollection,\n result,\n })\n\n await Promise.all(\n Object.entries(populationsByCollection).map(async ([collection, populations]) => {\n let res: PaginatedDocs\n\n const ids = new Set(populations.map(({ id }) => id))\n const requestHandler = args.collectionPopulationRequestHandler || defaultRequestHandler\n\n try {\n res = await requestHandler({\n apiPath: apiRoute || '/api',\n endpoint: encodeURI(\n `${collection}?depth=${depth}&where[id][in]=${Array.from(ids).join(',')}`,\n ),\n serverURL,\n }).then((res) => res.json())\n\n if (res?.docs?.length > 0) {\n res.docs.forEach((doc) => {\n populationsByCollection[collection].forEach((population) => {\n if (population.id === doc.id) {\n population.ref[population.accessor] = doc\n }\n })\n })\n }\n } catch (err) {\n console.error(err) // eslint-disable-line no-console\n }\n }),\n )\n\n return {\n ...result,\n ...(returnNumberOfRequests\n ? { _numberOfRequests: Object.keys(populationsByCollection).length }\n : {}),\n }\n}\n"],"names":["traverseFields","defaultRequestHandler","apiPath","endpoint","serverURL","url","fetch","credentials","headers","mergeData","args","apiRoute","depth","externallyUpdatedRelationship","fieldSchema","incomingData","initialData","returnNumberOfRequests","result","populationsByCollection","Promise","all","Object","entries","map","collection","populations","res","ids","Set","id","requestHandler","collectionPopulationRequestHandler","encodeURI","Array","from","join","then","json","docs","length","forEach","doc","population","ref","accessor","err","console","error","_numberOfRequests","keys"],"mappings":"AAKA,SAASA,cAAc,QAAQ,sBAAqB;AAEpD,MAAMC,wBAAwB,CAAC,EAAEC,OAAO,EAAEC,QAAQ,EAAEC,SAAS,EAAE;IAC7D,MAAMC,MAAM,CAAC,EAAED,UAAU,EAAEF,QAAQ,CAAC,EAAEC,SAAS,CAAC;IAChD,OAAOG,MAAMD,KAAK;QAChBE,aAAa;QACbC,SAAS;YACP,gBAAgB;QAClB;IACF;AACF;AAEA,OAAO,MAAMC,YAAY,OAAUC;IAu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CAAC;IACR;AACF,EAAC"}
1
+ {"version":3,"sources":["../src/mergeData.ts"],"sourcesContent":["import type { PaginatedDocs } from 'payload'\nimport type { fieldSchemaToJSON } from 'payload/shared'\n\nimport type { PopulationsByCollection, UpdatedDocument } from './types.js'\n\nimport { traverseFields } from './traverseFields.js'\n\nconst defaultRequestHandler = ({ apiPath, endpoint, serverURL }) => {\n const url = `${serverURL}${apiPath}/${endpoint}`\n return fetch(url, {\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n })\n}\n\n// Relationships are only updated when their `id` or `relationTo` changes, by comparing the old and new values\n// This needs to also happen when locale changes, except this is not not part of the API response\n// Instead, we keep track of the old locale ourselves and trigger a re-population when it changes\nlet prevLocale: string | undefined\n\nexport const mergeData = async <T>(args: {\n apiRoute?: string\n collectionPopulationRequestHandler?: ({\n apiPath,\n endpoint,\n serverURL,\n }: {\n apiPath: string\n endpoint: string\n serverURL: string\n }) => Promise<Response>\n depth?: number\n externallyUpdatedRelationship?: UpdatedDocument\n fieldSchema: ReturnType<typeof fieldSchemaToJSON>\n incomingData: Partial<T>\n initialData: T\n locale?: string\n returnNumberOfRequests?: boolean\n serverURL: string\n}): Promise<\n {\n _numberOfRequests?: number\n } & T\n> => {\n const {\n apiRoute,\n depth,\n externallyUpdatedRelationship,\n fieldSchema,\n incomingData,\n initialData,\n locale,\n returnNumberOfRequests,\n serverURL,\n } = args\n\n const result = { ...initialData }\n\n const populationsByCollection: PopulationsByCollection = {}\n\n traverseFields({\n externallyUpdatedRelationship,\n fieldSchema,\n incomingData,\n localeChanged: prevLocale !== locale,\n populationsByCollection,\n result,\n })\n\n await Promise.all(\n Object.entries(populationsByCollection).map(async ([collection, populations]) => {\n let res: PaginatedDocs\n\n const ids = new Set(populations.map(({ id }) => id))\n const requestHandler = args.collectionPopulationRequestHandler || defaultRequestHandler\n\n try {\n res = await requestHandler({\n apiPath: apiRoute || '/api',\n endpoint: encodeURI(\n `${collection}?depth=${depth}&where[id][in]=${Array.from(ids).join(',')}${locale ? `&locale=${locale}` : ''}`,\n ),\n serverURL,\n }).then((res) => res.json())\n\n if (res?.docs?.length > 0) {\n res.docs.forEach((doc) => {\n populationsByCollection[collection].forEach((population) => {\n if (population.id === doc.id) {\n population.ref[population.accessor] = doc\n }\n })\n })\n }\n } catch (err) {\n console.error(err) // eslint-disable-line no-console\n }\n }),\n )\n\n prevLocale = locale\n\n return {\n ...result,\n ...(returnNumberOfRequests\n ? { _numberOfRequests: Object.keys(populationsByCollection).length }\n : {}),\n }\n}\n"],"names":["traverseFields","defaultRequestHandler","apiPath","endpoint","serverURL","url","fetch","credentials","headers","prevLocale","mergeData","args","apiRoute","depth","externallyUpdatedRelationship","fieldSchema","incomingData","initialData","locale","returnNumberOfRequests","result","populationsByCollection","localeChanged","Promise","all","Object","entries","map","collection","populations","res","ids","Set","id","requestHandler","collectionPopulationRequestHandler","encodeURI","Array","from","join","then","json","docs","length","forEach","doc","population","ref","accessor","err","console","error","_numberOfRequests","keys"],"mappings":"AAKA,SAASA,cAAc,QAAQ,sBAAqB;AAEpD,MAAMC,wBAAwB,CAAC,EAAEC,OAAO,EAAEC,QAAQ,EAAEC,SAAS,EAAE;IAC7D,MAAMC,MAAM,CAAC,EAAED,UAAU,EAAEF,QAAQ,CAAC,EAAEC,SAAS,CAAC;IAChD,OAAOG,MAAMD,KAAK;QAChBE,aAAa;QACbC,SAAS;YACP,gBAAgB;QAClB;IACF;AACF;AAEA,8GAA8G;AAC9G,iGAAiG;AACjG,iGAAiG;AACjG,IAAIC;AAEJ,OAAO,MAAMC,YAAY,OAAUC;IAwBjC,MAAM,EACJC,QAAQ,EACRC,KAAK,EACLC,6BAA6B,EAC7BC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,MAAM,EACNC,sBAAsB,EACtBf,SAAS,EACV,GAAGO;IAEJ,MAAMS,SAAS;QAAE,GAAGH,WAAW;IAAC;IAEhC,MAAMI,0BAAmD,CAAC;IAE1DrB,eAAe;QACbc;QACAC;QACAC;QACAM,eAAeb,eAAeS;QAC9BG;QACAD;IACF;IAEA,MAAMG,QAAQC,GAAG,CACfC,OAAOC,OAAO,CAACL,yBAAyBM,GAAG,CAAC,OAAO,CAACC,YAAYC,YAAY;QAC1E,IAAIC;QAEJ,MAAMC,MAAM,IAAIC,IAAIH,YAAYF,GAAG,CAAC,CAAC,EAAEM,EAAE,EAAE,GAAKA;QAChD,MAAMC,iBAAiBvB,KAAKwB,kCAAkC,IAAIlC;QAElE,IAAI;YACF6B,MAAM,MAAMI,eAAe;gBACzBhC,SAASU,YAAY;gBACrBT,UAAUiC,UACR,CAAC,EAAER,WAAW,OAAO,EAAEf,MAAM,eAAe,EAAEwB,MAAMC,IAAI,CAACP,KAAKQ,IAAI,CAAC,KAAK,EAAErB,SAAS,CAAC,QAAQ,EAAEA,OAAO,CAAC,GAAG,GAAG,CAAC;gBAE/Gd;YACF,GAAGoC,IAAI,CAAC,CAACV,MAAQA,IAAIW,IAAI;YAEzB,IAAIX,KAAKY,MAAMC,SAAS,GAAG;gBACzBb,IAAIY,IAAI,CAACE,OAAO,CAAC,CAACC;oBAChBxB,uBAAuB,CAACO,WAAW,CAACgB,OAAO,CAAC,CAACE;wBAC3C,IAAIA,WAAWb,EAAE,KAAKY,IAAIZ,EAAE,EAAE;4BAC5Ba,WAAWC,GAAG,CAACD,WAAWE,QAAQ,CAAC,GAAGH;wBACxC;oBACF;gBACF;YACF;QACF,EAAE,OAAOI,KAAK;YACZC,QAAQC,KAAK,CAACF,KAAK,iCAAiC;;QACtD;IACF;IAGFxC,aAAaS;IAEb,OAAO;QACL,GAAGE,MAAM;QACT,GAAID,yBACA;YAAEiC,mBAAmB3B,OAAO4B,IAAI,CAAChC,yBAAyBsB,MAAM;QAAC,IACjE,CAAC,CAAC;IACR;AACF,EAAC"}
@@ -4,5 +4,5 @@ export declare const subscribe: <T>(args: {
4
4
  depth?: number;
5
5
  initialData: T;
6
6
  serverURL: string;
7
- }) => ((event: MessageEvent) => void);
7
+ }) => ((event: MessageEvent) => Promise<void> | void);
8
8
  //# sourceMappingURL=subscribe.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"subscribe.d.ts","sourceRoot":"","sources":["../src/subscribe.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS,GAAI,CAAC,QAAQ;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAAA;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,CAAC,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;CAClB,KAAG,CAAC,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAoBjC,CAAA"}
1
+ {"version":3,"file":"subscribe.d.ts","sourceRoot":"","sources":["../src/subscribe.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS,GAAI,CAAC,QAAQ;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAAA;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,CAAC,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;CAClB,KAAG,CAAC,CAAC,KAAK,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAoBjD,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/subscribe.ts"],"sourcesContent":["import { handleMessage } from './handleMessage.js'\n\nexport const subscribe = <T>(args: {\n apiRoute?: string\n callback: (data: T) => void\n depth?: number\n initialData: T\n serverURL: string\n}): ((event: MessageEvent) => void) => {\n const { apiRoute, callback, depth, initialData, serverURL } = args\n\n const onMessage = async (event: MessageEvent) => {\n const mergedData = await handleMessage<T>({\n apiRoute,\n depth,\n event,\n initialData,\n serverURL,\n })\n\n callback(mergedData)\n }\n\n if (typeof window !== 'undefined') {\n window.addEventListener('message', onMessage)\n }\n\n return onMessage\n}\n"],"names":["handleMessage","subscribe","args","apiRoute","callback","depth","initialData","serverURL","onMessage","event","mergedData","window","addEventListener"],"mappings":"AAAA,SAASA,aAAa,QAAQ,qBAAoB;AAElD,OAAO,MAAMC,YAAY,CAAIC;IAO3B,MAAM,EAAEC,QAAQ,EAAEC,QAAQ,EAAEC,KAAK,EAAEC,WAAW,EAAEC,SAAS,EAAE,GAAGL;IAE9D,MAAMM,YAAY,OAAOC;QACvB,MAAMC,aAAa,MAAMV,cAAiB;YACxCG;YACAE;YACAI;YACAH;YACAC;QACF;QAEAH,SAASM;IACX;IAEA,IAAI,OAAOC,WAAW,aAAa;QACjCA,OAAOC,gBAAgB,CAAC,WAAWJ;IACrC;IAEA,OAAOA;AACT,EAAC"}
1
+ {"version":3,"sources":["../src/subscribe.ts"],"sourcesContent":["import { handleMessage } from './handleMessage.js'\n\nexport const subscribe = <T>(args: {\n apiRoute?: string\n callback: (data: T) => void\n depth?: number\n initialData: T\n serverURL: string\n}): ((event: MessageEvent) => Promise<void> | void) => {\n const { apiRoute, callback, depth, initialData, serverURL } = args\n\n const onMessage = async (event: MessageEvent) => {\n const mergedData = await handleMessage<T>({\n apiRoute,\n depth,\n event,\n initialData,\n serverURL,\n })\n\n callback(mergedData)\n }\n\n if (typeof window !== 'undefined') {\n window.addEventListener('message', onMessage)\n }\n\n return onMessage\n}\n"],"names":["handleMessage","subscribe","args","apiRoute","callback","depth","initialData","serverURL","onMessage","event","mergedData","window","addEventListener"],"mappings":"AAAA,SAASA,aAAa,QAAQ,qBAAoB;AAElD,OAAO,MAAMC,YAAY,CAAIC;IAO3B,MAAM,EAAEC,QAAQ,EAAEC,QAAQ,EAAEC,KAAK,EAAEC,WAAW,EAAEC,SAAS,EAAE,GAAGL;IAE9D,MAAMM,YAAY,OAAOC;QACvB,MAAMC,aAAa,MAAMV,cAAiB;YACxCG;YACAE;YACAI;YACAH;YACAC;QACF;QAEAH,SAASM;IACX;IAEA,IAAI,OAAOC,WAAW,aAAa;QACjCA,OAAOC,gBAAgB,CAAC,WAAWJ;IACrC;IAEA,OAAOA;AACT,EAAC"}
@@ -4,6 +4,7 @@ export declare const traverseFields: <T>(args: {
4
4
  externallyUpdatedRelationship?: UpdatedDocument;
5
5
  fieldSchema: ReturnType<typeof fieldSchemaToJSON>;
6
6
  incomingData: T;
7
+ localeChanged: boolean;
7
8
  populationsByCollection: PopulationsByCollection;
8
9
  result: T;
9
10
  }) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"traverseFields.d.ts","sourceRoot":"","sources":["../src/traverseFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAEvD,OAAO,KAAK,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAI1E,eAAO,MAAM,cAAc,GAAI,CAAC,QAAQ;IACtC,6BAA6B,CAAC,EAAE,eAAe,CAAA;IAC/C,WAAW,EAAE,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAA;IACjD,YAAY,EAAE,CAAC,CAAA;IACf,uBAAuB,EAAE,uBAAuB,CAAA;IAChD,MAAM,EAAE,CAAC,CAAA;CACV,KAAG,IAqRH,CAAA"}
1
+ {"version":3,"file":"traverseFields.d.ts","sourceRoot":"","sources":["../src/traverseFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAEvD,OAAO,KAAK,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAI1E,eAAO,MAAM,cAAc,GAAI,CAAC,QAAQ;IACtC,6BAA6B,CAAC,EAAE,eAAe,CAAA;IAC/C,WAAW,EAAE,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAA;IACjD,YAAY,EAAE,CAAC,CAAA;IACf,aAAa,EAAE,OAAO,CAAA;IACtB,uBAAuB,EAAE,uBAAuB,CAAA;IAChD,MAAM,EAAE,CAAC,CAAA;CACV,KAAG,IA6RH,CAAA"}
@@ -1,6 +1,6 @@
1
1
  import { traverseRichText } from './traverseRichText.js';
2
2
  export const traverseFields = (args)=>{
3
- const { externallyUpdatedRelationship, fieldSchema: fieldSchemas, incomingData, populationsByCollection, result } = args;
3
+ const { externallyUpdatedRelationship, fieldSchema: fieldSchemas, incomingData, localeChanged, populationsByCollection, result } = args;
4
4
  fieldSchemas.forEach((fieldSchema)=>{
5
5
  if ('name' in fieldSchema && typeof fieldSchema.name === 'string') {
6
6
  const fieldName = fieldSchema.name;
@@ -21,6 +21,7 @@ export const traverseFields = (args)=>{
21
21
  externallyUpdatedRelationship,
22
22
  fieldSchema: fieldSchema.fields,
23
23
  incomingData: incomingRow,
24
+ localeChanged,
24
25
  populationsByCollection,
25
26
  result: result[fieldName][i]
26
27
  });
@@ -44,6 +45,7 @@ export const traverseFields = (args)=>{
44
45
  externallyUpdatedRelationship,
45
46
  fieldSchema: incomingBlockJSON.fields,
46
47
  incomingData: incomingBlock,
48
+ localeChanged,
47
49
  populationsByCollection,
48
50
  result: result[fieldName][i]
49
51
  });
@@ -63,6 +65,7 @@ export const traverseFields = (args)=>{
63
65
  externallyUpdatedRelationship,
64
66
  fieldSchema: fieldSchema.fields,
65
67
  incomingData: incomingData[fieldName] || {},
68
+ localeChanged,
66
69
  populationsByCollection,
67
70
  result: result[fieldName]
68
71
  });
@@ -91,7 +94,7 @@ export const traverseFields = (args)=>{
91
94
  const newRelation = incomingRelation.relationTo;
92
95
  const hasChanged = newID !== oldID || newRelation !== oldRelation;
93
96
  const hasUpdated = newRelation === externallyUpdatedRelationship?.entitySlug && newID === externallyUpdatedRelationship?.id;
94
- if (hasChanged || hasUpdated) {
97
+ if (hasChanged || hasUpdated || localeChanged) {
95
98
  if (!populationsByCollection[newRelation]) {
96
99
  populationsByCollection[newRelation] = [];
97
100
  }
@@ -105,7 +108,7 @@ export const traverseFields = (args)=>{
105
108
  // Handle `hasMany` monomorphic
106
109
  const hasChanged = incomingRelation !== result[fieldName][i]?.id;
107
110
  const hasUpdated = fieldSchema.relationTo === externallyUpdatedRelationship?.entitySlug && incomingRelation === externallyUpdatedRelationship?.id;
108
- if (hasChanged || hasUpdated) {
111
+ if (hasChanged || hasUpdated || localeChanged) {
109
112
  if (!populationsByCollection[fieldSchema.relationTo]) {
110
113
  populationsByCollection[fieldSchema.relationTo] = [];
111
114
  }
@@ -137,7 +140,7 @@ export const traverseFields = (args)=>{
137
140
  const hasUpdated = newRelation === externallyUpdatedRelationship?.entitySlug && newID === externallyUpdatedRelationship?.id;
138
141
  // if the new value/relation is different from the old value/relation
139
142
  // populate the new value, otherwise leave it alone
140
- if (hasChanged || hasUpdated) {
143
+ if (hasChanged || hasUpdated || localeChanged) {
141
144
  // if the new value is not empty, populate it
142
145
  // otherwise set the value to null
143
146
  if (newID) {
@@ -161,7 +164,7 @@ export const traverseFields = (args)=>{
161
164
  const hasUpdated = fieldSchema.relationTo === externallyUpdatedRelationship?.entitySlug && newID === externallyUpdatedRelationship?.id;
162
165
  // if the new value is different from the old value
163
166
  // populate the new value, otherwise leave it alone
164
- if (hasChanged || hasUpdated) {
167
+ if (hasChanged || hasUpdated || localeChanged) {
165
168
  // if the new value is not empty, populate it
166
169
  // otherwise set the value to null
167
170
  if (newID) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/traverseFields.ts"],"sourcesContent":["import type { fieldSchemaToJSON } from 'payload/shared'\n\nimport type { PopulationsByCollection, UpdatedDocument } from './types.js'\n\nimport { traverseRichText } from './traverseRichText.js'\n\nexport const traverseFields = <T>(args: {\n externallyUpdatedRelationship?: UpdatedDocument\n fieldSchema: ReturnType<typeof fieldSchemaToJSON>\n incomingData: T\n populationsByCollection: PopulationsByCollection\n result: T\n}): void => {\n const {\n externallyUpdatedRelationship,\n fieldSchema: fieldSchemas,\n incomingData,\n populationsByCollection,\n result,\n } = args\n\n fieldSchemas.forEach((fieldSchema) => {\n if ('name' in fieldSchema && typeof fieldSchema.name === 'string') {\n const fieldName = fieldSchema.name\n\n switch (fieldSchema.type) {\n case 'array':\n if (\n !incomingData[fieldName] &&\n incomingData[fieldName] !== undefined &&\n result?.[fieldName] !== undefined\n ) {\n result[fieldName] = []\n }\n\n if (Array.isArray(incomingData[fieldName])) {\n result[fieldName] = incomingData[fieldName].map((incomingRow, i) => {\n if (!result[fieldName]) {\n result[fieldName] = []\n }\n\n if (!result[fieldName][i]) {\n result[fieldName][i] = {}\n }\n\n traverseFields({\n externallyUpdatedRelationship,\n fieldSchema: fieldSchema.fields,\n incomingData: incomingRow,\n populationsByCollection,\n result: result[fieldName][i],\n })\n\n return result[fieldName][i]\n })\n }\n\n break\n\n case 'blocks':\n if (Array.isArray(incomingData[fieldName])) {\n result[fieldName] = incomingData[fieldName].map((incomingBlock, i) => {\n const incomingBlockJSON = fieldSchema.blocks[incomingBlock.blockType]\n\n if (!result[fieldName]) {\n result[fieldName] = []\n }\n\n if (\n !result[fieldName][i] ||\n result[fieldName][i].id !== incomingBlock.id ||\n result[fieldName][i].blockType !== incomingBlock.blockType\n ) {\n result[fieldName][i] = {\n blockType: incomingBlock.blockType,\n }\n }\n\n traverseFields({\n externallyUpdatedRelationship,\n fieldSchema: incomingBlockJSON.fields,\n incomingData: incomingBlock,\n populationsByCollection,\n result: result[fieldName][i],\n })\n\n return result[fieldName][i]\n })\n } else {\n result[fieldName] = []\n }\n\n break\n\n case 'group':\n // falls through\n case 'tabs':\n if (!result[fieldName]) {\n result[fieldName] = {}\n }\n\n traverseFields({\n externallyUpdatedRelationship,\n fieldSchema: fieldSchema.fields,\n incomingData: incomingData[fieldName] || {},\n populationsByCollection,\n result: result[fieldName],\n })\n\n break\n\n case 'relationship':\n // falls through\n case 'upload':\n // Handle `hasMany` relationships\n if (fieldSchema.hasMany && Array.isArray(incomingData[fieldName])) {\n if (!result[fieldName] || !incomingData[fieldName].length) {\n result[fieldName] = []\n }\n\n incomingData[fieldName].forEach((incomingRelation, i) => {\n // Handle `hasMany` polymorphic\n if (Array.isArray(fieldSchema.relationTo)) {\n // if the field doesn't exist on the result, create it\n // the value will be populated later\n if (!result[fieldName][i]) {\n result[fieldName][i] = {\n relationTo: incomingRelation.relationTo,\n }\n }\n\n const oldID = result[fieldName][i]?.value?.id\n const oldRelation = result[fieldName][i]?.relationTo\n const newID = incomingRelation.value\n const newRelation = incomingRelation.relationTo\n\n const hasChanged = newID !== oldID || newRelation !== oldRelation\n const hasUpdated =\n newRelation === externallyUpdatedRelationship?.entitySlug &&\n newID === externallyUpdatedRelationship?.id\n\n if (hasChanged || hasUpdated) {\n if (!populationsByCollection[newRelation]) {\n populationsByCollection[newRelation] = []\n }\n\n populationsByCollection[newRelation].push({\n id: incomingRelation.value,\n accessor: 'value',\n ref: result[fieldName][i],\n })\n }\n } else {\n // Handle `hasMany` monomorphic\n const hasChanged = incomingRelation !== result[fieldName][i]?.id\n const hasUpdated =\n fieldSchema.relationTo === externallyUpdatedRelationship?.entitySlug &&\n incomingRelation === externallyUpdatedRelationship?.id\n\n if (hasChanged || hasUpdated) {\n if (!populationsByCollection[fieldSchema.relationTo]) {\n populationsByCollection[fieldSchema.relationTo] = []\n }\n\n populationsByCollection[fieldSchema.relationTo].push({\n id: incomingRelation,\n accessor: i,\n ref: result[fieldName],\n })\n }\n }\n })\n } else {\n // Handle `hasOne` polymorphic\n if (Array.isArray(fieldSchema.relationTo)) {\n // if the field doesn't exist on the result, create it\n // the value will be populated later\n if (!result[fieldName]) {\n result[fieldName] = {\n relationTo: incomingData[fieldName]?.relationTo,\n }\n }\n\n const hasNewValue =\n incomingData[fieldName] &&\n typeof incomingData[fieldName] === 'object' &&\n incomingData[fieldName] !== null\n\n const hasOldValue =\n result[fieldName] &&\n typeof result[fieldName] === 'object' &&\n result[fieldName] !== null\n\n const newID = hasNewValue\n ? typeof incomingData[fieldName].value === 'object'\n ? incomingData[fieldName].value.id\n : incomingData[fieldName].value\n : ''\n\n const oldID = hasOldValue\n ? typeof result[fieldName].value === 'object'\n ? result[fieldName].value.id\n : result[fieldName].value\n : ''\n\n const newRelation = hasNewValue ? incomingData[fieldName].relationTo : ''\n const oldRelation = hasOldValue ? result[fieldName].relationTo : ''\n\n const hasChanged = newID !== oldID || newRelation !== oldRelation\n const hasUpdated =\n newRelation === externallyUpdatedRelationship?.entitySlug &&\n newID === externallyUpdatedRelationship?.id\n\n // if the new value/relation is different from the old value/relation\n // populate the new value, otherwise leave it alone\n if (hasChanged || hasUpdated) {\n // if the new value is not empty, populate it\n // otherwise set the value to null\n if (newID) {\n if (!populationsByCollection[newRelation]) {\n populationsByCollection[newRelation] = []\n }\n\n populationsByCollection[newRelation].push({\n id: newID,\n accessor: 'value',\n ref: result[fieldName],\n })\n } else {\n result[fieldName] = null\n }\n }\n } else {\n // Handle `hasOne` monomorphic\n const newID: number | string | undefined =\n (incomingData[fieldName] &&\n typeof incomingData[fieldName] === 'object' &&\n incomingData[fieldName].id) ||\n incomingData[fieldName]\n\n const oldID: number | string | undefined =\n (result[fieldName] &&\n typeof result[fieldName] === 'object' &&\n result[fieldName].id) ||\n result[fieldName]\n\n const hasChanged = newID !== oldID\n const hasUpdated =\n fieldSchema.relationTo === externallyUpdatedRelationship?.entitySlug &&\n newID === externallyUpdatedRelationship?.id\n\n // if the new value is different from the old value\n // populate the new value, otherwise leave it alone\n if (hasChanged || hasUpdated) {\n // if the new value is not empty, populate it\n // otherwise set the value to null\n if (newID) {\n if (!populationsByCollection[fieldSchema.relationTo]) {\n populationsByCollection[fieldSchema.relationTo] = []\n }\n\n populationsByCollection[fieldSchema.relationTo].push({\n id: newID,\n accessor: fieldName,\n ref: result as Record<string, unknown>,\n })\n } else {\n result[fieldName] = null\n }\n }\n }\n }\n\n break\n case 'richText':\n result[fieldName] = traverseRichText({\n externallyUpdatedRelationship,\n incomingData: incomingData[fieldName],\n populationsByCollection,\n result: result[fieldName],\n })\n\n break\n\n default:\n result[fieldName] = incomingData[fieldName]\n }\n }\n })\n}\n"],"names":["traverseRichText","traverseFields","args","externallyUpdatedRelationship","fieldSchema","fieldSchemas","incomingData","populationsByCollection","result","forEach","name","fieldName","type","undefined","Array","isArray","map","incomingRow","i","fields","incomingBlock","incomingBlockJSON","blocks","blockType","id","hasMany","length","incomingRelation","relationTo","oldID","value","oldRelation","newID","newRelation","hasChanged","hasUpdated","entitySlug","push","accessor","ref","hasNewValue","hasOldValue"],"mappings":"AAIA,SAASA,gBAAgB,QAAQ,wBAAuB;AAExD,OAAO,MAAMC,iBAAiB,CAAIC;IAOhC,MAAM,EACJC,6BAA6B,EAC7BC,aAAaC,YAAY,EACzBC,YAAY,EACZC,uBAAuB,EACvBC,MAAM,EACP,GAAGN;IAEJG,aAAaI,OAAO,CAAC,CAACL;QACpB,IAAI,UAAUA,eAAe,OAAOA,YAAYM,IAAI,KAAK,UAAU;YACjE,MAAMC,YAAYP,YAAYM,IAAI;YAElC,OAAQN,YAAYQ,IAAI;gBACtB,KAAK;oBACH,IACE,CAACN,YAAY,CAACK,UAAU,IACxBL,YAAY,CAACK,UAAU,KAAKE,aAC5BL,QAAQ,CAACG,UAAU,KAAKE,WACxB;wBACAL,MAAM,CAACG,UAAU,GAAG,EAAE;oBACxB;oBAEA,IAAIG,MAAMC,OAAO,CAACT,YAAY,CAACK,UAAU,GAAG;wBAC1CH,MAAM,CAACG,UAAU,GAAGL,YAAY,CAACK,UAAU,CAACK,GAAG,CAAC,CAACC,aAAaC;4BAC5D,IAAI,CAACV,MAAM,CAACG,UAAU,EAAE;gCACtBH,MAAM,CAACG,UAAU,GAAG,EAAE;4BACxB;4BAEA,IAAI,CAACH,MAAM,CAACG,UAAU,CAACO,EAAE,EAAE;gCACzBV,MAAM,CAACG,UAAU,CAACO,EAAE,GAAG,CAAC;4BAC1B;4BAEAjB,eAAe;gCACbE;gCACAC,aAAaA,YAAYe,MAAM;gCAC/Bb,cAAcW;gCACdV;gCACAC,QAAQA,MAAM,CAACG,UAAU,CAACO,EAAE;4BAC9B;4BAEA,OAAOV,MAAM,CAACG,UAAU,CAACO,EAAE;wBAC7B;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AAYwB,UAAU,CAAC,GAAG,EAAE;oCACtD;oCAEArB,uBAAuB,CAACH,YAAYwB,UAAU,CAAC,CAACS,IAAI,CAAC;wCACnDb,IAAIQ;wCACJM,UAAU3B;wCACV4B,KAAK/B;oCACP;gCACF,OAAO;oCACLA,MAAM,CAACG,UAAU,GAAG;gCACtB;4BACF;wBACF;oBACF;oBAEA;gBACF,KAAK;oBACHH,MAAM,CAACG,UAAU,GAAGX,iBAAiB;wBACnCG;wBACAG,cAAcA,YAAY,CAACK,UAAU;wBACrCJ;wBACAC,QAAQA,MAAM,CAACG,UAAU;oBAC3B;oBAEA;gBAEF;oBACEH,MAAM,CAACG,UAAU,GAAGL,YAAY,CAACK,UAAU;YAC/C;QACF;IACF;AACF,EAAC"}
1
+ {"version":3,"sources":["../src/traverseFields.ts"],"sourcesContent":["import type { fieldSchemaToJSON } from 'payload/shared'\n\nimport type { PopulationsByCollection, UpdatedDocument } from './types.js'\n\nimport { traverseRichText } from './traverseRichText.js'\n\nexport const traverseFields = <T>(args: {\n externallyUpdatedRelationship?: UpdatedDocument\n fieldSchema: ReturnType<typeof fieldSchemaToJSON>\n incomingData: T\n localeChanged: boolean\n populationsByCollection: PopulationsByCollection\n result: T\n}): void => {\n const {\n externallyUpdatedRelationship,\n fieldSchema: fieldSchemas,\n incomingData,\n localeChanged,\n populationsByCollection,\n result,\n } = args\n\n fieldSchemas.forEach((fieldSchema) => {\n if ('name' in fieldSchema && typeof fieldSchema.name === 'string') {\n const fieldName = fieldSchema.name\n\n switch (fieldSchema.type) {\n case 'array':\n if (\n !incomingData[fieldName] &&\n incomingData[fieldName] !== undefined &&\n result?.[fieldName] !== undefined\n ) {\n result[fieldName] = []\n }\n\n if (Array.isArray(incomingData[fieldName])) {\n result[fieldName] = incomingData[fieldName].map((incomingRow, i) => {\n if (!result[fieldName]) {\n result[fieldName] = []\n }\n\n if (!result[fieldName][i]) {\n result[fieldName][i] = {}\n }\n\n traverseFields({\n externallyUpdatedRelationship,\n fieldSchema: fieldSchema.fields,\n incomingData: incomingRow,\n localeChanged,\n populationsByCollection,\n result: result[fieldName][i],\n })\n\n return result[fieldName][i]\n })\n }\n\n break\n\n case 'blocks':\n if (Array.isArray(incomingData[fieldName])) {\n result[fieldName] = incomingData[fieldName].map((incomingBlock, i) => {\n const incomingBlockJSON = fieldSchema.blocks[incomingBlock.blockType]\n\n if (!result[fieldName]) {\n result[fieldName] = []\n }\n\n if (\n !result[fieldName][i] ||\n result[fieldName][i].id !== incomingBlock.id ||\n result[fieldName][i].blockType !== incomingBlock.blockType\n ) {\n result[fieldName][i] = {\n blockType: incomingBlock.blockType,\n }\n }\n\n traverseFields({\n externallyUpdatedRelationship,\n fieldSchema: incomingBlockJSON.fields,\n incomingData: incomingBlock,\n localeChanged,\n populationsByCollection,\n result: result[fieldName][i],\n })\n\n return result[fieldName][i]\n })\n } else {\n result[fieldName] = []\n }\n\n break\n\n case 'group':\n // falls through\n case 'tabs':\n if (!result[fieldName]) {\n result[fieldName] = {}\n }\n\n traverseFields({\n externallyUpdatedRelationship,\n fieldSchema: fieldSchema.fields,\n incomingData: incomingData[fieldName] || {},\n localeChanged,\n populationsByCollection,\n result: result[fieldName],\n })\n\n break\n\n case 'relationship':\n // falls through\n case 'upload':\n // Handle `hasMany` relationships\n if (fieldSchema.hasMany && Array.isArray(incomingData[fieldName])) {\n if (!result[fieldName] || !incomingData[fieldName].length) {\n result[fieldName] = []\n }\n\n incomingData[fieldName].forEach((incomingRelation, i) => {\n // Handle `hasMany` polymorphic\n if (Array.isArray(fieldSchema.relationTo)) {\n // if the field doesn't exist on the result, create it\n // the value will be populated later\n if (!result[fieldName][i]) {\n result[fieldName][i] = {\n relationTo: incomingRelation.relationTo,\n }\n }\n\n const oldID = result[fieldName][i]?.value?.id\n const oldRelation = result[fieldName][i]?.relationTo\n const newID = incomingRelation.value\n const newRelation = incomingRelation.relationTo\n\n const hasChanged = newID !== oldID || newRelation !== oldRelation\n\n const hasUpdated =\n newRelation === externallyUpdatedRelationship?.entitySlug &&\n newID === externallyUpdatedRelationship?.id\n\n if (hasChanged || hasUpdated || localeChanged) {\n if (!populationsByCollection[newRelation]) {\n populationsByCollection[newRelation] = []\n }\n\n populationsByCollection[newRelation].push({\n id: incomingRelation.value,\n accessor: 'value',\n ref: result[fieldName][i],\n })\n }\n } else {\n // Handle `hasMany` monomorphic\n const hasChanged = incomingRelation !== result[fieldName][i]?.id\n\n const hasUpdated =\n fieldSchema.relationTo === externallyUpdatedRelationship?.entitySlug &&\n incomingRelation === externallyUpdatedRelationship?.id\n\n if (hasChanged || hasUpdated || localeChanged) {\n if (!populationsByCollection[fieldSchema.relationTo]) {\n populationsByCollection[fieldSchema.relationTo] = []\n }\n\n populationsByCollection[fieldSchema.relationTo].push({\n id: incomingRelation,\n accessor: i,\n ref: result[fieldName],\n })\n }\n }\n })\n } else {\n // Handle `hasOne` polymorphic\n if (Array.isArray(fieldSchema.relationTo)) {\n // if the field doesn't exist on the result, create it\n // the value will be populated later\n if (!result[fieldName]) {\n result[fieldName] = {\n relationTo: incomingData[fieldName]?.relationTo,\n }\n }\n\n const hasNewValue =\n incomingData[fieldName] &&\n typeof incomingData[fieldName] === 'object' &&\n incomingData[fieldName] !== null\n\n const hasOldValue =\n result[fieldName] &&\n typeof result[fieldName] === 'object' &&\n result[fieldName] !== null\n\n const newID = hasNewValue\n ? typeof incomingData[fieldName].value === 'object'\n ? incomingData[fieldName].value.id\n : incomingData[fieldName].value\n : ''\n\n const oldID = hasOldValue\n ? typeof result[fieldName].value === 'object'\n ? result[fieldName].value.id\n : result[fieldName].value\n : ''\n\n const newRelation = hasNewValue ? incomingData[fieldName].relationTo : ''\n const oldRelation = hasOldValue ? result[fieldName].relationTo : ''\n\n const hasChanged = newID !== oldID || newRelation !== oldRelation\n\n const hasUpdated =\n newRelation === externallyUpdatedRelationship?.entitySlug &&\n newID === externallyUpdatedRelationship?.id\n\n // if the new value/relation is different from the old value/relation\n // populate the new value, otherwise leave it alone\n if (hasChanged || hasUpdated || localeChanged) {\n // if the new value is not empty, populate it\n // otherwise set the value to null\n if (newID) {\n if (!populationsByCollection[newRelation]) {\n populationsByCollection[newRelation] = []\n }\n\n populationsByCollection[newRelation].push({\n id: newID,\n accessor: 'value',\n ref: result[fieldName],\n })\n } else {\n result[fieldName] = null\n }\n }\n } else {\n // Handle `hasOne` monomorphic\n const newID: number | string | undefined =\n (incomingData[fieldName] &&\n typeof incomingData[fieldName] === 'object' &&\n incomingData[fieldName].id) ||\n incomingData[fieldName]\n\n const oldID: number | string | undefined =\n (result[fieldName] &&\n typeof result[fieldName] === 'object' &&\n result[fieldName].id) ||\n result[fieldName]\n\n const hasChanged = newID !== oldID\n\n const hasUpdated =\n fieldSchema.relationTo === externallyUpdatedRelationship?.entitySlug &&\n newID === externallyUpdatedRelationship?.id\n\n // if the new value is different from the old value\n // populate the new value, otherwise leave it alone\n if (hasChanged || hasUpdated || localeChanged) {\n // if the new value is not empty, populate it\n // otherwise set the value to null\n if (newID) {\n if (!populationsByCollection[fieldSchema.relationTo]) {\n populationsByCollection[fieldSchema.relationTo] = []\n }\n\n populationsByCollection[fieldSchema.relationTo].push({\n id: newID,\n accessor: fieldName,\n ref: result as Record<string, unknown>,\n })\n } else {\n result[fieldName] = null\n }\n }\n }\n }\n\n break\n case 'richText':\n result[fieldName] = traverseRichText({\n externallyUpdatedRelationship,\n incomingData: incomingData[fieldName],\n populationsByCollection,\n result: result[fieldName],\n })\n\n break\n\n default:\n result[fieldName] = incomingData[fieldName]\n }\n }\n })\n}\n"],"names":["traverseRichText","traverseFields","args","externallyUpdatedRelationship","fieldSchema","fieldSchemas","incomingData","localeChanged","populationsByCollection","result","forEach","name","fieldName","type","undefined","Array","isArray","map","incomingRow","i","fields","incomingBlock","incomingBlockJSON","blocks","blockType","id","hasMany","length","incomingRelation","relationTo","oldID","value","oldRelation","newID","newRelation","hasChanged","hasUpdated","entitySlug","push","accessor","ref","hasNewValue","hasOldValue"],"mappings":"AAIA,SAASA,gBAAg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F,OAAO;oCACLA,MAAM,CAACG,UAAU,GAAG;gCACtB;4BACF;wBACF;oBACF;oBAEA;gBACF,KAAK;oBACHH,MAAM,CAACG,UAAU,GAAGZ,iBAAiB;wBACnCG;wBACAG,cAAcA,YAAY,CAACM,UAAU;wBACrCJ;wBACAC,QAAQA,MAAM,CAACG,UAAU;oBAC3B;oBAEA;gBAEF;oBACEH,MAAM,CAACG,UAAU,GAAGN,YAAY,CAACM,UAAU;YAC/C;QACF;IACF;AACF,EAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/live-preview",
3
- "version": "3.2.2",
3
+ "version": "3.2.3-canary.2d2e7d5",
4
4
  "description": "The official live preview JavaScript SDK for Payload",
5
5
  "homepage": "https://payloadcms.com",
6
6
  "repository": {
@@ -32,7 +32,7 @@
32
32
  ],
33
33
  "devDependencies": {
34
34
  "@payloadcms/eslint-config": "3.0.0",
35
- "payload": "3.2.2"
35
+ "payload": "3.2.3-canary.2d2e7d5"
36
36
  },
37
37
  "publishConfig": {
38
38
  "registry": "https://registry.npmjs.org/"