Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.
TypeScript accessibilityalternativecloudflarecloudflare-workersdesignfreefrontendopen-sourceradix-uireactremixweb-developmentwebflowwebsite-builderwebsite-developmentwebsiteswebstudio
chore: Use structured clone for transactions (#4456)
Ivan Starkov7c3bf00dd020
diff --git a/apps/builder/app/shared/sync-client.ts b/apps/builder/app/shared/sync-client.tsindex 3abc319978..ee7a784612 100644--- a/apps/builder/app/shared/sync-client.ts+++ b/apps/builder/app/shared/sync-client.ts@@ -42,8 +42,9 @@ export class ImmerhinSyncObject implements SyncObject {}setState(state: Map<string, unknown>) {for (const [namespace, $store] of this.store.containers) {- // immer is not able to work with Map instances from another realm- // use clone to recreate data with current realm classes+ // Immer cannot handle Map instances from another realm.+ // Use `clone` to recreate the data with the current realm's classes.+ // This works because the structured clone algorithm skips prototype chains; classes must be defined in both realms.$store.set(structuredClone(state.get(namespace)));}}@@ -86,7 +87,10 @@ export class NanostoresSyncObject implements SyncObject {}addTransaction(transaction: Transaction) {this.operation = "add";- this.store.set(transaction.payload);+ // `instanceof` checks do not work with instances like Map, File, etc., from another realm.+ // Use `clone` to recreate the data with the current realm's classes.+ // This works because the structured clone algorithm skips prototype chains; classes must be defined in both realms.+ this.store.set(structuredClone(transaction.payload));this.operation = "local";}revertTransaction(_transaction: RevertedTransaction) {