@react-native/codegen 0.75.0-nightly-20240328-af309127a → 0.75.0-nightly-20240331-8769378e0
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.
|
@@ -258,136 +258,53 @@ function createStructsString(moduleName, aliasMap, resolveAlias, enumMap) {
|
|
|
258
258
|
resolveAlias,
|
|
259
259
|
enumMap,
|
|
260
260
|
);
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
.join(' && ')};
|
|
297
|
-
}
|
|
298
|
-
};
|
|
299
|
-
|
|
300
|
-
template <${templateParameterWithTypename}>
|
|
301
|
-
struct [[deprecated("Use ${structNameNew}Bridging instead.")]] ${structName}Bridging {
|
|
302
|
-
static ${structName}<${templateParameter}> fromJs(
|
|
303
|
-
jsi::Runtime &rt,
|
|
304
|
-
const jsi::Object &value,
|
|
305
|
-
const std::shared_ptr<CallInvoker> &jsInvoker) {
|
|
306
|
-
${structName}<${templateParameter}> result{
|
|
307
|
-
${value.properties
|
|
308
|
-
.map(
|
|
309
|
-
(v, i) =>
|
|
310
|
-
` bridging::fromJs<P${i}>(rt, value.getProperty(rt, "${v.name}"), jsInvoker)`,
|
|
311
|
-
)
|
|
312
|
-
.join(',\n')}};
|
|
313
|
-
return result;
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
#ifdef DEBUG
|
|
317
|
-
${debugParameterConversion}
|
|
318
|
-
#endif
|
|
319
|
-
|
|
320
|
-
static jsi::Object toJs(
|
|
321
|
-
jsi::Runtime &rt,
|
|
322
|
-
const ${structName}<${templateParameter}> &value,
|
|
323
|
-
const std::shared_ptr<CallInvoker> &jsInvoker) {
|
|
324
|
-
auto result = facebook::jsi::Object(rt);
|
|
325
|
-
${value.properties
|
|
326
|
-
.map((v, i) => {
|
|
327
|
-
if (v.optional) {
|
|
328
|
-
return ` if (value.${v.name}) {
|
|
329
|
-
result.setProperty(rt, "${v.name}", bridging::toJs(rt, value.${v.name}.value(), jsInvoker));
|
|
330
|
-
}`;
|
|
331
|
-
} else {
|
|
332
|
-
return ` result.setProperty(rt, "${v.name}", bridging::toJs(rt, value.${v.name}, jsInvoker));`;
|
|
333
|
-
}
|
|
334
|
-
})
|
|
335
|
-
.join('\n')}
|
|
336
|
-
return result;
|
|
337
|
-
}
|
|
338
|
-
};
|
|
339
|
-
|
|
340
|
-
`;
|
|
341
|
-
})
|
|
342
|
-
.join('\n') +
|
|
343
|
-
// TODO: T171006733 [End] Remove deprecated Cxx TMs structs after a new release.
|
|
344
|
-
Object.keys(aliasMap)
|
|
345
|
-
.map(alias => {
|
|
346
|
-
const value = aliasMap[alias];
|
|
347
|
-
if (value.properties.length === 0) {
|
|
348
|
-
return '';
|
|
261
|
+
return Object.keys(aliasMap)
|
|
262
|
+
.map(alias => {
|
|
263
|
+
const value = aliasMap[alias];
|
|
264
|
+
if (value.properties.length === 0) {
|
|
265
|
+
return '';
|
|
266
|
+
}
|
|
267
|
+
const structName = `${moduleName}${alias}`;
|
|
268
|
+
const templateParameter = value.properties.filter(
|
|
269
|
+
v =>
|
|
270
|
+
!isDirectRecursiveMember(alias, v.typeAnnotation) &&
|
|
271
|
+
!isArrayRecursiveMember(alias, v.typeAnnotation),
|
|
272
|
+
);
|
|
273
|
+
const templateParameterWithTypename = templateParameter
|
|
274
|
+
.map((v, i) => `typename P${i}`)
|
|
275
|
+
.join(', ');
|
|
276
|
+
const templateParameterWithoutTypename = templateParameter
|
|
277
|
+
.map((v, i) => `P${i}`)
|
|
278
|
+
.join(', ');
|
|
279
|
+
let i = -1;
|
|
280
|
+
const templateMemberTypes = value.properties.map(v => {
|
|
281
|
+
if (isDirectRecursiveMember(alias, v.typeAnnotation)) {
|
|
282
|
+
return `std::unique_ptr<${structName}<${templateParameterWithoutTypename}>> ${v.name}`;
|
|
283
|
+
} else if (isArrayRecursiveMember(alias, v.typeAnnotation)) {
|
|
284
|
+
const _unwrapNullable3 = unwrapNullable(v.typeAnnotation),
|
|
285
|
+
_unwrapNullable4 = _slicedToArray(_unwrapNullable3, 1),
|
|
286
|
+
nullable = _unwrapNullable4[0];
|
|
287
|
+
return (
|
|
288
|
+
(nullable
|
|
289
|
+
? `std::optional<std::vector<${structName}<${templateParameterWithoutTypename}>>>`
|
|
290
|
+
: `std::vector<${structName}<${templateParameterWithoutTypename}>>`) +
|
|
291
|
+
` ${v.name}`
|
|
292
|
+
);
|
|
293
|
+
} else {
|
|
294
|
+
i++;
|
|
295
|
+
return `P${i} ${v.name}`;
|
|
349
296
|
}
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
const templateParameterWithTypename = templateParameter
|
|
357
|
-
.map((v, i) => `typename P${i}`)
|
|
358
|
-
.join(', ');
|
|
359
|
-
const templateParameterWithoutTypename = templateParameter
|
|
360
|
-
.map((v, i) => `P${i}`)
|
|
361
|
-
.join(', ');
|
|
362
|
-
let i = -1;
|
|
363
|
-
const templateMemberTypes = value.properties.map(v => {
|
|
364
|
-
if (isDirectRecursiveMember(alias, v.typeAnnotation)) {
|
|
365
|
-
return `std::unique_ptr<${structName}<${templateParameterWithoutTypename}>> ${v.name}`;
|
|
366
|
-
} else if (isArrayRecursiveMember(alias, v.typeAnnotation)) {
|
|
367
|
-
const _unwrapNullable3 = unwrapNullable(v.typeAnnotation),
|
|
368
|
-
_unwrapNullable4 = _slicedToArray(_unwrapNullable3, 1),
|
|
369
|
-
nullable = _unwrapNullable4[0];
|
|
370
|
-
return (
|
|
371
|
-
(nullable
|
|
372
|
-
? `std::optional<std::vector<${structName}<${templateParameterWithoutTypename}>>>`
|
|
373
|
-
: `std::vector<${structName}<${templateParameterWithoutTypename}>>`) +
|
|
374
|
-
` ${v.name}`
|
|
375
|
-
);
|
|
376
|
-
} else {
|
|
377
|
-
i++;
|
|
378
|
-
return `P${i} ${v.name}`;
|
|
379
|
-
}
|
|
380
|
-
});
|
|
381
|
-
const debugParameterConversion = value.properties
|
|
382
|
-
.map(
|
|
383
|
-
v => ` static ${getCppType(alias, v)} ${
|
|
384
|
-
v.name
|
|
385
|
-
}ToJs(jsi::Runtime &rt, decltype(types.${v.name}) value) {
|
|
297
|
+
});
|
|
298
|
+
const debugParameterConversion = value.properties
|
|
299
|
+
.map(
|
|
300
|
+
v => ` static ${getCppType(alias, v)} ${
|
|
301
|
+
v.name
|
|
302
|
+
}ToJs(jsi::Runtime &rt, decltype(types.${v.name}) value) {
|
|
386
303
|
return bridging::toJs(rt, value);
|
|
387
304
|
}`,
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
305
|
+
)
|
|
306
|
+
.join('\n\n');
|
|
307
|
+
return `
|
|
391
308
|
#pragma mark - ${structName}
|
|
392
309
|
|
|
393
310
|
template <${templateParameterWithTypename}>
|
|
@@ -450,9 +367,8 @@ ${value.properties
|
|
|
450
367
|
};
|
|
451
368
|
|
|
452
369
|
`;
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
);
|
|
370
|
+
})
|
|
371
|
+
.join('\n');
|
|
456
372
|
}
|
|
457
373
|
const EnumTemplate = ({
|
|
458
374
|
enumName,
|
|
@@ -231,135 +231,53 @@ function createStructsString(
|
|
|
231
231
|
enumMap,
|
|
232
232
|
);
|
|
233
233
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
.
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
${
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
}
|
|
270
|
-
};
|
|
271
|
-
|
|
272
|
-
template <${templateParameterWithTypename}>
|
|
273
|
-
struct [[deprecated("Use ${structNameNew}Bridging instead.")]] ${structName}Bridging {
|
|
274
|
-
static ${structName}<${templateParameter}> fromJs(
|
|
275
|
-
jsi::Runtime &rt,
|
|
276
|
-
const jsi::Object &value,
|
|
277
|
-
const std::shared_ptr<CallInvoker> &jsInvoker) {
|
|
278
|
-
${structName}<${templateParameter}> result{
|
|
279
|
-
${value.properties
|
|
280
|
-
.map(
|
|
281
|
-
(v, i) =>
|
|
282
|
-
` bridging::fromJs<P${i}>(rt, value.getProperty(rt, "${v.name}"), jsInvoker)`,
|
|
283
|
-
)
|
|
284
|
-
.join(',\n')}};
|
|
285
|
-
return result;
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
#ifdef DEBUG
|
|
289
|
-
${debugParameterConversion}
|
|
290
|
-
#endif
|
|
291
|
-
|
|
292
|
-
static jsi::Object toJs(
|
|
293
|
-
jsi::Runtime &rt,
|
|
294
|
-
const ${structName}<${templateParameter}> &value,
|
|
295
|
-
const std::shared_ptr<CallInvoker> &jsInvoker) {
|
|
296
|
-
auto result = facebook::jsi::Object(rt);
|
|
297
|
-
${value.properties
|
|
298
|
-
.map((v, i) => {
|
|
299
|
-
if (v.optional) {
|
|
300
|
-
return ` if (value.${v.name}) {
|
|
301
|
-
result.setProperty(rt, "${v.name}", bridging::toJs(rt, value.${v.name}.value(), jsInvoker));
|
|
302
|
-
}`;
|
|
303
|
-
} else {
|
|
304
|
-
return ` result.setProperty(rt, "${v.name}", bridging::toJs(rt, value.${v.name}, jsInvoker));`;
|
|
305
|
-
}
|
|
306
|
-
})
|
|
307
|
-
.join('\n')}
|
|
308
|
-
return result;
|
|
309
|
-
}
|
|
310
|
-
};
|
|
311
|
-
|
|
312
|
-
`;
|
|
313
|
-
})
|
|
314
|
-
.join('\n') +
|
|
315
|
-
// TODO: T171006733 [End] Remove deprecated Cxx TMs structs after a new release.
|
|
316
|
-
Object.keys(aliasMap)
|
|
317
|
-
.map(alias => {
|
|
318
|
-
const value = aliasMap[alias];
|
|
319
|
-
if (value.properties.length === 0) {
|
|
320
|
-
return '';
|
|
234
|
+
return Object.keys(aliasMap)
|
|
235
|
+
.map(alias => {
|
|
236
|
+
const value = aliasMap[alias];
|
|
237
|
+
if (value.properties.length === 0) {
|
|
238
|
+
return '';
|
|
239
|
+
}
|
|
240
|
+
const structName = `${moduleName}${alias}`;
|
|
241
|
+
const templateParameter = value.properties.filter(
|
|
242
|
+
v =>
|
|
243
|
+
!isDirectRecursiveMember(alias, v.typeAnnotation) &&
|
|
244
|
+
!isArrayRecursiveMember(alias, v.typeAnnotation),
|
|
245
|
+
);
|
|
246
|
+
const templateParameterWithTypename = templateParameter
|
|
247
|
+
.map((v, i) => `typename P${i}`)
|
|
248
|
+
.join(', ');
|
|
249
|
+
const templateParameterWithoutTypename = templateParameter
|
|
250
|
+
.map((v, i) => `P${i}`)
|
|
251
|
+
.join(', ');
|
|
252
|
+
let i = -1;
|
|
253
|
+
const templateMemberTypes = value.properties.map(v => {
|
|
254
|
+
if (isDirectRecursiveMember(alias, v.typeAnnotation)) {
|
|
255
|
+
return `std::unique_ptr<${structName}<${templateParameterWithoutTypename}>> ${v.name}`;
|
|
256
|
+
} else if (isArrayRecursiveMember(alias, v.typeAnnotation)) {
|
|
257
|
+
const [nullable] = unwrapNullable<NativeModuleTypeAnnotation>(
|
|
258
|
+
v.typeAnnotation,
|
|
259
|
+
);
|
|
260
|
+
return (
|
|
261
|
+
(nullable
|
|
262
|
+
? `std::optional<std::vector<${structName}<${templateParameterWithoutTypename}>>>`
|
|
263
|
+
: `std::vector<${structName}<${templateParameterWithoutTypename}>>`) +
|
|
264
|
+
` ${v.name}`
|
|
265
|
+
);
|
|
266
|
+
} else {
|
|
267
|
+
i++;
|
|
268
|
+
return `P${i} ${v.name}`;
|
|
321
269
|
}
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
const templateParameterWithTypename = templateParameter
|
|
329
|
-
.map((v, i) => `typename P${i}`)
|
|
330
|
-
.join(', ');
|
|
331
|
-
const templateParameterWithoutTypename = templateParameter
|
|
332
|
-
.map((v, i) => `P${i}`)
|
|
333
|
-
.join(', ');
|
|
334
|
-
let i = -1;
|
|
335
|
-
const templateMemberTypes = value.properties.map(v => {
|
|
336
|
-
if (isDirectRecursiveMember(alias, v.typeAnnotation)) {
|
|
337
|
-
return `std::unique_ptr<${structName}<${templateParameterWithoutTypename}>> ${v.name}`;
|
|
338
|
-
} else if (isArrayRecursiveMember(alias, v.typeAnnotation)) {
|
|
339
|
-
const [nullable] = unwrapNullable<NativeModuleTypeAnnotation>(
|
|
340
|
-
v.typeAnnotation,
|
|
341
|
-
);
|
|
342
|
-
return (
|
|
343
|
-
(nullable
|
|
344
|
-
? `std::optional<std::vector<${structName}<${templateParameterWithoutTypename}>>>`
|
|
345
|
-
: `std::vector<${structName}<${templateParameterWithoutTypename}>>`) +
|
|
346
|
-
` ${v.name}`
|
|
347
|
-
);
|
|
348
|
-
} else {
|
|
349
|
-
i++;
|
|
350
|
-
return `P${i} ${v.name}`;
|
|
351
|
-
}
|
|
352
|
-
});
|
|
353
|
-
const debugParameterConversion = value.properties
|
|
354
|
-
.map(
|
|
355
|
-
v => ` static ${getCppType(alias, v)} ${
|
|
356
|
-
v.name
|
|
357
|
-
}ToJs(jsi::Runtime &rt, decltype(types.${v.name}) value) {
|
|
270
|
+
});
|
|
271
|
+
const debugParameterConversion = value.properties
|
|
272
|
+
.map(
|
|
273
|
+
v => ` static ${getCppType(alias, v)} ${
|
|
274
|
+
v.name
|
|
275
|
+
}ToJs(jsi::Runtime &rt, decltype(types.${v.name}) value) {
|
|
358
276
|
return bridging::toJs(rt, value);
|
|
359
277
|
}`,
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
278
|
+
)
|
|
279
|
+
.join('\n\n');
|
|
280
|
+
return `
|
|
363
281
|
#pragma mark - ${structName}
|
|
364
282
|
|
|
365
283
|
template <${templateParameterWithTypename}>
|
|
@@ -422,9 +340,8 @@ ${value.properties
|
|
|
422
340
|
};
|
|
423
341
|
|
|
424
342
|
`;
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
);
|
|
343
|
+
})
|
|
344
|
+
.join('\n');
|
|
428
345
|
}
|
|
429
346
|
|
|
430
347
|
type NativeEnumMemberValueType = 'std::string' | 'int32_t' | 'float';
|