mirror of
https://github.com/denoland/deno.git
synced 2025-08-04 19:08:15 +00:00
refactor: Use ES modules for internal runtime code (#17648)
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>
This commit is contained in:
parent
65500f36e8
commit
b4aa153097
123 changed files with 41574 additions and 41713 deletions
201
ext/web/internal.d.ts
vendored
201
ext/web/internal.d.ts
vendored
|
@ -1,120 +1,111 @@
|
|||
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
// deno-lint-ignore-file no-var
|
||||
|
||||
/// <reference no-default-lib="true" />
|
||||
/// <reference lib="esnext" />
|
||||
|
||||
declare namespace globalThis {
|
||||
declare namespace __bootstrap {
|
||||
declare var infra: {
|
||||
collectSequenceOfCodepoints(
|
||||
input: string,
|
||||
position: number,
|
||||
condition: (char: string) => boolean,
|
||||
): {
|
||||
result: string;
|
||||
position: number;
|
||||
};
|
||||
ASCII_DIGIT: string[];
|
||||
ASCII_UPPER_ALPHA: string[];
|
||||
ASCII_LOWER_ALPHA: string[];
|
||||
ASCII_ALPHA: string[];
|
||||
ASCII_ALPHANUMERIC: string[];
|
||||
HTTP_TAB_OR_SPACE: string[];
|
||||
HTTP_WHITESPACE: string[];
|
||||
HTTP_TOKEN_CODE_POINT: string[];
|
||||
HTTP_TOKEN_CODE_POINT_RE: RegExp;
|
||||
HTTP_QUOTED_STRING_TOKEN_POINT: string[];
|
||||
HTTP_QUOTED_STRING_TOKEN_POINT_RE: RegExp;
|
||||
HTTP_TAB_OR_SPACE_PREFIX_RE: RegExp;
|
||||
HTTP_TAB_OR_SPACE_SUFFIX_RE: RegExp;
|
||||
HTTP_WHITESPACE_PREFIX_RE: RegExp;
|
||||
HTTP_WHITESPACE_SUFFIX_RE: RegExp;
|
||||
httpTrim(s: string): string;
|
||||
regexMatcher(chars: string[]): string;
|
||||
byteUpperCase(s: string): string;
|
||||
byteLowerCase(s: string): string;
|
||||
collectHttpQuotedString(
|
||||
input: string,
|
||||
position: number,
|
||||
extractValue: boolean,
|
||||
): {
|
||||
result: string;
|
||||
position: number;
|
||||
};
|
||||
forgivingBase64Encode(data: Uint8Array): string;
|
||||
forgivingBase64Decode(data: string): Uint8Array;
|
||||
serializeJSValueToJSONString(value: unknown): string;
|
||||
};
|
||||
declare module "internal:ext/web/00_infra.js" {
|
||||
function collectSequenceOfCodepoints(
|
||||
input: string,
|
||||
position: number,
|
||||
condition: (char: string) => boolean,
|
||||
): {
|
||||
result: string;
|
||||
position: number;
|
||||
};
|
||||
const ASCII_DIGIT: string[];
|
||||
const ASCII_UPPER_ALPHA: string[];
|
||||
const ASCII_LOWER_ALPHA: string[];
|
||||
const ASCII_ALPHA: string[];
|
||||
const ASCII_ALPHANUMERIC: string[];
|
||||
const HTTP_TAB_OR_SPACE: string[];
|
||||
const HTTP_WHITESPACE: string[];
|
||||
const HTTP_TOKEN_CODE_POINT: string[];
|
||||
const HTTP_TOKEN_CODE_POINT_RE: RegExp;
|
||||
const HTTP_QUOTED_STRING_TOKEN_POINT: string[];
|
||||
const HTTP_QUOTED_STRING_TOKEN_POINT_RE: RegExp;
|
||||
const HTTP_TAB_OR_SPACE_PREFIX_RE: RegExp;
|
||||
const HTTP_TAB_OR_SPACE_SUFFIX_RE: RegExp;
|
||||
const HTTP_WHITESPACE_PREFIX_RE: RegExp;
|
||||
const HTTP_WHITESPACE_SUFFIX_RE: RegExp;
|
||||
function httpTrim(s: string): string;
|
||||
function regexMatcher(chars: string[]): string;
|
||||
function byteUpperCase(s: string): string;
|
||||
function byteLowerCase(s: string): string;
|
||||
function collectHttpQuotedString(
|
||||
input: string,
|
||||
position: number,
|
||||
extractValue: boolean,
|
||||
): {
|
||||
result: string;
|
||||
position: number;
|
||||
};
|
||||
function forgivingBase64Encode(data: Uint8Array): string;
|
||||
function forgivingBase64Decode(data: string): Uint8Array;
|
||||
function serializeJSValueToJSONString(value: unknown): string;
|
||||
}
|
||||
|
||||
declare var domException: {
|
||||
DOMException: typeof DOMException;
|
||||
};
|
||||
declare module "internal:ext/web/01_dom_exception.js" {
|
||||
export = DOMException;
|
||||
}
|
||||
|
||||
declare namespace mimesniff {
|
||||
declare interface MimeType {
|
||||
type: string;
|
||||
subtype: string;
|
||||
parameters: Map<string, string>;
|
||||
}
|
||||
declare function parseMimeType(input: string): MimeType | null;
|
||||
declare function essence(mimeType: MimeType): string;
|
||||
declare function serializeMimeType(mimeType: MimeType): string;
|
||||
declare function extractMimeType(
|
||||
headerValues: string[] | null,
|
||||
): MimeType | null;
|
||||
}
|
||||
declare module "internal:ext/web/01_mimesniff.js" {
|
||||
interface MimeType {
|
||||
type: string;
|
||||
subtype: string;
|
||||
parameters: Map<string, string>;
|
||||
}
|
||||
function parseMimeType(input: string): MimeType | null;
|
||||
function essence(mimeType: MimeType): string;
|
||||
function serializeMimeType(mimeType: MimeType): string;
|
||||
function extractMimeType(
|
||||
headerValues: string[] | null,
|
||||
): MimeType | null;
|
||||
}
|
||||
|
||||
declare var eventTarget: {
|
||||
EventTarget: typeof EventTarget;
|
||||
};
|
||||
declare module "internal:ext/web/02_event.js" {
|
||||
const EventTarget: typeof EventTarget;
|
||||
const Event: typeof event;
|
||||
const ErrorEvent: typeof ErrorEvent;
|
||||
const CloseEvent: typeof CloseEvent;
|
||||
const MessageEvent: typeof MessageEvent;
|
||||
const CustomEvent: typeof CustomEvent;
|
||||
const ProgressEvent: typeof ProgressEvent;
|
||||
const PromiseRejectionEvent: typeof PromiseRejectionEvent;
|
||||
const reportError: typeof reportError;
|
||||
}
|
||||
|
||||
declare var event: {
|
||||
Event: typeof event;
|
||||
ErrorEvent: typeof ErrorEvent;
|
||||
CloseEvent: typeof CloseEvent;
|
||||
MessageEvent: typeof MessageEvent;
|
||||
CustomEvent: typeof CustomEvent;
|
||||
ProgressEvent: typeof ProgressEvent;
|
||||
PromiseRejectionEvent: typeof PromiseRejectionEvent;
|
||||
reportError: typeof reportError;
|
||||
};
|
||||
declare module "internal:ext/web/12_location.js" {
|
||||
function getLocationHref(): string | undefined;
|
||||
}
|
||||
|
||||
declare var location: {
|
||||
getLocationHref(): string | undefined;
|
||||
};
|
||||
declare module "internal:ext/web/05_base64.js" {
|
||||
function atob(data: string): string;
|
||||
function btoa(data: string): string;
|
||||
}
|
||||
|
||||
declare var base64: {
|
||||
atob(data: string): string;
|
||||
btoa(data: string): string;
|
||||
};
|
||||
declare module "internal:ext/web/09_file.js" {
|
||||
function blobFromObjectUrl(url: string): Blob | null;
|
||||
function getParts(blob: Blob): string[];
|
||||
const Blob: typeof Blob;
|
||||
const File: typeof File;
|
||||
}
|
||||
|
||||
declare var file: {
|
||||
blobFromObjectUrl(url: string): Blob | null;
|
||||
getParts(blob: Blob): string[];
|
||||
Blob: typeof Blob;
|
||||
File: typeof File;
|
||||
};
|
||||
declare module "internal:ext/web/06_streams.js" {
|
||||
const ReadableStream: typeof ReadableStream;
|
||||
function isReadableStreamDisturbed(stream: ReadableStream): boolean;
|
||||
function createProxy<T>(stream: ReadableStream<T>): ReadableStream<T>;
|
||||
}
|
||||
|
||||
declare var streams: {
|
||||
ReadableStream: typeof ReadableStream;
|
||||
isReadableStreamDisturbed(stream: ReadableStream): boolean;
|
||||
createProxy<T>(stream: ReadableStream<T>): ReadableStream<T>;
|
||||
};
|
||||
|
||||
declare namespace messagePort {
|
||||
declare type Transferable = {
|
||||
kind: "messagePort";
|
||||
data: number;
|
||||
} | {
|
||||
kind: "arrayBuffer";
|
||||
data: number;
|
||||
};
|
||||
declare interface MessageData {
|
||||
data: Uint8Array;
|
||||
transferables: Transferable[];
|
||||
}
|
||||
}
|
||||
declare module "internal:ext/web/13_message_port.js" {
|
||||
type Transferable = {
|
||||
kind: "messagePort";
|
||||
data: number;
|
||||
} | {
|
||||
kind: "arrayBuffer";
|
||||
data: number;
|
||||
};
|
||||
interface MessageData {
|
||||
data: Uint8Array;
|
||||
transferables: Transferable[];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue