@riebeckite/plugin-excalibrain 0.0.19 → 0.0.20

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 CHANGED
@@ -73,9 +73,9 @@ hyphens. The default ontology is:
73
73
 
74
74
  | Role | Field names |
75
75
  | ---- | ----------- |
76
- | `parents` | `parent`, `parents`, `up`, `u`, `north`, `origin`, `inception` |
77
- | `children` | `children`, `child`, `down`, `d`, `south`, `leads to`, `contributes to` |
78
- | `leftFriends` | `friends`, `friend`, `similar`, `supports`, `alternatives`, `advantages` |
76
+ | `parents` | `parent`, `parents`, `up`, `u`, `north`, `origin`, `inception`, `source`, `parent domain` |
77
+ | `children` | `children`, `child`, `down`, `d`, `south`, `leads to`, `contributes to`, `nurtures` |
78
+ | `leftFriends` | `friends`, `friend`, `jump`, `jumps`, `j`, `similar`, `supports`, `alternatives`, `advantages`, `pros` |
79
79
  | `rightFriends` | `opposes`, `disadvantages`, `missing`, `cons` |
80
80
  | `previous` | `previous`, `prev`, `west`, `w`, `before` |
81
81
  | `next` | `next`, `n`, `east`, `e`, `after` |
@@ -87,6 +87,9 @@ still add an existing field to another role, but earlier roles in the
87
87
  canonical order (`parents`, `children`, `leftFriends`, `rightFriends`,
88
88
  `previous`, `next`, `hidden`) win when a field is listed twice.
89
89
 
90
+ `hidden` follows ExcaliBrain: it lists the targets to hide from this note's
91
+ map; it never hides the note itself. `showHidden` reveals those targets.
92
+
90
93
  ## Inference
91
94
 
92
95
  When `infer` is enabled (the default):
@@ -101,6 +104,13 @@ setting `infer: false` disables it. Link targets are resolved against the
101
104
  content manifest; unresolved targets become virtual nodes labelled with the
102
105
  raw link text (`data-node-virtual="true"`).
103
106
 
107
+ ## Publication boundary
108
+
109
+ Nodes are resolved against the content manifest. A target whose
110
+ `publishing.routable` flag is false is dropped from the map, so notes excluded
111
+ from publication never appear as nodes or links and their titles and permalinks
112
+ are not leaked.
113
+
104
114
  ## Rendering
105
115
 
106
116
  The `render` option selects where the map is produced:
@@ -133,7 +143,7 @@ The `render` option selects where the map is produced:
133
143
  | `infer` | `boolean` | `true` | Infer relations from links |
134
144
  | `siblings` | `boolean` | `true` | Infer siblings from parents (requires `infer`) |
135
145
  | `ontology` | object | — | Ontology field names appended per role |
136
- | `showHidden` | `boolean` | `false` | Include notes marked hidden |
146
+ | `showHidden` | `boolean` | `false` | Include targets named by `hidden` fields |
137
147
  | `width` | `number` | `720` | SVG viewBox width |
138
148
  | `height` | `number` | `480` | SVG viewBox height |
139
149
  | `language` | `string` | `"excalibrain"` | Fence language |
@@ -156,6 +166,15 @@ Each region is a `g.rb-excalibrain__region[data-region]`; each node is a
156
166
  wrapping an `<a href>` around its `<rect>` and `<text>`. Links are
157
167
  `path.rb-excalibrain__link[data-link-role][data-relation-type]`.
158
168
 
169
+ ## Limitations
170
+
171
+ - The map is read-only. The client layer only builds the SVG; there is no drag,
172
+ zoom, or expand/collapse interaction.
173
+ - `maxPerRegion` truncates each region, so a note with more relations than the
174
+ limit shows only the first nodes.
175
+ - Rendering is limited to the ontology roles above; there is no per-node
176
+ styling or per-region configuration beyond the options listed below.
177
+
159
178
  ## Exports
160
179
 
161
180
  - `excaliBrain(options?)` / `excaliBrainPlugin` — plugin factory
@@ -169,5 +188,5 @@ wrapping an `<a href>` around its `<rect>` and `<text>`. Links are
169
188
 
170
189
  ## See also
171
190
 
172
- - [Plugin guide](../../../docs/docs/reference/plugin-api.en.md)
191
+ - [Plugin guide](../../../docs/docs/reference/plugin-api.md)
173
192
 
