qsharp-lang 1.23.2-dev → 1.23.4-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/docs/Microsoft.Quantum.Core/IsRangeEmpty.md +1 -1
- package/docs/Microsoft.Quantum.Core/Length.md +1 -1
- package/docs/Microsoft.Quantum.Core/RangeEnd.md +1 -1
- package/docs/Microsoft.Quantum.Core/RangeStart.md +1 -1
- package/docs/Microsoft.Quantum.Core/Repeated.md +1 -1
- package/docs/Microsoft.Quantum.Core/index.md +1 -1
- package/docs/Std.Arithmetic/AddLE.md +1 -1
- package/docs/Std.Arithmetic/ApplyIfEqualL.md +1 -1
- package/docs/Std.Arithmetic/ApplyIfEqualLE.md +1 -1
- package/docs/Std.Arithmetic/ApplyIfGreaterL.md +1 -1
- package/docs/Std.Arithmetic/ApplyIfGreaterLE.md +1 -1
- package/docs/Std.Arithmetic/ApplyIfGreaterOrEqualL.md +1 -1
- package/docs/Std.Arithmetic/ApplyIfGreaterOrEqualLE.md +1 -1
- package/docs/Std.Arithmetic/ApplyIfLessL.md +1 -1
- package/docs/Std.Arithmetic/ApplyIfLessLE.md +1 -1
- package/docs/Std.Arithmetic/ApplyIfLessOrEqualL.md +1 -1
- package/docs/Std.Arithmetic/ApplyIfLessOrEqualLE.md +1 -1
- package/docs/Std.Arithmetic/FourierTDIncByLE.md +1 -1
- package/docs/Std.Arithmetic/IncByI.md +1 -1
- package/docs/Std.Arithmetic/IncByIUsingIncByLE.md +1 -1
- package/docs/Std.Arithmetic/IncByL.md +1 -1
- package/docs/Std.Arithmetic/IncByLE.md +1 -1
- package/docs/Std.Arithmetic/IncByLEUsingAddLE.md +1 -1
- package/docs/Std.Arithmetic/IncByLUsingIncByLE.md +1 -1
- package/docs/Std.Arithmetic/LookAheadDKRSAddLE.md +1 -1
- package/docs/Std.Arithmetic/MAJ.md +1 -1
- package/docs/Std.Arithmetic/ReflectAboutInteger.md +1 -1
- package/docs/Std.Arithmetic/RippleCarryCGAddLE.md +1 -1
- package/docs/Std.Arithmetic/RippleCarryCGIncByLE.md +1 -1
- package/docs/Std.Arithmetic/RippleCarryTTKIncByLE.md +1 -1
- package/docs/Std.Arithmetic/index.md +1 -1
- package/docs/Std.Arrays/All.md +1 -1
- package/docs/Std.Arrays/Any.md +1 -1
- package/docs/Std.Arrays/Chunks.md +1 -1
- package/docs/Std.Arrays/CircularlyShifted.md +1 -1
- package/docs/Std.Arrays/ColumnAt.md +1 -1
- package/docs/Std.Arrays/Count.md +1 -1
- package/docs/Std.Arrays/Diagonal.md +1 -1
- package/docs/Std.Arrays/DrawMany.md +1 -1
- package/docs/Std.Arrays/Enumerated.md +1 -1
- package/docs/Std.Arrays/Excluding.md +1 -1
- package/docs/Std.Arrays/Filtered.md +1 -1
- package/docs/Std.Arrays/FlatMapped.md +1 -1
- package/docs/Std.Arrays/Flattened.md +1 -1
- package/docs/Std.Arrays/Fold.md +1 -1
- package/docs/Std.Arrays/ForEach.md +1 -1
- package/docs/Std.Arrays/Head.md +1 -1
- package/docs/Std.Arrays/HeadAndRest.md +1 -1
- package/docs/Std.Arrays/IndexOf.md +1 -1
- package/docs/Std.Arrays/IndexRange.md +1 -1
- package/docs/Std.Arrays/Interleaved.md +1 -1
- package/docs/Std.Arrays/IsEmpty.md +1 -1
- package/docs/Std.Arrays/IsRectangularArray.md +1 -1
- package/docs/Std.Arrays/IsSorted.md +1 -1
- package/docs/Std.Arrays/IsSquareArray.md +1 -1
- package/docs/Std.Arrays/Mapped.md +1 -1
- package/docs/Std.Arrays/MappedByIndex.md +1 -1
- package/docs/Std.Arrays/MappedOverRange.md +1 -1
- package/docs/Std.Arrays/Most.md +1 -1
- package/docs/Std.Arrays/MostAndTail.md +1 -1
- package/docs/Std.Arrays/Padded.md +1 -1
- package/docs/Std.Arrays/Partitioned.md +1 -1
- package/docs/Std.Arrays/Rest.md +1 -1
- package/docs/Std.Arrays/Reversed.md +1 -1
- package/docs/Std.Arrays/SequenceI.md +1 -1
- package/docs/Std.Arrays/SequenceL.md +1 -1
- package/docs/Std.Arrays/Sorted.md +1 -1
- package/docs/Std.Arrays/Subarray.md +1 -1
- package/docs/Std.Arrays/Swapped.md +1 -1
- package/docs/Std.Arrays/Tail.md +1 -1
- package/docs/Std.Arrays/Transposed.md +1 -1
- package/docs/Std.Arrays/Unzipped.md +1 -1
- package/docs/Std.Arrays/Where.md +1 -1
- package/docs/Std.Arrays/Windows.md +1 -1
- package/docs/Std.Arrays/Zipped.md +1 -1
- package/docs/Std.Arrays/index.md +1 -1
- package/docs/Std.Canon/ApplyCNOTChain.md +1 -1
- package/docs/Std.Canon/ApplyControlledOnBitString.md +1 -1
- package/docs/Std.Canon/ApplyControlledOnInt.md +1 -1
- package/docs/Std.Canon/ApplyOperationPowerA.md +1 -1
- package/docs/Std.Canon/ApplyOperationPowerCA.md +1 -1
- package/docs/Std.Canon/ApplyP.md +1 -1
- package/docs/Std.Canon/ApplyPauli.md +1 -1
- package/docs/Std.Canon/ApplyPauliFromBitString.md +1 -1
- package/docs/Std.Canon/ApplyPauliFromInt.md +1 -1
- package/docs/Std.Canon/ApplyQFT.md +1 -1
- package/docs/Std.Canon/ApplyQPE.md +1 -1
- package/docs/Std.Canon/ApplyToEach.md +1 -1
- package/docs/Std.Canon/ApplyToEachA.md +1 -1
- package/docs/Std.Canon/ApplyToEachC.md +1 -1
- package/docs/Std.Canon/ApplyToEachCA.md +1 -1
- package/docs/Std.Canon/ApplyXorInPlace.md +1 -1
- package/docs/Std.Canon/ApplyXorInPlaceL.md +1 -1
- package/docs/Std.Canon/CX.md +1 -1
- package/docs/Std.Canon/CY.md +1 -1
- package/docs/Std.Canon/CZ.md +1 -1
- package/docs/Std.Canon/Fst.md +1 -1
- package/docs/Std.Canon/MapPauliAxis.md +1 -1
- package/docs/Std.Canon/Relabel.md +1 -1
- package/docs/Std.Canon/Snd.md +1 -1
- package/docs/Std.Canon/SwapReverseRegister.md +1 -1
- package/docs/Std.Canon/index.md +1 -1
- package/docs/Std.Convert/BigIntAsBoolArray.md +1 -1
- package/docs/Std.Convert/BigIntAsInt.md +1 -1
- package/docs/Std.Convert/BoolArrayAsBigInt.md +1 -1
- package/docs/Std.Convert/BoolArrayAsInt.md +1 -1
- package/docs/Std.Convert/BoolArrayAsResultArray.md +1 -1
- package/docs/Std.Convert/BoolAsResult.md +1 -1
- package/docs/Std.Convert/ComplexAsComplexPolar.md +1 -1
- package/docs/Std.Convert/ComplexPolarAsComplex.md +1 -1
- package/docs/Std.Convert/DoubleAsStringWithPrecision.md +1 -1
- package/docs/Std.Convert/IntAsBigInt.md +1 -1
- package/docs/Std.Convert/IntAsBoolArray.md +1 -1
- package/docs/Std.Convert/IntAsDouble.md +1 -1
- package/docs/Std.Convert/ResultArrayAsBoolArray.md +1 -1
- package/docs/Std.Convert/ResultArrayAsInt.md +1 -1
- package/docs/Std.Convert/ResultAsBool.md +1 -1
- package/docs/Std.Convert/index.md +1 -1
- package/docs/Std.Core/Complex.md +1 -1
- package/docs/Std.Core/Length.md +1 -1
- package/docs/Std.Core/Repeated.md +1 -1
- package/docs/Std.Core/index.md +1 -1
- package/docs/Std.Diagnostics/ApplyIdleNoise.md +1 -1
- package/docs/Std.Diagnostics/BitFlipNoise.md +1 -1
- package/docs/Std.Diagnostics/CheckAllZero.md +1 -1
- package/docs/Std.Diagnostics/CheckOperationsAreEqual.md +1 -1
- package/docs/Std.Diagnostics/CheckZero.md +1 -1
- package/docs/Std.Diagnostics/ConfigurePauliNoise.md +1 -1
- package/docs/Std.Diagnostics/ConfigureQubitLoss.md +1 -1
- package/docs/Std.Diagnostics/DepolarizingNoise.md +1 -1
- package/docs/Std.Diagnostics/DumpMachine.md +1 -1
- package/docs/Std.Diagnostics/DumpOperation.md +1 -1
- package/docs/Std.Diagnostics/DumpRegister.md +1 -1
- package/docs/Std.Diagnostics/Fact.md +1 -1
- package/docs/Std.Diagnostics/NoNoise.md +1 -1
- package/docs/Std.Diagnostics/PhaseFlipNoise.md +1 -1
- package/docs/Std.Diagnostics/StartCountingFunction.md +1 -1
- package/docs/Std.Diagnostics/StartCountingOperation.md +1 -1
- package/docs/Std.Diagnostics/StartCountingQubits.md +1 -1
- package/docs/Std.Diagnostics/StopCountingFunction.md +1 -1
- package/docs/Std.Diagnostics/StopCountingOperation.md +1 -1
- package/docs/Std.Diagnostics/StopCountingQubits.md +1 -1
- package/docs/Std.Diagnostics/index.md +1 -1
- package/docs/Std.Intrinsic/AND.md +1 -1
- package/docs/Std.Intrinsic/ApplyUnitary.md +1 -1
- package/docs/Std.Intrinsic/CCNOT.md +1 -1
- package/docs/Std.Intrinsic/CNOT.md +1 -1
- package/docs/Std.Intrinsic/Exp.md +1 -1
- package/docs/Std.Intrinsic/H.md +1 -1
- package/docs/Std.Intrinsic/I.md +1 -1
- package/docs/Std.Intrinsic/M.md +1 -1
- package/docs/Std.Intrinsic/Measure.md +1 -1
- package/docs/Std.Intrinsic/Message.md +1 -1
- package/docs/Std.Intrinsic/R.md +1 -1
- package/docs/Std.Intrinsic/R1.md +1 -1
- package/docs/Std.Intrinsic/R1Frac.md +1 -1
- package/docs/Std.Intrinsic/RFrac.md +1 -1
- package/docs/Std.Intrinsic/Reset.md +1 -1
- package/docs/Std.Intrinsic/ResetAll.md +1 -1
- package/docs/Std.Intrinsic/Rx.md +1 -1
- package/docs/Std.Intrinsic/Rxx.md +1 -1
- package/docs/Std.Intrinsic/Ry.md +1 -1
- package/docs/Std.Intrinsic/Ryy.md +1 -1
- package/docs/Std.Intrinsic/Rz.md +1 -1
- package/docs/Std.Intrinsic/Rzz.md +1 -1
- package/docs/Std.Intrinsic/S.md +1 -1
- package/docs/Std.Intrinsic/SWAP.md +1 -1
- package/docs/Std.Intrinsic/SX.md +1 -1
- package/docs/Std.Intrinsic/T.md +1 -1
- package/docs/Std.Intrinsic/X.md +1 -1
- package/docs/Std.Intrinsic/Y.md +1 -1
- package/docs/Std.Intrinsic/Z.md +1 -1
- package/docs/Std.Intrinsic/index.md +1 -1
- package/docs/Std.Logical/Xor.md +1 -1
- package/docs/Std.Logical/index.md +1 -1
- package/docs/Std.Math/AbsComplex.md +1 -1
- package/docs/Std.Math/AbsComplexPolar.md +1 -1
- package/docs/Std.Math/AbsD.md +1 -1
- package/docs/Std.Math/AbsI.md +1 -1
- package/docs/Std.Math/AbsL.md +1 -1
- package/docs/Std.Math/AbsSquaredComplex.md +1 -1
- package/docs/Std.Math/AbsSquaredComplexPolar.md +1 -1
- package/docs/Std.Math/ApproximateFactorial.md +1 -1
- package/docs/Std.Math/ArcCos.md +1 -1
- package/docs/Std.Math/ArcCosh.md +1 -1
- package/docs/Std.Math/ArcSin.md +1 -1
- package/docs/Std.Math/ArcSinh.md +1 -1
- package/docs/Std.Math/ArcTan.md +1 -1
- package/docs/Std.Math/ArcTan2.md +1 -1
- package/docs/Std.Math/ArcTanh.md +1 -1
- package/docs/Std.Math/ArgComplex.md +1 -1
- package/docs/Std.Math/ArgComplexPolar.md +1 -1
- package/docs/Std.Math/Binom.md +1 -1
- package/docs/Std.Math/BitSizeI.md +1 -1
- package/docs/Std.Math/BitSizeL.md +1 -1
- package/docs/Std.Math/Ceiling.md +1 -1
- package/docs/Std.Math/Complex.md +1 -1
- package/docs/Std.Math/ComplexPolar.md +1 -1
- package/docs/Std.Math/ContinuedFractionConvergentI.md +1 -1
- package/docs/Std.Math/ContinuedFractionConvergentL.md +1 -1
- package/docs/Std.Math/Cos.md +1 -1
- package/docs/Std.Math/Cosh.md +1 -1
- package/docs/Std.Math/DivRemI.md +1 -1
- package/docs/Std.Math/DivRemL.md +1 -1
- package/docs/Std.Math/DividedByC.md +1 -1
- package/docs/Std.Math/DividedByCP.md +1 -1
- package/docs/Std.Math/E.md +1 -1
- package/docs/Std.Math/ExpModI.md +1 -1
- package/docs/Std.Math/ExpModL.md +1 -1
- package/docs/Std.Math/ExtendedGreatestCommonDivisorI.md +1 -1
- package/docs/Std.Math/ExtendedGreatestCommonDivisorL.md +1 -1
- package/docs/Std.Math/FactorialI.md +1 -1
- package/docs/Std.Math/FactorialL.md +1 -1
- package/docs/Std.Math/Floor.md +1 -1
- package/docs/Std.Math/GreatestCommonDivisorI.md +1 -1
- package/docs/Std.Math/GreatestCommonDivisorL.md +1 -1
- package/docs/Std.Math/HammingWeightI.md +1 -1
- package/docs/Std.Math/InverseModI.md +1 -1
- package/docs/Std.Math/InverseModL.md +1 -1
- package/docs/Std.Math/IsCoprimeI.md +1 -1
- package/docs/Std.Math/IsCoprimeL.md +1 -1
- package/docs/Std.Math/IsInfinite.md +1 -1
- package/docs/Std.Math/IsNaN.md +1 -1
- package/docs/Std.Math/LargestFixedPoint.md +1 -1
- package/docs/Std.Math/Lg.md +1 -1
- package/docs/Std.Math/Log.md +1 -1
- package/docs/Std.Math/Log10.md +1 -1
- package/docs/Std.Math/LogFactorialD.md +1 -1
- package/docs/Std.Math/LogGammaD.md +1 -1
- package/docs/Std.Math/LogOf2.md +1 -1
- package/docs/Std.Math/Max.md +1 -1
- package/docs/Std.Math/MaxD.md +1 -1
- package/docs/Std.Math/MaxI.md +1 -1
- package/docs/Std.Math/MaxL.md +1 -1
- package/docs/Std.Math/Min.md +1 -1
- package/docs/Std.Math/MinD.md +1 -1
- package/docs/Std.Math/MinI.md +1 -1
- package/docs/Std.Math/MinL.md +1 -1
- package/docs/Std.Math/MinusC.md +1 -1
- package/docs/Std.Math/MinusCP.md +1 -1
- package/docs/Std.Math/ModulusI.md +1 -1
- package/docs/Std.Math/ModulusL.md +1 -1
- package/docs/Std.Math/NegationC.md +1 -1
- package/docs/Std.Math/NegationCP.md +1 -1
- package/docs/Std.Math/PI.md +1 -1
- package/docs/Std.Math/PNorm.md +1 -1
- package/docs/Std.Math/PNormalized.md +1 -1
- package/docs/Std.Math/PlusC.md +1 -1
- package/docs/Std.Math/PlusCP.md +1 -1
- package/docs/Std.Math/PowC.md +1 -1
- package/docs/Std.Math/PowCP.md +1 -1
- package/docs/Std.Math/RealMod.md +1 -1
- package/docs/Std.Math/Round.md +1 -1
- package/docs/Std.Math/RoundHalfAwayFromZero.md +1 -1
- package/docs/Std.Math/SignD.md +1 -1
- package/docs/Std.Math/SignI.md +1 -1
- package/docs/Std.Math/SignL.md +1 -1
- package/docs/Std.Math/Sin.md +1 -1
- package/docs/Std.Math/Sinh.md +1 -1
- package/docs/Std.Math/SmallestFixedPoint.md +1 -1
- package/docs/Std.Math/Sqrt.md +1 -1
- package/docs/Std.Math/SquaredNorm.md +1 -1
- package/docs/Std.Math/Tan.md +1 -1
- package/docs/Std.Math/Tanh.md +1 -1
- package/docs/Std.Math/TimesC.md +1 -1
- package/docs/Std.Math/TimesCP.md +1 -1
- package/docs/Std.Math/TrailingZeroCountI.md +1 -1
- package/docs/Std.Math/TrailingZeroCountL.md +1 -1
- package/docs/Std.Math/Truncate.md +1 -1
- package/docs/Std.Math/index.md +1 -1
- package/docs/Std.Measurement/IsLossResult.md +1 -1
- package/docs/Std.Measurement/MResetEachZ.md +1 -1
- package/docs/Std.Measurement/MResetX.md +1 -1
- package/docs/Std.Measurement/MResetY.md +1 -1
- package/docs/Std.Measurement/MResetZ.md +1 -1
- package/docs/Std.Measurement/MResetZChecked.md +1 -1
- package/docs/Std.Measurement/MeasureAllZ.md +1 -1
- package/docs/Std.Measurement/MeasureEachZ.md +1 -1
- package/docs/Std.Measurement/MeasureInteger.md +1 -1
- package/docs/Std.Measurement/index.md +1 -1
- package/docs/Std.Random/DrawRandomBool.md +1 -1
- package/docs/Std.Random/DrawRandomDouble.md +1 -1
- package/docs/Std.Random/DrawRandomInt.md +1 -1
- package/docs/Std.Random/index.md +1 -1
- package/docs/Std.Range/IsRangeEmpty.md +1 -1
- package/docs/Std.Range/RangeEnd.md +1 -1
- package/docs/Std.Range/RangeReverse.md +1 -1
- package/docs/Std.Range/RangeStart.md +1 -1
- package/docs/Std.Range/RangeStep.md +1 -1
- package/docs/Std.Range/index.md +1 -1
- package/docs/Std.ResourceEstimation/AccountForEstimates.md +1 -1
- package/docs/Std.ResourceEstimation/AuxQubitCount.md +1 -1
- package/docs/Std.ResourceEstimation/BeginEstimateCaching.md +1 -1
- package/docs/Std.ResourceEstimation/BeginRepeatEstimates.md +1 -1
- package/docs/Std.ResourceEstimation/CczCount.md +1 -1
- package/docs/Std.ResourceEstimation/EnableMemoryComputeArchitecture.md +1 -1
- package/docs/Std.ResourceEstimation/EndEstimateCaching.md +1 -1
- package/docs/Std.ResourceEstimation/EndRepeatEstimates.md +1 -1
- package/docs/Std.ResourceEstimation/LeastFrequentlyUsed.md +1 -1
- package/docs/Std.ResourceEstimation/LeastRecentlyUsed.md +1 -1
- package/docs/Std.ResourceEstimation/MeasurementCount.md +1 -1
- package/docs/Std.ResourceEstimation/PSSPCLayout.md +1 -1
- package/docs/Std.ResourceEstimation/RepeatEstimates.md +1 -1
- package/docs/Std.ResourceEstimation/RotationCount.md +1 -1
- package/docs/Std.ResourceEstimation/RotationDepth.md +1 -1
- package/docs/Std.ResourceEstimation/SingleVariant.md +1 -1
- package/docs/Std.ResourceEstimation/TCount.md +1 -1
- package/docs/Std.ResourceEstimation/index.md +1 -1
- package/docs/Std.StatePreparation/ApproximatelyPreparePureStateCP.md +1 -1
- package/docs/Std.StatePreparation/PreparePureStateD.md +1 -1
- package/docs/Std.StatePreparation/PrepareUniformSuperposition.md +1 -1
- package/docs/Std.StatePreparation/index.md +1 -1
- package/docs/Std.TableLookup/Select.md +1 -1
- package/docs/Std.TableLookup/index.md +1 -1
- package/docs/index.md +1 -1
- package/lib/nodejs/qsc_wasm.cjs +1 -1
- package/lib/nodejs/qsc_wasm_bg.wasm +0 -0
- package/lib/web/qsc_wasm.js +1 -1
- package/lib/web/qsc_wasm_bg.wasm +0 -0
- package/package.json +3 -2
- package/ux/index.ts +5 -0
- package/ux/qdk-theme.css +142 -0
- package/ux/qsharp-ux.css +25 -85
- package/ux/themeObserver.ts +124 -0
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
uid: Qdk.Std.StatePreparation.ApproximatelyPreparePureStateCP
|
|
3
3
|
title: ApproximatelyPreparePureStateCP operation
|
|
4
4
|
description: "Q# ApproximatelyPreparePureStateCP operation: Given a set of coefficients and a big-endian quantum register, prepares a state on that register described by the given coefficients, up to a given approximation tolerance."
|
|
5
|
-
ms.date: 01/
|
|
5
|
+
ms.date: 01/21/2026
|
|
6
6
|
qsharp.kind: operation
|
|
7
7
|
qsharp.package: __Std__
|
|
8
8
|
qsharp.namespace: Std.StatePreparation
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
uid: Qdk.Std.StatePreparation.PreparePureStateD
|
|
3
3
|
title: PreparePureStateD operation
|
|
4
4
|
description: "Q# PreparePureStateD operation: Given a set of coefficients and a big-endian quantum register, prepares a state on that register described by the given coefficients."
|
|
5
|
-
ms.date: 01/
|
|
5
|
+
ms.date: 01/21/2026
|
|
6
6
|
qsharp.kind: operation
|
|
7
7
|
qsharp.package: __Std__
|
|
8
8
|
qsharp.namespace: Std.StatePreparation
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
uid: Qdk.Std.StatePreparation.PrepareUniformSuperposition
|
|
3
3
|
title: PrepareUniformSuperposition operation
|
|
4
4
|
description: "Q# PrepareUniformSuperposition operation: Prepares a uniform superposition of states that represent integers 0 through `nStates - 1` in a little-endian `qubits` register."
|
|
5
|
-
ms.date: 01/
|
|
5
|
+
ms.date: 01/21/2026
|
|
6
6
|
qsharp.kind: operation
|
|
7
7
|
qsharp.package: __Std__
|
|
8
8
|
qsharp.namespace: Std.StatePreparation
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
uid: Qdk.Std.TableLookup.Select
|
|
3
3
|
title: Select operation
|
|
4
4
|
description: "Q# Select operation: Performs table lookup using a SELECT network"
|
|
5
|
-
ms.date: 01/
|
|
5
|
+
ms.date: 01/21/2026
|
|
6
6
|
qsharp.kind: operation
|
|
7
7
|
qsharp.package: __Std__
|
|
8
8
|
qsharp.namespace: Std.TableLookup
|
package/docs/index.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
uid: Microsoft.Quantum.apiref-toc
|
|
3
3
|
title: Q# standard libraries for the Microsoft Quantum Development Kit
|
|
4
4
|
description: Table of contents for the Q# standard libraries for Microsoft Quantum Development Kit
|
|
5
|
-
ms.date: 01/
|
|
5
|
+
ms.date: 01/21/2026
|
|
6
6
|
ms.topic: landing-page
|
|
7
7
|
---
|
|
8
8
|
|
package/lib/nodejs/qsc_wasm.cjs
CHANGED
|
@@ -1570,7 +1570,7 @@ module.exports.__wbindgen_cb_drop = function(arg0) {
|
|
|
1570
1570
|
return ret;
|
|
1571
1571
|
};
|
|
1572
1572
|
|
|
1573
|
-
module.exports.
|
|
1573
|
+
module.exports.__wbindgen_closure_wrapper6549 = function(arg0, arg1, arg2) {
|
|
1574
1574
|
const ret = makeMutClosure(arg0, arg1, 2063, __wbg_adapter_52);
|
|
1575
1575
|
return addHeapObject(ret);
|
|
1576
1576
|
};
|
|
Binary file
|
package/lib/web/qsc_wasm.js
CHANGED
|
@@ -1525,7 +1525,7 @@ function __wbg_get_imports() {
|
|
|
1525
1525
|
const ret = false;
|
|
1526
1526
|
return ret;
|
|
1527
1527
|
};
|
|
1528
|
-
imports.wbg.
|
|
1528
|
+
imports.wbg.__wbindgen_closure_wrapper6549 = function(arg0, arg1, arg2) {
|
|
1529
1529
|
const ret = makeMutClosure(arg0, arg1, 2063, __wbg_adapter_52);
|
|
1530
1530
|
return addHeapObject(ret);
|
|
1531
1531
|
};
|
package/lib/web/qsc_wasm_bg.wasm
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qsharp-lang",
|
|
3
3
|
"description": "qsharp language package for quantum development",
|
|
4
|
-
"version": "1.23.
|
|
4
|
+
"version": "1.23.4-dev",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"engines": {
|
|
7
7
|
"node": ">=16.17.0"
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
"./debug-service-worker": "./dist/debug-service/worker-browser.js",
|
|
23
23
|
"./katas": "./dist/katas.js",
|
|
24
24
|
"./katas-md": "./dist/katas-md.js",
|
|
25
|
-
"./ux": "./ux/index.ts"
|
|
25
|
+
"./ux": "./ux/index.ts",
|
|
26
|
+
"./qdk-theme.css": "./ux/qdk-theme.css"
|
|
26
27
|
},
|
|
27
28
|
"scripts": {
|
|
28
29
|
"build": "npm run docs && npm run generate && npm run build:tsc && npm run build:ux",
|
package/ux/index.ts
CHANGED
|
@@ -22,3 +22,8 @@ export { Circuit, CircuitPanel } from "./circuit.js";
|
|
|
22
22
|
export { setRenderer, Markdown } from "./renderers.js";
|
|
23
23
|
export { Atoms, type ZoneLayout, type TraceData } from "./atoms/index.js";
|
|
24
24
|
export { MoleculeViewer } from "./chem/index.js";
|
|
25
|
+
export {
|
|
26
|
+
ensureTheme,
|
|
27
|
+
detectThemeChange,
|
|
28
|
+
updateStyleSheetTheme,
|
|
29
|
+
} from "./themeObserver.js";
|
package/ux/qdk-theme.css
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/* Copyright (c) Microsoft Corporation.
|
|
2
|
+
Licensed under the MIT License. */
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
CSS is tricky get get right across environments we care about. This file attempts to centralize some of the nuances.
|
|
6
|
+
|
|
7
|
+
The approach is structured in 2 parts. This file is part 1:
|
|
8
|
+
|
|
9
|
+
1. Set the variables for the color palette based on the current theme (light/dark).
|
|
10
|
+
2. Set class values or variables for the specific ux elements based on the color palette variables.
|
|
11
|
+
|
|
12
|
+
Specifying ANY color values (e.g. `red`, `#ff0000`, etc) should only be done via the variables in this file.
|
|
13
|
+
Other styles that need colors should ONLY reference these variables, or variables derived from them.
|
|
14
|
+
|
|
15
|
+
This ensures that when the theme changes, all widgets automatically update to the correct colors, and
|
|
16
|
+
our `palette` of colors is consistent across all widgets.
|
|
17
|
+
|
|
18
|
+
=== HOW THIS SETS THEME COLORS ===
|
|
19
|
+
|
|
20
|
+
We want to set colors based on the current theme. This could be:
|
|
21
|
+
|
|
22
|
+
1. The theme set in VS Code.
|
|
23
|
+
2. The theme in Jupyter running in the browser.
|
|
24
|
+
3. A theme set on the host page (e.g. the katas viewer on the playground).
|
|
25
|
+
|
|
26
|
+
VS Code or Jupyter will always set an attribute on the body element indicating the current theme.
|
|
27
|
+
If outside of those environments, you can use the `ensureTheme()` function in themeObserver.ts to
|
|
28
|
+
detect the URL params or OS preference and set the `data-theme` attribute accordingly.
|
|
29
|
+
|
|
30
|
+
The goal is to use CSS selectors and variables to ensure the right colors are applied in each case,
|
|
31
|
+
with the 'cascade' ensuring the correct precedence.
|
|
32
|
+
|
|
33
|
+
Note that the 'default' light mode values (no attribute set and no browser preference) are always
|
|
34
|
+
on the :root selector (typically the html element), so if all the above fails, light mode will be set.
|
|
35
|
+
|
|
36
|
+
When a theme attribute is present on the body element, we set the variables again there to override
|
|
37
|
+
the :root values. As the body element will be closer to the element being styled than the :root selector
|
|
38
|
+
this will take precedence.
|
|
39
|
+
|
|
40
|
+
=== ENVIRONMENT SPECIFIC SELECTORS ===
|
|
41
|
+
|
|
42
|
+
There are a number of selectors we can use for various environments:
|
|
43
|
+
|
|
44
|
+
- VS Code will use one of the below attributes on the body element (including the body in the iframe
|
|
45
|
+
for the notebook cells when running Jupyter in VS Code). The first 2 are light, the second 2 are dark:
|
|
46
|
+
|
|
47
|
+
- [data-vscode-theme-kind="vscode-light"]
|
|
48
|
+
- [data-vscode-theme-kind="vscode-high-contrast-light"]
|
|
49
|
+
- [data-vscode-theme-kind="vscode-dark"]
|
|
50
|
+
- [data-vscode-theme-kind="vscode-high-contrast"]
|
|
51
|
+
|
|
52
|
+
- Jupyter in the browser will use one of the below attributes on the body element for light/dark themes:
|
|
53
|
+
|
|
54
|
+
- [data-jp-theme-light="true"]
|
|
55
|
+
- [data-jp-theme-light="false"]
|
|
56
|
+
|
|
57
|
+
- It is also common to use a [data-theme="light"] or [data-theme="dark"] attribute on the body element
|
|
58
|
+
to indicate light/dark themes, so look for that also (e.g. in the kata viewer in the playground).
|
|
59
|
+
|
|
60
|
+
Note that colors that are not theme dependent should just be set on :root, with no need to add overrides
|
|
61
|
+
*/
|
|
62
|
+
|
|
63
|
+
/* Default to light values set on :root if all else fails */
|
|
64
|
+
:root,
|
|
65
|
+
/* Set these variables on the body element if attributes indicate a light theme choice */
|
|
66
|
+
body[data-theme="light"],
|
|
67
|
+
body[data-jp-theme-light="true"],
|
|
68
|
+
body[data-vscode-theme-kind="vscode-light"],
|
|
69
|
+
body[data-vscode-theme-kind="vscode-high-contrast-light"] {
|
|
70
|
+
/* Set any non-theme specific values here only */
|
|
71
|
+
--qdk-font-family-monospace: var(
|
|
72
|
+
--vscode-editor-font-family,
|
|
73
|
+
"Consolas",
|
|
74
|
+
"Menlo",
|
|
75
|
+
"Liberation Mono",
|
|
76
|
+
monospace
|
|
77
|
+
);
|
|
78
|
+
--qdk-mid-gray: #888;
|
|
79
|
+
/* End non-theme specific values */
|
|
80
|
+
|
|
81
|
+
/* Use the host foreground/background if available */
|
|
82
|
+
--qdk-host-background: var(
|
|
83
|
+
--vscode-editor-background,
|
|
84
|
+
var(--jp-layout-color0, #eee)
|
|
85
|
+
);
|
|
86
|
+
--qdk-host-foreground: var(
|
|
87
|
+
--vscode-editor-foreground,
|
|
88
|
+
var(--jp-widgets-color, #222)
|
|
89
|
+
);
|
|
90
|
+
--qdk-background-accent: #ddd;
|
|
91
|
+
|
|
92
|
+
/* Used for text that must stand out on various backgrounds */
|
|
93
|
+
--qdk-text-high-contrast: #000;
|
|
94
|
+
|
|
95
|
+
/* Outline for widget borders, etc. */
|
|
96
|
+
--qdk-widget-outline: #ccc;
|
|
97
|
+
|
|
98
|
+
/* Use for menus */
|
|
99
|
+
--qdk-menu-fill: #ccc;
|
|
100
|
+
--qdk-menu-fill-hover: #9cf;
|
|
101
|
+
--qdk-menu-fill-selected: #7af;
|
|
102
|
+
|
|
103
|
+
/* Used for shapes in charts, etc. that may have overlapping text (which should contrast) */
|
|
104
|
+
--qdk-shape-fill: #8ab8ff;
|
|
105
|
+
--qdk-shape-fill-selected: #b5c5f2;
|
|
106
|
+
--qdk-shape-stroke-selected: #587ddd;
|
|
107
|
+
--qdk-shape-stroke-hover: #6b6b6b;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/* Set these variables on the body element if attributes indicate a dark theme choice */
|
|
111
|
+
body[data-theme="dark"],
|
|
112
|
+
body[data-jp-theme-light="false"],
|
|
113
|
+
body[data-vscode-theme-kind="vscode-dark"],
|
|
114
|
+
body[data-vscode-theme-kind="vscode-high-contrast"] {
|
|
115
|
+
/* Use the host foreground/background if available */
|
|
116
|
+
--qdk-host-background: var(
|
|
117
|
+
--vscode-editor-background,
|
|
118
|
+
var(--jp-layout-color0, #222)
|
|
119
|
+
);
|
|
120
|
+
--qdk-host-foreground: var(
|
|
121
|
+
--vscode-editor-foreground,
|
|
122
|
+
var(--jp-widgets-color, #eee)
|
|
123
|
+
);
|
|
124
|
+
--qdk-background-accent: #333;
|
|
125
|
+
|
|
126
|
+
/* Used for text that must stand out on various backgrounds */
|
|
127
|
+
--qdk-text-high-contrast: #fff;
|
|
128
|
+
|
|
129
|
+
/* Outline for widget borders, etc. */
|
|
130
|
+
--qdk-widget-outline: #444;
|
|
131
|
+
|
|
132
|
+
/* Use for menus */
|
|
133
|
+
--qdk-menu-fill: #444;
|
|
134
|
+
--qdk-menu-fill-hover: #468;
|
|
135
|
+
--qdk-menu-fill-selected: #47a;
|
|
136
|
+
|
|
137
|
+
/* Used for shapes in charts, etc. that may have overlapping text (which should contrast) */
|
|
138
|
+
--qdk-shape-fill: #4aa3ff;
|
|
139
|
+
--qdk-shape-fill-selected: #ffd54f;
|
|
140
|
+
--qdk-shape-stroke-selected: #ffecb3;
|
|
141
|
+
--qdk-shape-stroke-hover: #c5c5c5;
|
|
142
|
+
}
|
package/ux/qsharp-ux.css
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/* Copyright (c) Microsoft Corporation.
|
|
2
2
|
Licensed under the MIT License. */
|
|
3
3
|
|
|
4
|
+
@import "./qdk-theme.css";
|
|
5
|
+
|
|
4
6
|
/* Styles for Q# UX components.
|
|
5
7
|
|
|
6
8
|
Notes:
|
|
@@ -48,57 +50,6 @@ modern-normalize (see https://mattbrictson.com/blog/css-normalize-and-reset for
|
|
|
48
50
|
--error-background-color: #ffe3e3;
|
|
49
51
|
--warning-background-color: #fff6d7;
|
|
50
52
|
--bar-selected-outline: #587ddd;
|
|
51
|
-
|
|
52
|
-
/* Histogram palette (light scheme by default; used when no VS Code theme is detected) */
|
|
53
|
-
--qs-histogram-bg: #ffffff;
|
|
54
|
-
--qs-histogram-border: #768f9c;
|
|
55
|
-
--qs-histogram-bar-fill: #8ab8ff;
|
|
56
|
-
--qs-histogram-bar-hover-stroke: #6b6b6b;
|
|
57
|
-
--qs-histogram-bar-selected-fill: #b5c5f2;
|
|
58
|
-
--qs-histogram-bar-selected-stroke: #587ddd;
|
|
59
|
-
--qs-histogram-bar-label-fill: #202020;
|
|
60
|
-
--qs-histogram-label-fill: #3b3b3b;
|
|
61
|
-
--qs-histogram-hover-text-fill: #6b6b6b;
|
|
62
|
-
--qs-histogram-menu-icon-stroke: #3b3b3b;
|
|
63
|
-
--qs-histogram-menu-icon-fill: #ffffff;
|
|
64
|
-
--qs-histogram-menu-box-fill: #ffffff;
|
|
65
|
-
--qs-histogram-menu-box-stroke: #3b3b3b;
|
|
66
|
-
--qs-histogram-menu-item-fill: #b7d5ff;
|
|
67
|
-
--qs-histogram-menu-item-hover-fill: #9fc7ff;
|
|
68
|
-
--qs-histogram-menu-item-stroke: #6b6b6b;
|
|
69
|
-
--qs-histogram-menu-item-selected-fill: #6aa9ff;
|
|
70
|
-
--qs-histogram-menu-text-fill: #202020;
|
|
71
|
-
--qs-histogram-menu-separator-stroke: #6b6b6b;
|
|
72
|
-
--qs-histogram-help-fill: #ffffff;
|
|
73
|
-
--qs-histogram-help-stroke: #6b6b6b;
|
|
74
|
-
--qs-histogram-help-text-fill: #202020;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/* Histogram palette overrides for dark themes. */
|
|
78
|
-
body[data-vscode-theme-kind="vscode-dark"],
|
|
79
|
-
body[data-vscode-theme-kind="vscode-high-contrast"] {
|
|
80
|
-
--qs-histogram-bg: #1e1e1e;
|
|
81
|
-
--qs-histogram-border: #3c3c3c;
|
|
82
|
-
--qs-histogram-bar-fill: #4aa3ff;
|
|
83
|
-
--qs-histogram-bar-hover-stroke: #c5c5c5;
|
|
84
|
-
--qs-histogram-bar-selected-fill: #ffd54f;
|
|
85
|
-
--qs-histogram-bar-selected-stroke: #ffecb3;
|
|
86
|
-
--qs-histogram-bar-label-fill: #ffffff;
|
|
87
|
-
--qs-histogram-label-fill: #ffffff;
|
|
88
|
-
--qs-histogram-hover-text-fill: #ffffff;
|
|
89
|
-
--qs-histogram-menu-icon-stroke: #d4d4d4;
|
|
90
|
-
--qs-histogram-menu-icon-fill: #1e1e1e;
|
|
91
|
-
--qs-histogram-menu-box-fill: #252526;
|
|
92
|
-
--qs-histogram-menu-box-stroke: #d4d4d4;
|
|
93
|
-
--qs-histogram-menu-item-fill: #2d2d30;
|
|
94
|
-
--qs-histogram-menu-item-hover-fill: #3e3e42;
|
|
95
|
-
--qs-histogram-menu-item-stroke: #6b6b6b;
|
|
96
|
-
--qs-histogram-menu-item-selected-fill: #094771;
|
|
97
|
-
--qs-histogram-menu-text-fill: #ffffff;
|
|
98
|
-
--qs-histogram-menu-separator-stroke: #6b6b6b;
|
|
99
|
-
--qs-histogram-help-fill: #252526;
|
|
100
|
-
--qs-histogram-help-stroke: #6b6b6b;
|
|
101
|
-
--qs-histogram-help-text-fill: #ffffff;
|
|
102
53
|
}
|
|
103
54
|
|
|
104
55
|
/* TODO: Make the below playground specific classes */
|
|
@@ -396,108 +347,97 @@ body[data-vscode-theme-kind="vscode-high-contrast"] {
|
|
|
396
347
|
.histogram {
|
|
397
348
|
max-height: calc(100vh - 40px);
|
|
398
349
|
max-width: 600px;
|
|
399
|
-
border: 1px solid var(--
|
|
400
|
-
background-color: var(--
|
|
350
|
+
border: 1px solid var(--qdk-widget-outline);
|
|
351
|
+
background-color: var(--qdk-host-background);
|
|
401
352
|
}
|
|
402
353
|
|
|
403
354
|
.bar {
|
|
404
|
-
fill: var(--
|
|
355
|
+
fill: var(--qdk-shape-fill);
|
|
405
356
|
}
|
|
406
357
|
|
|
407
358
|
.bar:hover {
|
|
408
|
-
stroke: var(--
|
|
359
|
+
stroke: var(--qdk-shape-stroke-hover);
|
|
409
360
|
stroke-width: 0.5;
|
|
410
361
|
}
|
|
411
362
|
|
|
412
363
|
.bar-selected {
|
|
413
|
-
stroke: var(--
|
|
414
|
-
fill: var(--
|
|
364
|
+
stroke: var(--qdk-shape-stroke-selected);
|
|
365
|
+
fill: var(--qdk-shape-fill-selected);
|
|
415
366
|
}
|
|
416
367
|
|
|
417
368
|
.bar-label {
|
|
418
369
|
font-size: 3pt;
|
|
419
|
-
fill: var(--
|
|
370
|
+
fill: var(--qdk-text-high-contrast);
|
|
420
371
|
text-anchor: end;
|
|
421
372
|
pointer-events: none;
|
|
422
373
|
}
|
|
423
374
|
|
|
424
375
|
.bar-label-ket {
|
|
425
|
-
font-family: var(
|
|
426
|
-
--vscode-editor-font-family,
|
|
427
|
-
"Consolas",
|
|
428
|
-
"Menlo",
|
|
429
|
-
"Monaco",
|
|
430
|
-
"Liberation Mono",
|
|
431
|
-
"Courier New",
|
|
432
|
-
monospace
|
|
433
|
-
);
|
|
376
|
+
font-family: var(--qdk-font-family-monospace);
|
|
434
377
|
font-variant-ligatures: none;
|
|
435
|
-
font-size: 3.3pt;
|
|
436
378
|
}
|
|
437
379
|
|
|
438
380
|
.histo-label {
|
|
439
381
|
font-size: 3.5pt;
|
|
440
|
-
fill: var(--
|
|
382
|
+
fill: var(--qdk-host-foreground);
|
|
441
383
|
}
|
|
442
384
|
|
|
443
385
|
.hover-text {
|
|
444
386
|
font-size: 3.5pt;
|
|
445
|
-
fill: var(--
|
|
387
|
+
fill: var(--qdk-host-foreground);
|
|
446
388
|
text-anchor: middle;
|
|
447
389
|
}
|
|
448
390
|
|
|
449
391
|
.menu-icon * {
|
|
450
|
-
fill: var(--
|
|
451
|
-
stroke: var(--
|
|
392
|
+
fill: var(--qdk-host-background);
|
|
393
|
+
stroke: var(--qdk-host-foreground);
|
|
452
394
|
}
|
|
453
395
|
|
|
454
396
|
.menu-box {
|
|
455
|
-
fill: var(--
|
|
456
|
-
stroke: var(--
|
|
397
|
+
fill: var(--qdk-host-background);
|
|
398
|
+
stroke: var(--qdk-host-foreground);
|
|
457
399
|
stroke-width: 0.1;
|
|
458
400
|
}
|
|
459
401
|
|
|
460
402
|
.menu-item {
|
|
461
403
|
width: 32px;
|
|
462
404
|
height: 10px;
|
|
463
|
-
fill: var(--
|
|
464
|
-
stroke: var(--
|
|
405
|
+
fill: var(--qdk-menu-fill);
|
|
406
|
+
stroke: var(--qdk-mid-gray);
|
|
465
407
|
stroke-width: 0.2;
|
|
466
408
|
}
|
|
467
409
|
|
|
468
|
-
/* --vscode-list-inactiveSelectionBackground */
|
|
469
|
-
|
|
470
410
|
.menu-item:hover {
|
|
471
411
|
stroke-width: 0.6;
|
|
472
|
-
fill: var(--
|
|
412
|
+
fill: var(--qdk-menu-fill-hover);
|
|
473
413
|
}
|
|
474
414
|
|
|
475
415
|
.menu-selected {
|
|
476
416
|
/* stroke: #0800ff; */
|
|
477
|
-
fill: var(--
|
|
417
|
+
fill: var(--qdk-menu-fill-selected);
|
|
478
418
|
}
|
|
479
419
|
|
|
480
420
|
.menu-text {
|
|
481
421
|
font-size: 4.5px;
|
|
482
422
|
pointer-events: none;
|
|
483
|
-
fill: var(--
|
|
423
|
+
fill: var(--qdk-host-foreground);
|
|
484
424
|
}
|
|
485
425
|
|
|
486
426
|
.menu-separator {
|
|
487
|
-
stroke: var(--
|
|
427
|
+
stroke: var(--qdk-mid-gray);
|
|
488
428
|
stroke-width: 0.25;
|
|
489
429
|
}
|
|
490
430
|
|
|
491
431
|
.help-info {
|
|
492
|
-
fill: var(--
|
|
493
|
-
stroke: var(--
|
|
432
|
+
fill: var(--qdk-host-background);
|
|
433
|
+
stroke: var(--qdk-mid-gray);
|
|
494
434
|
stroke-width: 0.5;
|
|
495
435
|
}
|
|
496
436
|
|
|
497
437
|
.help-info-text {
|
|
498
438
|
font-size: 4.5px;
|
|
499
439
|
pointer-events: none;
|
|
500
|
-
fill: var(--
|
|
440
|
+
fill: var(--qdk-host-foreground);
|
|
501
441
|
}
|
|
502
442
|
|
|
503
443
|
/* RE details */
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
const vscodeThemeAttribute = "data-vscode-theme-kind";
|
|
5
|
+
const jupyterThemeAttribute = "data-jp-theme-light";
|
|
6
|
+
const commonThemeAttribute = "data-theme";
|
|
7
|
+
|
|
8
|
+
type ThemeChangeCallback = (isDark: boolean) => void;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Detects the current theme based on body attributes, url params, or OS preference.
|
|
12
|
+
* If no theme attribute is set on the body or url, sets the data-theme attribute
|
|
13
|
+
* based on the OS dark mode preference.
|
|
14
|
+
*
|
|
15
|
+
* Should be called after the DOM is ready. Returns undefined if document.body
|
|
16
|
+
* is not available (e.g., in non-browser environments or before DOM is ready).
|
|
17
|
+
*
|
|
18
|
+
* @returns true if dark theme, false if light theme, undefined if not in browser
|
|
19
|
+
*/
|
|
20
|
+
export function ensureTheme(): boolean | undefined {
|
|
21
|
+
if (typeof document === "undefined" || !document.body) {
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
const el = document.body;
|
|
25
|
+
|
|
26
|
+
// Check if any theme attribute is already set
|
|
27
|
+
const vscodeTheme = el.getAttribute(vscodeThemeAttribute);
|
|
28
|
+
const jupyterTheme = el.getAttribute(jupyterThemeAttribute);
|
|
29
|
+
const commonTheme = el.getAttribute(commonThemeAttribute);
|
|
30
|
+
|
|
31
|
+
if (vscodeTheme) {
|
|
32
|
+
return (
|
|
33
|
+
vscodeTheme !== "vscode-light" &&
|
|
34
|
+
vscodeTheme !== "vscode-high-contrast-light"
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (jupyterTheme) {
|
|
39
|
+
return jupyterTheme !== "true"; // true means light theme
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (commonTheme) {
|
|
43
|
+
return commonTheme === "dark";
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Check for theme specified in URL parameters
|
|
47
|
+
const urlParams = new URLSearchParams(window.location.search);
|
|
48
|
+
const urlTheme = urlParams.get("theme");
|
|
49
|
+
if (urlTheme === "dark" || urlTheme === "light") {
|
|
50
|
+
el.setAttribute(commonThemeAttribute, urlTheme);
|
|
51
|
+
return urlTheme === "dark";
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// No theme attribute set, detect OS preference and set it, and observe for changes
|
|
55
|
+
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
56
|
+
el.setAttribute(commonThemeAttribute, mediaQuery.matches ? "dark" : "light");
|
|
57
|
+
|
|
58
|
+
mediaQuery.addEventListener("change", (e) => {
|
|
59
|
+
el.setAttribute(commonThemeAttribute, e.matches ? "dark" : "light");
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
return mediaQuery.matches;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Wire up a callback to invoke when the theme changes.
|
|
67
|
+
*
|
|
68
|
+
* @param el The element to observe for theme attribute changes (usually document.body)
|
|
69
|
+
* @param callback The callback to invoke when the theme changes
|
|
70
|
+
*/
|
|
71
|
+
export function detectThemeChange(el: Element, callback: ThemeChangeCallback) {
|
|
72
|
+
const observer = new MutationObserver((mutations: MutationRecord[]) => {
|
|
73
|
+
let isDark = false; // Default to light
|
|
74
|
+
|
|
75
|
+
for (const mutation of mutations) {
|
|
76
|
+
if (mutation.attributeName === vscodeThemeAttribute) {
|
|
77
|
+
const themeAttr = el.getAttribute(vscodeThemeAttribute);
|
|
78
|
+
isDark =
|
|
79
|
+
themeAttr !== "vscode-light" &&
|
|
80
|
+
themeAttr !== "vscode-high-contrast-light";
|
|
81
|
+
} else if (mutation.attributeName === jupyterThemeAttribute) {
|
|
82
|
+
const themeAttr = el.getAttribute(jupyterThemeAttribute);
|
|
83
|
+
isDark = themeAttr !== "true"; // true means light theme
|
|
84
|
+
} else if (mutation.attributeName === commonThemeAttribute) {
|
|
85
|
+
const themeAttr = el.getAttribute(commonThemeAttribute);
|
|
86
|
+
isDark = themeAttr === "dark";
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
callback(isDark);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
observer.observe(el, {
|
|
93
|
+
attributeFilter: [
|
|
94
|
+
vscodeThemeAttribute,
|
|
95
|
+
jupyterThemeAttribute,
|
|
96
|
+
commonThemeAttribute,
|
|
97
|
+
],
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Helper for updating specific stylesheets based on theme
|
|
103
|
+
* @param isDark true to set dark theme, false to set light theme
|
|
104
|
+
* @param searchText The text to search for in the stylesheet href to identify it
|
|
105
|
+
* @param replaceText The regex to use to find the part of the href to replace
|
|
106
|
+
* @param lightText The replacement text for light theme
|
|
107
|
+
* @param darkText The replacement text for dark theme
|
|
108
|
+
*/
|
|
109
|
+
export function updateStyleSheetTheme(
|
|
110
|
+
isDark: boolean,
|
|
111
|
+
searchText: string,
|
|
112
|
+
replaceText: RegExp,
|
|
113
|
+
lightText: string,
|
|
114
|
+
darkText: string,
|
|
115
|
+
) {
|
|
116
|
+
// Update the stylesheet href based on the theme to apply
|
|
117
|
+
document.head.querySelectorAll("link").forEach((el) => {
|
|
118
|
+
const ref = el.getAttribute("href");
|
|
119
|
+
if (ref && ref.includes(searchText)) {
|
|
120
|
+
const newVal = ref.replace(replaceText, isDark ? darkText : lightText);
|
|
121
|
+
el.setAttribute("href", newVal);
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
}
|