@aegis-framework/artemis 0.4.1 → 0.5.1

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.
Files changed (37) hide show
  1. package/README.md +555 -96
  2. package/dist/artemis.browser.js +2 -2
  3. package/dist/artemis.browser.js.map +19 -18
  4. package/dist/artemis.js +2 -2
  5. package/dist/artemis.js.map +18 -17
  6. package/dist/types/DOM.d.ts +190 -207
  7. package/dist/types/DOM.d.ts.map +1 -1
  8. package/dist/types/Debug.d.ts +73 -2
  9. package/dist/types/Debug.d.ts.map +1 -1
  10. package/dist/types/FileSystem.d.ts +55 -38
  11. package/dist/types/FileSystem.d.ts.map +1 -1
  12. package/dist/types/Form.d.ts +41 -16
  13. package/dist/types/Form.d.ts.map +1 -1
  14. package/dist/types/Platform.d.ts +62 -63
  15. package/dist/types/Platform.d.ts.map +1 -1
  16. package/dist/types/Preload.d.ts +70 -11
  17. package/dist/types/Preload.d.ts.map +1 -1
  18. package/dist/types/Request.d.ts +111 -47
  19. package/dist/types/Request.d.ts.map +1 -1
  20. package/dist/types/Space.d.ts +19 -6
  21. package/dist/types/Space.d.ts.map +1 -1
  22. package/dist/types/SpaceAdapter/IndexedDB.d.ts +10 -7
  23. package/dist/types/SpaceAdapter/IndexedDB.d.ts.map +1 -1
  24. package/dist/types/SpaceAdapter/LocalStorage.d.ts +18 -8
  25. package/dist/types/SpaceAdapter/LocalStorage.d.ts.map +1 -1
  26. package/dist/types/SpaceAdapter/RemoteStorage.d.ts +15 -2
  27. package/dist/types/SpaceAdapter/RemoteStorage.d.ts.map +1 -1
  28. package/dist/types/SpaceAdapter/SessionStorage.d.ts +21 -2
  29. package/dist/types/SpaceAdapter/SessionStorage.d.ts.map +1 -1
  30. package/dist/types/SpaceAdapter/types.d.ts +32 -1
  31. package/dist/types/SpaceAdapter/types.d.ts.map +1 -1
  32. package/dist/types/Text.d.ts +34 -23
  33. package/dist/types/Text.d.ts.map +1 -1
  34. package/dist/types/Util.d.ts +18 -14
  35. package/dist/types/Util.d.ts.map +1 -1
  36. package/dist/types/browser.d.ts.map +1 -1
  37. package/package.json +10 -11
package/README.md CHANGED
@@ -1,168 +1,627 @@
1
1
  # Artemis
2
2
 
3
- Artemis is a JavaScript Library that aims to provide common utilities needed during development such as DOM manipulation, a wrapper for client based Storage and other functions that may be useful for web app development.
3
+ Artemis is a lightweight JavaScript/TypeScript library providing common utilities for web development including DOM manipulation, storage wrappers, HTTP requests, and platform detection.
4
4
 
5
- ## Using it
6
- Artemis is provided as a CommonJS, ES6 and global library.
5
+ ## Installation
7
6
 
8
- ### Browser
7
+ ```bash
8
+ # Using npm
9
+ npm install @aegis-framework/artemis
9
10
 
10
- ```html
11
- <script src='./artemis.min.js'></script>
12
- ```
11
+ # Using yarn
12
+ yarn add @aegis-framework/artemis
13
13
 
14
- ```javascript
15
- const { $_, Text } = Artemis;
14
+ # Using bun
15
+ bun add @aegis-framework/artemis
16
16
  ```
17
17
 
18
- ### ES6 Modules
18
+ ### ES Modules
19
19
 
20
20
  ```javascript
21
- import { $_, Text } from '@aegis-framework/artemis';
21
+ import { $_, Text, Space, SpaceAdapter } from '@aegis-framework/artemis';
22
22
  ```
23
23
 
24
- ### Node JS
24
+ ### Browser (Script Tag)
25
25
 
26
- ```javascript
27
- const { $_, Text } = require ('@aegis-framework/artemis');
26
+ ```html
27
+ <script src="path/to/artemis.browser.js"></script>
28
+ <script>
29
+ const { $_, Text, Space, SpaceAdapter } = Artemis;
30
+ </script>
28
31
  ```
