react-native-3rddigital-appupdate 1.0.17 → 1.0.18

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 +38 -22
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.18",
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
@@ -486,6 +486,7 @@ function getIosTargetMetadata() {
486
486
  configObjects.map((config) => [
487
487
  config.id,
488
488
  {
489
+ id: config.id,
489
490
  name: cleanPbxString(readPbxValue(config.body, 'name')),
490
491
  version: cleanPbxString(readPbxValue(config.body, 'MARKETING_VERSION')),
491
492
  appId: cleanPbxString(
@@ -545,27 +546,42 @@ function getIosTargetMetadata() {
545
546
 
546
547
  if (!buildConfigs.length) return null;
547
548
 
548
- const configsByIdentity = new Map();
549
+ const buildConfigsWithAppId = buildConfigs.filter(
550
+ (config) => config.appId
551
+ );
549
552
 
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, []);
553
+ const configsByAppId = new Map();
554
+ for (const buildConfig of buildConfigsWithAppId) {
555
+ const appIdKey = buildConfig.appId;
556
+ if (!configsByAppId.has(appIdKey)) {
557
+ configsByAppId.set(appIdKey, []);
554
558
  }
555
559
 
556
- configsByIdentity.get(identity).push(buildConfig);
560
+ configsByAppId.get(appIdKey).push(buildConfig);
557
561
  }
558
562
 
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);
563
+ const preferredConfigNames = [
564
+ configList?.defaultName,
565
+ 'Release',
566
+ 'Profile',
567
+ 'Debug',
568
+ ].filter(Boolean);
569
+
570
+ const distinctConfigs =
571
+ configsByAppId.size <= 1
572
+ ? [
573
+ choosePreferredBuildConfig(
574
+ buildConfigsWithAppId.length
575
+ ? buildConfigsWithAppId
576
+ : buildConfigs,
577
+ preferredConfigNames
578
+ ),
579
+ ].filter(Boolean)
580
+ : Array.from(configsByAppId.values())
581
+ .map((configGroup) =>
582
+ choosePreferredBuildConfig(configGroup, preferredConfigNames)
583
+ )
584
+ .filter(Boolean);
569
585
 
570
586
  return distinctConfigs.map((selectedConfig) => {
571
587
  const buildConfigurationLabel = selectedConfig.name
@@ -577,7 +593,7 @@ function getIosTargetMetadata() {
577
593
  : '';
578
594
 
579
595
  return {
580
- name: `${targetName}::${selectedConfig.name ?? 'default'}::${selectedConfig.appId ?? 'no-app-id'}`,
596
+ name: `${targetName}::${selectedConfig.appId ?? selectedConfig.id ?? 'no-app-id'}`,
581
597
  targetName,
582
598
  label: `${targetName}${buildConfigurationLabel}${appIdLabel}`,
583
599
  appId: selectedConfig.appId ?? null,
@@ -592,11 +608,11 @@ function getIosTargetMetadata() {
592
608
 
593
609
  const uniqueTargets = targets.filter(
594
610
  (target, index, allTargets) =>
595
- allTargets.findIndex(
596
- (candidate) =>
597
- candidate.targetName === target.targetName &&
598
- candidate.appId === target.appId &&
599
- candidate.buildConfiguration === target.buildConfiguration
611
+ allTargets.findIndex((candidate) =>
612
+ candidate.appId
613
+ ? candidate.appId === target.appId
614
+ : candidate.targetName === target.targetName &&
615
+ candidate.buildConfiguration === target.buildConfiguration
600
616
  ) === index
601
617
  );
602
618