@aegis-framework/artemis 0.4.1 → 0.5.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.
Files changed (36) hide show
  1. package/README.md +547 -96
  2. package/dist/artemis.browser.js +2 -2
  3. package/dist/artemis.browser.js.map +18 -17
  4. package/dist/artemis.js +2 -2
  5. package/dist/artemis.js.map +18 -17
  6. package/dist/types/DOM.d.ts +189 -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/package.json +3 -4
@@ -20,6 +20,10 @@ export declare enum DebugLevel {
20
20
  */
21
21
  export declare class Debug {
22
22
  private static _level;
23
+ /**
24
+ * Get the current debug level
25
+ */
26
+ static get currentLevel(): DebugLevel;
23
27
  /**
24
28
  * Set or get the log level
25
29
  *
@@ -27,6 +31,18 @@ export declare class Debug {
27
31
  * @returns The current debug level
28
32
  */
29
33
  static level(level?: DebugLevel): DebugLevel;
34
+ /**
35
+ * Set the debug level
36
+ *
37
+ * @param level - The debug level to set
38
+ */
39
+ static setLevel(level: DebugLevel): void;
40
+ /**
41
+ * Check if a specific level is enabled
42
+ *
43
+ * @param level - The level to check
44
+ */
45
+ static isEnabled(level: DebugLevel): boolean;
30
46
  /**
31
47
  * Log the given elements.
32
48
  * Logs will only be made if the level is set to DEBUG or above
@@ -62,13 +78,20 @@ export declare class Debug {
62
78
  * @param args - Arguments to log
63
79
  */
64
80
  static warning(...args: unknown[]): void;
81
+ /**
82
+ * Alias for warning()
83
+ *
84
+ * @param args - Arguments to log
85
+ */
86
+ static warn(...args: unknown[]): void;
65
87
  /**
66
88
  * Show data as a table
67
89
  * Table will only be made if the level is set to DEBUG or above
68
90
  *
69
- * @param args - Arguments to display as table
91
+ * @param data - Data to display as table
92
+ * @param columns - Optional column names to include
70
93
  */
71
- static table(...args: unknown[]): void;
94
+ static table(data: unknown, columns?: string[]): void;
72
95
  /**
73
96
  * Start an indented group
74
97
  *
@@ -114,5 +137,53 @@ export declare class Debug {
114
137
  * @param args - Arguments to log with trace
115
138
  */
116
139
  static trace(...args: unknown[]): void;
140
+ /**
141
+ * Log a message if a condition is false
142
+ * Only logs if the level is set to ERROR or above
143
+ *
144
+ * @param condition - Condition to check
145
+ * @param args - Arguments to log if condition is false
146
+ */
147
+ static assert(condition: boolean, ...args: unknown[]): void;
148
+ /**
149
+ * Clear the console
150
+ * Only clears if the level is set to DEBUG or above
151
+ */
152
+ static clear(): void;
153
+ /**
154
+ * Increment a counter with the given label
155
+ * Only counts if the level is set to DEBUG or above
156
+ *
157
+ * @param label - Counter label
158
+ */
159
+ static count(label?: string): void;
160
+ /**
161
+ * Reset a counter with the given label
162
+ * Only resets if the level is set to DEBUG or above
163
+ *
164
+ * @param label - Counter label
165
+ */
166
+ static countReset(label?: string): void;
167
+ /**
168
+ * Display an interactive listing of the properties of an object
169
+ * Only displays if the level is set to DEBUG or above
170
+ *
171
+ * @param data - Object to display
172
+ */
173
+ static dir(data: unknown): void;
174
+ /**
175
+ * Display XML/HTML element representation
176
+ * Only displays if the level is set to DEBUG or above
177
+ *
178
+ * @param data - Element to display
179
+ */
180
+ static dirxml(data: unknown): void;
181
+ /**
182
+ * Create a formatted string with substitution values
183
+ *
184
+ * @param format - Format string
185
+ * @param args - Substitution values
186
+ */
187
+ static format(format: string, ...args: unknown[]): string;
117
188
  }
118
189
  //# sourceMappingURL=Debug.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Debug.d.ts","sourceRoot":"","sources":["../../src/Debug.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH;;GAEG;AACH,oBAAY,UAAU;IACrB,IAAI,IAAI;IACR,KAAK,IAAI;IACT,OAAO,IAAI;IACX,IAAI,IAAI;IACR,KAAK,IAAI;IACT,GAAG,IAAI;CACP;AAED;;;GAGG;AACH,qBAAa,KAAK;IACjB,OAAO,CAAC,MAAM,CAAC,MAAM,CAA+B;IAEpD;;;;;OAKG;IACH,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,UAAU,GAAG,UAAU;IAO5C;;;;;OAKG;IACH,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAMpC;;;;;OAKG;IACH,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAMtC;;;;;OAKG;IACH,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,EAAE,OAA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IACH,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAMxD;;;;;OAKG;IACH,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI;IAMpC;;;;;OAKG;IACH,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAMtC;;;;;;OAMG;IACH,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAM3D;;;OAGG;IACH,MAAM,CAAC,KAAK,IAAI,IAAI;IAMpB;;;;;OAKG;IACH,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI;IAMlC;;;;;OAKG;IACH,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI;IAMvC;;;;;OAKG;IACH,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI;IAM/B;;;;;OAKG;IACH,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI;IAMlC;;;;;OAKG;IACH,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,MAAM;CAwBzD"}
@@ -4,66 +4,83 @@
4
4
  * ==============================
5
5
  */
6
6
  import { RequestOptions } from './Request';
7
+ export type FileReadType = 'text' | 'base64' | 'buffer' | 'binary';
7
8
  /**
8
- * File read type options
9
- */
10
- export type FileReadType = 'text' | 'base64' | 'buffer';
11
- /**
12
- * File read result type based on read type
9
+ * Return type mapping for file read operations
13
10
  */
14
11
  export interface FileReadResult {
15
- event: ProgressEvent<FileReader>;
16
- content: string | ArrayBuffer | null;
12
+ text: string;
13
+ base64: string;
14
+ buffer: ArrayBuffer;
15
+ binary: string;
17
16
  }
18
17
  /**
19
- * A simple class wrapper for the File and FileReader web API, while this class
20
- * doesn't actually provide access to the host file system, it does provide useful
21
- * utilities for form file inputs and remote content loading.
18
+ * A utility wrapper for File/Blob operations
22
19
  */
23
20
  export declare class FileSystem {
24
21
  /**
25
- * Read a file from a remote location given a URL. This function will fetch
26
- * the file blob using the Request class and then use the read() function
27
- * to read the blob in the format required.
22
+ * Read a file from a remote URL.
28
23
  *
29
- * @param url - URL to fetch the file from
30
- * @param type - Type of data to be read, values can be 'text', 'base64' and 'buffer'
31
- * @param props - Props to send to the Request object
32
- * @returns Content of the file. The format depends on the type parameter used.
24
+ * @param url - The URL to fetch
25
+ * @param type - The format to return ('text', 'base64', 'buffer', 'binary')
26
+ * @param options - Request options
33
27
  */
34
- static readRemote(url: string, type?: FileReadType, props?: RequestOptions): Promise<FileReadResult>;
28
+ static readRemote<T extends FileReadType>(url: string, type?: T, options?: RequestOptions): Promise<FileReadResult[T]>;
35
29
  /**
36
- * Read a given File or Blob object.
30
+ * Read a local File or Blob.
37
31
  *
38
- * @param file - File to read
39
- * @param type - Type of data to be read, values can be 'text', 'base64' and 'buffer'
40
- * @returns Promise that resolves to the load event and content of the file
32
+ * @param file - The File or Blob to read
33
+ * @param type - The format to return
41
34
  */
42
- static read(file: File | Blob, type?: FileReadType): Promise<FileReadResult>;
35
+ static read<T extends FileReadType>(file: File | Blob, type?: T): Promise<FileReadResult[T]>;
43
36
  /**
44
- * Create a new File, this uses the File API and will not actually create
45
- * a file in the user's file system, however using it with other features,
46
- * that may be possible
37
+ * Create a File object.
38
+ * This is a synchronous operation.
47
39
  *
48
- * @param name - Name of the file (Including extension)
49
- * @param content - Content to save in the file
50
- * @param type - Mime Type for the file
51
- * @returns Promise resolving to the created File
40
+ * @param name - Filename
41
+ * @param content - Data (String, Blob, ArrayBuffer)
42
+ * @param mimeType - MIME type (e.g. 'application/json')
52
43
  */
53
- static create(name: string, content: BlobPart, type?: string): Promise<File>;
44
+ static create(name: string, content: BlobPart, mimeType?: string): File;
54
45
  /**
55
- * Returns the extension of a file given its file name.
46
+ * Trigger a browser download for a specific File or Blob.
47
+ * This will creates a temporary anchor tag to force the download.
56
48
  *
57
- * @param name - Name or full path of the file
58
- * @returns File extension without the leading dot (.)
49
+ * @param file - The file to download
50
+ * @param name - Optional rename for the downloaded file
59
51
  */
60
- static extension(name: string): string;
52
+ static download(file: File | Blob, name?: string): void;
61
53
  /**
62
- * Check if a file is an image by its extension.
54
+ * Get the file extension safely
63
55
  *
64
- * @param name - Name or full path of the file
65
- * @returns Whether the file is an image
56
+ * @param name - Filename or path
57
+ * @returns Lowercase extension without the dot, or empty string
58
+ */
59
+ static extension(name: string, allowHiddenFiles?: boolean): string;
60
+ /**
61
+ * Check if a file is an image based on extension.
62
+ *
63
+ * @param name - Filename to check
66
64
  */
67
65
  static isImage(name: string): boolean;
66
+ /**
67
+ * Check if a file is a video based on extension.
68
+ *
69
+ * @param name - Filename to check
70
+ */
71
+ static isVideo(name: string): boolean;
72
+ /**
73
+ * Check if a file is audio based on extension.
74
+ *
75
+ * @param name - Filename to check
76
+ */
77
+ static isAudio(name: string): boolean;
78
+ /**
79
+ * Convert bytes to human-readable size.
80
+ *
81
+ * @param bytes - Size in bytes
82
+ * @param decimals - Number of decimal places
83
+ */
84
+ static humanSize(bytes: number, decimals?: number): string;
68
85
  }
69
86
  //# sourceMappingURL=FileSystem.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"FileSystem.d.ts","sourceRoot":"","sources":["../../src/FileSystem.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAW,cAAc,EAAE,MAAM,WAAW,CAAC;AAEpD;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAExD;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B,KAAK,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;IACjC,OAAO,EAAE,MAAM,GAAG,WAAW,GAAG,IAA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;IAK7B;;;;;OAKG;WACU,IAAI,CAAC,CAAC,SAAS,YAAY,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,IAAI,GAAE,CAAe,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;IAwC/G;;;;;;;OAOG;IACH,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,GAAE,MAAqB,GAAG,IAAI;IAIrF;;;;;;OAMG;IACH,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI;IAyBvD;;;;;OAKG;IACH,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,gBAAgB,GAAE,OAAe,GAAG,MAAM;IAWzE;;;;OAIG;IACH,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IASrC;;;;OAIG;IACH,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAQrC;;;;OAIG;IACH,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAQrC;;;;;OAKG;IACH,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAU,GAAG,MAAM;CAS9D"}
@@ -3,30 +3,55 @@
3
3
  * Form
4
4
  * ==============================
5
5
  */
6
+ export type FormValue = string | number | boolean | File | null;
7
+ export type FormValues = Record<string, FormValue | FormValue[]>;
6
8
  /**
7
- * Form data object type
8
- */
9
- export type FormData = Record<string, string | File | FileList | undefined>;
10
- /**
11
- * Utility class that provides simple functions for filling and retrieving values
12
- * from forms. This class requires the use of the `data-form` attribute.
9
+ * Options for parsing form values
13
10
  */
11
+ export interface FormParseOptions {
12
+ parseNumbers?: boolean;
13
+ parseBooleans?: boolean;
14
+ }
14
15
  export declare class Form {
15
16
  /**
16
- * Fill a form's inputs with the given values. Each key in the provided object
17
- * must match the `name` attribute of the input to fill.
17
+ * Fill a form with data.
18
+ *
19
+ * @param formName - The data-form attribute value
20
+ * @param data - Key-value pairs to fill
21
+ */
22
+ static fill(formName: string, data: Record<string, unknown>): void;
23
+ /**
24
+ * Get all values from a form.
25
+ *
26
+ * @param formName - The data-form attribute value
27
+ * @param options - Parsing options
28
+ * @returns Form values as a record
29
+ */
30
+ static values(formName: string, options?: FormParseOptions): FormValues;
31
+ /**
32
+ * Parse a string value, optionally converting to number.
33
+ *
34
+ * @param value - String value to parse
35
+ * @param parseNumbers - Whether to parse numeric strings
36
+ */
37
+ private static parseValue;
38
+ /**
39
+ * Reset a form to its initial state.
40
+ *
41
+ * @param formName - The data-form attribute value
42
+ */
43
+ static reset(formName: string): void;
44
+ /**
45
+ * Check if a form is valid according to HTML5 validation.
18
46
  *
19
- * @param name - Form name. Must match the `data-form` attribute of the Form.
20
- * @param data - JSON object with key-value pairs to fill the inputs.
47
+ * @param formName - The data-form attribute value
21
48
  */
22
- static fill(name: string, data: Record<string, string>): void;
49
+ static isValid(formName: string): boolean;
23
50
  /**
24
- * Get all the values from a form's inputs. The keys are mapped using the
25
- * `name` attribute of each input.
51
+ * Report validity and show browser validation messages.
26
52
  *
27
- * @param name - Form name. Must match the `data-form` attribute of the Form.
28
- * @returns Key-value JSON object
53
+ * @param formName - The data-form attribute value
29
54
  */
30
- static values(name: string): FormData;
55
+ static reportValidity(formName: string): boolean;
31
56
  }
32
57
  //# sourceMappingURL=Form.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Form.d.ts","sourceRoot":"","sources":["../../src/Form.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,QAAQ,GAAG,SAAS,CAAC,CAAC;AAE5E;;;GAGG;AACH,qBAAa,IAAI;IAChB;;;;;;OAMG;IACH,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;IAkB7D;;;;;;OAMG;IACH,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ;CAwBrC"}
1
+ {"version":3,"file":"Form.d.ts","sourceRoot":"","sources":["../../src/Form.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,IAAI,CAAC;AAChE,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,EAAE,CAAC,CAAC;AAEjE;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,qBAAa,IAAI;IAEf;;;;;OAKG;IACH,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAoDlE;;;;;;OAMG;IACH,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,gBAAqB,GAAG,UAAU;IAiE3E;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,UAAU;IAOzB;;;;OAIG;IACH,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAWpC;;;;OAIG;IACH,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAWzC;;;;OAIG;IACH,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;CAUjD"}
@@ -3,91 +3,90 @@
3
3
  * Platform
4
4
  * ==============================
5
5
  */
6
- /**
7
- * Desktop platform types
8
- */
9
- export type DesktopPlatform = 'Windows' | 'macOS' | 'Linux' | 'FreeBSD' | 'webOS' | 'Any';
10
- /**
11
- * Mobile platform types
12
- */
13
- export type MobilePlatform = 'Android' | 'iOS' | 'Opera' | 'Windows' | 'BlackBerry' | 'Any';
14
- /**
15
- * Orientation types
16
- */
6
+ export type DesktopPlatform = 'Windows' | 'macOS' | 'Linux' | 'FreeBSD' | 'Any' | 'ChromeOS';
7
+ export type MobilePlatform = 'Android' | 'iOS' | 'iPadOS' | 'WindowsMobile' | 'BlackBerry' | 'Any';
17
8
  export type Orientation = 'portrait' | 'landscape';
18
- /**
19
- * Extended Navigator interface for userAgentData
20
- */
21
- interface NavigatorUAData {
22
- platform?: string;
23
- brands?: {
24
- brand: string;
25
- version: string;
26
- }[];
27
- mobile?: boolean;
28
- }
29
- declare global {
30
- interface Navigator {
31
- userAgentData?: NavigatorUAData;
32
- }
33
- }
34
- /**
35
- * General checks for what kind of platform is being used to run the app.
36
- */
37
9
  export declare class Platform {
38
10
  /**
39
- * Check if the screen has a retina pixel ratio
40
- * @returns Whether the screen is retina
11
+ * Check if the screen has a high pixel density (Retina)
41
12
  */
42
- static retina(): boolean;
13
+ static get retina(): boolean;
43
14
  /**
44
- * Check if the device is on portrait orientation
45
- * @returns Whether device is in portrait mode
15
+ * Check if the device is in portrait orientation.
16
+ * Uses matchMedia to align perfectly with CSS media queries.
46
17
  */
47
- static portrait(): boolean;
18
+ static get portrait(): boolean;
48
19
  /**
49
- * Check if the device is on landscape orientation
50
- * @returns Whether device is in landscape mode
20
+ * Check if the device is in landscape orientation.
51
21
  */
52
- static landscape(): boolean;
22
+ static get landscape(): boolean;
53
23
  /**
54
- * Get device Orientation
55
- * @returns 'portrait' or 'landscape'
24
+ * Get current device orientation as a string.
56
25
  */
57
- static orientation(): Orientation;
26
+ static get orientation(): Orientation;
58
27
  /**
59
- * Check if the app is running over Electron
60
- * @returns Whether running in Electron
28
+ * Check if the user prefers Dark Mode
61
29
  */
62
- static electron(): boolean;
30
+ static get darkMode(): boolean;
63
31
  /**
64
- * Check if the app is running over Cordova
65
- * @returns Whether running in Cordova
32
+ * Check if the user prefers reduced motion
66
33
  */
67
- static cordova(): boolean;
34
+ static get reducedMotion(): boolean;
68
35
  /**
69
- * Get the platform string using modern userAgentData API with fallback
70
- * @returns Platform string
36
+ * Check if the device supports touch events.
37
+ * Useful for distinguishing hybrid laptops from tablets.
71
38
  */
72
- private static getPlatformString;
39
+ static get touch(): boolean;
73
40
  /**
74
- * Check if the app is running in a desktop platform
75
- * @param platform - Check for a specific desktop platform
76
- * @returns Whether running on specified desktop platform
41
+ * Check if the app is running in "Standalone" mode (Installed PWA).
77
42
  */
78
- static desktop(platform?: DesktopPlatform): boolean;
43
+ static get standalone(): boolean;
79
44
  /**
80
- * Check if the app is running in a mobile platform
81
- * @param platform - Check for a specific mobile platform
82
- * @returns Whether running on specified mobile platform
45
+ * Check if the app is running inside Electron.
46
+ * Checks both Renderer process and Main process contexts.
83
47
  */
84
- static mobile(platform?: MobilePlatform): boolean;
48
+ static get electron(): boolean;
85
49
  /**
86
- * Check if the platform allows the use of service workers
50
+ * Check if the app is running inside Cordova / PhoneGap.
51
+ */
52
+ static get cordova(): boolean;
53
+ /**
54
+ * Internal helper to normalize platform detection
55
+ */
56
+ private static get userAgent();
57
+ /**
58
+ * Check if the app is running on a Desktop platform.
59
+ *
60
+ * @param os - Specific desktop OS to check for, or 'Any' for any desktop
61
+ */
62
+ static desktop(os?: DesktopPlatform): boolean;
63
+ /**
64
+ * Check if the app is running on a Mobile platform.
87
65
  *
88
- * @returns Whether service workers are supported
66
+ * @param os - Specific mobile OS to check for, or 'Any' for any mobile
67
+ */
68
+ static mobile(os?: MobilePlatform): boolean;
69
+ /**
70
+ * Detect iPadOS explicitly.
71
+ * Modern iPads send a "Macintosh" User Agent, but have Touch Points.
72
+ */
73
+ private static isIpadOS;
74
+ /**
75
+ * Check if the platform supports Service Workers.
76
+ * Uses `isSecureContext` to accurately allow localhost/HTTPS.
77
+ */
78
+ static get serviceWorkers(): boolean;
79
+ /**
80
+ * Check if the device has a coarse pointer (touch) as primary input.
81
+ */
82
+ static get coarsePointer(): boolean;
83
+ /**
84
+ * Check if the device has a fine pointer (mouse) as primary input.
85
+ */
86
+ static get finePointer(): boolean;
87
+ /**
88
+ * Check if the device supports hover interactions.
89
89
  */
90
- static serviceWorkers(): boolean;
90
+ static get canHover(): boolean;
91
91
  }
92
- export {};
93
92
  //# sourceMappingURL=Platform.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Platform.d.ts","sourceRoot":"","sources":["../../src/Platform.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,OAAO,GAAG,OAAO,GAAG,SAAS,GAAG,OAAO,GAAG,KAAK,CAAC;AAE1F;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,KAAK,GAAG,OAAO,GAAG,SAAS,GAAG,YAAY,GAAG,KAAK,CAAC;AAE5F;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,WAAW,CAAC;AAEnD;;GAEG;AACH,UAAU,eAAe;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC9C,MAAM,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,SAAS;QAClB,aAAa,CAAC,EAAE,eAAe,CAAC;KAChC;CACD;AAeD;;GAEG;AACH,qBAAa,QAAQ;IACpB;;;OAGG;IACH,MAAM,CAAC,MAAM,IAAI,OAAO;IAIxB;;;OAGG;IACH,MAAM,CAAC,QAAQ,IAAI,OAAO;IAI1B;;;OAGG;IACH,MAAM,CAAC,SAAS,IAAI,OAAO;IAI3B;;;OAGG;IACH,MAAM,CAAC,WAAW,IAAI,WAAW;IAIjC;;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;IAED;;OAEG;IACH,MAAM,KAAK,OAAO,IAAI,OAAO,CAE5B;IAED;;OAEG;IACH,OAAO,CAAC,MAAM,KAAK,SAAS,GAE3B;IAED;;;;OAIG;IACH,MAAM,CAAC,OAAO,CAAC,EAAE,GAAE,eAAuB,GAAG,OAAO;IA6BpD;;;;OAIG;IACH,MAAM,CAAC,MAAM,CAAC,EAAE,GAAE,cAAsB,GAAG,OAAO;IAwBlD;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ;IAcvB;;;OAGG;IACH,MAAM,KAAK,cAAc,IAAI,OAAO,CAEnC;IAED;;OAEG;IACH,MAAM,KAAK,aAAa,IAAI,OAAO,CAElC;IAED;;OAEG;IACH,MAAM,KAAK,WAAW,IAAI,OAAO,CAEhC;IAED;;OAEG;IACH,MAAM,KAAK,QAAQ,IAAI,OAAO,CAE7B;CACF"}
@@ -3,24 +3,83 @@
3
3
  * Preload
4
4
  * ==============================
5
5
  */
6
- /**
7
- * A simple class for asset preloading. This class assumes you have a service
8
- * worker set up that will be caching all requests.
9
- */
10
6
  export declare class Preload {
11
7
  /**
12
- * Preload an image file
8
+ * Preload and decode an image. Decoding prevents the image from still having
9
+ * a delay when it is displayed.
13
10
  *
14
- * @param route - Route to the image
15
- * @returns Resolves to the image object or gets rejected with the rejection event
11
+ * @param route - URL of the image
12
+ * @returns Promise<HTMLImageElement>
16
13
  */
17
14
  static image(route: string): Promise<HTMLImageElement>;
18
15
  /**
19
- * Preload any kind of file
16
+ * Preload multiple images in parallel.
17
+ *
18
+ * @param routes - Array of image URLs
19
+ * @returns Promise<HTMLImageElement[]>
20
+ */
21
+ static images(routes: string[]): Promise<HTMLImageElement[]>;
22
+ /**
23
+ * Preload a generic file by fetching it.
24
+ *
25
+ * @param route - URL of the file
26
+ * @param priority - Fetch priority hint (default: 'low')
27
+ * @returns Promise<Response>
28
+ */
29
+ static file(route: string, priority?: 'high' | 'low' | 'auto'): Promise<Response>;
30
+ /**
31
+ * Preload multiple files in parallel.
32
+ *
33
+ * @param routes - Array of file URLs
34
+ * @param priority - Fetch priority hint
35
+ * @returns Promise<Response[]>
36
+ */
37
+ static files(routes: string[], priority?: 'high' | 'low' | 'auto'): Promise<Response[]>;
38
+ /**
39
+ * Check if a URL is cached in a specific cache.
40
+ *
41
+ * @param cacheName - Name of the cache to check
42
+ * @param url - URL to look for
43
+ * @returns Whether the URL is cached
44
+ */
45
+ static isCached(cacheName: string, url: string): Promise<boolean>;
46
+ /**
47
+ * Add a URL to a cache.
48
+ *
49
+ * @param cacheName - Name of the cache
50
+ * @param url - URL to cache
51
+ * @returns Promise<void>
52
+ */
53
+ static addToCache(cacheName: string, url: string): Promise<void>;
54
+ /**
55
+ * Add multiple URLs to a cache.
56
+ *
57
+ * @param cacheName - Name of the cache
58
+ * @param urls - URLs to cache
59
+ * @returns Promise<void>
60
+ */
61
+ static addAllToCache(cacheName: string, urls: string[]): Promise<void>;
62
+ /**
63
+ * Preload a CSS stylesheet.
64
+ *
65
+ * @param url - URL of the stylesheet
66
+ * @returns Promise<void>
67
+ */
68
+ static stylesheet(url: string): Promise<void>;
69
+ /**
70
+ * Preload a JavaScript file.
71
+ *
72
+ * @param url - URL of the script
73
+ * @returns Promise<void>
74
+ */
75
+ static script(url: string): Promise<void>;
76
+ /**
77
+ * Preload a font file.
20
78
  *
21
- * @param route - Route to the file
22
- * @returns Resolves or rejects depending on request success
79
+ * @param url - URL of the font
80
+ * @param crossOrigin - Whether to use crossorigin attribute (default: true for fonts)
81
+ * @returns Promise<void>
23
82
  */
24
- static file(route: string): Promise<Blob>;
83
+ static font(url: string, crossOrigin?: boolean): Promise<void>;
25
84
  }
26
85
  //# sourceMappingURL=Preload.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Preload.d.ts","sourceRoot":"","sources":["../../src/Preload.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;;GAGG;AACH,qBAAa,OAAO;IACnB;;;;;OAKG;IACH,MAAM,CAAC,KAAK,CAA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