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.umd.js CHANGED
@@ -32447,6 +32447,8 @@ const rows = [
32447
32447
  const [selectedCategory, setSelectedCategory] = React.useState("all");
32448
32448
  const [apps, setApps] = React.useState([]);
32449
32449
  const [categories, setCategories] = React.useState([]);
32450
+ const [viewMode, setViewMode] = React.useState("list");
32451
+ const [isCondensed, setIsCondensed] = React.useState(true);
32450
32452
  const searchInputRef = React.useRef(null);
32451
32453
  const { createWindow } = useWindows();
32452
32454
  React.useEffect(() => {
@@ -32508,7 +32510,31 @@ const rows = [
32508
32510
  setSearchTerm("");
32509
32511
  };
32510
32512
  if (!isOpen) return null;
32511
- 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(
32513
+ 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(
32514
+ "button",
32515
+ {
32516
+ className: `application-menu__view-toggle ${isCondensed ? "active" : ""}`,
32517
+ onClick: () => setIsCondensed(!isCondensed),
32518
+ title: isCondensed ? "Normal view" : "Condensed view"
32519
+ },
32520
+ "⚏"
32521
+ ), /* @__PURE__ */ React.createElement(
32522
+ "button",
32523
+ {
32524
+ className: `application-menu__view-toggle ${viewMode === "grid" ? "active" : ""}`,
32525
+ onClick: () => setViewMode("grid"),
32526
+ title: "Grid view"
32527
+ },
32528
+ "⊞"
32529
+ ), /* @__PURE__ */ React.createElement(
32530
+ "button",
32531
+ {
32532
+ className: `application-menu__view-toggle ${viewMode === "list" ? "active" : ""}`,
32533
+ onClick: () => setViewMode("list"),
32534
+ title: "List view"
32535
+ },
32536
+ "☰"
32537
+ ), /* @__PURE__ */ React.createElement(
32512
32538
  "button",
32513
32539
  {
32514
32540
  className: "application-menu__close",
@@ -32516,7 +32542,7 @@ const rows = [
32516
32542
  title: "Close menu"
32517
32543
  },
32518
32544
  "×"
32519
- )), /* @__PURE__ */ React.createElement("div", { className: "application-menu__search" }, /* @__PURE__ */ React.createElement(
32545
+ ))), /* @__PURE__ */ React.createElement("div", { className: "application-menu__search" }, /* @__PURE__ */ React.createElement(
32520
32546
  "input",
32521
32547
  {
32522
32548
  ref: searchInputRef,
@@ -32530,7 +32556,8 @@ const rows = [
32530
32556
  "button",
32531
32557
  {
32532
32558
  className: `application-menu__category ${selectedCategory === "all" ? "active" : ""}`,
32533
- onClick: () => handleCategorySelect("all")
32559
+ onClick: () => handleCategorySelect("all"),
32560
+ title: "All Apps"
32534
32561
  },
32535
32562
  /* @__PURE__ */ React.createElement("span", { className: "category-icon" }, "📱"),
32536
32563
  /* @__PURE__ */ React.createElement("span", { className: "category-name" }, "All Apps")
@@ -32539,30 +32566,31 @@ const rows = [
32539
32566
  {
32540
32567
  key: category.id,
32541
32568
  className: `application-menu__category ${selectedCategory === category.id ? "active" : ""}`,
32542
- onClick: () => handleCategorySelect(category.id)
32569
+ onClick: () => handleCategorySelect(category.id),
32570
+ title: category.name
32543
32571
  },
32544
32572
  /* @__PURE__ */ React.createElement("span", { className: "category-icon" }, category.icon),
32545
32573
  /* @__PURE__ */ React.createElement("span", { className: "category-name" }, category.name)
32546
- )))), /* @__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(
32574
+ )))), /* @__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(
32547
32575
  "div",
32548
32576
  {
32549
32577
  key: app.id,
32550
- className: "application-menu__app",
32578
+ className: `application-menu__app--${viewMode}`,
32551
32579
  onClick: () => handleLaunchApp(app),
32552
32580
  title: app.description
32553
32581
  },
32554
32582
  /* @__PURE__ */ React.createElement("div", { className: "app-icon" }, app.icon),
32555
- /* @__PURE__ */ React.createElement("div", { className: "app-name" }, app.name)
32556
- )))), !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(
32583
+ 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)
32584
+ )))), !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(
32557
32585
  "div",
32558
32586
  {
32559
32587
  key: app.id,
32560
- className: "application-menu__app",
32588
+ className: `application-menu__app--${viewMode}`,
32561
32589
  onClick: () => handleLaunchApp(app),
32562
32590
  title: app.description
32563
32591
  },
32564
32592
  /* @__PURE__ */ React.createElement("div", { className: "app-icon" }, app.icon),
32565
- /* @__PURE__ */ React.createElement("div", { className: "app-name" }, app.name)
32593
+ 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)
32566
32594
  )))))), 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."))))));
