seitu 0.10.0 → 0.10.1

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.
@@ -164,4 +164,4 @@ function d(n, r) {
164
164
  }, e(() => i, s, c));
165
165
  }
166
166
  //#endregion
167
- export { c as a, n as c, s as i, e as l, u as n, i as o, l as r, r as s, d as t, t as u };
167
+ export { c as a, i as c, e as d, t as f, s as i, r as l, u as n, o, l as r, a as s, d as t, n as u };
package/dist/core.js CHANGED
@@ -1,2 +1,2 @@
1
- import { a as e, c as t, i as n, l as r, n as i, o as a, r as o, s, t as c, u as l } from "./core-Dldv77Xv.js";
2
- export { t as createComputed, s as createDebounce, a as createDebounceFn, r as createReadableSubscription, n as createSchemaStore, e as createSchemaStoreMemoryProvider, o as createStore, l as createSubscription, i as createThrottle, c as createThrottleFn };
1
+ import { a as e, c as t, d as n, f as r, i, l as a, n as o, r as s, t as c, u as l } from "./core-BFAZmVJI.js";
2
+ export { l as createComputed, a as createDebounce, t as createDebounceFn, n as createReadableSubscription, i as createSchemaStore, e as createSchemaStoreMemoryProvider, s as createStore, r as createSubscription, o as createThrottle, c as createThrottleFn };
@@ -1,3 +1,5 @@
1
1
  export * from './is-online';
2
2
  export * from './media-query';
3
3
  export * from './scroll-state';
4
+ export * from './web-storage';
5
+ export * from './web-storage-value';
package/dist/web.js CHANGED
@@ -1,6 +1,6 @@
1
- import { l as e, u as t } from "./core-Dldv77Xv.js";
1
+ import { d as e, f as t, o as n, s as r } from "./core-BFAZmVJI.js";
2
2
  //#region src/web/is-online.ts
