@ng-native/schematics 0.22.2 → 0.23.0
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/application/index.cjs +70 -28
- package/application/schema.json +5 -0
- package/builders/expo.cjs +35 -1
- package/builders/expo.json +8 -6
- package/builders/spawn-bin.cjs +3 -2
- package/builders/vitest.cjs +2 -1
- package/builders/vitest.json +4 -0
- package/builders.json +1 -1
- package/collection.json +10 -0
- package/desktop/index.cjs +161 -0
- package/desktop/schema.json +23 -0
- package/files/AGENTS.md +7 -6
- package/files/desktop/AGENTS.md +94 -0
- package/files/desktop/metro.config.js +10 -0
- package/files/desktop/src/app/app.device.ts +8 -0
- package/files/desktop/src/app/app.test.ts +42 -0
- package/files/desktop/src/app/app.ts +159 -0
- package/files/desktop/src/main.ts +43 -0
- package/files/desktop/vitest.config.mts +16 -0
- package/migrations.json +11 -1
- package/mobile/index.cjs +77 -0
- package/mobile/schema.json +23 -0
- package/native-app.cjs +47 -7
- package/ng-add/index.cjs +1 -1
- package/ng-add/schema.json +5 -0
- package/package.json +6 -4
package/application/index.cjs
CHANGED
|
@@ -14,6 +14,7 @@ const path = require('node:path').posix;
|
|
|
14
14
|
const { SchematicsException } = require('@angular-devkit/schematics');
|
|
15
15
|
const { NodePackageInstallTask } = require('@angular-devkit/schematics/tasks');
|
|
16
16
|
const native = require('../native-app.cjs');
|
|
17
|
+
const { desktopTargets } = require('../desktop/index.cjs');
|
|
17
18
|
|
|
18
19
|
function readJson(tree, file) {
|
|
19
20
|
return JSON.parse(tree.readText(file));
|
|
@@ -27,7 +28,7 @@ function writeJson(tree, file, value) {
|
|
|
27
28
|
* The project's targets. Each is an Expo command run in the project's directory, which is where
|
|
28
29
|
* Expo reads `app.json` and `metro.config.js` from.
|
|
29
30
|
*/
|
|
30
|
-
function targets(root, name, lint = false) {
|
|
31
|
+
function targets(root, name, lint = false, desktopOnly = false) {
|
|
31
32
|
const expo = (command, args) => ({
|
|
32
33
|
builder: '@ng-native/schematics:expo',
|
|
33
34
|
options: args ? { command, args } : { command },
|
|
@@ -37,9 +38,14 @@ function targets(root, name, lint = false) {
|
|
|
37
38
|
return {
|
|
38
39
|
serve: expo('start'),
|
|
39
40
|
build: expo('export', ['--output-dir', outputDir]),
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
// A desktop-only app runs with `ng-native-desktop`: the Expo CLI has no `run:macos`.
|
|
42
|
+
...(desktopOnly
|
|
43
|
+
? desktopTargets()
|
|
44
|
+
: { 'run-ios': expo('run:ios'), 'run-android': expo('run:android') }),
|
|
45
|
+
test: {
|
|
46
|
+
builder: '@ng-native/schematics:vitest',
|
|
47
|
+
options: desktopOnly ? { project: native.DESKTOP_TEST_PROJECT } : {},
|
|
48
|
+
},
|
|
43
49
|
typecheck: { builder: '@ng-native/schematics:typecheck', options: {} },
|
|
44
50
|
// With `--linter=eslint`, angular-eslint's builder, which `ng lint` runs, with the project's
|
|
45
51
|
// own config: the rules that know a device from a browser, which a workspace's config for its
|
|
@@ -71,7 +77,7 @@ const WEB_SPECS = [
|
|
|
71
77
|
'service',
|
|
72
78
|
];
|
|
73
79
|
|
|
74
|
-
function project(root, name, prefix, lint) {
|
|
80
|
+
function project(root, name, prefix, lint, desktopOnly) {
|
|
75
81
|
return {
|
|
76
82
|
projectType: 'application',
|
|
77
83
|
root,
|
|
@@ -85,20 +91,39 @@ function project(root, name, prefix, lint) {
|
|
|
85
91
|
schematics: Object.fromEntries(
|
|
86
92
|
WEB_SPECS.map((schematic) => [`@schematics/angular:${schematic}`, { skipTests: true }]),
|
|
87
93
|
),
|
|
88
|
-
architect: targets(root, name, lint),
|
|
94
|
+
architect: targets(root, name, lint, desktopOnly),
|
|
89
95
|
};
|
|
90
96
|
}
|
|
91
97
|
|
|
92
98
|
/** The Commands section of the app's `AGENTS.md`, as this workspace runs them. */
|
|
93
|
-
function commands(name, lint) {
|
|
99
|
+
function commands(name, lint, desktopOnly) {
|
|
100
|
+
const runs = desktopOnly
|
|
101
|
+
? [
|
|
102
|
+
[`ng serve ${name}`, 'Metro, the dev server the app loads from'],
|
|
103
|
+
[`ng run ${name}:macos`, 'builds the desktop host and opens the app from Metro'],
|
|
104
|
+
]
|
|
105
|
+
: [
|
|
106
|
+
[
|
|
107
|
+
`ng serve ${name}`,
|
|
108
|
+
'Metro; press i or a for a simulator, or scan the QR code with Expo Go',
|
|
109
|
+
],
|
|
110
|
+
[`ng run ${name}:run-ios`, 'the iOS simulator'],
|
|
111
|
+
[`ng run ${name}:run-android`, 'the Android emulator'],
|
|
112
|
+
];
|
|
94
113
|
const rows = [
|
|
95
|
-
|
|
96
|
-
[`ng run ${name}:run-ios`, 'the iOS simulator'],
|
|
97
|
-
[`ng run ${name}:run-android`, 'the Android emulator'],
|
|
114
|
+
...runs,
|
|
98
115
|
[`ng test ${name}`, 'Vitest, in Node against a fake native layer: no simulator needed'],
|
|
99
116
|
[`ng run ${name}:typecheck`, 'ngc, which checks the templates as well as the code'],
|
|
100
117
|
...(lint ? [[`ng lint ${name}`, 'ESLint: what compiles but does nothing on a device']] : []),
|
|
101
118
|
[`ng build ${name}`, 'an exported bundle'],
|
|
119
|
+
...(desktopOnly
|
|
120
|
+
? [
|
|
121
|
+
[
|
|
122
|
+
`ng run ${name}:package`,
|
|
123
|
+
'the .app; "args": ["--format", "dmg"] (or "mas") on the target in angular.json to ship it',
|
|
124
|
+
],
|
|
125
|
+
]
|
|
126
|
+
: []),
|
|
102
127
|
];
|
|
103
128
|
const width = Math.max(...rows.map(([command]) => command.length)) + 2;
|
|
104
129
|
return [
|
|
@@ -113,26 +138,36 @@ function commands(name, lint) {
|
|
|
113
138
|
].join('\n');
|
|
114
139
|
}
|
|
115
140
|
|
|
116
|
-
function writeFiles(tree, root, name, bundleIdentifier, lint) {
|
|
141
|
+
function writeFiles(tree, root, name, bundleIdentifier, lint, desktopOnly) {
|
|
117
142
|
for (const file of native.SOURCE_FILES) {
|
|
118
|
-
tree.create(path.join(root, file), native.sourceFile(file));
|
|
143
|
+
tree.create(path.join(root, file), native.sourceFile(file, desktopOnly));
|
|
119
144
|
}
|
|
120
|
-
|
|
121
|
-
|
|
145
|
+
for (const file of desktopOnly ? native.DESKTOP_ONLY_FILES : []) {
|
|
146
|
+
tree.create(path.join(root, file), native.sourceFile(file, true));
|
|
147
|
+
}
|
|
148
|
+
const platforms = desktopOnly ? ['macos'] : undefined;
|
|
149
|
+
tree.create(path.join(root, 'app.json'), native.appJson(name, bundleIdentifier, platforms));
|
|
150
|
+
tree.create(
|
|
151
|
+
path.join(root, 'AGENTS.md'),
|
|
152
|
+
native.agentsFile(commands(name, lint, desktopOnly), desktopOnly),
|
|
153
|
+
);
|
|
122
154
|
if (lint) tree.create(path.join(root, 'eslint.config.mjs'), native.ESLINT_CONFIG);
|
|
123
155
|
tree.create(path.join(root, 'CLAUDE.md'), '@AGENTS.md\n');
|
|
124
|
-
tree.create(
|
|
125
|
-
|
|
156
|
+
tree.create(
|
|
157
|
+
path.join(root, '.gitignore'),
|
|
158
|
+
desktopOnly ? `${native.GITIGNORE}\n${native.DESKTOP_GITIGNORE}` : native.GITIGNORE,
|
|
159
|
+
);
|
|
160
|
+
const manifest = native.projectManifest(name, readJson(tree, 'package.json'), desktopOnly);
|
|
126
161
|
tree.create(path.join(root, 'package.json'), JSON.stringify(manifest, null, 2) + '\n');
|
|
127
162
|
}
|
|
128
163
|
|
|
129
164
|
/** Adds what is missing and leaves every version the workspace already chose alone. */
|
|
130
|
-
function addDependencies(tree, context, lint) {
|
|
165
|
+
function addDependencies(tree, context, lint, desktopOnly) {
|
|
131
166
|
const manifest = readJson(tree, 'package.json');
|
|
132
167
|
const linter = lint ? 'eslint' : 'none';
|
|
133
168
|
for (const problem of native.conflicts(manifest, { linter })) context.logger.warn(problem);
|
|
134
169
|
const wanted = {
|
|
135
|
-
dependencies: native.dependencies,
|
|
170
|
+
dependencies: desktopOnly ? native.desktopOnlyDependencies : native.dependencies,
|
|
136
171
|
devDependencies: lint
|
|
137
172
|
? { ...native.devDependencies, ...native.lintDevDependencies }
|
|
138
173
|
: native.devDependencies,
|
|
@@ -156,7 +191,7 @@ function ignoreExpo(tree) {
|
|
|
156
191
|
}
|
|
157
192
|
|
|
158
193
|
/**
|
|
159
|
-
* @param {{ name: string, directory?: string, prefix?: string, bundleIdentifier?: string, linter?: 'eslint' | 'none', skipInstall?: boolean }} options
|
|
194
|
+
* @param {{ name: string, directory?: string, prefix?: string, bundleIdentifier?: string, linter?: 'eslint' | 'none', desktopOnly?: boolean, skipInstall?: boolean }} options
|
|
160
195
|
*/
|
|
161
196
|
function application(options) {
|
|
162
197
|
return (tree, context) => {
|
|
@@ -178,21 +213,28 @@ function application(options) {
|
|
|
178
213
|
if (problem) throw new SchematicsException(problem);
|
|
179
214
|
|
|
180
215
|
const lint = options.linter === 'eslint';
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
216
|
+
const desktopOnly = options.desktopOnly === true;
|
|
217
|
+
addDependencies(tree, context, lint, desktopOnly);
|
|
218
|
+
writeFiles(tree, root, name, bundleIdentifier, lint, desktopOnly);
|
|
219
|
+
const added = project(root, name, options.prefix, lint, desktopOnly);
|
|
184
220
|
workspace.projects = { ...workspace.projects, [name]: added };
|
|
185
221
|
writeJson(tree, 'angular.json', workspace);
|
|
186
222
|
ignoreExpo(tree);
|
|
187
223
|
|
|
188
224
|
if (!options.skipInstall) context.addTask(new NodePackageInstallTask());
|
|
189
|
-
context.logger.info(
|
|
190
|
-
`Created ${root}. Run it with: ng serve ${name} (Metro), ng run ${name}:run-ios, ` +
|
|
191
|
-
`ng test ${name}, ng run ${name}:typecheck, ` +
|
|
192
|
-
(lint ? `ng lint ${name}, ` : '') +
|
|
193
|
-
`ng build ${name}.`,
|
|
194
|
-
);
|
|
225
|
+
context.logger.info(created(root, name, lint, desktopOnly));
|
|
195
226
|
};
|
|
196
227
|
}
|
|
197
228
|
|
|
229
|
+
/** What the schematic says once the app is written: the commands that run it. */
|
|
230
|
+
function created(root, name, lint, desktopOnly) {
|
|
231
|
+
return (
|
|
232
|
+
`Created ${root}. Run it with: ng serve ${name} (Metro), ` +
|
|
233
|
+
`ng run ${name}:${desktopOnly ? 'macos' : 'run-ios'}, ` +
|
|
234
|
+
`ng test ${name}, ng run ${name}:typecheck, ` +
|
|
235
|
+
(lint ? `ng lint ${name}, ` : '') +
|
|
236
|
+
`ng build ${name}.`
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
|
|
198
240
|
module.exports = { application, targets };
|
package/application/schema.json
CHANGED
|
@@ -34,6 +34,11 @@
|
|
|
34
34
|
"enum": ["eslint", "none"],
|
|
35
35
|
"default": "none"
|
|
36
36
|
},
|
|
37
|
+
"desktopOnly": {
|
|
38
|
+
"type": "boolean",
|
|
39
|
+
"description": "A macOS-only app from the desktop template: macos alone in expo.platforms, a sidebar and menu bar starter, and macos and package targets in place of run-ios and run-android.",
|
|
40
|
+
"default": false
|
|
41
|
+
},
|
|
37
42
|
"skipInstall": {
|
|
38
43
|
"type": "boolean",
|
|
39
44
|
"description": "Write the files and package.json without installing.",
|
package/builders/expo.cjs
CHANGED
|
@@ -4,10 +4,18 @@
|
|
|
4
4
|
* `ng serve native` is `expo start`, `ng build native` is `expo export` and
|
|
5
5
|
* `ng run native:run-ios` is `expo run:ios`. Nothing is translated: Metro builds an Angular Native
|
|
6
6
|
* app, Expo drives Metro, and this is how `ng` reaches it.
|
|
7
|
+
*
|
|
8
|
+
* Two commands are not the Expo CLI's, because its `run` commands are a fixed list with no
|
|
9
|
+
* `run:macos`: `macos` is `ng-native-desktop run`, which builds the desktop host and opens the app
|
|
10
|
+
* from the dev server `ng serve` runs, and `package` is `ng-native-desktop package`, which makes the
|
|
11
|
+
* `.app`, `.dmg` or Mac App Store package. Both come from `@ng-native/desktop`.
|
|
7
12
|
*/
|
|
8
13
|
const { createBuilder } = require('@angular-devkit/architect');
|
|
9
14
|
const { spawnBin } = require('./spawn-bin.cjs');
|
|
10
15
|
|
|
16
|
+
/** The commands `ng-native-desktop` runs in place of the Expo CLI, by its subcommand. */
|
|
17
|
+
const DESKTOP_COMMANDS = { macos: 'run', package: 'package' };
|
|
18
|
+
|
|
11
19
|
/**
|
|
12
20
|
* The Expo CLI's arguments for a target's options.
|
|
13
21
|
*
|
|
@@ -21,5 +29,31 @@ function expoArgs(options) {
|
|
|
21
29
|
return args;
|
|
22
30
|
}
|
|
23
31
|
|
|
24
|
-
|
|
32
|
+
/**
|
|
33
|
+
* `ng-native-desktop`'s arguments for a `macos` or `package` target. The port is the dev server's
|
|
34
|
+
* the host loads the app from, which only `macos` has: `package` bundles the app itself, and
|
|
35
|
+
* refuses `--port`.
|
|
36
|
+
*
|
|
37
|
+
* @param {{ command: 'macos' | 'package', args?: string[], port?: number }} options
|
|
38
|
+
*/
|
|
39
|
+
function desktopArgs(options) {
|
|
40
|
+
const args = [DESKTOP_COMMANDS[options.command], ...(options.args ?? [])];
|
|
41
|
+
if (options.port && options.command === 'macos') args.push('--port', String(options.port));
|
|
42
|
+
return args;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* @param {{ command: string, args?: string[], platform?: string, port?: number, clear?: boolean }} options
|
|
47
|
+
* @param {import('@angular-devkit/architect').BuilderContext} context
|
|
48
|
+
*/
|
|
49
|
+
function runCommand(options, context) {
|
|
50
|
+
if (options.command in DESKTOP_COMMANDS) {
|
|
51
|
+
return spawnBin('@ng-native/desktop', desktopArgs(options), context, 'ng-native-desktop');
|
|
52
|
+
}
|
|
53
|
+
return spawnBin('expo', expoArgs(options), context);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
module.exports = createBuilder(runCommand);
|
|
25
57
|
module.exports.expoArgs = expoArgs;
|
|
58
|
+
module.exports.desktopArgs = desktopArgs;
|
|
59
|
+
module.exports.runCommand = runCommand;
|
package/builders/expo.json
CHANGED
|
@@ -6,26 +6,28 @@
|
|
|
6
6
|
"properties": {
|
|
7
7
|
"command": {
|
|
8
8
|
"type": "string",
|
|
9
|
-
"description": "The Expo CLI command: start, export, run:ios, run:android, prebuild."
|
|
9
|
+
"description": "The Expo CLI command: start, export, run:ios, run:android, prebuild. Or macos, which builds the desktop host and opens the app in it, and package, which packages the macOS app: both run ng-native-desktop from @ng-native/desktop."
|
|
10
10
|
},
|
|
11
11
|
"args": {
|
|
12
12
|
"type": "array",
|
|
13
|
-
"items": {
|
|
13
|
+
"items": {
|
|
14
|
+
"type": "string"
|
|
15
|
+
},
|
|
14
16
|
"description": "Arguments passed to the command as they are.",
|
|
15
17
|
"default": []
|
|
16
18
|
},
|
|
17
19
|
"platform": {
|
|
18
20
|
"type": "string",
|
|
19
|
-
"enum": ["ios", "android", "web", "all"],
|
|
20
|
-
"description": "Passed as --platform, for export."
|
|
21
|
+
"enum": ["ios", "android", "macos", "web", "all"],
|
|
22
|
+
"description": "Passed as --platform, for export. Not for macos or package."
|
|
21
23
|
},
|
|
22
24
|
"port": {
|
|
23
25
|
"type": "number",
|
|
24
|
-
"description": "Passed as --port: the port Metro listens on."
|
|
26
|
+
"description": "Passed as --port: the port Metro listens on, or for macos the one the host loads the app from. Not for package, which has no dev server."
|
|
25
27
|
},
|
|
26
28
|
"clear": {
|
|
27
29
|
"type": "boolean",
|
|
28
|
-
"description": "Passed as --clear: start Metro with an empty transform cache."
|
|
30
|
+
"description": "Passed as --clear: start Metro with an empty transform cache. Not for macos or package."
|
|
29
31
|
}
|
|
30
32
|
},
|
|
31
33
|
"required": ["command"]
|
package/builders/spawn-bin.cjs
CHANGED
|
@@ -53,11 +53,12 @@ const SIGNALS = ['SIGINT', 'SIGTERM', 'SIGHUP'];
|
|
|
53
53
|
* @param {string} name
|
|
54
54
|
* @param {string[]} args
|
|
55
55
|
* @param {import('@angular-devkit/architect').BuilderContext} context
|
|
56
|
+
* @param {string} [command] the entry of its `bin` to run, when not named for the package
|
|
56
57
|
* @returns {Promise<{ success: boolean, error?: string }>}
|
|
57
58
|
*/
|
|
58
|
-
async function spawnBin(name, args, context) {
|
|
59
|
+
async function spawnBin(name, args, context, command = name) {
|
|
59
60
|
const cwd = await projectRoot(context);
|
|
60
|
-
return spawnFile(resolveBin(name, cwd), args, cwd,
|
|
61
|
+
return spawnFile(resolveBin(name, cwd, command), args, cwd, command, context);
|
|
61
62
|
}
|
|
62
63
|
|
|
63
64
|
/**
|
package/builders/vitest.cjs
CHANGED
|
@@ -9,9 +9,10 @@
|
|
|
9
9
|
const { createBuilder } = require('@angular-devkit/architect');
|
|
10
10
|
const { spawnBin } = require('./spawn-bin.cjs');
|
|
11
11
|
|
|
12
|
-
/** @param {{ watch?: boolean, filter?: string }} options */
|
|
12
|
+
/** @param {{ watch?: boolean, filter?: string, project?: string }} options */
|
|
13
13
|
function vitestArgs(options) {
|
|
14
14
|
const args = [options.watch ? 'watch' : 'run'];
|
|
15
|
+
if (options.project) args.push('--project', options.project);
|
|
15
16
|
if (options.filter) args.push(options.filter);
|
|
16
17
|
return args;
|
|
17
18
|
}
|
package/builders/vitest.json
CHANGED
|
@@ -12,6 +12,10 @@
|
|
|
12
12
|
"filter": {
|
|
13
13
|
"type": "string",
|
|
14
14
|
"description": "Only test files whose path contains this."
|
|
15
|
+
},
|
|
16
|
+
"project": {
|
|
17
|
+
"type": "string",
|
|
18
|
+
"description": "Only this Vitest project, by its name in vitest.config.mts. A desktop-only app's test target runs node-macos, since its macos project opens the app."
|
|
15
19
|
}
|
|
16
20
|
}
|
|
17
21
|
}
|
package/builders.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"expo": {
|
|
5
5
|
"implementation": "./builders/expo.cjs",
|
|
6
6
|
"schema": "./builders/expo.json",
|
|
7
|
-
"description": "Runs an Expo CLI command in the project: start, export, run:ios, run:android."
|
|
7
|
+
"description": "Runs an Expo CLI command in the project: start, export, run:ios, run:android. macos and package run ng-native-desktop."
|
|
8
8
|
},
|
|
9
9
|
"vitest": {
|
|
10
10
|
"implementation": "./builders/vitest.cjs",
|
package/collection.json
CHANGED
|
@@ -17,6 +17,16 @@
|
|
|
17
17
|
"description": "A component for an Angular Native app, with native elements and a test that runs in Node.",
|
|
18
18
|
"factory": "./component/index.cjs#component",
|
|
19
19
|
"schema": "./component/schema.json"
|
|
20
|
+
},
|
|
21
|
+
"desktop": {
|
|
22
|
+
"description": "Adds macOS to an Angular Native app: @ng-native/desktop, macos in expo.platforms with Expo's out-of-tree platforms flag, the config plugin, and macos and package targets.",
|
|
23
|
+
"factory": "./desktop/index.cjs#desktop",
|
|
24
|
+
"schema": "./desktop/schema.json"
|
|
25
|
+
},
|
|
26
|
+
"mobile": {
|
|
27
|
+
"description": "Adds iOS and Android to a desktop-only Angular Native app: ios and android in expo.platforms with the phone settings, expo-status-bar and expo-system-ui, and run-ios and run-android targets.",
|
|
28
|
+
"factory": "./mobile/index.cjs#mobile",
|
|
29
|
+
"schema": "./mobile/schema.json"
|
|
20
30
|
}
|
|
21
31
|
}
|
|
22
32
|
}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `ng generate @ng-native/schematics:desktop native`: an Angular Native app that runs on macOS too.
|
|
3
|
+
*
|
|
4
|
+
* The project's `app.json` lists `macos` with Expo's `experiments.outOfTreePlatforms` (without it
|
|
5
|
+
* Expo drops `macos` from every bundle and export, and says nothing) and the `@ng-native/desktop`
|
|
6
|
+
* config plugin. The workspace depends on `@ng-native/desktop`, and the project gains two targets on
|
|
7
|
+
* the `expo` builder: `ng run native:macos` builds the desktop host and opens the app from the dev
|
|
8
|
+
* server `ng serve native` runs, and `ng run native:package` makes the `.app`, `.dmg` or Mac App
|
|
9
|
+
* Store package.
|
|
10
|
+
*
|
|
11
|
+
* It only adds, so running it again changes nothing.
|
|
12
|
+
*/
|
|
13
|
+
const path = require('node:path').posix;
|
|
14
|
+
const { workspaces } = require('@angular-devkit/core');
|
|
15
|
+
const { SchematicsException } = require('@angular-devkit/schematics');
|
|
16
|
+
const { NodePackageInstallTask } = require('@angular-devkit/schematics/tasks');
|
|
17
|
+
const native = require('../native-app.cjs');
|
|
18
|
+
|
|
19
|
+
function readJson(tree, file) {
|
|
20
|
+
return JSON.parse(tree.readText(file));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Writes `value` as JSON, only where it differs from what is there. */
|
|
24
|
+
function writeJson(tree, file, value) {
|
|
25
|
+
const text = JSON.stringify(value, null, 2) + '\n';
|
|
26
|
+
if (!tree.exists(file)) tree.create(file, text);
|
|
27
|
+
else if (tree.readText(file) !== text) tree.overwrite(file, text);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The port the project's `serve` target runs Metro on, from its `port` option or a `--port` in its
|
|
32
|
+
* `args`, or undefined for Expo's default. The `macos` target loads the app from it.
|
|
33
|
+
*/
|
|
34
|
+
function servePort(project) {
|
|
35
|
+
const serve = project?.targets.get('serve');
|
|
36
|
+
// Angular lays each default configuration's options over the target's own, in order, a later
|
|
37
|
+
// value replacing an earlier one whole.
|
|
38
|
+
const names = (serve?.defaultConfiguration ?? '').split(',').map((name) => name.trim());
|
|
39
|
+
const layers = names.filter(Boolean).map((name) => serve.configurations?.[name] ?? {});
|
|
40
|
+
return portOf(Object.assign({}, serve?.options, ...layers));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** The port a set of `serve` options names, as `port` or as `--port` in `args`. */
|
|
44
|
+
function portOf(options = {}) {
|
|
45
|
+
if (typeof options.port === 'number') return options.port;
|
|
46
|
+
const args = Array.isArray(options.args) ? options.args.map(String) : [];
|
|
47
|
+
const at = args.findIndex((arg) => arg === '--port' || arg.startsWith('--port='));
|
|
48
|
+
if (at < 0) return undefined;
|
|
49
|
+
const value = args[at].includes('=') ? args[at].split('=')[1] : args[at + 1];
|
|
50
|
+
return /^\d+$/.test(value ?? '') ? Number(value) : undefined;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* The two targets, each on the `expo` builder, which runs `ng-native-desktop` for them. `macos`
|
|
55
|
+
* takes the `serve` target's port, so the host loads from the dev server `ng serve` runs.
|
|
56
|
+
*/
|
|
57
|
+
function desktopTargets(port) {
|
|
58
|
+
const desktop = (command, extra) => ({
|
|
59
|
+
builder: '@ng-native/schematics:expo',
|
|
60
|
+
options: { command, ...extra },
|
|
61
|
+
});
|
|
62
|
+
return { macos: desktop('macos', port ? { port } : {}), package: desktop('package') };
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** The project's `app.json` with `withOs` applied to its Expo config. */
|
|
66
|
+
function updateAppJson(tree, file, withOs) {
|
|
67
|
+
const config = readJson(tree, file);
|
|
68
|
+
writeJson(tree, file, { ...config, expo: withOs(config.expo ?? {}) });
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* `angular.json` as the Angular CLI reads it, comments and trailing commas allowed, and written
|
|
73
|
+
* back with them kept: Angular's own workspace reader and writer, over the schematic's tree.
|
|
74
|
+
*/
|
|
75
|
+
function workspaceHost(tree) {
|
|
76
|
+
return {
|
|
77
|
+
readFile: async (file) => tree.readText(file),
|
|
78
|
+
writeFile: async (file, data) => tree.overwrite(file, data),
|
|
79
|
+
isDirectory: async (dir) => !tree.exists(dir) && tree.getDir(dir).subfiles.length > 0,
|
|
80
|
+
isFile: async (file) => tree.exists(file),
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** Each of `wanted` the manifest at `file` lacks, added to its dependencies. */
|
|
85
|
+
function addDependencies(tree, file, wanted) {
|
|
86
|
+
if (!tree.exists(file)) return;
|
|
87
|
+
const manifest = readJson(tree, file);
|
|
88
|
+
const existing = { ...manifest.dependencies, ...manifest.devDependencies };
|
|
89
|
+
const added = Object.entries(wanted).filter(([name]) => !(name in existing));
|
|
90
|
+
if (!added.length) return;
|
|
91
|
+
manifest.dependencies = Object.fromEntries(
|
|
92
|
+
[...Object.entries(manifest.dependencies ?? {}), ...added].sort(([a], [b]) => (a < b ? -1 : 1)),
|
|
93
|
+
);
|
|
94
|
+
writeJson(tree, file, manifest);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** The lines of `native.DESKTOP_GITIGNORE` the project's `.gitignore` lacks, appended. */
|
|
98
|
+
function ignorePackages(tree, root) {
|
|
99
|
+
const file = path.join(root, '.gitignore');
|
|
100
|
+
const ignore = tree.exists(file) ? tree.readText(file) : '';
|
|
101
|
+
const rules = native.DESKTOP_GITIGNORE.split('\n').filter(
|
|
102
|
+
(line) => line && !line.startsWith('#'),
|
|
103
|
+
);
|
|
104
|
+
if (rules.every((rule) => ignore.split('\n').includes(rule))) return;
|
|
105
|
+
const separator = ignore === '' ? '' : ignore.endsWith('\n') ? '\n' : '\n\n';
|
|
106
|
+
const text = `${ignore}${separator}${native.DESKTOP_GITIGNORE}`;
|
|
107
|
+
if (tree.exists(file)) tree.overwrite(file, text);
|
|
108
|
+
else tree.create(file, text);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* @param {{ project: string, skipInstall?: boolean }} options
|
|
113
|
+
*/
|
|
114
|
+
function desktop(options) {
|
|
115
|
+
return async (tree, context) => {
|
|
116
|
+
if (!tree.exists('angular.json')) {
|
|
117
|
+
throw new SchematicsException('No angular.json here. Run this in an Angular CLI workspace.');
|
|
118
|
+
}
|
|
119
|
+
const host = workspaceHost(tree);
|
|
120
|
+
const { workspace } = await workspaces.readWorkspace(
|
|
121
|
+
'angular.json',
|
|
122
|
+
host,
|
|
123
|
+
workspaces.WorkspaceFormat.JSON,
|
|
124
|
+
);
|
|
125
|
+
const project = workspace.projects.get(options.project);
|
|
126
|
+
if (!project) {
|
|
127
|
+
throw new SchematicsException(`angular.json has no project called "${options.project}".`);
|
|
128
|
+
}
|
|
129
|
+
const root = project.root ?? '';
|
|
130
|
+
const appJson = path.join(root, 'app.json');
|
|
131
|
+
if (!tree.exists(appJson)) {
|
|
132
|
+
throw new SchematicsException(
|
|
133
|
+
`${options.project} is not an Angular Native app: it has no ${appJson}. Make one with ` +
|
|
134
|
+
'ng add @ng-native/schematics, or ng generate @ng-native/schematics:application.',
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
updateAppJson(tree, appJson, native.withDesktop);
|
|
138
|
+
addDependencies(tree, 'package.json', native.desktopDependencies);
|
|
139
|
+
ignorePackages(tree, root);
|
|
140
|
+
const missing = Object.entries(desktopTargets(servePort(project))).filter(
|
|
141
|
+
([name]) => !project.targets.has(name),
|
|
142
|
+
);
|
|
143
|
+
for (const [name, target] of missing) project.targets.add({ name, ...target });
|
|
144
|
+
if (missing.length) await workspaces.writeWorkspace(workspace, host);
|
|
145
|
+
|
|
146
|
+
if (!options.skipInstall) context.addTask(new NodePackageInstallTask());
|
|
147
|
+
context.logger.info(
|
|
148
|
+
`${options.project} runs on macOS: ng serve ${options.project}, then ` +
|
|
149
|
+
`ng run ${options.project}:macos. ng run ${options.project}:package makes the app.`,
|
|
150
|
+
);
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
module.exports = {
|
|
155
|
+
desktop,
|
|
156
|
+
desktopTargets,
|
|
157
|
+
servePort,
|
|
158
|
+
workspaceHost,
|
|
159
|
+
updateAppJson,
|
|
160
|
+
addDependencies,
|
|
161
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema",
|
|
3
|
+
"$id": "NgNativeDesktop",
|
|
4
|
+
"title": "macOS in an Angular Native app",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"project": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"description": "The Angular Native app, by its name in angular.json.",
|
|
10
|
+
"$default": {
|
|
11
|
+
"$source": "argv",
|
|
12
|
+
"index": 0
|
|
13
|
+
},
|
|
14
|
+
"x-prompt": "Which native app should run on macOS?"
|
|
15
|
+
},
|
|
16
|
+
"skipInstall": {
|
|
17
|
+
"type": "boolean",
|
|
18
|
+
"description": "Write the files and package.json without installing.",
|
|
19
|
+
"default": false
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"required": ["project"]
|
|
23
|
+
}
|
package/files/AGENTS.md
CHANGED
|
@@ -58,12 +58,13 @@ change; both are fast.
|
|
|
58
58
|
- `[style]` takes a React Native style object: camelCase keys, numbers in points
|
|
59
59
|
(`{ padding: 16, backgroundColor: '#fff' }`).
|
|
60
60
|
- A component's `styles` is real CSS, compiled at build time: type, class, id and attribute
|
|
61
|
-
selectors, combinators, `:host`, `@media`, custom properties, transitions and `@keyframes
|
|
62
|
-
|
|
63
|
-
naming the file, line and reason - lay out
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
- Tailwind v4 works through `@ng-native/tailwind`, with `ios:`, `android
|
|
61
|
+
selectors, combinators, `:host`, `@media`, custom properties, transitions and `@keyframes`, and
|
|
62
|
+
`:active`, `:focus`, `:hover`, `:focus-visible` and `:focus-within`. Float and
|
|
63
|
+
`::before`/`::after` are dropped with a build warning naming the file, line and reason - lay out
|
|
64
|
+
with flexbox, grid or a block. Everything is `display: flex` with `flex-direction: column` by
|
|
65
|
+
default, as in React Native.
|
|
66
|
+
- Tailwind v4 works through `@ng-native/tailwind`, with `ios:`, `android:`, `macos:`, `desktop:`
|
|
67
|
+
and `dark:` variants.
|
|
67
68
|
|
|
68
69
|
## Lists, navigation, forms
|
|
69
70
|
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# AGENTS.md
|
|
2
|
+
|
|
3
|
+
This is an Angular app rendering real native macOS views (AppKit) with
|
|
4
|
+
[Angular Native](https://ng-native.com): Angular components on React Native's Fabric renderer, in
|
|
5
|
+
the `@ng-native/desktop` host. Expo is the build tool (CLI, config, autolinking, Metro), not the
|
|
6
|
+
runtime. It is not a web app, not Electron and not React: there is no DOM, no web view and no JSX.
|
|
7
|
+
|
|
8
|
+
The whole documentation, for reading before a change: https://ng-native.com/llms-full.txt. An
|
|
9
|
+
outline with a line per page: https://ng-native.com/llms.txt.
|
|
10
|
+
|
|
11
|
+
Angular's own rules apply as well: https://angular.dev/assets/context/best-practices.md. Its
|
|
12
|
+
browser-only parts do not: there is no `NgOptimizedImage` (use `<image>`), and no AXE
|
|
13
|
+
(accessibility is the props below). Where the two disagree, this file wins.
|
|
14
|
+
|
|
15
|
+
## Commands
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
npm start # Metro, the dev server the app loads from
|
|
19
|
+
npm run macos # builds the desktop host (the first time) and opens the app from Metro
|
|
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
|
|
23
|
+
npm run typecheck
|
|
24
|
+
npm run package # the .app
|
|
25
|
+
npm run package -- --format dmg # a signed, notarised download; --format mas for the Mac App Store
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
`src/main.ts` mounts the root component, `src/app/app.ts`. Run `npm test` and `npm run typecheck` after a
|
|
29
|
+
change; both are fast.
|
|
30
|
+
|
|
31
|
+
## Rules that are easy to get wrong
|
|
32
|
+
|
|
33
|
+
- **Element names are lowercase:** `<view>`, `<text>`, `<pressable>`, `<scroll-view>`,
|
|
34
|
+
`<text-input>`, `<image>`, `<switch>`, `<safe-area-view>`, `<virtual-list>`, `<modal>`. Each is
|
|
35
|
+
imported from `@ng-native/components` into the component's `imports`, like any Angular
|
|
36
|
+
component: `imports: [View, Text]`. `<View>` matches no component and fails the build, and an element used
|
|
37
|
+
without its import renders as a plain view.
|
|
38
|
+
- **There is no DOM.** No `document`, no `window`, no `<button>`, `<a>`, `<input>` or `<img>`, no
|
|
39
|
+
`@angular/platform-browser`, and no `@angular/animations`. Use the native elements above. HTML's
|
|
40
|
+
text elements (`p`, `span`, `h1`, `strong`) draw as text and its layout elements (`div`,
|
|
41
|
+
`section`, `ul`) as plain views, with none of a browser's default styles.
|
|
42
|
+
- **A component's host is a flex item.** `<app-case-list />` commits as a view of its own, with no
|
|
43
|
+
`flex`, so a `flex: 1` scroll view inside it gets a height of zero and shows nothing. A component
|
|
44
|
+
that fills the space it is given sets `host: { style: 'flex: 1' }` (or `:host { flex: 1; }`).
|
|
45
|
+
- **Text is drawn in a text element.** `<text>` is the one with inputs and outputs (`numberOfLines`,
|
|
46
|
+
`(press)`). `p`, `span` and the other HTML text elements are text while they hold only text and
|
|
47
|
+
other text elements; one that holds a view is a view. Text written straight into a view is given
|
|
48
|
+
a paragraph of its own, one per run, and never flows inline with the elements beside it.
|
|
49
|
+
- **Events are native:** `(press)` on `<pressable>`, not `(click)`; `[(value)]` or `(changeText)` on
|
|
50
|
+
`<text-input>`; `(scroll)`, `(layout)`. A pressable text is `<text pressable (press)="...">`.
|
|
51
|
+
- **Signals, zoneless, AOT.** State is signals and `computed()`; there is no zone.js, so nothing
|
|
52
|
+
updates from a plain field changing outside a signal or an event.
|
|
53
|
+
- **No backticks inside an inline template**, even in an HTML comment: they end the template string
|
|
54
|
+
and the build fails with a misleading parse error.
|
|
55
|
+
- **Accessibility is props:** `accessibilityRole="button"`, `accessibilityLabel`,
|
|
56
|
+
`[accessibilityState]`. The web spellings work too, as aliases: `role`, and the `aria-*` names
|
|
57
|
+
React Native maps (`aria-label`, `aria-checked`, `aria-hidden` and so on). Screen readers and
|
|
58
|
+
the testing library's `getByRole` both read them.
|
|
59
|
+
|
|
60
|
+
## Styling
|
|
61
|
+
|
|
62
|
+
- `[style]` takes a React Native style object: camelCase keys, numbers in points
|
|
63
|
+
(`{ padding: 16, backgroundColor: '#fff' }`).
|
|
64
|
+
- A component's `styles` is real CSS, compiled at build time: type, class, id and attribute
|
|
65
|
+
selectors, combinators, `:host`, `@media`, custom properties, transitions and `@keyframes`, and
|
|
66
|
+
`:active`, `:focus`, `:hover`, `:focus-visible` and `:focus-within`. Float and
|
|
67
|
+
`::before`/`::after` are dropped with a build warning naming the file, line and reason - lay out
|
|
68
|
+
with flexbox, grid or a block. Everything is `display: flex` with `flex-direction: column` by
|
|
69
|
+
default, as in React Native.
|
|
70
|
+
- Tailwind v4 works through `@ng-native/tailwind`, with `ios:`, `android:`, `macos:`, `desktop:`
|
|
71
|
+
and `dark:` variants.
|
|
72
|
+
|
|
73
|
+
## Lists, navigation, forms
|
|
74
|
+
|
|
75
|
+
- A long list is `<virtual-list>`: `@for (row of list.window(); track row.slot)` recycles rows as
|
|
76
|
+
they scroll. `<scroll-view>` renders everything, so keep it for short content.
|
|
77
|
+
- Navigation is `@angular/router` on native stacks and tabs: `provideNativeRouter(routes)` from
|
|
78
|
+
`@ng-native/router` in `mount`'s `providers`, and `<native-stack-outlet />` in a template. Add
|
|
79
|
+
`withComponentInputBinding()` from `@angular/router` for route params to arrive as inputs, in
|
|
80
|
+
tests too.
|
|
81
|
+
- Forms are Signal Forms (`@angular/forms/signals`), with `[formField]` on `<text-input>` and
|
|
82
|
+
`<switch>`.
|
|
83
|
+
- HTTP needs `provideNativeHttpClient()` from `@ng-native/platform/http`, not `provideHttpClient()`.
|
|
84
|
+
|
|
85
|
+
## Tests
|
|
86
|
+
|
|
87
|
+
`app.test.ts` shows the shape: `render(Component)`, then query with `screen.getByRole`,
|
|
88
|
+
`getByText` or `getByTestId` (which matches `nativeID` and `testID`), and act with
|
|
89
|
+
`userEvent.setup().press(...)` or `.type(...)`, all from `@ng-native/testing`. Tests run in Node
|
|
90
|
+
with no simulator, so write one alongside a change.
|
|
91
|
+
|
|
92
|
+
A service that depends on the platform injects `OS` and `OS_VERSION` from `@ng-native/device`
|
|
93
|
+
rather than importing `Platform` from `react-native`, which a test cannot load. A test provides
|
|
94
|
+
the values it wants: `{ provide: OS, useValue: 'android' }`.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const { getDefaultConfig } = require('expo/metro-config');
|
|
2
|
+
const { withAngularNative } = require('@ng-native/metro/config.cjs');
|
|
3
|
+
const { withDeviceTests } = require('@ng-native/testing/device/metro');
|
|
4
|
+
|
|
5
|
+
// Registers the transformer that compiles Angular ahead of time, compiles each component's CSS
|
|
6
|
+
// into the sheet the engine reads, and adds the polyfills Angular needs before `@angular/core`
|
|
7
|
+
// is first evaluated. No options: the framework packages are ordinary dependencies here.
|
|
8
|
+
// `withDeviceTests` does nothing until Metro starts with EXPO_PUBLIC_DEVICE_TESTS set, for the
|
|
9
|
+
// tests that run inside the app.
|
|
10
|
+
module.exports = withDeviceTests(withAngularNative(getDefaultConfig(__dirname)));
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Platform } from 'react-native';
|
|
2
|
+
import { expect, it } from 'vitest';
|
|
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');
|
|
8
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { ErrorHandler } from '@angular/core';
|
|
2
|
+
import { Clipboard, type NativeClipboard } from '@ng-native/expo/clipboard';
|
|
3
|
+
import { render, screen, userEvent } from '@ng-native/testing';
|
|
4
|
+
import { expect, test } from 'vitest';
|
|
5
|
+
import { App } from './app.ts';
|
|
6
|
+
|
|
7
|
+
test('goes to a page from the menu bar and copies its title', async () => {
|
|
8
|
+
const copied: string[] = [];
|
|
9
|
+
const clipboard: NativeClipboard = {
|
|
10
|
+
getStringAsync: async () => copied.at(-1) ?? '',
|
|
11
|
+
setStringAsync: async (text) => (copied.push(text), true),
|
|
12
|
+
addClipboardListener: () => ({ remove: () => {} }),
|
|
13
|
+
};
|
|
14
|
+
await render(App, { providers: [{ provide: Clipboard.SOURCE, useValue: clipboard }] });
|
|
15
|
+
const user = userEvent.setup();
|
|
16
|
+
|
|
17
|
+
expect(await userEvent.keyboard('mod+2')).toBe(true);
|
|
18
|
+
expect(screen.getByRole('header', { name: 'Notes' })).toBeTruthy();
|
|
19
|
+
|
|
20
|
+
await user.press(screen.getByRole('button', { name: 'Copy Title' }));
|
|
21
|
+
expect(copied).toEqual(['Notes']);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test("hands a copy the clipboard refuses to Angular's ErrorHandler", async () => {
|
|
25
|
+
const refused = new Error('no clipboard');
|
|
26
|
+
const clipboard: NativeClipboard = {
|
|
27
|
+
getStringAsync: async () => '',
|
|
28
|
+
setStringAsync: async () => Promise.reject(refused),
|
|
29
|
+
addClipboardListener: () => ({ remove: () => {} }),
|
|
30
|
+
};
|
|
31
|
+
const handled: unknown[] = [];
|
|
32
|
+
await render(App, {
|
|
33
|
+
providers: [
|
|
34
|
+
{ provide: Clipboard.SOURCE, useValue: clipboard },
|
|
35
|
+
{ provide: ErrorHandler, useValue: { handleError: (error: unknown) => handled.push(error) } },
|
|
36
|
+
],
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
await userEvent.setup().press(screen.getByRole('button', { name: 'Copy Title' }));
|
|
40
|
+
expect(handled).toEqual([refused]);
|
|
41
|
+
expect(screen.queryByText(/^Copied/)).toBeNull();
|
|
42
|
+
});
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { Component, computed, ErrorHandler, inject, signal } from '@angular/core';
|
|
2
|
+
import {
|
|
3
|
+
MenuBar,
|
|
4
|
+
MenuGroup,
|
|
5
|
+
MenuItem,
|
|
6
|
+
NativeButton,
|
|
7
|
+
SafeAreaProvider,
|
|
8
|
+
SafeAreaView,
|
|
9
|
+
Sidebar,
|
|
10
|
+
SidebarItem,
|
|
11
|
+
SidebarSection,
|
|
12
|
+
SplitView,
|
|
13
|
+
Text,
|
|
14
|
+
} from '@ng-native/components';
|
|
15
|
+
// @ng-native/expo holds the services whose mobile source is Expo; on macOS the desktop host answers.
|
|
16
|
+
import { Clipboard } from '@ng-native/expo/clipboard';
|
|
17
|
+
|
|
18
|
+
interface Page {
|
|
19
|
+
readonly id: string;
|
|
20
|
+
readonly label: string;
|
|
21
|
+
readonly sfSymbol: string;
|
|
22
|
+
readonly hint: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const PAGES: readonly Page[] = [
|
|
26
|
+
{ id: 'home', label: 'Home', sfSymbol: 'house', hint: 'A native macOS app, written in Angular.' },
|
|
27
|
+
{ id: 'notes', label: 'Notes', sfSymbol: 'note.text', hint: 'Real AppKit views, no web view.' },
|
|
28
|
+
{ id: 'settings', label: 'Settings', sfSymbol: 'gearshape', hint: 'One runtime: no IPC.' },
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Element names are lowercase, and that is load-bearing rather than style: an uppercase name such
|
|
33
|
+
* as <View> matches no component's selector, and the Metro transform fails the build on it.
|
|
34
|
+
*
|
|
35
|
+
* Sizes are a phone's by default and a Mac's under :host-context(.platform-macos), so the app is
|
|
36
|
+
* Mac-sized now and still fits a phone if iOS or Android is added later.
|
|
37
|
+
*/
|
|
38
|
+
@Component({
|
|
39
|
+
imports: [
|
|
40
|
+
MenuBar,
|
|
41
|
+
MenuGroup,
|
|
42
|
+
MenuItem,
|
|
43
|
+
NativeButton,
|
|
44
|
+
SafeAreaProvider,
|
|
45
|
+
SafeAreaView,
|
|
46
|
+
Sidebar,
|
|
47
|
+
SidebarItem,
|
|
48
|
+
SidebarSection,
|
|
49
|
+
SplitView,
|
|
50
|
+
Text,
|
|
51
|
+
],
|
|
52
|
+
selector: 'app-root',
|
|
53
|
+
template: `
|
|
54
|
+
<menu-bar>
|
|
55
|
+
<menu-group label="Go" menuRole="view">
|
|
56
|
+
@for (page of pages; track page.id; let i = $index) {
|
|
57
|
+
<menu-item [label]="page.label" [shortcut]="'mod+' + (i + 1)" (select)="show(page.id)" />
|
|
58
|
+
}
|
|
59
|
+
</menu-group>
|
|
60
|
+
<menu-group label="Edit" menuRole="edit">
|
|
61
|
+
<menu-item label="Copy Page Title" shortcut="mod+shift+c" (select)="copyTitle()" />
|
|
62
|
+
</menu-group>
|
|
63
|
+
</menu-bar>
|
|
64
|
+
|
|
65
|
+
<safe-area-provider>
|
|
66
|
+
<split-view>
|
|
67
|
+
<sidebar minWidth="180" autosave="main">
|
|
68
|
+
<sidebar-section title="My App">
|
|
69
|
+
@for (page of pages; track page.id) {
|
|
70
|
+
<sidebar-item
|
|
71
|
+
[label]="page.label"
|
|
72
|
+
[sfSymbol]="page.sfSymbol"
|
|
73
|
+
[selected]="page.id === current().id"
|
|
74
|
+
(select)="show(page.id)"
|
|
75
|
+
/>
|
|
76
|
+
}
|
|
77
|
+
</sidebar-section>
|
|
78
|
+
</sidebar>
|
|
79
|
+
|
|
80
|
+
<safe-area-view class="content">
|
|
81
|
+
<text class="title" accessibilityRole="header">{{ current().label }}</text>
|
|
82
|
+
<text class="hint">{{ current().hint }}</text>
|
|
83
|
+
<native-button (press)="copyTitle()">Copy Title</native-button>
|
|
84
|
+
@if (copied()) {
|
|
85
|
+
<text class="hint">Copied {{ copied() }}.</text>
|
|
86
|
+
}
|
|
87
|
+
</safe-area-view>
|
|
88
|
+
</split-view>
|
|
89
|
+
</safe-area-provider>
|
|
90
|
+
`,
|
|
91
|
+
styles: `
|
|
92
|
+
:host {
|
|
93
|
+
flex: 1;
|
|
94
|
+
}
|
|
95
|
+
.content {
|
|
96
|
+
flex: 1;
|
|
97
|
+
gap: 12px;
|
|
98
|
+
padding: 24px;
|
|
99
|
+
align-items: flex-start;
|
|
100
|
+
background-color: #ffffff;
|
|
101
|
+
}
|
|
102
|
+
.title {
|
|
103
|
+
color: #101014;
|
|
104
|
+
font-size: 28px;
|
|
105
|
+
font-weight: 700;
|
|
106
|
+
}
|
|
107
|
+
.hint {
|
|
108
|
+
color: #5f5f6b;
|
|
109
|
+
font-size: 15px;
|
|
110
|
+
}
|
|
111
|
+
:host-context(.platform-macos) .content {
|
|
112
|
+
gap: 8px;
|
|
113
|
+
padding: 20px;
|
|
114
|
+
}
|
|
115
|
+
:host-context(.platform-macos) .title {
|
|
116
|
+
font-size: 22px;
|
|
117
|
+
}
|
|
118
|
+
:host-context(.platform-macos) .hint {
|
|
119
|
+
font-size: 13px;
|
|
120
|
+
}
|
|
121
|
+
@media (prefers-color-scheme: dark) {
|
|
122
|
+
.content {
|
|
123
|
+
background-color: #1e1e20;
|
|
124
|
+
}
|
|
125
|
+
.title {
|
|
126
|
+
color: #ffffff;
|
|
127
|
+
}
|
|
128
|
+
.hint {
|
|
129
|
+
color: #8b8b96;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
`,
|
|
133
|
+
})
|
|
134
|
+
export class App {
|
|
135
|
+
private readonly clipboard = inject(Clipboard);
|
|
136
|
+
private readonly errors = inject(ErrorHandler);
|
|
137
|
+
|
|
138
|
+
protected readonly pages = PAGES;
|
|
139
|
+
private readonly selected = signal(PAGES[0]!.id);
|
|
140
|
+
protected readonly current = computed(
|
|
141
|
+
() => PAGES.find((page) => page.id === this.selected()) ?? PAGES[0]!,
|
|
142
|
+
);
|
|
143
|
+
protected readonly copied = signal('');
|
|
144
|
+
|
|
145
|
+
protected show(id: string): void {
|
|
146
|
+
this.selected.set(id);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
protected async copyTitle(): Promise<void> {
|
|
150
|
+
const title = this.current().label;
|
|
151
|
+
// A handler's promise goes nowhere, so a refused copy goes to the ErrorHandler.
|
|
152
|
+
try {
|
|
153
|
+
await this.clipboard.write(title);
|
|
154
|
+
this.copied.set(title);
|
|
155
|
+
} catch (error) {
|
|
156
|
+
this.errors.handleError(error);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// Expo's runtime: its fetch, whose response streams a body, and URL, TextDecoderStream and
|
|
2
|
+
// structuredClone. Metro runs it before this file only when something imports it, and nothing
|
|
3
|
+
// else does in a release build, which would then get React Native's fetch, with no body.
|
|
4
|
+
import 'expo';
|
|
5
|
+
import { AppRegistry, Image, Platform, processColor } from 'react-native';
|
|
6
|
+
import { mount } from '@ng-native/platform';
|
|
7
|
+
import { currentConditions, deviceTokens, watchConditions } from '@ng-native/device';
|
|
8
|
+
import { getFabricUIManager, registerPlatformComponents } from '@ng-native/fabric';
|
|
9
|
+
import { App } from './app/app.ts';
|
|
10
|
+
|
|
11
|
+
registerPlatformComponents(Platform.OS);
|
|
12
|
+
|
|
13
|
+
/** What `mount` takes, for the app and for the tests that run inside it. */
|
|
14
|
+
const mountOptions = () => ({
|
|
15
|
+
// Colours, as the integers the platform wants.
|
|
16
|
+
processColor,
|
|
17
|
+
// What `@media` resolves against. Without it every media query is false and a responsive
|
|
18
|
+
// layout renders as its smallest case.
|
|
19
|
+
conditions: currentConditions(),
|
|
20
|
+
// Values only the device knows - the hairline width, which is a third of a point on a 3x
|
|
21
|
+
// screen. Without it `1px` is what you get, and that is a visibly fat divider.
|
|
22
|
+
tokens: deviceTokens(),
|
|
23
|
+
// Turns a `require('./x.png')` into something native can load. Without it images are blank.
|
|
24
|
+
resolveAssetSource: (value: unknown) => Image.resolveAssetSource(value as never),
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
if (process.env.EXPO_PUBLIC_DEVICE_TESTS) {
|
|
28
|
+
// Metro was started for `vitest --project macos`: the test host, not the app.
|
|
29
|
+
const { startDeviceTests } =
|
|
30
|
+
require('@ng-native/testing/device/host') as typeof import('@ng-native/testing/device/host');
|
|
31
|
+
startDeviceTests({ mount: mountOptions() });
|
|
32
|
+
} else {
|
|
33
|
+
AppRegistry.registerRunnable('main', ({ rootTag }) => {
|
|
34
|
+
const app = mount(Number(rootTag), App, getFabricUIManager(), mountOptions());
|
|
35
|
+
|
|
36
|
+
// Re-resolves the conditions when the device rotates or the theme changes. A rotation dirties
|
|
37
|
+
// no component and no binding, so without this nothing re-renders and `dark:` stops following
|
|
38
|
+
// the system switch. It stops with the app, which Android destroys when it recreates the
|
|
39
|
+
// activity, so the app mounted in its place is the only one still watching.
|
|
40
|
+
const stopWatching = watchConditions(app.engine);
|
|
41
|
+
app.applicationRef.onDestroy(stopWatching);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ngNative } from '@ng-native/testing/vitest';
|
|
2
|
+
import { deviceTests } from '@ng-native/testing/device/vitest';
|
|
3
|
+
import { defineConfig } from 'vitest/config';
|
|
4
|
+
|
|
5
|
+
// Two projects. `node-macos` compiles Angular for the tests the way Metro compiles it for the app
|
|
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.
|
|
9
|
+
export default defineConfig({
|
|
10
|
+
test: {
|
|
11
|
+
projects: [
|
|
12
|
+
{ plugins: [ngNative({ os: 'macos' })], test: { name: 'node-macos' } },
|
|
13
|
+
{ plugins: [deviceTests({ platform: 'macos' })] },
|
|
14
|
+
],
|
|
15
|
+
},
|
|
16
|
+
});
|
package/migrations.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"$schema": "../../node_modules/@angular-devkit/schematics/collection-schema.json",
|
|
3
3
|
"schematics": {
|
|
4
4
|
"sync-app-versions": {
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.23.0",
|
|
6
6
|
"description": "Move the @ng-native packages each project's own package.json lists to the new version.",
|
|
7
7
|
"factory": "./migrations/run.cjs#sync-app-versions"
|
|
8
8
|
},
|
|
@@ -50,6 +50,16 @@
|
|
|
50
50
|
"version": "0.18.1",
|
|
51
51
|
"description": "Resolve the workspace's path aliases in Nx Vitest configs with vite-tsconfig-paths, as nxViteTsPaths does nothing from Nx 24.",
|
|
52
52
|
"factory": "./migrations/run.cjs#vitest-tsconfig-paths"
|
|
53
|
+
},
|
|
54
|
+
"os-comparisons-on-macos": {
|
|
55
|
+
"version": "0.23.0",
|
|
56
|
+
"description": "Note each comparison with 'ios', which answers differently now that macOS is reported as 'macos', and each !== 'android' and OS_VERSION comparison, which a Mac passes into a branch that may be written for iOS.",
|
|
57
|
+
"factory": "./migrations/run.cjs#os-comparisons-on-macos"
|
|
58
|
+
},
|
|
59
|
+
"available-signal": {
|
|
60
|
+
"version": "0.23.0",
|
|
61
|
+
"description": "Call each service's available, now a Signal<boolean> on every service, and stop awaiting it.",
|
|
62
|
+
"factory": "./migrations/run.cjs#available-signal"
|
|
53
63
|
}
|
|
54
64
|
}
|
|
55
65
|
}
|
package/mobile/index.cjs
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `ng generate @ng-native/schematics:mobile native`: a desktop-only Angular Native app that runs on
|
|
3
|
+
* iOS and Android too, undoing what `--desktop-only` left out.
|
|
4
|
+
*
|
|
5
|
+
* The project's `app.json` lists `ios` and `android` beside `macos`, with the phone settings a
|
|
6
|
+
* mobile app's has. The workspace and the project's own `package.json`, whose native modules Expo
|
|
7
|
+
* autolinks, depend on the phone's status bar and system UI packages again. And the project gains
|
|
8
|
+
* `run-ios` and `run-android` on the `expo` builder, on the `serve` target's port.
|
|
9
|
+
*
|
|
10
|
+
* It only adds, so running it again changes nothing.
|
|
11
|
+
*/
|
|
12
|
+
const path = require('node:path').posix;
|
|
13
|
+
const { workspaces } = require('@angular-devkit/core');
|
|
14
|
+
const { SchematicsException } = require('@angular-devkit/schematics');
|
|
15
|
+
const { NodePackageInstallTask } = require('@angular-devkit/schematics/tasks');
|
|
16
|
+
const native = require('../native-app.cjs');
|
|
17
|
+
const {
|
|
18
|
+
servePort,
|
|
19
|
+
workspaceHost,
|
|
20
|
+
updateAppJson,
|
|
21
|
+
addDependencies,
|
|
22
|
+
} = require('../desktop/index.cjs');
|
|
23
|
+
|
|
24
|
+
/** The two targets, each on the `expo` builder, on the port `ng serve` runs Metro on. */
|
|
25
|
+
function mobileTargets(port) {
|
|
26
|
+
const expo = (command) => ({
|
|
27
|
+
builder: '@ng-native/schematics:expo',
|
|
28
|
+
options: { command, ...(port ? { port } : {}) },
|
|
29
|
+
});
|
|
30
|
+
return { 'run-ios': expo('run:ios'), 'run-android': expo('run:android') };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @param {{ project: string, skipInstall?: boolean }} options
|
|
35
|
+
*/
|
|
36
|
+
function mobile(options) {
|
|
37
|
+
return async (tree, context) => {
|
|
38
|
+
if (!tree.exists('angular.json')) {
|
|
39
|
+
throw new SchematicsException('No angular.json here. Run this in an Angular CLI workspace.');
|
|
40
|
+
}
|
|
41
|
+
const host = workspaceHost(tree);
|
|
42
|
+
const { workspace } = await workspaces.readWorkspace(
|
|
43
|
+
'angular.json',
|
|
44
|
+
host,
|
|
45
|
+
workspaces.WorkspaceFormat.JSON,
|
|
46
|
+
);
|
|
47
|
+
const project = workspace.projects.get(options.project);
|
|
48
|
+
if (!project) {
|
|
49
|
+
throw new SchematicsException(`angular.json has no project called "${options.project}".`);
|
|
50
|
+
}
|
|
51
|
+
const root = project.root ?? '';
|
|
52
|
+
const appJson = path.join(root, 'app.json');
|
|
53
|
+
if (!tree.exists(appJson)) {
|
|
54
|
+
throw new SchematicsException(
|
|
55
|
+
`${options.project} is not an Angular Native app: it has no ${appJson}. Make one with ` +
|
|
56
|
+
'ng add @ng-native/schematics, or ng generate @ng-native/schematics:application.',
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
updateAppJson(tree, appJson, native.withMobile);
|
|
60
|
+
for (const manifest of ['package.json', path.join(root, 'package.json')]) {
|
|
61
|
+
addDependencies(tree, manifest, native.mobileDependencies);
|
|
62
|
+
}
|
|
63
|
+
const missing = Object.entries(mobileTargets(servePort(project))).filter(
|
|
64
|
+
([name]) => !project.targets.has(name),
|
|
65
|
+
);
|
|
66
|
+
for (const [name, target] of missing) project.targets.add({ name, ...target });
|
|
67
|
+
if (missing.length) await workspaces.writeWorkspace(workspace, host);
|
|
68
|
+
|
|
69
|
+
if (!options.skipInstall) context.addTask(new NodePackageInstallTask());
|
|
70
|
+
context.logger.info(
|
|
71
|
+
`${options.project} runs on iOS and Android: ng run ${options.project}:run-ios, or ` +
|
|
72
|
+
`ng run ${options.project}:run-android.`,
|
|
73
|
+
);
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
module.exports = { mobile, mobileTargets };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema",
|
|
3
|
+
"$id": "NgNativeMobile",
|
|
4
|
+
"title": "iOS and Android in a desktop-only Angular Native app",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"project": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"description": "The Angular Native app, by its name in angular.json.",
|
|
10
|
+
"$default": {
|
|
11
|
+
"$source": "argv",
|
|
12
|
+
"index": 0
|
|
13
|
+
},
|
|
14
|
+
"x-prompt": "Which native app should run on iOS and Android?"
|
|
15
|
+
},
|
|
16
|
+
"skipInstall": {
|
|
17
|
+
"type": "boolean",
|
|
18
|
+
"description": "Write the files and package.json without installing.",
|
|
19
|
+
"default": false
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"required": ["project"]
|
|
23
|
+
}
|
package/native-app.cjs
CHANGED
|
@@ -27,9 +27,38 @@ const SOURCE_FILES = [
|
|
|
27
27
|
'tsconfig.json',
|
|
28
28
|
];
|
|
29
29
|
|
|
30
|
-
/**
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
/**
|
|
31
|
+
* The desktop template's files that differ from the template's, or that it alone has, which a
|
|
32
|
+
* desktop-only app takes from `files/desktop/`: its starter screen, the screen's Node test and
|
|
33
|
+
* in-app test, the entry file that starts the in-app tests, the Vitest config with a project for
|
|
34
|
+
* each, and the Metro config that keeps the in-app tests out of an ordinary bundle. Its `AGENTS.md`
|
|
35
|
+
* comes from there too, through `agentsFile`.
|
|
36
|
+
*/
|
|
37
|
+
const DESKTOP_SOURCE_FILES = [
|
|
38
|
+
'src/app/app.ts',
|
|
39
|
+
'src/app/app.test.ts',
|
|
40
|
+
'src/app/app.device.ts',
|
|
41
|
+
'src/main.ts',
|
|
42
|
+
'vitest.config.mts',
|
|
43
|
+
'metro.config.js',
|
|
44
|
+
];
|
|
45
|
+
|
|
46
|
+
/** The desktop template's files a desktop-only app has and a mobile one does not. */
|
|
47
|
+
const DESKTOP_ONLY_FILES = ['src/app/app.device.ts'];
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The desktop template's Vitest project that runs in Node, which `ng test` runs alone: its other
|
|
51
|
+
* project opens the app.
|
|
52
|
+
*/
|
|
53
|
+
const DESKTOP_TEST_PROJECT = 'node-macos';
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* @param {string} name
|
|
57
|
+
* @param {boolean} [desktopOnly] the desktop template's copy, where it has one of its own
|
|
58
|
+
*/
|
|
59
|
+
function sourceFile(name, desktopOnly = false) {
|
|
60
|
+
const own = desktopOnly && (DESKTOP_SOURCE_FILES.includes(name) || name === 'AGENTS.md');
|
|
61
|
+
return readFileSync(path.join(__dirname, 'files', own ? 'desktop' : '', name), 'utf8');
|
|
33
62
|
}
|
|
34
63
|
|
|
35
64
|
/**
|
|
@@ -37,9 +66,10 @@ function sourceFile(name) {
|
|
|
37
66
|
* describes the framework, which is the same wherever the app lives.
|
|
38
67
|
*
|
|
39
68
|
* @param {string} commands the markdown that goes under the Commands heading
|
|
69
|
+
* @param {boolean} [desktopOnly] the desktop template's, for a desktop-only app
|
|
40
70
|
*/
|
|
41
|
-
function agentsFile(commands) {
|
|
42
|
-
return sourceFile('AGENTS.md').replace(
|
|
71
|
+
function agentsFile(commands, desktopOnly = false) {
|
|
72
|
+
return sourceFile('AGENTS.md', desktopOnly).replace(
|
|
43
73
|
/## Commands\n[\s\S]*?(?=\n## )/,
|
|
44
74
|
`## Commands\n\n${commands}\n`,
|
|
45
75
|
);
|
|
@@ -52,14 +82,24 @@ function agentsFile(commands) {
|
|
|
52
82
|
* @param {string} name
|
|
53
83
|
* @param {{ dependencies?: Record<string, string>, devDependencies?: Record<string, string> }} root
|
|
54
84
|
* the workspace's root `package.json`, once this app's dependencies are in it
|
|
85
|
+
* @param {boolean} [desktopOnly] a desktop-only app, with the desktop template's dependencies
|
|
55
86
|
*/
|
|
56
|
-
function projectManifest(name, root) {
|
|
57
|
-
|
|
87
|
+
function projectManifest(name, root, desktopOnly = false) {
|
|
88
|
+
const wanted = desktopOnly ? shared.desktopOnlyDependencies : shared.dependencies;
|
|
89
|
+
return {
|
|
90
|
+
name,
|
|
91
|
+
private: true,
|
|
92
|
+
main: 'src/main.ts',
|
|
93
|
+
dependencies: shared.prebuildPins(root, wanted),
|
|
94
|
+
};
|
|
58
95
|
}
|
|
59
96
|
|
|
60
97
|
module.exports = {
|
|
61
98
|
...shared,
|
|
62
99
|
SOURCE_FILES,
|
|
100
|
+
DESKTOP_SOURCE_FILES,
|
|
101
|
+
DESKTOP_ONLY_FILES,
|
|
102
|
+
DESKTOP_TEST_PROJECT,
|
|
63
103
|
sourceFile,
|
|
64
104
|
agentsFile,
|
|
65
105
|
projectManifest,
|
package/ng-add/index.cjs
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
const { application } = require('../application/index.cjs');
|
|
10
10
|
|
|
11
|
-
/** @param {{ name?: string, directory?: string, bundleIdentifier?: string, linter?: 'eslint' | 'none', skipInstall?: boolean }} options */
|
|
11
|
+
/** @param {{ name?: string, directory?: string, bundleIdentifier?: string, linter?: 'eslint' | 'none', desktopOnly?: boolean, skipInstall?: boolean }} options */
|
|
12
12
|
function ngAdd(options) {
|
|
13
13
|
return application({ ...options, name: options.name ?? 'native', prefix: 'app' });
|
|
14
14
|
}
|
package/ng-add/schema.json
CHANGED
|
@@ -24,6 +24,11 @@
|
|
|
24
24
|
"enum": ["eslint", "none"],
|
|
25
25
|
"default": "none"
|
|
26
26
|
},
|
|
27
|
+
"desktopOnly": {
|
|
28
|
+
"type": "boolean",
|
|
29
|
+
"description": "A macOS-only app from the desktop template: macos alone in expo.platforms, a sidebar and menu bar starter, and macos and package targets in place of run-ios and run-android.",
|
|
30
|
+
"default": false
|
|
31
|
+
},
|
|
27
32
|
"skipInstall": {
|
|
28
33
|
"type": "boolean",
|
|
29
34
|
"description": "Write the files and package.json without installing.",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ng-native/schematics",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.0",
|
|
4
4
|
"description": "ng add and ng generate for Angular Native: an Expo app in an Angular CLI workspace, with builders that run it.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"angular",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"packageGroup": [
|
|
28
28
|
"@ng-native/analog",
|
|
29
29
|
"@ng-native/components",
|
|
30
|
+
"@ng-native/desktop",
|
|
30
31
|
"@ng-native/device",
|
|
31
32
|
"@ng-native/eslint-plugin",
|
|
32
33
|
"@ng-native/expo",
|
|
@@ -50,7 +51,7 @@
|
|
|
50
51
|
"@angular-devkit/architect": ">=0.2200.0 <0.2300.0",
|
|
51
52
|
"@angular-devkit/core": "^22.0.0",
|
|
52
53
|
"@angular-devkit/schematics": "^22.0.0",
|
|
53
|
-
"@ng-native/migrate": "0.
|
|
54
|
+
"@ng-native/migrate": "0.23.0"
|
|
54
55
|
},
|
|
55
56
|
"devDependencies": {
|
|
56
57
|
"@schematics/angular": "22.1.9"
|
|
@@ -62,7 +63,8 @@
|
|
|
62
63
|
"layer:build"
|
|
63
64
|
],
|
|
64
65
|
"implicitDependencies": [
|
|
65
|
-
"@ng-native/template"
|
|
66
|
+
"@ng-native/template",
|
|
67
|
+
"@ng-native/template-desktop"
|
|
66
68
|
]
|
|
67
69
|
},
|
|
68
70
|
"license": "MIT",
|
|
@@ -89,6 +91,6 @@
|
|
|
89
91
|
},
|
|
90
92
|
"scripts": {
|
|
91
93
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
92
|
-
"test": "node --test \"*.test.ts\" \"{application,component,builders,migrations}/*.test.ts\""
|
|
94
|
+
"test": "node --test \"*.test.ts\" \"{application,component,builders,migrations,desktop,mobile}/*.test.ts\""
|
|
93
95
|
}
|
|
94
96
|
}
|