react-native-3rddigital-appupdate 1.0.17 → 1.0.19

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 (2) hide show
  1. package/package.json +1 -1
  2. package/scripts/bundle.js +121 -33
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-3rddigital-appupdate",
3
- "version": "1.0.17",
3
+ "version": "1.0.19",
4
4
  "description": "A React Native library for seamless over-the-air (OTA) updates with version checks, automatic bundle download, and customizable user prompts for iOS and Android.",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",
package/scripts/bundle.js CHANGED
@@ -349,6 +349,14 @@ function choosePreferredBuildConfig(buildConfigs, preferredNames = []) {
349
349
  return buildConfigs[0] ?? null;
350
350
  }
351
351
 
352
+ function buildIosEntryLabel({ targetName, buildConfiguration, appId }) {
353
+ const buildConfigurationLabel = buildConfiguration
354
+ ? ` [${buildConfiguration}]`
355
+ : '';
356
+ const appIdLabel = appId ? ` (${appId})` : '';
357
+ return `${targetName}${buildConfigurationLabel}${appIdLabel}`;
358
+ }
359
+
352
360
  function getAndroidBuildGradlePath(projectRoot) {
353
361
  return findFirstExistingPath([
354
362
  path.join(projectRoot, 'android', 'app', 'build.gradle'),
@@ -486,6 +494,7 @@ function getIosTargetMetadata() {
486
494
  configObjects.map((config) => [
487
495
  config.id,
488
496
  {
497
+ id: config.id,
489
498
  name: cleanPbxString(readPbxValue(config.body, 'name')),
490
499
  version: cleanPbxString(readPbxValue(config.body, 'MARKETING_VERSION')),
491
500
  appId: cleanPbxString(
@@ -515,6 +524,18 @@ function getIosTargetMetadata() {
515
524
  ])
516
525
  );
517
526
 
527
+ const preferredConfigNames = ['Release', 'Profile', 'Debug'];
528
+ const fallbackConfigGroups = new Map();
529
+
530
+ for (const config of configMap.values()) {
531
+ const appIdKey = config.appId ?? `no-app-id::${config.id}`;
532
+ if (!fallbackConfigGroups.has(appIdKey)) {
533
+ fallbackConfigGroups.set(appIdKey, []);
534
+ }
535
+
536
+ fallbackConfigGroups.get(appIdKey).push(config);
537
+ }
538
+
518
539
  const targetObjects = parsePbxprojObjectsByIsa(
519
540
  pbxprojContent,
520
541
  'PBXNativeTarget'
@@ -545,41 +566,55 @@ function getIosTargetMetadata() {
545
566
 
546
567
  if (!buildConfigs.length) return null;
547
568
 
548
- const configsByIdentity = new Map();
569
+ const buildConfigsWithAppId = buildConfigs.filter(
570
+ (config) => config.appId
571
+ );
549
572
 
550
- for (const buildConfig of buildConfigs) {
551
- const identity = `${buildConfig.appId ?? 'no-app-id'}::${buildConfig.name ?? 'no-config-name'}`;
552
- if (!configsByIdentity.has(identity)) {
553
- configsByIdentity.set(identity, []);
573
+ const configsByAppId = new Map();
574
+ for (const buildConfig of buildConfigsWithAppId) {
575
+ const appIdKey = buildConfig.appId;
576
+ if (!configsByAppId.has(appIdKey)) {
577
+ configsByAppId.set(appIdKey, []);
554
578
  }
555
579
 
556
- configsByIdentity.get(identity).push(buildConfig);
580
+ configsByAppId.get(appIdKey).push(buildConfig);
557
581
  }
558
582
 
559
- const distinctConfigs = Array.from(configsByIdentity.values())
560
- .map((configGroup) =>
561
- choosePreferredBuildConfig(configGroup, [
562
- configList?.defaultName,
563
- 'Release',
564
- 'Profile',
565
- 'Debug',
566
- ])
567
- )
568
- .filter(Boolean);
583
+ const targetPreferredConfigNames = [
584
+ configList?.defaultName,
585
+ 'Release',
586
+ 'Profile',
587
+ 'Debug',
588
+ ].filter(Boolean);
589
+
590
+ const distinctConfigs =
591
+ configsByAppId.size <= 1
592
+ ? [
593
+ choosePreferredBuildConfig(
594
+ buildConfigsWithAppId.length
595
+ ? buildConfigsWithAppId
596
+ : buildConfigs,
597
+ targetPreferredConfigNames
598
+ ),
599
+ ].filter(Boolean)
600
+ : Array.from(configsByAppId.values())
601
+ .map((configGroup) =>
602
+ choosePreferredBuildConfig(
603
+ configGroup,
604
+ targetPreferredConfigNames
605
+ )
606
+ )
607
+ .filter(Boolean);
569
608
 
570
609
  return distinctConfigs.map((selectedConfig) => {
571
- const buildConfigurationLabel = selectedConfig.name
572
- ? ` [${selectedConfig.name}]`
573
- : '';
574
-
575
- const appIdLabel = selectedConfig.appId
576
- ? ` (${selectedConfig.appId})`
577
- : '';
578
-
579
610
  return {
580
- name: `${targetName}::${selectedConfig.name ?? 'default'}::${selectedConfig.appId ?? 'no-app-id'}`,
611
+ name: `${targetName}::${selectedConfig.appId ?? selectedConfig.id ?? 'no-app-id'}`,
581
612
  targetName,
582
- label: `${targetName}${buildConfigurationLabel}${appIdLabel}`,
613
+ label: buildIosEntryLabel({
614
+ targetName,
615
+ buildConfiguration: selectedConfig.name ?? null,
616
+ appId: selectedConfig.appId ?? null,
617
+ }),
583
618
  appId: selectedConfig.appId ?? null,
584
619
  version: selectedConfig.version ?? null,
585
620
  productName: selectedConfig.productName ?? targetName,
@@ -592,17 +627,70 @@ function getIosTargetMetadata() {
592
627
 
593
628
  const uniqueTargets = targets.filter(
594
629
  (target, index, allTargets) =>
595
- allTargets.findIndex(
596
- (candidate) =>
597
- candidate.targetName === target.targetName &&
598
- candidate.appId === target.appId &&
599
- candidate.buildConfiguration === target.buildConfiguration
630
+ allTargets.findIndex((candidate) =>
631
+ candidate.appId
632
+ ? candidate.appId === target.appId
633
+ : candidate.targetName === target.targetName &&
634
+ candidate.buildConfiguration === target.buildConfiguration
600
635
  ) === index
601
636
  );
602
637
 
638
+ const existingAppIds = new Set(
639
+ uniqueTargets.map((target) => target.appId).filter(Boolean)
640
+ );
641
+
642
+ const fallbackEntries = Array.from(fallbackConfigGroups.entries())
643
+ .filter(([appId]) => !existingAppIds.has(appId))
644
+ .map(([appId, configs]) => {
645
+ const selectedConfig = choosePreferredBuildConfig(
646
+ configs,
647
+ preferredConfigNames
648
+ );
649
+ if (!selectedConfig) return null;
650
+
651
+ const targetName =
652
+ selectedConfig.productName &&
653
+ selectedConfig.productName !== '$(TARGET_NAME)'
654
+ ? selectedConfig.productName
655
+ : 'Default';
656
+
657
+ return {
658
+ name: `${targetName}::${appId}`,
659
+ targetName,
660
+ label: buildIosEntryLabel({
661
+ targetName,
662
+ buildConfiguration: selectedConfig.name ?? null,
663
+ appId: selectedConfig.appId ?? null,
664
+ }),
665
+ appId: selectedConfig.appId ?? null,
666
+ version: selectedConfig.version ?? null,
667
+ productName: selectedConfig.productName ?? targetName,
668
+ buildConfiguration: selectedConfig.name ?? null,
669
+ };
670
+ })
671
+ .filter(Boolean);
672
+
673
+ const mergedTargets = [...uniqueTargets, ...fallbackEntries];
674
+
675
+ if (!mergedTargets.length) {
676
+ const fallbackVersionMatch = pbxprojContent.match(
677
+ /MARKETING_VERSION\s*=\s*([^;]+);/
678
+ );
679
+
680
+ return {
681
+ defaultConfig: {
682
+ name: 'default',
683
+ label: 'Default',
684
+ appId: null,
685
+ version: cleanPbxString(fallbackVersionMatch?.[1]) ?? null,
686
+ },
687
+ targets: [],
688
+ };
689
+ }
690
+
603
691
  return {
604
- defaultConfig: uniqueTargets[0] ?? null,
605
- targets: uniqueTargets,
692
+ defaultConfig: mergedTargets[0] ?? null,
693
+ targets: mergedTargets,
606
694
  };
607
695
  }
608
696