@telia-ace/widget-utilities 1.0.0 → 1.0.3
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.txt +5 -5
- package/README.md +3 -3
- package/{lib-esm → dist}/append-class-names.d.ts +0 -0
- package/{lib-esm → dist}/batch.d.ts +0 -0
- package/{lib-esm → dist}/camilize.d.ts +0 -0
- package/{lib-esm → dist}/category-trail.d.ts +0 -0
- package/{lib-esm → dist}/create-params.d.ts +0 -0
- package/{lib-esm → dist}/data-uri-to-blob.d.ts +0 -0
- package/{lib-esm → dist}/debug.d.ts +0 -0
- package/{lib-esm → dist}/deep-clone.d.ts +0 -0
- package/{lib-esm → dist}/find-and-activate-stored-widgets.d.ts +0 -0
- package/{lib-esm → dist}/find-category-by-id.d.ts +0 -0
- package/{lib-esm → dist}/format-date.d.ts +0 -0
- package/{lib-esm → dist}/format-url.d.ts +0 -0
- package/{lib-esm → dist}/get-cookie.d.ts +0 -0
- package/{lib-esm → dist}/has-non-empty-categories.d.ts +0 -0
- package/{lib-esm → dist}/hash.d.ts +0 -0
- package/{lib-esm → dist}/html-parent-contains.d.ts +0 -0
- package/{lib-esm → dist}/index.d.ts +0 -0
- package/dist/index.js +802 -0
- package/dist/index.js.map +1 -0
- package/{lib-esm → dist}/is-anchor-link.d.ts +0 -0
- package/{lib-esm → dist}/kebab-case.d.ts +0 -0
- package/{lib-esm → dist}/lock.d.ts +0 -0
- package/{lib-esm → dist}/merge-deep.d.ts +0 -0
- package/{lib-esm → dist}/notify-data-loaded.d.ts +0 -0
- package/{lib-esm → dist}/remove-null-and-undefined-values.d.ts +0 -0
- package/{lib-esm → dist}/set-cookie.d.ts +0 -0
- package/{lib-esm → dist}/shallow-compare.d.ts +0 -0
- package/{lib-esm → dist}/uuid.d.ts +0 -0
- package/{lib-esm → dist}/wait-for.d.ts +0 -0
- package/package.json +36 -35
- package/lib/append-class-names.d.ts +0 -6
- package/lib/append-class-names.js +0 -84
- package/lib/batch.d.ts +0 -4
- package/lib/batch.js +0 -38
- package/lib/camilize.d.ts +0 -1
- package/lib/camilize.js +0 -29
- package/lib/category-trail.d.ts +0 -14
- package/lib/category-trail.js +0 -96
- package/lib/create-params.d.ts +0 -21
- package/lib/create-params.js +0 -108
- package/lib/data-uri-to-blob.d.ts +0 -2
- package/lib/data-uri-to-blob.js +0 -20
- package/lib/debug.d.ts +0 -52
- package/lib/debug.js +0 -155
- package/lib/deep-clone.d.ts +0 -2
- package/lib/deep-clone.js +0 -21
- package/lib/find-and-activate-stored-widgets.d.ts +0 -9
- package/lib/find-and-activate-stored-widgets.js +0 -27
- package/lib/find-category-by-id.d.ts +0 -6
- package/lib/find-category-by-id.js +0 -89
- package/lib/format-date.d.ts +0 -2
- package/lib/format-date.js +0 -23
- package/lib/format-url.d.ts +0 -2
- package/lib/format-url.js +0 -111
- package/lib/get-cookie.d.ts +0 -1
- package/lib/get-cookie.js +0 -18
- package/lib/has-non-empty-categories.d.ts +0 -2
- package/lib/has-non-empty-categories.js +0 -23
- package/lib/hash.d.ts +0 -1
- package/lib/hash.js +0 -16
- package/lib/html-parent-contains.d.ts +0 -7
- package/lib/html-parent-contains.js +0 -21
- package/lib/index.d.ts +0 -27
- package/lib/index.js +0 -57
- package/lib/is-anchor-link.d.ts +0 -2
- package/lib/is-anchor-link.js +0 -9
- package/lib/kebab-case.d.ts +0 -1
- package/lib/kebab-case.js +0 -9
- package/lib/lock.d.ts +0 -9
- package/lib/lock.js +0 -78
- package/lib/merge-deep.d.ts +0 -7
- package/lib/merge-deep.js +0 -72
- package/lib/notify-data-loaded.d.ts +0 -6
- package/lib/notify-data-loaded.js +0 -96
- package/lib/remove-null-and-undefined-values.d.ts +0 -6
- package/lib/remove-null-and-undefined-values.js +0 -12
- package/lib/set-cookie.d.ts +0 -1
- package/lib/set-cookie.js +0 -12
- package/lib/shallow-compare.d.ts +0 -6
- package/lib/shallow-compare.js +0 -25
- package/lib/uuid.d.ts +0 -1
- package/lib/uuid.js +0 -12
- package/lib/wait-for.d.ts +0 -20
- package/lib/wait-for.js +0 -52
- package/lib-esm/append-class-names.js +0 -77
- package/lib-esm/batch.js +0 -36
- package/lib-esm/camilize.js +0 -26
- package/lib-esm/category-trail.js +0 -87
- package/lib-esm/create-params.js +0 -105
- package/lib-esm/data-uri-to-blob.js +0 -18
- package/lib-esm/debug.js +0 -151
- package/lib-esm/deep-clone.js +0 -19
- package/lib-esm/find-and-activate-stored-widgets.js +0 -25
- package/lib-esm/find-category-by-id.js +0 -87
- package/lib-esm/format-date.js +0 -21
- package/lib-esm/format-url.js +0 -109
- package/lib-esm/get-cookie.js +0 -15
- package/lib-esm/has-non-empty-categories.js +0 -18
- package/lib-esm/hash.js +0 -13
- package/lib-esm/html-parent-contains.js +0 -19
- package/lib-esm/index.js +0 -24
- package/lib-esm/is-anchor-link.js +0 -7
- package/lib-esm/kebab-case.js +0 -6
- package/lib-esm/lock.js +0 -75
- package/lib-esm/merge-deep.js +0 -67
- package/lib-esm/notify-data-loaded.js +0 -94
- package/lib-esm/remove-null-and-undefined-values.js +0 -10
- package/lib-esm/set-cookie.js +0 -9
- package/lib-esm/shallow-compare.js +0 -23
- package/lib-esm/uuid.js +0 -9
- package/lib-esm/wait-for.js +0 -50
package/lib-esm/format-url.js
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
var formatUrl = function (url) {
|
|
2
|
-
if (!url) {
|
|
3
|
-
return '';
|
|
4
|
-
}
|
|
5
|
-
var replacements = [
|
|
6
|
-
{ from: /[äæǽ]+/gi, to: 'ae' },
|
|
7
|
-
{ from: /[öœ]+/gi, to: 'oe' },
|
|
8
|
-
{ from: /[ü]+/gi, to: 'ue' },
|
|
9
|
-
{ from: /[Ä]+/gi, to: 'Ae' },
|
|
10
|
-
{ from: /[Ü]+/gi, to: 'Ue' },
|
|
11
|
-
{ from: /[Ö]+/gi, to: 'Oe' },
|
|
12
|
-
{ from: /[ÀÁÂÃÄÅǺĀĂĄǍΑΆẢẠẦẪẨẬẰẮẴẲẶА]+/gi, to: 'A' },
|
|
13
|
-
{ from: /[àáâãåǻāăąǎªαάảạầấẫẩậằắẵẳặа]+/gi, to: 'a' },
|
|
14
|
-
{ from: /[Б]+/gi, to: 'B' },
|
|
15
|
-
{ from: /[б]+/gi, to: 'b' },
|
|
16
|
-
{ from: /[ÇĆĈĊČ]+/gi, to: 'C' },
|
|
17
|
-
{ from: /[çćĉċč]+/gi, to: 'c' },
|
|
18
|
-
{ from: /[Д]+/gi, to: 'D' },
|
|
19
|
-
{ from: /[д]+/gi, to: 'd' },
|
|
20
|
-
{ from: /[ÐĎĐΔ]+/gi, to: 'Dj' },
|
|
21
|
-
{ from: /[ðďđδ]+/gi, to: 'dj' },
|
|
22
|
-
{ from: /[ÈÉÊËĒĔĖĘĚΕΈẼẺẸỀẾỄỂỆЕЭ]+/gi, to: 'E' },
|
|
23
|
-
{ from: /[èéêëēĕėęěέεẽẻẹềếễểệеэ]+/gi, to: 'e' },
|
|
24
|
-
{ from: /[Ф]+/gi, to: 'F' },
|
|
25
|
-
{ from: /[ф]+/gi, to: 'f' },
|
|
26
|
-
{ from: /[ĜĞĠĢΓГҐ]+/gi, to: 'G' },
|
|
27
|
-
{ from: /[ĝğġģγгґ]+/gi, to: 'g' },
|
|
28
|
-
{ from: /[ĤĦ]+/gi, to: 'H' },
|
|
29
|
-
{ from: /[ĥħ]+/gi, to: 'h' },
|
|
30
|
-
{ from: /[ÌÍÎÏĨĪĬǏĮİΗΉΊΙΪỈỊИЫ]+/gi, to: 'I' },
|
|
31
|
-
{ from: /[ìíîïĩīĭǐįıηήίιϊỉịиыї]+/gi, to: 'i' },
|
|
32
|
-
{ from: /[Ĵ]+/gi, to: 'J' },
|
|
33
|
-
{ from: /[ĵ]+/gi, to: 'j' },
|
|
34
|
-
{ from: /[ĶΚК]+/gi, to: 'K' },
|
|
35
|
-
{ from: /[ķκк]+/gi, to: 'k' },
|
|
36
|
-
{ from: /[ĹĻĽĿŁΛЛ]+/gi, to: 'L' },
|
|
37
|
-
{ from: /[ĺļľŀłλл]+/gi, to: 'l' },
|
|
38
|
-
{ from: /[М]+/gi, to: 'M' },
|
|
39
|
-
{ from: /[м]+/gi, to: 'm' },
|
|
40
|
-
{ from: /[ÑŃŅŇΝН]+/gi, to: 'N' },
|
|
41
|
-
{ from: /[ñńņňʼnνн]+/gi, to: 'n' },
|
|
42
|
-
{ from: /[ÒÓÔÕŌŎǑŐƠØǾΟΌΩΏỎỌỒỐỖỔỘỜỚỠỞỢО]+/gi, to: 'O' },
|
|
43
|
-
{ from: /[òóôõōŏǒőơøǿºοόωώỏọồốỗổộờớỡởợо]+/gi, to: 'o' },
|
|
44
|
-
{ from: /[П]+/gi, to: 'P' },
|
|
45
|
-
{ from: /[п]+/gi, to: 'p' },
|
|
46
|
-
{ from: /[ŔŖŘΡР]+/gi, to: 'R' },
|
|
47
|
-
{ from: /[ŕŗřρр]+/gi, to: 'r' },
|
|
48
|
-
{ from: /[ŚŜŞȘŠΣС]+/gi, to: 'S' },
|
|
49
|
-
{ from: /[śŝşșšſσςс]+/gi, to: 's' },
|
|
50
|
-
{ from: /[ȚŢŤŦτТ]+/gi, to: 'T' },
|
|
51
|
-
{ from: /[țţťŧт]+/gi, to: 't' },
|
|
52
|
-
{ from: /[ÙÚÛŨŪŬŮŰŲƯǓǕǗǙǛŨỦỤỪỨỮỬỰУ]+/gi, to: 'U' },
|
|
53
|
-
{ from: /[ùúûũūŭůűųưǔǖǘǚǜυύϋủụừứữửựу]+/gi, to: 'u' },
|
|
54
|
-
{ from: /[ÝŸŶΥΎΫỲỸỶỴЙ]+/gi, to: 'Y' },
|
|
55
|
-
{ from: /[ýÿŷỳỹỷỵй]+/gi, to: 'y' },
|
|
56
|
-
{ from: /[В]+/gi, to: 'V' },
|
|
57
|
-
{ from: /[в]+/gi, to: 'v' },
|
|
58
|
-
{ from: /[Ŵ]+/gi, to: 'W' },
|
|
59
|
-
{ from: /[ŵ]+/gi, to: 'w' },
|
|
60
|
-
{ from: /[ŹŻŽΖЗ]+/gi, to: 'Z' },
|
|
61
|
-
{ from: /[źżžζз]+/gi, to: 'z' },
|
|
62
|
-
{ from: /[ÆǼ]+/gi, to: 'AE' },
|
|
63
|
-
{ from: /[ß]+/gi, to: 'ss' },
|
|
64
|
-
{ from: /[IJ]+/gi, to: 'IJ' },
|
|
65
|
-
{ from: /[ij]+/gi, to: 'ij' },
|
|
66
|
-
{ from: /[Œ]+/gi, to: 'OE' },
|
|
67
|
-
{ from: /[ƒ]+/gi, to: 'f' },
|
|
68
|
-
{ from: /[ξ]+/gi, to: 'ks' },
|
|
69
|
-
{ from: /[π]+/gi, to: 'p' },
|
|
70
|
-
{ from: /[β]+/gi, to: 'v' },
|
|
71
|
-
{ from: /[μ]+/gi, to: 'm' },
|
|
72
|
-
{ from: /[ψ]+/gi, to: 'ps' },
|
|
73
|
-
{ from: /[Ё]+/gi, to: 'Yo' },
|
|
74
|
-
{ from: /[ё]+/gi, to: 'yo' },
|
|
75
|
-
{ from: /[Є]+/gi, to: 'Ye' },
|
|
76
|
-
{ from: /[є]+/gi, to: 'ye' },
|
|
77
|
-
{ from: /[Ї]+/gi, to: 'Yi' },
|
|
78
|
-
{ from: /[Ж]+/gi, to: 'Zh' },
|
|
79
|
-
{ from: /[ж]+/gi, to: 'zh' },
|
|
80
|
-
{ from: /[Х]+/gi, to: 'Kh' },
|
|
81
|
-
{ from: /[х]+/gi, to: 'kh' },
|
|
82
|
-
{ from: /[Ц]+/gi, to: 'Ts' },
|
|
83
|
-
{ from: /[ц]+/gi, to: 'ts' },
|
|
84
|
-
{ from: /[Ч]+/gi, to: 'Ch' },
|
|
85
|
-
{ from: /[ч]+/gi, to: 'ch' },
|
|
86
|
-
{ from: /[Ш]+/gi, to: 'Sh' },
|
|
87
|
-
{ from: /[ш]+/gi, to: 'sh' },
|
|
88
|
-
{ from: /[Щ]+/gi, to: 'Shch' },
|
|
89
|
-
{ from: /[щ]+/gi, to: 'shch' },
|
|
90
|
-
{ from: /[ЪъЬь]+/gi, to: '' },
|
|
91
|
-
{ from: /[Ю]+/gi, to: 'Yu' },
|
|
92
|
-
{ from: /[ю]+/gi, to: 'yu' },
|
|
93
|
-
{ from: /[Я]+/gi, to: 'Ya' },
|
|
94
|
-
{ from: /[я]+/gi, to: 'ya' },
|
|
95
|
-
];
|
|
96
|
-
var alphanumericExpression = /[^a-zA-Z0-9]+/g;
|
|
97
|
-
var trailingDashExpression = /[-]$/;
|
|
98
|
-
var parsed = url;
|
|
99
|
-
for (var i in replacements) {
|
|
100
|
-
if (replacements.hasOwnProperty(i) && replacements[i].from.test(url)) {
|
|
101
|
-
parsed = parsed.replace(replacements[i].from, replacements[i].to);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
parsed = parsed.replace(alphanumericExpression, '-');
|
|
105
|
-
parsed = parsed.replace(trailingDashExpression, '');
|
|
106
|
-
parsed = parsed.toLowerCase();
|
|
107
|
-
return parsed || 'humany';
|
|
108
|
-
};
|
|
109
|
-
export default formatUrl;
|
package/lib-esm/get-cookie.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export default function getCookie(cookieName) {
|
|
2
|
-
var documentCookie = document.cookie;
|
|
3
|
-
if (documentCookie.length > 0) {
|
|
4
|
-
var start = documentCookie.indexOf("".concat(cookieName, "="));
|
|
5
|
-
if (start !== -1) {
|
|
6
|
-
start = start + cookieName.length + 1;
|
|
7
|
-
var end = documentCookie.indexOf(';', start);
|
|
8
|
-
if (end === -1) {
|
|
9
|
-
end = documentCookie.length;
|
|
10
|
-
}
|
|
11
|
-
return unescape(documentCookie.substring(start, end));
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
return null;
|
|
15
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export function checkForEmptyCategories(items, v) {
|
|
2
|
-
if (v === void 0) { v = false; }
|
|
3
|
-
var value = v;
|
|
4
|
-
items.forEach(function (i) {
|
|
5
|
-
if ((typeof i.guidesCount === 'number' && i.guidesCount !== 0) ||
|
|
6
|
-
(typeof i.matchCount === 'number' && i.matchCount !== 0)) {
|
|
7
|
-
value = true;
|
|
8
|
-
}
|
|
9
|
-
if (i.items) {
|
|
10
|
-
value = checkForEmptyCategories(i.items, value);
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
return value;
|
|
14
|
-
}
|
|
15
|
-
export default function hasNonEmptyCategories(items, v) {
|
|
16
|
-
if (v === void 0) { v = false; }
|
|
17
|
-
return checkForEmptyCategories(items, v);
|
|
18
|
-
}
|
package/lib-esm/hash.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export default function (s) {
|
|
2
|
-
var hash = 0;
|
|
3
|
-
if (s.length === 0) {
|
|
4
|
-
return hash.toString();
|
|
5
|
-
}
|
|
6
|
-
// tslint:disable-next-line:no-increment-decrement
|
|
7
|
-
for (var i = 0; i < s.length; i++) {
|
|
8
|
-
var char = s.charCodeAt(i);
|
|
9
|
-
hash = (hash << 5) - hash + char;
|
|
10
|
-
hash = hash & hash;
|
|
11
|
-
}
|
|
12
|
-
return hash.toString();
|
|
13
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Checks whether or not the passed child is a descendant
|
|
3
|
-
* of the passed parent.
|
|
4
|
-
* Will return true if falsey parent or child.
|
|
5
|
-
*/
|
|
6
|
-
export default (function (parent, child) {
|
|
7
|
-
if (!parent || !child) {
|
|
8
|
-
return true;
|
|
9
|
-
}
|
|
10
|
-
var node = child.parentNode;
|
|
11
|
-
var hasChild = false;
|
|
12
|
-
while (node !== null) {
|
|
13
|
-
if (node === parent) {
|
|
14
|
-
hasChild = true;
|
|
15
|
-
}
|
|
16
|
-
node = node.parentNode;
|
|
17
|
-
}
|
|
18
|
-
return hasChild;
|
|
19
|
-
});
|
package/lib-esm/index.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export { default as appendClassNames } from './append-class-names';
|
|
2
|
-
export { default as createBatch } from './batch';
|
|
3
|
-
export { default as camilize } from './camilize';
|
|
4
|
-
export { buildCategoryTrail, categoryTrail, getCategoryTrailAsObjects } from './category-trail';
|
|
5
|
-
export { default as createParams } from './create-params';
|
|
6
|
-
export { default as dataURItoBlob } from './data-uri-to-blob';
|
|
7
|
-
export { debugLog, Logger } from './debug';
|
|
8
|
-
export { default as deepClone } from './deep-clone';
|
|
9
|
-
export { default as findAndActivateStoredWidgets } from './find-and-activate-stored-widgets';
|
|
10
|
-
export { default as findCategoryById } from './find-category-by-id';
|
|
11
|
-
export { default as formatDate } from './format-date';
|
|
12
|
-
export { default as formatUrl } from './format-url';
|
|
13
|
-
export { default as getCookie } from './get-cookie';
|
|
14
|
-
export { default as hash } from './hash';
|
|
15
|
-
export { default as htmlParentContains } from './html-parent-contains';
|
|
16
|
-
export { default as kebabCase } from './kebab-case';
|
|
17
|
-
export { default as lock } from './lock';
|
|
18
|
-
export { default as mergeDeep } from './merge-deep';
|
|
19
|
-
export { default as notifyDataLoaded } from './notify-data-loaded';
|
|
20
|
-
export { default as removeNullAndUndefinedValues } from './remove-null-and-undefined-values';
|
|
21
|
-
export { default as setCookie } from './set-cookie';
|
|
22
|
-
export { default as shallowCompare } from './shallow-compare';
|
|
23
|
-
export { default as uuid } from './uuid';
|
|
24
|
-
export { default as WaitFor } from './wait-for';
|
package/lib-esm/kebab-case.js
DELETED
package/lib-esm/lock.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { Logger } from './debug';
|
|
2
|
-
var Queue = /** @class */ (function () {
|
|
3
|
-
function Queue(lockWarningTime, lockErrorTime) {
|
|
4
|
-
this.lockWarningTime = lockWarningTime;
|
|
5
|
-
this.lockErrorTime = lockErrorTime;
|
|
6
|
-
this.tasks = [];
|
|
7
|
-
this.current = Promise.resolve();
|
|
8
|
-
this.next = this.next.bind(this);
|
|
9
|
-
}
|
|
10
|
-
Queue.prototype.add = function (task, resolve, reject, done) {
|
|
11
|
-
this.tasks.push({ task: task, resolve: resolve, reject: reject, done: done });
|
|
12
|
-
this.next();
|
|
13
|
-
};
|
|
14
|
-
Queue.prototype.next = function () {
|
|
15
|
-
var _this = this;
|
|
16
|
-
this.current = this.current.then(function () {
|
|
17
|
-
var next = _this.tasks.shift();
|
|
18
|
-
if (next) {
|
|
19
|
-
var errorTimeout_1; // NodeJS.Timeout
|
|
20
|
-
var warningTimeout_1 = setTimeout(function () {
|
|
21
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
22
|
-
// tslint:disable-next-line max-line-length
|
|
23
|
-
Logger.warn("A lock has exceeded ".concat(_this.lockWarningTime, " ms. Waiting additional ").concat(_this.lockErrorTime, " ms before rejecting the task."), next);
|
|
24
|
-
}
|
|
25
|
-
errorTimeout_1 = setTimeout(function () {
|
|
26
|
-
next.reject('lock timeout exceeded');
|
|
27
|
-
}, _this.lockErrorTime);
|
|
28
|
-
}, _this.lockWarningTime);
|
|
29
|
-
var taskPromise_1 = Promise.resolve(next.task()).then(function (result) {
|
|
30
|
-
clearTimeout(warningTimeout_1);
|
|
31
|
-
clearTimeout(errorTimeout_1);
|
|
32
|
-
return result;
|
|
33
|
-
});
|
|
34
|
-
return Promise.resolve(taskPromise_1)
|
|
35
|
-
.then(_this.next)
|
|
36
|
-
.then(function () {
|
|
37
|
-
return taskPromise_1.then(function (data) {
|
|
38
|
-
next.done();
|
|
39
|
-
next.resolve(data);
|
|
40
|
-
});
|
|
41
|
-
})
|
|
42
|
-
.catch(function (reason) {
|
|
43
|
-
next.done();
|
|
44
|
-
next.reject(reason);
|
|
45
|
-
return _this.next();
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
return Promise.resolve();
|
|
49
|
-
});
|
|
50
|
-
};
|
|
51
|
-
return Queue;
|
|
52
|
-
}());
|
|
53
|
-
var locks = new WeakMap();
|
|
54
|
-
/**
|
|
55
|
-
* Creates a lock for the specified owner that allows only one executing
|
|
56
|
-
* task simultaneously.
|
|
57
|
-
* @param key Lock owner.
|
|
58
|
-
*/
|
|
59
|
-
export default function lock(key, lockWarningTime, lockErrorTime) {
|
|
60
|
-
if (lockWarningTime === void 0) { lockWarningTime = 5000; }
|
|
61
|
-
if (lockErrorTime === void 0) { lockErrorTime = 1000; }
|
|
62
|
-
if (!locks.has(key)) {
|
|
63
|
-
locks.set(key, new Queue(lockWarningTime, lockErrorTime));
|
|
64
|
-
}
|
|
65
|
-
return function (task) {
|
|
66
|
-
return new Promise(function (resolve, reject) {
|
|
67
|
-
var queue = locks.get(key);
|
|
68
|
-
queue.add(task, resolve, reject, function () {
|
|
69
|
-
if (!queue.tasks.length) {
|
|
70
|
-
locks.delete(key);
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
};
|
|
75
|
-
}
|
package/lib-esm/merge-deep.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
2
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
3
|
-
if (!m) return o;
|
|
4
|
-
var i = m.call(o), r, ar = [], e;
|
|
5
|
-
try {
|
|
6
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
7
|
-
}
|
|
8
|
-
catch (error) { e = { error: error }; }
|
|
9
|
-
finally {
|
|
10
|
-
try {
|
|
11
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
12
|
-
}
|
|
13
|
-
finally { if (e) throw e.error; }
|
|
14
|
-
}
|
|
15
|
-
return ar;
|
|
16
|
-
};
|
|
17
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
18
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
19
|
-
if (ar || !(i in from)) {
|
|
20
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
21
|
-
ar[i] = from[i];
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
25
|
-
};
|
|
26
|
-
import deepClone from './deep-clone';
|
|
27
|
-
var isObject = function (item) {
|
|
28
|
-
return !!item && typeof item === 'object' && !Array.isArray(item);
|
|
29
|
-
};
|
|
30
|
-
/**
|
|
31
|
-
* @param target Target to merge into
|
|
32
|
-
* @param sources Source to merge into target
|
|
33
|
-
* @returns Clone (new reference) with merged sources
|
|
34
|
-
*/
|
|
35
|
-
var mergeDeep = function (target) {
|
|
36
|
-
var sources = [];
|
|
37
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
38
|
-
sources[_i - 1] = arguments[_i];
|
|
39
|
-
}
|
|
40
|
-
var clonedTarget = deepClone(target);
|
|
41
|
-
var clonedSources = deepClone(sources);
|
|
42
|
-
return mergeDeepRecursive.apply(void 0, __spreadArray([clonedTarget], __read(clonedSources), false));
|
|
43
|
-
};
|
|
44
|
-
var mergeDeepRecursive = function (target) {
|
|
45
|
-
var _a, _b;
|
|
46
|
-
var sources = [];
|
|
47
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
48
|
-
sources[_i - 1] = arguments[_i];
|
|
49
|
-
}
|
|
50
|
-
if (!sources.length)
|
|
51
|
-
return target;
|
|
52
|
-
var source = sources.shift();
|
|
53
|
-
if (isObject(target) && isObject(source)) {
|
|
54
|
-
for (var key in source) {
|
|
55
|
-
if (isObject(source[key])) {
|
|
56
|
-
if (!target[key])
|
|
57
|
-
Object.assign(target, (_a = {}, _a[key] = {}, _a));
|
|
58
|
-
mergeDeepRecursive(target[key], source[key]);
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
Object.assign(target, (_b = {}, _b[key] = source[key], _b));
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return mergeDeepRecursive.apply(void 0, __spreadArray([target], __read(sources), false));
|
|
66
|
-
};
|
|
67
|
-
export default mergeDeep;
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Dispatch widget:data-loaded event when all components
|
|
3
|
-
* is considered to be finished loading their initial data
|
|
4
|
-
*/
|
|
5
|
-
var watchForLoadingComplete = function (container, widgetDOMElement) {
|
|
6
|
-
var isLoading = function () { return widgetDOMElement.querySelectorAll('[data-loading=true]').length > 0; };
|
|
7
|
-
var complete = function () {
|
|
8
|
-
var dispatched = false;
|
|
9
|
-
return function () {
|
|
10
|
-
if (dispatched) {
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
var widget = container.get('$widget');
|
|
14
|
-
widget.events.dispatch('widget:data-loaded', {
|
|
15
|
-
element: widgetDOMElement,
|
|
16
|
-
});
|
|
17
|
-
dispatched = true;
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
var handleComplete = complete();
|
|
21
|
-
if (!isLoading()) {
|
|
22
|
-
return handleComplete();
|
|
23
|
-
}
|
|
24
|
-
var observer = new MutationObserver(function (mutations, observer) {
|
|
25
|
-
var check = mutations.find(function (mutation) {
|
|
26
|
-
return mutation.type === 'attributes' && mutation.attributeName === 'data-loading';
|
|
27
|
-
});
|
|
28
|
-
if (check && !isLoading()) {
|
|
29
|
-
observer.disconnect();
|
|
30
|
-
handleComplete();
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
observer.observe(widgetDOMElement, {
|
|
34
|
-
attributes: true,
|
|
35
|
-
childList: true,
|
|
36
|
-
subtree: true,
|
|
37
|
-
});
|
|
38
|
-
};
|
|
39
|
-
/**
|
|
40
|
-
* Wait for all visible components to render
|
|
41
|
-
*/
|
|
42
|
-
var notifyDataLoaded = function (viewOutletContainer, widgetDOMElement) {
|
|
43
|
-
var widget = viewOutletContainer.get('$widget');
|
|
44
|
-
widget.container.getAsync('components').then(function (components) {
|
|
45
|
-
components.events.subscribeOnce('components:component-model-initialized', function () {
|
|
46
|
-
// Store the names of all visible components we should wait for
|
|
47
|
-
var waitingFor = components.nodes.visible.reduce(function (acc, node) {
|
|
48
|
-
if (!node.name ||
|
|
49
|
-
!node.type ||
|
|
50
|
-
node.type === 'view' ||
|
|
51
|
-
node.type === 'root' ||
|
|
52
|
-
node.attributes.layout.size === 'none') {
|
|
53
|
-
return acc;
|
|
54
|
-
}
|
|
55
|
-
acc.push(node.name);
|
|
56
|
-
return acc;
|
|
57
|
-
}, []);
|
|
58
|
-
var complete = false;
|
|
59
|
-
var observer = new MutationObserver(function (mutations, observer) {
|
|
60
|
-
mutations.forEach(function (mutation) {
|
|
61
|
-
if (mutation.addedNodes) {
|
|
62
|
-
var componentElements_1 = Array.from(mutation.addedNodes).reduce(function (acc, element) {
|
|
63
|
-
var dataName = element.getAttribute && element.getAttribute('data-name');
|
|
64
|
-
if (dataName && waitingFor.indexOf(dataName) > -1) {
|
|
65
|
-
acc.push(dataName);
|
|
66
|
-
}
|
|
67
|
-
return acc;
|
|
68
|
-
}, []);
|
|
69
|
-
// Remove added elements from the list of elements we are waiting for
|
|
70
|
-
waitingFor = waitingFor.filter(function (name) {
|
|
71
|
-
return componentElements_1.indexOf(name) === -1;
|
|
72
|
-
});
|
|
73
|
-
// When the list is empty, we are finished waiting for components to render
|
|
74
|
-
if (!complete && waitingFor.length === 0) {
|
|
75
|
-
complete = true;
|
|
76
|
-
// Creates a new observer that observes data-loading changes
|
|
77
|
-
watchForLoadingComplete(viewOutletContainer, widgetDOMElement);
|
|
78
|
-
observer.disconnect();
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
observer.observe(widgetDOMElement, {
|
|
84
|
-
attributes: false,
|
|
85
|
-
characterData: false,
|
|
86
|
-
childList: true,
|
|
87
|
-
subtree: true,
|
|
88
|
-
attributeOldValue: false,
|
|
89
|
-
characterDataOldValue: false,
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
});
|
|
93
|
-
};
|
|
94
|
-
export default notifyDataLoaded;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
var removeNullAndUndefinedValues = function (object) {
|
|
2
|
-
if (object === void 0) { object = {}; }
|
|
3
|
-
Object.keys(object).forEach(function (key) {
|
|
4
|
-
if (object[key] === null || typeof object[key] === 'undefined') {
|
|
5
|
-
delete object[key];
|
|
6
|
-
}
|
|
7
|
-
});
|
|
8
|
-
return object;
|
|
9
|
-
};
|
|
10
|
-
export default removeNullAndUndefinedValues;
|
package/lib-esm/set-cookie.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export default function setCookie(cookieName, value, days) {
|
|
2
|
-
var expires = '';
|
|
3
|
-
if (days) {
|
|
4
|
-
var date = new Date();
|
|
5
|
-
date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
|
|
6
|
-
expires = "; expires=".concat(date.toUTCString());
|
|
7
|
-
}
|
|
8
|
-
document.cookie = "".concat(cookieName, "=").concat(value).concat(expires, "; path=/");
|
|
9
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
export default (function (a, b) {
|
|
2
|
-
var equal = true;
|
|
3
|
-
if (Object.keys(a).length !== Object.keys(b).length) {
|
|
4
|
-
return false;
|
|
5
|
-
}
|
|
6
|
-
var missingKey = Object.keys(a).some(function (key) {
|
|
7
|
-
var found = Object.keys(b).some(function (bKey) {
|
|
8
|
-
return key === bKey;
|
|
9
|
-
});
|
|
10
|
-
return !found;
|
|
11
|
-
});
|
|
12
|
-
if (missingKey) {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
Object.keys(a).forEach(function (key) {
|
|
16
|
-
if (equal) {
|
|
17
|
-
var c = typeof a[key] === 'undefined' ? '' : a[key];
|
|
18
|
-
var d = typeof b[key] === 'undefined' ? '' : b[key];
|
|
19
|
-
equal = c.toString() === d.toString();
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
return equal;
|
|
23
|
-
});
|
package/lib-esm/uuid.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
var s4 = function () {
|
|
2
|
-
return Math.floor((1 + Math.random()) * 0x10000)
|
|
3
|
-
.toString(16)
|
|
4
|
-
.substring(1);
|
|
5
|
-
};
|
|
6
|
-
export default function uuid() {
|
|
7
|
-
// tslint:disable-next-line prefer-template
|
|
8
|
-
return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
|
|
9
|
-
}
|
package/lib-esm/wait-for.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
var WaitFor = /** @class */ (function () {
|
|
2
|
-
function WaitFor(options) {
|
|
3
|
-
var _this = this;
|
|
4
|
-
this.queue = [];
|
|
5
|
-
this.queueAttemptCalls = 0;
|
|
6
|
-
this.callCount = 5;
|
|
7
|
-
/**
|
|
8
|
-
* Add action to the queue
|
|
9
|
-
*/
|
|
10
|
-
this.add = function (action) {
|
|
11
|
-
_this.queue.push(action);
|
|
12
|
-
_this.queueAttempt = setInterval(_this.processQueue, 1000);
|
|
13
|
-
};
|
|
14
|
-
/**
|
|
15
|
-
* Go through queue and attempt to call each action
|
|
16
|
-
*/
|
|
17
|
-
this.processQueue = function () {
|
|
18
|
-
if (_this.queue.length > 0) {
|
|
19
|
-
var indexOfActionsEmitted_1 = [];
|
|
20
|
-
_this.queue.forEach(function (queuedAction, index) {
|
|
21
|
-
var evaluate = queuedAction();
|
|
22
|
-
if (typeof evaluate === 'function') {
|
|
23
|
-
evaluate();
|
|
24
|
-
indexOfActionsEmitted_1.push(index);
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
// clean up queue
|
|
28
|
-
_this.queue = _this.queue.filter(function (_, index) {
|
|
29
|
-
if (indexOfActionsEmitted_1.indexOf(index) > -1) {
|
|
30
|
-
return false;
|
|
31
|
-
}
|
|
32
|
-
return true;
|
|
33
|
-
});
|
|
34
|
-
if (_this.queueAttempt) {
|
|
35
|
-
clearInterval(_this.queueAttempt);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
if (_this.queueAttemptCalls > _this.callCount) {
|
|
39
|
-
clearInterval(_this.queueAttempt);
|
|
40
|
-
_this.queueAttemptCalls = 0;
|
|
41
|
-
}
|
|
42
|
-
_this.queueAttemptCalls = _this.queueAttemptCalls + 1;
|
|
43
|
-
};
|
|
44
|
-
if (options && options.callCount) {
|
|
45
|
-
this.callCount = options.callCount;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
return WaitFor;
|
|
49
|
-
}());
|
|
50
|
-
export default WaitFor;
|