17 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/mod.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * # Deno WebUI
3 | *
4 | * > Use any web browser as GUI, with Deno in the backend and HTML5 in the
5 | * > frontend, all in a lightweight Deno module.
6 | *
7 | * ## Features
8 | *
9 | * - Fully Independent (_No need for any third-party runtimes_)
10 | * - Lightweight _~900 Kb_ for the whole package & Small memory footprint
11 | * - Fast binary communication protocol between WebUI and the browser (_Instead of JSON_)
12 | * - Multi-platform & Multi-Browser
13 | * - Using private profile for safety
14 | * - Original library written in Pure C
15 | *
16 | * ## Minimal Example
17 | *
18 | * ```ts
19 | * import { WebUI } from "jsr:@webui/deno-webui@2.5.13";
20 | *
21 | * const myWindow = new WebUI();
22 | * await myWindow.show(" Hello World! ");
23 | * await WebUI.wait();
24 | * ```
25 | *
26 | * @module
27 | * @license MIT
28 | */
29 | export { WebUI } from "./src/webui.ts";
30 | export type { BindCallback, Datatypes, WebUIEvent } from "./src/types.ts";
31 |
--------------------------------------------------------------------------------
/.github/workflows/deno.yml:
--------------------------------------------------------------------------------
1 | name: Deno
2 |
3 | on:
4 | push:
5 | branches: ["main"]
6 | pull_request:
7 | branches: ["main"]
8 |
9 | permissions:
10 | contents: read
11 |
12 | jobs:
13 | test:
14 | runs-on: ${{ matrix.os }}
15 | strategy:
16 | matrix:
17 | os: [ubuntu-latest, macOS-latest, windows-latest]
18 |
19 | steps:
20 | - name: Setup repo
21 | uses: actions/checkout@v4
22 |
23 | - name: Setup Rust
24 | uses: dtolnay/rust-toolchain@master
25 | with:
26 | toolchain: 1.85.0 # Specify minimum Rust version that supports 2024 edition
27 |
28 | - name: Setup Deno
29 | uses: denoland/setup-deno@v2
30 |
31 | - name: Verify formatting
32 | if: runner.os == 'Linux'
33 | run: deno fmt --check
34 |
35 | - name: Run linter
36 | if: runner.os == 'Linux'
37 | run: deno lint
38 |
39 | - name: Run doc linter
40 | if: runner.os == 'Linux'
41 | run: deno doc --lint mod.ts
42 |
43 | - name: Run type checker
44 | if: runner.os == 'Linux'
45 | run: deno check .
46 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2025 Hassan Draga
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Deno binaries
2 | src/webui-windows-msvc-x64/
3 | src/webui-windows-msvc-arm/
4 | src/webui-windows-msvc-arm64/
5 | src/webui-macos-clang-x64/
6 | src/webui-macos-clang-arm/
7 | src/webui-macos-clang-arm64/
8 | src/webui-linux-gcc-x64/
9 | src/webui-linux-gcc-arm/
10 | src/webui-linux-gcc-arm64/
11 | *.dll
12 | *.so
13 | *.dylib
14 |
15 | # Archives
16 | *.zip
17 | *.tar
18 | *.gz
19 |
20 | # Build
21 | *.exe
22 | *.ilk
23 | *.pdb
24 | *.exp
25 | *.res
26 | *.out
27 | *.def
28 | *.obj
29 | *.iobj
30 | *.o
31 |
32 | # Logs
33 | *.log
34 | *.logs
35 | *.tlog
36 |
37 | # IDE
38 | .vscode/
39 | .vs/
40 | .zed/
41 |
42 | # Visual Studio
43 | .idea/
44 | *.recipe
45 | *.idb
46 |
47 | # Visual Studio for Mac
48 | .idea/
49 |
50 | # Visual Studio cache files
51 | ipch/
52 | *.dbmdl
53 | *.dbproj.schemaview
54 |
55 | # Others
56 | .builds
57 | *~*
58 | *.cache
59 | *.swp
60 | *.bak
61 | *.tmp
62 | *.swp
63 | *.userosscache
64 | *.err
65 | *.vspscc
66 | *.vssscc
67 | *.pidb
68 | *.svclog
69 | *.scc
70 |
71 | # NuGet
72 | packages/
73 | !packages/repositories.config
74 | *.nupkg
75 |
76 | # Microsoft Azure Build Output
77 | csx/
78 | *.build.csdef
79 |
80 | # User-specific files
81 | *.suo
82 | *.user
83 | *.userprefs
84 | *.sln.docstates
85 |
86 | # Python
87 | __pycache__/
88 | dist/
89 | webui2.egg-info/
90 |
91 | # Rust
92 | target/
93 | *.lock
94 |
95 | # Broken NTFS
96 | nul
97 |
98 | # Zig
99 | zig-cache/
100 | zig-out/
101 |
102 | # macOS
103 | .DS_Store
104 | .DS_Store?
105 | ._*
106 | .Spotlight-V100
107 | .Trashes
108 | ehthumbs.db
109 | Thumbs.db
110 |
111 | # User-specific private settings
112 | *.DotSettings.user
113 | /.claude
114 | CLAUDE.md
115 |
--------------------------------------------------------------------------------
/deps.ts:
--------------------------------------------------------------------------------
1 | // Deno WebUI
2 | // Resolves the path to the required native WebUI library,
3 | // ensuring it is downloaded to a central cache if needed.
4 |
5 | import { ensureWebUiLib } from "./src/utils.ts";
6 |
7 | // Determine the base library filename based
8 | // on the current operating system and architecture.
9 | function getBaseLibName(): string {
10 | let baseName: string;
11 | switch (Deno.build.os) {
12 | case "windows":
13 | baseName = "webui-2.dll";
14 | // Validate architecture for Windows
15 | if (Deno.build.arch !== "x86_64" && Deno.build.arch !== "aarch64") {
16 | throw new Error(
17 | `Unsupported architecture ${Deno.build.arch} for Windows`,
18 | );
19 | }
20 | break;
21 | case "darwin": // macOS
22 | baseName = "libwebui-2.dylib";
23 | // Validate architecture for macOS
24 | if (Deno.build.arch !== "x86_64" && Deno.build.arch !== "aarch64") {
25 | throw new Error(
26 | `Unsupported architecture ${Deno.build.arch} for macOS`,
27 | );
28 | }
29 | break;
30 | default: // Linux and other Unix-like OSes
31 | baseName = "libwebui-2.so";
32 | // Validate architecture for Linux/others
33 | if (Deno.build.arch !== "x86_64" && Deno.build.arch !== "aarch64") {
34 | throw new Error(
35 | `Unsupported architecture ${Deno.build.arch} for ${Deno.build.os}`,
36 | );
37 | }
38 | break;
39 | }
40 | return baseName;
41 | }
42 |
43 | // Determine the required base filename
44 | const baseLibName = getBaseLibName();
45 |
46 | // Ensure the library exists in the cache (downloads if needed)
47 | // and export the resolved path.
48 | // This promise resolves to the final path of the library file.
49 | export const libPath = await ensureWebUiLib(baseLibName);
50 |
51 | // Optional: Export the base name too if needed elsewhere
52 | export { baseLibName };
53 |
--------------------------------------------------------------------------------
/examples/custom_file_handler/custom_file_handler.ts:
--------------------------------------------------------------------------------
1 | // To run this script:
2 | // deno run --allow-read --allow-write --allow-net --allow-env --allow-ffi custom_file_handler.ts
3 |
4 | // To compile this script
5 | // deno compile --allow-all --no-terminal custom_file_handler.ts
6 |
7 | // To import from local (Debugging and Development)
8 | // import { WebUI } from "../../mod.ts";
9 |
10 | // To import from online package registry (Production)
11 | import { WebUI } from "@webui/deno-webui";
12 |
13 | // Return HTTP header + file raw binary content
14 | const getFile = async (
15 | contentType: string,
16 | filename: string,
17 | ): Promise => {
18 | const content = await Deno.readFile(filename);
19 | const header = `HTTP/1.1 200 OK\r\nContent-Type: ${contentType}\r\n\r\n`;
20 | const headerBytes = new TextEncoder().encode(header);
21 | const response = new Uint8Array(headerBytes.length + content.length);
22 | response.set(headerBytes);
23 | response.set(content, headerBytes.length);
24 | return response;
25 | };
26 |
27 | // Set a custom files handler
28 | async function myFileHandler(myUrl: URL) {
29 | console.log(`File: ${myUrl.pathname}`);
30 | // Index example
31 | if (myUrl.pathname === "/index.html" || myUrl.pathname === "/") {
32 | return await getFile("text/html", "index.html");
33 | }
34 | // Custom text string example
35 | if (myUrl.pathname === "/test") {
36 | return "HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\nHello";
37 | }
38 | // File examples
39 | if (myUrl.pathname === "/assets/test_app.js") {
40 | return await getFile("application/javascript", "assets/test_app.js");
41 | }
42 | if (myUrl.pathname === "/assets/webui.jpeg") {
43 | return await getFile("image/jpeg", "assets/webui.jpeg");
44 | }
45 | // Error 404 example
46 | return "HTTP/1.1 404 Not Found";
47 | }
48 |
49 | // Create new window
50 | const myWindow = new WebUI();
51 |
52 | // Bind Exit
53 | myWindow.bind("exit", () => {
54 | // Close all windows and exit
55 | WebUI.exit();
56 | });
57 |
58 | // Set files handler
59 | // Note: Should be called before `.show()`
60 | myWindow.setFileHandler(myFileHandler);
61 |
62 | // Show the window
63 | await myWindow.showBrowser("index.html", WebUI.Browser.AnyBrowser);
64 |
65 | // Wait until all windows get closed
66 | await WebUI.wait();
67 |
68 | console.log("Thank you.");
69 |
--------------------------------------------------------------------------------
/src/types.ts:
--------------------------------------------------------------------------------
1 | import type { WebUI } from "../mod.ts";
2 | import type { loadLib } from "./lib.ts";
3 |
4 | export type Usize = number | bigint;
5 |
6 | /**
7 | * Defines the signature for callback functions used with `WebUI.prototype.bind`.
8 | * These functions are executed when a corresponding event occurs in the UI.
9 | *
10 | * @template T The expected return type of the callback function. Can be a basic data type (`string`, `number`, `boolean`), `undefined`, or `void`. Can also be a Promise resolving to one of these types for asynchronous operations.
11 | * @param event A `WebUIEvent` object containing details about the event.
12 | * @returns The result to be sent back to the UI (if the call originated from `webui.call`), or `undefined`/`void` if no response is needed. Can be a direct value or a Promise.
13 | */
14 | export type BindCallback<
15 | T extends Datatypes | undefined | void,
16 | > = (event: WebUIEvent) => T | Promise;
17 |
18 | export type WebUILib = Awaited>;
19 |
20 | /**
21 | * Represents an event object passed to bound callback functions.
22 | */
23 | export interface WebUIEvent {
24 | /** The WebUI window instance associated with this event. */
25 | window: WebUI;
26 | /** The type of the event (e.g., Connected, Disconnected, MouseClick, Callback). See `WebUI.EventType`. */
27 | eventType: number;
28 | /** A unique identifier for this specific event instance. */
29 | eventNumber: number;
30 | /** The ID ('#' attribute) of the HTML element that triggered the event, if applicable. */
31 | element: string;
32 | /**
33 | * An object containing methods to retrieve arguments passed from the UI JavaScript function call.
34 | */
35 | arg: {
36 | /**
37 | * Retrieves a numeric argument passed from the UI at the specified index.
38 | * @param index The zero-based index of the argument.
39 | * @returns The numeric value of the argument.
40 | */
41 | number: (index: number) => number;
42 | /**
43 | * Retrieves a string argument passed from the UI at the specified index.
44 | * @param index The zero-based index of the argument.
45 | * @returns The string value of the argument.
46 | */
47 | string: (index: number) => string;
48 | /**
49 | * Retrieves a boolean argument passed from the UI at the specified index.
50 | * @param index The zero-based index of the argument.
51 | * @returns The boolean value of the argument.
52 | */
53 | boolean: (index: number) => boolean;
54 | };
55 | }
56 |
57 | /**
58 | * Represents the basic data types that can be returned from a `BindCallback`
59 | * function and serialized back to the UI.
60 | */
61 | export type Datatypes =
62 | | string
63 | | number
64 | | boolean;
65 |
--------------------------------------------------------------------------------
/examples/frameless/frameless.ts:
--------------------------------------------------------------------------------
1 | // To run this script:
2 | // deno run --allow-read --allow-write --allow-net --allow-env --allow-ffi frameless.ts
3 |
4 | // To compile this script
5 | // deno compile --allow-all --no-terminal frameless.ts
6 |
7 | // To import from local (Debugging and Development)
8 | // import { WebUI } from "../../mod.ts";
9 |
10 | // To import from online package registry (Production)
11 | import { WebUI } from "@webui/deno-webui";
12 |
13 | const myHtml = `
14 |
15 |
16 |
17 |
18 |
65 |
66 |
67 |
68 | WebUI Deno Frameless Window
69 |
70 | –
71 | ✕
72 |
73 |
74 |
75 | This is a WebUI Deno frameless example
76 |
77 |
78 | `;
79 |
80 | // Create new window
81 | const myWindow = new WebUI();
82 |
83 | // Bind
84 | myWindow.bind("minimize", () => {
85 | myWindow.minimize();
86 | });
87 | myWindow.bind("close_win", () => {
88 | WebUI.exit();
89 | });
90 |
91 | myWindow.setSize(800, 600);
92 | myWindow.setFrameless(true);
93 | myWindow.setTransparent(true);
94 | myWindow.setResizable(false);
95 | myWindow.setCenter();
96 |
97 | // Show the window
98 | await myWindow.showWebView(myHtml); // in Microsoft Windows you may need `WebView2Loader.dll`
99 |
100 | // Wait until all windows get closed
101 | await WebUI.wait();
102 |
103 | console.log("Thank you.");
104 |
--------------------------------------------------------------------------------
/examples/custom_web_server/custom_web_server.ts:
--------------------------------------------------------------------------------
1 | // To run this script:
2 | // deno run --allow-read --allow-write --allow-net --allow-env --allow-ffi --allow-run=deno custom_web_server.ts
3 |
4 | // To compile this script
5 | // deno compile --allow-all --no-terminal custom_web_server.ts
6 |
7 | // To import from local (Debugging and Development)
8 | // import { WebUI } from "../../mod.ts";
9 |
10 | // To import from online package registry (Production)
11 | import { WebUI } from "@webui/deno-webui";
12 |
13 | function allEvents(e: WebUI.Event) {
14 | /*
15 | e.window: WebUI;
16 | e.eventType: WebUI.EventType;
17 | e.element: string;
18 | */
19 | console.log(`\nallEvents: window = '${e.window}'`);
20 | console.log(`allEvents: eventType = '${e.eventType}'`);
21 | console.log(`allEvents: element = '${e.element}'`);
22 | switch (e.eventType) {
23 | case WebUI.EventType.Disconnected:
24 | // Window disconnection event
25 | console.log(`Window closed.`);
26 | break;
27 | case WebUI.EventType.Connected:
28 | // Window connection event
29 | console.log(`Window connected.`);
30 | break;
31 | case WebUI.EventType.MouseClick:
32 | // Mouse click event
33 | console.log(`Mouse click.`);
34 | break;
35 | case WebUI.EventType.Navigation: {
36 | // Window navigation event
37 | const url = e.arg.string(0);
38 | console.log(`Navigation to '${url}'`);
39 | // Because we used `webui_bind(MyWindow, "", events);`
40 | // WebUI will block all `href` link clicks and sent here instead.
41 | // We can then control the behaviour of links as needed.
42 | e.window.navigate(url);
43 | break;
44 | }
45 | case WebUI.EventType.Callback:
46 | // Function call event
47 | console.log(`Function call.`);
48 | break;
49 | }
50 | }
51 |
52 | function myBackendFunc(e: WebUI.Event) {
53 | const a = e.arg.number(0); // First argument
54 | const b = e.arg.number(1); // Second argument
55 | const c = e.arg.number(2); // Third argument
56 | console.log(`\nFirst argument: ${a}`);
57 | console.log(`Second argument: ${b}`);
58 | console.log(`Third argument: ${c}`);
59 | }
60 |
61 | // Create new window
62 | const myWindow = new WebUI();
63 |
64 | // Bind All Events
65 | myWindow.bind("", allEvents);
66 |
67 | // Bind Backend Function
68 | myWindow.bind("myBackendFunc", myBackendFunc);
69 |
70 | // Bind Exit Function
71 | myWindow.bind("exit", () => {
72 | // Close all windows and exit
73 | WebUI.exit();
74 | });
75 |
76 | // Set the web-server/WebSocket port that WebUI should
77 | // use. This means `webui.js` will be available at:
78 | // http://localhost:MY_PORT_NUMBER/webui.js
79 | myWindow.setPort(8081);
80 |
81 | // Start our custom web server using Python script `python simple_web_server.py`.
82 | // Or using `file-server` module.
83 | const webServer = new Deno.Command("deno", {
84 | args: ["-RNS", "jsr:@std/http/file-server", "-p", "8080"],
85 | }).spawn();
86 | await new Promise((r) => setTimeout(r, 500));
87 |
88 | // Show a new window and point to our custom web server
89 | // Assuming the custom web server is running on port
90 | // 8080...
91 | await myWindow.showBrowser("http://localhost:8080/", WebUI.Browser.AnyBrowser);
92 |
93 | // Wait until all windows get closed
94 | await WebUI.wait();
95 |
96 | // Stop the web server
97 | webServer.kill("SIGTERM");
98 | await webServer.status;
99 |
100 | console.log("Thank you.");
101 |
--------------------------------------------------------------------------------
/examples/send_raw_binary/send_raw_binary.ts:
--------------------------------------------------------------------------------
1 | // To run this script:
2 | // deno run --allow-read --allow-write --allow-net --allow-env --allow-ffi send_raw_binary.ts
3 |
4 | // To import from local (Debugging and Development)
5 | // import { WebUI } from "../../mod.ts";
6 |
7 | // To import from online package registry (Production)
8 | import { WebUI } from "@webui/deno-webui";
9 |
10 | const myHtml = `
11 |
12 |
13 |
14 | WebUI 2 - Deno Send Raw Binary Example
15 |
41 |
42 |
43 |
WebUI 2 - Deno Send Raw Binary Example
44 |
45 |
Received 0 bytes from backend
46 |
47 |
48 |
49 | - -
50 |
67 |
68 | `;
69 |
70 | function get_raw_data(e: WebUI.Event) {
71 | const rawData = new Uint8Array([0x01, 0x02, 0x03]);
72 | console.log(`Sending ${rawData.byteLength} bytes to UI...`);
73 | e.window.sendRaw("processRawData", rawData);
74 | }
75 |
76 | async function get_raw_picture(e: WebUI.Event) {
77 | const pictureRaw = await Deno.readFile("./webui.jpeg");
78 | console.log(`Sending picture file (${pictureRaw.byteLength} bytes) to UI...`);
79 | e.window.sendRaw("setRawImage", pictureRaw);
80 | }
81 |
82 | // Create new window
83 | const myWindow = new WebUI();
84 |
85 | // Bind
86 | myWindow.bind("get_raw_data", get_raw_data);
87 | myWindow.bind("get_raw_picture", get_raw_picture);
88 | myWindow.bind("exit", () => {
89 | // Close all windows and exit
90 | WebUI.exit();
91 | });
92 |
93 | // Show the window
94 | await myWindow.showBrowser(myHtml, WebUI.Browser.AnyBrowser); // Or await myWindow.show('./myFile.html');
95 |
96 | // Wait until all windows get closed
97 | await WebUI.wait();
98 |
99 | console.log("Thank you.");
100 |
--------------------------------------------------------------------------------
/examples/hello_world/hello_world.ts:
--------------------------------------------------------------------------------
1 | // To run this script:
2 | // deno run --allow-read --allow-write --allow-net --allow-env --allow-ffi hello_world.ts
3 |
4 | // To compile this script
5 | // deno compile --allow-all --no-terminal hello_world.ts
6 |
7 | // To import from local (Debugging and Development)
8 | // import { WebUI } from "../../mod.ts";
9 |
10 | // To import from online package registry (Production)
11 | import { WebUI } from "@webui/deno-webui";
12 |
13 | const myHtml = `
14 |
15 |
16 |
17 | WebUI 2 - Deno Hello World Example
18 |
44 |
45 |
46 |
WebUI 2 - Deno Hello World
47 | A:
48 | B:
49 |
Result: ?
50 | - -
51 |
74 |
75 | `;
76 |
77 | function checkResult(e: WebUI.Event) {
78 | const a = e.arg.number(0); // First argument
79 | const b = e.arg.number(1); // Second argument
80 | const res = e.arg.number(2); // Third argument
81 | if ((a + b) == res) {
82 | return `Correct: ${a} + ${b} = ${res}`;
83 | } else {
84 | return `Incorrect: ${a} + ${b} != ${res}`;
85 | }
86 | }
87 |
88 | async function calculate(e: WebUI.Event) {
89 | // Run JavaScript and wait for response
90 | const getA = await e.window.script("return get_A()").catch((error) => {
91 | console.error(`Error in the JavaScript: ${error}`);
92 | return "";
93 | });
94 | const getB = await e.window.script("return get_B()").catch((error) => {
95 | console.error(`Error in the JavaScript: ${error}`);
96 | return "";
97 | });
98 |
99 | // Calculate
100 | const result = parseInt(getA) + parseInt(getB);
101 |
102 | // Run JavaScript without waiting for response (Quick)
103 | e.window.run(`set_result(${result});`);
104 | }
105 |
106 | // Create new window
107 | const myWindow = new WebUI();
108 |
109 | // Bind
110 | myWindow.bind("calculate", calculate);
111 | myWindow.bind("checkResult", checkResult);
112 | myWindow.bind("exit", () => {
113 | // Close all windows and exit
114 | WebUI.exit();
115 | });
116 |
117 | // Show the window
118 | await myWindow.showBrowser(myHtml, WebUI.Browser.AnyBrowser); // Or await myWindow.show('./myFile.html');
119 |
120 | // Wait until all windows get closed
121 | await WebUI.wait();
122 |
123 | console.log("Thank you.");
124 |
--------------------------------------------------------------------------------
/src/bootstrap.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # This script downloads the trusted WebUI compiled library by GitHub CI for Linux.
4 |
5 | if [[ "$1" == "" ]]; then
6 |
7 | # --- Full -------------------------------------
8 | # Download WebUI library for all supported OS.
9 | echo "WebUI Deno Bootstrap"
10 | echo
11 |
12 | # Creating the temporary cache folder
13 | mkdir -p "cache" 2>/dev/null
14 |
15 | # Nightly Build
16 | # LINUX_ARM="https://github.com/webui-dev/webui/releases/download/nightly/webui-linux-gcc-arm.zip"
17 | # LINUX_ARM64="https://github.com/webui-dev/webui/releases/download/nightly/webui-linux-gcc-arm64.zip"
18 | # LINUX_X64="https://github.com/webui-dev/webui/releases/download/nightly/webui-linux-gcc-x64.zip"
19 | # MACOS_ARM64="https://github.com/webui-dev/webui/releases/download/nightly/webui-macos-clang-arm64.zip"
20 | # MACOS_X64="https://github.com/webui-dev/webui/releases/download/nightly/webui-macos-clang-x64.zip"
21 | # WINDOWS_MSVC_X64="https://github.com/webui-dev/webui/releases/download/nightly/webui-windows-msvc-x64.zip"
22 |
23 | # Release
24 | LINUX_ARM="https://github.com/webui-dev/webui/releases/download/2.5.0-beta.3/webui-linux-gcc-arm.zip"
25 | LINUX_ARM64="https://github.com/webui-dev/webui/releases/download/2.5.0-beta.3/webui-linux-gcc-arm64.zip"
26 | LINUX_X64="https://github.com/webui-dev/webui/releases/download/2.5.0-beta.3/webui-linux-gcc-x64.zip"
27 | MACOS_ARM64="https://github.com/webui-dev/webui/releases/download/2.5.0-beta.3/webui-macos-clang-arm64.zip"
28 | MACOS_X64="https://github.com/webui-dev/webui/releases/download/2.5.0-beta.3/webui-macos-clang-x64.zip"
29 | WINDOWS_MSVC_X64="https://github.com/webui-dev/webui/releases/download/2.5.0-beta.3/webui-windows-msvc-x64.zip"
30 |
31 | # Download and extract archives
32 | download_and_extract() {
33 | echo "* Downloading [$1]..."
34 | wget -q "$1" -O "cache/$2.zip"
35 | echo "* Extracting [$2.zip]..."
36 | mkdir -p "cache/$2" 2>/dev/null
37 | unzip -q "cache/$2.zip" -d "cache"
38 | if [ -n "$3" ]; then
39 | echo "* Copying [$3]..."
40 | mkdir -p "$2" 2>/dev/null
41 | cp -f "cache/$2/$3" "$2/$3"
42 | fi
43 | if [ -n "$4" ]; then
44 | echo "* Copying [$4]..."
45 | mkdir -p "$2" 2>/dev/null
46 | cp -f "cache/$2/$4" "$2/$4"
47 | fi
48 | }
49 |
50 | download_and_extract $LINUX_ARM "webui-linux-gcc-arm" "libwebui-2.so"
51 | download_and_extract $LINUX_ARM64 "webui-linux-gcc-arm64" "libwebui-2.so"
52 | download_and_extract $LINUX_X64 "webui-linux-gcc-x64" "libwebui-2.so"
53 | download_and_extract $MACOS_ARM64 "webui-macos-clang-arm64" "libwebui-2.dylib"
54 | download_and_extract $MACOS_X64 "webui-macos-clang-x64" "libwebui-2.dylib"
55 | download_and_extract $WINDOWS_MSVC_X64 "webui-windows-msvc-x64" "webui-2.dll"
56 |
57 | # Remove cache folder
58 | echo "* Cleaning..."
59 | rm -rf "cache"
60 | exit 0
61 | fi
62 |
63 | if [[ "$1" == "minimal" ]]; then
64 |
65 | # --- Minimal ----------------------------------
66 | # Download WebUI library for only the current OS.
67 |
68 | # Nightly Build
69 | # BASE_URL="https://github.com/webui-dev/webui/releases/download/nightly/"
70 |
71 | # Release
72 | BASE_URL="https://github.com/webui-dev/webui/releases/download/2.5.0-beta.3/"
73 |
74 | # Detect OS (macOS / Linux)
75 | OS="linux"
76 | CC="gcc"
77 | EXT="so"
78 | if [[ "$OSTYPE" == "darwin"* ]]; then
79 | OS="macos"
80 | CC="clang"
81 | EXT="dylib"
82 | fi
83 |
84 | # Check the CPU architecture
85 | ARCH=$(uname -m)
86 | if [ "$ARCH" = "x86" ]; then
87 | # x86 32Bit
88 | # FILENAME="webui-${OS}-${CC}-x86"
89 | echo "Error: Linux/macOS x86 32Bit architecture is not supported yet"
90 | exit 1
91 | elif [ "$ARCH" = "x86_64" ]; then
92 | # x86 64Bit
93 | FILENAME="webui-${OS}-${CC}-x64"
94 | elif [ "$ARCH" = "arm" ]; then
95 | # ARM 32Bit
96 | FILENAME="webui-${OS}-${CC}-arm"
97 | elif [ "$ARCH" = "aarch64" ]; then
98 | # ARM 64Bit
99 | FILENAME="webui-${OS}-${CC}-arm64"
100 | else
101 | echo "Error: Unknown architecture '$ARCH'"
102 | exit 1
103 | fi
104 |
105 | # Creating the temporary cache folder
106 | mkdir -p "cache/$FILENAME" 2>/dev/null
107 |
108 | # Download the archive using wget
109 | wget -q "$BASE_URL$FILENAME.zip" -O "cache/$FILENAME.zip"
110 |
111 | # Extract archive
112 | unzip -q "cache/$FILENAME.zip" -d "cache"
113 |
114 | # Copy library
115 | mkdir -p "$FILENAME" 2>/dev/null
116 | cp -f "cache/$FILENAME/webui-2.${EXT}" "$FILENAME/webui-2.${EXT}"
117 |
118 | # Remove cache folder
119 | rm -rf "cache"
120 |
121 | exit 0
122 | fi
123 |
--------------------------------------------------------------------------------
/src/bootstrap.bat:
--------------------------------------------------------------------------------
1 | @echo off
2 | SETLOCAL
3 |
4 | :: This script downloads the trusted WebUI compiled library by GitHub CI for Windows.
5 |
6 | IF "%1"=="minimal" (
7 | goto MINIMAL
8 | )
9 |
10 | :: --- Full -------------------------------------
11 | :: Download WebUI library for all supported OS.
12 | echo WebUI Deno Bootstrap
13 | echo.
14 |
15 | :: Creating the temporary cache folder
16 | mkdir "cache" 2>nul 1>nul
17 |
18 | :: Nightly Build
19 | :: SET "LINUX_ARM=https://github.com/webui-dev/webui/releases/download/nightly/webui-linux-gcc-arm.zip"
20 | :: SET "LINUX_ARM64=https://github.com/webui-dev/webui/releases/download/nightly/webui-linux-gcc-arm64.zip"
21 | :: SET "LINUX_X64=https://github.com/webui-dev/webui/releases/download/nightly/webui-linux-gcc-x64.zip"
22 | :: SET "MACOS_ARM64=https://github.com/webui-dev/webui/releases/download/nightly/webui-macos-clang-arm64.zip"
23 | :: SET "MACOS_X64=https://github.com/webui-dev/webui/releases/download/nightly/webui-macos-clang-x64.zip"
24 | :: SET "WINDOWS_MSVC_X64=https://github.com/webui-dev/webui/releases/download/nightly/webui-windows-msvc-x64.zip"
25 |
26 | :: Release
27 | SET "LINUX_ARM=https://github.com/webui-dev/webui/releases/download/2.5.0-beta.3/webui-linux-gcc-arm.zip"
28 | SET "LINUX_ARM64=https://github.com/webui-dev/webui/releases/download/2.5.0-beta.3/webui-linux-gcc-arm64.zip"
29 | SET "LINUX_X64=https://github.com/webui-dev/webui/releases/download/2.5.0-beta.3/webui-linux-gcc-x64.zip"
30 | SET "MACOS_ARM64=https://github.com/webui-dev/webui/releases/download/2.5.0-beta.3/webui-macos-clang-arm64.zip"
31 | SET "MACOS_X64=https://github.com/webui-dev/webui/releases/download/2.5.0-beta.3/webui-macos-clang-x64.zip"
32 | SET "WINDOWS_MSVC_X64=https://github.com/webui-dev/webui/releases/download/2.5.0-beta.3/webui-windows-msvc-x64.zip"
33 |
34 | :: Download and extract archives
35 | CALL :DOWNLOAD_AND_EXTRACT %LINUX_ARM% webui-linux-gcc-arm libwebui-2.so
36 | CALL :DOWNLOAD_AND_EXTRACT %LINUX_ARM64% webui-linux-gcc-arm64 libwebui-2.so
37 | CALL :DOWNLOAD_AND_EXTRACT %LINUX_X64% webui-linux-gcc-x64 libwebui-2.so
38 | CALL :DOWNLOAD_AND_EXTRACT %MACOS_ARM64% webui-macos-clang-arm64 libwebui-2.dylib
39 | CALL :DOWNLOAD_AND_EXTRACT %MACOS_X64% webui-macos-clang-x64 libwebui-2.dylib
40 | CALL :DOWNLOAD_AND_EXTRACT %WINDOWS_MSVC_X64% webui-windows-msvc-x64 webui-2.dll
41 |
42 | :: Remove cache folder
43 | echo * Cleaning...
44 | rmdir /S /Q "cache" 2>nul 1>nul
45 | exit /b
46 |
47 | :: Download and Extract Function
48 | :DOWNLOAD_AND_EXTRACT
49 | echo * Downloading [%1]...
50 | SET FULL_URL=%1
51 | SET FILE_NAME=%2
52 | SET LIB_DYN=%3
53 | SET LIB_STATIC=%4
54 | powershell -Command "Invoke-WebRequest '%FULL_URL%' -OutFile 'cache\%FILE_NAME%.zip'"
55 | echo * Extracting [%FILE_NAME%.zip]...
56 | mkdir "cache\%FILE_NAME%" 2>nul 1>nul
57 | tar -xf "cache\%FILE_NAME%.zip" -C "cache"
58 | IF NOT "%LIB_DYN%"=="" (
59 | :: Copy dynamic library
60 | echo * Copying [%LIB_DYN%]...
61 | mkdir "%FILE_NAME%" 2>nul 1>nul
62 | copy /Y "cache\%FILE_NAME%\%LIB_DYN%" "%FILE_NAME%\%LIB_DYN%" 2>nul 1>nul
63 | )
64 | IF NOT "%LIB_STATIC%"=="" (
65 | :: Copy dynamic library
66 | echo * Copying [%LIB_STATIC%]...
67 | mkdir "%FILE_NAME%" 2>nul 1>nul
68 | copy /Y "cache\%FILE_NAME%\%LIB_STATIC%" "%FILE_NAME%\%LIB_STATIC%" 2>nul 1>nul
69 | )
70 | GOTO :EOF
71 |
72 | :: --- Minimal ----------------------------------
73 | :: Download WebUI library for only the current OS.
74 | :MINIMAL
75 |
76 | SET "BASE_URL=https://github.com/webui-dev/webui/releases/download/2.5.0-beta.3/"
77 |
78 | :: Check the CPU architecture
79 | IF "%PROCESSOR_ARCHITECTURE%"=="x86" (
80 | :: x86 32Bit
81 | :: SET "FILENAME=webui-windows-msvc-x86"
82 | ECHO Error: Windows x86 32Bit architecture is not supported yet
83 | exit /b
84 | ) ELSE IF "%PROCESSOR_ARCHITECTURE%"=="AMD64" (
85 | :: x86 64Bit
86 | SET "FILENAME=webui-windows-msvc-x64"
87 | ) ELSE IF "%PROCESSOR_ARCHITECTURE%"=="ARM" (
88 | :: ARM 32Bit
89 | :: SET "FILENAME=webui-windows-msvc-arm"
90 | ECHO Error: Windows ARM architecture is unsupported yet
91 | exit /b
92 | ) ELSE IF "%PROCESSOR_ARCHITECTURE%"=="ARM64" (
93 | :: ARM 64Bit
94 | :: SET "FILENAME=webui-windows-msvc-arm64"
95 | ECHO Error: Windows ARM64 architecture is unsupported yet
96 | exit /b
97 | ) ELSE (
98 | ECHO Error: Unknown architecture '%PROCESSOR_ARCHITECTURE%'
99 | exit /b
100 | )
101 |
102 | :: Creating the temporary cache folder
103 | mkdir "cache" 2>nul 1>nul
104 | mkdir "cache\%FILENAME%" 2>nul 1>nul
105 |
106 | :: Download the archive using PowerShell
107 | powershell -Command "Invoke-WebRequest '%BASE_URL%%FILENAME%.zip' -OutFile 'cache\%FILENAME%.zip'"
108 |
109 | :: Extract archive (Windows 10 and later)
110 | tar -xf "cache\%FILENAME%.zip" -C "cache"
111 |
112 | :: Copy library
113 | mkdir "%FILENAME%" 2>nul 1>nul
114 | copy /Y "cache\%FILENAME%\webui-2.dll" "%FILENAME%\webui-2.dll" 2>nul 1>nul
115 |
116 | :: Remove cache folder
117 | rmdir /S /Q "cache" 2>nul 1>nul
118 |
119 | ENDLOCAL
120 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | 
4 |
5 | # Deno-WebUI v2.5.13 (Beta)
6 |
7 | [last-commit]: https://img.shields.io/github/last-commit/webui-dev/webui?style=for-the-badge&logo=github&logoColor=C0CAF5&labelColor=414868
8 | [release-version]: https://img.shields.io/github/v/tag/webui-dev/webui?style=for-the-badge&logo=webtrees&logoColor=C0CAF5&labelColor=414868&color=7664C6
9 | [license]: https://img.shields.io/github/license/webui-dev/webui?style=for-the-badge&logo=opensourcehardware&label=License&logoColor=C0CAF5&labelColor=414868&color=8c73cc
10 |
11 | [![][last-commit]](https://github.com/webui-dev/deno-webui/pulse)
12 | [![][release-version]](https://github.com/webui-dev/deno-webui/releases/latest)
13 | [![][license]](https://github.com/webui-dev/deno-webui/blob/main/LICENSE)
14 |
15 | > Use any web browser or WebView as GUI, with your preferred language in the
16 | > backend and modern web technologies in the frontend, all in a lightweight
17 | > portable library.
18 |
19 | 
20 |
21 |