@ng-desktop/builders 0.0.0-stage → 0.4.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 +200 -0
- package/builders.json +15 -0
- package/fesm2022/application-builder.d.mts +62 -0
- package/fesm2022/application-builder.mjs +58 -0
- package/fesm2022/ast-metadata-extractor.d.mts +40 -0
- package/fesm2022/ast-metadata-extractor.mjs +460 -0
- package/fesm2022/build-bundle.d.mts +45 -0
- package/fesm2022/build-bundle.mjs +462 -0
- package/fesm2022/builder.d.ts +66 -0
- package/fesm2022/builder.js +123 -0
- package/fesm2022/dev-server-builder.d.mts +26 -0
- package/fesm2022/dev-server-builder.mjs +24 -0
- package/fesm2022/dev-server.mjs +47 -0
- package/fesm2022/hmr-client.d.mts +24 -0
- package/fesm2022/hmr-client.mjs +84 -0
- package/fesm2022/icon-compiler.d.mts +6 -0
- package/fesm2022/icon-compiler.mjs +148 -0
- package/fesm2022/index.d.ts +13 -0
- package/fesm2022/index.js +13 -0
- package/fesm2022/permission-analyzer.d.mts +45 -0
- package/fesm2022/permission-analyzer.mjs +333 -0
- package/fesm2022/resolve-engine-binary.d.mts +35 -0
- package/fesm2022/resolve-engine-binary.mjs +130 -0
- package/fesm2022/server-compiler.d.mts +29 -0
- package/fesm2022/server-compiler.mjs +236 -0
- package/fesm2022/style-compiler.d.mts +26 -0
- package/fesm2022/style-compiler.mjs +258 -0
- package/fesm2022/template-compiler.d.mts +53 -0
- package/fesm2022/template-compiler.mjs +892 -0
- package/fesm2022/workspace-resolver.d.mts +24 -0
- package/fesm2022/workspace-resolver.mjs +199 -0
- package/package.json +79 -4
- package/schema/angular-native-schema.json +52 -0
- package/schema/native-builder-schema.json +97 -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,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,24 @@
|
|
|
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 pushHmrServerReload(
|
|
18
|
+
socketPath: string,
|
|
19
|
+
serverBundleCode: string,
|
|
20
|
+
): Promise<HmrClientResult>;
|
|
21
|
+
|
|
22
|
+
export function pushHmrEval(socketPath: string, jsCode: string): Promise<HmrClientResult>;
|
|
23
|
+
|
|
24
|
+
export function pingHmr(socketPath: string): Promise<HmrClientResult>;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import net from 'node:net';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Sends an HMR IPC message to the running native Rust engine over a local Unix domain socket.
|
|
6
|
+
* Gracefully resolves with `{ connected: false }` if the engine is not currently running.
|
|
7
|
+
*/
|
|
8
|
+
export function sendHmrMessage(socketPath, message, { timeoutMs = 1500 } = {}) {
|
|
9
|
+
return new Promise((resolve) => {
|
|
10
|
+
if (!existsSync(socketPath)) {
|
|
11
|
+
resolve({ connected: false, error: 'Socket file not found' });
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const client = net.createConnection(socketPath);
|
|
16
|
+
let resolved = false;
|
|
17
|
+
let responseData = '';
|
|
18
|
+
|
|
19
|
+
const timer = setTimeout(() => {
|
|
20
|
+
if (!resolved) {
|
|
21
|
+
resolved = true;
|
|
22
|
+
client.destroy();
|
|
23
|
+
resolve({ connected: true, timeout: true });
|
|
24
|
+
}
|
|
25
|
+
}, timeoutMs);
|
|
26
|
+
|
|
27
|
+
client.on('connect', () => {
|
|
28
|
+
client.write(JSON.stringify(message) + '\n');
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
client.on('data', (chunk) => {
|
|
32
|
+
responseData += chunk.toString();
|
|
33
|
+
if (responseData.includes('\n')) {
|
|
34
|
+
const line = responseData.split('\n')[0].trim();
|
|
35
|
+
clearTimeout(timer);
|
|
36
|
+
if (!resolved) {
|
|
37
|
+
resolved = true;
|
|
38
|
+
client.end();
|
|
39
|
+
try {
|
|
40
|
+
resolve({ connected: true, response: JSON.parse(line) });
|
|
41
|
+
} catch {
|
|
42
|
+
resolve({ connected: true, rawResponse: line });
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
client.on('error', (err) => {
|
|
49
|
+
clearTimeout(timer);
|
|
50
|
+
if (!resolved) {
|
|
51
|
+
resolved = true;
|
|
52
|
+
resolve({ connected: false, error: err.message });
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Pushes a newly compiled `.ngb` bundle to the live running desktop window.
|
|
60
|
+
*/
|
|
61
|
+
export async function pushHmrReload(socketPath, bundleScript) {
|
|
62
|
+
return sendHmrMessage(socketPath, { type: 'reload', script: bundleScript });
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Pushes a newly compiled `server.bundle.js` to hot-reload the isolated backend worker.
|
|
67
|
+
*/
|
|
68
|
+
export async function pushHmrServerReload(socketPath, serverBundleCode) {
|
|
69
|
+
return sendHmrMessage(socketPath, { type: 'reload_server', bundle: serverBundleCode });
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Evaluates arbitrary JavaScript inside the active runtime of the running desktop window.
|
|
74
|
+
*/
|
|
75
|
+
export async function pushHmrEval(socketPath, jsCode) {
|
|
76
|
+
return sendHmrMessage(socketPath, { type: 'eval', code: jsCode });
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Pings the running desktop engine to check IPC connectivity.
|
|
81
|
+
*/
|
|
82
|
+
export async function pingHmr(socketPath) {
|
|
83
|
+
return sendHmrMessage(socketPath, { type: 'ping' });
|
|
84
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { homedir } from 'node:os';
|
|
3
|
+
import { resolve } from 'node:path';
|
|
4
|
+
import { deflateSync } from 'node:zlib';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Multi-Resolution Icon Compiler (SRP):
|
|
8
|
+
* Decodes 32-bit DIB frames from `favicon.ico` and emits multi-DPI PNGs (`16x16`..`256x256`)
|
|
9
|
+
* for the Freedesktop `hicolor` theme and desktop taskbar integration.
|
|
10
|
+
*/
|
|
11
|
+
function crc32(buf) {
|
|
12
|
+
let crc = 0xffffffff;
|
|
13
|
+
for (let i = 0; i < buf.length; i++) {
|
|
14
|
+
crc ^= buf[i];
|
|
15
|
+
for (let j = 0; j < 8; j++) {
|
|
16
|
+
crc = (crc >>> 1) ^ (crc & 1 ? 0xedb88320 : 0);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return (crc ^ 0xffffffff) >>> 0;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function makePngChunk(type, data) {
|
|
23
|
+
const len = Buffer.alloc(4);
|
|
24
|
+
len.writeUInt32BE(data.length, 0);
|
|
25
|
+
const typeBuf = Buffer.from(type, 'ascii');
|
|
26
|
+
const crcBuf = Buffer.alloc(4);
|
|
27
|
+
crcBuf.writeUInt32BE(crc32(Buffer.concat([typeBuf, data])), 0);
|
|
28
|
+
return Buffer.concat([len, typeBuf, data, crcBuf]);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function encodeRgbaToPng(width, height, rgba) {
|
|
32
|
+
const signature = Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]);
|
|
33
|
+
const ihdr = Buffer.alloc(13);
|
|
34
|
+
ihdr.writeUInt32BE(width, 0);
|
|
35
|
+
ihdr.writeUInt32BE(height, 4);
|
|
36
|
+
ihdr[8] = 8;
|
|
37
|
+
ihdr[9] = 6;
|
|
38
|
+
|
|
39
|
+
const stride = width * 4;
|
|
40
|
+
const rawScanlines = Buffer.alloc((stride + 1) * height);
|
|
41
|
+
for (let y = 0; y < height; y++) {
|
|
42
|
+
const rowStart = y * (stride + 1);
|
|
43
|
+
rawScanlines[rowStart] = 0;
|
|
44
|
+
rgba.copy(rawScanlines, rowStart + 1, y * stride, (y + 1) * stride);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const idat = deflateSync(rawScanlines);
|
|
48
|
+
return Buffer.concat([
|
|
49
|
+
signature,
|
|
50
|
+
makePngChunk('IHDR', ihdr),
|
|
51
|
+
makePngChunk('IDAT', idat),
|
|
52
|
+
makePngChunk('IEND', Buffer.alloc(0)),
|
|
53
|
+
]);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function extractIcoFrames(icoBuf) {
|
|
57
|
+
const count = icoBuf.readUInt16LE(4);
|
|
58
|
+
const frames = [];
|
|
59
|
+
for (let i = 0; i < count; i++) {
|
|
60
|
+
const entryOff = 6 + i * 16;
|
|
61
|
+
const width = icoBuf[entryOff] || 256;
|
|
62
|
+
const height = icoBuf[entryOff + 1] || 256;
|
|
63
|
+
const bpp = icoBuf.readUInt16LE(entryOff + 6);
|
|
64
|
+
const imgOff = icoBuf.readUInt32LE(entryOff + 12);
|
|
65
|
+
|
|
66
|
+
if (bpp !== 32) continue;
|
|
67
|
+
const headerSize = icoBuf.readUInt32LE(imgOff);
|
|
68
|
+
const pixelStart = imgOff + headerSize;
|
|
69
|
+
const rgba = Buffer.alloc(width * height * 4);
|
|
70
|
+
|
|
71
|
+
for (let y = 0; y < height; y++) {
|
|
72
|
+
const srcRow = height - 1 - y;
|
|
73
|
+
for (let x = 0; x < width; x++) {
|
|
74
|
+
const srcIdx = pixelStart + (srcRow * width + x) * 4;
|
|
75
|
+
const dstIdx = (y * width + x) * 4;
|
|
76
|
+
rgba[dstIdx] = icoBuf[srcIdx + 2];
|
|
77
|
+
rgba[dstIdx + 1] = icoBuf[srcIdx + 1];
|
|
78
|
+
rgba[dstIdx + 2] = icoBuf[srcIdx];
|
|
79
|
+
rgba[dstIdx + 3] = icoBuf[srcIdx + 3];
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
frames.push({ width, height, rgba });
|
|
83
|
+
}
|
|
84
|
+
return frames;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function scaleNearest(frame, targetSize) {
|
|
88
|
+
if (frame.width === targetSize && frame.height === targetSize) {
|
|
89
|
+
return frame.rgba;
|
|
90
|
+
}
|
|
91
|
+
const out = Buffer.alloc(targetSize * targetSize * 4);
|
|
92
|
+
for (let y = 0; y < targetSize; y++) {
|
|
93
|
+
const srcY = Math.min(frame.height - 1, Math.floor((y * frame.height) / targetSize));
|
|
94
|
+
for (let x = 0; x < targetSize; x++) {
|
|
95
|
+
const srcX = Math.min(frame.width - 1, Math.floor((x * frame.width) / targetSize));
|
|
96
|
+
const srcIdx = (srcY * frame.width + srcX) * 4;
|
|
97
|
+
const dstIdx = (y * targetSize + x) * 4;
|
|
98
|
+
frame.rgba.copy(out, dstIdx, srcIdx, srcIdx + 4);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return out;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export function buildMultiResolutionIcons(icoAbsPath, appId, outDir, windowTitle) {
|
|
105
|
+
const icoBuf = readFileSync(icoAbsPath);
|
|
106
|
+
const frames = extractIcoFrames(icoBuf);
|
|
107
|
+
if (frames.length === 0) return;
|
|
108
|
+
|
|
109
|
+
frames.sort((a, b) => b.width - a.width);
|
|
110
|
+
const targetSizes = [16, 24, 32, 48, 64, 128, 256];
|
|
111
|
+
const localShare = resolve(homedir(), '.local/share');
|
|
112
|
+
|
|
113
|
+
for (const size of targetSizes) {
|
|
114
|
+
const exact = frames.find((f) => f.width === size) || frames[0];
|
|
115
|
+
const scaledRgba = scaleNearest(exact, size);
|
|
116
|
+
const pngBytes = encodeRgbaToPng(size, size, scaledRgba);
|
|
117
|
+
|
|
118
|
+
const distIconDir = resolve(outDir, 'icons/hicolor', `${size}x${size}`, 'apps');
|
|
119
|
+
mkdirSync(distIconDir, { recursive: true });
|
|
120
|
+
writeFileSync(resolve(distIconDir, `${appId}.png`), pngBytes);
|
|
121
|
+
|
|
122
|
+
try {
|
|
123
|
+
const userIconDir = resolve(localShare, 'icons/hicolor', `${size}x${size}`, 'apps');
|
|
124
|
+
mkdirSync(userIconDir, { recursive: true });
|
|
125
|
+
writeFileSync(resolve(userIconDir, `${appId}.png`), pngBytes);
|
|
126
|
+
} catch {
|
|
127
|
+
// Ignore if running in a restricted sandbox without ~/.local/share write access
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
try {
|
|
132
|
+
const appsDir = resolve(localShare, 'applications');
|
|
133
|
+
mkdirSync(appsDir, { recursive: true });
|
|
134
|
+
const desktopEntry = [
|
|
135
|
+
'[Desktop Entry]',
|
|
136
|
+
'Type=Application',
|
|
137
|
+
`Name=${windowTitle || appId}`,
|
|
138
|
+
`Icon=${appId}`,
|
|
139
|
+
`StartupWMClass=${appId}`,
|
|
140
|
+
'NoDisplay=true',
|
|
141
|
+
'Terminal=false',
|
|
142
|
+
'',
|
|
143
|
+
].join('\n');
|
|
144
|
+
writeFileSync(resolve(appsDir, `${appId}.desktop`), desktopEntry, 'utf8');
|
|
145
|
+
} catch {
|
|
146
|
+
// Ignore if ~/.local/share/applications is not writable
|
|
147
|
+
}
|
|
148
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { extractComponentMetadata, type ComponentDecoratorMeta, type ExtractedComponentMetadata, type MethodMutationMeta, } from './ast-metadata-extractor.mjs';
|
|
2
|
+
export { ARCHITECT_BUILDER_SYMBOL, ARCHITECT_VERSION_SYMBOL, applicationBuilder, createArchitectBuilder, runNativeApplicationBuilder, type ArchitectBuilderContextLike, type ArchitectBuilderObject, type NativeApplicationBuilderOptions, type NativeApplicationBuilderOutput, } from './application-builder.mjs';
|
|
3
|
+
export { devServerBuilder, runNativeDevServerBuilder, type NativeDevServerBuilderOptions, type NativeDevServerBuilderOutput, } from './dev-server-builder.mjs';
|
|
4
|
+
export { compileBundle, emitNgbBundle, watchBundle, type CompileBundleOptions, type CompileBundleResult, type HmrDeltaSummary, } from './build-bundle.mjs';
|
|
5
|
+
export { analyzeProjectPermissions, analyzeSourcePermissions, type NativeCapabilitiesObject, type PermissionAnalysisManifest, type PermissionEvidence, type PermissionPolicyMode, type PermissionsPolicyConfig, } from './permission-analyzer.mjs';
|
|
6
|
+
export { resolveWorkspaceProject, type ResolvedWorkspaceProject, type ResolveWorkspaceOptions, type WorkspaceKind, } from './workspace-resolver.mjs';
|
|
7
|
+
export { ENGINE_BINARY_PACKAGES, resolveEngineBinaryPath, type EngineBinaryPackageMeta, type EngineBinaryResolution, type EngineBinarySource, type ResolveEngineBinaryOptions, } from './resolve-engine-binary.mjs';
|
|
8
|
+
export { createNativeTargetConfig, executeNativeBuilder, resolveNativeBuilderConfig, type LinuxPackageFormat, type NativeArchKind, type NativeBuilderOptions, type NativeBuilderResult, type NativeCpuProfile, type NativeJsEngineKind, type NativeOsKind, type NativePackageFormat, type NativePermissionsMode, type NativePermissionsOptions, type NativePlatformTarget, type ResolvedNativeBuilderConfig, } from './builder';
|
|
9
|
+
export { pingHmr, pushHmrEval, pushHmrReload, pushHmrServerReload, sendHmrMessage, type HmrClientResult, } from './hmr-client.mjs';
|
|
10
|
+
export { buildMultiResolutionIcons } from './icon-compiler.mjs';
|
|
11
|
+
export { emitStyleInstruction, formatStyleRuleExtensions, parseStylesCss, type StyleRuleIr, } from './style-compiler.mjs';
|
|
12
|
+
export { applyPipeTransform, parseTemplateHtml, type ComponentDefinitionIr, type ReactiveBindingIr, type TemplateAstNode, type TemplateIdState, } from './template-compiler.mjs';
|
|
13
|
+
export { compileServerBundle, discoverServerRoutes, type CompileServerBundleOptions, type DiscoveredServerRoute, } from './server-compiler.mjs';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { extractComponentMetadata, } from './ast-metadata-extractor.mjs';
|
|
2
|
+
export { ARCHITECT_BUILDER_SYMBOL, ARCHITECT_VERSION_SYMBOL, applicationBuilder, createArchitectBuilder, runNativeApplicationBuilder, } from './application-builder.mjs';
|
|
3
|
+
export { devServerBuilder, runNativeDevServerBuilder, } from './dev-server-builder.mjs';
|
|
4
|
+
export { compileBundle, emitNgbBundle, watchBundle, } from './build-bundle.mjs';
|
|
5
|
+
export { analyzeProjectPermissions, analyzeSourcePermissions, } from './permission-analyzer.mjs';
|
|
6
|
+
export { resolveWorkspaceProject, } from './workspace-resolver.mjs';
|
|
7
|
+
export { ENGINE_BINARY_PACKAGES, resolveEngineBinaryPath, } from './resolve-engine-binary.mjs';
|
|
8
|
+
export { createNativeTargetConfig, executeNativeBuilder, resolveNativeBuilderConfig, } from './builder.js';
|
|
9
|
+
export { pingHmr, pushHmrEval, pushHmrReload, pushHmrServerReload, sendHmrMessage, } from './hmr-client.mjs';
|
|
10
|
+
export { buildMultiResolutionIcons } from './icon-compiler.mjs';
|
|
11
|
+
export { emitStyleInstruction, formatStyleRuleExtensions, parseStylesCss, } from './style-compiler.mjs';
|
|
12
|
+
export { applyPipeTransform, parseTemplateHtml, } from './template-compiler.mjs';
|
|
13
|
+
export { compileServerBundle, discoverServerRoutes, } from './server-compiler.mjs';
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export type PermissionPolicyMode = 'auto' | 'strict';
|
|
2
|
+
|
|
3
|
+
export interface PermissionsPolicyConfig {
|
|
4
|
+
mode?: PermissionPolicyMode;
|
|
5
|
+
allow?: string[];
|
|
6
|
+
deny?: string[];
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface PermissionEvidence {
|
|
10
|
+
capability: string;
|
|
11
|
+
file: string;
|
|
12
|
+
reason: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface NativeCapabilitiesObject {
|
|
16
|
+
network: boolean;
|
|
17
|
+
sqlite: boolean;
|
|
18
|
+
filesystem: {
|
|
19
|
+
xdg: boolean;
|
|
20
|
+
dialogs: boolean;
|
|
21
|
+
drop: boolean;
|
|
22
|
+
};
|
|
23
|
+
clipboard: boolean;
|
|
24
|
+
notifications: boolean;
|
|
25
|
+
computeThreads: boolean;
|
|
26
|
+
fullSystemAccess: boolean;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface PermissionAnalysisManifest {
|
|
30
|
+
schemaVersion: 1;
|
|
31
|
+
mode: PermissionPolicyMode;
|
|
32
|
+
capabilities: NativeCapabilitiesObject;
|
|
33
|
+
evidence: PermissionEvidence[];
|
|
34
|
+
warnings: string[];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function analyzeSourcePermissions(
|
|
38
|
+
files: ReadonlyArray<{ file: string; content: string }>,
|
|
39
|
+
permissionsConfig?: PermissionsPolicyConfig,
|
|
40
|
+
): PermissionAnalysisManifest;
|
|
41
|
+
|
|
42
|
+
export function analyzeProjectPermissions(
|
|
43
|
+
sourceRoot: string,
|
|
44
|
+
permissionsConfig?: PermissionsPolicyConfig,
|
|
45
|
+
): PermissionAnalysisManifest;
|