@loaders.gl/graphs 5.0.0-alpha.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.
Files changed (53) hide show
  1. package/README.md +66 -0
  2. package/dist/dot-loader-types.d.ts +36 -0
  3. package/dist/dot-loader-types.d.ts.map +1 -0
  4. package/dist/dot-loader-types.js +26 -0
  5. package/dist/dot-loader-types.js.map +1 -0
  6. package/dist/dot-loader.cjs +1482 -0
  7. package/dist/dot-loader.cjs.map +6 -0
  8. package/dist/dot-loader.d.ts +20 -0
  9. package/dist/dot-loader.d.ts.map +1 -0
  10. package/dist/dot-loader.js +13 -0
  11. package/dist/dot-loader.js.map +1 -0
  12. package/dist/dot-types.d.ts +32 -0
  13. package/dist/dot-types.d.ts.map +1 -0
  14. package/dist/dot-types.js +5 -0
  15. package/dist/dot-types.js.map +1 -0
  16. package/dist/graph-types.d.ts +28 -0
  17. package/dist/graph-types.d.ts.map +1 -0
  18. package/dist/graph-types.js +5 -0
  19. package/dist/graph-types.js.map +1 -0
  20. package/dist/graphml-loader-types.d.ts +36 -0
  21. package/dist/graphml-loader-types.d.ts.map +1 -0
  22. package/dist/graphml-loader-types.js +26 -0
  23. package/dist/graphml-loader-types.js.map +1 -0
  24. package/dist/graphml-loader.cjs +650 -0
  25. package/dist/graphml-loader.cjs.map +6 -0
  26. package/dist/graphml-loader.d.ts +20 -0
  27. package/dist/graphml-loader.d.ts.map +1 -0
  28. package/dist/graphml-loader.js +13 -0
  29. package/dist/graphml-loader.js.map +1 -0
  30. package/dist/index.cjs +1136 -0
  31. package/dist/index.cjs.map +6 -0
  32. package/dist/index.d.ts +5 -0
  33. package/dist/index.d.ts.map +1 -0
  34. package/dist/index.js +6 -0
  35. package/dist/index.js.map +1 -0
  36. package/dist/lib/parse-dot.d.ts +4 -0
  37. package/dist/lib/parse-dot.d.ts.map +1 -0
  38. package/dist/lib/parse-dot.js +724 -0
  39. package/dist/lib/parse-dot.js.map +1 -0
  40. package/dist/lib/parse-graphml.d.ts +6 -0
  41. package/dist/lib/parse-graphml.d.ts.map +1 -0
  42. package/dist/lib/parse-graphml.js +296 -0
  43. package/dist/lib/parse-graphml.js.map +1 -0
  44. package/package.json +58 -0
  45. package/src/dot-loader-types.ts +31 -0
  46. package/src/dot-loader.ts +14 -0
  47. package/src/dot-types.ts +38 -0
  48. package/src/graph-types.ts +33 -0
  49. package/src/graphml-loader-types.ts +31 -0
  50. package/src/graphml-loader.ts +14 -0
  51. package/src/index.ts +8 -0
  52. package/src/lib/parse-dot.ts +924 -0
  53. package/src/lib/parse-graphml.ts +414 -0
