@ng-desktop/builders 0.0.0-stage → 0.3.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/LICENSE +21 -0
- package/README.md +13 -2
- package/bin/ng-desktop.mjs +191 -0
- package/builders.json +10 -0
- package/fesm2022/ast-metadata-extractor.d.mts +40 -0
- package/fesm2022/ast-metadata-extractor.mjs +420 -0
- package/fesm2022/build-bundle.d.mts +36 -0
- package/fesm2022/build-bundle.mjs +315 -0
- package/fesm2022/builder.d.ts +67 -0
- package/fesm2022/builder.d.ts.map +1 -0
- package/fesm2022/builder.js +124 -0
- package/fesm2022/builder.js.map +1 -0
- package/fesm2022/dev-server.mjs +47 -0
- package/fesm2022/hmr-client.d.mts +19 -0
- package/fesm2022/hmr-client.mjs +77 -0
- package/fesm2022/icon-compiler.d.mts +6 -0
- package/fesm2022/icon-compiler.mjs +148 -0
- package/fesm2022/index.d.ts +11 -0
- package/fesm2022/index.d.ts.map +1 -0
- package/fesm2022/index.js +11 -0
- package/fesm2022/index.js.map +1 -0
- package/fesm2022/permission-analyzer.d.mts +45 -0
- package/fesm2022/permission-analyzer.mjs +313 -0
- package/fesm2022/resolve-engine-binary.d.mts +35 -0
- package/fesm2022/resolve-engine-binary.mjs +130 -0
- package/fesm2022/style-compiler.d.mts +14 -0
- package/fesm2022/style-compiler.mjs +97 -0
- package/fesm2022/template-compiler.d.mts +53 -0
- package/fesm2022/template-compiler.mjs +810 -0
- package/fesm2022/workspace-resolver.d.mts +24 -0
- package/fesm2022/workspace-resolver.mjs +199 -0
- package/package.json +78 -4
- package/schema/angular-native-schema.json +52 -0
- package/schema/native-builder-schema.json +79 -0
- package/schematics/collection.json +10 -0
- package/schematics/ng-add/index.d.mts +20 -0
- package/schematics/ng-add/index.mjs +56 -0
- package/schematics/ng-add/schema.json +24 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { FSWatcher } from 'node:fs';
|
|
2
|
+
import { PermissionAnalysisManifest } from './permission-analyzer.mjs';
|
|
3
|
+
import { StyleRuleIr } from './style-compiler.mjs';
|
|
4
|
+
import { TemplateAstNode } from './template-compiler.mjs';
|
|
5
|
+
|
|
6
|
+
export interface CompileBundleOptions {
|
|
7
|
+
rebuildIcons?: boolean;
|
|
8
|
+
cwd?: string;
|
|
9
|
+
configPath?: string;
|
|
10
|
+
projectName?: string;
|
|
11
|
+
version?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface CompileBundleResult {
|
|
15
|
+
projectName: string;
|
|
16
|
+
version: string;
|
|
17
|
+
sourceRoot: string;
|
|
18
|
+
bundleFile: string;
|
|
19
|
+
permissionsFile: string;
|
|
20
|
+
runtimeConfigFile: string;
|
|
21
|
+
permissions: PermissionAnalysisManifest;
|
|
22
|
+
socketPath: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function emitNgbBundle(
|
|
26
|
+
styleRules: StyleRuleIr[],
|
|
27
|
+
numericSignals: Record<string, number>,
|
|
28
|
+
methods: Record<string, { kind: 'set' | 'add'; signalName: string; value: number }>,
|
|
29
|
+
astRoots: TemplateAstNode[],
|
|
30
|
+
iconMeta: { appId: string; relPath: string } | null,
|
|
31
|
+
sourceLabel: string,
|
|
32
|
+
): string;
|
|
33
|
+
|
|
34
|
+
export function compileBundle(options?: CompileBundleOptions): CompileBundleResult;
|
|
35
|
+
|
|
36
|
+
export function watchBundle(options?: CompileBundleOptions): FSWatcher;
|
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
import {
|
|
2
|
+
existsSync,
|
|
3
|
+
mkdirSync,
|
|
4
|
+
readdirSync,
|
|
5
|
+
readFileSync,
|
|
6
|
+
statSync,
|
|
7
|
+
watch,
|
|
8
|
+
writeFileSync,
|
|
9
|
+
} from 'node:fs';
|
|
10
|
+
import { dirname, relative, resolve } from 'node:path';
|
|
11
|
+
import { fileURLToPath } from 'node:url';
|
|
12
|
+
import { extractComponentMetadata } from './ast-metadata-extractor.mjs';
|
|
13
|
+
import { pushHmrReload } from './hmr-client.mjs';
|
|
14
|
+
import { buildMultiResolutionIcons } from './icon-compiler.mjs';
|
|
15
|
+
import { analyzeProjectPermissions } from './permission-analyzer.mjs';
|
|
16
|
+
import { emitStyleInstruction, parseStylesCss } from './style-compiler.mjs';
|
|
17
|
+
import { parseTemplateHtml } from './template-compiler.mjs';
|
|
18
|
+
import { resolveWorkspaceProject } from './workspace-resolver.mjs';
|
|
19
|
+
|
|
20
|
+
export { extractComponentMetadata, parseStylesCss, parseTemplateHtml, pushHmrReload };
|
|
21
|
+
|
|
22
|
+
function extractCliFlagValue(argv, flag) {
|
|
23
|
+
const prefix = `${flag}=`;
|
|
24
|
+
for (let i = 0; i < argv.length; i += 1) {
|
|
25
|
+
const arg = argv[i];
|
|
26
|
+
if (arg.startsWith(prefix)) {
|
|
27
|
+
return arg.slice(prefix.length).trim() || undefined;
|
|
28
|
+
}
|
|
29
|
+
if (arg === flag && i + 1 < argv.length && !argv[i + 1].startsWith('--')) {
|
|
30
|
+
return argv[i + 1].trim() || undefined;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function mapNativeEventName(evtName) {
|
|
37
|
+
if (evtName === 'click') return 'clicked';
|
|
38
|
+
if (evtName === 'change') return 'toggled';
|
|
39
|
+
if (evtName === 'valueChange') return 'value-changed';
|
|
40
|
+
return evtName;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function collectComponentTsFiles(dirPath, rootAppDir, out = []) {
|
|
44
|
+
if (!existsSync(dirPath)) return out;
|
|
45
|
+
for (const entry of readdirSync(dirPath)) {
|
|
46
|
+
const full = resolve(dirPath, entry);
|
|
47
|
+
const stat = statSync(full);
|
|
48
|
+
if (stat.isDirectory()) {
|
|
49
|
+
collectComponentTsFiles(full, rootAppDir, out);
|
|
50
|
+
} else if (entry.endsWith('.ts') && !entry.endsWith('.spec.ts') && entry !== 'app.ts') {
|
|
51
|
+
out.push(relative(rootAppDir, full));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return out;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* 4. Bytecode Emitter (SRP): Translates Styles IR + Signals + Icons + Template AST into `.ngb` instructions.
|
|
59
|
+
*/
|
|
60
|
+
export function emitNgbBundle(
|
|
61
|
+
styleRules,
|
|
62
|
+
numericSignals,
|
|
63
|
+
methods,
|
|
64
|
+
astRoots,
|
|
65
|
+
iconMeta,
|
|
66
|
+
sourceLabel,
|
|
67
|
+
) {
|
|
68
|
+
const lines = [`// Auto-compiled by Angular Native Template Compiler from ${sourceLabel}`];
|
|
69
|
+
|
|
70
|
+
for (const [sigName, initialValue] of Object.entries(numericSignals)) {
|
|
71
|
+
lines.push(`signal ${sigName} ${initialValue}`);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
for (const rule of styleRules) {
|
|
75
|
+
lines.push(emitStyleInstruction(rule));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const appendInstructions = [];
|
|
79
|
+
const bindingInstructions = [];
|
|
80
|
+
|
|
81
|
+
function visitNode(node) {
|
|
82
|
+
if (node.isComment) {
|
|
83
|
+
lines.push(`comment ${node.id} ${node.text}`);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
lines.push(`create ${node.id} ${node.tag}`);
|
|
88
|
+
|
|
89
|
+
if (node.title) {
|
|
90
|
+
lines.push(`text ${node.id} ${node.title}`);
|
|
91
|
+
} else if (node.text) {
|
|
92
|
+
lines.push(`text ${node.id} ${node.text}`);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if ((node.tag === 'ng-window' || node.tag === 'adw-window') && iconMeta) {
|
|
96
|
+
lines.push(`icon ${node.id} ${iconMeta.appId} ${iconMeta.relPath}`);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
for (const [attrKey, attrVal] of Object.entries(node.attributes || {})) {
|
|
100
|
+
lines.push(`attr ${node.id} ${attrKey} ${attrVal}`);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
for (const cls of node.classes) {
|
|
104
|
+
lines.push(`add_class ${node.id} ${cls}`);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (node.reactiveBinding) {
|
|
108
|
+
bindingInstructions.push(
|
|
109
|
+
`bind_text ${node.id} ${node.reactiveBinding.signalName} ${node.reactiveBinding.template}`,
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
for (const attrBind of node.reactiveAttrs || []) {
|
|
114
|
+
bindingInstructions.push(
|
|
115
|
+
`bind_attr ${node.id} ${attrBind.attrKey} ${attrBind.signalName} ${attrBind.template}`,
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (node.visibilityBinding) {
|
|
120
|
+
bindingInstructions.push(
|
|
121
|
+
`bind_visible ${node.id} ${node.visibilityBinding.signalName} ${node.visibilityBinding.op} ${node.visibilityBinding.rhs}`,
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
for (const [evtName, methodName] of Object.entries(node.events)) {
|
|
126
|
+
const nativeEvt = mapNativeEventName(evtName);
|
|
127
|
+
const methodMeta = methods[methodName];
|
|
128
|
+
if (methodMeta) {
|
|
129
|
+
const opcode = methodMeta.kind === 'set' ? 'on_set' : 'on_add';
|
|
130
|
+
bindingInstructions.push(
|
|
131
|
+
`${opcode} ${node.id} ${nativeEvt} ${methodMeta.signalName} ${methodMeta.value}`,
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
for (const child of node.children) {
|
|
137
|
+
visitNode(child);
|
|
138
|
+
appendInstructions.push(`append ${node.id} ${child.id}`);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
for (const root of astRoots) {
|
|
143
|
+
visitNode(root);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
lines.push(...appendInstructions);
|
|
147
|
+
lines.push(...bindingInstructions);
|
|
148
|
+
return lines.join('\n') + '\n';
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export function compileBundle({
|
|
152
|
+
rebuildIcons = true,
|
|
153
|
+
cwd,
|
|
154
|
+
configPath,
|
|
155
|
+
projectName: requestedProject,
|
|
156
|
+
version: versionOverride,
|
|
157
|
+
} = {}) {
|
|
158
|
+
const workspace = resolveWorkspaceProject({
|
|
159
|
+
cwd,
|
|
160
|
+
configPath,
|
|
161
|
+
projectName: requestedProject,
|
|
162
|
+
});
|
|
163
|
+
const rootDir = workspace.workspaceRoot;
|
|
164
|
+
const projectName = workspace.projectName;
|
|
165
|
+
const nativeOptions = workspace.nativeOptions ?? {};
|
|
166
|
+
const resolvedOutputPath = workspace.outputPath;
|
|
167
|
+
const resolvedVersion = versionOverride || workspace.version;
|
|
168
|
+
|
|
169
|
+
const sourceRootAbs = resolve(rootDir, workspace.sourceRoot);
|
|
170
|
+
const appDir = resolve(sourceRootAbs, 'app');
|
|
171
|
+
const tsSource = readFileSync(resolve(appDir, 'app.ts'), 'utf8');
|
|
172
|
+
const { state, numericSignals, methods, component } = extractComponentMetadata(tsSource);
|
|
173
|
+
const htmlSource = readFileSync(resolve(appDir, component.templateUrl), 'utf8');
|
|
174
|
+
const cssSource = readFileSync(resolve(appDir, component.styleUrl), 'utf8');
|
|
175
|
+
const indexHtmlPath = resolve(sourceRootAbs, 'index.html');
|
|
176
|
+
const indexHtml = existsSync(indexHtmlPath) ? readFileSync(indexHtmlPath, 'utf8') : '';
|
|
177
|
+
|
|
178
|
+
const iconHrefMatch = indexHtml.match(/<link[^>]*rel="icon"[^>]*href="([^"]+)"/);
|
|
179
|
+
const iconFileName = iconHrefMatch ? iconHrefMatch[1] : 'favicon.ico';
|
|
180
|
+
const publicPrefix = workspace.projectRoot === '.' ? 'public' : `${workspace.projectRoot}/public`;
|
|
181
|
+
const iconRelPath = `${publicPrefix}/${iconFileName}`;
|
|
182
|
+
const iconAbsPath = resolve(rootDir, iconRelPath);
|
|
183
|
+
|
|
184
|
+
const componentRegistry = {};
|
|
185
|
+
const allStyleRules = [...parseStylesCss(cssSource)];
|
|
186
|
+
|
|
187
|
+
const candidateFiles = collectComponentTsFiles(appDir, appDir);
|
|
188
|
+
for (const file of candidateFiles) {
|
|
189
|
+
const filePath = resolve(appDir, file);
|
|
190
|
+
if (existsSync(filePath)) {
|
|
191
|
+
const ts = readFileSync(filePath, 'utf8');
|
|
192
|
+
const meta = extractComponentMetadata(ts, file);
|
|
193
|
+
if (!ts.includes('@Component')) continue;
|
|
194
|
+
const compDir = dirname(filePath);
|
|
195
|
+
const tmplPath = resolve(compDir, meta.component.templateUrl);
|
|
196
|
+
const stylePath = resolve(compDir, meta.component.styleUrl);
|
|
197
|
+
const templateHtml = existsSync(tmplPath) ? readFileSync(tmplPath, 'utf8') : '';
|
|
198
|
+
if (existsSync(stylePath)) {
|
|
199
|
+
const rules = parseStylesCss(readFileSync(stylePath, 'utf8'));
|
|
200
|
+
allStyleRules.push(...rules);
|
|
201
|
+
}
|
|
202
|
+
componentRegistry[meta.component.selector] = {
|
|
203
|
+
templateHtml,
|
|
204
|
+
templateUrl: meta.component.templateUrl,
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
const templateAst = parseTemplateHtml(
|
|
210
|
+
htmlSource,
|
|
211
|
+
state,
|
|
212
|
+
numericSignals,
|
|
213
|
+
'app.html',
|
|
214
|
+
componentRegistry,
|
|
215
|
+
);
|
|
216
|
+
|
|
217
|
+
const outDir = resolve(rootDir, resolvedOutputPath);
|
|
218
|
+
mkdirSync(outDir, { recursive: true });
|
|
219
|
+
|
|
220
|
+
let iconMeta = null;
|
|
221
|
+
if (existsSync(iconAbsPath)) {
|
|
222
|
+
iconMeta = { appId: projectName, relPath: iconRelPath };
|
|
223
|
+
if (rebuildIcons) {
|
|
224
|
+
buildMultiResolutionIcons(iconAbsPath, projectName, outDir, state.windowTitle);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
const bundle = emitNgbBundle(
|
|
229
|
+
allStyleRules,
|
|
230
|
+
numericSignals,
|
|
231
|
+
methods,
|
|
232
|
+
templateAst,
|
|
233
|
+
iconMeta,
|
|
234
|
+
`${workspace.sourceRoot}/app/app.{ts,html,css}`,
|
|
235
|
+
);
|
|
236
|
+
|
|
237
|
+
const bundleFile = resolve(outDir, 'main.ngb');
|
|
238
|
+
writeFileSync(bundleFile, bundle, 'utf8');
|
|
239
|
+
|
|
240
|
+
const permissions = analyzeProjectPermissions(sourceRootAbs, nativeOptions.permissions);
|
|
241
|
+
const permissionsFile = resolve(outDir, 'permissions.manifest.json');
|
|
242
|
+
writeFileSync(permissionsFile, JSON.stringify(permissions, null, 2) + '\n', 'utf8');
|
|
243
|
+
|
|
244
|
+
const runtimeConfig = {
|
|
245
|
+
schemaVersion: 1,
|
|
246
|
+
workspaceKind: workspace.workspaceKind,
|
|
247
|
+
projectName,
|
|
248
|
+
version: resolvedVersion,
|
|
249
|
+
targetPlatform: nativeOptions.targetPlatform || 'linux-gtk4',
|
|
250
|
+
outputPath: resolvedOutputPath,
|
|
251
|
+
iconSearchDir: `${resolvedOutputPath}/icons`,
|
|
252
|
+
permissions,
|
|
253
|
+
};
|
|
254
|
+
const runtimeConfigFile = resolve(outDir, 'ng-desktop.runtime.json');
|
|
255
|
+
writeFileSync(runtimeConfigFile, JSON.stringify(runtimeConfig, null, 2) + '\n', 'utf8');
|
|
256
|
+
|
|
257
|
+
const standaloneFallback = resolve(rootDir, 'src/standalone_pokedex.ngb');
|
|
258
|
+
if (projectName === 'ng-linux-counter' && existsSync(standaloneFallback)) {
|
|
259
|
+
writeFileSync(standaloneFallback, bundle, 'utf8');
|
|
260
|
+
}
|
|
261
|
+
console.log(
|
|
262
|
+
`[Angular Native Compiler] Compiled ${projectName} v${resolvedVersion} (${workspace.workspaceKind}) -> ${bundleFile}`,
|
|
263
|
+
);
|
|
264
|
+
|
|
265
|
+
const socketPath = resolve(outDir, 'hmr.sock');
|
|
266
|
+
if (existsSync(socketPath)) {
|
|
267
|
+
pushHmrReload(socketPath, bundle).then((res) => {
|
|
268
|
+
if (res.connected && res.response?.status === 'ok') {
|
|
269
|
+
console.log(`[Angular Native HMR] Pushed live bundle update over IPC -> ${socketPath}`);
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
return {
|
|
275
|
+
projectName,
|
|
276
|
+
version: resolvedVersion,
|
|
277
|
+
sourceRoot: sourceRootAbs,
|
|
278
|
+
bundleFile,
|
|
279
|
+
permissionsFile,
|
|
280
|
+
runtimeConfigFile,
|
|
281
|
+
permissions,
|
|
282
|
+
socketPath,
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
export function watchBundle(options = {}) {
|
|
287
|
+
const { sourceRoot } = compileBundle({ ...options, rebuildIcons: true });
|
|
288
|
+
console.log(`[Angular Native Watcher] Watching '${sourceRoot}' for changes...`);
|
|
289
|
+
|
|
290
|
+
let debounceTimer = null;
|
|
291
|
+
return watch(sourceRoot, { recursive: true }, (_eventType, filename) => {
|
|
292
|
+
if (!filename || !/\.(ts|html|css)$/.test(filename)) return;
|
|
293
|
+
if (debounceTimer) clearTimeout(debounceTimer);
|
|
294
|
+
debounceTimer = setTimeout(() => {
|
|
295
|
+
try {
|
|
296
|
+
compileBundle({ ...options, rebuildIcons: filename.endsWith('index.html') });
|
|
297
|
+
} catch (err) {
|
|
298
|
+
console.error('[Angular Native Watcher] Compilation error:', err);
|
|
299
|
+
}
|
|
300
|
+
}, 60);
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
if (process.argv[1] === fileURLToPath(import.meta.url)) {
|
|
305
|
+
const cliOptions = {
|
|
306
|
+
configPath: extractCliFlagValue(process.argv, '--config'),
|
|
307
|
+
projectName: extractCliFlagValue(process.argv, '--project'),
|
|
308
|
+
version: extractCliFlagValue(process.argv, '--version'),
|
|
309
|
+
};
|
|
310
|
+
if (process.argv.includes('--watch')) {
|
|
311
|
+
watchBundle(cliOptions);
|
|
312
|
+
} else {
|
|
313
|
+
compileBundle({ ...cliOptions, rebuildIcons: true });
|
|
314
|
+
}
|
|
315
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export type NativeOsKind = 'auto' | 'linux' | 'windows' | 'macos';
|
|
2
|
+
export type NativeArchKind = 'auto' | 'x86_64' | 'aarch64' | 'universal';
|
|
3
|
+
export type NativeCpuProfile = 'auto' | 'native' | 'baseline' | 'avx2' | 'neon';
|
|
4
|
+
export type NativePlatformTarget = 'linux-gtk4' | 'windows-winui' | 'macos-appkit';
|
|
5
|
+
export type NativeJsEngineKind = 'jsc' | 'quickjs';
|
|
6
|
+
export type NativePackageFormat = 'deb' | 'appimage' | 'flatpak' | 'msi' | 'dmg';
|
|
7
|
+
export type LinuxPackageFormat = 'deb' | 'appimage' | 'flatpak';
|
|
8
|
+
export type NativePermissionsMode = 'auto' | 'strict';
|
|
9
|
+
export interface NativePermissionsOptions {
|
|
10
|
+
mode?: NativePermissionsMode;
|
|
11
|
+
allow?: string[];
|
|
12
|
+
deny?: string[];
|
|
13
|
+
}
|
|
14
|
+
export interface NativeBuilderOptions {
|
|
15
|
+
os?: NativeOsKind;
|
|
16
|
+
arch?: NativeArchKind;
|
|
17
|
+
cpu?: NativeCpuProfile;
|
|
18
|
+
targetPlatform?: NativePlatformTarget;
|
|
19
|
+
jsEngine?: NativeJsEngineKind;
|
|
20
|
+
outputPath?: string;
|
|
21
|
+
version?: string;
|
|
22
|
+
permissions?: NativePermissionsOptions;
|
|
23
|
+
packageFormats?: NativePackageFormat[];
|
|
24
|
+
}
|
|
25
|
+
export interface ResolvedNativeBuilderConfig {
|
|
26
|
+
os: 'linux' | 'windows' | 'macos';
|
|
27
|
+
arch: 'x86_64' | 'aarch64' | 'universal';
|
|
28
|
+
cpu: NativeCpuProfile;
|
|
29
|
+
targetPlatform: NativePlatformTarget;
|
|
30
|
+
jsEngine: NativeJsEngineKind;
|
|
31
|
+
outputPath: string;
|
|
32
|
+
rustTargetTriple: string;
|
|
33
|
+
packageFormats: NativePackageFormat[];
|
|
34
|
+
}
|
|
35
|
+
export interface NativeBuilderResult {
|
|
36
|
+
success: boolean;
|
|
37
|
+
projectName: string;
|
|
38
|
+
os: 'linux' | 'windows' | 'macos';
|
|
39
|
+
arch: 'x86_64' | 'aarch64' | 'universal';
|
|
40
|
+
cpu: NativeCpuProfile;
|
|
41
|
+
rustTargetTriple: string;
|
|
42
|
+
targetPlatform: NativePlatformTarget;
|
|
43
|
+
jsEngine: NativeJsEngineKind;
|
|
44
|
+
bundlePath: string;
|
|
45
|
+
permissionsManifestPath: string;
|
|
46
|
+
runtimeConfigPath: string;
|
|
47
|
+
packageArtifacts: string[];
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Resolves minimal `angular.json` options (`os`, `arch`, `cpu`) into full target platform,
|
|
51
|
+
* embedded JS engine, Rust target triple, and output directory defaults.
|
|
52
|
+
*/
|
|
53
|
+
export declare function resolveNativeBuilderConfig(projectName: string, options?: NativeBuilderOptions): ResolvedNativeBuilderConfig;
|
|
54
|
+
/**
|
|
55
|
+
* Generates an `angular.json` `architect.native` target configuration block
|
|
56
|
+
* for `@ng-desktop/builders:application`.
|
|
57
|
+
*/
|
|
58
|
+
export declare function createNativeTargetConfig(options: NativeBuilderOptions): {
|
|
59
|
+
builder: '@ng-desktop/builders:application';
|
|
60
|
+
options: NativeBuilderOptions;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Executes the Angular 22 Native Builder pipeline, resolving minimal OS/CPU config,
|
|
64
|
+
* `.ngb` bundle path, and target distribution artifacts.
|
|
65
|
+
*/
|
|
66
|
+
export declare function executeNativeBuilder(projectName: string, options: NativeBuilderOptions): NativeBuilderResult;
|
|
67
|
+
//# sourceMappingURL=builder.d.ts.map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detectHostOs() {
|
|
2
|
+
if (typeof process !== 'undefined') {
|
|
3
|
+
if (process.platform === 'win32')
|
|
4
|
+
return 'windows';
|
|
5
|
+
if (process.platform === 'darwin')
|
|
6
|
+
return 'macos';
|
|
7
|
+
}
|
|
8
|
+
return 'linux';
|
|
9
|
+
}
|
|
10
|
+
function detectHostArch() {
|
|
11
|
+
if (typeof process !== 'undefined' && process.arch === 'arm64') {
|
|
12
|
+
return 'aarch64';
|
|
13
|
+
}
|
|
14
|
+
return 'x86_64';
|
|
15
|
+
}
|
|
16
|
+
function resolveTargetTriple(os, arch) {
|
|
17
|
+
if (os === 'windows') {
|
|
18
|
+
return arch === 'aarch64' ? 'aarch64-pc-windows-msvc' : 'x86_64-pc-windows-msvc';
|
|
19
|
+
}
|
|
20
|
+
if (os === 'macos') {
|
|
21
|
+
if (arch === 'universal')
|
|
22
|
+
return 'universal-apple-darwin';
|
|
23
|
+
return arch === 'x86_64' ? 'x86_64-apple-darwin' : 'aarch64-apple-darwin';
|
|
24
|
+
}
|
|
25
|
+
return arch === 'aarch64' ? 'aarch64-unknown-linux-gnu' : 'x86_64-unknown-linux-gnu';
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Resolves minimal `angular.json` options (`os`, `arch`, `cpu`) into full target platform,
|
|
29
|
+
* embedded JS engine, Rust target triple, and output directory defaults.
|
|
30
|
+
*/
|
|
31
|
+
export function resolveNativeBuilderConfig(projectName, options = {}) {
|
|
32
|
+
let os;
|
|
33
|
+
if (options.os && options.os !== 'auto') {
|
|
34
|
+
os = options.os;
|
|
35
|
+
}
|
|
36
|
+
else if (options.targetPlatform === 'windows-winui') {
|
|
37
|
+
os = 'windows';
|
|
38
|
+
}
|
|
39
|
+
else if (options.targetPlatform === 'macos-appkit') {
|
|
40
|
+
os = 'macos';
|
|
41
|
+
}
|
|
42
|
+
else if (options.targetPlatform === 'linux-gtk4') {
|
|
43
|
+
os = 'linux';
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
os = detectHostOs();
|
|
47
|
+
}
|
|
48
|
+
const targetPlatform = options.targetPlatform ??
|
|
49
|
+
(os === 'windows' ? 'windows-winui' : os === 'macos' ? 'macos-appkit' : 'linux-gtk4');
|
|
50
|
+
const jsEngine = options.jsEngine ?? (os === 'windows' ? 'quickjs' : 'jsc');
|
|
51
|
+
const arch = options.arch && options.arch !== 'auto' ? options.arch : detectHostArch();
|
|
52
|
+
const cpu = options.cpu ?? 'auto';
|
|
53
|
+
const outputPath = (options.outputPath ?? `dist/${projectName}`).replace(/\/+$/, '');
|
|
54
|
+
const defaultFormats = os === 'linux' ? ['deb', 'appimage', 'flatpak'] : os === 'windows' ? ['msi'] : ['dmg'];
|
|
55
|
+
return {
|
|
56
|
+
os,
|
|
57
|
+
arch,
|
|
58
|
+
cpu,
|
|
59
|
+
targetPlatform,
|
|
60
|
+
jsEngine,
|
|
61
|
+
outputPath,
|
|
62
|
+
rustTargetTriple: resolveTargetTriple(os, arch),
|
|
63
|
+
packageFormats: options.packageFormats ?? defaultFormats,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Generates an `angular.json` `architect.native` target configuration block
|
|
68
|
+
* for `@ng-desktop/builders:application`.
|
|
69
|
+
*/
|
|
70
|
+
export function createNativeTargetConfig(options) {
|
|
71
|
+
return {
|
|
72
|
+
builder: '@ng-desktop/builders:application',
|
|
73
|
+
options: {
|
|
74
|
+
os: options.os ?? 'linux',
|
|
75
|
+
arch: options.arch ?? 'x86_64',
|
|
76
|
+
...(options.cpu ? { cpu: options.cpu } : {}),
|
|
77
|
+
...(options.targetPlatform ? { targetPlatform: options.targetPlatform } : {}),
|
|
78
|
+
...(options.jsEngine ? { jsEngine: options.jsEngine } : {}),
|
|
79
|
+
...(options.outputPath ? { outputPath: options.outputPath } : {}),
|
|
80
|
+
...(options.packageFormats ? { packageFormats: options.packageFormats } : {}),
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Executes the Angular 22 Native Builder pipeline, resolving minimal OS/CPU config,
|
|
86
|
+
* `.ngb` bundle path, and target distribution artifacts.
|
|
87
|
+
*/
|
|
88
|
+
export function executeNativeBuilder(projectName, options) {
|
|
89
|
+
const resolved = resolveNativeBuilderConfig(projectName, options);
|
|
90
|
+
const packageArtifacts = [];
|
|
91
|
+
for (const fmt of resolved.packageFormats) {
|
|
92
|
+
if (fmt === 'deb') {
|
|
93
|
+
packageArtifacts.push(`${resolved.outputPath}/packages/deb/DEBIAN/control`);
|
|
94
|
+
packageArtifacts.push(`${resolved.outputPath}/packages/deb/usr/share/applications/${projectName}.desktop`);
|
|
95
|
+
}
|
|
96
|
+
else if (fmt === 'appimage') {
|
|
97
|
+
packageArtifacts.push(`${resolved.outputPath}/packages/appimage/AppRun`);
|
|
98
|
+
}
|
|
99
|
+
else if (fmt === 'flatpak') {
|
|
100
|
+
packageArtifacts.push(`${resolved.outputPath}/packages/flatpak/${projectName}.yml`);
|
|
101
|
+
}
|
|
102
|
+
else if (fmt === 'msi') {
|
|
103
|
+
packageArtifacts.push(`${resolved.outputPath}/packages/windows/${projectName}.msi`);
|
|
104
|
+
}
|
|
105
|
+
else if (fmt === 'dmg') {
|
|
106
|
+
packageArtifacts.push(`${resolved.outputPath}/packages/macos/${projectName}.dmg`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
success: true,
|
|
111
|
+
projectName,
|
|
112
|
+
os: resolved.os,
|
|
113
|
+
arch: resolved.arch,
|
|
114
|
+
cpu: resolved.cpu,
|
|
115
|
+
rustTargetTriple: resolved.rustTargetTriple,
|
|
116
|
+
targetPlatform: resolved.targetPlatform,
|
|
117
|
+
jsEngine: resolved.jsEngine,
|
|
118
|
+
bundlePath: `${resolved.outputPath}/main.ngb`,
|
|
119
|
+
permissionsManifestPath: `${resolved.outputPath}/permissions.manifest.json`,
|
|
120
|
+
runtimeConfigPath: `${resolved.outputPath}/ng-desktop.runtime.json`,
|
|
121
|
+
packageArtifacts,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builder.js","sourceRoot":"","sources":["../../../../packages/builders-native/src/builder.ts"],"names":[],"mappings":"AAqDA,SAAS,YAAY;IACnB,IAAI,OAAO,OAAO,KAAK,WAAW,EAAE,CAAC;QACnC,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO;YAAE,OAAO,SAAS,CAAC;QACnD,IAAI,OAAO,CAAC,QAAQ,KAAK,QAAQ;YAAE,OAAO,OAAO,CAAC;IACpD,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAS,cAAc;IACrB,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QAC/D,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAS,mBAAmB,CAC1B,EAAiC,EACjC,IAAwC;IAExC,IAAI,EAAE,KAAK,SAAS,EAAE,CAAC;QACrB,OAAO,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,wBAAwB,CAAC;IACnF,CAAC;IACD,IAAI,EAAE,KAAK,OAAO,EAAE,CAAC;QACnB,IAAI,IAAI,KAAK,WAAW;YAAE,OAAO,wBAAwB,CAAC;QAC1D,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,sBAAsB,CAAC;IAC5E,CAAC;IACD,OAAO,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,2BAA2B,CAAC,CAAC,CAAC,0BAA0B,CAAC;AACvF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,0BAA0B,CACxC,WAAmB,EACnB,UAAgC,EAAE;IAElC,IAAI,EAAiC,CAAC;IACtC,IAAI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QAAQ,CAAC,cAAc;QACvC,QAAQ,EAAE,QAAQ,CAAC,QAAQ;QAC3B,UAAU,EAAE,GAAG,QAAQ,CAAC,UAAU,WAAW;QAC7C,uBAAuB,EAAE,GAAG,QAAQ,CAAC,UAAU,4BAA4B;QAC3E,iBAAiB,EAAE,GAAG,QAAQ,CAAC,UAAU,0BAA0B;QACnE,gBAAgB;KACjB,CAAC;AACJ,CAAC","sourcesContent":["export type NativeOsKind = 'auto' | 'linux' | 'windows' | 'macos';\nexport type NativeArchKind = 'auto' | 'x86_64' | 'aarch64' | 'universal';\nexport type NativeCpuProfile = 'auto' | 'native' | 'baseline' | 'avx2' | 'neon';\nexport type NativePlatformTarget = 'linux-gtk4' | 'windows-winui' | 'macos-appkit';\nexport type NativeJsEngineKind = 'jsc' | 'quickjs';\nexport type NativePackageFormat = 'deb' | 'appimage' | 'flatpak' | 'msi' | 'dmg';\nexport type LinuxPackageFormat = 'deb' | 'appimage' | 'flatpak';\nexport type NativePermissionsMode = 'auto' | 'strict';\n\nexport interface NativePermissionsOptions {\n mode?: NativePermissionsMode;\n allow?: string[];\n deny?: string[];\n}\n\nexport interface NativeBuilderOptions {\n os?: NativeOsKind;\n arch?: NativeArchKind;\n cpu?: NativeCpuProfile;\n targetPlatform?: NativePlatformTarget;\n jsEngine?: NativeJsEngineKind;\n outputPath?: string;\n version?: string;\n permissions?: NativePermissionsOptions;\n packageFormats?: NativePackageFormat[];\n}\n\nexport interface ResolvedNativeBuilderConfig {\n os: 'linux' | 'windows' | 'macos';\n arch: 'x86_64' | 'aarch64' | 'universal';\n cpu: NativeCpuProfile;\n targetPlatform: NativePlatformTarget;\n jsEngine: NativeJsEngineKind;\n outputPath: string;\n rustTargetTriple: string;\n packageFormats: NativePackageFormat[];\n}\n\nexport interface NativeBuilderResult {\n success: boolean;\n projectName: string;\n os: 'linux' | 'windows' | 'macos';\n arch: 'x86_64' | 'aarch64' | 'universal';\n cpu: NativeCpuProfile;\n rustTargetTriple: string;\n targetPlatform: NativePlatformTarget;\n jsEngine: NativeJsEngineKind;\n bundlePath: string;\n permissionsManifestPath: string;\n runtimeConfigPath: string;\n packageArtifacts: string[];\n}\n\nfunction detectHostOs(): 'linux' | 'windows' | 'macos' {\n if (typeof process !== 'undefined') {\n if (process.platform === 'win32') return 'windows';\n if (process.platform === 'darwin') return 'macos';\n }\n return 'linux';\n}\n\nfunction detectHostArch(): 'x86_64' | 'aarch64' {\n if (typeof process !== 'undefined' && process.arch === 'arm64') {\n return 'aarch64';\n }\n return 'x86_64';\n}\n\nfunction resolveTargetTriple(\n os: 'linux' | 'windows' | 'macos',\n arch: 'x86_64' | 'aarch64' | 'universal',\n): string {\n if (os === 'windows') {\n return arch === 'aarch64' ? 'aarch64-pc-windows-msvc' : 'x86_64-pc-windows-msvc';\n }\n if (os === 'macos') {\n if (arch === 'universal') return 'universal-apple-darwin';\n return arch === 'x86_64' ? 'x86_64-apple-darwin' : 'aarch64-apple-darwin';\n }\n return arch === 'aarch64' ? 'aarch64-unknown-linux-gnu' : 'x86_64-unknown-linux-gnu';\n}\n\n/**\n * Resolves minimal `angular.json` options (`os`, `arch`, `cpu`) into full target platform,\n * embedded JS engine, Rust target triple, and output directory defaults.\n */\nexport function resolveNativeBuilderConfig(\n projectName: string,\n options: NativeBuilderOptions = {},\n): ResolvedNativeBuilderConfig {\n let os: 'linux' | 'windows' | 'macos';\n if (options.os && options.os !== 'auto') {\n os = options.os;\n } else if (options.targetPlatform === 'windows-winui') {\n os = 'windows';\n } else if (options.targetPlatform === 'macos-appkit') {\n os = 'macos';\n } else if (options.targetPlatform === 'linux-gtk4') {\n os = 'linux';\n } else {\n os = detectHostOs();\n }\n\n const targetPlatform: NativePlatformTarget =\n options.targetPlatform ??\n (os === 'windows' ? 'windows-winui' : os === 'macos' ? 'macos-appkit' : 'linux-gtk4');\n\n const jsEngine: NativeJsEngineKind = options.jsEngine ?? (os === 'windows' ? 'quickjs' : 'jsc');\n\n const arch: 'x86_64' | 'aarch64' | 'universal' =\n options.arch && options.arch !== 'auto' ? options.arch : detectHostArch();\n\n const cpu: NativeCpuProfile = options.cpu ?? 'auto';\n const outputPath = (options.outputPath ?? `dist/${projectName}`).replace(/\\/+$/, '');\n const defaultFormats: NativePackageFormat[] =\n os === 'linux' ? ['deb', 'appimage', 'flatpak'] : os === 'windows' ? ['msi'] : ['dmg'];\n\n return {\n os,\n arch,\n cpu,\n targetPlatform,\n jsEngine,\n outputPath,\n rustTargetTriple: resolveTargetTriple(os, arch),\n packageFormats: options.packageFormats ?? defaultFormats,\n };\n}\n\n/**\n * Generates an `angular.json` `architect.native` target configuration block\n * for `@ng-desktop/builders:application`.\n */\nexport function createNativeTargetConfig(options: NativeBuilderOptions): {\n builder: '@ng-desktop/builders:application';\n options: NativeBuilderOptions;\n} {\n return {\n builder: '@ng-desktop/builders:application',\n options: {\n os: options.os ?? 'linux',\n arch: options.arch ?? 'x86_64',\n ...(options.cpu ? { cpu: options.cpu } : {}),\n ...(options.targetPlatform ? { targetPlatform: options.targetPlatform } : {}),\n ...(options.jsEngine ? { jsEngine: options.jsEngine } : {}),\n ...(options.outputPath ? { outputPath: options.outputPath } : {}),\n ...(options.packageFormats ? { packageFormats: options.packageFormats } : {}),\n },\n };\n}\n\n/**\n * Executes the Angular 22 Native Builder pipeline, resolving minimal OS/CPU config,\n * `.ngb` bundle path, and target distribution artifacts.\n */\nexport function executeNativeBuilder(\n projectName: string,\n options: NativeBuilderOptions,\n): NativeBuilderResult {\n const resolved = resolveNativeBuilderConfig(projectName, options);\n const packageArtifacts: string[] = [];\n\n for (const fmt of resolved.packageFormats) {\n if (fmt === 'deb') {\n packageArtifacts.push(`${resolved.outputPath}/packages/deb/DEBIAN/control`);\n packageArtifacts.push(\n `${resolved.outputPath}/packages/deb/usr/share/applications/${projectName}.desktop`,\n );\n } else if (fmt === 'appimage') {\n packageArtifacts.push(`${resolved.outputPath}/packages/appimage/AppRun`);\n } else if (fmt === 'flatpak') {\n packageArtifacts.push(`${resolved.outputPath}/packages/flatpak/${projectName}.yml`);\n } else if (fmt === 'msi') {\n packageArtifacts.push(`${resolved.outputPath}/packages/windows/${projectName}.msi`);\n } else if (fmt === 'dmg') {\n packageArtifacts.push(`${resolved.outputPath}/packages/macos/${projectName}.dmg`);\n }\n }\n\n return {\n success: true,\n projectName,\n os: resolved.os,\n arch: resolved.arch,\n cpu: resolved.cpu,\n rustTargetTriple: resolved.rustTargetTriple,\n targetPlatform: resolved.targetPlatform,\n jsEngine: resolved.jsEngine,\n bundlePath: `${resolved.outputPath}/main.ngb`,\n permissionsManifestPath: `${resolved.outputPath}/permissions.manifest.json`,\n runtimeConfigPath: `${resolved.outputPath}/ng-desktop.runtime.json`,\n packageArtifacts,\n };\n}\n"]}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
import { watchBundle } from './build-bundle.mjs';
|
|
3
|
+
import { resolveEngineBinaryPath } from './resolve-engine-binary.mjs';
|
|
4
|
+
import { resolveWorkspaceProject } from './workspace-resolver.mjs';
|
|
5
|
+
|
|
6
|
+
const workspace = resolveWorkspaceProject();
|
|
7
|
+
const watcher = watchBundle({
|
|
8
|
+
cwd: workspace.workspaceRoot,
|
|
9
|
+
configPath: workspace.configFile,
|
|
10
|
+
projectName: workspace.projectName,
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
const resolvedEngine = resolveEngineBinaryPath({
|
|
14
|
+
cwd: process.cwd(),
|
|
15
|
+
workspaceRoot: workspace.workspaceRoot,
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const engineArgs = [
|
|
19
|
+
...resolvedEngine.args,
|
|
20
|
+
`--config=${workspace.configFile}`,
|
|
21
|
+
`--project=${workspace.projectName}`,
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
process.stdout.write(
|
|
25
|
+
`[NgDesktop Dev Server] Launching '${workspace.projectName}' via ${resolvedEngine.source} (${resolvedEngine.command})...\n`,
|
|
26
|
+
);
|
|
27
|
+
const engineProc = spawn(resolvedEngine.command, engineArgs, {
|
|
28
|
+
cwd: workspace.workspaceRoot,
|
|
29
|
+
stdio: 'inherit',
|
|
30
|
+
env: process.env,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
function shutdown(code = 0) {
|
|
34
|
+
watcher.close();
|
|
35
|
+
if (!engineProc.killed) {
|
|
36
|
+
engineProc.kill('SIGTERM');
|
|
37
|
+
}
|
|
38
|
+
process.exit(code);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
engineProc.on('exit', (code) => {
|
|
42
|
+
watcher.close();
|
|
43
|
+
process.exit(code ?? 0);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
process.on('SIGINT', () => shutdown(0));
|
|
47
|
+
process.on('SIGTERM', () => shutdown(0));
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface HmrClientResult {
|
|
2
|
+
connected: boolean;
|
|
3
|
+
response?: Record<string, unknown>;
|
|
4
|
+
rawResponse?: string;
|
|
5
|
+
error?: string;
|
|
6
|
+
timeout?: boolean;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function sendHmrMessage(
|
|
10
|
+
socketPath: string,
|
|
11
|
+
message: { type: string; [key: string]: unknown },
|
|
12
|
+
options?: { timeoutMs?: number },
|
|
13
|
+
): Promise<HmrClientResult>;
|
|
14
|
+
|
|
15
|
+
export function pushHmrReload(socketPath: string, bundleScript: string): Promise<HmrClientResult>;
|
|
16
|
+
|
|
17
|
+
export function pushHmrEval(socketPath: string, jsCode: string): Promise<HmrClientResult>;
|
|
18
|
+
|
|
19
|
+
export function pingHmr(socketPath: string): Promise<HmrClientResult>;
|