pxt-core 7.5.22 → 7.5.25
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/pxt.js +69 -59
- package/built/pxtblockly.js +5 -4
- package/built/pxtblocks.js +3 -2
- package/built/pxtcompiler.js +6 -1
- package/built/pxtlib.d.ts +2 -0
- package/built/pxtlib.js +10 -9
- package/built/pxtsim.d.ts +2 -0
- package/built/pxtsim.js +53 -49
- package/built/target.js +1 -1
- package/built/web/main.js +1 -1
- package/built/web/pxtapp.js +1 -1
- package/built/web/pxtblockly.js +2 -2
- package/built/web/pxtblocks.js +1 -1
- package/built/web/pxtcompiler.js +1 -1
- package/built/web/pxtembed.js +2 -2
- package/built/web/pxtlib.js +1 -1
- package/built/web/pxtsim.js +1 -1
- package/built/web/pxtworker.js +1 -1
- package/docfiles/{domains.html → domains-template.html} +0 -0
- package/package.json +2 -2
- package/react-common/components/controls/DraggableGraph.tsx +4 -4
- package/webapp/public/blockly/blockly_compressed.js +2 -2
- package/webapp/public/run.html +5 -0
package/built/pxt.js
CHANGED
|
@@ -114473,11 +114473,10 @@ var pxt;
|
|
|
114473
114473
|
(function (pxt) {
|
|
114474
114474
|
var assets;
|
|
114475
114475
|
(function (assets) {
|
|
114476
|
+
assets.MAX_FREQUENCY = 5000;
|
|
114477
|
+
assets.MAX_VOLUME = 255;
|
|
114476
114478
|
function renderSoundPath(sound, width, height) {
|
|
114477
114479
|
const { startFrequency, endFrequency, startVolume, endVolume, wave, interpolation } = sound;
|
|
114478
|
-
const scale = (start, end, percent) => {
|
|
114479
|
-
return Math.pow(start, 1 - percent) * Math.pow(end, percent);
|
|
114480
|
-
};
|
|
114481
114480
|
// To make the graph appear consistent with the implementation, use a seeded random for the noise waveform.
|
|
114482
114481
|
// The numbers are still nonsense but at least this reflects that it's deterministic.
|
|
114483
114482
|
const random = new SeededRandom(startFrequency + endFrequency + 1);
|
|
@@ -114494,11 +114493,13 @@ var pxt;
|
|
|
114494
114493
|
break;
|
|
114495
114494
|
}
|
|
114496
114495
|
if (wave === "noise") {
|
|
114497
|
-
getFrequencyAt = () => random.randomRange(500,
|
|
114496
|
+
getFrequencyAt = () => random.randomRange(500, 5000);
|
|
114498
114497
|
}
|
|
114499
|
-
const getVolumeAt = (x) => ((endVolume - startVolume) / width) * x + startVolume;
|
|
114500
|
-
const
|
|
114501
|
-
const
|
|
114498
|
+
const getVolumeAt = (x) => Math.max(Math.min(((endVolume - startVolume) / width) * x + startVolume, assets.MAX_VOLUME), 0);
|
|
114499
|
+
const minWaveWidth = 10;
|
|
114500
|
+
const maxWaveWidth = width / 2;
|
|
114501
|
+
const volumeToAmplitude = (volume) => (volume / assets.MAX_VOLUME) * (height - 2) / 2;
|
|
114502
|
+
const frequencyToWidth = (frequency) => (1 - frequency / assets.MAX_FREQUENCY) * (maxWaveWidth - minWaveWidth) + minWaveWidth;
|
|
114502
114503
|
const parts = [`M ${2} ${height / 2}`];
|
|
114503
114504
|
let currentX = 0;
|
|
114504
114505
|
while (currentX < width) {
|
|
@@ -114515,8 +114516,8 @@ var pxt;
|
|
|
114515
114516
|
// The numbers are still nonsense but at least this reflects that it's deterministic.
|
|
114516
114517
|
const random = new SeededRandom(frequency);
|
|
114517
114518
|
if (wave === "noise")
|
|
114518
|
-
frequency = random.randomRange(500,
|
|
114519
|
-
const amplitude = (volume /
|
|
114519
|
+
frequency = random.randomRange(500, 5000);
|
|
114520
|
+
const amplitude = (volume / assets.MAX_VOLUME) * (height - 2) / 2;
|
|
114520
114521
|
const waveHalfWidth = (width / (frequency * timeBase / 1000)) / 2;
|
|
114521
114522
|
let numSegments = Math.ceil(width / (waveHalfWidth * 2));
|
|
114522
114523
|
if (numSegments % 2 === 1)
|
|
@@ -126870,7 +126871,12 @@ ${output}</xml>`;
|
|
|
126870
126871
|
if (optionalCount) {
|
|
126871
126872
|
if (!r.mutation)
|
|
126872
126873
|
r.mutation = {};
|
|
126873
|
-
|
|
126874
|
+
if (attributes.compileHiddenArguments) {
|
|
126875
|
+
r.mutation["_expanded"] = "0";
|
|
126876
|
+
}
|
|
126877
|
+
else {
|
|
126878
|
+
r.mutation["_expanded"] = optionalCount.toString();
|
|
126879
|
+
}
|
|
126874
126880
|
}
|
|
126875
126881
|
return r;
|
|
126876
126882
|
}
|
|
@@ -152889,62 +152895,64 @@ var pxsim;
|
|
|
152889
152895
|
const single = !!((_a = this._currentRuntime) === null || _a === void 0 ? void 0 : _a.single);
|
|
152890
152896
|
const parentWindow = window.parent && window.parent !== window.window
|
|
152891
152897
|
? window.parent : window.opener;
|
|
152892
|
-
if (
|
|
152898
|
+
if (parentWindow) {
|
|
152893
152899
|
// if message comes from parent already, don't echo
|
|
152894
152900
|
if (source !== parentWindow) {
|
|
152895
152901
|
const parentOrigin = this.options.parentOrigin || window.location.origin;
|
|
152896
152902
|
parentWindow.postMessage(msg, parentOrigin);
|
|
152897
152903
|
}
|
|
152898
|
-
// send message to other editors
|
|
152899
152904
|
}
|
|
152900
|
-
|
|
152901
|
-
|
|
152902
|
-
|
|
152903
|
-
|
|
152904
|
-
|
|
152905
|
-
|
|
152906
|
-
|
|
152907
|
-
|
|
152908
|
-
|
|
152909
|
-
|
|
152910
|
-
|
|
152911
|
-
|
|
152912
|
-
|
|
152913
|
-
|
|
152914
|
-
|
|
152915
|
-
//
|
|
152916
|
-
|
|
152917
|
-
|
|
152918
|
-
|
|
152919
|
-
|
|
152920
|
-
|
|
152921
|
-
.
|
|
152922
|
-
|
|
152923
|
-
|
|
152924
|
-
|
|
152925
|
-
|
|
152926
|
-
|
|
152927
|
-
|
|
152928
|
-
|
|
152929
|
-
|
|
152930
|
-
|
|
152931
|
-
|
|
152932
|
-
|
|
152933
|
-
|
|
152934
|
-
|
|
152935
|
-
|
|
152936
|
-
|
|
152937
|
-
|
|
152938
|
-
|
|
152939
|
-
// start secondary frame if needed
|
|
152940
|
-
const mkcdFrames = frames.filter(frame => !frame.dataset[FRAME_DATA_MESSAGE_CHANNEL]);
|
|
152941
|
-
if (mkcdFrames.length < 2) {
|
|
152942
|
-
this.container.appendChild(this.createFrame());
|
|
152943
|
-
frames = this.simFrames();
|
|
152944
|
-
// there might be an old frame
|
|
152905
|
+
if (!this.options.nestedEditorSim && !(broadcastmsg === null || broadcastmsg === void 0 ? void 0 : broadcastmsg.toParentIFrameOnly)) {
|
|
152906
|
+
// send message to other editors
|
|
152907
|
+
if (depEditors) {
|
|
152908
|
+
depEditors.forEach(w => {
|
|
152909
|
+
if (source !== w)
|
|
152910
|
+
// dependant editors should be in the same origin
|
|
152911
|
+
w.postMessage(msg, window.location.origin);
|
|
152912
|
+
});
|
|
152913
|
+
// start second simulator
|
|
152914
|
+
}
|
|
152915
|
+
else if (!single) {
|
|
152916
|
+
const messageChannel = msg.type === "messagepacket" && msg.channel;
|
|
152917
|
+
const messageSimulator = messageChannel &&
|
|
152918
|
+
this.options.messageSimulators &&
|
|
152919
|
+
this.options.messageSimulators[messageChannel];
|
|
152920
|
+
// should we start an extension editor?
|
|
152921
|
+
if (messageSimulator) {
|
|
152922
|
+
// find a frame already running that simulator
|
|
152923
|
+
let messageFrame = frames.find(frame => frame.dataset[FRAME_DATA_MESSAGE_CHANNEL] === messageChannel);
|
|
152924
|
+
// not found, spin a new one
|
|
152925
|
+
if (!messageFrame) {
|
|
152926
|
+
const useLocalHost = pxsim.U.isLocalHost() && /localhostmessagesims=1/i.test(window.location.href);
|
|
152927
|
+
const url = ((useLocalHost && messageSimulator.localHostUrl) || messageSimulator.url)
|
|
152928
|
+
.replace("$PARENT_ORIGIN$", encodeURIComponent(this.options.parentOrigin || ""));
|
|
152929
|
+
let wrapper = this.createFrame(url);
|
|
152930
|
+
this.container.appendChild(wrapper);
|
|
152931
|
+
messageFrame = wrapper.firstElementChild;
|
|
152932
|
+
messageFrame.dataset[FRAME_DATA_MESSAGE_CHANNEL] = messageChannel;
|
|
152933
|
+
pxsim.U.addClass(wrapper, "simmsg");
|
|
152934
|
+
pxsim.U.addClass(wrapper, "simmsg" + messageChannel);
|
|
152935
|
+
if (messageSimulator.permanent)
|
|
152936
|
+
messageFrame.dataset[PERMANENT] = "true";
|
|
152937
|
+
this.startFrame(messageFrame);
|
|
152938
|
+
frames = this.simFrames(); // refresh
|
|
152939
|
+
}
|
|
152940
|
+
// not running the curren run, restart
|
|
152941
|
+
else if (messageFrame.dataset['runid'] != this.runId) {
|
|
152942
|
+
this.startFrame(messageFrame);
|
|
152943
|
+
}
|
|
152945
152944
|
}
|
|
152946
|
-
else
|
|
152947
|
-
|
|
152945
|
+
else {
|
|
152946
|
+
// start secondary frame if needed
|
|
152947
|
+
const mkcdFrames = frames.filter(frame => !frame.dataset[FRAME_DATA_MESSAGE_CHANNEL]);
|
|
152948
|
+
if (mkcdFrames.length < 2) {
|
|
152949
|
+
this.container.appendChild(this.createFrame());
|
|
152950
|
+
frames = this.simFrames();
|
|
152951
|
+
// there might be an old frame
|
|
152952
|
+
}
|
|
152953
|
+
else if (mkcdFrames[1].dataset['runid'] != this.runId) {
|
|
152954
|
+
this.startFrame(mkcdFrames[1]);
|
|
152955
|
+
}
|
|
152948
152956
|
}
|
|
152949
152957
|
}
|
|
152950
152958
|
}
|
|
@@ -153224,12 +153232,14 @@ var pxsim;
|
|
|
153224
153232
|
}
|
|
153225
153233
|
// ensure _currentRuntime is ready
|
|
153226
153234
|
startFrame(frame) {
|
|
153235
|
+
var _a, _b;
|
|
153227
153236
|
if (!this._currentRuntime || !frame.contentWindow)
|
|
153228
153237
|
return false;
|
|
153229
153238
|
const msg = JSON.parse(JSON.stringify(this._currentRuntime));
|
|
153230
153239
|
msg.frameCounter = ++this.frameCounter;
|
|
153231
153240
|
msg.options = {
|
|
153232
153241
|
theme: this.themes[this.nextFrameId++ % this.themes.length],
|
|
153242
|
+
mpRole: (_b = (_a = /[\&\?]mp=(server|client)/i.exec(window.location.href)) === null || _a === void 0 ? void 0 : _a[1]) === null || _b === void 0 ? void 0 : _b.toLowerCase()
|
|
153233
153243
|
};
|
|
153234
153244
|
msg.id = `${msg.options.theme}-${this.nextId()}`;
|
|
153235
153245
|
frame.dataset['runid'] = this.runId;
|
package/built/pxtblockly.js
CHANGED
|
@@ -674,7 +674,7 @@ Blockly.Field.prototype.markDirty=function(){this.isDirty_=!0;this.constants_=nu
|
|
|
674
674
|
Blockly.Field.prototype.setValue=function(a){if(null!==a){var b=this.doClassValidation_(a);a=this.processValidation_(a,b);if(!(a instanceof Error)){if(b=this.getValidator())if(b=b.call(this,a),a=this.processValidation_(a,b),a instanceof Error)return;b=this.sourceBlock_;if(!b||!b.disposed){var c=this.getValue();c===a?this.doValueUpdate_(a):(b&&Blockly.Events.isEnabled()&&Blockly.Events.fire(new (Blockly.Events.get(Blockly.Events.BLOCK_CHANGE))(b,"field",this.name||null,c,a)),this.doValueUpdate_(a),
|
|
675
675
|
this.isDirty_&&this.forceRerender())}}}};Blockly.Field.prototype.processValidation_=function(a,b){if(null===b)return this.doValueInvalid_(a),this.isDirty_&&this.forceRerender(),Error();void 0!==b&&(a=b);return a};Blockly.Field.prototype.getValue=function(){return this.value_};Blockly.Field.prototype.doClassValidation_=function(a){return null===a||void 0===a?null:a};Blockly.Field.prototype.doValueUpdate_=function(a){this.value_=a;this.isDirty_=!0};Blockly.Field.prototype.doValueInvalid_=function(a){};
|
|
676
676
|
Blockly.Field.prototype.onMouseDown_=function(a){this.sourceBlock_&&this.sourceBlock_.workspace&&(a=this.sourceBlock_.workspace.getGesture(a))&&a.setStartField(this)};Blockly.Field.prototype.setTooltip=function(a){a||""===a||(a=this.sourceBlock_);var b=this.getClickTarget_();b?b.tooltip=a:this.tooltip_=a};Blockly.Field.prototype.getTooltip=function(){var a=this.getClickTarget_();return a?Blockly.Tooltip.getTooltipOfObject(a):Blockly.Tooltip.getTooltipOfObject({tooltip:this.tooltip_})};
|
|
677
|
-
Blockly.Field.prototype.getClickTarget_=function(){if(this.clickTarget_)return this.clickTarget_;if(!this.sourceBlock_)return null;for(var a=0,b=0,c=0,d;d=this.sourceBlock_.inputList[c];c++){for(var e=0,f;f=d.fieldRow[e];e++)f instanceof Blockly.FieldLabel||a++;d.connection&&b++}return this.clickTarget_=1>=a&&this.sourceBlock_.outputConnection&&!b?this.sourceBlock_.getSvgRoot():this.getSvgRoot()};
|
|
677
|
+
Blockly.Field.prototype.getClickTarget_=function(){if(this.clickTarget_)return this.clickTarget_;if(!this.sourceBlock_||!this.sourceBlock_.getSvgRoot)return null;for(var a=0,b=0,c=0,d;d=this.sourceBlock_.inputList[c];c++){for(var e=0,f;f=d.fieldRow[e];e++)f instanceof Blockly.FieldLabel||a++;d.connection&&b++}return this.clickTarget_=1>=a&&this.sourceBlock_.outputConnection&&!b?this.sourceBlock_.getSvgRoot():this.getSvgRoot()};
|
|
678
678
|
Blockly.Field.prototype.getTotalFields_=function(a){a=void 0===a?!1:a;for(var b=0,c=0,d;d=this.sourceBlock_.inputList[c];c++)for(var e=0,f;f=d.fieldRow[e];e++)f instanceof Blockly.FieldLabel&&a||b++;return b};Blockly.Field.prototype.getAbsoluteXY_=function(){return Blockly.utils.style.getPageOffset(this.getClickTarget_())};Blockly.Field.prototype.referencesVariables=function(){return!1};
|
|
679
679
|
Blockly.Field.prototype.getParentInput=function(){for(var a=null,b=this.sourceBlock_,c=b.inputList,d=0;d<b.inputList.length;d++)for(var e=c[d],f=e.fieldRow,g=0;g<f.length;g++)if(f[g]===this){a=e;break}return a};Blockly.Field.prototype.getFlipRtl=function(){return!1};Blockly.Field.prototype.isTabNavigable=function(){return!1};Blockly.Field.prototype.onShortcut=function(a){return!1};
|
|
680
680
|
Blockly.Field.prototype.setCursorSvg=function(a){a?(this.fieldGroup_.appendChild(a),this.cursorSvg_=a):this.cursorSvg_=null};Blockly.Field.prototype.setMarkerSvg=function(a){a?(this.fieldGroup_.appendChild(a),this.markerSvg_=a):this.markerSvg_=null};Blockly.Field.prototype.updateMarkers_=function(){var a=this.sourceBlock_.workspace;a.keyboardAccessibilityMode&&this.cursorSvg_&&a.getCursor().draw();a.keyboardAccessibilityMode&&this.markerSvg_&&a.getMarker(Blockly.MarkerManager.LOCAL_MARKER).draw()};Blockly.fieldRegistry={};Blockly.fieldRegistry.register=function(a,b){Blockly.registry.register(Blockly.registry.Type.FIELD,a,b)};Blockly.fieldRegistry.unregister=function(a){Blockly.registry.unregister(Blockly.registry.Type.FIELD,a)};
|
|
@@ -1084,7 +1084,7 @@ return Blockly.Functions.namesInUse(b,null,a)[c]?(Blockly.alert(Blockly.Msg.VARI
|
|
|
1084
1084
|
Blockly.Functions.mutateCallersAndDefinition=function(a,b,c){var d=Blockly.Functions.getDefinition(a,b);d?(a=Blockly.Functions.getCallers(a,d.workspace),a.push(d),Blockly.Events.setGroup(!0),a.forEach(function(a){var b=a.mutationToDom(),e=b&&Blockly.Xml.domToText(b);a.domToMutation(c);var h=a.mutationToDom(),k=h&&Blockly.Xml.domToText(h);if(e!=k)if(Blockly.Events.fire(new Blockly.Events.BlockChange(a,"mutation",null,e,k)),a.id==d.id){var l=Blockly.Functions.getArgMap(b),m=Blockly.Functions.getArgMap(h,
|
|
1085
1085
|
!0);d.getDescendants().forEach(function(a){if(Blockly.pxtBlocklyUtils.isFunctionArgumentReporter(a)){var b=a.getFieldValue("VALUE"),c=l[b];m[c]?m[c]!==b&&a.setFieldValue(m[c],"VALUE"):a.dispose()}})}else setTimeout(function(){a.bumpNeighbours()},Blockly.BUMP_DELAY)}),Blockly.Events.setGroup(!1)):console.warn("Attempted to change function "+a+", but no definition block was found on the workspace")};
|
|
1086
1086
|
Blockly.Functions.createFlyout=function(a,b){var c=new Blockly.Options({scrollbars:!0,disabledPatternId:a.options.disabledPatternId,parentWorkspace:a,rtl:a.RTL,oneBasedIndex:a.options.oneBasedIndex,horizontalLayout:a.horizontalLayout,toolboxPosition:a.options.toolboxPosition,zoomOptions:a.options.zoomOptions,renderer:a.options.renderer,rendererOverrides:a.options.rendererOverrides,newFunctions:a.options.newFunctions,move:{scrollbars:!0}});c=c.horizontalLayout?new Blockly.HorizontalFlyout(c):new Blockly.VerticalFlyout(c);
|
|
1087
|
-
var d=c.createDom("svg");goog.dom.insertSiblingAfter(d,b);c.init(a);return c};Blockly.VERSION="4.0.
|
|
1087
|
+
var d=c.createDom("svg");goog.dom.insertSiblingAfter(d,b);c.init(a);return c};Blockly.VERSION="4.0.10";Blockly.mainWorkspace=null;Blockly.selected=null;Blockly.draggingConnections=[];Blockly.clipboardXml_=null;Blockly.clipboardSource_=null;Blockly.clipboardTypeCounts_=null;Blockly.cache3dSupported_=null;Blockly.parentContainer=null;Blockly.svgSize=function(a){Blockly.utils.deprecation.warn("Blockly.svgSize","March 2021","March 2022","workspace.getCachedParentSvgSize");return new Blockly.utils.Size(a.cachedWidth_,a.cachedHeight_)};Blockly.resizeSvgContents=function(a){a.resizeContents()};
|
|
1088
1088
|
Blockly.svgResize=function(a){for(;a.options.parentWorkspace;)a=a.options.parentWorkspace;var b=a.getParentSvg(),c=a.getCachedParentSvgSize(),d=b.parentNode;if(d){var e=d.offsetWidth;d=d.offsetHeight;c.width!=e&&(b.setAttribute("width",e+"px"),a.setCachedParentSvgSize(e,null));c.height!=d&&(b.setAttribute("height",d+"px"),a.setCachedParentSvgSize(null,d));a.resize()}};
|
|
1089
1089
|
Blockly.onKeyDown=function(a){var b=Blockly.mainWorkspace;if(b&&!(Blockly.utils.isTargetInput(a)||b.rendered&&!b.isVisible()))Blockly.ShortcutRegistry.registry.onKeyDown(b,a)};Blockly.deleteBlock=function(a){a.workspace.isFlyout||(Blockly.Events.setGroup(!0),Blockly.hideChaff(),a.outputConnection?a.dispose(!1,!0):a.dispose(!0,!0),Blockly.Events.setGroup(!1))};Blockly.copy=function(a){if(a=a.toCopyData())Blockly.clipboardXml_=a.xml,Blockly.clipboardSource_=a.source,Blockly.clipboardTypeCounts_=a.typeCounts};
|
|
1090
1090
|
Blockly.paste=function(){if(!Blockly.clipboardXml_)return!1;var a=Blockly.clipboardSource_;a.isFlyout&&(a=a.targetWorkspace);return Blockly.clipboardTypeCounts_&&a.isCapacityAvailable(Blockly.clipboardTypeCounts_)?(Blockly.Events.setGroup(!0),a.paste(Blockly.clipboardXml_),Blockly.Events.setGroup(!1),!0):!1};
|
|
@@ -15246,6 +15246,7 @@ var pxtblockly;
|
|
|
15246
15246
|
.size(TOTAL_WIDTH, TOTAL_HEIGHT)
|
|
15247
15247
|
.setClass("blocklySpriteField")
|
|
15248
15248
|
.stroke("#fff", 1)
|
|
15249
|
+
.fill("#dedede")
|
|
15249
15250
|
.corner(TOTAL_HEIGHT / 2);
|
|
15250
15251
|
const clipPathId = "preview-clip-" + pxt.U.guidGen();
|
|
15251
15252
|
const clip = new svg.ClipPath()
|
|
@@ -15480,8 +15481,8 @@ var pxtblockly;
|
|
|
15480
15481
|
sound = {
|
|
15481
15482
|
duration: 1000,
|
|
15482
15483
|
startFrequency: 100,
|
|
15483
|
-
endFrequency:
|
|
15484
|
-
startVolume:
|
|
15484
|
+
endFrequency: 4800,
|
|
15485
|
+
startVolume: 100,
|
|
15485
15486
|
endVolume: 0,
|
|
15486
15487
|
wave: "sine",
|
|
15487
15488
|
interpolation: "linear",
|
package/built/pxtblocks.js
CHANGED
|
@@ -11684,6 +11684,7 @@ var pxtblockly;
|
|
|
11684
11684
|
.size(TOTAL_WIDTH, TOTAL_HEIGHT)
|
|
11685
11685
|
.setClass("blocklySpriteField")
|
|
11686
11686
|
.stroke("#fff", 1)
|
|
11687
|
+
.fill("#dedede")
|
|
11687
11688
|
.corner(TOTAL_HEIGHT / 2);
|
|
11688
11689
|
const clipPathId = "preview-clip-" + pxt.U.guidGen();
|
|
11689
11690
|
const clip = new svg.ClipPath()
|
|
@@ -11918,8 +11919,8 @@ var pxtblockly;
|
|
|
11918
11919
|
sound = {
|
|
11919
11920
|
duration: 1000,
|
|
11920
11921
|
startFrequency: 100,
|
|
11921
|
-
endFrequency:
|
|
11922
|
-
startVolume:
|
|
11922
|
+
endFrequency: 4800,
|
|
11923
|
+
startVolume: 100,
|
|
11923
11924
|
endVolume: 0,
|
|
11924
11925
|
wave: "sine",
|
|
11925
11926
|
interpolation: "linear",
|
package/built/pxtcompiler.js
CHANGED
|
@@ -5818,7 +5818,12 @@ ${output}</xml>`;
|
|
|
5818
5818
|
if (optionalCount) {
|
|
5819
5819
|
if (!r.mutation)
|
|
5820
5820
|
r.mutation = {};
|
|
5821
|
-
|
|
5821
|
+
if (attributes.compileHiddenArguments) {
|
|
5822
|
+
r.mutation["_expanded"] = "0";
|
|
5823
|
+
}
|
|
5824
|
+
else {
|
|
5825
|
+
r.mutation["_expanded"] = optionalCount.toString();
|
|
5826
|
+
}
|
|
5822
5827
|
}
|
|
5823
5828
|
return r;
|
|
5824
5829
|
}
|
package/built/pxtlib.d.ts
CHANGED
|
@@ -2313,6 +2313,8 @@ declare namespace pxt.assets {
|
|
|
2313
2313
|
endVolume: number;
|
|
2314
2314
|
duration: number;
|
|
2315
2315
|
}
|
|
2316
|
+
const MAX_FREQUENCY = 5000;
|
|
2317
|
+
const MAX_VOLUME = 255;
|
|
2316
2318
|
function renderSoundPath(sound: pxt.assets.Sound, width: number, height: number): string;
|
|
2317
2319
|
function renderWaveSnapshot(frequency: number, volume: number, wave: SoundWaveForm, width: number, height: number, timeBase: number): string;
|
|
2318
2320
|
}
|
package/built/pxtlib.js
CHANGED
|
@@ -16787,11 +16787,10 @@ var pxt;
|
|
|
16787
16787
|
(function (pxt) {
|
|
16788
16788
|
var assets;
|
|
16789
16789
|
(function (assets) {
|
|
16790
|
+
assets.MAX_FREQUENCY = 5000;
|
|
16791
|
+
assets.MAX_VOLUME = 255;
|
|
16790
16792
|
function renderSoundPath(sound, width, height) {
|
|
16791
16793
|
const { startFrequency, endFrequency, startVolume, endVolume, wave, interpolation } = sound;
|
|
16792
|
-
const scale = (start, end, percent) => {
|
|
16793
|
-
return Math.pow(start, 1 - percent) * Math.pow(end, percent);
|
|
16794
|
-
};
|
|
16795
16794
|
// To make the graph appear consistent with the implementation, use a seeded random for the noise waveform.
|
|
16796
16795
|
// The numbers are still nonsense but at least this reflects that it's deterministic.
|
|
16797
16796
|
const random = new SeededRandom(startFrequency + endFrequency + 1);
|
|
@@ -16808,11 +16807,13 @@ var pxt;
|
|
|
16808
16807
|
break;
|
|
16809
16808
|
}
|
|
16810
16809
|
if (wave === "noise") {
|
|
16811
|
-
getFrequencyAt = () => random.randomRange(500,
|
|
16810
|
+
getFrequencyAt = () => random.randomRange(500, 5000);
|
|
16812
16811
|
}
|
|
16813
|
-
const getVolumeAt = (x) => ((endVolume - startVolume) / width) * x + startVolume;
|
|
16814
|
-
const
|
|
16815
|
-
const
|
|
16812
|
+
const getVolumeAt = (x) => Math.max(Math.min(((endVolume - startVolume) / width) * x + startVolume, assets.MAX_VOLUME), 0);
|
|
16813
|
+
const minWaveWidth = 10;
|
|
16814
|
+
const maxWaveWidth = width / 2;
|
|
16815
|
+
const volumeToAmplitude = (volume) => (volume / assets.MAX_VOLUME) * (height - 2) / 2;
|
|
16816
|
+
const frequencyToWidth = (frequency) => (1 - frequency / assets.MAX_FREQUENCY) * (maxWaveWidth - minWaveWidth) + minWaveWidth;
|
|
16816
16817
|
const parts = [`M ${2} ${height / 2}`];
|
|
16817
16818
|
let currentX = 0;
|
|
16818
16819
|
while (currentX < width) {
|
|
@@ -16829,8 +16830,8 @@ var pxt;
|
|
|
16829
16830
|
// The numbers are still nonsense but at least this reflects that it's deterministic.
|
|
16830
16831
|
const random = new SeededRandom(frequency);
|
|
16831
16832
|
if (wave === "noise")
|
|
16832
|
-
frequency = random.randomRange(500,
|
|
16833
|
-
const amplitude = (volume /
|
|
16833
|
+
frequency = random.randomRange(500, 5000);
|
|
16834
|
+
const amplitude = (volume / assets.MAX_VOLUME) * (height - 2) / 2;
|
|
16834
16835
|
const waveHalfWidth = (width / (frequency * timeBase / 1000)) / 2;
|
|
16835
16836
|
let numSegments = Math.ceil(width / (waveHalfWidth * 2));
|
|
16836
16837
|
if (numSegments % 2 === 1)
|
package/built/pxtsim.d.ts
CHANGED
|
@@ -382,6 +382,7 @@ declare namespace pxsim {
|
|
|
382
382
|
}
|
|
383
383
|
interface SimulatorBroadcastMessage extends SimulatorMessage {
|
|
384
384
|
broadcast: boolean;
|
|
385
|
+
toParentIFrameOnly?: boolean;
|
|
385
386
|
}
|
|
386
387
|
interface SimulatorControlMessage extends SimulatorBroadcastMessage {
|
|
387
388
|
type: "messagepacket";
|
|
@@ -1219,6 +1220,7 @@ declare namespace pxsim {
|
|
|
1219
1220
|
invalidatedClass?: string;
|
|
1220
1221
|
nestedEditorSim?: boolean;
|
|
1221
1222
|
parentOrigin?: string;
|
|
1223
|
+
mpRole?: string;
|
|
1222
1224
|
messageSimulators?: pxt.Map<{
|
|
1223
1225
|
url: string;
|
|
1224
1226
|
localHostUrl?: string;
|
package/built/pxtsim.js
CHANGED
|
@@ -6199,62 +6199,64 @@ var pxsim;
|
|
|
6199
6199
|
const single = !!((_a = this._currentRuntime) === null || _a === void 0 ? void 0 : _a.single);
|
|
6200
6200
|
const parentWindow = window.parent && window.parent !== window.window
|
|
6201
6201
|
? window.parent : window.opener;
|
|
6202
|
-
if (
|
|
6202
|
+
if (parentWindow) {
|
|
6203
6203
|
// if message comes from parent already, don't echo
|
|
6204
6204
|
if (source !== parentWindow) {
|
|
6205
6205
|
const parentOrigin = this.options.parentOrigin || window.location.origin;
|
|
6206
6206
|
parentWindow.postMessage(msg, parentOrigin);
|
|
6207
6207
|
}
|
|
6208
|
-
// send message to other editors
|
|
6209
6208
|
}
|
|
6210
|
-
|
|
6211
|
-
|
|
6212
|
-
|
|
6213
|
-
|
|
6214
|
-
|
|
6215
|
-
|
|
6216
|
-
|
|
6217
|
-
|
|
6218
|
-
|
|
6219
|
-
|
|
6220
|
-
|
|
6221
|
-
|
|
6222
|
-
|
|
6223
|
-
|
|
6224
|
-
|
|
6225
|
-
//
|
|
6226
|
-
|
|
6227
|
-
|
|
6228
|
-
|
|
6229
|
-
|
|
6230
|
-
|
|
6231
|
-
.
|
|
6232
|
-
|
|
6233
|
-
|
|
6234
|
-
|
|
6235
|
-
|
|
6236
|
-
|
|
6237
|
-
|
|
6238
|
-
|
|
6239
|
-
|
|
6240
|
-
|
|
6241
|
-
|
|
6242
|
-
|
|
6243
|
-
|
|
6244
|
-
|
|
6245
|
-
|
|
6246
|
-
|
|
6247
|
-
|
|
6248
|
-
|
|
6249
|
-
// start secondary frame if needed
|
|
6250
|
-
const mkcdFrames = frames.filter(frame => !frame.dataset[FRAME_DATA_MESSAGE_CHANNEL]);
|
|
6251
|
-
if (mkcdFrames.length < 2) {
|
|
6252
|
-
this.container.appendChild(this.createFrame());
|
|
6253
|
-
frames = this.simFrames();
|
|
6254
|
-
// there might be an old frame
|
|
6209
|
+
if (!this.options.nestedEditorSim && !(broadcastmsg === null || broadcastmsg === void 0 ? void 0 : broadcastmsg.toParentIFrameOnly)) {
|
|
6210
|
+
// send message to other editors
|
|
6211
|
+
if (depEditors) {
|
|
6212
|
+
depEditors.forEach(w => {
|
|
6213
|
+
if (source !== w)
|
|
6214
|
+
// dependant editors should be in the same origin
|
|
6215
|
+
w.postMessage(msg, window.location.origin);
|
|
6216
|
+
});
|
|
6217
|
+
// start second simulator
|
|
6218
|
+
}
|
|
6219
|
+
else if (!single) {
|
|
6220
|
+
const messageChannel = msg.type === "messagepacket" && msg.channel;
|
|
6221
|
+
const messageSimulator = messageChannel &&
|
|
6222
|
+
this.options.messageSimulators &&
|
|
6223
|
+
this.options.messageSimulators[messageChannel];
|
|
6224
|
+
// should we start an extension editor?
|
|
6225
|
+
if (messageSimulator) {
|
|
6226
|
+
// find a frame already running that simulator
|
|
6227
|
+
let messageFrame = frames.find(frame => frame.dataset[FRAME_DATA_MESSAGE_CHANNEL] === messageChannel);
|
|
6228
|
+
// not found, spin a new one
|
|
6229
|
+
if (!messageFrame) {
|
|
6230
|
+
const useLocalHost = pxsim.U.isLocalHost() && /localhostmessagesims=1/i.test(window.location.href);
|
|
6231
|
+
const url = ((useLocalHost && messageSimulator.localHostUrl) || messageSimulator.url)
|
|
6232
|
+
.replace("$PARENT_ORIGIN$", encodeURIComponent(this.options.parentOrigin || ""));
|
|
6233
|
+
let wrapper = this.createFrame(url);
|
|
6234
|
+
this.container.appendChild(wrapper);
|
|
6235
|
+
messageFrame = wrapper.firstElementChild;
|
|
6236
|
+
messageFrame.dataset[FRAME_DATA_MESSAGE_CHANNEL] = messageChannel;
|
|
6237
|
+
pxsim.U.addClass(wrapper, "simmsg");
|
|
6238
|
+
pxsim.U.addClass(wrapper, "simmsg" + messageChannel);
|
|
6239
|
+
if (messageSimulator.permanent)
|
|
6240
|
+
messageFrame.dataset[PERMANENT] = "true";
|
|
6241
|
+
this.startFrame(messageFrame);
|
|
6242
|
+
frames = this.simFrames(); // refresh
|
|
6243
|
+
}
|
|
6244
|
+
// not running the curren run, restart
|
|
6245
|
+
else if (messageFrame.dataset['runid'] != this.runId) {
|
|
6246
|
+
this.startFrame(messageFrame);
|
|
6247
|
+
}
|
|
6255
6248
|
}
|
|
6256
|
-
else
|
|
6257
|
-
|
|
6249
|
+
else {
|
|
6250
|
+
// start secondary frame if needed
|
|
6251
|
+
const mkcdFrames = frames.filter(frame => !frame.dataset[FRAME_DATA_MESSAGE_CHANNEL]);
|
|
6252
|
+
if (mkcdFrames.length < 2) {
|
|
6253
|
+
this.container.appendChild(this.createFrame());
|
|
6254
|
+
frames = this.simFrames();
|
|
6255
|
+
// there might be an old frame
|
|
6256
|
+
}
|
|
6257
|
+
else if (mkcdFrames[1].dataset['runid'] != this.runId) {
|
|
6258
|
+
this.startFrame(mkcdFrames[1]);
|
|
6259
|
+
}
|
|
6258
6260
|
}
|
|
6259
6261
|
}
|
|
6260
6262
|
}
|
|
@@ -6534,12 +6536,14 @@ var pxsim;
|
|
|
6534
6536
|
}
|
|
6535
6537
|
// ensure _currentRuntime is ready
|
|
6536
6538
|
startFrame(frame) {
|
|
6539
|
+
var _a, _b;
|
|
6537
6540
|
if (!this._currentRuntime || !frame.contentWindow)
|
|
6538
6541
|
return false;
|
|
6539
6542
|
const msg = JSON.parse(JSON.stringify(this._currentRuntime));
|
|
6540
6543
|
msg.frameCounter = ++this.frameCounter;
|
|
6541
6544
|
msg.options = {
|
|
6542
6545
|
theme: this.themes[this.nextFrameId++ % this.themes.length],
|
|
6546
|
+
mpRole: (_b = (_a = /[\&\?]mp=(server|client)/i.exec(window.location.href)) === null || _a === void 0 ? void 0 : _a[1]) === null || _b === void 0 ? void 0 : _b.toLowerCase()
|
|
6543
6547
|
};
|
|
6544
6548
|
msg.id = `${msg.options.theme}-${this.nextId()}`;
|
|
6545
6549
|
frame.dataset['runid'] = this.runId;
|