Skip to content

Commit 76329e4

Browse files
committed
tidy up server exports
1 parent d49e2ae commit 76329e4

File tree

3 files changed

+32
-26
lines changed

3 files changed

+32
-26
lines changed

packages/svelte/src/index-server.js

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,39 @@
11
import { current_component_context } from './internal/client/runtime.js';
2+
import { noop } from './internal/common.js';
23

3-
export {
4-
createEventDispatcher,
5-
flushSync,
6-
getAllContexts,
7-
getContext,
8-
hasContext,
9-
mount,
10-
hydrate,
11-
setContext,
12-
tick,
13-
unmount,
14-
untrack
15-
} from './index-client.js';
16-
17-
/** @returns {void} */
18-
export function onMount() {}
4+
export { getAllContexts, getContext, hasContext, setContext } from './index-client.js';
195

206
/** @param {() => void} fn */
217
export function onDestroy(fn) {
228
const context = /** @type {import('#client').ComponentContext} */ (current_component_context);
239
(context.ondestroy ??= []).push(fn);
2410
}
2511

26-
/** @returns {void} */
27-
export function beforeUpdate() {}
12+
export {
13+
noop as beforeUpdate,
14+
noop as afterUpdate,
15+
noop as onMount,
16+
noop as flushSync,
17+
run as untrack
18+
} from './internal/common.js';
19+
20+
export function createEventDispatcher() {
21+
return noop;
22+
}
23+
24+
export function mount() {
25+
throw new Error('mount(...) is not available on the server');
26+
}
27+
28+
export function hydrate() {
29+
throw new Error('hydrate(...) is not available on the server');
30+
}
31+
32+
export function unmount() {
33+
throw new Error('unmount(...) is not available on the server');
34+
}
2835

29-
/** @returns {void} */
30-
export function afterUpdate() {}
36+
export async function tick() {}
3137

3238
/**
3339
* @template T

packages/svelte/src/internal/client/dom/legacy/lifecycle.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { run_all } from '../../../common.js';
1+
import { run, run_all } from '../../../common.js';
22
import { user_pre_effect, user_effect } from '../../reactivity/effects.js';
33
import {
44
current_component_context,
@@ -9,11 +9,6 @@ import {
99
untrack
1010
} from '../../runtime.js';
1111

12-
/** @param {Function} fn */
13-
function run(fn) {
14-
return fn();
15-
}
16-
1712
/**
1813
* Legacy-mode only: Call `onMount` callbacks and set up `beforeUpdate`/`afterUpdate` effects
1914
*/

packages/svelte/src/internal/common.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ export function is_promise(value) {
1313
return typeof value?.then === 'function';
1414
}
1515

16+
/** @param {Function} fn */
17+
export function run(fn) {
18+
return fn();
19+
}
20+
1621
/** @param {Array<() => void>} arr */
1722
export function run_all(arr) {
1823
for (var i = 0; i < arr.length; i++) {

0 commit comments

Comments
 (0)