@riebeckite/plugin-d2 0.0.31 → 0.0.32

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/dist/index.js CHANGED
@@ -14,52 +14,23 @@ 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
 
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riebeckite/plugin-d2",
3
- "version": "0.0.31",
3
+ "version": "0.0.32",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -22,7 +22,8 @@
22
22
  },
23
23
  "dependencies": {
24
24
  "@d2lang/d2": "^0.1.34",
25
- "@riebeckite/core": "0.0.31"
25
+ "@riebeckite/core": "0.0.32",
26
+ "@riebeckite/diagram": "0.0.32"
26
27
  },
27
28
  "publishConfig": {
28
29
  "access": "public"