@thednp/dommatrix 2.0.7 → 2.0.9
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/.lgtm.yml +0 -0
- package/LICENSE +0 -0
- package/README.md +5 -7
- package/dist/dommatrix.cjs +2 -1
- package/dist/dommatrix.cjs.map +1 -1
- package/dist/dommatrix.d.ts +285 -288
- package/dist/dommatrix.js +2 -1
- package/dist/dommatrix.js.map +1 -1
- package/dist/dommatrix.mjs +54 -7
- package/dist/dommatrix.mjs.map +1 -1
- package/package.json +68 -76
- package/tsconfig.json +0 -0
- package/.eslintrc.cjs +0 -224
- package/.prettierrc.json +0 -15
- package/cypress/e2e/dommatrix.spec.ts +0 -328
- package/cypress/fixtures/testSamples.ts +0 -32
- package/cypress/plugins/esbuild-istanbul.ts +0 -50
- package/cypress/plugins/tsCompile.ts +0 -34
- package/cypress/support/commands.ts +0 -37
- package/cypress/support/e2e.ts +0 -21
- package/cypress/test.html +0 -35
- package/cypress.config.ts +0 -29
- package/dts.config.ts +0 -15
- package/src/index.ts +0 -912
- package/src/types.ts +0 -63
- package/vite.config.ts +0 -30
|
@@ -1,328 +0,0 @@
|
|
|
1
|
-
/// <reference types="cypress" />
|
|
2
|
-
|
|
3
|
-
import CSSMatrix from '../../src/index';
|
|
4
|
-
import type { Matrix, Matrix3d } from '../../src/types';
|
|
5
|
-
import testSamples from '../fixtures/testSamples';
|
|
6
|
-
|
|
7
|
-
const roundTo4 = (x: number) => Math.round(x * 10000) / 10000
|
|
8
|
-
|
|
9
|
-
describe('DOMMatrix Class Test', () => {
|
|
10
|
-
|
|
11
|
-
beforeEach(() => {
|
|
12
|
-
cy.visit('cypress/test.html')
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it('Test init with no parameter, expect same output as native DOMMatrix', () => {
|
|
16
|
-
const css = new CSSMatrix();
|
|
17
|
-
const css1 = new CSSMatrix().setMatrixValue();
|
|
18
|
-
const dom = new DOMMatrix();
|
|
19
|
-
cy.wrap(css).as('css')
|
|
20
|
-
.get('@css').its('is2D').should('equal', dom.is2D)
|
|
21
|
-
.get('@css').its('isIdentity').should('equal', dom.isIdentity)
|
|
22
|
-
.get('@css').should(($this) => {
|
|
23
|
-
expect(JSON.stringify($this)).to.equal(JSON.stringify(dom));
|
|
24
|
-
expect(JSON.stringify($this)).to.equal(JSON.stringify(css1));
|
|
25
|
-
})
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it('Test init with invalid array, expect error', () => {
|
|
29
|
-
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'];
|
|
30
|
-
try {
|
|
31
|
-
// @ts-ignore
|
|
32
|
-
CSSMatrix.fromArray(test);
|
|
33
|
-
} catch (err) {
|
|
34
|
-
expect(err).to.be.instanceOf(TypeError);
|
|
35
|
-
expect(err).to.have.property('message', `CSSMatrix: "${test}" must be an array with 6/16 numbers.`);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const test1 = [0.9659, 0.25879, -0.2588, 0.9659, -1.53961, 'NaN'];
|
|
39
|
-
try {
|
|
40
|
-
// @ts-ignore
|
|
41
|
-
CSSMatrix.fromArray(test1);
|
|
42
|
-
} catch (err) {
|
|
43
|
-
expect(err).to.be.instanceOf(TypeError);
|
|
44
|
-
expect(err).to.have.property('message', `CSSMatrix: "${test1}" must be an array with 6/16 numbers.`);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it('Test init with incomplete array, expect error', () => {
|
|
50
|
-
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];
|
|
51
|
-
try {
|
|
52
|
-
CSSMatrix.fromArray(test);
|
|
53
|
-
} catch (err) {
|
|
54
|
-
expect(err).to.be.instanceOf(TypeError);
|
|
55
|
-
expect(err).to.have.property('message', `CSSMatrix: "${test}" must be an array with 6/16 numbers.`);
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it('Test init with incompatible CSSMatrix, DOMMatrix, JSON object', () => {
|
|
60
|
-
// 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};
|
|
61
|
-
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};
|
|
62
|
-
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};
|
|
63
|
-
const css3 = {a: 0.94, b: 0.25, c: -0.25, d: 0.95, e: 0, f: 0};
|
|
64
|
-
|
|
65
|
-
[css1, css2, css3].forEach((c) => {
|
|
66
|
-
try {
|
|
67
|
-
// @ts-ignore
|
|
68
|
-
new CSSMatrix(c);
|
|
69
|
-
} catch (err) {
|
|
70
|
-
expect(err).to.be.instanceOf(TypeError);
|
|
71
|
-
expect(err).to.have.property('message', `CSSMatrix: "${JSON.stringify(c)}" is not a DOMMatrix / CSSMatrix / JSON compatible object.`);
|
|
72
|
-
}
|
|
73
|
-
})
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
it('Test init compatible CSSMatrix, DOMMatrix, JSON object', () => {
|
|
77
|
-
const css = new CSSMatrix().rotate(15, 15);
|
|
78
|
-
const dom = new DOMMatrix().rotate(15, 15);
|
|
79
|
-
|
|
80
|
-
cy.wrap(new CSSMatrix(css)).as('cc')
|
|
81
|
-
.get('@cc').its('is2D').should('equal', css.is2D)
|
|
82
|
-
.get('@cc').its('is2D').should('equal', new CSSMatrix(dom).is2D)
|
|
83
|
-
.get('@cc').its('isIdentity').should('equal', css.isIdentity)
|
|
84
|
-
.get('@cc').its('isIdentity').should('equal', new CSSMatrix(dom).isIdentity);
|
|
85
|
-
|
|
86
|
-
cy.wrap(css.toJSON()).as('js')
|
|
87
|
-
.get('@js').its('is2D').should('equal', css.is2D)
|
|
88
|
-
.get('@js').its('is2D').should('equal', new CSSMatrix(dom).is2D)
|
|
89
|
-
.get('@js').its('isIdentity').should('equal', css.isIdentity)
|
|
90
|
-
.get('@js').its('isIdentity').should('equal', new CSSMatrix(dom).isIdentity)
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it('Test specific private methods', () => {
|
|
94
|
-
cy.log('CSSMatrix.rotateAxisAngle specific error').then(() => {
|
|
95
|
-
try {
|
|
96
|
-
// @ts-ignore
|
|
97
|
-
new CSSMatrix().rotateAxisAngle('a','true','wombat','05');
|
|
98
|
-
} catch (err) {
|
|
99
|
-
expect(err).to.be.instanceOf(TypeError);
|
|
100
|
-
expect(err).to.have.property('message', 'CSSMatrix: expecting 4 values');
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
cy.log('CSSMatrix.rotate').then(() => {
|
|
105
|
-
const d1 = new DOMMatrix().rotate(15);
|
|
106
|
-
const m1 = new CSSMatrix().rotate(15);
|
|
107
|
-
|
|
108
|
-
cy.get('.bg-primary').then(($el) => {
|
|
109
|
-
$el[0].style.transform = m1.toString();
|
|
110
|
-
})
|
|
111
|
-
.get('.bg-secondary').then(($el) => {
|
|
112
|
-
$el[0].style.transform = d1.toString();
|
|
113
|
-
})
|
|
114
|
-
expect(m1.isIdentity).to.equal(d1.isIdentity);
|
|
115
|
-
expect(m1.is2D).to.equal(d1.is2D);
|
|
116
|
-
|
|
117
|
-
// for some reason DOMMatrix in
|
|
118
|
-
// expect(m1.toFloat32Array()).to.deep.equal(d1.toFloat32Array());
|
|
119
|
-
// expect(m1.toFloat64Array()).to.deep.equal(d1.toFloat64Array());
|
|
120
|
-
expect(Array.from(m1.toFloat32Array()).map(roundTo4))
|
|
121
|
-
.to.deep.equal(Array.from(d1.toFloat32Array()).map(roundTo4));
|
|
122
|
-
expect(Array.from(m1.toFloat64Array()).map(roundTo4))
|
|
123
|
-
.to.deep.equal(Array.from(d1.toFloat64Array()).map(roundTo4));
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
cy.log('CSSMatrix.rotate(x:25, y:15)').then(() => {
|
|
127
|
-
const d2 = new DOMMatrix().rotate(25,15);
|
|
128
|
-
const m2 = new CSSMatrix().rotate(25,15);
|
|
129
|
-
cy.get('.bg-primary').then(($el) => {
|
|
130
|
-
$el[0].style.transform = m2.toString();
|
|
131
|
-
})
|
|
132
|
-
.get('.bg-secondary').then(($el) => {
|
|
133
|
-
$el[0].style.transform = d2.toString();
|
|
134
|
-
})
|
|
135
|
-
|
|
136
|
-
expect(m2.isIdentity).to.equal(d2.isIdentity);
|
|
137
|
-
expect(m2.is2D).to.equal(d2.is2D);
|
|
138
|
-
|
|
139
|
-
// same here
|
|
140
|
-
// expect(m2.toFloat32Array()).to.deep.equal(d2.toFloat32Array());
|
|
141
|
-
// expect(m2.toFloat64Array()).to.deep.equal(d2.toFloat64Array());
|
|
142
|
-
expect(Array.from(m2.toFloat32Array()).map(roundTo4))
|
|
143
|
-
.to.deep.equal(Array.from(d2.toFloat32Array()).map(roundTo4));
|
|
144
|
-
expect(Array.from(m2.toFloat64Array()).map(roundTo4))
|
|
145
|
-
.to.deep.equal(Array.from(d2.toFloat64Array()).map(roundTo4));
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
cy.log('CSSMatrix.translate(x:150)').then(() => {
|
|
149
|
-
const d3 = new DOMMatrix().translate(150);
|
|
150
|
-
const m3 = new CSSMatrix().translate(150);
|
|
151
|
-
|
|
152
|
-
cy.get('.bg-primary').then(($el) => {
|
|
153
|
-
$el[0].style.transform = m3.toString();
|
|
154
|
-
})
|
|
155
|
-
.get('.bg-secondary').then(($el) => {
|
|
156
|
-
$el[0].style.transform = d3.toString();
|
|
157
|
-
})
|
|
158
|
-
expect(m3.isIdentity).to.equal(d3.isIdentity);
|
|
159
|
-
expect(m3.is2D).to.equal(d3.is2D);
|
|
160
|
-
// expect(m3.toFloat32Array()).to.deep.equal(d3.toFloat32Array());
|
|
161
|
-
// expect(m3.toFloat64Array()).to.deep.equal(d3.toFloat64Array());
|
|
162
|
-
expect(Array.from(m3.toFloat32Array()).map(roundTo4))
|
|
163
|
-
.to.deep.equal(Array.from(d3.toFloat32Array()).map(roundTo4));
|
|
164
|
-
expect(Array.from(m3.toFloat64Array()).map(roundTo4))
|
|
165
|
-
.to.deep.equal(Array.from(d3.toFloat64Array()).map(roundTo4));
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
cy.log('CSSMatrix.skew(x:15, y:-20)').then(() => {
|
|
169
|
-
const d4 = new DOMMatrix('skew(15deg, -20deg)');
|
|
170
|
-
const m4 = new CSSMatrix().skew(15, -20);
|
|
171
|
-
cy.log('In this test we\'re addapting to the output of the native DOMMatrix method since it doesn\'t support the skew() method itself.')
|
|
172
|
-
.get('.bg-primary').then(($el) => {
|
|
173
|
-
$el[0].style.transform = m4.toString();
|
|
174
|
-
})
|
|
175
|
-
.get('.bg-secondary').then(($el) => {
|
|
176
|
-
$el[0].style.transform = d4.toString();
|
|
177
|
-
})
|
|
178
|
-
expect(m4.isIdentity).to.equal(d4.isIdentity);
|
|
179
|
-
expect(m4.is2D).to.equal(d4.is2D);
|
|
180
|
-
// expect(m4.toFloat32Array()).to.deep.equal(d4.toFloat32Array());
|
|
181
|
-
// expect(m4.toFloat64Array()).to.deep.equal(d4.toFloat64Array());
|
|
182
|
-
expect(Array.from(m4.toFloat32Array()).map(roundTo4))
|
|
183
|
-
.to.deep.equal(Array.from(d4.toFloat32Array()).map(roundTo4));
|
|
184
|
-
expect(Array.from(m4.toFloat64Array()).map(roundTo4))
|
|
185
|
-
.to.deep.equal(Array.from(d4.toFloat64Array()).map(roundTo4));
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
cy.log('CSSMatrix.scale(x:1.3)').then(() => {
|
|
189
|
-
const d5 = new DOMMatrix().scale(1.3);
|
|
190
|
-
const m5 = new CSSMatrix().scale(1.3);
|
|
191
|
-
cy.get('.bg-primary').then(($el) => {
|
|
192
|
-
$el[0].style.transform = m5.toString();
|
|
193
|
-
})
|
|
194
|
-
.get('.bg-secondary').then(($el) => {
|
|
195
|
-
$el[0].style.transform = d5.toString();
|
|
196
|
-
})
|
|
197
|
-
expect(m5.isIdentity).to.equal(d5.isIdentity);
|
|
198
|
-
expect(m5.is2D).to.equal(d5.is2D);
|
|
199
|
-
// expect(m5.toFloat32Array()).to.deep.equal(d5.toFloat32Array());
|
|
200
|
-
// expect(m5.toFloat64Array()).to.deep.equal(d5.toFloat64Array());
|
|
201
|
-
expect(Array.from(m5.toFloat32Array()).map(roundTo4))
|
|
202
|
-
.to.deep.equal(Array.from(d5.toFloat32Array()).map(roundTo4));
|
|
203
|
-
expect(Array.from(m5.toFloat64Array()).map(roundTo4))
|
|
204
|
-
.to.deep.equal(Array.from(d5.toFloat64Array()).map(roundTo4));
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
cy.log('CSSMatrix.scale(x:1.3,y:1.8)').then(() => {
|
|
208
|
-
const d6 = new DOMMatrix().scale(1.3,1.8);
|
|
209
|
-
const m6 = new CSSMatrix().scale(1.3,1.8);
|
|
210
|
-
cy.get('.bg-primary').then(($el) => {
|
|
211
|
-
$el[0].style.transform = m6.toString();
|
|
212
|
-
})
|
|
213
|
-
.get('.bg-secondary').then(($el) => {
|
|
214
|
-
$el[0].style.transform = d6.toString();
|
|
215
|
-
})
|
|
216
|
-
expect(m6.isIdentity).to.equal(d6.isIdentity);
|
|
217
|
-
expect(m6.is2D).to.equal(d6.is2D);
|
|
218
|
-
// expect(m6.toFloat32Array()).to.deep.equal(d6.toFloat32Array());
|
|
219
|
-
// expect(m6.toFloat64Array()).to.deep.equal(d6.toFloat64Array());
|
|
220
|
-
expect(Array.from(m6.toFloat32Array()).map(roundTo4))
|
|
221
|
-
.to.deep.equal(Array.from(d6.toFloat32Array()).map(roundTo4));
|
|
222
|
-
expect(Array.from(m6.toFloat64Array()).map(roundTo4))
|
|
223
|
-
.to.deep.equal(Array.from(d6.toFloat64Array()).map(roundTo4));
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
cy.log('CSSMatrix.transformPoint').then(() => {
|
|
227
|
-
const p1 = new DOMPoint(15, 20, 35, 1);
|
|
228
|
-
const p2 = { x: 15, y: 20, z: 35, w: 1};
|
|
229
|
-
const dp = new DOMMatrix().rotate(15).translate(15, 15);
|
|
230
|
-
const mp = new CSSMatrix().rotate(15).translate(15, 15);
|
|
231
|
-
|
|
232
|
-
cy.log('For some reason the native DOMMatrix again falsely claims **is2D** to be true');
|
|
233
|
-
expect(mp.isIdentity).to.equal(dp.isIdentity);
|
|
234
|
-
expect(mp.is2D).to.equal(dp.is2D);
|
|
235
|
-
expect(mp.toFloat32Array()).to.deep.equal(dp.toFloat32Array());
|
|
236
|
-
expect(mp.toFloat64Array()).to.deep.equal(dp.toFloat64Array());
|
|
237
|
-
expect(mp.transformPoint(p1)).to.deep.equal(dp.transformPoint(p1));
|
|
238
|
-
expect(mp.transformPoint(p2)).to.deep.equal(dp.transformPoint(p2).toJSON());
|
|
239
|
-
});
|
|
240
|
-
});
|
|
241
|
-
|
|
242
|
-
it('Test init a 6 values array', () => {
|
|
243
|
-
const test = [0.9659, 0.25879, -0.2588, 0.9659, -1.53961, -1.53961] as Matrix;
|
|
244
|
-
const m1 = new CSSMatrix(test);
|
|
245
|
-
// const m2 = new CSSMatrix(...test);
|
|
246
|
-
const m3 = new CSSMatrix([...test]);
|
|
247
|
-
const m4 = new DOMMatrix(test);
|
|
248
|
-
|
|
249
|
-
expect(m1.toFloat64Array()).to.deep.equal(m3.toFloat64Array())
|
|
250
|
-
expect(m1.toFloat64Array()).to.deep.equal(m4.toFloat64Array())
|
|
251
|
-
});
|
|
252
|
-
|
|
253
|
-
it('Test init a 16 values array', () => {
|
|
254
|
-
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;
|
|
255
|
-
const m1 = new CSSMatrix(test);
|
|
256
|
-
// const m2 = new CSSMatrix(...test);
|
|
257
|
-
const m3 = new CSSMatrix([...test]);
|
|
258
|
-
const m4 = new DOMMatrix(test);
|
|
259
|
-
|
|
260
|
-
expect(m1.toFloat32Array()).to.deep.equal(m3.toFloat32Array())
|
|
261
|
-
expect(m1.toFloat32Array()).to.deep.equal(m4.toFloat32Array())
|
|
262
|
-
});
|
|
263
|
-
|
|
264
|
-
it('Test static methods', () => {
|
|
265
|
-
const m = new CSSMatrix();
|
|
266
|
-
const source = {a: 1};
|
|
267
|
-
const source1 = 'wombat(1)';
|
|
268
|
-
const source2 = 'skew()';
|
|
269
|
-
const source3 = 'translate(wombat)';
|
|
270
|
-
|
|
271
|
-
expect(CSSMatrix.fromMatrix(m)).to.deep.equal(m);
|
|
272
|
-
expect(CSSMatrix.fromMatrix(m.toJSON())).to.deep.equal(m);
|
|
273
|
-
|
|
274
|
-
try {
|
|
275
|
-
// @ts-ignore
|
|
276
|
-
CSSMatrix.fromString(source);
|
|
277
|
-
} catch (err) {
|
|
278
|
-
expect(err).to.be.instanceOf(TypeError);
|
|
279
|
-
expect(err).to.have.property('message', `CSSMatrix: "${JSON.stringify(source)}" is not a string.`);
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
try {
|
|
283
|
-
CSSMatrix.fromString(source1);
|
|
284
|
-
} catch (err) {
|
|
285
|
-
expect(err).to.be.instanceOf(TypeError);
|
|
286
|
-
expect(err).to.have.property('message', `CSSMatrix: invalid transform string "${source1}"`);
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
try {
|
|
290
|
-
CSSMatrix.fromString(source2);
|
|
291
|
-
} catch (err) {
|
|
292
|
-
expect(err).to.be.instanceOf(TypeError);
|
|
293
|
-
expect(err).to.have.property('message', `CSSMatrix: invalid transform string "${source2}"`);
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
try {
|
|
297
|
-
CSSMatrix.fromString(source3);
|
|
298
|
-
} catch (err) {
|
|
299
|
-
expect(err).to.be.instanceOf(TypeError);
|
|
300
|
-
expect(err).to.have.property('message', `CSSMatrix: invalid transform string "${source3}"`);
|
|
301
|
-
}
|
|
302
|
-
});
|
|
303
|
-
|
|
304
|
-
Object.keys(testSamples).forEach((test) => {
|
|
305
|
-
it(`Test string input ${test}, expect same output as native DOMMatrix`, () => {
|
|
306
|
-
const str = testSamples[test];
|
|
307
|
-
const css = new CSSMatrix(str);
|
|
308
|
-
const dom = new DOMMatrix(str);
|
|
309
|
-
|
|
310
|
-
cy.get('.bg-primary').then(($el) => {
|
|
311
|
-
$el[0].style.transform = css.toString();
|
|
312
|
-
});
|
|
313
|
-
cy.get('.bg-secondary').then(($el) => {
|
|
314
|
-
$el[0].style.transform = dom.toString();
|
|
315
|
-
});
|
|
316
|
-
|
|
317
|
-
cy.log('Due to the nature of the native DOMMatrix RegExp, for consistency reasons we\'re rounding numbers to 6 decimals in this test.')
|
|
318
|
-
|
|
319
|
-
expect(Array.from(css.toFloat32Array()).map(roundTo4))
|
|
320
|
-
.to.deep.equal(Array.from(dom.toFloat32Array()).map(roundTo4));
|
|
321
|
-
|
|
322
|
-
cy.wrap(css).as('css')
|
|
323
|
-
.log('The native `DOMMatrix` is a little weird when it comes to rotateAxisAngle, it falsely claims the identity matrix is NOT `is2D`')
|
|
324
|
-
.get('@css').its('isIdentity').should((isIdentity) => expect(isIdentity).to.equal(dom.isIdentity))
|
|
325
|
-
.get('@css').its('is2D').should((test === 'rotate3d1' ? 'not.equal' : 'equal'), dom.is2D);
|
|
326
|
-
});
|
|
327
|
-
})
|
|
328
|
-
});
|
|
@@ -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
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
// sources
|
|
2
|
-
// * https://github.com/enketo/enketo-express/blob/master/tools/esbuild-plugin-istanbul.js
|
|
3
|
-
'use strict';
|
|
4
|
-
import esbuild from 'esbuild';
|
|
5
|
-
import { promises } from 'fs';
|
|
6
|
-
import { createInstrumenter } from 'istanbul-lib-instrument';
|
|
7
|
-
import { extname, sep } from 'path';
|
|
8
|
-
import tsCompile from './tsCompile';
|
|
9
|
-
|
|
10
|
-
// import Cypress settings
|
|
11
|
-
const sourceFolder = 'src';
|
|
12
|
-
const [name] = process.cwd().split(sep).slice(-1);
|
|
13
|
-
|
|
14
|
-
const sourceFilter = `${name}${sep}${sourceFolder}`;
|
|
15
|
-
const instrumenter = createInstrumenter({
|
|
16
|
-
compact: false,
|
|
17
|
-
esModules: true,
|
|
18
|
-
preserveComments: true,
|
|
19
|
-
autoWrap: true,
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
const createEsbuildIstanbulPlugin = (): esbuild.Plugin => {
|
|
23
|
-
return {
|
|
24
|
-
name: 'istanbul',
|
|
25
|
-
setup(build: esbuild.PluginBuild) {
|
|
26
|
-
build.onLoad(
|
|
27
|
-
{ filter: /\.(ts|tsx)$/ },
|
|
28
|
-
async ({ path }: esbuild.OnLoadArgs): Promise<{ contents: string } & Record<string, any>> => {
|
|
29
|
-
|
|
30
|
-
if (!path.includes(sourceFilter)) {
|
|
31
|
-
// console.log("> compiling typescript %s for output build", path);
|
|
32
|
-
const contents = await promises.readFile(path, 'utf8');
|
|
33
|
-
return {
|
|
34
|
-
contents: ['.ts', '.tsx'].includes(extname(path)) ? tsCompile(path).outputText : contents,
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// console.log("🧡 instrumenting %s for output coverage", path);
|
|
39
|
-
const { outputText, sourceMap } = tsCompile(path);
|
|
40
|
-
|
|
41
|
-
return {
|
|
42
|
-
contents: instrumenter.instrumentSync(outputText, path, sourceMap),
|
|
43
|
-
};
|
|
44
|
-
},
|
|
45
|
-
);
|
|
46
|
-
},
|
|
47
|
-
};
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
export default createEsbuildIstanbulPlugin;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
// compile.ts
|
|
2
|
-
import TypeScript from 'typescript';
|
|
3
|
-
import { basename } from 'path';
|
|
4
|
-
import { RawSourceMap } from 'source-map';
|
|
5
|
-
import { readFileSync } from 'fs';
|
|
6
|
-
|
|
7
|
-
export default function tsCompile(
|
|
8
|
-
path: string,
|
|
9
|
-
ops?: Partial<TypeScript.TranspileOptions>,
|
|
10
|
-
): TypeScript.TranspileOutput & { sourceMap: RawSourceMap } {
|
|
11
|
-
// Default options -- you could also perform a merge, or use the project tsconfig.json
|
|
12
|
-
const options: TypeScript.TranspileOptions = Object.assign(
|
|
13
|
-
{
|
|
14
|
-
compilerOptions: {
|
|
15
|
-
allowJs: true,
|
|
16
|
-
esModuleInterop: true,
|
|
17
|
-
removeComments: false,
|
|
18
|
-
target: 99, // ESNext
|
|
19
|
-
allowSyntheticDefaultImports: true,
|
|
20
|
-
isolatedModules: true,
|
|
21
|
-
noEmitHelpers: true,
|
|
22
|
-
sourceMap: true,
|
|
23
|
-
} as Partial<TypeScript.CompilerOptions>,
|
|
24
|
-
},
|
|
25
|
-
ops,
|
|
26
|
-
);
|
|
27
|
-
const contents = readFileSync(path, { encoding: 'utf8' });
|
|
28
|
-
const { outputText, sourceMapText } = TypeScript.transpileModule(contents, options);
|
|
29
|
-
const sourceMap: RawSourceMap = JSON.parse(sourceMapText || '');
|
|
30
|
-
sourceMap.file = basename(path);
|
|
31
|
-
sourceMap.sources = [basename(path)];
|
|
32
|
-
|
|
33
|
-
return { outputText, sourceMap, sourceMapText };
|
|
34
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/// <reference types="cypress" />
|
|
2
|
-
// ***********************************************
|
|
3
|
-
// This example commands.ts shows you how to
|
|
4
|
-
// create various custom commands and overwrite
|
|
5
|
-
// existing commands.
|
|
6
|
-
//
|
|
7
|
-
// For more comprehensive examples of custom
|
|
8
|
-
// commands please read more here:
|
|
9
|
-
// https://on.cypress.io/custom-commands
|
|
10
|
-
// ***********************************************
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
// -- This is a parent command --
|
|
14
|
-
// Cypress.Commands.add('login', (email, password) => { ... })
|
|
15
|
-
//
|
|
16
|
-
//
|
|
17
|
-
// -- This is a child command --
|
|
18
|
-
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
|
|
19
|
-
//
|
|
20
|
-
//
|
|
21
|
-
// -- This is a dual command --
|
|
22
|
-
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
|
|
23
|
-
//
|
|
24
|
-
//
|
|
25
|
-
// -- This will overwrite an existing command --
|
|
26
|
-
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
|
|
27
|
-
//
|
|
28
|
-
// declare global {
|
|
29
|
-
// namespace Cypress {
|
|
30
|
-
// interface Chainable {
|
|
31
|
-
// login(email: string, password: string): Chainable<void>
|
|
32
|
-
// drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
|
|
33
|
-
// dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
|
|
34
|
-
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>
|
|
35
|
-
// }
|
|
36
|
-
// }
|
|
37
|
-
// }
|
package/cypress/support/e2e.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
// ***********************************************************
|
|
2
|
-
// This example support/e2e.ts is processed and
|
|
3
|
-
// loaded automatically before your test files.
|
|
4
|
-
//
|
|
5
|
-
// This is a great place to put global configuration and
|
|
6
|
-
// behavior that modifies Cypress.
|
|
7
|
-
//
|
|
8
|
-
// You can change the location of this file or turn off
|
|
9
|
-
// automatically serving support files with the
|
|
10
|
-
// 'supportFile' configuration option.
|
|
11
|
-
//
|
|
12
|
-
// You can read more here:
|
|
13
|
-
// https://on.cypress.io/configuration
|
|
14
|
-
// ***********************************************************
|
|
15
|
-
|
|
16
|
-
// Import commands.js using ES2015 syntax:
|
|
17
|
-
import "./commands";
|
|
18
|
-
|
|
19
|
-
// Alternatively you can use CommonJS syntax:
|
|
20
|
-
// require('./commands')
|
|
21
|
-
import "@cypress/code-coverage/support";
|
package/cypress/test.html
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8">
|
|
5
|
-
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1.0">
|
|
7
|
-
<title>DOMMatrix Test</title>
|
|
8
|
-
<meta name="description" content="DOMMatrix Shim Demo">
|
|
9
|
-
<meta name="keywords" content="javascript,svg,svg path,dommatrix,cssmatrix">
|
|
10
|
-
<meta name="author" content="thednp">
|
|
11
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css">
|
|
12
|
-
<style>
|
|
13
|
-
.box {height: 200px;}
|
|
14
|
-
#dom, #css {transition: transform 0.5s ease;}
|
|
15
|
-
</style>
|
|
16
|
-
</head>
|
|
17
|
-
<body class="container">
|
|
18
|
-
<h1 class="mt-3 mt-md-5"><a class="text-decoration-none" href="https://github.com/thednp/DOMMatrix">DOMMatrix Shim Test</a></h1>
|
|
19
|
-
|
|
20
|
-
<div class="row">
|
|
21
|
-
<div id="css" class="col-12 col-md-6">
|
|
22
|
-
<div class="box bg-primary text-white p-3 my-3 text-center align-self-center rounded">
|
|
23
|
-
<b>CSSMatrix</b><br><span class="row"></span>
|
|
24
|
-
</div>
|
|
25
|
-
</div>
|
|
26
|
-
<div id="dom" class="col-12 col-md-6">
|
|
27
|
-
<div class="box bg-secondary text-white p-3 my-3 text-center align-self-center rounded">
|
|
28
|
-
<b>DOMMatrix</b><br><span class="row"></span>
|
|
29
|
-
</div>
|
|
30
|
-
</div>
|
|
31
|
-
</div>
|
|
32
|
-
|
|
33
|
-
</body>
|
|
34
|
-
|
|
35
|
-
</html>
|
package/cypress.config.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from "cypress";
|
|
2
|
-
import createBundler from "@bahmutov/cypress-esbuild-preprocessor";
|
|
3
|
-
import createEsbuildIstanbulPlugin from "./cypress/plugins/esbuild-istanbul";
|
|
4
|
-
|
|
5
|
-
async function setupNodeEvents(
|
|
6
|
-
on: Cypress.PluginEvents,
|
|
7
|
-
config: Cypress.PluginConfigOptions
|
|
8
|
-
): Promise<Cypress.PluginConfigOptions> {
|
|
9
|
-
await require("@cypress/code-coverage/task")(on, config);
|
|
10
|
-
|
|
11
|
-
on(
|
|
12
|
-
"file:preprocessor",
|
|
13
|
-
createBundler({
|
|
14
|
-
plugins: [createEsbuildIstanbulPlugin()],
|
|
15
|
-
})
|
|
16
|
-
);
|
|
17
|
-
|
|
18
|
-
// Make sure to return the config object as it might have been modified by the plugin.
|
|
19
|
-
return config;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export default defineConfig({
|
|
23
|
-
e2e: {
|
|
24
|
-
specPattern: "cypress/e2e/**/*.{js,jsx,ts,tsx}",
|
|
25
|
-
supportFile: "cypress/support/e2e.ts",
|
|
26
|
-
video: false,
|
|
27
|
-
setupNodeEvents,
|
|
28
|
-
},
|
|
29
|
-
});
|
package/dts.config.ts
DELETED