@aegis-framework/artemis 0.3.25 → 0.3.29
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/artemis.js +1 -1
- package/dist/artemis.js.map +1 -1
- package/dist/artemis.min.js +1 -1
- package/dist/artemis.min.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/DOM.js +3 -6
- package/src/SpaceAdapter/IndexedDB.js +25 -5
- package/src/SpaceAdapter/RemoteStorage.js +15 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aegis-framework/artemis",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.29",
|
|
4
4
|
"description": "Aegis Framework Javascript Library",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/artemis.js",
|
|
@@ -61,13 +61,13 @@
|
|
|
61
61
|
"build:main": "parcel build --target main --no-cache --public-url .",
|
|
62
62
|
"build:module": "parcel build --target module --no-cache --public-url .",
|
|
63
63
|
"build:legacy": "parcel build --target legacy --no-cache --public-url .",
|
|
64
|
-
"watch": "parcel watch
|
|
64
|
+
"watch": "parcel watch --target legacy --no-cache --public-url ."
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
|
-
"eslint": "^8.
|
|
67
|
+
"eslint": "^8.6.0",
|
|
68
68
|
"jsdoc": "^3.6.5",
|
|
69
69
|
"jsdoc-to-markdown": "^7.1.0",
|
|
70
|
-
"parcel": "^2.
|
|
70
|
+
"parcel": "^2.1.1"
|
|
71
71
|
},
|
|
72
72
|
"files": [
|
|
73
73
|
"index.js",
|
package/src/DOM.js
CHANGED
|
@@ -748,20 +748,17 @@ export class DOM {
|
|
|
748
748
|
*/
|
|
749
749
|
style (properties, value) {
|
|
750
750
|
for (let i = 0; i < this.collection.length; i++) {
|
|
751
|
-
if (typeof properties === 'string' && value !== 'undefined') {
|
|
751
|
+
if (typeof properties === 'string' && typeof value !== 'undefined') {
|
|
752
752
|
this.collection[i].style[properties] = value;
|
|
753
|
-
|
|
754
|
-
return this;
|
|
755
|
-
} else if (typeof properties === 'string' && value === 'undefined') {
|
|
753
|
+
} else if (typeof properties === 'string' && typeof value === 'undefined') {
|
|
756
754
|
return this.collection[i].style[properties];
|
|
757
755
|
} else if (typeof properties === 'object') {
|
|
758
756
|
for (const property in properties) {
|
|
759
757
|
this.collection[i].style[property] = properties[property];
|
|
760
758
|
}
|
|
761
|
-
|
|
762
|
-
return this;
|
|
763
759
|
}
|
|
764
760
|
}
|
|
761
|
+
return this;
|
|
765
762
|
}
|
|
766
763
|
|
|
767
764
|
/**
|
|
@@ -32,9 +32,11 @@ export class IndexedDB {
|
|
|
32
32
|
this.name = name;
|
|
33
33
|
this.version = version;
|
|
34
34
|
this.store = store;
|
|
35
|
-
this.props = props;
|
|
35
|
+
this.props = props || {};
|
|
36
36
|
this.index = index;
|
|
37
37
|
|
|
38
|
+
this.keyPath = props.keyPath || 'id';
|
|
39
|
+
|
|
38
40
|
this.upgrades = {};
|
|
39
41
|
|
|
40
42
|
if (this.version === '') {
|
|
@@ -90,7 +92,7 @@ export class IndexedDB {
|
|
|
90
92
|
} else {
|
|
91
93
|
// Check what upgrade functions have been declared in their respective order
|
|
92
94
|
const availableUpgrades = Object.keys (this.upgrades).sort ();
|
|
93
|
-
|
|
95
|
+
|
|
94
96
|
// Find the first update that needs to be applied to the database given
|
|
95
97
|
// the old version it currently has.
|
|
96
98
|
const startFrom = availableUpgrades.findIndex (u => {
|
|
@@ -138,7 +140,9 @@ export class IndexedDB {
|
|
|
138
140
|
const transaction = this.storage.transaction (this.store, 'readwrite').objectStore (this.store);
|
|
139
141
|
let op;
|
|
140
142
|
if (key !== null) {
|
|
141
|
-
|
|
143
|
+
const temp = {};
|
|
144
|
+
temp[this.keyPath] = key;
|
|
145
|
+
op = transaction.put (Object.assign ({}, temp, value));
|
|
142
146
|
} else {
|
|
143
147
|
op = transaction.add (value);
|
|
144
148
|
}
|
|
@@ -187,7 +191,14 @@ export class IndexedDB {
|
|
|
187
191
|
const transaction = this.storage.transaction (this.store).objectStore (this.store);
|
|
188
192
|
const op = transaction.get (key);
|
|
189
193
|
|
|
190
|
-
op.addEventListener ('success', (event) => {
|
|
194
|
+
op.addEventListener ('success', (event) => {
|
|
195
|
+
const value = event.target.result;
|
|
196
|
+
if (typeof value !== 'undefined' && value !== null) {
|
|
197
|
+
resolve (value);
|
|
198
|
+
} else {
|
|
199
|
+
reject ();
|
|
200
|
+
}
|
|
201
|
+
});
|
|
191
202
|
op.addEventListener ('error', (event) => {reject (event);});
|
|
192
203
|
});
|
|
193
204
|
});
|
|
@@ -204,7 +215,16 @@ export class IndexedDB {
|
|
|
204
215
|
const transaction = this.storage.transaction (this.store).objectStore (this.store);
|
|
205
216
|
const op = transaction.getAll ();
|
|
206
217
|
|
|
207
|
-
op.addEventListener ('success', (event) => {
|
|
218
|
+
op.addEventListener ('success', (event) => {
|
|
219
|
+
const results = {};
|
|
220
|
+
event.target.result.forEach((item) => {
|
|
221
|
+
const id = item[this.keyPath];
|
|
222
|
+
delete item[this.keyPath];
|
|
223
|
+
|
|
224
|
+
results[id] = item;
|
|
225
|
+
});
|
|
226
|
+
resolve (results);
|
|
227
|
+
});
|
|
208
228
|
op.addEventListener ('error', (event) => {reject (event);});
|
|
209
229
|
});
|
|
210
230
|
});
|
|
@@ -76,9 +76,11 @@ export class RemoteStorage {
|
|
|
76
76
|
*/
|
|
77
77
|
set (key, value) {
|
|
78
78
|
return this.open ().then (() => {
|
|
79
|
-
return this.storage.post (this.endpoint + key, value, this.props)
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
return this.storage.post (this.endpoint + key, value, this.props)
|
|
80
|
+
.then ((response) => response.json ())
|
|
81
|
+
.then ((value) => {
|
|
82
|
+
return Promise.resolve ({ key, value });
|
|
83
|
+
});
|
|
82
84
|
});
|
|
83
85
|
}
|
|
84
86
|
|
|
@@ -93,9 +95,11 @@ export class RemoteStorage {
|
|
|
93
95
|
*/
|
|
94
96
|
update (key, value) {
|
|
95
97
|
return this.get (key).then ((currentValue) => {
|
|
96
|
-
return this.storage.put (this.endpoint + key, Object.assign ({}, currentValue, value), this.props)
|
|
97
|
-
|
|
98
|
-
|
|
98
|
+
return this.storage.put (this.endpoint + key, Object.assign ({}, currentValue, value), this.props)
|
|
99
|
+
.then ((response) => response.json ())
|
|
100
|
+
.then ((value) => {
|
|
101
|
+
return Promise.resolve ({ key, value });
|
|
102
|
+
});
|
|
99
103
|
});
|
|
100
104
|
}
|
|
101
105
|
|
|
@@ -198,9 +202,11 @@ export class RemoteStorage {
|
|
|
198
202
|
*/
|
|
199
203
|
remove (key) {
|
|
200
204
|
return this.open ().then (() => {
|
|
201
|
-
return this.storage.delete (this.endpoint + key, {}, this.props)
|
|
202
|
-
|
|
203
|
-
|
|
205
|
+
return this.storage.delete (this.endpoint + key, {}, this.props)
|
|
206
|
+
.then ((response) => response.json ())
|
|
207
|
+
.then ((value) => {
|
|
208
|
+
return Promise.resolve (key,value);
|
|
209
|
+
});
|
|
204
210
|
});
|
|
205
211
|
}
|
|
206
212
|
|