Socket
Socket
Sign inDemoInstall

svelte

Package Overview
Dependencies
Maintainers
3
Versions
727
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

svelte - npm Package Compare versions

Comparing version 5.0.0-next.236 to 5.0.0-next.237

2

package.json

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

"license": "MIT",
"version": "5.0.0-next.236",
"version": "5.0.0-next.237",
"type": "module",

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

@@ -109,3 +109,3 @@ /** @import { LegacyRoot } from './types/legacy-nodes.js' */

state.reset_warning_filter(() => false);
state.reset(source, { filename, rootDir }); // TODO it's weird to require filename/rootDir here. reconsider the API
state.reset(source, { filename: filename ?? '(unknown)', rootDir });

@@ -112,0 +112,0 @@ const ast = _parse(source);

@@ -246,3 +246,3 @@ /** @import { Expression, Node, Program } from 'estree' */

module: { ast, scope, scopes },
name: options.filename || 'module',
name: options.filename,
accessors: false,

@@ -353,3 +353,3 @@ runes: true,

const component_name = get_component_name(options.filename ?? 'Component');
const component_name = get_component_name(options.filename);

@@ -395,3 +395,3 @@ const runes = options.runes ?? Array.from(module.scope.references.keys()).some(is_rune);

css: root.css.content.styles,
filename: options.filename ?? '<unknown>',
filename: options.filename,
name: component_name,

@@ -398,0 +398,0 @@ hash

@@ -508,10 +508,8 @@ /** @import * as ESTree from 'estree' */

if (dev) {
if (filename) {
// add `App[$.FILENAME] = 'App.svelte'` so that we can print useful messages later
body.unshift(
b.stmt(
b.assignment('=', b.member(b.id(analysis.name), '$.FILENAME', true), b.literal(filename))
)
);
}
// add `App[$.FILENAME] = 'App.svelte'` so that we can print useful messages later
body.unshift(
b.stmt(
b.assignment('=', b.member(b.id(analysis.name), '$.FILENAME', true), b.literal(filename))
)
);

@@ -518,0 +516,0 @@ body.unshift(b.stmt(b.call(b.id('$.mark_module_start'))));

@@ -60,16 +60,2 @@ /** @import { AssignmentExpression, AssignmentOperator, Expression, Pattern } from 'estree' */

}
} else if (left.property.type === 'Identifier' && context.state.in_constructor) {
const public_state = context.state.public_state.get(left.property.name);
if (public_state !== undefined && should_proxy(right, context.state.scope)) {
const value = /** @type {Expression} */ (context.visit(right));
return b.assignment(
operator,
/** @type {Pattern} */ (context.visit(left)),
public_state.kind === 'raw_state'
? value
: build_proxy_reassignment(value, public_state.id)
);
}
}

@@ -76,0 +62,0 @@ }

@@ -16,11 +16,2 @@ /** @import { MemberExpression } from 'estree' */

}
} else if (node.object.type === 'ThisExpression') {
// rewrite `this.foo` as `this.#foo.v` inside a constructor
if (node.property.type === 'Identifier' && !node.computed) {
const field = context.state.public_state.get(node.property.name);
if (field && context.state.in_constructor) {
return b.member(b.member(b.this, field.id), 'v');
}
}
}

@@ -27,0 +18,0 @@

@@ -83,3 +83,3 @@ /** @import { ValidatedCompileOptions, CompileResult, ValidatedModuleCompileOptions } from '#compiler' */

