|
|
|
@ -7,7 +7,6 @@ import {
|
|
|
|
current_untracked_writes,
|
|
|
|
current_untracked_writes,
|
|
|
|
get,
|
|
|
|
get,
|
|
|
|
is_runes,
|
|
|
|
is_runes,
|
|
|
|
mark_reactions,
|
|
|
|
|
|
|
|
schedule_effect,
|
|
|
|
schedule_effect,
|
|
|
|
set_current_untracked_writes,
|
|
|
|
set_current_untracked_writes,
|
|
|
|
set_signal_status,
|
|
|
|
set_signal_status,
|
|
|
|
@ -17,7 +16,15 @@ import {
|
|
|
|
inspect_effects
|
|
|
|
inspect_effects
|
|
|
|
} from '../runtime.js';
|
|
|
|
} from '../runtime.js';
|
|
|
|
import { equals, safe_equals } from './equality.js';
|
|
|
|
import { equals, safe_equals } from './equality.js';
|
|
|
|
import { CLEAN, DERIVED, DIRTY, BRANCH_EFFECT } from '../constants.js';
|
|
|
|
import {
|
|
|
|
|
|
|
|
CLEAN,
|
|
|
|
|
|
|
|
DERIVED,
|
|
|
|
|
|
|
|
DIRTY,
|
|
|
|
|
|
|
|
BRANCH_EFFECT,
|
|
|
|
|
|
|
|
INSPECT_EFFECT,
|
|
|
|
|
|
|
|
UNOWNED,
|
|
|
|
|
|
|
|
MAYBE_DIRTY
|
|
|
|
|
|
|
|
} from '../constants.js';
|
|
|
|
import { UNINITIALIZED } from '../../../constants.js';
|
|
|
|
import { UNINITIALIZED } from '../../../constants.js';
|
|
|
|
import * as e from '../errors.js';
|
|
|
|
import * as e from '../errors.js';
|
|
|
|
|
|
|
|
|
|
|
|
@ -91,7 +98,7 @@ export function set(source, value) {
|
|
|
|
source.v = value;
|
|
|
|
source.v = value;
|
|
|
|
source.version = increment_version();
|
|
|
|
source.version = increment_version();
|
|
|
|
|
|
|
|
|
|
|
|
mark_reactions(source, DIRTY, true);
|
|
|
|
mark_reactions(source, DIRTY);
|
|
|
|
|
|
|
|
|
|
|
|
// If the current signal is running for the first time, it won't have any
|
|
|
|
// If the current signal is running for the first time, it won't have any
|
|
|
|
// reactions as we only allocate and assign the reactions after the signal
|
|
|
|
// reactions as we only allocate and assign the reactions after the signal
|
|
|
|
@ -132,3 +139,44 @@ export function set(source, value) {
|
|
|
|
|
|
|
|
|
|
|
|
return value;
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @param {import('#client').Value} signal
|
|
|
|
|
|
|
|
* @param {number} status should be DIRTY or MAYBE_DIRTY
|
|
|
|
|
|
|
|
* @returns {void}
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
function mark_reactions(signal, status) {
|
|
|
|
|
|
|
|
var reactions = signal.reactions;
|
|
|
|
|
|
|
|
if (reactions === null) return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var runes = is_runes();
|
|
|
|
|
|
|
|
var length = reactions.length;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (var i = 0; i < length; i++) {
|
|
|
|
|
|
|
|
var reaction = reactions[i];
|
|
|
|
|
|
|
|
var flags = reaction.f;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (DEV && (flags & INSPECT_EFFECT) !== 0) {
|
|
|
|
|
|
|
|
inspect_effects.add(reaction);
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// We skip any effects that are already dirty. Additionally, we also
|
|
|
|
|
|
|
|
// skip if the reaction is the same as the current effect (except if we're not in runes or we
|
|
|
|
|
|
|
|
// are in force schedule mode).
|
|
|
|
|
|
|
|
if ((flags & DIRTY) !== 0 || (!runes && reaction === current_effect)) {
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
set_signal_status(reaction, status);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// If the signal a) was previously clean or b) is an unowned derived, then mark it
|
|
|
|
|
|
|
|
if ((flags & (CLEAN | UNOWNED)) !== 0) {
|
|
|
|
|
|
|
|
if ((flags & DERIVED) !== 0) {
|
|
|
|
|
|
|
|
mark_reactions(/** @type {import('#client').Derived} */ (reaction), MAYBE_DIRTY);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
schedule_effect(/** @type {import('#client').Effect} */ (reaction));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|