svelte
Advanced tools
Comparing version 5.0.0-next.173 to 5.0.0-next.174
@@ -5,3 +5,3 @@ { | ||
"license": "MIT", | ||
"version": "5.0.0-next.173", | ||
"version": "5.0.0-next.174", | ||
"type": "module", | ||
@@ -101,2 +101,3 @@ "types": "./types/index.d.ts", | ||
"keywords": [ | ||
"svelte", | ||
"UI", | ||
@@ -103,0 +104,0 @@ "framework", |
@@ -169,13 +169,7 @@ import is_reference from 'is-reference'; | ||
// If we can't find a function, bail-out | ||
if (target_function == null) { | ||
return non_hoistable; | ||
} | ||
if (target_function == null) return non_hoistable; | ||
// If the function is marked as non-hoistable, bail-out | ||
if (target_function.metadata.hoistable === 'impossible') { | ||
return non_hoistable; | ||
} | ||
if (target_function.metadata.hoistable === 'impossible') return non_hoistable; | ||
// If the function has more than one arg, then bail-out | ||
if (target_function.params.length > 1) { | ||
return non_hoistable; | ||
} | ||
if (target_function.params.length > 1) return non_hoistable; | ||
@@ -186,5 +180,6 @@ const visited_references = new Set(); | ||
// Bail-out if the arguments keyword is used | ||
if (reference === 'arguments') { | ||
return non_hoistable; | ||
} | ||
if (reference === 'arguments') return non_hoistable; | ||
// Bail-out if references a store subscription | ||
if (scope.get(`$${reference}`)?.kind === 'store_sub') return non_hoistable; | ||
const binding = scope.get(reference); | ||
@@ -208,5 +203,3 @@ const local_binding = context.state.scope.get(reference); | ||
// If we reference the index within an each block, then bail-out. | ||
if (binding !== null && binding.initial?.type === 'EachBlock') { | ||
return non_hoistable; | ||
} | ||
if (binding !== null && binding.initial?.type === 'EachBlock') return non_hoistable; | ||
@@ -213,0 +206,0 @@ if ( |
@@ -550,2 +550,7 @@ import * as b from '../../../utils/builders.js'; | ||
push_unique(b.id(binding.node.name)); | ||
// rest props are often accessed through the $$props object for optimization reasons, | ||
// but we can't know if the delegated event handler will use it, so we need to add both as params | ||
if (binding.kind === 'rest_prop' && context.state.analysis.runes) { | ||
push_unique(b.id('$$props')); | ||
} | ||
} | ||
@@ -552,0 +557,0 @@ } |
@@ -140,3 +140,3 @@ /** @import { Context } from 'zimmerframe' */ | ||
* @param {Compiler.Namespace} namespace | ||
* @param {TransformState} state | ||
* @param {TransformState & { options: Compiler.ValidatedCompileOptions }} state | ||
* @param {boolean} preserve_whitespace | ||
@@ -283,2 +283,3 @@ * @param {boolean} preserve_comments | ||
(first.type === 'Component' && | ||
!state.options.hmr && | ||
!first.attributes.some( | ||
@@ -285,0 +286,0 @@ (attribute) => attribute.type === 'Attribute' && attribute.name.startsWith('--') |
@@ -31,3 +31,3 @@ import { | ||
import { is_array, is_frozen } from '../../utils.js'; | ||
import { INERT, STATE_SYMBOL } from '../../constants.js'; | ||
import { INERT, STATE_FROZEN_SYMBOL, STATE_SYMBOL } from '../../constants.js'; | ||
import { queue_micro_task } from '../task.js'; | ||
@@ -141,3 +141,8 @@ import { current_effect } from '../../runtime.js'; | ||
var flags = state.flags; | ||
if ((flags & EACH_IS_STRICT_EQUALS) !== 0 && !is_frozen(array) && !(STATE_SYMBOL in array)) { | ||
if ( | ||
(flags & EACH_IS_STRICT_EQUALS) !== 0 && | ||
!is_frozen(array) && | ||
!(STATE_FROZEN_SYMBOL in array) && | ||
!(STATE_SYMBOL in array) | ||
) { | ||
flags ^= EACH_IS_STRICT_EQUALS; | ||
@@ -144,0 +149,0 @@ |
@@ -145,7 +145,1 @@ import { hydrate_anchor, hydrate_start, hydrating } from './hydration.js'; | ||
} | ||
/** @param {string} name */ | ||
/*#__NO_SIDE_EFFECTS__*/ | ||
export function create_element(name) { | ||
return document.createElement(name); | ||
} |
@@ -27,3 +27,2 @@ import { DEV } from 'esm-env'; | ||
} from '../constants.js'; | ||
import { UNINITIALIZED } from '../../../constants.js'; | ||
import * as e from '../errors.js'; | ||
@@ -88,10 +87,3 @@ | ||
export function set(source, value) { | ||
var initialized = source.v !== UNINITIALIZED; | ||
if ( | ||
initialized && | ||
current_reaction !== null && | ||
is_runes() && | ||
(current_reaction.f & DERIVED) !== 0 | ||
) { | ||
if (current_reaction !== null && is_runes() && (current_reaction.f & DERIVED) !== 0) { | ||
e.state_unsafe_mutation(); | ||
@@ -117,3 +109,2 @@ } | ||
is_runes() && | ||
initialized && | ||
current_effect !== null && | ||
@@ -120,0 +111,0 @@ (current_effect.f & CLEAN) !== 0 && |
@@ -5,3 +5,2 @@ /** @import { StoreReferencesContainer } from '#client' */ | ||
import { noop } from '../../shared/utils.js'; | ||
import { UNINITIALIZED } from '../../../constants.js'; | ||
import { get } from '../runtime.js'; | ||
@@ -24,3 +23,3 @@ import { teardown } from './effects.js'; | ||
store: null, | ||
source: mutable_source(UNINITIALIZED), | ||
source: mutable_source(undefined), | ||
unsubscribe: noop | ||
@@ -37,3 +36,14 @@ }); | ||
} else { | ||
entry.unsubscribe = subscribe_to_store(store, (v) => set(entry.source, v)); | ||
var initial = true; | ||
entry.unsubscribe = subscribe_to_store(store, (v) => { | ||
if (initial) { | ||
// if the first time the store value is read is inside a derived, | ||
// we will hit the `state_unsafe_mutation` error if we `set` the value | ||
entry.source.v = v; | ||
initial = false; | ||
} else { | ||
set(entry.source, v); | ||
} | ||
}); | ||
} | ||
@@ -40,0 +50,0 @@ } |
import { DEV } from 'esm-env'; | ||
import { clear_text_content, create_element, empty, init_operations } from './dom/operations.js'; | ||
import { clear_text_content, empty, init_operations } from './dom/operations.js'; | ||
import { HYDRATION_ERROR, HYDRATION_START, PassiveDelegatedEvents } from '../../constants.js'; | ||
import { flush_sync, push, pop, current_component_context, current_effect } from './runtime.js'; | ||
import { flush_sync, push, pop, current_component_context } from './runtime.js'; | ||
import { effect_root, branch } from './reactivity/effects.js'; | ||
@@ -9,3 +9,2 @@ import { | ||
hydrate_nodes, | ||
hydrating, | ||
set_hydrate_nodes, | ||
@@ -308,3 +307,3 @@ set_hydrating | ||
if (!append_styles_to.getElementById(style_sheet_id)) { | ||
const style = create_element('style'); | ||
const style = document.createElement('style'); | ||
style.id = style_sheet_id; | ||
@@ -311,0 +310,0 @@ style.textContent = styles; |
@@ -1141,3 +1141,3 @@ import { DEV } from 'esm-env'; | ||
visited.add(value); | ||
// When working with a possible ReactiveDate, this | ||
// When working with a possible SvelteDate, this | ||
// will ensure we capture changes to it. | ||
@@ -1144,0 +1144,0 @@ if (value instanceof Date) { |
@@ -116,3 +116,3 @@ import { is_promise, noop } from '../shared/utils.js'; | ||
// @ts-expect-error | ||
component(payload, options.props, {}, {}); | ||
component(payload, options.props ?? {}, {}, {}); | ||
@@ -119,0 +119,0 @@ if (options.context) { |
@@ -0,89 +1,58 @@ | ||
/** @import { Source } from '#client' */ | ||
import { derived } from '../internal/client/index.js'; | ||
import { source, set } from '../internal/client/reactivity/sources.js'; | ||
import { get } from '../internal/client/runtime.js'; | ||
/** @type {Array<keyof Date>} */ | ||
const read = [ | ||
'getDate', | ||
'getDay', | ||
'getFullYear', | ||
'getHours', | ||
'getMilliseconds', | ||
'getMinutes', | ||
'getMonth', | ||
'getSeconds', | ||
'getTime', | ||
'getTimezoneOffset', | ||
'getUTCDate', | ||
'getUTCDay', | ||
'getUTCFullYear', | ||
'getUTCHours', | ||
'getUTCMilliseconds', | ||
'getUTCMinutes', | ||
'getUTCMonth', | ||
'getUTCSeconds', | ||
// @ts-expect-error this is deprecated | ||
'getYear', | ||
'toDateString', | ||
'toISOString', | ||
'toJSON', | ||
'toLocaleDateString', | ||
'toLocaleString', | ||
'toLocaleTimeString', | ||
'toString', | ||
'toTimeString', | ||
'toUTCString' | ||
]; | ||
/** @type {Array<keyof Date>} */ | ||
const write = [ | ||
'setDate', | ||
'setFullYear', | ||
'setHours', | ||
'setMilliseconds', | ||
'setMinutes', | ||
'setMonth', | ||
'setSeconds', | ||
'setTime', | ||
'setUTCDate', | ||
'setUTCFullYear', | ||
'setUTCHours', | ||
'setUTCMilliseconds', | ||
'setUTCMinutes', | ||
'setUTCMonth', | ||
'setUTCSeconds', | ||
// @ts-expect-error this is deprecated | ||
'setYear' | ||
]; | ||
var inited = false; | ||
export class SvelteDate extends Date { | ||
#raw_time = source(super.getTime()); | ||
#time = source(super.getTime()); | ||
// We init as part of the first instance so that we can treeshake this class | ||
/** @type {Map<keyof Date, Source<unknown>>} */ | ||
#deriveds = new Map(); | ||
/** @param {any[]} params */ | ||
constructor(...params) { | ||
// @ts-ignore | ||
super(...params); | ||
if (!inited) this.#init(); | ||
} | ||
#init() { | ||
if (!inited) { | ||
inited = true; | ||
const proto = SvelteDate.prototype; | ||
const date_proto = Date.prototype; | ||
inited = true; | ||
for (const method of read) { | ||
var proto = SvelteDate.prototype; | ||
var date_proto = Date.prototype; | ||
var methods = /** @type {Array<keyof Date & string>} */ ( | ||
Object.getOwnPropertyNames(date_proto) | ||
); | ||
for (const method of methods) { | ||
if (method.startsWith('get') || method.startsWith('to')) { | ||
// @ts-ignore | ||
proto[method] = function (...args) { | ||
get(this.#raw_time); | ||
// @ts-ignore | ||
return date_proto[method].apply(this, args); | ||
var d = this.#deriveds.get(method); | ||
if (d === undefined) { | ||
d = derived(() => { | ||
get(this.#time); | ||
// @ts-ignore | ||
return date_proto[method].apply(this, args); | ||
}); | ||
this.#deriveds.set(method, d); | ||
} | ||
return get(d); | ||
}; | ||
} | ||
for (const method of write) { | ||
if (method.startsWith('set')) { | ||
// @ts-ignore | ||
proto[method] = function (...args) { | ||
// @ts-ignore | ||
const v = date_proto[method].apply(this, args); | ||
const time = date_proto.getTime.call(this); | ||
if (time !== this.#raw_time.v) { | ||
set(this.#raw_time, time); | ||
} | ||
return v; | ||
var result = date_proto[method].apply(this, args); | ||
set(this.#time, date_proto.getTime.call(this)); | ||
return result; | ||
}; | ||
@@ -93,11 +62,2 @@ } | ||
} | ||
/** | ||
* @param {any[]} values | ||
*/ | ||
constructor(...values) { | ||
// @ts-ignore | ||
super(...values); | ||
this.#init(); | ||
} | ||
} |
@@ -9,3 +9,3 @@ // generated during release, do not modify | ||
*/ | ||
export const VERSION = '5.0.0-next.173'; | ||
export const VERSION = '5.0.0-next.174'; | ||
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2113080
46316