Socket
Socket
Sign inDemoInstall

svelte

Package Overview
Dependencies
18
Maintainers
3
Versions
633
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 5.0.0-next.123 to 5.0.0-next.125

src/internal/client/dev/elements.js

2

package.json

@@ -5,3 +5,3 @@ {

"license": "MIT",
"version": "5.0.0-next.123",
"version": "5.0.0-next.125",
"type": "module",

@@ -8,0 +8,0 @@ "types": "./types/index.d.ts",

@@ -11,2 +11,3 @@ import { walk } from 'zimmerframe';

import { render_stylesheet } from '../css/index.js';
import { getLocator } from 'locate-character';

@@ -51,2 +52,3 @@ /**

node: /** @type {any} */ (null), // populated by the root node
source_locator: getLocator(source, { offsetLine: 1 }),
// these should be set by create_block - if they're called outside, it's a bug

@@ -93,2 +95,10 @@ get before_init() {

},
get locations() {
/** @type {any[]} */
const a = [];
a.push = () => {
throw new Error('locations.push should not be called outside create_block');
};
return a;
},
legacy_reactive_statements: new Map(),

@@ -238,2 +248,3 @@ metadata: {

/** @type {Array<import('estree').Property | import('estree').SpreadElement>} */
const component_returned_object = analysis.exports.map(({ name, alias }) => {

@@ -317,37 +328,3 @@ const expression = serialize_get_binding(b.id(name), instance_state);

} else if (options.dev) {
component_returned_object.push(
b.init(
'$set',
b.thunk(
b.block([
b.throw_error(
`The component shape you get when doing bind:this changed. Updating its properties via $set is no longer valid in Svelte 5. ` +
'See https://svelte-5-preview.vercel.app/docs/breaking-changes#components-are-no-longer-classes for more information'
)
])
)
),
b.init(
'$on',
b.thunk(
b.block([
b.throw_error(
`The component shape you get when doing bind:this changed. Listening to events via $on is no longer valid in Svelte 5. ` +
'See https://svelte-5-preview.vercel.app/docs/breaking-changes#components-are-no-longer-classes for more information'
)
])
)
),
b.init(
'$destroy',
b.thunk(
b.block([
b.throw_error(
`The component shape you get when doing bind:this changed. Destroying such a component via $destroy is no longer valid in Svelte 5. ` +
'See https://svelte-5-preview.vercel.app/docs/breaking-changes#components-are-no-longer-classes for more information'
)
])
)
)
);
component_returned_object.push(b.spread(b.call(b.id('$.legacy_api'))));
}

@@ -470,2 +447,6 @@

if (options.hmr) {
const accept_fn = b.arrow(
[b.id('module')],
b.block([b.stmt(b.call('$.set', b.id('s'), b.member(b.id('module'), b.id('default'))))])
);
body.push(

@@ -478,12 +459,8 @@ component,

b.stmt(b.assignment('=', b.id(analysis.name), b.call('$.hmr', b.id('s')))),
b.stmt(
b.call(
'import.meta.hot.accept',
b.arrow(
[b.id('module')],
b.block([
b.stmt(b.call('$.set', b.id('s'), b.member(b.id('module'), b.id('default'))))
])
)
)
b.if(
b.id('import.meta.hot.acceptExports'),
b.stmt(
b.call('import.meta.hot.acceptExports', b.array([b.literal('default')]), accept_fn)
),
b.stmt(b.call('import.meta.hot.accept', accept_fn))
)

@@ -509,3 +486,3 @@ ])

// add `App.filename = 'App.svelte'` so that we can print useful messages later
body.push(
body.unshift(
b.stmt(

@@ -512,0 +489,0 @@ b.assignment('=', b.member(b.id(analysis.name), b.id('filename')), b.literal(filename))

@@ -11,2 +11,3 @@ import type {

import type { ComponentAnalysis } from '../../types.js';
import type { Location } from 'locate-character';

@@ -27,2 +28,6 @@ export interface ClientTransformState extends TransformState {

export type SourceLocation =
| [line: number, column: number]
| [line: number, column: number, SourceLocation[]];
export interface ComponentClientTransformState extends ClientTransformState {

@@ -33,2 +38,6 @@ readonly analysis: ComponentAnalysis;

readonly events: Set<string>;
readonly source_locator: (
search: string | number,
index?: number | undefined
) => Location | undefined;

@@ -45,2 +54,3 @@ /** Stuff that happens before the render effect(s) */

readonly template: string[];
readonly locations: SourceLocation[];
readonly metadata: {

@@ -47,0 +57,0 @@ namespace: Namespace;

@@ -16,11 +16,9 @@ import is_reference from 'is-reference';

MemberExpression(node, { state, next }) {
if (node.object.type === 'ThisExpression') {
// rewrite `this.#foo` as `this.#foo.v` inside a constructor
if (node.property.type === 'PrivateIdentifier') {
const field = state.private_state.get(node.property.name);
if (field) {
return state.in_constructor ? b.member(node, b.id('v')) : b.call('$.get', node);
}
// rewrite `this.#foo` as `this.#foo.v` inside a constructor
if (node.property.type === 'PrivateIdentifier') {
const field = state.private_state.get(node.property.name);
if (field) {
return state.in_constructor ? b.member(node, b.id('v')) : b.call('$.get', node);
}
} else if (node.object.type === 'ThisExpression') {
// rewrite `this.foo` as `this.#foo.v` inside a constructor

@@ -27,0 +25,0 @@ if (node.property.type === 'Identifier' && !node.computed) {

@@ -283,2 +283,4 @@ import is_reference from 'is-reference';

const skip = () => {};
/**

@@ -678,4 +680,11 @@ * @type {import('zimmerframe').Visitor<import('#compiler').ElementLike, State, import('#compiler').SvelteNode>}

AnimateDirective: SvelteDirective,
UseDirective: SvelteDirective
UseDirective: SvelteDirective,
// @ts-ignore
TSTypeAnnotation: skip,
TSInterfaceDeclaration: skip,
TSTypeAliasDeclaration: skip,
TSTypeParameterDeclaration: skip,
TSEnumDeclaration: skip
// TODO others

@@ -682,0 +691,0 @@ });

@@ -102,3 +102,3 @@ import { regex_is_valid_identifier } from '../phases/patterns.js';

* @param {string | import('estree').Expression} callee
* @param {...(import('estree').Expression | import('estree').SpreadElement)} args
* @param {...(import('estree').Expression | import('estree').SpreadElement | false | undefined)} args
* @returns {import('estree').CallExpression}

@@ -110,3 +110,16 @@ */

while (args.length > 0 && !args.at(-1)) args.pop();
// replacing missing arguments with `undefined`, unless they're at the end in which case remove them
let i = args.length;
let popping = true;
while (i--) {
if (!args[i]) {
if (popping) {
args.pop();
} else {
args[i] = id('undefined');
}
} else {
popping = false;
}
}

@@ -116,3 +129,5 @@ return {

callee,
arguments: args,
arguments: /** @type {Array<import('estree').Expression | import('estree').SpreadElement>} */ (
args
),
optional: false

@@ -119,0 +134,0 @@ };

@@ -5,3 +5,3 @@ /** @typedef {{ file: string, line: number, column: number }} Location */

import { render_effect, user_pre_effect } from '../reactivity/effects.js';
import { dev_current_component_function, set_dev_current_component_function } from '../runtime.js';
import { dev_current_component_function } from '../runtime.js';
import { get_prototype_of } from '../utils.js';

@@ -41,3 +41,3 @@ import * as w from '../warnings.js';

*/
function get_component() {
export function get_component() {
// first 4 lines are svelte internals; adjust this number if we change the internal call stack

@@ -133,8 +133,4 @@ const stack = get_stack()?.slice(4);

export function add_owner_effect(get_object, Component) {
var component = dev_current_component_function;
user_pre_effect(() => {
var prev = dev_current_component_function;
set_dev_current_component_function(component);
add_owner(get_object(), Component);
set_dev_current_component_function(prev);
});

@@ -141,0 +137,0 @@ }

@@ -7,6 +7,8 @@ import { is_promise } from '../../../shared/utils.js';

set_current_effect,
set_current_reaction
set_current_reaction,
set_dev_current_component_function
} from '../../runtime.js';
import { block, branch, destroy_effect, pause_effect } from '../../reactivity/effects.js';
import { INERT } from '../../constants.js';
import { DEV } from 'esm-env';

@@ -24,2 +26,7 @@ /**

const component_context = current_component_context;
/** @type {any} */
let component_function;
if (DEV) {
component_function = component_context?.function ?? null;
}

@@ -46,3 +53,9 @@ /** @type {any} */

set_current_component_context(component_context);
if (DEV) {
set_dev_current_component_function(component_function);
}
var e = branch(() => fn(anchor, value));
if (DEV) {
set_dev_current_component_function(null);
}
set_current_component_context(null);

@@ -49,0 +62,0 @@ set_current_reaction(null);

@@ -12,3 +12,3 @@ import {

import { hydrate_anchor, hydrate_nodes, hydrating, set_hydrating } from '../hydration.js';
import { empty } from '../operations.js';
import { clear_text_content, empty } from '../operations.js';
import { remove } from '../reconciler.js';

@@ -71,3 +71,3 @@ import { untrack } from '../../runtime.js';

var parent_node = /** @type {Element} */ (controlled_anchor.parentNode);
parent_node.textContent = '';
clear_text_content(parent_node);
parent_node.append(controlled_anchor);

@@ -74,0 +74,0 @@ }

import { namespace_svg } from '../../../../constants.js';
import { hydrate_anchor, hydrate_nodes, hydrating } from '../hydration.js';
import { hydrate_anchor, hydrate_nodes, hydrating, set_hydrate_nodes } from '../hydration.js';
import { empty } from '../operations.js';

@@ -15,4 +15,5 @@ import {

import { current_each_item, set_current_each_item } from './each.js';
import { current_effect } from '../../runtime.js';
import { current_component_context, current_effect } from '../../runtime.js';
import { push_template_node } from '../template.js';
import { DEV } from 'esm-env';

@@ -46,7 +47,10 @@ /**

* @param {undefined | (() => string)} get_namespace
* @param {undefined | [number, number]} location
* @returns {void}
*/
export function element(anchor, get_tag, is_svg, render_fn, get_namespace) {
export function element(anchor, get_tag, is_svg, render_fn, get_namespace, location) {
const parent_effect = /** @type {import('#client').Effect} */ (current_effect);
const filename = DEV && location && current_component_context?.function.filename;
render_effect(() => {

@@ -113,2 +117,13 @@ /** @type {string | null} */

if (DEV && location) {
// @ts-expect-error
element.__svelte_meta = {
loc: {
filename,
line: location[0],
column: location[1]
}
};
}
if (render_fn) {

@@ -121,2 +136,8 @@ // If hydrating, use the existing ssr comment as the anchor so that the

if (hydrating && !element.firstChild) {
// if the element is a void element with content, add an empty
// node to avoid breaking assumptions elsewhere
set_hydrate_nodes([empty()]);
}
// `child_anchor` is undefined if this is a void element, but we still

@@ -123,0 +144,0 @@ // need to call `render_fn` in order to run actions etc. If the element

@@ -19,4 +19,8 @@ import { DEV } from 'esm-env';

if (hydrating) {
// using getAttribute instead of dom.value allows us to have
// null instead of "on" if the user didn't set a value
const value = dom.getAttribute('value');
set_attribute(dom, 'value', null);
set_attribute(dom, 'checked', null);
if (value) dom.value = value;
}

@@ -23,0 +27,0 @@ }

@@ -35,3 +35,5 @@ import { render_effect } from '../../../reactivity/effects.js';

render_effect(() => {
latest_value = get_value() || 0;
latest_value = get_value();
if (latest_value === undefined) return;
if (!scrolling) {

@@ -38,0 +40,0 @@ scrolling = true;

@@ -196,3 +196,3 @@ import { createClassComponent } from '../../../../legacy/legacy-client.js';

Promise.resolve().then(() => {
if (!this.$$cn) {
if (!this.$$cn && this.$$c) {
this.$$c.$destroy();

@@ -199,0 +199,0 @@ destroy_effect(this.$$me);

import { hydrating } from '../hydration.js';
import { effect } from '../../reactivity/effects.js';
import { clear_text_content } from '../operations.js';

@@ -30,4 +31,4 @@ /**

if (hydrating && dom.firstChild !== null) {
dom.textContent = '';
clear_text_content(dom);
}
}
import { hydrate_anchor, hydrate_nodes, hydrating } from './hydration.js';
import { get_descriptor } from '../utils.js';
import { DEV } from 'esm-env';

@@ -73,2 +74,7 @@ // We cache the Node and Element prototype methods, so that we can avoid doing

if (DEV) {
// @ts-expect-error
element_prototype.__svelte_meta = null;
}
first_child_get = /** @type {(this: Node) => ChildNode | null} */ (

@@ -75,0 +81,0 @@ // @ts-ignore

@@ -60,2 +60,21 @@ /* This file is generated by scripts/process-messages/index.js. Do not edit! */

/**
* %parent% called `%method%` on an instance of %component%, which is no longer valid in Svelte 5. See https://svelte-5-preview.vercel.app/docs/breaking-changes#components-are-no-longer-classes for more information
* @param {string} parent
* @param {string} method
* @param {string} component
* @returns {never}
*/
export function component_api_changed(parent, method, component) {
if (DEV) {
const error = new Error(`${"component_api_changed"}\n${`${parent} called \`${method}\` on an instance of ${component}, which is no longer valid in Svelte 5. See https://svelte-5-preview.vercel.app/docs/breaking-changes#components-are-no-longer-classes for more information`}`);
error.name = 'Svelte error';
throw error;
} else {
// TODO print a link to the documentation
throw new Error("component_api_changed");
}
}
/**
* Keyed each block has duplicate key `%value%` at indexes %a% and %b%

@@ -62,0 +81,0 @@ * @param {string} a

@@ -0,1 +1,2 @@

export { add_locations } from './dev/elements.js';
export { hmr } from './dev/hmr.js';

@@ -9,2 +10,3 @@ export {

} from './dev/ownership.js';
export { legacy_api } from './dev/legacy.js';
export { inspect } from './dev/inspect.js';

@@ -11,0 +13,0 @@ export { await_block as await } from './dom/blocks/await.js';

@@ -7,2 +7,3 @@ import {

destroy_effect_children,
dev_current_component_function,
execute_effect,

@@ -34,2 +35,3 @@ get,

import * as e from '../errors.js';
import { DEV } from 'esm-env';

@@ -91,2 +93,6 @@ /**

if (DEV) {
effect.component_function = dev_current_component_function;
}
if (current_reaction !== null && !is_root) {

@@ -93,0 +99,0 @@ push_effect(effect, current_reaction);

@@ -52,2 +52,4 @@ import type { ComponentContext, Dom, Equals, TransitionManager } from '#client';

next: null | Effect;
/** Dev only */
component_function?: any;
}

@@ -54,0 +56,0 @@

@@ -116,5 +116,2 @@ import { DEV } from 'esm-env';

current_component_context = context;
if (DEV) {
dev_current_component_function = context?.function;
}
}

@@ -204,7 +201,2 @@

update_derived(/** @type {import('#client').Derived} **/ (dependency), true);
// `signal` might now be dirty, as a result of calling `update_derived`
if ((reaction.f & DIRTY) !== 0) {
return true;
}
}

@@ -235,2 +227,5 @@

}
} else if ((reaction.f & DIRTY) !== 0) {
// `signal` might now be dirty, as a result of calling `check_dirtiness` and/or `update_derived`
return true;
}

@@ -426,4 +421,9 @@ }

current_effect = effect;
set_current_component_context(component_context);
current_component_context = component_context;
if (DEV) {
var previous_component_fn = dev_current_component_function;
dev_current_component_function = effect.component_function;
}
try {

@@ -439,3 +439,7 @@ if ((flags & BLOCK_EFFECT) === 0) {

current_effect = previous_effect;
set_current_component_context(previous_component_context);
current_component_context = previous_component_context;
if (DEV) {
dev_current_component_function = previous_component_fn;
}
}

@@ -1015,3 +1019,3 @@ }

export function update(signal, d = 1) {
const value = get(signal);
var value = +get(signal);
set(signal, value + d);

@@ -1027,5 +1031,3 @@ return value;

export function update_pre(signal, d = 1) {
const value = get(signal) + d;
set(signal, value);
return value;
return set(signal, +get(signal) + d);
}

@@ -1118,3 +1120,6 @@

}
set_current_component_context(context_stack_item.p);
current_component_context = context_stack_item.p;
if (DEV) {
dev_current_component_function = context_stack_item.p?.function ?? null;
}
context_stack_item.m = true;

@@ -1121,0 +1126,0 @@ }

@@ -9,3 +9,3 @@ // generated during release, do not modify

*/
export const VERSION = '5.0.0-next.123';
export const VERSION = '5.0.0-next.125';
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 not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc