@hot-updater/android-helper 1.2.0-rc.13 → 1.2.0-rc.14
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/dist/index.cjs +16 -1
- package/dist/index.mjs +16 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -548,6 +548,8 @@ const resolveSandboxLauncher = (mergedManifest) => {
|
|
|
548
548
|
if (activity === void 0) throw new Error(`The launcher ${name} targets ${targetActivity ?? "no activity"}, which this variant's manifest doesn't declare.\nFix its android:targetActivity.`);
|
|
549
549
|
const refusal = taskRefusal(name, activity);
|
|
550
550
|
if (refusal !== null) throw new Error(refusal);
|
|
551
|
+
const launcherProcess = attribute(activity, "process");
|
|
552
|
+
if (launcherProcess !== void 0 && launcherProcess !== attribute(application ?? {}, "process")) throw new Error(`Sandbox builds run the launcher in the application's process, and ${name} sets android:process ${launcherProcess}.\nRemove it, or set the same android:process on <application>, for this build variant.`);
|
|
551
553
|
const shortcuts = asArray(element["meta-data"]).find((item) => attribute(item, "name") === SHORTCUTS);
|
|
552
554
|
const label = attribute(element, "label");
|
|
553
555
|
const icon = attribute(element, "icon");
|
|
@@ -582,10 +584,12 @@ const optional = (name, value) => value === void 0 ? "" : ` android:${name}="${x
|
|
|
582
584
|
* also takes the links of `appId`'s URL scheme; the rest of the app's activity
|
|
583
585
|
* stays, so its own links still reach it. `appId` is the scheme's `packageName`,
|
|
584
586
|
* before the `.sandbox` suffix, so a preview link needs no build to derive it.
|
|
587
|
+
* The dev server is plain http, which a project's network security config can
|
|
588
|
+
* still refuse: the screen then says so.
|
|
585
589
|
*/
|
|
586
590
|
const sandboxManifestOverlay = ({ channel, appId, launcher }) => `<?xml version="1.0" encoding="utf-8"?>
|
|
587
591
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools">
|
|
588
|
-
<application>
|
|
592
|
+
<application android:usesCleartextTraffic="true" tools:replace="android:usesCleartextTraffic">
|
|
589
593
|
<meta-data android:name="com.hotupdater.CHANNEL" android:value="${xml(channel)}" tools:replace="android:value" />
|
|
590
594
|
<meta-data android:name="${_hot_updater_protocol_native_artifact.SANDBOX_META_DATA}" android:value="true" />
|
|
591
595
|
<activity android:name="${_hot_updater_protocol_native_artifact.SANDBOX_ACTIVITY}" android:exported="true" android:launchMode="singleTop" android:theme="@style/HotUpdaterSandboxTheme" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"${optional("label", launcher.label)}${optional("icon", launcher.icon)}${optional("roundIcon", launcher.roundIcon)}>
|
|
@@ -601,6 +605,7 @@ ${filterXml(launcher.filter)}
|
|
|
601
605
|
<${launcher.kind} android:name="${xml(launcher.name)}"${optional("targetActivity", launcher.targetActivity)}>
|
|
602
606
|
${filterXml(launcher.filter, " tools:node=\"remove\"")}${launcher.shortcuts === void 0 ? "" : `\n <meta-data android:name="${SHORTCUTS}" tools:node="remove" />`}
|
|
603
607
|
</${launcher.kind}>
|
|
608
|
+
<activity android:name="com.hotupdater.HotUpdaterSandboxRelaunchActivity" android:excludeFromRecents="true" android:exported="false" android:launchMode="singleTask" android:noHistory="true" android:process=":hotupdater_restart" android:theme="@android:style/Theme.NoDisplay" />
|
|
604
609
|
<provider android:name="com.hotupdater.HotUpdaterSandboxProcess" android:authorities="\${applicationId}.hotupdater.sandbox" android:exported="false" />
|
|
605
610
|
</application>
|
|
606
611
|
</manifest>
|
|
@@ -629,6 +634,9 @@ const UNSUPPORTED_DSL = `Sandbox builds don't support AGP 9's default DSL yet.
|
|
|
629
634
|
Set android.newDsl=false in android/gradle.properties.`;
|
|
630
635
|
/** The message when the build type has a manifest the overlay would replace. */
|
|
631
636
|
const ownManifest = (manifest) => `A sandbox build can't merge with ${manifest}.\nMove what it declares to src/main/AndroidManifest.xml.`;
|
|
637
|
+
/** The message when no project compiled the SDK from source, which a dev server needs. */
|
|
638
|
+
const PREBUILT_SDK = `This app takes @hot-updater/react-native as a prebuilt AAR, and a sandbox build compiles the SDK from source.
|
|
639
|
+
Add the SDK's autolinked project to this build instead of the AAR.`;
|
|
632
640
|
/** Text as a single-quoted Groovy string. */
|
|
633
641
|
const groovyString = (text) => `'${text.replace(/\\/gu, "\\\\").replace(/'/gu, "\\'").replace(/\n/gu, "\\n")}'`;
|
|
634
642
|
/**
|
|
@@ -644,6 +652,13 @@ def overlay = new File(${groovyString(overlay)})
|
|
|
644
652
|
def minVersionCode = ${minVersionCode ?? "null"}
|
|
645
653
|
allprojects { project ->
|
|
646
654
|
if (project.path != appModule) return
|
|
655
|
+
// In this build alone: an init script also runs for React Native's included
|
|
656
|
+
// Gradle plugin. The SDK's sandbox script sets this on the project it compiles.
|
|
657
|
+
gradle.taskGraph.whenReady {
|
|
658
|
+
if (!gradle.rootProject.ext.has('hotUpdaterSandboxSdkProject')) {
|
|
659
|
+
throw new GradleException(${groovyString(PREBUILT_SDK)})
|
|
660
|
+
}
|
|
661
|
+
}
|
|
647
662
|
project.plugins.withId('com.android.application') {
|
|
648
663
|
def components = project.extensions.getByName('androidComponents')
|
|
649
664
|
if (components.pluginVersion.major >= 9 && project.findProperty('android.newDsl')?.toString() != 'false') {
|
package/dist/index.mjs
CHANGED
|
@@ -520,6 +520,8 @@ const resolveSandboxLauncher = (mergedManifest) => {
|
|
|
520
520
|
if (activity === void 0) throw new Error(`The launcher ${name} targets ${targetActivity ?? "no activity"}, which this variant's manifest doesn't declare.\nFix its android:targetActivity.`);
|
|
521
521
|
const refusal = taskRefusal(name, activity);
|
|
522
522
|
if (refusal !== null) throw new Error(refusal);
|
|
523
|
+
const launcherProcess = attribute(activity, "process");
|
|
524
|
+
if (launcherProcess !== void 0 && launcherProcess !== attribute(application ?? {}, "process")) throw new Error(`Sandbox builds run the launcher in the application's process, and ${name} sets android:process ${launcherProcess}.\nRemove it, or set the same android:process on <application>, for this build variant.`);
|
|
523
525
|
const shortcuts = asArray(element["meta-data"]).find((item) => attribute(item, "name") === SHORTCUTS);
|
|
524
526
|
const label = attribute(element, "label");
|
|
525
527
|
const icon = attribute(element, "icon");
|
|
@@ -554,10 +556,12 @@ const optional = (name, value) => value === void 0 ? "" : ` android:${name}="${x
|
|
|
554
556
|
* also takes the links of `appId`'s URL scheme; the rest of the app's activity
|
|
555
557
|
* stays, so its own links still reach it. `appId` is the scheme's `packageName`,
|
|
556
558
|
* before the `.sandbox` suffix, so a preview link needs no build to derive it.
|
|
559
|
+
* The dev server is plain http, which a project's network security config can
|
|
560
|
+
* still refuse: the screen then says so.
|
|
557
561
|
*/
|
|
558
562
|
const sandboxManifestOverlay = ({ channel, appId, launcher }) => `<?xml version="1.0" encoding="utf-8"?>
|
|
559
563
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools">
|
|
560
|
-
<application>
|
|
564
|
+
<application android:usesCleartextTraffic="true" tools:replace="android:usesCleartextTraffic">
|
|
561
565
|
<meta-data android:name="com.hotupdater.CHANNEL" android:value="${xml(channel)}" tools:replace="android:value" />
|
|
562
566
|
<meta-data android:name="${SANDBOX_META_DATA}" android:value="true" />
|
|
563
567
|
<activity android:name="${SANDBOX_ACTIVITY}" android:exported="true" android:launchMode="singleTop" android:theme="@style/HotUpdaterSandboxTheme" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"${optional("label", launcher.label)}${optional("icon", launcher.icon)}${optional("roundIcon", launcher.roundIcon)}>
|
|
@@ -573,6 +577,7 @@ ${filterXml(launcher.filter)}
|
|
|
573
577
|
<${launcher.kind} android:name="${xml(launcher.name)}"${optional("targetActivity", launcher.targetActivity)}>
|
|
574
578
|
${filterXml(launcher.filter, " tools:node=\"remove\"")}${launcher.shortcuts === void 0 ? "" : `\n <meta-data android:name="${SHORTCUTS}" tools:node="remove" />`}
|
|
575
579
|
</${launcher.kind}>
|
|
580
|
+
<activity android:name="com.hotupdater.HotUpdaterSandboxRelaunchActivity" android:excludeFromRecents="true" android:exported="false" android:launchMode="singleTask" android:noHistory="true" android:process=":hotupdater_restart" android:theme="@android:style/Theme.NoDisplay" />
|
|
576
581
|
<provider android:name="com.hotupdater.HotUpdaterSandboxProcess" android:authorities="\${applicationId}.hotupdater.sandbox" android:exported="false" />
|
|
577
582
|
</application>
|
|
578
583
|
</manifest>
|
|
@@ -601,6 +606,9 @@ const UNSUPPORTED_DSL = `Sandbox builds don't support AGP 9's default DSL yet.
|
|
|
601
606
|
Set android.newDsl=false in android/gradle.properties.`;
|
|
602
607
|
/** The message when the build type has a manifest the overlay would replace. */
|
|
603
608
|
const ownManifest = (manifest) => `A sandbox build can't merge with ${manifest}.\nMove what it declares to src/main/AndroidManifest.xml.`;
|
|
609
|
+
/** The message when no project compiled the SDK from source, which a dev server needs. */
|
|
610
|
+
const PREBUILT_SDK = `This app takes @hot-updater/react-native as a prebuilt AAR, and a sandbox build compiles the SDK from source.
|
|
611
|
+
Add the SDK's autolinked project to this build instead of the AAR.`;
|
|
604
612
|
/** Text as a single-quoted Groovy string. */
|
|
605
613
|
const groovyString = (text) => `'${text.replace(/\\/gu, "\\\\").replace(/'/gu, "\\'").replace(/\n/gu, "\\n")}'`;
|
|
606
614
|
/**
|
|
@@ -616,6 +624,13 @@ def overlay = new File(${groovyString(overlay)})
|
|
|
616
624
|
def minVersionCode = ${minVersionCode ?? "null"}
|
|
617
625
|
allprojects { project ->
|
|
618
626
|
if (project.path != appModule) return
|
|
627
|
+
// In this build alone: an init script also runs for React Native's included
|
|
628
|
+
// Gradle plugin. The SDK's sandbox script sets this on the project it compiles.
|
|
629
|
+
gradle.taskGraph.whenReady {
|
|
630
|
+
if (!gradle.rootProject.ext.has('hotUpdaterSandboxSdkProject')) {
|
|
631
|
+
throw new GradleException(${groovyString(PREBUILT_SDK)})
|
|
632
|
+
}
|
|
633
|
+
}
|
|
619
634
|
project.plugins.withId('com.android.application') {
|
|
620
635
|
def components = project.extensions.getByName('androidComponents')
|
|
621
636
|
if (components.pluginVersion.major >= 9 && project.findProperty('android.newDsl')?.toString() != 'false') {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hot-updater/android-helper",
|
|
3
|
-
"version": "1.2.0-rc.
|
|
3
|
+
"version": "1.2.0-rc.14",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
"execa": "9.5.2",
|
|
31
31
|
"fast-xml-parser": "5.7.2",
|
|
32
32
|
"jszip": "^3.10.1",
|
|
33
|
-
"@hot-updater/plugin-core": "1.2.0-rc.
|
|
34
|
-
"@hot-updater/cli-tools": "1.2.0-rc.
|
|
35
|
-
"@hot-updater/protocol": "1.2.0-rc.
|
|
33
|
+
"@hot-updater/plugin-core": "1.2.0-rc.14",
|
|
34
|
+
"@hot-updater/cli-tools": "1.2.0-rc.14",
|
|
35
|
+
"@hot-updater/protocol": "1.2.0-rc.14"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/node": "^20"
|