3
- function n() {
3
+ function i() {
4
4
  let { subscribe: n, notify: r } = t({ onFirstSubscribe: () => (typeof window < "u" && (window.addEventListener("online", r), window.addEventListener("offline", r)), () => {
5
5
  typeof window < "u" && (window.removeEventListener("online", r), window.removeEventListener("offline", r));
6
6
  }) });
@@ -8,7 +8,7 @@ function n() {
8
8
  }
9
9
  //#endregion
10
10
  //#region src/web/media-query.ts
11
- function r(n) {
11
+ function a(n) {
12
12
  let r = typeof window > "u" ? null : window.matchMedia(n.query), { subscribe: i, notify: a } = t({ onFirstSubscribe: () => (r?.addEventListener("change", a), () => {
13
13
  r?.removeEventListener("change", a);
14
14
  }) });
@@ -16,12 +16,12 @@ function r(n) {
16
16
  }
17
17
  //#endregion
18
18
  //#region src/web/scroll-state.ts
19
- var i = {
19
+ var o = {
20
20
  reached: !1,
21
21
  remaining: 0
22
22
  };
23
- function a(e) {
24
- let { direction: n = "both", threshold: r = 0 } = e, a = typeof r == "number" ? {
23
+ function s(e) {
24
+ let { direction: n = "both", threshold: r = 0 } = e, i = typeof r == "number" ? {
25
25
  top: r,
26
26
  bottom: r,
27
27
  left: r,
@@ -31,33 +31,33 @@ function a(e) {
31
31
  bottom: r.bottom ?? 0,
32
32
  left: r.left ?? 0,
33
33
  right: r.right ?? 0
34
- }, o = () => typeof e.element == "function" ? e.element() : e.element, s = () => {
35
- let e = o(), t = (e, t) => ({
34
+ }, a = () => typeof e.element == "function" ? e.element() : e.element, s = () => {
35
+ let e = a(), t = (e, t) => ({
36
36
  reached: e,
37
37
  remaining: Math.max(0, t)
38
38
  });
39
39
  if (!e) return {
40
- top: i,
41
- bottom: i,
42
- left: i,
43
- right: i
40
+ top: o,
41
+ bottom: o,
42
+ left: o,
43
+ right: o
44
44
  };
45
45
  let r = e.scrollTop, s = e.scrollHeight - e.scrollTop - e.clientHeight, c = e.scrollLeft, l = e.scrollWidth - e.scrollLeft - e.clientWidth;
46
46
  return {
47
- top: n === "horizontal" ? i : t(r <= a.top, r),
48
- bottom: n === "horizontal" ? i : t(s <= a.bottom, s),
49
- left: n === "vertical" ? i : t(c <= a.left, c),
50
- right: n === "vertical" ? i : t(l <= a.right, l)
47
+ top: n === "horizontal" ? o : t(r <= i.top, r),
48
+ bottom: n === "horizontal" ? o : t(s <= i.bottom, s),
49
+ left: n === "vertical" ? o : t(c <= i.left, c),
50
+ right: n === "vertical" ? o : t(l <= i.right, l)
51
51
  };
52
52
  }, { subscribe: c, notify: l } = t({ onFirstSubscribe() {
53
- let e = o();
53
+ let e = a();
54
54
  if (!e) return;
55
55
  let t = () => l();
56
56
  return e.addEventListener("scroll", t, { passive: !0 }), () => e.removeEventListener("scroll", t);
57
57
  } });
58
58
  return {
59
59
  get: s,
60
- subscribe: (e, t = {}) => o() ? c(() => e(s()), t) : (e(s()), () => {}),
60
+ subscribe: (e, t = {}) => a() ? c(() => e(s()), t) : (e(s()), () => {}),
61
61
  "~": {
62
62
  output: null,
63
63
  notify: l
@@ -65,4 +65,105 @@ function a(e) {
65
65
  };
66
66
  }
67
67
  //#endregion
68
- export { n as createIsOnline, r as createMediaQuery, a as createScrollState };
68
+ //#region src/web/web-storage.ts
69
+ function c(r) {
70
+ let i = !1, { subscribe: a, notify: o } = t({ onFirstSubscribe: () => {
71
+ let e = () => {
72
+ i || o();
73
+ };
74
+ return typeof window < "u" && window.addEventListener("storage", e), () => {
75
+ typeof window < "u" && window.removeEventListener("storage", e);
76
+ };
77
+ } }), s = { ...r.defaultValues }, c = Object.keys(r.defaultValues), l = /* @__PURE__ */ new Map(), u, d = () => {
78
+ if (typeof window > "u") return r.defaultValues;
79
+ let e = window[r.type], t = u !== void 0, i = {};
80
+ for (let n of c) {
81
+ let a = String(r.keyTransform ? r.keyTransform(n) : n), o = e.getItem(a);
82
+ i[n] = o, t && l.get(n) !== o && (t = !1);
83
+ }
84
+ if (t) return u;
85
+ let a = { ...r.defaultValues };
86
+ for (let e of c) {
87
+ let t = i[e];
88
+ t === null ? a[e] = r.defaultValues[e] : a[e] = n(r.schemas[e], t, {
89
+ defaultValue: r.defaultValues[e],
90
+ label: `createWebStorage:${String(e)}`,
91
+ onError: r.onValidationError ? (t, n) => r.onValidationError({
92
+ issues: [...t],
93
+ key: e,
94
+ value: n,
95
+ defaultValue: r.defaultValues[e]
96
+ }) : void 0
97
+ }), l.set(String(e), i[String(e)]);
98
+ }
99
+ return u = a, a;
100
+ }, f = e(d, a, o);
101
+ return {
102
+ ...f,
103
+ set: (e) => {
104
+ let t = typeof e == "function" ? e(d()) : e;
105
+ if (typeof window > "u") return;
106
+ let n = window[r.type];
107
+ i = !0, Object.entries(t).forEach(([e, t]) => {
108
+ let i = typeof t == "string" ? t : JSON.stringify(t);
109
+ n.setItem(r.keyTransform ? r.keyTransform(e) : e, i), window.dispatchEvent(new StorageEvent("storage", {
110
+ key: r.keyTransform ? r.keyTransform(e) : e,
111
+ newValue: i
112
+ }));
113
+ }), i = !1, u = void 0, o();
114
+ },
115
+ "~": {
116
+ ...f["~"],
117
+ getDefaultValue: (e) => s[e],
118
+ type: r.type
119
+ }
120
+ };
121
+ }
122
+ //#endregion
123
+ //#region src/web/web-storage-value.ts
124
+ var l = Symbol("no-cache");
125
+ function u(i) {
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: () => {
127
+ let e = (e) => {
128
+ o || e.key === i.key && u();
129
+ };
130
+ return typeof window < "u" && window.addEventListener("storage", e), () => {
131
+ typeof window < "u" && window.removeEventListener("storage", e);
132
+ };
133
+ } }), d = l, f, p = () => {
134
+ if (typeof window > "u") return s;
135
+ let e = window[a].getItem(i.key);
136
+ if (d !== l && e === d) return f;
137
+ if (d = e, e === null) return f = s, f;
138
+ let t = r(e);
139
+ try {
140
+ return "schema" in i ? (f = n(i.schema, e, {
141
+ defaultValue: s,
142
+ label: `createWebStorageValue:${i.key}`,
143
+ onError: i.onValidationError ? (e, t) => i.onValidationError({
144
+ defaultValue: s,
145
+ issues: [...e],
146
+ value: t
147
+ }) : void 0
148
+ }), f) : (f = t, f);
149
+ } catch {
150
+ return f = s !== void 0 && typeof s != "string" ? s : t, f;
151
+ }
152
+ };
153
+ return {
154
+ ...e(p, c, u),
155
+ set: (e) => {
156
+ if (typeof window > "u") return;
157
+ let t = window[a], n = typeof e == "function" ? e(p()) : e;
158
+ o = !0, t.setItem(i.key, typeof n == "string" ? n : JSON.stringify(n)), window.dispatchEvent(new StorageEvent("storage", {
159
+ key: i.key,
160
+ newValue: n
161
+ })), o = !1, d = l, u();
162
+ },
163
+ remove: () => {
164
+ typeof window > "u" || (window[a].removeItem(i.key), d = l);
165
+ }
166
+ };
167
+ }
168
+ //#endregion
169
+ export { i as createIsOnline, a as createMediaQuery, s as createScrollState, c as createWebStorage, u as createWebStorageValue };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "seitu",
3
3
  "displayName": "Seitu",
4
4
  "type": "module",
5
- "version": "0.10.0",
5
+ "version": "0.10.1",
6
6
  "private": false,
7
7
  "author": "Valerii Strilets",
8
8
  "license": "MIT",