quicktype 17.0.1 → 17.0.3
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/cli/CompressedJSONFromStream.js +26 -38
- package/dist/cli/GraphQLIntrospection.js +33 -41
- package/dist/cli/TypeSource.d.ts +1 -1
- package/dist/cli/URLGrammar.js +4 -3
- package/dist/cli/index.js +363 -364
- package/dist/quicktype-core/Annotation.js +2 -0
- package/dist/quicktype-core/ConvenienceRenderer.d.ts +17 -17
- package/dist/quicktype-core/ConvenienceRenderer.js +104 -81
- package/dist/quicktype-core/DateTime.js +1 -0
- package/dist/quicktype-core/DeclarationIR.d.ts +1 -1
- package/dist/quicktype-core/DeclarationIR.js +13 -10
- package/dist/quicktype-core/EncodedMarkovChain.js +1 -0
- package/dist/quicktype-core/GatherNames.js +47 -25
- package/dist/quicktype-core/Graph.d.ts +2 -2
- package/dist/quicktype-core/Graph.js +23 -19
- package/dist/quicktype-core/GraphRewriting.d.ts +2 -2
- package/dist/quicktype-core/GraphRewriting.js +65 -54
- package/dist/quicktype-core/MakeTransformations.js +23 -22
- package/dist/quicktype-core/MarkovChain.d.ts +3 -3
- package/dist/quicktype-core/MarkovChain.js +9 -8
- package/dist/quicktype-core/Messages.d.ts +3 -3
- package/dist/quicktype-core/Messages.js +8 -3
- package/dist/quicktype-core/Naming.d.ts +11 -11
- package/dist/quicktype-core/Naming.js +76 -61
- package/dist/quicktype-core/Renderer.d.ts +6 -6
- package/dist/quicktype-core/Renderer.js +34 -17
- package/dist/quicktype-core/RendererOptions.d.ts +5 -5
- package/dist/quicktype-core/RendererOptions.js +6 -3
- package/dist/quicktype-core/Run.d.ts +9 -9
- package/dist/quicktype-core/Run.js +72 -67
- package/dist/quicktype-core/Source.d.ts +3 -3
- package/dist/quicktype-core/Source.js +19 -18
- package/dist/quicktype-core/TargetLanguage.d.ts +10 -10
- package/dist/quicktype-core/TargetLanguage.js +6 -2
- package/dist/quicktype-core/Transformers.d.ts +25 -25
- package/dist/quicktype-core/Transformers.js +94 -66
- package/dist/quicktype-core/Type.d.ts +41 -43
- package/dist/quicktype-core/Type.js +96 -71
- package/dist/quicktype-core/TypeBuilder.d.ts +2 -2
- package/dist/quicktype-core/TypeBuilder.js +53 -47
- package/dist/quicktype-core/TypeGraph.d.ts +4 -4
- package/dist/quicktype-core/TypeGraph.js +49 -40
- package/dist/quicktype-core/TypeUtils.d.ts +2 -2
- package/dist/quicktype-core/TypeUtils.js +23 -22
- package/dist/quicktype-core/UnifyClasses.js +16 -12
- package/dist/quicktype-core/UnionBuilder.d.ts +3 -3
- package/dist/quicktype-core/UnionBuilder.js +33 -30
- package/dist/quicktype-core/attributes/AccessorNames.d.ts +2 -2
- package/dist/quicktype-core/attributes/AccessorNames.js +18 -17
- package/dist/quicktype-core/attributes/Constraints.d.ts +3 -3
- package/dist/quicktype-core/attributes/Constraints.js +8 -4
- package/dist/quicktype-core/attributes/Description.js +6 -5
- package/dist/quicktype-core/attributes/EnumValues.js +4 -3
- package/dist/quicktype-core/attributes/StringTypes.d.ts +1 -1
- package/dist/quicktype-core/attributes/StringTypes.js +24 -21
- package/dist/quicktype-core/attributes/TypeAttributes.d.ts +3 -3
- package/dist/quicktype-core/attributes/TypeAttributes.js +12 -10
- package/dist/quicktype-core/attributes/TypeNames.d.ts +9 -9
- package/dist/quicktype-core/attributes/TypeNames.js +49 -21
- package/dist/quicktype-core/attributes/URIAttributes.d.ts +1 -1
- package/dist/quicktype-core/attributes/URIAttributes.js +10 -6
- package/dist/quicktype-core/index.js +128 -125
- package/dist/quicktype-core/input/CompressedJSON.d.ts +7 -7
- package/dist/quicktype-core/input/CompressedJSON.js +49 -54
- package/dist/quicktype-core/input/FetchingJSONSchemaStore.js +5 -13
- package/dist/quicktype-core/input/Inference.d.ts +2 -2
- package/dist/quicktype-core/input/Inference.js +25 -17
- package/dist/quicktype-core/input/Inputs.d.ts +2 -2
- package/dist/quicktype-core/input/Inputs.js +38 -54
- package/dist/quicktype-core/input/JSONSchemaInput.d.ts +11 -11
- package/dist/quicktype-core/input/JSONSchemaInput.js +503 -523
- package/dist/quicktype-core/input/JSONSchemaStore.d.ts +1 -1
- package/dist/quicktype-core/input/JSONSchemaStore.js +24 -35
- package/dist/quicktype-core/input/PostmanCollection.js +2 -1
- package/dist/quicktype-core/input/io/NodeIO.js +55 -44
- package/dist/quicktype-core/input/io/get-stream/index.js +6 -2
- package/dist/quicktype-core/language/All.js +3 -2
- package/dist/quicktype-core/language/CPlusPlus.d.ts +8 -8
- package/dist/quicktype-core/language/CPlusPlus.js +185 -151
- package/dist/quicktype-core/language/CSharp.d.ts +7 -7
- package/dist/quicktype-core/language/CSharp.js +82 -72
- package/dist/quicktype-core/language/Crystal.d.ts +2 -2
- package/dist/quicktype-core/language/Crystal.js +18 -17
- package/dist/quicktype-core/language/Dart.d.ts +4 -4
- package/dist/quicktype-core/language/Dart.js +36 -34
- package/dist/quicktype-core/language/Elm.d.ts +6 -6
- package/dist/quicktype-core/language/Elm.js +47 -45
- package/dist/quicktype-core/language/Golang.d.ts +4 -4
- package/dist/quicktype-core/language/Golang.js +23 -20
- package/dist/quicktype-core/language/Haskell.d.ts +5 -5
- package/dist/quicktype-core/language/Haskell.js +25 -23
- package/dist/quicktype-core/language/JSONSchema.d.ts +3 -3
- package/dist/quicktype-core/language/JSONSchema.js +17 -16
- package/dist/quicktype-core/language/Java.d.ts +2 -2
- package/dist/quicktype-core/language/Java.js +97 -97
- package/dist/quicktype-core/language/JavaScript.d.ts +7 -7
- package/dist/quicktype-core/language/JavaScript.js +19 -17
- package/dist/quicktype-core/language/JavaScriptPropTypes.js +15 -13
- package/dist/quicktype-core/language/JavaScriptUnicodeMaps.js +12 -11
- package/dist/quicktype-core/language/Kotlin.d.ts +2 -2
- package/dist/quicktype-core/language/Kotlin.js +39 -37
- package/dist/quicktype-core/language/Objective-C.d.ts +3 -3
- package/dist/quicktype-core/language/Objective-C.js +45 -41
- package/dist/quicktype-core/language/Php.d.ts +2 -2
- package/dist/quicktype-core/language/Php.js +66 -41
- package/dist/quicktype-core/language/Pike.d.ts +1 -1
- package/dist/quicktype-core/language/Pike.js +18 -17
- package/dist/quicktype-core/language/Python.d.ts +8 -8
- package/dist/quicktype-core/language/Python.js +63 -64
- package/dist/quicktype-core/language/Rust.d.ts +2 -2
- package/dist/quicktype-core/language/Rust.js +21 -19
- package/dist/quicktype-core/language/Swift.d.ts +7 -7
- package/dist/quicktype-core/language/Swift.js +568 -565
- package/dist/quicktype-core/language/TypeScriptFlow.d.ts +7 -7
- package/dist/quicktype-core/language/TypeScriptFlow.js +28 -26
- package/dist/quicktype-core/language/ruby/index.d.ts +4 -4
- package/dist/quicktype-core/language/ruby/index.js +49 -24
- package/dist/quicktype-core/language/ruby/keywords.js +1 -0
- package/dist/quicktype-core/rewrites/CombineClasses.js +9 -8
- package/dist/quicktype-core/rewrites/ExpandStrings.d.ts +1 -1
- package/dist/quicktype-core/rewrites/ExpandStrings.js +18 -17
- package/dist/quicktype-core/rewrites/FlattenStrings.js +7 -6
- package/dist/quicktype-core/rewrites/FlattenUnions.js +9 -8
- package/dist/quicktype-core/rewrites/InferMaps.js +11 -10
- package/dist/quicktype-core/rewrites/ReplaceObjectType.js +8 -7
- package/dist/quicktype-core/rewrites/ResolveIntersections.js +68 -67
- package/dist/quicktype-core/support/Acronyms.js +3 -1
- package/dist/quicktype-core/support/Chance.js +10 -0
- package/dist/quicktype-core/support/Converters.js +1 -0
- package/dist/quicktype-core/support/Strings.d.ts +4 -4
- package/dist/quicktype-core/support/Strings.js +17 -16
- package/dist/quicktype-core/support/Support.d.ts +1 -1
- package/dist/quicktype-core/support/Support.js +30 -6
- package/dist/quicktype-graphql-input/GraphQLSchema.d.ts +4 -4
- package/dist/quicktype-graphql-input/GraphQLSchema.js +1 -0
- package/dist/quicktype-graphql-input/index.d.ts +1 -1
- package/dist/quicktype-graphql-input/index.js +229 -212
- package/dist/quicktype-typescript-input/index.js +30 -5
- package/package.json +25 -19
|
@@ -1,6 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
26
|
+
exports.gatherNames = void 0;
|
|
27
|
+
const pluralize = __importStar(require("pluralize"));
|
|
4
28
|
const collection_utils_1 = require("collection-utils");
|
|
5
29
|
const Type_1 = require("./Type");
|
|
6
30
|
const TypeUtils_1 = require("./TypeUtils");
|
|
@@ -8,11 +32,9 @@ const TypeNames_1 = require("./attributes/TypeNames");
|
|
|
8
32
|
const Support_1 = require("./support/Support");
|
|
9
33
|
const Transformers_1 = require("./Transformers");
|
|
10
34
|
class UniqueQueue {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
this._front = 0;
|
|
15
|
-
}
|
|
35
|
+
_present = new Set();
|
|
36
|
+
_queue = [];
|
|
37
|
+
_front = 0;
|
|
16
38
|
get size() {
|
|
17
39
|
return this._queue.length - this._front;
|
|
18
40
|
}
|
|
@@ -26,10 +48,10 @@ class UniqueQueue {
|
|
|
26
48
|
this._present.add(v);
|
|
27
49
|
}
|
|
28
50
|
unshift() {
|
|
29
|
-
Support_1.assert(!this.isEmpty, "Trying to unshift from an empty queue");
|
|
51
|
+
(0, Support_1.assert)(!this.isEmpty, "Trying to unshift from an empty queue");
|
|
30
52
|
const v = this._queue[this._front];
|
|
31
53
|
if (v === undefined) {
|
|
32
|
-
return Support_1.panic("Value should have been present in queue");
|
|
54
|
+
return (0, Support_1.panic)("Value should have been present in queue");
|
|
33
55
|
}
|
|
34
56
|
this._queue[this._front] = undefined;
|
|
35
57
|
this._front += 1;
|
|
@@ -109,13 +131,13 @@ function gatherNames(graph, destructive, debugPrint) {
|
|
|
109
131
|
newNames = null;
|
|
110
132
|
}
|
|
111
133
|
else {
|
|
112
|
-
newNames = collection_utils_1.setUnion(oldNames, names);
|
|
134
|
+
newNames = (0, collection_utils_1.setUnion)(oldNames, names);
|
|
113
135
|
}
|
|
114
136
|
if (newNames !== null && newNames.size >= TypeNames_1.tooManyNamesThreshold) {
|
|
115
137
|
newNames = null;
|
|
116
138
|
}
|
|
117
139
|
namesForType.set(t, newNames);
|
|
118
|
-
const transformation = Transformers_1.transformationForType(t);
|
|
140
|
+
const transformation = (0, Transformers_1.transformationForType)(t);
|
|
119
141
|
if (transformation !== undefined) {
|
|
120
142
|
addNames(transformation.targetType, names);
|
|
121
143
|
}
|
|
@@ -134,7 +156,7 @@ function gatherNames(graph, destructive, debugPrint) {
|
|
|
134
156
|
}
|
|
135
157
|
while (!queue.isEmpty) {
|
|
136
158
|
const t = queue.unshift();
|
|
137
|
-
const names = Support_1.defined(namesForType.get(t));
|
|
159
|
+
const names = (0, Support_1.defined)(namesForType.get(t));
|
|
138
160
|
if (t instanceof Type_1.ObjectType) {
|
|
139
161
|
const properties = t.getSortedProperties();
|
|
140
162
|
for (const [propertyName, property] of properties) {
|
|
@@ -142,14 +164,14 @@ function gatherNames(graph, destructive, debugPrint) {
|
|
|
142
164
|
}
|
|
143
165
|
const values = t.getAdditionalProperties();
|
|
144
166
|
if (values !== undefined) {
|
|
145
|
-
addNames(values, names === null ? null : collection_utils_1.setMap(names, pluralize.singular));
|
|
167
|
+
addNames(values, names === null ? null : (0, collection_utils_1.setMap)(names, pluralize.singular));
|
|
146
168
|
}
|
|
147
169
|
}
|
|
148
170
|
else {
|
|
149
|
-
TypeUtils_1.matchCompoundType(t, arrayType => {
|
|
150
|
-
addNames(arrayType.items, names === null ? null : collection_utils_1.setMap(names, pluralize.singular));
|
|
151
|
-
}, _classType => Support_1.panic("We handled this above"), _mapType => Support_1.panic("We handled this above"), _objectType => Support_1.panic("We handled this above"), unionType => {
|
|
152
|
-
const members = collection_utils_1.setSortBy(unionType.members, member => member.kind);
|
|
171
|
+
(0, TypeUtils_1.matchCompoundType)(t, arrayType => {
|
|
172
|
+
addNames(arrayType.items, names === null ? null : (0, collection_utils_1.setMap)(names, pluralize.singular));
|
|
173
|
+
}, _classType => (0, Support_1.panic)("We handled this above"), _mapType => (0, Support_1.panic)("We handled this above"), _objectType => (0, Support_1.panic)("We handled this above"), unionType => {
|
|
174
|
+
const members = (0, collection_utils_1.setSortBy)(unionType.members, member => member.kind);
|
|
153
175
|
for (const memberType of members) {
|
|
154
176
|
addNames(memberType, names);
|
|
155
177
|
}
|
|
@@ -176,14 +198,14 @@ function gatherNames(graph, destructive, debugPrint) {
|
|
|
176
198
|
if (existing === undefined) {
|
|
177
199
|
existing = new Set();
|
|
178
200
|
}
|
|
179
|
-
existing = collection_utils_1.setUnion(existing, alternatives);
|
|
201
|
+
existing = (0, collection_utils_1.setUnion)(existing, alternatives);
|
|
180
202
|
if (existing.size < TypeNames_1.tooManyNamesThreshold) {
|
|
181
203
|
return existing;
|
|
182
204
|
}
|
|
183
205
|
return null;
|
|
184
206
|
}
|
|
185
207
|
function processType(ancestor, t, alternativeSuffix) {
|
|
186
|
-
const names = Support_1.defined(namesForType.get(t));
|
|
208
|
+
const names = (0, Support_1.defined)(namesForType.get(t));
|
|
187
209
|
let processedEntry = pairsProcessed.get(ancestor);
|
|
188
210
|
if (processedEntry === undefined)
|
|
189
211
|
processedEntry = new Set();
|
|
@@ -191,7 +213,7 @@ function gatherNames(graph, destructive, debugPrint) {
|
|
|
191
213
|
return;
|
|
192
214
|
processedEntry.add(t);
|
|
193
215
|
pairsProcessed.set(ancestor, processedEntry);
|
|
194
|
-
const transformation = Transformers_1.transformationForType(t);
|
|
216
|
+
const transformation = (0, Transformers_1.transformationForType)(t);
|
|
195
217
|
if (transformation !== undefined) {
|
|
196
218
|
processType(ancestor, transformation.targetType, alternativeSuffix);
|
|
197
219
|
}
|
|
@@ -244,12 +266,12 @@ function gatherNames(graph, destructive, debugPrint) {
|
|
|
244
266
|
}
|
|
245
267
|
}
|
|
246
268
|
else {
|
|
247
|
-
TypeUtils_1.matchCompoundType(t, arrayType => {
|
|
269
|
+
(0, TypeUtils_1.matchCompoundType)(t, arrayType => {
|
|
248
270
|
processType(ancestor, arrayType.items, "element");
|
|
249
|
-
}, _classType => Support_1.panic("We handled this above"), _mapType => Support_1.panic("We handled this above"), _objectType => Support_1.panic("We handled this above"), unionType => {
|
|
250
|
-
const members = collection_utils_1.setSortBy(unionType.members, member => member.kind);
|
|
271
|
+
}, _classType => (0, Support_1.panic)("We handled this above"), _mapType => (0, Support_1.panic)("We handled this above"), _objectType => (0, Support_1.panic)("We handled this above"), unionType => {
|
|
272
|
+
const members = (0, collection_utils_1.setSortBy)(unionType.members, member => member.kind);
|
|
251
273
|
const unionHasGivenName = unionType.hasNames && !unionType.getNames().areInferred;
|
|
252
|
-
const unionIsAncestor = unionHasGivenName || TypeUtils_1.nullableFromUnion(unionType) === null;
|
|
274
|
+
const unionIsAncestor = unionHasGivenName || (0, TypeUtils_1.nullableFromUnion)(unionType) === null;
|
|
253
275
|
const ancestorForMembers = unionIsAncestor ? unionType : ancestor;
|
|
254
276
|
for (const memberType of members) {
|
|
255
277
|
processType(ancestorForMembers, memberType, undefined);
|
|
@@ -274,7 +296,7 @@ function gatherNames(graph, destructive, debugPrint) {
|
|
|
274
296
|
if (alternatives === undefined) {
|
|
275
297
|
alternatives = new Set();
|
|
276
298
|
}
|
|
277
|
-
alternatives = collection_utils_1.setUnion(alternatives, collection_utils_1.setMap(names, name => `${name}_${t.kind}`));
|
|
299
|
+
alternatives = (0, collection_utils_1.setUnion)(alternatives, (0, collection_utils_1.setMap)(names, name => `${name}_${t.kind}`));
|
|
278
300
|
directAlternativesForType.set(t, alternatives);
|
|
279
301
|
}
|
|
280
302
|
for (const t of graph.allTypesUnordered()) {
|
|
@@ -300,7 +322,7 @@ function gatherNames(graph, destructive, debugPrint) {
|
|
|
300
322
|
alternatives = new Set();
|
|
301
323
|
}
|
|
302
324
|
if (ancestorAlternatives !== null && ancestorAlternatives !== undefined) {
|
|
303
|
-
alternatives = collection_utils_1.setUnion(alternatives, ancestorAlternatives);
|
|
325
|
+
alternatives = (0, collection_utils_1.setUnion)(alternatives, ancestorAlternatives);
|
|
304
326
|
}
|
|
305
327
|
}
|
|
306
328
|
typeNames = TypeNames_1.TypeNames.makeWithDistance(names, alternatives, destructive ? 1 : 10);
|
|
@@ -3,8 +3,8 @@ export declare class Graph<T> {
|
|
|
3
3
|
private readonly _indexByNode;
|
|
4
4
|
private readonly _successors;
|
|
5
5
|
constructor(nodes: Iterable<T>, invertDirection: boolean, edges: number[][] | ((node: T) => ReadonlySet<T>));
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
get size(): number;
|
|
7
|
+
get nodes(): ReadonlyArray<T>;
|
|
8
8
|
findRoots(): ReadonlySet<T>;
|
|
9
9
|
dfsTraversal(root: T, preOrder: boolean, process: (node: T) => void): void;
|
|
10
10
|
stronglyConnectedComponents(): Graph<ReadonlySet<T>>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Graph = void 0;
|
|
3
4
|
const collection_utils_1 = require("collection-utils");
|
|
4
5
|
const Support_1 = require("./support/Support");
|
|
5
6
|
function countComponentGraphNodes(components) {
|
|
@@ -8,14 +9,14 @@ function countComponentGraphNodes(components) {
|
|
|
8
9
|
let largest = -1;
|
|
9
10
|
let count = 0;
|
|
10
11
|
for (const c of components) {
|
|
11
|
-
Support_1.assert(c.length > 0, "Empty component not allowed");
|
|
12
|
+
(0, Support_1.assert)(c.length > 0, "Empty component not allowed");
|
|
12
13
|
for (const v of c) {
|
|
13
|
-
Support_1.assert(v >= 0, "Negative vertex index is invalid");
|
|
14
|
+
(0, Support_1.assert)(v >= 0, "Negative vertex index is invalid");
|
|
14
15
|
largest = Math.max(largest, v);
|
|
15
16
|
count += 1;
|
|
16
17
|
}
|
|
17
18
|
}
|
|
18
|
-
Support_1.assert(largest + 1 === count, "Vertex indexes and count don't match up");
|
|
19
|
+
(0, Support_1.assert)(largest + 1 === count, "Vertex indexes and count don't match up");
|
|
19
20
|
return count;
|
|
20
21
|
}
|
|
21
22
|
// https://en.wikipedia.org/wiki/Tarjan%27s_strongly_connected_components_algorithm
|
|
@@ -23,9 +24,9 @@ function stronglyConnectedComponents(successors) {
|
|
|
23
24
|
let index = 0;
|
|
24
25
|
const stack = [];
|
|
25
26
|
const numNodes = successors.length;
|
|
26
|
-
const indexes = Support_1.repeated(numNodes, -1);
|
|
27
|
-
const lowLinks = Support_1.repeated(numNodes, -1);
|
|
28
|
-
const onStack = Support_1.repeated(numNodes, false);
|
|
27
|
+
const indexes = (0, Support_1.repeated)(numNodes, -1);
|
|
28
|
+
const lowLinks = (0, Support_1.repeated)(numNodes, -1);
|
|
29
|
+
const onStack = (0, Support_1.repeated)(numNodes, false);
|
|
29
30
|
const sccs = [];
|
|
30
31
|
function strongconnect(v) {
|
|
31
32
|
// Set the depth index for v to the smallest unused index
|
|
@@ -54,7 +55,7 @@ function stronglyConnectedComponents(successors) {
|
|
|
54
55
|
const scc = [];
|
|
55
56
|
let w;
|
|
56
57
|
do {
|
|
57
|
-
w = Support_1.defined(stack.pop());
|
|
58
|
+
w = (0, Support_1.defined)(stack.pop());
|
|
58
59
|
onStack[w] = false;
|
|
59
60
|
scc.push(w);
|
|
60
61
|
} while (w !== v);
|
|
@@ -66,17 +67,17 @@ function stronglyConnectedComponents(successors) {
|
|
|
66
67
|
strongconnect(v);
|
|
67
68
|
}
|
|
68
69
|
}
|
|
69
|
-
Support_1.assert(countComponentGraphNodes(sccs) === numNodes, "We didn't put all the nodes into SCCs");
|
|
70
|
+
(0, Support_1.assert)(countComponentGraphNodes(sccs) === numNodes, "We didn't put all the nodes into SCCs");
|
|
70
71
|
return sccs;
|
|
71
72
|
}
|
|
72
73
|
function buildComponentOfNodeMap(successors, components) {
|
|
73
74
|
const numComponents = components.length;
|
|
74
75
|
const numNodes = successors.length;
|
|
75
|
-
Support_1.assert(numNodes === countComponentGraphNodes(components), "Components don't match up with graph");
|
|
76
|
-
const componentOfNode = Support_1.repeated(numNodes, -1);
|
|
76
|
+
(0, Support_1.assert)(numNodes === countComponentGraphNodes(components), "Components don't match up with graph");
|
|
77
|
+
const componentOfNode = (0, Support_1.repeated)(numNodes, -1);
|
|
77
78
|
for (let c = 0; c < numComponents; c++) {
|
|
78
79
|
for (const n of components[c]) {
|
|
79
|
-
Support_1.assert(componentOfNode[n] < 0, "We have a node that's in two components");
|
|
80
|
+
(0, Support_1.assert)(componentOfNode[n] < 0, "We have a node that's in two components");
|
|
80
81
|
componentOfNode[n] = c;
|
|
81
82
|
}
|
|
82
83
|
}
|
|
@@ -85,7 +86,7 @@ function buildComponentOfNodeMap(successors, components) {
|
|
|
85
86
|
function buildMetaSuccessors(successors, components) {
|
|
86
87
|
const numComponents = components.length;
|
|
87
88
|
const componentOfNode = buildComponentOfNodeMap(successors, components);
|
|
88
|
-
const componentAdded = Support_1.repeated(numComponents, false);
|
|
89
|
+
const componentAdded = (0, Support_1.repeated)(numComponents, false);
|
|
89
90
|
const metaSuccessors = [];
|
|
90
91
|
for (let c = 0; c < numComponents; c++) {
|
|
91
92
|
const succ = [];
|
|
@@ -100,7 +101,7 @@ function buildMetaSuccessors(successors, components) {
|
|
|
100
101
|
}
|
|
101
102
|
// reset bookkeeping
|
|
102
103
|
for (const ms of succ) {
|
|
103
|
-
Support_1.assert(componentAdded[ms]);
|
|
104
|
+
(0, Support_1.assert)(componentAdded[ms]);
|
|
104
105
|
componentAdded[ms] = false;
|
|
105
106
|
}
|
|
106
107
|
metaSuccessors.push(succ);
|
|
@@ -109,7 +110,7 @@ function buildMetaSuccessors(successors, components) {
|
|
|
109
110
|
}
|
|
110
111
|
function invertEdges(successors) {
|
|
111
112
|
const numNodes = successors.length;
|
|
112
|
-
const predecessors = Support_1.repeatedCall(numNodes, () => []);
|
|
113
|
+
const predecessors = (0, Support_1.repeatedCall)(numNodes, () => []);
|
|
113
114
|
for (let s = 0; s < numNodes; s++) {
|
|
114
115
|
for (const v of successors[s]) {
|
|
115
116
|
predecessors[v].push(s);
|
|
@@ -119,7 +120,7 @@ function invertEdges(successors) {
|
|
|
119
120
|
}
|
|
120
121
|
function calculateInDegrees(successors) {
|
|
121
122
|
const numNodes = successors.length;
|
|
122
|
-
const inDegrees = Support_1.repeated(numNodes, 0);
|
|
123
|
+
const inDegrees = (0, Support_1.repeated)(numNodes, 0);
|
|
123
124
|
for (const s of successors) {
|
|
124
125
|
for (const v of s) {
|
|
125
126
|
inDegrees[v] += 1;
|
|
@@ -139,6 +140,9 @@ function findRoots(successors) {
|
|
|
139
140
|
return roots;
|
|
140
141
|
}
|
|
141
142
|
class Graph {
|
|
143
|
+
_nodes;
|
|
144
|
+
_indexByNode;
|
|
145
|
+
_successors;
|
|
142
146
|
constructor(nodes, invertDirection, edges) {
|
|
143
147
|
this._nodes = Array.from(nodes);
|
|
144
148
|
this._indexByNode = new Map(this._nodes.map((n, i) => [n, i]));
|
|
@@ -147,7 +151,7 @@ class Graph {
|
|
|
147
151
|
edgesArray = edges;
|
|
148
152
|
}
|
|
149
153
|
else {
|
|
150
|
-
edgesArray = this._nodes.map(n => Array.from(edges(n)).map(s => Support_1.defined(this._indexByNode.get(s))));
|
|
154
|
+
edgesArray = this._nodes.map(n => Array.from(edges(n)).map(s => (0, Support_1.defined)(this._indexByNode.get(s))));
|
|
151
155
|
}
|
|
152
156
|
if (invertDirection) {
|
|
153
157
|
edgesArray = invertEdges(edgesArray);
|
|
@@ -166,7 +170,7 @@ class Graph {
|
|
|
166
170
|
}
|
|
167
171
|
// The subgraph starting at `root` must be acyclic.
|
|
168
172
|
dfsTraversal(root, preOrder, process) {
|
|
169
|
-
const visited = Support_1.repeated(this.size, false);
|
|
173
|
+
const visited = (0, Support_1.repeated)(this.size, false);
|
|
170
174
|
const visit = (v) => {
|
|
171
175
|
if (visited[v])
|
|
172
176
|
return;
|
|
@@ -181,12 +185,12 @@ class Graph {
|
|
|
181
185
|
process(this._nodes[v]);
|
|
182
186
|
}
|
|
183
187
|
};
|
|
184
|
-
visit(Support_1.defined(this._indexByNode.get(root)));
|
|
188
|
+
visit((0, Support_1.defined)(this._indexByNode.get(root)));
|
|
185
189
|
}
|
|
186
190
|
stronglyConnectedComponents() {
|
|
187
191
|
const components = stronglyConnectedComponents(this._successors);
|
|
188
192
|
const componentSuccessors = buildMetaSuccessors(this._successors, components);
|
|
189
|
-
return new Graph(components.map(ns => collection_utils_1.setMap(ns, n => this._nodes[n])), false, componentSuccessors);
|
|
193
|
+
return new Graph(components.map(ns => (0, collection_utils_1.setMap)(ns, n => this._nodes[n])), false, componentSuccessors);
|
|
190
194
|
}
|
|
191
195
|
makeDot(includeNode, nodeLabel) {
|
|
192
196
|
const lines = [];
|
|
@@ -60,10 +60,10 @@ export declare abstract class BaseGraphRewriteBuilder extends TypeBuilder implem
|
|
|
60
60
|
reconstituteTypeAttributes(attributes: TypeAttributes): TypeAttributes;
|
|
61
61
|
protected assertTypeRefsToReconstitute(typeRefs: TypeRef[], forwardingRef?: TypeRef): void;
|
|
62
62
|
protected changeDebugPrintIndent(delta: number): void;
|
|
63
|
-
protected
|
|
63
|
+
protected get debugPrintIndentation(): string;
|
|
64
64
|
finish(): TypeGraph;
|
|
65
65
|
setLostTypeAttributes(): void;
|
|
66
|
-
|
|
66
|
+
get lostTypeAttributes(): boolean;
|
|
67
67
|
}
|
|
68
68
|
export declare class GraphRemapBuilder extends BaseGraphRewriteBuilder {
|
|
69
69
|
private readonly _map;
|