gjendje 1.0.2 → 1.0.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/dist/{chunk-T7HIO2XN.js → chunk-ALDPHYTI.js} +6 -10
- package/dist/{chunk-XK3VWFXS.cjs → chunk-MPNZGKMR.cjs} +6 -10
- package/dist/index.cjs +48 -60
- package/dist/index.js +26 -38
- package/dist/server.cjs +4 -4
- package/dist/server.js +1 -1
- package/package.json +1 -1
|
@@ -224,7 +224,6 @@ function readAndMigrate(raw, options, key, scope) {
|
|
|
224
224
|
storedVersion = parsed.v;
|
|
225
225
|
data = parsed.data;
|
|
226
226
|
} else {
|
|
227
|
-
storedVersion = 1;
|
|
228
227
|
data = parsed;
|
|
229
228
|
}
|
|
230
229
|
if (storedVersion < currentVersion && options.migrate) {
|
|
@@ -363,7 +362,7 @@ function createStorageAdapter(storage, key, options) {
|
|
|
363
362
|
window.addEventListener("storage", onStorageEvent);
|
|
364
363
|
}
|
|
365
364
|
return {
|
|
366
|
-
ready:
|
|
365
|
+
ready: RESOLVED,
|
|
367
366
|
get() {
|
|
368
367
|
return read();
|
|
369
368
|
},
|
|
@@ -554,8 +553,8 @@ function withSync(adapter, key, scope) {
|
|
|
554
553
|
channel.onmessage = (event) => {
|
|
555
554
|
if (isDestroyed) return;
|
|
556
555
|
const msg = event.data;
|
|
557
|
-
if (msg == null || typeof msg !== "object" || !("value" in msg))
|
|
558
|
-
|
|
556
|
+
if (msg == null || typeof msg !== "object" || !("value" in msg) || Object.keys(msg).length !== 1)
|
|
557
|
+
return;
|
|
559
558
|
const value = msg.value;
|
|
560
559
|
try {
|
|
561
560
|
adapter.set(value);
|
|
@@ -654,7 +653,7 @@ function createUrlAdapter(key, defaultValue, serializer, persist) {
|
|
|
654
653
|
}
|
|
655
654
|
window.addEventListener("popstate", onPopState);
|
|
656
655
|
return {
|
|
657
|
-
ready:
|
|
656
|
+
ready: RESOLVED,
|
|
658
657
|
get() {
|
|
659
658
|
return read();
|
|
660
659
|
},
|
|
@@ -677,7 +676,7 @@ function isServer() {
|
|
|
677
676
|
}
|
|
678
677
|
var BROWSER_SCOPES = /* @__PURE__ */ new Set(["session", "local", "url", "bucket"]);
|
|
679
678
|
function afterHydration(fn) {
|
|
680
|
-
if (isServer()) return
|
|
679
|
+
if (isServer()) return RESOLVED;
|
|
681
680
|
return new Promise((resolve) => {
|
|
682
681
|
Promise.resolve().then(() => {
|
|
683
682
|
if (typeof requestAnimationFrame !== "undefined") {
|
|
@@ -738,10 +737,7 @@ function resolveAdapter(storageKey, scope, options) {
|
|
|
738
737
|
return createUrlAdapter(
|
|
739
738
|
storageKey,
|
|
740
739
|
options.default,
|
|
741
|
-
options.serialize ?? {
|
|
742
|
-
stringify: (v) => JSON.stringify(v),
|
|
743
|
-
parse: (s) => JSON.parse(s)
|
|
744
|
-
},
|
|
740
|
+
options.serialize ?? { stringify: JSON.stringify, parse: JSON.parse },
|
|
745
741
|
options.persist
|
|
746
742
|
);
|
|
747
743
|
case "server":
|
|
@@ -226,7 +226,6 @@ function readAndMigrate(raw, options, key, scope) {
|
|
|
226
226
|
storedVersion = parsed.v;
|
|
227
227
|
data = parsed.data;
|
|
228
228
|
} else {
|
|
229
|
-
storedVersion = 1;
|
|
230
229
|
data = parsed;
|
|
231
230
|
}
|
|
232
231
|
if (storedVersion < currentVersion && options.migrate) {
|
|
@@ -365,7 +364,7 @@ function createStorageAdapter(storage, key, options) {
|
|
|
365
364
|
window.addEventListener("storage", onStorageEvent);
|
|
366
365
|
}
|
|
367
366
|
return {
|
|
368
|
-
ready:
|
|
367
|
+
ready: RESOLVED,
|
|
369
368
|
get() {
|
|
370
369
|
return read();
|
|
371
370
|
},
|
|
@@ -556,8 +555,8 @@ function withSync(adapter, key, scope) {
|
|
|
556
555
|
channel.onmessage = (event) => {
|
|
557
556
|
if (isDestroyed) return;
|
|
558
557
|
const msg = event.data;
|
|
559
|
-
if (msg == null || typeof msg !== "object" || !("value" in msg))
|
|
560
|
-
|
|
558
|
+
if (msg == null || typeof msg !== "object" || !("value" in msg) || Object.keys(msg).length !== 1)
|
|
559
|
+
return;
|
|
561
560
|
const value = msg.value;
|
|
562
561
|
try {
|
|
563
562
|
adapter.set(value);
|
|
@@ -656,7 +655,7 @@ function createUrlAdapter(key, defaultValue, serializer, persist) {
|
|
|
656
655
|
}
|
|
657
656
|
window.addEventListener("popstate", onPopState);
|
|
658
657
|
return {
|
|
659
|
-
ready:
|
|
658
|
+
ready: RESOLVED,
|
|
660
659
|
get() {
|
|
661
660
|
return read();
|
|
662
661
|
},
|
|
@@ -679,7 +678,7 @@ function isServer() {
|
|
|
679
678
|
}
|
|
680
679
|
var BROWSER_SCOPES = /* @__PURE__ */ new Set(["session", "local", "url", "bucket"]);
|
|
681
680
|
function afterHydration(fn) {
|
|
682
|
-
if (isServer()) return
|
|
681
|
+
if (isServer()) return RESOLVED;
|
|
683
682
|
return new Promise((resolve) => {
|
|
684
683
|
Promise.resolve().then(() => {
|
|
685
684
|
if (typeof requestAnimationFrame !== "undefined") {
|
|
@@ -740,10 +739,7 @@ function resolveAdapter(storageKey, scope, options) {
|
|
|
740
739
|
return createUrlAdapter(
|
|
741
740
|
storageKey,
|
|
742
741
|
options.default,
|
|
743
|
-
options.serialize ?? {
|
|
744
|
-
stringify: (v) => JSON.stringify(v),
|
|
745
|
-
parse: (s) => JSON.parse(s)
|
|
746
|
-
},
|
|
742
|
+
options.serialize ?? { stringify: JSON.stringify, parse: JSON.parse },
|
|
747
743
|
options.persist
|
|
748
744
|
);
|
|
749
745
|
case "server":
|
package/dist/index.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkMPNZGKMR_cjs = require('./chunk-MPNZGKMR.cjs');
|
|
4
4
|
|
|
5
5
|
// src/collection.ts
|
|
6
6
|
function collection(key, options) {
|
|
7
|
-
const base =
|
|
7
|
+
const base = chunkMPNZGKMR_cjs.createBase(key, options);
|
|
8
8
|
const watchers = /* @__PURE__ */ new Map();
|
|
9
9
|
let prevItems = base.get();
|
|
10
10
|
const unsubscribe = base.subscribe((next) => {
|
|
@@ -15,17 +15,21 @@ function collection(key, options) {
|
|
|
15
15
|
const changedKeys = /* @__PURE__ */ new Set();
|
|
16
16
|
const lengthChanged = next.length !== prevItems.length;
|
|
17
17
|
if (lengthChanged) {
|
|
18
|
-
for (const
|
|
19
|
-
|
|
18
|
+
for (const [, listeners] of watchers) {
|
|
19
|
+
for (const listener of listeners) {
|
|
20
|
+
listener(next);
|
|
21
|
+
}
|
|
20
22
|
}
|
|
23
|
+
prevItems = next;
|
|
24
|
+
return;
|
|
21
25
|
} else {
|
|
22
26
|
const len = next.length;
|
|
23
27
|
for (let i = 0; i < len; i++) {
|
|
24
28
|
const prev = prevItems[i];
|
|
25
29
|
const curr = next[i];
|
|
26
30
|
if (prev === curr) continue;
|
|
27
|
-
const p =
|
|
28
|
-
const n =
|
|
31
|
+
const p = chunkMPNZGKMR_cjs.isRecord(prev) ? prev : void 0;
|
|
32
|
+
const n = chunkMPNZGKMR_cjs.isRecord(curr) ? curr : void 0;
|
|
29
33
|
if (!p || !n) {
|
|
30
34
|
for (const watchKey of watchers.keys()) {
|
|
31
35
|
changedKeys.add(watchKey);
|
|
@@ -50,10 +54,9 @@ function collection(key, options) {
|
|
|
50
54
|
}
|
|
51
55
|
prevItems = next;
|
|
52
56
|
});
|
|
53
|
-
const originalDestroy = base.destroy.bind(base);
|
|
54
57
|
const col = Object.create(base);
|
|
55
58
|
col.watch = (watchKey, listener) => {
|
|
56
|
-
return
|
|
59
|
+
return chunkMPNZGKMR_cjs.addWatcher(watchers, watchKey, listener);
|
|
57
60
|
};
|
|
58
61
|
col.add = (...items) => {
|
|
59
62
|
base.set((prev) => [...prev, ...items]);
|
|
@@ -119,7 +122,7 @@ function collection(key, options) {
|
|
|
119
122
|
col.destroy = () => {
|
|
120
123
|
watchers.clear();
|
|
121
124
|
unsubscribe();
|
|
122
|
-
|
|
125
|
+
base.destroy();
|
|
123
126
|
};
|
|
124
127
|
return col;
|
|
125
128
|
}
|
|
@@ -127,7 +130,7 @@ function collection(key, options) {
|
|
|
127
130
|
// src/computed.ts
|
|
128
131
|
var computedCounter = 0;
|
|
129
132
|
function computed(deps, fn, options) {
|
|
130
|
-
const listeners =
|
|
133
|
+
const listeners = chunkMPNZGKMR_cjs.createListeners();
|
|
131
134
|
const instanceKey = options?.key ?? `computed:${computedCounter++}`;
|
|
132
135
|
let cached;
|
|
133
136
|
let isDirty = true;
|
|
@@ -152,7 +155,7 @@ function computed(deps, fn, options) {
|
|
|
152
155
|
};
|
|
153
156
|
const markDirty = () => {
|
|
154
157
|
isDirty = true;
|
|
155
|
-
|
|
158
|
+
chunkMPNZGKMR_cjs.notify(notifyListeners);
|
|
156
159
|
};
|
|
157
160
|
const unsubscribers = new Array(depLen);
|
|
158
161
|
for (let i = 0; i < depLen; i++) {
|
|
@@ -160,10 +163,11 @@ function computed(deps, fn, options) {
|
|
|
160
163
|
unsubscribers[i] = dep.subscribe(markDirty);
|
|
161
164
|
}
|
|
162
165
|
recompute();
|
|
163
|
-
const lazyDestroyed =
|
|
164
|
-
const allDepsImmediate = deps.every((d) => d.ready ===
|
|
165
|
-
const readyPromise = allDepsImmediate ?
|
|
166
|
-
const hydratedPromise = allDepsImmediate ?
|
|
166
|
+
const lazyDestroyed = chunkMPNZGKMR_cjs.createLazyDestroyed();
|
|
167
|
+
const allDepsImmediate = deps.every((d) => d.ready === chunkMPNZGKMR_cjs.RESOLVED);
|
|
168
|
+
const readyPromise = allDepsImmediate ? chunkMPNZGKMR_cjs.RESOLVED : Promise.all(deps.map((d) => d.ready)).then(() => void 0);
|
|
169
|
+
const hydratedPromise = allDepsImmediate ? chunkMPNZGKMR_cjs.RESOLVED : Promise.all(deps.map((d) => d.hydrated)).then(() => void 0);
|
|
170
|
+
const settledPromise = allDepsImmediate ? chunkMPNZGKMR_cjs.RESOLVED : Promise.all(deps.map((d) => d.settled)).then(() => void 0);
|
|
167
171
|
return {
|
|
168
172
|
key: instanceKey,
|
|
169
173
|
scope: "memory",
|
|
@@ -171,8 +175,7 @@ function computed(deps, fn, options) {
|
|
|
171
175
|
return readyPromise;
|
|
172
176
|
},
|
|
173
177
|
get settled() {
|
|
174
|
-
|
|
175
|
-
return Promise.all(deps.map((d) => d.settled)).then(() => void 0);
|
|
178
|
+
return settledPromise;
|
|
176
179
|
},
|
|
177
180
|
get hydrated() {
|
|
178
181
|
return hydratedPromise;
|
|
@@ -204,17 +207,12 @@ function computed(deps, fn, options) {
|
|
|
204
207
|
|
|
205
208
|
// src/devtools.ts
|
|
206
209
|
function snapshot() {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
value: instance.isDestroyed ? void 0 : instance.get(),
|
|
214
|
-
isDestroyed: instance.isDestroyed
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
return result;
|
|
210
|
+
return Array.from(chunkMPNZGKMR_cjs.getRegistry().values(), (instance) => ({
|
|
211
|
+
key: instance.key,
|
|
212
|
+
scope: instance.scope,
|
|
213
|
+
value: instance.isDestroyed ? void 0 : instance.get(),
|
|
214
|
+
isDestroyed: instance.isDestroyed
|
|
215
|
+
}));
|
|
218
216
|
}
|
|
219
217
|
|
|
220
218
|
// src/effect.ts
|
|
@@ -280,31 +278,21 @@ function withHistory(instance, options) {
|
|
|
280
278
|
}
|
|
281
279
|
return next;
|
|
282
280
|
});
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
if (past.length === 0) return;
|
|
281
|
+
function navigate(from, to) {
|
|
282
|
+
if (from.length === 0) return;
|
|
286
283
|
const current = instance.get();
|
|
287
|
-
const
|
|
288
|
-
|
|
284
|
+
const value = from.pop();
|
|
285
|
+
to.push(current);
|
|
289
286
|
isNavigating = true;
|
|
290
287
|
try {
|
|
291
|
-
instance.set(
|
|
288
|
+
instance.set(value);
|
|
292
289
|
} finally {
|
|
293
290
|
isNavigating = false;
|
|
294
291
|
}
|
|
295
|
-
}
|
|
296
|
-
result
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
const next = future.pop();
|
|
300
|
-
past.push(current);
|
|
301
|
-
isNavigating = true;
|
|
302
|
-
try {
|
|
303
|
-
instance.set(next);
|
|
304
|
-
} finally {
|
|
305
|
-
isNavigating = false;
|
|
306
|
-
}
|
|
307
|
-
};
|
|
292
|
+
}
|
|
293
|
+
const result = Object.create(instance);
|
|
294
|
+
result.undo = () => navigate(past, future);
|
|
295
|
+
result.redo = () => navigate(future, past);
|
|
308
296
|
Object.defineProperty(result, "canUndo", {
|
|
309
297
|
get() {
|
|
310
298
|
return past.length > 0;
|
|
@@ -344,7 +332,7 @@ function withWatch(instance) {
|
|
|
344
332
|
}
|
|
345
333
|
unsubscribe = instance.subscribe((next) => {
|
|
346
334
|
if (watchers && watchers.size > 0) {
|
|
347
|
-
|
|
335
|
+
chunkMPNZGKMR_cjs.notifyWatchers(watchers, prev, next);
|
|
348
336
|
}
|
|
349
337
|
prev = next;
|
|
350
338
|
});
|
|
@@ -353,7 +341,7 @@ function withWatch(instance) {
|
|
|
353
341
|
result.watch = (watchKey, listener) => {
|
|
354
342
|
if (!watchers) watchers = /* @__PURE__ */ new Map();
|
|
355
343
|
ensureSubscription();
|
|
356
|
-
return
|
|
344
|
+
return chunkMPNZGKMR_cjs.addWatcher(watchers, watchKey, listener);
|
|
357
345
|
};
|
|
358
346
|
result.destroy = () => {
|
|
359
347
|
watchers?.clear();
|
|
@@ -366,7 +354,7 @@ function withWatch(instance) {
|
|
|
366
354
|
// src/previous.ts
|
|
367
355
|
var previousCounter = 0;
|
|
368
356
|
function previous(source, options) {
|
|
369
|
-
const listeners =
|
|
357
|
+
const listeners = chunkMPNZGKMR_cjs.createListeners();
|
|
370
358
|
const instanceKey = options?.key ?? `previous:${previousCounter++}`;
|
|
371
359
|
let prev;
|
|
372
360
|
let current = source.get();
|
|
@@ -376,10 +364,10 @@ function previous(source, options) {
|
|
|
376
364
|
prev = current;
|
|
377
365
|
current = next;
|
|
378
366
|
if (old !== prev) {
|
|
379
|
-
|
|
367
|
+
chunkMPNZGKMR_cjs.notify(() => listeners.notify(prev));
|
|
380
368
|
}
|
|
381
369
|
});
|
|
382
|
-
const lazyDestroyed =
|
|
370
|
+
const lazyDestroyed = chunkMPNZGKMR_cjs.createLazyDestroyed();
|
|
383
371
|
return {
|
|
384
372
|
key: instanceKey,
|
|
385
373
|
scope: "memory",
|
|
@@ -428,7 +416,7 @@ function readonly(instance) {
|
|
|
428
416
|
// src/select.ts
|
|
429
417
|
var selectCounter = 0;
|
|
430
418
|
function select(source, fn, options) {
|
|
431
|
-
const listeners =
|
|
419
|
+
const listeners = chunkMPNZGKMR_cjs.createListeners();
|
|
432
420
|
const instanceKey = options?.key ?? `select:${selectCounter++}`;
|
|
433
421
|
let cached;
|
|
434
422
|
let isDirty = true;
|
|
@@ -447,11 +435,11 @@ function select(source, fn, options) {
|
|
|
447
435
|
};
|
|
448
436
|
const markDirty = () => {
|
|
449
437
|
isDirty = true;
|
|
450
|
-
|
|
438
|
+
chunkMPNZGKMR_cjs.notify(notifyListeners);
|
|
451
439
|
};
|
|
452
440
|
const unsubscribe = source.subscribe(markDirty);
|
|
453
441
|
recompute();
|
|
454
|
-
const lazyDestroyed =
|
|
442
|
+
const lazyDestroyed = chunkMPNZGKMR_cjs.createLazyDestroyed();
|
|
455
443
|
return {
|
|
456
444
|
key: instanceKey,
|
|
457
445
|
scope: "memory",
|
|
@@ -500,7 +488,7 @@ function extractEntry(entry) {
|
|
|
500
488
|
}
|
|
501
489
|
function scopeShortcut(scope, entry, options) {
|
|
502
490
|
const [key, defaultValue] = extractEntry(entry);
|
|
503
|
-
return
|
|
491
|
+
return chunkMPNZGKMR_cjs.createBase(key, { ...options, default: defaultValue, scope });
|
|
504
492
|
}
|
|
505
493
|
function _state(keyOrEntry, optionsOrDefault, extraOptions) {
|
|
506
494
|
let key;
|
|
@@ -513,7 +501,7 @@ function _state(keyOrEntry, optionsOrDefault, extraOptions) {
|
|
|
513
501
|
key = keyOrEntry;
|
|
514
502
|
options = extraOptions ? { ...extraOptions, default: optionsOrDefault } : optionsOrDefault !== null && typeof optionsOrDefault === "object" && "default" in optionsOrDefault ? optionsOrDefault : { default: optionsOrDefault };
|
|
515
503
|
}
|
|
516
|
-
return
|
|
504
|
+
return chunkMPNZGKMR_cjs.createBase(key, options);
|
|
517
505
|
}
|
|
518
506
|
_state.local = (e, o) => scopeShortcut("local", e, o);
|
|
519
507
|
_state.session = (e, o) => scopeShortcut("session", e, o);
|
|
@@ -524,15 +512,15 @@ var state = _state;
|
|
|
524
512
|
|
|
525
513
|
Object.defineProperty(exports, "batch", {
|
|
526
514
|
enumerable: true,
|
|
527
|
-
get: function () { return
|
|
515
|
+
get: function () { return chunkMPNZGKMR_cjs.batch; }
|
|
528
516
|
});
|
|
529
517
|
Object.defineProperty(exports, "configure", {
|
|
530
518
|
enumerable: true,
|
|
531
|
-
get: function () { return
|
|
519
|
+
get: function () { return chunkMPNZGKMR_cjs.configure; }
|
|
532
520
|
});
|
|
533
521
|
Object.defineProperty(exports, "shallowEqual", {
|
|
534
522
|
enumerable: true,
|
|
535
|
-
get: function () { return
|
|
523
|
+
get: function () { return chunkMPNZGKMR_cjs.shallowEqual; }
|
|
536
524
|
});
|
|
537
525
|
exports.collection = collection;
|
|
538
526
|
exports.computed = computed;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createBase, isRecord, addWatcher, createListeners, createLazyDestroyed, RESOLVED, getRegistry, notify, notifyWatchers } from './chunk-
|
|
2
|
-
export { batch, configure, shallowEqual } from './chunk-
|
|
1
|
+
import { createBase, isRecord, addWatcher, createListeners, createLazyDestroyed, RESOLVED, getRegistry, notify, notifyWatchers } from './chunk-ALDPHYTI.js';
|
|
2
|
+
export { batch, configure, shallowEqual } from './chunk-ALDPHYTI.js';
|
|
3
3
|
|
|
4
4
|
// src/collection.ts
|
|
5
5
|
function collection(key, options) {
|
|
@@ -14,9 +14,13 @@ function collection(key, options) {
|
|
|
14
14
|
const changedKeys = /* @__PURE__ */ new Set();
|
|
15
15
|
const lengthChanged = next.length !== prevItems.length;
|
|
16
16
|
if (lengthChanged) {
|
|
17
|
-
for (const
|
|
18
|
-
|
|
17
|
+
for (const [, listeners] of watchers) {
|
|
18
|
+
for (const listener of listeners) {
|
|
19
|
+
listener(next);
|
|
20
|
+
}
|
|
19
21
|
}
|
|
22
|
+
prevItems = next;
|
|
23
|
+
return;
|
|
20
24
|
} else {
|
|
21
25
|
const len = next.length;
|
|
22
26
|
for (let i = 0; i < len; i++) {
|
|
@@ -49,7 +53,6 @@ function collection(key, options) {
|
|
|
49
53
|
}
|
|
50
54
|
prevItems = next;
|
|
51
55
|
});
|
|
52
|
-
const originalDestroy = base.destroy.bind(base);
|
|
53
56
|
const col = Object.create(base);
|
|
54
57
|
col.watch = (watchKey, listener) => {
|
|
55
58
|
return addWatcher(watchers, watchKey, listener);
|
|
@@ -118,7 +121,7 @@ function collection(key, options) {
|
|
|
118
121
|
col.destroy = () => {
|
|
119
122
|
watchers.clear();
|
|
120
123
|
unsubscribe();
|
|
121
|
-
|
|
124
|
+
base.destroy();
|
|
122
125
|
};
|
|
123
126
|
return col;
|
|
124
127
|
}
|
|
@@ -163,6 +166,7 @@ function computed(deps, fn, options) {
|
|
|
163
166
|
const allDepsImmediate = deps.every((d) => d.ready === RESOLVED);
|
|
164
167
|
const readyPromise = allDepsImmediate ? RESOLVED : Promise.all(deps.map((d) => d.ready)).then(() => void 0);
|
|
165
168
|
const hydratedPromise = allDepsImmediate ? RESOLVED : Promise.all(deps.map((d) => d.hydrated)).then(() => void 0);
|
|
169
|
+
const settledPromise = allDepsImmediate ? RESOLVED : Promise.all(deps.map((d) => d.settled)).then(() => void 0);
|
|
166
170
|
return {
|
|
167
171
|
key: instanceKey,
|
|
168
172
|
scope: "memory",
|
|
@@ -170,8 +174,7 @@ function computed(deps, fn, options) {
|
|
|
170
174
|
return readyPromise;
|
|
171
175
|
},
|
|
172
176
|
get settled() {
|
|
173
|
-
|
|
174
|
-
return Promise.all(deps.map((d) => d.settled)).then(() => void 0);
|
|
177
|
+
return settledPromise;
|
|
175
178
|
},
|
|
176
179
|
get hydrated() {
|
|
177
180
|
return hydratedPromise;
|
|
@@ -203,17 +206,12 @@ function computed(deps, fn, options) {
|
|
|
203
206
|
|
|
204
207
|
// src/devtools.ts
|
|
205
208
|
function snapshot() {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
value: instance.isDestroyed ? void 0 : instance.get(),
|
|
213
|
-
isDestroyed: instance.isDestroyed
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
return result;
|
|
209
|
+
return Array.from(getRegistry().values(), (instance) => ({
|
|
210
|
+
key: instance.key,
|
|
211
|
+
scope: instance.scope,
|
|
212
|
+
value: instance.isDestroyed ? void 0 : instance.get(),
|
|
213
|
+
isDestroyed: instance.isDestroyed
|
|
214
|
+
}));
|
|
217
215
|
}
|
|
218
216
|
|
|
219
217
|
// src/effect.ts
|
|
@@ -279,31 +277,21 @@ function withHistory(instance, options) {
|
|
|
279
277
|
}
|
|
280
278
|
return next;
|
|
281
279
|
});
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
if (past.length === 0) return;
|
|
280
|
+
function navigate(from, to) {
|
|
281
|
+
if (from.length === 0) return;
|
|
285
282
|
const current = instance.get();
|
|
286
|
-
const
|
|
287
|
-
|
|
283
|
+
const value = from.pop();
|
|
284
|
+
to.push(current);
|
|
288
285
|
isNavigating = true;
|
|
289
286
|
try {
|
|
290
|
-
instance.set(
|
|
287
|
+
instance.set(value);
|
|
291
288
|
} finally {
|
|
292
289
|
isNavigating = false;
|
|
293
290
|
}
|
|
294
|
-
}
|
|
295
|
-
result
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
const next = future.pop();
|
|
299
|
-
past.push(current);
|
|
300
|
-
isNavigating = true;
|
|
301
|
-
try {
|
|
302
|
-
instance.set(next);
|
|
303
|
-
} finally {
|
|
304
|
-
isNavigating = false;
|
|
305
|
-
}
|
|
306
|
-
};
|
|
291
|
+
}
|
|
292
|
+
const result = Object.create(instance);
|
|
293
|
+
result.undo = () => navigate(past, future);
|
|
294
|
+
result.redo = () => navigate(future, past);
|
|
307
295
|
Object.defineProperty(result, "canUndo", {
|
|
308
296
|
get() {
|
|
309
297
|
return past.length > 0;
|
package/dist/server.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkMPNZGKMR_cjs = require('./chunk-MPNZGKMR.cjs');
|
|
4
4
|
var async_hooks = require('async_hooks');
|
|
5
5
|
|
|
6
6
|
var als = new async_hooks.AsyncLocalStorage();
|
|
@@ -9,7 +9,7 @@ async function withServerSession(fn) {
|
|
|
9
9
|
return als.run(store, fn);
|
|
10
10
|
}
|
|
11
11
|
function createServerAdapter(key, defaultValue) {
|
|
12
|
-
const listeners =
|
|
12
|
+
const listeners = chunkMPNZGKMR_cjs.createListeners();
|
|
13
13
|
function getStore() {
|
|
14
14
|
return als.getStore();
|
|
15
15
|
}
|
|
@@ -31,7 +31,7 @@ function createServerAdapter(key, defaultValue) {
|
|
|
31
31
|
}
|
|
32
32
|
store.set(key, value);
|
|
33
33
|
lastNotifiedValue = value;
|
|
34
|
-
|
|
34
|
+
chunkMPNZGKMR_cjs.notify(notifyListeners);
|
|
35
35
|
},
|
|
36
36
|
subscribe: listeners.subscribe,
|
|
37
37
|
destroy() {
|
|
@@ -39,7 +39,7 @@ function createServerAdapter(key, defaultValue) {
|
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
|
-
|
|
42
|
+
chunkMPNZGKMR_cjs.registerServerAdapter(createServerAdapter);
|
|
43
43
|
|
|
44
44
|
exports.createServerAdapter = createServerAdapter;
|
|
45
45
|
exports.withServerSession = withServerSession;
|
package/dist/server.js
CHANGED