@altano/satori-fit-text 3.2.0 → 3.2.1
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/dist/TextMeasurer/BrowserTextMeasurer.js +1 -2
- package/dist/TextMeasurer/HeadlessTextMeasurer.js +1 -2
- package/dist/TextMeasurer/TextMeasurer.js +1 -2
- package/dist/TextMeasurer/getTextMeasurer.js +1 -2
- package/dist/fitText.d.ts +0 -2
- package/dist/fitText.js +1 -2
- package/dist/index.d.ts +1 -1
- package/dist/log.d.ts +0 -2
- package/dist/log.js +1 -2
- package/dist/types.d.ts +0 -2
- package/package.json +10 -10
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import log from "../log.js";
|
|
2
2
|
import { TextMeasurer } from "./TextMeasurer.js";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/TextMeasurer/BrowserTextMeasurer.ts
|
|
5
5
|
/* v8 ignore start */
|
|
6
6
|
var BrowserTextMeasurer = class extends TextMeasurer {
|
|
7
7
|
#createSvgElement(svgXML) {
|
|
@@ -37,6 +37,5 @@ var BrowserTextMeasurer = class extends TextMeasurer {
|
|
|
37
37
|
};
|
|
38
38
|
/* v8 ignore stop */
|
|
39
39
|
|
|
40
|
-
//#endregion
|
|
41
40
|
export { BrowserTextMeasurer as default };
|
|
42
41
|
//# sourceMappingURL=BrowserTextMeasurer.js.map
|
|
@@ -3,7 +3,7 @@ import { TextMeasurer } from "./TextMeasurer.js";
|
|
|
3
3
|
import { SVG, registerWindow } from "@svgdotjs/svg.js";
|
|
4
4
|
import { createSVGWindow } from "svgdom";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// src/TextMeasurer/HeadlessTextMeasurer.ts
|
|
7
7
|
var HeadlessTextMeasurer = class extends TextMeasurer {
|
|
8
8
|
#canvas;
|
|
9
9
|
constructor(text, font, maxWidth, maxHeight, lineHeight) {
|
|
@@ -37,6 +37,5 @@ var HeadlessTextMeasurer = class extends TextMeasurer {
|
|
|
37
37
|
}
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
-
//#endregion
|
|
41
40
|
export { HeadlessTextMeasurer as default };
|
|
42
41
|
//# sourceMappingURL=HeadlessTextMeasurer.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import satori from "satori";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// src/TextMeasurer/TextMeasurer.ts
|
|
4
4
|
const epsilon = 1e-4;
|
|
5
5
|
var TextMeasurer = class {
|
|
6
6
|
text;
|
|
@@ -50,6 +50,5 @@ var TextMeasurer = class {
|
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
52
|
|
|
53
|
-
//#endregion
|
|
54
53
|
export { TextMeasurer };
|
|
55
54
|
//# sourceMappingURL=TextMeasurer.js.map
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
// src/TextMeasurer/getTextMeasurer.ts
|
|
2
2
|
async function getTextMeasurer(...args) {
|
|
3
3
|
/* v8 ignore next 3 */
|
|
4
4
|
if (typeof window !== "undefined") return new (await (import("./BrowserTextMeasurer.js"))).default(...args);
|
|
5
5
|
else return new (await (import("./HeadlessTextMeasurer.js"))).default(...args);
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
//#endregion
|
|
9
8
|
export { getTextMeasurer };
|
|
10
9
|
//# sourceMappingURL=getTextMeasurer.js.map
|
package/dist/fitText.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Font } from "./types.js";
|
|
2
|
-
//#region src/fitText.d.ts
|
|
3
2
|
export type FindOptions = {
|
|
4
3
|
/**
|
|
5
4
|
* The text you want to fit
|
|
@@ -41,5 +40,4 @@ export type FindOptions = {
|
|
|
41
40
|
* would keep the text contained within the dimensions.
|
|
42
41
|
*/
|
|
43
42
|
export declare function findLargestUsableFontSize({ text, font, maxWidth, maxHeight, lineHeight, minFontSize, maxFontSize, maxTries }: FindOptions): Promise<number>;
|
|
44
|
-
//#endregion
|
|
45
43
|
//# sourceMappingURL=fitText.d.ts.map
|
package/dist/fitText.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getTextMeasurer } from "./TextMeasurer/getTextMeasurer.js";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// src/fitText.ts
|
|
4
4
|
/**
|
|
5
5
|
* Given text, dimensions, and some options, returns the largest font size that
|
|
6
6
|
* would keep the text contained within the dimensions.
|
|
@@ -18,6 +18,5 @@ async function findLargestUsableFontSize({ text, font, maxWidth, maxHeight, line
|
|
|
18
18
|
throw new Error(`Could not find a valid font size in ${maxTries - 1} attempts. Giving up. Please try again after constraining the search space, e.g. by restricting the min/max font size difference.`);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
//#endregion
|
|
22
21
|
export { findLargestUsableFontSize };
|
|
23
22
|
//# sourceMappingURL=fitText.js.map
|
package/dist/index.d.ts
CHANGED
package/dist/log.d.ts
CHANGED
package/dist/log.js
CHANGED
package/dist/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@altano/satori-fit-text",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.1",
|
|
4
4
|
"description": "Fit text to a bounding box in Node or the browser",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fit-text",
|
|
@@ -45,23 +45,23 @@
|
|
|
45
45
|
"@types/debug": "^4.1.13",
|
|
46
46
|
"@types/he": "^1.2.3",
|
|
47
47
|
"@types/jest-image-snapshot": "^6.4.2",
|
|
48
|
-
"@types/node": "^26.6.
|
|
48
|
+
"@types/node": "^26.6.6",
|
|
49
49
|
"@types/react": "^19.3.0",
|
|
50
50
|
"@types/react-dom": "^19.3.0",
|
|
51
51
|
"@types/svgdom": "^0.1.2",
|
|
52
|
-
"@vitest/coverage-v8": "^5.0
|
|
52
|
+
"@vitest/coverage-v8": "^5.1.0",
|
|
53
53
|
"depcheck": "^1.4.7",
|
|
54
54
|
"jest-image-snapshot": "^6.5.2",
|
|
55
|
-
"prettier": "3.9.
|
|
56
|
-
"react": "^19.3.
|
|
57
|
-
"tsdown": "^0.23.
|
|
55
|
+
"prettier": "3.9.10",
|
|
56
|
+
"react": "^19.3.1",
|
|
57
|
+
"tsdown": "^0.23.5",
|
|
58
58
|
"typescript": "^6.0.3",
|
|
59
|
-
"vite": "^8.3.
|
|
60
|
-
"vitest": "^5.0
|
|
59
|
+
"vite": "^8.3.5",
|
|
60
|
+
"vitest": "^5.1.0",
|
|
61
61
|
"@altano/assets": "0.0.1",
|
|
62
|
-
"@altano/tsconfig": "0.0.1",
|
|
63
62
|
"@altano/build-config": "0.0.1",
|
|
64
|
-
"@altano/testing": "0.0.1"
|
|
63
|
+
"@altano/testing": "0.0.1",
|
|
64
|
+
"@altano/tsconfig": "0.0.1"
|
|
65
65
|
},
|
|
66
66
|
"peerDependencies": {
|
|
67
67
|
"@types/react": "19.x.x"
|