From 328c82f63bd0883f91dd31b6ea259ecc49035cdc Mon Sep 17 00:00:00 2001 From: Yan Chen <48968912+chenyan-dfinity@users.noreply.github.com> Date: Tue, 3 Sep 2024 15:27:02 -0700 Subject: [PATCH] fix --- src/workers/file.ts | 3 --- src/workers/moc.ts | 10 +++++++++- src/workers/pow.ts | 4 ---- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/workers/file.ts b/src/workers/file.ts index 98dbc278..9022f9af 100644 --- a/src/workers/file.ts +++ b/src/workers/file.ts @@ -1,4 +1,3 @@ -import * as Comlink from "comlink"; declare var Motoko: any; interface ExtraFile { @@ -157,5 +156,3 @@ async function fetchFromGithub( return files; }); } - -Comlink.expose({ fetchPackage, fetchGithub, saveWorkplaceToMotoko }); diff --git a/src/workers/moc.ts b/src/workers/moc.ts index ab3fd4a5..a24aaf2e 100644 --- a/src/workers/moc.ts +++ b/src/workers/moc.ts @@ -1,5 +1,7 @@ import * as Comlink from "comlink"; import { loadMoc } from "./mocShim.js"; +import { fetchPackage, fetchGithub, saveWorkplaceToMotoko } from "./file"; +import { pow } from "./pow"; let Motoko: any; @@ -58,7 +60,13 @@ loadMoc() if (Motoko) { globalThis.Motoko = Motoko; Motoko.saveFile("Main.mo", ""); - Comlink.expose({ Moc }); + Comlink.expose({ + Moc, + fetchPackage, + fetchGithub, + saveWorkplaceToMotoko, + pow, + }); } else { console.error("Failed to initialize Motoko"); } diff --git a/src/workers/pow.ts b/src/workers/pow.ts index 5f4dcb9c..e9c2820d 100644 --- a/src/workers/pow.ts +++ b/src/workers/pow.ts @@ -1,5 +1,3 @@ -import * as Comlink from "comlink"; - const DOMAIN = "motoko-playground"; export function pow(timestamp: bigint) { @@ -33,5 +31,3 @@ function motokoHash(message: string): number { function hashOk(hash: number): boolean { return (hash & 0xc0000000) === 0; } - -Comlink.expose({ pow });