@graphty/graph-io 0.3.41 → 0.3.42
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/README.md +2 -0
- package/dist/chunks/{children-CL3Cy0ez.js → children-CA4coBi0.js} +36 -27
- package/dist/chunks/children-CA4coBi0.js.map +1 -0
- package/dist/chunks/{choose-CwFQamH9.js → choose-DvpbdRuz.js} +2 -2
- package/dist/chunks/{choose-CwFQamH9.js.map → choose-DvpbdRuz.js.map} +1 -1
- package/dist/chunks/{constants-Cf4Nn6tw.js → constants-fT3E8JYY.js} +2 -2
- package/dist/chunks/{constants-Cf4Nn6tw.js.map → constants-fT3E8JYY.js.map} +1 -1
- package/dist/chunks/{escape-DBb8zuNE.js → escape-B62ZGM_a.js} +2 -2
- package/dist/chunks/{escape-DBb8zuNE.js.map → escape-B62ZGM_a.js.map} +1 -1
- package/dist/chunks/{export-DD3Lvw-F.js → export-rKLeGQMo.js} +232 -128
- package/dist/chunks/export-rKLeGQMo.js.map +1 -0
- package/dist/chunks/{exporter-CS35R6Fg.js → exporter-8hLNemFk.js} +4 -4
- package/dist/chunks/{exporter-CS35R6Fg.js.map → exporter-8hLNemFk.js.map} +1 -1
- package/dist/chunks/{exporter-D8r1N2dU.js → exporter-BWwEuOPT.js} +5 -5
- package/dist/chunks/{exporter-D8r1N2dU.js.map → exporter-BWwEuOPT.js.map} +1 -1
- package/dist/chunks/{exporter-BqtmlxNr.js → exporter-CpRyHZ3H.js} +34 -21
- package/dist/chunks/exporter-CpRyHZ3H.js.map +1 -0
- package/dist/chunks/{exporter-NMplSnYn.js → exporter-yLxKBvLE.js} +3 -3
- package/dist/chunks/{exporter-NMplSnYn.js.map → exporter-yLxKBvLE.js.map} +1 -1
- package/dist/chunks/{importer-S-abxJHn.js → importer-BbNb7eNg.js} +111 -71
- package/dist/chunks/importer-BbNb7eNg.js.map +1 -0
- package/dist/chunks/{importer-BdWHmlmG.js → importer-C98dpSH4.js} +5 -5
- package/dist/chunks/{importer-BdWHmlmG.js.map → importer-C98dpSH4.js.map} +1 -1
- package/dist/chunks/{importer-r29cWnEf.js → importer-D794XUTe.js} +3 -3
- package/dist/chunks/{importer-r29cWnEf.js.map → importer-D794XUTe.js.map} +1 -1
- package/dist/chunks/{importer-BfbzWk6k.js → importer-Dz7tI8Sa.js} +5 -5
- package/dist/chunks/{importer-BfbzWk6k.js.map → importer-Dz7tI8Sa.js.map} +1 -1
- package/dist/chunks/{importer-DviEsHy4.js → importer-Ht7LNg8L.js} +4 -4
- package/dist/chunks/{importer-DviEsHy4.js.map → importer-Ht7LNg8L.js.map} +1 -1
- package/dist/chunks/{importer-BKC7AmCA.js → importer-WrGRZb0N.js} +6 -6
- package/dist/chunks/{importer-BKC7AmCA.js.map → importer-WrGRZb0N.js.map} +1 -1
- package/dist/chunks/{importer-BmaZcskq.js → importer-xZ-3suY1.js} +5 -5
- package/dist/chunks/{importer-BmaZcskq.js.map → importer-xZ-3suY1.js.map} +1 -1
- package/dist/chunks/{json-elements-DdF-etPT.js → json-elements-DKSqpNW1.js} +3 -3
- package/dist/chunks/{json-elements-DdF-etPT.js.map → json-elements-DKSqpNW1.js.map} +1 -1
- package/dist/chunks/{ontology-export-BC0zyPhj.js → ontology-export-CtRXjg_i.js} +2 -2
- package/dist/chunks/{ontology-export-BC0zyPhj.js.map → ontology-export-CtRXjg_i.js.map} +1 -1
- package/dist/chunks/{records-Uc3LkABx.js → records-Cu4bxYOm.js} +56 -26
- package/dist/chunks/records-Cu4bxYOm.js.map +1 -0
- package/dist/chunks/{text-Bh9SaAob.js → text-DHOJXnED.js} +2 -2
- package/dist/chunks/{text-Bh9SaAob.js.map → text-DHOJXnED.js.map} +1 -1
- package/dist/csv.js +260 -196
- package/dist/csv.js.map +1 -1
- package/dist/cx.js +1 -1
- package/dist/cx2.js +2 -2
- package/dist/cys.js +1 -1
- package/dist/dot.js +1 -1
- package/dist/gexf.js +2 -2
- package/dist/gml.js +3 -3
- package/dist/graph-io.js +27 -27
- package/dist/graphml.js +2 -2
- package/dist/json.js +1 -1
- package/dist/neo4j.js +3 -3
- package/dist/obo.js +1 -1
- package/dist/pajek.js +1 -1
- package/dist/src/children.d.ts.map +1 -1
- package/dist/src/children.js +50 -27
- package/dist/src/children.js.map +1 -1
- package/dist/src/common/attributes.d.ts.map +1 -1
- package/dist/src/common/attributes.js +52 -33
- package/dist/src/common/attributes.js.map +1 -1
- package/dist/src/common/input.d.ts.map +1 -1
- package/dist/src/common/input.js +178 -82
- package/dist/src/common/input.js.map +1 -1
- package/dist/src/common/lists.js +30 -15
- package/dist/src/common/lists.js.map +1 -1
- package/dist/src/formats/csv/exporter.d.ts.map +1 -1
- package/dist/src/formats/csv/exporter.js +211 -121
- package/dist/src/formats/csv/exporter.js.map +1 -1
- package/dist/src/formats/csv/importer.d.ts.map +1 -1
- package/dist/src/formats/csv/importer.js +113 -74
- package/dist/src/formats/csv/importer.js.map +1 -1
- package/dist/src/formats/csv/records.d.ts.map +1 -1
- package/dist/src/formats/csv/records.js +60 -26
- package/dist/src/formats/csv/records.js.map +1 -1
- package/dist/src/formats/dot/tokenizer.d.ts +39 -0
- package/dist/src/formats/dot/tokenizer.d.ts.map +1 -1
- package/dist/src/formats/dot/tokenizer.js +112 -66
- package/dist/src/formats/dot/tokenizer.js.map +1 -1
- package/dist/src/formats/json/dialect.d.ts.map +1 -1
- package/dist/src/formats/json/dialect.js +54 -20
- package/dist/src/formats/json/dialect.js.map +1 -1
- package/dist/xgmml.js +2 -2
- package/package.json +2 -2
- package/src/children.ts +54 -27
- package/src/common/attributes.ts +59 -30
- package/src/common/input.ts +223 -95
- package/src/common/lists.ts +29 -15
- package/src/formats/csv/exporter.ts +274 -136
- package/src/formats/csv/importer.ts +138 -78
- package/src/formats/csv/records.ts +71 -25
- package/src/formats/dot/tokenizer.ts +118 -68
- package/src/formats/json/dialect.ts +61 -22
- package/dist/chunks/children-CL3Cy0ez.js.map +0 -1
- package/dist/chunks/export-DD3Lvw-F.js.map +0 -1
- package/dist/chunks/exporter-BqtmlxNr.js.map +0 -1
- package/dist/chunks/importer-S-abxJHn.js.map +0 -1
- package/dist/chunks/records-Uc3LkABx.js.map +0 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { GraphFormatError, INVALID_INDEX } from "@graphty/graph-format";
|
|
2
|
-
import { c as childrenCsr } from "./children-
|
|
3
|
-
import { L as LOSS, r as resolveExportOptions, a as checkCapabilities, c as capabilities, bD as countMixedEdges, e as explicitWeights, p as pairFolding, b as plural, aE as sanitizeIds, aa as formatF32, ab as formatF64, a9 as idText, $ as agree, aF as formatDecimal, aG as formatInteger, aH as canonicalId, M as MIXED_DIRECTION_CODE, D as DIRECTION_FORCED_CODE, d as DIRECTION_REFUSED_CODE, S as SINK_OPTION_CODE, I as ID_MERGED_CODE, O as OPTION_IGNORED_CODE, C as COLUMN_RENAMED_CODE, R as ROLE_TAKEN_CODE, o as DUPLICATE_ATTRIBUTE_CODE, P as PRECISION_CODE, ae as AMBIGUOUS_GRAPH_NAME_CODE, af as GRAPH_NOT_FOUND_CODE, l as MULTIPLE_GRAPHS_CODE, v as ENCODING_CONFLICT_CODE, w as UNKNOWN_ENCODING_CODE, x as ENCODING_FALLBACK_CODE, y as INVALID_ENCODING_CODE, z as INVALID_UTF8_CODE, E as EMPTY_INPUT_CODE, ak as SYNTAX_CODE, F as ELEMENT_ISSUE, G as INPUT_ISSUE, al as resolveImportOptions, a8 as ImportReportBuilder, an as reportUnusedOptions, bB as readText, ao as reportSinkOptions, am as throwIfAborted, ap as graphChosen, ar as IdCoercer, aq as DirectionResolver, aK as parseWeightText, bE as canonicalEncoding, a1 as declareResolved } from "./export-
|
|
4
|
-
import { c as quoteDotId, d as isWritableDotText } from "./escape-
|
|
5
|
-
import { i as inferTextDtype, W as WIDENING_UNSUPPORTED_CODE, p as parseTextCell, T as TextCellWriter } from "./text-
|
|
2
|
+
import { c as childrenCsr } from "./children-CA4coBi0.js";
|
|
3
|
+
import { L as LOSS, r as resolveExportOptions, a as checkCapabilities, c as capabilities, bD as countMixedEdges, e as explicitWeights, p as pairFolding, b as plural, aE as sanitizeIds, aa as formatF32, ab as formatF64, a9 as idText, $ as agree, aF as formatDecimal, aG as formatInteger, aH as canonicalId, M as MIXED_DIRECTION_CODE, D as DIRECTION_FORCED_CODE, d as DIRECTION_REFUSED_CODE, S as SINK_OPTION_CODE, I as ID_MERGED_CODE, O as OPTION_IGNORED_CODE, C as COLUMN_RENAMED_CODE, R as ROLE_TAKEN_CODE, o as DUPLICATE_ATTRIBUTE_CODE, P as PRECISION_CODE, ae as AMBIGUOUS_GRAPH_NAME_CODE, af as GRAPH_NOT_FOUND_CODE, l as MULTIPLE_GRAPHS_CODE, v as ENCODING_CONFLICT_CODE, w as UNKNOWN_ENCODING_CODE, x as ENCODING_FALLBACK_CODE, y as INVALID_ENCODING_CODE, z as INVALID_UTF8_CODE, E as EMPTY_INPUT_CODE, ak as SYNTAX_CODE, F as ELEMENT_ISSUE, G as INPUT_ISSUE, al as resolveImportOptions, a8 as ImportReportBuilder, an as reportUnusedOptions, bB as readText, ao as reportSinkOptions, am as throwIfAborted, ap as graphChosen, ar as IdCoercer, aq as DirectionResolver, aK as parseWeightText, bE as canonicalEncoding, a1 as declareResolved } from "./export-rKLeGQMo.js";
|
|
4
|
+
import { c as quoteDotId, d as isWritableDotText } from "./escape-B62ZGM_a.js";
|
|
5
|
+
import { i as inferTextDtype, W as WIDENING_UNSUPPORTED_CODE, p as parseTextCell, T as TextCellWriter } from "./text-DHOJXnED.js";
|
|
6
6
|
import { j as joinText, e as encodeChunks, i as indentUnit } from "./writer-DxjgHwSe.js";
|
|
7
|
-
import { i as importChosenGraph } from "./choose-
|
|
7
|
+
import { i as importChosenGraph } from "./choose-DvpbdRuz.js";
|
|
8
8
|
const DOT_FORMAT = "dot";
|
|
9
9
|
const DOT_ORIGIN = Object.freeze({ format: DOT_FORMAT });
|
|
10
10
|
const CLUSTER_COLUMN = "graphty.cluster";
|
|
@@ -890,6 +890,9 @@ function isIdentifierPart(c) {
|
|
|
890
890
|
function isDigit(c) {
|
|
891
891
|
return c >= 48 && c <= 57;
|
|
892
892
|
}
|
|
893
|
+
function isBlank(c) {
|
|
894
|
+
return c === 32 || c === 9 || c === 11 || c === 12 || c === BOM_CODE;
|
|
895
|
+
}
|
|
893
896
|
class DotTokenizer {
|
|
894
897
|
/**
|
|
895
898
|
* Create a lexer over a whole document.
|
|
@@ -1037,37 +1040,64 @@ class DotTokenizer {
|
|
|
1037
1040
|
this.pos = i + 1;
|
|
1038
1041
|
return { kind: "id", text: out, quoted: true, html: false, line };
|
|
1039
1042
|
}
|
|
1040
|
-
if (c === 92) {
|
|
1041
|
-
|
|
1042
|
-
if (
|
|
1043
|
-
out +=
|
|
1044
|
-
i += 2;
|
|
1045
|
-
segment = i;
|
|
1046
|
-
continue;
|
|
1047
|
-
}
|
|
1048
|
-
if (d === 92) {
|
|
1049
|
-
i += 2;
|
|
1050
|
-
continue;
|
|
1051
|
-
}
|
|
1052
|
-
if (d === 10 || d === 13) {
|
|
1053
|
-
out += text.slice(segment, i);
|
|
1054
|
-
i += d === 13 && text.charCodeAt(i + 2) === 10 ? 3 : 2;
|
|
1055
|
-
this.line++;
|
|
1056
|
-
segment = i;
|
|
1057
|
-
continue;
|
|
1058
|
-
}
|
|
1059
|
-
i++;
|
|
1060
|
-
continue;
|
|
1061
|
-
}
|
|
1062
|
-
if (c === 10 || c === 13) {
|
|
1063
|
-
if (c === 13 && text.charCodeAt(i + 1) === 10) {
|
|
1064
|
-
i++;
|
|
1043
|
+
if (c === 92 && this.isQuotedSplice(i)) {
|
|
1044
|
+
out += text.slice(segment, i);
|
|
1045
|
+
if (text.codePointAt(i + 1) === 34) {
|
|
1046
|
+
out += '"';
|
|
1065
1047
|
}
|
|
1066
|
-
this.
|
|
1048
|
+
i = this.quotedSpliceEnd(i);
|
|
1049
|
+
segment = i;
|
|
1050
|
+
} else {
|
|
1051
|
+
i = this.quotedStep(i, c);
|
|
1067
1052
|
}
|
|
1068
|
-
i++;
|
|
1069
1053
|
}
|
|
1070
1054
|
}
|
|
1055
|
+
/**
|
|
1056
|
+
* Whether the backslash at `i` inside a quoted string starts a sequence that changes the decoded
|
|
1057
|
+
* text: `\"` (an escaped quote) or a backslash before a line break (a line continuation).
|
|
1058
|
+
* @param i - the offset of the backslash
|
|
1059
|
+
* @returns true for an escaped quote or a line continuation
|
|
1060
|
+
*/
|
|
1061
|
+
isQuotedSplice(i) {
|
|
1062
|
+
const d = this.text.codePointAt(i + 1);
|
|
1063
|
+
return d === 34 || d === 10 || d === 13;
|
|
1064
|
+
}
|
|
1065
|
+
/**
|
|
1066
|
+
* The offset just past an escaped quote or a line continuation, counting the line a
|
|
1067
|
+
* continuation ends.
|
|
1068
|
+
* @param i - the offset of the backslash
|
|
1069
|
+
* @returns the offset after the sequence
|
|
1070
|
+
*/
|
|
1071
|
+
quotedSpliceEnd(i) {
|
|
1072
|
+
const { text } = this;
|
|
1073
|
+
const d = text.charCodeAt(i + 1);
|
|
1074
|
+
if (d === 34) {
|
|
1075
|
+
return i + 2;
|
|
1076
|
+
}
|
|
1077
|
+
this.line++;
|
|
1078
|
+
return d === 13 && text.codePointAt(i + 2) === 10 ? i + 3 : i + 2;
|
|
1079
|
+
}
|
|
1080
|
+
/**
|
|
1081
|
+
* Step over one unit of a quoted string kept as written: a backslash pair (consumed as one unit,
|
|
1082
|
+
* as Graphviz's scanner does, so the second backslash never escapes a closing quote: "x\\" is
|
|
1083
|
+
* the text x\\), a lone backslash, a raw line break (counted) or any other character.
|
|
1084
|
+
* @param i - the offset of the unit
|
|
1085
|
+
* @param c - the code unit at `i`
|
|
1086
|
+
* @returns the offset after the unit
|
|
1087
|
+
*/
|
|
1088
|
+
quotedStep(i, c) {
|
|
1089
|
+
const { text } = this;
|
|
1090
|
+
if (c === 92) {
|
|
1091
|
+
return text.codePointAt(i + 1) === 92 ? i + 2 : i + 1;
|
|
1092
|
+
}
|
|
1093
|
+
if (c === 10) {
|
|
1094
|
+
this.line++;
|
|
1095
|
+
} else if (c === 13) {
|
|
1096
|
+
this.line++;
|
|
1097
|
+
return text.codePointAt(i + 1) === 10 ? i + 2 : i + 1;
|
|
1098
|
+
}
|
|
1099
|
+
return i + 1;
|
|
1100
|
+
}
|
|
1071
1101
|
/**
|
|
1072
1102
|
* Lex an HTML string starting at the opening angle bracket: the text up to the matching
|
|
1073
1103
|
* closing bracket, brackets balanced, kept verbatim including the outer pair.
|
|
@@ -1099,49 +1129,59 @@ class DotTokenizer {
|
|
|
1099
1129
|
*/
|
|
1100
1130
|
skipTrivia() {
|
|
1101
1131
|
const { text } = this;
|
|
1102
|
-
|
|
1103
|
-
if (this.pos >= text.length) {
|
|
1104
|
-
return;
|
|
1105
|
-
}
|
|
1132
|
+
while (this.pos < text.length) {
|
|
1106
1133
|
const c = text.charCodeAt(this.pos);
|
|
1107
|
-
if (c
|
|
1108
|
-
this.line++;
|
|
1134
|
+
if (isBlank(c)) {
|
|
1109
1135
|
this.pos++;
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
}
|
|
1113
|
-
if (c === 13) {
|
|
1114
|
-
this.line++;
|
|
1115
|
-
this.pos += text.charCodeAt(this.pos + 1) === 10 ? 2 : 1;
|
|
1116
|
-
this.skipPreprocessorLine();
|
|
1117
|
-
continue;
|
|
1118
|
-
}
|
|
1119
|
-
if (c === 32 || c === 9 || c === 11 || c === 12) {
|
|
1120
|
-
this.pos++;
|
|
1121
|
-
continue;
|
|
1122
|
-
}
|
|
1123
|
-
if (c === BOM_CODE) {
|
|
1124
|
-
this.pos++;
|
|
1125
|
-
continue;
|
|
1126
|
-
}
|
|
1127
|
-
if (c === 47) {
|
|
1128
|
-
const d = text.charCodeAt(this.pos + 1);
|
|
1129
|
-
if (d === 47) {
|
|
1130
|
-
this.skipToLineEnd();
|
|
1131
|
-
continue;
|
|
1132
|
-
}
|
|
1133
|
-
if (d === 42) {
|
|
1134
|
-
this.skipBlockComment();
|
|
1135
|
-
continue;
|
|
1136
|
-
}
|
|
1137
|
-
}
|
|
1138
|
-
if (c === 35 && this.pos === 0) {
|
|
1139
|
-
this.skipToLineEnd();
|
|
1140
|
-
continue;
|
|
1136
|
+
} else if (!this.skipBreakOrComment(c)) {
|
|
1137
|
+
return;
|
|
1141
1138
|
}
|
|
1142
|
-
return;
|
|
1143
1139
|
}
|
|
1144
1140
|
}
|
|
1141
|
+
/**
|
|
1142
|
+
* Skip one line break, comment or leading `#` line at the current position.
|
|
1143
|
+
* @param c - the code unit at the current position
|
|
1144
|
+
* @returns false when the current position starts a token
|
|
1145
|
+
*/
|
|
1146
|
+
skipBreakOrComment(c) {
|
|
1147
|
+
if (c === 10 || c === 13) {
|
|
1148
|
+
this.skipLineBreak(c);
|
|
1149
|
+
return true;
|
|
1150
|
+
}
|
|
1151
|
+
if (c === 47) {
|
|
1152
|
+
return this.skipComment();
|
|
1153
|
+
}
|
|
1154
|
+
if (c === 35 && this.pos === 0) {
|
|
1155
|
+
this.skipToLineEnd();
|
|
1156
|
+
return true;
|
|
1157
|
+
}
|
|
1158
|
+
return false;
|
|
1159
|
+
}
|
|
1160
|
+
/**
|
|
1161
|
+
* Consume the line break at the current position (CR LF as one) and a `#` line after it.
|
|
1162
|
+
* @param c - the code unit at the current position, LF or CR
|
|
1163
|
+
*/
|
|
1164
|
+
skipLineBreak(c) {
|
|
1165
|
+
this.line++;
|
|
1166
|
+
this.pos += c === 13 && this.text.codePointAt(this.pos + 1) === 10 ? 2 : 1;
|
|
1167
|
+
this.skipPreprocessorLine();
|
|
1168
|
+
}
|
|
1169
|
+
/**
|
|
1170
|
+
* Skip a `//` or block comment starting at the current `/`.
|
|
1171
|
+
* @returns false when the `/` starts no comment
|
|
1172
|
+
*/
|
|
1173
|
+
skipComment() {
|
|
1174
|
+
const d = this.text.codePointAt(this.pos + 1);
|
|
1175
|
+
if (d === 47) {
|
|
1176
|
+
this.skipToLineEnd();
|
|
1177
|
+
return true;
|
|
1178
|
+
}
|
|
1179
|
+
if (d === 42) {
|
|
1180
|
+
this.skipBlockComment();
|
|
1181
|
+
return true;
|
|
1182
|
+
}
|
|
1183
|
+
return false;
|
|
1184
|
+
}
|
|
1145
1185
|
/**
|
|
1146
1186
|
* Discard a `#` line when one starts at the current position (the start of a line).
|
|
1147
1187
|
*/
|
|
@@ -2681,4 +2721,4 @@ export {
|
|
|
2681
2721
|
dotImporter as b,
|
|
2682
2722
|
dotExporter as d
|
|
2683
2723
|
};
|
|
2684
|
-
//# sourceMappingURL=importer-
|
|
2724
|
+
//# sourceMappingURL=importer-BbNb7eNg.js.map
|