@@ -67,10 +67,15 @@ export class ImmerhinSyncObject implements SyncObject {
67
67
}
68
68
setState ( state : Map < string , unknown > ) {
69
69
for ( const [ namespace , $store ] of this . store . containers ) {
70
- // Immer cannot handle Map instances from another realm.
71
- // Use `clone` to recreate the data with the current realm's classes.
72
- // This works because the structured clone algorithm skips prototype chains; classes must be defined in both realms.
73
- $store . set ( structuredClone ( state . get ( namespace ) ) ) ;
70
+ // catch errors triggered by CSP configuration when user put iframe onto canvas
71
+ try {
72
+ // Immer cannot handle Map instances from another realm.
73
+ // Use `clone` to recreate the data with the current realm's classes.
74
+ // This works because the structured clone algorithm skips prototype chains; classes must be defined in both realms.
75
+ $store . set ( structuredClone ( state . get ( namespace ) ) ) ;
76
+ } catch {
77
+ // empty block
78
+ }
74
79
}
75
80
}
76
81
applyTransaction ( transaction : Transaction < Change [ ] > ) {
@@ -112,10 +117,15 @@ export class NanostoresSyncObject implements SyncObject {
112
117
}
113
118
applyTransaction ( transaction : Transaction ) {
114
119
this . operation = "add" ;
115
- // `instanceof` checks do not work with instances like Map, File, etc., from another realm.
116
- // Use `clone` to recreate the data with the current realm's classes.
117
- // This works because the structured clone algorithm skips prototype chains; classes must be defined in both realms.
118
- this . store . set ( structuredClone ( transaction . payload ) ) ;
120
+ // catch errors triggered by CSP configuration when user put iframe onto canvas
121
+ try {
122
+ // `instanceof` checks do not work with instances like Map, File, etc., from another realm.
123
+ // Use `clone` to recreate the data with the current realm's classes.
124
+ // This works because the structured clone algorithm skips prototype chains; classes must be defined in both realms.
125
+ this . store . set ( structuredClone ( transaction . payload ) ) ;
126
+ } catch {
127
+ // empty block
128
+ }
119
129
this . operation = "local" ;
120
130
}
121
131
revertTransaction ( _transaction : RevertedTransaction ) {
0 commit comments