New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@payloadcms/live-preview

Package Overview
Dependencies
Maintainers
0
Versions
399
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@payloadcms/live-preview - npm Package Compare versions

Comparing version 3.2.2 to 3.2.3-canary.2d2e7d5

1

dist/handleMessage.js

@@ -31,2 +31,3 @@ import { isLivePreviewEvent } from './isLivePreviewEvent.js';

initialData: payloadLivePreviewPreviousData || initialData,
locale: event.data.locale,
serverURL

@@ -33,0 +34,0 @@ });

@@ -15,2 +15,3 @@ import type { fieldSchemaToJSON } from 'payload/shared';

initialData: T;
locale?: string;
returnNumberOfRequests?: boolean;

@@ -17,0 +18,0 @@ serverURL: string;

10

dist/mergeData.js

@@ -11,4 +11,8 @@ import { traverseFields } from './traverseFields.js';

};
// Relationships are only updated when their `id` or `relationTo` changes, by comparing the old and new values
// This needs to also happen when locale changes, except this is not not part of the API response
// Instead, we keep track of the old locale ourselves and trigger a re-population when it changes
let prevLocale;
export const mergeData = async (args)=>{
const { apiRoute, depth, externallyUpdatedRelationship, fieldSchema, incomingData, initialData, returnNumberOfRequests, serverURL } = args;
const { apiRoute, depth, externallyUpdatedRelationship, fieldSchema, incomingData, initialData, locale, returnNumberOfRequests, serverURL } = args;
const result = {

@@ -22,2 +26,3 @@ ...initialData

incomingData,
localeChanged: prevLocale !== locale,
populationsByCollection,

@@ -33,3 +38,3 @@ result

apiPath: apiRoute || '/api',
endpoint: encodeURI(`${collection}?depth=${depth}&where[id][in]=${Array.from(ids).join(',')}`),
endpoint: encodeURI(`${collection}?depth=${depth}&where[id][in]=${Array.from(ids).join(',')}${locale ? `&locale=${locale}` : ''}`),
serverURL

@@ -51,2 +56,3 @@ }).then((res)=>res.json());

}));
prevLocale = locale;
return {

@@ -53,0 +59,0 @@ ...result,

@@ -7,3 +7,3 @@ export declare const subscribe: <T>(args: {

serverURL: string;
}) => ((event: MessageEvent) => void);
}) => ((event: MessageEvent) => Promise<void> | void);
//# sourceMappingURL=subscribe.d.ts.map

@@ -7,2 +7,3 @@ import type { fieldSchemaToJSON } from 'payload/shared';

incomingData: T;
localeChanged: boolean;
populationsByCollection: PopulationsByCollection;

@@ -9,0 +10,0 @@ result: T;

import { traverseRichText } from './traverseRichText.js';
export const traverseFields = (args)=>{
const { externallyUpdatedRelationship, fieldSchema: fieldSchemas, incomingData, populationsByCollection, result } = args;
const { externallyUpdatedRelationship, fieldSchema: fieldSchemas, incomingData, localeChanged, populationsByCollection, result } = args;
fieldSchemas.forEach((fieldSchema)=>{

@@ -24,2 +24,3 @@ if ('name' in fieldSchema && typeof fieldSchema.name === 'string') {

incomingData: incomingRow,
localeChanged,
populationsByCollection,

@@ -48,2 +49,3 @@ result: result[fieldName][i]

incomingData: incomingBlock,
localeChanged,
populationsByCollection,

@@ -68,2 +70,3 @@ result: result[fieldName][i]

incomingData: incomingData[fieldName] || {},
localeChanged,
populationsByCollection,

@@ -97,3 +100,3 @@ result: result[fieldName]

const hasUpdated = newRelation === externallyUpdatedRelationship?.entitySlug && newID === externallyUpdatedRelationship?.id;
if (hasChanged || hasUpdated) {
if (hasChanged || hasUpdated || localeChanged) {
if (!populationsByCollection[newRelation]) {

@@ -112,3 +115,3 @@ populationsByCollection[newRelation] = [];

const hasUpdated = fieldSchema.relationTo === externallyUpdatedRelationship?.entitySlug && incomingRelation === externallyUpdatedRelationship?.id;
if (hasChanged || hasUpdated) {
if (hasChanged || hasUpdated || localeChanged) {
if (!populationsByCollection[fieldSchema.relationTo]) {

@@ -145,3 +148,3 @@ populationsByCollection[fieldSchema.relationTo] = [];

// populate the new value, otherwise leave it alone
if (hasChanged || hasUpdated) {
if (hasChanged || hasUpdated || localeChanged) {
// if the new value is not empty, populate it

@@ -170,3 +173,3 @@ // otherwise set the value to null

// populate the new value, otherwise leave it alone
if (hasChanged || hasUpdated) {
if (hasChanged || hasUpdated || localeChanged) {
// if the new value is not empty, populate it

@@ -173,0 +176,0 @@ // otherwise set the value to null

{
"name": "@payloadcms/live-preview",
"version": "3.2.2",
"version": "3.2.3-canary.2d2e7d5",
"description": "The official live preview JavaScript SDK for Payload",

@@ -35,3 +35,3 @@ "homepage": "https://payloadcms.com",

"@payloadcms/eslint-config": "3.0.0",
"payload": "3.2.2"
"payload": "3.2.3-canary.2d2e7d5"
},

@@ -38,0 +38,0 @@ "publishConfig": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc