@bbn/bbn 1.0.117 → 1.0.119
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/$.js +1 -1
- package/dist/_.js +11 -7
- package/dist/bundle-webpack.js +77 -0
- package/dist/bundle-webpack.js.map +1 -0
- package/dist/bundle.js +13374 -9875
- package/dist/bundle.js.map +1 -0
- package/dist/db.js +82 -81
- package/dist/env.js +1 -1
- package/dist/fn/ajax/_addLoader.js +6 -6
- package/dist/fn/ajax/_deleteLoader.js +16 -14
- package/dist/fn/ajax/abort.js +3 -3
- package/dist/fn/ajax/abortURL.js +4 -4
- package/dist/fn/ajax/ajax.js +36 -31
- package/dist/fn/ajax/callback.js +14 -10
- package/dist/fn/ajax/download.js +15 -13
- package/dist/fn/ajax/downloadContent.js +10 -9
- package/dist/fn/ajax/getLoader.js +3 -3
- package/dist/fn/ajax/getRequestId.js +5 -5
- package/dist/fn/ajax/link.js +20 -16
- package/dist/fn/ajax/post.js +10 -6
- package/dist/fn/ajax/postOut.js +7 -5
- package/dist/fn/ajax/setNavigationVars.js +11 -9
- package/dist/fn/ajax/treatAjaxArguments.js +8 -8
- package/dist/fn/ajax/upload.js +11 -8
- package/dist/fn/browser/copy.js +10 -8
- package/dist/fn/browser/eraseCookie.js +1 -1
- package/dist/fn/browser/error.js +4 -4
- package/dist/fn/browser/getBrowserName.js +2 -2
- package/dist/fn/browser/getBrowserVersion.js +2 -2
- package/dist/fn/browser/getCookie.js +6 -6
- package/dist/fn/browser/getDeviceType.js +2 -2
- package/dist/fn/browser/getEventData.js +33 -33
- package/dist/fn/browser/happy.js +6 -2
- package/dist/fn/browser/history.js +1 -1
- package/dist/fn/browser/info.js +6 -2
- package/dist/fn/browser/isActiveInterface.js +3 -2
- package/dist/fn/browser/isDesktopDevice.js +2 -2
- package/dist/fn/browser/isFocused.js +2 -1
- package/dist/fn/browser/isMobile.js +3 -3
- package/dist/fn/browser/isMobileDevice.js +2 -2
- package/dist/fn/browser/isTabletDevice.js +2 -2
- package/dist/fn/browser/log.js +13 -9
- package/dist/fn/browser/replaceSelection.js +6 -6
- package/dist/fn/browser/selectElementText.js +5 -4
- package/dist/fn/browser/setCookie.js +4 -4
- package/dist/fn/browser/toggleFullScreen.js +2 -2
- package/dist/fn/browser/warning.js +4 -4
- package/dist/fn/convert/arrayBuffer2String.js +1 -1
- package/dist/fn/convert/canvasToImage.js +2 -2
- package/dist/fn/convert/colorToHex.js +2 -2
- package/dist/fn/convert/fromXml.js +14 -8
- package/dist/fn/convert/hex2rgb.js +1 -1
- package/dist/fn/convert/imageToCanvas.js +2 -2
- package/dist/fn/convert/imgToBase64.js +4 -3
- package/dist/fn/convert/rgb2hex.js +1 -1
- package/dist/fn/convert/string2ArrayBuffer.js +1 -1
- package/dist/fn/convert/toCSV.js +13 -10
- package/dist/fn/datetime/calendar.js +11 -10
- package/dist/fn/datetime/chrono.js +9 -9
- package/dist/fn/datetime/date.js +5 -5
- package/dist/fn/datetime/dateSQL.d.ts +1 -1
- package/dist/fn/datetime/dateSQL.js +4 -4
- package/dist/fn/datetime/daysInMonth.js +3 -3
- package/dist/fn/datetime/fdate.js +7 -6
- package/dist/fn/datetime/fdatetime.js +6 -5
- package/dist/fn/datetime/formatDate.js +1 -1
- package/dist/fn/datetime/ftime.js +5 -5
- package/dist/fn/datetime/getDay.js +5 -5
- package/dist/fn/datetime/timestamp.js +3 -2
- package/dist/fn/default/defaultAjaxAbortFunction.js +3 -2
- package/dist/fn/default/defaultAjaxErrorFunction.js +4 -2
- package/dist/fn/default/defaultAlertFunction.js +2 -1
- package/dist/fn/default/defaultConfirmFunction.js +4 -3
- package/dist/fn/default/defaultEndLoadingFunction.js +3 -1
- package/dist/fn/default/defaultErrorFunction.js +2 -2
- package/dist/fn/default/defaultHistoryFunction.js +1 -1
- package/dist/fn/default/defaultLinkFunction.js +1 -1
- package/dist/fn/default/defaultPostLinkFunction.js +2 -1
- package/dist/fn/default/defaultPreLinkFunction.js +4 -2
- package/dist/fn/default/defaultResizeFunction.js +1 -1
- package/dist/fn/default/defaultStartLoadingFunction.js +3 -1
- package/dist/fn/form/addInputs.js +13 -11
- package/dist/fn/form/fieldValue.js +2 -2
- package/dist/fn/form/formdata.js +29 -29
- package/dist/fn/form/objectToFormData.js +13 -10
- package/dist/fn/form/submit.js +5 -5
- package/dist/fn/html/adjustHeight.js +4 -4
- package/dist/fn/html/adjustSize.js +7 -7
- package/dist/fn/html/adjustWidth.js +4 -4
- package/dist/fn/html/getAllTags.js +3 -3
- package/dist/fn/html/getAncestors.js +3 -2
- package/dist/fn/html/getAttributes.js +4 -4
- package/dist/fn/html/getHTMLOfSelection.js +6 -6
- package/dist/fn/html/getHtml.js +4 -3
- package/dist/fn/html/getPath.js +24 -17
- package/dist/fn/html/getText.js +1 -1
- package/dist/fn/html/html2text.js +2 -2
- package/dist/fn/html/isInside.js +9 -9
- package/dist/fn/html/makeReactive.js +35 -31
- package/dist/fn/html/selector.js +1 -1
- package/dist/fn/init.js +28 -28
- package/dist/fn/loop/each.js +6 -6
- package/dist/fn/loop/fori.js +7 -5
- package/dist/fn/loop/forir.js +7 -5
- package/dist/fn/loop/iterate.js +7 -4
- package/dist/fn/loop/riterate.js +3 -2
- package/dist/fn/misc/analyzeFunction.js +30 -30
- package/dist/fn/misc/getTimeoff.js +1 -1
- package/dist/fn/misc/money.js +6 -6
- package/dist/fn/misc/percent.js +1 -1
- package/dist/fn/misc/randomInt.js +1 -1
- package/dist/fn/misc/roundDecimal.js +1 -1
- package/dist/fn/misc/translate.js +4 -4
- package/dist/fn/object/_compareValues.js +7 -6
- package/dist/fn/object/arrayFromProp.js +5 -5
- package/dist/fn/object/autoExtend.js +2 -2
- package/dist/fn/object/checkProps.js +3 -2
- package/dist/fn/object/checkPropsDetails.js +13 -12
- package/dist/fn/object/checkPropsOrDie.js +4 -3
- package/dist/fn/object/circularReplacer.js +6 -6
- package/dist/fn/object/clone.js +6 -6
- package/dist/fn/object/compare.js +6 -6
- package/dist/fn/object/compareConditions.js +11 -11
- package/dist/fn/object/count.js +4 -2
- package/dist/fn/object/createObject.js +17 -4
- package/dist/fn/object/deepPath.js +10 -9
- package/dist/fn/object/deleteProp.js +2 -2
- package/dist/fn/object/diffObj.js +19 -17
- package/dist/fn/object/extend.js +17 -13
- package/dist/fn/object/extendOut.js +10 -5
- package/dist/fn/object/filter.d.ts +1 -1
- package/dist/fn/object/filter.js +12 -10
- package/dist/fn/object/filterToConditions.js +10 -9
- package/dist/fn/object/findAll.js +8 -7
- package/dist/fn/object/getField.js +6 -3
- package/dist/fn/object/getFieldValues.js +6 -6
- package/dist/fn/object/getProp.js +2 -2
- package/dist/fn/object/getProperty.js +2 -2
- package/dist/fn/object/getRow.js +4 -2
- package/dist/fn/object/map.js +4 -3
- package/dist/fn/object/move.js +2 -2
- package/dist/fn/object/multiorder.js +8 -7
- package/dist/fn/object/numProperties.js +1 -1
- package/dist/fn/object/order.js +3 -2
- package/dist/fn/object/pickValue.js +1 -1
- package/dist/fn/object/removeEmpty.js +6 -6
- package/dist/fn/object/removePrivateProp.js +4 -3
- package/dist/fn/object/search.d.ts +1 -1
- package/dist/fn/object/search.js +15 -12
- package/dist/fn/object/setProp.js +3 -1
- package/dist/fn/object/setProperty.js +10 -10
- package/dist/fn/object/shortenObj.js +8 -7
- package/dist/fn/object/shuffle.js +4 -3
- package/dist/fn/object/sum.js +6 -6
- package/dist/fn/object/unique.js +1 -1
- package/dist/fn/string/baseName.js +6 -6
- package/dist/fn/string/br2nl.js +2 -2
- package/dist/fn/string/camelToCss.js +1 -1
- package/dist/fn/string/camelize.js +1 -1
- package/dist/fn/string/correctCase.js +2 -2
- package/dist/fn/string/crc32.js +8 -8
- package/dist/fn/string/dirName.js +4 -4
- package/dist/fn/string/escapeDquotes.js +2 -2
- package/dist/fn/string/escapeRegExp.js +1 -1
- package/dist/fn/string/escapeSquotes.js +2 -2
- package/dist/fn/string/escapeTicks.js +2 -2
- package/dist/fn/string/escapeUrl.js +11 -11
- package/dist/fn/string/fileExt.js +3 -3
- package/dist/fn/string/format.js +6 -6
- package/dist/fn/string/formatBytes.js +3 -2
- package/dist/fn/string/formatSize.js +3 -3
- package/dist/fn/string/hash.js +9 -9
- package/dist/fn/string/md5.js +1 -1
- package/dist/fn/string/nl2br.js +2 -2
- package/dist/fn/string/printf.js +1 -1
- package/dist/fn/string/quotes2html.js +2 -2
- package/dist/fn/string/randomString.js +7 -7
- package/dist/fn/string/removeAccents.js +3 -3
- package/dist/fn/string/removeExtraSpaces.js +1 -1
- package/dist/fn/string/removeHtmlComments.js +2 -2
- package/dist/fn/string/removeTrailingChars.js +2 -2
- package/dist/fn/string/repeat.js +1 -1
- package/dist/fn/string/replaceAll.js +4 -3
- package/dist/fn/string/sanitize.js +9 -8
- package/dist/fn/string/shorten.js +3 -3
- package/dist/fn/string/simpleHash.js +5 -5
- package/dist/fn/string/simpleHash1.js +4 -4
- package/dist/fn/string/simpleHash2.js +4 -4
- package/dist/fn/string/substr.js +4 -4
- package/dist/fn/string/trim.js +3 -2
- package/dist/fn/string/uniqString.js +17 -10
- package/dist/fn/style/addColors.js +17 -17
- package/dist/fn/style/addStyle.js +4 -4
- package/dist/fn/style/animateCss.js +4 -4
- package/dist/fn/style/center.js +2 -2
- package/dist/fn/style/cssExists.js +8 -8
- package/dist/fn/style/getCssVar.js +1 -1
- package/dist/fn/style/getScrollBarSize.js +6 -6
- package/dist/fn/style/lightenDarkenHex.js +3 -3
- package/dist/fn/style/outerHeight.js +4 -4
- package/dist/fn/style/outerWidth.js +4 -4
- package/dist/fn/style/resize.js +17 -17
- package/dist/fn/style/setCssVar.js +1 -1
- package/dist/fn/type/checkType.js +16 -12
- package/dist/fn/type/isArray.js +7 -2
- package/dist/fn/type/isBlob.js +7 -2
- package/dist/fn/type/isBoolean.js +7 -2
- package/dist/fn/type/isCanvas.js +7 -2
- package/dist/fn/type/isColor.js +8 -3
- package/dist/fn/type/isComment.js +7 -2
- package/dist/fn/type/isCp.js +9 -4
- package/dist/fn/type/isDate.js +7 -2
- package/dist/fn/type/isDimension.js +8 -3
- package/dist/fn/type/isDom.js +7 -2
- package/dist/fn/type/isEmail.js +9 -4
- package/dist/fn/type/isEmpty.js +3 -3
- package/dist/fn/type/isEvent.js +7 -2
- package/dist/fn/type/isFunction.js +7 -2
- package/dist/fn/type/isHostname.js +9 -4
- package/dist/fn/type/isIP.js +8 -3
- package/dist/fn/type/isInt.js +7 -2
- package/dist/fn/type/isIterable.js +7 -2
- package/dist/fn/type/isNull.js +7 -2
- package/dist/fn/type/isNumber.js +7 -2
- package/dist/fn/type/isObject.js +7 -2
- package/dist/fn/type/isPercent.js +7 -2
- package/dist/fn/type/isPrimitive.js +7 -2
- package/dist/fn/type/isPromise.js +7 -2
- package/dist/fn/type/isPropSize.js +4 -4
- package/dist/fn/type/isSQLDate.js +7 -2
- package/dist/fn/type/isSame.js +9 -9
- package/dist/fn/type/isString.js +7 -2
- package/dist/fn/type/isSymbol.js +7 -2
- package/dist/fn/type/isURL.js +7 -2
- package/dist/fn/type/isValidDimension.js +5 -5
- package/dist/fn/type/isValidName.js +8 -3
- package/dist/fn/type/isValue.js +8 -3
- package/dist/fn/type/isVue.js +11 -4
- package/dist/fn.d.ts +1 -1
- package/dist/fn.js +456 -456
- package/dist/index.d.ts +5 -5
- package/dist/index.js +1241 -920
- package/dist/lng.js +1 -1
- package/dist/vars.js +1 -1
- package/package.json +8 -5
package/dist/db.js
CHANGED
|
@@ -1,108 +1,109 @@
|
|
|
1
|
-
import { _ } from
|
|
2
|
-
import { each } from
|
|
3
|
-
import { iterate } from
|
|
4
|
-
import { log } from
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { _ } from './_.js';
|
|
2
|
+
import { each } from './fn/loop/each.js';
|
|
3
|
+
import { iterate } from './fn/loop/iterate.js';
|
|
4
|
+
import { log } from './fn/browser/log.js';
|
|
5
|
+
var idb = window['indexedDB'] || window['webkitIndexedDB'] || window['mozIndexedDB'] || window['OIndexedDB'] || window['msIndexedDB'];
|
|
6
|
+
var dbObject = function (dbName) {
|
|
7
|
+
var _this = this;
|
|
8
|
+
var conn = db._connections[dbName];
|
|
9
|
+
var structure = db._structures[dbName];
|
|
10
|
+
this.insert = function (table, data) {
|
|
10
11
|
if (!Array.isArray(data)) {
|
|
11
12
|
data = [data];
|
|
12
13
|
}
|
|
13
|
-
return new Promise(resolve
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
each(data, a
|
|
18
|
-
|
|
19
|
-
request.onerror = ()
|
|
14
|
+
return new Promise(function (resolve) {
|
|
15
|
+
var tx = conn.transaction(table, "readwrite");
|
|
16
|
+
var store = tx.objectStore(table);
|
|
17
|
+
var res = data.length;
|
|
18
|
+
each(data, function (a) {
|
|
19
|
+
var request = store.put(a);
|
|
20
|
+
request.onerror = function () {
|
|
20
21
|
log(request.error);
|
|
21
22
|
res--;
|
|
22
23
|
};
|
|
23
24
|
});
|
|
24
|
-
tx.onabort = ()
|
|
25
|
+
tx.onabort = function () {
|
|
25
26
|
throw new Error(tx.error);
|
|
26
27
|
};
|
|
27
|
-
tx.oncomplete = ()
|
|
28
|
+
tx.oncomplete = function () {
|
|
28
29
|
resolve(res);
|
|
29
30
|
};
|
|
30
31
|
});
|
|
31
32
|
};
|
|
32
|
-
this.update = (table, data, where)
|
|
33
|
-
return new Promise(resolve
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
this.update = function (table, data, where) {
|
|
34
|
+
return new Promise(function (resolve) {
|
|
35
|
+
var tx = conn.transaction(table, "readwrite");
|
|
36
|
+
var store = tx.objectStore(table);
|
|
37
|
+
var arch = structure[table];
|
|
38
|
+
var primary = arch.keys.PRIMARY.columns.length > 1 ? arch.keys.PRIMARY.columns : arch.keys.PRIMARY.columns[0];
|
|
38
39
|
if (!where[primary]) {
|
|
39
40
|
throw new Error(_("No "));
|
|
40
41
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
request.onerror = ()
|
|
42
|
+
var res = 1;
|
|
43
|
+
var request = store.put(data, where[primary]);
|
|
44
|
+
request.onerror = function () {
|
|
44
45
|
log(request.error);
|
|
45
46
|
res--;
|
|
46
47
|
};
|
|
47
|
-
tx.onabort = ()
|
|
48
|
+
tx.onabort = function () {
|
|
48
49
|
throw new Error(tx.error);
|
|
49
50
|
};
|
|
50
|
-
tx.oncomplete = ()
|
|
51
|
+
tx.oncomplete = function () {
|
|
51
52
|
resolve(res);
|
|
52
53
|
};
|
|
53
54
|
});
|
|
54
55
|
};
|
|
55
|
-
this.delete = (table, where)
|
|
56
|
-
return new Promise(resolve
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
56
|
+
this.delete = function (table, where) {
|
|
57
|
+
return new Promise(function (resolve) {
|
|
58
|
+
var tx = conn.transaction(table, "readwrite");
|
|
59
|
+
var store = tx.objectStore(table);
|
|
60
|
+
var arch = structure[table];
|
|
61
|
+
var primary = arch.keys.PRIMARY.columns.length > 1 ? arch.keys.PRIMARY.columns : arch.keys.PRIMARY.columns[0];
|
|
61
62
|
if (!where[primary]) {
|
|
62
63
|
throw new Error(_("No "));
|
|
63
64
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
request.onerror = ()
|
|
65
|
+
var res = 1;
|
|
66
|
+
var request = store.delete(where[primary]);
|
|
67
|
+
request.onerror = function () {
|
|
67
68
|
log(request.error);
|
|
68
69
|
res--;
|
|
69
70
|
};
|
|
70
|
-
tx.onabort = ()
|
|
71
|
+
tx.onabort = function () {
|
|
71
72
|
throw new Error(tx.error);
|
|
72
73
|
};
|
|
73
|
-
tx.oncomplete = ()
|
|
74
|
+
tx.oncomplete = function () {
|
|
74
75
|
resolve(res);
|
|
75
76
|
};
|
|
76
77
|
});
|
|
77
78
|
};
|
|
78
|
-
this.selectOne = (table, field, where, order, start, limit)
|
|
79
|
-
return new Promise(resolve
|
|
80
|
-
|
|
79
|
+
this.selectOne = function (table, field, where, order, start, limit) {
|
|
80
|
+
return new Promise(function (resolve) {
|
|
81
|
+
_this.select(table, [field], where, order, start, limit).then(function (d) {
|
|
81
82
|
var _a;
|
|
82
83
|
resolve((_a = d[field]) !== null && _a !== void 0 ? _a : undefined);
|
|
83
84
|
});
|
|
84
85
|
});
|
|
85
86
|
};
|
|
86
|
-
this.select = (table, fields, where, order, start, limit)
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
87
|
+
this.select = function (table, fields, where, order, start, limit) {
|
|
88
|
+
var tx = conn.transaction(table, "readonly");
|
|
89
|
+
var store = tx.objectStore(table);
|
|
90
|
+
var arch = structure[table];
|
|
91
|
+
var primary = arch.keys.PRIMARY.columns.length > 1 ? arch.keys.PRIMARY.columns : arch.keys.PRIMARY.columns[0];
|
|
91
92
|
if (!where[primary]) {
|
|
92
93
|
throw new Error(_("No "));
|
|
93
94
|
}
|
|
94
|
-
return new Promise(resolve
|
|
95
|
-
|
|
96
|
-
req.onsuccess = ()
|
|
97
|
-
|
|
95
|
+
return new Promise(function (resolve) {
|
|
96
|
+
var req = store.get(where[primary]);
|
|
97
|
+
req.onsuccess = function () {
|
|
98
|
+
var obj = req.result;
|
|
98
99
|
if (fields.length) {
|
|
99
|
-
|
|
100
|
-
iterate(obj, (v, n)
|
|
100
|
+
var res_1 = {};
|
|
101
|
+
iterate(obj, function (v, n) {
|
|
101
102
|
if (fields.indexOf(n) > -1) {
|
|
102
|
-
|
|
103
|
+
res_1[n] = v;
|
|
103
104
|
}
|
|
104
105
|
});
|
|
105
|
-
return resolve(
|
|
106
|
+
return resolve(res_1);
|
|
106
107
|
}
|
|
107
108
|
else {
|
|
108
109
|
resolve(obj);
|
|
@@ -110,46 +111,46 @@ const dbObject = function (dbName) {
|
|
|
110
111
|
};
|
|
111
112
|
});
|
|
112
113
|
};
|
|
113
|
-
this.selectAll = (table, fields, where, order, start, limit)
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
114
|
+
this.selectAll = function (table, fields, where, order, start, limit) {
|
|
115
|
+
var tx = conn.transaction(table, "read");
|
|
116
|
+
var store = tx.objectStore(table);
|
|
117
|
+
var arch = structure[table];
|
|
118
|
+
var primary = arch.keys.PRIMARY.columns.length > 1 ? arch.keys.PRIMARY.columns : arch.keys.PRIMARY.columns[0];
|
|
118
119
|
if (!where[primary]) {
|
|
119
120
|
throw new Error(_("No "));
|
|
120
121
|
}
|
|
121
|
-
return new Promise(resolve
|
|
122
|
-
|
|
122
|
+
return new Promise(function (resolve) {
|
|
123
|
+
var req = store.get(structure.keys.PRIMARY);
|
|
123
124
|
});
|
|
124
125
|
};
|
|
125
|
-
this.getColumnValues = (table, field, where, order, start, limit)
|
|
126
|
-
return new Promise(resolve
|
|
127
|
-
|
|
128
|
-
|
|
126
|
+
this.getColumnValues = function (table, field, where, order, start, limit) {
|
|
127
|
+
return new Promise(function (resolve) {
|
|
128
|
+
var tx = conn.transaction(table, "read");
|
|
129
|
+
var store = tx.objectStore(table);
|
|
129
130
|
});
|
|
130
131
|
};
|
|
131
132
|
};
|
|
132
|
-
|
|
133
|
+
var db = {
|
|
133
134
|
_structures: {},
|
|
134
135
|
/* This variable should be set to true in debugging mode only */
|
|
135
136
|
_connections: {},
|
|
136
137
|
/* Address of the CDN (where this file should be hosted) */
|
|
137
138
|
_stores: {},
|
|
138
139
|
ok: idb !== undefined,
|
|
139
|
-
open(name) {
|
|
140
|
-
return new Promise((resolve)
|
|
140
|
+
open: function (name) {
|
|
141
|
+
return new Promise(function (resolve) {
|
|
141
142
|
if (!db._connections[name]) {
|
|
142
143
|
if (!db._structures[name]) {
|
|
143
144
|
throw new Error(_("Impossible to find a structure for the database %s", name));
|
|
144
145
|
}
|
|
145
|
-
|
|
146
|
-
|
|
146
|
+
var conn_1 = idb.open(name);
|
|
147
|
+
conn_1.onupgradeneeded = function () {
|
|
147
148
|
log("UPGRADE NEEDED");
|
|
148
|
-
|
|
149
|
-
iterate(db._structures[name], (structure, storeName)
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
iterate(structure.keys, (a, n)
|
|
149
|
+
var res = conn_1.result;
|
|
150
|
+
iterate(db._structures[name], function (structure, storeName) {
|
|
151
|
+
var primary = structure.keys.PRIMARY.columns.length > 1 ? structure.keys.PRIMARY.columns : structure.keys.PRIMARY.columns[0];
|
|
152
|
+
var store = res.createObjectStore(storeName, { keyPath: primary });
|
|
153
|
+
iterate(structure.keys, function (a, n) {
|
|
153
154
|
if (n !== 'PRIMARY') {
|
|
154
155
|
store.createIndex(n, a.columns.length > 1 ? a.columns : a.columns[0], {
|
|
155
156
|
unique: !!a.unique
|
|
@@ -158,9 +159,9 @@ const db = {
|
|
|
158
159
|
});
|
|
159
160
|
});
|
|
160
161
|
};
|
|
161
|
-
|
|
162
|
-
db._connections[name] =
|
|
163
|
-
|
|
162
|
+
conn_1.onsuccess = function () {
|
|
163
|
+
db._connections[name] = conn_1.result;
|
|
164
|
+
var obj = new dbObject(name);
|
|
164
165
|
resolve(obj);
|
|
165
166
|
};
|
|
166
167
|
return;
|
|
@@ -168,7 +169,7 @@ const db = {
|
|
|
168
169
|
resolve(new dbObject(db._connections[name]));
|
|
169
170
|
});
|
|
170
171
|
},
|
|
171
|
-
add(database, name, structure) {
|
|
172
|
+
add: function (database, name, structure) {
|
|
172
173
|
var _a;
|
|
173
174
|
if (((_a = structure === null || structure === void 0 ? void 0 : structure.keys) === null || _a === void 0 ? void 0 : _a.PRIMARY) && (structure === null || structure === void 0 ? void 0 : structure.fields)) {
|
|
174
175
|
if (!db._structures[database]) {
|
package/dist/env.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { substr } from
|
|
1
|
+
import { substr } from '../string/substr.js';
|
|
2
2
|
/**
|
|
3
3
|
* Creates and adds a "loader" object to the property bbn.env.loaders.
|
|
4
4
|
*
|
|
@@ -13,13 +13,13 @@ import { substr } from "../string/substr.js";
|
|
|
13
13
|
*
|
|
14
14
|
* @returns {Number} The timestamp (in ms)
|
|
15
15
|
*/
|
|
16
|
-
|
|
16
|
+
var _addLoader = function (requestId, prom, source) {
|
|
17
17
|
/** @var {Number} tst Current timestamp */
|
|
18
|
-
|
|
18
|
+
var tst = new Date().getTime();
|
|
19
19
|
/** @var {String} url The original URL (part of requestId before : and md5) */
|
|
20
|
-
|
|
20
|
+
var url = substr(requestId, 0, requestId.length - 33);
|
|
21
21
|
/** @var {Object} loader The loader object */
|
|
22
|
-
|
|
22
|
+
var loader = {
|
|
23
23
|
key: requestId,
|
|
24
24
|
url: url,
|
|
25
25
|
loader: prom,
|
|
@@ -36,7 +36,7 @@ const _addLoader = function (requestId, prom, source) {
|
|
|
36
36
|
// Adding an object with this loader info in bbn.env.loadersHistory
|
|
37
37
|
bbn.env.loadersHistory.unshift(loader);
|
|
38
38
|
/** @var {Number} idx A pointer starting at the end of array loadersHistory */
|
|
39
|
-
|
|
39
|
+
var idx = bbn.env.loadersHistory.length;
|
|
40
40
|
// Removing elements from the loadersHistory object if their number is higher
|
|
41
41
|
// than bbn.env.maxLoadersHistory
|
|
42
42
|
while (idx && bbn.env.loadersHistory.length > bbn.env.maxLoadersHistory) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { search } from
|
|
2
|
-
import { getRow } from
|
|
3
|
-
import { isObject } from
|
|
1
|
+
import { search } from '../object/search.js';
|
|
2
|
+
import { getRow } from '../object/getRow.js';
|
|
3
|
+
import { isObject } from '../type/isObject.js';
|
|
4
4
|
/**
|
|
5
5
|
* Deletes a loader and changes its history state after the promise is fullfilled.
|
|
6
6
|
*
|
|
@@ -15,21 +15,23 @@ import { isObject } from "../type/isObject.js";
|
|
|
15
15
|
*
|
|
16
16
|
* @returns {Boolean} True if the loader was found
|
|
17
17
|
*/
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
var _deleteLoader = function (requestId, res, isAbort) {
|
|
19
|
+
if (res === void 0) { res = null; }
|
|
20
|
+
if (isAbort === void 0) { isAbort = false; }
|
|
21
|
+
var idx = search(bbn.env.loaders, { key: requestId });
|
|
20
22
|
if (idx > -1) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if (
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
var loader = bbn.env.loaders.splice(idx, 1)[0];
|
|
24
|
+
var history_1 = getRow(bbn.env.loadersHistory, { key: requestId, start: loader.start });
|
|
25
|
+
if (history_1) {
|
|
26
|
+
history_1.loading = false;
|
|
27
|
+
history_1.duration = new Date().getTime() - loader.start;
|
|
26
28
|
if (typeof res === 'string') {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
history_1.errorMessage = res;
|
|
30
|
+
history_1.error = !isAbort;
|
|
31
|
+
history_1.abort = isAbort;
|
|
30
32
|
}
|
|
31
33
|
else if (isObject(res)) {
|
|
32
|
-
|
|
34
|
+
history_1.success = true;
|
|
33
35
|
}
|
|
34
36
|
}
|
|
35
37
|
return true;
|
package/dist/fn/ajax/abort.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getLoader } from
|
|
1
|
+
import { getLoader } from './getLoader.js';
|
|
2
2
|
/**
|
|
3
3
|
* Aborts (client side) the XHR corresponding to the given ID if it still exists.
|
|
4
4
|
*
|
|
@@ -21,8 +21,8 @@ import { getLoader } from "./getLoader.js";
|
|
|
21
21
|
*
|
|
22
22
|
* @returns {undefined}
|
|
23
23
|
*/
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
var abort = function (requestId) {
|
|
25
|
+
var loader = getLoader(requestId);
|
|
26
26
|
if (loader && loader.source) {
|
|
27
27
|
//_deleteLoader(requestId);
|
|
28
28
|
loader.source.cancel('Operation canceled by the user.');
|
package/dist/fn/ajax/abortURL.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { each } from
|
|
2
|
-
import { filter } from
|
|
1
|
+
import { each } from '../loop/each.js';
|
|
2
|
+
import { filter } from '../object/filter.js';
|
|
3
3
|
/**
|
|
4
4
|
* Aborts (client side) all the XHR using the given URL if it still exists.
|
|
5
5
|
*
|
|
@@ -20,8 +20,8 @@ import { filter } from "../object/filter.js";
|
|
|
20
20
|
*
|
|
21
21
|
* @returns {undefined}
|
|
22
22
|
*/
|
|
23
|
-
|
|
24
|
-
each(filter(bbn.env.loaders, { url: url }), (a)
|
|
23
|
+
var abortURL = function (url) {
|
|
24
|
+
each(filter(bbn.env.loaders, { url: url }), function (a) {
|
|
25
25
|
if (a && a.source) {
|
|
26
26
|
a.source.cancel('Operation canceled by the user.');
|
|
27
27
|
}
|
package/dist/fn/ajax/ajax.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { isObject } from
|
|
2
|
-
import { replaceAll } from
|
|
3
|
-
import { getRequestId } from
|
|
4
|
-
import { getLoader } from
|
|
5
|
-
import { extend } from
|
|
6
|
-
import { numProperties } from
|
|
7
|
-
import { _deleteLoader } from
|
|
8
|
-
import { isFunction } from
|
|
9
|
-
import { _addLoader } from
|
|
1
|
+
import { isObject } from '../type/isObject.js';
|
|
2
|
+
import { replaceAll } from '../string/replaceAll.js';
|
|
3
|
+
import { getRequestId } from './getRequestId.js';
|
|
4
|
+
import { getLoader } from './getLoader.js';
|
|
5
|
+
import { extend } from '../object/extend.js';
|
|
6
|
+
import { numProperties } from '../object/numProperties.js';
|
|
7
|
+
import { _deleteLoader } from './_deleteLoader.js';
|
|
8
|
+
import { isFunction } from '../type/isFunction.js';
|
|
9
|
+
import { _addLoader } from './_addLoader.js';
|
|
10
10
|
/**
|
|
11
11
|
* Creates an XHR object and returns the Promise.
|
|
12
12
|
*
|
|
@@ -63,7 +63,12 @@ import { _addLoader } from "./_addLoader.js";
|
|
|
63
63
|
*
|
|
64
64
|
* @returns {Promise} The Promise created by the generated XHR.
|
|
65
65
|
*/
|
|
66
|
-
|
|
66
|
+
var ajax = function (url, datatype, data, success, failure, abort) {
|
|
67
|
+
if (datatype === void 0) { datatype = null; }
|
|
68
|
+
if (data === void 0) { data = null; }
|
|
69
|
+
if (success === void 0) { success = null; }
|
|
70
|
+
if (failure === void 0) { failure = null; }
|
|
71
|
+
if (abort === void 0) { abort = null; }
|
|
67
72
|
if (arguments.length === 1 && url && typeof url === "object" && url.url) {
|
|
68
73
|
if (url.abort) {
|
|
69
74
|
abort = url.abort;
|
|
@@ -93,8 +98,8 @@ const ajax = function (url, datatype = null, data = null, success = null, failur
|
|
|
93
98
|
if (!datatype) {
|
|
94
99
|
datatype = "json";
|
|
95
100
|
}
|
|
96
|
-
|
|
97
|
-
|
|
101
|
+
var requestId_1 = getRequestId(url, data, datatype);
|
|
102
|
+
var loaderObj = getLoader(requestId_1);
|
|
98
103
|
//log("IN AJAX", loaderObj? loaderObj.loader : "NO LOADER")
|
|
99
104
|
if (loaderObj === null || loaderObj === void 0 ? void 0 : loaderObj.loader) {
|
|
100
105
|
return loaderObj.loader;
|
|
@@ -102,9 +107,9 @@ const ajax = function (url, datatype = null, data = null, success = null, failur
|
|
|
102
107
|
if (bbn.env.token) {
|
|
103
108
|
extend(data || {}, { _bbn_token: bbn.env.token });
|
|
104
109
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
110
|
+
var cancelToken = axios.CancelToken;
|
|
111
|
+
var source = cancelToken.source();
|
|
112
|
+
var options = {
|
|
108
113
|
responseType: datatype,
|
|
109
114
|
cancelToken: source.token,
|
|
110
115
|
};
|
|
@@ -114,17 +119,17 @@ const ajax = function (url, datatype = null, data = null, success = null, failur
|
|
|
114
119
|
"Content-Type": "text/javascript",
|
|
115
120
|
};
|
|
116
121
|
}
|
|
117
|
-
|
|
122
|
+
var args = [url];
|
|
118
123
|
if (isObject(data) && numProperties(data) > 0) {
|
|
119
124
|
args.push(data);
|
|
120
125
|
}
|
|
121
126
|
args.push(options);
|
|
122
|
-
|
|
123
|
-
|
|
127
|
+
var axiosMethod = args.length === 2 ? "get" : "post";
|
|
128
|
+
var loader_1 = axios[axiosMethod]
|
|
124
129
|
.apply(null, args)
|
|
125
|
-
.then((res)
|
|
126
|
-
_deleteLoader(
|
|
127
|
-
bbn.fn.defaultEndLoadingFunction(url,
|
|
130
|
+
.then(function (res) {
|
|
131
|
+
_deleteLoader(requestId_1, res);
|
|
132
|
+
bbn.fn.defaultEndLoadingFunction(url, tst_1, data, res);
|
|
128
133
|
switch (res.status) {
|
|
129
134
|
case 200:
|
|
130
135
|
if (isFunction(success)) {
|
|
@@ -132,16 +137,16 @@ const ajax = function (url, datatype = null, data = null, success = null, failur
|
|
|
132
137
|
}
|
|
133
138
|
break;
|
|
134
139
|
default:
|
|
135
|
-
bbn.fn.defaultAjaxErrorFunction(
|
|
140
|
+
bbn.fn.defaultAjaxErrorFunction(loader_1, res);
|
|
136
141
|
}
|
|
137
142
|
return res;
|
|
138
143
|
})
|
|
139
|
-
.catch((err)
|
|
140
|
-
|
|
141
|
-
_deleteLoader(
|
|
142
|
-
bbn.fn.defaultEndLoadingFunction(url,
|
|
144
|
+
.catch(function (err) {
|
|
145
|
+
var isAbort = axios.isCancel(err);
|
|
146
|
+
_deleteLoader(requestId_1, err.message || err.response.data, isAbort);
|
|
147
|
+
bbn.fn.defaultEndLoadingFunction(url, tst_1, data, err);
|
|
143
148
|
if (isAbort) {
|
|
144
|
-
|
|
149
|
+
var ok = 1;
|
|
145
150
|
if (isFunction(abort)) {
|
|
146
151
|
ok = abort(err.message, url);
|
|
147
152
|
}
|
|
@@ -150,7 +155,7 @@ const ajax = function (url, datatype = null, data = null, success = null, failur
|
|
|
150
155
|
}
|
|
151
156
|
}
|
|
152
157
|
else {
|
|
153
|
-
|
|
158
|
+
var ok = 1;
|
|
154
159
|
if (isFunction(failure)) {
|
|
155
160
|
ok = failure(err.request, err);
|
|
156
161
|
}
|
|
@@ -159,9 +164,9 @@ const ajax = function (url, datatype = null, data = null, success = null, failur
|
|
|
159
164
|
}
|
|
160
165
|
}
|
|
161
166
|
});
|
|
162
|
-
|
|
163
|
-
bbn.fn.defaultStartLoadingFunction(url,
|
|
164
|
-
return
|
|
167
|
+
var tst_1 = _addLoader(requestId_1, loader_1, source);
|
|
168
|
+
bbn.fn.defaultStartLoadingFunction(url, tst_1, data, requestId_1);
|
|
169
|
+
return loader_1;
|
|
165
170
|
}
|
|
166
171
|
};
|
|
167
172
|
export { ajax };
|
package/dist/fn/ajax/callback.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { error } from
|
|
2
|
-
import { isFunction } from
|
|
3
|
-
import { log } from
|
|
1
|
+
import { error } from '../browser/error.js';
|
|
2
|
+
import { isFunction } from '../type/isFunction.js';
|
|
3
|
+
import { log } from '../browser/log.js';
|
|
4
4
|
/**
|
|
5
5
|
* Executes a serie of predefined actions once an Ajax request has been done.
|
|
6
6
|
*
|
|
@@ -36,13 +36,17 @@ import { log } from "../browser/log.js";
|
|
|
36
36
|
*
|
|
37
37
|
* @returns {*} The result of the main callback function: res.script, fn, or bbn.fn.defaultLinkFunction
|
|
38
38
|
*/
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
var callback = function (url, res, fn, fn2, ele) {
|
|
40
|
+
if (res === void 0) { res = null; }
|
|
41
|
+
if (fn === void 0) { fn = null; }
|
|
42
|
+
if (fn2 === void 0) { fn2 = null; }
|
|
43
|
+
if (ele === void 0) { ele = null; }
|
|
44
|
+
var tmp = false;
|
|
41
45
|
if (res) {
|
|
42
46
|
tmp = true;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
47
|
+
var t = typeof res;
|
|
48
|
+
var isObj = t.toLowerCase() === 'object';
|
|
49
|
+
var errTitle = void 0;
|
|
46
50
|
if (isObj && res.prescript) {
|
|
47
51
|
/* var ok can be changed to false in prescript execution */
|
|
48
52
|
try {
|
|
@@ -75,8 +79,8 @@ const callback = function (url, res = null, fn = null, fn2 = null, ele = null) {
|
|
|
75
79
|
tmp = res.script(res.data ? res.data : {}, ele || null);
|
|
76
80
|
}
|
|
77
81
|
else {
|
|
78
|
-
tmp = ((data, ele)
|
|
79
|
-
|
|
82
|
+
tmp = (function (data, ele) {
|
|
83
|
+
var r = null;
|
|
80
84
|
try {
|
|
81
85
|
r = eval(res.script);
|
|
82
86
|
if (isFunction(r)) {
|
package/dist/fn/ajax/download.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ajax } from
|
|
2
|
-
import { substr } from
|
|
3
|
-
import { baseName } from
|
|
4
|
-
import { isBlob } from
|
|
5
|
-
import { fileExt } from
|
|
6
|
-
import { downloadContent } from
|
|
1
|
+
import { ajax } from './ajax.js';
|
|
2
|
+
import { substr } from '../string/substr.js';
|
|
3
|
+
import { baseName } from '../string/baseName.js';
|
|
4
|
+
import { isBlob } from '../type/isBlob.js';
|
|
5
|
+
import { fileExt } from '../string/fileExt.js';
|
|
6
|
+
import { downloadContent } from './downloadContent.js';
|
|
7
7
|
/**
|
|
8
8
|
* Downloads a file with given filename from a URL.
|
|
9
9
|
*
|
|
@@ -32,16 +32,18 @@ import { downloadContent } from "./downloadContent.js";
|
|
|
32
32
|
*
|
|
33
33
|
* @returns {undefined}
|
|
34
34
|
*/
|
|
35
|
-
|
|
35
|
+
var download = function (url, filename, params) {
|
|
36
|
+
if (filename === void 0) { filename = ''; }
|
|
37
|
+
if (params === void 0) { params = null; }
|
|
36
38
|
// We can intervert the arguments
|
|
37
39
|
if (filename && typeof filename === "object") {
|
|
38
40
|
params = filename;
|
|
39
41
|
filename = "";
|
|
40
42
|
}
|
|
41
|
-
return ajax(url, "blob", params || { _bbn_download: 1 }, (d, headers)
|
|
43
|
+
return ajax(url, "blob", params || { _bbn_download: 1 }, function (d, headers) {
|
|
42
44
|
if (!filename) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
+
var prop = "content-disposition";
|
|
46
|
+
var cd = "attachment; filename=";
|
|
45
47
|
if ((headers === null || headers === void 0 ? void 0 : headers[prop]) && headers[prop].indexOf(cd) === 0) {
|
|
46
48
|
filename = substr(headers[prop], cd.length + 1, headers[prop].length - cd.length - 2);
|
|
47
49
|
}
|
|
@@ -50,8 +52,8 @@ const download = function (url, filename = '', params = null) {
|
|
|
50
52
|
}
|
|
51
53
|
}
|
|
52
54
|
if (isBlob(d)) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
+
var extension = fileExt(filename);
|
|
56
|
+
var htmlExtensions = ["php", "html"];
|
|
55
57
|
if (typeof filename === "string" &&
|
|
56
58
|
(("type" in d && d.type !== "text/html") ||
|
|
57
59
|
htmlExtensions.includes(extension))) {
|
|
@@ -59,7 +61,7 @@ const download = function (url, filename = '', params = null) {
|
|
|
59
61
|
return;
|
|
60
62
|
}
|
|
61
63
|
}
|
|
62
|
-
}, (e)
|
|
64
|
+
}, function (e) {
|
|
63
65
|
bbn.fn.defaultAjaxErrorFunction(e);
|
|
64
66
|
});
|
|
65
67
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { isCanvas } from
|
|
2
|
-
import { isObject } from
|
|
3
|
-
import { isString } from
|
|
4
|
-
import { log } from
|
|
1
|
+
import { isCanvas } from '../type/isCanvas.js';
|
|
2
|
+
import { isObject } from '../type/isObject.js';
|
|
3
|
+
import { isString } from '../type/isString.js';
|
|
4
|
+
import { log } from '../browser/log.js';
|
|
5
5
|
/**
|
|
6
6
|
* Downloads a file with given filename from the given content.
|
|
7
7
|
*
|
|
@@ -28,11 +28,12 @@ import { log } from "../browser/log.js";
|
|
|
28
28
|
*
|
|
29
29
|
* @returns {undefined}
|
|
30
30
|
*/
|
|
31
|
-
|
|
31
|
+
var downloadContent = function (filename, content, type) {
|
|
32
|
+
if (type === void 0) { type = null; }
|
|
32
33
|
if (isCanvas(content)) {
|
|
33
|
-
content.toBlob((blob)
|
|
34
|
+
content.toBlob(function (blob) {
|
|
34
35
|
// blob ready, download it
|
|
35
|
-
|
|
36
|
+
var a = document.createElement('a');
|
|
36
37
|
a.download = filename;
|
|
37
38
|
a.href = window.URL.createObjectURL(blob);
|
|
38
39
|
a.className = 'bbn-no';
|
|
@@ -48,9 +49,9 @@ const downloadContent = function (filename, content, type = null) {
|
|
|
48
49
|
else if (type.indexOf('/') === -1) {
|
|
49
50
|
type = 'text/' + type;
|
|
50
51
|
}
|
|
51
|
-
|
|
52
|
+
var a = window.document.createElement('a');
|
|
52
53
|
a.className = 'bbn-no';
|
|
53
|
-
|
|
54
|
+
var src = null;
|
|
54
55
|
if (isString(content)) {
|
|
55
56
|
src = new Blob([content], { type: type });
|
|
56
57
|
}
|