svelte 5.43.13 → 5.43.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compiler/index.js +1 -1
- package/package.json +1 -1
- package/src/compiler/errors.js +9 -0
- package/src/compiler/migrate/index.js +5 -3
- package/src/compiler/phases/1-parse/state/element.js +2 -3
- package/src/compiler/phases/2-analyze/index.js +2 -0
- package/src/compiler/phases/2-analyze/visitors/AnimateDirective.js +15 -0
- package/src/compiler/phases/2-analyze/visitors/AttachTag.js +5 -1
- package/src/compiler/phases/2-analyze/visitors/BindDirective.js +10 -0
- package/src/compiler/phases/2-analyze/visitors/TransitionDirective.js +6 -1
- package/src/compiler/phases/2-analyze/visitors/UseDirective.js +7 -1
- package/src/compiler/phases/3-transform/client/visitors/AnimateDirective.js +18 -8
- package/src/compiler/phases/3-transform/client/visitors/AttachTag.js +13 -1
- package/src/compiler/phases/3-transform/client/visitors/TransitionDirective.js +13 -1
- package/src/compiler/phases/3-transform/client/visitors/UseDirective.js +13 -1
- package/src/compiler/phases/3-transform/client/visitors/shared/component.js +3 -0
- package/src/compiler/phases/3-transform/server/visitors/shared/component.js +4 -0
- package/src/internal/client/constants.js +9 -0
- package/src/internal/client/dom/elements/attachments.js +2 -2
- package/src/internal/client/dom/elements/attributes.js +2 -2
- package/src/internal/client/dom/elements/transitions.js +1 -7
- package/src/internal/client/errors.js +0 -16
- package/src/internal/client/reactivity/async.js +6 -1
- package/src/internal/client/reactivity/batch.js +7 -8
- package/src/internal/client/reactivity/deriveds.js +1 -1
- package/src/internal/client/reactivity/effects.js +14 -1
- package/src/internal/client/reactivity/sources.js +2 -4
- package/src/internal/client/runtime.js +14 -4
- package/src/version.js +1 -1
- package/types/index.d.ts.map +1 -1
package/package.json
CHANGED
package/src/compiler/errors.js
CHANGED
|
@@ -1148,6 +1148,15 @@ export function expected_whitespace(node) {
|
|
|
1148
1148
|
e(node, 'expected_whitespace', `Expected whitespace\nhttps://svelte.dev/e/expected_whitespace`);
|
|
1149
1149
|
}
|
|
1150
1150
|
|
|
1151
|
+
/**
|
|
1152
|
+
* `use:`, `transition:` and `animate:` directives, attachments and bindings do not support await expressions
|
|
1153
|
+
* @param {null | number | NodeLike} node
|
|
1154
|
+
* @returns {never}
|
|
1155
|
+
*/
|
|
1156
|
+
export function illegal_await_expression(node) {
|
|
1157
|
+
e(node, 'illegal_await_expression', `\`use:\`, \`transition:\` and \`animate:\` directives, attachments and bindings do not support await expressions\nhttps://svelte.dev/e/illegal_await_expression`);
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1151
1160
|
/**
|
|
1152
1161
|
* `<%name%>` does not support non-event attributes or spread attributes
|
|
1153
1162
|
* @param {null | number | NodeLike} node
|
|
@@ -1058,8 +1058,6 @@ const template = {
|
|
|
1058
1058
|
handle_identifier(node, state, path);
|
|
1059
1059
|
},
|
|
1060
1060
|
RegularElement(node, { state, path, next }) {
|
|
1061
|
-
migrate_slot_usage(node, path, state);
|
|
1062
|
-
handle_events(node, state);
|
|
1063
1061
|
// Strip off any namespace from the beginning of the node name.
|
|
1064
1062
|
const node_name = node.name.replace(/[a-zA-Z-]*:/g, '');
|
|
1065
1063
|
|
|
@@ -1067,8 +1065,12 @@ const template = {
|
|
|
1067
1065
|
let trimmed_position = node.end - 2;
|
|
1068
1066
|
while (state.str.original.charAt(trimmed_position - 1) === ' ') trimmed_position--;
|
|
1069
1067
|
state.str.remove(trimmed_position, node.end - 1);
|
|
1070
|
-
state.str.
|
|
1068
|
+
state.str.appendLeft(node.end, `</${node.name}>`);
|
|
1071
1069
|
}
|
|
1070
|
+
|
|
1071
|
+
migrate_slot_usage(node, path, state);
|
|
1072
|
+
handle_events(node, state);
|
|
1073
|
+
|
|
1072
1074
|
next();
|
|
1073
1075
|
},
|
|
1074
1076
|
SvelteSelf(node, { state, next }) {
|
|
@@ -654,8 +654,7 @@ function read_attribute(parser) {
|
|
|
654
654
|
}
|
|
655
655
|
}
|
|
656
656
|
|
|
657
|
-
/** @type {AST.Directive} */
|
|
658
|
-
const directive = {
|
|
657
|
+
const directive = /** @type {AST.Directive} */ ({
|
|
659
658
|
start,
|
|
660
659
|
end,
|
|
661
660
|
type,
|
|
@@ -664,7 +663,7 @@ function read_attribute(parser) {
|
|
|
664
663
|
metadata: {
|
|
665
664
|
expression: new ExpressionMetadata()
|
|
666
665
|
}
|
|
667
|
-
};
|
|
666
|
+
});
|
|
668
667
|
|
|
669
668
|
// @ts-expect-error we do this separately from the declaration to avoid upsetting typescript
|
|
670
669
|
directive.modifiers = modifiers;
|
|
@@ -24,6 +24,7 @@ import { extract_svelte_ignore } from '../../utils/extract_svelte_ignore.js';
|
|
|
24
24
|
import { ignore_map, ignore_stack, pop_ignore, push_ignore } from '../../state.js';
|
|
25
25
|
import { ArrowFunctionExpression } from './visitors/ArrowFunctionExpression.js';
|
|
26
26
|
import { AssignmentExpression } from './visitors/AssignmentExpression.js';
|
|
27
|
+
import { AnimateDirective } from './visitors/AnimateDirective.js';
|
|
27
28
|
import { AttachTag } from './visitors/AttachTag.js';
|
|
28
29
|
import { Attribute } from './visitors/Attribute.js';
|
|
29
30
|
import { AwaitBlock } from './visitors/AwaitBlock.js';
|
|
@@ -142,6 +143,7 @@ const visitors = {
|
|
|
142
143
|
pop_ignore();
|
|
143
144
|
}
|
|
144
145
|
},
|
|
146
|
+
AnimateDirective,
|
|
145
147
|
ArrowFunctionExpression,
|
|
146
148
|
AssignmentExpression,
|
|
147
149
|
AttachTag,
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** @import { Context } from '../types' */
|
|
2
|
+
/** @import { AST } from '#compiler'; */
|
|
3
|
+
import * as e from '../../../errors.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @param {AST.AnimateDirective} node
|
|
7
|
+
* @param {Context} context
|
|
8
|
+
*/
|
|
9
|
+
export function AnimateDirective(node, context) {
|
|
10
|
+
context.next({ ...context.state, expression: node.metadata.expression });
|
|
11
|
+
|
|
12
|
+
if (node.metadata.expression.has_await) {
|
|
13
|
+
e.illegal_await_expression(node);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** @import { AST } from '#compiler' */
|
|
2
2
|
/** @import { Context } from '../types' */
|
|
3
|
-
|
|
4
3
|
import { mark_subtree_dynamic } from './shared/fragment.js';
|
|
4
|
+
import * as e from '../../../errors.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* @param {AST.AttachTag} node
|
|
@@ -10,4 +10,8 @@ import { mark_subtree_dynamic } from './shared/fragment.js';
|
|
|
10
10
|
export function AttachTag(node, context) {
|
|
11
11
|
mark_subtree_dynamic(context.path);
|
|
12
12
|
context.next({ ...context.state, expression: node.metadata.expression });
|
|
13
|
+
|
|
14
|
+
if (node.metadata.expression.has_await) {
|
|
15
|
+
e.illegal_await_expression(node);
|
|
16
|
+
}
|
|
13
17
|
}
|
|
@@ -161,6 +161,7 @@ export function BindDirective(node, context) {
|
|
|
161
161
|
|
|
162
162
|
const [get, set] = node.expression.expressions;
|
|
163
163
|
// We gotta jump across the getter/setter functions to avoid the expression metadata field being reset to null
|
|
164
|
+
// as we want to collect the functions' blocker/async info
|
|
164
165
|
context.visit(get.type === 'ArrowFunctionExpression' ? get.body : get, {
|
|
165
166
|
...context.state,
|
|
166
167
|
expression: node.metadata.expression
|
|
@@ -169,6 +170,11 @@ export function BindDirective(node, context) {
|
|
|
169
170
|
...context.state,
|
|
170
171
|
expression: node.metadata.expression
|
|
171
172
|
});
|
|
173
|
+
|
|
174
|
+
if (node.metadata.expression.has_await) {
|
|
175
|
+
e.illegal_await_expression(node);
|
|
176
|
+
}
|
|
177
|
+
|
|
172
178
|
return;
|
|
173
179
|
}
|
|
174
180
|
|
|
@@ -267,4 +273,8 @@ export function BindDirective(node, context) {
|
|
|
267
273
|
}
|
|
268
274
|
|
|
269
275
|
context.next({ ...context.state, expression: node.metadata.expression });
|
|
276
|
+
|
|
277
|
+
if (node.metadata.expression.has_await) {
|
|
278
|
+
e.illegal_await_expression(node);
|
|
279
|
+
}
|
|
270
280
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/** @import { AST } from '#compiler' */
|
|
2
2
|
/** @import { Context } from '../types' */
|
|
3
|
+
import * as e from '../../../errors.js';
|
|
3
4
|
|
|
4
5
|
import { mark_subtree_dynamic } from './shared/fragment.js';
|
|
5
6
|
|
|
@@ -10,5 +11,9 @@ import { mark_subtree_dynamic } from './shared/fragment.js';
|
|
|
10
11
|
export function TransitionDirective(node, context) {
|
|
11
12
|
mark_subtree_dynamic(context.path);
|
|
12
13
|
|
|
13
|
-
context.next();
|
|
14
|
+
context.next({ ...context.state, expression: node.metadata.expression });
|
|
15
|
+
|
|
16
|
+
if (node.metadata.expression.has_await) {
|
|
17
|
+
e.illegal_await_expression(node);
|
|
18
|
+
}
|
|
14
19
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/** @import { AST } from '#compiler' */
|
|
2
2
|
/** @import { Context } from '../types' */
|
|
3
3
|
import { mark_subtree_dynamic } from './shared/fragment.js';
|
|
4
|
+
import * as e from '../../../errors.js';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* @param {AST.UseDirective} node
|
|
@@ -8,5 +9,10 @@ import { mark_subtree_dynamic } from './shared/fragment.js';
|
|
|
8
9
|
*/
|
|
9
10
|
export function UseDirective(node, context) {
|
|
10
11
|
mark_subtree_dynamic(context.path);
|
|
11
|
-
|
|
12
|
+
|
|
13
|
+
context.next({ ...context.state, expression: node.metadata.expression });
|
|
14
|
+
|
|
15
|
+
if (node.metadata.expression.has_await) {
|
|
16
|
+
e.illegal_await_expression(node);
|
|
17
|
+
}
|
|
12
18
|
}
|
|
@@ -15,14 +15,24 @@ export function AnimateDirective(node, context) {
|
|
|
15
15
|
: b.thunk(/** @type {Expression} */ (context.visit(node.expression)));
|
|
16
16
|
|
|
17
17
|
// in after_update to ensure it always happens after bind:this
|
|
18
|
-
|
|
19
|
-
b.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
expression
|
|
25
|
-
)
|
|
18
|
+
let statement = b.stmt(
|
|
19
|
+
b.call(
|
|
20
|
+
'$.animation',
|
|
21
|
+
context.state.node,
|
|
22
|
+
b.thunk(/** @type {Expression} */ (context.visit(parse_directive_name(node.name)))),
|
|
23
|
+
expression
|
|
26
24
|
)
|
|
27
25
|
);
|
|
26
|
+
|
|
27
|
+
if (node.metadata.expression.is_async()) {
|
|
28
|
+
statement = b.stmt(
|
|
29
|
+
b.call(
|
|
30
|
+
'$.run_after_blockers',
|
|
31
|
+
node.metadata.expression.blockers(),
|
|
32
|
+
b.thunk(b.block([statement]))
|
|
33
|
+
)
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
context.state.after_update.push(statement);
|
|
28
38
|
}
|
|
@@ -9,6 +9,18 @@ import { build_expression } from './shared/utils.js';
|
|
|
9
9
|
*/
|
|
10
10
|
export function AttachTag(node, context) {
|
|
11
11
|
const expression = build_expression(context, node.expression, node.metadata.expression);
|
|
12
|
-
|
|
12
|
+
let statement = b.stmt(b.call('$.attach', context.state.node, b.thunk(expression)));
|
|
13
|
+
|
|
14
|
+
if (node.metadata.expression.is_async()) {
|
|
15
|
+
statement = b.stmt(
|
|
16
|
+
b.call(
|
|
17
|
+
'$.run_after_blockers',
|
|
18
|
+
node.metadata.expression.blockers(),
|
|
19
|
+
b.thunk(b.block([statement]))
|
|
20
|
+
)
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
context.state.init.push(statement);
|
|
13
25
|
context.next();
|
|
14
26
|
}
|
|
@@ -25,5 +25,17 @@ export function TransitionDirective(node, context) {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
// in after_update to ensure it always happens after bind:this
|
|
28
|
-
|
|
28
|
+
let statement = b.stmt(b.call('$.transition', ...args));
|
|
29
|
+
|
|
30
|
+
if (node.metadata.expression.is_async()) {
|
|
31
|
+
statement = b.stmt(
|
|
32
|
+
b.call(
|
|
33
|
+
'$.run_after_blockers',
|
|
34
|
+
node.metadata.expression.blockers(),
|
|
35
|
+
b.thunk(b.block([statement]))
|
|
36
|
+
)
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
context.state.after_update.push(statement);
|
|
29
41
|
}
|
|
@@ -32,6 +32,18 @@ export function UseDirective(node, context) {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
// actions need to run after attribute updates in order with bindings/events
|
|
35
|
-
|
|
35
|
+
let statement = b.stmt(b.call('$.action', ...args));
|
|
36
|
+
|
|
37
|
+
if (node.metadata.expression.is_async()) {
|
|
38
|
+
statement = b.stmt(
|
|
39
|
+
b.call(
|
|
40
|
+
'$.run_after_blockers',
|
|
41
|
+
node.metadata.expression.blockers(),
|
|
42
|
+
b.thunk(b.block([statement]))
|
|
43
|
+
)
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
context.state.init.push(statement);
|
|
36
48
|
context.next();
|
|
37
49
|
}
|
|
@@ -296,6 +296,9 @@ export function build_component(node, component_name, context) {
|
|
|
296
296
|
);
|
|
297
297
|
}
|
|
298
298
|
|
|
299
|
+
// TODO also support await expressions here?
|
|
300
|
+
memoizer.check_blockers(attribute.metadata.expression);
|
|
301
|
+
|
|
299
302
|
push_prop(b.prop('init', b.call('$.attachment'), expression, true));
|
|
300
303
|
}
|
|
301
304
|
}
|
|
@@ -142,6 +142,10 @@ export function build_inline_component(node, expression, context) {
|
|
|
142
142
|
true
|
|
143
143
|
);
|
|
144
144
|
}
|
|
145
|
+
} else if (attribute.type === 'AttachTag') {
|
|
146
|
+
// While we don't run attachments on the server, on the client they might generate a surrounding blocker function which generates
|
|
147
|
+
// extra comments, and to prevent hydration mismatches we therefore have to account for them here to generate similar comments on the server.
|
|
148
|
+
optimiser.check_blockers(attribute.metadata.expression);
|
|
145
149
|
}
|
|
146
150
|
}
|
|
147
151
|
|
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
export const DERIVED = 1 << 1;
|
|
3
3
|
export const EFFECT = 1 << 2;
|
|
4
4
|
export const RENDER_EFFECT = 1 << 3;
|
|
5
|
+
/**
|
|
6
|
+
* An effect that does not destroy its child effects when it reruns.
|
|
7
|
+
* Runs as part of render effects, i.e. not eagerly as part of tree traversal or effect flushing.
|
|
8
|
+
*/
|
|
9
|
+
export const MANAGED_EFFECT = 1 << 24;
|
|
10
|
+
/**
|
|
11
|
+
* An effect that does not destroy its child effects when it reruns (like MANAGED_EFFECT).
|
|
12
|
+
* Runs eagerly as part of tree traversal or effect flushing.
|
|
13
|
+
*/
|
|
5
14
|
export const BLOCK_EFFECT = 1 << 4;
|
|
6
15
|
export const BRANCH_EFFECT = 1 << 5;
|
|
7
16
|
export const ROOT_EFFECT = 1 << 6;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** @import { Effect } from '#client' */
|
|
2
|
-
import {
|
|
2
|
+
import { branch, effect, destroy_effect, managed } from '../../reactivity/effects.js';
|
|
3
3
|
|
|
4
4
|
// TODO in 6.0 or 7.0, when we remove legacy mode, we can simplify this by
|
|
5
5
|
// getting rid of the block/branch stuff and just letting the effect rip.
|
|
@@ -16,7 +16,7 @@ export function attach(node, get_fn) {
|
|
|
16
16
|
/** @type {Effect | null} */
|
|
17
17
|
var e;
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
managed(() => {
|
|
20
20
|
if (fn !== (fn = get_fn())) {
|
|
21
21
|
if (e) {
|
|
22
22
|
destroy_effect(e);
|
|
@@ -20,7 +20,7 @@ import { clsx } from '../../../shared/attributes.js';
|
|
|
20
20
|
import { set_class } from './class.js';
|
|
21
21
|
import { set_style } from './style.js';
|
|
22
22
|
import { ATTACHMENT_KEY, NAMESPACE_HTML, UNINITIALIZED } from '../../../../constants.js';
|
|
23
|
-
import {
|
|
23
|
+
import { branch, destroy_effect, effect, managed } from '../../reactivity/effects.js';
|
|
24
24
|
import { init_select, select_option } from './bindings/select.js';
|
|
25
25
|
import { flatten } from '../../reactivity/async.js';
|
|
26
26
|
|
|
@@ -508,7 +508,7 @@ export function attribute_effect(
|
|
|
508
508
|
var is_select = element.nodeName === 'SELECT';
|
|
509
509
|
var inited = false;
|
|
510
510
|
|
|
511
|
-
|
|
511
|
+
managed(() => {
|
|
512
512
|
var next = fn(...values.map(get));
|
|
513
513
|
/** @type {Record<string | symbol, any>} */
|
|
514
514
|
var current = set_attributes(
|
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
/** @import { AnimateFn, Animation, AnimationConfig, EachItem, Effect, TransitionFn, TransitionManager } from '#client' */
|
|
2
2
|
import { noop, is_function } from '../../../shared/utils.js';
|
|
3
3
|
import { effect } from '../../reactivity/effects.js';
|
|
4
|
-
import {
|
|
5
|
-
active_effect,
|
|
6
|
-
active_reaction,
|
|
7
|
-
set_active_effect,
|
|
8
|
-
set_active_reaction,
|
|
9
|
-
untrack
|
|
10
|
-
} from '../../runtime.js';
|
|
4
|
+
import { active_effect, untrack } from '../../runtime.js';
|
|
11
5
|
import { loop } from '../../loop.js';
|
|
12
6
|
import { should_intro } from '../../render.js';
|
|
13
7
|
import { current_each_item } from '../blocks/each.js';
|
|
@@ -245,22 +245,6 @@ export function experimental_async_fork() {
|
|
|
245
245
|
}
|
|
246
246
|
}
|
|
247
247
|
|
|
248
|
-
/**
|
|
249
|
-
* Cannot use `flushSync` inside an effect
|
|
250
|
-
* @returns {never}
|
|
251
|
-
*/
|
|
252
|
-
export function flush_sync_in_effect() {
|
|
253
|
-
if (DEV) {
|
|
254
|
-
const error = new Error(`flush_sync_in_effect\nCannot use \`flushSync\` inside an effect\nhttps://svelte.dev/e/flush_sync_in_effect`);
|
|
255
|
-
|
|
256
|
-
error.name = 'Svelte error';
|
|
257
|
-
|
|
258
|
-
throw error;
|
|
259
|
-
} else {
|
|
260
|
-
throw new Error(`https://svelte.dev/e/flush_sync_in_effect`);
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
|
|
264
248
|
/**
|
|
265
249
|
* Cannot commit a fork that was already discarded
|
|
266
250
|
* @returns {never}
|
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
} from './deriveds.js';
|
|
27
27
|
import { aborted } from './effects.js';
|
|
28
28
|
import { hydrate_next, hydrating, set_hydrate_node, skip_nodes } from '../dom/hydration.js';
|
|
29
|
+
import { current_each_item, set_current_each_item } from '../dom/blocks/each.js';
|
|
29
30
|
|
|
30
31
|
/**
|
|
31
32
|
* @param {Array<Promise<void>>} blockers
|
|
@@ -89,7 +90,11 @@ export function flatten(blockers, sync, async, fn) {
|
|
|
89
90
|
* @param {(values: Value[]) => any} fn
|
|
90
91
|
*/
|
|
91
92
|
export function run_after_blockers(blockers, fn) {
|
|
92
|
-
|
|
93
|
+
var each_item = current_each_item; // TODO should this be part of capture?
|
|
94
|
+
flatten(blockers, [], [], (v) => {
|
|
95
|
+
set_current_each_item(each_item);
|
|
96
|
+
fn(v);
|
|
97
|
+
});
|
|
93
98
|
}
|
|
94
99
|
|
|
95
100
|
/**
|
|
@@ -17,7 +17,8 @@ import {
|
|
|
17
17
|
EAGER_EFFECT,
|
|
18
18
|
HEAD_EFFECT,
|
|
19
19
|
ERROR_VALUE,
|
|
20
|
-
WAS_MARKED
|
|
20
|
+
WAS_MARKED,
|
|
21
|
+
MANAGED_EFFECT
|
|
21
22
|
} from '#client/constants';
|
|
22
23
|
import { async_mode_flag } from '../../flags/index.js';
|
|
23
24
|
import { deferred, define_property } from '../../shared/utils.js';
|
|
@@ -234,7 +235,7 @@ export class Batch {
|
|
|
234
235
|
effect.f ^= CLEAN;
|
|
235
236
|
} else if ((flags & EFFECT) !== 0) {
|
|
236
237
|
target.effects.push(effect);
|
|
237
|
-
} else if (async_mode_flag && (flags & RENDER_EFFECT) !== 0) {
|
|
238
|
+
} else if (async_mode_flag && (flags & (RENDER_EFFECT | MANAGED_EFFECT)) !== 0) {
|
|
238
239
|
target.render_effects.push(effect);
|
|
239
240
|
} else if (is_dirty(effect)) {
|
|
240
241
|
if ((effect.f & BLOCK_EFFECT) !== 0) target.block_effects.push(effect);
|
|
@@ -562,11 +563,6 @@ export class Batch {
|
|
|
562
563
|
* @returns {T}
|
|
563
564
|
*/
|
|
564
565
|
export function flushSync(fn) {
|
|
565
|
-
if (async_mode_flag && active_effect !== null) {
|
|
566
|
-
// We disallow this because it creates super-hard to reason about stack trace and because it's generally a bad idea
|
|
567
|
-
e.flush_sync_in_effect();
|
|
568
|
-
}
|
|
569
|
-
|
|
570
566
|
var was_flushing_sync = is_flushing_sync;
|
|
571
567
|
is_flushing_sync = true;
|
|
572
568
|
|
|
@@ -779,7 +775,7 @@ function mark_effects(value, sources, marked, checked) {
|
|
|
779
775
|
mark_effects(/** @type {Derived} */ (reaction), sources, marked, checked);
|
|
780
776
|
} else if (
|
|
781
777
|
(flags & (ASYNC | BLOCK_EFFECT)) !== 0 &&
|
|
782
|
-
(flags & DIRTY) === 0 &&
|
|
778
|
+
(flags & DIRTY) === 0 &&
|
|
783
779
|
depends_on(reaction, sources, checked)
|
|
784
780
|
) {
|
|
785
781
|
set_signal_status(reaction, DIRTY);
|
|
@@ -958,12 +954,15 @@ export function fork(fn) {
|
|
|
958
954
|
|
|
959
955
|
var batch = Batch.ensure();
|
|
960
956
|
batch.is_fork = true;
|
|
957
|
+
batch_values = new Map();
|
|
961
958
|
|
|
962
959
|
var committed = false;
|
|
963
960
|
var settled = batch.settled();
|
|
964
961
|
|
|
965
962
|
flushSync(fn);
|
|
966
963
|
|
|
964
|
+
batch_values = null;
|
|
965
|
+
|
|
967
966
|
// revert state changes
|
|
968
967
|
for (var [source, value] of batch.previous) {
|
|
969
968
|
source.v = value;
|
|
@@ -378,7 +378,7 @@ export function update_derived(derived) {
|
|
|
378
378
|
if (batch_values !== null) {
|
|
379
379
|
// only cache the value if we're in a tracking context, otherwise we won't
|
|
380
380
|
// clear the cache in `mark_reactions` when dependencies are updated
|
|
381
|
-
if (effect_tracking()) {
|
|
381
|
+
if (effect_tracking() || current_batch?.is_fork) {
|
|
382
382
|
batch_values.set(derived, value);
|
|
383
383
|
}
|
|
384
384
|
} else {
|
|
@@ -33,7 +33,8 @@ import {
|
|
|
33
33
|
STALE_REACTION,
|
|
34
34
|
USER_EFFECT,
|
|
35
35
|
ASYNC,
|
|
36
|
-
CONNECTED
|
|
36
|
+
CONNECTED,
|
|
37
|
+
MANAGED_EFFECT
|
|
37
38
|
} from '#client/constants';
|
|
38
39
|
import * as e from '../errors.js';
|
|
39
40
|
import { DEV } from 'esm-env';
|
|
@@ -401,6 +402,18 @@ export function block(fn, flags = 0) {
|
|
|
401
402
|
return effect;
|
|
402
403
|
}
|
|
403
404
|
|
|
405
|
+
/**
|
|
406
|
+
* @param {(() => void)} fn
|
|
407
|
+
* @param {number} flags
|
|
408
|
+
*/
|
|
409
|
+
export function managed(fn, flags = 0) {
|
|
410
|
+
var effect = create_effect(MANAGED_EFFECT | flags, fn, true);
|
|
411
|
+
if (DEV) {
|
|
412
|
+
effect.dev_stack = dev_stack;
|
|
413
|
+
}
|
|
414
|
+
return effect;
|
|
415
|
+
}
|
|
416
|
+
|
|
404
417
|
/**
|
|
405
418
|
* @param {(() => void)} fn
|
|
406
419
|
*/
|
|
@@ -363,10 +363,8 @@ function mark_reactions(signal, status) {
|
|
|
363
363
|
mark_reactions(derived, MAYBE_DIRTY);
|
|
364
364
|
}
|
|
365
365
|
} else if (not_dirty) {
|
|
366
|
-
if ((flags & BLOCK_EFFECT) !== 0) {
|
|
367
|
-
|
|
368
|
-
eager_block_effects.add(/** @type {Effect} */ (reaction));
|
|
369
|
-
}
|
|
366
|
+
if ((flags & BLOCK_EFFECT) !== 0 && eager_block_effects !== null) {
|
|
367
|
+
eager_block_effects.add(/** @type {Effect} */ (reaction));
|
|
370
368
|
}
|
|
371
369
|
|
|
372
370
|
schedule_effect(/** @type {Effect} */ (reaction));
|
|
@@ -21,7 +21,8 @@ import {
|
|
|
21
21
|
REACTION_IS_UPDATING,
|
|
22
22
|
STALE_REACTION,
|
|
23
23
|
ERROR_VALUE,
|
|
24
|
-
WAS_MARKED
|
|
24
|
+
WAS_MARKED,
|
|
25
|
+
MANAGED_EFFECT
|
|
25
26
|
} from './constants.js';
|
|
26
27
|
import { old_values } from './reactivity/sources.js';
|
|
27
28
|
import {
|
|
@@ -43,7 +44,13 @@ import {
|
|
|
43
44
|
set_dev_stack
|
|
44
45
|
} from './context.js';
|
|
45
46
|
import * as w from './warnings.js';
|
|
46
|
-
import {
|
|
47
|
+
import {
|
|
48
|
+
Batch,
|
|
49
|
+
batch_values,
|
|
50
|
+
current_batch,
|
|
51
|
+
flushSync,
|
|
52
|
+
schedule_effect
|
|
53
|
+
} from './reactivity/batch.js';
|
|
47
54
|
import { handle_error } from './error-handling.js';
|
|
48
55
|
import { UNINITIALIZED } from '../../constants.js';
|
|
49
56
|
import { captured_signals } from './legacy.js';
|
|
@@ -421,7 +428,7 @@ export function update_effect(effect) {
|
|
|
421
428
|
}
|
|
422
429
|
|
|
423
430
|
try {
|
|
424
|
-
if ((flags & BLOCK_EFFECT) !== 0) {
|
|
431
|
+
if ((flags & (BLOCK_EFFECT | MANAGED_EFFECT)) !== 0) {
|
|
425
432
|
destroy_block_effect_children(effect);
|
|
426
433
|
} else {
|
|
427
434
|
destroy_effect_children(effect);
|
|
@@ -611,7 +618,10 @@ export function get(signal) {
|
|
|
611
618
|
|
|
612
619
|
return value;
|
|
613
620
|
}
|
|
614
|
-
} else if (
|
|
621
|
+
} else if (
|
|
622
|
+
is_derived &&
|
|
623
|
+
(!batch_values?.has(signal) || (current_batch?.is_fork && !effect_tracking()))
|
|
624
|
+
) {
|
|
615
625
|
derived = /** @type {Derived} */ (signal);
|
|
616
626
|
|
|
617
627
|
if (is_dirty(derived)) {
|
package/src/version.js
CHANGED
package/types/index.d.ts.map
CHANGED
|
@@ -263,6 +263,6 @@
|
|
|
263
263
|
null,
|
|
264
264
|
null
|
|
265
265
|
],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