@blotch/angular-lynx-native 22.2.19 → 22.2.21

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 (50) hide show
  1. package/README.md +4 -4
  2. package/dist/android/icon.d.ts +29 -0
  3. package/dist/android/icon.d.ts.map +1 -0
  4. package/dist/android/icon.js +142 -0
  5. package/dist/android/project.d.ts +2 -1
  6. package/dist/android/project.d.ts.map +1 -1
  7. package/dist/android/project.js +5 -2
  8. package/dist/generate.d.ts +2 -2
  9. package/dist/generate.d.ts.map +1 -1
  10. package/dist/generate.js +11 -4
  11. package/dist/index.d.ts +1 -1
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +12 -4
  14. package/dist/ios/build.d.ts +55 -12
  15. package/dist/ios/build.d.ts.map +1 -1
  16. package/dist/ios/build.js +203 -42
  17. package/dist/ios/iphone.d.ts +99 -0
  18. package/dist/ios/iphone.d.ts.map +1 -0
  19. package/dist/ios/iphone.js +204 -0
  20. package/dist/ios/project.d.ts +2 -0
  21. package/dist/ios/project.d.ts.map +1 -1
  22. package/dist/ios/project.js +10 -1
  23. package/dist/ios/run.d.ts +17 -2
  24. package/dist/ios/run.d.ts.map +1 -1
  25. package/dist/ios/run.js +30 -4
  26. package/dist/options.d.ts +49 -3
  27. package/dist/options.d.ts.map +1 -1
  28. package/dist/options.js +33 -1
  29. package/dist/permissions.d.ts.map +1 -1
  30. package/dist/permissions.js +6 -0
  31. package/dist/png.d.ts +38 -0
  32. package/dist/png.d.ts.map +1 -1
  33. package/dist/png.js +167 -0
  34. package/dist/run.d.ts +12 -4
  35. package/dist/run.d.ts.map +1 -1
  36. package/package.json +5 -1
  37. package/templates/android/README.md +5 -1
  38. package/templates/android/app/src/main/AndroidManifest.xml +16 -0
  39. package/templates/android/app/src/main/java/dev/angularlynx/shell/MainActivity.kt +16 -0
  40. package/templates/android/app/src/main/java/dev/angularlynx/shell/ShareModule.kt +274 -0
  41. package/templates/android/app/src/main/java/dev/angularlynx/shell/WebGLContext.kt +57 -0
  42. package/templates/android/app/src/main/java/dev/angularlynx/shell/WebGLModule.kt +95 -0
  43. package/templates/android/app/src/main/res/mipmap/ic_launcher_round.xml +6 -0
  44. package/templates/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +6 -0
  45. package/templates/android/app/src/main/res/xml/share_paths.xml +8 -0
  46. package/templates/ios/App/AngularLynxWebGL.h +7 -0
  47. package/templates/ios/App/AngularLynxWebGL.m +27 -0
  48. package/templates/ios/App/AngularLynxWebGLContext.m +139 -0
  49. package/templates/ios/App/LynxViewController.swift +2 -0
  50. package/templates/ios/App/ShareModule.swift +215 -0
@@ -52,6 +52,8 @@ export const xcconfig = (app) => [
52
52
  `DEVELOPMENT_TEAM = ${app.ios.teamId ?? ''}`,
53
53
  '',
54
54
  ].join('\n');
