svelte 3.43.2 → 3.44.3

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/internal/index.js CHANGED
@@ -1013,22 +1013,40 @@ function add_render_callback(fn) {
1013
1013
  function add_flush_callback(fn) {
1014
1014
  flush_callbacks.push(fn);
1015
1015
  }
1016
- let flushing = false;
1016
+ // flush() calls callbacks in this order:
1017
+ // 1. All beforeUpdate callbacks, in order: parents before children
1018
+ // 2. All bind:this callbacks, in reverse order: children before parents.
1019
+ // 3. All afterUpdate callbacks, in order: parents before children. EXCEPT
1020
+ // for afterUpdates called during the initial onMount, which are called in
1021
+ // reverse order: children before parents.
1022
+ // Since callbacks might update component values, which could trigger another
1023
+ // call to flush(), the following steps guard against this:
1024
+ // 1. During beforeUpdate, any updated components will be added to the
1025
+ // dirty_components array and will cause a reentrant call to flush(). Because
1026
+ // the flush index is kept outside the function, the reentrant call will pick
1027
+ // up where the earlier call left off and go through all dirty components. The
1028
+ // current_component value is saved and restored so that the reentrant call will
1029
+ // not interfere with the "parent" flush() call.
1030
+ // 2. bind:this callbacks cannot trigger new flush() calls.
1031
+ // 3. During afterUpdate, any updated components will NOT have their afterUpdate
1032
+ // callback called a second time; the seen_callbacks set, outside the flush()
1033
+ // function, guarantees this behavior.
1017
1034
  const seen_callbacks = new Set();
1035
+ let flushidx = 0; // Do *not* move this inside the flush() function
1018
1036
  function flush() {
1019
- if (flushing)
1020
- return;
1021
- flushing = true;
1037
+ const saved_component = exports.current_component;
1022
1038
  do {
1023
1039
  // first, call beforeUpdate functions
1024
1040
  // and update components
1025
- for (let i = 0; i < dirty_components.length; i += 1) {
1026
- const component = dirty_components[i];
1041
+ while (flushidx < dirty_components.length) {
1042
+ const component = dirty_components[flushidx];
1043
+ flushidx++;
1027
1044
  set_current_component(component);
1028
1045
  update(component.$$);
1029
1046
  }
1030
1047
  set_current_component(null);
1031
1048
  dirty_components.length = 0;
1049
+ flushidx = 0;
1032
1050
  while (binding_callbacks.length)
1033
1051
  binding_callbacks.pop()();
1034
1052
  // then, once components are updated, call
@@ -1048,8 +1066,8 @@ function flush() {
1048
1066
  flush_callbacks.pop()();
1049
1067
  }
1050
1068
  update_scheduled = false;
1051
- flushing = false;
1052
1069
  seen_callbacks.clear();
1070
+ set_current_component(saved_component);
1053
1071
  }
1054
1072
  function update($$) {
1055
1073
  if ($$.fragment !== null) {
@@ -1898,7 +1916,7 @@ class SvelteComponent {
1898
1916
  }
1899
1917
 
1900
1918
  function dispatch_dev(type, detail) {
1901
- document.dispatchEvent(custom_event(type, Object.assign({ version: '3.43.2' }, detail), true));
1919
+ document.dispatchEvent(custom_event(type, Object.assign({ version: '3.44.3' }, detail), true));
1902
1920
  }
1903
1921
  function append_dev(target, node) {
1904
1922
  dispatch_dev('SvelteDOMInsert', { target, node });
@@ -1010,22 +1010,40 @@ function add_render_callback(fn) {
1010
1010
  function add_flush_callback(fn) {
1011
1011
  flush_callbacks.push(fn);
1012
1012
  }
1013
- let flushing = false;
1013
+ // flush() calls callbacks in this order:
1014
+ // 1. All beforeUpdate callbacks, in order: parents before children
1015
+ // 2. All bind:this callbacks, in reverse order: children before parents.
1016
+ // 3. All afterUpdate callbacks, in order: parents before children. EXCEPT
1017
+ // for afterUpdates called during the initial onMount, which are called in
1018
+ // reverse order: children before parents.
1019
+ // Since callbacks might update component values, which could trigger another
1020
+ // call to flush(), the following steps guard against this:
1021
+ // 1. During beforeUpdate, any updated components will be added to the
1022
+ // dirty_components array and will cause a reentrant call to flush(). Because
1023
+ // the flush index is kept outside the function, the reentrant call will pick
1024
+ // up where the earlier call left off and go through all dirty components. The
1025
+ // current_component value is saved and restored so that the reentrant call will
1026
+ // not interfere with the "parent" flush() call.
1027
+ // 2. bind:this callbacks cannot trigger new flush() calls.
1028
+ // 3. During afterUpdate, any updated components will NOT have their afterUpdate
1029
+ // callback called a second time; the seen_callbacks set, outside the flush()
1030
+ // function, guarantees this behavior.
1014
1031
  const seen_callbacks = new Set();
1032
+ let flushidx = 0; // Do *not* move this inside the flush() function
1015
1033
  function flush() {
1016
- if (flushing)
1017
- return;
1018
- flushing = true;
1034
+ const saved_component = current_component;
1019
1035
  do {
1020
1036
  // first, call beforeUpdate functions
1021
1037
  // and update components
1022
- for (let i = 0; i < dirty_components.length; i += 1) {
1023
- const component = dirty_components[i];
1038
+ while (flushidx < dirty_components.length) {
1039
+ const component = dirty_components[flushidx];
1040
+ flushidx++;
1024
1041
  set_current_component(component);
1025
1042
  update(component.$$);
1026
1043
  }
1027
1044
  set_current_component(null);
1028
1045
  dirty_components.length = 0;
1046
+ flushidx = 0;
1029
1047
  while (binding_callbacks.length)
1030
1048
  binding_callbacks.pop()();
1031
1049
  // then, once components are updated, call
@@ -1045,8 +1063,8 @@ function flush() {
1045
1063
  flush_callbacks.pop()();
1046
1064
  }
1047
1065
  update_scheduled = false;
1048
- flushing = false;
1049
1066
  seen_callbacks.clear();
1067
+ set_current_component(saved_component);
1050
1068
  }
1051
1069
  function update($$) {
1052
1070
  if ($$.fragment !== null) {
@@ -1896,7 +1914,7 @@ class SvelteComponent {
1896
1914
  }
1897
1915
 
1898
1916
  function dispatch_dev(type, detail) {
1899
- document.dispatchEvent(custom_event(type, Object.assign({ version: '3.43.2' }, detail), true));
1917
+ document.dispatchEvent(custom_event(type, Object.assign({ version: '3.44.3' }, detail), true));
1900
1918
  }
1901
1919
  function append_dev(target, node) {
1902
1920
  dispatch_dev('SvelteDOMInsert', { target, node });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte",
3
- "version": "3.43.2",
3
+ "version": "3.44.3",
4
4
  "description": "Cybernetically enhanced web apps",
5
5
  "module": "index.mjs",
6
6
  "main": "index",
@@ -22,6 +22,11 @@
22
22
  "exports": {
23
23
  "./package.json": "./package.json",
24
24
  ".": {
25
+ "types": "./types/runtime/index.d.ts",
26
+ "browser": {
27
+ "import": "./index.mjs",
28
+ "require": "./index.js"
29
+ },
25
30
  "node": {
26
31
  "import": "./ssr.mjs",
27
32
  "require": "./ssr.js"
@@ -30,22 +35,27 @@
30
35
  "require": "./index.js"
31
36
  },
32
37
  "./compiler": {
38
+ "types": "./types/compiler/index.d.ts",
33
39
  "import": "./compiler.mjs",
34
40
  "require": "./compiler.js"
35
41
  },
36
42
  "./animate": {
43
+ "types": "./types/runtime/animate/index.d.ts",
37
44
  "import": "./animate/index.mjs",
38
45
  "require": "./animate/index.js"
39
46
  },
40
47
  "./easing": {
48
+ "types": "./types/runtime/easing/index.d.ts",
41
49
  "import": "./easing/index.mjs",
42
50
  "require": "./easing/index.js"
43
51
  },
44
52
  "./internal": {
53
+ "types": "./types/runtime/internal/index.d.ts",
45
54
  "import": "./internal/index.mjs",
46
55
  "require": "./internal/index.js"
47
56
  },
48
57
  "./motion": {
58
+ "types": "./types/runtime/motion/index.d.ts",
49
59
  "import": "./motion/index.mjs",
50
60
  "require": "./motion/index.js"
51
61
  },
@@ -53,14 +63,17 @@
53
63
  "require": "./register.js"
54
64
  },
55
65
  "./store": {
66
+ "types": "./types/runtime/store/index.d.ts",
56
67
  "import": "./store/index.mjs",
57
68
  "require": "./store/index.js"
58
69
  },
59
70
  "./transition": {
71
+ "types": "./types/runtime/transition/index.d.ts",
60
72
  "import": "./transition/index.mjs",
61
73
  "require": "./transition/index.js"
62
74
  },
63
75
  "./ssr": {
76
+ "types": "./types/runtime/index.d.ts",
64
77
  "import": "./ssr.mjs",
65
78
  "require": "./ssr.js"
66
79
  }
@@ -119,7 +132,7 @@
119
132
  "acorn": "^8.4.1",
120
133
  "agadoo": "^1.1.0",
121
134
  "c8": "^5.0.1",
122
- "code-red": "^0.2.2",
135
+ "code-red": "^0.2.3",
123
136
  "codecov": "^3.5.0",
124
137
  "css-tree": "^1.1.2",
125
138
  "eslint": "^7.32.0",
@@ -5,7 +5,7 @@ import Fragment from './nodes/Fragment';
5
5
  import { Ast, CompileOptions, Var, Warning, CssResult } from '../interfaces';
6
6
  import TemplateScope from './nodes/shared/TemplateScope';
7
7
  import Slot from './nodes/Slot';
8
- import { Node, ImportDeclaration, ExportNamedDeclaration, Identifier } from 'estree';
8
+ import { Node, ImportDeclaration, ExportNamedDeclaration, Identifier, FunctionDeclaration } from 'estree';
9
9
  import Element from './nodes/Element';
10
10
  interface ComponentOptions {
11
11
  namespace?: string;
@@ -104,7 +104,7 @@ export default class Component {
104
104
  message: string;
105
105
  }): void;
106
106
  extract_imports(node: any): void;
107
- extract_exports(node: any, module_script?: boolean): void | import("estree").FunctionDeclaration | import("estree").VariableDeclaration | import("estree").ClassDeclaration;
107
+ extract_exports(node: any, module_script?: boolean): void | FunctionDeclaration | import("estree").VariableDeclaration | import("estree").ClassDeclaration;
108
108
  private _extract_exports;
109
109
  extract_javascript(script: any): any;
110
110
  walk_module_js(): void;
@@ -0,0 +1,2 @@
1
+ import { EnableSourcemap } from '../../interfaces';
2
+ export default function check_enable_sourcemap(enable_sourcemap: EnableSourcemap, namespace: keyof Extract<EnableSourcemap, object>): boolean;
@@ -101,6 +101,10 @@ export interface Warning {
101
101
  toString: () => string;
102
102
  }
103
103
  export declare type ModuleFormat = 'esm' | 'cjs';
104
+ export declare type EnableSourcemap = boolean | {
105
+ js: boolean;
106
+ css: boolean;
107
+ };
104
108
  export declare type CssHashGetter = (args: {
105
109
  name: string;
106
110
  filename: string | undefined;
@@ -115,6 +119,7 @@ export interface CompileOptions {
115
119
  errorMode?: 'throw' | 'warn';
116
120
  varsReport?: 'full' | 'strict' | false;
117
121
  sourcemap?: object | string;
122
+ enableSourcemap?: EnableSourcemap;
118
123
  outputFilename?: string;
119
124
  cssOutputFilename?: string;
120
125
  sveltePath?: string;
@@ -6,8 +6,8 @@ export interface Processed {
6
6
  }
7
7
  export declare type MarkupPreprocessor = (options: {
8
8
  content: string;
9
- filename: string;
10
- }) => Processed | Promise<Processed>;
9
+ filename?: string;
10
+ }) => Processed | void | Promise<Processed | void>;
11
11
  export declare type Preprocessor = (options: {
12
12
  /**
13
13
  * The script/style tag content
@@ -19,7 +19,7 @@ export declare type Preprocessor = (options: {
19
19
  */
20
20
  markup: string;
21
21
  filename?: string;
22
- }) => Processed | Promise<Processed>;
22
+ }) => Processed | void | Promise<Processed | void>;
23
23
  export interface PreprocessorGroup {
24
24
  markup?: MarkupPreprocessor;
25
25
  style?: Preprocessor;
@@ -1,2 +1,4 @@
1
1
  export declare const whitespace: RegExp;
2
+ export declare const start_whitespace: RegExp;
3
+ export declare const end_whitespace: RegExp;
2
4
  export declare const dimensions: RegExp;
@@ -59,6 +59,8 @@ export interface CrossfadeParams {
59
59
  }
60
60
  export declare function crossfade({ fallback, ...defaults }: CrossfadeParams & {
61
61
  fallback?: (node: Element, params: CrossfadeParams, intro: boolean) => TransitionConfig;
62
- }): ((node: Element, params: CrossfadeParams & {
62
+ }): [(node: Element, params: CrossfadeParams & {
63
63
  key: any;
64
- }) => () => TransitionConfig)[];
64
+ }) => () => TransitionConfig, (node: Element, params: CrossfadeParams & {
65
+ key: any;
66
+ }) => () => TransitionConfig];