@graphty/graphty-element 2.6.2 → 3.0.1
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/ai.js +3 -3
- package/dist/catalog.js +53 -54
- package/dist/chunks/{AiManager-4iQpsJW1.js → AiManager-Bhh0rR_p.js} +706 -655
- package/dist/chunks/GraphSession-DPoTaT3b.js +21175 -0
- package/dist/chunks/{GraphtyLogger-B_O67a6c.js → GraphtyLogger-BtcBJQPL.js} +1 -1
- package/dist/chunks/{VoiceInputAdapter-Cc6mHXTI.js → VoiceInputAdapter-CdLsJ_nG.js} +1 -1
- package/dist/chunks/{XRPivotCameraController-BLa89LXn.js → XRPivotCameraController-CiLJ9Gz6.js} +2 -2
- package/dist/chunks/algorithms-qij74zEN.js +6811 -0
- package/dist/chunks/{capability-check-Am2zliFj.js → capability-check-BbgTejS3.js} +1 -1
- package/dist/chunks/definePalette-BYt2Llxs.js +1333 -0
- package/dist/chunks/fields-5uVC1Pll.js +4999 -0
- package/dist/chunks/{format-detection-BHwrAVzW.js → format-detection-FKaDMshR.js} +1 -1
- package/dist/chunks/{index-BkBLbvui.js → index-Cc_6D9hV.js} +6034 -7127
- package/dist/chunks/interpolation-Dk206AhZ.js +105 -0
- package/dist/chunks/paletteRegistry-De3CGdst.js +357 -0
- package/dist/chunks/parse-SVp77JbE.js +669 -0
- package/dist/chunks/{pluginRegistry-Bs8bEkz9.js → pluginRegistry-Ddfl6Mv2.js} +27 -24
- package/dist/chunks/{registry-BdGvyZou.js → registry-CgMqldp4.js} +1 -1
- package/dist/chunks/{DataSource-BL2UzPff.js → sources-BbAJCDIH.js} +279 -108
- package/dist/commands.d.ts +128 -19
- package/dist/commands.js +49 -1
- package/dist/custom-elements.json +1 -1
- package/dist/extend.d.ts +10 -2
- package/dist/extend.js +64 -57
- package/dist/graphty-catalog.json +6 -3
- package/dist/graphty.bundle.js +267177 -240648
- package/dist/graphty.js +84 -78
- package/dist/index.d.ts +4 -0
- package/dist/logging.js +2 -2
- package/dist/schema.js +70 -71
- package/dist/session.d.ts +5 -6
- package/dist/session.js +40 -86
- package/dist/src/Edge.d.ts +31 -67
- package/dist/src/Graph.d.ts +335 -77
- package/dist/src/Node.d.ts +36 -3
- package/dist/src/NodeBehavior.d.ts +28 -0
- package/dist/src/Styles.d.ts +15 -4
- package/dist/src/acceleration/AccelerationController.d.ts +8 -0
- package/dist/src/acceleration/narrow.d.ts +9 -1
- package/dist/src/acceleration/types.d.ts +10 -0
- package/dist/src/ai/AiController.d.ts +12 -0
- package/dist/src/ai/AiManager.d.ts +7 -0
- package/dist/src/ai/commands/AlgorithmCommands.d.ts +1 -1
- package/dist/src/ai/commands/LayoutCommands.d.ts +1 -1
- package/dist/src/ai/commands/StyleCommands.d.ts +1 -1
- package/dist/src/ai/commands/types.d.ts +20 -1
- package/dist/src/algorithms/Algorithm.d.ts +21 -4
- package/dist/src/algorithms/BFSAlgorithm.d.ts +0 -9
- package/dist/src/algorithms/BellmanFordAlgorithm.d.ts +0 -14
- package/dist/src/algorithms/DFSAlgorithm.d.ts +1 -1
- package/dist/src/algorithms/FloydWarshallAlgorithm.d.ts +5 -0
- package/dist/src/algorithms/GirvanNewmanAlgorithm.d.ts +5 -0
- package/dist/src/algorithms/LeidenAlgorithm.d.ts +5 -0
- package/dist/src/algorithms/PageRankAlgorithm.d.ts +1 -1
- package/dist/src/algorithms/StronglyConnectedComponentsAlgorithm.d.ts +1 -1
- package/dist/src/algorithms/metrics/fields.d.ts +23 -1
- package/dist/src/algorithms/utils/graphUtils.d.ts +13 -1
- package/dist/src/catalog/paletteRegistry.d.ts +4 -4
- package/dist/src/catalog/registry.d.ts +3 -2
- package/dist/src/catalog/types.d.ts +18 -1
- package/dist/src/config/GraphStyle.d.ts +1 -1
- package/dist/src/config/StyleTemplate.d.ts +2 -2
- package/dist/src/config/xr-config-schema.d.ts +4 -4
- package/dist/src/data/CSVDataSource.d.ts +77 -22
- package/dist/src/data/ErrorAggregator.d.ts +5 -0
- package/dist/src/data/GEXFDataSource.d.ts +12 -61
- package/dist/src/data/GraphMLDataSource.d.ts +3 -44
- package/dist/src/data/GraphStore.d.ts +322 -15
- package/dist/src/data/JsonDataSource.d.ts +43 -1
- package/dist/src/data/graph-io-import.d.ts +89 -0
- package/dist/src/data/graph-io-records.d.ts +64 -0
- package/dist/src/data/lane.d.ts +23 -0
- package/dist/src/data/positions.d.ts +13 -0
- package/dist/src/data/seedPosition.d.ts +16 -0
- package/dist/src/errors/GraphtyError.d.ts +3 -1
- package/dist/src/errors/codes.d.ts +23 -0
- package/dist/src/events.d.ts +12 -0
- package/dist/src/graphty-element.d.ts +149 -54
- package/dist/src/input/types.d.ts +2 -0
- package/dist/src/layout/D3GraphLayoutEngine.d.ts +17 -3
- package/dist/src/layout/FixedLayoutEngine.d.ts +20 -4
- package/dist/src/layout/KamadaKawaiLayoutEngine.d.ts +6 -0
- package/dist/src/layout/LayoutEngine.d.ts +214 -116
- package/dist/src/layout/NGraphLayoutEngine.d.ts +10 -3
- package/dist/src/layout/SimulationLayoutEngine.d.ts +8 -3
- package/dist/src/managers/AlgorithmManager.d.ts +24 -5
- package/dist/src/managers/DataManager.d.ts +258 -181
- package/dist/src/managers/EventManager.d.ts +5 -2
- package/dist/src/managers/GraphContext.d.ts +7 -0
- package/dist/src/managers/InputManager.d.ts +11 -0
- package/dist/src/managers/LayoutManager.d.ts +129 -50
- package/dist/src/managers/RenderManager.d.ts +14 -1
- package/dist/src/managers/UpdateManager.d.ts +20 -0
- package/dist/src/screenshot/ScreenshotCapture.d.ts +1 -1
- package/dist/src/session/GraphSession.d.ts +83 -6
- package/dist/src/session/commands/algo.d.ts +169 -0
- package/dist/src/session/commands/config.d.ts +45 -0
- package/dist/src/session/commands/data.d.ts +178 -0
- package/dist/src/session/commands/doors.d.ts +93 -0
- package/dist/src/session/commands/index.d.ts +20 -0
- package/dist/src/session/commands/layout.d.ts +104 -0
- package/dist/src/session/commands/positions.d.ts +30 -0
- package/dist/src/session/commands/sets.d.ts +113 -0
- package/dist/src/session/commands/style.d.ts +92 -0
- package/dist/src/session/commands/view.d.ts +57 -0
- package/dist/src/session/commands/visibility.d.ts +41 -0
- package/dist/src/session/data.d.ts +131 -4
- package/dist/src/session/index.d.ts +1 -1
- package/dist/src/session/planning.d.ts +25 -8
- package/dist/src/session/project/Dispatcher.d.ts +905 -0
- package/dist/src/session/project/History.d.ts +382 -0
- package/dist/src/session/project/arrangement.d.ts +247 -0
- package/dist/src/session/project/derive.d.ts +132 -0
- package/dist/src/session/project/digest.d.ts +33 -0
- package/dist/src/session/project/draft.d.ts +194 -0
- package/dist/src/session/project/graphOps.d.ts +304 -0
- package/dist/src/session/project/ingest.d.ts +364 -0
- package/dist/src/session/project/state.d.ts +145 -0
- package/dist/src/session/project/strict.d.ts +68 -0
- package/dist/src/session/results/RunResult.d.ts +48 -0
- package/dist/src/session/results/statistics.d.ts +20 -0
- package/dist/src/session/runs/Run.d.ts +80 -4
- package/dist/src/session/runs/RunsApi.d.ts +23 -6
- package/dist/src/session/runs/types.d.ts +25 -6
- package/dist/src/session/scope/ElementMask.d.ts +14 -0
- package/dist/src/session/scope/ScopeApi.d.ts +3 -22
- package/dist/src/session/scope/spaces.d.ts +29 -0
- package/dist/src/session/sealed.d.ts +22 -0
- package/dist/src/session/selection/SelectionApi.d.ts +14 -4
- package/dist/src/session/sets/SetsApi.d.ts +13 -5
- package/dist/src/session/sets/store.d.ts +54 -53
- package/dist/src/session/sets/types.d.ts +5 -2
- package/dist/src/session/styles/Layer.d.ts +5 -0
- package/dist/src/session/styles/StylesApi.d.ts +68 -17
- package/dist/src/session/styles/autoApply.d.ts +64 -53
- package/dist/src/session/styles/index.d.ts +3 -3
- package/dist/src/session/styles/predicate.d.ts +7 -0
- package/dist/src/session/styles/repaint.d.ts +16 -1
- package/dist/src/session/styles/sources.d.ts +1 -1
- package/dist/src/session/types.d.ts +625 -54
- package/dist/src/session/visibility/VisibilityApi.d.ts +38 -18
- package/dist/src/session/visibility/filter.d.ts +10 -0
- package/dist/src/simple/defineAlgorithm.d.ts +28 -0
- package/dist/src/simple/defineLayout.d.ts +35 -0
- package/dist/src/simple/defineLogDestination.d.ts +31 -0
- package/dist/src/simple/definePalette.d.ts +26 -0
- package/dist/src/simple/definition.d.ts +106 -0
- package/dist/src/simple/options.d.ts +33 -0
- package/dist/src/simple/source.d.ts +49 -0
- package/dist/src/simple/types.d.ts +366 -0
- package/dist/src/simple/view.d.ts +107 -0
- package/dist/webgpu.js +2 -2
- package/package.json +10 -12
- package/dist/chunks/GraphSession-BhuHSXIo.js +0 -12819
- package/dist/chunks/GraphStyle-Cwr55SAE.js +0 -65
- package/dist/chunks/algorithms-BJ6DQMOe.js +0 -3777
- package/dist/chunks/detect-fyuVnlCT.js +0 -88
- package/dist/chunks/interpolation-DY-PNpqX.js +0 -43
- package/dist/chunks/optionsFromZod-CKMYSwTz.js +0 -3636
- package/dist/chunks/paletteRegistry-BCFSwJGK.js +0 -1196
- package/dist/chunks/parse-BMTqt4SS.js +0 -3658
- package/dist/src/data/csv-variant-detection.d.ts +0 -29
- package/dist/src/data/ingest.d.ts +0 -104
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { z as n } from "zod/v4";
|
|
2
|
+
import { C as d, I as p } from "./common-DWNKjpH_.js";
|
|
3
|
+
const f = ["2d", "3d", "ar", "vr"], b = "3d";
|
|
4
|
+
function k(r) {
|
|
5
|
+
return f.includes(r);
|
|
6
|
+
}
|
|
7
|
+
const g = n.strictObject({
|
|
8
|
+
backgroundType: n.literal("color"),
|
|
9
|
+
color: d
|
|
10
|
+
}), h = n.strictObject({
|
|
11
|
+
backgroundType: n.literal("skybox"),
|
|
12
|
+
data: p
|
|
13
|
+
}), m = n.discriminatedUnion("backgroundType", [g, h]), s = n.strictObject({
|
|
14
|
+
/** The halo's colour. Any colour the element understands; normalised to hex on parse. */
|
|
15
|
+
color: d.default("#FFD700"),
|
|
16
|
+
/**
|
|
17
|
+
* How much of the node's own size the halo is drawn at.
|
|
18
|
+
*
|
|
19
|
+
* Greater than 1 puts a ring around the node, which is what a highlight reads as. Below 1 the
|
|
20
|
+
* halo disappears inside the node it is meant to mark, so the schema takes any positive
|
|
21
|
+
* number and the default stands a little clear of the node.
|
|
22
|
+
*/
|
|
23
|
+
scale: n.number().positive().default(1.45),
|
|
24
|
+
/** How solid the halo is, in `[0, 1]`. Low enough to read as a highlight rather than a node. */
|
|
25
|
+
opacity: n.number().min(0).max(1).default(0.4)
|
|
26
|
+
}), D = s, I = s.parse({}), y = n.enum(["2d", "3d", "ar", "vr"]), _ = n.strictObject({
|
|
27
|
+
/**
|
|
28
|
+
* ACCEPTED AND IGNORED. It used to decide whether the element unshifted a default layer onto
|
|
29
|
+
* the 1.x layer stack; that stack is gone, and the session's two locked base layers give
|
|
30
|
+
* every graph its defaults unconditionally. The key stays because this object is strict, so
|
|
31
|
+
* dropping it would turn every document that still carries it into a parse error.
|
|
32
|
+
*/
|
|
33
|
+
addDefaultStyle: n.boolean().default(!0),
|
|
34
|
+
background: m.prefault({ backgroundType: "color", color: "whitesmoke" }),
|
|
35
|
+
selection: s.optional(),
|
|
36
|
+
/**
|
|
37
|
+
* How far the camera starts from the graph, in scene units. Set, it places the camera and
|
|
38
|
+
* turns off the element's automatic zoom-to-fit; unset, the graph is framed to fit.
|
|
39
|
+
*/
|
|
40
|
+
startingCameraDistance: n.number().optional(),
|
|
41
|
+
layout: n.string().optional(),
|
|
42
|
+
// No default - let Graph constructor set the default
|
|
43
|
+
layoutOptions: n.looseObject({}).optional(),
|
|
44
|
+
/**
|
|
45
|
+
* View mode controls how the graph is rendered and displayed.
|
|
46
|
+
* - "2d": Orthographic camera, fixed top-down view
|
|
47
|
+
* - "3d": Perspective camera with orbit controls (default)
|
|
48
|
+
* - "ar": Augmented reality mode using WebXR
|
|
49
|
+
* - "vr": Virtual reality mode using WebXR
|
|
50
|
+
*/
|
|
51
|
+
viewMode: y.default(b),
|
|
52
|
+
/**
|
|
53
|
+
* @deprecated Use viewMode instead. twoD: true is equivalent to viewMode: "2d"
|
|
54
|
+
*/
|
|
55
|
+
twoD: n.boolean().default(!1)
|
|
56
|
+
}), S = "#ff00ff", M = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i;
|
|
57
|
+
function u(r) {
|
|
58
|
+
if (typeof r != "string")
|
|
59
|
+
return null;
|
|
60
|
+
const t = M.exec(r);
|
|
61
|
+
return t === null ? null : {
|
|
62
|
+
r: parseInt(t[1], 16),
|
|
63
|
+
g: parseInt(t[2], 16),
|
|
64
|
+
b: parseInt(t[3], 16)
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function O(r, t, o) {
|
|
68
|
+
const e = (a) => {
|
|
69
|
+
const i = Math.round(Math.max(0, Math.min(255, a))).toString(16);
|
|
70
|
+
return i.length === 1 ? `0${i}` : i;
|
|
71
|
+
};
|
|
72
|
+
return `#${e(r)}${e(t)}${e(o)}`;
|
|
73
|
+
}
|
|
74
|
+
function E(r, t, o) {
|
|
75
|
+
const e = u(r), a = u(t);
|
|
76
|
+
if (e === null || a === null || !Number.isFinite(o))
|
|
77
|
+
return null;
|
|
78
|
+
const i = e.r + (a.r - e.r) * o, c = e.g + (a.g - e.g) * o, l = e.b + (a.b - e.b) * o;
|
|
79
|
+
return O(i, c, l);
|
|
80
|
+
}
|
|
81
|
+
function w(r, t, o = S) {
|
|
82
|
+
if (t.length === 0)
|
|
83
|
+
throw new Error("interpolatePalette was given an empty palette, which has no color to return");
|
|
84
|
+
if (typeof r != "number" || !Number.isFinite(r))
|
|
85
|
+
return o;
|
|
86
|
+
const e = Math.max(0, Math.min(1, r));
|
|
87
|
+
if (e === 0)
|
|
88
|
+
return t[0];
|
|
89
|
+
if (e === 1)
|
|
90
|
+
return t[t.length - 1];
|
|
91
|
+
const a = e * (t.length - 1), i = Math.floor(a), c = Math.min(i + 1, t.length - 1), l = a - i;
|
|
92
|
+
return E(t[i], t[c], l) ?? o;
|
|
93
|
+
}
|
|
94
|
+
export {
|
|
95
|
+
I as D,
|
|
96
|
+
m as G,
|
|
97
|
+
S as M,
|
|
98
|
+
f as V,
|
|
99
|
+
b as a,
|
|
100
|
+
D as b,
|
|
101
|
+
k as c,
|
|
102
|
+
_ as d,
|
|
103
|
+
u as h,
|
|
104
|
+
w as i
|
|
105
|
+
};
|
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
import { c as N, G as h } from "./pluginRegistry-Ddfl6Mv2.js";
|
|
2
|
+
import { a as O, d as b } from "./types-DFchv4Ny.js";
|
|
3
|
+
import { c as v } from "./common-DWNKjpH_.js";
|
|
4
|
+
const m = N({
|
|
5
|
+
kind: "format",
|
|
6
|
+
idOf: (e) => e.descriptor.id,
|
|
7
|
+
descriptorOf: (e) => e.descriptor,
|
|
8
|
+
implementationOf: (e) => e.descriptor,
|
|
9
|
+
builtInIds: () => O
|
|
10
|
+
});
|
|
11
|
+
function P(e, t) {
|
|
12
|
+
m.register(e, t);
|
|
13
|
+
}
|
|
14
|
+
function S() {
|
|
15
|
+
return m.entries();
|
|
16
|
+
}
|
|
17
|
+
function E() {
|
|
18
|
+
return m.descriptors();
|
|
19
|
+
}
|
|
20
|
+
function I(e) {
|
|
21
|
+
return m.byId(e);
|
|
22
|
+
}
|
|
23
|
+
function M() {
|
|
24
|
+
m.clearForTesting();
|
|
25
|
+
}
|
|
26
|
+
const j = {
|
|
27
|
+
"edge-list": "Edge List",
|
|
28
|
+
"node-list": "Node List",
|
|
29
|
+
"adjacency-list": "Adjacency List",
|
|
30
|
+
neo4j: "Neo4j Export",
|
|
31
|
+
gephi: "Gephi Export",
|
|
32
|
+
cytoscape: "Cytoscape Export",
|
|
33
|
+
generic: "Generic"
|
|
34
|
+
}, F = [
|
|
35
|
+
{
|
|
36
|
+
name: "delimiter",
|
|
37
|
+
plainName: "Column Separator",
|
|
38
|
+
technicalName: "delimiter",
|
|
39
|
+
type: "string",
|
|
40
|
+
description: "The character between one column and the next. Worked out from the first line (comma, tab, semicolon or pipe) when it is not set."
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: "variant",
|
|
44
|
+
plainName: "File Shape",
|
|
45
|
+
technicalName: "variant",
|
|
46
|
+
type: "enum",
|
|
47
|
+
values: Object.entries(j).map(([e, t]) => ({ value: e, label: t })),
|
|
48
|
+
description: "Which CSV shape to read. Worked out from the header row when it is not set."
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: "idColumn",
|
|
52
|
+
plainName: "Node Id Column",
|
|
53
|
+
technicalName: "idColumn",
|
|
54
|
+
type: "string",
|
|
55
|
+
description: "The column holding each node's identity, when the file lists nodes."
|
|
56
|
+
}
|
|
57
|
+
], c = [
|
|
58
|
+
{
|
|
59
|
+
name: "edgeSource",
|
|
60
|
+
plainName: "Edge Start Field",
|
|
61
|
+
technicalName: "edgeSource",
|
|
62
|
+
type: "string",
|
|
63
|
+
description: "Where to find the node an edge starts at. Left unset, the element looks for source, then src, then from."
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: "edgeTarget",
|
|
67
|
+
plainName: "Edge End Field",
|
|
68
|
+
technicalName: "edgeTarget",
|
|
69
|
+
type: "string",
|
|
70
|
+
description: "Where to find the node an edge ends at. Left unset, the element looks for target, then dst, then to."
|
|
71
|
+
}
|
|
72
|
+
], w = [
|
|
73
|
+
{
|
|
74
|
+
name: "nodeIdPath",
|
|
75
|
+
plainName: "Node Id Field",
|
|
76
|
+
technicalName: "nodeIdPath",
|
|
77
|
+
type: "string",
|
|
78
|
+
description: "An expression selecting each node's identity out of the node record."
|
|
79
|
+
}
|
|
80
|
+
], f = [
|
|
81
|
+
{
|
|
82
|
+
id: "json",
|
|
83
|
+
plainName: "JSON",
|
|
84
|
+
extensions: [".json"],
|
|
85
|
+
mimeTypes: ["application/json"],
|
|
86
|
+
canImport: !0,
|
|
87
|
+
canExport: !1,
|
|
88
|
+
options: [...w, ...c]
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
id: "csv",
|
|
92
|
+
plainName: "CSV",
|
|
93
|
+
extensions: [".csv", ".tsv", ".tab", ".edges", ".edgelist"],
|
|
94
|
+
mimeTypes: ["text/csv", "text/tab-separated-values", "text/plain"],
|
|
95
|
+
canImport: !0,
|
|
96
|
+
canExport: !1,
|
|
97
|
+
options: [...F, ...c]
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
id: "graphml",
|
|
101
|
+
plainName: "GraphML",
|
|
102
|
+
extensions: [".graphml", ".xml"],
|
|
103
|
+
mimeTypes: ["application/graphml+xml", "application/xml", "text/xml"],
|
|
104
|
+
canImport: !0,
|
|
105
|
+
canExport: !1,
|
|
106
|
+
options: c
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
id: "gexf",
|
|
110
|
+
plainName: "GEXF",
|
|
111
|
+
// ".xml" is claimed here as well as by GraphML because both formats are XML and both are
|
|
112
|
+
// routinely saved under the generic extension. Two claimants is what lets detection ask
|
|
113
|
+
// each one's content sniffer which of them the file actually is, instead of a private
|
|
114
|
+
// branch inside the detector hard-coding the two namespace strings -- which is the same
|
|
115
|
+
// route a third party's XML dialect now takes.
|
|
116
|
+
extensions: [".gexf", ".xml"],
|
|
117
|
+
mimeTypes: ["application/gexf+xml", "application/xml", "text/xml"],
|
|
118
|
+
canImport: !0,
|
|
119
|
+
canExport: !1,
|
|
120
|
+
options: c
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
id: "gml",
|
|
124
|
+
plainName: "GML",
|
|
125
|
+
extensions: [".gml"],
|
|
126
|
+
mimeTypes: ["text/plain"],
|
|
127
|
+
canImport: !0,
|
|
128
|
+
canExport: !1,
|
|
129
|
+
options: c
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
id: "dot",
|
|
133
|
+
plainName: "DOT",
|
|
134
|
+
extensions: [".dot", ".gv"],
|
|
135
|
+
mimeTypes: ["text/vnd.graphviz", "text/plain"],
|
|
136
|
+
canImport: !0,
|
|
137
|
+
canExport: !1,
|
|
138
|
+
options: c
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
id: "pajek",
|
|
142
|
+
plainName: "Pajek NET",
|
|
143
|
+
extensions: [".net", ".paj"],
|
|
144
|
+
mimeTypes: ["text/plain"],
|
|
145
|
+
canImport: !0,
|
|
146
|
+
canExport: !1,
|
|
147
|
+
options: c
|
|
148
|
+
}
|
|
149
|
+
], $ = [
|
|
150
|
+
{
|
|
151
|
+
id: "sif",
|
|
152
|
+
reason: "No data source reads the Cytoscape simple interaction format. The name is deprecated and is removed at the next major release unless a reader lands."
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
id: "cx2",
|
|
156
|
+
reason: "No data source reads the Cytoscape Exchange format. The name is deprecated and is removed at the next major release unless a reader lands."
|
|
157
|
+
}
|
|
158
|
+
];
|
|
159
|
+
function z(e) {
|
|
160
|
+
return f.find((t) => t.id === e) ?? I(e)?.descriptor;
|
|
161
|
+
}
|
|
162
|
+
function G(e) {
|
|
163
|
+
const t = e.toLowerCase();
|
|
164
|
+
return [...f, ...E()].filter(
|
|
165
|
+
(n) => n.extensions.includes(t)
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
function p(e) {
|
|
169
|
+
return e.startsWith("<");
|
|
170
|
+
}
|
|
171
|
+
const y = [
|
|
172
|
+
// The root element names the format, whatever namespace it declares: GEXF 1.2 declares
|
|
173
|
+
// "http://www.gexf.net/1.2draft" and 1.3 "http://gexf.net/1.3".
|
|
174
|
+
{ id: "graphml", detect: (e) => p(e) && /<graphml[\s>]/.test(e) },
|
|
175
|
+
{ id: "gexf", detect: (e) => p(e) && /<gexf[\s>]/.test(e) },
|
|
176
|
+
{ id: "json", detect: (e) => e.startsWith("{") || e.startsWith("[") },
|
|
177
|
+
{ id: "gml", detect: (e) => !p(e) && /graph\s*\[/i.test(e) },
|
|
178
|
+
{ id: "pajek", detect: (e) => /^\*vertices/i.test(e) },
|
|
179
|
+
{ id: "dot", detect: (e) => /^\s*(strict\s+)?(di)?graph\s+/i.test(e) },
|
|
180
|
+
{ id: "csv", detect: (e) => !p(e) && /^[\w-]+[ \t]*[,\t;|][ \t]*[\w-]+/m.test(e) }
|
|
181
|
+
];
|
|
182
|
+
function g(e, t) {
|
|
183
|
+
try {
|
|
184
|
+
return e(t);
|
|
185
|
+
} catch {
|
|
186
|
+
return !1;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
function k(e) {
|
|
190
|
+
return /\.[^.]+$/.exec(e.toLowerCase())?.[0] ?? null;
|
|
191
|
+
}
|
|
192
|
+
function A(e) {
|
|
193
|
+
const t = e.sample?.trim() ?? "", n = S(), r = e.filename === void 0 ? null : k(e.filename);
|
|
194
|
+
if (r !== null) {
|
|
195
|
+
const i = [
|
|
196
|
+
...f.filter((a) => a.extensions.includes(r)).map(
|
|
197
|
+
(a) => a.id
|
|
198
|
+
),
|
|
199
|
+
...n.filter((a) => a.descriptor.extensions.includes(r)).map((a) => a.descriptor.id)
|
|
200
|
+
];
|
|
201
|
+
if (i.length > 1 && t !== "") {
|
|
202
|
+
const a = new Map([
|
|
203
|
+
...y.map((o) => [o.id, o.detect]),
|
|
204
|
+
...n.filter((o) => o.detect !== void 0).map((o) => [o.descriptor.id, o.detect])
|
|
205
|
+
]), d = i.filter((o) => {
|
|
206
|
+
const x = a.get(o);
|
|
207
|
+
return x !== void 0 && g(x, t);
|
|
208
|
+
});
|
|
209
|
+
if (d.length > 0)
|
|
210
|
+
return Object.freeze([...d, ...i.filter((o) => !d.includes(o))]);
|
|
211
|
+
}
|
|
212
|
+
if (i.length > 0)
|
|
213
|
+
return Object.freeze(i);
|
|
214
|
+
}
|
|
215
|
+
if (t === "")
|
|
216
|
+
return Object.freeze([]);
|
|
217
|
+
const s = y.filter((i) => g(i.detect, t)).map(
|
|
218
|
+
(i) => i.id
|
|
219
|
+
);
|
|
220
|
+
for (const i of n) {
|
|
221
|
+
const { detect: a } = i;
|
|
222
|
+
a !== void 0 && g(a, t) && !s.includes(i.descriptor.id) && s.push(i.descriptor.id);
|
|
223
|
+
}
|
|
224
|
+
return Object.freeze(s);
|
|
225
|
+
}
|
|
226
|
+
function U(e) {
|
|
227
|
+
return A(e)[0] ?? null;
|
|
228
|
+
}
|
|
229
|
+
function T() {
|
|
230
|
+
return [
|
|
231
|
+
...f.map((e) => e.id),
|
|
232
|
+
...S().map((e) => e.descriptor.id)
|
|
233
|
+
];
|
|
234
|
+
}
|
|
235
|
+
function B(e) {
|
|
236
|
+
const t = T(), n = $.find((s) => s.id === e), r = n === void 0 ? `no format is named "${e}".` : `the format "${e}" cannot be read: ${n.reason}`;
|
|
237
|
+
return new h({
|
|
238
|
+
code: "E_UNKNOWN_FORMAT",
|
|
239
|
+
message: `${r} The formats this element can read are: ${t.join(", ")}. A format of your own is registered with \`DataSource.register\`.`,
|
|
240
|
+
source: "data",
|
|
241
|
+
details: { format: e, available: [...t] }
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
function K(e, t) {
|
|
245
|
+
const n = T();
|
|
246
|
+
return new h({
|
|
247
|
+
code: "E_UNKNOWN_FORMAT",
|
|
248
|
+
message: `nothing recognised the format of "${e}". The formats this element can read are: ${n.join(", ")}. Name one explicitly: ${t}`,
|
|
249
|
+
source: "data",
|
|
250
|
+
details: { source: e, available: [...n] }
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
const _ = /^#[0-9a-f]{6}$/i;
|
|
254
|
+
function C(e) {
|
|
255
|
+
if (typeof e != "string" || e.trim() === "")
|
|
256
|
+
return null;
|
|
257
|
+
try {
|
|
258
|
+
const t = v(e.trim());
|
|
259
|
+
if (t === void 0)
|
|
260
|
+
return null;
|
|
261
|
+
const n = t.length === 9 ? t.slice(0, 7) : t;
|
|
262
|
+
return _.test(n) ? n.toUpperCase() : null;
|
|
263
|
+
} catch {
|
|
264
|
+
return null;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
function D(e) {
|
|
268
|
+
return JSON.stringify([
|
|
269
|
+
e.id,
|
|
270
|
+
e.kind,
|
|
271
|
+
e.colors,
|
|
272
|
+
e.capacity,
|
|
273
|
+
e.colorblindSafe
|
|
274
|
+
]);
|
|
275
|
+
}
|
|
276
|
+
const u = N({
|
|
277
|
+
kind: "palette",
|
|
278
|
+
idOf: (e) => e.id,
|
|
279
|
+
descriptorOf: (e) => e,
|
|
280
|
+
implementationOf: D,
|
|
281
|
+
builtInIds: () => b
|
|
282
|
+
});
|
|
283
|
+
function l(e, t, n) {
|
|
284
|
+
throw new h({
|
|
285
|
+
code: "E_BAD_COMMAND",
|
|
286
|
+
message: n,
|
|
287
|
+
source: "registry",
|
|
288
|
+
details: { kind: "palette", name: typeof e == "string" ? e : "", field: t }
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
function V(e, t) {
|
|
292
|
+
typeof e != "object" && l("", "descriptor", "registerPalette takes a palette descriptor"), (e.plainName === void 0 || e.plainName === "") && l(
|
|
293
|
+
e.id,
|
|
294
|
+
"plainName",
|
|
295
|
+
`the palette "${String(e.id)}" was registered without a plain name`
|
|
296
|
+
), e.kind !== "sequential" && e.kind !== "diverging" && e.kind !== "categorical" && l(
|
|
297
|
+
e.id,
|
|
298
|
+
"kind",
|
|
299
|
+
`the palette "${String(e.id)}" must be sequential, diverging or categorical`
|
|
300
|
+
), (!Array.isArray(e.colors) || e.colors.length === 0) && l(e.id, "colors", `the palette "${String(e.id)}" was registered with no colours`);
|
|
301
|
+
const n = [];
|
|
302
|
+
for (const a of e.colors) {
|
|
303
|
+
const d = C(a);
|
|
304
|
+
d === null && l(
|
|
305
|
+
e.id,
|
|
306
|
+
"colors",
|
|
307
|
+
`"${String(a)}" in the palette "${String(e.id)}" is not a colour`
|
|
308
|
+
), n.push(d);
|
|
309
|
+
}
|
|
310
|
+
const r = e.colorblindSafe ?? [], s = ["deuteranopia", "protanopia", "tritanopia"];
|
|
311
|
+
(!Array.isArray(r) || r.some((a) => !s.includes(a))) && l(
|
|
312
|
+
e.id,
|
|
313
|
+
"colorblindSafe",
|
|
314
|
+
`the palette "${String(e.id)}" claims colorblindSafe ${JSON.stringify(r)}; a claim lists "deuteranopia", "protanopia" or "tritanopia"`
|
|
315
|
+
);
|
|
316
|
+
const i = e.kind === "categorical" ? n.length : null;
|
|
317
|
+
e.capacity !== void 0 && e.capacity !== i && l(
|
|
318
|
+
e.id,
|
|
319
|
+
"capacity",
|
|
320
|
+
`the palette "${String(e.id)}" is ${e.kind}, so its capacity is ${i === null ? "null" : String(i)} rather than ${String(e.capacity)}`
|
|
321
|
+
), u.register(
|
|
322
|
+
Object.freeze({
|
|
323
|
+
...e,
|
|
324
|
+
colors: Object.freeze(n),
|
|
325
|
+
capacity: i,
|
|
326
|
+
colorblindSafe: Object.freeze(e.colorblindSafe ?? [])
|
|
327
|
+
}),
|
|
328
|
+
t
|
|
329
|
+
);
|
|
330
|
+
}
|
|
331
|
+
function X() {
|
|
332
|
+
return u.descriptors();
|
|
333
|
+
}
|
|
334
|
+
function H(e) {
|
|
335
|
+
return u.byId(e);
|
|
336
|
+
}
|
|
337
|
+
function J() {
|
|
338
|
+
u.clearForTesting();
|
|
339
|
+
}
|
|
340
|
+
export {
|
|
341
|
+
f as F,
|
|
342
|
+
$ as U,
|
|
343
|
+
J as a,
|
|
344
|
+
A as b,
|
|
345
|
+
M as c,
|
|
346
|
+
U as d,
|
|
347
|
+
E as e,
|
|
348
|
+
X as f,
|
|
349
|
+
z as g,
|
|
350
|
+
G as h,
|
|
351
|
+
H as i,
|
|
352
|
+
B as j,
|
|
353
|
+
C as n,
|
|
354
|
+
P as p,
|
|
355
|
+
V as r,
|
|
356
|
+
K as u
|
|
357
|
+
};
|