@bddh/starling-realtime-client 1.0.0-beta.2 → 1.0.0-beta.3
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/LICENSE +21 -0
- package/cjs/node_modules/fast-unique-numbers/build/es2019/factories/cache.js +1 -0
- package/cjs/node_modules/fast-unique-numbers/build/es2019/factories/generate-unique-number.js +1 -0
- package/cjs/node_modules/fast-unique-numbers/build/es2019/module.js +1 -0
- package/cjs/node_modules/worker-timers/build/es2019/factories/load-or-return-broker.js +1 -0
- package/cjs/node_modules/worker-timers/build/es2019/module.js +1 -0
- package/cjs/node_modules/worker-timers/build/es2019/worker/worker.js +1 -0
- package/cjs/node_modules/worker-timers-broker/build/es2019/guards/call-notification.js +1 -0
- package/cjs/node_modules/worker-timers-broker/build/es2019/guards/clear-response.js +1 -0
- package/cjs/node_modules/worker-timers-broker/build/es2019/module.js +1 -0
- package/es/node_modules/fast-unique-numbers/build/es2019/factories/cache.js +1 -0
- package/es/node_modules/fast-unique-numbers/build/es2019/factories/generate-unique-number.js +1 -0
- package/es/node_modules/fast-unique-numbers/build/es2019/module.js +1 -0
- package/es/node_modules/worker-timers/build/es2019/factories/load-or-return-broker.js +1 -0
- package/es/node_modules/worker-timers/build/es2019/module.js +1 -0
- package/es/node_modules/worker-timers/build/es2019/worker/worker.js +1 -0
- package/es/node_modules/worker-timers-broker/build/es2019/guards/call-notification.js +1 -0
- package/es/node_modules/worker-timers-broker/build/es2019/guards/clear-response.js +1 -0
- package/es/node_modules/worker-timers-broker/build/es2019/module.js +1 -0
- package/package.json +11 -10
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) zhangyibo02@baidu.com
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";exports.createCache=function(t){return function(e,r){return t.set(e,r),r}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var r=void 0===Number.MAX_SAFE_INTEGER?9007199254740991:Number.MAX_SAFE_INTEGER,e=536870912,t=1073741824;exports.createGenerateUniqueNumber=function(a,o){return function(n){var i=o.get(n),u=void 0===i?n.size:i<t?i+1:0;if(!n.has(u))return a(n,u);if(n.size<e){for(;n.has(u);)u=Math.floor(Math.random()*t);return a(n,u)}if(n.size>r)throw new Error("Congratulations, you created a collection of unique numbers which uses all available integers!");for(;n.has(u);)u=Math.floor(Math.random()*r);return a(n,u)}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("./factories/cache.js"),r=require("./factories/generate-unique-number.js"),a=new WeakMap,t=e.createCache(a),u=r.createGenerateUniqueNumber(t,a);exports.generateUniqueNumber=u;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";exports.createLoadOrReturnBroker=function(t,e){var r=null;return function(){if(null!==r)return r;var n=new Blob([e],{type:"application/javascript; charset=utf-8"}),u=URL.createObjectURL(n);return r=t(u),setTimeout((function(){return URL.revokeObjectURL(u)})),r}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var r=require("../../../worker-timers-broker/build/es2019/module.js"),e=require("./factories/load-or-return-broker.js"),o=require("./worker/worker.js"),t=e.createLoadOrReturnBroker(r.load,o.worker);exports.clearTimeout=function(r){return t().clearTimeout(r)},exports.setTimeout=function(){var r;return(r=t()).setTimeout.apply(r,arguments)};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";exports.worker='(()=>{"use strict";const e=new Map,t=new Map,r=(e,t)=>{let r,o;const i=performance.now();r=i,o=e-Math.max(0,i-t);return{expected:r+o,remainingDelay:o}},o=(e,t,r,i)=>{const s=performance.now();s>r?postMessage({id:null,method:"call",params:{timerId:t,timerType:i}}):e.set(t,setTimeout(o,r-s,e,t,r,i))};addEventListener("message",(i=>{let{data:s}=i;try{if("clear"===s.method){const{id:r,params:{timerId:o,timerType:i}}=s;if("interval"===i)(t=>{const r=e.get(t);if(void 0===r)throw new Error(\'There is no interval scheduled with the given id "\'.concat(t,\'".\'));clearTimeout(r),e.delete(t)})(o),postMessage({error:null,id:r});else{if("timeout"!==i)throw new Error(\'The given type "\'.concat(i,\'" is not supported\'));(e=>{const r=t.get(e);if(void 0===r)throw new Error(\'There is no timeout scheduled with the given id "\'.concat(e,\'".\'));clearTimeout(r),t.delete(e)})(o),postMessage({error:null,id:r})}}else{if("set"!==s.method)throw new Error(\'The given method "\'.concat(s.method,\'" is not supported\'));{const{params:{delay:i,now:n,timerId:a,timerType:d}}=s;if("interval"===d)((t,i,s)=>{const{expected:n,remainingDelay:a}=r(t,s);e.set(i,setTimeout(o,a,e,i,n,"interval"))})(i,a,n);else{if("timeout"!==d)throw new Error(\'The given type "\'.concat(d,\'" is not supported\'));((e,i,s)=>{const{expected:n,remainingDelay:a}=r(e,s);t.set(i,setTimeout(o,a,t,i,n,"timeout"))})(i,a,n)}}}}catch(e){postMessage({error:{message:e.message},id:s.id,result:null})}}))})();';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";exports.isCallNotification=function(t){return void 0!==t.method&&"call"===t.method};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";exports.isClearResponse=function(e){return null===e.error&&"number"==typeof e.id};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("../../../fast-unique-numbers/build/es2019/module.js"),r=require("./guards/call-notification.js"),t=require("./guards/clear-response.js");exports.load=function(i){var n=new Map([[0,function(){}]]),a=new Map([[0,function(){}]]),o=new Map,s=new Worker(i);s.addEventListener("message",(function(e){var i=e.data;if(r.isCallNotification(i)){var s=i.params,m=s.timerId,d=s.timerType;if("interval"===d){var u=n.get(m);if("number"==typeof u){var l=o.get(u);if(void 0===l||l.timerId!==m||l.timerType!==d)throw new Error("The timer is in an undefined state.")}else{if(void 0===u)throw new Error("The timer is in an undefined state.");u()}}else if("timeout"===d){var f=a.get(m);if("number"==typeof f){var p=o.get(f);if(void 0===p||p.timerId!==m||p.timerType!==d)throw new Error("The timer is in an undefined state.")}else{if(void 0===f)throw new Error("The timer is in an undefined state.");f(),a.delete(m)}}}else{if(!t.isClearResponse(i)){var v=i.error.message;throw new Error(v)}var c=i.id,w=o.get(c);if(void 0===w)throw new Error("The timer is in an undefined state.");var g=w.timerId,h=w.timerType;o.delete(c),"interval"===h?n.delete(g):a.delete(g)}}));return{clearInterval:function(r){var t=e.generateUniqueNumber(o);o.set(t,{timerId:r,timerType:"interval"}),n.set(r,t),s.postMessage({id:t,method:"clear",params:{timerId:r,timerType:"interval"}})},clearTimeout:function(r){var t=e.generateUniqueNumber(o);o.set(t,{timerId:r,timerType:"timeout"}),a.set(r,t),s.postMessage({id:t,method:"clear",params:{timerId:r,timerType:"timeout"}})},setInterval:function(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=e.generateUniqueNumber(n);return n.set(i,(function(){r(),"function"==typeof n.get(i)&&s.postMessage({id:null,method:"set",params:{delay:t,now:performance.now(),timerId:i,timerType:"interval"}})})),s.postMessage({id:null,method:"set",params:{delay:t,now:performance.now(),timerId:i,timerType:"interval"}}),i},setTimeout:function(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=e.generateUniqueNumber(a);return a.set(i,r),s.postMessage({id:null,method:"set",params:{delay:t,now:performance.now(),timerId:i,timerType:"timeout"}}),i}}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var n=function(n){return function(r,t){return n.set(r,t),t}};export{n as createCache};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var r=void 0===Number.MAX_SAFE_INTEGER?9007199254740991:Number.MAX_SAFE_INTEGER,e=536870912,o=1073741824,a=function(a,t){return function(n){var i=t.get(n),u=void 0===i?n.size:i<o?i+1:0;if(!n.has(u))return a(n,u);if(n.size<e){for(;n.has(u);)u=Math.floor(Math.random()*o);return a(n,u)}if(n.size>r)throw new Error("Congratulations, you created a collection of unique numbers which uses all available integers!");for(;n.has(u);)u=Math.floor(Math.random()*r);return a(n,u)}};export{a as createGenerateUniqueNumber};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createCache as e}from"./factories/cache.js";import{createGenerateUniqueNumber as r}from"./factories/generate-unique-number.js";var a=new WeakMap,o=r(e(a),a);export{o as generateUniqueNumber};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var t=function(t,e){var r=null;return function(){if(null!==r)return r;var n=new Blob([e],{type:"application/javascript; charset=utf-8"}),u=URL.createObjectURL(n);return r=t(u),setTimeout((function(){return URL.revokeObjectURL(u)})),r}};export{t as createLoadOrReturnBroker};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{load as r}from"../../../worker-timers-broker/build/es2019/module.js";import{createLoadOrReturnBroker as o}from"./factories/load-or-return-broker.js";import{worker as e}from"./worker/worker.js";var t=o(r,e),i=function(r){return t().clearTimeout(r)},m=function(){var r;return(r=t()).setTimeout.apply(r,arguments)};export{i as clearTimeout,m as setTimeout};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e='(()=>{"use strict";const e=new Map,t=new Map,r=(e,t)=>{let r,o;const i=performance.now();r=i,o=e-Math.max(0,i-t);return{expected:r+o,remainingDelay:o}},o=(e,t,r,i)=>{const s=performance.now();s>r?postMessage({id:null,method:"call",params:{timerId:t,timerType:i}}):e.set(t,setTimeout(o,r-s,e,t,r,i))};addEventListener("message",(i=>{let{data:s}=i;try{if("clear"===s.method){const{id:r,params:{timerId:o,timerType:i}}=s;if("interval"===i)(t=>{const r=e.get(t);if(void 0===r)throw new Error(\'There is no interval scheduled with the given id "\'.concat(t,\'".\'));clearTimeout(r),e.delete(t)})(o),postMessage({error:null,id:r});else{if("timeout"!==i)throw new Error(\'The given type "\'.concat(i,\'" is not supported\'));(e=>{const r=t.get(e);if(void 0===r)throw new Error(\'There is no timeout scheduled with the given id "\'.concat(e,\'".\'));clearTimeout(r),t.delete(e)})(o),postMessage({error:null,id:r})}}else{if("set"!==s.method)throw new Error(\'The given method "\'.concat(s.method,\'" is not supported\'));{const{params:{delay:i,now:n,timerId:a,timerType:d}}=s;if("interval"===d)((t,i,s)=>{const{expected:n,remainingDelay:a}=r(t,s);e.set(i,setTimeout(o,a,e,i,n,"interval"))})(i,a,n);else{if("timeout"!==d)throw new Error(\'The given type "\'.concat(d,\'" is not supported\'));((e,i,s)=>{const{expected:n,remainingDelay:a}=r(e,s);t.set(i,setTimeout(o,a,t,i,n,"timeout"))})(i,a,n)}}}}catch(e){postMessage({error:{message:e.message},id:s.id,result:null})}}))})();';export{e as worker};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var o=function(o){return void 0!==o.method&&"call"===o.method};export{o as isCallNotification};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var r=function(r){return null===r.error&&"number"==typeof r.id};export{r as isClearResponse};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{generateUniqueNumber as e}from"../../../fast-unique-numbers/build/es2019/module.js";import{isCallNotification as t}from"./guards/call-notification.js";import{isClearResponse as r}from"./guards/clear-response.js";var i=function(i){var n=new Map([[0,function(){}]]),a=new Map([[0,function(){}]]),o=new Map,s=new Worker(i);s.addEventListener("message",(function(e){var i=e.data;if(t(i)){var s=i.params,m=s.timerId,d=s.timerType;if("interval"===d){var f=n.get(m);if("number"==typeof f){var l=o.get(f);if(void 0===l||l.timerId!==m||l.timerType!==d)throw new Error("The timer is in an undefined state.")}else{if(void 0===f)throw new Error("The timer is in an undefined state.");f()}}else if("timeout"===d){var p=a.get(m);if("number"==typeof p){var u=o.get(p);if(void 0===u||u.timerId!==m||u.timerType!==d)throw new Error("The timer is in an undefined state.")}else{if(void 0===p)throw new Error("The timer is in an undefined state.");p(),a.delete(m)}}}else{if(!r(i)){var v=i.error.message;throw new Error(v)}var w=i.id,c=o.get(w);if(void 0===c)throw new Error("The timer is in an undefined state.");var h=c.timerId,T=c.timerType;o.delete(w),"interval"===T?n.delete(h):a.delete(h)}}));return{clearInterval:function(t){var r=e(o);o.set(r,{timerId:t,timerType:"interval"}),n.set(t,r),s.postMessage({id:r,method:"clear",params:{timerId:t,timerType:"interval"}})},clearTimeout:function(t){var r=e(o);o.set(r,{timerId:t,timerType:"timeout"}),a.set(t,r),s.postMessage({id:r,method:"clear",params:{timerId:t,timerType:"timeout"}})},setInterval:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=e(n);return n.set(i,(function(){t(),"function"==typeof n.get(i)&&s.postMessage({id:null,method:"set",params:{delay:r,now:performance.now(),timerId:i,timerType:"interval"}})})),s.postMessage({id:null,method:"set",params:{delay:r,now:performance.now(),timerId:i,timerType:"interval"}}),i},setTimeout:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=e(a);return a.set(i,t),s.postMessage({id:null,method:"set",params:{delay:r,now:performance.now(),timerId:i,timerType:"timeout"}}),i}}};export{i as load};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bddh/starling-realtime-client",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.3",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"react",
|
|
6
6
|
"indexDB"
|
|
@@ -27,18 +27,19 @@
|
|
|
27
27
|
"deploy": "npm publish --registry=https://registry.npmjs.org --access public"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"lodash": "^4.17.21",
|
|
31
|
-
"uuid": "^9.0.0",
|
|
32
30
|
"@bddh/starling-brtc": "^1.0.2",
|
|
33
|
-
"@bddh/starling-timeout-controller": "^1.0.2"
|
|
31
|
+
"@bddh/starling-timeout-controller": "^1.0.2",
|
|
32
|
+
"lodash": "^4.17.21",
|
|
33
|
+
"uuid": "^9.0.0"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@bddh/starling-web-socket": "^1.0.10",
|
|
37
|
-
"lodash": "^4.17.21",
|
|
38
|
-
"uuid": "^9.0.0",
|
|
39
|
-
"@bddh/starling-json": "^1.0.1",
|
|
40
36
|
"@bddh/starling-brtc": "^1.0.2",
|
|
37
|
+
"@bddh/starling-cutout": "^1.2.1",
|
|
38
|
+
"@bddh/starling-json": "^1.0.1",
|
|
41
39
|
"@bddh/starling-timeout-controller": "^1.0.2",
|
|
42
|
-
"@bddh/starling-
|
|
43
|
-
|
|
40
|
+
"@bddh/starling-web-socket": "^1.0.10",
|
|
41
|
+
"lodash": "^4.17.21",
|
|
42
|
+
"uuid": "^9.0.0"
|
|
43
|
+
},
|
|
44
|
+
"gitHead": "c41faba560cd7aebaf1276f2cf384f6388d1cebd"
|
|
44
45
|
}
|