@riebeckite/plugin-wavedrom 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
@@ -76,6 +76,15 @@ You can also use a top-level `"caption"` key in the JSON. It is removed before t
76
76
  ```
77
77
  ````
78
78
 
79
+ ## Live example
80
+
81
+ ~~~wavedrom
82
+ { "signal": [
83
+ { "name": "clk", "wave": "p......" },
84
+ { "name": "bus", "wave": "x.34.5x", "data": "head body tail" }
85
+ ] }
86
+ ~~~
87
+
79
88
  ## Output
80
89
 
81
90
  ```html
package/README_ja.md CHANGED
@@ -76,6 +76,15 @@ JSON のトップレベル `"caption"` キーでも指定できます。この
76
76
  ```
77
77
  ````
78
78
 
79
+ ## 実行例
80
+
81
+ ~~~wavedrom
82
+ { "signal": [
83
+ { "name": "clk", "wave": "p......" },
84
+ { "name": "bus", "wave": "x.34.5x", "data": "head body tail" }
85
+ ] }
86
+ ~~~
87
+
79
88
  ## 出力
80
89
 
81
90
  ```html
@@ -103,7 +112,7 @@ JSON のトップレベル `"caption"` キーでも指定できます。この
103
112
  | `skin` | `"default" \| "narrow" \| "lowkey"` | `"default"` | ブラウザ側で使う WaveDrom スキン |
104
113
  | `caption` | `boolean` | `true` | キャプションを `<figcaption>` として表示する |
105
114
  | `fallback` | `boolean` | `true` | WaveJSON ソースを `<details>` に表示する |
106
- | `className` | `string` | `"rb-wavedrom"` | figure に付ける基底クラス |
115
+ | `className` | `string` | `"rb-wavedrom"` | `<figure>` に付ける基底クラス |
107
116
 
108
117
  ## 診断
109
118
 
@@ -119,7 +128,7 @@ JSON のトップレベル `"caption"` キーでも指定できます。この
119
128
  - E2E のビルドは出力マークアップだけを検査します。実際の描画にはブラウザが必要です
120
129
  - 本文は厳密な JSON である必要があります。WaveDrom エディタが受け付ける JSON5 形式(引用符なしキー、シングルクォート、コメント)は受理しません
121
130
  - WaveJSON は HTML 属性に直接埋め込まれるため、巨大な図は避けてください
122
- - 認識するのは `wavedrom` と `wavejson` という info string だけです。他の言語には影響しません
131
+ - 認識するのは `wavedrom` と `wavejson` という info 文字列だけです。他の言語には影響しません
123
132
 
124
133
  ## 関連資料
125
134
 
package/dist/index.d.ts CHANGED
@@ -7,5 +7,3 @@ export type { WavedromOptions, WavedromSkin } from "./src/types.js";
7
7
  * drawn in the browser by `initWaveDrom`.
8
8
  */
9
9
  export declare function wavedrom(options?: WavedromOptions): import("@riebeckite/core").RiebeckitePlugin<WavedromOptions>;
10
- /** Alias kept for symmetry with the other plugin factories. */
11
- export declare const wavedromPlugin: typeof wavedrom;
package/dist/index.js CHANGED
@@ -6,50 +6,20 @@ import {
6
6
  } from "@riebeckite/core";
7
7
 
8
8
  // src/hast.ts
9
- function visitElements(node, visitor, parent, index) {
10
- if (isElementNode(node)) visitor(node, parent, index);
11
- for (const [childIndex, child] of [...getChildren(node)].entries()) {
12
- visitElements(
13
- child,
14
- visitor,
15
- hasChildren(node) ? node : parent,
16
- childIndex
17
- );
18
- }
19
- }
20
- function element(tagName, properties = {}, children = []) {
21
- return { type: "element", tagName, properties, children };
22
- }
23
- function text(value) {
24
- return { type: "text", value };
25
- }
26
- function getTextContent(node) {
27
- if (node.type === "text" && "value" in node && typeof node.value === "string") {
28
- return node.value;
29
- }
30
- return getChildren(node).map(getTextContent).join("");
31
- }
32
- function getStringProperty(node, key) {
33
- const value = node.properties?.[key];
34
- if (typeof value === "string") return value;
35
- if (Array.isArray(value)) return value.join(" ");
36
- return null;
37
- }
38
- function hasClass(node, className) {
39
- const value = node.properties?.className;
40
- const classes = Array.isArray(value) ? value.map(String) : typeof value === "string" ? value.split(/\s+/) : [];
41
- return classes.includes(className);
42
- }
43
- function isElementNode(node) {
44
- return node.type === "element";
45
- }
46
- function hasChildren(node) {
47
- return Array.isArray(node.children);
48
- }
49
- function getChildren(node) {
50
- const children = node.children;
51
- return Array.isArray(children) ? children : [];
52
- }
9
+ import {
10
+ element as sharedElement,
11
+ getStringProperty as sharedGetStringProperty,
12
+ getTextContent as sharedGetTextContent,
13
+ hasClass as sharedHasClass,
14
+ text as sharedText,
15
+ visitElements as sharedVisitElements
16
+ } from "@riebeckite/diagram";
17
+ var element = sharedElement;
18
+ var text = sharedText;
19
+ var getTextContent = sharedGetTextContent;
20
+ var getStringProperty = sharedGetStringProperty;
21
+ var hasClass = sharedHasClass;
22
+ var visitElements = sharedVisitElements;
53
23
 
