react-native-sdk-pianoio 0.2.0 → 0.2.1
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/README.md +102 -5
- package/package.json +1 -1
package/README.md
CHANGED
@@ -4,6 +4,21 @@ Lo scopo di questo pacchetto npm è quello di avere la possibilità di interagir
|
|
4
4
|
|
5
5
|
Il progetto è ancora in **work in progress**.
|
6
6
|
|
7
|
+
## Indice
|
8
|
+
|
9
|
+
- [Installazione](#installazione)
|
10
|
+
- [Expo](#expo)
|
11
|
+
- [Adattamento del pacchetto a expo < 52](#adattamento-del-pacchetto-a-expo--52)
|
12
|
+
- [React native](#react-native)
|
13
|
+
- [Utilizzo](#utilizzo)
|
14
|
+
- [Importazione](#importazione)
|
15
|
+
- [Creazione del Composer](#creazione-del-composer)
|
16
|
+
- [Metodi del Composer](#metodi-del-composer)
|
17
|
+
- [Metodi statici](#metodi-statici)
|
18
|
+
- [Esempio completo](#esempio-completo)
|
19
|
+
<!-- - [Contributing](#contributing)
|
20
|
+
- [License](#license) -->
|
21
|
+
|
7
22
|
## Installazione
|
8
23
|
|
9
24
|
### Expo
|
@@ -34,6 +49,90 @@ In seguito si può far partire il progetto, tramite il comando:
|
|
34
49
|
npx expo start
|
35
50
|
```
|
36
51
|
|
52
|
+
### Adattamento del pacchetto a Expo < 52
|
53
|
+
|
54
|
+
Con l’introduzione della versione Expo SDK 52, il team di Expo ha adottato la **New Architecture** di React Native, che introduce importanti novità come i TurboModules, il Codegen e un nuovo sistema di gestione degli eventi (incluso EventEmitterCallback). Questi cambiamenti migliorano performance, interoperabilità con pacchetti nativi complessi e garantiscono una maggiore compatibilità futura con React Native.
|
55
|
+
|
56
|
+
Tuttavia, questa evoluzione comporta incompatibilità con versioni precedenti (Expo 51 o inferiori), che non includono le definizioni e i meccanismi introdotti dalla nuova architettura.
|
57
|
+
|
58
|
+
Un esempio concreto è l’uso del tipo facebook::react::EventEmitterCallback, che esiste solo all’interno della New Architecture.
|
59
|
+
|
60
|
+
Per far funzionare il pacchetto con versioni precedenti alla 52, è necessario usare un approccio un po' forzato, modificando manualmente il codice generato per evitare riferimenti non supportati.
|
61
|
+
|
62
|
+
Una volta installato il pacchetto e aver eseguito:
|
63
|
+
```sh
|
64
|
+
npx expo run:ios
|
65
|
+
```
|
66
|
+
|
67
|
+
Dovrebbe comparire una serie di errori simili a questo:
|
68
|
+
|
69
|
+
```sh
|
70
|
+
❌ (node_modules/react-native-sdk-pianoio/ios/generated/RNSdkPianoioSpec/RNSdkPianoioSpec.h:72:18)
|
71
|
+
|
72
|
+
70 | @interface NativeSdkPianoioSpecBase : NSObject {
|
73
|
+
71 | @protected
|
74
|
+
> 72 | facebook::react::EventEmitterCallback _eventEmitterCallback;
|
75
|
+
| ^ no type named 'EventEmitterCallback' in namespace 'facebook::react'
|
76
|
+
73 | }
|
77
|
+
74 | - (void)setEventEmitterCallback:(EventEmitterCallbackWrapper *) eventEmitterCallbackWrapper;
|
78
|
+
75 |
|
79
|
+
```
|
80
|
+
|
81
|
+
I file causanti di questi errori sono:
|
82
|
+
- RNSdkPianoioSpec.h
|
83
|
+
- RNSdkPianoioSpec-generated.mm
|
84
|
+
|
85
|
+
Quindi, cliccare sulla referenza del file e andare alla linea dell'errore.
|
86
|
+
|
87
|
+
#### Modifica del file RNSdkPianoioSpec.h
|
88
|
+
|
89
|
+
```
|
90
|
+
@interface NativeSdkPianoioSpecBase : NSObject {
|
91
|
+
@protected
|
92
|
+
facebook::react::EventEmitterCallback _eventEmitterCallback;
|
93
|
+
}
|
94
|
+
- (void)setEventEmitterCallback:(EventEmitterCallbackWrapper *) eventEmitterCallbackWrapper;
|
95
|
+
|
96
|
+
@end
|
97
|
+
```
|
98
|
+
Sostituire il codice sovrastante con:
|
99
|
+
|
100
|
+
```
|
101
|
+
@interface NativeSdkPianoioSpecBase : NSObject {
|
102
|
+
@protected
|
103
|
+
void *_eventEmitterCallback;
|
104
|
+
}
|
105
|
+
- (void)setEventEmitterCallback:(void *)eventEmitterCallbackWrapper;
|
106
|
+
|
107
|
+
@end
|
108
|
+
```
|
109
|
+
|
110
|
+
#### Modifica del file RNSdkPianoioSpec.h
|
111
|
+
|
112
|
+
```
|
113
|
+
@implementation NativeSdkPianoioSpecBase
|
114
|
+
|
115
|
+
|
116
|
+
- (void)setEventEmitterCallback:(EventEmitterCallbackWrapper *)eventEmitterCallbackWrapper
|
117
|
+
{
|
118
|
+
_eventEmitterCallback = std::move(eventEmitterCallbackWrapper->_eventEmitterCallback);
|
119
|
+
}
|
120
|
+
@end
|
121
|
+
```
|
122
|
+
|
123
|
+
Sostituire il codice sovrastante con:
|
124
|
+
|
125
|
+
```
|
126
|
+
@implementation NativeSdkPianoioSpecBase
|
127
|
+
|
128
|
+
- (void)setEventEmitterCallback:(void *)eventEmitterCallbackWrapper;
|
129
|
+
{
|
130
|
+
_eventEmitterCallback = std::move(eventEmitterCallbackWrapper);
|
131
|
+
}
|
132
|
+
@end
|
133
|
+
```
|
134
|
+
|
135
|
+
|
37
136
|
### React native
|
38
137
|
|
39
138
|
Nel progetto di react native eseguire:
|
@@ -74,7 +173,7 @@ import PianoComposer from './PianoComposer';
|
|
74
173
|
const composer = await PianoComposer.create('your_aid');
|
75
174
|
```
|
76
175
|
|
77
|
-
##
|
176
|
+
## Metodi del Composer
|
78
177
|
|
79
178
|
### `addTag(tag: string)`
|
80
179
|
|
@@ -170,7 +269,7 @@ PianoComposer {
|
|
170
269
|
|
171
270
|
---
|
172
271
|
|
173
|
-
##
|
272
|
+
## Metodi statici
|
174
273
|
|
175
274
|
### `PianoComposer.create(aid: string): Promise<PianoComposer>`
|
176
275
|
|
@@ -201,7 +300,7 @@ Recupera i dati correnti dal modulo nativo iOS. Questo oggetto include:
|
|
201
300
|
}
|
202
301
|
```
|
203
302
|
|
204
|
-
##
|
303
|
+
## Esempio completo
|
205
304
|
|
206
305
|
```ts
|
207
306
|
const composer = await PianoComposer.create('YOUR_AID');
|
@@ -213,8 +312,6 @@ await composer.setUrl('https://my.site/article');
|
|
213
312
|
await composer.setUserToken('jwt-token');
|
214
313
|
await composer.setCustomVariable('device', 'mobile');
|
215
314
|
|
216
|
-
await composer.execute();
|
217
|
-
|
218
315
|
console.log(await composer.toString());
|
219
316
|
```
|
220
317
|
|