@yoltra/react 0.5.0 → 0.6.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/README.md +20 -20
- package/dist/index.cjs +2 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +4 -22
- package/dist/index.mjs.map +1 -1
- package/dist/types/hooks/createHooks.d.ts +2 -2
- package/dist/types/hooks/hooks.d.ts +2 -2
- package/dist/types/hooks/suspense.d.ts +22 -3
- package/dist/types/index.d.ts +1 -0
- package/package.json +8 -8
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DeepReadonly, Dotted, Emit, Event, EventMapBase, EventPhase, PathValue, StoreInstance, WithGlob } from '@yoltra/core';
|
|
1
|
+
import { DeepReadonly, Dotted, Emit, Event, EventMapBase, EventPhase, NotifiedPhase, PathValue, StoreInstance, WithGlob } from '@yoltra/core';
|
|
2
2
|
import { UseSuspenseAtomicProp, UseSuspenseAtomicProps } from './suspense.js';
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
/**
|
|
@@ -109,7 +109,7 @@ export type UseAtomicProps<R extends string, S extends Record<R, any>> = {
|
|
|
109
109
|
*
|
|
110
110
|
* @public
|
|
111
111
|
*/
|
|
112
|
-
export type UseEvent<EM extends EventMapBase, S> = <C extends keyof EM & string, T extends keyof EM[C] & string>(channel: C, type: T, handler: (event: Event<EM, C, T>, getState: () => DeepReadonly<S>, emit: Emit<EM>, phase:
|
|
112
|
+
export type UseEvent<EM extends EventMapBase, S> = <C extends keyof EM & string, T extends keyof EM[C] & string>(channel: C, type: T, handler: (event: Event<EM, C, T>, getState: () => DeepReadonly<S>, emit: Emit<EM>, phase: NotifiedPhase) => void | Promise<void>, phase?: EventPhase) => void;
|
|
113
113
|
/**
|
|
114
114
|
* The bundle of fully-typed hooks returned by {@link createHooks} (and, with the
|
|
115
115
|
* store and provider added, by {@link createYoltra}).
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DeepReadonly, Dotted, Emit, Event, EventMapBase, EventPhase, PathValue, StoreInstance, WithGlob } from '@yoltra/core';
|
|
1
|
+
import { DeepReadonly, Dotted, Emit, Event, EventMapBase, EventPhase, NotifiedPhase, PathValue, StoreInstance, WithGlob } from '@yoltra/core';
|
|
2
2
|
/**
|
|
3
3
|
* Re-export of {@link PathValue} from `@yoltra/core`.
|
|
4
4
|
*
|
|
@@ -243,4 +243,4 @@ export declare function useAtomicProps<R extends string, S extends Record<R, any
|
|
|
243
243
|
*
|
|
244
244
|
* @public
|
|
245
245
|
*/
|
|
246
|
-
export declare function useEvent<EM extends EventMapBase, C extends keyof EM & string, T extends keyof EM[C] & string>(channel: C, type: T, handler: (event: Event<EM, C, T>, getState: () => DeepReadonly<any>, emit: Emit<EM>, phase:
|
|
246
|
+
export declare function useEvent<EM extends EventMapBase, C extends keyof EM & string, T extends keyof EM[C] & string>(channel: C, type: T, handler: (event: Event<EM, C, T>, getState: () => DeepReadonly<any>, emit: Emit<EM>, phase: NotifiedPhase) => void | Promise<void>, phase?: EventPhase): void;
|
|
@@ -1,4 +1,22 @@
|
|
|
1
1
|
import { Dotted, WithGlob } from '@yoltra/core';
|
|
2
|
+
/**
|
|
3
|
+
* Backing store for the `useSuspense*` hooks.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* Documented because {@link suspenseCache} exports an instance of it: a type reachable
|
|
7
|
+
* through a published value is part of the surface whether or not it was meant to be.
|
|
8
|
+
* Its internals stay private; what is documented is what a consumer can actually call.
|
|
9
|
+
*
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
declare class SuspenseCache {
|
|
13
|
+
private store;
|
|
14
|
+
/** Number of entries currently held. */
|
|
15
|
+
get size(): number;
|
|
16
|
+
read<T>(key: CacheKey, load: () => T | Promise<T>, staleTime: number | null, errorTtlMs: number | null | undefined): T;
|
|
17
|
+
invalidate(key: CacheKey): void;
|
|
18
|
+
clear(): void;
|
|
19
|
+
}
|
|
2
20
|
/**
|
|
3
21
|
* Default Suspense cache instance shared by all `useSuspense*` hooks.
|
|
4
22
|
*
|
|
@@ -7,9 +25,10 @@ import { Dotted, WithGlob } from '@yoltra/core';
|
|
|
7
25
|
*
|
|
8
26
|
* @public
|
|
9
27
|
*/
|
|
28
|
+
export type { SuspenseCache };
|
|
10
29
|
export declare const suspenseCache: SuspenseCache;
|
|
11
30
|
/**
|
|
12
|
-
* Options for
|
|
31
|
+
* Options for `useSuspenseAtomicProp`.
|
|
13
32
|
*
|
|
14
33
|
* @typeParam T - The resolved value type after loading.
|
|
15
34
|
* @typeParam S - Store state record.
|
|
@@ -103,7 +122,7 @@ export declare function useSuspenseAtomicProp<R extends string, S extends Record
|
|
|
103
122
|
property: string;
|
|
104
123
|
}, options: SuspenseAtomicPropOptions<T, S>): T;
|
|
105
124
|
/**
|
|
106
|
-
* Options for
|
|
125
|
+
* Options for `useSuspenseAtomicProps`.
|
|
107
126
|
*
|
|
108
127
|
* @typeParam T - The resolved value type after loading.
|
|
109
128
|
* @typeParam S - Store state record.
|
|
@@ -227,7 +246,7 @@ export declare function clearSuspenseCache(): void;
|
|
|
227
246
|
/**
|
|
228
247
|
* Call signature for the typed `useSuspenseAtomicProp` returned by `createHooks`.
|
|
229
248
|
*
|
|
230
|
-
* Identical in behaviour to the package-level
|
|
249
|
+
* Identical in behaviour to the package-level `useSuspenseAtomicProp`; the reducer union
|
|
231
250
|
* and state shape are fixed by the store the hooks were created for, so neither has to be
|
|
232
251
|
* supplied at the call site.
|
|
233
252
|
*
|
package/dist/types/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export { StoreContext } from './context/StoreContext.js';
|
|
|
5
5
|
export { StoreProvider } from './context/StoreProvider.js';
|
|
6
6
|
export { shallowEqual, useEmit, useEvent, useSelector, useStore } from './hooks/hooks.js';
|
|
7
7
|
export { clearSuspenseCache, invalidateAtomicProp, invalidateAtomicPropsByReducer, suspenseCache, } from './hooks/suspense.js';
|
|
8
|
+
export type { SuspenseCache } from './hooks/suspense.js';
|
|
8
9
|
export { createHooks } from './hooks/createHooks.js';
|
|
9
10
|
export type { UseAtomicProp, UseAtomicProps, UseEvent, YoltraHooks } from './hooks/createHooks.js';
|
|
10
11
|
export type { UseSuspenseAtomicProp, UseSuspenseAtomicProps } from './hooks/suspense.js';
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yoltra/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "React bindings for Yoltra",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Manu Ramirez <@pixerael>",
|
|
8
|
-
"email": "
|
|
8
|
+
"email": "opensource@yoltra.dev"
|
|
9
9
|
},
|
|
10
10
|
"maintainers": [],
|
|
11
11
|
"homepage": "https://yoltra.dev",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"node": ">=18.18"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"@yoltra/core": "^0.
|
|
43
|
+
"@yoltra/core": "^0.6.0",
|
|
44
44
|
"react": "^18 || ^19"
|
|
45
45
|
},
|
|
46
46
|
"peerDependenciesMeta": {
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"@types/node": "^24.0.12",
|
|
65
65
|
"@vitejs/plugin-react-swc": "^3.10.2",
|
|
66
66
|
"@vitejs/plugin-react": "^5.0.0",
|
|
67
|
-
"@vitest/coverage-v8": "3.2.
|
|
67
|
+
"@vitest/coverage-v8": "3.2.7",
|
|
68
68
|
"eslint-plugin-react-hooks": "^5.2.0",
|
|
69
69
|
"eslint-plugin-react-refresh": "^0.4.20",
|
|
70
70
|
"vite-plugin-banner": "0.8.1",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"jsdom": "^24.0.0",
|
|
74
74
|
"react-dom": "19.1.1",
|
|
75
75
|
"react": "19.1.1",
|
|
76
|
-
"rollup": "^4.
|
|
76
|
+
"rollup": "^4.62.4",
|
|
77
77
|
"typescript-eslint": "^8.35.1",
|
|
78
78
|
"typescript": "5.9.3",
|
|
79
79
|
"typedoc": "^0.28.13",
|
|
@@ -81,9 +81,9 @@
|
|
|
81
81
|
"typedoc-plugin-localization": "3.0.6",
|
|
82
82
|
"vite-plugin-dts": "^4.5.4",
|
|
83
83
|
"vite-tsconfig-paths": "^4.3.2",
|
|
84
|
-
"vite": "^7.
|
|
85
|
-
"vitest": "3.2.
|
|
86
|
-
"@yoltra/core": "0.
|
|
84
|
+
"vite": "^7.3.6",
|
|
85
|
+
"vitest": "3.2.7",
|
|
86
|
+
"@yoltra/core": "0.6.0"
|
|
87
87
|
},
|
|
88
88
|
"exports": {
|
|
89
89
|
".": {
|