chore: use message-box for message processing

message-box
Rich Harris 15 hours ago
parent 4bf15ae6f3
commit 36ed1a78be
No known key found for this signature in database

@ -157,6 +157,7 @@
"@rollup/plugin-node-resolve": "^15.3.0",
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-virtual": "^3.0.2",
"@sveltejs/message-box": "^1.1.0",
"@types/aria-query": "^5.0.4",
"@types/node": "^20.11.5",
"@types/trusted-types": "^2.0.7",

@ -1,21 +1,16 @@
/** @import { Node } from 'esrap/languages/ts' */
/** @import * as ESTree from 'estree' */
/** @import { AST } from 'svelte/compiler' */
/** @import { Message } from '@sveltejs/message-box' */
// @ts-check
import process from 'node:process';
import fs from 'node:fs';
import * as acorn from 'acorn';
import { walk } from 'zimmerframe';
import * as esrap from 'esrap';
import ts from 'esrap/languages/ts';
import { parse, render } from '@sveltejs/message-box';
const DIR = '../../documentation/docs/98-reference/.generated';
const watch = process.argv.includes('-w');
function run() {
/** @type {Record<string, Record<string, { messages: string[], details: string | null }>>} */
/** @type {Record<string, Record<string, Message>>} */
const messages = {};
const seen = new Set();
@ -34,35 +29,22 @@ function run() {
.readFileSync(`messages/${category}/${file}`, 'utf-8')
.replace(/\r\n/g, '\n');
const sorted = [];
for (const match of markdown.matchAll(/## ([\w]+)\n\n([^]+?)(?=$|\n\n## )/g)) {
const [_, code, text] = match;
if (seen.has(code)) {
throw new Error(`Duplicate message code ${category}/${code}`);
}
sorted.push({ code, _ });
const sections = text.trim().split('\n\n');
const details = [];
while (!sections[sections.length - 1].startsWith('> ')) {
details.unshift(/** @type {string} */ (sections.pop()));
}
if (sections.length === 0) {
throw new Error('No message text');
for (const message of parse(markdown)) {
if (seen.has(message.code)) {
throw new Error(`Duplicate message code ${category}/${message.code}`);
}
seen.add(code);
messages[category][code] = {
messages: sections.map((section) => section.replace(/^> /gm, '').replace(/^>\n/gm, '\n')),
details: details.join('\n\n')
};
seen.add(message.code);
messages[category][message.code] = message;
}
const sorted = Array.from(
markdown.matchAll(/## ([\w]+)\n\n([^]+?)(?=$|\n\n## )/g),
([_, code]) => ({
code,
_
})
);
sorted.sort((a, b) => (a.code < b.code ? -1 : 1));
fs.writeFileSync(
@ -75,11 +57,8 @@ function run() {
`${DIR}/${category}.md`,
'<!-- This file is generated by scripts/process-messages/index.js. Do not edit! -->\n\n' +
Object.entries(messages[category])
.map(([code, { messages, details }]) => {
const chunks = [
`### ${code}`,
...messages.map((message) => '```\n' + message + '\n```')
];
.map(([code, { variants, details }]) => {
const chunks = [`### ${code}`, ...variants.map(({ text }) => '```\n' + text + '\n```')];
if (details) {
chunks.push(details);
@ -101,296 +80,28 @@ function run() {
const source = fs
.readFileSync(new URL(`./templates/${name}.js`, import.meta.url), 'utf-8')
.replace(/\r\n/g, '\n');
const marker = '/**\n * DESCRIPTION';
const index = source.lastIndexOf(marker);
/** @type {AST.JSComment[]} */
const comments = [];
let ast = /** @type {ESTree.Node} */ (
/** @type {unknown} */ (
acorn.parse(source, {
ecmaVersion: 'latest',
sourceType: 'module',
locations: true,
onComment: comments
})
)
);
comments.forEach((comment) => {
if (comment.type === 'Block') {
comment.value = comment.value.replace(/^\t+/gm, '');
}
});
ast = walk(ast, null, {
Identifier(node, context) {
if (node.name === 'CODES') {
/** @type {ESTree.ArrayExpression} */
const array = {
type: 'ArrayExpression',
elements: Object.keys(messages[name]).map((code) => ({
type: 'Literal',
value: code
}))
};
return array;
}
}
});
const body = /** @type {ESTree.Program} */ (ast).body;
if (index === -1) throw new Error(`missing message template in ${name}.js`);
const category = messages[name];
// find the `export function CODE` node
const index = body.findIndex((node) => {
if (
node.type === 'ExportNamedDeclaration' &&
node.declaration &&
node.declaration.type === 'FunctionDeclaration'
) {
return node.declaration.id.name === 'CODE';
}
});
if (index === -1) throw new Error(`missing export function CODE in ${name}.js`);
const template_node = body[index];
body.splice(index, 1);
const jsdoc = /** @type {AST.JSComment} */ (
comments.findLast((comment) => comment.start < /** @type {number} */ (template_node.start))
);
const printed = esrap.print(
/** @type {Node} */ (ast),
ts({
comments: comments.filter((comment) => comment !== jsdoc)
})
);
for (const code in category) {
const { messages } = category[code];
/** @type {string[]} */
const vars = [];
const group = messages.map((text, i) => {
for (const match of text.matchAll(/%(\w+)%/g)) {
const name = match[1];
if (!vars.includes(name)) {
vars.push(match[1]);
}
}
return {
text,
vars: vars.slice()
};
});
/** @type {ESTree.Expression} */
let message = { type: 'Literal', value: '' };
let prev_vars;
for (let i = 0; i < group.length; i += 1) {
const { text, vars } = group[i];
if (vars.length === 0) {
message = {
type: 'Literal',
value: text
};
prev_vars = vars;
continue;
}
const parts = text.split(/(%\w+%)/);
/** @type {ESTree.Expression[]} */
const expressions = [];
/** @type {ESTree.TemplateElement[]} */
const quasis = [];
for (let i = 0; i < parts.length; i += 1) {
const part = parts[i];
if (i % 2 === 0) {
const str = part.replace(/(`|\${)/g, '\\$1');
quasis.push({
type: 'TemplateElement',
value: { raw: str, cooked: str },
tail: i === parts.length - 1
});
} else {
expressions.push({
type: 'Identifier',
name: part.slice(1, -1)
});
}
}
/** @type {ESTree.Expression} */
const expression = {
type: 'TemplateLiteral',
expressions,
quasis
};
if (prev_vars) {
if (vars.length === prev_vars.length) {
throw new Error('Message overloads must have new parameters');
}
message = {
type: 'ConditionalExpression',
test: {
type: 'Identifier',
name: vars[prev_vars.length]
},
consequent: expression,
alternate: message
};
} else {
message = expression;
}
prev_vars = vars;
}
const clone = /** @type {ESTree.Statement} */ (
walk(/** @type {ESTree.Node} */ (template_node), null, {
FunctionDeclaration(node, context) {
if (node.id.name !== 'CODE') return;
const params = [];
for (const param of node.params) {
if (param.type === 'Identifier' && param.name === 'PARAMETER') {
params.push(...vars.map((name) => ({ type: 'Identifier', name })));
} else {
params.push(param);
}
}
return /** @type {ESTree.FunctionDeclaration} */ ({
.../** @type {ESTree.FunctionDeclaration} */ (context.next()),
params,
id: {
...node.id,
name: code
}
});
},
TemplateLiteral(node, context) {
/** @type {ESTree.TemplateElement} */
let quasi = {
type: 'TemplateElement',
value: {
...node.quasis[0].value
},
tail: node.quasis[0].tail
};
/** @type {ESTree.TemplateLiteral} */
let out = {
type: 'TemplateLiteral',
quasis: [quasi],
expressions: []
};
for (let i = 0; i < node.expressions.length; i += 1) {
const q = structuredClone(node.quasis[i + 1]);
const e = node.expressions[i];
if (e.type === 'Literal' && e.value === 'CODE') {
quasi.value.raw += code + q.value.raw;
continue;
}
if (e.type === 'Identifier' && e.name === 'MESSAGE') {
if (message.type === 'Literal') {
const str = /** @type {string} */ (message.value).replace(/(`|\${)/g, '\\$1');
quasi.value.raw += str + q.value.raw;
continue;
}
if (message.type === 'TemplateLiteral') {
const m = structuredClone(message);
quasi.value.raw += m.quasis[0].value.raw;
out.quasis.push(...m.quasis.slice(1));
out.expressions.push(...m.expressions);
quasi = m.quasis[m.quasis.length - 1];
quasi.value.raw += q.value.raw;
continue;
}
}
out.quasis.push((quasi = q));
out.expressions.push(/** @type {ESTree.Expression} */ (context.visit(e)));
}
return out;
},
Literal(node) {
if (node.value === 'CODE') {
return {
type: 'Literal',
value: code
};
}
},
Identifier(node) {
if (node.name !== 'MESSAGE') return;
return message;
}
})
);
const jsdoc_clone = {
...jsdoc,
value: /** @type {string} */ (jsdoc.value)
.split('\n')
.map((line) => {
if (line === ' * MESSAGE') {
return messages[messages.length - 1]
.split('\n')
.map((line) => ` * ${line}`)
.join('\n');
}
if (line.includes('PARAMETER')) {
return vars
.map((name, i) => {
const optional = i >= group[0].vars.length;
return optional
? ` * @param {string | undefined | null} [${name}]`
: ` * @param {string} ${name}`;
})
.join('\n');
}
return line;
})
.filter((x) => x !== '')
.join('\n')
};
const block = esrap.print(
/** @type {ESTree.Program} */ ({ ...ast, body: [clone] }),
ts({ comments: [jsdoc_clone] })
).code;
printed.code += `\n\n${block}`;
body.push(clone);
}
const codes = `[\n${Object.keys(category)
.map((code) => `\t'${code}'`)
.join(',\n')}\n]`;
const preamble = source.slice(0, index).trimEnd().replace('CODES', codes);
const template = source.slice(index).trim();
const output = Object.values(category)
.map((message) => render(message, template))
.join('\n\n');
fs.writeFileSync(
dest,
`/* This file is generated by scripts/process-messages/index.js. Do not edit! */\n\n` +
printed.code,
preamble +
'\n\n' +
output +
'\n',
'utf-8'
);
}

@ -3,13 +3,13 @@ import { DEV } from 'esm-env';
export * from '../shared/errors.js';
/**
* MESSAGE
* @param {string} PARAMETER
* DESCRIPTION
* @param {VALUES} values
* @returns {never}
*/
export function CODE(PARAMETER) {
export function CODE(values) {
if (DEV) {
const error = new Error(`${'CODE'}\n${MESSAGE}\nhttps://svelte.dev/e/${'CODE'}`);
const error = new Error(`${'CODE'}\n${MESSAGE(values)}\nhttps://svelte.dev/e/${'CODE'}`);
error.name = 'Svelte error';
throw error;
} else {

@ -4,13 +4,13 @@ var bold = 'font-weight: bold';
var normal = 'font-weight: normal';
/**
* MESSAGE
* @param {string} PARAMETER
* DESCRIPTION
* @param {VALUES} values
*/
export function CODE(PARAMETER) {
export function CODE(values) {
if (DEV) {
console.warn(
`%c[svelte] ${'CODE'}\n%c${MESSAGE}\nhttps://svelte.dev/e/${'CODE'}`,
`%c[svelte] ${'CODE'}\n%c${MESSAGE(values)}\nhttps://svelte.dev/e/${'CODE'}`,
bold,
normal
);

@ -50,11 +50,11 @@ function e(node, code, message) {
}
/**
* MESSAGE
* DESCRIPTION
* @param {null | number | NodeLike} node
* @param {string} PARAMETER
* @param {VALUES} values
* @returns {never}
*/
export function CODE(node, PARAMETER) {
e(node, 'CODE', `${MESSAGE}\nhttps://svelte.dev/e/${'CODE'}`);
export function CODE(node, values) {
e(node, 'CODE', `${MESSAGE(values)}\nhttps://svelte.dev/e/${'CODE'}`);
}

@ -42,10 +42,10 @@ function w(node, code, message) {
export const codes = CODES;
/**
* MESSAGE
* DESCRIPTION
* @param {null | NodeLike} node
* @param {string} PARAMETER
* @param {VALUES} values
*/
export function CODE(node, PARAMETER) {
w(node, 'CODE', `${MESSAGE}\nhttps://svelte.dev/e/${'CODE'}`);
export function CODE(node, values) {
w(node, 'CODE', `${MESSAGE(values)}\nhttps://svelte.dev/e/${'CODE'}`);
}

@ -1,12 +1,12 @@
export * from '../shared/errors.js';
/**
* MESSAGE
* @param {string} PARAMETER
* DESCRIPTION
* @param {VALUES} values
* @returns {never}
*/
export function CODE(PARAMETER) {
const error = new Error(`${'CODE'}\n${MESSAGE}\nhttps://svelte.dev/e/${'CODE'}`);
export function CODE(values) {
const error = new Error(`${'CODE'}\n${MESSAGE(values)}\nhttps://svelte.dev/e/${'CODE'}`);
error.name = 'Svelte error';
throw error;
}

@ -4,13 +4,13 @@ var bold = 'font-weight: bold';
var normal = 'font-weight: normal';
/**
* MESSAGE
* @param {string} PARAMETER
* DESCRIPTION
* @param {VALUES} values
*/
export function CODE(PARAMETER) {
export function CODE(values) {
if (DEV) {
console.warn(
`%c[svelte] ${'CODE'}\n%c${MESSAGE}\nhttps://svelte.dev/e/${'CODE'}`,
`%c[svelte] ${'CODE'}\n%c${MESSAGE(values)}\nhttps://svelte.dev/e/${'CODE'}`,
bold,
normal
);

@ -1,13 +1,13 @@
import { DEV } from 'esm-env';
/**
* MESSAGE
* @param {string} PARAMETER
* DESCRIPTION
* @param {VALUES} values
* @returns {never}
*/
export function CODE(PARAMETER) {
export function CODE(values) {
if (DEV) {
const error = new Error(`${'CODE'}\n${MESSAGE}\nhttps://svelte.dev/e/${'CODE'}`);
const error = new Error(`${'CODE'}\n${MESSAGE(values)}\nhttps://svelte.dev/e/${'CODE'}`);
error.name = 'Svelte error';
throw error;
} else {

@ -4,13 +4,13 @@ var bold = 'font-weight: bold';
var normal = 'font-weight: normal';
/**
* MESSAGE
* @param {string} PARAMETER
* DESCRIPTION
* @param {VALUES} values
*/
export function CODE(PARAMETER) {
export function CODE(values) {
if (DEV) {
console.warn(
`%c[svelte] ${'CODE'}\n%c${MESSAGE}\nhttps://svelte.dev/e/${'CODE'}`,
`%c[svelte] ${'CODE'}\n%c${MESSAGE(values)}\nhttps://svelte.dev/e/${'CODE'}`,
bold,
normal
);

File diff suppressed because it is too large Load Diff

@ -169,7 +169,7 @@ const regex_position_indicator = / \(\d+:\d+\)$/;
* @returns {never}
*/
function handle_parse_error(err) {
e.js_parse_error(err.pos, err.message.replace(regex_position_indicator, ''));
e.js_parse_error(err.pos, { message: err.message.replace(regex_position_indicator, '') });
}
/**

@ -122,7 +122,7 @@ export class Parser {
current.end = this.template.length;
} else if (current.type === 'RegularElement') {
current.end = current.start + 1;
e.element_unclosed(current, current.name);
e.element_unclosed(current, { name: current.name });
} else {
current.end = current.start + 1;
e.block_unclosed(current);
@ -171,7 +171,7 @@ export class Parser {
}
if (required && (!this.loose || required_in_loose)) {
e.expected_token(this.index, str);
e.expected_token(this.index, { token: str });
}
return false;
@ -244,7 +244,7 @@ export class Parser {
this.index = end;
if (is_reserved(name)) {
e.unexpected_reserved_word(start, name);
e.unexpected_reserved_word(start, { word: name });
}
}

@ -160,7 +160,9 @@ export default function read_options(node) {
} else if (value === 'html' || value === 'mathml' || value === 'svg') {
component_options.namespace = value;
} else {
e.svelte_options_invalid_attribute_value(attribute, `"html", "mathml" or "svg"`);
e.svelte_options_invalid_attribute_value(attribute, {
list: `"html", "mathml" or "svg"`
});
}
break;
@ -171,7 +173,7 @@ export default function read_options(node) {
if (value === 'injected') {
component_options.css = value;
} else {
e.svelte_options_invalid_attribute_value(attribute, `"injected"`);
e.svelte_options_invalid_attribute_value(attribute, { list: `"injected"` });
}
break;
@ -189,7 +191,7 @@ export default function read_options(node) {
break;
}
default:
e.svelte_options_unknown_attribute(attribute, name);
e.svelte_options_unknown_attribute(attribute, { name });
}
}
@ -224,7 +226,7 @@ function get_static_value(attribute) {
function get_boolean_value(attribute) {
const value = get_static_value(attribute);
if (typeof value !== 'boolean') {
e.svelte_options_invalid_attribute_value(attribute, 'true or false');
e.svelte_options_invalid_attribute_value(attribute, { list: 'true or false' });
}
return value;
}

@ -24,7 +24,7 @@ export function read_script(parser, start, attributes) {
const script_start = parser.index;
const data = parser.read_until_regex(regex_closing_script_tag);
if (parser.index >= parser.template.length) {
e.element_unclosed(parser.template.length, 'script');
e.element_unclosed(parser.template.length, { name: 'script' });
}
const source =
@ -47,7 +47,7 @@ export function read_script(parser, start, attributes) {
for (const attribute of /** @type {AST.Attribute[]} */ (attributes)) {
if (RESERVED_ATTRIBUTES.includes(attribute.name)) {
e.script_reserved_attribute(attribute, attribute.name);
e.script_reserved_attribute(attribute, { name: attribute.name });
}
if (!ALLOWED_ATTRIBUTES.includes(attribute.name)) {
@ -57,7 +57,7 @@ export function read_script(parser, start, attributes) {
if (attribute.name === 'module') {
if (attribute.value !== true) {
// Deliberately a generic code to future-proof for potential other attributes
e.script_invalid_attribute_value(attribute, attribute.name);
e.script_invalid_attribute_value(attribute, { name: attribute.name });
}
context = 'module';

@ -38,7 +38,9 @@ const visitors = {
}
},
Decorator(node) {
e.typescript_invalid_feature(node, 'decorators (related TSC proposal is not stage 4 yet)');
e.typescript_invalid_feature(node, {
feature: 'decorators (related TSC proposal is not stage 4 yet)'
});
},
ImportDeclaration(node) {
if (node.importKind === 'type') return b.empty;
@ -82,10 +84,9 @@ const visitors = {
},
PropertyDefinition(node, { next }) {
if (node.accessor) {
e.typescript_invalid_feature(
node,
'accessor fields (related TSC proposal is not stage 4 yet)'
);
e.typescript_invalid_feature(node, {
feature: 'accessor fields (related TSC proposal is not stage 4 yet)'
});
}
return next();
},
@ -108,11 +109,13 @@ const visitors = {
return context.visit(node.expression);
},
TSEnumDeclaration(node) {
e.typescript_invalid_feature(node, 'enums');
e.typescript_invalid_feature(node, { feature: 'enums' });
},
TSParameterProperty(node, context) {
if ((node.readonly || node.accessibility) && context.path.at(-2)?.kind === 'constructor') {
e.typescript_invalid_feature(node, 'accessibility modifiers on constructor parameters');
e.typescript_invalid_feature(node, {
feature: 'accessibility modifiers on constructor parameters'
});
}
return context.visit(node.parameter);
},
@ -171,7 +174,7 @@ const visitors = {
// namespaces can contain non-type nodes
const cleaned = /** @type {any[]} */ (node.body.body).map((entry) => context.visit(entry));
if (cleaned.some((entry) => entry !== b.empty)) {
e.typescript_invalid_feature(node, 'namespaces with non-type nodes');
e.typescript_invalid_feature(node, { feature: 'namespaces with non-type nodes' });
}
return b.empty;

@ -106,15 +106,17 @@ export default function element(parser) {
const end = parent.fragment.nodes[0]?.start ?? start;
w.element_implicitly_closed(
{ start: parent.start, end },
`</${name}>`,
`</${parent.name}>`
{ tag: `</${name}>`, closing: `</${parent.name}>` }
);
}
} else if (!parser.loose) {
if (parser.last_auto_closed_tag && parser.last_auto_closed_tag.tag === name) {
e.element_invalid_closing_tag_autoclosed(start, name, parser.last_auto_closed_tag.reason);
e.element_invalid_closing_tag_autoclosed(start, {
name,
reason: parser.last_auto_closed_tag.reason
});
} else {
e.element_invalid_closing_tag(start, name);
e.element_invalid_closing_tag(start, { name });
}
}
@ -138,7 +140,7 @@ export default function element(parser) {
if (tag.name.startsWith('svelte:') && !meta_tags.has(tag.name)) {
const bounds = { start: start + 1, end: start + 1 + tag.name.length };
e.svelte_meta_invalid_tag(bounds, list(Array.from(meta_tags.keys())));
e.svelte_meta_invalid_tag(bounds, { list: list(Array.from(meta_tags.keys())) });
}
if (!is_valid_element_name(tag.name) && !regex_valid_component_name.test(tag.name)) {
@ -151,11 +153,11 @@ export default function element(parser) {
if (root_only_meta_tags.has(tag.name)) {
if (tag.name in parser.meta_tags) {
e.svelte_meta_duplicate(start, tag.name);
e.svelte_meta_duplicate(start, { name: tag.name });
}
if (parent.type !== 'Root') {
e.svelte_meta_invalid_placement(start, tag.name);
e.svelte_meta_invalid_placement(start, { name: tag.name });
}
parser.meta_tags[tag.name] = true;
@ -209,7 +211,10 @@ export default function element(parser) {
if (parent.type === 'RegularElement' && closing_tag_omitted(parent.name, tag.name)) {
const end = parent.fragment.nodes[0]?.start ?? start;
w.element_implicitly_closed({ start: parent.start, end }, `<${tag.name}>`, `</${parent.name}>`);
w.element_implicitly_closed(
{ start: parent.start, end },
{ tag: `<${tag.name}>`, closing: `</${parent.name}>` }
);
parent.end = start;
parser.pop();
parser.last_auto_closed_tag = {
@ -504,7 +509,7 @@ function read_static_attribute(parser) {
}
if (parser.match_regex(regex_starts_with_quote_characters)) {
e.expected_token(parser.index, '=');
e.expected_token(parser.index, { token: '=' });
}
return create_attribute(tag.name, tag.loc, start, parser.index, value);
@ -638,14 +643,14 @@ function read_attribute(parser) {
end = parser.index;
}
} else if (parser.match_regex(regex_starts_with_quote_characters)) {
e.expected_token(parser.index, '=');
e.expected_token(parser.index, { token: '=' });
}
if (type) {
const [directive_name, ...modifiers] = tag.name.slice(colon_index + 1).split('|');
if (directive_name === '') {
e.directive_missing_name({ start, end: start + colon_index + 1 }, tag.name);
e.directive_missing_name({ start, end: start + colon_index + 1 }, { type: tag.name });
}
if (type === 'StyleDirective') {
@ -818,7 +823,7 @@ function read_attribute_value(parser) {
const pos = error.position?.[0];
if (pos !== undefined && parser.template.slice(pos - 1, pos + 1) === '/>') {
parser.index = pos;
e.expected_token(pos, quote_mark || '}');
e.expected_token(pos, { token: quote_mark || '}' });
}
}
throw error;
@ -874,13 +879,13 @@ function read_sequence(parser, done, location) {
parser.eat('#');
// const name = parser.read_until_regex(/[^a-z]/);
const name = read_lowercase_name(parser);
e.block_invalid_placement(index, name, location);
e.block_invalid_placement(index, { name, location });
} else if (parser.match('@')) {
const index = parser.index - 1;
parser.eat('@');
// const name = parser.read_until_regex(/[^a-z]/);
const name = read_lowercase_name(parser);
e.tag_invalid_placement(index, name, location);
e.tag_invalid_placement(index, { name, location });
}
flush(parser.index - 1);

@ -531,7 +531,7 @@ function next(parser) {
const block = parser.current(); // TODO type should not be TemplateNode, that's much too broad
if (block.type === 'IfBlock') {
if (!parser.eat('else')) e.expected_token(start, '{:else} or {:else if}');
if (!parser.eat('else')) e.expected_token(start, { token: '{:else} or {:else if}' });
if (parser.eat('if')) e.block_invalid_elseif(start);
parser.allow_whitespace();
@ -580,7 +580,7 @@ function next(parser) {
}
if (block.type === 'EachBlock') {
if (!parser.eat('else')) e.expected_token(start, '{:else}');
if (!parser.eat('else')) e.expected_token(start, { token: '{:else}' });
parser.allow_whitespace();
parser.eat('}', true);
@ -596,7 +596,7 @@ function next(parser) {
if (block.type === 'AwaitBlock') {
if (parser.eat('then')) {
if (block.then) {
e.block_duplicate_clause(start, '{:then}');
e.block_duplicate_clause(start, { name: '{:then}' });
}
if (!parser.eat('}')) {
@ -615,7 +615,7 @@ function next(parser) {
if (parser.eat('catch')) {
if (block.catch) {
e.block_duplicate_clause(start, '{:catch}');
e.block_duplicate_clause(start, { name: '{:catch}' });
}
if (!parser.eat('}')) {
@ -632,7 +632,7 @@ function next(parser) {
return;
}
e.expected_token(start, '{:then ...} or {:catch ...}');
e.expected_token(start, { token: '{:then ...} or {:catch ...}' });
}
e.block_invalid_continuation_placement(start);

@ -180,7 +180,7 @@ export function match_bracket(parser, start, brackets = default_brackets) {
const expected = /** @type {string} */ (brackets[popped]);
if (char !== expected) {
e.expected_token(i - 1, expected);
e.expected_token(i - 1, { token: expected });
}
if (bracket_stack.length === 0) {

@ -230,7 +230,7 @@ const css_visitors = {
}
if (child.combinator && child.combinator.name !== ' ') {
e.css_global_block_invalid_combinator(child, child.combinator.name);
e.css_global_block_invalid_combinator(child, { name: child.combinator.name });
}
const declaration = node.block.children.find((child) => child.type === 'Declaration');

@ -35,7 +35,7 @@ const visitors = {
) {
const content = context.state.stylesheet.content;
const text = content.styles.substring(node.start - content.start, node.end - content.start);
w.css_unused_selector(node, text);
w.css_unused_selector(node, { name: text });
}
context.next();

@ -267,7 +267,7 @@ export function analyze_module(source, options) {
for (const [name, references] of scope.references) {
if (name[0] !== '$' || RESERVED.includes(name)) continue;
if (name === '$' || name[1] === '$') {
e.global_reference_invalid(references[0].node, name);
e.global_reference_invalid(references[0].node, { name });
}
const binding = scope.get(name.slice(1));
@ -354,7 +354,7 @@ export function analyze_component(root, source, options) {
for (const [name, references] of module.scope.references) {
if (name[0] !== '$' || RESERVED.includes(name)) continue;
if (name === '$' || name[1] === '$') {
e.global_reference_invalid(references[0].node, name);
e.global_reference_invalid(references[0].node, { name });
}
const store_name = name.slice(1);
@ -402,11 +402,11 @@ export function analyze_component(root, source, options) {
if (runes_option !== false) {
if (declaration === null && /[a-z]/.test(store_name[0])) {
e.global_reference_invalid(references[0].node, name);
e.global_reference_invalid(references[0].node, { name });
} else if (declaration !== null && is_rune(name)) {
for (const { node, path } of references) {
if (path.at(-1)?.type === 'CallExpression') {
w.store_rune_conflict(node, store_name);
w.store_rune_conflict(node, { name: store_name });
}
}
}
@ -762,7 +762,7 @@ export function analyze_component(root, source, options) {
type === 'AwaitBlock' ||
type === 'KeyBlock'
) {
w.non_reactive_update(binding.node, name);
w.non_reactive_update(binding.node, { name });
continue outer;
}
}
@ -770,7 +770,7 @@ export function analyze_component(root, source, options) {
}
}
w.non_reactive_update(binding.node, name);
w.non_reactive_update(binding.node, { name });
continue outer;
}
}
@ -812,7 +812,7 @@ export function analyze_component(root, source, options) {
(r) => r.node !== binding.node && r.path.at(-1)?.type !== 'ExportSpecifier'
);
if (!references.length && !instance.scope.declarations.has(`$${name}`)) {
w.export_let_unused(binding.node, name);
w.export_let_unused(binding.node, { name });
}
}
}
@ -830,7 +830,7 @@ export function analyze_component(root, source, options) {
if ([...analysis.snippets].find((snippet) => snippet.expression.name === name)) {
e.snippet_invalid_export(specifier);
} else {
e.export_undefined(specifier, name);
e.export_undefined(specifier, { name });
}
} else if (binding.initial?.type === 'SnippetBlock') {
// If a snippet is exported, a consumer could only import this named export and not the default export (the component).
@ -843,10 +843,9 @@ export function analyze_component(root, source, options) {
}
if (analysis.event_directive_node && analysis.uses_event_attributes) {
e.mixed_event_handler_syntaxes(
analysis.event_directive_node,
analysis.event_directive_node.name
);
e.mixed_event_handler_syntaxes(analysis.event_directive_node, {
name: analysis.event_directive_node.name
});
}
for (const [node, resolved] of analysis.snippet_renderers) {
@ -1326,7 +1325,7 @@ function order_reactive_statements(unsorted_reactive_declarations) {
const cycle = check_graph_for_cycles(edges);
if (cycle?.length) {
const declaration = /** @type {Tuple[]} */ (lookup.get(cycle[0]))[0];
e.reactive_declaration_cycle(declaration[0], cycle.join(' → '));
e.reactive_declaration_cycle(declaration[0], { cycle: cycle.join(' → ') });
}
// We use a map and take advantage of the fact that the spec says insertion order is preserved when iterating

@ -23,7 +23,7 @@ export function AwaitBlock(node, context) {
.match(/{(\s*):then\s+$/);
if (match && match[1] !== '') {
e.block_unexpected_character({ start: start - 10, end: start }, ':');
e.block_unexpected_character({ start: start - 10, end: start }, { character: ':' });
}
}
@ -34,7 +34,7 @@ export function AwaitBlock(node, context) {
.match(/{(\s*):catch\s+$/);
if (match && match[1] !== '') {
e.block_unexpected_character({ start: start - 10, end: start }, ':');
e.block_unexpected_character({ start: start - 10, end: start }, { character: ':' });
}
}
}

@ -30,11 +30,12 @@ export function BindDirective(node, context) {
if (node.name in binding_properties) {
const property = binding_properties[node.name];
if (property.valid_elements && !property.valid_elements.includes(parent.name)) {
e.bind_invalid_target(
node,
node.name,
property.valid_elements.map((valid_element) => `\`<${valid_element}>\``).join(', ')
);
e.bind_invalid_target(node, {
name: node.name,
elements: property.valid_elements
.map((valid_element) => `\`<${valid_element}>\``)
.join(', ')
});
}
if (property.invalid_elements && property.invalid_elements.includes(parent.name)) {
@ -49,11 +50,10 @@ export function BindDirective(node, context) {
.map(([property_name]) => property_name)
.sort();
e.bind_invalid_name(
node,
node.name,
`Possible bindings for <${parent.name}> are ${valid_bindings.join(', ')}`
);
e.bind_invalid_name(node, {
name: node.name,
explanation: `Possible bindings for <${parent.name}> are ${valid_bindings.join(', ')}`
});
}
if (parent.name === 'input' && node.name !== 'this') {
@ -67,15 +67,14 @@ export function BindDirective(node, context) {
}
} else {
if (node.name === 'checked' && type?.value[0].data !== 'checkbox') {
e.bind_invalid_target(
node,
node.name,
`\`<input type="checkbox">\`${type?.value[0].data === 'radio' ? ` — for \`<input type="radio">\`, use \`bind:group\`` : ''}`
);
e.bind_invalid_target(node, {
name: node.name,
elements: `\`<input type="checkbox">\`${type?.value[0].data === 'radio' ? ` — for \`<input type="radio">\`, use \`bind:group\`` : ''}`
});
}
if (node.name === 'files' && type?.value[0].data !== 'file') {
e.bind_invalid_target(node, node.name, '`<input type="file">`');
e.bind_invalid_target(node, { name: node.name, elements: '`<input type="file">`' });
}
}
}
@ -95,11 +94,10 @@ export function BindDirective(node, context) {
}
if (node.name === 'offsetWidth' && is_svg(parent.name)) {
e.bind_invalid_target(
node,
node.name,
`non-\`<svg>\` elements. Use \`bind:clientWidth\` for \`<svg>\` instead`
);
e.bind_invalid_target(node, {
name: node.name,
elements: `non-\`<svg>\` elements. Use \`bind:clientWidth\` for \`<svg>\` instead`
});
}
if (is_content_editable_binding(node.name)) {
@ -119,11 +117,11 @@ export function BindDirective(node, context) {
if (match) {
const property = binding_properties[match];
if (!property.valid_elements || property.valid_elements.includes(parent.name)) {
e.bind_invalid_name(node, node.name, `Did you mean '${match}'?`);
e.bind_invalid_name(node, { name: node.name, explanation: `Did you mean '${match}'?` });
}
}
e.bind_invalid_name(node, node.name);
e.bind_invalid_name(node, { name: node.name });
}
}
@ -149,7 +147,7 @@ export function BindDirective(node, context) {
i >= leading_comments_start
)
) {
e.bind_invalid_parens(node, node.name);
e.bind_invalid_parens(node, { name: node.name });
}
}
@ -269,7 +267,7 @@ export function BindDirective(node, context) {
}
if (binding?.kind === 'each' && binding.metadata?.inside_rest) {
w.bind_invalid_each_rest(binding.node, binding.node.name);
w.bind_invalid_each_rest(binding.node, { name: binding.node.name });
}
context.next({ ...context.state, expression: node.metadata.expression });

@ -21,7 +21,7 @@ export function CallExpression(node, context) {
if (rune && rune !== '$inspect') {
for (const arg of node.arguments) {
if (arg.type === 'SpreadElement') {
e.rune_invalid_spread(node, rune);
e.rune_invalid_spread(node, { rune });
}
}
}
@ -36,7 +36,7 @@ export function CallExpression(node, context) {
case '$bindable':
if (node.arguments.length > 1) {
e.rune_invalid_arguments_length(node, '$bindable', 'zero or one arguments');
e.rune_invalid_arguments_length(node, { rune: '$bindable', args: 'zero or one arguments' });
}
if (
@ -58,7 +58,7 @@ export function CallExpression(node, context) {
case '$host':
if (node.arguments.length > 0) {
e.rune_invalid_arguments(node, '$host');
e.rune_invalid_arguments(node, { rune: '$host' });
} else if (context.state.ast_type === 'module' || !context.state.analysis.custom_element) {
e.host_invalid_placement(node);
}
@ -67,7 +67,7 @@ export function CallExpression(node, context) {
case '$props':
if (context.state.has_props_rune) {
e.props_duplicate(node, rune);
e.props_duplicate(node, { rune });
}
context.state.has_props_rune = true;
@ -81,7 +81,7 @@ export function CallExpression(node, context) {
}
if (node.arguments.length > 0) {
e.rune_invalid_arguments(node, rune);
e.rune_invalid_arguments(node, { rune });
}
break;
@ -90,7 +90,7 @@ export function CallExpression(node, context) {
const grand_parent = get_parent(context.path, -2);
if (context.state.analysis.props_id) {
e.props_duplicate(node, rune);
e.props_duplicate(node, { rune });
}
if (
@ -104,7 +104,7 @@ export function CallExpression(node, context) {
}
if (node.arguments.length > 0) {
e.rune_invalid_arguments(node, rune);
e.rune_invalid_arguments(node, { rune });
}
context.state.analysis.props_id = parent.id;
@ -122,13 +122,13 @@ export function CallExpression(node, context) {
is_class_property_assignment_at_constructor_root(parent, context);
if (!valid) {
e.state_invalid_placement(node, rune);
e.state_invalid_placement(node, { rune });
}
if ((rune === '$derived' || rune === '$derived.by') && node.arguments.length !== 1) {
e.rune_invalid_arguments_length(node, rune, 'exactly one argument');
e.rune_invalid_arguments_length(node, { rune, args: 'exactly one argument' });
} else if (node.arguments.length > 1) {
e.rune_invalid_arguments_length(node, rune, 'zero or one arguments');
e.rune_invalid_arguments_length(node, { rune, args: 'zero or one arguments' });
}
break;
@ -141,7 +141,7 @@ export function CallExpression(node, context) {
}
if (node.arguments.length !== 1) {
e.rune_invalid_arguments_length(node, rune, 'exactly one argument');
e.rune_invalid_arguments_length(node, { rune, args: 'exactly one argument' });
}
// `$effect` needs context because Svelte needs to know whether it should re-run
@ -152,14 +152,14 @@ export function CallExpression(node, context) {
case '$effect.tracking':
if (node.arguments.length !== 0) {
e.rune_invalid_arguments(node, rune);
e.rune_invalid_arguments(node, { rune });
}
break;
case '$effect.root':
if (node.arguments.length !== 1) {
e.rune_invalid_arguments_length(node, rune, 'exactly one argument');
e.rune_invalid_arguments_length(node, { rune, args: 'exactly one argument' });
}
break;
@ -173,21 +173,21 @@ export function CallExpression(node, context) {
case '$inspect':
if (node.arguments.length < 1) {
e.rune_invalid_arguments_length(node, rune, 'one or more arguments');
e.rune_invalid_arguments_length(node, { rune, args: 'one or more arguments' });
}
break;
case '$inspect().with':
if (node.arguments.length !== 1) {
e.rune_invalid_arguments_length(node, rune, 'exactly one argument');
e.rune_invalid_arguments_length(node, { rune, args: 'exactly one argument' });
}
break;
case '$inspect.trace': {
if (node.arguments.length > 1) {
e.rune_invalid_arguments_length(node, rune, 'zero or one arguments');
e.rune_invalid_arguments_length(node, { rune, args: 'zero or one arguments' });
}
const grand_parent = context.path.at(-2);
@ -228,14 +228,14 @@ export function CallExpression(node, context) {
case '$state.eager':
if (node.arguments.length !== 1) {
e.rune_invalid_arguments_length(node, rune, 'exactly one argument');
e.rune_invalid_arguments_length(node, { rune, args: 'exactly one argument' });
}
break;
case '$state.snapshot':
if (node.arguments.length !== 1) {
e.rune_invalid_arguments_length(node, rune, 'exactly one argument');
e.rune_invalid_arguments_length(node, { rune, args: 'exactly one argument' });
}
break;

@ -54,7 +54,7 @@ export function ClassBody(node, context) {
if (rune && is_state_creation_rune(rune)) {
if (state_fields.has(name)) {
e.state_field_duplicate(node, name);
e.state_field_duplicate(node, { name });
}
const _key = (node.type === 'AssignmentExpression' || !node.static ? '' : '@') + name;
@ -62,7 +62,7 @@ export function ClassBody(node, context) {
// if there's already a method or assigned field, error
if (field && !(field.length === 1 && field[0] === 'prop')) {
e.duplicate_class_field(node, _key);
e.duplicate_class_field(node, { name: _key });
}
state_fields.set(name, {
@ -84,7 +84,7 @@ export function ClassBody(node, context) {
fields.set(key, [child.value ? 'assigned_prop' : 'prop']);
continue;
}
e.duplicate_class_field(child, key);
e.duplicate_class_field(child, { name: key });
}
if (child.type === 'MethodDefinition') {
@ -102,7 +102,7 @@ export function ClassBody(node, context) {
field.includes('prop') ||
field.includes('assigned_prop')
) {
e.duplicate_class_field(child, key);
e.duplicate_class_field(child, { name: key });
}
if (child.kind === 'get') {
if (field.length === 1 && field[0] === 'set') {
@ -118,7 +118,7 @@ export function ClassBody(node, context) {
field.push(child.kind);
continue;
}
e.duplicate_class_field(child, key);
e.duplicate_class_field(child, { name: key });
}
}
}

@ -19,7 +19,7 @@ export function DeclarationTag(node, context) {
.flatMap((declaration) => extract_identifiers(declaration.id))
.find((id) => context.state.analysis.instance.scope.declarations.has(id.name));
if (duplicate) {
e.declaration_duplicate(duplicate, duplicate.name);
e.declaration_duplicate(duplicate, { name: duplicate.name });
}
}

@ -20,7 +20,7 @@ export function EachBlock(node, context) {
const id = node.context;
if (id?.type === 'Identifier' && (id.name === '$state' || id.name === '$derived')) {
// TODO weird that this is necessary
e.state_invalid_placement(node, id.name);
e.state_invalid_placement(node, { rune: id.name });
}
if (node.key) {

@ -14,7 +14,7 @@ export function ExpressionTag(node, context) {
if (in_template && context.state.parent_element) {
const message = is_tag_valid_with_parent('#text', context.state.parent_element);
if (message) {
e.node_invalid_placement(node, message);
e.node_invalid_placement(node, { message });
}
}

@ -55,18 +55,18 @@ export function Identifier(node, context) {
if (!is_rune(name)) {
if (name === '$effect.active') {
e.rune_renamed(parent, '$effect.active', '$effect.tracking');
e.rune_renamed(parent, { name: '$effect.active', replacement: '$effect.tracking' });
}
if (name === '$state.frozen') {
e.rune_renamed(parent, '$state.frozen', '$state.raw');
e.rune_renamed(parent, { name: '$state.frozen', replacement: '$state.raw' });
}
if (name === '$state.is') {
e.rune_removed(parent, '$state.is');
e.rune_removed(parent, { name: '$state.is' });
}
e.rune_invalid_name(parent, name);
e.rune_invalid_name(parent, { name });
}
}
@ -148,7 +148,7 @@ export function Identifier(node, context) {
}
}
w.state_referenced_locally(node, node.name, type);
w.state_referenced_locally(node, { name: node.name, type });
}
if (
@ -183,7 +183,7 @@ export function Identifier(node, context) {
? grand_parent.metadata.scopes.default === binding.scope
: context.state.scopes.get(parent) === binding.scope
) {
e.const_tag_invalid_reference(node, node.name);
e.const_tag_invalid_reference(node, { name: node.name });
} else {
break;
}

@ -22,7 +22,7 @@ export function ImportDeclaration(node, context) {
(specifier.imported.name === 'beforeUpdate' ||
specifier.imported.name === 'afterUpdate')
) {
e.runes_mode_invalid_import(specifier, specifier.imported.name);
e.runes_mode_invalid_import(specifier, { name: specifier.imported.name });
}
}
}

@ -13,7 +13,7 @@ export function OnDirective(node, context) {
// Don't warn on component events; these might not be under the author's control so the warning would be unactionable
if (parent_type === 'RegularElement' || parent_type === 'SvelteElement') {
w.event_directive_deprecated(node, node.name);
w.event_directive_deprecated(node, { name: node.name });
}
}

@ -123,7 +123,7 @@ export function RegularElement(node, context) {
binding.declaration_kind === 'import' &&
binding.references.length === 0
) {
w.component_name_lowercase(node, node.name);
w.component_name_lowercase(node, { name: node.name });
}
node.metadata.has_spread = node.attributes.some(
@ -180,9 +180,9 @@ export function RegularElement(node, context) {
const message = is_tag_valid_with_parent(node.name, context.state.parent_element);
if (message) {
if (only_warn) {
w.node_invalid_placement_ssr(node, message);
w.node_invalid_placement_ssr(node, { message });
} else {
e.node_invalid_placement(node, message);
e.node_invalid_placement(node, { message });
}
}
@ -194,9 +194,9 @@ export function RegularElement(node, context) {
const message = is_tag_valid_with_ancestor(node.name, ancestors);
if (message) {
if (only_warn) {
w.node_invalid_placement_ssr(node, message);
w.node_invalid_placement_ssr(node, { message });
} else {
e.node_invalid_placement(node, message);
e.node_invalid_placement(node, { message });
}
}
} else if (
@ -220,7 +220,7 @@ export function RegularElement(node, context) {
!is_svg(node_name) &&
!is_mathml(node_name)
) {
w.element_invalid_self_closing_tag(node, node.name);
w.element_invalid_self_closing_tag(node, { name: node.name });
}
context.next({ ...context.state, parent_element: node.name });

@ -31,7 +31,7 @@ export function SnippetBlock(node, context) {
const name = node.expression.name;
if (context.state.analysis.instance.scope.declarations.has(name)) {
e.declaration_duplicate(node.expression, name);
e.declaration_duplicate(node.expression, { name });
}
node.metadata.can_hoist =
@ -56,7 +56,7 @@ export function SnippetBlock(node, context) {
attribute.name === node.expression.name
)
) {
e.snippet_shadowing_prop(node, node.expression.name);
e.snippet_shadowing_prop(node, { prop: node.expression.name });
}
if (node.expression.name !== 'children') return;

@ -16,7 +16,7 @@ export function SvelteDocument(node, context) {
if (attribute.type === 'Attribute' && is_event_attribute(attribute)) {
check_global_event_reference(attribute, context);
} else if (attribute.type === 'SpreadAttribute' || attribute.type === 'Attribute') {
e.illegal_element_attribute(attribute, 'svelte:document');
e.illegal_element_attribute(attribute, { name: 'svelte:document' });
}
}

@ -29,7 +29,7 @@ export function SvelteSelf(node, context) {
? 'Self.svelte'
: /** @type {string} */ (filename.split(/[/\\]/).pop());
w.svelte_self_deprecated(node, name, basename);
w.svelte_self_deprecated(node, { name, basename });
}
visit_component(node, context);

@ -16,7 +16,7 @@ export function SvelteWindow(node, context) {
if (attribute.type === 'Attribute' && is_event_attribute(attribute)) {
check_global_event_reference(attribute, context);
} else if (attribute.type === 'SpreadAttribute' || attribute.type === 'Attribute') {
e.illegal_element_attribute(attribute, 'svelte:window');
e.illegal_element_attribute(attribute, { name: 'svelte:window' });
}
}

@ -20,7 +20,7 @@ export function Text(node, context) {
) {
const message = is_tag_valid_with_parent('#text', context.state.parent_element);
if (message) {
e.node_invalid_placement(node, message);
e.node_invalid_placement(node, { message });
}
}

@ -141,7 +141,7 @@ export function VariableDeclarator(node, context) {
(callee.name === '$state' || callee.name === '$derived' || callee.name === '$props') &&
context.state.scope.get(callee.name)?.kind !== 'store_sub'
) {
e.rune_invalid_usage(node.init, callee.name);
e.rune_invalid_usage(node.init, { rune: callee.name });
}
}
}

@ -113,17 +113,20 @@ export function check_element(node, context) {
if (name.startsWith('aria-')) {
if (invisible_elements.includes(node.name)) {
// aria-unsupported-elements
w.a11y_aria_attributes(attribute, node.name);
w.a11y_aria_attributes(attribute, { name: node.name });
}
const type = name.slice(5);
if (!aria_attributes.includes(type)) {
const match = fuzzymatch(type, aria_attributes);
w.a11y_unknown_aria_attribute(attribute, type, match);
w.a11y_unknown_aria_attribute(
attribute,
match === null ? { attribute: type } : { attribute: type, suggestion: match }
);
}
if (name === 'aria-hidden' && regex_heading_tags.test(node.name)) {
w.a11y_hidden(attribute, node.name);
w.a11y_hidden(attribute, { name: node.name });
}
// aria-proptypes
@ -151,7 +154,7 @@ export function check_element(node, context) {
case 'role': {
if (invisible_elements.includes(node.name)) {
// aria-unsupported-elements
w.a11y_misplaced_role(attribute, node.name);
w.a11y_misplaced_role(attribute, { name: node.name });
}
const value = get_static_value(attribute);
@ -162,10 +165,13 @@ export function check_element(node, context) {
const current_role = /** @type {ARIARoleDefinitionKey} current_role */ (c_r);
if (current_role && is_abstract_role(current_role)) {
w.a11y_no_abstract_role(attribute, current_role);
w.a11y_no_abstract_role(attribute, { role: current_role });
} else if (current_role && !aria_roles.includes(current_role)) {
const match = fuzzymatch(current_role, aria_roles);
w.a11y_unknown_role(attribute, current_role, match);
w.a11y_unknown_role(
attribute,
match === null ? { role: current_role } : { role: current_role, suggestion: match }
);
}
// no-redundant-roles
@ -176,7 +182,7 @@ export function check_element(node, context) {
// <a role="link" /> is ok because without href the a tag doesn't have a role of link
!(node.name === 'a' && !attribute_map.has('href'))
) {
w.a11y_no_redundant_roles(attribute, current_role);
w.a11y_no_redundant_roles(attribute, { role: current_role });
}
// Footers and headers are special cases, and should not have redundant roles unless they are the children of sections or articles.
@ -185,7 +191,7 @@ export function check_element(node, context) {
const has_nested_redundant_role =
current_role === a11y_nested_implicit_semantics.get(node.name);
if (has_nested_redundant_role) {
w.a11y_no_redundant_roles(attribute, current_role);
w.a11y_no_redundant_roles(attribute, { role: current_role });
}
}
@ -201,14 +207,13 @@ export function check_element(node, context) {
!has_spread &&
required_role_props.some((prop) => !attributes.find((a) => a.name === prop));
if (has_missing_props) {
w.a11y_role_has_required_aria_props(
attribute,
current_role,
list(
w.a11y_role_has_required_aria_props(attribute, {
role: current_role,
props: list(
required_role_props.map((v) => `"${v}"`),
'and'
)
);
});
}
}
}
@ -227,7 +232,7 @@ export function check_element(node, context) {
a11y_interactive_handlers.includes(handler)
);
if (has_interactive_handlers) {
w.a11y_interactive_supports_focus(node, current_role);
w.a11y_interactive_supports_focus(node, { role: current_role });
}
}
@ -237,7 +242,10 @@ export function check_element(node, context) {
is_interactive &&
(is_non_interactive_roles(current_role) || is_presentation_role(current_role))
) {
w.a11y_no_interactive_element_to_noninteractive_role(node, node.name, current_role);
w.a11y_no_interactive_element_to_noninteractive_role(node, {
element: node.name,
role: current_role
});
}
// no-noninteractive-element-to-interactive-role
@ -249,7 +257,10 @@ export function check_element(node, context) {
current_role
)
) {
w.a11y_no_noninteractive_element_to_interactive_role(node, node.name, current_role);
w.a11y_no_noninteractive_element_to_interactive_role(node, {
element: node.name,
role: current_role
});
}
}
break;
@ -302,7 +313,7 @@ export function check_element(node, context) {
const has_key_event =
handlers.has('keydown') || handlers.has('keyup') || handlers.has('keypress');
if (!has_key_event) {
w.a11y_click_events_have_key_events(node, node.name);
w.a11y_click_events_have_key_events(node, { element: node.name });
}
}
}
@ -328,9 +339,13 @@ export function check_element(node, context) {
for (const attr of attributes) {
if (invalid_aria_props.includes(/** @type {ARIAProperty} */ (attr.name))) {
if (is_implicit) {
w.a11y_role_supports_aria_props_implicit(attr, attr.name, role_value, node.name);
w.a11y_role_supports_aria_props_implicit(attr, {
attribute: attr.name,
role: role_value,
name: node.name
});
} else {
w.a11y_role_supports_aria_props(attr, attr.name, role_value);
w.a11y_role_supports_aria_props(attr, { attribute: attr.name, role: role_value });
}
}
}
@ -349,7 +364,7 @@ export function check_element(node, context) {
a11y_recommended_interactive_handlers.includes(handler)
);
if (has_interactive_handlers) {
w.a11y_no_noninteractive_element_interactions(node, node.name);
w.a11y_no_noninteractive_element_interactions(node, { element: node.name });
}
}
@ -369,7 +384,10 @@ export function check_element(node, context) {
a11y_interactive_handlers.includes(handler)
);
if (interactive_handlers.length > 0) {
w.a11y_no_static_element_interactions(node, node.name, list(interactive_handlers));
w.a11y_no_static_element_interactions(node, {
element: node.name,
handler: list(interactive_handlers)
});
}
}
@ -381,7 +399,7 @@ export function check_element(node, context) {
!handlers.has('focus') &&
!handlers.has('focusin')
) {
w.a11y_mouse_events_have_key_events(node, 'mouseover', 'focus');
w.a11y_mouse_events_have_key_events(node, { event: 'mouseover', accompanied_by: 'focus' });
}
if (
@ -390,7 +408,7 @@ export function check_element(node, context) {
!handlers.has('blur') &&
!handlers.has('focusout')
) {
w.a11y_mouse_events_have_key_events(node, 'mouseout', 'blur');
w.a11y_mouse_events_have_key_events(node, { event: 'mouseout', accompanied_by: 'blur' });
}
// element-specific checks
@ -417,7 +435,7 @@ export function check_element(node, context) {
const href_value = get_static_text_value(href);
if (href_value !== null) {
if (href_value === '' || href_value === '#' || regex_js_prefix.test(href_value)) {
w.a11y_invalid_attribute(href, href_value, href.name);
w.a11y_invalid_attribute(href, { href_value, href_attribute: href.name });
}
}
} else if (!has_spread) {
@ -445,11 +463,10 @@ export function check_element(node, context) {
if (type && autocomplete) {
const autocomplete_value = get_static_value(autocomplete);
if (!is_valid_autocomplete(autocomplete_value)) {
w.a11y_autocomplete_valid(
autocomplete,
/** @type {string} */ (autocomplete_value),
type_value ?? '...'
);
w.a11y_autocomplete_valid(autocomplete, {
value: /** @type {string} */ (autocomplete_value),
type: type_value ?? '...'
});
}
}
break;
@ -559,7 +576,7 @@ export function check_element(node, context) {
if (a11y_distracting_elements.includes(node.name)) {
// no-distracting-elements
w.a11y_distracting_elements(node, node.name);
w.a11y_distracting_elements(node, { name: node.name });
}
// Check content
@ -570,7 +587,7 @@ export function check_element(node, context) {
a11y_required_content.includes(node.name) &&
!has_content(node)
) {
w.a11y_missing_content(node, node.name);
w.a11y_missing_content(node, { name: node.name });
}
}
@ -885,42 +902,44 @@ function validate_aria_attribute_value(attribute, name, schema, value) {
case 'id':
case 'string': {
if (value === '') {
w.a11y_incorrect_aria_attribute_type(attribute, name, 'non-empty string');
w.a11y_incorrect_aria_attribute_type(attribute, {
attribute: name,
type: 'non-empty string'
});
}
break;
}
case 'number': {
if (value === '' || isNaN(+value)) {
w.a11y_incorrect_aria_attribute_type(attribute, name, 'number');
w.a11y_incorrect_aria_attribute_type(attribute, { attribute: name, type: 'number' });
}
break;
}
case 'boolean': {
if (value !== 'true' && value !== 'false') {
w.a11y_incorrect_aria_attribute_type_boolean(attribute, name);
w.a11y_incorrect_aria_attribute_type_boolean(attribute, { attribute: name });
}
break;
}
case 'idlist': {
if (value === '') {
w.a11y_incorrect_aria_attribute_type_idlist(attribute, name);
w.a11y_incorrect_aria_attribute_type_idlist(attribute, { attribute: name });
}
break;
}
case 'integer': {
if (value === '' || !Number.isInteger(+value)) {
w.a11y_incorrect_aria_attribute_type_integer(attribute, name);
w.a11y_incorrect_aria_attribute_type_integer(attribute, { attribute: name });
}
break;
}
case 'token': {
const values = (schema.values ?? []).map((value) => value.toString());
if (!values.includes(value.toLowerCase())) {
w.a11y_incorrect_aria_attribute_type_token(
attribute,
name,
list(values.map((v) => `"${v}"`))
);
w.a11y_incorrect_aria_attribute_type_token(attribute, {
attribute: name,
values: list(values.map((v) => `"${v}"`))
});
}
break;
}
@ -932,17 +951,16 @@ function validate_aria_attribute_value(attribute, name, schema, value) {
.split(regex_whitespaces)
.some((value) => !values.includes(value))
) {
w.a11y_incorrect_aria_attribute_type_tokenlist(
attribute,
name,
list(values.map((v) => `"${v}"`))
);
w.a11y_incorrect_aria_attribute_type_tokenlist(attribute, {
attribute: name,
values: list(values.map((v) => `"${v}"`))
});
}
break;
}
case 'tristate': {
if (value !== 'true' && value !== 'false' && value !== 'mixed') {
w.a11y_incorrect_aria_attribute_type_tristate(attribute, name);
w.a11y_incorrect_aria_attribute_type_tristate(attribute, { attribute: name });
}
break;
}
@ -962,5 +980,5 @@ function warn_missing_attribute(node, attributes, name = node.name) {
? attributes.slice(0, -1).join(', ') + ` or ${attributes[attributes.length - 1]}`
: attributes[0];
w.a11y_missing_attribute(node, name, article, sequence);
w.a11y_missing_attribute(node, { name, article, sequence });
}

@ -97,7 +97,7 @@ export function validate_slot_attribute(context, attribute, is_component = false
const name = attribute.value[0].data;
if (context.state.component_slots.has(name)) {
e.slot_attribute_duplicate(attribute, name, owner.name);
e.slot_attribute_duplicate(attribute, { name, component: owner.name });
}
context.state.component_slots.add(name);

@ -57,7 +57,7 @@ export function validate_element(node, context) {
}
if (regex_illegal_attribute_character.test(attribute.name)) {
e.attribute_invalid_name(attribute, attribute.name);
e.attribute_invalid_name(attribute, { name: attribute.name });
}
if (attribute.name.startsWith('on') && attribute.name.length > 2) {
@ -79,7 +79,10 @@ export function validate_element(node, context) {
const correct_name = react_attributes.get(attribute.name);
if (correct_name) {
w.attribute_invalid_property_name(attribute, attribute.name, correct_name);
w.attribute_invalid_property_name(attribute, {
wrong: attribute.name,
right: correct_name
});
}
validate_attribute_name(attribute);
@ -116,9 +119,9 @@ export function validate_element(node, context) {
const b = attribute.intro ? (attribute.outro ? 'transition' : 'in') : 'out';
if (a === b) {
e.transition_duplicate(attribute, a);
e.transition_duplicate(attribute, { type: a });
} else {
e.transition_conflict(attribute, a, b);
e.transition_conflict(attribute, { type: a, existing: b });
}
}
@ -130,7 +133,7 @@ export function validate_element(node, context) {
for (const modifier of attribute.modifiers) {
if (!EVENT_MODIFIERS.includes(modifier)) {
const list = `${EVENT_MODIFIERS.slice(0, -1).join(', ')} or ${EVENT_MODIFIERS.at(-1)}`;
e.event_handler_invalid_modifier(attribute, list);
e.event_handler_invalid_modifier(attribute, { list });
}
if (modifier === 'passive') {
has_passive_modifier = true;
@ -138,11 +141,10 @@ export function validate_element(node, context) {
conflicting_passive_modifier = modifier;
}
if (has_passive_modifier && conflicting_passive_modifier) {
e.event_handler_invalid_modifier_combination(
attribute,
'passive',
conflicting_passive_modifier
);
e.event_handler_invalid_modifier_combination(attribute, {
modifier1: 'passive',
modifier2: conflicting_passive_modifier
});
}
}
}

@ -11,6 +11,6 @@ export function disallow_children(node) {
const first = nodes[0];
const last = nodes[nodes.length - 1];
e.svelte_meta_invalid_content({ start: first.start, end: last.end }, node.name);
e.svelte_meta_invalid_content({ start: first.start, end: last.end }, { name: node.name });
}
}

@ -30,7 +30,7 @@ export function validate_assignment(node, argument, context) {
context.state.analysis.props_id != null &&
binding?.node === context.state.analysis.props_id
) {
e.constant_assignment(node, '$props.id()');
e.constant_assignment(node, { thing: '$props.id()' });
}
if (binding?.kind === 'each') {
@ -118,9 +118,9 @@ export function validate_no_const_assignment(node, argument, scope, is_binding)
const thing = binding.declaration_kind === 'import' ? 'import' : 'constant';
if (is_binding) {
e.constant_binding(node, thing);
e.constant_binding(node, { thing });
} else {
e.constant_assignment(node, thing);
e.constant_assignment(node, { thing });
}
}
}
@ -136,7 +136,10 @@ export function validate_no_const_assignment(node, argument, scope, is_binding)
export function validate_opening_tag(node, state, expected) {
if (state.analysis.source[node.start + 1] !== expected) {
// avoid a sea of red and only mark the first few characters
e.block_unexpected_character({ start: node.start, end: node.start + 5 }, expected);
e.block_unexpected_character(
{ start: node.start, end: node.start + 5 },
{ character: expected }
);
}
}
@ -317,6 +320,6 @@ export function check_global_event_reference(attribute, context) {
value.name === attribute.name &&
!context.state.scope.get(value.name)
) {
w.attribute_global_event_reference(attribute, attribute.name);
w.attribute_global_event_reference(attribute, { name: attribute.name });
}
}

@ -81,7 +81,7 @@ function sort_const_tags(nodes, state) {
const cycle = check_graph_for_cycles(edges);
if (cycle?.length) {
const tag = /** @type {Tag} */ (tags.get(cycle[0]));
e.const_tag_cycle(tag.node, cycle.map((binding) => binding.node.name).join(' → '));
e.const_tag_cycle(tag.node, { cycle: cycle.map((binding) => binding.node.name).join(' → ') });
}
/** @type {AST.ConstTag[]} */

@ -686,7 +686,7 @@ export class Scope {
if (binding && binding.declaration_kind !== 'var' && declaration_kind !== 'var') {
// This also errors on function types, but that's arguably a good thing
// declaring function twice is also caught by acorn in the parse phase
e.declaration_duplicate(node, node.name);
e.declaration_duplicate(node, { name: node.name });
}
}

@ -50,10 +50,10 @@ export function extract_svelte_ignore(offset, text, runes) {
const end = start + code.length;
if (codes.includes(replacement)) {
w.legacy_code({ start, end }, code, replacement);
w.legacy_code({ start, end }, { code, suggestion: replacement });
} else {
const suggestion = fuzzymatch(code, codes);
w.unknown_code({ start, end }, code, suggestion);
w.unknown_code({ start, end }, suggestion === null ? { code } : { code, suggestion });
}
}

@ -187,7 +187,7 @@ export const validate_component_options =
function removed(msg) {
return (input) => {
if (input !== undefined) {
e.options_removed(null, msg);
e.options_removed(null, { details: msg });
}
return /** @type {any} */ (undefined);
};
@ -245,7 +245,7 @@ function object(children, allow_unknown = false) {
if (allow_unknown) {
output[key] = input[key];
} else {
e.options_unrecognised(null, `${keypath ? `${keypath}.${key}` : key}`);
e.options_unrecognised(null, { keypath: `${keypath ? `${keypath}.${key}` : key}` });
}
}
}
@ -357,5 +357,5 @@ function parametric(fallback, normalize = (value) => /** @type {ReturnType<F>} *
/** @param {string} msg */
function throw_error(msg) {
e.options_invalid_value(null, msg);
e.options_invalid_value(null, { details: msg });
}

@ -4,6 +4,7 @@ import { warnings, ignore_stack, ignore_map, warning_filter } from './state.js';
import { CompileDiagnostic } from './utils/compile_diagnostic.js';
/** @typedef {{ start?: number, end?: number }} NodeLike */
class InternalCompileWarning extends CompileDiagnostic {
name = 'CompileWarning';
@ -24,14 +25,16 @@ class InternalCompileWarning extends CompileDiagnostic {
*/
function w(node, code, message) {
let stack = ignore_stack;
if (node) {
stack = ignore_map.get(node) ?? ignore_stack;
}
if (stack && stack.at(-1)?.has(code)) return;
const warning = new InternalCompileWarning(code, message, node && node.start !== undefined ? [node.start, node.end ?? node.start] : undefined);
const warning = new InternalCompileWarning(
code,
message,
node && node.start !== undefined ? [node.start, node.end ?? node.start] : undefined
);
if (!warning_filter(warning)) return;
@ -125,722 +128,728 @@ export const codes = [
/**
* Avoid using accesskey
* @param {null | NodeLike} node
* @param {void} values
*/
export function a11y_accesskey(node) {
w(node, 'a11y_accesskey', `Avoid using accesskey\nhttps://svelte.dev/e/a11y_accesskey`);
export function a11y_accesskey(node, values) {
w(node, 'a11y_accesskey', `${`Avoid using accesskey`}\nhttps://svelte.dev/e/${'a11y_accesskey'}`);
}
/**
* An element with an aria-activedescendant attribute should have a tabindex value
* @param {null | NodeLike} node
* @param {void} values
*/
export function a11y_aria_activedescendant_has_tabindex(node) {
w(node, 'a11y_aria_activedescendant_has_tabindex', `An element with an aria-activedescendant attribute should have a tabindex value\nhttps://svelte.dev/e/a11y_aria_activedescendant_has_tabindex`);
export function a11y_aria_activedescendant_has_tabindex(node, values) {
w(node, 'a11y_aria_activedescendant_has_tabindex', `${`An element with an aria-activedescendant attribute should have a tabindex value`}\nhttps://svelte.dev/e/${'a11y_aria_activedescendant_has_tabindex'}`);
}
/**
* `<%name%>` should not have aria-* attributes
* @param {null | NodeLike} node
* @param {string} name
* @param {{ "name": string }} values
*/
export function a11y_aria_attributes(node, name) {
w(node, 'a11y_aria_attributes', `\`<${name}>\` should not have aria-* attributes\nhttps://svelte.dev/e/a11y_aria_attributes`);
export function a11y_aria_attributes(node, values) {
w(node, 'a11y_aria_attributes', `${`\`<${values.name}>\` should not have aria-* attributes`}\nhttps://svelte.dev/e/${'a11y_aria_attributes'}`);
}
/**
* '%value%' is an invalid value for 'autocomplete' on `<input type="%type%">`
* @param {null | NodeLike} node
* @param {string} value
* @param {string} type
* @param {{ "value": string, "type": string }} values
*/
export function a11y_autocomplete_valid(node, value, type) {
w(node, 'a11y_autocomplete_valid', `'${value}' is an invalid value for 'autocomplete' on \`<input type="${type}">\`\nhttps://svelte.dev/e/a11y_autocomplete_valid`);
export function a11y_autocomplete_valid(node, values) {
w(node, 'a11y_autocomplete_valid', `${`'${values.value}' is an invalid value for 'autocomplete' on \`<input type="${values.type}">\``}\nhttps://svelte.dev/e/${'a11y_autocomplete_valid'}`);
}
/**
* Avoid using autofocus
* @param {null | NodeLike} node
* @param {void} values
*/
export function a11y_autofocus(node) {
w(node, 'a11y_autofocus', `Avoid using autofocus\nhttps://svelte.dev/e/a11y_autofocus`);
export function a11y_autofocus(node, values) {
w(node, 'a11y_autofocus', `${`Avoid using autofocus`}\nhttps://svelte.dev/e/${'a11y_autofocus'}`);
}
/**
* Visible, non-interactive element `<%element%>` with a click event must be accompanied by a keyboard event handler. Consider whether an interactive element such as `<button type="button">` or `<a>` might be more appropriate
* @param {null | NodeLike} node
* @param {string} element
* @param {{ "element": string }} values
*/
export function a11y_click_events_have_key_events(node, element) {
w(node, 'a11y_click_events_have_key_events', `Visible, non-interactive element \`<${element}>\` with a click event must be accompanied by a keyboard event handler. Consider whether an interactive element such as \`<button type="button">\` or \`<a>\` might be more appropriate\nhttps://svelte.dev/e/a11y_click_events_have_key_events`);
export function a11y_click_events_have_key_events(node, values) {
w(node, 'a11y_click_events_have_key_events', `${`Visible, non-interactive element \`<${values.element}>\` with a click event must be accompanied by a keyboard event handler. Consider whether an interactive element such as \`<button type="button">\` or \`<a>\` might be more appropriate`}\nhttps://svelte.dev/e/${'a11y_click_events_have_key_events'}`);
}
/**
* Buttons and links should either contain text or have an `aria-label`, `aria-labelledby` or `title` attribute
* @param {null | NodeLike} node
* @param {void} values
*/
export function a11y_consider_explicit_label(node) {
w(node, 'a11y_consider_explicit_label', `Buttons and links should either contain text or have an \`aria-label\`, \`aria-labelledby\` or \`title\` attribute\nhttps://svelte.dev/e/a11y_consider_explicit_label`);
export function a11y_consider_explicit_label(node, values) {
w(node, 'a11y_consider_explicit_label', `${`Buttons and links should either contain text or have an \`aria-label\`, \`aria-labelledby\` or \`title\` attribute`}\nhttps://svelte.dev/e/${'a11y_consider_explicit_label'}`);
}
/**
* Avoid `<%name%>` elements
* @param {null | NodeLike} node
* @param {string} name
* @param {{ "name": string }} values
*/
export function a11y_distracting_elements(node, name) {
w(node, 'a11y_distracting_elements', `Avoid \`<${name}>\` elements\nhttps://svelte.dev/e/a11y_distracting_elements`);
export function a11y_distracting_elements(node, values) {
w(node, 'a11y_distracting_elements', `${`Avoid \`<${values.name}>\` elements`}\nhttps://svelte.dev/e/${'a11y_distracting_elements'}`);
}
/**
* `<figcaption>` must be first or last child of `<figure>`
* @param {null | NodeLike} node
* @param {void} values
*/
export function a11y_figcaption_index(node) {
w(node, 'a11y_figcaption_index', `\`<figcaption>\` must be first or last child of \`<figure>\`\nhttps://svelte.dev/e/a11y_figcaption_index`);
export function a11y_figcaption_index(node, values) {
w(node, 'a11y_figcaption_index', `${`\`<figcaption>\` must be first or last child of \`<figure>\``}\nhttps://svelte.dev/e/${'a11y_figcaption_index'}`);
}
/**
* `<figcaption>` must be an immediate child of `<figure>`
* @param {null | NodeLike} node
* @param {void} values
*/
export function a11y_figcaption_parent(node) {
w(node, 'a11y_figcaption_parent', `\`<figcaption>\` must be an immediate child of \`<figure>\`\nhttps://svelte.dev/e/a11y_figcaption_parent`);
export function a11y_figcaption_parent(node, values) {
w(node, 'a11y_figcaption_parent', `${`\`<figcaption>\` must be an immediate child of \`<figure>\``}\nhttps://svelte.dev/e/${'a11y_figcaption_parent'}`);
}
/**
* `<%name%>` element should not be hidden
* @param {null | NodeLike} node
* @param {string} name
* @param {{ "name": string }} values
*/
export function a11y_hidden(node, name) {
w(node, 'a11y_hidden', `\`<${name}>\` element should not be hidden\nhttps://svelte.dev/e/a11y_hidden`);
export function a11y_hidden(node, values) {
w(node, 'a11y_hidden', `${`\`<${values.name}>\` element should not be hidden`}\nhttps://svelte.dev/e/${'a11y_hidden'}`);
}
/**
* Screenreaders already announce `<img>` elements as an image
* @param {null | NodeLike} node
* @param {void} values
*/
export function a11y_img_redundant_alt(node) {
w(node, 'a11y_img_redundant_alt', `Screenreaders already announce \`<img>\` elements as an image\nhttps://svelte.dev/e/a11y_img_redundant_alt`);
export function a11y_img_redundant_alt(node, values) {
w(node, 'a11y_img_redundant_alt', `${`Screenreaders already announce \`<img>\` elements as an image`}\nhttps://svelte.dev/e/${'a11y_img_redundant_alt'}`);
}
/**
* The value of '%attribute%' must be a %type%
* @param {null | NodeLike} node
* @param {string} attribute
* @param {string} type
* @param {{ "attribute": string, "type": string }} values
*/
export function a11y_incorrect_aria_attribute_type(node, attribute, type) {
w(node, 'a11y_incorrect_aria_attribute_type', `The value of '${attribute}' must be a ${type}\nhttps://svelte.dev/e/a11y_incorrect_aria_attribute_type`);
export function a11y_incorrect_aria_attribute_type(node, values) {
w(node, 'a11y_incorrect_aria_attribute_type', `${`The value of '${values.attribute}' must be a ${values.type}`}\nhttps://svelte.dev/e/${'a11y_incorrect_aria_attribute_type'}`);
}
/**
* The value of '%attribute%' must be either 'true' or 'false'. It cannot be empty
* @param {null | NodeLike} node
* @param {string} attribute
* @param {{ "attribute": string }} values
*/
export function a11y_incorrect_aria_attribute_type_boolean(node, attribute) {
w(node, 'a11y_incorrect_aria_attribute_type_boolean', `The value of '${attribute}' must be either 'true' or 'false'. It cannot be empty\nhttps://svelte.dev/e/a11y_incorrect_aria_attribute_type_boolean`);
export function a11y_incorrect_aria_attribute_type_boolean(node, values) {
w(node, 'a11y_incorrect_aria_attribute_type_boolean', `${`The value of '${values.attribute}' must be either 'true' or 'false'. It cannot be empty`}\nhttps://svelte.dev/e/${'a11y_incorrect_aria_attribute_type_boolean'}`);
}
/**
* The value of '%attribute%' must be a string that represents a DOM element ID
* @param {null | NodeLike} node
* @param {string} attribute
* @param {{ "attribute": string }} values
*/
export function a11y_incorrect_aria_attribute_type_id(node, attribute) {
w(node, 'a11y_incorrect_aria_attribute_type_id', `The value of '${attribute}' must be a string that represents a DOM element ID\nhttps://svelte.dev/e/a11y_incorrect_aria_attribute_type_id`);
export function a11y_incorrect_aria_attribute_type_id(node, values) {
w(node, 'a11y_incorrect_aria_attribute_type_id', `${`The value of '${values.attribute}' must be a string that represents a DOM element ID`}\nhttps://svelte.dev/e/${'a11y_incorrect_aria_attribute_type_id'}`);
}
/**
* The value of '%attribute%' must be a space-separated list of strings that represent DOM element IDs
* @param {null | NodeLike} node
* @param {string} attribute
* @param {{ "attribute": string }} values
*/
export function a11y_incorrect_aria_attribute_type_idlist(node, attribute) {
w(node, 'a11y_incorrect_aria_attribute_type_idlist', `The value of '${attribute}' must be a space-separated list of strings that represent DOM element IDs\nhttps://svelte.dev/e/a11y_incorrect_aria_attribute_type_idlist`);
export function a11y_incorrect_aria_attribute_type_idlist(node, values) {
w(node, 'a11y_incorrect_aria_attribute_type_idlist', `${`The value of '${values.attribute}' must be a space-separated list of strings that represent DOM element IDs`}\nhttps://svelte.dev/e/${'a11y_incorrect_aria_attribute_type_idlist'}`);
}
/**
* The value of '%attribute%' must be an integer
* @param {null | NodeLike} node
* @param {string} attribute
* @param {{ "attribute": string }} values
*/
export function a11y_incorrect_aria_attribute_type_integer(node, attribute) {
w(node, 'a11y_incorrect_aria_attribute_type_integer', `The value of '${attribute}' must be an integer\nhttps://svelte.dev/e/a11y_incorrect_aria_attribute_type_integer`);
export function a11y_incorrect_aria_attribute_type_integer(node, values) {
w(node, 'a11y_incorrect_aria_attribute_type_integer', `${`The value of '${values.attribute}' must be an integer`}\nhttps://svelte.dev/e/${'a11y_incorrect_aria_attribute_type_integer'}`);
}
/**
* The value of '%attribute%' must be exactly one of %values%
* @param {null | NodeLike} node
* @param {string} attribute
* @param {string} values
* @param {{ "attribute": string, "values": string }} values
*/
export function a11y_incorrect_aria_attribute_type_token(node, attribute, values) {
w(node, 'a11y_incorrect_aria_attribute_type_token', `The value of '${attribute}' must be exactly one of ${values}\nhttps://svelte.dev/e/a11y_incorrect_aria_attribute_type_token`);
export function a11y_incorrect_aria_attribute_type_token(node, values) {
w(node, 'a11y_incorrect_aria_attribute_type_token', `${`The value of '${values.attribute}' must be exactly one of ${values.values}`}\nhttps://svelte.dev/e/${'a11y_incorrect_aria_attribute_type_token'}`);
}
/**
* The value of '%attribute%' must be a space-separated list of one or more of %values%
* @param {null | NodeLike} node
* @param {string} attribute
* @param {string} values
* @param {{ "attribute": string, "values": string }} values
*/
export function a11y_incorrect_aria_attribute_type_tokenlist(node, attribute, values) {
w(node, 'a11y_incorrect_aria_attribute_type_tokenlist', `The value of '${attribute}' must be a space-separated list of one or more of ${values}\nhttps://svelte.dev/e/a11y_incorrect_aria_attribute_type_tokenlist`);
export function a11y_incorrect_aria_attribute_type_tokenlist(node, values) {
w(node, 'a11y_incorrect_aria_attribute_type_tokenlist', `${`The value of '${values.attribute}' must be a space-separated list of one or more of ${values.values}`}\nhttps://svelte.dev/e/${'a11y_incorrect_aria_attribute_type_tokenlist'}`);
}
/**
* The value of '%attribute%' must be exactly one of true, false, or mixed
* @param {null | NodeLike} node
* @param {string} attribute
* @param {{ "attribute": string }} values
*/
export function a11y_incorrect_aria_attribute_type_tristate(node, attribute) {
w(node, 'a11y_incorrect_aria_attribute_type_tristate', `The value of '${attribute}' must be exactly one of true, false, or mixed\nhttps://svelte.dev/e/a11y_incorrect_aria_attribute_type_tristate`);
export function a11y_incorrect_aria_attribute_type_tristate(node, values) {
w(node, 'a11y_incorrect_aria_attribute_type_tristate', `${`The value of '${values.attribute}' must be exactly one of true, false, or mixed`}\nhttps://svelte.dev/e/${'a11y_incorrect_aria_attribute_type_tristate'}`);
}
/**
* Elements with the '%role%' interactive role must have a tabindex value
* @param {null | NodeLike} node
* @param {string} role
* @param {{ "role": string }} values
*/
export function a11y_interactive_supports_focus(node, role) {
w(node, 'a11y_interactive_supports_focus', `Elements with the '${role}' interactive role must have a tabindex value\nhttps://svelte.dev/e/a11y_interactive_supports_focus`);
export function a11y_interactive_supports_focus(node, values) {
w(node, 'a11y_interactive_supports_focus', `${`Elements with the '${values.role}' interactive role must have a tabindex value`}\nhttps://svelte.dev/e/${'a11y_interactive_supports_focus'}`);
}
/**
* '%href_value%' is not a valid %href_attribute% attribute
* @param {null | NodeLike} node
* @param {string} href_value
* @param {string} href_attribute
* @param {{ "href_value": string, "href_attribute": string }} values
*/
export function a11y_invalid_attribute(node, href_value, href_attribute) {
w(node, 'a11y_invalid_attribute', `'${href_value}' is not a valid ${href_attribute} attribute\nhttps://svelte.dev/e/a11y_invalid_attribute`);
export function a11y_invalid_attribute(node, values) {
w(node, 'a11y_invalid_attribute', `${`'${values.href_value}' is not a valid ${values.href_attribute} attribute`}\nhttps://svelte.dev/e/${'a11y_invalid_attribute'}`);
}
/**
* A form label must be associated with a control
* @param {null | NodeLike} node
* @param {void} values
*/
export function a11y_label_has_associated_control(node) {
w(node, 'a11y_label_has_associated_control', `A form label must be associated with a control\nhttps://svelte.dev/e/a11y_label_has_associated_control`);
export function a11y_label_has_associated_control(node, values) {
w(node, 'a11y_label_has_associated_control', `${`A form label must be associated with a control`}\nhttps://svelte.dev/e/${'a11y_label_has_associated_control'}`);
}
/**
* `<video>` elements must have a `<track kind="captions">`
* @param {null | NodeLike} node
* @param {void} values
*/
export function a11y_media_has_caption(node) {
w(node, 'a11y_media_has_caption', `\`<video>\` elements must have a \`<track kind="captions">\`\nhttps://svelte.dev/e/a11y_media_has_caption`);
export function a11y_media_has_caption(node, values) {
w(node, 'a11y_media_has_caption', `${`\`<video>\` elements must have a \`<track kind="captions">\``}\nhttps://svelte.dev/e/${'a11y_media_has_caption'}`);
}
/**
* `<%name%>` should not have role attribute
* @param {null | NodeLike} node
* @param {string} name
* @param {{ "name": string }} values
*/
export function a11y_misplaced_role(node, name) {
w(node, 'a11y_misplaced_role', `\`<${name}>\` should not have role attribute\nhttps://svelte.dev/e/a11y_misplaced_role`);
export function a11y_misplaced_role(node, values) {
w(node, 'a11y_misplaced_role', `${`\`<${values.name}>\` should not have role attribute`}\nhttps://svelte.dev/e/${'a11y_misplaced_role'}`);
}
/**
* The scope attribute should only be used with `<th>` elements
* @param {null | NodeLike} node
* @param {void} values
*/
export function a11y_misplaced_scope(node) {
w(node, 'a11y_misplaced_scope', `The scope attribute should only be used with \`<th>\` elements\nhttps://svelte.dev/e/a11y_misplaced_scope`);
export function a11y_misplaced_scope(node, values) {
w(node, 'a11y_misplaced_scope', `${`The scope attribute should only be used with \`<th>\` elements`}\nhttps://svelte.dev/e/${'a11y_misplaced_scope'}`);
}
/**
* `<%name%>` element should have %article% %sequence% attribute
* @param {null | NodeLike} node
* @param {string} name
* @param {string} article
* @param {string} sequence
* @param {{ "name": string, "article": string, "sequence": string }} values
*/
export function a11y_missing_attribute(node, name, article, sequence) {
w(node, 'a11y_missing_attribute', `\`<${name}>\` element should have ${article} ${sequence} attribute\nhttps://svelte.dev/e/a11y_missing_attribute`);
export function a11y_missing_attribute(node, values) {
w(node, 'a11y_missing_attribute', `${`\`<${values.name}>\` element should have ${values.article} ${values.sequence} attribute`}\nhttps://svelte.dev/e/${'a11y_missing_attribute'}`);
}
/**
* `<%name%>` element should contain text
* @param {null | NodeLike} node
* @param {string} name
* @param {{ "name": string }} values
*/
export function a11y_missing_content(node, name) {
w(node, 'a11y_missing_content', `\`<${name}>\` element should contain text\nhttps://svelte.dev/e/a11y_missing_content`);
export function a11y_missing_content(node, values) {
w(node, 'a11y_missing_content', `${`\`<${values.name}>\` element should contain text`}\nhttps://svelte.dev/e/${'a11y_missing_content'}`);
}
/**
* '%event%' event must be accompanied by '%accompanied_by%' event
* @param {null | NodeLike} node
* @param {string} event
* @param {string} accompanied_by
* @param {{ "event": string, "accompanied_by": string }} values
*/
export function a11y_mouse_events_have_key_events(node, event, accompanied_by) {
w(node, 'a11y_mouse_events_have_key_events', `'${event}' event must be accompanied by '${accompanied_by}' event\nhttps://svelte.dev/e/a11y_mouse_events_have_key_events`);
export function a11y_mouse_events_have_key_events(node, values) {
w(node, 'a11y_mouse_events_have_key_events', `${`'${values.event}' event must be accompanied by '${values.accompanied_by}' event`}\nhttps://svelte.dev/e/${'a11y_mouse_events_have_key_events'}`);
}
/**
* Abstract role '%role%' is forbidden
* @param {null | NodeLike} node
* @param {string} role
* @param {{ "role": string }} values
*/
export function a11y_no_abstract_role(node, role) {
w(node, 'a11y_no_abstract_role', `Abstract role '${role}' is forbidden\nhttps://svelte.dev/e/a11y_no_abstract_role`);
export function a11y_no_abstract_role(node, values) {
w(node, 'a11y_no_abstract_role', `${`Abstract role '${values.role}' is forbidden`}\nhttps://svelte.dev/e/${'a11y_no_abstract_role'}`);
}
/**
* `<%element%>` cannot have role '%role%'
* @param {null | NodeLike} node
* @param {string} element
* @param {string} role
* @param {{ "element": string, "role": string }} values
*/
export function a11y_no_interactive_element_to_noninteractive_role(node, element, role) {
w(node, 'a11y_no_interactive_element_to_noninteractive_role', `\`<${element}>\` cannot have role '${role}'\nhttps://svelte.dev/e/a11y_no_interactive_element_to_noninteractive_role`);
export function a11y_no_interactive_element_to_noninteractive_role(node, values) {
w(node, 'a11y_no_interactive_element_to_noninteractive_role', `${`\`<${values.element}>\` cannot have role '${values.role}'`}\nhttps://svelte.dev/e/${'a11y_no_interactive_element_to_noninteractive_role'}`);
}
/**
* Non-interactive element `<%element%>` should not be assigned mouse or keyboard event listeners
* @param {null | NodeLike} node
* @param {string} element
* @param {{ "element": string }} values
*/
export function a11y_no_noninteractive_element_interactions(node, element) {
w(node, 'a11y_no_noninteractive_element_interactions', `Non-interactive element \`<${element}>\` should not be assigned mouse or keyboard event listeners\nhttps://svelte.dev/e/a11y_no_noninteractive_element_interactions`);
export function a11y_no_noninteractive_element_interactions(node, values) {
w(node, 'a11y_no_noninteractive_element_interactions', `${`Non-interactive element \`<${values.element}>\` should not be assigned mouse or keyboard event listeners`}\nhttps://svelte.dev/e/${'a11y_no_noninteractive_element_interactions'}`);
}
/**
* Non-interactive element `<%element%>` cannot have interactive role '%role%'
* @param {null | NodeLike} node
* @param {string} element
* @param {string} role
* @param {{ "element": string, "role": string }} values
*/
export function a11y_no_noninteractive_element_to_interactive_role(node, element, role) {
w(node, 'a11y_no_noninteractive_element_to_interactive_role', `Non-interactive element \`<${element}>\` cannot have interactive role '${role}'\nhttps://svelte.dev/e/a11y_no_noninteractive_element_to_interactive_role`);
export function a11y_no_noninteractive_element_to_interactive_role(node, values) {
w(node, 'a11y_no_noninteractive_element_to_interactive_role', `${`Non-interactive element \`<${values.element}>\` cannot have interactive role '${values.role}'`}\nhttps://svelte.dev/e/${'a11y_no_noninteractive_element_to_interactive_role'}`);
}
/**
* noninteractive element cannot have nonnegative tabIndex value
* @param {null | NodeLike} node
* @param {void} values
*/
export function a11y_no_noninteractive_tabindex(node) {
w(node, 'a11y_no_noninteractive_tabindex', `noninteractive element cannot have nonnegative tabIndex value\nhttps://svelte.dev/e/a11y_no_noninteractive_tabindex`);
export function a11y_no_noninteractive_tabindex(node, values) {
w(node, 'a11y_no_noninteractive_tabindex', `${`noninteractive element cannot have nonnegative tabIndex value`}\nhttps://svelte.dev/e/${'a11y_no_noninteractive_tabindex'}`);
}
/**
* Redundant role '%role%'
* @param {null | NodeLike} node
* @param {string} role
* @param {{ "role": string }} values
*/
export function a11y_no_redundant_roles(node, role) {
w(node, 'a11y_no_redundant_roles', `Redundant role '${role}'\nhttps://svelte.dev/e/a11y_no_redundant_roles`);
export function a11y_no_redundant_roles(node, values) {
w(node, 'a11y_no_redundant_roles', `${`Redundant role '${values.role}'`}\nhttps://svelte.dev/e/${'a11y_no_redundant_roles'}`);
}
/**
* `<%element%>` with a %handler% handler must have an ARIA role
* @param {null | NodeLike} node
* @param {string} element
* @param {string} handler
* @param {{ "element": string, "handler": string }} values
*/
export function a11y_no_static_element_interactions(node, element, handler) {
w(node, 'a11y_no_static_element_interactions', `\`<${element}>\` with a ${handler} handler must have an ARIA role\nhttps://svelte.dev/e/a11y_no_static_element_interactions`);
export function a11y_no_static_element_interactions(node, values) {
w(node, 'a11y_no_static_element_interactions', `${`\`<${values.element}>\` with a ${values.handler} handler must have an ARIA role`}\nhttps://svelte.dev/e/${'a11y_no_static_element_interactions'}`);
}
/**
* Avoid tabindex values above zero
* @param {null | NodeLike} node
* @param {void} values
*/
export function a11y_positive_tabindex(node) {
w(node, 'a11y_positive_tabindex', `Avoid tabindex values above zero\nhttps://svelte.dev/e/a11y_positive_tabindex`);
export function a11y_positive_tabindex(node, values) {
w(node, 'a11y_positive_tabindex', `${`Avoid tabindex values above zero`}\nhttps://svelte.dev/e/${'a11y_positive_tabindex'}`);
}
/**
* Elements with the ARIA role "%role%" must have the following attributes defined: %props%
* @param {null | NodeLike} node
* @param {string} role
* @param {string} props
* @param {{ "role": string, "props": string }} values
*/
export function a11y_role_has_required_aria_props(node, role, props) {
w(node, 'a11y_role_has_required_aria_props', `Elements with the ARIA role "${role}" must have the following attributes defined: ${props}\nhttps://svelte.dev/e/a11y_role_has_required_aria_props`);
export function a11y_role_has_required_aria_props(node, values) {
w(node, 'a11y_role_has_required_aria_props', `${`Elements with the ARIA role "${values.role}" must have the following attributes defined: ${values.props}`}\nhttps://svelte.dev/e/${'a11y_role_has_required_aria_props'}`);
}
/**
* The attribute '%attribute%' is not supported by the role '%role%'
* @param {null | NodeLike} node
* @param {string} attribute
* @param {string} role
* @param {{ "attribute": string, "role": string }} values
*/
export function a11y_role_supports_aria_props(node, attribute, role) {
w(node, 'a11y_role_supports_aria_props', `The attribute '${attribute}' is not supported by the role '${role}'\nhttps://svelte.dev/e/a11y_role_supports_aria_props`);
export function a11y_role_supports_aria_props(node, values) {
w(node, 'a11y_role_supports_aria_props', `${`The attribute '${values.attribute}' is not supported by the role '${values.role}'`}\nhttps://svelte.dev/e/${'a11y_role_supports_aria_props'}`);
}
/**
* The attribute '%attribute%' is not supported by the role '%role%'. This role is implicit on the element `<%name%>`
* @param {null | NodeLike} node
* @param {string} attribute
* @param {string} role
* @param {string} name
* @param {{ "attribute": string, "role": string, "name": string }} values
*/
export function a11y_role_supports_aria_props_implicit(node, attribute, role, name) {
w(node, 'a11y_role_supports_aria_props_implicit', `The attribute '${attribute}' is not supported by the role '${role}'. This role is implicit on the element \`<${name}>\`\nhttps://svelte.dev/e/a11y_role_supports_aria_props_implicit`);
export function a11y_role_supports_aria_props_implicit(node, values) {
w(node, 'a11y_role_supports_aria_props_implicit', `${`The attribute '${values.attribute}' is not supported by the role '${values.role}'. This role is implicit on the element \`<${values.name}>\``}\nhttps://svelte.dev/e/${'a11y_role_supports_aria_props_implicit'}`);
}
/**
* Unknown aria attribute 'aria-%attribute%'. Did you mean '%suggestion%'?
* Unknown aria attribute 'aria-%attribute%'
* @param {null | NodeLike} node
* @param {string} attribute
* @param {string | undefined | null} [suggestion]
* @param {{ "attribute": string } | { "attribute": string, "suggestion": string }} values
*/
export function a11y_unknown_aria_attribute(node, attribute, suggestion) {
w(node, 'a11y_unknown_aria_attribute', `${suggestion
? `Unknown aria attribute 'aria-${attribute}'. Did you mean '${suggestion}'?`
: `Unknown aria attribute 'aria-${attribute}'`}\nhttps://svelte.dev/e/a11y_unknown_aria_attribute`);
export function a11y_unknown_aria_attribute(node, values) {
w(node, 'a11y_unknown_aria_attribute', `${(values?.suggestion !== undefined ? `Unknown aria attribute 'aria-${values.attribute}'. Did you mean '${values.suggestion}'?` : `Unknown aria attribute 'aria-${values.attribute}'`)}\nhttps://svelte.dev/e/${'a11y_unknown_aria_attribute'}`);
}
/**
* Unknown role '%role%'. Did you mean '%suggestion%'?
* Unknown role '%role%'
* @param {null | NodeLike} node
* @param {string} role
* @param {string | undefined | null} [suggestion]
* @param {{ "role": string } | { "role": string, "suggestion": string }} values
*/
export function a11y_unknown_role(node, role, suggestion) {
w(node, 'a11y_unknown_role', `${suggestion
? `Unknown role '${role}'. Did you mean '${suggestion}'?`
: `Unknown role '${role}'`}\nhttps://svelte.dev/e/a11y_unknown_role`);
export function a11y_unknown_role(node, values) {
w(node, 'a11y_unknown_role', `${(values?.suggestion !== undefined ? `Unknown role '${values.role}'. Did you mean '${values.suggestion}'?` : `Unknown role '${values.role}'`)}\nhttps://svelte.dev/e/${'a11y_unknown_role'}`);
}
/**
* A bidirectional control character was detected in your code. These characters can be used to alter the visual direction of your code and could have unintended consequences
* @param {null | NodeLike} node
* @param {void} values
*/
export function bidirectional_control_characters(node) {
w(node, 'bidirectional_control_characters', `A bidirectional control character was detected in your code. These characters can be used to alter the visual direction of your code and could have unintended consequences\nhttps://svelte.dev/e/bidirectional_control_characters`);
export function bidirectional_control_characters(node, values) {
w(node, 'bidirectional_control_characters', `${`A bidirectional control character was detected in your code. These characters can be used to alter the visual direction of your code and could have unintended consequences`}\nhttps://svelte.dev/e/${'bidirectional_control_characters'}`);
}
/**
* `%code%` is no longer valid please use `%suggestion%` instead
* @param {null | NodeLike} node
* @param {string} code
* @param {string} suggestion
* @param {{ "code": string, "suggestion": string }} values
*/
export function legacy_code(node, code, suggestion) {
w(node, 'legacy_code', `\`${code}\` is no longer valid — please use \`${suggestion}\` instead\nhttps://svelte.dev/e/legacy_code`);
export function legacy_code(node, values) {
w(node, 'legacy_code', `${`\`${values.code}\` is no longer valid — please use \`${values.suggestion}\` instead`}\nhttps://svelte.dev/e/${'legacy_code'}`);
}
/**
* `%code%` is not a recognised code (did you mean `%suggestion%`?)
* `%code%` is not a recognised code
* @param {null | NodeLike} node
* @param {string} code
* @param {string | undefined | null} [suggestion]
* @param {{ "code": string } | { "code": string, "suggestion": string }} values
*/
export function unknown_code(node, code, suggestion) {
w(node, 'unknown_code', `${suggestion
? `\`${code}\` is not a recognised code (did you mean \`${suggestion}\`?)`
: `\`${code}\` is not a recognised code`}\nhttps://svelte.dev/e/unknown_code`);
export function unknown_code(node, values) {
w(node, 'unknown_code', `${(values?.suggestion !== undefined ? `\`${values.code}\` is not a recognised code (did you mean \`${values.suggestion}\`?)` : `\`${values.code}\` is not a recognised code`)}\nhttps://svelte.dev/e/${'unknown_code'}`);
}
/**
* The `accessors` option has been deprecated. It will have no effect in runes mode
* @param {null | NodeLike} node
* @param {void} values
*/
export function options_deprecated_accessors(node) {
w(node, 'options_deprecated_accessors', `The \`accessors\` option has been deprecated. It will have no effect in runes mode\nhttps://svelte.dev/e/options_deprecated_accessors`);
export function options_deprecated_accessors(node, values) {
w(node, 'options_deprecated_accessors', `${`The \`accessors\` option has been deprecated. It will have no effect in runes mode`}\nhttps://svelte.dev/e/${'options_deprecated_accessors'}`);
}
/**
* The `immutable` option has been deprecated. It will have no effect in runes mode
* @param {null | NodeLike} node
* @param {void} values
*/
export function options_deprecated_immutable(node) {
w(node, 'options_deprecated_immutable', `The \`immutable\` option has been deprecated. It will have no effect in runes mode\nhttps://svelte.dev/e/options_deprecated_immutable`);
export function options_deprecated_immutable(node, values) {
w(node, 'options_deprecated_immutable', `${`The \`immutable\` option has been deprecated. It will have no effect in runes mode`}\nhttps://svelte.dev/e/${'options_deprecated_immutable'}`);
}
/**
* The `customElement` option is used when generating a custom element. Did you forget the `customElement: true` compile option?
* @param {null | NodeLike} node
* @param {void} values
*/
export function options_missing_custom_element(node) {
w(node, 'options_missing_custom_element', `The \`customElement\` option is used when generating a custom element. Did you forget the \`customElement: true\` compile option?\nhttps://svelte.dev/e/options_missing_custom_element`);
export function options_missing_custom_element(node, values) {
w(node, 'options_missing_custom_element', `${`The \`customElement\` option is used when generating a custom element. Did you forget the \`customElement: true\` compile option?`}\nhttps://svelte.dev/e/${'options_missing_custom_element'}`);
}
/**
* The `enableSourcemap` option has been removed. Source maps are always generated now, and tooling can choose to ignore them
* @param {null | NodeLike} node
* @param {void} values
*/
export function options_removed_enable_sourcemap(node) {
w(node, 'options_removed_enable_sourcemap', `The \`enableSourcemap\` option has been removed. Source maps are always generated now, and tooling can choose to ignore them\nhttps://svelte.dev/e/options_removed_enable_sourcemap`);
export function options_removed_enable_sourcemap(node, values) {
w(node, 'options_removed_enable_sourcemap', `${`The \`enableSourcemap\` option has been removed. Source maps are always generated now, and tooling can choose to ignore them`}\nhttps://svelte.dev/e/${'options_removed_enable_sourcemap'}`);
}
/**
* The `hydratable` option has been removed. Svelte components are always hydratable now
* @param {null | NodeLike} node
* @param {void} values
*/
export function options_removed_hydratable(node) {
w(node, 'options_removed_hydratable', `The \`hydratable\` option has been removed. Svelte components are always hydratable now\nhttps://svelte.dev/e/options_removed_hydratable`);
export function options_removed_hydratable(node, values) {
w(node, 'options_removed_hydratable', `${`The \`hydratable\` option has been removed. Svelte components are always hydratable now`}\nhttps://svelte.dev/e/${'options_removed_hydratable'}`);
}
/**
* The `loopGuardTimeout` option has been removed
* @param {null | NodeLike} node
* @param {void} values
*/
export function options_removed_loop_guard_timeout(node) {
w(node, 'options_removed_loop_guard_timeout', `The \`loopGuardTimeout\` option has been removed\nhttps://svelte.dev/e/options_removed_loop_guard_timeout`);
export function options_removed_loop_guard_timeout(node, values) {
w(node, 'options_removed_loop_guard_timeout', `${`The \`loopGuardTimeout\` option has been removed`}\nhttps://svelte.dev/e/${'options_removed_loop_guard_timeout'}`);
}
/**
* `generate: "dom"` and `generate: "ssr"` options have been renamed to "client" and "server" respectively
* @param {null | NodeLike} node
* @param {void} values
*/
export function options_renamed_ssr_dom(node) {
w(node, 'options_renamed_ssr_dom', `\`generate: "dom"\` and \`generate: "ssr"\` options have been renamed to "client" and "server" respectively\nhttps://svelte.dev/e/options_renamed_ssr_dom`);
export function options_renamed_ssr_dom(node, values) {
w(node, 'options_renamed_ssr_dom', `${`\`generate: "dom"\` and \`generate: "ssr"\` options have been renamed to "client" and "server" respectively`}\nhttps://svelte.dev/e/${'options_renamed_ssr_dom'}`);
}
/**
* Using a rest element or a non-destructured declaration with `$props()` means that Svelte can't infer what properties to expose when creating a custom element. Consider destructuring all the props or explicitly specifying the `customElement.props` option.
* @param {null | NodeLike} node
* @param {void} values
*/
export function custom_element_props_identifier(node) {
w(node, 'custom_element_props_identifier', `Using a rest element or a non-destructured declaration with \`$props()\` means that Svelte can't infer what properties to expose when creating a custom element. Consider destructuring all the props or explicitly specifying the \`customElement.props\` option.\nhttps://svelte.dev/e/custom_element_props_identifier`);
export function custom_element_props_identifier(node, values) {
w(node, 'custom_element_props_identifier', `${`Using a rest element or a non-destructured declaration with \`$props()\` means that Svelte can't infer what properties to expose when creating a custom element. Consider destructuring all the props or explicitly specifying the \`customElement.props\` option.`}\nhttps://svelte.dev/e/${'custom_element_props_identifier'}`);
}
/**
* Component has unused export property '%name%'. If it is for external reference only, please consider using `export const %name%`
* @param {null | NodeLike} node
* @param {string} name
* @param {{ "name": string }} values
*/
export function export_let_unused(node, name) {
w(node, 'export_let_unused', `Component has unused export property '${name}'. If it is for external reference only, please consider using \`export const ${name}\`\nhttps://svelte.dev/e/export_let_unused`);
export function export_let_unused(node, values) {
w(node, 'export_let_unused', `${`Component has unused export property '${values.name}'. If it is for external reference only, please consider using \`export const ${values.name}\``}\nhttps://svelte.dev/e/${'export_let_unused'}`);
}
/**
* Svelte 5 components are no longer classes. Instantiate them using `mount` or `hydrate` (imported from 'svelte') instead.
* @param {null | NodeLike} node
* @param {void} values
*/
export function legacy_component_creation(node) {
w(node, 'legacy_component_creation', `Svelte 5 components are no longer classes. Instantiate them using \`mount\` or \`hydrate\` (imported from 'svelte') instead.\nhttps://svelte.dev/e/legacy_component_creation`);
export function legacy_component_creation(node, values) {
w(node, 'legacy_component_creation', `${`Svelte 5 components are no longer classes. Instantiate them using \`mount\` or \`hydrate\` (imported from 'svelte') instead.`}\nhttps://svelte.dev/e/${'legacy_component_creation'}`);
}
/**
* `%name%` is updated, but is not declared with `$state(...)`. Changing its value will not correctly trigger updates
* @param {null | NodeLike} node
* @param {string} name
* @param {{ "name": string }} values
*/
export function non_reactive_update(node, name) {
w(node, 'non_reactive_update', `\`${name}\` is updated, but is not declared with \`$state(...)\`. Changing its value will not correctly trigger updates\nhttps://svelte.dev/e/non_reactive_update`);
export function non_reactive_update(node, values) {
w(node, 'non_reactive_update', `${`\`${values.name}\` is updated, but is not declared with \`$state(...)\`. Changing its value will not correctly trigger updates`}\nhttps://svelte.dev/e/${'non_reactive_update'}`);
}
/**
* Avoid 'new class' instead, declare the class at the top level scope
* @param {null | NodeLike} node
* @param {void} values
*/
export function perf_avoid_inline_class(node) {
w(node, 'perf_avoid_inline_class', `Avoid 'new class' — instead, declare the class at the top level scope\nhttps://svelte.dev/e/perf_avoid_inline_class`);
export function perf_avoid_inline_class(node, values) {
w(node, 'perf_avoid_inline_class', `${`Avoid 'new class' — instead, declare the class at the top level scope`}\nhttps://svelte.dev/e/${'perf_avoid_inline_class'}`);
}
/**
* Avoid declaring classes below the top level scope
* @param {null | NodeLike} node
* @param {void} values
*/
export function perf_avoid_nested_class(node) {
w(node, 'perf_avoid_nested_class', `Avoid declaring classes below the top level scope\nhttps://svelte.dev/e/perf_avoid_nested_class`);
export function perf_avoid_nested_class(node, values) {
w(node, 'perf_avoid_nested_class', `${`Avoid declaring classes below the top level scope`}\nhttps://svelte.dev/e/${'perf_avoid_nested_class'}`);
}
/**
* Reactive declarations only exist at the top level of the instance script
* @param {null | NodeLike} node
* @param {void} values
*/
export function reactive_declaration_invalid_placement(node) {
w(node, 'reactive_declaration_invalid_placement', `Reactive declarations only exist at the top level of the instance script\nhttps://svelte.dev/e/reactive_declaration_invalid_placement`);
export function reactive_declaration_invalid_placement(node, values) {
w(node, 'reactive_declaration_invalid_placement', `${`Reactive declarations only exist at the top level of the instance script`}\nhttps://svelte.dev/e/${'reactive_declaration_invalid_placement'}`);
}
/**
* Reassignments of module-level declarations will not cause reactive statements to update
* @param {null | NodeLike} node
* @param {void} values
*/
export function reactive_declaration_module_script_dependency(node) {
w(node, 'reactive_declaration_module_script_dependency', `Reassignments of module-level declarations will not cause reactive statements to update\nhttps://svelte.dev/e/reactive_declaration_module_script_dependency`);
export function reactive_declaration_module_script_dependency(node, values) {
w(node, 'reactive_declaration_module_script_dependency', `${`Reassignments of module-level declarations will not cause reactive statements to update`}\nhttps://svelte.dev/e/${'reactive_declaration_module_script_dependency'}`);
}
/**
* This reference only captures the initial value of `%name%`. Did you mean to reference it inside a %type% instead?
* @param {null | NodeLike} node
* @param {string} name
* @param {string} type
* @param {{ "name": string, "type": string }} values
*/
export function state_referenced_locally(node, name, type) {
w(node, 'state_referenced_locally', `This reference only captures the initial value of \`${name}\`. Did you mean to reference it inside a ${type} instead?\nhttps://svelte.dev/e/state_referenced_locally`);
export function state_referenced_locally(node, values) {
w(node, 'state_referenced_locally', `${`This reference only captures the initial value of \`${values.name}\`. Did you mean to reference it inside a ${values.type} instead?`}\nhttps://svelte.dev/e/${'state_referenced_locally'}`);
}
/**
* It looks like you're using the `$%name%` rune, but there is a local binding called `%name%`. Referencing a local variable with a `$` prefix will create a store subscription. Please rename `%name%` to avoid the ambiguity
* @param {null | NodeLike} node
* @param {string} name
* @param {{ "name": string }} values
*/
export function store_rune_conflict(node, name) {
w(node, 'store_rune_conflict', `It looks like you're using the \`$${name}\` rune, but there is a local binding called \`${name}\`. Referencing a local variable with a \`$\` prefix will create a store subscription. Please rename \`${name}\` to avoid the ambiguity\nhttps://svelte.dev/e/store_rune_conflict`);
export function store_rune_conflict(node, values) {
w(node, 'store_rune_conflict', `${`It looks like you're using the \`$${values.name}\` rune, but there is a local binding called \`${values.name}\`. Referencing a local variable with a \`$\` prefix will create a store subscription. Please rename \`${values.name}\` to avoid the ambiguity`}\nhttps://svelte.dev/e/${'store_rune_conflict'}`);
}
/**
* Unused CSS selector "%name%"
* @param {null | NodeLike} node
* @param {string} name
* @param {{ "name": string }} values
*/
export function css_unused_selector(node, name) {
w(node, 'css_unused_selector', `Unused CSS selector "${name}"\nhttps://svelte.dev/e/css_unused_selector`);
export function css_unused_selector(node, values) {
w(node, 'css_unused_selector', `${`Unused CSS selector "${values.name}"`}\nhttps://svelte.dev/e/${'css_unused_selector'}`);
}
/**
* The "is" attribute is not supported cross-browser and should be avoided
* @param {null | NodeLike} node
* @param {void} values
*/
export function attribute_avoid_is(node) {
w(node, 'attribute_avoid_is', `The "is" attribute is not supported cross-browser and should be avoided\nhttps://svelte.dev/e/attribute_avoid_is`);
export function attribute_avoid_is(node, values) {
w(node, 'attribute_avoid_is', `${`The "is" attribute is not supported cross-browser and should be avoided`}\nhttps://svelte.dev/e/${'attribute_avoid_is'}`);
}
/**
* You are referencing `globalThis.%name%`. Did you forget to declare a variable with that name?
* @param {null | NodeLike} node
* @param {string} name
* @param {{ "name": string }} values
*/
export function attribute_global_event_reference(node, name) {
w(node, 'attribute_global_event_reference', `You are referencing \`globalThis.${name}\`. Did you forget to declare a variable with that name?\nhttps://svelte.dev/e/attribute_global_event_reference`);
export function attribute_global_event_reference(node, values) {
w(node, 'attribute_global_event_reference', `${`You are referencing \`globalThis.${values.name}\`. Did you forget to declare a variable with that name?`}\nhttps://svelte.dev/e/${'attribute_global_event_reference'}`);
}
/**
* Attributes should not contain ':' characters to prevent ambiguity with Svelte directives
* @param {null | NodeLike} node
* @param {void} values
*/
export function attribute_illegal_colon(node) {
w(node, 'attribute_illegal_colon', `Attributes should not contain ':' characters to prevent ambiguity with Svelte directives\nhttps://svelte.dev/e/attribute_illegal_colon`);
export function attribute_illegal_colon(node, values) {
w(node, 'attribute_illegal_colon', `${`Attributes should not contain ':' characters to prevent ambiguity with Svelte directives`}\nhttps://svelte.dev/e/${'attribute_illegal_colon'}`);
}
/**
* '%wrong%' is not a valid HTML attribute. Did you mean '%right%'?
* @param {null | NodeLike} node
* @param {string} wrong
* @param {string} right
* @param {{ "wrong": string, "right": string }} values
*/
export function attribute_invalid_property_name(node, wrong, right) {
w(node, 'attribute_invalid_property_name', `'${wrong}' is not a valid HTML attribute. Did you mean '${right}'?\nhttps://svelte.dev/e/attribute_invalid_property_name`);
export function attribute_invalid_property_name(node, values) {
w(node, 'attribute_invalid_property_name', `${`'${values.wrong}' is not a valid HTML attribute. Did you mean '${values.right}'?`}\nhttps://svelte.dev/e/${'attribute_invalid_property_name'}`);
}
/**
* Quoted attributes on components and custom elements will be stringified in a future version of Svelte. If this isn't what you want, remove the quotes
* @param {null | NodeLike} node
* @param {void} values
*/
export function attribute_quoted(node) {
w(node, 'attribute_quoted', `Quoted attributes on components and custom elements will be stringified in a future version of Svelte. If this isn't what you want, remove the quotes\nhttps://svelte.dev/e/attribute_quoted`);
export function attribute_quoted(node, values) {
w(node, 'attribute_quoted', `${`Quoted attributes on components and custom elements will be stringified in a future version of Svelte. If this isn't what you want, remove the quotes`}\nhttps://svelte.dev/e/${'attribute_quoted'}`);
}
/**
* The rest operator (...) will create a new object and binding '%name%' with the original object will not work
* @param {null | NodeLike} node
* @param {string} name
* @param {{ "name": string }} values
*/
export function bind_invalid_each_rest(node, name) {
w(node, 'bind_invalid_each_rest', `The rest operator (...) will create a new object and binding '${name}' with the original object will not work\nhttps://svelte.dev/e/bind_invalid_each_rest`);
export function bind_invalid_each_rest(node, values) {
w(node, 'bind_invalid_each_rest', `${`The rest operator (...) will create a new object and binding '${values.name}' with the original object will not work`}\nhttps://svelte.dev/e/${'bind_invalid_each_rest'}`);
}
/**
* Empty block
* @param {null | NodeLike} node
* @param {void} values
*/
export function block_empty(node) {
w(node, 'block_empty', `Empty block\nhttps://svelte.dev/e/block_empty`);
export function block_empty(node, values) {
w(node, 'block_empty', `${`Empty block`}\nhttps://svelte.dev/e/${'block_empty'}`);
}
/**
* `<%name%>` will be treated as an HTML element unless it begins with a capital letter
* @param {null | NodeLike} node
* @param {string} name
* @param {{ "name": string }} values
*/
export function component_name_lowercase(node, name) {
w(node, 'component_name_lowercase', `\`<${name}>\` will be treated as an HTML element unless it begins with a capital letter\nhttps://svelte.dev/e/component_name_lowercase`);
export function component_name_lowercase(node, values) {
w(node, 'component_name_lowercase', `${`\`<${values.name}>\` will be treated as an HTML element unless it begins with a capital letter`}\nhttps://svelte.dev/e/${'component_name_lowercase'}`);
}
/**
* This element is implicitly closed by the following `%tag%`, which can cause an unexpected DOM structure. Add an explicit `%closing%` to avoid surprises.
* @param {null | NodeLike} node
* @param {string} tag
* @param {string} closing
* @param {{ "tag": string, "closing": string }} values
*/
export function element_implicitly_closed(node, tag, closing) {
w(node, 'element_implicitly_closed', `This element is implicitly closed by the following \`${tag}\`, which can cause an unexpected DOM structure. Add an explicit \`${closing}\` to avoid surprises.\nhttps://svelte.dev/e/element_implicitly_closed`);
export function element_implicitly_closed(node, values) {
w(node, 'element_implicitly_closed', `${`This element is implicitly closed by the following \`${values.tag}\`, which can cause an unexpected DOM structure. Add an explicit \`${values.closing}\` to avoid surprises.`}\nhttps://svelte.dev/e/${'element_implicitly_closed'}`);
}
/**
* Self-closing HTML tags for non-void elements are ambiguous use `<%name% ...></%name%>` rather than `<%name% ... />`
* @param {null | NodeLike} node
* @param {string} name
* @param {{ "name": string }} values
*/
export function element_invalid_self_closing_tag(node, name) {
w(node, 'element_invalid_self_closing_tag', `Self-closing HTML tags for non-void elements are ambiguous — use \`<${name} ...></${name}>\` rather than \`<${name} ... />\`\nhttps://svelte.dev/e/element_invalid_self_closing_tag`);
export function element_invalid_self_closing_tag(node, values) {
w(node, 'element_invalid_self_closing_tag', `${`Self-closing HTML tags for non-void elements are ambiguous — use \`<${values.name} ...></${values.name}>\` rather than \`<${values.name} ... />\``}\nhttps://svelte.dev/e/${'element_invalid_self_closing_tag'}`);
}
/**
* Using `on:%name%` to listen to the %name% event is deprecated. Use the event attribute `on%name%` instead
* @param {null | NodeLike} node
* @param {string} name
* @param {{ "name": string }} values
*/
export function event_directive_deprecated(node, name) {
w(node, 'event_directive_deprecated', `Using \`on:${name}\` to listen to the ${name} event is deprecated. Use the event attribute \`on${name}\` instead\nhttps://svelte.dev/e/event_directive_deprecated`);
export function event_directive_deprecated(node, values) {
w(node, 'event_directive_deprecated', `${`Using \`on:${values.name}\` to listen to the ${values.name} event is deprecated. Use the event attribute \`on${values.name}\` instead`}\nhttps://svelte.dev/e/${'event_directive_deprecated'}`);
}
/**
* %message%. When rendering this component on the server, the resulting HTML will be modified by the browser (by moving, removing, or inserting elements), likely resulting in a `hydration_mismatch` warning
* @param {null | NodeLike} node
* @param {string} message
* @param {{ "message": string }} values
*/
export function node_invalid_placement_ssr(node, message) {
w(node, 'node_invalid_placement_ssr', `${message}. When rendering this component on the server, the resulting HTML will be modified by the browser (by moving, removing, or inserting elements), likely resulting in a \`hydration_mismatch\` warning\nhttps://svelte.dev/e/node_invalid_placement_ssr`);
export function node_invalid_placement_ssr(node, values) {
w(node, 'node_invalid_placement_ssr', `${`${values.message}. When rendering this component on the server, the resulting HTML will be modified by the browser (by moving, removing, or inserting elements), likely resulting in a \`hydration_mismatch\` warning`}\nhttps://svelte.dev/e/${'node_invalid_placement_ssr'}`);
}
/**
* `context="module"` is deprecated, use the `module` attribute instead
* @param {null | NodeLike} node
* @param {void} values
*/
export function script_context_deprecated(node) {
w(node, 'script_context_deprecated', `\`context="module"\` is deprecated, use the \`module\` attribute instead\nhttps://svelte.dev/e/script_context_deprecated`);
export function script_context_deprecated(node, values) {
w(node, 'script_context_deprecated', `${`\`context="module"\` is deprecated, use the \`module\` attribute instead`}\nhttps://svelte.dev/e/${'script_context_deprecated'}`);
}
/**
* Unrecognised attribute should be one of `generics`, `lang` or `module`. If this exists for a preprocessor, ensure that the preprocessor removes it
* @param {null | NodeLike} node
* @param {void} values
*/
export function script_unknown_attribute(node) {
w(node, 'script_unknown_attribute', `Unrecognised attribute — should be one of \`generics\`, \`lang\` or \`module\`. If this exists for a preprocessor, ensure that the preprocessor removes it\nhttps://svelte.dev/e/script_unknown_attribute`);
export function script_unknown_attribute(node, values) {
w(node, 'script_unknown_attribute', `${`Unrecognised attribute — should be one of \`generics\`, \`lang\` or \`module\`. If this exists for a preprocessor, ensure that the preprocessor removes it`}\nhttps://svelte.dev/e/${'script_unknown_attribute'}`);
}
/**
* Using `<slot>` to render parent content is deprecated. Use `{@render ...}` tags instead
* @param {null | NodeLike} node
* @param {void} values
*/
export function slot_element_deprecated(node) {
w(node, 'slot_element_deprecated', `Using \`<slot>\` to render parent content is deprecated. Use \`{@render ...}\` tags instead\nhttps://svelte.dev/e/slot_element_deprecated`);
export function slot_element_deprecated(node, values) {
w(node, 'slot_element_deprecated', `${`Using \`<slot>\` to render parent content is deprecated. Use \`{@render ...}\` tags instead`}\nhttps://svelte.dev/e/${'slot_element_deprecated'}`);
}
/**
* `<svelte:component>` is deprecated in runes mode components are dynamic by default
* @param {null | NodeLike} node
* @param {void} values
*/
export function svelte_component_deprecated(node) {
w(node, 'svelte_component_deprecated', `\`<svelte:component>\` is deprecated in runes mode — components are dynamic by default\nhttps://svelte.dev/e/svelte_component_deprecated`);
export function svelte_component_deprecated(node, values) {
w(node, 'svelte_component_deprecated', `${`\`<svelte:component>\` is deprecated in runes mode — components are dynamic by default`}\nhttps://svelte.dev/e/${'svelte_component_deprecated'}`);
}
/**
* `this` should be an `{expression}`. Using a string attribute value will cause an error in future versions of Svelte
* @param {null | NodeLike} node
* @param {void} values
*/
export function svelte_element_invalid_this(node) {
w(node, 'svelte_element_invalid_this', `\`this\` should be an \`{expression}\`. Using a string attribute value will cause an error in future versions of Svelte\nhttps://svelte.dev/e/svelte_element_invalid_this`);
export function svelte_element_invalid_this(node, values) {
w(node, 'svelte_element_invalid_this', `${`\`this\` should be an \`{expression}\`. Using a string attribute value will cause an error in future versions of Svelte`}\nhttps://svelte.dev/e/${'svelte_element_invalid_this'}`);
}
/**
* `<svelte:self>` is deprecated use self-imports (e.g. `import %name% from './%basename%'`) instead
* @param {null | NodeLike} node
* @param {string} name
* @param {string} basename
* @param {{ "name": string, "basename": string }} values
*/
export function svelte_self_deprecated(node, name, basename) {
w(node, 'svelte_self_deprecated', `\`<svelte:self>\` is deprecated — use self-imports (e.g. \`import ${name} from './${basename}'\`) instead\nhttps://svelte.dev/e/svelte_self_deprecated`);
}
export function svelte_self_deprecated(node, values) {
w(node, 'svelte_self_deprecated', `${`\`<svelte:self>\` is deprecated — use self-imports (e.g. \`import ${values.name} from './${values.basename}'\`) instead`}\nhttps://svelte.dev/e/${'svelte_self_deprecated'}`);
}

@ -26,7 +26,7 @@ if (DEV) {
return value;
}
e.rune_outside_svelte(rune);
e.rune_outside_svelte({ rune });
},
set: (v) => {
value = v;
@ -90,7 +90,7 @@ export function getAbortSignal() {
*/
export function onMount(fn) {
if (component_context === null) {
e.lifecycle_outside_component('onMount');
e.lifecycle_outside_component({ name: 'onMount' });
}
if (legacy_mode_flag && component_context.l !== null) {
@ -114,7 +114,7 @@ export function onMount(fn) {
*/
export function onDestroy(fn) {
if (component_context === null) {
e.lifecycle_outside_component('onDestroy');
e.lifecycle_outside_component({ name: 'onDestroy' });
}
onMount(() => () => untrack(fn));
@ -157,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) {
e.lifecycle_outside_component('createEventDispatcher');
e.lifecycle_outside_component({ name: 'createEventDispatcher' });
}
/**
@ -199,11 +199,11 @@ export function createEventDispatcher() {
*/
export function beforeUpdate(fn) {
if (component_context === null) {
e.lifecycle_outside_component('beforeUpdate');
e.lifecycle_outside_component({ name: 'beforeUpdate' });
}
if (component_context.l === null) {
e.lifecycle_legacy_only('beforeUpdate');
e.lifecycle_legacy_only({ name: 'beforeUpdate' });
}
init_update_callbacks(component_context).b.push(fn);
@ -222,11 +222,11 @@ export function beforeUpdate(fn) {
*/
export function afterUpdate(fn) {
if (component_context === null) {
e.lifecycle_outside_component('afterUpdate');
e.lifecycle_outside_component({ name: 'afterUpdate' });
}
if (component_context.l === null) {
e.lifecycle_legacy_only('afterUpdate');
e.lifecycle_legacy_only({ name: 'afterUpdate' });
}
init_update_callbacks(component_context).a.push(fn);

@ -22,19 +22,19 @@ export function createEventDispatcher() {
}
export function mount() {
e.lifecycle_function_unavailable('mount');
e.lifecycle_function_unavailable({ name: 'mount' });
}
export function hydrate() {
e.lifecycle_function_unavailable('hydrate');
e.lifecycle_function_unavailable({ name: 'hydrate' });
}
export function unmount() {
e.lifecycle_function_unavailable('unmount');
e.lifecycle_function_unavailable({ name: 'unmount' });
}
export function fork() {
e.lifecycle_function_unavailable('fork');
e.lifecycle_function_unavailable({ name: 'fork' });
}
export async function tick() {}

@ -12,7 +12,10 @@ import * as w from '../warnings.js';
*/
function compare(a, b, property, location) {
if (a !== b && typeof b === 'object' && STATE_SYMBOL in b) {
w.assignment_value_stale(property, /** @type {string} */ (sanitize_location(location)));
w.assignment_value_stale({
property,
location: /** @type {string} */ (sanitize_location(location))
});
}
return a;

@ -23,7 +23,7 @@ export function log_if_contains_state(method, ...objects) {
}
if (has_state) {
w.console_log_state(method);
w.console_log_state({ method });
// eslint-disable-next-line no-console
console.log('%c[snapshot]', 'color: grey', ...transformed);

@ -19,7 +19,7 @@ export function init_array_prototype_warnings() {
if (index === -1) {
for (let i = from_index ?? 0; i < this.length; i += 1) {
if (get_proxied_value(this[i]) === item) {
w.state_proxy_equality_mismatch('array.indexOf(...)');
w.state_proxy_equality_mismatch({ operator: 'array.indexOf(...)' });
break;
}
}
@ -36,7 +36,7 @@ export function init_array_prototype_warnings() {
if (index === -1) {
for (let i = 0; i <= (from_index ?? this.length - 1); i += 1) {
if (get_proxied_value(this[i]) === item) {
w.state_proxy_equality_mismatch('array.lastIndexOf(...)');
w.state_proxy_equality_mismatch({ operator: 'array.lastIndexOf(...)' });
break;
}
}
@ -51,7 +51,7 @@ export function init_array_prototype_warnings() {
if (!has) {
for (let i = 0; i < this.length; i += 1) {
if (get_proxied_value(this[i]) === item) {
w.state_proxy_equality_mismatch('array.includes(...)');
w.state_proxy_equality_mismatch({ operator: 'array.includes(...)' });
break;
}
}
@ -79,7 +79,7 @@ export function strict_equals(a, b, equal = true) {
// which could be disallowed for example in a secure context
try {
if ((a === b) !== (get_proxied_value(a) === get_proxied_value(b))) {
w.state_proxy_equality_mismatch(equal ? '===' : '!==');
w.state_proxy_equality_mismatch({ operator: equal ? '===' : '!==' });
}
} catch {}
@ -94,7 +94,7 @@ export function strict_equals(a, b, equal = true) {
*/
export function equals(a, b, equal = true) {
if ((a == b) !== (get_proxied_value(a) == get_proxied_value(b))) {
w.state_proxy_equality_mismatch(equal ? '==' : '!=');
w.state_proxy_equality_mismatch({ operator: equal ? '==' : '!=' });
}
return (a == b) === equal;

@ -5,7 +5,10 @@ import { FILENAME } from '../../../constants.js';
/** @param {Function & { [FILENAME]: string }} target */
export function check_target(target) {
if (target) {
e.component_api_invalid_new(target[FILENAME] ?? 'a component', target.name);
e.component_api_invalid_new({
component: target[FILENAME] ?? 'a component',
name: target.name
});
}
}
@ -14,7 +17,7 @@ export function legacy_api() {
/** @param {string} method */
function error(method) {
e.component_api_changed(method, component[FILENAME]);
e.component_api_changed({ method, component: component[FILENAME] });
}
return {

@ -43,7 +43,7 @@ export function create_ownership_validator(props) {
const location = sanitize_location(`${component[FILENAME]}:${line}:${column}`);
w.ownership_invalid_mutation(name, location, prop, parent[FILENAME]);
w.ownership_invalid_mutation({ name, location, prop, parent: parent[FILENAME] });
return result;
},
@ -54,12 +54,12 @@ export function create_ownership_validator(props) {
*/
binding: (key, child_component, value) => {
if (!is_bound_or_unset(props, key) && parent && value()?.[STATE_SYMBOL]) {
w.ownership_invalid_binding(
component[FILENAME],
key,
child_component[FILENAME],
parent[FILENAME]
);
w.ownership_invalid_binding({
parent: component[FILENAME],
prop: key,
child: child_component[FILENAME],
owner: parent[FILENAME]
});
}
}
};

@ -307,7 +307,7 @@ export function each(node, flags, get_collection, get_key, render_fn, fallback_f
// Check that the key function is idempotent (returns the same value when called twice)
var key_again = get_key(value, index);
if (key !== key_again) {
e.each_key_volatile(String(index), String(key), String(key_again));
e.each_key_volatile({ index: String(index), a: String(key), b: String(key_again) });
}
}
@ -357,7 +357,7 @@ export function each(node, flags, get_collection, get_key, render_fn, fallback_f
validate_each_keys(array, get_key);
} else {
// in prod, the additional information isn't printed, so don't bother computing it
e.each_key_duplicate('', '', '');
e.each_key_duplicate({ a: '', b: '', value: '' });
}
}
@ -768,7 +768,7 @@ function validate_each_keys(array, key_fn) {
let k = String(key);
if (k.startsWith('[object ')) k = null;
e.each_key_duplicate(a, b, k);
e.each_key_duplicate(k === null ? { a, b } : { a, b, value: k });
}
keys.set(key, i);

@ -36,7 +36,8 @@ function check_hash(element, server_hash, value) {
location = `in ${dev_current_component_function[FILENAME]}`;
}
w.hydration_html_changed(sanitize_location(location));
const sanitized = sanitize_location(location);
w.hydration_html_changed(sanitized === undefined ? undefined : { location: sanitized });
}
/**

@ -630,11 +630,11 @@ function check_src_in_dev_hydration(element, attribute, value) {
if (attribute === 'srcset' && srcset_url_equal(element, value)) return;
if (src_url_equal(element.getAttribute(attribute) ?? '', value)) return;
w.hydration_attribute_changed(
w.hydration_attribute_changed({
attribute,
element.outerHTML.replace(element.innerHTML, element.innerHTML && '...'),
String(value)
);
html: element.outerHTML.replace(element.innerHTML, element.innerHTML && '...'),
value: String(value)
});
}
/**

@ -363,7 +363,7 @@ export function apply(
const description = `\`${event_name}\` handler${location}`;
const suggestion = remove_parens ? 'remove the trailing `()`' : 'add a leading `() =>`';
w.event_handler_invalid(description, suggestion);
w.event_handler_invalid({ handler: description, suggestion });
if (error) {
throw error;

@ -2,493 +2,439 @@
import { DEV } from 'esm-env';
export * from '../shared/errors.js';
export * from '../shared/errors.js';
/**
* Cannot create a `$derived(...)` with an `await` expression outside of an effect tree
* @param {void} values
* @returns {never}
*/
export function async_derived_orphan() {
export function async_derived_orphan(values) {
if (DEV) {
const error = new Error(`async_derived_orphan\nCannot create a \`$derived(...)\` with an \`await\` expression outside of an effect tree\nhttps://svelte.dev/e/async_derived_orphan`);
const error = new Error(`${'async_derived_orphan'}\n${`Cannot create a \`$derived(...)\` with an \`await\` expression outside of an effect tree`}\nhttps://svelte.dev/e/${'async_derived_orphan'}`);
error.name = 'Svelte error';
throw error;
} else {
throw new Error(`https://svelte.dev/e/async_derived_orphan`);
throw new Error(`https://svelte.dev/e/${'async_derived_orphan'}`);
}
}
/**
* Using `bind:value` together with a checkbox input is not allowed. Use `bind:checked` instead
* @param {void} values
* @returns {never}
*/
export function bind_invalid_checkbox_value() {
export function bind_invalid_checkbox_value(values) {
if (DEV) {
const error = new Error(`bind_invalid_checkbox_value\nUsing \`bind:value\` together with a checkbox input is not allowed. Use \`bind:checked\` instead\nhttps://svelte.dev/e/bind_invalid_checkbox_value`);
const error = new Error(`${'bind_invalid_checkbox_value'}\n${`Using \`bind:value\` together with a checkbox input is not allowed. Use \`bind:checked\` instead`}\nhttps://svelte.dev/e/${'bind_invalid_checkbox_value'}`);
error.name = 'Svelte error';
throw error;
} else {
throw new Error(`https://svelte.dev/e/bind_invalid_checkbox_value`);
throw new Error(`https://svelte.dev/e/${'bind_invalid_checkbox_value'}`);
}
}
/**
* Component %component% has an export named `%key%` that a consumer component is trying to access using `bind:%key%`, which is disallowed. Instead, use `bind:this` (e.g. `<%name% bind:this={component} />`) and then access the property on the bound component instance (e.g. `component.%key%`)
* @param {string} component
* @param {string} key
* @param {string} name
* @param {{ "component": string, "key": string, "name": string }} values
* @returns {never}
*/
export function bind_invalid_export(component, key, name) {
export function bind_invalid_export(values) {
if (DEV) {
const error = new Error(`bind_invalid_export\nComponent ${component} has an export named \`${key}\` that a consumer component is trying to access using \`bind:${key}\`, which is disallowed. Instead, use \`bind:this\` (e.g. \`<${name} bind:this={component} />\`) and then access the property on the bound component instance (e.g. \`component.${key}\`)\nhttps://svelte.dev/e/bind_invalid_export`);
const error = new Error(`${'bind_invalid_export'}\n${`Component ${values.component} has an export named \`${values.key}\` that a consumer component is trying to access using \`bind:${values.key}\`, which is disallowed. Instead, use \`bind:this\` (e.g. \`<${values.name} bind:this={component} />\`) and then access the property on the bound component instance (e.g. \`component.${values.key}\`)`}\nhttps://svelte.dev/e/${'bind_invalid_export'}`);
error.name = 'Svelte error';
throw error;
} else {
throw new Error(`https://svelte.dev/e/bind_invalid_export`);
throw new Error(`https://svelte.dev/e/${'bind_invalid_export'}`);
}
}
/**
* A component is attempting to bind to a non-bindable property `%key%` belonging to %component% (i.e. `<%name% bind:%key%={...}>`). To mark a property as bindable: `let { %key% = $bindable() } = $props()`
* @param {string} key
* @param {string} component
* @param {string} name
* @param {{ "key": string, "component": string, "name": string }} values
* @returns {never}
*/
export function bind_not_bindable(key, component, name) {
export function bind_not_bindable(values) {
if (DEV) {
const error = new Error(`bind_not_bindable\nA component is attempting to bind to a non-bindable property \`${key}\` belonging to ${component} (i.e. \`<${name} bind:${key}={...}>\`). To mark a property as bindable: \`let { ${key} = $bindable() } = $props()\`\nhttps://svelte.dev/e/bind_not_bindable`);
const error = new Error(`${'bind_not_bindable'}\n${`A component is attempting to bind to a non-bindable property \`${values.key}\` belonging to ${values.component} (i.e. \`<${values.name} bind:${values.key}={...}>\`). To mark a property as bindable: \`let { ${values.key} = $bindable() } = $props()\``}\nhttps://svelte.dev/e/${'bind_not_bindable'}`);
error.name = 'Svelte error';
throw error;
} else {
throw new Error(`https://svelte.dev/e/bind_not_bindable`);
throw new Error(`https://svelte.dev/e/${'bind_not_bindable'}`);
}
}
/**
* Calling `%method%` on a component instance (of %component%) is no longer valid in Svelte 5
* @param {string} method
* @param {string} component
* @param {{ "method": string, "component": string }} values
* @returns {never}
*/
export function component_api_changed(method, component) {
export function component_api_changed(values) {
if (DEV) {
const error = new Error(`component_api_changed\nCalling \`${method}\` on a component instance (of ${component}) is no longer valid in Svelte 5\nhttps://svelte.dev/e/component_api_changed`);
const error = new Error(`${'component_api_changed'}\n${`Calling \`${values.method}\` on a component instance (of ${values.component}) is no longer valid in Svelte 5`}\nhttps://svelte.dev/e/${'component_api_changed'}`);
error.name = 'Svelte error';
throw error;
} else {
throw new Error(`https://svelte.dev/e/component_api_changed`);
throw new Error(`https://svelte.dev/e/${'component_api_changed'}`);
}
}
/**
* Attempted to instantiate %component% with `new %name%`, which is no longer valid in Svelte 5. If this component is not under your control, set the `compatibility.componentApi` compiler option to `4` to keep it working.
* @param {string} component
* @param {string} name
* @param {{ "component": string, "name": string }} values
* @returns {never}
*/
export function component_api_invalid_new(component, name) {
export function component_api_invalid_new(values) {
if (DEV) {
const error = new Error(`component_api_invalid_new\nAttempted to instantiate ${component} with \`new ${name}\`, which is no longer valid in Svelte 5. If this component is not under your control, set the \`compatibility.componentApi\` compiler option to \`4\` to keep it working.\nhttps://svelte.dev/e/component_api_invalid_new`);
const error = new Error(`${'component_api_invalid_new'}\n${`Attempted to instantiate ${values.component} with \`new ${values.name}\`, which is no longer valid in Svelte 5. If this component is not under your control, set the \`compatibility.componentApi\` compiler option to \`4\` to keep it working.`}\nhttps://svelte.dev/e/${'component_api_invalid_new'}`);
error.name = 'Svelte error';
throw error;
} else {
throw new Error(`https://svelte.dev/e/component_api_invalid_new`);
throw new Error(`https://svelte.dev/e/${'component_api_invalid_new'}`);
}
}
/**
* A derived value cannot reference itself recursively
* @param {void} values
* @returns {never}
*/
export function derived_references_self() {
export function derived_references_self(values) {
if (DEV) {
const error = new Error(`derived_references_self\nA derived value cannot reference itself recursively\nhttps://svelte.dev/e/derived_references_self`);
const error = new Error(`${'derived_references_self'}\n${`A derived value cannot reference itself recursively`}\nhttps://svelte.dev/e/${'derived_references_self'}`);
error.name = 'Svelte error';
throw error;
} else {
throw new Error(`https://svelte.dev/e/derived_references_self`);
throw new Error(`https://svelte.dev/e/${'derived_references_self'}`);
}
}
/**
* Keyed each block has duplicate key `%value%` at indexes %a% and %b%
* @param {string} a
* @param {string} b
* @param {string | undefined | null} [value]
* Keyed each block has duplicate key at indexes %a% and %b%
* @param {{ "a": string, "b": string } | { "value": string, "a": string, "b": string }} values
* @returns {never}
*/
export function each_key_duplicate(a, b, value) {
export function each_key_duplicate(values) {
if (DEV) {
const error = new Error(`each_key_duplicate\n${value
? `Keyed each block has duplicate key \`${value}\` at indexes ${a} and ${b}`
: `Keyed each block has duplicate key at indexes ${a} and ${b}`}\nhttps://svelte.dev/e/each_key_duplicate`);
const error = new Error(`${'each_key_duplicate'}\n${(values?.b !== undefined ? `Keyed each block has duplicate key \`${values.value}\` at indexes ${values.a} and ${values.b}` : `Keyed each block has duplicate key at indexes ${values.a} and ${values.b}`)}\nhttps://svelte.dev/e/${'each_key_duplicate'}`);
error.name = 'Svelte error';
throw error;
} else {
throw new Error(`https://svelte.dev/e/each_key_duplicate`);
throw new Error(`https://svelte.dev/e/${'each_key_duplicate'}`);
}
}
/**
* Keyed each block has key that is not idempotent the key for item at index %index% was `%a%` but is now `%b%`. Keys must be the same each time for a given item
* @param {string} index
* @param {string} a
* @param {string} b
* @param {{ "index": string, "a": string, "b": string }} values
* @returns {never}
*/
export function each_key_volatile(index, a, b) {
export function each_key_volatile(values) {
if (DEV) {
const error = new Error(`each_key_volatile\nKeyed each block has key that is not idempotent — the key for item at index ${index} was \`${a}\` but is now \`${b}\`. Keys must be the same each time for a given item\nhttps://svelte.dev/e/each_key_volatile`);
const error = new Error(`${'each_key_volatile'}\n${`Keyed each block has key that is not idempotent — the key for item at index ${values.index} was \`${values.a}\` but is now \`${values.b}\`. Keys must be the same each time for a given item`}\nhttps://svelte.dev/e/${'each_key_volatile'}`);
error.name = 'Svelte error';
throw error;
} else {
throw new Error(`https://svelte.dev/e/each_key_volatile`);
throw new Error(`https://svelte.dev/e/${'each_key_volatile'}`);
}
}
/**
* `%rune%` cannot be used inside an effect cleanup function
* @param {string} rune
* @param {{ "rune": string }} values
* @returns {never}
*/
export function effect_in_teardown(rune) {
export function effect_in_teardown(values) {
if (DEV) {
const error = new Error(`effect_in_teardown\n\`${rune}\` cannot be used inside an effect cleanup function\nhttps://svelte.dev/e/effect_in_teardown`);
const error = new Error(`${'effect_in_teardown'}\n${`\`${values.rune}\` cannot be used inside an effect cleanup function`}\nhttps://svelte.dev/e/${'effect_in_teardown'}`);
error.name = 'Svelte error';
throw error;
} else {
throw new Error(`https://svelte.dev/e/effect_in_teardown`);
throw new Error(`https://svelte.dev/e/${'effect_in_teardown'}`);
}
}
/**
* Effect cannot be created inside a `$derived` value that was not itself created inside an effect
* @param {void} values
* @returns {never}
*/
export function effect_in_unowned_derived() {
export function effect_in_unowned_derived(values) {
if (DEV) {
const error = new Error(`effect_in_unowned_derived\nEffect cannot be created inside a \`$derived\` value that was not itself created inside an effect\nhttps://svelte.dev/e/effect_in_unowned_derived`);
const error = new Error(`${'effect_in_unowned_derived'}\n${`Effect cannot be created inside a \`$derived\` value that was not itself created inside an effect`}\nhttps://svelte.dev/e/${'effect_in_unowned_derived'}`);
error.name = 'Svelte error';
throw error;
} else {
throw new Error(`https://svelte.dev/e/effect_in_unowned_derived`);
throw new Error(`https://svelte.dev/e/${'effect_in_unowned_derived'}`);
}
}
/**
* `%rune%` can only be used inside an effect (e.g. during component initialisation)
* @param {string} rune
* @param {{ "rune": string }} values
* @returns {never}
*/
export function effect_orphan(rune) {
export function effect_orphan(values) {
if (DEV) {
const error = new Error(`effect_orphan\n\`${rune}\` can only be used inside an effect (e.g. during component initialisation)\nhttps://svelte.dev/e/effect_orphan`);
const error = new Error(`${'effect_orphan'}\n${`\`${values.rune}\` can only be used inside an effect (e.g. during component initialisation)`}\nhttps://svelte.dev/e/${'effect_orphan'}`);
error.name = 'Svelte error';
throw error;
} else {
throw new Error(`https://svelte.dev/e/effect_orphan`);
throw new Error(`https://svelte.dev/e/${'effect_orphan'}`);
}
}
/**
* `$effect.pending()` can only be called inside an effect or derived
* @param {void} values
* @returns {never}
*/
export function effect_pending_outside_reaction() {
export function effect_pending_outside_reaction(values) {
if (DEV) {
const error = new Error(`effect_pending_outside_reaction\n\`$effect.pending()\` can only be called inside an effect or derived\nhttps://svelte.dev/e/effect_pending_outside_reaction`);
const error = new Error(`${'effect_pending_outside_reaction'}\n${`\`$effect.pending()\` can only be called inside an effect or derived`}\nhttps://svelte.dev/e/${'effect_pending_outside_reaction'}`);
error.name = 'Svelte error';
throw error;
} else {
throw new Error(`https://svelte.dev/e/effect_pending_outside_reaction`);
throw new Error(`https://svelte.dev/e/${'effect_pending_outside_reaction'}`);
}
}
/**
* Maximum update depth exceeded. This typically indicates that an effect reads and writes the same piece of state
* @param {void} values
* @returns {never}
*/
export function effect_update_depth_exceeded() {
export function effect_update_depth_exceeded(values) {
if (DEV) {
const error = new Error(`effect_update_depth_exceeded\nMaximum update depth exceeded. This typically indicates that an effect reads and writes the same piece of state\nhttps://svelte.dev/e/effect_update_depth_exceeded`);
const error = new Error(`${'effect_update_depth_exceeded'}\n${`Maximum update depth exceeded. This typically indicates that an effect reads and writes the same piece of state`}\nhttps://svelte.dev/e/${'effect_update_depth_exceeded'}`);
error.name = 'Svelte error';
throw error;
} else {
throw new Error(`https://svelte.dev/e/effect_update_depth_exceeded`);
throw new Error(`https://svelte.dev/e/${'effect_update_depth_exceeded'}`);
}
}
/**
* Cannot use `flushSync` inside an effect
* @param {void} values
* @returns {never}
*/
export function flush_sync_in_effect() {
export function flush_sync_in_effect(values) {
if (DEV) {
const error = new Error(`flush_sync_in_effect\nCannot use \`flushSync\` inside an effect\nhttps://svelte.dev/e/flush_sync_in_effect`);
const error = new Error(`${'flush_sync_in_effect'}\n${`Cannot use \`flushSync\` inside an effect`}\nhttps://svelte.dev/e/${'flush_sync_in_effect'}`);
error.name = 'Svelte error';
throw error;
} else {
throw new Error(`https://svelte.dev/e/flush_sync_in_effect`);
throw new Error(`https://svelte.dev/e/${'flush_sync_in_effect'}`);
}
}
/**
* Cannot commit a fork that was already discarded
* @param {void} values
* @returns {never}
*/
export function fork_discarded() {
export function fork_discarded(values) {
if (DEV) {
const error = new Error(`fork_discarded\nCannot commit a fork that was already discarded\nhttps://svelte.dev/e/fork_discarded`);
const error = new Error(`${'fork_discarded'}\n${`Cannot commit a fork that was already discarded`}\nhttps://svelte.dev/e/${'fork_discarded'}`);
error.name = 'Svelte error';
throw error;
} else {
throw new Error(`https://svelte.dev/e/fork_discarded`);
throw new Error(`https://svelte.dev/e/${'fork_discarded'}`);
}
}
/**
* Cannot create a fork inside an effect or when state changes are pending
* @param {void} values
* @returns {never}
*/
export function fork_timing() {
export function fork_timing(values) {
if (DEV) {
const error = new Error(`fork_timing\nCannot create a fork inside an effect or when state changes are pending\nhttps://svelte.dev/e/fork_timing`);
const error = new Error(`${'fork_timing'}\n${`Cannot create a fork inside an effect or when state changes are pending`}\nhttps://svelte.dev/e/${'fork_timing'}`);
error.name = 'Svelte error';
throw error;
} else {
throw new Error(`https://svelte.dev/e/fork_timing`);
throw new Error(`https://svelte.dev/e/${'fork_timing'}`);
}
}
/**
* `getAbortSignal()` can only be called inside an effect or derived
* @param {void} values
* @returns {never}
*/
export function get_abort_signal_outside_reaction() {
export function get_abort_signal_outside_reaction(values) {
if (DEV) {
const error = new Error(`get_abort_signal_outside_reaction\n\`getAbortSignal()\` can only be called inside an effect or derived\nhttps://svelte.dev/e/get_abort_signal_outside_reaction`);
const error = new Error(`${'get_abort_signal_outside_reaction'}\n${`\`getAbortSignal()\` can only be called inside an effect or derived`}\nhttps://svelte.dev/e/${'get_abort_signal_outside_reaction'}`);
error.name = 'Svelte error';
throw error;
} else {
throw new Error(`https://svelte.dev/e/get_abort_signal_outside_reaction`);
throw new Error(`https://svelte.dev/e/${'get_abort_signal_outside_reaction'}`);
}
}
/**
* Expected to find a hydratable with key `%key%` during hydration, but did not.
* @param {string} key
* @param {{ "key": string }} values
* @returns {never}
*/
export function hydratable_missing_but_required(key) {
export function hydratable_missing_but_required(values) {
if (DEV) {
const error = new Error(`hydratable_missing_but_required\nExpected to find a hydratable with key \`${key}\` during hydration, but did not.\nhttps://svelte.dev/e/hydratable_missing_but_required`);
const error = new Error(`${'hydratable_missing_but_required'}\n${`Expected to find a hydratable with key \`${values.key}\` during hydration, but did not.`}\nhttps://svelte.dev/e/${'hydratable_missing_but_required'}`);
error.name = 'Svelte error';
throw error;
} else {
throw new Error(`https://svelte.dev/e/hydratable_missing_but_required`);
throw new Error(`https://svelte.dev/e/${'hydratable_missing_but_required'}`);
}
}
/**
* Failed to hydrate the application
* @param {void} values
* @returns {never}
*/
export function hydration_failed() {
export function hydration_failed(values) {
if (DEV) {
const error = new Error(`hydration_failed\nFailed to hydrate the application\nhttps://svelte.dev/e/hydration_failed`);
const error = new Error(`${'hydration_failed'}\n${`Failed to hydrate the application`}\nhttps://svelte.dev/e/${'hydration_failed'}`);
error.name = 'Svelte error';
throw error;
} else {
throw new Error(`https://svelte.dev/e/hydration_failed`);
throw new Error(`https://svelte.dev/e/${'hydration_failed'}`);
}
}
/**
* Could not `{@render}` snippet due to the expression being `null` or `undefined`. Consider using optional chaining `{@render snippet?.()}`
* @param {void} values
* @returns {never}
*/
export function invalid_snippet() {
export function invalid_snippet(values) {
if (DEV) {
const error = new Error(`invalid_snippet\nCould not \`{@render}\` snippet due to the expression being \`null\` or \`undefined\`. Consider using optional chaining \`{@render snippet?.()}\`\nhttps://svelte.dev/e/invalid_snippet`);
const error = new Error(`${'invalid_snippet'}\n${`Could not \`{@render}\` snippet due to the expression being \`null\` or \`undefined\`. Consider using optional chaining \`{@render snippet?.()}\``}\nhttps://svelte.dev/e/${'invalid_snippet'}`);
error.name = 'Svelte error';
throw error;
} else {
throw new Error(`https://svelte.dev/e/invalid_snippet`);
throw new Error(`https://svelte.dev/e/${'invalid_snippet'}`);
}
}
/**
* `%name%(...)` cannot be used in runes mode
* @param {string} name
* @param {{ "name": string }} values
* @returns {never}
*/
export function lifecycle_legacy_only(name) {
export function lifecycle_legacy_only(values) {
if (DEV) {
const error = new Error(`lifecycle_legacy_only\n\`${name}(...)\` cannot be used in runes mode\nhttps://svelte.dev/e/lifecycle_legacy_only`);
const error = new Error(`${'lifecycle_legacy_only'}\n${`\`${values.name}(...)\` cannot be used in runes mode`}\nhttps://svelte.dev/e/${'lifecycle_legacy_only'}`);
error.name = 'Svelte error';
throw error;
} else {
throw new Error(`https://svelte.dev/e/lifecycle_legacy_only`);
throw new Error(`https://svelte.dev/e/${'lifecycle_legacy_only'}`);
}
}
/**
* Cannot do `bind:%key%={undefined}` when `%key%` has a fallback value
* @param {string} key
* @param {{ "key": string }} values
* @returns {never}
*/
export function props_invalid_value(key) {
export function props_invalid_value(values) {
if (DEV) {
const error = new Error(`props_invalid_value\nCannot do \`bind:${key}={undefined}\` when \`${key}\` has a fallback value\nhttps://svelte.dev/e/props_invalid_value`);
const error = new Error(`${'props_invalid_value'}\n${`Cannot do \`bind:${values.key}={undefined}\` when \`${values.key}\` has a fallback value`}\nhttps://svelte.dev/e/${'props_invalid_value'}`);
error.name = 'Svelte error';
throw error;
} else {
throw new Error(`https://svelte.dev/e/props_invalid_value`);
throw new Error(`https://svelte.dev/e/${'props_invalid_value'}`);
}
}
/**
* Rest element properties of `$props()` such as `%property%` are readonly
* @param {string} property
* @param {{ "property": string }} values
* @returns {never}
*/
export function props_rest_readonly(property) {
export function props_rest_readonly(values) {
if (DEV) {
const error = new Error(`props_rest_readonly\nRest element properties of \`$props()\` such as \`${property}\` are readonly\nhttps://svelte.dev/e/props_rest_readonly`);
const error = new Error(`${'props_rest_readonly'}\n${`Rest element properties of \`$props()\` such as \`${values.property}\` are readonly`}\nhttps://svelte.dev/e/${'props_rest_readonly'}`);
error.name = 'Svelte error';
throw error;
} else {
throw new Error(`https://svelte.dev/e/props_rest_readonly`);
throw new Error(`https://svelte.dev/e/${'props_rest_readonly'}`);
}
}
/**
* The `%rune%` rune is only available inside `.svelte` and `.svelte.js/ts` files
* @param {string} rune
* @param {{ "rune": string }} values
* @returns {never}
*/
export function rune_outside_svelte(rune) {
export function rune_outside_svelte(values) {
if (DEV) {
const error = new Error(`rune_outside_svelte\nThe \`${rune}\` rune is only available inside \`.svelte\` and \`.svelte.js/ts\` files\nhttps://svelte.dev/e/rune_outside_svelte`);
const error = new Error(`${'rune_outside_svelte'}\n${`The \`${values.rune}\` rune is only available inside \`.svelte\` and \`.svelte.js/ts\` files`}\nhttps://svelte.dev/e/${'rune_outside_svelte'}`);
error.name = 'Svelte error';
throw error;
} else {
throw new Error(`https://svelte.dev/e/rune_outside_svelte`);
throw new Error(`https://svelte.dev/e/${'rune_outside_svelte'}`);
}
}
/**
* Property descriptors defined on `$state` objects must contain `value` and always be `enumerable`, `configurable` and `writable`.
* @param {void} values
* @returns {never}
*/
export function state_descriptors_fixed() {
export function state_descriptors_fixed(values) {
if (DEV) {
const error = new Error(`state_descriptors_fixed\nProperty descriptors defined on \`$state\` objects must contain \`value\` and always be \`enumerable\`, \`configurable\` and \`writable\`.\nhttps://svelte.dev/e/state_descriptors_fixed`);
const error = new Error(`${'state_descriptors_fixed'}\n${`Property descriptors defined on \`$state\` objects must contain \`value\` and always be \`enumerable\`, \`configurable\` and \`writable\`.`}\nhttps://svelte.dev/e/${'state_descriptors_fixed'}`);
error.name = 'Svelte error';
throw error;
} else {
throw new Error(`https://svelte.dev/e/state_descriptors_fixed`);
throw new Error(`https://svelte.dev/e/${'state_descriptors_fixed'}`);
}
}
/**
* Cannot set prototype of `$state` object
* @param {void} values
* @returns {never}
*/
export function state_prototype_fixed() {
export function state_prototype_fixed(values) {
if (DEV) {
const error = new Error(`state_prototype_fixed\nCannot set prototype of \`$state\` object\nhttps://svelte.dev/e/state_prototype_fixed`);
const error = new Error(`${'state_prototype_fixed'}\n${`Cannot set prototype of \`$state\` object`}\nhttps://svelte.dev/e/${'state_prototype_fixed'}`);
error.name = 'Svelte error';
throw error;
} else {
throw new Error(`https://svelte.dev/e/state_prototype_fixed`);
throw new Error(`https://svelte.dev/e/${'state_prototype_fixed'}`);
}
}
/**
* Updating state inside `$derived(...)`, `$inspect(...)` or a template expression is forbidden. If the value should not be reactive, declare it without `$state`
* @param {void} values
* @returns {never}
*/
export function state_unsafe_mutation() {
export function state_unsafe_mutation(values) {
if (DEV) {
const error = new Error(`state_unsafe_mutation\nUpdating state inside \`$derived(...)\`, \`$inspect(...)\` or a template expression is forbidden. If the value should not be reactive, declare it without \`$state\`\nhttps://svelte.dev/e/state_unsafe_mutation`);
const error = new Error(`${'state_unsafe_mutation'}\n${`Updating state inside \`$derived(...)\`, \`$inspect(...)\` or a template expression is forbidden. If the value should not be reactive, declare it without \`$state\``}\nhttps://svelte.dev/e/${'state_unsafe_mutation'}`);
error.name = 'Svelte error';
throw error;
} else {
throw new Error(`https://svelte.dev/e/state_unsafe_mutation`);
throw new Error(`https://svelte.dev/e/${'state_unsafe_mutation'}`);
}
}
/**
* A `<svelte:boundary>` `reset` function cannot be called while an error is still being handled
* @param {void} values
* @returns {never}
*/
export function svelte_boundary_reset_onerror() {
export function svelte_boundary_reset_onerror(values) {
if (DEV) {
const error = new Error(`svelte_boundary_reset_onerror\nA \`<svelte:boundary>\` \`reset\` function cannot be called while an error is still being handled\nhttps://svelte.dev/e/svelte_boundary_reset_onerror`);
const error = new Error(`${'svelte_boundary_reset_onerror'}\n${`A \`<svelte:boundary>\` \`reset\` function cannot be called while an error is still being handled`}\nhttps://svelte.dev/e/${'svelte_boundary_reset_onerror'}`);
error.name = 'Svelte error';
throw error;
} else {
throw new Error(`https://svelte.dev/e/svelte_boundary_reset_onerror`);
throw new Error(`https://svelte.dev/e/${'svelte_boundary_reset_onerror'}`);
}
}
}

@ -12,7 +12,7 @@ import { DEV } from 'esm-env';
*/
export function hydratable(key, fn) {
if (!async_mode_flag) {
e.experimental_async_required('hydratable');
e.experimental_async_required({ name: 'hydratable' });
}
if (hydrating) {
@ -23,9 +23,9 @@ export function hydratable(key, fn) {
}
if (DEV) {
e.hydratable_missing_but_required(key);
e.hydratable_missing_but_required({ key });
} else {
w.hydratable_missing_but_expected(key);
w.hydratable_missing_but_expected({ key });
}
}

@ -1375,7 +1375,7 @@ function reset_all(effect) {
*/
export function fork(fn) {
if (!async_mode_flag) {
e.experimental_async_required('fork');
e.experimental_async_required({ name: 'fork' });
}
if (current_batch !== null) {

@ -236,7 +236,10 @@ export function async_derived(fn, label, location) {
setTimeout(() => {
if (recent_async_deriveds.has(signal) && (effect.f & DESTROYED) === 0) {
w.await_waterfall(/** @type {string} */ (signal.label), location);
w.await_waterfall({
name: /** @type {string} */ (signal.label),
location
});
recent_async_deriveds.delete(signal);
}
});

@ -54,14 +54,14 @@ import { set_signal_status } from './status.js';
export function validate_effect(rune) {
if (active_effect === null) {
if (active_reaction === null) {
e.effect_orphan(rune);
e.effect_orphan({ rune });
}
e.effect_in_unowned_derived();
}
if (is_destroying_effect) {
e.effect_in_teardown(rune);
e.effect_in_teardown({ rune });
}
}

@ -59,7 +59,7 @@ const rest_props_handler = {
set(target, key) {
if (DEV) {
// TODO should this happen in prod too?
e.props_rest_readonly(`${target.name}.${String(key)}`);
e.props_rest_readonly({ property: `${target.name}.${String(key)}` });
}
return false;
@ -326,7 +326,7 @@ export function prop(props, key, flags, fallback) {
initial_value = get_fallback();
if (setter) {
if (runes) e.props_invalid_value(key);
if (runes) e.props_invalid_value({ key });
setter(initial_value);
}
}

@ -618,7 +618,7 @@ export function get(signal) {
) {
reactivity_loss_tracker.warned = true;
w.await_reactivity_loss(/** @type {string} */ (signal.label));
w.await_reactivity_loss({ name: /** @type {string} */ (signal.label) });
var trace = get_error('traced at');
// eslint-disable-next-line no-console

@ -45,7 +45,7 @@ export function validate_binding(binding, blockers, get_object, get_property, li
if (effect.deps === null) {
var location = `${filename}:${line}:${column}`;
w.binding_property_non_reactive(binding, location);
w.binding_property_non_reactive({ binding, location });
warned = true;
}

@ -7,265 +7,320 @@ var normal = 'font-weight: normal';
/**
* Assignment to `%property%` property (%location%) will evaluate to the right-hand side, not the value of `%property%` following the assignment. This may result in unexpected behaviour.
* @param {string} property
* @param {string} location
* @param {{ "property": string, "location": string }} values
*/
export function assignment_value_stale(property, location) {
export function assignment_value_stale(values) {
if (DEV) {
console.warn(`%c[svelte] assignment_value_stale\n%cAssignment to \`${property}\` property (${location}) will evaluate to the right-hand side, not the value of \`${property}\` following the assignment. This may result in unexpected behaviour.\nhttps://svelte.dev/e/assignment_value_stale`, bold, normal);
console.warn(
`%c[svelte] ${'assignment_value_stale'}\n%c${`Assignment to \`${values.property}\` property (${values.location}) will evaluate to the right-hand side, not the value of \`${values.property}\` following the assignment. This may result in unexpected behaviour.`}\nhttps://svelte.dev/e/${'assignment_value_stale'}`,
bold,
normal
);
} else {
console.warn(`https://svelte.dev/e/assignment_value_stale`);
console.warn(`https://svelte.dev/e/${'assignment_value_stale'}`);
}
}
/**
* Detected reactivity loss when reading `%name%`. This happens when state is read in an async function after an earlier `await`
* @param {string} name
* @param {{ "name": string }} values
*/
export function await_reactivity_loss(name) {
export function await_reactivity_loss(values) {
if (DEV) {
console.warn(`%c[svelte] await_reactivity_loss\n%cDetected reactivity loss when reading \`${name}\`. This happens when state is read in an async function after an earlier \`await\`\nhttps://svelte.dev/e/await_reactivity_loss`, bold, normal);
console.warn(
`%c[svelte] ${'await_reactivity_loss'}\n%c${`Detected reactivity loss when reading \`${values.name}\`. This happens when state is read in an async function after an earlier \`await\``}\nhttps://svelte.dev/e/${'await_reactivity_loss'}`,
bold,
normal
);
} else {
console.warn(`https://svelte.dev/e/await_reactivity_loss`);
console.warn(`https://svelte.dev/e/${'await_reactivity_loss'}`);
}
}
/**
* An async derived, `%name%` (%location%) was not read immediately after it resolved. This often indicates an unnecessary waterfall, which can slow down your app
* @param {string} name
* @param {string} location
* @param {{ "name": string, "location": string }} values
*/
export function await_waterfall(name, location) {
export function await_waterfall(values) {
if (DEV) {
console.warn(`%c[svelte] await_waterfall\n%cAn async derived, \`${name}\` (${location}) was not read immediately after it resolved. This often indicates an unnecessary waterfall, which can slow down your app\nhttps://svelte.dev/e/await_waterfall`, bold, normal);
console.warn(
`%c[svelte] ${'await_waterfall'}\n%c${`An async derived, \`${values.name}\` (${values.location}) was not read immediately after it resolved. This often indicates an unnecessary waterfall, which can slow down your app`}\nhttps://svelte.dev/e/${'await_waterfall'}`,
bold,
normal
);
} else {
console.warn(`https://svelte.dev/e/await_waterfall`);
console.warn(`https://svelte.dev/e/${'await_waterfall'}`);
}
}
/**
* `%binding%` (%location%) is binding to a non-reactive property
* @param {string} binding
* @param {string | undefined | null} [location]
* `%binding%` is binding to a non-reactive property
* @param {{ "binding": string } | { "binding": string, "location": string }} values
*/
export function binding_property_non_reactive(binding, location) {
export function binding_property_non_reactive(values) {
if (DEV) {
console.warn(
`%c[svelte] binding_property_non_reactive\n%c${location
? `\`${binding}\` (${location}) is binding to a non-reactive property`
: `\`${binding}\` is binding to a non-reactive property`}\nhttps://svelte.dev/e/binding_property_non_reactive`,
`%c[svelte] ${'binding_property_non_reactive'}\n%c${(values?.location !== undefined ? `\`${values.binding}\` (${values.location}) is binding to a non-reactive property` : `\`${values.binding}\` is binding to a non-reactive property`)}\nhttps://svelte.dev/e/${'binding_property_non_reactive'}`,
bold,
normal
);
} else {
console.warn(`https://svelte.dev/e/binding_property_non_reactive`);
console.warn(`https://svelte.dev/e/${'binding_property_non_reactive'}`);
}
}
/**
* Your `console.%method%` contained `$state` proxies. Consider using `$inspect(...)` or `$state.snapshot(...)` instead
* @param {string} method
* @param {{ "method": string }} values
*/
export function console_log_state(method) {
export function console_log_state(values) {
if (DEV) {
console.warn(`%c[svelte] console_log_state\n%cYour \`console.${method}\` contained \`$state\` proxies. Consider using \`$inspect(...)\` or \`$state.snapshot(...)\` instead\nhttps://svelte.dev/e/console_log_state`, bold, normal);
console.warn(
`%c[svelte] ${'console_log_state'}\n%c${`Your \`console.${values.method}\` contained \`$state\` proxies. Consider using \`$inspect(...)\` or \`$state.snapshot(...)\` instead`}\nhttps://svelte.dev/e/${'console_log_state'}`,
bold,
normal
);
} else {
console.warn(`https://svelte.dev/e/console_log_state`);
console.warn(`https://svelte.dev/e/${'console_log_state'}`);
}
}
/**
* Reading a derived belonging to a now-destroyed effect may result in stale values
* @param {void} values
*/
export function derived_inert() {
export function derived_inert(values) {
if (DEV) {
console.warn(`%c[svelte] derived_inert\n%cReading a derived belonging to a now-destroyed effect may result in stale values\nhttps://svelte.dev/e/derived_inert`, bold, normal);
console.warn(
`%c[svelte] ${'derived_inert'}\n%c${`Reading a derived belonging to a now-destroyed effect may result in stale values`}\nhttps://svelte.dev/e/${'derived_inert'}`,
bold,
normal
);
} else {
console.warn(`https://svelte.dev/e/derived_inert`);
console.warn(`https://svelte.dev/e/${'derived_inert'}`);
}
}
/**
* %handler% should be a function. Did you mean to %suggestion%?
* @param {string} handler
* @param {string} suggestion
* @param {{ "handler": string, "suggestion": string }} values
*/
export function event_handler_invalid(handler, suggestion) {
export function event_handler_invalid(values) {
if (DEV) {
console.warn(`%c[svelte] event_handler_invalid\n%c${handler} should be a function. Did you mean to ${suggestion}?\nhttps://svelte.dev/e/event_handler_invalid`, bold, normal);
console.warn(
`%c[svelte] ${'event_handler_invalid'}\n%c${`${values.handler} should be a function. Did you mean to ${values.suggestion}?`}\nhttps://svelte.dev/e/${'event_handler_invalid'}`,
bold,
normal
);
} else {
console.warn(`https://svelte.dev/e/event_handler_invalid`);
console.warn(`https://svelte.dev/e/${'event_handler_invalid'}`);
}
}
/**
* Expected to find a hydratable with key `%key%` during hydration, but did not.
* @param {string} key
* @param {{ "key": string }} values
*/
export function hydratable_missing_but_expected(key) {
export function hydratable_missing_but_expected(values) {
if (DEV) {
console.warn(`%c[svelte] hydratable_missing_but_expected\n%cExpected to find a hydratable with key \`${key}\` during hydration, but did not.\nhttps://svelte.dev/e/hydratable_missing_but_expected`, bold, normal);
console.warn(
`%c[svelte] ${'hydratable_missing_but_expected'}\n%c${`Expected to find a hydratable with key \`${values.key}\` during hydration, but did not.`}\nhttps://svelte.dev/e/${'hydratable_missing_but_expected'}`,
bold,
normal
);
} else {
console.warn(`https://svelte.dev/e/hydratable_missing_but_expected`);
console.warn(`https://svelte.dev/e/${'hydratable_missing_but_expected'}`);
}
}
/**
* The `%attribute%` attribute on `%html%` changed its value between server and client renders. The client value, `%value%`, will be ignored in favour of the server value
* @param {string} attribute
* @param {string} html
* @param {string} value
* @param {{ "attribute": string, "html": string, "value": string }} values
*/
export function hydration_attribute_changed(attribute, html, value) {
export function hydration_attribute_changed(values) {
if (DEV) {
console.warn(`%c[svelte] hydration_attribute_changed\n%cThe \`${attribute}\` attribute on \`${html}\` changed its value between server and client renders. The client value, \`${value}\`, will be ignored in favour of the server value\nhttps://svelte.dev/e/hydration_attribute_changed`, bold, normal);
console.warn(
`%c[svelte] ${'hydration_attribute_changed'}\n%c${`The \`${values.attribute}\` attribute on \`${values.html}\` changed its value between server and client renders. The client value, \`${values.value}\`, will be ignored in favour of the server value`}\nhttps://svelte.dev/e/${'hydration_attribute_changed'}`,
bold,
normal
);
} else {
console.warn(`https://svelte.dev/e/hydration_attribute_changed`);
console.warn(`https://svelte.dev/e/${'hydration_attribute_changed'}`);
}
}
/**
* The value of an `{@html ...}` block %location% changed between server and client renders. The client value will be ignored in favour of the server value
* @param {string | undefined | null} [location]
* The value of an `{@html ...}` block changed between server and client renders. The client value will be ignored in favour of the server value
* @param {void | { "location": string }} values
*/
export function hydration_html_changed(location) {
export function hydration_html_changed(values) {
if (DEV) {
console.warn(
`%c[svelte] hydration_html_changed\n%c${location
? `The value of an \`{@html ...}\` block ${location} changed between server and client renders. The client value will be ignored in favour of the server value`
: 'The value of an `{@html ...}` block changed between server and client renders. The client value will be ignored in favour of the server value'}\nhttps://svelte.dev/e/hydration_html_changed`,
`%c[svelte] ${'hydration_html_changed'}\n%c${(values?.location !== undefined ? `The value of an \`{@html ...}\` block ${values.location} changed between server and client renders. The client value will be ignored in favour of the server value` : `The value of an \`{@html ...}\` block changed between server and client renders. The client value will be ignored in favour of the server value`)}\nhttps://svelte.dev/e/${'hydration_html_changed'}`,
bold,
normal
);
} else {
console.warn(`https://svelte.dev/e/hydration_html_changed`);
console.warn(`https://svelte.dev/e/${'hydration_html_changed'}`);
}
}
/**
* Hydration failed because the initial UI does not match what was rendered on the server. The error occurred near %location%
* @param {string | undefined | null} [location]
* Hydration failed because the initial UI does not match what was rendered on the server
* @param {void | { "location": string }} values
*/
export function hydration_mismatch(location) {
export function hydration_mismatch(values) {
if (DEV) {
console.warn(
`%c[svelte] hydration_mismatch\n%c${location
? `Hydration failed because the initial UI does not match what was rendered on the server. The error occurred near ${location}`
: 'Hydration failed because the initial UI does not match what was rendered on the server'}\nhttps://svelte.dev/e/hydration_mismatch`,
`%c[svelte] ${'hydration_mismatch'}\n%c${(values?.location !== undefined ? `Hydration failed because the initial UI does not match what was rendered on the server. The error occurred near ${values.location}` : `Hydration failed because the initial UI does not match what was rendered on the server`)}\nhttps://svelte.dev/e/${'hydration_mismatch'}`,
bold,
normal
);
} else {
console.warn(`https://svelte.dev/e/hydration_mismatch`);
console.warn(`https://svelte.dev/e/${'hydration_mismatch'}`);
}
}
/**
* The `render` function passed to `createRawSnippet` should return HTML for a single element
* @param {void} values
*/
export function invalid_raw_snippet_render() {
export function invalid_raw_snippet_render(values) {
if (DEV) {
console.warn(`%c[svelte] invalid_raw_snippet_render\n%cThe \`render\` function passed to \`createRawSnippet\` should return HTML for a single element\nhttps://svelte.dev/e/invalid_raw_snippet_render`, bold, normal);
console.warn(
`%c[svelte] ${'invalid_raw_snippet_render'}\n%c${`The \`render\` function passed to \`createRawSnippet\` should return HTML for a single element`}\nhttps://svelte.dev/e/${'invalid_raw_snippet_render'}`,
bold,
normal
);
} else {
console.warn(`https://svelte.dev/e/invalid_raw_snippet_render`);
console.warn(`https://svelte.dev/e/${'invalid_raw_snippet_render'}`);
}
}
/**
* Detected a migrated `$:` reactive block in `%filename%` that both accesses and updates the same reactive value. This may cause recursive updates when converted to an `$effect`.
* @param {string} filename
* @param {{ "filename": string }} values
*/
export function legacy_recursive_reactive_block(filename) {
export function legacy_recursive_reactive_block(values) {
if (DEV) {
console.warn(`%c[svelte] legacy_recursive_reactive_block\n%cDetected a migrated \`$:\` reactive block in \`${filename}\` that both accesses and updates the same reactive value. This may cause recursive updates when converted to an \`$effect\`.\nhttps://svelte.dev/e/legacy_recursive_reactive_block`, bold, normal);
console.warn(
`%c[svelte] ${'legacy_recursive_reactive_block'}\n%c${`Detected a migrated \`$:\` reactive block in \`${values.filename}\` that both accesses and updates the same reactive value. This may cause recursive updates when converted to an \`$effect\`.`}\nhttps://svelte.dev/e/${'legacy_recursive_reactive_block'}`,
bold,
normal
);
} else {
console.warn(`https://svelte.dev/e/legacy_recursive_reactive_block`);
console.warn(`https://svelte.dev/e/${'legacy_recursive_reactive_block'}`);
}
}
/**
* Tried to unmount a component that was not mounted
* @param {void} values
*/
export function lifecycle_double_unmount() {
export function lifecycle_double_unmount(values) {
if (DEV) {
console.warn(`%c[svelte] lifecycle_double_unmount\n%cTried to unmount a component that was not mounted\nhttps://svelte.dev/e/lifecycle_double_unmount`, bold, normal);
console.warn(
`%c[svelte] ${'lifecycle_double_unmount'}\n%c${`Tried to unmount a component that was not mounted`}\nhttps://svelte.dev/e/${'lifecycle_double_unmount'}`,
bold,
normal
);
} else {
console.warn(`https://svelte.dev/e/lifecycle_double_unmount`);
console.warn(`https://svelte.dev/e/${'lifecycle_double_unmount'}`);
}
}
/**
* %parent% passed property `%prop%` to %child% with `bind:`, but its parent component %owner% did not declare `%prop%` as a binding. Consider creating a binding between %owner% and %parent% (e.g. `bind:%prop%={...}` instead of `%prop%={...}`)
* @param {string} parent
* @param {string} prop
* @param {string} child
* @param {string} owner
* @param {{ "parent": string, "prop": string, "child": string, "owner": string }} values
*/
export function ownership_invalid_binding(parent, prop, child, owner) {
export function ownership_invalid_binding(values) {
if (DEV) {
console.warn(`%c[svelte] ownership_invalid_binding\n%c${parent} passed property \`${prop}\` to ${child} with \`bind:\`, but its parent component ${owner} did not declare \`${prop}\` as a binding. Consider creating a binding between ${owner} and ${parent} (e.g. \`bind:${prop}={...}\` instead of \`${prop}={...}\`)\nhttps://svelte.dev/e/ownership_invalid_binding`, bold, normal);
console.warn(
`%c[svelte] ${'ownership_invalid_binding'}\n%c${`${values.parent} passed property \`${values.prop}\` to ${values.child} with \`bind:\`, but its parent component ${values.owner} did not declare \`${values.prop}\` as a binding. Consider creating a binding between ${values.owner} and ${values.parent} (e.g. \`bind:${values.prop}={...}\` instead of \`${values.prop}={...}\`)`}\nhttps://svelte.dev/e/${'ownership_invalid_binding'}`,
bold,
normal
);
} else {
console.warn(`https://svelte.dev/e/ownership_invalid_binding`);
console.warn(`https://svelte.dev/e/${'ownership_invalid_binding'}`);
}
}
/**
* Mutating unbound props (`%name%`, at %location%) is strongly discouraged. Consider using `bind:%prop%={...}` in %parent% (or using a callback) instead
* @param {string} name
* @param {string} location
* @param {string} prop
* @param {string} parent
* @param {{ "name": string, "location": string, "prop": string, "parent": string }} values
*/
export function ownership_invalid_mutation(name, location, prop, parent) {
export function ownership_invalid_mutation(values) {
if (DEV) {
console.warn(`%c[svelte] ownership_invalid_mutation\n%cMutating unbound props (\`${name}\`, at ${location}) is strongly discouraged. Consider using \`bind:${prop}={...}\` in ${parent} (or using a callback) instead\nhttps://svelte.dev/e/ownership_invalid_mutation`, bold, normal);
console.warn(
`%c[svelte] ${'ownership_invalid_mutation'}\n%c${`Mutating unbound props (\`${values.name}\`, at ${values.location}) is strongly discouraged. Consider using \`bind:${values.prop}={...}\` in ${values.parent} (or using a callback) instead`}\nhttps://svelte.dev/e/${'ownership_invalid_mutation'}`,
bold,
normal
);
} else {
console.warn(`https://svelte.dev/e/ownership_invalid_mutation`);
console.warn(`https://svelte.dev/e/${'ownership_invalid_mutation'}`);
}
}
/**
* The `value` property of a `<select multiple>` element should be an array, but it received a non-array value. The selection will be kept as is.
* @param {void} values
*/
export function select_multiple_invalid_value() {
export function select_multiple_invalid_value(values) {
if (DEV) {
console.warn(`%c[svelte] select_multiple_invalid_value\n%cThe \`value\` property of a \`<select multiple>\` element should be an array, but it received a non-array value. The selection will be kept as is.\nhttps://svelte.dev/e/select_multiple_invalid_value`, bold, normal);
console.warn(
`%c[svelte] ${'select_multiple_invalid_value'}\n%c${`The \`value\` property of a \`<select multiple>\` element should be an array, but it received a non-array value. The selection will be kept as is.`}\nhttps://svelte.dev/e/${'select_multiple_invalid_value'}`,
bold,
normal
);
} else {
console.warn(`https://svelte.dev/e/select_multiple_invalid_value`);
console.warn(`https://svelte.dev/e/${'select_multiple_invalid_value'}`);
}
}
/**
* Reactive `$state(...)` proxies and the values they proxy have different identities. Because of this, comparisons with `%operator%` will produce unexpected results
* @param {string} operator
* @param {{ "operator": string }} values
*/
export function state_proxy_equality_mismatch(operator) {
export function state_proxy_equality_mismatch(values) {
if (DEV) {
console.warn(`%c[svelte] state_proxy_equality_mismatch\n%cReactive \`$state(...)\` proxies and the values they proxy have different identities. Because of this, comparisons with \`${operator}\` will produce unexpected results\nhttps://svelte.dev/e/state_proxy_equality_mismatch`, bold, normal);
console.warn(
`%c[svelte] ${'state_proxy_equality_mismatch'}\n%c${`Reactive \`$state(...)\` proxies and the values they proxy have different identities. Because of this, comparisons with \`${values.operator}\` will produce unexpected results`}\nhttps://svelte.dev/e/${'state_proxy_equality_mismatch'}`,
bold,
normal
);
} else {
console.warn(`https://svelte.dev/e/state_proxy_equality_mismatch`);
console.warn(`https://svelte.dev/e/${'state_proxy_equality_mismatch'}`);
}
}
/**
* A `<svelte:boundary>` `reset` function only resets the boundary the first time it is called
* @param {void} values
*/
export function svelte_boundary_reset_noop() {
export function svelte_boundary_reset_noop(values) {
if (DEV) {
console.warn(`%c[svelte] svelte_boundary_reset_noop\n%cA \`<svelte:boundary>\` \`reset\` function only resets the boundary the first time it is called\nhttps://svelte.dev/e/svelte_boundary_reset_noop`, bold, normal);
console.warn(
`%c[svelte] ${'svelte_boundary_reset_noop'}\n%c${`A \`<svelte:boundary>\` \`reset\` function only resets the boundary the first time it is called`}\nhttps://svelte.dev/e/${'svelte_boundary_reset_noop'}`,
bold,
normal
);
} else {
console.warn(`https://svelte.dev/e/svelte_boundary_reset_noop`);
console.warn(`https://svelte.dev/e/${'svelte_boundary_reset_noop'}`);
}
}
/**
* The `slide` transition does not work correctly for elements with `display: %value%`
* @param {string} value
* @param {{ "value": string }} values
*/
export function transition_slide_display(value) {
export function transition_slide_display(values) {
if (DEV) {
console.warn(`%c[svelte] transition_slide_display\n%cThe \`slide\` transition does not work correctly for elements with \`display: ${value}\`\nhttps://svelte.dev/e/transition_slide_display`, bold, normal);
console.warn(
`%c[svelte] ${'transition_slide_display'}\n%c${`The \`slide\` transition does not work correctly for elements with \`display: ${values.value}\``}\nhttps://svelte.dev/e/${'transition_slide_display'}`,
bold,
normal
);
} else {
console.warn(`https://svelte.dev/e/transition_slide_display`);
console.warn(`https://svelte.dev/e/${'transition_slide_display'}`);
}
}
}

@ -1,143 +1,127 @@
/* This file is generated by scripts/process-messages/index.js. Do not edit! */
export * from '../shared/errors.js';
export * from '../shared/errors.js';
/**
* The node API `AsyncLocalStorage` is not available, but is required to use async server rendering.
* @param {void} values
* @returns {never}
*/
export function async_local_storage_unavailable() {
const error = new Error(`async_local_storage_unavailable\nThe node API \`AsyncLocalStorage\` is not available, but is required to use async server rendering.\nhttps://svelte.dev/e/async_local_storage_unavailable`);
export function async_local_storage_unavailable(values) {
const error = new Error(`${'async_local_storage_unavailable'}\n${`The node API \`AsyncLocalStorage\` is not available, but is required to use async server rendering.`}\nhttps://svelte.dev/e/${'async_local_storage_unavailable'}`);
error.name = 'Svelte error';
throw error;
}
/**
* Encountered asynchronous work while rendering synchronously.
* @param {void} values
* @returns {never}
*/
export function await_invalid() {
const error = new Error(`await_invalid\nEncountered asynchronous work while rendering synchronously.\nhttps://svelte.dev/e/await_invalid`);
export function await_invalid(values) {
const error = new Error(`${'await_invalid'}\n${`Encountered asynchronous work while rendering synchronously.`}\nhttps://svelte.dev/e/${'await_invalid'}`);
error.name = 'Svelte error';
throw error;
}
/**
* `<svelte:element this="%tag%">` is not a valid element name the element will not be rendered
* @param {string} tag
* @param {{ "tag": string }} values
* @returns {never}
*/
export function dynamic_element_invalid_tag(tag) {
const error = new Error(`dynamic_element_invalid_tag\n\`<svelte:element this="${tag}">\` is not a valid element name — the element will not be rendered\nhttps://svelte.dev/e/dynamic_element_invalid_tag`);
export function dynamic_element_invalid_tag(values) {
const error = new Error(`${'dynamic_element_invalid_tag'}\n${`\`<svelte:element this="${values.tag}">\` is not a valid element name — the element will not be rendered`}\nhttps://svelte.dev/e/${'dynamic_element_invalid_tag'}`);
error.name = 'Svelte error';
throw error;
}
/**
* The `html` property of server render results has been deprecated. Use `body` instead.
* @param {void} values
* @returns {never}
*/
export function html_deprecated() {
const error = new Error(`html_deprecated\nThe \`html\` property of server render results has been deprecated. Use \`body\` instead.\nhttps://svelte.dev/e/html_deprecated`);
export function html_deprecated(values) {
const error = new Error(`${'html_deprecated'}\n${`The \`html\` property of server render results has been deprecated. Use \`body\` instead.`}\nhttps://svelte.dev/e/${'html_deprecated'}`);
error.name = 'Svelte error';
throw error;
}
/**
* Attempted to set `hydratable` with key `%key%` twice with different values.
*
* %stack%
* @param {string} key
* @param {string} stack
%stack%
* @param {{ "key": string, "stack": string }} values
* @returns {never}
*/
export function hydratable_clobbering(key, stack) {
const error = new Error(`hydratable_clobbering\nAttempted to set \`hydratable\` with key \`${key}\` twice with different values.
${stack}\nhttps://svelte.dev/e/hydratable_clobbering`);
export function hydratable_clobbering(values) {
const error = new Error(`${'hydratable_clobbering'}\n${`Attempted to set \`hydratable\` with key \`${values.key}\` twice with different values.
${values.stack}`}\nhttps://svelte.dev/e/${'hydratable_clobbering'}`);
error.name = 'Svelte error';
throw error;
}
/**
* Failed to serialize `hydratable` data for key `%key%`.
*
* `hydratable` can serialize anything [`uneval` from `devalue`](https://npmjs.com/package/uneval) can, plus Promises.
*
* Cause:
* %stack%
* @param {string} key
* @param {string} stack
`hydratable` can serialize anything [`uneval` from `devalue`](https://npmjs.com/package/uneval) can, plus Promises.
Cause:
%stack%
* @param {{ "key": string, "stack": string }} values
* @returns {never}
*/
export function hydratable_serialization_failed(key, stack) {
const error = new Error(`hydratable_serialization_failed\nFailed to serialize \`hydratable\` data for key \`${key}\`.
export function hydratable_serialization_failed(values) {
const error = new Error(`${'hydratable_serialization_failed'}\n${`Failed to serialize \`hydratable\` data for key \`${values.key}\`.
\`hydratable\` can serialize anything [\`uneval\` from \`devalue\`](https://npmjs.com/package/uneval) can, plus Promises.
Cause:
${stack}\nhttps://svelte.dev/e/hydratable_serialization_failed`);
${values.stack}`}\nhttps://svelte.dev/e/${'hydratable_serialization_failed'}`);
error.name = 'Svelte error';
throw error;
}
/**
* `csp.nonce` was set while `csp.hash` was `true`. These options cannot be used simultaneously.
* @param {void} values
* @returns {never}
*/
export function invalid_csp() {
const error = new Error(`invalid_csp\n\`csp.nonce\` was set while \`csp.hash\` was \`true\`. These options cannot be used simultaneously.\nhttps://svelte.dev/e/invalid_csp`);
export function invalid_csp(values) {
const error = new Error(`${'invalid_csp'}\n${`\`csp.nonce\` was set while \`csp.hash\` was \`true\`. These options cannot be used simultaneously.`}\nhttps://svelte.dev/e/${'invalid_csp'}`);
error.name = 'Svelte error';
throw error;
}
/**
* The `idPrefix` option cannot include `--`.
* @param {void} values
* @returns {never}
*/
export function invalid_id_prefix() {
const error = new Error(`invalid_id_prefix\nThe \`idPrefix\` option cannot include \`--\`.\nhttps://svelte.dev/e/invalid_id_prefix`);
export function invalid_id_prefix(values) {
const error = new Error(`${'invalid_id_prefix'}\n${`The \`idPrefix\` option cannot include \`--\`.`}\nhttps://svelte.dev/e/${'invalid_id_prefix'}`);
error.name = 'Svelte error';
throw error;
}
/**
* `%name%(...)` is not available on the server
* @param {string} name
* @param {{ "name": string }} values
* @returns {never}
*/
export function lifecycle_function_unavailable(name) {
const error = new Error(`lifecycle_function_unavailable\n\`${name}(...)\` is not available on the server\nhttps://svelte.dev/e/lifecycle_function_unavailable`);
export function lifecycle_function_unavailable(values) {
const error = new Error(`${'lifecycle_function_unavailable'}\n${`\`${values.name}(...)\` is not available on the server`}\nhttps://svelte.dev/e/${'lifecycle_function_unavailable'}`);
error.name = 'Svelte error';
throw error;
}
/**
* Could not resolve `render` context.
* @param {void} values
* @returns {never}
*/
export function server_context_required() {
const error = new Error(`server_context_required\nCould not resolve \`render\` context.\nhttps://svelte.dev/e/server_context_required`);
export function server_context_required(values) {
const error = new Error(`${'server_context_required'}\n${`Could not resolve \`render\` context.`}\nhttps://svelte.dev/e/${'server_context_required'}`);
error.name = 'Svelte error';
throw error;
}
}

@ -14,7 +14,7 @@ import { get_user_code_location } from './dev.js';
*/
export function hydratable(key, fn) {
if (!async_mode_flag) {
e.experimental_async_required('hydratable');
e.experimental_async_required({ name: 'hydratable' });
}
const { hydratable } = get_render_context();
@ -73,10 +73,10 @@ function encode(key, value, unresolved) {
);
})
.catch((devalue_error) =>
e.hydratable_serialization_failed(
e.hydratable_serialization_failed({
key,
serialization_stack(entry.stack, devalue_error?.stack)
)
stack: serialization_stack(entry.stack, devalue_error?.stack)
})
);
unresolved?.set(p, key);
@ -127,7 +127,7 @@ async function compare(key, a, b) {
? `Occurred at:\n${a_stack}`
: `First occurrence at:\n${a_stack}\n\nSecond occurrence at:\n${b_stack}`;
e.hydratable_clobbering(key, stack);
e.hydratable_clobbering({ key, stack });
}
}

@ -42,7 +42,7 @@ export function element(renderer, tag, attributes_fn = noop, children_fn = noop)
if (tag) {
if (!REGEX_VALID_TAG_NAME.test(tag)) {
e.dynamic_element_invalid_tag(tag);
e.dynamic_element_invalid_tag({ tag });
}
renderer.push(`<${tag}`);
attributes_fn();

@ -843,7 +843,10 @@ export class Renderer {
for (const [_, key] of ctx.unresolved_promises) {
// this is a problem -- it means we've finished the render but we're still waiting on a promise to resolve so we can
// serialize it, so we're blocking the response on useless content.
w.unresolved_hydratable(key, ctx.lookup.get(key)?.stack ?? '<missing stack trace>');
w.unresolved_hydratable({
key,
stack: ctx.lookup.get(key)?.stack ?? '<missing stack trace>'
});
}
for (const comparison of ctx.comparisons) {

@ -7,23 +7,22 @@ var normal = 'font-weight: normal';
/**
* A `hydratable` value with key `%key%` was created, but at least part of it was not used during the render.
*
* The `hydratable` was initialized in:
* %stack%
* @param {string} key
* @param {string} stack
The `hydratable` was initialized in:
%stack%
* @param {{ "key": string, "stack": string }} values
*/
export function unresolved_hydratable(key, stack) {
export function unresolved_hydratable(values) {
if (DEV) {
console.warn(
`%c[svelte] unresolved_hydratable\n%cA \`hydratable\` value with key \`${key}\` was created, but at least part of it was not used during the render.
`%c[svelte] ${'unresolved_hydratable'}\n%c${`A \`hydratable\` value with key \`${values.key}\` was created, but at least part of it was not used during the render.
The \`hydratable\` was initialized in:
${stack}\nhttps://svelte.dev/e/unresolved_hydratable`,
${values.stack}`}\nhttps://svelte.dev/e/${'unresolved_hydratable'}`,
bold,
normal
);
} else {
console.warn(`https://svelte.dev/e/unresolved_hydratable`);
console.warn(`https://svelte.dev/e/${'unresolved_hydratable'}`);
}
}
}

@ -35,7 +35,7 @@ export function snapshot(value, skip_warning = false, no_tojson = false) {
let uncloned = slice.map((path) => `- <value>${path}`).join('\n');
if (excess > 0) uncloned += `\n- ...and ${excess} more`;
w.state_snapshot_uncloneable(uncloned);
w.state_snapshot_uncloneable({ properties: uncloned });
}
return copy;

@ -46,7 +46,7 @@ function get_parent_context(context) {
*/
export function get_or_init_context_map(context, name) {
if (context === null) {
lifecycle_outside_component(name);
lifecycle_outside_component({ name });
}
return (context.c ??= new Map(get_parent_context(context) || undefined));

@ -75,5 +75,5 @@ export function invariant(condition, message) {
throw new Error('invariant(...) was not guarded by if (DEV)');
}
if (!condition) e.invariant_violation(message);
if (!condition) e.invariant_violation({ message });
}

@ -4,164 +4,150 @@ import { DEV } from 'esm-env';
/**
* Cannot use `%name%(...)` unless the `experimental.async` compiler option is `true`
* @param {string} name
* @param {{ "name": string }} values
* @returns {never}
*/
export function experimental_async_required(name) {
export function experimental_async_required(values) {
if (DEV) {
const error = new Error(`experimental_async_required\nCannot use \`${name}(...)\` unless the \`experimental.async\` compiler option is \`true\`\nhttps://svelte.dev/e/experimental_async_required`);
const error = new Error(`${'experimental_async_required'}\n${`Cannot use \`${values.name}(...)\` unless the \`experimental.async\` compiler option is \`true\``}\nhttps://svelte.dev/e/${'experimental_async_required'}`);
error.name = 'Svelte error';
throw error;
} else {
throw new Error(`https://svelte.dev/e/experimental_async_required`);
throw new Error(`https://svelte.dev/e/${'experimental_async_required'}`);
}
}
/**
* Cannot use `{@render children(...)}` if the parent component uses `let:` directives. Consider using a named snippet instead
* @param {void} values
* @returns {never}
*/
export function invalid_default_snippet() {
export function invalid_default_snippet(values) {
if (DEV) {
const error = new Error(`invalid_default_snippet\nCannot use \`{@render children(...)}\` if the parent component uses \`let:\` directives. Consider using a named snippet instead\nhttps://svelte.dev/e/invalid_default_snippet`);
const error = new Error(`${'invalid_default_snippet'}\n${`Cannot use \`{@render children(...)}\` if the parent component uses \`let:\` directives. Consider using a named snippet instead`}\nhttps://svelte.dev/e/${'invalid_default_snippet'}`);
error.name = 'Svelte error';
throw error;
} else {
throw new Error(`https://svelte.dev/e/invalid_default_snippet`);
throw new Error(`https://svelte.dev/e/${'invalid_default_snippet'}`);
}
}
/**
* A snippet function was passed invalid arguments. Snippets should only be instantiated via `{@render ...}`
* @param {void} values
* @returns {never}
*/
export function invalid_snippet_arguments() {
export function invalid_snippet_arguments(values) {
if (DEV) {
const error = new Error(`invalid_snippet_arguments\nA snippet function was passed invalid arguments. Snippets should only be instantiated via \`{@render ...}\`\nhttps://svelte.dev/e/invalid_snippet_arguments`);
const error = new Error(`${'invalid_snippet_arguments'}\n${`A snippet function was passed invalid arguments. Snippets should only be instantiated via \`{@render ...}\``}\nhttps://svelte.dev/e/${'invalid_snippet_arguments'}`);
error.name = 'Svelte error';
throw error;
} else {
throw new Error(`https://svelte.dev/e/invalid_snippet_arguments`);
throw new Error(`https://svelte.dev/e/${'invalid_snippet_arguments'}`);
}
}
/**
* An invariant violation occurred, meaning Svelte's internal assumptions were flawed. This is a bug in Svelte, not your app please open an issue at https://github.com/sveltejs/svelte, citing the following message: "%message%"
* @param {string} message
* @param {{ "message": string }} values
* @returns {never}
*/
export function invariant_violation(message) {
export function invariant_violation(values) {
if (DEV) {
const error = new Error(`invariant_violation\nAn invariant violation occurred, meaning Svelte's internal assumptions were flawed. This is a bug in Svelte, not your app — please open an issue at https://github.com/sveltejs/svelte, citing the following message: "${message}"\nhttps://svelte.dev/e/invariant_violation`);
const error = new Error(`${'invariant_violation'}\n${`An invariant violation occurred, meaning Svelte's internal assumptions were flawed. This is a bug in Svelte, not your app — please open an issue at https://github.com/sveltejs/svelte, citing the following message: "${values.message}"`}\nhttps://svelte.dev/e/${'invariant_violation'}`);
error.name = 'Svelte error';
throw error;
} else {
throw new Error(`https://svelte.dev/e/invariant_violation`);
throw new Error(`https://svelte.dev/e/${'invariant_violation'}`);
}
}
/**
* `%name%(...)` can only be used during component initialisation
* @param {string} name
* @param {{ "name": string }} values
* @returns {never}
*/
export function lifecycle_outside_component(name) {
export function lifecycle_outside_component(values) {
if (DEV) {
const error = new Error(`lifecycle_outside_component\n\`${name}(...)\` can only be used during component initialisation\nhttps://svelte.dev/e/lifecycle_outside_component`);
const error = new Error(`${'lifecycle_outside_component'}\n${`\`${values.name}(...)\` can only be used during component initialisation`}\nhttps://svelte.dev/e/${'lifecycle_outside_component'}`);
error.name = 'Svelte error';
throw error;
} else {
throw new Error(`https://svelte.dev/e/lifecycle_outside_component`);
throw new Error(`https://svelte.dev/e/${'lifecycle_outside_component'}`);
}
}
/**
* Context was not set in the current component or any of its ancestors
* @param {void} values
* @returns {never}
*/
export function missing_context() {
export function missing_context(values) {
if (DEV) {
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`);
const error = new Error(`${'missing_context'}\n${`Context was not set in the current component or any of its ancestors`}\nhttps://svelte.dev/e/${'missing_context'}`);
error.name = 'Svelte error';
throw error;
} else {
throw new Error(`https://svelte.dev/e/missing_context`);
throw new Error(`https://svelte.dev/e/${'missing_context'}`);
}
}
/**
* `setContext` must be called when a component first initializes, not in a subsequent effect or after an `await` expression
* @param {void} values
* @returns {never}
*/
export function set_context_after_init() {
export function set_context_after_init(values) {
if (DEV) {
const error = new Error(`set_context_after_init\n\`setContext\` must be called when a component first initializes, not in a subsequent effect or after an \`await\` expression\nhttps://svelte.dev/e/set_context_after_init`);
const error = new Error(`${'set_context_after_init'}\n${`\`setContext\` must be called when a component first initializes, not in a subsequent effect or after an \`await\` expression`}\nhttps://svelte.dev/e/${'set_context_after_init'}`);
error.name = 'Svelte error';
throw error;
} else {
throw new Error(`https://svelte.dev/e/set_context_after_init`);
throw new Error(`https://svelte.dev/e/${'set_context_after_init'}`);
}
}
/**
* Attempted to render a snippet without a `{@render}` block. This would cause the snippet code to be stringified instead of its content being rendered to the DOM. To fix this, change `{snippet}` to `{@render snippet()}`.
* @param {void} values
* @returns {never}
*/
export function snippet_without_render_tag() {
export function snippet_without_render_tag(values) {
if (DEV) {
const error = new Error(`snippet_without_render_tag\nAttempted to render a snippet without a \`{@render}\` block. This would cause the snippet code to be stringified instead of its content being rendered to the DOM. To fix this, change \`{snippet}\` to \`{@render snippet()}\`.\nhttps://svelte.dev/e/snippet_without_render_tag`);
const error = new Error(`${'snippet_without_render_tag'}\n${`Attempted to render a snippet without a \`{@render}\` block. This would cause the snippet code to be stringified instead of its content being rendered to the DOM. To fix this, change \`{snippet}\` to \`{@render snippet()}\`.`}\nhttps://svelte.dev/e/${'snippet_without_render_tag'}`);
error.name = 'Svelte error';
throw error;
} else {
throw new Error(`https://svelte.dev/e/snippet_without_render_tag`);
throw new Error(`https://svelte.dev/e/${'snippet_without_render_tag'}`);
}
}
/**
* `%name%` is not a store with a `subscribe` method
* @param {string} name
* @param {{ "name": string }} values
* @returns {never}
*/
export function store_invalid_shape(name) {
export function store_invalid_shape(values) {
if (DEV) {
const error = new Error(`store_invalid_shape\n\`${name}\` is not a store with a \`subscribe\` method\nhttps://svelte.dev/e/store_invalid_shape`);
const error = new Error(`${'store_invalid_shape'}\n${`\`${values.name}\` is not a store with a \`subscribe\` method`}\nhttps://svelte.dev/e/${'store_invalid_shape'}`);
error.name = 'Svelte error';
throw error;
} else {
throw new Error(`https://svelte.dev/e/store_invalid_shape`);
throw new Error(`https://svelte.dev/e/${'store_invalid_shape'}`);
}
}
/**
* The `this` prop on `<svelte:element>` must be a string, if defined
* @param {void} values
* @returns {never}
*/
export function svelte_element_invalid_this_value() {
export function svelte_element_invalid_this_value(values) {
if (DEV) {
const error = new Error(`svelte_element_invalid_this_value\nThe \`this\` prop on \`<svelte:element>\` must be a string, if defined\nhttps://svelte.dev/e/svelte_element_invalid_this_value`);
const error = new Error(`${'svelte_element_invalid_this_value'}\n${`The \`this\` prop on \`<svelte:element>\` must be a string, if defined`}\nhttps://svelte.dev/e/${'svelte_element_invalid_this_value'}`);
error.name = 'Svelte error';
throw error;
} else {
throw new Error(`https://svelte.dev/e/svelte_element_invalid_this_value`);
throw new Error(`https://svelte.dev/e/${'svelte_element_invalid_this_value'}`);
}
}
}

@ -11,7 +11,7 @@ export { invalid_default_snippet } from './errors.js';
export function validate_void_dynamic_element(tag_fn) {
const tag = tag_fn();
if (tag && is_void(tag)) {
w.dynamic_void_element_content(tag);
w.dynamic_void_element_content({ tag });
}
}
@ -30,7 +30,7 @@ export function validate_dynamic_element_tag(tag_fn) {
*/
export function validate_store(store, name) {
if (store != null && typeof store.subscribe !== 'function') {
e.store_invalid_shape(name);
e.store_invalid_shape({ name });
}
}

@ -7,34 +7,34 @@ var normal = 'font-weight: normal';
/**
* `<svelte:element this="%tag%">` is a void element it cannot have content
* @param {string} tag
* @param {{ "tag": string }} values
*/
export function dynamic_void_element_content(tag) {
export function dynamic_void_element_content(values) {
if (DEV) {
console.warn(`%c[svelte] dynamic_void_element_content\n%c\`<svelte:element this="${tag}">\` is a void element — it cannot have content\nhttps://svelte.dev/e/dynamic_void_element_content`, bold, normal);
console.warn(
`%c[svelte] ${'dynamic_void_element_content'}\n%c${`\`<svelte:element this="${values.tag}">\` is a void element — it cannot have content`}\nhttps://svelte.dev/e/${'dynamic_void_element_content'}`,
bold,
normal
);
} else {
console.warn(`https://svelte.dev/e/dynamic_void_element_content`);
console.warn(`https://svelte.dev/e/${'dynamic_void_element_content'}`);
}
}
/**
* The following properties cannot be cloned with `$state.snapshot` the return value contains the originals:
*
* %properties%
* @param {string | undefined | null} [properties]
* Value cannot be cloned with `$state.snapshot` the original value was returned
* @param {void | { "properties": string }} values
*/
export function state_snapshot_uncloneable(properties) {
export function state_snapshot_uncloneable(values) {
if (DEV) {
console.warn(
`%c[svelte] state_snapshot_uncloneable\n%c${properties
? `The following properties cannot be cloned with \`$state.snapshot\` — the return value contains the originals:
`%c[svelte] ${'state_snapshot_uncloneable'}\n%c${(values?.properties !== undefined ? `The following properties cannot be cloned with \`$state.snapshot\` — the return value contains the originals:
${properties}`
: 'Value cannot be cloned with `$state.snapshot` — the original value was returned'}\nhttps://svelte.dev/e/state_snapshot_uncloneable`,
${values.properties}` : `Value cannot be cloned with \`$state.snapshot\` — the original value was returned`)}\nhttps://svelte.dev/e/${'state_snapshot_uncloneable'}`,
bold,
normal
);
} else {
console.warn(`https://svelte.dev/e/state_snapshot_uncloneable`);
console.warn(`https://svelte.dev/e/${'state_snapshot_uncloneable'}`);
}
}
}

@ -198,7 +198,7 @@ export function run(fn) {
// @ts-ignore
filename = dev_current_component_function?.[FILENAME] ?? filename;
}
w.legacy_recursive_reactive_block(filename);
w.legacy_recursive_reactive_block({ filename });
set_signal_status(effect, MAYBE_DIRTY);
}
});
@ -250,7 +250,7 @@ export function handlers(...handlers) {
export function createBubbler() {
const active_component_context = component_context;
if (active_component_context === null) {
e.lifecycle_outside_component('createBubbler');
e.lifecycle_outside_component({ name: 'createBubbler' });
}
return (/**@type {string}*/ type) => (/**@type {Event}*/ event) => {

@ -122,7 +122,7 @@ export function slide(node, { delay = 0, duration = 400, easing = cubic_out, axi
if (DEV && !slide_warning && /(contents|inline|table)/.test(style.display)) {
slide_warning = true;
Promise.resolve().then(() => (slide_warning = false));
w.transition_slide_display(style.display);
w.transition_slide_display({ value: style.display });
}
const opacity = +style.opacity;

@ -132,6 +132,9 @@ importers:
'@rollup/plugin-virtual':
specifier: ^3.0.2
version: 3.0.2(rollup@4.62.2)
'@sveltejs/message-box':
specifier: ^1.1.0
version: 1.1.0
'@types/aria-query':
specifier: ^5.0.4
version: 5.0.4
@ -937,6 +940,9 @@ packages:
typescript: '>= 5'
typescript-eslint: '>= 8'
'@sveltejs/message-box@1.1.0':
resolution: {integrity: sha512-zJ9WUolgv6W4IpAHBSu4da5Uha4Je4ZGrKjVyIY4jWSqkJNbofoCgZxRoLuKExcyXODphzommhsHH/42zxd6zg==}
'@sveltejs/vite-plugin-svelte-inspector@5.0.1':
resolution: {integrity: sha512-ubWshlMk4bc8mkwWbg6vNvCeT7lGQojE3ijDh3QTR6Zr/R+GXxsGbyH4PExEPpiFmqPhYiVSVmHBjUcVc1JIrA==}
engines: {node: ^20.19 || ^22.12 || >=24}
@ -3072,6 +3078,8 @@ snapshots:
typescript: 5.5.4
typescript-eslint: 8.56.0(eslint@10.0.0)(typescript@5.5.4)
'@sveltejs/message-box@1.1.0': {}
'@sveltejs/vite-plugin-svelte-inspector@5.0.1(@sveltejs/vite-plugin-svelte@6.2.0(svelte@packages+svelte)(vite@7.3.5(@types/node@24.5.2)(lightningcss@1.23.0)(sass@1.70.0)(terser@5.27.0)))(svelte@packages+svelte)(vite@7.3.5(@types/node@24.5.2)(lightningcss@1.23.0)(sass@1.70.0)(terser@5.27.0))':
dependencies:
'@sveltejs/vite-plugin-svelte': 6.2.0(svelte@packages+svelte)(vite@7.3.5(@types/node@24.5.2)(lightningcss@1.23.0)(sass@1.70.0)(terser@5.27.0))

Loading…
Cancel
Save