@react-native/codegen 0.73.0-nightly-20230807-2bf59c764 → 0.73.0-nightly-20230823-0b6e9bf0d
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 +7 -1
- package/lib/cli/combine/combine-js-to-schema-cli.js.flow +7 -1
- package/lib/parsers/flow/components/events.js +12 -28
- package/lib/parsers/flow/components/events.js.flow +11 -27
- package/lib/parsers/parsers-commons.js +30 -0
- package/lib/parsers/parsers-commons.js.flow +33 -0
- package/lib/parsers/typescript/components/events.js +12 -28
- package/lib/parsers/typescript/components/events.js.flow +11 -27
- package/package.json +1 -1
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
const combine = require('./combine-js-to-schema');
|
|
15
15
|
const fs = require('fs');
|
|
16
16
|
const glob = require('glob');
|
|
17
|
+
const path = require('path');
|
|
17
18
|
const _require = require('./combine-utils'),
|
|
18
19
|
parseArgs = _require.parseArgs,
|
|
19
20
|
filterJSFile = _require.filterJSFile;
|
|
@@ -24,9 +25,14 @@ const _parseArgs = parseArgs(process.argv),
|
|
|
24
25
|
const allFiles = [];
|
|
25
26
|
fileList.forEach(file => {
|
|
26
27
|
if (fs.lstatSync(file).isDirectory()) {
|
|
28
|
+
const filePattern = path.sep === '\\' ? file.replace(/\\/g, '/') : file;
|
|
27
29
|
const dirFiles = glob
|
|
28
|
-
.sync(`${
|
|
30
|
+
.sync(`${filePattern}/**/*.{js,ts,tsx}`, {
|
|
29
31
|
nodir: true,
|
|
32
|
+
// TODO: This will remove the need of slash substitution above for Windows,
|
|
33
|
+
// but it requires glob@v9+; with the package currenlty relying on
|
|
34
|
+
// glob@7.1.1; and flow-typed repo not having definitions for glob@9+.
|
|
35
|
+
// windowsPathsNoEscape: true,
|
|
30
36
|
})
|
|
31
37
|
.filter(element => filterJSFile(element, platform));
|
|
32
38
|
allFiles.push(...dirFiles);
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
const combine = require('./combine-js-to-schema');
|
|
15
15
|
const fs = require('fs');
|
|
16
16
|
const glob = require('glob');
|
|
17
|
+
const path = require('path');
|
|
17
18
|
const {parseArgs, filterJSFile} = require('./combine-utils');
|
|
18
19
|
|
|
19
20
|
const {platform, outfile, fileList} = parseArgs(process.argv);
|
|
@@ -21,9 +22,14 @@ const {platform, outfile, fileList} = parseArgs(process.argv);
|
|
|
21
22
|
const allFiles = [];
|
|
22
23
|
fileList.forEach(file => {
|
|
23
24
|
if (fs.lstatSync(file).isDirectory()) {
|
|
25
|
+
const filePattern = path.sep === '\\' ? file.replace(/\\/g, '/') : file;
|
|
24
26
|
const dirFiles = glob
|
|
25
|
-
.sync(`${
|
|
27
|
+
.sync(`${filePattern}/**/*.{js,ts,tsx}`, {
|
|
26
28
|
nodir: true,
|
|
29
|
+
// TODO: This will remove the need of slash substitution above for Windows,
|
|
30
|
+
// but it requires glob@v9+; with the package currenlty relying on
|
|
31
|
+
// glob@7.1.1; and flow-typed repo not having definitions for glob@9+.
|
|
32
|
+
// windowsPathsNoEscape: true,
|
|
27
33
|
})
|
|
28
34
|
.filter(element => filterJSFile(element, platform));
|
|
29
35
|
allFiles.push(...dirFiles);
|
|
@@ -17,7 +17,8 @@ const _require = require('../../error-utils'),
|
|
|
17
17
|
const _require2 = require('../../parsers-commons'),
|
|
18
18
|
getEventArgument = _require2.getEventArgument,
|
|
19
19
|
buildPropertiesForEvent = _require2.buildPropertiesForEvent,
|
|
20
|
-
handleEventHandler = _require2.handleEventHandler
|
|
20
|
+
handleEventHandler = _require2.handleEventHandler,
|
|
21
|
+
emitBuildEventSchema = _require2.emitBuildEventSchema;
|
|
21
22
|
const _require3 = require('../../parsers-primitives'),
|
|
22
23
|
emitBoolProp = _require3.emitBoolProp,
|
|
23
24
|
emitDoubleProp = _require3.emitDoubleProp,
|
|
@@ -227,35 +228,18 @@ function buildEventSchema(types, property, parser) {
|
|
|
227
228
|
name,
|
|
228
229
|
);
|
|
229
230
|
const nonNullableBubblingType = throwIfBubblingTypeIsNull(bubblingType, name);
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
type: 'EventTypeAnnotation',
|
|
238
|
-
argument: getEventArgument(
|
|
239
|
-
nonNullableArgumentProps,
|
|
240
|
-
parser,
|
|
241
|
-
getPropertyType,
|
|
242
|
-
),
|
|
243
|
-
},
|
|
244
|
-
};
|
|
245
|
-
}
|
|
246
|
-
return {
|
|
231
|
+
const argument = getEventArgument(
|
|
232
|
+
nonNullableArgumentProps,
|
|
233
|
+
parser,
|
|
234
|
+
getPropertyType,
|
|
235
|
+
);
|
|
236
|
+
return emitBuildEventSchema(
|
|
237
|
+
paperTopLevelNameDeprecated,
|
|
247
238
|
name,
|
|
248
239
|
optional,
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
argument: getEventArgument(
|
|
253
|
-
nonNullableArgumentProps,
|
|
254
|
-
parser,
|
|
255
|
-
getPropertyType,
|
|
256
|
-
),
|
|
257
|
-
},
|
|
258
|
-
};
|
|
240
|
+
nonNullableBubblingType,
|
|
241
|
+
argument,
|
|
242
|
+
);
|
|
259
243
|
}
|
|
260
244
|
|
|
261
245
|
// $FlowFixMe[unclear-type] there's no flowtype for ASTs
|
|
@@ -27,6 +27,7 @@ const {
|
|
|
27
27
|
getEventArgument,
|
|
28
28
|
buildPropertiesForEvent,
|
|
29
29
|
handleEventHandler,
|
|
30
|
+
emitBuildEventSchema,
|
|
30
31
|
} = require('../../parsers-commons');
|
|
31
32
|
const {
|
|
32
33
|
emitBoolProp,
|
|
@@ -245,36 +246,19 @@ function buildEventSchema(
|
|
|
245
246
|
);
|
|
246
247
|
const nonNullableBubblingType = throwIfBubblingTypeIsNull(bubblingType, name);
|
|
247
248
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
paperTopLevelNameDeprecated,
|
|
254
|
-
typeAnnotation: {
|
|
255
|
-
type: 'EventTypeAnnotation',
|
|
256
|
-
argument: getEventArgument(
|
|
257
|
-
nonNullableArgumentProps,
|
|
258
|
-
parser,
|
|
259
|
-
getPropertyType,
|
|
260
|
-
),
|
|
261
|
-
},
|
|
262
|
-
};
|
|
263
|
-
}
|
|
249
|
+
const argument = getEventArgument(
|
|
250
|
+
nonNullableArgumentProps,
|
|
251
|
+
parser,
|
|
252
|
+
getPropertyType,
|
|
253
|
+
);
|
|
264
254
|
|
|
265
|
-
return
|
|
255
|
+
return emitBuildEventSchema(
|
|
256
|
+
paperTopLevelNameDeprecated,
|
|
266
257
|
name,
|
|
267
258
|
optional,
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
argument: getEventArgument(
|
|
272
|
-
nonNullableArgumentProps,
|
|
273
|
-
parser,
|
|
274
|
-
getPropertyType,
|
|
275
|
-
),
|
|
276
|
-
},
|
|
277
|
-
};
|
|
259
|
+
nonNullableBubblingType,
|
|
260
|
+
argument,
|
|
261
|
+
);
|
|
278
262
|
}
|
|
279
263
|
|
|
280
264
|
// $FlowFixMe[unclear-type] there's no flowtype for ASTs
|
|
@@ -1035,6 +1035,35 @@ function handleEventHandler(
|
|
|
1035
1035
|
);
|
|
1036
1036
|
}
|
|
1037
1037
|
}
|
|
1038
|
+
function emitBuildEventSchema(
|
|
1039
|
+
paperTopLevelNameDeprecated,
|
|
1040
|
+
name,
|
|
1041
|
+
optional,
|
|
1042
|
+
nonNullableBubblingType,
|
|
1043
|
+
argument,
|
|
1044
|
+
) {
|
|
1045
|
+
if (paperTopLevelNameDeprecated != null) {
|
|
1046
|
+
return {
|
|
1047
|
+
name,
|
|
1048
|
+
optional,
|
|
1049
|
+
bubblingType: nonNullableBubblingType,
|
|
1050
|
+
paperTopLevelNameDeprecated,
|
|
1051
|
+
typeAnnotation: {
|
|
1052
|
+
type: 'EventTypeAnnotation',
|
|
1053
|
+
argument: argument,
|
|
1054
|
+
},
|
|
1055
|
+
};
|
|
1056
|
+
}
|
|
1057
|
+
return {
|
|
1058
|
+
name,
|
|
1059
|
+
optional,
|
|
1060
|
+
bubblingType: nonNullableBubblingType,
|
|
1061
|
+
typeAnnotation: {
|
|
1062
|
+
type: 'EventTypeAnnotation',
|
|
1063
|
+
argument: argument,
|
|
1064
|
+
},
|
|
1065
|
+
};
|
|
1066
|
+
}
|
|
1038
1067
|
module.exports = {
|
|
1039
1068
|
wrapModuleSchema,
|
|
1040
1069
|
unwrapNullable,
|
|
@@ -1064,4 +1093,5 @@ module.exports = {
|
|
|
1064
1093
|
buildPropertiesForEvent,
|
|
1065
1094
|
verifyPropNotAlreadyDefined,
|
|
1066
1095
|
handleEventHandler,
|
|
1096
|
+
emitBuildEventSchema,
|
|
1067
1097
|
};
|
|
@@ -26,6 +26,7 @@ import type {
|
|
|
26
26
|
PropTypeAnnotation,
|
|
27
27
|
EventTypeAnnotation,
|
|
28
28
|
ObjectTypeAnnotation,
|
|
29
|
+
EventTypeShape,
|
|
29
30
|
} from '../CodegenSchema.js';
|
|
30
31
|
|
|
31
32
|
import type {Parser} from './parser';
|
|
@@ -1125,6 +1126,37 @@ function handleEventHandler(
|
|
|
1125
1126
|
}
|
|
1126
1127
|
}
|
|
1127
1128
|
|
|
1129
|
+
function emitBuildEventSchema(
|
|
1130
|
+
paperTopLevelNameDeprecated: $FlowFixMe,
|
|
1131
|
+
name: $FlowFixMe,
|
|
1132
|
+
optional: $FlowFixMe,
|
|
1133
|
+
nonNullableBubblingType: 'direct' | 'bubble',
|
|
1134
|
+
argument: ObjectTypeAnnotation<EventTypeAnnotation>,
|
|
1135
|
+
): ?EventTypeShape {
|
|
1136
|
+
if (paperTopLevelNameDeprecated != null) {
|
|
1137
|
+
return {
|
|
1138
|
+
name,
|
|
1139
|
+
optional,
|
|
1140
|
+
bubblingType: nonNullableBubblingType,
|
|
1141
|
+
paperTopLevelNameDeprecated,
|
|
1142
|
+
typeAnnotation: {
|
|
1143
|
+
type: 'EventTypeAnnotation',
|
|
1144
|
+
argument: argument,
|
|
1145
|
+
},
|
|
1146
|
+
};
|
|
1147
|
+
}
|
|
1148
|
+
|
|
1149
|
+
return {
|
|
1150
|
+
name,
|
|
1151
|
+
optional,
|
|
1152
|
+
bubblingType: nonNullableBubblingType,
|
|
1153
|
+
typeAnnotation: {
|
|
1154
|
+
type: 'EventTypeAnnotation',
|
|
1155
|
+
argument: argument,
|
|
1156
|
+
},
|
|
1157
|
+
};
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1128
1160
|
module.exports = {
|
|
1129
1161
|
wrapModuleSchema,
|
|
1130
1162
|
unwrapNullable,
|
|
@@ -1154,4 +1186,5 @@ module.exports = {
|
|
|
1154
1186
|
buildPropertiesForEvent,
|
|
1155
1187
|
verifyPropNotAlreadyDefined,
|
|
1156
1188
|
handleEventHandler,
|
|
1189
|
+
emitBuildEventSchema,
|
|
1157
1190
|
};
|
|
@@ -21,7 +21,8 @@ const _require3 = require('../../error-utils'),
|
|
|
21
21
|
const _require4 = require('../../parsers-commons'),
|
|
22
22
|
getEventArgument = _require4.getEventArgument,
|
|
23
23
|
buildPropertiesForEvent = _require4.buildPropertiesForEvent,
|
|
24
|
-
handleEventHandler = _require4.handleEventHandler
|
|
24
|
+
handleEventHandler = _require4.handleEventHandler,
|
|
25
|
+
emitBuildEventSchema = _require4.emitBuildEventSchema;
|
|
25
26
|
const _require5 = require('../../parsers-primitives'),
|
|
26
27
|
emitBoolProp = _require5.emitBoolProp,
|
|
27
28
|
emitDoubleProp = _require5.emitDoubleProp,
|
|
@@ -236,35 +237,18 @@ function buildEventSchema(types, property, parser) {
|
|
|
236
237
|
name,
|
|
237
238
|
);
|
|
238
239
|
const nonNullableBubblingType = throwIfBubblingTypeIsNull(bubblingType, name);
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
type: 'EventTypeAnnotation',
|
|
247
|
-
argument: getEventArgument(
|
|
248
|
-
nonNullableArgumentProps,
|
|
249
|
-
parser,
|
|
250
|
-
getPropertyType,
|
|
251
|
-
),
|
|
252
|
-
},
|
|
253
|
-
};
|
|
254
|
-
}
|
|
255
|
-
return {
|
|
240
|
+
const argument = getEventArgument(
|
|
241
|
+
nonNullableArgumentProps,
|
|
242
|
+
parser,
|
|
243
|
+
getPropertyType,
|
|
244
|
+
);
|
|
245
|
+
return emitBuildEventSchema(
|
|
246
|
+
paperTopLevelNameDeprecated,
|
|
256
247
|
name,
|
|
257
248
|
optional,
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
argument: getEventArgument(
|
|
262
|
-
nonNullableArgumentProps,
|
|
263
|
-
parser,
|
|
264
|
-
getPropertyType,
|
|
265
|
-
),
|
|
266
|
-
},
|
|
267
|
-
};
|
|
249
|
+
nonNullableBubblingType,
|
|
250
|
+
argument,
|
|
251
|
+
);
|
|
268
252
|
}
|
|
269
253
|
function getEvents(eventTypeAST, types, parser) {
|
|
270
254
|
return eventTypeAST
|
|
@@ -28,6 +28,7 @@ const {
|
|
|
28
28
|
getEventArgument,
|
|
29
29
|
buildPropertiesForEvent,
|
|
30
30
|
handleEventHandler,
|
|
31
|
+
emitBuildEventSchema,
|
|
31
32
|
} = require('../../parsers-commons');
|
|
32
33
|
const {
|
|
33
34
|
emitBoolProp,
|
|
@@ -259,36 +260,19 @@ function buildEventSchema(
|
|
|
259
260
|
);
|
|
260
261
|
const nonNullableBubblingType = throwIfBubblingTypeIsNull(bubblingType, name);
|
|
261
262
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
paperTopLevelNameDeprecated,
|
|
268
|
-
typeAnnotation: {
|
|
269
|
-
type: 'EventTypeAnnotation',
|
|
270
|
-
argument: getEventArgument(
|
|
271
|
-
nonNullableArgumentProps,
|
|
272
|
-
parser,
|
|
273
|
-
getPropertyType,
|
|
274
|
-
),
|
|
275
|
-
},
|
|
276
|
-
};
|
|
277
|
-
}
|
|
263
|
+
const argument = getEventArgument(
|
|
264
|
+
nonNullableArgumentProps,
|
|
265
|
+
parser,
|
|
266
|
+
getPropertyType,
|
|
267
|
+
);
|
|
278
268
|
|
|
279
|
-
return
|
|
269
|
+
return emitBuildEventSchema(
|
|
270
|
+
paperTopLevelNameDeprecated,
|
|
280
271
|
name,
|
|
281
272
|
optional,
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
argument: getEventArgument(
|
|
286
|
-
nonNullableArgumentProps,
|
|
287
|
-
parser,
|
|
288
|
-
getPropertyType,
|
|
289
|
-
),
|
|
290
|
-
},
|
|
291
|
-
};
|
|
273
|
+
nonNullableBubblingType,
|
|
274
|
+
argument,
|
|
275
|
+
);
|
|
292
276
|
}
|
|
293
277
|
|
|
294
278
|
function getEvents(
|