hermes-estree 0.32.1 → 0.33.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/dist/generated/HermesESTreeSelectorTypes.js.flow +262 -27
  2. package/dist/generated/predicates.js +120 -0
  3. package/dist/generated/predicates.js.flow +72 -0
  4. package/dist/predicates.js +2 -4
  5. package/dist/predicates.js.flow +5 -4
  6. package/dist/src/generated/predicates.js +120 -0
  7. package/dist/src/predicates.js +2 -4
  8. package/dist/types.js.flow +103 -11
  9. package/package.json +1 -1
  10. package/dist/HermesAST.js.flow +0 -57
  11. package/dist/HermesASTAdapter.js +0 -192
  12. package/dist/HermesASTAdapter.js.flow +0 -189
  13. package/dist/HermesParser.js +0 -108
  14. package/dist/HermesParser.js.flow +0 -161
  15. package/dist/HermesParserDecodeUTF8String.js +0 -68
  16. package/dist/HermesParserDecodeUTF8String.js.flow +0 -65
  17. package/dist/HermesParserDeserializer.js +0 -242
  18. package/dist/HermesParserDeserializer.js.flow +0 -260
  19. package/dist/HermesParserNodeDeserializers.js +0 -2477
  20. package/dist/HermesParserNodeDeserializers.js.flow +0 -16
  21. package/dist/HermesParserWASM.js +0 -6
  22. package/dist/HermesParserWASM.js.flow +0 -87
  23. package/dist/HermesToESTreeAdapter.js +0 -439
  24. package/dist/HermesToESTreeAdapter.js.flow +0 -421
  25. package/dist/ParserOptions.js +0 -18
  26. package/dist/ParserOptions.js.flow +0 -41
  27. package/dist/babel/TransformESTreeToBabel.js +0 -1123
  28. package/dist/babel/TransformESTreeToBabel.js.flow +0 -1277
  29. package/dist/estree/StripFlowTypes.js +0 -175
  30. package/dist/estree/StripFlowTypes.js.flow +0 -158
  31. package/dist/estree/StripFlowTypesForBabel.js +0 -215
  32. package/dist/estree/StripFlowTypesForBabel.js.flow +0 -216
  33. package/dist/estree/TransformComponentSyntax.js +0 -788
  34. package/dist/estree/TransformComponentSyntax.js.flow +0 -864
  35. package/dist/estree/TransformEnumSyntax.js +0 -106
  36. package/dist/estree/TransformEnumSyntax.js.flow +0 -125
  37. package/dist/estree/TransformMatchSyntax.js +0 -1006
  38. package/dist/estree/TransformMatchSyntax.js.flow +0 -912
  39. package/dist/generated/ESTreeVisitorKeys.js +0 -220
  40. package/dist/generated/ESTreeVisitorKeys.js.flow +0 -15
  41. package/dist/generated/ParserVisitorKeys.js +0 -794
  42. package/dist/generated/ParserVisitorKeys.js.flow +0 -17
  43. package/dist/getModuleDocblock.js +0 -112
  44. package/dist/getModuleDocblock.js.flow +0 -118
  45. package/dist/src/HermesASTAdapter.js +0 -192
  46. package/dist/src/HermesParser.js +0 -108
  47. package/dist/src/HermesParserDecodeUTF8String.js +0 -68
  48. package/dist/src/HermesParserDeserializer.js +0 -242
  49. package/dist/src/HermesParserNodeDeserializers.js +0 -2477
  50. package/dist/src/HermesToESTreeAdapter.js +0 -439
  51. package/dist/src/ParserOptions.js +0 -18
  52. package/dist/src/babel/TransformESTreeToBabel.js +0 -1123
  53. package/dist/src/estree/StripFlowTypes.js +0 -175
  54. package/dist/src/estree/StripFlowTypesForBabel.js +0 -215
  55. package/dist/src/estree/TransformComponentSyntax.js +0 -788
  56. package/dist/src/estree/TransformEnumSyntax.js +0 -106
  57. package/dist/src/estree/TransformMatchSyntax.js +0 -1006
  58. package/dist/src/generated/ESTreeVisitorKeys.js +0 -220
  59. package/dist/src/generated/ParserVisitorKeys.js +0 -794
  60. package/dist/src/getModuleDocblock.js +0 -112
  61. package/dist/src/transform/SimpleTransform.js +0 -136
  62. package/dist/src/transform/astArrayMutationHelpers.js +0 -62
  63. package/dist/src/transform/astNodeMutationHelpers.js +0 -200
  64. package/dist/src/traverse/SimpleTraverser.js +0 -137
  65. package/dist/src/traverse/getVisitorKeys.js +0 -37
  66. package/dist/src/utils/Builders.js +0 -191
  67. package/dist/src/utils/GenID.js +0 -41
  68. package/dist/src/utils/createSyntaxError.js +0 -25
  69. package/dist/src/utils/mutateESTreeASTForPrettier.js +0 -127
  70. package/dist/transform/SimpleTransform.js +0 -136
  71. package/dist/transform/SimpleTransform.js.flow +0 -169
  72. package/dist/transform/astArrayMutationHelpers.js +0 -62
  73. package/dist/transform/astArrayMutationHelpers.js.flow +0 -71
  74. package/dist/transform/astNodeMutationHelpers.js +0 -200
  75. package/dist/transform/astNodeMutationHelpers.js.flow +0 -246
  76. package/dist/traverse/SimpleTraverser.js +0 -137
  77. package/dist/traverse/SimpleTraverser.js.flow +0 -133
  78. package/dist/traverse/getVisitorKeys.js +0 -37
  79. package/dist/traverse/getVisitorKeys.js.flow +0 -36
  80. package/dist/utils/Builders.js +0 -191
  81. package/dist/utils/Builders.js.flow +0 -218
  82. package/dist/utils/GenID.js +0 -41
  83. package/dist/utils/GenID.js.flow +0 -38
  84. package/dist/utils/createSyntaxError.js +0 -25
  85. package/dist/utils/createSyntaxError.js.flow +0 -24
  86. package/dist/utils/mutateESTreeASTForPrettier.js +0 -127
  87. package/dist/utils/mutateESTreeASTForPrettier.js.flow +0 -130
