@@ -217,9 +217,10 @@ function is_expression_async(expression) {
217217 * @param {import('estree').AssignmentExpression } node
218218 * @param {import('zimmerframe').Context<import('#compiler').SvelteNode, State> } context
219219 * @param {() => any } fallback
220+ * @param {{skip_proxy_and_freeze?: boolean} } [options]
220221 * @returns {import('estree').Expression }
221222 */
222- export function serialize_set_binding ( node , context , fallback ) {
223+ export function serialize_set_binding ( node , context , fallback , options ) {
223224 const { state, visit } = context ;
224225
225226 if (
@@ -242,7 +243,7 @@ export function serialize_set_binding(node, context, fallback) {
242243 const value = path . expression ?. ( b . id ( tmp_id ) ) ;
243244 const assignment = b . assignment ( '=' , path . node , value ) ;
244245 original_assignments . push ( assignment ) ;
245- assignments . push ( serialize_set_binding ( assignment , context , ( ) => assignment ) ) ;
246+ assignments . push ( serialize_set_binding ( assignment , context , ( ) => assignment , options ) ) ;
246247 }
247248
248249 if ( assignments . every ( ( assignment , i ) => assignment === original_assignments [ i ] ) ) {
@@ -288,7 +289,11 @@ export function serialize_set_binding(node, context, fallback) {
288289 if ( private_state !== undefined ) {
289290 if ( state . in_constructor ) {
290291 // 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+ ) {
292297 const assignment = fallback ( ) ;
293298 if ( assignment . type === 'AssignmentExpression' ) {
294299 assignment . right =
@@ -302,7 +307,9 @@ export function serialize_set_binding(node, context, fallback) {
302307 return b . call (
303308 '$.set' ,
304309 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 )
306313 ? private_state . kind === 'frozen_state'
307314 ? b . call ( '$.freeze' , value )
308315 : b . call ( '$.proxy' , value )
@@ -321,6 +328,7 @@ export function serialize_set_binding(node, context, fallback) {
321328 if (
322329 context . state . analysis . runes &&
323330 public_state !== undefined &&
331+ ! options ?. skip_proxy_and_freeze &&
324332 should_proxy_or_freeze ( value )
325333 ) {
326334 const assignment = fallback ( ) ;
@@ -387,15 +395,19 @@ export function serialize_set_binding(node, context, fallback) {
387395 return b . call (
388396 '$.set' ,
389397 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 )
391401 ? b . call ( '$.proxy' , value )
392402 : value
393403 ) ;
394404 } else if ( binding . kind === 'frozen_state' ) {
395405 return b . call (
396406 '$.set' ,
397407 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 )
399411 ? b . call ( '$.freeze' , value )
400412 : value
401413 ) ;
@@ -624,6 +636,5 @@ export function should_proxy_or_freeze(node) {
624636 ) {
625637 return false ;
626638 }
627-
628639 return true ;
629640}
0 commit comments