Socket
Socket
Sign inDemoInstall

svelte

Package Overview
Dependencies
Maintainers
3
Versions
735
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.212 to 5.0.0-next.213

2

package.json

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

"license": "MIT",
"version": "5.0.0-next.212",
"version": "5.0.0-next.213",
"type": "module",

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

@@ -158,4 +158,4 @@ /** @import { ArrowFunctionExpression, Expression, FunctionDeclaration, FunctionExpression } from 'estree' */

for (const [reference] of scope.references) {
// Bail out if the arguments keyword is used
if (reference === 'arguments') return unhoisted;
// Bail out if the arguments keyword is used or $host is referenced
if (reference === 'arguments' || reference === '$host') return unhoisted;
// Bail out if references a store subscription

@@ -162,0 +162,0 @@ if (scope.get(`$${reference}`)?.kind === 'store_sub') return unhoisted;

@@ -330,5 +330,4 @@ /** @import { Expression, ExpressionStatement, Identifier, Literal, MemberExpression, ObjectExpression, Statement } from 'estree' */

needs_reset = true;
child_state.init.push(b.stmt(b.call('$.hydrate_template', arg)));
arg = b.member(arg, b.id('content'));
child_state.init.push(b.stmt(b.call('$.reset', arg)));
}

@@ -335,0 +334,0 @@

@@ -5,3 +5,3 @@ /** @import { VariableDeclaration, VariableDeclarator, Expression, CallExpression, Pattern, Identifier } from 'estree' */

/** @import { Scope } from '../../../scope.js' */
import { extract_paths, is_expression_async } from '../../../../utils/ast.js';
import { build_fallback, extract_paths } from '../../../../utils/ast.js';
import * as b from '../../../../utils/builders.js';

@@ -100,5 +100,3 @@ import { get_rune } from '../../../scope.js';

const prop = b.member(b.id('$$props'), b.literal(binding.prop_alias ?? name), true);
declarations.push(
b.declarator(path.node, b.call('$.value_or_fallback', prop, b.thunk(value)))
);
declarations.push(b.declarator(path.node, build_fallback(prop, value)));
}

@@ -119,5 +117,3 @@ continue;

const default_value = /** @type {Expression} */ (context.visit(declarator.init));
init = is_expression_async(default_value)
? b.await(b.call('$.value_or_fallback_async', prop, b.thunk(default_value, true)))
: b.call('$.value_or_fallback', prop, b.thunk(default_value));
init = build_fallback(prop, default_value);
}

@@ -124,0 +120,0 @@

@@ -371,8 +371,3 @@ /** @import { Attribute, Text, ExpressionTag, SvelteNode } from '#compiler' */

/** @type {DestructuredAssignment['expression']} */
const fallback_expression = (object) =>
is_expression_async(param.right)
? b.await(
b.call('$.value_or_fallback_async', expression(object), b.thunk(param.right, true))
)
: b.call('$.value_or_fallback', expression(object), b.thunk(param.right));
const fallback_expression = (object) => build_fallback(expression(object), param.right);

@@ -553,1 +548,20 @@ if (param.left.type === 'Identifier') {

}
/**
*
* @param {ESTree.Expression} expression
* @param {ESTree.Expression} fallback
*/
export function build_fallback(expression, fallback) {
if (is_simple_expression(fallback)) {
return b.call('$.fallback', expression, fallback);
}
if (fallback.type === 'AwaitExpression' && is_simple_expression(fallback.argument)) {
return b.await(b.call('$.fallback', expression, fallback.argument));
}
return is_expression_async(fallback)
? b.await(b.call('$.fallback', expression, b.thunk(fallback, true), b.true))
: b.call('$.fallback', expression, b.thunk(fallback), b.true);
}

@@ -33,2 +33,7 @@ /** @import { TemplateNode } from '#client' */

export function set_hydrate_node(node) {
if (node === null) {
w.hydration_mismatch();
throw HYDRATION_ERROR;
}
return (hydrate_node = node);

@@ -38,13 +43,25 @@ }

