@sixb/desktop 0.0.0-stage → 0.2.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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Sixb contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,84 @@
1
- # Temporary Holding Version
1
+ # `@sixb/desktop`
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Ships a Sixb project's app as a desktop app, built with [Electron](https://www.electronjs.org).
4
+ Install it in a project, and the `sixb` CLI does the rest:
5
+
6
+ ```bash
7
+ bun add -d @sixb/desktop
8
+ bun sixb dev --desktop # the dev server, and the app in a desktop window
9
+ bun sixb desktop build # the deployed app, packaged for this machine
10
+ ```
11
+
12
+ See [Desktop App](https://docs.sixb.ai/apps/desktop) for what the desktop app takes from the app,
13
+ signing, and distribution. The rest of this file is how it works.
14
+
15
+ ## How it works
16
+
17
+ The CLI does not depend on this package, because it brings Electron. It loads the project's copy
18
+ and calls its two exports, `openDesktopApp` and `buildDesktopApp`, with the app's URL and the API's
19
+ origin. Both generate the same Electron app first:
20
+
21
+ ```
22
+ <app>/app.webmanifest ─▶ name, icon (src/identity.ts)
23
+ │
24
+ ▼
25
+ .sixb/desktop/app/ rewritten on every call (src/generate.ts)
26
+ main.js the main process, compiled from src/shell/main.ts
27
+ preload.js what the page can reach, compiled from src/shell/preload.ts
28
+ shell.json name, app URL, API origin
29
+ index.html the page shown while the app loads
30
+ icon.png
31
+ │
32
+ ├─ openDesktopApp electron .sixb/desktop/app
33
+ └─ buildDesktopApp @electron/packager ─▶ .sixb/desktop/dist/
34
+ ```
35
+
36
+ The window loads the app from where it is served; `app/` is not compiled into the binary. The
37
+ page runs sandboxed, with no Node, and reaches the shell only through what `src/shell/bridge.ts`
38
+ exposes, which says how to add to it. The window stays on the app and API origins
39
+ (`src/shell/window.ts`): any other link opens in the user's browser.
40
+
41
+ ### macOS builds
42
+
43
+ - **Icon.** `src/mac-icon.ts` redraws the icon on Apple's grid, a rounded square of 824 pixels with
44
+ continuous corners in a canvas of 1024, over a soft shadow. Both were measured against Apple's
45
+ Notes icon. An icon drawn to its edges otherwise stands larger than every icon beside it. It runs
46
+ AppKit through `osascript`, and `sips` and `iconutil` turn the result into `.icns`.
47
+ - **Signature.** Packaging breaks the ad-hoc signature Electron ships with, and macOS calls a
48
+ downloaded app with a broken signature damaged, with no way to open it. An unsigned build is
49
+ re-signed ad hoc, so users can allow it. With `APPLE_API_KEY`, `APPLE_API_KEY_ID` and
50
+ `APPLE_API_ISSUER`, the packager signs with the keychain's Developer ID certificate and notarizes
51
+ instead.
52
+ - **Packager.** `@electron/packager` fails under Bun whenever it verifies a download, so
53
+ `src/packager.mjs` runs it under Electron's own binary as Node.
54
+
55
+ ### Signing in
56
+
57
+ A window like this cannot finish a sign-in on its own: a magic link opens in the user's browser,
58
+ not in the window, and identity providers refuse embedded browsers. So the shell sends the window
59
+ to `GET /auth/sign-in/device` instead of the sign-in page, and opens the approval page in the
60
+ system browser:
61
+
62
+ ```
63
+ window API system browser
64
+ │ app redirects to /auth/sign-in │
65
+ │ shell loads /auth/sign-in/device ─▶ creates an authorization│
66
+ │◀─ "Continue in your browser", cookie holds its secret │
67
+ │ shell opens /auth/device?user_code=… ──────────────────────▶│ signs in if needed,
68
+ │ ◀── Authorize ──────────│ approves
69
+ │ page reloads ─▶ approved: session cookie, back to the app │
70
+ ```
71
+
72
+ The session is an ordinary browser session, kept in the window's persistent cookie store, so later
73
+ launches open straight into the app. `src/shell/navigation.ts` holds those two decisions as a pure
74
+ function; `src/shell/main.ts` wires them to the window.
75
+
76
+ ### Title bar
77
+
78
+ On macOS the window has no title bar: the app draws to the top edge and the window controls float
79
+ over it. Two things a title bar did then come from the shell (`src/shell/window.ts`):
80
+
81
+ - A 36px strip across the top is the handle the window is dragged by. Buttons, links and form
82
+ controls under it still take their clicks; the space between them moves the window.
83
+ - `<html data-sixb-desktop="inset">` and `--sixb-desktop-controls-height` let an app make room for
84
+ the controls. The sidebar of the default `AppShell` is moved down for it already.
@@ -0,0 +1,30 @@
1
+ export interface DesktopAppOptions {
2
+ /** The Sixb project. The desktop app is generated under its `.sixb/desktop`. */
3
+ readonly projectRoot: string;
4
+ /** Where the app is served. The window opens it; the desktop app takes its name and icon from it. */
5
+ readonly appUrl: string;
6
+ /** The project's API. Its sign-in pages are where the window is approved. */
7
+ readonly apiOrigin: string;
8
+ }
9
+ /** The Electron app `writeDesktopApp` generated, and what it is called. */
10
+ export interface GeneratedApp {
11
+ readonly dir: string;
12
+ readonly name: string;
13
+ readonly version: string;
14
+ /** The app's icon in `dir`, when it declares one. */
15
+ readonly icon: string | null;
16
+ }
17
+ /** Where a project's desktop app is generated (`app`) and packaged (`dist`). */
18
+ export declare function desktopDir(projectRoot: string, part: "app" | "dist"): string;
19
+ /**
20
+ * Writes the Electron app that opens `appUrl` into the project's `.sixb/desktop/app`. The directory
21
+ * is build-owned, like the rest of `.sixb`: it is cleared on every call.
22
+ */
23
+ export declare function writeDesktopApp(options: DesktopAppOptions): Promise<GeneratedApp>;
24
+ /** The page the window shows while the app loads, and when it cannot reach the app. */
25
+ export declare function renderShellPage(template: string, page: {
26
+ readonly name: string;
27
+ readonly appUrl: string;
28
+ readonly icon: boolean;
29
+ }): string;
30
+ //# sourceMappingURL=generate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../src/generate.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,iBAAiB;IAChC,gFAAgF;IAChF,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,qGAAqG;IACrG,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,6EAA6E;IAC7E,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;CAC3B;AAED,2EAA2E;AAC3E,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,qDAAqD;IACrD,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;CAC7B;AAKD,gFAAgF;AAChF,wBAAgB,UAAU,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,GAAG,MAAM,GAAG,MAAM,CAE5E;AAED;;;GAGG;AACH,wBAAsB,eAAe,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,YAAY,CAAC,CA4CvF;AAED,uFAAuF;AACvF,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;CAAE,GAC/E,MAAM,CAYR"}
@@ -0,0 +1,22 @@
1
+ /** What the desktop app takes from the web app it opens. */
2
+ export interface AppIdentity {
3
+ /** The app's name: `metadata.title` in `app/layout.tsx`. */
4
+ readonly name: string;
5
+ /**
6
+ * The app's maskable icon, such as `app/public/icon-maskable-512.png`, or else its largest PNG
7
+ * icon, such as `app/public/icon-512.png`.
8
+ */
9
+ readonly icon: Uint8Array | null;
10
+ }
11
+ /**
12
+ * Reads the app's web app manifest, the one a browser installs the app from. The desktop app is
13
+ * the same app installed another way, so it takes the same name and icon and has no settings of
14
+ * its own.
15
+ */
16
+ export declare function readAppIdentity(appUrl: string): Promise<AppIdentity>;
17
+ /**
18
+ * The app's id on the desktop, from the address it opens: `https://orders.acme.com` becomes
19
+ * `com.acme.orders`. Each deployment gets its own, so a staging build installs beside production.
20
+ */
21
+ export declare function bundleIdentifier(appUrl: string): string;
22
+ //# sourceMappingURL=identity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,MAAM,WAAW,WAAW;IAC1B,4DAA4D;IAC5D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB;;;OAGG;IACH,QAAQ,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,CAAA;CACjC;AAED;;;;GAIG;AACH,wBAAsB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAa1E;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAOvD"}
@@ -0,0 +1,18 @@
1
+ import { type DesktopAppOptions } from "./generate";
2
+ export type { DesktopAppOptions } from "./generate";
3
+ export interface DesktopWindow {
4
+ /** Resolves with Electron's exit code once the user quits it. */
5
+ readonly exited: Promise<number>;
6
+ close(): void;
7
+ }
8
+ export interface DesktopBuild {
9
+ /** What to hand to users: a zip of the app on macOS, the app's folder elsewhere. */
10
+ readonly path: string;
11
+ /** Whether it was signed and notarized, and so opens without a warning. */
12
+ readonly signed: boolean;
13
+ }
14
+ /** Opens the app in a desktop window. `sixb dev --desktop` calls this. */
15
+ export declare function openDesktopApp(options: DesktopAppOptions): Promise<DesktopWindow>;
16
+ /** Packages the app for this machine's platform. `sixb desktop build` calls this. */
17
+ export declare function buildDesktopApp(options: DesktopAppOptions): Promise<DesktopBuild>;
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,iBAAiB,EAA+B,MAAM,YAAY,CAAA;AAIhF,YAAY,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAEnD,MAAM,WAAW,aAAa;IAC5B,iEAAiE;IACjE,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAA;IAChC,KAAK,IAAI,IAAI,CAAA;CACd;AAED,MAAM,WAAW,YAAY;IAC3B,oFAAoF;IACpF,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,2EAA2E;IAC3E,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAA;CACzB;AAMD,0EAA0E;AAC1E,wBAAsB,cAAc,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,aAAa,CAAC,CAsBvF;AAED,qFAAqF;AACrF,wBAAsB,eAAe,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,YAAY,CAAC,CAiCvF"}
package/dist/index.js ADDED
@@ -0,0 +1,326 @@
1
+ // @bun
2
+ // src/index.ts
3
+ import { mkdir as mkdir2, readdir, rm as rm2 } from "fs/promises";
4
+ import { createRequire } from "module";
5
+ import { dirname, join as join2 } from "path";
6
+ import { fileURLToPath as fileURLToPath2 } from "url";
7
+
8
+ // src/generate.ts
9
+ import { mkdir, readFile, rm, writeFile } from "fs/promises";
10
+ import { join } from "path";
11
+ import { fileURLToPath } from "url";
12
+
13
+ // src/identity.ts
14
+ async function readAppIdentity(appUrl) {
15
+ const manifestUrl = new URL("/app.webmanifest", appUrl);
16
+ const manifest = await (await fetchFromApp(manifestUrl)).json();
17
+ const { name, icons } = typeof manifest === "object" && manifest !== null ? manifest : {};
18
+ const iconUrl = desktopIcon(icons, manifestUrl);
19
+ return {
20
+ name: typeof name === "string" && name.trim() ? name.trim() : "Sixb",
21
+ icon: iconUrl ? new Uint8Array(await (await fetchFromApp(iconUrl)).arrayBuffer()) : null
22
+ };
23
+ }
24
+ function bundleIdentifier(appUrl) {
25
+ const labels = new URL(appUrl).hostname.split(".").reverse().map((label) => label.toLowerCase().replaceAll(/[^a-z0-9-]/g, "-")).filter(Boolean);
26
+ return (labels.length > 1 ? labels : ["local", ...labels]).join(".");
27
+ }
28
+ function desktopIcon(icons, manifestUrl) {
29
+ let best = null;
30
+ for (const icon of Array.isArray(icons) ? icons : []) {
31
+ if (typeof icon !== "object" || icon === null)
32
+ continue;
33
+ const { src, sizes, type, purpose } = icon;
34
+ if (typeof src !== "string")
35
+ continue;
36
+ const url = new URL(src, manifestUrl);
37
+ if (type === undefined ? !url.pathname.endsWith(".png") : type !== "image/png")
38
+ continue;
39
+ const maskable = typeof purpose === "string" && purpose.split(/\s+/).includes("maskable");
40
+ const size = Math.max(0, ...(typeof sizes === "string" ? sizes.split(/\s+/) : []).map((entry) => Number.parseInt(entry, 10) || 0));
41
+ const rank = [maskable ? 1 : 0, size];
42
+ if (!best || rank[0] > best.rank[0] || rank[0] === best.rank[0] && rank[1] > best.rank[1]) {
43
+ best = { url, rank };
44
+ }
45
+ }
46
+ return best?.url ?? null;
47
+ }
48
+ async function fetchFromApp(url) {
49
+ let response;
50
+ try {
51
+ response = await fetch(url);
52
+ } catch (error) {
53
+ throw new Error(`[SixbDesktop] Could not reach ${url} (${error instanceof Error ? error.message : error}). ` + "The desktop app takes its name and icon from the app, so the app must be running there.");
54
+ }
55
+ if (!response.ok)
56
+ throw new Error(`[SixbDesktop] ${url} answered ${response.status}.`);
57
+ return response;
58
+ }
59
+
60
+ // src/run.ts
61
+ async function run(command, failure) {
62
+ const child = Bun.spawn([...command], {
63
+ stdio: ["ignore", "ignore", "pipe"],
64
+ timeout: 120000
65
+ });
66
+ const [exitCode, errors] = await Promise.all([child.exited, new Response(child.stderr).text()]);
67
+ if (exitCode !== 0) {
68
+ throw new Error(`[SixbDesktop] ${failure}${errors.trim() ? `
69
+ ${errors.trim()}` : ""}`);
70
+ }
71
+ }
72
+
73
+ // src/mac-icon.ts
74
+ async function drawMacIcon(png, out) {
75
+ await run(["osascript", "-l", "JavaScript", "-e", MAC_ICON_SCRIPT, png, out], "Could not draw the macOS icon.");
76
+ }
77
+ var MAC_ICON_SCRIPT = `
78
+ ObjC.import("AppKit")
79
+ ObjC.import("CoreGraphics")
80
+
81
+ function run([input, output]) {
82
+ const canvas = 1024
83
+ const body = 824
84
+ const radius = 185.4
85
+ const min = (canvas - body) / 2
86
+ const max = min + body
87
+
88
+ // One corner, as offsets in radii from the edge it leaves and the edge it joins.
89
+ const corner = [
90
+ [[1.52866483, 0]],
91
+ [[0.66993427, 0.065496], [1.08849323, 0], [0.86840689, 0.02065986]],
92
+ [[0.63149399, 0.074911]],
93
+ [[0.074911, 0.63149399], [0.37282392, 0.16906933], [0.16906933, 0.37282392]],
94
+ [[0.065496, 0.66993427]],
95
+ [[0, 1.52866483], [0.02065986, 0.86840689], [0, 1.08849323]],
96
+ ]
97
+ const corners = [
98
+ ([u, v]) => $.NSMakePoint(max - u * radius, max - v * radius),
99
+ ([u, v]) => $.NSMakePoint(max - v * radius, min + u * radius),
100
+ ([u, v]) => $.NSMakePoint(min + u * radius, min + v * radius),
101
+ ([u, v]) => $.NSMakePoint(min + v * radius, max - u * radius),
102
+ ]
103
+ const shape = $.NSBezierPath.bezierPath
104
+ shape.moveToPoint(corners[3]([0, 1.52866483]))
105
+ for (const at of corners) {
106
+ for (const [to, c1, c2] of corner) {
107
+ if (c1) shape.curveToPointControlPoint1ControlPoint2(at(to), at(c1), at(c2))
108
+ else shape.lineToPoint(at(to))
109
+ }
110
+ }
111
+ shape.closePath
112
+
113
+ const image = $.NSImage.alloc.initWithContentsOfFile(input)
114
+ if (image.isNil()) throw new Error("Cannot read " + input)
115
+ const bitmap = $.NSBitmapImageRep.alloc
116
+ .initWithBitmapDataPlanesPixelsWidePixelsHighBitsPerSampleSamplesPerPixelHasAlphaIsPlanarColorSpaceNameBytesPerRowBitsPerPixel(
117
+ null, canvas, canvas, 8, 4, true, false, $.NSDeviceRGBColorSpace, 0, 0
118
+ )
119
+ const context = $.NSGraphicsContext.graphicsContextWithBitmapImageRep(bitmap)
120
+ $.NSGraphicsContext.setCurrentContext(context)
121
+ context.setImageInterpolation($.NSImageInterpolationHigh)
122
+
123
+ const shadow = $.NSShadow.alloc.init
124
+ shadow.setShadowOffset($.NSMakeSize(0, -8))
125
+ shadow.setShadowBlurRadius(30)
126
+ shadow.setShadowColor($.NSColor.colorWithWhiteAlpha(0, 0.22))
127
+ shadow.set
128
+ // A layer, so the shadow falls from the clipped icon and not from the clip.
129
+ $.CGContextBeginTransparencyLayer(context.CGContext, null)
130
+ shape.addClip
131
+ image.drawInRectFromRectOperationFraction(
132
+ $.NSMakeRect(min, min, body, body), $.NSZeroRect, $.NSCompositingOperationSourceOver, 1
133
+ )
134
+ $.CGContextEndTransparencyLayer(context.CGContext)
135
+ context.flushGraphics
136
+
137
+ const png = bitmap.representationUsingTypeProperties($.NSBitmapImageFileTypePNG, $.NSDictionary.dictionary)
138
+ if (!png.writeToFileAtomically(output, true)) throw new Error("Cannot write " + output)
139
+ }
140
+ `;
141
+
142
+ // src/generate.ts
143
+ var SHELL_SOURCE_DIR = fileURLToPath(new URL("../src/shell", import.meta.url));
144
+ function desktopDir(projectRoot, part) {
145
+ return join(projectRoot, ".sixb", "desktop", part);
146
+ }
147
+ async function writeDesktopApp(options) {
148
+ const identity = await readAppIdentity(options.appUrl);
149
+ const version = await readProjectVersion(options.projectRoot);
150
+ const dir = desktopDir(options.projectRoot, "app");
151
+ await rm(dir, { recursive: true, force: true });
152
+ await mkdir(dir, { recursive: true });
153
+ const config = {
154
+ name: identity.name,
155
+ appUrl: new URL(options.appUrl).href,
156
+ apiOrigin: new URL(options.apiOrigin).origin
157
+ };
158
+ const manifest = {
159
+ name: "sixb-desktop-app",
160
+ productName: identity.name,
161
+ version,
162
+ private: true,
163
+ main: "main.js"
164
+ };
165
+ const icon = identity.icon ? await writeIcon(dir, identity.icon) : null;
166
+ const template = await readFile(join(SHELL_SOURCE_DIR, "index.html"), "utf-8");
167
+ await Promise.all([
168
+ writeFile(join(dir, "package.json"), `${JSON.stringify(manifest, null, 2)}
169
+ `),
170
+ writeFile(join(dir, "shell.json"), `${JSON.stringify(config, null, 2)}
171
+ `),
172
+ writeFile(join(dir, "index.html"), renderShellPage(template, { ...config, icon: !!icon }))
173
+ ]);
174
+ await run([
175
+ process.execPath,
176
+ "build",
177
+ join(SHELL_SOURCE_DIR, "main.ts"),
178
+ join(SHELL_SOURCE_DIR, "preload.ts"),
179
+ "--target=node",
180
+ "--format=cjs",
181
+ "--external=electron",
182
+ `--outdir=${dir}`
183
+ ], "Could not compile the desktop shell.");
184
+ return { dir, name: identity.name, version, icon };
185
+ }
186
+ function renderShellPage(template, page) {
187
+ const initial = Array.from(page.name.trim())[0]?.toUpperCase() ?? "";
188
+ const markup = {
189
+ name: escapeHtml(page.name),
190
+ host: escapeHtml(new URL(page.appUrl).host),
191
+ appUrl: escapeHtml(page.appUrl),
192
+ mark: page.icon ? '<img class="mark" src="icon.png" alt="" />' : `<div class="mark" aria-hidden="true">${escapeHtml(initial)}</div>`
193
+ };
194
+ return template.replaceAll(/\{\{(\w+)\}\}/g, (_match, key) => markup[key] ?? "");
195
+ }
196
+ async function writeIcon(dir, png) {
197
+ const icon = join(dir, "icon.png");
198
+ if (process.platform !== "darwin") {
199
+ await writeFile(icon, png);
200
+ return icon;
201
+ }
202
+ const source = join(dir, "..", "icon-source.png");
203
+ await writeFile(source, png);
204
+ await drawMacIcon(source, icon);
205
+ return icon;
206
+ }
207
+ async function readProjectVersion(projectRoot) {
208
+ try {
209
+ const manifest = JSON.parse(await readFile(join(projectRoot, "package.json"), "utf-8"));
210
+ const version = manifest?.version;
211
+ return typeof version === "string" ? version : "0.0.0";
212
+ } catch {
213
+ return "0.0.0";
214
+ }
215
+ }
216
+ function escapeHtml(value) {
217
+ return value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;");
218
+ }
219
+
220
+ // src/index.ts
221
+ var packageRequire = createRequire(import.meta.url);
222
+ var PACKAGER_SCRIPT = fileURLToPath2(new URL("../src/packager.mjs", import.meta.url));
223
+ async function openDesktopApp(options) {
224
+ const app = await writeDesktopApp(options);
225
+ const log = join2(dirname(app.dir), "electron.log");
226
+ const electron = Bun.spawn([electronBinary(), app.dir], {
227
+ stdio: ["ignore", "ignore", Bun.file(log)]
228
+ });
229
+ let closing = false;
230
+ const exited = electron.exited.then((code) => {
231
+ if (code !== 0 && !closing) {
232
+ console.error(`[SixbDesktop] The desktop window quit with exit code ${code}. See ${log}.`);
233
+ }
234
+ return code;
235
+ });
236
+ return {
237
+ exited,
238
+ close: () => {
239
+ closing = true;
240
+ electron.kill();
241
+ }
242
+ };
243
+ }
244
+ async function buildDesktopApp(options) {
245
+ const app = await writeDesktopApp(options);
246
+ const out = desktopDir(options.projectRoot, "dist");
247
+ await rm2(out, { recursive: true, force: true });
248
+ const mac = process.platform === "darwin";
249
+ const notarize = mac ? appleNotarization() : null;
250
+ const packaged = await packageApp({
251
+ dir: app.dir,
252
+ name: app.name,
253
+ out,
254
+ appBundleId: bundleIdentifier(options.appUrl),
255
+ appVersion: app.version,
256
+ electronVersion: packageRequire("electron/package.json").version,
257
+ ...mac && app.icon ? { icon: await macIcon(app.icon) } : {},
258
+ ...notarize ? { osxSign: {}, osxNotarize: notarize } : {}
259
+ });
260
+ if (!mac)
261
+ return { path: packaged, signed: false };
262
+ const name = (await readdir(packaged)).find((entry) => entry.endsWith(".app"));
263
+ if (!name)
264
+ throw new Error(`[SixbDesktop] The packaged app is missing from ${packaged}.`);
265
+ const bundle = join2(packaged, name);
266
+ if (!notarize) {
267
+ await run(["codesign", "--force", "--deep", "--sign", "-", bundle], "Could not sign the app.");
268
+ }
269
+ const zip = `${packaged}.zip`;
270
+ await run(["ditto", "-c", "-k", "--keepParent", bundle, zip], "Could not zip the app.");
271
+ return { path: zip, signed: notarize !== null };
272
+ }
273
+ function appleNotarization() {
274
+ const { APPLE_API_KEY, APPLE_API_KEY_ID, APPLE_API_ISSUER } = process.env;
275
+ if (!APPLE_API_KEY && !APPLE_API_KEY_ID && !APPLE_API_ISSUER)
276
+ return null;
277
+ if (!APPLE_API_KEY || !APPLE_API_KEY_ID || !APPLE_API_ISSUER) {
278
+ throw new Error("[SixbDesktop] Set all of APPLE_API_KEY, APPLE_API_KEY_ID and APPLE_API_ISSUER to sign the " + "macOS app, or none of them to build it unsigned.");
279
+ }
280
+ return {
281
+ appleApiKey: APPLE_API_KEY,
282
+ appleApiKeyId: APPLE_API_KEY_ID,
283
+ appleApiIssuer: APPLE_API_ISSUER
284
+ };
285
+ }
286
+ async function macIcon(png) {
287
+ const desktop = dirname(dirname(png));
288
+ const iconset = join2(desktop, "icon.iconset");
289
+ await rm2(iconset, { recursive: true, force: true });
290
+ await mkdir2(iconset);
291
+ const sizes = [16, 32, 128, 256, 512].flatMap((points) => [
292
+ { name: `icon_${points}x${points}.png`, pixels: points },
293
+ { name: `icon_${points}x${points}@2x.png`, pixels: points * 2 }
294
+ ]);
295
+ await Promise.all(sizes.map(({ name, pixels }) => run(["sips", "-z", `${pixels}`, `${pixels}`, png, "--out", join2(iconset, name)], "Could not scale the icon.")));
296
+ const icns = join2(desktop, "icon.icns");
297
+ await run(["iconutil", "-c", "icns", iconset, "-o", icns], "Could not convert the icon.");
298
+ return icns;
299
+ }
300
+ async function packageApp(options) {
301
+ const packager = Bun.spawn([electronBinary(), PACKAGER_SCRIPT, JSON.stringify({ ...options, quiet: true })], {
302
+ stdio: ["ignore", "inherit", "inherit"],
303
+ env: { ...process.env, ELECTRON_RUN_AS_NODE: "1", ELECTRON_NO_ASAR: "1" }
304
+ });
305
+ if (await packager.exited !== 0) {
306
+ throw new Error("[SixbDesktop] Packaging failed. See the output above.");
307
+ }
308
+ const [written] = await readdir(options.out);
309
+ if (!written)
310
+ throw new Error(`[SixbDesktop] The packager wrote nothing to ${options.out}.`);
311
+ return join2(options.out, written);
312
+ }
313
+ function electronBinary() {
314
+ try {
315
+ return packageRequire("electron");
316
+ } catch {
317
+ const electronDir = dirname(packageRequire.resolve("electron/package.json"));
318
+ throw new Error("[SixbDesktop] Electron's binary is missing: its install script did not run. " + `Run \`bun run --cwd ${electronDir} postinstall\`, then try again.`);
319
+ }
320
+ }
321
+ export {
322
+ buildDesktopApp,
323
+ openDesktopApp
324
+ };
325
+
326
+ //# debugId=AA1E41BFA25EB6CC64756E2164756E21
@@ -0,0 +1,14 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/index.ts", "../src/generate.ts", "../src/identity.ts", "../src/run.ts", "../src/mac-icon.ts"],
4
+ "sourcesContent": [
5
+ "import { mkdir, readdir, rm } from \"node:fs/promises\"\nimport { createRequire } from \"node:module\"\nimport { dirname, join } from \"node:path\"\nimport { fileURLToPath } from \"node:url\"\nimport { type DesktopAppOptions, desktopDir, writeDesktopApp } from \"./generate\"\nimport { bundleIdentifier } from \"./identity\"\nimport { run } from \"./run\"\n\nexport type { DesktopAppOptions } from \"./generate\"\n\nexport interface DesktopWindow {\n /** Resolves with Electron's exit code once the user quits it. */\n readonly exited: Promise<number>\n close(): void\n}\n\nexport interface DesktopBuild {\n /** What to hand to users: a zip of the app on macOS, the app's folder elsewhere. */\n readonly path: string\n /** Whether it was signed and notarized, and so opens without a warning. */\n readonly signed: boolean\n}\n\nconst packageRequire = createRequire(import.meta.url)\n// From the package's `src`, like the shell: see `SHELL_SOURCE_DIR`.\nconst PACKAGER_SCRIPT = fileURLToPath(new URL(\"../src/packager.mjs\", import.meta.url))\n\n/** Opens the app in a desktop window. `sixb dev --desktop` calls this. */\nexport async function openDesktopApp(options: DesktopAppOptions): Promise<DesktopWindow> {\n const app = await writeDesktopApp(options)\n // Chromium writes plenty to stderr when all is well, so it goes to a file, named if the window\n // quits on its own with an error.\n const log = join(dirname(app.dir), \"electron.log\")\n const electron = Bun.spawn([electronBinary(), app.dir], {\n stdio: [\"ignore\", \"ignore\", Bun.file(log)],\n })\n let closing = false\n const exited = electron.exited.then((code) => {\n if (code !== 0 && !closing) {\n console.error(`[SixbDesktop] The desktop window quit with exit code ${code}. See ${log}.`)\n }\n return code\n })\n return {\n exited,\n close: () => {\n closing = true\n electron.kill()\n },\n }\n}\n\n/** Packages the app for this machine's platform. `sixb desktop build` calls this. */\nexport async function buildDesktopApp(options: DesktopAppOptions): Promise<DesktopBuild> {\n const app = await writeDesktopApp(options)\n const out = desktopDir(options.projectRoot, \"dist\")\n await rm(out, { recursive: true, force: true })\n\n const mac = process.platform === \"darwin\"\n const notarize = mac ? appleNotarization() : null\n const packaged = await packageApp({\n dir: app.dir,\n name: app.name,\n out,\n appBundleId: bundleIdentifier(options.appUrl),\n appVersion: app.version,\n electronVersion: (packageRequire(\"electron/package.json\") as { readonly version: string })\n .version,\n ...(mac && app.icon ? { icon: await macIcon(app.icon) } : {}),\n // Signs with the Developer ID certificate in the keychain, which notarization requires.\n ...(notarize ? { osxSign: {}, osxNotarize: notarize } : {}),\n })\n if (!mac) return { path: packaged, signed: false }\n\n const name = (await readdir(packaged)).find((entry) => entry.endsWith(\".app\"))\n if (!name) throw new Error(`[SixbDesktop] The packaged app is missing from ${packaged}.`)\n const bundle = join(packaged, name)\n // Packaging breaks the ad-hoc signature Electron ships with. macOS calls a downloaded app with a\n // broken signature damaged, and offers no way to open it; signed ad hoc, it can be allowed.\n if (!notarize) {\n await run([\"codesign\", \"--force\", \"--deep\", \"--sign\", \"-\", bundle], \"Could not sign the app.\")\n }\n // `ditto`, not `zip`: it keeps the bundle's symlinks, and with them its signature.\n const zip = `${packaged}.zip`\n await run([\"ditto\", \"-c\", \"-k\", \"--keepParent\", bundle, zip], \"Could not zip the app.\")\n return { path: zip, signed: notarize !== null }\n}\n\n/**\n * An App Store Connect API key, which notarizes the app so macOS opens it without a warning.\n * Without one, the app is built unsigned.\n */\nfunction appleNotarization(): {\n readonly appleApiKey: string\n readonly appleApiKeyId: string\n readonly appleApiIssuer: string\n} | null {\n const { APPLE_API_KEY, APPLE_API_KEY_ID, APPLE_API_ISSUER } = process.env\n if (!APPLE_API_KEY && !APPLE_API_KEY_ID && !APPLE_API_ISSUER) return null\n if (!APPLE_API_KEY || !APPLE_API_KEY_ID || !APPLE_API_ISSUER) {\n throw new Error(\n \"[SixbDesktop] Set all of APPLE_API_KEY, APPLE_API_KEY_ID and APPLE_API_ISSUER to sign the \" +\n \"macOS app, or none of them to build it unsigned.\"\n )\n }\n return {\n appleApiKey: APPLE_API_KEY,\n appleApiKeyId: APPLE_API_KEY_ID,\n appleApiIssuer: APPLE_API_ISSUER,\n }\n}\n\n/**\n * The packager wants `.icns`: every size macOS shows, scaled from the 1024-pixel icon, in one file.\n * `sips` and `iconutil` ship with every Mac. Written beside the app, not in it: everything in the\n * app's directory ships inside the bundle.\n */\nasync function macIcon(png: string): Promise<string> {\n const desktop = dirname(dirname(png))\n const iconset = join(desktop, \"icon.iconset\")\n await rm(iconset, { recursive: true, force: true })\n await mkdir(iconset)\n const sizes = [16, 32, 128, 256, 512].flatMap((points) => [\n { name: `icon_${points}x${points}.png`, pixels: points },\n { name: `icon_${points}x${points}@2x.png`, pixels: points * 2 },\n ])\n await Promise.all(\n sizes.map(({ name, pixels }) =>\n run(\n [\"sips\", \"-z\", `${pixels}`, `${pixels}`, png, \"--out\", join(iconset, name)],\n \"Could not scale the icon.\"\n )\n )\n )\n const icns = join(desktop, \"icon.icns\")\n await run([\"iconutil\", \"-c\", \"icns\", iconset, \"-o\", icns], \"Could not convert the icon.\")\n return icns\n}\n\n/**\n * Runs `@electron/packager` into `options.out`, which starts empty, and resolves with the one\n * directory it wrote there. Under Electron's own binary, which doubles as the Node the packager was\n * written for: under Bun, the packager fails whenever it verifies a download (its checksum\n * dependency does not load).\n */\nasync function packageApp(\n options: { readonly out: string } & Record<string, unknown>\n): Promise<string> {\n const packager = Bun.spawn(\n [electronBinary(), PACKAGER_SCRIPT, JSON.stringify({ ...options, quiet: true })],\n {\n stdio: [\"ignore\", \"inherit\", \"inherit\"],\n // Without the second, Electron's file system reads the `app.asar` the packager writes as a\n // directory.\n env: { ...process.env, ELECTRON_RUN_AS_NODE: \"1\", ELECTRON_NO_ASAR: \"1\" },\n }\n )\n if ((await packager.exited) !== 0) {\n throw new Error(\"[SixbDesktop] Packaging failed. See the output above.\")\n }\n const [written] = await readdir(options.out)\n if (!written) throw new Error(`[SixbDesktop] The packager wrote nothing to ${options.out}.`)\n return join(options.out, written)\n}\n\n// Outside Electron, `require(\"electron\")` is the path of the binary its install script fetched.\nfunction electronBinary(): string {\n try {\n return packageRequire(\"electron\") as string\n } catch {\n const electronDir = dirname(packageRequire.resolve(\"electron/package.json\"))\n throw new Error(\n \"[SixbDesktop] Electron's binary is missing: its install script did not run. \" +\n `Run \\`bun run --cwd ${electronDir} postinstall\\`, then try again.`\n )\n }\n}\n",
6
+ "import { mkdir, readFile, rm, writeFile } from \"node:fs/promises\"\nimport { join } from \"node:path\"\nimport { fileURLToPath } from \"node:url\"\nimport { readAppIdentity } from \"./identity\"\nimport { drawMacIcon } from \"./mac-icon\"\nimport { run } from \"./run\"\nimport type { ShellConfig } from \"./shell/navigation\"\n\nexport interface DesktopAppOptions {\n /** The Sixb project. The desktop app is generated under its `.sixb/desktop`. */\n readonly projectRoot: string\n /** Where the app is served. The window opens it; the desktop app takes its name and icon from it. */\n readonly appUrl: string\n /** The project's API. Its sign-in pages are where the window is approved. */\n readonly apiOrigin: string\n}\n\n/** The Electron app `writeDesktopApp` generated, and what it is called. */\nexport interface GeneratedApp {\n readonly dir: string\n readonly name: string\n readonly version: string\n /** The app's icon in `dir`, when it declares one. */\n readonly icon: string | null\n}\n\n// Read from the package's `src`, which ships, whether this module runs from `src` or `dist`.\nconst SHELL_SOURCE_DIR = fileURLToPath(new URL(\"../src/shell\", import.meta.url))\n\n/** Where a project's desktop app is generated (`app`) and packaged (`dist`). */\nexport function desktopDir(projectRoot: string, part: \"app\" | \"dist\"): string {\n return join(projectRoot, \".sixb\", \"desktop\", part)\n}\n\n/**\n * Writes the Electron app that opens `appUrl` into the project's `.sixb/desktop/app`. The directory\n * is build-owned, like the rest of `.sixb`: it is cleared on every call.\n */\nexport async function writeDesktopApp(options: DesktopAppOptions): Promise<GeneratedApp> {\n const identity = await readAppIdentity(options.appUrl)\n const version = await readProjectVersion(options.projectRoot)\n const dir = desktopDir(options.projectRoot, \"app\")\n await rm(dir, { recursive: true, force: true })\n await mkdir(dir, { recursive: true })\n\n const config: ShellConfig = {\n name: identity.name,\n appUrl: new URL(options.appUrl).href,\n apiOrigin: new URL(options.apiOrigin).origin,\n }\n const manifest = {\n name: \"sixb-desktop-app\",\n // Names the folder the window's cookies are kept in, so each app has its own sign-in.\n productName: identity.name,\n version,\n private: true,\n main: \"main.js\",\n }\n const icon = identity.icon ? await writeIcon(dir, identity.icon) : null\n const template = await readFile(join(SHELL_SOURCE_DIR, \"index.html\"), \"utf-8\")\n await Promise.all([\n writeFile(join(dir, \"package.json\"), `${JSON.stringify(manifest, null, 2)}\\n`),\n writeFile(join(dir, \"shell.json\"), `${JSON.stringify(config, null, 2)}\\n`),\n writeFile(join(dir, \"index.html\"), renderShellPage(template, { ...config, icon: !!icon })),\n ])\n\n // Electron loads plain JavaScript. A child process, because an in-process `Bun.build()` that\n // wedges takes its caller down with it.\n await run(\n [\n process.execPath,\n \"build\",\n join(SHELL_SOURCE_DIR, \"main.ts\"),\n join(SHELL_SOURCE_DIR, \"preload.ts\"),\n \"--target=node\",\n \"--format=cjs\",\n \"--external=electron\",\n `--outdir=${dir}`,\n ],\n \"Could not compile the desktop shell.\"\n )\n return { dir, name: identity.name, version, icon }\n}\n\n/** The page the window shows while the app loads, and when it cannot reach the app. */\nexport function renderShellPage(\n template: string,\n page: { readonly name: string; readonly appUrl: string; readonly icon: boolean }\n): string {\n const initial = Array.from(page.name.trim())[0]?.toUpperCase() ?? \"\"\n const markup: Record<string, string> = {\n name: escapeHtml(page.name),\n host: escapeHtml(new URL(page.appUrl).host),\n appUrl: escapeHtml(page.appUrl),\n // The app's icon, or the first letter of its name standing in for one.\n mark: page.icon\n ? '<img class=\"mark\" src=\"icon.png\" alt=\"\" />'\n : `<div class=\"mark\" aria-hidden=\"true\">${escapeHtml(initial)}</div>`,\n }\n return template.replaceAll(/\\{\\{(\\w+)\\}\\}/g, (_match, key: string) => markup[key] ?? \"\")\n}\n\n/** Writes the app's icon into `dir` as `icon.png`; on macOS, drawn the way macOS draws app icons. */\nasync function writeIcon(dir: string, png: Uint8Array): Promise<string> {\n const icon = join(dir, \"icon.png\")\n if (process.platform !== \"darwin\") {\n await writeFile(icon, png)\n return icon\n }\n // The original goes beside the app, not in it: everything in the app's directory ships.\n const source = join(dir, \"..\", \"icon-source.png\")\n await writeFile(source, png)\n await drawMacIcon(source, icon)\n return icon\n}\n\nasync function readProjectVersion(projectRoot: string): Promise<string> {\n try {\n const manifest: unknown = JSON.parse(await readFile(join(projectRoot, \"package.json\"), \"utf-8\"))\n const version = (manifest as { readonly version?: unknown } | null)?.version\n return typeof version === \"string\" ? version : \"0.0.0\"\n } catch {\n return \"0.0.0\"\n }\n}\n\nfunction escapeHtml(value: string): string {\n return value\n .replaceAll(\"&\", \"&amp;\")\n .replaceAll(\"<\", \"&lt;\")\n .replaceAll(\">\", \"&gt;\")\n .replaceAll('\"', \"&quot;\")\n}\n",
7
+ "/** What the desktop app takes from the web app it opens. */\nexport interface AppIdentity {\n /** The app's name: `metadata.title` in `app/layout.tsx`. */\n readonly name: string\n /**\n * The app's maskable icon, such as `app/public/icon-maskable-512.png`, or else its largest PNG\n * icon, such as `app/public/icon-512.png`.\n */\n readonly icon: Uint8Array | null\n}\n\n/**\n * Reads the app's web app manifest, the one a browser installs the app from. The desktop app is\n * the same app installed another way, so it takes the same name and icon and has no settings of\n * its own.\n */\nexport async function readAppIdentity(appUrl: string): Promise<AppIdentity> {\n const manifestUrl = new URL(\"/app.webmanifest\", appUrl)\n const manifest: unknown = await (await fetchFromApp(manifestUrl)).json()\n const { name, icons } = (typeof manifest === \"object\" && manifest !== null ? manifest : {}) as {\n readonly name?: unknown\n readonly icons?: unknown\n }\n\n const iconUrl = desktopIcon(icons, manifestUrl)\n return {\n name: typeof name === \"string\" && name.trim() ? name.trim() : \"Sixb\",\n icon: iconUrl ? new Uint8Array(await (await fetchFromApp(iconUrl)).arrayBuffer()) : null,\n }\n}\n\n/**\n * The app's id on the desktop, from the address it opens: `https://orders.acme.com` becomes\n * `com.acme.orders`. Each deployment gets its own, so a staging build installs beside production.\n */\nexport function bundleIdentifier(appUrl: string): string {\n const labels = new URL(appUrl).hostname\n .split(\".\")\n .reverse()\n .map((label) => label.toLowerCase().replaceAll(/[^a-z0-9-]/g, \"-\"))\n .filter(Boolean)\n return (labels.length > 1 ? labels : [\"local\", ...labels]).join(\".\")\n}\n\n// A maskable icon is drawn to its edges for a platform to cut its own shape from, which is what\n// macOS does with it. Any other icon may carry its own shape and margins.\nfunction desktopIcon(icons: unknown, manifestUrl: URL): URL | null {\n let best: { readonly url: URL; readonly rank: readonly [number, number] } | null = null\n for (const icon of Array.isArray(icons) ? icons : []) {\n if (typeof icon !== \"object\" || icon === null) continue\n const { src, sizes, type, purpose } = icon as Record<string, unknown>\n if (typeof src !== \"string\") continue\n const url = new URL(src, manifestUrl)\n if (type === undefined ? !url.pathname.endsWith(\".png\") : type !== \"image/png\") continue\n\n const maskable = typeof purpose === \"string\" && purpose.split(/\\s+/).includes(\"maskable\")\n const size = Math.max(\n 0,\n ...(typeof sizes === \"string\" ? sizes.split(/\\s+/) : []).map(\n (entry) => Number.parseInt(entry, 10) || 0\n )\n )\n const rank = [maskable ? 1 : 0, size] as const\n if (!best || rank[0] > best.rank[0] || (rank[0] === best.rank[0] && rank[1] > best.rank[1])) {\n best = { url, rank }\n }\n }\n return best?.url ?? null\n}\n\nasync function fetchFromApp(url: URL): Promise<Response> {\n let response: Response\n try {\n response = await fetch(url)\n } catch (error) {\n throw new Error(\n `[SixbDesktop] Could not reach ${url} (${error instanceof Error ? error.message : error}). ` +\n \"The desktop app takes its name and icon from the app, so the app must be running there.\"\n )\n }\n if (!response.ok) throw new Error(`[SixbDesktop] ${url} answered ${response.status}.`)\n return response\n}\n",
8
+ "/** Runs a command to completion, quietly unless it fails: then it throws `failure` and its errors. */\nexport async function run(command: readonly string[], failure: string): Promise<void> {\n const child = Bun.spawn([...command], {\n stdio: [\"ignore\", \"ignore\", \"pipe\"],\n timeout: 120_000,\n })\n const [exitCode, errors] = await Promise.all([child.exited, new Response(child.stderr).text()])\n if (exitCode !== 0) {\n throw new Error(`[SixbDesktop] ${failure}${errors.trim() ? `\\n${errors.trim()}` : \"\"}`)\n }\n}\n",
9
+ "import { run } from \"./run\"\n\n/**\n * Draws `png` the way macOS draws app icons, into `out`: on Apple's grid, a rounded square of 824\n * pixels with continuous corners in a canvas of 1024, over the soft shadow Apple's own icons have.\n * An icon drawn to its edges otherwise stands larger than every other icon in the Dock.\n */\nexport async function drawMacIcon(png: string, out: string): Promise<void> {\n await run(\n [\"osascript\", \"-l\", \"JavaScript\", \"-e\", MAC_ICON_SCRIPT, png, out],\n \"Could not draw the macOS icon.\"\n )\n}\n\n// AppKit, through the JavaScript `osascript` runs, which every Mac has. The corner is the curve\n// UIKit rounds continuous corners with; with this radius it matches the outline of Apple's Notes\n// icon to a few pixels, and the shadow matches its shadow.\nconst MAC_ICON_SCRIPT = `\nObjC.import(\"AppKit\")\nObjC.import(\"CoreGraphics\")\n\nfunction run([input, output]) {\n const canvas = 1024\n const body = 824\n const radius = 185.4\n const min = (canvas - body) / 2\n const max = min + body\n\n // One corner, as offsets in radii from the edge it leaves and the edge it joins.\n const corner = [\n [[1.52866483, 0]],\n [[0.66993427, 0.065496], [1.08849323, 0], [0.86840689, 0.02065986]],\n [[0.63149399, 0.074911]],\n [[0.074911, 0.63149399], [0.37282392, 0.16906933], [0.16906933, 0.37282392]],\n [[0.065496, 0.66993427]],\n [[0, 1.52866483], [0.02065986, 0.86840689], [0, 1.08849323]],\n ]\n const corners = [\n ([u, v]) => $.NSMakePoint(max - u * radius, max - v * radius),\n ([u, v]) => $.NSMakePoint(max - v * radius, min + u * radius),\n ([u, v]) => $.NSMakePoint(min + u * radius, min + v * radius),\n ([u, v]) => $.NSMakePoint(min + v * radius, max - u * radius),\n ]\n const shape = $.NSBezierPath.bezierPath\n shape.moveToPoint(corners[3]([0, 1.52866483]))\n for (const at of corners) {\n for (const [to, c1, c2] of corner) {\n if (c1) shape.curveToPointControlPoint1ControlPoint2(at(to), at(c1), at(c2))\n else shape.lineToPoint(at(to))\n }\n }\n shape.closePath\n\n const image = $.NSImage.alloc.initWithContentsOfFile(input)\n if (image.isNil()) throw new Error(\"Cannot read \" + input)\n const bitmap = $.NSBitmapImageRep.alloc\n .initWithBitmapDataPlanesPixelsWidePixelsHighBitsPerSampleSamplesPerPixelHasAlphaIsPlanarColorSpaceNameBytesPerRowBitsPerPixel(\n null, canvas, canvas, 8, 4, true, false, $.NSDeviceRGBColorSpace, 0, 0\n )\n const context = $.NSGraphicsContext.graphicsContextWithBitmapImageRep(bitmap)\n $.NSGraphicsContext.setCurrentContext(context)\n context.setImageInterpolation($.NSImageInterpolationHigh)\n\n const shadow = $.NSShadow.alloc.init\n shadow.setShadowOffset($.NSMakeSize(0, -8))\n shadow.setShadowBlurRadius(30)\n shadow.setShadowColor($.NSColor.colorWithWhiteAlpha(0, 0.22))\n shadow.set\n // A layer, so the shadow falls from the clipped icon and not from the clip.\n $.CGContextBeginTransparencyLayer(context.CGContext, null)\n shape.addClip\n image.drawInRectFromRectOperationFraction(\n $.NSMakeRect(min, min, body, body), $.NSZeroRect, $.NSCompositingOperationSourceOver, 1\n )\n $.CGContextEndTransparencyLayer(context.CGContext)\n context.flushGraphics\n\n const png = bitmap.representationUsingTypeProperties($.NSBitmapImageFileTypePNG, $.NSDictionary.dictionary)\n if (!png.writeToFileAtomically(output, true)) throw new Error(\"Cannot write \" + output)\n}\n`\n"
10
+ ],
11
+ "mappings": ";;AAAA,kBAAS,uBAAgB;AACzB;AACA,0BAAkB;AAClB,0BAAS;;;ACHT;AACA;AACA;;;ACcO,eAAe,eAAe,CAAC,QAAsC;AAAA,EAC1E,MAAM,cAAc,IAAI,IAAI,oBAAoB,MAAM;AAAA,EACtD,MAAM,WAAoB,OAAO,MAAM,aAAa,WAAW,GAAG,KAAK;AAAA,EACvE,QAAQ,MAAM,UAAW,OAAO,aAAa,YAAY,aAAa,OAAO,WAAW,CAAC;AAAA,EAKzF,MAAM,UAAU,YAAY,OAAO,WAAW;AAAA,EAC9C,OAAO;AAAA,IACL,MAAM,OAAO,SAAS,YAAY,KAAK,KAAK,IAAI,KAAK,KAAK,IAAI;AAAA,IAC9D,MAAM,UAAU,IAAI,WAAW,OAAO,MAAM,aAAa,OAAO,GAAG,YAAY,CAAC,IAAI;AAAA,EACtF;AAAA;AAOK,SAAS,gBAAgB,CAAC,QAAwB;AAAA,EACvD,MAAM,SAAS,IAAI,IAAI,MAAM,EAAE,SAC5B,MAAM,GAAG,EACT,QAAQ,EACR,IAAI,CAAC,UAAU,MAAM,YAAY,EAAE,WAAW,eAAe,GAAG,CAAC,EACjE,OAAO,OAAO;AAAA,EACjB,QAAQ,OAAO,SAAS,IAAI,SAAS,CAAC,SAAS,GAAG,MAAM,GAAG,KAAK,GAAG;AAAA;AAKrE,SAAS,WAAW,CAAC,OAAgB,aAA8B;AA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,MACR,iFACE,uBAAuB,4CAC3B;AAAA;AAAA;",
12
+ "debugId": "AA1E41BFA25EB6CC64756E2164756E21",
13
+ "names": []
14
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Draws `png` the way macOS draws app icons, into `out`: on Apple's grid, a rounded square of 824
3
+ * pixels with continuous corners in a canvas of 1024, over the soft shadow Apple's own icons have.
4
+ * An icon drawn to its edges otherwise stands larger than every other icon in the Dock.
5
+ */
6
+ export declare function drawMacIcon(png: string, out: string): Promise<void>;
7
+ //# sourceMappingURL=mac-icon.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mac-icon.d.ts","sourceRoot":"","sources":["../src/mac-icon.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAKzE"}
package/dist/run.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ /** Runs a command to completion, quietly unless it fails: then it throws `failure` and its errors. */
2
+ export declare function run(command: readonly string[], failure: string): Promise<void>;
3
+ //# sourceMappingURL=run.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AAAA,sGAAsG;AACtG,wBAAsB,GAAG,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CASpF"}
@@ -0,0 +1,16 @@
1
+ /** The name a page finds the desktop app under, through `useDesktop` in `@sixb/client/hooks`. */
2
+ export declare const DESKTOP_BRIDGE_NAME = "sixbDesktop";
3
+ /**
4
+ * What the shell offers the page. `SixbDesktop` in `@sixb/client` is the page's view of this, and
5
+ * `tests/app.test.ts` holds the two together.
6
+ *
7
+ * The page is remote, and anything here is open to whatever runs in it. To offer more:
8
+ * 1. Add one narrow method here, calling `ipcRenderer.invoke`, never a general way to run a command
9
+ * or read a file. The page asks; the person decides, in a native dialog, what it gets.
10
+ * 2. Handle it in `main.ts`, refusing any sender that `isAppUrl` does not accept.
11
+ * 3. Add it to `SixbDesktop` as optional, because a page can outlive the shell it runs in.
12
+ */
13
+ export declare function desktopBridge<const Platform extends NodeJS.Platform>(platform: Platform): {
14
+ platform: Platform;
15
+ };
16
+ //# sourceMappingURL=bridge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../../src/shell/bridge.ts"],"names":[],"mappings":"AAAA,iGAAiG;AACjG,eAAO,MAAM,mBAAmB,gBAAgB,CAAA;AAEhD;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,KAAK,CAAC,QAAQ,SAAS,MAAM,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ;;EAEvF"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=main.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/shell/main.ts"],"names":[],"mappings":""}