@riebeckite/plugin-plantuml 0.0.31 → 0.0.33

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
@@ -20,7 +20,7 @@ export default defineConfig({
20
20
  });
21
21
  ```
22
22
 
23
- `plantuml` is also exported under the alias `plantumlPlugin`.
23
+ `plantuml` is also exported under the alias `plantuml`.
24
24
 
25
25
  ## Live example
26
26
 
@@ -100,7 +100,7 @@ Encoding failures are reported with `file.message(...)`. Diagnostics use
100
100
  ## Exports
101
101
 
102
102
  - `plantuml(options?)` — plugin factory
103
- - `plantumlPlugin` — alias of `plantuml`
103
+ - `plantuml` — alias of `plantuml`
104
104
  - Types: `PlantumlOptions`, `PlantumlFormat`
105
105
 
106
106
  ## See also
package/README_ja.md CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  [English](./README.md)
8
8
 
9
- ## 設定する
9
+ ## 使い方
10
10
 
11
11
  ```ts
12
12
  import { defineConfig } from "@riebeckite/core";
@@ -18,7 +18,7 @@ export default defineConfig({
18
18
  });
19
19
  ```
20
20
 
21
- `plantuml` は `plantumlPlugin` という別名でもエクスポートしています。
21
+ `plantuml` は `plantuml` という別名でもエクスポートしています。
22
22
 
23
23
  ## 実行例
24
24
 
@@ -35,7 +35,7 @@ Bob --> Alice: Hi
35
35
  ```
36
36
  ````
37
37
 
38
- #### 実行例
38
+ #### 描画結果
39
39
 
