Changes
8 changed files (+94/-4)
-
-
@@ -23,3 +23,8 @@ # <https://protobuf.dev/programming-guides/style/>[*.proto] indent_style = space indent_size = 2 # YAML は 2 スペース以外のインデントを仕様レベルで読むことができない。 [*.{yml,yaml}] indent_style = space indent_size = 2
-
-
-
-
@@ -18,10 +18,12 @@ "command": "bunx buf format {{file_path}}"} ] }, "yaml": {}, "plugins": [ "https://plugins.dprint.dev/markdown-0.17.8.wasm", // "Biome is a fast formatter for JavaScript, TypeScript, JSX, TSX, JSON, CSS and GraphQL..." "https://plugins.dprint.dev/biome-0.7.1.wasm", "https://plugins.dprint.dev/exec-0.5.0.json@8d9972eee71fa1590e04873540421f3eda7674d0f1aae3d7c788615e7b7413d0" "https://plugins.dprint.dev/exec-0.5.0.json@8d9972eee71fa1590e04873540421f3eda7674d0f1aae3d7c788615e7b7413d0", "https://plugins.dprint.dev/g-plane/pretty_yaml-v0.5.0.wasm" ] }
-
-
-
@@ -3,7 +3,9 @@ "name": "@yamori/workspace","private": true, "workspaces": ["packages/*"], "scripts": { "lint": "bun run --filter '*' lint" "lint": "bun run --filter '*' lint", "build": "bun run --filter '*' build", "clean": "bun run --filter '*' clean" }, "devDependencies": { "@bufbuild/buf": "^1.47.2"
-
-
-
@@ -0,0 +1,8 @@# このディレクトリ特有の無視設定。 # # SPDX-FileCopyrightText: 2024 Shota FUJI <pockawoooh@gmail.com> # SPDX-License-Identifier: AGPL-3.0-only # What: 自動生成された .js/.dts ファイルの格納先。 # Why: `yamori/` ディレクトリ配下の .proto ファイルから自動生成されるため。 /es
-
-
-
@@ -7,10 +7,54 @@ # `proto`このプロジェクトで取り扱う Protocol Buffers のデータ定義が全てまとまっているディレクトリ。 ## 品質チェック ## 利用方法 ### JavaScript API 依存パッケージとして [`@bufbuild/protobuf`](https://www.npmjs.com/package/@bufbuild/protobuf) が必要。 `peerDependencies` にバージョン要件があるため確認すること。 Protobuf のメッセージやサービス定義のファイルが 1:1 で JS/DTS に変換されており、 `@yamori/proto/path/to/file_pb.js` としてアクセスできる。 例えば以下のような Protobuf の定義ファイルがあった場合、 ```protobuf # packages/proto/yamori/foo/bar.proto package yamori.foo.bar; message Bar { string value = 1; } ``` 以下のように `import` できる。 ```ts import { fromBinary } from "@bufbuild/protobuf"; import { type Bar, BarSchema } from "@yamori/proto/yamori/foo/bar_pb.js"; export function decodeBar(bytes: Uint8Array): Bar { return fromBinary(BarSchema, bytes); } ``` ## 開発 このパッケージ自体の開発を行う場合のドキュメント。 ### 品質チェック このプロジェクトでは [Buf CLI](https://buf.build/docs/cli/) を使って Protobuf ファイルの品質をチェックしている。以下のコマンドでチェックを実行できる。 ``` $ bun lint ``` ### コード生成 Protobuf データのデコード・エンコードを行うコードを生成するには以下のコマンドを実行する。 ``` $ bun run build ```
-
-
-
@@ -0,0 +1,13 @@# `buf generate` を実行する際の設定。 # # SPDX-FileCopyrightText: 2024 Shota FUJI <pockawoooh@gmail.com> # SPDX-License-Identifier: AGPL-3.0-only version: v2 plugins: - local: protoc-gen-es out: es opt: - target=js+dts - import_extension=js
-
-
-
@@ -2,6 +2,22 @@ {"name": "@yamori/proto", "private": true, "scripts": { "lint": "buf lint" "lint": "buf lint", "build": "buf generate", "clean": "rm -rf es" }, "type": "module", "exports": { "./*.js": { "types": "./es/*.d.ts", "default": "./es/*.js" } }, "devDependencies": { "@bufbuild/protoc-gen-es": "^2.2.2", "@bufbuild/protobuf": "^2.2.2" }, "peerDependencies": { "@bufbuild/protobuf": "^2.2.0" } }
-