package/README_ja.md CHANGED
@@ -68,9 +68,9 @@ related:: [[note-a]] and [[note-b]] are similar
68
68
 
69
69
  | ロール | フィールド名 |
70
70
  | --- | --- |
71
- | `parents` | `parent`, `parents`, `up`, `u`, `north`, `origin`, `inception` |
72
- | `children` | `children`, `child`, `down`, `d`, `south`, `leads to`, `contributes to` |
73
- | `leftFriends` | `friends`, `friend`, `similar`, `supports`, `alternatives`, `advantages` |
71
+ | `parents` | `parent`, `parents`, `up`, `u`, `north`, `origin`, `inception`, `source`, `parent domain` |
72
+ | `children` | `children`, `child`, `down`, `d`, `south`, `leads to`, `contributes to`, `nurtures` |
73
+ | `leftFriends` | `friends`, `friend`, `jump`, `jumps`, `j`, `similar`, `supports`, `alternatives`, `advantages`, `pros` |
74
74
  | `rightFriends` | `opposes`, `disadvantages`, `missing`, `cons` |
75
75
  | `previous` | `previous`, `prev`, `west`, `w`, `before` |
76
76
  | `next` | `next`, `n`, `east`, `e`, `after` |
@@ -78,6 +78,8 @@ related:: [[note-a]] and [[note-b]] are similar
78
78
 
79
79
  `ontology` オプションは既定のオントロジーを拡張します。各ロールのフィールド名は、そのロールの既定値を置き換えるのではなく末尾に追加されます。既存のフィールドを別のロールに追加することもできますが、正規の順序(`parents`、`children`、`leftFriends`、`rightFriends`、`previous`、`next`、`hidden`)で先に現れるロールが優先されます。
80
80
 
81
+ `hidden` は ExcaliBrain と同じく、このノートのマップから隠すターゲットを列挙するもので、ノート自体を隠すことはありません。`showHidden` を指定すると、これらのターゲットも表示します。
82
+
81
83
  ## 推論
82
84
 
83
85
  `infer` が有効な場合(既定)、次のように推論します。
@@ -88,6 +90,10 @@ related:: [[note-a]] and [[note-b]] are similar
88
90
 
89
91
  `siblings` が有効な場合(既定)、親ノートの他の子ノートを `sibling` として追加します。兄弟の推論には `infer` も必要で、`infer: false` にすると無効になります。リンク先はコンテンツマニフェストから解決し、解決できない場合は元のリンクテキストをラベルにした仮想ノード(`data-node-virtual="true"`)にします。
90
92
 
93
+ ## 公開範囲
94
+
95
+ ノードはコンテンツマニフェストから解決します。`publishing.routable` が false のターゲットはマップから除外するため、公開対象外のノートがノードやリンクとして現れることはなく、タイトルやパーマリンクも漏れません。
96
+
91
97
  ## 描画
92
98
 
93
99
  `render` で描画する場所を選びます。
@@ -118,7 +124,7 @@ related:: [[note-a]] and [[note-b]] are similar
118
124
  | `infer` | `boolean` | `true` | リンクから関係を推論する |
119
125
  | `siblings` | `boolean` | `true` | 親から兄弟を推論する(`infer` が必要) |
120
126
  | `ontology` | object | — | ロールごとに末尾追加するオントロジーのフィールド名 |
121
- | `showHidden` | `boolean` | `false` | `hidden` のノートも含める |
127
+ | `showHidden` | `boolean` | `false` | `hidden` フィールドで指定したターゲットも含める |
122
128
  | `width` | `number` | `720` | SVG viewBox の幅 |
123
129
  | `height` | `number` | `480` | SVG viewBox の高さ |
124
130
  | `language` | `string` | `"excalibrain"` | 対象にするフェンス言語 |
@@ -138,6 +144,12 @@ related:: [[note-a]] and [[note-b]] are similar
138
144
 
139
145
  領域は `g.rb-excalibrain__region[data-region]`、ノードは `g.rb-excalibrain__node[data-node-role][data-node-slug][data-relation-type]` で、`<a href>` が `<rect>` と `<text>` を包みます。リンクは `path.rb-excalibrain__link[data-link-role][data-relation-type]` です。
140
146
 
