Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@react-native/codegen

Package Overview
Dependencies
Maintainers
2
Versions
488
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.77.0-nightly-20241113-d3c5446a6 to 0.77.0-nightly-20241114-316170ce8

29

lib/parsers/flow/modules/__test_fixtures__/failures.js

@@ -258,2 +258,30 @@ /**

`;
const NUMERIC_VALUES_ENUM_NATIVE_MODULE = `
/**
* 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.
*
* @flow strict-local
* @format
*/
'use strict';
import type {TurboModule} from '../RCTExport';
import * as TurboModuleRegistry from '../TurboModuleRegistry';
export enum SomeEnum {
NUM = 1,
NEGATIVE = -1,
SUBFACTORIAL = !5,
}
export interface Spec extends TurboModule {
+getEnums: (a: SomeEnum) => string;
}
export default TurboModuleRegistry.getEnforcing<Spec>('NumericValuesEnumNativeModule');
`;
const MAP_WITH_EXTRA_KEYS_NATIVE_MODULE = `

@@ -297,3 +325,4 @@ /**

MIXED_VALUES_ENUM_NATIVE_MODULE,
NUMERIC_VALUES_ENUM_NATIVE_MODULE,
MAP_WITH_EXTRA_KEYS_NATIVE_MODULE,
};

1

lib/parsers/flow/modules/__test_fixtures__/fixtures.js

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

export enum Resolution {
Corrupted = -1,
Low = 720,

@@ -762,0 +763,0 @@ High = 1080,

@@ -202,2 +202,29 @@ /**

`;
const NUMERIC_VALUES_ENUM_NATIVE_MODULE = `
/**
* 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
*/
import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport';
import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry';
export enum SomeEnum {
NUM = 1,
NEGATIVE = -1,
SUBFACTORIAL = !5,
}
export interface Spec extends TurboModule {
readonly getEnums: (a: SomeEnum) => string;
}
export default TurboModuleRegistry.getEnforcing<Spec>(
'NumericValuesEnumNativeModule',
);
`;
const MAP_WITH_EXTRA_KEYS_NATIVE_MODULE = `

@@ -237,3 +264,4 @@ /**

MIXED_VALUES_ENUM_NATIVE_MODULE,
NUMERIC_VALUES_ENUM_NATIVE_MODULE,
MAP_WITH_EXTRA_KEYS_NATIVE_MODULE,
};

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

export enum Resolution {
Corrupted = -1,
Low = 720,

@@ -840,0 +841,0 @@ High = 1080,

@@ -180,8 +180,25 @@ /**

: _typeAnnotation$membe.initializer;
const enumMembersType =
!enumInitializer || enumInitializer.type === 'StringLiteral'
? 'StringTypeAnnotation'
: enumInitializer.type === 'NumericLiteral'
? 'NumberTypeAnnotation'
: null;
const enumInitializerType =
enumInitializer === null || enumInitializer === void 0
? void 0
: enumInitializer.type;
let enumMembersType = null;
if (!enumInitializerType) {
return 'StringTypeAnnotation';
}
switch (enumInitializerType) {
case 'StringLiteral':
enumMembersType = 'StringTypeAnnotation';
break;
case 'NumericLiteral':
enumMembersType = 'NumberTypeAnnotation';
break;
case 'UnaryExpression':
if (enumInitializer.operator === '-') {
enumMembersType = 'NumberTypeAnnotation';
}
break;
default:
enumMembersType = null;
}
if (!enumMembersType) {

@@ -205,11 +222,29 @@ throw new Error(

typeAnnotation.members.forEach(member => {
var _member$initializer$t, _member$initializer;
var _member$initializer,
_member$initializer2,
_member$initializer3,
_member$initializer4;
const isNegative =
((_member$initializer = member.initializer) === null ||
_member$initializer === void 0
? void 0
: _member$initializer.type) === 'UnaryExpression' &&
((_member$initializer2 = member.initializer) === null ||
_member$initializer2 === void 0
? void 0
: _member$initializer2.operator) === '-';
const initializerType = isNegative
? (_member$initializer3 = member.initializer) === null ||
_member$initializer3 === void 0 ||
(_member$initializer3 = _member$initializer3.argument) === null ||
_member$initializer3 === void 0
? void 0
: _member$initializer3.type
: (_member$initializer4 = member.initializer) === null ||
_member$initializer4 === void 0
? void 0
: _member$initializer4.type;
if (
((_member$initializer$t =
(_member$initializer = member.initializer) === null ||
_member$initializer === void 0
? void 0
: _member$initializer.type) !== null &&
_member$initializer$t !== void 0
? _member$initializer$t
(initializerType !== null && initializerType !== void 0
? initializerType
: 'StringLiteral') !== enumInitializerType

@@ -225,3 +260,26 @@ ) {

return typeAnnotation.members.map(member => {
var _member$initializer$v, _member$initializer2;
var _member$initializer5, _member$initializer$v, _member$initializer7;
// Handle negative values
if (
((_member$initializer5 = member.initializer) === null ||
_member$initializer5 === void 0
? void 0
: _member$initializer5.operator) === '-'
) {
var _member$initializer$a, _member$initializer6;
return {
name: member.id.name,
value:
(_member$initializer$a = -((_member$initializer6 =
member.initializer) === null ||
_member$initializer6 === void 0 ||
(_member$initializer6 = _member$initializer6.argument) === null ||
_member$initializer6 === void 0
? void 0
: _member$initializer6.value)) !== null &&
_member$initializer$a !== void 0
? _member$initializer$a
: member.id.name,
};
}
return {

@@ -231,6 +289,6 @@ name: member.id.name,

(_member$initializer$v =
(_member$initializer2 = member.initializer) === null ||
_member$initializer2 === void 0
(_member$initializer7 = member.initializer) === null ||
_member$initializer7 === void 0
? void 0
: _member$initializer2.value) !== null &&
: _member$initializer7.value) !== null &&
_member$initializer$v !== void 0

@@ -237,0 +295,0 @@ ? _member$initializer$v

2

package.json
{
"name": "@react-native/codegen",
"version": "0.77.0-nightly-20241113-d3c5446a6",
"version": "0.77.0-nightly-20241114-316170ce8",
"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

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