@trakit/react 0.0.3 → 0.0.5
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/hooks/useConnection.d.ts +1 -1
- package/hooks/useSync.d.ts +1 -1
- package/index.d.ts +2 -2
- package/package.json +4 -2
- package/trakit-react.min.js +2 -2
package/hooks/useConnection.d.ts
CHANGED
|
@@ -37,5 +37,5 @@ export type UseConnectionResult = {
|
|
|
37
37
|
* It initializes the synchronizer, listens for connection and account events,
|
|
38
38
|
* and provides the current connection state and user/machine information.
|
|
39
39
|
*/
|
|
40
|
-
export
|
|
40
|
+
export declare function useConnection(restAddress?: URL | url | nothing, socketAddress?: URL | url | nothing): UseConnectionResult;
|
|
41
41
|
//# sourceMappingURL=useConnection.d.ts.map
|
package/hooks/useSync.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export interface UseSyncResult {
|
|
|
8
8
|
* Whether the hook is currently loading data. This will be `true` until the initial synchronization
|
|
9
9
|
* is complete, and may briefly become `true` again if the connection is lost and re-established.
|
|
10
10
|
*/
|
|
11
|
-
|
|
11
|
+
loading: boolean;
|
|
12
12
|
/**
|
|
13
13
|
* The list of replies received from the synchronization process.
|
|
14
14
|
* This is normally not needed, but can be useful for debugging or error handling,
|
package/index.d.ts
CHANGED
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
* Last updated on Thu June 11 2026 15:43:01
|
|
5
5
|
* @copyright Trak-iT Wireless Inc. 2026
|
|
6
6
|
*/
|
|
7
|
-
import useConnection,
|
|
7
|
+
import { useConnection, UseConnectionResult } from "./hooks/useConnection";
|
|
8
8
|
import useIsOnline from "./hooks/useIsOnline";
|
|
9
9
|
import { useSingle, useSync, UseSyncMultiple, UseSyncResult, UseSyncSingle } from "./hooks/useSync";
|
|
10
10
|
/**
|
|
11
11
|
* Version number for this release.
|
|
12
12
|
*/
|
|
13
|
-
export declare const version = "0.0.
|
|
13
|
+
export declare const version = "0.0.5";
|
|
14
14
|
/**
|
|
15
15
|
* Hooks
|
|
16
16
|
*/
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trakit/react",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.5",
|
|
5
5
|
"main": "./trakit-react.min.js",
|
|
6
6
|
"types": "./index.d.ts",
|
|
7
7
|
"scripts": {
|
|
@@ -39,6 +39,8 @@
|
|
|
39
39
|
"@trakit/objects": "^0.1.2",
|
|
40
40
|
"@trakit/sync": "^0.1.2",
|
|
41
41
|
"@types/react": "^19.2.17",
|
|
42
|
-
"react
|
|
42
|
+
"react": "19.2.3",
|
|
43
|
+
"react-cookie": "^8.0.1",
|
|
44
|
+
"react-dom": "19.2.3"
|
|
43
45
|
}
|
|
44
46
|
}
|
package/trakit-react.min.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
function n(n,e){function t(n){b(n.online)}function o(n){const{account:e}=n;e.user?.login&&e.expiry>new Date?(c(h,e.ghostId,{...x,expires:e.expiry}),j(e.ghostId||"")):u(h,x),z(e.user||null),e.machine?.key&&e.expiry>new Date?(c(
|
|
1
|
+
function n(n,e){function t(n){b(n.online)}function o(n){const{account:e}=n;e.user?.login&&e.expiry>new Date?(c(h,e.ghostId,{...x,expires:e.expiry}),j(e.ghostId||"")):u(h,x),z(e.user||null),e.machine?.key&&e.expiry>new Date?(c(y,e.machine.key,{...x,expires:e.expiry}),c(k,e.machine.secret,{...x,expires:e.expiry})):(u(y,x),u(k,x)),S(e.machine||null)}const i=d(new l(null,n||a.URI_PROD,e||f.URI_PROD)),[r,c,u]=g([h,y,k]),[w,b]=p(i.current.socketOnline),[I,j]=p(r[h]||""),[D,z]=p(i.current.account.user||null),[N,S]=p(i.current.account.machine||r[y]&&new s({key:r[y],secret:r[k]})||null),v=!(!I&&!N)==!(!i.current.account.user&&!i.current.account.machine);return m(()=>{i.current.on("open",t),i.current.on("error",t),i.current.on("close",t),i.current.on("account",o),(I||N)&&i.current.setAuth({ghostId:I,machine:N?.toJSON()})},[]),{synchronizer:i.current,ready:v,ghostId:I,online:w,user:D,machine:N}}function e(n){return window.addEventListener("online",n),window.addEventListener("offline",n),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",n)}}function t(){return navigator.onLine}function o(){return!0}function i(){return w(e,t,o)}function r(e,t){const o=d(null),i=d(0),[r,c]=p(null),[s,l]=p({}),{synchronizer:a,ready:w,online:g,user:h,machine:y}=n();return m(()=>{function n(n,o){0!==i.current&&t===o&&e.includes(n)&&l(e=>({...e,[n]:[...u[n].values().filter(n=>n.companyId===t)]}))}function s(e){const{kind:t,companyId:o}=e;n(t,o)}function d(e){const{name:t,body:o}=e;n(f.msgNameToSyncName(t),o.company)}function p(){if(0===i.current){const n=r?.map(n=>n.syncName).filter(n=>!!n);n?.length&&a.desync(t,n),a.off("list",s),a.off("update",s),a.off("delete",s),a.off("message",d)}o.current=null}function m(o){c(o),e.forEach(e=>n(e,t))}if(w&&e?.length&&!isNaN(t))return i.current++,a.on("list",s),a.on("update",s),a.on("delete",s),a.on("message",d),o.current=a.sync(t,e),o.current.then(m,m),o.current.finally(p),()=>{i.current--,o.current||p()}},[t=t??h?.companyId??y?.companyId,e.sort().join(",")]),{loading:!(w&&g&&Object.keys(s).length&&!o.current),replies:r??[],...s}}function c(n,e){const{loading:t,replies:o,[n]:i}=r([n],e);return{loading:t,replies:o,objects:i??[]}}
|
|
2
2
|
/**
|
|
3
3
|
* ReactJS library.
|
|
4
4
|
* {@link https://github.com/trakitwireless/trakit-ts-react|ReactJS controls.}
|
|
5
5
|
* Last updated on Thu June 11 2026 15:43:01
|
|
6
6
|
* @copyright Trak-iT Wireless Inc. 2026
|
|
7
|
-
*/import{Machine as s,storage as u}from"@trakit/objects";import{TrakitSyncCommander as
|
|
7
|
+
*/import{Machine as s,storage as u}from"@trakit/objects";import{TrakitSyncCommander as l,TrakitRestfulCommander as a,TrakitSocketCommander as f}from"@trakit/sync";import{useRef as d,useState as p,useEffect as m,useSyncExternalStore as w}from"react";import{useCookies as g}from"react-cookie";const h="ghostId",y="aK",k="aS",x={path:"/",secure:!0,sameSite:"strict",expires:new Date(0)},b="0.0.5";export{n as useConnection,i as useIsOnline,c as useSingle,r as useSync,b as version};
|