diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6be63bd..fec9185 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -30,14 +30,12 @@ jobs: steps: - name: Clone repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: true - name: Install deno - uses: denoland/setup-deno@v1 - with: - deno-version: v2.x + uses: denoland/setup-deno@v2 - name: install webkit2gtk (Linux) if: startsWith(matrix.os, 'ubuntu') diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 34bcf81..127e8c4 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -8,22 +8,20 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout sources - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Install stable deno - uses: denoland/setup-deno@v1 - with: - deno-version: v2.x + uses: denoland/setup-deno@v2 - name: Run check - run: deno task check + run: deno check mod.ts # TODO: Re-enable these tests # - name: Run test:doc # run: deno task test:doc - name: Run fmt - run: deno task fmt:check + run: deno fmt --check - name: Run lint - run: deno task lint + run: deno lint diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index ebf40ee..6834bba 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -12,6 +12,11 @@ jobs: contents: read id-token: write steps: - - uses: actions/checkout@v4 - - uses: denoland/setup-deno@v1 - - run: deno publish + - name: Clone repository + uses: actions/checkout@v4 + + - name: Install deno + uses: denoland/setup-deno@v2 + + - name: Publish to JSR + run: deno publish diff --git a/LICENSE b/LICENSE index 3ce3392..d4f65b5 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2020-2022 the webview team +Copyright (c) 2020-2025 the webview team Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/deno.json b/deno.json index 42347a3..612362e 100644 --- a/deno.json +++ b/deno.json @@ -1,14 +1,9 @@ { "name": "@webview/webview", - "version": "0.8.1", + "version": "0.9.0", "exports": "./mod.ts", "lock": false, "tasks": { - "check": "deno check mod.ts", - "fmt": "deno fmt", - "fmt:check": "deno fmt --check", - "lint": "deno lint", - "test:doc": "deno test -A --unstable-ffi --doc --import-map test_import_map.json", "build": "deno run -A script/build.ts", "run": "deno task build && export PLUGIN_URL=\"./build/\" && deno run -A --unstable-ffi", "run:fast": "export PLUGIN_URL=\"./build/\" && deno run -A --unstable-ffi" @@ -17,5 +12,5 @@ "fmt": { "exclude": ["webview/"] }, - "imports": { "@denosaurs/plug": "jsr:@denosaurs/plug@^1.0.6" } + "imports": { "@denosaurs/plug": "jsr:@denosaurs/plug@^1.0" } } diff --git a/script/build.ts b/script/build.ts index e15b209..cecc488 100644 --- a/script/build.ts +++ b/script/build.ts @@ -1,23 +1,54 @@ import { $ } from "jsr:@david/dax@0.42.0"; -const { os } = Deno.build; +async function findClangFormat() { + let WEBVIEW_CLANG_FORMAT_EXE = Deno.env.get("WEBVIEW_CLANG_FORMAT_EXE"); + if (WEBVIEW_CLANG_FORMAT_EXE) { + return WEBVIEW_CLANG_FORMAT_EXE; + } + + WEBVIEW_CLANG_FORMAT_EXE = await $.which("clang-format"); + if (WEBVIEW_CLANG_FORMAT_EXE) { + return WEBVIEW_CLANG_FORMAT_EXE; + } + + if (await $.commandExists("brew")) { + const llvm = await $`brew --prefix llvm`.text(); + return `${llvm}/bin/clang-format"`; + } + + $.logError( + "error", + "clang-format not found. Please install clang-format using brew or set the WEBVIEW_CLANG_FORMAT_EXE environment variable.", + ); + Deno.exit(1); +} + $.setPrintCommand(true); await $.path("./build").ensureDir(); -switch (os) { - case "windows": +switch (Deno.build.os) { + case "windows": { await $`script/build.bat`; await $`cp webview/build/core/Release/webview.dll build/webview.dll`; break; - case "linux": + } + case "linux": { $.cd("webview"); await $`export PATH=/usr/lib/llvm14/bin/:/usr/lib/llvm-14/bin/:/usr/lib64/llvm15/bin/:$PATH`; - await $`cmake -G Ninja -B build -S . -D CMAKE_BUILD_TYPE=Release -D WEBVIEW_WEBKITGTK_API=6.0 -DWEBVIEW_ENABLE_CHECKS=false -DCMAKE_TOOLCHAIN_FILE=cmake/toolchains/host-llvm.cmake -DWEBVIEW_USE_CLANG_TIDY=OFF -DWEBVIEW_BUILD_DOCS=OFF -DWEBVIEW_USE_CLANG_FORMAT=OFF`; + await $`cmake -G Ninja -B build -S . \ + -D CMAKE_BUILD_TYPE=Release \ + -D WEBVIEW_WEBKITGTK_API=6.0 \ + -DWEBVIEW_ENABLE_CHECKS=false \ + -DCMAKE_TOOLCHAIN_FILE=cmake/toolchains/host-llvm.cmake \ + -DWEBVIEW_USE_CLANG_TIDY=OFF \ + -DWEBVIEW_BUILD_DOCS=OFF \ + -DWEBVIEW_USE_CLANG_FORMAT=OFF`; await $`cmake --build build`; await $`cp build/core/libwebview.so ../build/libwebview.${Deno.build.arch}.so`; await $`strip ../build/libwebview.${Deno.build.arch}.so`; break; - case "darwin": + } + case "darwin": { $.cd("webview"); await $`cmake -G "Ninja Multi-Config" -B build -S . \ -DCMAKE_BUILD_TYPE=Release \ @@ -28,11 +59,10 @@ switch (os) { -DWEBVIEW_USE_CLANG_TIDY=OFF \ -DWEBVIEW_BUILD_DOCS=OFF \ -DWEBVIEW_USE_CLANG_FORMAT=OFF \ - -DWEBVIEW_CLANG_FORMAT_EXE=${Deno.env.get( - "WEBVIEW_CLANG_FORMAT_EXE", - )!}`; + -DWEBVIEW_CLANG_FORMAT_EXE=${await findClangFormat()}`; await $`cmake --build build --config Release`; await $`cp build/core/Release/libwebview.dylib ../build/libwebview.${Deno.build.arch}.dylib`; await $`strip -x -S ../build/libwebview.${Deno.build.arch}.dylib`; break; + } } diff --git a/test_import_map.json b/test_import_map.json index 09bcc53..036bb80 100644 --- a/test_import_map.json +++ b/test_import_map.json @@ -1,6 +1,6 @@ { "imports": { "@webview/webview": "./mod.ts", - "@denosaurs/plug": "jsr:@denosaurs/plug@^1.0.5" + "@denosaurs/plug": "jsr:@denosaurs/plug@^1.0" } }