@etsoo/shared 1.2.76 → 1.2.79
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/.github/workflows/main.yml +3 -3
- package/README.md +0 -1
- package/__tests__/DataTypes.ts +190 -0
- package/__tests__/DomUtils.ts +3 -38
- package/__tests__/Utils.ts +3 -3
- package/lib/cjs/ArrayUtils.js +3 -6
- package/lib/cjs/DataTypes.d.ts +8 -0
- package/lib/cjs/DataTypes.js +58 -0
- package/lib/cjs/StorageUtils.js +3 -3
- package/lib/cjs/Utils.d.ts +4 -11
- package/lib/cjs/Utils.js +7 -34
- package/lib/cjs/index.d.ts +3 -0
- package/lib/cjs/index.js +3 -0
- package/lib/cjs/node/{Storage.d.ts → NodeStorage.d.ts} +1 -1
- package/lib/cjs/test/MockDOMRect.d.ts +15 -0
- package/lib/cjs/test/MockDOMRect.js +31 -0
- package/lib/cjs/test/MockResizeObserver.d.ts +12 -0
- package/lib/cjs/test/MockResizeObserver.js +27 -0
- package/lib/mjs/ArrayUtils.js +3 -3
- package/lib/mjs/DataTypes.d.ts +8 -0
- package/lib/mjs/DataTypes.js +58 -0
- package/lib/mjs/StorageUtils.js +1 -1
- package/lib/mjs/Utils.d.ts +4 -11
- package/lib/mjs/Utils.js +7 -31
- package/lib/mjs/index.d.ts +3 -0
- package/lib/mjs/index.js +3 -0
- package/lib/mjs/node/{Storage.d.ts → NodeStorage.d.ts} +1 -1
- package/lib/mjs/test/MockDOMRect.d.ts +15 -0
- package/lib/mjs/test/MockDOMRect.js +27 -0
- package/lib/mjs/test/MockResizeObserver.d.ts +12 -0
- package/lib/mjs/test/MockResizeObserver.js +23 -0
- package/package.json +6 -10
- package/src/ArrayUtils.ts +4 -4
- package/src/DataTypes.ts +64 -0
- package/src/StorageUtils.ts +1 -1
- package/src/Utils.ts +7 -31
- package/src/index.ts +5 -0
- package/src/node/{Storage.ts → NodeStorage.ts} +1 -1
- package/src/test/MockDOMRect.ts +37 -0
- package/src/test/MockResizeObserver.ts +28 -0
- /package/lib/cjs/node/{Storage.js → NodeStorage.js} +0 -0
- /package/lib/mjs/node/{Storage.js → NodeStorage.js} +0 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A mock implementation of DOMRect for testing purposes
|
|
3
|
+
*/
|
|
4
|
+
export class MockDOMRect implements DOMRect {
|
|
5
|
+
readonly bottom: number;
|
|
6
|
+
readonly height: number;
|
|
7
|
+
readonly left: number;
|
|
8
|
+
readonly right: number;
|
|
9
|
+
readonly top: number;
|
|
10
|
+
readonly width: number;
|
|
11
|
+
readonly x: number;
|
|
12
|
+
readonly y: number;
|
|
13
|
+
toJSON(): any {
|
|
14
|
+
return JSON.stringify({
|
|
15
|
+
bottom: this.bottom,
|
|
16
|
+
height: this.height,
|
|
17
|
+
left: this.left,
|
|
18
|
+
right: this.right,
|
|
19
|
+
top: this.top,
|
|
20
|
+
width: this.width,
|
|
21
|
+
x: this.x,
|
|
22
|
+
y: this.y
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
constructor(width: number, height: number, x: number = 0, y: number = 0) {
|
|
27
|
+
this.x = x;
|
|
28
|
+
this.y = y;
|
|
29
|
+
this.width = width;
|
|
30
|
+
this.height = height;
|
|
31
|
+
|
|
32
|
+
this.left = x;
|
|
33
|
+
this.top = y;
|
|
34
|
+
this.bottom = this.top + this.height;
|
|
35
|
+
this.right = this.left = this.width;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mock implementation of ResizeObserver for testing purposes
|
|
3
|
+
*/
|
|
4
|
+
export class MockResizeObserver implements ResizeObserver {
|
|
5
|
+
callbacks: Function[] = [];
|
|
6
|
+
elements: Element[] = [];
|
|
7
|
+
|
|
8
|
+
constructor(callback: Function) {
|
|
9
|
+
this.callbacks.push(callback);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
observe(element: Element) {
|
|
13
|
+
this.elements.push(element);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
unobserve(element: Element) {
|
|
17
|
+
this.elements = this.elements.filter((el) => el !== element);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
disconnect() {
|
|
21
|
+
this.elements = [];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Helper to trigger the callback manually in tests
|
|
25
|
+
trigger(entries: ResizeObserverEntry[]) {
|
|
26
|
+
this.callbacks.forEach((cb) => cb(entries));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
File without changes
|
|
File without changes
|