Comparing version 5.0.0-next.134 to 5.0.0-next.135
@@ -5,3 +5,3 @@ { | ||
"license": "MIT", | ||
"version": "5.0.0-next.134", | ||
"version": "5.0.0-next.135", | ||
"type": "module", | ||
@@ -8,0 +8,0 @@ "types": "./types/index.d.ts", |
@@ -931,3 +931,3 @@ /* This file is generated by scripts/process-messages/index.js. Do not edit! */ | ||
/** | ||
* Mixing old (on:%name%) and new syntaxes for event handling is not allowed. Use only the on%name% syntax. | ||
* Mixing old (on:%name%) and new syntaxes for event handling is not allowed. Use only the on%name% syntax | ||
* @param {null | number | NodeLike} node | ||
@@ -938,3 +938,3 @@ * @param {string} name | ||
export function mixed_event_handler_syntaxes(node, name) { | ||
e(node, "mixed_event_handler_syntaxes", `Mixing old (on:${name}) and new syntaxes for event handling is not allowed. Use only the on${name} syntax.`); | ||
e(node, "mixed_event_handler_syntaxes", `Mixing old (on:${name}) and new syntaxes for event handling is not allowed. Use only the on${name} syntax`); | ||
} | ||
@@ -1064,3 +1064,3 @@ | ||
/** | ||
* Cannot use `<slot>` syntax and `{@render ...}` tags in the same component. Migrate towards `{@render ...}` tags completely. | ||
* Cannot use `<slot>` syntax and `{@render ...}` tags in the same component. Migrate towards `{@render ...}` tags completely | ||
* @param {null | number | NodeLike} node | ||
@@ -1070,3 +1070,3 @@ * @returns {never} | ||
export function slot_snippet_conflict(node) { | ||
e(node, "slot_snippet_conflict", "Cannot use `<slot>` syntax and `{@render ...}` tags in the same component. Migrate towards `{@render ...}` tags completely."); | ||
e(node, "slot_snippet_conflict", "Cannot use `<slot>` syntax and `{@render ...}` tags in the same component. Migrate towards `{@render ...}` tags completely"); | ||
} | ||
@@ -1073,0 +1073,0 @@ |
@@ -22,6 +22,6 @@ import { walk as zimmerframe_walk } from 'zimmerframe'; | ||
export function compile(source, options) { | ||
const validated = validate_component_options(options, ''); | ||
state.reset(source, validated); | ||
try { | ||
state.reset({ source, filename: options.filename }); | ||
const validated = validate_component_options(options, ''); | ||
let parsed = _parse(source); | ||
@@ -53,3 +53,3 @@ | ||
if (e instanceof CompileError) { | ||
handle_compile_error(e, options.filename, source); | ||
handle_compile_error(e); | ||
} | ||
@@ -70,6 +70,6 @@ | ||
export function compileModule(source, options) { | ||
const validated = validate_module_options(options, ''); | ||
state.reset(source, validated); | ||
try { | ||
state.reset({ source, filename: options.filename }); | ||
const validated = validate_module_options(options, ''); | ||
const analysis = analyze_module(parse_acorn(source, false), validated); | ||
@@ -80,3 +80,3 @@ const result = transform_module(analysis, source, validated); | ||
if (e instanceof CompileError) { | ||
handle_compile_error(e, options.filename, source); | ||
handle_compile_error(e); | ||
} | ||
@@ -90,7 +90,5 @@ | ||
* @param {import('#compiler').CompileError} error | ||
* @param {string | undefined} filename | ||
* @param {string} source | ||
*/ | ||
function handle_compile_error(error, filename, source) { | ||
error.filename = filename; | ||
function handle_compile_error(error) { | ||
error.filename = state.filename; | ||
@@ -142,7 +140,7 @@ if (error.position) { | ||
* @param {string} source | ||
* @param {{ filename?: string; modern?: boolean }} [options] | ||
* @param {{ filename?: string; rootDir?: string; modern?: boolean }} [options] | ||
* @returns {import('#compiler').Root | import('./types/legacy-nodes.js').LegacyRoot} | ||
*/ | ||
export function parse(source, options = {}) { | ||
state.reset({ source, filename: options.filename }); | ||
export function parse(source, { filename, rootDir, modern } = {}) { | ||
state.reset(source, { filename, rootDir }); // TODO it's weird to require filename/rootDir here. reconsider the API | ||
@@ -155,3 +153,3 @@ /** @type {import('#compiler').Root} */ | ||
if (e instanceof CompileError) { | ||
handle_compile_error(e, options.filename, source); | ||
handle_compile_error(e); | ||
} | ||
@@ -162,3 +160,3 @@ | ||
return to_public_ast(source, ast, options.modern); | ||
return to_public_ast(source, ast, modern); | ||
} | ||
@@ -165,0 +163,0 @@ |
@@ -21,3 +21,3 @@ import MagicString from 'magic-string'; | ||
try { | ||
reset({ source, filename: 'migrate.svelte' }); | ||
reset(source, { filename: 'migrate.svelte' }); | ||
@@ -24,0 +24,0 @@ let parsed = parse(source); |
@@ -56,2 +56,20 @@ import { walk } from 'zimmerframe'; | ||
return b.empty; | ||
}, | ||
TSTypeParameterDeclaration() { | ||
return b.empty; | ||
}, | ||
TSTypeParameterInstantiation() { | ||
return b.empty; | ||
}, | ||
TSEnumDeclaration() { | ||
return b.empty; | ||
}, | ||
Identifier(node) { | ||
if (node.typeAnnotation) { | ||
return { | ||
...node, | ||
typeAnnotation: null | ||
}; | ||
} | ||
return node; | ||
} | ||
@@ -58,0 +76,0 @@ }; |
@@ -11,2 +11,3 @@ import { walk } from 'zimmerframe'; | ||
import { render_stylesheet } from '../css/index.js'; | ||
import { filename } from '../../../state.js'; | ||
@@ -475,10 +476,3 @@ /** | ||
if (options.dev) { | ||
if (options.filename) { | ||
let filename = options.filename; | ||
if (/(\/|\w:)/.test(options.filename)) { | ||
// filename is absolute — truncate it | ||
const parts = filename.split(/[/\\]/); | ||
filename = parts.length > 3 ? ['...', ...parts.slice(-3)].join('/') : filename; | ||
} | ||
if (filename) { | ||
// add `App.filename = 'App.svelte'` so that we can print useful messages later | ||
@@ -485,0 +479,0 @@ body.unshift( |
@@ -679,11 +679,4 @@ import is_reference from 'is-reference'; | ||
AnimateDirective: SvelteDirective, | ||
UseDirective: SvelteDirective, | ||
UseDirective: SvelteDirective | ||
// @ts-ignore | ||
TSTypeAnnotation: skip, | ||
TSInterfaceDeclaration: skip, | ||
TSTypeAliasDeclaration: skip, | ||
TSTypeParameterDeclaration: skip, | ||
TSEnumDeclaration: skip | ||
// TODO others | ||
@@ -690,0 +683,0 @@ }); |
@@ -8,3 +8,7 @@ import { getLocator } from 'locate-character'; | ||
/** @type {string | undefined} */ | ||
/** | ||
* The filename (if specified in the compiler options) relative to the rootDir (if specified). | ||
* This should not be used in the compiler output except in dev mode | ||
* @type {string | undefined} | ||
*/ | ||
export let filename; | ||
@@ -30,12 +34,21 @@ | ||
/** | ||
* @param {{ | ||
* source: string; | ||
* filename: string | undefined; | ||
* }} options | ||
* @param {string} source | ||
* @param {{ filename?: string, rootDir?: string }} options | ||
*/ | ||
export function reset(options) { | ||
filename = options.filename; | ||
locator = getLocator(options.source, { offsetLine: 1 }); | ||
export function reset(source, options) { | ||
const root_dir = options.rootDir?.replace(/\\/g, '/'); | ||
filename = options.filename?.replace(/\\/g, '/'); | ||
if ( | ||
typeof filename === 'string' && | ||
typeof root_dir === 'string' && | ||
filename.startsWith(root_dir) | ||
) { | ||
// make filename relative to rootDir | ||
filename = filename.replace(root_dir, '').replace(/^[/\\]/, ''); | ||
} | ||
locator = getLocator(source, { offsetLine: 1 }); | ||
warnings = []; | ||
ignore_stack = []; | ||
} |
@@ -219,2 +219,8 @@ import type { | ||
filename?: string; | ||
/** | ||
* Used for ensuring filenames don't leak filesystem information. Your bundler plugin will set it automatically. | ||
* @default process.cwd() on node-like environments, undefined elsewhere | ||
*/ | ||
rootDir?: string; | ||
} | ||
@@ -224,4 +230,8 @@ | ||
export type ValidatedModuleCompileOptions = Omit<Required<ModuleCompileOptions>, 'filename'> & { | ||
export type ValidatedModuleCompileOptions = Omit< | ||
Required<ModuleCompileOptions>, | ||
'filename' | 'rootDir' | ||
> & { | ||
filename: ModuleCompileOptions['filename']; | ||
rootDir: ModuleCompileOptions['rootDir']; | ||
}; | ||
@@ -228,0 +238,0 @@ |
@@ -13,2 +13,6 @@ import * as e from './errors.js'; | ||
// default to process.cwd() where it exists to replicate svelte4 behavior | ||
// see https://github.com/sveltejs/svelte/blob/b62fc8c8fd2640c9b99168f01b9d958cb2f7574f/packages/svelte/src/compiler/compile/Component.js#L211 | ||
rootDir: string(typeof process !== 'undefined' ? process.cwd?.() : undefined), | ||
dev: boolean(false), | ||
@@ -15,0 +19,0 @@ |
@@ -140,7 +140,7 @@ /* This file is generated by scripts/process-messages/index.js. Do not edit! */ | ||
/** | ||
* Visible, non-interactive elements 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. See https://svelte.dev/docs/accessibility-warnings#a11y-click-events-have-key-events for more details. | ||
* Visible, non-interactive elements 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. See https://svelte.dev/docs/accessibility-warnings#a11y-click-events-have-key-events for more details | ||
* @param {null | NodeLike} node | ||
*/ | ||
export function a11y_click_events_have_key_events(node) { | ||
w(node, "a11y_click_events_have_key_events", "Visible, non-interactive elements 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. See https://svelte.dev/docs/accessibility-warnings#a11y-click-events-have-key-events for more details."); | ||
w(node, "a11y_click_events_have_key_events", "Visible, non-interactive elements 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. See https://svelte.dev/docs/accessibility-warnings#a11y-click-events-have-key-events for more details"); | ||
} | ||
@@ -183,7 +183,7 @@ | ||
/** | ||
* Screenreaders already announce `<img>` elements as an image. | ||
* Screenreaders already announce `<img>` elements as an image | ||
* @param {null | NodeLike} node | ||
*/ | ||
export function a11y_img_redundant_alt(node) { | ||
w(node, "a11y_img_redundant_alt", "Screenreaders already announce `<img>` elements as an image."); | ||
w(node, "a11y_img_redundant_alt", "Screenreaders already announce `<img>` elements as an image"); | ||
} | ||
@@ -267,3 +267,3 @@ | ||
/** | ||
* Elements with the '%role%' interactive role must have a tabindex value. | ||
* Elements with the '%role%' interactive role must have a tabindex value | ||
* @param {null | NodeLike} node | ||
@@ -273,3 +273,3 @@ * @param {string} role | ||
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.`); | ||
w(node, "a11y_interactive_supports_focus", `Elements with the '${role}' interactive role must have a tabindex value`); | ||
} | ||
@@ -288,7 +288,7 @@ | ||
/** | ||
* A form label must be associated with a control. | ||
* A form label must be associated with a control | ||
* @param {null | NodeLike} node | ||
*/ | ||
export function a11y_label_has_associated_control(node) { | ||
w(node, "a11y_label_has_associated_control", "A form label must be associated with a control."); | ||
w(node, "a11y_label_has_associated_control", "A form label must be associated with a control"); | ||
} | ||
@@ -371,3 +371,3 @@ | ||
/** | ||
* Non-interactive element `<%element%>` should not be assigned mouse or keyboard event listeners. | ||
* Non-interactive element `<%element%>` should not be assigned mouse or keyboard event listeners | ||
* @param {null | NodeLike} node | ||
@@ -377,3 +377,3 @@ * @param {string} element | ||
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.`); | ||
w(node, "a11y_no_noninteractive_element_interactions", `Non-interactive element \`<${element}>\` should not be assigned mouse or keyboard event listeners`); | ||
} | ||
@@ -708,3 +708,3 @@ | ||
/** | ||
* Using `on:%name%` to listen to the %name% event is deprecated. Use the event attribute `on%name%` instead. | ||
* Using `on:%name%` to listen to the %name% event is deprecated. Use the event attribute `on%name%` instead | ||
* @param {null | NodeLike} node | ||
@@ -714,11 +714,11 @@ * @param {string} name | ||
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.`); | ||
w(node, "event_directive_deprecated", `Using \`on:${name}\` to listen to the ${name} event is deprecated. Use the event attribute \`on${name}\` instead`); | ||
} | ||
/** | ||
* Using `<slot>` to render parent content is deprecated. Use `{@render ...}` tags instead. | ||
* Using `<slot>` to render parent content is deprecated. Use `{@render ...}` tags instead | ||
* @param {null | NodeLike} node | ||
*/ | ||
export function slot_element_deprecated(node) { | ||
w(node, "slot_element_deprecated", "Using `<slot>` to render parent content is deprecated. Use `{@render ...}` tags instead."); | ||
w(node, "slot_element_deprecated", "Using `<slot>` to render parent content is deprecated. Use `{@render ...}` tags instead"); | ||
} |
@@ -37,3 +37,3 @@ import { HYDRATION_END, HYDRATION_START } from '../../../constants.js'; | ||
element.__svelte_meta = { | ||
loc: { filename, line: location[0], column: location[1] } | ||
loc: { file: filename, line: location[0], column: location[1] } | ||
}; | ||
@@ -40,0 +40,0 @@ |
@@ -119,3 +119,3 @@ import { namespace_svg } from '../../../../constants.js'; | ||
loc: { | ||
filename, | ||
file: filename, | ||
line: location[0], | ||
@@ -122,0 +122,0 @@ column: location[1] |
@@ -152,2 +152,3 @@ import { DEV } from 'esm-env'; | ||
if (!delegated) { | ||
// we use `addEventListener` here because these events are not delegated | ||
if (!prev) { | ||
@@ -154,0 +155,0 @@ events.push([key, value, () => element.addEventListener(event_name, value, opts)]); |
@@ -9,3 +9,3 @@ // generated during release, do not modify | ||
*/ | ||
export const VERSION = '5.0.0-next.134'; | ||
export const VERSION = '5.0.0-next.135'; | ||
export const PUBLIC_VERSION = '5'; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2085343
45684