Skip to content

Commit d382701

Browse files
committed
型エラーを修正、一応selfに統一
1 parent 6b7b28b commit d382701

File tree

4 files changed

+18
-10
lines changed

4 files changed

+18
-10
lines changed

app/terminal/worker/jsEval.worker.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1+
/// <reference lib="webworker" />
2+
13
import type { ReplOutput } from "../repl";
24
import type { MessageType, WorkerRequest, WorkerResponse } from "./runtime";
35

46
let jsOutput: ReplOutput[] = [];
57

68
// Helper function to capture console output
7-
const originalConsole = globalThis.console;
8-
globalThis.console = {
9+
const originalConsole = self.console;
10+
self.console = {
911
...originalConsole,
1012
// eslint-disable-next-line @typescript-eslint/no-explicit-any
1113
log: (...args: any[]) => {
@@ -38,7 +40,7 @@ async function runCode({ id, payload }: WorkerRequest["runCode"]) {
3840
try {
3941
// Execute code directly with eval in the worker global scope
4042
// This will preserve variables across calls
41-
const result = globalThis.eval(code);
43+
const result = self.eval(code);
4244

4345
if (result !== undefined) {
4446
jsOutput.push({
@@ -77,7 +79,7 @@ function runFile({ id, payload }: WorkerRequest["runFile"]) {
7779
try {
7880
// Execute code directly with eval in the worker global scope
7981
// This will preserve variables across calls
80-
globalThis.eval(files[name]);
82+
self.eval(files[name]);
8183
} catch (e) {
8284
originalConsole.log(e);
8385
// TODO: stack trace?
@@ -147,7 +149,7 @@ async function restoreState({ id, payload }: WorkerRequest["restoreState"]) {
147149

148150
for (const command of commands) {
149151
try {
150-
globalThis.eval(command);
152+
self.eval(command);
151153
} catch (e) {
152154
// If restoration fails, we still continue with other commands
153155
originalConsole.error("Failed to restore command:", command, e);

app/terminal/worker/pyodide.worker.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/// <reference lib="webworker" />
2+
/// <reference lib="ES2023" />
3+
14
import type { PyodideInterface } from "pyodide";
25
// import { loadPyodide } from "pyodide"; -> Reading from "node:child_process" is not handled by plugins
36
import { version as pyodideVersion } from "pyodide/package.json";
@@ -32,10 +35,10 @@ function readAllFiles(): Record<string, string> {
3235
async function init({ id, payload }: WorkerRequest["init"]) {
3336
const { interruptBuffer } = payload;
3437
if (!pyodide) {
35-
(globalThis as WorkerGlobalScope).importScripts(`${PYODIDE_CDN}pyodide.js`);
38+
self.importScripts(`${PYODIDE_CDN}pyodide.js`);
3639

3740
// eslint-disable-next-line @typescript-eslint/no-explicit-any
38-
pyodide = await (globalThis as any).loadPyodide({ indexURL: PYODIDE_CDN });
41+
pyodide = await (self as any).loadPyodide({ indexURL: PYODIDE_CDN });
3942

4043
pyodide.setStdout({
4144
batched: (str: string) => {

app/terminal/worker/ruby.worker.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/// <reference lib="webworker" />
2+
/// <reference lib="ES2023" />
3+
14
import { DefaultRubyVM } from "@ruby/wasm-wasi/dist/browser";
25
import type { RubyVM } from "@ruby/wasm-wasi/dist/vm";
36
import type { MessageType, WorkerRequest, WorkerResponse } from "./runtime";
@@ -12,12 +15,12 @@ declare global {
1215
var stdout: { write: (str: string) => void };
1316
var stderr: { write: (str: string) => void };
1417
}
15-
globalThis.stdout = {
18+
self.stdout = {
1619
write(str: string) {
1720
stdoutBuffer += str;
1821
},
1922
};
20-
globalThis.stderr = {
23+
self.stderr = {
2124
write(str: string) {
2225
stderrBuffer += str;
2326
},

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"compilerOptions": {
33
"target": "ES2017",
4-
"lib": ["dom", "dom.iterable", "esnext", "webworker"],
4+
"lib": ["dom", "dom.iterable", "es2023"],
55
"allowJs": true,
66
"skipLibCheck": true,
77
"strict": true,

0 commit comments

Comments
 (0)