@graphty/graph-io 0.3.18 → 0.3.19

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 (118) hide show
  1. package/README.md +37 -2
  2. package/dist/chunks/{escape-D-gZWO26.js → escape-CWExcecC.js} +3 -3
  3. package/dist/chunks/{escape-D-gZWO26.js.map → escape-CWExcecC.js.map} +1 -1
  4. package/dist/chunks/exporter-CbMZyVt-.js +735 -0
  5. package/dist/chunks/exporter-CbMZyVt-.js.map +1 -0
  6. package/dist/chunks/importer-BAP4PrxR.js +2194 -0
  7. package/dist/chunks/importer-BAP4PrxR.js.map +1 -0
  8. package/dist/chunks/{importer-Br_QeAeE.js → importer-BNFuV1-K.js} +5 -4
  9. package/dist/chunks/{importer-Br_QeAeE.js.map → importer-BNFuV1-K.js.map} +1 -1
  10. package/dist/chunks/{importer-d0uQxFp6.js → importer-BVGtU1NA.js} +5 -4
  11. package/dist/chunks/{importer-d0uQxFp6.js.map → importer-BVGtU1NA.js.map} +1 -1
  12. package/dist/chunks/{importer-DHagxvDD.js → importer-BW-Ft2ps.js} +5 -4
  13. package/dist/chunks/{importer-DHagxvDD.js.map → importer-BW-Ft2ps.js.map} +1 -1
  14. package/dist/chunks/{importer-Du5crN9l.js → importer-Bm1_5vPS.js} +275 -82
  15. package/dist/chunks/importer-Bm1_5vPS.js.map +1 -0
  16. package/dist/chunks/{importer-aNJfe0qu.js → importer-ByPGO-09.js} +2 -2
  17. package/dist/chunks/{importer-aNJfe0qu.js.map → importer-ByPGO-09.js.map} +1 -1
  18. package/dist/chunks/importer-DOepkgnG.js +1713 -0
  19. package/dist/chunks/importer-DOepkgnG.js.map +1 -0
  20. package/dist/chunks/json-elements-CZY1wiZh.js +779 -0
  21. package/dist/chunks/json-elements-CZY1wiZh.js.map +1 -0
  22. package/dist/chunks/{records-Bk9jgodz.js → records-BzNicMsf.js} +2 -2
  23. package/dist/chunks/{records-Bk9jgodz.js.map → records-BzNicMsf.js.map} +1 -1
  24. package/dist/chunks/{report-BOk0p5y8.js → report-BcWboivV.js} +95 -95
  25. package/dist/chunks/{report-BOk0p5y8.js.map → report-BcWboivV.js.map} +1 -1
  26. package/dist/chunks/weights-CwISIpCP.js +176 -0
  27. package/dist/chunks/weights-CwISIpCP.js.map +1 -0
  28. package/dist/chunks/{writer-GAdltGmC.js → writer-DQiKgQJc.js} +8 -179
  29. package/dist/chunks/writer-DQiKgQJc.js.map +1 -0
  30. package/dist/csv.js +5 -4
  31. package/dist/csv.js.map +1 -1
  32. package/dist/cx.d.ts +1 -0
  33. package/dist/cx.js +6 -0
  34. package/dist/cx.js.map +1 -0
  35. package/dist/cx2.d.ts +1 -0
  36. package/dist/cx2.js +10 -0
  37. package/dist/cx2.js.map +1 -0
  38. package/dist/dot.js +1 -1
  39. package/dist/gexf.js +15 -4
  40. package/dist/gexf.js.map +1 -1
  41. package/dist/gml.js +5 -4
  42. package/dist/gml.js.map +1 -1
  43. package/dist/graph-io.js +145 -389
  44. package/dist/graph-io.js.map +1 -1
  45. package/dist/graphml.js +1 -1
  46. package/dist/json.js +1 -1
  47. package/dist/neo4j.js +5 -4
  48. package/dist/neo4j.js.map +1 -1
  49. package/dist/obo.js +1 -1
  50. package/dist/pajek.js +1 -1
  51. package/dist/src/common/json-elements.d.ts +286 -0
  52. package/dist/src/common/json-elements.d.ts.map +1 -0
  53. package/dist/src/common/json-elements.js +926 -0
  54. package/dist/src/common/json-elements.js.map +1 -0
  55. package/dist/src/formats/cx/importer.d.ts +133 -0
  56. package/dist/src/formats/cx/importer.d.ts.map +1 -0
  57. package/dist/src/formats/cx/importer.js +2220 -0
  58. package/dist/src/formats/cx/importer.js.map +1 -0
  59. package/dist/src/formats/cx/index.d.ts +7 -0
  60. package/dist/src/formats/cx/index.d.ts.map +1 -0
  61. package/dist/src/formats/cx/index.js +7 -0
  62. package/dist/src/formats/cx/index.js.map +1 -0
  63. package/dist/src/formats/cx2/exporter.d.ts +59 -0
  64. package/dist/src/formats/cx2/exporter.d.ts.map +1 -0
  65. package/dist/src/formats/cx2/exporter.js +864 -0
  66. package/dist/src/formats/cx2/exporter.js.map +1 -0
  67. package/dist/src/formats/cx2/importer.d.ts +169 -0
  68. package/dist/src/formats/cx2/importer.d.ts.map +1 -0
  69. package/dist/src/formats/cx2/importer.js +1652 -0
  70. package/dist/src/formats/cx2/importer.js.map +1 -0
  71. package/dist/src/formats/cx2/index.d.ts +7 -0
  72. package/dist/src/formats/cx2/index.d.ts.map +1 -0
  73. package/dist/src/formats/cx2/index.js +7 -0
  74. package/dist/src/formats/cx2/index.js.map +1 -0
  75. package/dist/src/formats/gexf/exporter.d.ts +2 -0
  76. package/dist/src/formats/gexf/exporter.d.ts.map +1 -1
  77. package/dist/src/formats/gexf/exporter.js +6 -0
  78. package/dist/src/formats/gexf/exporter.js.map +1 -1
  79. package/dist/src/formats/gexf/importer.d.ts +2 -4
  80. package/dist/src/formats/gexf/importer.d.ts.map +1 -1
  81. package/dist/src/formats/gexf/importer.js +2 -4
  82. package/dist/src/formats/gexf/importer.js.map +1 -1
  83. package/dist/src/formats/gexf/index.d.ts +1 -1
  84. package/dist/src/formats/gexf/index.js +2 -2
  85. package/dist/src/formats/gexf/index.js.map +1 -1
  86. package/dist/src/formats/gml/exporter.js +1 -1
  87. package/dist/src/formats/gml/exporter.js.map +1 -1
  88. package/dist/src/formats/json/importer.d.ts.map +1 -1
  89. package/dist/src/formats/json/importer.js +6 -104
  90. package/dist/src/formats/json/importer.js.map +1 -1
  91. package/dist/src/index.d.ts +2 -0
  92. package/dist/src/index.d.ts.map +1 -1
  93. package/dist/src/index.js +2 -0
  94. package/dist/src/index.js.map +1 -1
  95. package/dist/src/registry.d.ts.map +1 -1
  96. package/dist/src/registry.js +5 -0
  97. package/dist/src/registry.js.map +1 -1
  98. package/dist/src/sniff.d.ts +1 -1
  99. package/dist/src/sniff.d.ts.map +1 -1
  100. package/dist/src/sniff.js +2 -0
  101. package/dist/src/sniff.js.map +1 -1
  102. package/package.json +11 -1
  103. package/src/common/json-elements.ts +1147 -0
  104. package/src/formats/cx/importer.ts +2733 -0
  105. package/src/formats/cx/index.ts +7 -0
  106. package/src/formats/cx2/exporter.ts +1036 -0
  107. package/src/formats/cx2/importer.ts +2187 -0
  108. package/src/formats/cx2/index.ts +7 -0
  109. package/src/formats/gexf/exporter.ts +11 -0
  110. package/src/formats/gexf/importer.ts +2 -2
  111. package/src/formats/gexf/index.ts +1 -1
  112. package/src/formats/gml/exporter.ts +1 -1
  113. package/src/formats/json/importer.ts +6 -105
  114. package/src/index.ts +10 -0
  115. package/src/registry.ts +5 -0
  116. package/src/sniff.ts +14 -1
  117. package/dist/chunks/importer-Du5crN9l.js.map +0 -1
  118. package/dist/chunks/writer-GAdltGmC.js.map +0 -1
