svelte 5.58.1 → 5.59.0
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 +19 -1
- package/renderer.d.ts +1 -0
- package/src/compiler/errors.js +19 -0
- package/src/compiler/index.js +37 -2
- package/src/compiler/migrate/index.js +2 -1
- package/src/compiler/phases/1-parse/read/options.js +20 -0
- package/src/compiler/phases/2-analyze/index.js +21 -2
- package/src/compiler/phases/2-analyze/visitors/AnimateDirective.js +5 -0
- package/src/compiler/phases/2-analyze/visitors/Attribute.js +6 -2
- package/src/compiler/phases/2-analyze/visitors/BindDirective.js +4 -0
- package/src/compiler/phases/2-analyze/visitors/ExpressionTag.js +2 -1
- package/src/compiler/phases/2-analyze/visitors/HtmlTag.js +5 -0
- package/src/compiler/phases/2-analyze/visitors/OnDirective.js +6 -0
- package/src/compiler/phases/2-analyze/visitors/RegularElement.js +13 -6
- package/src/compiler/phases/2-analyze/visitors/SvelteBody.js +5 -0
- package/src/compiler/phases/2-analyze/visitors/SvelteDocument.js +5 -0
- package/src/compiler/phases/2-analyze/visitors/SvelteElement.js +5 -1
- package/src/compiler/phases/2-analyze/visitors/SvelteHead.js +5 -0
- package/src/compiler/phases/2-analyze/visitors/SvelteWindow.js +5 -0
- package/src/compiler/phases/2-analyze/visitors/Text.js +3 -1
- package/src/compiler/phases/2-analyze/visitors/TransitionDirective.js +6 -0
- package/src/compiler/phases/2-analyze/visitors/shared/element.js +3 -2
- package/src/compiler/phases/3-transform/client/transform-client.js +68 -1
- package/src/compiler/phases/3-transform/client/transform-template/index.js +4 -3
- package/src/compiler/phases/3-transform/client/transform-template/template.js +1 -1
- package/src/compiler/phases/3-transform/client/visitors/RegularElement.js +23 -13
- package/src/compiler/phases/3-transform/client/visitors/RenderTag.js +13 -1
- package/src/compiler/phases/3-transform/client/visitors/SnippetBlock.js +11 -1
- package/src/compiler/phases/3-transform/client/visitors/SvelteBoundary.js +8 -5
- package/src/compiler/phases/3-transform/client/visitors/shared/component.js +17 -8
- package/src/compiler/phases/3-transform/client/visitors/shared/element.js +4 -3
- package/src/compiler/phases/3-transform/client/visitors/shared/fragment.js +7 -1
- package/src/compiler/phases/3-transform/server/transform-server.js +14 -1
- package/src/compiler/phases/3-transform/server/visitors/RegularElement.js +8 -4
- package/src/compiler/state.js +12 -0
- package/src/compiler/utils/builders.js +2 -2
- package/src/compiler/validate-options.js +47 -1
- package/src/internal/client/constants.js +7 -0
- package/src/internal/client/custom-renderer/containers.js +213 -0
- package/src/internal/client/custom-renderer/cross.js +145 -0
- package/src/internal/client/custom-renderer/index.js +28 -0
- package/src/internal/client/custom-renderer/state.js +59 -0
- package/src/internal/client/dev/css.js +3 -1
- package/src/internal/client/dev/elements.js +9 -7
- package/src/internal/client/dev/validation.js +2 -1
- package/src/internal/client/dom/blocks/await.js +3 -2
- package/src/internal/client/dom/blocks/boundary.js +41 -24
- package/src/internal/client/dom/blocks/branches.js +83 -57
- package/src/internal/client/dom/blocks/css-props.js +31 -3
- package/src/internal/client/dom/blocks/each.js +78 -32
- package/src/internal/client/dom/blocks/html.js +19 -13
- package/src/internal/client/dom/blocks/slot.js +3 -3
- package/src/internal/client/dom/blocks/snippet.js +52 -3
- package/src/internal/client/dom/blocks/svelte-element.js +17 -6
- package/src/internal/client/dom/blocks/svelte-head.js +13 -4
- package/src/internal/client/dom/css.js +4 -4
- package/src/internal/client/dom/elements/attributes.js +89 -50
- package/src/internal/client/dom/elements/bindings/select.js +11 -2
- package/src/internal/client/dom/elements/class.js +16 -5
- package/src/internal/client/dom/elements/events.js +126 -19
- package/src/internal/client/dom/elements/misc.js +3 -2
- package/src/internal/client/dom/elements/style.js +17 -6
- package/src/internal/client/dom/hydration.js +6 -6
- package/src/internal/client/dom/operations.js +433 -11
- package/src/internal/client/dom/reconciler.js +2 -2
- package/src/internal/client/dom/template.js +94 -66
- package/src/internal/client/errors.js +67 -0
- package/src/internal/client/index.js +9 -1
- package/src/internal/client/reactivity/async.js +10 -0
- package/src/internal/client/reactivity/batch.js +22 -1
- package/src/internal/client/reactivity/effects.js +44 -27
- package/src/internal/client/render.js +50 -88
- package/src/internal/client/runtime.js +6 -1
- package/src/internal/disclose-version.js +1 -1
- package/src/internal/flags/custom-renderer-server.js +10 -0
- package/src/internal/flags/custom-renderer.js +3 -0
- package/src/internal/flags/index.js +6 -0
- package/src/internal/init-operations.js +3 -0
- package/src/internal/shared/errors.js +20 -0
- package/src/legacy/legacy-client.js +6 -2
- package/src/renderer/index-server.js +18 -0
- package/src/renderer/index.js +2 -0
- package/src/version.js +1 -1
- package/types/index.d.ts +244 -24
- package/types/index.d.ts.map +10 -1
|
@@ -1,32 +1,33 @@
|
|
|
1
1
|
/** @import { ComponentContext, Effect, EffectNodes, TemplateNode } from '#client' */
|
|
2
2
|
/** @import { Component, ComponentType, SvelteComponent, MountOptions } from '../../index.js' */
|
|
3
|
+
/** @import { Renderer } from './custom-renderer/types.js' */
|
|
3
4
|
import { DEV } from 'esm-env';
|
|
4
5
|
import {
|
|
5
6
|
clear_text_content,
|
|
6
7
|
create_text,
|
|
7
8
|
get_first_child,
|
|
8
9
|
get_next_sibling,
|
|
9
|
-
|
|
10
|
+
append_child,
|
|
11
|
+
get_parent_node,
|
|
12
|
+
remove_child,
|
|
13
|
+
set_node_value,
|
|
14
|
+
get_node_value,
|
|
15
|
+
node_type
|
|
10
16
|
} from './dom/operations.js';
|
|
11
17
|
import { HYDRATION_END, HYDRATION_ERROR, HYDRATION_START } from '../../constants.js';
|
|
12
18
|
import { active_effect } from './runtime.js';
|
|
13
19
|
import { push, pop, component_context, mark_as_component } from './context.js';
|
|
14
20
|
import { component_root } from './reactivity/effects.js';
|
|
15
21
|
import { hydrate_node, hydrating, set_hydrate_node, set_hydrating } from './dom/hydration.js';
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
all_registered_events,
|
|
19
|
-
handle_event_propagation,
|
|
20
|
-
root_event_handles
|
|
21
|
-
} from './dom/elements/events.js';
|
|
22
|
+
import { listen_to_delegated_events } from './dom/elements/events.js';
|
|
22
23
|
import * as w from './warnings.js';
|
|
23
24
|
import * as e from './errors.js';
|
|
24
25
|
import { assign_nodes } from './dom/template.js';
|
|
25
|
-
import { is_passive_event } from '../../utils.js';
|
|
26
26
|
import { COMMENT_NODE, TEXT_CACHE } from './constants.js';
|
|
27
27
|
import { boundary } from './dom/blocks/boundary.js';
|
|
28
|
+
import { push_renderer, pop_renderer } from './custom-renderer/state.js';
|
|
29
|
+
import { async_mode_flag, custom_renderers_flag } from '../flags/index.js';
|
|
28
30
|
import { current_batch } from './reactivity/batch.js';
|
|
29
|
-
import { async_mode_flag } from '../flags/index.js';
|
|
30
31
|
|
|
31
32
|
/**
|
|
32
33
|
* This is normally true — block effects should run their intro transitions —
|
|
@@ -49,9 +50,9 @@ export function set_text(text, value) {
|
|
|
49
50
|
// For objects, we apply string coercion (which might make things like $state array references in the template reactive) before diffing
|
|
50
51
|
var str = value == null ? '' : typeof value === 'object' ? `${value}` : value;
|
|
51
52
|
// prettier-ignore
|
|
52
|
-
if (str !== (/** @type {any} */ (text)[TEXT_CACHE] ??= text
|
|
53
|
+
if (str !== (/** @type {any} */ (text)[TEXT_CACHE] ??= get_node_value(text))) {
|
|
53
54
|
/** @type {any} */ (text)[TEXT_CACHE] = str;
|
|
54
|
-
text
|
|
55
|
+
set_node_value(text, `${str}`);
|
|
55
56
|
}
|
|
56
57
|
}
|
|
57
58
|
|
|
@@ -61,8 +62,9 @@ export function set_text(text, value) {
|
|
|
61
62
|
*
|
|
62
63
|
* @template {Record<string, any>} Props
|
|
63
64
|
* @template {Record<string, any>} Exports
|
|
65
|
+
* @template [Renderer=undefined]
|
|
64
66
|
* @param {ComponentType<SvelteComponent<Props>> | Component<Props, Exports, any>} component
|
|
65
|
-
* @param {MountOptions<Props>} options
|
|
67
|
+
* @param {MountOptions<Props, Renderer>} options
|
|
66
68
|
* @returns {Exports}
|
|
67
69
|
*/
|
|
68
70
|
export function mount(component, options) {
|
|
@@ -95,7 +97,6 @@ export function mount(component, options) {
|
|
|
95
97
|
* @returns {Exports}
|
|
96
98
|
*/
|
|
97
99
|
export function hydrate(component, options) {
|
|
98
|
-
init_operations();
|
|
99
100
|
options.intro = options.intro ?? false;
|
|
100
101
|
const target = options.target;
|
|
101
102
|
const was_hydrating = hydrating;
|
|
@@ -106,7 +107,7 @@ export function hydrate(component, options) {
|
|
|
106
107
|
|
|
107
108
|
while (
|
|
108
109
|
anchor &&
|
|
109
|
-
(anchor
|
|
110
|
+
(node_type(anchor) !== COMMENT_NODE || get_node_value(anchor) !== HYDRATION_START)
|
|
110
111
|
) {
|
|
111
112
|
anchor = get_next_sibling(anchor);
|
|
112
113
|
}
|
|
@@ -149,8 +150,6 @@ export function hydrate(component, options) {
|
|
|
149
150
|
e.hydration_failed();
|
|
150
151
|
}
|
|
151
152
|
|
|
152
|
-
// If an error occurred above, the operations might not yet have been initialised.
|
|
153
|
-
init_operations();
|
|
154
153
|
clear_text_content(target);
|
|
155
154
|
|
|
156
155
|
set_hydrating(false);
|
|
@@ -161,27 +160,43 @@ export function hydrate(component, options) {
|
|
|
161
160
|
}
|
|
162
161
|
}
|
|
163
162
|
|
|
164
|
-
/**
|
|
165
|
-
|
|
163
|
+
/**
|
|
164
|
+
* @template {Record<string, any>} Exports
|
|
165
|
+
* @param {ComponentType<SvelteComponent<any>> | Component<any>} Component
|
|
166
|
+
* @param {MountOptions<any, any> & { renderer?: Renderer }} options
|
|
167
|
+
* @returns {Exports}
|
|
168
|
+
*/
|
|
169
|
+
function _mount(Component, options) {
|
|
170
|
+
if (custom_renderers_flag && options.renderer) {
|
|
171
|
+
var previous_renderer = push_renderer(options.renderer);
|
|
172
|
+
|
|
173
|
+
try {
|
|
174
|
+
return _mount_inner(Component, options);
|
|
175
|
+
} finally {
|
|
176
|
+
pop_renderer(previous_renderer);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return _mount_inner(Component, options);
|
|
181
|
+
}
|
|
166
182
|
|
|
167
183
|
/**
|
|
168
184
|
* @template {Record<string, any>} Exports
|
|
169
185
|
* @param {ComponentType<SvelteComponent<any>> | Component<any>} Component
|
|
170
|
-
* @param {MountOptions} options
|
|
186
|
+
* @param {MountOptions<any, any> & { renderer?: Renderer }} options
|
|
171
187
|
* @returns {Exports}
|
|
172
188
|
*/
|
|
173
|
-
function
|
|
189
|
+
function _mount_inner(
|
|
174
190
|
Component,
|
|
175
|
-
{ target, anchor, props = {}, events, context, intro = true, transformError }
|
|
191
|
+
{ target, anchor, props = {}, events, context, intro = true, transformError, renderer }
|
|
176
192
|
) {
|
|
177
|
-
init_operations();
|
|
178
|
-
|
|
179
193
|
/** @type {Exports} */
|
|
180
194
|
// @ts-expect-error will be defined because the render effect runs synchronously
|
|
181
195
|
var component = undefined;
|
|
182
196
|
|
|
183
197
|
var unmount = component_root(() => {
|
|
184
|
-
var anchor_node =
|
|
198
|
+
var anchor_node =
|
|
199
|
+
anchor ?? /** @type {Text} */ (append_child(/** @type {Node} */ (target), create_text()));
|
|
185
200
|
|
|
186
201
|
boundary(
|
|
187
202
|
/** @type {TemplateNode} */ (anchor_node),
|
|
@@ -212,8 +227,8 @@ function _mount(
|
|
|
212
227
|
|
|
213
228
|
if (
|
|
214
229
|
hydrate_node === null ||
|
|
215
|
-
hydrate_node
|
|
216
|
-
|
|
230
|
+
node_type(hydrate_node) !== COMMENT_NODE ||
|
|
231
|
+
get_node_value(hydrate_node) !== HYDRATION_END
|
|
217
232
|
) {
|
|
218
233
|
w.hydration_mismatch();
|
|
219
234
|
throw HYDRATION_ERROR;
|
|
@@ -225,72 +240,19 @@ function _mount(
|
|
|
225
240
|
transformError
|
|
226
241
|
);
|
|
227
242
|
|
|
228
|
-
// Setup event delegation _after_ component is mounted - if an error would happen during mount, it would otherwise not be cleaned up
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
for (var i = 0; i < events.length; i++) {
|
|
235
|
-
var event_name = events[i];
|
|
236
|
-
|
|
237
|
-
if (registered_events.has(event_name)) continue;
|
|
238
|
-
registered_events.add(event_name);
|
|
239
|
-
|
|
240
|
-
var passive = is_passive_event(event_name);
|
|
241
|
-
|
|
242
|
-
// Add the event listener to both the container and the document.
|
|
243
|
-
// The container listener ensures we catch events from within in case
|
|
244
|
-
// the outer content stops propagation of the event.
|
|
245
|
-
//
|
|
246
|
-
// The document listener ensures we catch events that originate from elements that were
|
|
247
|
-
// manually moved outside of the container (e.g. via manual portals).
|
|
248
|
-
for (const node of [target, document]) {
|
|
249
|
-
var counts = listeners.get(node);
|
|
250
|
-
|
|
251
|
-
if (counts === undefined) {
|
|
252
|
-
counts = new Map();
|
|
253
|
-
listeners.set(node, counts);
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
var count = counts.get(event_name);
|
|
257
|
-
|
|
258
|
-
if (count === undefined) {
|
|
259
|
-
node.addEventListener(event_name, handle_event_propagation, { passive });
|
|
260
|
-
counts.set(event_name, 1);
|
|
261
|
-
} else {
|
|
262
|
-
counts.set(event_name, count + 1);
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
};
|
|
267
|
-
|
|
268
|
-
event_handle(array_from(all_registered_events));
|
|
269
|
-
root_event_handles.add(event_handle);
|
|
243
|
+
// Setup event delegation _after_ component is mounted - if an error would happen during mount, it would otherwise not be cleaned up.
|
|
244
|
+
// When mounting with a custom renderer the target isn't a DOM node; any DOM content inside it is rendered
|
|
245
|
+
// into DOM containers that become delegation roots themselves (see `cross`)
|
|
246
|
+
var stop_listening = renderer
|
|
247
|
+
? null
|
|
248
|
+
: listen_to_delegated_events(/** @type {EventTarget} */ (target));
|
|
270
249
|
|
|
271
250
|
return () => {
|
|
272
|
-
|
|
273
|
-
for (const node of [target, document]) {
|
|
274
|
-
var counts = /** @type {Map<string, number>} */ (listeners.get(node));
|
|
275
|
-
var count = /** @type {number} */ (counts.get(event_name));
|
|
276
|
-
|
|
277
|
-
if (--count == 0) {
|
|
278
|
-
node.removeEventListener(event_name, handle_event_propagation);
|
|
279
|
-
counts.delete(event_name);
|
|
280
|
-
|
|
281
|
-
if (counts.size === 0) {
|
|
282
|
-
listeners.delete(node);
|
|
283
|
-
}
|
|
284
|
-
} else {
|
|
285
|
-
counts.set(event_name, count);
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
root_event_handles.delete(event_handle);
|
|
251
|
+
stop_listening?.();
|
|
291
252
|
|
|
292
253
|
if (anchor_node !== anchor) {
|
|
293
|
-
|
|
254
|
+
var parent = get_parent_node(/** @type {Node} */ (anchor_node));
|
|
255
|
+
if (parent) remove_child(parent, /** @type {ChildNode} */ (anchor_node));
|
|
294
256
|
}
|
|
295
257
|
};
|
|
296
258
|
});
|
|
@@ -36,7 +36,7 @@ import {
|
|
|
36
36
|
update_derived,
|
|
37
37
|
get_view
|
|
38
38
|
} from './reactivity/deriveds.js';
|
|
39
|
-
import { async_mode_flag, tracing_mode_flag } from '../flags/index.js';
|
|
39
|
+
import { async_mode_flag, tracing_mode_flag, custom_renderers_flag } from '../flags/index.js';
|
|
40
40
|
import { tracing_expressions } from './dev/tracing.js';
|
|
41
41
|
import { get_error } from '../shared/dev.js';
|
|
42
42
|
import {
|
|
@@ -67,6 +67,7 @@ import { set_signal_status, update_derived_status } from './reactivity/status.js
|
|
|
67
67
|
import { merge_target } from './reactivity/async.js';
|
|
68
68
|
import * as e from './errors.js';
|
|
69
69
|
import * as w from './warnings.js';
|
|
70
|
+
import { push_renderer, pop_renderer } from './custom-renderer/state.js';
|
|
70
71
|
|
|
71
72
|
export let is_destroying_effect = false;
|
|
72
73
|
|
|
@@ -1171,6 +1172,8 @@ export function update_effect(effect) {
|
|
|
1171
1172
|
|
|
1172
1173
|
active_effect = effect;
|
|
1173
1174
|
|
|
1175
|
+
var previous_renderer = custom_renderers_flag ? push_renderer(effect.r) : null;
|
|
1176
|
+
|
|
1174
1177
|
if (DEV) {
|
|
1175
1178
|
var previous_component_fn = dev_current_component_function;
|
|
1176
1179
|
set_dev_current_component_function(effect.component_function);
|
|
@@ -1207,6 +1210,8 @@ export function update_effect(effect) {
|
|
|
1207
1210
|
} finally {
|
|
1208
1211
|
active_effect = previous_effect;
|
|
1209
1212
|
|
|
1213
|
+
if (custom_renderers_flag) pop_renderer(previous_renderer);
|
|
1214
|
+
|
|
1210
1215
|
if (DEV) {
|
|
1211
1216
|
set_dev_current_component_function(previous_component_fn);
|
|
1212
1217
|
set_dev_stack(previous_stack);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as e from '../shared/errors.js';
|
|
2
|
+
|
|
3
|
+
// This module is injected by the compiler into every component when the custom
|
|
4
|
+
// renderer feature is enabled. It is only ever imported as a package specifier
|
|
5
|
+
// (`svelte/internal/flags/custom-renderer`) from compiled client output, which
|
|
6
|
+
// must run where Svelte's client build is available — i.e. with the `browser`
|
|
7
|
+
// or `svelte-custom-renderer` resolve condition set. If we end up here, the component
|
|
8
|
+
// is running in a server context without that condition, so fail fast with the
|
|
9
|
+
// same descriptive error as `svelte/renderer`.
|
|
10
|
+
e.custom_renderer_unavailable_on_server();
|
|
@@ -4,6 +4,8 @@ export let async_mode_flag = false;
|
|
|
4
4
|
export let legacy_mode_flag = false;
|
|
5
5
|
/** True if $inspect.trace is used */
|
|
6
6
|
export let tracing_mode_flag = false;
|
|
7
|
+
/** True if custom renderers are used */
|
|
8
|
+
export let custom_renderers_flag = false;
|
|
7
9
|
|
|
8
10
|
export function enable_async_mode_flag() {
|
|
9
11
|
async_mode_flag = true;
|
|
@@ -21,3 +23,7 @@ export function enable_legacy_mode_flag() {
|
|
|
21
23
|
export function enable_tracing_mode_flag() {
|
|
22
24
|
tracing_mode_flag = true;
|
|
23
25
|
}
|
|
26
|
+
|
|
27
|
+
export function enable_custom_renderers_flag() {
|
|
28
|
+
custom_renderers_flag = true;
|
|
29
|
+
}
|
|
@@ -2,6 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
import { DEV } from 'esm-env';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* You need to specify a custom condition to use a custom renderer in a non-browser environment such as Node. Add the `svelte-custom-renderer` resolve condition (eg. run Node with `--conditions=svelte-custom-renderer`).
|
|
7
|
+
*
|
|
8
|
+
* If you're using a bundler, add `svelte-custom-renderer` to its list of resolve conditions instead.
|
|
9
|
+
* @returns {never}
|
|
10
|
+
*/
|
|
11
|
+
export function custom_renderer_unavailable_on_server() {
|
|
12
|
+
if (DEV) {
|
|
13
|
+
const error = new Error(`custom_renderer_unavailable_on_server\nYou need to specify a custom condition to use a custom renderer in a non-browser environment such as Node. Add the \`svelte-custom-renderer\` resolve condition (eg. run Node with \`--conditions=svelte-custom-renderer\`).
|
|
14
|
+
|
|
15
|
+
If you're using a bundler, add \`svelte-custom-renderer\` to its list of resolve conditions instead.\nhttps://svelte.dev/e/custom_renderer_unavailable_on_server`);
|
|
16
|
+
|
|
17
|
+
error.name = 'Svelte error';
|
|
18
|
+
|
|
19
|
+
throw error;
|
|
20
|
+
} else {
|
|
21
|
+
throw new Error(`https://svelte.dev/e/custom_renderer_unavailable_on_server`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
5
25
|
/**
|
|
6
26
|
* Cannot use `%name%(...)` unless the `experimental.async` compiler option is `true`
|
|
7
27
|
* @param {string} name
|
|
@@ -113,7 +113,7 @@ class Svelte4Component {
|
|
|
113
113
|
}
|
|
114
114
|
);
|
|
115
115
|
|
|
116
|
-
|
|
116
|
+
const render_options = {
|
|
117
117
|
target: options.target,
|
|
118
118
|
anchor: options.anchor,
|
|
119
119
|
props,
|
|
@@ -121,7 +121,11 @@ class Svelte4Component {
|
|
|
121
121
|
intro: options.intro ?? false,
|
|
122
122
|
recover: options.recover,
|
|
123
123
|
transformError: options.transformError
|
|
124
|
-
}
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
this.#instance = options.hydrate
|
|
127
|
+
? hydrate(options.component, render_options)
|
|
128
|
+
: mount(options.component, render_options);
|
|
125
129
|
|
|
126
130
|
// We don't flushSync for custom element wrappers or if the user doesn't want it,
|
|
127
131
|
// or if we're in async mode since `flushSync()` will fail
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as e from '../internal/shared/errors.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Server-side stub for `svelte/renderer`. Custom renderers rely on Svelte's
|
|
5
|
+
* client build (the same one selected by the `browser` export condition), which
|
|
6
|
+
* is not available in a server context. Calling `createRenderer` here throws a
|
|
7
|
+
* descriptive error pointing users at the `svelte-custom-renderer` resolve condition
|
|
8
|
+
* rather than letting them fail later with a cryptic `mount` error.
|
|
9
|
+
*
|
|
10
|
+
* The parameter mirrors the real `createRenderer` signature so this stub is a
|
|
11
|
+
* drop-in replacement; it is intentionally unused.
|
|
12
|
+
*
|
|
13
|
+
* @param {unknown} [_renderer]
|
|
14
|
+
* @returns {never}
|
|
15
|
+
*/
|
|
16
|
+
export function createRenderer(_renderer) {
|
|
17
|
+
e.custom_renderer_unavailable_on_server();
|
|
18
|
+
}
|
package/src/version.js
CHANGED