pxt-core 7.5.8 → 7.5.9

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.
Files changed (46) hide show
  1. package/built/pxt.js +1002 -2
  2. package/built/pxtblockly.js +428 -50
  3. package/built/pxtblocks.d.ts +34 -0
  4. package/built/pxtblocks.js +428 -50
  5. package/built/pxtlib.d.ts +19 -1
  6. package/built/pxtlib.js +125 -1
  7. package/built/pxtsim.d.ts +222 -0
  8. package/built/pxtsim.js +877 -1
  9. package/built/target.js +1 -1
  10. package/built/web/icons.css +49 -10
  11. package/built/web/main.js +1 -1
  12. package/built/web/pxtapp.js +1 -1
  13. package/built/web/pxtasseteditor.js +1 -1
  14. package/built/web/pxtblockly.js +1 -1
  15. package/built/web/pxtblocks.js +1 -1
  16. package/built/web/pxtembed.js +2 -2
  17. package/built/web/pxtlib.js +1 -1
  18. package/built/web/pxtsim.js +1 -1
  19. package/built/web/pxtworker.js +1 -1
  20. package/built/web/react-common-authcode.css +104 -1
  21. package/built/web/react-common-skillmap.css +1 -1
  22. package/built/web/rtlreact-common-skillmap.css +1 -1
  23. package/built/web/rtlsemantic.css +2 -2
  24. package/built/web/semantic.css +2 -2
  25. package/built/web/skillmap/js/main.b5f3628d.chunk.js +1 -0
  26. package/docfiles/footer.html +1 -1
  27. package/docfiles/script.html +1 -1
  28. package/docfiles/thin-footer.html +1 -1
  29. package/localtypings/pxtarget.d.ts +1 -0
  30. package/package.json +1 -1
  31. package/react-common/components/controls/Button.tsx +7 -3
  32. package/react-common/components/controls/DraggableGraph.tsx +242 -0
  33. package/react-common/components/controls/Dropdown.tsx +121 -0
  34. package/react-common/components/controls/FocusList.tsx +17 -8
  35. package/react-common/components/controls/Input.tsx +13 -3
  36. package/react-common/components/controls/RadioButtonGroup.tsx +66 -0
  37. package/react-common/components/util.tsx +23 -0
  38. package/react-common/styles/controls/DraggableGraph.less +13 -0
  39. package/react-common/styles/controls/Dropdown.less +64 -0
  40. package/react-common/styles/controls/RadioButtonGroup.less +36 -0
  41. package/react-common/styles/react-common-variables.less +24 -0
  42. package/react-common/styles/react-common.less +3 -0
  43. package/theme/pxt.less +1 -0
  44. package/theme/soundeffecteditor.less +132 -0
  45. package/webapp/public/skillmap.html +1 -1
  46. package/built/web/skillmap/js/main.2485091f.chunk.js +0 -1
package/built/pxtlib.js CHANGED
@@ -15844,7 +15844,8 @@ var ts;
15844
15844
  "topblock",
15845
15845
  "callInDebugger",
15846
15846
  "duplicateShadowOnDrag",
15847
- "argsNullable"
15847
+ "argsNullable",
15848
+ "compileHiddenArguments"
15848
15849
  ];
15849
15850
  function parseCommentString(cmt) {
15850
15851
  let res = {
@@ -16762,6 +16763,125 @@ var pxt;
16762
16763
  skillmap.IndexedDBWorkspace = IndexedDBWorkspace;
16763
16764
  })(skillmap = pxt.skillmap || (pxt.skillmap = {}));
16764
16765
  })(pxt || (pxt = {}));
