novelaidraw 0.0.0-stage → 0.1.1
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/README.md +97 -2
- package/dist/index.cjs +848 -0
- package/dist/index.d.ts +225 -0
- package/dist/index.js +1303 -0
- package/package.json +63 -4
package/README.md
CHANGED
|
@@ -1,3 +1,98 @@
|
|
|
1
|
-
#
|
|
1
|
+
# novelaidraw
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
小説執筆向けの **人物相関図(`relation`)** や **家系図(`family`)** を簡易テキスト(DSL)から自己完結した SVG 文字列として生成する、Pure TypeScript コアライブラリです。
|
|
4
|
+
|
|
5
|
+
* **Web ライブエディター(GitHub Pages)**: https://mituha.github.io/novelaidraw/
|
|
6
|
+
* **公式ドキュメント**: https://mituha.github.io/novelaidraw/docs/
|
|
7
|
+
* **DSL 記法マニュアル**: https://mituha.github.io/novelaidraw/docs/manual/01_DSL記法マニュアル.html
|
|
8
|
+
* **GitHub リポジトリ**: https://github.com/mituha/novelaidraw
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## インストール
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install novelaidraw
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## 使用方法
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
import { render } from 'novelaidraw';
|
|
24
|
+
|
|
25
|
+
const dsl = `---
|
|
26
|
+
title: 勇者一行と魔王軍の相関図
|
|
27
|
+
theme: dark
|
|
28
|
+
direction: RIGHT
|
|
29
|
+
---
|
|
30
|
+
relation
|
|
31
|
+
|
|
32
|
+
group hero_party "勇者一行" {
|
|
33
|
+
alice "アリス" [ruby: "ありす", role: "勇者", color: "#38bdf8"]
|
|
34
|
+
bob "ボブ" [role: "魔法使い"]
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
carol "キャロル" [role: "魔王", color: "#ef4444"]
|
|
38
|
+
|
|
39
|
+
alice --> bob : "信頼" [type: ally]
|
|
40
|
+
bob ==> alice : "片想い" [type: love]
|
|
41
|
+
alice <--> carol : "宿敵" [type: rival]
|
|
42
|
+
`;
|
|
43
|
+
|
|
44
|
+
const svgString = await render(dsl);
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### 家系図(`family`)の例
|
|
48
|
+
|
|
49
|
+
```text
|
|
50
|
+
---
|
|
51
|
+
title: アルフレッド王家 家系図
|
|
52
|
+
theme: sepia
|
|
53
|
+
---
|
|
54
|
+
family
|
|
55
|
+
|
|
56
|
+
alfred "アルフレッド王" [role: "初代国王", status: deceased]
|
|
57
|
+
elizabeth "エリザベス王妃" [role: "正室", status: deceased]
|
|
58
|
+
edward "エドワード" [role: "第一王子"]
|
|
59
|
+
mary "メアリー" [role: "第一王女"]
|
|
60
|
+
|
|
61
|
+
alfred === elizabeth -> edward, mary
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### 公開 API
|
|
65
|
+
|
|
66
|
+
| 関数 | 説明 |
|
|
67
|
+
| :--- | :--- |
|
|
68
|
+
| `render(code, options?)` | DSL を解析・レイアウトし、SVG 文字列(`Promise<string>`)を返します。 |
|
|
69
|
+
| `parse(code)` | DSL を構文解析し、中間表現 `GraphIR` を返します。 |
|
|
70
|
+
| `layout(ir, options?)` | `GraphIR` を ELKjs でレイアウトし、`PositionedGraph` を返します。 |
|
|
71
|
+
| `renderSvgFromLayout(graph)` | `PositionedGraph` から SVG 文字列を生成します。 |
|
|
72
|
+
|
|
73
|
+
#### `RenderOptions`
|
|
74
|
+
|
|
75
|
+
| オプション | 型 | 説明 |
|
|
76
|
+
| :--- | :--- | :--- |
|
|
77
|
+
| `theme` | `'light' \| 'dark' \| 'sepia'` | カラーテーマを上書きします。 |
|
|
78
|
+
| `direction` | `'DOWN' \| 'RIGHT' \| 'UP' \| 'LEFT'` | レイアウト展開方向を上書きします(相関図既定: `RIGHT` / 家系図既定: `DOWN`)。 |
|
|
79
|
+
| `title` | `string` | タイトル文字列を上書きします。 |
|
|
80
|
+
| `padding` | `number` | キャンバス外周余白 (px)(既定: `24`)。 |
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## 開発用のコンパイル・テスト方法
|
|
85
|
+
|
|
86
|
+
本パッケージはリポジトリルートの npm workspaces 配下で管理されています。
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
# ルートディレクトリで依存インストール後
|
|
90
|
+
# Langium 文法から AST・パーサーコード生成
|
|
91
|
+
npm run langium:generate -w novelaidraw
|
|
92
|
+
|
|
93
|
+
# 型チェックおよびビルド (dist/index.js, dist/index.cjs, dist/index.d.ts)
|
|
94
|
+
npm run build -w novelaidraw
|
|
95
|
+
|
|
96
|
+
# 単体・統合テストの実行 (Vitest)
|
|
97
|
+
npm test -w novelaidraw
|
|
98
|
+
```
|