@@ -1,6 +1,8 @@
1
1
  import { GraphFormatError, INVALID_INDEX } from "@graphty/graph-format";
2
- import { aC as resolveExportOptions, ay as pairFolding, as as declareResolved, ag as UNKNOWN_ENCODING_CODE, s as ENCODING_FALLBACK_CODE, z as INVALID_ENCODING_CODE, F as INVALID_UTF8_CODE, V as OPTION_IGNORED_CODE, a3 as SINK_OPTION_CODE, H as HYPEREDGE_CODE, ad as TOO_LARGE_CODE, D as DANGLING_REFERENCE_CODE, A as AMBIGUOUS_GRAPH_NAME_CODE, G as GRAPH_NOT_FOUND_CODE, P as MULTIPLE_GRAPHS_CODE, v as ID_MERGED_CODE, n as DUPLICATE_EDGE_ID_CODE, p as DUPLICATE_NODE_CODE, ah as UNKNOWN_PARENT_CODE, e as BAD_VALUE_CODE, M as MISSING_ENDPOINT_CODE, N as MISSING_ID_CODE, a9 as SYNTAX_CODE, r as EMPTY_INPUT_CODE, aD as resolveImportOptions, I as ImportReportBuilder, az as readText, t as textChunks, aA as reportSinkOptions, aB as reportUnusedOptions, a as throwIfAborted, J as IdCoercer, q as DirectionResolver, aE as uniqueColumnName, ao as chooseGraph } from "./report-BOk0p5y8.js";
3
- import { c as capabilities, L as LOSS, n as joinText, e as encodeChunks, a as checkCapabilities, r as countMixedEdges, f as explicitWeights, h as formatF32, i as formatF64, w as weightFromValue } from "./writer-GAdltGmC.js";
2
+ import { aB as resolveExportOptions, ax as pairFolding, ar as declareResolved, af as UNKNOWN_ENCODING_CODE, r as ENCODING_FALLBACK_CODE, y as INVALID_ENCODING_CODE, z as INVALID_UTF8_CODE, U as OPTION_IGNORED_CODE, a2 as SINK_OPTION_CODE, H as HYPEREDGE_CODE, ac as TOO_LARGE_CODE, D as DANGLING_REFERENCE_CODE, A as AMBIGUOUS_GRAPH_NAME_CODE, G as GRAPH_NOT_FOUND_CODE, O as MULTIPLE_GRAPHS_CODE, u as ID_MERGED_CODE, m as DUPLICATE_EDGE_ID_CODE, o as DUPLICATE_NODE_CODE, ag as UNKNOWN_PARENT_CODE, d as BAD_VALUE_CODE, M as MISSING_ENDPOINT_CODE, K as MISSING_ID_CODE, a8 as SYNTAX_CODE, q as EMPTY_INPUT_CODE, aC as resolveImportOptions, I as ImportReportBuilder, ay as readText, aD as textChunks, az as reportSinkOptions, aA as reportUnusedOptions, t as throwIfAborted, F as IdCoercer, p as DirectionResolver, aE as uniqueColumnName, an as chooseGraph } from "./report-BcWboivV.js";
3
+ import { c as capabilities, L as LOSS, j as joinText, e as encodeChunks, a as checkCapabilities, g as countMixedEdges } from "./writer-DQiKgQJc.js";
4
+ import { e as explicitWeights, a as formatF32, b as formatF64, w as weightFromValue } from "./weights-CwISIpCP.js";
5
+ import { M as MAYBE_UNSAFE_INTEGER, e as rewriteNumbers, g as reviveNonstandard } from "./json-elements-CZY1wiZh.js";
4
6
  import { a as OBOGRAPHS_PREDICATE_TAGS, c as compactOboIri, o as oboColumnDecl, P as PLACEHOLDER_COLUMN, s as synonymScopeOf, O as OBO_NODE_COLUMNS } from "./ontology-BnrJ4I98.js";
