Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { DEV } from 'esm-env';

export * from '../shared/errors.js';

/**
* MESSAGE
* @param {string} PARAMETER
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export * from '../shared/errors.js';

/**
* MESSAGE
* @param {string} PARAMETER
Expand Down
11 changes: 5 additions & 6 deletions packages/svelte/src/index-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { active_reaction, untrack } from './internal/client/runtime.js';
import { is_array } from './internal/shared/utils.js';
import { user_effect } from './internal/client/index.js';
import * as e from './internal/client/errors.js';
import { lifecycle_outside_component } from './internal/shared/errors.js';
import { legacy_mode_flag } from './internal/flags/index.js';
import { component_context } from './internal/client/context.js';
import { DEV } from 'esm-env';
Expand Down Expand Up @@ -91,7 +90,7 @@ export function getAbortSignal() {
*/
export function onMount(fn) {
if (component_context === null) {
lifecycle_outside_component('onMount');
e.lifecycle_outside_component('onMount');
}

if (legacy_mode_flag && component_context.l !== null) {
Expand All @@ -115,7 +114,7 @@ export function onMount(fn) {
*/
export function onDestroy(fn) {
if (component_context === null) {
lifecycle_outside_component('onDestroy');
e.lifecycle_outside_component('onDestroy');
}

onMount(() => () => untrack(fn));
Expand Down Expand Up @@ -158,7 +157,7 @@ function create_custom_event(type, detail, { bubbles = false, cancelable = false
export function createEventDispatcher() {
const active_component_context = component_context;
if (active_component_context === null) {
lifecycle_outside_component('createEventDispatcher');
e.lifecycle_outside_component('createEventDispatcher');
}

return (type, detail, options) => {
Expand Down Expand Up @@ -196,7 +195,7 @@ export function createEventDispatcher() {
*/
export function beforeUpdate(fn) {
if (component_context === null) {
lifecycle_outside_component('beforeUpdate');
e.lifecycle_outside_component('beforeUpdate');
}

if (component_context.l === null) {
Expand All @@ -219,7 +218,7 @@ export function beforeUpdate(fn) {
*/
export function afterUpdate(fn) {
if (component_context === null) {
lifecycle_outside_component('afterUpdate');
e.lifecycle_outside_component('afterUpdate');
}

if (component_context.l === null) {
Expand Down
4 changes: 2 additions & 2 deletions packages/svelte/src/internal/client/context.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** @import { ComponentContext, DevStackEntry } from '#client' */

import { DEV } from 'esm-env';
import { lifecycle_outside_component } from '../shared/errors.js';
import * as e from './errors.js';
import { source } from './reactivity/sources.js';
import {
active_effect,
Expand Down Expand Up @@ -205,7 +205,7 @@ export function is_runes() {
*/
function get_or_init_context_map(name) {
if (component_context === null) {
lifecycle_outside_component(name);
e.lifecycle_outside_component(name);
}

return (component_context.c ??= new Map(get_parent_context(component_context) || undefined));
Expand Down
7 changes: 4 additions & 3 deletions packages/svelte/src/internal/client/dev/validation.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { invalid_snippet_arguments } from '../../shared/errors.js';
import * as e from '../errors.js';
/**
* @param {Node} anchor
* @param {...(()=>any)[]} args
*/
export function validate_snippet_args(anchor, ...args) {
if (typeof anchor !== 'object' || !(anchor instanceof Node)) {
invalid_snippet_arguments();
e.invalid_snippet_arguments();
}

for (let arg of args) {
if (typeof arg !== 'function') {
invalid_snippet_arguments();
e.invalid_snippet_arguments();
}
}
}
2 changes: 2 additions & 0 deletions packages/svelte/src/internal/client/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import { DEV } from 'esm-env';

export * from '../shared/errors.js';

/**
* Using `bind:value` together with a checkbox input is not allowed. Use `bind:checked` instead
* @returns {never}
Expand Down
2 changes: 1 addition & 1 deletion packages/svelte/src/internal/server/context.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** @import { Component } from '#server' */
import { DEV } from 'esm-env';
import { on_destroy } from './index.js';
import * as e from '../shared/errors.js';
import * as e from './errors.js';

/** @type {Component | null} */
export var current_component = null;
Expand Down
4 changes: 2 additions & 2 deletions packages/svelte/src/internal/server/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
is_tag_valid_with_parent
} from '../../html-tree-validation.js';
import { current_component } from './context.js';
import { invalid_snippet_arguments } from '../shared/errors.js';
import * as e from './errors.js';
import { HeadPayload, Payload } from './payload.js';

/**
Expand Down Expand Up @@ -102,6 +102,6 @@ export function validate_snippet_args(payload) {
// for some reason typescript consider the type of payload as never after the first instanceof
!(payload instanceof Payload || /** @type {any} */ (payload) instanceof HeadPayload)
) {
invalid_snippet_arguments();
e.invalid_snippet_arguments();
}
}
2 changes: 1 addition & 1 deletion packages/svelte/src/internal/server/errors.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* This file is generated by scripts/process-messages/index.js. Do not edit! */


export * from '../shared/errors.js';

/**
* `%name%(...)` is not available on the server
Expand Down
4 changes: 2 additions & 2 deletions packages/svelte/src/legacy/legacy-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { user_pre_effect } from '../internal/client/reactivity/effects.js';
import { mutable_source, set } from '../internal/client/reactivity/sources.js';
import { hydrate, mount, unmount } from '../internal/client/render.js';
import { active_effect, flushSync, get, set_signal_status } from '../internal/client/runtime.js';
import { lifecycle_outside_component } from '../internal/shared/errors.js';
import { define_property, is_array } from '../internal/shared/utils.js';
import * as e from '../internal/client/errors.js';
import * as w from '../internal/client/warnings.js';
import { DEV } from 'esm-env';
import { FILENAME } from '../constants.js';
Expand Down Expand Up @@ -245,7 +245,7 @@ export function handlers(...handlers) {
export function createBubbler() {
const active_component_context = component_context;
if (active_component_context === null) {
lifecycle_outside_component('createBubbler');
e.lifecycle_outside_component('createBubbler');
}

return (/**@type {string}*/ type) => (/**@type {Event}*/ event) => {
Expand Down
Loading