package/README.md ADDED
@@ -0,0 +1,66 @@
1
+ # @loaders.gl/graphs
2
+
3
+ Framework-independent loaders for GraphML and Graphviz DOT documents.
4
+
5
+ ## GraphML loader
6
+
7
+ `GraphMLLoader` reads the first graph in a GraphML 1.0 document.
8
+
9
+ ```typescript
10
+ import {load} from '@loaders.gl/core';
11
+ import {GraphMLLoader} from '@loaders.gl/graphs';
12
+
13
+ const graph = await load('network.graphml', GraphMLLoader);
14
+ ```
15
+
16
+ For synchronous parsing, import `GraphMLLoaderWithParser` from
17
+ `@loaders.gl/graphs/graphml-loader` and pass it to `parseSync` from `@loaders.gl/core`.
18
+ The package root exports metadata only; asynchronous core APIs preload the implementation.
19
+
20
+ The result is `GraphData` with `shape: 'plain-graph-data'`, `nodes`, and `edges`.
21
+ Nodes have `id`, optional `label`, and optional `attributes`. Edges additionally have
22
+ `sourceId`, `targetId`, and `directed`. This shape is compatible with
23
+ `createGraphFromData` in `@deck.gl-community/graph-layers`.
24
+
25
+ Supported constructs include node and edge identifiers, generated IDs for unnamed edges,
26
+ `edgedefault` and per-edge direction overrides, node/edge/all keys, typed data and defaults,
27
+ unknown data keys, and namespace-prefixed elements. Numeric and boolean keys become JavaScript
28
+ values; other values remain strings. Nested XML data becomes a JSON string.
29
+
30
+ Only the first graph is returned. Nested graphs, hyperedges, ports, and graph-level data are
31
+ ignored. Nodes without IDs and edges without endpoints are skipped. This is a permissive
32
+ parser, not a GraphML schema validator. Long integers use JavaScript numbers and may lose
33
+ precision outside the safe integer range.
34
+
35
+
36
+ ## DOT loader
37
+
38
+ ```typescript
39
+ import {load} from '@loaders.gl/core';
40
+ import {DOTLoader} from '@loaders.gl/graphs';
41
+
42
+ const graph = await load('network.dot', DOTLoader);
43
+ ```
44
+
45
+ Use `DOTLoaderWithParser` from `@loaders.gl/graphs/dot-loader` with `parseSync`
46
+ for synchronous text or UTF-8 `ArrayBuffer` parsing. `DOTLoader` recognizes `.dot` and `.gv` files.
47
+
48
+ The loader returns the same plain `GraphData` node/edge shape as GraphML, plus typed
49
+ DOT metadata: graph ID, direction, strictness, graph attributes, and subgraph descriptors.
50
+ Identifiers remain strings, including numeric-looking IDs. Unquoted numeric attributes
51
+ become numbers; quoted attributes remain strings. Node and edge `label` attributes are
52
+ also exposed as record labels.
53
+
54
+ Supported syntax includes `graph` and `digraph`, strict graphs with parallel-edge
55
+ coalescing, implicit nodes, chained edges, repeated attribute lists, scoped node/edge
56
+ defaults, graph attribute assignments, nested named and anonymous subgraphs, comments,
57
+ quoted identifiers, and balanced HTML-like labels. Node and edge attributes include
58
+ subgraph membership descriptors. Reopening a named subgraph retains its attributes and
59
+ node/edge defaults; anonymous subgraph identifiers remain distinct from explicit names. An edge `id`, `Id`, or `ID` attribute supplies its ID;
60
+ otherwise the loader generates an ID from its endpoints and a counter. `dir=none`
61
+ marks an edge as undirected; other `dir` strings mark it as directed.
62
+
63
+ This is a parser for the supported DOT subset, not a Graphviz renderer. Node ports,
64
+ subgraph endpoints in edge statements, and concatenated quoted strings are unsupported.
65
+ Port syntax is rejected; identifiers containing colons must be quoted. Truncated input,
66
+ trailing content, and edge operators inconsistent with the graph declaration are rejected.
@@ -0,0 +1,36 @@
1
+ import type { DOTGraphData } from "./dot-types.js";
2
+ /** Preloads the DOT parser implementation. */
3
+ declare function preload(): Promise<{
4
+ parse: (data: ArrayBuffer) => Promise<DOTGraphData>;
5
+ parseSync: (data: ArrayBuffer) => DOTGraphData;
6
+ parseTextSync: typeof import("./lib/parse-dot").parseDOT;
7
+ name: "DOT";
8
+ id: "dot";
9
+ module: "graphs";
10
+ version: any;
11
+ extensions: ["dot", "gv"];
12
+ mimeTypes: ["text/vnd.graphviz", "text/x-graphviz", "application/vnd.graphviz"];
13
+ text: true;
14
+ worker: false;
15
+ dataType: DOTGraphData;
16
+ batchType: never;
17
+ options: {};
18
+ preload: typeof preload;
19
+ }>;
20
+ /** Metadata-only loader for Graphviz DOT documents. */
21
+ export declare const DOTLoader: {
22
+ readonly name: "DOT";
23
+ readonly id: "dot";
24
+ readonly module: "graphs";
25
+ readonly version: any;
26
+ readonly extensions: ["dot", "gv"];
27
+ readonly mimeTypes: ["text/vnd.graphviz", "text/x-graphviz", "application/vnd.graphviz"];
28
+ readonly text: true;
29
+ readonly worker: false;
30
+ readonly dataType: DOTGraphData;
31
+ readonly batchType: never;
32
+ readonly options: {};
33
+ readonly preload: typeof preload;
34
+ };
35
+ export {};
36
+ //# sourceMappingURL=dot-loader-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dot-loader-types.d.ts","sourceRoot":"","sources":["../src/dot-loader-types.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,YAAY,EAAC,uBAAoB;AAK9C,8CAA8C;AAC9C,iBAAe,OAAO;;;;;;;;;;;;cAeS,YAAY;eACtB,KAAK;;;GAbzB;AAED,uDAAuD;AACvD,eAAO,MAAM,SAAS;;;;;;;;;uBASS,YAAY;wBACtB,KAAK;;;CAGsB,CAAC"}
@@ -0,0 +1,26 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+ // @ts-ignore __VERSION__ is injected by the build.
5
+ const VERSION = typeof "5.0.0-alpha.9" !== 'undefined' ? "5.0.0-alpha.9" : 'latest';
6
+ /** Preloads the DOT parser implementation. */
7
+ async function preload() {
8
+ const { DOTLoaderWithParser } = await import('@loaders.gl/graphs/dot-loader');
9
+ return DOTLoaderWithParser;
10
+ }
11
+ /** Metadata-only loader for Graphviz DOT documents. */
12
+ export const DOTLoader = {
13
+ name: 'DOT',
14
+ id: 'dot',
15
+ module: 'graphs',
16
+ version: VERSION,
17
+ extensions: ['dot', 'gv'],
18
+ mimeTypes: ['text/vnd.graphviz', 'text/x-graphviz', 'application/vnd.graphviz'],
19
+ text: true,
20
+ worker: false,
21
+ dataType: null,
22
+ batchType: null,
23
+ options: {},
24
+ preload
25
+ };
26
+ //# sourceMappingURL=dot-loader-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dot-loader-types.js","sourceRoot":"","sources":["../src/dot-loader-types.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,+BAA+B;AAC/B,oCAAoC;AAKpC,mDAAmD;AACnD,MAAM,OAAO,GAAG,sBAAkB,KAAK,WAAW,CAAC,CAAC,iBAAa,CAAC,CAAC,QAAQ,CAAC;AAE5E,8CAA8C;AAC9C,KAAK,UAAU,OAAO;IACpB,MAAM,EAAC,mBAAmB,EAAC,GAAG,MAAM,MAAM,CAAC,+BAA+B,CAAC,CAAC;IAC5E,OAAO,mBAAmB,CAAC;AAC7B,CAAC;AAED,uDAAuD;AACvD,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,IAAI,EAAE,KAAK;IACX,EAAE,EAAE,KAAK;IACT,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,OAAO;IAChB,UAAU,EAAE,CAAC,KAAK,EAAE,IAAI,CAAC;IACzB,SAAS,EAAE,CAAC,mBAAmB,EAAE,iBAAiB,EAAE,0BAA0B,CAAC;IAC/E,IAAI,EAAE,IAAI;IACV,MAAM,EAAE,KAAK;IACb,QAAQ,EAAE,IAA+B;IACzC,SAAS,EAAE,IAAa;IACxB,OAAO,EAAE,EAAE;IACX,OAAO;CACuC,CAAC"}