react-native-update 8.1.0 → 9.0.0-beta.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.
Files changed (37) hide show
  1. package/.github/workflows/e2e_android.yml +49 -0
  2. package/.github/workflows/e2e_ios.yml +182 -0
  3. package/.github/workflows/scripts/adb_all_emulators.sh +10 -0
  4. package/.github/workflows/scripts/database.rules +13 -0
  5. package/.github/workflows/scripts/firebase.json +39 -0
  6. package/.github/workflows/scripts/firestore.indexes.json +72 -0
  7. package/.github/workflows/scripts/firestore.rules +17 -0
  8. package/.github/workflows/scripts/functions/package.json +24 -0
  9. package/.github/workflows/scripts/functions/src/exports.ts +13 -0
  10. package/.github/workflows/scripts/functions/src/index.ts +12 -0
  11. package/.github/workflows/scripts/functions/src/sample-data.ts +80 -0
  12. package/.github/workflows/scripts/functions/src/testFunctionCustomRegion.ts +14 -0
  13. package/.github/workflows/scripts/functions/src/testFunctionDefaultRegion.ts +70 -0
  14. package/.github/workflows/scripts/functions/tsconfig.json +16 -0
  15. package/.github/workflows/scripts/start-firebase-emulator.bat +6 -0
  16. package/.github/workflows/scripts/start-firebase-emulator.sh +44 -0
  17. package/.github/workflows/scripts/storage.rules +21 -0
  18. package/README.md +8 -6
  19. package/android/build.gradle +22 -0
  20. package/android/jni/hpatch.c +4 -4
  21. package/android/jni/hpatch.h +3 -3
  22. package/android/src/main/java/cn/reactnative/modules/update/DownloadTaskParams.java +0 -2
  23. package/android/src/main/java/cn/reactnative/modules/update/UpdateModuleImpl.java +265 -0
  24. package/android/src/main/java/cn/reactnative/modules/update/UpdatePackage.java +31 -20
  25. package/android/src/newarch/cn/reactnative/modules/update/UpdateModule.java +147 -0
  26. package/android/src/{main/java → oldarch}/cn/reactnative/modules/update/UpdateModule.java +6 -2
  27. package/e2e/jest.config.js +12 -0
  28. package/e2e/starter.test.js +23 -0
  29. package/ios/RCTPushy/{RCTPushy.m → RCTPushy.mm} +116 -44
  30. package/ios/pushy_build_time.txt +1 -1
  31. package/lib/NativeUpdate.js +51 -0
  32. package/lib/main.js +29 -23
  33. package/package.json +36 -2
  34. package/react-native-update.podspec +20 -2
  35. /package/ios/RCTPushy/HDiffPatch/{HDiffPatch.m → HDiffPatch.mm} +0 -0
  36. /package/ios/RCTPushy/{RCTPushyDownloader.m → RCTPushyDownloader.mm} +0 -0
  37. /package/ios/RCTPushy/{RCTPushyManager.m → RCTPushyManager.mm} +0 -0
@@ -0,0 +1,23 @@
1
+ describe('Example', () => {
2
+ beforeAll(async () => {
3
+ await device.launchApp();
4
+ });
5
+
6
+ beforeEach(async () => {
7
+ await device.reloadReactNative();
8
+ });
9
+
10
+ it('should have welcome screen', async () => {
11
+ await expect(element(by.id('welcome'))).toBeVisible();
12
+ });
13
+
14
+ it('should show hello screen after tap', async () => {
15
+ await element(by.id('hello_button')).tap();
16
+ await expect(element(by.text('Hello!!!'))).toBeVisible();
17
+ });
18
+
19
+ it('should show world screen after tap', async () => {
20
+ await element(by.id('world_button')).tap();
21
+ await expect(element(by.text('World!!!'))).toBeVisible();
22
+ });
23
+ });
@@ -1,7 +1,10 @@
1
1
  #import "RCTPushy.h"
2
2
  #import "RCTPushyDownloader.h"
3
3
  #import "RCTPushyManager.h"
4
-
4
+ // Thanks to this guard, we won't import this header when we build for the old architecture.
5
+ #ifdef RCT_NEW_ARCH_ENABLED
6
+ #import "RCTPushySpec.h"
7
+ #endif
5
8
 
