@wellesley/ws 1.0.136 → 1.0.137
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.mjs +21 -3
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -1,4 +1,22 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{rootReducer as St}from"https://cdn.jsdelivr.net/npm/@wellesley/store@1.0.154";import{logErrorToSentry as Ct}from"https://cdn.jsdelivr.net/npm/@wellesley/sentry@1.0.21";import{authSlice as Et}from"https://cdn.jsdelivr.net/npm/@wellesley/auth@1.0.211";function Rt(e,t){for(var r=0;r<t.length;r++){const n=t[r];if("string"!=typeof n&&!Array.isArray(n))for(const t in n)if("default"!==t&&!(t in e)){const r=Object.getOwnPropertyDescriptor(n,t);r&&Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:()=>n[t]})}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}function Ot(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ze,$e,be={exports:{}},p={};
|
|
2
|
+
/**
|
|
3
|
+
* @license React
|
|
4
|
+
* react.production.min.js
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
7
|
+
*
|
|
8
|
+
* This source code is licensed under the MIT license found in the
|
|
9
|
+
* LICENSE file in the root directory of this source tree.
|
|
10
|
+
*/function xt(){if(ze)return p;ze=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),n=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),s=Symbol.for("react.provider"),i=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),a=Symbol.for("react.memo"),l=Symbol.for("react.lazy"),f=Symbol.iterator;var d={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},h=Object.assign,y={};function _(e,t,r){this.props=e,this.context=t,this.refs=y,this.updater=r||d}function b(){}function m(e,t,r){this.props=e,this.context=t,this.refs=y,this.updater=r||d}_.prototype.isReactComponent={},_.prototype.setState=function(e,t){if("object"!=typeof e&&"function"!=typeof e&&null!=e)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")},_.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},b.prototype=_.prototype;var v=m.prototype=new b;v.constructor=m,h(v,_.prototype),v.isPureReactComponent=!0;var g=Array.isArray,w=Object.prototype.hasOwnProperty,S={current:null},O={key:!0,ref:!0,__self:!0,__source:!0};function E(t,r,n){var o,s={},i=null,c=null;if(null!=r)for(o in void 0!==r.ref&&(c=r.ref),void 0!==r.key&&(i=""+r.key),r)w.call(r,o)&&!O.hasOwnProperty(o)&&(s[o]=r[o]);var u=arguments.length-2;if(1===u)s.children=n;else if(1<u){for(var a=Array(u),l=0;l<u;l++)a[l]=arguments[l+2];s.children=a}if(t&&t.defaultProps)for(o in u=t.defaultProps)void 0===s[o]&&(s[o]=u[o]);return{$$typeof:e,type:t,key:i,ref:c,props:s,_owner:S.current}}function C(t){return"object"==typeof t&&null!==t&&t.$$typeof===e}var j=/\/+/g;function R(e,t){return"object"==typeof e&&null!==e&&null!=e.key?function(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,(function(e){return t[e]}))}(""+e.key):t.toString(36)}function T(r,n,o,s,i){var c=typeof r;("undefined"===c||"boolean"===c)&&(r=null);var u=!1;if(null===r)u=!0;else switch(c){case"string":case"number":u=!0;break;case"object":switch(r.$$typeof){case e:case t:u=!0}}if(u)return i=i(u=r),r=""===s?"."+R(u,0):s,g(i)?(o="",null!=r&&(o=r.replace(j,"$&/")+"/"),T(i,n,o,"",(function(e){return e}))):null!=i&&(C(i)&&(i=function(t,r){return{$$typeof:e,type:t.type,key:r,ref:t.ref,props:t.props,_owner:t._owner}}(i,o+(!i.key||u&&u.key===i.key?"":(""+i.key).replace(j,"$&/")+"/")+r)),n.push(i)),1;if(u=0,s=""===s?".":s+":",g(r))for(var a=0;a<r.length;a++){var l=s+R(c=r[a],a);u+=T(c,n,o,l,i)}else if(l=function(e){return null===e||"object"!=typeof e?null:"function"==typeof(e=f&&e[f]||e["@@iterator"])?e:null}(r),"function"==typeof l)for(r=l.call(r),a=0;!(c=r.next()).done;)u+=T(c=c.value,n,o,l=s+R(c,a++),i);else if("object"===c)throw n=String(r),Error("Objects are not valid as a React child (found: "+("[object Object]"===n?"object with keys {"+Object.keys(r).join(", ")+"}":n)+"). If you meant to render a collection of children, use an array instead.");return u}function k(e,t,r){if(null==e)return e;var n=[],o=0;return T(e,n,"","",(function(e){return t.call(r,e,o++)})),n}function P(e){if(-1===e._status){var t=e._result;(t=t()).then((function(t){(0===e._status||-1===e._status)&&(e._status=1,e._result=t)}),(function(t){(0===e._status||-1===e._status)&&(e._status=2,e._result=t)})),-1===e._status&&(e._status=0,e._result=t)}if(1===e._status)return e._result.default;throw e._result}var x={current:null},N={transition:null},A={ReactCurrentDispatcher:x,ReactCurrentBatchConfig:N,ReactCurrentOwner:S};return p.Children={map:k,forEach:function(e,t,r){k(e,(function(){t.apply(this,arguments)}),r)},count:function(e){var t=0;return k(e,(function(){t++})),t},toArray:function(e){return k(e,(function(e){return e}))||[]},only:function(e){if(!C(e))throw Error("React.Children.only expected to receive a single React element child.");return e}},p.Component=_,p.Fragment=r,p.Profiler=o,p.PureComponent=m,p.StrictMode=n,p.Suspense=u,p.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=A,p.cloneElement=function(t,r,n){if(null==t)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+t+".");var o=h({},t.props),s=t.key,i=t.ref,c=t._owner;if(null!=r){if(void 0!==r.ref&&(i=r.ref,c=S.current),void 0!==r.key&&(s=""+r.key),t.type&&t.type.defaultProps)var u=t.type.defaultProps;for(a in r)w.call(r,a)&&!O.hasOwnProperty(a)&&(o[a]=void 0===r[a]&&void 0!==u?u[a]:r[a])}var a=arguments.length-2;if(1===a)o.children=n;else if(1<a){u=Array(a);for(var l=0;l<a;l++)u[l]=arguments[l+2];o.children=u}return{$$typeof:e,type:t.type,key:s,ref:i,props:o,_owner:c}},p.createContext=function(e){return(e={$$typeof:i,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null}).Provider={$$typeof:s,_context:e},e.Consumer=e},p.createElement=E,p.createFactory=function(e){var t=E.bind(null,e);return t.type=e,t},p.createRef=function(){return{current:null}},p.forwardRef=function(e){return{$$typeof:c,render:e}},p.isValidElement=C,p.lazy=function(e){return{$$typeof:l,_payload:{_status:-1,_result:e},_init:P}},p.memo=function(e,t){return{$$typeof:a,type:e,compare:void 0===t?null:t}},p.startTransition=function(e){var t=N.transition;N.transition={};try{e()}finally{N.transition=t}},p.unstable_act=function(){throw Error("act(...) is not supported in production builds of React.")},p.useCallback=function(e,t){return x.current.useCallback(e,t)},p.useContext=function(e){return x.current.useContext(e)},p.useDebugValue=function(){},p.useDeferredValue=function(e){return x.current.useDeferredValue(e)},p.useEffect=function(e,t){return x.current.useEffect(e,t)},p.useId=function(){return x.current.useId()},p.useImperativeHandle=function(e,t,r){return x.current.useImperativeHandle(e,t,r)},p.useInsertionEffect=function(e,t){return x.current.useInsertionEffect(e,t)},p.useLayoutEffect=function(e,t){return x.current.useLayoutEffect(e,t)},p.useMemo=function(e,t){return x.current.useMemo(e,t)},p.useReducer=function(e,t,r){return x.current.useReducer(e,t,r)},p.useRef=function(e){return x.current.useRef(e)},p.useState=function(e){return x.current.useState(e)},p.useSyncExternalStore=function(e,t,r){return x.current.useSyncExternalStore(e,t,r)},p.useTransition=function(){return x.current.useTransition()},p.version="18.2.0",p}function tt(){return $e||($e=1,be.exports=xt()),be.exports}var W=tt();const rt=Ot(W),Fe=Rt({__proto__:null,default:rt},[W]);var We,Ue,ve={exports:{}},we={};
|
|
11
|
+
/**
|
|
12
|
+
* @license React
|
|
13
|
+
* use-sync-external-store-with-selector.production.min.js
|
|
14
|
+
*
|
|
15
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
16
|
+
*
|
|
17
|
+
* This source code is licensed under the MIT license found in the
|
|
18
|
+
* LICENSE file in the root directory of this source tree.
|
|
19
|
+
*/function Tt(){if(We)return we;We=1;var e=tt();var t="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},r=e.useSyncExternalStore,n=e.useRef,o=e.useEffect,s=e.useMemo,i=e.useDebugValue;return we.useSyncExternalStoreWithSelector=function(e,c,u,a,l){var f=n(null);if(null===f.current){var p={hasValue:!1,value:null};f.current=p}else p=f.current;f=s((function(){function e(e){if(!o){if(o=!0,r=e,e=a(e),void 0!==l&&p.hasValue){var s=p.value;if(l(s,e))return n=s}return n=e}if(s=n,t(r,e))return s;var i=a(e);return void 0!==l&&l(s,i)?s:(r=e,n=i)}var r,n,o=!1,s=void 0===u?null:u;return[function(){return e(c())},null===s?void 0:function(){return e(s())}]}),[c,u,a,l]);var d=r(e,f[0],f[1]);return o((function(){p.hasValue=!0,p.value=d}),[d]),i(d),d},we}function kt(){return Ue||(Ue=1,ve.exports=Tt()),ve.exports}var Pt=kt(),q="default"in Fe?rt:Fe,qe=Symbol.for("react-redux-context"),Be=typeof globalThis<"u"?globalThis:{};function Dt(){if(!q.createContext)return{};const e=Be[qe]??(Be[qe]=new Map);let t=e.get(q.createContext);return t||(t=q.createContext(null),e.set(q.createContext,t)),t}var Q=Dt(),jt=()=>{throw new Error("uSES not initialized!")};function De(e=Q){return function(){return q.useContext(e)}}var nt=De(),ot=jt,Mt=e=>{ot=e},Lt=(e,t)=>e===t;function Nt(e=Q){const t=e===Q?nt:De(e),r=(e,r={})=>{const{equalityFn:n=Lt,devModeChecks:o={}}="function"==typeof r?{equalityFn:r}:r,{store:s,subscription:i,getServerState:c,stabilityCheck:u,identityFunctionCheck:a}=t();q.useRef(!0);const l=q.useCallback({[e.name]:t=>e(t)}[e.name],[e,u,o.stabilityCheck]),f=ot(i.addNestedSub,s.getState,c||s.getState,l,n);return q.useDebugValue(f),f};return Object.assign(r,{withTypes:()=>r}),r}var je=Nt(),At=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function it(e=Q){const t=e===Q?nt:De(e),r=()=>{const{store:e}=t();return e};return Object.assign(r,{withTypes:()=>r}),r}At?q.useLayoutEffect:q.useEffect;var It=it();function zt(e=Q){const t=e===Q?It:it(e),r=()=>t().dispatch;return Object.assign(r,{withTypes:()=>r}),r}var st=zt();function $t(e){if("object"!=typeof e||null===e)return!1;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||null===Object.getPrototypeOf(e)}function Ft(e){return $t(e)&&"type"in e&&"string"==typeof e.type}Mt(Pt.useSyncExternalStoreWithSelector);var ct=Symbol.for("immer-nothing"),Ge=Symbol.for("immer-draftable"),A=Symbol.for("immer-state");function $(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var J=Object.getPrototypeOf;function G(e){return!!e&&!!e[A]}function B(e){var t;return!!e&&(ut(e)||Array.isArray(e)||!!e[Ge]||!(null==(t=e.constructor)||!t[Ge])||he(e)||ye(e))}var Wt=Object.prototype.constructor.toString();function ut(e){if(!e||"object"!=typeof e)return!1;const t=J(e);if(null===t)return!0;const r=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return r===Object||"function"==typeof r&&Function.toString.call(r)===Wt}function ee(e,t){0===pe(e)?Object.entries(e).forEach((([r,n])=>{t(r,n,e)})):e.forEach(((r,n)=>t(n,r,e)))}function pe(e){const t=e[A];return t?t.type_:Array.isArray(e)?1:he(e)?2:ye(e)?3:0}function Ee(e,t){return 2===pe(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function at(e,t,r){const n=pe(e);2===n?e.set(t,r):3===n?e.add(r):e[t]=r}function Ut(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function he(e){return e instanceof Map}function ye(e){return e instanceof Set}function H(e){return e.copy_||e.base_}function Re(e,t){if(he(e))return new Map(e);if(ye(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&ut(e))return J(e)?{...e}:Object.assign(Object.create(null),e);const r=Object.getOwnPropertyDescriptors(e);delete r[A];let n=Reflect.ownKeys(r);for(let t=0;t<n.length;t++){const o=n[t],s=r[o];!1===s.writable&&(s.writable=!0,s.configurable=!0),(s.get||s.set)&&(r[o]={configurable:!0,writable:!0,enumerable:s.enumerable,value:e[o]})}return Object.create(J(e),r)}function Me(e,t=!1){return _e(e)||G(e)||!B(e)||(pe(e)>1&&(e.set=e.add=e.clear=e.delete=qt),Object.freeze(e),t&&ee(e,((e,t)=>Me(t,!0)))),e}function qt(){$(2)}function _e(e){return Object.isFrozen(e)}var te,Bt={};function K(e){const t=Bt[e];return t||$(0,e),t}function ft(){return te}function Gt(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function Ve(e,t){t&&(K("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Oe(e){xe(e),e.drafts_.forEach(Vt),e.drafts_=null}function xe(e){e===te&&(te=e.parent_)}function He(e){return te=Gt(te,e)}function Vt(e){const t=e[A];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function Qe(e,t){t.unfinalizedDrafts_=t.drafts_.length;const r=t.drafts_[0];return void 0!==e&&e!==r?(r[A].modified_&&(Oe(t),$(4)),B(e)&&(e=fe(t,e),t.parent_||le(t,e)),t.patches_&&K("Patches").generateReplacementPatches_(r[A].base_,e,t.patches_,t.inversePatches_)):e=fe(t,r,[]),Oe(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==ct?e:void 0}function fe(e,t,r){if(_e(t))return t;const n=t[A];if(!n)return ee(t,((o,s)=>Ke(e,n,t,o,s,r))),t;if(n.scope_!==e)return t;if(!n.modified_)return le(e,n.base_,!0),n.base_;if(!n.finalized_){n.finalized_=!0,n.scope_.unfinalizedDrafts_--;const t=n.copy_;let o=t,s=!1;3===n.type_&&(o=new Set(t),t.clear(),s=!0),ee(o,((o,i)=>Ke(e,n,t,o,i,r,s))),le(e,t,!1),r&&e.patches_&&K("Patches").generatePatches_(n,r,e.patches_,e.inversePatches_)}return n.copy_}function Ke(e,t,r,n,o,s,i){if(G(o)){const i=fe(e,o,s&&t&&3!==t.type_&&!Ee(t.assigned_,n)?s.concat(n):void 0);if(at(r,n,i),!G(i))return;e.canAutoFreeze_=!1}else i&&r.add(o);if(B(o)&&!_e(o)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;fe(e,o),(!t||!t.scope_.parent_)&&le(e,o)}}function le(e,t,r=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Me(t,r)}function Ht(e,t){const r=Array.isArray(e),n={type_:r?1:0,scope_:t?t.scope_:ft(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let o=n,s=Le;r&&(o=[n],s=re);const{revoke:i,proxy:c}=Proxy.revocable(o,s);return n.draft_=c,n.revoke_=i,c}var Le={get(e,t){if(t===A)return e;const r=H(e);if(!Ee(r,t))return Qt(e,r,t);const n=r[t];return e.finalized_||!B(n)?n:n===Se(e.base_,t)?(Ce(e),e.copy_[t]=ke(n,e)):n},has:(e,t)=>t in H(e),ownKeys:e=>Reflect.ownKeys(H(e)),set(e,t,r){const n=lt(H(e),t);if(null!=n&&n.set)return n.set.call(e.draft_,r),!0;if(!e.modified_){const n=Se(H(e),t),o=null==n?void 0:n[A];if(o&&o.base_===r)return e.copy_[t]=r,e.assigned_[t]=!1,!0;if(Ut(r,n)&&(void 0!==r||Ee(e.base_,t)))return!0;Ce(e),Te(e)}return e.copy_[t]===r&&(void 0!==r||t in e.copy_)||Number.isNaN(r)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=r,e.assigned_[t]=!0),!0},deleteProperty:(e,t)=>(void 0!==Se(e.base_,t)||t in e.base_?(e.assigned_[t]=!1,Ce(e),Te(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const r=H(e),n=Reflect.getOwnPropertyDescriptor(r,t);return n&&{writable:!0,configurable:1!==e.type_||"length"!==t,enumerable:n.enumerable,value:r[t]}},defineProperty(){$(11)},getPrototypeOf:e=>J(e.base_),setPrototypeOf(){$(12)}},re={};function Se(e,t){const r=e[A];return(r?H(r):e)[t]}function Qt(e,t,r){var n;const o=lt(t,r);return o?"value"in o?o.value:null==(n=o.get)?void 0:n.call(e.draft_):void 0}function lt(e,t){if(!(t in e))return;let r=J(e);for(;r;){const e=Object.getOwnPropertyDescriptor(r,t);if(e)return e;r=J(r)}}function Te(e){e.modified_||(e.modified_=!0,e.parent_&&Te(e.parent_))}function Ce(e){e.copy_||(e.copy_=Re(e.base_,e.scope_.immer_.useStrictShallowCopy_))}ee(Le,((e,t)=>{re[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),re.deleteProperty=function(e,t){return re.set.call(this,e,t,void 0)},re.set=function(e,t,r){return Le.set.call(this,e[0],t,r,e[0])};var Kt=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(e,t,r)=>{if("function"==typeof e&&"function"!=typeof t){const r=t;t=e;const n=this;return function(e=r,...o){return n.produce(e,(e=>t.call(this,e,...o)))}}let n;if("function"!=typeof t&&$(6),void 0!==r&&"function"!=typeof r&&$(7),B(e)){const o=He(this),s=ke(e,void 0);let i=!0;try{n=t(s),i=!1}finally{i?Oe(o):xe(o)}return Ve(o,r),Qe(n,o)}if(!e||"object"!=typeof e){if(n=t(e),void 0===n&&(n=e),n===ct&&(n=void 0),this.autoFreeze_&&Me(n,!0),r){const t=[],o=[];K("Patches").generateReplacementPatches_(e,n,t,o),r(t,o)}return n}$(1,e)},this.produceWithPatches=(e,t)=>{if("function"==typeof e)return(t,...r)=>this.produceWithPatches(t,(t=>e(t,...r)));let r,n;return[this.produce(e,t,((e,t)=>{r=e,n=t})),r,n]},"boolean"==typeof(null==e?void 0:e.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),"boolean"==typeof(null==e?void 0:e.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){B(e)||$(8),G(e)&&(e=dt(e));const t=He(this),r=ke(e,void 0);return r[A].isManual_=!0,xe(t),r}finishDraft(e,t){const r=e&&e[A];(!r||!r.isManual_)&&$(9);const{scope_:n}=r;return Ve(n,t),Qe(void 0,n)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let r;for(r=t.length-1;r>=0;r--){const n=t[r];if(0===n.path.length&&"replace"===n.op){e=n.value;break}}r>-1&&(t=t.slice(r+1));const n=K("Patches").applyPatches_;return G(e)?n(e,t):this.produce(e,(e=>n(e,t)))}};function ke(e,t){const r=he(e)?K("MapSet").proxyMap_(e,t):ye(e)?K("MapSet").proxySet_(e,t):Ht(e,t);return(t?t.scope_:ft()).drafts_.push(r),r}function dt(e){return G(e)||$(10,e),pt(e)}function pt(e){if(!B(e)||_e(e))return e;const t=e[A];let r;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,r=Re(e,t.scope_.immer_.useStrictShallowCopy_)}else r=Re(e,!0);return ee(r,((e,t)=>{at(r,e,pt(t))})),t&&(t.finalized_=!1),r}var I=new Kt,ht=I.produce;function Jt(e,t="expected a function, instead received "+typeof e){if("function"!=typeof e)throw new TypeError(t)}function Yt(e,t="expected an object, instead received "+typeof e){if("object"!=typeof e)throw new TypeError(t)}function Xt(e,t="expected all items to be functions, instead received the following types: "){if(!e.every((e=>"function"==typeof e))){const r=e.map((e=>"function"==typeof e?`function ${e.name||"unnamed"}()`:typeof e)).join(", ");throw new TypeError(`${t}[${r}]`)}}I.produceWithPatches.bind(I),I.setAutoFreeze.bind(I),I.setUseStrictShallowCopy.bind(I),I.applyPatches.bind(I),I.createDraft.bind(I),I.finishDraft.bind(I);var Je=e=>Array.isArray(e)?e:[e];function Zt(e){const t=Array.isArray(e[0])?e[0]:e;return Xt(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function er(e,t){const r=[],{length:n}=e;for(let o=0;o<n;o++)r.push(e[o].apply(null,t));return r}var tr=class{constructor(e){this.value=e}deref(){return this.value}},rr=typeof WeakRef<"u"?WeakRef:tr,nr=0,Ye=1;function ce(){return{s:nr,v:void 0,o:null,p:null}}function Ne(e,t={}){let r=ce();const{resultEqualityCheck:n}=t;let o,s=0;function i(){var t;let i=r;const{length:c}=arguments;for(let e=0,t=c;e<t;e++){const t=arguments[e];if("function"==typeof t||"object"==typeof t&&null!==t){let e=i.o;null===e&&(i.o=e=new WeakMap);const r=e.get(t);void 0===r?(i=ce(),e.set(t,i)):i=r}else{let e=i.p;null===e&&(i.p=e=new Map);const r=e.get(t);void 0===r?(i=ce(),e.set(t,i)):i=r}}const u=i;let a;if(i.s===Ye?a=i.v:(a=e.apply(null,arguments),s++),u.s=Ye,n){const e=(null==(t=null==o?void 0:o.deref)?void 0:t.call(o))??o;null!=e&&n(e,a)&&(a=e,0!==s&&s--),o="object"==typeof a&&null!==a||"function"==typeof a?new rr(a):a}return u.v=a,a}return i.clearCache=()=>{r=ce(),i.resetResultsCount()},i.resultsCount=()=>s,i.resetResultsCount=()=>{s=0},i}function yt(e,...t){const r="function"==typeof e?{memoize:e,memoizeOptions:t}:e,n=(...e)=>{let t,n=0,o=0,s={},i=e.pop();"object"==typeof i&&(s=i,i=e.pop()),Jt(i,`createSelector expects an output function after the inputs, but received: [${typeof i}]`);const c={...r,...s},{memoize:u,memoizeOptions:a=[],argsMemoize:l=Ne,argsMemoizeOptions:f=[],devModeChecks:p={}}=c,d=Je(a),h=Je(f),y=Zt(e),_=u((function(){return n++,i.apply(null,arguments)}),...d),b=l((function(){o++;const e=er(y,arguments);return t=_.apply(null,e),t}),...h);return Object.assign(b,{resultFunc:i,memoizedResultFunc:_,dependencies:y,dependencyRecomputations:()=>o,resetDependencyRecomputations:()=>{o=0},lastResult:()=>t,recomputations:()=>n,resetRecomputations:()=>{n=0},memoize:u,argsMemoize:l})};return Object.assign(n,{withTypes:()=>n}),n}var or=yt(Ne),ir=Object.assign(((e,t=or)=>{Yt(e,"createStructuredSelector expects first argument to be an object where each property is a selector, instead received a "+typeof e);const r=Object.keys(e);return t(r.map((t=>e[t])),((...e)=>e.reduce(((e,t,n)=>(e[r[n]]=t,e)),{})))}),{withTypes:()=>ir}),sr=(...e)=>{const t=yt(...e),r=Object.assign(((...e)=>{const r=t(...e),n=(e,...t)=>r(G(e)?dt(e):e,...t);return Object.assign(n,r),n}),{withTypes:()=>r});return r};function Y(e,t){function r(...r){if(t){let n=t(...r);if(!n)throw new Error(N(0));return{type:e,payload:n.payload,..."meta"in n&&{meta:n.meta},..."error"in n&&{error:n.error}}}return{type:e,payload:r[0]}}return r.toString=()=>`${e}`,r.type=e,r.match=t=>Ft(t)&&t.type===e,r}function Xe(e){return B(e)?ht(e,(()=>{})):e}function Ze(e,t,r){if(e.has(t)){let n=e.get(t);return r.update&&(n=r.update(n,t,e),e.set(t,n)),n}if(!r.insert)throw new Error(N(10));const n=r.insert(t,e);return e.set(t,n),n}function _t(e){const t={},r=[];let n;const o={addCase(e,r){const n="string"==typeof e?e:e.type;if(!n)throw new Error(N(28));if(n in t)throw new Error(N(29));return t[n]=r,o},addMatcher:(e,t)=>(r.push({matcher:e,reducer:t}),o),addDefaultCase:e=>(n=e,o)};return e(o),[t,r,n]}function cr(e){return"function"==typeof e}function ur(e,t){let r,[n,o,s]=_t(t);if(cr(e))r=()=>Xe(e());else{const t=Xe(e);r=()=>t}function i(e=r(),t){let i=[n[t.type],...o.filter((({matcher:e})=>e(t))).map((({reducer:e})=>e))];return 0===i.filter((e=>!!e)).length&&(i=[s]),i.reduce(((e,r)=>{if(r){if(G(e)){const n=r(e,t);return void 0===n?e:n}if(B(e))return ht(e,(e=>r(e,t)));{const n=r(e,t);if(void 0===n){if(null===e)return e;throw new Error(N(9))}return n}}return e}),e)}return i.getInitialState=r,i}sr(Ne);var ar="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",fr=(e=21)=>{let t="",r=e;for(;r--;)t+=ar[64*Math.random()|0];return t},lr=Symbol.for("rtk-slice-createasyncthunk");function dr(e,t){return`${e}/${t}`}function pr({creators:e}={}){var t;const r=null==(t=null==e?void 0:e.asyncThunk)?void 0:t[lr];return function(e){const{name:t,reducerPath:n=t}=e;if(!t)throw new Error(N(11));const o=("function"==typeof e.reducers?e.reducers(_r()):e.reducers)||{},s=Object.keys(o),i={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},c={addCase(e,t){const r="string"==typeof e?e:e.type;if(!r)throw new Error(N(12));if(r in i.sliceCaseReducersByType)throw new Error(N(13));return i.sliceCaseReducersByType[r]=t,c},addMatcher:(e,t)=>(i.sliceMatchers.push({matcher:e,reducer:t}),c),exposeAction:(e,t)=>(i.actionCreators[e]=t,c),exposeCaseReducer:(e,t)=>(i.sliceCaseReducersByName[e]=t,c)};function u(){const[t={},r=[],n]="function"==typeof e.extraReducers?_t(e.extraReducers):[e.extraReducers],o={...t,...i.sliceCaseReducersByType};return ur(e.initialState,(e=>{for(let t in o)e.addCase(t,o[t]);for(let t of i.sliceMatchers)e.addMatcher(t.matcher,t.reducer);for(let t of r)e.addMatcher(t.matcher,t.reducer);n&&e.addDefaultCase(n)}))}s.forEach((n=>{const s=o[n],i={reducerName:n,type:dr(t,n),createNotation:"function"==typeof e.reducers};gr(s)?vr(i,s,c,r):mr(i,s,c)}));const a=e=>e,l=new Map;let f;function p(e,t){return f||(f=u()),f(e,t)}function d(){return f||(f=u()),f.getInitialState()}function h(t,r=!1){function n(e){let n=e[t];return typeof n>"u"&&r&&(n=d()),n}function o(t=a){const n=Ze(l,r,{insert:()=>new WeakMap});return Ze(n,t,{insert:()=>{const n={};for(const[o,s]of Object.entries(e.selectors??{}))n[o]=hr(s,t,d,r);return n}})}return{reducerPath:t,getSelectors:o,get selectors(){return o(n)},selectSlice:n}}const y={name:t,reducer:p,actions:i.actionCreators,caseReducers:i.sliceCaseReducersByName,getInitialState:d,...h(n),injectInto(e,{reducerPath:t,...r}={}){const o=t??n;return e.inject({reducerPath:o,reducer:p},r),{...y,...h(o,!0)}}};return y}}function hr(e,t,r,n){function o(o,...s){let i=t(o);return typeof i>"u"&&n&&(i=r()),e(i,...s)}return o.unwrapped=e,o}var yr=pr();function _r(){function e(e,t){return{_reducerDefinitionType:"asyncThunk",payloadCreator:e,...t}}return e.withTypes=()=>e,{reducer:e=>Object.assign({[e.name]:(...t)=>e(...t)}[e.name],{_reducerDefinitionType:"reducer"}),preparedReducer:(e,t)=>({_reducerDefinitionType:"reducerWithPrepare",prepare:e,reducer:t}),asyncThunk:e}}function mr({type:e,reducerName:t,createNotation:r},n,o){let s,i;if("reducer"in n){if(r&&!br(n))throw new Error(N(17));s=n.reducer,i=n.prepare}else s=n;o.addCase(e,s).exposeCaseReducer(t,s).exposeAction(t,i?Y(e,i):Y(e))}function gr(e){return"asyncThunk"===e._reducerDefinitionType}function br(e){return"reducerWithPrepare"===e._reducerDefinitionType}function vr({type:e,reducerName:t},r,n,o){if(!o)throw new Error(N(18));const{payloadCreator:s,fulfilled:i,pending:c,rejected:u,settled:a,options:l}=r,f=o(e,s,l);n.exposeAction(t,f),i&&n.addCase(f.fulfilled,i),c&&n.addCase(f.pending,c),u&&n.addCase(f.rejected,u),a&&n.addMatcher(f.settled,a),n.exposeCaseReducer(t,{fulfilled:i||ue,pending:c||ue,rejected:u||ue,settled:a||ue})}function ue(){}var wr=(e,t)=>{if("function"!=typeof e)throw new Error(N(32))},Ae="listenerMiddleware",Sr=e=>{let{type:t,actionCreator:r,matcher:n,predicate:o,effect:s}=e;if(t)o=Y(t).match;else if(r)t=r.type,o=r.match;else if(n)o=n;else if(!o)throw new Error(N(21));return wr(s),{predicate:o,type:t,effect:s}},Cr=Object.assign((e=>{const{type:t,predicate:r,effect:n}=Sr(e);return{id:fr(),effect:n,type:t,predicate:r,pending:new Set,unsubscribe:()=>{throw new Error(N(22))}}}),{withTypes:()=>Cr}),Er=Object.assign(Y(`${Ae}/add`),{withTypes:()=>Er});Y(`${Ae}/removeAll`);var Rr=Object.assign(Y(`${Ae}/remove`),{withTypes:()=>Rr});function N(e){return`Minified Redux Toolkit error #${e}; visit https://redux-toolkit.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}const Z={messages:[],subscribers:[],unsubscribers:[]},de=yr({name:"ws",initialState:Z,reducers:{reset:e=>{e.messages=Z.messages,e.subscribers=Z.subscribers,e.unsubscribers=Z.unsubscribers},subscribe:(e,{payload:t})=>{!e.subscribers.find((e=>e.id===t.id))&&e.subscribers.push(t)},onMessage:(e,{payload:t})=>{e.messages=[t,...e.messages.slice(0,100)]},cleanMessages:e=>{e.messages=Z.messages},unsubscribe:(e,{payload:t})=>{const r=e.subscribers.find((e=>e.id===t));r&&e.unsubscribers.push(r)},onUnsubscribe:(e,{payload:t})=>{e.subscribers=e.subscribers.filter((e=>e.id!==t)),e.unsubscribers=e.unsubscribers.filter((e=>e.id!==t))}},selectors:{selectMessages:e=>e.messages,selectSubscribers:e=>e.subscribers,selectUnSubscribers:e=>e.unsubscribers,selectLastUpdateFor:(e,t)=>{var r;return null==(r=e.messages)?void 0:r.find((({topic:e})=>e===t))}}}).injectInto(St),Or=()=>"object"!=typeof window,et=["debug","info","warn","error"],xr=(e,t)=>{const r=et.indexOf(e);return et.indexOf(t)>=r},ae=(e,t,r,...n)=>{xr(t,e)&&console.log(`[${e}] ${r}`,...n)},Tr=()=>null==window?void 0:window.localStorage.getItem("logger_lvl"),kr=(e=!Or()&&Tr()||"warn")=>{let t=e;return{debug:(e,...r)=>ae("debug",t,e,...r),info:(e,...r)=>ae("info",t,e,...r),warn:(e,...r)=>ae("warn",t,e,...r),error:(e,...r)=>(Ct(e,...r),ae("error",t,e,...r)),setLevel:e=>{t=e},getLevel:()=>t}},F=kr(),mt=e=>[...new Set(e.flatMap((e=>e.topics)))],Pr=({isReady:e,socket:t,serverSubscriptions:r})=>{const n=st(),o=je(de.selectors.selectUnSubscribers);W.useEffect((()=>{var s;if(e&&t){const e=mt(o);if(0===e.length)return;try{t.send(JSON.stringify({type:"UNSUBSCRIBE",topics:e})),r.current=null==(s=r.current)?void 0:s.filter((e=>!o.find((t=>t.id===e.id)))),F.debug("WebSocket unsubscribed from: ",e)}catch(e){F.error("WebSocket error when send: ",e)}}o.forEach((e=>{n(de.actions.onUnsubscribe(e.id))}))}),[o,t,e])},Dr=({isReady:e,socket:t,serverSubscriptions:r})=>{const n=je(de.selectors.selectSubscribers);W.useEffect((()=>{var o;if(e){F.debug("WebSocket subscribers list: ",n);const e=n.filter((e=>{var t;return!(null!=(t=r.current)&&t.includes(e))})),s=mt(e);if(s.length>0)try{null==t||t.send(JSON.stringify({type:"SUBSCRIBE",topics:s})),null==(o=r.current)||o.push(...e),F.debug("WebSocket subscribed to: ",s)}catch(e){F.error("WebSocket error when send: ",e)}}}),[e,n])},jr=e=>{switch(e.code){case 1e3:return"Normal closure, meaning that the purpose for which the connection was established has been fulfilled.";case 1001:return"An endpoint is 'going away', such as a server going down or a browser having navigated away from a page.";case 1002:return"An endpoint is terminating the connection due to a protocol error.";case 1003:return"An endpoint is terminating the connection because it has received a type of data it cannot accept (e.g., an endpoint that understands only text data MAY send this if it receives a binary message).";case 1004:return"Reserved. The specific meaning might be defined in the future.";case 1005:return"No status code was actually present.";case 1006:return"The connection was closed abnormally, e.g., without sending or receiving a Close control frame.";case 1007:return"An endpoint is terminating the connection because it has received data within a message that was not consistent with the type of the message (e.g., non-UTF-8 data within a text message).";case 1008:return"An endpoint is terminating the connection because it has received a message that 'violates its policy'. This reason is given either if there is no other suitable reason, or if there is a need to hide specific details about the policy.";case 1009:return"An endpoint is terminating the connection because it has received a message that is too big for it to process.";case 1010:return`An endpoint (client) is terminating the connection because it has expected the server to negotiate one or more extension, but the server didn't return them in the response message of the WebSocket handshake. Specifically, the extensions that are needed are: ${e.reason}`;case 1011:return"A server is terminating the connection because it encountered an unexpected condition that prevented it from fulfilling the request.";case 1015:return"The connection was closed due to a failure to perform a TLS handshake (e.g., the server certificate can't be verified).";default:return"Unknown reason."}},Mr=({onReady:e,socket:t,serverSubscriptions:r})=>{const n=st();W.useEffect((()=>{t&&(t.onopen=()=>{r.current=[],e(!0),F.info("Connected to WebSocket server")},t.onmessage=e=>{F.debug("WebSocket receive message: ",JSON.parse(e.data));try{n(de.actions.onMessage({...JSON.parse(e.data),date:(new Date).toISOString()}))}catch(e){F.error("WebSocket:onmessage:parse: ",e)}},t.onclose=t=>{e(!1),F.info("Disconnected from WebSocket server:",jr(t))},t.onerror=t=>{e(!1),F.error("WebSocket error:",t)})}),[t])};
|
|
2
20
|
/*! *****************************************************************************
|
|
3
21
|
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
22
|
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
@@ -12,10 +30,10 @@ MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
|
12
30
|
|
|
13
31
|
See the Apache Version 2.0 License for specific language governing permissions
|
|
14
32
|
and limitations under the License.
|
|
15
|
-
***************************************************************************** */var
|
|
33
|
+
***************************************************************************** */var Pe=function(e,t){return(Pe=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};function gt(e,t){function r(){this.constructor=e}Pe(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function Lr(e){var t="function"==typeof Symbol&&e[Symbol.iterator],r=0;return t?t.call(e):{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}}function Nr(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,s=r.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(n=s.next()).done;)i.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=s.return)&&r.call(s)}finally{if(o)throw o.error}}return i}function Ar(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(Nr(arguments[t]));return e}var bt=function(){return function(e,t){this.target=t,this.type=e}}(),Ir=function(e){function t(t,r){var n=e.call(this,"error",r)||this;return n.message=t.message,n.error=t,n}return gt(t,e),t}(bt),zr=function(e){function t(t,r,n){void 0===t&&(t=1e3),void 0===r&&(r="");var o=e.call(this,"close",n)||this;return o.wasClean=!0,o.code=t,o.reason=r,o}return gt(t,e),t}(bt),$r=function(){if(typeof WebSocket<"u")return WebSocket},Fr=function(e){return typeof e<"u"&&!!e&&2===e.CLOSING},V={maxReconnectionDelay:1e4,minReconnectionDelay:1e3+4e3*Math.random(),minUptime:5e3,reconnectionDelayGrowFactor:1.3,connectionTimeout:4e3,maxRetries:1/0,maxEnqueuedMessages:1/0,startClosed:!1,debug:!1},Wr=function(){function e(e,t,r){var n=this;void 0===r&&(r={}),this._listeners={error:[],message:[],open:[],close:[]},this._retryCount=-1,this._shouldReconnect=!0,this._connectLock=!1,this._binaryType="blob",this._closeCalled=!1,this._messageQueue=[],this.onclose=null,this.onerror=null,this.onmessage=null,this.onopen=null,this._handleOpen=function(e){n._debug("open event");var t=n._options.minUptime,r=void 0===t?V.minUptime:t;clearTimeout(n._connectTimeout),n._uptimeTimeout=setTimeout((function(){return n._acceptOpen()}),r),n._ws.binaryType=n._binaryType,n._messageQueue.forEach((function(e){return n._ws.send(e)})),n._messageQueue=[],n.onopen&&n.onopen(e),n._listeners.open.forEach((function(t){return n._callEventListener(e,t)}))},this._handleMessage=function(e){n._debug("message event"),n.onmessage&&n.onmessage(e),n._listeners.message.forEach((function(t){return n._callEventListener(e,t)}))},this._handleError=function(e){n._debug("error event",e.message),n._disconnect(void 0,"TIMEOUT"===e.message?"timeout":void 0),n.onerror&&n.onerror(e),n._debug("exec error listeners"),n._listeners.error.forEach((function(t){return n._callEventListener(e,t)})),n._connect()},this._handleClose=function(e){n._debug("close event"),n._clearTimeouts(),n._shouldReconnect&&n._connect(),n.onclose&&n.onclose(e),n._listeners.close.forEach((function(t){return n._callEventListener(e,t)}))},this._url=e,this._protocols=t,this._options=r,this._options.startClosed&&(this._shouldReconnect=!1),this._connect()}return Object.defineProperty(e,"CONNECTING",{get:function(){return 0},enumerable:!0,configurable:!0}),Object.defineProperty(e,"OPEN",{get:function(){return 1},enumerable:!0,configurable:!0}),Object.defineProperty(e,"CLOSING",{get:function(){return 2},enumerable:!0,configurable:!0}),Object.defineProperty(e,"CLOSED",{get:function(){return 3},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"CONNECTING",{get:function(){return e.CONNECTING},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"OPEN",{get:function(){return e.OPEN},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"CLOSING",{get:function(){return e.CLOSING},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"CLOSED",{get:function(){return e.CLOSED},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"binaryType",{get:function(){return this._ws?this._ws.binaryType:this._binaryType},set:function(e){this._binaryType=e,this._ws&&(this._ws.binaryType=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"retryCount",{get:function(){return Math.max(this._retryCount,0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"bufferedAmount",{get:function(){return this._messageQueue.reduce((function(e,t){return"string"==typeof t?e+=t.length:t instanceof Blob?e+=t.size:e+=t.byteLength,e}),0)+(this._ws?this._ws.bufferedAmount:0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"extensions",{get:function(){return this._ws?this._ws.extensions:""},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"protocol",{get:function(){return this._ws?this._ws.protocol:""},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"readyState",{get:function(){return this._ws?this._ws.readyState:this._options.startClosed?e.CLOSED:e.CONNECTING},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"url",{get:function(){return this._ws?this._ws.url:""},enumerable:!0,configurable:!0}),e.prototype.close=function(e,t){void 0===e&&(e=1e3),this._closeCalled=!0,this._shouldReconnect=!1,this._clearTimeouts(),this._ws?this._ws.readyState!==this.CLOSED?this._ws.close(e,t):this._debug("close: already closed"):this._debug("close enqueued: no ws instance")},e.prototype.reconnect=function(e,t){this._shouldReconnect=!0,this._closeCalled=!1,this._retryCount=-1,this._ws&&this._ws.readyState!==this.CLOSED?(this._disconnect(e,t),this._connect()):this._connect()},e.prototype.send=function(e){if(this._ws&&this._ws.readyState===this.OPEN)this._debug("send",e),this._ws.send(e);else{var t=this._options.maxEnqueuedMessages,r=void 0===t?V.maxEnqueuedMessages:t;this._messageQueue.length<r&&(this._debug("enqueue",e),this._messageQueue.push(e))}},e.prototype.addEventListener=function(e,t){this._listeners[e]&&this._listeners[e].push(t)},e.prototype.dispatchEvent=function(e){var t,r,n=this._listeners[e.type];if(n)try{for(var o=Lr(n),s=o.next();!s.done;s=o.next()){var i=s.value;this._callEventListener(e,i)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(t)throw t.error}}return!0},e.prototype.removeEventListener=function(e,t){this._listeners[e]&&(this._listeners[e]=this._listeners[e].filter((function(e){return e!==t})))},e.prototype._debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._options.debug&&console.log.apply(console,Ar(["RWS>"],e))},e.prototype._getNextDelay=function(){var e=this._options,t=e.reconnectionDelayGrowFactor,r=void 0===t?V.reconnectionDelayGrowFactor:t,n=e.minReconnectionDelay,o=void 0===n?V.minReconnectionDelay:n,s=e.maxReconnectionDelay,i=void 0===s?V.maxReconnectionDelay:s,c=0;return this._retryCount>0&&((c=o*Math.pow(r,this._retryCount-1))>i&&(c=i)),this._debug("next delay",c),c},e.prototype._wait=function(){var e=this;return new Promise((function(t){setTimeout(t,e._getNextDelay())}))},e.prototype._getNextUrl=function(e){if("string"==typeof e)return Promise.resolve(e);if("function"==typeof e){var t=e();if("string"==typeof t)return Promise.resolve(t);if(t.then)return t}throw Error("Invalid URL")},e.prototype._connect=function(){var e=this;if(!this._connectLock&&this._shouldReconnect){this._connectLock=!0;var t=this._options,r=t.maxRetries,n=void 0===r?V.maxRetries:r,o=t.connectionTimeout,s=void 0===o?V.connectionTimeout:o,i=t.WebSocket,c=void 0===i?$r():i;if(this._retryCount>=n)return void this._debug("max retries reached",this._retryCount,">=",n);if(this._retryCount++,this._debug("connect",this._retryCount),this._removeListeners(),!Fr(c))throw Error("No valid WebSocket class provided");this._wait().then((function(){return e._getNextUrl(e._url)})).then((function(t){e._closeCalled||(e._debug("connect",{url:t,protocols:e._protocols}),e._ws=e._protocols?new c(t,e._protocols):new c(t),e._ws.binaryType=e._binaryType,e._connectLock=!1,e._addListeners(),e._connectTimeout=setTimeout((function(){return e._handleTimeout()}),s))}))}},e.prototype._handleTimeout=function(){this._debug("timeout event"),this._handleError(new Ir(Error("TIMEOUT"),this))},e.prototype._disconnect=function(e,t){if(void 0===e&&(e=1e3),this._clearTimeouts(),this._ws){this._removeListeners();try{this._ws.close(e,t),this._handleClose(new zr(e,t,this))}catch{}}},e.prototype._acceptOpen=function(){this._debug("accept open"),this._retryCount=0},e.prototype._callEventListener=function(e,t){"handleEvent"in t?t.handleEvent(e):t(e)},e.prototype._removeListeners=function(){this._ws&&(this._debug("removeListeners"),this._ws.removeEventListener("open",this._handleOpen),this._ws.removeEventListener("close",this._handleClose),this._ws.removeEventListener("message",this._handleMessage),this._ws.removeEventListener("error",this._handleError))},e.prototype._addListeners=function(){this._ws&&(this._debug("addListeners"),this._ws.addEventListener("open",this._handleOpen),this._ws.addEventListener("close",this._handleClose),this._ws.addEventListener("message",this._handleMessage),this._ws.addEventListener("error",this._handleError))},e.prototype._clearTimeouts=function(){clearTimeout(this._connectTimeout),clearTimeout(this._uptimeTimeout)},e}();
|
|
16
34
|
/*!
|
|
17
35
|
* Reconnecting WebSocket
|
|
18
36
|
* by Pedro Ladaria <pedro.ladaria@gmail.com>
|
|
19
37
|
* https://github.com/pladaria/reconnecting-websocket
|
|
20
38
|
* License MIT
|
|
21
|
-
*/const
|
|
39
|
+
*/const Ur=({onReady:e})=>{const t=je(Et.selectors.selectToken),r=W.useRef(null),[n,o]=W.useState(null);r.current=n;const s=()=>{var t,n,o;if((null==(t=r.current)?void 0:t.readyState)===(null==(n=r.current)?void 0:n.OPEN))try{e(!1),null==(o=r.current)||o.close()}catch(e){F.error("WebSocket error when close: ",e)}};return W.useEffect((()=>()=>s()),[]),W.useEffect((()=>((()=>{const e=location.hostname,r=new Wr(`wss://${e}/api/v1/streaming${t?`?access_token=${t}`:""}`);o(r)})(),()=>s())),[t]),{socket:n}},Vr=()=>{const[e,t]=W.useState(!1),{socket:r}=Ur({onReady:t}),n=W.useRef([]);Mr({onReady:t,socket:r,serverSubscriptions:n}),Dr({isReady:e,socket:r,serverSubscriptions:n}),Pr({isReady:e,socket:r,serverSubscriptions:n})},Hr=(e,t)=>Object.keys(t).reduce(((e,r)=>e.replace(`$${r}`,t[r])),e);export{Hr as fillTopic,Vr as useWebSocket,de as wsSlice};
|
package/package.json
CHANGED