mirror of
https://github.com/denoland/deno.git
synced 2024-11-24 15:19:26 -05:00
refactor: migrate runtime/ and ext/canvas/ to virtual ops module (#22196)
This commit is contained in:
parent
13a91a69f8
commit
95e4741f00
2 changed files with 23 additions and 17 deletions
|
@ -1,7 +1,7 @@
|
||||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
import { core, internals, primordials } from "ext:core/mod.js";
|
import { internals, primordials } from "ext:core/mod.js";
|
||||||
const ops = core.ops;
|
import { op_image_decode_png, op_image_process } from "ext:core/ops";
|
||||||
import * as webidl from "ext:deno_webidl/00_webidl.js";
|
import * as webidl from "ext:deno_webidl/00_webidl.js";
|
||||||
import { DOMException } from "ext:deno_web/01_dom_exception.js";
|
import { DOMException } from "ext:deno_web/01_dom_exception.js";
|
||||||
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
|
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
|
||||||
|
@ -438,7 +438,7 @@ function createImageBitmap(
|
||||||
"InvalidStateError",
|
"InvalidStateError",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const { data: imageData, width, height } = ops.op_image_decode_png(data);
|
const { data: imageData, width, height } = op_image_decode_png(data);
|
||||||
const processedImage = processImage(
|
const processedImage = processImage(
|
||||||
imageData,
|
imageData,
|
||||||
width,
|
width,
|
||||||
|
@ -517,7 +517,7 @@ function processImage(input, width, height, sx, sy, sw, sh, options) {
|
||||||
* the image at the correct location, which is the inverse of the x & y of
|
* the image at the correct location, which is the inverse of the x & y of
|
||||||
* sourceRectangle's top-left corner.
|
* sourceRectangle's top-left corner.
|
||||||
*/
|
*/
|
||||||
const data = ops.op_image_process(
|
const data = op_image_process(
|
||||||
new Uint8Array(TypedArrayPrototypeGetBuffer(input)),
|
new Uint8Array(TypedArrayPrototypeGetBuffer(input)),
|
||||||
{
|
{
|
||||||
width,
|
width,
|
||||||
|
|
|
@ -5,6 +5,16 @@ delete Intl.v8BreakIterator;
|
||||||
|
|
||||||
import { core, internals, primordials } from "ext:core/mod.js";
|
import { core, internals, primordials } from "ext:core/mod.js";
|
||||||
const ops = core.ops;
|
const ops = core.ops;
|
||||||
|
import {
|
||||||
|
op_bootstrap_args,
|
||||||
|
op_bootstrap_is_tty,
|
||||||
|
op_bootstrap_no_color,
|
||||||
|
op_bootstrap_pid,
|
||||||
|
op_main_module,
|
||||||
|
op_ppid,
|
||||||
|
op_set_format_exception_callback,
|
||||||
|
op_snapshot_options,
|
||||||
|
} from "ext:core/ops";
|
||||||
const {
|
const {
|
||||||
ArrayPrototypeFilter,
|
ArrayPrototypeFilter,
|
||||||
ArrayPrototypeIncludes,
|
ArrayPrototypeIncludes,
|
||||||
|
@ -331,14 +341,10 @@ function importScripts(...urls) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function opMainModule() {
|
const opArgs = memoizeLazy(() => op_bootstrap_args());
|
||||||
return ops.op_main_module();
|
const opPid = memoizeLazy(() => op_bootstrap_pid());
|
||||||
}
|
const opPpid = memoizeLazy(() => op_ppid());
|
||||||
|
setNoColorFn(() => op_bootstrap_no_color() || !op_bootstrap_is_tty());
|
||||||
const opArgs = memoizeLazy(() => ops.op_bootstrap_args());
|
|
||||||
const opPid = memoizeLazy(() => ops.op_bootstrap_pid());
|
|
||||||
const opPpid = memoizeLazy(() => ops.op_ppid());
|
|
||||||
setNoColorFn(() => ops.op_bootstrap_no_color() || !ops.op_bootstrap_is_tty());
|
|
||||||
|
|
||||||
function formatException(error) {
|
function formatException(error) {
|
||||||
if (
|
if (
|
||||||
|
@ -433,7 +439,7 @@ function runtimeStart(
|
||||||
core.setMacrotaskCallback(timers.handleTimerMacrotask);
|
core.setMacrotaskCallback(timers.handleTimerMacrotask);
|
||||||
core.setWasmStreamingCallback(fetch.handleWasmStreaming);
|
core.setWasmStreamingCallback(fetch.handleWasmStreaming);
|
||||||
core.setReportExceptionCallback(event.reportException);
|
core.setReportExceptionCallback(event.reportException);
|
||||||
ops.op_set_format_exception_callback(formatException);
|
op_set_format_exception_callback(formatException);
|
||||||
version.setVersions(
|
version.setVersions(
|
||||||
denoVersion,
|
denoVersion,
|
||||||
v8Version,
|
v8Version,
|
||||||
|
@ -741,7 +747,7 @@ const {
|
||||||
tsVersion,
|
tsVersion,
|
||||||
v8Version,
|
v8Version,
|
||||||
target,
|
target,
|
||||||
} = ops.op_snapshot_options();
|
} = op_snapshot_options();
|
||||||
|
|
||||||
function bootstrapMainRuntime(runtimeOptions) {
|
function bootstrapMainRuntime(runtimeOptions) {
|
||||||
if (hasBootstrapped) {
|
if (hasBootstrapped) {
|
||||||
|
@ -823,9 +829,9 @@ function bootstrapMainRuntime(runtimeOptions) {
|
||||||
ObjectDefineProperties(finalDenoNs, {
|
ObjectDefineProperties(finalDenoNs, {
|
||||||
pid: util.getterOnly(opPid),
|
pid: util.getterOnly(opPid),
|
||||||
ppid: util.getterOnly(opPpid),
|
ppid: util.getterOnly(opPpid),
|
||||||
noColor: util.getterOnly(() => ops.op_bootstrap_no_color()),
|
noColor: util.getterOnly(() => op_bootstrap_no_color()),
|
||||||
args: util.getterOnly(opArgs),
|
args: util.getterOnly(opArgs),
|
||||||
mainModule: util.getterOnly(opMainModule),
|
mainModule: util.getterOnly(() => op_main_module()),
|
||||||
// TODO(kt3k): Remove this export at v2
|
// TODO(kt3k): Remove this export at v2
|
||||||
// See https://github.com/denoland/deno/issues/9294
|
// See https://github.com/denoland/deno/issues/9294
|
||||||
customInspect: {
|
customInspect: {
|
||||||
|
@ -983,7 +989,7 @@ function bootstrapWorkerRuntime(
|
||||||
|
|
||||||
ObjectDefineProperties(finalDenoNs, {
|
ObjectDefineProperties(finalDenoNs, {
|
||||||
pid: util.getterOnly(opPid),
|
pid: util.getterOnly(opPid),
|
||||||
noColor: util.getterOnly(() => ops.op_bootstrap_no_color()),
|
noColor: util.getterOnly(() => op_bootstrap_no_color()),
|
||||||
args: util.getterOnly(opArgs),
|
args: util.getterOnly(opArgs),
|
||||||
// TODO(kt3k): Remove this export at v2
|
// TODO(kt3k): Remove this export at v2
|
||||||
// See https://github.com/denoland/deno/issues/9294
|
// See https://github.com/denoland/deno/issues/9294
|
||||||
|
|
Loading…
Reference in a new issue