32567
32595
  };
32568
32596
  class AppManager {
@@ -32570,107 +32598,6 @@ const rows = [
32570
32598
  this.applications = /* @__PURE__ */ new Map();
32571
32599
  this.categories = /* @__PURE__ */ new Map();
32572
32600
  this.listeners = /* @__PURE__ */ new Set();
32573
- this.initializeDefaultApps();
32574
- }
32575
- /**
32576
- * Initialize default applications
32577
- */
32578
- initializeDefaultApps() {
32579
- this.registerApp({
32580
- id: "file-explorer",
32581
- name: "File Explorer",
32582
- description: "Browse and manage files",
32583
- icon: "📁",
32584
- category: "System",
32585
- component: null,
32586
- // Will be set when registering actual components
32587
- size: { width: 600, height: 400 },
32588
- toolbar: null,
32589
- statusBar: null
32590
- });
32591
- this.registerApp({
32592
- id: "text-editor",
32593
- name: "Text Editor",
32594
- description: "Edit text files",
32595
- icon: "📝",
32596
- category: "Productivity",
32597
- component: null,
32598
- size: { width: 500, height: 350 },
32599
- toolbar: null,
32600
- statusBar: null
32601
- });
32602
- this.registerApp({
32603
- id: "calculator",
32604
- name: "Calculator",
32605
- description: "Perform calculations",
32606
- icon: "🧮",
32607
- category: "Utilities",
32608
- component: null,
32609
- size: { width: 300, height: 400 }
32610
- });
32611
- this.registerApp({
32612
- id: "settings",
32613
- name: "Settings",
32614
- description: "System configuration",
32615
- icon: "⚙️",
32616
- category: "System",
32617
- component: null,
32618
- size: { width: 450, height: 300 }
32619
- });
32620
- this.registerApp({
32621
- id: "browser",
32622
- name: "Web Browser",
32623
- description: "Browse the internet",
32624
- icon: "🌐",
32625
- category: "Internet",
32626
- component: null,
32627
- size: { width: 800, height: 500 }
32628
- });
32629
- this.registerApp({
32630
- id: "terminal",
32631
- name: "Terminal",
32632
- description: "Command line interface",
32633
- icon: "💻",
32634
- category: "Development",
32635
- component: null,
32636
- size: { width: 700, height: 400 }
32637
- });
32638
- this.registerApp({
32639
- id: "image-viewer",
32640
- name: "Image Viewer",
32641
- description: "View and edit images",
32642
- icon: "🖼️",
32643
- category: "Media",
32644
- component: null,
32645
- size: { width: 600, height: 500 }
32646
- });
32647
- this.registerApp({
32648
- id: "music-player",
32649
- name: "Music Player",
32650
- description: "Play audio files",
32651
- icon: "🎵",
32652
- category: "Media",
32653
- component: null,
32654
- size: { width: 400, height: 300 }
32655
- });
32656
- this.initializeCategories();
32657
- }
32658
- /**
32659
- * Initialize application categories
32660
- */
32661
- initializeCategories() {
32662
- const categoryData = [
32663
- { id: "system", name: "System", icon: "⚙️", color: "#607d8b" },
32664
- { id: "productivity", name: "Productivity", icon: "📊", color: "#2196f3" },
32665
- { id: "utilities", name: "Utilities", icon: "🔧", color: "#ff9800" },
32666
- { id: "internet", name: "Internet", icon: "🌐", color: "#4caf50" },
32667
- { id: "development", name: "Development", icon: "💻", color: "#9c27b0" },
32668
- { id: "media", name: "Media", icon: "🎬", color: "#e91e63" },
32669
- { id: "games", name: "Games", icon: "🎮", color: "#f44336" }
32670
- ];
32671
- categoryData.forEach((category) => {
32672
- this.categories.set(category.id, category);
32673
- });
32674
32601
  }
32675
32602
  /**
32676
32603
  * Register a new application
@@ -32790,6 +32717,160 @@ const rows = [
32790
32717
  return grouped;
32791
32718
  }
32792
32719
  }
32720
+ class AppLoader {
32721
+ /**
32722
+ * Load configuration into AppManager
32723
+ * @param {AppManager} appManager - The AppManager instance
32724
+ * @param {Object} config - JSON configuration object
32725
+ * @param {Array} config.categories - Array of category definitions
32726
+ * @param {Array} config.applications - Array of application definitions
32727
+ */
32728
+ static load(appManager, config) {
32729
+ if (!config) {
32730
+ console.warn("AppLoader: No configuration provided");
32731
+ return;
32732
+ }
32733
+ if (config.categories && Array.isArray(config.categories)) {
32734
+ this.loadCategories(appManager, config.categories);
32735
+ }
32736
+ if (config.applications && Array.isArray(config.applications)) {
32737
+ this.loadApplications(appManager, config.applications);
32738
+ }
32739
+ }
32740
+ /**
32741
+ * Load categories from configuration
32742
+ * @param {AppManager} appManager - The AppManager instance
32743
+ * @param {Array} categories - Array of category definitions
32744
+ */
32745
+ static loadCategories(appManager, categories) {
32746
+ categories.forEach((category) => {
32747
+ if (this.validateCategory(category)) {
32748
+ appManager.categories.set(category.id, category);
32749
+ } else {
32750
+ console.warn("AppLoader: Invalid category configuration:", category);
32751
+ }
32752
+ });
32753
+ }
32754
+ /**
32755
+ * Load applications from configuration
32756
+ * @param {AppManager} appManager - The AppManager instance
32757
+ * @param {Array} applications - Array of application definitions
32758
+ */
32759
+ static loadApplications(appManager, applications) {
32760
+ applications.forEach((app) => {
32761
+ if (this.validateApplication(app)) {
32762
+ appManager.registerApp(app);
32763
+ } else {
32764
+ console.warn("AppLoader: Invalid application configuration:", app);
32765
+ }
32766
+ });
32767
+ }
32768
+ /**
32769
+ * Validate category configuration
32770
+ * @param {Object} category - Category definition
32771
+ * @returns {boolean} - True if valid
32772
+ */
32773
+ static validateCategory(category) {
32774
+ return category && typeof category.id === "string" && typeof category.name === "string" && category.id.length > 0 && category.name.length > 0;
32775
+ }
32776
+ /**
32777
+ * Validate application configuration
32778
+ * @param {Object} app - Application definition
32779
+ * @returns {boolean} - True if valid
32780
+ */
32781
+ static validateApplication(app) {
32782
+ return app && typeof app.id === "string" && typeof app.name === "string" && app.id.length > 0 && app.name.length > 0;
32783
+ }
32784
+ }
32785
+ const defaultDesktopConfig = {
32786
+ categories: [
32787
+ { id: "system", name: "System", icon: "⚙️", color: "#607d8b" },
32788
+ { id: "productivity", name: "Productivity", icon: "📊", color: "#2196f3" },
32789
+ { id: "utilities", name: "Utilities", icon: "🔧", color: "#ff9800" },
32790
+ { id: "internet", name: "Internet", icon: "🌐", color: "#4caf50" },
32791
+ { id: "development", name: "Development", icon: "💻", color: "#9c27b0" },
32792
+ { id: "media", name: "Media", icon: "🎬", color: "#e91e63" },
32793
+ { id: "games", name: "Games", icon: "🎮", color: "#f44336" }
32794
+ ],
32795
+ applications: [
32796
+ {
32797
+ id: "file-explorer",
32798
+ name: "File Explorer",
32799
+ description: "Browse and manage files",
32800
+ icon: "📁",
32801
+ category: "System",
32802
+ component: null,
32803
+ size: { width: 600, height: 400 },
32804
+ toolbar: null,
32805
+ statusBar: null
32806
+ },
32807
+ {
32808
+ id: "text-editor",
32809
+ name: "Text Editor",
32810
+ description: "Edit text files",
32811
+ icon: "📝",
32812
+ category: "Productivity",
32813
+ component: null,
32814
+ size: { width: 500, height: 350 },
32815
+ toolbar: null,
32816
+ statusBar: null
32817
+ },
32818
+ {
32819
+ id: "calculator",
32820
+ name: "Calculator",
32821
+ description: "Perform calculations",
32822
+ icon: "🧮",
32823
+ category: "Utilities",
32824
+ component: null,
32825
+ size: { width: 300, height: 400 }
32826
+ },
32827
+ {
32828
+ id: "settings",
32829
+ name: "Settings",
32830
+ description: "System configuration",
32831
+ icon: "⚙️",
32832
+ category: "System",
32833
+ component: null,
32834
+ size: { width: 450, height: 300 }
32835
+ },
32836
+ {
32837
+ id: "browser",
32838
+ name: "Web Browser",
32839
+ description: "Browse the internet",
32840
+ icon: "🌐",
32841
+ category: "Internet",
32842
+ component: null,
32843
+ size: { width: 800, height: 500 }
32844
+ },
32845
+ {
32846
+ id: "terminal",
32847
+ name: "Terminal",
32848
+ description: "Command line interface",
32849
+ icon: "💻",
32850
+ category: "Development",
32851
+ component: null,
32852
+ size: { width: 700, height: 400 }
32853
+ },
32854
+ {
32855
+ id: "image-viewer",
32856
+ name: "Image Viewer",
32857
+ description: "View and edit images",
32858
+ icon: "🖼️",
32859
+ category: "Media",
32860
+ component: null,
32861
+ size: { width: 600, height: 500 }
32862
+ },
32863
+ {
32864
+ id: "music-player",
32865
+ name: "Music Player",
32866
+ description: "Play audio files",
32867
+ icon: "🎵",
32868
+ category: "Media",
32869
+ component: null,
32870
+ size: { width: 400, height: 300 }
32871
+ }
32872
+ ]
32873
+ };
32793
32874
  const defaultAppManager = new AppManager();
