Socket
Socket
Sign inDemoInstall

svelte

Package Overview
Dependencies
Maintainers
3
Versions
738
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.158 to 5.0.0-next.159

2

package.json

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

"license": "MIT",
"version": "5.0.0-next.158",
"version": "5.0.0-next.159",
"type": "module",

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

@@ -114,6 +114,6 @@ import is_reference from 'is-reference';

const parent = path.at(-1);
if (parent == null) {
return non_hoistable;
}
if (parent == null) return non_hoistable;
const grandparent = path.at(-2);
/** @type {import('#compiler').RegularElement | null} */

@@ -124,10 +124,11 @@ let element = null;

if (parent.type === 'OnDirective') {
element = /** @type {import('#compiler').RegularElement} */ (path.at(-2));
element = /** @type {import('#compiler').RegularElement} */ (grandparent);
event_name = parent.name;
} else if (
parent.type === 'ExpressionTag' &&
is_event_attribute(/** @type {import('#compiler').Attribute} */ (path.at(-2)))
grandparent?.type === 'Attribute' &&
is_event_attribute(grandparent)
) {
element = /** @type {import('#compiler').RegularElement} */ (path.at(-3));
const attribute = /** @type {import('#compiler').Attribute} */ (path.at(-2));
const attribute = /** @type {import('#compiler').Attribute} */ (grandparent);
event_name = get_attribute_event_name(attribute.name);

@@ -134,0 +135,0 @@ }

@@ -19,2 +19,3 @@ export const DERIVED = 1 << 1;

export const LEGACY_DERIVED_PROP = 1 << 16;
export const INSPECT_EFFECT = 1 << 17;

@@ -21,0 +22,0 @@ export const STATE_SYMBOL = Symbol('$state');

@@ -1,18 +0,5 @@

