@selfcommunity/utils 0.1.7 → 0.1.8-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/lib/{types → cjs}/index.d.ts +2 -2
  2. package/lib/cjs/index.d.ts.map +1 -0
  3. package/lib/cjs/index.js +35 -50
  4. package/lib/cjs/index.js.map +1 -0
  5. package/lib/{types → cjs}/utils/browser.d.ts +0 -0
  6. package/lib/{types → cjs}/utils/browser.d.ts.map +0 -0
  7. package/lib/cjs/utils/browser.js +62 -78
  8. package/lib/cjs/utils/browser.js.map +1 -0
  9. package/lib/{types → cjs}/utils/logger.d.ts +0 -0
  10. package/lib/{types → cjs}/utils/logger.d.ts.map +0 -0
  11. package/lib/cjs/utils/logger.js +18 -25
  12. package/lib/cjs/utils/logger.js.map +1 -0
  13. package/lib/{types → cjs}/utils/object.d.ts +0 -0
  14. package/lib/{types → cjs}/utils/object.d.ts.map +0 -0
  15. package/lib/cjs/utils/object.js +23 -29
  16. package/lib/cjs/utils/object.js.map +1 -0
  17. package/lib/{types → cjs}/utils/string.d.ts +0 -0
  18. package/lib/{types → cjs}/utils/string.d.ts.map +0 -0
  19. package/lib/cjs/utils/string.js +56 -65
  20. package/lib/cjs/utils/string.js.map +1 -0
  21. package/lib/{types → cjs}/utils/url.d.ts +0 -0
  22. package/lib/{types → cjs}/utils/url.d.ts.map +0 -0
  23. package/lib/cjs/utils/url.js +52 -77
  24. package/lib/cjs/utils/url.js.map +1 -0
  25. package/lib/{types → cjs}/utils/websocket.d.ts +0 -0
  26. package/lib/{types → cjs}/utils/websocket.d.ts.map +0 -0
  27. package/lib/cjs/utils/websocket.js +221 -284
  28. package/lib/cjs/utils/websocket.js.map +1 -0
  29. package/lib/cjs/utils/window.d.ts +5 -0
  30. package/lib/cjs/utils/window.d.ts.map +1 -0
  31. package/lib/cjs/utils/window.js +34 -32
  32. package/lib/cjs/utils/window.js.map +1 -0
  33. package/lib/esm/index.d.ts +12 -0
  34. package/lib/esm/index.d.ts.map +1 -0
  35. package/lib/esm/index.js +12 -51
  36. package/lib/esm/index.js.map +1 -0
  37. package/lib/esm/utils/browser.d.ts +9 -0
  38. package/lib/esm/utils/browser.d.ts.map +1 -0
  39. package/lib/esm/utils/browser.js +61 -81
  40. package/lib/esm/utils/browser.js.map +1 -0
  41. package/lib/esm/utils/logger.d.ts +11 -0
  42. package/lib/esm/utils/logger.d.ts.map +1 -0
  43. package/lib/esm/utils/logger.js +17 -28
  44. package/lib/esm/utils/logger.js.map +1 -0
  45. package/lib/esm/utils/object.d.ts +13 -0
  46. package/lib/esm/utils/object.d.ts.map +1 -0
  47. package/lib/esm/utils/object.js +21 -32
  48. package/lib/esm/utils/object.js.map +1 -0
  49. package/lib/esm/utils/string.d.ts +43 -0
  50. package/lib/esm/utils/string.d.ts.map +1 -0
  51. package/lib/esm/utils/string.js +54 -73
  52. package/lib/esm/utils/string.js.map +1 -0
  53. package/lib/esm/utils/url.d.ts +33 -0
  54. package/lib/esm/utils/url.d.ts.map +1 -0
  55. package/lib/esm/utils/url.js +46 -80
  56. package/lib/esm/utils/url.js.map +1 -0
  57. package/lib/esm/utils/websocket.d.ts +177 -0
  58. package/lib/esm/utils/websocket.d.ts.map +1 -0
  59. package/lib/esm/utils/websocket.js +220 -286
  60. package/lib/esm/utils/websocket.js.map +1 -0
  61. package/lib/esm/utils/window.d.ts +5 -0
  62. package/lib/esm/utils/window.d.ts.map +1 -0
  63. package/lib/esm/utils/window.js +31 -36
  64. package/lib/esm/utils/window.js.map +1 -0
  65. package/lib/umd/utils.js +1 -1
  66. package/lib/umd/utils.js.map +1 -1
  67. package/package.json +5 -7
  68. package/lib/cjs/index.d.js +0 -2
  69. package/lib/esm/index.d.js +0 -2
  70. package/lib/types/index.d.ts.map +0 -1
  71. package/lib/types/tsconfig.build.tsbuildinfo +0 -1
