@etsoo/shared 1.2.33 → 1.2.34
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/__tests__/DomUtils.ts +7 -4
- package/__tests__/EHistory.ts +7 -7
- package/__tests__/ExtendUtils.ts +1 -1
- package/__tests__/tsconfig.json +1 -0
- package/lib/cjs/DomUtils.js +20 -9
- package/lib/cjs/types/ErrorData.d.ts +1 -1
- package/lib/mjs/DomUtils.js +20 -9
- package/lib/mjs/types/ErrorData.d.ts +1 -1
- package/package.json +1 -1
- package/src/DomUtils.ts +21 -10
- package/src/types/ErrorData.ts +1 -1
package/__tests__/DomUtils.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DomUtils } from '../src/DomUtils';
|
|
2
2
|
import { DataTypes } from '../src/DataTypes';
|
|
3
3
|
import { DateUtils } from '../src/DateUtils';
|
|
4
|
+
import { ErrorData } from '../src/types/ErrorData';
|
|
4
5
|
|
|
5
6
|
// Implement for tests
|
|
6
7
|
class Rect implements DOMRect {
|
|
@@ -302,12 +303,12 @@ test('Tests for setFocus', () => {
|
|
|
302
303
|
container.append(input);
|
|
303
304
|
|
|
304
305
|
DomUtils.setFocus('test');
|
|
305
|
-
expect(focus).
|
|
306
|
+
expect(focus).toHaveBeenCalledTimes(1);
|
|
306
307
|
|
|
307
308
|
input.blur();
|
|
308
309
|
|
|
309
310
|
DomUtils.setFocus({ test: 'No content' }, container);
|
|
310
|
-
expect(focus).
|
|
311
|
+
expect(focus).toHaveBeenCalledTimes(2);
|
|
311
312
|
});
|
|
312
313
|
|
|
313
314
|
test('Tests for getInputValue', () => {
|
|
@@ -327,9 +328,11 @@ test('Tests for getInputValue', () => {
|
|
|
327
328
|
}
|
|
328
329
|
});
|
|
329
330
|
|
|
330
|
-
test('Tests for setupLogging', () => {
|
|
331
|
+
test('Tests for setupLogging', async () => {
|
|
331
332
|
// Arrange
|
|
332
|
-
const action = jest.fn()
|
|
333
|
+
const action = jest.fn((data: ErrorData) => {
|
|
334
|
+
expect(data.message).toBe('Test');
|
|
335
|
+
});
|
|
333
336
|
DomUtils.setupLogging(action, true);
|
|
334
337
|
|
|
335
338
|
// Act
|
package/__tests__/EHistory.ts
CHANGED
|
@@ -49,28 +49,28 @@ test('Tests for events', () => {
|
|
|
49
49
|
history.on('navigate', navigatorFn, { capture: true, once: true });
|
|
50
50
|
|
|
51
51
|
history.clear();
|
|
52
|
-
expect(clearFn).
|
|
52
|
+
expect(clearFn).toHaveBeenCalled();
|
|
53
53
|
|
|
54
54
|
history.pushState(1);
|
|
55
|
-
expect(pushFn).
|
|
55
|
+
expect(pushFn).toHaveBeenCalled();
|
|
56
56
|
|
|
57
57
|
history.replaceState(11);
|
|
58
|
-
expect(replaceFn).
|
|
58
|
+
expect(replaceFn).toHaveBeenCalled();
|
|
59
59
|
|
|
60
60
|
history.pushState(2);
|
|
61
61
|
history.back();
|
|
62
|
-
expect(navigatorFn).
|
|
62
|
+
expect(navigatorFn).toHaveBeenCalledTimes(3);
|
|
63
63
|
|
|
64
64
|
history.forward();
|
|
65
65
|
// Once handler was removed
|
|
66
|
-
expect(navigatorFn).
|
|
66
|
+
expect(navigatorFn).toHaveBeenCalledTimes(5);
|
|
67
67
|
|
|
68
68
|
history.on('navigate', navigatorStopFn, { capture: true });
|
|
69
69
|
history.go(-1);
|
|
70
|
-
expect(navigatorStopFn).
|
|
70
|
+
expect(navigatorStopFn).toHaveBeenCalled();
|
|
71
71
|
|
|
72
72
|
// Previous handler stopped propagation
|
|
73
|
-
expect(navigatorFn).
|
|
73
|
+
expect(navigatorFn).toHaveBeenCalledTimes(5);
|
|
74
74
|
|
|
75
75
|
history.pushState(3);
|
|
76
76
|
history.pushState(4);
|
package/__tests__/ExtendUtils.ts
CHANGED
package/__tests__/tsconfig.json
CHANGED
package/lib/cjs/DomUtils.js
CHANGED
|
@@ -523,7 +523,7 @@ var DomUtils;
|
|
|
523
523
|
else {
|
|
524
524
|
data = {
|
|
525
525
|
type: 'error',
|
|
526
|
-
|
|
526
|
+
subType: message.type,
|
|
527
527
|
message: error?.message ??
|
|
528
528
|
`${message.currentTarget} event error`,
|
|
529
529
|
source,
|
|
@@ -541,14 +541,25 @@ var DomUtils;
|
|
|
541
541
|
if (rejectionPD)
|
|
542
542
|
event.preventDefault();
|
|
543
543
|
const reason = event.reason;
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
:
|
|
550
|
-
|
|
551
|
-
|
|
544
|
+
let data;
|
|
545
|
+
if (reason instanceof Error) {
|
|
546
|
+
data = {
|
|
547
|
+
type: 'unhandledrejection',
|
|
548
|
+
subType: reason.name,
|
|
549
|
+
message: reason.message,
|
|
550
|
+
stack: reason.stack,
|
|
551
|
+
source: globalThis.location.href
|
|
552
|
+
};
|
|
553
|
+
}
|
|
554
|
+
else {
|
|
555
|
+
data = {
|
|
556
|
+
type: 'unhandledrejection',
|
|
557
|
+
message: typeof reason === 'string'
|
|
558
|
+
? reason
|
|
559
|
+
: JSON.stringify(reason),
|
|
560
|
+
source: globalThis.location.href
|
|
561
|
+
};
|
|
562
|
+
}
|
|
552
563
|
action(data);
|
|
553
564
|
};
|
|
554
565
|
const localConsole = (type, orgin) => {
|
package/lib/mjs/DomUtils.js
CHANGED
|
@@ -520,7 +520,7 @@ export var DomUtils;
|
|
|
520
520
|
else {
|
|
521
521
|
data = {
|
|
522
522
|
type: 'error',
|
|
523
|
-
|
|
523
|
+
subType: message.type,
|
|
524
524
|
message: error?.message ??
|
|
525
525
|
`${message.currentTarget} event error`,
|
|
526
526
|
source,
|
|
@@ -538,14 +538,25 @@ export var DomUtils;
|
|
|
538
538
|
if (rejectionPD)
|
|
539
539
|
event.preventDefault();
|
|
540
540
|
const reason = event.reason;
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
:
|
|
547
|
-
|
|
548
|
-
|
|
541
|
+
let data;
|
|
542
|
+
if (reason instanceof Error) {
|
|
543
|
+
data = {
|
|
544
|
+
type: 'unhandledrejection',
|
|
545
|
+
subType: reason.name,
|
|
546
|
+
message: reason.message,
|
|
547
|
+
stack: reason.stack,
|
|
548
|
+
source: globalThis.location.href
|
|
549
|
+
};
|
|
550
|
+
}
|
|
551
|
+
else {
|
|
552
|
+
data = {
|
|
553
|
+
type: 'unhandledrejection',
|
|
554
|
+
message: typeof reason === 'string'
|
|
555
|
+
? reason
|
|
556
|
+
: JSON.stringify(reason),
|
|
557
|
+
source: globalThis.location.href
|
|
558
|
+
};
|
|
559
|
+
}
|
|
549
560
|
action(data);
|
|
550
561
|
};
|
|
551
562
|
const localConsole = (type, orgin) => {
|
package/package.json
CHANGED
package/src/DomUtils.ts
CHANGED
|
@@ -630,7 +630,7 @@ export namespace DomUtils {
|
|
|
630
630
|
} else {
|
|
631
631
|
data = {
|
|
632
632
|
type: 'error',
|
|
633
|
-
|
|
633
|
+
subType: message.type,
|
|
634
634
|
message:
|
|
635
635
|
error?.message ??
|
|
636
636
|
`${message.currentTarget} event error`,
|
|
@@ -652,15 +652,26 @@ export namespace DomUtils {
|
|
|
652
652
|
if (rejectionPD) event.preventDefault();
|
|
653
653
|
|
|
654
654
|
const reason = event.reason;
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
655
|
+
let data: ErrorData;
|
|
656
|
+
|
|
657
|
+
if (reason instanceof Error) {
|
|
658
|
+
data = {
|
|
659
|
+
type: 'unhandledrejection',
|
|
660
|
+
subType: reason.name,
|
|
661
|
+
message: reason.message,
|
|
662
|
+
stack: reason.stack,
|
|
663
|
+
source: globalThis.location.href
|
|
664
|
+
};
|
|
665
|
+
} else {
|
|
666
|
+
data = {
|
|
667
|
+
type: 'unhandledrejection',
|
|
668
|
+
message:
|
|
669
|
+
typeof reason === 'string'
|
|
670
|
+
? reason
|
|
671
|
+
: JSON.stringify(reason),
|
|
672
|
+
source: globalThis.location.href
|
|
673
|
+
};
|
|
674
|
+
}
|
|
664
675
|
|
|
665
676
|
action(data);
|
|
666
677
|
};
|