@riebeckite/plugin-d2 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
@@ -58,7 +58,7 @@ client -> server: request
58
58
  - `div.rb-d2__canvas` — the diagram (`role="img"`, labelled by the caption
59
59
  when present)
60
60
  - `details.rb-d2__fallback` — collapsible diagram source
61
- - Static SVG is rendered at build time when `render` is `"build"` or `"both"`
61
+ - Static SVG is rendered at build time when `render` is `"build"`
62
62
  by running the D2.js WebAssembly engine (`@d2lang/d2`) directly in Node. No
63
63
  browser, network access, or system D2 binary is required.
64
64
  - The generated figure always carries `data-d2`, `data-d2-source`, and
@@ -81,7 +81,7 @@ client -> server: request
81
81
 
82
82
  | Option | Type | Default | Description |
83
83
  | ------ | ---- | ------- | ----------- |
84
- | `render` | `"build" \| "client" \| "both"` | `"build"` | When diagrams are rendered |
84
+ | `render` | `"build" \| "client"` | `"build"` | When diagrams are rendered |
85
85
  | `theme` | `number \| { light: number; dark: number }` | `{ light: 0, dark: 1 }` | D2 theme id(s) |
86
86
  | `layout` | `"dagre" \| "elk"` | `"dagre"` | D2 layout engine |
87
87
  | `caption` | `boolean` | `true` | Show title / `# caption:` as `figcaption` |
@@ -93,8 +93,6 @@ client -> server: request
93
93
  - `"build"` — render SVG at build time; diagrams that fail fall back to client
94
94
  rendering
95
95
  - `"client"` — skip build-time rendering, render in the browser only
96
- - `"both"` — compatibility alias. It currently behaves like `"build"`: build
97
- first, then client fallback only when build rendering fails
98
96
 
99
97
  ## Offline requirements
100
98
 
@@ -121,10 +119,8 @@ copy if the deployment has no outbound network access.
121
119
  the WASM startup cost repeatedly.
122
120
  - `layout: "elk"` uses D2's ELK engine, which is slower than `dagre`.
123
121
  - Multi-board and animated D2 output are not configured by this plugin.
124
- - The renderer is `@d2lang/d2` (MPL-2.0), the current package for the D2.js WASM
125
- build; `@terrastruct/d2` is its compatibility alias.
122
+ - The renderer is `@d2lang/d2` (MPL-2.0), which provides the D2.js WASM build.
126
123
 
127
124
  ## See also
128
125
 
129
- - [Plugin guide](../../../docs/docs/reference/plugin-api.en.md)
130
-
126
+ - [Plugin guide](../../../docs/docs/reference/plugin-api.md)
package/README_ja.md CHANGED
@@ -52,7 +52,7 @@ client -> server: request
52
52
  - `div.rb-d2__canvas`: 図本体(`role="img"`、キャプションがある場合はそれをラベルに使用)
53
53
  - `details.rb-d2__fallback`: 元の D2 記法を折りたたんで表示
54
54
 
55
- `render: "build"` または `"both"` では、D2.js の WebAssembly 版(`@d2lang/d2`)を Node 上で直接実行して静的な SVG を生成します。ブラウザ、ネットワーク接続、D2 本体のインストールはいずれも不要です。
55
+ `render: "build"` では、D2.js の WebAssembly 版(`@d2lang/d2`)を Node 上で直接実行して静的な SVG を生成します。ブラウザ、ネットワーク接続、D2 本体のインストールはいずれも不要です。
56
56
 
57
57
  生成される figure には常に `data-d2`、`data-d2-source`、`data-d2-layout` が付きます。`data-d2` は静的 SVG があれば `rendered`、クライアント側の描画に委ねる場合は `pending` になります。
58
58
 
@@ -68,14 +68,14 @@ client -> server: request
68
68
 
69
69
  | 項目 | 既定値 | 説明 |
70
70
  | --- | --- | --- |
71
- | `render` | `"build"` | `"build"`、`"client"`、`"both"` のいずれで描画するか |
71
+ | `render` | `"build"` | `"build"` または `"client"` のいずれで描画するか |
72
72
  | `theme` | `{ light: 0, dark: 1 }` | D2 のテーマ ID、または明暗別のテーマ ID |
