react-native-3rddigital-appupdate 1.0.18 → 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 +86 -14
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-3rddigital-appupdate",
3
- "version": "1.0.18",
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'),
@@ -516,6 +524,18 @@ function getIosTargetMetadata() {
516
524
  ])
517
525
  );
518
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
+
519
539
  const targetObjects = parsePbxprojObjectsByIsa(
520
540
  pbxprojContent,
521
541
  'PBXNativeTarget'
@@ -560,7 +580,7 @@ function getIosTargetMetadata() {
560
580
  configsByAppId.get(appIdKey).push(buildConfig);
561
581
  }
562
582
 
563
- const preferredConfigNames = [
583
+ const targetPreferredConfigNames = [
564
584
  configList?.defaultName,
565
585
  'Release',
566
586
  'Profile',
@@ -574,28 +594,27 @@ function getIosTargetMetadata() {
574
594
  buildConfigsWithAppId.length
575
595
  ? buildConfigsWithAppId
576
596
  : buildConfigs,
577
- preferredConfigNames
597
+ targetPreferredConfigNames
578
598
  ),
579
599
  ].filter(Boolean)
580
600
  : Array.from(configsByAppId.values())
581
601
  .map((configGroup) =>
582
- choosePreferredBuildConfig(configGroup, preferredConfigNames)
602
+ choosePreferredBuildConfig(
603
+ configGroup,
604
+ targetPreferredConfigNames
605
+ )
583
606
  )
584
607
  .filter(Boolean);
585
608
 
586
609
  return distinctConfigs.map((selectedConfig) => {
587
- const buildConfigurationLabel = selectedConfig.name
588
- ? ` [${selectedConfig.name}]`
589
- : '';
590
-
591
- const appIdLabel = selectedConfig.appId
592
- ? ` (${selectedConfig.appId})`
593
- : '';
594
-
595
610
  return {
596
611
  name: `${targetName}::${selectedConfig.appId ?? selectedConfig.id ?? 'no-app-id'}`,
597
612
  targetName,
598
- label: `${targetName}${buildConfigurationLabel}${appIdLabel}`,
613
+ label: buildIosEntryLabel({
614
+ targetName,
615
+ buildConfiguration: selectedConfig.name ?? null,
616
+ appId: selectedConfig.appId ?? null,
617
+ }),
599
618
  appId: selectedConfig.appId ?? null,
600
619
  version: selectedConfig.version ?? null,
601
620
  productName: selectedConfig.productName ?? targetName,
@@ -616,9 +635,62 @@ function getIosTargetMetadata() {
616
635
  ) === index
617
636
  );
618
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
+
619
691
  return {
620
- defaultConfig: uniqueTargets[0] ?? null,
621
- targets: uniqueTargets,
692
+ defaultConfig: mergedTargets[0] ?? null,
693
+ targets: mergedTargets,
622
694
  };
623
695
  }
624
696