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