6
9
  #import <React/RCTConvert.h>
7
10
  #import <React/RCTLog.h>
@@ -189,29 +192,53 @@ RCT_EXPORT_MODULE(RCTPushy);
189
192
  return self;
190
193
  }
191
194
 
192
- RCT_EXPORT_METHOD(setBlockUpdate:(NSDictionary *)options)
195
+ RCT_EXPORT_METHOD(setBlockUpdate:(NSDictionary *)options
196
+ resolver:(RCTPromiseResolveBlock)resolve
197
+ rejecter:(RCTPromiseRejectBlock)reject)
193
198
  {
194
199
  // NSMutableDictionary *blockUpdateInfo = [NSMutableDictionary new];
195
200
  // blockUpdateInfo[@"reason"] = options[@"reason"];
196
201
  // blockUpdateInfo[@"until"] = options[@"until"];
197
- NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
198
- [defaults setObject:options forKey:keyBlockUpdate];
199
- [defaults synchronize];
202
+ @try {
203
+ NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
204
+ [defaults setObject:options forKey:keyBlockUpdate];
205
+ [defaults synchronize];
206
+ resolve(@true);
207
+ }
208
+ @catch (NSException *exception) {
209
+ reject(@"执行报错", nil, nil);
210
+ }
200
211
  }
201
212
 
202
- RCT_EXPORT_METHOD(setUuid:(NSString *)uuid)
213
+ RCT_EXPORT_METHOD(setUuid:(NSString *)uuid resolver:(RCTPromiseResolveBlock)resolve
214
+ rejecter:(RCTPromiseRejectBlock)reject)
203
215
  {
204
- NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
205
- [defaults setObject:uuid forKey:keyUuid];
206
- [defaults synchronize];
216
+ @try {
217
+ NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
218
+ [defaults setObject:uuid forKey:keyUuid];
219
+ [defaults synchronize];
220
+ resolve(@true);
221
+ }
222
+ @catch (NSException *exception) {
223
+ reject(@"json格式校验报错", nil, nil);
224
+ }
207
225
  }
208
226
 
209
227
  RCT_EXPORT_METHOD(setLocalHashInfo:(NSString *)hash
210
- value:(NSString *)value)
228
+ value:(NSString *)value resolver:(RCTPromiseResolveBlock)resolve
229
+ rejecter:(RCTPromiseRejectBlock)reject)
211
230
  {
212
- NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
213
- [defaults setObject:value forKey:[keyHashInfo stringByAppendingString:hash]];
214
- [defaults synchronize];
231
+ NSData *data = [value dataUsingEncoding:NSUTF8StringEncoding];
232
+ NSError *error = nil;
233
+ id object = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error];
234
+ if (object && [object isKindOfClass:[NSDictionary class]]) {
235
+ NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
236
+ [defaults setObject:value forKey:[keyHashInfo stringByAppendingString:hash]];
237
+ [defaults synchronize];
238
+ resolve(@true);
239
+ } else {
240
+ reject(@"json格式校验报错", nil, nil);
241
+ }
215
242
  }
216
243
 
217
244
 
@@ -266,7 +293,9 @@ RCT_EXPORT_METHOD(downloadPatchFromPpk:(NSDictionary *)options
266
293
  }];
267
294
  }
268
295
 
269
- RCT_EXPORT_METHOD(setNeedUpdate:(NSDictionary *)options)
296
+ RCT_EXPORT_METHOD(setNeedUpdate:(NSDictionary *)options
297
+ resolver:(RCTPromiseResolveBlock)resolve
298
+ rejecter:(RCTPromiseRejectBlock)reject)
270
299
  {
271
300
  NSString *hash = options[@"hash"];
272
301
 
@@ -287,45 +316,66 @@ RCT_EXPORT_METHOD(setNeedUpdate:(NSDictionary *)options)
287
316
  [defaults setObject:newInfo forKey:keyPushyInfo];
288
317
 
289
318
  [defaults synchronize];
319
+ resolve(@true);
320
+ }else{
321
+ reject(@"执行报错", nil, nil);
290
322
  }
291
323
  }
292
324
 
