@surdeddd/wmkit 0.7.1 → 0.7.2

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.
@@ -2472,7 +2472,7 @@ function attachDesktop(wm, element, options = {}) {
2472
2472
  // src/dom/binder.ts
2473
2473
  function createDesktopBinder(wm, options = {}) {
2474
2474
  let controller = null;
2475
- let stopOpen = null;
2475
+ let stops = [];
2476
2476
  const entries = /* @__PURE__ */ new Set();
2477
2477
  function attachEntry(entry) {
2478
2478
  if (controller && !entry.detach && wm.get(entry.id)) {
@@ -2480,8 +2480,8 @@ function createDesktopBinder(wm, options = {}) {
2480
2480
  }
2481
2481
  }
2482
2482
  function unbindDesktop() {
2483
- stopOpen?.();
2484
- stopOpen = null;
2483
+ for (const stop of stops) stop();
2484
+ stops = [];
2485
2485
  for (const entry of entries) entry.detach = null;
2486
2486
  controller?.destroy();
2487
2487
  controller = null;
@@ -2492,11 +2492,18 @@ function createDesktopBinder(wm, options = {}) {
2492
2492
  bindDesktop(element) {
2493
2493
  if (controller) throw new Error("wmkit: desktop is already bound");
2494
2494
  controller = attachDesktop(wm, element, options);
2495
- stopOpen = wm.on("open", ({ window: win }) => {
2496
- for (const entry of entries) {
2497
- if (entry.id === win.id) attachEntry(entry);
2498
- }
2499
- });
2495
+ stops.push(
2496
+ wm.on("open", ({ window: win }) => {
2497
+ for (const entry of entries) {
2498
+ if (entry.id === win.id) attachEntry(entry);
2499
+ }
2500
+ }),
2501
+ wm.on("close", ({ window: win }) => {
2502
+ for (const entry of entries) {
2503
+ if (entry.id === win.id) entry.detach = null;
2504
+ }
2505
+ })
2506
+ );
2500
2507
  for (const entry of entries) attachEntry(entry);
2501
2508
  return unbindDesktop;
2502
2509
  },
@@ -2534,5 +2541,5 @@ exports.flipToTarget = flipToTarget;
2534
2541
  exports.magnetize = magnetize;
2535
2542
  exports.prefersReducedMotion = prefersReducedMotion;
2536
2543
  exports.zoneBounds = zoneBounds;
2537
- //# sourceMappingURL=chunk-2VRCYMKH.cjs.map
2538
- //# sourceMappingURL=chunk-2VRCYMKH.cjs.map
2544
+ //# sourceMappingURL=chunk-NJAI5R4J.cjs.map
2545
+ //# sourceMappingURL=chunk-NJAI5R4J.cjs.map