Install an LMLayerWorker when in a Worker scope.

This commit is contained in:
Eddie Antonio Santos 2018-11-19 15:29:26 -07:00
parent 6c5ea6fea9
commit d1f8d71026
No known key found for this signature in database
GPG key ID: DD411EA4D9509D87
2 changed files with 3 additions and 1 deletions

View file

@ -17,7 +17,6 @@ describe('LMLayerWorker', function () {
assert.isString(code);
let blob = new Blob([code], { type: 'text/javascript' });
debugger;
let uri = URL.createObjectURL(blob);
let worker = new Worker(uri);

View file

@ -205,6 +205,9 @@ class LMLayerWorker {
// Let LMLayerWorker be available both in browser and in Node.
if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {
module.exports = LMLayerWorker;
} else if (typeof self !== 'undefined' && 'postMessage' in self) {
// Automatically install if we're in a Web Worker.
LMLayerWorker.install(self as DedicatedWorkerGlobalScope);
} else {
//@ts-ignore
window.LMLayerWorker = LMLayerWorker;