Socket
Socket
Sign inDemoInstall

@react-native/codegen

Package Overview
Dependencies
Maintainers
10
Versions
408
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@react-native/codegen - npm Package Compare versions

Comparing version 0.73.0-nightly-20230605-5062553c6 to 0.73.0-nightly-20230606-396cdac62

14

lib/parsers/flow/components/events.js

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

emitFloatProp = _require3.emitFloatProp,
emitMixedProp = _require3.emitMixedProp,
emitStringProp = _require3.emitStringProp,

@@ -74,9 +75,3 @@ emitInt32Prop = _require3.emitInt32Prop;

case 'UnsafeMixed':
return {
name,
optional,
typeAnnotation: {
type: 'MixedTypeAnnotation',
},
};
return emitMixedProp(name, optional);
case 'ArrayTypeAnnotation':

@@ -233,6 +228,3 @@ case '$ReadOnlyArray':

const optional = parser.isOptionalProperty(property);
let typeAnnotation =
property.value.type === 'NullableTypeAnnotation'
? property.value.typeAnnotation
: property.value;
const typeAnnotation = parser.getTypeAnnotationFromProperty(property);
return getPropertyType(name, optional, typeAnnotation, parser);

@@ -239,0 +231,0 @@ }

@@ -53,3 +53,5 @@ /**

buildSchema = _require3.buildSchema,
buildPropSchema = _require3.buildPropSchema;
buildPropSchema = _require3.buildPropSchema,
buildModuleSchema = _require3.buildModuleSchema,
handleGenericTypeAnnotation = _require3.handleGenericTypeAnnotation;
const _require4 = require('../parsers-primitives'),

@@ -61,8 +63,6 @@ Visitor = _require4.Visitor;

wrapComponentSchema = _require6.wrapComponentSchema;
const _require7 = require('../parsers-commons.js'),
buildModuleSchema = _require7.buildModuleSchema;
const fs = require('fs');
const _require8 = require('../errors'),
const _require7 = require('../errors'),
UnsupportedObjectPropertyTypeAnnotationParserError =
_require8.UnsupportedObjectPropertyTypeAnnotationParserError;
_require7.UnsupportedObjectPropertyTypeAnnotationParserError;
class FlowParser {

@@ -350,2 +350,7 @@ constructor() {

}
getTypeAnnotationFromProperty(property) {
return property.value.type === 'NullableTypeAnnotation'
? property.value.typeAnnotation
: property.value;
}
getGetTypeAnnotationFN() {

@@ -373,31 +378,16 @@ return getTypeAnnotation;

}
const resolvedTypeAnnotation = types[node.id.name];
const typeAnnotationName = this.nameForGenericTypeAnnotation(node);
const resolvedTypeAnnotation = types[typeAnnotationName];
if (resolvedTypeAnnotation == null) {
break;
}
switch (resolvedTypeAnnotation.type) {
case parser.typeAlias: {
typeResolutionStatus = {
successful: true,
type: 'alias',
name: node.id.name,
};
node = resolvedTypeAnnotation.right;
break;
}
case parser.enumDeclaration: {
typeResolutionStatus = {
successful: true,
type: 'enum',
name: node.id.name,
};
node = resolvedTypeAnnotation.body;
break;
}
default: {
throw new TypeError(
`A non GenericTypeAnnotation must be a type declaration ('${parser.typeAlias}') or enum ('${parser.enumDeclaration}'). Instead, got the unsupported ${resolvedTypeAnnotation.type}.`,
);
}
}
const _handleGenericTypeAnn = handleGenericTypeAnnotation(
node,
resolvedTypeAnnotation,
this,
),
typeAnnotationNode = _handleGenericTypeAnn.typeAnnotation,
status = _handleGenericTypeAnn.typeResolutionStatus;
typeResolutionStatus = status;
node = typeAnnotationNode;
}

@@ -468,2 +458,11 @@ return {

}
nextNodeForTypeAlias(typeAnnotation) {
return typeAnnotation.right;
}
nextNodeForEnum(typeAnnotation) {
return typeAnnotation.body;
}
genericTypeAnnotationErrorMessage(typeAnnotation) {
return `A non GenericTypeAnnotation must be a type declaration ('${this.typeAlias}') or enum ('${this.enumDeclaration}'). Instead, got the unsupported ${typeAnnotation.type}.`;
}
}

@@ -470,0 +469,0 @@ module.exports = {

@@ -248,2 +248,5 @@ /**

}
getTypeAnnotationFromProperty(property) {
return property.typeAnnotation.typeAnnotation;
}
getGetTypeAnnotationFN() {

@@ -385,2 +388,11 @@ return () => {

}
nextNodeForTypeAlias(typeAnnotation) {
return typeAnnotation.right;
}
nextNodeForEnum(typeAnnotation) {
return typeAnnotation.body;
}
genericTypeAnnotationErrorMessage(typeAnnotation) {
return `A non GenericTypeAnnotation must be a type declaration ('${this.typeAlias}') or enum ('${this.enumDeclaration}'). Instead, got the unsupported ${typeAnnotation.type}.`;
}
}

@@ -943,2 +943,56 @@ /**

}
function getTypeResolutionStatus(type, typeAnnotation, parser) {
return {
successful: true,
type,
name: parser.nameForGenericTypeAnnotation(typeAnnotation),
};
}
function handleGenericTypeAnnotation(
typeAnnotation,
resolvedTypeAnnotation,
parser,
) {
let typeResolutionStatus;
let node;
switch (resolvedTypeAnnotation.type) {
case parser.typeAlias: {
typeResolutionStatus = getTypeResolutionStatus(
'alias',
typeAnnotation,
parser,
);
node = parser.nextNodeForTypeAlias(resolvedTypeAnnotation);
break;
}
case parser.enumDeclaration: {
typeResolutionStatus = getTypeResolutionStatus(
'enum',
typeAnnotation,
parser,
);
node = parser.nextNodeForEnum(resolvedTypeAnnotation);
break;
}
// parser.interfaceDeclaration is not used here because for flow it should fall through to default case and throw an error
case 'TSInterfaceDeclaration': {
typeResolutionStatus = getTypeResolutionStatus(
'alias',
typeAnnotation,
parser,
);
node = resolvedTypeAnnotation;
break;
}
default: {
throw new TypeError(
parser.genericTypeAnnotationErrorMessage(resolvedTypeAnnotation),
);
}
}
return {
typeAnnotation: node,
typeResolutionStatus,
};
}
module.exports = {

@@ -968,2 +1022,4 @@ wrapModuleSchema,

getCommandProperties,
handleGenericTypeAnnotation,
getTypeResolutionStatus,
};

@@ -596,2 +596,11 @@ /**

}
function emitMixedProp(name, optional) {
return {
name,
optional,
typeAnnotation: {
type: 'MixedTypeAnnotation',
},
};
}
module.exports = {

@@ -608,2 +617,3 @@ emitArrayType,

emitInt32Prop,
emitMixedProp,
emitNumber,

@@ -610,0 +620,0 @@ emitGenericObject,

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

emitFloatProp = _require5.emitFloatProp,
emitMixedProp = _require5.emitMixedProp,
emitStringProp = _require5.emitStringProp,

@@ -79,9 +80,3 @@ emitInt32Prop = _require5.emitInt32Prop;

case 'UnsafeMixed':
return {
name,
optional,
typeAnnotation: {
type: 'MixedTypeAnnotation',
},
};
return emitMixedProp(name, optional);
case 'TSArrayType':

@@ -246,3 +241,3 @@ return {

const optional = parser.isOptionalProperty(property);
let typeAnnotation = property.typeAnnotation.typeAnnotation;
const typeAnnotation = parser.getTypeAnnotationFromProperty(property);
return getPropertyType(name, optional, typeAnnotation, parser);

@@ -249,0 +244,0 @@ }

@@ -48,24 +48,24 @@ /**

const babelParser = require('@babel/parser');
const _require2 = require('../parsers-commons'),
buildSchema = _require2.buildSchema;
const _require3 = require('../parsers-primitives'),
Visitor = _require3.Visitor;
const _require4 = require('./components'),
buildComponentSchema = _require4.buildComponentSchema;
const _require5 = require('../schema.js'),
wrapComponentSchema = _require5.wrapComponentSchema;
const _require6 = require('../parsers-commons.js'),
buildModuleSchema = _require6.buildModuleSchema,
extendsForProp = _require6.extendsForProp,
buildPropSchema = _require6.buildPropSchema;
const _require7 = require('./parseTopLevelType'),
parseTopLevelType = _require7.parseTopLevelType;
const _require8 = require('./components/componentsUtils'),
getSchemaInfo = _require8.getSchemaInfo,
getTypeAnnotation = _require8.getTypeAnnotation,
flattenProperties = _require8.flattenProperties;
const _require2 = require('../parsers-primitives'),
Visitor = _require2.Visitor;
const _require3 = require('./components'),
buildComponentSchema = _require3.buildComponentSchema;
const _require4 = require('../schema.js'),
wrapComponentSchema = _require4.wrapComponentSchema;
const _require5 = require('../parsers-commons.js'),
buildSchema = _require5.buildSchema,
buildModuleSchema = _require5.buildModuleSchema,
extendsForProp = _require5.extendsForProp,
buildPropSchema = _require5.buildPropSchema,
handleGenericTypeAnnotation = _require5.handleGenericTypeAnnotation;
const _require6 = require('./parseTopLevelType'),
parseTopLevelType = _require6.parseTopLevelType;
const _require7 = require('./components/componentsUtils'),
getSchemaInfo = _require7.getSchemaInfo,
getTypeAnnotation = _require7.getTypeAnnotation,
flattenProperties = _require7.flattenProperties;
const fs = require('fs');
const _require9 = require('../errors'),
const _require8 = require('../errors'),
UnsupportedObjectPropertyTypeAnnotationParserError =
_require9.UnsupportedObjectPropertyTypeAnnotationParserError;
_require8.UnsupportedObjectPropertyTypeAnnotationParserError;
class TypeScriptParser {

@@ -364,2 +364,5 @@ constructor() {

}
getTypeAnnotationFromProperty(property) {
return property.typeAnnotation.typeAnnotation;
}
getGetTypeAnnotationFN() {

@@ -393,40 +396,16 @@ return getTypeAnnotation;

}
const resolvedTypeAnnotation = types[node.typeName.name];
const typeAnnotationName = this.nameForGenericTypeAnnotation(node);
const resolvedTypeAnnotation = types[typeAnnotationName];
if (resolvedTypeAnnotation == null) {
break;
}
switch (resolvedTypeAnnotation.type) {
case parser.typeAlias: {
typeResolutionStatus = {
successful: true,
type: 'alias',
name: node.typeName.name,
};
node = resolvedTypeAnnotation.typeAnnotation;
break;
}
case parser.interfaceDeclaration: {
typeResolutionStatus = {
successful: true,
type: 'alias',
name: node.typeName.name,
};
node = resolvedTypeAnnotation;
break;
}
case parser.enumDeclaration: {
typeResolutionStatus = {
successful: true,
type: 'enum',
name: node.typeName.name,
};
node = resolvedTypeAnnotation;
break;
}
default: {
throw new TypeError(
`A non GenericTypeAnnotation must be a type declaration ('${parser.typeAlias}'), an interface ('${parser.interfaceDeclaration}'), or enum ('${parser.enumDeclaration}'). Instead, got the unsupported ${resolvedTypeAnnotation.type}.`,
);
}
}
const _handleGenericTypeAnn = handleGenericTypeAnnotation(
node,
resolvedTypeAnnotation,
this,
),
typeAnnotationNode = _handleGenericTypeAnn.typeAnnotation,
status = _handleGenericTypeAnn.typeResolutionStatus;
typeResolutionStatus = status;
node = typeAnnotationNode;
}

@@ -529,2 +508,11 @@ return {

}
nextNodeForTypeAlias(typeAnnotation) {
return typeAnnotation.typeAnnotation;
}
nextNodeForEnum(typeAnnotation) {
return typeAnnotation;
}
genericTypeAnnotationErrorMessage(typeAnnotation) {
return `A non GenericTypeAnnotation must be a type declaration ('${this.typeAlias}'), an interface ('${this.interfaceDeclaration}'), or enum ('${this.enumDeclaration}'). Instead, got the unsupported ${typeAnnotation.type}.`;
}
}

@@ -531,0 +519,0 @@ module.exports = {

{
"name": "@react-native/codegen",
"version": "0.73.0-nightly-20230605-5062553c6",
"version": "0.73.0-nightly-20230606-396cdac62",
"description": "Code generation tools for React Native",

@@ -5,0 +5,0 @@ "license": "MIT",

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 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc