Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions extensions/0832/rxFS.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@

search({ STR }) {
Search = "";
i = 0;
str = btoa(unescape(encodeURIComponent(STR)));
for (var i in rxFSsy) {
if (!(rxFSsy[i].indexOf(str) == undefined)) {
Expand All @@ -228,7 +227,6 @@

list({ STR }) {
Search = "";
i = 0;
str = btoa(unescape(encodeURIComponent(STR)));
for (var i in rxFSsy) {
if (rxFSsy[i].slice(0, str.length) == str) {
Expand Down
2 changes: 0 additions & 2 deletions extensions/0832/rxFS2.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@

search({ STR }) {
Search = "";
i = 0;
str = encodeURIComponent(STR);
for (var i in rxFSsy) {
if (!(rxFSsy[i].indexOf(str) == undefined)) {
Expand All @@ -253,7 +252,6 @@

list({ STR }) {
Search = "";
i = 0;
str = encodeURIComponent(STR);
for (var i in rxFSsy) {
if (rxFSsy[i].slice(0, str.length) == str) {
Expand Down
1 change: 0 additions & 1 deletion extensions/CubesterYT/WindowControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,6 @@
default:
"Are you sure you want to close this window?\n\n(This message will not appear when the project is packaged)",
});
// @ts-expect-error
if (typeof ScratchBlocks === "undefined" || confirm(editorConfirmation)) {
window.close();
}
Expand Down
2 changes: 1 addition & 1 deletion extensions/DT/cameracontrols.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
// tell resize to update camera as well
vm.runtime.on("STAGE_SIZE_CHANGED", (_) => updateCamera());

vm.runtime.on("RUNTIME_DISPOSED", (_) => {
vm.runtime.on("RUNTIME_DISPOSED", () => {
cameraX = 0;
cameraY = 0;
cameraZoom = 100;
Expand Down
1 change: 0 additions & 1 deletion extensions/Lily/ClonesPlus.js
Original file line number Diff line number Diff line change
Expand Up @@ -708,13 +708,12 @@
}

getVariables() {
// @ts-expect-error - Blockly not typed yet
const variables =
typeof Blockly === "undefined"
? []
: Blockly.getMainWorkspace()
.getVariableMap()
.getVariablesOfType("")

Check warning on line 716 in extensions/Lily/ClonesPlus.js

View workflow job for this annotation

GitHub Actions / type-warnings

Type warning - may indicate a bug - ignore if no bug

Argument of type '""' is not assignable to parameter of type 'VariableType'.
.filter((model) => model.isLocal)
.map((model) => ({
text: model.name,
Expand Down
2 changes: 0 additions & 2 deletions extensions/TheShovel/ShovelUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,13 @@
.then((r) => r.arrayBuffer())
.then((arrayBuffer) => {
const storage = vm.runtime.storage;
vm.addCostume(NAME + ".PNG", {

Check warning on line 211 in extensions/TheShovel/ShovelUtils.js

View workflow job for this annotation

GitHub Actions / type-warnings

Type warning - may indicate a bug - ignore if no bug

Argument of type '{ name: string; asset: ScratchStorage.Asset; }' is not assignable to parameter of type 'Costume'. Type '{ name: string; asset: Asset; }' is missing the following properties from type 'Costume': dataFormat, bitmapResolution, rotationCenterX, rotationCenterY, and 4 more.
name: NAME + "",
asset: new storage.Asset(
storage.AssetType.ImageBitmap,
null, // asset id, doesn't need to be set here because of `true` at the end will make Scratch generate it for you
storage.DataFormat.PNG,
new Uint8Array(arrayBuffer),

Check warning on line 217 in extensions/TheShovel/ShovelUtils.js

View workflow job for this annotation

GitHub Actions / type-warnings

Type warning - may indicate a bug - ignore if no bug

Argument of type 'Uint8Array<ArrayBuffer>' is not assignable to parameter of type 'ArrayBuffer'. Types of property '[Symbol.toStringTag]' are incompatible. Type '"Uint8Array"' is not assignable to type '"ArrayBuffer"'.
true
),
});
Expand All @@ -238,7 +238,6 @@
if (!target || target.isStage) {
return;
}
// @ts-expect-error
if (typeof ScratchBlocks !== "undefined") {
if (
!confirm(
Expand All @@ -260,10 +259,10 @@
storage.AssetType.Sound,
null,
storage.DataFormat.MP3,
new Uint8Array(arrayBuffer),

Check warning on line 262 in extensions/TheShovel/ShovelUtils.js

View workflow job for this annotation

GitHub Actions / type-warnings

Type warning - may indicate a bug - ignore if no bug

Argument of type 'Uint8Array<ArrayBuffer>' is not assignable to parameter of type 'ArrayBuffer'. Types of property '[Symbol.toStringTag]' are incompatible. Type '"Uint8Array"' is not assignable to type '"ArrayBuffer"'.
true
);
vm.addSound({

Check warning on line 265 in extensions/TheShovel/ShovelUtils.js

View workflow job for this annotation

GitHub Actions / type-warnings

Type warning - may indicate a bug - ignore if no bug

Argument of type '{ md5: string; asset: ScratchStorage.Asset; name: string; }' is not assignable to parameter of type 'Sound'. Type '{ md5: string; asset: Asset; name: string; }' is missing the following properties from type 'Sound': dataFormat, format, rate, sampleCount, and 2 more.
md5: asset.assetId + "." + asset.dataFormat,
asset: asset,
name: NAME + "",
Expand All @@ -272,7 +271,6 @@
}

importProject({ TEXT }) {
// @ts-ignore
if (typeof ScratchBlocks !== "undefined") {
// We are in the editor. Ask before loading a new project to avoid unrecoverable data loss.
if (
Expand Down
103 changes: 103 additions & 0 deletions globals.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/**
* @fileoverview
* Defines extra APIs that exist in real web browsers but that are missing from TypeScript's default types.
*/

interface Element {
/**
* requestFullscreen() but available in Safari.
*/
webkitRequestFullscreen?(): unknown;
}

interface Document {
/**
* exitFullscreen() but available in Safari.
*/
webkitExitFullscreen?(): unknown;
/**
* fullscreenElement but available in Safari.
*/
webkitFullscreenElement?: Element;
}

/**
* https://developer.mozilla.org/en-US/docs/Web/API/NDEFReader
*/
declare class NDEFReader extends EventTarget {
constructor();
scan(options?: { signal?: AbortSignal }): Promise<void>;
onreading?(event: Event & { message: NDEFMessage }): void;
onreadingerror?(event: Event): void;
}

type TypedArray =
| Uint8Array
| Int8Array
| Uint16Array
| Int16Array
| Uint32Array
| Int32Array
| BigUint64Array
| BigInt64Array;

/**
* https://developer.mozilla.org/en-US/docs/Web/API/NDEFMessage/NDEFMessage
*/
declare class NDEFMessage {
constructor(
records: Array<{
data?: string | ArrayBuffer | TypedArray | DataView | NDEFRecord[];
encoding?: string;
id?: string;
lang?: string;
mediaType?: string;
recordType?: string;
}>
);
readonly records: NDEFRecord[];
}

/**
* https://developer.mozilla.org/en-US/docs/Web/API/NDEFRecord
*/
declare class NDEFRecord {
constructor();
readonly recordType: string;
readonly mediaType: string;
readonly id: string;
readonly data: DataView;
readonly encoding: string | null;
readonly lang: string | null;
toRecords(): NDEFRecord[];
}

interface NetworkInformation {
downlink: number;
downlinkMax: number;
effectiveType: string;
rtt: number;
saveData: boolean;
type:
| "bluetooth"
| "cellular"
| "ethernet"
| "none"
| "wifi"
| "wimax"
| "other"
| "unknown";
}

interface Navigator {
connection?: NetworkInformation;
}

declare namespace Scratch.extensions {
/**
* Most extensions fail the type checking of @turbowarp/types-tw's default register().
* That error generally isn't very useful - so for now we'll just add this overload so
* that those errors don't appear.
*/
function register(extensionObj: any): void;
}
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"include": [
"node_modules/@turbowarp/types/types/scratch-vm-extension.d.ts",
"node_modules/@turbowarp/types/types/scratchx-extension.d.ts",
"globals.d.ts",
"extensions/**/*",
"website/**/*"
]
Expand Down