mirror of
https://github.com/denoland/deno.git
synced 2025-02-03 05:05:35 -05:00
b4aa153097
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>
51 lines
1.5 KiB
JavaScript
51 lines
1.5 KiB
JavaScript
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
|
|
|
// @ts-check
|
|
/// <reference no-default-lib="true" />
|
|
/// <reference path="../../core/lib.deno_core.d.ts" />
|
|
/// <reference path="../webidl/internal.d.ts" />
|
|
/// <reference path="../web/internal.d.ts" />
|
|
/// <reference path="../web/lib.deno_web.d.ts" />
|
|
/// <reference path="../url/internal.d.ts" />
|
|
/// <reference path="../url/lib.deno_url.d.ts" />
|
|
/// <reference path="./internal.d.ts" />
|
|
/// <reference lib="esnext" />
|
|
|
|
const core = globalThis.Deno.core;
|
|
const ops = core.ops;
|
|
import * as webidl from "internal:ext/webidl/00_webidl.js";
|
|
import { getParts } from "internal:ext/web/09_file.js";
|
|
import { URL } from "internal:ext/url/00_url.js";
|
|
|
|
/**
|
|
* @param {Blob} blob
|
|
* @returns {string}
|
|
*/
|
|
function createObjectURL(blob) {
|
|
const prefix = "Failed to execute 'createObjectURL' on 'URL'";
|
|
webidl.requiredArguments(arguments.length, 1, { prefix });
|
|
blob = webidl.converters["Blob"](blob, {
|
|
context: "Argument 1",
|
|
prefix,
|
|
});
|
|
|
|
return ops.op_blob_create_object_url(blob.type, getParts(blob));
|
|
}
|
|
|
|
/**
|
|
* @param {string} url
|
|
* @returns {void}
|
|
*/
|
|
function revokeObjectURL(url) {
|
|
const prefix = "Failed to execute 'revokeObjectURL' on 'URL'";
|
|
webidl.requiredArguments(arguments.length, 1, { prefix });
|
|
url = webidl.converters["DOMString"](url, {
|
|
context: "Argument 1",
|
|
prefix,
|
|
});
|
|
|
|
ops.op_blob_revoke_object_url(url);
|
|
}
|
|
|
|
URL.createObjectURL = createObjectURL;
|
|
URL.revokeObjectURL = revokeObjectURL;
|