Skip to content

Commit

Permalink
Fix installing plugins with wide unicode characters
Browse files Browse the repository at this point in the history
  • Loading branch information
abrenneke committed May 10, 2024
1 parent b75551b commit 6658904
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/app/src/hooks/useLoadPackagePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,15 +191,18 @@ export function useLoadPackagePlugin(options: { onLog?: (message: string) => voi

const main = packageJsonContents.main;

log(`Reading plugin main file: ${main}\n`);
const mainContents = await readTextFile(`${pluginFilesPath}/${main}`);

if (!mainContents) {
throw new Error(`Plugin main file not found: ${spec.package}@${spec.tag}`);
}

const b64Contents = btoa(mainContents);
log(`Converting plugin main file to base64\n`);
const b64Contents = await Rivet.uint8ArrayToBase64(new TextEncoder().encode(mainContents));

try {
log(`Initializing plugin: ${spec.package}@${spec.tag}\n`);
const pluginInitializer = (await import(
/* @vite-ignore */ `data:application/javascript;base64,${b64Contents}`
)) as {
Expand Down

0 comments on commit 6658904

Please sign in to comment.