Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

hermes-parser

Package Overview
Dependencies
Maintainers
3
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hermes-parser - npm Package Compare versions

Comparing version
0.32.1
to
0.33.0
+294
dist/estree/TransformRecordSyntax.js
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
*/
'use strict';
/**
* Transform record declarations.
*/
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.transformProgram = transformProgram;
var _hermesEstree = require("hermes-estree");
var _SimpleTransform = require("../transform/SimpleTransform");
var _astNodeMutationHelpers = require("../transform/astNodeMutationHelpers");
var _Builders = require("../utils/Builders");
var _isReservedWord = _interopRequireDefault(require("../utils/isReservedWord"));
var _GenID = _interopRequireDefault(require("../utils/GenID"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function nameOfKey(key) {
switch (key.type) {
case 'Identifier':
return key.name;
case 'Literal':
if ((0, _hermesEstree.isBigIntLiteral)(key)) {
return key.bigint;
}
return String(key.value);
}
}
function mapRecordDeclaration(genID, node) {
const ownProperties = [];
const staticProperties = [];
const methods = [];
const staticMethods = [];
for (const element of node.body.elements) {
switch (element.type) {
case 'RecordDeclarationProperty':
ownProperties.push(element);
break;
case 'RecordDeclarationStaticProperty':
staticProperties.push(element);
break;
case 'MethodDefinition':
if (element.static) {
staticMethods.push(element);
} else {
methods.push(element);
}
break;
}
}
const reservedPropNames = new Map(); // Create constructor parameter as an object pattern with all properties
const constructorParam = {
type: 'ObjectPattern',
properties: ownProperties.map(prop => {
const {
key,
defaultValue
} = prop;
const keyName = nameOfKey(key);
const getValue = bindingIdent => defaultValue != null ? {
type: 'AssignmentPattern',
left: bindingIdent,
right: (0, _astNodeMutationHelpers.deepCloneNode)(defaultValue),
...(0, _Builders.etc)()
} : bindingIdent;
switch (key.type) {
case 'Identifier':
{
const needsNewBinding = (0, _isReservedWord.default)(keyName);
const bindingName = needsNewBinding ? genID.id() : keyName;
const bindingIdent = (0, _Builders.ident)(bindingName);
if (needsNewBinding) {
reservedPropNames.set(keyName, bindingName);
}
if (needsNewBinding) {
return {
type: 'Property',
kind: 'init',
key: (0, _astNodeMutationHelpers.shallowCloneNode)(key),
value: getValue(bindingIdent),
shorthand: false,
method: false,
computed: false,
...(0, _Builders.etc)(),
parent: _Builders.EMPTY_PARENT
};
} else {
return {
type: 'Property',
kind: 'init',
key: (0, _astNodeMutationHelpers.shallowCloneNode)(key),
value: getValue(bindingIdent),
shorthand: true,
method: false,
computed: false,
...(0, _Builders.etc)(),
parent: _Builders.EMPTY_PARENT
};
}
}
case 'Literal':
{
const bindingName = genID.id();
const bindingIdent = (0, _Builders.ident)(bindingName);
reservedPropNames.set(keyName, bindingName);
return {
type: 'Property',
kind: 'init',
key: (0, _astNodeMutationHelpers.shallowCloneNode)(key),
value: getValue(bindingIdent),
shorthand: false,
method: false,
computed: false,
...(0, _Builders.etc)(),
parent: _Builders.EMPTY_PARENT
};
}
}
}),
typeAnnotation: null,
...(0, _Builders.etc)()
}; // Create the constructor method
const constructor = {
type: 'MethodDefinition',
key: (0, _Builders.ident)('constructor'),
kind: 'constructor',
computed: false,
static: false,
value: {
type: 'FunctionExpression',
id: null,
params: [constructorParam],
body: {
type: 'BlockStatement',
body: ownProperties.map(({
key
}) => {
var _reservedPropNames$ge;
const keyName = nameOfKey(key);
const bindingIdent = (0, _Builders.ident)((_reservedPropNames$ge = reservedPropNames.get(keyName)) != null ? _reservedPropNames$ge : keyName);
const object = {
type: 'ThisExpression',
...(0, _Builders.etc)()
};
const memberExpression = key.type === 'Identifier' ? {
type: 'MemberExpression',
object,
property: (0, _astNodeMutationHelpers.shallowCloneNode)(key),
computed: false,
optional: false,
...(0, _Builders.etc)()
} : {
type: 'MemberExpression',
object,
property: (0, _astNodeMutationHelpers.shallowCloneNode)(key),
computed: true,
optional: false,
...(0, _Builders.etc)()
};
return {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: memberExpression,
right: bindingIdent,
...(0, _Builders.etc)()
},
directive: null,
...(0, _Builders.etc)()
};
}),
...(0, _Builders.etc)()
},
generator: false,
async: false,
predicate: null,
returnType: null,
typeParameters: null,
...(0, _Builders.etc)()
},
...(0, _Builders.etc)(),
parent: _Builders.EMPTY_PARENT
};
const classStaticProperties = staticProperties.map(prop => ({
type: 'PropertyDefinition',
key: (0, _astNodeMutationHelpers.shallowCloneNode)(prop.key),
value: (0, _astNodeMutationHelpers.deepCloneNode)(prop.value),
static: true,
typeAnnotation: null,
variance: null,
computed: false,
declare: false,
optional: false,
...(0, _Builders.etc)(),
parent: _Builders.EMPTY_PARENT
}));
const classBodyElements = [constructor, ...methods, ...classStaticProperties, ...staticMethods];
return {
type: 'ClassDeclaration',
id: (0, _astNodeMutationHelpers.shallowCloneNode)(node.id),
body: {
type: 'ClassBody',
body: classBodyElements,
...(0, _Builders.etc)(),
parent: _Builders.EMPTY_PARENT
},
superClass: null,
typeParameters: null,
superTypeArguments: null,
implements: [],
decorators: [],
...(0, _Builders.etc)()
};
}
function mapRecordExpression(node) {
const obj = {
type: 'ObjectExpression',
properties: node.properties.properties,
...(0, _Builders.etc)()
};
return {
type: 'NewExpression',
callee: node.recordConstructor,
arguments: [obj],
typeArguments: null,
...(0, _Builders.etc)()
};
}
function transformProgram(program, _options) {
const genID = new _GenID.default('r');
return _SimpleTransform.SimpleTransform.transformProgram(program, {
transform(node) {
switch (node.type) {
case 'RecordDeclaration':
{
return mapRecordDeclaration(genID, node);
}
case 'RecordExpression':
{
return mapRecordExpression(node);
}
case 'Identifier':
{
// A rudimentary check to avoid some collisions with our generated
// variable names. Ideally, we would have access a scope analyzer
// inside the transform instead.
genID.addUsage(node.name);
return node;
}
default:
return node;
}
}
});
}

Sorry, the diff of this file is not supported yet

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
*/
'use strict';
/**
* Transform record declarations.
*/
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.transformProgram = transformProgram;
var _hermesEstree = require("hermes-estree");
var _SimpleTransform = require("../transform/SimpleTransform");
var _astNodeMutationHelpers = require("../transform/astNodeMutationHelpers");
var _Builders = require("../utils/Builders");
var _isReservedWord = _interopRequireDefault(require("../utils/isReservedWord"));
var _GenID = _interopRequireDefault(require("../utils/GenID"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function nameOfKey(key) {
switch (key.type) {
case 'Identifier':
return key.name;
case 'Literal':
if ((0, _hermesEstree.isBigIntLiteral)(key)) {
return key.bigint;
}
return String(key.value);
}
}
function mapRecordDeclaration(genID, node) {
const ownProperties = [];
const staticProperties = [];
const methods = [];
const staticMethods = [];
for (const element of node.body.elements) {
switch (element.type) {
case 'RecordDeclarationProperty':
ownProperties.push(element);
break;
case 'RecordDeclarationStaticProperty':
staticProperties.push(element);
break;
case 'MethodDefinition':
if (element.static) {
staticMethods.push(element);
} else {
methods.push(element);
}
break;
}
}
const reservedPropNames = new Map(); // Create constructor parameter as an object pattern with all properties
const constructorParam = {
type: 'ObjectPattern',
properties: ownProperties.map(prop => {
const {
key,
defaultValue
} = prop;
const keyName = nameOfKey(key);
const getValue = bindingIdent => defaultValue != null ? {
type: 'AssignmentPattern',
left: bindingIdent,
right: (0, _astNodeMutationHelpers.deepCloneNode)(defaultValue),
...(0, _Builders.etc)()
} : bindingIdent;
switch (key.type) {
case 'Identifier':
{
const needsNewBinding = (0, _isReservedWord.default)(keyName);
const bindingName = needsNewBinding ? genID.id() : keyName;
const bindingIdent = (0, _Builders.ident)(bindingName);
if (needsNewBinding) {
reservedPropNames.set(keyName, bindingName);
}
if (needsNewBinding) {
return {
type: 'Property',
kind: 'init',
key: (0, _astNodeMutationHelpers.shallowCloneNode)(key),
value: getValue(bindingIdent),
shorthand: false,
method: false,
computed: false,
...(0, _Builders.etc)(),
parent: _Builders.EMPTY_PARENT
};
} else {
return {
type: 'Property',
kind: 'init',
key: (0, _astNodeMutationHelpers.shallowCloneNode)(key),
value: getValue(bindingIdent),
shorthand: true,
method: false,
computed: false,
...(0, _Builders.etc)(),
parent: _Builders.EMPTY_PARENT
};
}
}
case 'Literal':
{
const bindingName = genID.id();
const bindingIdent = (0, _Builders.ident)(bindingName);
reservedPropNames.set(keyName, bindingName);
return {
type: 'Property',
kind: 'init',
key: (0, _astNodeMutationHelpers.shallowCloneNode)(key),
value: getValue(bindingIdent),
shorthand: false,
method: false,
computed: false,
...(0, _Builders.etc)(),
parent: _Builders.EMPTY_PARENT
};
}
}
}),
typeAnnotation: null,
...(0, _Builders.etc)()
}; // Create the constructor method
const constructor = {
type: 'MethodDefinition',
key: (0, _Builders.ident)('constructor'),
kind: 'constructor',
computed: false,
static: false,
value: {
type: 'FunctionExpression',
id: null,
params: [constructorParam],
body: {
type: 'BlockStatement',
body: ownProperties.map(({
key
}) => {
var _reservedPropNames$ge;
const keyName = nameOfKey(key);
const bindingIdent = (0, _Builders.ident)((_reservedPropNames$ge = reservedPropNames.get(keyName)) != null ? _reservedPropNames$ge : keyName);
const object = {
type: 'ThisExpression',
...(0, _Builders.etc)()
};
const memberExpression = key.type === 'Identifier' ? {
type: 'MemberExpression',
object,
property: (0, _astNodeMutationHelpers.shallowCloneNode)(key),
computed: false,
optional: false,
...(0, _Builders.etc)()
} : {
type: 'MemberExpression',
object,
property: (0, _astNodeMutationHelpers.shallowCloneNode)(key),
computed: true,
optional: false,
...(0, _Builders.etc)()
};
return {
type: 'ExpressionStatement',
expression: {
type: 'AssignmentExpression',
operator: '=',
left: memberExpression,
right: bindingIdent,
...(0, _Builders.etc)()
},
directive: null,
...(0, _Builders.etc)()
};
}),
...(0, _Builders.etc)()
},
generator: false,
async: false,
predicate: null,
returnType: null,
typeParameters: null,
...(0, _Builders.etc)()
},
...(0, _Builders.etc)(),
parent: _Builders.EMPTY_PARENT
};
const classStaticProperties = staticProperties.map(prop => ({
type: 'PropertyDefinition',
key: (0, _astNodeMutationHelpers.shallowCloneNode)(prop.key),
value: (0, _astNodeMutationHelpers.deepCloneNode)(prop.value),
static: true,
typeAnnotation: null,
variance: null,
computed: false,
declare: false,
optional: false,
...(0, _Builders.etc)(),
parent: _Builders.EMPTY_PARENT
}));
const classBodyElements = [constructor, ...methods, ...classStaticProperties, ...staticMethods];
return {
type: 'ClassDeclaration',
id: (0, _astNodeMutationHelpers.shallowCloneNode)(node.id),
body: {
type: 'ClassBody',
body: classBodyElements,
...(0, _Builders.etc)(),
parent: _Builders.EMPTY_PARENT
},
superClass: null,
typeParameters: null,
superTypeArguments: null,
implements: [],
decorators: [],
...(0, _Builders.etc)()
};
}
function mapRecordExpression(node) {
const obj = {
type: 'ObjectExpression',
properties: node.properties.properties,
...(0, _Builders.etc)()
};
return {
type: 'NewExpression',
callee: node.recordConstructor,
arguments: [obj],
typeArguments: null,
...(0, _Builders.etc)()
};
}
function transformProgram(program, _options) {
const genID = new _GenID.default('r');
return _SimpleTransform.SimpleTransform.transformProgram(program, {
transform(node) {
switch (node.type) {
case 'RecordDeclaration':
{
return mapRecordDeclaration(genID, node);
}
case 'RecordExpression':
{
return mapRecordExpression(node);
}
case 'Identifier':
{
// A rudimentary check to avoid some collisions with our generated
// variable names. Ideally, we would have access a scope analyzer
// inside the transform instead.
genID.addUsage(node.name);
return node;
}
default:
return node;
}
}
});
}
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
*/
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = isReservedWord;
function isReservedWord(name) {
switch (name) {
case 'await':
case 'break':
case 'case':
case 'catch':
case 'class':
case 'const':
case 'continue':
case 'debugger':
case 'default':
case 'delete':
case 'do':
case 'else':
case 'enum':
case 'export':
case 'extends':
case 'false':
case 'finally':
case 'for':
case 'function':
case 'if':
case 'import':
case 'in':
case 'instanceof':
case 'new':
case 'null':
case 'return':
case 'super':
case 'switch':
case 'this':
case 'throw':
case 'true':
case 'try':
case 'typeof':
case 'var':
case 'void':
case 'while':
case 'with':
case 'yield':
return true;
default:
return false;
}
}
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
*/
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = isReservedWord;
function isReservedWord(name) {
switch (name) {
case 'await':
case 'break':
case 'case':
case 'catch':
case 'class':
case 'const':
case 'continue':
case 'debugger':
case 'default':
case 'delete':
case 'do':
case 'else':
case 'enum':
case 'export':
case 'extends':
case 'false':
case 'finally':
case 'for':
case 'function':
case 'if':
case 'import':
case 'in':
case 'instanceof':
case 'new':
case 'null':
case 'return':
case 'super':
case 'switch':
case 'this':
case 'throw':
case 'true':
case 'try':
case 'typeof':
case 'var':
case 'void':
case 'while':
case 'with':
case 'yield':
return true;
default:
return false;
}
}

Sorry, the diff of this file is not supported yet

+76
-3

@@ -33,2 +33,4 @@ /**

BooleanLiteral: [],
ClassExpression: ['superTypeParameters', ..._ESTreeVisitorKeys.default.ClassExpression],
ClassDeclaration: ['superTypeParameters', ..._ESTreeVisitorKeys.default.ClassDeclaration],
ClassMethod: ['key', 'params', 'body', 'returnType', 'typeParameters'],

@@ -54,2 +56,3 @@ ClassPrivateMethod: ['key', 'params', 'body', 'returnType', 'typeParameters'],

StringLiteral: [],
TupleTypeAnnotation: ['types'],
CommentBlock: [],

@@ -826,6 +829,70 @@ CommentLine: []

// $FlowExpectedError[cannot-write]
delete node.inexact;
delete node.inexact; // $FlowExpectedError[prop-missing]
node.types = node.elementTypes; // $FlowExpectedError[cannot-write]
delete node.elementTypes;
return node;
}
case 'UnknownTypeAnnotation':
{
return {
type: 'GenericTypeAnnotation',
id: {
type: 'Identifier',
name: 'unknown',
optional: false,
typeAnnotation: null,
loc: node.loc,
range: node.range,
parent: EMPTY_PARENT
},
typeParameters: null,
loc: node.loc,
range: node.range,
parent: EMPTY_PARENT
};
}
case 'NeverTypeAnnotation':
{
return {
type: 'GenericTypeAnnotation',
id: {
type: 'Identifier',
name: 'never',
optional: false,
typeAnnotation: null,
loc: node.loc,
range: node.range,
parent: EMPTY_PARENT
},
typeParameters: null,
loc: node.loc,
range: node.range,
parent: EMPTY_PARENT
};
}
case 'UndefinedTypeAnnotation':
{
return {
type: 'GenericTypeAnnotation',
id: {
type: 'Identifier',
name: 'undefined',
optional: false,
typeAnnotation: null,
loc: node.loc,
range: node.range,
parent: EMPTY_PARENT
},
typeParameters: null,
loc: node.loc,
range: node.range,
parent: EMPTY_PARENT
};
}
case 'JSXText':

@@ -993,5 +1060,11 @@ {

if (node.superTypeParameters == null) {
if (node.superTypeArguments == null) {
// $FlowExpectedError[cannot-write]
delete node.superTypeParameters;
delete node.superTypeArguments;
} else {
// $FlowExpectedError[cannot-write]
// $FlowExpectedError[prop-missing]
node.superTypeParameters = node.superTypeArguments; // $FlowExpectedError[cannot-write]
delete node.superTypeArguments;
}

@@ -998,0 +1071,0 @@

+1
-1

@@ -120,3 +120,3 @@ /**

typeParameters: null,
superTypeParameters: null,
superTypeArguments: null,
implements: [],

@@ -123,0 +123,0 @@ decorators: []

@@ -28,4 +28,6 @@ /**

var _GenID = require("../utils/GenID");
var _GenID = _interopRequireDefault(require("../utils/GenID"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**

@@ -35,10 +37,10 @@ * Generated identifiers.

*/
let GenID = null;
let genID = null;
function genIdent() {
if (GenID == null) {
if (genID == null) {
throw Error('GenID must be initialized at the start of the transform.');
}
return (0, _Builders.ident)(GenID.genID());
return (0, _Builders.ident)(genID.id());
}

@@ -143,2 +145,3 @@ /**

case 'MatchObjectPattern':
case 'MatchInstancePattern':
case 'MatchArrayPattern':

@@ -165,2 +168,74 @@ return false;

/**
* Analyzes properties of both object patterns and instance patterns.
*/
function analyzeProperties(key, pattern, seenBindingNames, properties, rest) {
const conditions = [];
const bindings = [];
const objKeys = [];
const seenNames = new Set();
properties.forEach(prop => {
const {
key: objKey,
pattern: propPattern
} = prop;
objKeys.push(objKey);
const name = objKeyToString(objKey);
if (seenNames.has(name)) {
throw (0, _createSyntaxError.createSyntaxError)(propPattern, `Duplicate property name '${name}' in match object pattern.`);
}
seenNames.add(name);
const propKey = key.concat(objKey);
if (needsPropExistsCond(propPattern)) {
conditions.push({
type: 'prop-exists',
key,
propName: name
});
}
const {
conditions: childConditions,
bindings: childBindings
} = analyzePattern(propPattern, propKey, seenBindingNames);
conditions.push(...childConditions);
bindings.push(...childBindings);
});
if (rest != null && rest.argument != null) {
const {
id,
kind
} = rest.argument;
checkDuplicateBindingName(seenBindingNames, rest.argument, id.name);
checkBindingKind(pattern, kind);
bindings.push({
type: 'object-rest',
key,
exclude: objKeys,
kind,
id
});
}
return {
conditions,
bindings
};
}
function constructorExpression(constructor) {
switch (constructor.type) {
case 'MatchIdentifierPattern':
return constructor.id;
case 'MatchMemberPattern':
return convertMemberPattern(constructor);
}
}
/**
* Analyzes a match pattern, and produced both the conditions and bindings

@@ -367,56 +442,34 @@ * produced by that pattern.

} = pattern;
const {
conditions: propertyConditions,
bindings
} = analyzeProperties(key, pattern, seenBindingNames, properties, rest);
const conditions = [{
type: 'object',
key
}];
const bindings = [];
const objKeys = [];
const seenNames = new Set();
properties.forEach(prop => {
const {
key: objKey,
pattern: propPattern
} = prop;
objKeys.push(objKey);
const name = objKeyToString(objKey);
}, ...propertyConditions];
return {
conditions,
bindings
};
}
if (seenNames.has(name)) {
throw (0, _createSyntaxError.createSyntaxError)(propPattern, `Duplicate property name '${name}' in match object pattern.`);
case 'MatchInstancePattern':
{
const {
targetConstructor,
properties: {
properties,
rest
}
seenNames.add(name);
const propKey = key.concat(objKey);
if (needsPropExistsCond(propPattern)) {
conditions.push({
type: 'prop-exists',
key,
propName: name
});
}
const {
conditions: childConditions,
bindings: childBindings
} = analyzePattern(propPattern, propKey, seenBindingNames);
conditions.push(...childConditions);
bindings.push(...childBindings);
});
if (rest != null && rest.argument != null) {
const {
id,
kind
} = rest.argument;
checkDuplicateBindingName(seenBindingNames, rest.argument, id.name);
checkBindingKind(pattern, kind);
bindings.push({
type: 'object-rest',
key,
exclude: objKeys,
kind,
id
});
}
} = pattern;
const {
conditions: propertyConditions,
bindings
} = analyzeProperties(key, pattern, seenBindingNames, properties, rest);
const conditions = [{
type: 'instanceof',
key,
constructor: constructorExpression(targetConstructor)
}, ...propertyConditions];
return {

@@ -575,2 +628,17 @@ conditions,

case 'instanceof':
{
const {
key,
constructor
} = condition;
return [{
type: 'BinaryExpression',
left: expressionOfKey(root, key),
right: constructor,
operator: 'instanceof',
...(0, _Builders.etc)()
}];
}
case 'prop-exists':

@@ -977,3 +1045,3 @@ {

// variable name counter, and has its own usage tracking.
GenID = (0, _GenID.createGenID)('m');
genID = new _GenID.default('m');
return _SimpleTransform.SimpleTransform.transformProgram(program, {

@@ -997,7 +1065,7 @@ transform(node) {

// inside the transform instead.
if (GenID == null) {
if (genID == null) {
throw Error('GenID must be initialized at the start of the transform.');
}
GenID.addUsage(node.name);
genID.addUsage(node.name);
return node;

@@ -1004,0 +1072,0 @@ }

@@ -29,3 +29,3 @@ /**

ArrayTypeAnnotation: ['elementType'],
ArrowFunctionExpression: ['id', 'params', 'body', 'typeParameters', 'returnType', 'predicate'],
ArrowFunctionExpression: ['params', 'body', 'typeParameters', 'returnType', 'predicate'],
AsConstExpression: ['expression'],

@@ -47,4 +47,4 @@ AsExpression: ['expression', 'typeAnnotation'],

ClassBody: ['body'],
ClassDeclaration: ['id', 'typeParameters', 'superClass', 'superTypeParameters', 'implements', 'decorators', 'body'],
ClassExpression: ['id', 'typeParameters', 'superClass', 'superTypeParameters', 'implements', 'decorators', 'body'],
ClassDeclaration: ['id', 'typeParameters', 'superClass', 'superTypeArguments', 'implements', 'decorators', 'body'],
ClassExpression: ['id', 'typeParameters', 'superClass', 'superTypeArguments', 'implements', 'decorators', 'body'],
ClassImplements: ['id', 'typeParameters'],

@@ -143,2 +143,4 @@ ComponentDeclaration: ['id', 'params', 'body', 'typeParameters', 'rendersType'],

MatchIdentifierPattern: ['id'],
MatchInstanceObjectPattern: ['properties', 'rest'],
MatchInstancePattern: ['targetConstructor', 'properties'],
MatchLiteralPattern: ['literal'],

@@ -158,2 +160,3 @@ MatchMemberPattern: ['base', 'property'],

MixedTypeAnnotation: [],
NeverTypeAnnotation: [],
NewExpression: ['callee', 'typeArguments', 'arguments'],

@@ -181,2 +184,9 @@ NullableTypeAnnotation: ['typeAnnotation'],

QualifiedTypeofIdentifier: ['qualification', 'id'],
RecordDeclaration: ['id', 'typeParameters', 'implements', 'body'],
RecordDeclarationBody: ['elements'],
RecordDeclarationImplements: ['id', 'typeArguments'],
RecordDeclarationProperty: ['key', 'typeAnnotation', 'defaultValue'],
RecordDeclarationStaticProperty: ['key', 'typeAnnotation', 'value'],
RecordExpression: ['recordConstructor', 'typeArguments', 'properties'],
RecordExpressionProperties: ['properties'],
RestElement: ['argument'],

@@ -200,3 +210,3 @@ ReturnStatement: ['argument'],

TryStatement: ['block', 'handler', 'finalizer'],
TupleTypeAnnotation: ['types'],
TupleTypeAnnotation: ['elementTypes'],
TupleTypeLabeledElement: ['label', 'elementType', 'variance'],

@@ -214,3 +224,5 @@ TupleTypeSpreadElement: ['label', 'typeAnnotation'],

UnaryExpression: ['argument'],
UndefinedTypeAnnotation: [],
UnionTypeAnnotation: ['types'],
UnknownTypeAnnotation: [],
UpdateExpression: ['argument'],

@@ -217,0 +229,0 @@ VariableDeclaration: ['declarations'],

@@ -45,3 +45,2 @@ /**

ArrowFunctionExpression: {
id: 'Node',
params: 'NodeList',

@@ -106,3 +105,3 @@ body: 'Node',

superClass: 'Node',
superTypeParameters: 'Node',
superTypeArguments: 'Node',
implements: 'NodeList',

@@ -116,3 +115,3 @@ decorators: 'NodeList',

superClass: 'Node',
superTypeParameters: 'Node',
superTypeArguments: 'Node',
implements: 'NodeList',

@@ -490,2 +489,10 @@ decorators: 'NodeList',

},
MatchInstanceObjectPattern: {
properties: 'NodeList',
rest: 'Node'
},
MatchInstancePattern: {
targetConstructor: 'Node',
properties: 'Node'
},
MatchLiteralPattern: {

@@ -538,2 +545,3 @@ literal: 'Node'

MixedTypeAnnotation: {},
NeverTypeAnnotation: {},
NewExpression: {

@@ -626,2 +634,33 @@ callee: 'Node',

},
RecordDeclaration: {
id: 'Node',
typeParameters: 'Node',
implements: 'NodeList',
body: 'Node'
},
RecordDeclarationBody: {
elements: 'NodeList'
},
RecordDeclarationImplements: {
id: 'Node',
typeArguments: 'Node'
},
RecordDeclarationProperty: {
key: 'Node',
typeAnnotation: 'Node',
defaultValue: 'Node'
},
RecordDeclarationStaticProperty: {
key: 'Node',
typeAnnotation: 'Node',
value: 'Node'
},
RecordExpression: {
recordConstructor: 'Node',
typeArguments: 'Node',
properties: 'Node'
},
RecordExpressionProperties: {
properties: 'NodeList'
},
RegExpLiteral: {},

@@ -676,3 +715,3 @@ RestElement: {

TupleTypeAnnotation: {
types: 'NodeList'
elementTypes: 'NodeList'
},

@@ -725,5 +764,7 @@ TupleTypeLabeledElement: {

},
UndefinedTypeAnnotation: {},
UnionTypeAnnotation: {
types: 'NodeList'
},
UnknownTypeAnnotation: {},
UpdateExpression: {

@@ -730,0 +771,0 @@ argument: 'Node'

@@ -54,3 +54,3 @@ /**

});
hermesParse = HermesParserWASM.cwrap('hermesParse', 'number', ['number', 'number', 'number', 'number', 'number', 'number', 'number']);
hermesParse = HermesParserWASM.cwrap('hermesParse', 'number', ['number', 'number', 'number', 'number', 'number', 'number', 'number', 'number']);
hermesParseResult_free = HermesParserWASM.cwrap('hermesParseResult_free', 'void', ['number']);

@@ -85,3 +85,3 @@ hermesParseResult_getError = HermesParserWASM.cwrap('hermesParseResult_getError', 'string', ['number']);

copyToHeap(sourceBuffer, sourceAddr);
const parseResult = hermesParse(sourceAddr, sourceBuffer.length + 1, options.flow === 'detect', options.enableExperimentalComponentSyntax, options.enableExperimentalFlowMatchSyntax, options.tokens, options.allowReturnOutsideFunction);
const parseResult = hermesParse(sourceAddr, sourceBuffer.length + 1, options.flow === 'detect', options.enableExperimentalComponentSyntax, options.enableExperimentalFlowMatchSyntax, options.enableExperimentalFlowRecordSyntax, options.tokens, options.allowReturnOutsideFunction);

@@ -88,0 +88,0 @@ try {

@@ -40,2 +40,4 @@ /**

var TransformRecordSyntax = _interopRequireWildcard(require("./estree/TransformRecordSyntax"));
var StripFlowTypesForBabel = _interopRequireWildcard(require("./estree/StripFlowTypesForBabel"));

@@ -130,2 +132,6 @@

if (options.enableExperimentalFlowRecordSyntax == null) {
options.enableExperimentalFlowRecordSyntax = true; // Enable by default
}
options.tokens = options.tokens === true;

@@ -147,3 +153,3 @@ options.allowReturnOutsideFunction = options.allowReturnOutsideFunction === true;

const loweredESTreeAST = [TransformEnumSyntax.transformProgram, TransformMatchSyntax.transformProgram, TransformComponentSyntax.transformProgram, StripFlowTypesForBabel.transformProgram].reduce((ast, transform) => transform(ast, options), estreeAST);
const loweredESTreeAST = [TransformEnumSyntax.transformProgram, TransformMatchSyntax.transformProgram, TransformComponentSyntax.transformProgram, TransformRecordSyntax.transformProgram, StripFlowTypesForBabel.transformProgram].reduce((ast, transform) => transform(ast, options), estreeAST);
return TransformESTreeToBabel.transformProgram(loweredESTreeAST, options);

@@ -156,2 +162,3 @@ }

transformComponentSyntax: TransformComponentSyntax.transformProgram,
transformRecordSyntax: TransformRecordSyntax.transformProgram,
stripFlowTypesForBabel: StripFlowTypesForBabel.transformProgram,

@@ -158,0 +165,0 @@ stripFlowTypes: StripFlowTypes.transformProgram

@@ -17,3 +17,3 @@ "use strict";

*/
const ParserOptionsKeys = new Set(['allowReturnOutsideFunction', 'babel', 'flow', 'enableExperimentalComponentSyntax', 'enableExperimentalFlowMatchSyntax', 'reactRuntimeTarget', 'sourceFilename', 'sourceType', 'tokens', 'transformOptions']);
const ParserOptionsKeys = new Set(['allowReturnOutsideFunction', 'babel', 'flow', 'enableExperimentalComponentSyntax', 'enableExperimentalFlowMatchSyntax', 'enableExperimentalFlowRecordSyntax', 'reactRuntimeTarget', 'sourceFilename', 'sourceType', 'tokens', 'transformOptions']);
exports.ParserOptionsKeys = ParserOptionsKeys;

@@ -33,2 +33,4 @@ /**

BooleanLiteral: [],
ClassExpression: ['superTypeParameters', ..._ESTreeVisitorKeys.default.ClassExpression],
ClassDeclaration: ['superTypeParameters', ..._ESTreeVisitorKeys.default.ClassDeclaration],
ClassMethod: ['key', 'params', 'body', 'returnType', 'typeParameters'],

@@ -54,2 +56,3 @@ ClassPrivateMethod: ['key', 'params', 'body', 'returnType', 'typeParameters'],

StringLiteral: [],
TupleTypeAnnotation: ['types'],
CommentBlock: [],

@@ -826,6 +829,70 @@ CommentLine: []

// $FlowExpectedError[cannot-write]
delete node.inexact;
delete node.inexact; // $FlowExpectedError[prop-missing]
node.types = node.elementTypes; // $FlowExpectedError[cannot-write]
delete node.elementTypes;
return node;
}
case 'UnknownTypeAnnotation':
{
return {
type: 'GenericTypeAnnotation',
id: {
type: 'Identifier',
name: 'unknown',
optional: false,
typeAnnotation: null,
loc: node.loc,
range: node.range,
parent: EMPTY_PARENT
},
typeParameters: null,
loc: node.loc,
range: node.range,
parent: EMPTY_PARENT
};
}
case 'NeverTypeAnnotation':
{
return {
type: 'GenericTypeAnnotation',
id: {
type: 'Identifier',
name: 'never',
optional: false,
typeAnnotation: null,
loc: node.loc,
range: node.range,
parent: EMPTY_PARENT
},
typeParameters: null,
loc: node.loc,
range: node.range,
parent: EMPTY_PARENT
};
}
case 'UndefinedTypeAnnotation':
{
return {
type: 'GenericTypeAnnotation',
id: {
type: 'Identifier',
name: 'undefined',
optional: false,
typeAnnotation: null,
loc: node.loc,
range: node.range,
parent: EMPTY_PARENT
},
typeParameters: null,
loc: node.loc,
range: node.range,
parent: EMPTY_PARENT
};
}
case 'JSXText':

@@ -993,5 +1060,11 @@ {

if (node.superTypeParameters == null) {
if (node.superTypeArguments == null) {
// $FlowExpectedError[cannot-write]
delete node.superTypeParameters;
delete node.superTypeArguments;
} else {
// $FlowExpectedError[cannot-write]
// $FlowExpectedError[prop-missing]
node.superTypeParameters = node.superTypeArguments; // $FlowExpectedError[cannot-write]
delete node.superTypeArguments;
}

@@ -998,0 +1071,0 @@

@@ -120,3 +120,3 @@ /**

typeParameters: null,
superTypeParameters: null,
superTypeArguments: null,
implements: [],

@@ -123,0 +123,0 @@ decorators: []

@@ -28,4 +28,6 @@ /**

var _GenID = require("../utils/GenID");
var _GenID = _interopRequireDefault(require("../utils/GenID"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**

@@ -35,10 +37,10 @@ * Generated identifiers.

*/
let GenID = null;
let genID = null;
function genIdent() {
if (GenID == null) {
if (genID == null) {
throw Error('GenID must be initialized at the start of the transform.');
}
return (0, _Builders.ident)(GenID.genID());
return (0, _Builders.ident)(genID.id());
}

@@ -143,2 +145,3 @@ /**

case 'MatchObjectPattern':
case 'MatchInstancePattern':
case 'MatchArrayPattern':

@@ -165,2 +168,74 @@ return false;

/**
* Analyzes properties of both object patterns and instance patterns.
*/
function analyzeProperties(key, pattern, seenBindingNames, properties, rest) {
const conditions = [];
const bindings = [];
const objKeys = [];
const seenNames = new Set();
properties.forEach(prop => {
const {
key: objKey,
pattern: propPattern
} = prop;
objKeys.push(objKey);
const name = objKeyToString(objKey);
if (seenNames.has(name)) {
throw (0, _createSyntaxError.createSyntaxError)(propPattern, `Duplicate property name '${name}' in match object pattern.`);
}
seenNames.add(name);
const propKey = key.concat(objKey);
if (needsPropExistsCond(propPattern)) {
conditions.push({
type: 'prop-exists',
key,
propName: name
});
}
const {
conditions: childConditions,
bindings: childBindings
} = analyzePattern(propPattern, propKey, seenBindingNames);
conditions.push(...childConditions);
bindings.push(...childBindings);
});
if (rest != null && rest.argument != null) {
const {
id,
kind
} = rest.argument;
checkDuplicateBindingName(seenBindingNames, rest.argument, id.name);
checkBindingKind(pattern, kind);
bindings.push({
type: 'object-rest',
key,
exclude: objKeys,
kind,
id
});
}
return {
conditions,
bindings
};
}
function constructorExpression(constructor) {
switch (constructor.type) {
case 'MatchIdentifierPattern':
return constructor.id;
case 'MatchMemberPattern':
return convertMemberPattern(constructor);
}
}
/**
* Analyzes a match pattern, and produced both the conditions and bindings

@@ -367,56 +442,34 @@ * produced by that pattern.

} = pattern;
const {
conditions: propertyConditions,
bindings
} = analyzeProperties(key, pattern, seenBindingNames, properties, rest);
const conditions = [{
type: 'object',
key
}];
const bindings = [];
const objKeys = [];
const seenNames = new Set();
properties.forEach(prop => {
const {
key: objKey,
pattern: propPattern
} = prop;
objKeys.push(objKey);
const name = objKeyToString(objKey);
}, ...propertyConditions];
return {
conditions,
bindings
};
}
if (seenNames.has(name)) {
throw (0, _createSyntaxError.createSyntaxError)(propPattern, `Duplicate property name '${name}' in match object pattern.`);
case 'MatchInstancePattern':
{
const {
targetConstructor,
properties: {
properties,
rest
}
seenNames.add(name);
const propKey = key.concat(objKey);
if (needsPropExistsCond(propPattern)) {
conditions.push({
type: 'prop-exists',
key,
propName: name
});
}
const {
conditions: childConditions,
bindings: childBindings
} = analyzePattern(propPattern, propKey, seenBindingNames);
conditions.push(...childConditions);
bindings.push(...childBindings);
});
if (rest != null && rest.argument != null) {
const {
id,
kind
} = rest.argument;
checkDuplicateBindingName(seenBindingNames, rest.argument, id.name);
checkBindingKind(pattern, kind);
bindings.push({
type: 'object-rest',
key,
exclude: objKeys,
kind,
id
});
}
} = pattern;
const {
conditions: propertyConditions,
bindings
} = analyzeProperties(key, pattern, seenBindingNames, properties, rest);
const conditions = [{
type: 'instanceof',
key,
constructor: constructorExpression(targetConstructor)
}, ...propertyConditions];
return {

@@ -575,2 +628,17 @@ conditions,

case 'instanceof':
{
const {
key,
constructor
} = condition;
return [{
type: 'BinaryExpression',
left: expressionOfKey(root, key),
right: constructor,
operator: 'instanceof',
...(0, _Builders.etc)()
}];
}
case 'prop-exists':

@@ -977,3 +1045,3 @@ {

// variable name counter, and has its own usage tracking.
GenID = (0, _GenID.createGenID)('m');
genID = new _GenID.default('m');
return _SimpleTransform.SimpleTransform.transformProgram(program, {

@@ -997,7 +1065,7 @@ transform(node) {

// inside the transform instead.
if (GenID == null) {
if (genID == null) {
throw Error('GenID must be initialized at the start of the transform.');
}
GenID.addUsage(node.name);
genID.addUsage(node.name);
return node;

@@ -1004,0 +1072,0 @@ }

@@ -29,3 +29,3 @@ /**

ArrayTypeAnnotation: ['elementType'],
ArrowFunctionExpression: ['id', 'params', 'body', 'typeParameters', 'returnType', 'predicate'],
ArrowFunctionExpression: ['params', 'body', 'typeParameters', 'returnType', 'predicate'],
AsConstExpression: ['expression'],

@@ -47,4 +47,4 @@ AsExpression: ['expression', 'typeAnnotation'],

ClassBody: ['body'],
ClassDeclaration: ['id', 'typeParameters', 'superClass', 'superTypeParameters', 'implements', 'decorators', 'body'],
ClassExpression: ['id', 'typeParameters', 'superClass', 'superTypeParameters', 'implements', 'decorators', 'body'],
ClassDeclaration: ['id', 'typeParameters', 'superClass', 'superTypeArguments', 'implements', 'decorators', 'body'],
ClassExpression: ['id', 'typeParameters', 'superClass', 'superTypeArguments', 'implements', 'decorators', 'body'],
ClassImplements: ['id', 'typeParameters'],

@@ -143,2 +143,4 @@ ComponentDeclaration: ['id', 'params', 'body', 'typeParameters', 'rendersType'],

MatchIdentifierPattern: ['id'],
MatchInstanceObjectPattern: ['properties', 'rest'],
MatchInstancePattern: ['targetConstructor', 'properties'],
MatchLiteralPattern: ['literal'],

@@ -158,2 +160,3 @@ MatchMemberPattern: ['base', 'property'],

MixedTypeAnnotation: [],
NeverTypeAnnotation: [],
NewExpression: ['callee', 'typeArguments', 'arguments'],

@@ -181,2 +184,9 @@ NullableTypeAnnotation: ['typeAnnotation'],

QualifiedTypeofIdentifier: ['qualification', 'id'],
RecordDeclaration: ['id', 'typeParameters', 'implements', 'body'],
RecordDeclarationBody: ['elements'],
RecordDeclarationImplements: ['id', 'typeArguments'],
RecordDeclarationProperty: ['key', 'typeAnnotation', 'defaultValue'],
RecordDeclarationStaticProperty: ['key', 'typeAnnotation', 'value'],
RecordExpression: ['recordConstructor', 'typeArguments', 'properties'],
RecordExpressionProperties: ['properties'],
RestElement: ['argument'],

@@ -200,3 +210,3 @@ ReturnStatement: ['argument'],

TryStatement: ['block', 'handler', 'finalizer'],
TupleTypeAnnotation: ['types'],
TupleTypeAnnotation: ['elementTypes'],
TupleTypeLabeledElement: ['label', 'elementType', 'variance'],

@@ -214,3 +224,5 @@ TupleTypeSpreadElement: ['label', 'typeAnnotation'],

UnaryExpression: ['argument'],
UndefinedTypeAnnotation: [],
UnionTypeAnnotation: ['types'],
UnknownTypeAnnotation: [],
UpdateExpression: ['argument'],

@@ -217,0 +229,0 @@ VariableDeclaration: ['declarations'],

@@ -45,3 +45,2 @@ /**

ArrowFunctionExpression: {
id: 'Node',
params: 'NodeList',

@@ -106,3 +105,3 @@ body: 'Node',

superClass: 'Node',
superTypeParameters: 'Node',
superTypeArguments: 'Node',
implements: 'NodeList',

@@ -116,3 +115,3 @@ decorators: 'NodeList',

superClass: 'Node',
superTypeParameters: 'Node',
superTypeArguments: 'Node',
implements: 'NodeList',

@@ -490,2 +489,10 @@ decorators: 'NodeList',

},
MatchInstanceObjectPattern: {
properties: 'NodeList',
rest: 'Node'
},
MatchInstancePattern: {
targetConstructor: 'Node',
properties: 'Node'
},
MatchLiteralPattern: {

@@ -538,2 +545,3 @@ literal: 'Node'

MixedTypeAnnotation: {},
NeverTypeAnnotation: {},
NewExpression: {

@@ -626,2 +634,33 @@ callee: 'Node',

},
RecordDeclaration: {
id: 'Node',
typeParameters: 'Node',
implements: 'NodeList',
body: 'Node'
},
RecordDeclarationBody: {
elements: 'NodeList'
},
RecordDeclarationImplements: {
id: 'Node',
typeArguments: 'Node'
},
RecordDeclarationProperty: {
key: 'Node',
typeAnnotation: 'Node',
defaultValue: 'Node'
},
RecordDeclarationStaticProperty: {
key: 'Node',
typeAnnotation: 'Node',
value: 'Node'
},
RecordExpression: {
recordConstructor: 'Node',
typeArguments: 'Node',
properties: 'Node'
},
RecordExpressionProperties: {
properties: 'NodeList'
},
RegExpLiteral: {},

@@ -676,3 +715,3 @@ RestElement: {

TupleTypeAnnotation: {
types: 'NodeList'
elementTypes: 'NodeList'
},

@@ -725,5 +764,7 @@ TupleTypeLabeledElement: {

},
UndefinedTypeAnnotation: {},
UnionTypeAnnotation: {
types: 'NodeList'
},
UnknownTypeAnnotation: {},
UpdateExpression: {

@@ -730,0 +771,0 @@ argument: 'Node'

@@ -54,3 +54,3 @@ /**

});
hermesParse = HermesParserWASM.cwrap('hermesParse', 'number', ['number', 'number', 'number', 'number', 'number', 'number', 'number']);
hermesParse = HermesParserWASM.cwrap('hermesParse', 'number', ['number', 'number', 'number', 'number', 'number', 'number', 'number', 'number']);
hermesParseResult_free = HermesParserWASM.cwrap('hermesParseResult_free', 'void', ['number']);

@@ -85,3 +85,3 @@ hermesParseResult_getError = HermesParserWASM.cwrap('hermesParseResult_getError', 'string', ['number']);

copyToHeap(sourceBuffer, sourceAddr);
const parseResult = hermesParse(sourceAddr, sourceBuffer.length + 1, options.flow === 'detect', options.enableExperimentalComponentSyntax, options.enableExperimentalFlowMatchSyntax, options.tokens, options.allowReturnOutsideFunction);
const parseResult = hermesParse(sourceAddr, sourceBuffer.length + 1, options.flow === 'detect', options.enableExperimentalComponentSyntax, options.enableExperimentalFlowMatchSyntax, options.enableExperimentalFlowRecordSyntax, options.tokens, options.allowReturnOutsideFunction);

@@ -88,0 +88,0 @@ try {

@@ -40,2 +40,4 @@ /**

var TransformRecordSyntax = _interopRequireWildcard(require("./estree/TransformRecordSyntax"));
var StripFlowTypesForBabel = _interopRequireWildcard(require("./estree/StripFlowTypesForBabel"));

@@ -130,2 +132,6 @@

if (options.enableExperimentalFlowRecordSyntax == null) {
options.enableExperimentalFlowRecordSyntax = true; // Enable by default
}
options.tokens = options.tokens === true;

@@ -147,3 +153,3 @@ options.allowReturnOutsideFunction = options.allowReturnOutsideFunction === true;

const loweredESTreeAST = [TransformEnumSyntax.transformProgram, TransformMatchSyntax.transformProgram, TransformComponentSyntax.transformProgram, StripFlowTypesForBabel.transformProgram].reduce((ast, transform) => transform(ast, options), estreeAST);
const loweredESTreeAST = [TransformEnumSyntax.transformProgram, TransformMatchSyntax.transformProgram, TransformComponentSyntax.transformProgram, TransformRecordSyntax.transformProgram, StripFlowTypesForBabel.transformProgram].reduce((ast, transform) => transform(ast, options), estreeAST);
return TransformESTreeToBabel.transformProgram(loweredESTreeAST, options);

@@ -156,2 +162,3 @@ }

transformComponentSyntax: TransformComponentSyntax.transformProgram,
transformRecordSyntax: TransformRecordSyntax.transformProgram,
stripFlowTypesForBabel: StripFlowTypesForBabel.transformProgram,

@@ -158,0 +165,0 @@ stripFlowTypes: StripFlowTypes.transformProgram

@@ -17,3 +17,3 @@ "use strict";

*/
const ParserOptionsKeys = new Set(['allowReturnOutsideFunction', 'babel', 'flow', 'enableExperimentalComponentSyntax', 'enableExperimentalFlowMatchSyntax', 'reactRuntimeTarget', 'sourceFilename', 'sourceType', 'tokens', 'transformOptions']);
const ParserOptionsKeys = new Set(['allowReturnOutsideFunction', 'babel', 'flow', 'enableExperimentalComponentSyntax', 'enableExperimentalFlowMatchSyntax', 'enableExperimentalFlowRecordSyntax', 'reactRuntimeTarget', 'sourceFilename', 'sourceType', 'tokens', 'transformOptions']);
exports.ParserOptionsKeys = ParserOptionsKeys;

@@ -15,28 +15,33 @@ /**

});
exports.createGenID = createGenID;
exports.default = void 0;
const genPrefix = '$$gen$';
function createGenID(uniqueTransformPrefix) {
let genN = 0;
const used = new Set();
return {
genID() {
let name;
class GenID {
constructor(uniqueTransformPrefix) {
this.genN = 0;
this.used = new Set();
this.prefix = void 0;
this.prefix = `${genPrefix}${uniqueTransformPrefix}`;
}
do {
name = `${genPrefix}${uniqueTransformPrefix}${genN}`;
genN++;
} while (used.has(name));
id() {
let name;
used.add(name);
return name;
},
do {
name = `${this.prefix}${this.genN}`;
this.genN++;
} while (this.used.has(name));
addUsage(name) {
if (name.startsWith(genPrefix)) {
used.add(name);
}
this.used.add(name);
return name;
}
addUsage(name) {
if (name.startsWith(this.prefix)) {
this.used.add(name);
}
}
};
}
}
exports.default = GenID;

@@ -15,28 +15,33 @@ /**

});
exports.createGenID = createGenID;
exports.default = void 0;
const genPrefix = '$$gen$';
function createGenID(uniqueTransformPrefix) {
let genN = 0;
const used = new Set();
return {
genID() {
let name;
class GenID {
constructor(uniqueTransformPrefix) {
this.genN = 0;
this.used = new Set();
this.prefix = void 0;
this.prefix = `${genPrefix}${uniqueTransformPrefix}`;
}
do {
name = `${genPrefix}${uniqueTransformPrefix}${genN}`;
genN++;
} while (used.has(name));
id() {
let name;
used.add(name);
return name;
},
do {
name = `${this.prefix}${this.genN}`;
this.genN++;
} while (this.used.has(name));
addUsage(name) {
if (name.startsWith(genPrefix)) {
used.add(name);
}
this.used.add(name);
return name;
}
addUsage(name) {
if (name.startsWith(this.prefix)) {
this.used.add(name);
}
}
};
}
}
exports.default = GenID;
{
"name": "hermes-parser",
"version": "0.32.1",
"version": "0.33.0",
"description": "A JavaScript parser built from the Hermes engine",

@@ -12,3 +12,3 @@ "main": "dist/index.js",

"dependencies": {
"hermes-estree": "0.32.1"
"hermes-estree": "0.33.0"
},

@@ -15,0 +15,0 @@ "devDependencies": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet