Skip to content

Commit b4a6a0b

Browse files
committed
sync with upstream #13
2 parents 682254e + 96dfe03 commit b4a6a0b

File tree

22 files changed

+349
-406
lines changed

22 files changed

+349
-406
lines changed

package-lock.json

Lines changed: 39 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"dependencies": {
3535
"@microbit/microbit-universal-hex": "0.2.2",
3636
"@turbowarp/jszip": "^3.11.1",
37-
"@turbowarp/nanolog": "^0.2.0",
37+
"@turbowarp/nanolog": "^1.0.1",
3838
"@turbowarp/scratch-l10n": "^3.1001.0-202401241456-994097a5",
3939
"@turbowarp/scratch-storage": "^0.0.202505311821",
4040
"@turbowarp/scratch-svg-renderer": "^1.0.0-202312242305-12c360b",

src/addons/addons.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ const addons = [
7979
'hide-stage',
8080
'tw-straighten-comments',
8181
'tw-remove-backpack',
82+
'tw-disable-vibration',
8283
'tw-disable-cloud-variables',
8384
'tw-disable-compiler',
8485
'editor-stepping'

src/addons/addons/middle-click-popup/WorkspaceQuerier.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,8 @@ class TokenTypeBlock extends TokenType {
733733
strings.push(...blockPart.toLowerCase().split(" "));
734734
} else if (blockPart.type === BlockInputType.ENUM) {
735735
for (const enumValue of blockPart.values) {
736+
if (this.stringForms.length >= WorkspaceQuerier.MAX_RESULTS) return;
737+
736738
enumerateStringForms(
737739
partIdx + 1,
738740
[...strings, ...enumValue.string.toLowerCase().split(" ")],
@@ -749,6 +751,13 @@ class TokenTypeBlock extends TokenType {
749751
};
750752

751753
enumerateStringForms();
754+
755+
if (this.stringForms.length >= WorkspaceQuerier.MAX_STRING_FORMS) {
756+
console.warn(
757+
"Warning: Block '" + this.block.id + "' has too many string forms. Search results may not be very good."
758+
);
759+
this.stringForms.length = 0;
760+
}
752761
}
753762

754763
/**
@@ -1164,7 +1173,12 @@ export default class WorkspaceQuerier {
11641173
/**
11651174
* The maximum number of tokens to find before giving up.
11661175
*/
1167-
static MAX_TOKENS = 10000;
1176+
static MAX_TOKENS = 100000;
1177+
1178+
/**
1179+
* The maximum number of string forms a block can have before we give up.
1180+
*/
1181+
static MAX_STRING_FORMS = 500;
11681182

11691183
/**
11701184
* Indexes a workspace in preparation for querying it.
@@ -1208,12 +1222,12 @@ export default class WorkspaceQuerier {
12081222
}
12091223
++query.resultCount;
12101224
if (!limited && query.resultCount >= WorkspaceQuerier.MAX_RESULTS) {
1211-
console.log("Warning: Workspace query exceeded maximum result count.");
1225+
console.warn("Warning: Workspace query exceeded maximum result count.");
12121226
limited = true;
12131227
}
12141228

12151229
if (!query.canCreateMoreTokens()) {
1216-
console.log("Warning: Workspace query exceeded maximum token count.");
1230+
console.warn("Warning: Workspace query exceeded maximum token count.");
12171231
limited = true;
12181232
break;
12191233
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/* generated by pull.js */
2+
const manifest = {
3+
"noTranslations": true,
4+
"name": "Disable vibrations",
5+
"description": "Prevents the vibration and gamepad extensions from causing vibrations.",
6+
"userscripts": [
7+
{
8+
"url": "userscript.js"
9+
}
10+
],
11+
"tags": [
12+
"danger"
13+
],
14+
"enabledByDefault": false
15+
};
16+
export default manifest;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/* generated by pull.js */
2+
import _js from "./userscript.js";
3+
export const resources = {
4+
"userscript.js": _js,
5+
};
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
export default async function ({ addon }) {
2+
if (navigator.vibrate) {
3+
const originalVibrate = navigator.vibrate;
4+
navigator.vibrate = function (...args) {
5+
if (addon.self.disabled) {
6+
return originalVibrate.call(this, ...args);
7+
}
8+
return false;
9+
};
10+
}
11+
12+
if (typeof GamepadHapticActuator === 'function' && typeof GamepadHapticActuator.prototype.pulse === 'function') {
13+
const originalPulse = GamepadHapticActuator.prototype.pulse;
14+
GamepadHapticActuator.prototype.pulse = function (...args) {
15+
if (addon.self.disabled) {
16+
return originalPulse.call(this, ...args);
17+
}
18+
return Promise.resolve(false);
19+
};
20+
}
21+
22+
if (typeof GamepadHapticActuator === 'function' && typeof GamepadHapticActuator.prototype.playEffect === 'function') {
23+
const originalPlayEffect = GamepadHapticActuator.prototype.playEffect;
24+
GamepadHapticActuator.prototype.playEffect = function (...args) {
25+
if (addon.self.disabled) {
26+
return originalPlayEffect.call(this, ...args);
27+
}
28+
return Promise.resolve('preempted');
29+
};
30+
}
31+
}

src/addons/generated/addon-entries.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/addons/generated/addon-manifests.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ import _fullscreen from "../addons/fullscreen/_manifest_entry.js";
7575
import _hide_stage from "../addons/hide-stage/_manifest_entry.js";
7676
import _tw_straighten_comments from "../addons/tw-straighten-comments/_manifest_entry.js";
7777
import _tw_remove_backpack from "../addons/tw-remove-backpack/_manifest_entry.js";
78+
import _tw_disable_vibration from "../addons/tw-disable-vibration/_manifest_entry.js";
7879
import _tw_disable_cloud_variables from "../addons/tw-disable-cloud-variables/_manifest_entry.js";
7980
import _tw_disable_compiler from "../addons/tw-disable-compiler/_manifest_entry.js";
8081
import _editor_stepping from "../addons/editor-stepping/_manifest_entry.js";
@@ -159,6 +160,7 @@ export default {
159160
"hide-stage": _hide_stage,
160161
"tw-straighten-comments": _tw_straighten_comments,
161162
"tw-remove-backpack": _tw_remove_backpack,
163+
"tw-disable-vibration": _tw_disable_vibration,
162164
"tw-disable-cloud-variables": _tw_disable_cloud_variables,
163165
"tw-disable-compiler": _tw_disable_compiler,
164166
"editor-stepping": _editor_stepping,
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"commit":"df5f51e"}
1+
{"commit":"965a016"}

0 commit comments

Comments
 (0)