1
1
import { DEV } from 'esm-env' ;
2
2
import { subscribe_to_store } from '../../store/utils.js' ;
3
3
import { EMPTY_FUNC , run_all } from '../common.js' ;
4
- import { get_descriptors , is_array } from './utils.js' ;
4
+ import { get_descriptor , get_descriptors , is_array } from './utils.js' ;
5
5
import { PROPS_CALL_DEFAULT_VALUE , PROPS_IS_IMMUTABLE } from '../../constants.js' ;
6
6
7
7
export const SOURCE = 1 ;
@@ -31,8 +31,7 @@ let current_scheduler_mode = FLUSH_MICROTASK;
31
31
// Used for handling scheduling
32
32
let is_micro_task_queued = false ;
33
33
let is_task_queued = false ;
34
- // Used for exposing signals
35
- let is_signal_exposed = false ;
34
+
36
35
// Handle effect queues
37
36
38
37
/** @type {import('./types.js').EffectSignal[] } */
@@ -64,8 +63,6 @@ export let current_untracking = false;
64
63
/** Exists to opt out of the mutation validation for stores which may be set for the first time during a derivation */
65
64
let ignore_mutation_validation = false ;
66
65
67
- /** @type {null | import('./types.js').Signal } */
68
- let current_captured_signal = null ;
69
66
// If we are working with a get() chain that has no active container,
70
67
// to prevent memory leaks, we skip adding the consumer.
71
68
let current_skip_consumer = false ;
@@ -801,23 +798,6 @@ export function unsubscribe_on_destroy(stores) {
801
798
} ) ;
802
799
}
803
800
804
- /**
805
- * Wraps a function and marks execution context so that the last signal read from can be captured
806
- * using the `expose` function.
807
- * @template V
808
- * @param {() => V } fn
809
- * @returns {V }
810
- */
811
- export function exposable ( fn ) {
812
- const previous_is_signal_exposed = is_signal_exposed ;
813
- try {
814
- is_signal_exposed = true ;
815
- return fn ( ) ;
816
- } finally {
817
- is_signal_exposed = previous_is_signal_exposed ;
818
- }
819
- }
820
-
821
801
/**
822
802
* @template V
823
803
* @param {import('./types.js').Signal<V> } signal
@@ -837,10 +817,6 @@ export function get(signal) {
837
817
return signal . v ;
838
818
}
839
819
840
- if ( is_signal_exposed && current_should_capture_signal ) {
841
- current_captured_signal = signal ;
842
- }
843
-
844
820
if ( is_signals_recorded ) {
845
821
captured_signals . add ( signal ) ;
846
822
}
@@ -907,31 +883,6 @@ export function set_sync(signal, value) {
907
883
flushSync ( ( ) => set ( signal , value ) ) ;
908
884
}
909
885
910
- /**
911
- * Invokes a function and captures the last signal that is read during the invocation
912
- * if that signal is read within the `exposable` function context.
913
- * If a signal is captured, it returns the signal instead of the read value.
914
- * @template V
915
- * @param {() => V } possible_signal_fn
916
- * @returns {any }
917
- */
918
- export function expose ( possible_signal_fn ) {
919
- const previous_captured_signal = current_captured_signal ;
920
- const previous_should_capture_signal = current_should_capture_signal ;
921
- current_captured_signal = null ;
922
- current_should_capture_signal = true ;
923
- try {
924
- const value = possible_signal_fn ( ) ;
925
- if ( current_captured_signal === null ) {
926
- return value ;
927
- }
928
- return current_captured_signal ;
929
- } finally {
930
- current_captured_signal = previous_captured_signal ;
931
- current_should_capture_signal = previous_should_capture_signal ;
932
- }
933
- }
934
-
935
886
/**
936
887
* Invokes a function and captures all signals that are read during the invocation,
937
888
* then invalidates them.
@@ -1473,28 +1424,10 @@ export function prop_source(props_obj, key, flags, default_value) {
1473
1424
const immutable = ( flags & PROPS_IS_IMMUTABLE ) !== 0 ;
1474
1425
1475
1426
const props = is_signal ( props_obj ) ? get ( props_obj ) : props_obj ;
1476
- const possible_signal = /** @type {import('./types.js').MaybeSignal<V> } */ (
1477
- expose ( ( ) => props [ key ] )
1478
- ) ;
1479
- const update_bound_prop = Object . getOwnPropertyDescriptor ( props , key ) ?. set ;
1427
+ const update_bound_prop = get_descriptor ( props , key ) ?. set ;
1480
1428
let value = props [ key ] ;
1481
1429
const should_set_default_value = value === undefined && default_value !== undefined ;
1482
1430
1483
- if (
1484
- is_signal ( possible_signal ) &&
1485
- possible_signal . v === value &&
1486
- update_bound_prop === undefined
1487
- ) {
1488
- if ( should_set_default_value ) {
1489
- set (
1490
- possible_signal ,
1491
- // @ts -expect-error would need a cumbersome method overload to type this
1492
- call_default_value ? default_value ( ) : default_value
1493
- ) ;
1494
- }
1495
- return possible_signal ;
1496
- }
1497
-
1498
1431
if ( should_set_default_value ) {
1499
1432
value =
1500
1433
// @ts -expect-error would need a cumbersome method overload to type this
@@ -1537,7 +1470,7 @@ export function prop_source(props_obj, key, flags, default_value) {
1537
1470
}
1538
1471
} ) ;
1539
1472
1540
- if ( is_signal ( possible_signal ) && update_bound_prop !== undefined ) {
1473
+ if ( update_bound_prop !== undefined ) {
1541
1474
let ignore_first = ! should_set_default_value ;
1542
1475
sync_effect ( ( ) => {
1543
1476
// Before if to ensure signal dependency is registered
@@ -1551,11 +1484,9 @@ export function prop_source(props_obj, key, flags, default_value) {
1551
1484
return ;
1552
1485
}
1553
1486
1554
- if ( not_equal ( immutable , propagating_value , possible_signal . v ) ) {
1555
- ignore_next1 = true ;
1556
- did_update_to_defined = true ;
1557
- untrack ( ( ) => update_bound_prop ( propagating_value ) ) ;
1558
- }
1487
+ ignore_next1 = true ;
1488
+ did_update_to_defined = true ;
1489
+ untrack ( ( ) => update_bound_prop ( propagating_value ) ) ;
1559
1490
} ) ;
1560
1491
}
1561
1492
0 commit comments