Skip to content

Commit

Permalink
Rename package to justbe-webview
Browse files Browse the repository at this point in the history
  • Loading branch information
zephraph committed Feb 19, 2025
1 parent e6db4c5 commit f36cc06
Show file tree
Hide file tree
Showing 11 changed files with 76 additions and 84 deletions.
2 changes: 1 addition & 1 deletion mise.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ description = "Generate the python client"
run = "deno run -A scripts/generate-schema/index.ts --language python"
depends = ["gen:rust"]
sources = ["schemas/*", "scripts/generate-schema.ts"]
outputs = ["src/clients/python/src/webview_python/schemas/*.py"]
outputs = ["src/clients/python/src/justbe_webview/schemas/*.py"]

## Debug

Expand Down
2 changes: 1 addition & 1 deletion scripts/generate-schema/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { parseSchema } from "./parser.ts";
const schemasDir = new URL("../../schemas", import.meta.url).pathname;
const tsSchemaDir = new URL("../../src/clients/deno", import.meta.url).pathname;
const pySchemaDir =
new URL("../../src/clients/python/src/webview_python", import.meta.url)
new URL("../../src/clients/python/src/justbe_webview", import.meta.url)
.pathname;

async function ensureDir(dir: string) {
Expand Down
2 changes: 1 addition & 1 deletion scripts/sync-versions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ await Deno.writeTextFile(denoPath, updatedDenoContent);
console.log(`✓ Updated Deno BIN_VERSION to ${latestVersion}`);

// ===== Update Python Client BIN_VERSION =====
const pythonInitPath = "./src/clients/python/src/webview_python/__init__.py";
const pythonInitPath = "./src/clients/python/src/justbe_webview/__init__.py";
const pythonInitContent = await Deno.readTextFile(pythonInitPath);

const updatedPythonInitContent = pythonInitContent.replace(
Expand Down
11 changes: 5 additions & 6 deletions src/clients/python/examples/ipc.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
# /// script
# requires-python = ">=3.13"
# dependencies = [
# "webview-python",
# "justbe-webview",
# ]
#
# [tool.uv.sources]
# webview-python = { path = "../" }
# justbe-webview = { path = "../" }
# ///
import asyncio

from webview_python import WebView, WebViewOptions, WebViewContentHtml
from webview_python.schemas.WebViewMessage import IpcNotification
from justbe_webview import WebView, Options, ContentHtml, IpcNotification


async def main():
print("Creating webview")
config = WebViewOptions(
config = Options(
title="Simple",
load=WebViewContentHtml(
load=ContentHtml(
html='<button onclick="window.ipc.postMessage(`button clicked ${Date.now()}`)">Click me</button>'
),
ipc=True,
Expand Down
21 changes: 9 additions & 12 deletions src/clients/python/examples/load_html.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
# /// script
# requires-python = ">=3.13"
# dependencies = [
# "webview-python",
# "justbe-webview",
# ]
#
# [tool.uv.sources]
# webview-python = { path = "../" }
# justbe-webview = { path = "../" }
# ///
import sys
import asyncio
from pathlib import Path

from webview_python import (
from justbe_webview import (
WebView,
WebViewOptions,
WebViewContentHtml,
WebViewNotification,
Options,
ContentHtml,
Notification,
)


async def main():
print("Creating webview")
config = WebViewOptions(
config = Options(
title="Load Html Example",
load=WebViewContentHtml(
load=ContentHtml(
html="<h1>Initial html</h1>",
# Note: This origin is used with a custom protocol so it doesn't match
# https://example.com. This doesn't need to be set, but can be useful if
Expand All @@ -36,7 +34,7 @@ async def main():

async with WebView(config) as webview:

async def handle_start(event: WebViewNotification):
async def handle_start(event: Notification):
await webview.open_devtools()
await webview.load_html("<h1>Updated html!</h1>")

Expand All @@ -47,4 +45,3 @@ async def handle_start(event: WebViewNotification):

if __name__ == "__main__":
asyncio.run(main())

22 changes: 9 additions & 13 deletions src/clients/python/examples/load_url.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,27 @@
# /// script
# requires-python = ">=3.13"
# dependencies = [
# "webview-python",
# "justbe-webview",
# ]
#
# [tool.uv.sources]
# webview-python = { path = "../" }
# justbe-webview = { path = "../" }
# ///
import sys
import asyncio
import time
from pathlib import Path

from webview_python import (
from justbe_webview import (
WebView,
WebViewOptions,
WebViewContentUrl,
WebViewNotification,
Options,
ContentUrl,
Notification,
)


async def main():
print("Creating webview")
config = WebViewOptions(
config = Options(
title="Load Url Example",
load=WebViewContentUrl(
load=ContentUrl(
url="https://example.com",
headers={
"Content-Type": "text/html",
Expand All @@ -36,7 +33,7 @@ async def main():

async with WebView(config) as webview:

async def handle_start(event: WebViewNotification):
async def handle_start(event: Notification):
await webview.open_devtools()
await asyncio.sleep(2) # Sleep for 2 seconds
await webview.load_url(
Expand All @@ -53,4 +50,3 @@ async def handle_start(event: WebViewNotification):

if __name__ == "__main__":
asyncio.run(main())

18 changes: 9 additions & 9 deletions src/clients/python/examples/simple.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
# /// script
# requires-python = ">=3.13"
# dependencies = [
# "webview-python",
# "justbe-webview",
# ]
#
# [tool.uv.sources]
# webview-python = { path = "../" }
# justbe-webview = { path = "../" }
# ///
import asyncio

from webview_python import (
from justbe_webview import (
WebView,
WebViewOptions,
WebViewContentHtml,
WebViewNotification,
Options,
ContentHtml,
Notification,
)


async def main():
print("Creating webview")
config = WebViewOptions(
config = Options(
title="Simple",
load=WebViewContentHtml(html="<h1>Hello, World!</h1>"),
load=ContentHtml(html="<h1>Hello, World!</h1>"),
devtools=True,
initializationScript="console.log('This is printed from initializationScript!')",
)

async with WebView(config) as webview:

async def handle_start(event: WebViewNotification):
async def handle_start(event: Notification):
print("handle_start called")
await webview.set_title("Title set from Python")
current_title = await webview.get_title()
Expand Down
13 changes: 6 additions & 7 deletions src/clients/python/examples/window_size.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
# /// script
# requires-python = ">=3.13"
# dependencies = [
# "webview-python",
# "justbe-webview",
# ]
#
# [tool.uv.sources]
# webview-python = { path = "../" }
# justbe-webview = { path = "../" }
# ///
import asyncio

from webview_python import WebView, WebViewOptions, WebViewContentHtml, IpcNotification
from justbe_webview import WebView, Options, ContentHtml, IpcNotification, Size


async def main():
print("Creating webview")
config = WebViewOptions(
config = Options(
title="Window Size",
load=WebViewContentHtml(
load=ContentHtml(
html="""
<h1>Window Sizes</h1>
<div style="display: flex; gap: 10px;">
Expand All @@ -26,7 +26,7 @@ async def main():
</div>
"""
),
size={"width": 800, "height": 200},
size=Size(width=800, height=200),
ipc=True,
)

Expand All @@ -50,4 +50,3 @@ async def handle_ipc(event: IpcNotification):

if __name__ == "__main__":
asyncio.run(main())

6 changes: 3 additions & 3 deletions src/clients/python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "webview-python"
version = "0.1.0"
description = "Add your description here"
name = "justbe-webview"
version = "0.0.1"
description = "A simple webview client"
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
Expand Down
63 changes: 32 additions & 31 deletions src/clients/python/uv.lock

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

0 comments on commit f36cc06

Please sign in to comment.