Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use the downloaded sim.html instead of hitting the live sim #185

Merged
merged 2 commits into from
Mar 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,8 @@
"dependencies": {
"@types/path-browserify": "^1.0.0",
"@vscode/extension-telemetry": "^0.7.5",
"makecode-browser": "^1.2.1",
"makecode-core": "^1.4.3",
"makecode-browser": "^1.3.1",
"makecode-core": "^1.7.0",
"path-browserify": "^1.0.1"
}
}
4 changes: 4 additions & 0 deletions src/web/makecodeOperations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ export function addDependencyAsync(folder: vscode.WorkspaceFolder, repo: string,
return enqueueOperationAsync(folder, () => cmd.addCommand(repo, undefined as any /* the name is optional */, {}), cancellationToken);
}

export function getSimHtmlAsync(folder: vscode.WorkspaceFolder, cancellationToken?: vscode.CancellationToken) {
return enqueueOperationAsync(folder, () => cmd.getSimHTML({}), cancellationToken);
}

/**
* The mkc CLI uses global state, so we need to perform operations in a queue just in case the
* user is doing things in multiple workspaces at once
Expand Down
12 changes: 8 additions & 4 deletions src/web/simulator.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import * as vscode from "vscode";

import { simloaderFiles } from "makecode-core/built/simloaderfiles";
import { existsAsync, readFileAsync } from "./host";
import { activeWorkspace, existsAsync, readFileAsync } from "./host";
import { simulateCommand } from "./extension";
import { getSimHtmlAsync } from "./makecodeOperations";

let extensionContext: vscode.ExtensionContext;

Expand Down Expand Up @@ -54,6 +55,7 @@ export class Simulator {

protected panel: vscode.WebviewPanel;
protected binaryJS: string | undefined;
protected simHtml: string | undefined;
protected disposables: vscode.Disposable[];

private constructor(panel: vscode.WebviewPanel) {
Expand All @@ -77,7 +79,8 @@ export class Simulator {
async simulateAsync(binaryJS: string) {
this.binaryJS = binaryJS;
this.panel.webview.html = "";
const simulatorHTML = await getSimHtmlAsync();
const simulatorHTML = await getSimLoaderHtmlAsync();
this.simHtml = await getSimHtmlAsync(activeWorkspace());
if (this.simState == null) {
this.simState = await extensionContext.workspaceState.get("simstate", {});
}
Expand All @@ -99,7 +102,8 @@ export class Simulator {
case "fetch-js":
this.postMessage({
...message,
text: this.binaryJS
text: this.binaryJS,
srcDoc: this.simHtml
});
break;
case "bulkserial":
Expand Down Expand Up @@ -151,7 +155,7 @@ window.addEventListener("DOMContentLoaded", () => {
`;


async function getSimHtmlAsync() {
async function getSimLoaderHtmlAsync() {
const index = simloaderFiles["index.html"];
const loaderJs = simloaderFiles["loader.js"];
let customJs = simloaderFiles["custom.js"];
Expand Down
Loading
Loading