@react-native/codegen 0.74.0-nightly-20231125-caae38891 → 0.74.0-nightly-20231127-86c5abac2

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.
@@ -257,33 +257,37 @@ function createStructsString(moduleName, aliasMap, resolveAlias, enumMap) {
257
257
  resolveAlias,
258
258
  enumMap,
259
259
  );
260
- return Object.keys(aliasMap)
261
- .map(alias => {
262
- const value = aliasMap[alias];
263
- if (value.properties.length === 0) {
264
- return '';
265
- }
266
- const structName = `${moduleName}Base${alias}`;
267
- const templateParameterWithTypename = value.properties
268
- .map((v, i) => `typename P${i}`)
269
- .join(', ');
270
- const templateParameter = value.properties
271
- .map((v, i) => 'P' + i)
272
- .join(', ');
273
- const debugParameterConversion = value.properties
274
- .map(
275
- (v, i) => ` static ${getCppType(v)} ${
276
- v.name
277
- }ToJs(jsi::Runtime &rt, P${i} value) {
260
+
261
+ // TODO: T171006733 [Begin] Remove deprecated Cxx TMs structs after a new release.
262
+ return (
263
+ Object.keys(aliasMap)
264
+ .map(alias => {
265
+ const value = aliasMap[alias];
266
+ if (value.properties.length === 0) {
267
+ return '';
268
+ }
269
+ const structName = `${moduleName}Base${alias}`;
270
+ const structNameNew = `${moduleName}${alias}`;
271
+ const templateParameterWithTypename = value.properties
272
+ .map((v, i) => `typename P${i}`)
273
+ .join(', ');
274
+ const templateParameter = value.properties
275
+ .map((v, i) => 'P' + i)
276
+ .join(', ');
277
+ const debugParameterConversion = value.properties
278
+ .map(
279
+ (v, i) => ` static ${getCppType(v)} ${
280
+ v.name
281
+ }ToJs(jsi::Runtime &rt, P${i} value) {
278
282
  return bridging::toJs(rt, value);
279
283
  }`,
280
- )
281
- .join('\n\n');
282
- return `
284
+ )
285
+ .join('\n\n');
286
+ return `
283
287
  #pragma mark - ${structName}
284
288
 
285
289
  template <${templateParameterWithTypename}>
286
- struct ${structName} {
290
+ struct [[deprecated("Use ${structNameNew} instead.")]] ${structName} {
287
291
  ${value.properties.map((v, i) => ' P' + i + ' ' + v.name).join(';\n')};
288
292
  bool operator==(const ${structName} &other) const {
289
293
  return ${value.properties
@@ -293,7 +297,7 @@ ${value.properties.map((v, i) => ' P' + i + ' ' + v.name).join(';\n')};
293
297
  };
294
298
 
295
299
  template <${templateParameterWithTypename}>
296
- struct ${structName}Bridging {
300
+ struct [[deprecated("Use ${structNameNew}Bridging instead.")]] ${structName}Bridging {
297
301
  static ${structName}<${templateParameter}> fromJs(
298
302
  jsi::Runtime &rt,
299
303
  const jsi::Object &value,
@@ -333,8 +337,87 @@ ${value.properties
333
337
  };
334
338
 
335
339
  `;
336
- })
337
- .join('\n');
340
+ })
341
+ .join('\n') +
342
+ // TODO: T171006733 [End] Remove deprecated Cxx TMs structs after a new release.
343
+ Object.keys(aliasMap)
344
+ .map(alias => {
345
+ const value = aliasMap[alias];
346
+ if (value.properties.length === 0) {
347
+ return '';
348
+ }
349
+ const structName = `${moduleName}${alias}`;
350
+ const templateParameterWithTypename = value.properties
351
+ .map((v, i) => `typename P${i}`)
352
+ .join(', ');
353
+ const debugParameterConversion = value.properties
354
+ .map(
355
+ (v, i) => ` static ${getCppType(v)} ${
356
+ v.name
357
+ }ToJs(jsi::Runtime &rt, decltype(types.${v.name}) value) {
358
+ return bridging::toJs(rt, value);
359
+ }`,
360
+ )
361
+ .join('\n\n');
362
+ return `
363
+ #pragma mark - ${structName}
364
+
365
+ template <${templateParameterWithTypename}>
366
+ struct ${structName} {
367
+ ${value.properties.map((v, i) => ' P' + i + ' ' + v.name).join(';\n')};
368
+ bool operator==(const ${structName} &other) const {
369
+ return ${value.properties
370
+ .map(v => `${v.name} == other.${v.name}`)
371
+ .join(' && ')};
372
+ }
373
+ };
374
+
375
+ template <typename T>
376
+ struct ${structName}Bridging {
377
+ static T types;
378
+
379
+ static T fromJs(
380
+ jsi::Runtime &rt,
381
+ const jsi::Object &value,
382
+ const std::shared_ptr<CallInvoker> &jsInvoker) {
383
+ T result{
384
+ ${value.properties
385
+ .map(
386
+ (v, i) =>
387
+ ` bridging::fromJs<decltype(types.${v.name})>(rt, value.getProperty(rt, "${v.name}"), jsInvoker)`,
388
+ )
389
+ .join(',\n')}};
390
+ return result;
391
+ }
392
+
393
+ #ifdef DEBUG
394
+ ${debugParameterConversion}
395
+ #endif
396
+
397
+ static jsi::Object toJs(
398
+ jsi::Runtime &rt,
399
+ const T &value,
400
+ const std::shared_ptr<CallInvoker> &jsInvoker) {
401
+ auto result = facebook::jsi::Object(rt);
402
+ ${value.properties
403
+ .map((v, i) => {
404
+ if (v.optional) {
405
+ return ` if (value.${v.name}) {
406
+ result.setProperty(rt, "${v.name}", bridging::toJs(rt, value.${v.name}.value(), jsInvoker));
407
+ }`;
408
+ } else {
409
+ return ` result.setProperty(rt, "${v.name}", bridging::toJs(rt, value.${v.name}, jsInvoker));`;
410
+ }
411
+ })
412
+ .join('\n')}
413
+ return result;
414
+ }
415
+ };
416
+
417
+ `;
418
+ })
419
+ .join('\n')
420
+ );
338
421
  }