293
- RCT_EXPORT_METHOD(reloadUpdate:(NSDictionary *)options)
325
+ RCT_EXPORT_METHOD(reloadUpdate:(NSDictionary *)options
326
+ resolver:(RCTPromiseResolveBlock)resolve
327
+ rejecter:(RCTPromiseRejectBlock)reject)
294
328
  {
295
- NSString *hash = options[@"hash"];
296
-
297
- if (hash.length) {
298
- [self setNeedUpdate:options];
299
-
300
- // reload 0.62+
301
- // RCTReloadCommandSetBundleURL([[self class] bundleURL]);
302
- // RCTTriggerReloadCommandListeners(@"pushy reload");
303
-
304
- dispatch_async(dispatch_get_main_queue(), ^{
305
- [self.bridge setValue:[[self class] bundleURL] forKey:@"bundleURL"];
306
- [self.bridge reload];
307
- });
329
+ @try {
330
+ NSString *hash = options[@"hash"];
331
+ if (hash.length) {
332
+ [self setNeedUpdate:options resolver:resolve rejecter:reject];
333
+
334
+ // reload 0.62+
335
+ // RCTReloadCommandSetBundleURL([[self class] bundleURL]);
336
+ // RCTTriggerReloadCommandListeners(@"pushy reload");
337
+
338
+ dispatch_async(dispatch_get_main_queue(), ^{
339
+ [self.bridge setValue:[[self class] bundleURL] forKey:@"bundleURL"];
340
+ [self.bridge reload];
341
+ });
342
+ resolve(@true);
343
+ }else{
344
+ reject(@"执行报错", nil, nil);
345
+ }
346
+ }
347
+ @catch (NSException *exception) {
348
+ reject(@"执行报错", nil, nil);
308
349
  }
309
350
  }
310
351
 
311
- RCT_EXPORT_METHOD(markSuccess)
352
+ RCT_EXPORT_METHOD(markSuccess:
353
+ resolver:(RCTPromiseResolveBlock)resolve
354
+ rejecter:(RCTPromiseRejectBlock)reject)
312
355
  {
313
- // up package info
314
- NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
315
- NSMutableDictionary *pushyInfo = [[NSMutableDictionary alloc] initWithDictionary:[defaults objectForKey:keyPushyInfo]];
316
- [pushyInfo setObject:@(NO) forKey:paramIsFirstTime];
317
- [pushyInfo setObject:@(YES) forKey:paramIsFirstLoadOk];
318
356
 
319
- NSString *lastVersion = pushyInfo[paramLastVersion];
320
- NSString *curVersion = pushyInfo[paramCurrentVersion];
321
- if (lastVersion != nil && ![lastVersion isEqualToString:curVersion]) {
322
- [pushyInfo removeObjectForKey:[keyHashInfo stringByAppendingString:lastVersion]];
357
+ @try {
358
+ // up package info
359
+ NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
360
+ NSMutableDictionary *pushyInfo = [[NSMutableDictionary alloc] initWithDictionary:[defaults objectForKey:keyPushyInfo]];
361
+ [pushyInfo setObject:@(NO) forKey:paramIsFirstTime];
362
+ [pushyInfo setObject:@(YES) forKey:paramIsFirstLoadOk];
363
+
364
+ NSString *lastVersion = pushyInfo[paramLastVersion];
365
+ NSString *curVersion = pushyInfo[paramCurrentVersion];
366
+ if (lastVersion != nil && ![lastVersion isEqualToString:curVersion]) {
367
+ [pushyInfo removeObjectForKey:[keyHashInfo stringByAppendingString:lastVersion]];
368
+ }
369
+ [defaults setObject:pushyInfo forKey:keyPushyInfo];
370
+ [defaults synchronize];
371
+
372
+ // clear other package dir
373
+ [self clearInvalidFiles];
374
+ resolve(@true);
375
+ }
376
+ @catch (NSException *exception) {
377
+ reject(@"执行报错", nil, nil);
323
378
  }
324
- [defaults setObject:pushyInfo forKey:keyPushyInfo];
325
- [defaults synchronize];
326
-
327
- // clear other package dir
328
- [self clearInvalidFiles];
329
379
  }
330
380
 
331
381
 
@@ -351,6 +401,19 @@ RCT_EXPORT_METHOD(markSuccess)
351
401
  // Remove upstream listeners, stop unnecessary background tasks
352
402
  }
353
403
 
404
+ - (BOOL) isBlankString:(NSString *)string {
405
+ if (string == nil || string == NULL) {
406
+ return YES;
407
+ }
408
+ if ([string isKindOfClass:[NSNull class]]) {
409
+ return YES;
410
+ }
411
+ if ([[string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] length]==0) {
412
+ return YES;
413
+ }
414
+ return NO;
415
+ }
416
+
354
417
 
355
418
  - (void)doPushy:(PushyType)type options:(NSDictionary *)options callback:(void (^)(NSError *error))callback
356
419
  {
@@ -362,7 +425,7 @@ RCT_EXPORT_METHOD(markSuccess)
362
425
  return;
363
426
  }
364
427
  NSString *originHash = [RCTConvert NSString:options[@"originHash"]];
365
- if (type == PushyTypePatchFromPpk && originHash <= 0) {
428
+ if (type == PushyTypePatchFromPpk && [self isBlankString:originHash]) {
366
429
  callback([self errorWithMessage:ERROR_OPTIONS]);
367
430
  return;
368
431
  }
@@ -562,4 +625,13 @@ RCT_EXPORT_METHOD(markSuccess)
562
625
  #endif
563
626
  }
564
627
 
628
+ // Thanks to this guard, we won't compile this code when we build for the old architecture.
629
+ #ifdef RCT_NEW_ARCH_ENABLED
630
+ - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
631
+ (const facebook::react::ObjCTurboModule::InitParams &)params
632
+ {
633
+ return std::make_shared<facebook::react::NativeUpdateSpecJSI>(params);
634
+ }
635
+ #endif
636
+
565
637
  @end
@@ -1 +1 @@
1
- 1654072539
1
+ 1680488830
@@ -0,0 +1,51 @@
1
+ /**
2
+ * @format
3
+ * @flow strict-local
4
+ */
5
+ 'use strict';
6
+
7
+ import type { TurboModule } from 'react-native/Libraries/TurboModule/RCTExport';
8
+ import { TurboModuleRegistry } from 'react-native';
9
+
10
+ export interface Spec extends TurboModule {
11
+ getConstants: () => {
12
+ downloadRootDir: string,
13
+ packageVersion: string,
14
+ currentVersion: string,
15
+ isFirstTime: boolean,
16
+ rolledBackVersion: string,
17
+ buildTime: string,
18
+ blockUpdate: Object,
19
+ uuid: string,
20
+ isUsingBundleUrl: boolean,
21
+ };
22
+ setLocalHashInfo(hash: string, info: string): Promise<void>;
23
+ getLocalHashInfo(hash: string): Promise<string>;
24
+ setUuid(uuid: string): Promise<void>;
25
+ setBlockUpdate(options: { reason: string, until: number }): Promise<void>;
26
+ reloadUpdate(options: { hash: string }): Promise<void>;
27
+ setNeedUpdate(options: { hash: string }): Promise<void>;
28
+ markSuccess(): Promise<void>;
29
+ downloadPatchFromPpk(options: {
30
+ updateUrl: string,
31
+ hash: string,
32
+ originHash: string,
33
+ }): Promise<void>;
34
+ downloadPatchFromPackage(options: {
35
+ updateUrl: string,
36
+ hash: string,
37
+ }): Promise<void>;
38
+ downloadFullUpdate(options: {
39
+ updateUrl: string,
40
+ hash: string,
41
+ }): Promise<void>;
42
+ downloadAndInstallApk(options: {
43
+ url: string,
44
+ target: string,
45
+ hash: string,
46
+ }): Promise<void>;
47
+ addListener(eventName: string): void;
48
+ removeListeners(count: number): void;
49
+ }
50
+
51
+ export default (TurboModuleRegistry.get<Spec>('Pushy'): ?Spec);
package/lib/main.js CHANGED
@@ -15,47 +15,53 @@ const {
15
15
  version: v,
16
16
  } = require('react-native/Libraries/Core/ReactNativeVersion');
17
17
  const RNVersion = `${v.major}.${v.minor}.${v.patch}`;
18
+ const isTurboModuleEnabled = global.__turboModuleProxy != null;
18
19
 
19
- let Pushy = NativeModules.Pushy;
20
+ export const PushyModule = isTurboModuleEnabled
21
+ ? require('./NativeUpdate').default
22
+ : NativeModules.Pushy;
20
23
 
21
- if (!Pushy) {
24
+ if (!PushyModule) {
22
25
  throw new Error('react-native-update模块无法加载,请对照安装文档检查配置。');
23
26
  }
27
+ const PushyConstants = isTurboModuleEnabled
28
+ ? PushyModule.getConstants()
29
+ : PushyModule;
24
30
 
25
- export const downloadRootDir = Pushy.downloadRootDir;
26
- export const packageVersion = Pushy.packageVersion;
27
- export const currentVersion = Pushy.currentVersion;
28
- export const isFirstTime = Pushy.isFirstTime;
29
- const rolledBackVersion = Pushy.rolledBackVersion;
31
+ export const downloadRootDir = PushyConstants.downloadRootDir;
32
+ export const packageVersion = PushyConstants.packageVersion;
33
+ export const currentVersion = PushyConstants.currentVersion;
34
+ export const isFirstTime = PushyConstants.isFirstTime;
35
+ const rolledBackVersion = PushyConstants.rolledBackVersion;
30
36
  export const isRolledBack = typeof rolledBackVersion === 'string';
31
37
 
32
- export const buildTime = Pushy.buildTime;
33
- let blockUpdate = Pushy.blockUpdate;
34
- let uuid = Pushy.uuid;
38
+ export const buildTime = PushyConstants.buildTime;
39
+ let blockUpdate = PushyConstants.blockUpdate;
40
+ let uuid = PushyConstants.uuid;
35
41
 
36
- if (Platform.OS === 'android' && !Pushy.isUsingBundleUrl) {
42
+ if (Platform.OS === 'android' && !PushyConstants.isUsingBundleUrl) {
37
43
  throw new Error(
38
44
  'react-native-update模块无法加载,请对照文档检查Bundle URL的配置',
39
45
  );
40
46
  }
41
47
 
42
48
  function setLocalHashInfo(hash, info) {
43
- Pushy.setLocalHashInfo(hash, JSON.stringify(info));
49
+ PushyModule.setLocalHashInfo(hash, JSON.stringify(info));
44
50
  }
45
51
 
46
52
  async function getLocalHashInfo(hash) {
47
- return JSON.parse(await Pushy.getLocalHashInfo(hash));
53
+ return JSON.parse(await PushyModule.getLocalHashInfo(hash));
48
54
  }
49
55
 
50
56
  export async function getCurrentVersionInfo() {
51
57
  return currentVersion ? (await getLocalHashInfo(currentVersion)) || {} : {};
52
58
  }
53
59
 
54
- const eventEmitter = new NativeEventEmitter(Pushy);
60
+ const eventEmitter = new NativeEventEmitter(PushyModule);
55
61
 
56
62
  if (!uuid) {
57
63
  uuid = require('nanoid/non-secure').nanoid();
58
- Pushy.setUuid(uuid);
64
+ PushyModule.setUuid(uuid);
59
65
  }
60
66
 
61
67
  function logger(text) {
@@ -163,7 +169,7 @@ function checkOperation(op) {
163
169
  reason: action.reason,
164
170
  until: Math.round((Date.now() + action.duration) / 1000),
165
171
  };
166
- Pushy.setBlockUpdate(blockUpdate);
172
+ PushyModule.setBlockUpdate(blockUpdate);
167
173
  }
168
174
  });
169
175
  }
