Skip to content

Commit 61f7565

Browse files
authored
chore: re-export shared errors (#16356)
1 parent 58baf80 commit 61f7565

File tree

10 files changed

+23
-17
lines changed

10 files changed

+23
-17
lines changed

packages/svelte/scripts/process-messages/templates/client-errors.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { DEV } from 'esm-env';
22

3+
export * from '../shared/errors.js';
4+
35
/**
46
* MESSAGE
57
* @param {string} PARAMETER

packages/svelte/scripts/process-messages/templates/server-errors.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
export * from '../shared/errors.js';
2+
13
/**
24
* MESSAGE
35
* @param {string} PARAMETER

packages/svelte/src/index-client.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { active_reaction, untrack } from './internal/client/runtime.js';
55
import { is_array } from './internal/shared/utils.js';
66
import { user_effect } from './internal/client/index.js';
77
import * as e from './internal/client/errors.js';
8-
import { lifecycle_outside_component } from './internal/shared/errors.js';
98
import { legacy_mode_flag } from './internal/flags/index.js';
109
import { component_context } from './internal/client/context.js';
1110
import { DEV } from 'esm-env';
@@ -91,7 +90,7 @@ export function getAbortSignal() {
9190
*/
9291
export function onMount(fn) {
9392
if (component_context === null) {
94-
lifecycle_outside_component('onMount');
93+
e.lifecycle_outside_component('onMount');
9594
}
9695

9796
if (legacy_mode_flag && component_context.l !== null) {
@@ -115,7 +114,7 @@ export function onMount(fn) {
115114
*/
116115
export function onDestroy(fn) {
117116
if (component_context === null) {
118-
lifecycle_outside_component('onDestroy');
117+
e.lifecycle_outside_component('onDestroy');
119118
}
120119

121120
onMount(() => () => untrack(fn));
@@ -158,7 +157,7 @@ function create_custom_event(type, detail, { bubbles = false, cancelable = false
158157
export function createEventDispatcher() {
159158
const active_component_context = component_context;
160159
if (active_component_context === null) {
161-
lifecycle_outside_component('createEventDispatcher');
160+
e.lifecycle_outside_component('createEventDispatcher');
162161
}
163162

164163
return (type, detail, options) => {
@@ -196,7 +195,7 @@ export function createEventDispatcher() {
196195
*/
197196
export function beforeUpdate(fn) {
198197
if (component_context === null) {
199-
lifecycle_outside_component('beforeUpdate');
198+
e.lifecycle_outside_component('beforeUpdate');
200199
}
201200

202201
if (component_context.l === null) {
@@ -219,7 +218,7 @@ export function beforeUpdate(fn) {
219218
*/
220219
export function afterUpdate(fn) {
221220
if (component_context === null) {
222-
lifecycle_outside_component('afterUpdate');
221+
e.lifecycle_outside_component('afterUpdate');
223222
}
224223

225224
if (component_context.l === null) {

packages/svelte/src/internal/client/context.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/** @import { ComponentContext, DevStackEntry } from '#client' */
22

33
import { DEV } from 'esm-env';
4-
import { lifecycle_outside_component } from '../shared/errors.js';
4+
import * as e from './errors.js';
55
import { source } from './reactivity/sources.js';
66
import {
77
active_effect,
@@ -205,7 +205,7 @@ export function is_runes() {
205205
*/
206206
function get_or_init_context_map(name) {
207207
if (component_context === null) {
208-
lifecycle_outside_component(name);
208+
e.lifecycle_outside_component(name);
209209
}
210210

211211
return (component_context.c ??= new Map(get_parent_context(component_context) || undefined));
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
import { invalid_snippet_arguments } from '../../shared/errors.js';
1+
import * as e from '../errors.js';
22
/**
33
* @param {Node} anchor
44
* @param {...(()=>any)[]} args
55
*/
66
export function validate_snippet_args(anchor, ...args) {
77
if (typeof anchor !== 'object' || !(anchor instanceof Node)) {
8-
invalid_snippet_arguments();
8+
e.invalid_snippet_arguments();
99
}
10+
1011
for (let arg of args) {
1112
if (typeof arg !== 'function') {
12-
invalid_snippet_arguments();
13+
e.invalid_snippet_arguments();
1314
}
1415
}
1516
}

packages/svelte/src/internal/client/errors.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import { DEV } from 'esm-env';
44

5+
export * from '../shared/errors.js';
6+
57
/**
68
* Using `bind:value` together with a checkbox input is not allowed. Use `bind:checked` instead
79
* @returns {never}

packages/svelte/src/internal/server/context.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/** @import { Component } from '#server' */
22
import { DEV } from 'esm-env';
33
import { on_destroy } from './index.js';
4-
import * as e from '../shared/errors.js';
4+
import * as e from './errors.js';
55

66
/** @type {Component | null} */
77
export var current_component = null;

packages/svelte/src/internal/server/dev.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
is_tag_valid_with_parent
66
} from '../../html-tree-validation.js';
77
import { current_component } from './context.js';
8-
import { invalid_snippet_arguments } from '../shared/errors.js';
8+
import * as e from './errors.js';
99
import { HeadPayload, Payload } from './payload.js';
1010

1111
/**
@@ -102,6 +102,6 @@ export function validate_snippet_args(payload) {
102102
// for some reason typescript consider the type of payload as never after the first instanceof
103103
!(payload instanceof Payload || /** @type {any} */ (payload) instanceof HeadPayload)
104104
) {
105-
invalid_snippet_arguments();
105+
e.invalid_snippet_arguments();
106106
}
107107
}

packages/svelte/src/internal/server/errors.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* This file is generated by scripts/process-messages/index.js. Do not edit! */
22

3-
3+
export * from '../shared/errors.js';
44

55
/**
66
* `%name%(...)` is not available on the server

packages/svelte/src/legacy/legacy-client.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import { user_pre_effect } from '../internal/client/reactivity/effects.js';
44
import { mutable_source, set } from '../internal/client/reactivity/sources.js';
55
import { hydrate, mount, unmount } from '../internal/client/render.js';
66
import { active_effect, flushSync, get, set_signal_status } from '../internal/client/runtime.js';
7-
import { lifecycle_outside_component } from '../internal/shared/errors.js';
87
import { define_property, is_array } from '../internal/shared/utils.js';
8+
import * as e from '../internal/client/errors.js';
99
import * as w from '../internal/client/warnings.js';
1010
import { DEV } from 'esm-env';
1111
import { FILENAME } from '../constants.js';
@@ -245,7 +245,7 @@ export function handlers(...handlers) {
245245
export function createBubbler() {
246246
const active_component_context = component_context;
247247
if (active_component_context === null) {
248-
lifecycle_outside_component('createBubbler');
248+
e.lifecycle_outside_component('createBubbler');
249249
}
250250

251251
return (/**@type {string}*/ type) => (/**@type {Event}*/ event) => {

0 commit comments

Comments
 (0)