Add more docs

pull/96673/head
Piotr Jamróz 8 months ago
parent b7337edb0d
commit 79d57b49c9
No known key found for this signature in database
GPG Key ID: 1CF5CE03DBADA336
  1. 12
      public/app/core/utils/CorsSharedWorker.ts

@ -14,10 +14,22 @@ class SharedWorkerNotSupported implements SharedWorker {
addEventListener(): void {}
removeEventListener(): void {}
}
/**
* The base class is created dynamically here to allow later on syntax like:
* import { CorsSharedWorker as SharedWorker } from '../utils/CorsSharedWorker';
* And also take into account cases where SharedWorked is not available in the browser (mainly mobile browsers)
*
* It's important to use: new SharedWorker(...) syntax instead of new CorsSharedWorker(...) due to how web-workers
* are processing workers syntax (more details https://webpack.js.org/guides/web-workers/)
*/
const BaseSharedWorkerClass = sharedWorkersSupported() ? window.SharedWorker : SharedWorkerNotSupported;
export class CorsSharedWorker extends BaseSharedWorkerClass {
constructor(url: URL, options?: WorkerOptions) {
if (!sharedWorkersSupported()) {
return;
}
// by default, worker inherits HTML document's location and pathname which leads to wrong public path value
// the CorsWorkerPlugin will override it with the value based on the initial worker chunk, ie.
// initial worker chunk: http://host.com/cdn/scripts/worker-123.js

Loading…
Cancel
Save