@blotch/angular-lynx-native 22.2.25 → 22.2.27

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 (62) hide show
  1. package/README.md +15 -11
  2. package/dist/android/project.d.ts +13 -1
  3. package/dist/android/project.d.ts.map +1 -1
  4. package/dist/android/project.js +40 -11
  5. package/dist/app-links.d.ts +53 -0
  6. package/dist/app-links.d.ts.map +1 -0
  7. package/dist/app-links.js +115 -0
  8. package/dist/generate.d.ts +1 -1
  9. package/dist/generate.js +8 -2
  10. package/dist/index.d.ts +3 -1
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +23 -0
  13. package/dist/ios/build.d.ts.map +1 -1
  14. package/dist/ios/build.js +5 -0
  15. package/dist/ios/project.d.ts +16 -2
  16. package/dist/ios/project.d.ts.map +1 -1
  17. package/dist/ios/project.js +57 -6
  18. package/dist/options.d.ts +68 -1
  19. package/dist/options.d.ts.map +1 -1
  20. package/dist/options.js +70 -0
  21. package/dist/permissions.d.ts.map +1 -1
  22. package/dist/permissions.js +7 -0
  23. package/dist/png.d.ts +5 -0
  24. package/dist/png.d.ts.map +1 -1
  25. package/dist/png.js +19 -5
  26. package/dist/splash.d.ts +70 -0
  27. package/dist/splash.d.ts.map +1 -0
  28. package/dist/splash.js +239 -0
  29. package/package.json +1 -1
  30. package/templates/android/README.md +11 -2
  31. package/templates/android/app/build.gradle.kts +19 -9
  32. package/templates/android/app/proguard-rules.pro +67 -55
  33. package/templates/android/app/src/debug/java/dev/angularlynx/shell/DevServer.kt +6 -0
  34. package/templates/android/app/src/main/AndroidManifest.xml +3 -1
  35. package/templates/android/app/src/main/java/dev/angularlynx/shell/AssetsModule.kt +2 -1
  36. package/templates/android/app/src/main/java/dev/angularlynx/shell/CanvasUI.kt +16 -3
  37. package/templates/android/app/src/main/java/dev/angularlynx/shell/LinkingModule.kt +42 -0
  38. package/templates/android/app/src/main/java/dev/angularlynx/shell/MainActivity.kt +96 -7
  39. package/templates/android/app/src/main/java/dev/angularlynx/shell/ShellApplication.kt +15 -0
  40. package/templates/android/app/src/main/java/dev/angularlynx/shell/ShellModule.kt +24 -0
  41. package/templates/android/app/src/main/java/dev/angularlynx/shell/WebGLContext.kt +15 -4
  42. package/templates/android/app/src/main/java/dev/angularlynx/shell/WebGLModule.kt +10 -1
  43. package/templates/android/app/src/main/res/values/colors.xml +3 -2
  44. package/templates/android/app/src/main/res/values/splash.xml +9 -0
  45. package/templates/android/app/src/main/res/values/themes.xml +14 -0
  46. package/templates/android/app/src/release/java/dev/angularlynx/shell/DevServer.kt +2 -0
  47. package/templates/android/build.gradle.kts +1 -1
  48. package/templates/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  49. package/templates/android/gradle/wrapper/gradle-wrapper.properties +2 -2
  50. package/templates/android/gradlew.bat +41 -11
  51. package/templates/ios/App/AngularLynxWebGL.h +34 -6
  52. package/templates/ios/App/AngularLynxWebGL.m +58 -23
  53. package/templates/ios/App/AngularLynxWebGLContext.m +104 -26
  54. package/templates/ios/App/AnimationFrameRate.swift +214 -0
  55. package/templates/ios/App/AppDelegate.swift +48 -0
  56. package/templates/ios/App/AssetsModule.swift +3 -1
  57. package/templates/ios/App/DevServer.swift +3 -0
  58. package/templates/ios/App/Info.plist +12 -5
  59. package/templates/ios/App/LinkingModule.swift +62 -1
  60. package/templates/ios/App/LynxViewController.swift +30 -6
  61. package/templates/ios/App/ShellModule.swift +40 -1
  62. package/templates/ios/App/SplashScreen.swift +71 -0
@@ -3,6 +3,7 @@ import path from 'node:path';
3
3
  import { readPngSize } from "../png.js";
