@tuwaio/pulsar-react 0.3.1 → 0.4.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/dist/index.d.mts +33 -23
- package/dist/index.d.ts +33 -23
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -1,38 +1,48 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @file
|
|
3
|
-
*
|
|
2
|
+
* @file React hook for bootstrapping the Pulsar transaction lifecycle on app start.
|
|
3
|
+
* It rehydrates pending transaction trackers and can optionally perform an initial
|
|
4
|
+
* remote history fetch right after tracker initialization.
|
|
4
5
|
*/
|
|
5
6
|
/**
|
|
6
|
-
*
|
|
7
|
+
* Configuration for {@link useInitializeTransactionsPool}.
|
|
8
|
+
*/
|
|
9
|
+
type UseInitializeTransactionsPoolParams = {
|
|
10
|
+
/**
|
|
11
|
+
* Re-initializes background trackers for all pending transactions stored in the Pulsar store.
|
|
12
|
+
*/
|
|
13
|
+
initializeTransactionsPool: () => Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Optional error handler called when initialization or the optional initial fetch fails.
|
|
16
|
+
*
|
|
17
|
+
* @defaultValue `console.error`
|
|
18
|
+
*/
|
|
19
|
+
onError?: (error: Error) => void;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Re-initializes pending transaction trackers when the component mounts.
|
|
7
23
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
|
|
11
|
-
* their trackers are re-activated.
|
|
24
|
+
* Use this hook once in your application's root layout or top-level provider.
|
|
25
|
+
* It restores tracker activity after reloads and can optionally fetch the initial
|
|
26
|
+
* remote transaction history right after restoration.
|
|
12
27
|
*
|
|
13
|
-
* @param
|
|
14
|
-
* @param
|
|
15
|
-
* @param
|
|
28
|
+
* @param params Hook configuration.
|
|
29
|
+
* @param params.initializeTransactionsPool Function that restores trackers for pending transactions.
|
|
30
|
+
* @param params.onError Optional custom error handler.
|
|
16
31
|
*
|
|
17
32
|
* @example
|
|
18
33
|
* ```tsx
|
|
19
34
|
* import { useInitializeTransactionsPool } from '@tuwaio/pulsar-react';
|
|
20
|
-
* import { pulsarStore } from './path/to/your/store';
|
|
21
35
|
*
|
|
22
|
-
* function AppLayout(
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* });
|
|
36
|
+
* function AppLayout() {
|
|
37
|
+
* useInitializeTransactionsPool({
|
|
38
|
+
* initializeTransactionsPool: store.getState().initializeTransactionsPool,
|
|
39
|
+
* onError: (error) => console.warn('Failed to restore transactions:', error),
|
|
40
|
+
* });
|
|
28
41
|
*
|
|
29
|
-
*
|
|
42
|
+
* return <div>...</div>;
|
|
30
43
|
* }
|
|
31
44
|
* ```
|
|
32
45
|
*/
|
|
33
|
-
declare const useInitializeTransactionsPool: ({ initializeTransactionsPool, onError, }:
|
|
34
|
-
initializeTransactionsPool: () => Promise<void>;
|
|
35
|
-
onError?: (error: Error) => void;
|
|
36
|
-
}) => void;
|
|
46
|
+
declare const useInitializeTransactionsPool: ({ initializeTransactionsPool, onError, }: UseInitializeTransactionsPoolParams) => void;
|
|
37
47
|
|
|
38
|
-
export { useInitializeTransactionsPool };
|
|
48
|
+
export { type UseInitializeTransactionsPoolParams, useInitializeTransactionsPool };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,38 +1,48 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @file
|
|
3
|
-
*
|
|
2
|
+
* @file React hook for bootstrapping the Pulsar transaction lifecycle on app start.
|
|
3
|
+
* It rehydrates pending transaction trackers and can optionally perform an initial
|
|
4
|
+
* remote history fetch right after tracker initialization.
|
|
4
5
|
*/
|
|
5
6
|
/**
|
|
6
|
-
*
|
|
7
|
+
* Configuration for {@link useInitializeTransactionsPool}.
|
|
8
|
+
*/
|
|
9
|
+
type UseInitializeTransactionsPoolParams = {
|
|
10
|
+
/**
|
|
11
|
+
* Re-initializes background trackers for all pending transactions stored in the Pulsar store.
|
|
12
|
+
*/
|
|
13
|
+
initializeTransactionsPool: () => Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Optional error handler called when initialization or the optional initial fetch fails.
|
|
16
|
+
*
|
|
17
|
+
* @defaultValue `console.error`
|
|
18
|
+
*/
|
|
19
|
+
onError?: (error: Error) => void;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Re-initializes pending transaction trackers when the component mounts.
|
|
7
23
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
|
|
11
|
-
* their trackers are re-activated.
|
|
24
|
+
* Use this hook once in your application's root layout or top-level provider.
|
|
25
|
+
* It restores tracker activity after reloads and can optionally fetch the initial
|
|
26
|
+
* remote transaction history right after restoration.
|
|
12
27
|
*
|
|
13
|
-
* @param
|
|
14
|
-
* @param
|
|
15
|
-
* @param
|
|
28
|
+
* @param params Hook configuration.
|
|
29
|
+
* @param params.initializeTransactionsPool Function that restores trackers for pending transactions.
|
|
30
|
+
* @param params.onError Optional custom error handler.
|
|
16
31
|
*
|
|
17
32
|
* @example
|
|
18
33
|
* ```tsx
|
|
19
34
|
* import { useInitializeTransactionsPool } from '@tuwaio/pulsar-react';
|
|
20
|
-
* import { pulsarStore } from './path/to/your/store';
|
|
21
35
|
*
|
|
22
|
-
* function AppLayout(
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* });
|
|
36
|
+
* function AppLayout() {
|
|
37
|
+
* useInitializeTransactionsPool({
|
|
38
|
+
* initializeTransactionsPool: store.getState().initializeTransactionsPool,
|
|
39
|
+
* onError: (error) => console.warn('Failed to restore transactions:', error),
|
|
40
|
+
* });
|
|
28
41
|
*
|
|
29
|
-
*
|
|
42
|
+
* return <div>...</div>;
|
|
30
43
|
* }
|
|
31
44
|
* ```
|
|
32
45
|
*/
|
|
33
|
-
declare const useInitializeTransactionsPool: ({ initializeTransactionsPool, onError, }:
|
|
34
|
-
initializeTransactionsPool: () => Promise<void>;
|
|
35
|
-
onError?: (error: Error) => void;
|
|
36
|
-
}) => void;
|
|
46
|
+
declare const useInitializeTransactionsPool: ({ initializeTransactionsPool, onError, }: UseInitializeTransactionsPoolParams) => void;
|
|
37
47
|
|
|
38
|
-
export { useInitializeTransactionsPool };
|
|
48
|
+
export { type UseInitializeTransactionsPoolParams, useInitializeTransactionsPool };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var react=require('react');var c=({initializeTransactionsPool:r,onError:o})=>{react.useEffect(()=>{(async()=>{try{await r()
|
|
1
|
+
'use strict';var react=require('react');var c=({initializeTransactionsPool:r,onError:o})=>{react.useEffect(()=>{let i=true;return (async()=>{try{if(await r(),!i)return}catch(a){(o??(t=>{console.error("[Pulsar] Failed to initialize transactions pool:",t);}))(a);}})(),()=>{i=false;}},[r,o]);};exports.useInitializeTransactionsPool=c;
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {useEffect}from'react';var c=({initializeTransactionsPool:r,onError:o})=>{useEffect(()=>{(async()=>{try{await r()
|
|
1
|
+
import {useEffect}from'react';var c=({initializeTransactionsPool:r,onError:o})=>{useEffect(()=>{let i=true;return (async()=>{try{if(await r(),!i)return}catch(a){(o??(t=>{console.error("[Pulsar] Failed to initialize transactions pool:",t);}))(a);}})(),()=>{i=false;}},[r,o]);};export{c as useInitializeTransactionsPool};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tuwaio/pulsar-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Oleksandr Tkach",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -41,10 +41,10 @@
|
|
|
41
41
|
"react": ">=19.2.3"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@types/react": "^19.2.
|
|
45
|
-
"react": "^19.2.
|
|
44
|
+
"@types/react": "^19.2.14",
|
|
45
|
+
"react": "^19.2.5",
|
|
46
46
|
"tsup": "^8.5.1",
|
|
47
|
-
"typescript": "^
|
|
47
|
+
"typescript": "^6.0.3"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"start": "tsup src/index.ts --watch",
|