const basename = (options.filename ?? 'Module').split(/[/\\]/).at(-1);
const basename = options.filename.split(/[/\\]/).at(-1);
if (program.body.length > 0) {

@@ -86,0 +86,0 @@ program.body[0].leadingComments = [

@@ -359,3 +359,3 @@ /** @import { Program, Property, Statement, VariableDeclarator } from 'estree' */

if (dev && filename) {
if (dev) {
// add `App[$.FILENAME] = 'App.svelte'` so that we can print useful messages later

@@ -362,0 +362,0 @@ body.unshift(

@@ -11,5 +11,5 @@ /** @import { CompileOptions, SvelteNode } from './types' */

/**
* The filename (if specified in the compiler options) relative to the rootDir (if specified).
* The filename relative to the rootDir (if specified).
* This should not be used in the compiler output except in dev mode
* @type {string | undefined}
* @type {string}
*/

@@ -81,3 +81,3 @@ export let filename;

* @param {string} _source
* @param {{ dev?: boolean; filename?: string; rootDir?: string }} options
* @param {{ dev?: boolean; filename: string; rootDir?: string }} options
*/

@@ -87,11 +87,7 @@ export function reset(_source, options) {

const root_dir = options.rootDir?.replace(/\\/g, '/');
filename = options.filename?.replace(/\\/g, '/');
filename = options.filename.replace(/\\/g, '/');
dev = !!options.dev;
if (
typeof filename === 'string' &&
typeof root_dir === 'string' &&
filename.startsWith(root_dir)
) {
if (typeof root_dir === 'string' && filename.startsWith(root_dir)) {
// make filename relative to rootDir

@@ -98,0 +94,0 @@ filename = filename.replace(root_dir, '').replace(/^[/\\]/, '');

@@ -59,3 +59,3 @@ import type {

name: string;
filename: string | undefined;
filename: string;
css: string;

@@ -223,7 +223,3 @@ hash: (input: string) => string;

export type ValidatedModuleCompileOptions = Omit<
Required<ModuleCompileOptions>,
'filename' | 'rootDir'
> & {
filename: ModuleCompileOptions['filename'];
export type ValidatedModuleCompileOptions = Omit<Required<ModuleCompileOptions>, 'rootDir'> & {
rootDir: ModuleCompileOptions['rootDir'];

@@ -230,0 +226,0 @@ };

@@ -396,3 +396,3 @@ /** @import { ValidatedCompileOptions } from '#compiler' */

if (options.sourcemap) {
const file_basename = get_basename(options.filename || 'input.svelte');
const file_basename = get_basename(options.filename);
// The preprocessor map is expected to contain `sources: [basename_of_filename]`, but our own

@@ -446,3 +446,3 @@ // map may contain a different file name. Patch our map beforehand to align sources so merging

/**
* @param {string | undefined} filename
* @param {string} filename
* @param {string | undefined} output_filename

@@ -452,4 +452,3 @@ * @param {string} fallback

export function get_source_name(filename, output_filename, fallback) {
if (!filename) return fallback;
return output_filename ? get_relative_path(output_filename, filename) : get_basename(filename);
}

@@ -12,3 +12,3 @@ /** @import { ModuleCompileOptions, ValidatedModuleCompileOptions, CompileOptions, ValidatedCompileOptions } from '#compiler' */

const common = {
filename: string(undefined),
filename: string('(unknown)'),

@@ -15,0 +15,0 @@ // default to process.cwd() where it exists to replicate svelte4 behavior

@@ -20,2 +20,4 @@ // This should contain all the public interfaces (not all of them are actually importable, check current Svelte for which ones are).

intro?: boolean;
recover?: boolean;
sync?: boolean;
$$inline?: boolean;

@@ -22,0 +24,0 @@ }

@@ -313,7 +313,3 @@ /** @import { Location } from 'locate-character' */

const filename = component?.[FILENAME];
const location = filename
? loc
? ` at ${filename}:${loc[0]}:${loc[1]}`
: ` in ${filename}`
: '';
const location = loc ? ` at ${filename}:${loc[0]}:${loc[1]}` : ` in ${filename}`;

@@ -320,0 +316,0 @@ const event_name = args[0].type;

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

/**
* Reading state that was created inside the same derived is forbidden. Consider using `untrack` to read locally created state
* @returns {never}
*/
export function state_unsafe_local_read() {
if (DEV) {
const error = new Error(`state_unsafe_local_read\nReading state that was created inside the same derived is forbidden. Consider using \`untrack\` to read locally created state`);
error.name = 'Svelte error';
throw error;
} else {
// TODO print a link to the documentation
throw new Error("state_unsafe_local_read");
}
}
/**
* Updating state inside a derived is forbidden. If the value should not be reactive, declare it without `$state`

@@ -316,0 +332,0 @@ * @returns {never}

@@ -121,3 +121,3 @@ /** @import { ProxyMetadata, ProxyStateObject, Source } from '#client' */

if (s === undefined && (!exists || get_descriptor(target, prop)?.writable)) {
s = source(proxy(exists ? target[prop] : UNINITIALIZED, metadata));
s = source(proxy(exists ? target[prop] : UNINITIALIZED, metadata), null);
sources.set(prop, s);

@@ -174,3 +174,3 @@ }

if (s === undefined) {
s = source(has ? proxy(target[prop], metadata) : UNINITIALIZED);
s = source(has ? proxy(target[prop], metadata) : UNINITIALIZED, null);
sources.set(prop, s);

@@ -177,0 +177,0 @@ }

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

/** @import { Derived, Effect, Source, Value } from '#client' */
/** @import { Derived, Effect, Reaction, Source, Value } from '#client' */
import { DEV } from 'esm-env';

@@ -16,3 +16,5 @@ import {

increment_version,
update_effect
update_effect,
derived_sources,
set_derived_sources
} from '../runtime.js';

@@ -36,7 +38,8 @@ import { equals, safe_equals } from './equality.js';

* @param {V} v
* @param {Reaction | null} [owner]
* @returns {Source<V>}
*/
/*#__NO_SIDE_EFFECTS__*/
export function source(v) {
return {
export function source(v, owner = current_reaction) {
var source = {
f: 0, // TODO ideally we could skip this altogether, but it causes type errors

@@ -48,2 +51,12 @@ v,

};
if (owner !== null && (owner.f & DERIVED) !== 0) {
if (derived_sources === null) {
set_derived_sources([source]);
} else {
derived_sources.push(source);
}
}
return source;
}

@@ -54,7 +67,8 @@

* @param {V} initial_value
* @param {Reaction | null} [owner]
* @returns {Source<V>}
*/
/*#__NO_SIDE_EFFECTS__*/
export function mutable_source(initial_value) {
const s = source(initial_value);
export function mutable_source(initial_value, owner) {
const s = source(initial_value, owner);
s.equals = safe_equals;

@@ -91,3 +105,10 @@

export function set(source, value) {
if (current_reaction !== null && is_runes() && (current_reaction.f & DERIVED) !== 0) {
if (
current_reaction !== null &&
is_runes() &&
(current_reaction.f & DERIVED) !== 0 &&
// If the source was created locally within the current derived, then
// we allow the mutation.
(derived_sources === null || !derived_sources.includes(source))
) {
e.state_unsafe_mutation();

@@ -94,0 +115,0 @@ }

@@ -22,3 +22,3 @@ /** @import { StoreReferencesContainer } from '#client' */

store: null,
source: mutable_source(undefined),
source: mutable_source(undefined, null),
unsubscribe: noop

@@ -25,0 +25,0 @@ });

@@ -84,2 +84,16 @@ /** @import { ComponentContext, Derived, Effect, Reaction, Signal, Source, Value } from '#client' */

/**
* When sources are created within a derived, we record them so that we can safely allow
* local mutations to these sources without the side-effect error being invoked unnecessarily.
* @type {null | Source[]}
*/
export let derived_sources = null;
/**
* @param {Source[] | null} sources
*/
export function set_derived_sources(sources) {
derived_sources = sources;
}
/**
* The dependencies of the reaction that is currently being executed. In many cases,

@@ -234,8 +248,10 @@ * the dependencies are unchanged between runs, and so this will be `null` unless

while (current_context !== null) {
/** @type {string} */
var filename = current_context.function?.[FILENAME];
if (DEV) {
/** @type {string} */
var filename = current_context.function?.[FILENAME];
if (filename) {
const file = filename.split('/').pop();
component_stack.push(file);
if (filename) {
const file = filename.split('/').pop();
component_stack.push(file);
}
}

@@ -284,2 +300,3 @@

var previous_skip_reaction = current_skip_reaction;
var prev_derived_sources = derived_sources;

@@ -291,2 +308,3 @@ new_deps = /** @type {null | Value[]} */ (null);

current_skip_reaction = !is_flushing_effect && (reaction.f & UNOWNED) !== 0;
derived_sources = null;

@@ -328,2 +346,3 @@ try {

current_skip_reaction = previous_skip_reaction;
derived_sources = prev_derived_sources;
}

@@ -706,2 +725,5 @@ }

if (current_reaction !== null) {
if (derived_sources !== null && derived_sources.includes(signal)) {
e.state_unsafe_local_read();
}
var deps = current_reaction.deps;

@@ -708,0 +730,0 @@

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

if (effect.deps === null) {
var location = filename && `${filename}:${line}:${column}`;
var location = `${filename}:${line}:${column}`;
w.binding_property_non_reactive(binding, location);

@@ -108,0 +108,0 @@

@@ -59,2 +59,5 @@ /** @import { Snapshot } from './types' */

if (value instanceof Map) return /** @type {Snapshot<T>} */ (new Map(value));
if (value instanceof Set) return /** @type {Snapshot<T>} */ (new Set(value));
if (is_array(value)) {

@@ -61,0 +64,0 @@ const copy = /** @type {Snapshot<any>} */ ([]);

@@ -20,5 +20,2 @@ /** @import { ComponentConstructorOptions, ComponentType, SvelteComponent, Component } from 'svelte' */

* component: ComponentType<SvelteComponent<Props, Events, Slots>> | Component<Props>;
* immutable?: boolean;
* hydrate?: boolean;
* recover?: boolean;
* }} options

@@ -68,5 +65,2 @@ * @returns {SvelteComponent<Props, Events, Slots> & Exports}

* component: any;
* immutable?: boolean;
* hydrate?: boolean;
* recover?: false;
* }} options

@@ -115,4 +109,4 @@ */

// We don't flush_sync for custom element wrappers
if (!options?.props?.$$host) {
// We don't flush_sync for custom element wrappers or if the user doesn't want it
if (!options?.props?.$$host || options.sync === false) {
flush_sync();

@@ -119,0 +113,0 @@ }

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

*/
export const VERSION = '5.0.0-next.236';
export const VERSION = '5.0.0-next.237';
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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc