-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ESM and jsdoc #8
base: master
Are you sure you want to change the base?
Conversation
519dfdc
to
d7a4d22
Compare
…` `module` - Refactoring: ESM in source; change Bezier functions to individual exports - Docs: Fix jsdoc item; Add jsdoc config - npm: Add `rollup` script; add it and `eslint` to test script; add `jsdoc` script and scripts/server for opening docs; update deps
Thanks for accepting the last pull... FWIW, it seems the owner of kld-intersections has given a lot of feedback on my initial PR, so we can see what comes out of it as far as meeting your needs. I have rebased this PR too though, if you do care to take these changes now. |
kld-intersections has since integrated my linting and ESM changes, so if you end up utilizing their code, this PR should not be necessary (though there'd still need to be a simple Rollup routine). As far as working on top of the UI, I still think svg-intersections' approach would be warranted, but the kld-intersections author did not want to include this, so I think there is indeed still a need for svg-intersections, whose API has the following advantages in making explicit the properties:
I think you could even simplify further by allowing for just: circle({cx: 50, cy: 100, r: 300}); I made my own shim for your approach as below, but it is not complete. function shape ({shape, props}) {
let args;
switch (shape) {
default:
throw new TypeError('Unexpected shape ' + shape);
case 'rect': {
const {x, y, width, height} = props;
args = new IntersectionArgs('Rectangle', [
new Point2D(x, y),
new Point2D(x + width, y + height)
]);
break;
} case 'circle': {
const {cx, cy, r} = props;
args = new IntersectionArgs('Circle', [new Point2D(cx, cy), r]);
break;
} case 'polygon': {
const {points} = props;
args = new IntersectionArgs('Polygon', [points]);
break;
}
}
return args;
} Also I'd hope you could continue to expose In short, I'd recommend taking a look at https://github.com/thelonious/kld-intersections/blob/development/lib/AffineShapes.js and https://github.com/thelonious/kld-intersections/blob/development/lib/Shapes.js to see if you think it is enough to just continue to follow the Btw, he has already provided https://github.com/thelonious/kld-intersections/blob/development/lib/SvgShapes.js , so there is no need for a new shim for supplying SVG elements, unless you wanted an SVG-element version of svgElementIntersect(
svgElementShape1,
svgElementShape2
); Intersection.intersect(
SvgShapes.element(svgElementShape1),
SvgShapes.element(svgElementShape2)
); |
Builds on PR #7, so I'd appreciate a review of that first, and I can rebase this as needed; but you can see just these changes by looking at its latest commit:
package.json
module
rollup
script; addjsdoc
script and scripts/server for opening docs; update depsI havent yet refactored to ES6 (with Babel) besides the modules (as proposed in my previous PR), as wanted to get your approval first.
I only converted the Bezier functions to individual exports (the ESM equivalent of
exports
instead ofmodule.exports
), though I could have done so in some other cases. If you are open to it, I believe that should probably be done as well so that importers only need import those functions/classes they want, but I can revert even the Bezier functions if you want.