16766
+ var pxt;
16767
+ (function (pxt) {
16768
+ var assets;
16769
+ (function (assets) {
16770
+ function renderSoundPath(sound, width, height) {
16771
+ const { startFrequency, endFrequency, startVolume, endVolume, wave, interpolation } = sound;
16772
+ const scale = (start, end, percent) => {
16773
+ return Math.pow(start, 1 - percent) * Math.pow(end, percent);
16774
+ };
16775
+ // To make the graph appear consistent with the implementation, use a seeded random for the noise waveform.
16776
+ // The numbers are still nonsense but at least this reflects that it's deterministic.
16777
+ const random = new SeededRandom(startFrequency + endFrequency + 1);
16778
+ let getFrequencyAt;
16779
+ switch (interpolation) {
16780
+ case "linear":
16781
+ getFrequencyAt = x => startFrequency + x * (endFrequency - startFrequency) / width;
16782
+ break;
16783
+ case "curve":
16784
+ getFrequencyAt = x => startFrequency + (endFrequency - startFrequency) * Math.sin(x / width * (Math.PI / 2));
16785
+ break;
16786
+ case "logarithmic":
16787
+ getFrequencyAt = x => startFrequency + Math.log10(1 + 9 * (x / width)) * (endFrequency - startFrequency);
16788
+ break;
16789
+ }
16790
+ if (wave === "noise") {
16791
+ getFrequencyAt = () => random.randomRange(500, 1000);
16792
+ }
16793
+ const getVolumeAt = (x) => ((endVolume - startVolume) / width) * x + startVolume;
16794
+ const volumeToAmplitude = (volume) => (volume / 1023) * (height - 2) / 2;
16795
+ const frequencyToWidth = (frequency) => Math.min(width, Math.max(10, (1 / scale(1, 4000, frequency / 4000)) * width / 2));
16796
+ const parts = [`M ${2} ${height / 2}`];
16797
+ let currentX = 0;
16798
+ while (currentX < width) {
16799
+ parts.push(renderHalfWavePart(volumeToAmplitude(getVolumeAt(currentX)), frequencyToWidth(getFrequencyAt(currentX)) / 2, wave, false, random));
16800
+ currentX += frequencyToWidth(getFrequencyAt(currentX)) / 2;
16801
+ parts.push(renderHalfWavePart(volumeToAmplitude(getVolumeAt(currentX)), frequencyToWidth(getFrequencyAt(currentX)) / 2, wave, true, random));
16802
+ currentX += frequencyToWidth(getFrequencyAt(currentX)) / 2;
16803
+ }
16804
+ return parts.join(" ");
16805
+ }
16806
+ assets.renderSoundPath = renderSoundPath;
16807
+ function renderWaveSnapshot(frequency, volume, wave, width, height, timeBase) {
16808
+ // To make the graph appear consistent with the implementation, use a seeded random for the noise waveform.
16809
+ // The numbers are still nonsense but at least this reflects that it's deterministic.
16810
+ const random = new SeededRandom(frequency);
16811
+ if (wave === "noise")
16812
+ frequency = random.randomRange(500, 1000);
16813
+ const amplitude = (volume / 1023) * (height - 2) / 2;
16814
+ const waveHalfWidth = (width / (frequency * timeBase / 1000)) / 2;
16815
+ let numSegments = Math.ceil(width / (waveHalfWidth * 2));
16816
+ if (numSegments % 2 === 1)
16817
+ numSegments++;
16818
+ // Center the wave because it makes an animation look better. The overflow will be clipped
16819
+ // by the outer svg
16820
+ const parts = [`M ${(width / 2) - (numSegments * waveHalfWidth)} ${height / 2}`];
16821
+ let currentX = 0;
16822
+ for (let i = 0; i < numSegments; i++) {
16823
+ parts.push(renderHalfWavePart(amplitude, waveHalfWidth, wave, false, random));
16824
+ currentX += waveHalfWidth;
16825
+ parts.push(renderHalfWavePart(amplitude, waveHalfWidth, wave, true, random));
16826
+ currentX += waveHalfWidth;
16827
+ }
16828
+ return parts.join(" ");
16829
+ }
16830
+ assets.renderWaveSnapshot = renderWaveSnapshot;
16831
+ class SeededRandom {
16832
+ constructor(seed) {
16833
+ this.seed = seed;
16834
+ this.lfsr = seed;
16835
+ }
16836
+ next() {
16837
+ const n = this.lfsr = (this.lfsr >> 1) ^ ((-(this.lfsr & 1)) & 0xb400);
16838
+ return n / 0xffff;
16839
+ }
16840
+ randomRange(min, max) {
16841
+ return min + (max - min) * this.next();
16842
+ }
16843
+ }
16844
+ function renderHalfWavePart(amplitude, width, wave, flip, random) {
16845
+ switch (wave) {
16846
+ case "triangle":
16847
+ return `l ${width / 2} ${flip ? amplitude : -amplitude} l ${width / 2} ${flip ? -amplitude : amplitude}`;
16848
+ case "square":
16849
+ return `v ${flip ? amplitude : -amplitude} h ${width} v ${flip ? -amplitude : amplitude}`;
16850
+ case "sawtooth":
16851
+ if (flip) {
16852
+ return `l ${width} ${amplitude} v ${-amplitude}`;
16853
+ }
16854
+ else {
16855
+ return `v ${-amplitude} l ${width} ${amplitude}`;
16856
+ }
16857
+ case "sine":
16858
+ return `q ${width / 2} ${(flip ? amplitude : -amplitude) * 1.9} ${width} 0`;
16859
+ case "noise":
16860
+ const outParts = [];
16861
+ const points = [];
16862
+ const slice = Math.min(4, width / 4);
16863
+ let positive = flip;
16864
+ for (let x = 0; x < width; x += slice) {
16865
+ points.push(random.randomRange(0, amplitude) * (positive ? 1 : -1));
16866
+ positive = !positive;
16867
+ }
16868
+ points[0] = flip ? amplitude : -amplitude;
16869
+ points[points.length - 1] = 0;
16870
+ let offset = 0;
16871
+ let x = 0;
16872
+ for (const point of points) {
16873
+ let dx = Math.min(slice, width - x);
16874
+ outParts.push(`v ${point - offset} h ${dx}`);
16875
+ offset = point;
16876
+ x += dx;
16877
+ if (x >= width)
16878
+ break;
16879
+ }
16880
+ return outParts.join(" ");
16881
+ }
16882
+ }
16883
+ })(assets = pxt.assets || (pxt.assets = {}));
16884
+ })(pxt || (pxt = {}));
16765
16885
  // See https://github.com/microsoft/TouchDevelop-backend/blob/master/docs/streams.md
