@react-native/codegen 0.79.0-nightly-20250304-25d501df7 → 0.79.0-rc.0
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.
|
@@ -45,11 +45,11 @@ const ComponentTemplate = ({
|
|
|
45
45
|
dispatchEventName,
|
|
46
46
|
implementation,
|
|
47
47
|
}) => {
|
|
48
|
-
const capture = implementation.includes('event')
|
|
49
|
-
? 'event=std::move(event)'
|
|
48
|
+
const capture = implementation.includes('$event')
|
|
49
|
+
? '$event=std::move($event)'
|
|
50
50
|
: '';
|
|
51
51
|
return `
|
|
52
|
-
void ${className}EventEmitter::${eventName}(${structName} event) const {
|
|
52
|
+
void ${className}EventEmitter::${eventName}(${structName} $event) const {
|
|
53
53
|
dispatchEvent("${dispatchEventName}", [${capture}](jsi::Runtime &runtime) {
|
|
54
54
|
${implementation}
|
|
55
55
|
});
|
|
@@ -70,7 +70,7 @@ function generateSetter(
|
|
|
70
70
|
valueMapper = value => value,
|
|
71
71
|
) {
|
|
72
72
|
const eventChain = usingEvent
|
|
73
|
-
?
|
|
73
|
+
? `$event.${[...propertyParts, propertyName].join('.')}`
|
|
74
74
|
: [...propertyParts, propertyName].join('.');
|
|
75
75
|
return `${variableName}.setProperty(runtime, "${propertyName}", ${valueMapper(
|
|
76
76
|
eventChain,
|
|
@@ -120,7 +120,7 @@ function generateArraySetter(
|
|
|
120
120
|
usingEvent,
|
|
121
121
|
) {
|
|
122
122
|
const eventChain = usingEvent
|
|
123
|
-
?
|
|
123
|
+
? `$event.${[...propertyParts, propertyName].join('.')}`
|
|
124
124
|
: [...propertyParts, propertyName].join('.');
|
|
125
125
|
const indexVar = `${propertyName}Index`;
|
|
126
126
|
const innerLoopVar = `${propertyName}Value`;
|
|
@@ -329,14 +329,14 @@ function generateEvent(componentName, event, extraIncludes) {
|
|
|
329
329
|
: `${event.name[2].toLowerCase()}${event.name.slice(3)}`;
|
|
330
330
|
if (event.typeAnnotation.argument) {
|
|
331
331
|
const implementation = `
|
|
332
|
-
auto payload = jsi::Object(runtime);
|
|
332
|
+
auto $payload = jsi::Object(runtime);
|
|
333
333
|
${generateSetters(
|
|
334
|
-
'payload',
|
|
334
|
+
'$payload',
|
|
335
335
|
event.typeAnnotation.argument.properties,
|
|
336
336
|
[],
|
|
337
337
|
extraIncludes,
|
|
338
338
|
)}
|
|
339
|
-
return payload;
|
|
339
|
+
return $payload;
|
|
340
340
|
`.trim();
|
|
341
341
|
if (!event.name.startsWith('on')) {
|
|
342
342
|
throw new Error('Expected the event name to start with `on`');
|
|
@@ -68,11 +68,11 @@ const ComponentTemplate = ({
|
|
|
68
68
|
dispatchEventName: string,
|
|
69
69
|
implementation: string,
|
|
70
70
|
}) => {
|
|
71
|
-
const capture = implementation.includes('event')
|
|
72
|
-
? 'event=std::move(event)'
|
|
71
|
+
const capture = implementation.includes('$event')
|
|
72
|
+
? '$event=std::move($event)'
|
|
73
73
|
: '';
|
|
74
74
|
return `
|
|
75
|
-
void ${className}EventEmitter::${eventName}(${structName} event) const {
|
|
75
|
+
void ${className}EventEmitter::${eventName}(${structName} $event) const {
|
|
76
76
|
dispatchEvent("${dispatchEventName}", [${capture}](jsi::Runtime &runtime) {
|
|
77
77
|
${implementation}
|
|
78
78
|
});
|
|
@@ -103,7 +103,7 @@ function generateSetter(
|
|
|
103
103
|
valueMapper: string => string = value => value,
|
|
104
104
|
) {
|
|
105
105
|
const eventChain = usingEvent
|
|
106
|
-
?
|
|
106
|
+
? `$event.${[...propertyParts, propertyName].join('.')}`
|
|
107
107
|
: [...propertyParts, propertyName].join('.');
|
|
108
108
|
return `${variableName}.setProperty(runtime, "${propertyName}", ${valueMapper(
|
|
109
109
|
eventChain,
|
|
@@ -156,7 +156,7 @@ function generateArraySetter(
|
|
|
156
156
|
usingEvent: boolean,
|
|
157
157
|
): string {
|
|
158
158
|
const eventChain = usingEvent
|
|
159
|
-
?
|
|
159
|
+
? `$event.${[...propertyParts, propertyName].join('.')}`
|
|
160
160
|
: [...propertyParts, propertyName].join('.');
|
|
161
161
|
const indexVar = `${propertyName}Index`;
|
|
162
162
|
const innerLoopVar = `${propertyName}Value`;
|
|
@@ -376,14 +376,14 @@ function generateEvent(
|
|
|
376
376
|
|
|
377
377
|
if (event.typeAnnotation.argument) {
|
|
378
378
|
const implementation = `
|
|
379
|
-
auto payload = jsi::Object(runtime);
|
|
379
|
+
auto $payload = jsi::Object(runtime);
|
|
380
380
|
${generateSetters(
|
|
381
|
-
'payload',
|
|
381
|
+
'$payload',
|
|
382
382
|
event.typeAnnotation.argument.properties,
|
|
383
383
|
[],
|
|
384
384
|
extraIncludes,
|
|
385
385
|
)}
|
|
386
|
-
return payload;
|
|
386
|
+
return $payload;
|
|
387
387
|
`.trim();
|
|
388
388
|
|
|
389
389
|
if (!event.name.startsWith('on')) {
|