@obb871001/api-integration-sdk 1.0.40 → 1.0.41
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.cjs +4 -4
- package/dist/index.js +174 -174
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const M=require("react"),Ae=require("@tanstack/react-query"),et=require("axios"),Ce=require("lodash"),rt=require("react-dom");function tt(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Re={exports:{}},Ee={};var ir;function nt(){if(ir)return Ee;ir=1;var r=M,
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const M=require("react"),Ae=require("@tanstack/react-query"),et=require("axios"),Ce=require("lodash"),rt=require("react-dom");function tt(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Re={exports:{}},Ee={};var ir;function nt(){if(ir)return Ee;ir=1;var r=M,b=Symbol.for("react.element"),O=Symbol.for("react.fragment"),E=Object.prototype.hasOwnProperty,f=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,_={key:!0,ref:!0,__self:!0,__source:!0};function S(v,c,l){var u,a={},i=null,t=null;l!==void 0&&(i=""+l),c.key!==void 0&&(i=""+c.key),c.ref!==void 0&&(t=c.ref);for(u in c)E.call(c,u)&&!_.hasOwnProperty(u)&&(a[u]=c[u]);if(v&&v.defaultProps)for(u in c=v.defaultProps,c)a[u]===void 0&&(a[u]=c[u]);return{$$typeof:b,type:v,key:i,ref:t,props:a,_owner:f.current}}return Ee.Fragment=O,Ee.jsx=S,Ee.jsxs=S,Ee}var _e={};var sr;function at(){return sr||(sr=1,process.env.NODE_ENV!=="production"&&(function(){var r=M,b=Symbol.for("react.element"),O=Symbol.for("react.portal"),E=Symbol.for("react.fragment"),f=Symbol.for("react.strict_mode"),_=Symbol.for("react.profiler"),S=Symbol.for("react.provider"),v=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),l=Symbol.for("react.suspense"),u=Symbol.for("react.suspense_list"),a=Symbol.for("react.memo"),i=Symbol.for("react.lazy"),t=Symbol.for("react.offscreen"),n=Symbol.iterator,d="@@iterator";function h(e){if(e===null||typeof e!="object")return null;var s=n&&e[n]||e[d];return typeof s=="function"?s:null}var o=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function y(e){{for(var s=arguments.length,g=new Array(s>1?s-1:0),p=1;p<s;p++)g[p-1]=arguments[p];R("error",e,g)}}function R(e,s,g){{var p=o.ReactDebugCurrentFrame,w=p.getStackAddendum();w!==""&&(s+="%s",g=g.concat([w]));var k=g.map(function(C){return String(C)});k.unshift("Warning: "+s),Function.prototype.apply.call(console[e],console,k)}}var P=!1,T=!1,A=!1,I=!1,le=!1,fe;fe=Symbol.for("react.module.reference");function ke(e){return!!(typeof e=="string"||typeof e=="function"||e===E||e===_||le||e===f||e===l||e===u||I||e===t||P||T||A||typeof e=="object"&&e!==null&&(e.$$typeof===i||e.$$typeof===a||e.$$typeof===S||e.$$typeof===v||e.$$typeof===c||e.$$typeof===fe||e.getModuleId!==void 0))}function be(e,s,g){var p=e.displayName;if(p)return p;var w=s.displayName||s.name||"";return w!==""?g+"("+w+")":g}function H(e){return e.displayName||"Context"}function j(e){if(e==null)return null;if(typeof e.tag=="number"&&y("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case E:return"Fragment";case O:return"Portal";case _:return"Profiler";case f:return"StrictMode";case l:return"Suspense";case u:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case v:var s=e;return H(s)+".Consumer";case S:var g=e;return H(g._context)+".Provider";case c:return be(e,e.render,"ForwardRef");case a:var p=e.displayName||null;return p!==null?p:j(e.type)||"Memo";case i:{var w=e,k=w._payload,C=w._init;try{return j(C(k))}catch{return null}}}return null}var J=Object.assign,Z=0,B,ye,ge,L,U,Y,de;function ee(){}ee.__reactDisabledLog=!0;function X(){{if(Z===0){B=console.log,ye=console.info,ge=console.warn,L=console.error,U=console.group,Y=console.groupCollapsed,de=console.groupEnd;var e={configurable:!0,enumerable:!0,value:ee,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}Z++}}function Oe(){{if(Z--,Z===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:J({},e,{value:B}),info:J({},e,{value:ye}),warn:J({},e,{value:ge}),error:J({},e,{value:L}),group:J({},e,{value:U}),groupCollapsed:J({},e,{value:Y}),groupEnd:J({},e,{value:de})})}Z<0&&y("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var oe=o.ReactCurrentDispatcher,K;function ce(e,s,g){{if(K===void 0)try{throw Error()}catch(w){var p=w.stack.trim().match(/\n( *(at )?)/);K=p&&p[1]||""}return`
|
|
2
2
|
`+K+e}}var re=!1,pe;{var Pr=typeof WeakMap=="function"?WeakMap:Map;pe=new Pr}function Ye(e,s){if(!e||re)return"";{var g=pe.get(e);if(g!==void 0)return g}var p;re=!0;var w=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var k;k=oe.current,oe.current=null,X();try{if(s){var C=function(){throw Error()};if(Object.defineProperty(C.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(C,[])}catch(F){p=F}Reflect.construct(e,[],C)}else{try{C.call()}catch(F){p=F}e.call(C.prototype)}}else{try{throw Error()}catch(F){p=F}e()}}catch(F){if(F&&p&&typeof F.stack=="string"){for(var m=F.stack.split(`
|
|
3
3
|
`),W=p.stack.split(`
|
|
4
4
|
`),N=m.length-1,D=W.length-1;N>=1&&D>=0&&m[N]!==W[D];)D--;for(;N>=1&&D>=0;N--,D--)if(m[N]!==W[D]){if(N!==1||D!==1)do if(N--,D--,D<0||m[N]!==W[D]){var G=`
|
|
5
|
-
`+m[N].replace(" at new "," at ");return e.displayName&&G.includes("<anonymous>")&&(G=G.replace("<anonymous>",e.displayName)),typeof e=="function"&&pe.set(e,G),G}while(N>=1&&D>=0);break}}}finally{re=!1,oe.current=k,Oe(),Error.prepareStackTrace=w}var se=e?e.displayName||e.name:"",te=se?ce(se):"";return typeof e=="function"&&pe.set(e,te),te}function kr(e,s,g){return Ye(e,!1)}function Ir(e){var s=e.prototype;return!!(s&&s.isReactComponent)}function Te(e,s,g){if(e==null)return"";if(typeof e=="function")return Ye(e,Ir(e));if(typeof e=="string")return ce(e);switch(e){case l:return ce("Suspense");case u:return ce("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case c:return kr(e.render);case a:return Te(e.type,s,g);case i:{var p=e,w=p._payload,k=p._init;try{return Te(k(w),s,g)}catch{}}}return""}var
|
|
5
|
+
`+m[N].replace(" at new "," at ");return e.displayName&&G.includes("<anonymous>")&&(G=G.replace("<anonymous>",e.displayName)),typeof e=="function"&&pe.set(e,G),G}while(N>=1&&D>=0);break}}}finally{re=!1,oe.current=k,Oe(),Error.prepareStackTrace=w}var se=e?e.displayName||e.name:"",te=se?ce(se):"";return typeof e=="function"&&pe.set(e,te),te}function kr(e,s,g){return Ye(e,!1)}function Ir(e){var s=e.prototype;return!!(s&&s.isReactComponent)}function Te(e,s,g){if(e==null)return"";if(typeof e=="function")return Ye(e,Ir(e));if(typeof e=="string")return ce(e);switch(e){case l:return ce("Suspense");case u:return ce("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case c:return kr(e.render);case a:return Te(e.type,s,g);case i:{var p=e,w=p._payload,k=p._init;try{return Te(k(w),s,g)}catch{}}}return""}var ve=Object.prototype.hasOwnProperty,Ke={},xe=o.ReactDebugCurrentFrame;function me(e){if(e){var s=e._owner,g=Te(e.type,e._source,s?s.type:null);xe.setExtraStackFrame(g)}else xe.setExtraStackFrame(null)}function Nr(e,s,g,p,w){{var k=Function.call.bind(ve);for(var C in e)if(k(e,C)){var m=void 0;try{if(typeof e[C]!="function"){var W=Error((p||"React class")+": "+g+" type `"+C+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[C]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw W.name="Invariant Violation",W}m=e[C](s,C,p,g,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(N){m=N}m&&!(m instanceof Error)&&(me(w),y("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",p||"React class",g,C,typeof m),me(null)),m instanceof Error&&!(m.message in Ke)&&(Ke[m.message]=!0,me(w),y("Failed %s type: %s",g,m.message),me(null))}}}var Mr=Array.isArray;function Ie(e){return Mr(e)}function Dr(e){{var s=typeof Symbol=="function"&&Symbol.toStringTag,g=s&&e[Symbol.toStringTag]||e.constructor.name||"Object";return g}}function Lr(e){try{return Qe(e),!1}catch{return!0}}function Qe(e){return""+e}function ze(e){if(Lr(e))return y("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Dr(e)),Qe(e)}var Xe=o.ReactCurrentOwner,jr={key:!0,ref:!0,__self:!0,__source:!0},Ze,er;function Ur(e){if(ve.call(e,"ref")){var s=Object.getOwnPropertyDescriptor(e,"ref").get;if(s&&s.isReactWarning)return!1}return e.ref!==void 0}function Wr(e){if(ve.call(e,"key")){var s=Object.getOwnPropertyDescriptor(e,"key").get;if(s&&s.isReactWarning)return!1}return e.key!==void 0}function Fr(e,s){typeof e.ref=="string"&&Xe.current}function qr(e,s){{var g=function(){Ze||(Ze=!0,y("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",s))};g.isReactWarning=!0,Object.defineProperty(e,"key",{get:g,configurable:!0})}}function Gr(e,s){{var g=function(){er||(er=!0,y("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",s))};g.isReactWarning=!0,Object.defineProperty(e,"ref",{get:g,configurable:!0})}}var Jr=function(e,s,g,p,w,k,C){var m={$$typeof:b,type:e,key:s,ref:g,props:C,_owner:k};return m._store={},Object.defineProperty(m._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(m,"_self",{configurable:!1,enumerable:!1,writable:!1,value:p}),Object.defineProperty(m,"_source",{configurable:!1,enumerable:!1,writable:!1,value:w}),Object.freeze&&(Object.freeze(m.props),Object.freeze(m)),m};function Hr(e,s,g,p,w){{var k,C={},m=null,W=null;g!==void 0&&(ze(g),m=""+g),Wr(s)&&(ze(s.key),m=""+s.key),Ur(s)&&(W=s.ref,Fr(s,w));for(k in s)ve.call(s,k)&&!jr.hasOwnProperty(k)&&(C[k]=s[k]);if(e&&e.defaultProps){var N=e.defaultProps;for(k in N)C[k]===void 0&&(C[k]=N[k])}if(m||W){var D=typeof e=="function"?e.displayName||e.name||"Unknown":e;m&&qr(C,D),W&&Gr(C,D)}return Jr(e,m,W,w,p,Xe.current,C)}}var Ne=o.ReactCurrentOwner,rr=o.ReactDebugCurrentFrame;function ie(e){if(e){var s=e._owner,g=Te(e.type,e._source,s?s.type:null);rr.setExtraStackFrame(g)}else rr.setExtraStackFrame(null)}var Me;Me=!1;function De(e){return typeof e=="object"&&e!==null&&e.$$typeof===b}function tr(){{if(Ne.current){var e=j(Ne.current.type);if(e)return`
|
|
6
6
|
|
|
7
7
|
Check the render method of \``+e+"`."}return""}}function Vr(e){return""}var nr={};function $r(e){{var s=tr();if(!s){var g=typeof e=="string"?e:e.displayName||e.name;g&&(s=`
|
|
8
8
|
|
|
9
|
-
Check the top-level render call using <`+g+">.")}return s}}function ar(e,s){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var g=$r(s);if(nr[g])return;nr[g]=!0;var p="";e&&e._owner&&e._owner!==Ne.current&&(p=" It was passed a child from "+j(e._owner.type)+"."),ie(e),
|
|
9
|
+
Check the top-level render call using <`+g+">.")}return s}}function ar(e,s){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var g=$r(s);if(nr[g])return;nr[g]=!0;var p="";e&&e._owner&&e._owner!==Ne.current&&(p=" It was passed a child from "+j(e._owner.type)+"."),ie(e),y('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',g,p),ie(null)}}function ur(e,s){{if(typeof e!="object")return;if(Ie(e))for(var g=0;g<e.length;g++){var p=e[g];De(p)&&ar(p,s)}else if(De(e))e._store&&(e._store.validated=!0);else if(e){var w=h(e);if(typeof w=="function"&&w!==e.entries)for(var k=w.call(e),C;!(C=k.next()).done;)De(C.value)&&ar(C.value,s)}}}function Br(e){{var s=e.type;if(s==null||typeof s=="string")return;var g;if(typeof s=="function")g=s.propTypes;else if(typeof s=="object"&&(s.$$typeof===c||s.$$typeof===a))g=s.propTypes;else return;if(g){var p=j(s);Nr(g,e.props,"prop",p,e)}else if(s.PropTypes!==void 0&&!Me){Me=!0;var w=j(s);y("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",w||"Unknown")}typeof s.getDefaultProps=="function"&&!s.getDefaultProps.isReactClassApproved&&y("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Yr(e){{for(var s=Object.keys(e.props),g=0;g<s.length;g++){var p=s[g];if(p!=="children"&&p!=="key"){ie(e),y("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",p),ie(null);break}}e.ref!==null&&(ie(e),y("Invalid attribute `ref` supplied to `React.Fragment`."),ie(null))}}var or={};function cr(e,s,g,p,w,k){{var C=ke(e);if(!C){var m="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(m+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var W=Vr();W?m+=W:m+=tr();var N;e===null?N="null":Ie(e)?N="array":e!==void 0&&e.$$typeof===b?(N="<"+(j(e.type)||"Unknown")+" />",m=" Did you accidentally export a JSX literal instead of a component?"):N=typeof e,y("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",N,m)}var D=Hr(e,s,g,w,k);if(D==null)return D;if(C){var G=s.children;if(G!==void 0)if(p)if(Ie(G)){for(var se=0;se<G.length;se++)ur(G[se],e);Object.freeze&&Object.freeze(G)}else y("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else ur(G,e)}if(ve.call(s,"key")){var te=j(e),F=Object.keys(s).filter(function(Zr){return Zr!=="key"}),Le=F.length>0?"{key: someKey, "+F.join(": ..., ")+": ...}":"{key: someKey}";if(!or[te+Le]){var Xr=F.length>0?"{"+F.join(": ..., ")+": ...}":"{}";y(`A props object containing a "key" prop is being spread into JSX:
|
|
10
10
|
let props = %s;
|
|
11
11
|
<%s {...props} />
|
|
12
12
|
React keys must be passed directly to JSX without using spread:
|
|
13
13
|
let props = %s;
|
|
14
|
-
<%s key={someKey} {...props} />`,Le,te,Xr,te),or[te+Le]=!0}}return e===d?Yr(D):Br(D),D}}function Kr(e,s,g){return cr(e,s,g,!0)}function xr(e,s,g){return cr(e,s,g,!1)}var Qr=xr,zr=Kr;_e.Fragment=d,_e.jsx=Qr,_e.jsxs=zr})()),_e}var lr;function ut(){return lr||(lr=1,process.env.NODE_ENV==="production"?Re.exports=nt():Re.exports=at()),Re.exports}var fr=ut();const Ge=M.createContext(null),Pe=()=>{const r=M.useContext(Ge);if(!r)throw new Error("useApiContext must be used within ApiProvider");return r};function ot({baseURL:r,getToken:y,timeoutMs:O=15e3,currency:d="TWD",lng:f="tw",onError:_}={}){const S=et.create({baseURL:r,timeout:O,headers:{"Content-Type":"application/json"}});return S.interceptors.request.use(async E=>{if(E.headers=E.headers||{},y){const c=await y();c&&(E.headers.Authorization=`Bearer ${c}`)}return E.headers.Currency=d,E.headers["currency-code"]=d,E.headers.lang=f,E}),S.interceptors.response.use(E=>E.data,E=>_?_(E,{instance:S}):Promise.reject(E)),S}function ct({children:r,...y}){const O=M.useMemo(()=>ot(y),[y]),f=M.useMemo(()=>new Ae.QueryClient({defaultOptions:{queries:{refetchOnWindowFocus:!1,retry:1}}}),[]);return fr.jsx(Ae.QueryClientProvider,{client:f,children:fr.jsx(Ge.Provider,{value:{client:O,...y},children:r})})}const it=()=>{const r=(d,f)=>!d&&!f,y=d=>d.startsWith("pc.");return{executeLogout:({isCallBackInvalid:d=!1,hostname:f="",shouldRedirect:_,onShowError:S,onCleanup:E,onRemoveToken:c,onRedirect:l,onGoogleLogout:u})=>{const a=y(f);r(d,a)&&S?.(),E?.(),c?.(),_&&l?.("/"),u?.()},shouldShowErrorNotice:r,isMachineDomain:y}},wr=()=>{const{client:r}=Pe(),y=M.useCallback(async S=>{const{mac_address:E="",app_version:c="",anydesk_id:l=""}=S,{data:u}=await r.post("/cash-register/login",{mac_address:E,app_version:c,anydesk_id:l});return u},[r]),O=M.useCallback(async()=>r.get("/member/getMemberInfo"),[r]),d=M.useCallback(async()=>{const{data:S}=await r.get("/getGameList");return S},[r]),f=M.useCallback(async()=>{const{data:S}=await r.get("/getNowCurrencyExchange");return S},[r]),_=M.useCallback(async()=>{const{data:S}=await r.get("/getFavoriteGame");return S},[r]);return{machineLoginApi:y,userInfoApi:O,userGameListApi:d,userFavoriteGameApi:_,userCurrencyExchangeApi:f}},st=({otherQueryKey:r=[],options:y={}})=>{const{userCurrencyExchange:O}=wr(),{getToken:d}=Pe();return Ae.useQueries({queryKey:["getBalance",...r],queries:[{queryKey:["userCurrencyExchange"],queryFn:()=>O()}],enabled:!!d,...y})};var je={},q={},Ue={},vr;function $(){return vr||(vr=1,(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.isEventSourceSupported=r.isReactNative=r.ReadyState=r.DEFAULT_HEARTBEAT=r.UNPARSABLE_JSON_OBJECT=r.DEFAULT_RECONNECT_INTERVAL_MS=r.DEFAULT_RECONNECT_LIMIT=r.SOCKET_IO_PING_CODE=r.SOCKET_IO_PATH=r.SOCKET_IO_PING_INTERVAL=r.DEFAULT_EVENT_SOURCE_OPTIONS=r.EMPTY_EVENT_HANDLERS=r.DEFAULT_OPTIONS=void 0;var y=1,O=1e3*y;r.DEFAULT_OPTIONS={},r.EMPTY_EVENT_HANDLERS={},r.DEFAULT_EVENT_SOURCE_OPTIONS={withCredentials:!1,events:r.EMPTY_EVENT_HANDLERS},r.SOCKET_IO_PING_INTERVAL=25*O,r.SOCKET_IO_PATH="/socket.io/?EIO=3&transport=websocket",r.SOCKET_IO_PING_CODE="2",r.DEFAULT_RECONNECT_LIMIT=20,r.DEFAULT_RECONNECT_INTERVAL_MS=5e3,r.UNPARSABLE_JSON_OBJECT={},r.DEFAULT_HEARTBEAT={message:"ping",timeout:6e4,interval:25e3};var d;(function(_){_[_.UNINSTANTIATED=-1]="UNINSTANTIATED",_[_.CONNECTING=0]="CONNECTING",_[_.OPEN=1]="OPEN",_[_.CLOSING=2]="CLOSING",_[_.CLOSED=3]="CLOSED"})(d||(r.ReadyState=d={}));var f=function(){try{return"EventSource"in globalThis}catch{return!1}};r.isReactNative=typeof navigator<"u"&&navigator.product==="ReactNative",r.isEventSourceSupported=!r.isReactNative&&f()})(Ue)),Ue}var Se={},We={},dr;function Je(){return dr||(dr=1,(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.resetWebSockets=r.sharedWebSockets=void 0,r.sharedWebSockets={};var y=function(O){if(O&&r.sharedWebSockets.hasOwnProperty(O))delete r.sharedWebSockets[O];else for(var d in r.sharedWebSockets)r.sharedWebSockets.hasOwnProperty(d)&&delete r.sharedWebSockets[d]};r.resetWebSockets=y})(We)),We}var ne={},x={},Er;function He(){if(Er)return x;Er=1,Object.defineProperty(x,"__esModule",{value:!0}),x.setUpSocketIOPing=x.appendQueryParams=x.parseSocketIOUrl=void 0;var r=$(),y=function(f){if(f){var _=/^https|wss/.test(f),S=f.replace(/^(https?|wss?)(:\/\/)?/,""),E=S.replace(/\/$/,""),c=_?"wss":"ws";return"".concat(c,"://").concat(E).concat(r.SOCKET_IO_PATH)}else if(f===""){var _=/^https/.test(window.location.protocol),c=_?"wss":"ws",l=window.location.port?":".concat(window.location.port):"";return"".concat(c,"://").concat(window.location.hostname).concat(l).concat(r.SOCKET_IO_PATH)}return f};x.parseSocketIOUrl=y;var O=function(f,_){_===void 0&&(_={});var S=/\?([\w]+=[\w]+)/,E=S.test(f),c="".concat(Object.entries(_).reduce(function(l,u){var a=u[0],i=u[1];return l+"".concat(a,"=").concat(i,"&")},"").slice(0,-1));return"".concat(f).concat(E?"&":"?").concat(c)};x.appendQueryParams=O;var d=function(f,_){_===void 0&&(_=r.SOCKET_IO_PING_INTERVAL);var S=function(){return f(r.SOCKET_IO_PING_CODE)};return window.setInterval(S,_)};return x.setUpSocketIOPing=d,x}var we={},_r;function Ar(){if(_r)return we;_r=1,Object.defineProperty(we,"__esModule",{value:!0}),we.heartbeat=O;var r=$();function y(d){return Array.isArray(d)?d.reduce(function(f,_){return f.current>_.current?f:_}).current:d.current}function O(d,f,_){var S=_||{},E=S.interval,c=E===void 0?r.DEFAULT_HEARTBEAT.interval:E,l=S.timeout,u=l===void 0?r.DEFAULT_HEARTBEAT.timeout:l,a=S.message,i=a===void 0?r.DEFAULT_HEARTBEAT.message:a,t=Math.max(100,c/10),n=Date.now(),v=setInterval(function(){var h=Date.now(),o=y(f);if(o+u<=h)console.warn("Heartbeat timed out, closing connection, last message received ".concat(h-o,"ms ago, last ping sent ").concat(h-n,"ms ago")),d.close();else if(o+c<=h&&n+c<=h)try{typeof i=="function"?d.send(i()):d.send(i),n=h}catch(b){console.error("Heartbeat failed, closing connection",b instanceof Error?b.message:b),d.close()}},t);return d.addEventListener("close",function(){clearInterval(v)}),function(){}}return we}var he={},Fe={},Sr;function Ve(){return Sr||(Sr=1,(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.resetSubscribers=r.removeSubscriber=r.addSubscriber=r.hasSubscribers=r.getSubscribers=void 0;var y={},O=[],d=function(c){return(0,r.hasSubscribers)(c)?Array.from(y[c]):O};r.getSubscribers=d;var f=function(c){var l;return((l=y[c])===null||l===void 0?void 0:l.size)>0};r.hasSubscribers=f;var _=function(c,l){y[c]=y[c]||new Set,y[c].add(l)};r.addSubscriber=_;var S=function(c,l){y[c].delete(l)};r.removeSubscriber=S;var E=function(c){if(c&&y.hasOwnProperty(c))delete y[c];else for(var l in y)y.hasOwnProperty(l)&&delete y[l]};r.resetSubscribers=E})(Fe)),Fe}var hr;function $e(){if(hr)return he;hr=1,Object.defineProperty(he,"__esModule",{value:!0}),he.assertIsWebSocket=O,he.resetGlobalState=d;var r=Je(),y=Ve();function O(f,_){if(!_&&!(f instanceof WebSocket))throw new Error("")}function d(f){(0,y.resetSubscribers)(f),(0,r.resetWebSockets)(f)}return he}var yr;function lt(){if(yr)return ne;yr=1;var r=ne&&ne.__assign||function(){return r=Object.assign||function(u){for(var a,i=1,t=arguments.length;i<t;i++){a=arguments[i];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(u[n]=a[n])}return u},r.apply(this,arguments)};Object.defineProperty(ne,"__esModule",{value:!0}),ne.attachListeners=void 0;var y=He(),O=Ar(),d=$(),f=$e(),_=function(u,a,i,t){u.onmessage=function(n){var v;a.current.onMessage&&a.current.onMessage(n),typeof t?.current=="number"&&(t.current=Date.now()),!(typeof a.current.filter=="function"&&a.current.filter(n)!==!0)&&(a.current.heartbeat&&typeof a.current.heartbeat!="boolean"&&((v=a.current.heartbeat)===null||v===void 0?void 0:v.returnMessage)===n.data||i(n))}},S=function(u,a,i,t,n){u.onopen=function(v){if(a.current.onOpen&&a.current.onOpen(v),t.current=0,i(d.ReadyState.OPEN),a.current.heartbeat&&u instanceof WebSocket){var h=typeof a.current.heartbeat=="boolean"?void 0:a.current.heartbeat;n.current=Date.now(),(0,O.heartbeat)(u,n,h)}}},E=function(u,a,i,t,n){if(d.isEventSourceSupported&&u instanceof EventSource)return function(){};(0,f.assertIsWebSocket)(u,a.current.skipAssert);var v;return u.onclose=function(h){var o;if(a.current.onClose&&a.current.onClose(h),i(d.ReadyState.CLOSED),a.current.shouldReconnect&&a.current.shouldReconnect(h)){var b=(o=a.current.reconnectAttempts)!==null&&o!==void 0?o:d.DEFAULT_RECONNECT_LIMIT;if(n.current<b){var R=typeof a.current.reconnectInterval=="function"?a.current.reconnectInterval(n.current):a.current.reconnectInterval;v=window.setTimeout(function(){n.current++,t()},R??d.DEFAULT_RECONNECT_INTERVAL_MS)}else a.current.onReconnectStop&&a.current.onReconnectStop(b),console.warn("Max reconnect attempts of ".concat(b," exceeded"))}},function(){return v&&window.clearTimeout(v)}},c=function(u,a,i,t,n){var v;return u.onerror=function(h){var o;if(a.current.onError&&a.current.onError(h),d.isEventSourceSupported&&u instanceof EventSource&&(a.current.onClose&&a.current.onClose(r(r({},h),{code:1006,reason:"An error occurred with the EventSource: ".concat(h),wasClean:!1})),i(d.ReadyState.CLOSED),u.close()),a.current.retryOnError)if(n.current<((o=a.current.reconnectAttempts)!==null&&o!==void 0?o:d.DEFAULT_RECONNECT_LIMIT)){var b=typeof a.current.reconnectInterval=="function"?a.current.reconnectInterval(n.current):a.current.reconnectInterval;v=window.setTimeout(function(){n.current++,t()},b??d.DEFAULT_RECONNECT_INTERVAL_MS)}else a.current.onReconnectStop&&a.current.onReconnectStop(a.current.reconnectAttempts),console.warn("Max reconnect attempts of ".concat(a.current.reconnectAttempts," exceeded"))},function(){return v&&window.clearTimeout(v)}},l=function(u,a,i,t,n,v,h){var o=a.setLastMessage,b=a.setReadyState,R,P,T;return i.current.fromSocketIO&&(R=(0,y.setUpSocketIOPing)(h)),_(u,i,o,v),S(u,i,b,n,v),P=E(u,i,b,t,n),T=c(u,i,b,t,n),function(){b(d.ReadyState.CLOSING),P(),T(),u.close(),R&&clearInterval(R)}};return ne.attachListeners=l,ne}var ae={},br;function ft(){if(br)return ae;br=1;var r=ae&&ae.__assign||function(){return r=Object.assign||function(a){for(var i,t=1,n=arguments.length;t<n;t++){i=arguments[t];for(var v in i)Object.prototype.hasOwnProperty.call(i,v)&&(a[v]=i[v])}return a},r.apply(this,arguments)};Object.defineProperty(ae,"__esModule",{value:!0}),ae.attachSharedListeners=void 0;var y=Je(),O=$(),d=Ve(),f=He(),_=Ar(),S=function(a,i,t){a.onmessage=function(n){(0,d.getSubscribers)(i).forEach(function(v){var h;v.optionsRef.current.onMessage&&v.optionsRef.current.onMessage(n),typeof((h=v?.lastMessageTime)===null||h===void 0?void 0:h.current)=="number"&&(v.lastMessageTime.current=Date.now()),!(typeof v.optionsRef.current.filter=="function"&&v.optionsRef.current.filter(n)!==!0)&&(t&&typeof t!="boolean"&&t?.returnMessage===n.data||v.setLastMessage(n))})}},E=function(a,i,t){a.onopen=function(n){var v=(0,d.getSubscribers)(i);v.forEach(function(h){h.reconnectCount.current=0,h.optionsRef.current.onOpen&&h.optionsRef.current.onOpen(n),h.setReadyState(O.ReadyState.OPEN),t&&a instanceof WebSocket&&(h.lastMessageTime.current=Date.now())}),t&&a instanceof WebSocket&&(0,_.heartbeat)(a,v.map(function(h){return h.lastMessageTime}),typeof t=="boolean"?void 0:t)}},c=function(a,i){a instanceof WebSocket&&(a.onclose=function(t){(0,d.getSubscribers)(i).forEach(function(n){n.optionsRef.current.onClose&&n.optionsRef.current.onClose(t),n.setReadyState(O.ReadyState.CLOSED)}),delete y.sharedWebSockets[i],(0,d.getSubscribers)(i).forEach(function(n){var v;if(n.optionsRef.current.shouldReconnect&&n.optionsRef.current.shouldReconnect(t)){var h=(v=n.optionsRef.current.reconnectAttempts)!==null&&v!==void 0?v:O.DEFAULT_RECONNECT_LIMIT;if(n.reconnectCount.current<h){var o=typeof n.optionsRef.current.reconnectInterval=="function"?n.optionsRef.current.reconnectInterval(n.reconnectCount.current):n.optionsRef.current.reconnectInterval;setTimeout(function(){n.reconnectCount.current++,n.reconnect.current()},o??O.DEFAULT_RECONNECT_INTERVAL_MS)}else n.optionsRef.current.onReconnectStop&&n.optionsRef.current.onReconnectStop(n.optionsRef.current.reconnectAttempts),console.warn("Max reconnect attempts of ".concat(h," exceeded"))}})})},l=function(a,i){a.onerror=function(t){(0,d.getSubscribers)(i).forEach(function(n){n.optionsRef.current.onError&&n.optionsRef.current.onError(t),O.isEventSourceSupported&&a instanceof EventSource&&(n.optionsRef.current.onClose&&n.optionsRef.current.onClose(r(r({},t),{code:1006,reason:"An error occurred with the EventSource: ".concat(t),wasClean:!1})),n.setReadyState(O.ReadyState.CLOSED))}),O.isEventSourceSupported&&a instanceof EventSource&&a.close()}},u=function(a,i,t,n){var v;return t.current.fromSocketIO&&(v=(0,f.setUpSocketIOPing)(n)),S(a,i,t.current.heartbeat),c(a,i),E(a,i,t.current.heartbeat),l(a,i),function(){v&&clearInterval(v)}};return ae.attachSharedListeners=u,ae}var gr;function vt(){if(gr)return Se;gr=1,Object.defineProperty(Se,"__esModule",{value:!0}),Se.createOrJoinSocket=void 0;var r=Je(),y=$(),O=lt(),d=ft(),f=Ve(),_=function(E,c,l,u,a){return function(){if((0,f.removeSubscriber)(E,c),!(0,f.hasSubscribers)(E)){try{var i=r.sharedWebSockets[E];i instanceof WebSocket&&(i.onclose=function(t){l.current.onClose&&l.current.onClose(t),u(y.ReadyState.CLOSED)}),i.close()}catch{}a&&a(),delete r.sharedWebSockets[E]}}},S=function(E,c,l,u,a,i,t,n,v){if(!y.isEventSourceSupported&&u.current.eventSourceOptions)throw y.isReactNative?new Error("EventSource is not supported in ReactNative"):new Error("EventSource is not supported");if(u.current.share){var h=null;r.sharedWebSockets[c]===void 0?(r.sharedWebSockets[c]=u.current.eventSourceOptions?new EventSource(c,u.current.eventSourceOptions):new WebSocket(c,u.current.protocols),E.current=r.sharedWebSockets[c],l(y.ReadyState.CONNECTING),h=(0,d.attachSharedListeners)(r.sharedWebSockets[c],c,u,v)):(E.current=r.sharedWebSockets[c],l(r.sharedWebSockets[c].readyState));var o={setLastMessage:a,setReadyState:l,optionsRef:u,reconnectCount:t,lastMessageTime:n,reconnect:i};return(0,f.addSubscriber)(c,o),_(c,o,u,l,h)}else{if(E.current=u.current.eventSourceOptions?new EventSource(c,u.current.eventSourceOptions):new WebSocket(c,u.current.protocols),l(y.ReadyState.CONNECTING),!E.current)throw new Error("WebSocket failed to be created");return(0,O.attachListeners)(E.current,{setLastMessage:a,setReadyState:l},u,i.current,t,n,v)}};return Se.createOrJoinSocket=S,Se}var Q={},Or;function dt(){return Or||(Or=1,(function(r){var y=Q&&Q.__awaiter||function(c,l,u,a){function i(t){return t instanceof u?t:new u(function(n){n(t)})}return new(u||(u=Promise))(function(t,n){function v(b){try{o(a.next(b))}catch(R){n(R)}}function h(b){try{o(a.throw(b))}catch(R){n(R)}}function o(b){b.done?t(b.value):i(b.value).then(v,h)}o((a=a.apply(c,l||[])).next())})},O=Q&&Q.__generator||function(c,l){var u={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},a,i,t,n=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return n.next=v(0),n.throw=v(1),n.return=v(2),typeof Symbol=="function"&&(n[Symbol.iterator]=function(){return this}),n;function v(o){return function(b){return h([o,b])}}function h(o){if(a)throw new TypeError("Generator is already executing.");for(;n&&(n=0,o[0]&&(u=0)),u;)try{if(a=1,i&&(t=o[0]&2?i.return:o[0]?i.throw||((t=i.return)&&t.call(i),0):i.next)&&!(t=t.call(i,o[1])).done)return t;switch(i=0,t&&(o=[o[0]&2,t.value]),o[0]){case 0:case 1:t=o;break;case 4:return u.label++,{value:o[1],done:!1};case 5:u.label++,i=o[1],o=[0];continue;case 7:o=u.ops.pop(),u.trys.pop();continue;default:if(t=u.trys,!(t=t.length>0&&t[t.length-1])&&(o[0]===6||o[0]===2)){u=0;continue}if(o[0]===3&&(!t||o[1]>t[0]&&o[1]<t[3])){u.label=o[1];break}if(o[0]===6&&u.label<t[1]){u.label=t[1],t=o;break}if(t&&u.label<t[2]){u.label=t[2],u.ops.push(o);break}t[2]&&u.ops.pop(),u.trys.pop();continue}o=l.call(c,u)}catch(b){o=[6,b],i=0}finally{a=t=0}if(o[0]&5)throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}},d=Q&&Q.__spreadArray||function(c,l,u){if(u||arguments.length===2)for(var a=0,i=l.length,t;a<i;a++)(t||!(a in l))&&(t||(t=Array.prototype.slice.call(l,0,a)),t[a]=l[a]);return c.concat(t||Array.prototype.slice.call(l))};Object.defineProperty(r,"__esModule",{value:!0}),r.getUrl=void 0;var f=He(),_=$(),S=function(c){return new Promise(function(l){return window.setTimeout(l,c)})},E=function(c,l){for(var u=[],a=2;a<arguments.length;a++)u[a-2]=arguments[a];return y(void 0,d([c,l],u,!0),void 0,function(i,t,n){var v,h,o,b,R,P,T,A;return n===void 0&&(n=0),O(this,function(I){switch(I.label){case 0:if(typeof i!="function")return[3,10];I.label=1;case 1:return I.trys.push([1,3,,9]),[4,i()];case 2:return v=I.sent(),[3,9];case 3:return I.sent(),t.current.retryOnError?(h=(P=t.current.reconnectAttempts)!==null&&P!==void 0?P:_.DEFAULT_RECONNECT_LIMIT,n<h?(o=typeof t.current.reconnectInterval=="function"?t.current.reconnectInterval(n):t.current.reconnectInterval,[4,S(o??_.DEFAULT_RECONNECT_INTERVAL_MS)]):[3,5]):[3,7];case 4:return I.sent(),[2,(0,r.getUrl)(i,t,n+1)];case 5:return(A=(T=t.current).onReconnectStop)===null||A===void 0||A.call(T,n),[2,null];case 6:return[3,8];case 7:return[2,null];case 8:return[3,9];case 9:return[3,11];case 10:v=i,I.label=11;case 11:return b=t.current.fromSocketIO?(0,f.parseSocketIOUrl)(v):v,R=t.current.queryParams?(0,f.appendQueryParams)(b,t.current.queryParams):b,[2,R]}})})};r.getUrl=E})(Q)),Q}var qe={},pr;function Et(){return pr||(pr=1,(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.websocketWrapper=void 0;var y=function(O,d){return new Proxy(O,{get:function(f,_){var S=f[_];return _==="reconnect"?d:typeof S=="function"?(console.error("Calling methods directly on the websocket is not supported at this moment. You must use the methods returned by useWebSocket."),function(){}):S},set:function(f,_,S){return/^on/.test(_)?(console.warn("The websocket's event handlers should be defined through the options object passed into useWebSocket."),!1):(f[_]=S,!0)}})};r.websocketWrapper=y,r.default=r.websocketWrapper})(qe)),qe}var Tr;function Be(){if(Tr)return q;Tr=1;var r=q&&q.__assign||function(){return r=Object.assign||function(i){for(var t,n=1,v=arguments.length;n<v;n++){t=arguments[n];for(var h in t)Object.prototype.hasOwnProperty.call(t,h)&&(i[h]=t[h])}return i},r.apply(this,arguments)},y=q&&q.__awaiter||function(i,t,n,v){function h(o){return o instanceof n?o:new n(function(b){b(o)})}return new(n||(n=Promise))(function(o,b){function R(A){try{T(v.next(A))}catch(I){b(I)}}function P(A){try{T(v.throw(A))}catch(I){b(I)}}function T(A){A.done?o(A.value):h(A.value).then(R,P)}T((v=v.apply(i,t||[])).next())})},O=q&&q.__generator||function(i,t){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},v,h,o,b=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return b.next=R(0),b.throw=R(1),b.return=R(2),typeof Symbol=="function"&&(b[Symbol.iterator]=function(){return this}),b;function R(T){return function(A){return P([T,A])}}function P(T){if(v)throw new TypeError("Generator is already executing.");for(;b&&(b=0,T[0]&&(n=0)),n;)try{if(v=1,h&&(o=T[0]&2?h.return:T[0]?h.throw||((o=h.return)&&o.call(h),0):h.next)&&!(o=o.call(h,T[1])).done)return o;switch(h=0,o&&(T=[T[0]&2,o.value]),T[0]){case 0:case 1:o=T;break;case 4:return n.label++,{value:T[1],done:!1};case 5:n.label++,h=T[1],T=[0];continue;case 7:T=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(T[0]===6||T[0]===2)){n=0;continue}if(T[0]===3&&(!o||T[1]>o[0]&&T[1]<o[3])){n.label=T[1];break}if(T[0]===6&&n.label<o[1]){n.label=o[1],o=T;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(T);break}o[2]&&n.ops.pop(),n.trys.pop();continue}T=t.call(i,n)}catch(A){T=[6,A],h=0}finally{v=o=0}if(T[0]&5)throw T[1];return{value:T[0]?T[1]:void 0,done:!0}}},d=q&&q.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(q,"__esModule",{value:!0}),q.useWebSocket=void 0;var f=M,_=rt,S=$(),E=vt(),c=dt(),l=d(Et()),u=$e(),a=function(i,t,n){t===void 0&&(t=S.DEFAULT_OPTIONS),n===void 0&&(n=!0);var v=(0,f.useState)(null),h=v[0],o=v[1],b=(0,f.useState)({}),R=b[0],P=b[1],T=(0,f.useMemo)(function(){if(!t.disableJson&&h)try{return JSON.parse(h.data)}catch{return S.UNPARSABLE_JSON_OBJECT}return null},[h,t.disableJson]),A=(0,f.useRef)(null),I=(0,f.useRef)(null),le=(0,f.useRef)(function(){}),fe=(0,f.useRef)(0),ke=(0,f.useRef)(Date.now()),ye=(0,f.useRef)([]),H=(0,f.useRef)(null),j=(0,f.useRef)(t);j.current=t;var J=A.current&&R[A.current]!==void 0?R[A.current]:i!==null&&n===!0?S.ReadyState.CONNECTING:S.ReadyState.UNINSTANTIATED,Z=t.queryParams?JSON.stringify(t.queryParams):null,B=(0,f.useCallback)(function(L,U){var Y;if(U===void 0&&(U=!0),S.isEventSourceSupported&&I.current instanceof EventSource){console.warn("Unable to send a message from an eventSource");return}((Y=I.current)===null||Y===void 0?void 0:Y.readyState)===S.ReadyState.OPEN?((0,u.assertIsWebSocket)(I.current,j.current.skipAssert),I.current.send(L)):U&&ye.current.push(L)},[]),be=(0,f.useCallback)(function(L,U){U===void 0&&(U=!0),B(JSON.stringify(L),U)},[B]),ge=(0,f.useCallback)(function(){return j.current.share!==!0||S.isEventSourceSupported&&I.current instanceof EventSource?I.current:(H.current===null&&I.current&&((0,u.assertIsWebSocket)(I.current,j.current.skipAssert),H.current=(0,l.default)(I.current,le)),H.current)},[]);return(0,f.useEffect)(function(){if(i!==null&&n===!0){var L,U=!1,Y=!0,ve=function(){return y(void 0,void 0,void 0,function(){var ee,X,Oe;return O(this,function(oe){switch(oe.label){case 0:return ee=A,[4,(0,c.getUrl)(i,j)];case 1:return ee.current=oe.sent(),A.current===null?(console.error("Failed to get a valid URL. WebSocket connection aborted."),A.current="ABORTED",(0,_.flushSync)(function(){return P(function(K){return r(r({},K),{ABORTED:S.ReadyState.CLOSED})})}),[2]):(X=function(K){U||(0,_.flushSync)(function(){return o(K)})},Oe=function(K){U||(0,_.flushSync)(function(){return P(function(ce){var re;return r(r({},ce),A.current&&(re={},re[A.current]=K,re))})})},Y&&(L=(0,E.createOrJoinSocket)(I,A.current,Oe,j,X,le,fe,ke,B)),[2])}})})};return le.current=function(){U||(H.current&&(H.current=null),L?.(),ve())},ve(),function(){U=!0,Y=!1,H.current&&(H.current=null),L?.(),o(null)}}else(i===null||n===!1)&&(fe.current=0,P(function(ee){var X;return r(r({},ee),A.current&&(X={},X[A.current]=S.ReadyState.CLOSED,X))}))},[i,n,Z,B]),(0,f.useEffect)(function(){J===S.ReadyState.OPEN&&ye.current.splice(0).forEach(function(L){B(L)})},[J]),{sendMessage:B,sendJsonMessage:be,lastMessage:h,lastJsonMessage:T,readyState:J,getWebSocket:ge}};return q.useWebSocket=a,q}var ue={},mr;function _t(){if(mr)return ue;mr=1;var r=ue&&ue.__assign||function(){return r=Object.assign||function(E){for(var c,l=1,u=arguments.length;l<u;l++){c=arguments[l];for(var a in c)Object.prototype.hasOwnProperty.call(c,a)&&(E[a]=c[a])}return E},r.apply(this,arguments)};Object.defineProperty(ue,"__esModule",{value:!0}),ue.useSocketIO=void 0;var y=M,O=Be(),d=$(),f={type:"empty",payload:null},_=function(E){if(!E||!E.data)return f;var c=E.data.match(/\[.*]/);if(!c)return f;var l=JSON.parse(c);return!Array.isArray(l)||!l[1]?f:{type:l[0],payload:l[1]}},S=function(E,c,l){c===void 0&&(c=d.DEFAULT_OPTIONS),l===void 0&&(l=!0);var u=(0,y.useMemo)(function(){return r(r({},c),{fromSocketIO:!0})},[]),a=(0,O.useWebSocket)(E,u,l),i=a.sendMessage,t=a.sendJsonMessage,n=a.lastMessage,v=a.readyState,h=a.getWebSocket,o=(0,y.useMemo)(function(){return _(n)},[n]);return{sendMessage:i,sendJsonMessage:t,lastMessage:o,lastJsonMessage:o,readyState:v,getWebSocket:h}};return ue.useSocketIO=S,ue}var z={},Cr;function St(){if(Cr)return z;Cr=1;var r=z&&z.__assign||function(){return r=Object.assign||function(S){for(var E,c=1,l=arguments.length;c<l;c++){E=arguments[c];for(var u in E)Object.prototype.hasOwnProperty.call(E,u)&&(S[u]=E[u])}return S},r.apply(this,arguments)},y=z&&z.__rest||function(S,E){var c={};for(var l in S)Object.prototype.hasOwnProperty.call(S,l)&&E.indexOf(l)<0&&(c[l]=S[l]);if(S!=null&&typeof Object.getOwnPropertySymbols=="function")for(var u=0,l=Object.getOwnPropertySymbols(S);u<l.length;u++)E.indexOf(l[u])<0&&Object.prototype.propertyIsEnumerable.call(S,l[u])&&(c[l[u]]=S[l[u]]);return c};Object.defineProperty(z,"__esModule",{value:!0}),z.useEventSource=void 0;var O=M,d=Be(),f=$(),_=function(S,E,c){E===void 0&&(E=f.DEFAULT_EVENT_SOURCE_OPTIONS);var l=E.withCredentials,u=E.events,a=y(E,["withCredentials","events"]);c===void 0&&(c=!0);var i=r(r({},a),{eventSourceOptions:{withCredentials:l}}),t=(0,O.useRef)(f.EMPTY_EVENT_HANDLERS);u&&(t.current=u);var n=(0,d.useWebSocket)(S,i,c),v=n.lastMessage,h=n.readyState,o=n.getWebSocket;return(0,O.useEffect)(function(){v?.type&&Object.entries(t.current).forEach(function(b){var R=b[0],P=b[1];R===v.type&&P(v)})},[v]),{lastEvent:v,readyState:h,getEventSource:o}};return z.useEventSource=_,z}var Rr;function ht(){return Rr||(Rr=1,(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.resetGlobalState=r.useEventSource=r.ReadyState=r.useSocketIO=r.default=void 0;var y=Be();Object.defineProperty(r,"default",{enumerable:!0,get:function(){return y.useWebSocket}});var O=_t();Object.defineProperty(r,"useSocketIO",{enumerable:!0,get:function(){return O.useSocketIO}});var d=$();Object.defineProperty(r,"ReadyState",{enumerable:!0,get:function(){return d.ReadyState}});var f=St();Object.defineProperty(r,"useEventSource",{enumerable:!0,get:function(){return f.useEventSource}});var _=$e();Object.defineProperty(r,"resetGlobalState",{enumerable:!0,get:function(){return _.resetGlobalState}})})(je)),je}var yt=ht();const bt=tt(yt),V={DEPOSIT:"deposit",TRANS_CODE:"transCode",ERROR:"error",UPDATE_MEMBER:"update_member",MAINTAIN_NOTICE:"maintain_notice",MAINTAIN_NOTICE_MEMBER:"maintain_notice_member",RELOAD:"reload",TRANSFER_IN_GAME:"transfer_in_game",CHECK_REQUEST:"CHECK_RREQUEST",CASH_REGISTER_LIMIT:"cash_register_limit"},gt=3e4,Ot=({socketUrl:r,socketHandlers:y={},options:O={}})=>{const d=M.useRef(!1),f=M.useRef(y),{sendMessage:_,sendJsonMessage:S,lastMessage:E,readyState:c}=bt(r,{queryParams:{key:"wsky"},onOpen:()=>console.log("連線成功"),shouldReconnect:()=>d.current===!1,reconnectAttempts:9999,reconnectInterval:1e3,...O}),l=M.useMemo(()=>{try{return JSON.parse(E?.data)}catch{return null}},[E?.data]);return M.useEffect(()=>{const u=setInterval(()=>_("ping"),gt);return()=>clearInterval(u)},[_]),M.useEffect(()=>{f.current=y},[y]),M.useEffect(()=>{if(!l)return;const{onDeposit:u,onTransCode:a,onError:i,onUpdateMember:t,onMaintainNotice:n,onMaintainNoticeMember:v,onReload:h,onTransferInGame:o,onCashRegisterLimit:b}=f.current,R=Ce.get(l,"type",""),P={memberInfoUid:Ce.get(l,"member_info_uid",null),data:Ce.get(l,"data",null),memo:Ce.get(l,"memo",null)};switch(R){case V.DEPOSIT:u?.(P);break;case V.TRANS_CODE:a?.(P);break;case V.ERROR:i?.(P);break;case V.UPDATE_MEMBER:t?.(P);break;case V.MAINTAIN_NOTICE:n?.(P);break;case V.MAINTAIN_NOTICE_MEMBER:v?.(P);break;case V.RELOAD:h?.(P);break;case V.TRANSFER_IN_GAME:case V.CHECK_REQUEST:o?.(P);break;case V.CASH_REGISTER_LIMIT:b?.(P);break;default:console.warn("Unknown socket type:",R);break}},[l]),M.useEffect(()=>()=>d.current=!0,[]),{sendMessage:_,sendJsonMessage:S,readyState:c}},pt=()=>{const{getToken:r}=Pe(),{userInfoApi:y}=wr(),O=Ae.useQueries({queries:[{queryKey:["getMemberInfo"],queryFn:async()=>await y(),refetchInterval:5e4}],enabled:!!r}),{data:d,isFetching:f,error:_}=O[0]||{};return{data:d,isFetching:f,error:_}};exports.ApiCtx=Ge;exports.ApiProvider=ct;exports.createLogoutHandler=it;exports.useApiContext=Pe;exports.useBalanceGetter=st;exports.useClientWebSocket=Ot;exports.usePeriodicDataUpdater=pt;
|
|
14
|
+
<%s key={someKey} {...props} />`,Le,te,Xr,te),or[te+Le]=!0}}return e===E?Yr(D):Br(D),D}}function Kr(e,s,g){return cr(e,s,g,!0)}function xr(e,s,g){return cr(e,s,g,!1)}var Qr=xr,zr=Kr;_e.Fragment=E,_e.jsx=Qr,_e.jsxs=zr})()),_e}var lr;function ut(){return lr||(lr=1,process.env.NODE_ENV==="production"?Re.exports=nt():Re.exports=at()),Re.exports}var fr=ut();const Ge=M.createContext(null),Pe=()=>{const r=M.useContext(Ge);if(!r)throw new Error("useApiContext must be used within ApiProvider");return r};function ot({baseURL:r,getToken:b,timeoutMs:O=15e3,currency:E="TWD",lng:f="tw",onError:_}={}){const S=et.create({baseURL:r,timeout:O,headers:{"Content-Type":"application/json"}});return S.interceptors.request.use(async v=>{if(v.headers=v.headers||{},b){const c=await b();c&&(v.headers.Authorization=`Bearer ${c}`)}return v.headers.Currency=E,v.headers["currency-code"]=E,v.headers.lang=f,v}),S.interceptors.response.use(v=>v.data,v=>_?_(v,{instance:S}):Promise.reject(v)),S}function ct({children:r,...b}){const O=M.useMemo(()=>ot(b),[b]),f=M.useMemo(()=>new Ae.QueryClient({defaultOptions:{queries:{refetchOnWindowFocus:!1,retry:1}}}),[]);return fr.jsx(Ae.QueryClientProvider,{client:f,children:fr.jsx(Ge.Provider,{value:{client:O,...b},children:r})})}const it=()=>{const r=(E,f)=>!E&&!f,b=E=>E.startsWith("pc.");return{executeLogout:({isCallBackInvalid:E=!1,hostname:f="",shouldRedirect:_,onShowError:S,onCleanup:v,onRemoveToken:c,onRedirect:l,onGoogleLogout:u})=>{const a=b(f);r(E,a)&&S?.(),v?.(),c?.(),_&&l?.("/"),u?.()},shouldShowErrorNotice:r,isMachineDomain:b}},wr=()=>{const{client:r}=Pe(),b=M.useCallback(async S=>{const{mac_address:v="",app_version:c="",anydesk_id:l=""}=S,{data:u}=await r.post("/cash-register/login",{mac_address:v,app_version:c,anydesk_id:l});return u},[r]),O=M.useCallback(async()=>r.get("/member/getMemberInfo"),[r]),E=M.useCallback(async()=>{const{data:S}=await r.get("/getGameList");return S},[r]),f=M.useCallback(async()=>{const{data:S}=await r.get("/getNowCurrencyExchange");return S},[r]),_=M.useCallback(async()=>{const{data:S}=await r.get("/getFavoriteGame");return S},[r]);return{machineLoginApi:b,userInfoApi:O,userGameListApi:E,userFavoriteGameApi:_,userCurrencyExchangeApi:f}},st=({otherQueryKey:r=[],options:b={}})=>{const{userCurrencyExchangeApi:O}=wr(),{getToken:E}=Pe(),{enabled:f,..._}=b,S=!!E&&f.every(v=>v);return Ae.useQueries({queries:[{queryKey:["userCurrencyExchange",...r],queryFn:()=>O(),enabled:S,..._}]})};var je={},q={},Ue={},dr;function $(){return dr||(dr=1,(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.isEventSourceSupported=r.isReactNative=r.ReadyState=r.DEFAULT_HEARTBEAT=r.UNPARSABLE_JSON_OBJECT=r.DEFAULT_RECONNECT_INTERVAL_MS=r.DEFAULT_RECONNECT_LIMIT=r.SOCKET_IO_PING_CODE=r.SOCKET_IO_PATH=r.SOCKET_IO_PING_INTERVAL=r.DEFAULT_EVENT_SOURCE_OPTIONS=r.EMPTY_EVENT_HANDLERS=r.DEFAULT_OPTIONS=void 0;var b=1,O=1e3*b;r.DEFAULT_OPTIONS={},r.EMPTY_EVENT_HANDLERS={},r.DEFAULT_EVENT_SOURCE_OPTIONS={withCredentials:!1,events:r.EMPTY_EVENT_HANDLERS},r.SOCKET_IO_PING_INTERVAL=25*O,r.SOCKET_IO_PATH="/socket.io/?EIO=3&transport=websocket",r.SOCKET_IO_PING_CODE="2",r.DEFAULT_RECONNECT_LIMIT=20,r.DEFAULT_RECONNECT_INTERVAL_MS=5e3,r.UNPARSABLE_JSON_OBJECT={},r.DEFAULT_HEARTBEAT={message:"ping",timeout:6e4,interval:25e3};var E;(function(_){_[_.UNINSTANTIATED=-1]="UNINSTANTIATED",_[_.CONNECTING=0]="CONNECTING",_[_.OPEN=1]="OPEN",_[_.CLOSING=2]="CLOSING",_[_.CLOSED=3]="CLOSED"})(E||(r.ReadyState=E={}));var f=function(){try{return"EventSource"in globalThis}catch{return!1}};r.isReactNative=typeof navigator<"u"&&navigator.product==="ReactNative",r.isEventSourceSupported=!r.isReactNative&&f()})(Ue)),Ue}var Se={},We={},vr;function Je(){return vr||(vr=1,(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.resetWebSockets=r.sharedWebSockets=void 0,r.sharedWebSockets={};var b=function(O){if(O&&r.sharedWebSockets.hasOwnProperty(O))delete r.sharedWebSockets[O];else for(var E in r.sharedWebSockets)r.sharedWebSockets.hasOwnProperty(E)&&delete r.sharedWebSockets[E]};r.resetWebSockets=b})(We)),We}var ne={},x={},Er;function He(){if(Er)return x;Er=1,Object.defineProperty(x,"__esModule",{value:!0}),x.setUpSocketIOPing=x.appendQueryParams=x.parseSocketIOUrl=void 0;var r=$(),b=function(f){if(f){var _=/^https|wss/.test(f),S=f.replace(/^(https?|wss?)(:\/\/)?/,""),v=S.replace(/\/$/,""),c=_?"wss":"ws";return"".concat(c,"://").concat(v).concat(r.SOCKET_IO_PATH)}else if(f===""){var _=/^https/.test(window.location.protocol),c=_?"wss":"ws",l=window.location.port?":".concat(window.location.port):"";return"".concat(c,"://").concat(window.location.hostname).concat(l).concat(r.SOCKET_IO_PATH)}return f};x.parseSocketIOUrl=b;var O=function(f,_){_===void 0&&(_={});var S=/\?([\w]+=[\w]+)/,v=S.test(f),c="".concat(Object.entries(_).reduce(function(l,u){var a=u[0],i=u[1];return l+"".concat(a,"=").concat(i,"&")},"").slice(0,-1));return"".concat(f).concat(v?"&":"?").concat(c)};x.appendQueryParams=O;var E=function(f,_){_===void 0&&(_=r.SOCKET_IO_PING_INTERVAL);var S=function(){return f(r.SOCKET_IO_PING_CODE)};return window.setInterval(S,_)};return x.setUpSocketIOPing=E,x}var we={},_r;function Ar(){if(_r)return we;_r=1,Object.defineProperty(we,"__esModule",{value:!0}),we.heartbeat=O;var r=$();function b(E){return Array.isArray(E)?E.reduce(function(f,_){return f.current>_.current?f:_}).current:E.current}function O(E,f,_){var S=_||{},v=S.interval,c=v===void 0?r.DEFAULT_HEARTBEAT.interval:v,l=S.timeout,u=l===void 0?r.DEFAULT_HEARTBEAT.timeout:l,a=S.message,i=a===void 0?r.DEFAULT_HEARTBEAT.message:a,t=Math.max(100,c/10),n=Date.now(),d=setInterval(function(){var h=Date.now(),o=b(f);if(o+u<=h)console.warn("Heartbeat timed out, closing connection, last message received ".concat(h-o,"ms ago, last ping sent ").concat(h-n,"ms ago")),E.close();else if(o+c<=h&&n+c<=h)try{typeof i=="function"?E.send(i()):E.send(i),n=h}catch(y){console.error("Heartbeat failed, closing connection",y instanceof Error?y.message:y),E.close()}},t);return E.addEventListener("close",function(){clearInterval(d)}),function(){}}return we}var he={},Fe={},Sr;function Ve(){return Sr||(Sr=1,(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.resetSubscribers=r.removeSubscriber=r.addSubscriber=r.hasSubscribers=r.getSubscribers=void 0;var b={},O=[],E=function(c){return(0,r.hasSubscribers)(c)?Array.from(b[c]):O};r.getSubscribers=E;var f=function(c){var l;return((l=b[c])===null||l===void 0?void 0:l.size)>0};r.hasSubscribers=f;var _=function(c,l){b[c]=b[c]||new Set,b[c].add(l)};r.addSubscriber=_;var S=function(c,l){b[c].delete(l)};r.removeSubscriber=S;var v=function(c){if(c&&b.hasOwnProperty(c))delete b[c];else for(var l in b)b.hasOwnProperty(l)&&delete b[l]};r.resetSubscribers=v})(Fe)),Fe}var hr;function $e(){if(hr)return he;hr=1,Object.defineProperty(he,"__esModule",{value:!0}),he.assertIsWebSocket=O,he.resetGlobalState=E;var r=Je(),b=Ve();function O(f,_){if(!_&&!(f instanceof WebSocket))throw new Error("")}function E(f){(0,b.resetSubscribers)(f),(0,r.resetWebSockets)(f)}return he}var br;function lt(){if(br)return ne;br=1;var r=ne&&ne.__assign||function(){return r=Object.assign||function(u){for(var a,i=1,t=arguments.length;i<t;i++){a=arguments[i];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(u[n]=a[n])}return u},r.apply(this,arguments)};Object.defineProperty(ne,"__esModule",{value:!0}),ne.attachListeners=void 0;var b=He(),O=Ar(),E=$(),f=$e(),_=function(u,a,i,t){u.onmessage=function(n){var d;a.current.onMessage&&a.current.onMessage(n),typeof t?.current=="number"&&(t.current=Date.now()),!(typeof a.current.filter=="function"&&a.current.filter(n)!==!0)&&(a.current.heartbeat&&typeof a.current.heartbeat!="boolean"&&((d=a.current.heartbeat)===null||d===void 0?void 0:d.returnMessage)===n.data||i(n))}},S=function(u,a,i,t,n){u.onopen=function(d){if(a.current.onOpen&&a.current.onOpen(d),t.current=0,i(E.ReadyState.OPEN),a.current.heartbeat&&u instanceof WebSocket){var h=typeof a.current.heartbeat=="boolean"?void 0:a.current.heartbeat;n.current=Date.now(),(0,O.heartbeat)(u,n,h)}}},v=function(u,a,i,t,n){if(E.isEventSourceSupported&&u instanceof EventSource)return function(){};(0,f.assertIsWebSocket)(u,a.current.skipAssert);var d;return u.onclose=function(h){var o;if(a.current.onClose&&a.current.onClose(h),i(E.ReadyState.CLOSED),a.current.shouldReconnect&&a.current.shouldReconnect(h)){var y=(o=a.current.reconnectAttempts)!==null&&o!==void 0?o:E.DEFAULT_RECONNECT_LIMIT;if(n.current<y){var R=typeof a.current.reconnectInterval=="function"?a.current.reconnectInterval(n.current):a.current.reconnectInterval;d=window.setTimeout(function(){n.current++,t()},R??E.DEFAULT_RECONNECT_INTERVAL_MS)}else a.current.onReconnectStop&&a.current.onReconnectStop(y),console.warn("Max reconnect attempts of ".concat(y," exceeded"))}},function(){return d&&window.clearTimeout(d)}},c=function(u,a,i,t,n){var d;return u.onerror=function(h){var o;if(a.current.onError&&a.current.onError(h),E.isEventSourceSupported&&u instanceof EventSource&&(a.current.onClose&&a.current.onClose(r(r({},h),{code:1006,reason:"An error occurred with the EventSource: ".concat(h),wasClean:!1})),i(E.ReadyState.CLOSED),u.close()),a.current.retryOnError)if(n.current<((o=a.current.reconnectAttempts)!==null&&o!==void 0?o:E.DEFAULT_RECONNECT_LIMIT)){var y=typeof a.current.reconnectInterval=="function"?a.current.reconnectInterval(n.current):a.current.reconnectInterval;d=window.setTimeout(function(){n.current++,t()},y??E.DEFAULT_RECONNECT_INTERVAL_MS)}else a.current.onReconnectStop&&a.current.onReconnectStop(a.current.reconnectAttempts),console.warn("Max reconnect attempts of ".concat(a.current.reconnectAttempts," exceeded"))},function(){return d&&window.clearTimeout(d)}},l=function(u,a,i,t,n,d,h){var o=a.setLastMessage,y=a.setReadyState,R,P,T;return i.current.fromSocketIO&&(R=(0,b.setUpSocketIOPing)(h)),_(u,i,o,d),S(u,i,y,n,d),P=v(u,i,y,t,n),T=c(u,i,y,t,n),function(){y(E.ReadyState.CLOSING),P(),T(),u.close(),R&&clearInterval(R)}};return ne.attachListeners=l,ne}var ae={},yr;function ft(){if(yr)return ae;yr=1;var r=ae&&ae.__assign||function(){return r=Object.assign||function(a){for(var i,t=1,n=arguments.length;t<n;t++){i=arguments[t];for(var d in i)Object.prototype.hasOwnProperty.call(i,d)&&(a[d]=i[d])}return a},r.apply(this,arguments)};Object.defineProperty(ae,"__esModule",{value:!0}),ae.attachSharedListeners=void 0;var b=Je(),O=$(),E=Ve(),f=He(),_=Ar(),S=function(a,i,t){a.onmessage=function(n){(0,E.getSubscribers)(i).forEach(function(d){var h;d.optionsRef.current.onMessage&&d.optionsRef.current.onMessage(n),typeof((h=d?.lastMessageTime)===null||h===void 0?void 0:h.current)=="number"&&(d.lastMessageTime.current=Date.now()),!(typeof d.optionsRef.current.filter=="function"&&d.optionsRef.current.filter(n)!==!0)&&(t&&typeof t!="boolean"&&t?.returnMessage===n.data||d.setLastMessage(n))})}},v=function(a,i,t){a.onopen=function(n){var d=(0,E.getSubscribers)(i);d.forEach(function(h){h.reconnectCount.current=0,h.optionsRef.current.onOpen&&h.optionsRef.current.onOpen(n),h.setReadyState(O.ReadyState.OPEN),t&&a instanceof WebSocket&&(h.lastMessageTime.current=Date.now())}),t&&a instanceof WebSocket&&(0,_.heartbeat)(a,d.map(function(h){return h.lastMessageTime}),typeof t=="boolean"?void 0:t)}},c=function(a,i){a instanceof WebSocket&&(a.onclose=function(t){(0,E.getSubscribers)(i).forEach(function(n){n.optionsRef.current.onClose&&n.optionsRef.current.onClose(t),n.setReadyState(O.ReadyState.CLOSED)}),delete b.sharedWebSockets[i],(0,E.getSubscribers)(i).forEach(function(n){var d;if(n.optionsRef.current.shouldReconnect&&n.optionsRef.current.shouldReconnect(t)){var h=(d=n.optionsRef.current.reconnectAttempts)!==null&&d!==void 0?d:O.DEFAULT_RECONNECT_LIMIT;if(n.reconnectCount.current<h){var o=typeof n.optionsRef.current.reconnectInterval=="function"?n.optionsRef.current.reconnectInterval(n.reconnectCount.current):n.optionsRef.current.reconnectInterval;setTimeout(function(){n.reconnectCount.current++,n.reconnect.current()},o??O.DEFAULT_RECONNECT_INTERVAL_MS)}else n.optionsRef.current.onReconnectStop&&n.optionsRef.current.onReconnectStop(n.optionsRef.current.reconnectAttempts),console.warn("Max reconnect attempts of ".concat(h," exceeded"))}})})},l=function(a,i){a.onerror=function(t){(0,E.getSubscribers)(i).forEach(function(n){n.optionsRef.current.onError&&n.optionsRef.current.onError(t),O.isEventSourceSupported&&a instanceof EventSource&&(n.optionsRef.current.onClose&&n.optionsRef.current.onClose(r(r({},t),{code:1006,reason:"An error occurred with the EventSource: ".concat(t),wasClean:!1})),n.setReadyState(O.ReadyState.CLOSED))}),O.isEventSourceSupported&&a instanceof EventSource&&a.close()}},u=function(a,i,t,n){var d;return t.current.fromSocketIO&&(d=(0,f.setUpSocketIOPing)(n)),S(a,i,t.current.heartbeat),c(a,i),v(a,i,t.current.heartbeat),l(a,i),function(){d&&clearInterval(d)}};return ae.attachSharedListeners=u,ae}var gr;function dt(){if(gr)return Se;gr=1,Object.defineProperty(Se,"__esModule",{value:!0}),Se.createOrJoinSocket=void 0;var r=Je(),b=$(),O=lt(),E=ft(),f=Ve(),_=function(v,c,l,u,a){return function(){if((0,f.removeSubscriber)(v,c),!(0,f.hasSubscribers)(v)){try{var i=r.sharedWebSockets[v];i instanceof WebSocket&&(i.onclose=function(t){l.current.onClose&&l.current.onClose(t),u(b.ReadyState.CLOSED)}),i.close()}catch{}a&&a(),delete r.sharedWebSockets[v]}}},S=function(v,c,l,u,a,i,t,n,d){if(!b.isEventSourceSupported&&u.current.eventSourceOptions)throw b.isReactNative?new Error("EventSource is not supported in ReactNative"):new Error("EventSource is not supported");if(u.current.share){var h=null;r.sharedWebSockets[c]===void 0?(r.sharedWebSockets[c]=u.current.eventSourceOptions?new EventSource(c,u.current.eventSourceOptions):new WebSocket(c,u.current.protocols),v.current=r.sharedWebSockets[c],l(b.ReadyState.CONNECTING),h=(0,E.attachSharedListeners)(r.sharedWebSockets[c],c,u,d)):(v.current=r.sharedWebSockets[c],l(r.sharedWebSockets[c].readyState));var o={setLastMessage:a,setReadyState:l,optionsRef:u,reconnectCount:t,lastMessageTime:n,reconnect:i};return(0,f.addSubscriber)(c,o),_(c,o,u,l,h)}else{if(v.current=u.current.eventSourceOptions?new EventSource(c,u.current.eventSourceOptions):new WebSocket(c,u.current.protocols),l(b.ReadyState.CONNECTING),!v.current)throw new Error("WebSocket failed to be created");return(0,O.attachListeners)(v.current,{setLastMessage:a,setReadyState:l},u,i.current,t,n,d)}};return Se.createOrJoinSocket=S,Se}var Q={},Or;function vt(){return Or||(Or=1,(function(r){var b=Q&&Q.__awaiter||function(c,l,u,a){function i(t){return t instanceof u?t:new u(function(n){n(t)})}return new(u||(u=Promise))(function(t,n){function d(y){try{o(a.next(y))}catch(R){n(R)}}function h(y){try{o(a.throw(y))}catch(R){n(R)}}function o(y){y.done?t(y.value):i(y.value).then(d,h)}o((a=a.apply(c,l||[])).next())})},O=Q&&Q.__generator||function(c,l){var u={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},a,i,t,n=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return n.next=d(0),n.throw=d(1),n.return=d(2),typeof Symbol=="function"&&(n[Symbol.iterator]=function(){return this}),n;function d(o){return function(y){return h([o,y])}}function h(o){if(a)throw new TypeError("Generator is already executing.");for(;n&&(n=0,o[0]&&(u=0)),u;)try{if(a=1,i&&(t=o[0]&2?i.return:o[0]?i.throw||((t=i.return)&&t.call(i),0):i.next)&&!(t=t.call(i,o[1])).done)return t;switch(i=0,t&&(o=[o[0]&2,t.value]),o[0]){case 0:case 1:t=o;break;case 4:return u.label++,{value:o[1],done:!1};case 5:u.label++,i=o[1],o=[0];continue;case 7:o=u.ops.pop(),u.trys.pop();continue;default:if(t=u.trys,!(t=t.length>0&&t[t.length-1])&&(o[0]===6||o[0]===2)){u=0;continue}if(o[0]===3&&(!t||o[1]>t[0]&&o[1]<t[3])){u.label=o[1];break}if(o[0]===6&&u.label<t[1]){u.label=t[1],t=o;break}if(t&&u.label<t[2]){u.label=t[2],u.ops.push(o);break}t[2]&&u.ops.pop(),u.trys.pop();continue}o=l.call(c,u)}catch(y){o=[6,y],i=0}finally{a=t=0}if(o[0]&5)throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}},E=Q&&Q.__spreadArray||function(c,l,u){if(u||arguments.length===2)for(var a=0,i=l.length,t;a<i;a++)(t||!(a in l))&&(t||(t=Array.prototype.slice.call(l,0,a)),t[a]=l[a]);return c.concat(t||Array.prototype.slice.call(l))};Object.defineProperty(r,"__esModule",{value:!0}),r.getUrl=void 0;var f=He(),_=$(),S=function(c){return new Promise(function(l){return window.setTimeout(l,c)})},v=function(c,l){for(var u=[],a=2;a<arguments.length;a++)u[a-2]=arguments[a];return b(void 0,E([c,l],u,!0),void 0,function(i,t,n){var d,h,o,y,R,P,T,A;return n===void 0&&(n=0),O(this,function(I){switch(I.label){case 0:if(typeof i!="function")return[3,10];I.label=1;case 1:return I.trys.push([1,3,,9]),[4,i()];case 2:return d=I.sent(),[3,9];case 3:return I.sent(),t.current.retryOnError?(h=(P=t.current.reconnectAttempts)!==null&&P!==void 0?P:_.DEFAULT_RECONNECT_LIMIT,n<h?(o=typeof t.current.reconnectInterval=="function"?t.current.reconnectInterval(n):t.current.reconnectInterval,[4,S(o??_.DEFAULT_RECONNECT_INTERVAL_MS)]):[3,5]):[3,7];case 4:return I.sent(),[2,(0,r.getUrl)(i,t,n+1)];case 5:return(A=(T=t.current).onReconnectStop)===null||A===void 0||A.call(T,n),[2,null];case 6:return[3,8];case 7:return[2,null];case 8:return[3,9];case 9:return[3,11];case 10:d=i,I.label=11;case 11:return y=t.current.fromSocketIO?(0,f.parseSocketIOUrl)(d):d,R=t.current.queryParams?(0,f.appendQueryParams)(y,t.current.queryParams):y,[2,R]}})})};r.getUrl=v})(Q)),Q}var qe={},pr;function Et(){return pr||(pr=1,(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.websocketWrapper=void 0;var b=function(O,E){return new Proxy(O,{get:function(f,_){var S=f[_];return _==="reconnect"?E:typeof S=="function"?(console.error("Calling methods directly on the websocket is not supported at this moment. You must use the methods returned by useWebSocket."),function(){}):S},set:function(f,_,S){return/^on/.test(_)?(console.warn("The websocket's event handlers should be defined through the options object passed into useWebSocket."),!1):(f[_]=S,!0)}})};r.websocketWrapper=b,r.default=r.websocketWrapper})(qe)),qe}var Tr;function Be(){if(Tr)return q;Tr=1;var r=q&&q.__assign||function(){return r=Object.assign||function(i){for(var t,n=1,d=arguments.length;n<d;n++){t=arguments[n];for(var h in t)Object.prototype.hasOwnProperty.call(t,h)&&(i[h]=t[h])}return i},r.apply(this,arguments)},b=q&&q.__awaiter||function(i,t,n,d){function h(o){return o instanceof n?o:new n(function(y){y(o)})}return new(n||(n=Promise))(function(o,y){function R(A){try{T(d.next(A))}catch(I){y(I)}}function P(A){try{T(d.throw(A))}catch(I){y(I)}}function T(A){A.done?o(A.value):h(A.value).then(R,P)}T((d=d.apply(i,t||[])).next())})},O=q&&q.__generator||function(i,t){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},d,h,o,y=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return y.next=R(0),y.throw=R(1),y.return=R(2),typeof Symbol=="function"&&(y[Symbol.iterator]=function(){return this}),y;function R(T){return function(A){return P([T,A])}}function P(T){if(d)throw new TypeError("Generator is already executing.");for(;y&&(y=0,T[0]&&(n=0)),n;)try{if(d=1,h&&(o=T[0]&2?h.return:T[0]?h.throw||((o=h.return)&&o.call(h),0):h.next)&&!(o=o.call(h,T[1])).done)return o;switch(h=0,o&&(T=[T[0]&2,o.value]),T[0]){case 0:case 1:o=T;break;case 4:return n.label++,{value:T[1],done:!1};case 5:n.label++,h=T[1],T=[0];continue;case 7:T=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(T[0]===6||T[0]===2)){n=0;continue}if(T[0]===3&&(!o||T[1]>o[0]&&T[1]<o[3])){n.label=T[1];break}if(T[0]===6&&n.label<o[1]){n.label=o[1],o=T;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(T);break}o[2]&&n.ops.pop(),n.trys.pop();continue}T=t.call(i,n)}catch(A){T=[6,A],h=0}finally{d=o=0}if(T[0]&5)throw T[1];return{value:T[0]?T[1]:void 0,done:!0}}},E=q&&q.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(q,"__esModule",{value:!0}),q.useWebSocket=void 0;var f=M,_=rt,S=$(),v=dt(),c=vt(),l=E(Et()),u=$e(),a=function(i,t,n){t===void 0&&(t=S.DEFAULT_OPTIONS),n===void 0&&(n=!0);var d=(0,f.useState)(null),h=d[0],o=d[1],y=(0,f.useState)({}),R=y[0],P=y[1],T=(0,f.useMemo)(function(){if(!t.disableJson&&h)try{return JSON.parse(h.data)}catch{return S.UNPARSABLE_JSON_OBJECT}return null},[h,t.disableJson]),A=(0,f.useRef)(null),I=(0,f.useRef)(null),le=(0,f.useRef)(function(){}),fe=(0,f.useRef)(0),ke=(0,f.useRef)(Date.now()),be=(0,f.useRef)([]),H=(0,f.useRef)(null),j=(0,f.useRef)(t);j.current=t;var J=A.current&&R[A.current]!==void 0?R[A.current]:i!==null&&n===!0?S.ReadyState.CONNECTING:S.ReadyState.UNINSTANTIATED,Z=t.queryParams?JSON.stringify(t.queryParams):null,B=(0,f.useCallback)(function(L,U){var Y;if(U===void 0&&(U=!0),S.isEventSourceSupported&&I.current instanceof EventSource){console.warn("Unable to send a message from an eventSource");return}((Y=I.current)===null||Y===void 0?void 0:Y.readyState)===S.ReadyState.OPEN?((0,u.assertIsWebSocket)(I.current,j.current.skipAssert),I.current.send(L)):U&&be.current.push(L)},[]),ye=(0,f.useCallback)(function(L,U){U===void 0&&(U=!0),B(JSON.stringify(L),U)},[B]),ge=(0,f.useCallback)(function(){return j.current.share!==!0||S.isEventSourceSupported&&I.current instanceof EventSource?I.current:(H.current===null&&I.current&&((0,u.assertIsWebSocket)(I.current,j.current.skipAssert),H.current=(0,l.default)(I.current,le)),H.current)},[]);return(0,f.useEffect)(function(){if(i!==null&&n===!0){var L,U=!1,Y=!0,de=function(){return b(void 0,void 0,void 0,function(){var ee,X,Oe;return O(this,function(oe){switch(oe.label){case 0:return ee=A,[4,(0,c.getUrl)(i,j)];case 1:return ee.current=oe.sent(),A.current===null?(console.error("Failed to get a valid URL. WebSocket connection aborted."),A.current="ABORTED",(0,_.flushSync)(function(){return P(function(K){return r(r({},K),{ABORTED:S.ReadyState.CLOSED})})}),[2]):(X=function(K){U||(0,_.flushSync)(function(){return o(K)})},Oe=function(K){U||(0,_.flushSync)(function(){return P(function(ce){var re;return r(r({},ce),A.current&&(re={},re[A.current]=K,re))})})},Y&&(L=(0,v.createOrJoinSocket)(I,A.current,Oe,j,X,le,fe,ke,B)),[2])}})})};return le.current=function(){U||(H.current&&(H.current=null),L?.(),de())},de(),function(){U=!0,Y=!1,H.current&&(H.current=null),L?.(),o(null)}}else(i===null||n===!1)&&(fe.current=0,P(function(ee){var X;return r(r({},ee),A.current&&(X={},X[A.current]=S.ReadyState.CLOSED,X))}))},[i,n,Z,B]),(0,f.useEffect)(function(){J===S.ReadyState.OPEN&&be.current.splice(0).forEach(function(L){B(L)})},[J]),{sendMessage:B,sendJsonMessage:ye,lastMessage:h,lastJsonMessage:T,readyState:J,getWebSocket:ge}};return q.useWebSocket=a,q}var ue={},mr;function _t(){if(mr)return ue;mr=1;var r=ue&&ue.__assign||function(){return r=Object.assign||function(v){for(var c,l=1,u=arguments.length;l<u;l++){c=arguments[l];for(var a in c)Object.prototype.hasOwnProperty.call(c,a)&&(v[a]=c[a])}return v},r.apply(this,arguments)};Object.defineProperty(ue,"__esModule",{value:!0}),ue.useSocketIO=void 0;var b=M,O=Be(),E=$(),f={type:"empty",payload:null},_=function(v){if(!v||!v.data)return f;var c=v.data.match(/\[.*]/);if(!c)return f;var l=JSON.parse(c);return!Array.isArray(l)||!l[1]?f:{type:l[0],payload:l[1]}},S=function(v,c,l){c===void 0&&(c=E.DEFAULT_OPTIONS),l===void 0&&(l=!0);var u=(0,b.useMemo)(function(){return r(r({},c),{fromSocketIO:!0})},[]),a=(0,O.useWebSocket)(v,u,l),i=a.sendMessage,t=a.sendJsonMessage,n=a.lastMessage,d=a.readyState,h=a.getWebSocket,o=(0,b.useMemo)(function(){return _(n)},[n]);return{sendMessage:i,sendJsonMessage:t,lastMessage:o,lastJsonMessage:o,readyState:d,getWebSocket:h}};return ue.useSocketIO=S,ue}var z={},Cr;function St(){if(Cr)return z;Cr=1;var r=z&&z.__assign||function(){return r=Object.assign||function(S){for(var v,c=1,l=arguments.length;c<l;c++){v=arguments[c];for(var u in v)Object.prototype.hasOwnProperty.call(v,u)&&(S[u]=v[u])}return S},r.apply(this,arguments)},b=z&&z.__rest||function(S,v){var c={};for(var l in S)Object.prototype.hasOwnProperty.call(S,l)&&v.indexOf(l)<0&&(c[l]=S[l]);if(S!=null&&typeof Object.getOwnPropertySymbols=="function")for(var u=0,l=Object.getOwnPropertySymbols(S);u<l.length;u++)v.indexOf(l[u])<0&&Object.prototype.propertyIsEnumerable.call(S,l[u])&&(c[l[u]]=S[l[u]]);return c};Object.defineProperty(z,"__esModule",{value:!0}),z.useEventSource=void 0;var O=M,E=Be(),f=$(),_=function(S,v,c){v===void 0&&(v=f.DEFAULT_EVENT_SOURCE_OPTIONS);var l=v.withCredentials,u=v.events,a=b(v,["withCredentials","events"]);c===void 0&&(c=!0);var i=r(r({},a),{eventSourceOptions:{withCredentials:l}}),t=(0,O.useRef)(f.EMPTY_EVENT_HANDLERS);u&&(t.current=u);var n=(0,E.useWebSocket)(S,i,c),d=n.lastMessage,h=n.readyState,o=n.getWebSocket;return(0,O.useEffect)(function(){d?.type&&Object.entries(t.current).forEach(function(y){var R=y[0],P=y[1];R===d.type&&P(d)})},[d]),{lastEvent:d,readyState:h,getEventSource:o}};return z.useEventSource=_,z}var Rr;function ht(){return Rr||(Rr=1,(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.resetGlobalState=r.useEventSource=r.ReadyState=r.useSocketIO=r.default=void 0;var b=Be();Object.defineProperty(r,"default",{enumerable:!0,get:function(){return b.useWebSocket}});var O=_t();Object.defineProperty(r,"useSocketIO",{enumerable:!0,get:function(){return O.useSocketIO}});var E=$();Object.defineProperty(r,"ReadyState",{enumerable:!0,get:function(){return E.ReadyState}});var f=St();Object.defineProperty(r,"useEventSource",{enumerable:!0,get:function(){return f.useEventSource}});var _=$e();Object.defineProperty(r,"resetGlobalState",{enumerable:!0,get:function(){return _.resetGlobalState}})})(je)),je}var bt=ht();const yt=tt(bt),V={DEPOSIT:"deposit",TRANS_CODE:"transCode",ERROR:"error",UPDATE_MEMBER:"update_member",MAINTAIN_NOTICE:"maintain_notice",MAINTAIN_NOTICE_MEMBER:"maintain_notice_member",RELOAD:"reload",TRANSFER_IN_GAME:"transfer_in_game",CHECK_REQUEST:"CHECK_RREQUEST",CASH_REGISTER_LIMIT:"cash_register_limit"},gt=3e4,Ot=({socketUrl:r,socketHandlers:b={},options:O={}})=>{const E=M.useRef(!1),f=M.useRef(b),{sendMessage:_,sendJsonMessage:S,lastMessage:v,readyState:c}=yt(r,{queryParams:{key:"wsky"},onOpen:()=>console.log("連線成功"),shouldReconnect:()=>E.current===!1,reconnectAttempts:9999,reconnectInterval:1e3,...O}),l=M.useMemo(()=>{try{return JSON.parse(v?.data)}catch{return null}},[v?.data]);return M.useEffect(()=>{const u=setInterval(()=>_("ping"),gt);return()=>clearInterval(u)},[_]),M.useEffect(()=>{f.current=b},[b]),M.useEffect(()=>{if(!l)return;const{onDeposit:u,onTransCode:a,onError:i,onUpdateMember:t,onMaintainNotice:n,onMaintainNoticeMember:d,onReload:h,onTransferInGame:o,onCashRegisterLimit:y}=f.current,R=Ce.get(l,"type",""),P={memberInfoUid:Ce.get(l,"member_info_uid",null),data:Ce.get(l,"data",null),memo:Ce.get(l,"memo",null)};switch(R){case V.DEPOSIT:u?.(P);break;case V.TRANS_CODE:a?.(P);break;case V.ERROR:i?.(P);break;case V.UPDATE_MEMBER:t?.(P);break;case V.MAINTAIN_NOTICE:n?.(P);break;case V.MAINTAIN_NOTICE_MEMBER:d?.(P);break;case V.RELOAD:h?.(P);break;case V.TRANSFER_IN_GAME:case V.CHECK_REQUEST:o?.(P);break;case V.CASH_REGISTER_LIMIT:y?.(P);break;default:console.warn("Unknown socket type:",R);break}},[l]),M.useEffect(()=>()=>E.current=!0,[]),{sendMessage:_,sendJsonMessage:S,readyState:c}},pt=()=>{const{getToken:r}=Pe(),{userInfoApi:b}=wr(),O=Ae.useQueries({queries:[{queryKey:["getMemberInfo"],queryFn:async()=>await b(),refetchInterval:5e4}],enabled:!!r}),{data:E,isFetching:f,error:_}=O[0]||{};return{data:E,isFetching:f,error:_}};exports.ApiCtx=Ge;exports.ApiProvider=ct;exports.createLogoutHandler=it;exports.useApiContext=Pe;exports.useBalanceGetter=st;exports.useClientWebSocket=Ot;exports.usePeriodicDataUpdater=pt;
|
package/dist/index.js
CHANGED
|
@@ -6,26 +6,26 @@ import st from "react-dom";
|
|
|
6
6
|
function lt(r) {
|
|
7
7
|
return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
|
|
8
8
|
}
|
|
9
|
-
var Ae = { exports: {} },
|
|
9
|
+
var Ae = { exports: {} }, Ee = {};
|
|
10
10
|
var lr;
|
|
11
11
|
function ft() {
|
|
12
|
-
if (lr) return
|
|
12
|
+
if (lr) return Ee;
|
|
13
13
|
lr = 1;
|
|
14
|
-
var r = ye, y = Symbol.for("react.element"), O = Symbol.for("react.fragment"),
|
|
15
|
-
function S(
|
|
14
|
+
var r = ye, y = Symbol.for("react.element"), O = Symbol.for("react.fragment"), E = Object.prototype.hasOwnProperty, f = r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, _ = { key: !0, ref: !0, __self: !0, __source: !0 };
|
|
15
|
+
function S(d, c, l) {
|
|
16
16
|
var o, a = {}, i = null, t = null;
|
|
17
17
|
l !== void 0 && (i = "" + l), c.key !== void 0 && (i = "" + c.key), c.ref !== void 0 && (t = c.ref);
|
|
18
|
-
for (o in c)
|
|
19
|
-
if (
|
|
20
|
-
return { $$typeof: y, type:
|
|
18
|
+
for (o in c) E.call(c, o) && !_.hasOwnProperty(o) && (a[o] = c[o]);
|
|
19
|
+
if (d && d.defaultProps) for (o in c = d.defaultProps, c) a[o] === void 0 && (a[o] = c[o]);
|
|
20
|
+
return { $$typeof: y, type: d, key: i, ref: t, props: a, _owner: f.current };
|
|
21
21
|
}
|
|
22
|
-
return
|
|
22
|
+
return Ee.Fragment = O, Ee.jsx = S, Ee.jsxs = S, Ee;
|
|
23
23
|
}
|
|
24
|
-
var
|
|
24
|
+
var _e = {};
|
|
25
25
|
var fr;
|
|
26
26
|
function vt() {
|
|
27
27
|
return fr || (fr = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
28
|
-
var r = ye, y = Symbol.for("react.element"), O = Symbol.for("react.portal"),
|
|
28
|
+
var r = ye, y = Symbol.for("react.element"), O = Symbol.for("react.portal"), E = Symbol.for("react.fragment"), f = Symbol.for("react.strict_mode"), _ = Symbol.for("react.profiler"), S = Symbol.for("react.provider"), d = Symbol.for("react.context"), c = Symbol.for("react.forward_ref"), l = Symbol.for("react.suspense"), o = Symbol.for("react.suspense_list"), a = Symbol.for("react.memo"), i = Symbol.for("react.lazy"), t = Symbol.for("react.offscreen"), n = Symbol.iterator, v = "@@iterator";
|
|
29
29
|
function h(e) {
|
|
30
30
|
if (e === null || typeof e != "object")
|
|
31
31
|
return null;
|
|
@@ -53,7 +53,7 @@ function vt() {
|
|
|
53
53
|
var P = !1, T = !1, A = !1, I = !1, se = !1, le;
|
|
54
54
|
le = Symbol.for("react.module.reference");
|
|
55
55
|
function ke(e) {
|
|
56
|
-
return !!(typeof e == "string" || typeof e == "function" || e ===
|
|
56
|
+
return !!(typeof e == "string" || typeof e == "function" || e === E || e === _ || se || e === f || e === l || e === o || I || e === t || P || T || A || typeof e == "object" && e !== null && (e.$$typeof === i || e.$$typeof === a || e.$$typeof === S || e.$$typeof === d || e.$$typeof === c || // This needs to include all possible module reference object
|
|
57
57
|
// types supported by any Flight configuration anywhere since
|
|
58
58
|
// we don't know which Flight build this will end up being used
|
|
59
59
|
// with.
|
|
@@ -77,11 +77,11 @@ function vt() {
|
|
|
77
77
|
if (typeof e == "string")
|
|
78
78
|
return e;
|
|
79
79
|
switch (e) {
|
|
80
|
-
case
|
|
80
|
+
case E:
|
|
81
81
|
return "Fragment";
|
|
82
82
|
case O:
|
|
83
83
|
return "Portal";
|
|
84
|
-
case
|
|
84
|
+
case _:
|
|
85
85
|
return "Profiler";
|
|
86
86
|
case f:
|
|
87
87
|
return "StrictMode";
|
|
@@ -92,7 +92,7 @@ function vt() {
|
|
|
92
92
|
}
|
|
93
93
|
if (typeof e == "object")
|
|
94
94
|
switch (e.$$typeof) {
|
|
95
|
-
case
|
|
95
|
+
case d:
|
|
96
96
|
var s = e;
|
|
97
97
|
return J(s) + ".Consumer";
|
|
98
98
|
case S:
|
|
@@ -599,7 +599,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
599
599
|
<%s key={someKey} {...props} />`, Le, re, tt, re), cr[re + Le] = !0;
|
|
600
600
|
}
|
|
601
601
|
}
|
|
602
|
-
return e ===
|
|
602
|
+
return e === E ? zr(M) : Qr(M), M;
|
|
603
603
|
}
|
|
604
604
|
}
|
|
605
605
|
function Xr(e, s, g) {
|
|
@@ -609,8 +609,8 @@ React keys must be passed directly to JSX without using spread:
|
|
|
609
609
|
return ir(e, s, g, !1);
|
|
610
610
|
}
|
|
611
611
|
var et = Zr, rt = Xr;
|
|
612
|
-
|
|
613
|
-
})()),
|
|
612
|
+
_e.Fragment = E, _e.jsx = et, _e.jsxs = rt;
|
|
613
|
+
})()), _e;
|
|
614
614
|
}
|
|
615
615
|
var vr;
|
|
616
616
|
function dt() {
|
|
@@ -623,32 +623,32 @@ const kr = at(null), Je = () => {
|
|
|
623
623
|
throw new Error("useApiContext must be used within ApiProvider");
|
|
624
624
|
return r;
|
|
625
625
|
};
|
|
626
|
-
function
|
|
626
|
+
function Et({
|
|
627
627
|
baseURL: r,
|
|
628
628
|
getToken: y,
|
|
629
629
|
timeoutMs: O = 15e3,
|
|
630
|
-
currency:
|
|
630
|
+
currency: E = "TWD",
|
|
631
631
|
lng: f = "tw",
|
|
632
|
-
onError:
|
|
632
|
+
onError: _
|
|
633
633
|
} = {}) {
|
|
634
634
|
const S = it.create({
|
|
635
635
|
baseURL: r,
|
|
636
636
|
timeout: O,
|
|
637
637
|
headers: { "Content-Type": "application/json" }
|
|
638
638
|
});
|
|
639
|
-
return S.interceptors.request.use(async (
|
|
640
|
-
if (
|
|
639
|
+
return S.interceptors.request.use(async (d) => {
|
|
640
|
+
if (d.headers = d.headers || {}, y) {
|
|
641
641
|
const c = await y();
|
|
642
|
-
c && (
|
|
642
|
+
c && (d.headers.Authorization = `Bearer ${c}`);
|
|
643
643
|
}
|
|
644
|
-
return
|
|
644
|
+
return d.headers.Currency = E, d.headers["currency-code"] = E, d.headers.lang = f, d;
|
|
645
645
|
}), S.interceptors.response.use(
|
|
646
|
-
(
|
|
647
|
-
(
|
|
646
|
+
(d) => d.data,
|
|
647
|
+
(d) => _ ? _(d, { instance: S }) : Promise.reject(d)
|
|
648
648
|
), S;
|
|
649
649
|
}
|
|
650
650
|
function It({ children: r, ...y }) {
|
|
651
|
-
const O = Ge(() =>
|
|
651
|
+
const O = Ge(() => Et(y), [y]), f = Ge(
|
|
652
652
|
() => new ut({
|
|
653
653
|
defaultOptions: {
|
|
654
654
|
queries: {
|
|
@@ -662,20 +662,20 @@ function It({ children: r, ...y }) {
|
|
|
662
662
|
return /* @__PURE__ */ dr.jsx(ct, { client: f, children: /* @__PURE__ */ dr.jsx(kr.Provider, { value: { client: O, ...y }, children: r }) });
|
|
663
663
|
}
|
|
664
664
|
const Nt = () => {
|
|
665
|
-
const r = (
|
|
665
|
+
const r = (E, f) => !E && !f, y = (E) => E.startsWith("pc.");
|
|
666
666
|
return {
|
|
667
667
|
executeLogout: ({
|
|
668
|
-
isCallBackInvalid:
|
|
668
|
+
isCallBackInvalid: E = !1,
|
|
669
669
|
hostname: f = "",
|
|
670
|
-
shouldRedirect:
|
|
670
|
+
shouldRedirect: _,
|
|
671
671
|
onShowError: S,
|
|
672
|
-
onCleanup:
|
|
672
|
+
onCleanup: d,
|
|
673
673
|
onRemoveToken: c,
|
|
674
674
|
onRedirect: l,
|
|
675
675
|
onGoogleLogout: o
|
|
676
676
|
}) => {
|
|
677
677
|
const a = y(f);
|
|
678
|
-
r(
|
|
678
|
+
r(E, a) && S?.(), d?.(), c?.(), _ && l?.("/"), o?.();
|
|
679
679
|
},
|
|
680
680
|
shouldShowErrorNotice: r,
|
|
681
681
|
isMachineDomain: y
|
|
@@ -683,49 +683,49 @@ const Nt = () => {
|
|
|
683
683
|
}, Ir = () => {
|
|
684
684
|
const { client: r } = Je(), y = de(
|
|
685
685
|
async (S) => {
|
|
686
|
-
const { mac_address:
|
|
687
|
-
mac_address:
|
|
686
|
+
const { mac_address: d = "", app_version: c = "", anydesk_id: l = "" } = S, { data: o } = await r.post("/cash-register/login", {
|
|
687
|
+
mac_address: d,
|
|
688
688
|
app_version: c,
|
|
689
689
|
anydesk_id: l
|
|
690
690
|
});
|
|
691
691
|
return o;
|
|
692
692
|
},
|
|
693
693
|
[r]
|
|
694
|
-
), O = de(async () => r.get("/member/getMemberInfo"), [r]),
|
|
694
|
+
), O = de(async () => r.get("/member/getMemberInfo"), [r]), E = de(async () => {
|
|
695
695
|
const { data: S } = await r.get("/getGameList");
|
|
696
696
|
return S;
|
|
697
697
|
}, [r]), f = de(async () => {
|
|
698
698
|
const { data: S } = await r.get("/getNowCurrencyExchange");
|
|
699
699
|
return S;
|
|
700
|
-
}, [r]),
|
|
700
|
+
}, [r]), _ = de(async () => {
|
|
701
701
|
const { data: S } = await r.get("/getFavoriteGame");
|
|
702
702
|
return S;
|
|
703
703
|
}, [r]);
|
|
704
704
|
return {
|
|
705
705
|
machineLoginApi: y,
|
|
706
706
|
userInfoApi: O,
|
|
707
|
-
userGameListApi:
|
|
708
|
-
userFavoriteGameApi:
|
|
707
|
+
userGameListApi: E,
|
|
708
|
+
userFavoriteGameApi: _,
|
|
709
709
|
userCurrencyExchangeApi: f
|
|
710
710
|
};
|
|
711
711
|
}, Mt = ({ otherQueryKey: r = [], options: y = {} }) => {
|
|
712
|
-
const {
|
|
712
|
+
const { userCurrencyExchangeApi: O } = Ir(), { getToken: E } = Je(), { enabled: f, ..._ } = y, S = !!E && f.every((d) => d);
|
|
713
713
|
return Pr({
|
|
714
|
-
queryKey: ["getBalance", ...r],
|
|
715
714
|
queries: [
|
|
716
715
|
{
|
|
717
|
-
queryKey: ["userCurrencyExchange"],
|
|
718
|
-
queryFn: () => O()
|
|
716
|
+
queryKey: ["userCurrencyExchange", ...r],
|
|
717
|
+
queryFn: () => O(),
|
|
718
|
+
enabled: S,
|
|
719
|
+
// ← 使用合併後的條件
|
|
720
|
+
..._
|
|
721
|
+
// ← 不包含 enabled
|
|
719
722
|
}
|
|
720
|
-
|
|
721
|
-
],
|
|
722
|
-
enabled: !!d,
|
|
723
|
-
...y
|
|
723
|
+
]
|
|
724
724
|
});
|
|
725
725
|
};
|
|
726
|
-
var je = {}, F = {}, Ue = {},
|
|
726
|
+
var je = {}, F = {}, Ue = {}, Er;
|
|
727
727
|
function V() {
|
|
728
|
-
return
|
|
728
|
+
return Er || (Er = 1, (function(r) {
|
|
729
729
|
Object.defineProperty(r, "__esModule", { value: !0 }), r.isEventSourceSupported = r.isReactNative = r.ReadyState = r.DEFAULT_HEARTBEAT = r.UNPARSABLE_JSON_OBJECT = r.DEFAULT_RECONNECT_INTERVAL_MS = r.DEFAULT_RECONNECT_LIMIT = r.SOCKET_IO_PING_CODE = r.SOCKET_IO_PATH = r.SOCKET_IO_PING_INTERVAL = r.DEFAULT_EVENT_SOURCE_OPTIONS = r.EMPTY_EVENT_HANDLERS = r.DEFAULT_OPTIONS = void 0;
|
|
730
730
|
var y = 1, O = 1e3 * y;
|
|
731
731
|
r.DEFAULT_OPTIONS = {}, r.EMPTY_EVENT_HANDLERS = {}, r.DEFAULT_EVENT_SOURCE_OPTIONS = {
|
|
@@ -736,10 +736,10 @@ function V() {
|
|
|
736
736
|
timeout: 6e4,
|
|
737
737
|
interval: 25e3
|
|
738
738
|
};
|
|
739
|
-
var
|
|
740
|
-
(function(
|
|
741
|
-
|
|
742
|
-
})(
|
|
739
|
+
var E;
|
|
740
|
+
(function(_) {
|
|
741
|
+
_[_.UNINSTANTIATED = -1] = "UNINSTANTIATED", _[_.CONNECTING = 0] = "CONNECTING", _[_.OPEN = 1] = "OPEN", _[_.CLOSING = 2] = "CLOSING", _[_.CLOSED = 3] = "CLOSED";
|
|
742
|
+
})(E || (r.ReadyState = E = {}));
|
|
743
743
|
var f = function() {
|
|
744
744
|
try {
|
|
745
745
|
return "EventSource" in globalThis;
|
|
@@ -750,16 +750,16 @@ function V() {
|
|
|
750
750
|
r.isReactNative = typeof navigator < "u" && navigator.product === "ReactNative", r.isEventSourceSupported = !r.isReactNative && f();
|
|
751
751
|
})(Ue)), Ue;
|
|
752
752
|
}
|
|
753
|
-
var Se = {}, We = {},
|
|
753
|
+
var Se = {}, We = {}, _r;
|
|
754
754
|
function He() {
|
|
755
|
-
return
|
|
755
|
+
return _r || (_r = 1, (function(r) {
|
|
756
756
|
Object.defineProperty(r, "__esModule", { value: !0 }), r.resetWebSockets = r.sharedWebSockets = void 0, r.sharedWebSockets = {};
|
|
757
757
|
var y = function(O) {
|
|
758
758
|
if (O && r.sharedWebSockets.hasOwnProperty(O))
|
|
759
759
|
delete r.sharedWebSockets[O];
|
|
760
760
|
else
|
|
761
|
-
for (var
|
|
762
|
-
r.sharedWebSockets.hasOwnProperty(
|
|
761
|
+
for (var E in r.sharedWebSockets)
|
|
762
|
+
r.sharedWebSockets.hasOwnProperty(E) && delete r.sharedWebSockets[E];
|
|
763
763
|
};
|
|
764
764
|
r.resetWebSockets = y;
|
|
765
765
|
})(We)), We;
|
|
@@ -770,56 +770,56 @@ function Ve() {
|
|
|
770
770
|
Sr = 1, Object.defineProperty(K, "__esModule", { value: !0 }), K.setUpSocketIOPing = K.appendQueryParams = K.parseSocketIOUrl = void 0;
|
|
771
771
|
var r = V(), y = function(f) {
|
|
772
772
|
if (f) {
|
|
773
|
-
var
|
|
774
|
-
return "".concat(c, "://").concat(
|
|
773
|
+
var _ = /^https|wss/.test(f), S = f.replace(/^(https?|wss?)(:\/\/)?/, ""), d = S.replace(/\/$/, ""), c = _ ? "wss" : "ws";
|
|
774
|
+
return "".concat(c, "://").concat(d).concat(r.SOCKET_IO_PATH);
|
|
775
775
|
} else if (f === "") {
|
|
776
|
-
var
|
|
776
|
+
var _ = /^https/.test(window.location.protocol), c = _ ? "wss" : "ws", l = window.location.port ? ":".concat(window.location.port) : "";
|
|
777
777
|
return "".concat(c, "://").concat(window.location.hostname).concat(l).concat(r.SOCKET_IO_PATH);
|
|
778
778
|
}
|
|
779
779
|
return f;
|
|
780
780
|
};
|
|
781
781
|
K.parseSocketIOUrl = y;
|
|
782
|
-
var O = function(f,
|
|
783
|
-
|
|
784
|
-
var S = /\?([\w]+=[\w]+)/,
|
|
782
|
+
var O = function(f, _) {
|
|
783
|
+
_ === void 0 && (_ = {});
|
|
784
|
+
var S = /\?([\w]+=[\w]+)/, d = S.test(f), c = "".concat(Object.entries(_).reduce(function(l, o) {
|
|
785
785
|
var a = o[0], i = o[1];
|
|
786
786
|
return l + "".concat(a, "=").concat(i, "&");
|
|
787
787
|
}, "").slice(0, -1));
|
|
788
|
-
return "".concat(f).concat(
|
|
788
|
+
return "".concat(f).concat(d ? "&" : "?").concat(c);
|
|
789
789
|
};
|
|
790
790
|
K.appendQueryParams = O;
|
|
791
|
-
var
|
|
792
|
-
|
|
791
|
+
var E = function(f, _) {
|
|
792
|
+
_ === void 0 && (_ = r.SOCKET_IO_PING_INTERVAL);
|
|
793
793
|
var S = function() {
|
|
794
794
|
return f(r.SOCKET_IO_PING_CODE);
|
|
795
795
|
};
|
|
796
|
-
return window.setInterval(S,
|
|
796
|
+
return window.setInterval(S, _);
|
|
797
797
|
};
|
|
798
|
-
return K.setUpSocketIOPing =
|
|
798
|
+
return K.setUpSocketIOPing = E, K;
|
|
799
799
|
}
|
|
800
800
|
var Pe = {}, hr;
|
|
801
801
|
function Nr() {
|
|
802
802
|
if (hr) return Pe;
|
|
803
803
|
hr = 1, Object.defineProperty(Pe, "__esModule", { value: !0 }), Pe.heartbeat = O;
|
|
804
804
|
var r = V();
|
|
805
|
-
function y(
|
|
806
|
-
return Array.isArray(
|
|
807
|
-
return f.current >
|
|
808
|
-
}).current :
|
|
805
|
+
function y(E) {
|
|
806
|
+
return Array.isArray(E) ? E.reduce(function(f, _) {
|
|
807
|
+
return f.current > _.current ? f : _;
|
|
808
|
+
}).current : E.current;
|
|
809
809
|
}
|
|
810
|
-
function O(
|
|
811
|
-
var S =
|
|
810
|
+
function O(E, f, _) {
|
|
811
|
+
var S = _ || {}, d = S.interval, c = d === void 0 ? r.DEFAULT_HEARTBEAT.interval : d, l = S.timeout, o = l === void 0 ? r.DEFAULT_HEARTBEAT.timeout : l, a = S.message, i = a === void 0 ? r.DEFAULT_HEARTBEAT.message : a, t = Math.max(100, c / 10), n = Date.now(), v = setInterval(function() {
|
|
812
812
|
var h = Date.now(), u = y(f);
|
|
813
813
|
if (u + o <= h)
|
|
814
|
-
console.warn("Heartbeat timed out, closing connection, last message received ".concat(h - u, "ms ago, last ping sent ").concat(h - n, "ms ago")),
|
|
814
|
+
console.warn("Heartbeat timed out, closing connection, last message received ".concat(h - u, "ms ago, last ping sent ").concat(h - n, "ms ago")), E.close();
|
|
815
815
|
else if (u + c <= h && n + c <= h)
|
|
816
816
|
try {
|
|
817
|
-
typeof i == "function" ?
|
|
817
|
+
typeof i == "function" ? E.send(i()) : E.send(i), n = h;
|
|
818
818
|
} catch (b) {
|
|
819
|
-
console.error("Heartbeat failed, closing connection", b instanceof Error ? b.message : b),
|
|
819
|
+
console.error("Heartbeat failed, closing connection", b instanceof Error ? b.message : b), E.close();
|
|
820
820
|
}
|
|
821
821
|
}, t);
|
|
822
|
-
return
|
|
822
|
+
return E.addEventListener("close", function() {
|
|
823
823
|
clearInterval(v);
|
|
824
824
|
}), function() {
|
|
825
825
|
};
|
|
@@ -830,49 +830,49 @@ var he = {}, Fe = {}, yr;
|
|
|
830
830
|
function $e() {
|
|
831
831
|
return yr || (yr = 1, (function(r) {
|
|
832
832
|
Object.defineProperty(r, "__esModule", { value: !0 }), r.resetSubscribers = r.removeSubscriber = r.addSubscriber = r.hasSubscribers = r.getSubscribers = void 0;
|
|
833
|
-
var y = {}, O = [],
|
|
833
|
+
var y = {}, O = [], E = function(c) {
|
|
834
834
|
return (0, r.hasSubscribers)(c) ? Array.from(y[c]) : O;
|
|
835
835
|
};
|
|
836
|
-
r.getSubscribers =
|
|
836
|
+
r.getSubscribers = E;
|
|
837
837
|
var f = function(c) {
|
|
838
838
|
var l;
|
|
839
839
|
return ((l = y[c]) === null || l === void 0 ? void 0 : l.size) > 0;
|
|
840
840
|
};
|
|
841
841
|
r.hasSubscribers = f;
|
|
842
|
-
var
|
|
842
|
+
var _ = function(c, l) {
|
|
843
843
|
y[c] = y[c] || /* @__PURE__ */ new Set(), y[c].add(l);
|
|
844
844
|
};
|
|
845
|
-
r.addSubscriber =
|
|
845
|
+
r.addSubscriber = _;
|
|
846
846
|
var S = function(c, l) {
|
|
847
847
|
y[c].delete(l);
|
|
848
848
|
};
|
|
849
849
|
r.removeSubscriber = S;
|
|
850
|
-
var
|
|
850
|
+
var d = function(c) {
|
|
851
851
|
if (c && y.hasOwnProperty(c))
|
|
852
852
|
delete y[c];
|
|
853
853
|
else
|
|
854
854
|
for (var l in y)
|
|
855
855
|
y.hasOwnProperty(l) && delete y[l];
|
|
856
856
|
};
|
|
857
|
-
r.resetSubscribers =
|
|
857
|
+
r.resetSubscribers = d;
|
|
858
858
|
})(Fe)), Fe;
|
|
859
859
|
}
|
|
860
860
|
var br;
|
|
861
861
|
function Be() {
|
|
862
862
|
if (br) return he;
|
|
863
|
-
br = 1, Object.defineProperty(he, "__esModule", { value: !0 }), he.assertIsWebSocket = O, he.resetGlobalState =
|
|
863
|
+
br = 1, Object.defineProperty(he, "__esModule", { value: !0 }), he.assertIsWebSocket = O, he.resetGlobalState = E;
|
|
864
864
|
var r = He(), y = $e();
|
|
865
|
-
function O(f,
|
|
866
|
-
if (!
|
|
865
|
+
function O(f, _) {
|
|
866
|
+
if (!_ && !(f instanceof WebSocket))
|
|
867
867
|
throw new Error("");
|
|
868
868
|
}
|
|
869
|
-
function
|
|
869
|
+
function E(f) {
|
|
870
870
|
(0, y.resetSubscribers)(f), (0, r.resetWebSockets)(f);
|
|
871
871
|
}
|
|
872
872
|
return he;
|
|
873
873
|
}
|
|
874
874
|
var gr;
|
|
875
|
-
function
|
|
875
|
+
function _t() {
|
|
876
876
|
if (gr) return te;
|
|
877
877
|
gr = 1;
|
|
878
878
|
var r = te && te.__assign || function() {
|
|
@@ -885,33 +885,33 @@ function Et() {
|
|
|
885
885
|
}, r.apply(this, arguments);
|
|
886
886
|
};
|
|
887
887
|
Object.defineProperty(te, "__esModule", { value: !0 }), te.attachListeners = void 0;
|
|
888
|
-
var y = Ve(), O = Nr(),
|
|
888
|
+
var y = Ve(), O = Nr(), E = V(), f = Be(), _ = function(o, a, i, t) {
|
|
889
889
|
o.onmessage = function(n) {
|
|
890
890
|
var v;
|
|
891
891
|
a.current.onMessage && a.current.onMessage(n), typeof t?.current == "number" && (t.current = Date.now()), !(typeof a.current.filter == "function" && a.current.filter(n) !== !0) && (a.current.heartbeat && typeof a.current.heartbeat != "boolean" && ((v = a.current.heartbeat) === null || v === void 0 ? void 0 : v.returnMessage) === n.data || i(n));
|
|
892
892
|
};
|
|
893
893
|
}, S = function(o, a, i, t, n) {
|
|
894
894
|
o.onopen = function(v) {
|
|
895
|
-
if (a.current.onOpen && a.current.onOpen(v), t.current = 0, i(
|
|
895
|
+
if (a.current.onOpen && a.current.onOpen(v), t.current = 0, i(E.ReadyState.OPEN), a.current.heartbeat && o instanceof WebSocket) {
|
|
896
896
|
var h = typeof a.current.heartbeat == "boolean" ? void 0 : a.current.heartbeat;
|
|
897
897
|
n.current = Date.now(), (0, O.heartbeat)(o, n, h);
|
|
898
898
|
}
|
|
899
899
|
};
|
|
900
|
-
},
|
|
901
|
-
if (
|
|
900
|
+
}, d = function(o, a, i, t, n) {
|
|
901
|
+
if (E.isEventSourceSupported && o instanceof EventSource)
|
|
902
902
|
return function() {
|
|
903
903
|
};
|
|
904
904
|
(0, f.assertIsWebSocket)(o, a.current.skipAssert);
|
|
905
905
|
var v;
|
|
906
906
|
return o.onclose = function(h) {
|
|
907
907
|
var u;
|
|
908
|
-
if (a.current.onClose && a.current.onClose(h), i(
|
|
909
|
-
var b = (u = a.current.reconnectAttempts) !== null && u !== void 0 ? u :
|
|
908
|
+
if (a.current.onClose && a.current.onClose(h), i(E.ReadyState.CLOSED), a.current.shouldReconnect && a.current.shouldReconnect(h)) {
|
|
909
|
+
var b = (u = a.current.reconnectAttempts) !== null && u !== void 0 ? u : E.DEFAULT_RECONNECT_LIMIT;
|
|
910
910
|
if (n.current < b) {
|
|
911
911
|
var C = typeof a.current.reconnectInterval == "function" ? a.current.reconnectInterval(n.current) : a.current.reconnectInterval;
|
|
912
912
|
v = window.setTimeout(function() {
|
|
913
913
|
n.current++, t();
|
|
914
|
-
}, C ??
|
|
914
|
+
}, C ?? E.DEFAULT_RECONNECT_INTERVAL_MS);
|
|
915
915
|
} else
|
|
916
916
|
a.current.onReconnectStop && a.current.onReconnectStop(b), console.warn("Max reconnect attempts of ".concat(b, " exceeded"));
|
|
917
917
|
}
|
|
@@ -922,12 +922,12 @@ function Et() {
|
|
|
922
922
|
var v;
|
|
923
923
|
return o.onerror = function(h) {
|
|
924
924
|
var u;
|
|
925
|
-
if (a.current.onError && a.current.onError(h),
|
|
926
|
-
if (n.current < ((u = a.current.reconnectAttempts) !== null && u !== void 0 ? u :
|
|
925
|
+
if (a.current.onError && a.current.onError(h), E.isEventSourceSupported && o instanceof EventSource && (a.current.onClose && a.current.onClose(r(r({}, h), { code: 1006, reason: "An error occurred with the EventSource: ".concat(h), wasClean: !1 })), i(E.ReadyState.CLOSED), o.close()), a.current.retryOnError)
|
|
926
|
+
if (n.current < ((u = a.current.reconnectAttempts) !== null && u !== void 0 ? u : E.DEFAULT_RECONNECT_LIMIT)) {
|
|
927
927
|
var b = typeof a.current.reconnectInterval == "function" ? a.current.reconnectInterval(n.current) : a.current.reconnectInterval;
|
|
928
928
|
v = window.setTimeout(function() {
|
|
929
929
|
n.current++, t();
|
|
930
|
-
}, b ??
|
|
930
|
+
}, b ?? E.DEFAULT_RECONNECT_INTERVAL_MS);
|
|
931
931
|
} else
|
|
932
932
|
a.current.onReconnectStop && a.current.onReconnectStop(a.current.reconnectAttempts), console.warn("Max reconnect attempts of ".concat(a.current.reconnectAttempts, " exceeded"));
|
|
933
933
|
}, function() {
|
|
@@ -935,8 +935,8 @@ function Et() {
|
|
|
935
935
|
};
|
|
936
936
|
}, l = function(o, a, i, t, n, v, h) {
|
|
937
937
|
var u = a.setLastMessage, b = a.setReadyState, C, P, T;
|
|
938
|
-
return i.current.fromSocketIO && (C = (0, y.setUpSocketIOPing)(h)),
|
|
939
|
-
b(
|
|
938
|
+
return i.current.fromSocketIO && (C = (0, y.setUpSocketIOPing)(h)), _(o, i, u, v), S(o, i, b, n, v), P = d(o, i, b, t, n), T = c(o, i, b, t, n), function() {
|
|
939
|
+
b(E.ReadyState.CLOSING), P(), T(), o.close(), C && clearInterval(C);
|
|
940
940
|
};
|
|
941
941
|
};
|
|
942
942
|
return te.attachListeners = l, te;
|
|
@@ -955,27 +955,27 @@ function St() {
|
|
|
955
955
|
}, r.apply(this, arguments);
|
|
956
956
|
};
|
|
957
957
|
Object.defineProperty(ne, "__esModule", { value: !0 }), ne.attachSharedListeners = void 0;
|
|
958
|
-
var y = He(), O = V(),
|
|
958
|
+
var y = He(), O = V(), E = $e(), f = Ve(), _ = Nr(), S = function(a, i, t) {
|
|
959
959
|
a.onmessage = function(n) {
|
|
960
|
-
(0,
|
|
960
|
+
(0, E.getSubscribers)(i).forEach(function(v) {
|
|
961
961
|
var h;
|
|
962
962
|
v.optionsRef.current.onMessage && v.optionsRef.current.onMessage(n), typeof ((h = v?.lastMessageTime) === null || h === void 0 ? void 0 : h.current) == "number" && (v.lastMessageTime.current = Date.now()), !(typeof v.optionsRef.current.filter == "function" && v.optionsRef.current.filter(n) !== !0) && (t && typeof t != "boolean" && t?.returnMessage === n.data || v.setLastMessage(n));
|
|
963
963
|
});
|
|
964
964
|
};
|
|
965
|
-
},
|
|
965
|
+
}, d = function(a, i, t) {
|
|
966
966
|
a.onopen = function(n) {
|
|
967
|
-
var v = (0,
|
|
967
|
+
var v = (0, E.getSubscribers)(i);
|
|
968
968
|
v.forEach(function(h) {
|
|
969
969
|
h.reconnectCount.current = 0, h.optionsRef.current.onOpen && h.optionsRef.current.onOpen(n), h.setReadyState(O.ReadyState.OPEN), t && a instanceof WebSocket && (h.lastMessageTime.current = Date.now());
|
|
970
|
-
}), t && a instanceof WebSocket && (0,
|
|
970
|
+
}), t && a instanceof WebSocket && (0, _.heartbeat)(a, v.map(function(h) {
|
|
971
971
|
return h.lastMessageTime;
|
|
972
972
|
}), typeof t == "boolean" ? void 0 : t);
|
|
973
973
|
};
|
|
974
974
|
}, c = function(a, i) {
|
|
975
975
|
a instanceof WebSocket && (a.onclose = function(t) {
|
|
976
|
-
(0,
|
|
976
|
+
(0, E.getSubscribers)(i).forEach(function(n) {
|
|
977
977
|
n.optionsRef.current.onClose && n.optionsRef.current.onClose(t), n.setReadyState(O.ReadyState.CLOSED);
|
|
978
|
-
}), delete y.sharedWebSockets[i], (0,
|
|
978
|
+
}), delete y.sharedWebSockets[i], (0, E.getSubscribers)(i).forEach(function(n) {
|
|
979
979
|
var v;
|
|
980
980
|
if (n.optionsRef.current.shouldReconnect && n.optionsRef.current.shouldReconnect(t)) {
|
|
981
981
|
var h = (v = n.optionsRef.current.reconnectAttempts) !== null && v !== void 0 ? v : O.DEFAULT_RECONNECT_LIMIT;
|
|
@@ -991,13 +991,13 @@ function St() {
|
|
|
991
991
|
});
|
|
992
992
|
}, l = function(a, i) {
|
|
993
993
|
a.onerror = function(t) {
|
|
994
|
-
(0,
|
|
994
|
+
(0, E.getSubscribers)(i).forEach(function(n) {
|
|
995
995
|
n.optionsRef.current.onError && n.optionsRef.current.onError(t), O.isEventSourceSupported && a instanceof EventSource && (n.optionsRef.current.onClose && n.optionsRef.current.onClose(r(r({}, t), { code: 1006, reason: "An error occurred with the EventSource: ".concat(t), wasClean: !1 })), n.setReadyState(O.ReadyState.CLOSED));
|
|
996
996
|
}), O.isEventSourceSupported && a instanceof EventSource && a.close();
|
|
997
997
|
};
|
|
998
998
|
}, o = function(a, i, t, n) {
|
|
999
999
|
var v;
|
|
1000
|
-
return t.current.fromSocketIO && (v = (0, f.setUpSocketIOPing)(n)), S(a, i, t.current.heartbeat), c(a, i),
|
|
1000
|
+
return t.current.fromSocketIO && (v = (0, f.setUpSocketIOPing)(n)), S(a, i, t.current.heartbeat), c(a, i), d(a, i, t.current.heartbeat), l(a, i), function() {
|
|
1001
1001
|
v && clearInterval(v);
|
|
1002
1002
|
};
|
|
1003
1003
|
};
|
|
@@ -1007,25 +1007,25 @@ var pr;
|
|
|
1007
1007
|
function ht() {
|
|
1008
1008
|
if (pr) return Se;
|
|
1009
1009
|
pr = 1, Object.defineProperty(Se, "__esModule", { value: !0 }), Se.createOrJoinSocket = void 0;
|
|
1010
|
-
var r = He(), y = V(), O =
|
|
1010
|
+
var r = He(), y = V(), O = _t(), E = St(), f = $e(), _ = function(d, c, l, o, a) {
|
|
1011
1011
|
return function() {
|
|
1012
|
-
if ((0, f.removeSubscriber)(
|
|
1012
|
+
if ((0, f.removeSubscriber)(d, c), !(0, f.hasSubscribers)(d)) {
|
|
1013
1013
|
try {
|
|
1014
|
-
var i = r.sharedWebSockets[
|
|
1014
|
+
var i = r.sharedWebSockets[d];
|
|
1015
1015
|
i instanceof WebSocket && (i.onclose = function(t) {
|
|
1016
1016
|
l.current.onClose && l.current.onClose(t), o(y.ReadyState.CLOSED);
|
|
1017
1017
|
}), i.close();
|
|
1018
1018
|
} catch {
|
|
1019
1019
|
}
|
|
1020
|
-
a && a(), delete r.sharedWebSockets[
|
|
1020
|
+
a && a(), delete r.sharedWebSockets[d];
|
|
1021
1021
|
}
|
|
1022
1022
|
};
|
|
1023
|
-
}, S = function(
|
|
1023
|
+
}, S = function(d, c, l, o, a, i, t, n, v) {
|
|
1024
1024
|
if (!y.isEventSourceSupported && o.current.eventSourceOptions)
|
|
1025
1025
|
throw y.isReactNative ? new Error("EventSource is not supported in ReactNative") : new Error("EventSource is not supported");
|
|
1026
1026
|
if (o.current.share) {
|
|
1027
1027
|
var h = null;
|
|
1028
|
-
r.sharedWebSockets[c] === void 0 ? (r.sharedWebSockets[c] = o.current.eventSourceOptions ? new EventSource(c, o.current.eventSourceOptions) : new WebSocket(c, o.current.protocols),
|
|
1028
|
+
r.sharedWebSockets[c] === void 0 ? (r.sharedWebSockets[c] = o.current.eventSourceOptions ? new EventSource(c, o.current.eventSourceOptions) : new WebSocket(c, o.current.protocols), d.current = r.sharedWebSockets[c], l(y.ReadyState.CONNECTING), h = (0, E.attachSharedListeners)(r.sharedWebSockets[c], c, o, v)) : (d.current = r.sharedWebSockets[c], l(r.sharedWebSockets[c].readyState));
|
|
1029
1029
|
var u = {
|
|
1030
1030
|
setLastMessage: a,
|
|
1031
1031
|
setReadyState: l,
|
|
@@ -1034,11 +1034,11 @@ function ht() {
|
|
|
1034
1034
|
lastMessageTime: n,
|
|
1035
1035
|
reconnect: i
|
|
1036
1036
|
};
|
|
1037
|
-
return (0, f.addSubscriber)(c, u),
|
|
1037
|
+
return (0, f.addSubscriber)(c, u), _(c, u, o, l, h);
|
|
1038
1038
|
} else {
|
|
1039
|
-
if (
|
|
1039
|
+
if (d.current = o.current.eventSourceOptions ? new EventSource(c, o.current.eventSourceOptions) : new WebSocket(c, o.current.protocols), l(y.ReadyState.CONNECTING), !d.current)
|
|
1040
1040
|
throw new Error("WebSocket failed to be created");
|
|
1041
|
-
return (0, O.attachListeners)(
|
|
1041
|
+
return (0, O.attachListeners)(d.current, {
|
|
1042
1042
|
setLastMessage: a,
|
|
1043
1043
|
setReadyState: l
|
|
1044
1044
|
}, o, i.current, t, n, v);
|
|
@@ -1134,20 +1134,20 @@ function yt() {
|
|
|
1134
1134
|
if (u[0] & 5) throw u[1];
|
|
1135
1135
|
return { value: u[0] ? u[1] : void 0, done: !0 };
|
|
1136
1136
|
}
|
|
1137
|
-
},
|
|
1137
|
+
}, E = x && x.__spreadArray || function(c, l, o) {
|
|
1138
1138
|
if (o || arguments.length === 2) for (var a = 0, i = l.length, t; a < i; a++)
|
|
1139
1139
|
(t || !(a in l)) && (t || (t = Array.prototype.slice.call(l, 0, a)), t[a] = l[a]);
|
|
1140
1140
|
return c.concat(t || Array.prototype.slice.call(l));
|
|
1141
1141
|
};
|
|
1142
1142
|
Object.defineProperty(r, "__esModule", { value: !0 }), r.getUrl = void 0;
|
|
1143
|
-
var f = Ve(),
|
|
1143
|
+
var f = Ve(), _ = V(), S = function(c) {
|
|
1144
1144
|
return new Promise(function(l) {
|
|
1145
1145
|
return window.setTimeout(l, c);
|
|
1146
1146
|
});
|
|
1147
|
-
},
|
|
1147
|
+
}, d = function(c, l) {
|
|
1148
1148
|
for (var o = [], a = 2; a < arguments.length; a++)
|
|
1149
1149
|
o[a - 2] = arguments[a];
|
|
1150
|
-
return y(void 0,
|
|
1150
|
+
return y(void 0, E([c, l], o, !0), void 0, function(i, t, n) {
|
|
1151
1151
|
var v, h, u, b, C, P, T, A;
|
|
1152
1152
|
return n === void 0 && (n = 0), O(this, function(I) {
|
|
1153
1153
|
switch (I.label) {
|
|
@@ -1159,7 +1159,7 @@ function yt() {
|
|
|
1159
1159
|
case 2:
|
|
1160
1160
|
return v = I.sent(), [3, 9];
|
|
1161
1161
|
case 3:
|
|
1162
|
-
return I.sent(), t.current.retryOnError ? (h = (P = t.current.reconnectAttempts) !== null && P !== void 0 ? P :
|
|
1162
|
+
return I.sent(), t.current.retryOnError ? (h = (P = t.current.reconnectAttempts) !== null && P !== void 0 ? P : _.DEFAULT_RECONNECT_LIMIT, n < h ? (u = typeof t.current.reconnectInterval == "function" ? t.current.reconnectInterval(n) : t.current.reconnectInterval, [4, S(u ?? _.DEFAULT_RECONNECT_INTERVAL_MS)]) : [3, 5]) : [3, 7];
|
|
1163
1163
|
case 4:
|
|
1164
1164
|
return I.sent(), [2, (0, r.getUrl)(i, t, n + 1)];
|
|
1165
1165
|
case 5:
|
|
@@ -1180,22 +1180,22 @@ function yt() {
|
|
|
1180
1180
|
});
|
|
1181
1181
|
});
|
|
1182
1182
|
};
|
|
1183
|
-
r.getUrl =
|
|
1183
|
+
r.getUrl = d;
|
|
1184
1184
|
})(x)), x;
|
|
1185
1185
|
}
|
|
1186
1186
|
var qe = {}, mr;
|
|
1187
1187
|
function bt() {
|
|
1188
1188
|
return mr || (mr = 1, (function(r) {
|
|
1189
1189
|
Object.defineProperty(r, "__esModule", { value: !0 }), r.websocketWrapper = void 0;
|
|
1190
|
-
var y = function(O,
|
|
1190
|
+
var y = function(O, E) {
|
|
1191
1191
|
return new Proxy(O, {
|
|
1192
|
-
get: function(f,
|
|
1193
|
-
var S = f[
|
|
1194
|
-
return
|
|
1192
|
+
get: function(f, _) {
|
|
1193
|
+
var S = f[_];
|
|
1194
|
+
return _ === "reconnect" ? E : typeof S == "function" ? (console.error("Calling methods directly on the websocket is not supported at this moment. You must use the methods returned by useWebSocket."), function() {
|
|
1195
1195
|
}) : S;
|
|
1196
1196
|
},
|
|
1197
|
-
set: function(f,
|
|
1198
|
-
return /^on/.test(
|
|
1197
|
+
set: function(f, _, S) {
|
|
1198
|
+
return /^on/.test(_) ? (console.warn("The websocket's event handlers should be defined through the options object passed into useWebSocket."), !1) : (f[_] = S, !0);
|
|
1199
1199
|
}
|
|
1200
1200
|
});
|
|
1201
1201
|
};
|
|
@@ -1299,11 +1299,11 @@ function Ye() {
|
|
|
1299
1299
|
if (T[0] & 5) throw T[1];
|
|
1300
1300
|
return { value: T[0] ? T[1] : void 0, done: !0 };
|
|
1301
1301
|
}
|
|
1302
|
-
},
|
|
1302
|
+
}, E = F && F.__importDefault || function(i) {
|
|
1303
1303
|
return i && i.__esModule ? i : { default: i };
|
|
1304
1304
|
};
|
|
1305
1305
|
Object.defineProperty(F, "__esModule", { value: !0 }), F.useWebSocket = void 0;
|
|
1306
|
-
var f = ye,
|
|
1306
|
+
var f = ye, _ = st, S = V(), d = ht(), c = yt(), l = E(bt()), o = Be(), a = function(i, t, n) {
|
|
1307
1307
|
t === void 0 && (t = S.DEFAULT_OPTIONS), n === void 0 && (n = !0);
|
|
1308
1308
|
var v = (0, f.useState)(null), h = v[0], u = v[1], b = (0, f.useState)({}), C = b[0], P = b[1], T = (0, f.useMemo)(function() {
|
|
1309
1309
|
if (!t.disableJson && h)
|
|
@@ -1338,7 +1338,7 @@ function Ye() {
|
|
|
1338
1338
|
case 0:
|
|
1339
1339
|
return Z = A, [4, (0, c.getUrl)(i, L)];
|
|
1340
1340
|
case 1:
|
|
1341
|
-
return Z.current = oe.sent(), A.current === null ? (console.error("Failed to get a valid URL. WebSocket connection aborted."), A.current = "ABORTED", (0,
|
|
1341
|
+
return Z.current = oe.sent(), A.current === null ? (console.error("Failed to get a valid URL. WebSocket connection aborted."), A.current = "ABORTED", (0, _.flushSync)(function() {
|
|
1342
1342
|
return P(function(Y) {
|
|
1343
1343
|
return r(r({}, Y), { ABORTED: S.ReadyState.CLOSED });
|
|
1344
1344
|
});
|
|
@@ -1346,17 +1346,17 @@ function Ye() {
|
|
|
1346
1346
|
2
|
|
1347
1347
|
/*return*/
|
|
1348
1348
|
]) : (z = function(Y) {
|
|
1349
|
-
j || (0,
|
|
1349
|
+
j || (0, _.flushSync)(function() {
|
|
1350
1350
|
return u(Y);
|
|
1351
1351
|
});
|
|
1352
1352
|
}, pe = function(Y) {
|
|
1353
|
-
j || (0,
|
|
1353
|
+
j || (0, _.flushSync)(function() {
|
|
1354
1354
|
return P(function(ue) {
|
|
1355
1355
|
var ee;
|
|
1356
1356
|
return r(r({}, ue), A.current && (ee = {}, ee[A.current] = Y, ee));
|
|
1357
1357
|
});
|
|
1358
1358
|
});
|
|
1359
|
-
}, B && (D = (0,
|
|
1359
|
+
}, B && (D = (0, d.createOrJoinSocket)(I, A.current, pe, L, z, se, le, ke, $)), [
|
|
1360
1360
|
2
|
|
1361
1361
|
/*return*/
|
|
1362
1362
|
]);
|
|
@@ -1393,22 +1393,22 @@ function gt() {
|
|
|
1393
1393
|
if (Cr) return ae;
|
|
1394
1394
|
Cr = 1;
|
|
1395
1395
|
var r = ae && ae.__assign || function() {
|
|
1396
|
-
return r = Object.assign || function(
|
|
1396
|
+
return r = Object.assign || function(d) {
|
|
1397
1397
|
for (var c, l = 1, o = arguments.length; l < o; l++) {
|
|
1398
1398
|
c = arguments[l];
|
|
1399
|
-
for (var a in c) Object.prototype.hasOwnProperty.call(c, a) && (
|
|
1399
|
+
for (var a in c) Object.prototype.hasOwnProperty.call(c, a) && (d[a] = c[a]);
|
|
1400
1400
|
}
|
|
1401
|
-
return
|
|
1401
|
+
return d;
|
|
1402
1402
|
}, r.apply(this, arguments);
|
|
1403
1403
|
};
|
|
1404
1404
|
Object.defineProperty(ae, "__esModule", { value: !0 }), ae.useSocketIO = void 0;
|
|
1405
|
-
var y = ye, O = Ye(),
|
|
1405
|
+
var y = ye, O = Ye(), E = V(), f = {
|
|
1406
1406
|
type: "empty",
|
|
1407
1407
|
payload: null
|
|
1408
|
-
},
|
|
1409
|
-
if (!
|
|
1408
|
+
}, _ = function(d) {
|
|
1409
|
+
if (!d || !d.data)
|
|
1410
1410
|
return f;
|
|
1411
|
-
var c =
|
|
1411
|
+
var c = d.data.match(/\[.*]/);
|
|
1412
1412
|
if (!c)
|
|
1413
1413
|
return f;
|
|
1414
1414
|
var l = JSON.parse(c);
|
|
@@ -1416,12 +1416,12 @@ function gt() {
|
|
|
1416
1416
|
type: l[0],
|
|
1417
1417
|
payload: l[1]
|
|
1418
1418
|
};
|
|
1419
|
-
}, S = function(
|
|
1420
|
-
c === void 0 && (c =
|
|
1419
|
+
}, S = function(d, c, l) {
|
|
1420
|
+
c === void 0 && (c = E.DEFAULT_OPTIONS), l === void 0 && (l = !0);
|
|
1421
1421
|
var o = (0, y.useMemo)(function() {
|
|
1422
1422
|
return r(r({}, c), { fromSocketIO: !0 });
|
|
1423
|
-
}, []), a = (0, O.useWebSocket)(
|
|
1424
|
-
return
|
|
1423
|
+
}, []), a = (0, O.useWebSocket)(d, o, l), i = a.sendMessage, t = a.sendJsonMessage, n = a.lastMessage, v = a.readyState, h = a.getWebSocket, u = (0, y.useMemo)(function() {
|
|
1424
|
+
return _(n);
|
|
1425
1425
|
}, [n]);
|
|
1426
1426
|
return {
|
|
1427
1427
|
sendMessage: i,
|
|
@@ -1440,30 +1440,30 @@ function Ot() {
|
|
|
1440
1440
|
wr = 1;
|
|
1441
1441
|
var r = Q && Q.__assign || function() {
|
|
1442
1442
|
return r = Object.assign || function(S) {
|
|
1443
|
-
for (var
|
|
1444
|
-
|
|
1445
|
-
for (var o in
|
|
1443
|
+
for (var d, c = 1, l = arguments.length; c < l; c++) {
|
|
1444
|
+
d = arguments[c];
|
|
1445
|
+
for (var o in d) Object.prototype.hasOwnProperty.call(d, o) && (S[o] = d[o]);
|
|
1446
1446
|
}
|
|
1447
1447
|
return S;
|
|
1448
1448
|
}, r.apply(this, arguments);
|
|
1449
|
-
}, y = Q && Q.__rest || function(S,
|
|
1449
|
+
}, y = Q && Q.__rest || function(S, d) {
|
|
1450
1450
|
var c = {};
|
|
1451
|
-
for (var l in S) Object.prototype.hasOwnProperty.call(S, l) &&
|
|
1451
|
+
for (var l in S) Object.prototype.hasOwnProperty.call(S, l) && d.indexOf(l) < 0 && (c[l] = S[l]);
|
|
1452
1452
|
if (S != null && typeof Object.getOwnPropertySymbols == "function")
|
|
1453
1453
|
for (var o = 0, l = Object.getOwnPropertySymbols(S); o < l.length; o++)
|
|
1454
|
-
|
|
1454
|
+
d.indexOf(l[o]) < 0 && Object.prototype.propertyIsEnumerable.call(S, l[o]) && (c[l[o]] = S[l[o]]);
|
|
1455
1455
|
return c;
|
|
1456
1456
|
};
|
|
1457
1457
|
Object.defineProperty(Q, "__esModule", { value: !0 }), Q.useEventSource = void 0;
|
|
1458
|
-
var O = ye,
|
|
1459
|
-
|
|
1460
|
-
var l =
|
|
1458
|
+
var O = ye, E = Ye(), f = V(), _ = function(S, d, c) {
|
|
1459
|
+
d === void 0 && (d = f.DEFAULT_EVENT_SOURCE_OPTIONS);
|
|
1460
|
+
var l = d.withCredentials, o = d.events, a = y(d, ["withCredentials", "events"]);
|
|
1461
1461
|
c === void 0 && (c = !0);
|
|
1462
1462
|
var i = r(r({}, a), { eventSourceOptions: {
|
|
1463
1463
|
withCredentials: l
|
|
1464
1464
|
} }), t = (0, O.useRef)(f.EMPTY_EVENT_HANDLERS);
|
|
1465
1465
|
o && (t.current = o);
|
|
1466
|
-
var n = (0,
|
|
1466
|
+
var n = (0, E.useWebSocket)(S, i, c), v = n.lastMessage, h = n.readyState, u = n.getWebSocket;
|
|
1467
1467
|
return (0, O.useEffect)(function() {
|
|
1468
1468
|
v?.type && Object.entries(t.current).forEach(function(b) {
|
|
1469
1469
|
var C = b[0], P = b[1];
|
|
@@ -1475,7 +1475,7 @@ function Ot() {
|
|
|
1475
1475
|
getEventSource: u
|
|
1476
1476
|
};
|
|
1477
1477
|
};
|
|
1478
|
-
return Q.useEventSource =
|
|
1478
|
+
return Q.useEventSource = _, Q;
|
|
1479
1479
|
}
|
|
1480
1480
|
var Ar;
|
|
1481
1481
|
function pt() {
|
|
@@ -1489,17 +1489,17 @@ function pt() {
|
|
|
1489
1489
|
Object.defineProperty(r, "useSocketIO", { enumerable: !0, get: function() {
|
|
1490
1490
|
return O.useSocketIO;
|
|
1491
1491
|
} });
|
|
1492
|
-
var
|
|
1492
|
+
var E = V();
|
|
1493
1493
|
Object.defineProperty(r, "ReadyState", { enumerable: !0, get: function() {
|
|
1494
|
-
return
|
|
1494
|
+
return E.ReadyState;
|
|
1495
1495
|
} });
|
|
1496
1496
|
var f = Ot();
|
|
1497
1497
|
Object.defineProperty(r, "useEventSource", { enumerable: !0, get: function() {
|
|
1498
1498
|
return f.useEventSource;
|
|
1499
1499
|
} });
|
|
1500
|
-
var
|
|
1500
|
+
var _ = Be();
|
|
1501
1501
|
Object.defineProperty(r, "resetGlobalState", { enumerable: !0, get: function() {
|
|
1502
|
-
return
|
|
1502
|
+
return _.resetGlobalState;
|
|
1503
1503
|
} });
|
|
1504
1504
|
})(je)), je;
|
|
1505
1505
|
}
|
|
@@ -1520,12 +1520,12 @@ const mt = /* @__PURE__ */ lt(Tt), H = {
|
|
|
1520
1520
|
socketHandlers: y = {},
|
|
1521
1521
|
options: O = {}
|
|
1522
1522
|
}) => {
|
|
1523
|
-
const
|
|
1524
|
-
sendMessage:
|
|
1523
|
+
const E = sr(!1), f = sr(y), {
|
|
1524
|
+
sendMessage: _,
|
|
1525
1525
|
// 發送普通訊息
|
|
1526
1526
|
sendJsonMessage: S,
|
|
1527
1527
|
// 發送 JSON 訊息
|
|
1528
|
-
lastMessage:
|
|
1528
|
+
lastMessage: d,
|
|
1529
1529
|
// 最後接收到的訊息
|
|
1530
1530
|
// lastJsonMessage, // 最後接收到的 JSON 訊息
|
|
1531
1531
|
readyState: c
|
|
@@ -1534,24 +1534,24 @@ const mt = /* @__PURE__ */ lt(Tt), H = {
|
|
|
1534
1534
|
} = mt(r, {
|
|
1535
1535
|
queryParams: { key: "wsky" },
|
|
1536
1536
|
onOpen: () => console.log("連線成功"),
|
|
1537
|
-
shouldReconnect: () =>
|
|
1537
|
+
shouldReconnect: () => E.current === !1,
|
|
1538
1538
|
reconnectAttempts: 9999,
|
|
1539
1539
|
reconnectInterval: 1e3,
|
|
1540
1540
|
...O
|
|
1541
1541
|
}), l = Ge(() => {
|
|
1542
1542
|
try {
|
|
1543
|
-
return JSON.parse(
|
|
1543
|
+
return JSON.parse(d?.data);
|
|
1544
1544
|
} catch {
|
|
1545
1545
|
return null;
|
|
1546
1546
|
}
|
|
1547
|
-
}, [
|
|
1547
|
+
}, [d?.data]);
|
|
1548
1548
|
return Ce(() => {
|
|
1549
1549
|
const o = setInterval(
|
|
1550
|
-
() =>
|
|
1550
|
+
() => _("ping"),
|
|
1551
1551
|
Rt
|
|
1552
1552
|
);
|
|
1553
1553
|
return () => clearInterval(o);
|
|
1554
|
-
}, [
|
|
1554
|
+
}, [_]), Ce(() => {
|
|
1555
1555
|
f.current = y;
|
|
1556
1556
|
}, [y]), Ce(() => {
|
|
1557
1557
|
if (!l) return;
|
|
@@ -1603,8 +1603,8 @@ const mt = /* @__PURE__ */ lt(Tt), H = {
|
|
|
1603
1603
|
console.warn("Unknown socket type:", C);
|
|
1604
1604
|
break;
|
|
1605
1605
|
}
|
|
1606
|
-
}, [l]), Ce(() => () =>
|
|
1607
|
-
sendMessage:
|
|
1606
|
+
}, [l]), Ce(() => () => E.current = !0, []), {
|
|
1607
|
+
sendMessage: _,
|
|
1608
1608
|
sendJsonMessage: S,
|
|
1609
1609
|
readyState: c
|
|
1610
1610
|
// WebSocket 連線狀態
|
|
@@ -1619,8 +1619,8 @@ const mt = /* @__PURE__ */ lt(Tt), H = {
|
|
|
1619
1619
|
}
|
|
1620
1620
|
],
|
|
1621
1621
|
enabled: !!r
|
|
1622
|
-
}), { data:
|
|
1623
|
-
return { data:
|
|
1622
|
+
}), { data: E, isFetching: f, error: _ } = O[0] || {};
|
|
1623
|
+
return { data: E, isFetching: f, error: _ };
|
|
1624
1624
|
};
|
|
1625
1625
|
export {
|
|
1626
1626
|
kr as ApiCtx,
|