troika-worker-utils
Advanced tools
Comparing version 0.32.0 to 0.33.0
@@ -6,2 +6,15 @@ # Change Log | ||
# [0.33.0](https://github.com/protectwise/troika/compare/v0.32.0...v0.33.0) (2020-10-02) | ||
### Bug Fixes | ||
* add "sideEffects":false to package.json files to assist treeshaking ([61109b2](https://github.com/protectwise/troika/commit/61109b2e3d21dc794ef66b3f28cf63bbdd34150e)) | ||
* add PURE annotations to make troika-three-text treeshakeable ([8e76b5c](https://github.com/protectwise/troika/commit/8e76b5c31a3cbda86595654ba9d66d8d635e44a1)) | ||
* remove redundant "browser" and defunct "jsnext:main" fields from package.json files ([0abec40](https://github.com/protectwise/troika/commit/0abec40e3af06d3ae4d990bf198d871b46730f1f)) | ||
# [0.32.0](https://github.com/protectwise/troika/compare/v0.31.0...v0.32.0) (2020-09-16) | ||
@@ -8,0 +21,0 @@ |
@@ -410,4 +410,7 @@ /** | ||
const workers = Object.create(null); | ||
const openRequests = Object.create(null); | ||
openRequests._count = 0; | ||
const openRequests = /*#__PURE__*/(() => { | ||
const obj = Object.create(null); | ||
obj._count = 0; | ||
return obj | ||
})(); | ||
@@ -582,3 +585,3 @@ | ||
*/ | ||
var ThenableWorkerModule = defineWorkerModule({ | ||
var ThenableWorkerModule = /*#__PURE__*/defineWorkerModule({ | ||
name: 'Thenable', | ||
@@ -585,0 +588,0 @@ dependencies: [DefaultThenable], |
@@ -435,4 +435,7 @@ (function (global, factory) { | ||
var workers = Object.create(null); | ||
var openRequests = Object.create(null); | ||
openRequests._count = 0; | ||
var openRequests = /*#__PURE__*/(function () { | ||
var obj = Object.create(null); | ||
obj._count = 0; | ||
return obj | ||
})(); | ||
@@ -615,3 +618,3 @@ | ||
*/ | ||
var ThenableWorkerModule = defineWorkerModule({ | ||
var ThenableWorkerModule = /*#__PURE__*/defineWorkerModule({ | ||
name: 'Thenable', | ||
@@ -618,0 +621,0 @@ dependencies: [DefaultThenable], |
@@ -1,12 +0,13 @@ | ||
'use strict';(function(m,r){"object"===typeof exports&&"undefined"!==typeof module?r(exports):"function"===typeof define&&define.amd?define(["exports"],r):(m=m||self,r(m.troika_worker_utils={}))})(this,function(m){function r(){function c(f,b){p++;var v=0;try{b===q&&g();var u=0<f&&e(b);u?u.call(b,a(function(a){v++;c(1,a)}),a(function(a){v++;c(-1,a)})):(l=f,k=b,h||(setTimeout(d,0),h=1))}catch(D){l||v||c(-1,D)}}function d(){var a=f;h=0;f=[];a.forEach(b)}function b(a){a()}function e(a){a=a&&(n(a)||"object"=== | ||
typeof a)&&a.then;return n(a)&&a}function a(a){var c=0;return function(){for(var g=[],f=arguments.length;f--;)g[f]=arguments[f];c++||a.apply(this,g)}}function g(){throw new TypeError("Chaining cycle detected");}var l=0,f=[],k,h=0,p=0,u=a(function(a){p||c(1,a)}),m=a(function(a){p||c(-1,a)}),n=function(a){return"function"===typeof a},q={then:function(a,c){var b=r();f.push(function(){var f=0<l?a:c;if(n(f))try{var h=f(k);h===b&&g();var d=e(h);d?d.call(h,b.resolve,b.reject):b.resolve(h)}catch(E){b.reject(E)}else b[0< | ||
l?"resolve":"reject"](k)});l&&!h&&(setTimeout(d,0),h=1);return b},resolve:u,reject:m};return q}function z(){var c,d,b=new Promise(function(b,a){c=b;d=a});return{then:b.then.bind(b),resolve:c,reject:d}}function F(){function c(a,g){var d=a.id,f=a.name,k=a.dependencies;void 0===k&&(k=[]);var h=a.init;void 0===h&&(h=function(){});a=a.getTransferables;void 0===a&&(a=null);if(!e[d])try{k=k.map(function(a){a&&a.isWorkerModule&&(c(a,function(a){if(a instanceof Error)throw a;}),a=e[a.id].value);return a}), | ||
h=b("<"+f+">.init",h),a&&(a=b("<"+f+">.getTransferables",a)),f=null,"function"===typeof h?f=h.apply(void 0,k):console.error("worker module init function failed to rehydrate"),e[d]={id:d,value:f,getTransferables:a},g(f)}catch(p){p&&p.noLog||console.error(p),g(p)}}function d(a,c){function b(a){try{var b=e[d].getTransferables&&e[d].getTransferables(a);b&&Array.isArray(b)&&b.length||(b=void 0);c(a,b)}catch(y){console.error(y),c(y)}}var f,d=a.id;a=a.args;e[d]&&"function"===typeof e[d].value||c(Error("Worker module "+ | ||
d+": not found or its 'init' did not return a function"));try{var g=(f=e[d]).value.apply(f,a);g&&"function"===typeof g.then?g.then(b,function(a){return c(a instanceof Error?a:Error(""+a))}):b(g)}catch(p){c(p)}}function b(a,c){var b=void 0;self.troikaDefine=function(a){return b=a};a=URL.createObjectURL(new Blob(["/** "+a.replace(/\*/g,"")+" **/\n\ntroikaDefine(\n"+c+"\n)"],{type:"application/javascript"}));try{importScripts(a)}catch(f){console.error(f)}URL.revokeObjectURL(a);delete self.troikaDefine; | ||
return b}var e=Object.create(null);self.addEventListener("message",function(a){var b=a.data,e=b.messageId;a=b.action;b=b.data;try{"registerModule"===a&&c(b,function(a){a instanceof Error?postMessage({messageId:e,success:!1,error:a.message}):postMessage({messageId:e,success:!0,result:{isCallable:"function"===typeof a}})}),"callModule"===a&&d(b,function(a,b){a instanceof Error?postMessage({messageId:e,success:!1,error:a.message}):postMessage({messageId:e,success:!0,result:a},b||void 0)})}catch(f){postMessage({messageId:e, | ||
success:!1,error:f.stack})}})}function G(c){var d=function(){for(var b=[],c=arguments.length;c--;)b[c]=arguments[c];return d._getInitResult().then(function(a){if("function"===typeof a)return a.apply(void 0,b);throw Error("Worker module function was called but `init` did not return a callable function");})};d._getInitResult=function(){var b=c.dependencies,e=c.init;b=Array.isArray(b)?b.map(function(a){return a&&a._getInitResult?a._getInitResult():a}):[];var a=q.all(b).then(function(a){return e.apply(null, | ||
a)});d._getInitResult=function(){return a};return a};return d}function w(c){function d(){for(var a=[],b=arguments.length;b--;)a[b]=arguments[b];k||(k=A(g,"registerModule",d.workerModuleData));return k.then(function(b){if(b.isCallable)return A(g,"callModule",{id:l,args:a});throw Error("Worker module function was called but `init` did not return a callable function");})}if(!(c&&"function"===typeof c.init||x))throw Error("requires `options.init` function");var b=c.dependencies,e=c.init,a=c.getTransferables, | ||
g=c.workerId;if(!B())return G(c);null==g&&(g="#default");var l="workerModule"+ ++H,f=c.name||l,k=null;b=b&&b.map(function(a){"function"!==typeof a||a.workerModuleData||(x=!0,a=w({workerId:g,name:"<"+f+"> function dependency: "+a.name,init:"function(){return (\n"+t(a)+"\n)}"}),x=!1);a&&a.workerModuleData&&(a=a.workerModuleData);return a});d.workerModuleData={isWorkerModule:!0,id:l,name:f,dependencies:b,init:t(e),getTransferables:a&&t(a)};return d}function t(c){c=c.toString();!/^function/.test(c)&& | ||
/^\w+\s*\(/.test(c)&&(c="function "+c);return c}function I(c){var d=C[c];d||(d=t(F),d=C[c]=new Worker(URL.createObjectURL(new Blob(["/** Worker Module Bootstrap: "+c.replace(/\*/g,"")+" **/\n\n;("+d+")()"],{type:"application/javascript"}))),d.onmessage=function(b){b=b.data;var c=b.messageId,a=n[c];if(!a)throw Error("WorkerModule response with empty or unknown messageId");delete n[c];n.count--;a(b)});return d}function A(c,d,b){var e=q(),a=++J;n[a]=function(a){a.success?e.resolve(a.result):e.reject(Error("Error in worker "+ | ||
d+" call: "+a.error))};n._count++;1E3<n.count&&console.warn("Large number of open WorkerModule requests, some may not be returning");I(c).postMessage({messageId:a,action:d,data:b});return e}r.all=z.all=function(c){var d=0,b=[],e=q();0===c.length?e.resolve([]):c.forEach(function(a,g){var l=q();l.resolve(a);l.then(function(a){d++;b[g]=a;d===c.length&&e.resolve(b)},e.reject)});return e};var q="function"===typeof Promise?z:r,B=function(){var c=!1;if("undefined"!==typeof window&&"undefined"!==typeof window.document)try{(new Worker(URL.createObjectURL(new Blob([""], | ||
{type:"application/javascript"})))).terminate(),c=!0}catch(d){console.log("Troika createWorkerModule: web workers not allowed; falling back to main thread execution. Cause: ["+d.message+"]")}B=function(){return c};return c},H=0,J=0,x=!1,C=Object.create(null),n=Object.create(null);n._count=0;var K=w({name:"Thenable",dependencies:[q],init:function(c){return c}});m.Thenable=q;m.ThenableWorkerModule=K;m.defineWorkerModule=w;m.stringifyFunction=t;Object.defineProperty(m,"__esModule",{value:!0})}) | ||
'use strict';(function(m,r){"object"===typeof exports&&"undefined"!==typeof module?r(exports):"function"===typeof define&&define.amd?define(["exports"],r):(m=m||self,r(m.troika_worker_utils={}))})(this,function(m){function r(){function b(f,c){n++;var v=0;try{c===q&&g();var u=0<f&&e(c);u?u.call(c,a(function(a){v++;b(1,a)}),a(function(a){v++;b(-1,a)})):(l=f,k=c,h||(setTimeout(d,0),h=1))}catch(D){l||v||b(-1,D)}}function d(){var a=f;h=0;f=[];a.forEach(c)}function c(a){a()}function e(a){a=a&&(p(a)||"object"=== | ||
typeof a)&&a.then;return p(a)&&a}function a(a){var b=0;return function(){for(var g=[],f=arguments.length;f--;)g[f]=arguments[f];b++||a.apply(this,g)}}function g(){throw new TypeError("Chaining cycle detected");}var l=0,f=[],k,h=0,n=0,u=a(function(a){n||b(1,a)}),m=a(function(a){n||b(-1,a)}),p=function(a){return"function"===typeof a},q={then:function(a,b){var c=r();f.push(function(){var f=0<l?a:b;if(p(f))try{var h=f(k);h===c&&g();var d=e(h);d?d.call(h,c.resolve,c.reject):c.resolve(h)}catch(E){c.reject(E)}else c[0< | ||
l?"resolve":"reject"](k)});l&&!h&&(setTimeout(d,0),h=1);return c},resolve:u,reject:m};return q}function z(){var b,d,c=new Promise(function(c,a){b=c;d=a});return{then:c.then.bind(c),resolve:b,reject:d}}function F(){function b(a,g){var d=a.id,f=a.name,k=a.dependencies;void 0===k&&(k=[]);var h=a.init;void 0===h&&(h=function(){});a=a.getTransferables;void 0===a&&(a=null);if(!e[d])try{k=k.map(function(a){a&&a.isWorkerModule&&(b(a,function(a){if(a instanceof Error)throw a;}),a=e[a.id].value);return a}), | ||
h=c("<"+f+">.init",h),a&&(a=c("<"+f+">.getTransferables",a)),f=null,"function"===typeof h?f=h.apply(void 0,k):console.error("worker module init function failed to rehydrate"),e[d]={id:d,value:f,getTransferables:a},g(f)}catch(n){n&&n.noLog||console.error(n),g(n)}}function d(a,b){function c(a){try{var c=e[d].getTransferables&&e[d].getTransferables(a);c&&Array.isArray(c)&&c.length||(c=void 0);b(a,c)}catch(y){console.error(y),b(y)}}var f,d=a.id;a=a.args;e[d]&&"function"===typeof e[d].value||b(Error("Worker module "+ | ||
d+": not found or its 'init' did not return a function"));try{var g=(f=e[d]).value.apply(f,a);g&&"function"===typeof g.then?g.then(c,function(a){return b(a instanceof Error?a:Error(""+a))}):c(g)}catch(n){b(n)}}function c(a,b){var c=void 0;self.troikaDefine=function(a){return c=a};a=URL.createObjectURL(new Blob(["/** "+a.replace(/\*/g,"")+" **/\n\ntroikaDefine(\n"+b+"\n)"],{type:"application/javascript"}));try{importScripts(a)}catch(f){console.error(f)}URL.revokeObjectURL(a);delete self.troikaDefine; | ||
return c}var e=Object.create(null);self.addEventListener("message",function(a){var c=a.data,e=c.messageId;a=c.action;c=c.data;try{"registerModule"===a&&b(c,function(a){a instanceof Error?postMessage({messageId:e,success:!1,error:a.message}):postMessage({messageId:e,success:!0,result:{isCallable:"function"===typeof a}})}),"callModule"===a&&d(c,function(a,c){a instanceof Error?postMessage({messageId:e,success:!1,error:a.message}):postMessage({messageId:e,success:!0,result:a},c||void 0)})}catch(f){postMessage({messageId:e, | ||
success:!1,error:f.stack})}})}function G(b){var d=function(){for(var c=[],b=arguments.length;b--;)c[b]=arguments[b];return d._getInitResult().then(function(a){if("function"===typeof a)return a.apply(void 0,c);throw Error("Worker module function was called but `init` did not return a callable function");})};d._getInitResult=function(){var c=b.dependencies,e=b.init;c=Array.isArray(c)?c.map(function(a){return a&&a._getInitResult?a._getInitResult():a}):[];var a=p.all(c).then(function(a){return e.apply(null, | ||
a)});d._getInitResult=function(){return a};return a};return d}function w(b){function d(){for(var a=[],b=arguments.length;b--;)a[b]=arguments[b];k||(k=A(g,"registerModule",d.workerModuleData));return k.then(function(b){if(b.isCallable)return A(g,"callModule",{id:l,args:a});throw Error("Worker module function was called but `init` did not return a callable function");})}if(!(b&&"function"===typeof b.init||x))throw Error("requires `options.init` function");var c=b.dependencies,e=b.init,a=b.getTransferables, | ||
g=b.workerId;if(!B())return G(b);null==g&&(g="#default");var l="workerModule"+ ++H,f=b.name||l,k=null;c=c&&c.map(function(a){"function"!==typeof a||a.workerModuleData||(x=!0,a=w({workerId:g,name:"<"+f+"> function dependency: "+a.name,init:"function(){return (\n"+t(a)+"\n)}"}),x=!1);a&&a.workerModuleData&&(a=a.workerModuleData);return a});d.workerModuleData={isWorkerModule:!0,id:l,name:f,dependencies:c,init:t(e),getTransferables:a&&t(a)};return d}function t(b){b=b.toString();!/^function/.test(b)&& | ||
/^\w+\s*\(/.test(b)&&(b="function "+b);return b}function I(b){var d=C[b];d||(d=t(F),d=C[b]=new Worker(URL.createObjectURL(new Blob(["/** Worker Module Bootstrap: "+b.replace(/\*/g,"")+" **/\n\n;("+d+")()"],{type:"application/javascript"}))),d.onmessage=function(b){b=b.data;var c=b.messageId,a=q[c];if(!a)throw Error("WorkerModule response with empty or unknown messageId");delete q[c];q.count--;a(b)});return d}function A(b,d,c){var e=p(),a=++J;q[a]=function(a){a.success?e.resolve(a.result):e.reject(Error("Error in worker "+ | ||
d+" call: "+a.error))};q._count++;1E3<q.count&&console.warn("Large number of open WorkerModule requests, some may not be returning");I(b).postMessage({messageId:a,action:d,data:c});return e}r.all=z.all=function(b){var d=0,c=[],e=p();0===b.length?e.resolve([]):b.forEach(function(a,g){var l=p();l.resolve(a);l.then(function(a){d++;c[g]=a;d===b.length&&e.resolve(c)},e.reject)});return e};var p="function"===typeof Promise?z:r,B=function(){var b=!1;if("undefined"!==typeof window&&"undefined"!==typeof window.document)try{(new Worker(URL.createObjectURL(new Blob([""], | ||
{type:"application/javascript"})))).terminate(),b=!0}catch(d){console.log("Troika createWorkerModule: web workers not allowed; falling back to main thread execution. Cause: ["+d.message+"]")}B=function(){return b};return b},H=0,J=0,x=!1,C=Object.create(null),q=function(){var b=Object.create(null);b._count=0;return b}(),K=w({name:"Thenable",dependencies:[p],init:function(b){return b}});m.Thenable=p;m.ThenableWorkerModule=K;m.defineWorkerModule=w;m.stringifyFunction=t;Object.defineProperty(m,"__esModule", | ||
{value:!0})}) |
{ | ||
"name": "troika-worker-utils", | ||
"version": "0.32.0", | ||
"version": "0.33.0", | ||
"description": "Utilities for executing code in Web Workers", | ||
@@ -12,8 +12,7 @@ "author": "Jason Johnston <jason.johnston@protectwise.com>", | ||
"license": "MIT", | ||
"sideEffects": false, | ||
"main": "dist/troika-worker-utils.umd.js", | ||
"browser": "dist/troika-worker-utils.umd.js", | ||
"jsnext:main": "dist/troika-worker-utils.esm.js", | ||
"module": "dist/troika-worker-utils.esm.js", | ||
"module:src": "src/index.js", | ||
"gitHead": "9f263fcbf9d5c45dc3c73ede2baf7db26978f2ec" | ||
"gitHead": "0c397b65aac6137ce1b4417e55d0deeb77b5ee5f" | ||
} |
@@ -9,3 +9,3 @@ import Thenable from './Thenable.js' | ||
*/ | ||
export default defineWorkerModule({ | ||
export default /*#__PURE__*/defineWorkerModule({ | ||
name: 'Thenable', | ||
@@ -12,0 +12,0 @@ dependencies: [Thenable], |
@@ -10,4 +10,7 @@ import Thenable from './Thenable.js' | ||
const workers = Object.create(null) | ||
const openRequests = Object.create(null) | ||
openRequests._count = 0 | ||
const openRequests = /*#__PURE__*/(() => { | ||
const obj = Object.create(null) | ||
obj._count = 0 | ||
return obj | ||
})() | ||
@@ -14,0 +17,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
85711
2176