@react-native/codegen 0.74.0-nightly-20231217-2441fa284 → 0.74.0-nightly-20231220-dae4a11e9
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/cli/combine/combine-js-to-schema-cli.js +59 -8
- package/lib/cli/combine/combine-js-to-schema-cli.js.flow +20 -4
- package/lib/cli/combine/combine-schemas-cli.js +19 -20
- package/lib/cli/combine/combine-schemas-cli.js.flow +21 -19
- package/lib/cli/combine/combine-utils.js +0 -68
- package/lib/cli/combine/combine-utils.js.flow +0 -38
- package/lib/generators/RNCodegen.js +29 -11
- package/lib/generators/RNCodegen.js.flow +23 -10
- package/lib/generators/components/GenerateComponentDescriptorH.js +11 -4
- package/lib/generators/components/GenerateComponentDescriptorH.js.flow +5 -4
- package/lib/generators/components/GenerateComponentHObjCpp.js +7 -1
- package/lib/generators/components/GenerateComponentHObjCpp.js.flow +1 -0
- package/lib/generators/components/GenerateEventEmitterCpp.js +11 -4
- package/lib/generators/components/GenerateEventEmitterCpp.js.flow +5 -4
- package/lib/generators/components/GenerateEventEmitterH.js +7 -1
- package/lib/generators/components/GenerateEventEmitterH.js.flow +1 -0
- package/lib/generators/components/GeneratePropsCpp.js +11 -4
- package/lib/generators/components/GeneratePropsCpp.js.flow +5 -4
- package/lib/generators/components/GeneratePropsH.js +7 -1
- package/lib/generators/components/GeneratePropsH.js.flow +1 -0
- package/lib/generators/components/GeneratePropsJavaDelegate.js +7 -1
- package/lib/generators/components/GeneratePropsJavaDelegate.js.flow +1 -0
- package/lib/generators/components/GeneratePropsJavaInterface.js +7 -1
- package/lib/generators/components/GeneratePropsJavaInterface.js.flow +1 -0
- package/lib/generators/components/GenerateShadowNodeCpp.js +11 -4
- package/lib/generators/components/GenerateShadowNodeCpp.js.flow +5 -4
- package/lib/generators/components/GenerateShadowNodeH.js +13 -7
- package/lib/generators/components/GenerateShadowNodeH.js.flow +7 -10
- package/lib/generators/components/GenerateStateCpp.js +11 -4
- package/lib/generators/components/GenerateStateCpp.js.flow +5 -4
- package/lib/generators/components/GenerateStateH.js +7 -1
- package/lib/generators/components/GenerateStateH.js.flow +1 -0
- package/lib/generators/components/GenerateTests.js +7 -1
- package/lib/generators/components/GenerateTests.js.flow +1 -0
- package/lib/generators/modules/GenerateModuleCpp.js +7 -1
- package/lib/generators/modules/GenerateModuleCpp.js.flow +1 -0
- package/lib/generators/modules/GenerateModuleH.js +7 -1
- package/lib/generators/modules/GenerateModuleH.js.flow +1 -0
- package/lib/generators/modules/GenerateModuleJavaSpec.js +7 -1
- package/lib/generators/modules/GenerateModuleJavaSpec.js.flow +1 -0
- package/lib/generators/modules/GenerateModuleJniCpp.js +7 -1
- package/lib/generators/modules/GenerateModuleJniCpp.js.flow +1 -0
- package/lib/generators/modules/GenerateModuleJniH.js +7 -1
- package/lib/generators/modules/GenerateModuleJniH.js.flow +1 -0
- package/lib/generators/modules/GenerateModuleObjCpp/index.js +1 -1
- package/lib/generators/modules/GenerateModuleObjCpp/index.js.flow +1 -0
- package/package.json +5 -4
|
@@ -11,14 +11,65 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
+
function _toArray(arr) {
|
|
15
|
+
return (
|
|
16
|
+
_arrayWithHoles(arr) ||
|
|
17
|
+
_iterableToArray(arr) ||
|
|
18
|
+
_unsupportedIterableToArray(arr) ||
|
|
19
|
+
_nonIterableRest()
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
function _nonIterableRest() {
|
|
23
|
+
throw new TypeError(
|
|
24
|
+
'Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.',
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
28
|
+
if (!o) return;
|
|
29
|
+
if (typeof o === 'string') return _arrayLikeToArray(o, minLen);
|
|
30
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
31
|
+
if (n === 'Object' && o.constructor) n = o.constructor.name;
|
|
32
|
+
if (n === 'Map' || n === 'Set') return Array.from(o);
|
|
33
|
+
if (n === 'Arguments' || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
|
|
34
|
+
return _arrayLikeToArray(o, minLen);
|
|
35
|
+
}
|
|
36
|
+
function _arrayLikeToArray(arr, len) {
|
|
37
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
38
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
39
|
+
return arr2;
|
|
40
|
+
}
|
|
41
|
+
function _iterableToArray(iter) {
|
|
42
|
+
if (
|
|
43
|
+
(typeof Symbol !== 'undefined' && iter[Symbol.iterator] != null) ||
|
|
44
|
+
iter['@@iterator'] != null
|
|
45
|
+
)
|
|
46
|
+
return Array.from(iter);
|
|
47
|
+
}
|
|
48
|
+
function _arrayWithHoles(arr) {
|
|
49
|
+
if (Array.isArray(arr)) return arr;
|
|
50
|
+
}
|
|
14
51
|
const _require = require('./combine-js-to-schema'),
|
|
15
52
|
combineSchemasInFileListAndWriteToFile =
|
|
16
53
|
_require.combineSchemasInFileListAndWriteToFile;
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
54
|
+
const yargs = require('yargs');
|
|
55
|
+
const argv = yargs
|
|
56
|
+
.option('p', {
|
|
57
|
+
alias: 'platform',
|
|
58
|
+
})
|
|
59
|
+
.option('e', {
|
|
60
|
+
alias: 'exclude',
|
|
61
|
+
})
|
|
62
|
+
.parseSync();
|
|
63
|
+
const _argv$_ = _toArray(argv._),
|
|
64
|
+
outfile = _argv$_[0],
|
|
65
|
+
fileList = _argv$_.slice(1);
|
|
66
|
+
const platform = argv.platform;
|
|
67
|
+
const exclude = argv.exclude;
|
|
68
|
+
const excludeRegExp =
|
|
69
|
+
exclude != null && exclude !== '' ? new RegExp(exclude) : null;
|
|
70
|
+
combineSchemasInFileListAndWriteToFile(
|
|
71
|
+
fileList,
|
|
72
|
+
platform != null ? platform.toLowerCase() : platform,
|
|
73
|
+
outfile,
|
|
74
|
+
excludeRegExp,
|
|
75
|
+
);
|
|
@@ -14,10 +14,26 @@
|
|
|
14
14
|
const {
|
|
15
15
|
combineSchemasInFileListAndWriteToFile,
|
|
16
16
|
} = require('./combine-js-to-schema');
|
|
17
|
-
const
|
|
17
|
+
const yargs = require('yargs');
|
|
18
18
|
|
|
19
|
-
const
|
|
19
|
+
const argv = yargs
|
|
20
|
+
.option('p', {
|
|
21
|
+
alias: 'platform',
|
|
22
|
+
})
|
|
23
|
+
.option('e', {
|
|
24
|
+
alias: 'exclude',
|
|
25
|
+
})
|
|
26
|
+
.parseSync();
|
|
20
27
|
|
|
21
|
-
const
|
|
28
|
+
const [outfile, ...fileList] = argv._;
|
|
29
|
+
const platform: ?string = argv.platform;
|
|
30
|
+
const exclude: string = argv.exclude;
|
|
31
|
+
const excludeRegExp: ?RegExp =
|
|
32
|
+
exclude != null && exclude !== '' ? new RegExp(exclude) : null;
|
|
22
33
|
|
|
23
|
-
combineSchemasInFileListAndWriteToFile(
|
|
34
|
+
combineSchemasInFileListAndWriteToFile(
|
|
35
|
+
fileList,
|
|
36
|
+
platform != null ? platform.toLowerCase() : platform,
|
|
37
|
+
outfile,
|
|
38
|
+
excludeRegExp,
|
|
39
|
+
);
|
|
@@ -12,27 +12,26 @@
|
|
|
12
12
|
|
|
13
13
|
const assert = require('assert');
|
|
14
14
|
const fs = require('fs');
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
15
|
+
const yargs = require('yargs');
|
|
16
|
+
const argv = yargs
|
|
17
|
+
.option('p', {
|
|
18
|
+
alias: 'platform',
|
|
19
|
+
type: 'string',
|
|
20
|
+
demandOption: true,
|
|
21
|
+
})
|
|
22
|
+
.option('o', {
|
|
23
|
+
alias: 'output',
|
|
24
|
+
})
|
|
25
|
+
.option('s', {
|
|
26
|
+
alias: 'schema-query',
|
|
27
|
+
})
|
|
28
|
+
.parseSync();
|
|
29
|
+
const platform = argv.platform.toLowerCase();
|
|
30
|
+
const output = argv.output;
|
|
31
|
+
const schemaQuery = argv.s;
|
|
32
|
+
if (!['ios', 'android'].includes(platform)) {
|
|
33
|
+
throw new Error(`Invalid platform ${platform}`);
|
|
32
34
|
}
|
|
33
|
-
const platform = args.platform;
|
|
34
|
-
const output = args.output;
|
|
35
|
-
const schemaQuery = args['schema-query'];
|
|
36
35
|
if (!schemaQuery.startsWith('@')) {
|
|
37
36
|
throw new Error(
|
|
38
37
|
"The argument provided to --schema-query must be a filename that starts with '@'.",
|
|
@@ -18,27 +18,29 @@ import type {
|
|
|
18
18
|
|
|
19
19
|
const assert = require('assert');
|
|
20
20
|
const fs = require('fs');
|
|
21
|
-
const
|
|
21
|
+
const yargs = require('yargs');
|
|
22
22
|
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
23
|
+
const argv = yargs
|
|
24
|
+
.option('p', {
|
|
25
|
+
alias: 'platform',
|
|
26
|
+
type: 'string',
|
|
27
|
+
demandOption: true,
|
|
28
|
+
})
|
|
29
|
+
.option('o', {
|
|
30
|
+
alias: 'output',
|
|
31
|
+
})
|
|
32
|
+
.option('s', {
|
|
33
|
+
alias: 'schema-query',
|
|
34
|
+
})
|
|
35
|
+
.parseSync();
|
|
36
|
+
|
|
37
|
+
const platform: string = argv.platform.toLowerCase();
|
|
38
|
+
const output: string = argv.output;
|
|
39
|
+
const schemaQuery: string = argv.s;
|
|
40
|
+
|
|
41
|
+
if (!['ios', 'android'].includes(platform)) {
|
|
42
|
+
throw new Error(`Invalid platform ${platform}`);
|
|
38
43
|
}
|
|
39
|
-
const platform = args.platform;
|
|
40
|
-
const output = args.output;
|
|
41
|
-
const schemaQuery: string = args['schema-query'];
|
|
42
44
|
|
|
43
45
|
if (!schemaQuery.startsWith('@')) {
|
|
44
46
|
throw new Error(
|
|
@@ -11,74 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
function _toArray(arr) {
|
|
15
|
-
return (
|
|
16
|
-
_arrayWithHoles(arr) ||
|
|
17
|
-
_iterableToArray(arr) ||
|
|
18
|
-
_unsupportedIterableToArray(arr) ||
|
|
19
|
-
_nonIterableRest()
|
|
20
|
-
);
|
|
21
|
-
}
|
|
22
|
-
function _nonIterableRest() {
|
|
23
|
-
throw new TypeError(
|
|
24
|
-
'Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.',
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
28
|
-
if (!o) return;
|
|
29
|
-
if (typeof o === 'string') return _arrayLikeToArray(o, minLen);
|
|
30
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
31
|
-
if (n === 'Object' && o.constructor) n = o.constructor.name;
|
|
32
|
-
if (n === 'Map' || n === 'Set') return Array.from(o);
|
|
33
|
-
if (n === 'Arguments' || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
|
|
34
|
-
return _arrayLikeToArray(o, minLen);
|
|
35
|
-
}
|
|
36
|
-
function _arrayLikeToArray(arr, len) {
|
|
37
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
38
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
39
|
-
return arr2;
|
|
40
|
-
}
|
|
41
|
-
function _iterableToArray(iter) {
|
|
42
|
-
if (
|
|
43
|
-
(typeof Symbol !== 'undefined' && iter[Symbol.iterator] != null) ||
|
|
44
|
-
iter['@@iterator'] != null
|
|
45
|
-
)
|
|
46
|
-
return Array.from(iter);
|
|
47
|
-
}
|
|
48
|
-
function _arrayWithHoles(arr) {
|
|
49
|
-
if (Array.isArray(arr)) return arr;
|
|
50
|
-
}
|
|
51
14
|
const path = require('path');
|
|
52
|
-
const util = require('util');
|
|
53
|
-
function parseArgs(args) {
|
|
54
|
-
const parsedArgs = util.parseArgs({
|
|
55
|
-
args: args.slice(2),
|
|
56
|
-
options: {
|
|
57
|
-
platform: {
|
|
58
|
-
short: 'p',
|
|
59
|
-
type: 'string',
|
|
60
|
-
},
|
|
61
|
-
exclude: {
|
|
62
|
-
short: 'e',
|
|
63
|
-
type: 'string',
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
allowPositionals: true,
|
|
67
|
-
});
|
|
68
|
-
const _parsedArgs$values = parsedArgs.values,
|
|
69
|
-
platform = _parsedArgs$values.platform,
|
|
70
|
-
exclude = _parsedArgs$values.exclude,
|
|
71
|
-
files = parsedArgs.positionals;
|
|
72
|
-
const _files = _toArray(files),
|
|
73
|
-
outfile = _files[0],
|
|
74
|
-
fileList = _files.slice(1);
|
|
75
|
-
return {
|
|
76
|
-
platform: platform !== null && platform !== void 0 ? platform : null,
|
|
77
|
-
outfile,
|
|
78
|
-
fileList,
|
|
79
|
-
exclude: exclude != null && exclude !== '' ? new RegExp(exclude) : null,
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
15
|
|
|
83
16
|
/**
|
|
84
17
|
* This function is used by the CLI to decide whether a JS/TS file has to be processed or not by the Codegen.
|
|
@@ -119,6 +52,5 @@ function filterJSFile(file, currentPlatform, excludeRegExp) {
|
|
|
119
52
|
return isValidCandidate && currentPlatform === filePlatform;
|
|
120
53
|
}
|
|
121
54
|
module.exports = {
|
|
122
|
-
parseArgs,
|
|
123
55
|
filterJSFile,
|
|
124
56
|
};
|
|
@@ -12,43 +12,6 @@
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
14
|
const path = require('path');
|
|
15
|
-
const util = require('util');
|
|
16
|
-
|
|
17
|
-
function parseArgs(args: string[]): {
|
|
18
|
-
platform: ?string,
|
|
19
|
-
outfile: string,
|
|
20
|
-
fileList: string[],
|
|
21
|
-
exclude: ?RegExp,
|
|
22
|
-
} {
|
|
23
|
-
const parsedArgs = util.parseArgs({
|
|
24
|
-
args: args.slice(2),
|
|
25
|
-
options: {
|
|
26
|
-
platform: {
|
|
27
|
-
short: 'p',
|
|
28
|
-
type: 'string',
|
|
29
|
-
},
|
|
30
|
-
exclude: {
|
|
31
|
-
short: 'e',
|
|
32
|
-
type: 'string',
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
allowPositionals: true,
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
const {
|
|
39
|
-
values: {platform, exclude},
|
|
40
|
-
positionals: files,
|
|
41
|
-
} = parsedArgs;
|
|
42
|
-
|
|
43
|
-
const [outfile, ...fileList] = files;
|
|
44
|
-
|
|
45
|
-
return {
|
|
46
|
-
platform: platform ?? null,
|
|
47
|
-
outfile,
|
|
48
|
-
fileList,
|
|
49
|
-
exclude: exclude != null && exclude !== '' ? new RegExp(exclude) : null,
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
15
|
|
|
53
16
|
/**
|
|
54
17
|
* This function is used by the CLI to decide whether a JS/TS file has to be processed or not by the Codegen.
|
|
@@ -97,6 +60,5 @@ function filterJSFile(
|
|
|
97
60
|
}
|
|
98
61
|
|
|
99
62
|
module.exports = {
|
|
100
|
-
parseArgs,
|
|
101
63
|
filterJSFile,
|
|
102
64
|
};
|
|
@@ -166,14 +166,28 @@ module.exports = {
|
|
|
166
166
|
libraryGenerators: LIBRARY_GENERATORS,
|
|
167
167
|
schemaGenerators: SCHEMAS_GENERATORS,
|
|
168
168
|
generate(
|
|
169
|
-
{
|
|
169
|
+
{
|
|
170
|
+
libraryName,
|
|
171
|
+
schema,
|
|
172
|
+
outputDirectory,
|
|
173
|
+
packageName,
|
|
174
|
+
assumeNonnull,
|
|
175
|
+
useLocalIncludePaths,
|
|
176
|
+
},
|
|
170
177
|
{generators, test},
|
|
171
178
|
) {
|
|
172
179
|
schemaValidator.validate(schema);
|
|
180
|
+
const defaultHeaderPrefix = 'react/renderer/components';
|
|
181
|
+
const headerPrefix =
|
|
182
|
+
useLocalIncludePaths === true
|
|
183
|
+
? ''
|
|
184
|
+
: `${defaultHeaderPrefix}/${libraryName}/`;
|
|
173
185
|
function composePath(intermediate) {
|
|
174
186
|
return path.join(outputDirectory, intermediate, libraryName);
|
|
175
187
|
}
|
|
176
|
-
const componentIOSOutput = composePath(
|
|
188
|
+
const componentIOSOutput = composePath(
|
|
189
|
+
useLocalIncludePaths === true ? '' : defaultHeaderPrefix,
|
|
190
|
+
);
|
|
177
191
|
const modulesIOSOutput = composePath('./');
|
|
178
192
|
const outputFoldersForGenerators = {
|
|
179
193
|
componentsIOS: componentIOSOutput,
|
|
@@ -191,15 +205,19 @@ module.exports = {
|
|
|
191
205
|
const generatedFiles = [];
|
|
192
206
|
for (const name of generators) {
|
|
193
207
|
for (const generator of LIBRARY_GENERATORS[name]) {
|
|
194
|
-
generator(
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
208
|
+
generator(
|
|
209
|
+
libraryName,
|
|
210
|
+
schema,
|
|
211
|
+
packageName,
|
|
212
|
+
assumeNonnull,
|
|
213
|
+
headerPrefix,
|
|
214
|
+
).forEach((contents, fileName) => {
|
|
215
|
+
generatedFiles.push({
|
|
216
|
+
name: fileName,
|
|
217
|
+
content: contents,
|
|
218
|
+
outputDir: outputFoldersForGenerators[name],
|
|
219
|
+
});
|
|
220
|
+
});
|
|
203
221
|
}
|
|
204
222
|
}
|
|
205
223
|
return checkOrWriteFiles(generatedFiles, test);
|
|
@@ -77,6 +77,7 @@ type LibraryOptions = $ReadOnly<{
|
|
|
77
77
|
outputDirectory: string,
|
|
78
78
|
packageName?: string, // Some platforms have a notion of package, which should be configurable.
|
|
79
79
|
assumeNonnull: boolean,
|
|
80
|
+
useLocalIncludePaths?: boolean,
|
|
80
81
|
}>;
|
|
81
82
|
|
|
82
83
|
type SchemasOptions = $ReadOnly<{
|
|
@@ -232,16 +233,24 @@ module.exports = {
|
|
|
232
233
|
outputDirectory,
|
|
233
234
|
packageName,
|
|
234
235
|
assumeNonnull,
|
|
236
|
+
useLocalIncludePaths,
|
|
235
237
|
}: LibraryOptions,
|
|
236
238
|
{generators, test}: LibraryConfig,
|
|
237
239
|
): boolean {
|
|
238
240
|
schemaValidator.validate(schema);
|
|
239
241
|
|
|
242
|
+
const defaultHeaderPrefix = 'react/renderer/components';
|
|
243
|
+
const headerPrefix =
|
|
244
|
+
useLocalIncludePaths === true
|
|
245
|
+
? ''
|
|
246
|
+
: `${defaultHeaderPrefix}/${libraryName}/`;
|
|
240
247
|
function composePath(intermediate: string) {
|
|
241
248
|
return path.join(outputDirectory, intermediate, libraryName);
|
|
242
249
|
}
|
|
243
250
|
|
|
244
|
-
const componentIOSOutput = composePath(
|
|
251
|
+
const componentIOSOutput = composePath(
|
|
252
|
+
useLocalIncludePaths === true ? '' : defaultHeaderPrefix,
|
|
253
|
+
);
|
|
245
254
|
const modulesIOSOutput = composePath('./');
|
|
246
255
|
|
|
247
256
|
const outputFoldersForGenerators = {
|
|
@@ -262,15 +271,19 @@ module.exports = {
|
|
|
262
271
|
|
|
263
272
|
for (const name of generators) {
|
|
264
273
|
for (const generator of LIBRARY_GENERATORS[name]) {
|
|
265
|
-
generator(
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
+
generator(
|
|
275
|
+
libraryName,
|
|
276
|
+
schema,
|
|
277
|
+
packageName,
|
|
278
|
+
assumeNonnull,
|
|
279
|
+
headerPrefix,
|
|
280
|
+
).forEach((contents: string, fileName: string) => {
|
|
281
|
+
generatedFiles.push({
|
|
282
|
+
name: fileName,
|
|
283
|
+
content: contents,
|
|
284
|
+
outputDir: outputFoldersForGenerators[name],
|
|
285
|
+
});
|
|
286
|
+
});
|
|
274
287
|
}
|
|
275
288
|
}
|
|
276
289
|
return checkOrWriteFiles(generatedFiles, test);
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
// File path -> contents
|
|
14
14
|
|
|
15
|
-
const FileTemplate = ({componentDescriptors,
|
|
15
|
+
const FileTemplate = ({componentDescriptors, headerPrefix}) => `
|
|
16
16
|
/**
|
|
17
17
|
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
18
18
|
*
|
|
@@ -24,7 +24,7 @@ const FileTemplate = ({componentDescriptors, libraryName}) => `
|
|
|
24
24
|
|
|
25
25
|
#pragma once
|
|
26
26
|
|
|
27
|
-
#include
|
|
27
|
+
#include <${headerPrefix}ShadowNodes.h>
|
|
28
28
|
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
|
29
29
|
|
|
30
30
|
namespace facebook::react {
|
|
@@ -38,7 +38,13 @@ const ComponentTemplate = ({className}) =>
|
|
|
38
38
|
using ${className}ComponentDescriptor = ConcreteComponentDescriptor<${className}ShadowNode>;
|
|
39
39
|
`.trim();
|
|
40
40
|
module.exports = {
|
|
41
|
-
generate(
|
|
41
|
+
generate(
|
|
42
|
+
libraryName,
|
|
43
|
+
schema,
|
|
44
|
+
packageName,
|
|
45
|
+
assumeNonnull = false,
|
|
46
|
+
headerPrefix,
|
|
47
|
+
) {
|
|
42
48
|
const fileName = 'ComponentDescriptors.h';
|
|
43
49
|
const componentDescriptors = Object.keys(schema.modules)
|
|
44
50
|
.map(moduleName => {
|
|
@@ -66,7 +72,8 @@ module.exports = {
|
|
|
66
72
|
.join('\n');
|
|
67
73
|
const replacedTemplate = FileTemplate({
|
|
68
74
|
componentDescriptors,
|
|
69
|
-
|
|
75
|
+
headerPrefix:
|
|
76
|
+
headerPrefix !== null && headerPrefix !== void 0 ? headerPrefix : '',
|
|
70
77
|
});
|
|
71
78
|
return new Map([[fileName, replacedTemplate]]);
|
|
72
79
|
},
|
|
@@ -17,10 +17,10 @@ type FilesOutput = Map<string, string>;
|
|
|
17
17
|
|
|
18
18
|
const FileTemplate = ({
|
|
19
19
|
componentDescriptors,
|
|
20
|
-
|
|
20
|
+
headerPrefix,
|
|
21
21
|
}: {
|
|
22
22
|
componentDescriptors: string,
|
|
23
|
-
|
|
23
|
+
headerPrefix: string,
|
|
24
24
|
}) => `
|
|
25
25
|
/**
|
|
26
26
|
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
@@ -33,7 +33,7 @@ const FileTemplate = ({
|
|
|
33
33
|
|
|
34
34
|
#pragma once
|
|
35
35
|
|
|
36
|
-
#include
|
|
36
|
+
#include <${headerPrefix}ShadowNodes.h>
|
|
37
37
|
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
|
38
38
|
|
|
39
39
|
namespace facebook::react {
|
|
@@ -54,6 +54,7 @@ module.exports = {
|
|
|
54
54
|
schema: SchemaType,
|
|
55
55
|
packageName?: string,
|
|
56
56
|
assumeNonnull: boolean = false,
|
|
57
|
+
headerPrefix?: string,
|
|
57
58
|
): FilesOutput {
|
|
58
59
|
const fileName = 'ComponentDescriptors.h';
|
|
59
60
|
|
|
@@ -85,7 +86,7 @@ module.exports = {
|
|
|
85
86
|
|
|
86
87
|
const replacedTemplate = FileTemplate({
|
|
87
88
|
componentDescriptors,
|
|
88
|
-
|
|
89
|
+
headerPrefix: headerPrefix ?? '',
|
|
89
90
|
});
|
|
90
91
|
|
|
91
92
|
return new Map([[fileName, replacedTemplate]]);
|
|
@@ -294,7 +294,13 @@ function generateCommandHandler(component, componentName) {
|
|
|
294
294
|
});
|
|
295
295
|
}
|
|
296
296
|
module.exports = {
|
|
297
|
-
generate(
|
|
297
|
+
generate(
|
|
298
|
+
libraryName,
|
|
299
|
+
schema,
|
|
300
|
+
packageName,
|
|
301
|
+
assumeNonnull = false,
|
|
302
|
+
headerPrefix,
|
|
303
|
+
) {
|
|
298
304
|
const fileName = 'RCTComponentViewHelpers.h';
|
|
299
305
|
const componentContent = Object.keys(schema.modules)
|
|
300
306
|
.map(moduleName => {
|
|
@@ -17,7 +17,7 @@ const _require2 = require('./CppHelpers'),
|
|
|
17
17
|
|
|
18
18
|
// File path -> contents
|
|
19
19
|
|
|
20
|
-
const FileTemplate = ({events,
|
|
20
|
+
const FileTemplate = ({events, extraIncludes, headerPrefix}) => `
|
|
21
21
|
/**
|
|
22
22
|
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
23
23
|
*
|
|
@@ -27,7 +27,7 @@ const FileTemplate = ({events, libraryName, extraIncludes}) => `
|
|
|
27
27
|
* ${'@'}generated by codegen project: GenerateEventEmitterCpp.js
|
|
28
28
|
*/
|
|
29
29
|
|
|
30
|
-
#include
|
|
30
|
+
#include <${headerPrefix}EventEmitters.h>
|
|
31
31
|
${[...extraIncludes].join('\n')}
|
|
32
32
|
|
|
33
33
|
namespace facebook::react {
|
|
@@ -351,7 +351,13 @@ function generateEvent(componentName, event, extraIncludes) {
|
|
|
351
351
|
});
|
|
352
352
|
}
|
|
353
353
|
module.exports = {
|
|
354
|
-
generate(
|
|
354
|
+
generate(
|
|
355
|
+
libraryName,
|
|
356
|
+
schema,
|
|
357
|
+
packageName,
|
|
358
|
+
assumeNonnull = false,
|
|
359
|
+
headerPrefix,
|
|
360
|
+
) {
|
|
355
361
|
const moduleComponents = Object.keys(schema.modules)
|
|
356
362
|
.map(moduleName => {
|
|
357
363
|
const module = schema.modules[moduleName];
|
|
@@ -378,9 +384,10 @@ module.exports = {
|
|
|
378
384
|
.join('\n');
|
|
379
385
|
const fileName = 'EventEmitters.cpp';
|
|
380
386
|
const replacedTemplate = FileTemplate({
|
|
381
|
-
libraryName,
|
|
382
387
|
events: componentEmitters,
|
|
383
388
|
extraIncludes,
|
|
389
|
+
headerPrefix:
|
|
390
|
+
headerPrefix !== null && headerPrefix !== void 0 ? headerPrefix : '',
|
|
384
391
|
});
|
|
385
392
|
return new Map([[fileName, replacedTemplate]]);
|
|
386
393
|
},
|
|
@@ -31,12 +31,12 @@ type ComponentCollection = $ReadOnly<{
|
|
|
31
31
|
|
|
32
32
|
const FileTemplate = ({
|
|
33
33
|
events,
|
|
34
|
-
libraryName,
|
|
35
34
|
extraIncludes,
|
|
35
|
+
headerPrefix,
|
|
36
36
|
}: {
|
|
37
37
|
events: string,
|
|
38
|
-
libraryName: string,
|
|
39
38
|
extraIncludes: Set<string>,
|
|
39
|
+
headerPrefix: string,
|
|
40
40
|
}) => `
|
|
41
41
|
/**
|
|
42
42
|
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
@@ -47,7 +47,7 @@ const FileTemplate = ({
|
|
|
47
47
|
* ${'@'}generated by codegen project: GenerateEventEmitterCpp.js
|
|
48
48
|
*/
|
|
49
49
|
|
|
50
|
-
#include
|
|
50
|
+
#include <${headerPrefix}EventEmitters.h>
|
|
51
51
|
${[...extraIncludes].join('\n')}
|
|
52
52
|
|
|
53
53
|
namespace facebook::react {
|
|
@@ -411,6 +411,7 @@ module.exports = {
|
|
|
411
411
|
schema: SchemaType,
|
|
412
412
|
packageName?: string,
|
|
413
413
|
assumeNonnull: boolean = false,
|
|
414
|
+
headerPrefix?: string,
|
|
414
415
|
): FilesOutput {
|
|
415
416
|
const moduleComponents: ComponentCollection = Object.keys(schema.modules)
|
|
416
417
|
.map(moduleName => {
|
|
@@ -442,9 +443,9 @@ module.exports = {
|
|
|
442
443
|
|
|
443
444
|
const fileName = 'EventEmitters.cpp';
|
|
444
445
|
const replacedTemplate = FileTemplate({
|
|
445
|
-
libraryName,
|
|
446
446
|
events: componentEmitters,
|
|
447
447
|
extraIncludes,
|
|
448
|
+
headerPrefix: headerPrefix ?? '',
|
|
448
449
|
});
|
|
449
450
|
|
|
450
451
|
return new Map([[fileName, replacedTemplate]]);
|
|
@@ -227,7 +227,13 @@ function generateEvents(componentName, component) {
|
|
|
227
227
|
.join('\n\n' + ' ');
|
|
228
228
|
}
|
|
229
229
|
module.exports = {
|
|
230
|
-
generate(
|
|
230
|
+
generate(
|
|
231
|
+
libraryName,
|
|
232
|
+
schema,
|
|
233
|
+
packageName,
|
|
234
|
+
assumeNonnull = false,
|
|
235
|
+
headerPrefix,
|
|
236
|
+
) {
|
|
231
237
|
const moduleComponents = Object.keys(schema.modules)
|
|
232
238
|
.map(moduleName => {
|
|
233
239
|
const module = schema.modules[moduleName];
|
|
@@ -311,6 +311,7 @@ module.exports = {
|
|
|
311
311
|
schema: SchemaType,
|
|
312
312
|
packageName?: string,
|
|
313
313
|
assumeNonnull: boolean = false,
|
|
314
|
+
headerPrefix?: string,
|
|
314
315
|
): FilesOutput {
|
|
315
316
|
const moduleComponents: ComponentCollection = Object.keys(schema.modules)
|
|
316
317
|
.map(moduleName => {
|