16766
16886
  var pxt;
16767
16887
  (function (pxt) {
@@ -17169,6 +17289,10 @@ var pxt;
17169
17289
  cb(this.d);
17170
17290
  return this.update();
17171
17291
  }
17292
+ setD(d) {
17293
+ this.setAttribute("d", d);
17294
+ return this;
17295
+ }
17172
17296
  }
17173
17297
  svgUtil.Path = Path;
17174
17298
  class Image extends Drawable {
package/built/pxtsim.d.ts CHANGED
@@ -1528,6 +1528,228 @@ declare namespace pxsim.svg {
1528
1528
  function title(el: SVGElement, txt: string): SVGTitleElement;
1529
1529
  function toHtmlColor(c: number): string;
1530
1530
  }
1531
+ declare namespace pxsim.codal.music {
1532
+ interface Progression {
1533
+ interval: number[];
1534
+ length: number;
1535
+ }
1536
+ }
1537
+ declare namespace pxsim.codal.music.MusicalIntervals {
1538
+ const chromaticInterval: number[];
1539
+ const majorScaleInterval: number[];
1540
+ const minorScaleInterval: number[];
1541
+ const pentatonicScaleInterval: number[];
1542
+ const majorTriadInterval: number[];
1543
+ const minorTriadInterval: number[];
1544
+ const diminishedInterval: number[];
1545
+ const wholeToneInterval: number[];
1546
+ }
1547
+ declare namespace pxsim.codal.music.MusicalProgressions {
1548
+ const chromatic: Progression;
1549
+ const majorScale: Progression;
1550
+ const minorScale: Progression;
1551
+ const pentatonicScale: Progression;
1552
+ const majorTriad: Progression;
1553
+ const minorTriad: Progression;
1554
+ const diminished: Progression;
1555
+ const wholeTone: Progression;
1556
+ /**
1557
+ * Determine the frequency of a given note in a given progressions
1558
+ *
1559
+ * @param root The root frequency of the progression
1560
+ * @param progression The Progression to use
1561
+ * @param offset The offset (interval) of the note to generate
1562
+ * @return The frequency of the note requested in Hz.
1563
+ */
1564
+ function calculateFrequencyFromProgression(root: number, progression: Progression, offset: number): number;
1565
+ }
1566
+ /**
1567
+ * Adapted from lancaster-university/codal-microbit-v2
1568
+ * https://github.com/lancaster-university/codal-microbit-v2/blob/master/source/SoundEmojiSynthesizer.cpp
1569
+ */
1570
+ declare namespace pxsim.codal.music {
1571
+ const EMOJI_SYNTHESIZER_SAMPLE_RATE = 44100;
1572
+ const EMOJI_SYNTHESIZER_TONE_WIDTH_F = 1024;
1573
+ const EMOJI_SYNTHESIZER_TONE_WIDTH = 1024;
1574
+ const EMOJI_SYNTHESIZER_BUFFER_SIZE = 512;
1575
+ const EMOJI_SYNTHESIZER_TONE_EFFECT_PARAMETERS = 2;
1576
+ const EMOJI_SYNTHESIZER_TONE_EFFECTS = 3;
1577
+ const EMOJI_SYNTHESIZER_STATUS_ACTIVE = 1;
1578
+ const EMOJI_SYNTHESIZER_STATUS_OUTPUT_SILENCE_AS_EMPTY = 2;
1579
+ const EMOJI_SYNTHESIZER_STATUS_STOPPING = 4;
1580
+ class SoundEmojiSynthesizer {
1581
+ bufferSize: number;
1582
+ buffer: number[];
1583
+ sampleRate: number;
1584
+ sampleRange: number;
1585
+ samplesPerStep: number[];
1586
+ samplesToWrite: number;
1587
+ samplesWritten: number;
1588
+ orMask: number;
1589
+ frequency: number;
1590
+ volume: number;
1591
+ position: number;
1592
+ status: number;
1593
+ effectPointer: number;
1594
+ effectBuffer: SoundEffect[];
1595
+ get effect(): SoundEffect;
1596
+ constructor(id: number, sampleRate?: number);
1597
+ play(sound: SoundEffect[]): void;
1598
+ nextSoundEffect(): boolean;
1599
+ pull(): number[];
1600
+ determineSampleCount(playoutTime: number): number;
1601
+ totalDuration(): number;
1602
+ }
1603
+ }
1604
+ /**
1605
+ * Adapted from lancaster-university/codal-core
1606
+ * https://github.com/lancaster-university/codal-core/blob/master/source/streams/Synthesizer.cpp#L54
1607
+ */
1608
+ declare namespace pxsim.codal.music.Synthesizer {
1609
+ function SineTone(arg: number[], position: number): number;
1610
+ function SawtoothTone(arg: number[], position: number): number;
1611
+ function TriangleTone(arg: number[], position: number): number;
1612
+ function NoiseTone(arg: number[], position: number): number;
1613
+ function SquareWaveTone(arg: number[], position: number): 0 | 1023;
1614
+ }
1615
+ /**
1616
+ * Adapted from lancaster-university/codal-microbit-v2
1617
+ * https://github.com/lancaster-university/codal-microbit-v2/blob/master/source/SoundSynthesizerEffects.cpp
1618
+ */
1619
+ declare namespace pxsim.codal.music.SoundSynthesizerEffects {
1620
+ /**
1621
+ * Root Frequency Interpolation Effect Functions
1622
+ */
1623
+ function noInterpolation(synth: SoundEmojiSynthesizer, context: ToneEffect): void;
1624
+ function linearInterpolation(synth: SoundEmojiSynthesizer, context: ToneEffect): void;
1625
+ function logarithmicInterpolation(synth: SoundEmojiSynthesizer, context: ToneEffect): void;
1626
+ function curveInterpolation(synth: SoundEmojiSynthesizer, context: ToneEffect): void;
1627
+ function slowVibratoInterpolation(synth: SoundEmojiSynthesizer, context: ToneEffect): void;
1628
+ function warbleInterpolation(synth: SoundEmojiSynthesizer, context: ToneEffect): void;
1629
+ function vibratoInterpolation(synth: SoundEmojiSynthesizer, context: ToneEffect): void;
1630
+ function exponentialRisingInterpolation(synth: SoundEmojiSynthesizer, context: ToneEffect): void;
1631
+ function exponentialFallingInterpolation(synth: SoundEmojiSynthesizer, context: ToneEffect): void;
1632
+ function appregrioAscending(synth: SoundEmojiSynthesizer, context: ToneEffect): void;
1633
+ function appregrioDescending(synth: SoundEmojiSynthesizer, context: ToneEffect): void;
1634
+ /**
1635
+ * Frequency Delta effects
1636
+ */
1637
+ function frequencyVibratoEffect(synth: SoundEmojiSynthesizer, context: ToneEffect): void;
1638
+ function volumeVibratoEffect(synth: SoundEmojiSynthesizer, context: ToneEffect): void;
1639
+ /**
1640
+ * Volume Delta effects
1641
+ */
1642
+ /** Simple ADSR enveleope effect.
1643
+ * parameter[0]: Centre volume
1644
+ * parameter[1]: End volume
1645
+ * effect.volume: start volume
1646
+ */
1647
+ function adsrVolumeEffect(synth: SoundEmojiSynthesizer, context: ToneEffect): void;
1648
+ /**
1649
+ * Simple volume ramp effect
1650
+ * parameter[0]: End volume
1651
+ * effect.volume: start volume
1652
+ */
1653
+ function volumeRampEffect(synth: SoundEmojiSynthesizer, context: ToneEffect): void;
1654
+ }
1655
+ declare namespace pxsim.codal.music {
1656
+ enum WaveShape {
1657
+ Sine = 0,
1658
+ Sawtooth = 1,
1659
+ Triangle = 2,
1660
+ Square = 3,
1661
+ Noise = 4
1662
+ }
1663
+ enum InterpolationEffect {
1664
+ None = 0,
1665
+ Linear = 1,
1666
+ Curve = 2,
1667
+ ExponentialRising = 5,
1668
+ ExponentialFalling = 6,
1669
+ ArpeggioRisingMajor = 8,
1670
+ ArpeggioRisingMinor = 10,
1671
+ ArpeggioRisingDiminished = 12,
1672
+ ArpeggioRisingChromatic = 14,
1673
+ ArpeggioRisingWholeTone = 16,
1674
+ ArpeggioFallingMajor = 9,
1675
+ ArpeggioFallingMinor = 11,
1676
+ ArpeggioFallingDiminished = 13,
1677
+ ArpeggioFallingChromatic = 15,
1678
+ ArpeggioFallingWholeTone = 17,
1679
+ Logarithmic = 18
1680
+ }
1681
+ enum Effect {
1682
+ None = 0,
1683
+ Vibrato = 1,
1684
+ Tremolo = 2,
1685
+ Warble = 3
1686
+ }
1687
+ class Sound {
1688
+ src: string;
1689
+ constructor();
1690
+ get wave(): WaveShape;
1691
+ set wave(value: WaveShape);
1692
+ get volume(): number;
1693
+ set volume(value: number);
1694
+ get frequency(): number;
1695
+ set frequency(value: number);
1696
+ get duration(): number;
1697
+ set duration(value: number);
1698
+ get shape(): InterpolationEffect;
1699
+ set shape(value: InterpolationEffect);
1700
+ get endFrequency(): number;
1701
+ set endFrequency(value: number);
1702
+ get endVolume(): number;
1703
+ set endVolume(value: number);
1704
+ get steps(): number;
1705
+ set steps(value: number);
1706
+ get fx(): Effect;
1707
+ set fx(value: Effect);
1708
+ get fxParam(): number;
1709
+ set fxParam(value: number);
1710
+ get fxnSteps(): number;
1711
+ set fxnSteps(value: number);
1712
+ get frequencyRandomness(): number;
1713
+ set frequencyRandomness(value: number);
1714
+ get endFrequencyRandomness(): number;
1715
+ set endFrequencyRandomness(value: number);
1716
+ get volumeRandomness(): number;
1717
+ set volumeRandomness(value: number);
1718
+ get endVolumeRandomness(): number;
1719
+ set endVolumeRandomness(value: number);
1720
+ get durationRandomness(): number;
1721
+ set durationRandomness(value: number);
1722
+ get fxParamRandomness(): number;
1723
+ set fxParamRandomness(value: number);
1724
+ get fxnStepsRandomness(): number;
1725
+ set fxnStepsRandomness(value: number);
1726
+ copy(): Sound;
1727
+ protected setValue(offset: number, value: number, length: number): void;
1728
+ protected getValue(offset: number, length: number): number;
1729
+ }
1730
+ function __playSoundExpression(notes: string, waitTillDone: boolean): void;
1731
+ function playSoundExpressionAsync(notes: string, isCancelled?: () => boolean, onPull?: (freq: number, volume: number) => void): Promise<void>;
1732
+ function __stopSoundExpressions(): void;
1733
+ interface TonePrint {
1734
+ tonePrint: (arg: number[], position: number) => number;
1735
+ parameter: number[];
1736
+ }
1737
+ interface ToneEffect {
1738
+ effect: (synth: SoundEmojiSynthesizer, context: ToneEffect) => void;
1739
+ step: number;
1740
+ steps: number;
1741
+ parameter: number[];
1742
+ parameter_p: Progression[];
1743
+ }
1744
+ interface SoundEffect {
1745
+ frequency: number;
1746
+ volume: number;
1747
+ duration: number;
1748
+ tone: TonePrint;
1749
+ effects: ToneEffect[];
1750
+ }
1751
+ function parseSoundExpression(soundChars: string, fx: SoundEffect): boolean;
1752
+ }
1531
1753
  declare namespace pxsim {
1532
1754
  class Button {
1533
1755
  id: number;