import { DEV } from 'esm-env';
import { snapshot } from '../proxy.js';
import { render_effect, validate_effect } from '../reactivity/effects.js';
import { deep_read, untrack } from '../runtime.js';
import { inspect_effect, validate_effect } from '../reactivity/effects.js';
import { array_prototype, get_prototype_of, object_prototype } from '../utils.js';
/** @type {Function | null} */
export let inspect_fn = null;
/** @param {Function | null} fn */
export function set_inspect_fn(fn) {
inspect_fn = fn;
}
/** @type {Array<import('#client').ValueDebug>} */
export let inspect_captured_signals = [];
/**

@@ -28,28 +15,5 @@ * @param {() => any[]} get_value

// we assign the function directly to signals, rather than just
// calling `inspector` directly inside the effect, so that
// we get useful stack traces
var fn = () => {
const value = untrack(() => deep_snapshot(get_value()));
inspector(initial ? 'init' : 'update', ...value);
};
render_effect(() => {
inspect_fn = fn;
deep_read(get_value());
inspect_fn = null;
const signals = inspect_captured_signals.slice();
inspect_captured_signals = [];
if (initial) {
fn();
initial = false;
}
return () => {
for (const s of signals) {
s.inspect.delete(fn);
}
};
inspect_effect(() => {
inspector(initial ? 'init' : 'update', ...deep_snapshot(get_value()));
initial = false;
});

@@ -56,0 +20,0 @@ }

@@ -42,11 +42,9 @@ import { add_snippet_symbol } from '../../../shared/validate.js';

* @param {(node: import('#client').TemplateNode, ...args: any[]) => import('#client').Dom} fn
* @returns
* @param {any} component
*/
export function wrap_snippet(fn) {
let component = /** @type {import('#client').ComponentContext} */ (current_component_context);
export function wrap_snippet(fn, component) {
return add_snippet_symbol(
(/** @type {import('#client').TemplateNode} */ node, /** @type {any[]} */ ...args) => {
var previous_component_function = dev_current_component_function;
set_dev_current_component_function(component.function);
set_dev_current_component_function(component);

@@ -53,0 +51,0 @@ try {

@@ -19,25 +19,36 @@ import { DEV } from 'esm-env';

* to remove it upon hydration to avoid a bug when someone resets the form value.
* @param {HTMLInputElement} dom
* @param {HTMLInputElement} input
* @returns {void}
*/
export function remove_input_attr_defaults(dom) {
if (hydrating) {
let already_removed = false;
// We try and remove the default attributes later, rather than sync during hydration.
// Doing it sync during hydration has a negative impact on performance, but deferring the
// work in an idle task alleviates this greatly. If a form reset event comes in before
// the idle callback, then we ensure the input defaults are cleared just before.
const remove_defaults = () => {
if (already_removed) return;
already_removed = true;
const value = dom.getAttribute('value');
set_attribute(dom, 'value', null);
set_attribute(dom, 'checked', null);
if (value) dom.value = value;
};
// @ts-expect-error
dom.__on_r = remove_defaults;
queue_idle_task(remove_defaults);
add_form_reset_listener();
}
export function remove_input_defaults(input) {
if (!hydrating) return;
var already_removed = false;
// We try and remove the default attributes later, rather than sync during hydration.
// Doing it sync during hydration has a negative impact on performance, but deferring the
// work in an idle task alleviates this greatly. If a form reset event comes in before
// the idle callback, then we ensure the input defaults are cleared just before.
var remove_defaults = () => {
if (already_removed) return;
already_removed = true;
// Remove the attributes but preserve the values
if (input.hasAttribute('value')) {
var value = input.value;
set_attribute(input, 'value', null);
input.value = value;
}
if (input.hasAttribute('checked')) {
var checked = input.checked;
set_attribute(input, 'checked', null);
input.checked = checked;
}
};
// @ts-expect-error
input.__on_r = remove_defaults;
queue_idle_task(remove_defaults);
add_form_reset_listener();
}

@@ -44,0 +55,0 @@

import { effect, teardown } from '../../../reactivity/effects.js';
import { untrack } from '../../../runtime.js';

@@ -103,5 +104,6 @@ /**

effect(() => {
update(element[type]);
// The update could contain reads which should be ignored
untrack(() => update(element[type]));
return unsub;
});
}

@@ -24,3 +24,3 @@ export { add_locations } from './dev/elements.js';

export {
remove_input_attr_defaults,
remove_input_defaults,
set_attribute,

@@ -27,0 +27,0 @@ set_attributes,

import { DEV } from 'esm-env';
import { get, current_component_context, untrack, current_effect } from './runtime.js';
import {
get,
batch_inspect,
current_component_context,
untrack,
current_effect
} from './runtime.js';
import {
array_prototype,

@@ -233,7 +227,2 @@ define_property,

if (DEV) {
if (typeof target[prop] === 'function' && prop !== Symbol.iterator) {
return batch_inspect(target, prop, receiver);
}
}
return Reflect.get(target, prop, receiver);

@@ -240,0 +229,0 @@ },

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

import { DEV } from 'esm-env';
import { CLEAN, DERIVED, DESTROYED, DIRTY, MAYBE_DIRTY, UNOWNED } from '../constants.js';

@@ -42,6 +41,2 @@ import {

if (DEV) {
/** @type {import('#client').DerivedDebug} */ (signal).inspect = new Set();
}
if (current_reaction !== null && (current_reaction.f & DERIVED) !== 0) {

@@ -89,6 +84,5 @@ var current_derived = /** @type {import('#client').Derived<V>} */ (current_reaction);

* @param {import('#client').Derived} derived
* @param {boolean} force_schedule
* @returns {void}
*/
export function update_derived(derived, force_schedule) {
export function update_derived(derived) {
var previous_updating_derived = updating_derived;

@@ -110,8 +104,3 @@ updating_derived = true;

derived.version = increment_version();
mark_reactions(derived, DIRTY, force_schedule);
if (DEV && force_schedule) {
for (var fn of /** @type {import('#client').DerivedDebug} */ (derived).inspect) fn();
}
mark_reactions(derived, DIRTY, false);
}

@@ -118,0 +107,0 @@ }

@@ -33,3 +33,4 @@ import {

UNOWNED,
CLEAN
CLEAN,
INSPECT_EFFECT
} from '../constants.js';

@@ -208,2 +209,7 @@ import { set } from './sources.js';

/** @param {() => void | (() => void)} fn */
export function inspect_effect(fn) {
return create_effect(INSPECT_EFFECT, fn, true);
}
/**

@@ -210,0 +216,0 @@ * Internal representation of `$effect.root(...)`

@@ -13,3 +13,2 @@ import { DEV } from 'esm-env';

import { safe_equals } from './equality.js';
import { inspect_fn } from '../dev/inspect.js';
import * as e from '../errors.js';

@@ -312,3 +311,3 @@ import { LEGACY_DERIVED_PROP } from '../constants.js';

// also needed for when handling inspect logic so we can inspect the correct source signal
if (is_signals_recorded || (DEV && inspect_fn)) {
if (is_signals_recorded) {
// set this so that we don't reset to the parent value if `d`

@@ -315,0 +314,0 @@ // is invalidated because of `invalidate_inner_signals` (rather

@@ -9,3 +9,2 @@ import { DEV } from 'esm-env';

get,
is_batching_effect,
is_runes,

@@ -15,6 +14,7 @@ mark_reactions,

set_current_untracked_writes,
set_last_inspected_signal,
set_signal_status,
untrack,
increment_version
increment_version,
execute_effect,
inspect_effects
} from '../runtime.js';

@@ -28,21 +28,14 @@ import { equals, safe_equals } from './equality.js';

* @template V
* @param {V} value
* @param {V} v
* @returns {import('#client').Source<V>}
*/
/*#__NO_SIDE_EFFECTS__*/
export function source(value) {
/** @type {import('#client').Source<V>} */
const source = {
export function source(v) {
return {
f: 0, // TODO ideally we could skip this altogether, but it causes type errors
v,
reactions: null,
equals: equals,
v: value,
equals,
version: 0
};
if (DEV) {
/** @type {import('#client').ValueDebug<V>} */ (source).inspect = new Set();
}
return source;
}

@@ -135,7 +128,7 @@

if (DEV) {
if (is_batching_effect) {
set_last_inspected_signal(/** @type {import('#client').ValueDebug} */ (source));
} else {
for (const fn of /** @type {import('#client').ValueDebug} */ (source).inspect) fn();
for (const effect of inspect_effects) {
execute_effect(effect);
}
inspect_effects.clear();
}

@@ -142,0 +135,0 @@ }

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

export interface ValueDebug<V = unknown> extends Value<V> {
inspect: Set<Function>;
}
export interface DerivedDebug<V = unknown> extends Derived<V>, ValueDebug<V> {}
export type Source<V = unknown> = Value<V>;
export type MaybeSource<T = unknown> = T | Source<T>;

@@ -32,3 +32,4 @@ import { DEV } from 'esm-env';

DISCONNECTED,
STATE_FROZEN_SYMBOL
STATE_FROZEN_SYMBOL,
INSPECT_EFFECT
} from './constants.js';

@@ -39,3 +40,2 @@ import { flush_tasks } from './dom/task.js';

import { update_derived } from './reactivity/deriveds.js';
import { inspect_captured_signals, inspect_fn, set_inspect_fn } from './dev/inspect.js';
import * as e from './errors.js';

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

// Used for $inspect
export let is_batching_effect = false;
let is_inspecting_signal = false;
export let inspect_effects = new Set();

@@ -112,10 +110,2 @@ // Handle effect queues

/** @type {null | import('#client').ValueDebug} */
export let last_inspected_signal = null;
/** @param {null | import('#client').ValueDebug} signal */
export function set_last_inspected_signal(signal) {
last_inspected_signal = signal;
}
/** @type {number} Used by sources and deriveds for handling updates to unowned deriveds */

@@ -167,34 +157,2 @@ let current_version = 0;

/**
* @param {import('#client').ProxyStateObject} target
* @param {string | symbol} prop
* @param {any} receiver
*/
export function batch_inspect(target, prop, receiver) {
const value = Reflect.get(target, prop, receiver);
/**
* @this {any}
*/
return function () {
const previously_batching_effect = is_batching_effect;
is_batching_effect = true;
try {
return Reflect.apply(value, this, arguments);
} finally {
is_batching_effect = previously_batching_effect;
if (last_inspected_signal !== null && !is_inspecting_signal) {
is_inspecting_signal = true;
try {
for (const fn of last_inspected_signal.inspect) {
fn();
}
} finally {
is_inspecting_signal = false;
}
last_inspected_signal = null;
}
}
};
}
/**
* Determines whether a derived or effect is dirty.

@@ -227,3 +185,3 @@ * If it is MAYBE_DIRTY, will set the status to CLEAN

if (!is_dirty && check_dirtiness(/** @type {import('#client').Derived} */ (dependency))) {
update_derived(/** @type {import('#client').Derived} **/ (dependency), true);
update_derived(/** @type {import('#client').Derived} **/ (dependency));
}

@@ -802,8 +760,2 @@

export function get(signal) {
if (DEV && inspect_fn) {
var s = /** @type {import('#client').ValueDebug} */ (signal);
s.inspect.add(inspect_fn);
inspect_captured_signals.push(s);
}
const flags = signal.f;

@@ -856,11 +808,3 @@ if ((flags & DESTROYED) !== 0) {

) {
if (DEV) {
// we want to avoid tracking indirect dependencies
const previous_inspect_fn = inspect_fn;
set_inspect_fn(null);
update_derived(/** @type {import('#client').Derived} **/ (signal), false);
set_inspect_fn(previous_inspect_fn);
} else {
update_derived(/** @type {import('#client').Derived} **/ (signal), false);
}
update_derived(/** @type {import('#client').Derived} **/ (signal));
}

@@ -925,2 +869,7 @@

if (DEV && (flags & INSPECT_EFFECT) !== 0) {
inspect_effects.add(reaction);
continue;
}
// We skip any effects that are already dirty. Additionally, we also

@@ -927,0 +876,0 @@ // skip if the reaction is the same as the current effect (except if we're not in runes or we

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

*/
export const VERSION = '5.0.0-next.158';
export const VERSION = '5.0.0-next.159';
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

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