@hermannbjorgvin/kirby-desktop 1.0.0-beta.5 → 1.0.0-beta.6
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/main/main.js +71 -14
- package/package.json +1 -1
- package/preload/preload.cjs +19 -2
- package/renderer/assets/PrWorkspace-CtlIl38L.js +37 -0
- package/renderer/assets/SettingsView-CBn7NLBQ.js +1 -0
- package/renderer/assets/index-DKWx0PHr.js +51 -0
- package/renderer/assets/select-iIz9kCDK.js +1 -0
- package/renderer/index.html +1 -1
- package/renderer/assets/index-vGfeijvJ.js +0 -86
package/main/main.js
CHANGED
|
@@ -7296,14 +7296,26 @@ import {
|
|
|
7296
7296
|
shell
|
|
7297
7297
|
} from "electron";
|
|
7298
7298
|
|
|
7299
|
-
// apps/desktop/src/host/contract.ts
|
|
7300
|
-
var SECRET_PLACEHOLDER = "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022";
|
|
7299
|
+
// apps/desktop/src/host/contract-events.ts
|
|
7301
7300
|
var MENU_EVENTS = {
|
|
7302
7301
|
command: "kirby/menu/command"
|
|
7303
7302
|
};
|
|
7304
7303
|
var SYNC_EVENTS = {
|
|
7305
|
-
notice: "kirby/sync/notice"
|
|
7304
|
+
notice: "kirby/sync/notice",
|
|
7305
|
+
/**
|
|
7306
|
+
* Background remote data (the pull request list) has landed and the
|
|
7307
|
+
* sidebar model would now answer differently.
|
|
7308
|
+
*
|
|
7309
|
+
* `getSidebarModel` deliberately never waits for the network, so
|
|
7310
|
+
* without this the first pull requests of a session would appear
|
|
7311
|
+
* whenever the renderer's poll interval next came round — up to four
|
|
7312
|
+
* seconds after the host already had them.
|
|
7313
|
+
*/
|
|
7314
|
+
remote: "kirby/sync/remote"
|
|
7306
7315
|
};
|
|
7316
|
+
|
|
7317
|
+
// apps/desktop/src/host/contract.ts
|
|
7318
|
+
var SECRET_PLACEHOLDER = "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022";
|
|
7307
7319
|
var IPC = {
|
|
7308
7320
|
getVersion: "kirby/version",
|
|
7309
7321
|
openRepo: "kirby/repo/open",
|
|
@@ -7523,7 +7535,7 @@ function detectProviderFields(cfg, providers, detected) {
|
|
|
7523
7535
|
if (!provider?.autoDetectFields)
|
|
7524
7536
|
return;
|
|
7525
7537
|
try {
|
|
7526
|
-
const extra = provider.autoDetectFields();
|
|
7538
|
+
const extra = provider.autoDetectFields(cfg.vendorProject ?? {});
|
|
7527
7539
|
if (!extra)
|
|
7528
7540
|
return;
|
|
7529
7541
|
cfg.vendorProject ??= {};
|
|
@@ -9910,7 +9922,9 @@ var githubProvider = {
|
|
|
9910
9922
|
parseRemoteUrl(url) {
|
|
9911
9923
|
return parseGitHubRemoteUrl(url);
|
|
9912
9924
|
},
|
|
9913
|
-
autoDetectFields() {
|
|
9925
|
+
autoDetectFields(project = {}) {
|
|
9926
|
+
if (project.username)
|
|
9927
|
+
return null;
|
|
9914
9928
|
try {
|
|
9915
9929
|
const out = execSync2("gh api /user", {
|
|
9916
9930
|
encoding: "utf8",
|
|
@@ -11865,6 +11879,10 @@ var cache = null;
|
|
|
11865
11879
|
var inflight = null;
|
|
11866
11880
|
var lastError = null;
|
|
11867
11881
|
var fetchSeq = 0;
|
|
11882
|
+
var remoteUpdated = null;
|
|
11883
|
+
function setRemoteUpdatedNotifier(fn) {
|
|
11884
|
+
remoteUpdated = fn;
|
|
11885
|
+
}
|
|
11868
11886
|
function remoteIntervalMs(interval) {
|
|
11869
11887
|
return interval ?? DEFAULT_REMOTE_MS;
|
|
11870
11888
|
}
|
|
@@ -11874,17 +11892,24 @@ function resolveProvider(cwd) {
|
|
|
11874
11892
|
const configured = provider != null && provider.isConfigured(config.vendorAuth, config.vendorProject);
|
|
11875
11893
|
return { config, provider, configured };
|
|
11876
11894
|
}
|
|
11877
|
-
|
|
11895
|
+
function cachedPrMap(cwd) {
|
|
11896
|
+
return cache && cache.cwd === cwd ? cache.prMap : {};
|
|
11897
|
+
}
|
|
11898
|
+
function freshCache(cwd, ttl) {
|
|
11899
|
+
if (!cache || cache.cwd !== cwd)
|
|
11900
|
+
return null;
|
|
11901
|
+
return Date.now() - cache.fetchedAt < ttl ? cache : null;
|
|
11902
|
+
}
|
|
11903
|
+
async function fetchRemote2(cwd, force = false, onCommit) {
|
|
11878
11904
|
const { config, provider, configured } = resolveProvider(cwd);
|
|
11879
11905
|
if (!provider || !configured) {
|
|
11880
11906
|
cache = { cwd, prMap: {}, fetchedAt: Date.now() };
|
|
11881
11907
|
lastError = null;
|
|
11882
11908
|
return {};
|
|
11883
11909
|
}
|
|
11884
|
-
const
|
|
11885
|
-
if (
|
|
11886
|
-
return
|
|
11887
|
-
}
|
|
11910
|
+
const fresh = force ? null : freshCache(cwd, remoteIntervalMs(config.prPollInterval));
|
|
11911
|
+
if (fresh)
|
|
11912
|
+
return fresh.prMap;
|
|
11888
11913
|
if (inflight && inflight.cwd === cwd && !force)
|
|
11889
11914
|
return inflight.promise;
|
|
11890
11915
|
const seq = ++fetchSeq;
|
|
@@ -11892,6 +11917,7 @@ async function fetchRemote2(cwd, force = false) {
|
|
|
11892
11917
|
if (seq === fetchSeq) {
|
|
11893
11918
|
cache = { cwd, prMap, fetchedAt: Date.now() };
|
|
11894
11919
|
lastError = null;
|
|
11920
|
+
onCommit?.();
|
|
11895
11921
|
}
|
|
11896
11922
|
return prMap;
|
|
11897
11923
|
}).catch((err) => {
|
|
@@ -11908,13 +11934,16 @@ async function fetchRemote2(cwd, force = false) {
|
|
|
11908
11934
|
inflight = { cwd, promise };
|
|
11909
11935
|
return promise;
|
|
11910
11936
|
}
|
|
11937
|
+
function refreshRemoteInBackground(cwd) {
|
|
11938
|
+
void fetchRemote2(cwd, false, () => remoteUpdated?.()).catch(() => {
|
|
11939
|
+
});
|
|
11940
|
+
}
|
|
11911
11941
|
async function getSidebarModel() {
|
|
11912
11942
|
const cwd = requireRepo();
|
|
11913
11943
|
const { config, provider } = resolveProvider(cwd);
|
|
11914
|
-
|
|
11915
|
-
|
|
11916
|
-
|
|
11917
|
-
]);
|
|
11944
|
+
refreshRemoteInBackground(cwd);
|
|
11945
|
+
const worktrees = await listWorktrees();
|
|
11946
|
+
const prMap = cachedPrMap(cwd);
|
|
11918
11947
|
const sessions2 = worktrees.map((wt) => {
|
|
11919
11948
|
const name = worktreeSessionName(wt);
|
|
11920
11949
|
return {
|
|
@@ -12609,6 +12638,7 @@ function createHostApi() {
|
|
|
12609
12638
|
showAppMenu: () => appMenuPopup(),
|
|
12610
12639
|
onMenuCommand: () => () => void 0,
|
|
12611
12640
|
onSyncNotice: () => () => void 0,
|
|
12641
|
+
onRemoteUpdated: () => () => void 0,
|
|
12612
12642
|
getDesktopPrefs: () => Promise.resolve(loadDesktopPrefs()),
|
|
12613
12643
|
setDesktopPrefs: (patch) => {
|
|
12614
12644
|
const next = saveDesktopPrefs(patch);
|
|
@@ -12703,6 +12733,24 @@ function registerHostHandlers(register, api = createHostApi()) {
|
|
|
12703
12733
|
}
|
|
12704
12734
|
}
|
|
12705
12735
|
|
|
12736
|
+
// apps/desktop/src/main/boot-marks.ts
|
|
12737
|
+
var MAIN_MARKS = {
|
|
12738
|
+
/** Entry module evaluated — Electron is up, our bundle is loaded. */
|
|
12739
|
+
module: "kirby:main:module",
|
|
12740
|
+
/** `app.whenReady()` resolved. */
|
|
12741
|
+
ready: "kirby:main:ready",
|
|
12742
|
+
/** The startup repository is open (or there was none). */
|
|
12743
|
+
repo: "kirby:main:repo",
|
|
12744
|
+
/** `new BrowserWindow` returned and the load has been kicked off. */
|
|
12745
|
+
window: "kirby:main:window"
|
|
12746
|
+
};
|
|
12747
|
+
function mark(name) {
|
|
12748
|
+
try {
|
|
12749
|
+
performance.mark(name);
|
|
12750
|
+
} catch {
|
|
12751
|
+
}
|
|
12752
|
+
}
|
|
12753
|
+
|
|
12706
12754
|
// apps/desktop/src/main/menu.ts
|
|
12707
12755
|
function buildMenuTemplate(env, send) {
|
|
12708
12756
|
const isMac = env.platform === "darwin";
|
|
@@ -12907,6 +12955,7 @@ function loadTarget(devServerUrl, indexHtmlPath) {
|
|
|
12907
12955
|
}
|
|
12908
12956
|
|
|
12909
12957
|
// apps/desktop/src/main/main.ts
|
|
12958
|
+
mark(MAIN_MARKS.module);
|
|
12910
12959
|
var DIST = join9(import.meta.dirname, "..");
|
|
12911
12960
|
var DEV_SERVER_URL = process.env.KIRBY_VITE_URL;
|
|
12912
12961
|
var APP_VERSION = process.env.KIRBY_DESKTOP_VERSION ?? "dev";
|
|
@@ -13106,6 +13155,11 @@ setSyncNotifier((notice) => {
|
|
|
13106
13155
|
win.webContents.send(SYNC_EVENTS.notice, notice);
|
|
13107
13156
|
}
|
|
13108
13157
|
});
|
|
13158
|
+
setRemoteUpdatedNotifier(() => {
|
|
13159
|
+
for (const win of BrowserWindow.getAllWindows()) {
|
|
13160
|
+
win.webContents.send(SYNC_EVENTS.remote);
|
|
13161
|
+
}
|
|
13162
|
+
});
|
|
13109
13163
|
if (!app.requestSingleInstanceLock()) {
|
|
13110
13164
|
app.quit();
|
|
13111
13165
|
} else {
|
|
@@ -13118,12 +13172,15 @@ if (!app.requestSingleInstanceLock()) {
|
|
|
13118
13172
|
}
|
|
13119
13173
|
});
|
|
13120
13174
|
app.whenReady().then(() => {
|
|
13175
|
+
mark(MAIN_MARKS.ready);
|
|
13121
13176
|
nativeTheme.themeSource = prefs.theme;
|
|
13122
13177
|
installAppMenu();
|
|
13123
13178
|
void probeTmuxAvailability().catch(() => void 0);
|
|
13124
13179
|
const opened = openStartupRepo();
|
|
13180
|
+
mark(MAIN_MARKS.repo);
|
|
13125
13181
|
console.log(`[desktop] startup repo: ${opened ? opened.cwd : "none"}`);
|
|
13126
13182
|
void createMainWindow();
|
|
13183
|
+
mark(MAIN_MARKS.window);
|
|
13127
13184
|
app.on("activate", () => {
|
|
13128
13185
|
if (BrowserWindow.getAllWindows().length === 0) {
|
|
13129
13186
|
void createMainWindow();
|
package/package.json
CHANGED
package/preload/preload.cjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// apps/desktop/src/preload/preload.ts
|
|
4
4
|
var import_electron = require("electron");
|
|
5
5
|
|
|
6
|
-
// apps/desktop/src/host/contract.ts
|
|
6
|
+
// apps/desktop/src/host/contract-events.ts
|
|
7
7
|
var SESSION_EVENTS = {
|
|
8
8
|
data: "kirby/session/data",
|
|
9
9
|
exit: "kirby/session/exit"
|
|
@@ -12,8 +12,20 @@ var MENU_EVENTS = {
|
|
|
12
12
|
command: "kirby/menu/command"
|
|
13
13
|
};
|
|
14
14
|
var SYNC_EVENTS = {
|
|
15
|
-
notice: "kirby/sync/notice"
|
|
15
|
+
notice: "kirby/sync/notice",
|
|
16
|
+
/**
|
|
17
|
+
* Background remote data (the pull request list) has landed and the
|
|
18
|
+
* sidebar model would now answer differently.
|
|
19
|
+
*
|
|
20
|
+
* `getSidebarModel` deliberately never waits for the network, so
|
|
21
|
+
* without this the first pull requests of a session would appear
|
|
22
|
+
* whenever the renderer's poll interval next came round — up to four
|
|
23
|
+
* seconds after the host already had them.
|
|
24
|
+
*/
|
|
25
|
+
remote: "kirby/sync/remote"
|
|
16
26
|
};
|
|
27
|
+
|
|
28
|
+
// apps/desktop/src/host/contract.ts
|
|
17
29
|
var IPC = {
|
|
18
30
|
getVersion: "kirby/version",
|
|
19
31
|
openRepo: "kirby/repo/open",
|
|
@@ -136,6 +148,11 @@ var api = {
|
|
|
136
148
|
import_electron.ipcRenderer.on(SYNC_EVENTS.notice, listener);
|
|
137
149
|
return () => import_electron.ipcRenderer.removeListener(SYNC_EVENTS.notice, listener);
|
|
138
150
|
},
|
|
151
|
+
onRemoteUpdated: (cb) => {
|
|
152
|
+
const listener = () => cb();
|
|
153
|
+
import_electron.ipcRenderer.on(SYNC_EVENTS.remote, listener);
|
|
154
|
+
return () => import_electron.ipcRenderer.removeListener(SYNC_EVENTS.remote, listener);
|
|
155
|
+
},
|
|
139
156
|
getDesktopPrefs: () => import_electron.ipcRenderer.invoke(IPC.getDesktopPrefs),
|
|
140
157
|
setDesktopPrefs: (patch) => import_electron.ipcRenderer.invoke(IPC.setDesktopPrefs, patch),
|
|
141
158
|
showAbout: () => import_electron.ipcRenderer.invoke(IPC.showAbout)
|