@@ -209,7 +215,7 @@ export async function downloadUpdate(options, eventListeners) {
209
215
  if (options.diffUrl) {
210
216
  logger('downloading diff');
211
217
  try {
212
- await Pushy.downloadPatchFromPpk({
218
+ await PushyModule.downloadPatchFromPpk({
213
219
  updateUrl: options.diffUrl,
214
220
  hash: options.hash,
215
221
  originHash: currentVersion,
@@ -222,7 +228,7 @@ export async function downloadUpdate(options, eventListeners) {
222
228
  if (!succeeded && options.pdiffUrl) {
223
229
  logger('downloading pdiff');
224
230
  try {
225
- await Pushy.downloadPatchFromPackage({
231
+ await PushyModule.downloadPatchFromPackage({
226
232
  updateUrl: options.pdiffUrl,
227
233
  hash: options.hash,
228
234
  });
@@ -234,7 +240,7 @@ export async function downloadUpdate(options, eventListeners) {
234
240
  if (!succeeded && options.updateUrl) {
235
241
  logger('downloading full patch');
236
242
  try {
237
- await Pushy.downloadFullUpdate({
243
+ await PushyModule.downloadFullUpdate({
238
244
  updateUrl: options.updateUrl,
239
245
  hash: options.hash,
240
246
  });
@@ -273,7 +279,7 @@ export function switchVersion(hash) {
273
279
  assertRelease();
274
280
  if (assertHash(hash)) {
275
281
  logger('switchVersion: ' + hash);
276
- Pushy.reloadUpdate({ hash });
282
+ PushyModule.reloadUpdate({ hash });
277
283
  }
278
284
  }
279
285
 
@@ -281,7 +287,7 @@ export function switchVersionLater(hash) {
281
287
  assertRelease();
282
288
  if (assertHash(hash)) {
283
289
  logger('switchVersionLater: ' + hash);
284
- Pushy.setNeedUpdate({ hash });
290
+ PushyModule.setNeedUpdate({ hash });
285
291
  }
286
292
  }
287
293
 
@@ -293,7 +299,7 @@ export function markSuccess() {
293
299
  return;
294
300
  }
295
301
  marked = true;
296
- Pushy.markSuccess();
302
+ PushyModule.markSuccess();
297
303
  report(currentVersion, 'success');
298
304
  }
299
305
 
@@ -323,7 +329,7 @@ export async function downloadAndInstallApk({ url, onDownloadProgress }) {
323
329
  },
324
330
  );
325
331
  }
326
- await Pushy.downloadAndInstallApk({
332
+ await PushyModule.downloadAndInstallApk({
327
333
  url,
328
334
  target: 'update.apk',
329
335
  hash,
package/package.json CHANGED
@@ -1,13 +1,27 @@
1
1
  {
2
2
  "name": "react-native-update",
3
- "version": "8.1.0",
3
+ "version": "9.0.0-beta.0",
4
4
  "description": "react-native hot update",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
7
7
  "prepublish": "yarn submodule",
8
8
  "submodule": "git submodule update --init --recursive",
9
9
  "test": "echo \"Error: no test specified\" && exit 1",
10
- "build-lib": "yarn submodule && $ANDROID_HOME/ndk/20.1.5948944/ndk-build NDK_PROJECT_PATH=android APP_BUILD_SCRIPT=android/jni/Android.mk NDK_APPLICATION_MK=android/jni/Application.mk NDK_LIBS_OUT=android/lib"
10
+ "build-lib": "yarn submodule && $ANDROID_HOME/ndk/20.1.5948944/ndk-build NDK_PROJECT_PATH=android APP_BUILD_SCRIPT=android/jni/Android.mk NDK_APPLICATION_MK=android/jni/Application.mk NDK_LIBS_OUT=android/lib",
11
+ "build:ios-debug": "cd Example/testHotUpdate && yarn && detox build --configuration ios.sim.debug",
12
+ "build:ios-release": "cd Example/testHotUpdate && yarn && detox build --configuration ios.sim.release",
13
+ "test:ios-debug": "cd Example/testHotUpdate && detox test --configuration ios.sim.debug",
14
+ "test:ios-release": "cd Example/testHotUpdate && yarn detox test --configuration ios.sim.release",
15
+ "build:android-debug": "cd Example/testHotUpdate && yarn && detox build --configuration android.emu.debug",
16
+ "build:android-release": "cd Example/testHotUpdate && yarn && detox build --configuration android.emu.release",
17
+ "test:android-release": "cd Example/testHotUpdate && yarn detox test --configuration android.emu.release --headless --record-logs all",
18
+ "test:android-debug": "cd Example/testHotUpdate && detox test --configuration android.emu.debug --headless --record-logs all",
19
+ "e2e:ios": "npm run build:ios-release && npm run test:ios-release",
20
+ "e2e:android": "npm run build:android-release && npm run test:android-release",
21
+ "tests:emulator:prepare": "cd .github/workflows/scripts/functions && yarn && yarn build",
22
+ "tests:emulator:start-ci": "yarn tests:emulator:prepare && cd ./.github/workflows/scripts && ./start-firebase-emulator.sh",
23
+ "tests:packager:jet-ci": "cd Example/testHotUpdate && cross-env TMPDIR=$HOME/.metro REACT_DEBUGGER=\"echo nope\" node_modules/.bin/react-native start --no-interactive",
24
+ "tests:ios:pod:install": "cd Example/testHotUpdate && yarn && yarn pod-install"
11
25
  },
12
26
  "repository": {
13
27
  "type": "git",
@@ -30,5 +44,25 @@
30
44
  "homepage": "https://github.com/reactnativecn/react-native-pushy#readme",
31
45
  "dependencies": {
32
46
  "nanoid": "^3.3.3"
47
+ },
48
+ "codegenConfig": {
49
+ "libraries": [
50
+ {
51
+ "name": "RCTPushySpec",
52
+ "type": "modules",
53
+ "jsSrcsDir": "lib"
54
+ }
55
+ ]
56
+ },
57
+ "devDependencies": {
58
+ "@types/fs-extra": "^9.0.13",
59
+ "@types/jest": "^29.2.1",
60
+ "detox": "^20.5.0",
61
+ "firebase-tools": "^11.24.1",
62
+ "fs-extra": "^9.1.0",
63
+ "jest": "^29.2.1",
64
+ "pod-install": "^0.1.37",
65
+ "ts-jest": "^29.0.3",
66
+ "typescript": "^4.1.3"
33
67
  }
34
68
  }
@@ -1,7 +1,8 @@
1
1
  require 'json'
2
2
 
3
3
  package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
4
-
4
+ folly_version = '2021.06.28.00-v2'
5
+ folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
5
6
  Pod::Spec.new do |s|
6
7
  s.name = package['name']
7
8
  s.version = package['version']
@@ -13,7 +14,9 @@ Pod::Spec.new do |s|
13
14
 
14
15
  s.cocoapods_version = '>= 1.6.0'
15
16
  s.platform = :ios, "8.0"
17
+ s.platforms = { :ios => "11.0" }
16
18
  s.source = { :git => 'https://github.com/reactnativecn/react-native-pushy.git', :tag => '#{s.version}' }
19
+ s.source_files = "ios/**/*.{h,m,mm,swift}"
17
20
  s.libraries = 'bz2', 'z'
18
21
  s.vendored_libraries = 'RCTPushy/libRCTPushy.a'
19
22
  s.pod_target_xcconfig = { 'USER_HEADER_SEARCH_PATHS' => '"$(SRCROOT)/../node_modules/react-native-update/ios"' }
@@ -21,10 +24,11 @@ Pod::Spec.new do |s|
21
24
  s.script_phase = { :name => 'Generate build time', :script => 'set -x;date +%s > ${PODS_ROOT}/../../node_modules/react-native-update/ios/pushy_build_time.txt', :execution_position => :before_compile }
22
25
 
23
26
  s.dependency 'React'
27
+ s.dependency "React-Core"
24
28
  s.dependency 'SSZipArchive'
25
29
 
26
30
  s.subspec 'RCTPushy' do |ss|
27
- ss.source_files = 'ios/RCTPushy/*.{h,m}'
31
+ ss.source_files = 'ios/RCTPushy/*.{h,m,mm,swift}'
28
32
  ss.public_header_files = ['ios/RCTPushy/RCTPushy.h']
29
33
  end
30
34
 
@@ -37,4 +41,18 @@ Pod::Spec.new do |s|
37
41
  'android/jni/lzma/C/Lzma2Dec.{h,c}']
38
42
  ss.private_header_files = 'ios/RCTPushy/HDiffPatch/**/*.h'
39
43
  end
44
+ # This guard prevent to install the dependencies when we run `pod install` in the old architecture.
45
+ if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
46
+ s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
47
+ s.pod_target_xcconfig = {
48
+ "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
49
+ "CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
50
+ }
51
+
52
+ s.dependency "React-Codegen"
53
+ s.dependency "RCT-Folly", folly_version
54
+ s.dependency "RCTRequired"
55
+ s.dependency "RCTTypeSafety"
56
+ s.dependency "ReactCommon/turbomodule/core"
57
+ end
40
58
  end