@@ -217,9 +217,10 @@ function is_expression_async(expression) {
217
217
* @param {import('estree').AssignmentExpression } node
218
218
* @param {import('zimmerframe').Context<import('#compiler').SvelteNode, State> } context
219
219
* @param {() => any } fallback
220
+ * @param {{skip_proxy_and_freeze?: boolean} } [options]
220
221
* @returns {import('estree').Expression }
221
222
*/
222
- export function serialize_set_binding ( node , context , fallback ) {
223
+ export function serialize_set_binding ( node , context , fallback , options ) {
223
224
const { state, visit } = context ;
224
225
225
226
if (
@@ -242,7 +243,7 @@ export function serialize_set_binding(node, context, fallback) {
242
243
const value = path . expression ?. ( b . id ( tmp_id ) ) ;
243
244
const assignment = b . assignment ( '=' , path . node , value ) ;
244
245
original_assignments . push ( assignment ) ;
245
- assignments . push ( serialize_set_binding ( assignment , context , ( ) => assignment ) ) ;
246
+ assignments . push ( serialize_set_binding ( assignment , context , ( ) => assignment , options ) ) ;
246
247
}
247
248
248
249
if ( assignments . every ( ( assignment , i ) => assignment === original_assignments [ i ] ) ) {
@@ -288,7 +289,11 @@ export function serialize_set_binding(node, context, fallback) {
288
289
if ( private_state !== undefined ) {
289
290
if ( state . in_constructor ) {
290
291
// See if we should wrap value in $.proxy
291
- if ( context . state . analysis . runes && should_proxy_or_freeze ( value ) ) {
292
+ if (
293
+ context . state . analysis . runes &&
294
+ ! options ?. skip_proxy_and_freeze &&
295
+ should_proxy_or_freeze ( value )
296
+ ) {
292
297
const assignment = fallback ( ) ;
293
298
if ( assignment . type === 'AssignmentExpression' ) {
294
299
assignment . right =
@@ -302,7 +307,9 @@ export function serialize_set_binding(node, context, fallback) {
302
307
return b . call (
303
308
'$.set' ,
304
309
left ,
305
- context . state . analysis . runes && should_proxy_or_freeze ( value )
310
+ context . state . analysis . runes &&
311
+ ! options ?. skip_proxy_and_freeze &&
312
+ should_proxy_or_freeze ( value )
306
313
? private_state . kind === 'frozen_state'
307
314
? b . call ( '$.freeze' , value )
308
315
: b . call ( '$.proxy' , value )
@@ -321,6 +328,7 @@ export function serialize_set_binding(node, context, fallback) {
321
328
if (
322
329
context . state . analysis . runes &&
323
330
public_state !== undefined &&
331
+ ! options ?. skip_proxy_and_freeze &&
324
332
should_proxy_or_freeze ( value )
325
333
) {
326
334
const assignment = fallback ( ) ;
@@ -387,15 +395,19 @@ export function serialize_set_binding(node, context, fallback) {
387
395
return b . call (
388
396
'$.set' ,
389
397
b . id ( left_name ) ,
390
- context . state . analysis . runes && should_proxy_or_freeze ( value )
398
+ context . state . analysis . runes &&
399
+ ! options ?. skip_proxy_and_freeze &&
400
+ should_proxy_or_freeze ( value )
391
401
? b . call ( '$.proxy' , value )
392
402
: value
393
403
) ;
394
404
} else if ( binding . kind === 'frozen_state' ) {
395
405
return b . call (
396
406
'$.set' ,
397
407
b . id ( left_name ) ,
398
- context . state . analysis . runes && should_proxy_or_freeze ( value )
408
+ context . state . analysis . runes &&
409
+ ! options ?. skip_proxy_and_freeze &&
410
+ should_proxy_or_freeze ( value )
399
411
? b . call ( '$.freeze' , value )
400
412
: value
401
413
) ;
@@ -624,6 +636,5 @@ export function should_proxy_or_freeze(node) {
624
636
) {
625
637
return false ;
626
638
}
627
-
628
639
return true ;
629
640
}
0 commit comments