Socket
Socket
Sign inDemoInstall

svelte

Package Overview
Dependencies
Maintainers
3
Versions
752
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.264 to 5.0.0-next.265

4

package.json

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

"license": "MIT",
"version": "5.0.0-next.264",
"version": "5.0.0-next.265",
"type": "module",

@@ -119,3 +119,3 @@ "types": "./types/index.d.ts",

"esbuild": "^0.21.5",
"rollup": "^4.21.0",
"rollup": "^4.22.4",
"source-map": "^0.7.4",

@@ -122,0 +122,0 @@ "tiny-glob": "^0.2.9",

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

export function compile(source, options) {
source = remove_bom(source);
state.reset_warning_filter(options.warningFilter);

@@ -62,2 +63,3 @@ const validated = validate_component_options(options, '');

export function compileModule(source, options) {
source = remove_bom(source);
state.reset_warning_filter(options.warningFilter);

@@ -106,2 +108,3 @@ const validated = validate_module_options(options, '');

export function parse(source, { filename, rootDir, modern } = {}) {
source = remove_bom(source);
state.reset_warning_filter(() => false);

@@ -147,2 +150,13 @@ state.reset(source, { filename: filename ?? '(unknown)', rootDir });

/**
* Remove the byte order mark from a string if it's present since it would mess with our template generation logic
* @param {string} source
*/
function remove_bom(source) {
if (source.charCodeAt(0) === 0xfeff) {
return source.slice(1);
}
return source;
}
/**
* @deprecated Replace this with `import { walk } from 'estree-walker'`

@@ -149,0 +163,0 @@ * @returns {never}

@@ -45,3 +45,3 @@ /** @import { VariableDeclarator, Node, Identifier, AssignmentExpression, LabeledStatement, ExpressionStatement } from 'estree' */

reset_warning_filter(() => false);
reset(source, { filename: filename ?? 'migrate.svelte' });
reset(source, { filename: filename ?? '(unknown)' });

@@ -56,3 +56,4 @@ let parsed = parse(source);

...parsed_options,
customElementOptions
customElementOptions,
filename: filename ?? '(unknown)'
};

@@ -97,4 +98,3 @@

passive: analysis.root.unique('passive').name,
nonpassive: analysis.root.unique('nonpassive').name,
svelte_self: analysis.root.unique('SvelteSelf').name
nonpassive: analysis.root.unique('nonpassive').name
},

@@ -143,3 +143,3 @@ legacy_imports: new Set(),

insertion_point,
`\n${indent}import ${state.names.svelte_self} from './${file}';`
`\n${indent}import ${state.analysis.name} from './${file}';`
);

@@ -766,3 +766,3 @@ }

node.start + 1 + 'svelte:self'.length,
`${state.names.svelte_self}`
`${state.analysis.name}`
);

@@ -774,3 +774,3 @@ // if it has a fragment we need to overwrite the closing tag too

node.end - 1,
`${state.names.svelte_self}`
`${state.analysis.name}`
);

@@ -783,3 +783,3 @@ } else if (!source.endsWith('/>')) {

node.end - 1,
`${state.names.svelte_self}`
`${state.analysis.name}`
);

@@ -786,0 +786,0 @@ }

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

// include source content; makes it easier/more robust looking up the source map code
// (else esrap does return null for source and sourceMapContent which may trip up tooling)
sourceMapContent: source,

@@ -95,3 +96,8 @@ sourceMapSource: js_source_name

return {
js: print(program, {}),
js: print(program, {
// include source content; makes it easier/more robust looking up the source map code
// (else esrap does return null for source and sourceMapContent which may trip up tooling)
sourceMapContent: source,
sourceMapSource: get_source_name(options.filename, undefined, 'input.svelte.js')
}),
css: null,

@@ -98,0 +104,0 @@ metadata: {

@@ -135,2 +135,4 @@ /** @import { EachItem, EachState, Effect, MaybeSource, Source, TemplateNode, TransitionManager, Value } from '#client' */

var was_empty = false;
block(() => {

@@ -147,2 +149,9 @@ var collection = get_collection();

if (was_empty && length === 0) {
// ignore updates if the array is empty,
// and it already was empty on previous run
return;
}
was_empty = length === 0;
/** `true` if there was a hydration mismatch. Needs to be a `let` or else it isn't treeshaken out */

@@ -149,0 +158,0 @@ let mismatch = false;

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

var attributes = (element.__attributes ??= {});
if (attributes.value === (attributes.value = value)) return;
// @ts-expect-error
if (attributes.value === (attributes.value = value) || element.value === value) return;
// @ts-expect-error
element.value = value;

@@ -63,0 +63,0 @@ }

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

// @ts-expect-error the value is coerced on assignment
input.value = value ?? '';
// don't set the value of the input if it's the same to allow
// minlength to work properly
if (value !== input.value) {
// @ts-expect-error the value is coerced on assignment
input.value = value ?? '';
}
});

@@ -67,0 +71,0 @@ }

