pull/15844/head
Rich Harris 2 months ago
parent ffc1f6bd5e
commit a7e0c84782

@ -59,7 +59,6 @@ import { UpdateExpression } from './visitors/UpdateExpression.js';
import { UseDirective } from './visitors/UseDirective.js'; import { UseDirective } from './visitors/UseDirective.js';
import { AttachTag } from './visitors/AttachTag.js'; import { AttachTag } from './visitors/AttachTag.js';
import { VariableDeclaration } from './visitors/VariableDeclaration.js'; import { VariableDeclaration } from './visitors/VariableDeclaration.js';
import { Memoizer } from './visitors/shared/utils.js';
/** @type {Visitors} */ /** @type {Visitors} */
const visitors = { const visitors = {

@ -1,4 +1,4 @@
/** @import { BlockStatement, Expression } from 'estree' */ /** @import { BlockStatement } from 'estree' */
/** @import { AST } from '#compiler' */ /** @import { AST } from '#compiler' */
/** @import { ComponentContext } from '../types' */ /** @import { ComponentContext } from '../types' */
import { BLOCK_CLOSE, BLOCK_OPEN } from '../../../../../internal/server/hydration.js'; import { BLOCK_CLOSE, BLOCK_OPEN } from '../../../../../internal/server/hydration.js';

@ -22,7 +22,7 @@ export const USER_EFFECT = 1 << 20;
// Flags used for async // Flags used for async
export const REACTION_IS_UPDATING = 1 << 21; export const REACTION_IS_UPDATING = 1 << 21;
export const EFFECT_ASYNC = 1 << 22; export const ASYNC = 1 << 22;
export const ERROR_VALUE = 1 << 23; export const ERROR_VALUE = 1 << 23;

@ -7,7 +7,7 @@ import {
CLEAN, CLEAN,
DERIVED, DERIVED,
EFFECT, EFFECT,
EFFECT_ASYNC, ASYNC,
MAYBE_DIRTY, MAYBE_DIRTY,
RENDER_EFFECT, RENDER_EFFECT,
ROOT_EFFECT ROOT_EFFECT
@ -40,7 +40,7 @@ export function log_effect_tree(effect, depth = 0) {
label = 'boundary'; label = 'boundary';
} else if ((flags & BLOCK_EFFECT) !== 0) { } else if ((flags & BLOCK_EFFECT) !== 0) {
label = 'block'; label = 'block';
} else if ((flags & EFFECT_ASYNC) !== 0) { } else if ((flags & ASYNC) !== 0) {
label = 'async'; label = 'async';
} else if ((flags & BRANCH_EFFECT) !== 0) { } else if ((flags & BRANCH_EFFECT) !== 0) {
label = 'branch'; label = 'branch';

@ -2,7 +2,7 @@
import { UNINITIALIZED } from '../../../constants.js'; import { UNINITIALIZED } from '../../../constants.js';
import { snapshot } from '../../shared/clone.js'; import { snapshot } from '../../shared/clone.js';
import { define_property } from '../../shared/utils.js'; import { define_property } from '../../shared/utils.js';
import { DERIVED, EFFECT_ASYNC, PROXY_PATH_SYMBOL, STATE_SYMBOL } from '#client/constants'; import { DERIVED, ASYNC, PROXY_PATH_SYMBOL, STATE_SYMBOL } from '#client/constants';
import { effect_tracking } from '../reactivity/effects.js'; import { effect_tracking } from '../reactivity/effects.js';
import { active_reaction, captured_signals, set_captured_signals, untrack } from '../runtime.js'; import { active_reaction, captured_signals, set_captured_signals, untrack } from '../runtime.js';
@ -26,7 +26,7 @@ function log_entry(signal, entry) {
return; return;
} }
const type = (signal.f & (DERIVED | EFFECT_ASYNC)) !== 0 ? '$derived' : '$state'; const type = (signal.f & (DERIVED | ASYNC)) !== 0 ? '$derived' : '$state';
const current_reaction = /** @type {Reaction} */ (active_reaction); const current_reaction = /** @type {Reaction} */ (active_reaction);
const dirty = signal.wv > current_reaction.wv || current_reaction.wv === 0; const dirty = signal.wv > current_reaction.wv || current_reaction.wv === 0;
const style = dirty const style = dirty

@ -6,7 +6,7 @@ import {
DESTROYED, DESTROYED,
DIRTY, DIRTY,
EFFECT, EFFECT,
EFFECT_ASYNC, ASYNC,
INERT, INERT,
RENDER_EFFECT, RENDER_EFFECT,
ROOT_EFFECT, ROOT_EFFECT,
@ -248,7 +248,7 @@ export class Batch {
} else if (async_mode_flag && (flags & RENDER_EFFECT) !== 0) { } else if (async_mode_flag && (flags & RENDER_EFFECT) !== 0) {
this.#render_effects.push(effect); this.#render_effects.push(effect);
} else if (is_dirty(effect)) { } else if (is_dirty(effect)) {
if ((flags & EFFECT_ASYNC) !== 0) { if ((flags & ASYNC) !== 0) {
var effects = effect.b?.pending ? this.#boundary_async_effects : this.#async_effects; var effects = effect.b?.pending ? this.#boundary_async_effects : this.#async_effects;
effects.push(effect); effects.push(effect);
} else { } else {

@ -11,7 +11,7 @@ import {
STALE_REACTION, STALE_REACTION,
UNOWNED, UNOWNED,
DESTROYED, DESTROYED,
EFFECT_ASYNC ASYNC
} from '#client/constants'; } from '#client/constants';
import { import {
active_reaction, active_reaction,
@ -194,7 +194,7 @@ export function async_derived(fn, location) {
if (DEV) { if (DEV) {
// add a flag that lets this be printed as a derived // add a flag that lets this be printed as a derived
// when using `$inspect.trace()` // when using `$inspect.trace()`
signal.f |= EFFECT_ASYNC; signal.f |= ASYNC;
} }
return new Promise((fulfil) => { return new Promise((fulfil) => {

@ -34,7 +34,7 @@ import {
BOUNDARY_EFFECT, BOUNDARY_EFFECT,
STALE_REACTION, STALE_REACTION,
USER_EFFECT, USER_EFFECT,
EFFECT_ASYNC ASYNC
} from '#client/constants'; } from '#client/constants';
import * as e from '../errors.js'; import * as e from '../errors.js';
import { DEV } from 'esm-env'; import { DEV } from 'esm-env';
@ -332,7 +332,7 @@ export function legacy_pre_effect_reset() {
* @returns {Effect} * @returns {Effect}
*/ */
export function async_effect(fn) { export function async_effect(fn) {
return create_effect(EFFECT_ASYNC | EFFECT_PRESERVED, fn, true); return create_effect(ASYNC | EFFECT_PRESERVED, fn, true);
} }
/** /**

@ -27,7 +27,7 @@ import {
MAYBE_DIRTY, MAYBE_DIRTY,
BLOCK_EFFECT, BLOCK_EFFECT,
ROOT_EFFECT, ROOT_EFFECT,
EFFECT_ASYNC ASYNC
} from '#client/constants'; } from '#client/constants';
import * as e from '../errors.js'; import * as e from '../errors.js';
import { legacy_mode_flag, tracing_mode_flag } from '../../flags/index.js'; import { legacy_mode_flag, tracing_mode_flag } from '../../flags/index.js';
@ -140,7 +140,7 @@ export function set(source, value, should_proxy = false) {
// to ensure we error if state is set inside an inspect effect // to ensure we error if state is set inside an inspect effect
(!untracking || (active_reaction.f & INSPECT_EFFECT) !== 0) && (!untracking || (active_reaction.f & INSPECT_EFFECT) !== 0) &&
is_runes() && is_runes() &&
(active_reaction.f & (DERIVED | BLOCK_EFFECT | EFFECT_ASYNC | INSPECT_EFFECT)) !== 0 && (active_reaction.f & (DERIVED | BLOCK_EFFECT | ASYNC | INSPECT_EFFECT)) !== 0 &&
!current_sources?.includes(source) !current_sources?.includes(source)
) { ) {
e.state_unsafe_mutation(); e.state_unsafe_mutation();

Loading…
Cancel
Save