|
|
@ -9,18 +9,97 @@ import {
|
|
|
|
RENDER_EFFECT,
|
|
|
|
RENDER_EFFECT,
|
|
|
|
UNINITIALIZED,
|
|
|
|
UNINITIALIZED,
|
|
|
|
UNOWNED,
|
|
|
|
UNOWNED,
|
|
|
|
create_computation_signal,
|
|
|
|
|
|
|
|
current_block,
|
|
|
|
current_block,
|
|
|
|
current_component_context,
|
|
|
|
current_component_context,
|
|
|
|
current_consumer,
|
|
|
|
current_consumer,
|
|
|
|
current_effect,
|
|
|
|
current_effect,
|
|
|
|
destroy_signal,
|
|
|
|
destroy_signal,
|
|
|
|
flush_local_render_effects,
|
|
|
|
flush_local_render_effects,
|
|
|
|
push_reference,
|
|
|
|
|
|
|
|
schedule_effect
|
|
|
|
schedule_effect
|
|
|
|
} from '../runtime.js';
|
|
|
|
} from '../runtime.js';
|
|
|
|
import { default_equals, safe_equal } from './equality.js';
|
|
|
|
import { default_equals, safe_equal } from './equality.js';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @template V
|
|
|
|
|
|
|
|
* @param {import('../types.js').SignalFlags} flags
|
|
|
|
|
|
|
|
* @param {V} value
|
|
|
|
|
|
|
|
* @param {import('../types.js').Block | null} block
|
|
|
|
|
|
|
|
* @returns {import('../types.js').ComputationSignal<V> | import('../types.js').ComputationSignal<V> & import('../types.js').SourceSignalDebug}
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
function create_computation_signal(flags, value, block) {
|
|
|
|
|
|
|
|
if (DEV) {
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
|
|
// block
|
|
|
|
|
|
|
|
b: block,
|
|
|
|
|
|
|
|
// consumers
|
|
|
|
|
|
|
|
c: null,
|
|
|
|
|
|
|
|
// destroy
|
|
|
|
|
|
|
|
d: null,
|
|
|
|
|
|
|
|
// equals
|
|
|
|
|
|
|
|
e: null,
|
|
|
|
|
|
|
|
// flags
|
|
|
|
|
|
|
|
f: flags,
|
|
|
|
|
|
|
|
// init
|
|
|
|
|
|
|
|
i: null,
|
|
|
|
|
|
|
|
// level
|
|
|
|
|
|
|
|
l: 0,
|
|
|
|
|
|
|
|
// references
|
|
|
|
|
|
|
|
r: null,
|
|
|
|
|
|
|
|
// value
|
|
|
|
|
|
|
|
v: value,
|
|
|
|
|
|
|
|
// write version
|
|
|
|
|
|
|
|
w: 0,
|
|
|
|
|
|
|
|
// context: We can remove this if we get rid of beforeUpdate/afterUpdate
|
|
|
|
|
|
|
|
x: null,
|
|
|
|
|
|
|
|
// destroy
|
|
|
|
|
|
|
|
y: null,
|
|
|
|
|
|
|
|
// this is for DEV only
|
|
|
|
|
|
|
|
inspect: new Set()
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
|
|
// block
|
|
|
|
|
|
|
|
b: block,
|
|
|
|
|
|
|
|
// consumers
|
|
|
|
|
|
|
|
c: null,
|
|
|
|
|
|
|
|
// destroy
|
|
|
|
|
|
|
|
d: null,
|
|
|
|
|
|
|
|
// equals
|
|
|
|
|
|
|
|
e: null,
|
|
|
|
|
|
|
|
// flags
|
|
|
|
|
|
|
|
f: flags,
|
|
|
|
|
|
|
|
// level
|
|
|
|
|
|
|
|
l: 0,
|
|
|
|
|
|
|
|
// init
|
|
|
|
|
|
|
|
i: null,
|
|
|
|
|
|
|
|
// references
|
|
|
|
|
|
|
|
r: null,
|
|
|
|
|
|
|
|
// value
|
|
|
|
|
|
|
|
v: value,
|
|
|
|
|
|
|
|
// write version
|
|
|
|
|
|
|
|
w: 0,
|
|
|
|
|
|
|
|
// context: We can remove this if we get rid of beforeUpdate/afterUpdate
|
|
|
|
|
|
|
|
x: null,
|
|
|
|
|
|
|
|
// destroy
|
|
|
|
|
|
|
|
y: null
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @param {import('../types.js').ComputationSignal} target_signal
|
|
|
|
|
|
|
|
* @param {import('../types.js').ComputationSignal} ref_signal
|
|
|
|
|
|
|
|
* @returns {void}
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
export function push_reference(target_signal, ref_signal) {
|
|
|
|
|
|
|
|
const references = target_signal.r;
|
|
|
|
|
|
|
|
if (references === null) {
|
|
|
|
|
|
|
|
target_signal.r = [ref_signal];
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
references.push(ref_signal);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @param {import('../types.js').EffectType} type
|
|
|
|
* @param {import('../types.js').EffectType} type
|
|
|
|
* @param {(() => void | (() => void)) | ((b: import('../types.js').Block) => void | (() => void))} init
|
|
|
|
* @param {(() => void | (() => void)) | ((b: import('../types.js').Block) => void | (() => void))} init
|
|
|
|