import { createWindowManager, createDesktopBinder } from './chunk-YCHJXSTC.js'; import { shallowRef, computed, toValue, watch, getCurrentScope, onScopeDispose } from 'vue'; function disposeWithScope(dispose) { if (getCurrentScope()) onScopeDispose(dispose); } function useWindowManager(options) { const wm = createWindowManager(options); disposeWithScope(() => wm.destroy()); return wm; } function useWmState(wm) { const state = shallowRef(wm.getState()); disposeWithScope( wm.subscribe((next) => { state.value = next; }) ); return state; } function useWmWindow(wm, id) { const state = useWmState(wm); return computed(() => state.value.windows[toValue(id)]); } function useDesktop(wm, target, options) { const binder = createDesktopBinder(wm, options); watch( target, (element, _previous, onCleanup) => { if (element) onCleanup(binder.bindDesktop(element)); }, { immediate: true, flush: "post" } ); return binder; } function useWmWindowEl(binder, id, target, options) { watch( [target, () => toValue(id)], ([element, windowId], _previous, onCleanup) => { if (element && windowId) onCleanup(binder.bindWindow(windowId, element, options)); }, { immediate: true, flush: "post" } ); } export { useDesktop, useWindowManager, useWmState, useWmWindow, useWmWindowEl }; //# sourceMappingURL=vue.js.map //# sourceMappingURL=vue.js.map