29
32
 
30
-
31
- Below are some simple examples but you can read the full [documentation of each class](https://gitlab.com/AegisFramework/Artemis/tree/master/docs) for more details.
33
+ ---
32
34
 
33
35
  ## Classes
34
36
 
35
37
  ### DOM
36
- Artemis core library focuses on DOM manipulation, providing a jQuery-like experience and API
38
+
39
+ jQuery-like DOM manipulation with a modern API.
37
40
 
38
41
  ```javascript
39
- $_ready (()=> {
40
- $_('body').append ('<h1>Some Title</h1>');
41
- $_('h1').text ('A different title');
42
- $_('h1').style ('color', '#424242');
42
+ import { $_, $_ready, $_create } from '@aegis-framework/artemis';
43
+
44
+ $_ready(() => {
45
+ // Select and manipulate elements
46
+ $_('h1').text('Hello World').addClass('title');
47
+
48
+ // Chained operations
49
+ $_('.card')
50
+ .addClass('active')
51
+ .style({ 'background-color': '#fff', 'padding': '1rem' })
52
+ .fadeIn(400);
53
+
54
+ // Event handling
55
+ $_('button').click((e) => {
56
+ console.log('Button clicked!');
57
+ });
58
+
59
+ // Event delegation
60
+ $_('ul').on('click', 'li', (e) => {
61
+ console.log('List item clicked:', e.target);
62
+ });
63
+
64
+ // Removing event handlers
65
+ const handler = (e) => console.log('Clicked!');
66
+ $_('button').on('click', handler);
67
+ $_('button').off('click', handler); // Remove specific handler
68
+ $_('button').off('click'); // Remove all click handlers
69
+ $_('button').off(); // Remove all handlers
70
+
71
+ // Create new elements
72
+ const div = $_create('div', { class: 'container', id: 'main' });
73
+
74
+ // Traversal
75
+ $_('.item').parent().addClass('has-item');
76
+ $_('.item').siblings().removeClass('active');
77
+ $_('.item').next().addClass('following');
78
+
79
+ // Animations
80
+ $_('#box').fadeOut(400, () => console.log('Hidden'));
81
+ $_('#box').fadeIn(400, () => console.log('Visible'));
82
+ $_('#box').animate(
83
+ [{ transform: 'scale(1)' }, { transform: 'scale(1.2)' }],
84
+ { duration: 300, fill: 'forwards' }
85
+ );
43
86
  });
44
87
  ```
45
88
 
46
- ### Form
47
- Artemis also includes a small form utility class that helps with filling and retrieving values from a form.
89
+ #### Key Methods
90
+
91
+ | Method | Description |
92
+ |--------|-------------|
93
+ | `addClass(name)` | Add a class |
94
+ | `removeClass(name?)` | Remove class(es) |
95
+ | `toggleClass(names)` | Toggle space-separated classes |
96
+ | `hasClass(name)` | Check if all elements have class |
97
+ | `text(value?)` | Get/set text content |
98
+ | `html(value?)` | Get/set HTML content |
99
+ | `value(value?)` | Get/set form element value |
100
+ | `attribute(name, value?)` | Get/set attribute |
101
+ | `data(name, value?)` | Get/set data attributes |
102
+ | `style(prop, value?)` | Get/set inline styles |
103
+ | `on(event, callback)` | Add event listener |
104
+ | `on(event, selector, callback)` | Add delegated event listener |
105
+ | `off(event?, selectorOrCallback?, callback?)` | Remove event listener(s) |
106
+ | `trigger(event, detail?)` | Dispatch custom event |
107
+ | `find(selector)` | Find descendants |
108
+ | `closest(selector)` | Find closest ancestor |
109
+ | `parent()` | Get parent elements |
110
+ | `parents()` | Get all ancestors |
111
+ | `children()` | Get child elements |
112
+ | `siblings()` | Get sibling elements |
113
+ | `next()` | Get next sibling |
114
+ | `prev()` | Get previous sibling |
115
+ | `first()` | Get first element |
116
+ | `last()` | Get last element |
117
+ | `eq(index)` | Get element at index |
118
+ | `append(content)` | Append content |
119
+ | `prepend(content)` | Prepend content |
120
+ | `remove()` | Remove elements |
121
+ | `empty()` | Clear children |
122
+ | `clone(deep?)` | Clone elements |
123
+ | `fadeIn(duration, callback?)` | Fade in animation |
124
+ | `fadeOut(duration, callback?)` | Fade out animation |
125
+ | `animate(keyframes, options)` | Web Animations API |
126
+
127
+ ---
48
128
 
49
- ```html
50
- <form data-form="MyForm">
51
- <input type="text" name="SomeInput">
52
- <input type="text" name="OtherInput">
53
- </form>
54
- ```
129
+ ### Space
130
+
131
+ Storage wrapper with namespacing, versioning, and multiple backend adapters.
55
132
 
56
133
  ```javascript
57
- Form.fill ('MyForm', {
58
- 'SomeInput': 'Here is some Value',
59
- 'OtherInput': 'And here’s another one'
134
+ import { Space, SpaceAdapter } from '@aegis-framework/artemis';
135
+
136
+ // LocalStorage adapter
137
+ const storage = new Space(SpaceAdapter.LocalStorage, {
138
+ name: 'MyApp',
139
+ version: '1.0.0'
60
140
  });
61
141
 
62
- console.log (Form.values ('MyForm'));
142
+ await storage.open();
143
+
144
+ // Basic operations
145
+ await storage.set('user', { name: 'John', age: 30 });
146
+ const user = await storage.get('user');
147
+ await storage.update('user', { age: 31 }); // Merges with existing
148
+ await storage.remove('user');
149
+ await storage.clear();
150
+
151
+ // Get all data
152
+ const allData = await storage.getAll();
153
+ const keys = await storage.keys();
154
+
155
+ // Iterate
156
+ await storage.each((key, value) => {
157
+ console.log(key, value);
158
+ });
159
+
160
+ // Check existence
161
+ await storage.contains('user'); // Resolves if exists, rejects if not
162
+
163
+ // Callbacks
164
+ storage.onCreate((key, value) => console.log('Created:', key));
165
+ storage.onUpdate((key, value) => console.log('Updated:', key));
166
+ storage.onDelete((key, value) => console.log('Deleted:', key));
167
+
168
+ // Transformations (modify data on get/set)
169
+ storage.addTransformation({
170
+ id: 'timestamps',
171
+ set: (key, value) => ({ ...value, updatedAt: Date.now() }),
172
+ get: (key, value) => value
173
+ });
63
174
  ```
64
175
 
65
- ### Space
176
+ #### Adapters
66
177
 
67
- The Space Library is a wrapper for simple storage solutions as Local and Session storage but provides data independence through storage namespaces and versioning.
178
+ **LocalStorage** - Persistent browser storage
179
+ ```javascript
180
+ new Space(SpaceAdapter.LocalStorage, { name: 'App', version: '1.0.0' });
181
+ ```
68
182
 
183
+ **SessionStorage** - Session-only storage
69
184
  ```javascript
70
- let space = new Space (SpaceAdapter.LocalStorage, {
71
- name: 'Storage',
72
- version: '0.1.0'
73
- });
185
+ new Space(SpaceAdapter.SessionStorage, { name: 'App', version: '1.0.0' });
186
+ ```
74
187
 
75
- space.set ('Test', {
76
- value: 'Some Value'
77
- }).then (({key, value}) => {
78
- console.log ('The value was inserted correctly!');
188
+ **IndexedDB** - Large-scale structured storage
189
+ ```javascript
190
+ new Space(SpaceAdapter.IndexedDB, {
191
+ name: 'App',
192
+ version: '1.0.0',
193
+ store: 'users',
194
+ props: { keyPath: 'id', autoIncrement: true },
195
+ index: {
196
+ email: { name: 'Email Index', field: 'email', props: { unique: true } }
197
+ }
79
198
  });
199
+ ```
80
200
 
81
- space.get ('Test').then ((value) => {
82
- return value;
83
- }).then (({key, value}) => {
84
- console.log (value);
201
+ **RemoteStorage** - REST API backend
202
+ ```javascript
203
+ new Space(SpaceAdapter.RemoteStorage, {
204
+ name: 'App',
205
+ version: '1.0.0',
206
+ endpoint: 'https://api.example.com/',
207
+ store: 'users'
85
208
  });
209
+ ```
210
+
211
+ #### Version Upgrades
86
212
 
87
- space = new Space (SpaceAdapter.LocalStorage, {
88
- name: 'Storage',
89
- version: '0.1.1'
213
+ ```javascript
214
+ const storage = new Space(SpaceAdapter.LocalStorage, {
215
+ name: 'App',
216
+ version: '2.0.0'
90
217
  });
91
218
 
92
- space.upgrade ('0.1.0', '0.1.1', (storage) => {
93
- return storage.set ('Test', {
94
- value: 'Other Value'
95
- });
219
+ // Define upgrades before opening
220
+ await storage.upgrade('1.0.0', '2.0.0', async (adapter) => {
221
+ const oldData = await adapter.get('config');
222
+ await adapter.set('config', { ...oldData, newField: 'value' });
96
223
  });
224
+
225
+ await storage.open(); // Upgrades run automatically
97
226
  ```
98
227
 
228
+ ---
229
+
99
230
  ### Request
100
- The request library provides a simple way to send HTTP requests using the fetch API.
231
+
232
+ HTTP client built on the Fetch API with timeout support and error handling.
101
233
 
102
234
  ```javascript
103
- Request.get ('https://example.com/api/', {
104
- 'someQueryParam': 'Some Query Value!'
105
- }).then ((response) => {
106
- return response.text ();
107
- }).then ((text) => {
108
- console.log (text);
235
+ import { Request, RequestError, RequestTimeoutError } from '@aegis-framework/artemis';
236
+
237
+ // GET request
238
+ const response = await Request.get('https://api.example.com/users', {
239
+ page: 1,
240
+ limit: 10
109
241
  });
110
242
 
111
- Request.post ('https://example.com/api/', {
112
- 'someKey': 'Some Value!'
113
- }).then ((response) => {
114
- return response.text ();
115
- }).then ((text) => {
116
- console.log (text);
243
+ // POST with JSON
244
+ const created = await Request.postJson('https://api.example.com/users', {
245
+ name: 'John',
246
+ email: 'john@example.com'
117
247
  });
248
+
249
+ // PUT, PATCH, DELETE
250
+ await Request.put(url, data);
251
+ await Request.patch(url, data);
252
+ await Request.delete(url);
253
+
254
+ // HEAD request (check if resource exists)
255
+ const exists = await Request.exists('https://api.example.com/users/1');
256
+
257
+ // With timeout
258
+ const data = await Request.json('https://api.example.com/slow', {}, {
259
+ timeout: 5000 // 5 seconds
260
+ });
261
+
262
+ // Different response types
263
+ const json = await Request.json(url);
264
+ const text = await Request.text(url);
265
+ const blob = await Request.blob(url);
266
+ const buffer = await Request.arrayBuffer(url);
267
+
268
+ // Custom headers
269
+ await Request.post(url, data, {
270
+ headers: {
271
+ 'Authorization': 'Bearer token',
272
+ 'Content-Type': 'application/json'
273
+ }
274
+ });
275
+
276
+ // Error handling
277
+ try {
278
+ const data = await Request.json(url);
279
+ } catch (error) {
280
+ if (error instanceof RequestError) {
281
+ console.log('HTTP Error:', error.status, error.statusText);
282
+ } else if (error instanceof RequestTimeoutError) {
283
+ console.log('Request timed out');
284
+ }
285
+ }
286
+
287
+ // Serialize data to query string
288
+ const query = Request.serialize({ name: 'John', tags: ['a', 'b'] });
118
289
  ```
119
290
 
120
- ### Platform
121
- The platform library provides several utility methods to obtain information about the platform in which the code is running.
291
+ ---
292
+
293
+ ### Form
294
+
295
+ Form filling and value retrieval utilities.
296
+
297
+ ```html
298
+ <form data-form="UserForm">
299
+ <input type="text" name="username">
300
+ <input type="email" name="email">
301
+ <input type="number" name="age">
302
+ <input type="checkbox" name="newsletter">
303
+ <select name="country">
304
+ <option value="us">USA</option>
305
+ <option value="uk">UK</option>
306
+ </select>
307
+ </form>
308
+ ```
122
309
 
123
310
  ```javascript
124
- if (Platform.mobile ('Android')) {
125
- console.log ('You are running this on Android!');
126
- } else if (Platform.mobile ()) {
127
- console.log ('You are running this on some kind of mobile device!');
128
- } else if (Platform.desktop ('macOS')) {
129
- console.log ('You are running this on a Mac!');
130
- }
311
+ import { Form } from '@aegis-framework/artemis';
312
+
313
+ // Fill form with data
314
+ Form.fill('UserForm', {
315
+ username: 'john_doe',
316
+ email: 'john@example.com',
317
+ age: 30,
318
+ newsletter: true,
319
+ country: 'us'
320
+ });
321
+
322
+ // Get form values with type parsing
323
+ const values = Form.values('UserForm', {
324
+ parseNumbers: true, // Parse number inputs as numbers
325
+ parseBooleans: true // Parse single checkboxes as booleans
326
+ });
327
+ // { username: 'john_doe', email: '...', age: 30, newsletter: true, country: 'us' }
131
328
 
132
- if (Platform.electron ()) {
133
- console.log ('You are running this on a Electron!');
134
- } else if (Platform.cordova ()) {
135
- console.log ('You are running this on a Cordova!');
329
+ // Reset form
330
+ Form.reset('UserForm');
331
+
332
+ // Validation
333
+ if (Form.isValid('UserForm')) {
334
+ // Submit form
136
335
  }
336
+
337
+ // Show validation messages
338
+ Form.reportValidity('UserForm');
339
+ ```
340
+
341
+ ---
342
+
343
+ ### Platform
344
+
345
+ Platform and feature detection.
346
+
347
+ ```javascript
348
+ import { Platform } from '@aegis-framework/artemis';
349
+
350
+ // Device type
351
+ Platform.desktop(); // true if desktop
352
+ Platform.desktop('macOS'); // true if macOS
353
+ Platform.desktop('Windows'); // true if Windows
354
+ Platform.desktop('Linux'); // true if Linux
355
+
356
+ Platform.mobile(); // true if any mobile
357
+ Platform.mobile('iOS'); // true if iPhone/iPod
358
+ Platform.mobile('iPadOS'); // true if iPad
359
+ Platform.mobile('Android'); // true if Android
360
+
361
+ // Display
362
+ Platform.orientation; // 'portrait' | 'landscape'
363
+ Platform.portrait; // true if portrait
364
+ Platform.landscape; // true if landscape
365
+ Platform.retina; // true if high DPI display
366
+
367
+ // Input
368
+ Platform.touch; // true if touch supported
369
+ Platform.canHover; // true if hover supported
370
+ Platform.coarsePointer; // true if touch is primary
371
+ Platform.finePointer; // true if mouse is primary
372
+
373
+ // User preferences
374
+ Platform.darkMode; // true if dark mode preferred
375
+ Platform.reducedMotion; // true if reduced motion preferred
376
+
377
+ // Runtime environment
378
+ Platform.electron; // true if Electron
379
+ Platform.cordova; // true if Cordova/PhoneGap
380
+ Platform.standalone; // true if installed PWA
381
+
382
+ // Features
383
+ Platform.serviceWorkers; // true if service workers supported
137
384
  ```
138
385
 
386
+ ---
387
+
139
388
  ### Text
140
- The text library provides simple utility methods to perform text transformations or other text related functions.
389
+
390
+ Text transformation utilities.
141
391
 
142
392
  ```javascript
143
- console.log (Text.capitalize ('is this text capitalized?'));
144
- // Logs: Is This Text Capitalized?
393
+ import { Text } from '@aegis-framework/artemis';
394
+
395
+ // Capitalize words
396
+ Text.capitalize('hello world'); // 'Hello World'
397
+ Text.capitalize('API docs', { preserveCase: true }); // 'API Docs'
398
+
399
+ // URL-friendly slug
400
+ Text.friendly('Hello World!'); // 'hello-world'
401
+ Text.friendly('Café Münich'); // 'cafe-munich'
145
402
 
146
- console.log (Text.suffix ('Hello', 'Hello how are you?'));
147
- // Logs: how are you?
403
+ // Truncate with ellipsis
404
+ Text.truncate('Long text here', 10); // 'Long te...'
405
+ Text.truncate('Long text', 10, '…'); // 'Long text'
148
406
 
149
- console.log (Text.prefix ('how are you?', 'Hello how are you?'));
150
- // Logs: Hello
407
+ // Extract parts
408
+ Text.prefix('@', 'user@example.com'); // 'user'
409
+ Text.suffix('@', 'user@example.com'); // 'example.com'
410
+
411
+ // Check for blank
412
+ Text.isBlank(''); // true
413
+ Text.isBlank(' '); // true
414
+ Text.isBlank(null); // true
415
+ Text.isBlank('text'); // false
416
+
417
+ // Get selected text
418
+ const selected = Text.selection();
151
419
  ```
152
420
 
421
+ ---
422
+
423
+ ### FileSystem
424
+
425
+ File operations and utilities.
426
+
427
+ ```javascript
428
+ import { FileSystem } from '@aegis-framework/artemis';
429
+
430
+ // Read local file
431
+ const text = await FileSystem.read(file, 'text');
432
+ const base64 = await FileSystem.read(file, 'base64');
433
+ const buffer = await FileSystem.read(file, 'buffer');
434
+ const binary = await FileSystem.read(file, 'binary');
435
+
436
+ // Read remote file
437
+ const content = await FileSystem.readRemote('https://example.com/file.txt', 'text');
438
+
439
+ // Create and download file
440
+ const file = FileSystem.create('data.json', JSON.stringify(data), 'application/json');
441
+ FileSystem.download(file);
442
+ FileSystem.download(blob, 'custom-name.txt');
443
+
444
+ // File type checks
445
+ FileSystem.isImage('photo.jpg'); // true
446
+ FileSystem.isVideo('movie.mp4'); // true
447
+ FileSystem.isAudio('song.mp3'); // true
448
+ FileSystem.extension('file.txt'); // 'txt'
449
+
450
+ // Human-readable size
451
+ FileSystem.humanSize(1536); // '1.5 KB'
452
+ FileSystem.humanSize(1048576); // '1 MB'
453
+ ```
454
+
455
+ ---
456
+
153
457
  ### Util
154
- The util library provides diverse methods that could be useful for some applications
458
+
459
+ General utilities.
155
460
 
156
461
  ```javascript
157
- console.log (Util.uuid ());
158
- // Logs: Some UUID such as 116a7d96-8c6c-46ee-a9e1-3c7183e691b5
462
+ import { Util } from '@aegis-framework/artemis';
463
+
464
+ // Generate UUID v4
465
+ const id = Util.uuid(); // 'f47ac10b-58cc-4372-a567-0e02b2c3d479'
466
+
467
+ // Ensure async execution
468
+ await Util.callAsync(someFunction, context, arg1, arg2);
469
+
470
+ // Debounce (delay until quiet period)
471
+ const debouncedSearch = Util.debounce((query) => {
472
+ fetch(`/search?q=${query}`);
473
+ }, 300);
474
+
475
+ input.addEventListener('input', (e) => debouncedSearch(e.target.value));
476
+
477
+ // Throttle (limit call frequency)
478
+ const throttledScroll = Util.throttle(() => {
479
+ console.log('Scroll position:', window.scrollY);
480
+ }, 100);
481
+
482
+ window.addEventListener('scroll', throttledScroll);
483
+ ```
484
+
485
+ ---
486
+
487
+ ### Debug
159
488
 
160
- function test () {
161
- console.log ('A simple Function');
489
+ Conditional console logging with debug levels.
490
+
491
+ ```javascript
492
+ import { Debug, DebugLevel } from '@aegis-framework/artemis';
493
+
494
+ // Set debug level
495
+ Debug.setLevel(DebugLevel.DEBUG); // Show all logs
496
+ Debug.setLevel(DebugLevel.ERROR); // Only errors
497
+ Debug.setLevel(DebugLevel.NONE); // Silent
498
+
499
+ // Levels: NONE < ERROR < WARNING < INFO < DEBUG < ALL
500
+
501
+ // Logging (respects debug level)
502
+ Debug.log('General log'); // DEBUG+
503
+ Debug.debug('Debug info'); // DEBUG+
504
+ Debug.info('Information'); // INFO+
505
+ Debug.warning('Warning!'); // WARNING+
506
+ Debug.warn('Also warning'); // WARNING+
507
+ Debug.error('Error!'); // ERROR+
508
+
509
+ // Assertions
510
+ Debug.assert(value > 0, 'Value must be positive');
511
+
512
+ // Grouping
513
+ Debug.group('Network requests');
514
+ Debug.log('Request 1');
515
+ Debug.log('Request 2');
516
+ Debug.groupEnd();
517
+
518
+ Debug.groupCollapsed('Collapsed group');
519
+ Debug.log('Hidden by default');
520
+ Debug.groupEnd();
521
+
522
+ // Tables
523
+ Debug.table([{ name: 'Alice', age: 25 }, { name: 'Bob', age: 30 }]);
524
+
525
+ // Timing
526
+ Debug.time('Operation');
527
+ // ... do work ...
528
+ Debug.timeLog('Operation', 'still running...');
529
+ // ... more work ...
530
+ Debug.timeEnd('Operation'); // Logs: Operation: 123.45ms
531
+
532
+ // Counting
533
+ Debug.count('myFunction called'); // myFunction called: 1
534
+ Debug.count('myFunction called'); // myFunction called: 2
535
+ Debug.countReset('myFunction called');
536
+
537
+ // Object inspection
538
+ Debug.dir(complexObject);
539
+ Debug.dirxml(htmlElement);
540
+
541
+ // Clear console
542
+ Debug.clear();
543
+
544
+ // Check level
545
+ if (Debug.isEnabled(DebugLevel.DEBUG)) {
546
+ // Expensive debug operation
162
547
  }
548
+ ```
163
549
 
164
- Util.callAsync (test).then (() => {
165
- console.log ('Test was executed and a promise was inserted so test behaves like a function using promises');
166
- });
550
+ ---
551
+
552
+ ### Preload
553
+
554
+ Asset preloading utilities.
555
+
556
+ ```javascript
557
+ import { Preload } from '@aegis-framework/artemis';
558
+
559
+ // Preload single image
560
+ const img = await Preload.image('/assets/hero.jpg');
561
+ document.body.appendChild(img);
562
+
563
+ // Preload multiple images
564
+ const images = await Preload.images([
565
+ '/assets/1.jpg',
566
+ '/assets/2.jpg',
567
+ '/assets/3.jpg'
568
+ ]);
569
+
570
+ // Preload files with priority hint
571
+ await Preload.file('/data/config.json', 'high');
572
+ await Preload.files(['/a.js', '/b.js'], 'low');
573
+
574
+ // Preload specific asset types
575
+ await Preload.stylesheet('/styles/main.css');
576
+ await Preload.script('/js/vendor.js');
577
+ await Preload.font('/fonts/custom.woff2');
578
+
579
+ // Cache API integration
580
+ const isCached = await Preload.isCached('my-cache', '/assets/image.jpg');
581
+ await Preload.addToCache('my-cache', '/assets/image.jpg');
582
+ await Preload.addAllToCache('my-cache', ['/a.js', '/b.js', '/c.css']);
583
+ ```
584
+
585
+ ---
586
+
587
+ ## TypeScript Support
588
+
589
+ Artemis is written in TypeScript and includes full type definitions.
590
+
591
+ ```typescript
592
+ import {
593
+ $_,
594
+ DOM,
595
+ Space,
596
+ SpaceAdapter,
597
+ Request,
598
+ Platform,
599
+ Text,
600
+ FileSystem,
601
+ Form,
602
+ Util,
603
+ Debug,
604
+ DebugLevel,
605
+ Preload
606
+ } from '@aegis-framework/artemis';
607
+
608
+ import type {
609
+ SpaceConfiguration,
610
+ DesktopPlatform,
611
+ MobilePlatform,
612
+ Orientation,
613
+ FileReadType,
614
+ CapitalizeOptions
615
+ } from '@aegis-framework/artemis';
616
+
617
+ const config: SpaceConfiguration = {
618
+ name: 'MyApp',
619
+ version: '1.0.0'
620
+ };
621
+
622
+ const storage = new Space(SpaceAdapter.LocalStorage, config);
623
+ ```
624
+
625
+ ## License
167
626
 
168
- ```
627
+ MIT License - See [LICENSE](LICENSE) for details.