Skip to content

Commit ad4cdbd

Browse files
authored
Support types without enabling esModuleInterop in TypeScript (#118)
1 parent bd1dca4 commit ad4cdbd

File tree

16 files changed

+113
-42
lines changed

16 files changed

+113
-42
lines changed

CHANGELOG.md

Lines changed: 47 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,78 @@
11
# CHANGELOG
22

3-
## 1.2.5 - 2024-03-13
3+
## [Unreleased]
4+
5+
## [1.2.6] - 2024-03-14
6+
7+
- Support types without enabling `esModuleInterop` in TypeScript.
8+
9+
## [1.2.5] - 2024-03-13
410

511
- Fixed error computing some quadratic Bézier curves cases.
612

7-
## 1.2.4 - 2023-02-09
13+
## [1.2.4] - 2023-02-09
814

915
- Optimized proccesing of segments based on [Simple Icons] data.
1016

1117
[Simple Icons]: https://github.com/simple-icons/simple-icons
1218

13-
## 1.2.3 - 2022-12-23
19+
## [1.2.3] - 2022-12-23
1420

1521
- Fixed CLI not being executed in some versions of Node.js < v16.
1622

17-
## 1.2.2 - 2022-05-26
23+
## [1.2.2] - 2022-05-26
1824

1925
- Fixed edge case computing cubic Bézier curves bounding boxes.
2026

21-
## 1.2.1 - 2022-05-12
27+
## [1.2.1] - 2022-05-12
2228

2329
- Fixed error computing cubic Bézier curves bounding boxes.
2430

25-
## 1.2.0 - 2022-05-07
31+
## [1.2.0] - 2022-05-07
2632

2733
- Use default export for better interoperability.
2834

29-
## 1.1.0 - 2022-05-05
35+
## [1.1.0] - 2022-05-05
3036

3137
- Add support for Typescript.
3238

33-
## 1.0.2 - 2022-01-11
39+
## [1.0.2] - 2022-01-11
3440

3541
- Add basic options `--version` and `--help` to CLI.
3642

37-
## 1.0.1 - 2021-06-21
43+
## [1.0.1] - 2021-06-21
3844

3945
- Fixed error computing limits for cubic Bèzier curves of length 0.
4046

41-
## 1.0.0 - 2021-06-03
47+
## [1.0.0] - 2021-06-03
4248

4349
- Testing with 100% coverage.
4450
- Make `svgPathBbox` function the default export.
4551

46-
## 0.2.0 - 2020-12-22
52+
## [0.2.0] - 2020-12-22
4753

4854
- Removed almost all public API functions (only keep `svgPathBbox` function).
4955
- Removed `polf` dependency.
5056
- Optimized quadratic Bézier curves minimum and maximum values computation.
5157
- Optimized cubic Bézier curves minimum and maximum values computation.
5258
- Optimized lineal segments minimum and maximum values computation.
5359

54-
## 0.1.5 - 2020-11-26
60+
## [0.1.5] - 2020-11-26
5561

5662
- Documentation improved.
5763
- Switch CI to Github Actions.
5864

59-
## 0.1.4 - 2020-11-23
65+
## [0.1.4] - 2020-11-23
6066

6167
- Document and export `quadraticBezierCurveBbox` function.
6268
- Remove development file from NPM package.
6369
- Update acknowledgments.
6470

65-
## 0.1.1 - 2020-11-19
71+
## [0.1.1] - 2020-11-19
6672

6773
- Fix error computing bounding boxes for Q, T and some C commands.
6874

69-
## 0.0.47 - 2020-07-23
75+
## [0.0.47] - 2020-07-23
7076

7177
- Separate point on line functions in another package.
7278
- Replaced svg-path-parser dependency with svgpath to optimize parsing time.
@@ -75,29 +81,51 @@
7581
- Fix errors in utility functions.
7682
- Add tests for utilities and command line client.
7783

78-
## 0.0.28 - 2020-05-22
84+
## [0.0.28] - 2020-05-22
7985

8086
- Update LICENSE.
8187
- Fix error converting quaratic to Bézier coordinates.
8288
- Add tests for some bounding boxes functions.
8389

84-
## 0.0.26 - 2020-05-21
90+
## [0.0.26] - 2020-05-21
8591

8692
- Removed `quadraticBezierCurveBbox` function.
8793
- Optimized quadratic Bézier curve bounding box computation.
8894
- Optimized cubic Bézier curve bounding box algorithm.
8995
- Fixed error on V and H commands computing SVG path bbox.
9096

91-
## 0.0.20 - 2020-05-17
97+
## [0.0.20] - 2020-05-17
9298

9399
- Add function to obtain an array of numbers from SVG path.
94100
- Multiple paths as arguments for command line script.
95101

96-
## 0.0.13 - 2020-05-17
102+
## [0.0.13] - 2020-05-17
97103

98104
- Add command line interface.
99105
- Add linting.
100106
- Released to NPM.
101107
- Add documentation.
102108
- Add changelog.
103109
- Basic functionalities finished.
110+
111+
[Unreleased]: https://github.com/mondeja/svg-path-bbox/compare/v1.2.6...HEAD
112+
[1.2.6]: https://github.com/mondeja/svg-path-bbox/compare/v1.2.5...v1.2.6
113+
[1.2.5]: https://github.com/mondeja/svg-path-bbox/compare/v1.2.4...v1.2.5
114+
[1.2.4]: https://github.com/mondeja/svg-path-bbox/compare/v1.2.3...v1.2.4
115+
[1.2.3]: https://github.com/mondeja/svg-path-bbox/compare/v1.2.2...v1.2.3
116+
[1.2.2]: https://github.com/mondeja/svg-path-bbox/compare/v1.2.1...v1.2.2
117+
[1.2.1]: https://github.com/mondeja/svg-path-bbox/compare/v1.2.0...v1.2.1
118+
[1.2.0]: https://github.com/mondeja/svg-path-bbox/compare/v1.1.0...v1.2.0
119+
[1.1.0]: https://github.com/mondeja/svg-path-bbox/compare/v1.0.2...v1.1.0
120+
[1.0.2]: https://github.com/mondeja/svg-path-bbox/compare/v1.0.1...v1.0.2
121+
[1.0.1]: https://github.com/mondeja/svg-path-bbox/compare/v1.0.0...v1.0.1
122+
[1.0.0]: https://github.com/mondeja/svg-path-bbox/compare/v0.2.0...v1.0.0
123+
[0.2.0]: https://github.com/mondeja/svg-path-bbox/compare/v0.1.5...v0.2.0
124+
[0.1.5]: https://github.com/mondeja/svg-path-bbox/compare/v0.1.4...v0.1.5
125+
[0.1.4]: https://github.com/mondeja/svg-path-bbox/compare/v0.1.1...v0.1.4
126+
[0.1.1]: https://github.com/mondeja/svg-path-bbox/compare/v0.0.47...v0.1.1
127+
[0.0.47]: https://github.com/mondeja/svg-path-bbox/compare/v0.0.28...v0.0.47
128+
[0.0.28]: https://github.com/mondeja/svg-path-bbox/compare/v0.0.26...v0.0.28
129+
[0.0.26]: https://github.com/mondeja/svg-path-bbox/compare/v0.0.20...v0.0.26
130+
[0.0.20]: https://github.com/mondeja/svg-path-bbox/compare/v0.0.13...v0.0.20
131+
[0.0.13]: https://github.com/mondeja/svg-path-bbox/releases/tag/v0.0.13

dist/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,4 +163,4 @@ function svgPathBbox(d) {
163163
}, true);
164164
return [min[0], min[1], max[0], max[1]];
165165
}
166-
exports.default = svgPathBbox;
166+
module.exports = svgPathBbox;