package/lib/esm/index.js CHANGED
@@ -1,51 +1,12 @@
1
- "use strict";
2
-
3
- exports.__esModule = true;
4
-
5
- var _string = require("./utils/string");
6
-
7
- exports.capitalize = _string.capitalize;
8
- exports.isString = _string.isString;
9
- exports.stripHtml = _string.stripHtml;
10
- exports.camelCase = _string.camelCase;
11
- exports.copyTextToClipboard = _string.copyTextToClipboard;
12
- exports.fallbackCopyTextToClipboard = _string.fallbackCopyTextToClipboard;
13
- exports.random = _string.random;
14
-
15
- var _url = require("./utils/url");
16
-
17
- exports.isValidUrl = _url.isValidUrl;
18
- exports.isValidUrls = _url.isValidUrls;
19
- exports.urlReplacer = _url.urlReplacer;
20
- exports.getDomain = _url.getDomain;
21
- exports.appendURLSearchParams = _url.appendURLSearchParams;
22
- exports.urlB64ToUint8Array = _url.urlB64ToUint8Array;
23
-
24
- var _window = require("./utils/window");
25
-
26
- exports.getHighestSafeWindowContext = _window.getHighestSafeWindowContext;
27
- exports.getWindowWidth = _window.getWindowWidth;
28
- exports.getWindowHeight = _window.getWindowHeight;
29
-
30
- var _object = require("./utils/object");
31
-
32
- exports.mergeDeep = _object.mergeDeep;
33
- exports.isObject = _object.isObject;
34
-
35
- var _browser = require("./utils/browser");
36
-
37
- exports.loadVersionBrowser = _browser.loadVersionBrowser;
38
-
39
- var _logger = require("./utils/logger");
40
-
41
- exports.Logger = _logger.Logger;
42
-
43
- var _websocket = _interopRequireWildcard(require("./utils/websocket"));
44
-
45
- exports.WSClient = _websocket.default;
46
- exports.WSClientType = _websocket.WSClientType;
47
- exports.WSClientPropTypes = _websocket.WSClientPropTypes;
48
-
49
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
50
-
51
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
1
+ import { capitalize, isString, stripHtml, camelCase, copyTextToClipboard, fallbackCopyTextToClipboard, random } from './utils/string';
2
+ import { isValidUrl, isValidUrls, urlReplacer, getDomain, appendURLSearchParams, urlB64ToUint8Array } from './utils/url';
3
+ import { getHighestSafeWindowContext, getWindowWidth, getWindowHeight, isClientSideRendering } from './utils/window';
4
+ import { mergeDeep, isObject } from './utils/object';
5
+ import { loadVersionBrowser } from './utils/browser';
6
+ import { Logger } from './utils/logger';
7
+ import WSClient from './utils/websocket';
8
+ /**
9
+ * Export all utilities
10
+ */
11
+ export { capitalize, isString, stripHtml, camelCase, copyTextToClipboard, fallbackCopyTextToClipboard, random, isValidUrl, isValidUrls, urlReplacer, getDomain, appendURLSearchParams, urlB64ToUint8Array, getHighestSafeWindowContext, getWindowWidth, getWindowHeight, isClientSideRendering, Logger, mergeDeep, isObject, WSClient, loadVersionBrowser };
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,mBAAmB,EAAE,2BAA2B,EAAE,MAAM,EAAC,MAAM,gBAAgB,CAAC;AACpI,OAAO,EAAC,UAAU,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,qBAAqB,EAAE,kBAAkB,EAAC,MAAM,aAAa,CAAC;AACvH,OAAO,EAAC,2BAA2B,EAAE,cAAc,EAAE,eAAe,EAAE,qBAAqB,EAAC,MAAM,gBAAgB,CAAC;AACnH,OAAO,EAAC,SAAS,EAAE,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAC,kBAAkB,EAAC,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAC,MAAM,EAAC,MAAM,gBAAgB,CAAC;AACtC,OAAO,QAA2C,MAAM,mBAAmB,CAAC;AAE5E;;GAEG;AACH,OAAO,EACL,UAAU,EACV,QAAQ,EACR,SAAS,EACT,SAAS,EACT,mBAAmB,EACnB,2BAA2B,EAC3B,MAAM,EACN,UAAU,EACV,WAAW,EACX,WAAW,EACX,SAAS,EACT,qBAAqB,EACrB,kBAAkB,EAClB,2BAA2B,EAC3B,cAAc,EACd,eAAe,EACf,qBAAqB,EACrB,MAAM,EACN,SAAS,EACT,QAAQ,EACR,QAAQ,EAGR,kBAAkB,EACnB,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Get browser version to track on backend
3
+ * @return {{name: string, version: null}|{name: string, version: string}|{name: *, version: *}|{name: string, version}}
4
+ */
5
+ export declare const loadVersionBrowser: () => {
6
+ name: any;
7
+ version: any;
8
+ };
9
+ //# sourceMappingURL=browser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../../src/utils/browser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,kBAAkB;;;CAgE9B,CAAC"}
@@ -1,90 +1,70 @@
1
- "use strict";
2
-
3
- exports.__esModule = true;
4
- exports.loadVersionBrowser = void 0;
5
-
6
1
  /**
7
2
  * Get browser version to track on backend
8
3
  * @return {{name: string, version: null}|{name: string, version: string}|{name: *, version: *}|{name: string, version}}
9
4
  */
