From f4a8bf085a3312a1a0faf0f2583231275a6e311a Mon Sep 17 00:00:00 2001 From: Justin Bennett Date: Wed, 25 Sep 2024 10:35:19 -0400 Subject: [PATCH] Add tldraw example (#55) * Add tldraw example * Drop devtools --- deno.json | 5 +- deno.lock | 126 +++++++++++++++++++++++++++++++++++++++++++++ examples/tldraw.ts | 60 +++++++++++++++++++++ 3 files changed, 189 insertions(+), 2 deletions(-) create mode 100644 examples/tldraw.ts diff --git a/deno.json b/deno.json index 22d8c0c..6e3dc4b 100644 --- a/deno.json +++ b/deno.json @@ -8,9 +8,10 @@ "gen:rust": "cargo test", "gen:deno": "deno run -A scripts/generate-schema.ts && deno run -A scripts/sync-versions.ts", "build": "deno task gen && cargo build -F transparent -F devtools", - "run": "export WEBVIEW_BIN=./target/debug/deno-webview && deno run -E=WEBVIEW_BIN --allow-run=$WEBVIEW_BIN", + "run": "export WEBVIEW_BIN=./target/debug/deno-webview && deno run -E -R --allow-run", "example:simple": "deno task run examples/simple.ts", - "example:ipc": "deno task run examples/ipc.ts" + "example:ipc": "deno task run examples/ipc.ts", + "example:tldraw": "deno task run examples/tldraw.ts" }, "publish": { "include": ["README.md", "LICENSE", "src/**/*.ts"] diff --git a/deno.lock b/deno.lock index 1482739..6708c22 100644 --- a/deno.lock +++ b/deno.lock @@ -24,6 +24,7 @@ "npm:@types/json-schema": "npm:@types/json-schema@7.0.15", "npm:@types/node": "npm:@types/node@18.16.19", "npm:effection": "npm:effection@3.0.3", + "npm:esbuild": "npm:esbuild@0.23.1", "npm:json-schema-to-zod": "npm:json-schema-to-zod@2.4.1", "npm:ts-pattern": "npm:ts-pattern@5.0.6", "npm:type-fest": "npm:type-fest@4.25.0", @@ -101,6 +102,102 @@ } }, "npm": { + "@esbuild/aix-ppc64@0.23.1": { + "integrity": "sha512-6VhYk1diRqrhBAqpJEdjASR/+WVRtfjpqKuNw11cLiaWpAT/Uu+nokB+UJnevzy/P9C/ty6AOe0dwueMrGh/iQ==", + "dependencies": {} + }, + "@esbuild/android-arm64@0.23.1": { + "integrity": "sha512-xw50ipykXcLstLeWH7WRdQuysJqejuAGPd30vd1i5zSyKK3WE+ijzHmLKxdiCMtH1pHz78rOg0BKSYOSB/2Khw==", + "dependencies": {} + }, + "@esbuild/android-arm@0.23.1": { + "integrity": "sha512-uz6/tEy2IFm9RYOyvKl88zdzZfwEfKZmnX9Cj1BHjeSGNuGLuMD1kR8y5bteYmwqKm1tj8m4cb/aKEorr6fHWQ==", + "dependencies": {} + }, + "@esbuild/android-x64@0.23.1": { + "integrity": "sha512-nlN9B69St9BwUoB+jkyU090bru8L0NA3yFvAd7k8dNsVH8bi9a8cUAUSEcEEgTp2z3dbEDGJGfP6VUnkQnlReg==", + "dependencies": {} + }, + "@esbuild/darwin-arm64@0.23.1": { + "integrity": "sha512-YsS2e3Wtgnw7Wq53XXBLcV6JhRsEq8hkfg91ESVadIrzr9wO6jJDMZnCQbHm1Guc5t/CdDiFSSfWP58FNuvT3Q==", + "dependencies": {} + }, + "@esbuild/darwin-x64@0.23.1": { + "integrity": "sha512-aClqdgTDVPSEGgoCS8QDG37Gu8yc9lTHNAQlsztQ6ENetKEO//b8y31MMu2ZaPbn4kVsIABzVLXYLhCGekGDqw==", + "dependencies": {} + }, + "@esbuild/freebsd-arm64@0.23.1": { + "integrity": "sha512-h1k6yS8/pN/NHlMl5+v4XPfikhJulk4G+tKGFIOwURBSFzE8bixw1ebjluLOjfwtLqY0kewfjLSrO6tN2MgIhA==", + "dependencies": {} + }, + "@esbuild/freebsd-x64@0.23.1": { + "integrity": "sha512-lK1eJeyk1ZX8UklqFd/3A60UuZ/6UVfGT2LuGo3Wp4/z7eRTRYY+0xOu2kpClP+vMTi9wKOfXi2vjUpO1Ro76g==", + "dependencies": {} + }, + "@esbuild/linux-arm64@0.23.1": { + "integrity": "sha512-/93bf2yxencYDnItMYV/v116zff6UyTjo4EtEQjUBeGiVpMmffDNUyD9UN2zV+V3LRV3/on4xdZ26NKzn6754g==", + "dependencies": {} + }, + "@esbuild/linux-arm@0.23.1": { + "integrity": "sha512-CXXkzgn+dXAPs3WBwE+Kvnrf4WECwBdfjfeYHpMeVxWE0EceB6vhWGShs6wi0IYEqMSIzdOF1XjQ/Mkm5d7ZdQ==", + "dependencies": {} + }, + "@esbuild/linux-ia32@0.23.1": { + "integrity": "sha512-VTN4EuOHwXEkXzX5nTvVY4s7E/Krz7COC8xkftbbKRYAl96vPiUssGkeMELQMOnLOJ8k3BY1+ZY52tttZnHcXQ==", + "dependencies": {} + }, + "@esbuild/linux-loong64@0.23.1": { + "integrity": "sha512-Vx09LzEoBa5zDnieH8LSMRToj7ir/Jeq0Gu6qJ/1GcBq9GkfoEAoXvLiW1U9J1qE/Y/Oyaq33w5p2ZWrNNHNEw==", + "dependencies": {} + }, + "@esbuild/linux-mips64el@0.23.1": { + "integrity": "sha512-nrFzzMQ7W4WRLNUOU5dlWAqa6yVeI0P78WKGUo7lg2HShq/yx+UYkeNSE0SSfSure0SqgnsxPvmAUu/vu0E+3Q==", + "dependencies": {} + }, + "@esbuild/linux-ppc64@0.23.1": { + "integrity": "sha512-dKN8fgVqd0vUIjxuJI6P/9SSSe/mB9rvA98CSH2sJnlZ/OCZWO1DJvxj8jvKTfYUdGfcq2dDxoKaC6bHuTlgcw==", + "dependencies": {} + }, + "@esbuild/linux-riscv64@0.23.1": { + "integrity": "sha512-5AV4Pzp80fhHL83JM6LoA6pTQVWgB1HovMBsLQ9OZWLDqVY8MVobBXNSmAJi//Csh6tcY7e7Lny2Hg1tElMjIA==", + "dependencies": {} + }, + "@esbuild/linux-s390x@0.23.1": { + "integrity": "sha512-9ygs73tuFCe6f6m/Tb+9LtYxWR4c9yg7zjt2cYkjDbDpV/xVn+68cQxMXCjUpYwEkze2RcU/rMnfIXNRFmSoDw==", + "dependencies": {} + }, + "@esbuild/linux-x64@0.23.1": { + "integrity": "sha512-EV6+ovTsEXCPAp58g2dD68LxoP/wK5pRvgy0J/HxPGB009omFPv3Yet0HiaqvrIrgPTBuC6wCH1LTOY91EO5hQ==", + "dependencies": {} + }, + "@esbuild/netbsd-x64@0.23.1": { + "integrity": "sha512-aevEkCNu7KlPRpYLjwmdcuNz6bDFiE7Z8XC4CPqExjTvrHugh28QzUXVOZtiYghciKUacNktqxdpymplil1beA==", + "dependencies": {} + }, + "@esbuild/openbsd-arm64@0.23.1": { + "integrity": "sha512-3x37szhLexNA4bXhLrCC/LImN/YtWis6WXr1VESlfVtVeoFJBRINPJ3f0a/6LV8zpikqoUg4hyXw0sFBt5Cr+Q==", + "dependencies": {} + }, + "@esbuild/openbsd-x64@0.23.1": { + "integrity": "sha512-aY2gMmKmPhxfU+0EdnN+XNtGbjfQgwZj43k8G3fyrDM/UdZww6xrWxmDkuz2eCZchqVeABjV5BpildOrUbBTqA==", + "dependencies": {} + }, + "@esbuild/sunos-x64@0.23.1": { + "integrity": "sha512-RBRT2gqEl0IKQABT4XTj78tpk9v7ehp+mazn2HbUeZl1YMdaGAQqhapjGTCe7uw7y0frDi4gS0uHzhvpFuI1sA==", + "dependencies": {} + }, + "@esbuild/win32-arm64@0.23.1": { + "integrity": "sha512-4O+gPR5rEBe2FpKOVyiJ7wNDPA8nGzDuJ6gN4okSA1gEOYZ67N8JPk58tkWtdtPeLz7lBnY6I5L3jdsr3S+A6A==", + "dependencies": {} + }, + "@esbuild/win32-ia32@0.23.1": { + "integrity": "sha512-BcaL0Vn6QwCwre3Y717nVHZbAa4UBEigzFm6VdsVdT/MbZ38xoj1X9HPkZhbmaBGUD1W8vxAfffbDe8bA6AKnQ==", + "dependencies": {} + }, + "@esbuild/win32-x64@0.23.1": { + "integrity": "sha512-BHpFFeslkWrXWyUPnbKm+xYYVYruCinGcftSBaa8zoF9hZO4BcSCFUvHVTtzpIY6YzUnYtuEhZ+C9iEXjxnasg==", + "dependencies": {} + }, "@types/json-schema@7.0.15": { "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", "dependencies": {} @@ -113,6 +210,35 @@ "integrity": "sha512-9ASCaJ44flDoEKUUJtn9drfIomn2z30sZUw7//crbq+eltMu09AyILcouXwpMkcHR8TsD5hDvTTsOLHswWRxXQ==", "dependencies": {} }, + "esbuild@0.23.1": { + "integrity": "sha512-VVNz/9Sa0bs5SELtn3f7qhJCDPCF5oMEl5cO9/SSinpE9hbPVvxbd572HH5AKiP7WD8INO53GgfDDhRjkylHEg==", + "dependencies": { + "@esbuild/aix-ppc64": "@esbuild/aix-ppc64@0.23.1", + "@esbuild/android-arm": "@esbuild/android-arm@0.23.1", + "@esbuild/android-arm64": "@esbuild/android-arm64@0.23.1", + "@esbuild/android-x64": "@esbuild/android-x64@0.23.1", + "@esbuild/darwin-arm64": "@esbuild/darwin-arm64@0.23.1", + "@esbuild/darwin-x64": "@esbuild/darwin-x64@0.23.1", + "@esbuild/freebsd-arm64": "@esbuild/freebsd-arm64@0.23.1", + "@esbuild/freebsd-x64": "@esbuild/freebsd-x64@0.23.1", + "@esbuild/linux-arm": "@esbuild/linux-arm@0.23.1", + "@esbuild/linux-arm64": "@esbuild/linux-arm64@0.23.1", + "@esbuild/linux-ia32": "@esbuild/linux-ia32@0.23.1", + "@esbuild/linux-loong64": "@esbuild/linux-loong64@0.23.1", + "@esbuild/linux-mips64el": "@esbuild/linux-mips64el@0.23.1", + "@esbuild/linux-ppc64": "@esbuild/linux-ppc64@0.23.1", + "@esbuild/linux-riscv64": "@esbuild/linux-riscv64@0.23.1", + "@esbuild/linux-s390x": "@esbuild/linux-s390x@0.23.1", + "@esbuild/linux-x64": "@esbuild/linux-x64@0.23.1", + "@esbuild/netbsd-x64": "@esbuild/netbsd-x64@0.23.1", + "@esbuild/openbsd-arm64": "@esbuild/openbsd-arm64@0.23.1", + "@esbuild/openbsd-x64": "@esbuild/openbsd-x64@0.23.1", + "@esbuild/sunos-x64": "@esbuild/sunos-x64@0.23.1", + "@esbuild/win32-arm64": "@esbuild/win32-arm64@0.23.1", + "@esbuild/win32-ia32": "@esbuild/win32-ia32@0.23.1", + "@esbuild/win32-x64": "@esbuild/win32-x64@0.23.1" + } + }, "json-schema-to-zod@2.4.1": { "integrity": "sha512-aMoez9TxgnfLAIZaWTPaQ+j7rOt1K9Ew/TBI85XcnhcFlo/47b1MDgpi4r07XndLSZWOX/KsJiRJvhdzSvo2Dw==", "dependencies": {} diff --git a/examples/tldraw.ts b/examples/tldraw.ts new file mode 100644 index 0000000..56be198 --- /dev/null +++ b/examples/tldraw.ts @@ -0,0 +1,60 @@ +import { createWebView } from "../src/lib.ts"; +import * as esbuild from "npm:esbuild"; + +const tldrawApp = ` +import { Tldraw } from "tldraw"; +import { createRoot } from "react-dom/client"; + +function App() { + return ( + <> +
+ +
+ + ); +} + +createRoot(document.querySelector("main")).render(); +`; + +const app = await esbuild.transform(tldrawApp, { + loader: "jsx", + jsx: "automatic", + target: "esnext", + format: "esm", + minify: false, + sourcemap: false, +}); + +const webview = await createWebView({ + title: "TLDraw", + html: ` + + + + + + + + + +
+ + + + + `, +}); + +await webview.waitUntilClosed();