dist/index.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import svgPathBbox from "./index.js";
2+
export default svgPathBbox;
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
export type BBox = [minX: number, minY: number, maxX: number, maxY: number];
2+
23
/**
34
* Compute bounding boxes of SVG paths.
45
* @param {String} d SVG path for which their bounding box will be computed.
56
* @returns {BBox}
67
*/
7-
export default function svgPathBbox(d: string): BBox;
8+
declare function svgPathBbox(d: string): BBox;
9+
export = svgPathBbox;

dist/wrapper.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

examples/common.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const util = require("util")
2-
const svgPathBbox = require("../dist/wrapper.js");
2+
const svgPathBbox = require("../dist/index.js");
33

44
const bbox = svgPathBbox("M0 0H3V6Z");
55
process.stdout.write(`${util.inspect(bbox)}\n`)

examples/esm.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { inspect } from "node:util";
2-
import svgPathBbox from "../dist/wrapper.js";
2+
import svgPathBbox from "../dist/index.mjs";
33

44
const bbox = svgPathBbox("M0 0H3V6Z");
55
process.stdout.write(`${inspect(bbox)}\n`)

package.json

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,45 @@
11
{
22
"name": "svg-path-bbox",
3-
"version": "1.2.5",
3+
"version": "1.2.6",
44
"description": "Compute bounding boxes of SVG paths.",
55
"keywords": [
66
"svg",
77
"path",
88
"bbox"
99
],
10-
"main": "dist/wrapper.js",
11-
"browser": "dist/wrapper.js",
12-
"module": "dist/wrapper.js",
13-
"types": "dist/index.d.ts",
1410
"type": "commonjs",
11+
"exports": {
12+
".": {
13+
"import": {
14+
"types": "./dist/types.d.ts",
15+
"default": "./dist/index.mjs"
16+
},
17+
"module": {
18+
"types": "./dist/types.d.ts",
19+
"default": "./dist/index.mjs"
20+
},
21+
"require": {
22+
"types": "./dist/types.d.ts",
23+
"default": "./dist/index.js"
24+
},
25+
"default": {
26+
"types": "./dist/types.d.ts",
27+
"default": "./dist/index.js"
28+
}
29+
}
30+
},
1531
"bin": {
1632
"svg-path-bbox": "src/cli.js"
1733
},
1834
"scripts": {
1935
"coveralls": "cat ./tests/coverage/lcov.info | coveralls",
2036
"prebuild": "run-s build:index lint:fix dist:prepare",
21-
"build": "run-p build:ts build:cjs:wrapper",
37+
"build": "run-p build:ts build:patch-dist-indexjs build:create-index-mjs build:copy-types",
2238
"build:index": "ts-node scripts/build/index.ts",
2339
"build:ts": "tsc",
24-
"build:cjs:wrapper": "ts-node scripts/build/cjs-wrapper.ts",
40+
"build:patch-dist-indexjs": "ts-node scripts/build/patch-dist-indexjs.ts",
41+
"build:create-index-mjs": "ts-node scripts/build/create-index-mjs.ts",
42+
"build:copy-types": "ts-node scripts/build/copy-types.ts",
2543
"examples": "run-s example:*",
2644
"example:cjs": "node examples/common.js",
2745
"example:esm": "node examples/esm.mjs",

scripts/build/cjs-wrapper.ts

Lines changed: 0 additions & 8 deletions
This file was deleted.

scripts/build/copy-types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import * as fs from "node:fs";
2+
3+
fs.copyFileSync("src/types.d.ts", "dist/types.d.ts");

0 commit comments

Comments
 (0)