147
+ ## 制約
148
+
149
+ - マップは閲覧専用です。クライアント側の処理は SVG を生成するだけで、ドラッグ、ズーム、展開・折りたたみの操作はありません。
150
+ - `maxPerRegion` は領域ごとのノード数を打ち切るため、関係が多いノートでは先頭のノードだけを表示します。
151
+ - 描画できるのは上記のオントロジーのロールだけで、ノード単位のスタイルや領域単位の設定は下記のオプション以外にありません。
152
+
141
153
  ## 主なエクスポート
142
154
 
143
155
  - `excaliBrain(options?)` / `excaliBrainPlugin`: プラグインを作成する
@@ -149,5 +161,5 @@ related:: [[note-a]] and [[note-b]] are similar
149
161
 
150
162
  ## 関連資料
151
163
 
152
- - [プラグインシステム](../../../docs/docs/reference/plugin-api.md)
164
+ - [プラグインシステム](../../../docs/docs/reference/plugin-api.ja.md)
153
165
 
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import type { ExcaliBrainOptions } from "./src/types.js";
2
2
  export { buildExcaliBrainGraph } from "./src/graph.js";
3
3
  export { layoutExcaliBrain } from "./src/layout.js";
4
4
  export type { DefinedRelation, ResolvedOntology, } from "./src/ontology.js";
5
- export { collectDefinedRelations, DEFAULT_ONTOLOGY, isNoteHidden, normalizeFieldName, resolveOntology, } from "./src/ontology.js";
5
+ export { collectDefinedRelations, collectHiddenTargets, DEFAULT_ONTOLOGY, normalizeFieldName, resolveOntology, } from "./src/ontology.js";
6
6
  export type { ResolvedExcaliBrainOptions } from "./src/options.js";
7
7
  export { resolveExcaliBrainOptions, validateExcaliBrainOptions, } from "./src/options.js";
8
8
  export { renderExcaliBrainSection, renderExcaliBrainSvg, } from "./src/render.js";
