Socket
Socket
Sign inDemoInstall

svelte

Package Overview
Dependencies
18
Maintainers
3
Versions
642
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 5.0.0-next.110 to 5.0.0-next.111

2

package.json

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

"license": "MIT",
"version": "5.0.0-next.110",
"version": "5.0.0-next.111",
"type": "module",

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

@@ -106,2 +106,11 @@ /** @typedef {{ start?: number, end?: number }} NodeLike */

'invalid-css-empty-declaration': () => `Declaration cannot be empty`,
'invalid-css-global-block-list': () =>
`A :global {...} block cannot be part of a selector list with more than one item`,
'invalid-css-global-block-modifier': () =>
`A :global {...} block cannot modify an existing selector`,
/** @param {string} name */
'invalid-css-global-block-combinator': (name) =>
`A :global {...} block cannot follow a ${name} combinator`,
'invalid-css-global-block-declaration': () =>
`A :global {...} block can only contain rules, not declarations`,
'invalid-css-global-placement': () =>

@@ -108,0 +117,0 @@ `:global(...) can be at the start or end of a selector sequence, but not in the middle`,

import { getLocator } from 'locate-character';
import { walk } from 'zimmerframe';
import { walk as zimmerframe_walk } from 'zimmerframe';
import { CompileError } from './errors.js';

@@ -136,3 +136,3 @@ import { convert } from './legacy.js';

// remove things that we don't want to treat as public API
return walk(ast, null, {
return zimmerframe_walk(ast, null, {
_(node, { next }) {

@@ -155,3 +155,3 @@ // @ts-ignore

*/
function _walk() {
export function walk() {
throw new Error(

@@ -162,6 +162,4 @@ `'svelte/compiler' no longer exports a \`walk\` utility — please import it directly from 'estree-walker' instead`

export { _walk as walk };
export { CompileError } from './errors.js';
export { VERSION } from '../version.js';

@@ -89,2 +89,4 @@ import { walk } from 'zimmerframe';

delete instance.parent;
// @ts-ignore
delete instance.attributes;
}

@@ -95,2 +97,4 @@

delete module.parent;
// @ts-ignore
delete module.attributes;
}

@@ -97,0 +101,0 @@

@@ -14,3 +14,5 @@ import { namespace_svg } from '../../../../constants.js';

start: node.start,
end: node.end
end: node.end,
// @ts-ignore
attributes: node.attributes
};

@@ -17,0 +19,0 @@

@@ -66,4 +66,6 @@ import * as acorn from '../acorn.js';

content: ast,
parent: null
parent: null,
// @ts-ignore
attributes: attributes
};
}

@@ -6,3 +6,2 @@ import { error } from '../../../errors.js';

const REGEX_ATTRIBUTE_FLAGS = /^[a-zA-Z]+/; // only `i` and `s` are valid today, but make it future-proof
const REGEX_COMBINATOR_WHITESPACE = /^\s*(\+|~|>|\|\|)\s*/;
const REGEX_COMBINATOR = /^(\+|~|>|\|\|)/;

@@ -120,3 +119,4 @@ const REGEX_PERCENTAGE = /^\d+(\.\d+)?%/;

parent_rule: null,
has_local_selectors: false
has_local_selectors: false,
is_global_block: false
}

@@ -257,4 +257,2 @@ };

parser.eat(')', true);
} else if (name === 'global') {
error(parser.index, 'invalid-css-global-selector');
}

@@ -261,0 +259,0 @@

@@ -72,2 +72,13 @@ import { walk } from 'zimmerframe';

