@aegis-framework/artemis 0.3.28 → 0.4.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/LICENSE +1 -1
- package/dist/artemis.browser.js +4 -0
- package/dist/artemis.browser.js.map +24 -0
- package/dist/artemis.js +3 -1
- package/dist/artemis.js.map +23 -1
- package/dist/types/DOM.d.ts +383 -0
- package/dist/types/DOM.d.ts.map +1 -0
- package/dist/types/Debug.d.ts +118 -0
- package/dist/types/Debug.d.ts.map +1 -0
- package/dist/types/FileSystem.d.ts +69 -0
- package/dist/types/FileSystem.d.ts.map +1 -0
- package/dist/types/Form.d.ts +32 -0
- package/dist/types/Form.d.ts.map +1 -0
- package/dist/types/Platform.d.ts +93 -0
- package/dist/types/Platform.d.ts.map +1 -0
- package/dist/types/Preload.d.ts +26 -0
- package/dist/types/Preload.d.ts.map +1 -0
- package/dist/types/Request.d.ts +86 -0
- package/dist/types/Request.d.ts.map +1 -0
- package/dist/types/Space.d.ts +205 -0
- package/dist/types/Space.d.ts.map +1 -0
- package/dist/types/SpaceAdapter/IndexedDB.d.ts +130 -0
- package/dist/types/SpaceAdapter/IndexedDB.d.ts.map +1 -0
- package/dist/types/SpaceAdapter/LocalStorage.d.ts +125 -0
- package/dist/types/SpaceAdapter/LocalStorage.d.ts.map +1 -0
- package/dist/types/SpaceAdapter/RemoteStorage.d.ts +122 -0
- package/dist/types/SpaceAdapter/RemoteStorage.d.ts.map +1 -0
- package/dist/types/SpaceAdapter/SessionStorage.d.ts +30 -0
- package/dist/types/SpaceAdapter/SessionStorage.d.ts.map +1 -0
- package/dist/types/SpaceAdapter/types.d.ts +76 -0
- package/dist/types/SpaceAdapter/types.d.ts.map +1 -0
- package/dist/types/Text.d.ts +47 -0
- package/dist/types/Text.d.ts.map +1 -0
- package/dist/types/Util.d.ts +31 -0
- package/dist/types/Util.d.ts.map +1 -0
- package/dist/types/browser.d.ts +7 -0
- package/dist/types/browser.d.ts.map +1 -0
- package/dist/types/index.d.ts +11 -0
- package/dist/types/index.d.ts.map +1 -0
- package/package.json +42 -53
- package/dist/artemis.min.js +0 -2
- package/dist/artemis.min.js.map +0 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +0 -1
- package/index.js +0 -10
- package/src/DOM.js +0 -993
- package/src/Debug.js +0 -233
- package/src/FileSystem.js +0 -109
- package/src/Form.js +0 -73
- package/src/Platform.js +0 -166
- package/src/Preload.js +0 -48
- package/src/Request.js +0 -163
- package/src/Space.js +0 -334
- package/src/SpaceAdapter/IndexedDB.js +0 -345
- package/src/SpaceAdapter/LocalStorage.js +0 -395
- package/src/SpaceAdapter/RemoteStorage.js +0 -219
- package/src/SpaceAdapter/SessionStorage.js +0 -46
- package/src/Text.js +0 -133
- package/src/Util.js +0 -55
package/src/Text.js
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ==============================
|
|
3
|
-
* Text
|
|
4
|
-
* ==============================
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Provides utility functions for texts
|
|
9
|
-
* @class
|
|
10
|
-
*/
|
|
11
|
-
export class Text {
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @static capitalize - Capatalizes every word in a string
|
|
15
|
-
*
|
|
16
|
-
* @param {string} text - Text string to capitalize
|
|
17
|
-
* @return {string} - Capitalized string
|
|
18
|
-
*/
|
|
19
|
-
static capitalize (text) {
|
|
20
|
-
return text.replace (/\w\S*/g, (txt) => {
|
|
21
|
-
return txt.charAt (0).toUpperCase () + txt.substr (1).toLowerCase ();
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* @static suffix - Gets the suffix of a string given a key
|
|
27
|
-
*
|
|
28
|
-
* @param {string} key - Key part of the string
|
|
29
|
-
* @param {string} text - Full string to extract the suffix from
|
|
30
|
-
* @return {string} - Suffix
|
|
31
|
-
*/
|
|
32
|
-
static suffix (key, text) {
|
|
33
|
-
let suffix = '';
|
|
34
|
-
let position = text.indexOf (key);
|
|
35
|
-
if (position !== -1) {
|
|
36
|
-
position += key.length;
|
|
37
|
-
suffix = text.substr (position, text.length - position);
|
|
38
|
-
}
|
|
39
|
-
return suffix;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* @static selection - Get the currently selected text
|
|
45
|
-
*
|
|
46
|
-
* @return {string} - Text selection
|
|
47
|
-
*/
|
|
48
|
-
static selection () {
|
|
49
|
-
if (window.getSelection) {
|
|
50
|
-
return window.getSelection ().toString ();
|
|
51
|
-
} else if (document.selection && document.selection.type != 'Control') {
|
|
52
|
-
return document.selection.createRange ().text;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* @static prefix - Gets the prefix of a string given a key
|
|
58
|
-
*
|
|
59
|
-
* @param {string} key - Key part of the string
|
|
60
|
-
* @param {string} text - Full string to extract the prefix from
|
|
61
|
-
* @return {string} - Prefix
|
|
62
|
-
*/
|
|
63
|
-
static prefix (key, text) {
|
|
64
|
-
let prefix = '';
|
|
65
|
-
const position = text.indexOf (key);
|
|
66
|
-
if (position != -1) {
|
|
67
|
-
prefix = text.substr (0, position);
|
|
68
|
-
}
|
|
69
|
-
return prefix;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* @static friendly - Transforms a given text into a friendly URL string replacing all special characters
|
|
74
|
-
*
|
|
75
|
-
* @param {string} text - The text to build the url from
|
|
76
|
-
* @return {string} - Friendly URL
|
|
77
|
-
*/
|
|
78
|
-
static friendly (text) {
|
|
79
|
-
const regex = [
|
|
80
|
-
/[áàâãªä]/,
|
|
81
|
-
/[ÁÀÂÃÄ]/,
|
|
82
|
-
/[ÍÌÎÏ]/,
|
|
83
|
-
/[íìîï]/,
|
|
84
|
-
/[éèêë]/,
|
|
85
|
-
/[ÉÈÊË]/,
|
|
86
|
-
/[óòôõºö]/,
|
|
87
|
-
/[ÓÒÔÕÖ]/,
|
|
88
|
-
/[úùûü]/,
|
|
89
|
-
/[ÚÙÛÜ]/,
|
|
90
|
-
/ç/,
|
|
91
|
-
/Ç/,
|
|
92
|
-
/ñ/,
|
|
93
|
-
/Ñ/,
|
|
94
|
-
/_/,
|
|
95
|
-
/[’‘‹›<>']/,
|
|
96
|
-
/[“”«»„"]/,
|
|
97
|
-
/[(){}[\]]/,
|
|
98
|
-
/[?¿!¡#$%&^*´`~/°|]/,
|
|
99
|
-
/[,.:;]/,
|
|
100
|
-
/ /
|
|
101
|
-
];
|
|
102
|
-
|
|
103
|
-
const replacements = [
|
|
104
|
-
'a',
|
|
105
|
-
'A',
|
|
106
|
-
'I',
|
|
107
|
-
'i',
|
|
108
|
-
'e',
|
|
109
|
-
'E',
|
|
110
|
-
'o',
|
|
111
|
-
'O',
|
|
112
|
-
'u',
|
|
113
|
-
'U',
|
|
114
|
-
'c',
|
|
115
|
-
'C',
|
|
116
|
-
'n',
|
|
117
|
-
'N',
|
|
118
|
-
'-',
|
|
119
|
-
'',
|
|
120
|
-
'',
|
|
121
|
-
'',
|
|
122
|
-
'',
|
|
123
|
-
'',
|
|
124
|
-
'-'
|
|
125
|
-
];
|
|
126
|
-
|
|
127
|
-
for (const index in regex) {
|
|
128
|
-
text = text.replace(new RegExp(regex[index], 'g'), replacements[index]);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
return text;
|
|
132
|
-
}
|
|
133
|
-
}
|
package/src/Util.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ==============================
|
|
3
|
-
* Util
|
|
4
|
-
* ==============================
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Provides diverse utility functions
|
|
9
|
-
* @class
|
|
10
|
-
*/
|
|
11
|
-
export class Util {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @static callAsync - Calls any function using promises to keep a standard
|
|
16
|
-
* behavior between async and sync functions.
|
|
17
|
-
*
|
|
18
|
-
* @param {funcion} callable - The function to run
|
|
19
|
-
* @param {Object} context - The object `this` will be mapped to
|
|
20
|
-
* @param {any} ...args - List of parameters to pass to the function when called
|
|
21
|
-
* @return {Promise} - A promise that resolves to the result of the function
|
|
22
|
-
*/
|
|
23
|
-
static callAsync (callable, context, ...args) {
|
|
24
|
-
try {
|
|
25
|
-
// Call the provided function using the context and arguments given
|
|
26
|
-
const result = callable.apply (context, args);
|
|
27
|
-
|
|
28
|
-
// Check if the function returned a simple value or a Promise
|
|
29
|
-
if (result instanceof Promise) {
|
|
30
|
-
return result;
|
|
31
|
-
} else {
|
|
32
|
-
return Promise.resolve (result);
|
|
33
|
-
}
|
|
34
|
-
} catch (e) {
|
|
35
|
-
return Promise.reject (e);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* @static uuid - Creates a UUID. This UUIDs should not be trusted for uniqueness
|
|
41
|
-
*
|
|
42
|
-
* @return {string} - Generated UUID
|
|
43
|
-
*/
|
|
44
|
-
static uuid () {
|
|
45
|
-
if (window.crypto) {
|
|
46
|
-
return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, (c) =>
|
|
47
|
-
(c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString (16)
|
|
48
|
-
);
|
|
49
|
-
} else {
|
|
50
|
-
const generate = () => Math.floor ((1 + Math.random()) * 0x10000).toString (16).substring (1);
|
|
51
|
-
return generate () + generate () + '-' + generate () + '-' + generate () + '-' +
|
|
52
|
-
generate () + '-' + generate () + generate () + generate ();
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|