@qamposer/react 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +315 -0
- package/dist/index-BbUFQqpD.d.cts +155 -0
- package/dist/index-BbUFQqpD.d.ts +155 -0
- package/dist/index.cjs +3028 -0
- package/dist/index.d.cts +185 -0
- package/dist/index.d.ts +185 -0
- package/dist/index.js +3012 -0
- package/dist/visualization.cjs +3525 -0
- package/dist/visualization.d.cts +46 -0
- package/dist/visualization.d.ts +46 -0
- package/dist/visualization.js +3517 -0
- package/package.json +114 -0
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
type Theme = 'light' | 'dark';
|
|
5
|
+
interface ThemeContextValue {
|
|
6
|
+
theme: Theme;
|
|
7
|
+
toggleTheme: () => void;
|
|
8
|
+
setTheme: (theme: Theme) => void;
|
|
9
|
+
}
|
|
10
|
+
interface ThemeProviderProps {
|
|
11
|
+
children: ReactNode;
|
|
12
|
+
defaultTheme?: Theme;
|
|
13
|
+
}
|
|
14
|
+
declare function ThemeProvider({ children, defaultTheme }: ThemeProviderProps): react_jsx_runtime.JSX.Element;
|
|
15
|
+
declare function useTheme(): ThemeContextValue;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Qamposer type definitions
|
|
19
|
+
*/
|
|
20
|
+
type GateType = 'H' | 'X' | 'Y' | 'Z' | 'CNOT' | 'RX' | 'RY' | 'RZ';
|
|
21
|
+
interface Gate {
|
|
22
|
+
id: string;
|
|
23
|
+
type: GateType;
|
|
24
|
+
/** Target qubit for single-qubit gates */
|
|
25
|
+
qubit?: number;
|
|
26
|
+
/** Control qubit for CNOT */
|
|
27
|
+
control?: number;
|
|
28
|
+
/** Target qubit for CNOT */
|
|
29
|
+
target?: number;
|
|
30
|
+
/** Parameter in radians for rotation gates (RX, RY, RZ) */
|
|
31
|
+
parameter?: number;
|
|
32
|
+
/** Position in the circuit (column index) */
|
|
33
|
+
position: number;
|
|
34
|
+
}
|
|
35
|
+
interface GateInfo {
|
|
36
|
+
type: GateType;
|
|
37
|
+
label: string;
|
|
38
|
+
description: string;
|
|
39
|
+
category: 'single' | 'rotation' | 'multi';
|
|
40
|
+
color: string;
|
|
41
|
+
}
|
|
42
|
+
interface Circuit {
|
|
43
|
+
qubits: number;
|
|
44
|
+
gates: Gate[];
|
|
45
|
+
}
|
|
46
|
+
type BackendType = 'ideal' | 'noisy_fake';
|
|
47
|
+
interface SimulationProfile {
|
|
48
|
+
type: BackendType;
|
|
49
|
+
backend_name?: string;
|
|
50
|
+
seed?: number;
|
|
51
|
+
}
|
|
52
|
+
interface BackendInfo {
|
|
53
|
+
id: string;
|
|
54
|
+
name: string;
|
|
55
|
+
num_qubits: number;
|
|
56
|
+
backend_type: BackendType;
|
|
57
|
+
description?: string;
|
|
58
|
+
}
|
|
59
|
+
interface CircuitRequest {
|
|
60
|
+
qubits: number;
|
|
61
|
+
gates: Omit<Gate, 'id'>[];
|
|
62
|
+
shots: number;
|
|
63
|
+
profile?: SimulationProfile;
|
|
64
|
+
}
|
|
65
|
+
interface QSpherePoint {
|
|
66
|
+
state: string;
|
|
67
|
+
x: number;
|
|
68
|
+
y: number;
|
|
69
|
+
z: number;
|
|
70
|
+
probability: number;
|
|
71
|
+
phase: number;
|
|
72
|
+
}
|
|
73
|
+
interface SimulationResult {
|
|
74
|
+
counts: Record<string, number>;
|
|
75
|
+
execution_time: number;
|
|
76
|
+
qsphere?: QSpherePoint[];
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Event passed to onSimulationComplete callback
|
|
80
|
+
* Contains simulation result along with circuit information
|
|
81
|
+
*/
|
|
82
|
+
interface SimulationCompleteEvent {
|
|
83
|
+
/** Simulation result from the adapter */
|
|
84
|
+
result: SimulationResult;
|
|
85
|
+
/** Circuit that was simulated */
|
|
86
|
+
circuit: Circuit;
|
|
87
|
+
/** OpenQASM 2.0 representation of the circuit */
|
|
88
|
+
qasm: string;
|
|
89
|
+
}
|
|
90
|
+
type SimulationStatus = 'idle' | 'simulating' | 'error';
|
|
91
|
+
interface QamposerConfig {
|
|
92
|
+
/** Maximum number of qubits (default: 5) */
|
|
93
|
+
maxQubits?: number;
|
|
94
|
+
/** Maximum number of gates (default: 500) */
|
|
95
|
+
maxGates?: number;
|
|
96
|
+
/** Maximum number of shots (default: 10000) */
|
|
97
|
+
maxShots?: number;
|
|
98
|
+
}
|
|
99
|
+
interface QamposerProviderProps {
|
|
100
|
+
/** Controlled mode: external circuit state */
|
|
101
|
+
circuit?: Circuit;
|
|
102
|
+
/** Controlled mode: callback when circuit changes */
|
|
103
|
+
onCircuitChange?: (circuit: Circuit) => void;
|
|
104
|
+
/** Uncontrolled mode: initial circuit */
|
|
105
|
+
defaultCircuit?: Circuit;
|
|
106
|
+
/** Simulation adapter for backend communication */
|
|
107
|
+
adapter?: SimulationAdapter;
|
|
108
|
+
/** Callback when simulation completes (includes circuit info) */
|
|
109
|
+
onSimulationComplete?: (event: SimulationCompleteEvent) => void;
|
|
110
|
+
/** Configuration options */
|
|
111
|
+
config?: QamposerConfig;
|
|
112
|
+
children: React.ReactNode;
|
|
113
|
+
}
|
|
114
|
+
interface SimulationAdapter {
|
|
115
|
+
/** Adapter name for display */
|
|
116
|
+
name: string;
|
|
117
|
+
/** Execute simulation */
|
|
118
|
+
simulate(request: CircuitRequest): Promise<SimulationResult>;
|
|
119
|
+
/** Check if adapter is available */
|
|
120
|
+
isAvailable(): Promise<boolean>;
|
|
121
|
+
/** Get available backends (optional) */
|
|
122
|
+
getBackends?(): Promise<BackendInfo[]>;
|
|
123
|
+
}
|
|
124
|
+
interface QamposerContextValue {
|
|
125
|
+
circuit: Circuit;
|
|
126
|
+
result: SimulationResult | null;
|
|
127
|
+
status: SimulationStatus;
|
|
128
|
+
error: Error | null;
|
|
129
|
+
qasmCode: string;
|
|
130
|
+
parseError: string | null;
|
|
131
|
+
editingGate: Gate | null;
|
|
132
|
+
addGate: (gate: Omit<Gate, 'id'>) => void;
|
|
133
|
+
removeGate: (id: string) => void;
|
|
134
|
+
updateGate: (id: string, updates: Partial<Gate>) => void;
|
|
135
|
+
updateGates: (gates: Gate[]) => void;
|
|
136
|
+
setQubits: (count: number) => void;
|
|
137
|
+
addQubit: () => void;
|
|
138
|
+
removeQubit: (qubitIndex?: number) => void;
|
|
139
|
+
clearCircuit: () => void;
|
|
140
|
+
setEditingGate: (gate: Gate | null) => void;
|
|
141
|
+
importQasm: (code: string) => QasmParseResult;
|
|
142
|
+
exportQasm: () => string;
|
|
143
|
+
setQasmCode: (code: string) => void;
|
|
144
|
+
simulate: (shots?: number, profile?: SimulationProfile) => Promise<SimulationResult>;
|
|
145
|
+
canSimulate: boolean;
|
|
146
|
+
adapter: SimulationAdapter;
|
|
147
|
+
config: Required<QamposerConfig>;
|
|
148
|
+
}
|
|
149
|
+
interface QasmParseResult {
|
|
150
|
+
success: boolean;
|
|
151
|
+
circuit?: Circuit;
|
|
152
|
+
errors: string[];
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export { type Circuit as C, type Gate as G, type QamposerProviderProps as Q, type SimulationAdapter as S, type Theme as T, type SimulationCompleteEvent as a, type QamposerConfig as b, type QamposerContextValue as c, type QasmParseResult as d, ThemeProvider as e, type GateType as f, type GateInfo as g, type CircuitRequest as h, type SimulationResult as i, type QSpherePoint as j, useTheme as u };
|