@@ -107,2 +107,12 @@ /** @import { ProxyMetadata, ProxyStateObject, Source } from '#client' */

} else {
// When working with arrays, we need to also ensure we update the length when removing
// an indexed property
if (is_proxied_array && typeof prop === 'string') {
var ls = /** @type {Source<number>} */ (sources.get('length'));
var n = Number(prop);
if (Number.isInteger(n) && n < ls.v) {
set(ls, n);
}
}
set(s, UNINITIALIZED);

@@ -109,0 +119,0 @@ update_version(version);

@@ -61,2 +61,5 @@ /** @import { Derived, Effect } from '#client' */

}
if (active_effect !== null) {
(active_effect.deriveds ??= []).push(signal);
}

@@ -107,6 +110,7 @@ return signal;

/**
* @template T
* @param {Derived} derived
* @returns {void}
* @returns {T}
*/
export function update_derived(derived) {
export function execute_derived(derived) {
var value;

@@ -143,2 +147,11 @@ var prev_active_effect = active_effect;

return value;
}
/**
* @param {Derived} derived
* @returns {void}
*/
export function update_derived(derived) {
var value = execute_derived(derived);
var status =

@@ -159,3 +172,3 @@ (skip_reaction || (derived.f & UNOWNED) !== 0) && derived.deps !== null ? MAYBE_DIRTY : CLEAN;

*/
function destroy_derived(signal) {
export function destroy_derived(signal) {
destroy_derived_children(signal);

@@ -166,9 +179,3 @@ remove_reactions(signal, 0);

// TODO we need to ensure we remove the derived from any parent derives
signal.children =
signal.deps =
signal.reactions =
// @ts-expect-error `signal.fn` cannot be `null` while the signal is alive
signal.fn =
null;
signal.v = signal.children = signal.deps = signal.reactions = null;
}

@@ -100,2 +100,3 @@ /** @import { ComponentContext, ComponentContextLegacy, Derived, Effect, Reaction, TemplateNode, TransitionManager } from '#client' */

deps: null,
deriveds: null,
nodes_start: null,

@@ -102,0 +103,0 @@ nodes_end: null,

@@ -13,6 +13,13 @@ /** @import { Source } from './types.js' */

import { derived, derived_safe_equal } from './deriveds.js';
import { get, is_signals_recorded, untrack, update } from '../runtime.js';
import {
active_effect,
get,
is_signals_recorded,
set_active_effect,
untrack,
update
} from '../runtime.js';
import { safe_equals } from './equality.js';
import * as e from '../errors.js';
import { LEGACY_DERIVED_PROP } from '../constants.js';
import { BRANCH_EFFECT, LEGACY_DERIVED_PROP, ROOT_EFFECT } from '../constants.js';
import { proxy } from '../proxy.js';

@@ -222,2 +229,22 @@

/**
* @template T
* @param {() => T} fn
* @returns {T}
*/
function with_parent_branch(fn) {
var effect = active_effect;
var previous_effect = active_effect;
while (effect !== null && (effect.f & (BRANCH_EFFECT | ROOT_EFFECT)) === 0) {
effect = effect.parent;
}
try {
set_active_effect(effect);
return fn();
} finally {
set_active_effect(previous_effect);
}
}
/**
* This function is responsible for synchronizing a possibly bound prop with the inner component state.

@@ -281,4 +308,4 @@ * It is used whenever the compiler sees that the component writes to the prop, or when it has a default prop_value.

// Replicate that behavior through using a derived
var derived_getter = (immutable ? derived : derived_safe_equal)(
() => /** @type {V} */ (props[key])
var derived_getter = with_parent_branch(() =>
(immutable ? derived : derived_safe_equal)(() => /** @type {V} */ (props[key]))
);

@@ -327,15 +354,17 @@ derived_getter.f |= LEGACY_DERIVED_PROP;

var inner_current_value = mutable_source(prop_value);
var current_value = derived(() => {
var parent_value = getter();
var child_value = get(inner_current_value);
var current_value = with_parent_branch(() =>
derived(() => {
var parent_value = getter();
var child_value = get(inner_current_value);
if (from_child) {
from_child = false;
was_from_child = true;
return child_value;
}
if (from_child) {
from_child = false;
was_from_child = true;
return child_value;
}
was_from_child = false;
return (inner_current_value.v = parent_value);
});
was_from_child = false;
return (inner_current_value.v = parent_value);
})
);

@@ -342,0 +371,0 @@ if (!immutable) current_value.equals = safe_equals;

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

ctx: null | ComponentContext;
/** Reactions created inside this signal */
deriveds: null | Derived[];
/** The effect function */

@@ -47,0 +49,0 @@ fn: null | (() => void | (() => void));

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

import { mutate, set, source } from './reactivity/sources.js';
import { update_derived } from './reactivity/deriveds.js';
import { destroy_derived, execute_derived, update_derived } from './reactivity/deriveds.js';
import * as e from './errors.js';

@@ -304,2 +304,3 @@ import { lifecycle_outside_component } from '../shared/errors.js';

var prev_derived_sources = derived_sources;
var flags = reaction.f;

@@ -309,4 +310,4 @@ new_deps = /** @type {null | Value[]} */ (null);

untracked_writes = null;
active_reaction = (reaction.f & (BRANCH_EFFECT | ROOT_EFFECT)) === 0 ? reaction : null;
skip_reaction = !is_flushing_effect && (reaction.f & UNOWNED) !== 0;
active_reaction = (flags & (BRANCH_EFFECT | ROOT_EFFECT)) === 0 ? reaction : null;
skip_reaction = !is_flushing_effect && (flags & UNOWNED) !== 0;
derived_sources = null;

@@ -414,2 +415,12 @@

export function destroy_effect_children(signal, remove_dom = false) {
var deriveds = signal.deriveds;
if (deriveds !== null) {
signal.deriveds = null;
for (var i = 0; i < deriveds.length; i += 1) {
destroy_derived(deriveds[i]);
}
}
var effect = signal.first;

@@ -426,2 +437,18 @@ signal.first = signal.last = null;

/**
* @param {Effect} signal
* @returns {void}
*/
export function destroy_block_effect_children(signal) {
var effect = signal.first;
while (effect !== null) {
var next = effect.next;
if ((effect.f & BRANCH_EFFECT) === 0) {
destroy_effect(effect);
}
effect = next;
}
}
/**
* @param {Effect} effect

@@ -451,3 +478,5 @@ * @returns {void}

try {
if ((flags & BLOCK_EFFECT) === 0) {
if ((flags & BLOCK_EFFECT) !== 0) {
destroy_block_effect_children(effect);
} else {
destroy_effect_children(effect);

@@ -738,5 +767,11 @@ }

var flags = signal.f;
var is_derived = (flags & DERIVED) !== 0;
if ((flags & DESTROYED) !== 0) {
return signal.v;
// If the derived is destroyed, just execute it again without retaining
// its memoisation properties as the derived is stale
if (is_derived && (flags & DESTROYED) !== 0) {
var value = execute_derived(/** @type {Derived} */ (signal));
// Ensure the derived remains destroyed
destroy_derived(/** @type {Derived} */ (signal));
return value;
}

@@ -778,3 +813,3 @@

if ((flags & DERIVED) !== 0) {
if (is_derived) {
var derived = /** @type {Derived} */ (signal);

@@ -781,0 +816,0 @@

@@ -510,5 +510,8 @@ /** @import { ComponentType, SvelteComponent } from 'svelte' */

export function ensure_array_like(array_like_or_iterator) {
return array_like_or_iterator?.length !== undefined
? array_like_or_iterator
: Array.from(array_like_or_iterator);
if (array_like_or_iterator) {
return array_like_or_iterator.length !== undefined
? array_like_or_iterator
: Array.from(array_like_or_iterator);
}
return [];
}

@@ -515,0 +518,0 @@

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

*/
export const VERSION = '5.0.0-next.264';
export const VERSION = '5.0.0-next.265';
export const PUBLIC_VERSION = '5';

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