|
|
@ -139,16 +139,18 @@ export default class SuperMessagePort< |
|
|
|
this.log = logger('MP' + (logSuffix ? '-' + logSuffix : '')); |
|
|
|
this.log = logger('MP' + (logSuffix ? '-' + logSuffix : '')); |
|
|
|
this.debug = DEBUG; |
|
|
|
this.debug = DEBUG; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(typeof(window) !== 'undefined') { |
|
|
|
if('locks' in navigator) { |
|
|
|
if('locks' in navigator) { |
|
|
|
const id = 'lock-' + Date.now() + (Math.random() * 0xFFFF | 0); |
|
|
|
const id = 'lock-' + Date.now() + (Math.random() * 0xFFFF | 0); |
|
|
|
navigator.locks.request(id, () => new Promise(() => {})); |
|
|
|
navigator.locks.request(id, () => new Promise(() => {})); |
|
|
|
this.pushTask(this.createTask('lock', id)); |
|
|
|
this.pushTask(this.createTask('lock', id)); |
|
|
|
} else if(typeof(window) !== 'undefined') { |
|
|
|
} else { |
|
|
|
window.addEventListener('beforeunload', () => { |
|
|
|
window.addEventListener('beforeunload', () => { |
|
|
|
const task = this.createTask('close', undefined); |
|
|
|
const task = this.createTask('close', undefined); |
|
|
|
this.postMessage(undefined, task); |
|
|
|
this.postMessage(undefined, task); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.processTaskMap = { |
|
|
|
this.processTaskMap = { |
|
|
|
result: this.processResultTask, |
|
|
|
result: this.processResultTask, |
|
|
|