|
1 | 1 | import { get_rune } from '../../../scope.js'; |
2 | | -import { is_hoistable_function } from '../../utils.js'; |
| 2 | +import { is_hoistable_function, transform_inspect_rune } from '../../utils.js'; |
3 | 3 | import * as b from '../../../../utils/builders.js'; |
4 | 4 | import * as assert from '../../../../utils/assert.js'; |
5 | 5 | import { create_state_declarators, get_prop_source, should_proxy } from '../utils.js'; |
@@ -301,33 +301,24 @@ export const javascript_visitors_runes = { |
301 | 301 |
|
302 | 302 | context.next(); |
303 | 303 | }, |
304 | | - CallExpression(node, { state, next, visit }) { |
305 | | - const rune = get_rune(node, state.scope); |
| 304 | + CallExpression(node, context) { |
| 305 | + const rune = get_rune(node, context.state.scope); |
306 | 306 |
|
307 | 307 | if (rune === '$effect.active') { |
308 | 308 | return b.call('$.effect_active'); |
309 | 309 | } |
310 | 310 |
|
311 | 311 | if (rune === '$effect.root') { |
312 | 312 | const args = /** @type {import('estree').Expression[]} */ ( |
313 | | - node.arguments.map((arg) => visit(arg)) |
| 313 | + node.arguments.map((arg) => context.visit(arg)) |
314 | 314 | ); |
315 | 315 | return b.call('$.user_root_effect', ...args); |
316 | 316 | } |
317 | 317 |
|
318 | | - if (rune === '$inspect') { |
319 | | - if (state.options.dev) { |
320 | | - const arg = /** @type {import('estree').Expression} */ (visit(node.arguments[0])); |
321 | | - const fn = |
322 | | - node.arguments[1] && |
323 | | - /** @type {import('estree').Expression} */ (visit(node.arguments[1])); |
324 | | - |
325 | | - return b.call('$.inspect', b.thunk(arg), fn); |
326 | | - } |
327 | | - |
328 | | - return b.unary('void', b.literal(0)); |
| 318 | + if (rune === '$inspect' || rune === '$inspect().with') { |
| 319 | + return transform_inspect_rune(node, context); |
329 | 320 | } |
330 | 321 |
|
331 | | - next(); |
| 322 | + context.next(); |
332 | 323 | } |
333 | 324 | }; |
0 commit comments