@shopify/klint 0.0.4 → 0.0.7
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/README.md +72 -19
- package/dist/index.cjs +57 -111
- package/dist/index.d.cts +810 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +54 -108
- package/dist/plugins/index.cjs +12 -18
- package/dist/plugins/index.d.cts +731 -0
- package/dist/plugins/index.d.ts +1 -1
- package/dist/plugins/index.js +9 -15
- package/package.json +7 -3
package/dist/plugins/index.d.ts
CHANGED
package/dist/plugins/index.js
CHANGED
|
@@ -386,8 +386,7 @@ var Easing = class {
|
|
|
386
386
|
const m = val - 1;
|
|
387
387
|
const t = val * 2;
|
|
388
388
|
const k = 1.70158 * 1.525;
|
|
389
|
-
if (val < 0.5)
|
|
390
|
-
return val * t * (t * (k + 1) - k);
|
|
389
|
+
if (val < 0.5) return val * t * (t * (k + 1) - k);
|
|
391
390
|
return 1 + 2 * m * m * (2 * m * (k + 1) + k);
|
|
392
391
|
};
|
|
393
392
|
this.bounceOut = (val) => {
|
|
@@ -417,8 +416,7 @@ var Easing = class {
|
|
|
417
416
|
};
|
|
418
417
|
this.bounceInOut = (val) => {
|
|
419
418
|
const t = val * 2;
|
|
420
|
-
if (t < 1)
|
|
421
|
-
return 0.5 - 0.5 * this.bounceOut(1 - t);
|
|
419
|
+
if (t < 1) return 0.5 - 0.5 * this.bounceOut(1 - t);
|
|
422
420
|
return 0.5 + 0.5 * this.bounceOut(t - 1);
|
|
423
421
|
};
|
|
424
422
|
this.elasticIn = (val) => {
|
|
@@ -431,8 +429,7 @@ var Easing = class {
|
|
|
431
429
|
this.elasticInOut = (val) => {
|
|
432
430
|
const s = 2 * val - 1;
|
|
433
431
|
const k = (80 * s - 9) * Math.PI / 18;
|
|
434
|
-
if (s < 0)
|
|
435
|
-
return -0.5 * Math.pow(2, 10 * s) * Math.sin(k);
|
|
432
|
+
if (s < 0) return -0.5 * Math.pow(2, 10 * s) * Math.sin(k);
|
|
436
433
|
return 1 + 0.5 * Math.pow(2, -10 * s) * Math.sin(k);
|
|
437
434
|
};
|
|
438
435
|
this.smoothstep = (val, x0 = 0, x1 = 1) => {
|
|
@@ -563,8 +560,7 @@ var SVGfont = class {
|
|
|
563
560
|
const glyph = this.glyphs.get(char);
|
|
564
561
|
if (glyph) {
|
|
565
562
|
totalWidth += glyph.horizAdvX;
|
|
566
|
-
if (i < chars.length - 1)
|
|
567
|
-
totalWidth += letterSpacing;
|
|
563
|
+
if (i < chars.length - 1) totalWidth += letterSpacing;
|
|
568
564
|
}
|
|
569
565
|
});
|
|
570
566
|
let currentX = 0;
|
|
@@ -589,8 +585,7 @@ var SVGfont = class {
|
|
|
589
585
|
}
|
|
590
586
|
for (const char of chars) {
|
|
591
587
|
const glyph = this.glyphs.get(char);
|
|
592
|
-
if (!glyph)
|
|
593
|
-
continue;
|
|
588
|
+
if (!glyph) continue;
|
|
594
589
|
if (!glyph.d) {
|
|
595
590
|
currentX += glyph.horizAdvX + letterSpacing;
|
|
596
591
|
continue;
|
|
@@ -599,8 +594,7 @@ var SVGfont = class {
|
|
|
599
594
|
const subpaths = glyph.d.split(/(?=[Mm])/);
|
|
600
595
|
const glyphContours = [];
|
|
601
596
|
for (const subpath of subpaths) {
|
|
602
|
-
if (!subpath.trim())
|
|
603
|
-
continue;
|
|
597
|
+
if (!subpath.trim()) continue;
|
|
604
598
|
path.setAttribute("d", subpath);
|
|
605
599
|
const pathLength = path.getTotalLength();
|
|
606
600
|
const numPoints = Math.max(10, Math.floor(pathLength * factor));
|
|
@@ -705,7 +699,7 @@ var State = class {
|
|
|
705
699
|
var State_default = State;
|
|
706
700
|
|
|
707
701
|
// src/plugins/Vector.tsx
|
|
708
|
-
var Vector = class {
|
|
702
|
+
var Vector = class _Vector {
|
|
709
703
|
/**
|
|
710
704
|
* Creates a new Vector
|
|
711
705
|
* @param x - X-coordinate (default: 0)
|
|
@@ -812,7 +806,7 @@ var Vector = class {
|
|
|
812
806
|
* @returns A new Vector with the same coordinates
|
|
813
807
|
*/
|
|
814
808
|
copy() {
|
|
815
|
-
return new
|
|
809
|
+
return new _Vector(this.x, this.y);
|
|
816
810
|
}
|
|
817
811
|
/**
|
|
818
812
|
* Normalizes this vector (sets its magnitude to 1)
|
|
@@ -843,7 +837,7 @@ var Vector = class {
|
|
|
843
837
|
static fromAngle(center, a, r) {
|
|
844
838
|
const x = Math.cos(a) * r + center.x;
|
|
845
839
|
const y = Math.sin(a) * r + center.y;
|
|
846
|
-
return new
|
|
840
|
+
return new _Vector(x, y);
|
|
847
841
|
}
|
|
848
842
|
};
|
|
849
843
|
var Vector_default = Vector;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@shopify/klint",
|
|
3
3
|
"author": "arthurcloche",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "0.0.
|
|
5
|
+
"version": "0.0.7",
|
|
6
6
|
"description": "A modern creative coding library",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "dist/index.cjs",
|
|
@@ -20,6 +20,10 @@
|
|
|
20
20
|
"type": "git",
|
|
21
21
|
"url": "https://github.com/Shopify/Klint"
|
|
22
22
|
},
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public",
|
|
25
|
+
"@shopify:registry": "https://registry.npmjs.org/"
|
|
26
|
+
},
|
|
23
27
|
"files": [
|
|
24
28
|
"dist"
|
|
25
29
|
],
|
|
@@ -70,11 +74,11 @@
|
|
|
70
74
|
"concurrently": "^8.2.0",
|
|
71
75
|
"jsdom": "^26.0.0",
|
|
72
76
|
"rimraf": "^5.0.0",
|
|
73
|
-
"tsup": "^
|
|
77
|
+
"tsup": "^8.4.0",
|
|
74
78
|
"typescript": "^5.0.0",
|
|
75
79
|
"vite": "^6.2.5",
|
|
76
80
|
"vite-tsconfig-paths": "^5.1.4",
|
|
77
|
-
"vitest": "^
|
|
81
|
+
"vitest": "^3.1.1",
|
|
78
82
|
"vitest-canvas-mock": "^0.3.3"
|
|
79
83
|
}
|
|
80
84
|
}
|