svelte 5.56.8 → 5.56.10
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/index.js +2 -1
- package/src/compiler/migrate/index.js +6 -1
- package/src/compiler/phases/1-parse/index.js +4 -0
- package/src/compiler/phases/1-parse/read/style.js +75 -29
- package/src/compiler/phases/2-analyze/css/css-analyze.js +3 -0
- package/src/compiler/phases/2-analyze/css/css-warn.js +3 -0
- package/src/compiler/phases/2-analyze/index.js +19 -15
- package/src/compiler/phases/3-transform/client/visitors/AssignmentExpression.js +16 -3
- package/src/compiler/phases/3-transform/client/visitors/RegularElement.js +13 -2
- package/src/compiler/phases/3-transform/client/visitors/UpdateExpression.js +0 -1
- package/src/compiler/phases/3-transform/css/index.js +8 -1
- package/src/compiler/phases/3-transform/server/visitors/LabeledStatement.js +1 -0
- package/src/compiler/phases/3-transform/server/visitors/VariableDeclaration.js +4 -2
- package/src/compiler/phases/3-transform/server/visitors/shared/element.js +48 -43
- package/src/compiler/phases/3-transform/server/visitors/shared/utils.js +1 -1
- package/src/compiler/print/index.js +372 -177
- package/src/internal/client/context.js +20 -53
- package/src/internal/client/dom/blocks/css-props.js +3 -3
- package/src/internal/client/dom/blocks/each.js +6 -2
- package/src/internal/client/dom/css.js +6 -1
- package/src/internal/client/dom/elements/attributes.js +2 -1
- package/src/internal/client/dom/elements/events.js +19 -1
- package/src/internal/client/reactivity/batch.js +1 -0
- package/src/internal/client/reactivity/sources.js +7 -1
- package/src/internal/server/context.js +8 -47
- package/src/internal/server/renderer.js +1 -0
- package/src/internal/shared/attributes.js +2 -1
- package/src/internal/shared/context.js +52 -0
- package/src/internal/shared/errors.js +2 -2
- package/src/version.js +1 -1
- package/types/index.d.ts +23 -9
- package/types/index.d.ts.map +1 -1
|
@@ -6,6 +6,7 @@ import { create_user_effect } from './reactivity/effects.js';
|
|
|
6
6
|
import { async_mode_flag, legacy_mode_flag } from '../flags/index.js';
|
|
7
7
|
import { FILENAME } from '../../constants.js';
|
|
8
8
|
import { BRANCH_EFFECT } from './constants.js';
|
|
9
|
+
import { create_context, get_or_init_context_map } from '../shared/context.js';
|
|
9
10
|
|
|
10
11
|
/** @type {ComponentContext | null} */
|
|
11
12
|
export let component_context = null;
|
|
@@ -72,29 +73,23 @@ export function set_dev_current_component_function(fn) {
|
|
|
72
73
|
/**
|
|
73
74
|
* Returns a `[get, set]` pair of functions for working with context in a type-safe way.
|
|
74
75
|
*
|
|
75
|
-
* `get` will throw an error if
|
|
76
|
+
* `get` will throw an error if `set` has not yet been called in the current component or any of
|
|
77
|
+
* its ancestors.
|
|
76
78
|
*
|
|
77
79
|
* @template T
|
|
78
80
|
* @returns {[() => T, (context: T) => T]}
|
|
79
81
|
* @since 5.40.0
|
|
80
82
|
*/
|
|
81
83
|
export function createContext() {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
() => {
|
|
86
|
-
if (!hasContext(key)) {
|
|
87
|
-
e.missing_context();
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
return getContext(key);
|
|
91
|
-
},
|
|
92
|
-
(context) => setContext(key, context)
|
|
93
|
-
];
|
|
84
|
+
return /** @type {[() => T, (context: T) => T]} */ (
|
|
85
|
+
create_context(getContext, setContext, hasContext)
|
|
86
|
+
);
|
|
94
87
|
}
|
|
95
88
|
|
|
96
89
|
/**
|
|
97
|
-
* Retrieves the context
|
|
90
|
+
* Retrieves the context set with the specified `key` in the current component or any of its
|
|
91
|
+
* ancestors. If multiple components set the same key, the value from the closest one is returned.
|
|
92
|
+
* A `setContext` call in the current component is only visible to `getContext` calls that run after it.
|
|
98
93
|
* Must be called during component initialisation.
|
|
99
94
|
*
|
|
100
95
|
* [`createContext`](https://svelte.dev/docs/svelte/svelte#createContext) is a type-safe alternative.
|
|
@@ -104,15 +99,15 @@ export function createContext() {
|
|
|
104
99
|
* @returns {T}
|
|
105
100
|
*/
|
|
106
101
|
export function getContext(key) {
|
|
107
|
-
const context_map = get_or_init_context_map('getContext');
|
|
102
|
+
const context_map = get_or_init_context_map(component_context, 'getContext');
|
|
108
103
|
const result = /** @type {T} */ (context_map.get(key));
|
|
109
104
|
return result;
|
|
110
105
|
}
|
|
111
106
|
|
|
112
107
|
/**
|
|
113
108
|
* Associates an arbitrary `context` object with the current component and the specified `key`
|
|
114
|
-
* and returns that object. The context is then available to
|
|
115
|
-
* (including slotted content) with `getContext`.
|
|
109
|
+
* and returns that object. The context is then available to the component itself and all of its
|
|
110
|
+
* descendants (including slotted content) with `getContext`.
|
|
116
111
|
*
|
|
117
112
|
* Like lifecycle functions, this must be called during component initialisation.
|
|
118
113
|
*
|
|
@@ -124,7 +119,7 @@ export function getContext(key) {
|
|
|
124
119
|
* @returns {T}
|
|
125
120
|
*/
|
|
126
121
|
export function setContext(key, context) {
|
|
127
|
-
const context_map = get_or_init_context_map('setContext');
|
|
122
|
+
const context_map = get_or_init_context_map(component_context, 'setContext');
|
|
128
123
|
|
|
129
124
|
if (async_mode_flag) {
|
|
130
125
|
var flags = /** @type {Effect} */ (active_effect).f;
|
|
@@ -144,27 +139,27 @@ export function setContext(key, context) {
|
|
|
144
139
|
}
|
|
145
140
|
|
|
146
141
|
/**
|
|
147
|
-
* Checks whether a given `key` has been set in the context of
|
|
148
|
-
* Must be called during component initialisation.
|
|
142
|
+
* Checks whether a given `key` has been set in the context of the current component or any of
|
|
143
|
+
* its ancestors. Must be called during component initialisation.
|
|
149
144
|
*
|
|
150
145
|
* @param {any} key
|
|
151
146
|
* @returns {boolean}
|
|
152
147
|
*/
|
|
153
148
|
export function hasContext(key) {
|
|
154
|
-
const context_map = get_or_init_context_map('hasContext');
|
|
149
|
+
const context_map = get_or_init_context_map(component_context, 'hasContext');
|
|
155
150
|
return context_map.has(key);
|
|
156
151
|
}
|
|
157
152
|
|
|
158
153
|
/**
|
|
159
|
-
* Retrieves the whole context map that belongs to the
|
|
160
|
-
* Must be called during component initialisation. Useful, for
|
|
161
|
-
* programmatically create a component and want to pass the existing context to it.
|
|
154
|
+
* Retrieves the whole context map that belongs to the current component, including entries
|
|
155
|
+
* inherited from its ancestors. Must be called during component initialisation. Useful, for
|
|
156
|
+
* example, if you programmatically create a component and want to pass the existing context to it.
|
|
162
157
|
*
|
|
163
158
|
* @template {Map<any, any>} [T=Map<any, any>]
|
|
164
159
|
* @returns {T}
|
|
165
160
|
*/
|
|
166
161
|
export function getAllContexts() {
|
|
167
|
-
const context_map = get_or_init_context_map('getAllContexts');
|
|
162
|
+
const context_map = get_or_init_context_map(component_context, 'getAllContexts');
|
|
168
163
|
return /** @type {T} */ (context_map);
|
|
169
164
|
}
|
|
170
165
|
|
|
@@ -229,31 +224,3 @@ export function pop(component) {
|
|
|
229
224
|
export function is_runes() {
|
|
230
225
|
return !legacy_mode_flag || (component_context !== null && component_context.l === null);
|
|
231
226
|
}
|
|
232
|
-
|
|
233
|
-
/**
|
|
234
|
-
* @param {string} name
|
|
235
|
-
* @returns {Map<unknown, unknown>}
|
|
236
|
-
*/
|
|
237
|
-
function get_or_init_context_map(name) {
|
|
238
|
-
if (component_context === null) {
|
|
239
|
-
e.lifecycle_outside_component(name);
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
return (component_context.c ??= new Map(get_parent_context(component_context) || undefined));
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
/**
|
|
246
|
-
* @param {ComponentContext} component_context
|
|
247
|
-
* @returns {Map<unknown, unknown> | null}
|
|
248
|
-
*/
|
|
249
|
-
function get_parent_context(component_context) {
|
|
250
|
-
let parent = component_context.p;
|
|
251
|
-
while (parent !== null) {
|
|
252
|
-
const context_map = parent.c;
|
|
253
|
-
if (context_map !== null) {
|
|
254
|
-
return context_map;
|
|
255
|
-
}
|
|
256
|
-
parent = parent.p;
|
|
257
|
-
}
|
|
258
|
-
return null;
|
|
259
|
-
}
|
|
@@ -18,10 +18,10 @@ export function css_props(element, get_styles) {
|
|
|
18
18
|
for (var key in styles) {
|
|
19
19
|
var value = styles[key];
|
|
20
20
|
|
|
21
|
-
if (value) {
|
|
22
|
-
element.style.setProperty(key, value);
|
|
23
|
-
} else {
|
|
21
|
+
if (value == null || value === '') {
|
|
24
22
|
element.style.removeProperty(key);
|
|
23
|
+
} else {
|
|
24
|
+
element.style.setProperty(key, value);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
});
|
|
@@ -103,8 +103,12 @@ function pause_effects(state, to_destroy, controlled_anchor) {
|
|
|
103
103
|
if (remaining === 0) {
|
|
104
104
|
// If we're in a controlled each block (i.e. the block is the only child of an
|
|
105
105
|
// element), and we are removing all items, _and_ there are no out transitions,
|
|
106
|
-
// we can use the fast path — emptying the element and replacing the anchor
|
|
107
|
-
|
|
106
|
+
// we can use the fast path — emptying the element and replacing the anchor.
|
|
107
|
+
// Skip the fast path when another batch is still pending on this each block:
|
|
108
|
+
// that batch's keys still reference EachItems in `state.items`, which
|
|
109
|
+
// `destroy_effects` needs to preserve offscreen (see #18610).
|
|
110
|
+
var fast_path =
|
|
111
|
+
transitions.length === 0 && controlled_anchor !== null && state.pending.size === 0;
|
|
108
112
|
|
|
109
113
|
if (fast_path) {
|
|
110
114
|
var anchor = /** @type {Element} */ (controlled_anchor);
|
|
@@ -2,14 +2,19 @@ import { DEV } from 'esm-env';
|
|
|
2
2
|
import { register_style } from '../dev/css.js';
|
|
3
3
|
import { effect } from '../reactivity/effects.js';
|
|
4
4
|
import { create_element } from './operations.js';
|
|
5
|
+
import { active_effect } from '../runtime.js';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* @param {Node} anchor
|
|
8
9
|
* @param {{ hash: string, code: string }} css
|
|
9
10
|
*/
|
|
10
11
|
export function append_styles(anchor, css) {
|
|
11
|
-
// Use
|
|
12
|
+
// Use an effect to ensure `anchor` is in the DOM, otherwise getRootNode() will yield wrong results
|
|
12
13
|
effect(() => {
|
|
14
|
+
// Bit of a hack: branches.js/each.js use offscreen fragments with temporary text nodes that will
|
|
15
|
+
// never be connected to the real dom. Therfore walk up to the branch that has created the component
|
|
16
|
+
// whose styles we want to append, and check its node instead. It will be connected by the time we get here.
|
|
17
|
+
anchor = active_effect?.parent?.nodes?.start ?? anchor;
|
|
13
18
|
var root = anchor.getRootNode();
|
|
14
19
|
|
|
15
20
|
var target = /** @type {ShadowRoot} */ (root).host
|
|
@@ -315,7 +315,8 @@ function set_attributes(
|
|
|
315
315
|
var is_option_element = element.nodeName === OPTION_TAG;
|
|
316
316
|
|
|
317
317
|
for (var key in prev) {
|
|
318
|
-
|
|
318
|
+
// don't null our internal $$onX listeners
|
|
319
|
+
if (!(key in next) && key[0] + key[1] !== '$$') {
|
|
319
320
|
next[key] = null;
|
|
320
321
|
}
|
|
321
322
|
}
|
|
@@ -159,12 +159,15 @@ export function delegate(events) {
|
|
|
159
159
|
}
|
|
160
160
|
|
|
161
161
|
// used to store the reference to the currently propagated event
|
|
162
|
-
// to prevent garbage collection between microtasks in Firefox
|
|
162
|
+
// to prevent garbage collection between microtasks in Firefox (<= 141)
|
|
163
163
|
// If the event object is GCed too early, the expando __root property
|
|
164
164
|
// set on the event object is lost, causing the event delegation
|
|
165
165
|
// to process the event twice
|
|
166
166
|
let last_propagated_event = null;
|
|
167
167
|
|
|
168
|
+
// whether a task is already queued to clear `last_propagated_event`
|
|
169
|
+
let last_propagated_event_clear_scheduled = false;
|
|
170
|
+
|
|
168
171
|
/**
|
|
169
172
|
* @this {EventTarget}
|
|
170
173
|
* @param {Event} event
|
|
@@ -179,6 +182,21 @@ export function handle_event_propagation(event) {
|
|
|
179
182
|
|
|
180
183
|
last_propagated_event = event;
|
|
181
184
|
|
|
185
|
+
// The reference is only needed while the event can still reach another
|
|
186
|
+
// delegated root, i.e. during the current (synchronous) dispatch and its
|
|
187
|
+
// microtask checkpoints. Clearing it in a later task preserves the
|
|
188
|
+
// Firefox workaround while making sure the slot doesn't retain the last
|
|
189
|
+
// event forever — through `event.target` it would otherwise keep the
|
|
190
|
+
// entire detached subtree of whatever the user last clicked in alive
|
|
191
|
+
// until the next delegated event happens to arrive.
|
|
192
|
+
if (!last_propagated_event_clear_scheduled) {
|
|
193
|
+
last_propagated_event_clear_scheduled = true;
|
|
194
|
+
setTimeout(() => {
|
|
195
|
+
last_propagated_event_clear_scheduled = false;
|
|
196
|
+
last_propagated_event = null;
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
|
|
182
200
|
// composedPath contains list of nodes the event has propagated through.
|
|
183
201
|
// We check `event_symbol` to skip all nodes below it in case this is a
|
|
184
202
|
// parent of the `event_symbol` node, which indicates that there's nested
|
|
@@ -180,7 +180,13 @@ export function set(source, value, should_proxy = false) {
|
|
|
180
180
|
*/
|
|
181
181
|
export function internal_set(source, value, updated_during_traversal = null) {
|
|
182
182
|
if (!source.equals(value)) {
|
|
183
|
-
|
|
183
|
+
if (is_destroying_effect) {
|
|
184
|
+
old_values.set(source, value);
|
|
185
|
+
} else if (!old_values.has(source)) {
|
|
186
|
+
// only record the value from before the first write in this flush, otherwise a
|
|
187
|
+
// teardown would see the value from before whichever write happened to be last
|
|
188
|
+
old_values.set(source, source.v);
|
|
189
|
+
}
|
|
184
190
|
|
|
185
191
|
var batch = Batch.ensure();
|
|
186
192
|
batch.capture(source, value);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** @import { SSRContext } from '#server' */
|
|
2
2
|
import { DEV } from 'esm-env';
|
|
3
|
-
import
|
|
3
|
+
import { create_context, get_or_init_context_map } from '../shared/context.js';
|
|
4
4
|
|
|
5
5
|
/** @type {SSRContext | null} */
|
|
6
6
|
export var ssr_context = null;
|
|
@@ -16,18 +16,9 @@ export function set_ssr_context(v) {
|
|
|
16
16
|
* @since 5.40.0
|
|
17
17
|
*/
|
|
18
18
|
export function createContext() {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
() => {
|
|
23
|
-
if (!hasContext(key)) {
|
|
24
|
-
e.missing_context();
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return getContext(key);
|
|
28
|
-
},
|
|
29
|
-
(context) => setContext(key, context)
|
|
30
|
-
];
|
|
19
|
+
return /** @type {[() => T, (context: T) => T]} */ (
|
|
20
|
+
create_context(getContext, setContext, hasContext)
|
|
21
|
+
);
|
|
31
22
|
}
|
|
32
23
|
|
|
33
24
|
/**
|
|
@@ -36,7 +27,7 @@ export function createContext() {
|
|
|
36
27
|
* @returns {T}
|
|
37
28
|
*/
|
|
38
29
|
export function getContext(key) {
|
|
39
|
-
const context_map = get_or_init_context_map('getContext');
|
|
30
|
+
const context_map = get_or_init_context_map(ssr_context, 'getContext');
|
|
40
31
|
const result = /** @type {T} */ (context_map.get(key));
|
|
41
32
|
|
|
42
33
|
return result;
|
|
@@ -49,7 +40,7 @@ export function getContext(key) {
|
|
|
49
40
|
* @returns {T}
|
|
50
41
|
*/
|
|
51
42
|
export function setContext(key, context) {
|
|
52
|
-
get_or_init_context_map('setContext').set(key, context);
|
|
43
|
+
get_or_init_context_map(ssr_context, 'setContext').set(key, context);
|
|
53
44
|
return context;
|
|
54
45
|
}
|
|
55
46
|
|
|
@@ -58,24 +49,12 @@ export function setContext(key, context) {
|
|
|
58
49
|
* @returns {boolean}
|
|
59
50
|
*/
|
|
60
51
|
export function hasContext(key) {
|
|
61
|
-
return get_or_init_context_map('hasContext').has(key);
|
|
52
|
+
return get_or_init_context_map(ssr_context, 'hasContext').has(key);
|
|
62
53
|
}
|
|
63
54
|
|
|
64
55
|
/** @returns {Map<any, any>} */
|
|
65
56
|
export function getAllContexts() {
|
|
66
|
-
return get_or_init_context_map('getAllContexts');
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* @param {string} name
|
|
71
|
-
* @returns {Map<unknown, unknown>}
|
|
72
|
-
*/
|
|
73
|
-
function get_or_init_context_map(name) {
|
|
74
|
-
if (ssr_context === null) {
|
|
75
|
-
e.lifecycle_outside_component(name);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return (ssr_context.c ??= new Map(get_parent_context(ssr_context) || undefined));
|
|
57
|
+
return get_or_init_context_map(ssr_context, 'getAllContexts');
|
|
79
58
|
}
|
|
80
59
|
|
|
81
60
|
/**
|
|
@@ -94,24 +73,6 @@ export function pop() {
|
|
|
94
73
|
ssr_context = /** @type {SSRContext} */ (ssr_context).p;
|
|
95
74
|
}
|
|
96
75
|
|
|
97
|
-
/**
|
|
98
|
-
* @param {SSRContext} ssr_context
|
|
99
|
-
* @returns {Map<unknown, unknown> | null}
|
|
100
|
-
*/
|
|
101
|
-
function get_parent_context(ssr_context) {
|
|
102
|
-
let parent = ssr_context.p;
|
|
103
|
-
|
|
104
|
-
while (parent !== null) {
|
|
105
|
-
const context_map = parent.c;
|
|
106
|
-
if (context_map !== null) {
|
|
107
|
-
return context_map;
|
|
108
|
-
}
|
|
109
|
-
parent = parent.p;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
return null;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
76
|
/**
|
|
116
77
|
* Wraps an `await` expression in such a way that the component context that was
|
|
117
78
|
* active before the expression evaluated can be reapplied afterwards —
|
|
@@ -451,6 +451,7 @@ export class Renderer {
|
|
|
451
451
|
*/
|
|
452
452
|
copy() {
|
|
453
453
|
const copy = new Renderer(this.global, this.#parent);
|
|
454
|
+
copy.type = this.type;
|
|
454
455
|
copy.#out = this.#out.map((item) => (item instanceof Renderer ? item.copy() : item));
|
|
455
456
|
copy.promise = this.promise;
|
|
456
457
|
return copy;
|
|
@@ -142,8 +142,9 @@ export function to_style(value, styles) {
|
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
if (value) {
|
|
145
|
+
// strip comments; surrounding whitespace is handled by the trims below (which is much faster than doing it through regex)
|
|
145
146
|
value = String(value)
|
|
146
|
-
.replaceAll(
|
|
147
|
+
.replaceAll(/\/\*.*?\*\//g, '')
|
|
147
148
|
.trim();
|
|
148
149
|
|
|
149
150
|
/** @type {boolean | '"' | "'"} */
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { lifecycle_outside_component, missing_context } from './errors.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @template T
|
|
5
|
+
* @param {(key: object) => T} get_context
|
|
6
|
+
* @param {(key: object, context: T) => T} set_context
|
|
7
|
+
* @param {(key: object) => boolean} has_context
|
|
8
|
+
* @returns {[() => T, (context: T) => T]}
|
|
9
|
+
*/
|
|
10
|
+
export function create_context(get_context, set_context, has_context) {
|
|
11
|
+
const key = {};
|
|
12
|
+
|
|
13
|
+
return [
|
|
14
|
+
() => {
|
|
15
|
+
if (!has_context(key)) {
|
|
16
|
+
missing_context();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return get_context(key);
|
|
20
|
+
},
|
|
21
|
+
(context) => set_context(key, context)
|
|
22
|
+
];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @typedef {{ p: Context | null, c: Map<unknown, unknown> | null }} Context
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @param {Context} context
|
|
31
|
+
* @returns {Map<unknown, unknown> | null}
|
|
32
|
+
*/
|
|
33
|
+
function get_parent_context(context) {
|
|
34
|
+
let parent = context.p;
|
|
35
|
+
while (parent !== null && parent.c === null) {
|
|
36
|
+
parent = parent.p;
|
|
37
|
+
}
|
|
38
|
+
return parent?.c ?? null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @param {Context | null} context
|
|
43
|
+
* @param {string} name
|
|
44
|
+
* @returns {Map<unknown, unknown>}
|
|
45
|
+
*/
|
|
46
|
+
export function get_or_init_context_map(context, name) {
|
|
47
|
+
if (context === null) {
|
|
48
|
+
lifecycle_outside_component(name);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return (context.c ??= new Map(get_parent_context(context) || undefined));
|
|
52
|
+
}
|
|
@@ -86,12 +86,12 @@ export function lifecycle_outside_component(name) {
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
/**
|
|
89
|
-
* Context was not set in
|
|
89
|
+
* Context was not set in the current component or any of its ancestors
|
|
90
90
|
* @returns {never}
|
|
91
91
|
*/
|
|
92
92
|
export function missing_context() {
|
|
93
93
|
if (DEV) {
|
|
94
|
-
const error = new Error(`missing_context\nContext was not set in
|
|
94
|
+
const error = new Error(`missing_context\nContext was not set in the current component or any of its ancestors\nhttps://svelte.dev/e/missing_context`);
|
|
95
95
|
|
|
96
96
|
error.name = 'Svelte error';
|
|
97
97
|
|
package/src/version.js
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -494,13 +494,16 @@ declare module 'svelte' {
|
|
|
494
494
|
/**
|
|
495
495
|
* Returns a `[get, set]` pair of functions for working with context in a type-safe way.
|
|
496
496
|
*
|
|
497
|
-
* `get` will throw an error if
|
|
497
|
+
* `get` will throw an error if `set` has not yet been called in the current component or any of
|
|
498
|
+
* its ancestors.
|
|
498
499
|
*
|
|
499
500
|
* @since 5.40.0
|
|
500
501
|
*/
|
|
501
502
|
export function createContext<T>(): [() => T, (context: T) => T];
|
|
502
503
|
/**
|
|
503
|
-
* Retrieves the context
|
|
504
|
+
* Retrieves the context set with the specified `key` in the current component or any of its
|
|
505
|
+
* ancestors. If multiple components set the same key, the value from the closest one is returned.
|
|
506
|
+
* A `setContext` call in the current component is only visible to `getContext` calls that run after it.
|
|
504
507
|
* Must be called during component initialisation.
|
|
505
508
|
*
|
|
506
509
|
* [`createContext`](https://svelte.dev/docs/svelte/svelte#createContext) is a type-safe alternative.
|
|
@@ -509,8 +512,8 @@ declare module 'svelte' {
|
|
|
509
512
|
export function getContext<T>(key: any): T;
|
|
510
513
|
/**
|
|
511
514
|
* Associates an arbitrary `context` object with the current component and the specified `key`
|
|
512
|
-
* and returns that object. The context is then available to
|
|
513
|
-
* (including slotted content) with `getContext`.
|
|
515
|
+
* and returns that object. The context is then available to the component itself and all of its
|
|
516
|
+
* descendants (including slotted content) with `getContext`.
|
|
514
517
|
*
|
|
515
518
|
* Like lifecycle functions, this must be called during component initialisation.
|
|
516
519
|
*
|
|
@@ -519,15 +522,15 @@ declare module 'svelte' {
|
|
|
519
522
|
* */
|
|
520
523
|
export function setContext<T>(key: any, context: T): T;
|
|
521
524
|
/**
|
|
522
|
-
* Checks whether a given `key` has been set in the context of
|
|
523
|
-
* Must be called during component initialisation.
|
|
525
|
+
* Checks whether a given `key` has been set in the context of the current component or any of
|
|
526
|
+
* its ancestors. Must be called during component initialisation.
|
|
524
527
|
*
|
|
525
528
|
* */
|
|
526
529
|
export function hasContext(key: any): boolean;
|
|
527
530
|
/**
|
|
528
|
-
* Retrieves the whole context map that belongs to the
|
|
529
|
-
* Must be called during component initialisation. Useful, for
|
|
530
|
-
* programmatically create a component and want to pass the existing context to it.
|
|
531
|
+
* Retrieves the whole context map that belongs to the current component, including entries
|
|
532
|
+
* inherited from its ancestors. Must be called during component initialisation. Useful, for
|
|
533
|
+
* example, if you programmatically create a component and want to pass the existing context to it.
|
|
531
534
|
*
|
|
532
535
|
* */
|
|
533
536
|
export function getAllContexts<T extends Map<any, any> = Map<any, any>>(): T;
|
|
@@ -1694,6 +1697,15 @@ declare module 'svelte/compiler' {
|
|
|
1694
1697
|
|
|
1695
1698
|
export interface StyleSheetBase extends BaseNode {
|
|
1696
1699
|
children: Array<Atrule | Rule>;
|
|
1700
|
+
/** CSS comments in source order */
|
|
1701
|
+
comments: CSSComment[];
|
|
1702
|
+
}
|
|
1703
|
+
|
|
1704
|
+
export interface CSSComment extends BaseNode {
|
|
1705
|
+
type: 'CSSComment';
|
|
1706
|
+
value: string;
|
|
1707
|
+
/** Character offset in a containing declaration value or at-rule prelude */
|
|
1708
|
+
position?: number;
|
|
1697
1709
|
}
|
|
1698
1710
|
|
|
1699
1711
|
export interface StyleSheetFile extends StyleSheetBase {
|
|
@@ -1765,6 +1777,7 @@ declare module 'svelte/compiler' {
|
|
|
1765
1777
|
export interface TypeSelector extends BaseNode {
|
|
1766
1778
|
type: 'TypeSelector';
|
|
1767
1779
|
name: string;
|
|
1780
|
+
namespace?: string;
|
|
1768
1781
|
}
|
|
1769
1782
|
|
|
1770
1783
|
export interface IdSelector extends BaseNode {
|
|
@@ -1788,6 +1801,7 @@ declare module 'svelte/compiler' {
|
|
|
1788
1801
|
export interface PseudoElementSelector extends BaseNode {
|
|
1789
1802
|
type: 'PseudoElementSelector';
|
|
1790
1803
|
name: string;
|
|
1804
|
+
args?: SelectorList;
|
|
1791
1805
|
}
|
|
1792
1806
|
|
|
1793
1807
|
export interface PseudoClassSelector extends BaseNode {
|
package/types/index.d.ts.map
CHANGED
|
@@ -273,6 +273,6 @@
|
|
|
273
273
|
null,
|
|
274
274
|
null
|
|
275
275
|
],
|
|
276
|
-
"mappings": ";;;;;;;;;kBAUiBA,2BAA2BA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAmC/BC,eAAeA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAwEhBC,kBAAkBA;;;;;;;;;;;;;;;;;;;;;;;;kBAwBbC,SAASA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAoCbC,oBAAoBA;;;;;;;;;;;;;;;;;;;;;;;;aAwBrBC,eAAeA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAiCfC,cAAcA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aA6BdC,aAAaA;;;;;;;;;;;;;;;;;;;;;;;kBAuBRC,OAAOA;;;;;;;;;;;;;;;;kBAgBPC,eAAeA;;;;;;;;;;;;;;;;aAgBpBC,YAAYA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBA+CPC,IAAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBCzSLC,cAAcA;;;;;;;;;;;;iBAsBdC,OAAOA;;;;;;;;iBAwBPC,SAASA;;;;;;;;;;;;;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