@@ -1,133 +0,0 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- * @flow strict
8
- * @format
9
- */
10
-
11
- 'use strict';
12
-
13
- import type {VisitorKeysType} from './getVisitorKeys';
14
- import type {ESNode} from 'hermes-estree';
15
-
16
- import {getVisitorKeys, isNode} from './getVisitorKeys';
17
-
18
- export type TraverserCallback = (node: ESNode, parent: ?ESNode) => void;
19
- export type TraverserOptions = $ReadOnly<{
20
- /** The callback function which is called on entering each node. */
21
- enter: TraverserCallback,
22
- /** The callback function which is called on leaving each node. */
23
- leave: TraverserCallback,
24
- /** The set of visitor keys to use for traversal. Defaults to the Flow ESTree visitor keys */
25
- visitorKeys?: ?VisitorKeysType,
26
- }>;
27
-
28
- /**
29
- * Can be thrown within the traversal "enter" function to prevent the traverser
30
- * from traversing the node any further, essentially culling the remainder of the
31
- * AST branch
32
- */
33
- export const SimpleTraverserSkip: Error = new Error();
34
- /**
35
- * Can be thrown at any point during the traversal to immediately stop traversal
36
- * entirely.
37
- */
38
- export const SimpleTraverserBreak: Error = new Error();
39
-
40
- /**
41
- * A very simple traverser class to traverse AST trees.
42
- */
43
- export class SimpleTraverser {
44
- static Break: Error = SimpleTraverserBreak;
45
- static Skip: Error = SimpleTraverserSkip;
46
-
47
- /**
48
- * Traverse the given AST tree.
49
- * @param node The root node to traverse.
50
- * @param options The option object.
51
- */
52
- traverse(node: ESNode, options: TraverserOptions): void {
53
- try {
54
- this._traverse(node, null, options);
55
- } catch (ex) {
56
- if (ex === SimpleTraverserBreak) {
57
- return;
58
- }
59
- throw ex;
60
- }
61
- }
62
-
63
- /**
64
- * Traverse the given AST tree recursively.
65
- * @param node The current node.
66
- * @param parent The parent node.
67
- * @private
68
- */
69
- _traverse(node: ESNode, parent: ?ESNode, options: TraverserOptions): void {
70
- if (!isNode(node)) {
71
- return;
72
- }
73
-
74
- try {
75
- options.enter(node, parent);
76
- } catch (ex) {
77
- if (ex === SimpleTraverserSkip) {
78
- return;
79
- }
80
- this._setErrorContext(ex, node);
81
- throw ex;
82
- }
83
-
84
- const keys = getVisitorKeys(node, options.visitorKeys);
85
- for (const key of keys) {
86
- const child: ESNode | $ReadOnlyArray<ESNode> = (node[
87
- (key: $FlowFixMe)
88
- ]: $FlowFixMe);
89
-
90
- if (Array.isArray(child)) {
91
- for (let j = 0; j < child.length; ++j) {
92
- this._traverse(child[j], node, options);
93
- }
94
- } else {
95
- this._traverse(child, node, options);
96
- }
97
- }
98
-
99
- try {
100
- options.leave(node, parent);
101
- } catch (ex) {
102
- if (ex === SimpleTraverserSkip) {
103
- return;
104
- }
105
- this._setErrorContext(ex, node);
106
- throw ex;
107
- }
108
- }
109
-
110
- /**
111
- * Set useful contextual information onto the error object.
112
- * @param ex The error object.
113
- * @param node The current node.
114
- * @private
115
- */
116
- _setErrorContext(ex: Error, node: ESNode): void {
117
- // $FlowFixMe[prop-missing]
118
- ex.currentNode = {
119
- type: node.type,
120
- range: node.range,
121
- loc: node.loc,
122
- };
123
- }
124
-
125
- /**
126
- * Traverse the given AST tree.
127
- * @param node The root node to traverse.
128
- * @param options The option object.
129
- */
130
- static traverse(node: ESNode, options: TraverserOptions) {
131
- new SimpleTraverser().traverse(node, options);
132
- }
133
- }
@@ -1,37 +0,0 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- *
8
- * @noformat
9
- */
10
- 'use strict';
11
-
12
- Object.defineProperty(exports, "__esModule", {
13
- value: true
14
- });
15
- exports.getVisitorKeys = getVisitorKeys;
16
- exports.isNode = isNode;
17
-
18
- var _ESTreeVisitorKeys = _interopRequireDefault(require("../generated/ESTreeVisitorKeys"));
19
-
20
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
-
22
- function isNode(thing)
23
- /*: implies thing is {+[string]: mixed} */
24
- {
25
- return typeof thing === 'object' && thing != null && typeof thing.type === 'string';
26
- }
27
-
28
- function getVisitorKeys(node, visitorKeys) {
29
- const keys = (visitorKeys != null ? visitorKeys : _ESTreeVisitorKeys.default)[node.type];
30
-
31
- if (keys == null) {
32
- throw new Error(`No visitor keys found for node type "${node.type}".`);
33
- } // $FlowExpectedError[prop-missing]
34
-
35
-
36
- return keys;
37
- }
@@ -1,36 +0,0 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- * @flow strict
8
- * @noformat
9
- */
10
-
11
- 'use strict';
12
-
13
- import type {ESNode} from 'hermes-estree';
14
- import type {VisitorKeys as VisitorKeysType} from '../generated/ESTreeVisitorKeys';
15
-
16
- import FlowVisitorKeys from '../generated/ESTreeVisitorKeys';
17
-
18
- export function isNode(thing: mixed) /*: implies thing is {+[string]: mixed} */ {
19
- return (
20
- typeof thing === 'object' && thing != null && typeof thing.type === 'string'
21
- );
22
- }
23
-
24
- export type {VisitorKeysType};
25
- export function getVisitorKeys<T: ESNode>(
26
- node: T,
27
- visitorKeys?: ?VisitorKeysType,
28
- ): $ReadOnlyArray<$Keys<T>> {
29
- const keys = (visitorKeys ?? FlowVisitorKeys)[node.type];
30
- if (keys == null) {
31
- throw new Error(`No visitor keys found for node type "${node.type}".`);
32
- }
33
-
34
- // $FlowExpectedError[prop-missing]
35
- return keys;
36
- }
@@ -1,191 +0,0 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- *
8
- * @format
9
- */
10
- 'use strict';
11
-
12
- Object.defineProperty(exports, "__esModule", {
13
- value: true
14
- });
15
- exports.EMPTY_PARENT = void 0;
16
- exports.callExpression = callExpression;
17
- exports.conjunction = conjunction;
18
- exports.createDefaultPosition = createDefaultPosition;
19
- exports.disjunction = disjunction;
20
- exports.etc = etc;
21
- exports.ident = ident;
22
- exports.iife = iife;
23
- exports.nullLiteral = nullLiteral;
24
- exports.numberLiteral = numberLiteral;
25
- exports.stringLiteral = stringLiteral;
26
- exports.throwStatement = throwStatement;
27
- exports.typeofExpression = typeofExpression;
28
- exports.variableDeclaration = variableDeclaration;
29
- // Rely on the mapper to fix up parent relationships.
30
- const EMPTY_PARENT = null;
31
- exports.EMPTY_PARENT = EMPTY_PARENT;
32
-
33
- function createDefaultPosition() {
34
- return {
35
- line: 1,
36
- column: 0
37
- };
38
- }
39
-
40
- function etc({
41
- loc,
42
- range,
43
- parent
44
- } = {}) {
45
- return {
46
- loc: {
47
- start: (loc == null ? void 0 : loc.start) != null ? loc.start : createDefaultPosition(),
48
- end: (loc == null ? void 0 : loc.end) != null ? loc.end : createDefaultPosition()
49
- },
50
- range: range != null ? range : [0, 0],
51
- parent: parent != null ? parent : EMPTY_PARENT
52
- };
53
- }
54
-
55
- function ident(name, info) {
56
- return {
57
- type: 'Identifier',
58
- name,
59
- optional: false,
60
- typeAnnotation: null,
61
- ...etc(info)
62
- };
63
- }
64
-
65
- function stringLiteral(value, info) {
66
- return {
67
- type: 'Literal',
68
- value,
69
- raw: `"${value}"`,
70
- literalType: 'string',
71
- ...etc(info)
72
- };
73
- }
74
-
75
- function numberLiteral(value, info) {
76
- return {
77
- type: 'Literal',
78
- value,
79
- raw: String(value),
80
- literalType: 'numeric',
81
- ...etc(info)
82
- };
83
- }
84
-
85
- function nullLiteral(info) {
86
- return {
87
- type: 'Literal',
88
- value: null,
89
- raw: 'null',
90
- literalType: 'null',
91
- ...etc(info)
92
- };
93
- }
94
-
95
- function conjunction(tests) {
96
- if (tests.length === 0) {
97
- throw new Error('Must have at least one test.');
98
- }
99
-
100
- return tests.reduce((acc, test) => ({
101
- type: 'LogicalExpression',
102
- left: acc,
103
- right: test,
104
- operator: '&&',
105
- ...etc()
106
- }));
107
- }
108
-
109
- function disjunction(tests) {
110
- if (tests.length === 0) {
111
- throw new Error('Must have at least one test.');
112
- }
113
-
114
- return tests.reduce((acc, test) => ({
115
- type: 'LogicalExpression',
116
- left: acc,
117
- right: test,
118
- operator: '||',
119
- ...etc()
120
- }));
121
- }
122
-
123
- function variableDeclaration(kind, id, init, info) {
124
- return {
125
- type: 'VariableDeclaration',
126
- kind,
127
- declarations: [{
128
- type: 'VariableDeclarator',
129
- init,
130
- id,
131
- ...etc(),
132
- parent: EMPTY_PARENT
133
- }],
134
- ...etc(info)
135
- };
136
- }
137
-
138
- function callExpression(callee, args, info) {
139
- return {
140
- type: 'CallExpression',
141
- callee,
142
- arguments: args,
143
- typeArguments: null,
144
- optional: false,
145
- ...etc(info)
146
- };
147
- }
148
-
149
- function throwStatement(arg, info) {
150
- return {
151
- type: 'ThrowStatement',
152
- argument: callExpression(ident('Error'), [arg]),
153
- ...etc(info)
154
- };
155
- }
156
-
157
- function iife(statements, params = [], args = []) {
158
- const callee = {
159
- type: 'ArrowFunctionExpression',
160
- params,
161
- expression: false,
162
- async: false,
163
- predicate: null,
164
- returnType: null,
165
- typeParameters: null,
166
- id: null,
167
- body: {
168
- type: 'BlockStatement',
169
- body: statements,
170
- ...etc()
171
- },
172
- ...etc()
173
- };
174
- return callExpression(callee, args);
175
- }
176
-
177
- function typeofExpression(arg, kind) {
178
- return {
179
- type: 'BinaryExpression',
180
- left: {
181
- type: 'UnaryExpression',
182
- operator: 'typeof',
183
- argument: arg,
184
- prefix: true,
185
- ...etc()
186
- },
187
- right: stringLiteral(kind),
188
- operator: '===',
189
- ...etc()
190
- };
191
- }
@@ -1,218 +0,0 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- * @flow strict
8
- * @format
9
- */
10
-
11
- 'use strict';
12
-
13
- import type {
14
- ArrowFunctionExpression,
15
- BinaryExpression,
16
- BindingName,
17
- CallExpression,
18
- ESNode,
19
- Expression,
20
- Identifier,
21
- LogicalExpression,
22
- NullLiteral,
23
- NumericLiteral,
24
- Position,
25
- Range,
26
- SourceLocation,
27
- SpreadElement,
28
- Statement,
29
- StringLiteral,
30
- Super,
31
- ThrowStatement,
32
- VariableDeclaration,
33
- } from 'hermes-estree';
34
-
35
- // Rely on the mapper to fix up parent relationships.
36
- export const EMPTY_PARENT: $FlowFixMe = null;
37
-
38
- export function createDefaultPosition(): Position {
39
- return {
40
- line: 1,
41
- column: 0,
42
- };
43
- }
44
-
45
- export type Etc = {
46
- parent?: ESNode,
47
- loc?: SourceLocation,
48
- range?: Range,
49
- };
50
-
51
- export function etc({loc, range, parent}: Etc = {}): {
52
- parent: ESNode,
53
- loc: SourceLocation,
54
- range: Range,
55
- } {
56
- return {
57
- loc: {
58
- start: loc?.start != null ? loc.start : createDefaultPosition(),
59
- end: loc?.end != null ? loc.end : createDefaultPosition(),
60
- },
61
- range: range ?? [0, 0],
62
- parent: parent ?? EMPTY_PARENT,
63
- };
64
- }
65
-
66
- export function ident(name: string, info?: Etc): Identifier {
67
- return {
68
- type: 'Identifier',
69
- name,
70
- optional: false,
71
- typeAnnotation: null,
72
- ...etc(info),
73
- };
74
- }
75
-
76
- export function stringLiteral(value: string, info?: Etc): StringLiteral {
77
- return {
78
- type: 'Literal',
79
- value,
80
- raw: `"${value}"`,
81
- literalType: 'string',
82
- ...etc(info),
83
- };
84
- }
85
-
86
- export function numberLiteral(value: number, info?: Etc): NumericLiteral {
87
- return {
88
- type: 'Literal',
89
- value,
90
- raw: String(value),
91
- literalType: 'numeric',
92
- ...etc(info),
93
- };
94
- }
95
-
96
- export function nullLiteral(info?: Etc): NullLiteral {
97
- return {
98
- type: 'Literal',
99
- value: null,
100
- raw: 'null',
101
- literalType: 'null',
102
- ...etc(info),
103
- };
104
- }
105
-
106
- export function conjunction(tests: $ReadOnlyArray<Expression>): Expression {
107
- if (tests.length === 0) {
108
- throw new Error('Must have at least one test.');
109
- }
110
- return tests.reduce((acc, test): LogicalExpression => ({
111
- type: 'LogicalExpression',
112
- left: acc,
113
- right: test,
114
- operator: '&&',
115
- ...etc(),
116
- }));
117
- }
118
-
119
- export function disjunction(tests: $ReadOnlyArray<Expression>): Expression {
120
- if (tests.length === 0) {
121
- throw new Error('Must have at least one test.');
122
- }
123
- return tests.reduce((acc, test): LogicalExpression => ({
124
- type: 'LogicalExpression',
125
- left: acc,
126
- right: test,
127
- operator: '||',
128
- ...etc(),
129
- }));
130
- }
131
-
132
- export function variableDeclaration(
133
- kind: VariableDeclaration['kind'],
134
- id: BindingName,
135
- init: Expression,
136
- info?: Etc,
137
- ): VariableDeclaration {
138
- return {
139
- type: 'VariableDeclaration',
140
- kind,
141
- declarations: [
142
- {
143
- type: 'VariableDeclarator',
144
- init,
145
- id,
146
- ...etc(),
147
- parent: EMPTY_PARENT,
148
- },
149
- ],
150
- ...etc(info),
151
- };
152
- }
153
-
154
- export function callExpression(
155
- callee: Expression | Super,
156
- args: $ReadOnlyArray<Expression | SpreadElement>,
157
- info?: Etc,
158
- ): CallExpression {
159
- return {
160
- type: 'CallExpression',
161
- callee,
162
- arguments: args,
163
- typeArguments: null,
164
- optional: false,
165
- ...etc(info),
166
- };
167
- }
168
-
169
- export function throwStatement(arg: Expression, info?: Etc): ThrowStatement {
170
- return {
171
- type: 'ThrowStatement',
172
- argument: callExpression(ident('Error'), [arg]),
173
- ...etc(info),
174
- };
175
- }
176
-
177
- export function iife(
178
- statements: $ReadOnlyArray<Statement>,
179
- params: $ReadOnlyArray<BindingName> = [],
180
- args: $ReadOnlyArray<Expression> = [],
181
- ): CallExpression {
182
- const callee: ArrowFunctionExpression = {
183
- type: 'ArrowFunctionExpression',
184
- params,
185
- expression: false,
186
- async: false,
187
- predicate: null,
188
- returnType: null,
189
- typeParameters: null,
190
- id: null,
191
- body: {
192
- type: 'BlockStatement',
193
- body: statements,
194
- ...etc(),
195
- },
196
- ...etc(),
197
- };
198
- return callExpression(callee, args);
199
- }
200
-
201
- export function typeofExpression(
202
- arg: Expression,
203
- kind: string,
204
- ): BinaryExpression {
205
- return {
206
- type: 'BinaryExpression',
207
- left: {
208
- type: 'UnaryExpression',
209
- operator: 'typeof',
210
- argument: arg,
211
- prefix: true,
212
- ...etc(),
213
- },
214
- right: stringLiteral(kind),
215
- operator: '===',
216
- ...etc(),
217
- };
218
- }
@@ -1,41 +0,0 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- *
8
- * @format
9
- */
10
- 'use strict';
11
-
12
- Object.defineProperty(exports, "__esModule", {
13
- value: true
14
- });
15
- exports.createGenID = createGenID;
16
- const genPrefix = '$$gen$';
17
-
18
- function createGenID(uniqueTransformPrefix) {
19
- let genN = 0;
20
- const used = new Set();
21
- return {
22
- genID() {
23
- let name;
24
-
25
- do {
26
- name = `${genPrefix}${uniqueTransformPrefix}${genN}`;
27
- genN++;
28
- } while (used.has(name));
29
-
30
- used.add(name);
31
- return name;
32
- },
33
-
34
- addUsage(name) {
35
- if (name.startsWith(genPrefix)) {
36
- used.add(name);
37
- }
38
- }
39
-
40
- };
41
- }
@@ -1,38 +0,0 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- * @flow strict
8
- * @format
9
- */
10
-
11
- 'use strict';
12
-
13
- const genPrefix = '$$gen$';
14
-
15
- export function createGenID(uniqueTransformPrefix: string): {
16
- genID(): string,
17
- addUsage(string): void,
18
- } {
19
- let genN: number = 0;
20
- const used = new Set<string>();
21
-
22
- return {
23
- genID(): string {
24
- let name;
25
- do {
26
- name = `${genPrefix}${uniqueTransformPrefix}${genN}`;
27
- genN++;
28
- } while (used.has(name));
29
- used.add(name);
30
- return name;
31
- },
32
- addUsage(name: string): void {
33
- if (name.startsWith(genPrefix)) {
34
- used.add(name);
35
- }
36
- },
37
- };
38
- }
@@ -1,25 +0,0 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- *
8
- * @format
9
- */
10
- 'use strict';
11
-
12
- Object.defineProperty(exports, "__esModule", {
13
- value: true
14
- });
15
- exports.createSyntaxError = createSyntaxError;
16
-
17
- function createSyntaxError(node, err) {
18
- const syntaxError = new SyntaxError(err); // $FlowExpectedError[prop-missing]
19
-
20
- syntaxError.loc = {
21
- line: node.loc.start.line,
22
- column: node.loc.start.column
23
- };
24
- return syntaxError;
25
- }