4
4
  import { APP_NAME_PLACEHOLDER, shortcutIdentifier, } from "../options.js";
5
5
  import { PERMISSION_MAP } from "../permissions.js";
6
+ import { IOS_IMAGE_SET, writeIosSplash } from "../splash.js";
6
7
  import { escapeXml, replaceMarker } from "../xml.js";
7
8
  const ORIENTATIONS = {
8
9
  portrait: ['UIInterfaceOrientationPortrait'],
@@ -19,8 +20,10 @@ const ORIENTATIONS = {
19
20
  /**
20
21
  * Writes the app options into the iOS template: build settings go in
21
22
  * Config/App.xcconfig (which App.xcodeproj reads), Info.plist entries go
22
- * between the template's `angular-lynx:info` markers, and the shortcuts
23
- * become App/AppShortcuts.swift.
23
+ * between the template's `angular-lynx:info` markers, the shortcuts
24
+ * become App/AppShortcuts.swift, the app link domains become
25
+ * Config/App.entitlements, and the icon and the splash go in the asset
26
+ * catalog.
24
27
  */
25
28
  export const iosGenerator = {
26
29
  configure: (dir, app, projectRoot, development = false) => {
@@ -32,6 +35,13 @@ export const iosGenerator = {
32
35
  if (app.shortcuts.length > 0) {
33
36
  writeFileSync(path.join(dir, 'App/AppShortcuts.swift'), appShortcutsSwift(app));
34
37
  }
38
+ // In Config/, beside the xcconfig that points the target at it, rather
39
+ // than in App/: Xcode would copy a file in that synchronized folder into
40
+ // the app as a resource. An app without app links signs with no
41
+ // entitlements, as the template does.
42
+ if (app.appLinkDomains.length > 0) {
43
+ writeFileSync(path.join(dir, ENTITLEMENTS), entitlementsPlist(app));
44
+ }
35
45
  if (app.icon) {
36
46
  const icon = path.resolve(projectRoot, app.icon);
37
47
  const size = readPngSize(icon);
@@ -40,9 +50,12 @@ export const iosGenerator = {
40
50
  }
41
51
  copyFileSync(icon, path.join(dir, 'App/Assets.xcassets/AppIcon.appiconset/AppIcon.png'));
42
52
  }
53
+ writeIosSplash(dir, app, projectRoot);
43
54
  },
44
55
  bundleDir: (dir) => path.join(dir, 'LynxBundle'),
45
56
  };
57
+ /** The app's entitlements, from the project folder (see xcconfig). */
58
+ const ENTITLEMENTS = 'Config/App.entitlements';
46
59
  /**
47
60
  * xcconfig values can't be quoted; `$` and `//` would start a variable or a comment.
48
61
  */
@@ -57,6 +70,35 @@ export const xcconfig = (app) => [
57
70
  `MARKETING_VERSION = ${app.version}`,
58
71
  `CURRENT_PROJECT_VERSION = ${app.buildNumber}`,
59
72
  `DEVELOPMENT_TEAM = ${app.ios.teamId ?? ''}`,
73
+ // Only with app links: the only entitlement the generator writes.
74
+ ...(app.appLinkDomains.length > 0
75
+ ? [`CODE_SIGN_ENTITLEMENTS = ${ENTITLEMENTS}`]
76
+ : []),
77
+ '',
78
+ ].join('\n');
79
+ /**
80
+ * Config/App.entitlements: the Associated Domains entitlement, which has iOS
81
+ * open the app for an https link to one of the domains (a Universal Link),
82
+ * once the domain's apple-app-site-association names the app (see
83
+ * appLinkFiles). iOS fetches that file through Apple's CDN when the app is
84
+ * installed.
85
+ *
86
+ * Signing it needs a team in the paid Apple Developer Program: a free
87
+ * Personal Team can't sign Associated Domains. The simulator app needs no
88
+ * team.
89
+ */
90
+ export const entitlementsPlist = (app) => [
91
+ '<?xml version="1.0" encoding="UTF-8"?>',
92
+ '<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">',
93
+ '<!-- Written by @blotch/angular-lynx-native from appLinkDomains in angular.json. -->',
94
+ '<plist version="1.0">',
95
+ '<dict>',
96
+ '\t<key>com.apple.developer.associated-domains</key>',
97
+ '\t<array>',
98
+ ...app.appLinkDomains.map((domain) => `\t\t<string>applinks:${escapeXml(domain)}</string>`),
99
+ '\t</array>',
100
+ '</dict>',
101
+ '</plist>',
60
102
  '',
61
103
  ].join('\n');
62
104
  /** What iOS shows the first time someone taps Save Image, without `savePhotos`. */
@@ -73,6 +115,13 @@ export const infoPlistEntries = (app, { development = false } = {}) => {
73
115
  values.forEach((value) => lines.push(`\t<string>${escapeXml(value)}</string>`));
74
116
  lines.push('</array>');
75
117
  };
118
+ // The launch screen: angular.json's splash, its color (LaunchBackground,
119
+ // white by default) and its image, if it has one, centered on the whole
120
+ // screen. LynxViewController draws the same over the app until the app
121
+ // hides it (SplashScreen.swift).
122
+ lines.push('<key>UILaunchScreen</key>', '<dict>', '\t<key>UIColorName</key>', '\t<string>LaunchBackground</string>', ...(app.splash.light.image
123
+ ? ['\t<key>UIImageName</key>', `\t<string>${IOS_IMAGE_SET}</string>`]
124
+ : []), '</dict>');
76
125
  array('UISupportedInterfaceOrientations', ORIENTATIONS[app.orientation]);
77
126
  // Read by LynxViewController, which lays the LynxView out over the whole
78
127
  // screen or inside the safe area.
@@ -93,10 +142,12 @@ export const infoPlistEntries = (app, { development = false } = {}) => {
93
142
  // `ng serve --platform ios`'s development app loads from the dev server at
94
143
  // the Mac's address on the local network, which iOS (14 and later) lets an
95
144
  // app reach only once the person allows it. iOS asks the first time, with
96
- // this reason. Only the development app has it: the app for the stores
97
- // loads its own bundle, and App Review asks about any reason it doesn't
98
- // need.
99
- if (development) {
145
+ // this reason. Only the development app has it, unless the app asks for
146
+ // `localNetwork` itself: the app for the stores loads its own bundle, and
147
+ // App Review asks about any reason it doesn't need.
148
+ // An app that asks for `localNetwork` already has the key, with its own
149
+ // reason, which also covers the dev server.
150
+ if (development && !app.permissions.localNetwork) {
100
151
  lines.push('<key>NSLocalNetworkUsageDescription</key>', `<string>${escapeXml(LOCAL_NETWORK_REASON)}</string>`);
101
152
  }
102
153
  // The schemes LinkingModule's canOpenURL can ask about: iOS answers false
package/dist/options.d.ts CHANGED
@@ -30,6 +30,14 @@ export type NativeAppOptions = {
30
30
  readonly permissions?: Partial<Record<Permission, string>>;
31
31
  /** Custom URL schemes that open the app, e.g. `["myapp"]`. */
32
32
  readonly deepLinkSchemes?: readonly string[];
33
+ /**
34
+ * The app's own websites, whose https links open the app rather than the
35
+ * browser, e.g. `["example.com", "*.example.com"]`: Universal Links on iOS
36
+ * (the Associated Domains entitlement) and App Links on Android (a
37
+ * verified intent filter). Each site has to serve the file that names the
38
+ * app, which the build writes beside the app (see `appLinkFiles`).
39
+ */
40
+ readonly appLinkDomains?: readonly string[];
33
41
  /**
34
42
  * Other apps' URL schemes `LynxLinking.canOpenURL()` can ask about, e.g.
35
43
  * `["whatsapp", "instagram"]`. iOS answers only for the schemes in
@@ -52,9 +60,65 @@ export type NativeAppOptions = {
52
60
  * {@link AndroidOptions.adaptiveIcon}).
53
61
  */
54
62
  readonly icon?: string;
63
+ /**
64
+ * What the phone shows from the tap on the app's icon until the app's
65
+ * first screen is drawn (see {@link SplashOptions}).
66
+ */
67
+ readonly splash?: SplashOptions;
55
68
  readonly ios?: IosOptions;
56
69
  readonly android?: AndroidOptions;
57
70
  };
71
+ /**
72
+ * The launch screen: an image centered on a color, from the tap on the app's
73
+ * icon until the app hides it (the runtime's `provideSplashScreen()`), or
74
+ * until Angular first draws, without that.
75
+ *
76
+ * iOS shows it as the launch screen (`UILaunchScreen`), and the shell keeps a
77
+ * copy of it over the app until then. Android shows it as the splash screen,
78
+ * through AndroidX's `core-splashscreen`, which gives Android 7 to 11 the
79
+ * same splash as 12 and later.
80
+ */
81
+ export type SplashOptions = {
82
+ /**
83
+ * A PNG with transparency, relative to the project root, drawn centered.
84
+ * Without one, iOS shows the color alone, and Android the launcher icon,
85
+ * as Android 12 does by default.
86
+ */
87
+ readonly image?: string;
88
+ /**
89
+ * The image's width on screen, in points and dp; its height follows from
90
+ * its shape. Needed with `image`. Give the PNG at least three times this
91
+ * many pixels across, for the sharpest iPhones.
92
+ *
93
+ * Android shows a splash image inside a circle 192 dp across, so an image
94
+ * whose corners reach past it is drawn smaller there, with a build warning.
95
+ */
96
+ readonly imageWidth?: number;
97
+ /**
98
+ * The color behind the image, which the shells also paint behind the app
99
+ * (`#RRGGBB` or `#RGB`). Defaults to white, and on Android, to black in
100
+ * dark mode.
101
+ */
102
+ readonly backgroundColor?: string;
103
+ /** The image and the color in dark mode. Each defaults to the light one. */
104
+ readonly dark?: {
105
+ readonly image?: string;
106
+ readonly backgroundColor?: string;
107
+ };
108
+ };
109
+ /** The splash's image and color in one appearance, light or dark. */
110
+ export type SplashAppearance = {
111
+ readonly image?: string;
112
+ /** Undefined keeps the shell's own color. */
113
+ readonly backgroundColor?: string;
114
+ };
115
+ /** {@link SplashOptions} checked, with the dark values filled in. */
116
+ export type ResolvedSplash = {
117
+ /** Set when either appearance has an image. */
118
+ readonly imageWidth?: number;
119
+ readonly light: SplashAppearance;
120
+ readonly dark: SplashAppearance;
121
+ };
58
122
  export type Orientation = 'portrait' | 'landscape' | 'all';
59
123
  /**
60
124
  * One thing the app does, which the person can ask for without opening the
@@ -105,7 +169,7 @@ export type ResolvedShortcut = {
105
169
  };
106
170
  /** Where a shortcut's phrase names the app. */
107
171
  export declare const APP_NAME_PLACEHOLDER = "{appName}";
108
- export type Permission = 'camera' | 'microphone' | 'location' | 'photos' | 'savePhotos' | 'contacts' | 'notifications';
172
+ export type Permission = 'camera' | 'microphone' | 'location' | 'photos' | 'savePhotos' | 'contacts' | 'notifications' | 'localNetwork';
109
173
  /**
110
174
  * How the `.ipa` is signed, as Xcode's export methods name it:
111
175
  * `app-store-connect` for App Store Connect and TestFlight, and
@@ -177,6 +241,8 @@ export type ResolvedApp = {
177
241
  readonly edgeToEdge: boolean;
178
242
  readonly permissions: Partial<Record<Permission, string>>;
179
243
  readonly deepLinkSchemes: readonly string[];
244
+ /** {@link NativeAppOptions.appLinkDomains} in lowercase, each once. */
245
+ readonly appLinkDomains: readonly string[];
180
246
  /**
181
247
  * {@link NativeAppOptions.canOpenURLSchemes} after
182
248
  * {@link ALWAYS_QUERIED_SCHEMES}, in lowercase, each once.
@@ -184,6 +250,7 @@ export type ResolvedApp = {
184
250
  readonly canOpenURLSchemes: readonly string[];
185
251
  readonly shortcuts: readonly ResolvedShortcut[];
186
252
  readonly icon?: string;
253
+ readonly splash: ResolvedSplash;
187
254
  /** `MyApp`: the iOS product (and so .app/.ipa) name. */
188
255
  readonly productName: string;
189
256
  /** `my-app`: the base name of Android artifacts. */
@@ -1 +1 @@
1
- {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,6DAA6D;IAC7D,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,yEAAyE;IACzE,QAAQ,CAAC,KAAK,CAAC,EA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EAAuE;IACvE,QAAQ,CAAC,cAAc,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3C;;;OAGG;IACH,QAAQ,CAAC,iBAAiB,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9C,QAAQ,CAAC,SAAS,EAAE,SAAS,gBAAgB,EAAE,CAAC;IAChD,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,wDAAwD;IACxD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,oDAAoD;IACpD,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;CAClC,CAAC;AAEF,qBAAa,iBAAkB,SAAQ,KAAK;CAAG;AAmB/C;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,QAAuC,CAAC;AAG1E;;;GAGG;AACH,eAAO,MAAM,sBAAsB,EAAE,SAAS,MAAM,EAMnD,CAAC;AAiCF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAC5B,YAAY,gBAAgB,EAC5B,UAAU;IAAE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAA;CAAE,KAC3E,WAoKF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,kBAAkB,GAAI,IAAI,MAAM,KAAG,MAA+B,CAAC;AA6KhF;;;;;;GAMG;AACH,eAAO,MAAM,OAAO,GAAI,OAAO,OAAO,KAAG,OAWxC,CAAC"}
package/dist/options.js CHANGED
@@ -15,6 +15,13 @@ const APP_ID = /^[A-Za-z][A-Za-z0-9]*(\.[A-Za-z][A-Za-z0-9]*)+$/;
15
15
  /** Up to three period-separated integers, as App Store Connect requires. */
16
16
  const VERSION = /^\d+(\.\d+){0,2}$/;
17
17
  const SCHEME = /^[A-Za-z][A-Za-z0-9+.-]*$/;
18
+ /**
19
+ * A host name of two labels or more, optionally after `*.` for its
20
+ * subdomains, as both the `applinks:` entitlement and an intent filter's
21
+ * `android:host` take it. No scheme, port or path: iOS takes a port only in
22
+ * its developer mode, and the site's file chooses the paths.
23
+ */
24
+ const APP_LINK_DOMAIN = /^(\*\.)?([a-z0-9]([a-z0-9-]*[a-z0-9])?\.)+[a-z]([a-z0-9-]*[a-z0-9])?$/;
18
25
  /**
19
26
  * The colors both CSS and Android resources read the same way. Android also
20
27
  * takes `#ARGB` and `#AARRGGBB`, but CSS reads 4 and 8 digits with the alpha
@@ -62,6 +69,7 @@ const PERMISSIONS = [
62
69
  'savePhotos',
63
70
  'contacts',
64
71
  'notifications',
72
+ 'localNetwork',
65
73
  ];
66
74
  /**
67
75
  * Applies defaults and validates the options, so the generators never see a
@@ -108,6 +116,16 @@ export const resolveAppOptions = (rawOptions, defaults) => {
108
116
  throw new NativeConfigError(`deepLinkSchemes entry "${scheme}" is not a valid URL scheme.`);
109
117
  }
110
118
  }
119
+ // Host names are case-insensitive, so "Example.com" and "example.com" are
120
+ // one.
121
+ const appLinkDomains = [
122
+ ...new Set((options.appLinkDomains ?? []).map((domain) => domain.toLowerCase())),
123
+ ];
124
+ for (const domain of appLinkDomains) {
125
+ if (!APP_LINK_DOMAIN.test(domain)) {
126
+ throw new NativeConfigError(`appLinkDomains entry "${domain}" is not a domain. Give the host name alone, without https:// or a path, e.g. "example.com", or "*.example.com" for its subdomains.`);
127
+ }
128
+ }
111
129
  const userQueriedSchemes = options.canOpenURLSchemes ?? [];
112
130
  for (const scheme of userQueriedSchemes) {
113
131
  if (!SCHEME.test(scheme)) {
@@ -122,6 +140,7 @@ export const resolveAppOptions = (rawOptions, defaults) => {
122
140
  throw new NativeConfigError(`canOpenURLSchemes lists ${canOpenURLSchemes.length} schemes with the ${ALWAYS_QUERIED_SCHEMES.length} always there (${ALWAYS_QUERIED_SCHEMES.join(', ')}). iOS reads no more than ${MAX_QUERIED_SCHEMES}.`);
123
141
  }
124
142
  const shortcuts = resolveShortcuts(options.shortcuts ?? []);
143
+ const splash = resolveSplash(options.splash ?? {});
125
144
  const android = options.android ?? {};
126
145
  if (android.adaptiveIcon) {
127
146
  const { foreground, background } = android.adaptiveIcon;
@@ -157,9 +176,11 @@ export const resolveAppOptions = (rawOptions, defaults) => {
157
176
  edgeToEdge: options.edgeToEdge ?? true,
158
177
  permissions,
159
178
  deepLinkSchemes,
179
+ appLinkDomains,
160
180
  canOpenURLSchemes,
161
181
  shortcuts,
162
182
  icon: options.icon,
183
+ splash,
163
184
  productName,
164
185
  artifactName,
165
186
  ios: options.ios ?? {},
@@ -236,6 +257,55 @@ const resolveShortcuts = (shortcuts) => {
236
257
  };
237
258
  });
238
259
  };
260
+ /**
261
+ * Checks the splash options, and gives dark mode the light values it doesn't
262
+ * set. The images themselves are read when the project is generated.
263
+ */
264
+ const resolveSplash = (splash) => {
265
+ const { image, imageWidth, backgroundColor } = splash;
266
+ const dark = splash.dark ?? {};
267
+ for (const [option, file] of [
268
+ ['splash.image', image],
269
+ ['splash.dark.image', dark.image],
270
+ ]) {
271
+ if (file !== undefined &&
272
+ (typeof file !== 'string' || !file.toLowerCase().endsWith('.png'))) {
273
+ throw new NativeConfigError(`${option} "${file}" is not a PNG file. Give the path of a PNG with transparency, relative to the project root.`);
274
+ }
275
+ }
276
+ for (const [option, color] of [
277
+ ['splash.backgroundColor', backgroundColor],
278
+ ['splash.dark.backgroundColor', dark.backgroundColor],
279
+ ]) {
280
+ if (color !== undefined &&
281
+ (typeof color !== 'string' || !ICON_BACKGROUND_COLOR.test(color))) {
282
+ throw new NativeConfigError(`${option} "${color}" is not a color. Use #RRGGBB or #RGB, e.g. "#09090B".`);
283
+ }
284
+ }
285
+ // The dark image takes its size from imageWidth too, and a light mode
286
+ // without an image while dark mode has one would be a mistake.
287
+ if (dark.image !== undefined && image === undefined) {
288
+ throw new NativeConfigError('splash.dark.image needs splash.image too: dark mode has an image of its own only where light mode has one.');
289
+ }
290
+ if (image !== undefined) {
291
+ if (typeof imageWidth !== 'number' ||
292
+ !Number.isFinite(imageWidth) ||
293
+ imageWidth <= 0) {
294
+ throw new NativeConfigError(`splash.imageWidth ${imageWidth === undefined ? 'is missing' : `${imageWidth} is not valid`}. Give the image's width on screen in points and dp, e.g. 200: a phone's screen is about 400 across.`);
295
+ }
296
+ }
297
+ else if (imageWidth !== undefined) {
298
+ throw new NativeConfigError('splash.imageWidth needs splash.image: it sets how wide the image is drawn.');
299
+ }
300
+ return {
301
+ ...(image !== undefined && { imageWidth }),
302
+ light: { image, backgroundColor },
303
+ dark: {
304
+ image: dark.image ?? image,
305
+ backgroundColor: dark.backgroundColor ?? backgroundColor,
306
+ },
307
+ };
308
+ };
239
309
  /**
240
310
  * `my-app` → `myapp`: a project name as one app ID segment.
241
311
  */
@@ -1 +1 @@
1
- {"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../src/permissions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C;;;;GAIG;AACH,eAAO,MAAM,cAAc,EAAE,MAAM,CACjC,UAAU,EACV;IACE,QAAQ,CAAC,GAAG,EAAE,SAAS,MAAM,EAAE,CAAC;IAChC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC;;;;OAIG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC9C,CAuCF,CAAC"}
1
+ {"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../src/permissions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C;;;;GAIG;AACH,eAAO,MAAM,cAAc,EAAE,MAAM,CACjC,UAAU,EACV;IACE,QAAQ,CAAC,GAAG,EAAE,SAAS,MAAM,EAAE,CAAC;IAChC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC;;;;OAIG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC9C,CA8CF,CAAC"}
@@ -36,6 +36,13 @@ export const PERMISSION_MAP = {
36
36
  ios: ['NSContactsUsageDescription'],
37
37
  android: ['android.permission.READ_CONTACTS'],
38
38
  },
39
+ // Connecting to a device or server on the local network, such as a printer,
40
+ // a TV or a server on the Mac during development: iOS (14 and later) asks
41
+ // first, with this reason. Android needs no permission for it.
42
+ localNetwork: {
43
+ ios: ['NSLocalNetworkUsageDescription'],
44
+ android: [],
45
+ },
39
46
  // iOS asks for notification permission at runtime without a usage string.
40
47
  notifications: {
41
48
  ios: [],
package/dist/png.d.ts CHANGED
@@ -39,6 +39,11 @@ export declare const resize: (image: Image, width: number, height: number) => Im
39
39
  * continue the picture rather than show a frame of another color.
40
40
  */
41
41
  export declare const extendEdges: (image: Image, inset: number) => Image;
42
+ /**
43
+ * Puts the image in the middle of a transparent `width`×`height` canvas, at
44
+ * least as big as the image. An odd pixel of margin goes right and below.
45
+ */
46
+ export declare const centerOnCanvas: (image: Image, width: number, height: number) => Image;
42
47
  /**
43
48
  * Clears everything outside the largest circle that fits, with a one-pixel
44
49
  * soft edge so the circle isn't jagged: the round icon launchers on
package/dist/png.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"png.d.ts","sourceRoot":"","sources":["../src/png.ts"],"names":[],"mappings":"AAOA;;;;GAIG;AACH,eAAO,MAAM,WAAW,GACtB,MAAM,MAAM,KACX;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAiBnD,CAAC;AAYF,0EAA0E;AAC1E,MAAM,MAAM,KAAK,GAAG;IAClB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;CAC3B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AAM,cAAc,GACzB,OAAO,KAAK,EACZ,OAAO,MAAM,EACb,QAAQ,MAAM,KACb,KAYF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,UAAU,GAAI,OAAO,KAAK,KAAG,KAezC,CAAC"}
package/dist/png.js CHANGED
@@ -24,11 +24,11 @@ export const readPngSize = (file) => {
24
24
  return { width: header.readUInt32BE(16), height: header.readUInt32BE(20) };
25
25
  };
26
26
  /**
27
- * pngjs, loaded the first time an icon is resized rather than with this
28
- * module. Only Android needs it, and CI builds the iOS app from this
29
- * package's tarball unpacked without its dependencies (packages/e2e's
30
- * README), which works as long as the iOS path loads nothing but Node's
31
- * built-ins.
27
+ * pngjs, loaded the first time an image is resized rather than with this
28
+ * module. Only Android's icons and a splash image need it, and CI builds the
29
+ * iOS app, which has no splash image, from this package's tarball unpacked
30
+ * without its dependencies (packages/e2e's README), which works as long as
31
+ * that path loads nothing but Node's built-ins.
32
32
  */
33
33
  const pngjs = () => createRequire(import.meta.url)('pngjs').PNG;
34
34
  /**
@@ -171,6 +171,20 @@ export const extendEdges = (image, inset) => {
171
171
  }
172
172
  return { width, height, data };
173
173
  };
174
+ /**
175
+ * Puts the image in the middle of a transparent `width`×`height` canvas, at
176
+ * least as big as the image. An odd pixel of margin goes right and below.
177
+ */
178
+ export const centerOnCanvas = (image, width, height) => {
179
+ const data = new Uint8Array(width * height * 4);
180
+ const left = Math.floor((width - image.width) / 2);
181
+ const top = Math.floor((height - image.height) / 2);
182
+ for (let y = 0; y < image.height; y++) {
183
+ const row = y * image.width * 4;
184
+ data.set(image.data.subarray(row, row + image.width * 4), ((top + y) * width + left) * 4);
185
+ }
186
+ return { width, height, data };
187
+ };
174
188
  /**
175
189
  * Clears everything outside the largest circle that fits, with a one-pixel
176
190
  * soft edge so the circle isn't jagged: the round icon launchers on
@@ -0,0 +1,70 @@
1
+ import type { Platform } from './generate.ts';
2
+ import type { ResolvedApp, ResolvedSplash } from './options.ts';
3
+ /**
4
+ * Android's splash icon, without an icon background, is a 288 dp square...
5
+ */
6
+ export declare const ANDROID_SLOT_DP = 288;
7
+ /**
8
+ * ...of which it shows the middle: a circle 192 dp across, two thirds of it.
9
+ * Anything outside the circle is cut off.
10
+ */
11
+ export declare const ANDROID_CIRCLE_DP = 192;
12
+ /** Where the shells find the launch image, by name. */
13
+ export declare const IOS_IMAGE_SET = "LaunchImage";
14
+ type Size = {
15
+ readonly width: number;
16
+ readonly height: number;
17
+ };
18
+ /**
19
+ * The image's size on screen in points (dp on Android): `imageWidth` across,
20
+ * and as tall as its shape makes that.
21
+ */
22
+ export declare const splashImageSize: (pixels: Size, imageWidth: number) => Size;
23
+ /**
24
+ * The size Android draws the image at: as on iOS, unless its corners reach
25
+ * past the circle Android shows, when it's scaled down until they touch it.
26
+ * A wide logo is then smaller than on iOS, but whole.
27
+ */
28
+ export declare const androidSplashSize: (size: Size) => Size;
29
+ /**
30
+ * What's worth knowing about how the splash images will look, checked on
31
+ * every build (unlike the project, which is generated only when its inputs
32
+ * change): an image too wide for Android's circle, or with too few pixels to
33
+ * be sharp. A missing image is left to generation, which fails on it.
34
+ */
35
+ export declare const splashWarnings: (app: ResolvedApp, projectRoot: string, platform: Platform) => readonly string[];
36
+ /**
37
+ * The `LaunchBackground` color set: the launch screen's color, which the
38
+ * shell also paints behind the LynxView. Only its dark entry varies with dark
39
+ * mode: an entry without an appearance is the color for any.
40
+ */
41
+ export declare const launchBackgroundColorSet: (splash: ResolvedSplash) => string;
42
+ /** The image set's Contents.json, for the files {@link writeIosSplash} writes. */
43
+ export declare const launchImageSet: (hasDark: boolean) => string;
44
+ /**
45
+ * Writes the splash into the iOS project's asset catalog: the
46
+ * `LaunchBackground` color set, and the `LaunchImage` image set at 1×, 2× and
47
+ * 3× (and again for dark mode). Info.plist's UILaunchScreen names them (see
48
+ * `infoPlistEntries`), and the shell's SplashScreen.swift draws the same two
49
+ * over the app until the app hides it.
50
+ *
51
+ * Each scale is made here: a launch screen draws its image at its natural
52
+ * size, which is its pixels over its scale, so each copy is `imageWidth`
53
+ * points across.
54
+ */
55
+ export declare const writeIosSplash: (dir: string, app: ResolvedApp, projectRoot: string) => void;
56
+ /**
57
+ * Writes the splash into the Android project's resources: its colors as
58
+ * `window_background` (light in `values/`, dark in `values-night/`), which
59
+ * the splash theme and the window behind the LynxView both use, and its
60
+ * image as the `splash_icon` drawable the theme shows.
61
+ *
62
+ * Android shows a splash image in a 288 dp square, cut to the circle 192 dp
63
+ * across in its middle, and scales whatever drawable it's given to the
64
+ * square. So the image is drawn on a transparent 288 dp canvas, at
65
+ * `imageWidth` dp, or smaller if its corners would be cut off, and the canvas
66
+ * made at each density, as the icons are.
67
+ */
68
+ export declare const writeAndroidSplash: (dir: string, app: ResolvedApp, projectRoot: string) => void;
69
+ export {};
70
+ //# sourceMappingURL=splash.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"splash.d.ts","sourceRoot":"","sources":["../src/splash.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAUhE;;GAEG;AACH,eAAO,MAAM,eAAe,MAAM,CAAC;AACnC;;;GAGG;AACH,eAAO,MAAM,iBAAiB,MAAM,CAAC;AAIrC,uDAAuD;AACvD,eAAO,MAAM,aAAa,gBAAgB,CAAC;AAQ3C,KAAK,IAAI,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAEhE;;;GAGG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,IAAI,EAAE,YAAY,MAAM,KAAG,IAGjE,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAAI,MAAM,IAAI,KAAG,IAM9C,CAAC;AAgBF;;;;;GAKG;AACH,eAAO,MAAM,cAAc,GACzB,KAAK,WAAW,E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