54
24
  // src/rehype.ts
55
25
  var DEFAULT_CLASS_NAME = "rb-wavedrom";
@@ -118,10 +88,14 @@ function buildFigure(input) {
118
88
  );
119
89
  if (input.fallback) {
120
90
  children.push(
121
- element("details", { className: `${base}__fallback` }, [
122
- element("summary", {}, [text("WaveJSON source")]),
123
- element("pre", {}, [element("code", {}, [text(input.source)])])
124
- ])
91
+ element(
92
+ "details",
93
+ { className: `${base}__fallback rb-source-fallback` },
94
+ [
95
+ element("summary", {}, [text("WaveJSON source")]),
96
+ element("pre", {}, [element("code", {}, [text(input.source)])])
97
+ ]
98
+ )
125
99
  );
126
100
  }
127
101
  return element(
@@ -228,7 +202,6 @@ function wavedrom(options = {}) {
228
202
  ]
229
203
  });
230
204
  }
231
- var wavedromPlugin = wavedrom;
232
205
  function validateWavedromOptions(options) {
233
206
  if (!options) return [];
234
207
  const issues = [];
@@ -251,6 +224,5 @@ function validateWavedromOptions(options) {
251
224
  }
252
225
  export {
253
226
  rehypeWavedrom,
254
- wavedrom,
255
- wavedromPlugin
227
+ wavedrom
256
228
  };
@@ -1,8 +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;
8
- export declare function mergeClassName(current: unknown, next: string): string;
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;
@@ -11,7 +11,7 @@ export type TextNode = {
11
11
  type: "text";
12
12
  value: string;
13
13
  };
14
- export type RawNode = {
14
+ type RawNode = {
15
15
  type: "raw";
16
16
  value: string;
17
17
  };
@@ -35,3 +35,4 @@ export type WavedromOptions = {
35
35
  /** Base CSS class for the generated figure. Defaults to `"rb-wavedrom"`. */
36
36
  className?: string;
37
37
  };
38
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riebeckite/plugin-wavedrom",
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",
@@ -21,8 +21,9 @@
21
21
  "./style.css": "./style.css"
22
22
  },
23
23
  "dependencies": {
24
- "wavedrom": "^3.7.0",
25
- "@riebeckite/core": "0.0.31"
24
+ "@riebeckite/core": "0.0.33",
25
+ "@riebeckite/diagram": "0.0.33",
26
+ "wavedrom": "^3.7.0"
26
27
  },
27
28
  "publishConfig": {
28
29
  "access": "public"
package/style.css CHANGED
@@ -34,26 +34,6 @@
34
34
  height: auto;
35
35
  }
36
36
 
37
- .rb-wavedrom__fallback {
38
- border-top: 1px solid var(--rb-wavedrom-rule);
39
- color: var(--rb-wavedrom-muted);
40
- font-size: 0.8125rem;
41
- }
42
-
43
- .rb-wavedrom__fallback summary {
44
- cursor: pointer;
45
- padding: 0.5rem 0.75rem;
46
- }
47
-
48
- .rb-wavedrom__fallback pre {
49
- overflow: auto;
50
- margin: 0 1rem;
51
- padding: 0.75rem;
52
- border-top: 1px solid var(--rb-wavedrom-rule);
53
- color: var(--rb-wavedrom-ink);
54
- background: color-mix(in srgb, var(--rb-wavedrom-ink) 6%, transparent);
55
- }
56
-
57
37
  .rb-wavedrom[data-wavedrom="pending"] .rb-wavedrom__canvas:empty::before,
58
38
  .rb-wavedrom[data-wavedrom="error"] .rb-wavedrom__canvas:empty::before {
59
39
  content: "Timing diagram could not be rendered.";