@trakit/react 0.0.10 → 0.0.11
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/useAudit.d.ts +22 -0
- package/index.d.ts +4 -3
- package/package.json +1 -1
- package/trakit-react.min.js +2 -2
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { RepSelfGet } from '@trakit/commands';
|
|
2
|
+
import { guid, Machine, nothing, url } from '@trakit/objects';
|
|
3
|
+
import { TrakitAuditCommander } from '@trakit/sync';
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @param account The account information used for authentication.
|
|
7
|
+
* @param baseAddress The base address of the audit service.
|
|
8
|
+
* @returns An object containing the auditor instance and its readiness state.
|
|
9
|
+
*/
|
|
10
|
+
export declare function useAudit(account?: RepSelfGet | {
|
|
11
|
+
machine: {
|
|
12
|
+
key: string;
|
|
13
|
+
};
|
|
14
|
+
} | Machine | {
|
|
15
|
+
key: string;
|
|
16
|
+
} | {
|
|
17
|
+
ghostId: guid;
|
|
18
|
+
} | guid | nothing, baseAddress?: URL | url | nothing): {
|
|
19
|
+
auditor: TrakitAuditCommander;
|
|
20
|
+
ready: boolean;
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=useAudit.d.ts.map
|
package/index.d.ts
CHANGED
|
@@ -5,18 +5,19 @@
|
|
|
5
5
|
* @copyright Trak-iT Wireless Inc. 2026
|
|
6
6
|
*/
|
|
7
7
|
import { ConnectionProvider, useConnection, type ConnectionContextType } from "./context/connectionContext";
|
|
8
|
+
import { useAudit } from "./hooks/useAudit";
|
|
8
9
|
import useIsOnline from "./hooks/useIsOnline";
|
|
9
10
|
import { useSingle, useSync, UseSyncMultiple, UseSyncResult, UseSyncSingle } from "./hooks/useSync";
|
|
10
11
|
/**
|
|
11
12
|
* Version number for this release.
|
|
12
13
|
*/
|
|
13
|
-
export declare const version = "0.0.
|
|
14
|
+
export declare const version = "0.0.11";
|
|
14
15
|
/**
|
|
15
16
|
* Hooks
|
|
16
17
|
*/
|
|
17
|
-
export { useConnection, useIsOnline, useSingle, useSync, type UseSyncMultiple, type UseSyncResult, type UseSyncSingle
|
|
18
|
+
export { useAudit, useConnection, useIsOnline, useSingle, useSync, type UseSyncMultiple, type UseSyncResult, type UseSyncSingle };
|
|
18
19
|
/**
|
|
19
20
|
* Context provider for connection state and synchronizer instance.
|
|
20
21
|
*/
|
|
21
|
-
export { ConnectionProvider, type ConnectionContextType
|
|
22
|
+
export { ConnectionProvider, type ConnectionContextType };
|
|
22
23
|
//# sourceMappingURL=index.d.ts.map
|
package/package.json
CHANGED
package/trakit-react.min.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
function n({children:n,restAddress:t,socketAddress:r}){return
|
|
1
|
+
function n({children:n,restAddress:t,socketAddress:r}){return d(I,{children:d(e,{restAddress:t,socketAddress:r,children:n})})}function e({children:n,restAddress:e,socketAddress:t}){function r(n){f(n.online)}function o(n){const{account:e}=n;e.user?.login&&e.expiry>new Date?(c(v,e.ghostId,{...C,expires:e.expiry}),g(e.ghostId||"")):u(v,C),b(e.user||null),e.machine?.key&&e.expiry>new Date?(c(D,e.machine.key,{...C,expires:e.expiry}),c(z,e.machine.secret,{...C,expires:e.expiry})):(u(D,C),u(z,C)),S(e.machine||null)}const i=y(new m(null,e||p.URI_PROD,t||w.URI_PROD)),[s,c,u]=j([v,D,z]),[l,f]=k(i.current.socketOnline),[h,g]=k(s[v]||""),[A,b]=k(i.current.account.user||null),[I,S]=k(i.current.account.machine||s[D]&&new a({key:s[D],secret:s[z]})||null),E=!(!h&&!I)==!(!i.current.account.user&&!i.current.account.machine);return x(()=>{i.current.on("open",r),i.current.on("error",r),i.current.on("close",r),i.current.on("account",o),(h||I)&&i.current.setAuth({ghostId:h,machine:I?.toJSON()})},[]),d(N,{value:{synchronizer:i.current,ready:E,ghostId:h,online:l,user:A,machine:I},children:n})}function t(){const n=A(N);if(!n)throw new Error("useConnection must be used within ConnectionProvider");return n}function r(n,e){const t=y(new h(null,e||h.URI_PROD)),r=!(!t.current.account.user&&!t.current.account.machine);return x(()=>t.current.setAuth(n),[n?.machine?.key||n?.user?.login||n?.key||n?.ghostId||n||null]),{auditor:t.current,ready:r}}function o(n){return window.addEventListener("online",n),window.addEventListener("offline",n),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",n)}}function i(){return navigator.onLine}function s(){return!0}function c(){return b(o,i,s)}function u(n,e){const r=y(null),o=y(0),[i,s]=k(null),[c,u]=k({}),{synchronizer:l,ready:d,online:a,user:m,machine:p}=t();return x(()=>{function t(t,r){0!==o.current&&e===r&&n.includes(t)&&u(n=>({...n,[t]:[...f[t].values().filter(n=>n.companyId===e)]}))}function c(n){const{kind:e,companyId:r}=n;t(e,r)}function a(n){const{name:e,body:r}=n;t(w.msgNameToSyncName(e),r.company)}function m(){if(0===o.current){const n=i?.map(n=>n.syncName).filter(n=>!!n);n?.length&&l.desync(e,n),l.off("list",c),l.off("update",c),l.off("delete",c),l.off("message",a)}r.current=null}function p(r){s(r),n.forEach(n=>t(n,e))}if(d&&n?.length&&!isNaN(e))return o.current++,l.on("list",c),l.on("update",c),l.on("delete",c),l.on("message",a),r.current=r.current||l.sync(e,n),r.current.then(p,p),r.current.finally(m),()=>{o.current--,r.current||m()}},[e=e??m?.companyId??p?.companyId,n.sort().join(",")]),{loading:!(d&&a&&i&&!r.current),replies:i??[],...c}}function l(n,e){const{loading:t,replies:r,[n]:o}=u([n],e);return{loading:t,replies:r,objects:o??[]}}
|
|
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{jsx as
|
|
7
|
+
*/import{jsx as d}from"react/jsx-runtime";import{Machine as a,storage as f}from"@trakit/objects";import{TrakitSyncCommander as m,TrakitRestfulCommander as p,TrakitSocketCommander as w,TrakitAuditCommander as h}from"@trakit/sync";import{createContext as g,useRef as y,useState as k,useEffect as x,useContext as A,useSyncExternalStore as b}from"react";import{CookiesProvider as I,useCookies as j}from"react-cookie";const v="ghostId",D="aK",z="aS",C={path:"/",secure:!0,sameSite:"strict",expires:new Date(0)},N=g(null),S="0.0.11";export{n as ConnectionProvider,r as useAudit,t as useConnection,c as useIsOnline,l as useSingle,u as useSync,S as version};
|