aegis-framework 0.2.0 → 0.3.0
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/README.md +552 -158
- package/aegis/runtime/aegis-api.js +977 -246
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,14 +13,23 @@ Create desktop applications with HTML, CSS, and JavaScript that package into ~20
|
|
|
13
13
|
|
|
14
14
|
**That's 700x smaller!**
|
|
15
15
|
|
|
16
|
+
---
|
|
17
|
+
|
|
16
18
|
## 🚀 Installation
|
|
17
19
|
|
|
18
20
|
```bash
|
|
19
|
-
# Install globally
|
|
21
|
+
# Install globally
|
|
20
22
|
npm install -g aegis-framework
|
|
21
23
|
|
|
22
|
-
#
|
|
23
|
-
|
|
24
|
+
# Create new project
|
|
25
|
+
aegis init my-app
|
|
26
|
+
cd my-app
|
|
27
|
+
|
|
28
|
+
# Run development
|
|
29
|
+
aegis dev
|
|
30
|
+
|
|
31
|
+
# Build AppImage
|
|
32
|
+
aegis build
|
|
24
33
|
```
|
|
25
34
|
|
|
26
35
|
### System Requirements (Linux only)
|
|
@@ -36,200 +45,614 @@ sudo dnf install python3 python3-gobject webkit2gtk4.1
|
|
|
36
45
|
sudo pacman -S python python-gobject webkit2gtk-4.1
|
|
37
46
|
```
|
|
38
47
|
|
|
39
|
-
|
|
48
|
+
---
|
|
40
49
|
|
|
41
|
-
|
|
42
|
-
# Create a new project
|
|
43
|
-
aegis init my-app
|
|
50
|
+
# 🛠️ Aegis Utility API
|
|
44
51
|
|
|
45
|
-
|
|
46
|
-
cd my-app
|
|
52
|
+
Aegis includes a powerful utility API that simplifies common JavaScript patterns. No more repetitive code!
|
|
47
53
|
|
|
48
|
-
|
|
49
|
-
aegis dev
|
|
54
|
+
---
|
|
50
55
|
|
|
51
|
-
|
|
52
|
-
|
|
56
|
+
## 📌 Event Handling
|
|
57
|
+
|
|
58
|
+
### Aegis.click(selector, handler)
|
|
59
|
+
Add click event to element(s).
|
|
60
|
+
|
|
61
|
+
```javascript
|
|
62
|
+
// Add click to button
|
|
63
|
+
Aegis.click('#my-button', () => {
|
|
64
|
+
alert('Clicked!');
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
// Works with multiple elements
|
|
68
|
+
Aegis.click('.card', (e) => {
|
|
69
|
+
console.log('Card clicked:', e.target);
|
|
70
|
+
});
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Aegis.on(selector, events, handler)
|
|
74
|
+
Add any event(s) to element(s).
|
|
75
|
+
|
|
76
|
+
```javascript
|
|
77
|
+
// Single event
|
|
78
|
+
Aegis.on('#input', 'focus', () => console.log('Focused!'));
|
|
79
|
+
|
|
80
|
+
// Multiple events at once!
|
|
81
|
+
Aegis.on('.field', 'focus blur', (e) => {
|
|
82
|
+
console.log(e.type); // 'focus' or 'blur'
|
|
83
|
+
});
|
|
53
84
|
```
|
|
54
85
|
|
|
55
|
-
|
|
86
|
+
### Aegis.once(selector, events, handler)
|
|
87
|
+
Event that fires only once.
|
|
56
88
|
|
|
89
|
+
```javascript
|
|
90
|
+
Aegis.once('#start-btn', 'click', () => {
|
|
91
|
+
initializeApp();
|
|
92
|
+
});
|
|
57
93
|
```
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
94
|
+
|
|
95
|
+
### More Event Shortcuts
|
|
96
|
+
|
|
97
|
+
```javascript
|
|
98
|
+
Aegis.submit('#form', handler); // Form submit
|
|
99
|
+
Aegis.change('#select', handler); // Select change
|
|
100
|
+
Aegis.input('#search', handler); // Input typing
|
|
101
|
+
Aegis.keypress('#input', handler); // Key press
|
|
102
|
+
|
|
103
|
+
// Hover with enter and leave
|
|
104
|
+
Aegis.hover('#card',
|
|
105
|
+
() => console.log('Mouse entered'),
|
|
106
|
+
() => console.log('Mouse left')
|
|
107
|
+
);
|
|
67
108
|
```
|
|
68
109
|
|
|
69
|
-
|
|
110
|
+
---
|
|
70
111
|
|
|
71
|
-
|
|
112
|
+
## 🏗️ Element Selection
|
|
113
|
+
|
|
114
|
+
### Aegis.get(selector)
|
|
115
|
+
Get single element.
|
|
72
116
|
|
|
73
117
|
```javascript
|
|
74
|
-
|
|
75
|
-
const
|
|
76
|
-
|
|
118
|
+
const btn = Aegis.get('#my-button');
|
|
119
|
+
const first = Aegis.get('.card');
|
|
120
|
+
```
|
|
77
121
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
console.log(file.content);
|
|
122
|
+
### Aegis.getAll(selector)
|
|
123
|
+
Get all elements.
|
|
81
124
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
125
|
+
```javascript
|
|
126
|
+
const cards = Aegis.getAll('.card');
|
|
127
|
+
cards.forEach(card => console.log(card));
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## ✨ Element Creation
|
|
133
|
+
|
|
134
|
+
### Aegis.create(tag, options)
|
|
135
|
+
Create elements with all properties at once.
|
|
136
|
+
|
|
137
|
+
```javascript
|
|
138
|
+
// Simple element
|
|
139
|
+
const div = Aegis.create('div', {
|
|
140
|
+
id: 'my-div',
|
|
141
|
+
class: 'card active',
|
|
142
|
+
html: '<h1>Title</h1><p>Content</p>'
|
|
87
143
|
});
|
|
88
144
|
|
|
89
|
-
//
|
|
90
|
-
|
|
145
|
+
// Complete example
|
|
146
|
+
Aegis.create('button', {
|
|
147
|
+
id: 'submit-btn',
|
|
148
|
+
class: 'btn btn-primary',
|
|
149
|
+
text: 'Click Me',
|
|
150
|
+
attrs: { type: 'submit', disabled: false },
|
|
151
|
+
style: { backgroundColor: 'blue', color: 'white' },
|
|
152
|
+
data: { userId: '123', action: 'submit' },
|
|
153
|
+
on: {
|
|
154
|
+
click: () => alert('Clicked!'),
|
|
155
|
+
mouseenter: () => console.log('Hover')
|
|
156
|
+
},
|
|
157
|
+
parent: '#form' // Auto-append to parent
|
|
158
|
+
});
|
|
159
|
+
```
|
|
91
160
|
|
|
92
|
-
|
|
93
|
-
await Aegis.mkdir({ path: '/home/user/new-folder' });
|
|
161
|
+
---
|
|
94
162
|
|
|
95
|
-
|
|
96
|
-
await Aegis.remove({ path: '/home/user/old-file.txt' });
|
|
163
|
+
## 🎨 Class Manipulation
|
|
97
164
|
|
|
98
|
-
|
|
99
|
-
|
|
165
|
+
```javascript
|
|
166
|
+
Aegis.addClass('#el', 'active', 'visible');
|
|
167
|
+
Aegis.removeClass('#el', 'hidden');
|
|
168
|
+
Aegis.toggleClass('#el', 'active');
|
|
100
169
|
|
|
101
|
-
|
|
102
|
-
|
|
170
|
+
if (Aegis.hasClass('#el', 'active')) {
|
|
171
|
+
console.log('Element is active');
|
|
172
|
+
}
|
|
103
173
|
```
|
|
104
174
|
|
|
105
|
-
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
## 💅 Style Manipulation
|
|
106
178
|
|
|
107
179
|
```javascript
|
|
108
|
-
//
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
180
|
+
// Set styles
|
|
181
|
+
Aegis.css('#el', {
|
|
182
|
+
color: 'red',
|
|
183
|
+
fontSize: '18px',
|
|
184
|
+
backgroundColor: '#333'
|
|
113
185
|
});
|
|
114
186
|
|
|
115
|
-
//
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
187
|
+
// Show/Hide
|
|
188
|
+
Aegis.hide('#modal');
|
|
189
|
+
Aegis.show('#modal');
|
|
190
|
+
Aegis.toggleDisplay('#menu');
|
|
191
|
+
|
|
192
|
+
// Animations
|
|
193
|
+
Aegis.fadeIn('#modal', 300);
|
|
194
|
+
Aegis.fadeOut('#modal', 300);
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
## 📝 Content Manipulation
|
|
200
|
+
|
|
201
|
+
```javascript
|
|
202
|
+
// HTML content
|
|
203
|
+
Aegis.html('#container', '<h1>New Content</h1>');
|
|
204
|
+
const content = Aegis.html('#container'); // Get
|
|
205
|
+
|
|
206
|
+
// Text content
|
|
207
|
+
Aegis.text('#title', 'Hello World');
|
|
208
|
+
|
|
209
|
+
// Input values
|
|
210
|
+
Aegis.val('#input', 'New value');
|
|
211
|
+
const value = Aegis.val('#input'); // Get
|
|
212
|
+
|
|
213
|
+
// Attributes
|
|
214
|
+
Aegis.attr('#link', 'href', 'https://example.com');
|
|
215
|
+
|
|
216
|
+
// Data attributes
|
|
217
|
+
Aegis.data('#el', 'userId', '123');
|
|
218
|
+
const userId = Aegis.data('#el', 'userId');
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
## 📋 Form Utilities
|
|
224
|
+
|
|
225
|
+
### Aegis.form.serialize(selector)
|
|
226
|
+
Convert form to object.
|
|
227
|
+
|
|
228
|
+
```javascript
|
|
229
|
+
const data = Aegis.form.serialize('#my-form');
|
|
230
|
+
// { name: 'John', email: 'john@email.com' }
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### Aegis.form.fill(selector, data)
|
|
234
|
+
Fill form with data.
|
|
235
|
+
|
|
236
|
+
```javascript
|
|
237
|
+
Aegis.form.fill('#my-form', {
|
|
238
|
+
name: 'John',
|
|
239
|
+
email: 'john@email.com',
|
|
240
|
+
newsletter: true
|
|
121
241
|
});
|
|
122
|
-
|
|
242
|
+
```
|
|
123
243
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
244
|
+
### Aegis.form.validate(selector, rules)
|
|
245
|
+
Validate form fields.
|
|
246
|
+
|
|
247
|
+
```javascript
|
|
248
|
+
const result = Aegis.form.validate('#my-form', {
|
|
249
|
+
name: { required: true, minLength: 3 },
|
|
250
|
+
email: { required: true, email: true },
|
|
251
|
+
password: { required: true, minLength: 8 }
|
|
128
252
|
});
|
|
129
253
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
254
|
+
if (!result.valid) {
|
|
255
|
+
console.log(result.errors);
|
|
256
|
+
}
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
### Aegis.form.reset(selector)
|
|
260
|
+
Reset form fields.
|
|
261
|
+
|
|
262
|
+
```javascript
|
|
263
|
+
Aegis.form.reset('#my-form');
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
---
|
|
267
|
+
|
|
268
|
+
## 🌐 HTTP Requests
|
|
269
|
+
|
|
270
|
+
```javascript
|
|
271
|
+
// GET
|
|
272
|
+
const users = await Aegis.http.get('/api/users');
|
|
273
|
+
|
|
274
|
+
// POST
|
|
275
|
+
const newUser = await Aegis.http.post('/api/users', {
|
|
276
|
+
name: 'John',
|
|
277
|
+
email: 'john@email.com'
|
|
134
278
|
});
|
|
279
|
+
|
|
280
|
+
// PUT
|
|
281
|
+
await Aegis.http.put('/api/users/1', { name: 'Jane' });
|
|
282
|
+
|
|
283
|
+
// DELETE
|
|
284
|
+
await Aegis.http.delete('/api/users/1');
|
|
285
|
+
|
|
286
|
+
// Get raw response
|
|
287
|
+
const response = await Aegis.http.get('/api/data', { raw: true });
|
|
288
|
+
console.log(response.status);
|
|
135
289
|
```
|
|
136
290
|
|
|
137
|
-
|
|
291
|
+
---
|
|
292
|
+
|
|
293
|
+
## 🍪 Cookie Utilities
|
|
138
294
|
|
|
139
295
|
```javascript
|
|
140
|
-
//
|
|
141
|
-
|
|
142
|
-
await Aegis.app.maximize();
|
|
143
|
-
await Aegis.app.quit();
|
|
296
|
+
// Set cookie (expires in 30 days)
|
|
297
|
+
Aegis.cookie.set('theme', 'dark', 30);
|
|
144
298
|
|
|
145
|
-
// Get
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
//
|
|
299
|
+
// Get cookie
|
|
300
|
+
const theme = Aegis.cookie.get('theme');
|
|
301
|
+
|
|
302
|
+
// Remove cookie
|
|
303
|
+
Aegis.cookie.remove('theme');
|
|
149
304
|
```
|
|
150
305
|
|
|
151
|
-
|
|
306
|
+
---
|
|
307
|
+
|
|
308
|
+
## 🔗 URL Utilities
|
|
152
309
|
|
|
153
310
|
```javascript
|
|
154
|
-
//
|
|
155
|
-
Aegis.
|
|
311
|
+
// Get all URL parameters
|
|
312
|
+
const params = Aegis.url.params();
|
|
313
|
+
// { page: '1', sort: 'name' }
|
|
156
314
|
|
|
157
|
-
//
|
|
158
|
-
Aegis.
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
315
|
+
// Get single parameter
|
|
316
|
+
const page = Aegis.url.param('page');
|
|
317
|
+
|
|
318
|
+
// Build URL with params
|
|
319
|
+
const url = Aegis.url.build('/search', { q: 'hello', page: 1 });
|
|
320
|
+
// '/search?q=hello&page=1'
|
|
321
|
+
|
|
322
|
+
// Get current path
|
|
323
|
+
const path = Aegis.url.path();
|
|
324
|
+
|
|
325
|
+
// Get hash
|
|
326
|
+
const hash = Aegis.url.hash();
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
---
|
|
330
|
+
|
|
331
|
+
## 📝 String Utilities
|
|
332
|
+
|
|
333
|
+
```javascript
|
|
334
|
+
Aegis.string.capitalize('hello'); // 'Hello'
|
|
335
|
+
Aegis.string.titleCase('hello world'); // 'Hello World'
|
|
336
|
+
Aegis.string.camelCase('hello-world'); // 'helloWorld'
|
|
337
|
+
Aegis.string.kebabCase('helloWorld'); // 'hello-world'
|
|
338
|
+
Aegis.string.snakeCase('helloWorld'); // 'hello_world'
|
|
339
|
+
Aegis.string.slugify('Hello World!'); // 'hello-world'
|
|
340
|
+
|
|
341
|
+
Aegis.string.truncate('Long text here', 8); // 'Long tex...'
|
|
342
|
+
Aegis.string.reverse('hello'); // 'olleh'
|
|
343
|
+
Aegis.string.count('hello', 'l'); // 2
|
|
344
|
+
|
|
345
|
+
// Template strings
|
|
346
|
+
Aegis.string.template('Hello {{name}}!', { name: 'World' });
|
|
347
|
+
// 'Hello World!'
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
---
|
|
351
|
+
|
|
352
|
+
## 📦 Array Utilities
|
|
353
|
+
|
|
354
|
+
```javascript
|
|
355
|
+
Aegis.array.unique([1, 2, 2, 3]); // [1, 2, 3]
|
|
356
|
+
Aegis.array.shuffle([1, 2, 3, 4]); // [3, 1, 4, 2]
|
|
357
|
+
Aegis.array.chunk([1,2,3,4,5], 2); // [[1,2], [3,4], [5]]
|
|
358
|
+
Aegis.array.flatten([[1,2], [3,4]]); // [1, 2, 3, 4]
|
|
359
|
+
Aegis.array.compact([0, 1, false, 2, '', 3]); // [1, 2, 3]
|
|
360
|
+
|
|
361
|
+
Aegis.array.first([1, 2, 3]); // 1
|
|
362
|
+
Aegis.array.last([1, 2, 3]); // 3
|
|
363
|
+
Aegis.array.sample([1, 2, 3]); // Random item
|
|
364
|
+
|
|
365
|
+
Aegis.array.range(1, 5); // [1, 2, 3, 4, 5]
|
|
366
|
+
Aegis.array.diff([1,2,3], [2,3,4]); // [1]
|
|
367
|
+
Aegis.array.intersect([1,2,3], [2,3,4]); // [2, 3]
|
|
368
|
+
|
|
369
|
+
// Group by key
|
|
370
|
+
Aegis.array.groupBy(users, 'role');
|
|
371
|
+
// { admin: [...], user: [...] }
|
|
372
|
+
|
|
373
|
+
// Sort by key
|
|
374
|
+
Aegis.array.sortBy(users, 'name');
|
|
375
|
+
Aegis.array.sortBy(users, 'age', true); // Descending
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
---
|
|
379
|
+
|
|
380
|
+
## 🗃️ Object Utilities
|
|
381
|
+
|
|
382
|
+
```javascript
|
|
383
|
+
Aegis.object.clone(obj); // Deep clone
|
|
384
|
+
Aegis.object.merge(obj1, obj2); // Merge objects
|
|
385
|
+
Aegis.object.isEmpty({}); // true
|
|
386
|
+
|
|
387
|
+
Aegis.object.pick(obj, ['name', 'email']); // Pick keys
|
|
388
|
+
Aegis.object.omit(obj, ['password']); // Omit keys
|
|
389
|
+
|
|
390
|
+
Aegis.object.keys(obj); // Object.keys
|
|
391
|
+
Aegis.object.values(obj); // Object.values
|
|
392
|
+
Aegis.object.entries(obj); // Object.entries
|
|
393
|
+
|
|
394
|
+
// Deep get/set
|
|
395
|
+
Aegis.object.get(user, 'address.city', 'Unknown');
|
|
396
|
+
Aegis.object.set(user, 'address.city', 'New York');
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
---
|
|
400
|
+
|
|
401
|
+
## 📅 Date Utilities
|
|
402
|
+
|
|
403
|
+
```javascript
|
|
404
|
+
Aegis.date.now(); // Current date
|
|
405
|
+
Aegis.date.format(date, 'YYYY-MM-DD');
|
|
406
|
+
Aegis.date.format(date, 'DD/MM/YYYY HH:mm');
|
|
407
|
+
|
|
408
|
+
Aegis.date.ago(date); // '5 minutes ago'
|
|
409
|
+
Aegis.date.isToday(date); // true/false
|
|
410
|
+
Aegis.date.isYesterday(date); // true/false
|
|
411
|
+
|
|
412
|
+
Aegis.date.add(date, 7, 'day'); // Add 7 days
|
|
413
|
+
Aegis.date.diff(date1, date2, 'day'); // Days between
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
---
|
|
417
|
+
|
|
418
|
+
## 🔢 Number Utilities
|
|
419
|
+
|
|
420
|
+
```javascript
|
|
421
|
+
Aegis.number.format(1234567); // '1.234.567' (pt-BR)
|
|
422
|
+
Aegis.number.currency(1234.56); // 'R$ 1.234,56'
|
|
423
|
+
Aegis.number.currency(1234, 'USD', 'en-US'); // '$1,234.00'
|
|
424
|
+
|
|
425
|
+
Aegis.number.clamp(15, 0, 10); // 10
|
|
426
|
+
Aegis.number.random(1, 100); // Random int
|
|
427
|
+
Aegis.number.percent(25, 100); // 25
|
|
428
|
+
Aegis.number.bytes(1536000); // '1.46 MB'
|
|
429
|
+
Aegis.number.ordinal(3); // '3rd'
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
---
|
|
433
|
+
|
|
434
|
+
## 📋 Clipboard
|
|
435
|
+
|
|
436
|
+
```javascript
|
|
437
|
+
// Copy text
|
|
438
|
+
await Aegis.clipboard.copy('Hello World!');
|
|
439
|
+
|
|
440
|
+
// Paste text
|
|
441
|
+
const text = await Aegis.clipboard.paste();
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
---
|
|
445
|
+
|
|
446
|
+
## 🔔 Toast Notifications
|
|
447
|
+
|
|
448
|
+
```javascript
|
|
449
|
+
Aegis.toast('Hello World!');
|
|
450
|
+
|
|
451
|
+
Aegis.toast('Success!', { type: 'success' });
|
|
452
|
+
Aegis.toast('Warning!', { type: 'warning' });
|
|
453
|
+
Aegis.toast('Error!', { type: 'error' });
|
|
454
|
+
|
|
455
|
+
Aegis.toast('Custom toast', {
|
|
456
|
+
type: 'info',
|
|
457
|
+
duration: 5000,
|
|
458
|
+
position: 'top-right' // top-left, bottom-left, bottom-right
|
|
163
459
|
});
|
|
460
|
+
```
|
|
164
461
|
|
|
165
|
-
|
|
166
|
-
const size = await Aegis.window.getSize();
|
|
167
|
-
await Aegis.window.setSize({ width: 1024, height: 768 });
|
|
462
|
+
---
|
|
168
463
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
464
|
+
## 🎲 Random Utilities
|
|
465
|
+
|
|
466
|
+
```javascript
|
|
467
|
+
Aegis.random.int(1, 100); // Random integer
|
|
468
|
+
Aegis.random.float(0, 1); // Random float
|
|
469
|
+
Aegis.random.bool(); // true or false
|
|
470
|
+
Aegis.random.pick(['a', 'b', 'c']); // Random item
|
|
471
|
+
Aegis.random.color(); // '#a3f2c1'
|
|
472
|
+
Aegis.random.uuid(); // 'xxxxxxxx-xxxx-4xxx-...'
|
|
172
473
|
```
|
|
173
474
|
|
|
174
|
-
|
|
475
|
+
---
|
|
476
|
+
|
|
477
|
+
## ✅ Validation
|
|
175
478
|
|
|
176
479
|
```javascript
|
|
177
|
-
//
|
|
178
|
-
|
|
179
|
-
|
|
480
|
+
Aegis.is.email('test@email.com'); // true
|
|
481
|
+
Aegis.is.url('https://example.com'); // true
|
|
482
|
+
Aegis.is.number(123); // true
|
|
483
|
+
Aegis.is.string('hello'); // true
|
|
484
|
+
Aegis.is.array([1, 2, 3]); // true
|
|
485
|
+
Aegis.is.object({ a: 1 }); // true
|
|
486
|
+
Aegis.is.empty([]); // true
|
|
487
|
+
Aegis.is.mobile(); // true if mobile device
|
|
488
|
+
```
|
|
489
|
+
|
|
490
|
+
---
|
|
180
491
|
|
|
181
|
-
|
|
182
|
-
const py = await Aegis.run({ py: '2 + 2' });
|
|
183
|
-
console.log(py.output); // "4"
|
|
492
|
+
## 💾 Storage
|
|
184
493
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
)
|
|
494
|
+
```javascript
|
|
495
|
+
// Save data (auto JSON stringify)
|
|
496
|
+
Aegis.storage.set('user', { name: 'John', age: 30 });
|
|
497
|
+
|
|
498
|
+
// Get data (auto JSON parse)
|
|
499
|
+
const user = Aegis.storage.get('user');
|
|
500
|
+
|
|
501
|
+
// With fallback
|
|
502
|
+
const theme = Aegis.storage.get('theme', 'light');
|
|
503
|
+
|
|
504
|
+
// Remove
|
|
505
|
+
Aegis.storage.remove('user');
|
|
506
|
+
|
|
507
|
+
// Clear all
|
|
508
|
+
Aegis.storage.clear();
|
|
190
509
|
```
|
|
191
510
|
|
|
192
|
-
|
|
511
|
+
---
|
|
193
512
|
|
|
194
|
-
|
|
513
|
+
## 📜 Logging
|
|
514
|
+
|
|
515
|
+
```javascript
|
|
516
|
+
Aegis.log.info('Info message');
|
|
517
|
+
Aegis.log.success('Success message');
|
|
518
|
+
Aegis.log.warn('Warning message');
|
|
519
|
+
Aegis.log.error('Error message');
|
|
520
|
+
Aegis.log.debug('Debug message');
|
|
521
|
+
Aegis.log.table(data);
|
|
522
|
+
```
|
|
523
|
+
|
|
524
|
+
---
|
|
525
|
+
|
|
526
|
+
## ⏱️ Timing Utilities
|
|
527
|
+
|
|
528
|
+
```javascript
|
|
529
|
+
// Debounce (wait until user stops typing)
|
|
530
|
+
const search = Aegis.debounce((query) => {
|
|
531
|
+
fetchResults(query);
|
|
532
|
+
}, 300);
|
|
533
|
+
|
|
534
|
+
Aegis.input('#search', (e) => search(e.target.value));
|
|
535
|
+
|
|
536
|
+
// Throttle (max once per interval)
|
|
537
|
+
const scroll = Aegis.throttle(() => {
|
|
538
|
+
updatePosition();
|
|
539
|
+
}, 100);
|
|
540
|
+
|
|
541
|
+
Aegis.on(window, 'scroll', scroll);
|
|
542
|
+
|
|
543
|
+
// Delay (promise-based setTimeout)
|
|
544
|
+
await Aegis.delay(1000);
|
|
545
|
+
console.log('1 second later');
|
|
546
|
+
|
|
547
|
+
// Ready (DOM loaded)
|
|
548
|
+
Aegis.ready(() => {
|
|
549
|
+
console.log('DOM is ready!');
|
|
550
|
+
});
|
|
551
|
+
```
|
|
552
|
+
|
|
553
|
+
---
|
|
554
|
+
|
|
555
|
+
## 🔌 Backend API (Python Bridge)
|
|
556
|
+
|
|
557
|
+
### File Operations
|
|
558
|
+
|
|
559
|
+
```javascript
|
|
560
|
+
// Read directory
|
|
561
|
+
const dir = await Aegis.read({ path: '/home/user' });
|
|
562
|
+
|
|
563
|
+
// Read file
|
|
564
|
+
const file = await Aegis.read({ path: '/home', file: 'notes.txt' });
|
|
565
|
+
|
|
566
|
+
// Write file
|
|
567
|
+
await Aegis.write({ path: '/home', file: 'notes.txt', content: 'Hello!' });
|
|
568
|
+
|
|
569
|
+
// Check if exists
|
|
570
|
+
const info = await Aegis.exists({ path: '/home/user/file.txt' });
|
|
571
|
+
|
|
572
|
+
// Create directory
|
|
573
|
+
await Aegis.mkdir({ path: '/home/user/new-folder' });
|
|
574
|
+
|
|
575
|
+
// Delete file/folder
|
|
576
|
+
await Aegis.remove({ path: '/home/user/old-file.txt' });
|
|
577
|
+
|
|
578
|
+
// Copy
|
|
579
|
+
await Aegis.copy({ src: '/path/from', dest: '/path/to' });
|
|
580
|
+
|
|
581
|
+
// Move
|
|
582
|
+
await Aegis.move({ src: '/path/from', dest: '/path/to' });
|
|
583
|
+
```
|
|
584
|
+
|
|
585
|
+
### Downloads (with aria2c turbo!)
|
|
195
586
|
|
|
196
587
|
```javascript
|
|
197
|
-
// Basic download with progress
|
|
198
588
|
await Aegis.download(
|
|
199
589
|
{
|
|
200
|
-
url: 'https://example.com/
|
|
201
|
-
dest: '/home/user/
|
|
590
|
+
url: 'https://example.com/file.zip',
|
|
591
|
+
dest: '/home/user/file.zip',
|
|
592
|
+
connections: 16 // Multi-connection download!
|
|
202
593
|
},
|
|
203
594
|
(progress) => {
|
|
204
|
-
console.log(
|
|
205
|
-
console.log(
|
|
206
|
-
console.log(`Engine: ${progress.engine}`); // "aria2c" or "urllib"
|
|
595
|
+
console.log(progress.percent + '%');
|
|
596
|
+
console.log(progress.speed); // '5.2 MiB/s'
|
|
207
597
|
}
|
|
208
598
|
);
|
|
599
|
+
```
|
|
209
600
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
}
|
|
601
|
+
### Run Commands
|
|
602
|
+
|
|
603
|
+
```javascript
|
|
604
|
+
// Shell command
|
|
605
|
+
const result = await Aegis.run({ sh: 'ls -la' });
|
|
606
|
+
|
|
607
|
+
// Async command (UI doesn't freeze!)
|
|
608
|
+
await Aegis.runAsync(
|
|
609
|
+
{ sh: 'apt update' },
|
|
610
|
+
(progress) => console.log(progress.line)
|
|
221
611
|
);
|
|
222
612
|
```
|
|
223
613
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
614
|
+
### Dialogs
|
|
615
|
+
|
|
616
|
+
```javascript
|
|
617
|
+
// Message
|
|
618
|
+
await Aegis.dialog.message({
|
|
619
|
+
type: 'info', // info, warning, error, question
|
|
620
|
+
title: 'Hello',
|
|
621
|
+
message: 'World!'
|
|
622
|
+
});
|
|
623
|
+
|
|
624
|
+
// Open file
|
|
625
|
+
const file = await Aegis.dialog.open({
|
|
626
|
+
title: 'Select File',
|
|
627
|
+
filters: [{ name: 'Images', extensions: ['png', 'jpg'] }]
|
|
628
|
+
});
|
|
629
|
+
|
|
630
|
+
// Save file
|
|
631
|
+
const path = await Aegis.dialog.save({
|
|
632
|
+
title: 'Save As',
|
|
633
|
+
defaultName: 'document.txt'
|
|
634
|
+
});
|
|
635
|
+
```
|
|
636
|
+
|
|
637
|
+
### Window Control
|
|
638
|
+
|
|
639
|
+
```javascript
|
|
640
|
+
await Aegis.app.minimize();
|
|
641
|
+
await Aegis.app.maximize();
|
|
642
|
+
await Aegis.app.quit();
|
|
643
|
+
|
|
644
|
+
// For frameless windows
|
|
645
|
+
Aegis.window.moveBar('#titlebar', { exclude: '.btn' });
|
|
646
|
+
Aegis.window.resizeHandles({
|
|
647
|
+
'.resize-n': 'n', '.resize-se': 'se'
|
|
648
|
+
});
|
|
227
649
|
```
|
|
228
|
-
|
|
650
|
+
|
|
651
|
+
---
|
|
229
652
|
|
|
230
653
|
## 🔒 Security (preload.js)
|
|
231
654
|
|
|
232
|
-
Control which APIs are exposed
|
|
655
|
+
Control which APIs are exposed:
|
|
233
656
|
|
|
234
657
|
```javascript
|
|
235
658
|
// src/preload.js
|
|
@@ -243,36 +666,7 @@ Aegis.expose([
|
|
|
243
666
|
]);
|
|
244
667
|
```
|
|
245
668
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
```json
|
|
249
|
-
{
|
|
250
|
-
"name": "my-app",
|
|
251
|
-
"title": "My Application",
|
|
252
|
-
"version": "1.0.0",
|
|
253
|
-
"main": "src/index.html",
|
|
254
|
-
"preload": "src/preload.js",
|
|
255
|
-
"width": 1200,
|
|
256
|
-
"height": 800,
|
|
257
|
-
"frame": true,
|
|
258
|
-
"resizable": true,
|
|
259
|
-
"icon": "assets/icon.png"
|
|
260
|
-
}
|
|
261
|
-
```
|
|
262
|
-
|
|
263
|
-
Set `"frame": false` for frameless window (custom titlebar).
|
|
264
|
-
|
|
265
|
-
## 🤔 Why Aegis?
|
|
266
|
-
|
|
267
|
-
| Feature | Electron | Aegis |
|
|
268
|
-
|---------|----------|-------|
|
|
269
|
-
| Size | ~150 MB | **~200 KB** |
|
|
270
|
-
| Backend | Node.js | **Python** |
|
|
271
|
-
| Renderer | Chromium (bundled) | **WebKit2GTK (system)** |
|
|
272
|
-
| Platform | Cross-platform | **Linux** |
|
|
273
|
-
| RAM Usage | High | **Low** |
|
|
274
|
-
|
|
275
|
-
Aegis uses the WebKit that's already installed on Linux systems, so apps are tiny!
|
|
669
|
+
---
|
|
276
670
|
|
|
277
671
|
## 📜 License
|
|
278
672
|
|
|
@@ -280,4 +674,4 @@ MIT © Diego
|
|
|
280
674
|
|
|
281
675
|
---
|
|
282
676
|
|
|
283
|
-
Made with ❤️ for the Linux community
|
|
677
|
+
**Made with ❤️ for the Linux community**
|