@vxrn/utils 1.27.1 → 2.0.0-beta.100.1
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/cjs/createMessageSocket.cjs +115 -121
- package/dist/cjs/createMessageSocket.native.cjs +166 -0
- package/dist/cjs/createMessageSocket.native.js +152 -166
- package/dist/cjs/createMessageSocket.native.js.map +1 -1
- package/dist/cjs/detectPackageManager.cjs +76 -72
- package/dist/cjs/detectPackageManager.native.cjs +106 -0
- package/dist/cjs/detectPackageManager.native.js +82 -77
- package/dist/cjs/detectPackageManager.native.js.map +1 -1
- package/dist/cjs/exec.cjs +43 -45
- package/dist/cjs/exec.native.cjs +65 -0
- package/dist/cjs/exec.native.js +48 -49
- package/dist/cjs/exec.native.js.map +1 -1
- package/dist/cjs/index.cjs +10 -11
- package/dist/cjs/index.native.cjs +26 -0
- package/dist/cjs/index.native.js +10 -10
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/mustReplace.cjs +27 -35
- package/dist/cjs/mustReplace.native.cjs +60 -0
- package/dist/cjs/mustReplace.native.js +44 -60
- package/dist/cjs/mustReplace.native.js.map +1 -1
- package/dist/cjs/nativeAppManifest.cjs +110 -0
- package/dist/cjs/nativeAppManifest.native.cjs +135 -0
- package/dist/cjs/nativeAppManifest.native.js +137 -0
- package/dist/cjs/nativeAppManifest.native.js.map +1 -0
- package/dist/cjs/publicEnv.cjs +38 -0
- package/dist/cjs/publicEnv.native.cjs +57 -0
- package/dist/cjs/publicEnv.native.js +59 -0
- package/dist/cjs/publicEnv.native.js.map +1 -0
- package/dist/esm/createMessageSocket.mjs +103 -103
- package/dist/esm/createMessageSocket.mjs.map +1 -1
- package/dist/esm/createMessageSocket.native.js +139 -148
- package/dist/esm/createMessageSocket.native.js.map +1 -1
- package/dist/esm/detectPackageManager.mjs +65 -55
- package/dist/esm/detectPackageManager.mjs.map +1 -1
- package/dist/esm/detectPackageManager.native.js +71 -61
- package/dist/esm/detectPackageManager.native.js.map +1 -1
- package/dist/esm/exec.mjs +29 -27
- package/dist/esm/exec.mjs.map +1 -1
- package/dist/esm/exec.native.js +34 -32
- package/dist/esm/exec.native.js.map +1 -1
- package/dist/esm/index.js +13 -7
- package/dist/esm/index.mjs +13 -7
- package/dist/esm/index.native.js +13 -7
- package/dist/esm/mustReplace.mjs +15 -17
- package/dist/esm/mustReplace.mjs.map +1 -1
- package/dist/esm/mustReplace.native.js +32 -43
- package/dist/esm/mustReplace.native.js.map +1 -1
- package/dist/esm/nativeAppManifest.mjs +90 -0
- package/dist/esm/nativeAppManifest.mjs.map +1 -0
- package/dist/esm/nativeAppManifest.native.js +113 -0
- package/dist/esm/nativeAppManifest.native.js.map +1 -0
- package/dist/esm/publicEnv.mjs +14 -0
- package/dist/esm/publicEnv.mjs.map +1 -0
- package/dist/esm/publicEnv.native.js +31 -0
- package/dist/esm/publicEnv.native.js.map +1 -0
- package/package.json +17 -5
- package/src/index.ts +1 -0
- package/src/nativeAppManifest.test.ts +204 -0
- package/src/nativeAppManifest.ts +229 -0
- package/src/publicEnv.ts +19 -0
- package/types/createMessageSocket.d.ts +1 -1
- package/types/createMessageSocket.d.ts.map +1 -1
- package/types/detectPackageManager.d.ts.map +1 -1
- package/types/exec.d.ts.map +1 -1
- package/types/index.d.ts +1 -0
- package/types/index.d.ts.map +1 -1
- package/types/nativeAppManifest.d.ts +52 -0
- package/types/nativeAppManifest.d.ts.map +1 -0
- package/types/publicEnv.d.ts +9 -0
- package/types/publicEnv.d.ts.map +1 -0
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/index.mjs.map +0 -1
- package/dist/esm/index.native.js.map +0 -1
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
const TARGET_NAME = /^[A-Za-z][A-Za-z0-9_]*$/;
|
|
2
|
+
const SCHEME = /^[a-z][a-z0-9+.-]*$/i;
|
|
3
|
+
const VERSION = /^\d+\.\d+\.\d+/;
|
|
4
|
+
const BUILD_NUMBER = /^[A-Za-z0-9.]+$/;
|
|
5
|
+
const REVERSE_DNS = /^[A-Za-z][A-Za-z0-9-]*(\.[A-Za-z][A-Za-z0-9-]*)+$/;
|
|
6
|
+
const DEPLOYMENT_TARGET = /^\d+\.\d+$/;
|
|
7
|
+
const HEX_COLOR = /^#[\da-f]{6}$/i;
|
|
8
|
+
function fail(message) {
|
|
9
|
+
throw new Error(`[one] invalid native.app: ${message}`);
|
|
10
|
+
}
|
|
11
|
+
function validateNativeApp(manifest, platform) {
|
|
12
|
+
if (!manifest || typeof manifest !== "object") fail("manifest must be an object");
|
|
13
|
+
if (!manifest.name || typeof manifest.name !== "string") fail("name is required");
|
|
14
|
+
if (!TARGET_NAME.test(manifest.name)) {
|
|
15
|
+
fail(`name "${manifest.name}" must start with a letter and contain only letters, digits, and underscore`);
|
|
16
|
+
}
|
|
17
|
+
const schemes = manifest.scheme === void 0 ? [] : Array.isArray(manifest.scheme) ? manifest.scheme : [manifest.scheme];
|
|
18
|
+
for (const scheme of schemes) {
|
|
19
|
+
if (typeof scheme !== "string" || !SCHEME.test(scheme)) {
|
|
20
|
+
fail(`scheme "${scheme}" must be a valid uri scheme`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
if (manifest.version !== void 0 && !VERSION.test(manifest.version)) {
|
|
24
|
+
fail(`version "${manifest.version}" must start with major.minor.patch`);
|
|
25
|
+
}
|
|
26
|
+
if (manifest.icon !== void 0 && (!manifest.icon.source || !HEX_COLOR.test(manifest.icon.backgroundColor))) {
|
|
27
|
+
fail("icon requires source and a six-digit hex backgroundColor");
|
|
28
|
+
}
|
|
29
|
+
if (manifest.splash !== void 0 && (!manifest.splash.source || !HEX_COLOR.test(manifest.splash.backgroundColor) || manifest.splash.width !== void 0 && (!Number.isFinite(manifest.splash.width) || manifest.splash.width < 1 || manifest.splash.width > 288))) {
|
|
30
|
+
fail("splash requires source, a six-digit hex backgroundColor, and width from 1 to 288");
|
|
31
|
+
}
|
|
32
|
+
if (manifest.imagePicker?.camera !== void 0 && (typeof manifest.imagePicker.camera !== "string" || manifest.imagePicker.camera.trim() === "")) {
|
|
33
|
+
fail("imagePicker.camera must be a non-empty string");
|
|
34
|
+
}
|
|
35
|
+
if (manifest.notifications !== void 0) {
|
|
36
|
+
if (typeof manifest.notifications !== "object" || manifest.notifications.push !== void 0 && typeof manifest.notifications.push !== "boolean") {
|
|
37
|
+
fail("notifications.push must be a boolean");
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (manifest.pictureInPicture !== void 0 && typeof manifest.pictureInPicture !== "boolean") {
|
|
41
|
+
fail("pictureInPicture must be a boolean");
|
|
42
|
+
}
|
|
43
|
+
if (!platform || platform === "ios") {
|
|
44
|
+
if (!manifest.ios?.bundleId || !REVERSE_DNS.test(manifest.ios.bundleId)) {
|
|
45
|
+
fail(`ios.bundleId "${manifest.ios?.bundleId}" must be reverse-dns`);
|
|
46
|
+
}
|
|
47
|
+
if (manifest.ios.deploymentTarget !== void 0 && !DEPLOYMENT_TARGET.test(manifest.ios.deploymentTarget)) {
|
|
48
|
+
fail(`ios.deploymentTarget "${manifest.ios.deploymentTarget}" must look like "17.0"`);
|
|
49
|
+
}
|
|
50
|
+
if (manifest.ios.buildNumber !== void 0 && !BUILD_NUMBER.test(manifest.ios.buildNumber)) {
|
|
51
|
+
fail(`ios.buildNumber "${manifest.ios.buildNumber}" must contain only letters, digits, and dots`);
|
|
52
|
+
}
|
|
53
|
+
const widgets = manifest.ios.widgets;
|
|
54
|
+
if (widgets) {
|
|
55
|
+
if (!manifest.ios.deploymentTarget || Number(manifest.ios.deploymentTarget) < 17) {
|
|
56
|
+
fail("ios.widgets requires ios.deploymentTarget of 17.0 or newer");
|
|
57
|
+
}
|
|
58
|
+
if (!/^group\.[A-Za-z][A-Za-z0-9-]*(\.[A-Za-z][A-Za-z0-9-]*)+$/.test(widgets.appGroup)) {
|
|
59
|
+
fail("ios.widgets.appGroup must be a reverse-dns App Group beginning with group.");
|
|
60
|
+
}
|
|
61
|
+
if (!/^[A-Za-z][A-Za-z0-9._-]*$/.test(widgets.kind)) {
|
|
62
|
+
fail("ios.widgets.kind must be a non-empty WidgetKit kind");
|
|
63
|
+
}
|
|
64
|
+
if (!widgets.displayName?.trim() || !widgets.description?.trim()) {
|
|
65
|
+
fail("ios.widgets.displayName and description must be non-empty strings");
|
|
66
|
+
}
|
|
67
|
+
if (widgets.pushNotifications !== void 0 && typeof widgets.pushNotifications !== "boolean") {
|
|
68
|
+
fail("ios.widgets.pushNotifications must be a boolean");
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (!platform || platform === "android") {
|
|
73
|
+
if (!manifest.android?.applicationId || !REVERSE_DNS.test(manifest.android.applicationId)) {
|
|
74
|
+
fail(`android.applicationId "${manifest.android?.applicationId}" must be reverse-dns`);
|
|
75
|
+
}
|
|
76
|
+
if (manifest.android.minSdk !== void 0 && (!Number.isInteger(manifest.android.minSdk) || manifest.android.minSdk < 21 || manifest.android.minSdk > 36)) {
|
|
77
|
+
fail(`android.minSdk "${manifest.android.minSdk}" must be an integer from 21 to 36`);
|
|
78
|
+
}
|
|
79
|
+
if (manifest.android.versionCode !== void 0 && (!Number.isInteger(manifest.android.versionCode) || manifest.android.versionCode < 1)) {
|
|
80
|
+
fail(`android.versionCode "${manifest.android.versionCode}" must be a positive integer`);
|
|
81
|
+
}
|
|
82
|
+
if (manifest.android.googleMapsApiKey !== void 0 && (typeof manifest.android.googleMapsApiKey !== "string" || manifest.android.googleMapsApiKey.trim() === "")) {
|
|
83
|
+
fail("android.googleMapsApiKey must be a non-empty string");
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return manifest;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export { validateNativeApp };
|
|
90
|
+
//# sourceMappingURL=nativeAppManifest.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nativeAppManifest.js","names":[],"sources":["esm/nativeAppManifest.js"],"sourcesContent":["const TARGET_NAME = /^[A-Za-z][A-Za-z0-9_]*$/;\nconst SCHEME = /^[a-z][a-z0-9+.-]*$/i;\nconst VERSION = /^\\d+\\.\\d+\\.\\d+/;\nconst BUILD_NUMBER = /^[A-Za-z0-9.]+$/;\nconst REVERSE_DNS = /^[A-Za-z][A-Za-z0-9-]*(\\.[A-Za-z][A-Za-z0-9-]*)+$/;\nconst DEPLOYMENT_TARGET = /^\\d+\\.\\d+$/;\nconst HEX_COLOR = /^#[\\da-f]{6}$/i;\nfunction fail(message) {\n throw new Error(`[one] invalid native.app: ${message}`);\n}\nfunction validateNativeApp(manifest, platform) {\n if (!manifest || typeof manifest !== \"object\") fail(\"manifest must be an object\");\n if (!manifest.name || typeof manifest.name !== \"string\") fail(\"name is required\");\n if (!TARGET_NAME.test(manifest.name)) {\n fail(\n `name \"${manifest.name}\" must start with a letter and contain only letters, digits, and underscore`\n );\n }\n const schemes = manifest.scheme === void 0 ? [] : Array.isArray(manifest.scheme) ? manifest.scheme : [manifest.scheme];\n for (const scheme of schemes) {\n if (typeof scheme !== \"string\" || !SCHEME.test(scheme)) {\n fail(`scheme \"${scheme}\" must be a valid uri scheme`);\n }\n }\n if (manifest.version !== void 0 && !VERSION.test(manifest.version)) {\n fail(`version \"${manifest.version}\" must start with major.minor.patch`);\n }\n if (manifest.icon !== void 0 && (!manifest.icon.source || !HEX_COLOR.test(manifest.icon.backgroundColor))) {\n fail(\"icon requires source and a six-digit hex backgroundColor\");\n }\n if (manifest.splash !== void 0 && (!manifest.splash.source || !HEX_COLOR.test(manifest.splash.backgroundColor) || manifest.splash.width !== void 0 && (!Number.isFinite(manifest.splash.width) || manifest.splash.width < 1 || manifest.splash.width > 288))) {\n fail(\n \"splash requires source, a six-digit hex backgroundColor, and width from 1 to 288\"\n );\n }\n if (manifest.imagePicker?.camera !== void 0 && (typeof manifest.imagePicker.camera !== \"string\" || manifest.imagePicker.camera.trim() === \"\")) {\n fail(\"imagePicker.camera must be a non-empty string\");\n }\n if (manifest.notifications !== void 0) {\n if (typeof manifest.notifications !== \"object\" || manifest.notifications.push !== void 0 && typeof manifest.notifications.push !== \"boolean\") {\n fail(\"notifications.push must be a boolean\");\n }\n }\n if (manifest.pictureInPicture !== void 0 && typeof manifest.pictureInPicture !== \"boolean\") {\n fail(\"pictureInPicture must be a boolean\");\n }\n if (!platform || platform === \"ios\") {\n if (!manifest.ios?.bundleId || !REVERSE_DNS.test(manifest.ios.bundleId)) {\n fail(`ios.bundleId \"${manifest.ios?.bundleId}\" must be reverse-dns`);\n }\n if (manifest.ios.deploymentTarget !== void 0 && !DEPLOYMENT_TARGET.test(manifest.ios.deploymentTarget)) {\n fail(\n `ios.deploymentTarget \"${manifest.ios.deploymentTarget}\" must look like \"17.0\"`\n );\n }\n if (manifest.ios.buildNumber !== void 0 && !BUILD_NUMBER.test(manifest.ios.buildNumber)) {\n fail(\n `ios.buildNumber \"${manifest.ios.buildNumber}\" must contain only letters, digits, and dots`\n );\n }\n const widgets = manifest.ios.widgets;\n if (widgets) {\n if (!manifest.ios.deploymentTarget || Number(manifest.ios.deploymentTarget) < 17) {\n fail(\"ios.widgets requires ios.deploymentTarget of 17.0 or newer\");\n }\n if (!/^group\\.[A-Za-z][A-Za-z0-9-]*(\\.[A-Za-z][A-Za-z0-9-]*)+$/.test(widgets.appGroup)) {\n fail(\"ios.widgets.appGroup must be a reverse-dns App Group beginning with group.\");\n }\n if (!/^[A-Za-z][A-Za-z0-9._-]*$/.test(widgets.kind)) {\n fail(\"ios.widgets.kind must be a non-empty WidgetKit kind\");\n }\n if (!widgets.displayName?.trim() || !widgets.description?.trim()) {\n fail(\"ios.widgets.displayName and description must be non-empty strings\");\n }\n if (widgets.pushNotifications !== void 0 && typeof widgets.pushNotifications !== \"boolean\") {\n fail(\"ios.widgets.pushNotifications must be a boolean\");\n }\n }\n }\n if (!platform || platform === \"android\") {\n if (!manifest.android?.applicationId || !REVERSE_DNS.test(manifest.android.applicationId)) {\n fail(\n `android.applicationId \"${manifest.android?.applicationId}\" must be reverse-dns`\n );\n }\n if (manifest.android.minSdk !== void 0 && (!Number.isInteger(manifest.android.minSdk) || manifest.android.minSdk < 21 || manifest.android.minSdk > 36)) {\n fail(`android.minSdk \"${manifest.android.minSdk}\" must be an integer from 21 to 36`);\n }\n if (manifest.android.versionCode !== void 0 && (!Number.isInteger(manifest.android.versionCode) || manifest.android.versionCode < 1)) {\n fail(\n `android.versionCode \"${manifest.android.versionCode}\" must be a positive integer`\n );\n }\n if (manifest.android.googleMapsApiKey !== void 0 && (typeof manifest.android.googleMapsApiKey !== \"string\" || manifest.android.googleMapsApiKey.trim() === \"\")) {\n fail(\"android.googleMapsApiKey must be a non-empty string\");\n }\n }\n return manifest;\n}\nexport {\n validateNativeApp\n};\n//# sourceMappingURL=nativeAppManifest.js.map\n"],"mappings":";AAAA,MAAM,cAAc;AACpB,MAAM,SAAS;AACf,MAAM,UAAU;AAChB,MAAM,eAAe;AACrB,MAAM,cAAc;AACpB,MAAM,oBAAoB;AAC1B,MAAM,YAAY;AAClB,SAAS,KAAK,SAAS;CACrB,MAAM,IAAI,MAAM,6BAA6B,SAAS;AACxD;AACA,SAAS,kBAAkB,UAAU,UAAU;CAC7C,IAAI,CAAC,YAAY,OAAO,aAAa,UAAU,KAAK,4BAA4B;CAChF,IAAI,CAAC,SAAS,QAAQ,OAAO,SAAS,SAAS,UAAU,KAAK,kBAAkB;CAChF,IAAI,CAAC,YAAY,KAAK,SAAS,IAAI,GAAG;EACpC,KACE,SAAS,SAAS,KAAK,4EACzB;CACF;CACA,MAAM,UAAU,SAAS,WAAW,KAAK,IAAI,CAAC,IAAI,MAAM,QAAQ,SAAS,MAAM,IAAI,SAAS,SAAS,CAAC,SAAS,MAAM;CACrH,KAAK,MAAM,UAAU,SAAS;EAC5B,IAAI,OAAO,WAAW,YAAY,CAAC,OAAO,KAAK,MAAM,GAAG;GACtD,KAAK,WAAW,OAAO,6BAA6B;EACtD;CACF;CACA,IAAI,SAAS,YAAY,KAAK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,KAAK,qDAAqD;EAC5D;CACF;CACA,OAAO;AACT"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
var TARGET_NAME = /^[A-Za-z][A-Za-z0-9_]*$/;
|
|
2
|
+
var SCHEME = /^[a-z][a-z0-9+.-]*$/i;
|
|
3
|
+
var VERSION = /^\d+\.\d+\.\d+/;
|
|
4
|
+
var BUILD_NUMBER = /^[A-Za-z0-9.]+$/;
|
|
5
|
+
var REVERSE_DNS = /^[A-Za-z][A-Za-z0-9-]*(\.[A-Za-z][A-Za-z0-9-]*)+$/;
|
|
6
|
+
var DEPLOYMENT_TARGET = /^\d+\.\d+$/;
|
|
7
|
+
var HEX_COLOR = /^#[\da-f]{6}$/i;
|
|
8
|
+
function fail(message) {
|
|
9
|
+
throw new Error(`[one] invalid native.app: ${message}`);
|
|
10
|
+
}
|
|
11
|
+
function validateNativeApp(manifest, platform) {
|
|
12
|
+
var _manifest_imagePicker;
|
|
13
|
+
if (!manifest || typeof manifest !== "object") fail("manifest must be an object");
|
|
14
|
+
if (!manifest.name || typeof manifest.name !== "string") fail("name is required");
|
|
15
|
+
if (!TARGET_NAME.test(manifest.name)) {
|
|
16
|
+
fail(`name "${manifest.name}" must start with a letter and contain only letters, digits, and underscore`);
|
|
17
|
+
}
|
|
18
|
+
var schemes = manifest.scheme === void 0 ? [] : Array.isArray(manifest.scheme) ? manifest.scheme : [manifest.scheme];
|
|
19
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
20
|
+
try {
|
|
21
|
+
for (var _iterator = schemes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
22
|
+
var scheme = _step.value;
|
|
23
|
+
if (typeof scheme !== "string" || !SCHEME.test(scheme)) {
|
|
24
|
+
fail(`scheme "${scheme}" must be a valid uri scheme`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
} catch (err) {
|
|
28
|
+
_didIteratorError = true;
|
|
29
|
+
_iteratorError = err;
|
|
30
|
+
} finally {
|
|
31
|
+
try {
|
|
32
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
33
|
+
_iterator.return();
|
|
34
|
+
}
|
|
35
|
+
} finally {
|
|
36
|
+
if (_didIteratorError) {
|
|
37
|
+
throw _iteratorError;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (manifest.version !== void 0 && !VERSION.test(manifest.version)) {
|
|
42
|
+
fail(`version "${manifest.version}" must start with major.minor.patch`);
|
|
43
|
+
}
|
|
44
|
+
if (manifest.icon !== void 0 && (!manifest.icon.source || !HEX_COLOR.test(manifest.icon.backgroundColor))) {
|
|
45
|
+
fail("icon requires source and a six-digit hex backgroundColor");
|
|
46
|
+
}
|
|
47
|
+
if (manifest.splash !== void 0 && (!manifest.splash.source || !HEX_COLOR.test(manifest.splash.backgroundColor) || manifest.splash.width !== void 0 && (!Number.isFinite(manifest.splash.width) || manifest.splash.width < 1 || manifest.splash.width > 288))) {
|
|
48
|
+
fail("splash requires source, a six-digit hex backgroundColor, and width from 1 to 288");
|
|
49
|
+
}
|
|
50
|
+
if (((_manifest_imagePicker = manifest.imagePicker) === null || _manifest_imagePicker === void 0 ? void 0 : _manifest_imagePicker.camera) !== void 0 && (typeof manifest.imagePicker.camera !== "string" || manifest.imagePicker.camera.trim() === "")) {
|
|
51
|
+
fail("imagePicker.camera must be a non-empty string");
|
|
52
|
+
}
|
|
53
|
+
if (manifest.notifications !== void 0) {
|
|
54
|
+
if (typeof manifest.notifications !== "object" || manifest.notifications.push !== void 0 && typeof manifest.notifications.push !== "boolean") {
|
|
55
|
+
fail("notifications.push must be a boolean");
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (manifest.pictureInPicture !== void 0 && typeof manifest.pictureInPicture !== "boolean") {
|
|
59
|
+
fail("pictureInPicture must be a boolean");
|
|
60
|
+
}
|
|
61
|
+
if (!platform || platform === "ios") {
|
|
62
|
+
var _manifest_ios;
|
|
63
|
+
if (!((_manifest_ios = manifest.ios) === null || _manifest_ios === void 0 ? void 0 : _manifest_ios.bundleId) || !REVERSE_DNS.test(manifest.ios.bundleId)) {
|
|
64
|
+
var _manifest_ios1;
|
|
65
|
+
fail(`ios.bundleId "${(_manifest_ios1 = manifest.ios) === null || _manifest_ios1 === void 0 ? void 0 : _manifest_ios1.bundleId}" must be reverse-dns`);
|
|
66
|
+
}
|
|
67
|
+
if (manifest.ios.deploymentTarget !== void 0 && !DEPLOYMENT_TARGET.test(manifest.ios.deploymentTarget)) {
|
|
68
|
+
fail(`ios.deploymentTarget "${manifest.ios.deploymentTarget}" must look like "17.0"`);
|
|
69
|
+
}
|
|
70
|
+
if (manifest.ios.buildNumber !== void 0 && !BUILD_NUMBER.test(manifest.ios.buildNumber)) {
|
|
71
|
+
fail(`ios.buildNumber "${manifest.ios.buildNumber}" must contain only letters, digits, and dots`);
|
|
72
|
+
}
|
|
73
|
+
var widgets = manifest.ios.widgets;
|
|
74
|
+
if (widgets) {
|
|
75
|
+
var _widgets_displayName, _widgets_description;
|
|
76
|
+
if (!manifest.ios.deploymentTarget || Number(manifest.ios.deploymentTarget) < 17) {
|
|
77
|
+
fail("ios.widgets requires ios.deploymentTarget of 17.0 or newer");
|
|
78
|
+
}
|
|
79
|
+
if (!/^group\.[A-Za-z][A-Za-z0-9-]*(\.[A-Za-z][A-Za-z0-9-]*)+$/.test(widgets.appGroup)) {
|
|
80
|
+
fail("ios.widgets.appGroup must be a reverse-dns App Group beginning with group.");
|
|
81
|
+
}
|
|
82
|
+
if (!/^[A-Za-z][A-Za-z0-9._-]*$/.test(widgets.kind)) {
|
|
83
|
+
fail("ios.widgets.kind must be a non-empty WidgetKit kind");
|
|
84
|
+
}
|
|
85
|
+
if (!((_widgets_displayName = widgets.displayName) === null || _widgets_displayName === void 0 ? void 0 : _widgets_displayName.trim()) || !((_widgets_description = widgets.description) === null || _widgets_description === void 0 ? void 0 : _widgets_description.trim())) {
|
|
86
|
+
fail("ios.widgets.displayName and description must be non-empty strings");
|
|
87
|
+
}
|
|
88
|
+
if (widgets.pushNotifications !== void 0 && typeof widgets.pushNotifications !== "boolean") {
|
|
89
|
+
fail("ios.widgets.pushNotifications must be a boolean");
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (!platform || platform === "android") {
|
|
94
|
+
var _manifest_android;
|
|
95
|
+
if (!((_manifest_android = manifest.android) === null || _manifest_android === void 0 ? void 0 : _manifest_android.applicationId) || !REVERSE_DNS.test(manifest.android.applicationId)) {
|
|
96
|
+
var _manifest_android1;
|
|
97
|
+
fail(`android.applicationId "${(_manifest_android1 = manifest.android) === null || _manifest_android1 === void 0 ? void 0 : _manifest_android1.applicationId}" must be reverse-dns`);
|
|
98
|
+
}
|
|
99
|
+
if (manifest.android.minSdk !== void 0 && (!Number.isInteger(manifest.android.minSdk) || manifest.android.minSdk < 21 || manifest.android.minSdk > 36)) {
|
|
100
|
+
fail(`android.minSdk "${manifest.android.minSdk}" must be an integer from 21 to 36`);
|
|
101
|
+
}
|
|
102
|
+
if (manifest.android.versionCode !== void 0 && (!Number.isInteger(manifest.android.versionCode) || manifest.android.versionCode < 1)) {
|
|
103
|
+
fail(`android.versionCode "${manifest.android.versionCode}" must be a positive integer`);
|
|
104
|
+
}
|
|
105
|
+
if (manifest.android.googleMapsApiKey !== void 0 && (typeof manifest.android.googleMapsApiKey !== "string" || manifest.android.googleMapsApiKey.trim() === "")) {
|
|
106
|
+
fail("android.googleMapsApiKey must be a non-empty string");
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return manifest;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export { validateNativeApp };
|
|
113
|
+
//# sourceMappingURL=nativeAppManifest.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nativeAppManifest.native.js","names":[],"sources":["esm/nativeAppManifest.native.js"],"sourcesContent":["var TARGET_NAME = /^[A-Za-z][A-Za-z0-9_]*$/;\nvar SCHEME = /^[a-z][a-z0-9+.-]*$/i;\nvar VERSION = /^\\d+\\.\\d+\\.\\d+/;\nvar BUILD_NUMBER = /^[A-Za-z0-9.]+$/;\nvar REVERSE_DNS = /^[A-Za-z][A-Za-z0-9-]*(\\.[A-Za-z][A-Za-z0-9-]*)+$/;\nvar DEPLOYMENT_TARGET = /^\\d+\\.\\d+$/;\nvar HEX_COLOR = /^#[\\da-f]{6}$/i;\nfunction fail(message) {\n throw new Error(`[one] invalid native.app: ${message}`);\n}\nfunction validateNativeApp(manifest, platform) {\n var _manifest_imagePicker;\n if (!manifest || typeof manifest !== \"object\") fail(\"manifest must be an object\");\n if (!manifest.name || typeof manifest.name !== \"string\") fail(\"name is required\");\n if (!TARGET_NAME.test(manifest.name)) {\n fail(`name \"${manifest.name}\" must start with a letter and contain only letters, digits, and underscore`);\n }\n var schemes = manifest.scheme === void 0 ? [] : Array.isArray(manifest.scheme) ? manifest.scheme : [\n manifest.scheme\n ];\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = schemes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var scheme = _step.value;\n if (typeof scheme !== \"string\" || !SCHEME.test(scheme)) {\n fail(`scheme \"${scheme}\" must be a valid uri scheme`);\n }\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n if (manifest.version !== void 0 && !VERSION.test(manifest.version)) {\n fail(`version \"${manifest.version}\" must start with major.minor.patch`);\n }\n if (manifest.icon !== void 0 && (!manifest.icon.source || !HEX_COLOR.test(manifest.icon.backgroundColor))) {\n fail(\"icon requires source and a six-digit hex backgroundColor\");\n }\n if (manifest.splash !== void 0 && (!manifest.splash.source || !HEX_COLOR.test(manifest.splash.backgroundColor) || manifest.splash.width !== void 0 && (!Number.isFinite(manifest.splash.width) || manifest.splash.width < 1 || manifest.splash.width > 288))) {\n fail(\"splash requires source, a six-digit hex backgroundColor, and width from 1 to 288\");\n }\n if (((_manifest_imagePicker = manifest.imagePicker) === null || _manifest_imagePicker === void 0 ? void 0 : _manifest_imagePicker.camera) !== void 0 && (typeof manifest.imagePicker.camera !== \"string\" || manifest.imagePicker.camera.trim() === \"\")) {\n fail(\"imagePicker.camera must be a non-empty string\");\n }\n if (manifest.notifications !== void 0) {\n if (typeof manifest.notifications !== \"object\" || manifest.notifications.push !== void 0 && typeof manifest.notifications.push !== \"boolean\") {\n fail(\"notifications.push must be a boolean\");\n }\n }\n if (manifest.pictureInPicture !== void 0 && typeof manifest.pictureInPicture !== \"boolean\") {\n fail(\"pictureInPicture must be a boolean\");\n }\n if (!platform || platform === \"ios\") {\n var _manifest_ios;\n if (!((_manifest_ios = manifest.ios) === null || _manifest_ios === void 0 ? void 0 : _manifest_ios.bundleId) || !REVERSE_DNS.test(manifest.ios.bundleId)) {\n var _manifest_ios1;\n fail(`ios.bundleId \"${(_manifest_ios1 = manifest.ios) === null || _manifest_ios1 === void 0 ? void 0 : _manifest_ios1.bundleId}\" must be reverse-dns`);\n }\n if (manifest.ios.deploymentTarget !== void 0 && !DEPLOYMENT_TARGET.test(manifest.ios.deploymentTarget)) {\n fail(`ios.deploymentTarget \"${manifest.ios.deploymentTarget}\" must look like \"17.0\"`);\n }\n if (manifest.ios.buildNumber !== void 0 && !BUILD_NUMBER.test(manifest.ios.buildNumber)) {\n fail(`ios.buildNumber \"${manifest.ios.buildNumber}\" must contain only letters, digits, and dots`);\n }\n var widgets = manifest.ios.widgets;\n if (widgets) {\n var _widgets_displayName, _widgets_description;\n if (!manifest.ios.deploymentTarget || Number(manifest.ios.deploymentTarget) < 17) {\n fail(\"ios.widgets requires ios.deploymentTarget of 17.0 or newer\");\n }\n if (!/^group\\.[A-Za-z][A-Za-z0-9-]*(\\.[A-Za-z][A-Za-z0-9-]*)+$/.test(widgets.appGroup)) {\n fail(\"ios.widgets.appGroup must be a reverse-dns App Group beginning with group.\");\n }\n if (!/^[A-Za-z][A-Za-z0-9._-]*$/.test(widgets.kind)) {\n fail(\"ios.widgets.kind must be a non-empty WidgetKit kind\");\n }\n if (!((_widgets_displayName = widgets.displayName) === null || _widgets_displayName === void 0 ? void 0 : _widgets_displayName.trim()) || !((_widgets_description = widgets.description) === null || _widgets_description === void 0 ? void 0 : _widgets_description.trim())) {\n fail(\"ios.widgets.displayName and description must be non-empty strings\");\n }\n if (widgets.pushNotifications !== void 0 && typeof widgets.pushNotifications !== \"boolean\") {\n fail(\"ios.widgets.pushNotifications must be a boolean\");\n }\n }\n }\n if (!platform || platform === \"android\") {\n var _manifest_android;\n if (!((_manifest_android = manifest.android) === null || _manifest_android === void 0 ? void 0 : _manifest_android.applicationId) || !REVERSE_DNS.test(manifest.android.applicationId)) {\n var _manifest_android1;\n fail(`android.applicationId \"${(_manifest_android1 = manifest.android) === null || _manifest_android1 === void 0 ? void 0 : _manifest_android1.applicationId}\" must be reverse-dns`);\n }\n if (manifest.android.minSdk !== void 0 && (!Number.isInteger(manifest.android.minSdk) || manifest.android.minSdk < 21 || manifest.android.minSdk > 36)) {\n fail(`android.minSdk \"${manifest.android.minSdk}\" must be an integer from 21 to 36`);\n }\n if (manifest.android.versionCode !== void 0 && (!Number.isInteger(manifest.android.versionCode) || manifest.android.versionCode < 1)) {\n fail(`android.versionCode \"${manifest.android.versionCode}\" must be a positive integer`);\n }\n if (manifest.android.googleMapsApiKey !== void 0 && (typeof manifest.android.googleMapsApiKey !== \"string\" || manifest.android.googleMapsApiKey.trim() === \"\")) {\n fail(\"android.googleMapsApiKey must be a non-empty string\");\n }\n }\n return manifest;\n}\nexport {\n validateNativeApp\n};\n//# sourceMappingURL=nativeAppManifest.js.map\n"],"mappings":";AAAA,IAAI,cAAc;AAClB,IAAI,SAAS;AACb,IAA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B,SAAS,QAAQ,OAAO,mCAAmC;EACrF;EACA,IAAI,SAAS,QAAQ,gBAAgB,KAAK,MAAM,CAAC,OAAO,UAAU,SAAS,QAAQ,WAAW,KAAK,SAAS,QAAQ,cAAc,IAAI;GACpI,KAAK,wBAAwB,SAAS,QAAQ,YAAY,6BAA6B;EACzF;EACA,IAAI,SAAS,QAAQ,qBAAqB,KAAK,MAAM,OAAO,SAAS,QAAQ,qBAAqB,YAAY,SAAS,QAAQ,iBAAiB,KAAK,MAAM,KAAK;GAC9J,KAAK,qDAAqD;EAC5D;CACF;CACA,OAAO;AACT"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const ONE_PUBLIC_PREFIX = "ONE_PUBLIC_";
|
|
2
|
+
const EXPO_PUBLIC_PREFIX = "EXPO_PUBLIC_";
|
|
3
|
+
function withExpoPublicEnvAliases(env) {
|
|
4
|
+
const aliased = { ...env };
|
|
5
|
+
for (const [key, value] of Object.entries(env)) {
|
|
6
|
+
if (!key.startsWith("ONE_PUBLIC_")) continue;
|
|
7
|
+
const expoKey = `${EXPO_PUBLIC_PREFIX}${key.slice(ONE_PUBLIC_PREFIX.length)}`;
|
|
8
|
+
if (!(expoKey in aliased)) aliased[expoKey] = value;
|
|
9
|
+
}
|
|
10
|
+
return aliased;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { EXPO_PUBLIC_PREFIX, ONE_PUBLIC_PREFIX, withExpoPublicEnvAliases };
|
|
14
|
+
//# sourceMappingURL=publicEnv.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publicEnv.js","names":[],"sources":["esm/publicEnv.js"],"sourcesContent":["const ONE_PUBLIC_PREFIX = \"ONE_PUBLIC_\";\nconst EXPO_PUBLIC_PREFIX = \"EXPO_PUBLIC_\";\nfunction withExpoPublicEnvAliases(env) {\n const aliased = { ...env };\n for (const [key, value] of Object.entries(env)) {\n if (!key.startsWith(ONE_PUBLIC_PREFIX)) continue;\n const expoKey = `${EXPO_PUBLIC_PREFIX}${key.slice(ONE_PUBLIC_PREFIX.length)}`;\n if (!(expoKey in aliased)) aliased[expoKey] = value;\n }\n return aliased;\n}\nexport {\n EXPO_PUBLIC_PREFIX,\n ONE_PUBLIC_PREFIX,\n withExpoPublicEnvAliases\n};\n//# sourceMappingURL=publicEnv.js.map\n"],"mappings":";AAAA,MAAM,oBAAoB;AAC1B,MAAM,qBAAqB;AAC3B,SAAS,yBAAyB,KAAK;CACrC,MAAM,UAAU,EAAE,GAAG,IAAI;CACzB,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,GAAG,GAAG;EAC9C,IAAI,CAAC,IAAI,wBAA4B,GAAG;EACxC,MAAM,UAAU,GAAG,qBAAqB,IAAI,MAAM,kBAAkB,MAAM;EAC1E,IAAI,EAAE,WAAW,UAAU,QAAQ,WAAW;CAChD;CACA,OAAO;AACT"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
var ONE_PUBLIC_PREFIX = "ONE_PUBLIC_";
|
|
2
|
+
var EXPO_PUBLIC_PREFIX = "EXPO_PUBLIC_";
|
|
3
|
+
function withExpoPublicEnvAliases(env) {
|
|
4
|
+
var aliased = { ...env };
|
|
5
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
6
|
+
try {
|
|
7
|
+
for (var _iterator = Object.entries(env)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
8
|
+
var [key, value] = _step.value;
|
|
9
|
+
if (!key.startsWith("ONE_PUBLIC_")) continue;
|
|
10
|
+
var expoKey = `${EXPO_PUBLIC_PREFIX}${key.slice(ONE_PUBLIC_PREFIX.length)}`;
|
|
11
|
+
if (!(expoKey in aliased)) aliased[expoKey] = value;
|
|
12
|
+
}
|
|
13
|
+
} catch (err) {
|
|
14
|
+
_didIteratorError = true;
|
|
15
|
+
_iteratorError = err;
|
|
16
|
+
} finally {
|
|
17
|
+
try {
|
|
18
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
19
|
+
_iterator.return();
|
|
20
|
+
}
|
|
21
|
+
} finally {
|
|
22
|
+
if (_didIteratorError) {
|
|
23
|
+
throw _iteratorError;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return aliased;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export { EXPO_PUBLIC_PREFIX, ONE_PUBLIC_PREFIX, withExpoPublicEnvAliases };
|
|
31
|
+
//# sourceMappingURL=publicEnv.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publicEnv.native.js","names":[],"sources":["esm/publicEnv.native.js"],"sourcesContent":["var ONE_PUBLIC_PREFIX = \"ONE_PUBLIC_\";\nvar EXPO_PUBLIC_PREFIX = \"EXPO_PUBLIC_\";\nfunction withExpoPublicEnvAliases(env) {\n var aliased = {\n ...env\n };\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = Object.entries(env)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var [key, value] = _step.value;\n if (!key.startsWith(ONE_PUBLIC_PREFIX)) continue;\n var expoKey = `${EXPO_PUBLIC_PREFIX}${key.slice(ONE_PUBLIC_PREFIX.length)}`;\n if (!(expoKey in aliased)) aliased[expoKey] = value;\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n return aliased;\n}\nexport {\n EXPO_PUBLIC_PREFIX,\n ONE_PUBLIC_PREFIX,\n withExpoPublicEnvAliases\n};\n//# sourceMappingURL=publicEnv.js.map\n"],"mappings":";AAAA,IAAI,oBAAoB;AACxB,IAAI,qBAAqB;AACzB,SAAS,yBAAyB,KAAK;CACrC,IAAI,UAAU,EACZ,GAAG,IACL;CACA,IAAI,4BAA4B,MAAM,oBAAoB,OAAO,iBAAiB,KAAK;CACvF,IAAI;EACF,KAAK,IAAI,YAAY,OAAO,QAAQ,GAAG,CAAC,CAAC,OAAO,SAAS,CAAC,GAAG,OAAO,EAAE,6BAA6B,QAAQ,UAAU,KAAK,EAAC,CAAE,OAAO,4BAA4B,MAAM;GACpK,IAAI,CAAC,KAAK,SAAS,MAAM;GACzB,IAAI,CAAC,IAAI,wBAA4B,GAAG;GACxC,IAAI,UAAU,GAAG,qBAAqB,IAAI,MAAM,kBAAkB,MAAM;GACxE,IAAI,EAAE,WAAW,UAAU,QAAQ,WAAW;EAChD;CACF,SAAS,KAAK;EACZ,oBAAoB;EACpB,iBAAiB;CACnB,UAAU;EACR,IAAI;GACF,IAAI,CAAC,6BAA6B,UAAU,UAAU,MAAM;IAC1D,UAAU,OAAO;GACnB;EACF,UAAU;GACR,IAAI,mBAAmB;IACrB,MAAM;GACR;EACF;CACF;CACA,OAAO;AACT"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vxrn/utils",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-beta.100.1",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./types/index.d.ts",
|
|
@@ -13,6 +13,16 @@
|
|
|
13
13
|
"types": "./types/index.d.ts",
|
|
14
14
|
"import": "./dist/esm/index.mjs",
|
|
15
15
|
"require": "./dist/cjs/index.cjs"
|
|
16
|
+
},
|
|
17
|
+
"./publicEnv": {
|
|
18
|
+
"types": "./types/publicEnv.d.ts",
|
|
19
|
+
"import": "./dist/esm/publicEnv.mjs",
|
|
20
|
+
"require": "./dist/cjs/publicEnv.cjs"
|
|
21
|
+
},
|
|
22
|
+
"./nativeAppManifest": {
|
|
23
|
+
"types": "./types/nativeAppManifest.d.ts",
|
|
24
|
+
"import": "./dist/esm/nativeAppManifest.mjs",
|
|
25
|
+
"require": "./dist/cjs/nativeAppManifest.cjs"
|
|
16
26
|
}
|
|
17
27
|
},
|
|
18
28
|
"files": [
|
|
@@ -27,16 +37,18 @@
|
|
|
27
37
|
"lint:fix": "npx biome check --write --unsafe src",
|
|
28
38
|
"clean": "tamagui-build clean",
|
|
29
39
|
"clean:build": "tamagui-build clean:build",
|
|
40
|
+
"test": "vitest run --dir src",
|
|
30
41
|
"typecheck": "tsc --noEmit"
|
|
31
42
|
},
|
|
32
43
|
"dependencies": {
|
|
33
|
-
"@vxrn/debug": "
|
|
34
|
-
"@vxrn/resolve": "
|
|
44
|
+
"@vxrn/debug": "2.0.0-beta.100.1",
|
|
45
|
+
"@vxrn/resolve": "2.0.0-beta.100.1",
|
|
35
46
|
"ws": "^8.21.0"
|
|
36
47
|
},
|
|
37
48
|
"devDependencies": {
|
|
38
|
-
"@tamagui/build": "
|
|
39
|
-
"@types/ws": "^8.18.1"
|
|
49
|
+
"@tamagui/build": "3.0.0-beta.1432.1",
|
|
50
|
+
"@types/ws": "^8.18.1",
|
|
51
|
+
"vitest": "^4.1.0"
|
|
40
52
|
},
|
|
41
53
|
"publishConfig": {
|
|
42
54
|
"access": "public"
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { describe, expect, test } from 'vitest'
|
|
2
|
+
import { validateNativeApp, type NativeAppManifest } from './nativeAppManifest'
|
|
3
|
+
|
|
4
|
+
const app = {
|
|
5
|
+
name: 'MyApp',
|
|
6
|
+
displayName: 'My App',
|
|
7
|
+
scheme: ['myapp', 'myapp-dev'],
|
|
8
|
+
version: '1.0.0',
|
|
9
|
+
imagePicker: { camera: 'Take profile photos.' },
|
|
10
|
+
ios: {
|
|
11
|
+
bundleId: 'dev.one.myapp',
|
|
12
|
+
buildNumber: '42',
|
|
13
|
+
tablet: true,
|
|
14
|
+
deploymentTarget: '17.0',
|
|
15
|
+
screensGamma: true,
|
|
16
|
+
useFrameworks: 'static',
|
|
17
|
+
ccache: true,
|
|
18
|
+
usesNonExemptEncryption: false,
|
|
19
|
+
},
|
|
20
|
+
android: { applicationId: 'dev.one.myapp', versionCode: 42, minSdk: 28 },
|
|
21
|
+
} satisfies NativeAppManifest
|
|
22
|
+
|
|
23
|
+
describe('native.app manifest', () => {
|
|
24
|
+
test('accepts a valid manifest', () => {
|
|
25
|
+
expect(() => validateNativeApp(app)).not.toThrow()
|
|
26
|
+
expect(() => validateNativeApp(app, 'ios')).not.toThrow()
|
|
27
|
+
expect(() => validateNativeApp(app, 'android')).not.toThrow()
|
|
28
|
+
expect(validateNativeApp(app)).toBe(app)
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
test('rejects invalid target names and schemes', () => {
|
|
32
|
+
expect(() => validateNativeApp({} as any)).toThrow(/name/)
|
|
33
|
+
expect(() => validateNativeApp({ name: 'my-app' } as any)).toThrow(/name/)
|
|
34
|
+
expect(() => validateNativeApp({ ...app, scheme: 'not a scheme' })).toThrow(/scheme/)
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
test('rejects bad versions, icons, and splashes', () => {
|
|
38
|
+
expect(() => validateNativeApp({ ...app, version: 'latest' })).toThrow(/version/)
|
|
39
|
+
expect(() =>
|
|
40
|
+
validateNativeApp({
|
|
41
|
+
...app,
|
|
42
|
+
icon: { source: '', backgroundColor: '#000000' },
|
|
43
|
+
})
|
|
44
|
+
).toThrow(/icon/)
|
|
45
|
+
expect(() =>
|
|
46
|
+
validateNativeApp({
|
|
47
|
+
...app,
|
|
48
|
+
splash: { source: './splash.png', backgroundColor: 'black' },
|
|
49
|
+
})
|
|
50
|
+
).toThrow(/splash/)
|
|
51
|
+
expect(() =>
|
|
52
|
+
validateNativeApp({
|
|
53
|
+
...app,
|
|
54
|
+
splash: { source: './splash.png', backgroundColor: '#000000', width: 0.99 },
|
|
55
|
+
})
|
|
56
|
+
).toThrow(/splash/)
|
|
57
|
+
expect(() =>
|
|
58
|
+
validateNativeApp({
|
|
59
|
+
...app,
|
|
60
|
+
splash: { source: './splash.png', backgroundColor: '#000000', width: 289 },
|
|
61
|
+
})
|
|
62
|
+
).toThrow(/splash/)
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
test('accepts a camera permission string and rejects empty ones', () => {
|
|
66
|
+
expect(() => validateNativeApp({ ...app, imagePicker: undefined })).not.toThrow()
|
|
67
|
+
expect(() => validateNativeApp({ ...app, imagePicker: { camera: '' } })).toThrow(
|
|
68
|
+
/imagePicker\.camera/
|
|
69
|
+
)
|
|
70
|
+
expect(() => validateNativeApp({ ...app, imagePicker: { camera: ' ' } })).toThrow(
|
|
71
|
+
/imagePicker\.camera/
|
|
72
|
+
)
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
test('validates the iOS widget target and App Group before prebuild', () => {
|
|
76
|
+
const widgets = {
|
|
77
|
+
appGroup: 'group.dev.one.myapp',
|
|
78
|
+
kind: 'MyAppStatus',
|
|
79
|
+
displayName: 'Status',
|
|
80
|
+
description: 'Current status',
|
|
81
|
+
}
|
|
82
|
+
expect(() =>
|
|
83
|
+
validateNativeApp({ ...app, ios: { ...app.ios, widgets } })
|
|
84
|
+
).not.toThrow()
|
|
85
|
+
expect(() =>
|
|
86
|
+
validateNativeApp({
|
|
87
|
+
...app,
|
|
88
|
+
ios: { ...app.ios, widgets: { ...widgets, pushNotifications: 'yes' as any } },
|
|
89
|
+
})
|
|
90
|
+
).toThrow(/pushNotifications/)
|
|
91
|
+
expect(() =>
|
|
92
|
+
validateNativeApp({
|
|
93
|
+
...app,
|
|
94
|
+
ios: { ...app.ios, deploymentTarget: '16.4', widgets },
|
|
95
|
+
})
|
|
96
|
+
).toThrow(/deploymentTarget/)
|
|
97
|
+
expect(() =>
|
|
98
|
+
validateNativeApp({
|
|
99
|
+
...app,
|
|
100
|
+
ios: { ...app.ios, widgets: { ...widgets, appGroup: 'dev.one.myapp' } },
|
|
101
|
+
})
|
|
102
|
+
).toThrow(/appGroup/)
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
test('rejects missing platform ids and out-of-range platform values', () => {
|
|
106
|
+
expect(() => validateNativeApp({ name: 'MyApp' } as any)).toThrow(/bundleId/)
|
|
107
|
+
expect(() =>
|
|
108
|
+
validateNativeApp({ name: 'MyApp', android: app.android } as any)
|
|
109
|
+
).toThrow(/bundleId/)
|
|
110
|
+
expect(() =>
|
|
111
|
+
validateNativeApp({
|
|
112
|
+
name: 'MyApp',
|
|
113
|
+
ios: { bundleId: 'not-an-id' },
|
|
114
|
+
android: app.android,
|
|
115
|
+
} as any)
|
|
116
|
+
).toThrow(/bundleId/)
|
|
117
|
+
expect(() => validateNativeApp({ name: 'MyApp', ios: app.ios } as any)).toThrow(
|
|
118
|
+
/applicationId/
|
|
119
|
+
)
|
|
120
|
+
expect(() =>
|
|
121
|
+
validateNativeApp({
|
|
122
|
+
name: 'MyApp',
|
|
123
|
+
ios: app.ios,
|
|
124
|
+
android: { applicationId: '' },
|
|
125
|
+
} as any)
|
|
126
|
+
).toThrow(/applicationId/)
|
|
127
|
+
expect(() =>
|
|
128
|
+
validateNativeApp({
|
|
129
|
+
...app,
|
|
130
|
+
ios: { bundleId: 'dev.one.myapp', deploymentTarget: 'latest' },
|
|
131
|
+
} as any)
|
|
132
|
+
).toThrow(/deploymentTarget/)
|
|
133
|
+
expect(() =>
|
|
134
|
+
validateNativeApp({ ...app, android: { ...app.android, minSdk: 20 } } as any)
|
|
135
|
+
).toThrow(/minSdk/)
|
|
136
|
+
expect(() =>
|
|
137
|
+
validateNativeApp({
|
|
138
|
+
...app,
|
|
139
|
+
ios: { bundleId: 'dev.one.myapp', buildNumber: '1 2' },
|
|
140
|
+
})
|
|
141
|
+
).toThrow(/buildNumber/)
|
|
142
|
+
expect(() =>
|
|
143
|
+
validateNativeApp({
|
|
144
|
+
...app,
|
|
145
|
+
ios: { bundleId: 'dev.one.myapp', buildNumber: '' },
|
|
146
|
+
})
|
|
147
|
+
).toThrow(/buildNumber/)
|
|
148
|
+
expect(() =>
|
|
149
|
+
validateNativeApp({
|
|
150
|
+
...app,
|
|
151
|
+
android: { applicationId: 'dev.one.myapp', versionCode: 0 },
|
|
152
|
+
})
|
|
153
|
+
).toThrow(/versionCode/)
|
|
154
|
+
expect(() =>
|
|
155
|
+
validateNativeApp({
|
|
156
|
+
...app,
|
|
157
|
+
android: { applicationId: 'dev.one.myapp', versionCode: 1.5 },
|
|
158
|
+
})
|
|
159
|
+
).toThrow(/versionCode/)
|
|
160
|
+
})
|
|
161
|
+
|
|
162
|
+
test('accepts notifications and rejects a non-boolean push', () => {
|
|
163
|
+
expect(() => validateNativeApp({ ...app, notifications: undefined })).not.toThrow()
|
|
164
|
+
expect(() =>
|
|
165
|
+
validateNativeApp({ ...app, notifications: { push: true } })
|
|
166
|
+
).not.toThrow()
|
|
167
|
+
expect(() =>
|
|
168
|
+
validateNativeApp({ ...app, notifications: { push: 'yes' } } as any)
|
|
169
|
+
).toThrow(/notifications\.push/)
|
|
170
|
+
expect(() => validateNativeApp({ ...app, notifications: true } as any)).toThrow(
|
|
171
|
+
/notifications\.push/
|
|
172
|
+
)
|
|
173
|
+
})
|
|
174
|
+
|
|
175
|
+
test('accepts a maps key and rejects empty ones', () => {
|
|
176
|
+
expect(() =>
|
|
177
|
+
validateNativeApp({
|
|
178
|
+
...app,
|
|
179
|
+
android: { ...app.android, googleMapsApiKey: 'AIza-test' },
|
|
180
|
+
})
|
|
181
|
+
).not.toThrow()
|
|
182
|
+
expect(() =>
|
|
183
|
+
validateNativeApp({
|
|
184
|
+
...app,
|
|
185
|
+
android: { ...app.android, googleMapsApiKey: '' },
|
|
186
|
+
})
|
|
187
|
+
).toThrow(/googleMapsApiKey/)
|
|
188
|
+
expect(() =>
|
|
189
|
+
validateNativeApp({
|
|
190
|
+
...app,
|
|
191
|
+
android: { ...app.android, googleMapsApiKey: ' ' },
|
|
192
|
+
})
|
|
193
|
+
).toThrow(/googleMapsApiKey/)
|
|
194
|
+
})
|
|
195
|
+
|
|
196
|
+
test('platform scope skips the other platform requirement', () => {
|
|
197
|
+
expect(() =>
|
|
198
|
+
validateNativeApp({ name: 'MyApp', android: app.android } as any, 'android')
|
|
199
|
+
).not.toThrow()
|
|
200
|
+
expect(() =>
|
|
201
|
+
validateNativeApp({ name: 'MyApp', ios: app.ios } as any, 'ios')
|
|
202
|
+
).not.toThrow()
|
|
203
|
+
})
|
|
204
|
+
})
|