@bemedev/app-reactjs 1.9.4 → 1.10.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.
- package/lib/types.d.ts +11 -0
- package/lib/types.d.ts.map +1 -1
- package/lib/useCan.cjs +24 -11
- package/lib/useCan.cjs.map +1 -1
- package/lib/useCan.d.ts +14 -0
- package/lib/useCan.d.ts.map +1 -1
- package/lib/useCan.js +25 -12
- package/lib/useCan.js.map +1 -1
- package/lib/useIsInside.cjs +26 -10
- package/lib/useIsInside.cjs.map +1 -1
- package/lib/useIsInside.d.ts +13 -0
- package/lib/useIsInside.d.ts.map +1 -1
- package/lib/useIsInside.js +27 -11
- package/lib/useIsInside.js.map +1 -1
- package/lib/useService.cjs +17 -0
- package/lib/useService.cjs.map +1 -1
- package/lib/useService.d.ts +17 -0
- package/lib/useService.d.ts.map +1 -1
- package/lib/useService.js +17 -0
- package/lib/useService.js.map +1 -1
- package/lib/useState.cjs +25 -15
- package/lib/useState.cjs.map +1 -1
- package/lib/useState.d.ts +12 -4
- package/lib/useState.d.ts.map +1 -1
- package/lib/useState.js +26 -16
- package/lib/useState.js.map +1 -1
- package/package.json +27 -40
package/lib/types.d.ts
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
import type { EventObject, State, PrimitiveObject } from '@bemedev/app';
|
|
2
|
+
/**
|
|
3
|
+
* Options for configuring the `useService` hook.
|
|
4
|
+
*
|
|
5
|
+
* @template {PrimitiveObject} Tc - Context type extending type {@linkcode PrimitiveObject}.
|
|
6
|
+
* @template {string} Ta - Tag type extending `string`.
|
|
7
|
+
* @template {EventObject} Eo - Event object type extending type {@linkcode EventObject}.
|
|
8
|
+
* @template T - Selected state type, defaults to type {@linkcode State}<{@linkcode Eo}, {@linkcode Tc}, {@linkcode Ta}>.
|
|
9
|
+
*
|
|
10
|
+
* @property selector - Optional selector function to project the state into a sub-state.
|
|
11
|
+
* @property equals - Optional equality comparator function to compare previous and next selected state.
|
|
12
|
+
*/
|
|
2
13
|
export type UseServiceOptions<Tc extends PrimitiveObject, Ta extends string, Eo extends EventObject, T = State<Eo, Tc, Ta>> = {
|
|
3
14
|
selector?: (state: State<Eo, Tc, Ta>) => T;
|
|
4
15
|
equals?: (first: T, next: T) => boolean;
|
package/lib/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAExE,MAAM,MAAM,iBAAiB,CAC3B,EAAE,SAAS,eAAe,EAC1B,EAAE,SAAS,MAAM,EACjB,EAAE,SAAS,WAAW,EACtB,CAAC,GAAG,KAAK,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,IACnB;IACF,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC;IAC3C,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC;CACzC,CAAC"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAExE;;;;;;;;;;GAUG;AACH,MAAM,MAAM,iBAAiB,CAC3B,EAAE,SAAS,eAAe,EAC1B,EAAE,SAAS,MAAM,EACjB,EAAE,SAAS,WAAW,EACtB,CAAC,GAAG,KAAK,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,IACnB;IACF,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC;IAC3C,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC;CACzC,CAAC"}
|
package/lib/useCan.cjs
CHANGED
|
@@ -1,19 +1,32 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
let _bemedev_app_utils = require("@bemedev/app/utils");
|
|
3
|
-
let
|
|
3
|
+
let _bemedev_react_sync = require("@bemedev/react-sync");
|
|
4
4
|
let _bemedev_app_bemedev = require("@bemedev/app/bemedev");
|
|
5
5
|
//#region src/useCan.ts
|
|
6
|
+
/**
|
|
7
|
+
* React hook that creates reactive helpers for querying event capabilities from a service.
|
|
8
|
+
*
|
|
9
|
+
* @template {PrimitiveObject} Tc - Context type extending type {@linkcode PrimitiveObject}.
|
|
10
|
+
* @template {string} Ta - Tag type extending `string`.
|
|
11
|
+
* @template {EventObject} Eo - Event object type extending type {@linkcode EventObject}.
|
|
12
|
+
*
|
|
13
|
+
* @param service - Service object containing `subscribe`, `state`, and `canEvents`.
|
|
14
|
+
* @param service.subscribe - Subscription handler function of type {@linkcode AddSubscriber_F}.
|
|
15
|
+
* @param service.state - Current state of type {@linkcode State}.
|
|
16
|
+
* @param service.canEvents - Function checking if event types can be accepted.
|
|
17
|
+
*
|
|
18
|
+
* @returns Object helper with `or` and `and` methods to check event availability.
|
|
19
|
+
*/
|
|
6
20
|
function useCan(service) {
|
|
7
|
-
const dispatch = (matcher) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
};
|
|
21
|
+
const dispatch = (matcher) => (...events) => {
|
|
22
|
+
const selector = () => events[matcher]((event) => service.canEvents(event));
|
|
23
|
+
return (0, _bemedev_react_sync.useSync)((listener) => {
|
|
24
|
+
const { unsubscribe } = service.subscribe(listener, {
|
|
25
|
+
equals: (first, next) => (0, _bemedev_app_utils.deepEqual)(first.value, next.value),
|
|
26
|
+
firstTime: true
|
|
27
|
+
});
|
|
28
|
+
return unsubscribe;
|
|
29
|
+
}, selector, selector, _bemedev_app_utils.identity);
|
|
17
30
|
};
|
|
18
31
|
const or = dispatch("some");
|
|
19
32
|
const and = dispatch("every");
|
package/lib/useCan.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCan.cjs","names":["
|
|
1
|
+
{"version":3,"file":"useCan.cjs","names":["useSync","deepEqual","identity","expandFn"],"sources":["../src/useCan.ts"],"sourcesContent":["import {\n type AddSubscriber_F,\n type EventObject,\n type PrimitiveObject,\n type State,\n} from '@bemedev/app';\nimport { expandFn } from '@bemedev/app/bemedev';\nimport { deepEqual, identity } from '@bemedev/app/utils';\nimport { useSync } from '@bemedev/react-sync';\n\n/**\n * React hook that creates reactive helpers for querying event capabilities from a service.\n *\n * @template {PrimitiveObject} Tc - Context type extending type {@linkcode PrimitiveObject}.\n * @template {string} Ta - Tag type extending `string`.\n * @template {EventObject} Eo - Event object type extending type {@linkcode EventObject}.\n *\n * @param service - Service object containing `subscribe`, `state`, and `canEvents`.\n * @param service.subscribe - Subscription handler function of type {@linkcode AddSubscriber_F}.\n * @param service.state - Current state of type {@linkcode State}.\n * @param service.canEvents - Function checking if event types can be accepted.\n *\n * @returns Object helper with `or` and `and` methods to check event availability.\n */\nexport function useCan<\n Tc extends PrimitiveObject,\n Ta extends string,\n Eo extends EventObject,\n>(service: {\n subscribe: AddSubscriber_F<Tc, Ta, Eo>;\n state: State<Eo, Tc, Ta>;\n canEvents: (...events: Eo['type'][]) => boolean;\n}) {\n const dispatch =\n (matcher: 'some' | 'every') =>\n (...events: Eo['type'][]) => {\n const selector = () =>\n events[matcher](event => service.canEvents(event));\n return useSync(\n listener => {\n const { unsubscribe } = service.subscribe(listener, {\n equals: (first, next) => deepEqual(first.value, next.value),\n firstTime: true,\n });\n return unsubscribe;\n },\n selector,\n selector,\n identity,\n );\n };\n\n const or = dispatch('some');\n const and = dispatch('every');\n const out = expandFn(and, { or, and });\n return out;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAwBA,SAAgB,OAId,SAIC;CACD,MAAM,YACH,aACA,GAAG,WAAyB;EAC3B,MAAM,iBACJ,OAAO,QAAQ,EAAC,UAAS,QAAQ,UAAU,KAAK,CAAC;EACnD,QAAA,GAAOA,oBAAAA,QAAAA,EACL,aAAY;GACV,MAAM,EAAE,gBAAgB,QAAQ,UAAU,UAAU;IAClD,SAAS,OAAO,UAAA,GAASC,mBAAAA,UAAAA,CAAU,MAAM,OAAO,KAAK,KAAK;IAC1D,WAAW;GACb,CAAC;GACD,OAAO;EACT,GACA,UACA,UACAC,mBAAAA,QACF;CACF;CAEF,MAAM,KAAK,SAAS,MAAM;CAC1B,MAAM,MAAM,SAAS,OAAO;CAE5B,QAAA,GADYC,qBAAAA,SAAAA,CAAS,KAAK;EAAE;EAAI;CAAI,CAC3B;AACX"}
|
package/lib/useCan.d.ts
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
import { type AddSubscriber_F, type EventObject, type PrimitiveObject, type State } from '@bemedev/app';
|
|
2
|
+
/**
|
|
3
|
+
* React hook that creates reactive helpers for querying event capabilities from a service.
|
|
4
|
+
*
|
|
5
|
+
* @template {PrimitiveObject} Tc - Context type extending type {@linkcode PrimitiveObject}.
|
|
6
|
+
* @template {string} Ta - Tag type extending `string`.
|
|
7
|
+
* @template {EventObject} Eo - Event object type extending type {@linkcode EventObject}.
|
|
8
|
+
*
|
|
9
|
+
* @param service - Service object containing `subscribe`, `state`, and `canEvents`.
|
|
10
|
+
* @param service.subscribe - Subscription handler function of type {@linkcode AddSubscriber_F}.
|
|
11
|
+
* @param service.state - Current state of type {@linkcode State}.
|
|
12
|
+
* @param service.canEvents - Function checking if event types can be accepted.
|
|
13
|
+
*
|
|
14
|
+
* @returns Object helper with `or` and `and` methods to check event availability.
|
|
15
|
+
*/
|
|
2
16
|
export declare function useCan<Tc extends PrimitiveObject, Ta extends string, Eo extends EventObject>(service: {
|
|
3
17
|
subscribe: AddSubscriber_F<Tc, Ta, Eo>;
|
|
4
18
|
state: State<Eo, Tc, Ta>;
|
package/lib/useCan.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCan.d.ts","sourceRoot":"","sources":["../src/useCan.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,KAAK,EACX,MAAM,cAAc,CAAC;AAKtB,wBAAgB,MAAM,CACpB,EAAE,SAAS,eAAe,EAC1B,EAAE,SAAS,MAAM,EACjB,EAAE,SAAS,WAAW,EACtB,OAAO,EAAE;IACT,SAAS,EAAE,eAAe,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;IACvC,KAAK,EAAE,KAAK,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;IACzB,SAAS,EAAE,CAAC,GAAG,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,KAAK,OAAO,CAAC;CACjD,
|
|
1
|
+
{"version":3,"file":"useCan.d.ts","sourceRoot":"","sources":["../src/useCan.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,KAAK,EACX,MAAM,cAAc,CAAC;AAKtB;;;;;;;;;;;;;GAaG;AACH,wBAAgB,MAAM,CACpB,EAAE,SAAS,eAAe,EAC1B,EAAE,SAAS,MAAM,EACjB,EAAE,SAAS,WAAW,EACtB,OAAO,EAAE;IACT,SAAS,EAAE,eAAe,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;IACvC,KAAK,EAAE,KAAK,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;IACzB,SAAS,EAAE,CAAC,GAAG,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,KAAK,OAAO,CAAC;CACjD,sDAGe,EAAE,CAAC,MAAM,CAAC,EAAE;6BAAZ,EAAE,CAAC,MAAM,CAAC,EAAE;8BAAZ,EAAE,CAAC,MAAM,CAAC,EAAE;GAqB3B"}
|
package/lib/useCan.js
CHANGED
|
@@ -1,18 +1,31 @@
|
|
|
1
|
-
import { deepEqual } from "@bemedev/app/utils";
|
|
2
|
-
import {
|
|
1
|
+
import { deepEqual, identity } from "@bemedev/app/utils";
|
|
2
|
+
import { useSync } from "@bemedev/react-sync";
|
|
3
3
|
import { expandFn } from "@bemedev/app/bemedev";
|
|
4
4
|
//#region src/useCan.ts
|
|
5
|
+
/**
|
|
6
|
+
* React hook that creates reactive helpers for querying event capabilities from a service.
|
|
7
|
+
*
|
|
8
|
+
* @template {PrimitiveObject} Tc - Context type extending type {@linkcode PrimitiveObject}.
|
|
9
|
+
* @template {string} Ta - Tag type extending `string`.
|
|
10
|
+
* @template {EventObject} Eo - Event object type extending type {@linkcode EventObject}.
|
|
11
|
+
*
|
|
12
|
+
* @param service - Service object containing `subscribe`, `state`, and `canEvents`.
|
|
13
|
+
* @param service.subscribe - Subscription handler function of type {@linkcode AddSubscriber_F}.
|
|
14
|
+
* @param service.state - Current state of type {@linkcode State}.
|
|
15
|
+
* @param service.canEvents - Function checking if event types can be accepted.
|
|
16
|
+
*
|
|
17
|
+
* @returns Object helper with `or` and `and` methods to check event availability.
|
|
18
|
+
*/
|
|
5
19
|
function useCan(service) {
|
|
6
|
-
const dispatch = (matcher) => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
};
|
|
20
|
+
const dispatch = (matcher) => (...events) => {
|
|
21
|
+
const selector = () => events[matcher]((event) => service.canEvents(event));
|
|
22
|
+
return useSync((listener) => {
|
|
23
|
+
const { unsubscribe } = service.subscribe(listener, {
|
|
24
|
+
equals: (first, next) => deepEqual(first.value, next.value),
|
|
25
|
+
firstTime: true
|
|
26
|
+
});
|
|
27
|
+
return unsubscribe;
|
|
28
|
+
}, selector, selector, identity);
|
|
16
29
|
};
|
|
17
30
|
const or = dispatch("some");
|
|
18
31
|
const and = dispatch("every");
|
package/lib/useCan.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCan.js","names":[],"sources":["../src/useCan.ts"],"sourcesContent":["import {\n type AddSubscriber_F,\n type EventObject,\n type PrimitiveObject,\n type State,\n} from '@bemedev/app';\nimport { expandFn } from '@bemedev/app/bemedev';\nimport { deepEqual } from '@bemedev/app/utils';\nimport {
|
|
1
|
+
{"version":3,"file":"useCan.js","names":[],"sources":["../src/useCan.ts"],"sourcesContent":["import {\n type AddSubscriber_F,\n type EventObject,\n type PrimitiveObject,\n type State,\n} from '@bemedev/app';\nimport { expandFn } from '@bemedev/app/bemedev';\nimport { deepEqual, identity } from '@bemedev/app/utils';\nimport { useSync } from '@bemedev/react-sync';\n\n/**\n * React hook that creates reactive helpers for querying event capabilities from a service.\n *\n * @template {PrimitiveObject} Tc - Context type extending type {@linkcode PrimitiveObject}.\n * @template {string} Ta - Tag type extending `string`.\n * @template {EventObject} Eo - Event object type extending type {@linkcode EventObject}.\n *\n * @param service - Service object containing `subscribe`, `state`, and `canEvents`.\n * @param service.subscribe - Subscription handler function of type {@linkcode AddSubscriber_F}.\n * @param service.state - Current state of type {@linkcode State}.\n * @param service.canEvents - Function checking if event types can be accepted.\n *\n * @returns Object helper with `or` and `and` methods to check event availability.\n */\nexport function useCan<\n Tc extends PrimitiveObject,\n Ta extends string,\n Eo extends EventObject,\n>(service: {\n subscribe: AddSubscriber_F<Tc, Ta, Eo>;\n state: State<Eo, Tc, Ta>;\n canEvents: (...events: Eo['type'][]) => boolean;\n}) {\n const dispatch =\n (matcher: 'some' | 'every') =>\n (...events: Eo['type'][]) => {\n const selector = () =>\n events[matcher](event => service.canEvents(event));\n return useSync(\n listener => {\n const { unsubscribe } = service.subscribe(listener, {\n equals: (first, next) => deepEqual(first.value, next.value),\n firstTime: true,\n });\n return unsubscribe;\n },\n selector,\n selector,\n identity,\n );\n };\n\n const or = dispatch('some');\n const and = dispatch('every');\n const out = expandFn(and, { or, and });\n return out;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAwBA,SAAgB,OAId,SAIC;CACD,MAAM,YACH,aACA,GAAG,WAAyB;EAC3B,MAAM,iBACJ,OAAO,QAAQ,EAAC,UAAS,QAAQ,UAAU,KAAK,CAAC;EACnD,OAAO,SACL,aAAY;GACV,MAAM,EAAE,gBAAgB,QAAQ,UAAU,UAAU;IAClD,SAAS,OAAO,SAAS,UAAU,MAAM,OAAO,KAAK,KAAK;IAC1D,WAAW;GACb,CAAC;GACD,OAAO;EACT,GACA,UACA,UACA,QACF;CACF;CAEF,MAAM,KAAK,SAAS,MAAM;CAC1B,MAAM,MAAM,SAAS,OAAO;CAE5B,OADY,SAAS,KAAK;EAAE;EAAI;CAAI,CAC3B;AACX"}
|
package/lib/useIsInside.cjs
CHANGED
|
@@ -1,21 +1,37 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
let _bemedev_app_utils = require("@bemedev/app/utils");
|
|
3
|
-
let
|
|
3
|
+
let _bemedev_react_sync = require("@bemedev/react-sync");
|
|
4
4
|
let _bemedev_app_bemedev = require("@bemedev/app/bemedev");
|
|
5
5
|
//#region src/useIsInside.ts
|
|
6
|
+
/**
|
|
7
|
+
* React hook that creates reactive helpers for checking active state hierarchy.
|
|
8
|
+
*
|
|
9
|
+
* @template {PrimitiveObject} Tc - Context type extending type {@linkcode PrimitiveObject}.
|
|
10
|
+
* @template {string} Ta - Tag type extending `string`.
|
|
11
|
+
* @template {EventObject} Eo - Event object type extending type {@linkcode EventObject}.
|
|
12
|
+
*
|
|
13
|
+
* @param service - Service object containing `subscribe` and `state`.
|
|
14
|
+
* @param service.subscribe - Subscription handler function of type {@linkcode AddSubscriber_F}.
|
|
15
|
+
* @param service.state - Current state of type {@linkcode State}.
|
|
16
|
+
*
|
|
17
|
+
* @returns Object helper with `or` and `and` methods to check state hierarchy.
|
|
18
|
+
*/
|
|
6
19
|
function useIsInside(service) {
|
|
7
|
-
const selector1 = (
|
|
8
|
-
return (0, _bemedev_app_utils.decomposeSV)(
|
|
20
|
+
const selector1 = (value) => {
|
|
21
|
+
return (0, _bemedev_app_utils.decomposeSV)(value);
|
|
9
22
|
};
|
|
10
23
|
const dispatch = (matcher) => {
|
|
11
24
|
return (...states) => {
|
|
12
|
-
const selector = (
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
25
|
+
const selector = () => states[matcher]((state) => selector1(service.state.value).includes(state));
|
|
26
|
+
return (0, _bemedev_react_sync.useSync)((listener) => {
|
|
27
|
+
const { unsubscribe } = service.subscribe(listener, {
|
|
28
|
+
equals: (first, next) => {
|
|
29
|
+
return (0, _bemedev_app_utils.deepEqual)(first.value, next.value);
|
|
30
|
+
},
|
|
31
|
+
firstTime: true
|
|
32
|
+
});
|
|
33
|
+
return unsubscribe;
|
|
34
|
+
}, selector, selector, _bemedev_app_utils.identity);
|
|
19
35
|
};
|
|
20
36
|
};
|
|
21
37
|
const or = dispatch("some");
|
package/lib/useIsInside.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIsInside.cjs","names":["decomposeSV","
|
|
1
|
+
{"version":3,"file":"useIsInside.cjs","names":["decomposeSV","useSync","deepEqual","identity","expandFn"],"sources":["../src/useIsInside.ts"],"sourcesContent":["import type {\n AddSubscriber_F,\n EventObject,\n PrimitiveObject,\n State,\n StateValue,\n} from '@bemedev/app';\nimport { expandFn } from '@bemedev/app/bemedev';\nimport { decomposeSV, deepEqual, identity } from '@bemedev/app/utils';\nimport { useSync } from '@bemedev/react-sync';\n\n/**\n * React hook that creates reactive helpers for checking active state hierarchy.\n *\n * @template {PrimitiveObject} Tc - Context type extending type {@linkcode PrimitiveObject}.\n * @template {string} Ta - Tag type extending `string`.\n * @template {EventObject} Eo - Event object type extending type {@linkcode EventObject}.\n *\n * @param service - Service object containing `subscribe` and `state`.\n * @param service.subscribe - Subscription handler function of type {@linkcode AddSubscriber_F}.\n * @param service.state - Current state of type {@linkcode State}.\n *\n * @returns Object helper with `or` and `and` methods to check state hierarchy.\n */\nexport function useIsInside<\n Tc extends PrimitiveObject,\n Ta extends string,\n Eo extends EventObject,\n>(service: {\n subscribe: AddSubscriber_F<Tc, Ta, Eo>;\n state: State<Eo, Tc, Ta>;\n}) {\n const selector1 = (value: StateValue) => {\n return decomposeSV(value);\n };\n\n const dispatch = (matcher: 'some' | 'every') => {\n return (...states: string[]) => {\n const selector = () =>\n states[matcher](state =>\n selector1(service.state.value).includes(state),\n );\n return useSync(\n listener => {\n const { unsubscribe } = service.subscribe(listener, {\n equals: (first, next) => {\n return deepEqual(first.value, next.value);\n },\n firstTime: true,\n });\n\n return unsubscribe;\n },\n selector,\n selector,\n identity,\n );\n };\n };\n\n const or = dispatch('some');\n const and = dispatch('every');\n const out = expandFn(and, { or, and });\n return out;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAwBA,SAAgB,YAId,SAGC;CACD,MAAM,aAAa,UAAsB;EACvC,QAAA,GAAOA,mBAAAA,YAAAA,CAAY,KAAK;CAC1B;CAEA,MAAM,YAAY,YAA8B;EAC9C,QAAQ,GAAG,WAAqB;GAC9B,MAAM,iBACJ,OAAO,QAAQ,EAAC,UACd,UAAU,QAAQ,MAAM,KAAK,CAAC,CAAC,SAAS,KAAK,CAC/C;GACF,QAAA,GAAOC,oBAAAA,QAAAA,EACL,aAAY;IACV,MAAM,EAAE,gBAAgB,QAAQ,UAAU,UAAU;KAClD,SAAS,OAAO,SAAS;MACvB,QAAA,GAAOC,mBAAAA,UAAAA,CAAU,MAAM,OAAO,KAAK,KAAK;KAC1C;KACA,WAAW;IACb,CAAC;IAED,OAAO;GACT,GACA,UACA,UACAC,mBAAAA,QACF;EACF;CACF;CAEA,MAAM,KAAK,SAAS,MAAM;CAC1B,MAAM,MAAM,SAAS,OAAO;CAE5B,QAAA,GADYC,qBAAAA,SAAAA,CAAS,KAAK;EAAE;EAAI;CAAI,CAC3B;AACX"}
|
package/lib/useIsInside.d.ts
CHANGED
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
import type { AddSubscriber_F, EventObject, PrimitiveObject, State } from '@bemedev/app';
|
|
2
|
+
/**
|
|
3
|
+
* React hook that creates reactive helpers for checking active state hierarchy.
|
|
4
|
+
*
|
|
5
|
+
* @template {PrimitiveObject} Tc - Context type extending type {@linkcode PrimitiveObject}.
|
|
6
|
+
* @template {string} Ta - Tag type extending `string`.
|
|
7
|
+
* @template {EventObject} Eo - Event object type extending type {@linkcode EventObject}.
|
|
8
|
+
*
|
|
9
|
+
* @param service - Service object containing `subscribe` and `state`.
|
|
10
|
+
* @param service.subscribe - Subscription handler function of type {@linkcode AddSubscriber_F}.
|
|
11
|
+
* @param service.state - Current state of type {@linkcode State}.
|
|
12
|
+
*
|
|
13
|
+
* @returns Object helper with `or` and `and` methods to check state hierarchy.
|
|
14
|
+
*/
|
|
2
15
|
export declare function useIsInside<Tc extends PrimitiveObject, Ta extends string, Eo extends EventObject>(service: {
|
|
3
16
|
subscribe: AddSubscriber_F<Tc, Ta, Eo>;
|
|
4
17
|
state: State<Eo, Tc, Ta>;
|
package/lib/useIsInside.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIsInside.d.ts","sourceRoot":"","sources":["../src/useIsInside.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,WAAW,EACX,eAAe,EACf,KAAK,
|
|
1
|
+
{"version":3,"file":"useIsInside.d.ts","sourceRoot":"","sources":["../src/useIsInside.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,WAAW,EACX,eAAe,EACf,KAAK,EAEN,MAAM,cAAc,CAAC;AAKtB;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CACzB,EAAE,SAAS,eAAe,EAC1B,EAAE,SAAS,MAAM,EACjB,EAAE,SAAS,WAAW,EACtB,OAAO,EAAE;IACT,SAAS,EAAE,eAAe,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;IACvC,KAAK,EAAE,KAAK,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;CAC1B,sDAMsB,MAAM,EAAE;6BAAR,MAAM,EAAE;8BAAR,MAAM,EAAE;GA2B9B"}
|
package/lib/useIsInside.js
CHANGED
|
@@ -1,20 +1,36 @@
|
|
|
1
|
-
import { decomposeSV, deepEqual } from "@bemedev/app/utils";
|
|
2
|
-
import {
|
|
1
|
+
import { decomposeSV, deepEqual, identity } from "@bemedev/app/utils";
|
|
2
|
+
import { useSync } from "@bemedev/react-sync";
|
|
3
3
|
import { expandFn } from "@bemedev/app/bemedev";
|
|
4
4
|
//#region src/useIsInside.ts
|
|
5
|
+
/**
|
|
6
|
+
* React hook that creates reactive helpers for checking active state hierarchy.
|
|
7
|
+
*
|
|
8
|
+
* @template {PrimitiveObject} Tc - Context type extending type {@linkcode PrimitiveObject}.
|
|
9
|
+
* @template {string} Ta - Tag type extending `string`.
|
|
10
|
+
* @template {EventObject} Eo - Event object type extending type {@linkcode EventObject}.
|
|
11
|
+
*
|
|
12
|
+
* @param service - Service object containing `subscribe` and `state`.
|
|
13
|
+
* @param service.subscribe - Subscription handler function of type {@linkcode AddSubscriber_F}.
|
|
14
|
+
* @param service.state - Current state of type {@linkcode State}.
|
|
15
|
+
*
|
|
16
|
+
* @returns Object helper with `or` and `and` methods to check state hierarchy.
|
|
17
|
+
*/
|
|
5
18
|
function useIsInside(service) {
|
|
6
|
-
const selector1 = (
|
|
7
|
-
return decomposeSV(
|
|
19
|
+
const selector1 = (value) => {
|
|
20
|
+
return decomposeSV(value);
|
|
8
21
|
};
|
|
9
22
|
const dispatch = (matcher) => {
|
|
10
23
|
return (...states) => {
|
|
11
|
-
const selector = (
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
24
|
+
const selector = () => states[matcher]((state) => selector1(service.state.value).includes(state));
|
|
25
|
+
return useSync((listener) => {
|
|
26
|
+
const { unsubscribe } = service.subscribe(listener, {
|
|
27
|
+
equals: (first, next) => {
|
|
28
|
+
return deepEqual(first.value, next.value);
|
|
29
|
+
},
|
|
30
|
+
firstTime: true
|
|
31
|
+
});
|
|
32
|
+
return unsubscribe;
|
|
33
|
+
}, selector, selector, identity);
|
|
18
34
|
};
|
|
19
35
|
};
|
|
20
36
|
const or = dispatch("some");
|
package/lib/useIsInside.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIsInside.js","names":[],"sources":["../src/useIsInside.ts"],"sourcesContent":["import type {\n AddSubscriber_F,\n EventObject,\n PrimitiveObject,\n State,\n} from '@bemedev/app';\nimport {
|
|
1
|
+
{"version":3,"file":"useIsInside.js","names":[],"sources":["../src/useIsInside.ts"],"sourcesContent":["import type {\n AddSubscriber_F,\n EventObject,\n PrimitiveObject,\n State,\n StateValue,\n} from '@bemedev/app';\nimport { expandFn } from '@bemedev/app/bemedev';\nimport { decomposeSV, deepEqual, identity } from '@bemedev/app/utils';\nimport { useSync } from '@bemedev/react-sync';\n\n/**\n * React hook that creates reactive helpers for checking active state hierarchy.\n *\n * @template {PrimitiveObject} Tc - Context type extending type {@linkcode PrimitiveObject}.\n * @template {string} Ta - Tag type extending `string`.\n * @template {EventObject} Eo - Event object type extending type {@linkcode EventObject}.\n *\n * @param service - Service object containing `subscribe` and `state`.\n * @param service.subscribe - Subscription handler function of type {@linkcode AddSubscriber_F}.\n * @param service.state - Current state of type {@linkcode State}.\n *\n * @returns Object helper with `or` and `and` methods to check state hierarchy.\n */\nexport function useIsInside<\n Tc extends PrimitiveObject,\n Ta extends string,\n Eo extends EventObject,\n>(service: {\n subscribe: AddSubscriber_F<Tc, Ta, Eo>;\n state: State<Eo, Tc, Ta>;\n}) {\n const selector1 = (value: StateValue) => {\n return decomposeSV(value);\n };\n\n const dispatch = (matcher: 'some' | 'every') => {\n return (...states: string[]) => {\n const selector = () =>\n states[matcher](state =>\n selector1(service.state.value).includes(state),\n );\n return useSync(\n listener => {\n const { unsubscribe } = service.subscribe(listener, {\n equals: (first, next) => {\n return deepEqual(first.value, next.value);\n },\n firstTime: true,\n });\n\n return unsubscribe;\n },\n selector,\n selector,\n identity,\n );\n };\n };\n\n const or = dispatch('some');\n const and = dispatch('every');\n const out = expandFn(and, { or, and });\n return out;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAwBA,SAAgB,YAId,SAGC;CACD,MAAM,aAAa,UAAsB;EACvC,OAAO,YAAY,KAAK;CAC1B;CAEA,MAAM,YAAY,YAA8B;EAC9C,QAAQ,GAAG,WAAqB;GAC9B,MAAM,iBACJ,OAAO,QAAQ,EAAC,UACd,UAAU,QAAQ,MAAM,KAAK,CAAC,CAAC,SAAS,KAAK,CAC/C;GACF,OAAO,SACL,aAAY;IACV,MAAM,EAAE,gBAAgB,QAAQ,UAAU,UAAU;KAClD,SAAS,OAAO,SAAS;MACvB,OAAO,UAAU,MAAM,OAAO,KAAK,KAAK;KAC1C;KACA,WAAW;IACb,CAAC;IAED,OAAO;GACT,GACA,UACA,UACA,QACF;EACF;CACF;CAEA,MAAM,KAAK,SAAS,MAAM;CAC1B,MAAM,MAAM,SAAS,OAAO;CAE5B,OADY,SAAS,KAAK;EAAE;EAAI;CAAI,CAC3B;AACX"}
|
package/lib/useService.cjs
CHANGED
|
@@ -3,6 +3,20 @@ const require_useState = require("./useState.cjs");
|
|
|
3
3
|
const require_useCan = require("./useCan.cjs");
|
|
4
4
|
const require_useIsInside = require("./useIsInside.cjs");
|
|
5
5
|
//#region src/useService.ts
|
|
6
|
+
/**
|
|
7
|
+
* React hook that binds state management, event checking, and hierarchy querying for a service.
|
|
8
|
+
*
|
|
9
|
+
* @template {PrimitiveObject} Tc - Context type extending type {@linkcode PrimitiveObject}.
|
|
10
|
+
* @template {string} Ta - Tag type extending `string`.
|
|
11
|
+
* @template {EventObject} Eo - Event object type extending type {@linkcode EventObject}.
|
|
12
|
+
*
|
|
13
|
+
* @param service - Service instance containing `subscribe`, `state`, and `canEvents`.
|
|
14
|
+
* @param service.subscribe - Subscription function of type {@linkcode AddSubscriber_F}.
|
|
15
|
+
* @param service.state - Current state of type {@linkcode State}.
|
|
16
|
+
* @param service.canEvents - Method to check event execution capability.
|
|
17
|
+
*
|
|
18
|
+
* @returns Service hooks object containing `state`, `can`, and `isInside`.
|
|
19
|
+
*/
|
|
6
20
|
function useService(service) {
|
|
7
21
|
return {
|
|
8
22
|
state: (options) => require_useState.useState(service, options),
|
|
@@ -10,6 +24,9 @@ function useService(service) {
|
|
|
10
24
|
isInside: require_useIsInside.useIsInside(service)
|
|
11
25
|
};
|
|
12
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Alias for function {@linkcode useService}.
|
|
29
|
+
*/
|
|
13
30
|
const createHooks = useService;
|
|
14
31
|
//#endregion
|
|
15
32
|
exports.createHooks = createHooks;
|
package/lib/useService.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useService.cjs","names":["useState","useCan","useIsInside"],"sources":["../src/useService.ts"],"sourcesContent":["import type {\n AddSubscriber_F,\n EventObject,\n PrimitiveObject,\n State,\n} from '@bemedev/app';\nimport type { UseServiceOptions } from './types';\nimport { useCan } from './useCan';\nimport { useIsInside } from './useIsInside';\nimport { useState } from './useState';\n\nexport function useService<\n Tc extends PrimitiveObject,\n Ta extends string,\n Eo extends EventObject,\n>(service: {\n subscribe: AddSubscriber_F<Tc, Ta, Eo>;\n state: State<Eo, Tc, Ta>;\n canEvents: (...events: Eo['type'][]) => boolean;\n}) {\n return {\n state: <T = State<Eo, Tc, Ta>>(\n options?: UseServiceOptions<Tc, Ta, Eo, T>,\n ) => useState<Tc, Ta, Eo, T>(service, options),\n\n can: useCan(service),\n isInside: useIsInside(service),\n };\n}\n\nexport const createHooks = useService;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useService.cjs","names":["useState","useCan","useIsInside"],"sources":["../src/useService.ts"],"sourcesContent":["import type {\n AddSubscriber_F,\n EventObject,\n PrimitiveObject,\n State,\n} from '@bemedev/app';\nimport type { UseServiceOptions } from './types';\nimport { useCan } from './useCan';\nimport { useIsInside } from './useIsInside';\nimport { useState } from './useState';\n\n/**\n * React hook that binds state management, event checking, and hierarchy querying for a service.\n *\n * @template {PrimitiveObject} Tc - Context type extending type {@linkcode PrimitiveObject}.\n * @template {string} Ta - Tag type extending `string`.\n * @template {EventObject} Eo - Event object type extending type {@linkcode EventObject}.\n *\n * @param service - Service instance containing `subscribe`, `state`, and `canEvents`.\n * @param service.subscribe - Subscription function of type {@linkcode AddSubscriber_F}.\n * @param service.state - Current state of type {@linkcode State}.\n * @param service.canEvents - Method to check event execution capability.\n *\n * @returns Service hooks object containing `state`, `can`, and `isInside`.\n */\nexport function useService<\n Tc extends PrimitiveObject,\n Ta extends string,\n Eo extends EventObject,\n>(service: {\n subscribe: AddSubscriber_F<Tc, Ta, Eo>;\n state: State<Eo, Tc, Ta>;\n canEvents: (...events: Eo['type'][]) => boolean;\n}) {\n return {\n state: <T = State<Eo, Tc, Ta>>(\n options?: UseServiceOptions<Tc, Ta, Eo, T>,\n ) => useState<Tc, Ta, Eo, T>(service, options),\n\n can: useCan(service),\n isInside: useIsInside(service),\n };\n}\n\n/**\n * Alias for function {@linkcode useService}.\n */\nexport const createHooks = useService;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAyBA,SAAgB,WAId,SAIC;CACD,OAAO;EACL,QACE,YACGA,iBAAAA,SAAwB,SAAS,OAAO;EAE7C,KAAKC,eAAAA,OAAO,OAAO;EACnB,UAAUC,oBAAAA,YAAY,OAAO;CAC/B;AACF;;;;AAKA,MAAa,cAAc"}
|
package/lib/useService.d.ts
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
import type { AddSubscriber_F, EventObject, PrimitiveObject, State } from '@bemedev/app';
|
|
2
2
|
import type { UseServiceOptions } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* React hook that binds state management, event checking, and hierarchy querying for a service.
|
|
5
|
+
*
|
|
6
|
+
* @template {PrimitiveObject} Tc - Context type extending type {@linkcode PrimitiveObject}.
|
|
7
|
+
* @template {string} Ta - Tag type extending `string`.
|
|
8
|
+
* @template {EventObject} Eo - Event object type extending type {@linkcode EventObject}.
|
|
9
|
+
*
|
|
10
|
+
* @param service - Service instance containing `subscribe`, `state`, and `canEvents`.
|
|
11
|
+
* @param service.subscribe - Subscription function of type {@linkcode AddSubscriber_F}.
|
|
12
|
+
* @param service.state - Current state of type {@linkcode State}.
|
|
13
|
+
* @param service.canEvents - Method to check event execution capability.
|
|
14
|
+
*
|
|
15
|
+
* @returns Service hooks object containing `state`, `can`, and `isInside`.
|
|
16
|
+
*/
|
|
3
17
|
export declare function useService<Tc extends PrimitiveObject, Ta extends string, Eo extends EventObject>(service: {
|
|
4
18
|
subscribe: AddSubscriber_F<Tc, Ta, Eo>;
|
|
5
19
|
state: State<Eo, Tc, Ta>;
|
|
@@ -15,5 +29,8 @@ export declare function useService<Tc extends PrimitiveObject, Ta extends string
|
|
|
15
29
|
readonly and: (...states: string[]) => boolean;
|
|
16
30
|
}>;
|
|
17
31
|
};
|
|
32
|
+
/**
|
|
33
|
+
* Alias for function {@linkcode useService}.
|
|
34
|
+
*/
|
|
18
35
|
export declare const createHooks: typeof useService;
|
|
19
36
|
//# sourceMappingURL=useService.d.ts.map
|
package/lib/useService.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useService.d.ts","sourceRoot":"","sources":["../src/useService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,WAAW,EACX,eAAe,EACf,KAAK,EACN,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAKjD,wBAAgB,UAAU,CACxB,EAAE,SAAS,eAAe,EAC1B,EAAE,SAAS,MAAM,EACjB,EAAE,SAAS,WAAW,EACtB,OAAO,EAAE;IACT,SAAS,EAAE,eAAe,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;IACvC,KAAK,EAAE,KAAK,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;IACzB,SAAS,EAAE,CAAC,GAAG,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,KAAK,OAAO,CAAC;CACjD;YAEW,CAAC,gCACG,iBAAiB,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;;;;;;;;;EAM/C;AAED,eAAO,MAAM,WAAW,mBAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"useService.d.ts","sourceRoot":"","sources":["../src/useService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,WAAW,EACX,eAAe,EACf,KAAK,EACN,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAKjD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,UAAU,CACxB,EAAE,SAAS,eAAe,EAC1B,EAAE,SAAS,MAAM,EACjB,EAAE,SAAS,WAAW,EACtB,OAAO,EAAE;IACT,SAAS,EAAE,eAAe,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;IACvC,KAAK,EAAE,KAAK,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;IACzB,SAAS,EAAE,CAAC,GAAG,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,KAAK,OAAO,CAAC;CACjD;YAEW,CAAC,gCACG,iBAAiB,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;;;;;;;;;EAM/C;AAED;;GAEG;AACH,eAAO,MAAM,WAAW,mBAAa,CAAC"}
|
package/lib/useService.js
CHANGED
|
@@ -2,6 +2,20 @@ import { useState } from "./useState.js";
|
|
|
2
2
|
import { useCan } from "./useCan.js";
|
|
3
3
|
import { useIsInside } from "./useIsInside.js";
|
|
4
4
|
//#region src/useService.ts
|
|
5
|
+
/**
|
|
6
|
+
* React hook that binds state management, event checking, and hierarchy querying for a service.
|
|
7
|
+
*
|
|
8
|
+
* @template {PrimitiveObject} Tc - Context type extending type {@linkcode PrimitiveObject}.
|
|
9
|
+
* @template {string} Ta - Tag type extending `string`.
|
|
10
|
+
* @template {EventObject} Eo - Event object type extending type {@linkcode EventObject}.
|
|
11
|
+
*
|
|
12
|
+
* @param service - Service instance containing `subscribe`, `state`, and `canEvents`.
|
|
13
|
+
* @param service.subscribe - Subscription function of type {@linkcode AddSubscriber_F}.
|
|
14
|
+
* @param service.state - Current state of type {@linkcode State}.
|
|
15
|
+
* @param service.canEvents - Method to check event execution capability.
|
|
16
|
+
*
|
|
17
|
+
* @returns Service hooks object containing `state`, `can`, and `isInside`.
|
|
18
|
+
*/
|
|
5
19
|
function useService(service) {
|
|
6
20
|
return {
|
|
7
21
|
state: (options) => useState(service, options),
|
|
@@ -9,6 +23,9 @@ function useService(service) {
|
|
|
9
23
|
isInside: useIsInside(service)
|
|
10
24
|
};
|
|
11
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Alias for function {@linkcode useService}.
|
|
28
|
+
*/
|
|
12
29
|
const createHooks = useService;
|
|
13
30
|
//#endregion
|
|
14
31
|
export { createHooks, useService };
|
package/lib/useService.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useService.js","names":[],"sources":["../src/useService.ts"],"sourcesContent":["import type {\n AddSubscriber_F,\n EventObject,\n PrimitiveObject,\n State,\n} from '@bemedev/app';\nimport type { UseServiceOptions } from './types';\nimport { useCan } from './useCan';\nimport { useIsInside } from './useIsInside';\nimport { useState } from './useState';\n\nexport function useService<\n Tc extends PrimitiveObject,\n Ta extends string,\n Eo extends EventObject,\n>(service: {\n subscribe: AddSubscriber_F<Tc, Ta, Eo>;\n state: State<Eo, Tc, Ta>;\n canEvents: (...events: Eo['type'][]) => boolean;\n}) {\n return {\n state: <T = State<Eo, Tc, Ta>>(\n options?: UseServiceOptions<Tc, Ta, Eo, T>,\n ) => useState<Tc, Ta, Eo, T>(service, options),\n\n can: useCan(service),\n isInside: useIsInside(service),\n };\n}\n\nexport const createHooks = useService;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useService.js","names":[],"sources":["../src/useService.ts"],"sourcesContent":["import type {\n AddSubscriber_F,\n EventObject,\n PrimitiveObject,\n State,\n} from '@bemedev/app';\nimport type { UseServiceOptions } from './types';\nimport { useCan } from './useCan';\nimport { useIsInside } from './useIsInside';\nimport { useState } from './useState';\n\n/**\n * React hook that binds state management, event checking, and hierarchy querying for a service.\n *\n * @template {PrimitiveObject} Tc - Context type extending type {@linkcode PrimitiveObject}.\n * @template {string} Ta - Tag type extending `string`.\n * @template {EventObject} Eo - Event object type extending type {@linkcode EventObject}.\n *\n * @param service - Service instance containing `subscribe`, `state`, and `canEvents`.\n * @param service.subscribe - Subscription function of type {@linkcode AddSubscriber_F}.\n * @param service.state - Current state of type {@linkcode State}.\n * @param service.canEvents - Method to check event execution capability.\n *\n * @returns Service hooks object containing `state`, `can`, and `isInside`.\n */\nexport function useService<\n Tc extends PrimitiveObject,\n Ta extends string,\n Eo extends EventObject,\n>(service: {\n subscribe: AddSubscriber_F<Tc, Ta, Eo>;\n state: State<Eo, Tc, Ta>;\n canEvents: (...events: Eo['type'][]) => boolean;\n}) {\n return {\n state: <T = State<Eo, Tc, Ta>>(\n options?: UseServiceOptions<Tc, Ta, Eo, T>,\n ) => useState<Tc, Ta, Eo, T>(service, options),\n\n can: useCan(service),\n isInside: useIsInside(service),\n };\n}\n\n/**\n * Alias for function {@linkcode useService}.\n */\nexport const createHooks = useService;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAyBA,SAAgB,WAId,SAIC;CACD,OAAO;EACL,QACE,YACG,SAAwB,SAAS,OAAO;EAE7C,KAAK,OAAO,OAAO;EACnB,UAAU,YAAY,OAAO;CAC/B;AACF;;;;AAKA,MAAa,cAAc"}
|
package/lib/useState.cjs
CHANGED
|
@@ -1,26 +1,36 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
let _bemedev_app_utils = require("@bemedev/app/utils");
|
|
3
|
-
let
|
|
3
|
+
let _bemedev_react_sync = require("@bemedev/react-sync");
|
|
4
4
|
//#region src/useState.ts
|
|
5
5
|
/**
|
|
6
6
|
* A hook that creates a React state from a service with a subscribe function.
|
|
7
7
|
*
|
|
8
|
-
* @
|
|
9
|
-
* @
|
|
10
|
-
* @
|
|
8
|
+
* @template {PrimitiveObject} Tc - Context type extending type {@linkcode PrimitiveObject}.
|
|
9
|
+
* @template {string} Ta - Tag type extending `string`.
|
|
10
|
+
* @template {EventObject} Eo - Event object type extending type {@linkcode EventObject}.
|
|
11
|
+
* @template T - Selected state type, defaults to type {@linkcode State}<{@linkcode Eo}, {@linkcode Tc}, {@linkcode Ta}>.
|
|
12
|
+
*
|
|
13
|
+
* @param service - The service containing state and subscribe method.
|
|
14
|
+
* @param service.subscribe - Subscription handler function of type {@linkcode AddSubscriber_F}.
|
|
15
|
+
* @param service.state - Current state of type {@linkcode State}.
|
|
16
|
+
* @param options - Optional configuration options of type {@linkcode UseServiceOptions}.
|
|
17
|
+
*
|
|
18
|
+
* @returns The selected state of type `T`.
|
|
11
19
|
*/
|
|
12
20
|
function useState(service, options) {
|
|
13
|
-
const { selector =
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
const { selector = _bemedev_app_utils.identity, equals = _bemedev_app_utils.deepEqual } = options ?? {};
|
|
22
|
+
const _selector = () => selector(service.state);
|
|
23
|
+
return (0, _bemedev_react_sync.useSync)((listener) => {
|
|
24
|
+
const { unsubscribe } = service.subscribe(listener, {
|
|
25
|
+
equals: (prev, next) => {
|
|
26
|
+
const _prev = selector(prev);
|
|
27
|
+
const _next = selector(next);
|
|
28
|
+
return equals(_prev, _next);
|
|
29
|
+
},
|
|
30
|
+
firstTime: true
|
|
31
|
+
});
|
|
32
|
+
return unsubscribe;
|
|
33
|
+
}, _selector, _selector, _bemedev_app_utils.identity, equals);
|
|
24
34
|
}
|
|
25
35
|
//#endregion
|
|
26
36
|
exports.useState = useState;
|
package/lib/useState.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useState.cjs","names":["
|
|
1
|
+
{"version":3,"file":"useState.cjs","names":["identity","deepEqual","useSync"],"sources":["../src/useState.ts"],"sourcesContent":["import {\n type AddSubscriber_F,\n type EventObject,\n type PrimitiveObject,\n type State,\n} from '@bemedev/app';\nimport { deepEqual, identity } from '@bemedev/app/utils';\nimport { useSync } from '@bemedev/react-sync';\nimport type { UseServiceOptions } from './types';\n\n/**\n * A hook that creates a React state from a service with a subscribe function.\n *\n * @template {PrimitiveObject} Tc - Context type extending type {@linkcode PrimitiveObject}.\n * @template {string} Ta - Tag type extending `string`.\n * @template {EventObject} Eo - Event object type extending type {@linkcode EventObject}.\n * @template T - Selected state type, defaults to type {@linkcode State}<{@linkcode Eo}, {@linkcode Tc}, {@linkcode Ta}>.\n *\n * @param service - The service containing state and subscribe method.\n * @param service.subscribe - Subscription handler function of type {@linkcode AddSubscriber_F}.\n * @param service.state - Current state of type {@linkcode State}.\n * @param options - Optional configuration options of type {@linkcode UseServiceOptions}.\n *\n * @returns The selected state of type `T`.\n */\nexport function useState<\n Tc extends PrimitiveObject,\n Ta extends string,\n Eo extends EventObject,\n T = State<Eo, Tc, Ta>,\n>(\n service: {\n subscribe: AddSubscriber_F<Tc, Ta, Eo>;\n state: State<Eo, Tc, Ta>;\n },\n options?: UseServiceOptions<Tc, Ta, Eo, T>,\n): T {\n const { selector = identity, equals = deepEqual<T> } = options ?? {};\n const _selector = () => selector(service.state);\n\n return useSync(\n listener => {\n const { unsubscribe } = service.subscribe(listener, {\n equals: (prev, next) => {\n const _prev = selector(prev);\n const _next = selector(next);\n return equals(_prev, _next);\n },\n firstTime: true,\n });\n return unsubscribe;\n },\n _selector,\n _selector,\n identity,\n equals,\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAyBA,SAAgB,SAMd,SAIA,SACG;CACH,MAAM,EAAE,WAAWA,mBAAAA,UAAU,SAASC,mBAAAA,cAAiB,WAAW,CAAC;CACnE,MAAM,kBAAkB,SAAS,QAAQ,KAAK;CAE9C,QAAA,GAAOC,oBAAAA,QAAAA,EACL,aAAY;EACV,MAAM,EAAE,gBAAgB,QAAQ,UAAU,UAAU;GAClD,SAAS,MAAM,SAAS;IACtB,MAAM,QAAQ,SAAS,IAAI;IAC3B,MAAM,QAAQ,SAAS,IAAI;IAC3B,OAAO,OAAO,OAAO,KAAK;GAC5B;GACA,WAAW;EACb,CAAC;EACD,OAAO;CACT,GACA,WACA,WACAF,mBAAAA,UACA,MACF;AACF"}
|
package/lib/useState.d.ts
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type AddSubscriber_F, type EventObject, type PrimitiveObject, type State } from '@bemedev/app';
|
|
2
2
|
import type { UseServiceOptions } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* A hook that creates a React state from a service with a subscribe function.
|
|
5
5
|
*
|
|
6
|
-
* @
|
|
7
|
-
* @
|
|
8
|
-
* @
|
|
6
|
+
* @template {PrimitiveObject} Tc - Context type extending type {@linkcode PrimitiveObject}.
|
|
7
|
+
* @template {string} Ta - Tag type extending `string`.
|
|
8
|
+
* @template {EventObject} Eo - Event object type extending type {@linkcode EventObject}.
|
|
9
|
+
* @template T - Selected state type, defaults to type {@linkcode State}<{@linkcode Eo}, {@linkcode Tc}, {@linkcode Ta}>.
|
|
10
|
+
*
|
|
11
|
+
* @param service - The service containing state and subscribe method.
|
|
12
|
+
* @param service.subscribe - Subscription handler function of type {@linkcode AddSubscriber_F}.
|
|
13
|
+
* @param service.state - Current state of type {@linkcode State}.
|
|
14
|
+
* @param options - Optional configuration options of type {@linkcode UseServiceOptions}.
|
|
15
|
+
*
|
|
16
|
+
* @returns The selected state of type `T`.
|
|
9
17
|
*/
|
|
10
18
|
export declare function useState<Tc extends PrimitiveObject, Ta extends string, Eo extends EventObject, T = State<Eo, Tc, Ta>>(service: {
|
|
11
19
|
subscribe: AddSubscriber_F<Tc, Ta, Eo>;
|
package/lib/useState.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useState.d.ts","sourceRoot":"","sources":["../src/useState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"useState.d.ts","sourceRoot":"","sources":["../src/useState.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,KAAK,EACX,MAAM,cAAc,CAAC;AAGtB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEjD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,QAAQ,CACtB,EAAE,SAAS,eAAe,EAC1B,EAAE,SAAS,MAAM,EACjB,EAAE,SAAS,WAAW,EACtB,CAAC,GAAG,KAAK,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAErB,OAAO,EAAE;IACP,SAAS,EAAE,eAAe,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;IACvC,KAAK,EAAE,KAAK,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;CAC1B,EACD,OAAO,CAAC,EAAE,iBAAiB,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,GACzC,CAAC,CAqBH"}
|
package/lib/useState.js
CHANGED
|
@@ -1,25 +1,35 @@
|
|
|
1
|
-
import { deepEqual } from "@bemedev/app/utils";
|
|
2
|
-
import {
|
|
1
|
+
import { deepEqual, identity } from "@bemedev/app/utils";
|
|
2
|
+
import { useSync } from "@bemedev/react-sync";
|
|
3
3
|
//#region src/useState.ts
|
|
4
4
|
/**
|
|
5
5
|
* A hook that creates a React state from a service with a subscribe function.
|
|
6
6
|
*
|
|
7
|
-
* @
|
|
8
|
-
* @
|
|
9
|
-
* @
|
|
7
|
+
* @template {PrimitiveObject} Tc - Context type extending type {@linkcode PrimitiveObject}.
|
|
8
|
+
* @template {string} Ta - Tag type extending `string`.
|
|
9
|
+
* @template {EventObject} Eo - Event object type extending type {@linkcode EventObject}.
|
|
10
|
+
* @template T - Selected state type, defaults to type {@linkcode State}<{@linkcode Eo}, {@linkcode Tc}, {@linkcode Ta}>.
|
|
11
|
+
*
|
|
12
|
+
* @param service - The service containing state and subscribe method.
|
|
13
|
+
* @param service.subscribe - Subscription handler function of type {@linkcode AddSubscriber_F}.
|
|
14
|
+
* @param service.state - Current state of type {@linkcode State}.
|
|
15
|
+
* @param options - Optional configuration options of type {@linkcode UseServiceOptions}.
|
|
16
|
+
*
|
|
17
|
+
* @returns The selected state of type `T`.
|
|
10
18
|
*/
|
|
11
19
|
function useState(service, options) {
|
|
12
|
-
const { selector =
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
const { selector = identity, equals = deepEqual } = options ?? {};
|
|
21
|
+
const _selector = () => selector(service.state);
|
|
22
|
+
return useSync((listener) => {
|
|
23
|
+
const { unsubscribe } = service.subscribe(listener, {
|
|
24
|
+
equals: (prev, next) => {
|
|
25
|
+
const _prev = selector(prev);
|
|
26
|
+
const _next = selector(next);
|
|
27
|
+
return equals(_prev, _next);
|
|
28
|
+
},
|
|
29
|
+
firstTime: true
|
|
30
|
+
});
|
|
31
|
+
return unsubscribe;
|
|
32
|
+
}, _selector, _selector, identity, equals);
|
|
23
33
|
}
|
|
24
34
|
//#endregion
|
|
25
35
|
export { useState };
|
package/lib/useState.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useState.js","names":[
|
|
1
|
+
{"version":3,"file":"useState.js","names":[],"sources":["../src/useState.ts"],"sourcesContent":["import {\n type AddSubscriber_F,\n type EventObject,\n type PrimitiveObject,\n type State,\n} from '@bemedev/app';\nimport { deepEqual, identity } from '@bemedev/app/utils';\nimport { useSync } from '@bemedev/react-sync';\nimport type { UseServiceOptions } from './types';\n\n/**\n * A hook that creates a React state from a service with a subscribe function.\n *\n * @template {PrimitiveObject} Tc - Context type extending type {@linkcode PrimitiveObject}.\n * @template {string} Ta - Tag type extending `string`.\n * @template {EventObject} Eo - Event object type extending type {@linkcode EventObject}.\n * @template T - Selected state type, defaults to type {@linkcode State}<{@linkcode Eo}, {@linkcode Tc}, {@linkcode Ta}>.\n *\n * @param service - The service containing state and subscribe method.\n * @param service.subscribe - Subscription handler function of type {@linkcode AddSubscriber_F}.\n * @param service.state - Current state of type {@linkcode State}.\n * @param options - Optional configuration options of type {@linkcode UseServiceOptions}.\n *\n * @returns The selected state of type `T`.\n */\nexport function useState<\n Tc extends PrimitiveObject,\n Ta extends string,\n Eo extends EventObject,\n T = State<Eo, Tc, Ta>,\n>(\n service: {\n subscribe: AddSubscriber_F<Tc, Ta, Eo>;\n state: State<Eo, Tc, Ta>;\n },\n options?: UseServiceOptions<Tc, Ta, Eo, T>,\n): T {\n const { selector = identity, equals = deepEqual<T> } = options ?? {};\n const _selector = () => selector(service.state);\n\n return useSync(\n listener => {\n const { unsubscribe } = service.subscribe(listener, {\n equals: (prev, next) => {\n const _prev = selector(prev);\n const _next = selector(next);\n return equals(_prev, _next);\n },\n firstTime: true,\n });\n return unsubscribe;\n },\n _selector,\n _selector,\n identity,\n equals,\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAyBA,SAAgB,SAMd,SAIA,SACG;CACH,MAAM,EAAE,WAAW,UAAU,SAAS,cAAiB,WAAW,CAAC;CACnE,MAAM,kBAAkB,SAAS,QAAQ,KAAK;CAE9C,OAAO,SACL,aAAY;EACV,MAAM,EAAE,gBAAgB,QAAQ,UAAU,UAAU;GAClD,SAAS,MAAM,SAAS;IACtB,MAAM,QAAQ,SAAS,IAAI;IAC3B,MAAM,QAAQ,SAAS,IAAI;IAC3B,OAAO,OAAO,OAAO,KAAK;GAC5B;GACA,WAAW;EACb,CAAC;EACD,OAAO;CACT,GACA,WACA,WACA,UACA,MACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bemedev/app-reactjs",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.0",
|
|
4
4
|
"description": "Middleware between @bemedev/app and reactjs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"app",
|
|
@@ -48,10 +48,10 @@
|
|
|
48
48
|
"@bemedev/dev-utils": "^1.1.1",
|
|
49
49
|
"@bemedev/sleep": "^0.2.2",
|
|
50
50
|
"@size-limit/file": "^13.0.3",
|
|
51
|
-
"@testing-library/jest-dom": "^7.0.
|
|
51
|
+
"@testing-library/jest-dom": "^7.0.1",
|
|
52
52
|
"@testing-library/react": "^16.3.2",
|
|
53
|
-
"@testing-library/user-event": "^14.6.
|
|
54
|
-
"@types/node": "^26.
|
|
53
|
+
"@testing-library/user-event": "^14.6.3",
|
|
54
|
+
"@types/node": "^26.2.0",
|
|
55
55
|
"@types/react": "^19.2.18",
|
|
56
56
|
"@types/react-dom": "^19.2.4",
|
|
57
57
|
"@vitest/coverage-v8": "^4.1.10",
|
|
@@ -61,25 +61,25 @@
|
|
|
61
61
|
"husky": "^9.1.7",
|
|
62
62
|
"jsdom": "^30.0.1",
|
|
63
63
|
"onchange": "^7.1.0",
|
|
64
|
-
"oxfmt": "^0.
|
|
65
|
-
"oxlint": "^1.
|
|
64
|
+
"oxfmt": "^0.63.0",
|
|
65
|
+
"oxlint": "^1.78.0",
|
|
66
66
|
"prettier": "^3.9.6",
|
|
67
67
|
"pretty-quick": "^4.2.2",
|
|
68
68
|
"react": "^19.2.8",
|
|
69
69
|
"react-dom": "^19.2.8",
|
|
70
|
-
"rolldown": "1.2.
|
|
71
|
-
"rolldown-plugin-dts": "^0.28.
|
|
70
|
+
"rolldown": "1.2.3",
|
|
71
|
+
"rolldown-plugin-dts": "^0.28.1",
|
|
72
72
|
"size-limit": "^13.0.3",
|
|
73
73
|
"tslib": "^2.8.1",
|
|
74
|
-
"tsx": "^4.23.
|
|
75
|
-
"typescript": "
|
|
74
|
+
"tsx": "^4.23.12",
|
|
75
|
+
"typescript": "6.0.3",
|
|
76
76
|
"vitest": "^4.1.10",
|
|
77
|
-
"@bemedev/app": "^1.
|
|
78
|
-
"@bemedev/app-vitest": "^1.
|
|
77
|
+
"@bemedev/app": "^1.10.0",
|
|
78
|
+
"@bemedev/app-vitest": "^1.10.0"
|
|
79
79
|
},
|
|
80
80
|
"peerDependencies": {
|
|
81
81
|
"react": "^19.2.8",
|
|
82
|
-
"@bemedev/app": "^1.
|
|
82
|
+
"@bemedev/app": "^1.10.0"
|
|
83
83
|
},
|
|
84
84
|
"size-limit": [
|
|
85
85
|
{
|
|
@@ -89,45 +89,32 @@
|
|
|
89
89
|
{
|
|
90
90
|
"path": "lib/*.cjs",
|
|
91
91
|
"limit": "10 KB"
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"path": "lib/*.d.ts",
|
|
95
|
+
"limit": "10 KB"
|
|
92
96
|
}
|
|
93
97
|
],
|
|
94
98
|
"engines": {
|
|
95
99
|
"node": ">=24"
|
|
96
100
|
},
|
|
101
|
+
"dependencies": {
|
|
102
|
+
"@bemedev/react-sync": "^0.1.1"
|
|
103
|
+
},
|
|
97
104
|
"scripts": {
|
|
98
|
-
"build": "pnpm
|
|
99
|
-
"_ci": "pnpm run lint && pnpm run
|
|
100
|
-
"ci": "CI_START=$(date +%s) && pnpm run
|
|
101
|
-
"ci:admin": "pnpm run rm && pnpm run upgrade && pnpm run ci",
|
|
102
|
-
"generate": "app-cli generate -c ./src/__tests__",
|
|
103
|
-
"clean": "pnpm run rm && pnpm run config",
|
|
104
|
-
"config": "pnpm install",
|
|
105
|
-
"config:off": "pnpm run config --offline",
|
|
105
|
+
"build": "pnpm rm:lib && pnpm run rolldown",
|
|
106
|
+
"_ci": "pnpm run lint && pnpm run build",
|
|
107
|
+
"ci": "CI_START=$(date +%s) && pnpm run _ci && pnpm run p-q && echo \"\n✅ CI takes $(($(date +%s) - CI_START))s\n\"",
|
|
106
108
|
"fmt": "oxfmt",
|
|
107
109
|
"fmt:check": "oxfmt --check",
|
|
108
|
-
"gen:app": "app generate -c ./src/__tests__",
|
|
109
|
-
"gen:app:watch": "pnpm run gen:app --watch",
|
|
110
110
|
"_lint": "oxlint",
|
|
111
|
+
"postbuild": "pnpm run size && pnpm run fmt",
|
|
111
112
|
"lint:fix": "oxlint --fix",
|
|
112
113
|
"lint": "pnpm run fmt && pnpm run lint:fix",
|
|
113
|
-
"lint:watch": "onchange --await-write-finish 5500 \"**/*\" -- pnpm run lint",
|
|
114
|
-
"posttest": "pnpm run fmt",
|
|
115
|
-
"pretest": "pnpm run build && pnpm run size",
|
|
116
|
-
"prettier": "prettier --write \"src/**/*.{ts,tsx}\"",
|
|
117
114
|
"p-q": "pretty-quick",
|
|
118
|
-
"
|
|
119
|
-
"
|
|
120
|
-
"rimraf": "pnpx rimraf -rf",
|
|
121
|
-
"rm": "pnpm run rimraf -- node_modules pnpm-lock.yaml",
|
|
122
|
-
"rm:lib": "pnpm run rimraf -- lib",
|
|
123
|
-
"rolldown": "rolldown -c",
|
|
115
|
+
"rm": "pnpx rimraf ./node_modules ./pnpm-lock.yaml",
|
|
116
|
+
"rm:lib": "pnpx rimraf ./lib",
|
|
124
117
|
"size": "size-limit",
|
|
125
|
-
"
|
|
126
|
-
"test:only": "pnpm run test:coverage --no-coverage",
|
|
127
|
-
"test:coverage": "vitest run",
|
|
128
|
-
"test:ui": "vitest ui",
|
|
129
|
-
"test:watch": "vitest",
|
|
130
|
-
"upgrade": "pnpm upgrade --latest",
|
|
131
|
-
"upgrade:safe": "pnpm run upgrade"
|
|
118
|
+
"rolldown": "rolldown -c"
|
|
132
119
|
}
|
|
133
120
|
}
|