akanjs 3.3.0-rc.82 → 3.3.0-rc.84

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "akanjs",
3
- "version": "3.3.0-rc.82",
3
+ "version": "3.3.0-rc.84",
4
4
  "sourceType": "module",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -29,18 +29,18 @@ export class WellKnownRoutes {
29
29
  { cacheControl }: { cacheControl: string },
30
30
  ) {
31
31
  const associations = artifact.deepLinkAssociations ?? [];
32
+
33
+ const idSuffixes = process.env.AKAN_PUBLIC_ENV === "main" ? [""] : ["", ".debug"];
32
34
  if (pathname === APPLE_APP_SITE_ASSOCIATION_PATH) {
33
35
  const details = associations
34
36
  .filter((association) => association.domains.length > 0 && association.iosTeamId && association.iosAppId)
35
37
  .map((association) => ({
36
- appIDs: [`${association.iosTeamId}.${association.iosAppId}`],
38
+ appIDs: idSuffixes.map((suffix) => `${association.iosTeamId}.${association.iosAppId}${suffix}`),
37
39
  components: [{ "/": "/*" }],
38
40
  }));
39
41
  if (details.length === 0) return null;
40
42
  return WellKnownRoutes.#jsonResponse({ applinks: { apps: [], details } }, cacheControl);
41
43
  }
42
-
43
- const packageSuffixes = process.env.AKAN_PUBLIC_ENV === "main" ? [""] : ["", ".debug"];
44
44
  const assetLinks = associations
45
45
  .filter(
46
46
  (association) =>
@@ -49,7 +49,7 @@ export class WellKnownRoutes {
49
49
  (association.androidSha256CertFingerprints?.length ?? 0) > 0,
50
50
  )
51
51
  .flatMap((association) =>
52
- packageSuffixes.map((suffix) => ({
52
+ idSuffixes.map((suffix) => ({
53
53
  relation: ["delegate_permission/common.handle_all_urls"],
54
54
  target: {
55
55
  namespace: "android_app",
@@ -244,6 +244,8 @@ export interface AkanNativeConfig {
244
244
  * release app. Deep links and app links must list the suffixed id for debug builds.
245
245
  */
246
246
  debugAppIdSuffix?: string;
247
+ /** Appended to app.name in debug builds (e.g. " Dev"), so the launcher tells a debug build from the release app. */
248
+ debugAppNameSuffix?: string;
247
249
  /**
248
250
  * The Firebase project's google-services.json (relative to the app folder), for the push plugin's
249
251
  * FCM module: its values become the string resources Firebase initializes from, as the
@@ -285,6 +287,13 @@ export interface AkanNativeConfig {
285
287
  ios?: {
286
288
  /** Hide the bar with previous / next / Done above the keyboard for form fields. Default false. */
287
289
  hideFormAccessoryBar?: boolean;
290
+ /**
291
+ * Appended to app.id in debug builds (e.g. ".debug"), so a debug build installs next to the
292
+ * App Store app instead of replacing it. A device build then signs with a profile for the suffixed id.
293
+ */
294
+ debugAppIdSuffix?: string;
295
+ /** Appended to app.name in debug builds (e.g. " Dev"), so the home screen tells a debug build from the App Store app. */
296
+ debugAppNameSuffix?: string;
288
297
  };
289
298
  desktop?: {
290
299
  /**
@@ -0,0 +1,3 @@
1
+ import type { AkanNativeConfig } from "../config.ts";
2
+ /** Debug builds install next to the release app: an id suffix like ".debug" and a name suffix like " Dev", per platform. */
3
+ export declare function checkDebugSuffixes(raw: AkanNativeConfig, problems: string[]): void;
@@ -149,6 +149,10 @@ export interface BuildContext {
149
149
  /** iPhone builds: the identity and profile they were signed with. */
150
150
  iosSigning?: IosSigningResult;
151
151
  }
152
+ /** The bundle id: app.id, plus ios.debugAppIdSuffix in debug builds so they install next to the App Store app. */
153
+ export declare function iosAppId(ctx: BuildContext): string;
154
+ /** The home-screen name: app.name, plus the platform's debugAppNameSuffix in debug builds. */
155
+ export declare function nativeAppName(ctx: BuildContext, platform: "ios" | "android"): string;
152
156
  /** A dev start path: a path on the app's origin, not one of akan-native's (/__akan_native/*). */
153
157
  export declare function checkStartPath(path: string): string;
154
158
  /** The app's own web build failed (AkanNativeError WEB_BUILD_FAILED). */
@@ -236,6 +236,8 @@ export interface AkanNativeConfig {
236
236
  * release app. Deep links and app links must list the suffixed id for debug builds.
237
237
  */
238
238
  debugAppIdSuffix?: string;
239
+ /** Appended to app.name in debug builds (e.g. " Dev"), so the launcher tells a debug build from the release app. */
240
+ debugAppNameSuffix?: string;
239
241
  /**
240
242
  * The Firebase project's google-services.json (relative to the app folder), for the push plugin's
241
243
  * FCM module: its values become the string resources Firebase initializes from, as the
@@ -270,6 +272,13 @@ export interface AkanNativeConfig {
270
272
  ios?: {
271
273
  /** Hide the bar with previous / next / Done above the keyboard for form fields. Default false. */
272
274
  hideFormAccessoryBar?: boolean;
275
+ /**
276
+ * Appended to app.id in debug builds (e.g. ".debug"), so a debug build installs next to the
277
+ * App Store app instead of replacing it. A device build then signs with a profile for the suffixed id.
278
+ */
279
+ debugAppIdSuffix?: string;
280
+ /** Appended to app.name in debug builds (e.g. " Dev"), so the home screen tells a debug build from the App Store app. */
281
+ debugAppNameSuffix?: string;
273
282
  };
274
283
  desktop?: {
275
284
  /**
@@ -41,7 +41,13 @@ const KNOWN: Shape = {
41
41
  resources: { "[]": { from: true, to: true } },
42
42
  },
43
43
  security: { csp: true, shell: { externalSchemes: true } },
44
- android: { minWebViewVersion: true, debugAppIdSuffix: true, googleServices: true, autoplay: true },
44
+ android: {
45
+ minWebViewVersion: true,
46
+ debugAppIdSuffix: true,
47
+ debugAppNameSuffix: true,
48
+ googleServices: true,
49
+ autoplay: true,
50
+ },
45
51
  desktop: {
46
52
  quitOnLastWindowClosed: true,
47
53
  recovery: true,
@@ -65,7 +71,7 @@ const KNOWN: Shape = {
65
71
  push: {
66
72
  android: { channel: { id: true, name: true, importance: true, description: true }, smallIcon: true, color: true },
67
73
  },
68
- ios: { hideFormAccessoryBar: true },
74
+ ios: { hideFormAccessoryBar: true, debugAppIdSuffix: true, debugAppNameSuffix: true },
69
75
  icon: { image: true, backgroundColor: true },
70
76
  splash: { backgroundColor: { light: true, dark: true }, image: true, autoHide: true, timeout: true },
71
77
  };
@@ -0,0 +1,18 @@
1
+ import type { AkanNativeConfig } from "../config.ts";
2
+
3
+ /** Debug builds install next to the release app: an id suffix like ".debug" and a name suffix like " Dev", per platform. */
4
+ export function checkDebugSuffixes(raw: AkanNativeConfig, problems: string[]): void {
5
+ for (const platform of ["android", "ios"] as const) {
6
+ const idSuffix = raw[platform]?.debugAppIdSuffix;
7
+ if (idSuffix !== undefined && (typeof idSuffix !== "string" || !/^(\.[a-zA-Z][a-zA-Z0-9_]*)+$/.test(idSuffix)))
8
+ problems.push(`${platform}.debugAppIdSuffix must look like ".debug" (got ${JSON.stringify(idSuffix)})`);
9
+ const nameSuffix = raw[platform]?.debugAppNameSuffix;
10
+ if (
11
+ nameSuffix !== undefined &&
12
+ (typeof nameSuffix !== "string" ||
13
+ nameSuffix.length > 24 ||
14
+ !/^ ?[\p{L}\p{N}()_-]+( [\p{L}\p{N}()_-]+)*$/u.test(nameSuffix))
15
+ )
16
+ problems.push(`${platform}.debugAppNameSuffix must look like " Dev" (got ${JSON.stringify(nameSuffix)})`);
17
+ }
18
+ }
@@ -176,6 +176,18 @@ export interface BuildContext {
176
176
  iosSigning?: IosSigningResult;
177
177
  }
178
178
 
179
+ /** The bundle id: app.id, plus ios.debugAppIdSuffix in debug builds so they install next to the App Store app. */
180
+ export function iosAppId(ctx: BuildContext): string {
181
+ const { app, ios } = ctx.project.config;
182
+ return app.id + (ctx.dev ? (ios?.debugAppIdSuffix ?? "") : "");
183
+ }
184
+
185
+ /** The home-screen name: app.name, plus the platform's debugAppNameSuffix in debug builds. */
186
+ export function nativeAppName(ctx: BuildContext, platform: "ios" | "android"): string {
187
+ const { config } = ctx.project;
188
+ return config.app.name + (ctx.dev ? (config[platform]?.debugAppNameSuffix ?? "") : "");
189
+ }
190
+
179
191
  /** A dev start path: a path on the app's origin, not one of akan-native's (/__akan_native/*). */
180
192
  export function checkStartPath(path: string): string {
181
193
  if (!path.startsWith("/") || path.startsWith("//") || /^\/__akan_native(\/|$|\?)/.test(path) || /\s/.test(path)) {
@@ -7,6 +7,7 @@ import type { AkanNativeConfig } from "../config.ts";
7
7
  import { manifestPermissionProblems, type PermissionSet, resolveAcl } from "./acl.ts";
8
8
  import { unknownConfigKeys } from "./configkeys.ts";
9
9
  import { validateCsp, validateExternalSchemes } from "./csp.ts";
10
+ import { checkDebugSuffixes } from "./debugsuffix.ts";
10
11
  import { type DesktopServerConfig, validateDesktopServer } from "./desktop-server.ts";
11
12
  import { type ResolvedDmg, validateDmg } from "./dmg.ts";
12
13
  import { type EnvConfig, validateEnvConfig } from "./env.ts";
@@ -178,10 +179,6 @@ export function projectFromConfig(raw: AkanNativeConfig, appDir: string, options
178
179
  checkIconAndSplash(raw, appDir, problems);
179
180
  checkPrivacy(raw.privacy, problems);
180
181
  checkNative(raw, appDir, problems);
181
- const suffix = raw.android?.debugAppIdSuffix;
182
- if (suffix !== undefined && (typeof suffix !== "string" || !/^(\.[a-zA-Z][a-zA-Z0-9_]*)+$/.test(suffix))) {
183
- problems.push(`android.debugAppIdSuffix must look like ".debug" (got ${JSON.stringify(suffix)})`);
184
- }
185
182
  if (raw.app?.build !== undefined && raw.app.build > 2_100_000_000)
186
183
  problems.push("app.build must be at most 2100000000 (Android versionCode)");
187
184
  const googleServices = raw.android?.googleServices;
@@ -714,6 +711,7 @@ const HOST = /^(?=.{1,253}$)([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,63}$/
714
711
 
715
712
  /** deepLinks.domains, native.ios, native.android and native.resources (akanjs readiness O5). */
716
713
  function checkNative(raw: AkanNativeConfig, appDir: string, problems: string[]): void {
714
+ checkDebugSuffixes(raw, problems);
717
715
  for (const domain of raw.deepLinks?.domains ?? []) {
718
716
  const host = typeof domain === "string" ? domain : domain?.host;
719
717
  if (typeof host !== "string" || !HOST.test(host))
@@ -60,7 +60,7 @@ import {
60
60
  writePluginBindings,
61
61
  } from "../lib/native-plugins.ts";
62
62
  import { androidFeaturesFor, androidPermissionsFor } from "../lib/permissions.ts";
63
- import { type AndroidSigning, type BuildContext, SigningError } from "../lib/prepare.ts";
63
+ import { type AndroidSigning, type BuildContext, nativeAppName, SigningError } from "../lib/prepare.ts";
64
64
  import type { AndroidManifest, ResolvedConfig } from "../lib/project.ts";
65
65
  import { PACKAGE_ROOT } from "../lib/root.ts";
66
66
  import { writePhoneUpdates } from "../lib/updates.ts";
@@ -180,7 +180,7 @@ ${manifestXml.map((x) => ` ${x.replaceAll(`\${applicationId}`, appId)}`).join
180
180
 
181
181
  <application
182
182
  android:name="com.akanjs.runtime.AkanNativeApplication"
183
- android:label="${xml(app.name)}"
183
+ android:label="${xml(nativeAppName(ctx, "android"))}"
184
184
  ${icon ? ` android:icon="@mipmap/ic_launcher"\n` : ""}${ctx.dev ? ` android:networkSecurityConfig="@xml/akan_native_network_security"\n` : ""} android:theme="@style/AkanNativeTheme"
185
185
  android:allowBackup="false"
186
186
  android:supportsRtl="true"
@@ -48,7 +48,7 @@ import {
48
48
  } from "../lib/native-plugins.ts";
49
49
  import { permissionPlist } from "../lib/permissions.ts";
50
50
  import { type PlistValue, toPlist } from "../lib/plist.ts";
51
- import { type BuildContext, SigningError } from "../lib/prepare.ts";
51
+ import { type BuildContext, iosAppId, nativeAppName, SigningError } from "../lib/prepare.ts";
52
52
  import { privacyApiProblems, privacyManifest } from "../lib/privacy.ts";
53
53
  import type { IosManifest } from "../lib/project.ts";
54
54
  import { PACKAGE_ROOT } from "../lib/root.ts";
@@ -123,7 +123,7 @@ export async function buildIos(ctx: BuildContext): Promise<string> {
123
123
  const entitlements = join(gen, "Entitlements.plist");
124
124
  writeFileSync(
125
125
  entitlements,
126
- toPlist(iosEntitlements(config.app.id, plugins, config.deepLinks.domains, config.native?.ios?.entitlements)),
126
+ toPlist(iosEntitlements(iosAppId(ctx), plugins, config.deepLinks.domains, config.native?.ios?.entitlements)),
127
127
  );
128
128
 
129
129
  const shellSources = [...new Bun.Glob("*.swift").scanSync({ cwd: SHELL_SRC, absolute: true })].sort();
@@ -222,9 +222,9 @@ export async function buildIos(ctx: BuildContext): Promise<string> {
222
222
  const base: Record<string, PlistValue> = {
223
223
  CFBundleDevelopmentRegion: "en",
224
224
  CFBundleExecutable: module,
225
- CFBundleIdentifier: config.app.id,
225
+ CFBundleIdentifier: iosAppId(ctx),
226
226
  CFBundleName: module,
227
- CFBundleDisplayName: config.app.name,
227
+ CFBundleDisplayName: nativeAppName(ctx, "ios"),
228
228
  CFBundleInfoDictionaryVersion: "6.0",
229
229
  CFBundlePackageType: "APPL",
230
230
  CFBundleShortVersionString: config.app.version,
@@ -255,7 +255,7 @@ export async function buildIos(ctx: BuildContext): Promise<string> {
255
255
  ],
256
256
  UIViewControllerBasedStatusBarAppearance: true,
257
257
  ...(config.deepLinks.schemes.length
258
- ? { CFBundleURLTypes: [{ CFBundleURLName: config.app.id, CFBundleURLSchemes: config.deepLinks.schemes }] }
258
+ ? { CFBundleURLTypes: [{ CFBundleURLName: iosAppId(ctx), CFBundleURLSchemes: config.deepLinks.schemes }] }
259
259
  : {}),
260
260
  ...assets.infoPlist, // CFBundleIcons from actool
261
261
 
@@ -336,7 +336,7 @@ async function signForDevice(
336
336
  const entitlementsFor = (profile: ProvisioningProfile): Record<string, PlistValue> => {
337
337
  const requested: Record<string, PlistValue> = {
338
338
  ...iosEntitlements(
339
- config.app.id,
339
+ iosAppId(ctx),
340
340
  plugins,
341
341
  config.deepLinks.domains,
342
342
  config.native?.ios?.entitlements,
@@ -355,7 +355,7 @@ async function signForDevice(
355
355
  await signingIdentities(),
356
356
  profilePath ? [await readProfile(profilePath)] : await localProfiles(),
357
357
  {
358
- bundleId: config.app.id,
358
+ bundleId: iosAppId(ctx),
359
359
  kinds,
360
360
  identityKind: release ? "distribution" : "development",
361
361
  teamId: signing?.teamId ?? env.AKAN_NATIVE_IOS_TEAM,
@@ -669,7 +669,7 @@ async function launchOnDevice(
669
669
  throw new CliError(
670
670
  `${device.name} is not reachable: connect it with a cable or put it on the same network, and unlock it`,
671
671
  );
672
- const appId = ctx.project.config.app.id;
672
+ const appId = iosAppId(ctx);
673
673
  log.step(`install on ${device.name} (iOS ${device.os})`);
674
674
  await execOrThrow(["xcrun", "devicectl", "device", "install", "app", "--device", device.id, appPath], {
675
675
  echo: false,
@@ -724,7 +724,7 @@ export async function launchIos(
724
724
  }
725
725
  const sim = await ensureSimulator(opts.device, opts.headless);
726
726
  const udid = sim.udid;
727
- const appId = ctx.project.config.app.id;
727
+ const appId = iosAppId(ctx);
728
728
  log.step(`install on ${udid}`);
729
729
  await execOrThrow(["xcrun", "simctl", "install", udid, appPath], { echo: false });
730
730
 
@@ -758,7 +758,7 @@ export async function runIos(ctx: BuildContext, appPath: string, args: ParsedArg
758
758
  headless: args.flags.headless === true,
759
759
  device: typeof args.flags.device === "string" ? args.flags.device : undefined,
760
760
  });
761
- log.ok(`launched ${ctx.project.config.app.id}, logs below. Ctrl+C to stop.`);
761
+ log.ok(`launched ${iosAppId(ctx)}, logs below. Ctrl+C to stop.`);
762
762
  return follow(app);
763
763
  }
764
764