40
40
  ```plantuml
41
41
  @startuml
@@ -71,7 +71,7 @@ Bob --> Alice: Hi
71
71
 
72
72
  ## 出力される HTML / CSS
73
73
 
74
- プラグインは `style.css` を公開し、`rb-plantuml`、`rb-plantuml__frame`、`rb-plantuml__image`、`rb-plantuml__caption`、`rb-plantuml__fallback` という安定したクラス名で出力します。CSS 変数 `--rb-color-*` があればそれに追従し、`html[data-theme="dark"]`、または `data-theme` が無いときの `prefers-color-scheme: dark` で暗色に切り替わります。
74
+ プラグインは `style.css` を公開し、`rb-plantuml`、`rb-plantuml__frame`、`rb-plantuml__image`、`rb-plantuml__caption`、`rb-plantuml__fallback` という安定したクラス名で出力します。CSS 変数 `--rb-color-*` があればそれに追従し、`html[data-theme="dark"]`、または `data-theme` が無いときの `prefers-color-scheme: dark` で暗い配色に切り替わります。
75
75
 
76
76
  ## 診断
77
77
 
@@ -86,7 +86,7 @@ Bob --> Alice: Hi
86
86
  ## 主なエクスポート
87
87
 
88
88
  - `plantuml(options?)`: プラグインを作成する
89
- - `plantumlPlugin`: `plantuml` の別名
89
+ - `plantuml`: `plantuml` の別名
90
90
  - 型: `PlantumlOptions`、`PlantumlFormat`
91
91
 
92
92
  ## 関連資料
package/dist/index.d.ts CHANGED
@@ -7,4 +7,3 @@ export type { PlantumlFormat, PlantumlOptions } from "./src/types.js";
7
7
  * required while building and no client bundle is shipped.
8
8
  */
9
9
  export declare function plantuml(options?: PlantumlOptions): import("@riebeckite/core").RiebeckitePlugin<PlantumlOptions>;
10
- export declare const plantumlPlugin: typeof plantuml;
package/dist/index.js CHANGED
@@ -14,60 +14,30 @@ var __export = (target, all) => {
14
14
  };
15
15
 
16
16
  // src/hast.ts
17
- function visitElements(node, visitor, parent, index) {
18
- if (isElementNode(node)) visitor(node, parent, index);
19
- for (const [childIndex, child] of [...getChildren(node)].entries()) {
20
- visitElements(
21
- child,
22
- visitor,
23
- hasChildren(node) ? node : parent,
24
- childIndex
25
- );
26
- }
27
- }
28
- function element(tagName, properties = {}, children = []) {
29
- return { type: "element", tagName, properties, children };
30
- }
31
- function text(value) {
32
- return { type: "text", value };
33
- }
34
- function getTextContent(node) {
35
- if (node.type === "text" && "value" in node && typeof node.value === "string") {
36
- return node.value;
37
- }
38
- return getChildren(node).map(getTextContent).join("");
39
- }
40
- function getStringProperty(node, key) {
41
- const value = node.properties?.[key];
42
- if (typeof value === "string") return value;
43
- if (Array.isArray(value)) return value.join(" ");
44
- return null;
45
- }
46
- function hasClass(node, className) {
47
- const value = node.properties?.className;
48
- const classes = Array.isArray(value) ? value.map(String) : typeof value === "string" ? value.split(/\s+/) : [];
49
- return classes.includes(className);
50
- }
51
- function isElementNode(node) {
52
- return node.type === "element";
53
- }
54
- function hasChildren(node) {
55
- return Array.isArray(node.children);
56
- }
57
- function getChildren(node) {
58
- const children = node.children;
59
- return Array.isArray(children) ? children : [];
60
- }
17
+ import {
18
+ element as sharedElement,
19
+ getStringProperty as sharedGetStringProperty,
20
+ getTextContent as sharedGetTextContent,
21
+ hasClass as sharedHasClass,
22
+ text as sharedText,
23
+ visitElements as sharedVisitElements
24
+ } from "@riebeckite/diagram";
25
+ var element, text, getTextContent, getStringProperty, hasClass, visitElements;
61
26
  var init_hast = __esm({
62
27
  "src/hast.ts"() {
28
+ element = sharedElement;
29
+ text = sharedText;
30
+ getTextContent = sharedGetTextContent;
31
+ getStringProperty = sharedGetStringProperty;
32
+ hasClass = sharedHasClass;
33
+ visitElements = sharedVisitElements;
63
34
  }
64
35
  });
65
36
 
66
37
  // src/plantuml-encoder.ts
67
38
  var plantuml_encoder_exports = {};
68
39
  __export(plantuml_encoder_exports, {
69
- encodePlantuml: () => encodePlantuml,
70
- encodePlantumlBase64: () => encodePlantumlBase64
40
+ encodePlantuml: () => encodePlantuml
71
41
  });
72
42
  async function encodePlantuml(source) {
73
43
  const { deflateRawSync } = await import("node:zlib");
@@ -172,10 +142,14 @@ function buildFigure(input) {
172
142
  );
173
143
  if (input.fallback) {
174
144
  children.push(
175
- element("details", { className: "rb-plantuml__fallback" }, [
176
- element("summary", {}, [text("Diagram source")]),
177
- element("pre", {}, [element("code", {}, [text(input.source)])])
178
- ])
145
+ element(
146
+ "details",
147
+ { className: "rb-plantuml__fallback rb-source-fallback" },
148
+ [
149
+ element("summary", {}, [text("Diagram source")]),
150
+ element("pre", {}, [element("code", {}, [text(input.source)])])
151
+ ]
152
+ )
179
153
  );
180
154
  }
181
155
  if (input.caption) {
@@ -269,7 +243,6 @@ function plantuml(options = {}) {
269
243
  ]
270
244
  });
271
245
  }
272
- var plantumlPlugin = plantuml;
273
246
  function validatePlantumlOptions(options) {
274
247
  if (!options) return [];
275
248
  const issues = [];
@@ -300,6 +273,5 @@ function rehypePlantumlLazy(options = {}) {
300
273
  };
301
274
  }
302
275
  export {
303
- plantuml,
304
- plantumlPlugin
276
+ plantuml
305
277
  };
@@ -1,7 +1,7 @@
1
1
  import type { ElementNode, HastNode, ParentNode, TextNode } from "./types.js";
2
- export declare function visitElements(node: HastNode, visitor: (node: ElementNode, parent?: ParentNode, index?: number) => void, parent?: ParentNode, index?: number): void;
3
- export declare function element(tagName: string, properties?: Record<string, unknown>, children?: HastNode[]): ElementNode;
4
- export declare function text(value: string): TextNode;
5
- export declare function getTextContent(node: HastNode): string;
6
- export declare function getStringProperty(node: ElementNode, key: string): string | null;
7
- export declare function hasClass(node: ElementNode, className: string): boolean;
2
+ export declare const element: (tagName: string, properties?: Record<string, unknown>, children?: HastNode[]) => ElementNode;
3
+ export declare const text: (value: string) => TextNode;
4
+ export declare const getTextContent: (node: HastNode) => string;
5
+ export declare const getStringProperty: (node: ElementNode, key: string) => string | null;
6
+ export declare const hasClass: (node: ElementNode, className: string) => boolean;
7
+ export declare const visitElements: (node: HastNode, visitor: (node: ElementNode, parent?: ParentNode, index?: number) => void, parent?: ParentNode, index?: number) => void;
@@ -32,9 +32,3 @@
32
32
  */
33
33
  /** Encodes PlantUML source into the server URL path segment. */
34
34
  export declare function encodePlantuml(source: string): Promise<string>;
35
- /**
36
- * Re-encodes raw DEFLATE bytes with PlantUML's custom base64 alphabet.
37
- * Exposed separately from the compression step so it can be reasoned about
38
- * (and tested) without a Node runtime.
39
- */
40
- export declare function encodePlantumlBase64(bytes: Uint8Array): string;
@@ -36,7 +36,7 @@ export type TextNode = {
36
36
  type: "text";
37
37
  value: string;
38
38
  };
39
- export type RawNode = {
39
+ type RawNode = {
40
40
  type: "raw";
41
41
  value: string;
42
42
  };
@@ -44,3 +44,4 @@ export type HastNode = ElementNode | TextNode | RawNode | {
44
44
  type: string;
45
45
  [key: string]: unknown;
46
46
  };
47
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riebeckite/plugin-plantuml",
3
- "version": "0.0.31",
3
+ "version": "0.0.33",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -15,7 +15,8 @@
15
15
  "./style.css": "./style.css"
16
16
  },
17
17
  "dependencies": {
18
- "@riebeckite/core": "0.0.31"
18
+ "@riebeckite/core": "0.0.33",
19
+ "@riebeckite/diagram": "0.0.33"
19
20
  },
20
21
  "publishConfig": {
21
22
  "access": "public"
package/style.css CHANGED
@@ -41,29 +41,6 @@
41
41
  font-size: 0.875rem;
42
42
  }
43
43
 
44
- .rb-plantuml__fallback {
45
- align-self: stretch;
46
- border-top: 1px solid var(--rb-plantuml-rule);
47
- color: var(--rb-plantuml-muted);
48
- font-size: 0.8125rem;
49
- text-align: left;
50
- }
51
-
52
- .rb-plantuml__fallback summary {
53
- cursor: pointer;
54
- padding: 0.5rem 0;
55
- }
56
-
57
- .rb-plantuml__fallback pre {
58
- overflow: auto;
59
- margin: 0;
60
- padding: 0.75rem;
61
- border-top: 1px solid var(--rb-plantuml-rule);
62
- color: var(--rb-plantuml-ink);
63
- background: color-mix(in srgb, var(--rb-plantuml-ink) 6%, transparent);
64
- text-align: left;
65
- }
66
-
67
44
  .rb-plantuml__frame:empty::before {
68
45
  content: "Diagram could not be rendered.";
69
46
  color: var(--rb-plantuml-muted);