seitu 0.10.9 → 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 +12 -15
- package/package.json +1 -1
package/dist/web.js
CHANGED
|
@@ -101,9 +101,8 @@ function c(n) {
|
|
|
101
101
|
return {
|
|
102
102
|
...d,
|
|
103
103
|
set: (e) => {
|
|
104
|
-
let t = typeof e == "function" ? e(u()) : e;
|
|
105
104
|
if (typeof window > "u") return;
|
|
106
|
-
let r = window[n.type];
|
|
105
|
+
let t = typeof e == "function" ? e(u()) : e, r = window[n.type];
|
|
107
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", {
|
|
@@ -121,8 +120,7 @@ function c(n) {
|
|
|
121
120
|
}
|
|
122
121
|
//#endregion
|
|
123
122
|
//#region src/web/web-storage-value.ts
|
|
124
|
-
|
|
125
|
-
function u(i) {
|
|
123
|
+
function l(i) {
|
|
126
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();
|
|
@@ -130,14 +128,13 @@ function u(i) {
|
|
|
130
128
|
return typeof window < "u" && window.addEventListener("storage", e), () => {
|
|
131
129
|
typeof window < "u" && window.removeEventListener("storage", e);
|
|
132
130
|
};
|
|
133
|
-
} }),
|
|
131
|
+
} }), l = () => {
|
|
134
132
|
if (typeof window > "u") return o;
|
|
135
133
|
let t = window[a].getItem(i.key);
|
|
136
|
-
if (
|
|
137
|
-
if (u = t, t === null) return d = o, d;
|
|
134
|
+
if (t === null) return o;
|
|
138
135
|
let r = n(t);
|
|
139
136
|
try {
|
|
140
|
-
return "schema" in i ?
|
|
137
|
+
return "schema" in i ? e(i.schema, t, {
|
|
141
138
|
defaultValue: o,
|
|
142
139
|
label: `createWebStorageValue:${i.key}`,
|
|
143
140
|
onError: i.onValidationError ? (e, t) => i.onValidationError({
|
|
@@ -145,25 +142,25 @@ function u(i) {
|
|
|
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(
|
|
154
|
+
let t = window[a], n = typeof e == "function" ? e(l()) : e;
|
|
158
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 };
|