10
- const loadVersionBrowser = () => {
11
- if ('userAgentData' in navigator) {
12
- // navigator.userAgentData is not available in
13
- // Firefox and Safari
14
- const uaData = navigator['userAgentData']; // Outputs of navigator.userAgentData.brands[n].brand are e.g.
15
- // Chrome: 'Google Chrome'
16
- // Edge: 'Microsoft Edge'
17
- // Opera: 'Opera'
18
-
19
- let browsername;
20
- let browserversion;
21
- let chromeVersion = null;
22
-
23
- for (let i = 0; i < uaData['brands'].length; i++) {
24
- const brand = uaData['brands'][i].brand;
25
- browserversion = uaData['brands'][i].version;
26
-
27
- if (brand.match(/opera|chrome|edge|safari|firefox|msie|trident/i) !== null) {
28
- // If we have a chrome match, save the match, but try to find another match
29
- // E.g. Edge can also produce a false Chrome match.
30
- if (brand.match(/chrome/i) !== null) {
31
- chromeVersion = browserversion;
32
- } // If this is not a chrome match return immediately
33
- else {
34
- browsername = brand.substr(brand.indexOf(' ') + 1);
35
- return {
36
- name: browsername,
37
- version: browserversion
38
- };
5
+ export const loadVersionBrowser = () => {
6
+ if ('userAgentData' in navigator) {
7
+ // navigator.userAgentData is not available in
8
+ // Firefox and Safari
9
+ const uaData = navigator['userAgentData'];
10
+ // Outputs of navigator.userAgentData.brands[n].brand are e.g.
11
+ // Chrome: 'Google Chrome'
12
+ // Edge: 'Microsoft Edge'
13
+ // Opera: 'Opera'
14
+ let browsername;
15
+ let browserversion;
16
+ let chromeVersion = null;
17
+ for (let i = 0; i < uaData['brands'].length; i++) {
18
+ const brand = uaData['brands'][i].brand;
19
+ browserversion = uaData['brands'][i].version;
20
+ if (brand.match(/opera|chrome|edge|safari|firefox|msie|trident/i) !== null) {
21
+ // If we have a chrome match, save the match, but try to find another match
22
+ // E.g. Edge can also produce a false Chrome match.
23
+ if (brand.match(/chrome/i) !== null) {
24
+ chromeVersion = browserversion;
25
+ }
26
+ // If this is not a chrome match return immediately
27
+ else {
28
+ browsername = brand.substr(brand.indexOf(' ') + 1);
29
+ return {
30
+ name: browsername,
31
+ version: browserversion,
32
+ };
33
+ }
34
+ }
39
35
  }
40
- }
41
- } // No non-Chrome match was found. If we have a chrome match, return it.
42
-
43
-
44
- if (chromeVersion !== null) {
45
- return {
46
- name: 'chrome',
47
- version: chromeVersion
48
- };
36
+ // No non-Chrome match was found. If we have a chrome match, return it.
37
+ if (chromeVersion !== null) {
38
+ return {
39
+ name: 'chrome',
40
+ version: chromeVersion,
41
+ };
42
+ }
43
+ }
44
+ // If no userAgentData is not present, or if no match via userAgentData was found,
45
+ // try to extract the browser name and version from userAgent
46
+ const userAgent = navigator.userAgent;
47
+ let ua = userAgent;
48
+ let tem;
49
+ let M = ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
50
+ if (/trident/i.test(M[1])) {
51
+ tem = /\brv[ :]+(\d+)/g.exec(ua) || [];
52
+ return { name: 'IE', version: tem[1] || '' };
53
+ }
54
+ if (M[1] === 'Chrome') {
55
+ tem = ua.match(/\bOPR\/(\d+)/);
56
+ if (tem != null) {
57
+ return { name: 'Opera', version: tem[1] };
58
+ }
59
+ }
60
+ M = M[2] ? [M[1], M[2]] : [navigator.appName, navigator.appVersion, '-?'];
61
+ // eslint-disable-next-line @typescript-eslint/prefer-regexp-exec
62
+ if ((tem = ua.match(/version\/(\d+)/i)) != null) {
63
+ M.splice(1, 1, tem[1]);
49
64
  }
50
- } // If no userAgentData is not present, or if no match via userAgentData was found,
51
- // try to extract the browser name and version from userAgent
52
-
53
-
54
- const userAgent = navigator.userAgent;
55
- let ua = userAgent;
56
- let tem;
57
- let M = ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
58
-
59
- if (/trident/i.test(M[1])) {
60
- tem = /\brv[ :]+(\d+)/g.exec(ua) || [];
61
65
  return {
62
- name: 'IE',
63
- version: tem[1] || ''
66
+ name: M[0],
67
+ version: M[1],
64
68
  };
65
- }
66
-
67
- if (M[1] === 'Chrome') {
68
- tem = ua.match(/\bOPR\/(\d+)/);
69
-
70
- if (tem != null) {
71
- return {
72
- name: 'Opera',
73
- version: tem[1]
74
- };
75
- }
76
- }
77
-
78
- M = M[2] ? [M[1], M[2]] : [navigator.appName, navigator.appVersion, '-?']; // eslint-disable-next-line @typescript-eslint/prefer-regexp-exec
79
-
80
- if ((tem = ua.match(/version\/(\d+)/i)) != null) {
81
- M.splice(1, 1, tem[1]);
82
- }
83
-
84
- return {
85
- name: M[0],
86
- version: M[1]
87
- };
88
69
  };
89
-
90
- exports.loadVersionBrowser = loadVersionBrowser;
70
+ //# sourceMappingURL=browser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser.js","sourceRoot":"","sources":["../../../src/utils/browser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,EAAE;IACrC,IAAI,eAAe,IAAI,SAAS,EAAE;QAChC,8CAA8C;QAC9C,qBAAqB;QACrB,MAAM,MAAM,GAAe,SAAS,CAAC,eAAe,CAAC,CAAC;QACtD,8DAA8D;QAC9D,0BAA0B;QAC1B,yBAAyB;QACzB,iBAAiB;QACjB,IAAI,WAAW,CAAC;QAChB,IAAI,cAAc,CAAC;QACnB,IAAI,aAAa,GAAG,IAAI,CAAC;QACzB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAChD,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;YACxC,cAAc,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;YAC7C,IAAI,KAAK,CAAC,KAAK,CAAC,gDAAgD,CAAC,KAAK,IAAI,EAAE;gBAC1E,2EAA2E;gBAC3E,mDAAmD;gBACnD,IAAI,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;oBACnC,aAAa,GAAG,cAAc,CAAC;iBAChC;gBACD,mDAAmD;qBAC9C;oBACH,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,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AAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,IAAI,IAAI,EAAE;QAC/C,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;KACxB;IACD,OAAO;QACL,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QACV,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;KACd,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Emit styled message
3
+ */
4
+ export declare class Logger {
5
+ static info(scope: any, message: any): void;
6
+ static warn(scope: any, message: any): void;
7
+ static error(scope: any, message: any): void;
8
+ static log(scope: any, message: any): void;
9
+ static debug(scope: any, message: any): void;
10
+ }
11
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/utils/logger.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,MAAM;IACjB,MAAM,CAAC,IAAI,CAAC,KAAK,KAAA,EAAE,OAAO,KAAA;IAI1B,MAAM,CAAC,IAAI,CAAC,KAAK,KAAA,EAAE,OAAO,KAAA;IAI1B,MAAM,CAAC,KAAK,CAAC,KAAK,KAAA,EAAE,OAAO,KAAA;IAI3B,MAAM,CAAC,GAAG,CAAC,KAAK,KAAA,EAAE,OAAO,KAAA;IAIzB,MAAM,CAAC,KAAK,CAAC,KAAK,KAAA,EAAE,OAAO,KAAA;CAG5B"}
@@ -1,32 +1,21 @@
1
- "use strict";
2
-
3
- exports.__esModule = true;
4
- exports.Logger = void 0;
5
-
6
1
  /**
7
2
  * Emit styled message
8
3
  */
9
- class Logger {
10
- static info(scope, message) {
11
- console.info(`%c[${scope}]`, 'color:#008080', ` ${message}`);
12
- }
13
-
14
- static warn(scope, message) {
15
- console.warn(`%c[${scope}]`, 'color:#008080', ` ${message}`);
16
- }
17
-
18
- static error(scope, message) {
19
- console.error(`%c[${scope}]`, 'color:#008080', ` ${message}`);
20
- }
21
-
22
- static log(scope, message) {
23
- console.log(`%c[${scope}]`, 'color:#008080', ` ${message}`);
24
- }
25
-
26
- static debug(scope, message) {
27
- console.debug(`%c[${scope}]`, 'color:#008080', ` ${message}`);
28
- }
29
-
4
+ export class Logger {
5
+ static info(scope, message) {
6
+ console.info(`%c[${scope}]`, 'color:#008080', ` ${message}`);
7
+ }
8
+ static warn(scope, message) {
9
+ console.warn(`%c[${scope}]`, 'color:#008080', ` ${message}`);
10
+ }
11
+ static error(scope, message) {
12
+ console.error(`%c[${scope}]`, 'color:#008080', ` ${message}`);
13
+ }
14
+ static log(scope, message) {
15
+ console.log(`%c[${scope}]`, 'color:#008080', ` ${message}`);
16
+ }
17
+ static debug(scope, message) {
18
+ console.debug(`%c[${scope}]`, 'color:#008080', ` ${message}`);
19
+ }
30
20
  }
31
-
32
- exports.Logger = Logger;
21
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../src/utils/logger.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,OAAO,MAAM;IACjB,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO;QACxB,OAAO,CAAC,IAAI,CAAC,MAAM,KAAK,GAAG,EAAE,eAAe,EAAE,IAAI,OAAO,EAAE,CAAC,CAAC;IAC/D,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO;QACxB,OAAO,CAAC,IAAI,CAAC,MAAM,KAAK,GAAG,EAAE,eAAe,EAAE,IAAI,OAAO,EAAE,CAAC,CAAC;IAC/D,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,OAAO;QACzB,OAAO,CAAC,KAAK,CAAC,MAAM,KAAK,GAAG,EAAE,eAAe,EAAE,IAAI,OAAO,EAAE,CAAC,CAAC;IAChE,CAAC;IAED,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO;QACvB,OAAO,CAAC,GAAG,CAAC,MAAM,KAAK,GAAG,EAAE,eAAe,EAAE,IAAI,OAAO,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,OAAO;QACzB,OAAO,CAAC,KAAK,CAAC,MAAM,KAAK,GAAG,EAAE,eAAe,EAAE,IAAI,OAAO,EAAE,CAAC,CAAC;IAChE,CAAC;CACF"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Check if v is an object
3
+ * @param v
4
+ */
5
+ export declare function isObject(v: any): boolean;
6
+ /**
7
+ * Perfrom deep merge of two objects (not a shallow merge)
8
+ * @param target
9
+ * @param source
10
+ * @return {*}
11
+ */
12
+ export declare function mergeDeep(target: object, source: object): object;
13
+ //# sourceMappingURL=object.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"object.d.ts","sourceRoot":"","sources":["../../../src/utils/object.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,CAAC,KAAA,WAEzB;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAgBhE"}
@@ -1,15 +1,9 @@
1
- "use strict";
2
-
3
- exports.__esModule = true;
4
- exports.isObject = isObject;
5
- exports.mergeDeep = mergeDeep;
6
-
7
1
  /**
8
2
  * Check if v is an object
9
3
  * @param v
10
4
  */
11
- function isObject(v) {
12
- return typeof v === 'object' && !Array.isArray(v) && v !== null;
5
+ export function isObject(v) {
6
+ return typeof v === 'object' && !Array.isArray(v) && v !== null;
13
7
  }
14
8
  /**
15
9
  * Perfrom deep merge of two objects (not a shallow merge)
@@ -17,28 +11,23 @@ function isObject(v) {
17
11
  * @param source
18
12
  * @return {*}
19
13
  */
20
-
21
-
22
- function mergeDeep(target, source) {
23
- let output = Object.assign({}, target);
24
-
25
- if (isObject(target) && isObject(source)) {
26
- Object.keys(source).forEach(key => {
27
- if (isObject(source[key])) {
28
- if (!(key in target)) {
29
- Object.assign(output, {
30
- [key]: source[key]
31
- });
32
- } else {
33
- output[key] = mergeDeep(target[key], source[key]);
34
- }
35
- } else {
36
- Object.assign(output, {
37
- [key]: source[key]
14
+ export function mergeDeep(target, source) {
15
+ let output = Object.assign({}, target);
16
+ if (isObject(target) && isObject(source)) {
17
+ Object.keys(source).forEach((key) => {
18
+ if (isObject(source[key])) {
19
+ if (!(key in target)) {
20
+ Object.assign(output, { [key]: source[key] });
21
+ }
22
+ else {
23
+ output[key] = mergeDeep(target[key], source[key]);
24
+ }
25
+ }
26
+ else {
27
+ Object.assign(output, { [key]: source[key] });
28
+ }
38
29
  });
39
- }
40
- });
41
- }
42
-
43
- return output;
44
- }
30
+ }
31
+ return output;
32
+ }
33
+ //# sourceMappingURL=object.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"object.js","sourceRoot":"","sources":["../../../src/utils/object.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,CAAC;IACxB,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC;AAClE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAC,MAAc,EAAE,MAAc;IACtD,IAAI,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;IACvC,IAAI,QAAQ,CAAC,MAAM,CAAC,IAAI,QAAQ,CAAC,MAAM,CAAC,EAAE;QACxC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YAClC,IAAI,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE;gBACzB,IAAI,CAAC,CAAC,GAAG,IAAI,MAAM,CAAC,EAAE;oBACpB,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,EAAC,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,EAAC,CAAC,CAAC;iBAC7C;qBAAM;oBACL,MAAM,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;iBACnD;aACF;iBAAM;gBACL,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,EAAC,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,EAAC,CAAC,CAAC;aAC7C;QACH,CAAC,CAAC,CAAC;KACJ;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Check if v is a string
3
+ * @param v
4
+ */
5
+ export declare function isString(v: any): boolean;
6
+ /**
7
+ * Capitalize a string
8
+ * @param str
9
+ */
10
+ export declare function capitalize(str: string): string;
11
+ /**
12
+ * CamelCase a string
13
+ * @param str
14
+ */
15
+ export declare function camelCase(str: string): string;
16
+ /**
17
+ * Stripe html tags from a string
18
+ * @param str
19
+ */
20
+ export declare function stripHtml(str: string): string;
21
+ export declare function random(): string;
22
+ /**
23
+ * Fallback if navigator.clipboard doensn't exist
24
+ * @param text
25
+ * @returns {Promise<void>}
26
+ */
27
+ export declare function fallbackCopyTextToClipboard(text: any): Promise<void>;
28
+ /**
29
+ * Copy text to clipboard
30
+ * @param text
31
+ * @returns {Promise<void>}
32
+ *
33
+ * Ex.
34
+ * copyTextToClipboard(text).then(
35
+ * function () {
36
+ * console.log('Async: Copying to clipboard was successful!');
37
+ * },
38
+ * function (err) {
39
+ * console.error('Async: Could not copy text: ', err);
40
+ * });
41
+ */
42
+ export declare function copyTextToClipboard(text: any): Promise<void>;
43
+ //# sourceMappingURL=string.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../../../src/utils/string.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,CAAC,KAAA,WAEzB;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAO9C;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAiB7C;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED,wBAAgB,MAAM,WAErB;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,IAAI,KAAA,iBAqB/C;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,KAAA,iBAKvC"}
@@ -1,93 +1,76 @@
1
- "use strict";
2
-
3
- exports.__esModule = true;
4
- exports.camelCase = camelCase;
5
- exports.capitalize = capitalize;
6
- exports.copyTextToClipboard = copyTextToClipboard;
7
- exports.fallbackCopyTextToClipboard = fallbackCopyTextToClipboard;
8
- exports.isString = isString;
9
- exports.random = random;
10
- exports.stripHtml = stripHtml;
11
-
12
1
  /**
13
2
  * Check if v is a string
14
3
  * @param v
15
4
  */
16
- function isString(v) {
17
- return typeof v === 'string' || v instanceof String;
5
+ export function isString(v) {
6
+ return typeof v === 'string' || v instanceof String;
18
7
  }
19
8
  /**
20
9
  * Capitalize a string
21
10
  * @param str
22
11
  */
23
-
24
-
25
- function capitalize(str) {
26
- let strVal = '';
27
- let strArr = str.split(' ');
28
-
29
- for (let chr = 0; chr < strArr.length; chr++) {
30
- strVal += strArr[chr].substring(0, 1).toUpperCase() + strArr[chr].substring(1, strArr[chr].length);
31
- }
32
-
33
- return strVal;
12
+ export function capitalize(str) {
13
+ let strVal = '';
14
+ let strArr = str.split(' ');
15
+ for (let chr = 0; chr < strArr.length; chr++) {
16
+ strVal += strArr[chr].substring(0, 1).toUpperCase() + strArr[chr].substring(1, strArr[chr].length);
17
+ }
18
+ return strVal;
34
19
  }
35
20
  /**
36
21
  * CamelCase a string
37
22
  * @param str
38
23
  */
39
-
40
-
41
- function camelCase(str) {
42
- // Lower cases the string
43
- return str.toLowerCase() // Replaces any - or _ characters with a space
44
- .replace(/[-_]+/g, ' ') // Removes any non alphanumeric characters
45
- .replace(/[^\w\s]/g, '') // Uppercases the first character in each group immediately following a space
46
- // (delimited by spaces)
47
- .replace(/ (.)/g, $1 => {
48
- return $1.toUpperCase();
49
- }) // Removes spaces
50
- .replace(/ /g, '');
24
+ export function camelCase(str) {
25
+ // Lower cases the string
26
+ return (str
27
+ .toLowerCase()
28
+ // Replaces any - or _ characters with a space
29
+ .replace(/[-_]+/g, ' ')
30
+ // Removes any non alphanumeric characters
31
+ .replace(/[^\w\s]/g, '')
32
+ // Uppercases the first character in each group immediately following a space
33
+ // (delimited by spaces)
34
+ .replace(/ (.)/g, ($1) => {
35
+ return $1.toUpperCase();
36
+ })
37
+ // Removes spaces
38
+ .replace(/ /g, ''));
51
39
  }
52
40
  /**
53
41
  * Stripe html tags from a string
54
42
  * @param str
55
43
  */
56
-
57
-
58
- function stripHtml(str) {
59
- return str.replace(/<[^>]*>?/gm, '').trim();
44
+ export function stripHtml(str) {
45
+ return str.replace(/<[^>]*>?/gm, '').trim();
60
46
  }
61
-
62
- function random() {
63
- return (Math.random() + 1).toString(36).substring(7);
47
+ export function random() {
48
+ return (Math.random() + 1).toString(36).substring(7);
64
49
  }
65
50
  /**
66
51
  * Fallback if navigator.clipboard doensn't exist
67
52
  * @param text
68
53
  * @returns {Promise<void>}
69
54
  */
70
-
71
-
72
- function fallbackCopyTextToClipboard(text) {
73
- let textArea = document.createElement('textarea');
74
- textArea.value = text; // Avoid scrolling to bottom
75
-
76
- textArea.style.top = '0';
77
- textArea.style.left = '0';
78
- textArea.style.position = 'fixed';
79
- document.body.appendChild(textArea);
80
- textArea.focus();
81
- textArea.select();
82
-
83
- try {
84
- document.execCommand('copy');
85
- document.body.removeChild(textArea);
86
- return Promise.resolve();
87
- } catch (err) {
88
- document.body.removeChild(textArea);
89
- return Promise.reject(err);
90
- }
55
+ export function fallbackCopyTextToClipboard(text) {
56
+ let textArea = document.createElement('textarea');
57
+ textArea.value = text;
58
+ // Avoid scrolling to bottom
59
+ textArea.style.top = '0';
60
+ textArea.style.left = '0';
61
+ textArea.style.position = 'fixed';
62
+ document.body.appendChild(textArea);
63
+ textArea.focus();
64
+ textArea.select();
65
+ try {
66
+ document.execCommand('copy');
67
+ document.body.removeChild(textArea);
68
+ return Promise.resolve();
69
+ }
70
+ catch (err) {
71
+ document.body.removeChild(textArea);
72
+ return Promise.reject(err);
73
+ }
91
74
  }
92
75
  /**
93
76
  * Copy text to clipboard
@@ -103,12 +86,10 @@ function fallbackCopyTextToClipboard(text) {
103
86
  * console.error('Async: Could not copy text: ', err);
104
87
  * });
105
88
  */
106
-
107
-
108
- function copyTextToClipboard(text) {
109
- if (!navigator.clipboard) {
110
- return fallbackCopyTextToClipboard(text);
111
- }
112
-
113
- return navigator.clipboard.writeText(text);
114
- }
89
+ export function copyTextToClipboard(text) {
90
+ if (!navigator.clipboard) {
91
+ return fallbackCopyTextToClipboard(text);
92
+ }
93
+ return navigator.clipboard.writeText(text);
94
+ }
95
+ //# sourceMappingURL=string.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"string.js","sourceRoot":"","sources":["../../../src/utils/string.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,CAAC;IACxB,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,YAAY,MAAM,CAAC;AACtD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,GAAW;IACpC,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,IAAI,MAAM,GAAa,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACtC,KAAK,IAAI,GAAG,GAAG,CAAC,EAAE,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE;QAC5C,MAAM,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,SAAS,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