@tuwaio/pulsar-react 1.0.0-fix-orbit-integration-alpha.3.86c8fdb → 1.0.0-fix-orbit-integration-alpha.4.bd24308
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 +1 -40
- package/dist/index.d.ts +1 -40
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,38 +1,3 @@
|
|
|
1
|
-
import { Transaction, ITxTrackingStore } from '@tuwaio/pulsar-core';
|
|
2
|
-
import React, { PropsWithChildren } from 'react';
|
|
3
|
-
import { StoreApi } from 'zustand';
|
|
4
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
|
-
import { PulsarAdapter, ITxTrackingStore as ITxTrackingStore$1 } from '@tuwaio/pulsar-core/src';
|
|
6
|
-
import { PersistOptions } from 'zustand/middleware';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Type alias for the core store state (ITxTrackingStore<TTransaction>).
|
|
10
|
-
*/
|
|
11
|
-
type PulsarStore<TTransaction extends Transaction> = ITxTrackingStore<TTransaction>;
|
|
12
|
-
interface BoundedUseStore<T extends Transaction> {
|
|
13
|
-
<TRet>(selector: (state: PulsarStore<T>) => TRet): TRet;
|
|
14
|
-
<TTransaction extends T, TRet>(selector: (state: PulsarStore<TTransaction>) => TRet): TRet;
|
|
15
|
-
}
|
|
16
|
-
declare const PulsarStoreBindings: {
|
|
17
|
-
usePulsarStore: BoundedUseStore<any>;
|
|
18
|
-
};
|
|
19
|
-
type StoreContext<T extends Transaction> = React.Context<StoreApi<PulsarStore<T>> | null>;
|
|
20
|
-
/**
|
|
21
|
-
* Factory function to create a unique React Context and a strictly typed Bounded Hook for a specific T.
|
|
22
|
-
*/
|
|
23
|
-
declare function createPulsarStoreContextAndHook<T extends Transaction>(): {
|
|
24
|
-
StoreContext: StoreContext<T>;
|
|
25
|
-
usePulsarStore: BoundedUseStore<T>;
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* Public hook to access the Pulsar Store.
|
|
29
|
-
* @template T The specific Transaction type (inferred from usage or specified).
|
|
30
|
-
* @template TSelected The type of the value returned by the selector (inferred).
|
|
31
|
-
* * NOTE: The T = Transaction default helps with base type hints, but the actual hook
|
|
32
|
-
* resolves T via the Provider-bound instance.
|
|
33
|
-
*/
|
|
34
|
-
declare function usePulsarStore<T extends Transaction = Transaction, TSelected = unknown>(selector: (state: PulsarStore<T>) => TSelected): TSelected;
|
|
35
|
-
|
|
36
1
|
/**
|
|
37
2
|
* @file This file defines a React hook for initializing the transaction pool.
|
|
38
3
|
* This hook is crucial for resuming the tracking of pending transactions after a page reload.
|
|
@@ -70,8 +35,4 @@ declare const useInitializeTransactionsPool: ({ initializeTransactionsPool, onEr
|
|
|
70
35
|
onError?: (error: Error) => void;
|
|
71
36
|
}) => void;
|
|
72
37
|
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
declare function PulsarCoreProvider<T extends Transaction>({ children, ...params }: PulsarCoreProviderProps<T>): react_jsx_runtime.JSX.Element;
|
|
76
|
-
|
|
77
|
-
export { type BoundedUseStore, PulsarCoreProvider, type PulsarStore, PulsarStoreBindings, type StoreContext, createPulsarStoreContextAndHook, useInitializeTransactionsPool, usePulsarStore };
|
|
38
|
+
export { useInitializeTransactionsPool };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,38 +1,3 @@
|
|
|
1
|
-
import { Transaction, ITxTrackingStore } from '@tuwaio/pulsar-core';
|
|
2
|
-
import React, { PropsWithChildren } from 'react';
|
|
3
|
-
import { StoreApi } from 'zustand';
|
|
4
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
|
-
import { PulsarAdapter, ITxTrackingStore as ITxTrackingStore$1 } from '@tuwaio/pulsar-core/src';
|
|
6
|
-
import { PersistOptions } from 'zustand/middleware';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Type alias for the core store state (ITxTrackingStore<TTransaction>).
|
|
10
|
-
*/
|
|
11
|
-
type PulsarStore<TTransaction extends Transaction> = ITxTrackingStore<TTransaction>;
|
|
12
|
-
interface BoundedUseStore<T extends Transaction> {
|
|
13
|
-
<TRet>(selector: (state: PulsarStore<T>) => TRet): TRet;
|
|
14
|
-
<TTransaction extends T, TRet>(selector: (state: PulsarStore<TTransaction>) => TRet): TRet;
|
|
15
|
-
}
|
|
16
|
-
declare const PulsarStoreBindings: {
|
|
17
|
-
usePulsarStore: BoundedUseStore<any>;
|
|
18
|
-
};
|
|
19
|
-
type StoreContext<T extends Transaction> = React.Context<StoreApi<PulsarStore<T>> | null>;
|
|
20
|
-
/**
|
|
21
|
-
* Factory function to create a unique React Context and a strictly typed Bounded Hook for a specific T.
|
|
22
|
-
*/
|
|
23
|
-
declare function createPulsarStoreContextAndHook<T extends Transaction>(): {
|
|
24
|
-
StoreContext: StoreContext<T>;
|
|
25
|
-
usePulsarStore: BoundedUseStore<T>;
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* Public hook to access the Pulsar Store.
|
|
29
|
-
* @template T The specific Transaction type (inferred from usage or specified).
|
|
30
|
-
* @template TSelected The type of the value returned by the selector (inferred).
|
|
31
|
-
* * NOTE: The T = Transaction default helps with base type hints, but the actual hook
|
|
32
|
-
* resolves T via the Provider-bound instance.
|
|
33
|
-
*/
|
|
34
|
-
declare function usePulsarStore<T extends Transaction = Transaction, TSelected = unknown>(selector: (state: PulsarStore<T>) => TSelected): TSelected;
|
|
35
|
-
|
|
36
1
|
/**
|
|
37
2
|
* @file This file defines a React hook for initializing the transaction pool.
|
|
38
3
|
* This hook is crucial for resuming the tracking of pending transactions after a page reload.
|
|
@@ -70,8 +35,4 @@ declare const useInitializeTransactionsPool: ({ initializeTransactionsPool, onEr
|
|
|
70
35
|
onError?: (error: Error) => void;
|
|
71
36
|
}) => void;
|
|
72
37
|
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
declare function PulsarCoreProvider<T extends Transaction>({ children, ...params }: PulsarCoreProviderProps<T>): react_jsx_runtime.JSX.Element;
|
|
76
|
-
|
|
77
|
-
export { type BoundedUseStore, PulsarCoreProvider, type PulsarStore, PulsarStoreBindings, type StoreContext, createPulsarStoreContextAndHook, useInitializeTransactionsPool, usePulsarStore };
|
|
38
|
+
export { useInitializeTransactionsPool };
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var react=require('react')
|
|
1
|
+
'use strict';var react=require('react');var c=({initializeTransactionsPool:r,onError:o})=>{react.useEffect(()=>{(async()=>{try{await r();}catch(e){(o??(i=>console.error("Failed to initialize transactions pool:",i)))(e);}})();},[r,o]);};exports.useInitializeTransactionsPool=c;//# sourceMappingURL=index.js.map
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hooks/
|
|
1
|
+
{"version":3,"sources":["../src/hooks/useInitializeTransactionsPool.tsx"],"names":["useInitializeTransactionsPool","initializeTransactionsPool","onError","useEffect","error","e"],"mappings":"4CAmCaA,CAAAA,CAAgC,CAAC,CAC5C,0BAAA,CAAAC,CAAAA,CACA,QAAAC,CACF,CAAA,GAGM,CACJC,eAAAA,CAAU,IAAM,EACe,SAAY,CACvC,GAAI,CACF,MAAMF,IACR,CAAA,MAASG,EAAO,CAAA,CACOF,CAAAA,GAAaG,GAAa,OAAA,CAAQ,KAAA,CAAM,0CAA2CA,CAAC,CAAA,CAAA,EAC5FD,CAAc,EAC7B,CACF,KAOF,CAAA,CAAG,CAACH,CAAAA,CAA4BC,CAAO,CAAC,EAC1C","file":"index.js","sourcesContent":["/**\n * @file This file defines a React hook for initializing the transaction pool.\n * This hook is crucial for resuming the tracking of pending transactions after a page reload.\n */\n\nimport { useEffect } from 'react';\n\n/**\n * A React hook that triggers the initialization of the transaction pool when the component mounts.\n *\n * This should be used once in your application's layout or root component. It ensures that any\n * pending transactions from a previous session (stored in `localStorage`) are picked up and\n\n * their trackers are re-activated.\n *\n * @param {object} params - The parameters for the hook.\n * @param {() => Promise<void>} params.initializeTransactionsPool - The `initializeTransactionsPool` function from your Pulsar store instance.\n * @param {(error: Error) => void} [params.onError] - An optional custom function to handle any errors that occur during initialization. Defaults to `console.error`.\n *\n * @example\n * ```tsx\n * import { useInitializeTransactionsPool } from '@tuwaio/pulsar-react';\n * import { pulsarStore } from './path/to/your/store';\n *\n * function AppLayout({ children }) {\n * // This hook will run once when the layout mounts.\n * useInitializeTransactionsPool({\n * initializeTransactionsPool: pulsarStore.getState().initializeTransactionsPool,\n * onError: (err) => console.warn('Failed to re-initialize trackers:', err),\n * });\n *\n * return <div>{children}</div>;\n * }\n * ```\n */\nexport const useInitializeTransactionsPool = ({\n initializeTransactionsPool,\n onError,\n}: {\n initializeTransactionsPool: () => Promise<void>;\n onError?: (error: Error) => void;\n}) => {\n useEffect(() => {\n const reinitializeTrackers = async () => {\n try {\n await initializeTransactionsPool();\n } catch (error) {\n const errorHandler = onError ?? ((e: Error) => console.error('Failed to initialize transactions pool:', e));\n errorHandler(error as Error);\n }\n };\n\n // Run the initialization process.\n reinitializeTrackers();\n\n // The dependency array is empty to ensure this effect runs only once on mount.\n // The functions from a vanilla Zustand store are stable and do not need to be in the array.\n }, [initializeTransactionsPool, onError]);\n};\n"]}
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {useEffect}from'react';var c=({initializeTransactionsPool:r,onError:o})=>{useEffect(()=>{(async()=>{try{await r();}catch(e){(o??(i=>console.error("Failed to initialize transactions pool:",i)))(e);}})();},[r,o]);};export{c as useInitializeTransactionsPool};//# sourceMappingURL=index.mjs.map
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hooks/
|
|
1
|
+
{"version":3,"sources":["../src/hooks/useInitializeTransactionsPool.tsx"],"names":["useInitializeTransactionsPool","initializeTransactionsPool","onError","useEffect","error","e"],"mappings":"kCAmCaA,CAAAA,CAAgC,CAAC,CAC5C,0BAAA,CAAAC,CAAAA,CACA,QAAAC,CACF,CAAA,GAGM,CACJC,SAAAA,CAAU,IAAM,EACe,SAAY,CACvC,GAAI,CACF,MAAMF,IACR,CAAA,MAASG,EAAO,CAAA,CACOF,CAAAA,GAAaG,GAAa,OAAA,CAAQ,KAAA,CAAM,0CAA2CA,CAAC,CAAA,CAAA,EAC5FD,CAAc,EAC7B,CACF,KAOF,CAAA,CAAG,CAACH,CAAAA,CAA4BC,CAAO,CAAC,EAC1C","file":"index.mjs","sourcesContent":["/**\n * @file This file defines a React hook for initializing the transaction pool.\n * This hook is crucial for resuming the tracking of pending transactions after a page reload.\n */\n\nimport { useEffect } from 'react';\n\n/**\n * A React hook that triggers the initialization of the transaction pool when the component mounts.\n *\n * This should be used once in your application's layout or root component. It ensures that any\n * pending transactions from a previous session (stored in `localStorage`) are picked up and\n\n * their trackers are re-activated.\n *\n * @param {object} params - The parameters for the hook.\n * @param {() => Promise<void>} params.initializeTransactionsPool - The `initializeTransactionsPool` function from your Pulsar store instance.\n * @param {(error: Error) => void} [params.onError] - An optional custom function to handle any errors that occur during initialization. Defaults to `console.error`.\n *\n * @example\n * ```tsx\n * import { useInitializeTransactionsPool } from '@tuwaio/pulsar-react';\n * import { pulsarStore } from './path/to/your/store';\n *\n * function AppLayout({ children }) {\n * // This hook will run once when the layout mounts.\n * useInitializeTransactionsPool({\n * initializeTransactionsPool: pulsarStore.getState().initializeTransactionsPool,\n * onError: (err) => console.warn('Failed to re-initialize trackers:', err),\n * });\n *\n * return <div>{children}</div>;\n * }\n * ```\n */\nexport const useInitializeTransactionsPool = ({\n initializeTransactionsPool,\n onError,\n}: {\n initializeTransactionsPool: () => Promise<void>;\n onError?: (error: Error) => void;\n}) => {\n useEffect(() => {\n const reinitializeTrackers = async () => {\n try {\n await initializeTransactionsPool();\n } catch (error) {\n const errorHandler = onError ?? ((e: Error) => console.error('Failed to initialize transactions pool:', e));\n errorHandler(error as Error);\n }\n };\n\n // Run the initialization process.\n reinitializeTrackers();\n\n // The dependency array is empty to ensure this effect runs only once on mount.\n // The functions from a vanilla Zustand store are stable and do not need to be in the array.\n }, [initializeTransactionsPool, onError]);\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tuwaio/pulsar-react",
|
|
3
|
-
"version": "1.0.0-fix-orbit-integration-alpha.
|
|
3
|
+
"version": "1.0.0-fix-orbit-integration-alpha.4.bd24308",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Oleksandr Tkach",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"tsup": "^8.5.0",
|
|
59
59
|
"typescript": "^5.9.2",
|
|
60
60
|
"zustand": "^5.0.8",
|
|
61
|
-
"@tuwaio/pulsar-core": "^1.0.0-fix-orbit-integration-alpha.
|
|
61
|
+
"@tuwaio/pulsar-core": "^1.0.0-fix-orbit-integration-alpha.4.bd24308"
|
|
62
62
|
},
|
|
63
63
|
"scripts": {
|
|
64
64
|
"start": "tsup src/index.ts --watch",
|