ontologyviewer 0.1.2 → 0.2.0

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.
@@ -0,0 +1,58 @@
1
+ import type { OntologyEdge, OntologyGraph, OntologyNode } from "./graphModel";
2
+ export interface CompactTriplesResult {
3
+ nodes: OntologyNode[];
4
+ edges: OntologyEdge[];
5
+ /**
6
+ * Statements absorbed into a node because their object was folded away,
7
+ * keyed by node id — e.g. `":createdAt" -> ["range: dateTime"]`. Rendered on
8
+ * the node so nothing the document states disappears from view.
9
+ */
10
+ foldedFacts: Map<string, string[]>;
11
+ removedNodeCount: number;
12
+ removedEdgeCount: number;
13
+ }
14
+ /**
15
+ * Folds leaf annotation nodes out of the triples graph so the remaining boxes
16
+ * are the things the ontology is actually about.
17
+ *
18
+ * Measured on a 1182-triple schema-heavy ontology, the raw triples view drew
19
+ * 741 nodes and 1182 edges. Two thirds of those boxes carried no structure:
20
+ *
21
+ * - **485 literal nodes (65% of all boxes).** Every `rdfs:label` and
22
+ * `rdfs:comment` became its own box even though `buildGraphModel` already
23
+ * copies those values onto the subject's `label`/`comment` fields — the
24
+ * same fact drawn twice.
25
+ * - **A handful of enormous vocabulary hubs.** `owl:ObjectProperty` reached
26
+ * degree 105, `owl:DatatypeProperty` 95, `xsd:string` 56, `owl:Class` 49.
27
+ * No force-directed layout can arrange a 105-way hub, and none of them says
28
+ * anything as a node.
29
+ *
30
+ * Folding both takes that document to 246 nodes (-67%) and 349 edges (-70%).
31
+ *
32
+ * A node is folded when all three hold, which keeps the rule principled rather
33
+ * than a hardcoded blocklist:
34
+ * 1. it has no outgoing edges — it is purely something other nodes point at,
35
+ * 2. it has at least one incoming edge, and
36
+ * 3. it is a literal, or its IRI is in a standard vocabulary namespace
37
+ * (rdf, rdfs, owl, xsd, skos, dcterms, foaf).
38
+ *
39
+ * Condition 1 is what protects real structure: a document that states
40
+ * `xsd:string rdfs:comment "..."` has described that term, so it keeps its box.
41
+ *
42
+ * `rdfs:label` and `rdfs:comment` are folded *without* a fact line, because the
43
+ * node already displays them — restating them would reintroduce the very
44
+ * duplication being removed. Every other folded statement becomes a fact line.
45
+ *
46
+ * Note what this deliberately does **not** do: hide property nodes. On a
47
+ * schema-heavy ontology the property node is the hinge connecting one class to
48
+ * another (`Class <-domain- property -range-> Class`), so hiding those shatters
49
+ * the graph. The transformation that removes properties *and* keeps the graph
50
+ * connected is what the schema view already does, by rewiring domain/range
51
+ * into a direct class-to-class edge.
52
+ *
53
+ * Pure, and never mutates its input: the `OntologyGraph` stays a faithful
54
+ * representation of the parsed triples, and this compaction is a presentation
55
+ * choice the viewer can turn off.
56
+ */
57
+ export declare function compactTriples(graph: OntologyGraph): CompactTriplesResult;
58
+ //# sourceMappingURL=compactTriples.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compactTriples.d.ts","sourceRoot":"","sources":["../../src/rdf/compactTriples.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE9E,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB;;;;OAIG;IACH,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACnC,gBAAgB,EAAE,MAAM,CAAC;IACzB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,aAAa,GAAG,oBAAoB,CA4DzE"}
package/dist/types.d.ts CHANGED
@@ -20,6 +20,11 @@ export interface OntologyViewerOptions {
20
20
  layout?: LayoutName;
21
21
  /** Initial graph view. */
22
22
  defaultView?: ViewMode;
23
+ /**
24
+ * In the triples view, fold leaf annotation nodes (literals and standard
25
+ * vocabulary terms) into the nodes that point at them. Default: true.
26
+ */
27
+ compactTriples?: boolean;
23
28
  /** Base IRI used when the Turtle source has no @base directive. */
24
29
  baseIri?: string;
25
30
  /** @deprecated Use baseIri. */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAErC,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;AAC5C,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,OAAO,CAAC;AAC3C,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,WAAW,CAAC;AAEjF,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,qBAAqB;IACpC,yEAAyE;IACzE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gDAAgD;IAChD,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,+CAA+C;IAC/C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,8BAA8B;IAC9B,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,0BAA0B;IAC1B,WAAW,CAAC,EAAE,QAAQ,CAAC;IACvB,mEAAmE;IACnE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,+BAA+B;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kEAAkE;IAClE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,wFAAwF;IACxF,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,+CAA+C;IAC/C,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,sBAAsB,K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AAM,SAAS,CAAC;AAmCtI,wBAAgB,YAAY,CAC1B,aAAa,EAAE,WAAW,EAC1B,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,qBAAqB,EAC9B,SAAS,EAAE,MAAM,IAAI,GACpB,sBAAsB,CAgdxB"}
1
+ {"version":3,"file":"viewer.d.ts","sourceRoot":"","sources":["../src/viewer.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAmC,sBAAsB,EAAE,qBAAqB,EAA0B,MAAM,SAAS,CAAC;AAsCtI,wBAAgB,YAAY,CAC1B,aAAa,EAAE,WAAW,EAC1B,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,qBAAqB,EAC9B,SAAS,EAAE,MAAM,IAAI,GACpB,sBAAsB,CA8dxB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ontologyviewer",
3
- "version": "0.1.2",
3
+ "version": "0.2.0",
4
4
  "description": "Standalone read-only Turtle ontology viewer for web pages, with Schema and Triples diagrams powered by Cytoscape.",
5
5
  "type": "module",
6
6
  "main": "./dist/ontologyviewer.esm.mjs",