32794
32875
  const AppContext = React.createContext();
32795
32876
  const useApplicationMenu = () => {
@@ -32806,8 +32887,17 @@ const rows = [
32806
32887
  }
32807
32888
  return context.appManager;
32808
32889
  };
32809
- const AppProvider = ({ children, appManager = defaultAppManager }) => {
32890
+ const AppProvider = ({
32891
+ children,
32892
+ desktopConfig = defaultDesktopConfig
32893
+ }) => {
32894
+ const appManager = new AppManager();
32810
32895
  const [isApplicationMenuOpen, setIsApplicationMenuOpen] = React.useState(false);
32896
+ React.useEffect(() => {
32897
+ if (appManager.getAllApps().length === 0 && desktopConfig) {
32898
+ AppLoader.load(appManager, desktopConfig);
32899
+ }
32900
+ }, [appManager, desktopConfig]);
32811
32901
  const value = {
32812
32902
  // Application Menu state
32813
32903
  applicationMenu: {
@@ -33071,8 +33161,19 @@ Middle click: Close`
33071
33161
  }
33072
33162
  )), /* @__PURE__ */ React.createElement(DesktopTaskbar, null)));
33073
33163
  };
33074
- const Desktop = ({ desktopSize, children, ...props }) => {
33075
- return /* @__PURE__ */ React.createElement(AppProvider, null, /* @__PURE__ */ React.createElement(DesktopInternal, { desktopSize, ...props }, children));
33164
+ const Desktop = ({
33165
+ desktopSize,
33166
+ children,
33167
+ desktopConfig,
33168
+ ...props
33169
+ }) => {
33170
+ return /* @__PURE__ */ React.createElement(
33171
+ AppProvider,
33172
+ {
33173
+ desktopConfig
33174
+ },
33175
+ /* @__PURE__ */ React.createElement(DesktopInternal, { desktopSize, ...props }, children)
33176
+ );
33076
33177
  };
33077
33178
  const ContentForm = ({ content, columns = 1, filter, rules, onChange }) => {
33078
33179
  const form = content.form();