@react-native/codegen 0.72.2 → 0.72.3
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.
- package/lib/parsers/error-utils.js +41 -0
- package/lib/parsers/error-utils.js.flow +45 -0
- package/lib/parsers/flow/components/index.js +16 -20
- package/lib/parsers/flow/components/index.js.flow +7 -6
- package/lib/parsers/flow/modules/index.js +26 -36
- package/lib/parsers/flow/modules/index.js.flow +21 -34
- package/lib/parsers/flow/parser.js +52 -1
- package/lib/parsers/flow/parser.js.flow +58 -1
- package/lib/parsers/flow/utils.js +0 -38
- package/lib/parsers/flow/utils.js.flow +0 -38
- package/lib/parsers/parser.js.flow +22 -0
- package/lib/parsers/parserMock.js +14 -0
- package/lib/parsers/parserMock.js.flow +21 -0
- package/lib/parsers/parsers-commons.js +1 -1
- package/lib/parsers/parsers-commons.js.flow +10 -4
- package/lib/parsers/{flow/components/schema.js.flow → schema.js.flow} +2 -2
- package/lib/parsers/typescript/components/index.js +15 -19
- package/lib/parsers/typescript/components/index.js.flow +7 -6
- package/lib/parsers/typescript/modules/index.js +27 -40
- package/lib/parsers/typescript/modules/index.js.flow +21 -34
- package/lib/parsers/typescript/parser.js +45 -1
- package/lib/parsers/typescript/parser.js.flow +48 -1
- package/lib/parsers/typescript/utils.js +0 -31
- package/lib/parsers/typescript/utils.js.flow +0 -31
- package/package.json +1 -1
- package/lib/parsers/flow/components/schema.js +0 -106
- package/lib/parsers/typescript/components/schema.js.flow +0 -62
- /package/lib/parsers/{typescript/components/schema.js → schema.js} +0 -0
|
@@ -14,36 +14,6 @@ import type {TypeResolutionStatus, TypeDeclarationMap} from '../utils';
|
|
|
14
14
|
|
|
15
15
|
const {parseTopLevelType} = require('./parseTopLevelType');
|
|
16
16
|
|
|
17
|
-
/**
|
|
18
|
-
* TODO(T108222691): Use flow-types for @babel/parser
|
|
19
|
-
*/
|
|
20
|
-
function getTypes(ast: $FlowFixMe): TypeDeclarationMap {
|
|
21
|
-
return ast.body.reduce((types, node) => {
|
|
22
|
-
switch (node.type) {
|
|
23
|
-
case 'ExportNamedDeclaration': {
|
|
24
|
-
if (node.declaration) {
|
|
25
|
-
switch (node.declaration.type) {
|
|
26
|
-
case 'TSTypeAliasDeclaration':
|
|
27
|
-
case 'TSInterfaceDeclaration':
|
|
28
|
-
case 'TSEnumDeclaration': {
|
|
29
|
-
types[node.declaration.id.name] = node.declaration;
|
|
30
|
-
break;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
break;
|
|
35
|
-
}
|
|
36
|
-
case 'TSTypeAliasDeclaration':
|
|
37
|
-
case 'TSInterfaceDeclaration':
|
|
38
|
-
case 'TSEnumDeclaration': {
|
|
39
|
-
types[node.id.name] = node;
|
|
40
|
-
break;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return types;
|
|
44
|
-
}, {});
|
|
45
|
-
}
|
|
46
|
-
|
|
47
17
|
// $FlowFixMe[unclear-type] Use flow-types for @babel/parser
|
|
48
18
|
export type ASTNode = Object;
|
|
49
19
|
|
|
@@ -131,5 +101,4 @@ function resolveTypeAnnotation(
|
|
|
131
101
|
|
|
132
102
|
module.exports = {
|
|
133
103
|
resolveTypeAnnotation,
|
|
134
|
-
getTypes,
|
|
135
104
|
};
|
package/package.json
CHANGED
|
@@ -1,106 +0,0 @@
|
|
|
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
|
-
*/
|
|
10
|
-
|
|
11
|
-
'use strict';
|
|
12
|
-
|
|
13
|
-
function ownKeys(object, enumerableOnly) {
|
|
14
|
-
var keys = Object.keys(object);
|
|
15
|
-
if (Object.getOwnPropertySymbols) {
|
|
16
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
17
|
-
enumerableOnly &&
|
|
18
|
-
(symbols = symbols.filter(function (sym) {
|
|
19
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
20
|
-
})),
|
|
21
|
-
keys.push.apply(keys, symbols);
|
|
22
|
-
}
|
|
23
|
-
return keys;
|
|
24
|
-
}
|
|
25
|
-
function _objectSpread(target) {
|
|
26
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
27
|
-
var source = null != arguments[i] ? arguments[i] : {};
|
|
28
|
-
i % 2
|
|
29
|
-
? ownKeys(Object(source), !0).forEach(function (key) {
|
|
30
|
-
_defineProperty(target, key, source[key]);
|
|
31
|
-
})
|
|
32
|
-
: Object.getOwnPropertyDescriptors
|
|
33
|
-
? Object.defineProperties(
|
|
34
|
-
target,
|
|
35
|
-
Object.getOwnPropertyDescriptors(source),
|
|
36
|
-
)
|
|
37
|
-
: ownKeys(Object(source)).forEach(function (key) {
|
|
38
|
-
Object.defineProperty(
|
|
39
|
-
target,
|
|
40
|
-
key,
|
|
41
|
-
Object.getOwnPropertyDescriptor(source, key),
|
|
42
|
-
);
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
return target;
|
|
46
|
-
}
|
|
47
|
-
function _defineProperty(obj, key, value) {
|
|
48
|
-
key = _toPropertyKey(key);
|
|
49
|
-
if (key in obj) {
|
|
50
|
-
Object.defineProperty(obj, key, {
|
|
51
|
-
value: value,
|
|
52
|
-
enumerable: true,
|
|
53
|
-
configurable: true,
|
|
54
|
-
writable: true,
|
|
55
|
-
});
|
|
56
|
-
} else {
|
|
57
|
-
obj[key] = value;
|
|
58
|
-
}
|
|
59
|
-
return obj;
|
|
60
|
-
}
|
|
61
|
-
function _toPropertyKey(arg) {
|
|
62
|
-
var key = _toPrimitive(arg, 'string');
|
|
63
|
-
return typeof key === 'symbol' ? key : String(key);
|
|
64
|
-
}
|
|
65
|
-
function _toPrimitive(input, hint) {
|
|
66
|
-
if (typeof input !== 'object' || input === null) return input;
|
|
67
|
-
var prim = input[Symbol.toPrimitive];
|
|
68
|
-
if (prim !== undefined) {
|
|
69
|
-
var res = prim.call(input, hint || 'default');
|
|
70
|
-
if (typeof res !== 'object') return res;
|
|
71
|
-
throw new TypeError('@@toPrimitive must return a primitive value.');
|
|
72
|
-
}
|
|
73
|
-
return (hint === 'string' ? String : Number)(input);
|
|
74
|
-
}
|
|
75
|
-
function wrapComponentSchema({
|
|
76
|
-
filename,
|
|
77
|
-
componentName,
|
|
78
|
-
extendsProps,
|
|
79
|
-
events,
|
|
80
|
-
props,
|
|
81
|
-
options,
|
|
82
|
-
commands,
|
|
83
|
-
}) {
|
|
84
|
-
return {
|
|
85
|
-
modules: {
|
|
86
|
-
[filename]: {
|
|
87
|
-
type: 'Component',
|
|
88
|
-
components: {
|
|
89
|
-
[componentName]: _objectSpread(
|
|
90
|
-
_objectSpread({}, options || {}),
|
|
91
|
-
{},
|
|
92
|
-
{
|
|
93
|
-
extendsProps,
|
|
94
|
-
events,
|
|
95
|
-
props,
|
|
96
|
-
commands,
|
|
97
|
-
},
|
|
98
|
-
),
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
|
-
},
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
module.exports = {
|
|
105
|
-
wrapComponentSchema,
|
|
106
|
-
};
|
|
@@ -1,62 +0,0 @@
|
|
|
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
|
-
* @format
|
|
8
|
-
* @flow strict
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
'use strict';
|
|
12
|
-
|
|
13
|
-
import type {
|
|
14
|
-
EventTypeShape,
|
|
15
|
-
NamedShape,
|
|
16
|
-
CommandTypeAnnotation,
|
|
17
|
-
PropTypeAnnotation,
|
|
18
|
-
ExtendsPropsShape,
|
|
19
|
-
SchemaType,
|
|
20
|
-
OptionsShape,
|
|
21
|
-
} from '../../../CodegenSchema.js';
|
|
22
|
-
|
|
23
|
-
export type ComponentSchemaBuilderConfig = $ReadOnly<{
|
|
24
|
-
filename: string,
|
|
25
|
-
componentName: string,
|
|
26
|
-
extendsProps: $ReadOnlyArray<ExtendsPropsShape>,
|
|
27
|
-
events: $ReadOnlyArray<EventTypeShape>,
|
|
28
|
-
props: $ReadOnlyArray<NamedShape<PropTypeAnnotation>>,
|
|
29
|
-
commands: $ReadOnlyArray<NamedShape<CommandTypeAnnotation>>,
|
|
30
|
-
options?: ?OptionsShape,
|
|
31
|
-
}>;
|
|
32
|
-
|
|
33
|
-
function wrapComponentSchema({
|
|
34
|
-
filename,
|
|
35
|
-
componentName,
|
|
36
|
-
extendsProps,
|
|
37
|
-
events,
|
|
38
|
-
props,
|
|
39
|
-
options,
|
|
40
|
-
commands,
|
|
41
|
-
}: ComponentSchemaBuilderConfig): SchemaType {
|
|
42
|
-
return {
|
|
43
|
-
modules: {
|
|
44
|
-
[filename]: {
|
|
45
|
-
type: 'Component',
|
|
46
|
-
components: {
|
|
47
|
-
[componentName]: {
|
|
48
|
-
...(options || {}),
|
|
49
|
-
extendsProps,
|
|
50
|
-
events,
|
|
51
|
-
props,
|
|
52
|
-
commands,
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
module.exports = {
|
|
61
|
-
wrapComponentSchema,
|
|
62
|
-
};
|
|
File without changes
|