chore: extract some minor changes from #18861 (#18866)

doing my usual thing of extracting no-brainer changes from a giant PR to
try and make it slightly less giant
pull/18042/merge
Rich Harris 2 days ago committed by GitHub
parent 38098a9311
commit 58297c5a73
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -131,8 +131,10 @@ export function trace(label, fn) {
}
/**
* @param {Value} source
* @template {Value} T
* @param {T} source
* @param {string} label
* @returns {T}
*/
export function tag(source, label) {
source.label = label;

@ -1,4 +1,4 @@
/** @import { EachItem, EachOutroGroup, EachState, Effect, EffectNodes, MaybeSource, Source, TemplateNode, TransitionManager, Value } from '#client' */
/** @import { EachItem, EachOutroGroup, EachState, Effect, EffectNodes, MaybeSource, TemplateNode, TransitionManager } from '#client' */
/** @import { Batch } from '../../reactivity/batch.js'; */
import {
EACH_INDEX_REACTIVE,
@ -664,7 +664,7 @@ function reconcile(state, array, anchor, flags, get_key) {
* @param {V} value
* @param {unknown} key
* @param {number} index
* @param {(anchor: Node, item: V | Source<V>, index: number | Value<number>, collection: () => V[]) => void} render_fn
* @param {(anchor: Node, item: MaybeSource<V>, index: MaybeSource<number>, collection: () => V[]) => void} render_fn
* @param {number} flags
* @param {() => V[]} get_collection
* @returns {EachItem}

@ -1295,6 +1295,10 @@ export function eager(fn) {
let version = version_map.get(parent) ?? source(0);
version_map.set(parent, version);
if (DEV) {
version.label ??= '$state.eager version';
}
teardown(() => {
if (parent.f & DESTROYING) version_map.delete(parent);
});

@ -46,7 +46,7 @@ import { set_signal_status, update_derived_status } from './status.js';
/** @type {Set<Effect>} */
export let eager_effects = new Set();
/** @type {Map<Source, any>} */
/** @type {Map<Value, any>} */
export const old_values = new Map();
/**
@ -141,7 +141,7 @@ export function mutate(source, value) {
/**
* @template V
* @param {Source<V>} source
* @param {Value<V>} source
* @param {V} value
* @param {boolean} [should_proxy]
* @returns {V}
@ -181,7 +181,7 @@ var count_deps = 0;
/**
* @template V
* @param {Source<V>} source
* @param {Value<V>} source
* @param {V} value
* @param {Effect[] | null} [updated_during_traversal]
* @returns {V}

@ -93,7 +93,7 @@ export function set_active_effect(effect) {
/**
* When sources are created within a reaction, reading and writing
* them within that reaction should not cause a re-run
* @type {null | Set<Source>}
* @type {null | Set<Value>}
*/
export let current_sources = null;
@ -121,11 +121,11 @@ export let skipped_deps = 0;
/**
* Tracks writes that the effect it's executed in doesn't listen to yet,
* so that the dependency can be added to the effect later on if it then reads it
* @type {null | Source[]}
* @type {null | Value[]}
*/
export let untracked_writes = null;
/** @param {null | Source[]} value */
/** @param {null | Value[]} value */
export function set_untracked_writes(value) {
untracked_writes = value;
}

@ -1,4 +1,4 @@
/** @import { Source } from '#client' */
/** @import { Derived } from '#client' */
import { derived } from '../internal/client/index.js';
import { set, state } from '../internal/client/reactivity/sources.js';
import { tag } from '../internal/client/dev/tracing.js';
@ -42,7 +42,7 @@ var inited = false;
export class SvelteDate extends Date {
#time = state(super.getTime());
/** @type {Map<keyof Date, Source<unknown>>} */
/** @type {Map<keyof Date, Derived<unknown>>} */
#deriveds = new Map();
#reaction = active_reaction;

Loading…
Cancel
Save