ywana-core8 0.2.8 → 0.2.10

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
@@ -32446,6 +32446,8 @@ const ApplicationMenu = ({ isOpen, onClose }) => {
32446
32446
  const [selectedCategory, setSelectedCategory] = React.useState("all");
32447
32447
  const [apps, setApps] = React.useState([]);
32448
32448
  const [categories, setCategories] = React.useState([]);
32449
+ const [viewMode, setViewMode] = React.useState("list");
32450
+ const [isCondensed, setIsCondensed] = React.useState(true);
32449
32451
  const searchInputRef = React.useRef(null);
32450
32452
  const { createWindow } = useWindows();
32451
32453
  React.useEffect(() => {
@@ -32507,7 +32509,31 @@ const ApplicationMenu = ({ isOpen, onClose }) => {
32507
32509
  setSearchTerm("");
32508
32510
  };
32509
32511
  if (!isOpen) return null;
32510
- 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(
32511
32537
  "button",
32512
32538
  {
32513
32539
  className: "application-menu__close",
@@ -32515,7 +32541,7 @@ const ApplicationMenu = ({ isOpen, onClose }) => {
32515
32541
  title: "Close menu"
32516
32542
  },
32517
32543
  "×"
32518
- )), /* @__PURE__ */ React.createElement("div", { className: "application-menu__search" }, /* @__PURE__ */ React.createElement(
32544
+ ))), /* @__PURE__ */ React.createElement("div", { className: "application-menu__search" }, /* @__PURE__ */ React.createElement(
32519
32545
  "input",
32520
32546
  {
32521
32547
  ref: searchInputRef,
@@ -32529,7 +32555,8 @@ const ApplicationMenu = ({ isOpen, onClose }) => {
32529
32555
  "button",
32530
32556
  {
32531
32557
  className: `application-menu__category ${selectedCategory === "all" ? "active" : ""}`,
32532
- onClick: () => handleCategorySelect("all")
32558
+ onClick: () => handleCategorySelect("all"),
32559
+ title: "All Apps"
32533
32560
  },
32534
32561
  /* @__PURE__ */ React.createElement("span", { className: "category-icon" }, "📱"),
32535
32562
  /* @__PURE__ */ React.createElement("span", { className: "category-name" }, "All Apps")
@@ -32538,30 +32565,31 @@ const ApplicationMenu = ({ isOpen, onClose }) => {
32538
32565
  {
32539
32566
  key: category.id,
32540
32567
  className: `application-menu__category ${selectedCategory === category.id ? "active" : ""}`,
32541
- onClick: () => handleCategorySelect(category.id)
32568
+ onClick: () => handleCategorySelect(category.id),
32569
+ title: category.name
32542
32570
  },
32543
32571
  /* @__PURE__ */ React.createElement("span", { className: "category-icon" }, category.icon),
32544
32572
  /* @__PURE__ */ React.createElement("span", { className: "category-name" }, category.name)
32545
- )))), /* @__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(
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(
32546
32574
  "div",
32547
32575
  {
32548
32576
  key: app.id,
32549
- className: "application-menu__app",
32577
+ className: `application-menu__app--${viewMode}`,
32550
32578
  onClick: () => handleLaunchApp(app),
32551
32579
  title: app.description
32552
32580
  },
32553
32581
  /* @__PURE__ */ React.createElement("div", { className: "app-icon" }, app.icon),
32554
- /* @__PURE__ */ React.createElement("div", { className: "app-name" }, app.name)
32555
- )))), !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(
32556
32584
  "div",
32557
32585
  {
32558
32586
  key: app.id,
32559
- className: "application-menu__app",
32587
+ className: `application-menu__app--${viewMode}`,
32560
32588
  onClick: () => handleLaunchApp(app),
32561
32589
  title: app.description
32562
32590
  },
32563
32591
  /* @__PURE__ */ React.createElement("div", { className: "app-icon" }, app.icon),
32564
- /* @__PURE__ */ React.createElement("div", { className: "app-name" }, app.name)
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)
32565
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."))))));
32566
32594
  };
