@ng-native/template-desktop 0.25.0 → 0.26.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/AGENTS.md CHANGED
@@ -18,8 +18,8 @@ browser-only parts do not: there is no `NgOptimizedImage` (use `<image>`), and n
18
18
  npm start # Metro, the dev server the app loads from
19
19
  npm run macos # builds the desktop host (the first time) and opens the app from Metro
20
20
  npm test # Vitest, in Node against a fake native layer: no app window needed
21
- npx vitest --project macos # tests in src/**/*.device.ts, inside the running app; needs
22
- # EXPO_PUBLIC_DEVICE_TESTS=1 npx expo start in another terminal
21
+ npx vitest --project macos # tests in src/**/*.device.ts, inside the running app, which it
22
+ # starts, with its own Metro
23
23
  npm run typecheck
24
24
  npm run package # the .app
25
25
  npm run package -- --format dmg # a signed, notarised download; --format mas for the Mac App Store
@@ -89,6 +89,11 @@ change; both are fast.
89
89
  `userEvent.setup().press(...)` or `.type(...)`, all from `@ng-native/testing`. Tests run in Node
90
90
  with no simulator, so write one alongside a change.
91
91
 
92
+ A file under `src` ending in `.device.ts` runs inside the running app instead, on real native views, from
93
+ `@ng-native/testing/device`: `npx vitest --project` with an OS the app's `vitest.config.mts` has a
94
+ project for (`ios`, `android` or `macos`), from the app's directory. The first run builds the app,
95
+ which needs Xcode or the Android SDK, and takes some minutes; later runs take seconds.
96
+
92
97
  A service that depends on the platform injects `OS` and `OS_VERSION` from `@ng-native/device`
93
98
  rather than importing `Platform` from `react-native`, which a test cannot load. A test provides
94
99
  the values it wants: `{ provide: OS, useValue: 'android' }`.
package/README.md CHANGED
@@ -15,11 +15,10 @@ npm run package # dist/macos/my-app.app
15
15
  npm run package -- --format dmg # a signed, notarised .dmg; --format mas for the Mac App Store
16
16
  ```
17
17
 
18
- To run tests inside the app, on real AppKit views, start Metro for them and run the `macos` Vitest
19
- project, which opens the app itself (`src/app/app.device.ts` is the example):
18
+ To run tests inside the app, on real AppKit views, run the `macos` Vitest project, which starts
19
+ Metro and opens the app itself (`src/app/app.device.ts` is the example):
20
20
 
21
21
  ```sh
22
- EXPO_PUBLIC_DEVICE_TESTS=1 npx expo start
23
22
  npx vitest --project macos
24
23
  ```
25
24
 
package/gitignore CHANGED
@@ -41,3 +41,7 @@ yarn-error.*
41
41
 
42
42
  # Generated by @ng-native/tailwind's withTailwind, rebuilt on every Metro start
43
43
  .angular-native/
44
+
45
+ # Written beside a reference screenshot when a device test's capture differs from it
46
+ **/__screenshots__/**/*-actual.png
47
+ **/__screenshots__/**/*-diff.png
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@ng-native/template-desktop",
3
- "version": "0.25.0",
3
+ "version": "0.26.1",
4
4
  "description": "A macOS app in Angular, rendering real AppKit views. Use with create-expo-app --template.",
5
5
  "license": "MIT",
6
6
  "main": "src/main.ts",
7
7
  "dependencies": {
8
- "@ng-native/components": "0.25.0",
9
- "@ng-native/desktop": "0.25.0",
10
- "@ng-native/device": "0.25.0",
11
- "@ng-native/expo": "0.25.0",
12
- "@ng-native/fabric": "0.25.0",
13
- "@ng-native/metro": "0.25.0",
14
- "@ng-native/platform": "0.25.0",
8
+ "@ng-native/components": "0.26.1",
9
+ "@ng-native/desktop": "0.26.1",
10
+ "@ng-native/device": "0.26.1",
11
+ "@ng-native/expo": "0.26.1",
12
+ "@ng-native/fabric": "0.26.1",
13
+ "@ng-native/metro": "0.26.1",
14
+ "@ng-native/platform": "0.26.1",
15
15
  "@angular/common": "^22.0.0",
16
16
  "@angular/core": "^22.0.0",
17
17
  "expo": "~58.0.16",
@@ -22,7 +22,7 @@
22
22
  "devDependencies": {
23
23
  "@angular/compiler-cli": "^22.0.0",
24
24
  "@babel/core": "^7.29.7",
25
- "@ng-native/testing": "0.25.0",
25
+ "@ng-native/testing": "0.26.1",
26
26
  "@types/react": "~19.3.0",
27
27
  "typescript": "~6.0.3",
28
28
  "vitest": "^5.0.0"
@@ -1,8 +1,9 @@
1
1
  import { Platform } from 'react-native';
2
2
  import { expect, it } from 'vitest';
3
3
 
4
- // Runs inside the app, on real AppKit views: `npx vitest --project macos`. Render a component
5
- // with `render` and `screen` from `@ng-native/testing/device`.
6
- it('runs on the Mac', () => {
7
- expect(Platform.OS).toBe('macos');
4
+ // Runs inside the app, on real native views: `npx vitest --project macos`, and `ios` or `android`
5
+ // once the app has those projects. Render a component with `render` and `screen` from
6
+ // `@ng-native/testing/device`.
7
+ it('runs inside the app', () => {
8
+ expect(['macos', 'ios', 'android']).toContain(Platform.OS);
8
9
  });
package/src/main.ts CHANGED
@@ -28,7 +28,14 @@ if (process.env.EXPO_PUBLIC_DEVICE_TESTS) {
28
28
  // Metro was started for `vitest --project macos`: the test host, not the app.
29
29
  const { startDeviceTests } =
30
30
  require('@ng-native/testing/device/host') as typeof import('@ng-native/testing/device/host');
31
- startDeviceTests({ mount: mountOptions() });
31
+ startDeviceTests({
32
+ mount: mountOptions,
33
+ // The host follows rotation, the theme and reduced motion as the app does.
34
+ onMount: (app) => {
35
+ const stopWatching = watchConditions(app.engine);
36
+ app.applicationRef.onDestroy(stopWatching);
37
+ },
38
+ });
32
39
  } else {
33
40
  AppRegistry.registerRunnable('main', ({ rootTag }) => {
34
41
  const app = mount(Number(rootTag), App, getFabricUIManager(), mountOptions());
package/vitest.config.mts CHANGED
@@ -4,8 +4,8 @@ import { defineConfig } from 'vitest/config';
4
4
 
5
5
  // Two projects. `node-macos` compiles Angular for the tests the way Metro compiles it for the app
6
6
  // and runs them in Node against a fake of the native side: no app window. `macos` runs the
7
- // `*.device.ts` files inside the running app on this Mac, which it opens itself; start Metro with
8
- // EXPO_PUBLIC_DEVICE_TESTS=1 first. `npm test` runs `node-macos` alone.
7
+ // `*.device.ts` files inside the running app on this Mac, starting Metro and the app itself.
8
+ // `npm test` runs `node-macos` alone.
9
9
  export default defineConfig({
10
10
  test: {
11
11
  projects: [