@justin06lee/subaru 0.1.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/dist/card-BFhpWbA5.d.ts +32 -0
- package/dist/chunk-CPOOJ2JD.js +213 -0
- package/dist/chunk-CPOOJ2JD.js.map +1 -0
- package/dist/chunk-K7IY5EW6.js +138 -0
- package/dist/chunk-K7IY5EW6.js.map +1 -0
- package/dist/chunk-MI26ZEPP.js +92 -0
- package/dist/chunk-MI26ZEPP.js.map +1 -0
- package/dist/chunk-POOH3Z7G.js +178 -0
- package/dist/chunk-POOH3Z7G.js.map +1 -0
- package/dist/chunk-SRQ3JWJK.js +261 -0
- package/dist/chunk-SRQ3JWJK.js.map +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +59 -0
- package/dist/cli.js.map +1 -0
- package/dist/core-DmEjLKLp.d.ts +104 -0
- package/dist/electron-renderer.d.ts +34 -0
- package/dist/electron-renderer.js +81 -0
- package/dist/electron-renderer.js.map +1 -0
- package/dist/electron.d.ts +239 -0
- package/dist/electron.js +428 -0
- package/dist/electron.js.map +1 -0
- package/dist/github-Ds4DWDq9.d.ts +37 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +49 -0
- package/dist/index.js.map +1 -0
- package/dist/react.d.ts +42 -0
- package/dist/react.js +109 -0
- package/dist/react.js.map +1 -0
- package/dist/source.d.ts +57 -0
- package/dist/source.js +11 -0
- package/dist/source.js.map +1 -0
- package/dist/styles-zfa0Pc0l.d.ts +47 -0
- package/dist/tauri.d.ts +71 -0
- package/dist/tauri.js +109 -0
- package/dist/tauri.js.map +1 -0
- package/dist/web.d.ts +59 -0
- package/dist/web.js +79 -0
- package/dist/web.js.map +1 -0
- package/package.json +120 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { U as UpdaterState, a as UpdaterLike } from './core-DmEjLKLp.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Electron, preload and renderer side. Nothing here touches Node.
|
|
5
|
+
*
|
|
6
|
+
* preload: exposeUpdater(contextBridge, ipcRenderer)
|
|
7
|
+
* renderer: const updater = rendererUpdater() // an UpdaterLike for useUpdater / UpdatePrompt
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
interface IpcRendererLike {
|
|
11
|
+
invoke(channel: string, ...args: unknown[]): Promise<unknown>;
|
|
12
|
+
send(channel: string, ...args: unknown[]): void;
|
|
13
|
+
on(channel: string, listener: (event: unknown, ...args: unknown[]) => void): unknown;
|
|
14
|
+
removeListener(channel: string, listener: (event: unknown, ...args: unknown[]) => void): unknown;
|
|
15
|
+
}
|
|
16
|
+
interface ContextBridgeLike {
|
|
17
|
+
exposeInMainWorld(key: string, api: unknown): void;
|
|
18
|
+
}
|
|
19
|
+
/** What the preload puts on window.subaru. */
|
|
20
|
+
interface SubaruBridge {
|
|
21
|
+
get(): Promise<UpdaterState>;
|
|
22
|
+
onState(listener: (state: UpdaterState) => void): () => void;
|
|
23
|
+
check(): void;
|
|
24
|
+
install(): void;
|
|
25
|
+
restart(): void;
|
|
26
|
+
skip(): void;
|
|
27
|
+
dismiss(): void;
|
|
28
|
+
}
|
|
29
|
+
/** Call from the preload script. */
|
|
30
|
+
declare function exposeUpdater(contextBridge: ContextBridgeLike, ipcRenderer: IpcRendererLike, key?: string): void;
|
|
31
|
+
/** Call from the renderer. Reads the bridge the preload exposed. */
|
|
32
|
+
declare function rendererUpdater(bridge?: SubaruBridge): UpdaterLike;
|
|
33
|
+
|
|
34
|
+
export { type ContextBridgeLike, type IpcRendererLike, type SubaruBridge, exposeUpdater, rendererUpdater };
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// src/electron-renderer.ts
|
|
2
|
+
var CHANNELS = {
|
|
3
|
+
state: "subaru:state",
|
|
4
|
+
get: "subaru:get",
|
|
5
|
+
check: "subaru:check",
|
|
6
|
+
install: "subaru:install",
|
|
7
|
+
restart: "subaru:restart",
|
|
8
|
+
skip: "subaru:skip",
|
|
9
|
+
dismiss: "subaru:dismiss"
|
|
10
|
+
};
|
|
11
|
+
function exposeUpdater(contextBridge, ipcRenderer, key = "subaru") {
|
|
12
|
+
const bridge = {
|
|
13
|
+
get: () => ipcRenderer.invoke(CHANNELS.get),
|
|
14
|
+
onState(listener) {
|
|
15
|
+
const wrapped = (_event, state) => listener(state);
|
|
16
|
+
ipcRenderer.on(CHANNELS.state, wrapped);
|
|
17
|
+
return () => ipcRenderer.removeListener(CHANNELS.state, wrapped);
|
|
18
|
+
},
|
|
19
|
+
check: () => ipcRenderer.send(CHANNELS.check),
|
|
20
|
+
install: () => ipcRenderer.send(CHANNELS.install),
|
|
21
|
+
restart: () => ipcRenderer.send(CHANNELS.restart),
|
|
22
|
+
skip: () => ipcRenderer.send(CHANNELS.skip),
|
|
23
|
+
dismiss: () => ipcRenderer.send(CHANNELS.dismiss)
|
|
24
|
+
};
|
|
25
|
+
contextBridge.exposeInMainWorld(key, bridge);
|
|
26
|
+
}
|
|
27
|
+
var idle = {
|
|
28
|
+
status: "idle",
|
|
29
|
+
policy: "prompt",
|
|
30
|
+
release: null,
|
|
31
|
+
progress: null,
|
|
32
|
+
error: null,
|
|
33
|
+
skipped: false,
|
|
34
|
+
dismissed: false,
|
|
35
|
+
kind: "electron"
|
|
36
|
+
};
|
|
37
|
+
function rendererUpdater(bridge) {
|
|
38
|
+
const api = bridge ?? globalThis.subaru;
|
|
39
|
+
if (!api) throw new Error("subaru: window.subaru is missing; call exposeUpdater in the preload script");
|
|
40
|
+
let state = idle;
|
|
41
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
42
|
+
api.onState((next) => {
|
|
43
|
+
state = next;
|
|
44
|
+
for (const l of listeners) l(state);
|
|
45
|
+
});
|
|
46
|
+
void api.get().then((initial) => {
|
|
47
|
+
if (initial) {
|
|
48
|
+
state = initial;
|
|
49
|
+
for (const l of listeners) l(state);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
return {
|
|
53
|
+
getState: () => state,
|
|
54
|
+
subscribe(listener) {
|
|
55
|
+
listeners.add(listener);
|
|
56
|
+
return () => {
|
|
57
|
+
listeners.delete(listener);
|
|
58
|
+
};
|
|
59
|
+
},
|
|
60
|
+
async check() {
|
|
61
|
+
api.check();
|
|
62
|
+
},
|
|
63
|
+
async install() {
|
|
64
|
+
api.install();
|
|
65
|
+
},
|
|
66
|
+
async restart() {
|
|
67
|
+
api.restart();
|
|
68
|
+
},
|
|
69
|
+
async skip() {
|
|
70
|
+
api.skip();
|
|
71
|
+
},
|
|
72
|
+
dismiss() {
|
|
73
|
+
api.dismiss();
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
export {
|
|
78
|
+
exposeUpdater,
|
|
79
|
+
rendererUpdater
|
|
80
|
+
};
|
|
81
|
+
//# sourceMappingURL=electron-renderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/electron-renderer.ts"],"sourcesContent":["/**\n * Electron, preload and renderer side. Nothing here touches Node.\n *\n * preload: exposeUpdater(contextBridge, ipcRenderer)\n * renderer: const updater = rendererUpdater() // an UpdaterLike for useUpdater / UpdatePrompt\n */\nimport type { UpdaterLike, UpdaterState } from './core';\n\nconst CHANNELS = {\n state: 'subaru:state',\n get: 'subaru:get',\n check: 'subaru:check',\n install: 'subaru:install',\n restart: 'subaru:restart',\n skip: 'subaru:skip',\n dismiss: 'subaru:dismiss',\n} as const;\n\nexport interface IpcRendererLike {\n invoke(channel: string, ...args: unknown[]): Promise<unknown>;\n send(channel: string, ...args: unknown[]): void;\n on(channel: string, listener: (event: unknown, ...args: unknown[]) => void): unknown;\n removeListener(channel: string, listener: (event: unknown, ...args: unknown[]) => void): unknown;\n}\n\nexport interface ContextBridgeLike {\n exposeInMainWorld(key: string, api: unknown): void;\n}\n\n/** What the preload puts on window.subaru. */\nexport interface SubaruBridge {\n get(): Promise<UpdaterState>;\n onState(listener: (state: UpdaterState) => void): () => void;\n check(): void;\n install(): void;\n restart(): void;\n skip(): void;\n dismiss(): void;\n}\n\n/** Call from the preload script. */\nexport function exposeUpdater(contextBridge: ContextBridgeLike, ipcRenderer: IpcRendererLike, key = 'subaru'): void {\n const bridge: SubaruBridge = {\n get: () => ipcRenderer.invoke(CHANNELS.get) as Promise<UpdaterState>,\n onState(listener) {\n const wrapped = (_event: unknown, state: unknown) => listener(state as UpdaterState);\n ipcRenderer.on(CHANNELS.state, wrapped);\n return () => ipcRenderer.removeListener(CHANNELS.state, wrapped);\n },\n check: () => ipcRenderer.send(CHANNELS.check),\n install: () => ipcRenderer.send(CHANNELS.install),\n restart: () => ipcRenderer.send(CHANNELS.restart),\n skip: () => ipcRenderer.send(CHANNELS.skip),\n dismiss: () => ipcRenderer.send(CHANNELS.dismiss),\n };\n contextBridge.exposeInMainWorld(key, bridge);\n}\n\nconst idle: UpdaterState = {\n status: 'idle',\n policy: 'prompt',\n release: null,\n progress: null,\n error: null,\n skipped: false,\n dismissed: false,\n kind: 'electron',\n};\n\n/** Call from the renderer. Reads the bridge the preload exposed. */\nexport function rendererUpdater(bridge?: SubaruBridge): UpdaterLike {\n const api = bridge ?? (globalThis as unknown as { subaru?: SubaruBridge }).subaru;\n if (!api) throw new Error('subaru: window.subaru is missing; call exposeUpdater in the preload script');\n let state = idle;\n const listeners = new Set<(s: UpdaterState) => void>();\n api.onState((next) => {\n state = next;\n for (const l of listeners) l(state);\n });\n void api.get().then((initial) => {\n if (initial) {\n state = initial;\n for (const l of listeners) l(state);\n }\n });\n return {\n getState: () => state,\n subscribe(listener) {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n async check() {\n api.check();\n },\n async install() {\n api.install();\n },\n async restart() {\n api.restart();\n },\n async skip() {\n api.skip();\n },\n dismiss() {\n api.dismiss();\n },\n };\n}\n"],"mappings":";AAQA,IAAM,WAAW;AAAA,EACf,OAAO;AAAA,EACP,KAAK;AAAA,EACL,OAAO;AAAA,EACP,SAAS;AAAA,EACT,SAAS;AAAA,EACT,MAAM;AAAA,EACN,SAAS;AACX;AAyBO,SAAS,cAAc,eAAkC,aAA8B,MAAM,UAAgB;AAClH,QAAM,SAAuB;AAAA,IAC3B,KAAK,MAAM,YAAY,OAAO,SAAS,GAAG;AAAA,IAC1C,QAAQ,UAAU;AAChB,YAAM,UAAU,CAAC,QAAiB,UAAmB,SAAS,KAAqB;AACnF,kBAAY,GAAG,SAAS,OAAO,OAAO;AACtC,aAAO,MAAM,YAAY,eAAe,SAAS,OAAO,OAAO;AAAA,IACjE;AAAA,IACA,OAAO,MAAM,YAAY,KAAK,SAAS,KAAK;AAAA,IAC5C,SAAS,MAAM,YAAY,KAAK,SAAS,OAAO;AAAA,IAChD,SAAS,MAAM,YAAY,KAAK,SAAS,OAAO;AAAA,IAChD,MAAM,MAAM,YAAY,KAAK,SAAS,IAAI;AAAA,IAC1C,SAAS,MAAM,YAAY,KAAK,SAAS,OAAO;AAAA,EAClD;AACA,gBAAc,kBAAkB,KAAK,MAAM;AAC7C;AAEA,IAAM,OAAqB;AAAA,EACzB,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,UAAU;AAAA,EACV,OAAO;AAAA,EACP,SAAS;AAAA,EACT,WAAW;AAAA,EACX,MAAM;AACR;AAGO,SAAS,gBAAgB,QAAoC;AAClE,QAAM,MAAM,UAAW,WAAoD;AAC3E,MAAI,CAAC,IAAK,OAAM,IAAI,MAAM,4EAA4E;AACtG,MAAI,QAAQ;AACZ,QAAM,YAAY,oBAAI,IAA+B;AACrD,MAAI,QAAQ,CAAC,SAAS;AACpB,YAAQ;AACR,eAAW,KAAK,UAAW,GAAE,KAAK;AAAA,EACpC,CAAC;AACD,OAAK,IAAI,IAAI,EAAE,KAAK,CAAC,YAAY;AAC/B,QAAI,SAAS;AACX,cAAQ;AACR,iBAAW,KAAK,UAAW,GAAE,KAAK;AAAA,IACpC;AAAA,EACF,CAAC;AACD,SAAO;AAAA,IACL,UAAU,MAAM;AAAA,IAChB,UAAU,UAAU;AAClB,gBAAU,IAAI,QAAQ;AACtB,aAAO,MAAM;AACX,kBAAU,OAAO,QAAQ;AAAA,MAC3B;AAAA,IACF;AAAA,IACA,MAAM,QAAQ;AACZ,UAAI,MAAM;AAAA,IACZ;AAAA,IACA,MAAM,UAAU;AACd,UAAI,QAAQ;AAAA,IACd;AAAA,IACA,MAAM,UAAU;AACd,UAAI,QAAQ;AAAA,IACd;AAAA,IACA,MAAM,OAAO;AACX,UAAI,KAAK;AAAA,IACX;AAAA,IACA,UAAU;AACR,UAAI,QAAQ;AAAA,IACd;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { P as Policy, A as Adapter, b as Updater } from './core-DmEjLKLp.js';
|
|
2
|
+
import { F as FetchLike, G as GitHubAsset } from './github-Ds4DWDq9.js';
|
|
3
|
+
import { Runner, SourceAdapterOptions } from './source.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Electron, main-process side.
|
|
7
|
+
*
|
|
8
|
+
* subaru('owner/repo') — the whole integration in one call: the
|
|
9
|
+
* bundle adapter below, a native dialog,
|
|
10
|
+
* and the daily check.
|
|
11
|
+
* bundleAdapter({ repo }) — an Adapter that downloads the app from
|
|
12
|
+
* GitHub Releases and swaps it in place:
|
|
13
|
+
* the .app on macOS, the AppImage or the
|
|
14
|
+
* unpacked directory on Linux. Signed or
|
|
15
|
+
* unsigned; no electron-updater, no source
|
|
16
|
+
* checkout.
|
|
17
|
+
* electronAdapter(autoUpdater) — an Adapter over electron-updater, which
|
|
18
|
+
* downloads and applies releases published
|
|
19
|
+
* by electron-builder (Windows, or apps
|
|
20
|
+
* already on it).
|
|
21
|
+
* serveUpdater(updater, ipc) — mirrors the updater over IPC so the
|
|
22
|
+
* renderer can show the same prompt through
|
|
23
|
+
* "@justin06lee/subaru/electron/renderer".
|
|
24
|
+
* nodeRunner() — runs git and make for sourceAdapter
|
|
25
|
+
* (source mode: unsigned apps that a
|
|
26
|
+
* Makefile builds and installs).
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/** The slice of electron-updater's AppUpdater subaru uses. */
|
|
30
|
+
interface ElectronAutoUpdater {
|
|
31
|
+
autoDownload: boolean;
|
|
32
|
+
autoInstallOnAppQuit: boolean;
|
|
33
|
+
allowPrerelease: boolean;
|
|
34
|
+
checkForUpdates(): Promise<{
|
|
35
|
+
isUpdateAvailable: boolean;
|
|
36
|
+
updateInfo: ElectronUpdateInfo;
|
|
37
|
+
} | null>;
|
|
38
|
+
downloadUpdate(): Promise<unknown>;
|
|
39
|
+
quitAndInstall(isSilent?: boolean, isForceRunAfter?: boolean): void;
|
|
40
|
+
on(event: 'download-progress', listener: (progress: {
|
|
41
|
+
percent: number;
|
|
42
|
+
}) => void): unknown;
|
|
43
|
+
off(event: 'download-progress', listener: (progress: {
|
|
44
|
+
percent: number;
|
|
45
|
+
}) => void): unknown;
|
|
46
|
+
}
|
|
47
|
+
interface ElectronUpdateInfo {
|
|
48
|
+
version: string;
|
|
49
|
+
releaseName?: string | null;
|
|
50
|
+
releaseNotes?: string | Array<{
|
|
51
|
+
version: string;
|
|
52
|
+
note: string | null;
|
|
53
|
+
}> | null;
|
|
54
|
+
releaseDate?: string;
|
|
55
|
+
}
|
|
56
|
+
interface ElectronAdapterOptions {
|
|
57
|
+
allowPrerelease?: boolean;
|
|
58
|
+
/** Where to keep state. Default: no persistence beyond the process; pass fileStorage(join(app.getPath('userData'), 'subaru.json')). */
|
|
59
|
+
storagePath?: string;
|
|
60
|
+
}
|
|
61
|
+
declare function electronAdapter(autoUpdater: ElectronAutoUpdater, options?: ElectronAdapterOptions): Adapter;
|
|
62
|
+
/** The IPC surface subaru uses, so tests can pass a fake and apps pass Electron's. */
|
|
63
|
+
interface IpcMainLike {
|
|
64
|
+
handle(channel: string, listener: (event: unknown, ...args: unknown[]) => unknown): void;
|
|
65
|
+
on(channel: string, listener: (event: unknown, ...args: unknown[]) => void): unknown;
|
|
66
|
+
}
|
|
67
|
+
interface WebContentsLike {
|
|
68
|
+
send(channel: string, ...args: unknown[]): void;
|
|
69
|
+
isDestroyed?(): boolean;
|
|
70
|
+
}
|
|
71
|
+
declare const IPC: {
|
|
72
|
+
readonly state: "subaru:state";
|
|
73
|
+
readonly get: "subaru:get";
|
|
74
|
+
readonly check: "subaru:check";
|
|
75
|
+
readonly install: "subaru:install";
|
|
76
|
+
readonly restart: "subaru:restart";
|
|
77
|
+
readonly skip: "subaru:skip";
|
|
78
|
+
readonly dismiss: "subaru:dismiss";
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Publish the updater to renderers: state changes are pushed on
|
|
82
|
+
* "subaru:state", and the renderer's actions arrive on the other channels.
|
|
83
|
+
* `targets` returns the webContents that should receive state (usually every
|
|
84
|
+
* BrowserWindow's).
|
|
85
|
+
*/
|
|
86
|
+
declare function serveUpdater(updater: Updater, ipcMain: IpcMainLike, targets: () => WebContentsLike[]): () => void;
|
|
87
|
+
interface NodeRunnerOptions {
|
|
88
|
+
/** Where a detached `make update` writes its output. Default: subaru-update.log in the temp dir. */
|
|
89
|
+
log?: string;
|
|
90
|
+
env?: Record<string, string | undefined>;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* A Runner on Node's child_process for sourceAdapter. Detached requests are
|
|
94
|
+
* started in their own session with output appended to a log file, so
|
|
95
|
+
* `make update` keeps going after it has quit this program. PATH gains the
|
|
96
|
+
* usual tool directories a Finder-launched app lacks (Homebrew, bun, go,
|
|
97
|
+
* cargo).
|
|
98
|
+
*/
|
|
99
|
+
declare function nodeRunner(options?: NodeRunnerOptions): Runner;
|
|
100
|
+
/** The slice of Electron's `app` the bundle adapter and subaru() use. */
|
|
101
|
+
interface AppLike {
|
|
102
|
+
getName(): string;
|
|
103
|
+
getVersion(): string;
|
|
104
|
+
getPath(name: 'exe' | 'userData' | 'temp'): string;
|
|
105
|
+
relaunch(options?: {
|
|
106
|
+
execPath?: string;
|
|
107
|
+
args?: string[];
|
|
108
|
+
}): void;
|
|
109
|
+
exit(code?: number): void;
|
|
110
|
+
isPackaged: boolean;
|
|
111
|
+
whenReady(): Promise<void>;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* How the macOS app is signed, which decides what happens to its permission
|
|
115
|
+
* grants (Accessibility, Screen Recording, ...) across an update.
|
|
116
|
+
*
|
|
117
|
+
* 'unsigned' — ad-hoc or no signature. Every build is a new identity to
|
|
118
|
+
* macOS, so grants cannot survive; subaru resets the stale
|
|
119
|
+
* ones (resetPermissions) so the new build asks again.
|
|
120
|
+
* 'signed' — a stable signing identity (Developer ID, or any certificate
|
|
121
|
+
* you sign every build with). The new bundle must satisfy the
|
|
122
|
+
* running bundle's designated requirement, the same check
|
|
123
|
+
* macOS uses for grants, or it is refused before anything is
|
|
124
|
+
* replaced; grants carry over and nothing is reset.
|
|
125
|
+
*
|
|
126
|
+
* Ignored on Linux, which has no equivalent.
|
|
127
|
+
*/
|
|
128
|
+
type Signing = 'unsigned' | 'signed';
|
|
129
|
+
interface BundleAdapterOptions {
|
|
130
|
+
/** "owner/name" on GitHub. */
|
|
131
|
+
repo: string;
|
|
132
|
+
app?: AppLike;
|
|
133
|
+
/** Program name used to pick the asset (`<name>-darwin-arm64.zip`). Default: the app name, lowercased. */
|
|
134
|
+
name?: string;
|
|
135
|
+
/** Running version. Default app.getVersion(). */
|
|
136
|
+
currentVersion?: string;
|
|
137
|
+
/** Default 'unsigned'. */
|
|
138
|
+
signing?: Signing;
|
|
139
|
+
/**
|
|
140
|
+
* macOS permission services to reset before relaunching an unsigned
|
|
141
|
+
* build, so it asks again instead of sitting on a stale grant: e.g.
|
|
142
|
+
* ["Accessibility", "ScreenCapture", "ListenEvent"]. Needs the bundle id
|
|
143
|
+
* (read from the bundle when not given). Not used when signing is
|
|
144
|
+
* 'signed': the grants are still valid.
|
|
145
|
+
*/
|
|
146
|
+
resetPermissions?: string[];
|
|
147
|
+
bundleId?: string;
|
|
148
|
+
requireChecksum?: boolean;
|
|
149
|
+
fetch?: FetchLike;
|
|
150
|
+
/** Runs ditto, tar, unzip, xattr, codesign, tccutil. Default: nodeRunner(). */
|
|
151
|
+
run?: Runner;
|
|
152
|
+
/** Test hooks. */
|
|
153
|
+
bundlePath?: string;
|
|
154
|
+
platform?: string;
|
|
155
|
+
arch?: string;
|
|
156
|
+
api?: string;
|
|
157
|
+
allowAnyHost?: boolean;
|
|
158
|
+
env?: Record<string, string | undefined>;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Installs releases the way Tauri's updater does, with nothing but an
|
|
162
|
+
* archive on GitHub Releases.
|
|
163
|
+
*
|
|
164
|
+
* macOS `<name>-darwin-<arch>.zip` (or .tar.gz) holding the .app,
|
|
165
|
+
* unpacked with ditto so symlinks and signatures survive, swapped
|
|
166
|
+
* in place of the running bundle.
|
|
167
|
+
* Linux run as an AppImage: `<name>-linux-<arch>.AppImage` replaces the
|
|
168
|
+
* file $APPIMAGE points at. Run from an unpacked directory
|
|
169
|
+
* (electron-builder's linux-unpacked, a tarball in ~/.local or
|
|
170
|
+
* /opt): `<name>-linux-<arch>.tar.gz` (or .zip) replaces the
|
|
171
|
+
* directory the executable lives in.
|
|
172
|
+
*
|
|
173
|
+
* The published checksum is verified first, the new copy is staged next to
|
|
174
|
+
* the old one so the swap is a rename on one filesystem, and a failure at
|
|
175
|
+
* any step leaves the running app where it was.
|
|
176
|
+
*/
|
|
177
|
+
declare function bundleAdapter(options: BundleAdapterOptions): Adapter;
|
|
178
|
+
/**
|
|
179
|
+
* The asset for this platform in the shape the install needs: an AppImage,
|
|
180
|
+
* or a .zip / .tar.gz archive. Raw binaries (a Go program's assets in the
|
|
181
|
+
* same release) are never picked.
|
|
182
|
+
*/
|
|
183
|
+
declare function pickBundleAsset(assets: GitHubAsset[], name: string, os: string, arch: string, form: 'appimage' | 'archive'): GitHubAsset | null;
|
|
184
|
+
interface ElectronAutoOptions {
|
|
185
|
+
policy?: Policy;
|
|
186
|
+
/** Shown in the dialog. Default app.getName(). */
|
|
187
|
+
name?: string;
|
|
188
|
+
/** Source mode instead of GitHub Releases: the app's git checkout, fast-forwarded and rebuilt with make. */
|
|
189
|
+
checkout?: string;
|
|
190
|
+
source?: Omit<SourceAdapterOptions, 'checkout' | 'run'> & {
|
|
191
|
+
run?: Runner;
|
|
192
|
+
};
|
|
193
|
+
/** Passed to bundleAdapter. 'signed' keeps macOS permission grants across updates; default 'unsigned'. */
|
|
194
|
+
signing?: Signing;
|
|
195
|
+
resetPermissions?: string[];
|
|
196
|
+
bundleId?: string;
|
|
197
|
+
requireChecksum?: boolean;
|
|
198
|
+
/** false: no native dialog; drive the UI yourself (serveUpdater + the card in the renderer). */
|
|
199
|
+
dialog?: boolean;
|
|
200
|
+
/** Mirror state to renderers too. */
|
|
201
|
+
ipcMain?: IpcMainLike;
|
|
202
|
+
windows?: () => WebContentsLike[];
|
|
203
|
+
debug?: (message: string) => void;
|
|
204
|
+
/** Test hooks: Electron's app and dialog. */
|
|
205
|
+
electron?: {
|
|
206
|
+
app: AppLike;
|
|
207
|
+
dialog?: DialogLike;
|
|
208
|
+
};
|
|
209
|
+
adapter?: Adapter;
|
|
210
|
+
}
|
|
211
|
+
interface DialogLike {
|
|
212
|
+
showMessageBox(options: {
|
|
213
|
+
type?: string;
|
|
214
|
+
message: string;
|
|
215
|
+
detail?: string;
|
|
216
|
+
buttons: string[];
|
|
217
|
+
defaultId?: number;
|
|
218
|
+
cancelId?: number;
|
|
219
|
+
}): Promise<{
|
|
220
|
+
response: number;
|
|
221
|
+
}>;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* The whole integration in one call, from the main process:
|
|
225
|
+
*
|
|
226
|
+
* import { subaru } from '@justin06lee/subaru/electron';
|
|
227
|
+
* subaru('justin06lee/ruri');
|
|
228
|
+
*
|
|
229
|
+
* Once a day it looks at the repository's latest release. When there is a
|
|
230
|
+
* newer one it asks with a native dialog (Update now / Skip this version /
|
|
231
|
+
* Later), downloads the release for this platform, swaps it in and
|
|
232
|
+
* relaunches. Nothing needs publishing beyond a GitHub release; signing is
|
|
233
|
+
* optional, and { signing: 'signed' } keeps macOS permission grants.
|
|
234
|
+
* Pass { checkout } for source mode instead. Development runs (app.isPackaged
|
|
235
|
+
* false) stay off unless a policy is given.
|
|
236
|
+
*/
|
|
237
|
+
declare function subaru(repo: string, options?: ElectronAutoOptions): Promise<Updater>;
|
|
238
|
+
|
|
239
|
+
export { type AppLike, type BundleAdapterOptions, type DialogLike, type ElectronAdapterOptions, type ElectronAutoOptions, type ElectronAutoUpdater, type ElectronUpdateInfo, IPC, type IpcMainLike, type NodeRunnerOptions, type Signing, type WebContentsLike, bundleAdapter, electronAdapter, nodeRunner, pickBundleAsset, serveUpdater, subaru };
|