@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
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.checkForEmptyCategories = void 0;
|
|
4
|
-
function checkForEmptyCategories(items, v) {
|
|
5
|
-
if (v === void 0) { v = false; }
|
|
6
|
-
var value = v;
|
|
7
|
-
items.forEach(function (i) {
|
|
8
|
-
if ((typeof i.guidesCount === 'number' && i.guidesCount !== 0) ||
|
|
9
|
-
(typeof i.matchCount === 'number' && i.matchCount !== 0)) {
|
|
10
|
-
value = true;
|
|
11
|
-
}
|
|
12
|
-
if (i.items) {
|
|
13
|
-
value = checkForEmptyCategories(i.items, value);
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
return value;
|
|
17
|
-
}
|
|
18
|
-
exports.checkForEmptyCategories = checkForEmptyCategories;
|
|
19
|
-
function hasNonEmptyCategories(items, v) {
|
|
20
|
-
if (v === void 0) { v = false; }
|
|
21
|
-
return checkForEmptyCategories(items, v);
|
|
22
|
-
}
|
|
23
|
-
exports.default = hasNonEmptyCategories;
|
package/lib/hash.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function (s: string): string;
|
package/lib/hash.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
function default_1(s) {
|
|
4
|
-
var hash = 0;
|
|
5
|
-
if (s.length === 0) {
|
|
6
|
-
return hash.toString();
|
|
7
|
-
}
|
|
8
|
-
// tslint:disable-next-line:no-increment-decrement
|
|
9
|
-
for (var i = 0; i < s.length; i++) {
|
|
10
|
-
var char = s.charCodeAt(i);
|
|
11
|
-
hash = (hash << 5) - hash + char;
|
|
12
|
-
hash = hash & hash;
|
|
13
|
-
}
|
|
14
|
-
return hash.toString();
|
|
15
|
-
}
|
|
16
|
-
exports.default = default_1;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/**
|
|
4
|
-
* Checks whether or not the passed child is a descendant
|
|
5
|
-
* of the passed parent.
|
|
6
|
-
* Will return true if falsey parent or child.
|
|
7
|
-
*/
|
|
8
|
-
exports.default = (function (parent, child) {
|
|
9
|
-
if (!parent || !child) {
|
|
10
|
-
return true;
|
|
11
|
-
}
|
|
12
|
-
var node = child.parentNode;
|
|
13
|
-
var hasChild = false;
|
|
14
|
-
while (node !== null) {
|
|
15
|
-
if (node === parent) {
|
|
16
|
-
hasChild = true;
|
|
17
|
-
}
|
|
18
|
-
node = node.parentNode;
|
|
19
|
-
}
|
|
20
|
-
return hasChild;
|
|
21
|
-
});
|
package/lib/index.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export { default as appendClassNames } from './append-class-names';
|
|
2
|
-
export { default as createBatch } from './batch';
|
|
3
|
-
export type { Batch, BatchFunction } from './batch';
|
|
4
|
-
export { default as camilize } from './camilize';
|
|
5
|
-
export { buildCategoryTrail, categoryTrail, getCategoryTrailAsObjects } from './category-trail';
|
|
6
|
-
export { default as createParams } from './create-params';
|
|
7
|
-
export type { Params, ParamValue } from './create-params';
|
|
8
|
-
export { default as dataURItoBlob } from './data-uri-to-blob';
|
|
9
|
-
export { debugLog, Logger } from './debug';
|
|
10
|
-
export { default as deepClone } from './deep-clone';
|
|
11
|
-
export { default as findAndActivateStoredWidgets } from './find-and-activate-stored-widgets';
|
|
12
|
-
export { default as findCategoryById } from './find-category-by-id';
|
|
13
|
-
export { default as formatDate } from './format-date';
|
|
14
|
-
export { default as formatUrl } from './format-url';
|
|
15
|
-
export { default as getCookie } from './get-cookie';
|
|
16
|
-
export { default as hash } from './hash';
|
|
17
|
-
export { default as htmlParentContains } from './html-parent-contains';
|
|
18
|
-
export { default as kebabCase } from './kebab-case';
|
|
19
|
-
export { default as lock } from './lock';
|
|
20
|
-
export { default as mergeDeep } from './merge-deep';
|
|
21
|
-
export { default as notifyDataLoaded } from './notify-data-loaded';
|
|
22
|
-
export { default as removeNullAndUndefinedValues } from './remove-null-and-undefined-values';
|
|
23
|
-
export { default as setCookie } from './set-cookie';
|
|
24
|
-
export { default as shallowCompare } from './shallow-compare';
|
|
25
|
-
export { default as uuid } from './uuid';
|
|
26
|
-
export { default as WaitFor } from './wait-for';
|
|
27
|
-
export type { WaitForOptions } from './wait-for';
|
package/lib/index.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.WaitFor = exports.uuid = exports.shallowCompare = exports.setCookie = exports.removeNullAndUndefinedValues = exports.notifyDataLoaded = exports.mergeDeep = exports.lock = exports.kebabCase = exports.htmlParentContains = exports.hash = exports.getCookie = exports.formatUrl = exports.formatDate = exports.findCategoryById = exports.findAndActivateStoredWidgets = exports.deepClone = exports.Logger = exports.debugLog = exports.dataURItoBlob = exports.createParams = exports.getCategoryTrailAsObjects = exports.categoryTrail = exports.buildCategoryTrail = exports.camilize = exports.createBatch = exports.appendClassNames = void 0;
|
|
7
|
-
var append_class_names_1 = require("./append-class-names");
|
|
8
|
-
Object.defineProperty(exports, "appendClassNames", { enumerable: true, get: function () { return __importDefault(append_class_names_1).default; } });
|
|
9
|
-
var batch_1 = require("./batch");
|
|
10
|
-
Object.defineProperty(exports, "createBatch", { enumerable: true, get: function () { return __importDefault(batch_1).default; } });
|
|
11
|
-
var camilize_1 = require("./camilize");
|
|
12
|
-
Object.defineProperty(exports, "camilize", { enumerable: true, get: function () { return __importDefault(camilize_1).default; } });
|
|
13
|
-
var category_trail_1 = require("./category-trail");
|
|
14
|
-
Object.defineProperty(exports, "buildCategoryTrail", { enumerable: true, get: function () { return category_trail_1.buildCategoryTrail; } });
|
|
15
|
-
Object.defineProperty(exports, "categoryTrail", { enumerable: true, get: function () { return category_trail_1.categoryTrail; } });
|
|
16
|
-
Object.defineProperty(exports, "getCategoryTrailAsObjects", { enumerable: true, get: function () { return category_trail_1.getCategoryTrailAsObjects; } });
|
|
17
|
-
var create_params_1 = require("./create-params");
|
|
18
|
-
Object.defineProperty(exports, "createParams", { enumerable: true, get: function () { return __importDefault(create_params_1).default; } });
|
|
19
|
-
var data_uri_to_blob_1 = require("./data-uri-to-blob");
|
|
20
|
-
Object.defineProperty(exports, "dataURItoBlob", { enumerable: true, get: function () { return __importDefault(data_uri_to_blob_1).default; } });
|
|
21
|
-
var debug_1 = require("./debug");
|
|
22
|
-
Object.defineProperty(exports, "debugLog", { enumerable: true, get: function () { return debug_1.debugLog; } });
|
|
23
|
-
Object.defineProperty(exports, "Logger", { enumerable: true, get: function () { return debug_1.Logger; } });
|
|
24
|
-
var deep_clone_1 = require("./deep-clone");
|
|
25
|
-
Object.defineProperty(exports, "deepClone", { enumerable: true, get: function () { return __importDefault(deep_clone_1).default; } });
|
|
26
|
-
var find_and_activate_stored_widgets_1 = require("./find-and-activate-stored-widgets");
|
|
27
|
-
Object.defineProperty(exports, "findAndActivateStoredWidgets", { enumerable: true, get: function () { return __importDefault(find_and_activate_stored_widgets_1).default; } });
|
|
28
|
-
var find_category_by_id_1 = require("./find-category-by-id");
|
|
29
|
-
Object.defineProperty(exports, "findCategoryById", { enumerable: true, get: function () { return __importDefault(find_category_by_id_1).default; } });
|
|
30
|
-
var format_date_1 = require("./format-date");
|
|
31
|
-
Object.defineProperty(exports, "formatDate", { enumerable: true, get: function () { return __importDefault(format_date_1).default; } });
|
|
32
|
-
var format_url_1 = require("./format-url");
|
|
33
|
-
Object.defineProperty(exports, "formatUrl", { enumerable: true, get: function () { return __importDefault(format_url_1).default; } });
|
|
34
|
-
var get_cookie_1 = require("./get-cookie");
|
|
35
|
-
Object.defineProperty(exports, "getCookie", { enumerable: true, get: function () { return __importDefault(get_cookie_1).default; } });
|
|
36
|
-
var hash_1 = require("./hash");
|
|
37
|
-
Object.defineProperty(exports, "hash", { enumerable: true, get: function () { return __importDefault(hash_1).default; } });
|
|
38
|
-
var html_parent_contains_1 = require("./html-parent-contains");
|
|
39
|
-
Object.defineProperty(exports, "htmlParentContains", { enumerable: true, get: function () { return __importDefault(html_parent_contains_1).default; } });
|
|
40
|
-
var kebab_case_1 = require("./kebab-case");
|
|
41
|
-
Object.defineProperty(exports, "kebabCase", { enumerable: true, get: function () { return __importDefault(kebab_case_1).default; } });
|
|
42
|
-
var lock_1 = require("./lock");
|
|
43
|
-
Object.defineProperty(exports, "lock", { enumerable: true, get: function () { return __importDefault(lock_1).default; } });
|
|
44
|
-
var merge_deep_1 = require("./merge-deep");
|
|
45
|
-
Object.defineProperty(exports, "mergeDeep", { enumerable: true, get: function () { return __importDefault(merge_deep_1).default; } });
|
|
46
|
-
var notify_data_loaded_1 = require("./notify-data-loaded");
|
|
47
|
-
Object.defineProperty(exports, "notifyDataLoaded", { enumerable: true, get: function () { return __importDefault(notify_data_loaded_1).default; } });
|
|
48
|
-
var remove_null_and_undefined_values_1 = require("./remove-null-and-undefined-values");
|
|
49
|
-
Object.defineProperty(exports, "removeNullAndUndefinedValues", { enumerable: true, get: function () { return __importDefault(remove_null_and_undefined_values_1).default; } });
|
|
50
|
-
var set_cookie_1 = require("./set-cookie");
|
|
51
|
-
Object.defineProperty(exports, "setCookie", { enumerable: true, get: function () { return __importDefault(set_cookie_1).default; } });
|
|
52
|
-
var shallow_compare_1 = require("./shallow-compare");
|
|
53
|
-
Object.defineProperty(exports, "shallowCompare", { enumerable: true, get: function () { return __importDefault(shallow_compare_1).default; } });
|
|
54
|
-
var uuid_1 = require("./uuid");
|
|
55
|
-
Object.defineProperty(exports, "uuid", { enumerable: true, get: function () { return __importDefault(uuid_1).default; } });
|
|
56
|
-
var wait_for_1 = require("./wait-for");
|
|
57
|
-
Object.defineProperty(exports, "WaitFor", { enumerable: true, get: function () { return __importDefault(wait_for_1).default; } });
|
package/lib/is-anchor-link.d.ts
DELETED
package/lib/is-anchor-link.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
// Determine if href starts with a hashtag
|
|
4
|
-
var isAnchorLink = function (href) {
|
|
5
|
-
var re = new RegExp('^#', 'i');
|
|
6
|
-
var match = re.test(href);
|
|
7
|
-
return match;
|
|
8
|
-
};
|
|
9
|
-
exports.default = isAnchorLink;
|
package/lib/kebab-case.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function kebabCase(string: string): string;
|
package/lib/kebab-case.js
DELETED
package/lib/lock.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
declare type Task = () => Promise<any> | any;
|
|
2
|
-
export declare type AddTask = (task: Task) => Promise<any>;
|
|
3
|
-
/**
|
|
4
|
-
* Creates a lock for the specified owner that allows only one executing
|
|
5
|
-
* task simultaneously.
|
|
6
|
-
* @param key Lock owner.
|
|
7
|
-
*/
|
|
8
|
-
export default function lock(key: object, lockWarningTime?: number, lockErrorTime?: number): AddTask;
|
|
9
|
-
export {};
|
package/lib/lock.js
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var debug_1 = require("./debug");
|
|
4
|
-
var Queue = /** @class */ (function () {
|
|
5
|
-
function Queue(lockWarningTime, lockErrorTime) {
|
|
6
|
-
this.lockWarningTime = lockWarningTime;
|
|
7
|
-
this.lockErrorTime = lockErrorTime;
|
|
8
|
-
this.tasks = [];
|
|
9
|
-
this.current = Promise.resolve();
|
|
10
|
-
this.next = this.next.bind(this);
|
|
11
|
-
}
|
|
12
|
-
Queue.prototype.add = function (task, resolve, reject, done) {
|
|
13
|
-
this.tasks.push({ task: task, resolve: resolve, reject: reject, done: done });
|
|
14
|
-
this.next();
|
|
15
|
-
};
|
|
16
|
-
Queue.prototype.next = function () {
|
|
17
|
-
var _this = this;
|
|
18
|
-
this.current = this.current.then(function () {
|
|
19
|
-
var next = _this.tasks.shift();
|
|
20
|
-
if (next) {
|
|
21
|
-
var errorTimeout_1; // NodeJS.Timeout
|
|
22
|
-
var warningTimeout_1 = setTimeout(function () {
|
|
23
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
24
|
-
// tslint:disable-next-line max-line-length
|
|
25
|
-
debug_1.Logger.warn("A lock has exceeded ".concat(_this.lockWarningTime, " ms. Waiting additional ").concat(_this.lockErrorTime, " ms before rejecting the task."), next);
|
|
26
|
-
}
|
|
27
|
-
errorTimeout_1 = setTimeout(function () {
|
|
28
|
-
next.reject('lock timeout exceeded');
|
|
29
|
-
}, _this.lockErrorTime);
|
|
30
|
-
}, _this.lockWarningTime);
|
|
31
|
-
var taskPromise_1 = Promise.resolve(next.task()).then(function (result) {
|
|
32
|
-
clearTimeout(warningTimeout_1);
|
|
33
|
-
clearTimeout(errorTimeout_1);
|
|
34
|
-
return result;
|
|
35
|
-
});
|
|
36
|
-
return Promise.resolve(taskPromise_1)
|
|
37
|
-
.then(_this.next)
|
|
38
|
-
.then(function () {
|
|
39
|
-
return taskPromise_1.then(function (data) {
|
|
40
|
-
next.done();
|
|
41
|
-
next.resolve(data);
|
|
42
|
-
});
|
|
43
|
-
})
|
|
44
|
-
.catch(function (reason) {
|
|
45
|
-
next.done();
|
|
46
|
-
next.reject(reason);
|
|
47
|
-
return _this.next();
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
return Promise.resolve();
|
|
51
|
-
});
|
|
52
|
-
};
|
|
53
|
-
return Queue;
|
|
54
|
-
}());
|
|
55
|
-
var locks = new WeakMap();
|
|
56
|
-
/**
|
|
57
|
-
* Creates a lock for the specified owner that allows only one executing
|
|
58
|
-
* task simultaneously.
|
|
59
|
-
* @param key Lock owner.
|
|
60
|
-
*/
|
|
61
|
-
function lock(key, lockWarningTime, lockErrorTime) {
|
|
62
|
-
if (lockWarningTime === void 0) { lockWarningTime = 5000; }
|
|
63
|
-
if (lockErrorTime === void 0) { lockErrorTime = 1000; }
|
|
64
|
-
if (!locks.has(key)) {
|
|
65
|
-
locks.set(key, new Queue(lockWarningTime, lockErrorTime));
|
|
66
|
-
}
|
|
67
|
-
return function (task) {
|
|
68
|
-
return new Promise(function (resolve, reject) {
|
|
69
|
-
var queue = locks.get(key);
|
|
70
|
-
queue.add(task, resolve, reject, function () {
|
|
71
|
-
if (!queue.tasks.length) {
|
|
72
|
-
locks.delete(key);
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
exports.default = lock;
|
package/lib/merge-deep.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @param target Target to merge into
|
|
3
|
-
* @param sources Source to merge into target
|
|
4
|
-
* @returns Clone (new reference) with merged sources
|
|
5
|
-
*/
|
|
6
|
-
declare const mergeDeep: <Target, Source>(target: Target, ...sources: Source[]) => Target & Source;
|
|
7
|
-
export default mergeDeep;
|
package/lib/merge-deep.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
3
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
|
-
if (!m) return o;
|
|
5
|
-
var i = m.call(o), r, ar = [], e;
|
|
6
|
-
try {
|
|
7
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
8
|
-
}
|
|
9
|
-
catch (error) { e = { error: error }; }
|
|
10
|
-
finally {
|
|
11
|
-
try {
|
|
12
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
13
|
-
}
|
|
14
|
-
finally { if (e) throw e.error; }
|
|
15
|
-
}
|
|
16
|
-
return ar;
|
|
17
|
-
};
|
|
18
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
19
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
20
|
-
if (ar || !(i in from)) {
|
|
21
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
22
|
-
ar[i] = from[i];
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
26
|
-
};
|
|
27
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
28
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
29
|
-
};
|
|
30
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
-
var deep_clone_1 = __importDefault(require("./deep-clone"));
|
|
32
|
-
var isObject = function (item) {
|
|
33
|
-
return !!item && typeof item === 'object' && !Array.isArray(item);
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* @param target Target to merge into
|
|
37
|
-
* @param sources Source to merge into target
|
|
38
|
-
* @returns Clone (new reference) with merged sources
|
|
39
|
-
*/
|
|
40
|
-
var mergeDeep = function (target) {
|
|
41
|
-
var sources = [];
|
|
42
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
43
|
-
sources[_i - 1] = arguments[_i];
|
|
44
|
-
}
|
|
45
|
-
var clonedTarget = (0, deep_clone_1.default)(target);
|
|
46
|
-
var clonedSources = (0, deep_clone_1.default)(sources);
|
|
47
|
-
return mergeDeepRecursive.apply(void 0, __spreadArray([clonedTarget], __read(clonedSources), false));
|
|
48
|
-
};
|
|
49
|
-
var mergeDeepRecursive = function (target) {
|
|
50
|
-
var _a, _b;
|
|
51
|
-
var sources = [];
|
|
52
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
53
|
-
sources[_i - 1] = arguments[_i];
|
|
54
|
-
}
|
|
55
|
-
if (!sources.length)
|
|
56
|
-
return target;
|
|
57
|
-
var source = sources.shift();
|
|
58
|
-
if (isObject(target) && isObject(source)) {
|
|
59
|
-
for (var key in source) {
|
|
60
|
-
if (isObject(source[key])) {
|
|
61
|
-
if (!target[key])
|
|
62
|
-
Object.assign(target, (_a = {}, _a[key] = {}, _a));
|
|
63
|
-
mergeDeepRecursive(target[key], source[key]);
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
Object.assign(target, (_b = {}, _b[key] = source[key], _b));
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return mergeDeepRecursive.apply(void 0, __spreadArray([target], __read(sources), false));
|
|
71
|
-
};
|
|
72
|
-
exports.default = mergeDeep;
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/**
|
|
4
|
-
* Dispatch widget:data-loaded event when all components
|
|
5
|
-
* is considered to be finished loading their initial data
|
|
6
|
-
*/
|
|
7
|
-
var watchForLoadingComplete = function (container, widgetDOMElement) {
|
|
8
|
-
var isLoading = function () { return widgetDOMElement.querySelectorAll('[data-loading=true]').length > 0; };
|
|
9
|
-
var complete = function () {
|
|
10
|
-
var dispatched = false;
|
|
11
|
-
return function () {
|
|
12
|
-
if (dispatched) {
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
var widget = container.get('$widget');
|
|
16
|
-
widget.events.dispatch('widget:data-loaded', {
|
|
17
|
-
element: widgetDOMElement,
|
|
18
|
-
});
|
|
19
|
-
dispatched = true;
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
var handleComplete = complete();
|
|
23
|
-
if (!isLoading()) {
|
|
24
|
-
return handleComplete();
|
|
25
|
-
}
|
|
26
|
-
var observer = new MutationObserver(function (mutations, observer) {
|
|
27
|
-
var check = mutations.find(function (mutation) {
|
|
28
|
-
return mutation.type === 'attributes' && mutation.attributeName === 'data-loading';
|
|
29
|
-
});
|
|
30
|
-
if (check && !isLoading()) {
|
|
31
|
-
observer.disconnect();
|
|
32
|
-
handleComplete();
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
observer.observe(widgetDOMElement, {
|
|
36
|
-
attributes: true,
|
|
37
|
-
childList: true,
|
|
38
|
-
subtree: true,
|
|
39
|
-
});
|
|
40
|
-
};
|
|
41
|
-
/**
|
|
42
|
-
* Wait for all visible components to render
|
|
43
|
-
*/
|
|
44
|
-
var notifyDataLoaded = function (viewOutletContainer, widgetDOMElement) {
|
|
45
|
-
var widget = viewOutletContainer.get('$widget');
|
|
46
|
-
widget.container.getAsync('components').then(function (components) {
|
|
47
|
-
components.events.subscribeOnce('components:component-model-initialized', function () {
|
|
48
|
-
// Store the names of all visible components we should wait for
|
|
49
|
-
var waitingFor = components.nodes.visible.reduce(function (acc, node) {
|
|
50
|
-
if (!node.name ||
|
|
51
|
-
!node.type ||
|
|
52
|
-
node.type === 'view' ||
|
|
53
|
-
node.type === 'root' ||
|
|
54
|
-
node.attributes.layout.size === 'none') {
|
|
55
|
-
return acc;
|
|
56
|
-
}
|
|
57
|
-
acc.push(node.name);
|
|
58
|
-
return acc;
|
|
59
|
-
}, []);
|
|
60
|
-
var complete = false;
|
|
61
|
-
var observer = new MutationObserver(function (mutations, observer) {
|
|
62
|
-
mutations.forEach(function (mutation) {
|
|
63
|
-
if (mutation.addedNodes) {
|
|
64
|
-
var componentElements_1 = Array.from(mutation.addedNodes).reduce(function (acc, element) {
|
|
65
|
-
var dataName = element.getAttribute && element.getAttribute('data-name');
|
|
66
|
-
if (dataName && waitingFor.indexOf(dataName) > -1) {
|
|
67
|
-
acc.push(dataName);
|
|
68
|
-
}
|
|
69
|
-
return acc;
|
|
70
|
-
}, []);
|
|
71
|
-
// Remove added elements from the list of elements we are waiting for
|
|
72
|
-
waitingFor = waitingFor.filter(function (name) {
|
|
73
|
-
return componentElements_1.indexOf(name) === -1;
|
|
74
|
-
});
|
|
75
|
-
// When the list is empty, we are finished waiting for components to render
|
|
76
|
-
if (!complete && waitingFor.length === 0) {
|
|
77
|
-
complete = true;
|
|
78
|
-
// Creates a new observer that observes data-loading changes
|
|
79
|
-
watchForLoadingComplete(viewOutletContainer, widgetDOMElement);
|
|
80
|
-
observer.disconnect();
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
observer.observe(widgetDOMElement, {
|
|
86
|
-
attributes: false,
|
|
87
|
-
characterData: false,
|
|
88
|
-
childList: true,
|
|
89
|
-
subtree: true,
|
|
90
|
-
attributeOldValue: false,
|
|
91
|
-
characterDataOldValue: false,
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
};
|
|
96
|
-
exports.default = notifyDataLoaded;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var removeNullAndUndefinedValues = function (object) {
|
|
4
|
-
if (object === void 0) { object = {}; }
|
|
5
|
-
Object.keys(object).forEach(function (key) {
|
|
6
|
-
if (object[key] === null || typeof object[key] === 'undefined') {
|
|
7
|
-
delete object[key];
|
|
8
|
-
}
|
|
9
|
-
});
|
|
10
|
-
return object;
|
|
11
|
-
};
|
|
12
|
-
exports.default = removeNullAndUndefinedValues;
|
package/lib/set-cookie.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function setCookie(cookieName: string, value: any, days: number): void;
|
package/lib/set-cookie.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
function setCookie(cookieName, value, days) {
|
|
4
|
-
var expires = '';
|
|
5
|
-
if (days) {
|
|
6
|
-
var date = new Date();
|
|
7
|
-
date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
|
|
8
|
-
expires = "; expires=".concat(date.toUTCString());
|
|
9
|
-
}
|
|
10
|
-
document.cookie = "".concat(cookieName, "=").concat(value).concat(expires, "; path=/");
|
|
11
|
-
}
|
|
12
|
-
exports.default = setCookie;
|
package/lib/shallow-compare.d.ts
DELETED
package/lib/shallow-compare.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = (function (a, b) {
|
|
4
|
-
var equal = true;
|
|
5
|
-
if (Object.keys(a).length !== Object.keys(b).length) {
|
|
6
|
-
return false;
|
|
7
|
-
}
|
|
8
|
-
var missingKey = Object.keys(a).some(function (key) {
|
|
9
|
-
var found = Object.keys(b).some(function (bKey) {
|
|
10
|
-
return key === bKey;
|
|
11
|
-
});
|
|
12
|
-
return !found;
|
|
13
|
-
});
|
|
14
|
-
if (missingKey) {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
Object.keys(a).forEach(function (key) {
|
|
18
|
-
if (equal) {
|
|
19
|
-
var c = typeof a[key] === 'undefined' ? '' : a[key];
|
|
20
|
-
var d = typeof b[key] === 'undefined' ? '' : b[key];
|
|
21
|
-
equal = c.toString() === d.toString();
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
return equal;
|
|
25
|
-
});
|
package/lib/uuid.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function uuid(): string;
|
package/lib/uuid.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var s4 = function () {
|
|
4
|
-
return Math.floor((1 + Math.random()) * 0x10000)
|
|
5
|
-
.toString(16)
|
|
6
|
-
.substring(1);
|
|
7
|
-
};
|
|
8
|
-
function uuid() {
|
|
9
|
-
// tslint:disable-next-line prefer-template
|
|
10
|
-
return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
|
|
11
|
-
}
|
|
12
|
-
exports.default = uuid;
|
package/lib/wait-for.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
declare type Action = (...args: any[]) => Function | false;
|
|
2
|
-
export declare type WaitForOptions = {
|
|
3
|
-
callCount?: number;
|
|
4
|
-
};
|
|
5
|
-
export default class WaitFor {
|
|
6
|
-
private queue;
|
|
7
|
-
private queueAttempt;
|
|
8
|
-
private queueAttemptCalls;
|
|
9
|
-
private callCount;
|
|
10
|
-
constructor(options?: WaitForOptions);
|
|
11
|
-
/**
|
|
12
|
-
* Add action to the queue
|
|
13
|
-
*/
|
|
14
|
-
add: (action: Action) => void;
|
|
15
|
-
/**
|
|
16
|
-
* Go through queue and attempt to call each action
|
|
17
|
-
*/
|
|
18
|
-
processQueue: () => void;
|
|
19
|
-
}
|
|
20
|
-
export {};
|
package/lib/wait-for.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var WaitFor = /** @class */ (function () {
|
|
4
|
-
function WaitFor(options) {
|
|
5
|
-
var _this = this;
|
|
6
|
-
this.queue = [];
|
|
7
|
-
this.queueAttemptCalls = 0;
|
|
8
|
-
this.callCount = 5;
|
|
9
|
-
/**
|
|
10
|
-
* Add action to the queue
|
|
11
|
-
*/
|
|
12
|
-
this.add = function (action) {
|
|
13
|
-
_this.queue.push(action);
|
|
14
|
-
_this.queueAttempt = setInterval(_this.processQueue, 1000);
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* Go through queue and attempt to call each action
|
|
18
|
-
*/
|
|
19
|
-
this.processQueue = function () {
|
|
20
|
-
if (_this.queue.length > 0) {
|
|
21
|
-
var indexOfActionsEmitted_1 = [];
|
|
22
|
-
_this.queue.forEach(function (queuedAction, index) {
|
|
23
|
-
var evaluate = queuedAction();
|
|
24
|
-
if (typeof evaluate === 'function') {
|
|
25
|
-
evaluate();
|
|
26
|
-
indexOfActionsEmitted_1.push(index);
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
// clean up queue
|
|
30
|
-
_this.queue = _this.queue.filter(function (_, index) {
|
|
31
|
-
if (indexOfActionsEmitted_1.indexOf(index) > -1) {
|
|
32
|
-
return false;
|
|
33
|
-
}
|
|
34
|
-
return true;
|
|
35
|
-
});
|
|
36
|
-
if (_this.queueAttempt) {
|
|
37
|
-
clearInterval(_this.queueAttempt);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
if (_this.queueAttemptCalls > _this.callCount) {
|
|
41
|
-
clearInterval(_this.queueAttempt);
|
|
42
|
-
_this.queueAttemptCalls = 0;
|
|
43
|
-
}
|
|
44
|
-
_this.queueAttemptCalls = _this.queueAttemptCalls + 1;
|
|
45
|
-
};
|
|
46
|
-
if (options && options.callCount) {
|
|
47
|
-
this.callCount = options.callCount;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
return WaitFor;
|
|
51
|
-
}());
|
|
52
|
-
exports.default = WaitFor;
|