@javascriptcommon/react-native-carplay 2.4.4 → 2.4.5

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/ios/RNCarPlay.m CHANGED
@@ -167,9 +167,11 @@ RCT_EXPORT_MODULE();
167
167
  }
168
168
 
169
169
  - (void)updateItemImageWithURL:(CPListItem *)item imgUrl:(NSString *)imgUrlString placeholderImage:(UIImage *)placeholderImage {
170
- dispatch_async(dispatch_get_main_queue(), ^{
171
- [item setImage:placeholderImage];
172
- });
170
+ if (placeholderImage != nil) {
171
+ dispatch_async(dispatch_get_main_queue(), ^{
172
+ [item setImage:placeholderImage];
173
+ });
174
+ }
173
175
 
174
176
  NSURL *imgUrl = [NSURL URLWithString:imgUrlString];
175
177
 
@@ -186,20 +188,22 @@ RCT_EXPORT_MODULE();
186
188
  [task resume];
187
189
  }
188
190
 
189
- - (void)updateListRowItemImageWithURL:(CPListImageRowItem *)item imgUrl:(NSString *)imgUrlString index:(int)index placeholderImage:(UIImage *)placeholderImage {
190
- dispatch_async(dispatch_get_main_queue(), ^{
191
- NSMutableArray* newImages = [item.gridImages mutableCopy];
192
-
193
- @try {
194
- newImages[index] = placeholderImage;
195
- }
196
- @catch (NSException *exception) {
197
- // Best effort updating the array
198
- NSLog(@"Failed to update images array of CPListImageRowItem");
199
- }
200
-
201
- [item updateImages:newImages];
202
- });
191
+ - (void)updateListRowItemImageWithURL:(CPListImageRowItem *)item imgUrl:(NSString *)imgUrlString index:(int)index placeholderImage:(UIImage *)placeholderImage {
192
+ if (placeholderImage != nil) {
193
+ dispatch_async(dispatch_get_main_queue(), ^{
194
+ NSMutableArray* newImages = [item.gridImages mutableCopy];
195
+
196
+ @try {
197
+ newImages[index] = placeholderImage;
198
+ }
199
+ @catch (NSException *exception) {
200
+ // Best effort updating the array
201
+ NSLog(@"Failed to update images array of CPListImageRowItem");
202
+ }
203
+
204
+ [item updateImages:newImages];
205
+ });
206
+ }
203
207
 
204
208
  NSURL *imgUrl = [NSURL URLWithString:imgUrlString];
205
209
 
@@ -690,7 +694,11 @@ RCT_EXPORT_METHOD(updateListTemplateItem:(NSString *)templateId config:(NSDictio
690
694
  CPListItem *item = (CPListItem *)section.items[index];
691
695
  if (config[@"imgUrl"]) {
692
696
  NSString *imgUrlString = [RCTConvert NSString:config[@"imgUrl"]];
693
- [self updateItemImageWithURL:item imgUrl:imgUrlString];
697
+ UIImage *placeholderImage;
698
+ if (config[@"placeholderImage"] != nil) {
699
+ placeholderImage = [RCTConvert UIImage:config[@"placeholderImage"]];
700
+ }
701
+ [self updateItemImageWithURL:item imgUrl:imgUrlString placeholderImage:placeholderImage];
694
702
  }
695
703
  if (config[@"image"]) {
696
704
  [item setImage:[RCTConvert UIImage:config[@"image"]]];
@@ -1120,7 +1128,7 @@ RCT_EXPORT_METHOD(updateMapTemplateMapButtons:(NSString*) templateId mapButtons:
1120
1128
  }
1121
1129
  if (item[@"imgUrl"]) {
1122
1130
  NSString *imgUrlString = [RCTConvert NSString:item[@"imgUrl"]];
1123
- UIImage *placeholderImage
1131
+ UIImage *placeholderImage;
1124
1132
  if ([item objectForKey:@"placeholderImage"] != nil) {
1125
1133
  placeholderImage = [RCTConvert UIImage:[item objectForKey:@"placeholderImage"]];
1126
1134
  }
@@ -1162,9 +1170,12 @@ RCT_EXPORT_METHOD(updateMapTemplateMapButtons:(NSString*) templateId mapButtons:
1162
1170
  NSArray *_placeholderImages = [item objectForKey:@"placeholderImages"];
1163
1171
  int _index = 0;
1164
1172
  for (NSString* imgUrl in _slicedArray) {
1165
- UIImage *placeholderImage;
1166
- if (_placeholderImages != nil) {
1167
- placeholderImage = [RCTConvert UIImage:_placeholderImages[_index]];
1173
+ UIImage *placeholderImage = nil;
1174
+ if (_placeholderImages != nil && _index < _placeholderImages.count) {
1175
+ id placeholderImageObj = _placeholderImages[_index];
1176
+ if (placeholderImageObj != nil && placeholderImageObj != [NSNull null]) {
1177
+ placeholderImage = [RCTConvert UIImage:placeholderImageObj];
1178
+ }
1168
1179
  }
1169
1180
  [self updateListRowItemImageWithURL:_item imgUrl:imgUrl index:_index placeholderImage:placeholderImage];
1170
1181
  _index++;
@@ -1 +1 @@
1
- {"version":3,"file":"Template.d.ts","sourceRoot":"","sources":["../../src/templates/Template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAY,MAAM,cAAc,CAAC;AAE7D,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAKpD,MAAM,WAAW,SAAS;IACxB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,cAAe,SAAQ,SAAS;IAC/C,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;;;;OAKG;IACH,2BAA2B,CAAC,EAAE,SAAS,EAAE,CAAC;IAC1C;;;;;OAKG;IACH,4BAA4B,CAAC,EAAE,SAAS,EAAE,CAAC;IAC3C;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B;;OAEG;IACH,QAAQ,CAAC,EAAE,mBAAmB,CAAC;IAC/B;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,YAAY,CAAC,CAAC,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC;IAClC;;;OAGG;IACH,eAAe,CAAC,CAAC,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC;IACrC;;;OAGG;IACH,WAAW,CAAC,CAAC,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC;IACjC;;;OAGG;IACH,cAAc,CAAC,CAAC,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC;IAEpC;;;OAGG;IACH,kBAAkB,CAAC,CAAC,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;CAC9C;AAED,qBAAa,QA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C,CAAC,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC;IAEpC;;;OAGG;IACH,kBAAkB,CAAC,CAAC,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;CAC9C;AAED,qBAAa,QAAQ,CAAC,CAAC;IAUF,MAAM,EAAE,cAAc,GAAG,CAAC;IAT7C,IAAW,IAAI,IAAI,MAAM,CAExB;IACM,EAAE,EAAG,MAAM,CAAC;IAEnB,IAAW,QAAQ,OAElB;gBAEkB,MAAM,EAAE,cAAc,GAAG,CAAC;IAiD7C,cAAc,WAAY,CAAC,UAGzB;IAGK,WAAW,CAAC,MAAM,EAAE,GAAG;CAyB/B"}
@@ -57,13 +57,21 @@ class Template {
57
57
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
58
58
  function traverse(obj) {
59
59
  for (const i in obj) {
60
- if (obj[i] !== null && typeof obj[i] === 'object') {
61
- traverse(obj[i]);
60
+ if (String(i).match(/[Ii]mages$/)) {
61
+ console.log('array parsing', i, obj[i]);
62
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call
63
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
64
+ obj[i] = obj[i].map((asset) => resolveAssetSource(asset));
65
+ console.log('array parsed', i, obj[i]);
62
66
  }
63
- if (String(i).match(/[Ii]mage$/)) {
67
+ else if (String(i).match(/[Ii]mage$/)) {
68
+ console.log('single image parsing', i, obj[i]);
64
69
  // eslint-disable-next-line @typescript-eslint/no-unsafe-call
65
70
  obj[i] = resolveAssetSource(obj[i]);
66
71
  }
72
+ else if (obj[i] !== null && typeof obj[i] === 'object') {
73
+ traverse(obj[i]);
74
+ }
67
75
  }
68
76
  }
69
77
  const result = JSON.parse(JSON.stringify(config));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@javascriptcommon/react-native-carplay",
3
- "version": "2.4.4",
3
+ "version": "2.4.5",
4
4
  "description": "CarPlay for React Native",
5
5
  "main": "lib/index.js",
6
6
  "react-native": "src/index.ts",
@@ -148,13 +148,21 @@ export class Template<P> {
148
148
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
149
149
  function traverse(obj: any) {
150
150
  for (const i in obj) {
151
- if (obj[i] !== null && typeof obj[i] === 'object') {
152
- traverse(obj[i]);
151
+ if (String(i).match(/[Ii]mages$/)) {
152
+ console.log('array parsing', i, obj[i])
153
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call
154
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
155
+ obj[i] = obj[i].map((asset: any) => resolveAssetSource(asset));
156
+ console.log('array parsed', i, obj[i])
153
157
  }
154
- if (String(i).match(/[Ii]mage$/)) {
158
+ else if (String(i).match(/[Ii]mage$/)) {
159
+ console.log('single image parsing', i, obj[i])
155
160
  // eslint-disable-next-line @typescript-eslint/no-unsafe-call
156
161
  obj[i] = resolveAssetSource(obj[i]);
157
162
  }
163
+ else if (obj[i] !== null && typeof obj[i] === 'object') {
164
+ traverse(obj[i]);
165
+ }
158
166
  }
159
167
  }
160
168
  const result = JSON.parse(JSON.stringify(config));