@@ -22,7 +22,7 @@ import {
2222 STALE_REACTION ,
2323 ERROR_VALUE
2424} from './constants.js' ;
25- import { internal_set , old_values } from './reactivity/sources.js' ;
25+ import { old_values } from './reactivity/sources.js' ;
2626import {
2727 destroy_derived_effects ,
2828 execute_derived ,
@@ -45,6 +45,7 @@ import * as w from './warnings.js';
4545import { Batch , batch_deriveds , flushSync , schedule_effect } from './reactivity/batch.js' ;
4646import { handle_error } from './error-handling.js' ;
4747import { UNINITIALIZED } from '../../constants.js' ;
48+ import { captured_signals } from './legacy.js' ;
4849
4950export let is_updating_effect = false ;
5051
@@ -137,14 +138,6 @@ export function set_update_version(value) {
137138// If we are working with a get() chain that has no active container,
138139// to prevent memory leaks, we skip adding the reaction.
139140export let skip_reaction = false ;
140- // Handle collecting all signals which are read during a specific time frame
141- /** @type {Set<Value> | null } */
142- export let captured_signals = null ;
143-
144- /** @param {Set<Value> | null } value */
145- export function set_captured_signals ( value ) {
146- captured_signals = value ;
147- }
148141
149142export function increment_write_version ( ) {
150143 return ++ write_version ;
@@ -531,9 +524,7 @@ export function get(signal) {
531524 var flags = signal . f ;
532525 var is_derived = ( flags & DERIVED ) !== 0 ;
533526
534- if ( captured_signals !== null ) {
535- captured_signals . add ( signal ) ;
536- }
527+ captured_signals ?. add ( signal ) ;
537528
538529 // Register the dependency on the current reaction signal.
539530 if ( active_reaction !== null && ! untracking ) {
@@ -713,45 +704,6 @@ export function safe_get(signal) {
713704 return signal && get ( signal ) ;
714705}
715706
716- /**
717- * Capture an array of all the signals that are read when `fn` is called
718- * @template T
719- * @param {() => T } fn
720- */
721- function capture_signals ( fn ) {
722- var previous_captured_signals = captured_signals ;
723- captured_signals = new Set ( ) ;
724-
725- var captured = captured_signals ;
726- var signal ;
727-
728- try {
729- untrack ( fn ) ;
730- if ( previous_captured_signals !== null ) {
731- for ( signal of captured_signals ) {
732- previous_captured_signals . add ( signal ) ;
733- }
734- }
735- } finally {
736- captured_signals = previous_captured_signals ;
737- }
738-
739- return captured ;
740- }
741-
742- /**
743- * Invokes a function and captures all signals that are read during the invocation,
744- * then invalidates them.
745- * @param {() => any } fn
746- */
747- export function invalidate_inner_signals ( fn ) {
748- var captured = capture_signals ( ( ) => untrack ( fn ) ) ;
749-
750- for ( var signal of captured ) {
751- internal_set ( signal , signal . v ) ;
752- }
753- }
754-
755707/**
756708 * When used inside a [`$derived`](https://svelte.dev/docs/svelte/$derived) or [`$effect`](https://svelte.dev/docs/svelte/$effect),
757709 * any state read inside `fn` will not be treated as a dependency.
0 commit comments