diagrams-js 0.0.7 → 0.0.9
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.d.ts +19 -84
- package/dist/index.js +9 -9
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
//#region src/types.d.ts
|
|
2
2
|
declare const THEMES: {
|
|
3
|
-
readonly neutral: {
|
|
4
|
-
readonly bgcolor: readonly ["#F8F9FA", "#F1F3F5", "#E9ECEF", "#DEE2E6"];
|
|
5
|
-
readonly pencolor: "#ADB5BD";
|
|
6
|
-
readonly edgecolor: "#495057";
|
|
7
|
-
};
|
|
8
3
|
readonly pastel: {
|
|
9
4
|
readonly bgcolor: readonly ["#E5F5FD", "#EBF3E7", "#ECE8F6", "#FDF7E3"];
|
|
10
5
|
readonly pencolor: "#AEB6BE";
|
|
11
6
|
readonly edgecolor: "#7B8894";
|
|
12
7
|
};
|
|
8
|
+
readonly neutral: {
|
|
9
|
+
readonly bgcolor: readonly ["#F8F9FA", "#F1F3F5", "#E9ECEF", "#DEE2E6"];
|
|
10
|
+
readonly pencolor: "#ADB5BD";
|
|
11
|
+
readonly edgecolor: "#495057";
|
|
12
|
+
};
|
|
13
13
|
readonly blues: {
|
|
14
14
|
readonly bgcolor: readonly ["#E7F5FF", "#D0EBFF", "#A5D8FF", "#74C0FC"];
|
|
15
15
|
readonly pencolor: "#339AF0";
|
|
@@ -92,8 +92,6 @@ declare namespace Edge {
|
|
|
92
92
|
}
|
|
93
93
|
//#endregion
|
|
94
94
|
//#region src/Node.d.ts
|
|
95
|
-
declare function setIconBaseDir(dir: string): void;
|
|
96
|
-
declare function getIconBaseDir(): string;
|
|
97
95
|
interface Node {
|
|
98
96
|
label: string;
|
|
99
97
|
nodeId: string;
|
|
@@ -151,67 +149,20 @@ interface NodeIconMap {
|
|
|
151
149
|
interface IconData {
|
|
152
150
|
[key: string]: string;
|
|
153
151
|
}
|
|
154
|
-
/**
|
|
155
|
-
* Load an icon as a base64 data URI (browser only)
|
|
156
|
-
* @param path - Path to the icon file
|
|
157
|
-
* @returns Promise resolving to the data URI
|
|
158
|
-
*/
|
|
159
|
-
declare function loadIcon(path: string): Promise<string | null>;
|
|
160
|
-
/**
|
|
161
|
-
* Load multiple icons as data URIs (browser only)
|
|
162
|
-
* @param iconPaths - Map of icon keys to paths
|
|
163
|
-
* @returns Promise resolving to map of icon keys to data URIs
|
|
164
|
-
*/
|
|
165
|
-
declare function loadIcons(iconPaths: Record<string, string>): Promise<IconData>;
|
|
166
|
-
/**
|
|
167
|
-
* Inject icons into an SVG string using <use> tags for deduplication
|
|
168
|
-
* Works in both browser and Node.js environments
|
|
169
|
-
* @param svgString - The SVG string to inject icons into
|
|
170
|
-
* @param nodeMap - Map of nodes to their icon keys
|
|
171
|
-
* @param iconData - Map of icon keys to data URIs
|
|
172
|
-
* @returns Modified SVG string with icons injected
|
|
173
|
-
*/
|
|
174
|
-
declare function injectIcons(svgString: string, nodeMap: NodeIconMap[], iconData: IconData): string;
|
|
175
|
-
/**
|
|
176
|
-
* Helper class to manage icon loading and injection
|
|
177
|
-
*/
|
|
178
|
-
declare class IconManager {
|
|
179
|
-
private nodeMap;
|
|
180
|
-
private iconData;
|
|
181
|
-
private iconBaseDir;
|
|
182
|
-
constructor(iconBaseDir?: string);
|
|
183
|
-
/**
|
|
184
|
-
* Register a node with its icon
|
|
185
|
-
* @param node - The node to register
|
|
186
|
-
* @param iconKey - Key for the icon (used in iconData)
|
|
187
|
-
* @param iconPath - Optional specific path to the icon
|
|
188
|
-
*/
|
|
189
|
-
register(node: Node, iconKey: string, iconPath?: string): void;
|
|
190
|
-
/**
|
|
191
|
-
* Load all registered icons (browser only)
|
|
192
|
-
*/
|
|
193
|
-
loadAllIcons(): Promise<void>;
|
|
194
|
-
/**
|
|
195
|
-
* Inject icons into an SVG string
|
|
196
|
-
* @param svgString - The SVG string to modify
|
|
197
|
-
* @returns Modified SVG string with icons
|
|
198
|
-
*/
|
|
199
|
-
inject(svgString: string): string;
|
|
200
|
-
/**
|
|
201
|
-
* Get all loaded icon data
|
|
202
|
-
*/
|
|
203
|
-
getIconData(): IconData;
|
|
204
|
-
/**
|
|
205
|
-
* Get the node map
|
|
206
|
-
*/
|
|
207
|
-
getNodeMap(): NodeIconMap[];
|
|
208
|
-
/**
|
|
209
|
-
* Clear all registered nodes and loaded icons
|
|
210
|
-
*/
|
|
211
|
-
clear(): void;
|
|
212
|
-
}
|
|
213
152
|
//#endregion
|
|
214
153
|
//#region src/Diagram.d.ts
|
|
154
|
+
type RenderFunction = {
|
|
155
|
+
(options?: {
|
|
156
|
+
format?: "svg" | "dot";
|
|
157
|
+
} & Omit<RenderOptions, "format">): Promise<string>;
|
|
158
|
+
(options: {
|
|
159
|
+
format: "png" | "jpg";
|
|
160
|
+
} & Omit<RenderOptions, "format">): Promise<Uint8Array>;
|
|
161
|
+
(options: {
|
|
162
|
+
dataUrl: true;
|
|
163
|
+
} & RenderOptions): Promise<string>;
|
|
164
|
+
(options?: RenderOptions): Promise<Uint8Array | string>;
|
|
165
|
+
};
|
|
215
166
|
interface Diagram {
|
|
216
167
|
name: string;
|
|
217
168
|
filename: string;
|
|
@@ -244,7 +195,7 @@ interface Diagram {
|
|
|
244
195
|
connect(from: Node, to: Node, edge: Edge): void;
|
|
245
196
|
subgraph(cluster: Cluster): void;
|
|
246
197
|
cluster(label: string): Cluster;
|
|
247
|
-
render
|
|
198
|
+
render: RenderFunction;
|
|
248
199
|
renderWithIcons(iconData?: IconData, nodeMap?: NodeIconMap[]): Promise<string>;
|
|
249
200
|
save(filepath?: string, options?: RenderOptions): Promise<void>;
|
|
250
201
|
toString(): string;
|
|
@@ -286,20 +237,4 @@ declare function Custom(label: string, iconUrl: string, options?: {
|
|
|
286
237
|
imagescale?: string;
|
|
287
238
|
}): ReturnType<typeof Node> & CustomNode;
|
|
288
239
|
//#endregion
|
|
289
|
-
|
|
290
|
-
declare function getDiagram(): Diagram | undefined;
|
|
291
|
-
declare function setDiagram(diagram: Diagram): void;
|
|
292
|
-
declare function clearDiagram(): Diagram | undefined;
|
|
293
|
-
declare function getCluster(): Cluster | undefined;
|
|
294
|
-
declare function setCluster(cluster: Cluster): void;
|
|
295
|
-
declare function clearCluster(): Cluster | undefined;
|
|
296
|
-
/**
|
|
297
|
-
* Run a callback with a specific diagram in context
|
|
298
|
-
*/
|
|
299
|
-
declare function runWithDiagram<R>(diagram: Diagram, callback: () => R): R;
|
|
300
|
-
/**
|
|
301
|
-
* Run a callback with a specific cluster in context
|
|
302
|
-
*/
|
|
303
|
-
declare function runWithCluster<R>(cluster: Cluster | undefined, callback: () => R): R;
|
|
304
|
-
//#endregion
|
|
305
|
-
export { Cluster, type Cluster as ClusterInterface, Cluster as Group, Custom, type CustomNode, Diagram, type Diagram as DiagramInterface, type DiagramOptions, Edge, type Edge as EdgeInterface, type EdgeOptions, type IconData, IconManager, type Node, type Node as NodeInterface, type NodeIconMap, type NodeOptions, type ThemeConfig, type ThemeName, clearCluster, clearDiagram, getCluster, getDiagram, getIconBaseDir, injectIcons, loadIcon, loadIcons, runWithCluster, runWithDiagram, setCluster, setDiagram, setIconBaseDir };
|
|
240
|
+
export { type Cluster, Custom, Diagram, type DiagramOptions, Edge, type EdgeOptions, type Node, type NodeOptions, type ThemeConfig, type ThemeName };
|