|
| 1 | +# Configuration Files |
| 2 | + |
| 3 | +設定ファイルは `src/config/` ディレクトリに配置。 |
| 4 | + |
| 5 | +## stage.json |
| 6 | + |
| 7 | +表示領域(Stage)の設定。 |
| 8 | + |
| 9 | +| Property | Type | Default | Description | |
| 10 | +|----------|------|---------|-------------| |
| 11 | +| `width` | number | 240 | 表示領域の幅 | |
| 12 | +| `height` | number | 240 | 表示領域の高さ | |
| 13 | +| `fps` | number | 60 | 描画回数/秒 (1-60) | |
| 14 | +| `options` | object | null | オプション設定 | |
| 15 | + |
| 16 | +### Stage Options |
| 17 | + |
| 18 | +| Property | Type | Default | Description | |
| 19 | +|----------|------|---------|-------------| |
| 20 | +| `options.fullScreen` | boolean | false | 画面全体に描画 | |
| 21 | +| `options.tagId` | string | null | 描画先のエレメントID | |
| 22 | +| `options.bgColor` | string | "transparent" | 背景色 (16進数) | |
| 23 | + |
| 24 | +### Example |
| 25 | + |
| 26 | +```json |
| 27 | +{ |
| 28 | + "width": 240, |
| 29 | + "height": 240, |
| 30 | + "fps": 60, |
| 31 | + "options": { |
| 32 | + "fullScreen": true |
| 33 | + } |
| 34 | +} |
| 35 | +``` |
| 36 | + |
| 37 | +--- |
| 38 | + |
| 39 | +## config.json |
| 40 | + |
| 41 | +環境別の設定ファイル。`local`, `dev`, `stg`, `prd`, `all` に分離。 |
| 42 | + |
| 43 | +### Structure |
| 44 | + |
| 45 | +```json |
| 46 | +{ |
| 47 | + "local": { "api": { "endPoint": "/" }, "content": { "endPoint": "/" } }, |
| 48 | + "dev": { "api": { "endPoint": "/" }, "content": { "endPoint": "/" } }, |
| 49 | + "stg": { "api": { "endPoint": "/" }, "content": { "endPoint": "/" } }, |
| 50 | + "prd": { "api": { "endPoint": "https://..." }, "content": { "endPoint": "https://..." } }, |
| 51 | + "all": { /* 全環境共通 */ } |
| 52 | +} |
| 53 | +``` |
| 54 | + |
| 55 | +### `all` Properties (全環境共通) |
| 56 | + |
| 57 | +| Property | Type | Default | Description | |
| 58 | +|----------|------|---------|-------------| |
| 59 | +| `defaultTop` | string | "top" | ページトップのView名 | |
| 60 | +| `spa` | boolean | true | SPA (URLでシーン制御) | |
| 61 | +| `loading.callback` | string | "Loading" | ローディング画面のコールバッククラス。start/end関数が呼ばれる | |
| 62 | +| `gotoView.callback` | string/array | ["callback.Background"] | 画面遷移完了後のコールバッククラス。execute関数がasync/awaitで呼ばれる | |
| 63 | + |
| 64 | +### `platform` Property |
| 65 | + |
| 66 | +ビルド時の`--platform`値がセットされる。値: `macos`, `windows`, `linux`, `ios`, `android`, `web` |
| 67 | + |
| 68 | +### Config Access in Code |
| 69 | + |
| 70 | +```typescript |
| 71 | +import { config } from "@/config/Config"; |
| 72 | + |
| 73 | +const endpoint = config.api.endPoint; |
| 74 | +const stageWidth = config.stage.width; |
| 75 | +``` |
| 76 | + |
| 77 | +--- |
| 78 | + |
| 79 | +## routing.json |
| 80 | + |
| 81 | +ルーティング設定。トッププロパティは英数字・スラッシュ。スラッシュをキーにCamelCaseでViewクラスにアクセス。 |
| 82 | + |
| 83 | +### Routing Example |
| 84 | + |
| 85 | +```json |
| 86 | +{ |
| 87 | + "quest/list": { |
| 88 | + "requests": [] |
| 89 | + } |
| 90 | +} |
| 91 | +``` |
| 92 | + |
| 93 | +→ `https://example.com/quest/list` でアクセス可能。`QuestListView`クラスがセットされる。 |
| 94 | + |
| 95 | +### Cluster Pattern (共通リクエストの再利用) |
| 96 | + |
| 97 | +`@`プレフィックスで共通リクエスト群を定義し、他のルートから参照: |
| 98 | + |
| 99 | +```json |
| 100 | +{ |
| 101 | + "@sample": { |
| 102 | + "requests": [ |
| 103 | + { |
| 104 | + "type": "content", |
| 105 | + "path": "{{ content.endPoint }}content/sample.json", |
| 106 | + "name": "MainContent", |
| 107 | + "cache": true |
| 108 | + } |
| 109 | + ] |
| 110 | + }, |
| 111 | + "top": { |
| 112 | + "requests": [ |
| 113 | + { "type": "cluster", "path": "@sample" }, |
| 114 | + { "type": "json", "path": "{{ api.endPoint }}api/top.json", "name": "TopText" } |
| 115 | + ] |
| 116 | + } |
| 117 | +} |
| 118 | +``` |
| 119 | + |
| 120 | +### Second Level Properties |
| 121 | + |
| 122 | +| Property | Type | Default | Description | |
| 123 | +|----------|------|---------|-------------| |
| 124 | +| `private` | boolean | false | true時、URLアクセスするとTopViewが読み込まれる | |
| 125 | +| `requests` | array | null | Viewバインド前に実行するリクエスト群 | |
| 126 | + |
| 127 | +### Request Properties |
| 128 | + |
| 129 | +| Property | Type | Default | Description | |
| 130 | +|----------|------|---------|-------------| |
| 131 | +| `type` | string | "content" | `json`, `content`, `custom`, `cluster` | |
| 132 | +| `path` | string | "" | `{{***}}`でconfig変数を参照可能。`@`プレフィックスでcluster参照 | |
| 133 | +| `name` | string | "" | responseのキー名。`app.getResponse().get("key")` | |
| 134 | +| `cache` | boolean | false | キャッシュ有効。`app.getCache().get("key")` | |
| 135 | +| `callback` | string/array | null | リクエスト完了後のコールバッククラス。execute関数が呼ばれる | |
| 136 | +| `class` | string | "" | custom type時のリクエスト実行クラス | |
| 137 | +| `access` | string | "public" | custom type時の関数アクセス (`public`/`static`) | |
| 138 | +| `method` | string | "" | custom type時の関数名 | |
| 139 | + |
| 140 | +### Request Types |
| 141 | + |
| 142 | +- **`json`**: URLからJSONを取得 |
| 143 | +- **`content`**: Animation Toolコンテンツを取得 |
| 144 | +- **`custom`**: 指定クラスのメソッドを実行 |
| 145 | +- **`cluster`**: `@`プレフィックスの共通リクエスト群を参照 |
| 146 | + |
| 147 | +### Data Access |
| 148 | + |
| 149 | +```typescript |
| 150 | +// responseデータ (画面遷移で初期化される) |
| 151 | +const data = app.getResponse().get("HomeText"); |
| 152 | + |
| 153 | +// cacheデータ (画面遷移しても保持される) |
| 154 | +const cached = app.getCache().get("MainContent"); |
| 155 | +``` |
| 156 | + |
| 157 | +--- |
| 158 | + |
| 159 | +## Static Files |
| 160 | + |
| 161 | +### mock/ Directory |
| 162 | + |
| 163 | +ローカル開発用モックデータ。`http://localhost:5173/***`でアクセス可能。`routing.json`のパスと重複しないよう注意。 |
| 164 | + |
| 165 | +``` |
| 166 | +mock/ |
| 167 | +├── api/ # APIモック (JSON) |
| 168 | +├── content/ # Animation Toolコンテンツモック |
| 169 | +└── img/ # 画像モック |
| 170 | +``` |
| 171 | + |
| 172 | +### file/ Directory |
| 173 | + |
| 174 | +Animation Toolで作成した`.n2d`ファイルを格納。バージョン管理可能。 |
| 175 | + |
| 176 | +### assets/ Directory |
| 177 | + |
| 178 | +ビルド時にバンドルに含める静的アセット。 |
| 179 | + |
| 180 | +```typescript |
| 181 | +// 画像インポート |
| 182 | +import logoImage from "@/assets/logo.png?inline"; |
| 183 | + |
| 184 | +// JSONインポート |
| 185 | +import animation from "@/assets/animation.json"; |
| 186 | +``` |
| 187 | + |
| 188 | +| 項目 | assets | mock | |
| 189 | +|------|--------|------| |
| 190 | +| 用途 | バンドルに含める | 開発サーバーで配信 | |
| 191 | +| アクセス | importで取得 | URL経由でfetch | |
| 192 | +| ビルド | バンドルに含まれる | 含まれない | |
| 193 | + |
| 194 | +--- |
| 195 | + |
| 196 | +## @types/ Directory |
| 197 | + |
| 198 | +グローバルな型定義ファイル (.d.ts)。`Window`インターフェースの拡張等。アプリケーション固有のインターフェースは`src/interface/`に配置。 |
0 commit comments