seitu 0.10.11 → 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/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "seitu",
3
3
  "displayName": "Seitu",
4
4
  "type": "module",
5
- "version": "0.10.11",
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": {