svelte 4.2.0 → 4.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compiler.cjs +105 -56
- package/elements.d.ts +1 -0
- package/package.json +3 -2
- package/src/.eslintrc.json +6 -0
- package/src/compiler/compile/Component.js +2 -2
- package/src/compiler/compile/create_module.js +10 -10
- package/src/compiler/compile/nodes/Binding.js +2 -2
- package/src/compiler/compile/nodes/EachBlock.js +5 -3
- package/src/compiler/compile/nodes/Element.js +31 -3
- package/src/compiler/compile/nodes/shared/get_const_tags.js +2 -2
- package/src/compiler/compile/render_dom/wrappers/Element/index.js +3 -6
- package/src/compiler/compile/render_dom/wrappers/InlineComponent/index.js +8 -3
- package/src/compiler/compile/render_dom/wrappers/Window.js +8 -8
- package/src/compiler/compile/render_dom/wrappers/shared/is_dynamic.js +5 -2
- package/src/compiler/compile/render_ssr/index.js +4 -0
- package/src/compiler/parse/read/css-tree-cq/css_tree_parse.js +4 -4
- package/src/compiler/parse/read/css-tree-cq/node/query_feature_range.js +3 -3
- package/src/compiler/utils/mapped_code.js +12 -1
- package/src/runtime/internal/Component.js +15 -4
- package/src/runtime/internal/dom.js +35 -33
- package/src/shared/version.js +1 -1
- package/types/index.d.ts.map +1 -1
package/compiler.cjs
CHANGED
|
@@ -9042,16 +9042,16 @@ function encodeInteger(buf, pos, state, segment, j) {
|
|
|
9042
9042
|
}
|
|
9043
9043
|
|
|
9044
9044
|
/** @type {(str?: string) => string} str */
|
|
9045
|
-
let btoa$
|
|
9045
|
+
let btoa$1 = () => {
|
|
9046
9046
|
throw new Error(
|
|
9047
9047
|
'Unsupported environment: `window.btoa` or `Buffer` should be supported.'
|
|
9048
9048
|
);
|
|
9049
9049
|
};
|
|
9050
9050
|
|
|
9051
9051
|
if (typeof window !== 'undefined' && typeof window.btoa === 'function') {
|
|
9052
|
-
btoa$
|
|
9052
|
+
btoa$1 = (str) => window.btoa(unescape(encodeURIComponent(str)));
|
|
9053
9053
|
} else if (typeof Buffer === 'function') {
|
|
9054
|
-
btoa$
|
|
9054
|
+
btoa$1 = (str) => Buffer.from(str, 'utf-8').toString('base64');
|
|
9055
9055
|
}
|
|
9056
9056
|
|
|
9057
9057
|
/** @typedef {import('estree').Node} Node */
|
|
@@ -9171,7 +9171,7 @@ function print(node, opts = {}) {
|
|
|
9171
9171
|
enumerable: false,
|
|
9172
9172
|
value: function toUrl() {
|
|
9173
9173
|
return (
|
|
9174
|
-
'data:application/json;charset=utf-8;base64,' + btoa$
|
|
9174
|
+
'data:application/json;charset=utf-8;base64,' + btoa$1(this.toString())
|
|
9175
9175
|
);
|
|
9176
9176
|
}
|
|
9177
9177
|
}
|
|
@@ -10203,7 +10203,7 @@ const structure$1 = {
|
|
|
10203
10203
|
value: ['Identifier', 'Number', 'Comparison', 'Dimension', 'QueryCSSFunction', 'Ratio', null]
|
|
10204
10204
|
};
|
|
10205
10205
|
|
|
10206
|
-
function
|
|
10206
|
+
function lookup_non_ws_type_and_value(offset, type, reference_str) {
|
|
10207
10207
|
let current_type;
|
|
10208
10208
|
|
|
10209
10209
|
do {
|
|
@@ -10213,7 +10213,7 @@ function lookup_non_WS_type_and_value(offset, type, referenceStr) {
|
|
|
10213
10213
|
}
|
|
10214
10214
|
} while (current_type !== 0); // NULL -> 0
|
|
10215
10215
|
|
|
10216
|
-
return current_type === type ? this.lookupValue(offset - 1,
|
|
10216
|
+
return current_type === type ? this.lookupValue(offset - 1, reference_str) : false;
|
|
10217
10217
|
}
|
|
10218
10218
|
|
|
10219
10219
|
function parse$3() {
|
|
@@ -10227,7 +10227,7 @@ function parse$3() {
|
|
|
10227
10227
|
while (!this.eof && this.tokenType !== RightParenthesis) {
|
|
10228
10228
|
switch (this.tokenType) {
|
|
10229
10229
|
case Number$1:
|
|
10230
|
-
if (
|
|
10230
|
+
if (lookup_non_ws_type_and_value.call(this, 1, Delim, '/')) {
|
|
10231
10231
|
child = this.Ratio();
|
|
10232
10232
|
} else {
|
|
10233
10233
|
child = this.Number();
|
|
@@ -10346,7 +10346,7 @@ QueryFeatureRange: query_feature_range
|
|
|
10346
10346
|
*
|
|
10347
10347
|
* The new nodes are located in `./node`.
|
|
10348
10348
|
*/
|
|
10349
|
-
const
|
|
10349
|
+
const cq_syntax = Ab({
|
|
10350
10350
|
atrule: {
|
|
10351
10351
|
// extend or override at-rule dictionary
|
|
10352
10352
|
container: {
|
|
@@ -10354,8 +10354,8 @@ const cqSyntax = Ab({
|
|
|
10354
10354
|
prelude() {
|
|
10355
10355
|
return this.createSingleNodeList(this.ContainerQuery());
|
|
10356
10356
|
},
|
|
10357
|
-
block(
|
|
10358
|
-
return this.Block(
|
|
10357
|
+
block(is_style_block = false) {
|
|
10358
|
+
return this.Block(is_style_block);
|
|
10359
10359
|
}
|
|
10360
10360
|
}
|
|
10361
10361
|
}
|
|
@@ -10363,7 +10363,7 @@ const cqSyntax = Ab({
|
|
|
10363
10363
|
node
|
|
10364
10364
|
});
|
|
10365
10365
|
|
|
10366
|
-
const parse$1 =
|
|
10366
|
+
const parse$1 = cq_syntax.parse;
|
|
10367
10367
|
|
|
10368
10368
|
// @ts-ignore
|
|
10369
10369
|
// import parse from 'css-tree/parser'; // When css-tree supports container queries uncomment.
|
|
@@ -15697,8 +15697,11 @@ function is_reserved_keyword(name) {
|
|
|
15697
15697
|
/** @param {import('../../../../interfaces.js').Var} variable */
|
|
15698
15698
|
function is_dynamic$1(variable) {
|
|
15699
15699
|
if (variable) {
|
|
15700
|
-
|
|
15701
|
-
|
|
15700
|
+
// Only variables declared in the instance script tags should be considered dynamic
|
|
15701
|
+
const is_declared_in_reactive_context = !variable.module && !variable.global;
|
|
15702
|
+
|
|
15703
|
+
if (is_declared_in_reactive_context && (variable.mutated || variable.reassigned)) return true; // dynamic internal state
|
|
15704
|
+
if (is_declared_in_reactive_context && variable.writable && variable.export_name) return true; // writable props
|
|
15702
15705
|
if (is_reserved_keyword(variable.name)) return true;
|
|
15703
15706
|
}
|
|
15704
15707
|
return false;
|
|
@@ -17482,7 +17485,9 @@ let EachBlock$1 = class EachBlock extends AbstractBlock {
|
|
|
17482
17485
|
this.has_animation = false;
|
|
17483
17486
|
[this.const_tags, this.children] = get_const_tags$1(info.children, component, this, this);
|
|
17484
17487
|
if (this.has_animation) {
|
|
17485
|
-
this.children = this.children.filter(
|
|
17488
|
+
this.children = this.children.filter(
|
|
17489
|
+
(child) => !is_empty_node(child) && !is_comment_node(child)
|
|
17490
|
+
);
|
|
17486
17491
|
if (this.children.length !== 1) {
|
|
17487
17492
|
const child = this.children.find(
|
|
17488
17493
|
(child) => !!(/** @type {import('./Element.js').default} */ (child).animation)
|
|
@@ -17500,12 +17505,12 @@ let EachBlock$1 = class EachBlock extends AbstractBlock {
|
|
|
17500
17505
|
};
|
|
17501
17506
|
|
|
17502
17507
|
/** @param {import('./interfaces.js').INode} node */
|
|
17503
|
-
function
|
|
17508
|
+
function is_empty_node(node) {
|
|
17504
17509
|
return node.type === 'Text' && node.data.trim() === '';
|
|
17505
17510
|
}
|
|
17506
17511
|
|
|
17507
17512
|
/** @param {import('./interfaces.js').INode} node */
|
|
17508
|
-
function
|
|
17513
|
+
function is_comment_node(node) {
|
|
17509
17514
|
return node.type === 'Comment';
|
|
17510
17515
|
}
|
|
17511
17516
|
|
|
@@ -17601,7 +17606,7 @@ class Binding extends Node {
|
|
|
17601
17606
|
this.is_readonly =
|
|
17602
17607
|
regex_dimensions.test(this.name) ||
|
|
17603
17608
|
regex_box_size.test(this.name) ||
|
|
17604
|
-
(
|
|
17609
|
+
(is_element(parent) &&
|
|
17605
17610
|
((parent.is_media_node() && read_only_media_attributes.has(this.name)) ||
|
|
17606
17611
|
(parent.name === 'input' && type === 'file'))) /* TODO others? */;
|
|
17607
17612
|
}
|
|
@@ -17630,7 +17635,7 @@ class Binding extends Node {
|
|
|
17630
17635
|
* @param {import('./shared/Node.js').default} node
|
|
17631
17636
|
* @returns {node is import('./Element.js').default}
|
|
17632
17637
|
*/
|
|
17633
|
-
function
|
|
17638
|
+
function is_element(node) {
|
|
17634
17639
|
return !!(/** @type {any} */ (node).is_media_node);
|
|
17635
17640
|
}
|
|
17636
17641
|
|
|
@@ -28074,7 +28079,7 @@ let Element$1 = class Element extends Node {
|
|
|
28074
28079
|
}
|
|
28075
28080
|
if (this.name === 'textarea') {
|
|
28076
28081
|
if (info.children.length > 0) {
|
|
28077
|
-
const value_attribute = info.attributes
|
|
28082
|
+
const value_attribute = get_value_attribute(info.attributes);
|
|
28078
28083
|
if (value_attribute) {
|
|
28079
28084
|
component.error(value_attribute, compiler_errors.textarea_duplicate_value);
|
|
28080
28085
|
return;
|
|
@@ -28093,7 +28098,7 @@ let Element$1 = class Element extends Node {
|
|
|
28093
28098
|
// Special case — treat these the same way:
|
|
28094
28099
|
// <option>{foo}</option>
|
|
28095
28100
|
// <option value={foo}>{foo}</option>
|
|
28096
|
-
const value_attribute = info.attributes
|
|
28101
|
+
const value_attribute = get_value_attribute(info.attributes);
|
|
28097
28102
|
if (!value_attribute) {
|
|
28098
28103
|
info.attributes.push({
|
|
28099
28104
|
type: 'Attribute',
|
|
@@ -28519,7 +28524,7 @@ let Element$1 = class Element extends Node {
|
|
|
28519
28524
|
) {
|
|
28520
28525
|
const interactive_handlers = handlers
|
|
28521
28526
|
.map((handler) => handler.name)
|
|
28522
|
-
.filter((
|
|
28527
|
+
.filter((handler_name) => a11y_interactive_handlers.has(handler_name));
|
|
28523
28528
|
if (interactive_handlers.length > 0) {
|
|
28524
28529
|
component.warn(
|
|
28525
28530
|
this,
|
|
@@ -29065,6 +29070,33 @@ function within_custom_element(parent) {
|
|
|
29065
29070
|
return false;
|
|
29066
29071
|
}
|
|
29067
29072
|
|
|
29073
|
+
/**
|
|
29074
|
+
* @param {any[]} attributes
|
|
29075
|
+
*/
|
|
29076
|
+
function get_value_attribute(attributes) {
|
|
29077
|
+
let node_value;
|
|
29078
|
+
attributes.forEach((node) => {
|
|
29079
|
+
if (node.type !== 'Spread' && node.name.toLowerCase() === 'value') {
|
|
29080
|
+
node_value = node;
|
|
29081
|
+
}
|
|
29082
|
+
if (node.type === 'Spread') {
|
|
29083
|
+
walk(/** @type {any} */ (node.expression), {
|
|
29084
|
+
enter(/** @type {import('estree').Node} */ node) {
|
|
29085
|
+
if (node_value) {
|
|
29086
|
+
this.skip();
|
|
29087
|
+
}
|
|
29088
|
+
if (node.type === 'Identifier') {
|
|
29089
|
+
if (/** @type {import('estree').Identifier} */ (node).name.toLowerCase() === 'value') {
|
|
29090
|
+
node_value = node;
|
|
29091
|
+
}
|
|
29092
|
+
}
|
|
29093
|
+
}
|
|
29094
|
+
});
|
|
29095
|
+
}
|
|
29096
|
+
});
|
|
29097
|
+
return node_value;
|
|
29098
|
+
}
|
|
29099
|
+
|
|
29068
29100
|
/** @extends Node<'Head'> */
|
|
29069
29101
|
let Head$1 = class Head extends Node {
|
|
29070
29102
|
/** @type {any[]} */
|
|
@@ -29846,8 +29878,8 @@ function sort_consts_nodes(consts_nodes, component) {
|
|
|
29846
29878
|
}, [])
|
|
29847
29879
|
);
|
|
29848
29880
|
if (cycle && cycle.length) {
|
|
29849
|
-
const
|
|
29850
|
-
const node =
|
|
29881
|
+
const node_list = lookup.get(cycle[0]);
|
|
29882
|
+
const node = node_list[0];
|
|
29851
29883
|
component.error(node.node, compiler_errors.cyclical_const_tags(cycle));
|
|
29852
29884
|
}
|
|
29853
29885
|
|
|
@@ -33703,7 +33735,8 @@ class ElementWrapper extends Wrapper {
|
|
|
33703
33735
|
const static_attributes = [];
|
|
33704
33736
|
this.attributes.forEach((attr) => {
|
|
33705
33737
|
if (attr instanceof SpreadAttributeWrapper) {
|
|
33706
|
-
|
|
33738
|
+
const snippet = { type: 'SpreadElement', argument: attr.node.expression.manipulate(block) };
|
|
33739
|
+
static_attributes.push(snippet);
|
|
33707
33740
|
} else {
|
|
33708
33741
|
const name = attr.property_name || attr.name;
|
|
33709
33742
|
static_attributes.push(p`${name}: ${attr.get_value(block)}`);
|
|
@@ -33953,11 +33986,7 @@ class ElementWrapper extends Wrapper {
|
|
|
33953
33986
|
}
|
|
33954
33987
|
if (this.dynamic_style_dependencies.size > 0) {
|
|
33955
33988
|
maybe_create_style_changed_var();
|
|
33956
|
-
|
|
33957
|
-
condition =
|
|
33958
|
-
all_deps.size === this.dynamic_style_dependencies.size
|
|
33959
|
-
? style_changed_var
|
|
33960
|
-
: x$1`${style_changed_var} || ${condition}`;
|
|
33989
|
+
condition = x$1`${condition} || ${style_changed_var}`;
|
|
33961
33990
|
}
|
|
33962
33991
|
block.chunks.update.push(b$1`
|
|
33963
33992
|
if (${condition}) {
|
|
@@ -35254,14 +35283,19 @@ class InlineComponentWrapper extends Wrapper {
|
|
|
35254
35283
|
this.slots.set(name, slot_definition);
|
|
35255
35284
|
}
|
|
35256
35285
|
warn_if_reactive() {
|
|
35257
|
-
|
|
35258
|
-
const
|
|
35286
|
+
let { name } = this.node;
|
|
35287
|
+
const top = name.split('.')[0]; // <T.foo/> etc. should check for T instead of "T.foo"
|
|
35288
|
+
const variable = this.renderer.component.var_lookup.get(top);
|
|
35259
35289
|
if (!variable) {
|
|
35260
35290
|
return;
|
|
35261
35291
|
}
|
|
35262
35292
|
const ignores = extract_ignores_above_node(this.node);
|
|
35263
35293
|
this.renderer.component.push_ignores(ignores);
|
|
35264
|
-
if (
|
|
35294
|
+
if (
|
|
35295
|
+
variable.reassigned ||
|
|
35296
|
+
variable.export_name || // or a prop
|
|
35297
|
+
variable.mutated
|
|
35298
|
+
) {
|
|
35265
35299
|
this.renderer.component.warn(this.node, compiler_warnings.reactive_component(name));
|
|
35266
35300
|
}
|
|
35267
35301
|
this.renderer.component.pop_ignores();
|
|
@@ -36270,14 +36304,14 @@ class WindowWrapper extends Wrapper {
|
|
|
36270
36304
|
bindings.scrollX && bindings.scrollY
|
|
36271
36305
|
? x$1`"${bindings.scrollX}" in this._state || "${bindings.scrollY}" in this._state`
|
|
36272
36306
|
: x$1`"${bindings.scrollX || bindings.scrollY}" in this._state`;
|
|
36273
|
-
const
|
|
36274
|
-
const
|
|
36307
|
+
const scroll_x = bindings.scrollX && x$1`this._state.${bindings.scrollX}`;
|
|
36308
|
+
const scroll_y = bindings.scrollY && x$1`this._state.${bindings.scrollY}`;
|
|
36275
36309
|
renderer.meta_bindings.push(b$1`
|
|
36276
36310
|
if (${condition}) {
|
|
36277
|
-
@_scrollTo(${
|
|
36311
|
+
@_scrollTo(${scroll_x || '@_window.pageXOffset'}, ${scroll_y || '@_window.pageYOffset'});
|
|
36278
36312
|
}
|
|
36279
|
-
${
|
|
36280
|
-
${
|
|
36313
|
+
${scroll_x && `${scroll_x} = @_window.pageXOffset;`}
|
|
36314
|
+
${scroll_y && `${scroll_y} = @_window.pageYOffset;`}
|
|
36281
36315
|
`);
|
|
36282
36316
|
block.event_listeners.push(x$1`
|
|
36283
36317
|
@listen(@_window, "${event}", () => {
|
|
@@ -36308,17 +36342,17 @@ class WindowWrapper extends Wrapper {
|
|
|
36308
36342
|
// special case... might need to abstract this out if we add more special cases
|
|
36309
36343
|
if (bindings.scrollX || bindings.scrollY) {
|
|
36310
36344
|
const condition = renderer.dirty([bindings.scrollX, bindings.scrollY].filter(Boolean));
|
|
36311
|
-
const
|
|
36345
|
+
const scroll_x = bindings.scrollX
|
|
36312
36346
|
? renderer.reference(bindings.scrollX)
|
|
36313
36347
|
: x$1`@_window.pageXOffset`;
|
|
36314
|
-
const
|
|
36348
|
+
const scroll_y = bindings.scrollY
|
|
36315
36349
|
? renderer.reference(bindings.scrollY)
|
|
36316
36350
|
: x$1`@_window.pageYOffset`;
|
|
36317
36351
|
block.chunks.update.push(b$1`
|
|
36318
36352
|
if (${condition} && !${scrolling}) {
|
|
36319
36353
|
${scrolling} = true;
|
|
36320
36354
|
@_clearTimeout(${scrolling_timeout});
|
|
36321
|
-
@_scrollTo(${
|
|
36355
|
+
@_scrollTo(${scroll_x}, ${scroll_y});
|
|
36322
36356
|
${scrolling_timeout} = @_setTimeout(${clear_scrolling}, 100);
|
|
36323
36357
|
}
|
|
36324
36358
|
`);
|
|
@@ -38054,7 +38088,18 @@ function apply_preprocessor_sourcemap(filename, svelte_map, preprocessor_map_inp
|
|
|
38054
38088
|
toUrl: {
|
|
38055
38089
|
enumerable: false,
|
|
38056
38090
|
value: function toUrl() {
|
|
38057
|
-
|
|
38091
|
+
let b64 = '';
|
|
38092
|
+
if (typeof window !== 'undefined' && window.btoa) {
|
|
38093
|
+
// btoa doesn't support multi-byte characters
|
|
38094
|
+
b64 = window.btoa(unescape(encodeURIComponent(this.toString())));
|
|
38095
|
+
} else if (typeof Buffer !== 'undefined') {
|
|
38096
|
+
b64 = Buffer.from(this.toString(), 'utf8').toString('base64');
|
|
38097
|
+
} else {
|
|
38098
|
+
throw new Error(
|
|
38099
|
+
'Unsupported environment: `window.btoa` or `Buffer` should be present to use toUrl.'
|
|
38100
|
+
);
|
|
38101
|
+
}
|
|
38102
|
+
return 'data:application/json;charset=utf-8;base64,' + b64;
|
|
38058
38103
|
}
|
|
38059
38104
|
}
|
|
38060
38105
|
});
|
|
@@ -39803,9 +39848,13 @@ function ssr(component, options) {
|
|
|
39803
39848
|
? b$1`
|
|
39804
39849
|
let $$settled;
|
|
39805
39850
|
let $$rendered;
|
|
39851
|
+
let #previous_head = $$result.head;
|
|
39806
39852
|
|
|
39807
39853
|
do {
|
|
39808
39854
|
$$settled = true;
|
|
39855
|
+
// $$result.head is mutated by the literal expression
|
|
39856
|
+
// need to reset it if we're looping back to prevent duplication
|
|
39857
|
+
$$result.head = #previous_head;
|
|
39809
39858
|
|
|
39810
39859
|
${reactive_declarations}
|
|
39811
39860
|
|
|
@@ -40720,7 +40769,7 @@ var globals = new Set([
|
|
|
40720
40769
|
* @param {any} program
|
|
40721
40770
|
* @param {import('estree').Identifier} name
|
|
40722
40771
|
* @param {string} banner
|
|
40723
|
-
* @param {any}
|
|
40772
|
+
* @param {any} svelte_path
|
|
40724
40773
|
* @param {Array<{ name: string; alias: import('estree').Identifier }>} helpers
|
|
40725
40774
|
* @param {Array<{ name: string; alias: import('estree').Identifier }>} globals
|
|
40726
40775
|
* @param {import('estree').ImportDeclaration[]} imports
|
|
@@ -40731,21 +40780,21 @@ function create_module(
|
|
|
40731
40780
|
program,
|
|
40732
40781
|
name,
|
|
40733
40782
|
banner,
|
|
40734
|
-
|
|
40783
|
+
svelte_path = 'svelte',
|
|
40735
40784
|
helpers,
|
|
40736
40785
|
globals,
|
|
40737
40786
|
imports,
|
|
40738
40787
|
module_exports,
|
|
40739
40788
|
exports_from
|
|
40740
40789
|
) {
|
|
40741
|
-
const internal_path = `${
|
|
40790
|
+
const internal_path = `${svelte_path}/internal`;
|
|
40742
40791
|
helpers.sort((a, b) => (a.name < b.name ? -1 : 1));
|
|
40743
40792
|
globals.sort((a, b) => (a.name < b.name ? -1 : 1));
|
|
40744
40793
|
return esm(
|
|
40745
40794
|
program,
|
|
40746
40795
|
name,
|
|
40747
40796
|
banner,
|
|
40748
|
-
|
|
40797
|
+
svelte_path,
|
|
40749
40798
|
internal_path,
|
|
40750
40799
|
helpers,
|
|
40751
40800
|
globals,
|
|
@@ -40757,11 +40806,11 @@ function create_module(
|
|
|
40757
40806
|
|
|
40758
40807
|
/**
|
|
40759
40808
|
* @param {any} source
|
|
40760
|
-
* @param {any}
|
|
40809
|
+
* @param {any} svelte_path
|
|
40761
40810
|
*/
|
|
40762
|
-
function edit_source(source,
|
|
40811
|
+
function edit_source(source, svelte_path) {
|
|
40763
40812
|
return source === 'svelte' || source.startsWith('svelte/')
|
|
40764
|
-
? source.replace('svelte',
|
|
40813
|
+
? source.replace('svelte', svelte_path)
|
|
40765
40814
|
: source;
|
|
40766
40815
|
}
|
|
40767
40816
|
|
|
@@ -40800,7 +40849,7 @@ function get_internal_globals(globals, helpers) {
|
|
|
40800
40849
|
* @param {any} program
|
|
40801
40850
|
* @param {import('estree').Identifier} name
|
|
40802
40851
|
* @param {string} banner
|
|
40803
|
-
* @param {string}
|
|
40852
|
+
* @param {string} svelte_path
|
|
40804
40853
|
* @param {string} internal_path
|
|
40805
40854
|
* @param {Array<{ name: string; alias: import('estree').Identifier }>} helpers
|
|
40806
40855
|
* @param {Array<{ name: string; alias: import('estree').Identifier }>} globals
|
|
@@ -40812,7 +40861,7 @@ function esm(
|
|
|
40812
40861
|
program,
|
|
40813
40862
|
name,
|
|
40814
40863
|
banner,
|
|
40815
|
-
|
|
40864
|
+
svelte_path,
|
|
40816
40865
|
internal_path,
|
|
40817
40866
|
helpers,
|
|
40818
40867
|
globals,
|
|
@@ -40834,7 +40883,7 @@ function esm(
|
|
|
40834
40883
|
|
|
40835
40884
|
/** @param {any} node */
|
|
40836
40885
|
function rewrite_import(node) {
|
|
40837
|
-
const value = edit_source(node.source.value,
|
|
40886
|
+
const value = edit_source(node.source.value, svelte_path);
|
|
40838
40887
|
if (node.source.value !== value) {
|
|
40839
40888
|
node.source.value = value;
|
|
40840
40889
|
node.source.raw = null;
|
|
@@ -41051,7 +41100,7 @@ function getBtoa () {
|
|
|
41051
41100
|
}
|
|
41052
41101
|
}
|
|
41053
41102
|
|
|
41054
|
-
const btoa
|
|
41103
|
+
const btoa = /*#__PURE__*/ getBtoa();
|
|
41055
41104
|
|
|
41056
41105
|
class SourceMap {
|
|
41057
41106
|
constructor(properties) {
|
|
@@ -41071,7 +41120,7 @@ class SourceMap {
|
|
|
41071
41120
|
}
|
|
41072
41121
|
|
|
41073
41122
|
toUrl() {
|
|
41074
|
-
return 'data:application/json;charset=utf-8;base64,' + btoa
|
|
41123
|
+
return 'data:application/json;charset=utf-8;base64,' + btoa(this.toString());
|
|
41075
41124
|
}
|
|
41076
41125
|
}
|
|
41077
41126
|
|
|
@@ -43526,7 +43575,7 @@ function is_used_as_reference(node, parent) {
|
|
|
43526
43575
|
* https://svelte.dev/docs/svelte-compiler#svelte-version
|
|
43527
43576
|
* @type {string}
|
|
43528
43577
|
*/
|
|
43529
|
-
const VERSION = '4.2.
|
|
43578
|
+
const VERSION = '4.2.1';
|
|
43530
43579
|
|
|
43531
43580
|
const regex_leading_directory_separator = /^[/\\]/;
|
|
43532
43581
|
const regex_starts_with_term_export = /^Export/;
|
|
@@ -45052,8 +45101,8 @@ class Component {
|
|
|
45052
45101
|
}, [])
|
|
45053
45102
|
);
|
|
45054
45103
|
if (cycle && cycle.length) {
|
|
45055
|
-
const
|
|
45056
|
-
const declaration =
|
|
45104
|
+
const declaration_list = lookup.get(cycle[0]);
|
|
45105
|
+
const declaration = declaration_list[0];
|
|
45057
45106
|
return this.error(declaration.node, compiler_errors.cyclical_reactive_declaration(cycle));
|
|
45058
45107
|
}
|
|
45059
45108
|
|
package/elements.d.ts
CHANGED
|
@@ -808,6 +808,7 @@ export interface HTMLInputAttributes extends HTMLAttributes<HTMLInputElement> {
|
|
|
808
808
|
formnovalidate?: boolean | undefined | null;
|
|
809
809
|
formtarget?: string | undefined | null;
|
|
810
810
|
height?: number | string | undefined | null;
|
|
811
|
+
indeterminate?: boolean | undefined | null;
|
|
811
812
|
list?: string | undefined | null;
|
|
812
813
|
max?: number | string | undefined | null;
|
|
813
814
|
maxlength?: number | undefined | null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svelte",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.1",
|
|
4
4
|
"description": "Cybernetically enhanced web apps",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "src/runtime/index.js",
|
|
@@ -117,6 +117,7 @@
|
|
|
117
117
|
"agadoo": "^3.0.0",
|
|
118
118
|
"dts-buddy": "^0.1.7",
|
|
119
119
|
"esbuild": "^0.18.11",
|
|
120
|
+
"eslint-plugin-lube": "^0.1.7",
|
|
120
121
|
"happy-dom": "^9.20.3",
|
|
121
122
|
"jsdom": "^21.1.2",
|
|
122
123
|
"kleur": "^4.1.5",
|
|
@@ -135,6 +136,6 @@
|
|
|
135
136
|
"dev": "rollup -cw",
|
|
136
137
|
"posttest": "agadoo src/internal/index.js",
|
|
137
138
|
"types": "node ./scripts/generate-dts.js",
|
|
138
|
-
"lint": "prettier . --cache --plugin-search-dir=. --check && eslint \"{src,test}/**/*.
|
|
139
|
+
"lint": "prettier . --cache --plugin-search-dir=. --check && eslint \"{scripts,src,test}/**/*.js\" --cache --fix"
|
|
139
140
|
}
|
|
140
141
|
}
|
|
@@ -1555,8 +1555,8 @@ export default class Component {
|
|
|
1555
1555
|
}, [])
|
|
1556
1556
|
);
|
|
1557
1557
|
if (cycle && cycle.length) {
|
|
1558
|
-
const
|
|
1559
|
-
const declaration =
|
|
1558
|
+
const declaration_list = lookup.get(cycle[0]);
|
|
1559
|
+
const declaration = declaration_list[0];
|
|
1560
1560
|
return this.error(declaration.node, compiler_errors.cyclical_reactive_declaration(cycle));
|
|
1561
1561
|
}
|
|
1562
1562
|
|
|
@@ -4,7 +4,7 @@ import { b } from 'code-red';
|
|
|
4
4
|
* @param {any} program
|
|
5
5
|
* @param {import('estree').Identifier} name
|
|
6
6
|
* @param {string} banner
|
|
7
|
-
* @param {any}
|
|
7
|
+
* @param {any} svelte_path
|
|
8
8
|
* @param {Array<{ name: string; alias: import('estree').Identifier }>} helpers
|
|
9
9
|
* @param {Array<{ name: string; alias: import('estree').Identifier }>} globals
|
|
10
10
|
* @param {import('estree').ImportDeclaration[]} imports
|
|
@@ -15,21 +15,21 @@ export default function create_module(
|
|
|
15
15
|
program,
|
|
16
16
|
name,
|
|
17
17
|
banner,
|
|
18
|
-
|
|
18
|
+
svelte_path = 'svelte',
|
|
19
19
|
helpers,
|
|
20
20
|
globals,
|
|
21
21
|
imports,
|
|
22
22
|
module_exports,
|
|
23
23
|
exports_from
|
|
24
24
|
) {
|
|
25
|
-
const internal_path = `${
|
|
25
|
+
const internal_path = `${svelte_path}/internal`;
|
|
26
26
|
helpers.sort((a, b) => (a.name < b.name ? -1 : 1));
|
|
27
27
|
globals.sort((a, b) => (a.name < b.name ? -1 : 1));
|
|
28
28
|
return esm(
|
|
29
29
|
program,
|
|
30
30
|
name,
|
|
31
31
|
banner,
|
|
32
|
-
|
|
32
|
+
svelte_path,
|
|
33
33
|
internal_path,
|
|
34
34
|
helpers,
|
|
35
35
|
globals,
|
|
@@ -41,11 +41,11 @@ export default function create_module(
|
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
43
|
* @param {any} source
|
|
44
|
-
* @param {any}
|
|
44
|
+
* @param {any} svelte_path
|
|
45
45
|
*/
|
|
46
|
-
function edit_source(source,
|
|
46
|
+
function edit_source(source, svelte_path) {
|
|
47
47
|
return source === 'svelte' || source.startsWith('svelte/')
|
|
48
|
-
? source.replace('svelte',
|
|
48
|
+
? source.replace('svelte', svelte_path)
|
|
49
49
|
: source;
|
|
50
50
|
}
|
|
51
51
|
|
|
@@ -84,7 +84,7 @@ function get_internal_globals(globals, helpers) {
|
|
|
84
84
|
* @param {any} program
|
|
85
85
|
* @param {import('estree').Identifier} name
|
|
86
86
|
* @param {string} banner
|
|
87
|
-
* @param {string}
|
|
87
|
+
* @param {string} svelte_path
|
|
88
88
|
* @param {string} internal_path
|
|
89
89
|
* @param {Array<{ name: string; alias: import('estree').Identifier }>} helpers
|
|
90
90
|
* @param {Array<{ name: string; alias: import('estree').Identifier }>} globals
|
|
@@ -96,7 +96,7 @@ function esm(
|
|
|
96
96
|
program,
|
|
97
97
|
name,
|
|
98
98
|
banner,
|
|
99
|
-
|
|
99
|
+
svelte_path,
|
|
100
100
|
internal_path,
|
|
101
101
|
helpers,
|
|
102
102
|
globals,
|
|
@@ -118,7 +118,7 @@ function esm(
|
|
|
118
118
|
|
|
119
119
|
/** @param {any} node */
|
|
120
120
|
function rewrite_import(node) {
|
|
121
|
-
const value = edit_source(node.source.value,
|
|
121
|
+
const value = edit_source(node.source.value, svelte_path);
|
|
122
122
|
if (node.source.value !== value) {
|
|
123
123
|
node.source.value = value;
|
|
124
124
|
node.source.raw = null;
|
|
@@ -98,7 +98,7 @@ export default class Binding extends Node {
|
|
|
98
98
|
this.is_readonly =
|
|
99
99
|
regex_dimensions.test(this.name) ||
|
|
100
100
|
regex_box_size.test(this.name) ||
|
|
101
|
-
(
|
|
101
|
+
(is_element(parent) &&
|
|
102
102
|
((parent.is_media_node() && read_only_media_attributes.has(this.name)) ||
|
|
103
103
|
(parent.name === 'input' && type === 'file'))) /* TODO others? */;
|
|
104
104
|
}
|
|
@@ -127,6 +127,6 @@ export default class Binding extends Node {
|
|
|
127
127
|
* @param {import('./shared/Node.js').default} node
|
|
128
128
|
* @returns {node is import('./Element.js').default}
|
|
129
129
|
*/
|
|
130
|
-
function
|
|
130
|
+
function is_element(node) {
|
|
131
131
|
return !!(/** @type {any} */ (node).is_media_node);
|
|
132
132
|
}
|
|
@@ -84,7 +84,9 @@ export default class EachBlock extends AbstractBlock {
|
|
|
84
84
|
this.has_animation = false;
|
|
85
85
|
[this.const_tags, this.children] = get_const_tags(info.children, component, this, this);
|
|
86
86
|
if (this.has_animation) {
|
|
87
|
-
this.children = this.children.filter(
|
|
87
|
+
this.children = this.children.filter(
|
|
88
|
+
(child) => !is_empty_node(child) && !is_comment_node(child)
|
|
89
|
+
);
|
|
88
90
|
if (this.children.length !== 1) {
|
|
89
91
|
const child = this.children.find(
|
|
90
92
|
(child) => !!(/** @type {import('./Element.js').default} */ (child).animation)
|
|
@@ -102,11 +104,11 @@ export default class EachBlock extends AbstractBlock {
|
|
|
102
104
|
}
|
|
103
105
|
|
|
104
106
|
/** @param {import('./interfaces.js').INode} node */
|
|
105
|
-
function
|
|
107
|
+
function is_empty_node(node) {
|
|
106
108
|
return node.type === 'Text' && node.data.trim() === '';
|
|
107
109
|
}
|
|
108
110
|
|
|
109
111
|
/** @param {import('./interfaces.js').INode} node */
|
|
110
|
-
function
|
|
112
|
+
function is_comment_node(node) {
|
|
111
113
|
return node.type === 'Comment';
|
|
112
114
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { is_html, is_svg, is_void } from '../../../shared/utils/names.js';
|
|
2
2
|
import Node from './shared/Node.js';
|
|
3
|
+
import { walk } from 'estree-walker';
|
|
3
4
|
import Attribute from './Attribute.js';
|
|
4
5
|
import Binding from './Binding.js';
|
|
5
6
|
import EventHandler from './EventHandler.js';
|
|
@@ -430,7 +431,7 @@ export default class Element extends Node {
|
|
|
430
431
|
}
|
|
431
432
|
if (this.name === 'textarea') {
|
|
432
433
|
if (info.children.length > 0) {
|
|
433
|
-
const value_attribute = info.attributes
|
|
434
|
+
const value_attribute = get_value_attribute(info.attributes);
|
|
434
435
|
if (value_attribute) {
|
|
435
436
|
component.error(value_attribute, compiler_errors.textarea_duplicate_value);
|
|
436
437
|
return;
|
|
@@ -449,7 +450,7 @@ export default class Element extends Node {
|
|
|
449
450
|
// Special case — treat these the same way:
|
|
450
451
|
// <option>{foo}</option>
|
|
451
452
|
// <option value={foo}>{foo}</option>
|
|
452
|
-
const value_attribute = info.attributes
|
|
453
|
+
const value_attribute = get_value_attribute(info.attributes);
|
|
453
454
|
if (!value_attribute) {
|
|
454
455
|
info.attributes.push({
|
|
455
456
|
type: 'Attribute',
|
|
@@ -875,7 +876,7 @@ export default class Element extends Node {
|
|
|
875
876
|
) {
|
|
876
877
|
const interactive_handlers = handlers
|
|
877
878
|
.map((handler) => handler.name)
|
|
878
|
-
.filter((
|
|
879
|
+
.filter((handler_name) => a11y_interactive_handlers.has(handler_name));
|
|
879
880
|
if (interactive_handlers.length > 0) {
|
|
880
881
|
component.warn(
|
|
881
882
|
this,
|
|
@@ -1420,3 +1421,30 @@ function within_custom_element(parent) {
|
|
|
1420
1421
|
}
|
|
1421
1422
|
return false;
|
|
1422
1423
|
}
|
|
1424
|
+
|
|
1425
|
+
/**
|
|
1426
|
+
* @param {any[]} attributes
|
|
1427
|
+
*/
|
|
1428
|
+
function get_value_attribute(attributes) {
|
|
1429
|
+
let node_value;
|
|
1430
|
+
attributes.forEach((node) => {
|
|
1431
|
+
if (node.type !== 'Spread' && node.name.toLowerCase() === 'value') {
|
|
1432
|
+
node_value = node;
|
|
1433
|
+
}
|
|
1434
|
+
if (node.type === 'Spread') {
|
|
1435
|
+
walk(/** @type {any} */ (node.expression), {
|
|
1436
|
+
enter(/** @type {import('estree').Node} */ node) {
|
|
1437
|
+
if (node_value) {
|
|
1438
|
+
this.skip();
|
|
1439
|
+
}
|
|
1440
|
+
if (node.type === 'Identifier') {
|
|
1441
|
+
if (/** @type {import('estree').Identifier} */ (node).name.toLowerCase() === 'value') {
|
|
1442
|
+
node_value = node;
|
|
1443
|
+
}
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
});
|
|
1447
|
+
}
|
|
1448
|
+
});
|
|
1449
|
+
return node_value;
|
|
1450
|
+
}
|
|
@@ -73,8 +73,8 @@ function sort_consts_nodes(consts_nodes, component) {
|
|
|
73
73
|
}, [])
|
|
74
74
|
);
|
|
75
75
|
if (cycle && cycle.length) {
|
|
76
|
-
const
|
|
77
|
-
const node =
|
|
76
|
+
const node_list = lookup.get(cycle[0]);
|
|
77
|
+
const node = node_list[0];
|
|
78
78
|
component.error(node.node, compiler_errors.cyclical_const_tags(cycle));
|
|
79
79
|
}
|
|
80
80
|
|
|
@@ -990,7 +990,8 @@ export default class ElementWrapper extends Wrapper {
|
|
|
990
990
|
const static_attributes = [];
|
|
991
991
|
this.attributes.forEach((attr) => {
|
|
992
992
|
if (attr instanceof SpreadAttributeWrapper) {
|
|
993
|
-
|
|
993
|
+
const snippet = { type: 'SpreadElement', argument: attr.node.expression.manipulate(block) };
|
|
994
|
+
static_attributes.push(snippet);
|
|
994
995
|
} else {
|
|
995
996
|
const name = attr.property_name || attr.name;
|
|
996
997
|
static_attributes.push(p`${name}: ${attr.get_value(block)}`);
|
|
@@ -1240,11 +1241,7 @@ export default class ElementWrapper extends Wrapper {
|
|
|
1240
1241
|
}
|
|
1241
1242
|
if (this.dynamic_style_dependencies.size > 0) {
|
|
1242
1243
|
maybe_create_style_changed_var();
|
|
1243
|
-
|
|
1244
|
-
condition =
|
|
1245
|
-
all_deps.size === this.dynamic_style_dependencies.size
|
|
1246
|
-
? style_changed_var
|
|
1247
|
-
: x`${style_changed_var} || ${condition}`;
|
|
1244
|
+
condition = x`${condition} || ${style_changed_var}`;
|
|
1248
1245
|
}
|
|
1249
1246
|
block.chunks.update.push(b`
|
|
1250
1247
|
if (${condition}) {
|
|
@@ -105,14 +105,19 @@ export default class InlineComponentWrapper extends Wrapper {
|
|
|
105
105
|
this.slots.set(name, slot_definition);
|
|
106
106
|
}
|
|
107
107
|
warn_if_reactive() {
|
|
108
|
-
|
|
109
|
-
const
|
|
108
|
+
let { name } = this.node;
|
|
109
|
+
const top = name.split('.')[0]; // <T.foo/> etc. should check for T instead of "T.foo"
|
|
110
|
+
const variable = this.renderer.component.var_lookup.get(top);
|
|
110
111
|
if (!variable) {
|
|
111
112
|
return;
|
|
112
113
|
}
|
|
113
114
|
const ignores = extract_ignores_above_node(this.node);
|
|
114
115
|
this.renderer.component.push_ignores(ignores);
|
|
115
|
-
if (
|
|
116
|
+
if (
|
|
117
|
+
variable.reassigned ||
|
|
118
|
+
variable.export_name || // or a prop
|
|
119
|
+
variable.mutated
|
|
120
|
+
) {
|
|
116
121
|
this.renderer.component.warn(this.node, compiler_warnings.reactive_component(name));
|
|
117
122
|
}
|
|
118
123
|
this.renderer.component.pop_ignores();
|
|
@@ -94,14 +94,14 @@ export default class WindowWrapper extends Wrapper {
|
|
|
94
94
|
bindings.scrollX && bindings.scrollY
|
|
95
95
|
? x`"${bindings.scrollX}" in this._state || "${bindings.scrollY}" in this._state`
|
|
96
96
|
: x`"${bindings.scrollX || bindings.scrollY}" in this._state`;
|
|
97
|
-
const
|
|
98
|
-
const
|
|
97
|
+
const scroll_x = bindings.scrollX && x`this._state.${bindings.scrollX}`;
|
|
98
|
+
const scroll_y = bindings.scrollY && x`this._state.${bindings.scrollY}`;
|
|
99
99
|
renderer.meta_bindings.push(b`
|
|
100
100
|
if (${condition}) {
|
|
101
|
-
@_scrollTo(${
|
|
101
|
+
@_scrollTo(${scroll_x || '@_window.pageXOffset'}, ${scroll_y || '@_window.pageYOffset'});
|
|
102
102
|
}
|
|
103
|
-
${
|
|
104
|
-
${
|
|
103
|
+
${scroll_x && `${scroll_x} = @_window.pageXOffset;`}
|
|
104
|
+
${scroll_y && `${scroll_y} = @_window.pageYOffset;`}
|
|
105
105
|
`);
|
|
106
106
|
block.event_listeners.push(x`
|
|
107
107
|
@listen(@_window, "${event}", () => {
|
|
@@ -132,17 +132,17 @@ export default class WindowWrapper extends Wrapper {
|
|
|
132
132
|
// special case... might need to abstract this out if we add more special cases
|
|
133
133
|
if (bindings.scrollX || bindings.scrollY) {
|
|
134
134
|
const condition = renderer.dirty([bindings.scrollX, bindings.scrollY].filter(Boolean));
|
|
135
|
-
const
|
|
135
|
+
const scroll_x = bindings.scrollX
|
|
136
136
|
? renderer.reference(bindings.scrollX)
|
|
137
137
|
: x`@_window.pageXOffset`;
|
|
138
|
-
const
|
|
138
|
+
const scroll_y = bindings.scrollY
|
|
139
139
|
? renderer.reference(bindings.scrollY)
|
|
140
140
|
: x`@_window.pageYOffset`;
|
|
141
141
|
block.chunks.update.push(b`
|
|
142
142
|
if (${condition} && !${scrolling}) {
|
|
143
143
|
${scrolling} = true;
|
|
144
144
|
@_clearTimeout(${scrolling_timeout});
|
|
145
|
-
@_scrollTo(${
|
|
145
|
+
@_scrollTo(${scroll_x}, ${scroll_y});
|
|
146
146
|
${scrolling_timeout} = @_setTimeout(${clear_scrolling}, 100);
|
|
147
147
|
}
|
|
148
148
|
`);
|
|
@@ -3,8 +3,11 @@ import { is_reserved_keyword } from '../../../utils/reserved_keywords.js';
|
|
|
3
3
|
/** @param {import('../../../../interfaces.js').Var} variable */
|
|
4
4
|
export default function is_dynamic(variable) {
|
|
5
5
|
if (variable) {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
// Only variables declared in the instance script tags should be considered dynamic
|
|
7
|
+
const is_declared_in_reactive_context = !variable.module && !variable.global;
|
|
8
|
+
|
|
9
|
+
if (is_declared_in_reactive_context && (variable.mutated || variable.reassigned)) return true; // dynamic internal state
|
|
10
|
+
if (is_declared_in_reactive_context && variable.writable && variable.export_name) return true; // writable props
|
|
8
11
|
if (is_reserved_keyword(variable.name)) return true;
|
|
9
12
|
}
|
|
10
13
|
return false;
|
|
@@ -144,9 +144,13 @@ export default function ssr(component, options) {
|
|
|
144
144
|
? b`
|
|
145
145
|
let $$settled;
|
|
146
146
|
let $$rendered;
|
|
147
|
+
let #previous_head = $$result.head;
|
|
147
148
|
|
|
148
149
|
do {
|
|
149
150
|
$$settled = true;
|
|
151
|
+
// $$result.head is mutated by the literal expression
|
|
152
|
+
// need to reset it if we're looping back to prevent duplication
|
|
153
|
+
$$result.head = #previous_head;
|
|
150
154
|
|
|
151
155
|
${reactive_declarations}
|
|
152
156
|
|
|
@@ -8,7 +8,7 @@ import * as node from './node/index.js';
|
|
|
8
8
|
*
|
|
9
9
|
* The new nodes are located in `./node`.
|
|
10
10
|
*/
|
|
11
|
-
const
|
|
11
|
+
const cq_syntax = fork({
|
|
12
12
|
atrule: {
|
|
13
13
|
// extend or override at-rule dictionary
|
|
14
14
|
container: {
|
|
@@ -16,8 +16,8 @@ const cqSyntax = fork({
|
|
|
16
16
|
prelude() {
|
|
17
17
|
return this.createSingleNodeList(this.ContainerQuery());
|
|
18
18
|
},
|
|
19
|
-
block(
|
|
20
|
-
return this.Block(
|
|
19
|
+
block(is_style_block = false) {
|
|
20
|
+
return this.Block(is_style_block);
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
}
|
|
@@ -25,4 +25,4 @@ const cqSyntax = fork({
|
|
|
25
25
|
node
|
|
26
26
|
});
|
|
27
27
|
|
|
28
|
-
export const parse =
|
|
28
|
+
export const parse = cq_syntax.parse;
|
|
@@ -16,7 +16,7 @@ export const structure = {
|
|
|
16
16
|
value: ['Identifier', 'Number', 'Comparison', 'Dimension', 'QueryCSSFunction', 'Ratio', null]
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
function
|
|
19
|
+
function lookup_non_ws_type_and_value(offset, type, reference_str) {
|
|
20
20
|
let current_type;
|
|
21
21
|
|
|
22
22
|
do {
|
|
@@ -26,7 +26,7 @@ function lookup_non_WS_type_and_value(offset, type, referenceStr) {
|
|
|
26
26
|
}
|
|
27
27
|
} while (current_type !== 0); // NULL -> 0
|
|
28
28
|
|
|
29
|
-
return current_type === type ? this.lookupValue(offset - 1,
|
|
29
|
+
return current_type === type ? this.lookupValue(offset - 1, reference_str) : false;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
export function parse() {
|
|
@@ -40,7 +40,7 @@ export function parse() {
|
|
|
40
40
|
while (!this.eof && this.tokenType !== RightParenthesis) {
|
|
41
41
|
switch (this.tokenType) {
|
|
42
42
|
case Number:
|
|
43
|
-
if (
|
|
43
|
+
if (lookup_non_ws_type_and_value.call(this, 1, Delim, '/')) {
|
|
44
44
|
child = this.Ratio();
|
|
45
45
|
} else {
|
|
46
46
|
child = this.Number();
|
|
@@ -292,7 +292,18 @@ export function apply_preprocessor_sourcemap(filename, svelte_map, preprocessor_
|
|
|
292
292
|
toUrl: {
|
|
293
293
|
enumerable: false,
|
|
294
294
|
value: function toUrl() {
|
|
295
|
-
|
|
295
|
+
let b64 = '';
|
|
296
|
+
if (typeof window !== 'undefined' && window.btoa) {
|
|
297
|
+
// btoa doesn't support multi-byte characters
|
|
298
|
+
b64 = window.btoa(unescape(encodeURIComponent(this.toString())));
|
|
299
|
+
} else if (typeof Buffer !== 'undefined') {
|
|
300
|
+
b64 = Buffer.from(this.toString(), 'utf8').toString('base64');
|
|
301
|
+
} else {
|
|
302
|
+
throw new Error(
|
|
303
|
+
'Unsupported environment: `window.btoa` or `Buffer` should be present to use toUrl.'
|
|
304
|
+
);
|
|
305
|
+
}
|
|
306
|
+
return 'data:application/json;charset=utf-8;base64,' + b64;
|
|
296
307
|
}
|
|
297
308
|
}
|
|
298
309
|
});
|
|
@@ -84,7 +84,17 @@ function make_dirty(component, i) {
|
|
|
84
84
|
component.$$.dirty[(i / 31) | 0] |= 1 << i % 31;
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
|
|
87
|
+
// TODO: Document the other params
|
|
88
|
+
/**
|
|
89
|
+
* @param {SvelteComponent} component
|
|
90
|
+
* @param {import('./public.js').ComponentConstructorOptions} options
|
|
91
|
+
*
|
|
92
|
+
* @param {import('./utils.js')['not_equal']} not_equal Used to compare props and state values.
|
|
93
|
+
* @param {(target: Element | ShadowRoot) => void} [append_styles] Function that appends styles to the DOM when the component is first initialised.
|
|
94
|
+
* This will be the `add_css` function from the compiled component.
|
|
95
|
+
*
|
|
96
|
+
* @returns {void}
|
|
97
|
+
*/
|
|
88
98
|
export function init(
|
|
89
99
|
component,
|
|
90
100
|
options,
|
|
@@ -92,7 +102,7 @@ export function init(
|
|
|
92
102
|
create_fragment,
|
|
93
103
|
not_equal,
|
|
94
104
|
props,
|
|
95
|
-
append_styles,
|
|
105
|
+
append_styles = null,
|
|
96
106
|
dirty = [-1]
|
|
97
107
|
) {
|
|
98
108
|
const parent_component = current_component;
|
|
@@ -139,8 +149,9 @@ export function init(
|
|
|
139
149
|
if (options.target) {
|
|
140
150
|
if (options.hydrate) {
|
|
141
151
|
start_hydrating();
|
|
152
|
+
// TODO: what is the correct type here?
|
|
153
|
+
// @ts-expect-error
|
|
142
154
|
const nodes = children(options.target);
|
|
143
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
144
155
|
$$.fragment && $$.fragment.l(nodes);
|
|
145
156
|
nodes.forEach(detach);
|
|
146
157
|
} else {
|
|
@@ -283,7 +294,7 @@ if (typeof HTMLElement === 'function') {
|
|
|
283
294
|
'toAttribute'
|
|
284
295
|
);
|
|
285
296
|
if (attribute_value == null) {
|
|
286
|
-
this.removeAttribute(key);
|
|
297
|
+
this.removeAttribute(this.$$p_d[key].attribute || key);
|
|
287
298
|
} else {
|
|
288
299
|
this.setAttribute(this.$$p_d[key].attribute || key, attribute_value);
|
|
289
300
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { ResizeObserverSingleton } from './ResizeObserverSingleton.js';
|
|
2
1
|
import { contenteditable_truthy_values, has_prop } from './utils.js';
|
|
2
|
+
|
|
3
|
+
import { ResizeObserverSingleton } from './ResizeObserverSingleton.js';
|
|
4
|
+
|
|
3
5
|
// Track which nodes are claimed during hydration. Unclaimed nodes can then be removed from the DOM
|
|
4
6
|
// at the end of hydration without touching the remaining nodes.
|
|
5
7
|
let is_hydrating = false;
|
|
@@ -50,14 +52,14 @@ function init_hydrate(target) {
|
|
|
50
52
|
let children = /** @type {ArrayLike<NodeEx2>} */ (target.childNodes);
|
|
51
53
|
// If target is <head>, there may be children without claim_order
|
|
52
54
|
if (target.nodeName === 'HEAD') {
|
|
53
|
-
const
|
|
55
|
+
const my_children = [];
|
|
54
56
|
for (let i = 0; i < children.length; i++) {
|
|
55
57
|
const node = children[i];
|
|
56
58
|
if (node.claim_order !== undefined) {
|
|
57
|
-
|
|
59
|
+
my_children.push(node);
|
|
58
60
|
}
|
|
59
61
|
}
|
|
60
|
-
children =
|
|
62
|
+
children = my_children;
|
|
61
63
|
}
|
|
62
64
|
/*
|
|
63
65
|
* Reorder claimed children optimally.
|
|
@@ -87,15 +89,15 @@ function init_hydrate(target) {
|
|
|
87
89
|
// Find the largest subsequence length such that it ends in a value less than our current value
|
|
88
90
|
// upper_bound returns first greater value, so we subtract one
|
|
89
91
|
// with fast path for when we are on the current longest subsequence
|
|
90
|
-
const
|
|
92
|
+
const seq_len =
|
|
91
93
|
(longest > 0 && children[m[longest]].claim_order <= current
|
|
92
94
|
? longest + 1
|
|
93
95
|
: upper_bound(1, longest, (idx) => children[m[idx]].claim_order, current)) - 1;
|
|
94
|
-
p[i] = m[
|
|
95
|
-
const
|
|
96
|
+
p[i] = m[seq_len] + 1;
|
|
97
|
+
const new_len = seq_len + 1;
|
|
96
98
|
// We can guarantee that current is the smallest value. Otherwise, we would have generated a longer sequence.
|
|
97
|
-
m[
|
|
98
|
-
longest = Math.max(
|
|
99
|
+
m[new_len] = i;
|
|
100
|
+
longest = Math.max(new_len, longest);
|
|
99
101
|
}
|
|
100
102
|
// The longest increasing subsequence of nodes (initially reversed)
|
|
101
103
|
|
|
@@ -108,28 +110,28 @@ function init_hydrate(target) {
|
|
|
108
110
|
/**
|
|
109
111
|
* @type {NodeEx2[]}
|
|
110
112
|
*/
|
|
111
|
-
const
|
|
113
|
+
const to_move = [];
|
|
112
114
|
let last = children.length - 1;
|
|
113
115
|
for (let cur = m[longest] + 1; cur != 0; cur = p[cur - 1]) {
|
|
114
116
|
lis.push(children[cur - 1]);
|
|
115
117
|
for (; last >= cur; last--) {
|
|
116
|
-
|
|
118
|
+
to_move.push(children[last]);
|
|
117
119
|
}
|
|
118
120
|
last--;
|
|
119
121
|
}
|
|
120
122
|
for (; last >= 0; last--) {
|
|
121
|
-
|
|
123
|
+
to_move.push(children[last]);
|
|
122
124
|
}
|
|
123
125
|
lis.reverse();
|
|
124
126
|
// We sort the nodes being moved to guarantee that their insertion order matches the claim order
|
|
125
|
-
|
|
127
|
+
to_move.sort((a, b) => a.claim_order - b.claim_order);
|
|
126
128
|
// Finally, we move the nodes
|
|
127
|
-
for (let i = 0, j = 0; i <
|
|
128
|
-
while (j < lis.length &&
|
|
129
|
+
for (let i = 0, j = 0; i < to_move.length; i++) {
|
|
130
|
+
while (j < lis.length && to_move[i].claim_order >= lis[j].claim_order) {
|
|
129
131
|
j++;
|
|
130
132
|
}
|
|
131
133
|
const anchor = j < lis.length ? lis[j] : null;
|
|
132
|
-
target.insertBefore(
|
|
134
|
+
target.insertBefore(to_move[i], anchor);
|
|
133
135
|
}
|
|
134
136
|
}
|
|
135
137
|
|
|
@@ -624,26 +626,26 @@ function init_claim_info(nodes) {
|
|
|
624
626
|
* @template {ChildNodeEx} R
|
|
625
627
|
* @param {ChildNodeArray} nodes
|
|
626
628
|
* @param {(node: ChildNodeEx) => node is R} predicate
|
|
627
|
-
* @param {(node: ChildNodeEx) => ChildNodeEx | undefined}
|
|
628
|
-
* @param {() => R}
|
|
629
|
-
* @param {boolean}
|
|
629
|
+
* @param {(node: ChildNodeEx) => ChildNodeEx | undefined} process_node
|
|
630
|
+
* @param {() => R} create_node
|
|
631
|
+
* @param {boolean} dont_update_last_index
|
|
630
632
|
* @returns {R}
|
|
631
633
|
*/
|
|
632
|
-
function claim_node(nodes, predicate,
|
|
634
|
+
function claim_node(nodes, predicate, process_node, create_node, dont_update_last_index = false) {
|
|
633
635
|
// Try to find nodes in an order such that we lengthen the longest increasing subsequence
|
|
634
636
|
init_claim_info(nodes);
|
|
635
|
-
const
|
|
637
|
+
const result_node = (() => {
|
|
636
638
|
// We first try to find an element after the previous one
|
|
637
639
|
for (let i = nodes.claim_info.last_index; i < nodes.length; i++) {
|
|
638
640
|
const node = nodes[i];
|
|
639
641
|
if (predicate(node)) {
|
|
640
|
-
const replacement =
|
|
642
|
+
const replacement = process_node(node);
|
|
641
643
|
if (replacement === undefined) {
|
|
642
644
|
nodes.splice(i, 1);
|
|
643
645
|
} else {
|
|
644
646
|
nodes[i] = replacement;
|
|
645
647
|
}
|
|
646
|
-
if (!
|
|
648
|
+
if (!dont_update_last_index) {
|
|
647
649
|
nodes.claim_info.last_index = i;
|
|
648
650
|
}
|
|
649
651
|
return node;
|
|
@@ -654,13 +656,13 @@ function claim_node(nodes, predicate, processNode, createNode, dontUpdateLastInd
|
|
|
654
656
|
for (let i = nodes.claim_info.last_index - 1; i >= 0; i--) {
|
|
655
657
|
const node = nodes[i];
|
|
656
658
|
if (predicate(node)) {
|
|
657
|
-
const replacement =
|
|
659
|
+
const replacement = process_node(node);
|
|
658
660
|
if (replacement === undefined) {
|
|
659
661
|
nodes.splice(i, 1);
|
|
660
662
|
} else {
|
|
661
663
|
nodes[i] = replacement;
|
|
662
664
|
}
|
|
663
|
-
if (!
|
|
665
|
+
if (!dont_update_last_index) {
|
|
664
666
|
nodes.claim_info.last_index = i;
|
|
665
667
|
} else if (replacement === undefined) {
|
|
666
668
|
// Since we spliced before the last_index, we decrease it
|
|
@@ -670,11 +672,11 @@ function claim_node(nodes, predicate, processNode, createNode, dontUpdateLastInd
|
|
|
670
672
|
}
|
|
671
673
|
}
|
|
672
674
|
// If we can't find any matching node, we create a new one
|
|
673
|
-
return
|
|
675
|
+
return create_node();
|
|
674
676
|
})();
|
|
675
|
-
|
|
677
|
+
result_node.claim_order = nodes.claim_info.total_claimed;
|
|
676
678
|
nodes.claim_info.total_claimed += 1;
|
|
677
|
-
return
|
|
679
|
+
return result_node;
|
|
678
680
|
}
|
|
679
681
|
|
|
680
682
|
/**
|
|
@@ -736,13 +738,13 @@ export function claim_text(nodes, data) {
|
|
|
736
738
|
(node) => node.nodeType === 3,
|
|
737
739
|
/** @param {Text} node */
|
|
738
740
|
(node) => {
|
|
739
|
-
const
|
|
740
|
-
if (node.data.startsWith(
|
|
741
|
-
if (node.data.length !==
|
|
742
|
-
return node.splitText(
|
|
741
|
+
const data_str = '' + data;
|
|
742
|
+
if (node.data.startsWith(data_str)) {
|
|
743
|
+
if (node.data.length !== data_str.length) {
|
|
744
|
+
return node.splitText(data_str.length);
|
|
743
745
|
}
|
|
744
746
|
} else {
|
|
745
|
-
node.data =
|
|
747
|
+
node.data = data_str;
|
|
746
748
|
}
|
|
747
749
|
},
|
|
748
750
|
() => text(data),
|
package/src/shared/version.js
CHANGED
package/types/index.d.ts.map
CHANGED
|
@@ -179,5 +179,5 @@
|
|
|
179
179
|
null,
|
|
180
180
|
null
|
|
181
181
|
],
|
|
182
|
-
"mappings": ";kBAGiBA,2BAA2BA;;;;;;;;;;;;;;;;;;;;;;;;;;;aA2BhCC,eAAeA;;;;;;;;;;;;;;aAcfC,cAAcA;;;;;;;;;;;;;;;;;;;;;;aAsBdC,aAAaA;;;;;;;;;WASRC,eAAeA;;;;WAIfC,eAAeA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
182
|
+
"mappings": ";kBAGiBA,2BAA2BA;;;;;;;;;;;;;;;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