seitu 0.10.8 → 0.10.10
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/web.js +35 -38
- package/package.json +1 -1
package/dist/web.js
CHANGED
|
@@ -67,23 +67,23 @@ function s(e) {
|
|
|
67
67
|
//#endregion
|
|
68
68
|
//#region src/web/web-storage.ts
|
|
69
69
|
function c(n) {
|
|
70
|
-
let i =
|
|
71
|
-
let e = () => {
|
|
72
|
-
i
|
|
70
|
+
let i = { ...n.defaultValues }, { subscribe: a, notify: o } = t({ onFirstSubscribe: () => {
|
|
71
|
+
let e = (e) => {
|
|
72
|
+
Object.keys(i).some((t) => String(n.keyTransform ? n.keyTransform(t) : t) === e.key) && o();
|
|
73
73
|
};
|
|
74
74
|
return typeof window < "u" && window.addEventListener("storage", e), () => {
|
|
75
75
|
typeof window < "u" && window.removeEventListener("storage", e);
|
|
76
76
|
};
|
|
77
|
-
} }), s =
|
|
77
|
+
} }), s = Object.keys(n.defaultValues), c = /* @__PURE__ */ new Map(), l, u = () => {
|
|
78
78
|
if (typeof window > "u") return n.defaultValues;
|
|
79
|
-
let t = window[n.type], r =
|
|
80
|
-
for (let e of
|
|
79
|
+
let t = window[n.type], r = l !== void 0, i = {};
|
|
80
|
+
for (let e of s) {
|
|
81
81
|
let a = String(n.keyTransform ? n.keyTransform(e) : e), o = t.getItem(a);
|
|
82
|
-
i[e] = o, r &&
|
|
82
|
+
i[e] = o, r && c.get(e) !== o && (r = !1);
|
|
83
83
|
}
|
|
84
|
-
if (r) return
|
|
84
|
+
if (r) return l;
|
|
85
85
|
let a = { ...n.defaultValues };
|
|
86
|
-
for (let t of
|
|
86
|
+
for (let t of s) {
|
|
87
87
|
let r = i[t];
|
|
88
88
|
r === null ? a[t] = n.defaultValues[t] : a[t] = e(n.schemas[t], r, {
|
|
89
89
|
defaultValue: n.defaultValues[t],
|
|
@@ -94,76 +94,73 @@ function c(n) {
|
|
|
94
94
|
value: r,
|
|
95
95
|
defaultValue: n.defaultValues[t]
|
|
96
96
|
}) : void 0
|
|
97
|
-
}),
|
|
97
|
+
}), c.set(String(t), i[String(t)]);
|
|
98
98
|
}
|
|
99
|
-
return
|
|
100
|
-
},
|
|
99
|
+
return l = a, a;
|
|
100
|
+
}, d = r(u, a, o);
|
|
101
101
|
return {
|
|
102
|
-
...
|
|
102
|
+
...d,
|
|
103
103
|
set: (e) => {
|
|
104
|
-
let t = typeof e == "function" ? e(d()) : e;
|
|
105
104
|
if (typeof window > "u") return;
|
|
106
|
-
let r = window[n.type];
|
|
107
|
-
|
|
105
|
+
let t = typeof e == "function" ? e(u()) : e, r = window[n.type];
|
|
106
|
+
Object.entries(t).forEach(([e, t]) => {
|
|
108
107
|
let i = typeof t == "string" ? t : JSON.stringify(t);
|
|
109
108
|
r.setItem(n.keyTransform ? n.keyTransform(e) : e, i), window.dispatchEvent(new StorageEvent("storage", {
|
|
110
109
|
key: n.keyTransform ? n.keyTransform(e) : e,
|
|
111
110
|
newValue: i
|
|
112
111
|
}));
|
|
113
|
-
}),
|
|
112
|
+
}), l = void 0;
|
|
114
113
|
},
|
|
115
114
|
"~": {
|
|
116
|
-
...
|
|
117
|
-
getDefaultValue: (e) =>
|
|
115
|
+
...d["~"],
|
|
116
|
+
getDefaultValue: (e) => i[e],
|
|
118
117
|
type: n.type
|
|
119
118
|
}
|
|
120
119
|
};
|
|
121
120
|
}
|
|
122
121
|
//#endregion
|
|
123
122
|
//#region src/web/web-storage-value.ts
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
let a = "storage" in i ? i.storage["~"].type : i.type, o = !1, s = ("schema" in i ? i.defaultValue : i.storage["~"].getDefaultValue(i.key)) ?? null, { subscribe: c, notify: u } = t({ onFirstSubscribe: () => {
|
|
123
|
+
function l(i) {
|
|
124
|
+
let a = "storage" in i ? i.storage["~"].type : i.type, o = ("schema" in i ? i.defaultValue : i.storage["~"].getDefaultValue(i.key)) ?? null, { subscribe: s, notify: c } = t({ onFirstSubscribe: () => {
|
|
127
125
|
let e = (e) => {
|
|
128
|
-
|
|
126
|
+
e.key === i.key && c();
|
|
129
127
|
};
|
|
130
128
|
return typeof window < "u" && window.addEventListener("storage", e), () => {
|
|
131
129
|
typeof window < "u" && window.removeEventListener("storage", e);
|
|
132
130
|
};
|
|
133
|
-
} }),
|
|
134
|
-
if (typeof window > "u") return
|
|
131
|
+
} }), l = () => {
|
|
132
|
+
if (typeof window > "u") return o;
|
|
135
133
|
let t = window[a].getItem(i.key);
|
|
136
|
-
if (
|
|
137
|
-
if (d = t, t === null) return f = s, f;
|
|
134
|
+
if (t === null) return o;
|
|
138
135
|
let r = n(t);
|
|
139
136
|
try {
|
|
140
|
-
return "schema" in i ?
|
|
141
|
-
defaultValue:
|
|
137
|
+
return "schema" in i ? e(i.schema, t, {
|
|
138
|
+
defaultValue: o,
|
|
142
139
|
label: `createWebStorageValue:${i.key}`,
|
|
143
140
|
onError: i.onValidationError ? (e, t) => i.onValidationError({
|
|
144
|
-
defaultValue:
|
|
141
|
+
defaultValue: o,
|
|
145
142
|
issues: [...e],
|
|
146
143
|
value: t
|
|
147
144
|
}) : void 0
|
|
148
|
-
})
|
|
145
|
+
}) : r;
|
|
149
146
|
} catch {
|
|
150
|
-
return
|
|
147
|
+
return o !== void 0 && typeof o != "string" ? o : r;
|
|
151
148
|
}
|
|
152
149
|
};
|
|
153
150
|
return {
|
|
154
|
-
...r(
|
|
151
|
+
...r(l, s, c),
|
|
155
152
|
set: (e) => {
|
|
156
153
|
if (typeof window > "u") return;
|
|
157
|
-
let t = window[a], n = typeof e == "function" ? e(
|
|
158
|
-
|
|
154
|
+
let t = window[a], n = typeof e == "function" ? e(l()) : e;
|
|
155
|
+
t.setItem(i.key, typeof n == "string" ? n : JSON.stringify(n)), window.dispatchEvent(new StorageEvent("storage", {
|
|
159
156
|
key: i.key,
|
|
160
157
|
newValue: n
|
|
161
|
-
}))
|
|
158
|
+
}));
|
|
162
159
|
},
|
|
163
160
|
remove: () => {
|
|
164
|
-
typeof window > "u" ||
|
|
161
|
+
typeof window > "u" || window[a].removeItem(i.key);
|
|
165
162
|
}
|
|
166
163
|
};
|
|
167
164
|
}
|
|
168
165
|
//#endregion
|
|
169
|
-
export { i as createIsOnline, a as createMediaQuery, s as createScrollState, c as createWebStorage,
|
|
166
|
+
export { i as createIsOnline, a as createMediaQuery, s as createScrollState, c as createWebStorage, l as createWebStorageValue };
|