ywana-core8 0.2.6 → 0.2.9

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.
@@ -1985,7 +1985,9 @@ const Button = (props) => {
1985
1985
  icon: loading ? "hourglass_empty" : icon,
1986
1986
  size: size === "small" ? "small" : size === "large" ? "normal" : "small",
1987
1987
  disabled: disabled || loading,
1988
- className: loading ? "loading-icon" : ""
1988
+ className: loading ? "loading-icon" : "",
1989
+ eventPropagation: true
1990
+ // Allow click events to bubble up to button
1989
1991
  };
1990
1992
  return /* @__PURE__ */ React.createElement(
1991
1993
  "button",
@@ -31708,6 +31710,7 @@ class WindowManager {
31708
31710
  this.windows = /* @__PURE__ */ new Map();
31709
31711
  this.activeWindowId = null;
31710
31712
  this.nextZIndex = 1e3;
31713
+ this.maxZIndex = 9999;
31711
31714
  this.listeners = /* @__PURE__ */ new Set();
31712
31715
  this.desktopSize = desktopSize;
31713
31716
  }
@@ -31769,7 +31772,7 @@ class WindowManager {
31769
31772
  size,
31770
31773
  minimized: false,
31771
31774
  maximized: false,
31772
- zIndex: this.nextZIndex++,
31775
+ zIndex: Math.min(this.nextZIndex++, this.maxZIndex),
31773
31776
  ...config
31774
31777
  };
31775
31778
  this.windows.set(window2.id, window2);
@@ -31788,7 +31791,7 @@ class WindowManager {
31788
31791
  let x = baseX + existingWindows.length * offsetStep;
31789
31792
  let y = baseY + existingWindows.length * offsetStep;
31790
31793
  const maxX = this.desktopSize.width - windowSize.width - 20;
31791
- const maxY = this.desktopSize.height - windowSize.height - 100;
31794
+ const maxY = this.desktopSize.height - windowSize.height - 20;
31792
31795
  if (x > maxX || y > maxY) {
31793
31796
  const cascadeIndex = existingWindows.length % 8;
31794
31797
  x = baseX + cascadeIndex * 30;
@@ -31824,7 +31827,10 @@ class WindowManager {
31824
31827
  if (window2.minimized) {
31825
31828
  window2.minimized = false;
31826
31829
  }
31827
- window2.zIndex = this.nextZIndex++;
31830
+ if (this.nextZIndex >= this.maxZIndex) {
31831
+ this.resetZIndexes();
31832
+ }
31833
+ window2.zIndex = Math.min(this.nextZIndex++, this.maxZIndex);
31828
31834
  this.activeWindowId = windowId;
31829
31835
  this.notifyListeners();
31830
31836
  return true;
@@ -31876,7 +31882,7 @@ class WindowManager {
31876
31882
  const minWidth = 200;
31877
31883
  const minHeight = 150;
31878
31884
  const maxWidth = this.desktopSize.width;
31879
- const maxHeight = this.desktopSize.height - 50;
31885
+ const maxHeight = this.desktopSize.height;
31880
31886
  const constrainedSize = {
31881
31887
  width: Math.max(minWidth, Math.min(size.width || window2.size.width, maxWidth)),
31882
31888
  height: Math.max(minHeight, Math.min(size.height || window2.size.height, maxHeight))
@@ -31912,7 +31918,7 @@ class WindowManager {
31912
31918
  this.windows.forEach((window2) => {
31913
31919
  if (window2.maximized) return;
31914
31920
  const maxX = this.desktopSize.width - window2.size.width;
31915
- const maxY = this.desktopSize.height - window2.size.height - 50;
31921
+ const maxY = this.desktopSize.height - window2.size.height;
31916
31922
  if (window2.position.x > maxX) {
31917
31923
  window2.position.x = Math.max(0, maxX);
31918
31924
  }
@@ -31947,7 +31953,7 @@ class WindowManager {
31947
31953
  const cols = Math.ceil(Math.sqrt(visibleWindows.length));
31948
31954
  const rows = Math.ceil(visibleWindows.length / cols);
31949
31955
  const windowWidth = Math.floor(this.desktopSize.width / cols);
31950
- const windowHeight = Math.floor((this.desktopSize.height - 80) / rows);
31956
+ const windowHeight = Math.floor(this.desktopSize.height / rows);
31951
31957
  visibleWindows.forEach((window2, index) => {
31952
31958
  const col = index % cols;
31953
31959
  const row = Math.floor(index / cols);
@@ -31972,8 +31978,8 @@ class WindowManager {
31972
31978
  if (!window2 || window2.maximized) return false;
31973
31979
  window2.position = {
31974
31980
  x: (this.desktopSize.width - window2.size.width) / 2,
31975
- y: (this.desktopSize.height - window2.size.height - 50) / 2
31976
- // Space for taskbar
31981
+ y: (this.desktopSize.height - window2.size.height) / 2
31982
+ // Workspace center
31977
31983
  };
31978
31984
  this.notifyListeners();
31979
31985
  return true;
@@ -31986,7 +31992,7 @@ class WindowManager {
31986
31992
  const offsetStep = 20;
31987
31993
  visibleWindows.forEach((window2, index) => {
31988
31994
  const baseX = (this.desktopSize.width - window2.size.width) / 2;
31989
- const baseY = (this.desktopSize.height - window2.size.height - 50) / 2;
31995
+ const baseY = (this.desktopSize.height - window2.size.height) / 2;
31990
31996
  window2.position = {
31991
31997
  x: baseX + index * offsetStep,
31992
31998
  y: baseY + index * offsetStep
@@ -32007,6 +32013,19 @@ class WindowManager {
32007
32013
  desktopSize: this.desktopSize
32008
32014
  };
32009
32015
  }
32016
+ /**
32017
+ * Reset z-indexes when they reach the maximum
32018
+ */
32019
+ resetZIndexes() {
32020
+ const windows = Array.from(this.windows.values());
32021
+ windows.sort((a, b) => a.zIndex - b.zIndex);
32022
+ this.nextZIndex = 1e3;
32023
+ windows.forEach((window2, index) => {
32024
+ window2.zIndex = this.nextZIndex + index;
32025
+ });
32026
+ this.nextZIndex = 1e3 + windows.length;
32027
+ this.notifyListeners();
32028
+ }
32010
32029
  }
32011
32030
  const WindowContext = createContext(null);
32012
32031
  const WindowProvider = ({ children, desktopSize }) => {
@@ -32031,8 +32050,10 @@ const WindowProvider = ({ children, desktopSize }) => {
32031
32050
  }
32032
32051
  }, [desktopSize]);
32033
32052
  if (!state || !windowManagerRef.current) {
32053
+ console.log("WindowProvider not ready - state:", state, "windowManager:", windowManagerRef.current);
32034
32054
  return null;
32035
32055
  }
32056
+ console.log("WindowProvider ready - providing context");
32036
32057
  const value = {
32037
32058
  // Current state
32038
32059
  windows: state.windows,
@@ -32174,6 +32195,86 @@ const Window = ({
32174
32195
  };
32175
32196
  updateWindowPosition(id, finalPosition);
32176
32197
  };
32198
+ const handleResizeStart = (e, direction) => {
32199
+ if (!resizable || maximized) return;
32200
+ e.preventDefault();
32201
+ e.stopPropagation();
32202
+ setIsResizing(true);
32203
+ setResizeDirection(direction);
32204
+ setResizeStartSize(size);
32205
+ setResizeStartPosition(position);
32206
+ setResizeStartMouse({ x: e.clientX, y: e.clientY });
32207
+ focusWindow(id);
32208
+ };
32209
+ const handleResizeMove = (e) => {
32210
+ if (!isResizing) return;
32211
+ e.preventDefault();
32212
+ const deltaX = e.clientX - resizeStartMouse.x;
32213
+ const deltaY = e.clientY - resizeStartMouse.y;
32214
+ let newSize = { ...resizeStartSize };
32215
+ let newPosition = { ...resizeStartPosition };
32216
+ switch (resizeDirection) {
32217
+ case "n":
32218
+ newSize.height = Math.max(150, resizeStartSize.height - deltaY);
32219
+ newPosition.y = resizeStartPosition.y + (resizeStartSize.height - newSize.height);
32220
+ break;
32221
+ case "s":
32222
+ newSize.height = Math.max(150, resizeStartSize.height + deltaY);
32223
+ break;
32224
+ case "e":
32225
+ newSize.width = Math.max(200, resizeStartSize.width + deltaX);
32226
+ break;
32227
+ case "w":
32228
+ newSize.width = Math.max(200, resizeStartSize.width - deltaX);
32229
+ newPosition.x = resizeStartPosition.x + (resizeStartSize.width - newSize.width);
32230
+ break;
32231
+ case "ne":
32232
+ newSize.width = Math.max(200, resizeStartSize.width + deltaX);
32233
+ newSize.height = Math.max(150, resizeStartSize.height - deltaY);
32234
+ newPosition.y = resizeStartPosition.y + (resizeStartSize.height - newSize.height);
32235
+ break;
32236
+ case "nw":
32237
+ newSize.width = Math.max(200, resizeStartSize.width - deltaX);
32238
+ newSize.height = Math.max(150, resizeStartSize.height - deltaY);
32239
+ newPosition.x = resizeStartPosition.x + (resizeStartSize.width - newSize.width);
32240
+ newPosition.y = resizeStartPosition.y + (resizeStartSize.height - newSize.height);
32241
+ break;
32242
+ case "se":
32243
+ newSize.width = Math.max(200, resizeStartSize.width + deltaX);
32244
+ newSize.height = Math.max(150, resizeStartSize.height + deltaY);
32245
+ break;
32246
+ case "sw":
32247
+ newSize.width = Math.max(200, resizeStartSize.width - deltaX);
32248
+ newSize.height = Math.max(150, resizeStartSize.height + deltaY);
32249
+ newPosition.x = resizeStartPosition.x + (resizeStartSize.width - newSize.width);
32250
+ break;
32251
+ }
32252
+ if (windowRef.current) {
32253
+ windowRef.current.style.width = `${newSize.width}px`;
32254
+ windowRef.current.style.height = `${newSize.height}px`;
32255
+ windowRef.current.style.left = `${newPosition.x}px`;
32256
+ windowRef.current.style.top = `${newPosition.y}px`;
32257
+ }
32258
+ };
32259
+ const handleResizeEnd = () => {
32260
+ if (!isResizing) return;
32261
+ setIsResizing(false);
32262
+ setResizeDirection("");
32263
+ const desktopContainer = windowRef.current?.parentElement;
32264
+ if (!desktopContainer) return;
32265
+ const windowRect = windowRef.current.getBoundingClientRect();
32266
+ const desktopRect = desktopContainer.getBoundingClientRect();
32267
+ const finalSize = {
32268
+ width: windowRect.width,
32269
+ height: windowRect.height
32270
+ };
32271
+ const finalPosition = {
32272
+ x: windowRect.left - desktopRect.left,
32273
+ y: windowRect.top - desktopRect.top
32274
+ };
32275
+ updateWindowSize(id, finalSize);
32276
+ updateWindowPosition(id, finalPosition);
32277
+ };
32177
32278
  useEffect(() => {
32178
32279
  if (isDragging) {
32179
32280
  document.addEventListener("mousemove", handleMouseMove);
@@ -32188,6 +32289,18 @@ const Window = ({
32188
32289
  };
32189
32290
  }
32190
32291
  }, [isDragging]);
32292
+ useEffect(() => {
32293
+ if (isResizing) {
32294
+ document.addEventListener("mousemove", handleResizeMove);
32295
+ document.addEventListener("mouseup", handleResizeEnd);
32296
+ document.body.style.userSelect = "none";
32297
+ return () => {
32298
+ document.removeEventListener("mousemove", handleResizeMove);
32299
+ document.removeEventListener("mouseup", handleResizeEnd);
32300
+ document.body.style.userSelect = "";
32301
+ };
32302
+ }
32303
+ }, [isResizing]);
32191
32304
  const handleMinimize = (e) => {
32192
32305
  e.stopPropagation();
32193
32306
  minimizeWindow(id, !minimized);
@@ -32222,6 +32335,7 @@ const Window = ({
32222
32335
  "window",
32223
32336
  maximized && "window--maximized",
32224
32337
  isDragging && "window--dragging",
32338
+ isResizing && "window--resizing",
32225
32339
  className
32226
32340
  ].filter(Boolean).join(" ");
32227
32341
  return /* @__PURE__ */ React.createElement(
@@ -32271,15 +32385,67 @@ const Window = ({
32271
32385
  ),
32272
32386
  toolbar && /* @__PURE__ */ React.createElement("div", { className: "window__toolbar" }, toolbar),
32273
32387
  /* @__PURE__ */ React.createElement("div", { className: "window__content" }, content || children),
32274
- statusBar && /* @__PURE__ */ React.createElement("div", { className: "window__status-bar" }, statusBar)
32388
+ statusBar && /* @__PURE__ */ React.createElement("div", { className: "window__status-bar" }, statusBar),
32389
+ resizable && !maximized && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
32390
+ "div",
32391
+ {
32392
+ className: "window__resize-handle window__resize-handle--n",
32393
+ onMouseDown: (e) => handleResizeStart(e, "n")
32394
+ }
32395
+ ), /* @__PURE__ */ React.createElement(
32396
+ "div",
32397
+ {
32398
+ className: "window__resize-handle window__resize-handle--s",
32399
+ onMouseDown: (e) => handleResizeStart(e, "s")
32400
+ }
32401
+ ), /* @__PURE__ */ React.createElement(
32402
+ "div",
32403
+ {
32404
+ className: "window__resize-handle window__resize-handle--e",
32405
+ onMouseDown: (e) => handleResizeStart(e, "e")
32406
+ }
32407
+ ), /* @__PURE__ */ React.createElement(
32408
+ "div",
32409
+ {
32410
+ className: "window__resize-handle window__resize-handle--w",
32411
+ onMouseDown: (e) => handleResizeStart(e, "w")
32412
+ }
32413
+ ), /* @__PURE__ */ React.createElement(
32414
+ "div",
32415
+ {
32416
+ className: "window__resize-handle window__resize-handle--ne",
32417
+ onMouseDown: (e) => handleResizeStart(e, "ne")
32418
+ }
32419
+ ), /* @__PURE__ */ React.createElement(
32420
+ "div",
32421
+ {
32422
+ className: "window__resize-handle window__resize-handle--nw",
32423
+ onMouseDown: (e) => handleResizeStart(e, "nw")
32424
+ }
32425
+ ), /* @__PURE__ */ React.createElement(
32426
+ "div",
32427
+ {
32428
+ className: "window__resize-handle window__resize-handle--se",
32429
+ onMouseDown: (e) => handleResizeStart(e, "se")
32430
+ }
32431
+ ), /* @__PURE__ */ React.createElement(
32432
+ "div",
32433
+ {
32434
+ className: "window__resize-handle window__resize-handle--sw",
32435
+ onMouseDown: (e) => handleResizeStart(e, "sw")
32436
+ }
32437
+ ))
32275
32438
  );
32276
32439
  };
32277
32440
  const ApplicationMenu = ({ isOpen, onClose }) => {
32441
+ console.log("ApplicationMenu render - isOpen:", isOpen, "onClose:", onClose);
32278
32442
  const appManager = useAppManager();
32279
32443
  const [searchTerm, setSearchTerm] = useState("");
32280
32444
  const [selectedCategory, setSelectedCategory] = useState("all");
32281
32445
  const [apps, setApps] = useState([]);
32282
32446
  const [categories, setCategories] = useState([]);
32447
+ const [viewMode, setViewMode] = useState("list");
32448
+ const [isCondensed, setIsCondensed] = useState(true);
32283
32449
  const searchInputRef = useRef(null);
32284
32450
  const { createWindow } = useWindows();
32285
32451
  useEffect(() => {
@@ -32341,7 +32507,31 @@ const ApplicationMenu = ({ isOpen, onClose }) => {
32341
32507
  setSearchTerm("");
32342
32508
  };
32343
32509
  if (!isOpen) return null;
32344
- return /* @__PURE__ */ React.createElement("div", { className: "application-menu-overlay", onClick: onClose }, /* @__PURE__ */ React.createElement("div", { className: "application-menu", onClick: (e) => e.stopPropagation() }, /* @__PURE__ */ React.createElement("div", { className: "application-menu__header" }, /* @__PURE__ */ React.createElement("h2", null, "Applications"), /* @__PURE__ */ React.createElement(
32510
+ return /* @__PURE__ */ React.createElement("div", { className: "application-menu-overlay", onClick: onClose }, /* @__PURE__ */ React.createElement("div", { className: `application-menu ${isCondensed ? "application-menu--condensed" : ""}`, onClick: (e) => e.stopPropagation() }, /* @__PURE__ */ React.createElement("div", { className: "application-menu__header" }, /* @__PURE__ */ React.createElement("div", { className: "application-menu__header-controls" }, /* @__PURE__ */ React.createElement(
32511
+ "button",
32512
+ {
32513
+ className: `application-menu__view-toggle ${isCondensed ? "active" : ""}`,
32514
+ onClick: () => setIsCondensed(!isCondensed),
32515
+ title: isCondensed ? "Normal view" : "Condensed view"
32516
+ },
32517
+ "⚏"
32518
+ ), /* @__PURE__ */ React.createElement(
32519
+ "button",
32520
+ {
32521
+ className: `application-menu__view-toggle ${viewMode === "grid" ? "active" : ""}`,
32522
+ onClick: () => setViewMode("grid"),
32523
+ title: "Grid view"
32524
+ },
32525
+ "⊞"
32526
+ ), /* @__PURE__ */ React.createElement(
32527
+ "button",
32528
+ {
32529
+ className: `application-menu__view-toggle ${viewMode === "list" ? "active" : ""}`,
32530
+ onClick: () => setViewMode("list"),
32531
+ title: "List view"
32532
+ },
32533
+ "☰"
32534
+ ), /* @__PURE__ */ React.createElement(
32345
32535
  "button",
32346
32536
  {
32347
32537
  className: "application-menu__close",
@@ -32349,7 +32539,7 @@ const ApplicationMenu = ({ isOpen, onClose }) => {
32349
32539
  title: "Close menu"
32350
32540
  },
32351
32541
  "×"
32352
- )), /* @__PURE__ */ React.createElement("div", { className: "application-menu__search" }, /* @__PURE__ */ React.createElement(
32542
+ ))), /* @__PURE__ */ React.createElement("div", { className: "application-menu__search" }, /* @__PURE__ */ React.createElement(
32353
32543
  "input",
32354
32544
  {
32355
32545
  ref: searchInputRef,
@@ -32359,151 +32549,52 @@ const ApplicationMenu = ({ isOpen, onClose }) => {
32359
32549
  onChange: (e) => setSearchTerm(e.target.value),
32360
32550
  className: "application-menu__search-input"
32361
32551
  }
32362
- )), /* @__PURE__ */ React.createElement("div", { className: "application-menu__categories" }, /* @__PURE__ */ React.createElement(
32552
+ )), /* @__PURE__ */ React.createElement("div", { className: "application-menu__main" }, /* @__PURE__ */ React.createElement("div", { className: "application-menu__sidebar" }, /* @__PURE__ */ React.createElement("div", { className: "application-menu__categories" }, /* @__PURE__ */ React.createElement(
32363
32553
  "button",
32364
32554
  {
32365
32555
  className: `application-menu__category ${selectedCategory === "all" ? "active" : ""}`,
32366
- onClick: () => handleCategorySelect("all")
32556
+ onClick: () => handleCategorySelect("all"),
32557
+ title: "All Apps"
32367
32558
  },
32368
32559
  /* @__PURE__ */ React.createElement("span", { className: "category-icon" }, "📱"),
32369
- "All Apps"
32560
+ /* @__PURE__ */ React.createElement("span", { className: "category-name" }, "All Apps")
32370
32561
  ), categories.map((category) => /* @__PURE__ */ React.createElement(
32371
32562
  "button",
32372
32563
  {
32373
32564
  key: category.id,
32374
32565
  className: `application-menu__category ${selectedCategory === category.id ? "active" : ""}`,
32375
- onClick: () => handleCategorySelect(category.id)
32566
+ onClick: () => handleCategorySelect(category.id),
32567
+ title: category.name
32376
32568
  },
32377
32569
  /* @__PURE__ */ React.createElement("span", { className: "category-icon" }, category.icon),
32378
- category.name
32379
- ))), /* @__PURE__ */ React.createElement("div", { className: "application-menu__content" }, searchTerm && /* @__PURE__ */ React.createElement("div", { className: "application-menu__search-results" }, /* @__PURE__ */ React.createElement("h3", null, "Search Results (", filteredApps.length, ")"), /* @__PURE__ */ React.createElement("div", { className: "application-menu__apps-grid" }, filteredApps.map((app) => /* @__PURE__ */ React.createElement(
32570
+ /* @__PURE__ */ React.createElement("span", { className: "category-name" }, category.name)
32571
+ )))), /* @__PURE__ */ React.createElement("div", { className: "application-menu__content" }, searchTerm && /* @__PURE__ */ React.createElement("div", { className: "application-menu__search-results" }, /* @__PURE__ */ React.createElement("h3", null, "Search Results (", filteredApps.length, ")"), /* @__PURE__ */ React.createElement("div", { className: `application-menu__apps-${viewMode}` }, filteredApps.map((app) => /* @__PURE__ */ React.createElement(
32380
32572
  "div",
32381
32573
  {
32382
32574
  key: app.id,
32383
- className: "application-menu__app",
32575
+ className: `application-menu__app--${viewMode}`,
32384
32576
  onClick: () => handleLaunchApp(app),
32385
32577
  title: app.description
32386
32578
  },
32387
32579
  /* @__PURE__ */ React.createElement("div", { className: "app-icon" }, app.icon),
32388
- /* @__PURE__ */ React.createElement("div", { className: "app-name" }, app.name)
32389
- )))), !searchTerm && /* @__PURE__ */ React.createElement("div", { className: "application-menu__categories-content" }, Object.entries(groupedApps).map(([categoryName, categoryApps]) => /* @__PURE__ */ React.createElement("div", { key: categoryName, className: "application-menu__category-section" }, /* @__PURE__ */ React.createElement("h3", { className: "category-title" }, categoryName), /* @__PURE__ */ React.createElement("div", { className: "application-menu__apps-grid" }, categoryApps.map((app) => /* @__PURE__ */ React.createElement(
32580
+ viewMode === "list" ? /* @__PURE__ */ React.createElement("div", { className: "app-info" }, /* @__PURE__ */ React.createElement("div", { className: "app-name" }, app.name), /* @__PURE__ */ React.createElement("div", { className: "app-description" }, app.description)) : /* @__PURE__ */ React.createElement("div", { className: "app-name" }, app.name)
32581
+ )))), !searchTerm && /* @__PURE__ */ React.createElement("div", { className: "application-menu__categories-content" }, Object.entries(groupedApps).map(([categoryName, categoryApps]) => /* @__PURE__ */ React.createElement("div", { key: categoryName, className: "application-menu__category-section" }, /* @__PURE__ */ React.createElement("h3", { className: "category-title" }, categoryName), /* @__PURE__ */ React.createElement("div", { className: `application-menu__apps-${viewMode}` }, categoryApps.map((app) => /* @__PURE__ */ React.createElement(
32390
32582
  "div",
32391
32583
  {
32392
32584
  key: app.id,
32393
- className: "application-menu__app",
32585
+ className: `application-menu__app--${viewMode}`,
32394
32586
  onClick: () => handleLaunchApp(app),
32395
32587
  title: app.description
32396
32588
  },
32397
32589
  /* @__PURE__ */ React.createElement("div", { className: "app-icon" }, app.icon),
32398
- /* @__PURE__ */ React.createElement("div", { className: "app-name" }, app.name)
32399
- )))))), filteredApps.length === 0 && /* @__PURE__ */ React.createElement("div", { className: "application-menu__no-results" }, /* @__PURE__ */ React.createElement("div", { style: { fontSize: "48px", marginBottom: "16px" } }, "🔍"), /* @__PURE__ */ React.createElement("h3", null, "No applications found"), /* @__PURE__ */ React.createElement("p", null, "Try adjusting your search or category filter.")))));
32590
+ viewMode === "list" ? /* @__PURE__ */ React.createElement("div", { className: "app-info" }, /* @__PURE__ */ React.createElement("div", { className: "app-name" }, app.name), /* @__PURE__ */ React.createElement("div", { className: "app-description" }, app.description)) : /* @__PURE__ */ React.createElement("div", { className: "app-name" }, app.name)
32591
+ )))))), filteredApps.length === 0 && /* @__PURE__ */ React.createElement("div", { className: "application-menu__no-results" }, /* @__PURE__ */ React.createElement("div", { style: { fontSize: "48px", marginBottom: "16px" } }, "🔍"), /* @__PURE__ */ React.createElement("h3", null, "No applications found"), /* @__PURE__ */ React.createElement("p", null, "Try adjusting your search or category filter."))))));
32400
32592
  };
32401
32593
  class AppManager {
32402
32594
  constructor() {
32403
32595
  this.applications = /* @__PURE__ */ new Map();
32404
32596
  this.categories = /* @__PURE__ */ new Map();
32405
32597
  this.listeners = /* @__PURE__ */ new Set();
32406
- this.initializeDefaultApps();
32407
- }
32408
- /**
32409
- * Initialize default applications
32410
- */
32411
- initializeDefaultApps() {
32412
- this.registerApp({
32413
- id: "file-explorer",
32414
- name: "File Explorer",
32415
- description: "Browse and manage files",
32416
- icon: "📁",
32417
- category: "System",
32418
- component: null,
32419
- // Will be set when registering actual components
32420
- size: { width: 600, height: 400 },
32421
- toolbar: null,
32422
- statusBar: null
32423
- });
32424
- this.registerApp({
32425
- id: "text-editor",
32426
- name: "Text Editor",
32427
- description: "Edit text files",
32428
- icon: "📝",
32429
- category: "Productivity",
32430
- component: null,
32431
- size: { width: 500, height: 350 },
32432
- toolbar: null,
32433
- statusBar: null
32434
- });
32435
- this.registerApp({
32436
- id: "calculator",
32437
- name: "Calculator",
32438
- description: "Perform calculations",
32439
- icon: "🧮",
32440
- category: "Utilities",
32441
- component: null,
32442
- size: { width: 300, height: 400 }
32443
- });
32444
- this.registerApp({
32445
- id: "settings",
32446
- name: "Settings",
32447
- description: "System configuration",
32448
- icon: "⚙️",
32449
- category: "System",
32450
- component: null,
32451
- size: { width: 450, height: 300 }
32452
- });
32453
- this.registerApp({
32454
- id: "browser",
32455
- name: "Web Browser",
32456
- description: "Browse the internet",
32457
- icon: "🌐",
32458
- category: "Internet",
32459
- component: null,
32460
- size: { width: 800, height: 500 }
32461
- });
32462
- this.registerApp({
32463
- id: "terminal",
32464
- name: "Terminal",
32465
- description: "Command line interface",
32466
- icon: "💻",
32467
- category: "Development",
32468
- component: null,
32469
- size: { width: 700, height: 400 }
32470
- });
32471
- this.registerApp({
32472
- id: "image-viewer",
32473
- name: "Image Viewer",
32474
- description: "View and edit images",
32475
- icon: "🖼️",
32476
- category: "Media",
32477
- component: null,
32478
- size: { width: 600, height: 500 }
32479
- });
32480
- this.registerApp({
32481
- id: "music-player",
32482
- name: "Music Player",
32483
- description: "Play audio files",
32484
- icon: "🎵",
32485
- category: "Media",
32486
- component: null,
32487
- size: { width: 400, height: 300 }
32488
- });
32489
- this.initializeCategories();
32490
- }
32491
- /**
32492
- * Initialize application categories
32493
- */
32494
- initializeCategories() {
32495
- const categoryData = [
32496
- { id: "system", name: "System", icon: "⚙️", color: "#607d8b" },
32497
- { id: "productivity", name: "Productivity", icon: "📊", color: "#2196f3" },
32498
- { id: "utilities", name: "Utilities", icon: "🔧", color: "#ff9800" },
32499
- { id: "internet", name: "Internet", icon: "🌐", color: "#4caf50" },
32500
- { id: "development", name: "Development", icon: "💻", color: "#9c27b0" },
32501
- { id: "media", name: "Media", icon: "🎬", color: "#e91e63" },
32502
- { id: "games", name: "Games", icon: "🎮", color: "#f44336" }
32503
- ];
32504
- categoryData.forEach((category) => {
32505
- this.categories.set(category.id, category);
32506
- });
32507
32598
  }
32508
32599
  /**
32509
32600
  * Register a new application
@@ -32623,6 +32714,160 @@ class AppManager {
32623
32714
  return grouped;
32624
32715
  }
32625
32716
  }
32717
+ class AppLoader {
32718
+ /**
32719
+ * Load configuration into AppManager
32720
+ * @param {AppManager} appManager - The AppManager instance
32721
+ * @param {Object} config - JSON configuration object
32722
+ * @param {Array} config.categories - Array of category definitions
32723
+ * @param {Array} config.applications - Array of application definitions
32724
+ */
32725
+ static load(appManager, config) {
32726
+ if (!config) {
32727
+ console.warn("AppLoader: No configuration provided");
32728
+ return;
32729
+ }
32730
+ if (config.categories && Array.isArray(config.categories)) {
32731
+ this.loadCategories(appManager, config.categories);
32732
+ }
32733
+ if (config.applications && Array.isArray(config.applications)) {
32734
+ this.loadApplications(appManager, config.applications);
32735
+ }
32736
+ }
32737
+ /**
32738
+ * Load categories from configuration
32739
+ * @param {AppManager} appManager - The AppManager instance
32740
+ * @param {Array} categories - Array of category definitions
32741
+ */
32742
+ static loadCategories(appManager, categories) {
32743
+ categories.forEach((category) => {
32744
+ if (this.validateCategory(category)) {
32745
+ appManager.categories.set(category.id, category);
32746
+ } else {
32747
+ console.warn("AppLoader: Invalid category configuration:", category);
32748
+ }
32749
+ });
32750
+ }
32751
+ /**
32752
+ * Load applications from configuration
32753
+ * @param {AppManager} appManager - The AppManager instance
32754
+ * @param {Array} applications - Array of application definitions
32755
+ */
32756
+ static loadApplications(appManager, applications) {
32757
+ applications.forEach((app) => {
32758
+ if (this.validateApplication(app)) {
32759
+ appManager.registerApp(app);
32760
+ } else {
32761
+ console.warn("AppLoader: Invalid application configuration:", app);
32762
+ }
32763
+ });
32764
+ }
32765
+ /**
32766
+ * Validate category configuration
32767
+ * @param {Object} category - Category definition
32768
+ * @returns {boolean} - True if valid
32769
+ */
32770
+ static validateCategory(category) {
32771
+ return category && typeof category.id === "string" && typeof category.name === "string" && category.id.length > 0 && category.name.length > 0;
32772
+ }
32773
+ /**
32774
+ * Validate application configuration
32775
+ * @param {Object} app - Application definition
32776
+ * @returns {boolean} - True if valid
32777
+ */
32778
+ static validateApplication(app) {
32779
+ return app && typeof app.id === "string" && typeof app.name === "string" && app.id.length > 0 && app.name.length > 0;
32780
+ }
32781
+ }
32782
+ const defaultDesktopConfig = {
32783
+ categories: [
32784
+ { id: "system", name: "System", icon: "⚙️", color: "#607d8b" },
32785
+ { id: "productivity", name: "Productivity", icon: "📊", color: "#2196f3" },
32786
+ { id: "utilities", name: "Utilities", icon: "🔧", color: "#ff9800" },
32787
+ { id: "internet", name: "Internet", icon: "🌐", color: "#4caf50" },
32788
+ { id: "development", name: "Development", icon: "💻", color: "#9c27b0" },
32789
+ { id: "media", name: "Media", icon: "🎬", color: "#e91e63" },
32790
+ { id: "games", name: "Games", icon: "🎮", color: "#f44336" }
32791
+ ],
32792
+ applications: [
32793
+ {
32794
+ id: "file-explorer",
32795
+ name: "File Explorer",
32796
+ description: "Browse and manage files",
32797
+ icon: "📁",
32798
+ category: "System",
32799
+ component: null,
32800
+ size: { width: 600, height: 400 },
32801
+ toolbar: null,
32802
+ statusBar: null
32803
+ },
32804
+ {
32805
+ id: "text-editor",
32806
+ name: "Text Editor",
32807
+ description: "Edit text files",
32808
+ icon: "📝",
32809
+ category: "Productivity",
32810
+ component: null,
32811
+ size: { width: 500, height: 350 },
32812
+ toolbar: null,
32813
+ statusBar: null
32814
+ },
32815
+ {
32816
+ id: "calculator",
32817
+ name: "Calculator",
32818
+ description: "Perform calculations",
32819
+ icon: "🧮",
32820
+ category: "Utilities",
32821
+ component: null,
32822
+ size: { width: 300, height: 400 }
32823
+ },
32824
+ {
32825
+ id: "settings",
32826
+ name: "Settings",
32827
+ description: "System configuration",
32828
+ icon: "⚙️",
32829
+ category: "System",
32830
+ component: null,
32831
+ size: { width: 450, height: 300 }
32832
+ },
32833
+ {
32834
+ id: "browser",
32835
+ name: "Web Browser",
32836
+ description: "Browse the internet",
32837
+ icon: "🌐",
32838
+ category: "Internet",
32839
+ component: null,
32840
+ size: { width: 800, height: 500 }
32841
+ },
32842
+ {
32843
+ id: "terminal",
32844
+ name: "Terminal",
32845
+ description: "Command line interface",
32846
+ icon: "💻",
32847
+ category: "Development",
32848
+ component: null,
32849
+ size: { width: 700, height: 400 }
32850
+ },
32851
+ {
32852
+ id: "image-viewer",
32853
+ name: "Image Viewer",
32854
+ description: "View and edit images",
32855
+ icon: "🖼️",
32856
+ category: "Media",
32857
+ component: null,
32858
+ size: { width: 600, height: 500 }
32859
+ },
32860
+ {
32861
+ id: "music-player",
32862
+ name: "Music Player",
32863
+ description: "Play audio files",
32864
+ icon: "🎵",
32865
+ category: "Media",
32866
+ component: null,
32867
+ size: { width: 400, height: 300 }
32868
+ }
32869
+ ]
32870
+ };
32626
32871
  const defaultAppManager = new AppManager();
32627
32872
  const AppContext = createContext();
32628
32873
  const useApplicationMenu = () => {
@@ -32639,8 +32884,17 @@ const useAppManager = () => {
32639
32884
  }
32640
32885
  return context.appManager;
32641
32886
  };
32642
- const AppProvider = ({ children, appManager = defaultAppManager }) => {
32887
+ const AppProvider = ({
32888
+ children,
32889
+ desktopConfig = defaultDesktopConfig
32890
+ }) => {
32891
+ const appManager = new AppManager();
32643
32892
  const [isApplicationMenuOpen, setIsApplicationMenuOpen] = useState(false);
32893
+ useEffect(() => {
32894
+ if (appManager.getAllApps().length === 0 && desktopConfig) {
32895
+ AppLoader.load(appManager, desktopConfig);
32896
+ }
32897
+ }, [appManager, desktopConfig]);
32644
32898
  const value = {
32645
32899
  // Application Menu state
32646
32900
  applicationMenu: {
@@ -32654,14 +32908,14 @@ const AppProvider = ({ children, appManager = defaultAppManager }) => {
32654
32908
  };
32655
32909
  return /* @__PURE__ */ React.createElement(AppContext.Provider, { value }, children);
32656
32910
  };
32657
- const DesktopLayout = ({ children, className = "", theme = "windows", ...props }) => {
32911
+ const DesktopLayout = ({ children, className = "", theme = "windows", workspaceRef, ...props }) => {
32658
32912
  const desktopRef = useRef(null);
32659
32913
  const { windowManager } = useWindows();
32660
32914
  useEffect(() => {
32661
- let currentSize = { width: 1200, height: 800 };
32662
- const measureDesktop = () => {
32663
- if (desktopRef.current) {
32664
- const rect = desktopRef.current.getBoundingClientRect();
32915
+ let currentSize = { width: 1200, height: 750 };
32916
+ const measureWorkspace = () => {
32917
+ if (workspaceRef.current) {
32918
+ const rect = workspaceRef.current.getBoundingClientRect();
32665
32919
  const newSize = {
32666
32920
  width: rect.width,
32667
32921
  height: rect.height
@@ -32672,10 +32926,10 @@ const DesktopLayout = ({ children, className = "", theme = "windows", ...props }
32672
32926
  }
32673
32927
  }
32674
32928
  };
32675
- measureDesktop();
32676
- const resizeObserver = new ResizeObserver(measureDesktop);
32677
- if (desktopRef.current) {
32678
- resizeObserver.observe(desktopRef.current);
32929
+ measureWorkspace();
32930
+ const resizeObserver = new ResizeObserver(measureWorkspace);
32931
+ if (workspaceRef.current) {
32932
+ resizeObserver.observe(workspaceRef.current);
32679
32933
  }
32680
32934
  return () => {
32681
32935
  resizeObserver.disconnect();
@@ -32700,7 +32954,7 @@ const DesktopLayout = ({ children, className = "", theme = "windows", ...props }
32700
32954
  };
32701
32955
  const Workspace = ({ children }) => {
32702
32956
  const { windows } = useWindows();
32703
- return /* @__PURE__ */ React.createElement(React.Fragment, null, children, windows.map((window2) => /* @__PURE__ */ React.createElement(
32957
+ return /* @__PURE__ */ React.createElement("div", { className: "workspace" }, children, windows.map((window2) => /* @__PURE__ */ React.createElement(
32704
32958
  Window,
32705
32959
  {
32706
32960
  key: window2.id,
@@ -32714,6 +32968,9 @@ const Workspace = ({ children }) => {
32714
32968
  )));
32715
32969
  };
32716
32970
  const DesktopTaskbar = () => {
32971
+ console.log("DesktopTaskbar render");
32972
+ const windowsContext = useWindows();
32973
+ console.log("useWindows result:", windowsContext);
32717
32974
  const {
32718
32975
  createWindow,
32719
32976
  windows,
@@ -32721,26 +32978,14 @@ const DesktopTaskbar = () => {
32721
32978
  activeWindowId,
32722
32979
  focusWindow,
32723
32980
  minimizeWindow,
32724
- closeWindow
32725
- } = useWindows();
32726
- const { open: openApplicationMenu } = useApplicationMenu();
32727
- const handleCreateWindow = () => {
32728
- const windowTypes = [
32729
- { title: "File Explorer", icon: "📁", size: { width: 600, height: 400 } },
32730
- { title: "Text Editor", icon: "📝", size: { width: 500, height: 350 } },
32731
- { title: "Calculator", icon: "🧮", size: { width: 300, height: 400 } },
32732
- { title: "Settings", icon: "⚙️", size: { width: 450, height: 300 } },
32733
- { title: "Browser", icon: "🌐", size: { width: 800, height: 500 } }
32734
- ];
32735
- const randomType = windowTypes[Math.floor(Math.random() * windowTypes.length)];
32736
- createWindow({
32737
- title: randomType.title,
32738
- icon: randomType.icon,
32739
- size: randomType.size,
32740
- toolbar: randomType.title === "Text Editor" ? /* @__PURE__ */ React.createElement("div", { style: { display: "flex", gap: "8px" } }, /* @__PURE__ */ React.createElement("button", { style: { padding: "4px 8px", fontSize: "12px" } }, "File"), /* @__PURE__ */ React.createElement("button", { style: { padding: "4px 8px", fontSize: "12px" } }, "Edit"), /* @__PURE__ */ React.createElement("button", { style: { padding: "4px 8px", fontSize: "12px" } }, "View")) : null,
32741
- statusBar: randomType.title === "Text Editor" ? /* @__PURE__ */ React.createElement("span", null, "Ready | Line 1, Column 1") : null
32742
- });
32743
- };
32981
+ closeWindow,
32982
+ cascadeWindows,
32983
+ tileWindows,
32984
+ centerAllWindows,
32985
+ clearAllWindows
32986
+ } = windowsContext;
32987
+ const { isOpen, toggle } = useApplicationMenu();
32988
+ console.log("DesktopTaskbar - isOpen:", isOpen, "toggle:", toggle);
32744
32989
  const handleWindowClick = (window2) => {
32745
32990
  if (window2.minimized) {
32746
32991
  minimizeWindow(window2.id, false);
@@ -32763,11 +33008,7 @@ const DesktopTaskbar = () => {
32763
33008
  closeWindow(window2.id);
32764
33009
  }
32765
33010
  };
32766
- return /* @__PURE__ */ React.createElement("div", { style: {
32767
- position: "absolute",
32768
- bottom: 0,
32769
- left: 0,
32770
- right: 0,
33011
+ return /* @__PURE__ */ React.createElement("div", { className: "desktop-taskbar", style: {
32771
33012
  height: "50px",
32772
33013
  background: "rgba(0,0,0,0.8)",
32773
33014
  display: "flex",
@@ -32775,44 +33016,16 @@ const DesktopTaskbar = () => {
32775
33016
  padding: "0 16px",
32776
33017
  gap: "8px"
32777
33018
  } }, /* @__PURE__ */ React.createElement(
32778
- "button",
33019
+ ToggleButton,
32779
33020
  {
32780
- onClick: openApplicationMenu,
32781
- style: {
32782
- padding: "8px 16px",
32783
- background: "#1976d2",
32784
- color: "white",
32785
- border: "none",
32786
- borderRadius: "4px",
32787
- cursor: "pointer",
32788
- fontSize: "14px",
32789
- fontWeight: "bold",
32790
- flexShrink: 0,
32791
- display: "flex",
32792
- alignItems: "center",
32793
- gap: "6px"
33021
+ checked: isOpen,
33022
+ onToggle: () => {
33023
+ console.log("Start button toggled, current state:", isOpen);
33024
+ toggle();
32794
33025
  },
32795
- title: "Open application menu"
32796
- },
32797
- /* @__PURE__ */ React.createElement("span", { style: { fontSize: "16px" } }, "🚀"),
32798
- "Start"
32799
- ), /* @__PURE__ */ React.createElement(
32800
- "button",
32801
- {
32802
- onClick: handleCreateWindow,
32803
- style: {
32804
- padding: "8px 12px",
32805
- background: "#666",
32806
- color: "white",
32807
- border: "none",
32808
- borderRadius: "4px",
32809
- cursor: "pointer",
32810
- fontSize: "12px",
32811
- flexShrink: 0
32812
- },
32813
- title: "Create random window (for testing)"
32814
- },
32815
- "+"
33026
+ icon: "start",
33027
+ label: "Start"
33028
+ }
32816
33029
  ), /* @__PURE__ */ React.createElement("div", { style: {
32817
33030
  width: "1px",
32818
33031
  height: "30px",
@@ -32873,6 +33086,60 @@ Middle click: Close`
32873
33086
  borderRadius: "1px"
32874
33087
  } })
32875
33088
  ))), /* @__PURE__ */ React.createElement("div", { style: {
33089
+ display: "flex",
33090
+ gap: "4px",
33091
+ alignItems: "center",
33092
+ marginLeft: "auto",
33093
+ marginRight: "8px"
33094
+ } }, /* @__PURE__ */ React.createElement(
33095
+ Icon,
33096
+ {
33097
+ clickable: true,
33098
+ size: "small",
33099
+ action: () => {
33100
+ console.log("Cascade windows clicked!");
33101
+ cascadeWindows();
33102
+ },
33103
+ icon: "view_stream",
33104
+ label: "Cascade"
33105
+ }
33106
+ ), /* @__PURE__ */ React.createElement(
33107
+ Icon,
33108
+ {
33109
+ clickable: true,
33110
+ size: "small",
33111
+ action: () => {
33112
+ console.log("Tile windows clicked!");
33113
+ tileWindows();
33114
+ },
33115
+ icon: "view_module",
33116
+ label: "Tile"
33117
+ }
33118
+ ), /* @__PURE__ */ React.createElement(
33119
+ Icon,
33120
+ {
33121
+ clickable: true,
33122
+ size: "small",
33123
+ action: () => {
33124
+ console.log("Center all windows clicked!");
33125
+ centerAllWindows();
33126
+ },
33127
+ icon: "center_focus_strong",
33128
+ label: "Center"
33129
+ }
33130
+ ), /* @__PURE__ */ React.createElement(
33131
+ Icon,
33132
+ {
33133
+ clickable: true,
33134
+ size: "small",
33135
+ action: () => {
33136
+ console.log("Clear all windows clicked!");
33137
+ clearAllWindows();
33138
+ },
33139
+ icon: "clear_all",
33140
+ label: "Clear"
33141
+ }
33142
+ )), /* @__PURE__ */ React.createElement("div", { style: {
32876
33143
  color: "rgba(255,255,255,0.7)",
32877
33144
  fontSize: "11px",
32878
33145
  fontFamily: "monospace",
@@ -32882,16 +33149,28 @@ Middle click: Close`
32882
33149
  };
32883
33150
  const DesktopInternal = ({ desktopSize, children, ...props }) => {
32884
33151
  const { isOpen, close } = useApplicationMenu();
32885
- return /* @__PURE__ */ React.createElement(WindowProvider, { desktopSize }, /* @__PURE__ */ React.createElement(DesktopLayout, { ...props }, /* @__PURE__ */ React.createElement(Workspace, null, children), /* @__PURE__ */ React.createElement(DesktopTaskbar, null), /* @__PURE__ */ React.createElement(
33152
+ const workspaceRef = useRef(null);
33153
+ return /* @__PURE__ */ React.createElement(WindowProvider, { desktopSize }, /* @__PURE__ */ React.createElement(DesktopLayout, { workspaceRef, ...props }, /* @__PURE__ */ React.createElement("div", { ref: workspaceRef, className: "desktop__workspace-container" }, /* @__PURE__ */ React.createElement(Workspace, null, children), /* @__PURE__ */ React.createElement(
32886
33154
  ApplicationMenu,
32887
33155
  {
32888
33156
  isOpen,
32889
33157
  onClose: close
32890
33158
  }
32891
- )));
33159
+ )), /* @__PURE__ */ React.createElement(DesktopTaskbar, null)));
32892
33160
  };
32893
- const Desktop = ({ desktopSize, children, ...props }) => {
32894
- return /* @__PURE__ */ React.createElement(AppProvider, null, /* @__PURE__ */ React.createElement(DesktopInternal, { desktopSize, ...props }, children));
33161
+ const Desktop = ({
33162
+ desktopSize,
33163
+ children,
33164
+ desktopConfig,
33165
+ ...props
33166
+ }) => {
33167
+ return /* @__PURE__ */ React.createElement(
33168
+ AppProvider,
33169
+ {
33170
+ desktopConfig
33171
+ },
33172
+ /* @__PURE__ */ React.createElement(DesktopInternal, { desktopSize, ...props }, children)
33173
+ );
32895
33174
  };
32896
33175
  const ContentForm = ({ content, columns = 1, filter: filter2, rules, onChange }) => {
32897
33176
  const form = content.form();