quicktype 18.0.6 → 19.0.5

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 (174) hide show
  1. package/README.md +1 -1
  2. package/dist/{cli/CompressedJSONFromStream.d.ts → CompressedJSONFromStream.d.ts} +1 -1
  3. package/dist/{cli/CompressedJSONFromStream.js → CompressedJSONFromStream.js} +2 -2
  4. package/dist/{cli/GraphQLIntrospection.d.ts → GraphQLIntrospection.d.ts} +0 -0
  5. package/dist/{cli/GraphQLIntrospection.js → GraphQLIntrospection.js} +1 -1
  6. package/dist/{cli/TypeSource.d.ts → TypeSource.d.ts} +2 -2
  7. package/dist/{cli/TypeSource.js → TypeSource.js} +0 -0
  8. package/dist/{cli/URLGrammar.d.ts → URLGrammar.d.ts} +0 -0
  9. package/dist/{cli/URLGrammar.js → URLGrammar.js} +1 -1
  10. package/dist/{cli/index.d.ts → index.d.ts} +2 -1
  11. package/dist/{cli/index.js → index.js} +4 -4
  12. package/package.json +61 -77
  13. package/dist/quicktype-core/Annotation.d.ts +0 -8
  14. package/dist/quicktype-core/Annotation.js +0 -16
  15. package/dist/quicktype-core/ConvenienceRenderer.d.ts +0 -138
  16. package/dist/quicktype-core/ConvenienceRenderer.js +0 -668
  17. package/dist/quicktype-core/DateTime.d.ts +0 -10
  18. package/dist/quicktype-core/DateTime.js +0 -57
  19. package/dist/quicktype-core/DeclarationIR.d.ts +0 -14
  20. package/dist/quicktype-core/DeclarationIR.js +0 -167
  21. package/dist/quicktype-core/EncodedMarkovChain.d.ts +0 -1
  22. package/dist/quicktype-core/EncodedMarkovChain.js +0 -4
  23. package/dist/quicktype-core/GatherNames.d.ts +0 -2
  24. package/dist/quicktype-core/GatherNames.js +0 -333
  25. package/dist/quicktype-core/Graph.d.ts +0 -12
  26. package/dist/quicktype-core/Graph.js +0 -220
  27. package/dist/quicktype-core/GraphRewriting.d.ts +0 -87
  28. package/dist/quicktype-core/GraphRewriting.js +0 -421
  29. package/dist/quicktype-core/MakeTransformations.d.ts +0 -4
  30. package/dist/quicktype-core/MakeTransformations.js +0 -193
  31. package/dist/quicktype-core/MarkovChain.d.ts +0 -15
  32. package/dist/quicktype-core/MarkovChain.js +0 -154
  33. package/dist/quicktype-core/Messages.d.ts +0 -294
  34. package/dist/quicktype-core/Messages.js +0 -105
  35. package/dist/quicktype-core/Naming.d.ts +0 -64
  36. package/dist/quicktype-core/Naming.js +0 -356
  37. package/dist/quicktype-core/Renderer.d.ts +0 -50
  38. package/dist/quicktype-core/Renderer.js +0 -274
  39. package/dist/quicktype-core/RendererOptions.d.ts +0 -71
  40. package/dist/quicktype-core/RendererOptions.js +0 -141
  41. package/dist/quicktype-core/Run.d.ts +0 -174
  42. package/dist/quicktype-core/Run.js +0 -393
  43. package/dist/quicktype-core/Source.d.ts +0 -65
  44. package/dist/quicktype-core/Source.js +0 -204
  45. package/dist/quicktype-core/TargetLanguage.d.ts +0 -34
  46. package/dist/quicktype-core/TargetLanguage.js +0 -66
  47. package/dist/quicktype-core/Transformers.d.ts +0 -209
  48. package/dist/quicktype-core/Transformers.js +0 -836
  49. package/dist/quicktype-core/Type.d.ts +0 -206
  50. package/dist/quicktype-core/Type.js +0 -716
  51. package/dist/quicktype-core/TypeBuilder.d.ts +0 -61
  52. package/dist/quicktype-core/TypeBuilder.js +0 -324
  53. package/dist/quicktype-core/TypeGraph.d.ts +0 -75
  54. package/dist/quicktype-core/TypeGraph.js +0 -420
  55. package/dist/quicktype-core/TypeUtils.d.ts +0 -33
  56. package/dist/quicktype-core/TypeUtils.js +0 -230
  57. package/dist/quicktype-core/UnifyClasses.d.ts +0 -16
  58. package/dist/quicktype-core/UnifyClasses.js +0 -159
  59. package/dist/quicktype-core/UnionBuilder.d.ts +0 -49
  60. package/dist/quicktype-core/UnionBuilder.js +0 -282
  61. package/dist/quicktype-core/attributes/AccessorNames.d.ts +0 -18
  62. package/dist/quicktype-core/attributes/AccessorNames.js +0 -182
  63. package/dist/quicktype-core/attributes/Constraints.d.ts +0 -38
  64. package/dist/quicktype-core/attributes/Constraints.js +0 -172
  65. package/dist/quicktype-core/attributes/Description.d.ts +0 -9
  66. package/dist/quicktype-core/attributes/Description.js +0 -97
  67. package/dist/quicktype-core/attributes/EnumValues.d.ts +0 -8
  68. package/dist/quicktype-core/attributes/EnumValues.js +0 -31
  69. package/dist/quicktype-core/attributes/StringTypes.d.ts +0 -28
  70. package/dist/quicktype-core/attributes/StringTypes.js +0 -189
  71. package/dist/quicktype-core/attributes/TypeAttributes.d.ts +0 -34
  72. package/dist/quicktype-core/attributes/TypeAttributes.js +0 -119
  73. package/dist/quicktype-core/attributes/TypeNames.d.ts +0 -46
  74. package/dist/quicktype-core/attributes/TypeNames.js +0 -274
  75. package/dist/quicktype-core/attributes/URIAttributes.d.ts +0 -8
  76. package/dist/quicktype-core/attributes/URIAttributes.js +0 -85
  77. package/dist/quicktype-core/index.d.ts +0 -48
  78. package/dist/quicktype-core/index.js +0 -180
  79. package/dist/quicktype-core/input/CompressedJSON.d.ts +0 -69
  80. package/dist/quicktype-core/input/CompressedJSON.js +0 -276
  81. package/dist/quicktype-core/input/FetchingJSONSchemaStore.d.ts +0 -6
  82. package/dist/quicktype-core/input/FetchingJSONSchemaStore.js +0 -18
  83. package/dist/quicktype-core/input/Inference.d.ts +0 -22
  84. package/dist/quicktype-core/input/Inference.js +0 -240
  85. package/dist/quicktype-core/input/Inputs.d.ts +0 -48
  86. package/dist/quicktype-core/input/Inputs.js +0 -145
  87. package/dist/quicktype-core/input/JSONSchemaInput.d.ts +0 -91
  88. package/dist/quicktype-core/input/JSONSchemaInput.js +0 -1041
  89. package/dist/quicktype-core/input/JSONSchemaStore.d.ts +0 -8
  90. package/dist/quicktype-core/input/JSONSchemaStore.js +0 -36
  91. package/dist/quicktype-core/input/PostmanCollection.d.ts +0 -5
  92. package/dist/quicktype-core/input/PostmanCollection.js +0 -60
  93. package/dist/quicktype-core/input/io/NodeIO.d.ts +0 -3
  94. package/dist/quicktype-core/input/io/NodeIO.js +0 -87
  95. package/dist/quicktype-core/input/io/get-stream/buffer-stream.d.ts +0 -2
  96. package/dist/quicktype-core/input/io/get-stream/buffer-stream.js +0 -45
  97. package/dist/quicktype-core/input/io/get-stream/index.d.ts +0 -9
  98. package/dist/quicktype-core/input/io/get-stream/index.js +0 -52
  99. package/dist/quicktype-core/language/All.d.ts +0 -3
  100. package/dist/quicktype-core/language/All.js +0 -57
  101. package/dist/quicktype-core/language/CPlusPlus.d.ts +0 -241
  102. package/dist/quicktype-core/language/CPlusPlus.js +0 -1847
  103. package/dist/quicktype-core/language/CSharp.d.ts +0 -201
  104. package/dist/quicktype-core/language/CSharp.js +0 -1850
  105. package/dist/quicktype-core/language/Crystal.d.ts +0 -37
  106. package/dist/quicktype-core/language/Crystal.js +0 -337
  107. package/dist/quicktype-core/language/Dart.d.ts +0 -66
  108. package/dist/quicktype-core/language/Dart.js +0 -576
  109. package/dist/quicktype-core/language/Elm.d.ts +0 -58
  110. package/dist/quicktype-core/language/Elm.js +0 -522
  111. package/dist/quicktype-core/language/Golang.d.ts +0 -51
  112. package/dist/quicktype-core/language/Golang.js +0 -460
  113. package/dist/quicktype-core/language/Haskell.d.ts +0 -56
  114. package/dist/quicktype-core/language/Haskell.js +0 -411
  115. package/dist/quicktype-core/language/JSONSchema.d.ts +0 -31
  116. package/dist/quicktype-core/language/JSONSchema.js +0 -169
  117. package/dist/quicktype-core/language/Java.d.ts +0 -125
  118. package/dist/quicktype-core/language/Java.js +0 -1081
  119. package/dist/quicktype-core/language/JavaScript.d.ts +0 -68
  120. package/dist/quicktype-core/language/JavaScript.js +0 -435
  121. package/dist/quicktype-core/language/JavaScriptPropTypes.d.ts +0 -40
  122. package/dist/quicktype-core/language/JavaScriptPropTypes.js +0 -213
  123. package/dist/quicktype-core/language/JavaScriptUnicodeMaps.d.ts +0 -2
  124. package/dist/quicktype-core/language/JavaScriptUnicodeMaps.js +0 -134
  125. package/dist/quicktype-core/language/Kotlin.d.ts +0 -109
  126. package/dist/quicktype-core/language/Kotlin.js +0 -832
  127. package/dist/quicktype-core/language/Objective-C.d.ts +0 -79
  128. package/dist/quicktype-core/language/Objective-C.js +0 -777
  129. package/dist/quicktype-core/language/Php.d.ts +0 -80
  130. package/dist/quicktype-core/language/Php.js +0 -702
  131. package/dist/quicktype-core/language/Pike.d.ts +0 -37
  132. package/dist/quicktype-core/language/Pike.js +0 -276
  133. package/dist/quicktype-core/language/Python.d.ts +0 -107
  134. package/dist/quicktype-core/language/Python.js +0 -969
  135. package/dist/quicktype-core/language/Rust.d.ts +0 -56
  136. package/dist/quicktype-core/language/Rust.js +0 -309
  137. package/dist/quicktype-core/language/Swift.d.ts +0 -96
  138. package/dist/quicktype-core/language/Swift.js +0 -1211
  139. package/dist/quicktype-core/language/TypeScriptFlow.d.ts +0 -77
  140. package/dist/quicktype-core/language/TypeScriptFlow.js +0 -286
  141. package/dist/quicktype-core/language/ruby/index.d.ts +0 -52
  142. package/dist/quicktype-core/language/ruby/index.js +0 -557
  143. package/dist/quicktype-core/language/ruby/keywords.d.ts +0 -3
  144. package/dist/quicktype-core/language/ruby/keywords.js +0 -358
  145. package/dist/quicktype-core/rewrites/CombineClasses.d.ts +0 -3
  146. package/dist/quicktype-core/rewrites/CombineClasses.js +0 -125
  147. package/dist/quicktype-core/rewrites/ExpandStrings.d.ts +0 -4
  148. package/dist/quicktype-core/rewrites/ExpandStrings.js +0 -143
  149. package/dist/quicktype-core/rewrites/FlattenStrings.d.ts +0 -3
  150. package/dist/quicktype-core/rewrites/FlattenStrings.js +0 -45
  151. package/dist/quicktype-core/rewrites/FlattenUnions.d.ts +0 -3
  152. package/dist/quicktype-core/rewrites/FlattenUnions.js +0 -47
  153. package/dist/quicktype-core/rewrites/InferMaps.d.ts +0 -3
  154. package/dist/quicktype-core/rewrites/InferMaps.js +0 -117
  155. package/dist/quicktype-core/rewrites/ReplaceObjectType.d.ts +0 -3
  156. package/dist/quicktype-core/rewrites/ReplaceObjectType.js +0 -60
  157. package/dist/quicktype-core/rewrites/ResolveIntersections.d.ts +0 -3
  158. package/dist/quicktype-core/rewrites/ResolveIntersections.js +0 -244
  159. package/dist/quicktype-core/support/Acronyms.d.ts +0 -10
  160. package/dist/quicktype-core/support/Acronyms.js +0 -1128
  161. package/dist/quicktype-core/support/Chance.d.ts +0 -38
  162. package/dist/quicktype-core/support/Chance.js +0 -2146
  163. package/dist/quicktype-core/support/Converters.d.ts +0 -6
  164. package/dist/quicktype-core/support/Converters.js +0 -16
  165. package/dist/quicktype-core/support/Strings.d.ts +0 -44
  166. package/dist/quicktype-core/support/Strings.js +0 -525
  167. package/dist/quicktype-core/support/Support.d.ts +0 -29
  168. package/dist/quicktype-core/support/Support.js +0 -162
  169. package/dist/quicktype-graphql-input/GraphQLSchema.d.ts +0 -645
  170. package/dist/quicktype-graphql-input/GraphQLSchema.js +0 -39
  171. package/dist/quicktype-graphql-input/index.d.ts +0 -17
  172. package/dist/quicktype-graphql-input/index.js +0 -407
  173. package/dist/quicktype-typescript-input/index.d.ts +0 -2
  174. package/dist/quicktype-typescript-input/index.js +0 -98
