create-webview2-bridge 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ishibashi0112
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # create-webview2-bridge
2
+
3
+ Scaffold a **WinForms (VB.NET / .NET Framework 4.8) + WebView2 + Vite/React** app wired with
4
+ [webview2-bridge](https://github.com/ishibashi0112/webview2-bridge): one zod contract, generated TypeScript types and
5
+ VB.NET DTO / Interface / Dispatcher, and a JSON-RPC bridge over `postMessage`.
6
+
7
+ ```sh
8
+ pnpm create webview2-bridge my-app --name MyInventory
9
+ # or: npm create webview2-bridge my-app -- --name MyInventory
10
+ # or: npx create-webview2-bridge my-app --name MyInventory
11
+
12
+ cd my-app
13
+ pnpm install
14
+ pnpm gen:check # generated files match the bundled generator
15
+ pnpm dev # http://localhost:5173 in a plain browser (mock transport)
16
+ ```
17
+
18
+ On Windows, run the WinForms host against the dev server:
19
+
20
+ ```bat
21
+ set WEBVIEW2_BRIDGE_DEV_URL=http://localhost:5173
22
+ dotnet run --project dotnet/MyInventory.Host
23
+ ```
24
+
25
+ This is a thin alias for `webview2-bridge-gen init` from
26
+ [`@ishibashi0112/webview2-bridge-gen`](https://www.npmjs.com/package/@ishibashi0112/webview2-bridge-gen), which
27
+ documents the generator, the contract format and the VB.NET runtime. `--name` becomes the VB namespace and project
28
+ names (PascalCase; defaults to the directory name). The generated README walks through the dev loop and the Windows checks.
29
+
30
+ Requires Node.js 20.19+, pnpm (or npm) and, for the VB side, the .NET SDK 8+ and the WebView2 Runtime.
31
+
32
+ MIT
package/dist/cli.js ADDED
@@ -0,0 +1,69 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * `pnpm create webview2-bridge <dir> [--name <AppName>] [--force]`
4
+ * = `webview2-bridge-gen init <dir> ...` の短い入口。
5
+ * npm / pnpm の `create` は `create-<name>` パッケージを実行する規約なので、この薄いパッケージを別名で公開している。
6
+ * 中身は @ishibashi0112/webview2-bridge-gen の scaffold を呼ぶだけ。
7
+ */
8
+ import path from "node:path";
9
+ import { scaffold, defaultAppName } from "@ishibashi0112/webview2-bridge-gen/generate";
10
+ function usage() {
11
+ console.error(`Usage: pnpm create webview2-bridge <dir> [--name <AppName>] [--force]
12
+ npm create webview2-bridge <dir> [--name <AppName>] [--force]
13
+
14
+ <dir> 新規アプリを書き出すディレクトリ
15
+ --name アプリ名(PascalCase。VB の名前空間・プロジェクト名になる。既定: <dir> の名前から生成)
16
+ --force <dir> にファイルがあっても書き込む`);
17
+ process.exit(2);
18
+ }
19
+ export async function main(argv) {
20
+ let dir;
21
+ let name;
22
+ let force = false;
23
+ for (let i = 0; i < argv.length; i++) {
24
+ const a = argv[i];
25
+ if (a === "--name")
26
+ name = argv[++i] ?? usage();
27
+ else if (a === "--force")
28
+ force = true;
29
+ else if (a === "-h" || a === "--help")
30
+ usage();
31
+ else if (a.startsWith("-")) {
32
+ console.error(`Unknown argument: ${a}`);
33
+ usage();
34
+ }
35
+ else if (dir === undefined)
36
+ dir = a;
37
+ else {
38
+ console.error(`Unexpected argument: ${a}`);
39
+ usage();
40
+ }
41
+ }
42
+ if (dir === undefined)
43
+ usage();
44
+ const targetDir = path.resolve(dir);
45
+ const appName = name ?? defaultAppName(path.basename(targetDir));
46
+ const result = await scaffold({ targetDir, name: appName, force });
47
+ console.log(result.files.map((f) => `wrote ${f}`).join("\n"));
48
+ console.log(`
49
+ Created ${appName} in ${targetDir} (${result.files.length} files).
50
+
51
+ Next:
52
+ cd ${dir}
53
+ pnpm install # esbuild の postinstall 許可は pnpm-workspace.yaml に設定済み
54
+ pnpm gen:check # 生成物が同梱版と一致することを確認(契約を変えたら pnpm gen)
55
+ pnpm dev # http://localhost:5173 をブラウザで開く(MemoryTransport のモック)
56
+ # Windows: set WEBVIEW2_BRIDGE_DEV_URL=http://localhost:5173 && dotnet run --project dotnet/${appName}.Host
57
+
58
+ See README.md in the new directory for the full walkthrough.`);
59
+ return 0;
60
+ }
61
+ main(process.argv.slice(2)).then((code) => process.exit(code), (err) => {
62
+ // gen の GenerateError(名前不正・ディレクトリ非空)はメッセージだけ出す
63
+ if (err instanceof Error && err.name === "GenerateError")
64
+ console.error(`create-webview2-bridge: ${err.message}`);
65
+ else
66
+ console.error(err);
67
+ process.exit(1);
68
+ });
69
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;;GAKG;AACH,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,6CAA6C,CAAC;AAEvF,SAAS,KAAK;IACZ,OAAO,CAAC,KAAK,CAAC;;;;;iCAKiB,CAAC,CAAC;I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O,EAAE,KAAK,EAAE,CAAC,CAAC;IACnE,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAC9D,OAAO,CAAC,GAAG,CAAC;UACJ,OAAO,OAAO,SAAS,KAAK,MAAM,CAAC,KAAK,CAAC,MAAM;;;OAGlD,GAAG;;;;gGAIsF,OAAO;;6DAE1C,CAAC,CAAC;IAC7D,OAAO,CAAC,CAAC;AACX,CAAC;AAED,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAC9B,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAC5B,CAAC,GAAY,EAAE,EAAE;IACf,+CAA+C;IAC/C,IAAI,GAAG,YAAY,KAAK,IAAI,GAAG,CAAC,IAAI,KAAK,eAAe;QAAE,OAAO,CAAC,KAAK,CAAC,2BAA2B,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;;QAC7G,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACxB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CACF,CAAC"}
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "create-webview2-bridge",
3
+ "version": "0.3.0",
4
+ "description": "Scaffold a WinForms (VB.NET / .NET Framework 4.8) + WebView2 + Vite/React app wired with webview2-bridge: `pnpm create webview2-bridge my-app`",
5
+ "keywords": [
6
+ "webview2",
7
+ "winforms",
8
+ "vb.net",
9
+ "react",
10
+ "vite",
11
+ "scaffold",
12
+ "create"
13
+ ],
14
+ "license": "MIT",
15
+ "author": "ishibashi0112",
16
+ "homepage": "https://github.com/ishibashi0112/webview2-bridge#readme",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/ishibashi0112/webview2-bridge.git",
20
+ "directory": "packages/create"
21
+ },
22
+ "bugs": "https://github.com/ishibashi0112/webview2-bridge/issues",
23
+ "type": "module",
24
+ "engines": {
25
+ "node": ">=20.19.0"
26
+ },
27
+ "bin": {
28
+ "create-webview2-bridge": "./dist/cli.js"
29
+ },
30
+ "files": [
31
+ "dist",
32
+ "README.md",
33
+ "LICENSE"
34
+ ],
35
+ "publishConfig": {
36
+ "access": "public"
37
+ },
38
+ "dependencies": {
39
+ "@ishibashi0112/webview2-bridge-gen": "^0.3.0"
40
+ },
41
+ "devDependencies": {
42
+ "@types/node": "^24.0.0",
43
+ "tsx": "^4.23.13",
44
+ "typescript": "^5.9.3",
45
+ "vitest": "^4.1.11"
46
+ },
47
+ "scripts": {
48
+ "build": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.build.json",
49
+ "test": "vitest run",
50
+ "typecheck": "tsc --noEmit -p tsconfig.json"
51
+ }
52
+ }