55
+ /** What iOS shows the first time someone taps Save Image, without `savePhotos`. */
56
+ export const DEFAULT_SAVE_PHOTOS_REASON = 'Saves the images you choose to your photo library.';
55
57
  export const infoPlistEntries = (app) => {
56
58
  const lines = [];
57
59
  const array = (key, values) => {
@@ -63,7 +65,14 @@ export const infoPlistEntries = (app) => {
63
65
  // Read by LynxViewController, which lays the LynxView out over the whole
64
66
  // screen or inside the safe area.
65
67
  lines.push('<key>AngularLynxEdgeToEdge</key>', app.edgeToEdge ? '<true/>' : '<false/>');
66
- for (const [permission, reason] of Object.entries(app.permissions)) {
68
+ // The share sheet LynxShare opens has Save Image for an image, which adds
69
+ // it to the photo library, and iOS ends an app that does so without a
70
+ // reason in Info.plist. So every app has one, which `savePhotos` changes.
71
+ const permissions = {
72
+ savePhotos: DEFAULT_SAVE_PHOTOS_REASON,
73
+ ...app.permissions,
74
+ };
75
+ for (const [permission, reason] of Object.entries(permissions)) {
67
76
  for (const key of PERMISSION_MAP[permission]
68
77
  .ios) {
69
78
  lines.push(`<key>${key}</key>`, `<string>${escapeXml(reason)}</string>`);
package/dist/ios/run.d.ts CHANGED
@@ -46,16 +46,31 @@ export type Simulator = {
46
46
  * newest iOS runtime, preferring a simulator that exists (Xcode creates one
47
47
  * of each iPhone) over creating one.
48
48
  */
49
- export declare const pickSimulator: (list: SimctlList, device: string | undefined) => Simulator;
49
+ export declare const pickSimulator: (list: SimctlList, device: string | undefined,
50
+ /** The paired iPhones' names, listed when `device` names nothing. */
51
+ iPhones?: readonly string[]) => Simulator;
52
+ /**
53
+ * Picks where `ng build --platform ios --run` opens the app: the paired
54
+ * iPhone `--device` names, or else a simulator. Without `--device` it's
55
+ * always a simulator, so a phone left plugged in doesn't change what `--run`
56
+ * does.
57
+ */
58
+ export declare const startIosTarget: ({ device, logFile, log, }: {
59
+ readonly device: string | undefined;
60
+ readonly logFile: string;
61
+ readonly log: (message: string) => void;
62
+ }) => Promise<RunTarget>;
50
63
  /**
51
64
  * Picks the simulator for `--run` and starts booting it, so it boots while
52
65
  * xcodebuild compiles. The returned target installs and opens the app once
53
66
  * it's built.
54
67
  */
55
- export declare const startIosSimulator: ({ device, logFile, log, }: {
68
+ export declare const startIosSimulator: ({ device, logFile, log, iPhones, }: {
56
69
  readonly device: string | undefined;
57
70
  readonly logFile: string;
58
71
  readonly log: (message: string) => void;
72
+ /** The paired iPhones' names, listed when `device` names nothing. */
73
+ readonly iPhones?: readonly string[];
59
74
  }) => Promise<RunTarget>;
60
75
  export {};
61
76
  //# sourceMappingURL=run.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/ios/run.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3C,yFAAyF;AACzF,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,YAAY,EAAE,CAAC,CAAC,CAAC;IACpE,QAAQ,CAAC,QAAQ,EAAE,SAAS,aAAa,EAAE,CAAC;CAC7C,CAAC;AAEF,KAAK,Y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IACxC,qEAAqE;IACrE,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACtC,KAAG,OAAO,CAAC,SAAS,CA8DpB,CAAC"}
package/dist/ios/run.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { existsSync } from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import { NativeBuildError, capture, run } from "../process.js";
4
+ import { listIPhones, pickIPhone, startIPhone } from "./iphone.js";
4
5
  /**
5
6
  * Chooses the simulator `ng build --platform ios --run` opens the app on.
6
7
  *
@@ -10,7 +11,9 @@ import { NativeBuildError, capture, run } from "../process.js";
10
11
  * newest iOS runtime, preferring a simulator that exists (Xcode creates one
11
12
  * of each iPhone) over creating one.
12
13
  */
13
- export const pickSimulator = (list, device) => {
14
+ export const pickSimulator = (list, device,
15
+ /** The paired iPhones' names, listed when `device` names nothing. */
16
+ iPhones = []) => {
14
17
  const runtimes = list.runtimes
15
18
  .filter((runtime) => runtime.isAvailable &&
16
19
  (runtime.platform
@@ -39,7 +42,9 @@ export const pickSimulator = (list, device) => {
39
42
  const match = matches.find((simulator) => simulator.booted) ?? matches[0];
40
43
  if (!match) {
41
44
  const names = [...new Set(simulators.map((simulator) => simulator.name))];
42
- throw new NativeBuildError(`There's no iOS simulator named "${device}". Pass the name or UDID of one of these: ${names.join(', ')}. Or create one in Xcode's DeviceHub.`);
45
+ throw new NativeBuildError(`There's no iOS simulator or paired iPhone named "${device}". Pass the name or UDID of one of these simulators: ${names.join(', ')}${iPhones.length > 0
46
+ ? `; or of one of these iPhones: ${iPhones.join(', ')}.`
47
+ : `. Or create a simulator in Xcode's DeviceHub, or pair an iPhone: connect it with a USB cable, unlock it and tap Trust.`}`);
43
48
  }
44
49
  return match;
45
50
  }
@@ -87,12 +92,33 @@ const compareVersions = (a, b) => {
87
92
  }
88
93
  return 0;
89
94
  };
95
+ /**
96
+ * Picks where `ng build --platform ios --run` opens the app: the paired
97
+ * iPhone `--device` names, or else a simulator. Without `--device` it's
98
+ * always a simulator, so a phone left plugged in doesn't change what `--run`
99
+ * does.
100
+ */
101
+ export const startIosTarget = async ({ device, logFile, log, }) => {
102
+ if (!device) {
103
+ return startIosSimulator({ device, logFile, log });
104
+ }
105
+ const iPhones = await listIPhones();
106
+ const iPhone = pickIPhone(iPhones, device);
107
+ return iPhone
108
+ ? startIPhone({ phone: iPhone, logFile, log })
109
+ : startIosSimulator({
110
+ device,
111
+ logFile,
112
+ log,
113
+ iPhones: iPhones.map((phone) => phone.name),
114
+ });
115
+ };
90
116
  /**
91
117
  * Picks the simulator for `--run` and starts booting it, so it boots while
92
118
  * xcodebuild compiles. The returned target installs and opens the app once
93
119
  * it's built.
94
120
  */
95
- export const startIosSimulator = async ({ device, logFile, log, }) => {
121
+ export const startIosSimulator = async ({ device, logFile, log, iPhones, }) => {
96
122
  const output = await capture('xcrun', [
97
123
  'simctl',
98
124
  'list',
@@ -103,7 +129,7 @@ export const startIosSimulator = async ({ device, logFile, log, }) => {
103
129
  if (output === undefined) {
104
130
  throw new NativeBuildError("Couldn't list the iOS simulators with `xcrun simctl`. Install Xcode and open it once, so it installs its command-line tools and the iOS platform.");
105
131
  }
106
- const simulator = pickSimulator(JSON.parse(output), device);
132
+ const simulator = pickSimulator(JSON.parse(output), device, iPhones);
107
133
  const xcrun = (args) => run('xcrun', args, { cwd: process.cwd(), logFile });
108
134
  const label = `${simulator.name} (${simulator.runtime.name})`;
109
135
  log(simulator.booted
package/dist/options.d.ts CHANGED
@@ -38,16 +38,39 @@ export type NativeAppOptions = {
38
38
  * `mailto`, `tel` and `sms` are always there.
39
39
  */
40
40
  readonly canOpenURLSchemes?: readonly string[];
41
- /** A 1024×1024 PNG without transparency, relative to the project root. */
41
+ /**
42
+ * A 1024×1024 PNG without transparency, relative to the project root. iOS
43
+ * uses it as it is. Android gets it resized for each screen density, round
44
+ * for the launchers that want a round icon, and as an adaptive icon (see
45
+ * {@link AndroidOptions.adaptiveIcon}).
46
+ */
42
47
  readonly icon?: string;
43
48
  readonly ios?: IosOptions;
44
49
  readonly android?: AndroidOptions;
45
50
  };
46
51
  export type Orientation = 'portrait' | 'landscape' | 'all';
47
- export type Permission = 'camera' | 'microphone' | 'location' | 'photos' | 'contacts' | 'notifications';
52
+ export type Permission = 'camera' | 'microphone' | 'location' | 'photos' | 'savePhotos' | 'contacts' | 'notifications';
53
+ /**
54
+ * How the `.ipa` is signed, as Xcode's export methods name it:
55
+ * `app-store-connect` for App Store Connect and TestFlight, and
56
+ * `release-testing` (ad hoc) for the iPhones registered to the team, which
57
+ * install it from Finder or Apple Configurator.
58
+ */
59
+ export type IosExportMethod = 'app-store-connect' | 'release-testing';
60
+ export declare const IOS_EXPORT_METHODS: readonly IosExportMethod[];
48
61
  export type IosOptions = {
49
- /** The Apple Developer team that signs the app. */
62
+ /**
63
+ * The Apple Developer team that signs the app. On its own, it signs the
64
+ * development builds `--run --device <iPhone>` installs, with the Apple ID
65
+ * signed in to Xcode; a free Apple ID's Personal Team works for those.
66
+ */
50
67
  readonly teamId?: string;
68
+ /**
69
+ * Builds an `.ipa` signed this way. Defaults to `app-store-connect` once
70
+ * `signing` is set; without `signing`, the Apple ID signed in to Xcode
71
+ * signs it.
72
+ */
73
+ readonly export?: IosExportMethod;
51
74
  /**
52
75
  * Headless signing with an App Store Connect API key. Each field names the
53
76
  * environment variable that holds the value, so no secret is ever written
@@ -70,6 +93,23 @@ export type AndroidOptions = {
70
93
  readonly keyAlias?: string;
71
94
  readonly keyPasswordEnv?: string;
72
95
  };
96
+ /**
97
+ * The two layers of the adaptive icon Android 8 and later show. The
98
+ * launcher masks it to its own shape and moves the layers apart as the
99
+ * icon is touched. Without it, the adaptive icon is `icon` alone, as the
100
+ * background layer, scaled so the masked shape shows all of it.
101
+ */
102
+ readonly adaptiveIcon?: AdaptiveIcon;
103
+ };
104
+ export type AdaptiveIcon = {
105
+ /**
106
+ * A 1024×1024 PNG with transparency, relative to the project root. The
107
+ * launcher's mask crops its edges: keep what matters inside the middle 66
108
+ * of its 108 dp, about 626 px of the 1024.
109
+ */
110
+ readonly foreground?: string;
111
+ /** A color (`#RRGGBB` or `#RGB`), or a 1024×1024 PNG like `foreground`. */
112
+ readonly background?: string;
73
113
  };
74
114
  /** {@link NativeAppOptions} with every default applied and every value checked. */
75
115
  export type ResolvedApp = {
@@ -96,6 +136,12 @@ export type ResolvedApp = {
96
136
  };
97
137
  export declare class NativeConfigError extends Error {
98
138
  }
139
+ /**
140
+ * The colors both CSS and Android resources read the same way. Android also
141
+ * takes `#ARGB` and `#AARRGGBB`, but CSS reads 4 and 8 digits with the alpha
142
+ * last, and an adaptive icon's background should be opaque anyway.
143
+ */
144
+ export declare const ICON_BACKGROUND_COLOR: RegExp;
99
145
  /**
100
146
  * The schemes `LynxLinking.canOpenURL()` can always ask about: the web, mail,
101
147
  * the phone and messages, which most apps link to.
@@ -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,EAAE,MAAM,CAAC;IACxB,0EAA0E;IAC1E,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,8DAA8D;IAC9D,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,WAAW,CAAC,EAAE,WAAW,CAAC;IACnC;;;;;OAKG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;IAC9B,uEAAuE;IACvE,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC;IAC3D,8DAA8D;IAC9D,QAAQ,CAAC,eAAe,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7C;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,SAAS,MAAM,EAAE,CAAC;IAC9C,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,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;AAW/C;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,QAAuC,CAAC;AAG1E;;;GAGG;AACH,eAAO,MAAM,sBAAsB,EAAE,SAAS,MAAM,EAMnD,CAAC;AAaF;;;;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,WA+IF,CAAC;AAUF;;;;;;GAMG;AACH,eAAO,MAAM,OAAO,GAAI,OAAO,OAAO,KAAG,OAWxC,CAAC"}
package/dist/options.js CHANGED
@@ -1,3 +1,7 @@
1
+ export const IOS_EXPORT_METHODS = [
2
+ 'app-store-connect',
3
+ 'release-testing',
4
+ ];
1
5
  export class NativeConfigError extends Error {
2
6
  }
3
7
  /**
@@ -9,6 +13,12 @@ const APP_ID = /^[A-Za-z][A-Za-z0-9]*(\.[A-Za-z][A-Za-z0-9]*)+$/;
9
13
  /** Up to three period-separated integers, as App Store Connect requires. */
10
14
  const VERSION = /^\d+(\.\d+){0,2}$/;
11
15
  const SCHEME = /^[A-Za-z][A-Za-z0-9+.-]*$/;
16
+ /**
17
+ * The colors both CSS and Android resources read the same way. Android also
18
+ * takes `#ARGB` and `#AARRGGBB`, but CSS reads 4 and 8 digits with the alpha
19
+ * last, and an adaptive icon's background should be opaque anyway.
20
+ */
21
+ export const ICON_BACKGROUND_COLOR = /^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/;
12
22
  /** Google Play's maximum versionCode. */
13
23
  const MAX_BUILD_NUMBER = 2_100_000_000;
14
24
  /**
@@ -29,6 +39,7 @@ const PERMISSIONS = [
29
39
  'microphone',
30
40
  'location',
31
41
  'photos',
42
+ 'savePhotos',
32
43
  'contacts',
33
44
  'notifications',
34
45
  ];
@@ -90,6 +101,27 @@ export const resolveAppOptions = (rawOptions, defaults) => {
90
101
  if (canOpenURLSchemes.length > MAX_QUERIED_SCHEMES) {
91
102
  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}.`);
92
103
  }
104
+ const android = options.android ?? {};
105
+ if (android.adaptiveIcon) {
106
+ const { foreground, background } = android.adaptiveIcon;
107
+ if (!foreground || !background) {
108
+ throw new NativeConfigError('android.adaptiveIcon needs both a foreground (a PNG) and a background (a color like "#111111", or a PNG).');
109
+ }
110
+ if (!ICON_BACKGROUND_COLOR.test(background) &&
111
+ !background.toLowerCase().endsWith('.png')) {
112
+ throw new NativeConfigError(`android.adaptiveIcon.background "${background}" is neither a color (#RRGGBB or #RGB) nor a PNG file.`);
113
+ }
114
+ // Android 7, and launchers that ignore adaptive icons, still show the
115
+ // flat icon made from \`icon\`.
116
+ if (!options.icon) {
117
+ throw new NativeConfigError('android.adaptiveIcon needs icon too: Android 7 shows the flat icon made from it.');
118
+ }
119
+ }
120
+ const exportMethod = options.ios?.export;
121
+ if (exportMethod !== undefined &&
122
+ !IOS_EXPORT_METHODS.includes(exportMethod)) {
123
+ throw new NativeConfigError(`ios.export "${exportMethod}" is not valid. Use ${IOS_EXPORT_METHODS.join(' or ')}.`);
124
+ }
93
125
  const productName = name.replace(/[^A-Za-z0-9]/g, '') || 'App';
94
126
  const artifactName = name
95
127
  .toLowerCase()
@@ -109,7 +141,7 @@ export const resolveAppOptions = (rawOptions, defaults) => {
109
141
  productName,
110
142
  artifactName,
111
143
  ios: options.ios ?? {},
112
- android: options.android ?? {},
144
+ android,
113
145
  };
114
146
  };
115
147
  /**
@@ -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,CAiCF,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,CAuCF,CAAC"}
@@ -26,6 +26,12 @@ export const PERMISSION_MAP = {
26
26
  ios: ['NSPhotoLibraryUsageDescription'],
27
27
  android: ['android.permission.READ_MEDIA_IMAGES'],
28
28
  },
29
+ // Adding to the photo library only, as the share sheet's Save Image does
30
+ // (LynxShare). Android needs no permission for it.
31
+ savePhotos: {
32
+ ios: ['NSPhotoLibraryAddUsageDescription'],
33
+ android: [],
34
+ },
29
35
  contacts: {
30
36
  ios: ['NSContactsUsageDescription'],
31
37
  android: ['android.permission.READ_CONTACTS'],
package/dist/png.d.ts CHANGED
@@ -7,4 +7,42 @@ export declare const readPngSize: (file: string) => {
7
7
  readonly width: number;
8
8
  readonly height: number;
9
9
  };
10
+ /** A decoded image: 8-bit RGBA rows, top to bottom, not premultiplied. */
11
+ export type Image = {
12
+ readonly width: number;
13
+ readonly height: number;
14
+ readonly data: Uint8Array;
15
+ };
16
+ /**
17
+ * Decodes a PNG of any color type and bit depth (palette, grayscale, 16-bit,
18
+ * interlaced) into 8-bit RGBA. pngjs is plain JavaScript, so this runs
19
+ * wherever Node does: Android builds don't need a Mac, so the icon can't be
20
+ * resized with macOS's `sips` the way an Xcode build could.
21
+ */
22
+ export declare const decodePng: (bytes: Buffer) => Image;
23
+ export declare const encodePng: (image: Image) => Buffer;
24
+ /**
25
+ * Scales an image to `width`×`height` by averaging the source pixels each
26
+ * output pixel covers (a box filter, weighted by the fraction of each pixel
27
+ * covered). For the big reductions icons need (1024 px to 48), that keeps
28
+ * every source pixel's contribution, where bilinear sampling would skip most
29
+ * of them and alias thin lines.
30
+ *
31
+ * It averages premultiplied colors, so the color of a fully transparent
32
+ * pixel (often black) doesn't bleed into the edge of a shape next to it.
33
+ */
34
+ export declare const resize: (image: Image, width: number, height: number) => Image;
35
+ /**
36
+ * Adds `inset` pixels on every side, each a copy of the nearest edge pixel.
37
+ * An adaptive icon layer is 108 dp, but the launcher shows only about the
38
+ * middle 72 and moves the layer around under its mask, so the margin must
39
+ * continue the picture rather than show a frame of another color.
40
+ */
41
+ export declare const extendEdges: (image: Image, inset: number) => Image;
42
+ /**
43
+ * Clears everything outside the largest circle that fits, with a one-pixel
44
+ * soft edge so the circle isn't jagged: the round icon launchers on
45
+ * Android 7.1 show (`android:roundIcon`), which predates adaptive icons.
46
+ */
47
+ export declare const maskCircle: (image: Image) => Image;
10
48
  //# sourceMappingURL=png.d.ts.map
package/dist/png.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"png.d.ts","sourceRoot":"","sources":["../src/png.ts"],"names":[],"mappings":"AAIA;;;;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"}
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,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,SAAS,GAAI,OAAO,MAAM,KAAG,KAGzC,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,OAAO,KAAK,KAAG,MAStC,CAAC;AAEJ;;;;;;;;;GASG;AACH,eAAO,MAAM,MAAM,GAAI,OAAO,KAAK,EAAE,OAAO,MAAM,EAAE,QAAQ,MAAM,KAAG,KAsBpE,CAAC;AA8FF;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GAAI,OAAO,KAAK,EAAE,OAAO,MAAM,KAAG,KAazD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,UAAU,GAAI,OAAO,KAAK,KAAG,KAezC,CAAC"}
package/dist/png.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { closeSync, openSync, readSync } from 'node:fs';
2
+ import { createRequire } from 'node:module';
2
3
  const SIGNATURE = Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]);
3
4
  /**
4
5
  * Reads a PNG's dimensions from its header, without decoding it. Enough to
@@ -22,3 +23,169 @@ export const readPngSize = (file) => {
22
23
  }
23
24
  return { width: header.readUInt32BE(16), height: header.readUInt32BE(20) };
24
25
  };
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.
32
+ */
33
+ const pngjs = () => createRequire(import.meta.url)('pngjs').PNG;
34
+ /**
35
+ * Decodes a PNG of any color type and bit depth (palette, grayscale, 16-bit,
36
+ * interlaced) into 8-bit RGBA. pngjs is plain JavaScript, so this runs
37
+ * wherever Node does: Android builds don't need a Mac, so the icon can't be
38
+ * resized with macOS's `sips` the way an Xcode build could.
39
+ */
40
+ export const decodePng = (bytes) => {
41
+ const png = pngjs().sync.read(bytes);
42
+ return { width: png.width, height: png.height, data: png.data };
43
+ };
44
+ export const encodePng = (image) => pngjs().sync.write(Object.assign(new (pngjs())({ width: image.width, height: image.height }), {
45
+ data: Buffer.from(image.data.buffer, image.data.byteOffset, image.data.byteLength),
46
+ }));
47
+ /**
48
+ * Scales an image to `width`×`height` by averaging the source pixels each
49
+ * output pixel covers (a box filter, weighted by the fraction of each pixel
50
+ * covered). For the big reductions icons need (1024 px to 48), that keeps
51
+ * every source pixel's contribution, where bilinear sampling would skip most
52
+ * of them and alias thin lines.
53
+ *
54
+ * It averages premultiplied colors, so the color of a fully transparent
55
+ * pixel (often black) doesn't bleed into the edge of a shape next to it.
56
+ */
57
+ export const resize = (image, width, height) => {
58
+ // Separable: rows first, then columns, which is the same average as over
59
+ // each output pixel's rectangle, at a fraction of the work.
60
+ const rows = resizeAxis(premultiply(image), image.width, width, image.height, true);
61
+ const both = resizeAxis(rows, image.height, height, width, false);
62
+ const data = new Uint8Array(width * height * 4);
63
+ for (let i = 0; i < width * height * 4; i += 4) {
64
+ const alpha = both[i + 3];
65
+ const unpremultiply = alpha > 0 ? 1 / alpha : 0;
66
+ data[i] = toByte(both[i] * unpremultiply);
67
+ data[i + 1] = toByte(both[i + 1] * unpremultiply);
68
+ data[i + 2] = toByte(both[i + 2] * unpremultiply);
69
+ data[i + 3] = toByte(alpha * 255);
70
+ }
71
+ return { width, height, data };
72
+ };
73
+ /**
74
+ * Each image's premultiplied pixels, kept while the image is: the generator
75
+ * resizes one icon to a dozen sizes.
76
+ */
77
+ const premultipliedCache = new WeakMap();
78
+ const premultiply = (image) => {
79
+ const cached = premultipliedCache.get(image);
80
+ if (cached) {
81
+ return cached;
82
+ }
83
+ const pixels = new Float32Array(image.data.length);
84
+ for (let i = 0; i < image.data.length; i += 4) {
85
+ const alpha = image.data[i + 3] / 255;
86
+ pixels[i] = image.data[i] * alpha;
87
+ pixels[i + 1] = image.data[i + 1] * alpha;
88
+ pixels[i + 2] = image.data[i + 2] * alpha;
89
+ pixels[i + 3] = alpha;
90
+ }
91
+ premultipliedCache.set(image, pixels);
92
+ return pixels;
93
+ };
94
+ /**
95
+ * Box-filters one axis of an image `lines` pixels across the other axis.
96
+ * Rows (`horizontal`) are `from` pixels long going in and `to` coming out.
97
+ * Columns are `from` pixels tall going in and `to` coming out, and `lines`
98
+ * is the width, both before and after, since rows were resized first.
99
+ */
100
+ const resizeAxis = (pixels, from, to, lines, horizontal) => {
101
+ const scale = from / to;
102
+ // Which source pixels each output pixel covers, and by how much: output
103
+ // pixel i reads `tapCount[i]` source pixels from `tapStart[i]`, with
104
+ // their weights in `weights` from `tapOffset[i]`. Flat typed arrays keep
105
+ // the loop below, run for every pixel of every line, free of objects.
106
+ const tapStart = new Int32Array(to);
107
+ const tapCount = new Int32Array(to);
108
+ const tapOffset = new Int32Array(to);
109
+ const weights = [];
110
+ for (let i = 0; i < to; i++) {
111
+ const start = i * scale;
112
+ const end = start + scale;
113
+ const first = Math.floor(start);
114
+ const last = Math.min(Math.ceil(end), from);
115
+ tapStart[i] = first;
116
+ tapCount[i] = last - first;
117
+ tapOffset[i] = weights.length;
118
+ for (let j = first; j < last; j++) {
119
+ weights.push((Math.min(end, j + 1) - Math.max(start, j)) / scale);
120
+ }
121
+ }
122
+ const weight = Float32Array.from(weights);
123
+ // How far apart, in floats, neighboring pixels along the axis are, and
124
+ // where each line starts, in the input and the output.
125
+ const step = horizontal ? 4 : lines * 4;
126
+ const inLine = horizontal ? from * 4 : 4;
127
+ const outLine = horizontal ? to * 4 : 4;
128
+ const out = new Float32Array(to * lines * 4);
129
+ for (let line = 0; line < lines; line++) {
130
+ for (let i = 0; i < to; i++) {
131
+ const target = line * outLine + i * step;
132
+ let r = 0;
133
+ let g = 0;
134
+ let b = 0;
135
+ let a = 0;
136
+ let source = line * inLine + tapStart[i] * step;
137
+ for (let k = 0, w = tapOffset[i]; k < tapCount[i]; k++, w++) {
138
+ const factor = weight[w];
139
+ r += pixels[source] * factor;
140
+ g += pixels[source + 1] * factor;
141
+ b += pixels[source + 2] * factor;
142
+ a += pixels[source + 3] * factor;
143
+ source += step;
144
+ }
145
+ out[target] = r;
146
+ out[target + 1] = g;
147
+ out[target + 2] = b;
148
+ out[target + 3] = a;
149
+ }
150
+ }
151
+ return out;
152
+ };
153
+ const toByte = (value) => Math.min(255, Math.max(0, Math.round(value)));
154
+ /**
155
+ * Adds `inset` pixels on every side, each a copy of the nearest edge pixel.
156
+ * An adaptive icon layer is 108 dp, but the launcher shows only about the
157
+ * middle 72 and moves the layer around under its mask, so the margin must
158
+ * continue the picture rather than show a frame of another color.
159
+ */
160
+ export const extendEdges = (image, inset) => {
161
+ const width = image.width + inset * 2;
162
+ const height = image.height + inset * 2;
163
+ const data = new Uint8Array(width * height * 4);
164
+ for (let y = 0; y < height; y++) {
165
+ const sourceY = Math.min(image.height - 1, Math.max(0, y - inset));
166
+ for (let x = 0; x < width; x++) {
167
+ const sourceX = Math.min(image.width - 1, Math.max(0, x - inset));
168
+ const source = (sourceY * image.width + sourceX) * 4;
169
+ data.set(image.data.subarray(source, source + 4), (y * width + x) * 4);
170
+ }
171
+ }
172
+ return { width, height, data };
173
+ };
174
+ /**
175
+ * Clears everything outside the largest circle that fits, with a one-pixel
176
+ * soft edge so the circle isn't jagged: the round icon launchers on
177
+ * Android 7.1 show (`android:roundIcon`), which predates adaptive icons.
178
+ */
179
+ export const maskCircle = (image) => {
180
+ const data = Uint8Array.from(image.data);
181
+ const radius = Math.min(image.width, image.height) / 2;
182
+ for (let y = 0; y < image.height; y++) {
183
+ for (let x = 0; x < image.width; x++) {
184
+ const distance = Math.hypot(x + 0.5 - image.width / 2, y + 0.5 - image.height / 2);
185
+ const coverage = Math.min(1, Math.max(0, radius - distance + 0.5));
186
+ const alpha = (y * image.width + x) * 4 + 3;
187
+ data[alpha] = Math.round(data[alpha] * coverage);
188
+ }
189
+ }
190
+ return { width: image.width, height: image.height, data };
191
+ };
package/dist/run.d.ts CHANGED
@@ -2,10 +2,10 @@ import type { ResolvedApp } from './options.ts';
2
2
  /** `ng build --platform <platform> --run`'s options. */
3
3
  export type RunOptions = {
4
4
  /**
5
- * Where to open the app. On iOS, a simulator's name or UDID; on Android, a
6
- * virtual device's name or an adb serial. When it's left out, a running
7
- * simulator, emulator or phone, or else the newest iPhone simulator or the
8
- * first virtual device.
5
+ * Where to open the app. On iOS, a simulator's or a paired iPhone's name or
6
+ * UDID; on Android, a virtual device's name or an adb serial. When it's
7
+ * left out, a running simulator, emulator or Android phone, or else the
8
+ * newest iPhone simulator or the first virtual device.
9
9
  */
10
10
  readonly device?: string;
11
11
  };
@@ -15,6 +15,14 @@ export type RunOptions = {
15
15
  * seconds, and a simulator or emulator boots while Xcode or Gradle compiles.
16
16
  */
17
17
  export type RunTarget = {
18
+ /**
19
+ * The real iPhone the app runs on, which takes a development-signed build
20
+ * for the device rather than the simulator app.
21
+ */
22
+ readonly iPhone?: {
23
+ readonly udid: string;
24
+ readonly name: string;
25
+ };
18
26
  /** Waits for the device to finish starting, then installs and opens the app. */
19
27
  readonly launch: (binary: string, app: ResolvedApp) => Promise<void>;
20
28
  };
package/dist/run.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,wDAAwD;AACxD,MAAM,MAAM,UAAU,GAAG;IACvB;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,SAAS,GAAG;IACtB,gFAAgF;IAChF,QAAQ,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACtE,CAAC"}
1
+ {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,wDAAwD;AACxD,MAAM,MAAM,UAAU,GAAG;IACvB;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,SAAS,GAAG;IACtB;;;OAGG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACnE,gFAAgF;IAChF,QAAQ,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACtE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blotch/angular-lynx-native",
3
- "version": "22.2.19",
3
+ "version": "22.2.21",
4
4
  "description": "Builds AngularLynx apps into iOS and Android binaries",
5
5
  "homepage": "https://github.com/Blotch-Smart-Frames/AngularLynx#readme",
6
6
  "bugs": {
@@ -43,9 +43,13 @@
43
43
  "build:angle-ios-frameworks": "scripts/build-angle-ios-frameworks.sh",
44
44
  "publish:local": "yalc publish --push"
45
45
  },
46
+ "dependencies": {
47
+ "pngjs": "^7.0.0"
48
+ },
46
49
  "devDependencies": {
47
50
  "@bacons/xcode": "1.0.0-alpha.33",
48
51
  "@types/node": "^22.0.0",
52
+ "@types/pngjs": "^6.0.5",
49
53
  "typescript": "~6.0.0"
50
54
  },
51
55
  "engines": {
@@ -67,9 +67,13 @@ iOS's `LocalStorageModule.swift` uses a `UserDefaults` suite and `SecureStorageM
67
67
 
68
68
  The module reads the picked photo on a background thread and calls back once with `{ base64, name, type }`, `{ canceled: true }` or `{ error, message }`. A JPEG, PNG, GIF or WebP goes back as it is unless the app passed `maxDimension` or `quality`; otherwise it's decoded with `BitmapFactory` at the smallest power-of-two reduction that covers the target, scaled, turned upright by its EXIF orientation (AndroidX `ExifInterface`, since `BitmapFactory` ignores it), drawn over white if it has transparency and compressed as a JPEG. iOS's `ImagePickerModule.swift` does the same with `PHPickerViewController` and ImageIO.
69
69
 
70
+ ## Share sheet
71
+
72
+ `NativeModules.AngularLynxShare.share(request, callback)` (`ShareModule.kt`, behind the runtime's `LynxShare`) writes the request's files (base64) under the cache's `angular-lynx-share/` folder, on a background thread, and opens an `ACTION_SEND` or `ACTION_SEND_MULTIPLE` chooser with their content:// URIs. They come from the manifest's `androidx.core.content.FileProvider` (authority `<applicationId>.angularlynx.share`, paths in `res/xml/share_paths.xml`), and the intent's `ClipData` and `FLAG_GRANT_READ_URI_PERMISSION` let the app picked read them. `MainActivity` registers it with itself as the param, since the module starts the chooser from it and watches its lifecycle. Android doesn't say whether sharing finished, so the module calls back `{ shared: true }` when the chooser's `IntentSender` reports the app picked, and `{ shared: false }` when the activity resumes without a pick. The last share's files stay until the next one, since the app picked may read them after the chooser closes. iOS's `ShareModule.swift` opens `UIActivityViewController` with the files as temporary files of their names, and leaves out Save Image when Info.plist has no `NSPhotoLibraryAddUsageDescription`.
73
+
70
74
  ## Canvas and WebGL
71
75
 
72
- `<canvas>` (issue #211) is the shell's: `CanvasUI.kt`, a `TextureView` registered as the `canvas` element (`addBehavior(CanvasUI.behavior())`), and `WebGLModule.kt`, the `AngularLynxWebGL` module the runtime's WebGL2 context sends its calls to. `MainActivity` turns on main-thread modules (`setEnableMTSModule(true)`), so the runtime, which runs on Lynx's main thread, calls the module synchronously with `lynx.module(name)`, on the UI thread. Each context (`WebGLContext.kt`) is an EGL context with OpenGL ES 3.0 and an offscreen default framebuffer, which `present` copies into the canvas's surface; `WebGLOps.kt` is generated from the runtime's opcodes (`npm run generate:webgl-ops -w packages/native`). `AssetsModule.kt` (`AngularLynxAssets`) reads a file the app bundles for the main thread's `fetch`, which has no page URL to resolve `/static/...` against.
76
+ `<canvas>` (issue #211) is the shell's: `CanvasUI.kt`, a `TextureView` registered as the `canvas` element (`addBehavior(CanvasUI.behavior())`), and `WebGLModule.kt`, the `AngularLynxWebGL` module the runtime's WebGL2 context sends its calls to. `MainActivity` turns on main-thread modules (`setEnableMTSModule(true)`), so the runtime, which runs on Lynx's main thread, calls the module synchronously with `lynx.module(name)`, on the UI thread. Each context (`WebGLContext.kt`) is an EGL context with OpenGL ES 3.0 and an offscreen default framebuffer, which `present` copies into the canvas's surface; `WebGLOps.kt` is generated from the runtime's opcodes (`npm run generate:webgl-ops -w packages/native`). `encodeImage`, behind `canvas.toBlob()` and `toDataURL()`, reads the default framebuffer and compresses it with `Bitmap.compress`, returning the file as base64. `AssetsModule.kt` (`AngularLynxAssets`) reads a file the app bundles for the main thread's `fetch`, which has no page URL to resolve `/static/...` against.
73
77
 
74
78
  Android's GLES has no 2D uploads from a `PIXEL_UNPACK_BUFFER` and no `glGetVertexAttribPointerv`, so those log a warning and answer 0.
75
79