@react-native/compatibility-check 0.0.0 → 0.0.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.
@@ -0,0 +1,71 @@
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
8
+ * @format
9
+ */
10
+
11
+ import type { ComparisonResult } from "./ComparisonResult";
12
+ import type {
13
+ DiffSet,
14
+ DiffSummary,
15
+ ErrorStore,
16
+ ObjectTypeChangeStore,
17
+ SchemaDiff,
18
+ } from "./DiffResults";
19
+ import type {
20
+ CompleteTypeAnnotation,
21
+ SchemaType,
22
+ } from "@react-native/codegen/src/CodegenSchema";
23
+
24
+ type BoundaryDirection = "toNative" | "fromNative" | "both";
25
+
26
+ // Exported for testing
27
+ declare export const removedPropertiesMessage: "Object removed required properties expected by native";
28
+ declare export const addedPropertiesMessage: "Object added required properties, which native will not provide";
29
+ declare export const stricterPropertiesMessage: "Property made strict, but native may not provide it";
30
+ declare export const tooOptionalPropertiesMessage: "Property made optional, but native requires it";
31
+ declare export const removedUnionMessage: "Union removed items, but native may still provide them";
32
+ declare export const addedUnionMessage: "Union added items, but native will not expect/support them";
33
+ declare export const removedEnumMessage: "Enum removed items, but native may still provide them";
34
+ declare export const addedEnumMessage: "Enum added items, but native will not expect/support them";
35
+ declare export const removedIntersectionMessage: "Intersection removed items, but native may still require properties contained in them";
36
+ declare export const addedIntersectionMessage: "Intersection added items, but native may not provide all required attributes";
37
+ declare export const toNativeVoidChangeMessage: "Native may not be able to safely handle presence of type";
38
+ declare export const typeNullableChangeMessage: "Type made nullable, but native requires it";
39
+ declare export const fromNativeVoidChangeMessage: "Type set to void but native may still provide a value";
40
+ declare export const typeNonNullableChangeMessage: "Type made non-nullable, but native might provide null still";
41
+ declare export function assessComparisonResult(
42
+ newTypes: Set<{
43
+ typeName: string,
44
+ typeInformation: CompleteTypeAnnotation,
45
+ ...
46
+ }>,
47
+ deprecatedTypes: Set<{
48
+ typeName: string,
49
+ typeInformation: CompleteTypeAnnotation,
50
+ ...
51
+ }>,
52
+ incompatibleChanges: Set<ErrorStore>,
53
+ objectTypeChanges: Set<ObjectTypeChangeStore>
54
+ ): (
55
+ typeName: string,
56
+ newType: CompleteTypeAnnotation,
57
+ oldType: ?CompleteTypeAnnotation,
58
+ difference: ComparisonResult,
59
+ oldDirection: BoundaryDirection
60
+ ) => void;
61
+
62
+ declare export function hasUpdatesTypes(diff: DiffSet): boolean;
63
+
64
+ declare export function hasCodegenUpdatesTypes(diff: DiffSet): boolean;
65
+
66
+ declare export function buildSchemaDiff(
67
+ newerSchemaSet: SchemaType,
68
+ olderSchemaSet: SchemaType
69
+ ): Set<SchemaDiff>;
70
+
71
+ declare export function summarizeDiffSet(diffs: Set<SchemaDiff>): DiffSummary;
@@ -0,0 +1,20 @@
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
+ * @oncall react_native
10
+ */
11
+
12
+ import type {
13
+ CompleteTypeAnnotation,
14
+ ComponentArrayTypeAnnotation,
15
+ PropTypeAnnotation,
16
+ } from "@react-native/codegen/src/CodegenSchema";
17
+ declare function convertPropToBasicTypes(
18
+ inputType: PropTypeAnnotation | ComponentArrayTypeAnnotation["elementType"]
19
+ ): CompleteTypeAnnotation;
20
+ export default convertPropToBasicTypes;
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true,
5
+ });
6
+ exports.default = convertPropToBasicTypes;
7
+ function convertPropToBasicTypes(inputType) {
8
+ let resultingType;
9
+ switch (inputType.type) {
10
+ case "BooleanTypeAnnotation":
11
+ resultingType = {
12
+ type: "BooleanTypeAnnotation",
13
+ };
14
+ break;
15
+ case "StringTypeAnnotation":
16
+ resultingType = {
17
+ type: "StringTypeAnnotation",
18
+ };
19
+ break;
20
+ case "DoubleTypeAnnotation":
21
+ resultingType = {
22
+ type: "DoubleTypeAnnotation",
23
+ };
24
+ break;
25
+ case "FloatTypeAnnotation":
26
+ resultingType = {
27
+ type: "FloatTypeAnnotation",
28
+ };
29
+ break;
30
+ case "Int32TypeAnnotation":
31
+ resultingType = {
32
+ type: "Int32TypeAnnotation",
33
+ };
34
+ break;
35
+ case "StringEnumTypeAnnotation":
36
+ resultingType = {
37
+ type: "StringLiteralUnionTypeAnnotation",
38
+ types: inputType.options.map((option) => {
39
+ return {
40
+ type: "StringLiteralTypeAnnotation",
41
+ value: option,
42
+ };
43
+ }),
44
+ };
45
+ break;
46
+ case "Int32EnumTypeAnnotation":
47
+ resultingType = {
48
+ type: "AnyTypeAnnotation",
49
+ };
50
+ break;
51
+ case "ReservedPropTypeAnnotation":
52
+ resultingType = {
53
+ type: "ReservedTypeAnnotation",
54
+ name: inputType.name,
55
+ };
56
+ break;
57
+ case "MixedTypeAnnotation":
58
+ resultingType = inputType;
59
+ break;
60
+ case "ObjectTypeAnnotation":
61
+ resultingType = {
62
+ type: "ObjectTypeAnnotation",
63
+ ...(inputType.baseTypes != null
64
+ ? {
65
+ baseTypes: inputType.baseTypes,
66
+ }
67
+ : {}),
68
+ properties: inputType.properties.map((property) => ({
69
+ name: property.name,
70
+ optional: property.optional,
71
+ typeAnnotation: convertPropToBasicTypes(property.typeAnnotation),
72
+ })),
73
+ };
74
+ break;
75
+ case "ArrayTypeAnnotation":
76
+ resultingType = {
77
+ type: "ArrayTypeAnnotation",
78
+ elementType: convertPropToBasicTypes(inputType.elementType),
79
+ };
80
+ break;
81
+ default:
82
+ inputType.type;
83
+ throw new Error("Unexpected type " + inputType.type);
84
+ }
85
+ return resultingType;
86
+ }
@@ -0,0 +1,20 @@
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-local
8
+ * @format
9
+ * @oncall react_native
10
+ */
11
+
12
+ import type {
13
+ CompleteTypeAnnotation,
14
+ ComponentArrayTypeAnnotation,
15
+ PropTypeAnnotation,
16
+ } from "@react-native/codegen/src/CodegenSchema";
17
+
18
+ declare export default function convertPropToBasicTypes(
19
+ inputType: PropTypeAnnotation | ComponentArrayTypeAnnotation["elementType"]
20
+ ): CompleteTypeAnnotation;
@@ -0,0 +1,12 @@
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
+ * @oncall react_native
10
+ */
11
+
12
+ export { compareSchemas } from "./index.js";
package/dist/index.js ADDED
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true,
5
+ });
6
+ Object.defineProperty(exports, "compareSchemas", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _index.compareSchemas;
10
+ },
11
+ });
12
+ var _index = require("./index.js");
@@ -0,0 +1,12 @@
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-local
8
+ * @format
9
+ * @oncall react_native
10
+ */
11
+
12
+ export { compareSchemas } from "./index.js";
package/package.json CHANGED
@@ -1,10 +1,38 @@
1
1
  {
2
2
  "name": "@react-native/compatibility-check",
3
- "version": "0.0.0",
3
+ "version": "0.0.1",
4
4
  "description": "Check a React Native app's boundary between JS and Native for incompatibilities",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
8
- "url": "git+https://github.com/facebook/react-native.git"
8
+ "url": "git+https://github.com/facebook/react-native.git",
9
+ "directory": "packages/react-native-compatibility-check"
10
+ },
11
+ "homepage": "https://github.com/facebook/react-native/tree/HEAD/packages/react-native-compatibility-check#readme",
12
+ "keywords": [
13
+ "boundary",
14
+ "crashes",
15
+ "native",
16
+ "codegen",
17
+ "tools",
18
+ "react-native"
19
+ ],
20
+ "bugs": "https://github.com/facebook/react-native/issues",
21
+ "engines": {
22
+ "node": ">=18"
23
+ },
24
+ "exports": {
25
+ ".": "./dist/index.js",
26
+ "./package.json": "./package.json"
27
+ },
28
+ "files": [
29
+ "dist"
30
+ ],
31
+ "dependencies": {
32
+ "@react-native/codegen": "0.79.0-main"
33
+ },
34
+ "devDependencies": {
35
+ "flow-remove-types": "^2.237.2",
36
+ "rimraf": "^3.0.2"
9
37
  }
10
- }
38
+ }