// `:global {...}` or `div :global {...}`
node.metadata.is_global_block = node.prelude.children.some((selector) => {
const last = selector.children[selector.children.length - 1];
const s = last.selectors[last.selectors.length - 1];
if (s.type === 'PseudoClassSelector' && s.name === 'global' && s.args === null) {
return true;
}
});
context.next({

@@ -88,2 +99,35 @@ ...context.state,

const validation_visitors = {
Rule(node, context) {
if (node.metadata.is_global_block) {
if (node.prelude.children.length > 1) {
error(node.prelude, 'invalid-css-global-block-list');
}
const complex_selector = node.prelude.children[0];
const relative_selector = complex_selector.children[complex_selector.children.length - 1];
if (relative_selector.selectors.length > 1) {
error(
relative_selector.selectors[relative_selector.selectors.length - 1],
'invalid-css-global-block-modifier'
);
}
if (relative_selector.combinator && relative_selector.combinator.name !== ' ') {
error(
relative_selector,
'invalid-css-global-block-combinator',
relative_selector.combinator.name
);
}
const declaration = node.block.children.find((child) => child.type === 'Declaration');
if (declaration) {
error(declaration, 'invalid-css-global-block-declaration');
}
}
context.next();
},
ComplexSelector(node, context) {

@@ -90,0 +134,0 @@ // ensure `:global(...)` is not used in the middle of a selector

import { walk } from 'zimmerframe';
import { get_possible_values } from './utils.js';
import { regex_ends_with_whitespace, regex_starts_with_whitespace } from '../../patterns.js';
import { error } from '../../../errors.js';

@@ -63,2 +62,9 @@ /**

const visitors = {
Rule(node, context) {
if (node.metadata.is_global_block) {
context.visit(node.prelude);
} else {
context.next();
}
},
ComplexSelector(node, context) {

@@ -65,0 +71,0 @@ const selectors = truncate(node);

@@ -33,3 +33,10 @@ import { walk } from 'zimmerframe';

context.next();
},
Rule(node, context) {
if (node.metadata.is_global_block) {
context.visit(node.prelude);
} else {
context.next();
}
}
};

@@ -119,3 +119,3 @@ import MagicString from 'magic-string';

},
Rule(node, { state, next }) {
Rule(node, { state, next, visit }) {
// keep empty rules in dev, because it's convenient to

@@ -138,2 +138,22 @@ // see them in devtools

if (node.metadata.is_global_block) {
const selector = node.prelude.children[0];
if (selector.children.length === 1) {
// `:global {...}`
state.code.prependRight(node.start, '/* ');
state.code.appendLeft(node.block.start + 1, '*/');
state.code.prependRight(node.block.end - 1, '/*');
state.code.appendLeft(node.block.end, '*/');
// don't recurse into selector or body
return;
}
// don't recurse into body
visit(node.prelude);
return;
}
next();

@@ -280,2 +300,6 @@ },

function is_empty(rule) {
if (rule.metadata.is_global_block) {
return rule.block.children.length === 0;
}
for (const child of rule.block.children) {

@@ -282,0 +306,0 @@ if (child.type === 'Declaration') {

@@ -24,2 +24,3 @@ /**

},
focused: {},
paused: {

@@ -26,0 +27,0 @@ valid_elements: ['audio', 'video'],

@@ -36,2 +36,3 @@ import type { Comment } from '#compiler';

has_local_selectors: boolean;
is_global_block: boolean;
};

@@ -38,0 +39,0 @@ }

@@ -96,2 +96,3 @@ import type { Binding, Css } from '#compiler';

};
attributes: Attribute[];
}

@@ -471,2 +472,3 @@

content: Program;
attributes: Attribute[];
}

@@ -473,0 +475,0 @@

@@ -23,11 +23,13 @@ import { EFFECT_TRANSPARENT } from '../../constants.js';

/** @type {import('#client').Effect | null} */
let consequent_effect = null;
var consequent_effect = null;
/** @type {import('#client').Effect | null} */
let alternate_effect = null;
var alternate_effect = null;
/** @type {boolean | null} */
let condition = null;
var condition = null;
const effect = block(() => {
var flags = elseif ? EFFECT_TRANSPARENT : 0;
block(() => {
if (condition === (condition = !!get_condition())) return;

@@ -80,7 +82,3 @@

}
});
if (elseif) {
effect.f |= EFFECT_TRANSPARENT;
}
}, flags);
}
import { EFFECT_TRANSPARENT } from '../../constants.js';
import { branch, render_effect } from '../../reactivity/effects.js';
import { branch, block, destroy_effect } from '../../reactivity/effects.js';

@@ -15,11 +15,17 @@ /**

var effect = render_effect(() => {
/** @type {import('#client').Effect | null} */
var snippet_effect;
block(() => {
if (snippet === (snippet = get_snippet())) return;
if (snippet_effect) {
destroy_effect(snippet_effect);
snippet_effect = null;
}
if (snippet) {
branch(() => /** @type {SnippetFn} */ (snippet)(node, ...args));
snippet_effect = branch(() => /** @type {SnippetFn} */ (snippet)(node, ...args));
}
});
effect.f |= EFFECT_TRANSPARENT;
}, EFFECT_TRANSPARENT);
}

@@ -43,3 +43,3 @@ import { namespace_svg } from '../../../../constants.js';

* @param {boolean} is_svg
* @param {undefined | ((element: Element, anchor: Node) => void)} render_fn,
* @param {undefined | ((element: Element, anchor: Node | null) => void)} render_fn,
* @param {undefined | (() => string)} get_namespace

