inplan 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/LICENSE +661 -0
- package/app/main/index.js +769 -0
- package/app/preload/index.mjs +92 -0
- package/app/renderer/assets/index-BqLfQmz0.js +52343 -0
- package/app/renderer/assets/index-C67b7qA1.css +272 -0
- package/app/renderer/index.html +13 -0
- package/bin/cli.js +1409 -0
- package/package.json +29 -0
- package/skill/SKILL.md +149 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { contextBridge, ipcRenderer } from "electron";
|
|
2
|
+
function createProfileController() {
|
|
3
|
+
let cached = { user: null, agentLocation: null, actions: [] };
|
|
4
|
+
const subs = /* @__PURE__ */ new Set();
|
|
5
|
+
const toState = (snap) => ({
|
|
6
|
+
user: snap.user,
|
|
7
|
+
agentLocation: snap.agentLocation,
|
|
8
|
+
actions: snap.actions.map((d) => ({
|
|
9
|
+
label: d.label,
|
|
10
|
+
...d.primary ? { primary: true } : {},
|
|
11
|
+
...d.danger ? { danger: true } : {},
|
|
12
|
+
...d.disabled ? { disabled: true } : {},
|
|
13
|
+
onSelect: () => void ipcRenderer.invoke("profile:action", d.id)
|
|
14
|
+
}))
|
|
15
|
+
});
|
|
16
|
+
const refresh = async () => {
|
|
17
|
+
const snap = await ipcRenderer.invoke("profile:get");
|
|
18
|
+
cached = toState(snap);
|
|
19
|
+
for (const cb of subs) cb(cached);
|
|
20
|
+
};
|
|
21
|
+
ipcRenderer.on("profile:changed", () => void refresh());
|
|
22
|
+
void refresh();
|
|
23
|
+
return {
|
|
24
|
+
get: () => cached,
|
|
25
|
+
subscribe: (cb) => {
|
|
26
|
+
subs.add(cb);
|
|
27
|
+
return () => void subs.delete(cb);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function createI18nController() {
|
|
32
|
+
const setLocale = (locale) => void ipcRenderer.invoke("i18n:set-locale", locale);
|
|
33
|
+
const toState = (snap) => ({ locale: snap.locale, catalogs: snap.catalogs, available: snap.available, setLocale });
|
|
34
|
+
let cached = toState({ locale: "en", catalogs: {}, available: [{ code: "en", label: "English" }] });
|
|
35
|
+
const subs = /* @__PURE__ */ new Set();
|
|
36
|
+
const refresh = async () => {
|
|
37
|
+
cached = toState(await ipcRenderer.invoke("i18n:get"));
|
|
38
|
+
for (const cb of subs) cb(cached);
|
|
39
|
+
};
|
|
40
|
+
ipcRenderer.on("i18n:changed", () => void refresh());
|
|
41
|
+
void refresh();
|
|
42
|
+
return {
|
|
43
|
+
get: () => cached,
|
|
44
|
+
subscribe: (cb) => {
|
|
45
|
+
subs.add(cb);
|
|
46
|
+
return () => void subs.delete(cb);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
const api = {
|
|
51
|
+
load: () => ipcRenderer.invoke("doc:load"),
|
|
52
|
+
save: (content, options) => ipcRenderer.invoke("doc:save", content, options),
|
|
53
|
+
logAction: (type, payload) => ipcRenderer.invoke("doc:log-action", type, payload),
|
|
54
|
+
reportState: (dirty, content) => ipcRenderer.invoke("doc:report-state", dirty, content),
|
|
55
|
+
setMode: (cadence, acceptance) => ipcRenderer.invoke("doc:set-mode", cadence, acceptance),
|
|
56
|
+
getSettings: () => ipcRenderer.invoke("settings:get"),
|
|
57
|
+
setSettings: (settings) => ipcRenderer.invoke("settings:set", settings),
|
|
58
|
+
complete: (content) => ipcRenderer.invoke("doc:complete", content),
|
|
59
|
+
onExternalChange: (cb) => {
|
|
60
|
+
ipcRenderer.on("doc:external-change", (_e, payload) => cb(payload));
|
|
61
|
+
},
|
|
62
|
+
onAgentDone: (cb) => {
|
|
63
|
+
ipcRenderer.on("agent:done", () => cb());
|
|
64
|
+
},
|
|
65
|
+
onAgentActive: (cb) => {
|
|
66
|
+
ipcRenderer.on("agent:active", () => cb());
|
|
67
|
+
},
|
|
68
|
+
onReload: (cb) => {
|
|
69
|
+
ipcRenderer.on("agent:reload", () => cb());
|
|
70
|
+
},
|
|
71
|
+
closeWindow: () => ipcRenderer.invoke("window:close"),
|
|
72
|
+
getProposal: () => ipcRenderer.invoke("proposal:get"),
|
|
73
|
+
clearProposal: () => ipcRenderer.invoke("proposal:clear"),
|
|
74
|
+
onProposal: (cb) => {
|
|
75
|
+
ipcRenderer.on("doc:proposal", (_e, payload) => cb(payload));
|
|
76
|
+
},
|
|
77
|
+
openDoc: (target) => ipcRenderer.invoke("doc:open", target),
|
|
78
|
+
navigate: (dir) => ipcRenderer.invoke("nav:go", dir),
|
|
79
|
+
onNavState: (cb) => {
|
|
80
|
+
ipcRenderer.on("nav:state", (_e, s) => cb(s));
|
|
81
|
+
},
|
|
82
|
+
onNavigated: (cb) => {
|
|
83
|
+
ipcRenderer.on("doc:navigated", (_e, payload) => cb(payload));
|
|
84
|
+
},
|
|
85
|
+
profile: createProfileController(),
|
|
86
|
+
i18n: createI18nController(),
|
|
87
|
+
onUpdateAvailable: (cb) => {
|
|
88
|
+
ipcRenderer.on("app:update-available", (_e, info) => cb(info));
|
|
89
|
+
},
|
|
90
|
+
applyUpdate: () => ipcRenderer.invoke("app:apply-update")
|
|
91
|
+
};
|
|
92
|
+
contextBridge.exposeInMainWorld("api", api);
|