svelte 5.42.0 → 5.42.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/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "svelte",
3
3
  "description": "Cybernetically enhanced web apps",
4
4
  "license": "MIT",
5
- "version": "5.42.0",
5
+ "version": "5.42.1",
6
6
  "type": "module",
7
7
  "types": "./types/index.d.ts",
8
8
  "engines": {
@@ -262,12 +262,12 @@ export function flush_sync_in_effect() {
262
262
  }
263
263
 
264
264
  /**
265
- * Cannot commit a fork that was already committed or discarded
265
+ * Cannot commit a fork that was already discarded
266
266
  * @returns {never}
267
267
  */
268
268
  export function fork_discarded() {
269
269
  if (DEV) {
270
- const error = new Error(`fork_discarded\nCannot commit a fork that was already committed or discarded\nhttps://svelte.dev/e/fork_discarded`);
270
+ const error = new Error(`fork_discarded\nCannot commit a fork that was already discarded\nhttps://svelte.dev/e/fork_discarded`);
271
271
 
272
272
  error.name = 'Svelte error';
273
273
 
@@ -913,28 +913,36 @@ export function fork(fn) {
913
913
  e.fork_timing();
914
914
  }
915
915
 
916
- const batch = Batch.ensure();
916
+ var batch = Batch.ensure();
917
917
  batch.is_fork = true;
918
918
 
919
- const settled = batch.settled();
919
+ var committed = false;
920
+ var settled = batch.settled();
920
921
 
921
922
  flushSync(fn);
922
923
 
923
924
  // revert state changes
924
- for (const [source, value] of batch.previous) {
925
+ for (var [source, value] of batch.previous) {
925
926
  source.v = value;
926
927
  }
927
928
 
928
929
  return {
929
930
  commit: async () => {
931
+ if (committed) {
932
+ await settled;
933
+ return;
934
+ }
935
+
930
936
  if (!batches.has(batch)) {
931
937
  e.fork_discarded();
932
938
  }
933
939
 
940
+ committed = true;
941
+
934
942
  batch.is_fork = false;
935
943
 
936
944
  // apply changes
937
- for (const [source, value] of batch.current) {
945
+ for (var [source, value] of batch.current) {
938
946
  source.v = value;
939
947
  }
940
948
 
@@ -945,9 +953,9 @@ export function fork(fn) {
945
953
  // TODO maybe there's a better implementation?
946
954
  flushSync(() => {
947
955
  /** @type {Set<Effect>} */
948
- const eager_effects = new Set();
956
+ var eager_effects = new Set();
949
957
 
950
- for (const source of batch.current.keys()) {
958
+ for (var source of batch.current.keys()) {
951
959
  mark_eager_effects(source, eager_effects);
952
960
  }
953
961
 
@@ -959,7 +967,7 @@ export function fork(fn) {
959
967
  await settled;
960
968
  },
961
969
  discard: () => {
962
- if (batches.has(batch)) {
970
+ if (!committed && batches.has(batch)) {
963
971
  batches.delete(batch);
964
972
  batch.discard();
965
973
  }
package/src/version.js CHANGED
@@ -4,5 +4,5 @@
4
4
  * The current version, as set in package.json.
5
5
  * @type {string}
6
6
  */
7
- export const VERSION = '5.42.0';
7
+ export const VERSION = '5.42.1';
8
8
  export const PUBLIC_VERSION = '5';