mirror of
https://github.com/denoland/deno.git
synced 2024-11-22 15:06:54 -05:00
Remove __blob and __console namespaces (#4677)
This commit is contained in:
parent
491b8e1cea
commit
dd2d19b22d
1 changed files with 96 additions and 143 deletions
239
cli/js/lib.deno.shared_globals.d.ts
vendored
239
cli/js/lib.deno.shared_globals.d.ts
vendored
|
@ -15,8 +15,6 @@ declare interface WindowOrWorkerGlobalScope {
|
|||
// methods
|
||||
fetch: typeof __fetch.fetch;
|
||||
// properties
|
||||
console: __console.Console;
|
||||
Blob: typeof __blob.DenoBlob;
|
||||
File: __domTypes.DomFileConstructor;
|
||||
CustomEvent: typeof __customEvent.CustomEvent;
|
||||
Event: typeof __event.Event;
|
||||
|
@ -27,18 +25,6 @@ declare interface WindowOrWorkerGlobalScope {
|
|||
Request: __domTypes.RequestConstructor;
|
||||
Response: typeof __fetch.Response;
|
||||
location: __domTypes.Location;
|
||||
|
||||
addEventListener: (
|
||||
type: string,
|
||||
callback: __domTypes.EventListenerOrEventListenerObject | null,
|
||||
options?: boolean | __domTypes.AddEventListenerOptions | undefined
|
||||
) => void;
|
||||
dispatchEvent: (event: __domTypes.Event) => boolean;
|
||||
removeEventListener: (
|
||||
type: string,
|
||||
callback: __domTypes.EventListenerOrEventListenerObject | null,
|
||||
options?: boolean | __domTypes.EventListenerOptions | undefined
|
||||
) => void;
|
||||
}
|
||||
|
||||
// This follows the WebIDL at: https://webassembly.github.io/spec/js-api/
|
||||
|
@ -54,7 +40,7 @@ declare namespace WebAssembly {
|
|||
* function is useful if it is necessary to a compile a module before it can
|
||||
* be instantiated (otherwise, the `WebAssembly.instantiate()` function
|
||||
* should be used). */
|
||||
function compile(bufferSource: __domTypes.BufferSource): Promise<Module>;
|
||||
function compile(bufferSource: BufferSource): Promise<Module>;
|
||||
|
||||
/** Compiles a `WebAssembly.Module` directly from a streamed underlying
|
||||
* source. This function is useful if it is necessary to a compile a module
|
||||
|
@ -69,7 +55,7 @@ declare namespace WebAssembly {
|
|||
* The returned `Promise` resolves to both a compiled `WebAssembly.Module` and
|
||||
* its first `WebAssembly.Instance`. */
|
||||
function instantiate(
|
||||
bufferSource: __domTypes.BufferSource,
|
||||
bufferSource: BufferSource,
|
||||
importObject?: object
|
||||
): Promise<WebAssemblyInstantiatedSource>;
|
||||
|
||||
|
@ -91,7 +77,7 @@ declare namespace WebAssembly {
|
|||
|
||||
/** Validates a given typed array of WebAssembly binary code, returning
|
||||
* whether the bytes form a valid wasm module (`true`) or not (`false`). */
|
||||
function validate(bufferSource: __domTypes.BufferSource): boolean;
|
||||
function validate(bufferSource: BufferSource): boolean;
|
||||
|
||||
type ImportExportKind = "function" | "table" | "memory" | "global";
|
||||
|
||||
|
@ -106,7 +92,7 @@ declare namespace WebAssembly {
|
|||
}
|
||||
|
||||
class Module {
|
||||
constructor(bufferSource: __domTypes.BufferSource);
|
||||
constructor(bufferSource: BufferSource);
|
||||
|
||||
/** Given a `Module` and string, returns a copy of the contents of all
|
||||
* custom sections in the module with the given string name. */
|
||||
|
@ -231,8 +217,7 @@ declare function clearTimeout(id?: number): void;
|
|||
declare function clearInterval(id?: number): void;
|
||||
declare function queueMicrotask(func: Function): void;
|
||||
|
||||
declare const console: __console.Console;
|
||||
declare const Blob: typeof __blob.DenoBlob;
|
||||
declare const console: Console;
|
||||
declare const File: __domTypes.DomFileConstructor;
|
||||
declare const CustomEventInit: typeof __customEvent.CustomEventInit;
|
||||
declare const CustomEvent: typeof __customEvent.CustomEvent;
|
||||
|
@ -247,19 +232,20 @@ declare const ReadableStream: __domTypes.ReadableStreamConstructor;
|
|||
declare const Request: __domTypes.RequestConstructor;
|
||||
declare const Response: typeof __fetch.Response;
|
||||
|
||||
declare const addEventListener: (
|
||||
declare function addEventListener(
|
||||
type: string,
|
||||
callback: __domTypes.EventListenerOrEventListenerObject | null,
|
||||
options?: boolean | __domTypes.AddEventListenerOptions | undefined
|
||||
) => void;
|
||||
declare const dispatchEvent: (event: __domTypes.Event) => boolean;
|
||||
declare const removeEventListener: (
|
||||
): void;
|
||||
|
||||
declare function dispatchEvent(event: __domTypes.Event): boolean;
|
||||
|
||||
declare function removeEventListener(
|
||||
type: string,
|
||||
callback: __domTypes.EventListenerOrEventListenerObject | null,
|
||||
options?: boolean | __domTypes.EventListenerOptions | undefined
|
||||
) => void;
|
||||
): void;
|
||||
|
||||
declare type Blob = __domTypes.Blob;
|
||||
declare type Body = __domTypes.Body;
|
||||
declare type File = __domTypes.DomFile;
|
||||
declare type CustomEventInit = __domTypes.CustomEventInit;
|
||||
|
@ -280,7 +266,6 @@ declare interface ImportMeta {
|
|||
}
|
||||
|
||||
declare namespace __domTypes {
|
||||
export type BufferSource = ArrayBufferView | ArrayBuffer;
|
||||
export type HeadersInit =
|
||||
| Headers
|
||||
| Array<[string, string]>
|
||||
|
@ -300,7 +285,6 @@ declare namespace __domTypes {
|
|||
| "origin-only"
|
||||
| "origin-when-cross-origin"
|
||||
| "unsafe-url";
|
||||
export type BlobPart = BufferSource | Blob | string;
|
||||
export type FormDataEntryValue = DomFile | string;
|
||||
export interface DomIterable<K, V> {
|
||||
keys(): IterableIterator<K>;
|
||||
|
@ -312,11 +296,6 @@ declare namespace __domTypes {
|
|||
thisArg?: any
|
||||
): void;
|
||||
}
|
||||
type EndingType = "transparent" | "native";
|
||||
export interface BlobPropertyBag {
|
||||
type?: string;
|
||||
ending?: EndingType;
|
||||
}
|
||||
interface AbortSignalEventMap {
|
||||
abort: ProgressEvent;
|
||||
}
|
||||
|
@ -578,19 +557,6 @@ declare namespace __domTypes {
|
|||
new (): FormData;
|
||||
prototype: FormData;
|
||||
}
|
||||
/** A blob object represents a file-like object of immutable, raw data. */
|
||||
export interface Blob {
|
||||
/** The size, in bytes, of the data contained in the `Blob` object. */
|
||||
readonly size: number;
|
||||
/** A string indicating the media type of the data contained in the `Blob`.
|
||||
* If the type is unknown, this string is empty.
|
||||
*/
|
||||
readonly type: string;
|
||||
/** Returns a new `Blob` object containing the data in the specified range of
|
||||
* bytes of the source `Blob`.
|
||||
*/
|
||||
slice(start?: number, end?: number, contentType?: string): Blob;
|
||||
}
|
||||
export interface Body {
|
||||
/** A simple getter used to expose a `ReadableStream` of the body contents. */
|
||||
readonly body: ReadableStream<Uint8Array> | null;
|
||||
|
@ -894,106 +860,93 @@ declare namespace __domTypes {
|
|||
}
|
||||
}
|
||||
|
||||
declare namespace __blob {
|
||||
export class DenoBlob implements __domTypes.Blob {
|
||||
readonly size: number;
|
||||
readonly type: string;
|
||||
/** A blob object represents a file-like object of immutable, raw data. */
|
||||
constructor(
|
||||
blobParts?: __domTypes.BlobPart[],
|
||||
options?: __domTypes.BlobPropertyBag
|
||||
);
|
||||
slice(start?: number, end?: number, contentType?: string): DenoBlob;
|
||||
stream(): __domTypes.ReadableStream<Uint8Array>;
|
||||
text(): Promise<string>;
|
||||
arrayBuffer(): Promise<ArrayBuffer>;
|
||||
}
|
||||
type BufferSource = ArrayBufferView | ArrayBuffer;
|
||||
type BlobPart = BufferSource | Blob | string;
|
||||
|
||||
interface BlobPropertyBag {
|
||||
type?: string;
|
||||
ending?: "transparent" | "native";
|
||||
}
|
||||
|
||||
declare namespace __console {
|
||||
type InspectOptions = Partial<{
|
||||
showHidden: boolean;
|
||||
depth: number;
|
||||
colors: boolean;
|
||||
indentLevel: number;
|
||||
}>;
|
||||
export class CSI {
|
||||
static kClear: string;
|
||||
static kClearScreenDown: string;
|
||||
}
|
||||
const isConsoleInstance: unique symbol;
|
||||
export class Console {
|
||||
indentLevel: number;
|
||||
[isConsoleInstance]: boolean;
|
||||
/** Writes the arguments to stdout */
|
||||
log: (...args: unknown[]) => void;
|
||||
/** Writes the arguments to stdout */
|
||||
debug: (...args: unknown[]) => void;
|
||||
/** Writes the arguments to stdout */
|
||||
info: (...args: unknown[]) => void;
|
||||
/** Writes the properties of the supplied `obj` to stdout */
|
||||
dir: (
|
||||
obj: unknown,
|
||||
options?: Partial<{
|
||||
showHidden: boolean;
|
||||
depth: number;
|
||||
colors: boolean;
|
||||
indentLevel: number;
|
||||
}>
|
||||
) => void;
|
||||
/** A file-like object of immutable, raw data. Blobs represent data that isn't necessarily in a JavaScript-native format. The File interface is based on Blob, inheriting blob functionality and expanding it to support files on the user's system. */
|
||||
interface Blob {
|
||||
readonly size: number;
|
||||
readonly type: string;
|
||||
arrayBuffer(): Promise<ArrayBuffer>;
|
||||
slice(start?: number, end?: number, contentType?: string): Blob;
|
||||
stream(): ReadableStream;
|
||||
text(): Promise<string>;
|
||||
}
|
||||
|
||||
/** From MDN:
|
||||
* Displays an interactive tree of the descendant elements of
|
||||
* the specified XML/HTML element. If it is not possible to display
|
||||
* as an element the JavaScript Object view is shown instead.
|
||||
* The output is presented as a hierarchical listing of expandable
|
||||
* nodes that let you see the contents of child nodes.
|
||||
*
|
||||
* Since we write to stdout, we can't display anything interactive
|
||||
* we just fall back to `console.dir`.
|
||||
*/
|
||||
dirxml: (
|
||||
obj: unknown,
|
||||
options?: Partial<{
|
||||
showHidden: boolean;
|
||||
depth: number;
|
||||
colors: boolean;
|
||||
indentLevel: number;
|
||||
}>
|
||||
) => void;
|
||||
declare const Blob: {
|
||||
prototype: Blob;
|
||||
new (blobParts?: BlobPart[], options?: BlobPropertyBag): Blob;
|
||||
};
|
||||
|
||||
/** Writes the arguments to stdout */
|
||||
warn: (...args: unknown[]) => void;
|
||||
/** Writes the arguments to stdout */
|
||||
error: (...args: unknown[]) => void;
|
||||
/** Writes an error message to stdout if the assertion is `false`. If the
|
||||
* assertion is `true`, nothing happens.
|
||||
*
|
||||
* ref: https://console.spec.whatwg.org/#assert
|
||||
*/
|
||||
assert: (condition?: boolean, ...args: unknown[]) => void;
|
||||
count: (label?: string) => void;
|
||||
countReset: (label?: string) => void;
|
||||
table: (data: unknown, properties?: string[] | undefined) => void;
|
||||
time: (label?: string) => void;
|
||||
timeLog: (label?: string, ...args: unknown[]) => void;
|
||||
timeEnd: (label?: string) => void;
|
||||
group: (...label: unknown[]) => void;
|
||||
groupCollapsed: (...label: unknown[]) => void;
|
||||
groupEnd: () => void;
|
||||
clear: () => void;
|
||||
trace: (...args: unknown[]) => void;
|
||||
static [Symbol.hasInstance](instance: Console): boolean;
|
||||
}
|
||||
/** A symbol which can be used as a key for a custom method which will be called
|
||||
* when `Deno.inspect()` is called, or when the object is logged to the console.
|
||||
declare const isConsoleInstance: unique symbol;
|
||||
|
||||
declare class Console {
|
||||
indentLevel: number;
|
||||
[isConsoleInstance]: boolean;
|
||||
/** Writes the arguments to stdout */
|
||||
log: (...args: unknown[]) => void;
|
||||
/** Writes the arguments to stdout */
|
||||
debug: (...args: unknown[]) => void;
|
||||
/** Writes the arguments to stdout */
|
||||
info: (...args: unknown[]) => void;
|
||||
/** Writes the properties of the supplied `obj` to stdout */
|
||||
dir: (
|
||||
obj: unknown,
|
||||
options?: Partial<{
|
||||
showHidden: boolean;
|
||||
depth: number;
|
||||
colors: boolean;
|
||||
indentLevel: number;
|
||||
}>
|
||||
) => void;
|
||||
|
||||
/** From MDN:
|
||||
* Displays an interactive tree of the descendant elements of
|
||||
* the specified XML/HTML element. If it is not possible to display
|
||||
* as an element the JavaScript Object view is shown instead.
|
||||
* The output is presented as a hierarchical listing of expandable
|
||||
* nodes that let you see the contents of child nodes.
|
||||
*
|
||||
* Since we write to stdout, we can't display anything interactive
|
||||
* we just fall back to `console.dir`.
|
||||
*/
|
||||
export const customInspect: unique symbol;
|
||||
/**
|
||||
* `inspect()` converts input into string that has the same format
|
||||
* as printed by `console.log(...)`;
|
||||
dirxml: (
|
||||
obj: unknown,
|
||||
options?: Partial<{
|
||||
showHidden: boolean;
|
||||
depth: number;
|
||||
colors: boolean;
|
||||
indentLevel: number;
|
||||
}>
|
||||
) => void;
|
||||
|
||||
/** Writes the arguments to stdout */
|
||||
warn: (...args: unknown[]) => void;
|
||||
/** Writes the arguments to stdout */
|
||||
error: (...args: unknown[]) => void;
|
||||
/** Writes an error message to stdout if the assertion is `false`. If the
|
||||
* assertion is `true`, nothing happens.
|
||||
*
|
||||
* ref: https://console.spec.whatwg.org/#assert
|
||||
*/
|
||||
export function inspect(value: unknown, options?: InspectOptions): string;
|
||||
assert: (condition?: boolean, ...args: unknown[]) => void;
|
||||
count: (label?: string) => void;
|
||||
countReset: (label?: string) => void;
|
||||
table: (data: unknown, properties?: string[] | undefined) => void;
|
||||
time: (label?: string) => void;
|
||||
timeLog: (label?: string, ...args: unknown[]) => void;
|
||||
timeEnd: (label?: string) => void;
|
||||
group: (...label: unknown[]) => void;
|
||||
groupCollapsed: (...label: unknown[]) => void;
|
||||
groupEnd: () => void;
|
||||
clear: () => void;
|
||||
trace: (...args: unknown[]) => void;
|
||||
static [Symbol.hasInstance](instance: Console): boolean;
|
||||
}
|
||||
|
||||
declare namespace __event {
|
||||
|
@ -1153,7 +1106,7 @@ declare namespace __fetch {
|
|||
readonly body: __domTypes.ReadableStream<Uint8Array>;
|
||||
constructor(rid: number, contentType: string);
|
||||
arrayBuffer(): Promise<ArrayBuffer>;
|
||||
blob(): Promise<__domTypes.Blob>;
|
||||
blob(): Promise<Blob>;
|
||||
formData(): Promise<__domTypes.FormData>;
|
||||
json(): Promise<any>;
|
||||
text(): Promise<string>;
|
||||
|
@ -1187,7 +1140,7 @@ declare namespace __fetch {
|
|||
body_?: null | Body
|
||||
);
|
||||
arrayBuffer(): Promise<ArrayBuffer>;
|
||||
blob(): Promise<__domTypes.Blob>;
|
||||
blob(): Promise<Blob>;
|
||||
formData(): Promise<__domTypes.FormData>;
|
||||
json(): Promise<any>;
|
||||
text(): Promise<string>;
|
||||
|
@ -1219,7 +1172,7 @@ declare class TextDecoder {
|
|||
options?: { fatal?: boolean; ignoreBOM?: boolean }
|
||||
);
|
||||
/** Returns the result of running encoding's decoder. */
|
||||
decode(input?: __domTypes.BufferSource, options?: { stream?: false }): string;
|
||||
decode(input?: BufferSource, options?: { stream?: false }): string;
|
||||
readonly [Symbol.toStringTag]: string;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue