Release 1.0.10 with subpath deployment and modal menu invokes.
Add app_base/router_base config, compat path helpers, and scoped service worker registration so apps can mount under a URL prefix. Wire invoke_type modal through a handler registry and open the notification center from the standard menu flow. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+46
-1
@@ -72,10 +72,55 @@ export const InvokeHandlers = {
|
||||
* @param {Event|null} event - Original event object
|
||||
*/
|
||||
goToModal: (menuItem, eventSource = null, event = null) => {
|
||||
// To be implemented in App.jsx
|
||||
return invokeRegisteredModal(menuItem, eventSource, event);
|
||||
}
|
||||
};
|
||||
|
||||
const modalHandlers = new Map();
|
||||
|
||||
/**
|
||||
* Register a handler for invoke_type "modal" targets (e.g. notifications panel).
|
||||
* @param {string} target - invoke_target value from the menu item
|
||||
* @param {Function} handler - (menuItem, eventSource, event) => any
|
||||
* @returns {Function} Unregister function
|
||||
*/
|
||||
export function registerModalHandler(target, handler) {
|
||||
const key = String(target || '').trim();
|
||||
if (!key || typeof handler !== 'function') {
|
||||
return () => {};
|
||||
}
|
||||
|
||||
modalHandlers.set(key, handler);
|
||||
return () => {
|
||||
modalHandlers.delete(key);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve a registered modal handler by invoke_target.
|
||||
* @param {string} target
|
||||
* @returns {Function|null}
|
||||
*/
|
||||
export function resolveModalHandler(target) {
|
||||
const key = String(target || '').trim();
|
||||
return key ? modalHandlers.get(key) || null : null;
|
||||
}
|
||||
|
||||
export function invokeRegisteredModal(menuItem, eventSource = null, event = null) {
|
||||
if (!menuItem?.invoke_target) {
|
||||
console.warn('[MenuItem] invoke_type "modal" requires invoke_target to be set');
|
||||
return null;
|
||||
}
|
||||
|
||||
const handler = resolveModalHandler(menuItem.invoke_target);
|
||||
if (!handler) {
|
||||
console.warn(`[MenuItem] No modal handler registered for "${menuItem.invoke_target}"`);
|
||||
return null;
|
||||
}
|
||||
|
||||
return handler(menuItem, eventSource, event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Subscribe to menu changes
|
||||
* @param {Function} listener - Callback function called when menu changes
|
||||
|
||||
Reference in New Issue
Block a user