Skip to content

Commit

Permalink
Fix remaining TS errors
Browse files Browse the repository at this point in the history
  • Loading branch information
adroitwhiz committed Mar 9, 2023
1 parent d2ab10a commit 82b33c0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ const KnownBlockInputMap = {
},
[OpCode.motion_ifonedgebounce]: {},
[OpCode.motion_setrotationstyle]: {
STYLE: { type: "rotationStyle", initial: "leftRight" }
STYLE: { type: "rotationStyle", initial: "left-right" }
},
[OpCode.motion_xposition]: {},
[OpCode.motion_yposition]: {},
Expand Down
11 changes: 8 additions & 3 deletions src/io/sb3/fromSb3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -487,9 +487,14 @@ export async function fromSb3JSON(json: sb3.ProjectJSON, options: { getAsset: Ge

export default async function fromSb3(fileData: Parameters<typeof JSZip.loadAsync>[0]): Promise<Project> {
const inZip = await JSZip.loadAsync(fileData);
const json = await inZip.file("project.json").async("text");
const getAsset = async ({ md5, ext }: { md5: string; ext: string }): Promise<ArrayBuffer> => {
return inZip.file(`${md5}.${ext}`).async("arraybuffer");
const projectFile = inZip.file("project.json");
if (!projectFile) {
throw new Error("Missing project.json");
}
const json = await projectFile.async("text");
const getAsset = async ({ md5, ext }: { md5: string; ext: string }): Promise<ArrayBuffer | undefined> => {
// TODO: figure out how to handle missing assets
return inZip.file(`${md5}.${ext}`)?.async("arraybuffer");
};
return fromSb3JSON(JSON.parse(json) as sb3.ProjectJSON, { getAsset });
}

0 comments on commit 82b33c0

Please sign in to comment.