package/dist/index.js CHANGED
@@ -7,7 +7,17 @@ import {
7
7
 
8
8
  // src/ontology.ts
9
9
  var DEFAULT_ONTOLOGY = {
10
- parents: ["parent", "parents", "up", "u", "north", "origin", "inception"],
10
+ parents: [
11
+ "parent",
12
+ "parents",
13
+ "up",
14
+ "u",
15
+ "north",
16
+ "origin",
17
+ "inception",
18
+ "source",
19
+ "parent domain"
20
+ ],
11
21
  children: [
12
22
  "children",
13
23
  "child",
@@ -15,15 +25,20 @@ var DEFAULT_ONTOLOGY = {
15
25
  "d",
16
26
  "south",
17
27
  "leads to",
18
- "contributes to"
28
+ "contributes to",
29
+ "nurtures"
19
30
  ],
20
31
  leftFriends: [
21
32
  "friends",
22
33
  "friend",
34
+ "jump",
35
+ "jumps",
36
+ "j",
23
37
  "similar",
24
38
  "supports",
25
39
  "alternatives",
26
- "advantages"
40
+ "advantages",
41
+ "pros"
27
42
  ],
28
43
  rightFriends: ["opposes", "disadvantages", "missing", "cons"],
29
44
  previous: ["previous", "prev", "west", "w", "before"],
@@ -95,14 +110,18 @@ function collectDefinedRelations(input) {
95
110
  }
96
111
  return relations;
97
112
  }
98
- function isNoteHidden(input) {
99
- for (const field of Object.keys(input.frontmatter)) {
100
- if (fieldRoleOf(field, input.ontology) === "hidden") return true;
113
+ function collectHiddenTargets(input) {
114
+ const targets = [];
115
+ const inlineFields = extractInlineFields(input.markdown);
116
+ for (const [field, value] of Object.entries(input.frontmatter)) {
117
+ if (fieldRoleOf(field, input.ontology) !== "hidden") continue;
118
+ targets.push(...extractTargets(value));
101
119
  }
102
- for (const [field] of extractInlineFields(input.markdown)) {
103
- if (fieldRoleOf(field, input.ontology) === "hidden") return true;
120
+ for (const [field, value] of inlineFields) {
121
+ if (fieldRoleOf(field, input.ontology) !== "hidden") continue;
122
+ targets.push(...extractTargets(value));
104
123
  }
105
- return false;
124
+ return targets;
106
125
  }
107
126
  var WIKILINK_PATTERN = /\[\[([^\]|#^]+)(?:[#^][^\]|]+)?(?:\|[^\]]+)?\]\]/g;
108
127
  function extractWikilinkTargets(value) {
@@ -236,16 +255,19 @@ function buildExcaliBrainGraph(input) {
236
255
  role: "center",
237
256
  relationType: "defined"
238
257
  };
239
- if (!options.showHidden && isNoteHidden({
240
- frontmatter: input.frontmatter,
241
- markdown: input.markdown,
242
- ontology: options.ontology
243
- })) {
244
- return { center, nodes: [], links: [] };
245
- }
258
+ const hiddenTargets = new Set(
259
+ collectHiddenTargets({
260
+ frontmatter: input.frontmatter,
261
+ markdown: input.markdown,
262
+ ontology: options.ontology
263
+ }).map((target) => target.trim().toLowerCase())
264
+ );
246
265
  const relations = /* @__PURE__ */ new Map();
247
266
  const add = (target, role, relationType) => {
248
267
  if (role === "center") return;
268
+ if (!options.showHidden && hiddenTargets.has(target.trim().toLowerCase())) {
269
+ return;
270
+ }
249
271
  const node = resolveNode(target, slug, manifest, input.isRoutable);
250
272
  if (!node) return;
251
273
  const existing = relations.get(node.id);
@@ -774,9 +796,9 @@ export {
774
796
  DEFAULT_ONTOLOGY,
775
797
  buildExcaliBrainGraph,
776
798
  collectDefinedRelations,
799
+ collectHiddenTargets,
777
800
  excaliBrain,
778
801
  excaliBrainPlugin,
779
- isNoteHidden,
780
802
  layoutExcaliBrain,
781
803
  normalizeFieldName,
782
804
  renderExcaliBrainSection,
@@ -25,11 +25,16 @@ export declare function collectDefinedRelations(input: {
25
25
  markdown: string;
26
26
  ontology: ResolvedOntology;
27
27
  }): DefinedRelation[];
28
- export declare function isNoteHidden(input: {
28
+ /**
29
+ * Collect the targets this note hides with its `hidden` fields. ExcaliBrain's
30
+ * `hidden` field lists the targets to hide from the note's map; it never
31
+ * hides the note itself.
32
+ */
33
+ export declare function collectHiddenTargets(input: {
29
34
  frontmatter: Record<string, unknown>;
30
35
  markdown: string;
31
36
  ontology: ResolvedOntology;
32
- }): boolean;
37
+ }): string[];
33
38
  /** Extract `[[target]]` link targets from a raw value. */
34
39
  export declare function extractWikilinkTargets(value: string): string[];
35
40
  /** Extract `Field:: value` pairs from the note body (frontmatter excluded). */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riebeckite/plugin-excalibrain",
3
- "version": "0.0.19",
3
+ "version": "0.0.20",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -21,11 +21,11 @@
21
21
  "./style.css": "./style.css"
22
22
  },
23
23
  "dependencies": {
24
- "@riebeckite/core": "0.0.19"
24
+ "@riebeckite/core": "0.0.20"
25
25
  },
26
26
  "devDependencies": {
27
27
  "tsx": "^4.22.4",
28
- "@riebeckite/test": "0.0.19"
28
+ "@riebeckite/test": "0.0.20"
29
29
  },
30
30
  "publishConfig": {
31
31
  "access": "public"
package/style.css CHANGED
@@ -88,8 +88,14 @@
88
88
  font-size: 0.8125rem;
89
89
  }
90
90
 
91
- html[data-theme="dark"] .rb-excalibrain,
92
- html.dark .rb-excalibrain {
91
+ :is(:root, .rb-theme-root)[data-theme="dark"] .rb-excalibrain {
93
92
  --rb-excalibrain-ink: var(--rb-color-paper, #ffffff);
94
93
  --rb-excalibrain-paper: var(--rb-color-ink, #000000);
95
94
  }
95
+
96
+ @media (prefers-color-scheme: dark) {
97
+ :is(:root, .rb-theme-root):not([data-theme]) .rb-excalibrain {
98
+ --rb-excalibrain-ink: var(--rb-color-paper, #ffffff);
99
+ --rb-excalibrain-paper: var(--rb-color-ink, #000000);
100
+ }
101
+ }