mirror of
https://github.com/denoland/deno.git
synced 2024-11-22 15:06:54 -05:00
c1fc7b2cd5
This commit refactors how we access "core", "internals" and "primordials" objects coming from `deno_core`, in our internal JavaScript code. Instead of capturing them from "globalThis.__bootstrap" namespace, we import them from recently added "ext:core/mod.js" file.
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 "ext:deno_web/02_event.js";
|
|
import { primordials } from "ext:core/mod.js";
|
|
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,
|
|
};
|