Skip to content
Open
Show file tree
Hide file tree
Changes from 14 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
2 changes: 1 addition & 1 deletion build.py
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now that we're just using the web target, should I simplify the code to account for that, or do I leave the structure as is in case we want to add the nodejs target back?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would simplify.

Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
npm_cmd = "npm.cmd" if platform.system() == "Windows" else "npm"

build_type = "debug" if args.debug else "release"
wasm_targets = ["web", "nodejs"] if not args.web_only else ["web"]
wasm_targets = ["web"] if not args.web_only else ["web"]
run_tests = args.test

root_dir = os.path.dirname(os.path.abspath(__file__))
Expand Down
9 changes: 9 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions source/npm/qsharp/generate_docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

// @ts-check

import { existsSync, mkdirSync, writeFileSync } from "node:fs";
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";

import { generate_docs } from "./lib/nodejs/qsc_wasm.cjs";
import initWasm, { generate_docs } from "./lib/web/qsc_wasm.js";

const scriptDirPath = dirname(fileURLToPath(import.meta.url));
const docsDirPath = join(scriptDirPath, "docs");
Expand All @@ -16,6 +16,11 @@ if (!existsSync(docsDirPath)) {
mkdirSync(docsDirPath);
}

// Initialize wasm before calling any exported functions
const wasmPath = join(scriptDirPath, "lib", "web", "qsc_wasm_bg.wasm");
const wasmBytes = readFileSync(wasmPath);
await initWasm({ module_or_path: wasmBytes });

// 'filename' will be of the format 'namespace/api.md' (except for 'toc.yaml')
// 'metadata' will be the metadata that will appear at the top of the file
// 'contents' will contain the non-metadata markdown expected
Expand Down
17 changes: 8 additions & 9 deletions source/npm/qsharp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,10 @@
"directory": "npm"
},
"exports": {
".": {
"browser": "./dist/browser.js",
"node": "./dist/main.js",
"default": "./dist/browser.js"
},
"./compiler-worker": "./dist/compiler/worker-browser.js",
"./language-service-worker": "./dist/language-service/worker-browser.js",
"./debug-service-worker": "./dist/debug-service/worker-browser.js",
".": "./dist/main.js",
"./compiler-worker": "./dist/compiler/worker.js",
"./language-service-worker": "./dist/language-service/worker.js",
"./debug-service-worker": "./dist/debug-service/worker.js",
"./katas": "./dist/katas.js",
"./katas-md": "./dist/katas-md.js",
"./state-viz": "./ux/circuit-vis/state-viz/worker/index.ts",
Expand All @@ -44,5 +40,8 @@
"docs",
"lib",
"ux"
]
],
"dependencies": {
"web-worker": "^1.5.0"
}
}
220 changes: 0 additions & 220 deletions source/npm/qsharp/src/browser.ts

This file was deleted.

29 changes: 29 additions & 0 deletions source/npm/qsharp/src/common-exports.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
export type { IVariable, IVariableChild } from "../lib/web/qsc_wasm.js";
export * as utils from "./utils.js";
export { log } from "./log.js";
export { QscEventTarget } from "./compiler/events.js";
export { QdkDiagnostics } from "./diagnostics.js";
export { default as samples } from "./samples.generated.js";
export { default as openqasm_samples } from "./openqasm-samples.generated.js";
export {
qsharpGithubUriScheme,
qsharpLibraryUriScheme,
} from "./language-service/language-service.js";
export type { Dump, ShotResult } from "./compiler/common.js";
export type { CompilerState, ProgramConfig } from "./compiler/compiler.js";
export type { ICompiler, ICompilerWorker } from "./compiler/compiler.js";
export type {
IDebugService,
IDebugServiceWorker,
} from "./debug-service/debug-service.js";
export type {
ILanguageService,
ILanguageServiceWorker,
LanguageServiceDiagnosticEvent,
LanguageServiceEvent,
LanguageServiceTestCallablesEvent,
} from "./language-service/language-service.js";
export type { ProjectLoader } from "./project.js";
export type { CircuitGroup as CircuitData } from "./data-structures/circuit.js";
export type { LogLevel } from "./log.js";
export { StepResultId } from "../lib/web/qsc_wasm.js";
8 changes: 0 additions & 8 deletions source/npm/qsharp/src/compiler/worker-browser.ts

This file was deleted.

7 changes: 0 additions & 7 deletions source/npm/qsharp/src/compiler/worker-node.ts

This file was deleted.

8 changes: 8 additions & 0 deletions source/npm/qsharp/src/compiler/worker.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import { createWorker } from "../workers/worker.js";
import { compilerProtocol } from "./compiler.js";

const messageHandler = createWorker(compilerProtocol);
addEventListener("message", messageHandler);
2 changes: 1 addition & 1 deletion source/npm/qsharp/src/debug-service/debug-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import type {
IStructStepResult,
IVariable,
} from "../../lib/web/qsc_wasm.js";
import { ProgramConfig } from "../browser.js";
import { ProgramConfig } from "../main.js";
import { eventStringToMsg } from "../compiler/common.js";
import {
IQscEventTarget,
Expand Down
8 changes: 0 additions & 8 deletions source/npm/qsharp/src/debug-service/worker-browser.ts

This file was deleted.

7 changes: 0 additions & 7 deletions source/npm/qsharp/src/debug-service/worker-node.ts

This file was deleted.

8 changes: 8 additions & 0 deletions source/npm/qsharp/src/debug-service/worker.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import { createWorker } from "../workers/worker.js";
import { debugServiceProtocol } from "./debug-service.js";

const messageHandler = createWorker(debugServiceProtocol);
addEventListener("message", messageHandler);
Loading
Loading