@@ -1,6 +0,0 @@
1
- import { EnumOption } from "../RendererOptions";
2
- export declare enum ConvertersOptions {
3
- TopLevel = "top-level",
4
- AllObjects = "all-objects"
5
- }
6
- export declare function convertersOption(): EnumOption<ConvertersOptions>;
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.convertersOption = exports.ConvertersOptions = void 0;
4
- const RendererOptions_1 = require("../RendererOptions");
5
- var ConvertersOptions;
6
- (function (ConvertersOptions) {
7
- ConvertersOptions["TopLevel"] = "top-level";
8
- ConvertersOptions["AllObjects"] = "all-objects";
9
- })(ConvertersOptions = exports.ConvertersOptions || (exports.ConvertersOptions = {}));
10
- function convertersOption() {
11
- return new RendererOptions_1.EnumOption("converters", "Which converters to generate (top-level by default)", [
12
- [ConvertersOptions.TopLevel, ConvertersOptions.TopLevel],
13
- [ConvertersOptions.AllObjects, ConvertersOptions.AllObjects]
14
- ], ConvertersOptions.TopLevel, "secondary");
15
- }
16
- exports.convertersOption = convertersOption;
@@ -1,44 +0,0 @@
1
- export type NamingStyle = "pascal" | "camel" | "underscore" | "upper-underscore" | "pascal-upper-acronyms" | "camel-upper-acronyms";
2
- type CodePointPredicate = (codePoint: number) => boolean;
3
- export declare function utf16ConcatMap(mapper: (utf16Unit: number) => string): (s: string) => string;
4
- export declare function utf32ConcatMap(mapper: (codePoint: number) => string): (s: string) => string;
5
- export declare function utf16LegalizeCharacters(isLegal: (utf16Unit: number) => boolean): (s: string) => string;
6
- export declare function legalizeCharacters(isLegal: (codePoint: number) => boolean): (s: string) => string;
7
- export declare function repeatString(s: string, n: number): string;
8
- export declare function intToHex(i: number, width: number): string;
9
- export declare function standardUnicodeHexEscape(codePoint: number): string;
10
- export declare function escapeNonPrintableMapper(printablePredicate: (codePoint: number) => boolean, escaper: (codePoint: number) => string): (u: number) => string;
11
- export declare const utf16StringEscape: (s: string) => string;
12
- export declare const stringEscape: (s: string) => string;
13
- export declare function isPrintable(codePoint: number): boolean;
14
- export declare function isAscii(codePoint: number): boolean;
15
- export declare function isLetter(codePoint: number): boolean;
16
- export declare function isDigit(codePoint: number): boolean;
17
- export declare function isNumeric(codePoint: number): boolean;
18
- export declare function isLetterOrDigit(codePoint: number): boolean;
19
- export declare function isLetterOrUnderscore(codePoint: number): boolean;
20
- export declare function isLetterOrUnderscoreOrDigit(codePoint: number): boolean;
21
- export declare function isWordCharacter(codePoint: number): boolean;
22
- export declare function trimEnd(str: string): string;
23
- export declare function capitalize(str: string): string;
24
- export declare function decapitalize(str: string): string;
25
- export declare function pascalCase(str: string): string;
26
- export declare function camelCase(str: string): string;
27
- export declare function snakeCase(str: string): string;
28
- export declare function startWithLetter(isAllowedStart: (codePoint: number) => boolean, // FIXME: technically, this operates on UTF16 units
29
- upper: boolean, str: string): string;
30
- export type WordInName = {
31
- word: string;
32
- isAcronym: boolean;
33
- };
34
- export declare const fastIsUpperCase: CodePointPredicate;
35
- export declare function splitIntoWords(s: string): WordInName[];
36
- export type WordStyle = (word: string) => string;
37
- export declare function firstUpperWordStyle(s: string): string;
38
- export declare function allUpperWordStyle(s: string): string;
39
- export declare function originalWord(s: string): string;
40
- export declare function allLowerWordStyle(s: string): string;
41
- export declare function combineWords(words: WordInName[], removeInvalidCharacters: (s: string) => string, firstWordStyle: WordStyle, restWordStyle: WordStyle, firstWordAcronymStyle: WordStyle, restAcronymStyle: WordStyle, separator: string, isStartCharacter: (codePoint: number) => boolean): string;
42
- export declare function addPrefixIfNecessary(prefix: string, name: string): string;
43
- export declare function makeNameStyle(namingStyle: NamingStyle, legalizeName: (name: string) => string, prefix?: string): (rawName: string) => string;
44
- export {};
@@ -1,525 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.makeNameStyle = exports.addPrefixIfNecessary = exports.combineWords = exports.allLowerWordStyle = exports.originalWord = exports.allUpperWordStyle = exports.firstUpperWordStyle = exports.splitIntoWords = exports.fastIsUpperCase = exports.startWithLetter = exports.snakeCase = exports.camelCase = exports.pascalCase = exports.decapitalize = exports.capitalize = exports.trimEnd = exports.isWordCharacter = exports.isLetterOrUnderscoreOrDigit = exports.isLetterOrUnderscore = exports.isLetterOrDigit = exports.isNumeric = exports.isDigit = exports.isLetter = exports.isAscii = exports.isPrintable = exports.stringEscape = exports.utf16StringEscape = exports.escapeNonPrintableMapper = exports.standardUnicodeHexEscape = exports.intToHex = exports.repeatString = exports.legalizeCharacters = exports.utf16LegalizeCharacters = exports.utf32ConcatMap = exports.utf16ConcatMap = void 0;
4
- const Support_1 = require("./Support");
5
- const Acronyms_1 = require("./Acronyms");
6
- const Messages_1 = require("../Messages");
7
- const unicode = require("unicode-properties");
8
- function computeAsciiMap(mapper) {
9
- const charStringMap = [];
10
- const charNoEscapeMap = [];
11
- for (let i = 0; i < 128; i++) {
12
- let noEscape = 0;
13
- const result = mapper(i);
14
- if (result === String.fromCharCode(i)) {
15
- noEscape = 1;
16
- }
17
- charStringMap.push(result);
18
- charNoEscapeMap.push(noEscape);
19
- }
20
- return { charStringMap, charNoEscapeMap };
21
- }
22
- function precomputedCodePointPredicate(p) {
23
- const asciiResults = [];
24
- for (let cp = 0; cp < 128; cp++) {
25
- asciiResults.push(p(cp));
26
- }
27
- return function (cp) {
28
- return cp < 128 ? asciiResults[cp] : p(cp);
29
- };
30
- }
31
- // FIXME: This is a copy of code in src/Data/String/Util.js
32
- function utf16ConcatMap(mapper) {
33
- const { charStringMap, charNoEscapeMap } = computeAsciiMap(mapper);
34
- return function stringConcatMap_inner(s) {
35
- let cs = null;
36
- let start = 0;
37
- let i = 0;
38
- while (i < s.length) {
39
- const cc = s.charCodeAt(i);
40
- if (charNoEscapeMap[cc] !== 1) {
41
- if (cs === null)
42
- cs = [];
43
- cs.push(s.substring(start, i));
44
- const str = charStringMap[cc];
45
- if (str === undefined) {
46
- cs.push(mapper(s.charCodeAt(i)));
47
- }
48
- else {
49
- cs.push(str);
50
- }
51
- start = i + 1;
52
- }
53
- i++;
54
- }
55
- if (cs === null)
56
- return s;
57
- cs.push(s.substring(start, i));
58
- return cs.join("");
59
- };
60
- }
61
- exports.utf16ConcatMap = utf16ConcatMap;
62
- function isHighSurrogate(cc) {
63
- return cc >= 0xd800 && cc <= 0xdbff;
64
- }
65
- function isLowSurrogate(cc) {
66
- return cc >= 0xdc00 && cc <= 0xdfff;
67
- }
68
- function utf32ConcatMap(mapper) {
69
- const { charStringMap, charNoEscapeMap } = computeAsciiMap(mapper);
70
- return function stringConcatMap_inner(s) {
71
- let cs = null;
72
- let start = 0;
73
- let i = 0;
74
- while (i < s.length) {
75
- let cc = s.charCodeAt(i);
76
- if (charNoEscapeMap[cc] !== 1) {
77
- if (cs === null)
78
- cs = [];
79
- cs.push(s.substring(start, i));
80
- if (isHighSurrogate(cc)) {
81
- const highSurrogate = cc;
82
- i++;
83
- const lowSurrogate = s.charCodeAt(i);
84
- (0, Messages_1.messageAssert)(isLowSurrogate(lowSurrogate), "MiscUnicodeHighSurrogateWithoutLowSurrogate", {});
85
- const highBits = highSurrogate - 0xd800;
86
- const lowBits = lowSurrogate - 0xdc00;
87
- cc = 0x10000 + lowBits + (highBits << 10);
88
- }
89
- const str = charStringMap[cc];
90
- if (str === undefined) {
91
- cs.push(mapper(cc));
92
- }
93
- else {
94
- cs.push(str);
95
- }
96
- start = i + 1;
97
- }
98
- i++;
99
- }
100
- if (cs === null)
101
- return s;
102
- cs.push(s.substring(start, i));
103
- return cs.join("");
104
- };
105
- }
106
- exports.utf32ConcatMap = utf32ConcatMap;
107
- function utf16LegalizeCharacters(isLegal) {
108
- return utf16ConcatMap(u => (isLegal(u) ? String.fromCharCode(u) : ""));
109
- }
110
- exports.utf16LegalizeCharacters = utf16LegalizeCharacters;
111
- function legalizeCharacters(isLegal) {
112
- return utf32ConcatMap(u => (u <= 0xffff && isLegal(u) ? String.fromCharCode(u) : ""));
113
- }
114
- exports.legalizeCharacters = legalizeCharacters;
115
- function repeatString(s, n) {
116
- (0, Support_1.assert)(n >= 0, "Cannot repeat a string a negative number of times");
117
- if (n === 0)
118
- return "";
119
- // From https://github.com/lodash/lodash
120
- // Leverage the exponentiation by squaring algorithm for a faster repeat.
121
- // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
122
- let result = "";
123
- do {
124
- if (n % 2 !== 0) {
125
- result += s;
126
- }
127
- n = Math.floor(n / 2);
128
- if (n > 0) {
129
- s += s;
130
- }
131
- } while (n > 0);
132
- return result;
133
- }
134
- exports.repeatString = repeatString;
135
- function intToHex(i, width) {
136
- let str = i.toString(16);
137
- if (str.length >= width)
138
- return str;
139
- return repeatString("0", width - str.length) + str;
140
- }
141
- exports.intToHex = intToHex;
142
- function standardUnicodeHexEscape(codePoint) {
143
- if (codePoint <= 0xffff) {
144
- return "\\u" + intToHex(codePoint, 4);
145
- }
146
- else {
147
- return "\\U" + intToHex(codePoint, 8);
148
- }
149
- }
150
- exports.standardUnicodeHexEscape = standardUnicodeHexEscape;
151
- function escapeNonPrintableMapper(printablePredicate, escaper) {
152
- function mapper(u) {
153
- switch (u) {
154
- case 0x5c:
155
- return "\\\\";
156
- case 0x22:
157
- return '\\"';
158
- case 0x0a:
159
- return "\\n";
160
- case 0x09:
161
- return "\\t";
162
- default:
163
- if (printablePredicate(u)) {
164
- return String.fromCharCode(u);
165
- }
166
- return escaper(u);
167
- }
168
- }
169
- return mapper;
170
- }
171
- exports.escapeNonPrintableMapper = escapeNonPrintableMapper;
172
- exports.utf16StringEscape = utf16ConcatMap(escapeNonPrintableMapper(isPrintable, standardUnicodeHexEscape));
173
- exports.stringEscape = utf32ConcatMap(escapeNonPrintableMapper(isPrintable, standardUnicodeHexEscape));
174
- function isPrintable(codePoint) {
175
- if (codePoint > 0xffff)
176
- return false;
177
- const category = unicode.getCategory(codePoint);
178
- return ([
179
- "Mc",
180
- "No",
181
- "Sk",
182
- "Me",
183
- "Nd",
184
- "Po",
185
- "Lt",
186
- "Pc",
187
- "Sm",
188
- "Zs",
189
- "Lu",
190
- "Pd",
191
- "So",
192
- "Pe",
193
- "Pf",
194
- "Ps",
195
- "Sc",
196
- "Ll",
197
- "Lm",
198
- "Pi",
199
- "Nl",
200
- "Mn",
201
- "Lo"
202
- ].indexOf(category) >= 0);
203
- }
204
- exports.isPrintable = isPrintable;
205
- function isAscii(codePoint) {
206
- return codePoint < 128;
207
- }
208
- exports.isAscii = isAscii;
209
- function isLetter(codePoint) {
210
- const category = unicode.getCategory(codePoint);
211
- // FIXME: Include Letter, modifier (Lm)?
212
- return ["Lu", "Ll", "Lt", "Lo"].indexOf(category) >= 0;
213
- }
214
- exports.isLetter = isLetter;
215
- function isDigit(codePoint) {
216
- const category = unicode.getCategory(codePoint);
217
- return ["Nd"].indexOf(category) >= 0;
218
- }
219
- exports.isDigit = isDigit;
220
- function isNumeric(codePoint) {
221
- const category = unicode.getCategory(codePoint);
222
- return ["No", "Nd", "Nl"].indexOf(category) >= 0;
223
- }
224
- exports.isNumeric = isNumeric;
225
- function isLetterOrDigit(codePoint) {
226
- return isLetter(codePoint) || isDigit(codePoint);
227
- }
228
- exports.isLetterOrDigit = isLetterOrDigit;
229
- function isLetterOrUnderscore(codePoint) {
230
- return isLetter(codePoint) || codePoint === 0x5f;
231
- }
232
- exports.isLetterOrUnderscore = isLetterOrUnderscore;
233
- function isLetterOrUnderscoreOrDigit(codePoint) {
234
- return isLetterOrUnderscore(codePoint) || isDigit(codePoint);
235
- }
236
- exports.isLetterOrUnderscoreOrDigit = isLetterOrUnderscoreOrDigit;
237
- function isWordCharacter(codePoint) {
238
- return isLetter(codePoint) || isDigit(codePoint);
239
- }
240
- exports.isWordCharacter = isWordCharacter;
241
- function trimEnd(str) {
242
- const l = str.length;
243
- let firstWS = l;
244
- for (let i = l - 1; i >= 0; i--) {
245
- if (!unicode.isWhiteSpace(str.charCodeAt(i)))
246
- break;
247
- firstWS = i;
248
- }
249
- if (firstWS === l)
250
- return str;
251
- return str.slice(0, firstWS);
252
- }
253
- exports.trimEnd = trimEnd;
254
- function modifyFirstChar(f, s) {
255
- if (s === "")
256
- return s;
257
- return f(s[0]) + s.slice(1);
258
- }
259
- function capitalize(str) {
260
- return modifyFirstChar(c => c.toUpperCase(), str);
261
- }
262
- exports.capitalize = capitalize;
263
- function decapitalize(str) {
264
- return modifyFirstChar(c => c.toLowerCase(), str);
265
- }
266
- exports.decapitalize = decapitalize;
267
- const wordSeparatorRegex = /[-_. ]+/;
268
- function pascalCase(str) {
269
- const words = str.split(wordSeparatorRegex).map(capitalize);
270
- return words.join("");
271
- }
272
- exports.pascalCase = pascalCase;
273
- function camelCase(str) {
274
- return decapitalize(pascalCase(str));
275
- }
276
- exports.camelCase = camelCase;
277
- function snakeCase(str) {
278
- const words = splitIntoWords(str).map(({ word }) => word.toLowerCase());
279
- return words.join("_");
280
- }
281
- exports.snakeCase = snakeCase;
282
- function startWithLetter(isAllowedStart, // FIXME: technically, this operates on UTF16 units
283
- upper, str) {
284
- const modify = upper ? capitalize : decapitalize;
285
- if (str === "")
286
- return modify("empty");
287
- if (isAllowedStart(str.charCodeAt(0)))
288
- return modify(str);
289
- return modify("the" + str);
290
- }
291
- exports.startWithLetter = startWithLetter;
292
- const knownAcronyms = new Set(Acronyms_1.acronyms);
293
- const fastIsWordCharacter = precomputedCodePointPredicate(isWordCharacter);
294
- const fastIsNonWordCharacter = precomputedCodePointPredicate(cp => !isWordCharacter(cp));
295
- const fastIsLowerCase = precomputedCodePointPredicate(cp => unicode.isLowerCase(cp));
296
- exports.fastIsUpperCase = precomputedCodePointPredicate(cp => unicode.isUpperCase(cp));
297
- const fastNonLetter = precomputedCodePointPredicate(cp => !unicode.isLowerCase(cp) && !unicode.isUpperCase(cp));
298
- const fastIsDigit = precomputedCodePointPredicate(isDigit);
299
- function splitIntoWords(s) {
300
- // [start, end, allUpper]
301
- const intervals = [];
302
- let intervalStart = undefined;
303
- const len = s.length;
304
- let i = 0;
305
- let lastLowerCaseIndex = undefined;
306
- function atEnd() {
307
- return i >= len;
308
- }
309
- function currentCodePoint() {
310
- return (0, Support_1.defined)(s.codePointAt(i));
311
- }
312
- function skipWhile(p) {
313
- while (!atEnd()) {
314
- const cp = currentCodePoint();
315
- if (!p(cp))
316
- break;
317
- if (fastIsLowerCase(cp))
318
- lastLowerCaseIndex = i;
319
- i++;
320
- }
321
- }
322
- function skipNonWord() {
323
- skipWhile(fastIsNonWordCharacter);
324
- }
325
- function skipLowerCase() {
326
- skipWhile(fastIsLowerCase);
327
- }
328
- function skipUpperCase() {
329
- skipWhile(exports.fastIsUpperCase);
330
- }
331
- function skipNonLetter() {
332
- skipWhile(fastNonLetter);
333
- }
334
- function skipDigits() {
335
- skipWhile(fastIsDigit);
336
- }
337
- function startInterval() {
338
- (0, Support_1.assert)(intervalStart === undefined, "Interval started before last one was committed");
339
- intervalStart = i;
340
- }
341
- function commitInterval() {
342
- if (intervalStart === undefined) {
343
- return (0, Support_1.panic)("Tried to commit interval without starting one");
344
- }
345
- (0, Support_1.assert)(i > intervalStart, "Interval must be non-empty");
346
- // FIXME: This is a hack to avoid splitting up surrogates. We shouldn't
347
- // look at surrogates individually in the first place. When we
348
- // encounter a high surrogate we have to combine it with the low
349
- // surrogate and then do the logic on the code point. Right now we're
350
- // only operating on UTF16 char codes, which is wrong.
351
- if (!atEnd() && isLowSurrogate(currentCodePoint())) {
352
- i += 1;
353
- }
354
- const allUpper = lastLowerCaseIndex === undefined || lastLowerCaseIndex < intervalStart;
355
- intervals.push([intervalStart, i, allUpper]);
356
- intervalStart = undefined;
357
- }
358
- function intervalLength() {
359
- if (intervalStart === undefined) {
360
- return (0, Support_1.panic)("Tried to get interval length without starting one");
361
- }
362
- return i - intervalStart;
363
- }
364
- for (;;) {
365
- skipNonWord();
366
- if (atEnd())
367
- break;
368
- startInterval();
369
- if (fastIsLowerCase(currentCodePoint())) {
370
- skipLowerCase();
371
- skipDigits();
372
- commitInterval();
373
- }
374
- else if ((0, exports.fastIsUpperCase)(currentCodePoint())) {
375
- skipUpperCase();
376
- if (atEnd()) {
377
- commitInterval();
378
- }
379
- else if (intervalLength() === 1) {
380
- skipLowerCase();
381
- skipDigits();
382
- commitInterval();
383
- }
384
- else if (isDigit(currentCodePoint())) {
385
- skipDigits();
386
- commitInterval();
387
- }
388
- else {
389
- if (fastIsWordCharacter(currentCodePoint())) {
390
- i -= 1;
391
- }
392
- commitInterval();
393
- }
394
- }
395
- else {
396
- skipNonLetter();
397
- commitInterval();
398
- }
399
- }
400
- const words = [];
401
- for (const [start, end, allUpper] of intervals) {
402
- const word = s.slice(start, end);
403
- const isAcronym = (lastLowerCaseIndex !== undefined && allUpper) || knownAcronyms.has(word.toLowerCase());
404
- words.push({ word, isAcronym });
405
- }
406
- return words;
407
- }
408
- exports.splitIntoWords = splitIntoWords;
409
- function firstUpperWordStyle(s) {
410
- (0, Support_1.assert)(s.length > 0, "Cannot style an empty string");
411
- return s[0].toUpperCase() + s.slice(1).toLowerCase();
412
- }
413
- exports.firstUpperWordStyle = firstUpperWordStyle;
414
- function allUpperWordStyle(s) {
415
- return s.toUpperCase();
416
- }
417
- exports.allUpperWordStyle = allUpperWordStyle;
418
- function originalWord(s) {
419
- return s;
420
- }
421
- exports.originalWord = originalWord;
422
- function allLowerWordStyle(s) {
423
- return s.toLowerCase();
424
- }
425
- exports.allLowerWordStyle = allLowerWordStyle;
426
- function styleWord(style, word) {
427
- (0, Support_1.assert)(word.length > 0, "Tried to style an empty word");
428
- const result = style(word);
429
- (0, Support_1.assert)(result.length > 0, "Word style must not make word empty");
430
- return result;
431
- }
432
- function combineWords(words, removeInvalidCharacters, firstWordStyle, restWordStyle, firstWordAcronymStyle, restAcronymStyle, separator, isStartCharacter) {
433
- const legalizedWords = [];
434
- for (const w of words) {
435
- const word = removeInvalidCharacters(w.word);
436
- if (word.length === 0)
437
- continue;
438
- legalizedWords.push({ word, isAcronym: w.isAcronym });
439
- }
440
- if (legalizedWords.length === 0) {
441
- const validEmpty = removeInvalidCharacters("empty");
442
- (0, Support_1.assert)(validEmpty.length > 0, 'Word "empty" is invalid in target language');
443
- legalizedWords.push({ word: validEmpty, isAcronym: false });
444
- }
445
- const styledWords = [];
446
- const first = legalizedWords[0];
447
- const firstStyle = first.isAcronym ? firstWordAcronymStyle : firstWordStyle;
448
- const styledFirstWord = styleWord(firstStyle, first.word);
449
- let restWords;
450
- if (!isStartCharacter((0, Support_1.defined)(styledFirstWord.codePointAt(0)))) {
451
- const validThe = removeInvalidCharacters("the");
452
- (0, Support_1.assert)(validThe.length > 0, 'Word "the" is invalid in the target language');
453
- const styledThe = styleWord(firstWordStyle, validThe);
454
- (0, Support_1.assert)(isStartCharacter((0, Support_1.defined)(styledThe.codePointAt(0))), 'The first character of styling "the" is not a start character');
455
- styledWords.push(styledThe);
456
- restWords = legalizedWords;
457
- }
458
- else {
459
- styledWords.push(styledFirstWord);
460
- restWords = legalizedWords.slice(1);
461
- }
462
- for (const w of restWords) {
463
- const style = w.isAcronym ? restAcronymStyle : restWordStyle;
464
- styledWords.push(styleWord(style, w.word));
465
- }
466
- return styledWords.join(separator);
467
- }
468
- exports.combineWords = combineWords;
469
- function addPrefixIfNecessary(prefix, name) {
470
- // Take care not to doubly-prefix type names
471
- return name.startsWith(prefix) ? name : prefix + name;
472
- }
473
- exports.addPrefixIfNecessary = addPrefixIfNecessary;
474
- function makeNameStyle(namingStyle, legalizeName, prefix) {
475
- let separator;
476
- let firstWordStyle;
477
- let restWordStyle;
478
- let firstWordAcronymStyle;
479
- let restAcronymStyle;
480
- if (namingStyle === "pascal" ||
481
- namingStyle === "camel" ||
482
- namingStyle === "pascal-upper-acronyms" ||
483
- namingStyle === "camel-upper-acronyms") {
484
- separator = "";
485
- if (namingStyle === "pascal-upper-acronyms" || namingStyle === "camel-upper-acronyms") {
486
- restWordStyle = firstUpperWordStyle;
487
- restAcronymStyle = allUpperWordStyle;
488
- }
489
- else {
490
- restWordStyle = restAcronymStyle = firstUpperWordStyle;
491
- }
492
- }
493
- else {
494
- separator = "_";
495
- }
496
- switch (namingStyle) {
497
- case "pascal":
498
- case "pascal-upper-acronyms":
499
- firstWordStyle = firstWordAcronymStyle = firstUpperWordStyle;
500
- break;
501
- case "camel":
502
- case "camel-upper-acronyms":
503
- firstWordStyle = firstWordAcronymStyle = allLowerWordStyle;
504
- break;
505
- case "underscore":
506
- firstWordStyle = restWordStyle = firstWordAcronymStyle = restAcronymStyle = allLowerWordStyle;
507
- break;
508
- case "upper-underscore":
509
- firstWordStyle = restWordStyle = firstWordAcronymStyle = restAcronymStyle = allUpperWordStyle;
510
- break;
511
- default:
512
- return (0, Support_1.assertNever)(namingStyle);
513
- }
514
- return (original) => {
515
- const words = splitIntoWords(original);
516
- const styledName = combineWords(words, legalizeName, firstWordStyle, restWordStyle, firstWordAcronymStyle, restAcronymStyle, separator, isLetterOrUnderscore);
517
- if (prefix !== undefined) {
518
- return addPrefixIfNecessary(prefix, styledName);
519
- }
520
- else {
521
- return styledName;
522
- }
523
- };
524
- }
525
- exports.makeNameStyle = makeNameStyle;
@@ -1,29 +0,0 @@
1
- export type StringMap = {
2
- [name: string]: any;
3
- };
4
- export declare function isStringMap(x: any): x is StringMap;
5
- export declare function isStringMap<T>(x: any, checkValue: (v: any) => v is T): x is {
6
- [name: string]: T;
7
- };
8
- export declare function checkString(x: any): x is string;
9
- export declare function checkStringMap(x: any): StringMap;
10
- export declare function checkStringMap<T>(x: any, checkValue: (v: any) => v is T): {
11
- [name: string]: T;
12
- };
13
- export declare function checkArray(x: any): any[];
14
- export declare function checkArray<T>(x: any, checkItem: (v: any) => v is T): T[];
15
- export declare function defined<T>(x: T | undefined): T;
16
- export declare function nonNull<T>(x: T | null): T;
17
- export declare function assertNever(x: never): never;
18
- export declare function assert(condition: boolean, message?: string): void;
19
- export declare function panic(message: string): never;
20
- export declare function mustNotHappen(): never;
21
- export declare function repeated<T>(n: number, value: T): T[];
22
- export declare function repeatedCall<T>(n: number, producer: () => T): T[];
23
- export declare function errorMessage(e: any): string;
24
- export declare function inflateBase64(encoded: string): string;
25
- export declare function parseJSON(text: string, description: string, address?: string): any;
26
- export declare function indentationString(level: number): string;
27
- export declare function numberEnumValues(e: {
28
- [key: string]: any;
29
- }): number[];