flexdesk 0.13.0 → 0.14.1
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/README.md +72 -0
- package/css/flexdesk.css +99 -0
- package/dist/charts.js +2 -2
- package/dist/{chunk-M2L4XW2U.js → chunk-FBGP5KN5.js} +33 -21
- package/dist/chunk-FBGP5KN5.js.map +7 -0
- package/dist/{chunk-IYMNDPWH.js → chunk-RQM5Z2MU.js} +2 -2
- package/dist/flexdesk.css +99 -0
- package/dist/flow.js +4 -1
- package/dist/flow.js.map +2 -2
- package/dist/host.js +138 -0
- package/dist/host.js.map +3 -3
- package/dist/tiles.js +11 -3
- package/dist/tiles.js.map +2 -2
- package/dist/widgets.js +564 -6
- package/dist/widgets.js.map +3 -3
- package/dist/wm.js +146 -0
- package/dist/wm.js.map +3 -3
- package/package.json +1 -1
- package/src/flow/kit/dom.js +6 -0
- package/src/host/photino_host.js +176 -0
- package/src/host/photino_host.md +98 -0
- package/src/tiles/chart_tiles.js +14 -1
- package/src/tiling/bottom_panel_tabs.js +201 -0
- package/src/ui/components/alert_log.js +274 -0
- package/src/ui/components/alerts_pane.js +294 -0
- package/src/ui/components/data_table.js +32 -14
- package/src/ui/components/notification_history.js +54 -4
- package/src/ui/utils/auto_scrollbars.js +30 -0
- package/dist/chunk-M2L4XW2U.js.map +0 -7
- /package/dist/{chunk-IYMNDPWH.js.map → chunk-RQM5Z2MU.js.map} +0 -0
package/dist/host.js
CHANGED
|
@@ -121,11 +121,149 @@ function createPywebviewHost({ bridgeRef = null, resolvePath = (k) => `${k}.json
|
|
|
121
121
|
}
|
|
122
122
|
});
|
|
123
123
|
}
|
|
124
|
+
|
|
125
|
+
// src/host/photino_host.js
|
|
126
|
+
function isPhotinoWindow(ext = typeof window !== "undefined" ? window.external : void 0) {
|
|
127
|
+
return !!ext && typeof ext.sendMessage === "function" && typeof ext.receiveMessage === "function";
|
|
128
|
+
}
|
|
129
|
+
function createPhotinoTransport({ external, timeoutMs = 1e4, onEvent = null, logger = console }) {
|
|
130
|
+
const pending = /* @__PURE__ */ new Map();
|
|
131
|
+
let seq = 0;
|
|
132
|
+
external.receiveMessage((text) => {
|
|
133
|
+
let m;
|
|
134
|
+
try {
|
|
135
|
+
m = typeof text === "string" ? JSON.parse(text) : text;
|
|
136
|
+
} catch {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
if (!m || typeof m !== "object") return;
|
|
140
|
+
if (m.id == null) {
|
|
141
|
+
if (typeof m.event === "string" && onEvent) {
|
|
142
|
+
try {
|
|
143
|
+
onEvent(m.event, m.value);
|
|
144
|
+
} catch (e) {
|
|
145
|
+
logger.warn?.("[host] photino event handler failed", m.event, e);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
const p = pending.get(m.id);
|
|
151
|
+
if (!p) return;
|
|
152
|
+
pending.delete(m.id);
|
|
153
|
+
clearTimeout(p.timer);
|
|
154
|
+
if (m.ok) p.resolve(m.value === void 0 ? null : m.value);
|
|
155
|
+
else p.reject(new Error(m.error || `${p.what}: refused by the host`));
|
|
156
|
+
});
|
|
157
|
+
const request = (cap, op, args = [], { wait = timeoutMs } = {}) => new Promise((resolve, reject) => {
|
|
158
|
+
const id = ++seq;
|
|
159
|
+
const what = `${cap}.${op}`;
|
|
160
|
+
const timer = wait > 0 ? setTimeout(() => {
|
|
161
|
+
if (pending.delete(id)) reject(new Error(`${what}: no answer from the host within ${wait} ms`));
|
|
162
|
+
}, wait) : null;
|
|
163
|
+
pending.set(id, { resolve, reject, timer, what });
|
|
164
|
+
try {
|
|
165
|
+
external.sendMessage(JSON.stringify({ id, cap, op, args }));
|
|
166
|
+
} catch (e) {
|
|
167
|
+
pending.delete(id);
|
|
168
|
+
clearTimeout(timer);
|
|
169
|
+
reject(e);
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
const call = (cap, op, ...args) => request(cap, op, args);
|
|
173
|
+
return { call, request, pending: () => pending.size };
|
|
174
|
+
}
|
|
175
|
+
function createPhotinoHost(opts = {}) {
|
|
176
|
+
const {
|
|
177
|
+
external = typeof window !== "undefined" ? window.external : void 0,
|
|
178
|
+
timeoutMs = 1e4,
|
|
179
|
+
onEvent = null,
|
|
180
|
+
logger = console
|
|
181
|
+
} = opts;
|
|
182
|
+
if (!isPhotinoWindow(external)) return NULL_HOST;
|
|
183
|
+
const { call, request } = createPhotinoTransport({ external, timeoutMs, onEvent, logger });
|
|
184
|
+
const warn = (cap, op, e) => logger.warn?.("[host] photino call failed", `${cap}.${op}`, e);
|
|
185
|
+
const soft = async (fallback, cap, op, ...args) => {
|
|
186
|
+
try {
|
|
187
|
+
return await call(cap, op, ...args);
|
|
188
|
+
} catch (e) {
|
|
189
|
+
warn(cap, op, e);
|
|
190
|
+
return fallback;
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
const fire = (cap, op, ...args) => {
|
|
194
|
+
void soft(null, cap, op, ...args);
|
|
195
|
+
};
|
|
196
|
+
const defaults = {
|
|
197
|
+
window: {
|
|
198
|
+
// Photino draws a decorated, native window on every OS: FlexDesk's
|
|
199
|
+
// own min/max/close buttons would be a second set.
|
|
200
|
+
chrome: () => "native",
|
|
201
|
+
minimize: () => {
|
|
202
|
+
fire("window", "minimize");
|
|
203
|
+
},
|
|
204
|
+
close: () => {
|
|
205
|
+
fire("window", "close");
|
|
206
|
+
},
|
|
207
|
+
isMaximized: async () => await soft(false, "window", "isMaximized") === true,
|
|
208
|
+
setMaximized: async (on) => await soft(false, "window", "setMaximized", !!on) === true,
|
|
209
|
+
isFullscreen: async () => await soft(false, "window", "isFullscreen") === true,
|
|
210
|
+
toggleFullscreen: async () => await soft(false, "window", "toggleFullscreen") === true,
|
|
211
|
+
async getBounds() {
|
|
212
|
+
const b = await soft(null, "window", "getBounds");
|
|
213
|
+
if (!b || typeof b !== "object") return null;
|
|
214
|
+
return { x: b.x, y: b.y, width: b.width, height: b.height };
|
|
215
|
+
},
|
|
216
|
+
// Not async, like pywebview's: a rAF hot path during a drag; nobody awaits.
|
|
217
|
+
setBounds({ x = null, y = null, width = null, height = null } = {}) {
|
|
218
|
+
fire("window", "setBounds", { x, y, width, height });
|
|
219
|
+
}
|
|
220
|
+
},
|
|
221
|
+
dialogs: {
|
|
222
|
+
// `{ok: true, path}` | `{ok: false, cancelled: true}` | `{ok: false, error}`,
|
|
223
|
+
// or null when the host refused: fall back to a download. NO TIMEOUT —
|
|
224
|
+
// the dialog is open for as long as the user takes, and giving up on it
|
|
225
|
+
// would download the file a second time behind the dialog.
|
|
226
|
+
async saveFile({ data, filename, kind } = {}) {
|
|
227
|
+
let r = null;
|
|
228
|
+
try {
|
|
229
|
+
r = await request("dialogs", "saveFile", [{ data, filename, kind }], { wait: 0 });
|
|
230
|
+
} catch (e) {
|
|
231
|
+
warn("dialogs", "saveFile", e);
|
|
232
|
+
}
|
|
233
|
+
return r && typeof r === "object" ? r : null;
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
state: {
|
|
237
|
+
async read(key) {
|
|
238
|
+
const v = await soft(null, "state", "read", key);
|
|
239
|
+
if (typeof v !== "string") return v ?? null;
|
|
240
|
+
try {
|
|
241
|
+
return JSON.parse(v);
|
|
242
|
+
} catch (e) {
|
|
243
|
+
logger.warn?.("[host] bad JSON for state key", key, e);
|
|
244
|
+
return null;
|
|
245
|
+
}
|
|
246
|
+
},
|
|
247
|
+
async write(key, value) {
|
|
248
|
+
return await soft(false, "state", "write", key, value) !== false;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
const caps = {};
|
|
253
|
+
for (const name of Object.keys(defaults)) {
|
|
254
|
+
if (!(name in opts)) caps[name] = defaults[name];
|
|
255
|
+
else if (opts[name] != null) caps[name] = opts[name];
|
|
256
|
+
}
|
|
257
|
+
return createHost(caps);
|
|
258
|
+
}
|
|
124
259
|
export {
|
|
125
260
|
HOST_CONTRACT,
|
|
126
261
|
NULL_HOST,
|
|
127
262
|
createHost,
|
|
263
|
+
createPhotinoHost,
|
|
264
|
+
createPhotinoTransport,
|
|
128
265
|
createPywebviewHost,
|
|
266
|
+
isPhotinoWindow,
|
|
129
267
|
usesCustomWindowChrome,
|
|
130
268
|
validateCapability
|
|
131
269
|
};
|
package/dist/host.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/host/host.js", "../src/host/pywebview_host.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * host.js \u2014 the host port.\n *\n * The framework declares what it needs from its embedder. A Host is a bag of\n * INDEPENDENTLY OPTIONAL capability objects:\n *\n * - absent capability => absent key (never a stub)\n * - present capability => must be complete (validated at boot)\n *\n * There is NO module-level default host and NO getHost(). Hosts are injected \u2014\n * a module singleton here would just be `window.pywebview` wearing a hat, and\n * would make a second host (mock, browser tab, VS Code webview) impossible.\n *\n * Zero pywebview. Zero EcoAgent. See pywebview_host.js for the reference\n * adapter that implements this port against the pywebview / HTTP transports.\n */\n\nexport const HOST_CONTRACT = Object.freeze({\n window: Object.freeze({\n required: Object.freeze(['chrome', 'minimize', 'close', 'isMaximized', 'setMaximized',\n 'isFullscreen', 'toggleFullscreen', 'getBounds', 'setBounds']),\n optional: Object.freeze(['startNativeDrag']),\n }),\n dialogs: Object.freeze({ required: Object.freeze(['saveFile']), optional: Object.freeze([]) }),\n state: Object.freeze({ required: Object.freeze(['read', 'write']), optional: Object.freeze([]) }),\n});\n\n/**\n * Validate ONE capability object. We validate the capability the adapter\n * authored \u2014 a plain object literal with real closures \u2014 not the raw bridge:\n * `index.html`'s browser-mode polyfill installs a `new Proxy({}, {get})` that\n * returns a function for EVERY property name, so duck-typing the bridge is\n * vacuously true and validates nothing. A Proxy cannot forge a missing key in\n * an object literal.\n *\n * @returns {{ ok: boolean, missing: string[] }}\n */\nexport function validateCapability(name, cap) {\n const spec = HOST_CONTRACT[name];\n if (!spec) return { ok: false, missing: [`unknown capability '${name}'`] };\n if (!cap || typeof cap !== 'object') return { ok: false, missing: [...spec.required] };\n const missing = spec.required.filter((m) => typeof cap[m] !== 'function');\n return { ok: missing.length === 0, missing };\n}\n\n/**\n * Validate + freeze a set of capabilities into a Host.\n * Throws at boot on an incomplete capability \u2014 a half-wired host is a bug,\n * and a bug at boot beats a silent degrade at click time.\n *\n * @param {{ window?: object, dialogs?: object, state?: object }} caps\n * @returns {Readonly<object>} the Host\n */\nexport function createHost(caps = {}) {\n const host = {};\n for (const name of Object.keys(HOST_CONTRACT)) {\n const cap = caps[name];\n if (cap == null) continue; // legitimately absent\n const v = validateCapability(name, cap);\n if (!v.ok) {\n throw new Error(`Host capability '${name}' is incomplete: missing ${v.missing.join(', ')}`);\n }\n host[name] = Object.freeze(cap);\n }\n return Object.freeze(host);\n}\n\n/** The zero-capability host. Every framework consumer MUST survive it. */\nexport const NULL_HOST = createHost({});\n", "/**\n * pywebview_host.js \u2014 the REFERENCE host adapter.\n *\n * Knows pywebview. Knows NOTHING about EcoAgent: every domain fact (which\n * bridge ref to use, where a state key lands on disk) arrives as a parameter.\n * This is the adapter a standalone consumer copies; EcoAgent is just its first\n * caller (see ui/js/bootstrap/app_bootstrap.js).\n *\n * It speaks to whatever `window.pywebview.api` currently is \u2014 the real\n * pywebview bridge in the desktop app, or the `POST /api/<method>` Proxy\n * polyfill that ui/index.html installs in --browser mode. Both transports are\n * positional-on-the-wire, which is why setBounds() spreads its object back out\n * into positional args.\n */\n\nimport { createHost } from './host.js';\n\nconst FRAMELESS_BACKENDS = new Set(['edgechromium', 'mshtml']);\n\n/**\n * Custom (frameless) window chrome \u2014 the min/max/close buttons, edge resize\n * handles and drag-to-move top bar \u2014 only makes sense when our top bar IS the\n * window's title bar. That holds on a native pywebview window the OS draws\n * *without* decorations of its own: Windows (frameless). On Linux/macOS the\n * window manager already draws a native title bar above our top bar, and in\n * `--browser` mode the browser supplies its own chrome \u2014 in both cases the\n * custom controls are a redundant second set, so we neither render nor wire\n * them (which also stops us swallowing native F11 fullscreen and showing dead\n * resize cursors at the window edges).\n *\n * Detection keys off the pywebview backend string, which is unambiguous: the\n * browser-mode polyfill in index.html injects only `.api`, never `.platform`,\n * so any `.platform` at all \u21D2 running as a native pywebview app. The frameless\n * (custom-title-bar) backends are the Windows WebViews \u2014 'edgechromium' /\n * 'mshtml'. Linux ('gtkwebkit2' / 'qtwebengine') and macOS ('cocoa') draw\n * native decorations, so they return false. Verified live: WebKitGTK reports\n * platform 'gtkwebkit2'.\n */\nexport function usesCustomWindowChrome() {\n // Authoritative signal from the Python host: run_pywebview_mode() appends\n // `?frameless=1` to the window URL exactly when it created a frameless native\n // window (Windows). Prefer it over the backend sniff below because it's\n // present at document parse \u2014 before pywebview finishes injecting\n // `window.pywebview` (and before the browser-mode polyfill, which sets `.api`\n // but no `.platform`, can clobber it). Reading the sniff at shell-build time\n // otherwise races and the whole custom chrome silently fails to render.\n try {\n if (new URLSearchParams(window.location.search).get('frameless') === '1') {\n return true;\n }\n } catch (_) { /* location unavailable (non-browser env) \u2014 fall through */ }\n const platform = window.pywebview && window.pywebview.platform;\n return !!platform && FRAMELESS_BACKENDS.has(platform);\n}\n\n/**\n * Build a Host backed by the pywebview bridge.\n *\n * @param {object} opts\n * @param {{current: object|null}} [opts.bridgeRef] LIVE ref to the bridge.\n * MUST be a ref, never a snapshot: `setupHostBridgeListener` mutates\n * `.current` when a late bridge arrives, and `resolveHostBridge` can\n * resolve `null` after its timeout. Snapshotting the bridge here would\n * freeze that null and reproduce as an intermittent boot failure.\n * @param {(key: string) => string} [opts.resolvePath] logical state key ->\n * storage path. THE domain seam: the framework only ever names keys\n * ('desktops', 'datatable_state'); the embedder decides where they land.\n * @param {object} [opts.logger]\n */\nexport function createPywebviewHost({ bridgeRef = null, resolvePath = (k) => `${k}.json`, logger = console } = {}) {\n const api = () => bridgeRef?.current ?? window.pywebview?.api ?? null;\n\n const call = async (name, args = []) => {\n const a = api();\n if (!a || typeof a[name] !== 'function') return null;\n try { return await a[name](...args); }\n catch (e) { logger.warn?.('[host] call failed', name, e); return null; }\n };\n\n // Envelope unwrapping, in ONE place. Transcribed from the call sites this\n // replaces, so app.py's catch-all `{ok: true}` reply (which carries no\n // `maximized` key) still reads as false, exactly as it does today.\n const okMax = (r) => Boolean(r && r.ok && r.maximized === true);\n const okFs = (r) => Boolean(r && r.ok && r.fullscreen);\n\n // ALL THREE capabilities are ALWAYS advertised. Do NOT gate them on api()\n // being non-null at construction time: the methods late-bind through the\n // ref, and gating here would permanently strand a late-arriving bridge on\n // the fallback paths (Blob download instead of the native save dialog).\n return createHost({\n window: {\n chrome: () => (usesCustomWindowChrome() ? 'custom' : 'native'),\n minimize: () => { void call('window_minimize'); },\n close: () => { void call('window_close'); },\n isMaximized: async () => okMax(await call('window_is_maximized')),\n setMaximized: async (on) => okMax(await call('window_set_maximized', [on])),\n isFullscreen: async () => okFs(await call('window_is_fullscreen')),\n toggleFullscreen: async () => okFs(await call('window_toggle_fullscreen')),\n async getBounds() {\n const r = await call('window_get_bounds');\n if (!r || !r.ok) return null;\n return { x: r.x, y: r.y, width: r.width, height: r.height };\n },\n // POSITIONAL on the wire \u2014 both transports depend on it. Not async:\n // this is a rAF hot path during a window drag/resize; nobody awaits.\n setBounds({ x = null, y = null, width = null, height = null } = {}) {\n void call('window_set_bounds', [x, y, width, height]);\n },\n startNativeDrag: async () => Boolean((await call('window_start_native_drag'))?.ok),\n },\n dialogs: {\n // Resolves to null when the transport has no save_file_dialog behind it.\n // Per host.js that is the contract for \"unavailable\", and every caller\n // treats it exactly like an absent `dialogs` capability: fall back to a\n // Blob download, never report a failed save. Covered by\n // tests/ui/test_host_save_fallback.mjs.\n saveFile: ({ data, filename, kind }) => call('save_file_dialog', [data, filename, kind]),\n },\n state: {\n async read(key) {\n const blob = await call('workspace_state_read', [{ path: resolvePath(key) }]);\n if (!blob) return null;\n try { return typeof blob === 'string' ? JSON.parse(blob) : blob; }\n catch (e) { logger.warn?.('[host] bad JSON for state key', key, e); return null; }\n },\n async write(key, value) {\n const r = await call('workspace_state_write',\n [{ path: resolvePath(key), data: JSON.stringify(value) }]);\n return r !== null;\n },\n },\n });\n}\n"],
|
|
5
|
-
"mappings": ";;;AAiBO,IAAM,gBAAgB,OAAO,OAAO;AAAA,EACvC,QAAQ,OAAO,OAAO;AAAA,IAClB,UAAU,OAAO,OAAO;AAAA,MAAC;AAAA,MAAU;AAAA,MAAY;AAAA,MAAS;AAAA,MAAe;AAAA,MAC9C;AAAA,MAAgB;AAAA,MAAoB;AAAA,MAAa;AAAA,IAAW,CAAC;AAAA,IACtF,UAAU,OAAO,OAAO,CAAC,iBAAiB,CAAC;AAAA,EAC/C,CAAC;AAAA,EACD,SAAS,OAAO,OAAO,EAAE,UAAU,OAAO,OAAO,CAAC,UAAU,CAAC,GAAG,UAAU,OAAO,OAAO,CAAC,CAAC,EAAE,CAAC;AAAA,EAC7F,OAAS,OAAO,OAAO,EAAE,UAAU,OAAO,OAAO,CAAC,QAAQ,OAAO,CAAC,GAAG,UAAU,OAAO,OAAO,CAAC,CAAC,EAAE,CAAC;AACtG,CAAC;AAYM,SAAS,mBAAmB,MAAM,KAAK;AAC1C,QAAM,OAAO,cAAc,IAAI;AAC/B,MAAI,CAAC,KAAM,QAAO,EAAE,IAAI,OAAO,SAAS,CAAC,uBAAuB,IAAI,GAAG,EAAE;AACzE,MAAI,CAAC,OAAO,OAAO,QAAQ,SAAU,QAAO,EAAE,IAAI,OAAO,SAAS,CAAC,GAAG,KAAK,QAAQ,EAAE;AACrF,QAAM,UAAU,KAAK,SAAS,OAAO,CAAC,MAAM,OAAO,IAAI,CAAC,MAAM,UAAU;AACxE,SAAO,EAAE,IAAI,QAAQ,WAAW,GAAG,QAAQ;AAC/C;AAUO,SAAS,WAAW,OAAO,CAAC,GAAG;AAClC,QAAM,OAAO,CAAC;AACd,aAAW,QAAQ,OAAO,KAAK,aAAa,GAAG;AAC3C,UAAM,MAAM,KAAK,IAAI;AACrB,QAAI,OAAO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YAAI,CAAC,KAAM,QAAO;AAClB,YAAI;AAAE,iBAAO,OAAO,SAAS,WAAW,KAAK,MAAM,IAAI,IAAI;AAAA,QAAM,SAC1D,GAAG;AAAE,iBAAO,OAAO,iCAAiC,KAAK,CAAC;AAAG,iBAAO;AAAA,QAAM;AAAA,MACrF;AAAA,MACA,MAAM,MAAM,KAAK,OAAO;AACpB,cAAM,IAAI,MAAM;AAAA,UAAK;AAAA,UACA,CAAC,EAAE,MAAM,YAAY,GAAG,GAAG,MAAM,KAAK,UAAU,KAAK,EAAE,CAAC;AAAA,QAAC;AAC9E,eAAO,MAAM;AAAA,MACjB;AAAA,IACJ;AAAA,EACJ,CAAC;AACL;",
|
|
3
|
+
"sources": ["../src/host/host.js", "../src/host/pywebview_host.js", "../src/host/photino_host.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * host.js \u2014 the host port.\n *\n * The framework declares what it needs from its embedder. A Host is a bag of\n * INDEPENDENTLY OPTIONAL capability objects:\n *\n * - absent capability => absent key (never a stub)\n * - present capability => must be complete (validated at boot)\n *\n * There is NO module-level default host and NO getHost(). Hosts are injected \u2014\n * a module singleton here would just be `window.pywebview` wearing a hat, and\n * would make a second host (mock, browser tab, VS Code webview) impossible.\n *\n * Zero pywebview. Zero EcoAgent. See pywebview_host.js for the reference\n * adapter that implements this port against the pywebview / HTTP transports.\n */\n\nexport const HOST_CONTRACT = Object.freeze({\n window: Object.freeze({\n required: Object.freeze(['chrome', 'minimize', 'close', 'isMaximized', 'setMaximized',\n 'isFullscreen', 'toggleFullscreen', 'getBounds', 'setBounds']),\n optional: Object.freeze(['startNativeDrag']),\n }),\n dialogs: Object.freeze({ required: Object.freeze(['saveFile']), optional: Object.freeze([]) }),\n state: Object.freeze({ required: Object.freeze(['read', 'write']), optional: Object.freeze([]) }),\n});\n\n/**\n * Validate ONE capability object. We validate the capability the adapter\n * authored \u2014 a plain object literal with real closures \u2014 not the raw bridge:\n * `index.html`'s browser-mode polyfill installs a `new Proxy({}, {get})` that\n * returns a function for EVERY property name, so duck-typing the bridge is\n * vacuously true and validates nothing. A Proxy cannot forge a missing key in\n * an object literal.\n *\n * @returns {{ ok: boolean, missing: string[] }}\n */\nexport function validateCapability(name, cap) {\n const spec = HOST_CONTRACT[name];\n if (!spec) return { ok: false, missing: [`unknown capability '${name}'`] };\n if (!cap || typeof cap !== 'object') return { ok: false, missing: [...spec.required] };\n const missing = spec.required.filter((m) => typeof cap[m] !== 'function');\n return { ok: missing.length === 0, missing };\n}\n\n/**\n * Validate + freeze a set of capabilities into a Host.\n * Throws at boot on an incomplete capability \u2014 a half-wired host is a bug,\n * and a bug at boot beats a silent degrade at click time.\n *\n * @param {{ window?: object, dialogs?: object, state?: object }} caps\n * @returns {Readonly<object>} the Host\n */\nexport function createHost(caps = {}) {\n const host = {};\n for (const name of Object.keys(HOST_CONTRACT)) {\n const cap = caps[name];\n if (cap == null) continue; // legitimately absent\n const v = validateCapability(name, cap);\n if (!v.ok) {\n throw new Error(`Host capability '${name}' is incomplete: missing ${v.missing.join(', ')}`);\n }\n host[name] = Object.freeze(cap);\n }\n return Object.freeze(host);\n}\n\n/** The zero-capability host. Every framework consumer MUST survive it. */\nexport const NULL_HOST = createHost({});\n", "/**\n * pywebview_host.js \u2014 the REFERENCE host adapter.\n *\n * Knows pywebview. Knows NOTHING about EcoAgent: every domain fact (which\n * bridge ref to use, where a state key lands on disk) arrives as a parameter.\n * This is the adapter a standalone consumer copies; EcoAgent is just its first\n * caller (see ui/js/bootstrap/app_bootstrap.js).\n *\n * It speaks to whatever `window.pywebview.api` currently is \u2014 the real\n * pywebview bridge in the desktop app, or the `POST /api/<method>` Proxy\n * polyfill that ui/index.html installs in --browser mode. Both transports are\n * positional-on-the-wire, which is why setBounds() spreads its object back out\n * into positional args.\n */\n\nimport { createHost } from './host.js';\n\nconst FRAMELESS_BACKENDS = new Set(['edgechromium', 'mshtml']);\n\n/**\n * Custom (frameless) window chrome \u2014 the min/max/close buttons, edge resize\n * handles and drag-to-move top bar \u2014 only makes sense when our top bar IS the\n * window's title bar. That holds on a native pywebview window the OS draws\n * *without* decorations of its own: Windows (frameless). On Linux/macOS the\n * window manager already draws a native title bar above our top bar, and in\n * `--browser` mode the browser supplies its own chrome \u2014 in both cases the\n * custom controls are a redundant second set, so we neither render nor wire\n * them (which also stops us swallowing native F11 fullscreen and showing dead\n * resize cursors at the window edges).\n *\n * Detection keys off the pywebview backend string, which is unambiguous: the\n * browser-mode polyfill in index.html injects only `.api`, never `.platform`,\n * so any `.platform` at all \u21D2 running as a native pywebview app. The frameless\n * (custom-title-bar) backends are the Windows WebViews \u2014 'edgechromium' /\n * 'mshtml'. Linux ('gtkwebkit2' / 'qtwebengine') and macOS ('cocoa') draw\n * native decorations, so they return false. Verified live: WebKitGTK reports\n * platform 'gtkwebkit2'.\n */\nexport function usesCustomWindowChrome() {\n // Authoritative signal from the Python host: run_pywebview_mode() appends\n // `?frameless=1` to the window URL exactly when it created a frameless native\n // window (Windows). Prefer it over the backend sniff below because it's\n // present at document parse \u2014 before pywebview finishes injecting\n // `window.pywebview` (and before the browser-mode polyfill, which sets `.api`\n // but no `.platform`, can clobber it). Reading the sniff at shell-build time\n // otherwise races and the whole custom chrome silently fails to render.\n try {\n if (new URLSearchParams(window.location.search).get('frameless') === '1') {\n return true;\n }\n } catch (_) { /* location unavailable (non-browser env) \u2014 fall through */ }\n const platform = window.pywebview && window.pywebview.platform;\n return !!platform && FRAMELESS_BACKENDS.has(platform);\n}\n\n/**\n * Build a Host backed by the pywebview bridge.\n *\n * @param {object} opts\n * @param {{current: object|null}} [opts.bridgeRef] LIVE ref to the bridge.\n * MUST be a ref, never a snapshot: `setupHostBridgeListener` mutates\n * `.current` when a late bridge arrives, and `resolveHostBridge` can\n * resolve `null` after its timeout. Snapshotting the bridge here would\n * freeze that null and reproduce as an intermittent boot failure.\n * @param {(key: string) => string} [opts.resolvePath] logical state key ->\n * storage path. THE domain seam: the framework only ever names keys\n * ('desktops', 'datatable_state'); the embedder decides where they land.\n * @param {object} [opts.logger]\n */\nexport function createPywebviewHost({ bridgeRef = null, resolvePath = (k) => `${k}.json`, logger = console } = {}) {\n const api = () => bridgeRef?.current ?? window.pywebview?.api ?? null;\n\n const call = async (name, args = []) => {\n const a = api();\n if (!a || typeof a[name] !== 'function') return null;\n try { return await a[name](...args); }\n catch (e) { logger.warn?.('[host] call failed', name, e); return null; }\n };\n\n // Envelope unwrapping, in ONE place. Transcribed from the call sites this\n // replaces, so app.py's catch-all `{ok: true}` reply (which carries no\n // `maximized` key) still reads as false, exactly as it does today.\n const okMax = (r) => Boolean(r && r.ok && r.maximized === true);\n const okFs = (r) => Boolean(r && r.ok && r.fullscreen);\n\n // ALL THREE capabilities are ALWAYS advertised. Do NOT gate them on api()\n // being non-null at construction time: the methods late-bind through the\n // ref, and gating here would permanently strand a late-arriving bridge on\n // the fallback paths (Blob download instead of the native save dialog).\n return createHost({\n window: {\n chrome: () => (usesCustomWindowChrome() ? 'custom' : 'native'),\n minimize: () => { void call('window_minimize'); },\n close: () => { void call('window_close'); },\n isMaximized: async () => okMax(await call('window_is_maximized')),\n setMaximized: async (on) => okMax(await call('window_set_maximized', [on])),\n isFullscreen: async () => okFs(await call('window_is_fullscreen')),\n toggleFullscreen: async () => okFs(await call('window_toggle_fullscreen')),\n async getBounds() {\n const r = await call('window_get_bounds');\n if (!r || !r.ok) return null;\n return { x: r.x, y: r.y, width: r.width, height: r.height };\n },\n // POSITIONAL on the wire \u2014 both transports depend on it. Not async:\n // this is a rAF hot path during a window drag/resize; nobody awaits.\n setBounds({ x = null, y = null, width = null, height = null } = {}) {\n void call('window_set_bounds', [x, y, width, height]);\n },\n startNativeDrag: async () => Boolean((await call('window_start_native_drag'))?.ok),\n },\n dialogs: {\n // Resolves to null when the transport has no save_file_dialog behind it.\n // Per host.js that is the contract for \"unavailable\", and every caller\n // treats it exactly like an absent `dialogs` capability: fall back to a\n // Blob download, never report a failed save. Covered by\n // tests/ui/test_host_save_fallback.mjs.\n saveFile: ({ data, filename, kind }) => call('save_file_dialog', [data, filename, kind]),\n },\n state: {\n async read(key) {\n const blob = await call('workspace_state_read', [{ path: resolvePath(key) }]);\n if (!blob) return null;\n try { return typeof blob === 'string' ? JSON.parse(blob) : blob; }\n catch (e) { logger.warn?.('[host] bad JSON for state key', key, e); return null; }\n },\n async write(key, value) {\n const r = await call('workspace_state_write',\n [{ path: resolvePath(key), data: JSON.stringify(value) }]);\n return r !== null;\n },\n },\n });\n}\n", "/**\n * photino_host.js \u2014 the host port over a Photino.NET window.\n *\n * Photino gives the page exactly two things: `window.external.sendMessage(text)`\n * and `window.external.receiveMessage(callback)`. Strings in, strings out, no\n * replies. This adapter puts a request/reply protocol over them, matched by id:\n *\n * page \u2192 host {\"id\": 7, \"cap\": \"window\", \"op\": \"setBounds\", \"args\": [{\"x\":0,\"y\":0,\"width\":1200,\"height\":800}]}\n * host \u2192 page {\"id\": 7, \"ok\": true, \"value\": null}\n * host \u2192 page {\"id\": 8, \"ok\": false, \"error\": \"no such op\"}\n * host \u2192 page {\"event\": \"window.maximizedChanged\", \"value\": true} // unsolicited, no id\n *\n * and offers the port's `window`, `dialogs` and `state` capabilities on top.\n * The C# side \u2014 one dispatcher on the window's web-message handler, every op\n * with its args and reply \u2014 is documented in `photino_host.md` beside this file.\n *\n * Like pywebview_host.js it knows the transport and NOTHING about the app: an\n * embedder that keeps some capability elsewhere (BugDesk keeps `state` on its\n * own server) passes that capability in, or `null` to leave it out.\n *\n * In a browser tab there is no `window.external.sendMessage`, and\n * createPhotinoHost() returns NULL_HOST \u2014 the fallback every FlexDesk consumer\n * already has to survive.\n */\n\nimport { createHost, NULL_HOST } from './host.js';\n\n/** True when `ext` (default: `window.external`) is a Photino bridge. */\nexport function isPhotinoWindow(ext = (typeof window !== 'undefined' ? window.external : undefined)) {\n return !!ext && typeof ext.sendMessage === 'function' && typeof ext.receiveMessage === 'function';\n}\n\n/**\n * The bare request/reply layer. `call(cap, op, ...args)` sends one request and\n * resolves with the reply's `value` (`request(cap, op, args, {wait})` is the\n * same with a timeout of its own). It REJECTS when the host answers\n * `ok: false` (with the host's error) and when no reply arrives within\n * `timeoutMs`. A reply for an id nobody is waiting on, a message that is not\n * JSON, and anything that is neither a reply nor an event are dropped.\n *\n * @param {object} opts\n * @param {{sendMessage: Function, receiveMessage: Function}} opts.external\n * @param {number} [opts.timeoutMs=10000]\n * @param {(name: string, value: any) => void} [opts.onEvent] id-less `{event, value}` messages\n * @param {object} [opts.logger]\n */\nexport function createPhotinoTransport({ external, timeoutMs = 10000, onEvent = null, logger = console }) {\n const pending = new Map();\n let seq = 0;\n external.receiveMessage((text) => {\n let m;\n try { m = typeof text === 'string' ? JSON.parse(text) : text; } catch { return; }\n if (!m || typeof m !== 'object') return;\n if (m.id == null) {\n if (typeof m.event === 'string' && onEvent) {\n try { onEvent(m.event, m.value); }\n catch (e) { logger.warn?.('[host] photino event handler failed', m.event, e); }\n }\n return;\n }\n const p = pending.get(m.id);\n if (!p) return;\n pending.delete(m.id);\n clearTimeout(p.timer);\n if (m.ok) p.resolve(m.value === undefined ? null : m.value);\n else p.reject(new Error(m.error || `${p.what}: refused by the host`));\n });\n // `wait` is this request's timeout in ms; 0 waits for as long as it takes.\n const request = (cap, op, args = [], { wait = timeoutMs } = {}) => new Promise((resolve, reject) => {\n const id = ++seq;\n const what = `${cap}.${op}`;\n const timer = wait > 0 ? setTimeout(() => {\n if (pending.delete(id)) reject(new Error(`${what}: no answer from the host within ${wait} ms`));\n }, wait) : null;\n pending.set(id, { resolve, reject, timer, what });\n try {\n external.sendMessage(JSON.stringify({ id, cap, op, args }));\n } catch (e) {\n pending.delete(id);\n clearTimeout(timer);\n reject(e);\n }\n });\n const call = (cap, op, ...args) => request(cap, op, args);\n return { call, request, pending: () => pending.size };\n}\n\n/**\n * Build a Host backed by a Photino window.\n *\n * The capability methods follow pywebview_host.js's contract, so a consumer\n * cannot tell the two apart: they DEGRADE instead of rejecting. A failed query\n * reads as false / null, a failed fire-and-forget is logged, and a save that\n * the host refused or never answered resolves `null` \u2014 the host.js meaning of\n * \"unavailable\", which every caller turns into a Blob download.\n *\n * @param {object} [opts]\n * @param {object} [opts.external=window.external] the Photino bridge (a fake one in tests)\n * @param {number} [opts.timeoutMs=10000]\n * @param {(name: string, value: any) => void} [opts.onEvent]\n * @param {object} [opts.logger=console]\n * @param {object|null} [opts.window] replace the window capability, or `null` to leave it out\n * @param {object|null} [opts.dialogs] replace the dialogs capability, or `null` to leave it out\n * @param {object|null} [opts.state] replace the state capability, or `null` to leave it out\n * @returns {Readonly<object>} a Host, or NULL_HOST outside a Photino window\n */\nexport function createPhotinoHost(opts = {}) {\n const {\n external = (typeof window !== 'undefined' ? window.external : undefined),\n timeoutMs = 10000,\n onEvent = null,\n logger = console,\n } = opts;\n if (!isPhotinoWindow(external)) return NULL_HOST;\n\n const { call, request } = createPhotinoTransport({ external, timeoutMs, onEvent, logger });\n const warn = (cap, op, e) => logger.warn?.('[host] photino call failed', `${cap}.${op}`, e);\n const soft = async (fallback, cap, op, ...args) => {\n try { return await call(cap, op, ...args); }\n catch (e) { warn(cap, op, e); return fallback; }\n };\n const fire = (cap, op, ...args) => { void soft(null, cap, op, ...args); };\n\n const defaults = {\n window: {\n // Photino draws a decorated, native window on every OS: FlexDesk's\n // own min/max/close buttons would be a second set.\n chrome: () => 'native',\n minimize: () => { fire('window', 'minimize'); },\n close: () => { fire('window', 'close'); },\n isMaximized: async () => (await soft(false, 'window', 'isMaximized')) === true,\n setMaximized: async (on) => (await soft(false, 'window', 'setMaximized', !!on)) === true,\n isFullscreen: async () => (await soft(false, 'window', 'isFullscreen')) === true,\n toggleFullscreen: async () => (await soft(false, 'window', 'toggleFullscreen')) === true,\n async getBounds() {\n const b = await soft(null, 'window', 'getBounds');\n if (!b || typeof b !== 'object') return null;\n return { x: b.x, y: b.y, width: b.width, height: b.height };\n },\n // Not async, like pywebview's: a rAF hot path during a drag; nobody awaits.\n setBounds({ x = null, y = null, width = null, height = null } = {}) {\n fire('window', 'setBounds', { x, y, width, height });\n },\n },\n dialogs: {\n // `{ok: true, path}` | `{ok: false, cancelled: true}` | `{ok: false, error}`,\n // or null when the host refused: fall back to a download. NO TIMEOUT \u2014\n // the dialog is open for as long as the user takes, and giving up on it\n // would download the file a second time behind the dialog.\n async saveFile({ data, filename, kind } = {}) {\n let r = null;\n try { r = await request('dialogs', 'saveFile', [{ data, filename, kind }], { wait: 0 }); }\n catch (e) { warn('dialogs', 'saveFile', e); }\n return r && typeof r === 'object' ? r : null;\n },\n },\n state: {\n async read(key) {\n const v = await soft(null, 'state', 'read', key);\n if (typeof v !== 'string') return v ?? null;\n try { return JSON.parse(v); }\n catch (e) { logger.warn?.('[host] bad JSON for state key', key, e); return null; }\n },\n async write(key, value) {\n return (await soft(false, 'state', 'write', key, value)) !== false;\n },\n },\n };\n\n const caps = {};\n for (const name of Object.keys(defaults)) {\n if (!(name in opts)) caps[name] = defaults[name];\n else if (opts[name] != null) caps[name] = opts[name];\n }\n return createHost(caps);\n}\n"],
|
|
5
|
+
"mappings": ";;;AAiBO,IAAM,gBAAgB,OAAO,OAAO;AAAA,EACvC,QAAQ,OAAO,OAAO;AAAA,IAClB,UAAU,OAAO,OAAO;AAAA,MAAC;AAAA,MAAU;AAAA,MAAY;AAAA,MAAS;AAAA,MAAe;AAAA,MAC9C;AAAA,MAAgB;AAAA,MAAoB;AAAA,MAAa;AAAA,IAAW,CAAC;AAAA,IACtF,UAAU,OAAO,OAAO,CAAC,iBAAiB,CAAC;AAAA,EAC/C,CAAC;AAAA,EACD,SAAS,OAAO,OAAO,EAAE,UAAU,OAAO,OAAO,CAAC,UAAU,CAAC,GAAG,UAAU,OAAO,OAAO,CAAC,CAAC,EAAE,CAAC;AAAA,EAC7F,OAAS,OAAO,OAAO,EAAE,UAAU,OAAO,OAAO,CAAC,QAAQ,OAAO,CAAC,GAAG,UAAU,OAAO,OAAO,CAAC,CAAC,EAAE,CAAC;AACtG,CAAC;AAYM,SAAS,mBAAmB,MAAM,K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AM,MAAM,KAAK,OAAO;AACpB,eAAQ,MAAM,KAAK,OAAO,SAAS,SAAS,KAAK,KAAK,MAAO;AAAA,MACjE;AAAA,IACJ;AAAA,EACJ;AAEA,QAAM,OAAO,CAAC;AACd,aAAW,QAAQ,OAAO,KAAK,QAAQ,GAAG;AACtC,QAAI,EAAE,QAAQ,MAAO,MAAK,IAAI,IAAI,SAAS,IAAI;AAAA,aACtC,KAAK,IAAI,KAAK,KAAM,MAAK,IAAI,IAAI,KAAK,IAAI;AAAA,EACvD;AACA,SAAO,WAAW,IAAI;AAC1B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/tiles.js
CHANGED
|
@@ -28,8 +28,8 @@ import {
|
|
|
28
28
|
purge,
|
|
29
29
|
resize,
|
|
30
30
|
strideDownsampleShared
|
|
31
|
-
} from "./chunk-
|
|
32
|
-
import "./chunk-
|
|
31
|
+
} from "./chunk-RQM5Z2MU.js";
|
|
32
|
+
import "./chunk-FBGP5KN5.js";
|
|
33
33
|
import "./chunk-6JSOVNID.js";
|
|
34
34
|
import "./chunk-FL5KFNQH.js";
|
|
35
35
|
import {
|
|
@@ -1355,9 +1355,17 @@ var ChartTile = class extends TileBase {
|
|
|
1355
1355
|
try {
|
|
1356
1356
|
const P = await ensurePlotly();
|
|
1357
1357
|
const uri = await P.toImage(this._plotEl, { format: "png", scale: 2 });
|
|
1358
|
+
const filename = `${slug(this.config.title || this.constructor.TITLE)}.png`;
|
|
1359
|
+
const dialogs = this.host?.dialogs;
|
|
1360
|
+
const result = dialogs ? await dialogs.saveFile({ data: uri.split(",")[1], filename, kind: "png" }) : null;
|
|
1361
|
+
if (result) {
|
|
1362
|
+
if (result.ok) this._notify("Download", `Chart saved to ${result.path}`, "success");
|
|
1363
|
+
else if (!result.cancelled) this._notify("Download failed", result.error || "The image could not be saved", "error");
|
|
1364
|
+
return;
|
|
1365
|
+
}
|
|
1358
1366
|
const a = document.createElement("a");
|
|
1359
1367
|
a.href = uri;
|
|
1360
|
-
a.download =
|
|
1368
|
+
a.download = filename;
|
|
1361
1369
|
a.click();
|
|
1362
1370
|
} catch (err) {
|
|
1363
1371
|
this._notify("Download failed", `The image could not be made: ${err?.message || err}`, "error");
|