Skip to content

Commit

Permalink
move into qsharp package
Browse files Browse the repository at this point in the history
  • Loading branch information
minestarks committed Feb 5, 2025
1 parent ad5030f commit fffdd8e
Show file tree
Hide file tree
Showing 30 changed files with 28 additions and 133 deletions.
11 changes: 0 additions & 11 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@
wasm_bld = os.path.join(root_dir, "target", "wasm32", build_type)
samples_src = os.path.join(root_dir, "samples")
npm_src = os.path.join(root_dir, "npm", "qsharp")
circuit_vis_src = os.path.join(root_dir, "circuit_vis")
play_src = os.path.join(root_dir, "playground")
pip_src = os.path.join(root_dir, "pip")
widgets_src = os.path.join(root_dir, "widgets")
Expand Down Expand Up @@ -399,16 +398,6 @@ def run_ci_historic_benchmark():
)
step_end()

if build_npm:
step_start("Building the circuit_vis package")

npm_args = [npm_cmd, "install"]
subprocess.run(npm_args, check=True, text=True, cwd=circuit_vis_src)

npm_args = [npm_cmd, "run", "build:prod"]
subprocess.run(npm_args, check=True, text=True, cwd=circuit_vis_src)
step_end()

if build_npm:
step_start("Building the npm package")
# Copy the wasm build files over for web and node targets
Expand Down
23 changes: 0 additions & 23 deletions circuit_vis/package.json

This file was deleted.

12 changes: 0 additions & 12 deletions circuit_vis/tsconfig.json

This file was deleted.

71 changes: 0 additions & 71 deletions circuit_vis/webpack.config.js

This file was deleted.

2 changes: 1 addition & 1 deletion compiler/qsc_circuit/src/circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use serde::Serialize;
use std::{fmt::Display, fmt::Write, ops::Not, vec};

/// Representation of a quantum circuit.
/// Implementation of <https://github.com/microsoft/quantum-viz.js/wiki/API-schema-reference>
/// Implementation of `Circuit` type at npm/qsharp/shared/circuit.ts
#[derive(Clone, Serialize, Default, Debug, PartialEq)]
pub struct Circuit {
pub operations: Vec<Operation>,
Expand Down
2 changes: 2 additions & 0 deletions npm/qsharp/src/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,3 +191,5 @@ export type {
};

export * as utils from "./utils.js";

export type { Circuit as CircuitData } from "./shared/circuit.js";
2 changes: 1 addition & 1 deletion npm/qsharp/src/compiler/compiler.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import { type Circuit as CircuitData } from "@microsoft/quantum-viz.js/lib/circuit.js";
import { type Circuit as CircuitData } from "../shared/circuit.js";
import {
IDocFile,
IOperationInfo,
Expand Down
2 changes: 1 addition & 1 deletion npm/qsharp/src/debug-service/debug-service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import { type Circuit as CircuitData } from "@microsoft/quantum-viz.js/lib/circuit.js";
import { type Circuit as CircuitData } from "../shared/circuit.js";
import type {
DebugService,
IBreakpointSpan,
Expand Down
1 change: 1 addition & 0 deletions npm/qsharp/src/shared/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This directory contains shared modules to be referenced from both `src/` and `ux/`.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

import { Register } from "./register";
import { Register } from "./register.js";

/**
* Circuit to be visualized.
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions npm/qsharp/ux/circuit-vis/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The code in this folder was copied and adapted from `https://github.com/microsoft/quantum-viz.js`.
7 changes: 7 additions & 0 deletions npm/qsharp/ux/circuit-vis/circuit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export {
ConditionalRender,
type Circuit,
type DataAttributes,
type Operation,
type Qubit,
} from "../../src/shared/circuit";
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions npm/qsharp/ux/circuit-vis/register.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export {
RegisterType,
type Register,
type RegisterMap,
type RegisterMetadata,
} from "../../src/shared/register";
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions npm/qsharp/ux/circuit.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import * as qviz from "@microsoft/quantum-viz.js/lib";
import * as qviz from "./circuit-vis";
import { useEffect, useRef, useState } from "preact/hooks";
import { CircuitProps } from "./data.js";
import { Spinner } from "./spinner.js";
Expand Down Expand Up @@ -131,7 +131,7 @@ function ZoomableCircuit(props: { circuit: qviz.Circuit }) {
function renderCircuit(circuit: qviz.Circuit, container: HTMLDivElement) {
qviz.draw(circuit, container);

// quantum-viz hardcodes the styles in the SVG.
// circuit-vis hardcodes the styles in the SVG.
// Remove the style elements -- we'll define the styles in our own CSS.
const styleElements = container.querySelectorAll("style");
styleElements?.forEach((tag) => tag.remove());
Expand Down
2 changes: 1 addition & 1 deletion npm/qsharp/ux/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,4 @@ export type CircuitProps = {
calculating: boolean;
};

export type CircuitData = import("@microsoft/quantum-viz.js/lib").Circuit;
export type CircuitData = import("../src/shared/circuit").Circuit;
8 changes: 2 additions & 6 deletions package-lock.json

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

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
"workspaces": [
"./npm/qsharp",
"./playground",
"./vscode",
"./circuit_vis"
"./vscode"
],
"license": "MIT",
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion vscode/src/circuit.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import { type Circuit as CircuitData } from "@microsoft/quantum-viz.js/lib";
import type { CircuitData } from "qsharp-lang";
import { escapeHtml } from "markdown-it/lib/common/utils.mjs";
import {
ICompilerWorker,
Expand Down

0 comments on commit fffdd8e

Please sign in to comment.