fix dialog key override / restore, add named module loading

This commit is contained in:
Stewart Allen 2025-12-25 17:58:45 -05:00
commit 7290103b22
8 changed files with 37 additions and 22 deletions

View file

@ -1,7 +1,5 @@
self.kiri.load(api => { self.kiri.load(api => {
console.log('BAMBU MODULE RUNNING');
const { uc: ui } = api; const { uc: ui } = api;
const { $, h } = api.web; const { $, h } = api.web;
const defams = ";; DEFINE BAMBU-AMS "; const defams = ";; DEFINE BAMBU-AMS ";
@ -1327,4 +1325,4 @@ self.kiri.load(api => {
setInterval(monitor_keepalive, 5000); setInterval(monitor_keepalive, 5000);
let bblapi = api.bambu = { send, prep_export }; let bblapi = api.bambu = { send, prep_export };
}); }, 'Bambu');

View file

@ -20,4 +20,4 @@ self.kiri.load(api => {
} }
}; };
}); });
}); }, 'Developer');

View file

@ -115,7 +115,15 @@ export const api = {
clone: Object.clone, clone: Object.clone,
color, color,
conf: settings.conf, conf: settings.conf,
const: { LANG, LOCAL, SETUP, SECURE, SPACE, STACKS, ...consts }, const: {
LANG, LOCAL, SETUP, SECURE, SPACE, STACKS,
...consts,
URL: {
path: LOC.pathname,
hash: LOC.hash.substring(1),
query: LOC.search.substring(1)
}
},
/** /**
* Development/debug utilities * Development/debug utilities
*/ */
@ -151,12 +159,14 @@ export const api = {
redo: noop // do.js redo: noop // do.js
}, },
event: { event: {
on(t,l) { return EVENT.on(t,l) },
emit(t,m,o) { return EVENT.publish(t,m,o) },
bind(t,m,o) { return EVENT.bind(t,m,o) },
alerts(clr) { alerts.update(clr) }, alerts(clr) { alerts.update(clr) },
bind(t,m,o) { return EVENT.bind(t,m,o) },
emit(t,m,o) { return EVENT.publish(t,m,o) },
import() { api.ui.load.click() }, import() { api.ui.load.click() },
settings: settingsUI.trigger_event listeners(topic) { return EVENT.targets(topic) },
on(t,l) { return EVENT.on(t,l) },
settings: settingsUI.trigger_event,
topics() { return EVENT.topics() }
}, },
electron: navigator.userAgent.includes('Electron'), electron: navigator.userAgent.includes('Electron'),
/** /**

View file

@ -208,9 +208,11 @@ function confirm(message, buttons, input, opt = {}) {
html.appendAll(opt.post); html.appendAll(opt.post);
} }
dialog.innerHTML = html.join(''); dialog.innerHTML = html.join('');
dialog.onclose = () => {
feature.on_key = onkey_save;
};
function done(value) { function done(value) {
dialog.close(); dialog.close();
feature.on_key = onkey_save;
if (value !== undefined) { if (value !== undefined) {
setTimeout(() => { resolve(value) }, 150); setTimeout(() => { resolve(value) }, 150);
} }

View file

@ -253,15 +253,15 @@ class KeyboardControl {
if (handler({key:evt})) return; if (handler({key:evt})) return;
} }
// Handle Ctrl key combinations // Handle widget grouping (disabled: broken, conflicts with hash settings)
if (evt.ctrlKey) { if (evt.ctrlKey) {
switch (evt.key) { switch (evt.key) {
case 'g': return this.#api.group.merge(); // case 'g': return this.#api.group.merge();
case 'u': return this.#api.group.split(); // case 'u': return this.#api.group.split();
} }
} }
switch (evt.charCode) { switch (evt.keyCode) {
case this.#cca('`'): this.#api.show.slices(0); break; case this.#cca('`'): this.#api.show.slices(0); break;
case this.#cca('0'): { case this.#cca('0'): {
const { max } = this.#slider.getRange(); const { max } = this.#slider.getRange();

View file

@ -62,7 +62,6 @@ class ModalControl {
// hide all modals before showing another // hide all modals before showing another
Object.keys(modal.#ui.modals).forEach(name => { Object.keys(modal.#ui.modals).forEach(name => {
console.log({ name, which });
modal.#ui.modals[name].style.display = name === which ? 'flex' : ''; modal.#ui.modals[name].style.display = name === which ? 'flex' : '';
}); });

View file

@ -14,10 +14,12 @@ import { init_sync } from '../kiri/app/init/sync.js';
let traceload = location.search.indexOf('traceload') > 0; let traceload = location.search.indexOf('traceload') > 0;
let load = []; let load = [];
function safeExec(fn) { function safeExec(fn, name) {
try { try {
if (traceload) { if (traceload) {
console.log('kiri | exec |', fn); console.log('kiri | exec |', name, fn);
} else if (name) {
console.log('kiri | load mods |', name);
} }
fn(kiri.api); fn(kiri.api);
} catch (error) { } catch (error) {
@ -37,8 +39,8 @@ async function checkReady() {
await init_input(); await init_input();
await init_sync(); await init_sync();
} }
for (let fn of load) { for (let [fn, name] of load) {
safeExec(fn); safeExec(fn, name);
} }
load = undefined; load = undefined;
api.event.emit('load-done', stats); api.event.emit('load-done', stats);
@ -63,12 +65,12 @@ async function checkReady() {
} }
self.kiri = { self.kiri = {
load(fn) { load(fn, name) {
// console.log('KIRI LOAD', [...arguments]); // console.log('KIRI LOAD', [...arguments]);
if (load) { if (load) {
load.push(fn); load.push([fn, name]);
} else { } else {
safeExec(fn); safeExec(fn, name);
} }
} }
}; };

View file

@ -18,6 +18,10 @@ class Broker {
return Object.keys(this.#topics); return Object.keys(this.#topics);
} }
targets(topic) {
return this.#topics[topic];
}
get send() { get send() {
return this.#send; return this.#send;
} }