@riebeckite/graph 0.0.0-stage → 0.0.36

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,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright Rerurate_514
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,174 @@
1
- # Temporary Holding Version
1
+ # @riebeckite/graph
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Shared graph engine for Riebeckite's Local Graph and Garden Explorer.
4
+
5
+ [日本語](./README_ja.md)
6
+
7
+ ## What it provides
8
+
9
+ `@riebeckite/graph` turns the public content manifest into a graph document and
10
+ renders it with a Canvas 2D force simulation and Obsidian-style controls. The
11
+ same engine powers both the article Local Graph and the Global Graph, so
12
+ physics, camera, filters, groups, persistence, and lifecycle behavior are not
13
+ duplicated between plugins.
14
+
15
+ - Server-safe data building from public entries, unresolved links, public
16
+ attachments, and tags
17
+ - Obsidian-compatible subset of graph search: `file:`, `path:`, `tag:`, quoted
18
+ phrases, and `-` negation
19
+ - Filters for tags, attachments, unresolved files, and orphans
20
+ - Ordered color groups with first-match priority
21
+ - Continuous center, repel, link, and link-distance forces with deterministic
22
+ initial placement and automatic settling
23
+ - Canvas renderer with wheel/pinch zoom at the pointer, background pan, node
24
+ drag, hover emphasis, labels that fade by zoom, arrows, groups, animation, and
25
+ pointer/keyboard/context-menu interaction
26
+ - Settings persistence through `localStorage`
27
+ - Pause when off-screen or when the document is hidden, plus cleanup for SPA
28
+ page transitions
29
+
30
+ ## Usage
31
+
32
+ ```ts
33
+ import {
34
+ buildGraphDocument,
35
+ buildVisibleGraph,
36
+ DEFAULT_GRAPH_SETTINGS,
37
+ } from "@riebeckite/graph";
38
+ import { createGraphRenderer } from "@riebeckite/graph/client";
39
+ ```
40
+
41
+ Build a document from public entries:
42
+
43
+ ```ts
44
+ const document = buildGraphDocument(
45
+ entries.map((entry) => ({
46
+ slug: entry.slug,
47
+ title: entry.title,
48
+ permalink: entry.permalink,
49
+ tags: entry.tags,
50
+ links: entry.links,
51
+ assets: entry.assets,
52
+ date: entry.date ?? null,
53
+ })),
54
+ { centerSlug: entry.slug },
55
+ );
56
+ ```
57
+
58
+ Mount the renderer in a browser-only effect:
59
+
60
+ ```ts
61
+ const renderer = createGraphRenderer({
62
+ canvas,
63
+ reducedMotion: window.matchMedia("(prefers-reduced-motion: reduce)").matches,
64
+ });
65
+
66
+ renderer.update({
67
+ document,
68
+ settings: DEFAULT_GRAPH_SETTINGS,
69
+ mode: "global",
70
+ });
71
+
72
+ return () => renderer.destroy();
73
+ ```
74
+
75
+ For a ready-made UI, use the shared component:
76
+
77
+ ```tsx
78
+ import GraphView from "@riebeckite/graph/ui";
79
+ import "@riebeckite/graph/style.css";
80
+
81
+ <GraphView
82
+ document={document}
83
+ mode="local"
84
+ centerId={entry.slug}
85
+ initialSettings={{ depth: 1 }}
86
+ maxDepth={3}
87
+ expandable
88
+ storageKey="example-graph-settings"
89
+ />;
90
+ ```
91
+
92
+ `GraphView` is safe to server-render. It creates the renderer and reads
93
+ `localStorage` only in effects, so it can be hydrated by the client lifecycle
94
+ used by Riebeckite plugins.
95
+
96
+ ## Settings
97
+
98
+ Defaults follow Obsidian's graph view where the public data model allows it:
99
+
100
+ | Setting | Default | Range |
101
+ | --- | --- | --- |
102
+ | Depth | 2 | 0–5 |
103
+ | Tags | on | — |
104
+ | Attachments | on | — |
105
+ | Existing files only | off | — |
106
+ | Orphans | on | — |
107
+ | Arrows | off | — |
108
+ | Text fade threshold | 0.35 | 0–1 |
109
+ | Node size | 1 | 0.5–2.5 |
110
+ | Link thickness | 1 | 0.25–3 |
111
+ | Center force | 0.35 | 0–1 |
112
+ | Repel force | 600 | 0–2000 |
113
+ | Link force | 0.7 | 0–1 |
114
+ | Link distance | 100 | 30–500 |
115
+
116
+ `normalizeGraphSettings()` clamps stored values and rejects malformed groups.
117
+ `restore defaults` on the settings panel returns to these values while keeping
118
+ the mode-specific depth cap.
119
+
120
+ ## Public boundary
121
+
122
+ Build graph input from `manifest.discoverableEntries` or
123
+ `PublicContentView.discoverableEntries`. Never pass private, draft, scheduled,
124
+ or unlisted entries to the browser. Resolved links to non-public notes are
125
+ removed by `PublicContentView`; unresolved links preserve only the text that is
126
+ already in the public note. `buildGraphDocument` also drops note links whose
127
+ target is not present in the supplied entries.
128
+
129
+ ## Performance
130
+
131
+ The simulation uses exact pair repulsion for small graphs and a Barnes-Hut-style
132
+ quadtree above 250 nodes. The renderer draws with Canvas 2D, uses a device-pixel
133
+ ratio cap of 2, skips off-screen edges and nodes, limits labels on dense graphs,
134
+ and stops requesting animation frames once the simulation settles.
135
+
136
+ `pnpm --filter @riebeckite/graph benchmark` runs synthetic 100 / 675 / 1,000 /
137
+ 3,000 node graphs with low and high edge density. On the development machine,
138
+ settling 3,000 nodes with about 3,600 links takes roughly 1.15 seconds of
139
+ simulation work and about 3.8 ms per tick. In the browser, average frame time
140
+ stays within a 60 Hz frame at that size, though dense 3,000-node graphs with
141
+ about 11,900 links exceed it on some frames (about 12.4 ms average and 24 ms at
142
+ the 95th percentile). These numbers are machine dependent.
143
+
144
+ `d3-force` was evaluated as the default engine. The custom simulation was kept
145
+ because it gives deterministic initial placement, explicit pin/release and
146
+ reheat control for dragging, and a small dependency-free surface that is shared
147
+ by both plugins. Its Barnes-Hut-style quadtree provides the same asymptotic
148
+ repulsion behavior without adding a runtime dependency. It is not a drop-in
149
+ replacement for every `d3-force` behavior.
150
+
151
+ ## Exports
152
+
153
+ - `buildGraphDocument(entries, options)`
154
+ - `sliceGraphDocument(document, centerId, depth, maxNodes)`
155
+ - `buildVisibleGraph({ document, settings, mode, centerId })`
156
+ - `collectLocalNodeIds(adjacency, centerId, depth)`
157
+ - `parseGraphQuery`, `matchesGraphQuery`, `normalizeGraphText`
158
+ - `createGraphSimulation`, `buildRevealSchedule`, `hasDatedNodes`
159
+ - `DEFAULT_GRAPH_SETTINGS`, `GRAPH_SETTINGS_RANGES`, `mergeGraphSettings`,
160
+ `normalizeGraphSettings`, `readStoredGraphSettings`,
161
+ `writeStoredGraphSettings`
162
+ - `@riebeckite/graph/client`: `createGraphRenderer`
163
+ - `@riebeckite/graph/ui`: default `GraphView`
164
+ - Types: `GraphDocument`, `GraphNode`, `GraphLink`, `GraphSettings`,
165
+ `GraphGroup`, `GraphMode`, `VisibleGraph`, `VisibleGraphNode`,
166
+ `GraphRenderer`, `GraphViewProps`
167
+
168
+ ## Development
169
+
170
+ ```sh
171
+ pnpm --filter @riebeckite/graph test
172
+ pnpm --filter @riebeckite/graph benchmark
173
+ pnpm --filter @riebeckite/graph build
174
+ ```
package/README_ja.md ADDED
@@ -0,0 +1,141 @@
1
+ # @riebeckite/graph
2
+
3
+ Riebeckite の Local Graph と Garden Explorer が共有するグラフエンジンです。
4
+
5
+ [English](./README.md)
6
+
7
+ ## 提供する機能
8
+
9
+ `@riebeckite/graph` は公開コンテンツのマニフェストからグラフドキュメントを構築し、Canvas 2D の強制シミュレーションと Obsidian 風の操作 UI で描画します。記事内の Local Graph と Global Graph が同じエンジンを使うため、物理演算、カメラ、フィルター、グループ、設定の保存、ライフサイクル管理をプラグインごとに複製していません。
10
+
11
+ - 公開エントリ、未解決リンク、公開添付ファイル、タグからサーバー側でデータを構築
12
+ - Obsidian 互換の検索サブセット: `file:`、`path:`、`tag:`、引用符、`-` 否定
13
+ - タグ、添付ファイル、未解決ファイル、孤立ノートのフィルター
14
+ - 順序付きの色分けグループ(最初に一致したものが優先)
15
+ - Center / Repel / Link / Link distance の継続的な力。初期配置は再現性があり、安定後は自動停止
16
+ - ポインター中心のホイール/ピンチズーム、背景パン、ノードドラッグ、ホバー強調、ズームに応じたラベルのフェード、矢印、グループ、アニメーション、ポインター/キーボード/右クリック操作を備えた Canvas レンダラー
17
+ - `localStorage` による設定の保存と復元
18
+ - 画面外・非表示時の一時停止と、SPA ページ遷移時の確実な解放
19
+
20
+ ## 使い方
21
+
22
+ ```ts
23
+ import {
24
+ buildGraphDocument,
25
+ buildVisibleGraph,
26
+ DEFAULT_GRAPH_SETTINGS,
27
+ } from "@riebeckite/graph";
28
+ import { createGraphRenderer } from "@riebeckite/graph/client";
29
+ ```
30
+
31
+ 公開エントリからドキュメントを構築します。
32
+
33
+ ```ts
34
+ const document = buildGraphDocument(
35
+ entries.map((entry) => ({
36
+ slug: entry.slug,
37
+ title: entry.title,
38
+ permalink: entry.permalink,
39
+ tags: entry.tags,
40
+ links: entry.links,
41
+ assets: entry.assets,
42
+ date: entry.date ?? null,
43
+ })),
44
+ { centerSlug: entry.slug },
45
+ );
46
+ ```
47
+
48
+ ブラウザ専用の effect でレンダラーをマウントします。
49
+
50
+ ```ts
51
+ const renderer = createGraphRenderer({
52
+ canvas,
53
+ reducedMotion: window.matchMedia("(prefers-reduced-motion: reduce)").matches,
54
+ });
55
+
56
+ renderer.update({
57
+ document,
58
+ settings: DEFAULT_GRAPH_SETTINGS,
59
+ mode: "global",
60
+ });
61
+
62
+ return () => renderer.destroy();
63
+ ```
64
+
65
+ UI をそのまま使う場合:
66
+
67
+ ```tsx
68
+ import GraphView from "@riebeckite/graph/ui";
69
+ import "@riebeckite/graph/style.css";
70
+
71
+ <GraphView
72
+ document={document}
73
+ mode="local"
74
+ centerId={entry.slug}
75
+ initialSettings={{ depth: 1 }}
76
+ maxDepth={3}
77
+ expandable
78
+ storageKey="example-graph-settings"
79
+ />;
80
+ ```
81
+
82
+ `GraphView` はサーバー描画に対応します。レンダラーの生成と `localStorage` の読み書きは effect 内だけで行うため、Riebeckite のプラグインが使うクライアントライフサイクルでハイドレートできます。
83
+
84
+ ## 設定
85
+
86
+ 公開データモデルで表現できる範囲は Obsidian の Graph View に合わせています。
87
+
88
+ | 設定 | 初期値 | 範囲 |
89
+ | --- | --- | --- |
90
+ | Depth | 2 | 0–5 |
91
+ | Tags | オン | — |
92
+ | Attachments | オン | — |
93
+ | Existing files only | オフ | — |
94
+ | Orphans | オン | — |
95
+ | Arrows | オフ | — |
96
+ | Text fade threshold | 0.35 | 0–1 |
97
+ | Node size | 1 | 0.5–2.5 |
98
+ | Link thickness | 1 | 0.25–3 |
99
+ | Center force | 0.35 | 0–1 |
100
+ | Repel force | 600 | 0–2000 |
101
+ | Link force | 0.7 | 0–1 |
102
+ | Link distance | 100 | 30–500 |
103
+
104
+ `normalizeGraphSettings()` は保存値をクランプし、不正なグループを除外します。設定パネルの Restore defaults は、モードごとの Depth 上限を保ったまま初期値へ戻します。
105
+
106
+ ## 公開境界
107
+
108
+ グラフの入力は `manifest.discoverableEntries` または `PublicContentView.discoverableEntries` から構築してください。非公開、下書き、予約公開、unlisted のエントリをブラウザへ渡してはいけません。非公開ノートへの解決済みリンクは `PublicContentView` が除去し、未解決リンクは公開ノートにすでに書かれているテキストだけを保持します。`buildGraphDocument` も、渡されたエントリに存在しないノートへのリンクを破棄します。
109
+
110
+ ## 性能
111
+
112
+ シミュレーションは小規模グラフでは全ペアの反発力、250ノード超では Barnes-Hut 方式の四分木を使います。レンダラーは Canvas 2D、デバイスピクセル比の上限2、画面外の辺・ノードのスキップ、高密度時のラベル数制限を行い、シミュレーションが安定すると `requestAnimationFrame` の要求を止めます。
113
+
114
+ `pnpm --filter @riebeckite/graph benchmark` は 100 / 675 / 1,000 / 3,000 ノードを低密度・高密度の辺で計測します。開発機では約3,600リンクの3,000ノードが約1.15秒(1ティック約3.8ms)で安定します。ブラウザではこの規模でも平均フレーム時間は60Hzの1フレーム以内ですが、約11,900リンクの高密度3,000ノードでは一部のフレームで超えます(平均約12.4ms、95パーセンタイル約24ms)。数値は実行環境に依存します。
115
+
116
+ `d3-force` も既定エンジンの候補として評価しました。独自シミュレーションを採用した理由は、決定的な初期配置、ドラッグ時の固定・解放と再加熱の明示的な制御、両プラグインで共有できる依存なしの小さな実装面です。Barnes-Hut 方式の四分木により、実行時依存を増やさずに同等のオーダーの反発計算を行います。`d3-force` のすべての挙動を置き換えるものではありません。
117
+
118
+ ## 公開 API
119
+
120
+ - `buildGraphDocument(entries, options)`
121
+ - `sliceGraphDocument(document, centerId, depth, maxNodes)`
122
+ - `buildVisibleGraph({ document, settings, mode, centerId })`
123
+ - `collectLocalNodeIds(adjacency, centerId, depth)`
124
+ - `parseGraphQuery`、`matchesGraphQuery`、`normalizeGraphText`
125
+ - `createGraphSimulation`、`buildRevealSchedule`、`hasDatedNodes`
126
+ - `DEFAULT_GRAPH_SETTINGS`、`GRAPH_SETTINGS_RANGES`、`mergeGraphSettings`、
127
+ `normalizeGraphSettings`、`readStoredGraphSettings`、
128
+ `writeStoredGraphSettings`
129
+ - `@riebeckite/graph/client`: `createGraphRenderer`
130
+ - `@riebeckite/graph/ui`: デフォルトの `GraphView`
131
+ - 型: `GraphDocument`、`GraphNode`、`GraphLink`、`GraphSettings`、
132
+ `GraphGroup`、`GraphMode`、`VisibleGraph`、`VisibleGraphNode`、
133
+ `GraphRenderer`、`GraphViewProps`
134
+
135
+ ## 開発
136
+
137
+ ```sh
138
+ pnpm --filter @riebeckite/graph test
139
+ pnpm --filter @riebeckite/graph benchmark
140
+ pnpm --filter @riebeckite/graph build
141
+ ```
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,34 @@
1
+ import type { GraphDocument, GraphMode, GraphNode, GraphSettings } from "./index.js";
2
+ export type GraphRendererCallbacks = {
3
+ onSelect?: (node: GraphNode | null) => void;
4
+ onOpen?: (node: GraphNode) => void;
5
+ onHover?: (node: GraphNode | null) => void;
6
+ onContextMenu?: (node: GraphNode, x: number, y: number) => void;
7
+ onAnimationChange?: (animating: boolean) => void;
8
+ };
9
+ export type GraphRendererInput = {
10
+ document: GraphDocument;
11
+ settings: GraphSettings;
12
+ mode: GraphMode;
13
+ centerId?: string | null;
14
+ selectedId?: string | null;
15
+ };
16
+ export type GraphRendererOptions = GraphRendererCallbacks & {
17
+ canvas: HTMLCanvasElement;
18
+ reducedMotion?: boolean;
19
+ };
20
+ export type GraphRenderer = {
21
+ update(input: GraphRendererInput): void;
22
+ setSelected(id: string | null): void;
23
+ zoomBy(factor: number, origin?: {
24
+ x: number;
25
+ y: number;
26
+ }): void;
27
+ resetView(): void;
28
+ focusNode(id: string): void;
29
+ playAnimation(): void;
30
+ stopAnimation(): void;
31
+ isAnimating(): boolean;
32
+ destroy(): void;
33
+ };
34
+ export declare function createGraphRenderer(options: GraphRendererOptions): GraphRenderer;