From 7ad426226cd163ca34807a9715373b11c8d29f4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Junichi=20TAKAI=20=EF=BC=88=E3=81=9F=E3=81=8B=E3=81=84?= =?UTF-8?q?=E3=80=80=E3=81=98=E3=82=85=E3=82=93=E3=81=84=E3=81=A1=EF=BC=89?= Date: Sun, 30 Mar 2025 03:57:42 +0900 Subject: [PATCH] i18n(ja): Add Japanese texts for Concept section (#3197) Co-authored-by: Ayres Vitor --- .../Inter-Process Communication/index-0.svg | 191 +++++++++++++++++ .../Inter-Process Communication/index-1.svg | 194 +++++++++++++++++ public/d2/docs/ja/concept/architecture-0.svg | 198 ++++++++++++++++++ public/d2/docs/ja/concept/process-model-0.svg | 197 +++++++++++++++++ .../Inter-Process Communication/brownfield.md | 36 ++++ .../Inter-Process Communication/index.mdx | 100 +++++++++ .../Inter-Process Communication/isolation.md | 121 +++++++++++ src/content/docs/ja/concept/architecture.mdx | 193 +++++++++++++++++ src/content/docs/ja/concept/index.mdx | 45 ++++ src/content/docs/ja/concept/process-model.md | 88 ++++++++ src/content/docs/ja/concept/size.mdx | 77 +++++++ src/content/docs/ja/doc-JP Rev Control.md | 32 +-- 12 files changed, 1456 insertions(+), 16 deletions(-) create mode 100644 public/d2/docs/ja/concept/Inter-Process Communication/index-0.svg create mode 100644 public/d2/docs/ja/concept/Inter-Process Communication/index-1.svg create mode 100644 public/d2/docs/ja/concept/architecture-0.svg create mode 100644 public/d2/docs/ja/concept/process-model-0.svg create mode 100644 src/content/docs/ja/concept/Inter-Process Communication/brownfield.md create mode 100644 src/content/docs/ja/concept/Inter-Process Communication/index.mdx create mode 100644 src/content/docs/ja/concept/Inter-Process Communication/isolation.md create mode 100644 src/content/docs/ja/concept/architecture.mdx create mode 100644 src/content/docs/ja/concept/index.mdx create mode 100644 src/content/docs/ja/concept/process-model.md create mode 100644 src/content/docs/ja/concept/size.mdx diff --git a/public/d2/docs/ja/concept/Inter-Process Communication/index-0.svg b/public/d2/docs/ja/concept/Inter-Process Communication/index-0.svg new file mode 100644 index 000000000..03c0d9441 --- /dev/null +++ b/public/d2/docs/ja/concept/Inter-Process Communication/index-0.svg @@ -0,0 +1,191 @@ + + + + + + + + +WebviewFrontendCoreBackend Event Event + + + + + + diff --git a/public/d2/docs/ja/concept/Inter-Process Communication/index-1.svg b/public/d2/docs/ja/concept/Inter-Process Communication/index-1.svg new file mode 100644 index 000000000..5f002bab0 --- /dev/null +++ b/public/d2/docs/ja/concept/Inter-Process Communication/index-1.svg @@ -0,0 +1,194 @@ + + + + + + + + +WebviewFrontendCoreBackendInvokeHandler IPC Request Invoke command Serialize return Response + + + + + + + + + diff --git a/public/d2/docs/ja/concept/architecture-0.svg b/public/d2/docs/ja/concept/architecture-0.svg new file mode 100644 index 000000000..d93a3e68c --- /dev/null +++ b/public/d2/docs/ja/concept/architecture-0.svg @@ -0,0 +1,198 @@ + + + + + + + + +CoreUpstreamtauritauri-buildtauri-codegentauri-runtime-wryWRYTAOtauri-runtimetauri-macrostauri-utils + + + + + + + + + + + + + diff --git a/public/d2/docs/ja/concept/process-model-0.svg b/public/d2/docs/ja/concept/process-model-0.svg new file mode 100644 index 000000000..20963bf72 --- /dev/null +++ b/public/d2/docs/ja/concept/process-model-0.svg @@ -0,0 +1,197 @@ + + + + + + + + +CoreEvents & Commands 1Events & Commands 2Events & Commands 3WebView1WebView2WebView3WebViewWebViewWebView + + + + + + + + + + + + diff --git a/src/content/docs/ja/concept/Inter-Process Communication/brownfield.md b/src/content/docs/ja/concept/Inter-Process Communication/brownfield.md new file mode 100644 index 000000000..c83dc1a1c --- /dev/null +++ b/src/content/docs/ja/concept/Inter-Process Communication/brownfield.md @@ -0,0 +1,36 @@ +--- +title: ブラウンフィールド型(Brownfield Pattern) +i18nReady: true +--- + +_**デフォルトの IPC パターンです**_ + +このパターンは、Tauri を使用する上で最も明快で分かりやすいものです。というのも、既存のフロントエンド・プロジェクトと可能な限り互換性を持たせようとしているからです。手短に言えば、既存の Web フロントエンドがブラウザー内で使用するもの以外には、他に何も必要としないようになっているということです。 +ただ、これは既存のブラウザー・アプリケーションで動作する _**すべて**_ が、そのまま動作するというわけではありません。 + +一般的な「ブラウンフィールド」型のソフトウェア開発について馴染みがない場合は、Wikipedia の記事 [Brownfield Wikipedia article](日本語版なし)に判りやすい概説があります。 +Tauri の場合、(ブラウンフィールド型開発の対象となる)既存のソフトウェアとは、レガシー・システムではなく、現行ブラウザーのサポートと動作です。 + +## 設定 + +ブラウンフィールド型開発はデフォルトのパターンなので、設定オプションを指定する必要はありません。 +明示的に設定するには、`tauri.conf.json` 構成ファイル内の `tauri > pattern` オブジェクトを使用します。 + +```json +{ + "tauri": { + "pattern": { + "use": "brownfield" + } + } +} +``` + +_**ブラウンフィールド型では追加の設定オプションはありません。**_ + +[brownfield wikipedia article]: https://en.wikipedia.org/wiki/Brownfield_(software_development) + +
+【※ この日本語版は、「Feb 22, 2025 英語版」に基づいています】
+Doc-JP 2.00.00 +
diff --git a/src/content/docs/ja/concept/Inter-Process Communication/index.mdx b/src/content/docs/ja/concept/Inter-Process Communication/index.mdx new file mode 100644 index 000000000..8e30717cd --- /dev/null +++ b/src/content/docs/ja/concept/Inter-Process Communication/index.mdx @@ -0,0 +1,100 @@ +--- +title: プロセス間通信 +sidebar: + label: Overview + order: 1 +i18nReady: true +--- + +import { CardGrid, LinkCard } from '@astrojs/starlight/components'; + +「プロセス間通信 Inter-Process Communication」(IPC)は、単独のプロセスが安全に通信することを可能にし、より複雑なアプリケーションを構築するための鍵となります。 + +具体的な「プロセス間通信(IPC)」の型(パターン)については、次の説明内容を参照してください: + + + + + + +Tauri は、[Asynchronous Message Passing](非同期メッセージ・パッシング、[日本語版リンク]())と呼ばれる特別なスタイルのプロセス間通信を使用します。この方法では、プロセス同士が単純なデータ表現を使用してシリアル化された「_リクエスト_(要求)」と「_レスポンス_(応答)」をやり取りします。メッセージ・パッシングは、インターネット上のクライアント・サーバー通信に使用される仕組みであるため、Web 開発の経験がある人なら誰でも馴染みがあるはずです。 + +また、メッセージ・パッシングは受信者が必要に応じて「リクエスト」を拒否または破棄できるため、「共有メモリ方式」や「直接関数アクセス方式」よりも安全な手法です。たとえば、Tauri コア・プロセスが「リクエスト」を悪意のあるものと判断した場合、そのリクエストは破棄され、対応する関数処理は実行されません。 + +以下では、Tauri の二つの「IPC プリミティブ(同期基本命令)」、すなわち「イベント `Events` 」と「コマンド `Commands` 」について詳しく説明します。 + +## イベント + +「イベント」は、自動追尾型・一方向性の「IPC メッセージ」で、ライフサイクル中の各イベントと状態の変化を伝達するのに最適です。 +「[コマンド](#コマンド)」とは異なり、「イベント」はフロントエンドと Tauri Core(コア部)の両方から発行できます。 + +
+ +```d2 sketch pad=50 +shape: sequence_diagram + +Frontend: { + shape: rectangle + label: "Webview\nFrontend" +} +Core: { + shape: rectangle + label: "Core\nBackend" +} + +Frontend -> Core: "イベント"{style.animated: true} +Core -> Frontend: "イベント"{style.animated: true} +``` + +
コア部と Webview 間でやり取りされるイベント
+
+ +## コマンド + +Tauri は、また、「IPC メッセージ」に加えて、[foreign function interface](外部関数インターフェース、[日本語版リンク](https://ja.wikipedia.org/wiki/Foreign_function_interface))のような抽象化も提供します[^1]。基本主要 API である `invoke` は、ブラウザの `fetch` API に似ており、フロントエンドが Rust 関数を呼び出し、引数を渡して、データを受信できるようにします。 + +このメカニズムは、内部で [JSON-RPC] のようなプロトコルを使用してリクエストとレスポンスをシリアル化するので、すべての引数と戻り値データは JSON の規格に従ってシリアル化可能である必要があります。 + +
+ +```d2 sketch pad=50 +shape: sequence_diagram + + +Frontend: { + label: "Webview\nFrontend" +} + +Core: { + label: "Core\nBackend" +} +InvokeHandler: { + label: "Invoke\nHandler" +} + +Frontend -> Core: "IPC リクエスト"{style.animated: true} +Core -> InvokeHandler: "コマンド 呼び出し"{style.animated: true} +InvokeHandler -> Core: "戻り値 シリアル化"{style.animated: true} +Core -> Frontend: "レスポンス"{style.animated: true} +``` + +
コマンド呼び出しに関与する IPC メッセージ
+
+ +[^1]: コマンドは、内部ではメッセージ・パッシングを使用しているため、実際の「外部関数インターフェース(FFI)」と同じようなセキュリティ上の落とし穴はありません。 + +[Asynchronous Message Passing]: https://en.wikipedia.org/wiki/Message_passing#Asynchronous_message_passing +[json-rpc]: https://www.jsonrpc.org +[foreign function interface]: https://en.wikipedia.org/wiki/Foreign_function_interface + +
+ 【※ この日本語版は、「Feb 22, 2025 英語版」に基づいています】 +
+ Doc-JP 2.00.00 +
diff --git a/src/content/docs/ja/concept/Inter-Process Communication/isolation.md b/src/content/docs/ja/concept/Inter-Process Communication/isolation.md new file mode 100644 index 000000000..42a94d986 --- /dev/null +++ b/src/content/docs/ja/concept/Inter-Process Communication/isolation.md @@ -0,0 +1,121 @@ +--- +title: アイソレーション型(Isolation Pattern) +i18nReady: true +--- + +アイソレーション(分離・隔絶)型は、フロントエンドから送信された Tauri API メッセージが Tauri コア部に到達する前に、JavaScript を使用して傍受・変更する方法です。アイソレーション型で挿入される安全な JavaScript コードは、アイソレーション型アプリケーションと呼ばれます。 + +## アイソレーション型の必要性 + +アイソレーション型の目的は、Tauri コア部への望ましくないあるいは悪意のあるフロントエンドからの呼び出しから、アプリケーションを保護するための仕組みを開発者に提供することです。アイソレーション型が必要となったのは、フロントエンドで実行される信頼できないコンテンツから生じる脅威に対応するために生まれました。このような脅威は多くの依存関係を持つアプリケーションによくあるケースです。アプリケーションが遭遇する可能性のある多くの脅威源のリストについては、[セキュリティ:脅威モデル] を参照してください。 + +上記の最大の脅威モデルは「開発時の脅威」でしたが、このような脅威は、アイソレーション型を設計する際に念頭に置かれていたものです。多くのフロントエンドのビルド・ツールが、しばしば深くネスト化された数十(もしくは数百)の依存関係で成り立っているだけではなく、複雑なアプリケーション側にも、数多くの(こちらもしばしば深くネスト化された)依存関係があり得るので、最終出力版にバンドルされるのです。 + +## アイソレーション型を使用する局面 + +Tauri は、アイソレーション型が使用できる場合には常に使用することを強く推奨しています。アイソレーション型のアプリケーションではフロントエンドからの _**すべての**_ メッセージを「捕捉」(インターセプト)するため、アイソレーション型が _常に_ 使用されます。 + +さらに Tauri では、外部の Tauri API を使用するときは常に、アプリケーションを「封鎖」(ロックダウン)することを強く推奨しています。アプリの開発者は、安全なアイソレーション型アプリケーションを利用して IPC 入力を検証し、その入力内容が確実に想定されるパラメータの範囲内にあることを確かめます。事例としては、ファイルの読み取りまたは書き込みの呼び出しが、そのアプリケーションの想定外の場所へのパスにアクセスしようとしていないかを確認したり、あるいは、Tauri API の「HTTP フェッチコール」が 「Origin ヘッダー」にそのアプリケーションが想定しているもののみを設定しているかを確認したりすることです。 + +とはいえ、フロントエンドからの _**すべての**_ メッセージを捕捉するため、常時動作 API、たとえば [Events] など、でも動作します。一部のイベントでは、アプリ独自の Rust コードにアクションを実行させる可能性があるので、それにも同様の検証手法で対応することができます。 + +## アイソレーション型の適用 + +アイソレーション型で重要なのは、フロントエンドと Tauri Core(タウリ・コア部)との間に安全なアプリケーションを挿入して、IPC 受信メッセージを捕捉し修正することです。これには、`