@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.
@@ -0,0 +1,185 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { Q as QamposerProviderProps$1, T as Theme, C as Circuit, S as SimulationAdapter, a as SimulationCompleteEvent, b as QamposerConfig, c as QamposerContextValue, d as QasmParseResult } from './index-BbUFQqpD.cjs';
3
+ export { h as CircuitRequest, G as Gate, g as GateInfo, f as GateType, j as QSpherePoint, i as SimulationResult, e as ThemeProvider, u as useTheme } from './index-BbUFQqpD.cjs';
4
+ import { ReactNode } from 'react';
5
+
6
+ interface QamposerMicroProps extends Omit<QamposerProviderProps$1, 'children'> {
7
+ /** Additional CSS class */
8
+ className?: string;
9
+ /** Show header (default: true) */
10
+ showHeader?: boolean;
11
+ /** Custom title (default: 'Qamposer') */
12
+ title?: string;
13
+ /** Custom ratio for operations:circuit (default: '1fr 3fr') */
14
+ gridTemplate?: string;
15
+ /** Default theme (default: 'dark') */
16
+ defaultTheme?: Theme;
17
+ /** Show theme toggle button (default: true) */
18
+ showThemeToggle?: boolean;
19
+ }
20
+ /**
21
+ * QamposerMicro - Minimal Quantum Circuit Composer
22
+ *
23
+ * A compact circuit editor with:
24
+ * - Operations panel (gate library)
25
+ * - Circuit editor (drag & drop)
26
+ * - Simulation controls
27
+ *
28
+ * Ideal for embedding in games, educational apps, or space-constrained layouts.
29
+ * Exposes the same data callbacks as the full Qamposer component.
30
+ */
31
+ declare function QamposerMicro({ className, showHeader, title, gridTemplate, defaultTheme, showThemeToggle, ...providerProps }: QamposerMicroProps): react_jsx_runtime.JSX.Element;
32
+
33
+ interface CircuitEditorProps {
34
+ /** Additional CSS class */
35
+ className?: string;
36
+ }
37
+ declare function CircuitEditor({ className }?: CircuitEditorProps): react_jsx_runtime.JSX.Element;
38
+
39
+ interface OperationsProps {
40
+ /** Additional CSS class */
41
+ className?: string;
42
+ }
43
+ declare function Operations({ className }?: OperationsProps): react_jsx_runtime.JSX.Element;
44
+
45
+ interface CodeEditorProps {
46
+ /** Additional CSS class */
47
+ className?: string;
48
+ /** Whether to show the header */
49
+ showHeader?: boolean;
50
+ /** Placeholder text */
51
+ placeholder?: string;
52
+ /** Read-only mode */
53
+ readOnly?: boolean;
54
+ }
55
+ declare function CodeEditor({ className, showHeader, placeholder, readOnly, }: CodeEditorProps): react_jsx_runtime.JSX.Element;
56
+
57
+ interface SimulationControlsProps {
58
+ /** Render as button only (without dialog) */
59
+ buttonOnly?: boolean;
60
+ /** Custom button label */
61
+ buttonLabel?: string;
62
+ /** Additional CSS class */
63
+ className?: string;
64
+ }
65
+ declare function SimulationControls({ buttonOnly, buttonLabel, className, }: SimulationControlsProps): react_jsx_runtime.JSX.Element;
66
+
67
+ interface QamposerProviderProps {
68
+ /** Controlled mode: external circuit state */
69
+ circuit?: Circuit;
70
+ /** Controlled mode: callback when circuit changes */
71
+ onCircuitChange?: (circuit: Circuit) => void;
72
+ /** Uncontrolled mode: initial circuit */
73
+ defaultCircuit?: Circuit;
74
+ /** Simulation adapter for backend communication */
75
+ adapter?: SimulationAdapter;
76
+ /** Callback when simulation completes (includes circuit info) */
77
+ onSimulationComplete?: (event: SimulationCompleteEvent) => void;
78
+ /** Configuration options */
79
+ config?: QamposerConfig;
80
+ children: ReactNode;
81
+ }
82
+ declare function QamposerProvider({ circuit: controlledCircuit, onCircuitChange, defaultCircuit, adapter, onSimulationComplete, config: userConfig, children, }: QamposerProviderProps): react_jsx_runtime.JSX.Element;
83
+
84
+ /**
85
+ * Hook to access Qamposer context
86
+ *
87
+ * Must be used within a QamposerProvider
88
+ *
89
+ * @example
90
+ * ```tsx
91
+ * function MyComponent() {
92
+ * const { circuit, addGate, simulate } = useQamposer();
93
+ *
94
+ * return (
95
+ * <div>
96
+ * <p>Qubits: {circuit.qubits}</p>
97
+ * <p>Gates: {circuit.gates.length}</p>
98
+ * <button onClick={() => simulate(1024)}>Run</button>
99
+ * </div>
100
+ * );
101
+ * }
102
+ * ```
103
+ */
104
+ declare function useQamposer(): QamposerContextValue;
105
+
106
+ /**
107
+ * Simulation adapter types
108
+ */
109
+
110
+ interface QiskitAdapterConfig {
111
+ /** Base URL of the Qiskit backend API */
112
+ baseUrl: string;
113
+ /** Additional headers to include in requests */
114
+ headers?: Record<string, string>;
115
+ /** Request timeout in milliseconds (default: 30000) */
116
+ timeout?: number;
117
+ }
118
+
119
+ /**
120
+ * Qiskit backend simulation adapter
121
+ */
122
+
123
+ /**
124
+ * Create a simulation adapter for Qiskit backend
125
+ *
126
+ * @example
127
+ * ```tsx
128
+ * // Simple usage with just URL
129
+ * const adapter = qiskitAdapter('https://api.example.com');
130
+ *
131
+ * // With configuration
132
+ * const adapter = qiskitAdapter({
133
+ * baseUrl: 'https://api.example.com',
134
+ * headers: { 'Authorization': 'Bearer token' },
135
+ * timeout: 30000,
136
+ * });
137
+ * ```
138
+ */
139
+ declare function qiskitAdapter(configOrUrl: string | QiskitAdapterConfig): SimulationAdapter;
140
+
141
+ /**
142
+ * No-operation adapter for editor-only mode
143
+ *
144
+ * Use this adapter when you only need the circuit editor
145
+ * without simulation capabilities.
146
+ */
147
+
148
+ /**
149
+ * No-op adapter that disables simulation
150
+ *
151
+ * @example
152
+ * ```tsx
153
+ * import { QamposerProvider, QamposerMicro, noopAdapter } from '@qamposer/react';
154
+ *
155
+ * // Editor-only mode - RunButton will be disabled
156
+ * <QamposerProvider adapter={noopAdapter}>
157
+ * <QamposerMicro />
158
+ * </QamposerProvider>
159
+ * ```
160
+ */
161
+ declare const noopAdapter: SimulationAdapter;
162
+
163
+ /**
164
+ * OpenQASM 2.0 utilities for bidirectional conversion between
165
+ * circuit representation and QASM code.
166
+ */
167
+
168
+ /**
169
+ * Convert circuit to OpenQASM 2.0 code
170
+ */
171
+ declare function circuitToQasm(circuit: Circuit): string;
172
+ /**
173
+ * Parse OpenQASM 2.0 code to circuit representation
174
+ */
175
+ declare function qasmToCircuit(qasm: string): QasmParseResult;
176
+ /**
177
+ * Generate unique gate ID
178
+ */
179
+ declare function generateGateId(): string;
180
+ /**
181
+ * Create a default empty circuit
182
+ */
183
+ declare function createDefaultCircuit(qubits?: number): Circuit;
184
+
185
+ export { Circuit, CircuitEditor, type CircuitEditorProps, CodeEditor, type CodeEditorProps, Operations, type OperationsProps, QamposerConfig, QamposerContextValue, QamposerMicro, type QamposerMicroProps, QamposerProvider, QamposerProviderProps$1 as QamposerProviderProps, QasmParseResult, type QiskitAdapterConfig, SimulationAdapter, SimulationCompleteEvent, SimulationControls, type SimulationControlsProps, Theme, circuitToQasm, createDefaultCircuit, generateGateId, noopAdapter, qasmToCircuit, qiskitAdapter, useQamposer };
@@ -0,0 +1,185 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { Q as QamposerProviderProps$1, T as Theme, C as Circuit, S as SimulationAdapter, a as SimulationCompleteEvent, b as QamposerConfig, c as QamposerContextValue, d as QasmParseResult } from './index-BbUFQqpD.js';
3
+ export { h as CircuitRequest, G as Gate, g as GateInfo, f as GateType, j as QSpherePoint, i as SimulationResult, e as ThemeProvider, u as useTheme } from './index-BbUFQqpD.js';
4
+ import { ReactNode } from 'react';
5
+
6
+ interface QamposerMicroProps extends Omit<QamposerProviderProps$1, 'children'> {
7
+ /** Additional CSS class */
8
+ className?: string;
9
+ /** Show header (default: true) */
10
+ showHeader?: boolean;
11
+ /** Custom title (default: 'Qamposer') */
12
+ title?: string;
13
+ /** Custom ratio for operations:circuit (default: '1fr 3fr') */
14
+ gridTemplate?: string;
15
+ /** Default theme (default: 'dark') */
16
+ defaultTheme?: Theme;
17
+ /** Show theme toggle button (default: true) */
18
+ showThemeToggle?: boolean;
19
+ }
20
+ /**
21
+ * QamposerMicro - Minimal Quantum Circuit Composer
22
+ *
23
+ * A compact circuit editor with:
24
+ * - Operations panel (gate library)
25
+ * - Circuit editor (drag & drop)
26
+ * - Simulation controls
27
+ *
28
+ * Ideal for embedding in games, educational apps, or space-constrained layouts.
29
+ * Exposes the same data callbacks as the full Qamposer component.
30
+ */
31
+ declare function QamposerMicro({ className, showHeader, title, gridTemplate, defaultTheme, showThemeToggle, ...providerProps }: QamposerMicroProps): react_jsx_runtime.JSX.Element;
32
+
33
+ interface CircuitEditorProps {
34
+ /** Additional CSS class */
35
+ className?: string;
36
+ }
37
+ declare function CircuitEditor({ className }?: CircuitEditorProps): react_jsx_runtime.JSX.Element;
38
+
39
+ interface OperationsProps {
40
+ /** Additional CSS class */
41
+ className?: string;
42
+ }
43
+ declare function Operations({ className }?: OperationsProps): react_jsx_runtime.JSX.Element;
44
+
45
+ interface CodeEditorProps {
46
+ /** Additional CSS class */
47
+ className?: string;
48
+ /** Whether to show the header */
49
+ showHeader?: boolean;
50
+ /** Placeholder text */
51
+ placeholder?: string;
52
+ /** Read-only mode */
53
+ readOnly?: boolean;
54
+ }
55
+ declare function CodeEditor({ className, showHeader, placeholder, readOnly, }: CodeEditorProps): react_jsx_runtime.JSX.Element;
56
+
57
+ interface SimulationControlsProps {
58
+ /** Render as button only (without dialog) */
59
+ buttonOnly?: boolean;
60
+ /** Custom button label */
61
+ buttonLabel?: string;
62
+ /** Additional CSS class */
63
+ className?: string;
64
+ }
65
+ declare function SimulationControls({ buttonOnly, buttonLabel, className, }: SimulationControlsProps): react_jsx_runtime.JSX.Element;
66
+
67
+ interface QamposerProviderProps {
68
+ /** Controlled mode: external circuit state */
69
+ circuit?: Circuit;
70
+ /** Controlled mode: callback when circuit changes */
71
+ onCircuitChange?: (circuit: Circuit) => void;
72
+ /** Uncontrolled mode: initial circuit */
73
+ defaultCircuit?: Circuit;
74
+ /** Simulation adapter for backend communication */
75
+ adapter?: SimulationAdapter;
76
+ /** Callback when simulation completes (includes circuit info) */
77
+ onSimulationComplete?: (event: SimulationCompleteEvent) => void;
78
+ /** Configuration options */
79
+ config?: QamposerConfig;
80
+ children: ReactNode;
81
+ }
82
+ declare function QamposerProvider({ circuit: controlledCircuit, onCircuitChange, defaultCircuit, adapter, onSimulationComplete, config: userConfig, children, }: QamposerProviderProps): react_jsx_runtime.JSX.Element;
83
+
84
+ /**
85
+ * Hook to access Qamposer context
86
+ *
87
+ * Must be used within a QamposerProvider
88
+ *
89
+ * @example
90
+ * ```tsx
91
+ * function MyComponent() {
92
+ * const { circuit, addGate, simulate } = useQamposer();
93
+ *
94
+ * return (
95
+ * <div>
96
+ * <p>Qubits: {circuit.qubits}</p>
97
+ * <p>Gates: {circuit.gates.length}</p>
98
+ * <button onClick={() => simulate(1024)}>Run</button>
99
+ * </div>
100
+ * );
101
+ * }
102
+ * ```
103
+ */
104
+ declare function useQamposer(): QamposerContextValue;
105
+
106
+ /**
107
+ * Simulation adapter types
108
+ */
109
+
110
+ interface QiskitAdapterConfig {
111
+ /** Base URL of the Qiskit backend API */
112
+ baseUrl: string;
113
+ /** Additional headers to include in requests */
114
+ headers?: Record<string, string>;
115
+ /** Request timeout in milliseconds (default: 30000) */
116
+ timeout?: number;
117
+ }
118
+
119
+ /**
120
+ * Qiskit backend simulation adapter
121
+ */
122
+
123
+ /**
124
+ * Create a simulation adapter for Qiskit backend
125
+ *
126
+ * @example
127
+ * ```tsx
128
+ * // Simple usage with just URL
129
+ * const adapter = qiskitAdapter('https://api.example.com');
130
+ *
131
+ * // With configuration
132
+ * const adapter = qiskitAdapter({
133
+ * baseUrl: 'https://api.example.com',
134
+ * headers: { 'Authorization': 'Bearer token' },
135
+ * timeout: 30000,
136
+ * });
137
+ * ```
138
+ */
139
+ declare function qiskitAdapter(configOrUrl: string | QiskitAdapterConfig): SimulationAdapter;
140
+
141
+ /**
142
+ * No-operation adapter for editor-only mode
143
+ *
144
+ * Use this adapter when you only need the circuit editor
145
+ * without simulation capabilities.
146
+ */
147
+
148
+ /**
149
+ * No-op adapter that disables simulation
150
+ *
151
+ * @example
152
+ * ```tsx
153
+ * import { QamposerProvider, QamposerMicro, noopAdapter } from '@qamposer/react';
154
+ *
155
+ * // Editor-only mode - RunButton will be disabled
156
+ * <QamposerProvider adapter={noopAdapter}>
157
+ * <QamposerMicro />
158
+ * </QamposerProvider>
159
+ * ```
160
+ */
161
+ declare const noopAdapter: SimulationAdapter;
162
+
163
+ /**
164
+ * OpenQASM 2.0 utilities for bidirectional conversion between
165
+ * circuit representation and QASM code.
166
+ */
167
+
168
+ /**
169
+ * Convert circuit to OpenQASM 2.0 code
170
+ */
171
+ declare function circuitToQasm(circuit: Circuit): string;
172
+ /**
173
+ * Parse OpenQASM 2.0 code to circuit representation
174
+ */
175
+ declare function qasmToCircuit(qasm: string): QasmParseResult;
176
+ /**
177
+ * Generate unique gate ID
178
+ */
179
+ declare function generateGateId(): string;
180
+ /**
181
+ * Create a default empty circuit
182
+ */
183
+ declare function createDefaultCircuit(qubits?: number): Circuit;
184
+
185
+ export { Circuit, CircuitEditor, type CircuitEditorProps, CodeEditor, type CodeEditorProps, Operations, type OperationsProps, QamposerConfig, QamposerContextValue, QamposerMicro, type QamposerMicroProps, QamposerProvider, QamposerProviderProps$1 as QamposerProviderProps, QasmParseResult, type QiskitAdapterConfig, SimulationAdapter, SimulationCompleteEvent, SimulationControls, type SimulationControlsProps, Theme, circuitToQasm, createDefaultCircuit, generateGateId, noopAdapter, qasmToCircuit, qiskitAdapter, useQamposer };