Skip to content

Commit

Permalink
fix: scripts/buildPreload.mjs
Browse files Browse the repository at this point in the history
  • Loading branch information
linonetwo committed Nov 29, 2024
1 parent 339b450 commit 229d1cf
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
4 changes: 2 additions & 2 deletions assets/preload/streamChunksPreloadScript.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
break;
}
case OnStreamChunksToWebViewEventTypes.CHECK_RECEIVER_READY: {
// @ts-ignore
// @ts-ignore error TS2339: Property 'service' does not exist on type 'Window & typeof globalThis'
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
(_c = (_b = (_a = window.service) === null || _a === void 0 ? void 0 : _a.wikiHookService) === null || _b === void 0 ? void 0 : _b.setWebviewReceiverReady) === null || _c === void 0 ? void 0 : _c.call(_b);
break;
}
Expand Down Expand Up @@ -130,7 +131,6 @@
script.parentNode.replaceChild(newScript, script);
}
catch (error) {
// FIXME: can't catch error `SyntaxError: Can't create duplicate variable: 'A'` on iOS
console.error("Faile to refresh script tag with error ".concat(error.message, ": newScript, script"), newScript, script, error);
}
}
Expand Down
11 changes: 9 additions & 2 deletions scripts/buildPreload.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
import { mkdir, readFile, writeFile } from 'fs/promises';
import { mkdir, readFile, writeFile, rmdir } from 'fs/promises';
import { $ } from 'zx';

if (process.platform === 'win32') {
Expand All @@ -25,7 +25,14 @@ await writeFile(tmpTsFilePath, modifiedTsContent);

// Use TypeScript compiler to compile the temporary file
const outFilePath = 'assets/preload/streamChunksPreloadScript.js.html';
await $`tsc ${tmpTsFilePath.replace('C:\\', '/')} --outFile ${outFilePath}`;
try {
await $`tsc ${tmpTsFilePath.replace('C:\\', '/')} --outFile ${outFilePath}`;
} catch (error) {
console.error(error);
throw error;
} finally {
await rmdir('build', { recursive: true });
}

// Optionally, you can log the output file path or perform other actions
console.log(`Compiled file written to: ${outFilePath}`);
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ export enum OnStreamChunksToWebViewEventTypes {
break;
}
case OnStreamChunksToWebViewEventTypes.CHECK_RECEIVER_READY: {
// @ts-ignore error TS2339: Property 'service' does not exist on type 'Window & typeof globalThis'
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
window.service?.wikiHookService?.setWebviewReceiverReady?.();
break;
}
Expand Down

0 comments on commit 229d1cf

Please sign in to comment.