339
422
  const EnumTemplate = ({
340
423
  enumName,
@@ -232,33 +232,36 @@ function createStructsString(
232
232
  enumMap,
233
233
  );
234
234
 
235
- return Object.keys(aliasMap)
236
- .map(alias => {
237
- const value = aliasMap[alias];
238
- if (value.properties.length === 0) {
239
- return '';
240
- }
241
- const structName = `${moduleName}Base${alias}`;
242
- const templateParameterWithTypename = value.properties
243
- .map((v, i) => `typename P${i}`)
244
- .join(', ');
245
- const templateParameter = value.properties
246
- .map((v, i) => 'P' + i)
247
- .join(', ');
248
- const debugParameterConversion = value.properties
249
- .map(
250
- (v, i) => ` static ${getCppType(v)} ${
251
- v.name
252
- }ToJs(jsi::Runtime &rt, P${i} value) {
235
+ // TODO: T171006733 [Begin] Remove deprecated Cxx TMs structs after a new release.
236
+ return (
237
+ Object.keys(aliasMap)
238
+ .map(alias => {
239
+ const value = aliasMap[alias];
240
+ if (value.properties.length === 0) {
241
+ return '';
242
+ }
243
+ const structName = `${moduleName}Base${alias}`;
244
+ const structNameNew = `${moduleName}${alias}`;
245
+ const templateParameterWithTypename = value.properties
246
+ .map((v, i) => `typename P${i}`)
247
+ .join(', ');
248
+ const templateParameter = value.properties
249
+ .map((v, i) => 'P' + i)
250
+ .join(', ');
251
+ const debugParameterConversion = value.properties
252
+ .map(
253
+ (v, i) => ` static ${getCppType(v)} ${
254
+ v.name
255
+ }ToJs(jsi::Runtime &rt, P${i} value) {
253
256
  return bridging::toJs(rt, value);
254
257
  }`,
255
- )
256
- .join('\n\n');
257
- return `
258
+ )
259
+ .join('\n\n');
260
+ return `
258
261
  #pragma mark - ${structName}
259
262
 
260
263
  template <${templateParameterWithTypename}>
261
- struct ${structName} {
264
+ struct [[deprecated("Use ${structNameNew} instead.")]] ${structName} {
262
265
  ${value.properties.map((v, i) => ' P' + i + ' ' + v.name).join(';\n')};
263
266
  bool operator==(const ${structName} &other) const {
264
267
  return ${value.properties
@@ -268,7 +271,7 @@ ${value.properties.map((v, i) => ' P' + i + ' ' + v.name).join(';\n')};
268
271
  };
269
272
 
270
273
  template <${templateParameterWithTypename}>
271
- struct ${structName}Bridging {
274
+ struct [[deprecated("Use ${structNameNew}Bridging instead.")]] ${structName}Bridging {
272
275
  static ${structName}<${templateParameter}> fromJs(
273
276
  jsi::Runtime &rt,
274
277
  const jsi::Object &value,
@@ -308,8 +311,87 @@ ${value.properties
308
311
  };
309
312
 
310
313
  `;
311
- })
312
- .join('\n');
314
+ })
315
+ .join('\n') +
316
+ // TODO: T171006733 [End] Remove deprecated Cxx TMs structs after a new release.
317
+ Object.keys(aliasMap)
318
+ .map(alias => {
319
+ const value = aliasMap[alias];
320
+ if (value.properties.length === 0) {
321
+ return '';
322
+ }
323
+ const structName = `${moduleName}${alias}`;
324
+ const templateParameterWithTypename = value.properties
325
+ .map((v, i) => `typename P${i}`)
326
+ .join(', ');
327
+ const debugParameterConversion = value.properties
328
+ .map(
329
+ (v, i) => ` static ${getCppType(v)} ${
330
+ v.name
331
+ }ToJs(jsi::Runtime &rt, decltype(types.${v.name}) value) {
332
+ return bridging::toJs(rt, value);
333
+ }`,
334
+ )
335
+ .join('\n\n');
336
+ return `
337
+ #pragma mark - ${structName}
338
+
339
+ template <${templateParameterWithTypename}>
340
+ struct ${structName} {
341
+ ${value.properties.map((v, i) => ' P' + i + ' ' + v.name).join(';\n')};
342
+ bool operator==(const ${structName} &other) const {
343
+ return ${value.properties
344
+ .map(v => `${v.name} == other.${v.name}`)
345
+ .join(' && ')};
346
+ }
347
+ };
348
+
349
+ template <typename T>
350
+ struct ${structName}Bridging {
351
+ static T types;
352
+
353
+ static T fromJs(
354
+ jsi::Runtime &rt,
355
+ const jsi::Object &value,
356
+ const std::shared_ptr<CallInvoker> &jsInvoker) {
357
+ T result{
358
+ ${value.properties
359
+ .map(
360
+ (v, i) =>
361
+ ` bridging::fromJs<decltype(types.${v.name})>(rt, value.getProperty(rt, "${v.name}"), jsInvoker)`,
362
+ )
363
+ .join(',\n')}};
364
+ return result;
365
+ }
366
+
367
+ #ifdef DEBUG
368
+ ${debugParameterConversion}
369
+ #endif
370
+
371
+ static jsi::Object toJs(
372
+ jsi::Runtime &rt,
373
+ const T &value,
374
+ const std::shared_ptr<CallInvoker> &jsInvoker) {
375
+ auto result = facebook::jsi::Object(rt);
376
+ ${value.properties
377
+ .map((v, i) => {
378
+ if (v.optional) {
379
+ return ` if (value.${v.name}) {
380
+ result.setProperty(rt, "${v.name}", bridging::toJs(rt, value.${v.name}.value(), jsInvoker));
381
+ }`;
382
+ } else {
383
+ return ` result.setProperty(rt, "${v.name}", bridging::toJs(rt, value.${v.name}, jsInvoker));`;
384
+ }
385
+ })
386
+ .join('\n')}
387
+ return result;
388
+ }
389
+ };
390
+
391
+ `;
392
+ })
393
+ .join('\n')
394
+ );
313
395
  }
314
396
 
315
397
  type NativeEnumMemberValueType = 'std::string' | 'int32_t' | 'float';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native/codegen",
3
- "version": "0.74.0-nightly-20231125-caae38891",
3
+ "version": "0.74.0-nightly-20231127-86c5abac2",
4
4
  "description": "Code generation tools for React Native",
5
5
  "license": "MIT",
6
6
  "repository": {