gjendje 1.3.2 → 1.3.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-3YGK3425.cjs → chunk-3K5IERQC.cjs} +39 -6
- package/dist/{chunk-RB7FJ7WC.cjs → chunk-G6VLCNVY.cjs} +260 -134
- package/dist/{chunk-YPT6TO4H.js → chunk-N54IDKRP.js} +39 -6
- package/dist/{chunk-JRTZTDT6.js → chunk-PAJH64N4.js} +209 -85
- package/dist/devtools.cjs +6 -6
- package/dist/devtools.d.cts +1 -1
- package/dist/devtools.d.ts +1 -1
- package/dist/devtools.js +1 -1
- package/dist/index.cjs +99 -64
- package/dist/index.d.cts +34 -3
- package/dist/index.d.ts +34 -3
- package/dist/index.js +57 -30
- package/dist/react.d.cts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/server.cjs +5 -5
- package/dist/server.d.cts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +3 -3
- package/dist/{types-DzWE2M22.d.cts → types-CFykgWDQ.d.cts} +5 -1
- package/dist/{types-DzWE2M22.d.ts → types-CFykgWDQ.d.ts} +5 -1
- package/dist/vue.d.cts +1 -1
- package/dist/vue.d.ts +1 -1
- package/package.json +1 -1
|
@@ -3,7 +3,33 @@
|
|
|
3
3
|
// src/config.ts
|
|
4
4
|
var globalConfig = {};
|
|
5
5
|
var PERSISTENT_SCOPES = /* @__PURE__ */ new Set(["local", "session", "bucket"]);
|
|
6
|
+
var VALID_LOG_LEVELS = /* @__PURE__ */ new Set(["silent", "warn", "error", "debug"]);
|
|
7
|
+
var VALID_SCOPES = /* @__PURE__ */ new Set([
|
|
8
|
+
"memory",
|
|
9
|
+
"render",
|
|
10
|
+
"session",
|
|
11
|
+
"local",
|
|
12
|
+
"url",
|
|
13
|
+
"server",
|
|
14
|
+
"bucket"
|
|
15
|
+
]);
|
|
6
16
|
function configure(config) {
|
|
17
|
+
if (config.maxKeys !== void 0 && (!Number.isSafeInteger(config.maxKeys) || config.maxKeys < 1)) {
|
|
18
|
+
throw new Error(`[gjendje] maxKeys must be a positive integer, got ${config.maxKeys}.`);
|
|
19
|
+
}
|
|
20
|
+
if (config.logLevel !== void 0 && !VALID_LOG_LEVELS.has(config.logLevel)) {
|
|
21
|
+
throw new Error(
|
|
22
|
+
`[gjendje] logLevel must be one of 'silent', 'warn', 'error', 'debug', got '${config.logLevel}'.`
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
if (config.scope !== void 0 && !VALID_SCOPES.has(config.scope)) {
|
|
26
|
+
throw new Error(
|
|
27
|
+
`[gjendje] scope must be a valid scope ('memory', 'local', 'session', 'url', 'server', 'bucket'), got '${config.scope}'.`
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
if (config.keyPattern !== void 0 && !(config.keyPattern instanceof RegExp)) {
|
|
31
|
+
throw new Error(`[gjendje] keyPattern must be a RegExp, got ${typeof config.keyPattern}.`);
|
|
32
|
+
}
|
|
7
33
|
for (const key of Object.keys(config)) {
|
|
8
34
|
const value = config[key];
|
|
9
35
|
if (value === void 0) {
|
|
@@ -12,10 +38,11 @@ function configure(config) {
|
|
|
12
38
|
globalConfig[key] = value;
|
|
13
39
|
}
|
|
14
40
|
}
|
|
15
|
-
|
|
41
|
+
const effectiveScope = globalConfig.scope ?? config.scope;
|
|
42
|
+
if (globalConfig.registry === false && effectiveScope && PERSISTENT_SCOPES.has(effectiveScope)) {
|
|
16
43
|
log(
|
|
17
44
|
"warn",
|
|
18
|
-
`registry: false has no effect on scope "${
|
|
45
|
+
`registry: false has no effect on scope "${effectiveScope}" \u2014 persistent scopes always use the registry.`
|
|
19
46
|
);
|
|
20
47
|
}
|
|
21
48
|
}
|
|
@@ -43,18 +70,24 @@ function reportError(key, scope, error) {
|
|
|
43
70
|
}
|
|
44
71
|
|
|
45
72
|
// src/listeners.ts
|
|
46
|
-
function safeCall(listener, value) {
|
|
73
|
+
function safeCall(listener, value, key, scope) {
|
|
47
74
|
try {
|
|
48
75
|
listener(value);
|
|
49
76
|
} catch (err) {
|
|
50
77
|
console.error("[gjendje] Listener threw:", err);
|
|
78
|
+
if (key !== void 0 && scope !== void 0) {
|
|
79
|
+
reportError(key, scope, err);
|
|
80
|
+
}
|
|
51
81
|
}
|
|
52
82
|
}
|
|
53
|
-
function safeCallChange(handler, next, prev) {
|
|
83
|
+
function safeCallChange(handler, next, prev, key, scope) {
|
|
54
84
|
try {
|
|
55
85
|
handler(next, prev);
|
|
56
86
|
} catch (err) {
|
|
57
87
|
console.error("[gjendje] Change handler threw:", err);
|
|
88
|
+
if (key !== void 0 && scope !== void 0) {
|
|
89
|
+
reportError(key, scope, err);
|
|
90
|
+
}
|
|
58
91
|
}
|
|
59
92
|
}
|
|
60
93
|
function safeCallConfig(fn, arg) {
|
|
@@ -65,12 +98,12 @@ function safeCallConfig(fn, arg) {
|
|
|
65
98
|
console.error("[gjendje] Config callback threw:", err);
|
|
66
99
|
}
|
|
67
100
|
}
|
|
68
|
-
function createListeners() {
|
|
101
|
+
function createListeners(key, scope) {
|
|
69
102
|
const set = /* @__PURE__ */ new Set();
|
|
70
103
|
return {
|
|
71
104
|
notify(value) {
|
|
72
105
|
for (const listener of set) {
|
|
73
|
-
safeCall(listener, value);
|
|
106
|
+
safeCall(listener, value, key, scope);
|
|
74
107
|
}
|
|
75
108
|
},
|
|
76
109
|
subscribe(listener) {
|