32567
32595
  class AppManager {
@@ -32569,107 +32597,6 @@ class AppManager {
32569
32597
  this.applications = /* @__PURE__ */ new Map();
32570
32598
  this.categories = /* @__PURE__ */ new Map();
32571
32599
  this.listeners = /* @__PURE__ */ new Set();
32572
- this.initializeDefaultApps();
32573
- }
32574
- /**
32575
- * Initialize default applications
32576
- */
32577
- initializeDefaultApps() {
32578
- this.registerApp({
32579
- id: "file-explorer",
32580
- name: "File Explorer",
32581
- description: "Browse and manage files",
32582
- icon: "📁",
32583
- category: "System",
32584
- component: null,
32585
- // Will be set when registering actual components
32586
- size: { width: 600, height: 400 },
32587
- toolbar: null,
32588
- statusBar: null
32589
- });
32590
- this.registerApp({
32591
- id: "text-editor",
32592
- name: "Text Editor",
32593
- description: "Edit text files",
32594
- icon: "📝",
32595
- category: "Productivity",
32596
- component: null,
32597
- size: { width: 500, height: 350 },
32598
- toolbar: null,
32599
- statusBar: null
32600
- });
32601
- this.registerApp({
32602
- id: "calculator",
32603
- name: "Calculator",
32604
- description: "Perform calculations",
32605
- icon: "🧮",
32606
- category: "Utilities",
32607
- component: null,
32608
- size: { width: 300, height: 400 }
32609
- });
32610
- this.registerApp({
32611
- id: "settings",
32612
- name: "Settings",
32613
- description: "System configuration",
32614
- icon: "⚙️",
32615
- category: "System",
32616
- component: null,
32617
- size: { width: 450, height: 300 }
32618
- });
32619
- this.registerApp({
32620
- id: "browser",
32621
- name: "Web Browser",
32622
- description: "Browse the internet",
32623
- icon: "🌐",
32624
- category: "Internet",
32625
- component: null,
32626
- size: { width: 800, height: 500 }
32627
- });
32628
- this.registerApp({
32629
- id: "terminal",
32630
- name: "Terminal",
32631
- description: "Command line interface",
32632
- icon: "💻",
32633
- category: "Development",
32634
- component: null,
32635
- size: { width: 700, height: 400 }
32636
- });
32637
- this.registerApp({
32638
- id: "image-viewer",
32639
- name: "Image Viewer",
32640
- description: "View and edit images",
32641
- icon: "🖼️",
32642
- category: "Media",
32643
- component: null,
32644
- size: { width: 600, height: 500 }
32645
- });
32646
- this.registerApp({
32647
- id: "music-player",
32648
- name: "Music Player",
32649
- description: "Play audio files",
32650
- icon: "🎵",
32651
- category: "Media",
32652
- component: null,
32653
- size: { width: 400, height: 300 }
32654
- });
32655
- this.initializeCategories();
32656
- }
32657
- /**
32658
- * Initialize application categories
32659
- */
32660
- initializeCategories() {
32661
- const categoryData = [
32662
- { id: "system", name: "System", icon: "⚙️", color: "#607d8b" },
32663
- { id: "productivity", name: "Productivity", icon: "📊", color: "#2196f3" },
32664
- { id: "utilities", name: "Utilities", icon: "🔧", color: "#ff9800" },
32665
- { id: "internet", name: "Internet", icon: "🌐", color: "#4caf50" },
32666
- { id: "development", name: "Development", icon: "💻", color: "#9c27b0" },
32667
- { id: "media", name: "Media", icon: "🎬", color: "#e91e63" },
32668
- { id: "games", name: "Games", icon: "🎮", color: "#f44336" }
32669
- ];
32670
- categoryData.forEach((category) => {
32671
- this.categories.set(category.id, category);
32672
- });
32673
32600
  }
32674
32601
  /**
32675
32602
  * Register a new application
@@ -32789,6 +32716,160 @@ class AppManager {
32789
32716
  return grouped;
32790
32717
  }
32791
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
+ };
32792
32873
  const defaultAppManager = new AppManager();
32793
32874
  const AppContext = React.createContext();
32794
32875
  const useApplicationMenu = () => {
@@ -32805,8 +32886,17 @@ const useAppManager = () => {
32805
32886
  }
32806
32887
  return context.appManager;
32807
32888
  };
32808
- const AppProvider = ({ children, appManager = defaultAppManager }) => {
32889
+ const AppProvider = ({
32890
+ children,
32891
+ desktopConfig = defaultDesktopConfig
32892
+ }) => {
32893
+ const appManager = new AppManager();
32809
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]);
32810
32900
  const value = {
32811
32901
  // Application Menu state
32812
32902
  applicationMenu: {
@@ -33070,8 +33160,19 @@ const DesktopInternal = ({ desktopSize, children, ...props }) => {
33070
33160
  }
33071
33161
  )), /* @__PURE__ */ React.createElement(DesktopTaskbar, null)));
33072
33162
  };
33073
- const Desktop = ({ desktopSize, children, ...props }) => {
33074
- 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
+ );
33075
33176
  };
33076
33177
  const ContentForm = ({ content, columns = 1, filter: filter2, rules, onChange }) => {
33077
33178
  const form = content.form();