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
|
@@ -262,12 +262,12 @@ export function flush_sync_in_effect() {
|
|
|
262
262
|
}
|
|
263
263
|
|
|
264
264
|
/**
|
|
265
|
-
* Cannot commit a fork that was already
|
|
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
|
|
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
|
-
|
|
916
|
+
var batch = Batch.ensure();
|
|
917
917
|
batch.is_fork = true;
|
|
918
918
|
|
|
919
|
-
|
|
919
|
+
var committed = false;
|
|
920
|
+
var settled = batch.settled();
|
|
920
921
|
|
|
921
922
|
flushSync(fn);
|
|
922
923
|
|
|
923
924
|
// revert state changes
|
|
924
|
-
for (
|
|
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 (
|
|
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
|
-
|
|
956
|
+
var eager_effects = new Set();
|
|
949
957
|
|
|
950
|
-
for (
|
|
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