@@ -119,9 +119,7 @@ * @returns {void}

if (child_anchor) {
// `child_anchor` can be undefined if this is a void element with children,
// i.e. `<svelte:element this={"hr"}>...</svelte:element>`. This is
// user error, but we warn on it elsewhere (in dev) so here we just
// silently ignore it
render_fn(element, child_anchor);
}
// `child_anchor` is undefined if this is a void element, but we still
// need to call `render_fn` in order to run actions etc. If the element
// contains children, it's a user error (which is warned on elsewhere)
// and the DOM will be silently discarded
render_fn(element, child_anchor);
}

@@ -128,0 +126,0 @@

import { render_effect } from '../../../reactivity/effects.js';
import { listen } from './shared.js';

@@ -70,1 +71,12 @@ /**

}
/**
* @param {HTMLElement} element
* @param {(value: unknown) => void} update
* @returns {void}
*/
export function bind_focused(element, update) {
listen(element, ['focus', 'blur'], () => {
update(element === document.activeElement);
});
}

@@ -125,34 +125,40 @@ import { render_effect } from '../../reactivity/effects.js';

while (current_target !== null) {
/** @param {Element} current_target */
function next(current_target) {
/** @type {null | Element} */
var parent_element =
current_target.parentNode || /** @type {any} */ (current_target).host || null;
var internal_prop_name = '__' + event_name;
// @ts-ignore
var delegated = current_target[internal_prop_name];
if (delegated !== undefined && !(/** @type {any} */ (current_target).disabled)) {
if (is_array(delegated)) {
var [fn, ...data] = delegated;
fn.apply(current_target, [event, ...data]);
} else {
delegated.call(current_target, event);
try {
// @ts-expect-error
var delegated = current_target['__' + event_name];
if (delegated !== undefined && !(/** @type {any} */ (current_target).disabled)) {
if (is_array(delegated)) {
var [fn, ...data] = delegated;
fn.apply(current_target, [event, ...data]);
} else {
delegated.call(current_target, event);
}
}
} finally {
if (
!event.cancelBubble &&
parent_element !== handler_element &&
parent_element !== null &&
current_target !== handler_element
) {
next(parent_element);
}
}
}
if (
event.cancelBubble ||
parent_element === handler_element ||
current_target === handler_element
) {
break;
}
current_target = parent_element;
try {
next(current_target);
} finally {
// @ts-expect-error is used above
event.__root = handler_element;
// @ts-expect-error is used above
current_target = handler_element;
}
// @ts-expect-error is used above
event.__root = handler_element;
// @ts-expect-error is used above
current_target = handler_element;
}

@@ -10,3 +10,3 @@ import { noop } from '../../../shared/utils.js';

import { TRANSITION_GLOBAL, TRANSITION_IN, TRANSITION_OUT } from '../../../../constants.js';
import { BLOCK_EFFECT, EFFECT_RAN } from '../../constants.js';
import { BLOCK_EFFECT, EFFECT_RAN, EFFECT_TRANSPARENT } from '../../constants.js';

@@ -245,14 +245,22 @@ /**

// if this is a local transition, we only want to run it if the parent (block) effect's
// parent (branch) effect is where the state change happened. we can determine that by
// looking at whether the branch effect is currently initializing
// if this is a local transition, we only want to run it if the parent (branch) effect's
// parent (block) effect is where the state change happened. we can determine that by
// looking at whether the block effect is currently initializing
if (is_intro && should_intro) {
var parent = /** @type {import('#client').Effect} */ (e.parent);
let run = is_global;
// e.g snippets are implemented as render effects — keep going until we find the parent block
while ((parent.f & BLOCK_EFFECT) === 0 && parent.parent) {
parent = parent.parent;
if (!run) {
var block = /** @type {import('#client').Effect | null} */ (e.parent);
// skip over transparent blocks (e.g. snippets, else-if blocks)
while (block && (block.f & EFFECT_TRANSPARENT) !== 0) {
while ((block = block.parent)) {
if ((block.f & BLOCK_EFFECT) !== 0) break;
}
}
run = !block || (block.f & EFFECT_RAN) !== 0;
}
if (is_global || (parent.f & EFFECT_RAN) !== 0) {
if (run) {
effect(() => {

@@ -259,0 +267,0 @@ untrack(() => transition.in());

@@ -47,3 +47,7 @@ export { hmr } from './dev/hmr.js';

export { bind_this } from './dom/elements/bindings/this.js';
export { bind_content_editable, bind_property } from './dom/elements/bindings/universal.js';
export {
bind_content_editable,
bind_property,
bind_focused
} from './dom/elements/bindings/universal.js';
export { bind_window_scroll, bind_window_size } from './dom/elements/bindings/window.js';

@@ -50,0 +54,0 @@ export {

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

/**
* @param {import('./types.js').Derived} signal
* @param {import('#client').Derived} signal
* @returns {void}

@@ -73,0 +73,0 @@ */

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

/** @param {(() => void)} fn */
export function block(fn) {
return create_effect(RENDER_EFFECT | BLOCK_EFFECT, fn, true);
/**
* @param {(() => void)} fn
* @param {number} flags
*/
export function block(fn, flags = 0) {
return create_effect(RENDER_EFFECT | BLOCK_EFFECT | flags, fn, true);
}

@@ -238,0 +241,0 @@

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

/** @type {import('./types.js').Effect[]} */
/** @type {import('#client').Effect[]} */
let current_queued_root_effects = [];

@@ -59,6 +59,6 @@

/** @type {null | import('./types.js').Reaction} */
/** @type {null | import('#client').Reaction} */
export let current_reaction = null;
/** @param {null | import('./types.js').Reaction} reaction */
/** @param {null | import('#client').Reaction} reaction */
export function set_current_reaction(reaction) {

@@ -68,6 +68,6 @@ current_reaction = reaction;

/** @type {null | import('./types.js').Effect} */
/** @type {null | import('#client').Effect} */
export let current_effect = null;
/** @param {null | import('./types.js').Effect} effect */
/** @param {null | import('#client').Effect} effect */
export function set_current_effect(effect) {

@@ -77,3 +77,3 @@ current_effect = effect;

/** @type {null | import('./types.js').Value[]} */
/** @type {null | import('#client').Value[]} */
export let current_dependencies = null;

@@ -84,7 +84,7 @@ let current_dependencies_index = 0;

* so that the dependency can be added to the effect later on if it then reads it
* @type {null | import('./types.js').Source[]}
* @type {null | import('#client').Source[]}
*/
export let current_untracked_writes = null;
/** @param {null | import('./types.js').Source[]} value */
/** @param {null | import('#client').Source[]} value */
export function set_current_untracked_writes(value) {

@@ -94,6 +94,6 @@ current_untracked_writes = value;

/** @type {null | import('./types.js').ValueDebug} */
/** @type {null | import('#client').ValueDebug} */
export let last_inspected_signal = null;
/** @param {null | import('./types.js').ValueDebug} signal */
/** @param {null | import('#client').ValueDebug} signal */
export function set_last_inspected_signal(signal) {

@@ -114,6 +114,6 @@ last_inspected_signal = signal;

// Handling runtime component context
/** @type {import('./types.js').ComponentContext | null} */
/** @type {import('#client').ComponentContext | null} */
export let current_component_context = null;
/** @param {import('./types.js').ComponentContext | null} context */
/** @param {import('#client').ComponentContext | null} context */
export function set_current_component_context(context) {

@@ -129,3 +129,3 @@ current_component_context = context;

/**
* @param {import('./types.js').ProxyStateObject} target
* @param {import('#client').ProxyStateObject} target
* @param {string | symbol} prop

@@ -164,3 +164,3 @@ * @param {any} receiver

* If it is MAYBE_DIRTY, will set the status to CLEAN
* @param {import('./types.js').Reaction} reaction
* @param {import('#client').Reaction} reaction
* @returns {boolean}

@@ -230,3 +230,3 @@ */

* @template V
* @param {import('./types.js').Reaction} signal
* @param {import('#client').Reaction} signal
* @returns {V}

@@ -242,3 +242,3 @@ */

current_dependencies = /** @type {null | import('./types.js').Value[]} */ (null);
current_dependencies = /** @type {null | import('#client').Value[]} */ (null);
current_dependencies_index = 0;

@@ -252,3 +252,3 @@ current_untracked_writes = null;

let res = signal.fn();
let dependencies = /** @type {import('./types.js').Value<unknown>[]} **/ (signal.deps);
let dependencies = /** @type {import('#client').Value<unknown>[]} **/ (signal.deps);
if (current_dependencies !== null) {

@@ -288,3 +288,3 @@ let i;

} else {
signal.deps = /** @type {import('./types.js').Value<V>[]} **/ (
signal.deps = /** @type {import('#client').Value<V>[]} **/ (
dependencies = current_dependencies

@@ -327,4 +327,4 @@ );

* @template V
* @param {import('./types.js').Reaction} signal
* @param {import('./types.js').Value<V>} dependency
* @param {import('#client').Reaction} signal
* @param {import('#client').Value<V>} dependency
* @returns {void}

@@ -351,3 +351,3 @@ */

set_signal_status(dependency, DIRTY);
remove_reactions(/** @type {import('./types.js').Derived} **/ (dependency), 0);
remove_reactions(/** @type {import('#client').Derived} **/ (dependency), 0);
}

@@ -357,3 +357,3 @@ }

/**
* @param {import('./types.js').Reaction} signal
* @param {import('#client').Reaction} signal
* @param {number} start_index

@@ -378,3 +378,3 @@ * @returns {void}

/**
* @param {import('./types.js').Reaction} signal
* @param {import('#client').Reaction} signal
* @returns {void}

@@ -395,3 +395,3 @@ */

/**
* @param {import('./types.js').Effect} effect
* @param {import('#client').Effect} effect
* @returns {void}

@@ -445,3 +445,3 @@ */

/**
* @param {Array<import('./types.js').Effect>} root_effects
* @param {Array<import('#client').Effect>} root_effects
* @returns {void}

@@ -457,3 +457,3 @@ */

/**
* @param {Array<import('./types.js').Effect>} effects
* @param {Array<import('#client').Effect>} effects
* @returns {void}

@@ -489,3 +489,3 @@ */

/**
* @param {import('./types.js').Effect} signal
* @param {import('#client').Effect} signal
* @returns {void}

@@ -523,6 +523,6 @@ */

*
* @param {import('./types.js').Effect} effect
* @param {import('#client').Effect} effect
* @param {number} filter_flags
* @param {boolean} shallow
* @param {import('./types.js').Effect[]} collected_effects
* @param {import('#client').Effect[]} collected_effects
* @returns {void}

@@ -616,3 +616,3 @@ */

*
* @param {import('./types.js').Effect} effect
* @param {import('#client').Effect} effect
* @param {number} filter_flags

@@ -643,3 +643,3 @@ * @param {boolean} [shallow]

/**
* @param {import('./types.js').Effect} effect
* @param {import('#client').Effect} effect
* @returns {void}

@@ -667,3 +667,3 @@ */

/** @type {import('./types.js').Effect[]} */
/** @type {import('#client').Effect[]} */
const root_effects = [];

@@ -707,3 +707,3 @@

* @template V
* @param {import('./types.js').Value<V>} signal
* @param {import('#client').Value<V>} signal
* @returns {V}

@@ -773,6 +773,6 @@ */

set_inspect_fn(null);
update_derived(/** @type {import('./types.js').Derived} **/ (signal), false);
update_derived(/** @type {import('#client').Derived} **/ (signal), false);
set_inspect_fn(previous_inspect_fn);
} else {
update_derived(/** @type {import('./types.js').Derived} **/ (signal), false);
update_derived(/** @type {import('#client').Derived} **/ (signal), false);
}

@@ -879,3 +879,3 @@ }

/**
* @param {import('./types.js').Signal} signal
* @param {import('#client').Signal} signal
* @param {number} status

@@ -890,4 +890,4 @@ * @returns {void}

* @template V
* @param {V | import('./types.js').Value<V>} val
* @returns {val is import('./types.js').Value<V>}
* @param {V | import('#client').Value<V>} val
* @returns {val is import('#client').Value<V>}
*/

@@ -898,3 +898,3 @@ export function is_signal(val) {

val !== null &&
typeof (/** @type {import('./types.js').Value<V>} */ (val).f) === 'number'
typeof (/** @type {import('#client').Value<V>} */ (val).f) === 'number'
);

@@ -997,3 +997,3 @@ }

/**
* @param {import('./types.js').ComponentContext} component_context
* @param {import('#client').ComponentContext} component_context
* @returns {Map<unknown, unknown> | null}

@@ -1014,3 +1014,3 @@ */

/**
* @param {import('./types.js').Value<number>} signal
* @param {import('#client').Value<number>} signal
* @param {1 | -1} [d]

@@ -1026,3 +1026,3 @@ * @returns {number}

/**
* @param {import('./types.js').Value<number>} signal
* @param {import('#client').Value<number>} signal
* @param {1 | -1} [d]

@@ -1029,0 +1029,0 @@ * @returns {number}

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

* @template V
* @extends {Map<K, V>}
*/

@@ -12,0 +13,0 @@ export class ReactiveMap extends Map {

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

* @template T
* @extends {Set<T>}
*/

@@ -15,0 +16,0 @@ export class ReactiveSet extends Set {

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

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc