Skip to content

Commit

Permalink
refactor(geom): restructure package
Browse files Browse the repository at this point in the history
- migrate/lift `/src/ops` source files to `/src` for easier use
  • Loading branch information
postspectacular committed Oct 8, 2021
1 parent 7e6f84e commit 2439102
Show file tree
Hide file tree
Showing 42 changed files with 380 additions and 385 deletions.
189 changes: 94 additions & 95 deletions packages/geom/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"scripts": {
"build": "yarn clean && tsc --declaration",
"build:check": "tsc --isolatedModules --noEmit",
"clean": "rimraf *.js *.d.ts *.map doc api ctors internal ops",
"clean": "rimraf *.js *.d.ts *.map doc api ctors internal",
"doc": "typedoc --excludePrivate --excludeInternal --out doc src/index.ts",
"doc:ae": "mkdir -p .ae/doc .ae/temp && node_modules/.bin/api-extractor run --local --verbose",
"doc:readme": "../../scripts/node-esm ../../tools/src/readme.ts",
Expand Down Expand Up @@ -95,8 +95,7 @@
"*.d.ts",
"api",
"ctors",
"internal",
"ops"
"internal"
],
"exports": {
".": {
Expand Down Expand Up @@ -165,6 +164,48 @@
"./api/triangle": {
"import": "./api/triangle.js"
},
"./arc-length": {
"import": "./arc-length.js"
},
"./area": {
"import": "./area.js"
},
"./as-cubic": {
"import": "./as-cubic.js"
},
"./as-path": {
"import": "./as-path.js"
},
"./as-polygon": {
"import": "./as-polygon.js"
},
"./as-polyline": {
"import": "./as-polyline.js"
},
"./as-svg": {
"import": "./as-svg.js"
},
"./bounds": {
"import": "./bounds.js"
},
"./center": {
"import": "./center.js"
},
"./centroid": {
"import": "./centroid.js"
},
"./classify-point": {
"import": "./classify-point.js"
},
"./clip-convex": {
"import": "./clip-convex.js"
},
"./closest-point": {
"import": "./closest-point.js"
},
"./convex-hull": {
"import": "./convex-hull.js"
},
"./ctors/aabb": {
"import": "./ctors/aabb.js"
},
Expand Down Expand Up @@ -228,122 +269,80 @@
"./ctors/triangle": {
"import": "./ctors/triangle.js"
},
"./ops/arc-length": {
"import": "./ops/arc-length.js"
},
"./ops/area": {
"import": "./ops/area.js"
},
"./ops/as-cubic": {
"import": "./ops/as-cubic.js"
},
"./ops/as-path": {
"import": "./ops/as-path.js"
},
"./ops/as-polygon": {
"import": "./ops/as-polygon.js"
},
"./ops/as-polyline": {
"import": "./ops/as-polyline.js"
},
"./ops/as-svg": {
"import": "./ops/as-svg.js"
},
"./ops/bounds": {
"import": "./ops/bounds.js"
},
"./ops/center": {
"import": "./ops/center.js"
},
"./ops/centroid": {
"import": "./ops/centroid.js"
},
"./ops/classify-point": {
"import": "./ops/classify-point.js"
},
"./ops/clip-convex": {
"import": "./ops/clip-convex.js"
},
"./ops/closest-point": {
"import": "./ops/closest-point.js"
},
"./ops/convex-hull": {
"import": "./ops/convex-hull.js"
},
"./ops/edges": {
"import": "./ops/edges.js"
"./edges": {
"import": "./edges.js"
},
"./ops/fit-into-bounds": {
"import": "./ops/fit-into-bounds.js"
"./fit-into-bounds": {
"import": "./fit-into-bounds.js"
},
"./ops/flip": {
"import": "./ops/flip.js"
"./flip": {
"import": "./flip.js"
},
"./ops/intersects": {
"import": "./ops/intersects.js"
"./intersects": {
"import": "./intersects.js"
},
"./ops/map-point": {
"import": "./ops/map-point.js"
"./map-point": {
"import": "./map-point.js"
},
"./ops/offset": {
"import": "./ops/offset.js"
"./offset": {
"import": "./offset.js"
},
"./ops/point-at": {
"import": "./ops/point-at.js"
"./point-at": {
"import": "./point-at.js"
},
"./ops/point-inside": {
"import": "./ops/point-inside.js"
"./point-inside": {
"import": "./point-inside.js"
},
"./ops/resample": {
"import": "./ops/resample.js"
"./resample": {
"import": "./resample.js"
},
"./ops/scatter": {
"import": "./ops/scatter.js"
"./scatter": {
"import": "./scatter.js"
},
"./ops/simplify": {
"import": "./ops/simplify.js"
"./simplify": {
"import": "./simplify.js"
},
"./ops/split-at": {
"import": "./ops/split-at.js"
"./split-at": {
"import": "./split-at.js"
},
"./ops/split-near": {
"import": "./ops/split-near.js"
"./split-near": {
"import": "./split-near.js"
},
"./ops/subdiv-curve": {
"import": "./ops/subdiv-curve.js"
"./subdiv-curve": {
"import": "./subdiv-curve.js"
},
"./ops/tangent-at": {
"import": "./ops/tangent-at.js"
"./tangent-at": {
"import": "./tangent-at.js"
},
"./ops/tessellate": {
"import": "./ops/tessellate.js"
"./tessellate": {
"import": "./tessellate.js"
},
"./ops/transform-vertices": {
"import": "./ops/transform-vertices.js"
"./transform-vertices": {
"import": "./transform-vertices.js"
},
"./ops/transform": {
"import": "./ops/transform.js"
"./transform": {
"import": "./transform.js"
},
"./ops/translate": {
"import": "./ops/translate.js"
"./translate": {
"import": "./translate.js"
},
"./ops/union": {
"import": "./ops/union.js"
"./union": {
"import": "./union.js"
},
"./ops/unmap-point": {
"import": "./ops/unmap-point.js"
"./unmap-point": {
"import": "./unmap-point.js"
},
"./ops/vertices": {
"import": "./ops/vertices.js"
"./vertices": {
"import": "./vertices.js"
},
"./ops/volume": {
"import": "./ops/volume.js"
"./volume": {
"import": "./volume.js"
},
"./ops/warp-points": {
"import": "./ops/warp-points.js"
"./warp-points": {
"import": "./warp-points.js"
},
"./ops/with-attribs": {
"import": "./ops/with-attribs.js"
"./with-attribs": {
"import": "./with-attribs.js"
}
},
"thi.ng": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import type { IShape } from "@thi.ng/geom-api";
import { perimeter } from "@thi.ng/geom-poly-utils/perimeter";
import { PI, TAU } from "@thi.ng/math/api";
import { dist } from "@thi.ng/vectors/dist";
import type { Circle } from "../api/circle";
import type { Ellipse } from "../api/ellipse";
import type { Group } from "../api/group";
import type { Line } from "../api/line";
import type { Polygon } from "../api/polygon";
import type { Rect } from "../api/rect";
import type { Triangle } from "../api/triangle";
import { dispatch } from "../internal/dispatch";
import type { Circle } from "./api/circle";
import type { Ellipse } from "./api/ellipse";
import type { Group } from "./api/group";
import type { Line } from "./api/line";
import type { Polygon } from "./api/polygon";
import type { Rect } from "./api/rect";
import type { Triangle } from "./api/triangle";
import { dispatch } from "./internal/dispatch";

/**
* Returns the arc length / perimeter / circumference of the given
Expand Down
20 changes: 10 additions & 10 deletions packages/geom/src/ops/area.ts → packages/geom/src/area.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ import { polyArea2 } from "@thi.ng/geom-poly-utils/area";
import { PI } from "@thi.ng/math/api";
import type { Vec } from "@thi.ng/vectors";
import { signedArea2 } from "@thi.ng/vectors/signed-area";
import type { AABB } from "../api/aabb";
import type { Arc } from "../api/arc";
import type { Circle } from "../api/circle";
import type { Ellipse } from "../api/ellipse";
import type { Group } from "../api/group";
import type { Polygon } from "../api/polygon";
import type { Rect } from "../api/rect";
import type { Sphere } from "../api/sphere";
import type { Triangle } from "../api/triangle";
import { dispatch } from "../internal/dispatch";
import type { AABB } from "./api/aabb";
import type { Arc } from "./api/arc";
import type { Circle } from "./api/circle";
import type { Ellipse } from "./api/ellipse";
import type { Group } from "./api/group";
import type { Polygon } from "./api/polygon";
import type { Rect } from "./api/rect";
import type { Sphere } from "./api/sphere";
import type { Triangle } from "./api/triangle";
import { dispatch } from "./internal/dispatch";

/**
* Returns the possibly signed (unsigned by default) surface area of given
Expand Down
30 changes: 13 additions & 17 deletions packages/geom/src/ops/as-cubic.ts → packages/geom/src/as-cubic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,19 @@ import {
import { TAU } from "@thi.ng/math/api";
import { mapcat } from "@thi.ng/transducers/mapcat";
import type { ReadonlyVec, Vec } from "@thi.ng/vectors";
import type { Circle } from "../api/circle";
import { Cubic } from "../api/cubic";
import type { Group } from "../api/group";
import type { Line } from "../api/line";
import type { Path } from "../api/path";
import type { Polygon } from "../api/polygon";
import type { Polyline } from "../api/polyline";
import type { Quadratic } from "../api/quadratic";
import type { Rect } from "../api/rect";
import { arc } from "../ctors/arc";
import {
cubicFromArc,
cubicFromLine,
cubicFromQuadratic,
} from "../ctors/cubic";
import { copyAttribs } from "../internal/copy-attribs";
import { dispatch } from "../internal/dispatch";
import type { Circle } from "./api/circle";
import { Cubic } from "./api/cubic";
import type { Group } from "./api/group";
import type { Line } from "./api/line";
import type { Path } from "./api/path";
import type { Polygon } from "./api/polygon";
import type { Polyline } from "./api/polyline";
import type { Quadratic } from "./api/quadratic";
import type { Rect } from "./api/rect";
import { arc } from "./ctors/arc";
import { cubicFromArc, cubicFromLine, cubicFromQuadratic } from "./ctors/cubic";
import { copyAttribs } from "./internal/copy-attribs";
import { dispatch } from "./internal/dispatch";
import { asPolygon } from "./as-polygon";

export const asCubic: MultiFn1O<IShape, Partial<CubicOpts>, Cubic[]> = defmulti(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { pathFromCubics } from "../ctors/path";
import { copyAttribs } from "../internal/copy-attribs";
import { pathFromCubics } from "./ctors/path";
import { copyAttribs } from "./internal/copy-attribs";
import { asCubic } from "./as-cubic";
import type { Attribs, IShape } from "@thi.ng/geom-api";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { MultiFn1O } from "@thi.ng/defmulti";
import { defmulti } from "@thi.ng/defmulti/defmulti";
import type { IShape, SamplingOpts } from "@thi.ng/geom-api";
import { Polygon } from "../api/polygon";
import { copyAttribs } from "../internal/copy-attribs";
import { dispatch } from "../internal/dispatch";
import { Polygon } from "./api/polygon";
import { copyAttribs } from "./internal/copy-attribs";
import { dispatch } from "./internal/dispatch";
import { vertices } from "./vertices";

export const asPolygon: MultiFn1O<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import type { MultiFn1O } from "@thi.ng/defmulti";
import { defmulti } from "@thi.ng/defmulti/defmulti";
import type { IShape, SamplingOpts } from "@thi.ng/geom-api";
import { set } from "@thi.ng/vectors/set";
import type { Path } from "../api/path";
import { Polyline } from "../api/polyline";
import { copyAttribs } from "../internal/copy-attribs";
import { dispatch } from "../internal/dispatch";
import type { Path } from "./api/path";
import { Polyline } from "./api/polyline";
import { copyAttribs } from "./internal/copy-attribs";
import { dispatch } from "./internal/dispatch";
import { vertices } from "./vertices";

export const asPolyline: MultiFn1O<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { convertTree } from "@thi.ng/hiccup-svg/convert";
import { ff } from "@thi.ng/hiccup-svg/format";
import { svg } from "@thi.ng/hiccup-svg/svg";
import { serialize } from "@thi.ng/hiccup/serialize";
import { collBounds } from "../internal/coll-bounds";
import { collBounds } from "./internal/coll-bounds";
import { bounds } from "./bounds";

export const asSvg = (...args: any[]) =>
Expand Down
Loading

0 comments on commit 2439102

Please sign in to comment.