Skip to content

Commit

Permalink
🐛 fix: refreshBlock issues when sideloaded extensions
Browse files Browse the repository at this point in the history
Signed-off-by: SimonShiki <[email protected]>
  • Loading branch information
SimonShiki committed Sep 17, 2023
1 parent b656e48 commit 36892a2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "chibi",
"displayName": "Chibi",
"version": "0.0.1",
"version": "0.0.2",
"description": "Load scratch extension everywhere.",
"repository": "https://github.com/SimonShiki/chibi",
"author": "SimonShiki",
Expand Down
10 changes: 9 additions & 1 deletion src/injector/inject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export function inject (vm: ChibiCompatibleVM) {
await loader.load(url, env as 'unsandboxed' | 'sandboxed');
const extensionId = loader.getIdByUrl(url);
// @ts-expect-error internal hack
vm.extensionManager._loadedExtensions.set(extensionId, null);
vm.extensionManager._loadedExtensions.set(extensionId, 'Chibi');
} else {
// @ts-expect-error internal hack
return originalLoadFunc.apply(vm.extensionManager, [extensionURL, ...args]);
Expand All @@ -76,6 +76,14 @@ export function inject (vm: ChibiCompatibleVM) {
}
};

const originalRefreshBlocksFunc = vm.extensionManager.refreshBlocks;
vm.extensionManager.refreshBlocks = async function (...args: unknown[]) {
// @ts-expect-error internal hack
const result = await originalRefreshBlocksFunc.apply(vm.extensionManager, [...args]);
await window.chibi.loader.refreshBlocks();
return result;
}

const originalToJSONFunc = vm.toJSON;
vm.toJSON = function (optTargetId: string, ...args: unknown[]) {
// @ts-expect-error internal hack
Expand Down

0 comments on commit 36892a2

Please sign in to comment.