@trakit/react 0.0.4 → 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/index.d.ts +1 -1
- package/package.json +4 -2
- package/trakit-react.min.js +2 -2
package/index.d.ts
CHANGED
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(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
|
|
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 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.
|
|
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};
|