Skip to content

Commit ec9db38

Browse files
authored
Merge pull request #82 from sigmaSd/main
Upgrade codebase
2 parents d349a44 + e428f30 commit ec9db38

File tree

19 files changed

+621
-431
lines changed

19 files changed

+621
-431
lines changed

.github/workflows/deno.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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 type checker
40+
if: runner.os == 'Linux'
41+
run: deno check .

.github/workflows/publish-jsr.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Publish
2+
on:
3+
push:
4+
branches:
5+
- main
6+
7+
jobs:
8+
publish:
9+
runs-on: ubuntu-latest
10+
11+
permissions:
12+
contents: read
13+
id-token: write
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: Publish package
19+
run: npx jsr publish

.zed/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"format_on_save": "on"
3+
}

README.md

Lines changed: 49 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
![Logo](https://raw.githubusercontent.com/webui-dev/webui-logo/main/webui_deno.png)
44

5-
# Deno-WebUI v2.5.3 (Beta)
5+
# Deno-WebUI v2.5.4 (Beta)
66

77
[last-commit]: https://img.shields.io/github/last-commit/webui-dev/webui?style=for-the-badge&logo=github&logoColor=C0CAF5&labelColor=414868
88
[release-version]: https://img.shields.io/github/v/tag/webui-dev/webui?style=for-the-badge&logo=webtrees&logoColor=C0CAF5&labelColor=414868&color=7664C6
@@ -12,7 +12,9 @@
1212
[![][release-version]](https://github.com/webui-dev/deno-webui/releases/latest)
1313
[![][license]](https://github.com/webui-dev/deno-webui/blob/main/LICENSE)
1414

15-
> Use any web browser or WebView as GUI, with your preferred language in the backend and modern web technologies in the frontend, all in a lightweight portable library.
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.
1618
1719
![Screenshot](https://raw.githubusercontent.com/webui-dev/webui-logo/main/screenshot.png)
1820

@@ -24,30 +26,43 @@
2426

2527
## Features
2628

27-
- Portable (*Needs only a web browser or a WebView at runtime*)
28-
- Lightweight (*Few Kb library*) & Small memory footprint
29+
- Portable (_Needs only a web browser or a WebView at runtime_)
30+
- Lightweight (_Few Kb library_) & Small memory footprint
2931
- Fast binary communication protocol
3032
- Multi-platform & Multi-Browser
3133
- Using private profile for safety
3234
- Cross-platform WebView
3335

3436
## Screenshot
3537

36-
This [hello world example](https://github.com/webui-dev/deno-webui/tree/main/examples/hello_world)
38+
This
39+
[hello world example](https://github.com/webui-dev/deno-webui/tree/main/examples/hello_world)
3740
is written in Deno using WebUI as the GUI library.
3841

3942
![ScreenShot](img/webui_deno_example.png)
4043

4144
## Installation
4245

43-
Specific version: `import { WebUI } from "https://deno.land/x/[email protected]/mod.ts";`
46+
Specific version:
4447

45-
Latest version: `import { WebUI } from "https://deno.land/x/webui/mod.ts";`
48+
```js
49+
import { WebUI } from "@webui/[email protected]";
50+
// Or
51+
import { WebUI } from "https://deno.land/x/[email protected]/mod.ts";
52+
```
53+
54+
Latest version:
55+
56+
```js
57+
import { WebUI } from "jsr:@webui/deno-webui";
58+
// Or
59+
import { WebUI } from "https://deno.land/x/webui/mod.ts";
60+
```
4661

4762
## Minimal Example
4863

4964
```js
50-
import { WebUI } from "https://deno.land/x/webui@2.5.3/mod.ts";
65+
import { WebUI } from "jsr:@webui/deno-webui";
5166

5267
const myWindow = new WebUI();
5368
myWindow.show('<html><script src="webui.js"></script> Hello World! </html>');
@@ -132,35 +147,35 @@ browser**.
132147

133148
## Supported Languages
134149

135-
| Language | v2.4.0 API | v2.5.0 API | Link |
136-
| --------------- | --- | -------------- | --------------------------------------------------------- |
137-
| Python | ✔️ | _not complete_ | [Python-WebUI](https://github.com/webui-dev/python-webui) |
138-
| Go | ✔️ | _not complete_ | [Go-WebUI](https://github.com/webui-dev/go-webui) |
139-
| Zig | ✔️ | _not complete_ | [Zig-WebUI](https://github.com/webui-dev/zig-webui) |
140-
| Nim | ✔️ | _not complete_ | [Nim-WebUI](https://github.com/webui-dev/nim-webui) |
141-
| V | ✔️ | _not complete_ | [V-WebUI](https://github.com/webui-dev/v-webui) |
142-
| Rust | _not complete_ | _not complete_ | [Rust-WebUI](https://github.com/webui-dev/rust-webui) |
143-
| TS / JS (Deno) | ✔️ | _not complete_ | [Deno-WebUI](https://github.com/webui-dev/deno-webui) |
144-
| TS / JS (Bun) | _not complete_ | _not complete_ | [Bun-WebUI](https://github.com/webui-dev/bun-webui) |
145-
| Swift | _not complete_ | _not complete_ | [Swift-WebUI](https://github.com/webui-dev/swift-webui) |
146-
| Odin | _not complete_ | _not complete_ | [Odin-WebUI](https://github.com/webui-dev/odin-webui) |
147-
| Pascal | _not complete_ | _not complete_ | [Pascal-WebUI](https://github.com/webui-dev/pascal-webui) |
148-
| Purebasic | _not complete_ | _not complete_ | [Purebasic-WebUI](https://github.com/webui-dev/purebasic-webui)|
149-
| - | | |
150-
| Common Lisp | _not complete_ | _not complete_ | [cl-webui](https://github.com/garlic0x1/cl-webui) |
151-
| Delphi | _not complete_ | _not complete_ | [WebUI4Delphi](https://github.com/salvadordf/WebUI4Delphi) |
152-
| C# | _not complete_ | _not complete_ | [WebUI4CSharp](https://github.com/salvadordf/WebUI4CSharp) |
153-
| WebUI.NET | _not complete_ | _not complete_ | [WebUI.NET](https://github.com/Juff-Ma/WebUI.NET) |
154-
| QuickJS | _not complete_ | _not complete_ | [QuickUI](https://github.com/xland/QuickUI) |
155-
| PHP | _not complete_ | _not complete_ | [PHPWebUiComposer](https://github.com/KingBes/php-webui-composer) |
150+
| Language | v2.4.0 API | v2.5.0 API | Link |
151+
| -------------- | -------------- | -------------- | ----------------------------------------------------------------- |
152+
| Python | ✔️ | _not complete_ | [Python-WebUI](https://github.com/webui-dev/python-webui) |
153+
| Go | ✔️ | _not complete_ | [Go-WebUI](https://github.com/webui-dev/go-webui) |
154+
| Zig | ✔️ | _not complete_ | [Zig-WebUI](https://github.com/webui-dev/zig-webui) |
155+
| Nim | ✔️ | _not complete_ | [Nim-WebUI](https://github.com/webui-dev/nim-webui) |
156+
| V | ✔️ | _not complete_ | [V-WebUI](https://github.com/webui-dev/v-webui) |
157+
| Rust | _not complete_ | _not complete_ | [Rust-WebUI](https://github.com/webui-dev/rust-webui) |
158+
| TS / JS (Deno) | ✔️ | _not complete_ | [Deno-WebUI](https://github.com/webui-dev/deno-webui) |
159+
| TS / JS (Bun) | _not complete_ | _not complete_ | [Bun-WebUI](https://github.com/webui-dev/bun-webui) |
160+
| Swift | _not complete_ | _not complete_ | [Swift-WebUI](https://github.com/webui-dev/swift-webui) |
161+
| Odin | _not complete_ | _not complete_ | [Odin-WebUI](https://github.com/webui-dev/odin-webui) |
162+
| Pascal | _not complete_ | _not complete_ | [Pascal-WebUI](https://github.com/webui-dev/pascal-webui) |
163+
| Purebasic | _not complete_ | _not complete_ | [Purebasic-WebUI](https://github.com/webui-dev/purebasic-webui) |
164+
| - | | | |
165+
| Common Lisp | _not complete_ | _not complete_ | [cl-webui](https://github.com/garlic0x1/cl-webui) |
166+
| Delphi | _not complete_ | _not complete_ | [WebUI4Delphi](https://github.com/salvadordf/WebUI4Delphi) |
167+
| C# | _not complete_ | _not complete_ | [WebUI4CSharp](https://github.com/salvadordf/WebUI4CSharp) |
168+
| WebUI.NET | _not complete_ | _not complete_ | [WebUI.NET](https://github.com/Juff-Ma/WebUI.NET) |
169+
| QuickJS | _not complete_ | _not complete_ | [QuickUI](https://github.com/xland/QuickUI) |
170+
| PHP | _not complete_ | _not complete_ | [PHPWebUiComposer](https://github.com/KingBes/php-webui-composer) |
156171

157172
## Supported WebView
158173

159-
| WebView | Status |
160-
| --------------- | --------------- |
161-
| Windows WebView2 | ✔️ |
162-
| Linux GTK WebView | ✔️ |
163-
| macOS WKWebView | ✔️ |
174+
| WebView | Status |
175+
| ----------------- | ------ |
176+
| Windows WebView2 | ✔️ |
177+
| Linux GTK WebView | ✔️ |
178+
| macOS WKWebView | ✔️ |
164179

165180
### License
166181

deno.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "@webui/deno-webui",
3+
"version": "2.5.4",
4+
"exports": "./mod.ts"
5+
}

deps.ts

Lines changed: 38 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,102 +1,52 @@
11
// Deno WebUI
2-
// Dependences needed by webui.ts
2+
// Resolves the path to the required native WebUI library,
3+
// ensuring it is downloaded to a central cache if needed.
34

4-
import {
5-
fileExists,
6-
downloadCoreLibrary,
7-
currentModulePath
8-
} from "./src/utils.ts";
5+
import { ensureWebUiLib, useNightly } from "./src/utils.ts";
96

10-
// Determine the library name based
11-
// on the current operating system
12-
async function getLibName() {
13-
let fileName = "";
14-
let localFileName = "";
7+
// Determine the base library filename based
8+
// on the current operating system and architecture.
9+
function getBaseLibName(): string {
10+
let baseName: string;
1511
switch (Deno.build.os) {
1612
case "windows":
17-
switch (Deno.build.arch) {
18-
case "x86_64":
19-
fileName = "webui-windows-msvc-x64/webui-2.dll";
20-
localFileName = "./webui-2.dll";
21-
break;
22-
// case "arm":
23-
// fileName = "webui-windows-msvc-arm/webui-2.dll";
24-
// localFileName = "./webui-2.dll";
25-
// break;
26-
// case "arm64":
27-
case "aarch64":
28-
fileName = "webui-windows-msvc-arm64/webui-2.dll";
29-
localFileName = "./webui-2.dll";
30-
break;
31-
default:
32-
throw new Error(
33-
`Unsupported architecture ${Deno.build.arch} for Windows`,
34-
);
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+
);
3519
}
3620
break;
37-
case "darwin":
38-
switch (Deno.build.arch) {
39-
case "x86_64":
40-
fileName = "webui-macos-clang-x64/libwebui-2.dylib";
41-
localFileName = "./libwebui-2.dylib";
42-
break;
43-
// case "arm":
44-
// fileName = "webui-macos-clang-arm/libwebui-2.dylib";
45-
// localFileName = "./libwebui-2.dylib";
46-
// break;
47-
// case "arm64":
48-
case "aarch64":
49-
fileName = "webui-macos-clang-arm64/libwebui-2.dylib";
50-
localFileName = "./libwebui-2.dylib";
51-
break;
52-
default:
53-
throw new Error(
54-
`Unsupported architecture ${Deno.build.arch} for macOS`,
55-
);
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+
);
5628
}
5729
break;
58-
default:
59-
// Linux
60-
// freebsd
61-
// netbsd
62-
// aix
63-
// solaris
64-
// illumos
65-
switch (Deno.build.arch) {
66-
case "x86_64":
67-
fileName = "webui-linux-gcc-x64/libwebui-2.so";
68-
localFileName = "./libwebui-2.so";
69-
break;
70-
// case "arm":
71-
// fileName = "webui-linux-gcc-arm/libwebui-2.so";
72-
// localFileName = "./libwebui-2.so";
73-
// break;
74-
// case "arm64":
75-
case "aarch64":
76-
fileName = "webui-linux-gcc-arm64/libwebui-2.so";
77-
localFileName = "./libwebui-2.so";
78-
break;
79-
default:
80-
throw new Error(
81-
`Unsupported architecture ${Deno.build.arch} for ${Deno.build.os}`,
82-
);
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+
);
8337
}
8438
break;
8539
}
86-
// Check if local file exisit
87-
const localExists = await fileExists(localFileName);
88-
if (localExists)
89-
return localFileName;
90-
// Get the current module full path
91-
const srcFullPath = currentModulePath;
92-
const FullPath = srcFullPath + fileName;
93-
// Check if WebUI library exist
94-
const exists = await fileExists(FullPath);
95-
if (!exists) {
96-
// Download the WebUI library
97-
await downloadCoreLibrary();
98-
}
99-
return FullPath;
40+
return baseName;
10041
}
10142

102-
export const libName = await getLibName();
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 };
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
// deno-lint-ignore no-unused-vars
22
function test_app() {
3-
alert('Hello from test_app.js');
3+
alert("Hello from test_app.js");
44
}

0 commit comments

Comments
 (0)