hermes-transform 0.33.2 → 0.34.0

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.
@@ -71,6 +71,7 @@ import type {
71
71
  DeclareOpaqueType,
72
72
  DeclareTypeAlias,
73
73
  DeclareVariable,
74
+ Decorator,
74
75
  DoWhileStatement,
75
76
  EmptyStatement,
76
77
  EmptyTypeAnnotation,
@@ -283,6 +284,7 @@ import type {
283
284
  DeclareOpaqueTypeProps,
284
285
  DeclareTypeAliasProps,
285
286
  DeclareVariableProps,
287
+ DecoratorProps,
286
288
  DoWhileStatementProps,
287
289
  EmptyStatementProps,
288
290
  EmptyTypeAnnotationProps,
@@ -839,6 +841,14 @@ type DeclareVariableCloneSignature = ((
839
841
  node: ?DeclareVariable,
840
842
  newProps: Partial<DeclareVariableProps>,
841
843
  ) => DetachedNode<DeclareVariable> | null);
844
+ type DecoratorCloneSignature = ((
845
+ node: Decorator,
846
+ newProps: Partial<DecoratorProps>,
847
+ ) => DetachedNode<Decorator>) &
848
+ ((
849
+ node: ?Decorator,
850
+ newProps: Partial<DecoratorProps>,
851
+ ) => DetachedNode<Decorator> | null);
842
852
  type DoWhileStatementCloneSignature = ((
843
853
  node: DoWhileStatement,
844
854
  newProps: Partial<DoWhileStatementProps>,
@@ -2173,6 +2183,7 @@ export type TransformCloneSignatures = AnyTypeAnnotationCloneSignature &
2173
2183
  DeclareOpaqueTypeCloneSignature &
2174
2184
  DeclareTypeAliasCloneSignature &
2175
2185
  DeclareVariableCloneSignature &
2186
+ DecoratorCloneSignature &
2176
2187
  DoWhileStatementCloneSignature &
2177
2188
  EmptyStatementCloneSignature &
2178
2189
  EmptyTypeAnnotationCloneSignature &
@@ -71,6 +71,7 @@ import type {
71
71
  DeclareOpaqueType,
72
72
  DeclareTypeAlias,
73
73
  DeclareVariable,
74
+ Decorator,
74
75
  DoWhileStatement,
75
76
  EmptyStatement,
76
77
  EmptyTypeAnnotation,
@@ -283,6 +284,7 @@ import type {
283
284
  DeclareOpaqueTypeProps,
284
285
  DeclareTypeAliasProps,
285
286
  DeclareVariableProps,
287
+ DecoratorProps,
286
288
  DoWhileStatementProps,
287
289
  EmptyStatementProps,
288
290
  EmptyTypeAnnotationProps,
@@ -642,6 +644,10 @@ type DeclareVariableModifySignature = (
642
644
  node: ?DeclareVariable,
643
645
  newProps: Partial<DeclareVariableProps>,
644
646
  ) => void;
647
+ type DecoratorModifySignature = (
648
+ node: ?Decorator,
649
+ newProps: Partial<DecoratorProps>,
650
+ ) => void;
645
651
  type DoWhileStatementModifySignature = (
646
652
  node: ?DoWhileStatement,
647
653
  newProps: Partial<DoWhileStatementProps>,
@@ -1335,6 +1341,7 @@ export type TransformModifySignatures = AnyTypeAnnotationModifySignature &
1335
1341
  DeclareOpaqueTypeModifySignature &
1336
1342
  DeclareTypeAliasModifySignature &
1337
1343
  DeclareVariableModifySignature &
1344
+ DecoratorModifySignature &
1338
1345
  DoWhileStatementModifySignature &
1339
1346
  EmptyStatementModifySignature &
1340
1347
  EmptyTypeAnnotationModifySignature &
@@ -69,6 +69,7 @@ import type {
69
69
  DeclareOpaqueType,
70
70
  DeclareTypeAlias,
71
71
  DeclareVariable,
72
+ Decorator,
72
73
  DoWhileStatement,
73
74
  EmptyStatement,
74
75
  EmptyTypeAnnotation,
@@ -465,6 +466,11 @@ type DeclareVariableReplaceSignature = (
465
466
  nodeToReplaceWith: DetachedNode<DeclareVariable>,
466
467
  options?: $ReadOnly<{keepComments?: boolean}>,
467
468
  ) => void;
469
+ type DecoratorReplaceSignature = (
470
+ target: Decorator,
471
+ nodeToReplaceWith: DetachedNode<Decorator>,
472
+ options?: $ReadOnly<{keepComments?: boolean}>,
473
+ ) => void;
468
474
  type DoWhileStatementReplaceSignature = (
469
475
  target: DoWhileStatement,
470
476
  nodeToReplaceWith: DetachedNode<DoWhileStatement>,
@@ -1302,6 +1308,7 @@ export type TransformReplaceSignatures = AnyTypeAnnotationReplaceSignature &
1302
1308
  DeclareOpaqueTypeReplaceSignature &
1303
1309
  DeclareTypeAliasReplaceSignature &
1304
1310
  DeclareVariableReplaceSignature &
1311
+ DecoratorReplaceSignature &
1305
1312
  DoWhileStatementReplaceSignature &
1306
1313
  EmptyStatementReplaceSignature &
1307
1314
  EmptyTypeAnnotationReplaceSignature &
@@ -66,6 +66,7 @@ var _exportNames = {
66
66
  DeclareOpaqueType: true,
67
67
  DeclareTypeAlias: true,
68
68
  DeclareVariable: true,
69
+ Decorator: true,
69
70
  DoWhileStatement: true,
70
71
  EmptyStatement: true,
71
72
  EmptyTypeAnnotation: true,
@@ -259,6 +260,7 @@ exports.DeclareOpaqueType = DeclareOpaqueType;
259
260
  exports.DeclareTypeAlias = DeclareTypeAlias;
260
261
  exports.DeclareVariable = DeclareVariable;
261
262
  exports.DeclaredPredicate = DeclaredPredicate;
263
+ exports.Decorator = Decorator;
262
264
  exports.DoWhileStatement = DoWhileStatement;
263
265
  exports.EmptyStatement = EmptyStatement;
264
266
  exports.EmptyTypeAnnotation = EmptyTypeAnnotation;
@@ -631,7 +633,8 @@ function ComponentDeclaration(props) {
631
633
  params: props.params.map(n => (0, _detachedNode.asDetachedNodeForCodeGen)(n)),
632
634
  body: (0, _detachedNode.asDetachedNodeForCodeGen)(props.body),
633
635
  typeParameters: (0, _detachedNode.asDetachedNodeForCodeGen)(props.typeParameters),
634
- rendersType: (0, _detachedNode.asDetachedNodeForCodeGen)(props.rendersType)
636
+ rendersType: (0, _detachedNode.asDetachedNodeForCodeGen)(props.rendersType),
637
+ async: props.async
635
638
  });
636
639
  (0, _detachedNode.setParentPointersInDirectChildren)(node);
637
640
  return node;
@@ -841,6 +844,15 @@ function DeclareVariable(props) {
841
844
  return node;
842
845
  }
843
846
 
847
+ function Decorator(props) {
848
+ const node = (0, _detachedNode.detachedProps)(props.parent, {
849
+ type: 'Decorator',
850
+ expression: (0, _detachedNode.asDetachedNodeForCodeGen)(props.expression)
851
+ });
852
+ (0, _detachedNode.setParentPointersInDirectChildren)(node);
853
+ return node;
854
+ }
855
+
844
856
  function DoWhileStatement(props) {
845
857
  const node = (0, _detachedNode.detachedProps)(props.parent, {
846
858
  type: 'DoWhileStatement',
@@ -1133,7 +1145,8 @@ function HookDeclaration(props) {
1133
1145
  params: props.params.map(n => (0, _detachedNode.asDetachedNodeForCodeGen)(n)),
1134
1146
  body: (0, _detachedNode.asDetachedNodeForCodeGen)(props.body),
1135
1147
  typeParameters: (0, _detachedNode.asDetachedNodeForCodeGen)(props.typeParameters),
1136
- returnType: (0, _detachedNode.asDetachedNodeForCodeGen)(props.returnType)
1148
+ returnType: (0, _detachedNode.asDetachedNodeForCodeGen)(props.returnType),
1149
+ async: props.async
1137
1150
  });
1138
1151
  (0, _detachedNode.setParentPointersInDirectChildren)(node);
1139
1152
  return node;
@@ -1173,13 +1186,13 @@ function ImportAttribute(props) {
1173
1186
  }
1174
1187
 
1175
1188
  function ImportDeclaration(props) {
1176
- var _props$assertions;
1189
+ var _props$attributes;
1177
1190
 
1178
1191
  const node = (0, _detachedNode.detachedProps)(props.parent, {
1179
1192
  type: 'ImportDeclaration',
1180
1193
  specifiers: props.specifiers.map(n => (0, _detachedNode.asDetachedNodeForCodeGen)(n)),
1181
1194
  source: (0, _detachedNode.asDetachedNodeForCodeGen)(props.source),
1182
- assertions: (_props$assertions = props.assertions) == null ? void 0 : _props$assertions.map(n => (0, _detachedNode.asDetachedNodeForCodeGen)(n)),
1195
+ attributes: (_props$attributes = props.attributes) == null ? void 0 : _props$attributes.map(n => (0, _detachedNode.asDetachedNodeForCodeGen)(n)),
1183
1196
  importKind: props.importKind
1184
1197
  });
1185
1198
  (0, _detachedNode.setParentPointersInDirectChildren)(node);
@@ -1655,7 +1668,8 @@ function MethodDefinition(props) {
1655
1668
  value: (0, _detachedNode.asDetachedNodeForCodeGen)(props.value),
1656
1669
  kind: props.kind,
1657
1670
  computed: props.computed,
1658
- static: props.static
1671
+ static: props.static,
1672
+ decorators: props.decorators.map(n => (0, _detachedNode.asDetachedNodeForCodeGen)(n))
1659
1673
  });
1660
1674
  (0, _detachedNode.setParentPointersInDirectChildren)(node);
1661
1675
  return node;
@@ -1865,6 +1879,7 @@ function PropertyDefinition(props) {
1865
1879
  value: (0, _detachedNode.asDetachedNodeForCodeGen)(props.value),
1866
1880
  computed: props.computed,
1867
1881
  static: props.static,
1882
+ decorators: props.decorators.map(n => (0, _detachedNode.asDetachedNodeForCodeGen)(n)),
1868
1883
  declare: props.declare,
1869
1884
  optional: props.optional,
1870
1885
  variance: (0, _detachedNode.asDetachedNodeForCodeGen)(props.variance),
@@ -64,6 +64,7 @@ import type {
64
64
  DeclareOpaqueType as DeclareOpaqueTypeType,
65
65
  DeclareTypeAlias as DeclareTypeAliasType,
66
66
  DeclareVariable as DeclareVariableType,
67
+ Decorator as DecoratorType,
67
68
  DoWhileStatement as DoWhileStatementType,
68
69
  EmptyStatement as EmptyStatementType,
69
70
  EmptyTypeAnnotation as EmptyTypeAnnotationType,
@@ -343,6 +344,7 @@ export type ComponentDeclarationProps = {
343
344
  ComponentDeclarationType['typeParameters'],
344
345
  >,
345
346
  +rendersType?: ?MaybeDetachedNode<ComponentDeclarationType['rendersType']>,
347
+ +async: ComponentDeclarationType['async'],
346
348
  };
347
349
 
348
350
  export type ComponentParameterProps = {
@@ -472,6 +474,10 @@ export type DeclareVariableProps = {
472
474
  +kind: DeclareVariableType['kind'],
473
475
  };
474
476
 
477
+ export type DecoratorProps = {
478
+ +expression: MaybeDetachedNode<DecoratorType['expression']>,
479
+ };
480
+
475
481
  export type DoWhileStatementProps = {
476
482
  +body: MaybeDetachedNode<DoWhileStatementType['body']>,
477
483
  +test: MaybeDetachedNode<DoWhileStatementType['test']>,
@@ -654,6 +660,7 @@ export type HookDeclarationProps = {
654
660
  +body: MaybeDetachedNode<HookDeclarationType['body']>,
655
661
  +typeParameters?: ?MaybeDetachedNode<HookDeclarationType['typeParameters']>,
656
662
  +returnType?: ?MaybeDetachedNode<HookDeclarationType['returnType']>,
663
+ +async: HookDeclarationType['async'],
657
664
  };
658
665
 
659
666
  export type HookTypeAnnotationProps = {
@@ -683,8 +690,8 @@ export type ImportDeclarationProps = {
683
690
  MaybeDetachedNode<ImportDeclarationType['specifiers'][number]>,
684
691
  >,
685
692
  +source: MaybeDetachedNode<ImportDeclarationType['source']>,
686
- +assertions?: ?$ReadOnlyArray<
687
- MaybeDetachedNode<ImportDeclarationType['assertions'][number]>,
693
+ +attributes?: ?$ReadOnlyArray<
694
+ MaybeDetachedNode<ImportDeclarationType['attributes'][number]>,
688
695
  >,
689
696
  +importKind: ImportDeclarationType['importKind'],
690
697
  };
@@ -945,6 +952,9 @@ export type MethodDefinitionProps = {
945
952
  +kind: MethodDefinitionType['kind'],
946
953
  +computed: MethodDefinitionType['computed'],
947
954
  +static: MethodDefinitionType['static'],
955
+ +decorators: $ReadOnlyArray<
956
+ MaybeDetachedNode<MethodDefinitionType['decorators'][number]>,
957
+ >,
948
958
  };
949
959
 
950
960
  export type MixedTypeAnnotationProps = {};
@@ -1072,6 +1082,9 @@ export type PropertyDefinitionProps = {
1072
1082
  +value?: ?MaybeDetachedNode<PropertyDefinitionType['value']>,
1073
1083
  +computed: PropertyDefinitionType['computed'],
1074
1084
  +static: PropertyDefinitionType['static'],
1085
+ +decorators: $ReadOnlyArray<
1086
+ MaybeDetachedNode<PropertyDefinitionType['decorators'][number]>,
1087
+ >,
1075
1088
  +declare: PropertyDefinitionType['declare'],
1076
1089
  +optional: PropertyDefinitionType['optional'],
1077
1090
  +variance?: ?MaybeDetachedNode<PropertyDefinitionType['variance']>,
@@ -1649,6 +1662,7 @@ export function ComponentDeclaration(props: {
1649
1662
  body: asDetachedNodeForCodeGen(props.body),
1650
1663
  typeParameters: asDetachedNodeForCodeGen(props.typeParameters),
1651
1664
  rendersType: asDetachedNodeForCodeGen(props.rendersType),
1665
+ async: props.async,
1652
1666
  },
1653
1667
  );
1654
1668
  setParentPointersInDirectChildren((node: $FlowFixMe));
@@ -1946,6 +1960,18 @@ export function DeclareVariable(props: {
1946
1960
  return node;
1947
1961
  }
1948
1962
 
1963
+ export function Decorator(props: {
1964
+ ...DecoratorProps,
1965
+ +parent?: ESNode,
1966
+ }): DetachedNode<DecoratorType> {
1967
+ const node = detachedProps<DecoratorType>((props.parent: $FlowFixMe), {
1968
+ type: 'Decorator',
1969
+ expression: asDetachedNodeForCodeGen(props.expression),
1970
+ });
1971
+ setParentPointersInDirectChildren((node: $FlowFixMe));
1972
+ return node;
1973
+ }
1974
+
1949
1975
  export function DoWhileStatement(props: {
1950
1976
  ...DoWhileStatementProps,
1951
1977
  +parent?: ESNode,
@@ -2353,6 +2379,7 @@ export function HookDeclaration(props: {
2353
2379
  body: asDetachedNodeForCodeGen(props.body),
2354
2380
  typeParameters: asDetachedNodeForCodeGen(props.typeParameters),
2355
2381
  returnType: asDetachedNodeForCodeGen(props.returnType),
2382
+ async: props.async,
2356
2383
  });
2357
2384
  setParentPointersInDirectChildren((node: $FlowFixMe));
2358
2385
  return node;
@@ -2413,7 +2440,7 @@ export function ImportDeclaration(props: {
2413
2440
  type: 'ImportDeclaration',
2414
2441
  specifiers: props.specifiers.map(n => asDetachedNodeForCodeGen(n)),
2415
2442
  source: asDetachedNodeForCodeGen(props.source),
2416
- assertions: props.assertions?.map(n => asDetachedNodeForCodeGen(n)),
2443
+ attributes: props.attributes?.map(n => asDetachedNodeForCodeGen(n)),
2417
2444
  importKind: props.importKind,
2418
2445
  },
2419
2446
  );
@@ -3119,6 +3146,7 @@ export function MethodDefinition(props: {
3119
3146
  kind: props.kind,
3120
3147
  computed: props.computed,
3121
3148
  static: props.static,
3149
+ decorators: props.decorators.map(n => asDetachedNodeForCodeGen(n)),
3122
3150
  });
3123
3151
  setParentPointersInDirectChildren((node: $FlowFixMe));
3124
3152
  return node;
@@ -3425,6 +3453,7 @@ export function PropertyDefinition(props: {
3425
3453
  value: asDetachedNodeForCodeGen(props.value),
3426
3454
  computed: props.computed,
3427
3455
  static: props.static,
3456
+ decorators: props.decorators.map(n => asDetachedNodeForCodeGen(n)),
3428
3457
  declare: props.declare,
3429
3458
  optional: props.optional,
3430
3459
  variance: asDetachedNodeForCodeGen(props.variance),
@@ -66,6 +66,7 @@ var _exportNames = {
66
66
  DeclareOpaqueType: true,
67
67
  DeclareTypeAlias: true,
68
68
  DeclareVariable: true,
69
+ Decorator: true,
69
70
  DoWhileStatement: true,
70
71
  EmptyStatement: true,
71
72
  EmptyTypeAnnotation: true,
@@ -259,6 +260,7 @@ exports.DeclareOpaqueType = DeclareOpaqueType;
259
260
  exports.DeclareTypeAlias = DeclareTypeAlias;
260
261
  exports.DeclareVariable = DeclareVariable;
261
262
  exports.DeclaredPredicate = DeclaredPredicate;
263
+ exports.Decorator = Decorator;
262
264
  exports.DoWhileStatement = DoWhileStatement;
263
265
  exports.EmptyStatement = EmptyStatement;
264
266
  exports.EmptyTypeAnnotation = EmptyTypeAnnotation;
@@ -631,7 +633,8 @@ function ComponentDeclaration(props) {
631
633
  params: props.params.map(n => (0, _detachedNode.asDetachedNodeForCodeGen)(n)),
632
634
  body: (0, _detachedNode.asDetachedNodeForCodeGen)(props.body),
633
635
  typeParameters: (0, _detachedNode.asDetachedNodeForCodeGen)(props.typeParameters),
634
- rendersType: (0, _detachedNode.asDetachedNodeForCodeGen)(props.rendersType)
636
+ rendersType: (0, _detachedNode.asDetachedNodeForCodeGen)(props.rendersType),
637
+ async: props.async
635
638
  });
636
639
  (0, _detachedNode.setParentPointersInDirectChildren)(node);
637
640
  return node;
@@ -841,6 +844,15 @@ function DeclareVariable(props) {
841
844
  return node;
842
845
  }
843
846
 
847
+ function Decorator(props) {
848
+ const node = (0, _detachedNode.detachedProps)(props.parent, {
849
+ type: 'Decorator',
850
+ expression: (0, _detachedNode.asDetachedNodeForCodeGen)(props.expression)
851
+ });
852
+ (0, _detachedNode.setParentPointersInDirectChildren)(node);
853
+ return node;
854
+ }
855
+
844
856
  function DoWhileStatement(props) {
845
857
  const node = (0, _detachedNode.detachedProps)(props.parent, {
846
858
  type: 'DoWhileStatement',
@@ -1133,7 +1145,8 @@ function HookDeclaration(props) {
1133
1145
  params: props.params.map(n => (0, _detachedNode.asDetachedNodeForCodeGen)(n)),
1134
1146
  body: (0, _detachedNode.asDetachedNodeForCodeGen)(props.body),
1135
1147
  typeParameters: (0, _detachedNode.asDetachedNodeForCodeGen)(props.typeParameters),
1136
- returnType: (0, _detachedNode.asDetachedNodeForCodeGen)(props.returnType)
1148
+ returnType: (0, _detachedNode.asDetachedNodeForCodeGen)(props.returnType),
1149
+ async: props.async
1137
1150
  });
1138
1151
  (0, _detachedNode.setParentPointersInDirectChildren)(node);
1139
1152
  return node;
@@ -1173,13 +1186,13 @@ function ImportAttribute(props) {
1173
1186
  }
1174
1187
 
1175
1188
  function ImportDeclaration(props) {
1176
- var _props$assertions;
1189
+ var _props$attributes;
1177
1190
 
1178
1191
  const node = (0, _detachedNode.detachedProps)(props.parent, {
1179
1192
  type: 'ImportDeclaration',
1180
1193
  specifiers: props.specifiers.map(n => (0, _detachedNode.asDetachedNodeForCodeGen)(n)),
1181
1194
  source: (0, _detachedNode.asDetachedNodeForCodeGen)(props.source),
1182
- assertions: (_props$assertions = props.assertions) == null ? void 0 : _props$assertions.map(n => (0, _detachedNode.asDetachedNodeForCodeGen)(n)),
1195
+ attributes: (_props$attributes = props.attributes) == null ? void 0 : _props$attributes.map(n => (0, _detachedNode.asDetachedNodeForCodeGen)(n)),
1183
1196
  importKind: props.importKind
1184
1197
  });
1185
1198
  (0, _detachedNode.setParentPointersInDirectChildren)(node);
@@ -1655,7 +1668,8 @@ function MethodDefinition(props) {
1655
1668
  value: (0, _detachedNode.asDetachedNodeForCodeGen)(props.value),
1656
1669
  kind: props.kind,
1657
1670
  computed: props.computed,
1658
- static: props.static
1671
+ static: props.static,
1672
+ decorators: props.decorators.map(n => (0, _detachedNode.asDetachedNodeForCodeGen)(n))
1659
1673
  });
1660
1674
  (0, _detachedNode.setParentPointersInDirectChildren)(node);
1661
1675
  return node;
@@ -1865,6 +1879,7 @@ function PropertyDefinition(props) {
1865
1879
  value: (0, _detachedNode.asDetachedNodeForCodeGen)(props.value),
1866
1880
  computed: props.computed,
1867
1881
  static: props.static,
1882
+ decorators: props.decorators.map(n => (0, _detachedNode.asDetachedNodeForCodeGen)(n)),
1868
1883
  declare: props.declare,
1869
1884
  optional: props.optional,
1870
1885
  variance: (0, _detachedNode.asDetachedNodeForCodeGen)(props.variance),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hermes-transform",
3
- "version": "0.33.2",
3
+ "version": "0.34.0",
4
4
  "description": "Tools built on top of Hermes-ESTree to enable codebase transformation",
5
5
  "main": "dist/index.js",
6
6
  "license": "MIT",
@@ -12,9 +12,9 @@
12
12
  "@babel/code-frame": "^7.16.0",
13
13
  "esquery": "^1.4.0",
14
14
  "flow-enums-runtime": "^0.0.6",
15
- "hermes-eslint": "0.33.2",
16
- "hermes-estree": "0.33.2",
17
- "hermes-parser": "0.33.2",
15
+ "hermes-eslint": "0.34.0",
16
+ "hermes-estree": "0.34.0",
17
+ "hermes-parser": "0.34.0",
18
18
  "string-width": "4.2.3"
19
19
  },
20
20
  "peerDependencies": {