qsharp-lang 1.1.4-dev → 1.1.6-dev
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/dist/browser.d.ts +3 -3
- package/dist/browser.js +12 -58
- package/dist/compiler/compiler.d.ts +29 -9
- package/dist/compiler/compiler.js +42 -9
- package/dist/compiler/events.d.ts +1 -1
- package/dist/compiler/worker-browser.d.ts +1 -1
- package/dist/compiler/worker-browser.js +3 -40
- package/dist/compiler/worker-node.js +3 -39
- package/dist/debug-service/debug-service.d.ts +7 -5
- package/dist/debug-service/debug-service.js +20 -3
- package/dist/debug-service/worker-browser.d.ts +1 -1
- package/dist/debug-service/worker-browser.js +3 -29
- package/dist/debug-service/worker-node.js +3 -28
- package/dist/katas-content.generated.js +353 -353
- package/dist/language-service/language-service.d.ts +7 -1
- package/dist/language-service/language-service.js +27 -0
- package/dist/language-service/worker-browser.d.ts +1 -1
- package/dist/language-service/worker-browser.js +3 -29
- package/dist/language-service/worker-node.js +3 -28
- package/dist/main.d.ts +2 -2
- package/dist/main.js +7 -42
- package/dist/samples.generated.js +1 -1
- package/dist/workers/browser.d.ts +21 -0
- package/dist/workers/browser.js +67 -0
- package/dist/{worker-proxy.d.ts → workers/common.d.ts} +26 -9
- package/dist/{worker-proxy.js → workers/common.js} +33 -4
- package/dist/workers/node.d.ts +20 -0
- package/dist/workers/node.js +55 -0
- package/docs/Microsoft.Quantum.Arrays/All.md +4 -6
- package/docs/Microsoft.Quantum.Arrays/Any.md +4 -6
- package/docs/Microsoft.Quantum.Arrays/Chunks.md +4 -4
- package/docs/Microsoft.Quantum.Arrays/CircularlyShifted.md +4 -4
- package/docs/Microsoft.Quantum.Arrays/ColumnAt.md +4 -4
- package/docs/Microsoft.Quantum.Arrays/Count.md +4 -6
- package/docs/Microsoft.Quantum.Arrays/Diagonal.md +4 -4
- package/docs/Microsoft.Quantum.Arrays/DrawMany.md +5 -6
- package/docs/Microsoft.Quantum.Arrays/Enumerated.md +4 -5
- package/docs/Microsoft.Quantum.Arrays/Excluding.md +4 -5
- package/docs/Microsoft.Quantum.Arrays/Filtered.md +4 -6
- package/docs/Microsoft.Quantum.Arrays/FlatMapped.md +4 -5
- package/docs/Microsoft.Quantum.Arrays/Flattened.md +4 -4
- package/docs/Microsoft.Quantum.Arrays/Fold.md +4 -5
- package/docs/Microsoft.Quantum.Arrays/ForEach.md +5 -7
- package/docs/Microsoft.Quantum.Arrays/Head.md +4 -4
- package/docs/Microsoft.Quantum.Arrays/HeadAndRest.md +4 -4
- package/docs/Microsoft.Quantum.Arrays/IndexOf.md +4 -5
- package/docs/Microsoft.Quantum.Arrays/IndexRange.md +4 -5
- package/docs/Microsoft.Quantum.Arrays/Interleaved.md +4 -4
- package/docs/Microsoft.Quantum.Arrays/IsEmpty.md +4 -4
- package/docs/Microsoft.Quantum.Arrays/IsRectangularArray.md +4 -4
- package/docs/Microsoft.Quantum.Arrays/IsSorted.md +4 -5
- package/docs/Microsoft.Quantum.Arrays/IsSquareArray.md +4 -4
- package/docs/Microsoft.Quantum.Arrays/Mapped.md +4 -6
- package/docs/Microsoft.Quantum.Arrays/MappedByIndex.md +4 -6
- package/docs/Microsoft.Quantum.Arrays/MappedOverRange.md +4 -6
- package/docs/Microsoft.Quantum.Arrays/Most.md +4 -5
- package/docs/Microsoft.Quantum.Arrays/MostAndTail.md +4 -4
- package/docs/Microsoft.Quantum.Arrays/Padded.md +4 -5
- package/docs/Microsoft.Quantum.Arrays/Partitioned.md +4 -4
- package/docs/Microsoft.Quantum.Arrays/Rest.md +4 -5
- package/docs/Microsoft.Quantum.Arrays/Reversed.md +4 -5
- package/docs/Microsoft.Quantum.Arrays/SequenceI.md +4 -4
- package/docs/Microsoft.Quantum.Arrays/SequenceL.md +4 -4
- package/docs/Microsoft.Quantum.Arrays/Sorted.md +4 -5
- package/docs/Microsoft.Quantum.Arrays/Subarray.md +4 -6
- package/docs/Microsoft.Quantum.Arrays/Swapped.md +4 -4
- package/docs/Microsoft.Quantum.Arrays/Tail.md +4 -4
- package/docs/Microsoft.Quantum.Arrays/Transposed.md +4 -5
- package/docs/Microsoft.Quantum.Arrays/Unzipped.md +4 -5
- package/docs/Microsoft.Quantum.Arrays/Where.md +4 -5
- package/docs/Microsoft.Quantum.Arrays/Windows.md +4 -4
- package/docs/Microsoft.Quantum.Arrays/Zipped.md +4 -5
- package/docs/Microsoft.Quantum.Canon/ApplyCNOTChain.md +5 -5
- package/docs/Microsoft.Quantum.Canon/ApplyControlledOnBitString.md +5 -6
- package/docs/Microsoft.Quantum.Canon/ApplyControlledOnInt.md +5 -6
- package/docs/Microsoft.Quantum.Canon/ApplyP.md +5 -6
- package/docs/Microsoft.Quantum.Canon/ApplyPauli.md +5 -6
- package/docs/Microsoft.Quantum.Canon/ApplyPauliFromBitString.md +5 -6
- package/docs/Microsoft.Quantum.Canon/ApplyPauliFromInt.md +5 -6
- package/docs/Microsoft.Quantum.Canon/ApplyQFT.md +5 -5
- package/docs/Microsoft.Quantum.Canon/ApplyToEach.md +5 -5
- package/docs/Microsoft.Quantum.Canon/ApplyToEachA.md +5 -6
- package/docs/Microsoft.Quantum.Canon/ApplyToEachC.md +5 -6
- package/docs/Microsoft.Quantum.Canon/ApplyToEachCA.md +5 -6
- package/docs/Microsoft.Quantum.Canon/ApplyXorInPlace.md +5 -6
- package/docs/Microsoft.Quantum.Canon/ApplyXorInPlaceL.md +5 -6
- package/docs/Microsoft.Quantum.Canon/CX.md +5 -5
- package/docs/Microsoft.Quantum.Canon/CY.md +5 -5
- package/docs/Microsoft.Quantum.Canon/CZ.md +5 -5
- package/docs/Microsoft.Quantum.Canon/Fst.md +4 -4
- package/docs/Microsoft.Quantum.Canon/Snd.md +4 -4
- package/docs/Microsoft.Quantum.Canon/SwapReverseRegister.md +5 -5
- package/docs/Microsoft.Quantum.Convert/BigIntAsBoolArray.md +4 -5
- package/docs/Microsoft.Quantum.Convert/BoolArrayAsBigInt.md +4 -5
- package/docs/Microsoft.Quantum.Convert/BoolArrayAsInt.md +4 -4
- package/docs/Microsoft.Quantum.Convert/BoolArrayAsResultArray.md +4 -5
- package/docs/Microsoft.Quantum.Convert/BoolAsResult.md +4 -5
- package/docs/Microsoft.Quantum.Convert/ComplexAsComplexPolar.md +4 -5
- package/docs/Microsoft.Quantum.Convert/ComplexPolarAsComplex.md +4 -5
- package/docs/Microsoft.Quantum.Convert/IntAsBigInt.md +4 -4
- package/docs/Microsoft.Quantum.Convert/IntAsBoolArray.md +4 -5
- package/docs/Microsoft.Quantum.Convert/IntAsDouble.md +4 -4
- package/docs/Microsoft.Quantum.Convert/ResultArrayAsBoolArray.md +4 -5
- package/docs/Microsoft.Quantum.Convert/ResultArrayAsInt.md +4 -4
- package/docs/Microsoft.Quantum.Convert/ResultAsBool.md +4 -5
- package/docs/Microsoft.Quantum.Core/IsRangeEmpty.md +4 -4
- package/docs/Microsoft.Quantum.Core/Length.md +4 -4
- package/docs/Microsoft.Quantum.Core/RangeEnd.md +4 -5
- package/docs/Microsoft.Quantum.Core/RangeReverse.md +4 -4
- package/docs/Microsoft.Quantum.Core/RangeStart.md +4 -4
- package/docs/Microsoft.Quantum.Core/RangeStep.md +4 -4
- package/docs/Microsoft.Quantum.Core/Repeated.md +4 -4
- package/docs/Microsoft.Quantum.Diagnostics/CheckAllZero.md +5 -5
- package/docs/Microsoft.Quantum.Diagnostics/CheckOperationsAreEqual.md +5 -5
- package/docs/Microsoft.Quantum.Diagnostics/CheckZero.md +5 -5
- package/docs/Microsoft.Quantum.Diagnostics/DumpMachine.md +4 -4
- package/docs/Microsoft.Quantum.Diagnostics/Fact.md +4 -4
- package/docs/Microsoft.Quantum.Intrinsic/CCNOT.md +5 -5
- package/docs/Microsoft.Quantum.Intrinsic/CNOT.md +5 -5
- package/docs/Microsoft.Quantum.Intrinsic/Exp.md +5 -5
- package/docs/Microsoft.Quantum.Intrinsic/H.md +11 -8
- package/docs/Microsoft.Quantum.Intrinsic/I.md +5 -5
- package/docs/Microsoft.Quantum.Intrinsic/M.md +5 -6
- package/docs/Microsoft.Quantum.Intrinsic/Measure.md +5 -6
- package/docs/Microsoft.Quantum.Intrinsic/Message.md +4 -4
- package/docs/Microsoft.Quantum.Intrinsic/R.md +5 -5
- package/docs/Microsoft.Quantum.Intrinsic/R1.md +5 -5
- package/docs/Microsoft.Quantum.Intrinsic/R1Frac.md +5 -11
- package/docs/Microsoft.Quantum.Intrinsic/RFrac.md +5 -10
- package/docs/Microsoft.Quantum.Intrinsic/Reset.md +5 -6
- package/docs/Microsoft.Quantum.Intrinsic/ResetAll.md +5 -6
- package/docs/Microsoft.Quantum.Intrinsic/Rx.md +5 -5
- package/docs/Microsoft.Quantum.Intrinsic/Rxx.md +5 -5
- package/docs/Microsoft.Quantum.Intrinsic/Ry.md +5 -5
- package/docs/Microsoft.Quantum.Intrinsic/Ryy.md +5 -5
- package/docs/Microsoft.Quantum.Intrinsic/Rz.md +5 -5
- package/docs/Microsoft.Quantum.Intrinsic/Rzz.md +5 -5
- package/docs/Microsoft.Quantum.Intrinsic/S.md +5 -5
- package/docs/Microsoft.Quantum.Intrinsic/SWAP.md +5 -5
- package/docs/Microsoft.Quantum.Intrinsic/T.md +5 -5
- package/docs/Microsoft.Quantum.Intrinsic/X.md +5 -5
- package/docs/Microsoft.Quantum.Intrinsic/Y.md +5 -5
- package/docs/Microsoft.Quantum.Intrinsic/Z.md +5 -5
- package/docs/Microsoft.Quantum.Logical/Xor.md +4 -4
- package/docs/Microsoft.Quantum.Math/AbsComplex.md +4 -5
- package/docs/Microsoft.Quantum.Math/AbsComplexPolar.md +4 -5
- package/docs/Microsoft.Quantum.Math/AbsD.md +4 -4
- package/docs/Microsoft.Quantum.Math/AbsI.md +4 -4
- package/docs/Microsoft.Quantum.Math/AbsL.md +4 -4
- package/docs/Microsoft.Quantum.Math/AbsSquaredComplex.md +4 -5
- package/docs/Microsoft.Quantum.Math/AbsSquaredComplexPolar.md +4 -5
- package/docs/Microsoft.Quantum.Math/ApproximateFactorial.md +4 -4
- package/docs/Microsoft.Quantum.Math/ArcCos.md +4 -4
- package/docs/Microsoft.Quantum.Math/ArcCosh.md +4 -4
- package/docs/Microsoft.Quantum.Math/ArcSin.md +4 -4
- package/docs/Microsoft.Quantum.Math/ArcSinh.md +4 -4
- package/docs/Microsoft.Quantum.Math/ArcTan.md +4 -4
- package/docs/Microsoft.Quantum.Math/ArcTan2.md +4 -4
- package/docs/Microsoft.Quantum.Math/ArcTanh.md +4 -4
- package/docs/Microsoft.Quantum.Math/ArgComplex.md +4 -5
- package/docs/Microsoft.Quantum.Math/ArgComplexPolar.md +4 -4
- package/docs/Microsoft.Quantum.Math/Binom.md +4 -4
- package/docs/Microsoft.Quantum.Math/BitSizeI.md +4 -5
- package/docs/Microsoft.Quantum.Math/BitSizeL.md +4 -5
- package/docs/Microsoft.Quantum.Math/Ceiling.md +4 -5
- package/docs/Microsoft.Quantum.Math/Complex.md +4 -6
- package/docs/Microsoft.Quantum.Math/ComplexPolar.md +4 -5
- package/docs/Microsoft.Quantum.Math/ContinuedFractionConvergentI.md +4 -6
- package/docs/Microsoft.Quantum.Math/ContinuedFractionConvergentL.md +4 -6
- package/docs/Microsoft.Quantum.Math/Cos.md +4 -4
- package/docs/Microsoft.Quantum.Math/Cosh.md +4 -4
- package/docs/Microsoft.Quantum.Math/DivRemI.md +4 -4
- package/docs/Microsoft.Quantum.Math/DivRemL.md +4 -4
- package/docs/Microsoft.Quantum.Math/DividedByC.md +4 -4
- package/docs/Microsoft.Quantum.Math/DividedByCP.md +4 -4
- package/docs/Microsoft.Quantum.Math/E.md +4 -4
- package/docs/Microsoft.Quantum.Math/ExpModI.md +4 -5
- package/docs/Microsoft.Quantum.Math/ExpModL.md +4 -5
- package/docs/Microsoft.Quantum.Math/ExtendedGreatestCommonDivisorI.md +4 -5
- package/docs/Microsoft.Quantum.Math/ExtendedGreatestCommonDivisorL.md +4 -5
- package/docs/Microsoft.Quantum.Math/FactorialI.md +4 -4
- package/docs/Microsoft.Quantum.Math/FactorialL.md +4 -4
- package/docs/Microsoft.Quantum.Math/Floor.md +4 -5
- package/docs/Microsoft.Quantum.Math/GreatestCommonDivisorI.md +4 -5
- package/docs/Microsoft.Quantum.Math/GreatestCommonDivisorL.md +4 -5
- package/docs/Microsoft.Quantum.Math/HammingWeightI.md +4 -4
- package/docs/Microsoft.Quantum.Math/InverseModI.md +4 -4
- package/docs/Microsoft.Quantum.Math/InverseModL.md +4 -4
- package/docs/Microsoft.Quantum.Math/IsCoprimeI.md +4 -4
- package/docs/Microsoft.Quantum.Math/IsCoprimeL.md +4 -4
- package/docs/Microsoft.Quantum.Math/IsInfinite.md +4 -5
- package/docs/Microsoft.Quantum.Math/IsNaN.md +4 -5
- package/docs/Microsoft.Quantum.Math/LargestFixedPoint.md +4 -4
- package/docs/Microsoft.Quantum.Math/Lg.md +4 -4
- package/docs/Microsoft.Quantum.Math/Log.md +4 -4
- package/docs/Microsoft.Quantum.Math/Log10.md +4 -4
- package/docs/Microsoft.Quantum.Math/LogFactorialD.md +4 -5
- package/docs/Microsoft.Quantum.Math/LogGammaD.md +4 -5
- package/docs/Microsoft.Quantum.Math/LogOf2.md +4 -4
- package/docs/Microsoft.Quantum.Math/Max.md +4 -4
- package/docs/Microsoft.Quantum.Math/MaxD.md +4 -4
- package/docs/Microsoft.Quantum.Math/MaxI.md +4 -4
- package/docs/Microsoft.Quantum.Math/MaxL.md +4 -4
- package/docs/Microsoft.Quantum.Math/Min.md +4 -4
- package/docs/Microsoft.Quantum.Math/MinD.md +4 -4
- package/docs/Microsoft.Quantum.Math/MinI.md +4 -4
- package/docs/Microsoft.Quantum.Math/MinL.md +4 -4
- package/docs/Microsoft.Quantum.Math/MinusC.md +4 -4
- package/docs/Microsoft.Quantum.Math/MinusCP.md +4 -4
- package/docs/Microsoft.Quantum.Math/ModulusI.md +4 -5
- package/docs/Microsoft.Quantum.Math/ModulusL.md +4 -5
- package/docs/Microsoft.Quantum.Math/NegationC.md +4 -4
- package/docs/Microsoft.Quantum.Math/NegationCP.md +4 -4
- package/docs/Microsoft.Quantum.Math/PI.md +4 -4
- package/docs/Microsoft.Quantum.Math/PNorm.md +4 -7
- package/docs/Microsoft.Quantum.Math/PNormalized.md +4 -8
- package/docs/Microsoft.Quantum.Math/PlusC.md +4 -4
- package/docs/Microsoft.Quantum.Math/PlusCP.md +4 -4
- package/docs/Microsoft.Quantum.Math/PowC.md +4 -5
- package/docs/Microsoft.Quantum.Math/PowCP.md +4 -5
- package/docs/Microsoft.Quantum.Math/RealMod.md +4 -4
- package/docs/Microsoft.Quantum.Math/Round.md +4 -5
- package/docs/Microsoft.Quantum.Math/SignD.md +4 -4
- package/docs/Microsoft.Quantum.Math/SignI.md +4 -4
- package/docs/Microsoft.Quantum.Math/SignL.md +4 -4
- package/docs/Microsoft.Quantum.Math/Sin.md +4 -4
- package/docs/Microsoft.Quantum.Math/Sinh.md +4 -4
- package/docs/Microsoft.Quantum.Math/SmallestFixedPoint.md +4 -4
- package/docs/Microsoft.Quantum.Math/Sqrt.md +4 -4
- package/docs/Microsoft.Quantum.Math/SquaredNorm.md +4 -4
- package/docs/Microsoft.Quantum.Math/Tan.md +4 -4
- package/docs/Microsoft.Quantum.Math/Tanh.md +4 -4
- package/docs/Microsoft.Quantum.Math/TimesC.md +4 -4
- package/docs/Microsoft.Quantum.Math/TimesCP.md +4 -4
- package/docs/Microsoft.Quantum.Math/TrailingZeroCountI.md +4 -5
- package/docs/Microsoft.Quantum.Math/TrailingZeroCountL.md +4 -5
- package/docs/Microsoft.Quantum.Math/Truncate.md +4 -5
- package/docs/Microsoft.Quantum.Measurement/MResetEachZ.md +5 -6
- package/docs/Microsoft.Quantum.Measurement/MResetX.md +5 -7
- package/docs/Microsoft.Quantum.Measurement/MResetY.md +5 -7
- package/docs/Microsoft.Quantum.Measurement/MResetZ.md +5 -7
- package/docs/Microsoft.Quantum.Measurement/MeasureAllZ.md +5 -5
- package/docs/Microsoft.Quantum.Measurement/MeasureEachZ.md +5 -5
- package/docs/Microsoft.Quantum.Measurement/MeasureInteger.md +5 -7
- package/docs/Microsoft.Quantum.Random/DrawRandomDouble.md +5 -5
- package/docs/Microsoft.Quantum.Random/DrawRandomInt.md +5 -5
- package/docs/Microsoft.Quantum.ResourceEstimation/AccountForEstimates.md +5 -7
- package/docs/Microsoft.Quantum.ResourceEstimation/AuxQubitCount.md +4 -5
- package/docs/Microsoft.Quantum.ResourceEstimation/BeginEstimateCaching.md +4 -6
- package/docs/Microsoft.Quantum.ResourceEstimation/BeginRepeatEstimates.md +5 -10
- package/docs/Microsoft.Quantum.ResourceEstimation/CczCount.md +4 -5
- package/docs/Microsoft.Quantum.ResourceEstimation/EndEstimateCaching.md +4 -6
- package/docs/Microsoft.Quantum.ResourceEstimation/EndRepeatEstimates.md +5 -5
- package/docs/Microsoft.Quantum.ResourceEstimation/MeasurementCount.md +4 -5
- package/docs/Microsoft.Quantum.ResourceEstimation/PSSPCLayout.md +4 -6
- package/docs/Microsoft.Quantum.ResourceEstimation/RepeatEstimates.md +5 -8
- package/docs/Microsoft.Quantum.ResourceEstimation/RotationCount.md +4 -5
- package/docs/Microsoft.Quantum.ResourceEstimation/RotationDepth.md +4 -5
- package/docs/Microsoft.Quantum.ResourceEstimation/SingleVariant.md +4 -5
- package/docs/Microsoft.Quantum.ResourceEstimation/TCount.md +4 -5
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/AddLE.md +5 -6
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyIfEqualL.md +5 -6
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyIfEqualLE.md +5 -7
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyIfGreaterL.md +5 -6
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyIfGreaterLE.md +5 -7
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyIfGreaterOrEqualL.md +5 -6
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyIfGreaterOrEqualLE.md +5 -7
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyIfLessL.md +5 -6
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyIfLessLE.md +5 -7
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyIfLessOrEqualL.md +5 -6
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyIfLessOrEqualLE.md +5 -7
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/FourierTDIncByLE.md +5 -6
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/IncByI.md +5 -5
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/IncByIUsingIncByLE.md +5 -6
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/IncByL.md +5 -5
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/IncByLE.md +5 -5
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/IncByLEUsingAddLE.md +5 -5
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/IncByLUsingIncByLE.md +5 -6
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/LookAheadDKRSAddLE.md +5 -6
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/MAJ.md +5 -5
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/ReflectAboutInteger.md +5 -5
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/RippleCarryCGAddLE.md +5 -6
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/RippleCarryCGIncByLE.md +5 -6
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/RippleCarryTTKIncByLE.md +5 -5
- package/docs/Microsoft.Quantum.Unstable.StatePreparation/ApproximatelyPreparePureStateCP.md +5 -7
- package/docs/Microsoft.Quantum.Unstable.StatePreparation/PreparePureStateD.md +5 -6
- package/docs/Microsoft.Quantum.Unstable.TableLookup/Select.md +5 -5
- package/docs/toc.yml +286 -284
- package/lib/node/qsc_wasm.cjs +74 -51
- package/lib/node/qsc_wasm.d.cts +12 -6
- package/lib/node/qsc_wasm_bg.wasm +0 -0
- package/lib/web/qsc_wasm.d.ts +17 -11
- package/lib/web/qsc_wasm.js +72 -49
- package/lib/web/qsc_wasm_bg.wasm +0 -0
- package/package.json +1 -1
- package/ux/estimatesOverview.tsx +6 -2
- package/ux/scatterChart.tsx +31 -10
- package/dist/compiler/worker-proxy.d.ts +0 -7
- package/dist/compiler/worker-proxy.js +0 -18
- package/dist/debug-service/worker-proxy.d.ts +0 -7
- package/dist/debug-service/worker-proxy.js +0 -22
- package/dist/language-service/worker-proxy.d.ts +0 -6
- package/dist/language-service/worker-proxy.js +0 -28
package/dist/browser.d.ts
CHANGED
|
@@ -11,13 +11,13 @@ export declare function getDebugService(): Promise<IDebugService>;
|
|
|
11
11
|
export declare function getProjectLoader(readFile: (path: string) => Promise<string | null>, loadDirectory: (path: string) => Promise<[string, number][]>, getManifest: (path: string) => Promise<{
|
|
12
12
|
manifestDirectory: string;
|
|
13
13
|
} | null>): Promise<wasm.ProjectLoader>;
|
|
14
|
-
export declare function getDebugServiceWorker(
|
|
14
|
+
export declare function getDebugServiceWorker(worker: string | Worker): IDebugServiceWorker;
|
|
15
15
|
export declare function getCompiler(): Promise<ICompiler>;
|
|
16
|
-
export declare function getCompilerWorker(
|
|
16
|
+
export declare function getCompilerWorker(worker: string | Worker): ICompilerWorker;
|
|
17
17
|
export declare function getLanguageService(readFile?: (uri: string) => Promise<string | null>, listDir?: (uri: string) => Promise<[string, number][]>, getManifest?: (uri: string) => Promise<{
|
|
18
18
|
manifestDirectory: string;
|
|
19
19
|
} | null>): Promise<ILanguageService>;
|
|
20
|
-
export declare function getLanguageServiceWorker(
|
|
20
|
+
export declare function getLanguageServiceWorker(worker: string | Worker): ILanguageServiceWorker;
|
|
21
21
|
export { type Dump, type ShotResult } from "./compiler/common.js";
|
|
22
22
|
export { type CompilerState } from "./compiler/compiler.js";
|
|
23
23
|
export { QscEventTarget } from "./compiler/events.js";
|
package/dist/browser.js
CHANGED
|
@@ -2,14 +2,13 @@
|
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
3
|
// This module is the entry point for browser environments. For Node.js environment,
|
|
4
4
|
// the "./main.js" module is the entry point.
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import { QSharpDebugService, } from "./debug-service/debug-service.js";
|
|
9
|
-
import {
|
|
10
|
-
import { QSharpLanguageService, qsharpLibraryUriScheme, } from "./language-service/language-service.js";
|
|
11
|
-
import { createLanguageServiceProxy } from "./language-service/worker-proxy.js";
|
|
5
|
+
import * as wasm from "../lib/web/qsc_wasm.js";
|
|
6
|
+
import initWasm from "../lib/web/qsc_wasm.js";
|
|
7
|
+
import { Compiler, compilerProtocol, } from "./compiler/compiler.js";
|
|
8
|
+
import { QSharpDebugService, debugServiceProtocol, } from "./debug-service/debug-service.js";
|
|
9
|
+
import { QSharpLanguageService, languageServiceProtocol, qsharpLibraryUriScheme, } from "./language-service/language-service.js";
|
|
12
10
|
import { log } from "./log.js";
|
|
11
|
+
import { createProxy } from "./workers/browser.js";
|
|
13
12
|
export { qsharpLibraryUriScheme };
|
|
14
13
|
// Create once. A module is stateless and can be efficiently passed to WebWorkers.
|
|
15
14
|
let wasmModule = null;
|
|
@@ -79,25 +78,10 @@ export async function getProjectLoader(readFile, loadDirectory, getManifest) {
|
|
|
79
78
|
// Create the debugger inside a WebWorker and proxy requests.
|
|
80
79
|
// If the Worker was already created via other means and is ready to receive
|
|
81
80
|
// messages, then the worker may be passed in and it will be initialized.
|
|
82
|
-
export function getDebugServiceWorker(
|
|
81
|
+
export function getDebugServiceWorker(worker) {
|
|
83
82
|
if (!wasmModule)
|
|
84
83
|
throw "Wasm module must be loaded first";
|
|
85
|
-
|
|
86
|
-
const worker = typeof workerArg === "string" ? new Worker(workerArg) : workerArg;
|
|
87
|
-
// Send it the Wasm module to instantiate
|
|
88
|
-
worker.postMessage({
|
|
89
|
-
type: "init",
|
|
90
|
-
wasmModule,
|
|
91
|
-
qscLogLevel: log.getLogLevel(),
|
|
92
|
-
});
|
|
93
|
-
// If you lose the 'this' binding, some environments have issues
|
|
94
|
-
const postMessage = worker.postMessage.bind(worker);
|
|
95
|
-
const onTerminate = () => worker.terminate();
|
|
96
|
-
// Create the proxy which will forward method calls to the worker
|
|
97
|
-
const proxy = createDebugServiceProxy(postMessage, onTerminate);
|
|
98
|
-
// Let proxy handle response and event messages from the worker
|
|
99
|
-
worker.onmessage = (ev) => proxy.onMsgFromWorker(ev.data);
|
|
100
|
-
return proxy;
|
|
84
|
+
return createProxy(worker, wasmModule, debugServiceProtocol);
|
|
101
85
|
}
|
|
102
86
|
export async function getCompiler() {
|
|
103
87
|
await instantiateWasm();
|
|
@@ -106,25 +90,10 @@ export async function getCompiler() {
|
|
|
106
90
|
// Create the compiler inside a WebWorker and proxy requests.
|
|
107
91
|
// If the Worker was already created via other means and is ready to receive
|
|
108
92
|
// messages, then the worker may be passed in and it will be initialized.
|
|
109
|
-
export function getCompilerWorker(
|
|
93
|
+
export function getCompilerWorker(worker) {
|
|
110
94
|
if (!wasmModule)
|
|
111
95
|
throw "Wasm module must be loaded first";
|
|
112
|
-
|
|
113
|
-
const worker = typeof workerArg === "string" ? new Worker(workerArg) : workerArg;
|
|
114
|
-
// Send it the Wasm module to instantiate
|
|
115
|
-
worker.postMessage({
|
|
116
|
-
type: "init",
|
|
117
|
-
wasmModule,
|
|
118
|
-
qscLogLevel: log.getLogLevel(),
|
|
119
|
-
});
|
|
120
|
-
// If you lose the 'this' binding, some environments have issues
|
|
121
|
-
const postMessage = worker.postMessage.bind(worker);
|
|
122
|
-
const onTerminate = () => worker.terminate();
|
|
123
|
-
// Create the proxy which will forward method calls to the worker
|
|
124
|
-
const proxy = createCompilerProxy(postMessage, onTerminate);
|
|
125
|
-
// Let proxy handle response and event messages from the worker
|
|
126
|
-
worker.onmessage = (ev) => proxy.onMsgFromWorker(ev.data);
|
|
127
|
-
return proxy;
|
|
96
|
+
return createProxy(worker, wasmModule, compilerProtocol);
|
|
128
97
|
}
|
|
129
98
|
export async function getLanguageService(readFile, listDir, getManifest) {
|
|
130
99
|
await instantiateWasm();
|
|
@@ -133,25 +102,10 @@ export async function getLanguageService(readFile, listDir, getManifest) {
|
|
|
133
102
|
// Create the compiler inside a WebWorker and proxy requests.
|
|
134
103
|
// If the Worker was already created via other means and is ready to receive
|
|
135
104
|
// messages, then the worker may be passed in and it will be initialized.
|
|
136
|
-
export function getLanguageServiceWorker(
|
|
105
|
+
export function getLanguageServiceWorker(worker) {
|
|
137
106
|
if (!wasmModule)
|
|
138
107
|
throw "Wasm module must be loaded first";
|
|
139
|
-
|
|
140
|
-
const worker = typeof workerArg === "string" ? new Worker(workerArg) : workerArg;
|
|
141
|
-
// Send it the Wasm module to instantiate
|
|
142
|
-
worker.postMessage({
|
|
143
|
-
type: "init",
|
|
144
|
-
wasmModule,
|
|
145
|
-
qscLogLevel: log.getLogLevel(),
|
|
146
|
-
});
|
|
147
|
-
// If you lose the 'this' binding, some environments have issues
|
|
148
|
-
const postMessage = worker.postMessage.bind(worker);
|
|
149
|
-
const onTerminate = () => worker.terminate();
|
|
150
|
-
// Create the proxy which will forward method calls to the worker
|
|
151
|
-
const proxy = createLanguageServiceProxy(postMessage, onTerminate);
|
|
152
|
-
// Let proxy handle response and event messages from the worker
|
|
153
|
-
worker.onmessage = (ev) => proxy.onMsgFromWorker(ev.data);
|
|
154
|
-
return proxy;
|
|
108
|
+
return createProxy(worker, wasmModule, languageServiceProtocol);
|
|
155
109
|
}
|
|
156
110
|
export { QscEventTarget } from "./compiler/events.js";
|
|
157
111
|
export { getAllKatas, getExerciseSources, getKata, } from "./katas.js";
|
|
@@ -1,26 +1,46 @@
|
|
|
1
1
|
import { type VSDiagnostic } from "../../lib/web/qsc_wasm.js";
|
|
2
|
-
import { IServiceProxy, ServiceState } from "../
|
|
3
|
-
import { IQscEventTarget } from "./events.js";
|
|
2
|
+
import { IServiceProxy, ServiceProtocol, ServiceState } from "../workers/common.js";
|
|
3
|
+
import { IQscEventTarget, QscEventData } from "./events.js";
|
|
4
4
|
type Wasm = typeof import("../../lib/node/qsc_wasm.cjs");
|
|
5
5
|
export interface ICompiler {
|
|
6
6
|
checkCode(code: string): Promise<VSDiagnostic[]>;
|
|
7
|
-
getHir(code: string): Promise<string>;
|
|
7
|
+
getHir(code: string, languageFeatures?: string[]): Promise<string>;
|
|
8
|
+
/** @deprecated -- switch to using `ProgramConfig`-based overload. Instead of passing
|
|
9
|
+
* all arguments separately, pass an object with named properties. This change was made
|
|
10
|
+
* for the sake of extensibility and future-compatibility. Note that only the new API
|
|
11
|
+
* supports passing guage features. If you need to pass language features, you must use
|
|
12
|
+
* the new API.
|
|
13
|
+
**/
|
|
8
14
|
run(sources: [string, string][], expr: string, shots: number, eventHandler: IQscEventTarget): Promise<void>;
|
|
9
|
-
|
|
10
|
-
|
|
15
|
+
run(config: ProgramConfig, eventHandler: IQscEventTarget): Promise<void>;
|
|
16
|
+
getQir(sources: [string, string][], languageFeatures?: string[]): Promise<string>;
|
|
17
|
+
getEstimates(sources: [string, string][], params: string, languageFeatures?: string[]): Promise<string>;
|
|
11
18
|
checkExerciseSolution(user_code: string, exercise_sources: string[], eventHandler: IQscEventTarget): Promise<boolean>;
|
|
12
19
|
}
|
|
20
|
+
/** Type definition for the configuration of a program. */
|
|
21
|
+
export type ProgramConfig = {
|
|
22
|
+
/** An array of source objects, each containing a name and contents. */
|
|
23
|
+
sources: [string, string][];
|
|
24
|
+
/** The entry expression to be evaluated. */
|
|
25
|
+
expr: string;
|
|
26
|
+
/** The number of shots to be performed in the quantum simulation. */
|
|
27
|
+
shots: number;
|
|
28
|
+
/** An array of language features to be opted in to in this compilation. */
|
|
29
|
+
languageFeatures?: string[];
|
|
30
|
+
};
|
|
13
31
|
export type ICompilerWorker = ICompiler & IServiceProxy;
|
|
14
32
|
export type CompilerState = ServiceState;
|
|
15
33
|
export declare class Compiler implements ICompiler {
|
|
16
34
|
private wasm;
|
|
17
35
|
constructor(wasm: Wasm);
|
|
18
36
|
checkCode(code: string): Promise<VSDiagnostic[]>;
|
|
19
|
-
getQir(sources: [string, string][]): Promise<string>;
|
|
20
|
-
getEstimates(sources: [string, string][], params: string): Promise<string>;
|
|
21
|
-
getHir(code: string): Promise<string>;
|
|
22
|
-
run(
|
|
37
|
+
getQir(sources: [string, string][], languageFeatures: string[]): Promise<string>;
|
|
38
|
+
getEstimates(sources: [string, string][], params: string, languageFeatures: string[]): Promise<string>;
|
|
39
|
+
getHir(code: string, languageFeatures: string[]): Promise<string>;
|
|
40
|
+
run(sourcesOrConfig: [string, string][] | ProgramConfig, exprOrEventHandler: string | IQscEventTarget, maybeShots?: number, maybeEventHandler?: IQscEventTarget): Promise<void>;
|
|
23
41
|
checkExerciseSolution(user_code: string, exercise_sources: string[], eventHandler: IQscEventTarget): Promise<boolean>;
|
|
24
42
|
}
|
|
25
43
|
export declare function onCompilerEvent(msg: string, eventTarget: IQscEventTarget): void;
|
|
44
|
+
/** The protocol definition to allow running the compiler in a worker. */
|
|
45
|
+
export declare const compilerProtocol: ServiceProtocol<ICompiler, QscEventData>;
|
|
26
46
|
export {};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
3
|
import { log } from "../log.js";
|
|
4
4
|
import { eventStringToMsg } from "./common.js";
|
|
5
|
-
import { makeEvent } from "./events.js";
|
|
5
|
+
import { makeEvent, } from "./events.js";
|
|
6
6
|
export class Compiler {
|
|
7
7
|
constructor(wasm) {
|
|
8
8
|
log.info("Constructing a Compiler instance");
|
|
@@ -25,20 +25,40 @@ export class Compiler {
|
|
|
25
25
|
languageService.free();
|
|
26
26
|
return diags;
|
|
27
27
|
}
|
|
28
|
-
async getQir(sources) {
|
|
29
|
-
return this.wasm.get_qir(sources);
|
|
28
|
+
async getQir(sources, languageFeatures) {
|
|
29
|
+
return this.wasm.get_qir(sources, languageFeatures);
|
|
30
30
|
}
|
|
31
|
-
async getEstimates(sources, params) {
|
|
32
|
-
return this.wasm.get_estimates(sources, params);
|
|
31
|
+
async getEstimates(sources, params, languageFeatures) {
|
|
32
|
+
return this.wasm.get_estimates(sources, params, languageFeatures);
|
|
33
33
|
}
|
|
34
|
-
async getHir(code) {
|
|
35
|
-
return this.wasm.get_hir(code);
|
|
34
|
+
async getHir(code, languageFeatures) {
|
|
35
|
+
return this.wasm.get_hir(code, languageFeatures);
|
|
36
36
|
}
|
|
37
|
-
async run(
|
|
37
|
+
async run(sourcesOrConfig, exprOrEventHandler, maybeShots, maybeEventHandler) {
|
|
38
|
+
let sources;
|
|
39
|
+
let expr;
|
|
40
|
+
let shots;
|
|
41
|
+
let eventHandler;
|
|
42
|
+
let languageFeatures = [];
|
|
43
|
+
if (Array.isArray(sourcesOrConfig)) {
|
|
44
|
+
// this is the deprecated API
|
|
45
|
+
sources = sourcesOrConfig;
|
|
46
|
+
expr = exprOrEventHandler;
|
|
47
|
+
shots = maybeShots;
|
|
48
|
+
eventHandler = maybeEventHandler;
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
// this is the new API
|
|
52
|
+
sources = sourcesOrConfig.sources;
|
|
53
|
+
expr = sourcesOrConfig.expr;
|
|
54
|
+
shots = sourcesOrConfig.shots;
|
|
55
|
+
eventHandler = exprOrEventHandler;
|
|
56
|
+
languageFeatures = sourcesOrConfig.languageFeatures || [];
|
|
57
|
+
}
|
|
38
58
|
// All results are communicated as events, but if there is a compiler error (e.g. an invalid
|
|
39
59
|
// entry expression or similar), it may throw on run. The caller should expect this promise
|
|
40
60
|
// may reject without all shots running or events firing.
|
|
41
|
-
this.wasm.run(sources, expr, (msg) => onCompilerEvent(msg, eventHandler), shots);
|
|
61
|
+
this.wasm.run(sources, expr, (msg) => onCompilerEvent(msg, eventHandler), shots, languageFeatures);
|
|
42
62
|
}
|
|
43
63
|
async checkExerciseSolution(user_code, exercise_sources, eventHandler) {
|
|
44
64
|
const success = this.wasm.check_exercise_solution(user_code, exercise_sources, (msg) => onCompilerEvent(msg, eventHandler));
|
|
@@ -70,3 +90,16 @@ export function onCompilerEvent(msg, eventTarget) {
|
|
|
70
90
|
log.debug("worker dispatching event " + JSON.stringify(qscEvent));
|
|
71
91
|
eventTarget.dispatchEvent(qscEvent);
|
|
72
92
|
}
|
|
93
|
+
/** The protocol definition to allow running the compiler in a worker. */
|
|
94
|
+
export const compilerProtocol = {
|
|
95
|
+
class: Compiler,
|
|
96
|
+
methods: {
|
|
97
|
+
checkCode: "request",
|
|
98
|
+
getHir: "request",
|
|
99
|
+
getQir: "request",
|
|
100
|
+
getEstimates: "request",
|
|
101
|
+
run: "requestWithProgress",
|
|
102
|
+
checkExerciseSolution: "requestWithProgress",
|
|
103
|
+
},
|
|
104
|
+
eventNames: ["DumpMachine", "Message", "Result"],
|
|
105
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ShotResult, Dump, Result } from "./common.js";
|
|
2
2
|
import { TelemetryEvent } from "../log.js";
|
|
3
|
-
import { IServiceEventTarget } from "../
|
|
3
|
+
import { IServiceEventTarget } from "../workers/common.js";
|
|
4
4
|
export type QscEventData = {
|
|
5
5
|
type: "Message";
|
|
6
6
|
detail: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare
|
|
1
|
+
export declare const messageHandler: (e: MessageEvent<any>) => void;
|
|
@@ -1,43 +1,6 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import { Compiler } from "./compiler.js";
|
|
6
|
-
import { createCompilerDispatcher } from "./worker-proxy.js";
|
|
7
|
-
let invokeCompiler = null;
|
|
8
|
-
function telemetryHandler(telemetry) {
|
|
9
|
-
self.postMessage({
|
|
10
|
-
messageType: "event",
|
|
11
|
-
type: "telemetry-event",
|
|
12
|
-
detail: telemetry,
|
|
13
|
-
});
|
|
14
|
-
}
|
|
3
|
+
import { createWorker } from "../workers/browser.js";
|
|
4
|
+
import { compilerProtocol } from "./compiler.js";
|
|
15
5
|
// This export should be assigned to 'self.onmessage' in a WebWorker
|
|
16
|
-
export
|
|
17
|
-
const data = e.data;
|
|
18
|
-
if (!data.type || typeof data.type !== "string") {
|
|
19
|
-
log.error(`Unrecognized msg: ${data}`);
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
switch (data.type) {
|
|
23
|
-
case "init":
|
|
24
|
-
{
|
|
25
|
-
log.setLogLevel(data.qscLogLevel);
|
|
26
|
-
log.setTelemetryCollector(telemetryHandler);
|
|
27
|
-
wasm.initSync(data.wasmModule);
|
|
28
|
-
// Set up logging and telemetry as soon as possible after instantiating
|
|
29
|
-
wasm.initLogging(log.logWithLevel, log.getLogLevel());
|
|
30
|
-
log.onLevelChanged = (level) => wasm.setLogLevel(level);
|
|
31
|
-
const compiler = new Compiler(wasm);
|
|
32
|
-
invokeCompiler = createCompilerDispatcher(self.postMessage.bind(self), compiler);
|
|
33
|
-
}
|
|
34
|
-
break;
|
|
35
|
-
default:
|
|
36
|
-
if (!invokeCompiler) {
|
|
37
|
-
log.error(`Received message before the compiler was initialized: %o`, data);
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
invokeCompiler(data);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
6
|
+
export const messageHandler = createWorker(compilerProtocol);
|
|
@@ -1,41 +1,5 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
// const worker = new Worker(join(thisDir,"worker-node.js"), {
|
|
7
|
-
// workerData: {qscLogLevel: log.getLogLevel() }
|
|
8
|
-
// });
|
|
9
|
-
import { isMainThread, parentPort, workerData } from "node:worker_threads";
|
|
10
|
-
import * as wasm from "../../lib/node/qsc_wasm.cjs";
|
|
11
|
-
import { log } from "../log.js";
|
|
12
|
-
import { Compiler } from "./compiler.js";
|
|
13
|
-
import { createCompilerDispatcher } from "./worker-proxy.js";
|
|
14
|
-
if (isMainThread)
|
|
15
|
-
throw "Worker script should be loaded in a Worker thread only";
|
|
16
|
-
if (workerData && typeof workerData.qscLogLevel === "number") {
|
|
17
|
-
log.setLogLevel(workerData.qscLogLevel);
|
|
18
|
-
}
|
|
19
|
-
const port = parentPort; // eslint-disable-line @typescript-eslint/no-non-null-assertion
|
|
20
|
-
const postMessage = port.postMessage.bind(port);
|
|
21
|
-
function telemetryHandler(telemetry) {
|
|
22
|
-
postMessage({
|
|
23
|
-
messageType: "event",
|
|
24
|
-
type: "telemetry-event",
|
|
25
|
-
detail: telemetry,
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
// Set up logging and telemetry as soon as possible after instantiating
|
|
29
|
-
log.onLevelChanged = (level) => wasm.setLogLevel(level);
|
|
30
|
-
log.setTelemetryCollector(telemetryHandler);
|
|
31
|
-
wasm.initLogging(log.logWithLevel, log.getLogLevel());
|
|
32
|
-
const compiler = new Compiler(wasm);
|
|
33
|
-
const invokeCompiler = createCompilerDispatcher(postMessage, compiler);
|
|
34
|
-
function messageHandler(data) {
|
|
35
|
-
if (!data.type || typeof data.type !== "string") {
|
|
36
|
-
log.error(`Unrecognized msg: %O"`, data);
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
invokeCompiler(data);
|
|
40
|
-
}
|
|
41
|
-
port.addListener("message", messageHandler);
|
|
3
|
+
import { createWorker } from "../workers/node.js";
|
|
4
|
+
import { compilerProtocol } from "./compiler.js";
|
|
5
|
+
createWorker(compilerProtocol);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { IBreakpointSpan, IStackFrame, IStructStepResult, IVariable
|
|
1
|
+
import type { IBreakpointSpan, IQuantumState, IStackFrame, IStructStepResult, IVariable } from "../../lib/node/qsc_wasm.cjs";
|
|
2
2
|
import { TargetProfile } from "../browser.js";
|
|
3
|
-
import { IQscEventTarget } from "../compiler/events.js";
|
|
4
|
-
import { IServiceProxy } from "../
|
|
3
|
+
import { IQscEventTarget, QscEventData } from "../compiler/events.js";
|
|
4
|
+
import { IServiceProxy, ServiceProtocol } from "../workers/common.js";
|
|
5
5
|
type QscWasm = typeof import("../../lib/node/qsc_wasm.cjs");
|
|
6
6
|
export interface IDebugService {
|
|
7
|
-
loadSource(sources: [string, string][], target: TargetProfile, entry: string | undefined): Promise<string>;
|
|
7
|
+
loadSource(sources: [string, string][], target: TargetProfile, entry: string | undefined, language_features: string[]): Promise<string>;
|
|
8
8
|
getBreakpoints(path: string): Promise<IBreakpointSpan[]>;
|
|
9
9
|
getLocalVariables(): Promise<Array<IVariable>>;
|
|
10
10
|
captureQuantumState(): Promise<Array<IQuantumState>>;
|
|
@@ -20,7 +20,7 @@ export declare class QSharpDebugService implements IDebugService {
|
|
|
20
20
|
private wasm;
|
|
21
21
|
private debugService;
|
|
22
22
|
constructor(wasm: QscWasm);
|
|
23
|
-
loadSource(sources: [string, string][], target: TargetProfile, entry: string | undefined): Promise<string>;
|
|
23
|
+
loadSource(sources: [string, string][], target: TargetProfile, entry: string | undefined, language_features: string[]): Promise<string>;
|
|
24
24
|
getStackFrames(): Promise<IStackFrame[]>;
|
|
25
25
|
evalNext(bps: number[], eventHandler: IQscEventTarget): Promise<IStructStepResult>;
|
|
26
26
|
evalStepIn(bps: number[], eventHandler: IQscEventTarget): Promise<IStructStepResult>;
|
|
@@ -32,4 +32,6 @@ export declare class QSharpDebugService implements IDebugService {
|
|
|
32
32
|
dispose(): Promise<void>;
|
|
33
33
|
}
|
|
34
34
|
export declare function onCompilerEvent(msg: string, eventTarget: IQscEventTarget): void;
|
|
35
|
+
/** The protocol definition to allow running the debugger in a worker. */
|
|
36
|
+
export declare const debugServiceProtocol: ServiceProtocol<IDebugService, QscEventData>;
|
|
35
37
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
3
|
import { eventStringToMsg } from "../compiler/common.js";
|
|
4
|
-
import { makeEvent } from "../compiler/events.js";
|
|
4
|
+
import { makeEvent, } from "../compiler/events.js";
|
|
5
5
|
import { log } from "../log.js";
|
|
6
6
|
export class QSharpDebugService {
|
|
7
7
|
constructor(wasm) {
|
|
@@ -9,8 +9,8 @@ export class QSharpDebugService {
|
|
|
9
9
|
this.wasm = wasm;
|
|
10
10
|
this.debugService = new wasm.DebugService();
|
|
11
11
|
}
|
|
12
|
-
async loadSource(sources, target, entry) {
|
|
13
|
-
return this.debugService.load_source(sources, target, entry);
|
|
12
|
+
async loadSource(sources, target, entry, language_features) {
|
|
13
|
+
return this.debugService.load_source(sources, target, entry, language_features);
|
|
14
14
|
}
|
|
15
15
|
async getStackFrames() {
|
|
16
16
|
return this.debugService.get_stack_frames().frames;
|
|
@@ -75,3 +75,20 @@ export function onCompilerEvent(msg, eventTarget) {
|
|
|
75
75
|
log.debug("worker dispatching event " + JSON.stringify(qscEvent));
|
|
76
76
|
eventTarget.dispatchEvent(qscEvent);
|
|
77
77
|
}
|
|
78
|
+
/** The protocol definition to allow running the debugger in a worker. */
|
|
79
|
+
export const debugServiceProtocol = {
|
|
80
|
+
class: QSharpDebugService,
|
|
81
|
+
methods: {
|
|
82
|
+
loadSource: "request",
|
|
83
|
+
getBreakpoints: "request",
|
|
84
|
+
getLocalVariables: "request",
|
|
85
|
+
captureQuantumState: "request",
|
|
86
|
+
getStackFrames: "request",
|
|
87
|
+
evalContinue: "requestWithProgress",
|
|
88
|
+
evalNext: "requestWithProgress",
|
|
89
|
+
evalStepIn: "requestWithProgress",
|
|
90
|
+
evalStepOut: "requestWithProgress",
|
|
91
|
+
dispose: "request",
|
|
92
|
+
},
|
|
93
|
+
eventNames: ["DumpMachine", "Message", "Result"],
|
|
94
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare
|
|
1
|
+
export declare const messageHandler: (e: MessageEvent<any>) => void;
|
|
@@ -1,32 +1,6 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import { QSharpDebugService } from "./debug-service.js";
|
|
6
|
-
import { createDebugServiceDispatcher } from "./worker-proxy.js";
|
|
7
|
-
let invokeDebugger = null;
|
|
3
|
+
import { createWorker } from "../workers/browser.js";
|
|
4
|
+
import { debugServiceProtocol } from "./debug-service.js";
|
|
8
5
|
// This export should be assigned to 'self.onmessage' in a WebWorker
|
|
9
|
-
export
|
|
10
|
-
const data = e.data;
|
|
11
|
-
if (!data.type || typeof data.type !== "string") {
|
|
12
|
-
log.error(`Unrecognized msg: ${data}`);
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
switch (data.type) {
|
|
16
|
-
case "init":
|
|
17
|
-
{
|
|
18
|
-
log.setLogLevel(data.qscLogLevel);
|
|
19
|
-
wasm.initSync(data.wasmModule);
|
|
20
|
-
const debugService = new QSharpDebugService(wasm);
|
|
21
|
-
invokeDebugger = createDebugServiceDispatcher(self.postMessage.bind(self), debugService);
|
|
22
|
-
}
|
|
23
|
-
break;
|
|
24
|
-
default:
|
|
25
|
-
if (!invokeDebugger) {
|
|
26
|
-
log.error(`Received message before the debugger was initialized: %o`, data);
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
invokeDebugger(data);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
6
|
+
export const messageHandler = createWorker(debugServiceProtocol);
|
|
@@ -1,30 +1,5 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
// const worker = new Worker(join(thisDir,"worker-node.js"), {
|
|
7
|
-
// workerData: {qscLogLevel: log.getLogLevel() }
|
|
8
|
-
// });
|
|
9
|
-
import { isMainThread, parentPort, workerData } from "node:worker_threads";
|
|
10
|
-
import * as wasm from "../../lib/node/qsc_wasm.cjs";
|
|
11
|
-
import { log } from "../log.js";
|
|
12
|
-
import { QSharpDebugService } from "./debug-service.js";
|
|
13
|
-
import { createDebugServiceDispatcher } from "./worker-proxy.js";
|
|
14
|
-
if (isMainThread)
|
|
15
|
-
throw "Worker script should be loaded in a Worker thread only";
|
|
16
|
-
if (workerData && typeof workerData.qscLogLevel === "number") {
|
|
17
|
-
log.setLogLevel(workerData.qscLogLevel);
|
|
18
|
-
}
|
|
19
|
-
const port = parentPort; // eslint-disable-line @typescript-eslint/no-non-null-assertion
|
|
20
|
-
const postMessage = port.postMessage.bind(port);
|
|
21
|
-
const debuggerd = new QSharpDebugService(wasm);
|
|
22
|
-
const invokeDebugger = createDebugServiceDispatcher(postMessage, debuggerd);
|
|
23
|
-
function messageHandler(data) {
|
|
24
|
-
if (!data.type || typeof data.type !== "string") {
|
|
25
|
-
log.error(`Unrecognized msg: %O"`, data);
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
invokeDebugger(data);
|
|
29
|
-
}
|
|
30
|
-
port.addListener("message", messageHandler);
|
|
3
|
+
import { createWorker } from "../workers/node.js";
|
|
4
|
+
import { debugServiceProtocol } from "./debug-service.js";
|
|
5
|
+
createWorker(debugServiceProtocol);
|