73
73
  | `layout` | `"dagre"` | D2 のレイアウトエンジン(`"dagre"` または `"elk"`) |
74
74
  | `caption` | `true` | タイトルまたは `# caption:` をキャプションとして表示する |
75
75
  | `fallback` | `true` | 元の D2 記法を `<details>` に残す |
76
76
  | `className` | `"rb-d2"` | figure に付ける基準クラス |
77
77
 
78
- `"client"` はビルド時の描画を行いません。`"both"` は後方互換の値で、現在は `"build"` と同じくビルドを優先し、失敗時だけクライアント側へ切り替えます。
78
+ `"client"` はビルド時の描画を行いません。
79
79
 
80
80
  ## オフラインでの利用
81
81
 
@@ -97,9 +97,8 @@ client -> server: request
97
97
  - 図ごとに新しい D2 ワーカーを起動するため、大量の図を含むビルドでは WASM の起動コストが繰り返し発生します
98
98
  - `layout: "elk"` は D2 の ELK エンジンを使うため `dagre` より遅くなります
99
99
  - マルチボードやアニメーション付きの出力はこのプラグインでは設定できません
100
- - レンダラーには `@d2lang/d2`(MPL-2.0)を使用しています。`@terrastruct/d2` はその後方互換パッケージです
100
+ - レンダラーには D2.js の WebAssembly ビルドを提供する `@d2lang/d2`(MPL-2.0)を使用しています
101
101
 
102
102
  ## 関連資料
103
103
 
104
- - [プラグインシステム](../../../docs/docs/reference/plugin-api.md)
105
-
104
+ - [プラグインシステム](../../../docs/docs/reference/plugin-api.ja.md)
package/dist/index.js CHANGED
@@ -340,7 +340,7 @@ function extractCaption(source, pre, code) {
340
340
  return { caption: caption?.trim() || null, body: body.trim() };
341
341
  }
342
342
  function shouldRenderAtBuild(render) {
343
- return render === "build" || render === "both";
343
+ return render === "build";
344
344
  }
345
345
  function shouldRenderAtClient(render) {
346
346
  return render === "client";
@@ -396,10 +396,10 @@ var d2Plugin = d2;
396
396
  function validateD2Options(options) {
397
397
  if (!options) return [];
398
398
  const issues = [];
399
- if (options.render !== void 0 && options.render !== "build" && options.render !== "client" && options.render !== "both") {
399
+ if (options.render !== void 0 && options.render !== "build" && options.render !== "client") {
400
400
  issues.push({
401
401
  path: "render",
402
- message: 'Expected "build", "client", or "both".'
402
+ message: 'Expected "build" or "client".'
403
403
  });
404
404
  }
405
405
  if (options.layout !== void 0 && !LAYOUTS.includes(options.layout)) {
@@ -1,4 +1,4 @@
1
- export type D2RenderMode = "build" | "client" | "both";
1
+ export type D2RenderMode = "build" | "client";
2
2
  export type D2Layout = "dagre" | "elk";
3
3
  /**
4
4
  * D2 theme id, or a light/dark pair of theme ids. D2's default theme is `0`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riebeckite/plugin-d2",
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",
@@ -22,7 +22,7 @@
22
22
  },
23
23
  "dependencies": {
24
24
  "@d2lang/d2": "^0.1.34",
25
- "@riebeckite/core": "0.0.19"
25
+ "@riebeckite/core": "0.0.20"
26
26
  },
27
27
  "publishConfig": {
28
28
  "access": "public"
package/style.css CHANGED
@@ -58,8 +58,14 @@
58
58
  color: var(--rb-d2-muted);
59
59
  }
60
60
 
61
- html[data-theme="dark"] .rb-d2,
62
- html.dark .rb-d2 {
61
+ :is(:root, .rb-theme-root)[data-theme="dark"] .rb-d2 {
63
62
  --rb-d2-paper: var(--rb-color-ink, #000000);
64
63
  --rb-d2-ink: var(--rb-color-paper, #ffffff);
65
64
  }
65
+
66
+ @media (prefers-color-scheme: dark) {
67
+ :is(:root, .rb-theme-root):not([data-theme]) .rb-d2 {
68
+ --rb-d2-paper: var(--rb-color-ink, #000000);
69
+ --rb-d2-ink: var(--rb-color-paper, #ffffff);
70
+ }
71
+ }