Skip to content

Commit

Permalink
🔧 chore: fix export sprite & add getLanguage
Browse files Browse the repository at this point in the history
Signed-off-by: SimonShiki <[email protected]>
  • Loading branch information
SimonShiki committed Feb 5, 2024
1 parent 1e25dbe commit f77464d
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 14 deletions.
45 changes: 31 additions & 14 deletions src/injector/inject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,37 @@ export function inject (vm: EurekaCompatibleVM) {
obj.extensionEnvs = Object.assign({}, obj.extensionEnvs, envs);

if (window.eureka.settings.convertProcCall) {
for (const target of obj.targets) {
for (const blockId in target.blocks) {
const block = target.blocks[blockId];
if ('targets' in obj) {
for (const target of obj.targets) {
for (const blockId in target.blocks) {
const block = target.blocks[blockId];
if (!block.opcode) continue;
const extensionId = getExtensionIdForOpcode(block.opcode);
if (!extensionId) continue;
if (sideloadIds.includes(extensionId)) {
if (!('mutation' in block)) block.mutation = {};
block.mutation.proccode = `[📎 Sideload] ${block.opcode}`;
block.mutation.children = [];
block.mutation.tagName = 'mutation';

block.opcode = 'procedures_call';
}
}
}
for (const i in obj.monitors) {
const monitor = obj.monitors[i];
if (!monitor.opcode) continue;
const extensionId = getExtensionIdForOpcode(monitor.opcode);
if (!extensionId) continue;
if (sideloadIds.includes(extensionId)) {
if (!('sideloadMonitors' in obj)) obj.sideloadMonitors = [];
obj.sideloadMonitors.push(monitor);
obj.monitors.splice(i, 1);
}
}
} else {
for (const blockId in obj.blocks) {
const block = obj.blocks[blockId];
if (!block.opcode) continue;
const extensionId = getExtensionIdForOpcode(block.opcode);
if (!extensionId) continue;
Expand All @@ -254,17 +282,6 @@ export function inject (vm: EurekaCompatibleVM) {
}
}
}
for (const i in obj.monitors) {
const monitor = obj.monitors[i];
if (!monitor.opcode) continue;
const extensionId = getExtensionIdForOpcode(monitor.opcode);
if (!extensionId) continue;
if (sideloadIds.includes(extensionId)) {
if (!('sideloadMonitors' in obj)) obj.sideloadMonitors = [];
obj.sideloadMonitors.push(monitor);
obj.monitors.splice(i, 1);
}
}
}
return JSON.stringify(obj);
};
Expand Down
7 changes: 7 additions & 0 deletions src/loader/make-ctx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ function createTranslate (vm?: VM) {
});
}

// TurboWarp/scratch-vm@24b6036
Object.defineProperty(translate, 'language', {
configurable: true,
enumerable: true,
get: () => getLocale()
});

return translate;
}

Expand Down

0 comments on commit f77464d

Please sign in to comment.