export function hydrate_next() {
if (hydrate_node === null) {
return set_hydrate_node(/** @type {TemplateNode} */ (hydrate_node.nextSibling));
}
/** @param {TemplateNode} node */
export function reset(node) {
if (!hydrating) return;
// If the node has remaining siblings, something has gone wrong
if (hydrate_node.nextSibling !== null) {
w.hydration_mismatch();
throw HYDRATION_ERROR;
}
return (hydrate_node = /** @type {TemplateNode} */ (hydrate_node.nextSibling));
hydrate_node = node;
}
/** @param {TemplateNode} node */
export function reset(node) {
/**
* @param {HTMLTemplateElement} template
*/
export function hydrate_template(template) {
if (hydrating) {
hydrate_node = node;
// @ts-expect-error TemplateNode doesn't include DocumentFragment, but it's actually fine
hydrate_node = template.content;
}

@@ -51,0 +68,0 @@ }

@@ -69,3 +69,3 @@ export { FILENAME, HMR } from '../../constants.js';

export { bind_window_scroll, bind_window_size } from './dom/elements/bindings/window.js';
export { next, reset } from './dom/hydration.js';
export { hydrate_template, next, reset } from './dom/hydration.js';
export {

@@ -138,4 +138,2 @@ once,

update_pre,
value_or_fallback,
value_or_fallback_async,
exclude_from_object,

@@ -169,3 +167,3 @@ pop,

export { snapshot } from '../shared/clone.js';
export { noop } from '../shared/utils.js';
export { noop, fallback } from '../shared/utils.js';
export {

@@ -172,0 +170,0 @@ invalid_default_snippet,

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

/**
* @template V
* @param {V} value
* @param {() => V} fallback lazy because could contain side effects
* @returns {V}
*/
export function value_or_fallback(value, fallback) {
return value === undefined ? fallback() : value;
}
/**
* @template V
* @param {V} value
* @param {() => Promise<V>} fallback lazy because could contain side effects
* @returns {Promise<V>}
*/
export async function value_or_fallback_async(value, fallback) {
return value === undefined ? fallback() : value;
}
/**
* @param {Record<string, unknown>} props

@@ -1029,0 +1009,0 @@ * @param {any} runes

@@ -387,22 +387,2 @@ /** @import { ComponentType, SvelteComponent } from 'svelte' */

/**
* @template V
* @param {V} value
* @param {() => V} fallback lazy because could contain side effects
* @returns {V}
*/
export function value_or_fallback(value, fallback) {
return value === undefined ? fallback() : value;
}
/**
* @template V
* @param {V} value
* @param {() => Promise<V>} fallback lazy because could contain side effects
* @returns {Promise<V>}
*/
export async function value_or_fallback_async(value, fallback) {
return value === undefined ? fallback() : value;
}
/**
* @param {Payload} payload

@@ -540,2 +520,4 @@ * @param {void | ((payload: Payload, props: Record<string, unknown>) => void)} slot_fn

export { fallback } from '../shared/utils.js';
export {

@@ -542,0 +524,0 @@ invalid_default_snippet,

@@ -49,1 +49,16 @@ // Store the references to globals in case someone tries to monkey patch these, causing the below

}
/**
* @template V
* @param {V} value
* @param {V | (() => V)} fallback
* @param {boolean} [lazy]
* @returns {V}
*/
export function fallback(value, fallback, lazy = false) {
return value === undefined
? lazy
? /** @type {() => V} */ (fallback)()
: /** @type {V} */ (fallback)
: value;
}

@@ -113,3 +113,6 @@ /** @import { ComponentConstructorOptions, ComponentType, SvelteComponent, Component } from 'svelte' */

flush_sync();
// We don't flush_sync for custom element wrappers
if (!options?.props?.$$host) {
flush_sync();
}

@@ -116,0 +119,0 @@ this.#events = props.$$events;

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

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