@thednp/dommatrix 2.0.8 → 2.0.10

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/src/types.ts DELETED
@@ -1,63 +0,0 @@
1
- import CSSMatrix from '.';
2
-
3
- /** A DOMMPoint compatible Tuple. */
4
- export interface PointTuple {
5
- x: number;
6
- y: number;
7
- z: number;
8
- w: number;
9
- }
10
-
11
- /** The result of **CSSMatrix.toJSON()** / **DOMMatrix.toJSON()** instance calls. */
12
- export interface JSONMatrix {
13
- m11: number;
14
- m12: number;
15
- m13: number;
16
- m14: number;
17
- m21: number;
18
- m22: number;
19
- m23: number;
20
- m24: number;
21
- m31: number;
22
- m32: number;
23
- m33: number;
24
- m34: number;
25
- m41: number;
26
- m42: number;
27
- m43: number;
28
- m44: number;
29
- a: number;
30
- b: number;
31
- c: number;
32
- d: number;
33
- e: number;
34
- f: number;
35
- is2D: boolean;
36
- isIdentity: boolean;
37
- }
38
-
39
- /** An array of 6 numbers representing a 2D matrix. */
40
- export type Matrix = [number, number, number, number, number, number];
41
-
42
- /** An array of 16 numbers representing a 3D matrix. */
43
- export type Matrix3d = [
44
- number,
45
- number,
46
- number,
47
- number,
48
- number,
49
- number,
50
- number,
51
- number,
52
- number,
53
- number,
54
- number,
55
- number,
56
- number,
57
- number,
58
- number,
59
- number,
60
- ];
61
-
62
- /** All CSSMatrix compatible initialization values. */
63
- export type CSSMatrixInput = string | any[] | CSSMatrix | DOMMatrix | JSONMatrix | Float32Array | Float64Array;
@@ -1,299 +0,0 @@
1
- import { expect, it, describe, vi, beforeEach, afterEach } from 'vitest';
2
- import { getExampleDOM } from './fixtures/getExampleDom';
3
-
4
- import CSSMatrix from '../src/index';
5
- import type { Matrix, Matrix3d } from '../src/types';
6
- import testSamples from './fixtures/testSamples';
7
-
8
- const roundTo4 = (x: number) => Math.round(x * 10000) / 10000
9
-
10
- describe('DOMMatrix Class Test', () => {
11
- let container: HTMLElement;
12
- beforeEach(async () => {
13
- container = getExampleDOM();
14
- await vi.waitUntil(() => container.querySelector('div') !== null, { timeout: 150 });
15
- });
16
- afterEach(async () => {
17
- document.documentElement.innerHTML = '';
18
- });
19
-
20
- it('Test init with no parameter, expect same output as native DOMMatrix', () => {
21
- const css = new CSSMatrix();
22
- const css1 = new CSSMatrix().setMatrixValue();
23
- const dom = new DOMMatrix();
24
-
25
- expect(css.is2D).to.equal(dom.is2D);
26
- expect(css.isIdentity).to.equal(dom.isIdentity);
27
- expect(JSON.stringify(css)).to.equal(JSON.stringify(dom));
28
- expect(JSON.stringify(css)).to.equal(JSON.stringify(css1));
29
- });
30
-
31
- it('Test init with invalid array, expect error', () => {
32
- const test = [0.906308, 0.0839613, -0.414194, 0.00103549, 0, 0.980067, 0.198669, -0.000496673, 0.422618, -0.180056, 0.888242, -0.0022206, 0, 0, 0, 'NaN'];
33
- try {
34
- CSSMatrix.fromArray(test);
35
- } catch (err) {
36
- expect(err).to.be.instanceOf(TypeError);
37
- expect(err).to.have.property('message', `CSSMatrix: "${test}" must be an array with 6/16 numbers.`);
38
- }
39
-
40
- const test1 = [0.9659, 0.25879, -0.2588, 0.9659, -1.53961, 'NaN'];
41
- try {
42
- // @ts-ignore
43
- CSSMatrix.fromArray(test1);
44
- } catch (err) {
45
- expect(err).to.be.instanceOf(TypeError);
46
- expect(err).to.have.property('message', `CSSMatrix: "${test1}" must be an array with 6/16 numbers.`);
47
- }
48
-
49
- });
50
-
51
- it('Test init with incomplete array, expect error', () => {
52
- const test = [0.906308, 0.0839613, -0.414194, 0.00103549, 0, 0.980067, 0.198669, -0.000496673, 0.422618, -0.180056, 0.888242, -0.0022206, 0, 0, 0];
53
- try {
54
- CSSMatrix.fromArray(test);
55
- } catch (err) {
56
- expect(err).to.be.instanceOf(TypeError);
57
- expect(err).to.have.property('message', `CSSMatrix: "${test}" must be an array with 6/16 numbers.`);
58
- }
59
- });
60
-
61
- it('Test init with incompatible CSSMatrix, DOMMatrix, JSON object', () => {
62
- // const css1 = {a: 0.94, b: 0.25, c: -0.25, d: 0.95, e: 0, f: 0, m11: 0.93, m12: 0.25, m13: -0.25, m14: 0, m21: -0.25, m22: 0.95, m23: 0, m24: 0, m31: 0.2, m32: 0.05, m33: 0.95, m34: 0, m41: 0, m42: 0, m43: 0, m44: 1};
63
- const css1 = {a: 0.94, b: 0.25, c: -0.25, d: 0.95, e: 0, f: 0, m11: 0.93, m12: 0.25, m13: -0.25, m14: 0, m21: -0.25, m22: 0.95, m23: 0, m24: 0, m31: 0.2, m32: 0.05, m33: 0.95, m34: 0, m41: 0, m42: 0, m43: 0, m44: 1};
64
- const css2 = {m11: 0.93, m12: 0.25, m13: -0.25, m14: 0, m21: -0.25, m22: 0.95, m23: 0, m24: 0, m31: 0.2, m32: 0.05, m33: 0.95, m34: 0, m41: 0, m42: 0, m43: 0, m44: 1};
65
- const css3 = {a: 0.94, b: 0.25, c: -0.25, d: 0.95, e: 0, f: 0};
66
-
67
- [css1, css2, css3].forEach((c) => {
68
- try {
69
- // @ts-expect-error
70
- new CSSMatrix(c);
71
- } catch (err) {
72
- expect(err).to.be.instanceOf(TypeError);
73
- expect(err).to.have.property('message', `CSSMatrix: "${JSON.stringify(c)}" is not a DOMMatrix / CSSMatrix / JSON compatible object.`);
74
- }
75
- })
76
- });
77
-
78
- it('Test init compatible CSSMatrix, DOMMatrix, JSON object', () => {
79
- const css = new CSSMatrix().rotate(15, 15);
80
- const dom = new DOMMatrix().rotate(15, 15);
81
-
82
- expect(css.is2D).to.equal(dom.is2D)
83
- expect(css.is2D).to.equal(new CSSMatrix(css).is2D)
84
- expect(css.isIdentity).to.equal(dom.isIdentity)
85
- expect(css.isIdentity).to.equal((new CSSMatrix(dom)).isIdentity)
86
-
87
- });
88
-
89
- it('Test specific private methods', () => {
90
- try {
91
- // @ts-ignore
92
- new CSSMatrix().rotateAxisAngle('a','true','wombat','05');
93
- } catch (err) {
94
- expect(err).to.be.instanceOf(TypeError);
95
- expect(err).to.have.property('message', 'CSSMatrix: expecting 4 values');
96
- }
97
-
98
- const d1 = new DOMMatrix().rotate(15);
99
- const m1 = new CSSMatrix().rotate(15);
100
-
101
- const cssDiv = container.querySelector('.bg-primary') as HTMLElement;
102
- const domDiv = container.querySelector('.bg-secondary') as HTMLElement;
103
-
104
- console.log('Some initial testing');
105
-
106
- cssDiv.style.transform = m1.toString();
107
- domDiv.style.transform = d1.toString();
108
- expect(m1.isIdentity).to.equal(d1.isIdentity);
109
- expect(m1.is2D).to.equal(d1.is2D);
110
-
111
- // for some reason DOMMatrix in
112
- // expect(m1.toFloat32Array()).to.deep.equal(d1.toFloat32Array());
113
- // expect(m1.toFloat64Array()).to.deep.equal(d1.toFloat64Array());
114
- expect(Array.from(m1.toFloat32Array()).map(roundTo4))
115
- .to.deep.equal(Array.from(d1.toFloat32Array()).map(roundTo4));
116
- expect(Array.from(m1.toFloat64Array()).map(roundTo4))
117
- .to.deep.equal(Array.from(d1.toFloat64Array()).map(roundTo4));
118
-
119
- console.log('CSSMatrix.rotate(x:25, y:15)');
120
- const d2 = new DOMMatrix().rotate(25,15);
121
- const m2 = new CSSMatrix().rotate(25,15);
122
- cssDiv.style.transform = m2.toString();
123
- domDiv.style.transform = d2.toString();
124
-
125
- expect(m2.isIdentity).to.equal(d2.isIdentity);
126
- expect(m2.is2D).to.equal(d2.is2D);
127
-
128
- // same here
129
- // expect(m2.toFloat32Array()).to.deep.equal(d2.toFloat32Array());
130
- // expect(m2.toFloat64Array()).to.deep.equal(d2.toFloat64Array());
131
- expect(Array.from(m2.toFloat32Array()).map(roundTo4))
132
- .to.deep.equal(Array.from(d2.toFloat32Array()).map(roundTo4));
133
- expect(Array.from(m2.toFloat64Array()).map(roundTo4))
134
- .to.deep.equal(Array.from(d2.toFloat64Array()).map(roundTo4));
135
-
136
-
137
- console.log('CSSMatrix.translate(x:150)');
138
- const d3 = new DOMMatrix().translate(150);
139
- const m3 = new CSSMatrix().translate(150);
140
-
141
- cssDiv.style.transform = m3.toString();
142
- domDiv.style.transform = d3.toString();
143
- expect(m3.isIdentity).to.equal(d3.isIdentity);
144
- expect(m3.is2D).to.equal(d3.is2D);
145
- // expect(m3.toFloat32Array()).to.deep.equal(d3.toFloat32Array());
146
- // expect(m3.toFloat64Array()).to.deep.equal(d3.toFloat64Array());
147
- expect(Array.from(m3.toFloat32Array()).map(roundTo4))
148
- .to.deep.equal(Array.from(d3.toFloat32Array()).map(roundTo4));
149
- expect(Array.from(m3.toFloat64Array()).map(roundTo4))
150
- .to.deep.equal(Array.from(d3.toFloat64Array()).map(roundTo4));
151
-
152
- console.log('CSSMatrix.skew(x:15, y:-20)');
153
- const d4 = new DOMMatrix('skew(15deg, -20deg)');
154
- const m4 = new CSSMatrix().skew(15, -20);
155
- console.log('In this test we\'re addapting to the output of the native DOMMatrix method since it doesn\'t support the skew() method itself.');
156
- cssDiv.style.transform = m4.toString();
157
- domDiv.style.transform = d4.toString();
158
- expect(m4.isIdentity).to.equal(d4.isIdentity);
159
- expect(m4.is2D).to.equal(d4.is2D);
160
- // expect(m4.toFloat32Array()).to.deep.equal(d4.toFloat32Array());
161
- // expect(m4.toFloat64Array()).to.deep.equal(d4.toFloat64Array());
162
- expect(Array.from(m4.toFloat32Array()).map(roundTo4))
163
- .to.deep.equal(Array.from(d4.toFloat32Array()).map(roundTo4));
164
- expect(Array.from(m4.toFloat64Array()).map(roundTo4))
165
- .to.deep.equal(Array.from(d4.toFloat64Array()).map(roundTo4));
166
-
167
- console.log('CSSMatrix.scale(x:1.3)');
168
- const d5 = new DOMMatrix().scale(1.3);
169
- const m5 = new CSSMatrix().scale(1.3);
170
-
171
- cssDiv.style.transform = m5.toString();
172
- domDiv.style.transform = d5.toString();
173
- expect(m5.isIdentity).to.equal(d5.isIdentity);
174
- expect(m5.is2D).to.equal(d5.is2D);
175
- // expect(m5.toFloat32Array()).to.deep.equal(d5.toFloat32Array());
176
- // expect(m5.toFloat64Array()).to.deep.equal(d5.toFloat64Array());
177
- expect(Array.from(m5.toFloat32Array()).map(roundTo4))
178
- .to.deep.equal(Array.from(d5.toFloat32Array()).map(roundTo4));
179
- expect(Array.from(m5.toFloat64Array()).map(roundTo4))
180
- .to.deep.equal(Array.from(d5.toFloat64Array()).map(roundTo4));
181
-
182
- console.log('CSSMatrix.scale(x:1.3,y:1.8)');
183
- const d6 = new DOMMatrix().scale(1.3,1.8);
184
- const m6 = new CSSMatrix().scale(1.3,1.8);
185
- cssDiv.style.transform = m6.toString();
186
- domDiv.style.transform = d6.toString();
187
- expect(m6.isIdentity).to.equal(d6.isIdentity);
188
- expect(m6.is2D).to.equal(d6.is2D);
189
- // expect(m6.toFloat32Array()).to.deep.equal(d6.toFloat32Array());
190
- // expect(m6.toFloat64Array()).to.deep.equal(d6.toFloat64Array());
191
- expect(Array.from(m6.toFloat32Array()).map(roundTo4))
192
- .to.deep.equal(Array.from(d6.toFloat32Array()).map(roundTo4));
193
- expect(Array.from(m6.toFloat64Array()).map(roundTo4))
194
- .to.deep.equal(Array.from(d6.toFloat64Array()).map(roundTo4));
195
-
196
- console.log('CSSMatrix.transformPoint');
197
- const p1 = new DOMPoint(15, 20, 35, 1);
198
- const p2 = { x: 15, y: 20, z: 35, w: 1};
199
- const dp = new DOMMatrix().rotate(15).translate(15, 15);
200
- const mp = new CSSMatrix().rotate(15).translate(15, 15);
201
-
202
- console.log('For some reason the native DOMMatrix again falsely claims **is2D** to be true');
203
- expect(mp.isIdentity).to.equal(dp.isIdentity);
204
- expect(mp.is2D).to.equal(dp.is2D);
205
- expect(mp.toFloat32Array()).to.deep.equal(dp.toFloat32Array());
206
- expect(mp.toFloat64Array()).to.deep.equal(dp.toFloat64Array());
207
- expect(mp.transformPoint(p1)).to.deep.equal(dp.transformPoint(p1));
208
- expect(mp.transformPoint(p2)).to.deep.equal(dp.transformPoint(p2).toJSON());
209
- });
210
-
211
- it('Test init a 6 values array', () => {
212
- const test = [0.9659, 0.25879, -0.2588, 0.9659, -1.53961, -1.53961] as Matrix;
213
- const m1 = new CSSMatrix(test);
214
- // const m2 = new CSSMatrix(...test);
215
- const m3 = new CSSMatrix(test);
216
- const m4 = new DOMMatrix(test);
217
-
218
- expect(m1.toFloat64Array()).to.deep.equal(m3.toFloat64Array())
219
- expect(m1.toFloat64Array()).to.deep.equal(m4.toFloat64Array())
220
- });
221
-
222
- it('Test init a 16 values array', () => {
223
- const test = [0.852, 0.153, 0.186, -0.0004, -0.092, 0.869, -0.266, 0.0006, -0.25, 0.258, 0.933, -0.002, 0, 0, 0, 1] as Matrix3d;
224
- const m1 = new CSSMatrix(test);
225
- // const m2 = new CSSMatrix(...test);
226
- const m3 = new CSSMatrix([...test]);
227
- const m4 = new DOMMatrix(test);
228
-
229
- expect(m1.toFloat32Array()).to.deep.equal(m3.toFloat32Array())
230
- expect(m1.toFloat32Array()).to.deep.equal(m4.toFloat32Array())
231
- });
232
-
233
- it('Test static methods', () => {
234
- const m = new CSSMatrix();
235
- const source = {a: 1};
236
- const source1 = 'wombat(1)';
237
- const source2 = 'skew()';
238
- const source3 = 'translate(wombat)';
239
-
240
- expect(CSSMatrix.fromMatrix(m)).to.deep.equal(m);
241
- expect(CSSMatrix.fromMatrix(m.toJSON())).to.deep.equal(m);
242
-
243
- try {
244
- // @ts-expect-error
245
- CSSMatrix.fromString(source);
246
- } catch (err) {
247
- expect(err).to.be.instanceOf(TypeError);
248
- expect(err).to.have.property('message', `CSSMatrix: "${JSON.stringify(source)}" is not a string.`);
249
- }
250
-
251
- try {
252
- CSSMatrix.fromString(source1);
253
- } catch (err) {
254
- expect(err).to.be.instanceOf(TypeError);
255
- expect(err).to.have.property('message', `CSSMatrix: invalid transform string "${source1}"`);
256
- }
257
-
258
- try {
259
- CSSMatrix.fromString(source2);
260
- } catch (err) {
261
- expect(err).to.be.instanceOf(TypeError);
262
- expect(err).to.have.property('message', `CSSMatrix: invalid transform string "${source2}"`);
263
- }
264
-
265
- try {
266
- CSSMatrix.fromString(source3);
267
- } catch (err) {
268
- expect(err).to.be.instanceOf(TypeError);
269
- expect(err).to.have.property('message', `CSSMatrix: invalid transform string "${source3}"`);
270
- }
271
- });
272
-
273
- Object.keys(testSamples).forEach((test) => {
274
- it(`Test string input ${test}, expect same output as native DOMMatrix`, () => {
275
- const str = testSamples[test];
276
- const css = new CSSMatrix(str);
277
- const dom = new DOMMatrix(str);
278
- const cssDiv = container.querySelector('.bg-primary') as HTMLElement;
279
- const domDiv = container.querySelector('.bg-secondary') as HTMLElement;
280
-
281
- cssDiv.style.transform = css.toString();
282
- domDiv.style.transform = dom.toString();
283
-
284
- console.log('Due to the nature of the native DOMMatrix RegExp, for consistency reasons we\'re rounding numbers to 6 decimals in this test.')
285
-
286
- expect(Array.from(css.toFloat32Array()).map(roundTo4))
287
- .to.deep.equal(Array.from(dom.toFloat32Array()).map(roundTo4));
288
-
289
- console.log('The native `DOMMatrix` is a little weird when it comes to rotateAxisAngle, it falsely claims the identity matrix is NOT `is2D`');
290
-
291
- expect(css.isIdentity).to.equal(dom.isIdentity)
292
- if (test === 'rotate3d1') {
293
- expect(css.is2D).to.not.equal(dom.is2D)
294
- } else {
295
- expect(css.is2D).to.equal(dom.is2D)
296
- }
297
- })
298
- })
299
- });
@@ -1,38 +0,0 @@
1
- export const getExampleDOM = () => {
2
- // const CSS = await fetch("https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css").then(r => r.text());
3
- // This is just a raw example of setting up some DOM
4
- // that we can interact with. Swap this with your UI
5
- // framework of choice 😉
6
- // const div = document.createElement('div');
7
- const HTML = document.documentElement;
8
- HTML.innerHTML =
9
- `<head>
10
- <meta charset="UTF-8">
11
- <title>DOMMatrix Testing Page</title>
12
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css">
13
- <style>
14
- .box {height: 200px;}
15
- #dom, #css {transition: transform 0.5s ease;}
16
- </style>
17
- </head>
18
- <bo<body class="container">
19
- <h1 class="mt-3 mt-md-5"><a class="text-decoration-none" href="https://github.com/thednp/DOMMatrix">DOMMatrix Shim Test</a></h1>
20
-
21
- <div class="row">
22
- <div id="css" class="col-12 col-md-6">
23
- <div class="box bg-primary text-white p-3 my-3 text-center align-self-center rounded">
24
- <b>CSSMatrix</b><br><span class="row"></span>
25
- </div>
26
- </div>
27
- <div id="dom" class="col-12 col-md-6">
28
- <div class="box bg-secondary text-white p-3 my-3 text-center align-self-center rounded">
29
- <b>DOMMatrix</b><br><span class="row"></span>
30
- </div>
31
- </div>
32
- </div>
33
-
34
- </body>
35
- `;
36
-
37
- return HTML;
38
- };
@@ -1,32 +0,0 @@
1
- export default {
2
- skew: 'skew(25deg)',
3
- skewX: 'skewX(25deg)',
4
- skewY: 'skewY(-25deg)',
5
- skew2d: 'skew(15deg, 25deg)',
6
- skewsX0: 'skew(15deg, 0)',
7
- skews0Y: 'skew(0, 25deg)',
8
- skews3: 'skew(35deg, -45deg)',
9
- rotate: 'rotate(25deg)',
10
- rotateX: 'rotateX(-25deg)',
11
- rotateY: 'rotateY(25deg)',
12
- rotate3d: 'rotate3d(0.1,1.5,0.7,25deg)',
13
- rotate3d1: 'rotate3d(0,0,0,20deg)',
14
- translate: 'translate(25px)',
15
- translateX: 'translateX(25px)',
16
- translateY: 'translateY(25px)',
17
- translateZ: 'translateZ(25px)',
18
- translate2d: 'translate(25px, 15px)',
19
- translate3D: 'translate3d(25px, 15px, 5px)',
20
- scale: 'scale(1.25)',
21
- scaleX: 'scaleX(1.515)',
22
- scaleY: 'scaleY(1.155)',
23
- scaleZ: 'scaleZ(1.153)',
24
- scale3D: 'scale3d(1.15, 1.51, 2)',
25
- regular: 'perspective(400px) translate(150px, 200px) rotateX(0.2rad) rotateY(25deg)',
26
- matrix: 'matrix(0.9659, 0.2588, -0.2588, 0.9659, -1.5396, -1.5396) translate(15px)',
27
- matrix3d: 'matrix3d(0.852, 0.153, 0.186, -0.0004, -0.092, 0.869, -0.266, 0.0006, -0.25, 0.258, 0.933, -0.002, 0, 0, 0, 1)',
28
- combo: 'translate(25px, 15px) matrix(0.984807, -0.173648, 0.173648, 0.984807, 0, 0)',
29
- combo1: 'skewX(0.3rad) skewY(10deg) translate3d(15px,15px, -15px) matrix(0.984807, -0.173648, 0.173648, 0.984807, 0, 0)',
30
- combo2: 'perspective(800px) scale(0.9,1.1) rotateX(15deg) rotate(-0.125rad) skewX(-5deg) rotate3d(0.1,1.5,0.7,25deg) skewY(-0.2rad)',
31
- combo3: 'perspective(1200px) rotateY(-175deg) rotate(-0.125rad) scale3d(0.9,1.1,0.75) skewX(-0.2rad) rotate3d(0.1,1.5,0.7,25deg) skewY(-5deg) matrix(0.9659, 0.2588, -0.2588, 0.9659, -1.5396, -1.5396)'
32
- }
package/tsconfig.json DELETED
@@ -1,29 +0,0 @@
1
- {
2
- // https://janessagarrow.com/blog/typescript-and-esbuild/
3
- "compilerOptions": {
4
- "lib": ["DOM", "ESNext", "DOM.Iterable"],
5
- // "types": ["vite", "vite/client", "cypress"],
6
- "rootDir": "./src",
7
- "baseUrl": "./",
8
- "module": "ESNext",
9
- "target": "ESNext",
10
- "moduleResolution": "Bundler",
11
- "allowJs": true,
12
- "forceConsistentCasingInFileNames": true,
13
- "useDefineForClassFields": true,
14
- "strict": true,
15
- "sourceMap": true,
16
- "resolveJsonModule": true,
17
- "esModuleInterop": true,
18
- "isolatedModules": true,
19
- "noUnusedLocals": true,
20
- "noUnusedParameters": true,
21
- "noImplicitReturns": true,
22
- "removeComments": false,
23
- "allowSyntheticDefaultImports": true,
24
- "noEmit": true,
25
- "checkJs": true
26
- },
27
- "include": ["src/*"],
28
- "exclude": ["node_modules", "experiments", "coverage"]
29
- }
package/vite.config.ts DELETED
@@ -1,30 +0,0 @@
1
- import {resolve} from 'path';
2
- import { defineConfig } from 'vite';
3
- import { name } from './package.json';
4
-
5
- const getPackageName = () => {
6
- return name.includes('@') ? name.split('/')[1] : name;
7
- };
8
-
9
- const NAME = 'CSSMatrix';
10
-
11
- const fileName = {
12
- es: `${getPackageName()}.mjs`,
13
- cjs: `${getPackageName()}.cjs`,
14
- iife: `${getPackageName()}.js`,
15
- };
16
-
17
- export default defineConfig({
18
- base: './',
19
- build: {
20
- emptyOutDir: true,
21
- outDir: 'dist',
22
- lib: {
23
- entry: resolve(__dirname, 'src/index.ts'),
24
- name: NAME,
25
- formats: ['es', 'cjs', 'iife'],
26
- fileName: (format: string) => fileName[format],
27
- },
28
- sourcemap: true,
29
- },
30
- });
@@ -1,21 +0,0 @@
1
- import { defineConfig } from "vitest/config";
2
-
3
-
4
- export default defineConfig({
5
- test: {
6
- globals: true,
7
- coverage: {
8
- provider: "istanbul",
9
- reporter: ["html", "text", "lcov"],
10
- enabled: true,
11
- include: ["src/**/*.{ts,tsx}"],
12
- },
13
- browser: {
14
- provider: 'preview', // or 'webdriverio'
15
- enabled: true,
16
- headless: false,
17
- name: 'chromium', // browser name is required
18
- // enableUI: true
19
- },
20
- },
21
- });
package/vitest.config.ts DELETED
@@ -1,19 +0,0 @@
1
- import { defineConfig } from "vitest/config";
2
-
3
- export default defineConfig({
4
- test: {
5
- globals: true,
6
- coverage: {
7
- provider: "istanbul",
8
- reporter: ["html", "text", "lcov"],
9
- enabled: true,
10
- include: ["src/**/*.{ts,tsx}"],
11
- },
12
- browser: {
13
- provider: 'playwright', // or 'webdriverio'
14
- enabled: true,
15
- headless: true,
16
- name: 'chromium', // browser name is required
17
- },
18
- },
19
- });