Files
MajoorWaldi-ComfyUI-Majoor-…/js/stores/panelStateBridge.js
T
MajoorWaldi 2fa41a0e76 feat: add useGridState and useVirtualGrid composables for asset management
- Implemented useGridState to manage grid state, including asset selection and loading states.
- Created useVirtualGrid to centralize virtualization helpers for improved performance.
- Added createVueApp for isolated Vue 3 + Pinia application instances.
- Introduced Vite configuration for building the ComfyUI-Majoor-AssetsManager with external dependencies.
2026-04-03 11:04:55 +02:00

49 lines
1.3 KiB
JavaScript

import { getOptionalPanelStore } from "./getOptionalPanelStore.js";
/**
* Creates a thin read/write facade over the Pinia panel store.
*
* The `state` and `keys` parameters are kept for call-site compatibility but
* are no longer used — migration to Pinia-only (Phase 3) is complete.
*
* @param {*} _state - Unused (legacy transition parameter).
* @param {string[]} _keys - Unused (legacy transition parameter).
* @returns {{ panelStore, read, write, controllerState, isPiniaOnly: true }}
*/
export function createPanelStateBridge(_state, _keys = []) {
const panelStore = getOptionalPanelStore();
const read = (key, fallback = "") => {
try {
if (panelStore && key in panelStore) {
const value = panelStore[key];
if (value !== undefined) return value;
}
} catch (e) {
console.debug?.(e);
}
return fallback;
};
const write = (key, value) => {
try {
if (panelStore && key in panelStore) {
panelStore[key] = value;
}
} catch (e) {
console.debug?.(e);
}
};
const controllerState = () => panelStore;
return {
panelStore,
hydrateStoreFromLegacy: () => {},
read,
write,
controllerState,
isPiniaOnly: true,
};
}