Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 1947x 1947x 2x 2x 2x 2x 2x 2x 6035x 9180x 9180x 9180x 8436x 9180x 808x 808x 808x 739x 739x 739x 8x 8x 739x 739x 808x 808x 83x 13x 13x 70x 70x 808x 808x 99x 99x 99x 99x 99x 99x 808x 808x 9180x 6035x | /** @import { BinaryOperator, Expression, Identifier } from 'estree' */ /** @import { ComponentContext, Context } from '../../types' */ import { build_proxy_reassignment, is_state_source, should_proxy_or_freeze } from '../../utils.js'; import * as b from '../../../../../utils/builders.js'; /** * Turns `foo` into `$.get(foo)` * @param {Identifier} node */ export function get_value(node) { return b.call('$.get', node); } /** * * @param {Context | ComponentContext} context */ export function add_state_transformers(context) { for (const [name, binding] of context.state.scope.declarations) { if ( is_state_source(binding, context.state) || binding.kind === 'derived' || binding.kind === 'legacy_reactive' ) { context.state.transform[name] = { read: get_value, assign: (node, value) => { let call = b.call('$.set', node, value); if (context.state.scope.get(`$${node.name}`)?.kind === 'store_sub') { call = b.call('$.store_unsub', call, b.literal(`$${node.name}`), b.id('$$stores')); } return call; }, mutate: (node, mutation) => { if (context.state.analysis.runes) { return mutation; } return b.call('$.mutate', node, mutation); }, update: (node) => { return b.call( node.prefix ? '$.update_pre' : '$.update', node.argument, node.operator === '--' && b.literal(-1) ); } }; } } } |