gjendje 0.4.4 → 0.5.0
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-ZQ2PWVTL.cjs → chunk-SCIDKAI5.cjs} +15 -15
- package/dist/{chunk-WLY6NN5P.js → chunk-Z32544QA.js} +15 -15
- package/dist/index.cjs +20 -20
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/server.cjs +4 -4
- package/dist/server.d.cts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +1 -1
- package/dist/{types-Dr0NA1JQ.d.cts → types-BQb8Z14O.d.cts} +3 -3
- package/dist/{types-Dr0NA1JQ.d.ts → types-BQb8Z14O.d.ts} +3 -3
- package/package.json +1 -1
|
@@ -703,7 +703,7 @@ var StateImpl = class {
|
|
|
703
703
|
lastValue: adapter.get(),
|
|
704
704
|
isDestroyed: false,
|
|
705
705
|
interceptors: void 0,
|
|
706
|
-
|
|
706
|
+
changeHandlers: void 0,
|
|
707
707
|
settled: RESOLVED2,
|
|
708
708
|
resolveDestroyed: void 0,
|
|
709
709
|
destroyed: void 0,
|
|
@@ -733,8 +733,8 @@ var StateImpl = class {
|
|
|
733
733
|
s.lastValue = next;
|
|
734
734
|
this._adapter.set(next);
|
|
735
735
|
s.settled = this._adapter.ready;
|
|
736
|
-
if (s.
|
|
737
|
-
for (const hook of s.
|
|
736
|
+
if (s.changeHandlers !== void 0 && s.changeHandlers.size > 0) {
|
|
737
|
+
for (const hook of s.changeHandlers) {
|
|
738
738
|
hook(next, prev);
|
|
739
739
|
}
|
|
740
740
|
}
|
|
@@ -756,8 +756,8 @@ var StateImpl = class {
|
|
|
756
756
|
s.lastValue = next;
|
|
757
757
|
this._adapter.set(next);
|
|
758
758
|
s.settled = this._adapter.ready;
|
|
759
|
-
if (s.
|
|
760
|
-
for (const hook of s.
|
|
759
|
+
if (s.changeHandlers !== void 0 && s.changeHandlers.size > 0) {
|
|
760
|
+
for (const hook of s.changeHandlers) {
|
|
761
761
|
hook(next, prev);
|
|
762
762
|
}
|
|
763
763
|
}
|
|
@@ -791,12 +791,12 @@ var StateImpl = class {
|
|
|
791
791
|
s.interceptors?.delete(fn);
|
|
792
792
|
};
|
|
793
793
|
}
|
|
794
|
-
|
|
794
|
+
onChange(fn) {
|
|
795
795
|
const s = this._s;
|
|
796
|
-
if (!s.
|
|
797
|
-
s.
|
|
796
|
+
if (!s.changeHandlers) s.changeHandlers = /* @__PURE__ */ new Set();
|
|
797
|
+
s.changeHandlers.add(fn);
|
|
798
798
|
return () => {
|
|
799
|
-
s.
|
|
799
|
+
s.changeHandlers?.delete(fn);
|
|
800
800
|
};
|
|
801
801
|
}
|
|
802
802
|
watch(watchKey, listener) {
|
|
@@ -823,7 +823,7 @@ var StateImpl = class {
|
|
|
823
823
|
s.lastValue = this._adapter.get();
|
|
824
824
|
s.isDestroyed = true;
|
|
825
825
|
s.interceptors?.clear();
|
|
826
|
-
s.
|
|
826
|
+
s.changeHandlers?.clear();
|
|
827
827
|
s.watchers?.clear();
|
|
828
828
|
s.watchUnsub?.();
|
|
829
829
|
this._adapter.destroy?.();
|
|
@@ -891,8 +891,8 @@ var RenderStateImpl = class extends StateImpl {
|
|
|
891
891
|
if (s.notifyFn !== void 0) {
|
|
892
892
|
notify(s.notifyFn);
|
|
893
893
|
}
|
|
894
|
-
if (s.
|
|
895
|
-
for (const hook of s.
|
|
894
|
+
if (s.changeHandlers !== void 0 && s.changeHandlers.size > 0) {
|
|
895
|
+
for (const hook of s.changeHandlers) {
|
|
896
896
|
hook(next, prev);
|
|
897
897
|
}
|
|
898
898
|
}
|
|
@@ -933,8 +933,8 @@ var RenderStateImpl = class extends StateImpl {
|
|
|
933
933
|
if (s.notifyFn !== void 0) {
|
|
934
934
|
notify(s.notifyFn);
|
|
935
935
|
}
|
|
936
|
-
if (s.
|
|
937
|
-
for (const hook of s.
|
|
936
|
+
if (s.changeHandlers !== void 0 && s.changeHandlers.size > 0) {
|
|
937
|
+
for (const hook of s.changeHandlers) {
|
|
938
938
|
hook(next, prev);
|
|
939
939
|
}
|
|
940
940
|
}
|
|
@@ -969,7 +969,7 @@ var RenderStateImpl = class extends StateImpl {
|
|
|
969
969
|
s.lastValue = s.current;
|
|
970
970
|
s.isDestroyed = true;
|
|
971
971
|
s.interceptors?.clear();
|
|
972
|
-
s.
|
|
972
|
+
s.changeHandlers?.clear();
|
|
973
973
|
s.watchers?.clear();
|
|
974
974
|
s.watchUnsub?.();
|
|
975
975
|
s.renderListeners?.clear();
|
|
@@ -701,7 +701,7 @@ var StateImpl = class {
|
|
|
701
701
|
lastValue: adapter.get(),
|
|
702
702
|
isDestroyed: false,
|
|
703
703
|
interceptors: void 0,
|
|
704
|
-
|
|
704
|
+
changeHandlers: void 0,
|
|
705
705
|
settled: RESOLVED2,
|
|
706
706
|
resolveDestroyed: void 0,
|
|
707
707
|
destroyed: void 0,
|
|
@@ -731,8 +731,8 @@ var StateImpl = class {
|
|
|
731
731
|
s.lastValue = next;
|
|
732
732
|
this._adapter.set(next);
|
|
733
733
|
s.settled = this._adapter.ready;
|
|
734
|
-
if (s.
|
|
735
|
-
for (const hook of s.
|
|
734
|
+
if (s.changeHandlers !== void 0 && s.changeHandlers.size > 0) {
|
|
735
|
+
for (const hook of s.changeHandlers) {
|
|
736
736
|
hook(next, prev);
|
|
737
737
|
}
|
|
738
738
|
}
|
|
@@ -754,8 +754,8 @@ var StateImpl = class {
|
|
|
754
754
|
s.lastValue = next;
|
|
755
755
|
this._adapter.set(next);
|
|
756
756
|
s.settled = this._adapter.ready;
|
|
757
|
-
if (s.
|
|
758
|
-
for (const hook of s.
|
|
757
|
+
if (s.changeHandlers !== void 0 && s.changeHandlers.size > 0) {
|
|
758
|
+
for (const hook of s.changeHandlers) {
|
|
759
759
|
hook(next, prev);
|
|
760
760
|
}
|
|
761
761
|
}
|
|
@@ -789,12 +789,12 @@ var StateImpl = class {
|
|
|
789
789
|
s.interceptors?.delete(fn);
|
|
790
790
|
};
|
|
791
791
|
}
|
|
792
|
-
|
|
792
|
+
onChange(fn) {
|
|
793
793
|
const s = this._s;
|
|
794
|
-
if (!s.
|
|
795
|
-
s.
|
|
794
|
+
if (!s.changeHandlers) s.changeHandlers = /* @__PURE__ */ new Set();
|
|
795
|
+
s.changeHandlers.add(fn);
|
|
796
796
|
return () => {
|
|
797
|
-
s.
|
|
797
|
+
s.changeHandlers?.delete(fn);
|
|
798
798
|
};
|
|
799
799
|
}
|
|
800
800
|
watch(watchKey, listener) {
|
|
@@ -821,7 +821,7 @@ var StateImpl = class {
|
|
|
821
821
|
s.lastValue = this._adapter.get();
|
|
822
822
|
s.isDestroyed = true;
|
|
823
823
|
s.interceptors?.clear();
|
|
824
|
-
s.
|
|
824
|
+
s.changeHandlers?.clear();
|
|
825
825
|
s.watchers?.clear();
|
|
826
826
|
s.watchUnsub?.();
|
|
827
827
|
this._adapter.destroy?.();
|
|
@@ -889,8 +889,8 @@ var RenderStateImpl = class extends StateImpl {
|
|
|
889
889
|
if (s.notifyFn !== void 0) {
|
|
890
890
|
notify(s.notifyFn);
|
|
891
891
|
}
|
|
892
|
-
if (s.
|
|
893
|
-
for (const hook of s.
|
|
892
|
+
if (s.changeHandlers !== void 0 && s.changeHandlers.size > 0) {
|
|
893
|
+
for (const hook of s.changeHandlers) {
|
|
894
894
|
hook(next, prev);
|
|
895
895
|
}
|
|
896
896
|
}
|
|
@@ -931,8 +931,8 @@ var RenderStateImpl = class extends StateImpl {
|
|
|
931
931
|
if (s.notifyFn !== void 0) {
|
|
932
932
|
notify(s.notifyFn);
|
|
933
933
|
}
|
|
934
|
-
if (s.
|
|
935
|
-
for (const hook of s.
|
|
934
|
+
if (s.changeHandlers !== void 0 && s.changeHandlers.size > 0) {
|
|
935
|
+
for (const hook of s.changeHandlers) {
|
|
936
936
|
hook(next, prev);
|
|
937
937
|
}
|
|
938
938
|
}
|
|
@@ -967,7 +967,7 @@ var RenderStateImpl = class extends StateImpl {
|
|
|
967
967
|
s.lastValue = s.current;
|
|
968
968
|
s.isDestroyed = true;
|
|
969
969
|
s.interceptors?.clear();
|
|
970
|
-
s.
|
|
970
|
+
s.changeHandlers?.clear();
|
|
971
971
|
s.watchers?.clear();
|
|
972
972
|
s.watchUnsub?.();
|
|
973
973
|
s.renderListeners?.clear();
|
package/dist/index.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkSCIDKAI5_cjs = require('./chunk-SCIDKAI5.cjs');
|
|
4
4
|
|
|
5
5
|
// src/collection.ts
|
|
6
6
|
function collection(key, options) {
|
|
7
|
-
const base =
|
|
7
|
+
const base = chunkSCIDKAI5_cjs.createBase(key, options);
|
|
8
8
|
const watchers = /* @__PURE__ */ new Map();
|
|
9
9
|
let prevItems = base.get();
|
|
10
10
|
const unsubscribe = base.subscribe((next) => {
|
|
@@ -139,7 +139,7 @@ function collection(key, options) {
|
|
|
139
139
|
// src/computed.ts
|
|
140
140
|
var computedCounter = 0;
|
|
141
141
|
function computed(deps, fn, options) {
|
|
142
|
-
const listeners =
|
|
142
|
+
const listeners = chunkSCIDKAI5_cjs.createListeners();
|
|
143
143
|
const instanceKey = options?.key ?? `computed:${computedCounter++}`;
|
|
144
144
|
let cached;
|
|
145
145
|
let isDirty = true;
|
|
@@ -164,7 +164,7 @@ function computed(deps, fn, options) {
|
|
|
164
164
|
};
|
|
165
165
|
const markDirty = () => {
|
|
166
166
|
isDirty = true;
|
|
167
|
-
|
|
167
|
+
chunkSCIDKAI5_cjs.notify(notifyListeners);
|
|
168
168
|
};
|
|
169
169
|
const unsubscribers = new Array(depLen);
|
|
170
170
|
for (let i = 0; i < depLen; i++) {
|
|
@@ -224,7 +224,7 @@ function computed(deps, fn, options) {
|
|
|
224
224
|
|
|
225
225
|
// src/devtools.ts
|
|
226
226
|
function snapshot() {
|
|
227
|
-
const registry =
|
|
227
|
+
const registry = chunkSCIDKAI5_cjs.getRegistry();
|
|
228
228
|
const result = [];
|
|
229
229
|
for (const instance of registry.values()) {
|
|
230
230
|
result.push({
|
|
@@ -410,39 +410,39 @@ function state(key, optionsOrDefault) {
|
|
|
410
410
|
if (!key) {
|
|
411
411
|
throw new Error("[state] key must be a non-empty string.");
|
|
412
412
|
}
|
|
413
|
-
const config =
|
|
413
|
+
const config = chunkSCIDKAI5_cjs.getConfig();
|
|
414
414
|
if (config.keyPattern && !config.keyPattern.test(key)) {
|
|
415
415
|
throw new Error(
|
|
416
416
|
`[gjendje] Key "${key}" does not match the configured keyPattern ${config.keyPattern}.`
|
|
417
417
|
);
|
|
418
418
|
}
|
|
419
419
|
const scope = options.scope ?? config.scope ?? "render";
|
|
420
|
-
const rKey =
|
|
421
|
-
const existing =
|
|
420
|
+
const rKey = chunkSCIDKAI5_cjs.scopedKey(key, scope);
|
|
421
|
+
const existing = chunkSCIDKAI5_cjs.getRegistered(rKey);
|
|
422
422
|
if (existing && !existing.isDestroyed) {
|
|
423
423
|
if (config.warnOnDuplicate) {
|
|
424
|
-
|
|
424
|
+
chunkSCIDKAI5_cjs.log("warn", `Duplicate state("${key}") with scope "${scope}". Returning cached instance.`);
|
|
425
425
|
}
|
|
426
426
|
return existing;
|
|
427
427
|
}
|
|
428
428
|
if (scope === "render" && !options.ssr && !config.ssr) {
|
|
429
429
|
if (options.sync) {
|
|
430
|
-
|
|
430
|
+
chunkSCIDKAI5_cjs.log(
|
|
431
431
|
"warn",
|
|
432
432
|
`sync: true is ignored for scope "render". Only "local" and "bucket" scopes support cross-tab sync.`
|
|
433
433
|
);
|
|
434
434
|
}
|
|
435
|
-
const instance =
|
|
436
|
-
|
|
435
|
+
const instance = chunkSCIDKAI5_cjs.createRenderState(key, rKey, options, config);
|
|
436
|
+
chunkSCIDKAI5_cjs.registerByKey(rKey, key, scope, instance, config);
|
|
437
437
|
return instance;
|
|
438
438
|
}
|
|
439
|
-
return
|
|
439
|
+
return chunkSCIDKAI5_cjs.createBase(key, options);
|
|
440
440
|
}
|
|
441
441
|
|
|
442
442
|
// src/previous.ts
|
|
443
443
|
var previousCounter = 0;
|
|
444
444
|
function previous(source, options) {
|
|
445
|
-
const listeners =
|
|
445
|
+
const listeners = chunkSCIDKAI5_cjs.createListeners();
|
|
446
446
|
const instanceKey = options?.key ?? `previous:${previousCounter++}`;
|
|
447
447
|
let prev;
|
|
448
448
|
let current = source.get();
|
|
@@ -452,7 +452,7 @@ function previous(source, options) {
|
|
|
452
452
|
prev = current;
|
|
453
453
|
current = next;
|
|
454
454
|
if (old !== prev) {
|
|
455
|
-
|
|
455
|
+
chunkSCIDKAI5_cjs.notify(() => listeners.notify(prev));
|
|
456
456
|
}
|
|
457
457
|
});
|
|
458
458
|
let destroyedPromise;
|
|
@@ -514,7 +514,7 @@ function readonly(instance) {
|
|
|
514
514
|
// src/select.ts
|
|
515
515
|
var selectCounter = 0;
|
|
516
516
|
function select(source, fn, options) {
|
|
517
|
-
const listeners =
|
|
517
|
+
const listeners = chunkSCIDKAI5_cjs.createListeners();
|
|
518
518
|
const instanceKey = options?.key ?? `select:${selectCounter++}`;
|
|
519
519
|
let cached;
|
|
520
520
|
let isDirty = true;
|
|
@@ -533,7 +533,7 @@ function select(source, fn, options) {
|
|
|
533
533
|
};
|
|
534
534
|
const markDirty = () => {
|
|
535
535
|
isDirty = true;
|
|
536
|
-
|
|
536
|
+
chunkSCIDKAI5_cjs.notify(notifyListeners);
|
|
537
537
|
};
|
|
538
538
|
const unsubscribe = source.subscribe(markDirty);
|
|
539
539
|
recompute();
|
|
@@ -585,15 +585,15 @@ function select(source, fn, options) {
|
|
|
585
585
|
|
|
586
586
|
Object.defineProperty(exports, "batch", {
|
|
587
587
|
enumerable: true,
|
|
588
|
-
get: function () { return
|
|
588
|
+
get: function () { return chunkSCIDKAI5_cjs.batch; }
|
|
589
589
|
});
|
|
590
590
|
Object.defineProperty(exports, "configure", {
|
|
591
591
|
enumerable: true,
|
|
592
|
-
get: function () { return
|
|
592
|
+
get: function () { return chunkSCIDKAI5_cjs.configure; }
|
|
593
593
|
});
|
|
594
594
|
Object.defineProperty(exports, "shallowEqual", {
|
|
595
595
|
enumerable: true,
|
|
596
|
-
get: function () { return
|
|
596
|
+
get: function () { return chunkSCIDKAI5_cjs.shallowEqual; }
|
|
597
597
|
});
|
|
598
598
|
exports.collection = collection;
|
|
599
599
|
exports.computed = computed;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { B as BaseInstance, U as Unsubscribe, S as StateOptions, R as ReadonlyInstance, a as Scope, b as StateInstance } from './types-
|
|
2
|
-
export { A as Adapter, c as BucketOptions, E as Enhancer, L as Listener, d as Serializer } from './types-
|
|
1
|
+
import { B as BaseInstance, U as Unsubscribe, S as StateOptions, R as ReadonlyInstance, a as Scope, b as StateInstance } from './types-BQb8Z14O.cjs';
|
|
2
|
+
export { A as Adapter, c as BucketOptions, E as Enhancer, L as Listener, d as Serializer } from './types-BQb8Z14O.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Runs all state updates inside fn as a single batch.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { B as BaseInstance, U as Unsubscribe, S as StateOptions, R as ReadonlyInstance, a as Scope, b as StateInstance } from './types-
|
|
2
|
-
export { A as Adapter, c as BucketOptions, E as Enhancer, L as Listener, d as Serializer } from './types-
|
|
1
|
+
import { B as BaseInstance, U as Unsubscribe, S as StateOptions, R as ReadonlyInstance, a as Scope, b as StateInstance } from './types-BQb8Z14O.js';
|
|
2
|
+
export { A as Adapter, c as BucketOptions, E as Enhancer, L as Listener, d as Serializer } from './types-BQb8Z14O.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Runs all state updates inside fn as a single batch.
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createBase, createListeners, getRegistry, getConfig, scopedKey, getRegistered, log, createRenderState, registerByKey, notify } from './chunk-
|
|
2
|
-
export { batch, configure, shallowEqual } from './chunk-
|
|
1
|
+
import { createBase, createListeners, getRegistry, getConfig, scopedKey, getRegistered, log, createRenderState, registerByKey, notify } from './chunk-Z32544QA.js';
|
|
2
|
+
export { batch, configure, shallowEqual } from './chunk-Z32544QA.js';
|
|
3
3
|
|
|
4
4
|
// src/collection.ts
|
|
5
5
|
function collection(key, options) {
|
package/dist/server.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkSCIDKAI5_cjs = require('./chunk-SCIDKAI5.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 = chunkSCIDKAI5_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
|
+
chunkSCIDKAI5_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
|
+
chunkSCIDKAI5_cjs.registerServerAdapter(createServerAdapter);
|
|
43
43
|
|
|
44
44
|
exports.createServerAdapter = createServerAdapter;
|
|
45
45
|
exports.withServerSession = withServerSession;
|
package/dist/server.d.cts
CHANGED
package/dist/server.d.ts
CHANGED
package/dist/server.js
CHANGED
|
@@ -56,11 +56,11 @@ interface BaseInstance<T> extends ReadonlyInstance<T> {
|
|
|
56
56
|
*/
|
|
57
57
|
intercept(fn: (next: T, prev: T) => T): Unsubscribe;
|
|
58
58
|
/**
|
|
59
|
-
* Register a
|
|
59
|
+
* Register a handler that fires after each set/reset.
|
|
60
60
|
* Receives `(next, prev)`. Return value is ignored.
|
|
61
|
-
* Multiple
|
|
61
|
+
* Multiple handlers run in registration order.
|
|
62
62
|
*/
|
|
63
|
-
|
|
63
|
+
onChange(fn: (next: T, prev: T) => void): Unsubscribe;
|
|
64
64
|
}
|
|
65
65
|
type Enhancer<TIn, TOut extends TIn> = (instance: TIn) => TOut;
|
|
66
66
|
interface StateInstance<T> extends BaseInstance<T> {
|
|
@@ -56,11 +56,11 @@ interface BaseInstance<T> extends ReadonlyInstance<T> {
|
|
|
56
56
|
*/
|
|
57
57
|
intercept(fn: (next: T, prev: T) => T): Unsubscribe;
|
|
58
58
|
/**
|
|
59
|
-
* Register a
|
|
59
|
+
* Register a handler that fires after each set/reset.
|
|
60
60
|
* Receives `(next, prev)`. Return value is ignored.
|
|
61
|
-
* Multiple
|
|
61
|
+
* Multiple handlers run in registration order.
|
|
62
62
|
*/
|
|
63
|
-
|
|
63
|
+
onChange(fn: (next: T, prev: T) => void): Unsubscribe;
|
|
64
64
|
}
|
|
65
65
|
type Enhancer<TIn, TOut extends TIn> = (instance: TIn) => TOut;
|
|
66
66
|
interface StateInstance<T> extends BaseInstance<T> {
|