seitu 0.10.10 → 0.11.0

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.
@@ -3,6 +3,7 @@ import * as React from 'react';
3
3
  export interface UseSubscriptionOptions<S extends Subscribable<any> & Readable<any>, R = S['~']['output']> {
4
4
  selector?: (value: S['~']['output']) => R;
5
5
  deps?: React.DependencyList;
6
+ isEqual?: (prev: R, next: R) => boolean;
6
7
  }
7
8
  /**
8
9
  * Use this hook to subscribe to a reactive value. Accepts a subscription object
package/dist/react.js CHANGED
@@ -2,13 +2,13 @@ import { deepEqual as e } from "fast-equals";
2
2
  import * as t from "react";
3
3
  //#region src/react/hooks.ts
4
4
  function n(n, r) {
5
- let { selector: i, deps: a = [] } = r ?? {}, o = typeof n == "function", s = o ? n : () => n, c = t.useMemo(() => s(), o ? a : [n, ...a]), l = t.useRef(void 0), u = t.useRef(c), d = t.useRef(i);
6
- (u.current !== c || d.current !== i) && (u.current = c, d.current = i, l.current = void 0);
7
- let f = t.useCallback(() => {
8
- let t = d.current, n = t ? t(u.current.get()) : u.current.get(), r = l.current;
9
- return r !== void 0 && e(r, n) ? r : (l.current = n, n);
5
+ let { selector: i, deps: a = [], isEqual: o = e } = r ?? {}, s = typeof n == "function", c = s ? n : () => n, l = t.useMemo(() => c(), s ? a : [n, ...a]), u = t.useRef(void 0), d = t.useRef(l), f = t.useRef(i), p = t.useRef(o);
6
+ (d.current !== l || f.current !== i) && (d.current = l, f.current = i, u.current = void 0), p.current = o;
7
+ let m = t.useCallback(() => {
8
+ let e = f.current, t = e ? e(d.current.get()) : d.current.get(), n = u.current;
9
+ return n !== void 0 && p.current(n, t) ? n : (u.current = t, t);
10
10
  }, []);
11
- return t.useSyncExternalStore(c.subscribe, f, f);
11
+ return t.useSyncExternalStore(l.subscribe, m, m);
12
12
  }
13
13
  //#endregion
14
14
  //#region src/react/components.tsx
@@ -2,6 +2,7 @@ import type { MaybeRefOrGetter, ShallowRef } from 'vue';
2
2
  import type { Readable, Subscribable } from '../core/index';
3
3
  export interface UseSubscriptionOptions<S extends Subscribable<any> & Readable<any>, R = S['~']['output']> {
4
4
  selector?: (value: S['~']['output']) => R;
5
+ isEqual?: (prev: R, next: R) => boolean;
5
6
  }
6
7
  /**
7
8
  * Use this composable to subscribe to a reactive value. Accepts a subscription object
package/dist/vue.js CHANGED
@@ -2,21 +2,21 @@ import { deepEqual as e } from "fast-equals";
2
2
  import { computed as t, onWatcherCleanup as n, readonly as r, shallowRef as i, toValue as a, watch as o } from "vue";
3
3
  //#region src/vue/composables.ts
4
4
  function s(s, c) {
5
- let { selector: l } = c ?? {};
6
- function u(e) {
5
+ let { selector: l, isEqual: u = e } = c ?? {};
6
+ function d(e) {
7
7
  return l ? l(e.get()) : e.get();
8
8
  }
9
- let d = t(() => a(s)), f = i(u(d.value));
10
- return o(d, (t) => {
11
- f.value = u(t);
12
- let r = t.subscribe(() => {
13
- let n = u(t);
14
- e(f.value, n) || (f.value = n);
9
+ let f = t(() => a(s)), p = i(d(f.value));
10
+ return o(f, (e) => {
11
+ p.value = d(e);
12
+ let t = e.subscribe(() => {
13
+ let t = d(e);
14
+ u(p.value, t) || (p.value = t);
15
15
  });
16
16
  n(() => {
17
- r();
17
+ t();
18
18
  });
19
- }, { immediate: !0 }), r(f);
19
+ }, { immediate: !0 }), r(p);
20
20
  }
21
21
  //#endregion
22
22
  export { s as useSubscription };
package/dist/web.js CHANGED
@@ -128,13 +128,14 @@ function l(i) {
128
128
  return typeof window < "u" && window.addEventListener("storage", e), () => {
129
129
  typeof window < "u" && window.removeEventListener("storage", e);
130
130
  };
131
- } }), l = () => {
131
+ } }), l, u, d = () => {
132
132
  if (typeof window > "u") return o;
133
133
  let t = window[a].getItem(i.key);
134
- if (t === null) return o;
134
+ if (l !== void 0 && t === l) return u;
135
+ if (l = t, t === null) return u = o, u;
135
136
  let r = n(t);
136
137
  try {
137
- return "schema" in i ? e(i.schema, t, {
138
+ return "schema" in i ? (u = e(i.schema, t, {
138
139
  defaultValue: o,
139
140
  label: `createWebStorageValue:${i.key}`,
140
141
  onError: i.onValidationError ? (e, t) => i.onValidationError({
@@ -142,23 +143,23 @@ function l(i) {
142
143
  issues: [...e],
143
144
  value: t
144
145
  }) : void 0
145
- }) : r;
146
+ }), u) : (u = r, u);
146
147
  } catch {
147
- return o !== void 0 && typeof o != "string" ? o : r;
148
+ return u = o !== void 0 && typeof o != "string" ? o : r, u;
148
149
  }
149
150
  };
150
151
  return {
151
- ...r(l, s, c),
152
+ ...r(d, s, c),
152
153
  set: (e) => {
153
154
  if (typeof window > "u") return;
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", {
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", {
156
157
  key: i.key,
157
- newValue: n
158
- }));
158
+ newValue: r
159
+ })), l = void 0;
159
160
  },
160
161
  remove: () => {
161
- typeof window > "u" || window[a].removeItem(i.key);
162
+ typeof window > "u" || (window[a].removeItem(i.key), l = void 0);
162
163
  }
163
164
  };
164
165
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "seitu",
3
3
  "displayName": "Seitu",
4
4
  "type": "module",
5
- "version": "0.10.10",
5
+ "version": "0.11.0",
6
6
  "private": false,
7
7
  "author": "Valerii Strilets",
8
8
  "license": "MIT",
@@ -82,10 +82,10 @@
82
82
  "react-dom": "^19.2.4",
83
83
  "type-fest": "^5.5.0",
84
84
  "typescript": "^6.0.2",
85
- "vite": "^8.0.3",
85
+ "vite": "^8.0.4",
86
86
  "vite-plugin-dts": "^4.5.4",
87
87
  "vitest": "^4.1.2",
88
- "vue": "^3.5.31",
88
+ "vue": "^3.5.32",
89
89
  "zod": "^4.3.6"
90
90
  },
91
91
  "scripts": {