5
7
  const JSON_DIALECTS = Object.freeze([
6
8
  "node-link",
@@ -1370,6 +1372,266 @@ const jsonExporter = Object.freeze({
1370
1372
  function jsonCapabilities(dialect) {
1371
1373
  return dialectCapabilities(dialect);
1372
1374
  }
1375
+ const GRAPH_FORMATS = Object.freeze([
1376
+ "json",
1377
+ "graphml",
1378
+ "gexf",
1379
+ "csv",
1380
+ "gml",
1381
+ "dot",
1382
+ "pajek",
1383
+ "neo4j",
1384
+ "cx2",
1385
+ "cx",
1386
+ "obo"
1387
+ ]);
1388
+ const SNIFF_HEAD_BYTES = 8192;
1389
+ function extensionOf(filename) {
1390
+ const base = filename.slice(Math.max(filename.lastIndexOf("/"), filename.lastIndexOf("\\")) + 1);
1391
+ const dot = base.lastIndexOf(".");
1392
+ if (dot <= 0 || dot === base.length - 1) {
1393
+ return null;
1394
+ }
1395
+ return base.slice(dot).toLowerCase();
1396
+ }
1397
+ function normalizeMimeType(mimeType) {
1398
+ const semicolon = mimeType.indexOf(";");
1399
+ return (semicolon < 0 ? mimeType : mimeType.slice(0, semicolon)).trim().toLowerCase();
1400
+ }
1401
+ function headBytes(head) {
1402
+ if (typeof head === "string") {
1403
+ return new TextEncoder().encode(head.slice(0, SNIFF_HEAD_BYTES)).subarray(0, SNIFF_HEAD_BYTES);
1404
+ }
1405
+ if (head.byteLength >= 2 && (head[0] === 255 && head[1] === 254 || head[0] === 254 && head[1] === 255)) {
1406
+ const encoding = head[0] === 255 ? "utf-16le" : "utf-16be";
1407
+ return headBytes(new TextDecoder(encoding).decode(head.subarray(0, SNIFF_HEAD_BYTES)));
1408
+ }
1409
+ return head.byteLength > SNIFF_HEAD_BYTES ? head.subarray(0, SNIFF_HEAD_BYTES) : head;
1410
+ }
1411
+ function rankFormats(hints, importers) {
1412
+ const extension = typeof hints.filename === "string" ? extensionOf(hints.filename) : null;
1413
+ const mime = typeof hints.mimeType === "string" ? normalizeMimeType(hints.mimeType) : null;
1414
+ const head = hints.head === void 0 || hints.head === null ? null : headBytes(hints.head);
1415
+ const candidates = [];
1416
+ let rank = 0;
1417
+ for (const importer of importers) {
1418
+ const extensionMatch = extension !== null && importer.extensions.some((e) => e.toLowerCase() === extension);
1419
+ const mimeMatch = mime !== null && importer.mimeTypes.some((m) => m.toLowerCase() === mime);
1420
+ let content = 0;
1421
+ if (head !== null && head.byteLength > 0 && typeof importer.sniff === "function") {
1422
+ content = clamp(importer.sniff(head));
1423
+ }
1424
+ let confidence;
1425
+ if (content > 0) {
1426
+ confidence = 0.5 + 0.35 * content + (extensionMatch ? 0.1 : 0) + (mimeMatch ? 0.05 : 0);
1427
+ } else if (extensionMatch || mimeMatch) {
1428
+ confidence = (extensionMatch ? 0.3 : 0) + (mimeMatch ? 0.1 : 0);
1429
+ } else {
1430
+ continue;
1431
+ }
1432
+ const dialect = importer.format === "json" && head !== null ? sniffJsonDialectHead(head) : null;
1433
+ const result = Object.freeze({
1434
+ format: importer.format,
1435
+ confidence: Math.min(1, confidence),
1436
+ content,
1437
+ extension: extensionMatch,
1438
+ mimeType: mimeMatch,
1439
+ dialect
1440
+ });
1441
+ candidates.push({ result, rank: rank++ });
1442
+ }
1443
+ candidates.sort((a, b) => b.result.confidence - a.result.confidence || a.rank - b.rank);
1444
+ return candidates.map((c) => c.result);
1445
+ }
1446
+ function sniffFormat(hints, importers) {
1447
+ const ranked = rankFormats(hints, importers);
1448
+ return ranked.length > 0 ? ranked[0] : null;
1449
+ }
1450
+ function sniffJsonDialectHead(head) {
1451
+ const text = typeof head === "string" ? head : new TextDecoder("utf-8", { fatal: false }).decode(head);
1452
+ const body = text.charCodeAt(0) === 65279 ? text.slice(1) : text;
1453
+ const trimmed = body.trimStart();
1454
+ if (!trimmed.startsWith("{") && !trimmed.startsWith("[")) {
1455
+ return null;
1456
+ }
1457
+ let root;
1458
+ try {
1459
+ root = JSON.parse(trimmed);
1460
+ } catch {
1461
+ root = skeletonOf(trimmed);
1462
+ }
1463
+ return sniffJsonDialect(root);
1464
+ }
1465
+ function skeletonOf(text) {
1466
+ const keys = scanKeys(text);
1467
+ if (text.startsWith("[")) {
1468
+ const first = keys.get("nodes[0]");
1469
+ return first === void 0 ? null : [objectOf(first)];
1470
+ }
1471
+ const rootKeys = keys.get("");
1472
+ if (rootKeys === void 0) {
1473
+ return null;
1474
+ }
1475
+ const root = {};
1476
+ for (const key of rootKeys) {
1477
+ switch (key) {
1478
+ case "graph":
1479
+ case "options":
1480
+ root[key] = objectOf(keys.get(key));
1481
+ break;
1482
+ case "graphs": {
1483
+ const nodes = keys.get("graphs[0].nodes[]");
1484
+ const edges = keys.get("graphs[0].edges[]");
1485
+ const graph = {};
1486
+ if (nodes !== void 0) {
1487
+ graph.nodes = [objectOf(nodes)];
1488
+ }
1489
+ if (edges !== void 0) {
1490
+ graph.edges = [objectOf(edges)];
1491
+ }
1492
+ root[key] = nodes === void 0 && edges === void 0 ? [] : [graph];
1493
+ break;
1494
+ }
1495
+ case "nodes":
1496
+ case "edges":
1497
+ case "links": {
1498
+ const first = keys.get(`${key}[0]`);
1499
+ root[key] = first === void 0 ? [] : [objectOf(first)];
1500
+ break;
1501
+ }
1502
+ default:
1503
+ root[key] = true;
1504
+ break;
1505
+ }
1506
+ }
1507
+ return root;
1508
+ }
1509
+ function objectOf(names) {
1510
+ const out = {};
1511
+ if (names !== void 0) {
1512
+ for (const name of names) {
1513
+ out[name] = name === "attributes" || name === "data" ? {} : true;
1514
+ }
1515
+ }
1516
+ return out;
1517
+ }
1518
+ function scanKeys(text) {
1519
+ const found = /* @__PURE__ */ new Map();
1520
+ const kinds = [];
1521
+ const labels = [];
1522
+ const counts = [];
1523
+ let pendingKey = null;
1524
+ let expectingKey = false;
1525
+ const pathOf = () => {
1526
+ const depth = kinds.length;
1527
+ if (depth === 1) {
1528
+ return kinds[0] === "object" ? "" : null;
1529
+ }
1530
+ if (depth === 2 && kinds[0] === "array" && kinds[1] === "object" && labels[1] === "0") {
1531
+ return "nodes[0]";
1532
+ }
1533
+ if (depth === 2 && kinds[0] === "object" && kinds[1] === "object") {
1534
+ return labels[1] === "graph" || labels[1] === "options" ? labels[1] : null;
1535
+ }
1536
+ if (depth === 5 && kinds.join() === "object,array,object,array,object" && labels[1] === "graphs" && labels[2] === "0" && (labels[3] === "nodes" || labels[3] === "edges")) {
1537
+ return labels[3] === "nodes" ? "graphs[0].nodes[]" : "graphs[0].edges[]";
1538
+ }
1539
+ if (depth === 3 && kinds[0] === "object" && kinds[1] === "array" && kinds[2] === "object") {
1540
+ const section = labels[1];
1541
+ if ((section === "nodes" || section === "edges" || section === "links") && labels[2] === "0") {
1542
+ return `${section}[0]`;
1543
+ }
1544
+ }
1545
+ return null;
1546
+ };
1547
+ let i = 0;
1548
+ const n = text.length;
1549
+ while (i < n) {
1550
+ const ch = text[i];
1551
+ if (ch === '"') {
1552
+ const end = scanString(text, i + 1);
1553
+ if (end < 0) {
1554
+ break;
1555
+ }
1556
+ const literal = text.slice(i + 1, end);
1557
+ i = end + 1;
1558
+ if (expectingKey) {
1559
+ pendingKey = decodeKey(literal);
1560
+ expectingKey = false;
1561
+ }
1562
+ continue;
1563
+ }
1564
+ if (ch === "{" || ch === "[") {
1565
+ let label = "";
1566
+ if (kinds.length > 0) {
1567
+ label = kinds[kinds.length - 1] === "object" ? pendingKey ?? "" : String(counts[counts.length - 1]);
1568
+ }
1569
+ kinds.push(ch === "{" ? "object" : "array");
1570
+ labels.push(label);
1571
+ counts.push(0);
1572
+ expectingKey = ch === "{";
1573
+ pendingKey = null;
1574
+ } else if (ch === "}" || ch === "]") {
1575
+ kinds.pop();
1576
+ labels.pop();
1577
+ counts.pop();
1578
+ expectingKey = false;
1579
+ pendingKey = null;
1580
+ } else if (ch === ":") {
1581
+ if (pendingKey !== null) {
1582
+ const path = pathOf();
1583
+ if (path !== null) {
1584
+ let set = found.get(path);
1585
+ if (set === void 0) {
1586
+ set = /* @__PURE__ */ new Set();
1587
+ found.set(path, set);
1588
+ }
1589
+ set.add(pendingKey);
1590
+ }
1591
+ }
1592
+ } else if (ch === ",") {
1593
+ const top = kinds.length - 1;
1594
+ if (top >= 0) {
1595
+ counts[top]++;
1596
+ expectingKey = kinds[top] === "object";
1597
+ }
1598
+ pendingKey = null;
1599
+ }
1600
+ i++;
1601
+ }
1602
+ return found;
1603
+ }
1604
+ function scanString(text, from) {
1605
+ let i = from;
1606
+ while (i < text.length) {
1607
+ const ch = text[i];
1608
+ if (ch === "\\") {
1609
+ i += 2;
1610
+ continue;
1611
+ }
1612
+ if (ch === '"') {
1613
+ return i;
1614
+ }
1615
+ i++;
1616
+ }
1617
+ return -1;
1618
+ }
1619
+ function decodeKey(literal) {
1620
+ if (!literal.includes("\\")) {
1621
+ return literal;
1622
+ }
1623
+ try {
1624
+ return JSON.parse(`"${literal}"`);
1625
+ } catch {
1626
+ return literal;
1627
+ }
1628
+ }
1629
+ function clamp(value) {
1630
+ if (!(value > 0)) {
1631
+ return 0;
1632
+ }
1633
+ return value > 1 ? 1 : value;
1634
+ }
1373
1635
  const NODE_KEYS = /* @__PURE__ */ new Set(["id", "lbl", "type", "propertyType", "meta"]);
1374
1636
  const META_KEYS = /* @__PURE__ */ new Set([
1375
1637
  "definition",
@@ -2592,84 +2854,7 @@ function parseDocument(text, report) {
2592
2854
  }
2593
2855
  return root;
2594
2856
  }
2595
- const MAYBE_UNSAFE_INTEGER = new RegExp("(?<![0-9.])[0-9]{16}");
2596
2857
  const BIG_INTEGERS_SHOWN = 10;
2597
- const NONSTANDARD_SENTINEL = `${String.fromCharCode(0)}graph-io:`;
2598
- const NONSTANDARD_TOKENS = [
2599
- ["-Infinity", -Infinity],
2600
- ["Infinity", Infinity],
2601
- ["NaN", NaN]
2602
- ];
2603
- const INTEGER_LITERAL = /^-?(0|[1-9][0-9]*)$/;
2604
- function rewriteNumbers(text) {
2605
- const parts = [];
2606
- const tokens = /* @__PURE__ */ new Set();
2607
- const bigIntegers = [];
2608
- const arrays = [];
2609
- let expectValue = true;
2610
- let copied = 0;
2611
- let i = 0;
2612
- const n = text.length;
2613
- while (i < n) {
2614
- const ch = text[i];
2615
- if (ch === '"') {
2616
- i++;
2617
- while (i < n && text[i] !== '"') {
2618
- i += text[i] === "\\" ? 2 : 1;
2619
- }
2620
- i++;
2621
- expectValue = false;
2622
- continue;
2623
- }
2624
- if (ch === "{" || ch === "[") {
2625
- arrays.push(ch === "[");
2626
- expectValue = ch === "[";
2627
- } else if (ch === "}" || ch === "]") {
2628
- arrays.pop();
2629
- expectValue = false;
2630
- } else if (ch === ":") {
2631
- expectValue = true;
2632
- } else if (ch === ",") {
2633
- expectValue = arrays.length > 0 && arrays[arrays.length - 1];
2634
- } else if (expectValue && ch !== " " && ch !== " " && ch !== "\n" && ch !== "\r") {
2635
- expectValue = false;
2636
- const token = NONSTANDARD_TOKENS.find(([word]) => text.startsWith(word, i));
2637
- let end = i;
2638
- let replacement = null;
2639
- if (token !== void 0) {
2640
- end = i + token[0].length;
2641
- tokens.add(token[0]);
2642
- replacement = JSON.stringify(`${NONSTANDARD_SENTINEL}${token[0]}`);
2643
- } else if (ch === "-" || ch >= "0" && ch <= "9") {
2644
- end = i + 1;
2645
- while (end < n && "0123456789+-.eE".includes(text[end])) {
2646
- end++;
2647
- }
2648
- const literal = text.slice(i, end);
2649
- if (INTEGER_LITERAL.test(literal) && !Number.isSafeInteger(Number(literal))) {
2650
- bigIntegers.push(literal);
2651
- replacement = `"${literal}"`;
2652
- }
2653
- }
2654
- if (replacement !== null) {
2655
- parts.push(text.slice(copied, i), replacement);
2656
- copied = end;
2657
- }
2658
- i = Math.max(end, i + 1);
2659
- continue;
2660
- }
2661
- i++;
2662
- }
2663
- parts.push(text.slice(copied));
2664
- return { text: parts.join(""), tokens, bigIntegers };
2665
- }
2666
- function reviveNonstandard(_key, value) {
2667
- if (typeof value === "string" && value.startsWith(NONSTANDARD_SENTINEL)) {
2668
- const found = NONSTANDARD_TOKENS.find(([word]) => word === value.slice(NONSTANDARD_SENTINEL.length));
2669
- return found === void 0 ? value : found[1];
2670
- }
2671
- return value;
2672
- }
2673
2858
  function detectDialect(root, forced, report) {
2674
2859
  if (forced !== "auto") {
2675
2860
  return forced;
@@ -3860,7 +4045,8 @@ const jsonImporter = Object.freeze({
3860
4045
  if (!trimmed.startsWith("{") && !trimmed.startsWith("[")) {
3861
4046
  return 0;
3862
4047
  }
3863
- return SNIFF_KEYS.some((key) => trimmed.includes(key)) ? 0.9 : 0.5;
4048
+ const score = SNIFF_KEYS.some((key) => trimmed.includes(key)) ? 0.9 : 0.5;
4049
+ return trimmed.startsWith("[") && sniffJsonDialectHead(trimmed) !== "cytoscape" ? Math.min(score, 0.3) : score;
3864
4050
  },
3865
4051
  /**
3866
4052
  * Read a JSON graph document into the sink.
@@ -3962,13 +4148,20 @@ function readGraph(root, dialect, sink, report, resolved, json, options) {
3962
4148
  throwIfAborted(resolved.signal);
3963
4149
  }
3964
4150
  export {
4151
+ GRAPH_FORMATS as G,
3965
4152
  JSON_DIALECTS as J,
4153
+ SNIFF_HEAD_BYTES as S,
3966
4154
  JSON_ISSUE as a,
3967
4155
  JSON_LOSS as b,
3968
4156
  jsonExporter as c,
3969
4157
  dialectCapabilities as d,
3970
4158
  jsonImporter as e,
4159
+ extensionOf as f,
4160
+ sniffJsonDialectHead as g,
4161
+ headBytes as h,
3971
4162
  jsonCapabilities as j,
3972
- sniffJsonDialect as s
4163
+ normalizeMimeType as n,
4164
+ rankFormats as r,
4165
+ sniffFormat as s
3973
4166
  };
3974
- //# sourceMappingURL=importer-Du5crN9l.js.map
4167
+ //# sourceMappingURL=importer-Bm1_5vPS.js.map