pxt-core 12.2.25 → 12.2.27
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/built/backendutils.js +1 -1
- package/built/cli.js +2 -1
- package/built/pxt.js +297 -12
- package/built/pxtlib.js +2 -1
- package/built/pxtsim.d.ts +11 -0
- package/built/pxtsim.js +293 -10
- package/built/target.js +1 -1
- package/built/targetlight.js +1 -1
- package/built/tests/blocksrunner.js +49 -5
- package/built/tests/blockssetup.js +49 -5
- package/built/web/blockly.css +1 -1
- package/built/web/main.js +2 -2
- package/built/web/pxtapp.js +1 -1
- package/built/web/pxtasseteditor.js +2 -2
- package/built/web/pxtembed.js +1 -1
- package/built/web/pxtlib.js +1 -1
- package/built/web/pxtsim.js +1 -1
- package/built/web/pxtworker.js +1 -1
- package/built/web/rtlblockly.css +1 -1
- package/built/web/rtlsemantic.css +1 -1
- package/built/web/runnerembed.js +1 -1
- package/built/web/semantic.css +1 -1
- package/built/web/skillmap/js/{main.9134fb4e.js → main.5472c093.js} +2 -2
- package/built/web/teachertool/css/main.a4357c60.css +1 -0
- package/localtypings/pxteditor.d.ts +1 -0
- package/package.json +1 -1
- package/react-common/components/share/ShareInfo.tsx +1 -1
- package/theme/blockly-core.less +2 -2
- package/theme/debugger.less +5 -1
- package/theme/fieldeditors.less +4 -0
- package/webapp/public/blockly/media/1x1.gif +0 -0
- package/webapp/public/blockly/media/click.mp3 +0 -0
- package/webapp/public/blockly/media/click.ogg +0 -0
- package/webapp/public/blockly/media/click.wav +0 -0
- package/webapp/public/blockly/media/delete.mp3 +0 -0
- package/webapp/public/blockly/media/delete.ogg +0 -0
- package/webapp/public/blockly/media/delete.wav +0 -0
- package/webapp/public/blockly/media/disconnect.mp3 +0 -0
- package/webapp/public/blockly/media/disconnect.ogg +0 -0
- package/webapp/public/blockly/media/disconnect.wav +0 -0
- package/webapp/public/blockly/media/handclosed.cur +0 -0
- package/webapp/public/blockly/media/handdelete.cur +0 -0
- package/webapp/public/blockly/media/handopen.cur +0 -0
- package/webapp/public/blockly/media/pilcrow.png +0 -0
- package/webapp/public/blockly/media/quote0.png +0 -0
- package/webapp/public/blockly/media/quote1.png +0 -0
- package/webapp/public/blockly/media/sprites.png +0 -0
- package/webapp/public/skillmap.html +1 -1
- package/webapp/public/teachertool.html +1 -1
- package/built/web/teachertool/css/main.a240bbae.css +0 -1
package/built/backendutils.js
CHANGED
|
@@ -1071,7 +1071,7 @@ ${opts.repo.name.replace(/^pxt-/, '')}=github:${opts.repo.fullName}#${opts.repo.
|
|
|
1071
1071
|
}
|
|
1072
1072
|
return r;
|
|
1073
1073
|
}
|
|
1074
|
-
html = html.replace(/<h(\d)[^>]
|
|
1074
|
+
html = html.replace(/<h(\d)[^>]*>\s*([~@])?\s*(.*?)<\/h\d>/g, (full, lvl, tp, body) => {
|
|
1075
1075
|
let m = /^(\w+)\s+(.*)/.exec(body);
|
|
1076
1076
|
let cmd = m ? m[1] : body;
|
|
1077
1077
|
let args = m ? m[2] : "";
|
package/built/cli.js
CHANGED
|
@@ -36,11 +36,12 @@ pxt.docs.requireDOMSanitizer = () => {
|
|
|
36
36
|
const sanitizeHtml = require("sanitize-html");
|
|
37
37
|
const defaults = sanitizeHtml.defaults || {};
|
|
38
38
|
const baseAllowedAttrs = defaults.allowedAttributes || {};
|
|
39
|
+
const allowedTags = defaults.allowedTags || [];
|
|
39
40
|
const mergeClassAttribute = (tag, ...otherAttributes) => {
|
|
40
41
|
const existing = baseAllowedAttrs[tag] || [];
|
|
41
42
|
return Array.from(new Set([...existing, "class", ...otherAttributes]));
|
|
42
43
|
};
|
|
43
|
-
const options = Object.assign(Object.assign({}, defaults), { allowedAttributes: Object.assign(Object.assign({}, baseAllowedAttrs), { code: mergeClassAttribute("code"), pre: mergeClassAttribute("pre"), div: mergeClassAttribute("div", "data-youtube", "title") }) });
|
|
44
|
+
const options = Object.assign(Object.assign({}, defaults), { allowedTags: [...allowedTags, "img"], allowedAttributes: Object.assign(Object.assign({}, baseAllowedAttrs), { code: mergeClassAttribute("code"), pre: mergeClassAttribute("pre"), div: mergeClassAttribute("div", "data-youtube", "title") }) });
|
|
44
45
|
return (html) => sanitizeHtml(html, options);
|
|
45
46
|
};
|
|
46
47
|
let forceCloudBuild = process.env["KS_FORCE_CLOUD"] !== "no";
|
package/built/pxt.js
CHANGED
|
@@ -107281,7 +107281,7 @@ ${opts.repo.name.replace(/^pxt-/, '')}=github:${opts.repo.fullName}#${opts.repo.
|
|
|
107281
107281
|
}
|
|
107282
107282
|
return r;
|
|
107283
107283
|
}
|
|
107284
|
-
html = html.replace(/<h(\d)[^>]
|
|
107284
|
+
html = html.replace(/<h(\d)[^>]*>\s*([~@])?\s*(.*?)<\/h\d>/g, (full, lvl, tp, body) => {
|
|
107285
107285
|
let m = /^(\w+)\s+(.*)/.exec(body);
|
|
107286
107286
|
let cmd = m ? m[1] : body;
|
|
107287
107287
|
let args = m ? m[2] : "";
|
|
@@ -119272,6 +119272,7 @@ var pxt;
|
|
|
119272
119272
|
}
|
|
119273
119273
|
if (entry.tilemapTile) {
|
|
119274
119274
|
tags.push("tile");
|
|
119275
|
+
tags.push("category-" + namespaceName);
|
|
119275
119276
|
}
|
|
119276
119277
|
}
|
|
119277
119278
|
if (mimeType === pxt.IMAGE_MIME_TYPE) {
|
|
@@ -159070,20 +159071,13 @@ var pxsim;
|
|
|
159070
159071
|
}
|
|
159071
159072
|
async function playInstructionsAsync(instructions, isCancelled, onPull) {
|
|
159072
159073
|
AudioContextManager.soundEventCallback === null || AudioContextManager.soundEventCallback === void 0 ? void 0 : AudioContextManager.soundEventCallback("playinstructions", instructions);
|
|
159073
|
-
|
|
159074
|
-
let channel;
|
|
159074
|
+
const channel = new AudioContextManager.PlayInstructionsSource(context(), destination);
|
|
159075
159075
|
let finished = false;
|
|
159076
159076
|
if (onPull) {
|
|
159077
|
-
channel
|
|
159078
|
-
initOscilloscope(onPull, channel.analyser, () => finished || (isCancelled === null || isCancelled === void 0 ? void 0 : isCancelled()));
|
|
159079
|
-
}
|
|
159080
|
-
else {
|
|
159081
|
-
channel = AudioContextManager.AudioWorkletSource.getAvailableSource();
|
|
159082
|
-
if (!channel) {
|
|
159083
|
-
channel = new AudioContextManager.AudioWorkletSource(context(), destination);
|
|
159084
|
-
}
|
|
159077
|
+
initOscilloscope(onPull, channel.analyser, () => finished || (isCancelled === null || isCancelled === void 0 ? void 0 : isCancelled()) || channel.isDisposed());
|
|
159085
159078
|
}
|
|
159086
159079
|
await channel.playInstructionsAsync(instructions, isCancelled);
|
|
159080
|
+
channel.dispose();
|
|
159087
159081
|
finished = true;
|
|
159088
159082
|
}
|
|
159089
159083
|
AudioContextManager.playInstructionsAsync = playInstructionsAsync;
|
|
@@ -159612,6 +159606,296 @@ var pxsim;
|
|
|
159612
159606
|
})(music = codal.music || (codal.music = {}));
|
|
159613
159607
|
})(codal = pxsim.codal || (pxsim.codal = {}));
|
|
159614
159608
|
})(pxsim || (pxsim = {}));
|
|
159609
|
+
var pxsim;
|
|
159610
|
+
(function (pxsim) {
|
|
159611
|
+
var AudioContextManager;
|
|
159612
|
+
(function (AudioContextManager) {
|
|
159613
|
+
const waveForms = [null, "triangle", "sawtooth", "sine"];
|
|
159614
|
+
let noiseBuffer;
|
|
159615
|
+
let rectNoiseBuffer;
|
|
159616
|
+
let cycleNoiseBuffer = [];
|
|
159617
|
+
let squareBuffer = [];
|
|
159618
|
+
function getNoiseBuffer(context) {
|
|
159619
|
+
if (!noiseBuffer) {
|
|
159620
|
+
const bufferSize = 100000;
|
|
159621
|
+
noiseBuffer = context.createBuffer(1, bufferSize, context.sampleRate);
|
|
159622
|
+
const output = noiseBuffer.getChannelData(0);
|
|
159623
|
+
let x = 0xf01ba80;
|
|
159624
|
+
for (let i = 0; i < bufferSize; i++) {
|
|
159625
|
+
x ^= x << 13;
|
|
159626
|
+
x ^= x >> 17;
|
|
159627
|
+
x ^= x << 5;
|
|
159628
|
+
output[i] = ((x & 1023) / 512.0) - 1.0;
|
|
159629
|
+
}
|
|
159630
|
+
}
|
|
159631
|
+
return noiseBuffer;
|
|
159632
|
+
}
|
|
159633
|
+
function getRectNoiseBuffer(context) {
|
|
159634
|
+
// Create a square wave filtered by a pseudorandom bit sequence.
|
|
159635
|
+
// This uses four samples per cycle to create square-ish waves.
|
|
159636
|
+
// The Web Audio API's frequency scaling may be using linear
|
|
159637
|
+
// interpolation which would turn a two-sample wave into a triangle.
|
|
159638
|
+
if (!rectNoiseBuffer) {
|
|
159639
|
+
const bufferSize = 131072; // must be a multiple of 4
|
|
159640
|
+
rectNoiseBuffer = context.createBuffer(1, bufferSize, context.sampleRate);
|
|
159641
|
+
const output = rectNoiseBuffer.getChannelData(0);
|
|
159642
|
+
let x = 0xf01ba80;
|
|
159643
|
+
for (let i = 0; i < bufferSize; i += 4) {
|
|
159644
|
+
// see https://en.wikipedia.org/wiki/Xorshift
|
|
159645
|
+
x ^= x << 13;
|
|
159646
|
+
x ^= x >> 17;
|
|
159647
|
+
x ^= x << 5;
|
|
159648
|
+
if (x & 0x8000) {
|
|
159649
|
+
output[i] = 1.0;
|
|
159650
|
+
output[i + 1] = 1.0;
|
|
159651
|
+
output[i + 2] = -1.0;
|
|
159652
|
+
output[i + 3] = -1.0;
|
|
159653
|
+
}
|
|
159654
|
+
else {
|
|
159655
|
+
output[i] = 0.0;
|
|
159656
|
+
output[i + 1] = 0.0;
|
|
159657
|
+
output[i + 2] = 0.0;
|
|
159658
|
+
output[i + 3] = 0.0;
|
|
159659
|
+
}
|
|
159660
|
+
}
|
|
159661
|
+
}
|
|
159662
|
+
return rectNoiseBuffer;
|
|
159663
|
+
}
|
|
159664
|
+
function getCycleNoiseBuffer(context, bits) {
|
|
159665
|
+
if (!cycleNoiseBuffer[bits]) {
|
|
159666
|
+
// Buffer size needs to be a multiple of 4x the largest cycle length,
|
|
159667
|
+
// 4*64 in this case.
|
|
159668
|
+
const bufferSize = 1024;
|
|
159669
|
+
const buf = context.createBuffer(1, bufferSize, context.sampleRate);
|
|
159670
|
+
const output = buf.getChannelData(0);
|
|
159671
|
+
// See pxt-common-packages's libs/mixer/melody.cpp for details.
|
|
159672
|
+
// "bits" must be in the range 4..6.
|
|
159673
|
+
const cycle_bits = [0x2df0eb47, 0xc8165a93];
|
|
159674
|
+
const mask_456 = [0xf, 0x1f, 0x3f];
|
|
159675
|
+
for (let i = 0; i < bufferSize; i += 4) {
|
|
159676
|
+
let cycle = i / 4;
|
|
159677
|
+
let is_on;
|
|
159678
|
+
let cycle_mask = mask_456[bits - 4];
|
|
159679
|
+
cycle &= cycle_mask;
|
|
159680
|
+
is_on = (cycle_bits[cycle >> 5] & (1 << (cycle & 0x1f))) != 0;
|
|
159681
|
+
if (is_on) {
|
|
159682
|
+
output[i] = 1.0;
|
|
159683
|
+
output[i + 1] = 1.0;
|
|
159684
|
+
output[i + 2] = -1.0;
|
|
159685
|
+
output[i + 3] = -1.0;
|
|
159686
|
+
}
|
|
159687
|
+
else {
|
|
159688
|
+
output[i] = 0.0;
|
|
159689
|
+
output[i + 1] = 0.0;
|
|
159690
|
+
output[i + 2] = 0.0;
|
|
159691
|
+
output[i + 3] = 0.0;
|
|
159692
|
+
}
|
|
159693
|
+
}
|
|
159694
|
+
cycleNoiseBuffer[bits] = buf;
|
|
159695
|
+
}
|
|
159696
|
+
return cycleNoiseBuffer[bits];
|
|
159697
|
+
}
|
|
159698
|
+
function getSquareBuffer(context, param) {
|
|
159699
|
+
if (!squareBuffer[param]) {
|
|
159700
|
+
const bufferSize = 1024;
|
|
159701
|
+
const buf = context.createBuffer(1, bufferSize, context.sampleRate);
|
|
159702
|
+
const output = buf.getChannelData(0);
|
|
159703
|
+
for (let i = 0; i < bufferSize; i++) {
|
|
159704
|
+
output[i] = i < (param / 100 * bufferSize) ? 1 : -1;
|
|
159705
|
+
}
|
|
159706
|
+
squareBuffer[param] = buf;
|
|
159707
|
+
}
|
|
159708
|
+
return squareBuffer[param];
|
|
159709
|
+
}
|
|
159710
|
+
/*
|
|
159711
|
+
#define SW_TRIANGLE 1
|
|
159712
|
+
#define SW_SAWTOOTH 2
|
|
159713
|
+
#define SW_SINE 3
|
|
159714
|
+
#define SW_TUNEDNOISE 4
|
|
159715
|
+
#define SW_NOISE 5
|
|
159716
|
+
#define SW_SQUARE_10 11
|
|
159717
|
+
#define SW_SQUARE_50 15
|
|
159718
|
+
#define SW_SQUARE_CYCLE_16 16
|
|
159719
|
+
#define SW_SQUARE_CYCLE_32 17
|
|
159720
|
+
#define SW_SQUARE_CYCLE_64 18
|
|
159721
|
+
*/
|
|
159722
|
+
/*
|
|
159723
|
+
struct SoundInstruction {
|
|
159724
|
+
uint8_t soundWave;
|
|
159725
|
+
uint8_t flags;
|
|
159726
|
+
uint16_t frequency;
|
|
159727
|
+
uint16_t duration;
|
|
159728
|
+
uint16_t startVolume;
|
|
159729
|
+
uint16_t endVolume;
|
|
159730
|
+
};
|
|
159731
|
+
*/
|
|
159732
|
+
function getGenerator(context, waveFormIdx, hz) {
|
|
159733
|
+
let form = waveForms[waveFormIdx];
|
|
159734
|
+
if (form) {
|
|
159735
|
+
let src = context.createOscillator();
|
|
159736
|
+
src.type = form;
|
|
159737
|
+
src.frequency.value = hz;
|
|
159738
|
+
return src;
|
|
159739
|
+
}
|
|
159740
|
+
let buffer;
|
|
159741
|
+
if (waveFormIdx == 4)
|
|
159742
|
+
buffer = getRectNoiseBuffer(context);
|
|
159743
|
+
else if (waveFormIdx == 5)
|
|
159744
|
+
buffer = getNoiseBuffer(context);
|
|
159745
|
+
else if (11 <= waveFormIdx && waveFormIdx <= 15)
|
|
159746
|
+
buffer = getSquareBuffer(context, (waveFormIdx - 10) * 10);
|
|
159747
|
+
else if (16 <= waveFormIdx && waveFormIdx <= 18)
|
|
159748
|
+
buffer = getCycleNoiseBuffer(context, (waveFormIdx - 16) + 4);
|
|
159749
|
+
else
|
|
159750
|
+
return null;
|
|
159751
|
+
let node = context.createBufferSource();
|
|
159752
|
+
node.buffer = buffer;
|
|
159753
|
+
node.loop = true;
|
|
159754
|
+
const isFilteredNoise = waveFormIdx == 4 || (16 <= waveFormIdx && waveFormIdx <= 18);
|
|
159755
|
+
if (isFilteredNoise)
|
|
159756
|
+
node.playbackRate.value = hz / (context.sampleRate / 4);
|
|
159757
|
+
else if (waveFormIdx != 5)
|
|
159758
|
+
node.playbackRate.value = hz / (context.sampleRate / 1024);
|
|
159759
|
+
return node;
|
|
159760
|
+
}
|
|
159761
|
+
class PlayInstructionsSource extends AudioContextManager.AudioSource {
|
|
159762
|
+
constructor(context, destination) {
|
|
159763
|
+
super(context, destination);
|
|
159764
|
+
this.context = context;
|
|
159765
|
+
this.destination = destination;
|
|
159766
|
+
this.analyser = context.createAnalyser();
|
|
159767
|
+
this.analyser.fftSize = 2048;
|
|
159768
|
+
this.analyser.connect(this.vca);
|
|
159769
|
+
this.gain = context.createGain();
|
|
159770
|
+
this.gain.connect(this.analyser);
|
|
159771
|
+
}
|
|
159772
|
+
playInstructionsAsync(instructions, isCancelled, onPull) {
|
|
159773
|
+
return new Promise(async (resolve) => {
|
|
159774
|
+
AudioContextManager.soundEventCallback === null || AudioContextManager.soundEventCallback === void 0 ? void 0 : AudioContextManager.soundEventCallback("playinstructions", instructions);
|
|
159775
|
+
let resolved = false;
|
|
159776
|
+
const oscillators = {};
|
|
159777
|
+
const gains = {};
|
|
159778
|
+
let startTime = this.context.currentTime;
|
|
159779
|
+
let currentTime = startTime;
|
|
159780
|
+
let currentWave = 0;
|
|
159781
|
+
let totalDuration = 0;
|
|
159782
|
+
/** Square waves are perceved as much louder than other sounds, so scale it down a bit to make it less jarring **/
|
|
159783
|
+
const scaleVol = (n, isSqWave) => (n / 1024) / 4 * (isSqWave ? .5 : 1);
|
|
159784
|
+
const disconnectNodes = () => {
|
|
159785
|
+
if (resolved)
|
|
159786
|
+
return;
|
|
159787
|
+
resolved = true;
|
|
159788
|
+
for (const wave of Object.keys(oscillators)) {
|
|
159789
|
+
oscillators[wave].stop();
|
|
159790
|
+
oscillators[wave].disconnect();
|
|
159791
|
+
gains[wave].disconnect();
|
|
159792
|
+
}
|
|
159793
|
+
resolve();
|
|
159794
|
+
};
|
|
159795
|
+
for (let i = 0; i < instructions.length; i += 12) {
|
|
159796
|
+
const wave = instructions[i];
|
|
159797
|
+
const startFrequency = readUint16(instructions, i + 2);
|
|
159798
|
+
const duration = readUint16(instructions, i + 4) / 1000;
|
|
159799
|
+
const startVolume = readUint16(instructions, i + 6);
|
|
159800
|
+
const endVolume = readUint16(instructions, i + 8);
|
|
159801
|
+
const endFrequency = readUint16(instructions, i + 10);
|
|
159802
|
+
totalDuration += duration;
|
|
159803
|
+
if (wave === 0) {
|
|
159804
|
+
currentTime += duration;
|
|
159805
|
+
continue;
|
|
159806
|
+
}
|
|
159807
|
+
const isSquareWave = 11 <= wave && wave <= 15;
|
|
159808
|
+
if (!oscillators[wave]) {
|
|
159809
|
+
oscillators[wave] = getGenerator(this.context, wave, startFrequency);
|
|
159810
|
+
gains[wave] = this.context.createGain();
|
|
159811
|
+
gains[wave].gain.value = 0;
|
|
159812
|
+
gains[wave].connect(this.gain);
|
|
159813
|
+
oscillators[wave].connect(gains[wave]);
|
|
159814
|
+
oscillators[wave].start();
|
|
159815
|
+
}
|
|
159816
|
+
if (currentWave && wave !== currentWave) {
|
|
159817
|
+
gains[currentWave].gain.setTargetAtTime(0, currentTime, 0.015);
|
|
159818
|
+
}
|
|
159819
|
+
const osc = oscillators[wave];
|
|
159820
|
+
const gain = gains[wave];
|
|
159821
|
+
if (osc instanceof OscillatorNode) {
|
|
159822
|
+
osc.frequency.setValueAtTime(startFrequency, currentTime);
|
|
159823
|
+
osc.frequency.linearRampToValueAtTime(endFrequency, currentTime + duration);
|
|
159824
|
+
}
|
|
159825
|
+
else {
|
|
159826
|
+
const isFilteredNoise = wave == 4 || (16 <= wave && wave <= 18);
|
|
159827
|
+
if (isFilteredNoise)
|
|
159828
|
+
osc.playbackRate.linearRampToValueAtTime(endFrequency / (this.context.sampleRate / 4), currentTime + duration);
|
|
159829
|
+
else if (wave != 5)
|
|
159830
|
+
osc.playbackRate.linearRampToValueAtTime(endFrequency / (this.context.sampleRate / 1024), currentTime + duration);
|
|
159831
|
+
}
|
|
159832
|
+
gain.gain.setValueAtTime(scaleVol(startVolume, isSquareWave), currentTime);
|
|
159833
|
+
gain.gain.linearRampToValueAtTime(scaleVol(endVolume, isSquareWave), currentTime + duration);
|
|
159834
|
+
currentWave = wave;
|
|
159835
|
+
currentTime += duration;
|
|
159836
|
+
}
|
|
159837
|
+
this.gain.gain.setTargetAtTime(0, currentTime, 0.015);
|
|
159838
|
+
if (isCancelled || onPull) {
|
|
159839
|
+
const handleAnimationFrame = () => {
|
|
159840
|
+
const time = this.context.currentTime;
|
|
159841
|
+
if (time > startTime + totalDuration) {
|
|
159842
|
+
return;
|
|
159843
|
+
}
|
|
159844
|
+
if ((isCancelled && isCancelled()) || this.isDisposed()) {
|
|
159845
|
+
disconnectNodes();
|
|
159846
|
+
return;
|
|
159847
|
+
}
|
|
159848
|
+
const { frequency, volume } = findFrequencyAndVolumeAtTime((time - startTime) * 1000, instructions);
|
|
159849
|
+
if (onPull)
|
|
159850
|
+
onPull(frequency, volume / 1024);
|
|
159851
|
+
requestAnimationFrame(handleAnimationFrame);
|
|
159852
|
+
};
|
|
159853
|
+
requestAnimationFrame(handleAnimationFrame);
|
|
159854
|
+
}
|
|
159855
|
+
await pxsim.U.delay(totalDuration * 1000);
|
|
159856
|
+
disconnectNodes();
|
|
159857
|
+
});
|
|
159858
|
+
}
|
|
159859
|
+
dispose() {
|
|
159860
|
+
if (this.isDisposed())
|
|
159861
|
+
return;
|
|
159862
|
+
super.dispose();
|
|
159863
|
+
this.analyser.disconnect();
|
|
159864
|
+
this.gain.disconnect();
|
|
159865
|
+
}
|
|
159866
|
+
}
|
|
159867
|
+
AudioContextManager.PlayInstructionsSource = PlayInstructionsSource;
|
|
159868
|
+
function readUint16(buf, offset) {
|
|
159869
|
+
const temp = new Uint8Array(2);
|
|
159870
|
+
temp[0] = buf[offset];
|
|
159871
|
+
temp[1] = buf[offset + 1];
|
|
159872
|
+
return new Uint16Array(temp.buffer)[0];
|
|
159873
|
+
}
|
|
159874
|
+
function findFrequencyAndVolumeAtTime(millis, instructions) {
|
|
159875
|
+
let currentTime = 0;
|
|
159876
|
+
for (let i = 0; i < instructions.length; i += 12) {
|
|
159877
|
+
const startFrequency = readUint16(instructions, i + 2);
|
|
159878
|
+
const duration = readUint16(instructions, i + 4);
|
|
159879
|
+
const startVolume = readUint16(instructions, i + 6);
|
|
159880
|
+
const endVolume = readUint16(instructions, i + 8);
|
|
159881
|
+
const endFrequency = readUint16(instructions, i + 10);
|
|
159882
|
+
if (currentTime + duration < millis) {
|
|
159883
|
+
currentTime += duration;
|
|
159884
|
+
continue;
|
|
159885
|
+
}
|
|
159886
|
+
const offset = (millis - currentTime) / duration;
|
|
159887
|
+
return {
|
|
159888
|
+
frequency: startFrequency + (endFrequency - startFrequency) * offset,
|
|
159889
|
+
volume: startVolume + (endVolume - startVolume) * offset,
|
|
159890
|
+
};
|
|
159891
|
+
}
|
|
159892
|
+
return {
|
|
159893
|
+
frequency: -1,
|
|
159894
|
+
volume: -1
|
|
159895
|
+
};
|
|
159896
|
+
}
|
|
159897
|
+
})(AudioContextManager = pxsim.AudioContextManager || (pxsim.AudioContextManager = {}));
|
|
159898
|
+
})(pxsim || (pxsim = {}));
|
|
159615
159899
|
/// <reference path="../../localtypings/pxtmusic.d.ts" />
|
|
159616
159900
|
var pxsim;
|
|
159617
159901
|
(function (pxsim) {
|
|
@@ -163226,11 +163510,12 @@ pxt.docs.requireDOMSanitizer = () => {
|
|
|
163226
163510
|
const sanitizeHtml = require("sanitize-html");
|
|
163227
163511
|
const defaults = sanitizeHtml.defaults || {};
|
|
163228
163512
|
const baseAllowedAttrs = defaults.allowedAttributes || {};
|
|
163513
|
+
const allowedTags = defaults.allowedTags || [];
|
|
163229
163514
|
const mergeClassAttribute = (tag, ...otherAttributes) => {
|
|
163230
163515
|
const existing = baseAllowedAttrs[tag] || [];
|
|
163231
163516
|
return Array.from(new Set([...existing, "class", ...otherAttributes]));
|
|
163232
163517
|
};
|
|
163233
|
-
const options = Object.assign(Object.assign({}, defaults), { allowedAttributes: Object.assign(Object.assign({}, baseAllowedAttrs), { code: mergeClassAttribute("code"), pre: mergeClassAttribute("pre"), div: mergeClassAttribute("div", "data-youtube", "title") }) });
|
|
163518
|
+
const options = Object.assign(Object.assign({}, defaults), { allowedTags: [...allowedTags, "img"], allowedAttributes: Object.assign(Object.assign({}, baseAllowedAttrs), { code: mergeClassAttribute("code"), pre: mergeClassAttribute("pre"), div: mergeClassAttribute("div", "data-youtube", "title") }) });
|
|
163234
163519
|
return (html) => sanitizeHtml(html, options);
|
|
163235
163520
|
};
|
|
163236
163521
|
let forceCloudBuild = process.env["KS_FORCE_CLOUD"] !== "no";
|
package/built/pxtlib.js
CHANGED
|
@@ -9560,7 +9560,7 @@ ${opts.repo.name.replace(/^pxt-/, '')}=github:${opts.repo.fullName}#${opts.repo.
|
|
|
9560
9560
|
}
|
|
9561
9561
|
return r;
|
|
9562
9562
|
}
|
|
9563
|
-
html = html.replace(/<h(\d)[^>]
|
|
9563
|
+
html = html.replace(/<h(\d)[^>]*>\s*([~@])?\s*(.*?)<\/h\d>/g, (full, lvl, tp, body) => {
|
|
9564
9564
|
let m = /^(\w+)\s+(.*)/.exec(body);
|
|
9565
9565
|
let cmd = m ? m[1] : body;
|
|
9566
9566
|
let args = m ? m[2] : "";
|
|
@@ -21551,6 +21551,7 @@ var pxt;
|
|
|
21551
21551
|
}
|
|
21552
21552
|
if (entry.tilemapTile) {
|
|
21553
21553
|
tags.push("tile");
|
|
21554
|
+
tags.push("category-" + namespaceName);
|
|
21554
21555
|
}
|
|
21555
21556
|
}
|
|
21556
21557
|
if (mimeType === pxt.IMAGE_MIME_TYPE) {
|
package/built/pxtsim.d.ts
CHANGED
|
@@ -1865,6 +1865,17 @@ declare namespace pxsim.codal.music.MusicalProgressions {
|
|
|
1865
1865
|
*/
|
|
1866
1866
|
function calculateFrequencyFromProgression(root: number, progression: Progression, offset: number): number;
|
|
1867
1867
|
}
|
|
1868
|
+
declare namespace pxsim.AudioContextManager {
|
|
1869
|
+
class PlayInstructionsSource extends AudioSource {
|
|
1870
|
+
context: AudioContext;
|
|
1871
|
+
destination: AudioNode;
|
|
1872
|
+
analyser: AnalyserNode;
|
|
1873
|
+
gain: GainNode;
|
|
1874
|
+
constructor(context: AudioContext, destination: AudioNode);
|
|
1875
|
+
playInstructionsAsync(instructions: Uint8Array, isCancelled?: () => boolean, onPull?: (freq: number, volume: number) => void): Promise<void>;
|
|
1876
|
+
dispose(): void;
|
|
1877
|
+
}
|
|
1878
|
+
}
|
|
1868
1879
|
declare namespace pxsim.music {
|
|
1869
1880
|
type SequencerState = "play" | "loop" | "stop";
|
|
1870
1881
|
type SequencerEvent = "tick" | "play" | "stop" | "loop" | "state-change" | "looped";
|