pakstr 0.8.4 → 0.8.5
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/android/icon.js
CHANGED
|
@@ -7,12 +7,13 @@ exports.patchIcon = patchIcon;
|
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const sharp_1 = __importDefault(require("sharp"));
|
|
10
|
-
|
|
10
|
+
const assetPath_1 = require("../core/assetPath");
|
|
11
|
+
async function patchIcon(androidRoot, iconPath, backgroundColor = "#FFFFFF", manifestDir = process.cwd()) {
|
|
11
12
|
if (!iconPath) {
|
|
12
13
|
console.log("ℹ️ No icon provided");
|
|
13
14
|
return;
|
|
14
15
|
}
|
|
15
|
-
const absoluteIconPath =
|
|
16
|
+
const absoluteIconPath = (0, assetPath_1.resolveAssetPath)(iconPath, manifestDir);
|
|
16
17
|
if (!fs_1.default.existsSync(absoluteIconPath)) {
|
|
17
18
|
throw new Error(`❌ Icon not found: ${absoluteIconPath}`);
|
|
18
19
|
}
|
|
@@ -10,6 +10,7 @@ const permissionMap = {
|
|
|
10
10
|
internet: "android.permission.INTERNET",
|
|
11
11
|
camera: "android.permission.CAMERA",
|
|
12
12
|
notifications: "android.permission.POST_NOTIFICATIONS",
|
|
13
|
+
vibrate: "android.permission.VIBRATE",
|
|
13
14
|
};
|
|
14
15
|
function patchPermissions(androidRoot, manifest) {
|
|
15
16
|
if (!manifest.permissions?.length) {
|
|
@@ -18,7 +19,7 @@ function patchPermissions(androidRoot, manifest) {
|
|
|
18
19
|
const file = path_1.default.join(androidRoot, "app/src/main/AndroidManifest.xml");
|
|
19
20
|
let xml = fs_1.default.readFileSync(file, "utf-8");
|
|
20
21
|
for (const perm of manifest.permissions) {
|
|
21
|
-
const androidPermission = permissionMap[perm];
|
|
22
|
+
const androidPermission = permissionMap[perm.trim().toLowerCase()];
|
|
22
23
|
if (!androidPermission) {
|
|
23
24
|
console.warn(`⚠️ Unknown permission: ${perm}`);
|
|
24
25
|
continue;
|
package/dist/android/splash.js
CHANGED
|
@@ -7,12 +7,13 @@ exports.patchSplash = patchSplash;
|
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const sharp_1 = __importDefault(require("sharp"));
|
|
10
|
-
|
|
10
|
+
const assetPath_1 = require("../core/assetPath");
|
|
11
|
+
async function patchSplash(androidRoot, splashPath, backgroundColor, manifestDir = process.cwd()) {
|
|
11
12
|
if (!splashPath) {
|
|
12
13
|
console.log("ℹ️ No splash provided");
|
|
13
14
|
return;
|
|
14
15
|
}
|
|
15
|
-
const absolutePath =
|
|
16
|
+
const absolutePath = (0, assetPath_1.resolveAssetPath)(splashPath, manifestDir);
|
|
16
17
|
if (!fs_1.default.existsSync(absolutePath)) {
|
|
17
18
|
throw new Error(`❌ Splash not found: ${absolutePath}`);
|
|
18
19
|
}
|
package/dist/commands/build.js
CHANGED
|
@@ -51,7 +51,7 @@ async function buildCommand(args) {
|
|
|
51
51
|
? (workspace = (0, releaseWorkspace_1.createReleaseWorkspace)(templateRoot)).androidRoot
|
|
52
52
|
: templateRoot;
|
|
53
53
|
console.log("📱 Android:", androidRoot);
|
|
54
|
-
await prepareAndroidProject(androidRoot, ctx.dist, manifest, appName);
|
|
54
|
+
await prepareAndroidProject(androidRoot, ctx.dist, manifest, appName, ctx.manifestDir);
|
|
55
55
|
if (signingInput) {
|
|
56
56
|
signing = (0, releaseSigning_1.createReleaseSigningContext)(signingInput);
|
|
57
57
|
signingInput.keystoreBase64 = "";
|
|
@@ -110,7 +110,7 @@ async function buildCommand(args) {
|
|
|
110
110
|
console.log("📦 Output:", finalPath);
|
|
111
111
|
openFolder(finalPath);
|
|
112
112
|
}
|
|
113
|
-
async function prepareAndroidProject(androidRoot, distPath, manifest, appName) {
|
|
113
|
+
async function prepareAndroidProject(androidRoot, distPath, manifest, appName, manifestDir) {
|
|
114
114
|
const assetsTarget = path_1.default.join(androidRoot, "app/src/main/assets/www");
|
|
115
115
|
if (!fs_1.default.existsSync(distPath)) {
|
|
116
116
|
throw new Error("Web assets not found");
|
|
@@ -122,10 +122,10 @@ async function prepareAndroidProject(androidRoot, distPath, manifest, appName) {
|
|
|
122
122
|
(0, gradle_1.patchGradle)(androidRoot, manifest);
|
|
123
123
|
(0, branding_1.patchAppName)(androidRoot, appName);
|
|
124
124
|
if (manifest.ui?.icon) {
|
|
125
|
-
await (0, icon_1.patchIcon)(androidRoot, manifest.ui.icon, manifest.backgroundColor ?? "#FFFFFF");
|
|
125
|
+
await (0, icon_1.patchIcon)(androidRoot, manifest.ui.icon, manifest.backgroundColor ?? "#FFFFFF", manifestDir);
|
|
126
126
|
}
|
|
127
127
|
if (manifest.ui?.splash) {
|
|
128
|
-
await (0, splash_1.patchSplash)(androidRoot, manifest.ui.splash.image, manifest.ui.splash.background ?? "#FFFFFF");
|
|
128
|
+
await (0, splash_1.patchSplash)(androidRoot, manifest.ui.splash.image, manifest.ui.splash.background ?? "#FFFFFF", manifestDir);
|
|
129
129
|
}
|
|
130
130
|
(0, permissions_1.patchPermissions)(androidRoot, manifest);
|
|
131
131
|
(0, generatedProjectVerification_1.verifyGeneratedAndroidProject)(androidRoot, {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.resolveAssetPath = resolveAssetPath;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
function resolveAssetPath(assetPath, manifestDir) {
|
|
10
|
+
if (path_1.default.isAbsolute(assetPath)) {
|
|
11
|
+
return assetPath;
|
|
12
|
+
}
|
|
13
|
+
const manifestRelativePath = path_1.default.resolve(manifestDir, assetPath);
|
|
14
|
+
if (fs_1.default.existsSync(manifestRelativePath)) {
|
|
15
|
+
return manifestRelativePath;
|
|
16
|
+
}
|
|
17
|
+
const cwdRelativePath = path_1.default.resolve(process.cwd(), assetPath);
|
|
18
|
+
if (fs_1.default.existsSync(cwdRelativePath)) {
|
|
19
|
+
return cwdRelativePath;
|
|
20
|
+
}
|
|
21
|
+
return manifestRelativePath;
|
|
22
|
+
}
|
|
@@ -92,6 +92,8 @@ function createBuildContext(args) {
|
|
|
92
92
|
const androidRoot = path_1.default.resolve(process.cwd(), "android-template");
|
|
93
93
|
return {
|
|
94
94
|
manifest,
|
|
95
|
+
manifestPath,
|
|
96
|
+
manifestDir: path_1.default.dirname(manifestPath),
|
|
95
97
|
dist: path_1.default.resolve(web),
|
|
96
98
|
out,
|
|
97
99
|
androidRoot,
|