ywana-core8 0.2.8 → 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.css +292 -56
- package/dist/index.js +215 -114
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +215 -114
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +215 -114
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/desktop/AppManager.js +179 -115
- package/src/desktop/ApplicationMenu.css +292 -53
- package/src/desktop/ApplicationMenu.js +55 -15
- package/src/desktop/Desktop.stories.jsx +148 -584
- package/src/desktop/desktop-windows.css +0 -3
- package/src/desktop/desktop.js +43 -23
- package/src/desktop.backup/desktop.css +0 -6
- package/src/desktop.backup/desktop.js +0 -13
- package/src/desktop.backup/window.css +0 -58
- package/src/desktop.backup/window.js +0 -27
package/package.json
CHANGED
@@ -2,125 +2,11 @@
|
|
2
2
|
* AppManager - Manages available applications for the desktop
|
3
3
|
*/
|
4
4
|
export class AppManager {
|
5
|
+
|
5
6
|
constructor() {
|
6
7
|
this.applications = new Map()
|
7
8
|
this.categories = new Map()
|
8
9
|
this.listeners = new Set()
|
9
|
-
|
10
|
-
// Initialize with default applications
|
11
|
-
this.initializeDefaultApps()
|
12
|
-
}
|
13
|
-
|
14
|
-
/**
|
15
|
-
* Initialize default applications
|
16
|
-
*/
|
17
|
-
initializeDefaultApps() {
|
18
|
-
// System applications
|
19
|
-
this.registerApp({
|
20
|
-
id: 'file-explorer',
|
21
|
-
name: 'File Explorer',
|
22
|
-
description: 'Browse and manage files',
|
23
|
-
icon: '📁',
|
24
|
-
category: 'System',
|
25
|
-
component: null, // Will be set when registering actual components
|
26
|
-
size: { width: 600, height: 400 },
|
27
|
-
toolbar: null,
|
28
|
-
statusBar: null
|
29
|
-
})
|
30
|
-
|
31
|
-
this.registerApp({
|
32
|
-
id: 'text-editor',
|
33
|
-
name: 'Text Editor',
|
34
|
-
description: 'Edit text files',
|
35
|
-
icon: '📝',
|
36
|
-
category: 'Productivity',
|
37
|
-
component: null,
|
38
|
-
size: { width: 500, height: 350 },
|
39
|
-
toolbar: null,
|
40
|
-
statusBar: null,
|
41
|
-
})
|
42
|
-
|
43
|
-
this.registerApp({
|
44
|
-
id: 'calculator',
|
45
|
-
name: 'Calculator',
|
46
|
-
description: 'Perform calculations',
|
47
|
-
icon: '🧮',
|
48
|
-
category: 'Utilities',
|
49
|
-
component: null,
|
50
|
-
size: { width: 300, height: 400 }
|
51
|
-
})
|
52
|
-
|
53
|
-
this.registerApp({
|
54
|
-
id: 'settings',
|
55
|
-
name: 'Settings',
|
56
|
-
description: 'System configuration',
|
57
|
-
icon: '⚙️',
|
58
|
-
category: 'System',
|
59
|
-
component: null,
|
60
|
-
size: { width: 450, height: 300 }
|
61
|
-
})
|
62
|
-
|
63
|
-
this.registerApp({
|
64
|
-
id: 'browser',
|
65
|
-
name: 'Web Browser',
|
66
|
-
description: 'Browse the internet',
|
67
|
-
icon: '🌐',
|
68
|
-
category: 'Internet',
|
69
|
-
component: null,
|
70
|
-
size: { width: 800, height: 500 }
|
71
|
-
})
|
72
|
-
|
73
|
-
this.registerApp({
|
74
|
-
id: 'terminal',
|
75
|
-
name: 'Terminal',
|
76
|
-
description: 'Command line interface',
|
77
|
-
icon: '💻',
|
78
|
-
category: 'Development',
|
79
|
-
component: null,
|
80
|
-
size: { width: 700, height: 400 }
|
81
|
-
})
|
82
|
-
|
83
|
-
this.registerApp({
|
84
|
-
id: 'image-viewer',
|
85
|
-
name: 'Image Viewer',
|
86
|
-
description: 'View and edit images',
|
87
|
-
icon: '🖼️',
|
88
|
-
category: 'Media',
|
89
|
-
component: null,
|
90
|
-
size: { width: 600, height: 500 }
|
91
|
-
})
|
92
|
-
|
93
|
-
this.registerApp({
|
94
|
-
id: 'music-player',
|
95
|
-
name: 'Music Player',
|
96
|
-
description: 'Play audio files',
|
97
|
-
icon: '🎵',
|
98
|
-
category: 'Media',
|
99
|
-
component: null,
|
100
|
-
size: { width: 400, height: 300 }
|
101
|
-
})
|
102
|
-
|
103
|
-
// Initialize categories
|
104
|
-
this.initializeCategories()
|
105
|
-
}
|
106
|
-
|
107
|
-
/**
|
108
|
-
* Initialize application categories
|
109
|
-
*/
|
110
|
-
initializeCategories() {
|
111
|
-
const categoryData = [
|
112
|
-
{ id: 'system', name: 'System', icon: '⚙️', color: '#607d8b' },
|
113
|
-
{ id: 'productivity', name: 'Productivity', icon: '📊', color: '#2196f3' },
|
114
|
-
{ id: 'utilities', name: 'Utilities', icon: '🔧', color: '#ff9800' },
|
115
|
-
{ id: 'internet', name: 'Internet', icon: '🌐', color: '#4caf50' },
|
116
|
-
{ id: 'development', name: 'Development', icon: '💻', color: '#9c27b0' },
|
117
|
-
{ id: 'media', name: 'Media', icon: '🎬', color: '#e91e63' },
|
118
|
-
{ id: 'games', name: 'Games', icon: '🎮', color: '#f44336' }
|
119
|
-
]
|
120
|
-
|
121
|
-
categoryData.forEach(category => {
|
122
|
-
this.categories.set(category.id, category)
|
123
|
-
})
|
124
10
|
}
|
125
11
|
|
126
12
|
/**
|
@@ -266,5 +152,183 @@ export class AppManager {
|
|
266
152
|
}
|
267
153
|
}
|
268
154
|
|
155
|
+
/**
|
156
|
+
* AppLoader - Loads applications and categories from JSON configuration
|
157
|
+
*/
|
158
|
+
export class AppLoader {
|
159
|
+
/**
|
160
|
+
* Load configuration into AppManager
|
161
|
+
* @param {AppManager} appManager - The AppManager instance
|
162
|
+
* @param {Object} config - JSON configuration object
|
163
|
+
* @param {Array} config.categories - Array of category definitions
|
164
|
+
* @param {Array} config.applications - Array of application definitions
|
165
|
+
*/
|
166
|
+
static load(appManager, config) {
|
167
|
+
if (!config) {
|
168
|
+
console.warn('AppLoader: No configuration provided')
|
169
|
+
return
|
170
|
+
}
|
171
|
+
|
172
|
+
// Load categories first
|
173
|
+
if (config.categories && Array.isArray(config.categories)) {
|
174
|
+
this.loadCategories(appManager, config.categories)
|
175
|
+
}
|
176
|
+
|
177
|
+
// Load applications
|
178
|
+
if (config.applications && Array.isArray(config.applications)) {
|
179
|
+
this.loadApplications(appManager, config.applications)
|
180
|
+
}
|
181
|
+
}
|
182
|
+
|
183
|
+
/**
|
184
|
+
* Load categories from configuration
|
185
|
+
* @param {AppManager} appManager - The AppManager instance
|
186
|
+
* @param {Array} categories - Array of category definitions
|
187
|
+
*/
|
188
|
+
static loadCategories(appManager, categories) {
|
189
|
+
categories.forEach(category => {
|
190
|
+
if (this.validateCategory(category)) {
|
191
|
+
appManager.categories.set(category.id, category)
|
192
|
+
} else {
|
193
|
+
console.warn('AppLoader: Invalid category configuration:', category)
|
194
|
+
}
|
195
|
+
})
|
196
|
+
}
|
197
|
+
|
198
|
+
/**
|
199
|
+
* Load applications from configuration
|
200
|
+
* @param {AppManager} appManager - The AppManager instance
|
201
|
+
* @param {Array} applications - Array of application definitions
|
202
|
+
*/
|
203
|
+
static loadApplications(appManager, applications) {
|
204
|
+
applications.forEach(app => {
|
205
|
+
if (this.validateApplication(app)) {
|
206
|
+
appManager.registerApp(app)
|
207
|
+
} else {
|
208
|
+
console.warn('AppLoader: Invalid application configuration:', app)
|
209
|
+
}
|
210
|
+
})
|
211
|
+
}
|
212
|
+
|
213
|
+
/**
|
214
|
+
* Validate category configuration
|
215
|
+
* @param {Object} category - Category definition
|
216
|
+
* @returns {boolean} - True if valid
|
217
|
+
*/
|
218
|
+
static validateCategory(category) {
|
219
|
+
return category &&
|
220
|
+
typeof category.id === 'string' &&
|
221
|
+
typeof category.name === 'string' &&
|
222
|
+
category.id.length > 0 &&
|
223
|
+
category.name.length > 0
|
224
|
+
}
|
225
|
+
|
226
|
+
/**
|
227
|
+
* Validate application configuration
|
228
|
+
* @param {Object} app - Application definition
|
229
|
+
* @returns {boolean} - True if valid
|
230
|
+
*/
|
231
|
+
static validateApplication(app) {
|
232
|
+
return app &&
|
233
|
+
typeof app.id === 'string' &&
|
234
|
+
typeof app.name === 'string' &&
|
235
|
+
app.id.length > 0 &&
|
236
|
+
app.name.length > 0
|
237
|
+
}
|
238
|
+
}
|
239
|
+
|
240
|
+
/**
|
241
|
+
* Default desktop configuration
|
242
|
+
*/
|
243
|
+
export const defaultDesktopConfig = {
|
244
|
+
categories: [
|
245
|
+
{ id: 'system', name: 'System', icon: '⚙️', color: '#607d8b' },
|
246
|
+
{ id: 'productivity', name: 'Productivity', icon: '📊', color: '#2196f3' },
|
247
|
+
{ id: 'utilities', name: 'Utilities', icon: '🔧', color: '#ff9800' },
|
248
|
+
{ id: 'internet', name: 'Internet', icon: '🌐', color: '#4caf50' },
|
249
|
+
{ id: 'development', name: 'Development', icon: '💻', color: '#9c27b0' },
|
250
|
+
{ id: 'media', name: 'Media', icon: '🎬', color: '#e91e63' },
|
251
|
+
{ id: 'games', name: 'Games', icon: '🎮', color: '#f44336' }
|
252
|
+
],
|
253
|
+
applications: [
|
254
|
+
{
|
255
|
+
id: 'file-explorer',
|
256
|
+
name: 'File Explorer',
|
257
|
+
description: 'Browse and manage files',
|
258
|
+
icon: '📁',
|
259
|
+
category: 'System',
|
260
|
+
component: null,
|
261
|
+
size: { width: 600, height: 400 },
|
262
|
+
toolbar: null,
|
263
|
+
statusBar: null
|
264
|
+
},
|
265
|
+
{
|
266
|
+
id: 'text-editor',
|
267
|
+
name: 'Text Editor',
|
268
|
+
description: 'Edit text files',
|
269
|
+
icon: '📝',
|
270
|
+
category: 'Productivity',
|
271
|
+
component: null,
|
272
|
+
size: { width: 500, height: 350 },
|
273
|
+
toolbar: null,
|
274
|
+
statusBar: null
|
275
|
+
},
|
276
|
+
{
|
277
|
+
id: 'calculator',
|
278
|
+
name: 'Calculator',
|
279
|
+
description: 'Perform calculations',
|
280
|
+
icon: '🧮',
|
281
|
+
category: 'Utilities',
|
282
|
+
component: null,
|
283
|
+
size: { width: 300, height: 400 }
|
284
|
+
},
|
285
|
+
{
|
286
|
+
id: 'settings',
|
287
|
+
name: 'Settings',
|
288
|
+
description: 'System configuration',
|
289
|
+
icon: '⚙️',
|
290
|
+
category: 'System',
|
291
|
+
component: null,
|
292
|
+
size: { width: 450, height: 300 }
|
293
|
+
},
|
294
|
+
{
|
295
|
+
id: 'browser',
|
296
|
+
name: 'Web Browser',
|
297
|
+
description: 'Browse the internet',
|
298
|
+
icon: '🌐',
|
299
|
+
category: 'Internet',
|
300
|
+
component: null,
|
301
|
+
size: { width: 800, height: 500 }
|
302
|
+
},
|
303
|
+
{
|
304
|
+
id: 'terminal',
|
305
|
+
name: 'Terminal',
|
306
|
+
description: 'Command line interface',
|
307
|
+
icon: '💻',
|
308
|
+
category: 'Development',
|
309
|
+
component: null,
|
310
|
+
size: { width: 700, height: 400 }
|
311
|
+
},
|
312
|
+
{
|
313
|
+
id: 'image-viewer',
|
314
|
+
name: 'Image Viewer',
|
315
|
+
description: 'View and edit images',
|
316
|
+
icon: '🖼️',
|
317
|
+
category: 'Media',
|
318
|
+
component: null,
|
319
|
+
size: { width: 600, height: 500 }
|
320
|
+
},
|
321
|
+
{
|
322
|
+
id: 'music-player',
|
323
|
+
name: 'Music Player',
|
324
|
+
description: 'Play audio files',
|
325
|
+
icon: '🎵',
|
326
|
+
category: 'Media',
|
327
|
+
component: null,
|
328
|
+
size: { width: 400, height: 300 }
|
329
|
+
}
|
330
|
+
]
|
331
|
+
}
|
332
|
+
|
269
333
|
// Create default instance
|
270
334
|
export const defaultAppManager = new AppManager()
|