refactor: use web utils and lazy load utils from core (#22289)

This commit is contained in:
Leo Kettmeir 2024-02-06 22:28:32 +01:00 committed by GitHub
parent c6def993e0
commit c8b2af8ed1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 164 additions and 301 deletions

View file

@ -1,38 +1,7 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
import { op_lazy_load_esm } from "ext:core/ops";
import { core } from "ext:core/mod.js";
let webgpu;
const loadWebGPU = core.createLazyLoader("ext:deno_webgpu/01_webgpu.js");
function webGPUNonEnumerable(getter) {
let valueIsSet = false;
let value;
return {
get() {
loadWebGPU();
if (valueIsSet) {
return value;
} else {
return getter();
}
},
set(v) {
loadWebGPU();
valueIsSet = true;
value = v;
},
enumerable: false,
configurable: true,
};
}
function loadWebGPU() {
if (!webgpu) {
webgpu = op_lazy_load_esm("ext:deno_webgpu/01_webgpu.js");
}
}
export { loadWebGPU, webgpu, webGPUNonEnumerable };
export { loadWebGPU };