Skip to content

Commit

Permalink
fix: use new core interface
Browse files Browse the repository at this point in the history
  • Loading branch information
DjDeveloperr authored Jan 26, 2023
1 parent 0e915dd commit 210f946
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions build.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { encode } from "https://deno.land/[email protected]/encoding/base64.ts";

const $ = (cmd: string, ...args: string[]) => {
console.log(`%c$ ${cmd} ${args.join(" ")}`, "color: #888");
return new Deno.Command(cmd, {
Expand Down Expand Up @@ -64,11 +62,15 @@ const OUT_FILE = `./glfw3_${Deno.build.os}${
Deno.build.arch === "aarch64" ? "_aarch64" : ""
}.js`;

const encode = (Deno as any)[(Deno as any).internal]
.core
.ops.op_base64_encode;

Deno.writeTextFileSync(
OUT_FILE,
`const BASE64 = "${
encode(Deno.readFileSync(BIN_FILE))
}";\nfunction decode(b64) {\n const binString = atob(b64);\n const size = binString.length;\n const bytes = new Uint8Array(size); \n for (let i = 0; i < size; i++) {\n bytes[i] = binString.charCodeAt(i);\n }\n return bytes;\n}\nconst DECODED = Deno.build.os === "${Deno.build.os}" && Deno.build.arch === "${Deno.build.arch}" ? decode(BASE64) : new Uint8Array();\nexport default DECODED;\n`,
}";\nconst DECODED = Deno.build.os === "${Deno.build.os}" && Deno.build.arch === "${Deno.build.arch}" ? Deno[Deno.internal].core.ops.op_base64_decode(BASE64) : new Uint8Array();\nexport default DECODED;\n`,

This comment has been minimized.

Copy link
@disjukr

disjukr Jan 14, 2024

it seems only available on repl

$ deno repl -A --unstable
Deno 1.39.4
exit using ctrl+d, ctrl+c, or close()
> console.log(Deno[Deno.internal].core.ops.op_base64_decode);
[Function: op_base64_decode]
undefined
> 
press ctrl+c again to exit
> 

$ cat ./test.ts 
console.log(Deno[Deno.internal].core.ops.op_base64_decode);

$ deno run -A --unstable ./test.ts 
undefined
);

console.log(`%cWrote ${OUT_FILE}`, "color: #888");

0 comments on commit 210f946

Please sign in to comment.