mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 09:31:22 -05:00

This PR refactors all internal js files (except core) to be written as ES modules. `__bootstrap`has been mostly replaced with static imports in form in `internal:[path to file from repo root]`. To specify if files are ESM, an `esm` method has been added to `Extension`, similar to the `js` method. A new ModuleLoader called `InternalModuleLoader` has been added to enable the loading of internal specifiers, which is used in all situations except when a snapshot is only loaded, and not a new one is created from it. --------- Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
83 lines
1.7 KiB
JavaScript
83 lines
1.7 KiB
JavaScript
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
|
|
|
// @ts-check
|
|
/// <reference path="../../core/internal.d.ts" />
|
|
|
|
import { EventTarget } from "internal:ext/web/02_event.js";
|
|
const primordials = globalThis.__bootstrap.primordials;
|
|
const {
|
|
Symbol,
|
|
SymbolToStringTag,
|
|
TypeError,
|
|
} = primordials;
|
|
|
|
const illegalConstructorKey = Symbol("illegalConstructorKey");
|
|
|
|
class Window extends EventTarget {
|
|
constructor(key = null) {
|
|
if (key !== illegalConstructorKey) {
|
|
throw new TypeError("Illegal constructor.");
|
|
}
|
|
super();
|
|
}
|
|
|
|
get [SymbolToStringTag]() {
|
|
return "Window";
|
|
}
|
|
}
|
|
|
|
class WorkerGlobalScope extends EventTarget {
|
|
constructor(key = null) {
|
|
if (key != illegalConstructorKey) {
|
|
throw new TypeError("Illegal constructor.");
|
|
}
|
|
super();
|
|
}
|
|
|
|
get [SymbolToStringTag]() {
|
|
return "WorkerGlobalScope";
|
|
}
|
|
}
|
|
|
|
class DedicatedWorkerGlobalScope extends WorkerGlobalScope {
|
|
constructor(key = null) {
|
|
if (key != illegalConstructorKey) {
|
|
throw new TypeError("Illegal constructor.");
|
|
}
|
|
super();
|
|
}
|
|
|
|
get [SymbolToStringTag]() {
|
|
return "DedicatedWorkerGlobalScope";
|
|
}
|
|
}
|
|
|
|
const dedicatedWorkerGlobalScopeConstructorDescriptor = {
|
|
configurable: true,
|
|
enumerable: false,
|
|
value: DedicatedWorkerGlobalScope,
|
|
writable: true,
|
|
};
|
|
|
|
const windowConstructorDescriptor = {
|
|
configurable: true,
|
|
enumerable: false,
|
|
value: Window,
|
|
writable: true,
|
|
};
|
|
|
|
const workerGlobalScopeConstructorDescriptor = {
|
|
configurable: true,
|
|
enumerable: false,
|
|
value: WorkerGlobalScope,
|
|
writable: true,
|
|
};
|
|
|
|
export {
|
|
DedicatedWorkerGlobalScope,
|
|
dedicatedWorkerGlobalScopeConstructorDescriptor,
|
|
Window,
|
|
windowConstructorDescriptor,
|
|
WorkerGlobalScope,
|
|
workerGlobalScopeConstructorDescriptor,
|
|
};
|