svelte 4.2.0 → 4.2.2

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 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$2 = () => {
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$2 = (str) => window.btoa(unescape(encodeURIComponent(str)));
9052
+ btoa$1 = (str) => window.btoa(unescape(encodeURIComponent(str)));
9053
9053
  } else if (typeof Buffer === 'function') {
9054
- btoa$2 = (str) => Buffer.from(str, 'utf-8').toString('base64');
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$2(this.toString())
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 lookup_non_WS_type_and_value(offset, type, referenceStr) {
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, referenceStr) : false;
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 (lookup_non_WS_type_and_value.call(this, 1, Delim, '/')) {
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 cqSyntax = Ab({
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(isStyleBlock = false) {
10358
- return this.Block(isStyleBlock);
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 = cqSyntax.parse;
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,14 +15697,17 @@ 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
- if (variable.mutated || variable.reassigned) return true; // dynamic internal state
15701
- if (!variable.module && variable.writable && variable.export_name) return true; // writable props
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;
15705
15708
  }
15706
15709
 
15707
- function nodes_match(a, b) {
15710
+ function nodes_match(a, b, ignoreKeys=[]) {
15708
15711
  if (!!a !== !!b) return false;
15709
15712
  if (Array.isArray(a) !== Array.isArray(b)) return false;
15710
15713
 
@@ -15714,8 +15717,8 @@ function nodes_match(a, b) {
15714
15717
  return a.every((child, i) => nodes_match(child, b[i]));
15715
15718
  }
15716
15719
 
15717
- const a_keys = Object.keys(a).sort();
15718
- const b_keys = Object.keys(b).sort();
15720
+ const a_keys = Object.keys(a).sort().filter(key => !ignoreKeys.includes(key));
15721
+ const b_keys = Object.keys(b).sort().filter(key => !ignoreKeys.includes(key));
15719
15722
 
15720
15723
  if (a_keys.length !== b_keys.length) return false;
15721
15724
 
@@ -15786,7 +15789,7 @@ function invalidate(renderer, scope, node, names, main_execution_context = false
15786
15789
  if (
15787
15790
  node.type === 'AssignmentExpression' &&
15788
15791
  node.operator === '=' &&
15789
- nodes_match(node.left, node.right) &&
15792
+ nodes_match(node.left, node.right, ['trailingComments','leadingComments']) &&
15790
15793
  tail.length === 0
15791
15794
  ) {
15792
15795
  return get_invalidated(head, node);
@@ -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((child) => !isEmptyNode(child) && !isCommentNode(child));
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 isEmptyNode(node) {
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 isCommentNode(node) {
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
- (isElement(parent) &&
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 isElement(node) {
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.find((node) => node.name === 'value');
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.find((attribute) => attribute.name === 'value');
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((handlerName) => a11y_interactive_handlers.has(handlerName));
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 nodeList = lookup.get(cycle[0]);
29850
- const node = nodeList[0];
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
 
@@ -31459,8 +31491,8 @@ class AttributeWrapper extends BaseAttributeWrapper {
31459
31491
  this.parent.has_dynamic_value = true;
31460
31492
  }
31461
31493
  }
31462
- if (this.parent.node.namespace == namespaces.foreign) {
31463
- // leave attribute case alone for elements in the "foreign" namespace
31494
+ if (this.parent.node.namespace == namespaces.foreign || this.parent.node.name.includes('-')) {
31495
+ // leave attribute case alone for elements in the "foreign" namespace and for custom elements
31464
31496
  this.name = this.node.name;
31465
31497
  this.metadata = this.get_metadata();
31466
31498
  this.is_indirectly_bound_value = false;
@@ -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
- static_attributes.push({ type: 'SpreadElement', argument: attr.node.expression.node });
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
- // If all dependencies are same as the style attribute dependencies, then we can skip the dirty check
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
- const { name } = this.node;
35258
- const variable = this.renderer.component.var_lookup.get(name);
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 (variable.reassigned || variable.export_name || variable.is_reactive_dependency) {
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 scrollX = bindings.scrollX && x$1`this._state.${bindings.scrollX}`;
36274
- const scrollY = bindings.scrollY && x$1`this._state.${bindings.scrollY}`;
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(${scrollX || '@_window.pageXOffset'}, ${scrollY || '@_window.pageYOffset'});
36311
+ @_scrollTo(${scroll_x || '@_window.pageXOffset'}, ${scroll_y || '@_window.pageYOffset'});
36278
36312
  }
36279
- ${scrollX && `${scrollX} = @_window.pageXOffset;`}
36280
- ${scrollY && `${scrollY} = @_window.pageYOffset;`}
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 scrollX = bindings.scrollX
36345
+ const scroll_x = bindings.scrollX
36312
36346
  ? renderer.reference(bindings.scrollX)
36313
36347
  : x$1`@_window.pageXOffset`;
36314
- const scrollY = bindings.scrollY
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(${scrollX}, ${scrollY});
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
- return 'data:application/json;charset=utf-8;base64,' + btoa(this.toString());
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} sveltePath
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
- sveltePath = 'svelte',
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 = `${sveltePath}/internal`;
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
- sveltePath,
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} sveltePath
40809
+ * @param {any} svelte_path
40761
40810
  */
40762
- function edit_source(source, sveltePath) {
40811
+ function edit_source(source, svelte_path) {
40763
40812
  return source === 'svelte' || source.startsWith('svelte/')
40764
- ? source.replace('svelte', sveltePath)
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} sveltePath
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
- sveltePath,
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, sveltePath);
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;
@@ -40980,6 +41029,13 @@ class Chunk {
40980
41029
  this.end = index;
40981
41030
 
40982
41031
  if (this.edited) {
41032
+ // after split we should save the edit content record into the correct chunk
41033
+ // to make sure sourcemap correct
41034
+ // For example:
41035
+ // ' test'.trim()
41036
+ // split -> ' ' + 'test'
41037
+ // ✔️ edit -> '' + 'test'
41038
+ // ✖️ edit -> 'test' + ''
40983
41039
  // TODO is this block necessary?...
40984
41040
  newChunk.edit('', false);
40985
41041
  this.content = '';
@@ -41008,6 +41064,10 @@ class Chunk {
41008
41064
  if (trimmed.length) {
41009
41065
  if (trimmed !== this.content) {
41010
41066
  this.split(this.start + trimmed.length).edit('', undefined, true);
41067
+ if (this.edited) {
41068
+ // save the change, if it has been edited
41069
+ this.edit(trimmed, this.storeName, true);
41070
+ }
41011
41071
  }
41012
41072
  return true;
41013
41073
  } else {
@@ -41026,7 +41086,11 @@ class Chunk {
41026
41086
 
41027
41087
  if (trimmed.length) {
41028
41088
  if (trimmed !== this.content) {
41029
- this.split(this.end - trimmed.length);
41089
+ const newChunk = this.split(this.end - trimmed.length);
41090
+ if (this.edited) {
41091
+ // save the change, if it has been edited
41092
+ newChunk.edit(trimmed, this.storeName, true);
41093
+ }
41030
41094
  this.edit('', undefined, true);
41031
41095
  }
41032
41096
  return true;
@@ -41039,7 +41103,7 @@ class Chunk {
41039
41103
  }
41040
41104
  }
41041
41105
 
41042
- function getBtoa () {
41106
+ function getBtoa() {
41043
41107
  if (typeof window !== 'undefined' && typeof window.btoa === 'function') {
41044
41108
  return (str) => window.btoa(unescape(encodeURIComponent(str)));
41045
41109
  } else if (typeof Buffer === 'function') {
@@ -41051,7 +41115,7 @@ function getBtoa () {
41051
41115
  }
41052
41116
  }
41053
41117
 
41054
- const btoa$1 = /*#__PURE__*/ getBtoa();
41118
+ const btoa = /*#__PURE__*/ getBtoa();
41055
41119
 
41056
41120
  class SourceMap {
41057
41121
  constructor(properties) {
@@ -41071,7 +41135,7 @@ class SourceMap {
41071
41135
  }
41072
41136
 
41073
41137
  toUrl() {
41074
- return 'data:application/json;charset=utf-8;base64,' + btoa$1(this.toString());
41138
+ return 'data:application/json;charset=utf-8;base64,' + btoa(this.toString());
41075
41139
  }
41076
41140
  }
41077
41141
 
@@ -41152,6 +41216,8 @@ function getLocator(source) {
41152
41216
  };
41153
41217
  }
41154
41218
 
41219
+ const wordRegex = /\w/;
41220
+
41155
41221
  class Mappings {
41156
41222
  constructor(hires) {
41157
41223
  this.hires = hires;
@@ -41164,26 +41230,64 @@ class Mappings {
41164
41230
 
41165
41231
  addEdit(sourceIndex, content, loc, nameIndex) {
41166
41232
  if (content.length) {
41233
+ let contentLineEnd = content.indexOf('\n', 0);
41234
+ let previousContentLineEnd = -1;
41235
+ while (contentLineEnd >= 0) {
41236
+ const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
41237
+ if (nameIndex >= 0) {
41238
+ segment.push(nameIndex);
41239
+ }
41240
+ this.rawSegments.push(segment);
41241
+
41242
+ this.generatedCodeLine += 1;
41243
+ this.raw[this.generatedCodeLine] = this.rawSegments = [];
41244
+ this.generatedCodeColumn = 0;
41245
+
41246
+ previousContentLineEnd = contentLineEnd;
41247
+ contentLineEnd = content.indexOf('\n', contentLineEnd + 1);
41248
+ }
41249
+
41167
41250
  const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
41168
41251
  if (nameIndex >= 0) {
41169
41252
  segment.push(nameIndex);
41170
41253
  }
41171
41254
  this.rawSegments.push(segment);
41255
+
41256
+ this.advance(content.slice(previousContentLineEnd + 1));
41172
41257
  } else if (this.pending) {
41173
41258
  this.rawSegments.push(this.pending);
41259
+ this.advance(content);
41174
41260
  }
41175
41261
 
41176
- this.advance(content);
41177
41262
  this.pending = null;
41178
41263
  }
41179
41264
 
41180
41265
  addUneditedChunk(sourceIndex, chunk, original, loc, sourcemapLocations) {
41181
41266
  let originalCharIndex = chunk.start;
41182
41267
  let first = true;
41268
+ // when iterating each char, check if it's in a word boundary
41269
+ let charInHiresBoundary = false;
41183
41270
 
41184
41271
  while (originalCharIndex < chunk.end) {
41185
41272
  if (this.hires || first || sourcemapLocations.has(originalCharIndex)) {
41186
- this.rawSegments.push([this.generatedCodeColumn, sourceIndex, loc.line, loc.column]);
41273
+ const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
41274
+
41275
+ if (this.hires === 'boundary') {
41276
+ // in hires "boundary", group segments per word boundary than per char
41277
+ if (wordRegex.test(original[originalCharIndex])) {
41278
+ // for first char in the boundary found, start the boundary by pushing a segment
41279
+ if (!charInHiresBoundary) {
41280
+ this.rawSegments.push(segment);
41281
+ charInHiresBoundary = true;
41282
+ }
41283
+ } else {
41284
+ // for non-word char, end the boundary by pushing a segment
41285
+ this.rawSegments.push(segment);
41286
+ charInHiresBoundary = false;
41287
+ }
41288
+ } else {
41289
+ this.rawSegments.push(segment);
41290
+ }
41187
41291
  }
41188
41292
 
41189
41293
  if (original[originalCharIndex] === '\n') {
@@ -41356,7 +41460,7 @@ class MagicString {
41356
41460
  sourceIndex,
41357
41461
  chunk.content,
41358
41462
  loc,
41359
- chunk.storeName ? names.indexOf(chunk.original) : -1
41463
+ chunk.storeName ? names.indexOf(chunk.original) : -1,
41360
41464
  );
41361
41465
  } else {
41362
41466
  mappings.addUneditedChunk(sourceIndex, chunk, this.original, loc, this.sourcemapLocations);
@@ -41367,11 +41471,13 @@ class MagicString {
41367
41471
 
41368
41472
  return {
41369
41473
  file: options.file ? options.file.split(/[/\\]/).pop() : undefined,
41370
- sources: [options.source ? getRelativePath(options.file || '', options.source) : (options.file || '')],
41474
+ sources: [
41475
+ options.source ? getRelativePath(options.file || '', options.source) : options.file || '',
41476
+ ],
41371
41477
  sourcesContent: options.includeContent ? [this.original] : undefined,
41372
41478
  names,
41373
41479
  mappings: mappings.raw,
41374
- x_google_ignoreList: this.ignoreList ? [sourceIndex] : undefined
41480
+ x_google_ignoreList: this.ignoreList ? [sourceIndex] : undefined,
41375
41481
  };
41376
41482
  }
41377
41483
 
@@ -41485,14 +41591,14 @@ class MagicString {
41485
41591
 
41486
41592
  insert() {
41487
41593
  throw new Error(
41488
- 'magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)'
41594
+ 'magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)',
41489
41595
  );
41490
41596
  }
41491
41597
 
41492
41598
  insertLeft(index, content) {
41493
41599
  if (!warned.insertLeft) {
41494
41600
  console.warn(
41495
- 'magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead'
41601
+ 'magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead',
41496
41602
  ); // eslint-disable-line no-console
41497
41603
  warned.insertLeft = true;
41498
41604
  }
@@ -41503,7 +41609,7 @@ class MagicString {
41503
41609
  insertRight(index, content) {
41504
41610
  if (!warned.insertRight) {
41505
41611
  console.warn(
41506
- 'magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead'
41612
+ 'magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead',
41507
41613
  ); // eslint-disable-line no-console
41508
41614
  warned.insertRight = true;
41509
41615
  }
@@ -41562,7 +41668,7 @@ class MagicString {
41562
41668
  if (end > this.original.length) throw new Error('end is out of bounds');
41563
41669
  if (start === end)
41564
41670
  throw new Error(
41565
- 'Cannot overwrite a zero-length range – use appendLeft or prependRight instead'
41671
+ 'Cannot overwrite a zero-length range – use appendLeft or prependRight instead',
41566
41672
  );
41567
41673
 
41568
41674
  this._split(start);
@@ -41571,7 +41677,7 @@ class MagicString {
41571
41677
  if (options === true) {
41572
41678
  if (!warned.storeName) {
41573
41679
  console.warn(
41574
- 'The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string'
41680
+ 'The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string',
41575
41681
  ); // eslint-disable-line no-console
41576
41682
  warned.storeName = true;
41577
41683
  }
@@ -41793,7 +41899,7 @@ class MagicString {
41793
41899
  // zero-length edited chunks are a special case (overlapping replacements)
41794
41900
  const loc = getLocator(this.original)(index);
41795
41901
  throw new Error(
41796
- `Cannot split a chunk that has already been edited (${loc.line}:${loc.column} – "${chunk.original}")`
41902
+ `Cannot split a chunk that has already been edited (${loc.line}:${loc.column} – "${chunk.original}")`,
41797
41903
  );
41798
41904
  }
41799
41905
 
@@ -41952,7 +42058,7 @@ class MagicString {
41952
42058
  this.overwrite(
41953
42059
  match.index,
41954
42060
  match.index + match[0].length,
41955
- getReplacement(match, this.original)
42061
+ getReplacement(match, this.original),
41956
42062
  );
41957
42063
  });
41958
42064
  } else {
@@ -41961,7 +42067,7 @@ class MagicString {
41961
42067
  this.overwrite(
41962
42068
  match.index,
41963
42069
  match.index + match[0].length,
41964
- getReplacement(match, this.original)
42070
+ getReplacement(match, this.original),
41965
42071
  );
41966
42072
  }
41967
42073
  return this;
@@ -42007,7 +42113,7 @@ class MagicString {
42007
42113
 
42008
42114
  if (!searchValue.global) {
42009
42115
  throw new TypeError(
42010
- 'MagicString.prototype.replaceAll called with a non-global RegExp argument'
42116
+ 'MagicString.prototype.replaceAll called with a non-global RegExp argument',
42011
42117
  );
42012
42118
  }
42013
42119
 
@@ -43526,7 +43632,7 @@ function is_used_as_reference(node, parent) {
43526
43632
  * https://svelte.dev/docs/svelte-compiler#svelte-version
43527
43633
  * @type {string}
43528
43634
  */
43529
- const VERSION = '4.2.0';
43635
+ const VERSION = '4.2.2';
43530
43636
 
43531
43637
  const regex_leading_directory_separator = /^[/\\]/;
43532
43638
  const regex_starts_with_term_export = /^Export/;
@@ -45052,8 +45158,8 @@ class Component {
45052
45158
  }, [])
45053
45159
  );
45054
45160
  if (cycle && cycle.length) {
45055
- const declarationList = lookup.get(cycle[0]);
45056
- const declaration = declarationList[0];
45161
+ const declaration_list = lookup.get(cycle[0]);
45162
+ const declaration = declaration_list[0];
45057
45163
  return this.error(declaration.node, compiler_errors.cyclical_reactive_declaration(cycle));
45058
45164
  }
45059
45165