Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Offline Library Embedding #39

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

7flash
Copy link
Contributor

@7flash 7flash commented Dec 8, 2023

  1. Run embed script to download and uncompress library released to each of platforms, then encode and compress again, but this time save in .json files instead of .zip
deno run --allow-all --unstable embed.ts
  1. When compiled binary imports WebUI
const myWindow = new WebUI();

it already has all of libs compressed

import libs from './dir.ts';

and depending on user platform, it will uncompress and save that one into user home directory,

  const it = libs[Deno.build.os];
  const xit = `webui-2.${it.ext}`;
  const ixit = joinPath(Deno.env.get('HOME'), '.webui', xit);
  // ...
  export const libName = await getLibName();

and access it given that path

import {
  libName,
} from "../deps.ts";

export function loadLib() {
  return Deno.dlopen(
    libName,

@7flash
Copy link
Contributor Author

7flash commented Dec 8, 2023

Possible improvement:

If we want to avoid embedding all libs when only one needed compiling for each platform and further save space, then we can have WebUI to accept compressed library imported as an argument and let user to create several main files for each platform, but I'm not sure if it would be worth it like this:

import webuiMacosArm from "./src/webui-libs/webui-arm64.dylib_.json" with { type: "json" };

const myWindow = new WebUI(webuiMacosArm);

I think it's better as implemented in current PR:

const myWindow = new WebUI();

@7flash
Copy link
Contributor Author

7flash commented Dec 11, 2023

Does it make sense? @hassandraga

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant