seitu 0.10.9 → 0.10.11
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 +15 -17
- 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,14 @@ 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, u, d = () => {
|
|
134
132
|
if (typeof window > "u") return o;
|
|
135
133
|
let t = window[a].getItem(i.key);
|
|
136
|
-
if (
|
|
137
|
-
if (
|
|
134
|
+
if (l !== void 0 && t === l) return u;
|
|
135
|
+
if (l = t, t === null) return u = o, u;
|
|
138
136
|
let r = n(t);
|
|
139
137
|
try {
|
|
140
|
-
return "schema" in i ? (
|
|
138
|
+
return "schema" in i ? (u = e(i.schema, t, {
|
|
141
139
|
defaultValue: o,
|
|
142
140
|
label: `createWebStorageValue:${i.key}`,
|
|
143
141
|
onError: i.onValidationError ? (e, t) => i.onValidationError({
|
|
@@ -145,25 +143,25 @@ function u(i) {
|
|
|
145
143
|
issues: [...e],
|
|
146
144
|
value: t
|
|
147
145
|
}) : void 0
|
|
148
|
-
}),
|
|
146
|
+
}), u) : (u = r, u);
|
|
149
147
|
} catch {
|
|
150
|
-
return
|
|
148
|
+
return u = o !== void 0 && typeof o != "string" ? o : r, u;
|
|
151
149
|
}
|
|
152
150
|
};
|
|
153
151
|
return {
|
|
154
|
-
...r(
|
|
152
|
+
...r(d, s, c),
|
|
155
153
|
set: (e) => {
|
|
156
154
|
if (typeof window > "u") return;
|
|
157
|
-
let t = window[a], n = typeof e == "function" ? e(
|
|
158
|
-
t.setItem(i.key,
|
|
155
|
+
let t = window[a], n = typeof e == "function" ? e(d()) : e, r = typeof n == "string" ? n : JSON.stringify(n);
|
|
156
|
+
t.setItem(i.key, r), window.dispatchEvent(new StorageEvent("storage", {
|
|
159
157
|
key: i.key,
|
|
160
|
-
newValue:
|
|
161
|
-
})),
|
|
158
|
+
newValue: r
|
|
159
|
+
})), l = void 0;
|
|
162
160
|
},
|
|
163
161
|
remove: () => {
|
|
164
|
-
typeof window > "u" || (window[a].removeItem(i.key),
|
|
162
|
+
typeof window > "u" || (window[a].removeItem(i.key), l = void 0);
|
|
165
163
|
}
|
|
166
164
|
};
|
|
167
165
|
}
|
|
168
166
|
//#endregion
|
|
169
|
-
export { i as createIsOnline, a as createMediaQuery, s as createScrollState, c as createWebStorage,
|
|
167
|
+
export { i as createIsOnline, a as createMediaQuery, s as createScrollState, c as createWebStorage, l as createWebStorageValue };
|