Skip to content

Commit

Permalink
Prepare Deno Client for v1.0.0-rc release (#131)
Browse files Browse the repository at this point in the history
* Update sync-versions script to also work on py client

* Bump binary to 0.2.0

* Prepare for the 1.0.0-rc.1 release
  • Loading branch information
zephraph authored Feb 18, 2025
1 parent 9f72aa1 commit d4ddde3
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 20 deletions.
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
# Changelog

## 1.0.0-rc.1 Deno Client; 0.2.0 binary -- 2025-02-17

- Added new logging that can be triggered with the `LOG_LEVEL` environment variable

- [BREAKING] Changed some typenames/zod schemas not to include `Webview` in the name.
- [BREAKING] Updated code generation to support multiple clients which necessitated a breaking change for the Deno client.

```diff
using webview = await createWebView({
title: "Simple",
devtools: true,
+ load: {
html: "<h1>Hello, World!</h1>",
+ },
initializationScript:
"console.log('This is printed from initializationScript!')",
});
```
`html` or `url` must be wrapped in an object and passed to `load`.

## 0.0.17 (binary 0.1.14) -- 2024-10-02

- Add `webview.loadUrl` to load a new URL after the webview is initialized
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "webview"
version = "0.1.14"
version = "0.2.0"
edition = "2021"

[profile.release]
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ When executing this package, it checks to see if you have the required binary fo
This will be true of a first run of the package. These are the following permission requests you can expect to see:

- Read HOME env -- Used to locate the cache directory
- Read <cache>/deno-webview/deno-webview-<version> -- Tries to read the binary from cache
- Read <cache>/webview/webview-<version> -- Tries to read the binary from cache
- net to github.com:443 -- Connects to GitHub releases to try to download the binary (will be redirected)
- net to objects.githubusercontent.com:443 -- GitHub's CDN for the actual download
- Read <cache>/deno-webview/ -- Reads the cache directory
- Write <cache>/deno-webview/deno-webview-<version> -- Writes the binary
- Run <cache>/deno-webview/deno-webview-<version> -- Runs the binary
- Read <cache>/webview/ -- Reads the cache directory
- Write <cache>/webview/webview-<version> -- Writes the binary
- Run <cache>/webview/webview-<version> -- Runs the binary

### Binary cached

Expand Down
35 changes: 26 additions & 9 deletions scripts/sync-versions.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,42 @@
/**
* Keeps the version of the WebView binary in sync with the version in Cargo.toml.
* Synchronizes version numbers across the project:
* - Updates BIN_VERSION in Deno client (main.ts)
* - Updates package version in Python client (pyproject.toml)
* - Updates BIN_VERSION in Python client (__init__.py)
*
* All versions are synchronized with the main version from Cargo.toml
*/

import { parse } from "jsr:@std/toml";

// Read the source version from Cargo.toml
const latestVersion = await Deno
.readTextFile("./Cargo.toml").then((text) =>
parse(text) as { package: { version: string } }
).then((config) => config.package.version);

// Read the content of src/lib.ts
const libPath = "./src/clients/deno/main.ts";
const libContent = await Deno.readTextFile(libPath);
// ===== Update Deno Client Version =====
const denoPath = "./src/clients/deno/main.ts";
const denoContent = await Deno.readTextFile(denoPath);

// Replace the version in the URL
const updatedContent = libContent.replace(
const updatedDenoContent = denoContent.replace(
/const BIN_VERSION = "[^"]+"/,
`const BIN_VERSION = "${latestVersion}"`,
);

// Write the updated content back to src/lib.ts
await Deno.writeTextFile(libPath, updatedContent);
await Deno.writeTextFile(denoPath, updatedDenoContent);
console.log(`✓ Updated Deno BIN_VERSION to ${latestVersion}`);

console.log(`Updated WebView binary version to ${latestVersion} in src/lib.ts`);
// ===== Update Python Client BIN_VERSION =====
const pythonInitPath = "./src/clients/python/src/webview_python/__init__.py";
const pythonInitContent = await Deno.readTextFile(pythonInitPath);

const updatedPythonInitContent = pythonInitContent.replace(
/BIN_VERSION = "[^"]+"/,
`BIN_VERSION = "${latestVersion}"`,
);

await Deno.writeTextFile(pythonInitPath, updatedPythonInitContent);
console.log(`✓ Updated Python BIN_VERSION to ${latestVersion}`);

console.log(`\n🎉 Successfully synchronized all versions to ${latestVersion}`);
2 changes: 1 addition & 1 deletion src/clients/deno/deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@justbe/webview",
"exports": "./main.ts",
"license": "MIT",
"version": "0.0.17",
"version": "1.0.0-rc.1",
"publish": {
"include": ["README.md", "LICENSE", "*.ts", "schemas/*.ts"]
},
Expand Down
6 changes: 3 additions & 3 deletions src/clients/deno/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ import { ensureDir, exists } from "jsr:@std/fs";
import { error, FmtSubscriber, instrument, Level, trace, warn } from "tracing";
import { match, P } from "ts-pattern";

export * from "./schemas.ts";

if (
Deno.permissions.querySync({ name: "env", variable: "LOG_LEVEL" }).state ===
"granted"
Expand All @@ -51,11 +53,9 @@ if (
FmtSubscriber.setGlobalDefault({ level, color: true });
}

export * from "./schemas.ts";

// Should match the cargo package version
/** The version of the webview binary that's expected */
export const BIN_VERSION = "0.1.14";
export const BIN_VERSION = "0.2.0";

type WebViewNotification = Extract<
Message,
Expand Down
2 changes: 1 addition & 1 deletion src/clients/python/src/webview_python/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
)

# Constants
BIN_VERSION = "0.1.14"
BIN_VERSION = "0.2.0"

T = TypeVar("T", bound=WebViewNotification)

Expand Down

0 comments on commit d4ddde3

Please sign in to comment.