From b54b703d4d694f86845925de40d919f7451b5e2b Mon Sep 17 00:00:00 2001 From: Karsten Schmidt Date: Tue, 8 Jan 2019 02:28:20 +0000 Subject: [PATCH] build: update package build scripts & outputs, imports in ~50 packages BREAKING CHANGE: enabled multi-outputs (ES6 modules, CJS, UMD) - build scripts now first build ES6 modules in package root, then call `scripts/bundle-module` to build minified CJS & UMD bundles in `/lib` - all imports MUST be updated to only refer to package level (not individual files anymore). tree shaking in user land will get rid of all unused imported symbols. --- packages/associative/package.json | 17 +- packages/associative/src/api.ts | 2 +- packages/associative/src/array-set.ts | 2 +- packages/associative/src/common-keys.ts | 2 +- packages/associative/src/equiv-map.ts | 3 +- packages/associative/src/invert.ts | 3 +- packages/associative/src/join.ts | 3 +- packages/associative/src/ll-set.ts | 3 +- packages/associative/src/merge-apply.ts | 5 +- packages/associative/src/merge-deep.ts | 5 +- packages/associative/src/merge-with.ts | 3 +- packages/associative/src/merge.ts | 2 +- packages/associative/src/rename-keys.ts | 3 +- packages/associative/src/select-keys.ts | 3 +- packages/associative/src/sorted-map.ts | 16 +- packages/associative/src/sorted-set.ts | 6 +- packages/associative/src/utils.ts | 2 +- packages/associative/test/tsconfig.json | 3 +- packages/atom/package.json | 14 +- packages/atom/src/api.ts | 25 +- packages/atom/src/atom.ts | 14 +- packages/atom/src/cursor.ts | 8 +- packages/atom/src/history.ts | 12 +- packages/atom/test/atom.ts | 6 +- packages/atom/test/cursor.ts | 5 +- packages/atom/test/history.ts | 1 - packages/atom/test/tsconfig.json | 3 +- packages/atom/test/view.ts | 4 +- packages/bench/package.json | 14 +- packages/bench/test/tsconfig.json | 3 +- packages/binary/package.json | 14 +- packages/binary/test/tsconfig.json | 3 +- packages/bitstream/package.json | 17 +- packages/bitstream/test/index.ts | 2 +- packages/bitstream/test/tsconfig.json | 3 +- packages/cache/package.json | 17 +- packages/cache/src/api.ts | 2 +- packages/cache/src/lru.ts | 6 +- packages/cache/src/mru.ts | 1 - packages/cache/src/tlru.ts | 1 - packages/cache/test/tsconfig.json | 3 +- packages/checks/package.json | 12 +- packages/checks/test/tsconfig.json | 3 +- packages/compare/package.json | 17 +- packages/compare/test/tsconfig.json | 3 +- packages/compose/package.json | 19 +- packages/compose/src/comp.ts | 4 +- packages/compose/src/juxt.ts | 2 +- packages/compose/src/partial.ts | 2 +- packages/compose/src/thread-first.ts | 2 +- packages/compose/src/thread-last.ts | 2 +- packages/compose/test/tsconfig.json | 3 +- packages/csp/package.json | 15 +- packages/csp/src/api.ts | 3 +- packages/csp/src/buffer.ts | 4 +- packages/csp/src/channel.ts | 32 +- packages/csp/src/mult.ts | 5 +- packages/csp/src/pubsub.ts | 7 +- packages/csp/test/node.ts | 7 +- packages/csp/test/tsconfig.json | 3 +- packages/dcons/package.json | 17 +- packages/dcons/src/index.ts | 10 +- packages/dcons/test/tsconfig.json | 3 +- packages/defmulti/package.json | 17 +- packages/defmulti/src/index.ts | 11 +- packages/defmulti/test/tsconfig.json | 3 +- packages/dgraph/package.json | 17 +- packages/dgraph/src/index.ts | 11 +- packages/dgraph/test/tsconfig.json | 3 +- packages/diff/package.json | 22 +- packages/diff/src/api.ts | 2 +- packages/diff/src/object.ts | 2 +- packages/diff/test/tsconfig.json | 3 +- packages/dlogic/package.json | 17 +- packages/dlogic/test/tsconfig.json | 3 +- packages/dot/package.json | 17 +- packages/dot/src/api.ts | 2 +- packages/dot/src/serialize.ts | 5 +- packages/dot/test/tsconfig.json | 3 +- packages/dsp/package.json | 17 +- packages/dsp/src/api.ts | 3 +- packages/dsp/src/osc.ts | 11 +- packages/dsp/test/tsconfig.json | 3 +- packages/equiv/package.json | 14 +- packages/equiv/test/tsconfig.json | 3 +- packages/errors/package.json | 14 +- packages/errors/test/tsconfig.json | 3 +- packages/fsm/package.json | 17 +- packages/fsm/src/fsm.ts | 8 +- packages/fsm/test/tsconfig.json | 3 +- packages/geom-accel/package.json | 18 +- packages/geom-accel/src/kdtree.ts | 10 +- packages/geom-accel/test/tsconfig.json | 3 +- packages/geom/package.json | 18 +- packages/geom/src/api.ts | 10 +- packages/geom/src/arc2.ts | 29 +- packages/geom/src/bezier2.ts | 14 +- packages/geom/src/circle2.ts | 14 +- packages/geom/src/container2.ts | 3 +- packages/geom/src/container3.ts | 5 +- packages/geom/src/fit.ts | 3 +- packages/geom/src/index.ts | 3 - packages/geom/src/internal/arc-length.ts | 2 +- packages/geom/src/internal/area.ts | 2 +- packages/geom/src/internal/args.ts | 8 +- packages/geom/src/internal/barycentric.ts | 3 +- packages/geom/src/internal/bounds.ts | 2 +- packages/geom/src/internal/centroid.ts | 55 ++-- packages/geom/src/internal/circumcenter.ts | 4 +- packages/geom/src/internal/closest-point.ts | 2 +- packages/geom/src/internal/collate.ts | 14 +- packages/geom/src/internal/corner.ts | 5 +- .../internal/douglas\342\200\223peucker.ts" | 4 +- packages/geom/src/internal/edges.ts | 9 +- packages/geom/src/internal/eq-delta.ts | 19 +- packages/geom/src/internal/graham-scan.ts | 49 ++-- packages/geom/src/internal/liang-barsky.ts | 4 +- .../geom/src/internal/line-intersection.ts | 55 ++-- .../geom/src/internal/sutherland-hodgeman.ts | 53 ++-- packages/geom/src/line2.ts | 12 +- packages/geom/src/path2.ts | 18 +- packages/geom/src/polygon2.ts | 30 +- packages/geom/src/polyline2.ts | 10 +- packages/geom/src/quad2.ts | 3 +- packages/geom/src/rect2.ts | 7 +- packages/geom/src/sampler.ts | 4 +- packages/geom/src/subdiv-curve.ts | 18 +- packages/geom/src/tessellate.ts | 33 ++- packages/geom/src/triangle2.ts | 11 +- packages/geom/src/warp.ts | 23 +- packages/geom/test/circle2.ts | 4 +- packages/geom/test/tsconfig.json | 3 +- packages/heaps/package.json | 17 +- packages/heaps/src/api.ts | 2 +- packages/heaps/src/dheap.ts | 2 +- packages/heaps/src/heap.ts | 2 +- packages/heaps/test/tsconfig.json | 3 +- packages/hiccup-carbon-icons/package.json | 27 +- .../hiccup-carbon-icons/test/tsconfig.json | 3 +- packages/hiccup-css/package.json | 17 +- packages/hiccup-css/src/api.ts | 2 +- packages/hiccup-css/src/conditional.ts | 3 +- packages/hiccup-css/src/css.ts | 12 +- packages/hiccup-css/src/impl.ts | 32 +- packages/hiccup-css/test/tsconfig.json | 3 +- packages/hiccup-markdown/package.json | 17 +- packages/hiccup-markdown/src/parse.ts | 22 +- packages/hiccup-markdown/src/serialize.ts | 17 +- packages/hiccup-markdown/test/tsconfig.json | 3 +- packages/hiccup-svg/package.json | 21 +- packages/hiccup-svg/src/circle.ts | 15 +- packages/hiccup-svg/src/convert.ts | 277 +++++++++--------- packages/hiccup-svg/src/defs.ts | 5 +- packages/hiccup-svg/src/format.ts | 12 +- packages/hiccup-svg/src/gradients.ts | 36 +-- packages/hiccup-svg/src/group.ts | 5 +- packages/hiccup-svg/src/image.ts | 15 +- packages/hiccup-svg/src/line.ts | 27 +- packages/hiccup-svg/src/path.ts | 63 ++-- packages/hiccup-svg/src/points.ts | 43 +-- packages/hiccup-svg/src/polygon.ts | 5 +- packages/hiccup-svg/src/polyline.ts | 5 +- packages/hiccup-svg/src/rect.ts | 5 +- packages/hiccup-svg/src/svg.ts | 17 +- packages/hiccup-svg/src/text.ts | 13 +- packages/hiccup-svg/test/tsconfig.json | 3 +- packages/hiccup/package.json | 17 +- packages/hiccup/src/css.ts | 2 +- packages/hiccup/src/deref.ts | 2 +- packages/hiccup/src/serialize.ts | 14 +- packages/hiccup/test/tsconfig.json | 3 +- packages/iges/package.json | 17 +- packages/iges/src/index.ts | 24 +- packages/iges/test/tsconfig.json | 3 +- packages/interceptors/package.json | 17 +- packages/interceptors/src/api.ts | 2 +- packages/interceptors/src/event-bus.ts | 18 +- packages/interceptors/src/interceptors.ts | 1 - packages/interceptors/test/tsconfig.json | 3 +- packages/intervals/package.json | 17 +- packages/intervals/src/index.ts | 10 +- packages/intervals/test/tsconfig.json | 3 +- packages/iterators/package.json | 17 +- packages/iterators/src/dedupe-with.ts | 3 +- packages/iterators/src/drop-while.ts | 3 +- packages/iterators/src/ensure.ts | 3 +- packages/iterators/src/every.ts | 3 +- packages/iterators/src/filter.ts | 3 +- packages/iterators/src/fork.ts | 1 - packages/iterators/src/interleave.ts | 3 +- packages/iterators/src/partition.ts | 3 +- packages/iterators/src/some.ts | 3 +- packages/iterators/src/take-while.ts | 3 +- packages/iterators/src/walk.ts | 2 +- packages/iterators/test/tsconfig.json | 3 +- packages/malloc/package.json | 17 +- packages/malloc/src/index.ts | 6 +- packages/malloc/test/tsconfig.json | 3 +- packages/math/package.json | 17 +- packages/math/test/tsconfig.json | 3 +- packages/memoize/package.json | 17 +- packages/memoize/src/defonce.ts | 2 +- packages/memoize/src/memoizej.ts | 2 +- packages/memoize/test/tsconfig.json | 3 +- packages/morton/package.json | 17 +- packages/morton/src/index.ts | 8 +- packages/morton/test/tsconfig.json | 3 +- packages/paths/package.json | 14 +- packages/paths/src/index.ts | 4 +- packages/paths/test/tsconfig.json | 3 +- packages/pointfree-lang/package.json | 23 +- packages/pointfree-lang/src/index.ts | 5 +- packages/pointfree-lang/test/tsconfig.json | 3 +- packages/pointfree/package.json | 17 +- packages/pointfree/src/index.ts | 12 +- packages/pointfree/test/tsconfig.json | 3 +- packages/random/package.json | 17 +- packages/random/src/api.ts | 2 +- packages/random/src/smush32.ts | 2 +- packages/random/src/xorshift128.ts | 2 +- packages/random/src/xorwow.ts | 2 +- packages/random/src/xsadd.ts | 2 +- packages/random/test/tsconfig.json | 3 +- packages/range-coder/package.json | 17 +- packages/range-coder/test/index.ts | 6 +- packages/range-coder/test/tsconfig.json | 3 +- packages/resolve-map/package.json | 19 +- packages/resolve-map/src/index.ts | 14 +- packages/resolve-map/test/tsconfig.json | 3 +- packages/rle-pack/package.json | 23 +- packages/rle-pack/src/index.ts | 2 +- packages/rle-pack/test/tsconfig.json | 3 +- packages/router/package.json | 23 +- packages/router/src/api.ts | 2 +- packages/router/src/basic.ts | 12 +- packages/router/src/history.ts | 3 +- packages/router/test/tsconfig.json | 3 +- packages/sax/package.json | 17 +- packages/sax/src/index.ts | 3 +- packages/sax/test/tsconfig.json | 3 +- packages/strings/package.json | 32 +- packages/strings/src/center.ts | 2 +- packages/strings/src/float.ts | 2 +- packages/strings/src/format.ts | 31 +- packages/strings/src/pad-left.ts | 2 +- packages/strings/src/pad-right.ts | 2 +- packages/strings/src/parse.ts | 18 +- packages/strings/src/percent.ts | 5 +- packages/strings/src/radix.ts | 3 +- packages/strings/src/repeat.ts | 2 +- packages/strings/src/splice.ts | 37 +-- packages/strings/src/truncate-left.ts | 3 +- packages/strings/src/truncate.ts | 3 +- packages/strings/src/units.ts | 3 +- packages/strings/src/wrap.ts | 3 +- packages/strings/test/tsconfig.json | 3 +- packages/transducers-fsm/package.json | 17 +- packages/transducers-fsm/src/index.ts | 14 +- packages/transducers-fsm/test/tsconfig.json | 3 +- packages/transducers-hdom/test/tsconfig.json | 3 +- packages/transducers-stats/package.json | 18 +- packages/transducers-stats/src/bollinger.ts | 17 +- packages/transducers-stats/src/donchian.ts | 13 +- packages/transducers-stats/src/ema.ts | 11 +- packages/transducers-stats/src/hma.ts | 15 +- packages/transducers-stats/src/macd.ts | 12 +- packages/transducers-stats/src/momentum.ts | 11 +- packages/transducers-stats/src/roc.ts | 11 +- packages/transducers-stats/src/rsi.ts | 15 +- packages/transducers-stats/src/sd.ts | 17 +- packages/transducers-stats/src/sma.ts | 11 +- packages/transducers-stats/src/stochastic.ts | 12 +- packages/transducers-stats/src/trix.ts | 5 +- packages/transducers-stats/src/wma.ts | 17 +- packages/transducers-stats/test/tsconfig.json | 3 +- packages/transducers/package.json | 20 +- packages/transducers/src/api.ts | 2 +- .../transducers/src/func/binary-search.ts | 2 +- packages/transducers/src/func/comp.ts | 3 +- .../transducers/src/func/deep-transform.ts | 3 +- packages/transducers/src/func/ensure-array.ts | 3 +- .../transducers/src/func/ensure-iterable.ts | 2 +- packages/transducers/src/func/even.ts | 2 +- packages/transducers/src/func/fuzzy-match.ts | 2 +- packages/transducers/src/func/hex.ts | 3 +- packages/transducers/src/func/juxt.ts | 2 +- packages/transducers/src/func/odd.ts | 2 +- packages/transducers/src/func/renamer.ts | 2 +- packages/transducers/src/iter/pairs.ts | 2 +- packages/transducers/src/iter/permutations.ts | 2 +- packages/transducers/src/iter/range2d.ts | 3 +- packages/transducers/src/iter/range3d.ts | 3 +- packages/transducers/src/iter/vals.ts | 2 +- packages/transducers/src/iter/wrap.ts | 2 +- packages/transducers/src/iterator.ts | 4 +- packages/transducers/src/reduce.ts | 7 +- packages/transducers/src/reduced.ts | 2 +- packages/transducers/src/rfn/assoc-map.ts | 5 +- packages/transducers/src/rfn/assoc-obj.ts | 3 +- packages/transducers/src/rfn/every.ts | 3 +- packages/transducers/src/rfn/fill.ts | 5 +- packages/transducers/src/rfn/frequencies.ts | 3 +- packages/transducers/src/rfn/group-binary.ts | 3 +- packages/transducers/src/rfn/group-by-obj.ts | 5 +- packages/transducers/src/rfn/max-compare.ts | 3 +- packages/transducers/src/rfn/min-compare.ts | 3 +- packages/transducers/src/rfn/some.ts | 3 +- packages/transducers/src/transduce.ts | 3 +- packages/transducers/src/xform/convolve.ts | 3 +- packages/transducers/src/xform/dedupe.ts | 3 +- packages/transducers/src/xform/drop-while.ts | 3 +- .../transducers/src/xform/filter-fuzzy.ts | 3 +- packages/transducers/src/xform/hex-dump.ts | 3 +- packages/transducers/src/xform/labeled.ts | 3 +- packages/transducers/src/xform/map-keys.ts | 3 +- packages/transducers/src/xform/map-nth.ts | 3 +- packages/transducers/src/xform/map-vals.ts | 3 +- packages/transducers/src/xform/map.ts | 3 +- packages/transducers/src/xform/mapcat.ts | 3 +- .../transducers/src/xform/moving-average.ts | 3 +- .../transducers/src/xform/multiplex-obj.ts | 3 +- .../transducers/src/xform/partition-by.ts | 3 +- .../transducers/src/xform/partition-sync.ts | 5 +- packages/transducers/src/xform/rename.ts | 5 +- packages/transducers/src/xform/struct.ts | 3 +- packages/transducers/src/xform/take-while.ts | 3 +- packages/transducers/src/xform/throttle.ts | 3 +- packages/transducers/test/partition-bits.ts | 2 +- packages/transducers/test/tsconfig.json | 3 +- packages/unionstruct/package.json | 18 +- packages/unionstruct/src/index.ts | 145 +++++---- packages/unionstruct/test/tsconfig.json | 3 +- packages/vectors/package.json | 17 +- packages/vectors/src/api.ts | 8 +- packages/vectors/src/codegen.ts | 18 +- packages/vectors/src/common.ts | 3 +- packages/vectors/src/gvec.ts | 20 +- packages/vectors/src/mat23.ts | 6 +- packages/vectors/src/mat33.ts | 6 +- packages/vectors/src/mat44.ts | 6 +- packages/vectors/src/vec2.ts | 22 +- packages/vectors/src/vec3.ts | 20 +- packages/vectors/src/vec4.ts | 18 +- packages/vectors/test/tsconfig.json | 3 +- 344 files changed, 1862 insertions(+), 1595 deletions(-) diff --git a/packages/associative/package.json b/packages/associative/package.json index 72fa50cebc..240c201b25 100644 --- a/packages/associative/package.json +++ b/packages/associative/package.json @@ -2,7 +2,9 @@ "name": "@thi.ng/associative", "version": "0.6.23", "description": "Alternative Set & Map data type implementations with customizable equality semantics & supporting operations", - "main": "./index.js", + "module": "./index.js", + "main": "./lib/index.js", + "umd:main": "./lib/index.umd.js", "typings": "./index.d.ts", "repository": { "type": "git", @@ -12,12 +14,14 @@ "author": "Karsten Schmidt ", "license": "Apache-2.0", "scripts": { - "build": "yarn clean && tsc --declaration", - "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc", + "build": "yarn clean && yarn build:es6 && yarn build:bundle", + "build:es6": "tsc --declaration", + "build:bundle": "../../scripts/bundle-module associative api checks compare dcons equiv errors transducers", + "test": "rimraf build && tsc -p test/tsconfig.json && nyc mocha build/test/*.js", + "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc lib", "cover": "yarn test && nyc report --reporter=lcov", "doc": "node_modules/.bin/typedoc --mode modules --out doc src", - "pub": "yarn build && yarn publish --access public", - "test": "rimraf build && tsc -p test && nyc mocha build/test/*.js" + "pub": "yarn build && yarn publish --access public" }, "devDependencies": { "@types/mocha": "^5.2.5", @@ -53,5 +57,6 @@ ], "publishConfig": { "access": "public" - } + }, + "sideEffects": false } \ No newline at end of file diff --git a/packages/associative/src/api.ts b/packages/associative/src/api.ts index bcb6d9c5cf..3b92d71fcf 100644 --- a/packages/associative/src/api.ts +++ b/packages/associative/src/api.ts @@ -4,7 +4,7 @@ import { IEmpty, IEquiv, Predicate2 -} from "@thi.ng/api/api"; +} from "@thi.ng/api"; export interface IEquivSet extends Set, diff --git a/packages/associative/src/array-set.ts b/packages/associative/src/array-set.ts index f6da3eeddf..3e4098fd53 100644 --- a/packages/associative/src/array-set.ts +++ b/packages/associative/src/array-set.ts @@ -1,4 +1,4 @@ -import { Pair, Predicate2, SEMAPHORE } from "@thi.ng/api/api"; +import { Pair, Predicate2, SEMAPHORE } from "@thi.ng/api"; import { equiv } from "@thi.ng/equiv"; import { EquivSetOpts, IEquivSet } from "./api"; diff --git a/packages/associative/src/common-keys.ts b/packages/associative/src/common-keys.ts index bb647f358d..ce5b8962dc 100644 --- a/packages/associative/src/common-keys.ts +++ b/packages/associative/src/common-keys.ts @@ -1,4 +1,4 @@ -import { IObjectOf } from "@thi.ng/api/api"; +import { IObjectOf } from "@thi.ng/api"; /** * Like `commonKeysObj()`, but for ES6 Maps. diff --git a/packages/associative/src/equiv-map.ts b/packages/associative/src/equiv-map.ts index e66f961a9b..883f7ac8c8 100644 --- a/packages/associative/src/equiv-map.ts +++ b/packages/associative/src/equiv-map.ts @@ -5,9 +5,8 @@ import { IObjectOf, Pair, SEMAPHORE -} from "@thi.ng/api/api"; +} from "@thi.ng/api"; import { equiv } from "@thi.ng/equiv"; - import { EquivMapOpts, IEquivSet } from "./api"; import { ArraySet } from "./array-set"; diff --git a/packages/associative/src/invert.ts b/packages/associative/src/invert.ts index 2429da833e..88eac4c0dd 100644 --- a/packages/associative/src/invert.ts +++ b/packages/associative/src/invert.ts @@ -1,5 +1,4 @@ -import { IObjectOf } from "@thi.ng/api/api"; - +import { IObjectOf } from "@thi.ng/api"; import { empty } from "./utils"; /** diff --git a/packages/associative/src/join.ts b/packages/associative/src/join.ts index e3c2421759..040c825fb1 100644 --- a/packages/associative/src/join.ts +++ b/packages/associative/src/join.ts @@ -1,5 +1,4 @@ -import { IObjectOf } from "@thi.ng/api/api"; - +import { IObjectOf } from "@thi.ng/api"; import { commonKeysObj } from "./common-keys"; import { indexed } from "./indexed"; import { invertObj } from "./invert"; diff --git a/packages/associative/src/ll-set.ts b/packages/associative/src/ll-set.ts index b537782cd6..23fa0542f4 100644 --- a/packages/associative/src/ll-set.ts +++ b/packages/associative/src/ll-set.ts @@ -1,7 +1,6 @@ -import { Pair, Predicate2, SEMAPHORE } from "@thi.ng/api/api"; +import { Pair, Predicate2, SEMAPHORE } from "@thi.ng/api"; import { DCons } from "@thi.ng/dcons"; import { equiv } from "@thi.ng/equiv"; - import { EquivSetOpts, IEquivSet } from "./api"; interface SetProps { diff --git a/packages/associative/src/merge-apply.ts b/packages/associative/src/merge-apply.ts index 4947a2d9c5..4f9c77c8be 100644 --- a/packages/associative/src/merge-apply.ts +++ b/packages/associative/src/merge-apply.ts @@ -1,6 +1,5 @@ -import { IObjectOf } from "@thi.ng/api/api"; -import { isFunction } from "@thi.ng/checks/is-function"; - +import { IObjectOf } from "@thi.ng/api"; +import { isFunction } from "@thi.ng/checks"; import { copy } from "./utils"; /** diff --git a/packages/associative/src/merge-deep.ts b/packages/associative/src/merge-deep.ts index 11e41b6b97..577a8f0e8e 100644 --- a/packages/associative/src/merge-deep.ts +++ b/packages/associative/src/merge-deep.ts @@ -1,6 +1,5 @@ -import { IObjectOf } from "@thi.ng/api/api"; -import { isPlainObject } from "@thi.ng/checks/is-plain-object"; - +import { IObjectOf } from "@thi.ng/api"; +import { isPlainObject } from "@thi.ng/checks"; import { mergeObjWith } from "./merge-with"; export const mergeDeepObj = diff --git a/packages/associative/src/merge-with.ts b/packages/associative/src/merge-with.ts index 64f79b80ed..2f3adb9fd3 100644 --- a/packages/associative/src/merge-with.ts +++ b/packages/associative/src/merge-with.ts @@ -1,5 +1,4 @@ -import { IObjectOf } from "@thi.ng/api/api"; - +import { IObjectOf } from "@thi.ng/api"; import { copy } from "./utils"; export const mergeMapWith = ( diff --git a/packages/associative/src/merge.ts b/packages/associative/src/merge.ts index da901fa7f0..3ddea8e7d3 100644 --- a/packages/associative/src/merge.ts +++ b/packages/associative/src/merge.ts @@ -1,4 +1,4 @@ -import { IObjectOf } from "@thi.ng/api/api"; +import { IObjectOf } from "@thi.ng/api"; /** * Merges all given maps in left-to-right order into `dest`. diff --git a/packages/associative/src/rename-keys.ts b/packages/associative/src/rename-keys.ts index af06d7e462..5dbf167e55 100644 --- a/packages/associative/src/rename-keys.ts +++ b/packages/associative/src/rename-keys.ts @@ -1,5 +1,4 @@ -import { IObjectOf } from "@thi.ng/api/api"; - +import { IObjectOf } from "@thi.ng/api"; import { empty } from "./utils"; /** diff --git a/packages/associative/src/select-keys.ts b/packages/associative/src/select-keys.ts index 9307b4e6e8..9494862568 100644 --- a/packages/associative/src/select-keys.ts +++ b/packages/associative/src/select-keys.ts @@ -1,5 +1,4 @@ -import { IObjectOf } from "@thi.ng/api/api"; - +import { IObjectOf } from "@thi.ng/api"; import { empty } from "./utils"; /** diff --git a/packages/associative/src/sorted-map.ts b/packages/associative/src/sorted-map.ts index 49b7763a8c..465d43e8d6 100644 --- a/packages/associative/src/sorted-map.ts +++ b/packages/associative/src/sorted-map.ts @@ -8,15 +8,17 @@ import { Pair, Predicate2, SEMAPHORE -} from "@thi.ng/api/api"; -import { isArray } from "@thi.ng/checks/is-array"; +} from "@thi.ng/api"; +import { isArray } from "@thi.ng/checks"; import { compare } from "@thi.ng/compare"; import { equiv } from "@thi.ng/equiv"; -import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; -import { IReducible, ReductionFn } from "@thi.ng/transducers/api"; -import { isReduced } from "@thi.ng/transducers/reduced"; -import { map } from "@thi.ng/transducers/xform/map"; - +import { illegalArgs } from "@thi.ng/errors"; +import { + IReducible, + isReduced, + map, + ReductionFn +} from "@thi.ng/transducers"; import { SortedMapOpts } from "./api"; // stores private properties for all instances diff --git a/packages/associative/src/sorted-set.ts b/packages/associative/src/sorted-set.ts index 10f2ba080b..657426c76e 100644 --- a/packages/associative/src/sorted-set.ts +++ b/packages/associative/src/sorted-set.ts @@ -1,10 +1,8 @@ -import { ICompare, Pair, } from "@thi.ng/api/api"; import { compare } from "@thi.ng/compare"; -import { IReducible, ReductionFn } from "@thi.ng/transducers/api"; -import { map } from "@thi.ng/transducers/xform/map"; - +import { IReducible, map, ReductionFn } from "@thi.ng/transducers"; import { IEquivSet, SortedSetOpts } from "./api"; import { SortedMap } from "./sorted-map"; +import { ICompare, Pair, } from "@thi.ng/api"; const __private = new WeakMap, SortedMap>(); diff --git a/packages/associative/src/utils.ts b/packages/associative/src/utils.ts index 7082e43c53..51da602328 100644 --- a/packages/associative/src/utils.ts +++ b/packages/associative/src/utils.ts @@ -1,4 +1,4 @@ -import { implementsFunction } from "@thi.ng/checks/implements-function"; +import { implementsFunction } from "@thi.ng/checks"; export const empty = (x, ctor) => implementsFunction(x, "empty") ? x.empty() : new (x[Symbol.species] || ctor)(); diff --git a/packages/associative/test/tsconfig.json b/packages/associative/test/tsconfig.json index c93bb84899..2c9c12a650 100644 --- a/packages/associative/test/tsconfig.json +++ b/packages/associative/test/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../../tsconfig.json", "compilerOptions": { "outDir": "../build", - "module": "es6", - "target": "es6" + "module": "commonjs", }, "include": [ "./**/*.ts", diff --git a/packages/atom/package.json b/packages/atom/package.json index 307e8b6c87..5b0e55f4ee 100644 --- a/packages/atom/package.json +++ b/packages/atom/package.json @@ -4,6 +4,7 @@ "description": "Mutable wrappers for nested immutable values w/ optional undo/redo history", "module": "./index.js", "main": "./lib/index.js", + "umd:main": "./lib/index.umd.js", "typings": "./index.d.ts", "repository": { "type": "git", @@ -13,13 +14,11 @@ "author": "Karsten Schmidt ", "license": "Apache-2.0", "scripts": { - "build": "yarn clean && yarn build:es6 && yarn build:parcel && yarn build:parcel:min", + "build": "yarn clean && yarn build:es6 && yarn build:bundle", "build:es6": "tsc --declaration", - "build:parcel:min": "parcel build --global thing_atom -o index.min.js -d lib --experimental-scope-hoisting src/index.ts", - "build:parcel": "parcel build --global thing_atom -d lib --no-minify --experimental-scope-hoisting src/index.ts && prettier --write lib/index.js", - "build:gzip": "gzip -c lib/index.min.js > lib/index.min.js.gz", - "clean": "rimraf *.js *.d.ts .cache .nyc_output build coverage doc lib", - "test": "rimraf build && parcel build -d build --no-cache --no-minify --no-source-maps test/index.ts && nyc mocha build/index.js", + "build:bundle": "../../scripts/bundle-module atom api checks equiv errors paths", + "test": "rimraf build && tsc -p test/tsconfig.json && nyc mocha build/test/*.js", + "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc lib", "cover": "yarn test && nyc report --reporter=lcov", "doc": "typedoc --mode modules --out doc src", "pub": "yarn build && yarn publish --access public" @@ -59,5 +58,6 @@ "browser": { "process": false, "setTimeout": false - } + }, + "sideEffects": false } \ No newline at end of file diff --git a/packages/atom/src/api.ts b/packages/atom/src/api.ts index 2f64fc85a1..68ed2ca515 100644 --- a/packages/atom/src/api.ts +++ b/packages/atom/src/api.ts @@ -1,4 +1,11 @@ -import * as api from "@thi.ng/api/api"; +import { + IDeref, + IID, + INotify, + IRelease, + IWatch, + Predicate +} from "@thi.ng/api"; import { Path } from "@thi.ng/paths"; export type SwapFn = (curr: T, ...args: any[]) => T; @@ -6,9 +13,9 @@ export type SwapFn = (curr: T, ...args: any[]) => T; export type ViewTransform = (x: any) => T; export interface ReadonlyAtom extends - api.IDeref, - api.IRelease, - api.IWatch, + IDeref, + IRelease, + IWatch, IViewable { } @@ -29,9 +36,9 @@ export interface ISwap { } export interface IView extends - api.IDeref, - api.IID, - api.IRelease { + IDeref, + IID, + IRelease { readonly path: PropertyKey[]; readonly value: T; @@ -47,13 +54,13 @@ export interface IViewable { export interface CursorOpts { parent: IAtom; path: Path | [(s: any) => T, (s: any, v: T) => any]; - validate?: api.Predicate; + validate?: Predicate; id?: string; } export interface IHistory extends IAtom, - api.INotify { + INotify { canUndo(): boolean; canRedo(): boolean; diff --git a/packages/atom/src/atom.ts b/packages/atom/src/atom.ts index 2f9bdd0886..3aaebf8749 100644 --- a/packages/atom/src/atom.ts +++ b/packages/atom/src/atom.ts @@ -1,8 +1,11 @@ -import { IEquiv, Predicate, Watch } from "@thi.ng/api/api"; -import { IWatch } from "@thi.ng/api/mixins/iwatch"; -import { illegalState } from "@thi.ng/errors/illegal-state"; +import { + IEquiv, + IWatchMixin, + Predicate, + Watch +} from "@thi.ng/api"; +import { illegalState } from "@thi.ng/errors"; import { Path, setIn, updateIn } from "@thi.ng/paths"; - import { IAtom, IView, @@ -11,11 +14,12 @@ import { } from "./api"; import { View } from "./view"; + /** * Mutable wrapper for an (usually) immutable value. Support for * watches. */ -@IWatch +@IWatchMixin export class Atom implements IAtom, IEquiv { diff --git a/packages/atom/src/cursor.ts b/packages/atom/src/cursor.ts index 713be975ad..23f249272d 100644 --- a/packages/atom/src/cursor.ts +++ b/packages/atom/src/cursor.ts @@ -1,8 +1,6 @@ -import { IID, IRelease, Watch } from "@thi.ng/api/api"; -import { isArray } from "@thi.ng/checks/is-array"; -import { isFunction } from "@thi.ng/checks/is-function"; -import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; -import { illegalArity } from "@thi.ng/errors/illegal-arity"; +import { IID, IRelease, Watch } from "@thi.ng/api"; +import { isArray, isFunction } from "@thi.ng/checks"; +import { illegalArgs, illegalArity } from "@thi.ng/errors"; import { getter, Path, setter } from "@thi.ng/paths"; import { CursorOpts, diff --git a/packages/atom/src/history.ts b/packages/atom/src/history.ts index 9f04b70f4b..3b806945b3 100644 --- a/packages/atom/src/history.ts +++ b/packages/atom/src/history.ts @@ -1,5 +1,9 @@ -import { Event, Predicate2, Watch } from "@thi.ng/api/api"; -import * as mixin from "@thi.ng/api/mixins/inotify"; +import { + Event, + INotifyMixin, + Predicate2, + Watch +} from "@thi.ng/api"; import { equiv } from "@thi.ng/equiv"; import { getIn, @@ -7,7 +11,6 @@ import { setIn, updateIn } from "@thi.ng/paths"; - import { IAtom, IHistory, @@ -17,6 +20,7 @@ import { } from "./api"; import { View } from "./view"; + /** * Undo/redo history stack wrapper for atoms and cursors. Implements * `IAtom` interface and so can be used directly in place and delegates @@ -26,7 +30,7 @@ import { View } from "./view"; * `INotify` interface to support event listeners for `undo()`, `redo()` * and `record()`. */ -@mixin.INotify +@INotifyMixin export class History implements IHistory { diff --git a/packages/atom/test/atom.ts b/packages/atom/test/atom.ts index 86350ad5c6..c81ff901bb 100644 --- a/packages/atom/test/atom.ts +++ b/packages/atom/test/atom.ts @@ -1,6 +1,6 @@ +import { isNumber } from "@thi.ng/checks"; import * as assert from "assert"; import { Atom } from "../src/index"; -import { isNumber } from "@thi.ng/checks/is-number"; describe("atom", function () { @@ -51,7 +51,7 @@ describe("atom", function () { assert.equal(a.reset(2), 2); assert.equal(a.reset("3"), 2); assert.equal(a.reset(null), 2); - assert.equal(a.swap((x) => "3"), 2); - assert.equal(a.swap((x) => null), 2); + assert.equal(a.swap(() => "3"), 2); + assert.equal(a.swap(() => null), 2); }); }); diff --git a/packages/atom/test/cursor.ts b/packages/atom/test/cursor.ts index 348bd479a1..bd168fbada 100644 --- a/packages/atom/test/cursor.ts +++ b/packages/atom/test/cursor.ts @@ -1,8 +1,7 @@ -import * as assert from "assert"; +import { isNumber } from "@thi.ng/checks"; import { getIn } from "@thi.ng/paths"; - +import * as assert from "assert"; import { Atom, Cursor } from "../src/index"; -import { isNumber } from "@thi.ng/checks/is-number"; describe("cursor", function () { diff --git a/packages/atom/test/history.ts b/packages/atom/test/history.ts index 6b0445693e..20a7e49732 100644 --- a/packages/atom/test/history.ts +++ b/packages/atom/test/history.ts @@ -1,5 +1,4 @@ import * as assert from "assert"; - import { Atom } from "../src/atom"; import { Cursor } from "../src/cursor"; import { History } from "../src/history"; diff --git a/packages/atom/test/tsconfig.json b/packages/atom/test/tsconfig.json index c93bb84899..2c9c12a650 100644 --- a/packages/atom/test/tsconfig.json +++ b/packages/atom/test/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../../tsconfig.json", "compilerOptions": { "outDir": "../build", - "module": "es6", - "target": "es6" + "module": "commonjs", }, "include": [ "./**/*.ts", diff --git a/packages/atom/test/view.ts b/packages/atom/test/view.ts index 5eeaf7e38e..c755ec7017 100644 --- a/packages/atom/test/view.ts +++ b/packages/atom/test/view.ts @@ -1,7 +1,5 @@ -import * as assert from "assert"; - import { setIn, updateIn } from "@thi.ng/paths"; - +import * as assert from "assert"; import { IView } from "../src/api"; import { Atom } from "../src/atom"; import { Cursor } from "../src/cursor"; diff --git a/packages/bench/package.json b/packages/bench/package.json index b30ab6a162..66cf9cbf82 100644 --- a/packages/bench/package.json +++ b/packages/bench/package.json @@ -4,6 +4,7 @@ "description": "Basic benchmarking helpers", "module": "./index.js", "main": "./lib/index.js", + "umd:main": "./lib/index.umd.js", "typings": "./index.d.ts", "repository": { "type": "git", @@ -13,13 +14,11 @@ "author": "Karsten Schmidt ", "license": "Apache-2.0", "scripts": { - "build": "yarn clean && yarn build:es6 && yarn build:parcel && yarn build:parcel:min", + "build": "yarn clean && yarn build:es6 && yarn build:bundle", "build:es6": "tsc --declaration", - "build:parcel:min": "parcel build --global thing_bench -o index.min.js -d lib --experimental-scope-hoisting src/index.ts", - "build:parcel": "parcel build --global thing_bench -d lib --no-minify --experimental-scope-hoisting src/index.ts && prettier --write lib/index.js", - "build:gzip": "gzip -c lib/index.min.js > lib/index.min.js.gz", - "clean": "rimraf *.js *.d.ts .cache .nyc_output build coverage doc lib", - "test": "rimraf build && parcel build -d build --no-cache --no-minify --no-source-maps test/index.ts && nyc mocha build/index.js", + "build:bundle": "../../scripts/bundle-module bench", + "test": "rimraf build && tsc -p test/tsconfig.json && nyc mocha build/test/*.js", + "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc lib", "cover": "yarn test && nyc report --reporter=lcov", "doc": "node_modules/.bin/typedoc --mode modules --out doc src", "pub": "yarn build && yarn publish --access public" @@ -50,5 +49,6 @@ "browser": { "process": false, "setTimeout": false - } + }, + "sideEffects": false } \ No newline at end of file diff --git a/packages/bench/test/tsconfig.json b/packages/bench/test/tsconfig.json index c93bb84899..2c9c12a650 100644 --- a/packages/bench/test/tsconfig.json +++ b/packages/bench/test/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../../tsconfig.json", "compilerOptions": { "outDir": "../build", - "module": "es6", - "target": "es6" + "module": "commonjs", }, "include": [ "./**/*.ts", diff --git a/packages/binary/package.json b/packages/binary/package.json index 9c4c6e2e38..1dce3e0718 100644 --- a/packages/binary/package.json +++ b/packages/binary/package.json @@ -4,6 +4,7 @@ "description": "Assorted binary / bitwise operations, conversions, utilities.", "module": "./index.js", "main": "./lib/index.js", + "umd:main": "./lib/index.umd.js", "typings": "./index.d.ts", "repository": { "type": "git", @@ -13,13 +14,11 @@ "author": "Karsten Schmidt ", "license": "Apache-2.0", "scripts": { - "build": "yarn clean && yarn build:es6 && yarn build:parcel && yarn build:parcel:min", + "build": "yarn clean && yarn build:es6 && yarn build:bundle", "build:es6": "tsc --declaration", - "build:parcel:min": "parcel build --global thing_binary -o index.min.js -d lib --experimental-scope-hoisting src/index.ts", - "build:parcel": "parcel build --global thing_binary -d lib --no-minify --experimental-scope-hoisting src/index.ts && prettier --write lib/index.js", - "build:gzip": "gzip -c lib/index.min.js > lib/index.min.js.gz", - "clean": "rimraf *.js *.d.ts .cache .nyc_output build coverage doc lib", - "test": "rimraf build && parcel build -d build --no-cache --no-minify --no-source-maps test/index.ts && nyc mocha build/index.js", + "build:bundle": "../../scripts/bundle-module binary", + "test": "rimraf build && tsc -p test/tsconfig.json && nyc mocha build/test/*.js", + "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc lib", "cover": "yarn test && nyc report --reporter=lcov", "doc": "node_modules/.bin/typedoc --mode modules --out doc src", "pub": "yarn build && yarn publish --access public" @@ -47,5 +46,6 @@ ], "publishConfig": { "access": "public" - } + }, + "sideEffects": false } \ No newline at end of file diff --git a/packages/binary/test/tsconfig.json b/packages/binary/test/tsconfig.json index c93bb84899..2c9c12a650 100644 --- a/packages/binary/test/tsconfig.json +++ b/packages/binary/test/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../../tsconfig.json", "compilerOptions": { "outDir": "../build", - "module": "es6", - "target": "es6" + "module": "commonjs", }, "include": [ "./**/*.ts", diff --git a/packages/bitstream/package.json b/packages/bitstream/package.json index 2477e45577..99ba9fd229 100644 --- a/packages/bitstream/package.json +++ b/packages/bitstream/package.json @@ -2,7 +2,9 @@ "name": "@thi.ng/bitstream", "version": "0.4.21", "description": "ES6 iterator based read/write bit streams & support for variable word widths", - "main": "./index.js", + "module": "./index.js", + "main": "./lib/index.js", + "umd:main": "./lib/index.umd.js", "typings": "./index.d.ts", "repository": { "type": "git", @@ -12,12 +14,14 @@ "author": "Karsten Schmidt ", "license": "Apache-2.0", "scripts": { - "build": "yarn clean && tsc --declaration", - "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc", + "build": "yarn clean && yarn build:es6 && yarn build:bundle", + "build:es6": "tsc --declaration", + "build:bundle": "../../scripts/bundle-module bitstream errors", + "test": "rimraf build && tsc -p test/tsconfig.json && nyc mocha build/test/*.js", + "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc lib", "cover": "yarn test && nyc report --reporter=lcov", "doc": "node_modules/.bin/typedoc --mode modules --out doc src", - "pub": "yarn build && yarn publish --access public", - "test": "rimraf build && tsc -p test && nyc mocha build/test/*.js" + "pub": "yarn build && yarn publish --access public" }, "dependencies": { "@thi.ng/errors": "^0.1.12" @@ -41,5 +45,6 @@ ], "publishConfig": { "access": "public" - } + }, + "sideEffects": false } \ No newline at end of file diff --git a/packages/bitstream/test/index.ts b/packages/bitstream/test/index.ts index 34f9102512..da632c1d66 100644 --- a/packages/bitstream/test/index.ts +++ b/packages/bitstream/test/index.ts @@ -1,5 +1,5 @@ -import * as bits from "../src/index"; import * as assert from "assert"; +import * as bits from "../src/index"; describe("BitInputStream", function () { let src = new Uint8Array([0xbe, 0xef, 0xde, 0xca, 0xfb, 0xad, 0xf0, 0x0b, 0xaa]); diff --git a/packages/bitstream/test/tsconfig.json b/packages/bitstream/test/tsconfig.json index c93bb84899..2c9c12a650 100644 --- a/packages/bitstream/test/tsconfig.json +++ b/packages/bitstream/test/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../../tsconfig.json", "compilerOptions": { "outDir": "../build", - "module": "es6", - "target": "es6" + "module": "commonjs", }, "include": [ "./**/*.ts", diff --git a/packages/cache/package.json b/packages/cache/package.json index 9195bf1efe..fcbd6c3d34 100644 --- a/packages/cache/package.json +++ b/packages/cache/package.json @@ -2,7 +2,9 @@ "name": "@thi.ng/cache", "version": "0.2.40", "description": "In-memory cache implementations with ES6 Map-like API and different eviction strategies", - "main": "./index.js", + "module": "./index.js", + "main": "./lib/index.js", + "umd:main": "./lib/index.umd.js", "typings": "./index.d.ts", "repository": { "type": "git", @@ -12,12 +14,14 @@ "author": "Karsten Schmidt ", "license": "Apache-2.0", "scripts": { - "build": "yarn clean && tsc --declaration", - "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc", + "build": "yarn clean && yarn build:es6 && yarn build:bundle", + "build:es6": "tsc --declaration", + "build:bundle": "../../scripts/bundle-module cache api dcons transducers", + "test": "rimraf build && tsc -p test/tsconfig.json && nyc mocha build/test/*.js", + "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc lib", "cover": "yarn test && nyc report --reporter=lcov", "doc": "node_modules/.bin/typedoc --mode modules --out doc src", - "pub": "yarn build && yarn publish --access public", - "test": "rimraf build && tsc -p test && nyc mocha build/test/*.js" + "pub": "yarn build && yarn publish --access public" }, "devDependencies": { "@types/mocha": "^5.2.5", @@ -45,5 +49,6 @@ ], "publishConfig": { "access": "public" - } + }, + "sideEffects": false } \ No newline at end of file diff --git a/packages/cache/src/api.ts b/packages/cache/src/api.ts index 442a225f3f..537a8b95c9 100644 --- a/packages/cache/src/api.ts +++ b/packages/cache/src/api.ts @@ -3,7 +3,7 @@ import { IEmpty, ILength, IRelease -} from "@thi.ng/api/api"; +} from "@thi.ng/api"; export interface ICache extends Iterable]>>, diff --git a/packages/cache/src/lru.ts b/packages/cache/src/lru.ts index 8c9d18026a..82fa66cd75 100644 --- a/packages/cache/src/lru.ts +++ b/packages/cache/src/lru.ts @@ -1,9 +1,9 @@ import { ConsCell, DCons } from "@thi.ng/dcons"; -import { map } from "@thi.ng/transducers/xform/map"; - +import { map } from "@thi.ng/transducers"; import { CacheEntry, CacheOpts, ICache } from "./api"; -export class LRUCache implements ICache { +export class LRUCache implements + ICache { protected map: Map>>; protected items: DCons>; diff --git a/packages/cache/src/mru.ts b/packages/cache/src/mru.ts index ae8e3632b0..8131202fd6 100644 --- a/packages/cache/src/mru.ts +++ b/packages/cache/src/mru.ts @@ -1,5 +1,4 @@ import { ConsCell } from "@thi.ng/dcons"; - import { CacheEntry, CacheOpts } from "./api"; import { LRUCache } from "./lru"; diff --git a/packages/cache/src/tlru.ts b/packages/cache/src/tlru.ts index 4d0e2f71b9..4090bd396b 100644 --- a/packages/cache/src/tlru.ts +++ b/packages/cache/src/tlru.ts @@ -1,5 +1,4 @@ import { ConsCell, DCons } from "@thi.ng/dcons"; - import { CacheEntry, CacheOpts } from "./api"; import { LRUCache } from "./lru"; diff --git a/packages/cache/test/tsconfig.json b/packages/cache/test/tsconfig.json index c93bb84899..2c9c12a650 100644 --- a/packages/cache/test/tsconfig.json +++ b/packages/cache/test/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../../tsconfig.json", "compilerOptions": { "outDir": "../build", - "module": "es6", - "target": "es6" + "module": "commonjs", }, "include": [ "./**/*.ts", diff --git a/packages/checks/package.json b/packages/checks/package.json index 0212ffb531..691204453a 100644 --- a/packages/checks/package.json +++ b/packages/checks/package.json @@ -4,6 +4,7 @@ "description": "Single-function sub-modules for type, feature & value checks", "module": "./index.js", "main": "./lib/index.js", + "umd:main": "./lib/index.umd.js", "typings": "./index.d.ts", "repository": { "type": "git", @@ -13,12 +14,10 @@ "author": "Karsten Schmidt ", "license": "Apache-2.0", "scripts": { - "build": "yarn clean && yarn build:es6 && yarn build:parcel && yarn build:parcel:min", + "build": "yarn clean && yarn build:es6 && yarn build:bundle", "build:es6": "tsc --declaration", - "build:parcel:min": "parcel build --global thing_checks -o index.min.js -d lib --experimental-scope-hoisting src/index.ts", - "build:parcel": "parcel build --global thing_checks -d lib --no-minify --experimental-scope-hoisting src/index.ts && prettier --write lib/index.js", - "build:gzip": "gzip -c lib/index.min.js > lib/index.min.js.gz", - "test": "rimraf build && parcel build -d build --no-cache --no-minify --no-source-maps test/index.ts && nyc mocha build/index.js", + "build:bundle": "../../scripts/bundle-module checks", + "test": "rimraf build && tsc -p test/tsconfig.json && nyc mocha build/test/*.js", "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc lib", "cover": "yarn test && nyc report --reporter=lcov", "doc": "node_modules/.bin/typedoc --mode modules --out doc src", @@ -51,5 +50,6 @@ "browser": { "process": false, "setTimeout": false - } + }, + "sideEffects": false } \ No newline at end of file diff --git a/packages/checks/test/tsconfig.json b/packages/checks/test/tsconfig.json index c93bb84899..2c9c12a650 100644 --- a/packages/checks/test/tsconfig.json +++ b/packages/checks/test/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../../tsconfig.json", "compilerOptions": { "outDir": "../build", - "module": "es6", - "target": "es6" + "module": "commonjs", }, "include": [ "./**/*.ts", diff --git a/packages/compare/package.json b/packages/compare/package.json index a923750465..981f7a6b36 100644 --- a/packages/compare/package.json +++ b/packages/compare/package.json @@ -2,7 +2,9 @@ "name": "@thi.ng/compare", "version": "0.1.12", "description": "Comparator with optional delegation for types implementing @thi.ng/api/ICompare interface", - "main": "./index.js", + "module": "./index.js", + "main": "./lib/index.js", + "umd:main": "./lib/index.umd.js", "typings": "./index.d.ts", "repository": { "type": "git", @@ -12,12 +14,14 @@ "author": "Karsten Schmidt ", "license": "Apache-2.0", "scripts": { - "build": "yarn clean && tsc --declaration", - "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc", + "build": "yarn clean && yarn build:es6 && yarn build:bundle", + "build:es6": "tsc --declaration", + "build:bundle": "../../scripts/bundle-module compare", + "test": "rimraf build && tsc -p test/tsconfig.json && nyc mocha build/test/*.js", + "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc lib", "cover": "yarn test && nyc report --reporter=lcov", "doc": "node_modules/.bin/typedoc --mode modules --out doc src", - "pub": "yarn build && yarn publish --access public", - "test": "rimraf build && tsc -p test && nyc mocha build/test/*.js" + "pub": "yarn build && yarn publish --access public" }, "devDependencies": { "@types/mocha": "^5.2.5", @@ -34,5 +38,6 @@ ], "publishConfig": { "access": "public" - } + }, + "sideEffects": false } \ No newline at end of file diff --git a/packages/compare/test/tsconfig.json b/packages/compare/test/tsconfig.json index c93bb84899..2c9c12a650 100644 --- a/packages/compare/test/tsconfig.json +++ b/packages/compare/test/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../../tsconfig.json", "compilerOptions": { "outDir": "../build", - "module": "es6", - "target": "es6" + "module": "commonjs", }, "include": [ "./**/*.ts", diff --git a/packages/compose/package.json b/packages/compose/package.json index 42320ef003..a81361a813 100644 --- a/packages/compose/package.json +++ b/packages/compose/package.json @@ -1,8 +1,10 @@ { "name": "@thi.ng/compose", "version": "0.3.0", - "description": "Functional composition helpers", - "main": "./index.js", + "description": "Arity-optimized functional composition helpers", + "module": "./index.js", + "main": "./lib/index.js", + "umd:main": "./lib/index.umd.js", "typings": "./index.d.ts", "repository": { "type": "git", @@ -12,12 +14,14 @@ "author": "Karsten Schmidt ", "license": "Apache-2.0", "scripts": { - "build": "yarn clean && tsc --declaration", - "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc", + "build": "yarn clean && yarn build:es6 && yarn build:bundle", + "build:es6": "tsc --declaration", + "build:bundle": "../../scripts/bundle-module compose api errors", + "test": "rimraf build && tsc -p test/tsconfig.json && nyc mocha build/test/*.js", + "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc lib", "cover": "yarn test && nyc report --reporter=lcov", "doc": "node_modules/.bin/typedoc --mode modules --out doc src", - "pub": "yarn build && yarn publish --access public", - "test": "rimraf build && tsc -p test && nyc mocha build/test/*.js" + "pub": "yarn build && yarn publish --access public" }, "devDependencies": { "@types/mocha": "^5.2.5", @@ -39,5 +43,6 @@ ], "publishConfig": { "access": "public" - } + }, + "sideEffects": false } \ No newline at end of file diff --git a/packages/compose/src/comp.ts b/packages/compose/src/comp.ts index bbd0a4f12a..26903fbfd3 100644 --- a/packages/compose/src/comp.ts +++ b/packages/compose/src/comp.ts @@ -1,5 +1,5 @@ -import { Fn, FnAny } from "@thi.ng/api/api"; -import { illegalArity } from "@thi.ng/errors/illegal-arity"; +import { Fn, FnAny } from "@thi.ng/api"; +import { illegalArity } from "@thi.ng/errors"; /** * Returns the right-to-left composition of given functions. I.e. when diff --git a/packages/compose/src/juxt.ts b/packages/compose/src/juxt.ts index 9c0113be54..4064f77b1c 100644 --- a/packages/compose/src/juxt.ts +++ b/packages/compose/src/juxt.ts @@ -1,4 +1,4 @@ -import { Fn } from "@thi.ng/api/api"; +import { Fn } from "@thi.ng/api"; export function juxt(a: Fn): Fn; export function juxt(a: Fn, b: Fn): Fn; diff --git a/packages/compose/src/partial.ts b/packages/compose/src/partial.ts index d8ba1c883d..b8bd0e82bd 100644 --- a/packages/compose/src/partial.ts +++ b/packages/compose/src/partial.ts @@ -1,4 +1,4 @@ -import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; +import { illegalArgs } from "@thi.ng/errors"; export function partial(fn: (a: A, ...args: any[]) => T, a: A): (...args: any[]) => T; export function partial(fn: (a: A, b: B, ...args: any[]) => T, a: A, b: B): (...args: any[]) => T; diff --git a/packages/compose/src/thread-first.ts b/packages/compose/src/thread-first.ts index 9b268b93c5..a4fad7a5c8 100644 --- a/packages/compose/src/thread-first.ts +++ b/packages/compose/src/thread-first.ts @@ -1,4 +1,4 @@ -import { FnAny } from "@thi.ng/api/api"; +import { FnAny } from "@thi.ng/api"; /** * Takes an `init` value and a number of functions and/or function diff --git a/packages/compose/src/thread-last.ts b/packages/compose/src/thread-last.ts index e06ff76ac6..24a511445a 100644 --- a/packages/compose/src/thread-last.ts +++ b/packages/compose/src/thread-last.ts @@ -1,4 +1,4 @@ -import { FnAny } from "@thi.ng/api/api"; +import { FnAny } from "@thi.ng/api"; /** * Takes an `init` value and a number of functions and/or function diff --git a/packages/compose/test/tsconfig.json b/packages/compose/test/tsconfig.json index c93bb84899..2c9c12a650 100644 --- a/packages/compose/test/tsconfig.json +++ b/packages/compose/test/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../../tsconfig.json", "compilerOptions": { "outDir": "../build", - "module": "es6", - "target": "es6" + "module": "commonjs", }, "include": [ "./**/*.ts", diff --git a/packages/csp/package.json b/packages/csp/package.json index cac40b2aac..ab3b139512 100644 --- a/packages/csp/package.json +++ b/packages/csp/package.json @@ -2,7 +2,9 @@ "name": "@thi.ng/csp", "version": "0.3.79", "description": "ES6 promise based CSP implementation", - "main": "./index.js", + "module": "./index.js", + "main": "./lib/index.js", + "umd:main": "./lib/index.umd.js", "typings": "./index.d.ts", "repository": { "type": "git", @@ -12,12 +14,14 @@ "author": "Karsten Schmidt ", "license": "Apache-2.0", "scripts": { - "build": "yarn clean && tsc --declaration", - "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc utils", + "build": "yarn clean && yarn build:es6 && yarn build:bundle", + "build:es6": "tsc --declaration", + "build:bundle": "../../scripts/bundle-module csp api checks dcons errors transducers", + "test": "rimraf build && tsc -p test/tsconfig.json && nyc mocha build/test/*.js", + "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc lib", "cover": "yarn test && nyc report --reporter=lcov", "doc": "node_modules/.bin/typedoc --mode modules --out doc src", "pub": "yarn build && yarn publish --access public", - "test": "rimraf build && tsc -p test && nyc mocha build/test/index.js", "testasync": "tsc -p test && node build/test/async.js", "testfile": "tsc -p test && node build/test/file.js", "testgraph": "tsc -p test && node build/test/graph.js", @@ -53,5 +57,6 @@ ], "publishConfig": { "access": "public" - } + }, + "sideEffects": false } \ No newline at end of file diff --git a/packages/csp/src/api.ts b/packages/csp/src/api.ts index 12326397bc..adff2752be 100644 --- a/packages/csp/src/api.ts +++ b/packages/csp/src/api.ts @@ -1,5 +1,4 @@ -import { IID, ILength, IRelease } from "@thi.ng/api/api"; - +import { IID, ILength, IRelease } from "@thi.ng/api"; import { Channel } from "./channel"; export const enum State { diff --git a/packages/csp/src/buffer.ts b/packages/csp/src/buffer.ts index 98cc936b26..0162e55234 100644 --- a/packages/csp/src/buffer.ts +++ b/packages/csp/src/buffer.ts @@ -1,8 +1,8 @@ import { DCons } from "@thi.ng/dcons"; - import { ChannelItem, IBuffer } from "./api"; -export class FixedBuffer implements IBuffer { +export class FixedBuffer implements + IBuffer { buf: DCons>; limit: number; diff --git a/packages/csp/src/channel.ts b/packages/csp/src/channel.ts index 9b8e48bea4..1b82f0f929 100644 --- a/packages/csp/src/channel.ts +++ b/packages/csp/src/channel.ts @@ -1,13 +1,16 @@ -import { Predicate } from "@thi.ng/api/api"; -import { illegalArity } from "@thi.ng/errors/illegal-arity"; -import { isFunction } from "@thi.ng/checks/is-function"; +import { Predicate } from "@thi.ng/api"; +import { isFunction } from "@thi.ng/checks"; import { DCons } from "@thi.ng/dcons"; -import { Reducer, Transducer } from "@thi.ng/transducers/api"; -import { cycle } from "@thi.ng/transducers/iter/cycle"; -import { range } from "@thi.ng/transducers/iter/range"; -import { isReduced, unreduced } from "@thi.ng/transducers/reduced"; -import { delayed } from "@thi.ng/transducers/xform/delayed"; - +import { illegalArity } from "@thi.ng/errors"; +import { + cycle, + delayed, + isReduced, + range, + Reducer, + Transducer, + unreduced +} from "@thi.ng/transducers"; import { ChannelItem, ErrorHandler, @@ -561,10 +564,9 @@ export class Channel implements } } -function defaultErrorHandler(e: Error, chan: Channel, val?: any) { - console.log(chan.id, "error occurred", e.message, (val !== undefined ? val : "")); -} +const defaultErrorHandler = + (e: Error, chan: Channel, val?: any) => + console.log(chan.id, "error occurred", e.message, (val !== undefined ? val : "")); -function maybeBuffer(x) { - return x instanceof FixedBuffer || typeof x === "number"; -} +const maybeBuffer = (x) => + x instanceof FixedBuffer || typeof x === "number"; diff --git a/packages/csp/src/mult.ts b/packages/csp/src/mult.ts index a5d09addb7..3907574af6 100644 --- a/packages/csp/src/mult.ts +++ b/packages/csp/src/mult.ts @@ -1,7 +1,6 @@ -import { illegalArity } from "@thi.ng/errors/illegal-arity"; import { DCons } from "@thi.ng/dcons"; -import { Transducer } from "@thi.ng/transducers/api"; - +import { illegalArity } from "@thi.ng/errors"; +import { Transducer } from "@thi.ng/transducers"; import { IWriteableChannel } from "./api"; import { Channel } from "./channel"; diff --git a/packages/csp/src/pubsub.ts b/packages/csp/src/pubsub.ts index 56820e6163..a0f33c9815 100644 --- a/packages/csp/src/pubsub.ts +++ b/packages/csp/src/pubsub.ts @@ -1,7 +1,6 @@ -import { IObjectOf } from "@thi.ng/api/api"; -import { illegalArity } from "@thi.ng/errors/illegal-arity"; -import { Transducer } from "@thi.ng/transducers/api"; - +import { IObjectOf } from "@thi.ng/api"; +import { illegalArity } from "@thi.ng/errors"; +import { Transducer } from "@thi.ng/transducers"; import { IWriteableChannel, TopicFn } from "./api"; import { Channel } from "./channel"; import { Mult } from "./mult"; diff --git a/packages/csp/test/node.ts b/packages/csp/test/node.ts index 4af2ecdeba..af20a74836 100644 --- a/packages/csp/test/node.ts +++ b/packages/csp/test/node.ts @@ -1,11 +1,10 @@ -import { IEnable, IID, IObjectOf } from "@thi.ng/api/api"; -import { implementsFunction } from "@thi.ng/checks/implements-function"; -// import { DCons } from "@thi.ng/dcons"; +import { IEnable, IID, IObjectOf } from "@thi.ng/api"; +import { implementsFunction } from "@thi.ng/checks"; import * as tx from "@thi.ng/transducers"; - import { IBuffer, IWriteableChannel } from "../src/api"; import { Channel } from "../src/channel"; import { Mult } from "../src/mult"; +// import { DCons } from "@thi.ng/dcons"; export type NodeInput = NodeInputSpec | Channel | Mult | tx.Transducer; export type NodeOutput = NodeOutputSpec | IWriteableChannel; diff --git a/packages/csp/test/tsconfig.json b/packages/csp/test/tsconfig.json index c93bb84899..2c9c12a650 100644 --- a/packages/csp/test/tsconfig.json +++ b/packages/csp/test/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../../tsconfig.json", "compilerOptions": { "outDir": "../build", - "module": "es6", - "target": "es6" + "module": "commonjs", }, "include": [ "./**/*.ts", diff --git a/packages/dcons/package.json b/packages/dcons/package.json index 3f0c731a4a..3695f10345 100644 --- a/packages/dcons/package.json +++ b/packages/dcons/package.json @@ -2,7 +2,9 @@ "name": "@thi.ng/dcons", "version": "1.1.23", "description": "Comprehensive doubly linked list structure w/ iterator support", - "main": "./index.js", + "module": "./index.js", + "main": "./lib/index.js", + "umd:main": "./lib/index.umd.js", "typings": "./index.d.ts", "repository": { "type": "git", @@ -12,12 +14,14 @@ "author": "Karsten Schmidt ", "license": "Apache-2.0", "scripts": { - "build": "yarn clean && tsc --declaration", - "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc", + "build": "yarn clean && yarn build:es6 && yarn build:bundle", + "build:es6": "tsc --declaration", + "build:bundle": "../../scripts/bundle-module dcons api checks compare equiv errors transducers", + "test": "rimraf build && tsc -p test/tsconfig.json && nyc mocha build/test/*.js", + "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc lib", "cover": "yarn test && nyc report --reporter=lcov", "doc": "node_modules/.bin/typedoc --mode modules --out doc src", - "pub": "yarn build && yarn publish --access public", - "test": "rimraf build && tsc -p test && nyc mocha build/test/*.js" + "pub": "yarn build && yarn publish --access public" }, "devDependencies": { "@types/mocha": "^5.2.5", @@ -48,5 +52,6 @@ ], "publishConfig": { "access": "public" - } + }, + "sideEffects": false } \ No newline at end of file diff --git a/packages/dcons/src/index.ts b/packages/dcons/src/index.ts index 97686dbd57..a861aae749 100644 --- a/packages/dcons/src/index.ts +++ b/packages/dcons/src/index.ts @@ -8,14 +8,12 @@ import { IRelease, IStack, Predicate -} from "@thi.ng/api/api"; -import { isArrayLike } from "@thi.ng/checks/is-arraylike"; +} from "@thi.ng/api"; +import { isArrayLike } from "@thi.ng/checks"; import { compare } from "@thi.ng/compare"; import { equiv } from "@thi.ng/equiv"; -import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; -import { illegalState } from "@thi.ng/errors/illegal-state"; -import { IReducible, ReductionFn } from "@thi.ng/transducers/api"; -import { isReduced } from "@thi.ng/transducers/reduced"; +import { illegalArgs, illegalState } from "@thi.ng/errors"; +import { IReducible, isReduced, ReductionFn } from "@thi.ng/transducers"; export interface ConsCell { value: T; diff --git a/packages/dcons/test/tsconfig.json b/packages/dcons/test/tsconfig.json index c93bb84899..2c9c12a650 100644 --- a/packages/dcons/test/tsconfig.json +++ b/packages/dcons/test/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../../tsconfig.json", "compilerOptions": { "outDir": "../build", - "module": "es6", - "target": "es6" + "module": "commonjs", }, "include": [ "./**/*.ts", diff --git a/packages/defmulti/package.json b/packages/defmulti/package.json index af2fe4b369..eddf10edd7 100644 --- a/packages/defmulti/package.json +++ b/packages/defmulti/package.json @@ -2,7 +2,9 @@ "name": "@thi.ng/defmulti", "version": "0.7.0", "description": "Dynamically extensible multiple dispatch via user supplied dispatch function.", - "main": "./index.js", + "module": "./index.js", + "main": "./lib/index.js", + "umd:main": "./lib/index.umd.js", "typings": "./index.d.ts", "repository": { "type": "git", @@ -12,12 +14,14 @@ "author": "Karsten Schmidt ", "license": "Apache-2.0", "scripts": { - "build": "yarn clean && tsc --declaration", - "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc", + "build": "yarn clean && yarn build:es6 && yarn build:bundle", + "build:es6": "tsc --declaration", + "build:bundle": "../../scripts/bundle-module defmulti api errors", + "test": "rimraf build && tsc -p test/tsconfig.json && nyc mocha build/test/*.js", + "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc lib", "cover": "yarn test && nyc report --reporter=lcov", "doc": "node_modules/.bin/typedoc --mode modules --out doc src", - "pub": "yarn build && yarn publish --access public", - "test": "rimraf build && tsc -p test && nyc mocha build/test/*.js" + "pub": "yarn build && yarn publish --access public" }, "devDependencies": { "@types/mocha": "^5.2.5", @@ -37,5 +41,6 @@ ], "publishConfig": { "access": "public" - } + }, + "sideEffects": false } \ No newline at end of file diff --git a/packages/defmulti/src/index.ts b/packages/defmulti/src/index.ts index 202714b8f7..d7e1ed664e 100644 --- a/packages/defmulti/src/index.ts +++ b/packages/defmulti/src/index.ts @@ -1,6 +1,5 @@ -import { IObjectOf } from "@thi.ng/api/api"; -import { unsupported } from "@thi.ng/errors/unsupported"; -import { illegalArity } from "@thi.ng/errors/illegal-arity"; +import { IObjectOf } from "@thi.ng/api"; +import { illegalArity, unsupported } from "@thi.ng/errors"; export const DEFAULT: unique symbol = Symbol(); @@ -247,14 +246,14 @@ const makeRels = (spec: AncestorDefs) => { * @param impls * @param fallback */ -export function defmultiN( +export const defmultiN = ( impls: { [id: number]: Implementation }, fallback?: Implementation -) { +) => { const fn = defmulti((...args: any[]) => args.length); fn.add(DEFAULT, fallback || ((...args) => illegalArity(args.length))); for (let id in impls) { fn.add(id, impls[id]); } return fn; -} +}; diff --git a/packages/defmulti/test/tsconfig.json b/packages/defmulti/test/tsconfig.json index c93bb84899..2c9c12a650 100644 --- a/packages/defmulti/test/tsconfig.json +++ b/packages/defmulti/test/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../../tsconfig.json", "compilerOptions": { "outDir": "../build", - "module": "es6", - "target": "es6" + "module": "commonjs", }, "include": [ "./**/*.ts", diff --git a/packages/dgraph/package.json b/packages/dgraph/package.json index b7b121df78..d03047aa40 100644 --- a/packages/dgraph/package.json +++ b/packages/dgraph/package.json @@ -2,7 +2,9 @@ "name": "@thi.ng/dgraph", "version": "0.2.35", "description": "Type-agnostic directed acyclic graph (DAG) & graph operations", - "main": "./index.js", + "module": "./index.js", + "main": "./lib/index.js", + "umd:main": "./lib/index.umd.js", "typings": "./index.d.ts", "repository": { "type": "git", @@ -12,12 +14,14 @@ "author": "Karsten Schmidt ", "license": "Apache-2.0", "scripts": { - "build": "yarn clean && tsc --declaration", - "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc", + "build": "yarn clean && yarn build:es6 && yarn build:bundle", + "build:es6": "tsc --declaration", + "build:bundle": "../../scripts/bundle-module dgraph api associative equiv errors transducers", + "test": "rimraf build && tsc -p test/tsconfig.json && nyc mocha build/test/*.js", + "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc lib", "cover": "yarn test && nyc report --reporter=lcov", "doc": "node_modules/.bin/typedoc --mode modules --out doc src", - "pub": "yarn build && yarn publish --access public", - "test": "rimraf build && tsc -p test && nyc mocha build/test/*.js" + "pub": "yarn build && yarn publish --access public" }, "devDependencies": { "@types/mocha": "^5.2.5", @@ -44,5 +48,6 @@ ], "publishConfig": { "access": "public" - } + }, + "sideEffects": false } \ No newline at end of file diff --git a/packages/dgraph/src/index.ts b/packages/dgraph/src/index.ts index 369b8725e2..3db28c2f7c 100644 --- a/packages/dgraph/src/index.ts +++ b/packages/dgraph/src/index.ts @@ -1,11 +1,8 @@ -import { ICopy } from "@thi.ng/api/api"; -import { EquivMap } from "@thi.ng/associative/equiv-map"; -import { LLSet } from "@thi.ng/associative/ll-set"; -import { union } from "@thi.ng/associative/union"; +import { ICopy } from "@thi.ng/api"; +import { EquivMap, LLSet, union } from "@thi.ng/associative"; import { equiv } from "@thi.ng/equiv"; -import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; -import { reduce, reducer } from "@thi.ng/transducers/reduce"; -import { filter } from "@thi.ng/transducers/xform/filter"; +import { illegalArgs } from "@thi.ng/errors"; +import { filter, reduce, reducer } from "@thi.ng/transducers"; export class DGraph implements Iterable, diff --git a/packages/dgraph/test/tsconfig.json b/packages/dgraph/test/tsconfig.json index c93bb84899..2c9c12a650 100644 --- a/packages/dgraph/test/tsconfig.json +++ b/packages/dgraph/test/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../../tsconfig.json", "compilerOptions": { "outDir": "../build", - "module": "es6", - "target": "es6" + "module": "commonjs", }, "include": [ "./**/*.ts", diff --git a/packages/diff/package.json b/packages/diff/package.json index 05f660152c..bbe005f914 100644 --- a/packages/diff/package.json +++ b/packages/diff/package.json @@ -2,7 +2,9 @@ "name": "@thi.ng/diff", "version": "2.0.2", "description": "Array & object Diff", - "main": "./index.js", + "module": "./index.js", + "main": "./lib/index.js", + "umd:main": "./lib/index.umd.js", "typings": "./index.d.ts", "repository": { "type": "git", @@ -12,11 +14,14 @@ "author": "Karsten Schmidt ", "license": "Apache-2.0", "scripts": { - "build": "yarn clean && tsc --declaration", - "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc", + "build": "yarn clean && yarn build:es6 && yarn build:bundle", + "build:es6": "tsc --declaration", + "build:bundle": "../../scripts/bundle-module diff api equiv", + "test": "rimraf build && tsc -p test/tsconfig.json && nyc mocha build/test/*.js", + "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc lib", + "cover": "yarn test && nyc report --reporter=lcov", "doc": "node_modules/.bin/typedoc --mode modules --out doc src", - "pub": "yarn build && yarn publish --access public", - "test": "rimraf build && tsc -p test && mocha build/test/*.js" + "pub": "yarn build && yarn publish --access public" }, "devDependencies": { "@types/mocha": "^5.2.5", @@ -30,14 +35,17 @@ "@thi.ng/equiv": "^0.1.15" }, "keywords": [ + "additions", "array", "diff", - "edit", + "edits", "ES6", "nested", + "removals", "typescript" ], "publishConfig": { "access": "public" - } + }, + "sideEffects": false } \ No newline at end of file diff --git a/packages/diff/src/api.ts b/packages/diff/src/api.ts index b23f67e1ee..c5100c21d1 100644 --- a/packages/diff/src/api.ts +++ b/packages/diff/src/api.ts @@ -1,4 +1,4 @@ -import { IObjectOf } from "@thi.ng/api/api"; +import { IObjectOf } from "@thi.ng/api"; export type DiffKeyMap = IObjectOf; diff --git a/packages/diff/src/object.ts b/packages/diff/src/object.ts index a1f7c04319..26bc6990f3 100644 --- a/packages/diff/src/object.ts +++ b/packages/diff/src/object.ts @@ -1,4 +1,4 @@ -import { IObjectOf, Predicate2 } from "@thi.ng/api/api"; +import { IObjectOf, Predicate2 } from "@thi.ng/api"; import { equiv } from "@thi.ng/equiv"; import { DiffMode, ObjectDiff } from "./api"; diff --git a/packages/diff/test/tsconfig.json b/packages/diff/test/tsconfig.json index c93bb84899..2c9c12a650 100644 --- a/packages/diff/test/tsconfig.json +++ b/packages/diff/test/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../../tsconfig.json", "compilerOptions": { "outDir": "../build", - "module": "es6", - "target": "es6" + "module": "commonjs", }, "include": [ "./**/*.ts", diff --git a/packages/dlogic/package.json b/packages/dlogic/package.json index 626923e384..ea427b895b 100644 --- a/packages/dlogic/package.json +++ b/packages/dlogic/package.json @@ -2,7 +2,9 @@ "name": "@thi.ng/dlogic", "version": "0.1.2", "description": "Assorted digital logic ops / constructs.", - "main": "./index.js", + "module": "./index.js", + "main": "./lib/index.js", + "umd:main": "./lib/index.umd.js", "typings": "./index.d.ts", "repository": { "type": "git", @@ -12,12 +14,14 @@ "author": "Karsten Schmidt ", "license": "Apache-2.0", "scripts": { - "build": "yarn clean && tsc --declaration", - "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc", + "build": "yarn clean && yarn build:es6 && yarn build:bundle", + "build:es6": "tsc --declaration", + "build:bundle": "../../scripts/bundle-module dlogic", + "test": "rimraf build && tsc -p test/tsconfig.json && nyc mocha build/test/*.js", + "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc lib", "cover": "yarn test && nyc report --reporter=lcov", "doc": "node_modules/.bin/typedoc --mode modules --out doc src", - "pub": "yarn build && yarn publish --access public", - "test": "rimraf build && tsc -p test && nyc mocha build/test/*.js" + "pub": "yarn build && yarn publish --access public" }, "devDependencies": { "@types/mocha": "^5.2.5", @@ -39,5 +43,6 @@ ], "publishConfig": { "access": "public" - } + }, + "sideEffects": false } \ No newline at end of file diff --git a/packages/dlogic/test/tsconfig.json b/packages/dlogic/test/tsconfig.json index c93bb84899..2c9c12a650 100644 --- a/packages/dlogic/test/tsconfig.json +++ b/packages/dlogic/test/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../../tsconfig.json", "compilerOptions": { "outDir": "../build", - "module": "es6", - "target": "es6" + "module": "commonjs", }, "include": [ "./**/*.ts", diff --git a/packages/dot/package.json b/packages/dot/package.json index 384f93f9ca..0696a6097f 100644 --- a/packages/dot/package.json +++ b/packages/dot/package.json @@ -2,7 +2,9 @@ "name": "@thi.ng/dot", "version": "0.1.18", "description": "Graphviz DOM abstraction as vanilla JS objects & serialization to DOT format", - "main": "./index.js", + "module": "./index.js", + "main": "./lib/index.js", + "umd:main": "./lib/index.umd.js", "typings": "./index.d.ts", "repository": { "type": "git", @@ -12,12 +14,14 @@ "author": "Karsten Schmidt ", "license": "Apache-2.0", "scripts": { - "build": "yarn clean && tsc --declaration", - "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc", + "build": "yarn clean && yarn build:es6 && yarn build:bundle", + "build:es6": "tsc --declaration", + "build:bundle": "../../scripts/bundle-module dot api checks", + "test": "rimraf build && tsc -p test/tsconfig.json && nyc mocha build/test/*.js", + "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc lib", "cover": "yarn test && nyc report --reporter=lcov", "doc": "node_modules/.bin/typedoc --mode modules --out doc src", - "pub": "yarn build && yarn publish --access public", - "test": "rimraf build && tsc -p test && nyc mocha build/test/*.js" + "pub": "yarn build && yarn publish --access public" }, "devDependencies": { "@types/mocha": "^5.2.5", @@ -37,5 +41,6 @@ ], "publishConfig": { "access": "public" - } + }, + "sideEffects": false } \ No newline at end of file diff --git a/packages/dot/src/api.ts b/packages/dot/src/api.ts index 3efffb6b0f..5cd087298d 100644 --- a/packages/dot/src/api.ts +++ b/packages/dot/src/api.ts @@ -1,4 +1,4 @@ -import { IObjectOf } from "@thi.ng/api/api"; +import { IObjectOf } from "@thi.ng/api"; export type NodeShape = "box" | diff --git a/packages/dot/src/serialize.ts b/packages/dot/src/serialize.ts index 48495c7804..93589dc65a 100644 --- a/packages/dot/src/serialize.ts +++ b/packages/dot/src/serialize.ts @@ -1,6 +1,5 @@ -import { IObjectOf } from "@thi.ng/api/api"; -import { isArray } from "@thi.ng/checks/is-array"; - +import { IObjectOf } from "@thi.ng/api"; +import { isArray } from "@thi.ng/checks"; import { Edge, Graph, diff --git a/packages/dot/test/tsconfig.json b/packages/dot/test/tsconfig.json index c93bb84899..2c9c12a650 100644 --- a/packages/dot/test/tsconfig.json +++ b/packages/dot/test/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../../tsconfig.json", "compilerOptions": { "outDir": "../build", - "module": "es6", - "target": "es6" + "module": "commonjs", }, "include": [ "./**/*.ts", diff --git a/packages/dsp/package.json b/packages/dsp/package.json index 6bd4ff6ad9..83d1da83ea 100644 --- a/packages/dsp/package.json +++ b/packages/dsp/package.json @@ -2,7 +2,9 @@ "name": "@thi.ng/dsp", "version": "0.1.3", "description": "Assorted DSP utils, oscillators etc.", - "main": "./index.js", + "module": "./index.js", + "main": "./lib/index.js", + "umd:main": "./lib/index.umd.js", "typings": "./index.d.ts", "repository": { "type": "git", @@ -12,12 +14,14 @@ "author": "Karsten Schmidt ", "license": "Apache-2.0", "scripts": { - "build": "yarn clean && tsc --declaration", - "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc", + "build": "yarn clean && yarn build:es6 && yarn build:bundle", + "build:es6": "tsc --declaration", + "build:bundle": "../../scripts/bundle-module dsp math", + "test": "rimraf build && tsc -p test/tsconfig.json && nyc mocha build/test/*.js", + "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc lib", "cover": "yarn test && nyc report --reporter=lcov", "doc": "node_modules/.bin/typedoc --mode modules --out doc src", - "pub": "yarn build && yarn publish --access public", - "test": "rimraf build && tsc -p test && nyc mocha build/test/*.js" + "pub": "yarn build && yarn publish --access public" }, "devDependencies": { "@types/mocha": "^5.2.5", @@ -44,5 +48,6 @@ ], "publishConfig": { "access": "public" - } + }, + "sideEffects": false } \ No newline at end of file diff --git a/packages/dsp/src/api.ts b/packages/dsp/src/api.ts index 99bd50b70f..c364d97acd 100644 --- a/packages/dsp/src/api.ts +++ b/packages/dsp/src/api.ts @@ -1 +1,2 @@ -export type StatelessOscillator = (phase: number, freq: number, amp?: number, dc?: number, opts?: any) => number; +export type StatelessOscillator = + (phase: number, freq: number, amp?: number, dc?: number, opts?: any) => number; diff --git a/packages/dsp/src/osc.ts b/packages/dsp/src/osc.ts index ce932921eb..f0fef27574 100644 --- a/packages/dsp/src/osc.ts +++ b/packages/dsp/src/osc.ts @@ -1,7 +1,10 @@ -import { HALF_PI, TAU } from "@thi.ng/math/api"; -import { mix as _mix } from "@thi.ng/math/mix"; -import { wrap01 } from "@thi.ng/math/interval"; -import { fract } from "@thi.ng/math/prec"; +import { + fract, + HALF_PI, + mix as _mix, + TAU, + wrap01 +} from "@thi.ng/math"; import { StatelessOscillator } from "./api"; export class Oscillator implements diff --git a/packages/dsp/test/tsconfig.json b/packages/dsp/test/tsconfig.json index c93bb84899..2c9c12a650 100644 --- a/packages/dsp/test/tsconfig.json +++ b/packages/dsp/test/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../../tsconfig.json", "compilerOptions": { "outDir": "../build", - "module": "es6", - "target": "es6" + "module": "commonjs", }, "include": [ "./**/*.ts", diff --git a/packages/equiv/package.json b/packages/equiv/package.json index d82579f5f5..a3cd21fe3e 100644 --- a/packages/equiv/package.json +++ b/packages/equiv/package.json @@ -4,6 +4,7 @@ "description": "Extensible deep equivalence checking for any data types", "module": "./index.js", "main": "./lib/index.js", + "umd:main": "./lib/index.umd.js", "typings": "./index.d.ts", "repository": { "type": "git", @@ -13,13 +14,11 @@ "author": "Karsten Schmidt ", "license": "Apache-2.0", "scripts": { - "build": "yarn clean && yarn build:es6 && yarn build:parcel && yarn build:parcel:min", + "build": "yarn clean && yarn build:es6 && yarn build:bundle", "build:es6": "tsc --declaration", - "build:parcel:min": "parcel build --global thing_equiv -o index.min.js -d lib --experimental-scope-hoisting src/index.ts", - "build:parcel": "parcel build --global thing_equiv -d lib --no-minify --experimental-scope-hoisting src/index.ts && prettier --write lib/index.js", - "build:gzip": "gzip -c lib/index.min.js > lib/index.min.js.gz", - "clean": "rimraf *.js *.d.ts .cache .nyc_output build coverage doc lib", - "test": "rimraf build && parcel build -d build --no-cache --no-minify --no-source-maps test/index.ts && nyc mocha build/index.js", + "build:bundle": "../../scripts/bundle-module equiv", + "test": "rimraf build && tsc -p test/tsconfig.json && nyc mocha build/test/*.js", + "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc lib", "cover": "yarn test && nyc report --reporter=lcov", "doc": "node_modules/.bin/typedoc --mode modules --out doc src", "pub": "yarn build && yarn publish --access public" @@ -52,5 +51,6 @@ "browser": { "process": false, "setTimeout": false - } + }, + "sideEffects": false } \ No newline at end of file diff --git a/packages/equiv/test/tsconfig.json b/packages/equiv/test/tsconfig.json index c93bb84899..2c9c12a650 100644 --- a/packages/equiv/test/tsconfig.json +++ b/packages/equiv/test/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../../tsconfig.json", "compilerOptions": { "outDir": "../build", - "module": "es6", - "target": "es6" + "module": "commonjs", }, "include": [ "./**/*.ts", diff --git a/packages/errors/package.json b/packages/errors/package.json index 50df7c0ab4..bc85cb9123 100644 --- a/packages/errors/package.json +++ b/packages/errors/package.json @@ -4,6 +4,7 @@ "description": "Custom error types and helper fns.", "module": "./index.js", "main": "./lib/index.js", + "umd:main": "./lib/index.umd.js", "typings": "./index.d.ts", "repository": { "type": "git", @@ -13,13 +14,11 @@ "author": "Karsten Schmidt ", "license": "Apache-2.0", "scripts": { - "build": "yarn clean && yarn build:es6 && yarn build:parcel && yarn build:parcel:min", + "build": "yarn clean && yarn build:es6 && yarn build:bundle", "build:es6": "tsc --declaration", - "build:parcel:min": "parcel build --global thing_errors -o index.min.js -d lib --experimental-scope-hoisting src/index.ts", - "build:parcel": "parcel build --global thing_errors -d lib --no-minify --experimental-scope-hoisting src/index.ts && prettier --write lib/index.js", - "build:gzip": "gzip -c lib/index.min.js > lib/index.min.js.gz", - "clean": "rimraf *.js *.d.ts .cache .nyc_output build coverage doc lib", - "test": "rimraf build && parcel build -d build --no-cache --no-minify --no-source-maps test/index.ts && nyc mocha build/index.js", + "build:bundle": "../../scripts/bundle-module errors", + "test": "rimraf build && tsc -p test/tsconfig.json && nyc mocha build/test/*.js", + "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc lib", "cover": "yarn test && nyc report --reporter=lcov", "doc": "node_modules/.bin/typedoc --mode modules --out doc src", "pub": "yarn build && yarn publish --access public" @@ -46,5 +45,6 @@ "browser": { "process": false, "setTimeout": false - } + }, + "sideEffects": false } \ No newline at end of file diff --git a/packages/errors/test/tsconfig.json b/packages/errors/test/tsconfig.json index c93bb84899..2c9c12a650 100644 --- a/packages/errors/test/tsconfig.json +++ b/packages/errors/test/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../../tsconfig.json", "compilerOptions": { "outDir": "../build", - "module": "es6", - "target": "es6" + "module": "commonjs", }, "include": [ "./**/*.ts", diff --git a/packages/fsm/package.json b/packages/fsm/package.json index da80319859..1d03346c8d 100644 --- a/packages/fsm/package.json +++ b/packages/fsm/package.json @@ -2,7 +2,9 @@ "name": "@thi.ng/fsm", "version": "0.1.0", "description": "Composable primitives for building declarative, transducer based Finite-State machines & parsers for arbitrary data streams", - "main": "./index.js", + "module": "./index.js", + "main": "./lib/index.js", + "umd:main": "./lib/index.umd.js", "typings": "./index.d.ts", "repository": { "type": "git", @@ -12,12 +14,14 @@ "author": "Karsten Schmidt ", "license": "Apache-2.0", "scripts": { - "build": "yarn clean && tsc --declaration", - "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc", + "build": "yarn clean && yarn build:es6 && yarn build:bundle", + "build:es6": "tsc --declaration", + "build:bundle": "../../scripts/bundle-module fsm api equiv errors transducers", + "test": "rimraf build && tsc -p test/tsconfig.json && nyc mocha build/test/*.js", + "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc lib", "cover": "yarn test && nyc report --reporter=lcov", "doc": "node_modules/.bin/typedoc --mode modules --out doc src", - "pub": "yarn build && yarn publish --access public", - "test": "rimraf build && tsc -p test && nyc mocha build/test/*.js" + "pub": "yarn build && yarn publish --access public" }, "devDependencies": { "@types/mocha": "^5.2.5", @@ -49,5 +53,6 @@ ], "publishConfig": { "access": "public" - } + }, + "sideEffects": false } \ No newline at end of file diff --git a/packages/fsm/src/fsm.ts b/packages/fsm/src/fsm.ts index 72a026b6bf..52133a1b45 100644 --- a/packages/fsm/src/fsm.ts +++ b/packages/fsm/src/fsm.ts @@ -1,13 +1,13 @@ import { IObjectOf } from "@thi.ng/api"; -import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; -import { illegalState } from "@thi.ng/errors/illegal-state"; -import { Reducer, Transducer } from "@thi.ng/transducers/api"; +import { illegalArgs, illegalState } from "@thi.ng/errors"; import { ensureReduced, isReduced, reduced, + Reducer, + Transducer, unreduced -} from "@thi.ng/transducers/reduced"; +} from "@thi.ng/transducers"; import { Match, Matcher } from "./api"; /** diff --git a/packages/fsm/test/tsconfig.json b/packages/fsm/test/tsconfig.json index c93bb84899..2c9c12a650 100644 --- a/packages/fsm/test/tsconfig.json +++ b/packages/fsm/test/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../../tsconfig.json", "compilerOptions": { "outDir": "../build", - "module": "es6", - "target": "es6" + "module": "commonjs", }, "include": [ "./**/*.ts", diff --git a/packages/geom-accel/package.json b/packages/geom-accel/package.json index 4c933a24b2..6c51e80c8f 100644 --- a/packages/geom-accel/package.json +++ b/packages/geom-accel/package.json @@ -2,7 +2,9 @@ "name": "@thi.ng/geom-accel", "version": "0.1.11", "description": "TODO", - "main": "./index.js", + "module": "./index.js", + "main": "./lib/index.js", + "umd:main": "./lib/index.umd.js", "typings": "./index.d.ts", "repository": { "type": "git", @@ -12,12 +14,14 @@ "author": "Karsten Schmidt ", "license": "Apache-2.0", "scripts": { - "build": "yarn clean && tsc --declaration", - "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc", + "build": "yarn clean && yarn build:es6 && yarn build:bundle", + "build:es6": "tsc --declaration", + "build:bundle": "../../scripts/bundle-module geomAccel api heaps math transducers vectors", + "test": "rimraf build && tsc -p test/tsconfig.json && nyc mocha build/test/*.js", + "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc lib internal", "cover": "yarn test && nyc report --reporter=lcov", "doc": "node_modules/.bin/typedoc --mode modules --out doc src", - "pub": "yarn build && yarn publish --access public", - "test": "rimraf build && tsc -p test && nyc mocha build/test/*.js" + "pub": "yarn build && yarn publish --access public" }, "devDependencies": { "@types/mocha": "^5.2.5", @@ -31,6 +35,7 @@ "@thi.ng/api": "^4.2.4", "@thi.ng/heaps": "^0.3.1", "@thi.ng/math": "^0.2.2", + "@thi.ng/transducers": "^2.3.2", "@thi.ng/vectors": "^1.4.12" }, "keywords": [ @@ -45,5 +50,6 @@ ], "publishConfig": { "access": "public" - } + }, + "sideEffects": false } \ No newline at end of file diff --git a/packages/geom-accel/src/kdtree.ts b/packages/geom-accel/src/kdtree.ts index 5cd86491f3..d7be2eedab 100644 --- a/packages/geom-accel/src/kdtree.ts +++ b/packages/geom-accel/src/kdtree.ts @@ -1,8 +1,8 @@ -import { ICopy, IEmpty, Pair } from "@thi.ng/api/api"; -import { Heap } from "@thi.ng/heaps/heap"; -import { EPS } from "@thi.ng/math/api"; -import { ensureArray } from "@thi.ng/transducers/func/ensure-array"; -import { IDistance } from "@thi.ng/vectors/api"; +import { ICopy, IEmpty, Pair } from "@thi.ng/api"; +import { Heap } from "@thi.ng/heaps"; +import { EPS } from "@thi.ng/math"; +import { ensureArray } from "@thi.ng/transducers"; +import { IDistance } from "@thi.ng/vectors"; export type KdIndexable = IDistance & IEmpty; diff --git a/packages/geom-accel/test/tsconfig.json b/packages/geom-accel/test/tsconfig.json index c93bb84899..2c9c12a650 100644 --- a/packages/geom-accel/test/tsconfig.json +++ b/packages/geom-accel/test/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../../tsconfig.json", "compilerOptions": { "outDir": "../build", - "module": "es6", - "target": "es6" + "module": "commonjs", }, "include": [ "./**/*.ts", diff --git a/packages/geom/package.json b/packages/geom/package.json index 547bdedf79..bd08be6182 100644 --- a/packages/geom/package.json +++ b/packages/geom/package.json @@ -2,7 +2,9 @@ "name": "@thi.ng/geom", "version": "0.2.11", "description": "2D/3D geometry primitives", - "main": "./index.js", + "module": "./index.js", + "main": "./lib/index.js", + "umd:main": "./lib/index.umd.js", "typings": "./index.d.ts", "repository": { "type": "git", @@ -12,12 +14,14 @@ "author": "Karsten Schmidt ", "license": "Apache-2.0", "scripts": { - "build": "yarn clean && tsc --declaration", - "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc internal", + "build": "yarn clean && yarn build:es6 && yarn build:bundle", + "build:es6": "tsc --declaration", + "build:bundle": "../../scripts/bundle-module geom api checks errors math transducers vectors", + "test": "rimraf build && tsc -p test/tsconfig.json && nyc mocha build/test/*.js", + "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc lib internal", "cover": "yarn test && nyc report --reporter=lcov", "doc": "node_modules/.bin/typedoc --mode modules --out doc src", - "pub": "yarn build && yarn publish --access public", - "test": "rimraf build && tsc -p test && nyc mocha build/test/*.js" + "pub": "yarn build && yarn publish --access public" }, "devDependencies": { "@types/mocha": "^5.2.5", @@ -30,6 +34,7 @@ "dependencies": { "@thi.ng/api": "^4.2.4", "@thi.ng/checks": "^1.5.14", + "@thi.ng/errors": "^0.1.12", "@thi.ng/math": "^0.2.2", "@thi.ng/transducers": "^2.3.2", "@thi.ng/vectors": "^1.4.12" @@ -45,5 +50,6 @@ ], "publishConfig": { "access": "public" - } + }, + "sideEffects": false } \ No newline at end of file diff --git a/packages/geom/src/api.ts b/packages/geom/src/api.ts index 333cf71b61..f15cc72701 100644 --- a/packages/geom/src/api.ts +++ b/packages/geom/src/api.ts @@ -1,6 +1,10 @@ -import { IObjectOf } from "@thi.ng/api/api"; -import { IVector, ReadonlyVec, Vec } from "@thi.ng/vectors/api"; -import { Vec2 } from "@thi.ng/vectors/vec2"; +import { IObjectOf } from "@thi.ng/api"; +import { + IVector, + ReadonlyVec, + Vec, + Vec2 +} from "@thi.ng/vectors"; export const DEFAULT_SAMPLES = 32; diff --git a/packages/geom/src/arc2.ts b/packages/geom/src/arc2.ts index 2916ef26e9..26b9d8e5c1 100644 --- a/packages/geom/src/arc2.ts +++ b/packages/geom/src/arc2.ts @@ -1,29 +1,30 @@ import { ICopy } from "@thi.ng/api"; -import { isNumber } from "@thi.ng/checks/is-number"; -import { isPlainObject } from "@thi.ng/checks/is-plain-object"; -import { sincos } from "@thi.ng/math/angle"; +import { isNumber, isPlainObject } from "@thi.ng/checks"; import { EPS, HALF_PI, + inRange, + mix, PI, + roundEps, + sincos, TAU -} from "@thi.ng/math/api"; -import { inRange } from "@thi.ng/math/interval"; -import { mix } from "@thi.ng/math/mix"; -import { roundEps } from "@thi.ng/math/prec"; -import { range } from "@thi.ng/transducers/iter/range"; -import { push } from "@thi.ng/transducers/rfn/push"; -import { transduce } from "@thi.ng/transducers/transduce"; -import { filter } from "@thi.ng/transducers/xform/filter"; -import { map } from "@thi.ng/transducers/xform/map"; -import { Vec } from "@thi.ng/vectors/api"; +} from "@thi.ng/math"; +import { + filter, + map, + push, + range, + transduce +} from "@thi.ng/transducers"; import { add2, asVec2, rotate2, setS2, + Vec, Vec2 -} from "@thi.ng/vectors/vec2"; +} from "@thi.ng/vectors"; import { Attribs, DEFAULT_SAMPLES, diff --git a/packages/geom/src/bezier2.ts b/packages/geom/src/bezier2.ts index b3e6da3469..5e8e8f78fa 100644 --- a/packages/geom/src/bezier2.ts +++ b/packages/geom/src/bezier2.ts @@ -1,10 +1,12 @@ import { ICopy } from "@thi.ng/api"; -import { isNumber } from "@thi.ng/checks/is-number"; -import { isPlainObject } from "@thi.ng/checks/is-plain-object"; -import { clamp01 } from "@thi.ng/math/interval"; -import { mixCubic as _mixC, mixQuadratic as _mixQ } from "@thi.ng/math/mix"; -import { IMath, ReadonlyVec, Vec } from "@thi.ng/vectors/api"; -import { Vec2 } from "@thi.ng/vectors/vec2"; +import { isNumber, isPlainObject } from "@thi.ng/checks"; +import { clamp01, mixCubic as _mixC, mixQuadratic as _mixQ } from "@thi.ng/math"; +import { + IMath, + ReadonlyVec, + Vec, + Vec2 +} from "@thi.ng/vectors"; import { Attribs, DEFAULT_SAMPLES, diff --git a/packages/geom/src/circle2.ts b/packages/geom/src/circle2.ts index edbec805e1..1f49dde94f 100644 --- a/packages/geom/src/circle2.ts +++ b/packages/geom/src/circle2.ts @@ -1,16 +1,14 @@ -import { IToHiccup } from "@thi.ng/api/api"; -import { isArrayLike } from "@thi.ng/checks/is-arraylike"; -import { isNumber } from "@thi.ng/checks/is-number"; -import { isPlainObject } from "@thi.ng/checks/is-plain-object"; -import { PI, TAU } from "@thi.ng/math/api"; -import { eqDelta } from "@thi.ng/math/eqdelta"; -import { ReadonlyVec, Vec } from "@thi.ng/vectors/api"; +import { IToHiccup } from "@thi.ng/api"; +import { isArrayLike, isNumber, isPlainObject } from "@thi.ng/checks"; +import { eqDelta, PI, TAU } from "@thi.ng/math"; import { asVec2, + ReadonlyVec, setS2, toCartesian2, + Vec, Vec2 -} from "@thi.ng/vectors/vec2"; +} from "@thi.ng/vectors"; import { Attribs, DEFAULT_SAMPLES, diff --git a/packages/geom/src/container2.ts b/packages/geom/src/container2.ts index d3f8c066fa..f4660564d3 100644 --- a/packages/geom/src/container2.ts +++ b/packages/geom/src/container2.ts @@ -1,5 +1,4 @@ -import { Mat23 } from "@thi.ng/vectors/mat23"; -import { Vec2 } from "@thi.ng/vectors/vec2"; +import { Mat23, Vec2 } from "@thi.ng/vectors"; import { Attribs, CollateOpts, diff --git a/packages/geom/src/container3.ts b/packages/geom/src/container3.ts index c8149bfad0..81cbd867f9 100644 --- a/packages/geom/src/container3.ts +++ b/packages/geom/src/container3.ts @@ -1,6 +1,5 @@ -import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; -import { Mat44 } from "@thi.ng/vectors/mat44"; -import { Vec3, vec3 } from "@thi.ng/vectors/vec3"; +import { illegalArgs } from "@thi.ng/errors"; +import { Mat44, Vec3, vec3 } from "@thi.ng/vectors"; import { Attribs, CollateOpts, diff --git a/packages/geom/src/fit.ts b/packages/geom/src/fit.ts index 2c7828dcbb..8d43994e33 100644 --- a/packages/geom/src/fit.ts +++ b/packages/geom/src/fit.ts @@ -1,5 +1,4 @@ -import { Mat23 } from "@thi.ng/vectors/mat23"; -import { Vec2 } from "@thi.ng/vectors/vec2"; +import { Mat23, Vec2 } from "@thi.ng/vectors"; import { IBounds, ICentroid, ITransformable } from "./api"; import { collBounds } from "./internal/bounds"; import { Rect2 } from "./rect2"; diff --git a/packages/geom/src/index.ts b/packages/geom/src/index.ts index 46762d01db..98b9fc69da 100644 --- a/packages/geom/src/index.ts +++ b/packages/geom/src/index.ts @@ -1,7 +1,4 @@ export * from "./api"; -export * from "./container2"; -export * from "./container3"; - export * from "./arc2"; export * from "./bezier2"; export * from "./circle2"; diff --git a/packages/geom/src/internal/arc-length.ts b/packages/geom/src/internal/arc-length.ts index 31ed1e0fbe..1d539f0af5 100644 --- a/packages/geom/src/internal/arc-length.ts +++ b/packages/geom/src/internal/arc-length.ts @@ -1,4 +1,4 @@ -import { IVector } from "@thi.ng/vectors/api"; +import { IVector } from "@thi.ng/vectors"; export const arcLength = >(pts: ReadonlyArray, closed = false) => { const num = pts.length; diff --git a/packages/geom/src/internal/area.ts b/packages/geom/src/internal/area.ts index 73b8d795b9..95197e5eed 100644 --- a/packages/geom/src/internal/area.ts +++ b/packages/geom/src/internal/area.ts @@ -1,4 +1,4 @@ -import { Vec2 } from "@thi.ng/vectors/vec2"; +import { Vec2 } from "@thi.ng/vectors"; export const polygonArea = (pts: ReadonlyArray) => { let res = 0; diff --git a/packages/geom/src/internal/args.ts b/packages/geom/src/internal/args.ts index 8d430d07b3..150bdcc193 100644 --- a/packages/geom/src/internal/args.ts +++ b/packages/geom/src/internal/args.ts @@ -1,8 +1,6 @@ -import { isArrayLike } from "@thi.ng/checks/is-arraylike"; -import { isNumber } from "@thi.ng/checks/is-number"; -import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; -import { ReadonlyVec } from "@thi.ng/vectors/api"; -import { asVec2, Vec2 } from "@thi.ng/vectors/vec2"; +import { isArrayLike, isNumber } from "@thi.ng/checks"; +import { illegalArgs } from "@thi.ng/errors"; +import { asVec2, ReadonlyVec, Vec2 } from "@thi.ng/vectors"; export const args3 = (args: any[]) => { let points = args[0], attribs; diff --git a/packages/geom/src/internal/barycentric.ts b/packages/geom/src/internal/barycentric.ts index 0eb94072f0..f0c873a0dd 100644 --- a/packages/geom/src/internal/barycentric.ts +++ b/packages/geom/src/internal/barycentric.ts @@ -1,5 +1,4 @@ -import { IVector } from "@thi.ng/vectors/api"; -import { Vec3 } from "@thi.ng/vectors/vec3"; +import { IVector, Vec3 } from "@thi.ng/vectors"; export const toBarycentric = > diff --git a/packages/geom/src/internal/bounds.ts b/packages/geom/src/internal/bounds.ts index 5d4cb1118d..0f834b5ba8 100644 --- a/packages/geom/src/internal/bounds.ts +++ b/packages/geom/src/internal/bounds.ts @@ -1,4 +1,4 @@ -import { IVector } from "@thi.ng/vectors/api"; +import { IVector } from "@thi.ng/vectors"; import { IBounds, IUnion } from "../api"; export const axisBounds = diff --git a/packages/geom/src/internal/centroid.ts b/packages/geom/src/internal/centroid.ts index e84643f1ef..a356869195 100644 --- a/packages/geom/src/internal/centroid.ts +++ b/packages/geom/src/internal/centroid.ts @@ -1,29 +1,30 @@ -import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; -import { IVector } from "@thi.ng/vectors/api"; -import { Vec2 } from "@thi.ng/vectors/vec2"; +import { illegalArgs } from "@thi.ng/errors"; +import { IVector, Vec2 } from "@thi.ng/vectors"; -export const centroid = >(pts: ReadonlyArray, c?: T) => { - const num = pts.length; - !num && illegalArgs("no points available"); - !c && (c = pts[0].empty()); - for (let i = num; --i >= 0;) { - c.add(pts[i]); - } - return c.divN(num); -}; +export const centroid = + >(pts: ReadonlyArray, c?: T) => { + const num = pts.length; + !num && illegalArgs("no points available"); + !c && (c = pts[0].empty()); + for (let i = num; --i >= 0;) { + c.add(pts[i]); + } + return c.divN(num); + }; -export const centerOfWeight = (pts: Vec2[], c?: Vec2) => { - let area = 0; - let x = 0; - let y = 0; - for (let n = pts.length - 1, i = pts[n], j = pts[0], k = 0; k <= n; k++ , i = j, j = pts[k]) { - const z = i.cross(j); - area += z; - x += (i.x + j.x) * z; - y += (i.y + j.y) * z; - } - area = 1 / (area * 3); - x *= area; - y *= area; - return c ? c.setS(x, y) : new Vec2([x, y]); -}; +export const centerOfWeight = + (pts: Vec2[], c?: Vec2) => { + let area = 0; + let x = 0; + let y = 0; + for (let n = pts.length - 1, i = pts[n], j = pts[0], k = 0; k <= n; k++ , i = j, j = pts[k]) { + const z = i.cross(j); + area += z; + x += (i.x + j.x) * z; + y += (i.y + j.y) * z; + } + area = 1 / (area * 3); + x *= area; + y *= area; + return c ? c.setS(x, y) : new Vec2([x, y]); + }; diff --git a/packages/geom/src/internal/circumcenter.ts b/packages/geom/src/internal/circumcenter.ts index 65517cf648..b0e4d4768b 100644 --- a/packages/geom/src/internal/circumcenter.ts +++ b/packages/geom/src/internal/circumcenter.ts @@ -1,5 +1,5 @@ -import { EPS } from "@thi.ng/math/api"; -import { Vec2 } from "@thi.ng/vectors/vec2"; +import { EPS } from "@thi.ng/math"; +import { Vec2 } from "@thi.ng/vectors"; export const circumCenter = (a: Readonly, b: Readonly, c: Readonly, eps = EPS) => { diff --git a/packages/geom/src/internal/closest-point.ts b/packages/geom/src/internal/closest-point.ts index ca8db6d33f..485313641e 100644 --- a/packages/geom/src/internal/closest-point.ts +++ b/packages/geom/src/internal/closest-point.ts @@ -1,4 +1,4 @@ -import { IVector } from "@thi.ng/vectors/api"; +import { IVector } from "@thi.ng/vectors"; export const closestPoint = >(p: T, pts: T[]) => { diff --git a/packages/geom/src/internal/collate.ts b/packages/geom/src/internal/collate.ts index c29f1e1a28..4fa27e767c 100644 --- a/packages/geom/src/internal/collate.ts +++ b/packages/geom/src/internal/collate.ts @@ -1,7 +1,13 @@ -import { Vec, IVec } from "@thi.ng/vectors/api"; +import { IVec, Vec } from "@thi.ng/vectors"; import { CollateOpts } from "../api"; -export const remap = (buf: Vec, pts: IVec[], start: number, cstride: number, estride: number) => { +export const remap = ( + buf: Vec, + pts: IVec[], + start: number, + cstride: number, + estride: number +) => { for (let i = pts.length; --i >= 0;) { const p = pts[i]; p.buf = buf; @@ -15,8 +21,8 @@ export const collateWith = ( fn: (buf: Vec, src: Iterable>, start, cstride, estride) => Vec, pts: T[], opts: Partial, - stride: number) => { - + stride: number +) => { opts = { start: 0, cstride: 1, diff --git a/packages/geom/src/internal/corner.ts b/packages/geom/src/internal/corner.ts index 8bf3274009..b817da7d0f 100644 --- a/packages/geom/src/internal/corner.ts +++ b/packages/geom/src/internal/corner.ts @@ -1,6 +1,5 @@ -import { sign } from "@thi.ng/math/abs"; -import { EPS } from "@thi.ng/math/api"; -import { Vec2 } from "@thi.ng/vectors/vec2"; +import { EPS, sign } from "@thi.ng/math"; +import { Vec2 } from "@thi.ng/vectors"; export const corner = (a: Readonly, b: Readonly, c: Readonly) => { diff --git "a/packages/geom/src/internal/douglas\342\200\223peucker.ts" "b/packages/geom/src/internal/douglas\342\200\223peucker.ts" index b2a7061dc1..5f6ae4e122 100644 --- "a/packages/geom/src/internal/douglas\342\200\223peucker.ts" +++ "b/packages/geom/src/internal/douglas\342\200\223peucker.ts" @@ -1,5 +1,5 @@ -import { peek } from "@thi.ng/transducers/func/peek"; -import { IVector } from "@thi.ng/vectors/api"; +import { peek } from "@thi.ng/transducers"; +import { IVector } from "@thi.ng/vectors"; import { farthestPointSegment } from "./closest-point"; // https://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm diff --git a/packages/geom/src/internal/edges.ts b/packages/geom/src/internal/edges.ts index fe9bed6d49..537fe27010 100644 --- a/packages/geom/src/internal/edges.ts +++ b/packages/geom/src/internal/edges.ts @@ -1,6 +1,5 @@ -import { wrap } from "@thi.ng/transducers/iter/wrap"; -import { partition } from "@thi.ng/transducers/xform/partition"; +import { partition, wrap } from "@thi.ng/transducers"; -export const edges = (vertices: Iterable, closed = false) => { - return partition(2, 1, closed ? wrap(vertices, 1, false, true) : vertices); -}; +export const edges = + (vertices: Iterable, closed = false) => + partition(2, 1, closed ? wrap(vertices, 1, false, true) : vertices); diff --git a/packages/geom/src/internal/eq-delta.ts b/packages/geom/src/internal/eq-delta.ts index 657aea90b1..26a715de2a 100644 --- a/packages/geom/src/internal/eq-delta.ts +++ b/packages/geom/src/internal/eq-delta.ts @@ -1,11 +1,12 @@ -import { EPS } from "@thi.ng/math/api"; -import { IVector } from "@thi.ng/vectors/api"; +import { EPS } from "@thi.ng/math"; +import { IVector } from "@thi.ng/vectors"; -export const containsDelta = >(pts: Iterable, q: Readonly, eps = EPS) => { - for (let p of pts) { - if (p.eqDelta(q, eps)) { - return true; +export const containsDelta = + >(pts: Iterable, q: Readonly, eps = EPS) => { + for (let p of pts) { + if (p.eqDelta(q, eps)) { + return true; + } } - } - return false; -}; + return false; + }; diff --git a/packages/geom/src/internal/graham-scan.ts b/packages/geom/src/internal/graham-scan.ts index eb446aa0b4..4134e7647c 100644 --- a/packages/geom/src/internal/graham-scan.ts +++ b/packages/geom/src/internal/graham-scan.ts @@ -1,4 +1,4 @@ -import { Vec2 } from "@thi.ng/vectors/vec2"; +import { Vec2 } from "@thi.ng/vectors"; import { corner } from "./corner"; /** @@ -9,29 +9,30 @@ import { corner } from "./corner"; * * @param pts */ -export const convexHull = (pts: ReadonlyArray) => { - const num = pts.length; - const res: Vec2[] = []; - let h = 0, i; - pts = pts.slice().sort(Vec2.comparator(0, 1)); +export const convexHull = + (pts: ReadonlyArray) => { + const num = pts.length; + const res: Vec2[] = []; + let h = 0, i; + pts = pts.slice().sort(Vec2.comparator(0, 1)); - const scan = (p: Vec2, thresh: number) => { - while (h >= thresh && corner(res[h - 2], res[h - 1], p) >= 0) { - res.pop(); - h--; + const scan = (p: Vec2, thresh: number) => { + while (h >= thresh && corner(res[h - 2], res[h - 1], p) >= 0) { + res.pop(); + h--; + } + res[h++] = p; + }; + + for (i = 0; i < num; i++) { + scan(pts[i], 2); + } + res.pop(); + h--; + const h2 = h + 2; + for (i = num - 1; i >= 0; i--) { + scan(pts[i], h2); } - res[h++] = p; + res.pop(); + return res; }; - - for (i = 0; i < num; i++) { - scan(pts[i], 2); - } - res.pop(); - h--; - const h2 = h + 2; - for (i = num - 1; i >= 0; i--) { - scan(pts[i], h2); - } - res.pop(); - return res; -}; diff --git a/packages/geom/src/internal/liang-barsky.ts b/packages/geom/src/internal/liang-barsky.ts index 9106f6faf3..e08223f671 100644 --- a/packages/geom/src/internal/liang-barsky.ts +++ b/packages/geom/src/internal/liang-barsky.ts @@ -1,5 +1,5 @@ -import { EPS } from "@thi.ng/math/api"; -import { Vec2 } from "@thi.ng/vectors/vec2"; +import { EPS } from "@thi.ng/math"; +import { Vec2 } from "@thi.ng/vectors"; // https://en.wikipedia.org/wiki/Liang%E2%80%93Barsky_algorithm // https://github.com/thi-ng/c-thing/blob/master/src/geom/clip/liangbarsky.c diff --git a/packages/geom/src/internal/line-intersection.ts b/packages/geom/src/internal/line-intersection.ts index 583a098dd4..0272f666bd 100644 --- a/packages/geom/src/internal/line-intersection.ts +++ b/packages/geom/src/internal/line-intersection.ts @@ -1,31 +1,32 @@ -import { Vec2 } from "@thi.ng/vectors/vec2"; +import { Vec2 } from "@thi.ng/vectors"; import { LineIntersection, LineIntersectionType } from "../api"; -export const intersectLines2 = (a: Vec2, b: Vec2, c: Vec2, d: Vec2) => { - const bax = b.x - a.x; - const bay = b.y - a.y; - const dcx = d.x - c.x; - const dcy = d.y - c.y; - const acx = a.x - c.x; - const acy = a.y - c.y; - const det = dcy * bax - dcx * bay; - let alpha = dcx * acy - dcy * acx; - let beta = bax * acy - bay * acx; - if (det === 0) { - if (alpha === 0 && beta === 0) { - return { type: LineIntersectionType.COINCIDENT }; +export const intersectLines2 = + (a: Vec2, b: Vec2, c: Vec2, d: Vec2) => { + const bax = b.x - a.x; + const bay = b.y - a.y; + const dcx = d.x - c.x; + const dcy = d.y - c.y; + const acx = a.x - c.x; + const acy = a.y - c.y; + const det = dcy * bax - dcx * bay; + let alpha = dcx * acy - dcy * acx; + let beta = bax * acy - bay * acx; + if (det === 0) { + if (alpha === 0 && beta === 0) { + return { type: LineIntersectionType.COINCIDENT }; + } + return { type: LineIntersectionType.PARALLEL }; } - return { type: LineIntersectionType.PARALLEL }; - } - alpha /= det; - beta /= det; - return >{ - type: (0 <= alpha && alpha <= 1) && (0 <= beta && beta <= 1) ? - LineIntersectionType.INTERSECT : - LineIntersectionType.INTERSECT_OUTSIDE, - isec: a.mixNewN(b, alpha), - alpha, - beta, - det, + alpha /= det; + beta /= det; + return >{ + type: (0 <= alpha && alpha <= 1) && (0 <= beta && beta <= 1) ? + LineIntersectionType.INTERSECT : + LineIntersectionType.INTERSECT_OUTSIDE, + isec: a.mixNewN(b, alpha), + alpha, + beta, + det, + }; }; -}; diff --git a/packages/geom/src/internal/sutherland-hodgeman.ts b/packages/geom/src/internal/sutherland-hodgeman.ts index fe4b1ea771..9b8175aab5 100644 --- a/packages/geom/src/internal/sutherland-hodgeman.ts +++ b/packages/geom/src/internal/sutherland-hodgeman.ts @@ -1,4 +1,4 @@ -import { Vec2 } from "@thi.ng/vectors/vec2"; +import { Vec2 } from "@thi.ng/vectors"; import { classify } from "./corner"; import { intersectLines2 } from "./line-intersection"; @@ -14,30 +14,31 @@ import { intersectLines2 } from "./line-intersection"; * @param bc pre-computed boundary centroid * @param eps edge classification tolerance */ -export const clipConvex = (poly: Vec2[], bounds: Vec2[], bc: Vec2, eps = 1e-4) => { - for (let ne = bounds.length, j = ne - 1, i = 0; i < ne; j = i, i++) { - const clipped = []; - const ca = bounds[j]; - const cb = bounds[i]; - const sign = classify(ca, cb, bc, eps); - for (let np = poly.length, k = np - 1, l = 0; l < np; k = l, l++) { - const p = poly[k]; - const q = poly[l]; - const cqsign = classify(ca, cb, q, eps); - if (classify(ca, cb, p, eps) === sign) { - clipped.push( - cqsign !== sign ? - intersectLines2(ca, cb, p, q).isec : - q - ); - } else if (cqsign === sign) { - clipped.push(intersectLines2(ca, cb, p, q).isec, q); +export const clipConvex = + (poly: Vec2[], bounds: Vec2[], bc: Vec2, eps = 1e-4) => { + for (let ne = bounds.length, j = ne - 1, i = 0; i < ne; j = i, i++) { + const clipped = []; + const ca = bounds[j]; + const cb = bounds[i]; + const sign = classify(ca, cb, bc, eps); + for (let np = poly.length, k = np - 1, l = 0; l < np; k = l, l++) { + const p = poly[k]; + const q = poly[l]; + const cqsign = classify(ca, cb, q, eps); + if (classify(ca, cb, p, eps) === sign) { + clipped.push( + cqsign !== sign ? + intersectLines2(ca, cb, p, q).isec : + q + ); + } else if (cqsign === sign) { + clipped.push(intersectLines2(ca, cb, p, q).isec, q); + } } + if (clipped.length < 2) { + return []; + } + poly = clipped; } - if (clipped.length < 2) { - return []; - } - poly = clipped; - } - return poly; -}; + return poly; + }; diff --git a/packages/geom/src/line2.ts b/packages/geom/src/line2.ts index 0b98609b26..e545dc5a0c 100644 --- a/packages/geom/src/line2.ts +++ b/packages/geom/src/line2.ts @@ -1,8 +1,10 @@ -import { isArrayLike } from "@thi.ng/checks/is-arraylike"; -import { isNumber } from "@thi.ng/checks/is-number"; -import { isPlainObject } from "@thi.ng/checks/is-plain-object"; -import { ReadonlyVec, Vec } from "@thi.ng/vectors/api"; -import { asVec2, Vec2 } from "@thi.ng/vectors/vec2"; +import { isArrayLike, isNumber, isPlainObject } from "@thi.ng/checks"; +import { + asVec2, + ReadonlyVec, + Vec, + Vec2 +} from "@thi.ng/vectors"; import { Attribs, HiccupLine2, diff --git a/packages/geom/src/path2.ts b/packages/geom/src/path2.ts index f826489522..4e89502311 100644 --- a/packages/geom/src/path2.ts +++ b/packages/geom/src/path2.ts @@ -1,10 +1,12 @@ -import { isNumber } from "@thi.ng/checks/is-number"; -import { implementsFunction } from "@thi.ng/checks/implements-function"; -import { rad } from "@thi.ng/math/angle"; -import { eqDelta } from "@thi.ng/math/eqdelta"; -import { ensureArray } from "@thi.ng/transducers/func/ensure-array"; -import { peek } from "@thi.ng/transducers/func/peek"; -import { Vec2 } from "@thi.ng/vectors/vec2"; +import { implementsFunction, isNumber } from "@thi.ng/checks"; +import { eqDelta, rad } from "@thi.ng/math"; +import { + ensureArray, + map, + mapcat, + peek +} from "@thi.ng/transducers"; +import { Vec2 } from "@thi.ng/vectors"; import { Attribs, IBounds, @@ -22,8 +24,6 @@ import { Polygon2 } from "./polygon2"; import { Polyline2 } from "./polyline2"; import { Rect2 } from "./rect2"; import { simplifyPolyline } from "./internal/douglas–peucker"; -import { mapcat } from "@thi.ng/transducers/xform/mapcat"; -import { map } from "@thi.ng/transducers/xform/map"; export class Path2 implements Iterable, diff --git a/packages/geom/src/polygon2.ts b/packages/geom/src/polygon2.ts index 3fbb535288..cd5b255c07 100644 --- a/packages/geom/src/polygon2.ts +++ b/packages/geom/src/polygon2.ts @@ -1,15 +1,21 @@ -import { ICopy, IToHiccup } from "@thi.ng/api/api"; -import { isNumber } from "@thi.ng/checks/is-number"; -import { isPlainObject } from "@thi.ng/checks/is-plain-object"; -import { TAU } from "@thi.ng/math/api"; -import { cycle } from "@thi.ng/transducers/iter/cycle"; -import { normRange } from "@thi.ng/transducers/iter/norm-range"; -import { tuples } from "@thi.ng/transducers/iter/tuples"; -import { push } from "@thi.ng/transducers/rfn/push"; -import { transduce } from "@thi.ng/transducers/transduce"; -import { map } from "@thi.ng/transducers/xform/map"; -import { ReadonlyVec, Vec } from "@thi.ng/vectors/api"; -import { asVec2, toCartesian2, Vec2 } from "@thi.ng/vectors/vec2"; +import { ICopy, IToHiccup } from "@thi.ng/api"; +import { isNumber, isPlainObject } from "@thi.ng/checks"; +import { TAU } from "@thi.ng/math"; +import { + cycle, + map, + normRange, + push, + transduce, + tuples +} from "@thi.ng/transducers"; +import { + asVec2, + ReadonlyVec, + toCartesian2, + Vec, + Vec2 +} from "@thi.ng/vectors"; import { Attribs, HiccupPolygon2, diff --git a/packages/geom/src/polyline2.ts b/packages/geom/src/polyline2.ts index 37c159e4a1..552289fdee 100644 --- a/packages/geom/src/polyline2.ts +++ b/packages/geom/src/polyline2.ts @@ -1,9 +1,7 @@ -import { ICopy, IToHiccup } from "@thi.ng/api/api"; -import { isPlainObject } from "@thi.ng/checks/is-plain-object"; -import { map } from "@thi.ng/transducers/xform/map"; -import { partition } from "@thi.ng/transducers/xform/partition"; -import { ReadonlyVec, Vec } from "@thi.ng/vectors/api"; -import { Vec2 } from "@thi.ng/vectors/vec2"; +import { ICopy, IToHiccup } from "@thi.ng/api"; +import { isPlainObject } from "@thi.ng/checks"; +import { map, partition } from "@thi.ng/transducers"; +import { ReadonlyVec, Vec, Vec2 } from "@thi.ng/vectors"; import { Attribs, IArcLength, diff --git a/packages/geom/src/quad2.ts b/packages/geom/src/quad2.ts index 4a2c07dbbc..e5dfdaf6a8 100644 --- a/packages/geom/src/quad2.ts +++ b/packages/geom/src/quad2.ts @@ -1,6 +1,5 @@ import { ICopy } from "@thi.ng/api"; -import { ReadonlyVec, Vec } from "@thi.ng/vectors/api"; -import { Vec2 } from "@thi.ng/vectors/vec2"; +import { ReadonlyVec, Vec, Vec2 } from "@thi.ng/vectors"; import { Attribs, IArcLength, diff --git a/packages/geom/src/rect2.ts b/packages/geom/src/rect2.ts index b6d3527645..12e6b5a21c 100644 --- a/packages/geom/src/rect2.ts +++ b/packages/geom/src/rect2.ts @@ -1,9 +1,6 @@ import { ICopy } from "@thi.ng/api"; -import { isArrayLike } from "@thi.ng/checks/is-arraylike"; -import { isNumber } from "@thi.ng/checks/is-number"; -import { isPlainObject } from "@thi.ng/checks/is-plain-object"; -import { ReadonlyVec } from "@thi.ng/vectors/api"; -import { asVec2, Vec2 } from "@thi.ng/vectors/vec2"; +import { isArrayLike, isNumber, isPlainObject } from "@thi.ng/checks"; +import { asVec2, ReadonlyVec, Vec2 } from "@thi.ng/vectors"; import { Attribs, CollateOpts, diff --git a/packages/geom/src/sampler.ts b/packages/geom/src/sampler.ts index 2f6a6a3c18..df343220e5 100644 --- a/packages/geom/src/sampler.ts +++ b/packages/geom/src/sampler.ts @@ -1,5 +1,5 @@ -import { peek } from "@thi.ng/transducers/func/peek"; -import { IVector } from "@thi.ng/vectors/api"; +import { peek } from "@thi.ng/transducers"; +import { IVector } from "@thi.ng/vectors"; export class Sampler> { diff --git a/packages/geom/src/subdiv-curve.ts b/packages/geom/src/subdiv-curve.ts index 31b3e93ebd..56300fef80 100644 --- a/packages/geom/src/subdiv-curve.ts +++ b/packages/geom/src/subdiv-curve.ts @@ -1,10 +1,12 @@ -import { comp } from "@thi.ng/transducers/func/comp"; -import { wrap } from "@thi.ng/transducers/iter/wrap"; -import { push } from "@thi.ng/transducers/rfn/push"; -import { transduce } from "@thi.ng/transducers/transduce"; -import { indexed } from "@thi.ng/transducers/xform/indexed"; -import { mapcat } from "@thi.ng/transducers/xform/mapcat"; -import { partition } from "@thi.ng/transducers/xform/partition"; +import { + comp, + indexed, + mapcat, + partition, + push, + transduce, + wrap +} from "@thi.ng/transducers"; import { IVector } from "@thi.ng/vectors/api"; import { SubdivKernel } from "./api"; @@ -21,7 +23,7 @@ const madd3 = const madd5 = > (a: Readonly, b: Readonly, c: Readonly, d: Readonly, e: Readonly, - ua: number, ub: number, uc: number, ud: number, ue: number) => + ua: number, ub: number, uc: number, ud: number, ue: number) => a.mulNewN(ua).maddN(b, ub).maddN(c, uc).maddN(d, ud).maddN(e, ue); export const subdivKernel2 = diff --git a/packages/geom/src/tessellate.ts b/packages/geom/src/tessellate.ts index dc100dc8e8..78be1ab2c3 100644 --- a/packages/geom/src/tessellate.ts +++ b/packages/geom/src/tessellate.ts @@ -1,19 +1,20 @@ -import { isFunction } from "@thi.ng/checks/is-function"; -import { comp } from "@thi.ng/transducers/func/comp"; -import { range } from "@thi.ng/transducers/iter/range"; -import { repeat } from "@thi.ng/transducers/iter/repeat"; -import { tuples } from "@thi.ng/transducers/iter/tuples"; -import { wrap } from "@thi.ng/transducers/iter/wrap"; -import { reducer } from "@thi.ng/transducers/reduce"; -import { last } from "@thi.ng/transducers/rfn/last"; -import { push } from "@thi.ng/transducers/rfn/push"; -import { transduce } from "@thi.ng/transducers/transduce"; -import { map } from "@thi.ng/transducers/xform/map"; -import { mapcat } from "@thi.ng/transducers/xform/mapcat"; -import { partition } from "@thi.ng/transducers/xform/partition"; -import { scan } from "@thi.ng/transducers/xform/scan"; -import { IVector } from "@thi.ng/vectors/api"; -import { Vec2 } from "@thi.ng/vectors/vec2"; +import { isFunction } from "@thi.ng/checks"; +import { + comp, + last, + map, + mapcat, + partition, + push, + range, + reducer, + repeat, + scan, + transduce, + tuples, + wrap +} from "@thi.ng/transducers"; +import { IVector, Vec2 } from "@thi.ng/vectors"; import { Tessellator } from "./api"; import { polygonArea } from "./internal/area"; import { centroid } from "./internal/centroid"; diff --git a/packages/geom/src/triangle2.ts b/packages/geom/src/triangle2.ts index faa20596c1..0b7f1e1d16 100644 --- a/packages/geom/src/triangle2.ts +++ b/packages/geom/src/triangle2.ts @@ -1,8 +1,11 @@ import { ICopy } from "@thi.ng/api"; -import { PI } from "@thi.ng/math/api"; -import { ReadonlyVec, Vec } from "@thi.ng/vectors/api"; -import { Vec2 } from "@thi.ng/vectors/vec2"; -import { Vec3 } from "@thi.ng/vectors/vec3"; +import { PI } from "@thi.ng/math"; +import { + ReadonlyVec, + Vec, + Vec2, + Vec3 +} from "@thi.ng/vectors"; import { Attribs, IArcLength, diff --git a/packages/geom/src/warp.ts b/packages/geom/src/warp.ts index 839d58c47d..6628ae86b9 100644 --- a/packages/geom/src/warp.ts +++ b/packages/geom/src/warp.ts @@ -1,12 +1,15 @@ +import { IVector } from "@thi.ng/vectors"; import { IPointMap } from "./api"; -import { IVector } from "@thi.ng/vectors/api"; -export const warpPoints = - , V2 extends IVector, A extends IPointMap, B extends IPointMap> - (dest: B, src: ReadonlyArray, srcBounds: A) => { - const res: V[] = []; - for (let n = src.length, i = 0; i < n; i++) { - res.push(dest.unmapPoint(srcBounds.mapPoint(src[i]))); - } - return res; - }; +export const warpPoints = < + V extends IVector, + V2 extends IVector, + A extends IPointMap, + B extends IPointMap +>(dest: B, src: ReadonlyArray, srcBounds: A) => { + const res: V[] = []; + for (let n = src.length, i = 0; i < n; i++) { + res.push(dest.unmapPoint(srcBounds.mapPoint(src[i]))); + } + return res; +}; diff --git a/packages/geom/test/circle2.ts b/packages/geom/test/circle2.ts index 4ab293f658..d5f877c2f9 100644 --- a/packages/geom/test/circle2.ts +++ b/packages/geom/test/circle2.ts @@ -1,6 +1,6 @@ import { equiv } from "@thi.ng/equiv"; -import { PI, TAU, HALF_PI } from "@thi.ng/math/api"; -import { eqDelta2array, vec2 } from "@thi.ng/vectors/vec2"; +import { HALF_PI, PI, TAU } from "@thi.ng/math"; +import { eqDelta2array, vec2 } from "@thi.ng/vectors"; import * as assert from "assert"; import { circle2, Circle2, HiccupCircle2 } from "../src"; diff --git a/packages/geom/test/tsconfig.json b/packages/geom/test/tsconfig.json index c93bb84899..2c9c12a650 100644 --- a/packages/geom/test/tsconfig.json +++ b/packages/geom/test/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../../tsconfig.json", "compilerOptions": { "outDir": "../build", - "module": "es6", - "target": "es6" + "module": "commonjs", }, "include": [ "./**/*.ts", diff --git a/packages/heaps/package.json b/packages/heaps/package.json index 1f16da8306..80b1811122 100644 --- a/packages/heaps/package.json +++ b/packages/heaps/package.json @@ -2,7 +2,9 @@ "name": "@thi.ng/heaps", "version": "0.3.1", "description": "Generic binary heap & d-ary heap implementations with customizable ordering", - "main": "./index.js", + "module": "./index.js", + "main": "./lib/index.js", + "umd:main": "./lib/index.umd.js", "typings": "./index.d.ts", "repository": { "type": "git", @@ -12,12 +14,14 @@ "author": "Karsten Schmidt ", "license": "Apache-2.0", "scripts": { - "build": "yarn clean && tsc --declaration", - "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc", + "build": "yarn clean && yarn build:es6 && yarn build:bundle", + "build:es6": "tsc --declaration", + "build:bundle": "../../scripts/bundle-module heaps api compare", + "test": "rimraf build && tsc -p test/tsconfig.json && nyc mocha build/test/*.js", + "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc lib", "cover": "yarn test && nyc report --reporter=lcov", "doc": "node_modules/.bin/typedoc --mode modules --out doc src", - "pub": "yarn build && yarn publish --access public", - "test": "rimraf build && tsc -p test && nyc mocha build/test/*.js" + "pub": "yarn build && yarn publish --access public" }, "devDependencies": { "@types/mocha": "^5.2.5", @@ -42,5 +46,6 @@ ], "publishConfig": { "access": "public" - } + }, + "sideEffects": false } \ No newline at end of file diff --git a/packages/heaps/src/api.ts b/packages/heaps/src/api.ts index 18b1b4466b..ebdd8abf85 100644 --- a/packages/heaps/src/api.ts +++ b/packages/heaps/src/api.ts @@ -1,4 +1,4 @@ -import { Comparator } from "@thi.ng/api/api"; +import { Comparator } from "@thi.ng/api"; export interface HeapOpts { compare: Comparator; diff --git a/packages/heaps/src/dheap.ts b/packages/heaps/src/dheap.ts index 87c5dea5b1..acfa8a7bf8 100644 --- a/packages/heaps/src/dheap.ts +++ b/packages/heaps/src/dheap.ts @@ -1,4 +1,4 @@ -import { ICopy, IEmpty } from "@thi.ng/api/api"; +import { ICopy, IEmpty } from "@thi.ng/api"; import { compare } from "@thi.ng/compare"; import { DHeapOpts } from "./api"; diff --git a/packages/heaps/src/heap.ts b/packages/heaps/src/heap.ts index a32d49cd46..f396ba8fd1 100644 --- a/packages/heaps/src/heap.ts +++ b/packages/heaps/src/heap.ts @@ -3,7 +3,7 @@ import { ICopy, IEmpty, ILength -} from "@thi.ng/api/api"; +} from "@thi.ng/api"; import { compare } from "@thi.ng/compare"; import { HeapOpts } from "./api"; diff --git a/packages/heaps/test/tsconfig.json b/packages/heaps/test/tsconfig.json index c93bb84899..2c9c12a650 100644 --- a/packages/heaps/test/tsconfig.json +++ b/packages/heaps/test/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../../tsconfig.json", "compilerOptions": { "outDir": "../build", - "module": "es6", - "target": "es6" + "module": "commonjs", }, "include": [ "./**/*.ts", diff --git a/packages/hiccup-carbon-icons/package.json b/packages/hiccup-carbon-icons/package.json index 59b90d3fdc..636cab1374 100644 --- a/packages/hiccup-carbon-icons/package.json +++ b/packages/hiccup-carbon-icons/package.json @@ -2,7 +2,9 @@ "name": "@thi.ng/hiccup-carbon-icons", "version": "0.1.2", "description": "TODO", - "main": "./index.js", + "module": "./index.js", + "main": "./lib/index.js", + "umd:main": "./lib/index.umd.js", "typings": "./index.d.ts", "repository": { "type": "git", @@ -12,12 +14,14 @@ "author": "Karsten Schmidt ", "license": "Apache-2.0", "scripts": { - "build": "yarn clean && tsc --declaration", - "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc", + "build": "yarn clean && yarn build:es6 && yarn build:bundle", + "build:es6": "tsc --declaration", + "build:bundle": "../../scripts/bundle-module hiccupCarbonIcons", + "test": "rimraf build && tsc -p test/tsconfig.json && nyc mocha build/test/*.js", + "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc lib", "cover": "yarn test && nyc report --reporter=lcov", "doc": "node_modules/.bin/typedoc --mode modules --out doc src", - "pub": "yarn build && yarn publish --access public", - "test": "rimraf build && tsc -p test && nyc mocha build/test/*.js" + "pub": "yarn build && yarn publish --access public" }, "devDependencies": { "@thi.ng/hiccup": "^2.7.2", @@ -29,10 +33,19 @@ "typescript": "^3.2.2" }, "keywords": [ + "assets", + "carbon", "ES6", - "typescript" + "hdom", + "hiccup", + "IBM", + "icons", + "svg", + "typescript", + "UI" ], "publishConfig": { "access": "public" - } + }, + "sideEffects": false } \ No newline at end of file diff --git a/packages/hiccup-carbon-icons/test/tsconfig.json b/packages/hiccup-carbon-icons/test/tsconfig.json index c93bb84899..2c9c12a650 100644 --- a/packages/hiccup-carbon-icons/test/tsconfig.json +++ b/packages/hiccup-carbon-icons/test/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../../tsconfig.json", "compilerOptions": { "outDir": "../build", - "module": "es6", - "target": "es6" + "module": "commonjs", }, "include": [ "./**/*.ts", diff --git a/packages/hiccup-css/package.json b/packages/hiccup-css/package.json index ac4af4e875..18f9f4d00c 100644 --- a/packages/hiccup-css/package.json +++ b/packages/hiccup-css/package.json @@ -2,7 +2,9 @@ "name": "@thi.ng/hiccup-css", "version": "0.3.5", "description": "CSS from nested JS data structures", - "main": "./index.js", + "module": "./index.js", + "main": "./lib/index.js", + "umd:main": "./lib/index.umd.js", "typings": "./index.d.ts", "repository": { "type": "git", @@ -12,12 +14,14 @@ "author": "Karsten Schmidt ", "license": "Apache-2.0", "scripts": { - "build": "yarn clean && tsc --declaration", - "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc", + "build": "yarn clean && yarn build:es6 && yarn build:bundle", + "build:es6": "tsc --declaration", + "build:bundle": "../../scripts/bundle-module hiccupCss api checks errors transducers", + "test": "rimraf build && tsc -p test/tsconfig.json && nyc mocha build/test/*.js", + "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc lib", "cover": "yarn test && nyc report --reporter=lcov", "doc": "node_modules/.bin/typedoc --mode modules --out doc src", - "pub": "yarn build && yarn publish --access public", - "test": "rimraf build && tsc -p test && nyc mocha build/test/*.js" + "pub": "yarn build && yarn publish --access public" }, "devDependencies": { "@types/mocha": "^5.2.5", @@ -49,5 +53,6 @@ ], "publishConfig": { "access": "public" - } + }, + "sideEffects": false } \ No newline at end of file diff --git a/packages/hiccup-css/src/api.ts b/packages/hiccup-css/src/api.ts index c604a121a3..6dcb8741dd 100644 --- a/packages/hiccup-css/src/api.ts +++ b/packages/hiccup-css/src/api.ts @@ -1,4 +1,4 @@ -import { IObjectOf } from "@thi.ng/api/api"; +import { IObjectOf } from "@thi.ng/api"; /** * Function type used by `at_xxx()` functions or any diff --git a/packages/hiccup-css/src/conditional.ts b/packages/hiccup-css/src/conditional.ts index 80fe10e627..40bba5d43e 100644 --- a/packages/hiccup-css/src/conditional.ts +++ b/packages/hiccup-css/src/conditional.ts @@ -1,5 +1,4 @@ -import { isString } from "@thi.ng/checks/is-string"; - +import { isString } from "@thi.ng/checks"; import { Conditional, CSSOpts, RuleFn } from "./api"; import { expand, indent } from "./impl"; diff --git a/packages/hiccup-css/src/css.ts b/packages/hiccup-css/src/css.ts index 821331f81a..b161242cd3 100644 --- a/packages/hiccup-css/src/css.ts +++ b/packages/hiccup-css/src/css.ts @@ -1,8 +1,10 @@ -import { isArray } from "@thi.ng/checks/is-array"; -import { isFunction } from "@thi.ng/checks/is-function"; -import { isIterable } from "@thi.ng/checks/is-iterable"; -import { isPlainObject } from "@thi.ng/checks/is-plain-object"; -import { isString } from "@thi.ng/checks/is-string"; +import { + isArray, + isFunction, + isIterable, + isPlainObject, + isString +} from "@thi.ng/checks"; import { COMPACT, CSSOpts, DEFAULT_VENDORS } from "./api"; import { expand, formatDecls } from "./impl"; diff --git a/packages/hiccup-css/src/impl.ts b/packages/hiccup-css/src/impl.ts index fc874a4f2f..b9f01d1487 100644 --- a/packages/hiccup-css/src/impl.ts +++ b/packages/hiccup-css/src/impl.ts @@ -1,17 +1,21 @@ -import { isArray } from "@thi.ng/checks/is-array"; -import { isFunction } from "@thi.ng/checks/is-function"; -import { isIterable } from "@thi.ng/checks/is-iterable"; -import { isPlainObject } from "@thi.ng/checks/is-plain-object"; -import { isString } from "@thi.ng/checks/is-string"; -import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; -import { Transducer } from "@thi.ng/transducers/api"; -import { comp } from "@thi.ng/transducers/func/comp"; -import { permutations } from "@thi.ng/transducers/iter/permutations"; -import { repeat } from "@thi.ng/transducers/iter/repeat"; -import { str } from "@thi.ng/transducers/rfn/str"; -import { transduce } from "@thi.ng/transducers/transduce"; -import { flatten } from "@thi.ng/transducers/xform/flatten"; -import { map } from "@thi.ng/transducers/xform/map"; +import { + isArray, + isFunction, + isIterable, + isPlainObject, + isString +} from "@thi.ng/checks"; +import { illegalArgs } from "@thi.ng/errors"; +import { + comp, + flatten, + map, + permutations, + repeat, + str, + transduce, + Transducer +} from "@thi.ng/transducers"; import { CSSOpts } from "./api"; const EMPTY = new Set(); diff --git a/packages/hiccup-css/test/tsconfig.json b/packages/hiccup-css/test/tsconfig.json index c93bb84899..2c9c12a650 100644 --- a/packages/hiccup-css/test/tsconfig.json +++ b/packages/hiccup-css/test/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../../tsconfig.json", "compilerOptions": { "outDir": "../build", - "module": "es6", - "target": "es6" + "module": "commonjs", }, "include": [ "./**/*.ts", diff --git a/packages/hiccup-markdown/package.json b/packages/hiccup-markdown/package.json index 13c044dd82..8f5fd411bc 100644 --- a/packages/hiccup-markdown/package.json +++ b/packages/hiccup-markdown/package.json @@ -2,7 +2,9 @@ "name": "@thi.ng/hiccup-markdown", "version": "0.2.0", "description": "Markdown serialization of hiccup DOM trees", - "main": "./index.js", + "module": "./index.js", + "main": "./lib/index.js", + "umd:main": "./lib/index.umd.js", "typings": "./index.d.ts", "repository": { "type": "git", @@ -12,12 +14,14 @@ "author": "Karsten Schmidt ", "license": "Apache-2.0", "scripts": { - "build": "yarn clean && tsc --declaration", - "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc", + "build": "yarn clean && yarn build:es6 && yarn build:bundle", + "build:es6": "tsc --declaration", + "build:bundle": "../../scripts/bundle-module hiccupMarkdown checks defmulti errors fsm hiccup strings transducers", + "test": "rimraf build && tsc -p test/tsconfig.json && nyc mocha build/test/*.js", + "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc lib", "cover": "yarn test && nyc report --reporter=lcov", "doc": "node_modules/.bin/typedoc --mode modules --out doc src", - "pub": "yarn build && yarn publish --access public", - "test": "rimraf build && tsc -p test && nyc mocha build/test/*.js" + "pub": "yarn build && yarn publish --access public" }, "devDependencies": { "@types/mocha": "^5.2.5", @@ -50,5 +54,6 @@ ], "publishConfig": { "access": "public" - } + }, + "sideEffects": false } \ No newline at end of file diff --git a/packages/hiccup-markdown/src/parse.ts b/packages/hiccup-markdown/src/parse.ts index 47516b611f..937537c9e8 100644 --- a/packages/hiccup-markdown/src/parse.ts +++ b/packages/hiccup-markdown/src/parse.ts @@ -1,13 +1,15 @@ -import { alts } from "@thi.ng/fsm/alts"; -import { ResultBody } from "@thi.ng/fsm/api"; -import { fsm } from "@thi.ng/fsm/fsm"; -import { not } from "@thi.ng/fsm/not"; -import { whitespace } from "@thi.ng/fsm/range"; -import { repeat } from "@thi.ng/fsm/repeat"; -import { seq } from "@thi.ng/fsm/seq"; -import { str } from "@thi.ng/fsm/str"; -import { until } from "@thi.ng/fsm/until"; -import { peek } from "@thi.ng/transducers/func/peek"; +import { + alts, + fsm, + not, + repeat, + ResultBody, + seq, + str, + until, + whitespace +} from "@thi.ng/fsm"; +import { peek } from "@thi.ng/transducers"; import { TagFactories } from "./api"; type ParseResult = ResultBody; diff --git a/packages/hiccup-markdown/src/serialize.ts b/packages/hiccup-markdown/src/serialize.ts index 397bf0ebb3..96f516e3e8 100644 --- a/packages/hiccup-markdown/src/serialize.ts +++ b/packages/hiccup-markdown/src/serialize.ts @@ -1,12 +1,13 @@ -import { implementsFunction } from "@thi.ng/checks/implements-function"; -import { isFunction } from "@thi.ng/checks/is-function"; -import { isNotStringAndIterable } from "@thi.ng/checks/is-not-string-iterable"; -import { isString } from "@thi.ng/checks/is-string"; +import { + implementsFunction, + isFunction, + isNotStringAndIterable, + isString +} from "@thi.ng/checks"; import { DEFAULT, defmulti, MultiFn3 } from "@thi.ng/defmulti"; -import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; -import { normalize } from "@thi.ng/hiccup/serialize"; -import { repeat } from "@thi.ng/strings/repeat"; -import { wrap } from "@thi.ng/strings/wrap"; +import { illegalArgs } from "@thi.ng/errors"; +import { normalize } from "@thi.ng/hiccup"; +import { repeat, wrap } from "@thi.ng/strings"; export const serialize = (tree: any, ctx) => _serialize(tree, ctx, { indent: 0, sep: "" }); diff --git a/packages/hiccup-markdown/test/tsconfig.json b/packages/hiccup-markdown/test/tsconfig.json index c93bb84899..2c9c12a650 100644 --- a/packages/hiccup-markdown/test/tsconfig.json +++ b/packages/hiccup-markdown/test/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../../tsconfig.json", "compilerOptions": { "outDir": "../build", - "module": "es6", - "target": "es6" + "module": "commonjs", }, "include": [ "./**/*.ts", diff --git a/packages/hiccup-svg/package.json b/packages/hiccup-svg/package.json index 6e35918f13..1c83318a92 100644 --- a/packages/hiccup-svg/package.json +++ b/packages/hiccup-svg/package.json @@ -2,7 +2,9 @@ "name": "@thi.ng/hiccup-svg", "version": "2.0.10", "description": "SVG element functions for @thi.ng/hiccup & @thi.ng/hdom", - "main": "./index.js", + "module": "./index.js", + "main": "./lib/index.js", + "umd:main": "./lib/index.umd.js", "typings": "./index.d.ts", "repository": { "type": "git", @@ -12,12 +14,14 @@ "author": "Karsten Schmidt ", "license": "Apache-2.0", "scripts": { - "build": "yarn clean && tsc --declaration", - "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc", + "build": "yarn clean && yarn build:es6 && yarn build:bundle", + "build:es6": "tsc --declaration", + "build:bundle": "../../scripts/bundle-module hiccup-svg checks hiccup", + "test": "rimraf build && tsc -p test/tsconfig.json && nyc mocha build/test/*.js", + "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc lib", "cover": "yarn test && nyc report --reporter=lcov", "doc": "node_modules/.bin/typedoc --mode modules --out doc src", - "pub": "yarn build && yarn publish --access public", - "test": "rimraf build && tsc -p test && nyc mocha build/test/*.js" + "pub": "yarn build && yarn publish --access public" }, "devDependencies": { "@types/mocha": "^5.2.5", @@ -28,19 +32,24 @@ "typescript": "^3.2.2" }, "dependencies": { + "@thi.ng/checks": "^1.5.14", "@thi.ng/hiccup": "^2.7.2" }, "keywords": [ "components", + "convert", "ES6", + "generator", "hiccup", "hdom", "SVG", + "serialize", "typescript", "UI", "visualization" ], "publishConfig": { "access": "public" - } + }, + "sideEffects": false } \ No newline at end of file diff --git a/packages/hiccup-svg/src/circle.ts b/packages/hiccup-svg/src/circle.ts index bde7615028..a902c298d3 100644 --- a/packages/hiccup-svg/src/circle.ts +++ b/packages/hiccup-svg/src/circle.ts @@ -1,10 +1,11 @@ import { Vec2Like } from "./api"; import { ff } from "./format"; -export const circle = (p: Vec2Like, r: number, attribs?: any): any[] => - ["circle", { - cx: ff(p[0]), - cy: ff(p[1]), - r: ff(r), - ...attribs - }]; +export const circle = + (p: Vec2Like, r: number, attribs?: any): any[] => + ["circle", { + cx: ff(p[0]), + cy: ff(p[1]), + r: ff(r), + ...attribs + }]; diff --git a/packages/hiccup-svg/src/convert.ts b/packages/hiccup-svg/src/convert.ts index 9b409f3ed9..094cca3aa9 100644 --- a/packages/hiccup-svg/src/convert.ts +++ b/packages/hiccup-svg/src/convert.ts @@ -1,6 +1,4 @@ -import { isArray } from "@thi.ng/checks/is-array"; -import { isArrayLike } from "@thi.ng/checks/is-arraylike"; - +import { isArray, isArrayLike } from "@thi.ng/checks"; import { PathSegment } from "./api"; import { circle } from "./circle"; import { ff } from "./format"; @@ -40,149 +38,152 @@ const TEXT_ALIGN = { * * @param tree */ -export const convertTree = (tree: any[]): any[] => { - const type = tree[0]; - if (isArray(type)) { - return tree.map(convertTree); - } - let attribs = convertAttribs(tree[1]); - switch (tree[0]) { - case "svg": - case "defs": - case "g": { - const res: any[] = [type, attribs]; - for (let i = 2, n = tree.length; i < n; i++) { - const c = convertTree(tree[i]); - c != null && res.push(c); - } - return res; +export const convertTree = + (tree: any[]): any[] => { + const type = tree[0]; + if (isArray(type)) { + return tree.map(convertTree); } - case "linearGradient": - return linearGradient( - attribs.id, - attribs.from, - attribs.to, - tree[2], - { - gradientUnits: attribs.gradientUnits || "userSpaceOnUse", - gradientTransform: attribs.gradientTransform, - } - ); - case "radialGradient": - return radialGradient( - attribs.id, - attribs.from, - attribs.to, - attribs.r1, - attribs.r2, - tree[2], - { - gradientUnits: attribs.gradientUnits || "userSpaceOnUse", - gradientTransform: attribs.gradientTransform, + let attribs = convertAttribs(tree[1]); + switch (tree[0]) { + case "svg": + case "defs": + case "g": { + const res: any[] = [type, attribs]; + for (let i = 2, n = tree.length; i < n; i++) { + const c = convertTree(tree[i]); + c != null && res.push(c); } - ); - case "circle": - return circle(tree[2], tree[3], attribs); - case "rect": { - const r = tree[5] || 0; - return roundedRect(tree[2], tree[3], tree[4], r, r, attribs); - } - case "line": - return line(tree[2], tree[3], attribs); - case "hline": - return hline(tree[2], attribs); - case "vline": - return vline(tree[2], attribs); - case "polyline": - case "polygon": - return polygon(tree[2], attribs); - case "path": { - let segments: PathSegment[] = []; - for (let seg of tree[2]) { - switch (seg[0].toLowerCase()) { - case "s": - case "t": - // TODO compute reflected control point - // https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d#Cubic_B%C3%A9zier_Curve - // https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d#Quadratic_B%C3%A9zier_Curve - break; - default: - segments.push(seg); + return res; + } + case "linearGradient": + return linearGradient( + attribs.id, + attribs.from, + attribs.to, + tree[2], + { + gradientUnits: attribs.gradientUnits || "userSpaceOnUse", + gradientTransform: attribs.gradientTransform, + } + ); + case "radialGradient": + return radialGradient( + attribs.id, + attribs.from, + attribs.to, + attribs.r1, + attribs.r2, + tree[2], + { + gradientUnits: attribs.gradientUnits || "userSpaceOnUse", + gradientTransform: attribs.gradientTransform, + } + ); + case "circle": + return circle(tree[2], tree[3], attribs); + case "rect": { + const r = tree[5] || 0; + return roundedRect(tree[2], tree[3], tree[4], r, r, attribs); + } + case "line": + return line(tree[2], tree[3], attribs); + case "hline": + return hline(tree[2], attribs); + case "vline": + return vline(tree[2], attribs); + case "polyline": + case "polygon": + return polygon(tree[2], attribs); + case "path": { + let segments: PathSegment[] = []; + for (let seg of tree[2]) { + switch (seg[0].toLowerCase()) { + case "s": + case "t": + // TODO compute reflected control point + // https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d#Cubic_B%C3%A9zier_Curve + // https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d#Quadratic_B%C3%A9zier_Curve + break; + default: + segments.push(seg); + } } + return path(segments, attribs); } - return path(segments, attribs); + case "text": + return text(tree[2], tree[3], attribs); + case "img": + return image(tree[2], tree[3].src, attribs); + case "points": + return points(tree[2], attribs.shape, attribs.size, attribs); + default: + return tree; } - case "text": - return text(tree[2], tree[3], attribs); - case "img": - return image(tree[2], tree[3].src, attribs); - case "points": - return points(tree[2], attribs.shape, attribs.size, attribs); - default: - return tree; - } -}; + }; -const convertAttribs = (attribs: any) => { - const res: any = convertTransforms(attribs); - for (let id in attribs) { - const v = attribs[id]; - if (ATTRIB_ALIASES[id]) { - res[ATTRIB_ALIASES[id]] = v; - } else { - switch (id) { - case "fill": - case "stroke": - res[id] = v[0] === "$" ? `url(#${v.substr(1)})` : v; - break; - case "font": { - const i = v.indexOf(" "); - res["font-size"] = v.substr(0, i); - res["font-family"] = v.substr(i + 1); - break; +const convertAttribs = + (attribs: any) => { + const res: any = convertTransforms(attribs); + for (let id in attribs) { + const v = attribs[id]; + if (ATTRIB_ALIASES[id]) { + res[ATTRIB_ALIASES[id]] = v; + } else { + switch (id) { + case "fill": + case "stroke": + res[id] = v[0] === "$" ? `url(#${v.substr(1)})` : v; + break; + case "font": { + const i = v.indexOf(" "); + res["font-size"] = v.substr(0, i); + res["font-family"] = v.substr(i + 1); + break; + } + case "align": + res["text-anchor"] = TEXT_ALIGN[v]; + break; + case "baseline": + // no SVG support? + case "filter": + // TODO needs to be translated into def first + // https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/filter + // https://developer.mozilla.org/en-US/docs/Web/SVG/Element/filter + case "transform": + case "translate": + case "rotate": + case "scale": + break; + default: + res[id] = v; } - case "align": - res["text-anchor"] = TEXT_ALIGN[v]; - break; - case "baseline": - // no SVG support? - case "filter": - // TODO needs to be translated into def first - // https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/filter - // https://developer.mozilla.org/en-US/docs/Web/SVG/Element/filter - case "transform": - case "translate": - case "rotate": - case "scale": - break; - default: - res[id] = v; } } - } - return res; -}; + return res; + }; -const convertTransforms = (attribs: any) => { - const res: any = {}; - if (!attribs) return res; - let v: any; - if ((v = attribs.transform) || - attribs.translate || - attribs.scale || - attribs.rotate) { +const convertTransforms = + (attribs: any) => { + const res: any = {}; + if (!attribs) return res; + let v: any; + if ((v = attribs.transform) || + attribs.translate || + attribs.scale || + attribs.rotate) { - const tx: string[] = []; - (v = attribs.transform) && tx.push(`matrix(${[...v].map(ff).join(" ")})`); - (v = attribs.translate) && tx.push(`translate(${ff(v[0])} ${ff(v[1])})`); - (v = attribs.rotate) && tx.push(`rotate(${ff(v * 180 / Math.PI)})`); - (v = attribs.scale) && - tx.push( - isArrayLike(v) ? - `scale(${ff(v[0])} ${ff(v[1])})` : - `scale(${ff(v)})` - ); - res.transform = tx.join(" "); - } - return res; -}; + const tx: string[] = []; + (v = attribs.transform) && tx.push(`matrix(${[...v].map(ff).join(" ")})`); + (v = attribs.translate) && tx.push(`translate(${ff(v[0])} ${ff(v[1])})`); + (v = attribs.rotate) && tx.push(`rotate(${ff(v * 180 / Math.PI)})`); + (v = attribs.scale) && + tx.push( + isArrayLike(v) ? + `scale(${ff(v[0])} ${ff(v[1])})` : + `scale(${ff(v)})` + ); + res.transform = tx.join(" "); + } + return res; + }; diff --git a/packages/hiccup-svg/src/defs.ts b/packages/hiccup-svg/src/defs.ts index fb03902b40..90966fb709 100644 --- a/packages/hiccup-svg/src/defs.ts +++ b/packages/hiccup-svg/src/defs.ts @@ -1,2 +1,3 @@ -export const defs = (...defs: any[]): any[] => - ["defs", {}, ...defs]; +export const defs = + (...defs: any[]): any[] => + ["defs", {}, ...defs]; diff --git a/packages/hiccup-svg/src/format.ts b/packages/hiccup-svg/src/format.ts index fd1359f41b..dceba79fbf 100644 --- a/packages/hiccup-svg/src/format.ts +++ b/packages/hiccup-svg/src/format.ts @@ -2,10 +2,14 @@ import { Vec2Like } from "./api"; let PRECISION = 2; -export const setPrecision = (n: number) => (PRECISION = n); +export const setPrecision = + (n: number) => (PRECISION = n); -export const ff = (x: number) => x.toFixed(PRECISION); +export const ff = + (x: number) => x.toFixed(PRECISION); -export const fpoint = (p: Vec2Like) => ff(p[0]) + "," + ff(p[1]); +export const fpoint = + (p: Vec2Like) => ff(p[0]) + "," + ff(p[1]); -export const fpoints = (pts: Vec2Like[], sep = " ") => pts ? pts.map(fpoint).join(sep) : ""; +export const fpoints = + (pts: Vec2Like[], sep = " ") => pts ? pts.map(fpoint).join(sep) : ""; diff --git a/packages/hiccup-svg/src/gradients.ts b/packages/hiccup-svg/src/gradients.ts index f754ab6fe1..cc2131f266 100644 --- a/packages/hiccup-svg/src/gradients.ts +++ b/packages/hiccup-svg/src/gradients.ts @@ -3,24 +3,26 @@ import { ff } from "./format"; const RE_ALPHA_COLOR = /(rgb|hsl)a\(([a-z0-9.-]+),([0-9.%]+),([0-9.%]+),([0-9.]+)\)/; -const gradient = (type: string, attribs: any, stops: GradientStop[]): any[] => - [ - type, - attribs, - ...stops.map(gradientStop) - ]; +const gradient = + (type: string, attribs: any, stops: GradientStop[]): any[] => + [ + type, + attribs, + ...stops.map(gradientStop) + ]; -const gradientStop = ([offset, col]: GradientStop) => { - // use stop-opacity attrib for safari compatibility - // https://stackoverflow.com/a/26220870/294515 - let opacity: string; - const parts = RE_ALPHA_COLOR.exec(col); - if (parts) { - col = `${parts[1]}(${parts[2]},${parts[3]},${parts[4]})`; - opacity = parts[5]; - } - return ["stop", { offset, "stop-color": col, "stop-opacity": opacity }]; -}; +const gradientStop = + ([offset, col]: GradientStop) => { + // use stop-opacity attrib for safari compatibility + // https://stackoverflow.com/a/26220870/294515 + let opacity: string; + const parts = RE_ALPHA_COLOR.exec(col); + if (parts) { + col = `${parts[1]}(${parts[2]},${parts[3]},${parts[4]})`; + opacity = parts[5]; + } + return ["stop", { offset, "stop-color": col, "stop-opacity": opacity }]; + }; export const linearGradient = ( id: string, diff --git a/packages/hiccup-svg/src/group.ts b/packages/hiccup-svg/src/group.ts index 3795760626..49129ef197 100644 --- a/packages/hiccup-svg/src/group.ts +++ b/packages/hiccup-svg/src/group.ts @@ -1,2 +1,3 @@ -export const group = (attr: any, ...body: any[]): any[] => - ["g", attr, ...body]; +export const group = + (attr: any, ...body: any[]): any[] => + ["g", attr, ...body]; diff --git a/packages/hiccup-svg/src/image.ts b/packages/hiccup-svg/src/image.ts index 02b18d907a..c3536c7aaf 100644 --- a/packages/hiccup-svg/src/image.ts +++ b/packages/hiccup-svg/src/image.ts @@ -1,10 +1,11 @@ import { Vec2Like } from "./api"; import { ff } from "./format"; -export const image = (pos: Vec2Like, url: string, attribs?: any): any[] => - ["image", { - // TODO replace w/ SVG2 `href` once Safari supports it - "xlink:href": url, - x: ff(pos[0]), y: ff(pos[1]), - ...attribs - }]; +export const image = + (pos: Vec2Like, url: string, attribs?: any): any[] => + ["image", { + // TODO replace w/ SVG2 `href` once Safari supports it + "xlink:href": url, + x: ff(pos[0]), y: ff(pos[1]), + ...attribs + }]; diff --git a/packages/hiccup-svg/src/line.ts b/packages/hiccup-svg/src/line.ts index 791009211d..de925124e1 100644 --- a/packages/hiccup-svg/src/line.ts +++ b/packages/hiccup-svg/src/line.ts @@ -1,17 +1,20 @@ import { Vec2Like } from "./api"; import { ff } from "./format"; -export const line = (a: Vec2Like, b: Vec2Like, attribs?: any): any[] => - ["line", { - x1: ff(a[0]), - y1: ff(a[1]), - x2: ff(b[0]), - y2: ff(b[1]), - ...attribs - }]; +export const line = + (a: Vec2Like, b: Vec2Like, attribs?: any): any[] => + ["line", { + x1: ff(a[0]), + y1: ff(a[1]), + x2: ff(b[0]), + y2: ff(b[1]), + ...attribs + }]; -export const hline = (y: number, attribs?: any) => - line([-1e6, y], [1e6, y], attribs); +export const hline = + (y: number, attribs?: any) => + line([-1e6, y], [1e6, y], attribs); -export const vline = (x: number, attribs?: any) => - line([x, -1e6], [x, 1e6], attribs); +export const vline = + (x: number, attribs?: any) => + line([x, -1e6], [x, 1e6], attribs); diff --git a/packages/hiccup-svg/src/path.ts b/packages/hiccup-svg/src/path.ts index daffdf041c..7ca825ff68 100644 --- a/packages/hiccup-svg/src/path.ts +++ b/packages/hiccup-svg/src/path.ts @@ -1,35 +1,36 @@ import { PathSegment } from "./api"; import { ff, fpoint, fpoints } from "./format"; -export const path = (segments: PathSegment[], attribs?: any): any[] => { - let res = []; - for (let seg of segments) { - res.push(seg[0]); - switch (seg[0].toLowerCase()) { - case "a": - res.push([ - ff(seg[1]), - ff(seg[2]), - ff(seg[3]), - seg[4] ? 1 : 0, - seg[5] ? 1 : 0, - ff(seg[6][0]), - ff(seg[6][1]), - ].join(",")); - break; - case "h": - case "v": - res.push(ff(seg[1])); - break; - case "m": - case "l": - res.push(fpoint(seg[1])); - break; - case "z": - break; - default: - res.push(fpoints((seg).slice(1), ",")); +export const path = + (segments: PathSegment[], attribs?: any): any[] => { + let res = []; + for (let seg of segments) { + res.push(seg[0]); + switch (seg[0].toLowerCase()) { + case "a": + res.push([ + ff(seg[1]), + ff(seg[2]), + ff(seg[3]), + seg[4] ? 1 : 0, + seg[5] ? 1 : 0, + ff(seg[6][0]), + ff(seg[6][1]), + ].join(",")); + break; + case "h": + case "v": + res.push(ff(seg[1])); + break; + case "m": + case "l": + res.push(fpoint(seg[1])); + break; + case "z": + break; + default: + res.push(fpoints((seg).slice(1), ",")); + } } - } - return ["path", { ...attribs, d: res.join("") }]; -}; + return ["path", { ...attribs, d: res.join("") }]; + }; diff --git a/packages/hiccup-svg/src/points.ts b/packages/hiccup-svg/src/points.ts index bcf110be8d..9e27d618b5 100644 --- a/packages/hiccup-svg/src/points.ts +++ b/packages/hiccup-svg/src/points.ts @@ -12,24 +12,25 @@ import { ff } from "./format"; * @param size * @param attribs */ -export const points = (pts: Iterable, shape: string, size = 1, attribs?: any): any[] => { - const group = ["g", attribs]; - let href: string; - if (!shape || shape[0] !== "#") { - const r = ff(size); - href = "_" + ((Math.random() * 1e6) | 0).toString(36); - group.push(["g", { opacity: 0 }, - shape === "circle" ? - ["circle", { id: href, cx: 0, cy: 0, r: r }] : - ["rect", { id: href, x: 0, y: 0, width: r, height: r }] - ]); - href = "#" + href; - } else { - href = shape; - } - for (let p of pts) { - // TODO replace w/ SVG2 `href` once Safari supports it - group.push(["use", { "xlink:href": href, x: ff(p[0]), y: ff(p[1]) }]); - } - return group; -}; +export const points = + (pts: Iterable, shape: string, size = 1, attribs?: any): any[] => { + const group = ["g", attribs]; + let href: string; + if (!shape || shape[0] !== "#") { + const r = ff(size); + href = "_" + ((Math.random() * 1e6) | 0).toString(36); + group.push(["g", { opacity: 0 }, + shape === "circle" ? + ["circle", { id: href, cx: 0, cy: 0, r: r }] : + ["rect", { id: href, x: 0, y: 0, width: r, height: r }] + ]); + href = "#" + href; + } else { + href = shape; + } + for (let p of pts) { + // TODO replace w/ SVG2 `href` once Safari supports it + group.push(["use", { "xlink:href": href, x: ff(p[0]), y: ff(p[1]) }]); + } + return group; + }; diff --git a/packages/hiccup-svg/src/polygon.ts b/packages/hiccup-svg/src/polygon.ts index 566b13786a..f3b593ae2f 100644 --- a/packages/hiccup-svg/src/polygon.ts +++ b/packages/hiccup-svg/src/polygon.ts @@ -1,5 +1,6 @@ import { Vec2Like } from "./api"; import { fpoints } from "./format"; -export const polygon = (pts: Vec2Like[], attribs?: any): any[] => - ["polygon", { points: fpoints(pts), ...attribs }]; +export const polygon = + (pts: Vec2Like[], attribs?: any): any[] => + ["polygon", { points: fpoints(pts), ...attribs }]; diff --git a/packages/hiccup-svg/src/polyline.ts b/packages/hiccup-svg/src/polyline.ts index d27a056443..5ea000444a 100644 --- a/packages/hiccup-svg/src/polyline.ts +++ b/packages/hiccup-svg/src/polyline.ts @@ -1,5 +1,6 @@ import { Vec2Like } from "./api"; import { fpoints } from "./format"; -export const polyline = (pts: Vec2Like[], attribs?: any): any[] => - ["polyline", { points: fpoints(pts), ...attribs }]; +export const polyline = + (pts: Vec2Like[], attribs?: any): any[] => + ["polyline", { points: fpoints(pts), ...attribs }]; diff --git a/packages/hiccup-svg/src/rect.ts b/packages/hiccup-svg/src/rect.ts index 65decabbc3..81338dcd45 100644 --- a/packages/hiccup-svg/src/rect.ts +++ b/packages/hiccup-svg/src/rect.ts @@ -1,8 +1,9 @@ import { Vec2Like } from "./api"; import { ff } from "./format"; -export const rect = (p: Vec2Like, width: number, height: number, attribs?: any) => - roundedRect(p, width, height, 0, 0, attribs); +export const rect = + (p: Vec2Like, width: number, height: number, attribs?: any) => + roundedRect(p, width, height, 0, 0, attribs); export const roundedRect = ( p: Vec2Like, diff --git a/packages/hiccup-svg/src/svg.ts b/packages/hiccup-svg/src/svg.ts index ba20816ee1..365191fce6 100644 --- a/packages/hiccup-svg/src/svg.ts +++ b/packages/hiccup-svg/src/svg.ts @@ -1,4 +1,4 @@ -import { SVG_NS, XLINK_NS } from "@thi.ng/hiccup/api"; +import { SVG_NS, XLINK_NS } from "@thi.ng/hiccup"; /** * Defines an root element with default XML namespaces. By default @@ -8,10 +8,11 @@ import { SVG_NS, XLINK_NS } from "@thi.ng/hiccup/api"; * @param attribs * @param body */ -export const svg = (attribs: any, ...body: any[]): any[] => - ["svg", { - version: "1.1", - xmlns: SVG_NS, - "xmlns:xlink": XLINK_NS, - ...attribs - }, ...body]; +export const svg = + (attribs: any, ...body: any[]): any[] => + ["svg", { + version: "1.1", + xmlns: SVG_NS, + "xmlns:xlink": XLINK_NS, + ...attribs + }, ...body]; diff --git a/packages/hiccup-svg/src/text.ts b/packages/hiccup-svg/src/text.ts index b453a33c58..9ee29591f9 100644 --- a/packages/hiccup-svg/src/text.ts +++ b/packages/hiccup-svg/src/text.ts @@ -1,9 +1,10 @@ import { Vec2Like } from "./api"; import { ff } from "./format"; -export const text = (p: Vec2Like, body: string, attribs?: any): any[] => - ["text", { - x: ff(p[0]), - y: ff(p[1]), - ...attribs - }, body]; +export const text = + (p: Vec2Like, body: string, attribs?: any): any[] => + ["text", { + x: ff(p[0]), + y: ff(p[1]), + ...attribs + }, body]; diff --git a/packages/hiccup-svg/test/tsconfig.json b/packages/hiccup-svg/test/tsconfig.json index c93bb84899..2c9c12a650 100644 --- a/packages/hiccup-svg/test/tsconfig.json +++ b/packages/hiccup-svg/test/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../../tsconfig.json", "compilerOptions": { "outDir": "../build", - "module": "es6", - "target": "es6" + "module": "commonjs", }, "include": [ "./**/*.ts", diff --git a/packages/hiccup/package.json b/packages/hiccup/package.json index 8c5b64ba68..4f22894840 100644 --- a/packages/hiccup/package.json +++ b/packages/hiccup/package.json @@ -2,7 +2,9 @@ "name": "@thi.ng/hiccup", "version": "2.7.2", "description": "HTML/SVG/XML serialization of nested data structures, iterables & closures", - "main": "./index.js", + "module": "./index.js", + "main": "./lib/index.js", + "umd:main": "./lib/index.umd.js", "typings": "./index.d.ts", "repository": { "type": "git", @@ -12,12 +14,14 @@ "author": "Karsten Schmidt ", "license": "Apache-2.0", "scripts": { - "build": "yarn clean && tsc --declaration", - "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc", + "build": "yarn clean && yarn build:es6 && yarn build:bundle", + "build:es6": "tsc --declaration", + "build:bundle": "../../scripts/bundle-module hiccup checks errors", + "test": "rimraf build && tsc -p test/tsconfig.json && nyc mocha build/test/*.js", + "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc lib", "cover": "yarn test && nyc report --reporter=lcov", "doc": "node_modules/.bin/typedoc --mode modules --out doc src", - "pub": "yarn build && yarn publish --access public", - "test": "rimraf build && tsc -p test && nyc mocha build/test/*.js" + "pub": "yarn build && yarn publish --access public" }, "devDependencies": { "@thi.ng/atom": "^1.5.8", @@ -48,5 +52,6 @@ ], "publishConfig": { "access": "public" - } + }, + "sideEffects": false } \ No newline at end of file diff --git a/packages/hiccup/src/css.ts b/packages/hiccup/src/css.ts index dee596eb47..afb0f76a07 100644 --- a/packages/hiccup/src/css.ts +++ b/packages/hiccup/src/css.ts @@ -1,4 +1,4 @@ -import { isFunction } from "@thi.ng/checks/is-function"; +import { isFunction } from "@thi.ng/checks"; export const css = (rules: any) => { diff --git a/packages/hiccup/src/deref.ts b/packages/hiccup/src/deref.ts index b6b18427a6..76bf890fc3 100644 --- a/packages/hiccup/src/deref.ts +++ b/packages/hiccup/src/deref.ts @@ -1,4 +1,4 @@ -import { implementsFunction } from "@thi.ng/checks/implements-function"; +import { implementsFunction } from "@thi.ng/checks"; /** * Takes an arbitrary `ctx` object and array of `keys`. Attempts to call diff --git a/packages/hiccup/src/serialize.ts b/packages/hiccup/src/serialize.ts index a776ef49d2..801be8ac6d 100644 --- a/packages/hiccup/src/serialize.ts +++ b/packages/hiccup/src/serialize.ts @@ -1,9 +1,11 @@ -import { implementsFunction } from "@thi.ng/checks/implements-function"; -import { isFunction } from "@thi.ng/checks/is-function"; -import { isNotStringAndIterable } from "@thi.ng/checks/is-not-string-iterable"; -import { isPlainObject } from "@thi.ng/checks/is-plain-object"; -import { isString } from "@thi.ng/checks/is-string"; -import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; +import { + implementsFunction, + isFunction, + isNotStringAndIterable, + isPlainObject, + isString +} from "@thi.ng/checks"; +import { illegalArgs } from "@thi.ng/errors"; import { COMMENT, NO_SPANS, diff --git a/packages/hiccup/test/tsconfig.json b/packages/hiccup/test/tsconfig.json index c93bb84899..2c9c12a650 100644 --- a/packages/hiccup/test/tsconfig.json +++ b/packages/hiccup/test/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../../tsconfig.json", "compilerOptions": { "outDir": "../build", - "module": "es6", - "target": "es6" + "module": "commonjs", }, "include": [ "./**/*.ts", diff --git a/packages/iges/package.json b/packages/iges/package.json index aa21eedbc4..7d1d7e824d 100644 --- a/packages/iges/package.json +++ b/packages/iges/package.json @@ -2,7 +2,9 @@ "name": "@thi.ng/iges", "version": "0.2.30", "description": "IGES 5.3 serializer for (currently only) polygonal geometry, both open & closed", - "main": "./index.js", + "module": "./index.js", + "main": "./lib/index.js", + "umd:main": "./lib/index.umd.js", "typings": "./index.d.ts", "repository": { "type": "git", @@ -12,12 +14,14 @@ "author": "Karsten Schmidt ", "license": "Apache-2.0", "scripts": { - "build": "yarn clean && tsc --declaration", - "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc", + "build": "yarn clean && yarn build:es6 && yarn build:bundle", + "build:es6": "tsc --declaration", + "build:bundle": "../../scripts/bundle-module iges api defmulti strings transducers", + "test": "rimraf build && tsc -p test/tsconfig.json && nyc mocha build/test/*.js", + "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc lib", "cover": "yarn test && nyc report --reporter=lcov", "doc": "node_modules/.bin/typedoc --mode modules --out doc src", - "pub": "yarn build && yarn publish --access public", - "test": "rimraf build && tsc -p test && nyc mocha build/test/*.js" + "pub": "yarn build && yarn publish --access public" }, "devDependencies": { "@types/mocha": "^5.2.5", @@ -44,5 +48,6 @@ ], "publishConfig": { "access": "public" - } + }, + "sideEffects": false } \ No newline at end of file diff --git a/packages/iges/src/index.ts b/packages/iges/src/index.ts index ad47f45b24..0323c74ba3 100644 --- a/packages/iges/src/index.ts +++ b/packages/iges/src/index.ts @@ -1,16 +1,16 @@ import { defmulti } from "@thi.ng/defmulti"; -import { float } from "@thi.ng/strings/float"; -import { padLeft } from "@thi.ng/strings/pad-left"; -import { padRight } from "@thi.ng/strings/pad-right"; -import { comp } from "@thi.ng/transducers/func/comp"; -import { wrap } from "@thi.ng/transducers/iter/wrap"; -import { push } from "@thi.ng/transducers/rfn/push"; -import { transduce } from "@thi.ng/transducers/transduce"; -import { map } from "@thi.ng/transducers/xform/map"; -import { mapIndexed } from "@thi.ng/transducers/xform/map-indexed"; -import { mapcat } from "@thi.ng/transducers/xform/mapcat"; -import { partition } from "@thi.ng/transducers/xform/partition"; -import { wordWrap } from "@thi.ng/transducers/xform/word-wrap"; +import { float, padLeft, padRight } from "@thi.ng/strings"; +import { + comp, + map, + mapcat, + mapIndexed, + partition, + push, + transduce, + wordWrap, + wrap +} from "@thi.ng/transducers"; import { DEFAULT_GLOBALS, DictEntry, diff --git a/packages/iges/test/tsconfig.json b/packages/iges/test/tsconfig.json index c93bb84899..2c9c12a650 100644 --- a/packages/iges/test/tsconfig.json +++ b/packages/iges/test/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../../tsconfig.json", "compilerOptions": { "outDir": "../build", - "module": "es6", - "target": "es6" + "module": "commonjs", }, "include": [ "./**/*.ts", diff --git a/packages/interceptors/package.json b/packages/interceptors/package.json index 1447b62f63..0df9b10a38 100644 --- a/packages/interceptors/package.json +++ b/packages/interceptors/package.json @@ -2,7 +2,9 @@ "name": "@thi.ng/interceptors", "version": "1.9.2", "description": "Interceptor based event bus, side effect & immutable state handling", - "main": "./index.js", + "module": "./index.js", + "main": "./lib/index.js", + "umd:main": "./lib/index.umd.js", "typings": "./index.d.ts", "repository": { "type": "git", @@ -12,12 +14,14 @@ "author": "Karsten Schmidt ", "license": "Apache-2.0", "scripts": { - "build": "yarn clean && tsc --declaration", - "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc", + "build": "yarn clean && yarn build:es6 && yarn build:bundle", + "build:es6": "tsc --declaration", + "build:bundle": "../../scripts/bundle-module interceptors api atom checks errors paths", + "test": "rimraf build && tsc -p test/tsconfig.json && nyc mocha build/test/*.js", + "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc lib", "cover": "yarn test && nyc report --reporter=lcov", "doc": "node_modules/.bin/typedoc --mode modules --out doc src", - "pub": "yarn build && yarn publish --access public", - "test": "rimraf build && tsc -p test && nyc mocha build/test/*.js" + "pub": "yarn build && yarn publish --access public" }, "devDependencies": { "@types/mocha": "^5.2.5", @@ -40,5 +44,6 @@ ], "publishConfig": { "access": "public" - } + }, + "sideEffects": false } \ No newline at end of file diff --git a/packages/interceptors/src/api.ts b/packages/interceptors/src/api.ts index 94718cd81a..f95cb5f824 100644 --- a/packages/interceptors/src/api.ts +++ b/packages/interceptors/src/api.ts @@ -1,4 +1,4 @@ -import { ReadonlyAtom } from "@thi.ng/atom/api"; +import { ReadonlyAtom } from "@thi.ng/atom"; export type InterceptorFn = (state: any, e: Event, bus?: IDispatch, ctx?: InterceptorContext) => InterceptorContext | void; export type InterceptorPredicate = (state: any, e: Event, bus?: IDispatch, ctx?: InterceptorContext) => boolean; diff --git a/packages/interceptors/src/event-bus.ts b/packages/interceptors/src/event-bus.ts index ce00512b2c..8fd413b629 100644 --- a/packages/interceptors/src/event-bus.ts +++ b/packages/interceptors/src/event-bus.ts @@ -1,13 +1,13 @@ -import { IDeref, IObjectOf } from "@thi.ng/api/api"; -import { IAtom } from "@thi.ng/atom/api"; -import { Atom } from "@thi.ng/atom/atom"; -import { implementsFunction } from "@thi.ng/checks/implements-function"; -import { isArray } from "@thi.ng/checks/is-array"; -import { isFunction } from "@thi.ng/checks/is-function"; -import { isPromise } from "@thi.ng/checks/is-promise"; -import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; +import { IDeref, IObjectOf } from "@thi.ng/api"; +import { Atom, IAtom } from "@thi.ng/atom"; +import { + implementsFunction, + isArray, + isFunction, + isPromise +} from "@thi.ng/checks"; +import { illegalArgs } from "@thi.ng/errors"; import { setIn, updateIn } from "@thi.ng/paths"; - import * as api from "./api"; const FX_CANCEL = api.FX_CANCEL; diff --git a/packages/interceptors/src/interceptors.ts b/packages/interceptors/src/interceptors.ts index e085687a4d..6361d7c5f4 100644 --- a/packages/interceptors/src/interceptors.ts +++ b/packages/interceptors/src/interceptors.ts @@ -14,7 +14,6 @@ import { InterceptorPredicate } from "./api"; - /** * Debug interceptor to log the current event to the console. */ diff --git a/packages/interceptors/test/tsconfig.json b/packages/interceptors/test/tsconfig.json index c93bb84899..2c9c12a650 100644 --- a/packages/interceptors/test/tsconfig.json +++ b/packages/interceptors/test/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../../tsconfig.json", "compilerOptions": { "outDir": "../build", - "module": "es6", - "target": "es6" + "module": "commonjs", }, "include": [ "./**/*.ts", diff --git a/packages/intervals/package.json b/packages/intervals/package.json index 0172b565e3..5def147018 100644 --- a/packages/intervals/package.json +++ b/packages/intervals/package.json @@ -2,7 +2,9 @@ "name": "@thi.ng/intervals", "version": "0.2.0", "description": "Closed/open/semi-open interval data type, queries & operations", - "main": "./index.js", + "module": "./index.js", + "main": "./lib/index.js", + "umd:main": "./lib/index.umd.js", "typings": "./index.d.ts", "repository": { "type": "git", @@ -12,12 +14,14 @@ "author": "Karsten Schmidt ", "license": "Apache-2.0", "scripts": { - "build": "yarn clean && tsc --declaration", - "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc", + "build": "yarn clean && yarn build:es6 && yarn build:bundle", + "build:es6": "tsc --declaration", + "build:bundle": "../../scripts/bundle-module intervals api errors", + "test": "rimraf build && tsc -p test/tsconfig.json && nyc mocha build/test/*.js", + "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc lib", "cover": "yarn test && nyc report --reporter=lcov", "doc": "node_modules/.bin/typedoc --mode modules --out doc src", - "pub": "yarn build && yarn publish --access public", - "test": "rimraf build && tsc -p test && nyc mocha build/test/*.js" + "pub": "yarn build && yarn publish --access public" }, "devDependencies": { "@types/mocha": "^5.2.5", @@ -45,5 +49,6 @@ ], "publishConfig": { "access": "public" - } + }, + "sideEffects": false } \ No newline at end of file diff --git a/packages/intervals/src/index.ts b/packages/intervals/src/index.ts index 9b3abe4ae7..72568bc93f 100644 --- a/packages/intervals/src/index.ts +++ b/packages/intervals/src/index.ts @@ -1,5 +1,11 @@ -import { ICopy, IEquiv, IContains, Fn, ICompare } from "@thi.ng/api/api"; -import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; +import { + Fn, + ICompare, + IContains, + ICopy, + IEquiv +} from "@thi.ng/api"; +import { illegalArgs } from "@thi.ng/errors"; export const enum Classifier { DISJOINT_LEFT, diff --git a/packages/intervals/test/tsconfig.json b/packages/intervals/test/tsconfig.json index c93bb84899..2c9c12a650 100644 --- a/packages/intervals/test/tsconfig.json +++ b/packages/intervals/test/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../../tsconfig.json", "compilerOptions": { "outDir": "../build", - "module": "es6", - "target": "es6" + "module": "commonjs", }, "include": [ "./**/*.ts", diff --git a/packages/iterators/package.json b/packages/iterators/package.json index f07d61f1b5..c367001ae8 100644 --- a/packages/iterators/package.json +++ b/packages/iterators/package.json @@ -2,7 +2,9 @@ "name": "@thi.ng/iterators", "version": "4.2.4", "description": "clojure.core inspired, composable ES6 iterators & generators", - "main": "./index.js", + "module": "./index.js", + "main": "./lib/index.js", + "umd:main": "./lib/index.umd.js", "typings": "./index.d.ts", "repository": { "type": "git", @@ -12,12 +14,14 @@ "author": "Karsten Schmidt ", "license": "Apache-2.0", "scripts": { - "build": "yarn clean && tsc --declaration", - "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc", + "build": "yarn clean && yarn build:es6 && yarn build:bundle", + "build:es6": "tsc --declaration", + "build:bundle": "../../scripts/bundle-module iterators api dcons errors", + "test": "rimraf build && tsc -p test/tsconfig.json && nyc mocha build/test/*.js", + "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc lib", "cover": "yarn test && nyc report --reporter=lcov", "doc": "node_modules/.bin/typedoc --mode modules --out doc src", - "pub": "yarn build && yarn publish --access public", - "test": "rimraf build && tsc -p test && nyc mocha build/test/*.js" + "pub": "yarn build && yarn publish --access public" }, "devDependencies": { "@types/mocha": "^5.2.5", @@ -45,5 +49,6 @@ ], "publishConfig": { "access": "public" - } + }, + "sideEffects": false } \ No newline at end of file diff --git a/packages/iterators/src/dedupe-with.ts b/packages/iterators/src/dedupe-with.ts index 7e3f603e24..45a6431d57 100644 --- a/packages/iterators/src/dedupe-with.ts +++ b/packages/iterators/src/dedupe-with.ts @@ -1,5 +1,4 @@ -import { Predicate2 } from "@thi.ng/api/api"; - +import { Predicate2 } from "@thi.ng/api"; import { iterator } from "./iterator"; export function* dedupeWith(equiv: Predicate2, input: Iterable) { diff --git a/packages/iterators/src/drop-while.ts b/packages/iterators/src/drop-while.ts index b3711238b1..21d94b41c7 100644 --- a/packages/iterators/src/drop-while.ts +++ b/packages/iterators/src/drop-while.ts @@ -1,5 +1,4 @@ -import { Predicate } from "@thi.ng/api/api"; - +import { Predicate } from "@thi.ng/api"; import { ensureIterator } from "./ensure"; export function* dropWhile(pred: Predicate, input: Iterable) { diff --git a/packages/iterators/src/ensure.ts b/packages/iterators/src/ensure.ts index e4a2171a25..6dfe8a38f1 100644 --- a/packages/iterators/src/ensure.ts +++ b/packages/iterators/src/ensure.ts @@ -1,5 +1,4 @@ -import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; - +import { illegalArgs } from "@thi.ng/errors"; import { iterator } from "./iterator"; export const ensureIterable = diff --git a/packages/iterators/src/every.ts b/packages/iterators/src/every.ts index 241e5a3907..c63a6cfe98 100644 --- a/packages/iterators/src/every.ts +++ b/packages/iterators/src/every.ts @@ -1,5 +1,4 @@ -import { Predicate } from "@thi.ng/api/api"; - +import { Predicate } from "@thi.ng/api"; import { iterator } from "./iterator"; export const every = diff --git a/packages/iterators/src/filter.ts b/packages/iterators/src/filter.ts index 91b41b5332..566c288ee5 100644 --- a/packages/iterators/src/filter.ts +++ b/packages/iterators/src/filter.ts @@ -1,5 +1,4 @@ -import { Predicate } from "@thi.ng/api/api"; - +import { Predicate } from "@thi.ng/api"; import { iterator } from "./iterator"; export function* filter(pred: Predicate, input: Iterable) { diff --git a/packages/iterators/src/fork.ts b/packages/iterators/src/fork.ts index 4c083db35f..54e80ab5bc 100644 --- a/packages/iterators/src/fork.ts +++ b/packages/iterators/src/fork.ts @@ -1,5 +1,4 @@ import { DCons } from "@thi.ng/dcons"; - import { iterator } from "./iterator"; export const fork = diff --git a/packages/iterators/src/interleave.ts b/packages/iterators/src/interleave.ts index bc830f399b..890c10a828 100644 --- a/packages/iterators/src/interleave.ts +++ b/packages/iterators/src/interleave.ts @@ -1,5 +1,4 @@ -import { illegalArity } from "@thi.ng/errors/illegal-arity"; - +import { illegalArity } from "@thi.ng/errors"; import { cycle } from "./cycle"; import { iterator } from "./iterator"; import { map } from "./map"; diff --git a/packages/iterators/src/partition.ts b/packages/iterators/src/partition.ts index 0a5e110e79..ed8fdfa439 100644 --- a/packages/iterators/src/partition.ts +++ b/packages/iterators/src/partition.ts @@ -1,5 +1,4 @@ -import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; - +import { illegalArgs } from "@thi.ng/errors"; import { consume } from "./consume"; import { iterator } from "./iterator"; diff --git a/packages/iterators/src/some.ts b/packages/iterators/src/some.ts index a526f90ceb..21490541c6 100644 --- a/packages/iterators/src/some.ts +++ b/packages/iterators/src/some.ts @@ -1,5 +1,4 @@ -import { Predicate } from "@thi.ng/api/api"; - +import { Predicate } from "@thi.ng/api"; import { iterator } from "./iterator"; export const some = diff --git a/packages/iterators/src/take-while.ts b/packages/iterators/src/take-while.ts index e7dcfc106c..5390b8953b 100644 --- a/packages/iterators/src/take-while.ts +++ b/packages/iterators/src/take-while.ts @@ -1,5 +1,4 @@ -import { Predicate } from "@thi.ng/api/api"; - +import { Predicate } from "@thi.ng/api"; import { iterator } from "./iterator"; export function* takeWhile(pred: Predicate, input: Iterable) { diff --git a/packages/iterators/src/walk.ts b/packages/iterators/src/walk.ts index af21b87c15..177dd4fec5 100644 --- a/packages/iterators/src/walk.ts +++ b/packages/iterators/src/walk.ts @@ -1,6 +1,6 @@ +import { Fn } from "@thi.ng/api"; import { iterator, maybeIterator } from "./iterator"; import { maybeObjectIterator } from "./object-iterator"; -import { Fn } from "@thi.ng/api/api"; export const walkable = (x) => diff --git a/packages/iterators/test/tsconfig.json b/packages/iterators/test/tsconfig.json index c93bb84899..2c9c12a650 100644 --- a/packages/iterators/test/tsconfig.json +++ b/packages/iterators/test/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../../tsconfig.json", "compilerOptions": { "outDir": "../build", - "module": "es6", - "target": "es6" + "module": "commonjs", }, "include": [ "./**/*.ts", diff --git a/packages/malloc/package.json b/packages/malloc/package.json index 3ea6a55f0d..2fff668e8a 100644 --- a/packages/malloc/package.json +++ b/packages/malloc/package.json @@ -2,7 +2,9 @@ "name": "@thi.ng/malloc", "version": "0.2.1", "description": "ArrayBuffer based malloc() impl for hybrid JS/WASM use cases, based on thi.ng/tinyalloc", - "main": "./index.js", + "module": "./index.js", + "main": "./lib/index.js", + "umd:main": "./lib/index.umd.js", "typings": "./index.d.ts", "repository": { "type": "git", @@ -12,12 +14,14 @@ "author": "Karsten Schmidt ", "license": "Apache-2.0", "scripts": { - "build": "yarn clean && tsc --declaration", - "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc", + "build": "yarn clean && yarn build:es6 && yarn build:bundle", + "build:es6": "tsc --declaration", + "build:bundle": "../../scripts/bundle-module malloc api binary checks errors", + "test": "rimraf build && tsc -p test/tsconfig.json && nyc mocha build/test/*.js", + "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc lib", "cover": "yarn test && nyc report --reporter=lcov", "doc": "node_modules/.bin/typedoc --mode modules --out doc src", - "pub": "yarn build && yarn publish --access public", - "test": "rimraf build && tsc -p test && nyc mocha build/test/*.js" + "pub": "yarn build && yarn publish --access public" }, "devDependencies": { "@types/mocha": "^5.2.5", @@ -39,5 +43,6 @@ ], "publishConfig": { "access": "public" - } + }, + "sideEffects": false } \ No newline at end of file diff --git a/packages/malloc/src/index.ts b/packages/malloc/src/index.ts index b99cca4c6f..067f6e8cf3 100644 --- a/packages/malloc/src/index.ts +++ b/packages/malloc/src/index.ts @@ -1,7 +1,7 @@ import { IObjectOf, IRelease, TypedArray } from "@thi.ng/api"; -import { align } from "@thi.ng/binary/align"; -import { isNumber } from "@thi.ng/checks/is-number"; -import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; +import { align } from "@thi.ng/binary"; +import { isNumber } from "@thi.ng/checks"; +import { illegalArgs } from "@thi.ng/errors"; export const enum Type { U8, diff --git a/packages/malloc/test/tsconfig.json b/packages/malloc/test/tsconfig.json index c93bb84899..2c9c12a650 100644 --- a/packages/malloc/test/tsconfig.json +++ b/packages/malloc/test/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../../tsconfig.json", "compilerOptions": { "outDir": "../build", - "module": "es6", - "target": "es6" + "module": "commonjs", }, "include": [ "./**/*.ts", diff --git a/packages/math/package.json b/packages/math/package.json index ce3f6a78f6..a7becea398 100644 --- a/packages/math/package.json +++ b/packages/math/package.json @@ -2,7 +2,9 @@ "name": "@thi.ng/math", "version": "0.2.2", "description": "Assorted common math functions & utilities", - "main": "./index.js", + "module": "./index.js", + "main": "./lib/index.js", + "umd:main": "./lib/index.umd.js", "typings": "./index.d.ts", "repository": { "type": "git", @@ -12,12 +14,14 @@ "author": "Karsten Schmidt ", "license": "Apache-2.0", "scripts": { - "build": "yarn clean && tsc --declaration", - "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc", + "build": "yarn clean && yarn build:es6 && yarn build:bundle", + "build:es6": "tsc --declaration", + "build:bundle": "../../scripts/bundle-module math", + "test": "rimraf build && tsc -p test/tsconfig.json && nyc mocha build/test/*.js", + "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc lib", "cover": "yarn test && nyc report --reporter=lcov", "doc": "node_modules/.bin/typedoc --mode modules --out doc src", - "pub": "yarn build && yarn publish --access public", - "test": "rimraf build && tsc -p test && nyc mocha build/test/*.js" + "pub": "yarn build && yarn publish --access public" }, "devDependencies": { "@types/mocha": "^5.2.5", @@ -38,5 +42,6 @@ ], "publishConfig": { "access": "public" - } + }, + "sideEffects": false } \ No newline at end of file diff --git a/packages/math/test/tsconfig.json b/packages/math/test/tsconfig.json index c93bb84899..2c9c12a650 100644 --- a/packages/math/test/tsconfig.json +++ b/packages/math/test/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../../tsconfig.json", "compilerOptions": { "outDir": "../build", - "module": "es6", - "target": "es6" + "module": "commonjs", }, "include": [ "./**/*.ts", diff --git a/packages/memoize/package.json b/packages/memoize/package.json index 16051bbd60..c3743dea12 100644 --- a/packages/memoize/package.json +++ b/packages/memoize/package.json @@ -2,7 +2,9 @@ "name": "@thi.ng/memoize", "version": "0.2.6", "description": "Function memoization with configurable caches", - "main": "./index.js", + "module": "./index.js", + "main": "./lib/index.js", + "umd:main": "./lib/index.umd.js", "typings": "./index.d.ts", "repository": { "type": "git", @@ -12,12 +14,14 @@ "author": "Karsten Schmidt ", "license": "Apache-2.0", "scripts": { - "build": "yarn clean && tsc --declaration", - "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc", + "build": "yarn clean && yarn build:es6 && yarn build:bundle", + "build:es6": "tsc --declaration", + "build:bundle": "../../scripts/bundle-module memoize api", + "test": "rimraf build && tsc -p test/tsconfig.json && nyc mocha build/test/*.js", + "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc lib", "cover": "yarn test && nyc report --reporter=lcov", "doc": "node_modules/.bin/typedoc --mode modules --out doc src", - "pub": "yarn build && yarn publish --access public", - "test": "rimraf build && tsc -p test && nyc mocha build/test/*.js" + "pub": "yarn build && yarn publish --access public" }, "devDependencies": { "@types/mocha": "^5.2.5", @@ -39,5 +43,6 @@ ], "publishConfig": { "access": "public" - } + }, + "sideEffects": false } \ No newline at end of file diff --git a/packages/memoize/src/defonce.ts b/packages/memoize/src/defonce.ts index 9af67bbe56..cf28036be7 100644 --- a/packages/memoize/src/defonce.ts +++ b/packages/memoize/src/defonce.ts @@ -1,4 +1,4 @@ -import { Fn0 } from "@thi.ng/memoize/src/api"; +import { Fn0 } from "./api"; const cache: any = {}; diff --git a/packages/memoize/src/memoizej.ts b/packages/memoize/src/memoizej.ts index e3cb361313..cb7508be4e 100644 --- a/packages/memoize/src/memoizej.ts +++ b/packages/memoize/src/memoizej.ts @@ -1,4 +1,4 @@ -import { IObjectOf } from "@thi.ng/api/api"; +import { IObjectOf } from "@thi.ng/api"; import { Fn1, Fn2, Fn3, Fn4, FnAny } from "./api"; /** diff --git a/packages/memoize/test/tsconfig.json b/packages/memoize/test/tsconfig.json index c93bb84899..2c9c12a650 100644 --- a/packages/memoize/test/tsconfig.json +++ b/packages/memoize/test/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../../tsconfig.json", "compilerOptions": { "outDir": "../build", - "module": "es6", - "target": "es6" + "module": "commonjs", }, "include": [ "./**/*.ts", diff --git a/packages/morton/package.json b/packages/morton/package.json index 2985274ac8..9e51bf51b3 100644 --- a/packages/morton/package.json +++ b/packages/morton/package.json @@ -2,7 +2,9 @@ "name": "@thi.ng/morton", "version": "0.2.2", "description": "Z-order-curve / Morton encoding & decoding for 1D, 2D, 3D", - "main": "./index.js", + "module": "./index.js", + "main": "./lib/index.js", + "umd:main": "./lib/index.umd.js", "typings": "./index.d.ts", "repository": { "type": "git", @@ -12,12 +14,14 @@ "author": "Karsten Schmidt ", "license": "Apache-2.0", "scripts": { - "build": "yarn clean && tsc --declaration", - "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc", + "build": "yarn clean && yarn build:es6 && yarn build:bundle", + "build:es6": "tsc --declaration", + "build:bundle": "../../scripts/bundle-module morton binary errors math", + "test": "rimraf build && tsc -p test/tsconfig.json && nyc mocha build/test/*.js", + "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc lib", "cover": "yarn test && nyc report --reporter=lcov", "doc": "node_modules/.bin/typedoc --mode modules --out doc src", - "pub": "yarn build && yarn publish --access public", - "test": "rimraf build && tsc -p test && nyc mocha build/test/*.js" + "pub": "yarn build && yarn publish --access public" }, "devDependencies": { "@types/mocha": "^5.2.5", @@ -43,5 +47,6 @@ ], "publishConfig": { "access": "public" - } + }, + "sideEffects": false } \ No newline at end of file diff --git a/packages/morton/src/index.ts b/packages/morton/src/index.ts index c368dea5b7..8cc52f4ce5 100644 --- a/packages/morton/src/index.ts +++ b/packages/morton/src/index.ts @@ -1,8 +1,6 @@ -import { MASKS } from "@thi.ng/binary/api"; -import { ceilPow2 } from "@thi.ng/binary/pow"; -import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; -import { fit, fit01 } from "@thi.ng/math/fit"; -import { inRange } from "@thi.ng/math/interval"; +import { ceilPow2, MASKS } from "@thi.ng/binary"; +import { illegalArgs } from "@thi.ng/errors"; +import { fit, fit01, inRange } from "@thi.ng/math"; const MIN = [0, 0, 0]; const MAX = [1, 1, 1]; diff --git a/packages/morton/test/tsconfig.json b/packages/morton/test/tsconfig.json index c93bb84899..2c9c12a650 100644 --- a/packages/morton/test/tsconfig.json +++ b/packages/morton/test/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../../tsconfig.json", "compilerOptions": { "outDir": "../build", - "module": "es6", - "target": "es6" + "module": "commonjs", }, "include": [ "./**/*.ts", diff --git a/packages/paths/package.json b/packages/paths/package.json index 87e88244f9..4812cd6513 100644 --- a/packages/paths/package.json +++ b/packages/paths/package.json @@ -4,6 +4,7 @@ "description": "immutable, optimized path-based object property / array accessors", "module": "./index.js", "main": "./lib/index.js", + "umd:main": "./lib/index.umd.js", "typings": "./index.d.ts", "repository": { "type": "git", @@ -13,13 +14,11 @@ "author": "Karsten Schmidt ", "license": "Apache-2.0", "scripts": { - "build": "yarn clean && yarn build:es6 && yarn build:parcel && yarn build:parcel:min", + "build": "yarn clean && yarn build:es6 && yarn build:bundle", "build:es6": "tsc --declaration", - "build:parcel:min": "parcel build --global thing_paths -o index.min.js -d lib --experimental-scope-hoisting src/index.ts", - "build:parcel": "parcel build --global thing_paths -d lib --no-minify --experimental-scope-hoisting src/index.ts && prettier --write lib/index.js", - "build:gzip": "gzip -c lib/index.min.js > lib/index.min.js.gz", - "clean": "rimraf *.js *.d.ts .cache .nyc_output build coverage doc lib", - "test": "rimraf build && parcel build -d build --no-cache --no-minify test/index.ts && nyc mocha build/index.js", + "build:bundle": "../../scripts/bundle-module paths checks errors", + "test": "rimraf build && tsc -p test/tsconfig.json && nyc mocha build/test/*.js", + "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc lib", "cover": "yarn test && nyc report --reporter=lcov", "doc": "node_modules/.bin/typedoc --mode modules --out doc src", "pub": "yarn build && yarn publish --access public" @@ -60,5 +59,6 @@ "browser": { "process": false, "setTimeout": false - } + }, + "sideEffects": false } \ No newline at end of file diff --git a/packages/paths/src/index.ts b/packages/paths/src/index.ts index 7ee36b787a..f7efef715a 100644 --- a/packages/paths/src/index.ts +++ b/packages/paths/src/index.ts @@ -1,5 +1,5 @@ -import { isString } from "@thi.ng/checks/is-string"; -import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; +import { isString } from "@thi.ng/checks"; +import { illegalArgs } from "@thi.ng/errors"; export type Path = PropertyKey | PropertyKey[]; diff --git a/packages/paths/test/tsconfig.json b/packages/paths/test/tsconfig.json index c93bb84899..2c9c12a650 100644 --- a/packages/paths/test/tsconfig.json +++ b/packages/paths/test/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../../tsconfig.json", "compilerOptions": { "outDir": "../build", - "module": "es6", - "target": "es6" + "module": "commonjs", }, "include": [ "./**/*.ts", diff --git a/packages/pointfree-lang/package.json b/packages/pointfree-lang/package.json index 978992ce77..5a1eb51432 100644 --- a/packages/pointfree-lang/package.json +++ b/packages/pointfree-lang/package.json @@ -2,7 +2,9 @@ "name": "@thi.ng/pointfree-lang", "version": "0.2.27", "description": "Forth style syntax layer/compiler for the @thi.ng/pointfree DSL", - "main": "./index.js", + "module": "./index.js", + "main": "./lib/index.js", + "umd:main": "./lib/index.umd.js", "typings": "./index.d.ts", "repository": { "type": "git", @@ -12,20 +14,22 @@ "author": "Karsten Schmidt ", "license": "Apache-2.0", "scripts": { - "build": "yarn clean && tsc --declaration && yarn peg", - "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc", + "build": "yarn clean && yarn build:es6 && yarn build:bundle", + "build:es6": "tsc --declaration && yarn peg", + "build:bundle": "../../scripts/bundle-module pointfree-lang api errors pointfree", + "test": "rimraf build && tsc -p test/tsconfig.json && yarn pegtest && nyc mocha build/test/*.js", + "peg": "pegjs -f es -o parser.js src/grammar.pegjs", + "pegtest": "pegjs -o build/src/parser.js src/grammar.pegjs", + "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc lib", "cover": "yarn test && nyc report --reporter=lcov", "doc": "node_modules/.bin/typedoc --mode modules --out doc src", - "peg": "pegjs -o parser.js src/grammar.pegjs", - "pegtest": "pegjs -o build/src/parser.js src/grammar.pegjs", - "pub": "yarn build && yarn publish --access public", - "test": "rimraf build && tsc -p test && yarn pegtest && nyc mocha build/test/*.js" + "pub": "yarn build && yarn publish --access public" }, "devDependencies": { "@types/mocha": "^5.2.5", "@types/node": "^10.12.15", "mocha": "^5.2.0", - "pegjs": "^0.10.0", + "pegjs": "^0.11.0-dev.325", "typedoc": "^0.14.0", "typescript": "^3.2.2" }, @@ -49,5 +53,6 @@ ], "publishConfig": { "access": "public" - } + }, + "sideEffects": false } \ No newline at end of file diff --git a/packages/pointfree-lang/src/index.ts b/packages/pointfree-lang/src/index.ts index 18035ecbcd..cf217b2987 100644 --- a/packages/pointfree-lang/src/index.ts +++ b/packages/pointfree-lang/src/index.ts @@ -1,6 +1,5 @@ -import { IObjectOf } from "@thi.ng/api/api"; -import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; -import { illegalState } from "@thi.ng/errors/illegal-state"; +import { IObjectOf } from "@thi.ng/api"; +import { illegalArgs, illegalState } from "@thi.ng/errors"; import * as pf from "@thi.ng/pointfree"; import { diff --git a/packages/pointfree-lang/test/tsconfig.json b/packages/pointfree-lang/test/tsconfig.json index c93bb84899..2c9c12a650 100644 --- a/packages/pointfree-lang/test/tsconfig.json +++ b/packages/pointfree-lang/test/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../../tsconfig.json", "compilerOptions": { "outDir": "../build", - "module": "es6", - "target": "es6" + "module": "commonjs", }, "include": [ "./**/*.ts", diff --git a/packages/pointfree/package.json b/packages/pointfree/package.json index b386e0f8f1..1014a41bef 100644 --- a/packages/pointfree/package.json +++ b/packages/pointfree/package.json @@ -2,7 +2,9 @@ "name": "@thi.ng/pointfree", "version": "0.8.15", "description": "Pointfree functional composition / Forth style stack execution engine", - "main": "./index.js", + "module": "./index.js", + "main": "./lib/index.js", + "umd:main": "./lib/index.umd.js", "typings": "./index.d.ts", "repository": { "type": "git", @@ -12,12 +14,14 @@ "author": "Karsten Schmidt ", "license": "Apache-2.0", "scripts": { - "build": "yarn clean && tsc --declaration", - "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc", + "build": "yarn clean && yarn build:es6 && yarn build:bundle", + "build:es6": "tsc --declaration", + "build:bundle": "../../scripts/bundle-module pointfree api checks compose equiv errors", + "test": "rimraf build && tsc -p test/tsconfig.json && nyc mocha build/test/*.js", + "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc lib", "cover": "yarn test && nyc report --reporter=lcov", "doc": "node_modules/.bin/typedoc --mode modules --out doc src", - "pub": "yarn build && yarn publish --access public", - "test": "rimraf build && tsc -p test && nyc mocha build/test/*.js" + "pub": "yarn build && yarn publish --access public" }, "devDependencies": { "@types/mocha": "^5.2.5", @@ -50,5 +54,6 @@ ], "publishConfig": { "access": "public" - } + }, + "sideEffects": false } \ No newline at end of file diff --git a/packages/pointfree/src/index.ts b/packages/pointfree/src/index.ts index bd97041471..9c816b4e44 100644 --- a/packages/pointfree/src/index.ts +++ b/packages/pointfree/src/index.ts @@ -1,11 +1,8 @@ -import { IObjectOf } from "@thi.ng/api/api"; -import { isArray } from "@thi.ng/checks/is-array"; -import { isFunction } from "@thi.ng/checks/is-function"; -import { isPlainObject } from "@thi.ng/checks/is-plain-object"; -import { compL } from "@thi.ng/compose/comp"; +import { IObjectOf } from "@thi.ng/api"; +import { isArray, isFunction, isPlainObject } from "@thi.ng/checks"; +import { compL } from "@thi.ng/compose"; import { equiv as _equiv } from "@thi.ng/equiv"; -import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; -import { illegalState } from "@thi.ng/errors/illegal-state"; +import { illegalArgs, illegalState } from "@thi.ng/errors"; import { Stack, StackContext, @@ -15,7 +12,6 @@ import { StackProgram } from "./api"; - let SAFE = true; export const safeMode = (state: boolean) => (SAFE = state); diff --git a/packages/pointfree/test/tsconfig.json b/packages/pointfree/test/tsconfig.json index c93bb84899..2c9c12a650 100644 --- a/packages/pointfree/test/tsconfig.json +++ b/packages/pointfree/test/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../../tsconfig.json", "compilerOptions": { "outDir": "../build", - "module": "es6", - "target": "es6" + "module": "commonjs", }, "include": [ "./**/*.ts", diff --git a/packages/random/package.json b/packages/random/package.json index 7761a15324..0c917cb8f9 100644 --- a/packages/random/package.json +++ b/packages/random/package.json @@ -2,7 +2,9 @@ "name": "@thi.ng/random", "version": "0.1.1", "description": "Pseudo-random number generators w/ unified API", - "main": "./index.js", + "module": "./index.js", + "main": "./lib/index.js", + "umd:main": "./lib/index.umd.js", "typings": "./index.d.ts", "repository": { "type": "git", @@ -12,12 +14,14 @@ "author": "Karsten Schmidt ", "license": "Apache-2.0", "scripts": { - "build": "yarn clean && tsc --declaration", - "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc", + "build": "yarn clean && yarn build:es6 && yarn build:bundle", + "build:es6": "tsc --declaration", + "build:bundle": "../../scripts/bundle-module random api", + "test": "rimraf build && tsc -p test/tsconfig.json && nyc mocha build/test/*.js", + "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc lib", "cover": "yarn test && nyc report --reporter=lcov", "doc": "node_modules/.bin/typedoc --mode modules --out doc src", - "pub": "yarn build && yarn publish --access public", - "test": "rimraf build && tsc -p test && nyc mocha build/test/*.js" + "pub": "yarn build && yarn publish --access public" }, "devDependencies": { "@types/mocha": "^5.2.5", @@ -39,5 +43,6 @@ ], "publishConfig": { "access": "public" - } + }, + "sideEffects": false } \ No newline at end of file diff --git a/packages/random/src/api.ts b/packages/random/src/api.ts index 078cc71f35..3cc92b0296 100644 --- a/packages/random/src/api.ts +++ b/packages/random/src/api.ts @@ -1,4 +1,4 @@ -import { ICopy } from "@thi.ng/api/api"; +import { ICopy } from "@thi.ng/api"; export interface IRandom { int(): number; diff --git a/packages/random/src/smush32.ts b/packages/random/src/smush32.ts index 48cf7df311..0cf7a3f2e3 100644 --- a/packages/random/src/smush32.ts +++ b/packages/random/src/smush32.ts @@ -1,4 +1,4 @@ -import { IBuffered, ICopy } from "@thi.ng/api/api"; +import { IBuffered, ICopy } from "@thi.ng/api"; import { ARandom, ISeedable } from "./api"; // https://github.com/thi-ng/ct-head/blob/master/random.h diff --git a/packages/random/src/xorshift128.ts b/packages/random/src/xorshift128.ts index f30f24f21c..ef36fd480b 100644 --- a/packages/random/src/xorshift128.ts +++ b/packages/random/src/xorshift128.ts @@ -1,4 +1,4 @@ -import { IBuffered, ICopy } from "@thi.ng/api/api"; +import { IBuffered, ICopy } from "@thi.ng/api"; import { ARandom, ISeedable } from "./api"; // https://en.wikipedia.org/wiki/Xorshift diff --git a/packages/random/src/xorwow.ts b/packages/random/src/xorwow.ts index 8ac281751b..2fb7f3635a 100644 --- a/packages/random/src/xorwow.ts +++ b/packages/random/src/xorwow.ts @@ -1,4 +1,4 @@ -import { IBuffered, ICopy } from "@thi.ng/api/api"; +import { IBuffered, ICopy } from "@thi.ng/api"; import { ARandom, ISeedable } from "./api"; // https://en.wikipedia.org/wiki/Xorshift#xorwow diff --git a/packages/random/src/xsadd.ts b/packages/random/src/xsadd.ts index 2bf75a106f..479416e8ee 100644 --- a/packages/random/src/xsadd.ts +++ b/packages/random/src/xsadd.ts @@ -1,4 +1,4 @@ -import { IBuffered, ICopy } from "@thi.ng/api/api"; +import { IBuffered, ICopy } from "@thi.ng/api"; import { ARandom, ISeedable } from "./api"; // https://github.com/MersenneTwister-Lab/XSadd/blob/master/xsadd.h diff --git a/packages/random/test/tsconfig.json b/packages/random/test/tsconfig.json index c93bb84899..2c9c12a650 100644 --- a/packages/random/test/tsconfig.json +++ b/packages/random/test/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../../tsconfig.json", "compilerOptions": { "outDir": "../build", - "module": "es6", - "target": "es6" + "module": "commonjs", }, "include": [ "./**/*.ts", diff --git a/packages/range-coder/package.json b/packages/range-coder/package.json index fe7fe12408..262d62bf26 100644 --- a/packages/range-coder/package.json +++ b/packages/range-coder/package.json @@ -2,7 +2,9 @@ "name": "@thi.ng/range-coder", "version": "0.1.28", "description": "Binary data range encoder / decoder", - "main": "./index.js", + "module": "./index.js", + "main": "./lib/index.js", + "umd:main": "./lib/index.umd.js", "typings": "./index.d.ts", "repository": { "type": "git", @@ -12,12 +14,14 @@ "author": "Karsten Schmidt ", "license": "Apache-2.0", "scripts": { - "build": "yarn clean && tsc --declaration", - "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc", + "build": "yarn clean && yarn build:es6 && yarn build:bundle", + "build:es6": "tsc --declaration", + "build:bundle": "../../scripts/bundle-module rangeCoder bitstream", + "test": "rimraf build && tsc -p test/tsconfig.json && nyc mocha build/test/*.js", + "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc lib", "cover": "yarn test && nyc report --reporter=lcov", "doc": "node_modules/.bin/typedoc --mode modules --out doc src", - "pub": "yarn build && yarn publish --access public", - "test": "rimraf build && tsc -p test && nyc mocha build/test/*.js" + "pub": "yarn build && yarn publish --access public" }, "devDependencies": { "@thi.ng/transducers": "^2.3.2", @@ -41,5 +45,6 @@ ], "publishConfig": { "access": "public" - } + }, + "sideEffects": false } \ No newline at end of file diff --git a/packages/range-coder/test/index.ts b/packages/range-coder/test/index.ts index 1c9d6abba8..3709477bdd 100644 --- a/packages/range-coder/test/index.ts +++ b/packages/range-coder/test/index.ts @@ -21,6 +21,6 @@ describe("range-coder", () => { }); }); -function randomArray(n: number, len: number) { - return new Uint8Array([...repeatedly(() => ~~(Math.random() * 256), n), ...repeat(0, len - n)]); -} +const randomArray = + (n: number, len: number) => + new Uint8Array([...repeatedly(() => ~~(Math.random() * 256), n), ...repeat(0, len - n)]); diff --git a/packages/range-coder/test/tsconfig.json b/packages/range-coder/test/tsconfig.json index c93bb84899..2c9c12a650 100644 --- a/packages/range-coder/test/tsconfig.json +++ b/packages/range-coder/test/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../../tsconfig.json", "compilerOptions": { "outDir": "../build", - "module": "es6", - "target": "es6" + "module": "commonjs", }, "include": [ "./**/*.ts", diff --git a/packages/resolve-map/package.json b/packages/resolve-map/package.json index 72e8f8ef47..164c9db410 100644 --- a/packages/resolve-map/package.json +++ b/packages/resolve-map/package.json @@ -2,7 +2,9 @@ "name": "@thi.ng/resolve-map", "version": "3.0.16", "description": "DAG resolution of vanilla objects & arrays with internally linked values", - "main": "./index.js", + "module": "./index.js", + "main": "./lib/index.js", + "umd:main": "./lib/index.umd.js", "typings": "./index.d.ts", "repository": { "type": "git", @@ -12,11 +14,14 @@ "author": "Karsten Schmidt ", "license": "Apache-2.0", "scripts": { - "build": "yarn clean && tsc --declaration", - "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc", + "build": "yarn clean && yarn build:es6 && yarn build:bundle", + "build:es6": "tsc --declaration", + "build:bundle": "../../scripts/bundle-module resolveMap api checks errors paths", + "test": "rimraf build && tsc -p test/tsconfig.json && nyc mocha build/test/*.js", + "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc lib", + "cover": "yarn test && nyc report --reporter=lcov", "doc": "node_modules/.bin/typedoc --mode modules --out doc src", - "pub": "yarn build && yarn publish --access public", - "test": "rimraf build && tsc -p test && mocha build/test/*.js" + "pub": "yarn build && yarn publish --access public" }, "devDependencies": { "@types/mocha": "^5.2.5", @@ -26,6 +31,7 @@ "typescript": "^3.2.2" }, "dependencies": { + "@thi.ng/api": "^4.2.4", "@thi.ng/checks": "^1.5.14", "@thi.ng/errors": "^0.1.12", "@thi.ng/paths": "^1.6.6" @@ -41,5 +47,6 @@ ], "publishConfig": { "access": "public" - } + }, + "sideEffects": false } \ No newline at end of file diff --git a/packages/resolve-map/src/index.ts b/packages/resolve-map/src/index.ts index e2e14335b9..5e8985a905 100644 --- a/packages/resolve-map/src/index.ts +++ b/packages/resolve-map/src/index.ts @@ -1,9 +1,11 @@ -import { SEMAPHORE } from "@thi.ng/api/api"; -import { isArray } from "@thi.ng/checks/is-array"; -import { isFunction } from "@thi.ng/checks/is-function"; -import { isPlainObject } from "@thi.ng/checks/is-plain-object"; -import { isString } from "@thi.ng/checks/is-string"; -import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; +import { SEMAPHORE } from "@thi.ng/api"; +import { + isArray, + isFunction, + isPlainObject, + isString +} from "@thi.ng/checks"; +import { illegalArgs } from "@thi.ng/errors"; import { exists, getIn, mutIn } from "@thi.ng/paths"; const RE_ARGS = /^(function\s+\w+)?\s*\(\{([\w\s,:]+)\}/ diff --git a/packages/resolve-map/test/tsconfig.json b/packages/resolve-map/test/tsconfig.json index c93bb84899..2c9c12a650 100644 --- a/packages/resolve-map/test/tsconfig.json +++ b/packages/resolve-map/test/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../../tsconfig.json", "compilerOptions": { "outDir": "../build", - "module": "es6", - "target": "es6" + "module": "commonjs", }, "include": [ "./**/*.ts", diff --git a/packages/rle-pack/package.json b/packages/rle-pack/package.json index a6ad426339..2f89c6a710 100644 --- a/packages/rle-pack/package.json +++ b/packages/rle-pack/package.json @@ -2,7 +2,9 @@ "name": "@thi.ng/rle-pack", "version": "1.0.8", "description": "Binary run-length encoding packer w/ flexible repeat bit widths", - "main": "./index.js", + "module": "./index.js", + "main": "./lib/index.js", + "umd:main": "./lib/index.umd.js", "typings": "./index.d.ts", "repository": { "type": "git", @@ -12,12 +14,14 @@ "author": "Karsten Schmidt ", "license": "Apache-2.0", "scripts": { - "build": "yarn clean && tsc --declaration", - "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc", + "build": "yarn clean && yarn build:es6 && yarn build:bundle", + "build:es6": "tsc --declaration", + "build:bundle": "../../scripts/bundle-module rlePack bitstream errors", + "test": "rimraf build && tsc -p test/tsconfig.json && nyc mocha build/test/*.js", + "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc lib", "cover": "yarn test && nyc report --reporter=lcov", "doc": "node_modules/.bin/typedoc --mode modules --out doc src", - "pub": "yarn build && yarn publish --access public", - "test": "rimraf build && tsc -p test && nyc mocha build/test/*.js" + "pub": "yarn build && yarn publish --access public" }, "devDependencies": { "@types/mocha": "^5.2.5", @@ -35,12 +39,17 @@ "keywords": [ "binary", "bits", + "compression", "ES6", "packer", "RLE", - "typescript" + "run-length", + "typescript", + "variable width", + "wordsize" ], "publishConfig": { "access": "public" - } + }, + "sideEffects": false } \ No newline at end of file diff --git a/packages/rle-pack/src/index.ts b/packages/rle-pack/src/index.ts index deeae4cb88..e665c8c04f 100644 --- a/packages/rle-pack/src/index.ts +++ b/packages/rle-pack/src/index.ts @@ -1,5 +1,5 @@ import { BitInputStream, BitOutputStream } from "@thi.ng/bitstream"; -import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; +import { illegalArgs } from "@thi.ng/errors"; export type RLESizes = [number, number, number, number]; diff --git a/packages/rle-pack/test/tsconfig.json b/packages/rle-pack/test/tsconfig.json index c93bb84899..2c9c12a650 100644 --- a/packages/rle-pack/test/tsconfig.json +++ b/packages/rle-pack/test/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../../tsconfig.json", "compilerOptions": { "outDir": "../build", - "module": "es6", - "target": "es6" + "module": "commonjs", }, "include": [ "./**/*.ts", diff --git a/packages/router/package.json b/packages/router/package.json index 39713d7e6f..d2eda13522 100644 --- a/packages/router/package.json +++ b/packages/router/package.json @@ -2,7 +2,9 @@ "name": "@thi.ng/router", "version": "0.1.30", "description": "Generic router for browser & non-browser based applications", - "main": "./index.js", + "module": "./index.js", + "main": "./lib/index.js", + "umd:main": "./lib/index.umd.js", "typings": "./index.d.ts", "repository": { "type": "git", @@ -12,11 +14,14 @@ "author": "Karsten Schmidt ", "license": "Apache-2.0", "scripts": { - "build": "yarn clean && tsc --declaration", - "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc", + "build": "yarn clean && yarn build:es6 && yarn build:bundle", + "build:es6": "tsc --declaration", + "build:bundle": "../../scripts/bundle-module router api checks equiv errors", + "test": "rimraf build && tsc -p test/tsconfig.json && nyc mocha build/test/*.js", + "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc lib", + "cover": "yarn test && nyc report --reporter=lcov", "doc": "node_modules/.bin/typedoc --mode modules --out doc src", - "pub": "yarn build && yarn publish --access public", - "test": "rimraf build && tsc -p test && mocha build/test/*.js" + "pub": "yarn build && yarn publish --access public" }, "devDependencies": { "@types/mocha": "^5.2.5", @@ -33,16 +38,20 @@ "@thi.ng/errors": "^0.1.12" }, "keywords": [ + "browser", "declarative", "ES6", "html", "history", "parametric", "router", + "SPA", "typescript", - "validation" + "validation", + "UI" ], "publishConfig": { "access": "public" - } + }, + "sideEffects": false } \ No newline at end of file diff --git a/packages/router/src/api.ts b/packages/router/src/api.ts index 05077031cc..40269510ff 100644 --- a/packages/router/src/api.ts +++ b/packages/router/src/api.ts @@ -1,4 +1,4 @@ -import { IID, IObjectOf } from "@thi.ng/api/api"; +import { IID, IObjectOf } from "@thi.ng/api"; /** * A validation function to for authenticated routes. If this function diff --git a/packages/router/src/basic.ts b/packages/router/src/basic.ts index 6a0082ebd3..a03e628fa7 100644 --- a/packages/router/src/basic.ts +++ b/packages/router/src/basic.ts @@ -1,15 +1,13 @@ import { Event, INotify, + INotifyMixin, IObjectOf, Listener -} from "@thi.ng/api/api"; -import * as mixin from "@thi.ng/api/mixins/inotify"; -import { isString } from "@thi.ng/checks/is-string"; +} from "@thi.ng/api"; +import { isString } from "@thi.ng/checks"; import { equiv } from "@thi.ng/equiv"; -import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; -import { illegalArity } from "@thi.ng/errors/illegal-arity"; - +import { illegalArgs, illegalArity } from "@thi.ng/errors"; import { EVENT_ROUTE_CHANGED, Route, @@ -18,7 +16,7 @@ import { RouterConfig } from "./api"; -@mixin.INotify +@INotifyMixin export class BasicRouter implements INotify { diff --git a/packages/router/src/history.ts b/packages/router/src/history.ts index 0a9b650adf..b6dfdb8245 100644 --- a/packages/router/src/history.ts +++ b/packages/router/src/history.ts @@ -1,7 +1,6 @@ +import { isString } from "@thi.ng/checks"; import { equiv } from "@thi.ng/equiv"; import { illegalArity } from "@thi.ng/errors"; -import { isString } from "@thi.ng/checks/is-string"; - import { HTMLRouterConfig, RouteMatch, RouterConfig } from "./api"; import { BasicRouter } from "./basic"; diff --git a/packages/router/test/tsconfig.json b/packages/router/test/tsconfig.json index c93bb84899..2c9c12a650 100644 --- a/packages/router/test/tsconfig.json +++ b/packages/router/test/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../../tsconfig.json", "compilerOptions": { "outDir": "../build", - "module": "es6", - "target": "es6" + "module": "commonjs", }, "include": [ "./**/*.ts", diff --git a/packages/sax/package.json b/packages/sax/package.json index 69fce5f6a6..0b655adc84 100644 --- a/packages/sax/package.json +++ b/packages/sax/package.json @@ -2,7 +2,9 @@ "name": "@thi.ng/sax", "version": "0.5.13", "description": "Transducer-based, SAX-like, non-validating, speedy & tiny XML parser", - "main": "./index.js", + "module": "./index.js", + "main": "./lib/index.js", + "umd:main": "./lib/index.umd.js", "typings": "./index.d.ts", "repository": { "type": "git", @@ -12,12 +14,14 @@ "author": "Karsten Schmidt ", "license": "Apache-2.0", "scripts": { - "build": "yarn clean && tsc --declaration", - "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc", + "build": "yarn clean && yarn build:es6 && yarn build:bundle", + "build:es6": "tsc --declaration", + "build:bundle": "../../scripts/bundle-module sax api transducers transducers-fsm", + "test": "rimraf build && tsc -p test/tsconfig.json && nyc mocha build/test/*.js", + "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc lib internal", "cover": "yarn test && nyc report --reporter=lcov", "doc": "node_modules/.bin/typedoc --mode modules --out doc src", - "pub": "yarn build && yarn publish --access public", - "test": "rimraf build && tsc -p test && nyc mocha build/test/*.js" + "pub": "yarn build && yarn publish --access public" }, "devDependencies": { "@types/mocha": "^5.2.5", @@ -43,5 +47,6 @@ ], "publishConfig": { "access": "public" - } + }, + "sideEffects": false } \ No newline at end of file diff --git a/packages/sax/src/index.ts b/packages/sax/src/index.ts index 4765924d6b..4d04b26c61 100644 --- a/packages/sax/src/index.ts +++ b/packages/sax/src/index.ts @@ -1,7 +1,6 @@ import { IObjectOf } from "@thi.ng/api"; +import { $iter, iterator, Transducer } from "@thi.ng/transducers"; import { fsm, FSMState, FSMStateMap } from "@thi.ng/transducers-fsm"; -import { Transducer } from "@thi.ng/transducers/api"; -import { $iter, iterator } from "@thi.ng/transducers/iterator"; export interface ParseOpts { /** diff --git a/packages/sax/test/tsconfig.json b/packages/sax/test/tsconfig.json index c93bb84899..2c9c12a650 100644 --- a/packages/sax/test/tsconfig.json +++ b/packages/sax/test/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../../tsconfig.json", "compilerOptions": { "outDir": "../build", - "module": "es6", - "target": "es6" + "module": "commonjs", }, "include": [ "./**/*.ts", diff --git a/packages/strings/package.json b/packages/strings/package.json index 8d0f4ca941..d3a8ec684d 100644 --- a/packages/strings/package.json +++ b/packages/strings/package.json @@ -2,7 +2,9 @@ "name": "@thi.ng/strings", "version": "0.7.1", "description": "Various string formatting & utility functions", - "main": "./index.js", + "module": "./index.js", + "main": "./lib/index.js", + "umd:main": "./lib/index.umd.js", "typings": "./index.d.ts", "repository": { "type": "git", @@ -12,12 +14,14 @@ "author": "Karsten Schmidt ", "license": "Apache-2.0", "scripts": { - "build": "yarn clean && tsc --declaration", - "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc", + "build": "yarn clean && yarn build:es6 && yarn build:bundle", + "build:es6": "tsc --declaration", + "build:bundle": "../../scripts/bundle-module strings errors memoize", + "test": "rimraf build && tsc -p test/tsconfig.json && nyc mocha build/test/*.js", + "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc lib", "cover": "yarn test && nyc report --reporter=lcov", "doc": "node_modules/.bin/typedoc --mode modules --out doc src", - "pub": "yarn build && yarn publish --access public", - "test": "rimraf build && tsc -p test && nyc mocha build/test/*.js" + "pub": "yarn build && yarn publish --access public" }, "devDependencies": { "@types/mocha": "^5.2.5", @@ -32,16 +36,28 @@ "@thi.ng/memoize": "^0.2.6" }, "keywords": [ + "composition", "ES6", + "camelcase", + "center", + "float", "format", "functional", + "hex", "higher order", - "padding", + "kebabcase", "number", + "padding", + "percent", + "radix", + "slugify", + "snakecase", "string", - "typescript" + "typescript", + "wordwrap" ], "publishConfig": { "access": "public" - } + }, + "sideEffects": false } \ No newline at end of file diff --git a/packages/strings/src/center.ts b/packages/strings/src/center.ts index a2a6597b5c..261b2da014 100644 --- a/packages/strings/src/center.ts +++ b/packages/strings/src/center.ts @@ -1,4 +1,4 @@ -import { memoizeJ } from "@thi.ng/memoize/memoizej"; +import { memoizeJ } from "@thi.ng/memoize"; import { Stringer } from "./api"; import { repeat } from "./repeat"; diff --git a/packages/strings/src/float.ts b/packages/strings/src/float.ts index 5b8d2f71d6..f85b028c35 100644 --- a/packages/strings/src/float.ts +++ b/packages/strings/src/float.ts @@ -1,4 +1,4 @@ -import { memoizeJ } from "@thi.ng/memoize/memoizej"; +import { memoizeJ } from "@thi.ng/memoize"; import { Stringer } from "./api"; diff --git a/packages/strings/src/format.ts b/packages/strings/src/format.ts index cb3f15c0c9..0b675165a6 100644 --- a/packages/strings/src/format.ts +++ b/packages/strings/src/format.ts @@ -1,15 +1,16 @@ -export const format = (fmt: any[], ...args: any[]) => { - const acc: any[] = []; - for (let i = 0, j = 0, n = fmt.length; i < n; i++) { - const f = fmt[i]; - const t = typeof f; - acc.push( - t === "function" ? - f(args[j++]) : - t === "object" ? - f[args[j++]] : - f - ); - } - return acc.join(""); -}; +export const format = + (fmt: any[], ...args: any[]) => { + const acc: any[] = []; + for (let i = 0, j = 0, n = fmt.length; i < n; i++) { + const f = fmt[i]; + const t = typeof f; + acc.push( + t === "function" ? + f(args[j++]) : + t === "object" ? + f[args[j++]] : + f + ); + } + return acc.join(""); + }; diff --git a/packages/strings/src/pad-left.ts b/packages/strings/src/pad-left.ts index 9f77c0153f..489a77ba46 100644 --- a/packages/strings/src/pad-left.ts +++ b/packages/strings/src/pad-left.ts @@ -1,4 +1,4 @@ -import { memoizeJ } from "@thi.ng/memoize/memoizej"; +import { memoizeJ } from "@thi.ng/memoize"; import { Stringer } from "./api"; import { repeat } from "./repeat"; diff --git a/packages/strings/src/pad-right.ts b/packages/strings/src/pad-right.ts index 2b2ff2e29f..73daa72358 100644 --- a/packages/strings/src/pad-right.ts +++ b/packages/strings/src/pad-right.ts @@ -1,4 +1,4 @@ -import { memoizeJ } from "@thi.ng/memoize/memoizej"; +import { memoizeJ } from "@thi.ng/memoize"; import { Stringer } from "./api"; import { repeat } from "./repeat"; diff --git a/packages/strings/src/parse.ts b/packages/strings/src/parse.ts index ada5e7bae6..86ada2b373 100644 --- a/packages/strings/src/parse.ts +++ b/packages/strings/src/parse.ts @@ -1,9 +1,11 @@ -export const maybeParseInt = (x: string, defaultVal: any = 0, radix = 10) => { - const n = parseInt(x, radix); - return isNaN(n) ? defaultVal : n; -}; +export const maybeParseInt = + (x: string, defaultVal: any = 0, radix = 10) => { + const n = parseInt(x, radix); + return isNaN(n) ? defaultVal : n; + }; -export const maybeParseFloat = (x: string, defaultVal: any = 0) => { - const n = parseFloat(x); - return isNaN(n) ? defaultVal : n; -}; +export const maybeParseFloat = + (x: string, defaultVal: any = 0) => { + const n = parseFloat(x); + return isNaN(n) ? defaultVal : n; + }; diff --git a/packages/strings/src/percent.ts b/packages/strings/src/percent.ts index cd6bd93645..fb1baf6e9d 100644 --- a/packages/strings/src/percent.ts +++ b/packages/strings/src/percent.ts @@ -6,5 +6,6 @@ import { Stringer } from "./api"; * * @param prec number of fractional digits (default: 0) */ -export const percent = (prec = 0): Stringer => - (x: number) => (x * 100).toFixed(prec) + "%"; +export const percent = + (prec = 0): Stringer => + (x: number) => (x * 100).toFixed(prec) + "%"; diff --git a/packages/strings/src/radix.ts b/packages/strings/src/radix.ts index fd3a84c46b..d404d748cc 100644 --- a/packages/strings/src/radix.ts +++ b/packages/strings/src/radix.ts @@ -1,5 +1,4 @@ -import { memoizeJ } from "@thi.ng/memoize/memoizej"; - +import { memoizeJ } from "@thi.ng/memoize"; import { Stringer } from "./api"; import { repeat } from "./repeat"; diff --git a/packages/strings/src/repeat.ts b/packages/strings/src/repeat.ts index 86738ee717..9813e2aa67 100644 --- a/packages/strings/src/repeat.ts +++ b/packages/strings/src/repeat.ts @@ -1,4 +1,4 @@ -import { memoizeJ } from "@thi.ng/memoize/memoizej"; +import { memoizeJ } from "@thi.ng/memoize"; /** * @param ch character diff --git a/packages/strings/src/splice.ts b/packages/strings/src/splice.ts index 7aa846314d..8b2f809fed 100644 --- a/packages/strings/src/splice.ts +++ b/packages/strings/src/splice.ts @@ -1,4 +1,4 @@ -import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; +import { illegalArgs } from "@thi.ng/errors"; /** * Forms a new strings which inserts given `insert` string into `src` @@ -13,20 +13,21 @@ import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; * @param from * @param to */ -export const splice = (src: string, insert: string, from: number, to = from) => { - if (from < 0) { - from += src.length; - } - if (to < 0) { - to += src.length; - } - if (from > to) { - illegalArgs("'from' index must be <= 'to'"); - } - to = Math.max(to, 0); - return from <= 0 ? - insert + src.substr(to) : - from >= src.length ? - src + insert : - src.substr(0, from) + insert + src.substr(to); -}; +export const splice = + (src: string, insert: string, from: number, to = from) => { + if (from < 0) { + from += src.length; + } + if (to < 0) { + to += src.length; + } + if (from > to) { + illegalArgs("'from' index must be <= 'to'"); + } + to = Math.max(to, 0); + return from <= 0 ? + insert + src.substr(to) : + from >= src.length ? + src + insert : + src.substr(0, from) + insert + src.substr(to); + }; diff --git a/packages/strings/src/truncate-left.ts b/packages/strings/src/truncate-left.ts index 27f0d44371..2534290364 100644 --- a/packages/strings/src/truncate-left.ts +++ b/packages/strings/src/truncate-left.ts @@ -1,5 +1,4 @@ -import { memoizeJ } from "@thi.ng/memoize/memoizej"; - +import { memoizeJ } from "@thi.ng/memoize"; import { Stringer } from "./api"; export const truncateLeft: (n: number, prefix?: string) => Stringer = diff --git a/packages/strings/src/truncate.ts b/packages/strings/src/truncate.ts index c470a25fd1..b4030b9461 100644 --- a/packages/strings/src/truncate.ts +++ b/packages/strings/src/truncate.ts @@ -1,5 +1,4 @@ -import { memoizeJ } from "@thi.ng/memoize/memoizej"; - +import { memoizeJ } from "@thi.ng/memoize"; import { Stringer } from "./api"; export const truncate: (n: number, suffix?: string) => Stringer = diff --git a/packages/strings/src/units.ts b/packages/strings/src/units.ts index efac24e8c9..3e6674f61f 100644 --- a/packages/strings/src/units.ts +++ b/packages/strings/src/units.ts @@ -1,5 +1,4 @@ -import { memoizeJ } from "@thi.ng/memoize/memoizej"; - +import { memoizeJ } from "@thi.ng/memoize"; import { Stringer } from "./api"; export const units: (exp: [number, string, number?][], base: string, prec?: number) => Stringer = diff --git a/packages/strings/src/wrap.ts b/packages/strings/src/wrap.ts index 95df096538..3fc08f4af4 100644 --- a/packages/strings/src/wrap.ts +++ b/packages/strings/src/wrap.ts @@ -1,5 +1,4 @@ -import { memoizeJ } from "@thi.ng/memoize/memoizej"; - +import { memoizeJ } from "@thi.ng/memoize"; import { Stringer } from "./api"; /** diff --git a/packages/strings/test/tsconfig.json b/packages/strings/test/tsconfig.json index c93bb84899..2c9c12a650 100644 --- a/packages/strings/test/tsconfig.json +++ b/packages/strings/test/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../../tsconfig.json", "compilerOptions": { "outDir": "../build", - "module": "es6", - "target": "es6" + "module": "commonjs", }, "include": [ "./**/*.ts", diff --git a/packages/transducers-fsm/package.json b/packages/transducers-fsm/package.json index 95855071d9..115c279295 100644 --- a/packages/transducers-fsm/package.json +++ b/packages/transducers-fsm/package.json @@ -2,7 +2,9 @@ "name": "@thi.ng/transducers-fsm", "version": "0.2.36", "description": "Transducer-based Finite State Machine transformer", - "main": "./index.js", + "module": "./index.js", + "main": "./lib/index.js", + "umd:main": "./lib/index.umd.js", "typings": "./index.d.ts", "repository": { "type": "git", @@ -12,12 +14,14 @@ "author": "Karsten Schmidt ", "license": "Apache-2.0", "scripts": { - "build": "yarn clean && tsc --declaration", - "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc", + "build": "yarn clean && yarn build:es6 && yarn build:bundle", + "build:es6": "tsc --declaration", + "build:bundle": "../../scripts/bundle-module transducersFsm api transducers", + "test": "rimraf build && tsc -p test/tsconfig.json && nyc mocha build/test/*.js", + "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc lib", "cover": "yarn test && nyc report --reporter=lcov", "doc": "node_modules/.bin/typedoc --mode modules --out doc src", - "pub": "yarn build && yarn publish --access public", - "test": "rimraf build && tsc -p test && nyc mocha build/test/*.js" + "pub": "yarn build && yarn publish --access public" }, "devDependencies": { "@types/mocha": "^5.2.5", @@ -40,5 +44,6 @@ ], "publishConfig": { "access": "public" - } + }, + "sideEffects": false } \ No newline at end of file diff --git a/packages/transducers-fsm/src/index.ts b/packages/transducers-fsm/src/index.ts index b11e2b44c9..32f024b832 100644 --- a/packages/transducers-fsm/src/index.ts +++ b/packages/transducers-fsm/src/index.ts @@ -1,8 +1,12 @@ -import { IObjectOf } from "@thi.ng/api/api"; -import { Reducer, Transducer } from "@thi.ng/transducers/api"; -import { comp } from "@thi.ng/transducers/func/comp"; -import { compR } from "@thi.ng/transducers/func/compr"; -import { ensureReduced, isReduced } from "@thi.ng/transducers/reduced"; +import { IObjectOf } from "@thi.ng/api"; +import { + comp, + compR, + ensureReduced, + isReduced, + Reducer, + Transducer +} from "@thi.ng/transducers"; export interface FSMState { state: PropertyKey; diff --git a/packages/transducers-fsm/test/tsconfig.json b/packages/transducers-fsm/test/tsconfig.json index c93bb84899..2c9c12a650 100644 --- a/packages/transducers-fsm/test/tsconfig.json +++ b/packages/transducers-fsm/test/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../../tsconfig.json", "compilerOptions": { "outDir": "../build", - "module": "es6", - "target": "es6" + "module": "commonjs", }, "include": [ "./**/*.ts", diff --git a/packages/transducers-hdom/test/tsconfig.json b/packages/transducers-hdom/test/tsconfig.json index c93bb84899..2c9c12a650 100644 --- a/packages/transducers-hdom/test/tsconfig.json +++ b/packages/transducers-hdom/test/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../../tsconfig.json", "compilerOptions": { "outDir": "../build", - "module": "es6", - "target": "es6" + "module": "commonjs", }, "include": [ "./**/*.ts", diff --git a/packages/transducers-stats/package.json b/packages/transducers-stats/package.json index fa1b6b3414..852f154157 100644 --- a/packages/transducers-stats/package.json +++ b/packages/transducers-stats/package.json @@ -2,7 +2,9 @@ "name": "@thi.ng/transducers-stats", "version": "0.4.23", "description": "Transducers for statistical / technical analysis", - "main": "./index.js", + "module": "./index.js", + "main": "./lib/index.js", + "umd:main": "./lib/index.umd.js", "typings": "./index.d.ts", "repository": { "type": "git", @@ -12,12 +14,14 @@ "author": "Karsten Schmidt ", "license": "Apache-2.0", "scripts": { - "build": "yarn clean && tsc --declaration", - "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc", + "build": "yarn clean && yarn build:es6 && yarn build:bundle", + "build:es6": "tsc --declaration", + "build:bundle": "../../scripts/bundle-module transducersStats checks dcons errors transducers", + "test": "rimraf build && tsc -p test/tsconfig.json && nyc mocha build/test/*.js", + "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc lib", "cover": "yarn test && nyc report --reporter=lcov", "doc": "node_modules/.bin/typedoc --mode modules --out doc src", - "pub": "yarn build && yarn publish --access public", - "test": "rimraf build && tsc -p test && nyc mocha build/test/*.js" + "pub": "yarn build && yarn publish --access public" }, "devDependencies": { "@types/mocha": "^5.2.5", @@ -28,6 +32,7 @@ "typescript": "^3.2.2" }, "dependencies": { + "@thi.ng/checks": "^1.5.14", "@thi.ng/dcons": "^1.1.23", "@thi.ng/errors": "^0.1.12", "@thi.ng/transducers": "^2.3.2" @@ -38,5 +43,6 @@ ], "publishConfig": { "access": "public" - } + }, + "sideEffects": false } \ No newline at end of file diff --git a/packages/transducers-stats/src/bollinger.ts b/packages/transducers-stats/src/bollinger.ts index 944547f04e..830362fe96 100644 --- a/packages/transducers-stats/src/bollinger.ts +++ b/packages/transducers-stats/src/bollinger.ts @@ -1,11 +1,12 @@ -import { Transducer } from "@thi.ng/transducers/api"; -import { $iter } from "@thi.ng/transducers/iterator"; -import { comp } from "@thi.ng/transducers/func/comp"; -import { drop } from "@thi.ng/transducers/xform/drop"; -import { map } from "@thi.ng/transducers/xform/map"; -import { multiplex } from "@thi.ng/transducers/xform/multiplex"; -import { partition } from "@thi.ng/transducers/xform/partition"; - +import { + $iter, + comp, + drop, + map, + multiplex, + partition, + Transducer +} from "@thi.ng/transducers"; import { mse } from "./mse"; import { sma } from "./sma"; diff --git a/packages/transducers-stats/src/donchian.ts b/packages/transducers-stats/src/donchian.ts index 10dc29094c..460e16494e 100644 --- a/packages/transducers-stats/src/donchian.ts +++ b/packages/transducers-stats/src/donchian.ts @@ -1,9 +1,10 @@ -import { Transducer } from "@thi.ng/transducers/api"; -import { comp } from "@thi.ng/transducers/func/comp"; -import { iterator } from "@thi.ng/transducers/iterator"; -import { map } from "@thi.ng/transducers/xform/map"; -import { partition } from "@thi.ng/transducers/xform/partition"; - +import { + comp, + iterator, + map, + partition, + Transducer +} from "@thi.ng/transducers"; import { bounds } from "./bounds"; /** diff --git a/packages/transducers-stats/src/ema.ts b/packages/transducers-stats/src/ema.ts index 005e5f62fa..406e1507a3 100644 --- a/packages/transducers-stats/src/ema.ts +++ b/packages/transducers-stats/src/ema.ts @@ -1,7 +1,10 @@ -import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; -import { Reducer, Transducer } from "@thi.ng/transducers/api"; -import { compR } from "@thi.ng/transducers/func/compr"; -import { iterator1 } from "@thi.ng/transducers/iterator"; +import { illegalArgs } from "@thi.ng/errors"; +import { + compR, + iterator1, + Reducer, + Transducer +} from "@thi.ng/transducers"; /** * https://en.wikipedia.org/wiki/Moving_average#Exponential_moving_average diff --git a/packages/transducers-stats/src/hma.ts b/packages/transducers-stats/src/hma.ts index ab70bd4282..4c80ab79a7 100644 --- a/packages/transducers-stats/src/hma.ts +++ b/packages/transducers-stats/src/hma.ts @@ -1,10 +1,11 @@ -import { Transducer } from "@thi.ng/transducers/api"; -import { comp } from "@thi.ng/transducers/func/comp"; -import { iterator1 } from "@thi.ng/transducers/iterator"; -import { drop } from "@thi.ng/transducers/xform/drop"; -import { map } from "@thi.ng/transducers/xform/map"; -import { multiplex } from "@thi.ng/transducers/xform/multiplex"; - +import { + comp, + drop, + iterator1, + map, + multiplex, + Transducer +} from "@thi.ng/transducers"; import { wma } from "./wma"; /** diff --git a/packages/transducers-stats/src/macd.ts b/packages/transducers-stats/src/macd.ts index c6206d4eb7..f98989d7da 100644 --- a/packages/transducers-stats/src/macd.ts +++ b/packages/transducers-stats/src/macd.ts @@ -1,8 +1,10 @@ -import { Reducer, Transducer } from "@thi.ng/transducers/api"; -import { compR } from "@thi.ng/transducers/func/compr"; -import { $iter } from "@thi.ng/transducers/iterator"; -import { step } from "@thi.ng/transducers/step"; - +import { + $iter, + compR, + Reducer, + step, + Transducer +} from "@thi.ng/transducers"; import { ema } from "./ema"; export interface MACD { diff --git a/packages/transducers-stats/src/momentum.ts b/packages/transducers-stats/src/momentum.ts index 5273474dad..492fc7146e 100644 --- a/packages/transducers-stats/src/momentum.ts +++ b/packages/transducers-stats/src/momentum.ts @@ -1,8 +1,11 @@ import { DCons } from "@thi.ng/dcons"; -import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; -import { Reducer, Transducer } from "@thi.ng/transducers/api"; -import { compR } from "@thi.ng/transducers/func/compr"; -import { iterator1 } from "@thi.ng/transducers/iterator"; +import { illegalArgs } from "@thi.ng/errors"; +import { + compR, + iterator1, + Reducer, + Transducer +} from "@thi.ng/transducers"; /** * https://en.wikipedia.org/wiki/Momentum_(technical_analysis) diff --git a/packages/transducers-stats/src/roc.ts b/packages/transducers-stats/src/roc.ts index b20dbf464a..18ae1fea0a 100644 --- a/packages/transducers-stats/src/roc.ts +++ b/packages/transducers-stats/src/roc.ts @@ -1,8 +1,11 @@ import { DCons } from "@thi.ng/dcons"; -import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; -import { Reducer, Transducer } from "@thi.ng/transducers/api"; -import { compR } from "@thi.ng/transducers/func/compr"; -import { iterator1 } from "@thi.ng/transducers/iterator"; +import { illegalArgs } from "@thi.ng/errors"; +import { + compR, + iterator1, + Reducer, + Transducer +} from "@thi.ng/transducers"; /** * Rate of change. diff --git a/packages/transducers-stats/src/rsi.ts b/packages/transducers-stats/src/rsi.ts index 0f6fb8e38d..3b1c9427b6 100644 --- a/packages/transducers-stats/src/rsi.ts +++ b/packages/transducers-stats/src/rsi.ts @@ -1,10 +1,11 @@ -import { Transducer } from "@thi.ng/transducers/api"; -import { comp } from "@thi.ng/transducers/func/comp"; -import { iterator1 } from "@thi.ng/transducers/iterator"; -import { drop } from "@thi.ng/transducers/xform/drop"; -import { map } from "@thi.ng/transducers/xform/map"; -import { multiplex } from "@thi.ng/transducers/xform/multiplex"; - +import { + comp, + drop, + iterator1, + map, + multiplex, + Transducer +} from "@thi.ng/transducers"; import { momentum } from "./momentum"; import { sma } from "./sma"; diff --git a/packages/transducers-stats/src/sd.ts b/packages/transducers-stats/src/sd.ts index 7c3ae0df08..99decec5ef 100644 --- a/packages/transducers-stats/src/sd.ts +++ b/packages/transducers-stats/src/sd.ts @@ -1,13 +1,14 @@ -import { Transducer } from "@thi.ng/transducers/api"; -import { comp } from "@thi.ng/transducers/func/comp"; -import { drop } from "@thi.ng/transducers/xform/drop"; -import { map } from "@thi.ng/transducers/xform/map"; -import { multiplex } from "@thi.ng/transducers/xform/multiplex"; -import { partition } from "@thi.ng/transducers/xform/partition"; - +import { + $iter, + comp, + drop, + map, + multiplex, + partition, + Transducer +} from "@thi.ng/transducers"; import { mse } from "./mse"; import { sma } from "./sma"; -import { $iter } from "@thi.ng/transducers/iterator"; /** * Moving standard deviation, calculates mean square error to SMA and diff --git a/packages/transducers-stats/src/sma.ts b/packages/transducers-stats/src/sma.ts index b76353accd..d824082acf 100644 --- a/packages/transducers-stats/src/sma.ts +++ b/packages/transducers-stats/src/sma.ts @@ -1,8 +1,11 @@ import { DCons } from "@thi.ng/dcons"; -import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; -import { Reducer, Transducer } from "@thi.ng/transducers/api"; -import { compR } from "@thi.ng/transducers/func/compr"; -import { iterator1 } from "@thi.ng/transducers/iterator"; +import { illegalArgs } from "@thi.ng/errors"; +import { + compR, + iterator1, + Reducer, + Transducer +} from "@thi.ng/transducers"; /** * Like @thi.ng/transducers `movingAverage`, but using more efficient diff --git a/packages/transducers-stats/src/stochastic.ts b/packages/transducers-stats/src/stochastic.ts index e3c326de89..27d7edcf0e 100644 --- a/packages/transducers-stats/src/stochastic.ts +++ b/packages/transducers-stats/src/stochastic.ts @@ -1,8 +1,10 @@ -import { Reducer, Transducer } from "@thi.ng/transducers/api"; -import { compR } from "@thi.ng/transducers/func/compr"; -import { $iter } from "@thi.ng/transducers/iterator"; -import { step } from "@thi.ng/transducers/step"; - +import { + $iter, + compR, + Reducer, + step, + Transducer +} from "@thi.ng/transducers"; import { donchian } from "./donchian"; import { sma } from "./sma"; diff --git a/packages/transducers-stats/src/trix.ts b/packages/transducers-stats/src/trix.ts index 15222027c8..a66ea94467 100644 --- a/packages/transducers-stats/src/trix.ts +++ b/packages/transducers-stats/src/trix.ts @@ -1,7 +1,4 @@ -import { Transducer } from "@thi.ng/transducers/api"; -import { comp } from "@thi.ng/transducers/func/comp"; -import { iterator1 } from "@thi.ng/transducers/iterator"; - +import { comp, iterator1, Transducer } from "@thi.ng/transducers"; import { ema } from "./ema"; import { roc } from "./roc"; diff --git a/packages/transducers-stats/src/wma.ts b/packages/transducers-stats/src/wma.ts index 8b5c5dea53..93bef142de 100644 --- a/packages/transducers-stats/src/wma.ts +++ b/packages/transducers-stats/src/wma.ts @@ -1,11 +1,12 @@ -import { isNumber } from "@thi.ng/checks/is-number"; -import { Transducer } from "@thi.ng/transducers/api"; -import { comp } from "@thi.ng/transducers/func/comp"; -import { range } from "@thi.ng/transducers/iter/range"; -import { iterator1 } from "@thi.ng/transducers/iterator"; -import { map } from "@thi.ng/transducers/xform/map"; -import { partition } from "@thi.ng/transducers/xform/partition"; - +import { isNumber } from "@thi.ng/checks"; +import { + comp, + iterator1, + map, + partition, + range, + Transducer +} from "@thi.ng/transducers"; import { dot } from "./dot"; /** diff --git a/packages/transducers-stats/test/tsconfig.json b/packages/transducers-stats/test/tsconfig.json index c93bb84899..2c9c12a650 100644 --- a/packages/transducers-stats/test/tsconfig.json +++ b/packages/transducers-stats/test/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../../tsconfig.json", "compilerOptions": { "outDir": "../build", - "module": "es6", - "target": "es6" + "module": "commonjs", }, "include": [ "./**/*.ts", diff --git a/packages/transducers/package.json b/packages/transducers/package.json index aadb83465a..420e44a7fa 100644 --- a/packages/transducers/package.json +++ b/packages/transducers/package.json @@ -2,7 +2,9 @@ "name": "@thi.ng/transducers", "version": "2.3.2", "description": "Lightweight transducer implementations for ES6 / TypeScript", - "main": "./index.js", + "module": "./index.js", + "main": "./lib/index.js", + "umd:main": "./lib/index.umd.js", "typings": "./index.d.ts", "repository": { "type": "git", @@ -12,12 +14,14 @@ "author": "Karsten Schmidt ", "license": "Apache-2.0", "scripts": { - "build": "yarn clean && tsc --declaration", - "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc func iter rfn xform", + "build": "yarn clean && yarn build:es6 && yarn build:bundle", + "build:es6": "tsc --declaration", + "build:bundle": "../../scripts/bundle-module transducers api checks compare compose equiv errors strings", + "test": "rimraf build && tsc -p test/tsconfig.json && nyc mocha build/test/*.js", + "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc lib func iter rfn xform", "cover": "yarn test && nyc report --reporter=lcov", "doc": "node_modules/.bin/typedoc --mode modules --out doc src", - "pub": "yarn build && yarn publish --access public", - "test": "rimraf build && tsc -p test && nyc mocha build/test/*.js" + "pub": "yarn build && yarn publish --access public" }, "devDependencies": { "@types/mocha": "^5.2.5", @@ -37,6 +41,9 @@ "@thi.ng/strings": "^0.7.1" }, "keywords": [ + "array", + "composition", + "data", "ES6", "functional", "generators", @@ -49,5 +56,6 @@ ], "publishConfig": { "access": "public" - } + }, + "sideEffects": false } \ No newline at end of file diff --git a/packages/transducers/src/api.ts b/packages/transducers/src/api.ts index b6265e275a..22eed2828c 100644 --- a/packages/transducers/src/api.ts +++ b/packages/transducers/src/api.ts @@ -1,4 +1,4 @@ -import { Comparator, Fn, IObjectOf } from "@thi.ng/api/api"; +import { Comparator, Fn, IObjectOf } from "@thi.ng/api"; import { Reduced } from "./reduced"; diff --git a/packages/transducers/src/func/binary-search.ts b/packages/transducers/src/func/binary-search.ts index 01093cdccf..1e0086b713 100644 --- a/packages/transducers/src/func/binary-search.ts +++ b/packages/transducers/src/func/binary-search.ts @@ -1,4 +1,4 @@ -import { Comparator, Fn } from "@thi.ng/api/api"; +import { Comparator, Fn } from "@thi.ng/api"; /** * Returns the supposed index of `x` in pre-sorted array-like collection diff --git a/packages/transducers/src/func/comp.ts b/packages/transducers/src/func/comp.ts index 8e17710c1c..5f14212095 100644 --- a/packages/transducers/src/func/comp.ts +++ b/packages/transducers/src/func/comp.ts @@ -1,5 +1,4 @@ -import { comp as _comp } from "@thi.ng/compose/comp"; - +import { comp as _comp } from "@thi.ng/compose"; import { Transducer } from "../api"; export function comp(a: Transducer): Transducer; diff --git a/packages/transducers/src/func/deep-transform.ts b/packages/transducers/src/func/deep-transform.ts index 4b78417788..b2fa9e69a6 100644 --- a/packages/transducers/src/func/deep-transform.ts +++ b/packages/transducers/src/func/deep-transform.ts @@ -1,5 +1,4 @@ -import { isFunction } from "@thi.ng/checks/is-function"; - +import { isFunction } from "@thi.ng/checks"; import { TransformSpec } from "../api"; /** diff --git a/packages/transducers/src/func/ensure-array.ts b/packages/transducers/src/func/ensure-array.ts index 94bdbaac25..0de070f414 100644 --- a/packages/transducers/src/func/ensure-array.ts +++ b/packages/transducers/src/func/ensure-array.ts @@ -1,5 +1,4 @@ -import { isArray } from "@thi.ng/checks/is-array"; -import { isArrayLike } from "@thi.ng/checks/is-arraylike"; +import { isArray, isArrayLike } from "@thi.ng/checks"; import { ensureIterable } from "./ensure-iterable"; /** diff --git a/packages/transducers/src/func/ensure-iterable.ts b/packages/transducers/src/func/ensure-iterable.ts index 9a92cc19cc..dd9acf06c5 100644 --- a/packages/transducers/src/func/ensure-iterable.ts +++ b/packages/transducers/src/func/ensure-iterable.ts @@ -1,4 +1,4 @@ -import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; +import { illegalArgs } from "@thi.ng/errors"; export const ensureIterable = (x: any): IterableIterator => { diff --git a/packages/transducers/src/func/even.ts b/packages/transducers/src/func/even.ts index 9d30160522..4fecc9bc95 100644 --- a/packages/transducers/src/func/even.ts +++ b/packages/transducers/src/func/even.ts @@ -1 +1 @@ -export { isEven as even } from "@thi.ng/checks/is-even"; +export { isEven as even } from "@thi.ng/checks"; diff --git a/packages/transducers/src/func/fuzzy-match.ts b/packages/transducers/src/func/fuzzy-match.ts index bc4a123062..d9476ff966 100644 --- a/packages/transducers/src/func/fuzzy-match.ts +++ b/packages/transducers/src/func/fuzzy-match.ts @@ -1,4 +1,4 @@ -import { Predicate2 } from "@thi.ng/api/api"; +import { Predicate2 } from "@thi.ng/api"; import { equiv } from "@thi.ng/equiv"; /** diff --git a/packages/transducers/src/func/hex.ts b/packages/transducers/src/func/hex.ts index f0c60ec00d..c2d5d6eb94 100644 --- a/packages/transducers/src/func/hex.ts +++ b/packages/transducers/src/func/hex.ts @@ -1,5 +1,4 @@ -import { Stringer } from "@thi.ng/strings/api"; -import { radix } from "@thi.ng/strings/radix"; +import { radix, Stringer } from "@thi.ng/strings"; /** * @deprecated use thi.ng/strings `radix()` instead diff --git a/packages/transducers/src/func/juxt.ts b/packages/transducers/src/func/juxt.ts index 6c9a09f973..f6dc86f79a 100644 --- a/packages/transducers/src/func/juxt.ts +++ b/packages/transducers/src/func/juxt.ts @@ -1 +1 @@ -export * from "@thi.ng/compose/juxt"; +export { juxt } from "@thi.ng/compose"; diff --git a/packages/transducers/src/func/odd.ts b/packages/transducers/src/func/odd.ts index f2914aff55..ab3065656e 100644 --- a/packages/transducers/src/func/odd.ts +++ b/packages/transducers/src/func/odd.ts @@ -1 +1 @@ -export { isOdd as odd } from "@thi.ng/checks/is-odd"; +export { isOdd as odd } from "@thi.ng/checks"; diff --git a/packages/transducers/src/func/renamer.ts b/packages/transducers/src/func/renamer.ts index 51f352aca4..1aefe1fd82 100644 --- a/packages/transducers/src/func/renamer.ts +++ b/packages/transducers/src/func/renamer.ts @@ -1,4 +1,4 @@ -import { IObjectOf } from "@thi.ng/api/api"; +import { IObjectOf } from "@thi.ng/api"; export const renamer = (kmap: IObjectOf) => { diff --git a/packages/transducers/src/iter/pairs.ts b/packages/transducers/src/iter/pairs.ts index 66a44b9a25..d8cc39c265 100644 --- a/packages/transducers/src/iter/pairs.ts +++ b/packages/transducers/src/iter/pairs.ts @@ -1,4 +1,4 @@ -import { IObjectOf } from "@thi.ng/api/api"; +import { IObjectOf } from "@thi.ng/api"; export function* pairs(x: IObjectOf): IterableIterator<[string, T]> { for (let k in x) { diff --git a/packages/transducers/src/iter/permutations.ts b/packages/transducers/src/iter/permutations.ts index 71377ebace..67c7fd2c50 100644 --- a/packages/transducers/src/iter/permutations.ts +++ b/packages/transducers/src/iter/permutations.ts @@ -1,4 +1,4 @@ -import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; +import { illegalArgs } from "@thi.ng/errors"; import { ensureArrayLike } from "../func/ensure-array"; import { range } from "./range"; diff --git a/packages/transducers/src/iter/range2d.ts b/packages/transducers/src/iter/range2d.ts index c20ce2cbf2..e1ef9e799d 100644 --- a/packages/transducers/src/iter/range2d.ts +++ b/packages/transducers/src/iter/range2d.ts @@ -1,5 +1,4 @@ -import { illegalArity } from "@thi.ng/errors/illegal-arity"; - +import { illegalArity } from "@thi.ng/errors"; import { range } from "./range"; export function range2d(toX: number, toY: number): IterableIterator<[number, number]>; diff --git a/packages/transducers/src/iter/range3d.ts b/packages/transducers/src/iter/range3d.ts index 3325ed43e5..cb68fc54f2 100644 --- a/packages/transducers/src/iter/range3d.ts +++ b/packages/transducers/src/iter/range3d.ts @@ -1,5 +1,4 @@ -import { illegalArity } from "@thi.ng/errors/illegal-arity"; - +import { illegalArity } from "@thi.ng/errors"; import { range } from "./range"; export function range3d(toX: number, toY: number, toZ: number): IterableIterator<[number, number, number]>; diff --git a/packages/transducers/src/iter/vals.ts b/packages/transducers/src/iter/vals.ts index 36c2acb2c5..679f9e862f 100644 --- a/packages/transducers/src/iter/vals.ts +++ b/packages/transducers/src/iter/vals.ts @@ -1,4 +1,4 @@ -import { IObjectOf } from "@thi.ng/api/api"; +import { IObjectOf } from "@thi.ng/api"; export function* vals(x: IObjectOf): IterableIterator { for (let k in x) { diff --git a/packages/transducers/src/iter/wrap.ts b/packages/transducers/src/iter/wrap.ts index b67d78c3e0..100e857528 100644 --- a/packages/transducers/src/iter/wrap.ts +++ b/packages/transducers/src/iter/wrap.ts @@ -1,4 +1,4 @@ -import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; +import { illegalArgs } from "@thi.ng/errors"; import { ensureArray } from "../func/ensure-array"; /** diff --git a/packages/transducers/src/iterator.ts b/packages/transducers/src/iterator.ts index fc161055ad..59bb3e21bd 100644 --- a/packages/transducers/src/iterator.ts +++ b/packages/transducers/src/iterator.ts @@ -1,5 +1,5 @@ -import { SEMAPHORE } from "@thi.ng/api/api"; -import { isIterable } from "@thi.ng/checks/is-iterable"; +import { SEMAPHORE } from "@thi.ng/api"; +import { isIterable } from "@thi.ng/checks"; import { Reducer, Transducer } from "./api"; import { isReduced, unreduced } from "./reduced"; diff --git a/packages/transducers/src/reduce.ts b/packages/transducers/src/reduce.ts index c2d01b0da6..7d1bb84562 100644 --- a/packages/transducers/src/reduce.ts +++ b/packages/transducers/src/reduce.ts @@ -1,8 +1,5 @@ -import { implementsFunction } from "@thi.ng/checks/implements-function"; -import { isArrayLike } from "@thi.ng/checks/is-arraylike"; -import { isIterable } from "@thi.ng/checks/is-iterable"; -import { illegalArity } from "@thi.ng/errors/illegal-arity"; - +import { implementsFunction, isArrayLike, isIterable } from "@thi.ng/checks"; +import { illegalArity } from "@thi.ng/errors"; import { IReducible, Reducer } from "./api"; import { isReduced, Reduced, unreduced } from "./reduced"; diff --git a/packages/transducers/src/reduced.ts b/packages/transducers/src/reduced.ts index 7e9f40afb9..e0e944c1bb 100644 --- a/packages/transducers/src/reduced.ts +++ b/packages/transducers/src/reduced.ts @@ -1,4 +1,4 @@ -import { IDeref } from "@thi.ng/api/api"; +import { IDeref } from "@thi.ng/api"; export class Reduced implements IDeref { diff --git a/packages/transducers/src/rfn/assoc-map.ts b/packages/transducers/src/rfn/assoc-map.ts index 24acf2f757..7f7ecefebd 100644 --- a/packages/transducers/src/rfn/assoc-map.ts +++ b/packages/transducers/src/rfn/assoc-map.ts @@ -1,7 +1,6 @@ -import { Pair } from "@thi.ng/api/api"; - +import { Pair } from "@thi.ng/api"; import { Reducer } from "../api"; -import { reducer, reduce } from "../reduce"; +import { reduce, reducer } from "../reduce"; /** * Reducer accepting key-value pairs / tuples and transforming / adding diff --git a/packages/transducers/src/rfn/assoc-obj.ts b/packages/transducers/src/rfn/assoc-obj.ts index 410f78eeaa..f29e0aa7c5 100644 --- a/packages/transducers/src/rfn/assoc-obj.ts +++ b/packages/transducers/src/rfn/assoc-obj.ts @@ -1,5 +1,4 @@ -import { IObjectOf, Pair } from "@thi.ng/api/api"; - +import { IObjectOf, Pair } from "@thi.ng/api"; import { Reducer } from "../api"; import { reduce, reducer } from "../reduce"; diff --git a/packages/transducers/src/rfn/every.ts b/packages/transducers/src/rfn/every.ts index e18a366709..3f882b3e05 100644 --- a/packages/transducers/src/rfn/every.ts +++ b/packages/transducers/src/rfn/every.ts @@ -1,5 +1,4 @@ -import { Predicate } from "@thi.ng/api/api"; - +import { Predicate } from "@thi.ng/api"; import { Reducer } from "../api"; import { $$reduce, reducer } from "../reduce"; import { reduced } from "../reduced"; diff --git a/packages/transducers/src/rfn/fill.ts b/packages/transducers/src/rfn/fill.ts index c68a89370a..742de3667c 100644 --- a/packages/transducers/src/rfn/fill.ts +++ b/packages/transducers/src/rfn/fill.ts @@ -1,7 +1,6 @@ -import { NumericArray } from "@thi.ng/api/api"; - +import { NumericArray } from "@thi.ng/api"; import { Reducer } from "../api"; -import { reducer, $$reduce } from "../reduce"; +import { $$reduce, reducer } from "../reduce"; /** * Reducer which starts filling array with results from given `start` diff --git a/packages/transducers/src/rfn/frequencies.ts b/packages/transducers/src/rfn/frequencies.ts index 3554709c87..1fa9467aa0 100644 --- a/packages/transducers/src/rfn/frequencies.ts +++ b/packages/transducers/src/rfn/frequencies.ts @@ -1,5 +1,4 @@ -import { Fn } from "@thi.ng/api/api"; - +import { Fn } from "@thi.ng/api"; import { Reducer } from "../api"; import { identity } from "../func/identity"; import { $$reduce } from "../reduce"; diff --git a/packages/transducers/src/rfn/group-binary.ts b/packages/transducers/src/rfn/group-binary.ts index e1bcc28a32..a0539edac3 100644 --- a/packages/transducers/src/rfn/group-binary.ts +++ b/packages/transducers/src/rfn/group-binary.ts @@ -1,5 +1,4 @@ -import { IObjectOf } from "@thi.ng/api/api"; - +import { IObjectOf } from "@thi.ng/api"; import { Reducer } from "../api"; import { groupByObj } from "./group-by-obj"; import { push } from "./push"; diff --git a/packages/transducers/src/rfn/group-by-obj.ts b/packages/transducers/src/rfn/group-by-obj.ts index 4f706a67bd..0e075ed96c 100644 --- a/packages/transducers/src/rfn/group-by-obj.ts +++ b/packages/transducers/src/rfn/group-by-obj.ts @@ -1,8 +1,7 @@ -import { IObjectOf } from "@thi.ng/api/api"; - +import { IObjectOf } from "@thi.ng/api"; import { GroupByOpts, Reducer } from "../api"; import { identity } from "../func/identity"; -import { reducer, $$reduce } from "../reduce"; +import { $$reduce, reducer } from "../reduce"; import { push } from "./push"; export function groupByObj(opts?: Partial>): Reducer, SRC>; diff --git a/packages/transducers/src/rfn/max-compare.ts b/packages/transducers/src/rfn/max-compare.ts index f49a78648f..6cca468f6a 100644 --- a/packages/transducers/src/rfn/max-compare.ts +++ b/packages/transducers/src/rfn/max-compare.ts @@ -1,6 +1,5 @@ -import { Comparator } from "@thi.ng/api/api"; +import { Comparator } from "@thi.ng/api"; import { compare } from "@thi.ng/compare"; - import { Reducer } from "../api"; import { $$reduce, reducer } from "../reduce"; diff --git a/packages/transducers/src/rfn/min-compare.ts b/packages/transducers/src/rfn/min-compare.ts index 381fe86420..f97ba5a3ce 100644 --- a/packages/transducers/src/rfn/min-compare.ts +++ b/packages/transducers/src/rfn/min-compare.ts @@ -1,6 +1,5 @@ -import { Comparator } from "@thi.ng/api/api"; +import { Comparator } from "@thi.ng/api"; import { compare } from "@thi.ng/compare"; - import { Reducer } from "../api"; import { $$reduce, reducer } from "../reduce"; diff --git a/packages/transducers/src/rfn/some.ts b/packages/transducers/src/rfn/some.ts index 266727ceab..90e67242b5 100644 --- a/packages/transducers/src/rfn/some.ts +++ b/packages/transducers/src/rfn/some.ts @@ -1,5 +1,4 @@ -import { Predicate } from "@thi.ng/api/api"; - +import { Predicate } from "@thi.ng/api"; import { Reducer } from "../api"; import { $$reduce, reducer } from "../reduce"; import { reduced } from "../reduced"; diff --git a/packages/transducers/src/transduce.ts b/packages/transducers/src/transduce.ts index 028bbf1bf8..91212f5ce0 100644 --- a/packages/transducers/src/transduce.ts +++ b/packages/transducers/src/transduce.ts @@ -1,5 +1,4 @@ -import { illegalArity } from "@thi.ng/errors/illegal-arity"; - +import { illegalArity } from "@thi.ng/errors"; import { IReducible, Reducer, Transducer } from "./api"; import { reduce } from "./reduce"; import { map } from "./xform/map"; diff --git a/packages/transducers/src/xform/convolve.ts b/packages/transducers/src/xform/convolve.ts index 6953b56044..b4dcbd15ab 100644 --- a/packages/transducers/src/xform/convolve.ts +++ b/packages/transducers/src/xform/convolve.ts @@ -1,5 +1,4 @@ -import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; - +import { illegalArgs } from "@thi.ng/errors"; import { Transducer } from "../api"; import { range2d } from "../iter/range2d"; import { tuples } from "../iter/tuples"; diff --git a/packages/transducers/src/xform/dedupe.ts b/packages/transducers/src/xform/dedupe.ts index 9834e7bb89..dacf24a2ba 100644 --- a/packages/transducers/src/xform/dedupe.ts +++ b/packages/transducers/src/xform/dedupe.ts @@ -1,5 +1,4 @@ -import { Predicate2, SEMAPHORE } from "@thi.ng/api/api"; - +import { Predicate2, SEMAPHORE } from "@thi.ng/api"; import { Reducer, Transducer } from "../api"; import { compR } from "../func/compr"; import { $iter } from "../iterator"; diff --git a/packages/transducers/src/xform/drop-while.ts b/packages/transducers/src/xform/drop-while.ts index a950d72180..abaa872067 100644 --- a/packages/transducers/src/xform/drop-while.ts +++ b/packages/transducers/src/xform/drop-while.ts @@ -1,5 +1,4 @@ -import { Predicate } from "@thi.ng/api/api"; - +import { Predicate } from "@thi.ng/api"; import { Reducer, Transducer } from "../api"; import { compR } from "../func/compr"; import { $iter } from "../iterator"; diff --git a/packages/transducers/src/xform/filter-fuzzy.ts b/packages/transducers/src/xform/filter-fuzzy.ts index 13d91830c3..9679fdc655 100644 --- a/packages/transducers/src/xform/filter-fuzzy.ts +++ b/packages/transducers/src/xform/filter-fuzzy.ts @@ -1,5 +1,4 @@ -import { Fn, Predicate2 } from "@thi.ng/api/api"; - +import { Fn, Predicate2 } from "@thi.ng/api"; import { Transducer } from "../api"; import { fuzzyMatch } from "../func/fuzzy-match"; import { $iter } from "../iterator"; diff --git a/packages/transducers/src/xform/hex-dump.ts b/packages/transducers/src/xform/hex-dump.ts index a25491038d..9c6cbbbcff 100644 --- a/packages/transducers/src/xform/hex-dump.ts +++ b/packages/transducers/src/xform/hex-dump.ts @@ -1,5 +1,4 @@ -import { U32, U8 } from "@thi.ng/strings/radix"; - +import { U32, U8 } from "@thi.ng/strings"; import { Transducer } from "../api"; import { comp } from "../func/comp"; import { juxt } from "../func/juxt"; diff --git a/packages/transducers/src/xform/labeled.ts b/packages/transducers/src/xform/labeled.ts index 73341868ae..611a5bbc19 100644 --- a/packages/transducers/src/xform/labeled.ts +++ b/packages/transducers/src/xform/labeled.ts @@ -1,5 +1,4 @@ -import { isFunction } from "@thi.ng/checks/is-function"; - +import { isFunction } from "@thi.ng/checks"; import { Transducer } from "../api"; import { iterator1 } from "../iterator"; import { map } from "./map"; diff --git a/packages/transducers/src/xform/map-keys.ts b/packages/transducers/src/xform/map-keys.ts index ff646a9b03..35ea24b9eb 100644 --- a/packages/transducers/src/xform/map-keys.ts +++ b/packages/transducers/src/xform/map-keys.ts @@ -1,5 +1,4 @@ -import { Fn, IObjectOf } from "@thi.ng/api/api"; - +import { Fn, IObjectOf } from "@thi.ng/api"; import { Transducer } from "../api"; import { $iter } from "../iterator"; import { map } from "./map"; diff --git a/packages/transducers/src/xform/map-nth.ts b/packages/transducers/src/xform/map-nth.ts index cc2750b894..95ab9e8bd1 100644 --- a/packages/transducers/src/xform/map-nth.ts +++ b/packages/transducers/src/xform/map-nth.ts @@ -1,5 +1,4 @@ -import { Fn } from "@thi.ng/api/api"; - +import { Fn } from "@thi.ng/api"; import { Reducer, Transducer } from "../api"; import { compR } from "../func/compr"; import { $iter } from "../iterator"; diff --git a/packages/transducers/src/xform/map-vals.ts b/packages/transducers/src/xform/map-vals.ts index 90eb39f13d..1a4f60cc7b 100644 --- a/packages/transducers/src/xform/map-vals.ts +++ b/packages/transducers/src/xform/map-vals.ts @@ -1,5 +1,4 @@ -import { Fn, IObjectOf } from "@thi.ng/api/api"; - +import { Fn, IObjectOf } from "@thi.ng/api"; import { Transducer } from "../api"; import { $iter } from "../iterator"; import { map } from "./map"; diff --git a/packages/transducers/src/xform/map.ts b/packages/transducers/src/xform/map.ts index 3a409a5247..ddbf92550c 100644 --- a/packages/transducers/src/xform/map.ts +++ b/packages/transducers/src/xform/map.ts @@ -1,5 +1,4 @@ -import { Fn } from "@thi.ng/api/api"; - +import { Fn } from "@thi.ng/api"; import { Reducer, Transducer } from "../api"; import { compR } from "../func/compr"; import { iterator1 } from "../iterator"; diff --git a/packages/transducers/src/xform/mapcat.ts b/packages/transducers/src/xform/mapcat.ts index 5038dac1a6..552afd5e0e 100644 --- a/packages/transducers/src/xform/mapcat.ts +++ b/packages/transducers/src/xform/mapcat.ts @@ -1,5 +1,4 @@ -import { Fn } from "@thi.ng/api/api"; - +import { Fn } from "@thi.ng/api"; import { Transducer } from "../api"; import { comp } from "../func/comp"; import { iterator } from "../iterator"; diff --git a/packages/transducers/src/xform/moving-average.ts b/packages/transducers/src/xform/moving-average.ts index 3100013a3a..178bdfa64c 100644 --- a/packages/transducers/src/xform/moving-average.ts +++ b/packages/transducers/src/xform/moving-average.ts @@ -1,5 +1,4 @@ -import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; - +import { illegalArgs } from "@thi.ng/errors"; import { Reducer, Transducer } from "../api"; import { compR } from "../func/compr"; import { iterator1 } from "../iterator"; diff --git a/packages/transducers/src/xform/multiplex-obj.ts b/packages/transducers/src/xform/multiplex-obj.ts index d0b9680df8..f9aa5f79cd 100644 --- a/packages/transducers/src/xform/multiplex-obj.ts +++ b/packages/transducers/src/xform/multiplex-obj.ts @@ -1,5 +1,4 @@ -import { IObjectOf } from "@thi.ng/api/api"; - +import { IObjectOf } from "@thi.ng/api"; import { Reducer, Transducer } from "../api"; import { comp } from "../func/comp"; import { $iter } from "../iterator"; diff --git a/packages/transducers/src/xform/partition-by.ts b/packages/transducers/src/xform/partition-by.ts index d40fd7b025..4966cb002c 100644 --- a/packages/transducers/src/xform/partition-by.ts +++ b/packages/transducers/src/xform/partition-by.ts @@ -1,5 +1,4 @@ -import { Fn, SEMAPHORE } from "@thi.ng/api/api"; - +import { Fn, SEMAPHORE } from "@thi.ng/api"; import { Transducer } from "../api"; import { $iter, iterator } from "../iterator"; import { isReduced } from "../reduced"; diff --git a/packages/transducers/src/xform/partition-sync.ts b/packages/transducers/src/xform/partition-sync.ts index f81291b21a..c02e180bde 100644 --- a/packages/transducers/src/xform/partition-sync.ts +++ b/packages/transducers/src/xform/partition-sync.ts @@ -1,6 +1,5 @@ -import { IObjectOf } from "@thi.ng/api/api"; -import { isArray } from "@thi.ng/checks/is-array"; - +import { IObjectOf } from "@thi.ng/api"; +import { isArray } from "@thi.ng/checks"; import { Reducer, Transducer } from "../api"; import { identity } from "../func/identity"; import { $iter, iterator } from "../iterator"; diff --git a/packages/transducers/src/xform/rename.ts b/packages/transducers/src/xform/rename.ts index af52156a98..2e55ddbbef 100644 --- a/packages/transducers/src/xform/rename.ts +++ b/packages/transducers/src/xform/rename.ts @@ -1,6 +1,5 @@ -import { IObjectOf } from "@thi.ng/api/api"; -import { isArray } from "@thi.ng/checks/is-array"; - +import { IObjectOf } from "@thi.ng/api"; +import { isArray } from "@thi.ng/checks"; import { Reducer, Transducer } from "../api"; import { comp } from "../func/comp"; import { renamer } from "../func/renamer"; diff --git a/packages/transducers/src/xform/struct.ts b/packages/transducers/src/xform/struct.ts index 577f0078c6..76a2c9e632 100644 --- a/packages/transducers/src/xform/struct.ts +++ b/packages/transducers/src/xform/struct.ts @@ -1,5 +1,4 @@ -import { Fn } from "@thi.ng/api/api"; - +import { Fn } from "@thi.ng/api"; import { Transducer } from "../api"; import { comp } from "../func/comp"; import { iterator } from "../iterator"; diff --git a/packages/transducers/src/xform/take-while.ts b/packages/transducers/src/xform/take-while.ts index 5a6e3798ba..a1a25b2d84 100644 --- a/packages/transducers/src/xform/take-while.ts +++ b/packages/transducers/src/xform/take-while.ts @@ -1,5 +1,4 @@ -import { Predicate } from "@thi.ng/api/api"; - +import { Predicate } from "@thi.ng/api"; import { Reducer, Transducer } from "../api"; import { compR } from "../func/compr"; import { $iter } from "../iterator"; diff --git a/packages/transducers/src/xform/throttle.ts b/packages/transducers/src/xform/throttle.ts index e8564cc139..a86fb2bb51 100644 --- a/packages/transducers/src/xform/throttle.ts +++ b/packages/transducers/src/xform/throttle.ts @@ -1,5 +1,4 @@ -import { StatefulPredicate } from "@thi.ng/api/api"; - +import { StatefulPredicate } from "@thi.ng/api"; import { Reducer, Transducer } from "../api"; import { compR } from "../func/compr"; import { iterator1 } from "../iterator"; diff --git a/packages/transducers/test/partition-bits.ts b/packages/transducers/test/partition-bits.ts index 9e6d09809e..deceb1fbe6 100644 --- a/packages/transducers/test/partition-bits.ts +++ b/packages/transducers/test/partition-bits.ts @@ -1,5 +1,5 @@ import * as assert from "assert"; -import { radix } from "@thi.ng/strings/radix"; +import { radix } from "@thi.ng/strings"; import { comp } from "../src/func/comp"; import { range } from "../src/iter/range"; diff --git a/packages/transducers/test/tsconfig.json b/packages/transducers/test/tsconfig.json index c93bb84899..2c9c12a650 100644 --- a/packages/transducers/test/tsconfig.json +++ b/packages/transducers/test/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../../tsconfig.json", "compilerOptions": { "outDir": "../build", - "module": "es6", - "target": "es6" + "module": "commonjs", }, "include": [ "./**/*.ts", diff --git a/packages/unionstruct/package.json b/packages/unionstruct/package.json index 1ee2cb8f8f..58ec64ef70 100644 --- a/packages/unionstruct/package.json +++ b/packages/unionstruct/package.json @@ -2,7 +2,9 @@ "name": "@thi.ng/unionstruct", "version": "0.1.19", "description": "C-style struct, union and bitfield views of ArrayBuffers", - "main": "./index.js", + "module": "./index.js", + "main": "./lib/index.js", + "umd:main": "./lib/index.umd.js", "typings": "./index.d.ts", "repository": { "type": "git", @@ -12,12 +14,14 @@ "author": "Karsten Schmidt ", "license": "Apache-2.0", "scripts": { - "build": "yarn clean && tsc --declaration", - "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc", + "build": "yarn clean && yarn build:es6 && yarn build:bundle", + "build:es6": "tsc --declaration", + "build:bundle": "../../scripts/bundle-module unionstruct", + "test": "rimraf build && tsc -p test/tsconfig.json && nyc mocha build/test/*.js", + "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc lib", "cover": "yarn test && nyc report --reporter=lcov", "doc": "node_modules/.bin/typedoc --mode modules --out doc src", - "pub": "yarn build && yarn publish --access public", - "test": "rimraf build && tsc -p test && nyc mocha build/test/*.js" + "pub": "yarn build && yarn publish --access public" }, "devDependencies": { "@types/mocha": "^5.2.5", @@ -34,11 +38,13 @@ "c", "cpp", "ES6", + "interop", "struct", "typescript", "union" ], "publishConfig": { "access": "public" - } + }, + "sideEffects": false } \ No newline at end of file diff --git a/packages/unionstruct/src/index.ts b/packages/unionstruct/src/index.ts index 88cfd8d40b..e735d0947b 100644 --- a/packages/unionstruct/src/index.ts +++ b/packages/unionstruct/src/index.ts @@ -24,35 +24,45 @@ const TYPES = { const UNION = "union"; const STRUCT = "struct"; -let isBitField = (f: Field) => typeof f[2] === "number" && /^(u|i)\d+$/.test(f[1]); +const isBitField = + (f: Field) => + typeof f[2] === "number" && /^(u|i)\d+$/.test(f[1]); -let align = (bitOffset: number, type: string, spec: any) => { - if (type === UNION) { - spec = (spec.__spec || spec); - let a = 0, f; - for (let i = 0; i < spec.length; i++) { - f = spec[i]; - a = Math.max(align(bitOffset, f[1], f[2]), a); +const align = + (bitOffset: number, type: string, spec: any) => { + if (type === UNION) { + spec = (spec.__spec || spec); + let a = 0, f; + for (let i = 0; i < spec.length; i++) { + f = spec[i]; + a = Math.max(align(bitOffset, f[1], f[2]), a); + } + return a; + } else if (type === STRUCT) { + spec = (spec.__spec || spec)[0]; + return align(bitOffset, spec[1], spec[2]); } - return a; - } else if (type === STRUCT) { - spec = (spec.__spec || spec)[0]; - return align(bitOffset, spec[1], spec[2]); - } - let block = TYPES[type][0]; - return block > 8 ? (bitOffset + block - 1) & -block : bitOffset; -}; + let block = TYPES[type][0]; + return block > 8 ? (bitOffset + block - 1) & -block : bitOffset; + }; -let maybePad = (offset: number, spec: any[], i: number) => { - let f = spec[i], width; - if (i === spec.length - 1 || !isBitField(spec[i + 1])) { - width = TYPES[f[1]][0]; - offset += ((offset + width - 1) & ~(width - 1)) - offset; - } - return offset; -}; +const maybePad = + (offset: number, spec: any[], i: number) => { + let f = spec[i], width; + if (i === spec.length - 1 || !isBitField(spec[i + 1])) { + width = TYPES[f[1]][0]; + offset += ((offset + width - 1) & ~(width - 1)) - offset; + } + return offset; + }; -let _sizeOf = (spec: Field[], union: boolean, doAlign: boolean, bitOffset: number, total: number) => { +const _sizeOf = ( + spec: Field[], + union: boolean, + doAlign: boolean, + bitOffset: number, + total: number +) => { for (let i = 0; i < spec.length; i++) { let f = spec[i], type = f[1], size = f[2], isBF = isBitField(f); bitOffset = doAlign && !isBF ? align(bitOffset, type, size) : bitOffset; @@ -71,36 +81,46 @@ let _sizeOf = (spec: Field[], union: boolean, doAlign: boolean, bitOffset: numbe return [total, bitOffset]; }; -export let sizeOf = (spec: Field[], union = false, doAlign = true) => - _sizeOf(spec, union, doAlign, 0, 0)[0]; +export const sizeOf = + (spec: Field[], union = false, doAlign = true) => + _sizeOf(spec, union, doAlign, 0, 0)[0]; -let bitReader = (dv: DataView, byteOffset: number, bit: number, size: number) => { - const b = bit - size; - if (b >= 0) { - return () => dv.getUint32(byteOffset, false) >>> b & (1 << size) - 1; - } - return () => ((dv.getUint32(byteOffset, false) & (1 << bit) - 1) << -b) | - (dv.getUint32(byteOffset + 4, false) >>> (32 + b)); -}; +const bitReader = + (dv: DataView, byteOffset: number, bit: number, size: number) => { + const b = bit - size; + if (b >= 0) { + return () => dv.getUint32(byteOffset, false) >>> b & (1 << size) - 1; + } + return () => ((dv.getUint32(byteOffset, false) & (1 << bit) - 1) << -b) | + (dv.getUint32(byteOffset + 4, false) >>> (32 + b)); + }; -let bitWriter = (dv: DataView, byteOffset: number, bit: number, size: number) => { - const b = bit - size; - let m = bit < 32 ? ~((1 << bit) - 1) : 0; - if (b >= 0) { - m |= (1 << b) - 1; - return (x) => { - dv.setUint32(byteOffset, (dv.getUint32(byteOffset, false) & m) | (x << b & ~m), false); - }; - } else { - let bb = 32 + b; - return (x) => { - dv.setUint32(byteOffset, (dv.getUint32(byteOffset, false) & m) | (x >>> -b & ~m), false); - dv.setUint32(byteOffset + 4, (dv.getUint32(byteOffset + 4, false) & (1 << bb) - 1) | x << bb, false); +const bitWriter = + (dv: DataView, byteOffset: number, bit: number, size: number) => { + const b = bit - size; + let m = bit < 32 ? ~((1 << bit) - 1) : 0; + if (b >= 0) { + m |= (1 << b) - 1; + return (x) => { + dv.setUint32(byteOffset, (dv.getUint32(byteOffset, false) & m) | (x << b & ~m), false); + }; + } else { + let bb = 32 + b; + return (x) => { + dv.setUint32(byteOffset, (dv.getUint32(byteOffset, false) & m) | (x >>> -b & ~m), false); + dv.setUint32(byteOffset + 4, (dv.getUint32(byteOffset + 4, false) & (1 << bb) - 1) | x << bb, false); + } } - } -}; + }; -let makeField = (field: Field, obj: any, dv: DataView, bitOffset: number, doAlign: boolean, le: boolean) => { +const makeField = ( + field: Field, + obj: any, + dv: DataView, + bitOffset: number, + doAlign: boolean, + le: boolean +) => { let [id, type, size] = field; const isBF = isBitField(field); bitOffset = doAlign && !isBF ? align(bitOffset, type, size) : bitOffset; @@ -146,7 +166,14 @@ let makeField = (field: Field, obj: any, dv: DataView, bitOffset: number, doAlig return bitOffset; }; -export let typedef = (spec: Field[], struct: boolean, buf?: ArrayBuffer, offset = 0, doAlign = true, le = false) => { +export const typedef = ( + spec: Field[], + struct: boolean, + buf?: ArrayBuffer, + offset = 0, + doAlign = true, + le = false +) => { let size = sizeOf(spec, !struct, doAlign); let dv = new DataView(buf || new ArrayBuffer(((size + 7) & -8) >>> 3)); let off = offset << 3; @@ -169,10 +196,12 @@ export let typedef = (spec: Field[], struct: boolean, buf?: ArrayBuffer, offset return obj; }; -export let union = (spec: Field[], buf?: ArrayBuffer, offset?: number, doAlign?: boolean, le?: boolean) => { - return typedef(spec, false, buf, offset, doAlign, le); -} +export const union = + (spec: Field[], buf?: ArrayBuffer, offset?: number, doAlign?: boolean, le?: boolean) => { + return typedef(spec, false, buf, offset, doAlign, le); + } -export let struct = (spec: Field[], buf?: ArrayBuffer, offset?: number, doAlign?: boolean, le?: boolean) => { - return typedef(spec, true, buf, offset, doAlign, le); -} +export const struct = + (spec: Field[], buf?: ArrayBuffer, offset?: number, doAlign?: boolean, le?: boolean) => { + return typedef(spec, true, buf, offset, doAlign, le); + } diff --git a/packages/unionstruct/test/tsconfig.json b/packages/unionstruct/test/tsconfig.json index c93bb84899..2c9c12a650 100644 --- a/packages/unionstruct/test/tsconfig.json +++ b/packages/unionstruct/test/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../../tsconfig.json", "compilerOptions": { "outDir": "../build", - "module": "es6", - "target": "es6" + "module": "commonjs", }, "include": [ "./**/*.ts", diff --git a/packages/vectors/package.json b/packages/vectors/package.json index f198471cff..0081e3567e 100644 --- a/packages/vectors/package.json +++ b/packages/vectors/package.json @@ -2,7 +2,9 @@ "name": "@thi.ng/vectors", "version": "1.4.12", "description": "Vector algebra for fixed & variable sizes, memory mapped, flexible layouts", - "main": "./index.js", + "module": "./index.js", + "main": "./lib/index.js", + "umd:main": "./lib/index.umd.js", "typings": "./index.d.ts", "repository": { "type": "git", @@ -12,12 +14,14 @@ "author": "Karsten Schmidt ", "license": "Apache-2.0", "scripts": { - "build": "yarn clean && tsc --declaration", - "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc", + "build": "yarn clean && yarn build:es6 && yarn build:bundle", + "build:es6": "tsc --declaration", + "build:bundle": "../../scripts/bundle-module vectors api checks errors math transducers", + "test": "rimraf build && tsc -p test/tsconfig.json && nyc mocha build/test/*.js", + "clean": "rimraf *.js *.d.ts .nyc_output build coverage doc lib", "cover": "yarn test && nyc report --reporter=lcov", "doc": "node_modules/.bin/typedoc --mode modules --out doc src", - "pub": "yarn build && yarn publish --access public", - "test": "rimraf build && tsc -p test && nyc mocha build/test/*.js" + "pub": "yarn build && yarn publish --access public" }, "devDependencies": { "@types/mocha": "^5.2.5", @@ -46,5 +50,6 @@ ], "publishConfig": { "access": "public" - } + }, + "sideEffects": false } \ No newline at end of file diff --git a/packages/vectors/src/api.ts b/packages/vectors/src/api.ts index c3ece347d7..afff2a2c45 100644 --- a/packages/vectors/src/api.ts +++ b/packages/vectors/src/api.ts @@ -1,12 +1,12 @@ import { + ICompare, ICopy, + IEmpty, IEqualsDelta, IEquiv, - NumericArray, - IEmpty, ILength, - ICompare -} from "@thi.ng/api/api"; + NumericArray +} from "@thi.ng/api"; export type Vec = NumericArray; export type ReadonlyVec = ArrayLike & Iterable; diff --git a/packages/vectors/src/codegen.ts b/packages/vectors/src/codegen.ts index 089d4ce6cc..3e840bcc65 100644 --- a/packages/vectors/src/codegen.ts +++ b/packages/vectors/src/codegen.ts @@ -1,11 +1,13 @@ -import { comp } from "@thi.ng/transducers/func/comp"; -import { range } from "@thi.ng/transducers/iter/range"; -import { tuples } from "@thi.ng/transducers/iter/tuples"; -import { push } from "@thi.ng/transducers/rfn/push"; -import { transduce } from "@thi.ng/transducers/transduce"; -import { map } from "@thi.ng/transducers/xform/map"; -import { mapcat } from "@thi.ng/transducers/xform/mapcat"; -import { take } from "@thi.ng/transducers/xform/take"; +import { + comp, + map, + mapcat, + push, + range, + take, + transduce, + tuples +} from "@thi.ng/transducers"; import { Vec, VecOp1, diff --git a/packages/vectors/src/common.ts b/packages/vectors/src/common.ts index 1d6dd58ec9..4e4664af96 100644 --- a/packages/vectors/src/common.ts +++ b/packages/vectors/src/common.ts @@ -1,5 +1,4 @@ -import { EPS } from "@thi.ng/math/api"; -import { eqDelta as _eqDelta } from "@thi.ng/math/eqdelta"; +import { EPS, eqDelta as _eqDelta } from "@thi.ng/math"; import { ReadonlyVec, ReadonlyVecOp1, diff --git a/packages/vectors/src/gvec.ts b/packages/vectors/src/gvec.ts index c0a65e9cea..e4aa908a30 100644 --- a/packages/vectors/src/gvec.ts +++ b/packages/vectors/src/gvec.ts @@ -3,14 +3,17 @@ import { IEqualsDelta, IEquiv, ILength -} from "@thi.ng/api/api"; -import { isArrayLike } from "@thi.ng/checks/is-arraylike"; -import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; -import { sign as _sign } from "@thi.ng/math/abs"; -import { EPS } from "@thi.ng/math/api"; -import { clamp as _clamp } from "@thi.ng/math/interval"; -import { fract as _fract } from "@thi.ng/math/prec"; -import { smoothStep as _smoothStep, step as _step } from "@thi.ng/math/step"; +} from "@thi.ng/api"; +import { isArrayLike } from "@thi.ng/checks"; +import { illegalArgs } from "@thi.ng/errors"; +import { + clamp as _clamp, + EPS, + fract as _fract, + sign as _sign, + smoothStep as _smoothStep, + step as _step +} from "@thi.ng/math"; import { IDotProduct, IMagnitude, @@ -24,7 +27,6 @@ import { } from "./api"; import { $iter, eqDelta, equiv } from "./common"; - export const opg0 = (fn: () => number, a: Vec, num = a.length, i = 0, s = 1) => { i += num * s; while (i -= s, --num >= 0) { diff --git a/packages/vectors/src/mat23.ts b/packages/vectors/src/mat23.ts index dbd72e5654..8e412ad833 100644 --- a/packages/vectors/src/mat23.ts +++ b/packages/vectors/src/mat23.ts @@ -1,6 +1,6 @@ -import { ICopy, IEqualsDelta } from "@thi.ng/api/api"; -import { isArrayLike } from "@thi.ng/checks/is-arraylike"; -import { EPS } from "@thi.ng/math/api"; +import { ICopy, IEqualsDelta } from "@thi.ng/api"; +import { isArrayLike } from "@thi.ng/checks"; +import { EPS } from "@thi.ng/math"; import { Mat, ReadonlyMat, diff --git a/packages/vectors/src/mat33.ts b/packages/vectors/src/mat33.ts index b4235482ef..8019b6393b 100644 --- a/packages/vectors/src/mat33.ts +++ b/packages/vectors/src/mat33.ts @@ -1,6 +1,6 @@ -import { ICopy, IEqualsDelta } from "@thi.ng/api/api"; -import { isArrayLike } from "@thi.ng/checks/is-arraylike"; -import { EPS } from "@thi.ng/math/api"; +import { ICopy, IEqualsDelta } from "@thi.ng/api"; +import { isArrayLike } from "@thi.ng/checks"; +import { EPS } from "@thi.ng/math"; import { Mat, ReadonlyMat, diff --git a/packages/vectors/src/mat44.ts b/packages/vectors/src/mat44.ts index fdb447d5a1..7dfae1fae6 100644 --- a/packages/vectors/src/mat44.ts +++ b/packages/vectors/src/mat44.ts @@ -1,5 +1,6 @@ -import { ICopy, IEqualsDelta } from "@thi.ng/api/api"; -import { isArrayLike } from "@thi.ng/checks/is-arraylike"; +import { ICopy, IEqualsDelta } from "@thi.ng/api"; +import { isArrayLike } from "@thi.ng/checks"; +import { DEG2RAD, EPS } from "@thi.ng/math"; import { Mat, ReadonlyMat, @@ -20,7 +21,6 @@ import { Vec3 } from "./vec3"; import { dot4, setS4, Vec4 } from "./vec4"; -import { EPS, DEG2RAD } from "@thi.ng/math/api"; export const get44 = (a: Mat, i = 0) => a.slice(i, i + 16); diff --git a/packages/vectors/src/vec2.ts b/packages/vectors/src/vec2.ts index d13aa63d09..7a3ee8ea46 100644 --- a/packages/vectors/src/vec2.ts +++ b/packages/vectors/src/vec2.ts @@ -1,11 +1,17 @@ -import { isArrayLike } from "@thi.ng/checks/is-arraylike"; -import { atan2Abs } from "@thi.ng/math/angle"; -import { EPS, HALF_PI, PI } from "@thi.ng/math/api"; -import { eqDelta } from "@thi.ng/math/eqdelta"; -import { max2id, min2id } from "@thi.ng/math/interval"; -import { mixBilinear } from "@thi.ng/math/mix"; -import { fract } from "@thi.ng/math/prec"; -import { smoothStep, step } from "@thi.ng/math/step"; +import { isArrayLike } from "@thi.ng/checks"; +import { + atan2Abs, + EPS, + eqDelta, + fract, + HALF_PI, + max2id, + min2id, + mixBilinear, + PI, + smoothStep, + step +} from "@thi.ng/math"; import { IAngleBetween, ICrossProduct, diff --git a/packages/vectors/src/vec3.ts b/packages/vectors/src/vec3.ts index 1ce2dfd6c4..c8003a52ec 100644 --- a/packages/vectors/src/vec3.ts +++ b/packages/vectors/src/vec3.ts @@ -1,11 +1,15 @@ -import { isArrayLike } from "@thi.ng/checks/is-arraylike"; -import { atan2Abs } from "@thi.ng/math/angle"; -import { EPS } from "@thi.ng/math/api"; -import { eqDelta } from "@thi.ng/math/eqdelta"; -import { max3id, min3id } from "@thi.ng/math/interval"; -import { mixBilinear } from "@thi.ng/math/mix"; -import { fract } from "@thi.ng/math/prec"; -import { smoothStep, step } from "@thi.ng/math/step"; +import { isArrayLike } from "@thi.ng/checks"; +import { + atan2Abs, + EPS, + eqDelta, + fract, + max3id, + min3id, + mixBilinear, + smoothStep, + step +} from "@thi.ng/math"; import { IAngleBetween, ICrossProduct, diff --git a/packages/vectors/src/vec4.ts b/packages/vectors/src/vec4.ts index 310f1ca4a8..90f83ae776 100644 --- a/packages/vectors/src/vec4.ts +++ b/packages/vectors/src/vec4.ts @@ -1,10 +1,14 @@ -import { isArrayLike } from "@thi.ng/checks/is-arraylike"; -import { EPS } from "@thi.ng/math/api"; -import { eqDelta } from "@thi.ng/math/eqdelta"; -import { max4id, min4id } from "@thi.ng/math/interval"; -import { mixBilinear } from "@thi.ng/math/mix"; -import { fract } from "@thi.ng/math/prec"; -import { smoothStep, step } from "@thi.ng/math/step"; +import { isArrayLike } from "@thi.ng/checks"; +import { + EPS, + eqDelta, + fract, + max4id, + min4id, + mixBilinear, + smoothStep, + step +} from "@thi.ng/math"; import { IVec, IVector, diff --git a/packages/vectors/test/tsconfig.json b/packages/vectors/test/tsconfig.json index c93bb84899..2c9c12a650 100644 --- a/packages/vectors/test/tsconfig.json +++ b/packages/vectors/test/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../../tsconfig.json", "compilerOptions": { "outDir": "../build", - "module": "es6", - "target": "es6" + "module": "commonjs", }, "include": [ "./**/*.ts",