mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 12:19:12 +00:00
refactor: use web utils and lazy load utils from core (#22289)
This commit is contained in:
parent
c6def993e0
commit
c8b2af8ed1
7 changed files with 164 additions and 301 deletions
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
import { primordials } from "ext:core/mod.js";
|
||||
import { core, primordials } from "ext:core/mod.js";
|
||||
import {
|
||||
op_bootstrap_language,
|
||||
op_bootstrap_numcpus,
|
||||
|
@ -12,14 +12,13 @@ const {
|
|||
SymbolFor,
|
||||
} = primordials;
|
||||
|
||||
import * as util from "ext:runtime/06_util.js";
|
||||
import * as location from "ext:deno_web/12_location.js";
|
||||
import * as console from "ext:deno_console/01_console.js";
|
||||
import * as webidl from "ext:deno_webidl/00_webidl.js";
|
||||
import * as globalInterfaces from "ext:deno_web/04_global_interfaces.js";
|
||||
import * as webStorage from "ext:deno_webstorage/01_webstorage.js";
|
||||
import * as prompt from "ext:runtime/41_prompt.js";
|
||||
import { loadWebGPU, webgpu } from "ext:deno_webgpu/00_init.js";
|
||||
import { loadWebGPU } from "ext:deno_webgpu/00_init.js";
|
||||
|
||||
class Navigator {
|
||||
constructor() {
|
||||
|
@ -65,7 +64,7 @@ ObjectDefineProperties(Navigator.prototype, {
|
|||
enumerable: true,
|
||||
get() {
|
||||
webidl.assertBranded(this, NavigatorPrototype);
|
||||
loadWebGPU();
|
||||
const webgpu = loadWebGPU();
|
||||
return webgpu.gpu;
|
||||
},
|
||||
},
|
||||
|
@ -108,16 +107,16 @@ const mainRuntimeGlobalProperties = {
|
|||
Location: location.locationConstructorDescriptor,
|
||||
location: location.locationDescriptor,
|
||||
Window: globalInterfaces.windowConstructorDescriptor,
|
||||
window: util.getterOnly(() => globalThis),
|
||||
self: util.getterOnly(() => globalThis),
|
||||
Navigator: util.nonEnumerable(Navigator),
|
||||
navigator: util.getterOnly(() => navigator),
|
||||
alert: util.writable(prompt.alert),
|
||||
confirm: util.writable(prompt.confirm),
|
||||
prompt: util.writable(prompt.prompt),
|
||||
localStorage: util.getterOnly(webStorage.localStorage),
|
||||
sessionStorage: util.getterOnly(webStorage.sessionStorage),
|
||||
Storage: util.nonEnumerable(webStorage.Storage),
|
||||
window: core.propGetterOnly(() => globalThis),
|
||||
self: core.propGetterOnly(() => globalThis),
|
||||
Navigator: core.propNonEnumerable(Navigator),
|
||||
navigator: core.propGetterOnly(() => navigator),
|
||||
alert: core.propWritable(prompt.alert),
|
||||
confirm: core.propWritable(prompt.confirm),
|
||||
prompt: core.propWritable(prompt.prompt),
|
||||
localStorage: core.propGetterOnly(webStorage.localStorage),
|
||||
sessionStorage: core.propGetterOnly(webStorage.sessionStorage),
|
||||
Storage: core.propNonEnumerable(webStorage.Storage),
|
||||
};
|
||||
|
||||
export { mainRuntimeGlobalProperties, memoizeLazy };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue