1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-14 16:33:45 -05:00
denoland-deno/js/globals.ts

47 lines
1.6 KiB
TypeScript
Raw Normal View History

// Copyright 2018 the Deno authors. All rights reserved. MIT license.
import * as blob from "./blob";
import * as console_ from "./console";
import * as fetch_ from "./fetch";
2018-11-02 21:43:37 -04:00
import { Headers } from "./headers";
2018-10-03 21:41:59 -04:00
import { globalEval } from "./global_eval";
import { libdeno } from "./libdeno";
import * as textEncoding from "./text_encoding";
import * as timers from "./timers";
import * as urlSearchParams from "./url_search_params";
2018-10-23 07:43:43 -04:00
import * as domTypes from "./dom_types";
2018-09-12 15:16:42 -04:00
// During the build process, augmentations to the variable `window` in this
// file are tracked and created as part of default library that is built into
// deno, we only need to declare the enough to compile deno.
2018-08-07 16:27:31 -04:00
declare global {
const console: console_.Console;
const setTimeout: typeof timers.setTimeout;
// tslint:disable-next-line:variable-name
2018-09-10 06:27:08 -04:00
const TextEncoder: typeof textEncoding.TextEncoder;
2018-08-07 16:27:31 -04:00
}
// A reference to the global object.
export const window = globalEval("this");
2018-08-06 18:37:32 -04:00
window.window = window;
window.setTimeout = timers.setTimeout;
window.setInterval = timers.setInterval;
window.clearTimeout = timers.clearTimer;
window.clearInterval = timers.clearTimer;
window.console = new console_.Console(libdeno.print);
window.TextEncoder = textEncoding.TextEncoder;
window.TextDecoder = textEncoding.TextDecoder;
2018-09-20 18:53:29 -04:00
window.atob = textEncoding.atob;
window.btoa = textEncoding.btoa;
window.URLSearchParams = urlSearchParams.URLSearchParams;
2018-10-21 11:07:29 -04:00
window.fetch = fetch_.fetch;
2018-09-12 15:16:42 -04:00
2018-10-23 07:43:43 -04:00
// using the `as` keyword to mask the internal types when generating the
// runtime library
2018-11-02 21:43:37 -04:00
window.Headers = Headers as domTypes.HeadersConstructor;
window.Blob = blob.DenoBlob;