summaryrefslogtreecommitdiff
path: root/runtime/js
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/js')
-rw-r--r--runtime/js/11_workers.js4
-rw-r--r--runtime/js/40_read_file.js7
-rw-r--r--runtime/js/41_prompt.js3
-rw-r--r--runtime/js/99_main.js16
4 files changed, 17 insertions, 13 deletions
diff --git a/runtime/js/11_workers.js b/runtime/js/11_workers.js
index 5660b291c..c917a2880 100644
--- a/runtime/js/11_workers.js
+++ b/runtime/js/11_workers.js
@@ -38,8 +38,6 @@
return core.opAsync("op_host_get_message", id);
}
- const decoder = new TextDecoder();
-
/**
* @param {string} permission
* @return {boolean}
@@ -166,7 +164,7 @@
this.#name = name;
const hasSourceCode = false;
- const sourceCode = decoder.decode(new Uint8Array());
+ const sourceCode = core.decode(new Uint8Array());
if (
specifier.startsWith("./") || specifier.startsWith("../") ||
diff --git a/runtime/js/40_read_file.js b/runtime/js/40_read_file.js
index 1efd5338d..7eee28d89 100644
--- a/runtime/js/40_read_file.js
+++ b/runtime/js/40_read_file.js
@@ -2,6 +2,7 @@
"use strict";
((window) => {
+ const core = window.Deno.core;
const { open, openSync } = window.__bootstrap.files;
const { readAll, readAllSync } = window.__bootstrap.io;
@@ -29,8 +30,7 @@
const file = openSync(path);
try {
const contents = readAllSync(file);
- const decoder = new TextDecoder();
- return decoder.decode(contents);
+ return core.decode(contents);
} finally {
file.close();
}
@@ -40,8 +40,7 @@
const file = await open(path);
try {
const contents = await readAll(file);
- const decoder = new TextDecoder();
- return decoder.decode(contents);
+ return core.decode(contents);
} finally {
file.close();
}
diff --git a/runtime/js/41_prompt.js b/runtime/js/41_prompt.js
index d74a937aa..cb088dafa 100644
--- a/runtime/js/41_prompt.js
+++ b/runtime/js/41_prompt.js
@@ -5,7 +5,6 @@
const { isatty } = window.__bootstrap.tty;
const LF = "\n".charCodeAt(0);
const CR = "\r".charCodeAt(0);
- const decoder = new TextDecoder();
const core = window.Deno.core;
function alert(message = "Alert") {
@@ -70,7 +69,7 @@
}
buf.push(c[0]);
}
- return decoder.decode(new Uint8Array(buf));
+ return core.decode(new Uint8Array(buf));
}
window.__bootstrap.prompt = {
diff --git a/runtime/js/99_main.js b/runtime/js/99_main.js
index d64625993..7ec422c1f 100644
--- a/runtime/js/99_main.js
+++ b/runtime/js/99_main.js
@@ -16,6 +16,8 @@ delete Object.prototype.__proto__;
const errorStack = window.__bootstrap.errorStack;
const os = window.__bootstrap.os;
const timers = window.__bootstrap.timers;
+ const base64 = window.__bootstrap.base64;
+ const encoding = window.__bootstrap.encoding;
const Console = window.__bootstrap.console.Console;
const worker = window.__bootstrap.worker;
const signals = window.__bootstrap.signals;
@@ -198,6 +200,12 @@ delete Object.prototype.__proto__;
return new DOMException(msg, "NotSupported");
},
);
+ core.registerErrorBuilder(
+ "DOMExceptionInvalidCharacterError",
+ function DOMExceptionInvalidCharacterError(msg) {
+ return new DOMException(msg, "InvalidCharacterError");
+ },
+ );
}
class Navigator {
@@ -277,8 +285,8 @@ delete Object.prototype.__proto__;
),
Request: util.nonEnumerable(fetch.Request),
Response: util.nonEnumerable(fetch.Response),
- TextDecoder: util.nonEnumerable(TextDecoder),
- TextEncoder: util.nonEnumerable(TextEncoder),
+ TextDecoder: util.nonEnumerable(encoding.TextDecoder),
+ TextEncoder: util.nonEnumerable(encoding.TextEncoder),
TransformStream: util.nonEnumerable(streams.TransformStream),
URL: util.nonEnumerable(url.URL),
URLSearchParams: util.nonEnumerable(url.URLSearchParams),
@@ -295,8 +303,8 @@ delete Object.prototype.__proto__;
TransformStreamDefaultController: util.nonEnumerable(
streams.TransformStreamDefaultController,
),
- atob: util.writable(atob),
- btoa: util.writable(btoa),
+ atob: util.writable(base64.atob),
+ btoa: util.writable(base64.btoa),
clearInterval: util.writable(timers.clearInterval),
clearTimeout: util.writable(timers.clearTimeout),
console: util.writable(