From 138571a498530536b6ea130d78e4c87c0a2fc576 Mon Sep 17 00:00:00 2001 From: Karsten Schmidt Date: Fri, 10 Sep 2021 23:55:50 +0200 Subject: [PATCH] refactor: update imports --- packages/gp/src/ast.ts | 12 +- packages/gp/src/mep.ts | 6 +- packages/gp/src/utils.ts | 6 +- packages/grid-iterators/src/columns.ts | 3 +- packages/grid-iterators/src/interleave.ts | 3 +- packages/grid-iterators/src/random.ts | 7 +- packages/grid-iterators/src/rows.ts | 2 +- packages/grid-iterators/src/zcurve.ts | 4 +- packages/hdiff/src/diff.ts | 6 +- packages/hdiff/src/html.ts | 2 +- packages/hdiff/src/theme.ts | 2 +- packages/hdom-canvas/src/index.ts | 13 +- packages/hdom-components/src/button-group.ts | 17 +- packages/hdom-components/src/fps-counter.ts | 4 +- packages/hdom-components/src/link.ts | 2 +- packages/hdom-components/src/pager.ts | 3 +- packages/hdom-components/src/sparkline.ts | 5 +- packages/hdom-mock/src/index.ts | 14 +- packages/hdom/src/diff.ts | 6 +- packages/hdom/src/dom.ts | 14 +- packages/hdom/src/logger.ts | 3 +- packages/hdom/src/normalize.ts | 13 +- packages/hdom/src/render-once.ts | 2 +- packages/hdom/src/start.ts | 2 +- packages/hdom/src/utils.ts | 2 +- packages/heaps/src/heap.ts | 2 +- packages/heaps/src/pairing.ts | 2 +- packages/heaps/src/priority-queue.ts | 2 +- packages/hiccup-canvas/src/arc.ts | 2 +- packages/hiccup-canvas/src/color.ts | 4 +- packages/hiccup-canvas/src/draw.ts | 3 +- packages/hiccup-canvas/src/image.ts | 2 +- packages/hiccup-canvas/src/packed-points.ts | 2 +- packages/hiccup-canvas/src/points.ts | 2 +- packages/hiccup-canvas/src/state.ts | 2 +- packages/hiccup-css/src/conditional.ts | 26 +- packages/hiccup-css/src/css.ts | 12 +- packages/hiccup-css/src/impl.ts | 32 ++- packages/hiccup-markdown/src/parse.ts | 137 +++++----- packages/hiccup-markdown/src/serialize.ts | 41 ++- packages/hiccup-svg/src/convert.ts | 3 +- packages/hiccup-svg/src/format.ts | 5 +- packages/hiccup-svg/src/svg.ts | 2 +- packages/hiccup/src/attribs.ts | 4 +- packages/hiccup/src/css.ts | 4 +- packages/hiccup/src/deref.ts | 2 +- packages/hiccup/src/normalize.ts | 5 +- packages/hiccup/src/serialize.ts | 20 +- packages/idgen/src/index.ts | 11 +- packages/iges/src/index.ts | 29 +-- packages/imgui/src/behaviors/dial.ts | 7 +- packages/imgui/src/behaviors/slider.ts | 8 +- packages/imgui/src/behaviors/text.ts | 2 +- packages/imgui/src/components/button.ts | 3 +- packages/imgui/src/components/dial.ts | 9 +- packages/imgui/src/components/dropdown.ts | 8 +- packages/imgui/src/components/icon-button.ts | 5 +- packages/imgui/src/components/radial-menu.ts | 9 +- packages/imgui/src/components/radio.ts | 4 +- packages/imgui/src/components/ring.ts | 16 +- packages/imgui/src/components/sliderh.ts | 4 +- packages/imgui/src/components/sliderv.ts | 5 +- packages/imgui/src/components/textfield.ts | 4 +- packages/imgui/src/components/textlabel.ts | 2 +- packages/imgui/src/components/toggle.ts | 2 +- packages/imgui/src/components/tooltip.ts | 2 +- packages/imgui/src/components/xypad.ts | 4 +- packages/imgui/src/gui.ts | 9 +- packages/imgui/src/hash.ts | 2 +- packages/imgui/src/layout.ts | 3 +- packages/interceptors/src/api.ts | 3 +- packages/interceptors/src/event-bus.ts | 60 +++-- packages/interceptors/src/interceptors.ts | 52 ++-- packages/intervals/src/index.ts | 18 +- packages/iterators/src/ensure.ts | 2 +- packages/iterators/src/fnil.ts | 2 +- packages/iterators/src/fork.ts | 2 +- packages/iterators/src/interleave.ts | 2 +- packages/iterators/src/juxt.ts | 16 +- packages/iterators/src/partition.ts | 2 +- packages/k-means/src/kmeans.ts | 16 +- packages/ksuid/src/aksuid.ts | 10 +- packages/ksuid/src/ulid.ts | 2 +- packages/layout/src/grid-layout.ts | 2 +- packages/layout/src/is-layout.ts | 2 +- packages/leb128/src/index.ts | 32 ++- packages/lowdisc/src/lowdisc.ts | 2 +- packages/lowdisc/src/plastic.ts | 2 +- packages/lsys/src/index.ts | 19 +- packages/malloc/src/native.ts | 7 +- packages/malloc/src/pool.ts | 15 +- packages/markdown-table/src/table.ts | 46 ++-- packages/math/src/solve.ts | 7 +- packages/matrices/src/add.ts | 2 +- packages/matrices/src/addn.ts | 2 +- packages/matrices/src/alignment-quat.ts | 12 +- packages/matrices/src/column.ts | 3 +- packages/matrices/src/conjugate.ts | 3 +- packages/matrices/src/determinant.ts | 2 +- packages/matrices/src/diag.ts | 3 +- packages/matrices/src/div.ts | 2 +- packages/matrices/src/divn.ts | 2 +- packages/matrices/src/frustum.ts | 4 +- packages/matrices/src/identity.ts | 2 +- packages/matrices/src/internal/codegen.ts | 5 +- packages/matrices/src/invert.ts | 16 +- packages/matrices/src/lookat.ts | 14 +- packages/matrices/src/m22-m23.ts | 2 +- packages/matrices/src/m23-m22.ts | 2 +- packages/matrices/src/m23-m44.ts | 2 +- packages/matrices/src/m33-m44.ts | 2 +- packages/matrices/src/m44-m33.ts | 2 +- packages/matrices/src/matv.ts | 2 +- packages/matrices/src/mixq.ts | 6 +- packages/matrices/src/mul.ts | 2 +- packages/matrices/src/mulm.ts | 4 +- packages/matrices/src/muln.ts | 2 +- packages/matrices/src/mulq.ts | 3 +- packages/matrices/src/mulv.ts | 16 +- packages/matrices/src/mulvm.ts | 17 +- packages/matrices/src/orthagonal.ts | 3 +- packages/matrices/src/ortho.ts | 2 +- packages/matrices/src/outer-product.ts | 4 +- packages/matrices/src/project.ts | 3 +- packages/matrices/src/quat-axis-angle.ts | 5 +- packages/matrices/src/quat-euler.ts | 2 +- packages/matrices/src/quat-m33.ts | 2 +- packages/matrices/src/quat-m44.ts | 3 +- packages/matrices/src/rotation-around-axis.ts | 6 +- packages/matrices/src/rotation.ts | 4 +- packages/matrices/src/row.ts | 3 +- packages/matrices/src/scale-center.ts | 3 +- packages/matrices/src/scale.ts | 4 +- packages/matrices/src/set.ts | 4 +- packages/matrices/src/sub.ts | 2 +- packages/matrices/src/subn.ts | 2 +- packages/matrices/src/trace.ts | 2 +- packages/matrices/src/translation.ts | 3 +- packages/matrices/src/transpose.ts | 2 +- packages/morton/src/scaled.ts | 8 +- packages/morton/src/tree.ts | 2 +- packages/morton/src/zcurve.ts | 6 +- packages/oquery/src/query.ts | 6 +- packages/parse/src/context.ts | 3 +- packages/parse/src/error.ts | 2 +- packages/parse/src/grammar.ts | 15 +- packages/parse/src/presets/alpha.ts | 5 +- packages/parse/src/presets/escape.ts | 2 +- packages/parse/src/presets/hex.ts | 2 +- packages/parse/src/presets/whitespace.ts | 2 +- packages/parse/src/prims/anchor.ts | 12 +- packages/parse/src/prims/none-of.ts | 3 +- packages/parse/src/prims/one-of.ts | 3 +- packages/parse/src/prims/pass.ts | 11 +- packages/parse/src/prims/skip.ts | 22 +- packages/paths/src/mut-in-many.ts | 2 +- packages/paths/src/path.ts | 7 +- packages/paths/src/set-in-many.ts | 2 +- packages/paths/src/setter.ts | 13 +- packages/pixel-io-netpbm/src/read.ts | 10 +- packages/pixel-io-netpbm/src/write.ts | 4 +- packages/pixel/src/canvas.ts | 2 +- packages/pixel/src/codegen.ts | 2 +- packages/pixel/src/convolve.ts | 28 ++- packages/pixel/src/dither.ts | 2 +- packages/pixel/src/dominant-colors.ts | 3 +- packages/pixel/src/float.ts | 11 +- packages/pixel/src/format/argb8888.ts | 2 +- packages/pixel/src/format/float-format.ts | 2 +- packages/pixel/src/format/float-hsva.ts | 3 +- packages/pixel/src/format/float-norm.ts | 2 +- packages/pixel/src/format/indexed.ts | 5 +- packages/pixel/src/format/packed-format.ts | 5 +- packages/pixel/src/packed.ts | 16 +- packages/pixel/src/pyramid.ts | 2 +- packages/pixel/src/sample.ts | 238 +++++++++--------- packages/pixel/src/utils.ts | 9 +- packages/pointfree-lang/src/index.ts | 85 ++++--- packages/pointfree/src/array.ts | 6 +- packages/pointfree/src/cond.ts | 42 ++-- packages/pointfree/src/env.ts | 10 +- packages/pointfree/src/ops.ts | 44 ++-- packages/pointfree/src/run.ts | 5 +- packages/pointfree/src/safe.ts | 5 +- packages/pointfree/src/word.ts | 5 +- packages/poisson/src/poisson.ts | 7 +- packages/poisson/src/stratified.ts | 9 +- packages/porter-duff/src/porter-duff.ts | 96 +++---- packages/ramp/src/aramp.ts | 10 +- packages/ramp/src/hermite.ts | 19 +- packages/ramp/src/linear.ts | 2 +- packages/random/src/random-bytes.ts | 2 +- packages/random/src/unique-indices.ts | 3 +- packages/random/src/weighted-random.ts | 2 +- packages/range-coder/src/index.ts | 3 +- packages/rdom-canvas/src/index.ts | 24 +- packages/rdom-components/src/accordion.ts | 12 +- packages/rdom-components/src/dropdown.ts | 5 +- packages/rdom-components/src/editor.ts | 16 +- packages/rdom-components/src/icon-button.ts | 3 +- packages/rdom-components/src/input.ts | 14 +- packages/rdom-components/src/radio.ts | 6 +- packages/rdom-components/src/tabs.ts | 12 +- packages/rdom/src/checks.ts | 5 + packages/rdom/src/compile.ts | 6 +- packages/rdom/src/dom.ts | 31 ++- packages/rdom/src/event.ts | 2 +- packages/rdom/src/index.ts | 2 +- packages/rdom/src/object.ts | 11 +- packages/rdom/src/sub.ts | 8 +- packages/rdom/src/switch.ts | 3 +- packages/rdom/src/utils.ts | 9 - packages/rdom/src/wrap.ts | 36 ++- packages/resolve-map/src/index.ts | 14 +- packages/rle-pack/src/index.ts | 5 +- packages/router/src/basic.ts | 16 +- packages/router/src/history.ts | 4 +- packages/rstream-csp/src/from/channel.ts | 3 +- packages/rstream-dot/src/index.ts | 14 +- .../rstream-gestures/src/gesture-stream.ts | 10 +- packages/rstream-graph/src/graph.ts | 81 +++--- packages/rstream-graph/src/nodes/extract.ts | 4 +- packages/rstream-graph/src/nodes/math.ts | 2 +- packages/rstream-log/src/logger.ts | 8 +- packages/rstream-log/src/xform/filter.ts | 4 +- packages/rstream-log/src/xform/format.ts | 7 +- packages/rstream-query/src/api.ts | 3 +- packages/rstream-query/src/convert.ts | 35 +-- packages/rstream-query/src/pattern.ts | 2 +- packages/rstream-query/src/qvar.ts | 2 +- packages/rstream-query/src/store.ts | 38 ++- packages/rstream-query/src/xforms.ts | 44 ++-- packages/rstream/src/api.ts | 3 +- packages/rstream/src/checks.ts | 5 + packages/rstream/src/forkjoin.ts | 36 ++- packages/rstream/src/from/object.ts | 5 +- packages/rstream/src/from/promises.ts | 2 +- packages/rstream/src/from/raf.ts | 2 +- packages/rstream/src/from/view.ts | 7 +- packages/rstream/src/index.ts | 1 + packages/rstream/src/metastream.ts | 4 +- packages/rstream/src/pubsub.ts | 7 +- packages/rstream/src/stream-sync.ts | 12 +- packages/rstream/src/stream.ts | 2 +- packages/rstream/src/subs/post-worker.ts | 3 +- packages/rstream/src/subs/resolve.ts | 3 +- .../rstream/src/subs/sidechain-partition.ts | 4 +- packages/rstream/src/subs/transduce.ts | 2 +- packages/rstream/src/subscription.ts | 26 +- packages/rstream/src/tween.ts | 6 +- packages/sax/src/index.ts | 6 +- packages/scenegraph/src/anode.ts | 3 +- packages/scenegraph/src/hiccup.ts | 5 +- packages/scenegraph/src/node2.ts | 13 +- packages/scenegraph/src/node3.ts | 13 +- packages/seq/src/ensure.ts | 3 +- packages/sexpr/src/parse.ts | 2 +- packages/sexpr/src/runtime.ts | 3 +- packages/shader-ast-glsl/src/target.ts | 5 +- packages/shader-ast-js/src/env.ts | 14 +- packages/shader-ast-js/src/env/bvec.ts | 14 +- packages/shader-ast-js/src/env/int.ts | 2 +- packages/shader-ast-js/src/env/ivec2.ts | 30 +-- packages/shader-ast-js/src/env/ivec3.ts | 30 +-- packages/shader-ast-js/src/env/ivec4.ts | 30 +-- packages/shader-ast-js/src/env/mat2.ts | 2 +- packages/shader-ast-js/src/env/mat3.ts | 4 +- packages/shader-ast-js/src/env/mat4.ts | 4 +- packages/shader-ast-js/src/env/uint.ts | 2 +- packages/shader-ast-js/src/env/uvec2.ts | 30 +-- packages/shader-ast-js/src/env/uvec3.ts | 30 +-- packages/shader-ast-js/src/env/uvec4.ts | 30 +-- packages/shader-ast-js/src/env/vec2.ts | 107 ++++---- packages/shader-ast-js/src/env/vec3.ts | 109 ++++---- packages/shader-ast-js/src/env/vec4.ts | 107 ++++---- packages/shader-ast-js/src/runtime.ts | 8 +- packages/shader-ast-js/src/target.ts | 8 +- packages/shader-ast/src/ast/assign.ts | 2 +- packages/shader-ast/src/ast/checks.ts | 4 +- packages/shader-ast/src/ast/function.ts | 5 +- packages/shader-ast/src/ast/indexed.ts | 2 +- packages/shader-ast/src/ast/lit.ts | 3 +- packages/shader-ast/src/ast/ops.ts | 2 +- packages/shader-ast/src/ast/scope.ts | 2 +- packages/shader-ast/src/ast/sym.ts | 6 +- packages/shader-ast/src/builtin/texture.ts | 2 +- packages/shader-ast/src/logger.ts | 3 +- packages/shader-ast/src/optimize.ts | 11 +- packages/shader-ast/src/target.ts | 5 +- packages/simd/src/index.ts | 2 +- packages/soa/src/aos.ts | 5 +- packages/soa/src/serialize.ts | 4 +- packages/soa/src/soa.ts | 6 +- packages/sparse/src/amatrix.ts | 2 +- packages/sparse/src/coo.ts | 4 +- packages/sparse/src/csc.ts | 4 +- packages/sparse/src/csr.ts | 4 +- packages/sparse/src/diag.ts | 4 +- packages/sparse/src/vec.ts | 5 +- packages/strings/src/center.ts | 2 +- packages/strings/src/float.ts | 16 +- packages/strings/src/int.ts | 8 +- packages/strings/src/interpolate.ts | 2 +- packages/strings/src/join.ts | 6 +- packages/strings/src/pad-left.ts | 2 +- packages/strings/src/pad-right.ts | 2 +- packages/strings/src/radix.ts | 2 +- packages/strings/src/repeat.ts | 2 +- packages/strings/src/splice.ts | 2 +- packages/strings/src/trim.ts | 2 +- packages/strings/src/truncate-left.ts | 16 +- packages/strings/src/truncate.ts | 14 +- packages/strings/src/units.ts | 2 +- packages/strings/src/vector.ts | 2 +- packages/strings/src/wrap.ts | 8 +- packages/system/src/api.ts | 3 +- packages/text-canvas/src/bars.ts | 9 +- packages/text-canvas/src/canvas.ts | 4 +- packages/text-canvas/src/circle.ts | 2 +- packages/text-canvas/src/format.ts | 4 +- packages/text-canvas/src/hvline.ts | 2 +- packages/text-canvas/src/image.ts | 6 +- packages/text-canvas/src/line.ts | 4 +- packages/text-canvas/src/rect.ts | 2 +- packages/text-canvas/src/table.ts | 6 +- packages/text-canvas/src/text.ts | 6 +- packages/transducers-binary/src/base64.ts | 14 +- packages/transducers-binary/src/bits.ts | 12 +- packages/transducers-binary/src/bytes.ts | 19 +- packages/transducers-binary/src/hex-dump.ts | 19 +- .../transducers-binary/src/partition-bits.ts | 10 +- .../transducers-binary/src/random-bits.ts | 5 +- packages/transducers-binary/src/utf8.ts | 12 +- packages/transducers-fsm/src/index.ts | 50 ++-- packages/transducers-hdom/src/index.ts | 5 +- packages/transducers-patch/src/patch-array.ts | 8 +- packages/transducers-patch/src/patch-obj.ts | 11 +- packages/transducers-stats/src/bollinger.ts | 16 +- packages/transducers-stats/src/donchian.ts | 12 +- packages/transducers-stats/src/ema.ts | 6 +- packages/transducers-stats/src/hma.ts | 14 +- packages/transducers-stats/src/macd.ts | 5 +- packages/transducers-stats/src/momentum.ts | 8 +- packages/transducers-stats/src/roc.ts | 8 +- packages/transducers-stats/src/rsi.ts | 14 +- packages/transducers-stats/src/sd.ts | 16 +- packages/transducers-stats/src/sma.ts | 8 +- packages/transducers-stats/src/stochastic.ts | 5 +- packages/transducers-stats/src/trix.ts | 4 +- packages/transducers-stats/src/wma.ts | 16 +- packages/transducers/src/func/comp.ts | 2 +- .../transducers/src/func/deep-transform.ts | 2 +- packages/transducers/src/internal/drain.ts | 18 +- packages/transducers/src/internal/ensure.ts | 2 +- .../transducers/src/internal/group-opts.ts | 3 +- .../transducers/src/internal/sort-opts.ts | 5 +- packages/transducers/src/iter/choices.ts | 6 +- packages/transducers/src/iter/concat.ts | 2 +- packages/transducers/src/iter/dup.ts | 5 +- packages/transducers/src/iter/extend-sides.ts | 2 +- packages/transducers/src/iter/palindrome.ts | 5 +- packages/transducers/src/iter/permutations.ts | 4 +- packages/transducers/src/iter/range2d.ts | 2 +- packages/transducers/src/iter/range3d.ts | 2 +- packages/transducers/src/iter/reverse.ts | 2 +- packages/transducers/src/iter/sorted-keys.ts | 2 +- packages/transducers/src/iter/wrap-sides.ts | 6 +- packages/transducers/src/iterator.ts | 5 +- packages/transducers/src/reduce.ts | 6 +- packages/transducers/src/rfn/frequencies.ts | 2 +- packages/transducers/src/rfn/group-binary.ts | 10 +- packages/transducers/src/rfn/last.ts | 2 +- packages/transducers/src/rfn/max-compare.ts | 2 +- packages/transducers/src/rfn/min-compare.ts | 2 +- .../transducers/src/rfn/norm-frequencies.ts | 2 +- packages/transducers/src/rfn/push-sort.ts | 2 +- packages/transducers/src/run.ts | 3 +- packages/transducers/src/transduce.ts | 2 +- packages/transducers/src/xform/benchmark.ts | 2 +- packages/transducers/src/xform/cat.ts | 28 +-- packages/transducers/src/xform/converge.ts | 3 +- packages/transducers/src/xform/convolve.ts | 2 +- packages/transducers/src/xform/dedupe.ts | 3 +- packages/transducers/src/xform/delayed.ts | 2 +- packages/transducers/src/xform/drop-nth.ts | 4 +- packages/transducers/src/xform/drop.ts | 2 +- packages/transducers/src/xform/duplicate.ts | 2 +- .../transducers/src/xform/filter-fuzzy.ts | 2 +- packages/transducers/src/xform/filter.ts | 2 +- .../transducers/src/xform/flatten-with.ts | 3 +- packages/transducers/src/xform/flatten.ts | 2 +- packages/transducers/src/xform/interleave.ts | 2 +- .../src/xform/interpolate-hermite.ts | 2 +- .../src/xform/interpolate-linear.ts | 2 +- packages/transducers/src/xform/interpolate.ts | 2 +- packages/transducers/src/xform/interpose.ts | 2 +- packages/transducers/src/xform/keep.ts | 2 +- packages/transducers/src/xform/labeled.ts | 3 +- packages/transducers/src/xform/map-deep.ts | 2 +- packages/transducers/src/xform/map.ts | 2 +- packages/transducers/src/xform/mapcat.ts | 2 +- packages/transducers/src/xform/match-first.ts | 2 +- packages/transducers/src/xform/match-last.ts | 2 +- .../transducers/src/xform/moving-average.ts | 4 +- packages/transducers/src/xform/multiplex.ts | 2 +- packages/transducers/src/xform/pad-last.ts | 2 +- .../transducers/src/xform/partition-by.ts | 3 +- .../transducers/src/xform/partition-of.ts | 2 +- .../transducers/src/xform/partition-sync.ts | 6 +- .../transducers/src/xform/partition-time.ts | 2 +- packages/transducers/src/xform/peek.ts | 2 +- packages/transducers/src/xform/pluck.ts | 2 +- packages/transducers/src/xform/rename.ts | 2 +- packages/transducers/src/xform/sample.ts | 3 +- packages/transducers/src/xform/select-keys.ts | 2 +- .../transducers/src/xform/sliding-window.ts | 2 +- .../transducers/src/xform/stream-shuffle.ts | 2 +- packages/transducers/src/xform/stream-sort.ts | 2 +- packages/transducers/src/xform/struct.ts | 2 +- packages/transducers/src/xform/swizzle.ts | 4 +- packages/transducers/src/xform/take-last.ts | 2 +- packages/transducers/src/xform/take-nth.ts | 4 +- packages/transducers/src/xform/take.ts | 2 +- .../transducers/src/xform/throttle-time.ts | 2 +- packages/transducers/src/xform/throttle.ts | 2 +- packages/transducers/src/xform/toggle.ts | 2 +- packages/vector-pools/src/attrib-pool.ts | 23 +- packages/vector-pools/src/vec-pool.ts | 12 +- packages/vector-pools/src/wrap.ts | 6 +- packages/vectors/src/angle-between.ts | 2 +- packages/vectors/src/bisect.ts | 2 +- packages/vectors/src/buffer.ts | 9 +- packages/vectors/src/cartesian.ts | 2 +- packages/vectors/src/clamp.ts | 2 +- packages/vectors/src/clampn.ts | 2 +- packages/vectors/src/clockwise.ts | 3 +- packages/vectors/src/copy.ts | 2 +- packages/vectors/src/degrees.ts | 2 +- packages/vectors/src/empty.ts | 2 +- packages/vectors/src/eqdelta.ts | 5 +- packages/vectors/src/fit.ts | 6 +- packages/vectors/src/fract.ts | 2 +- packages/vectors/src/gvec.ts | 7 +- packages/vectors/src/hash.ts | 3 +- packages/vectors/src/heading-segment.ts | 8 +- packages/vectors/src/heading.ts | 2 +- packages/vectors/src/internal/codegen.ts | 18 +- packages/vectors/src/internal/ensure.ts | 2 +- packages/vectors/src/internal/vop.ts | 2 +- packages/vectors/src/jitter.ts | 3 +- packages/vectors/src/major.ts | 2 +- packages/vectors/src/map-vectors.ts | 2 +- packages/vectors/src/minor.ts | 2 +- packages/vectors/src/mix-bilinear.ts | 2 +- packages/vectors/src/mod.ts | 2 +- packages/vectors/src/modn.ts | 2 +- packages/vectors/src/normalize.ts | 2 +- packages/vectors/src/normalizes.ts | 2 +- packages/vectors/src/radians.ts | 2 +- packages/vectors/src/random.ts | 3 +- packages/vectors/src/randoms.ts | 3 +- packages/vectors/src/remainder.ts | 2 +- packages/vectors/src/remaindern.ts | 2 +- packages/vectors/src/round.ts | 2 +- packages/vectors/src/safe-div.ts | 2 +- packages/vectors/src/smoothstep.ts | 2 +- packages/vectors/src/step.ts | 2 +- packages/vectors/src/string.ts | 5 +- packages/vectors/src/sum.ts | 3 +- packages/vectors/src/vec2.ts | 2 +- packages/vectors/src/vec3.ts | 2 +- packages/vectors/src/vec4.ts | 2 +- packages/vectors/src/wrap.ts | 2 +- packages/viz/src/axis/common.ts | 2 +- packages/viz/src/axis/lens.ts | 5 +- packages/viz/src/axis/linear.ts | 31 ++- packages/viz/src/axis/log.ts | 67 ++--- packages/viz/src/domain.ts | 12 +- packages/viz/src/plot.ts | 25 +- packages/viz/src/plot/area.ts | 35 ++- packages/viz/src/plot/bar.ts | 63 +++-- packages/viz/src/plot/candle.ts | 60 ++--- packages/viz/src/plot/stacked-intervals.ts | 98 ++++---- packages/viz/src/plot/utils.ts | 30 +-- packages/webgl-msdf/src/shader.ts | 5 +- packages/webgl-msdf/src/text.ts | 14 +- packages/webgl-shadertoy/src/shadertoy.ts | 16 +- packages/webgl/src/api/logger.ts | 3 +- packages/webgl/src/buffer.ts | 2 +- packages/webgl/src/canvas.ts | 2 +- packages/webgl/src/draw.ts | 2 +- packages/webgl/src/fbo.ts | 2 +- packages/webgl/src/matrices.ts | 34 +-- packages/webgl/src/multipass.ts | 9 +- packages/webgl/src/shader.ts | 23 +- packages/webgl/src/shaders/lambert.ts | 6 +- packages/webgl/src/shaders/phong.ts | 3 +- packages/webgl/src/syntax.ts | 4 +- packages/webgl/src/texture.ts | 4 +- packages/webgl/src/textures/checkerboard.ts | 3 +- packages/webgl/src/textures/stripes.ts | 3 +- packages/webgl/src/uniforms.ts | 98 ++++---- packages/zipper/src/zipper.ts | 7 +- 503 files changed, 2510 insertions(+), 2310 deletions(-) create mode 100644 packages/rdom/src/checks.ts delete mode 100644 packages/rdom/src/utils.ts create mode 100644 packages/rstream/src/checks.ts diff --git a/packages/gp/src/ast.ts b/packages/gp/src/ast.ts index cf43553116..49d268023d 100644 --- a/packages/gp/src/ast.ts +++ b/packages/gp/src/ast.ts @@ -1,7 +1,11 @@ -import { assert } from "@thi.ng/api"; -import { SYSTEM } from "@thi.ng/random"; -import { iterate, iterator, repeatedly, takeWhile } from "@thi.ng/transducers"; -import { Location, zipper } from "@thi.ng/zipper"; +import { assert } from "@thi.ng/api/assert"; +import { SYSTEM } from "@thi.ng/random/system"; +import { iterate } from "@thi.ng/transducers/iter/iterate"; +import { repeatedly } from "@thi.ng/transducers/iter/repeatedly"; +import { iterator } from "@thi.ng/transducers/iterator"; +import { takeWhile } from "@thi.ng/transducers/xform/take-while"; +import type { Location } from "@thi.ng/zipper"; +import { zipper } from "@thi.ng/zipper/zipper"; import type { ASTNode, ASTOpts, OpGene } from "./api"; import { opNode, probabilities, terminalNode } from "./utils"; diff --git a/packages/gp/src/mep.ts b/packages/gp/src/mep.ts index 0dcf07a720..5cac438a9b 100644 --- a/packages/gp/src/mep.ts +++ b/packages/gp/src/mep.ts @@ -1,6 +1,6 @@ -import { inRange } from "@thi.ng/math"; -import { SYSTEM } from "@thi.ng/random"; -import { repeatedly } from "@thi.ng/transducers"; +import { inRange } from "@thi.ng/math/interval"; +import { SYSTEM } from "@thi.ng/random/system"; +import { repeatedly } from "@thi.ng/transducers/iter/repeatedly"; import type { ASTNode, MEPChromosome, MEPGene, MEPOpts } from "./api"; import { opNode, probabilities, terminalNode } from "./utils"; diff --git a/packages/gp/src/utils.ts b/packages/gp/src/utils.ts index fba40a2aba..7b1d719592 100644 --- a/packages/gp/src/utils.ts +++ b/packages/gp/src/utils.ts @@ -1,5 +1,7 @@ -import { assert } from "@thi.ng/api"; -import { add, choices, range } from "@thi.ng/transducers"; +import { assert } from "@thi.ng/api/assert"; +import { choices } from "@thi.ng/transducers/iter/choices"; +import { range } from "@thi.ng/transducers/iter/range"; +import { add } from "@thi.ng/transducers/rfn/add"; import type { GPOpts, OpGene, TerminalGene } from "./api"; export const terminalNode = (value: T): TerminalGene => ({ diff --git a/packages/grid-iterators/src/columns.ts b/packages/grid-iterators/src/columns.ts index 934aac74e8..733ab36525 100644 --- a/packages/grid-iterators/src/columns.ts +++ b/packages/grid-iterators/src/columns.ts @@ -1,4 +1,5 @@ -import { map, range2d } from "@thi.ng/transducers"; +import { range2d } from "@thi.ng/transducers/iter/range2d"; +import { map } from "@thi.ng/transducers/xform/map"; import { swapxy } from "./utils"; /** diff --git a/packages/grid-iterators/src/interleave.ts b/packages/grid-iterators/src/interleave.ts index 6ab3b124de..0172194f37 100644 --- a/packages/grid-iterators/src/interleave.ts +++ b/packages/grid-iterators/src/interleave.ts @@ -1,4 +1,5 @@ -import { map, range2d } from "@thi.ng/transducers"; +import { range2d } from "@thi.ng/transducers/iter/range2d"; +import { map } from "@thi.ng/transducers/xform/map"; import { swapxy } from "./utils"; /** diff --git a/packages/grid-iterators/src/random.ts b/packages/grid-iterators/src/random.ts index f4a86483be..c30bfdf496 100644 --- a/packages/grid-iterators/src/random.ts +++ b/packages/grid-iterators/src/random.ts @@ -1,6 +1,7 @@ -import { shuffle } from "@thi.ng/arrays"; -import { IRandom, SYSTEM } from "@thi.ng/random"; -import { range } from "@thi.ng/transducers"; +import { shuffle } from "@thi.ng/arrays/shuffle"; +import type { IRandom } from "@thi.ng/random"; +import { SYSTEM } from "@thi.ng/random/system"; +import { range } from "@thi.ng/transducers/iter/range"; import { asInt } from "./utils"; /** diff --git a/packages/grid-iterators/src/rows.ts b/packages/grid-iterators/src/rows.ts index 808bf2ff22..588ccc0fb5 100644 --- a/packages/grid-iterators/src/rows.ts +++ b/packages/grid-iterators/src/rows.ts @@ -1,4 +1,4 @@ -import { range2d } from "@thi.ng/transducers"; +import { range2d } from "@thi.ng/transducers/iter/range2d"; /** * Yields sequence of 2D grid coordinates in row-major order. Same as diff --git a/packages/grid-iterators/src/zcurve.ts b/packages/grid-iterators/src/zcurve.ts index 6471524c0c..b85aa6aa79 100644 --- a/packages/grid-iterators/src/zcurve.ts +++ b/packages/grid-iterators/src/zcurve.ts @@ -1,5 +1,5 @@ -import { ceilPow2 } from "@thi.ng/binary"; -import { demux2 } from "@thi.ng/morton"; +import { ceilPow2 } from "@thi.ng/binary/pow"; +import { demux2 } from "@thi.ng/morton/mux"; import { asInt } from "./utils"; /** diff --git a/packages/hdiff/src/diff.ts b/packages/hdiff/src/diff.ts index 11bca8d9e1..a5eaccd9b4 100644 --- a/packages/hdiff/src/diff.ts +++ b/packages/hdiff/src/diff.ts @@ -1,6 +1,6 @@ -import { diffArray } from "@thi.ng/diff"; -import { escape } from "@thi.ng/hiccup"; -import { padLeft } from "@thi.ng/strings"; +import { diffArray } from "@thi.ng/diff/array"; +import { escape } from "@thi.ng/hiccup/escape"; +import { padLeft } from "@thi.ng/strings/pad-left"; const FMT_LN = padLeft(4, " "); diff --git a/packages/hdiff/src/html.ts b/packages/hdiff/src/html.ts index 05b24731ef..365973bd0f 100644 --- a/packages/hdiff/src/html.ts +++ b/packages/hdiff/src/html.ts @@ -1,4 +1,4 @@ -import { serialize } from "@thi.ng/hiccup"; +import { serialize } from "@thi.ng/hiccup/serialize"; import { DEFAULT_THEME, Theme } from "./api"; import { compileTheme } from "./theme"; diff --git a/packages/hdiff/src/theme.ts b/packages/hdiff/src/theme.ts index a539a5d9f5..05d7519d9d 100644 --- a/packages/hdiff/src/theme.ts +++ b/packages/hdiff/src/theme.ts @@ -1,4 +1,4 @@ -import { css } from "@thi.ng/hiccup-css"; +import { css } from "@thi.ng/hiccup-css/css"; import type { BgFg, BgFgBorder, Theme } from "./api"; const block = { display: "block" }; diff --git a/packages/hdom-canvas/src/index.ts b/packages/hdom-canvas/src/index.ts index 6c7d80ff63..d9026b11fe 100644 --- a/packages/hdom-canvas/src/index.ts +++ b/packages/hdom-canvas/src/index.ts @@ -1,8 +1,11 @@ -import { assert, NO_OP } from "@thi.ng/api"; -import { isArray, isNotStringAndIterable } from "@thi.ng/checks"; -import { diffArray } from "@thi.ng/diff"; -import { equiv, HDOMImplementation, HDOMOpts, releaseTree } from "@thi.ng/hdom"; -import { draw } from "@thi.ng/hiccup-canvas"; +import { assert } from "@thi.ng/api/assert"; +import { NO_OP } from "@thi.ng/api/constants"; +import { isArray } from "@thi.ng/checks/is-array"; +import { isNotStringAndIterable } from "@thi.ng/checks/is-not-string-iterable"; +import { diffArray } from "@thi.ng/diff/array"; +import type { HDOMImplementation, HDOMOpts } from "@thi.ng/hdom"; +import { equiv, releaseTree } from "@thi.ng/hdom/diff"; +import { draw } from "@thi.ng/hiccup-canvas/draw"; const FN = "function"; const STR = "string"; diff --git a/packages/hdom-components/src/button-group.ts b/packages/hdom-components/src/button-group.ts index db49883ca5..7b1d5b83e6 100644 --- a/packages/hdom-components/src/button-group.ts +++ b/packages/hdom-components/src/button-group.ts @@ -75,15 +75,14 @@ export type ButtonGroup = ( * * @param opts - */ -export const buttonGroup = (opts: ButtonGroupOpts): ButtonGroup => ( - _, - args: ButtonGroupArgs, - ...buttons: ButtonGroupItem[] -) => [ - "div", - mergeAttribs(opts.attribs, args.attribs), - ...groupBody(opts, args.disabled, buttons), -]; +export const buttonGroup = + (opts: ButtonGroupOpts): ButtonGroup => + (_, args: ButtonGroupArgs, ...buttons: ButtonGroupItem[]) => + [ + "div", + mergeAttribs(opts.attribs, args.attribs), + ...groupBody(opts, args.disabled, buttons), + ]; const groupBody = ( opts: ButtonGroupOpts, diff --git a/packages/hdom-components/src/fps-counter.ts b/packages/hdom-components/src/fps-counter.ts index bb7f2179fa..14d092d571 100644 --- a/packages/hdom-components/src/fps-counter.ts +++ b/packages/hdom-components/src/fps-counter.ts @@ -1,5 +1,5 @@ -import { step } from "@thi.ng/transducers"; -import { sma } from "@thi.ng/transducers-stats"; +import { step } from "@thi.ng/transducers/step"; +import { sma } from "@thi.ng/transducers-stats/sma"; import { sparkline, SparklineOpts } from "./sparkline"; export interface FpsCounterOpts { diff --git a/packages/hdom-components/src/link.ts b/packages/hdom-components/src/link.ts index 1f1158b34e..2e21cb9849 100644 --- a/packages/hdom-components/src/link.ts +++ b/packages/hdom-components/src/link.ts @@ -1,4 +1,4 @@ -import { isString } from "@thi.ng/checks"; +import { isString } from "@thi.ng/checks/is-string"; export const link = (attribs: any, body: any) => [ "a", diff --git a/packages/hdom-components/src/pager.ts b/packages/hdom-components/src/pager.ts index 119a35c3fd..340399f84e 100644 --- a/packages/hdom-components/src/pager.ts +++ b/packages/hdom-components/src/pager.ts @@ -1,4 +1,5 @@ -import { map, range } from "@thi.ng/transducers"; +import { range } from "@thi.ng/transducers/iter/range"; +import { map } from "@thi.ng/transducers/xform/map"; /** * Configuration options for pager components. diff --git a/packages/hdom-components/src/sparkline.ts b/packages/hdom-components/src/sparkline.ts index 921bab6ca7..d2a8ff6b49 100644 --- a/packages/hdom-components/src/sparkline.ts +++ b/packages/hdom-components/src/sparkline.ts @@ -1,5 +1,6 @@ -import { fitClamped } from "@thi.ng/math"; -import { mapIndexed, str } from "@thi.ng/transducers"; +import { fitClamped } from "@thi.ng/math/fit"; +import { str } from "@thi.ng/transducers/rfn/str"; +import { mapIndexed } from "@thi.ng/transducers/xform/map-indexed"; export interface SparklineOpts { /** diff --git a/packages/hdom-mock/src/index.ts b/packages/hdom-mock/src/index.ts index b56f0e0677..0f6f099c87 100644 --- a/packages/hdom-mock/src/index.ts +++ b/packages/hdom-mock/src/index.ts @@ -1,13 +1,9 @@ -import { isFunction } from "@thi.ng/checks"; -import { - createTree, - diffTree, - HDOMImplementation, - HDOMOpts, - hydrateTree, - normalizeTree, -} from "@thi.ng/hdom"; import type { IObjectOf } from "@thi.ng/api"; +import { isFunction } from "@thi.ng/checks/is-function"; +import type { HDOMImplementation, HDOMOpts } from "@thi.ng/hdom"; +import { diffTree } from "@thi.ng/hdom/diff"; +import { createTree, hydrateTree } from "@thi.ng/hdom/dom"; +import { normalizeTree } from "@thi.ng/hdom/normalize"; export const TEXT = Symbol(); diff --git a/packages/hdom/src/diff.ts b/packages/hdom/src/diff.ts index 7ad8372d25..a1515bef51 100644 --- a/packages/hdom/src/diff.ts +++ b/packages/hdom/src/diff.ts @@ -1,5 +1,7 @@ -import { IObjectOf, SEMAPHORE } from "@thi.ng/api"; -import { diffArray, diffObject } from "@thi.ng/diff"; +import type { IObjectOf } from "@thi.ng/api"; +import { SEMAPHORE } from "@thi.ng/api/constants"; +import { diffArray } from "@thi.ng/diff/array"; +import { diffObject } from "@thi.ng/diff/object"; import { equiv as _equiv, equivArrayLike, diff --git a/packages/hdom/src/dom.ts b/packages/hdom/src/dom.ts index fa89820c72..bdafdccdf6 100644 --- a/packages/hdom/src/dom.ts +++ b/packages/hdom/src/dom.ts @@ -1,10 +1,10 @@ -import { - isArray as isa, - isNotStringAndIterable as isi, - isString as iss, -} from "@thi.ng/checks"; -import { css, formatPrefixes, SVG_TAGS } from "@thi.ng/hiccup"; -import { XML_SVG } from "@thi.ng/prefixes"; +import { isArray as isa } from "@thi.ng/checks/is-array"; +import { isNotStringAndIterable as isi } from "@thi.ng/checks/is-not-string-iterable"; +import { isString as iss } from "@thi.ng/checks/is-string"; +import { SVG_TAGS } from "@thi.ng/hiccup/api"; +import { css } from "@thi.ng/hiccup/css"; +import { formatPrefixes } from "@thi.ng/hiccup/prefix"; +import { XML_SVG } from "@thi.ng/prefixes/xml"; import type { HDOMImplementation, HDOMOpts } from "./api"; const isArray = isa; diff --git a/packages/hdom/src/logger.ts b/packages/hdom/src/logger.ts index c67c890f11..a0c4c5369e 100644 --- a/packages/hdom/src/logger.ts +++ b/packages/hdom/src/logger.ts @@ -1,4 +1,5 @@ -import { ILogger, NULL_LOGGER } from "@thi.ng/api"; +import type { ILogger } from "@thi.ng/api"; +import { NULL_LOGGER } from "@thi.ng/api/logger"; export let LOGGER = NULL_LOGGER; diff --git a/packages/hdom/src/normalize.ts b/packages/hdom/src/normalize.ts index eff3c30dba..0130d2ac6f 100644 --- a/packages/hdom/src/normalize.ts +++ b/packages/hdom/src/normalize.ts @@ -1,10 +1,9 @@ -import { - isArray as isa, - isNotStringAndIterable as isi, - isPlainObject as iso, -} from "@thi.ng/checks"; -import { illegalArgs } from "@thi.ng/errors"; -import { mergeEmmetAttribs, NO_SPANS, RE_TAG } from "@thi.ng/hiccup"; +import { isArray as isa } from "@thi.ng/checks/is-array"; +import { isNotStringAndIterable as isi } from "@thi.ng/checks/is-not-string-iterable"; +import { isPlainObject as iso } from "@thi.ng/checks/is-plain-object"; +import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; +import { NO_SPANS, RE_TAG } from "@thi.ng/hiccup/api"; +import { mergeEmmetAttribs } from "@thi.ng/hiccup/attribs"; import type { HDOMOpts } from "./api"; const isArray = isa; diff --git a/packages/hdom/src/render-once.ts b/packages/hdom/src/render-once.ts index e9a7ad1fb3..d4e05ef9cd 100644 --- a/packages/hdom/src/render-once.ts +++ b/packages/hdom/src/render-once.ts @@ -1,4 +1,4 @@ -import { derefContext } from "@thi.ng/hiccup"; +import { derefContext } from "@thi.ng/hiccup/deref"; import type { HDOMImplementation, HDOMOpts } from "./api"; import { DEFAULT_IMPL } from "./default"; import { resolveRoot } from "./utils"; diff --git a/packages/hdom/src/start.ts b/packages/hdom/src/start.ts index 9676e96d93..aed5ab5471 100644 --- a/packages/hdom/src/start.ts +++ b/packages/hdom/src/start.ts @@ -1,4 +1,4 @@ -import { derefContext } from "@thi.ng/hiccup"; +import { derefContext } from "@thi.ng/hiccup/deref"; import type { HDOMImplementation, HDOMOpts } from "./api"; import { DEFAULT_IMPL } from "./default"; import { resolveRoot } from "./utils"; diff --git a/packages/hdom/src/utils.ts b/packages/hdom/src/utils.ts index 7170b1e210..09d6de6f33 100644 --- a/packages/hdom/src/utils.ts +++ b/packages/hdom/src/utils.ts @@ -1,4 +1,4 @@ -import { isString } from "@thi.ng/checks"; +import { isString } from "@thi.ng/checks/is-string"; import type { HDOMImplementation } from "./api"; export const resolveRoot = (root: any, impl: HDOMImplementation) => diff --git a/packages/heaps/src/heap.ts b/packages/heaps/src/heap.ts index 7f9b0ff6be..fd3713804c 100644 --- a/packages/heaps/src/heap.ts +++ b/packages/heaps/src/heap.ts @@ -9,7 +9,7 @@ import type { Predicate, Predicate2, } from "@thi.ng/api"; -import { compare } from "@thi.ng/compare"; +import { compare } from "@thi.ng/compare/compare"; import { equiv } from "@thi.ng/equiv"; import type { HeapOpts } from "./api"; diff --git a/packages/heaps/src/pairing.ts b/packages/heaps/src/pairing.ts index b13cddb6ed..a9cf271939 100644 --- a/packages/heaps/src/pairing.ts +++ b/packages/heaps/src/pairing.ts @@ -9,7 +9,7 @@ import type { Predicate, Predicate2, } from "@thi.ng/api"; -import { compare } from "@thi.ng/compare"; +import { compare } from "@thi.ng/compare/compare"; import { equiv } from "@thi.ng/equiv"; import type { HeapOpts } from "./api"; diff --git a/packages/heaps/src/priority-queue.ts b/packages/heaps/src/priority-queue.ts index 03b6696f68..bedee7c0db 100644 --- a/packages/heaps/src/priority-queue.ts +++ b/packages/heaps/src/priority-queue.ts @@ -8,7 +8,7 @@ import type { Predicate, Predicate2, } from "@thi.ng/api"; -import { compareNumDesc } from "@thi.ng/compare"; +import { compareNumDesc } from "@thi.ng/compare/numeric"; import { equiv } from "@thi.ng/equiv"; import type { PriorityQueueOpts } from "./api"; import { Heap } from "./heap"; diff --git a/packages/hiccup-canvas/src/arc.ts b/packages/hiccup-canvas/src/arc.ts index 8bbd94f52a..a27d8092dc 100644 --- a/packages/hiccup-canvas/src/arc.ts +++ b/packages/hiccup-canvas/src/arc.ts @@ -1,5 +1,5 @@ import type { IObjectOf } from "@thi.ng/api"; -import { TAU } from "@thi.ng/math"; +import { TAU } from "@thi.ng/math/api"; import type { ReadonlyVec } from "@thi.ng/vectors"; import { endShape } from "./end-shape"; diff --git a/packages/hiccup-canvas/src/color.ts b/packages/hiccup-canvas/src/color.ts index 26dc6b352f..bb2ef8359a 100644 --- a/packages/hiccup-canvas/src/color.ts +++ b/packages/hiccup-canvas/src/color.ts @@ -1,5 +1,5 @@ -import { isString } from "@thi.ng/checks"; -import { css } from "@thi.ng/color"; +import { isString } from "@thi.ng/checks/is-string"; +import { css } from "@thi.ng/color/css/css"; import type { DrawState } from "./api"; export const resolveColor = css; diff --git a/packages/hiccup-canvas/src/draw.ts b/packages/hiccup-canvas/src/draw.ts index e02b3593ed..5f4ac0e534 100644 --- a/packages/hiccup-canvas/src/draw.ts +++ b/packages/hiccup-canvas/src/draw.ts @@ -1,4 +1,5 @@ -import { implementsFunction, isArray } from "@thi.ng/checks"; +import { implementsFunction } from "@thi.ng/checks/implements-function"; +import { isArray } from "@thi.ng/checks/is-array"; import type { DrawState } from "./api"; import { circularArc, ellipticArc } from "./arc"; import { defLinearGradient, defRadialGradient } from "./color"; diff --git a/packages/hiccup-canvas/src/image.ts b/packages/hiccup-canvas/src/image.ts index 35de31ceb2..379c95942d 100644 --- a/packages/hiccup-canvas/src/image.ts +++ b/packages/hiccup-canvas/src/image.ts @@ -1,5 +1,5 @@ import type { IObjectOf } from "@thi.ng/api"; -import { implementsFunction } from "@thi.ng/checks"; +import { implementsFunction } from "@thi.ng/checks/implements-function"; import type { IToImageData } from "@thi.ng/pixel"; import type { ReadonlyVec } from "@thi.ng/vectors"; diff --git a/packages/hiccup-canvas/src/packed-points.ts b/packages/hiccup-canvas/src/packed-points.ts index 32cc8cf8a5..a9c2413ab6 100644 --- a/packages/hiccup-canvas/src/packed-points.ts +++ b/packages/hiccup-canvas/src/packed-points.ts @@ -1,5 +1,5 @@ import type { IObjectOf } from "@thi.ng/api"; -import { TAU } from "@thi.ng/math"; +import { TAU } from "@thi.ng/math/api"; export const packedPoints = ( ctx: CanvasRenderingContext2D, diff --git a/packages/hiccup-canvas/src/points.ts b/packages/hiccup-canvas/src/points.ts index e42a5d308b..f5b89fb427 100644 --- a/packages/hiccup-canvas/src/points.ts +++ b/packages/hiccup-canvas/src/points.ts @@ -1,5 +1,5 @@ import type { IObjectOf } from "@thi.ng/api"; -import { TAU } from "@thi.ng/math"; +import { TAU } from "@thi.ng/math/api"; import type { ReadonlyVec } from "@thi.ng/vectors"; export const points = ( diff --git a/packages/hiccup-canvas/src/state.ts b/packages/hiccup-canvas/src/state.ts index 6372ccaddc..7a666c502d 100644 --- a/packages/hiccup-canvas/src/state.ts +++ b/packages/hiccup-canvas/src/state.ts @@ -1,5 +1,5 @@ import type { IObjectOf } from "@thi.ng/api"; -import { isArrayLike } from "@thi.ng/checks"; +import { isArrayLike } from "@thi.ng/checks/is-arraylike"; import type { DrawState } from "./api"; import { resolveGradientOrColor } from "./color"; diff --git a/packages/hiccup-css/src/conditional.ts b/packages/hiccup-css/src/conditional.ts index 5eb0f1d388..223c148136 100644 --- a/packages/hiccup-css/src/conditional.ts +++ b/packages/hiccup-css/src/conditional.ts @@ -1,20 +1,18 @@ -import { isString } from "@thi.ng/checks"; +import { isString } from "@thi.ng/checks/is-string"; import { expand, indent } from "./impl"; import type { Conditional, CSSOpts, RuleFn } from "./api"; -export const conditional = ( - type: string, - cond: Conditional, - rules: any[] -): RuleFn => (acc: string[], opts: CSSOpts) => { - const space = indent(opts); - acc.push(`${space}${type} ${formatCond(cond)}${opts.format.declStart}`); - opts.depth++; - expand(acc, [], rules, opts); - opts.depth--; - acc.push(space + opts.format.declEnd); - return acc; -}; +export const conditional = + (type: string, cond: Conditional, rules: any[]): RuleFn => + (acc: string[], opts: CSSOpts) => { + const space = indent(opts); + acc.push(`${space}${type} ${formatCond(cond)}${opts.format.declStart}`); + opts.depth++; + expand(acc, [], rules, opts); + opts.depth--; + acc.push(space + opts.format.declEnd); + return acc; + }; const formatCond = (cond: any) => { if (isString(cond)) { diff --git a/packages/hiccup-css/src/css.ts b/packages/hiccup-css/src/css.ts index 6bf37379d5..12b32b90ad 100644 --- a/packages/hiccup-css/src/css.ts +++ b/packages/hiccup-css/src/css.ts @@ -1,10 +1,8 @@ -import { - isArray, - isFunction, - isNotStringAndIterable, - isPlainObject, -} from "@thi.ng/checks"; -import { illegalArgs } from "@thi.ng/errors"; +import { isArray } from "@thi.ng/checks/is-array"; +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 { illegalArgs } from "@thi.ng/errors/illegal-arguments"; 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 e003f29aca..605803675c 100644 --- a/packages/hiccup-css/src/impl.ts +++ b/packages/hiccup-css/src/impl.ts @@ -1,22 +1,18 @@ -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 type { FnAny } from "@thi.ng/api"; +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 type { Transducer } from "@thi.ng/transducers"; +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 type { CSSOpts, RuleFn } from "./api"; const EMPTY = new Set(); diff --git a/packages/hiccup-markdown/src/parse.ts b/packages/hiccup-markdown/src/parse.ts index d9f5d0aaaf..09cf20dc4c 100644 --- a/packages/hiccup-markdown/src/parse.ts +++ b/packages/hiccup-markdown/src/parse.ts @@ -1,17 +1,16 @@ -import { peek } from "@thi.ng/arrays"; -import { - alts, - fsm, - not, - repeat, - ResultBody, - seq, - str, - untilStr, - whitespace, -} from "@thi.ng/fsm"; -import { comp, filter } from "@thi.ng/transducers"; import type { Fn, Fn2 } from "@thi.ng/api"; +import { peek } from "@thi.ng/arrays/peek"; +import type { ResultBody } from "@thi.ng/fsm"; +import { alts } from "@thi.ng/fsm/alts"; +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 { untilStr } from "@thi.ng/fsm/until"; +import { comp } from "@thi.ng/transducers/func/comp"; +import { filter } from "@thi.ng/transducers/xform/filter"; import type { TagFactories } from "./api"; type ParseResult = ResultBody; @@ -97,41 +96,49 @@ const TD = "|"; // state / context handling helpers -const transition = (ctx: FSMCtx, id: State): ParseResult => ( - (ctx.children = []), (ctx.body = ""), [id] -); - -const push = (id: State, next: State) => (ctx: FSMCtx): ParseResult => ( - ctx.stack.push({ id, children: ctx.children!.concat(ctx.body) }), - transition(ctx, next) -); - -const pop = (result: Fn2) => ( - ctx: FSMCtx, - body: any -): ParseResult => { - const { id, children } = ctx.stack.pop(); - children.push(result(ctx, body)); - ctx.children = children; +const transition = (ctx: FSMCtx, id: State): ParseResult => { + ctx.children = []; ctx.body = ""; return [id]; }; +const push = + (id: State, next: State) => + (ctx: FSMCtx): ParseResult => { + ctx.stack.push({ id, children: ctx.children!.concat(ctx.body) }); + return transition(ctx, next); + }; + +const pop = + (result: Fn2) => + (ctx: FSMCtx, body: any): ParseResult => { + const { id, children } = ctx.stack.pop(); + children.push(result(ctx, body)); + ctx.children = children; + ctx.body = ""; + return [id]; + }; + const collectChildren = (ctx: FSMCtx) => ( ctx.children!.push(ctx.body), ctx.children! ); -const collect = (id: State) => (ctx: FSMCtx, buf: string[]): ParseResult => ( - (ctx.body += buf.join("")), [id] -); +const collect = + (id: State) => + (ctx: FSMCtx, buf: string[]): ParseResult => { + ctx.body += buf.join(""); + return [id]; + }; -const collectHeading = (tag: Fn2) => ( - ctx: FSMCtx -): ParseResult => [State.START, [tag(ctx.hd!, collectChildren(ctx))]]; +const collectHeading = + (tag: Fn2) => + (ctx: FSMCtx): ParseResult => + [State.START, [tag(ctx.hd!, collectChildren(ctx))]]; -const collectAndRestart = (tag: (xs: any[]) => any[]) => ( - ctx: FSMCtx -): ParseResult => [State.START, [tag(collectChildren(ctx))]]; +const collectAndRestart = + (tag: (xs: any[]) => any[]) => + (ctx: FSMCtx): ParseResult => + [State.START, [tag(collectChildren(ctx))]]; const collectBlockQuote = (ctx: FSMCtx): ParseResult => ( ctx.children!.push(ctx.body, ["br", {}]), @@ -139,27 +146,26 @@ const collectBlockQuote = (ctx: FSMCtx): ParseResult => ( [State.BLOCKQUOTE] ); -const collectCodeBlock = (tag: Fn2) => ( - ctx: FSMCtx, - body: string -): ParseResult => [State.START, [tag(ctx.lang!, body)]]; +const collectCodeBlock = + (tag: Fn2) => + (ctx: FSMCtx, body: string): ParseResult => + [State.START, [tag(ctx.lang!, body)]]; const collectLi = (ctx: FSMCtx, tag: Fn) => ctx.container!.push(tag(collectChildren(ctx))); -const collectList = ( - type: string, - list: Fn2, - item: Fn -) => (ctx: FSMCtx): ParseResult => ( - collectLi(ctx, item), [State.START, [list(type, ctx.container!)]] -); - -const collectTD = (tag: Fn2) => (ctx: FSMCtx) => ( - ctx.children!.push(ctx.body), - ctx.container!.push(tag(peek(ctx.stack).container.length, ctx.children!)), - transition(ctx, State.TABLE) -); +const collectList = + (type: string, list: Fn2, item: Fn) => + (ctx: FSMCtx): ParseResult => { + collectLi(ctx, item); + return [State.START, [list(type, ctx.container!)]]; + }; + +const collectTD = (tag: Fn2) => (ctx: FSMCtx) => { + ctx.children!.push(ctx.body); + ctx.container!.push(tag(peek(ctx.stack).container.length, ctx.children!)); + return transition(ctx, State.TABLE); +}; const collectTR = (tag: Fn2) => (ctx: FSMCtx) => { const rows = peek(ctx.stack).container; @@ -168,11 +174,13 @@ const collectTR = (tag: Fn2) => (ctx: FSMCtx) => { return transition(ctx, State.END_TABLE); }; -const collectTable = (tag: Fn) => (ctx: FSMCtx): ParseResult => { - const rows = ctx.stack.pop().container; - rows.splice(1, 1); - return [State.START, [tag(rows)]]; -}; +const collectTable = + (tag: Fn) => + (ctx: FSMCtx): ParseResult => { + const rows = ctx.stack.pop().container; + rows.splice(1, 1); + return [State.START, [tag(rows)]]; + }; const collectInline = (fn: Fn) => pop((ctx, body: string) => fn(ctx.body + body.trim())); @@ -219,9 +227,12 @@ const newPara = (ctx: FSMCtx, buf: string[]): ParseResult => ( (ctx.body = buf.join("")), (ctx.children = []), [State.PARA] ); -const newParaInline = (next: State) => (ctx: FSMCtx): ParseResult => ( - ctx.stack.push({ id: State.PARA, children: [] }), transition(ctx, next) -); +const newParaInline = + (next: State) => + (ctx: FSMCtx): ParseResult => { + ctx.stack.push({ id: State.PARA, children: [] }); + return transition(ctx, next); + }; const newParaCode = (ctx: FSMCtx, x: string[]): ParseResult => ( (ctx.body = x[1]), diff --git a/packages/hiccup-markdown/src/serialize.ts b/packages/hiccup-markdown/src/serialize.ts index 61523fe7b6..75c2aa966b 100644 --- a/packages/hiccup-markdown/src/serialize.ts +++ b/packages/hiccup-markdown/src/serialize.ts @@ -1,14 +1,17 @@ -import { - implementsFunction, - isFunction, - isNotStringAndIterable, - isString, -} from "@thi.ng/checks"; -import { DEFAULT, defmulti, MultiFn3 } from "@thi.ng/defmulti"; -import { illegalArgs } from "@thi.ng/errors"; -import { normalize } from "@thi.ng/hiccup"; -import { repeat, wrap } from "@thi.ng/strings"; -import { Border, tableCanvas, toString } from "@thi.ng/text-canvas"; +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 type { MultiFn3 } from "@thi.ng/defmulti"; +import { DEFAULT } from "@thi.ng/defmulti/constants"; +import { defmulti } from "@thi.ng/defmulti/defmulti"; +import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; +import { normalize } from "@thi.ng/hiccup/normalize"; +import { repeat } from "@thi.ng/strings/repeat"; +import { wrap } from "@thi.ng/strings/wrap"; +import { Border } from "@thi.ng/text-canvas/api"; +import { toString } from "@thi.ng/text-canvas/string"; +import { tableCanvas } from "@thi.ng/text-canvas/table"; interface SerializeState { indent: number; @@ -83,21 +86,15 @@ const serializeIter = ( return res.join(state.sep); }; -const header = (level: number) => ( - el: any[], - ctx: any, - state: SerializeState -) => repeat("#", level) + " " + body(el, ctx, state) + "\n\n"; +const header = + (level: number) => (el: any[], ctx: any, state: SerializeState) => + repeat("#", level) + " " + body(el, ctx, state) + "\n\n"; const body = (el: any[], ctx: any, state: SerializeState) => serializeIter(el[2], ctx, state); -export const serializeElement: MultiFn3< - any, - any, - SerializeState, - string -> = defmulti((el) => el[0]); +export const serializeElement: MultiFn3 = + defmulti((el) => el[0]); serializeElement.add(DEFAULT, body); serializeElement.addAll({ diff --git a/packages/hiccup-svg/src/convert.ts b/packages/hiccup-svg/src/convert.ts index 5e29777dcf..7e4775bbd9 100644 --- a/packages/hiccup-svg/src/convert.ts +++ b/packages/hiccup-svg/src/convert.ts @@ -1,4 +1,5 @@ -import { implementsFunction, isArray } from "@thi.ng/checks"; +import { implementsFunction } from "@thi.ng/checks/implements-function"; +import { isArray } from "@thi.ng/checks/is-array"; import { circle } from "./circle"; import { ellipse } from "./ellipse"; import { fattribs } from "./format"; diff --git a/packages/hiccup-svg/src/format.ts b/packages/hiccup-svg/src/format.ts index aba9aec484..6799014ce9 100644 --- a/packages/hiccup-svg/src/format.ts +++ b/packages/hiccup-svg/src/format.ts @@ -1,5 +1,6 @@ -import { isArrayLike, isString } from "@thi.ng/checks"; -import { css } from "@thi.ng/color"; +import { isArrayLike } from "@thi.ng/checks/is-arraylike"; +import { isString } from "@thi.ng/checks/is-string"; +import { css } from "@thi.ng/color/css/css"; import type { Vec2Like } from "./api"; let PRECISION = 2; diff --git a/packages/hiccup-svg/src/svg.ts b/packages/hiccup-svg/src/svg.ts index a570d8dbb5..613307f551 100644 --- a/packages/hiccup-svg/src/svg.ts +++ b/packages/hiccup-svg/src/svg.ts @@ -1,4 +1,4 @@ -import { XML_SVG, XML_XLINK } from "@thi.ng/prefixes"; +import { XML_SVG, XML_XLINK } from "@thi.ng/prefixes/xml"; import { convertTree } from "./convert"; import { fattribs, numericAttribs } from "./format"; diff --git a/packages/hiccup/src/attribs.ts b/packages/hiccup/src/attribs.ts index eb446f4242..6c5a89ee72 100644 --- a/packages/hiccup/src/attribs.ts +++ b/packages/hiccup/src/attribs.ts @@ -1,5 +1,5 @@ -import { deref } from "@thi.ng/api"; -import { isString } from "@thi.ng/checks"; +import { deref } from "@thi.ng/api/api/deref"; +import { isString } from "@thi.ng/checks/is-string"; /** * Takes a space separated string of existing CSS class names and merges diff --git a/packages/hiccup/src/css.ts b/packages/hiccup/src/css.ts index 763aca2648..fd7fffb1d3 100644 --- a/packages/hiccup/src/css.ts +++ b/packages/hiccup/src/css.ts @@ -1,5 +1,5 @@ -import { deref } from "@thi.ng/api"; -import { isFunction } from "@thi.ng/checks"; +import { deref } from "@thi.ng/api/api/deref"; +import { isFunction } from "@thi.ng/checks/is-function"; export const css = (rules: any) => { let css = ""; diff --git a/packages/hiccup/src/deref.ts b/packages/hiccup/src/deref.ts index ee0abd0a59..fb42b50578 100644 --- a/packages/hiccup/src/deref.ts +++ b/packages/hiccup/src/deref.ts @@ -1,4 +1,4 @@ -import { implementsFunction } from "@thi.ng/checks"; +import { implementsFunction } from "@thi.ng/checks/implements-function"; /** * Takes an arbitrary `ctx` object and array of `keys`. Attempts to call diff --git a/packages/hiccup/src/normalize.ts b/packages/hiccup/src/normalize.ts index a7dff95e9e..04d05bf68b 100644 --- a/packages/hiccup/src/normalize.ts +++ b/packages/hiccup/src/normalize.ts @@ -1,5 +1,6 @@ -import { isPlainObject, isString } from "@thi.ng/checks"; -import { illegalArgs } from "@thi.ng/errors"; +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 { RE_TAG } from "./api"; import { mergeEmmetAttribs } from "./attribs"; diff --git a/packages/hiccup/src/serialize.ts b/packages/hiccup/src/serialize.ts index 9d00007408..35f3dbd849 100644 --- a/packages/hiccup/src/serialize.ts +++ b/packages/hiccup/src/serialize.ts @@ -1,20 +1,18 @@ -import { deref, isDeref } from "@thi.ng/api"; -import { - implementsFunction, - isArray, - isFunction, - isNotStringAndIterable, - isPlainObject, - isString, -} from "@thi.ng/checks"; -import { illegalArgs } from "@thi.ng/errors"; +import { deref, isDeref } from "@thi.ng/api/api/deref"; +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 { 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 { ATTRIB_JOIN_DELIMS, CDATA, COMMENT, + NO_CLOSE_EMPTY, NO_SPANS, PROC_TAGS, - NO_CLOSE_EMPTY, VOID_TAGS, } from "./api"; import { css } from "./css"; diff --git a/packages/idgen/src/index.ts b/packages/idgen/src/index.ts index d19b029656..e7e32bfa59 100644 --- a/packages/idgen/src/index.ts +++ b/packages/idgen/src/index.ts @@ -1,11 +1,6 @@ -import { - assert, - Event, - IClear, - INotify, - INotifyMixin, - Listener, -} from "@thi.ng/api"; +import type { Event, IClear, INotify, Listener } from "@thi.ng/api"; +import { assert } from "@thi.ng/api/assert"; +import { INotifyMixin } from "@thi.ng/api/mixins/inotify"; export const EVENT_ADDED = "added"; export const EVENT_REMOVED = "removed"; diff --git a/packages/iges/src/index.ts b/packages/iges/src/index.ts index 5ec92cc713..d6202873f8 100644 --- a/packages/iges/src/index.ts +++ b/packages/iges/src/index.ts @@ -1,17 +1,18 @@ -import { isArray } from "@thi.ng/checks"; -import { defmulti } from "@thi.ng/defmulti"; -import { float, hstr, padLeft, padRight } from "@thi.ng/strings"; -import { - comp, - map, - mapcat, - mapIndexed, - partition, - push, - transduce, - wordWrap, - wrapSides, -} from "@thi.ng/transducers"; +import { isArray } from "@thi.ng/checks/is-array"; +import { defmulti } from "@thi.ng/defmulti/defmulti"; +import { float } from "@thi.ng/strings/float"; +import { hstr } from "@thi.ng/strings/hollerith"; +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 { wrapSides } from "@thi.ng/transducers/iter/wrap-sides"; +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 type { ReadonlyVec } from "@thi.ng/vectors"; import { BooleanNode, diff --git a/packages/imgui/src/behaviors/dial.ts b/packages/imgui/src/behaviors/dial.ts index bb17f40cc2..6b106054f1 100644 --- a/packages/imgui/src/behaviors/dial.ts +++ b/packages/imgui/src/behaviors/dial.ts @@ -1,5 +1,8 @@ -import { fit, TAU } from "@thi.ng/math"; -import { heading, ReadonlyVec, sub2 } from "@thi.ng/vectors"; +import { TAU } from "@thi.ng/math/api"; +import { fit } from "@thi.ng/math/fit"; +import type { ReadonlyVec } from "@thi.ng/vectors"; +import { heading } from "@thi.ng/vectors/heading"; +import { sub2 } from "@thi.ng/vectors/sub"; import { slider1Val } from "./slider"; export const dialVal = ( diff --git a/packages/imgui/src/behaviors/slider.ts b/packages/imgui/src/behaviors/slider.ts index 3811e8f23b..d27defecc1 100644 --- a/packages/imgui/src/behaviors/slider.ts +++ b/packages/imgui/src/behaviors/slider.ts @@ -1,8 +1,12 @@ import type { FnN4 } from "@thi.ng/api"; import { pointInside } from "@thi.ng/geom"; import type { IShape } from "@thi.ng/geom-api"; -import { clamp, roundTo } from "@thi.ng/math"; -import { add2, clamp2, roundN2, Vec } from "@thi.ng/vectors"; +import { clamp } from "@thi.ng/math/interval"; +import { roundTo } from "@thi.ng/math/prec"; +import type { Vec } from "@thi.ng/vectors"; +import { add2 } from "@thi.ng/vectors/add"; +import { clamp2 } from "@thi.ng/vectors/clamp"; +import { roundN2 } from "@thi.ng/vectors/round"; import { Key } from "../api"; import type { IMGUI } from "../gui"; diff --git a/packages/imgui/src/behaviors/text.ts b/packages/imgui/src/behaviors/text.ts index 3b47ca1237..73b80f04b8 100644 --- a/packages/imgui/src/behaviors/text.ts +++ b/packages/imgui/src/behaviors/text.ts @@ -1,5 +1,5 @@ import type { Predicate } from "@thi.ng/api"; -import { clamp0 } from "@thi.ng/math"; +import { clamp0 } from "@thi.ng/math/interval"; import { Key } from "../api"; import type { IMGUI } from "../gui"; diff --git a/packages/imgui/src/components/button.ts b/packages/imgui/src/components/button.ts index 2c8c810af7..17b8f1fbbf 100644 --- a/packages/imgui/src/components/button.ts +++ b/packages/imgui/src/components/button.ts @@ -2,7 +2,8 @@ import type { Fn5 } from "@thi.ng/api"; import { rect } from "@thi.ng/geom"; import type { IShape } from "@thi.ng/geom-api"; import type { IGridLayout, LayoutBox } from "@thi.ng/layout"; -import { hash, ZERO2 } from "@thi.ng/vectors"; +import { ZERO2 } from "@thi.ng/vectors/api"; +import { hash } from "@thi.ng/vectors/hash"; import type { GUITheme, Hash } from "../api"; import { handleButtonKeys, hoverButton } from "../behaviors/button"; import type { IMGUI } from "../gui"; diff --git a/packages/imgui/src/components/dial.ts b/packages/imgui/src/components/dial.ts index d47cc2e317..d802e6e992 100644 --- a/packages/imgui/src/components/dial.ts +++ b/packages/imgui/src/components/dial.ts @@ -1,8 +1,11 @@ import type { Fn } from "@thi.ng/api"; import { circle, line } from "@thi.ng/geom"; -import { IGridLayout, isLayout, LayoutBox } from "@thi.ng/layout"; -import { HALF_PI, norm, PI, TAU } from "@thi.ng/math"; -import { cartesian2, hash } from "@thi.ng/vectors"; +import type { IGridLayout, LayoutBox } from "@thi.ng/layout"; +import { isLayout } from "@thi.ng/layout/is-layout"; +import { HALF_PI, PI, TAU } from "@thi.ng/math/api"; +import { norm } from "@thi.ng/math/fit"; +import { cartesian2 } from "@thi.ng/vectors/cartesian"; +import { hash } from "@thi.ng/vectors/hash"; import { dialVal } from "../behaviors/dial"; import { handleSlider1Keys, isHoverSlider } from "../behaviors/slider"; import type { IMGUI } from "../gui"; diff --git a/packages/imgui/src/components/dropdown.ts b/packages/imgui/src/components/dropdown.ts index fffcaa6aeb..0ea8e7b21c 100644 --- a/packages/imgui/src/components/dropdown.ts +++ b/packages/imgui/src/components/dropdown.ts @@ -1,7 +1,9 @@ import { polygon } from "@thi.ng/geom"; -import { gridLayout, IGridLayout, isLayout, LayoutBox } from "@thi.ng/layout"; -import { clamp0 } from "@thi.ng/math"; -import { hash } from "@thi.ng/vectors"; +import type { IGridLayout, LayoutBox } from "@thi.ng/layout"; +import { gridLayout } from "@thi.ng/layout/grid-layout"; +import { isLayout } from "@thi.ng/layout/is-layout"; +import { clamp0 } from "@thi.ng/math/interval"; +import { hash } from "@thi.ng/vectors/hash"; import { Key } from "../api"; import type { IMGUI } from "../gui"; import { buttonH } from "./button"; diff --git a/packages/imgui/src/components/icon-button.ts b/packages/imgui/src/components/icon-button.ts index b3d774cfdf..9b89466062 100644 --- a/packages/imgui/src/components/icon-button.ts +++ b/packages/imgui/src/components/icon-button.ts @@ -1,6 +1,7 @@ import { rect } from "@thi.ng/geom"; -import { IGridLayout, isLayout, LayoutBox } from "@thi.ng/layout"; -import { hash } from "@thi.ng/vectors"; +import type { IGridLayout, LayoutBox } from "@thi.ng/layout"; +import { isLayout } from "@thi.ng/layout/is-layout"; +import { hash } from "@thi.ng/vectors/hash"; import type { IMGUI } from "../gui"; import { mixHash } from "../hash"; import { buttonRaw } from "./button"; diff --git a/packages/imgui/src/components/radial-menu.ts b/packages/imgui/src/components/radial-menu.ts index a03b5995b1..a8bb0645c4 100644 --- a/packages/imgui/src/components/radial-menu.ts +++ b/packages/imgui/src/components/radial-menu.ts @@ -1,8 +1,9 @@ import { centroid, circle, polygon, Polygon, vertices } from "@thi.ng/geom"; -import { triFan } from "@thi.ng/geom-tessellate"; -import { mod } from "@thi.ng/math"; -import { mapIndexed } from "@thi.ng/transducers"; -import { add2, hash } from "@thi.ng/vectors"; +import { triFan } from "@thi.ng/geom-tessellate/tri-fan"; +import { mod } from "@thi.ng/math/prec"; +import { mapIndexed } from "@thi.ng/transducers/xform/map-indexed"; +import { add2 } from "@thi.ng/vectors/add"; +import { hash } from "@thi.ng/vectors/hash"; import { Hash, Key } from "../api"; import type { IMGUI } from "../gui"; import { buttonRaw } from "./button"; diff --git a/packages/imgui/src/components/radio.ts b/packages/imgui/src/components/radio.ts index 125654218e..62a07f08cb 100644 --- a/packages/imgui/src/components/radio.ts +++ b/packages/imgui/src/components/radio.ts @@ -1,4 +1,6 @@ -import { gridLayout, IGridLayout, isLayout, LayoutBox } from "@thi.ng/layout"; +import type { IGridLayout, LayoutBox } from "@thi.ng/layout"; +import { gridLayout } from "@thi.ng/layout/grid-layout"; +import { isLayout } from "@thi.ng/layout/is-layout"; import type { IMGUI } from "../gui"; import { toggle } from "./toggle"; diff --git a/packages/imgui/src/components/ring.ts b/packages/imgui/src/components/ring.ts index b62b7781b3..9debaed2c7 100644 --- a/packages/imgui/src/components/ring.ts +++ b/packages/imgui/src/components/ring.ts @@ -1,10 +1,16 @@ import type { Fn, FnN2 } from "@thi.ng/api"; import { polygon } from "@thi.ng/geom"; -import { pointInRect } from "@thi.ng/geom-isec"; -import { IGridLayout, isLayout, LayoutBox } from "@thi.ng/layout"; -import { fitClamped, HALF_PI, mix, norm, PI, TAU } from "@thi.ng/math"; -import { map, normRange } from "@thi.ng/transducers"; -import { cartesian2, hash, Vec } from "@thi.ng/vectors"; +import { pointInRect } from "@thi.ng/geom-isec/point"; +import type { IGridLayout, LayoutBox } from "@thi.ng/layout"; +import { isLayout } from "@thi.ng/layout/is-layout"; +import { HALF_PI, PI, TAU } from "@thi.ng/math/api"; +import { fitClamped, norm } from "@thi.ng/math/fit"; +import { mix } from "@thi.ng/math/mix"; +import { normRange } from "@thi.ng/transducers/iter/norm-range"; +import { map } from "@thi.ng/transducers/xform/map"; +import type { Vec } from "@thi.ng/vectors"; +import { cartesian2 } from "@thi.ng/vectors/cartesian"; +import { hash } from "@thi.ng/vectors/hash"; import { dialVal } from "../behaviors/dial"; import { handleSlider1Keys } from "../behaviors/slider"; import type { IMGUI } from "../gui"; diff --git a/packages/imgui/src/components/sliderh.ts b/packages/imgui/src/components/sliderh.ts index e77d3bf27b..d56f6be1b7 100644 --- a/packages/imgui/src/components/sliderh.ts +++ b/packages/imgui/src/components/sliderh.ts @@ -1,8 +1,8 @@ import type { Fn } from "@thi.ng/api"; import { rect } from "@thi.ng/geom"; import type { IGridLayout, LayoutBox } from "@thi.ng/layout"; -import { fit, norm } from "@thi.ng/math"; -import { hash } from "@thi.ng/vectors"; +import { fit, norm } from "@thi.ng/math/fit"; +import { hash } from "@thi.ng/vectors/hash"; import { handleSlider1Keys, isHoverSlider, diff --git a/packages/imgui/src/components/sliderv.ts b/packages/imgui/src/components/sliderv.ts index a624a77027..04459fe659 100644 --- a/packages/imgui/src/components/sliderv.ts +++ b/packages/imgui/src/components/sliderv.ts @@ -1,8 +1,9 @@ import type { Fn } from "@thi.ng/api"; import { rect } from "@thi.ng/geom"; import type { IGridLayout, LayoutBox } from "@thi.ng/layout"; -import { fit, norm } from "@thi.ng/math"; -import { hash, ZERO2 } from "@thi.ng/vectors"; +import { fit, norm } from "@thi.ng/math/fit"; +import { ZERO2 } from "@thi.ng/vectors/api"; +import { hash } from "@thi.ng/vectors/hash"; import { handleSlider1Keys, isHoverSlider, diff --git a/packages/imgui/src/components/textfield.ts b/packages/imgui/src/components/textfield.ts index c2fbfa8d10..8082c771ea 100644 --- a/packages/imgui/src/components/textfield.ts +++ b/packages/imgui/src/components/textfield.ts @@ -1,8 +1,8 @@ import type { Predicate } from "@thi.ng/api"; import { rect } from "@thi.ng/geom"; import type { IGridLayout, LayoutBox } from "@thi.ng/layout"; -import { fitClamped } from "@thi.ng/math"; -import { hash } from "@thi.ng/vectors"; +import { fitClamped } from "@thi.ng/math/fit"; +import { hash } from "@thi.ng/vectors/hash"; import { isHoverSlider } from "../behaviors/slider"; import { handleTextfieldKeys } from "../behaviors/text"; import type { IMGUI } from "../gui"; diff --git a/packages/imgui/src/components/textlabel.ts b/packages/imgui/src/components/textlabel.ts index 310a8a4a13..174bc3712c 100644 --- a/packages/imgui/src/components/textlabel.ts +++ b/packages/imgui/src/components/textlabel.ts @@ -1,5 +1,5 @@ import type { Fn } from "@thi.ng/api"; -import { isPlainObject } from "@thi.ng/checks"; +import { isPlainObject } from "@thi.ng/checks/is-plain-object"; import type { IGridLayout, LayoutBox } from "@thi.ng/layout"; import type { ReadonlyVec } from "@thi.ng/vectors"; import type { Color, GUITheme } from "../api"; diff --git a/packages/imgui/src/components/toggle.ts b/packages/imgui/src/components/toggle.ts index 78dcac2647..8db05c829e 100644 --- a/packages/imgui/src/components/toggle.ts +++ b/packages/imgui/src/components/toggle.ts @@ -1,6 +1,6 @@ import { rect } from "@thi.ng/geom"; import type { IGridLayout, LayoutBox } from "@thi.ng/layout"; -import { hash } from "@thi.ng/vectors"; +import { hash } from "@thi.ng/vectors/hash"; import { handleButtonKeys, hoverButton } from "../behaviors/button"; import type { IMGUI } from "../gui"; import { layoutBox } from "../layout"; diff --git a/packages/imgui/src/components/tooltip.ts b/packages/imgui/src/components/tooltip.ts index 8b62499cf6..6777eca1af 100644 --- a/packages/imgui/src/components/tooltip.ts +++ b/packages/imgui/src/components/tooltip.ts @@ -1,5 +1,5 @@ import { rect } from "@thi.ng/geom"; -import { add2 } from "@thi.ng/vectors"; +import { add2 } from "@thi.ng/vectors/add"; import type { IMGUI } from "../gui"; import { textLabelRaw } from "./textlabel"; diff --git a/packages/imgui/src/components/xypad.ts b/packages/imgui/src/components/xypad.ts index c3eb727752..d67f4ffc25 100644 --- a/packages/imgui/src/components/xypad.ts +++ b/packages/imgui/src/components/xypad.ts @@ -1,7 +1,9 @@ import type { Fn } from "@thi.ng/api"; import { line, rect } from "@thi.ng/geom"; import type { IGridLayout, LayoutBox } from "@thi.ng/layout"; -import { fit2, hash, Vec } from "@thi.ng/vectors"; +import type { Vec } from "@thi.ng/vectors"; +import { fit2 } from "@thi.ng/vectors/fit"; +import { hash } from "@thi.ng/vectors/hash"; import { handleSlider2Keys, isHoverSlider, diff --git a/packages/imgui/src/gui.ts b/packages/imgui/src/gui.ts index 51190668f4..1b5e651377 100644 --- a/packages/imgui/src/gui.ts +++ b/packages/imgui/src/gui.ts @@ -1,5 +1,6 @@ import type { Fn0, IClear, IToHiccup } from "@thi.ng/api"; -import { set2, Vec } from "@thi.ng/vectors"; +import type { Vec } from "@thi.ng/vectors"; +import { set2 } from "@thi.ng/vectors/set"; import { DEFAULT_THEME, GUITheme, @@ -48,7 +49,11 @@ export class IMGUI implements IClear, IToHiccup { this.mouse = [-1e3, -1e3]; this.prevMouse = [-1e3, -1e3]; this.key = this.prevKey = ""; - this.buttons = this.prevButtons = this.modifiers = this.prevModifiers = 0; + this.buttons = + this.prevButtons = + this.modifiers = + this.prevModifiers = + 0; this.hotID = this.activeID = this.focusID = this.lastID = ""; this.currIDs = new Set(); this.prevIDs = new Set(); diff --git a/packages/imgui/src/hash.ts b/packages/imgui/src/hash.ts index de8a58da80..f3a9713011 100644 --- a/packages/imgui/src/hash.ts +++ b/packages/imgui/src/hash.ts @@ -1,4 +1,4 @@ -import { hash } from "@thi.ng/vectors"; +import { hash } from "@thi.ng/vectors/hash"; const BUF = new Array(1024); diff --git a/packages/imgui/src/layout.ts b/packages/imgui/src/layout.ts index 54d302b033..6ed573eeb0 100644 --- a/packages/imgui/src/layout.ts +++ b/packages/imgui/src/layout.ts @@ -1,4 +1,5 @@ -import { IGridLayout, isLayout, LayoutBox } from "@thi.ng/layout"; +import type { IGridLayout, LayoutBox } from "@thi.ng/layout"; +import { isLayout } from "@thi.ng/layout/is-layout"; export const layoutBox = ( layout: IGridLayout | LayoutBox, diff --git a/packages/interceptors/src/api.ts b/packages/interceptors/src/api.ts index d3b863ea31..6471df0952 100644 --- a/packages/interceptors/src/api.ts +++ b/packages/interceptors/src/api.ts @@ -1,4 +1,5 @@ -import { ILogger, NULL_LOGGER } from "@thi.ng/api"; +import type { ILogger } from "@thi.ng/api"; +import { NULL_LOGGER } from "@thi.ng/api/logger"; import type { ReadonlyAtom } from "@thi.ng/atom"; export type InterceptorFn = ( diff --git a/packages/interceptors/src/event-bus.ts b/packages/interceptors/src/event-bus.ts index a0b9233776..21c04c02c0 100644 --- a/packages/interceptors/src/event-bus.ts +++ b/packages/interceptors/src/event-bus.ts @@ -1,13 +1,13 @@ import type { 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 { setInUnsafe, updateInUnsafe } from "@thi.ng/paths"; +import type { IAtom } from "@thi.ng/atom"; +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 { setInUnsafe } from "@thi.ng/paths/set-in"; +import { updateInUnsafe } from "@thi.ng/paths/update-in"; import { EffectDef, EffectPriority, @@ -601,7 +601,8 @@ export class StatelessEventBus implements IDispatch { */ export class EventBus extends StatelessEventBus - implements IDeref, IDispatch { + implements IDeref, IDispatch +{ readonly state: IAtom; /** @@ -774,24 +775,21 @@ export class EventBus const asInterceptor = (i: Interceptor | InterceptorFn) => isFunction(i) ? { pre: i } : i; -const undoHandler = (action: string): InterceptorFn => ( - _, - [__, ev], - bus, - ctx -) => { - const id = ev ? ev[0] : "history"; - if (implementsFunction(ctx[id], action)) { - const ok = ctx[id][action](); - return { - [FX_STATE]: bus.state.deref(), - [FX_DISPATCH_NOW]: ev - ? ok !== undefined - ? ev[1] - : ev[2] - : undefined, - }; - } else { - LOGGER.warn("no history in context"); - } -}; +const undoHandler = + (action: string): InterceptorFn => + (_, [__, ev], bus, ctx) => { + const id = ev ? ev[0] : "history"; + if (implementsFunction(ctx[id], action)) { + const ok = ctx[id][action](); + return { + [FX_STATE]: bus.state.deref(), + [FX_DISPATCH_NOW]: ev + ? ok !== undefined + ? ev[1] + : ev[2] + : undefined, + }; + } else { + LOGGER.warn("no history in context"); + } + }; diff --git a/packages/interceptors/src/interceptors.ts b/packages/interceptors/src/interceptors.ts index c8a5a1377a..bb2ca08204 100644 --- a/packages/interceptors/src/interceptors.ts +++ b/packages/interceptors/src/interceptors.ts @@ -1,5 +1,7 @@ import type { Fn, FnO, Path } from "@thi.ng/api"; -import { defSetterUnsafe, defUpdaterUnsafe, getInUnsafe } from "@thi.ng/paths"; +import { getInUnsafe } from "@thi.ng/paths/get-in"; +import { defSetterUnsafe } from "@thi.ng/paths/setter"; +import { defUpdaterUnsafe } from "@thi.ng/paths/updater"; import { Event, FX_CANCEL, @@ -22,10 +24,9 @@ export const trace: InterceptorFn = (_, e) => console.log("event:", e); * * @param fxID - side effect ID */ -export const forwardSideFx = (fxID: string): InterceptorFn => ( - _, - [__, body] -) => ({ [fxID]: body !== undefined ? body : true }); +export const forwardSideFx = + (fxID: string): InterceptorFn => + (_, [__, body]) => ({ [fxID]: body !== undefined ? body : true }); /** * Higher-order interceptor. Returns interceptor which assigns given @@ -33,9 +34,11 @@ export const forwardSideFx = (fxID: string): InterceptorFn => ( * * @param event - */ -export const dispatch = (event: Event): InterceptorFn => () => ({ - [FX_DISPATCH]: event, -}); +export const dispatch = + (event: Event): InterceptorFn => + () => ({ + [FX_DISPATCH]: event, + }); /** * Higher-order interceptor. Returns interceptor which assigns given @@ -43,9 +46,11 @@ export const dispatch = (event: Event): InterceptorFn => () => ({ * * @param event - */ -export const dispatchNow = (event: Event): InterceptorFn => () => ({ - [FX_DISPATCH_NOW]: event, -}); +export const dispatchNow = + (event: Event): InterceptorFn => + () => ({ + [FX_DISPATCH_NOW]: event, + }); /** * Higher-order interceptor. Returns interceptor which calls @@ -78,8 +83,10 @@ export const dispatchNow = (event: Event): InterceptorFn => () => ({ * * @param id - */ -export const snapshot = (id = "history"): InterceptorFn => (_, __, ___, ctx) => - ctx[id].record(); +export const snapshot = + (id = "history"): InterceptorFn => + (_, __, ___, ctx) => + ctx[id].record(); /** * Higher-order interceptor for validation purposes. Takes a predicate @@ -120,16 +127,15 @@ export const snapshot = (id = "history"): InterceptorFn => (_, __, ___, ctx) => * @param pred - predicate applied to given state & event * @param err - interceptor triggered on predicate failure */ -export const ensurePred = ( - pred: InterceptorPredicate, - err?: InterceptorFn -): InterceptorFn => (state, e, bus, ctx) => - !pred(state, e, bus, ctx) - ? { - [FX_CANCEL]: true, - ...(err ? err(state, e, bus, ctx) : null), - } - : undefined; +export const ensurePred = + (pred: InterceptorPredicate, err?: InterceptorFn): InterceptorFn => + (state, e, bus, ctx) => + !pred(state, e, bus, ctx) + ? { + [FX_CANCEL]: true, + ...(err ? err(state, e, bus, ctx) : null), + } + : undefined; const eventPathState = ( state: any, diff --git a/packages/intervals/src/index.ts b/packages/intervals/src/index.ts index 50cb1cf938..bd16b3bfc0 100644 --- a/packages/intervals/src/index.ts +++ b/packages/intervals/src/index.ts @@ -1,15 +1,8 @@ -import { - DEFAULT_EPS, - Fn, - Fn2, - ICompare, - IContains, - ICopy, - IEquiv, -} from "@thi.ng/api"; -import { isString } from "@thi.ng/checks"; +import type { Fn, Fn2, ICompare, IContains, ICopy, IEquiv } from "@thi.ng/api"; +import { DEFAULT_EPS } from "@thi.ng/api/constants"; +import { isString } from "@thi.ng/checks/is-string"; import { and, or } from "@thi.ng/dlogic"; -import { illegalArgs } from "@thi.ng/errors"; +import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; export enum Classifier { DISJOINT_LEFT, @@ -22,7 +15,8 @@ export enum Classifier { } export class Interval - implements ICompare, IContains, ICopy, IEquiv { + implements ICompare, IContains, ICopy, IEquiv +{ l: number; r: number; diff --git a/packages/iterators/src/ensure.ts b/packages/iterators/src/ensure.ts index a496f1c970..1aa77a34c6 100644 --- a/packages/iterators/src/ensure.ts +++ b/packages/iterators/src/ensure.ts @@ -1,4 +1,4 @@ -import { illegalArgs } from "@thi.ng/errors"; +import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; import { iterator } from "./iterator"; export const ensureIterable = (x: any): IterableIterator => diff --git a/packages/iterators/src/fnil.ts b/packages/iterators/src/fnil.ts index a025539daf..b3076965f7 100644 --- a/packages/iterators/src/fnil.ts +++ b/packages/iterators/src/fnil.ts @@ -1,5 +1,5 @@ import type { Fn0, FnAny } from "@thi.ng/api"; -import { illegalArity } from "@thi.ng/errors"; +import { illegalArity } from "@thi.ng/errors/illegal-arity"; export const fnil = (fn: FnAny, ...ctors: Fn0[]) => { let [cta, ctb, ctc] = ctors; diff --git a/packages/iterators/src/fork.ts b/packages/iterators/src/fork.ts index 256e6805f9..4e519b58dd 100644 --- a/packages/iterators/src/fork.ts +++ b/packages/iterators/src/fork.ts @@ -1,4 +1,4 @@ -import { DCons } from "@thi.ng/dcons"; +import { DCons } from "@thi.ng/dcons/dcons"; import { iterator } from "./iterator"; export const fork = (src: Iterable, cacheLimit = 16) => { diff --git a/packages/iterators/src/interleave.ts b/packages/iterators/src/interleave.ts index 890c10a828..9e33313289 100644 --- a/packages/iterators/src/interleave.ts +++ b/packages/iterators/src/interleave.ts @@ -1,4 +1,4 @@ -import { illegalArity } from "@thi.ng/errors"; +import { illegalArity } from "@thi.ng/errors/illegal-arity"; import { cycle } from "./cycle"; import { iterator } from "./iterator"; import { map } from "./map"; diff --git a/packages/iterators/src/juxt.ts b/packages/iterators/src/juxt.ts index ce19f200c4..d4a83c0e44 100644 --- a/packages/iterators/src/juxt.ts +++ b/packages/iterators/src/juxt.ts @@ -5,10 +5,12 @@ import type { Fn } from "@thi.ng/api"; * * @param fns - */ -export const juxt = (...fns: Fn[]) => (x: T) => { - let res = []; - for (let i = 0; i < fns.length; i++) { - res[i] = fns[i](x); - } - return res; -}; +export const juxt = + (...fns: Fn[]) => + (x: T) => { + let res = []; + for (let i = 0; i < fns.length; i++) { + res[i] = fns[i](x); + } + return res; + }; diff --git a/packages/iterators/src/partition.ts b/packages/iterators/src/partition.ts index e8ec8e3653..c773854388 100644 --- a/packages/iterators/src/partition.ts +++ b/packages/iterators/src/partition.ts @@ -1,4 +1,4 @@ -import { illegalArgs } from "@thi.ng/errors"; +import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; import { consume } from "./consume"; import { iterator } from "./iterator"; diff --git a/packages/k-means/src/kmeans.ts b/packages/k-means/src/kmeans.ts index 7b6c09fb62..840bb04bac 100644 --- a/packages/k-means/src/kmeans.ts +++ b/packages/k-means/src/kmeans.ts @@ -1,7 +1,15 @@ -import { assert } from "@thi.ng/api"; -import { argmin, DIST_SQ, IDistance } from "@thi.ng/distance"; -import { SYSTEM, uniqueIndices, weightedRandom } from "@thi.ng/random"; -import { add, median, mulN, ReadonlyVec, Vec, zeroes } from "@thi.ng/vectors"; +import { assert } from "@thi.ng/api/assert"; +import type { IDistance } from "@thi.ng/distance"; +import { argmin } from "@thi.ng/distance/argmin"; +import { DIST_SQ } from "@thi.ng/distance/squared"; +import { SYSTEM } from "@thi.ng/random/system"; +import { uniqueIndices } from "@thi.ng/random/unique-indices"; +import { weightedRandom } from "@thi.ng/random/weighted-random"; +import type { ReadonlyVec, Vec } from "@thi.ng/vectors"; +import { add } from "@thi.ng/vectors/add"; +import { median } from "@thi.ng/vectors/median"; +import { mulN } from "@thi.ng/vectors/muln"; +import { zeroes } from "@thi.ng/vectors/setn"; import type { CentroidStrategy, Cluster, KMeansOpts } from "./api"; /** diff --git a/packages/ksuid/src/aksuid.ts b/packages/ksuid/src/aksuid.ts index 9a72a64d19..beccd6a487 100644 --- a/packages/ksuid/src/aksuid.ts +++ b/packages/ksuid/src/aksuid.ts @@ -1,7 +1,9 @@ -import { assert } from "@thi.ng/api"; -import { BASE62, BaseN } from "@thi.ng/base-n"; -import { IRandom, randomBytes, randomBytesFrom } from "@thi.ng/random"; -import { padLeft } from "@thi.ng/strings"; +import { assert } from "@thi.ng/api/assert"; +import { BASE62 } from "@thi.ng/base-n/62"; +import type { BaseN } from "@thi.ng/base-n"; +import type { IRandom } from "@thi.ng/random"; +import { randomBytes, randomBytesFrom } from "@thi.ng/random/random-bytes"; +import { padLeft } from "@thi.ng/strings/pad-left"; import type { IKSUID, KSUIDOpts } from "./api"; /** diff --git a/packages/ksuid/src/ulid.ts b/packages/ksuid/src/ulid.ts index 01af524f22..6b9dd737f1 100644 --- a/packages/ksuid/src/ulid.ts +++ b/packages/ksuid/src/ulid.ts @@ -1,4 +1,4 @@ -import { BASE32_CROCKFORD } from "@thi.ng/base-n"; +import { BASE32_CROCKFORD } from "@thi.ng/base-n/32"; import { AKSUID } from "./aksuid"; import type { KSUIDOpts } from "./api"; diff --git a/packages/layout/src/grid-layout.ts b/packages/layout/src/grid-layout.ts index b335b9a2a9..9edf3a98c3 100644 --- a/packages/layout/src/grid-layout.ts +++ b/packages/layout/src/grid-layout.ts @@ -1,4 +1,4 @@ -import { isNumber } from "@thi.ng/checks"; +import { isNumber } from "@thi.ng/checks/is-number"; import type { IGridLayout, LayoutBox } from "./api"; const DEFAULT_SPANS: [number, number] = [1, 1]; diff --git a/packages/layout/src/is-layout.ts b/packages/layout/src/is-layout.ts index 2e0ccb789e..1404c18326 100644 --- a/packages/layout/src/is-layout.ts +++ b/packages/layout/src/is-layout.ts @@ -1,4 +1,4 @@ -import { implementsFunction } from "@thi.ng/checks"; +import { implementsFunction } from "@thi.ng/checks/implements-function"; import type { ILayout } from "./api"; export const isLayout = (x: any): x is ILayout => diff --git a/packages/leb128/src/index.ts b/packages/leb128/src/index.ts index 790e501306..d962646057 100644 --- a/packages/leb128/src/index.ts +++ b/packages/leb128/src/index.ts @@ -1,6 +1,6 @@ -import { hasWASM } from "@thi.ng/checks"; -import { unsupported } from "@thi.ng/errors"; -import { base64Decode } from "@thi.ng/transducers-binary"; +import { hasWASM } from "@thi.ng/checks/has-wasm"; +import { unsupported } from "@thi.ng/errors/unsupported"; +import { base64Decode } from "@thi.ng/transducers-binary/base64"; import { BINARY } from "./binary"; interface LEB128 { @@ -26,21 +26,19 @@ if (hasWASM()) { const ensureWASM = () => !wasm && unsupported("WASM module unavailable"); -const encode = (op: "leb128_encode_s_js" | "leb128_encode_u_js") => ( - x: number -) => { - ensureWASM(); - return U8.slice(0, wasm[op](x)); -}; +const encode = + (op: "leb128_encode_s_js" | "leb128_encode_u_js") => (x: number) => { + ensureWASM(); + return U8.slice(0, wasm[op](x)); + }; -const decode = (op: "leb128_decode_s_js" | "leb128_decode_u_js") => ( - src: Uint8Array, - idx = 0 -) => { - ensureWASM(); - U8.set(src.subarray(idx, Math.min(idx + 10, src.length)), 0); - return [wasm[op](0, 0), U8[0]]; -}; +const decode = + (op: "leb128_decode_s_js" | "leb128_decode_u_js") => + (src: Uint8Array, idx = 0) => { + ensureWASM(); + U8.set(src.subarray(idx, Math.min(idx + 10, src.length)), 0); + return [wasm[op](0, 0), U8[0]]; + }; /** * Encodes signed integer `x` into LEB128 varint format and returns diff --git a/packages/lowdisc/src/lowdisc.ts b/packages/lowdisc/src/lowdisc.ts index f94103246d..c658766dd4 100644 --- a/packages/lowdisc/src/lowdisc.ts +++ b/packages/lowdisc/src/lowdisc.ts @@ -1,4 +1,4 @@ -import { assert } from "@thi.ng/api"; +import { assert } from "@thi.ng/api/assert"; /** * General purpose iterator yielding n-dimensional sequence values obtained from diff --git a/packages/lowdisc/src/plastic.ts b/packages/lowdisc/src/plastic.ts index ea646509d7..de5d8d40d0 100644 --- a/packages/lowdisc/src/plastic.ts +++ b/packages/lowdisc/src/plastic.ts @@ -1,4 +1,4 @@ -import { assert } from "@thi.ng/api"; +import { assert } from "@thi.ng/api/assert"; import { kronecker } from "./kronecker"; import { lowDiscrepancy } from "./lowdisc"; diff --git a/packages/lsys/src/index.ts b/packages/lsys/src/index.ts index 9070c9da3d..7c7e8bcf68 100644 --- a/packages/lsys/src/index.ts +++ b/packages/lsys/src/index.ts @@ -1,10 +1,17 @@ import type { Fn2, IObjectOf } from "@thi.ng/api"; -import { partial, threadLast } from "@thi.ng/compose"; -import { illegalState } from "@thi.ng/errors"; -import { cossin, HALF_PI } from "@thi.ng/math"; -import { IRandom, SYSTEM } from "@thi.ng/random"; -import { iterate, last, mapcat, take } from "@thi.ng/transducers"; -import { add, Vec } from "@thi.ng/vectors"; +import { partial } from "@thi.ng/compose/partial"; +import { threadLast } from "@thi.ng/compose/thread-last"; +import { illegalState } from "@thi.ng/errors/illegal-state"; +import { cossin } from "@thi.ng/math/angle"; +import { HALF_PI } from "@thi.ng/math/api"; +import type { IRandom } from "@thi.ng/random"; +import { SYSTEM } from "@thi.ng/random/system"; +import { iterate } from "@thi.ng/transducers/iter/iterate"; +import { last } from "@thi.ng/transducers/rfn/last"; +import { mapcat } from "@thi.ng/transducers/xform/mapcat"; +import { take } from "@thi.ng/transducers/xform/take"; +import type { Vec } from "@thi.ng/vectors"; +import { add } from "@thi.ng/vectors/add"; export type LSysSymbol = string | number; export type ProductionRules = IObjectOf< diff --git a/packages/malloc/src/native.ts b/packages/malloc/src/native.ts index 9bf79cc9ac..4ec0fe92e3 100644 --- a/packages/malloc/src/native.ts +++ b/packages/malloc/src/native.ts @@ -1,4 +1,9 @@ -import { Type, TypedArray, typedArray, TypedArrayTypeMap } from "@thi.ng/api"; +import { + Type, + TypedArray, + typedArray, + TypedArrayTypeMap, +} from "@thi.ng/api/api/typedarray"; import type { IMemPoolArray } from "./api"; /** diff --git a/packages/malloc/src/pool.ts b/packages/malloc/src/pool.ts index b8a4c89e36..0029d786b9 100644 --- a/packages/malloc/src/pool.ts +++ b/packages/malloc/src/pool.ts @@ -1,7 +1,14 @@ -import { assert, SIZEOF, Type, TypedArray, typedArray } from "@thi.ng/api"; -import { align, Pow2 } from "@thi.ng/binary"; -import { isNumber } from "@thi.ng/checks"; -import { illegalArgs } from "@thi.ng/errors"; +import { + SIZEOF, + Type, + TypedArray, + typedArray, +} from "@thi.ng/api/api/typedarray"; +import { assert } from "@thi.ng/api/assert"; +import type { Pow2 } from "@thi.ng/binary"; +import { align } from "@thi.ng/binary/align"; +import { isNumber } from "@thi.ng/checks/is-number"; +import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; import type { IMemPool, MemPoolOpts, MemPoolStats } from "./api"; const STATE_FREE = 0; diff --git a/packages/markdown-table/src/table.ts b/packages/markdown-table/src/table.ts index 3016d8c501..c924541376 100644 --- a/packages/markdown-table/src/table.ts +++ b/packages/markdown-table/src/table.ts @@ -1,28 +1,24 @@ -import { assert, Fn, Keys } from "@thi.ng/api"; -import { isString } from "@thi.ng/checks"; -import { juxt } from "@thi.ng/compose"; -import { - center, - padLeft, - padRight, - repeat, - Stringer, - wrap, -} from "@thi.ng/strings"; -import { - comp, - last, - map, - max, - multiplex, - repeat as $repeat, - repeatedly, - scan, - transduce, - Transducer, -} from "@thi.ng/transducers"; -import type { Column } from "."; -import type { Align, Row, TableOpts } from "./api"; +import type { Fn, Keys } from "@thi.ng/api"; +import { assert } from "@thi.ng/api/assert"; +import { isString } from "@thi.ng/checks/is-string"; +import { juxt } from "@thi.ng/compose/juxt"; +import type { Stringer } from "@thi.ng/strings"; +import { center } from "@thi.ng/strings/center"; +import { padLeft } from "@thi.ng/strings/pad-left"; +import { padRight } from "@thi.ng/strings/pad-right"; +import { repeat } from "@thi.ng/strings/repeat"; +import { wrap } from "@thi.ng/strings/wrap"; +import type { Transducer } from "@thi.ng/transducers"; +import { comp } from "@thi.ng/transducers/func/comp"; +import { repeat as $repeat } from "@thi.ng/transducers/iter/repeat"; +import { repeatedly } from "@thi.ng/transducers/iter/repeatedly"; +import { last } from "@thi.ng/transducers/rfn/last"; +import { max } from "@thi.ng/transducers/rfn/max"; +import { transduce } from "@thi.ng/transducers/transduce"; +import { map } from "@thi.ng/transducers/xform/map"; +import { multiplex } from "@thi.ng/transducers/xform/multiplex"; +import { scan } from "@thi.ng/transducers/xform/scan"; +import type { Align, Column, Row, TableOpts } from "./api"; const PADS: Record>> = { c: center, diff --git a/packages/math/src/solve.ts b/packages/math/src/solve.ts index a90dbb284c..769ad59cc6 100644 --- a/packages/math/src/solve.ts +++ b/packages/math/src/solve.ts @@ -18,9 +18,10 @@ import { safeDiv } from "./safe-div"; * @param fn - * @param eps - */ -export const derivative = (f: (x: number) => number, eps = EPS) => ( - x: number -) => (f(x + eps) - f(x)) / eps; +export const derivative = + (f: (x: number) => number, eps = EPS) => + (x: number) => + (f(x + eps) - f(x)) / eps; /** * Computes solution for linear equation: `ax + b = 0`. diff --git a/packages/matrices/src/add.ts b/packages/matrices/src/add.ts index 23fd344cab..88add1bc8f 100644 --- a/packages/matrices/src/add.ts +++ b/packages/matrices/src/add.ts @@ -1,4 +1,4 @@ -import { add as _add, add4 } from "@thi.ng/vectors"; +import { add as _add, add4 } from "@thi.ng/vectors/add"; import type { MatOpMM, MultiMatOpMM } from "./api"; import { defMath } from "./internal/codegen"; diff --git a/packages/matrices/src/addn.ts b/packages/matrices/src/addn.ts index 2799e83a82..46daf8580b 100644 --- a/packages/matrices/src/addn.ts +++ b/packages/matrices/src/addn.ts @@ -1,4 +1,4 @@ -import { addN as _addN, addN4 } from "@thi.ng/vectors"; +import { addN as _addN, addN4 } from "@thi.ng/vectors/addn"; import type { MatOpMN, MultiMatOpMN } from "./api"; import { defMathN } from "./internal/codegen"; diff --git a/packages/matrices/src/alignment-quat.ts b/packages/matrices/src/alignment-quat.ts index fb307bd4c2..2c707a7b7b 100644 --- a/packages/matrices/src/alignment-quat.ts +++ b/packages/matrices/src/alignment-quat.ts @@ -1,10 +1,8 @@ -import { - cross3, - dot3, - mag, - normalize as _normalize, - ReadonlyVec, -} from "@thi.ng/vectors"; +import type { ReadonlyVec } from "@thi.ng/vectors"; +import { cross3 } from "@thi.ng/vectors/cross"; +import { dot3 } from "@thi.ng/vectors/dot"; +import { mag } from "@thi.ng/vectors/mag"; +import { normalize as _normalize } from "@thi.ng/vectors/normalize"; import { quatFromAxisAngle } from "./quat-axis-angle"; /** diff --git a/packages/matrices/src/column.ts b/packages/matrices/src/column.ts index 96c02360b3..1f90158c9d 100644 --- a/packages/matrices/src/column.ts +++ b/packages/matrices/src/column.ts @@ -1,4 +1,5 @@ -import { setS2, setS3, setS4, vop } from "@thi.ng/vectors"; +import { vop } from "@thi.ng/vectors/internal/vop"; +import { setS2, setS3, setS4 } from "@thi.ng/vectors/sets"; import type { MultiVecOpMN, VecOpMN } from "./api"; /** diff --git a/packages/matrices/src/conjugate.ts b/packages/matrices/src/conjugate.ts index 094c17bc29..d20e342e36 100644 --- a/packages/matrices/src/conjugate.ts +++ b/packages/matrices/src/conjugate.ts @@ -1,4 +1,5 @@ -import { ReadonlyVec, setC4, Vec } from "@thi.ng/vectors"; +import type { ReadonlyVec, Vec } from "@thi.ng/vectors"; +import { setC4 } from "@thi.ng/vectors/setc"; export const conjugateQ = (out: Vec | null, a: ReadonlyVec) => setC4(out || a, -a[0], -a[1], -a[2], a[3]); diff --git a/packages/matrices/src/determinant.ts b/packages/matrices/src/determinant.ts index 4cdfa012fa..906a03f211 100644 --- a/packages/matrices/src/determinant.ts +++ b/packages/matrices/src/determinant.ts @@ -1,4 +1,4 @@ -import { dotC4, dotC6 } from "@thi.ng/vectors"; +import { dotC4, dotC6 } from "@thi.ng/vectors/dotc"; import type { ReadonlyMat } from "./api"; const dp4 = dotC4; diff --git a/packages/matrices/src/diag.ts b/packages/matrices/src/diag.ts index 584b2e4b26..813dc70e55 100644 --- a/packages/matrices/src/diag.ts +++ b/packages/matrices/src/diag.ts @@ -1,4 +1,5 @@ -import { setS2, setS3, setS4, vop } from "@thi.ng/vectors"; +import { vop } from "@thi.ng/vectors/internal/vop"; +import { setS2, setS3, setS4 } from "@thi.ng/vectors/sets"; import type { MultiVecOpM } from "./api"; /** diff --git a/packages/matrices/src/div.ts b/packages/matrices/src/div.ts index c95e3ab7c3..a8718eccf6 100644 --- a/packages/matrices/src/div.ts +++ b/packages/matrices/src/div.ts @@ -1,4 +1,4 @@ -import { div as _div, div4 } from "@thi.ng/vectors"; +import { div as _div, div4 } from "@thi.ng/vectors/div"; import type { MatOpMM, MultiMatOpMM } from "./api"; import { defMath } from "./internal/codegen"; diff --git a/packages/matrices/src/divn.ts b/packages/matrices/src/divn.ts index f3c5749e29..00d7356018 100644 --- a/packages/matrices/src/divn.ts +++ b/packages/matrices/src/divn.ts @@ -1,4 +1,4 @@ -import { divN as _divN, divN4 } from "@thi.ng/vectors"; +import { divN as _divN, divN4 } from "@thi.ng/vectors/divn"; import type { MatOpMN, MultiMatOpMN } from "./api"; import { defMathN } from "./internal/codegen"; diff --git a/packages/matrices/src/frustum.ts b/packages/matrices/src/frustum.ts index 1125172dd8..df4efb5111 100644 --- a/packages/matrices/src/frustum.ts +++ b/packages/matrices/src/frustum.ts @@ -1,5 +1,5 @@ -import { DEG2RAD } from "@thi.ng/math"; -import { setC } from "@thi.ng/vectors"; +import { DEG2RAD } from "@thi.ng/math/api"; +import { setC } from "@thi.ng/vectors/setc"; import type { Mat } from "./api"; /** diff --git a/packages/matrices/src/identity.ts b/packages/matrices/src/identity.ts index ddfad7ba92..bc530adca9 100644 --- a/packages/matrices/src/identity.ts +++ b/packages/matrices/src/identity.ts @@ -1,4 +1,4 @@ -import { vop } from "@thi.ng/vectors"; +import { vop } from "@thi.ng/vectors/internal/vop"; import type { MultiMatOp1 } from "./api"; import { IDENT22, IDENT23, IDENT33, IDENT44 } from "./constants"; import { set } from "./set"; diff --git a/packages/matrices/src/internal/codegen.ts b/packages/matrices/src/internal/codegen.ts index 06c48d0ee6..0527e770b2 100644 --- a/packages/matrices/src/internal/codegen.ts +++ b/packages/matrices/src/internal/codegen.ts @@ -3,9 +3,8 @@ import { ARGS_VV, compile, DEFAULT_OUT, - MATH, - MATH_N, -} from "@thi.ng/vectors"; +} from "@thi.ng/vectors/internal/codegen"; +import { MATH, MATH_N } from "@thi.ng/vectors/internal/templates"; import type { MultiMatOpMM, MultiMatOpMN } from "../api"; const DEFAULT_SIZES = [6, 9, 16]; diff --git a/packages/matrices/src/invert.ts b/packages/matrices/src/invert.ts index a4353ba665..2b55a8ec3d 100644 --- a/packages/matrices/src/invert.ts +++ b/packages/matrices/src/invert.ts @@ -1,14 +1,8 @@ -import { - dotC4, - dotC6, - magSq4, - ReadonlyVec, - setC, - setC4, - setC6, - Vec, - vop, -} from "@thi.ng/vectors"; +import type { ReadonlyVec, Vec } from "@thi.ng/vectors"; +import { dotC4, dotC6 } from "@thi.ng/vectors/dotc"; +import { vop } from "@thi.ng/vectors/internal/vop"; +import { magSq4 } from "@thi.ng/vectors/magsq"; +import { setC, setC4, setC6 } from "@thi.ng/vectors/setc"; import type { MatOpMU, MultiMatOpMU } from "./api"; import { det44FromCoeffs, detCoeffs44 } from "./determinant"; diff --git a/packages/matrices/src/lookat.ts b/packages/matrices/src/lookat.ts index c671d56c0f..ea51fb1e56 100644 --- a/packages/matrices/src/lookat.ts +++ b/packages/matrices/src/lookat.ts @@ -1,11 +1,9 @@ -import { - cross3, - dot3, - normalize, - ReadonlyVec, - setC, - sub3, -} from "@thi.ng/vectors"; +import type { ReadonlyVec } from "@thi.ng/vectors"; +import { cross3 } from "@thi.ng/vectors/cross"; +import { dot3 } from "@thi.ng/vectors/dot"; +import { normalize } from "@thi.ng/vectors/normalize"; +import { setC } from "@thi.ng/vectors/setc"; +import { sub3 } from "@thi.ng/vectors/sub"; import type { Mat } from "./api"; /** diff --git a/packages/matrices/src/m22-m23.ts b/packages/matrices/src/m22-m23.ts index 5727f68797..e56c3988b6 100644 --- a/packages/matrices/src/m22-m23.ts +++ b/packages/matrices/src/m22-m23.ts @@ -1,4 +1,4 @@ -import { set4 } from "@thi.ng/vectors"; +import { set4 } from "@thi.ng/vectors/set"; import type { MatOpM } from "./api"; /** diff --git a/packages/matrices/src/m23-m22.ts b/packages/matrices/src/m23-m22.ts index 429342a6ba..6c7b99b232 100644 --- a/packages/matrices/src/m23-m22.ts +++ b/packages/matrices/src/m23-m22.ts @@ -1,4 +1,4 @@ -import { set4 } from "@thi.ng/vectors"; +import { set4 } from "@thi.ng/vectors/set"; import type { MatOpM } from "./api"; /** diff --git a/packages/matrices/src/m23-m44.ts b/packages/matrices/src/m23-m44.ts index 0a83ba0ce7..73af963971 100644 --- a/packages/matrices/src/m23-m44.ts +++ b/packages/matrices/src/m23-m44.ts @@ -1,4 +1,4 @@ -import { setC } from "@thi.ng/vectors"; +import { setC } from "@thi.ng/vectors/setc"; import type { MatOpM } from "./api"; /** diff --git a/packages/matrices/src/m33-m44.ts b/packages/matrices/src/m33-m44.ts index c68199edf4..399097f99f 100644 --- a/packages/matrices/src/m33-m44.ts +++ b/packages/matrices/src/m33-m44.ts @@ -1,4 +1,4 @@ -import { setC } from "@thi.ng/vectors"; +import { setC } from "@thi.ng/vectors/setc"; import type { MatOpM } from "./api"; /** diff --git a/packages/matrices/src/m44-m33.ts b/packages/matrices/src/m44-m33.ts index 9800b5672c..09e2c1bbc3 100644 --- a/packages/matrices/src/m44-m33.ts +++ b/packages/matrices/src/m44-m33.ts @@ -1,4 +1,4 @@ -import { setS3 } from "@thi.ng/vectors"; +import { setS3 } from "@thi.ng/vectors/sets"; import type { MatOpM } from "./api"; /** diff --git a/packages/matrices/src/matv.ts b/packages/matrices/src/matv.ts index 5f360d7975..584b558d7b 100644 --- a/packages/matrices/src/matv.ts +++ b/packages/matrices/src/matv.ts @@ -1,4 +1,4 @@ -import { setVV16, setVV4, setVV6, setVV9 } from "@thi.ng/vectors"; +import { setVV16, setVV4, setVV6, setVV9 } from "@thi.ng/vectors/setvv"; /** * Initializes 2x2 matrix from 2D column vectors. diff --git a/packages/matrices/src/mixq.ts b/packages/matrices/src/mixq.ts index 331c1ecaff..cfa77608cf 100644 --- a/packages/matrices/src/mixq.ts +++ b/packages/matrices/src/mixq.ts @@ -1,4 +1,8 @@ -import { dot4, maddN4, mulN4, ReadonlyVec, set4, Vec } from "@thi.ng/vectors"; +import type { ReadonlyVec, Vec } from "@thi.ng/vectors"; +import { dot4 } from "@thi.ng/vectors/dot"; +import { maddN4 } from "@thi.ng/vectors/maddn"; +import { mulN4 } from "@thi.ng/vectors/muln"; +import { set4 } from "@thi.ng/vectors/set"; /** * Interpolates quaternion `a` to `b` by given amount `t` [0...1], using diff --git a/packages/matrices/src/mul.ts b/packages/matrices/src/mul.ts index 23f308a2ab..4cab08b73d 100644 --- a/packages/matrices/src/mul.ts +++ b/packages/matrices/src/mul.ts @@ -1,4 +1,4 @@ -import { mul as _mul, mul4 } from "@thi.ng/vectors"; +import { mul as _mul, mul4 } from "@thi.ng/vectors/mul"; import type { MatOpMM, MultiMatOpMM } from "./api"; import { defMath } from "./internal/codegen"; diff --git a/packages/matrices/src/mulm.ts b/packages/matrices/src/mulm.ts index 4c489bffbf..a58a5e94fb 100644 --- a/packages/matrices/src/mulm.ts +++ b/packages/matrices/src/mulm.ts @@ -1,4 +1,6 @@ -import { dotS2, dotS3, dotS4, setC, setC4, setC6, vop } from "@thi.ng/vectors"; +import { dotS2, dotS3, dotS4 } from "@thi.ng/vectors/dots"; +import { vop } from "@thi.ng/vectors/internal/vop"; +import { setC, setC4, setC6 } from "@thi.ng/vectors/setc"; import type { MultiMatOpMM } from "./api"; /** diff --git a/packages/matrices/src/muln.ts b/packages/matrices/src/muln.ts index f6913b3a7a..fcce749218 100644 --- a/packages/matrices/src/muln.ts +++ b/packages/matrices/src/muln.ts @@ -1,4 +1,4 @@ -import { mulN as _mulN, mulN4 } from "@thi.ng/vectors"; +import { mulN as _mulN, mulN4 } from "@thi.ng/vectors/muln"; import type { MatOpMN, MultiMatOpMN } from "./api"; import { defMathN } from "./internal/codegen"; diff --git a/packages/matrices/src/mulq.ts b/packages/matrices/src/mulq.ts index 69922a308a..fd46fc7bbd 100644 --- a/packages/matrices/src/mulq.ts +++ b/packages/matrices/src/mulq.ts @@ -1,4 +1,5 @@ -import { setC4, VecOpVV } from "@thi.ng/vectors"; +import type { VecOpVV } from "@thi.ng/vectors"; +import { setC4 } from "@thi.ng/vectors/setc"; /** * Performs quaternion multiplication of `a` and `b` and writes result diff --git a/packages/matrices/src/mulv.ts b/packages/matrices/src/mulv.ts index df17f3e977..aef7138211 100644 --- a/packages/matrices/src/mulv.ts +++ b/packages/matrices/src/mulv.ts @@ -1,15 +1,7 @@ -import { - dotS2, - dotS3, - dotS4, - ReadonlyVec, - setC2, - setC3, - setC4, - Vec, - VecOpVV, - vop, -} from "@thi.ng/vectors"; +import type { ReadonlyVec, Vec, VecOpVV } from "@thi.ng/vectors"; +import { dotS2, dotS3, dotS4 } from "@thi.ng/vectors/dots"; +import { vop } from "@thi.ng/vectors/internal/vop"; +import { setC2, setC3, setC4 } from "@thi.ng/vectors/setc"; import type { MatOpMV, MultiMatOpMV, ReadonlyMat } from "./api"; /** diff --git a/packages/matrices/src/mulvm.ts b/packages/matrices/src/mulvm.ts index 17342c37c7..9824ae9201 100644 --- a/packages/matrices/src/mulvm.ts +++ b/packages/matrices/src/mulvm.ts @@ -1,16 +1,7 @@ -import { - dot2, - dot3, - dot4, - dotS2, - dotS3, - dotS4, - ReadonlyVec, - setC2, - setC3, - setC4, - Vec, -} from "@thi.ng/vectors"; +import type { ReadonlyVec, Vec } from "@thi.ng/vectors"; +import { dot2, dot3, dot4 } from "@thi.ng/vectors/dot"; +import { dotS2, dotS3, dotS4 } from "@thi.ng/vectors/dots"; +import { setC2, setC3, setC4 } from "@thi.ng/vectors/setc"; import type { ReadonlyMat } from "./api"; /** diff --git a/packages/matrices/src/orthagonal.ts b/packages/matrices/src/orthagonal.ts index 2bd00fb667..567df4b10c 100644 --- a/packages/matrices/src/orthagonal.ts +++ b/packages/matrices/src/orthagonal.ts @@ -1,4 +1,5 @@ -import { EPS, eqDelta } from "@thi.ng/math"; +import { EPS } from "@thi.ng/math/api"; +import { eqDelta } from "@thi.ng/math/eqdelta"; import type { ReadonlyMat } from "./api"; /** diff --git a/packages/matrices/src/ortho.ts b/packages/matrices/src/ortho.ts index baf5ab6fcc..3373227f48 100644 --- a/packages/matrices/src/ortho.ts +++ b/packages/matrices/src/ortho.ts @@ -1,4 +1,4 @@ -import { setC } from "@thi.ng/vectors"; +import { setC } from "@thi.ng/vectors/setc"; import type { Mat } from "./api"; /** diff --git a/packages/matrices/src/outer-product.ts b/packages/matrices/src/outer-product.ts index 3fdbd4f56e..ddbb84cfe7 100644 --- a/packages/matrices/src/outer-product.ts +++ b/packages/matrices/src/outer-product.ts @@ -1,4 +1,6 @@ -import { MultiVecOpVV, ReadonlyVec, setC, setC4, vop } from "@thi.ng/vectors"; +import type { MultiVecOpVV, ReadonlyVec } from "@thi.ng/vectors"; +import { vop } from "@thi.ng/vectors/internal/vop"; +import { setC, setC4 } from "@thi.ng/vectors/setc"; import type { Mat } from "./api"; /** diff --git a/packages/matrices/src/project.ts b/packages/matrices/src/project.ts index 481bde2725..dd795369b5 100644 --- a/packages/matrices/src/project.ts +++ b/packages/matrices/src/project.ts @@ -1,4 +1,5 @@ -import { fromHomogeneous4, ReadonlyVec, Vec } from "@thi.ng/vectors"; +import type { ReadonlyVec, Vec } from "@thi.ng/vectors"; +import { fromHomogeneous4 } from "@thi.ng/vectors/homogeneous"; import type { ReadonlyMat } from "./api"; import { invert23, invert44 } from "./invert"; import { mulV23, mulV344, mulV44 } from "./mulv"; diff --git a/packages/matrices/src/quat-axis-angle.ts b/packages/matrices/src/quat-axis-angle.ts index d617366022..a57824ca93 100644 --- a/packages/matrices/src/quat-axis-angle.ts +++ b/packages/matrices/src/quat-axis-angle.ts @@ -1,5 +1,6 @@ -import { EPS } from "@thi.ng/math"; -import { normalize, ReadonlyVec } from "@thi.ng/vectors"; +import { EPS } from "@thi.ng/math/api"; +import type { ReadonlyVec } from "@thi.ng/vectors"; +import { normalize } from "@thi.ng/vectors/normalize"; /** * Computes a quaternion representing the rotation `theta` around diff --git a/packages/matrices/src/quat-euler.ts b/packages/matrices/src/quat-euler.ts index 6607a2621d..5bb477f28b 100644 --- a/packages/matrices/src/quat-euler.ts +++ b/packages/matrices/src/quat-euler.ts @@ -1,4 +1,4 @@ -import { X3, Y3, Z3 } from "@thi.ng/vectors"; +import { X3, Y3, Z3 } from "@thi.ng/vectors/api"; import { mulQ } from "./mulq"; import { quatFromAxisAngle } from "./quat-axis-angle"; diff --git a/packages/matrices/src/quat-m33.ts b/packages/matrices/src/quat-m33.ts index 932889e1ab..cb16eab3fd 100644 --- a/packages/matrices/src/quat-m33.ts +++ b/packages/matrices/src/quat-m33.ts @@ -1,4 +1,4 @@ -import { setC } from "@thi.ng/vectors"; +import { setC } from "@thi.ng/vectors/setc"; import type { MatOpV } from "./api"; /** diff --git a/packages/matrices/src/quat-m44.ts b/packages/matrices/src/quat-m44.ts index 4dd01ac5c8..3e3fe99a34 100644 --- a/packages/matrices/src/quat-m44.ts +++ b/packages/matrices/src/quat-m44.ts @@ -1,4 +1,5 @@ -import { ReadonlyVec, setC, ZERO3 } from "@thi.ng/vectors"; +import { ReadonlyVec, ZERO3 } from "@thi.ng/vectors/api"; +import { setC } from "@thi.ng/vectors/setc"; import type { Mat } from "./api"; /** diff --git a/packages/matrices/src/rotation-around-axis.ts b/packages/matrices/src/rotation-around-axis.ts index 563191c205..a0405f7df1 100644 --- a/packages/matrices/src/rotation-around-axis.ts +++ b/packages/matrices/src/rotation-around-axis.ts @@ -1,5 +1,7 @@ -import { sincos } from "@thi.ng/math"; -import { normalize as _normalize, ReadonlyVec, setC } from "@thi.ng/vectors"; +import { sincos } from "@thi.ng/math/angle"; +import type { ReadonlyVec } from "@thi.ng/vectors"; +import { normalize as _normalize } from "@thi.ng/vectors/normalize"; +import { setC } from "@thi.ng/vectors/setc"; import type { Mat } from "./api"; import { mat33to44 } from "./m33-m44"; diff --git a/packages/matrices/src/rotation.ts b/packages/matrices/src/rotation.ts index 1f803f02e5..9f2fc9728f 100644 --- a/packages/matrices/src/rotation.ts +++ b/packages/matrices/src/rotation.ts @@ -1,5 +1,5 @@ -import { sincos } from "@thi.ng/math"; -import { setC, setC4, setC6 } from "@thi.ng/vectors"; +import { sincos } from "@thi.ng/math/angle"; +import { setC, setC4, setC6 } from "@thi.ng/vectors/setc"; import type { MatOpN } from "./api"; /** diff --git a/packages/matrices/src/row.ts b/packages/matrices/src/row.ts index 20bcfd878f..deaa682e6d 100644 --- a/packages/matrices/src/row.ts +++ b/packages/matrices/src/row.ts @@ -1,4 +1,5 @@ -import { setS2, setS3, setS4, vop } from "@thi.ng/vectors"; +import { vop } from "@thi.ng/vectors/internal/vop"; +import { setS2, setS3, setS4 } from "@thi.ng/vectors/sets"; import type { MultiVecOpMN } from "./api"; /** diff --git a/packages/matrices/src/scale-center.ts b/packages/matrices/src/scale-center.ts index 1b2b89dc0f..a364526997 100644 --- a/packages/matrices/src/scale-center.ts +++ b/packages/matrices/src/scale-center.ts @@ -1,4 +1,5 @@ -import { neg, ReadonlyVec } from "@thi.ng/vectors"; +import type { ReadonlyVec } from "@thi.ng/vectors"; +import { neg } from "@thi.ng/vectors/neg"; import type { Mat } from "./api"; import { concat } from "./concat"; import { scale23, scale44 } from "./scale"; diff --git a/packages/matrices/src/scale.ts b/packages/matrices/src/scale.ts index b189e07210..b008fa0c12 100644 --- a/packages/matrices/src/scale.ts +++ b/packages/matrices/src/scale.ts @@ -1,5 +1,5 @@ -import { isNumber } from "@thi.ng/checks"; -import { setC, setC4, setC6 } from "@thi.ng/vectors"; +import { isNumber } from "@thi.ng/checks/is-number"; +import { setC, setC4, setC6 } from "@thi.ng/vectors/setc"; import type { MatOpNV } from "./api"; /** diff --git a/packages/matrices/src/set.ts b/packages/matrices/src/set.ts index 463b674156..701807b70d 100644 --- a/packages/matrices/src/set.ts +++ b/packages/matrices/src/set.ts @@ -1,4 +1,6 @@ -import { compile, set as _set, SET, set4 } from "@thi.ng/vectors"; +import { compile } from "@thi.ng/vectors/internal/codegen"; +import { SET } from "@thi.ng/vectors/internal/templates"; +import { set as _set, set4 } from "@thi.ng/vectors/set"; import type { MatOpM } from "./api"; const $ = (dim: number) => _set.add(dim, compile(dim, SET, "o,a")); diff --git a/packages/matrices/src/sub.ts b/packages/matrices/src/sub.ts index e978fa1c80..6b70a62fad 100644 --- a/packages/matrices/src/sub.ts +++ b/packages/matrices/src/sub.ts @@ -1,4 +1,4 @@ -import { sub as _sub, sub4 } from "@thi.ng/vectors"; +import { sub as _sub, sub4 } from "@thi.ng/vectors/sub"; import type { MatOpMM, MultiMatOpMM } from "./api"; import { defMath } from "./internal/codegen"; diff --git a/packages/matrices/src/subn.ts b/packages/matrices/src/subn.ts index cd553fec15..915a9acde0 100644 --- a/packages/matrices/src/subn.ts +++ b/packages/matrices/src/subn.ts @@ -1,4 +1,4 @@ -import { subN as _subN, subN4 } from "@thi.ng/vectors"; +import { subN as _subN, subN4 } from "@thi.ng/vectors/subn"; import type { MatOpMN, MultiMatOpMN } from "./api"; import { defMathN } from "./internal/codegen"; diff --git a/packages/matrices/src/trace.ts b/packages/matrices/src/trace.ts index 20cbdbac8a..5d700b0343 100644 --- a/packages/matrices/src/trace.ts +++ b/packages/matrices/src/trace.ts @@ -1,4 +1,4 @@ -import { sum } from "@thi.ng/vectors"; +import { sum } from "@thi.ng/vectors/sum"; import type { ReadonlyMat } from "./api"; import { diag } from "./diag"; diff --git a/packages/matrices/src/translation.ts b/packages/matrices/src/translation.ts index ac789658b1..71db7432ba 100644 --- a/packages/matrices/src/translation.ts +++ b/packages/matrices/src/translation.ts @@ -1,4 +1,5 @@ -import { ReadonlyVec, setC, setC6 } from "@thi.ng/vectors"; +import type { ReadonlyVec } from "@thi.ng/vectors"; +import { setC, setC6 } from "@thi.ng/vectors/setc"; import type { Mat } from "./api"; /** diff --git a/packages/matrices/src/transpose.ts b/packages/matrices/src/transpose.ts index 866a2f890e..825e5ea37e 100644 --- a/packages/matrices/src/transpose.ts +++ b/packages/matrices/src/transpose.ts @@ -1,4 +1,4 @@ -import { setC, setC4 } from "@thi.ng/vectors"; +import { setC, setC4 } from "@thi.ng/vectors/setc"; import type { MatOpM } from "./api"; /** diff --git a/packages/morton/src/scaled.ts b/packages/morton/src/scaled.ts index a61d655871..e92e2b763c 100644 --- a/packages/morton/src/scaled.ts +++ b/packages/morton/src/scaled.ts @@ -1,6 +1,8 @@ -import { assert, FnN4 } from "@thi.ng/api"; -import { MASKS } from "@thi.ng/binary"; -import { fit, fit01, inRange } from "@thi.ng/math"; +import type { FnN4 } from "@thi.ng/api"; +import { assert } from "@thi.ng/api/assert"; +import { MASKS } from "@thi.ng/binary/constants"; +import { fit, fit01 } from "@thi.ng/math/fit"; +import { inRange } from "@thi.ng/math/interval"; import { decode10, decode16, diff --git a/packages/morton/src/tree.ts b/packages/morton/src/tree.ts index b5a7479c0a..4be1ea4f7d 100644 --- a/packages/morton/src/tree.ts +++ b/packages/morton/src/tree.ts @@ -1,4 +1,4 @@ -import { ceilPow2 } from "@thi.ng/binary"; +import { ceilPow2 } from "@thi.ng/binary/pow"; export const treeToMorton = (t: number[], dim: number) => { let n = 0; diff --git a/packages/morton/src/zcurve.ts b/packages/morton/src/zcurve.ts index 40031aa021..67f8a921c6 100644 --- a/packages/morton/src/zcurve.ts +++ b/packages/morton/src/zcurve.ts @@ -1,11 +1,11 @@ -import { - assert, +import type { NumericArray, Range1_32, Range1_64, RangeValueMap, } from "@thi.ng/api"; -import { MASKS } from "@thi.ng/binary"; +import { assert } from "@thi.ng/api/assert"; +import { MASKS } from "@thi.ng/binary/constants"; type Range2_64 = Exclude; diff --git a/packages/oquery/src/query.ts b/packages/oquery/src/query.ts index c7181c1789..d98b3d8920 100644 --- a/packages/oquery/src/query.ts +++ b/packages/oquery/src/query.ts @@ -1,6 +1,8 @@ import type { Fn2, Predicate } from "@thi.ng/api"; -import { isArray, isFunction, isSet } from "@thi.ng/checks"; -import { defmulti } from "@thi.ng/defmulti"; +import { isArray } from "@thi.ng/checks/is-array"; +import { isFunction } from "@thi.ng/checks/is-function"; +import { isSet } from "@thi.ng/checks/is-set"; +import { defmulti } from "@thi.ng/defmulti/defmulti"; import { equiv } from "@thi.ng/equiv"; import type { FTerm, diff --git a/packages/parse/src/context.ts b/packages/parse/src/context.ts index 0a03a1aa4e..dc6fff1e11 100644 --- a/packages/parse/src/context.ts +++ b/packages/parse/src/context.ts @@ -1,4 +1,5 @@ -import { isArrayLike, isString } from "@thi.ng/checks"; +import { isArrayLike } from "@thi.ng/checks/is-arraylike"; +import { isString } from "@thi.ng/checks/is-string"; import type { ContextOpts, IReader, ParseScope, ParseState } from "./api"; import { parseError } from "./error"; import { defArrayReader } from "./readers/array-reader"; diff --git a/packages/parse/src/error.ts b/packages/parse/src/error.ts index be6e21afa8..fef1b706e7 100644 --- a/packages/parse/src/error.ts +++ b/packages/parse/src/error.ts @@ -1,4 +1,4 @@ -import { defError } from "@thi.ng/errors"; +import { defError } from "@thi.ng/errors/deferror"; import type { ParseContext } from "./context"; const ParseError = defError(() => `ParseError`); diff --git a/packages/parse/src/grammar.ts b/packages/parse/src/grammar.ts index 2e12c6d0cd..f8e0d3a92b 100644 --- a/packages/parse/src/grammar.ts +++ b/packages/parse/src/grammar.ts @@ -1,6 +1,8 @@ import type { Fn } from "@thi.ng/api"; -import { DEFAULT, defmulti } from "@thi.ng/defmulti"; -import { illegalArgs, unsupported } from "@thi.ng/errors"; +import { DEFAULT } from "@thi.ng/defmulti/constants"; +import { defmulti } from "@thi.ng/defmulti/defmulti"; +import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; +import { unsupported } from "@thi.ng/errors/unsupported"; import type { DynamicParser, GrammarOpts, @@ -237,13 +239,8 @@ compile.addAll({ }, alt: ($, lang, opts, flags) => { opts.debug && console.log(`alt: ${$.id}`, flags); - const [ - term0, - { children: terms }, - repeat, - disc, - lookahead, - ] = $.children!; + const [term0, { children: terms }, repeat, disc, lookahead] = + $.children!; const acc: Parser[] = [compile(term0, lang, opts, flags)]; if (terms) { for (let c of terms) { diff --git a/packages/parse/src/presets/alpha.ts b/packages/parse/src/presets/alpha.ts index 5c51edd11d..f3bcfe06dd 100644 --- a/packages/parse/src/presets/alpha.ts +++ b/packages/parse/src/presets/alpha.ts @@ -1,4 +1,7 @@ -import { ALPHA as _ALPHA, ALPHA_NUM as _ALPHA_NUM } from "@thi.ng/strings"; +import { + ALPHA as _ALPHA, + ALPHA_NUM as _ALPHA_NUM, +} from "@thi.ng/strings/groups"; import { oneOf } from "../prims/one-of"; import { range } from "../prims/range"; diff --git a/packages/parse/src/presets/escape.ts b/packages/parse/src/presets/escape.ts index 55581e44c5..bfa4af9495 100644 --- a/packages/parse/src/presets/escape.ts +++ b/packages/parse/src/presets/escape.ts @@ -1,4 +1,4 @@ -import { ESCAPES } from "@thi.ng/strings"; +import { ESCAPES } from "@thi.ng/strings/escape"; import { repeat } from "../combinators/repeat"; import { seq } from "../combinators/seq"; import { xform } from "../combinators/xform"; diff --git a/packages/parse/src/presets/hex.ts b/packages/parse/src/presets/hex.ts index a728a77cf2..7ad5806d63 100644 --- a/packages/parse/src/presets/hex.ts +++ b/packages/parse/src/presets/hex.ts @@ -1,4 +1,4 @@ -import { HEX } from "@thi.ng/strings"; +import { HEX } from "@thi.ng/strings/groups"; import { oneOrMore, repeat } from "../combinators/repeat"; import { xform } from "../combinators/xform"; import { oneOf } from "../prims/one-of"; diff --git a/packages/parse/src/presets/whitespace.ts b/packages/parse/src/presets/whitespace.ts index 72925c582b..3851a1de12 100644 --- a/packages/parse/src/presets/whitespace.ts +++ b/packages/parse/src/presets/whitespace.ts @@ -1,4 +1,4 @@ -import { WS as _WS } from "@thi.ng/strings"; +import { WS as _WS } from "@thi.ng/strings/groups"; import { oneOrMoreD, zeroOrMoreD } from "../combinators/repeat"; import { oneOf, oneOfD } from "../prims/one-of"; diff --git a/packages/parse/src/prims/anchor.ts b/packages/parse/src/prims/anchor.ts index 59bba6df18..d6abd3dd2f 100644 --- a/packages/parse/src/prims/anchor.ts +++ b/packages/parse/src/prims/anchor.ts @@ -1,11 +1,13 @@ import type { Nullable, Predicate2 } from "@thi.ng/api"; -import { ALPHA_NUM } from "@thi.ng/strings"; +import { ALPHA_NUM } from "@thi.ng/strings/groups"; import type { Parser } from "../api"; -export const anchor = (fn: Predicate2>): Parser => (ctx) => { - const state = ctx.state; - return fn(state.last, state.done ? null : ctx.reader.read(state)); -}; +export const anchor = + (fn: Predicate2>): Parser => + (ctx) => { + const state = ctx.state; + return fn(state.last, state.done ? null : ctx.reader.read(state)); + }; export const inputStart: Parser = (ctx) => ctx.state.last == null; diff --git a/packages/parse/src/prims/none-of.ts b/packages/parse/src/prims/none-of.ts index 15cdad6f0f..d1b22b64bf 100644 --- a/packages/parse/src/prims/none-of.ts +++ b/packages/parse/src/prims/none-of.ts @@ -1,5 +1,6 @@ import type { Predicate } from "@thi.ng/api"; -import { isPlainObject, isSet } from "@thi.ng/checks"; +import { isPlainObject } from "@thi.ng/checks/is-plain-object"; +import { isSet } from "@thi.ng/checks/is-set"; import type { CharSet, LitParser } from "../api"; import { satisfy, satisfyD } from "./satisfy"; diff --git a/packages/parse/src/prims/one-of.ts b/packages/parse/src/prims/one-of.ts index 8cc2170efd..3a29b76925 100644 --- a/packages/parse/src/prims/one-of.ts +++ b/packages/parse/src/prims/one-of.ts @@ -1,5 +1,6 @@ import type { Predicate } from "@thi.ng/api"; -import { isPlainObject, isSet } from "@thi.ng/checks"; +import { isPlainObject } from "@thi.ng/checks/is-plain-object"; +import { isSet } from "@thi.ng/checks/is-set"; import type { CharSet, LitParser } from "../api"; import { satisfy, satisfyD } from "./satisfy"; diff --git a/packages/parse/src/prims/pass.ts b/packages/parse/src/prims/pass.ts index 363ac6564a..cc0de043bc 100644 --- a/packages/parse/src/prims/pass.ts +++ b/packages/parse/src/prims/pass.ts @@ -1,4 +1,4 @@ -import { isFunction } from "@thi.ng/checks"; +import { isFunction } from "@thi.ng/checks/is-function"; import type { Parser, PassValue } from "../api"; /** @@ -8,11 +8,10 @@ import type { Parser, PassValue } from "../api"; * @param result - * @param id - */ -export const pass = ( - result: PassValue, - id = "pass" -): Parser => (ctx) => - ctx.addChild(id, isFunction(result) ? result() : result); +export const pass = + (result: PassValue, id = "pass"): Parser => + (ctx) => + ctx.addChild(id, isFunction(result) ? result() : result); /** * Parser which consumes no input and always succeeds. No AST creation. diff --git a/packages/parse/src/prims/skip.ts b/packages/parse/src/prims/skip.ts index 23175c7ad1..4f42d0b650 100644 --- a/packages/parse/src/prims/skip.ts +++ b/packages/parse/src/prims/skip.ts @@ -21,13 +21,15 @@ import type { Parser } from "../api"; * * @param pred */ -export const skipWhile = (pred: Predicate): Parser => (ctx) => { - const state = { ...ctx.state }; - const reader = ctx.reader; - while (!state.done) { - if (!pred(reader.read(state))) break; - reader.next(state); - } - ctx.state = state; - return true; -}; +export const skipWhile = + (pred: Predicate): Parser => + (ctx) => { + const state = { ...ctx.state }; + const reader = ctx.reader; + while (!state.done) { + if (!pred(reader.read(state))) break; + reader.next(state); + } + ctx.state = state; + return true; + }; diff --git a/packages/paths/src/mut-in-many.ts b/packages/paths/src/mut-in-many.ts index 85e8e1c06a..8e4be28864 100644 --- a/packages/paths/src/mut-in-many.ts +++ b/packages/paths/src/mut-in-many.ts @@ -1,5 +1,5 @@ import type { Path } from "@thi.ng/api"; -import { illegalArgs } from "@thi.ng/errors"; +import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; import { mutIn } from "./mut-in"; /** diff --git a/packages/paths/src/path.ts b/packages/paths/src/path.ts index 05ec502560..5091181c78 100644 --- a/packages/paths/src/path.ts +++ b/packages/paths/src/path.ts @@ -1,5 +1,8 @@ -import { assert, NumOrString, Path } from "@thi.ng/api"; -import { isArray, isProtoPath, isString } from "@thi.ng/checks"; +import type { NumOrString, Path } from "@thi.ng/api"; +import { assert } from "@thi.ng/api/assert"; +import { isArray } from "@thi.ng/checks/is-array"; +import { isProtoPath } from "@thi.ng/checks/is-proto-path"; +import { isString } from "@thi.ng/checks/is-string"; /** * Converts the given key path to canonical form (array). diff --git a/packages/paths/src/set-in-many.ts b/packages/paths/src/set-in-many.ts index d1e806f697..63bbd2a52f 100644 --- a/packages/paths/src/set-in-many.ts +++ b/packages/paths/src/set-in-many.ts @@ -1,5 +1,5 @@ import type { Path } from "@thi.ng/api"; -import { illegalArgs } from "@thi.ng/errors"; +import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; import { setIn } from "./set-in"; /** diff --git a/packages/paths/src/setter.ts b/packages/paths/src/setter.ts index 2218dc3f77..632cdc4c0d 100644 --- a/packages/paths/src/setter.ts +++ b/packages/paths/src/setter.ts @@ -14,7 +14,8 @@ import type { Path8, PathVal, } from "@thi.ng/api"; -import { isArray, isTypedArray } from "@thi.ng/checks"; +import { isArray } from "@thi.ng/checks/is-array"; +import { isTypedArray } from "@thi.ng/checks/is-typedarray"; import { toPath } from "./path"; /** @@ -194,7 +195,9 @@ export const copy = (x: any) => * * @internal */ -const compS = (k: NumOrString, f: (o: any, v: any) => any) => ( - s: any, - v: any -) => ((s = copy(s)), (s[k] = f ? f(s[k], v) : v), s); +const compS = + (k: NumOrString, f: (o: any, v: any) => any) => (s: any, v: any) => { + s = copy(s); + s[k] = f ? f(s[k], v) : v; + return s; + }; diff --git a/packages/pixel-io-netpbm/src/read.ts b/packages/pixel-io-netpbm/src/read.ts index a4fc4adecb..fb27e75335 100644 --- a/packages/pixel-io-netpbm/src/read.ts +++ b/packages/pixel-io-netpbm/src/read.ts @@ -1,6 +1,10 @@ -import { assert, Predicate } from "@thi.ng/api"; -import { unsupported } from "@thi.ng/errors"; -import { GRAY16, GRAY8, packedBuffer, RGB888 } from "@thi.ng/pixel"; +import type { Predicate } from "@thi.ng/api"; +import { assert } from "@thi.ng/api/assert"; +import { unsupported } from "@thi.ng/errors/unsupported"; +import { GRAY16 } from "@thi.ng/pixel/format/gray16"; +import { GRAY8 } from "@thi.ng/pixel/format/gray8"; +import { RGB888 } from "@thi.ng/pixel/format/rgb888"; +import { packedBuffer } from "@thi.ng/pixel/packed"; const isLinebreak = (c: number) => c === 0xa; diff --git a/packages/pixel-io-netpbm/src/write.ts b/packages/pixel-io-netpbm/src/write.ts index f8071d7b79..862c2bdbc0 100644 --- a/packages/pixel-io-netpbm/src/write.ts +++ b/packages/pixel-io-netpbm/src/write.ts @@ -1,4 +1,6 @@ -import { GRAY16, luminanceABGR, PackedBuffer } from "@thi.ng/pixel"; +import type { PackedBuffer } from "@thi.ng/pixel"; +import { GRAY16 } from "@thi.ng/pixel/format/gray16"; +import { luminanceABGR } from "@thi.ng/pixel/utils"; const formatComments = ( comments: string[] = ["generated by @thi.ng/pixel-io-netpbm"] diff --git a/packages/pixel/src/canvas.ts b/packages/pixel/src/canvas.ts index a940f02c84..a25314d395 100644 --- a/packages/pixel/src/canvas.ts +++ b/packages/pixel/src/canvas.ts @@ -1,4 +1,4 @@ -import { isNumber } from "@thi.ng/checks"; +import { isNumber } from "@thi.ng/checks/is-number"; import type { CanvasContext, RawPixelBuffer } from "./api"; /** diff --git a/packages/pixel/src/codegen.ts b/packages/pixel/src/codegen.ts index 77d398e8ea..b959dedf10 100644 --- a/packages/pixel/src/codegen.ts +++ b/packages/pixel/src/codegen.ts @@ -1,6 +1,6 @@ -import { luminanceABGR } from "./utils"; import type { Fn } from "@thi.ng/api"; import type { PackedChannel } from "./api"; +import { luminanceABGR } from "./utils"; const compileLShift = (x: string, shift: number) => shift > 0 diff --git a/packages/pixel/src/convolve.ts b/packages/pixel/src/convolve.ts index 4ce8a6e049..d739d85b93 100644 --- a/packages/pixel/src/convolve.ts +++ b/packages/pixel/src/convolve.ts @@ -1,6 +1,8 @@ -import { assert, Fn, FnN3, NumericArray } from "@thi.ng/api"; -import { isFunction } from "@thi.ng/checks"; -import { clamp, lanczos } from "@thi.ng/math"; +import type { Fn, FnN3, NumericArray } from "@thi.ng/api"; +import { assert } from "@thi.ng/api/assert"; +import { isFunction } from "@thi.ng/checks/is-function"; +import { clamp } from "@thi.ng/math/interval"; +import { lanczos } from "@thi.ng/math/mix"; import type { ConvolutionKernelSpec, ConvolveOpts, @@ -108,7 +110,13 @@ const initKernel = ( /** @internal */ const initConvolve = (src: FloatBuffer, opts: ConvolveOpts) => { - const { kernel, channel, stride: sampleStride, scale, offset } = { + const { + kernel, + channel, + stride: sampleStride, + scale, + offset, + } = { channel: 0, offset: 0, scale: 1, @@ -297,11 +305,13 @@ export const POOL_MAX: PoolTemplate = (body) => `Math.max(${body.join(",")})`; * * @param bias */ -export const POOL_THRESHOLD = (bias = 0): PoolTemplate => (body, w, h) => { - const center = POOL_NEAREST(body, w, h); - const mean = `(${body.join("+")})/${w * h}`; - return `(${center} - ${mean} + ${bias}) < 0 ? 0 : 1`; -}; +export const POOL_THRESHOLD = + (bias = 0): PoolTemplate => + (body, w, h) => { + const center = POOL_NEAREST(body, w, h); + const mean = `(${body.join("+")})/${w * h}`; + return `(${center} - ${mean} + ${bias}) < 0 ? 0 : 1`; + }; export const SOBEL_X: KernelSpec = { spec: [-1, -2, -1, 0, 0, 0, 1, 2, 1], diff --git a/packages/pixel/src/dither.ts b/packages/pixel/src/dither.ts index 078513ca27..d60af35f6d 100644 --- a/packages/pixel/src/dither.ts +++ b/packages/pixel/src/dither.ts @@ -1,5 +1,5 @@ import type { NumericArray } from "@thi.ng/api"; -import { clamp } from "@thi.ng/math"; +import { clamp } from "@thi.ng/math/interval"; import type { BayerMatrix, BayerSize } from "./api"; const init = ( diff --git a/packages/pixel/src/dominant-colors.ts b/packages/pixel/src/dominant-colors.ts index 83de0ad507..9d409e1bbf 100644 --- a/packages/pixel/src/dominant-colors.ts +++ b/packages/pixel/src/dominant-colors.ts @@ -1,5 +1,6 @@ import type { Fn2 } from "@thi.ng/api"; -import { kmeans, KMeansOpts } from "@thi.ng/k-means"; +import type { KMeansOpts } from "@thi.ng/k-means"; +import { kmeans } from "@thi.ng/k-means/kmeans"; import type { FloatBuffer } from "./float"; export interface DominantColorOpts extends KMeansOpts { diff --git a/packages/pixel/src/float.ts b/packages/pixel/src/float.ts index c5c3d808af..de5e7302ea 100644 --- a/packages/pixel/src/float.ts +++ b/packages/pixel/src/float.ts @@ -1,6 +1,8 @@ -import { assert, Fn2, ICopy, IEmpty, NumericArray } from "@thi.ng/api"; -import { isNumber, isString } from "@thi.ng/checks"; -import { clamp01 } from "@thi.ng/math"; +import type { Fn2, ICopy, IEmpty, NumericArray } from "@thi.ng/api"; +import { assert } from "@thi.ng/api/assert"; +import { isNumber } from "@thi.ng/checks/is-number"; +import { isString } from "@thi.ng/checks/is-string"; +import { clamp01 } from "@thi.ng/math/interval"; import type { BlendFnFloat, BlitOpts, @@ -57,7 +59,8 @@ export class FloatBuffer IBlit, IInvert, ICopy, - IEmpty { + IEmpty +{ /** * Creates a new `FloatBuffer` from given {@link PackedBuffer} and using * provided {@link FloatFormat}. diff --git a/packages/pixel/src/format/argb8888.ts b/packages/pixel/src/format/argb8888.ts index 0e9acb234a..323223667e 100644 --- a/packages/pixel/src/format/argb8888.ts +++ b/packages/pixel/src/format/argb8888.ts @@ -1,4 +1,4 @@ -import { swapLane13 } from "@thi.ng/binary"; +import { swapLane13 } from "@thi.ng/binary/swizzle"; import { Lane } from "../api"; import { defPackedFormat } from "./packed-format"; diff --git a/packages/pixel/src/format/float-format.ts b/packages/pixel/src/format/float-format.ts index ecbf1ae318..fcc99eee65 100644 --- a/packages/pixel/src/format/float-format.ts +++ b/packages/pixel/src/format/float-format.ts @@ -1,5 +1,5 @@ import type { Fn2, FnN2, IObjectOf, NumericArray } from "@thi.ng/api"; -import { clamp01 } from "@thi.ng/math"; +import { clamp01 } from "@thi.ng/math/interval"; import { FloatFormat, FloatFormatSpec, Lane } from "../api"; import { luminanceABGR } from "../utils"; diff --git a/packages/pixel/src/format/float-hsva.ts b/packages/pixel/src/format/float-hsva.ts index d394539510..3891e311ce 100644 --- a/packages/pixel/src/format/float-hsva.ts +++ b/packages/pixel/src/format/float-hsva.ts @@ -1,4 +1,5 @@ -import { clamp01, EPS } from "@thi.ng/math"; +import { EPS } from "@thi.ng/math/api"; +import { clamp01 } from "@thi.ng/math/interval"; import { Lane } from "../api"; import { defFloatFormat } from "./float-format"; diff --git a/packages/pixel/src/format/float-norm.ts b/packages/pixel/src/format/float-norm.ts index 039b997219..42b9b9dfc8 100644 --- a/packages/pixel/src/format/float-norm.ts +++ b/packages/pixel/src/format/float-norm.ts @@ -1,4 +1,4 @@ -import { clamp } from "@thi.ng/math"; +import { clamp } from "@thi.ng/math/interval"; import { FloatFormat, Lane } from "../api"; const from = (x: number) => x / 127.5 - 1; diff --git a/packages/pixel/src/format/indexed.ts b/packages/pixel/src/format/indexed.ts index 4da5ce81c2..ac13649003 100644 --- a/packages/pixel/src/format/indexed.ts +++ b/packages/pixel/src/format/indexed.ts @@ -1,5 +1,6 @@ -import { assert, NumericArray } from "@thi.ng/api"; -import { swapLane13 } from "@thi.ng/binary"; +import type { NumericArray } from "@thi.ng/api"; +import { assert } from "@thi.ng/api/assert"; +import { swapLane13 } from "@thi.ng/binary/swizzle"; import { Lane } from "../api"; import { defPackedFormat } from "./packed-format"; diff --git a/packages/pixel/src/format/packed-format.ts b/packages/pixel/src/format/packed-format.ts index c02d4b00b1..9db3896286 100644 --- a/packages/pixel/src/format/packed-format.ts +++ b/packages/pixel/src/format/packed-format.ts @@ -1,5 +1,6 @@ -import { assert, FnN, FnN2 } from "@thi.ng/api"; -import { clamp01 } from "@thi.ng/math"; +import type { FnN, FnN2 } from "@thi.ng/api"; +import { assert } from "@thi.ng/api/assert"; +import { clamp01 } from "@thi.ng/math/interval"; import type { PackedChannel, PackedChannelSpec, diff --git a/packages/pixel/src/packed.ts b/packages/pixel/src/packed.ts index d41ca5d851..3764cc5154 100644 --- a/packages/pixel/src/packed.ts +++ b/packages/pixel/src/packed.ts @@ -1,18 +1,17 @@ +import type { Fn2, ICopy, IEmpty } from "@thi.ng/api"; import { - assert, - Fn2, - ICopy, - IEmpty, typedArray, UIntArray, uintTypeForBits, -} from "@thi.ng/api"; -import { isNumber, isString } from "@thi.ng/checks"; +} from "@thi.ng/api/api/typedarray"; +import { assert } from "@thi.ng/api/assert"; +import { isNumber } from "@thi.ng/checks/is-number"; +import { isString } from "@thi.ng/checks/is-string"; import { isPremultipliedInt, postmultiplyInt, premultiplyInt, -} from "@thi.ng/porter-duff"; +} from "@thi.ng/porter-duff/premultiply"; import { BayerMatrix, BayerSize, @@ -87,7 +86,8 @@ export class PackedBuffer IBlit, IInvert, ICopy, - IEmpty { + IEmpty +{ /** * Creates a new pixel buffer from given HTML image element with optional * support for format conversion (default: {@link ABGR8888} & resizing. diff --git a/packages/pixel/src/pyramid.ts b/packages/pixel/src/pyramid.ts index 8fb99b10f4..e45b97512b 100644 --- a/packages/pixel/src/pyramid.ts +++ b/packages/pixel/src/pyramid.ts @@ -1,4 +1,4 @@ -import { assert } from "@thi.ng/api"; +import { assert } from "@thi.ng/api/assert"; import type { KernelSpec } from "./api"; import { convolveImage, LANCZOS } from "./convolve"; import type { FloatBuffer } from "./float"; diff --git a/packages/pixel/src/sample.ts b/packages/pixel/src/sample.ts index 11c116e116..4ed1e5484f 100644 --- a/packages/pixel/src/sample.ts +++ b/packages/pixel/src/sample.ts @@ -1,5 +1,8 @@ -import { assert, Fn, IObjectOf, NumericArray } from "@thi.ng/api"; -import { clamp, fract, mixBicubic, mixBilinear, mod } from "@thi.ng/math"; +import type { Fn, IObjectOf, NumericArray } from "@thi.ng/api"; +import { assert } from "@thi.ng/api/assert"; +import { clamp } from "@thi.ng/math/interval"; +import { mixBicubic, mixBilinear } from "@thi.ng/math/mix"; +import { fract, mod } from "@thi.ng/math/prec"; import type { Filter, FloatSampler, @@ -28,63 +31,64 @@ export function defSampler( const isFloat = !!(src.format).__float; const suffix = (src.format).channels.length === 1 ? "1" : ""; const id = `${filter[0]}${wrap[0]}${suffix}`; - const impl = (isFloat - ? >>{ - nc1: sampleFNC, - nw1: sampleFNW, - nr1: sampleFNR, - nc: sampleFNC, - nw: sampleFNW, - nr: sampleFNR, - lc1: (src) => bilinearGrayF(sampleINC(src)), - lw1: (src) => bilinearGrayF(sampleINW(src)), - lr1: (src) => bilinearGrayF(sampleINR(src)), - lc: (src) => bilinearFloat(src, sampleFNC(src)), - lw: (src) => bilinearFloat(src, sampleFNW(src)), - lr: (src) => bilinearFloat(src, sampleFNR(src)), - cc1: (src) => bicubicGrayF(sampleINC(src)), - cw1: (src) => bicubicGrayF(sampleINW(src)), - cr1: (src) => bicubicGrayF(sampleINR(src)), - cc: (src) => bicubicFloat(src, sampleFNC(src)), - cw: (src) => bicubicFloat(src, sampleFNW(src)), - cr: (src) => bicubicFloat(src, sampleFNR(src)), - } - : >>{ - nc1: sampleINC, - nw1: sampleINW, - nr1: sampleINR, - nc: sampleINC, - nw: sampleINW, - nr: sampleINR, - lc1: (src) => bilinearGray(sampleINC(src)), - lw1: (src) => bilinearGray(sampleINW(src)), - lr1: (src) => bilinearGray(sampleINR(src)), - lc: (src) => bilinearABGR(src, sampleINC(src)), - lw: (src) => bilinearABGR(src, sampleINW(src)), - lr: (src) => bilinearABGR(src, sampleINR(src)), - cc1: (src) => bicubicGrayI(src, sampleINC(src)), - cw1: (src) => bicubicGrayI(src, sampleINW(src)), - cr1: (src) => bicubicGrayI(src, sampleINR(src)), - cc: (src) => bicubicABGR(src, sampleINC(src)), - cw: (src) => bicubicABGR(src, sampleINW(src)), - cr: (src) => bicubicABGR(src, sampleINR(src)), - })[id]; + const impl = ( + isFloat + ? >>{ + nc1: sampleFNC, + nw1: sampleFNW, + nr1: sampleFNR, + nc: sampleFNC, + nw: sampleFNW, + nr: sampleFNR, + lc1: (src) => bilinearGrayF(sampleINC(src)), + lw1: (src) => bilinearGrayF(sampleINW(src)), + lr1: (src) => bilinearGrayF(sampleINR(src)), + lc: (src) => bilinearFloat(src, sampleFNC(src)), + lw: (src) => bilinearFloat(src, sampleFNW(src)), + lr: (src) => bilinearFloat(src, sampleFNR(src)), + cc1: (src) => bicubicGrayF(sampleINC(src)), + cw1: (src) => bicubicGrayF(sampleINW(src)), + cr1: (src) => bicubicGrayF(sampleINR(src)), + cc: (src) => bicubicFloat(src, sampleFNC(src)), + cw: (src) => bicubicFloat(src, sampleFNW(src)), + cr: (src) => bicubicFloat(src, sampleFNR(src)), + } + : >>{ + nc1: sampleINC, + nw1: sampleINW, + nr1: sampleINR, + nc: sampleINC, + nw: sampleINW, + nr: sampleINR, + lc1: (src) => bilinearGray(sampleINC(src)), + lw1: (src) => bilinearGray(sampleINW(src)), + lr1: (src) => bilinearGray(sampleINR(src)), + lc: (src) => bilinearABGR(src, sampleINC(src)), + lw: (src) => bilinearABGR(src, sampleINW(src)), + lr: (src) => bilinearABGR(src, sampleINR(src)), + cc1: (src) => bicubicGrayI(src, sampleINC(src)), + cw1: (src) => bicubicGrayI(src, sampleINW(src)), + cr1: (src) => bicubicGrayI(src, sampleINR(src)), + cc: (src) => bicubicABGR(src, sampleINC(src)), + cw: (src) => bicubicABGR(src, sampleINW(src)), + cr: (src) => bicubicABGR(src, sampleINR(src)), + } + )[id]; assert(!!impl, `missing impl for ${id}`); return impl(src); } -const sampleINC = ({ pixels, width, height }: IPixelBuffer): IntSampler => ( - x, - y -) => - x >= 0 && x < width && y >= 0 && y < height - ? pixels[(y | 0) * width + (x | 0)] - : 0; +const sampleINC = + ({ pixels, width, height }: IPixelBuffer): IntSampler => + (x, y) => + x >= 0 && x < width && y >= 0 && y < height + ? pixels[(y | 0) * width + (x | 0)] + : 0; -const sampleINW = ({ pixels, width, height }: IPixelBuffer): IntSampler => ( - x, - y -) => pixels[mod(y | 0, height) * width + mod(x | 0, width)]; +const sampleINW = + ({ pixels, width, height }: IPixelBuffer): IntSampler => + (x, y) => + pixels[mod(y | 0, height) * width + mod(x | 0, width)]; const sampleINR = ({ pixels, width, height }: IPixelBuffer): IntSampler => { const w1 = width - 1; @@ -92,30 +96,22 @@ const sampleINR = ({ pixels, width, height }: IPixelBuffer): IntSampler => { return (x, y) => pixels[clamp(y | 0, 0, h1) * width + clamp(x | 0, 0, w1)]; }; -const sampleFNC = ({ - pixels, - width, - height, - rowStride, - stride, -}: FloatBuffer): FloatSampler => (x, y) => { - let i: number; - return x >= 0 && x < width && y >= 0 && y < height - ? ((i = (y | 0) * rowStride + (x | 0) * stride), - pixels.slice(i, i + stride)) - : [0]; -}; +const sampleFNC = + ({ pixels, width, height, rowStride, stride }: FloatBuffer): FloatSampler => + (x, y) => { + let i: number; + return x >= 0 && x < width && y >= 0 && y < height + ? ((i = (y | 0) * rowStride + (x | 0) * stride), + pixels.slice(i, i + stride)) + : [0]; + }; -const sampleFNW = ({ - pixels, - width, - height, - rowStride, - stride, -}: FloatBuffer): FloatSampler => (x, y) => { - let i = mod(y | 0, height) * rowStride + mod(x | 0, width) * stride; - return pixels.slice(i, i + stride); -}; +const sampleFNW = + ({ pixels, width, height, rowStride, stride }: FloatBuffer): FloatSampler => + (x, y) => { + let i = mod(y | 0, height) * rowStride + mod(x | 0, width) * stride; + return pixels.slice(i, i + stride); + }; const sampleFNR = ({ pixels, @@ -140,18 +136,20 @@ const mixBilinearChan = ( s = 4 ) => mixBilinear(buf[i], buf[i + s], buf[i + 2 * s], buf[i + 3 * s], u, v); -const bilinearGray = (sample: IntSampler): IntSampler => (x, y) => { - x -= 0.5; - y -= 0.5; - return mixBilinear( - sample(x, y), - sample(x + 1, y), - sample(x, y + 1), - sample(x + 1, y + 1), - fract(x), - fract(y) - ); -}; +const bilinearGray = + (sample: IntSampler): IntSampler => + (x, y) => { + x -= 0.5; + y -= 0.5; + return mixBilinear( + sample(x, y), + sample(x + 1, y), + sample(x, y + 1), + sample(x + 1, y + 1), + fract(x), + fract(y) + ); + }; const bilinearGrayF = (sample: IntSampler): FloatSampler => { sample = bilinearGray(sample); @@ -204,36 +202,38 @@ const bilinearFloat = ( }; }; -const bicubicGray = (sample: IntSampler): IntSampler => (x, y) => { - x -= 0.5; - y -= 0.5; - const x1 = x - 1; - const x2 = x + 1; - const x3 = x + 2; - const y1 = y - 1; - const y2 = y + 1; - const y3 = y + 2; - return mixBicubic( - sample(x1, y1), - sample(x, y1), - sample(x2, y1), - sample(x3, y1), - sample(x1, y), - sample(x, y), - sample(x2, y), - sample(x3, y), - sample(x1, y2), - sample(x, y2), - sample(x2, y2), - sample(x3, y2), - sample(x1, y3), - sample(x, y3), - sample(x2, y3), - sample(x3, y3), - fract(x), - fract(y) - ); -}; +const bicubicGray = + (sample: IntSampler): IntSampler => + (x, y) => { + x -= 0.5; + y -= 0.5; + const x1 = x - 1; + const x2 = x + 1; + const x3 = x + 2; + const y1 = y - 1; + const y2 = y + 1; + const y3 = y + 2; + return mixBicubic( + sample(x1, y1), + sample(x, y1), + sample(x2, y1), + sample(x3, y1), + sample(x1, y), + sample(x, y), + sample(x2, y), + sample(x3, y), + sample(x1, y2), + sample(x, y2), + sample(x2, y2), + sample(x3, y2), + sample(x1, y3), + sample(x, y3), + sample(x2, y3), + sample(x3, y3), + fract(x), + fract(y) + ); + }; const bicubicGrayI = (src: PackedBuffer, sample: IntSampler): IntSampler => { const max = src.format.channels[0].mask0; diff --git a/packages/pixel/src/utils.ts b/packages/pixel/src/utils.ts index 5320e23298..3e75600b95 100644 --- a/packages/pixel/src/utils.ts +++ b/packages/pixel/src/utils.ts @@ -1,7 +1,8 @@ -import { assert, Fn, Fn2, FnN, TypedArray, UIntArray } from "@thi.ng/api"; -import { isNumber } from "@thi.ng/checks"; -import { clamp } from "@thi.ng/math"; -import type { BlitOpts, PackedFormat, FloatFormat } from "./api"; +import type { Fn, Fn2, FnN, TypedArray, UIntArray } from "@thi.ng/api"; +import { assert } from "@thi.ng/api/assert"; +import { isNumber } from "@thi.ng/checks/is-number"; +import { clamp } from "@thi.ng/math/interval"; +import type { BlitOpts, FloatFormat, PackedFormat } from "./api"; /** @internal */ export const ensureSize = ( diff --git a/packages/pointfree-lang/src/index.ts b/packages/pointfree-lang/src/index.ts index 77cbab28fc..1e70f3992d 100644 --- a/packages/pointfree-lang/src/index.ts +++ b/packages/pointfree-lang/src/index.ts @@ -1,5 +1,7 @@ -import { Fn, Fn2, FnU, ILogger, IObjectOf, NULL_LOGGER } from "@thi.ng/api"; -import { illegalArgs, illegalState } from "@thi.ng/errors"; +import type { Fn, Fn2, FnU, ILogger, IObjectOf } from "@thi.ng/api"; +import { NULL_LOGGER } from "@thi.ng/api/logger"; +import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; +import { illegalState } from "@thi.ng/errors/illegal-state"; import * as pf from "@thi.ng/pointfree"; import { ALIASES, ASTNode, VisitorState } from "./api"; import { parse, SyntaxError } from "./parser"; @@ -113,9 +115,10 @@ const resolveObject = (node: ASTNode, ctx: pf.StackContext) => { * * @param node - */ -const loadvar = (node: ASTNode) => (ctx: pf.StackContext) => ( - ctx[0].push(resolveVar(node, ctx)), ctx -); +const loadvar = (node: ASTNode) => (ctx: pf.StackContext) => { + ctx[0].push(resolveVar(node, ctx)); + return ctx; +}; /** * HOF word function. Pops TOS and stores value in current scope of @@ -142,16 +145,18 @@ const storevar = (id: string) => (ctx: pf.StackContext) => { * * @param id - */ -const beginvar = (id: string): FnU => (ctx) => { - pf.ensureStack(ctx[0], 1); - const v = ctx[2].__vars[id]; - if (v === undefined) { - ctx[2].__vars[id] = [ctx[0].pop()]; - } else { - v.unshift(ctx[0].pop()); - } - return ctx; -}; +const beginvar = + (id: string): FnU => + (ctx) => { + pf.ensureStack(ctx[0], 1); + const v = ctx[2].__vars[id]; + if (v === undefined) { + ctx[2].__vars[id] = [ctx[0].pop()]; + } else { + v.unshift(ctx[0].pop()); + } + return ctx; + }; /** * HOF word function used by {@link visitWord} to end local variables. Removes @@ -161,17 +166,19 @@ const beginvar = (id: string): FnU => (ctx) => { * * @param id - */ -const endvar = (id: string): FnU => (ctx) => { - const v = ctx[2].__vars[id]; - if (v === undefined || v.length === 0) { - illegalState(`can't end scope for var: ${id}`); - } - v.shift(); - if (!v.length) { - delete ctx[2].__vars[id]; - } - return ctx; -}; +const endvar = + (id: string): FnU => + (ctx) => { + const v = ctx[2].__vars[id]; + if (v === undefined || v.length === 0) { + illegalState(`can't end scope for var: ${id}`); + } + v.shift(); + if (!v.length) { + delete ctx[2].__vars[id]; + } + return ctx; + }; /** * Main AST node visitor dispatcher. @@ -324,20 +331,18 @@ const visitStackComment = (node: ASTNode, state: VisitorState) => { } }; -const visitWithResolver = (resolve: Fn2) => ( - node: ASTNode, - ctx: pf.StackContext, - state: VisitorState -) => ( - ctx[0].push( - state.word - ? (_ctx: pf.StackContext) => ( - _ctx[0].push(resolve(node, _ctx)), _ctx - ) - : resolve(node, ctx) - ), - ctx -); +const visitWithResolver = + (resolve: Fn2) => + (node: ASTNode, ctx: pf.StackContext, state: VisitorState) => { + ctx[0].push( + state.word + ? (_ctx: pf.StackContext) => ( + _ctx[0].push(resolve(node, _ctx)), _ctx + ) + : resolve(node, ctx) + ); + return ctx; + }; /** * ARRAY visitor for arrays/quotations. If `state.word` is true, pushes diff --git a/packages/pointfree/src/array.ts b/packages/pointfree/src/array.ts index 2472849b78..2656842548 100644 --- a/packages/pointfree/src/array.ts +++ b/packages/pointfree/src/array.ts @@ -1,5 +1,7 @@ -import { isArray, isPlainObject } from "@thi.ng/checks"; -import { illegalArgs, illegalState } from "@thi.ng/errors"; +import { isArray } from "@thi.ng/checks/is-array"; +import { isPlainObject } from "@thi.ng/checks/is-plain-object"; +import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; +import { illegalState } from "@thi.ng/errors/illegal-state"; import type { StackContext, StackFn } from "./api"; import { defOp1, defOp2, defOp2v } from "./ops"; import { $, $n } from "./safe"; diff --git a/packages/pointfree/src/cond.ts b/packages/pointfree/src/cond.ts index f2726a7711..1caed2495b 100644 --- a/packages/pointfree/src/cond.ts +++ b/packages/pointfree/src/cond.ts @@ -1,5 +1,5 @@ import type { IObjectOf } from "@thi.ng/api"; -import { illegalState } from "@thi.ng/errors"; +import { illegalState } from "@thi.ng/errors/illegal-state"; import type { StackContext, StackProc } from "./api"; import { $ } from "./safe"; import { nop } from "./stack"; @@ -20,9 +20,12 @@ import { $stackFn } from "./word"; * @param _then - * @param _else - */ -export const defCond = (_then: StackProc, _else: StackProc = nop) => ( - ctx: StackContext -) => ($(ctx[0], 1), $stackFn(ctx[0].pop() ? _then : _else)(ctx)); +export const defCond = + (_then: StackProc, _else: StackProc = nop) => + (ctx: StackContext) => { + $(ctx[0], 1); + return $stackFn(ctx[0].pop() ? _then : _else)(ctx); + }; /** * Non-HOF version of {@link cond}, expects `test` result and both branches on @@ -68,22 +71,21 @@ export const whenq = (ctx: StackContext) => { * * @param cases - */ -export const defCases = (cases: IObjectOf) => ( - ctx: StackContext -) => { - $(ctx[0], 1); - const stack = ctx[0]; - const tos = stack.pop(); - const cas = cases[tos]; - if (cas !== undefined) { - return $stackFn(cas)(ctx); - } - if (cases.default) { - stack.push(tos); - return $stackFn(cases.default)(ctx); - } - return illegalState(`no matching case for: ${tos}`); -}; +export const defCases = + (cases: IObjectOf) => (ctx: StackContext) => { + $(ctx[0], 1); + const stack = ctx[0]; + const tos = stack.pop(); + const cas = cases[tos]; + if (cas !== undefined) { + return $stackFn(cas)(ctx); + } + if (cases.default) { + stack.push(tos); + return $stackFn(cases.default)(ctx); + } + return illegalState(`no matching case for: ${tos}`); + }; export const casesq = (ctx: StackContext) => { const stack = ctx[0]; diff --git a/packages/pointfree/src/env.ts b/packages/pointfree/src/env.ts index d00ef367a1..52fd3f6114 100644 --- a/packages/pointfree/src/env.ts +++ b/packages/pointfree/src/env.ts @@ -1,4 +1,4 @@ -import { illegalArgs } from "@thi.ng/errors"; +import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; import type { StackContext } from "./api"; import { $ } from "./safe"; @@ -70,6 +70,8 @@ export const defLoadKey = (key: PropertyKey) => (ctx: StackContext) => { * @param ctx - * @param env - */ -export const defStoreKey = (key: PropertyKey) => (ctx: StackContext) => ( - $(ctx[0], 1), (ctx[2][key] = ctx[0].pop()), ctx -); +export const defStoreKey = (key: PropertyKey) => (ctx: StackContext) => { + $(ctx[0], 1); + ctx[2][key] = ctx[0].pop(); + return ctx; +}; diff --git a/packages/pointfree/src/ops.ts b/packages/pointfree/src/ops.ts index 5b52991f74..9841d874f4 100644 --- a/packages/pointfree/src/ops.ts +++ b/packages/pointfree/src/ops.ts @@ -1,6 +1,6 @@ import type { Fn, Fn2 } from "@thi.ng/api"; -import { isArray } from "@thi.ng/checks"; -import { illegalArgs } from "@thi.ng/errors"; +import { isArray } from "@thi.ng/checks/is-array"; +import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; import type { StackContext } from "./api"; import { $, $n } from "./safe"; @@ -50,26 +50,26 @@ export const defOp2 = (op: Fn2) => (ctx: StackContext) => { * * @param f - */ -export const defOp2v = (f: Fn2) => ( - ctx: StackContext -): StackContext => { - $(ctx[0], 2); - const stack = ctx[0]; - const b = stack.pop(); - const n = stack.length - 1; - const a = stack[n]; - const isa = isArray(a); - const isb = isArray(b); - stack[n] = - isa && isb - ? op2vAB(f, a, b) - : isb && !isa - ? op2vB(f, a, b) - : isa && !isb - ? op2vA(f, a, b) - : illegalArgs("at least one arg must be an array"); - return ctx; -}; +export const defOp2v = + (f: Fn2) => + (ctx: StackContext): StackContext => { + $(ctx[0], 2); + const stack = ctx[0]; + const b = stack.pop(); + const n = stack.length - 1; + const a = stack[n]; + const isa = isArray(a); + const isb = isArray(b); + stack[n] = + isa && isb + ? op2vAB(f, a, b) + : isb && !isa + ? op2vB(f, a, b) + : isa && !isb + ? op2vA(f, a, b) + : illegalArgs("at least one arg must be an array"); + return ctx; + }; const op2vAB = (f: Fn2, a: any, b: any) => { const res = new Array(Math.min(a.length, b.length)); diff --git a/packages/pointfree/src/run.ts b/packages/pointfree/src/run.ts index c1e0e06d84..64e360d594 100644 --- a/packages/pointfree/src/run.ts +++ b/packages/pointfree/src/run.ts @@ -1,6 +1,7 @@ -import { isArray, isFunction } from "@thi.ng/checks"; -import { unwrap } from "./word"; +import { isArray } from "@thi.ng/checks/is-array"; +import { isFunction } from "@thi.ng/checks/is-function"; import type { StackContext, StackProc } from "./api"; +import { unwrap } from "./word"; /** * Executes program / quotation with given stack context (initial D/R diff --git a/packages/pointfree/src/safe.ts b/packages/pointfree/src/safe.ts index 577bbdb401..f183448052 100644 --- a/packages/pointfree/src/safe.ts +++ b/packages/pointfree/src/safe.ts @@ -1,5 +1,6 @@ -import { Fn2, NO_OP } from "@thi.ng/api"; -import { illegalState } from "@thi.ng/errors"; +import type { Fn2 } from "@thi.ng/api"; +import { NO_OP } from "@thi.ng/api/constants"; +import { illegalState } from "@thi.ng/errors/illegal-state"; import type { Stack } from "./api"; // ensure stack size diff --git a/packages/pointfree/src/word.ts b/packages/pointfree/src/word.ts index ffd1201789..30e28caaaf 100644 --- a/packages/pointfree/src/word.ts +++ b/packages/pointfree/src/word.ts @@ -1,5 +1,6 @@ -import { isArray, isFunction } from "@thi.ng/checks"; -import { compL } from "@thi.ng/compose"; +import { isArray } from "@thi.ng/checks/is-array"; +import { isFunction } from "@thi.ng/checks/is-function"; +import { compL } from "@thi.ng/compose/comp"; import type { StackContext, StackEnv, diff --git a/packages/poisson/src/poisson.ts b/packages/poisson/src/poisson.ts index cf51a7a01e..569f463b02 100644 --- a/packages/poisson/src/poisson.ts +++ b/packages/poisson/src/poisson.ts @@ -1,6 +1,7 @@ -import { isNumber } from "@thi.ng/checks"; -import { SYSTEM } from "@thi.ng/random"; -import { jitter as _jitter, Vec } from "@thi.ng/vectors"; +import { isNumber } from "@thi.ng/checks/is-number"; +import { SYSTEM } from "@thi.ng/random/system"; +import type { Vec } from "@thi.ng/vectors"; +import { jitter as _jitter } from "@thi.ng/vectors/jitter"; import type { PoissonOpts } from "./api"; /** diff --git a/packages/poisson/src/stratified.ts b/packages/poisson/src/stratified.ts index fd344e276e..baac03b78b 100644 --- a/packages/poisson/src/stratified.ts +++ b/packages/poisson/src/stratified.ts @@ -1,6 +1,9 @@ -import { SYSTEM } from "@thi.ng/random"; -import { mapcat, rangeNd, repeatedly } from "@thi.ng/transducers"; -import { add, random } from "@thi.ng/vectors"; +import { SYSTEM } from "@thi.ng/random/system"; +import { rangeNd } from "@thi.ng/transducers/iter/range-nd"; +import { repeatedly } from "@thi.ng/transducers/iter/repeatedly"; +import { mapcat } from "@thi.ng/transducers/xform/mapcat"; +import { add } from "@thi.ng/vectors/add"; +import { random } from "@thi.ng/vectors/random"; import type { StratifiedGridOpts } from "./api"; /** diff --git a/packages/porter-duff/src/porter-duff.ts b/packages/porter-duff/src/porter-duff.ts index bbe8b72596..80b13629d2 100644 --- a/packages/porter-duff/src/porter-duff.ts +++ b/packages/porter-duff/src/porter-duff.ts @@ -1,5 +1,5 @@ import type { Fn3, FnN2 } from "@thi.ng/api"; -import { clamp, clamp01 } from "@thi.ng/math"; +import { clamp, clamp01 } from "@thi.ng/math/interval"; import type { Color, ReadonlyColor } from "./api"; import { postmultiply, @@ -37,39 +37,47 @@ export const ONE_MINUS_B: FnN2 = (_, b) => 1 - b; * @param fa - fn for src coeff * @param fb - fn for dest coeff */ -export const porterDuff = (fa: FnN2, fb: FnN2) => ( - out: Color | null, - src: ReadonlyColor, - dest: ReadonlyColor -) => { - const sa = src[3]; - const sb = dest[3]; - const aa = fa(sa, sb); - const bb = fb(sa, sb); - return setC4( - out || dest, - src[0] * aa + dest[0] * bb, - src[1] * aa + dest[1] * bb, - src[2] * aa + dest[2] * bb, - clamp01(src[3] * aa + dest[3] * bb) - ); -}; - -export const porterDuffInt = (fa: FnN2, fb: FnN2): FnN2 => (a, b) => { - const sa = (a >>> 24) / 255; - const sb = (b >>> 24) / 255; - const aa = fa(sa, sb); - const bb = fb(sa, sb); - return ( - (clamp(((a >>> 24) & 0xff) * aa + ((b >>> 24) & 0xff) * bb, 0, 255) << - 24) | - (clamp(((a >>> 16) & 0xff) * aa + ((b >>> 16) & 0xff) * bb, 0, 255) << - 16) | - (clamp(((a >>> 8) & 0xff) * aa + ((b >>> 8) & 0xff) * bb, 0, 255) << - 8) | - clamp((a & 0xff) * aa + (b & 0xff) * bb, 0, 255) - ); -}; +export const porterDuff = + (fa: FnN2, fb: FnN2) => + (out: Color | null, src: ReadonlyColor, dest: ReadonlyColor) => { + const sa = src[3]; + const sb = dest[3]; + const aa = fa(sa, sb); + const bb = fb(sa, sb); + return setC4( + out || dest, + src[0] * aa + dest[0] * bb, + src[1] * aa + dest[1] * bb, + src[2] * aa + dest[2] * bb, + clamp01(src[3] * aa + dest[3] * bb) + ); + }; + +export const porterDuffInt = + (fa: FnN2, fb: FnN2): FnN2 => + (a, b) => { + const sa = (a >>> 24) / 255; + const sb = (b >>> 24) / 255; + const aa = fa(sa, sb); + const bb = fb(sa, sb); + return ( + (clamp( + ((a >>> 24) & 0xff) * aa + ((b >>> 24) & 0xff) * bb, + 0, + 255 + ) << + 24) | + (clamp( + ((a >>> 16) & 0xff) * aa + ((b >>> 16) & 0xff) * bb, + 0, + 255 + ) << + 16) | + (clamp(((a >>> 8) & 0xff) * aa + ((b >>> 8) & 0xff) * bb, 0, 255) << + 8) | + clamp((a & 0xff) * aa + (b & 0xff) * bb, 0, 255) + ); + }; /** * Higher order function. Takes existing PD operator and returns @@ -79,21 +87,23 @@ export const porterDuffInt = (fa: FnN2, fb: FnN2): FnN2 => (a, b) => { * * @param mode - */ -export const porterDuffP = ( - mode: Fn3 -) => (out: Color, src: ReadonlyColor, dest: ReadonlyColor) => - postmultiply( - null, - mode(null, premultiply([], src), premultiply(out, dest)) - ); +export const porterDuffP = + (mode: Fn3) => + (out: Color, src: ReadonlyColor, dest: ReadonlyColor) => + postmultiply( + null, + mode(null, premultiply([], src), premultiply(out, dest)) + ); /** * Like {@link porterDuffP}, but for packed integers. * * @param mode - */ -export const porterDuffPInt = (mode: FnN2): FnN2 => (src, dest) => - postmultiplyInt(mode(premultiplyInt(src), premultiplyInt(dest))); +export const porterDuffPInt = + (mode: FnN2): FnN2 => + (src, dest) => + postmultiplyInt(mode(premultiplyInt(src), premultiplyInt(dest))); /** * Porter-Duff operator. None of the terms are used. Always results in diff --git a/packages/ramp/src/aramp.ts b/packages/ramp/src/aramp.ts index 6619f049c0..7d64862cd3 100644 --- a/packages/ramp/src/aramp.ts +++ b/packages/ramp/src/aramp.ts @@ -1,7 +1,9 @@ -import { binarySearch } from "@thi.ng/arrays"; -import { compareNumAsc } from "@thi.ng/compare"; -import { absDiff, clamp } from "@thi.ng/math"; -import { comparator2, ReadonlyVec, Vec } from "@thi.ng/vectors"; +import { binarySearch } from "@thi.ng/arrays/binary-search"; +import { compareNumAsc } from "@thi.ng/compare/numeric"; +import { absDiff } from "@thi.ng/math/abs"; +import { clamp } from "@thi.ng/math/interval"; +import type { ReadonlyVec, Vec } from "@thi.ng/vectors"; +import { comparator2 } from "@thi.ng/vectors/compare"; import type { IRamp, RampBounds } from "./api"; export abstract class ARamp implements IRamp { diff --git a/packages/ramp/src/hermite.ts b/packages/ramp/src/hermite.ts index db6bf35459..40293c45f0 100644 --- a/packages/ramp/src/hermite.ts +++ b/packages/ramp/src/hermite.ts @@ -1,13 +1,12 @@ -import { mix, mixCubicHermite, norm, tangentCardinal } from "@thi.ng/math"; -import { - comp, - extendSides, - iterator, - map, - mapcat, - normRange, - partition, -} from "@thi.ng/transducers"; +import { norm } from "@thi.ng/math/fit"; +import { mix, mixCubicHermite, tangentCardinal } from "@thi.ng/math/mix"; +import { comp } from "@thi.ng/transducers/func/comp"; +import { extendSides } from "@thi.ng/transducers/iter/extend-sides"; +import { normRange } from "@thi.ng/transducers/iter/norm-range"; +import { iterator } from "@thi.ng/transducers/iterator"; +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 type { Vec } from "@thi.ng/vectors"; import { ARamp } from "./aramp"; diff --git a/packages/ramp/src/linear.ts b/packages/ramp/src/linear.ts index cea0cad3de..dd6bcb6b44 100644 --- a/packages/ramp/src/linear.ts +++ b/packages/ramp/src/linear.ts @@ -1,4 +1,4 @@ -import { fit } from "@thi.ng/math"; +import { fit } from "@thi.ng/math/fit"; import type { Vec } from "@thi.ng/vectors"; import { ARamp } from "./aramp"; diff --git a/packages/random/src/random-bytes.ts b/packages/random/src/random-bytes.ts index fea9e15060..372577e0f6 100644 --- a/packages/random/src/random-bytes.ts +++ b/packages/random/src/random-bytes.ts @@ -1,4 +1,4 @@ -import { hasCrypto } from "@thi.ng/checks"; +import { hasCrypto } from "@thi.ng/checks/has-crypto"; import type { IRandom } from "./api"; import { SYSTEM } from "./system"; diff --git a/packages/random/src/unique-indices.ts b/packages/random/src/unique-indices.ts index a640895d85..d25fbf8d56 100644 --- a/packages/random/src/unique-indices.ts +++ b/packages/random/src/unique-indices.ts @@ -1,4 +1,5 @@ -import { assert, Fn0 } from "@thi.ng/api"; +import type { Fn0 } from "@thi.ng/api"; +import { assert } from "@thi.ng/api/assert"; import type { IRandom } from "./api"; import { SYSTEM } from "./system"; diff --git a/packages/random/src/weighted-random.ts b/packages/random/src/weighted-random.ts index d33b71e89e..7f1f06eb55 100644 --- a/packages/random/src/weighted-random.ts +++ b/packages/random/src/weighted-random.ts @@ -1,4 +1,4 @@ -import { assert } from "@thi.ng/api"; +import { assert } from "@thi.ng/api/assert"; import type { IRandom } from "./api"; import { SYSTEM } from "./system"; diff --git a/packages/range-coder/src/index.ts b/packages/range-coder/src/index.ts index 1220604845..927faee994 100644 --- a/packages/range-coder/src/index.ts +++ b/packages/range-coder/src/index.ts @@ -1,4 +1,5 @@ -import { BitInputStream, BitOutputStream } from "@thi.ng/bitstream"; +import { BitInputStream } from "@thi.ng/bitstream/input"; +import { BitOutputStream } from "@thi.ng/bitstream/output"; const HIGH = 0x7fffff; const HALF = 0x400000; diff --git a/packages/rdom-canvas/src/index.ts b/packages/rdom-canvas/src/index.ts index 9b27740ebc..1b7d6c5281 100644 --- a/packages/rdom-canvas/src/index.ts +++ b/packages/rdom-canvas/src/index.ts @@ -1,17 +1,14 @@ import { adaptDPI } from "@thi.ng/adapt-dpi"; import type { IToHiccup } from "@thi.ng/api"; -import { implementsFunction } from "@thi.ng/checks"; -import { draw } from "@thi.ng/hiccup-canvas"; -import { - $sub, - Component, - IComponent, - IMountWithState, - isSubscribable, - NumOrElement, -} from "@thi.ng/rdom"; -import { ISubscription, reactive } from "@thi.ng/rstream"; -import { sideEffect } from "@thi.ng/transducers"; +import { implementsFunction } from "@thi.ng/checks/implements-function"; +import { draw } from "@thi.ng/hiccup-canvas/draw"; +import type { IComponent, IMountWithState, NumOrElement } from "@thi.ng/rdom"; +import { Component } from "@thi.ng/rdom/component"; +import { $sub } from "@thi.ng/rdom/sub"; +import type { ISubscription } from "@thi.ng/rstream"; +import { isSubscribable } from "@thi.ng/rstream/checks"; +import { reactive } from "@thi.ng/rstream/stream"; +import { sideEffect } from "@thi.ng/transducers/xform/side-effect"; /** * Reactive {@link @thi.ng/hiccup-canvas} component wrapper. Returns a @@ -32,7 +29,8 @@ export const $canvas = ( export class $Canvas extends Component - implements IMountWithState { + implements IMountWithState +{ el?: HTMLCanvasElement; ctx?: CanvasRenderingContext2D; inner?: IComponent; diff --git a/packages/rdom-components/src/accordion.ts b/packages/rdom-components/src/accordion.ts index 028bb87889..79d3e87811 100644 --- a/packages/rdom-components/src/accordion.ts +++ b/packages/rdom-components/src/accordion.ts @@ -1,8 +1,14 @@ import type { Fn, Fn4 } from "@thi.ng/api"; -import { Attribs, div, section } from "@thi.ng/hiccup-html"; -import { $list, $promise, ComponentLike } from "@thi.ng/rdom"; +import type { Attribs } from "@thi.ng/hiccup-html"; +import { div } from "@thi.ng/hiccup-html/blocks"; +import { section } from "@thi.ng/hiccup-html/sections"; +import type { ComponentLike } from "@thi.ng/rdom"; +import { $list } from "@thi.ng/rdom/list"; +import { $promise } from "@thi.ng/rdom/promise"; import type { ISubscription } from "@thi.ng/rstream"; -import { dedupe, map, range } from "@thi.ng/transducers"; +import { range } from "@thi.ng/transducers/iter/range"; +import { dedupe } from "@thi.ng/transducers/xform/dedupe"; +import { map } from "@thi.ng/transducers/xform/map"; export interface AccordionOpts { attribs: { diff --git a/packages/rdom-components/src/dropdown.ts b/packages/rdom-components/src/dropdown.ts index c486631b00..77617ce513 100644 --- a/packages/rdom-components/src/dropdown.ts +++ b/packages/rdom-components/src/dropdown.ts @@ -1,6 +1,7 @@ import type { Fn } from "@thi.ng/api"; -import { option, select, SelectAttribs } from "@thi.ng/hiccup-html"; -import { $input, $list } from "@thi.ng/rdom"; +import { option, select, SelectAttribs } from "@thi.ng/hiccup-html/forms"; +import { $input } from "@thi.ng/rdom/event"; +import { $list } from "@thi.ng/rdom/list"; import type { ISubscribable, Subscription } from "@thi.ng/rstream"; export interface DropdownOpts { diff --git a/packages/rdom-components/src/editor.ts b/packages/rdom-components/src/editor.ts index 066bb302f0..322c236eb6 100644 --- a/packages/rdom-components/src/editor.ts +++ b/packages/rdom-components/src/editor.ts @@ -1,9 +1,13 @@ import type { Fn } from "@thi.ng/api"; -import { meldDeepObj } from "@thi.ng/associative"; -import { Attribs, div, textArea, TextAreaAttribs } from "@thi.ng/hiccup-html"; -import { $compile, IComponent } from "@thi.ng/rdom"; -import { reactive, Subscription } from "@thi.ng/rstream"; -import { computeCursorPos } from "@thi.ng/strings"; +import { meldDeepObj } from "@thi.ng/associative/merge-deep"; +import type { Attribs } from "@thi.ng/hiccup-html"; +import { div } from "@thi.ng/hiccup-html/blocks"; +import { textArea, TextAreaAttribs } from "@thi.ng/hiccup-html/forms"; +import type { IComponent } from "@thi.ng/rdom"; +import { $compile } from "@thi.ng/rdom/compile"; +import type { ISubscription } from "@thi.ng/rstream"; +import { reactive } from "@thi.ng/rstream/stream"; +import { computeCursorPos } from "@thi.ng/strings/cursor"; export interface EditorOpts { /** @@ -30,7 +34,7 @@ export interface EditorOpts { } export const editor = ( - src: Subscription, + src: ISubscription, opts: Partial = {} ) => { opts = meldDeepObj( diff --git a/packages/rdom-components/src/icon-button.ts b/packages/rdom-components/src/icon-button.ts index b404dbae5b..bec5dc71cd 100644 --- a/packages/rdom-components/src/icon-button.ts +++ b/packages/rdom-components/src/icon-button.ts @@ -1,5 +1,6 @@ import type { MaybeDeref } from "@thi.ng/api"; -import { button, i, InputAttribs } from "@thi.ng/hiccup-html"; +import { button, InputAttribs } from "@thi.ng/hiccup-html/forms"; +import { i } from "@thi.ng/hiccup-html/inline"; export interface IconButtonOpts { attribs: Partial; diff --git a/packages/rdom-components/src/input.ts b/packages/rdom-components/src/input.ts index 571baf10ed..0617150342 100644 --- a/packages/rdom-components/src/input.ts +++ b/packages/rdom-components/src/input.ts @@ -1,13 +1,11 @@ import type { NumericArray } from "@thi.ng/api"; -import { - Attribs, - div, - inputNumber, - InputNumericAttribs, -} from "@thi.ng/hiccup-html"; -import { $inputNum } from "@thi.ng/rdom"; +import type { Attribs } from "@thi.ng/hiccup-html"; +import { div } from "@thi.ng/hiccup-html/blocks"; +import { inputNumber, InputNumericAttribs } from "@thi.ng/hiccup-html/forms"; +import { $inputNum } from "@thi.ng/rdom/event"; import type { ISubscription } from "@thi.ng/rstream"; -import { pluck, repeatedly } from "@thi.ng/transducers"; +import { repeatedly } from "@thi.ng/transducers/iter/repeatedly"; +import { pluck } from "@thi.ng/transducers/xform/pluck"; export const inputNumeric = ( dest: ISubscription, diff --git a/packages/rdom-components/src/radio.ts b/packages/rdom-components/src/radio.ts index b59414bd06..1a2222fe8e 100644 --- a/packages/rdom-components/src/radio.ts +++ b/packages/rdom-components/src/radio.ts @@ -1,6 +1,8 @@ import type { Fn, Fn2 } from "@thi.ng/api"; -import { div, InputRadioAttribs, label, radio } from "@thi.ng/hiccup-html"; -import { $input, ComponentLike } from "@thi.ng/rdom"; +import { div } from "@thi.ng/hiccup-html/blocks"; +import { InputRadioAttribs, label, radio } from "@thi.ng/hiccup-html/forms"; +import type { ComponentLike } from "@thi.ng/rdom"; +import { $input } from "@thi.ng/rdom/event"; import type { ISubscription } from "@thi.ng/rstream"; export interface RadioOpts { diff --git a/packages/rdom-components/src/tabs.ts b/packages/rdom-components/src/tabs.ts index 6a63dcd116..d7731a71c0 100644 --- a/packages/rdom-components/src/tabs.ts +++ b/packages/rdom-components/src/tabs.ts @@ -1,8 +1,14 @@ import type { Fn, Fn4 } from "@thi.ng/api"; -import { Attribs, div, section } from "@thi.ng/hiccup-html"; -import { $list, $switch, ComponentLike } from "@thi.ng/rdom"; +import type { Attribs } from "@thi.ng/hiccup-html"; +import { div } from "@thi.ng/hiccup-html/blocks"; +import { section } from "@thi.ng/hiccup-html/sections"; +import type { ComponentLike } from "@thi.ng/rdom"; +import { $list } from "@thi.ng/rdom/list"; +import { $switch } from "@thi.ng/rdom/switch"; import type { ISubscription } from "@thi.ng/rstream"; -import { dedupe, map, range } from "@thi.ng/transducers"; +import { range } from "@thi.ng/transducers/iter/range"; +import { dedupe } from "@thi.ng/transducers/xform/dedupe"; +import { map } from "@thi.ng/transducers/xform/map"; export interface TabOpts { attribs?: Partial<{ diff --git a/packages/rdom/src/checks.ts b/packages/rdom/src/checks.ts new file mode 100644 index 0000000000..4d456de29f --- /dev/null +++ b/packages/rdom/src/checks.ts @@ -0,0 +1,5 @@ +import { implementsFunction } from "@thi.ng/checks/implements-function"; +import type { IComponent } from "./api"; + +export const isComponent = (x: any): x is IComponent => + implementsFunction(x, "mount"); diff --git a/packages/rdom/src/compile.ts b/packages/rdom/src/compile.ts index d6b3874770..7167812e16 100644 --- a/packages/rdom/src/compile.ts +++ b/packages/rdom/src/compile.ts @@ -1,10 +1,12 @@ import type { Fn2, NumOrString } from "@thi.ng/api"; -import { isArray, isPlainObject } from "@thi.ng/checks"; +import { isArray } from "@thi.ng/checks/is-array"; +import { isPlainObject } from "@thi.ng/checks/is-plain-object"; +import { isSubscribable } from "@thi.ng/rstream/checks"; import type { CompiledComponent, IComponent, NumOrElement } from "./api"; +import { isComponent } from "./checks"; import { $el, $remove, $tree } from "./dom"; import { SCHEDULER } from "./scheduler"; import { $sub, $SubA } from "./sub"; -import { isComponent, isSubscribable } from "./utils"; import { $wrapText } from "./wrap"; /** diff --git a/packages/rdom/src/dom.ts b/packages/rdom/src/dom.ts index 6eaabc3705..3e1fc56cb6 100644 --- a/packages/rdom/src/dom.ts +++ b/packages/rdom/src/dom.ts @@ -1,25 +1,24 @@ -import { assert, deref, IObjectOf, isDeref, MaybeDeref } from "@thi.ng/api"; -import { - implementsFunction, - isArray, - isFunction, - isNotStringAndIterable, - isNumber, - isString, -} from "@thi.ng/checks"; -import { unsupported } from "@thi.ng/errors"; +import type { IObjectOf } from "@thi.ng/api"; +import { deref, isDeref, MaybeDeref } from "@thi.ng/api/api/deref"; +import { assert } from "@thi.ng/api/assert"; +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 { isNotStringAndIterable } from "@thi.ng/checks/is-not-string-iterable"; +import { isNumber } from "@thi.ng/checks/is-number"; +import { isString } from "@thi.ng/checks/is-string"; +import { unsupported } from "@thi.ng/errors/unsupported"; import { ATTRIB_JOIN_DELIMS, - formatPrefixes, - mergeClasses, - mergeEmmetAttribs, NO_SPANS, RE_TAG, SVG_TAGS, -} from "@thi.ng/hiccup"; -import { XML_SVG, XML_XLINK, XML_XMLNS } from "@thi.ng/prefixes"; +} from "@thi.ng/hiccup/api"; +import { mergeClasses, mergeEmmetAttribs } from "@thi.ng/hiccup/attribs"; +import { formatPrefixes } from "@thi.ng/hiccup/prefix"; +import { XML_SVG, XML_XLINK, XML_XMLNS } from "@thi.ng/prefixes/xml"; import type { NumOrElement } from "./api"; -import { isComponent } from "./utils"; +import { isComponent } from "./checks"; /** * hdom-style DOM tree creation from hiccup format. Returns DOM element diff --git a/packages/rdom/src/event.ts b/packages/rdom/src/event.ts index 387d5d797a..1f6c38d84b 100644 --- a/packages/rdom/src/event.ts +++ b/packages/rdom/src/event.ts @@ -1,5 +1,5 @@ import type { ISubscriber } from "@thi.ng/rstream"; -import { maybeParseFloat } from "@thi.ng/strings"; +import { maybeParseFloat } from "@thi.ng/strings/parse"; /** * HOF DOM event listener to emit element's value on given stream. diff --git a/packages/rdom/src/index.ts b/packages/rdom/src/index.ts index a1540b551d..7a61b432c7 100644 --- a/packages/rdom/src/index.ts +++ b/packages/rdom/src/index.ts @@ -1,4 +1,5 @@ export * from "./api"; +export * from "./checks"; export * from "./compile"; export * from "./component"; export * from "./dom"; @@ -10,5 +11,4 @@ export * from "./promise"; export * from "./scheduler"; export * from "./sub"; export * from "./switch"; -export * from "./utils"; export * from "./wrap"; diff --git a/packages/rdom/src/object.ts b/packages/rdom/src/object.ts index 35fc84fb2a..771d9fa2cc 100644 --- a/packages/rdom/src/object.ts +++ b/packages/rdom/src/object.ts @@ -1,10 +1,6 @@ import type { Fn, Keys } from "@thi.ng/api"; -import { - fromObject, - ISubscribable, - StreamObj, - StreamObjOpts, -} from "@thi.ng/rstream"; +import type { ISubscribable, StreamObj, StreamObjOpts } from "@thi.ng/rstream"; +import { fromObject } from "@thi.ng/rstream/from/object"; import type { ComponentLike, IComponent, @@ -96,7 +92,8 @@ export const $subObject = >( export class $Object> extends Component - implements IMountWithState { + implements IMountWithState +{ protected obj: StreamObj; protected inner?: IComponent; diff --git a/packages/rdom/src/sub.ts b/packages/rdom/src/sub.ts index 608e02dc3f..33ca3be177 100644 --- a/packages/rdom/src/sub.ts +++ b/packages/rdom/src/sub.ts @@ -1,7 +1,9 @@ import type { Fn2, Path } from "@thi.ng/api"; -import { isString } from "@thi.ng/checks"; -import { defSetterUnsafe } from "@thi.ng/paths"; -import { ISubscribable, nextID, Subscription } from "@thi.ng/rstream"; +import { isString } from "@thi.ng/checks/is-string"; +import { defSetterUnsafe } from "@thi.ng/paths/setter"; +import type { ISubscribable } from "@thi.ng/rstream"; +import { Subscription } from "@thi.ng/rstream/subscription"; +import { nextID } from "@thi.ng/rstream/utils/idgen"; import type { IComponent, IMountWithState, NumOrElement } from "./api"; import { $attribs } from "./dom"; import { SCHEDULER } from "./scheduler"; diff --git a/packages/rdom/src/switch.ts b/packages/rdom/src/switch.ts index cd35ffd000..472ead4103 100644 --- a/packages/rdom/src/switch.ts +++ b/packages/rdom/src/switch.ts @@ -1,4 +1,5 @@ -import { assert, Fn, NumOrString } from "@thi.ng/api"; +import type { Fn, NumOrString } from "@thi.ng/api"; +import { assert } from "@thi.ng/api/assert"; import type { ISubscribable } from "@thi.ng/rstream"; import type { IComponent, IMountWithState, NumOrElement } from "./api"; import { $compile } from "./compile"; diff --git a/packages/rdom/src/utils.ts b/packages/rdom/src/utils.ts deleted file mode 100644 index 9d4cc678be..0000000000 --- a/packages/rdom/src/utils.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { implementsFunction } from "@thi.ng/checks"; -import type { ISubscribable } from "@thi.ng/rstream"; -import type { IComponent } from "./api"; - -export const isSubscribable = (x: any): x is ISubscribable => - implementsFunction(x, "subscribe"); - -export const isComponent = (x: any): x is IComponent => - implementsFunction(x, "mount"); diff --git a/packages/rdom/src/wrap.ts b/packages/rdom/src/wrap.ts index d625e454a7..19064b90a6 100644 --- a/packages/rdom/src/wrap.ts +++ b/packages/rdom/src/wrap.ts @@ -3,28 +3,26 @@ import type { IMountWithState, NumOrElement } from "./api"; import { $el, $html, $remove, $text } from "./dom"; import { SCHEDULER } from "./scheduler"; -const wrapper = (update: Fn2) => ( - tag: string, - attribs?: any, - body?: T -): IMountWithState => ({ - el: undefined, +const wrapper = + (update: Fn2) => + (tag: string, attribs?: any, body?: T): IMountWithState => ({ + el: undefined, - async mount(parent: Element, index: NumOrElement, state: T) { - this.el = $el(tag, attribs, null, parent, index); - update(this.el!, state != null ? state : body!); - return this.el; - }, + async mount(parent: Element, index: NumOrElement, state: T) { + this.el = $el(tag, attribs, null, parent, index); + update(this.el!, state != null ? state : body!); + return this.el; + }, - async unmount() { - $remove(this.el!); - this.el = undefined; - }, + async unmount() { + $remove(this.el!); + this.el = undefined; + }, - update(body: T) { - SCHEDULER.add(this, () => this.el && update(this.el!, body)); - }, -}); + update(body: T) { + SCHEDULER.add(this, () => this.el && update(this.el!, body)); + }, + }); /** * Returns a component wrapper for a single DOM element whose TEXT body can be diff --git a/packages/resolve-map/src/index.ts b/packages/resolve-map/src/index.ts index b1eab22a7f..d5d8884853 100644 --- a/packages/resolve-map/src/index.ts +++ b/packages/resolve-map/src/index.ts @@ -1,7 +1,13 @@ -import { NumOrString, SEMAPHORE } from "@thi.ng/api"; -import { isArray, isFunction, isPlainObject, isString } from "@thi.ng/checks"; -import { illegalArgs } from "@thi.ng/errors"; -import { exists, getInUnsafe, mutInUnsafe } from "@thi.ng/paths"; +import type { NumOrString } from "@thi.ng/api"; +import { SEMAPHORE } from "@thi.ng/api/constants"; +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 { getInUnsafe } from "@thi.ng/paths/get-in"; +import { mutInUnsafe } from "@thi.ng/paths/mut-in"; +import { exists } from "@thi.ng/paths/path"; const RE_ARGS = /^(function\s+\w+)?\s*\(\{([\w\s,:]+)\}/; diff --git a/packages/rle-pack/src/index.ts b/packages/rle-pack/src/index.ts index dc0eae14c9..483042ce75 100644 --- a/packages/rle-pack/src/index.ts +++ b/packages/rle-pack/src/index.ts @@ -1,5 +1,6 @@ -import { BitInputStream, BitOutputStream } from "@thi.ng/bitstream"; -import { illegalArgs } from "@thi.ng/errors"; +import { BitInputStream } from "@thi.ng/bitstream/input"; +import { BitOutputStream } from "@thi.ng/bitstream/output"; +import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; export type RLESizes = [number, number, number, number]; diff --git a/packages/router/src/basic.ts b/packages/router/src/basic.ts index 81e13b8af9..ec7ad01518 100644 --- a/packages/router/src/basic.ts +++ b/packages/router/src/basic.ts @@ -1,14 +1,10 @@ -import { - assert, - Event, - INotify, - INotifyMixin, - IObjectOf, - Listener, -} from "@thi.ng/api"; -import { isString } from "@thi.ng/checks"; +import type { Event, INotify, IObjectOf, Listener } from "@thi.ng/api"; +import { assert } from "@thi.ng/api/assert"; +import { INotifyMixin } from "@thi.ng/api/mixins/inotify"; +import { isString } from "@thi.ng/checks/is-string"; import { equiv } from "@thi.ng/equiv"; -import { illegalArgs, illegalArity } from "@thi.ng/errors"; +import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; +import { illegalArity } from "@thi.ng/errors/illegal-arity"; import type { Route, RouteMatch, diff --git a/packages/router/src/history.ts b/packages/router/src/history.ts index 670bff1910..6ac17486b6 100644 --- a/packages/router/src/history.ts +++ b/packages/router/src/history.ts @@ -1,7 +1,7 @@ import type { Fn } from "@thi.ng/api"; -import { isString } from "@thi.ng/checks"; +import { isString } from "@thi.ng/checks/is-string"; import { equiv } from "@thi.ng/equiv"; -import { illegalArity } from "@thi.ng/errors"; +import { illegalArity } from "@thi.ng/errors/illegal-arity"; import type { HTMLRouterConfig, RouteMatch, RouterConfig } from "./api"; import { BasicRouter } from "./basic"; diff --git a/packages/rstream-csp/src/from/channel.ts b/packages/rstream-csp/src/from/channel.ts index ea86aa2faf..5f15319a04 100644 --- a/packages/rstream-csp/src/from/channel.ts +++ b/packages/rstream-csp/src/from/channel.ts @@ -1,6 +1,7 @@ import type { Channel } from "@thi.ng/csp"; import type { CommonOpts } from "@thi.ng/rstream"; -import { LOGGER, Stream } from "@thi.ng/rstream"; +import { LOGGER } from "@thi.ng/rstream/api"; +import { Stream } from "@thi.ng/rstream/stream"; export interface FromChannelOpts extends CommonOpts { /** diff --git a/packages/rstream-dot/src/index.ts b/packages/rstream-dot/src/index.ts index 2e37b9a802..7550377d1b 100644 --- a/packages/rstream-dot/src/index.ts +++ b/packages/rstream-dot/src/index.ts @@ -1,11 +1,9 @@ -import { - ISubscribable, - Stream, - StreamMerge, - StreamSync, -} from "@thi.ng/rstream"; -import { truncate } from "@thi.ng/strings"; -import { map } from "@thi.ng/transducers"; +import type { ISubscribable } from "@thi.ng/rstream"; +import { Stream } from "@thi.ng/rstream/stream"; +import { StreamMerge } from "@thi.ng/rstream/stream-merge"; +import { StreamSync } from "@thi.ng/rstream/stream-sync"; +import { truncate } from "@thi.ng/strings/truncate"; +import { map } from "@thi.ng/transducers/xform/map"; import type { DotOpts, Node, NodeType, WalkState } from "./api"; export * from "./api"; diff --git a/packages/rstream-gestures/src/gesture-stream.ts b/packages/rstream-gestures/src/gesture-stream.ts index d287acc669..bec2656140 100644 --- a/packages/rstream-gestures/src/gesture-stream.ts +++ b/packages/rstream-gestures/src/gesture-stream.ts @@ -1,8 +1,10 @@ import type { IObjectOf } from "@thi.ng/api"; -import { isBoolean } from "@thi.ng/checks"; -import { clamp } from "@thi.ng/math"; -import { fromDOMEvent, merge, Stream } from "@thi.ng/rstream"; -import { map } from "@thi.ng/transducers"; +import { isBoolean } from "@thi.ng/checks/is-boolean"; +import { clamp } from "@thi.ng/math/interval"; +import type { Stream } from "@thi.ng/rstream"; +import { fromDOMEvent } from "@thi.ng/rstream/from/event"; +import { merge } from "@thi.ng/rstream/stream-merge"; +import { map } from "@thi.ng/transducers/xform/map"; import type { GestureEvent, GestureInfo, diff --git a/packages/rstream-graph/src/graph.ts b/packages/rstream-graph/src/graph.ts index 7d713bf1f9..388ad566fb 100644 --- a/packages/rstream-graph/src/graph.ts +++ b/packages/rstream-graph/src/graph.ts @@ -1,18 +1,17 @@ import type { IObjectOf, Path, Tuple } from "@thi.ng/api"; import type { IAtom } from "@thi.ng/atom"; -import { isFunction, isPlainObject, isString } from "@thi.ng/checks"; -import { illegalArgs } from "@thi.ng/errors"; -import { getInUnsafe } from "@thi.ng/paths"; +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 { getInUnsafe } from "@thi.ng/paths/get-in"; import { absPath, resolve, ResolveFn } from "@thi.ng/resolve-map"; -import { - CloseMode, - fromIterableSync, - fromViewUnsafe, - ISubscription, - StreamSync, - sync, -} from "@thi.ng/rstream"; -import { map, Transducer } from "@thi.ng/transducers"; +import { CloseMode, ISubscription } from "@thi.ng/rstream/api"; +import { fromIterableSync } from "@thi.ng/rstream/from/iterable"; +import { fromViewUnsafe } from "@thi.ng/rstream/from/view"; +import { StreamSync, sync } from "@thi.ng/rstream/stream-sync"; +import type { Transducer } from "@thi.ng/transducers"; +import { map } from "@thi.ng/transducers/xform/map"; import type { Graph, GraphSpec, @@ -97,14 +96,14 @@ const isNodeSpec = (x: any): x is NodeSpec => * @param spec - * @param id - */ -const nodeFromSpec = (state: IAtom, spec: NodeSpec, id: string) => ( - resolve: ResolveFn -): Node => { - const ins = prepareNodeInputs(spec.ins, state, resolve); - const node = spec.fn(ins, id); - const outs = prepareNodeOutputs(spec.outs, node, state, id); - return { ins, node, outs }; -}; +const nodeFromSpec = + (state: IAtom, spec: NodeSpec, id: string) => + (resolve: ResolveFn): Node => { + const ins = prepareNodeInputs(spec.ins, state, resolve); + const node = spec.fn(ins, id); + const outs = prepareNodeOutputs(spec.outs, node, state, id); + return { ins, node, outs }; + }; const prepareNodeInputs = ( ins: IObjectOf, @@ -255,16 +254,19 @@ export const stop = (graph: Graph) => { * @param inputIDs - * @param reset - */ -export const node = ( - xform: Transducer, any>, - inputIDs?: string[], - reset = false -): NodeFactory => ( - src: IObjectOf>, - id: string -): StreamSync => ( - ensureInputs(src, inputIDs, id), sync({ src, xform, id, reset }) -); +export const node = + ( + xform: Transducer, any>, + inputIDs?: string[], + reset = false + ): NodeFactory => + ( + src: IObjectOf>, + id: string + ): StreamSync => { + ensureInputs(src, inputIDs, id); + return sync({ src, xform, id, reset }); + }; /** * Similar to {@link node}, but optimized for nodes using only a single @@ -275,16 +277,15 @@ export const node = ( * @param xform - * @param inputID - */ -export const node1 = ( - xform?: Transducer, - inputID = "src" -): NodeFactory => ( - src: IObjectOf>, - id: string -): ISubscription => { - ensureInputs(src, [inputID], id); - return src[inputID].subscribe({}, { xform, id }); -}; +export const node1 = + (xform?: Transducer, inputID = "src"): NodeFactory => + ( + src: IObjectOf>, + id: string + ): ISubscription => { + ensureInputs(src, [inputID], id); + return src[inputID].subscribe({}, { xform, id }); + }; /** * Syntax sugar for `node()`, intended for nodes w/ 2 inputs, by default diff --git a/packages/rstream-graph/src/nodes/extract.ts b/packages/rstream-graph/src/nodes/extract.ts index 07d08736ad..9521bd586b 100644 --- a/packages/rstream-graph/src/nodes/extract.ts +++ b/packages/rstream-graph/src/nodes/extract.ts @@ -1,6 +1,6 @@ import type { Path } from "@thi.ng/api"; -import { getInUnsafe } from "@thi.ng/paths"; -import { map } from "@thi.ng/transducers"; +import { getInUnsafe } from "@thi.ng/paths/get-in"; +import { map } from "@thi.ng/transducers/xform/map"; import type { NodeFactory } from "../api"; import { node1 } from "../graph"; diff --git a/packages/rstream-graph/src/nodes/math.ts b/packages/rstream-graph/src/nodes/math.ts index 17cd1ac03c..dbefcddfa5 100644 --- a/packages/rstream-graph/src/nodes/math.ts +++ b/packages/rstream-graph/src/nodes/math.ts @@ -1,5 +1,5 @@ import type { IObjectOf } from "@thi.ng/api"; -import { map } from "@thi.ng/transducers"; +import { map } from "@thi.ng/transducers/xform/map"; import type { NodeFactory } from "../api"; import { node, node2 } from "../graph"; diff --git a/packages/rstream-log/src/logger.ts b/packages/rstream-log/src/logger.ts index 29b58d998e..9a3047f59f 100644 --- a/packages/rstream-log/src/logger.ts +++ b/packages/rstream-log/src/logger.ts @@ -1,6 +1,8 @@ -import { LogLevel } from "@thi.ng/api"; -import { illegalArity } from "@thi.ng/errors"; -import { CloseMode, ISubscribable, nextID, StreamMerge } from "@thi.ng/rstream"; +import { LogLevel } from "@thi.ng/api/api/logger"; +import { illegalArity } from "@thi.ng/errors/illegal-arity"; +import { CloseMode, ISubscribable } from "@thi.ng/rstream/api"; +import { StreamMerge } from "@thi.ng/rstream/stream-merge"; +import { nextID } from "@thi.ng/rstream/utils/idgen"; import type { ILogger, LogEntry } from "./api"; export class Logger extends StreamMerge implements ILogger { diff --git a/packages/rstream-log/src/xform/filter.ts b/packages/rstream-log/src/xform/filter.ts index 1ba62588aa..82958b0480 100644 --- a/packages/rstream-log/src/xform/filter.ts +++ b/packages/rstream-log/src/xform/filter.ts @@ -1,7 +1,7 @@ import type { LogLevel } from "@thi.ng/api"; -import { isString } from "@thi.ng/checks"; +import { isString } from "@thi.ng/checks/is-string"; import type { Transducer } from "@thi.ng/transducers"; -import { filter } from "@thi.ng/transducers"; +import { filter } from "@thi.ng/transducers/xform/filter"; import type { LogEntry } from "../api"; export const onlyLevel = (level: LogLevel): Transducer => diff --git a/packages/rstream-log/src/xform/format.ts b/packages/rstream-log/src/xform/format.ts index 3e5b743c7f..de07f51574 100644 --- a/packages/rstream-log/src/xform/format.ts +++ b/packages/rstream-log/src/xform/format.ts @@ -1,6 +1,7 @@ -import { LogLevel } from "@thi.ng/api"; -import { stringify } from "@thi.ng/strings"; -import { map, Transducer } from "@thi.ng/transducers"; +import { LogLevel } from "@thi.ng/api/api/logger"; +import { stringify } from "@thi.ng/strings/stringify"; +import type { Transducer } from "@thi.ng/transducers"; +import { map } from "@thi.ng/transducers/xform/map"; import type { BodyFormat, DateFormat, LogEntry, LogEntryObj } from "../api"; export const isoDate = (dt: number) => new Date(dt).toISOString(); diff --git a/packages/rstream-query/src/api.ts b/packages/rstream-query/src/api.ts index 69f3532537..c87b0e1fcd 100644 --- a/packages/rstream-query/src/api.ts +++ b/packages/rstream-query/src/api.ts @@ -1,4 +1,5 @@ -import { Fn, ILogger, IObjectOf, NULL_LOGGER } from "@thi.ng/api"; +import type { Fn, ILogger, IObjectOf } from "@thi.ng/api"; +import { NULL_LOGGER } from "@thi.ng/api/logger"; import type { ISubscription } from "@thi.ng/rstream"; export type Pattern = [any, any, any]; diff --git a/packages/rstream-query/src/convert.ts b/packages/rstream-query/src/convert.ts index c532a6fdc4..deeb574c22 100644 --- a/packages/rstream-query/src/convert.ts +++ b/packages/rstream-query/src/convert.ts @@ -1,5 +1,8 @@ -import { isArray, isPlainObject } from "@thi.ng/checks"; -import { concat, mapcat, pairs } from "@thi.ng/transducers"; +import { isArray } from "@thi.ng/checks/is-array"; +import { isPlainObject } from "@thi.ng/checks/is-plain-object"; +import { concat } from "@thi.ng/transducers/iter/concat"; +import { pairs } from "@thi.ng/transducers/iter/pairs"; +import { mapcat } from "@thi.ng/transducers/xform/mapcat"; let NEXT_ID = 0; @@ -8,18 +11,22 @@ const mapBNode = (s: any, p: any, o: any): IterableIterator => { return concat([[s, p, id]], asTriples(o, id)); }; -const mapSubject = (subject: any) => ([p, o]: [any, any]) => { - if (isArray(o)) { - return mapcat( - (o) => - isPlainObject(o) ? mapBNode(subject, p, o) : [[subject, p, o]], - o - ); - } else if (isPlainObject(o)) { - return mapBNode(subject, p, o); - } - return [[subject, p, o]]; -}; +const mapSubject = + (subject: any) => + ([p, o]: [any, any]) => { + if (isArray(o)) { + return mapcat( + (o) => + isPlainObject(o) + ? mapBNode(subject, p, o) + : [[subject, p, o]], + o + ); + } else if (isPlainObject(o)) { + return mapBNode(subject, p, o); + } + return [[subject, p, o]]; + }; /** * Converts given object into an iterable of triples, with the following diff --git a/packages/rstream-query/src/pattern.ts b/packages/rstream-query/src/pattern.ts index a697d2fba9..fe09fbd359 100644 --- a/packages/rstream-query/src/pattern.ts +++ b/packages/rstream-query/src/pattern.ts @@ -1,4 +1,4 @@ -import { repeatedly } from "@thi.ng/transducers"; +import { repeatedly } from "@thi.ng/transducers/iter/repeatedly"; import type { PathPattern, Pattern } from "./api"; import { autoQVar, isQVar, qvarName } from "./qvar"; diff --git a/packages/rstream-query/src/qvar.ts b/packages/rstream-query/src/qvar.ts index e7d18592f1..e50370c675 100644 --- a/packages/rstream-query/src/qvar.ts +++ b/packages/rstream-query/src/qvar.ts @@ -1,4 +1,4 @@ -import { isString } from "@thi.ng/checks"; +import { isString } from "@thi.ng/checks/is-string"; import type { Triple } from "./api"; const AUTO_QVAR_PREFIX = "?__q"; diff --git a/packages/rstream-query/src/store.ts b/packages/rstream-query/src/store.ts index 4c75c5e241..25e669147f 100644 --- a/packages/rstream-query/src/store.ts +++ b/packages/rstream-query/src/store.ts @@ -1,26 +1,22 @@ -import { assert, IObjectOf } from "@thi.ng/api"; -import { join } from "@thi.ng/associative"; +import type { IObjectOf } from "@thi.ng/api"; +import { assert } from "@thi.ng/api/assert"; +import { join } from "@thi.ng/associative/join"; import { equiv } from "@thi.ng/equiv"; -import { illegalArgs } from "@thi.ng/errors"; -import { min3id } from "@thi.ng/math"; -import { - CloseMode, - ISubscription, - nextID, - Stream, - Subscription, - sync, -} from "@thi.ng/rstream"; +import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; +import { min3id } from "@thi.ng/math/interval"; import { DotOpts, IToDot, toDot, walk } from "@thi.ng/rstream-dot"; -import { - assocObj, - comp, - dedupe, - map, - mapIndexed, - transduce, - Transducer, -} from "@thi.ng/transducers"; +import { CloseMode, ISubscription } from "@thi.ng/rstream/api"; +import { Stream } from "@thi.ng/rstream/stream"; +import { sync } from "@thi.ng/rstream/stream-sync"; +import type { Subscription } from "@thi.ng/rstream"; +import { nextID } from "@thi.ng/rstream/utils/idgen"; +import type { Transducer } from "@thi.ng/transducers"; +import { comp } from "@thi.ng/transducers/func/comp"; +import { assocObj } from "@thi.ng/transducers/rfn/assoc-obj"; +import { transduce } from "@thi.ng/transducers/transduce"; +import { dedupe } from "@thi.ng/transducers/xform/dedupe"; +import { map } from "@thi.ng/transducers/xform/map"; +import { mapIndexed } from "@thi.ng/transducers/xform/map-indexed"; import type { Edit, PathPattern, diff --git a/packages/rstream-query/src/xforms.ts b/packages/rstream-query/src/xforms.ts index 5d895960ac..3ca9dc0c63 100644 --- a/packages/rstream-query/src/xforms.ts +++ b/packages/rstream-query/src/xforms.ts @@ -1,16 +1,14 @@ import type { IObjectOf } from "@thi.ng/api"; -import { intersection, join } from "@thi.ng/associative"; +import { intersection } from "@thi.ng/associative/intersection"; +import { join } from "@thi.ng/associative/join"; import { equiv } from "@thi.ng/equiv"; -import { LOGGER } from "@thi.ng/rstream"; -import { - comp, - compR, - dedupe, - keySelector, - map, - Reducer, - Transducer, -} from "@thi.ng/transducers"; +import { LOGGER } from "@thi.ng/rstream/api"; +import type { Reducer, Transducer } from "@thi.ng/transducers"; +import { comp } from "@thi.ng/transducers/func/comp"; +import { compR } from "@thi.ng/transducers/func/compr"; +import { keySelector } from "@thi.ng/transducers/func/key-selector"; +import { dedupe } from "@thi.ng/transducers/xform/dedupe"; +import { map } from "@thi.ng/transducers/xform/map"; import type { BindFn, Edit, Solutions, Triple, TripleIds } from "./api"; import type { TripleStore } from "./store"; @@ -24,18 +22,18 @@ export const intersect3: Transducer, TripleIds> = comp( dedupe(equiv) ); -export const indexSel = (key: any): Transducer => ( - rfn: Reducer -) => { - const r = rfn[2]; - return compR(rfn, (acc, e) => { - LOGGER.fine("index sel", e.key, key); - if (equiv(e.key, key)) { - return r(acc, e.index); - } - return acc; - }); -}; +export const indexSel = + (key: any): Transducer => + (rfn: Reducer) => { + const r = rfn[2]; + return compR(rfn, (acc, e) => { + LOGGER.fine("index sel", e.key, key); + if (equiv(e.key, key)) { + return r(acc, e.index); + } + return acc; + }); + }; export const resultTriples = (graph: TripleStore) => map>((ids) => { diff --git a/packages/rstream/src/api.ts b/packages/rstream/src/api.ts index e38b614e4e..7042929ee1 100644 --- a/packages/rstream/src/api.ts +++ b/packages/rstream/src/api.ts @@ -1,4 +1,5 @@ -import { Fn, Fn0, IDeref, IID, ILogger, NULL_LOGGER } from "@thi.ng/api"; +import type { Fn, Fn0, IDeref, IID, ILogger } from "@thi.ng/api"; +import { NULL_LOGGER } from "@thi.ng/api/logger"; import type { Transducer } from "@thi.ng/transducers"; import type { Stream } from "./stream"; diff --git a/packages/rstream/src/checks.ts b/packages/rstream/src/checks.ts new file mode 100644 index 0000000000..6a0ca23cd7 --- /dev/null +++ b/packages/rstream/src/checks.ts @@ -0,0 +1,5 @@ +import { implementsFunction } from "@thi.ng/checks/implements-function"; +import type { ISubscribable } from "./api"; + +export const isSubscribable = (x: any): x is ISubscribable => + implementsFunction(x, "subscribe"); diff --git a/packages/rstream/src/forkjoin.ts b/packages/rstream/src/forkjoin.ts index bbd1589cb0..e8509c4363 100644 --- a/packages/rstream/src/forkjoin.ts +++ b/packages/rstream/src/forkjoin.ts @@ -1,12 +1,12 @@ -import type { ArrayLikeIterable, Fn, Fn3, IObjectOf } from "@thi.ng/api"; -import { - assocObj, - comp, - map, - mapcat, - range, - transduce, -} from "@thi.ng/transducers"; +import type { Fn, Fn3 } from "@thi.ng/api"; +import type { IObjectOf } from "@thi.ng/api"; +import type { ArrayLikeIterable } from "@thi.ng/api"; +import { comp } from "@thi.ng/transducers/func/comp"; +import { range } from "@thi.ng/transducers/iter/range"; +import { assocObj } from "@thi.ng/transducers/rfn/assoc-obj"; +import { transduce } from "@thi.ng/transducers/transduce"; +import { map } from "@thi.ng/transducers/xform/map"; +import { mapcat } from "@thi.ng/transducers/xform/mapcat"; import type { CommonOpts, ISubscribable, ITransformable } from "./api"; import { sync } from "./stream-sync"; import { tunnel } from "./subs/tunnel"; @@ -195,16 +195,14 @@ type Sliceable = ArrayLike & { * * @param minChunkSize - */ -export const forkBuffer = (minChunkSize = 1) => >( - id: number, - numWorkers: number, - buf: T -) => { - const chunkSize = Math.max(minChunkSize, (buf.length / numWorkers) | 0); - return id < numWorkers - 1 - ? buf.slice(id * chunkSize, (id + 1) * chunkSize) - : buf.slice(id * chunkSize); -}; +export const forkBuffer = + (minChunkSize = 1) => + >(id: number, numWorkers: number, buf: T) => { + const chunkSize = Math.max(minChunkSize, (buf.length / numWorkers) | 0); + return id < numWorkers - 1 + ? buf.slice(id * chunkSize, (id + 1) * chunkSize) + : buf.slice(id * chunkSize); + }; /** * Higher-order join function for scenarios involving the split-parallel diff --git a/packages/rstream/src/from/object.ts b/packages/rstream/src/from/object.ts index b1219648ee..c8aba1adfe 100644 --- a/packages/rstream/src/from/object.ts +++ b/packages/rstream/src/from/object.ts @@ -1,5 +1,6 @@ -import type { Keys, Predicate2 } from "@thi.ng/api"; -import { dedupe } from "@thi.ng/transducers"; +import type { Keys } from "@thi.ng/api"; +import type { Predicate2 } from "@thi.ng/api"; +import { dedupe } from "@thi.ng/transducers/xform/dedupe"; import type { CommonOpts, SubscriptionOpts } from "../api"; import { Subscription, subscription } from "../subscription"; import { nextID } from "../utils/idgen"; diff --git a/packages/rstream/src/from/promises.ts b/packages/rstream/src/from/promises.ts index e74c1c3568..e22244d3a3 100644 --- a/packages/rstream/src/from/promises.ts +++ b/packages/rstream/src/from/promises.ts @@ -1,4 +1,4 @@ -import { mapcat } from "@thi.ng/transducers"; +import { mapcat } from "@thi.ng/transducers/xform/mapcat"; import type { ISubscription, WithErrorHandlerOpts } from "../api"; import { optsWithID } from "../utils/idgen"; import { fromPromise } from "./promise"; diff --git a/packages/rstream/src/from/raf.ts b/packages/rstream/src/from/raf.ts index 6c7d9d1016..1616e4bb4e 100644 --- a/packages/rstream/src/from/raf.ts +++ b/packages/rstream/src/from/raf.ts @@ -1,4 +1,4 @@ -import { isNode } from "@thi.ng/checks"; +import { isNode } from "@thi.ng/checks/is-node"; import type { CommonOpts } from "../api"; import { Stream } from "../stream"; import { optsWithID } from "../utils/idgen"; diff --git a/packages/rstream/src/from/view.ts b/packages/rstream/src/from/view.ts index 3a1eb22b17..574f186e5b 100644 --- a/packages/rstream/src/from/view.ts +++ b/packages/rstream/src/from/view.ts @@ -1,6 +1,6 @@ +import type { Fn } from "@thi.ng/api"; import type { DeepPath, - Fn, OptPathVal, Path, Path0, @@ -12,9 +12,10 @@ import type { Path6, Path7, Path8, - Predicate2, } from "@thi.ng/api"; -import { ReadonlyAtom, View } from "@thi.ng/atom"; +import type { Predicate2 } from "@thi.ng/api"; +import type { ReadonlyAtom } from "@thi.ng/atom"; +import { View } from "@thi.ng/atom/view"; import type { CommonOpts } from "../api"; import { Stream } from "../stream"; import { optsWithID } from "../utils/idgen"; diff --git a/packages/rstream/src/index.ts b/packages/rstream/src/index.ts index 49f299cb1a..e0cac239be 100644 --- a/packages/rstream/src/index.ts +++ b/packages/rstream/src/index.ts @@ -1,4 +1,5 @@ export * from "./api"; +export * from "./checks"; export * from "./forkjoin"; export * from "./metastream"; export * from "./pubsub"; diff --git a/packages/rstream/src/metastream.ts b/packages/rstream/src/metastream.ts index 3003f4ed98..2bfc953b2d 100644 --- a/packages/rstream/src/metastream.ts +++ b/packages/rstream/src/metastream.ts @@ -1,4 +1,6 @@ -import { assert, Fn, Nullable } from "@thi.ng/api"; +import type { Fn } from "@thi.ng/api"; +import type { Nullable } from "@thi.ng/api"; +import { assert } from "@thi.ng/api/assert"; import { CloseMode, CommonOpts, ISubscription, State } from "./api"; import { Subscription } from "./subscription"; import { optsWithID } from "./utils/idgen"; diff --git a/packages/rstream/src/pubsub.ts b/packages/rstream/src/pubsub.ts index 788f67053c..9903fd50c7 100644 --- a/packages/rstream/src/pubsub.ts +++ b/packages/rstream/src/pubsub.ts @@ -1,6 +1,7 @@ -import type { Fn, Predicate2 } from "@thi.ng/api"; -import { EquivMap } from "@thi.ng/associative"; -import { unsupported } from "@thi.ng/errors"; +import type { Fn } from "@thi.ng/api"; +import type { Predicate2 } from "@thi.ng/api"; +import { EquivMap } from "@thi.ng/associative/equiv-map"; +import { unsupported } from "@thi.ng/errors/unsupported"; import type { Transducer } from "@thi.ng/transducers"; import { CloseMode, diff --git a/packages/rstream/src/stream-sync.ts b/packages/rstream/src/stream-sync.ts index 43297f22ec..1f5a0f42a8 100644 --- a/packages/rstream/src/stream-sync.ts +++ b/packages/rstream/src/stream-sync.ts @@ -1,11 +1,13 @@ -import type { Always, Derefed, IObjectOf } from "@thi.ng/api"; +import type { Derefed } from "@thi.ng/api"; +import type { Always } from "@thi.ng/api"; +import type { IObjectOf } from "@thi.ng/api"; +import { comp } from "@thi.ng/transducers/func/comp"; +import { labeled } from "@thi.ng/transducers/xform/labeled"; +import { mapVals } from "@thi.ng/transducers/xform/map-vals"; import { - comp, - labeled, - mapVals, partitionSync, PartitionSync, -} from "@thi.ng/transducers"; +} from "@thi.ng/transducers/xform/partition-sync"; import { ISubscribable, ISubscription, LOGGER, TransformableOpts } from "./api"; import { Subscription } from "./subscription"; import { isFirstOrLastInput } from "./utils/checks"; diff --git a/packages/rstream/src/stream.ts b/packages/rstream/src/stream.ts index 813739b838..0b7542ff17 100644 --- a/packages/rstream/src/stream.ts +++ b/packages/rstream/src/stream.ts @@ -1,4 +1,4 @@ -import { isFunction } from "@thi.ng/checks"; +import { isFunction } from "@thi.ng/checks/is-function"; import { CloseMode, CommonOpts, diff --git a/packages/rstream/src/subs/post-worker.ts b/packages/rstream/src/subs/post-worker.ts index f4b5b20966..d2bff151b6 100644 --- a/packages/rstream/src/subs/post-worker.ts +++ b/packages/rstream/src/subs/post-worker.ts @@ -1,4 +1,5 @@ -import { isTransferable, isTypedArray } from "@thi.ng/checks"; +import { isTransferable } from "@thi.ng/checks/is-transferable"; +import { isTypedArray } from "@thi.ng/checks/is-typedarray"; import { ISubscriber, LOGGER } from "../api"; import { makeWorker } from "../utils/worker"; diff --git a/packages/rstream/src/subs/resolve.ts b/packages/rstream/src/subs/resolve.ts index bef46c7370..9aa0b06169 100644 --- a/packages/rstream/src/subs/resolve.ts +++ b/packages/rstream/src/subs/resolve.ts @@ -1,4 +1,5 @@ -import type { Fn, IID } from "@thi.ng/api"; +import type { Fn } from "@thi.ng/api"; +import type { IID } from "@thi.ng/api"; import { LOGGER, State } from "../api"; import { Subscription } from "../subscription"; import { optsWithID } from "../utils/idgen"; diff --git a/packages/rstream/src/subs/sidechain-partition.ts b/packages/rstream/src/subs/sidechain-partition.ts index a51d17a3da..7c74f5aeda 100644 --- a/packages/rstream/src/subs/sidechain-partition.ts +++ b/packages/rstream/src/subs/sidechain-partition.ts @@ -1,6 +1,6 @@ import type { Predicate } from "@thi.ng/api"; -import { peek } from "@thi.ng/arrays"; -import { map } from "@thi.ng/transducers"; +import { peek } from "@thi.ng/arrays/peek"; +import { map } from "@thi.ng/transducers/xform/map"; import { CommonOpts, ISubscribable, State } from "../api"; import { fromRAF } from "../from/raf"; import type { Subscription } from "../subscription"; diff --git a/packages/rstream/src/subs/transduce.ts b/packages/rstream/src/subs/transduce.ts index a99fa9e796..1a6c0c0198 100644 --- a/packages/rstream/src/subs/transduce.ts +++ b/packages/rstream/src/subs/transduce.ts @@ -1,5 +1,5 @@ import type { Reducer, Transducer } from "@thi.ng/transducers"; -import { isReduced, Reduced } from "@thi.ng/transducers"; +import { isReduced, Reduced } from "@thi.ng/transducers/reduced"; import type { ISubscription } from "../api"; import type { Subscription } from "../subscription"; diff --git a/packages/rstream/src/subscription.ts b/packages/rstream/src/subscription.ts index 5e29c97b47..5f633ee635 100644 --- a/packages/rstream/src/subscription.ts +++ b/packages/rstream/src/subscription.ts @@ -1,17 +1,15 @@ -import { assert, Fn, NULL_LOGGER, SEMAPHORE } from "@thi.ng/api"; -import { peek } from "@thi.ng/arrays"; -import { isPlainObject } from "@thi.ng/checks"; -import { illegalState } from "@thi.ng/errors"; -import { - comp, - isReduced, - map, - push, - Reduced, - Reducer, - Transducer, - unreduced, -} from "@thi.ng/transducers"; +import type { Fn } from "@thi.ng/api"; +import { assert } from "@thi.ng/api/assert"; +import { SEMAPHORE } from "@thi.ng/api/constants"; +import { NULL_LOGGER } from "@thi.ng/api/logger"; +import { peek } from "@thi.ng/arrays/peek"; +import { isPlainObject } from "@thi.ng/checks/is-plain-object"; +import { illegalState } from "@thi.ng/errors/illegal-state"; +import type { Reducer, Transducer } from "@thi.ng/transducers"; +import { comp } from "@thi.ng/transducers/func/comp"; +import { isReduced, Reduced, unreduced } from "@thi.ng/transducers/reduced"; +import { push } from "@thi.ng/transducers/rfn/push"; +import { map } from "@thi.ng/transducers/xform/map"; import { CloseMode, CommonOpts, diff --git a/packages/rstream/src/tween.ts b/packages/rstream/src/tween.ts index cf898edd30..59bef36e6e 100644 --- a/packages/rstream/src/tween.ts +++ b/packages/rstream/src/tween.ts @@ -1,6 +1,8 @@ import type { Fn2 } from "@thi.ng/api"; -import { isNumber } from "@thi.ng/checks"; -import { dedupe, reducer, scan } from "@thi.ng/transducers"; +import { isNumber } from "@thi.ng/checks/is-number"; +import { reducer } from "@thi.ng/transducers/reduce"; +import { dedupe } from "@thi.ng/transducers/xform/dedupe"; +import { scan } from "@thi.ng/transducers/xform/scan"; import { CloseMode, ISubscribable } from "./api"; import { fromInterval } from "./from/interval"; import { fromRAF } from "./from/raf"; diff --git a/packages/sax/src/index.ts b/packages/sax/src/index.ts index 00f7027057..ef69c2a481 100644 --- a/packages/sax/src/index.ts +++ b/packages/sax/src/index.ts @@ -1,6 +1,8 @@ -import { IObjectOf, NO_OP } from "@thi.ng/api"; -import { $iter, iterator, Transducer } from "@thi.ng/transducers"; +import type { IObjectOf } from "@thi.ng/api"; +import { NO_OP } from "@thi.ng/api/constants"; +import type { Transducer } from "@thi.ng/transducers"; import { fsm, FSMState, FSMStateMap } from "@thi.ng/transducers-fsm"; +import { $iter, iterator } from "@thi.ng/transducers/iterator"; export interface ParseOpts { /** diff --git a/packages/scenegraph/src/anode.ts b/packages/scenegraph/src/anode.ts index 296d1873f2..d121184b6f 100644 --- a/packages/scenegraph/src/anode.ts +++ b/packages/scenegraph/src/anode.ts @@ -1,4 +1,5 @@ -import { assert, Nullable } from "@thi.ng/api"; +import type { Nullable } from "@thi.ng/api"; +import { assert } from "@thi.ng/api/assert"; import type { Mat } from "@thi.ng/matrices"; import type { ReadonlyVec, Vec } from "@thi.ng/vectors"; import type { ISceneNode, NodeInfo } from "./api"; diff --git a/packages/scenegraph/src/hiccup.ts b/packages/scenegraph/src/hiccup.ts index deeae52588..104ca0a800 100644 --- a/packages/scenegraph/src/hiccup.ts +++ b/packages/scenegraph/src/hiccup.ts @@ -1,5 +1,6 @@ -import { deref, IToHiccup } from "@thi.ng/api"; -import { isFunction } from "@thi.ng/checks"; +import type { IToHiccup } from "@thi.ng/api"; +import { deref } from "@thi.ng/api/api/deref"; +import { isFunction } from "@thi.ng/checks/is-function"; import type { ANode } from "./anode"; /** diff --git a/packages/scenegraph/src/node2.ts b/packages/scenegraph/src/node2.ts index ed1aeaf255..197d95d2c3 100644 --- a/packages/scenegraph/src/node2.ts +++ b/packages/scenegraph/src/node2.ts @@ -1,14 +1,19 @@ import type { ICopy, IToHiccup, Nullable } from "@thi.ng/api"; -import { isNumber } from "@thi.ng/checks"; -import { invert23, mulM23, mulV23, transform23 } from "@thi.ng/matrices"; -import { ReadonlyVec, set2, Vec } from "@thi.ng/vectors"; +import { isNumber } from "@thi.ng/checks/is-number"; +import { invert23 } from "@thi.ng/matrices/invert"; +import { mulM23 } from "@thi.ng/matrices/mulm"; +import { mulV23 } from "@thi.ng/matrices/mulv"; +import { transform23 } from "@thi.ng/matrices/transform"; +import type { ReadonlyVec, Vec } from "@thi.ng/vectors"; +import { set2 } from "@thi.ng/vectors/set"; import { ANode } from "./anode"; import type { ISceneNode } from "./api"; import { toHiccup } from "./hiccup"; export class Node2D extends ANode - implements ICopy, ISceneNode, IToHiccup { + implements ICopy, ISceneNode, IToHiccup +{ translate: Vec; rotate: number; scale: Vec | number; diff --git a/packages/scenegraph/src/node3.ts b/packages/scenegraph/src/node3.ts index df1eb9f4f5..3bfc9f073b 100644 --- a/packages/scenegraph/src/node3.ts +++ b/packages/scenegraph/src/node3.ts @@ -1,14 +1,19 @@ import type { ICopy, IToHiccup, Nullable } from "@thi.ng/api"; -import { isNumber } from "@thi.ng/checks"; -import { invert44, mulM44, mulV344, transform44 } from "@thi.ng/matrices"; -import { ReadonlyVec, set3, Vec } from "@thi.ng/vectors"; +import { isNumber } from "@thi.ng/checks/is-number"; +import { invert44 } from "@thi.ng/matrices/invert"; +import { mulM44 } from "@thi.ng/matrices/mulm"; +import { mulV344 } from "@thi.ng/matrices/mulv"; +import { transform44 } from "@thi.ng/matrices/transform"; +import type { ReadonlyVec, Vec } from "@thi.ng/vectors"; +import { set3 } from "@thi.ng/vectors/set"; import { ANode } from "./anode"; import type { ISceneNode } from "./api"; import { toHiccup } from "./hiccup"; export class Node3D extends ANode - implements ICopy, ISceneNode, IToHiccup { + implements ICopy, ISceneNode, IToHiccup +{ translate: Vec; rotate: Vec; scale: Vec | number; diff --git a/packages/seq/src/ensure.ts b/packages/seq/src/ensure.ts index 63ba847021..64b35b883d 100644 --- a/packages/seq/src/ensure.ts +++ b/packages/seq/src/ensure.ts @@ -1,5 +1,6 @@ import type { ISeq, ISeqable, Nullable } from "@thi.ng/api"; -import { implementsFunction, isArrayLike } from "@thi.ng/checks"; +import { implementsFunction } from "@thi.ng/checks/implements-function"; +import { isArrayLike } from "@thi.ng/checks/is-arraylike"; import { aseq } from "./array"; export const isSeq = (x: any): x is ISeq => diff --git a/packages/sexpr/src/parse.ts b/packages/sexpr/src/parse.ts index 35bf42b2a6..570a7015ac 100644 --- a/packages/sexpr/src/parse.ts +++ b/packages/sexpr/src/parse.ts @@ -1,4 +1,4 @@ -import { isString } from "@thi.ng/checks"; +import { isString } from "@thi.ng/checks/is-string"; import { DEFAULT_SYNTAX } from "./constants"; import { tokenize } from "./tokenize"; import type { ASTNode, Expression, Root, SyntaxOpts, Token } from "./api"; diff --git a/packages/sexpr/src/runtime.ts b/packages/sexpr/src/runtime.ts index 653951eb5d..8a9c8b53f8 100644 --- a/packages/sexpr/src/runtime.ts +++ b/packages/sexpr/src/runtime.ts @@ -1,4 +1,5 @@ -import { defmulti, MultiFn1O } from "@thi.ng/defmulti"; +import type { MultiFn1O } from "@thi.ng/defmulti"; +import { defmulti } from "@thi.ng/defmulti/defmulti"; import type { ASTNode, Implementations } from "./api"; export const runtime = , ENV, RES>( diff --git a/packages/shader-ast-glsl/src/target.ts b/packages/shader-ast-glsl/src/target.ts index 195a457136..b8372053da 100644 --- a/packages/shader-ast-glsl/src/target.ts +++ b/packages/shader-ast-glsl/src/target.ts @@ -1,6 +1,7 @@ import type { Fn } from "@thi.ng/api"; -import { isBoolean, isNumber } from "@thi.ng/checks"; -import { unsupported } from "@thi.ng/errors"; +import { isBoolean } from "@thi.ng/checks/is-boolean"; +import { isNumber } from "@thi.ng/checks/is-number"; +import { unsupported } from "@thi.ng/errors/unsupported"; import { defTarget, FnCall, diff --git a/packages/shader-ast-js/src/env.ts b/packages/shader-ast-js/src/env.ts index 01d468b8b5..14fc2e0a45 100644 --- a/packages/shader-ast-js/src/env.ts +++ b/packages/shader-ast-js/src/env.ts @@ -6,22 +6,18 @@ import { mat44n, mat44v, } from "@thi.ng/matrices"; +import { ZERO3, ZERO4 } from "@thi.ng/vectors/api"; +import { fromBVec2, fromBVec3, fromBVec4 } from "@thi.ng/vectors/convert"; +import { setVN3, setVN4 } from "@thi.ng/vectors/setvn"; +import { setVV4 } from "@thi.ng/vectors/setvv"; import { - fromBVec2, - fromBVec3, - fromBVec4, setSwizzle2, setSwizzle3, setSwizzle4, - setVN3, - setVN4, - setVV4, swizzle2, swizzle3, swizzle4, - ZERO3, - ZERO4, -} from "@thi.ng/vectors"; +} from "@thi.ng/vectors/swizzle"; import type { JSBuiltinsSampler, JSEnv } from "./api"; import { BVEC2, BVEC3, BVEC4 } from "./env/bvec"; import { FLOAT } from "./env/float"; diff --git a/packages/shader-ast-js/src/env/bvec.ts b/packages/shader-ast-js/src/env/bvec.ts index 781abface8..d99dd740ea 100644 --- a/packages/shader-ast-js/src/env/bvec.ts +++ b/packages/shader-ast-js/src/env/bvec.ts @@ -1,14 +1,6 @@ -import { - every2, - every3, - every4, - not2, - not3, - not4, - some2, - some3, - some4, -} from "@thi.ng/vectors"; +import { every2, every3, every4 } from "@thi.ng/vectors/every"; +import { not2, not3, not4 } from "@thi.ng/vectors/not"; +import { some2, some3, some4 } from "@thi.ng/vectors/some"; import type { JSBuiltinsBool } from "../api"; export const BVEC2: JSBuiltinsBool = { diff --git a/packages/shader-ast-js/src/env/int.ts b/packages/shader-ast-js/src/env/int.ts index f7ece76493..21bd619680 100644 --- a/packages/shader-ast-js/src/env/int.ts +++ b/packages/shader-ast-js/src/env/int.ts @@ -1,4 +1,4 @@ -import { clamp } from "@thi.ng/math"; +import { clamp } from "@thi.ng/math/interval"; import type { JSBuiltinsInt } from "../api"; export const INT: JSBuiltinsInt = { diff --git a/packages/shader-ast-js/src/env/ivec2.ts b/packages/shader-ast-js/src/env/ivec2.ts index d22335ce00..66bece54f0 100644 --- a/packages/shader-ast-js/src/env/ivec2.ts +++ b/packages/shader-ast-js/src/env/ivec2.ts @@ -1,21 +1,15 @@ -import { - addI2, - addNI2, - bitAndI2, - bitNotI2, - bitOrI2, - bitXorI2, - divI2, - divNI2, - fmod2, - fmodN2, - lshiftI2, - mulI2, - mulNI2, - rshiftI2, - subI2, - subNI2, -} from "@thi.ng/vectors"; +import { addI2, addNI2 } from "@thi.ng/vectors/addi"; +import { bitAndI2 } from "@thi.ng/vectors/bit-and"; +import { bitNotI2 } from "@thi.ng/vectors/bit-not"; +import { bitOrI2 } from "@thi.ng/vectors/bit-or"; +import { bitXorI2 } from "@thi.ng/vectors/bit-xor"; +import { divI2, divNI2 } from "@thi.ng/vectors/divi"; +import { fmod2 } from "@thi.ng/vectors/fmod"; +import { fmodN2 } from "@thi.ng/vectors/fmodn"; +import { lshiftI2 } from "@thi.ng/vectors/lshift"; +import { mulI2, mulNI2 } from "@thi.ng/vectors/muli"; +import { rshiftI2 } from "@thi.ng/vectors/rshift"; +import { subI2, subNI2 } from "@thi.ng/vectors/subi"; import type { JSBuiltinsIntVec } from "../api"; import { VEC2 } from "./vec2"; diff --git a/packages/shader-ast-js/src/env/ivec3.ts b/packages/shader-ast-js/src/env/ivec3.ts index 1a35012286..1f904c33ed 100644 --- a/packages/shader-ast-js/src/env/ivec3.ts +++ b/packages/shader-ast-js/src/env/ivec3.ts @@ -1,21 +1,15 @@ -import { - addI3, - addNI3, - bitAndI3, - bitNotI3, - bitOrI3, - bitXorI3, - divI3, - divNI3, - fmod3, - fmodN3, - lshiftI3, - mulI3, - mulNI3, - rshiftI3, - subI3, - subNI3, -} from "@thi.ng/vectors"; +import { addI3, addNI3 } from "@thi.ng/vectors/addi"; +import { bitAndI3 } from "@thi.ng/vectors/bit-and"; +import { bitNotI3 } from "@thi.ng/vectors/bit-not"; +import { bitOrI3 } from "@thi.ng/vectors/bit-or"; +import { bitXorI3 } from "@thi.ng/vectors/bit-xor"; +import { divI3, divNI3 } from "@thi.ng/vectors/divi"; +import { fmod3 } from "@thi.ng/vectors/fmod"; +import { fmodN3 } from "@thi.ng/vectors/fmodn"; +import { lshiftI3 } from "@thi.ng/vectors/lshift"; +import { mulI3, mulNI3 } from "@thi.ng/vectors/muli"; +import { rshiftI3 } from "@thi.ng/vectors/rshift"; +import { subI3, subNI3 } from "@thi.ng/vectors/subi"; import type { JSBuiltinsIntVec } from "../api"; import { VEC3 } from "./vec3"; diff --git a/packages/shader-ast-js/src/env/ivec4.ts b/packages/shader-ast-js/src/env/ivec4.ts index 406f505c94..a69684fb46 100644 --- a/packages/shader-ast-js/src/env/ivec4.ts +++ b/packages/shader-ast-js/src/env/ivec4.ts @@ -1,21 +1,15 @@ -import { - addI4, - addNI4, - bitAndI4, - bitNotI4, - bitOrI4, - bitXorI4, - divI4, - divNI4, - fmod4, - fmodN4, - lshiftI4, - mulI4, - mulNI4, - rshiftI4, - subI4, - subNI4, -} from "@thi.ng/vectors"; +import { addI4, addNI4 } from "@thi.ng/vectors/addi"; +import { bitAndI4 } from "@thi.ng/vectors/bit-and"; +import { bitNotI4 } from "@thi.ng/vectors/bit-not"; +import { bitOrI4 } from "@thi.ng/vectors/bit-or"; +import { bitXorI4 } from "@thi.ng/vectors/bit-xor"; +import { divI4, divNI4 } from "@thi.ng/vectors/divi"; +import { fmod4 } from "@thi.ng/vectors/fmod"; +import { fmodN4 } from "@thi.ng/vectors/fmodn"; +import { lshiftI4 } from "@thi.ng/vectors/lshift"; +import { mulI4, mulNI4 } from "@thi.ng/vectors/muli"; +import { rshiftI4 } from "@thi.ng/vectors/rshift"; +import { subI4, subNI4 } from "@thi.ng/vectors/subi"; import type { JSBuiltinsIntVec } from "../api"; import { VEC4 } from "./vec4"; diff --git a/packages/shader-ast-js/src/env/mat2.ts b/packages/shader-ast-js/src/env/mat2.ts index 58055b990a..2a74c30efb 100644 --- a/packages/shader-ast-js/src/env/mat2.ts +++ b/packages/shader-ast-js/src/env/mat2.ts @@ -11,7 +11,7 @@ import { sub22, subN22, } from "@thi.ng/matrices"; -import { neg } from "@thi.ng/vectors"; +import { neg } from "@thi.ng/vectors/neg"; import type { JSBuiltinsMat } from "../api"; export const MAT2: JSBuiltinsMat = { diff --git a/packages/shader-ast-js/src/env/mat3.ts b/packages/shader-ast-js/src/env/mat3.ts index c46d2e975a..633f1e779f 100644 --- a/packages/shader-ast-js/src/env/mat3.ts +++ b/packages/shader-ast-js/src/env/mat3.ts @@ -11,7 +11,9 @@ import { sub33, subN33, } from "@thi.ng/matrices"; -import { neg, setS3, vecOf } from "@thi.ng/vectors"; +import { neg } from "@thi.ng/vectors/neg"; +import { setS3 } from "@thi.ng/vectors/sets"; +import { vecOf } from "@thi.ng/vectors/vec-of"; import type { JSBuiltinsMat } from "../api"; export const MAT3: JSBuiltinsMat = { diff --git a/packages/shader-ast-js/src/env/mat4.ts b/packages/shader-ast-js/src/env/mat4.ts index 3038cf59a5..b4191b1f3b 100644 --- a/packages/shader-ast-js/src/env/mat4.ts +++ b/packages/shader-ast-js/src/env/mat4.ts @@ -11,7 +11,9 @@ import { sub44, subN44, } from "@thi.ng/matrices"; -import { neg, setS4, vecOf } from "@thi.ng/vectors"; +import { neg } from "@thi.ng/vectors/neg"; +import { setS4 } from "@thi.ng/vectors/sets"; +import { vecOf } from "@thi.ng/vectors/vec-of"; import type { JSBuiltinsMat } from "../api"; export const MAT4: JSBuiltinsMat = { diff --git a/packages/shader-ast-js/src/env/uint.ts b/packages/shader-ast-js/src/env/uint.ts index e4a35ceedf..1a0e311fe8 100644 --- a/packages/shader-ast-js/src/env/uint.ts +++ b/packages/shader-ast-js/src/env/uint.ts @@ -1,4 +1,4 @@ -import { clamp } from "@thi.ng/math"; +import { clamp } from "@thi.ng/math/interval"; import type { JSBuiltinsInt } from "../api"; export const UINT: JSBuiltinsInt = { diff --git a/packages/shader-ast-js/src/env/uvec2.ts b/packages/shader-ast-js/src/env/uvec2.ts index e18c2e1727..721000e670 100644 --- a/packages/shader-ast-js/src/env/uvec2.ts +++ b/packages/shader-ast-js/src/env/uvec2.ts @@ -1,21 +1,15 @@ -import { - addNU2, - addU2, - bitAndU2, - bitNotU2, - bitOrU2, - bitXorU2, - divNU2, - divU2, - fmod2, - fmodN2, - lshiftU2, - mulNU2, - mulU2, - rshiftU2, - subNU2, - subU2, -} from "@thi.ng/vectors"; +import { addNU2, addU2 } from "@thi.ng/vectors/addi"; +import { bitAndU2 } from "@thi.ng/vectors/bit-and"; +import { bitNotU2 } from "@thi.ng/vectors/bit-not"; +import { bitOrU2 } from "@thi.ng/vectors/bit-or"; +import { bitXorU2 } from "@thi.ng/vectors/bit-xor"; +import { divNU2, divU2 } from "@thi.ng/vectors/divi"; +import { fmod2 } from "@thi.ng/vectors/fmod"; +import { fmodN2 } from "@thi.ng/vectors/fmodn"; +import { lshiftU2 } from "@thi.ng/vectors/lshift"; +import { mulNU2, mulU2 } from "@thi.ng/vectors/muli"; +import { rshiftU2 } from "@thi.ng/vectors/rshift"; +import { subNU2, subU2 } from "@thi.ng/vectors/subi"; import type { JSBuiltinsIntVec } from "../api"; import { VEC2 } from "./vec2"; diff --git a/packages/shader-ast-js/src/env/uvec3.ts b/packages/shader-ast-js/src/env/uvec3.ts index 76df56106b..31e5eb01e3 100644 --- a/packages/shader-ast-js/src/env/uvec3.ts +++ b/packages/shader-ast-js/src/env/uvec3.ts @@ -1,21 +1,15 @@ -import { - addNU3, - addU3, - bitAndU3, - bitNotU3, - bitOrU3, - bitXorU3, - divNU3, - divU3, - fmod3, - fmodN3, - lshiftU3, - mulNU3, - mulU3, - rshiftU3, - subNU3, - subU3, -} from "@thi.ng/vectors"; +import { addNU3, addU3 } from "@thi.ng/vectors/addi"; +import { bitAndU3 } from "@thi.ng/vectors/bit-and"; +import { bitNotU3 } from "@thi.ng/vectors/bit-not"; +import { bitOrU3 } from "@thi.ng/vectors/bit-or"; +import { bitXorU3 } from "@thi.ng/vectors/bit-xor"; +import { divNU3, divU3 } from "@thi.ng/vectors/divi"; +import { fmod3 } from "@thi.ng/vectors/fmod"; +import { fmodN3 } from "@thi.ng/vectors/fmodn"; +import { lshiftU3 } from "@thi.ng/vectors/lshift"; +import { mulNU3, mulU3 } from "@thi.ng/vectors/muli"; +import { rshiftU3 } from "@thi.ng/vectors/rshift"; +import { subNU3, subU3 } from "@thi.ng/vectors/subi"; import type { JSBuiltinsIntVec } from "../api"; import { VEC3 } from "./vec3"; diff --git a/packages/shader-ast-js/src/env/uvec4.ts b/packages/shader-ast-js/src/env/uvec4.ts index e17c550c7f..14b13f3df2 100644 --- a/packages/shader-ast-js/src/env/uvec4.ts +++ b/packages/shader-ast-js/src/env/uvec4.ts @@ -1,21 +1,15 @@ -import { - addNU4, - addU4, - bitAndU4, - bitNotU4, - bitOrU4, - bitXorU4, - divNU4, - divU4, - fmod4, - fmodN4, - lshiftU4, - mulNU4, - mulU4, - rshiftU4, - subNU4, - subU4, -} from "@thi.ng/vectors"; +import { addNU4, addU4 } from "@thi.ng/vectors/addi"; +import { bitAndU4 } from "@thi.ng/vectors/bit-and"; +import { bitNotU4 } from "@thi.ng/vectors/bit-not"; +import { bitOrU4 } from "@thi.ng/vectors/bit-or"; +import { bitXorU4 } from "@thi.ng/vectors/bit-xor"; +import { divNU4, divU4 } from "@thi.ng/vectors/divi"; +import { fmod4 } from "@thi.ng/vectors/fmod"; +import { fmodN4 } from "@thi.ng/vectors/fmodn"; +import { lshiftU4 } from "@thi.ng/vectors/lshift"; +import { mulNU4, mulU4 } from "@thi.ng/vectors/muli"; +import { rshiftU4 } from "@thi.ng/vectors/rshift"; +import { subNU4, subU4 } from "@thi.ng/vectors/subi"; import type { JSBuiltinsIntVec } from "../api"; import { VEC4 } from "./vec4"; diff --git a/packages/shader-ast-js/src/env/vec2.ts b/packages/shader-ast-js/src/env/vec2.ts index 4d49ef6cad..4cc9d42012 100644 --- a/packages/shader-ast-js/src/env/vec2.ts +++ b/packages/shader-ast-js/src/env/vec2.ts @@ -1,58 +1,55 @@ -import { - abs2, - acos2, - add2, - addN2, - asin2, - atan2, - atan_22, - ceil2, - clamp2, - cos2, - degrees2, - dist, - div2, - divN2, - dot2, - eq2, - exp2, - exp_22, - faceForward, - floor2, - fract2, - gt2, - gte2, - invSqrt2, - log2, - log_22, - lt2, - lte2, - mag, - max2, - min2, - mix2, - mixN2, - mod2, - modN2, - mul2, - mulN2, - neg, - neq2, - normalize, - pow2, - radians2, - reflect, - refract, - sign2, - sin2, - smoothStep2, - sqrt2, - step2, - sub2, - subN2, - tan2, - ZERO2, -} from "@thi.ng/vectors"; +import { abs2 } from "@thi.ng/vectors/abs"; +import { acos2 } from "@thi.ng/vectors/acos"; +import { add2 } from "@thi.ng/vectors/add"; +import { addN2 } from "@thi.ng/vectors/addn"; +import { ZERO2 } from "@thi.ng/vectors/api"; +import { asin2 } from "@thi.ng/vectors/asin"; +import { atan2, atan_22 } from "@thi.ng/vectors/atan"; +import { ceil2 } from "@thi.ng/vectors/ceil"; +import { clamp2 } from "@thi.ng/vectors/clamp"; +import { cos2 } from "@thi.ng/vectors/cos"; +import { degrees2 } from "@thi.ng/vectors/degrees"; +import { dist } from "@thi.ng/vectors/dist"; +import { div2 } from "@thi.ng/vectors/div"; +import { divN2 } from "@thi.ng/vectors/divn"; +import { dot2 } from "@thi.ng/vectors/dot"; +import { eq2 } from "@thi.ng/vectors/eq"; +import { exp2 } from "@thi.ng/vectors/exp"; +import { exp_22 } from "@thi.ng/vectors/exp_2"; +import { faceForward } from "@thi.ng/vectors/face-forward"; +import { floor2 } from "@thi.ng/vectors/floor"; +import { fract2 } from "@thi.ng/vectors/fract"; +import { gt2 } from "@thi.ng/vectors/gt"; +import { gte2 } from "@thi.ng/vectors/gte"; +import { invSqrt2 } from "@thi.ng/vectors/invsqrt"; +import { log2 } from "@thi.ng/vectors/log"; +import { log_22 } from "@thi.ng/vectors/log_2"; +import { lt2 } from "@thi.ng/vectors/lt"; +import { lte2 } from "@thi.ng/vectors/lte"; +import { mag } from "@thi.ng/vectors/mag"; +import { max2 } from "@thi.ng/vectors/max"; +import { min2 } from "@thi.ng/vectors/min"; +import { mix2 } from "@thi.ng/vectors/mix"; +import { mixN2 } from "@thi.ng/vectors/mixn"; +import { mod2 } from "@thi.ng/vectors/mod"; +import { modN2 } from "@thi.ng/vectors/modn"; +import { mul2 } from "@thi.ng/vectors/mul"; +import { mulN2 } from "@thi.ng/vectors/muln"; +import { neg } from "@thi.ng/vectors/neg"; +import { neq2 } from "@thi.ng/vectors/neq"; +import { normalize } from "@thi.ng/vectors/normalize"; +import { pow2 } from "@thi.ng/vectors/pow"; +import { radians2 } from "@thi.ng/vectors/radians"; +import { reflect } from "@thi.ng/vectors/reflect"; +import { refract } from "@thi.ng/vectors/refract"; +import { sign2 } from "@thi.ng/vectors/sign"; +import { sin2 } from "@thi.ng/vectors/sin"; +import { smoothStep2 } from "@thi.ng/vectors/smoothstep"; +import { sqrt2 } from "@thi.ng/vectors/sqrt"; +import { step2 } from "@thi.ng/vectors/step"; +import { sub2 } from "@thi.ng/vectors/sub"; +import { subN2 } from "@thi.ng/vectors/subn"; +import { tan2 } from "@thi.ng/vectors/tan"; import type { JSBuiltinsVec } from "../api"; export const VEC2: JSBuiltinsVec = { diff --git a/packages/shader-ast-js/src/env/vec3.ts b/packages/shader-ast-js/src/env/vec3.ts index 3245d3ee89..9875d63086 100644 --- a/packages/shader-ast-js/src/env/vec3.ts +++ b/packages/shader-ast-js/src/env/vec3.ts @@ -1,59 +1,56 @@ -import { - abs3, - acos3, - add3, - addN3, - asin3, - atan3, - atan_23, - ceil3, - clamp3, - cos3, - cross3, - degrees3, - dist, - div3, - divN3, - dot3, - eq3, - exp3, - exp_23, - faceForward, - floor3, - fract3, - gt3, - gte3, - invSqrt3, - log3, - log_23, - lt3, - lte3, - mag, - max3, - min3, - mix3, - mixN3, - mod3, - modN3, - mul3, - mulN3, - neg, - neq3, - normalize, - pow3, - radians3, - reflect, - refract, - sign3, - sin3, - smoothStep3, - sqrt3, - step3, - sub3, - subN3, - tan3, - ZERO3, -} from "@thi.ng/vectors"; +import { cross3 } from "@thi.ng/vectors/cross"; +import { abs3 } from "@thi.ng/vectors/abs"; +import { acos3 } from "@thi.ng/vectors/acos"; +import { add3 } from "@thi.ng/vectors/add"; +import { addN3 } from "@thi.ng/vectors/addn"; +import { ZERO3 } from "@thi.ng/vectors/api"; +import { asin3 } from "@thi.ng/vectors/asin"; +import { atan3, atan_23 } from "@thi.ng/vectors/atan"; +import { ceil3 } from "@thi.ng/vectors/ceil"; +import { clamp3 } from "@thi.ng/vectors/clamp"; +import { cos3 } from "@thi.ng/vectors/cos"; +import { degrees3 } from "@thi.ng/vectors/degrees"; +import { dist } from "@thi.ng/vectors/dist"; +import { div3 } from "@thi.ng/vectors/div"; +import { divN3 } from "@thi.ng/vectors/divn"; +import { dot3 } from "@thi.ng/vectors/dot"; +import { eq3 } from "@thi.ng/vectors/eq"; +import { exp3 } from "@thi.ng/vectors/exp"; +import { exp_23 } from "@thi.ng/vectors/exp_2"; +import { faceForward } from "@thi.ng/vectors/face-forward"; +import { floor3 } from "@thi.ng/vectors/floor"; +import { fract3 } from "@thi.ng/vectors/fract"; +import { gt3 } from "@thi.ng/vectors/gt"; +import { gte3 } from "@thi.ng/vectors/gte"; +import { invSqrt3 } from "@thi.ng/vectors/invsqrt"; +import { log3 } from "@thi.ng/vectors/log"; +import { log_23 } from "@thi.ng/vectors/log_2"; +import { lt3 } from "@thi.ng/vectors/lt"; +import { lte3 } from "@thi.ng/vectors/lte"; +import { mag } from "@thi.ng/vectors/mag"; +import { max3 } from "@thi.ng/vectors/max"; +import { min3 } from "@thi.ng/vectors/min"; +import { mix3 } from "@thi.ng/vectors/mix"; +import { mixN3 } from "@thi.ng/vectors/mixn"; +import { mod3 } from "@thi.ng/vectors/mod"; +import { modN3 } from "@thi.ng/vectors/modn"; +import { mul3 } from "@thi.ng/vectors/mul"; +import { mulN3 } from "@thi.ng/vectors/muln"; +import { neg } from "@thi.ng/vectors/neg"; +import { neq3 } from "@thi.ng/vectors/neq"; +import { normalize } from "@thi.ng/vectors/normalize"; +import { pow3 } from "@thi.ng/vectors/pow"; +import { radians3 } from "@thi.ng/vectors/radians"; +import { reflect } from "@thi.ng/vectors/reflect"; +import { refract } from "@thi.ng/vectors/refract"; +import { sign3 } from "@thi.ng/vectors/sign"; +import { sin3 } from "@thi.ng/vectors/sin"; +import { smoothStep3 } from "@thi.ng/vectors/smoothstep"; +import { sqrt3 } from "@thi.ng/vectors/sqrt"; +import { step3 } from "@thi.ng/vectors/step"; +import { sub3 } from "@thi.ng/vectors/sub"; +import { subN3 } from "@thi.ng/vectors/subn"; +import { tan3 } from "@thi.ng/vectors/tan"; import type { JSBuiltinsVec3 } from "../api"; export const VEC3: JSBuiltinsVec3 = { diff --git a/packages/shader-ast-js/src/env/vec4.ts b/packages/shader-ast-js/src/env/vec4.ts index 7955e81c25..a8e2520c2e 100644 --- a/packages/shader-ast-js/src/env/vec4.ts +++ b/packages/shader-ast-js/src/env/vec4.ts @@ -1,58 +1,55 @@ -import { - abs4, - acos4, - add4, - addN4, - asin4, - atan4, - atan_24, - ceil4, - clamp4, - cos4, - degrees4, - dist, - div4, - divN4, - dot4, - eq4, - exp4, - exp_24, - faceForward, - floor4, - fract4, - gt4, - gte4, - invSqrt4, - log4, - log_24, - lt4, - lte4, - mag, - max4, - min4, - mix4, - mixN4, - mod4, - modN4, - mul4, - mulN4, - neg, - neq4, - normalize, - pow4, - radians4, - reflect, - refract, - sign4, - sin4, - smoothStep4, - sqrt4, - step4, - sub4, - subN4, - tan4, - ZERO4, -} from "@thi.ng/vectors"; +import { abs4 } from "@thi.ng/vectors/abs"; +import { acos4 } from "@thi.ng/vectors/acos"; +import { add4 } from "@thi.ng/vectors/add"; +import { addN4 } from "@thi.ng/vectors/addn"; +import { ZERO4 } from "@thi.ng/vectors/api"; +import { asin4 } from "@thi.ng/vectors/asin"; +import { atan4, atan_24 } from "@thi.ng/vectors/atan"; +import { ceil4 } from "@thi.ng/vectors/ceil"; +import { clamp4 } from "@thi.ng/vectors/clamp"; +import { cos4 } from "@thi.ng/vectors/cos"; +import { degrees4 } from "@thi.ng/vectors/degrees"; +import { dist } from "@thi.ng/vectors/dist"; +import { div4 } from "@thi.ng/vectors/div"; +import { divN4 } from "@thi.ng/vectors/divn"; +import { dot4 } from "@thi.ng/vectors/dot"; +import { eq4 } from "@thi.ng/vectors/eq"; +import { exp4 } from "@thi.ng/vectors/exp"; +import { exp_24 } from "@thi.ng/vectors/exp_2"; +import { faceForward } from "@thi.ng/vectors/face-forward"; +import { floor4 } from "@thi.ng/vectors/floor"; +import { fract4 } from "@thi.ng/vectors/fract"; +import { gt4 } from "@thi.ng/vectors/gt"; +import { gte4 } from "@thi.ng/vectors/gte"; +import { invSqrt4 } from "@thi.ng/vectors/invsqrt"; +import { log4 } from "@thi.ng/vectors/log"; +import { log_24 } from "@thi.ng/vectors/log_2"; +import { lt4 } from "@thi.ng/vectors/lt"; +import { lte4 } from "@thi.ng/vectors/lte"; +import { mag } from "@thi.ng/vectors/mag"; +import { max4 } from "@thi.ng/vectors/max"; +import { min4 } from "@thi.ng/vectors/min"; +import { mix4 } from "@thi.ng/vectors/mix"; +import { mixN4 } from "@thi.ng/vectors/mixn"; +import { mod4 } from "@thi.ng/vectors/mod"; +import { modN4 } from "@thi.ng/vectors/modn"; +import { mul4 } from "@thi.ng/vectors/mul"; +import { mulN4 } from "@thi.ng/vectors/muln"; +import { neg } from "@thi.ng/vectors/neg"; +import { neq4 } from "@thi.ng/vectors/neq"; +import { normalize } from "@thi.ng/vectors/normalize"; +import { pow4 } from "@thi.ng/vectors/pow"; +import { radians4 } from "@thi.ng/vectors/radians"; +import { reflect } from "@thi.ng/vectors/reflect"; +import { refract } from "@thi.ng/vectors/refract"; +import { sign4 } from "@thi.ng/vectors/sign"; +import { sin4 } from "@thi.ng/vectors/sin"; +import { smoothStep4 } from "@thi.ng/vectors/smoothstep"; +import { sqrt4 } from "@thi.ng/vectors/sqrt"; +import { step4 } from "@thi.ng/vectors/step"; +import { sub4 } from "@thi.ng/vectors/sub"; +import { subN4 } from "@thi.ng/vectors/subn"; +import { tan4 } from "@thi.ng/vectors/tan"; import type { JSBuiltinsVec } from "../api"; export const VEC4: JSBuiltinsVec = { diff --git a/packages/shader-ast-js/src/runtime.ts b/packages/shader-ast-js/src/runtime.ts index 8024149bb6..4231833dd7 100644 --- a/packages/shader-ast-js/src/runtime.ts +++ b/packages/shader-ast-js/src/runtime.ts @@ -1,6 +1,8 @@ -import { assert, Fn } from "@thi.ng/api"; -import { clamp, clamp01 } from "@thi.ng/math"; -import { ABGR8888, PackedBuffer } from "@thi.ng/pixel"; +import type { Fn } from "@thi.ng/api"; +import { assert } from "@thi.ng/api/assert"; +import { clamp, clamp01 } from "@thi.ng/math/interval"; +import { ABGR8888 } from "@thi.ng/pixel/format/abgr8888"; +import { PackedBuffer } from "@thi.ng/pixel/packed"; import type { ReadonlyVec, Vec } from "@thi.ng/vectors"; const rgba2bgra = (rgba: ReadonlyVec) => diff --git a/packages/shader-ast-js/src/target.ts b/packages/shader-ast-js/src/target.ts index eb4269308e..24ebc884dd 100644 --- a/packages/shader-ast-js/src/target.ts +++ b/packages/shader-ast-js/src/target.ts @@ -1,6 +1,7 @@ import type { Fn } from "@thi.ng/api"; -import { isBoolean, isNumber } from "@thi.ng/checks"; -import { unsupported } from "@thi.ng/errors"; +import { isBoolean } from "@thi.ng/checks/is-boolean"; +import { isNumber } from "@thi.ng/checks/is-number"; +import { unsupported } from "@thi.ng/errors/unsupported"; import { defTarget, Func, @@ -188,9 +189,6 @@ export const targetJS = () => { case "uvec2": case "uvec3": case "uvec4": - case "bvec2": - case "bvec3": - case "bvec4": case "mat2": case "mat3": case "mat4": diff --git a/packages/shader-ast/src/ast/assign.ts b/packages/shader-ast/src/ast/assign.ts index ba6f0df633..6f4addf3a8 100644 --- a/packages/shader-ast/src/ast/assign.ts +++ b/packages/shader-ast/src/ast/assign.ts @@ -1,4 +1,4 @@ -import { assert } from "@thi.ng/api"; +import { assert } from "@thi.ng/api/assert"; import type { Assign, Swizzle, Term } from "../api/nodes"; import type { Assignable, Type } from "../api/types"; diff --git a/packages/shader-ast/src/ast/checks.ts b/packages/shader-ast/src/ast/checks.ts index aeb7bee282..c365507f15 100644 --- a/packages/shader-ast/src/ast/checks.ts +++ b/packages/shader-ast/src/ast/checks.ts @@ -1,4 +1,6 @@ -import { isArrayLike, isNumber, isPlainObject } from "@thi.ng/checks"; +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 type { Lit, Term } from "../api/nodes"; import type { BoolTerm, FloatTerm, IntTerm, UintTerm } from "../api/terms"; import type { BVec, IVec, UVec, Vec } from "../api/types"; diff --git a/packages/shader-ast/src/ast/function.ts b/packages/shader-ast/src/ast/function.ts index bd47d98e89..00c260eecc 100644 --- a/packages/shader-ast/src/ast/function.ts +++ b/packages/shader-ast/src/ast/function.ts @@ -1,5 +1,6 @@ -import { assert, Nullable } from "@thi.ng/api"; -import { isString } from "@thi.ng/checks"; +import type { Nullable } from "@thi.ng/api"; +import { assert } from "@thi.ng/api/assert"; +import { isString } from "@thi.ng/checks/is-string"; import type { Arg, Arg1, diff --git a/packages/shader-ast/src/ast/indexed.ts b/packages/shader-ast/src/ast/indexed.ts index 9700c1fde1..16c6a6f73d 100644 --- a/packages/shader-ast/src/ast/indexed.ts +++ b/packages/shader-ast/src/ast/indexed.ts @@ -1,4 +1,4 @@ -import { isNumber } from "@thi.ng/checks"; +import { isNumber } from "@thi.ng/checks/is-number"; import type { Index, IndexM, Sym } from "../api/nodes"; import type { UintTerm } from "../api/terms"; import type { diff --git a/packages/shader-ast/src/ast/lit.ts b/packages/shader-ast/src/ast/lit.ts index 8c79912099..b3fdd2bc66 100644 --- a/packages/shader-ast/src/ast/lit.ts +++ b/packages/shader-ast/src/ast/lit.ts @@ -1,5 +1,6 @@ import type { Fn } from "@thi.ng/api"; -import { isBoolean, isNumber } from "@thi.ng/checks"; +import { isBoolean } from "@thi.ng/checks/is-boolean"; +import { isNumber } from "@thi.ng/checks/is-number"; import type { Lit, Term } from "../api/nodes"; import type { BVec2Term, diff --git a/packages/shader-ast/src/ast/ops.ts b/packages/shader-ast/src/ast/ops.ts index 2e7b3d2a22..6daa83836e 100644 --- a/packages/shader-ast/src/ast/ops.ts +++ b/packages/shader-ast/src/ast/ops.ts @@ -1,5 +1,5 @@ import type { IObjectOf } from "@thi.ng/api"; -import { isNumber } from "@thi.ng/checks"; +import { isNumber } from "@thi.ng/checks/is-number"; import type { Op1, Op2, Sym, Term } from "../api/nodes"; import type { ComparisonOperator, Operator } from "../api/ops"; import type { diff --git a/packages/shader-ast/src/ast/scope.ts b/packages/shader-ast/src/ast/scope.ts index 1ba88c6c7a..cae956c097 100644 --- a/packages/shader-ast/src/ast/scope.ts +++ b/packages/shader-ast/src/ast/scope.ts @@ -1,5 +1,5 @@ import type { Fn, Fn2 } from "@thi.ng/api"; -import { isArray } from "@thi.ng/checks"; +import { isArray } from "@thi.ng/checks/is-array"; import { DGraph } from "@thi.ng/dgraph"; import type { Assign, diff --git a/packages/shader-ast/src/ast/sym.ts b/packages/shader-ast/src/ast/sym.ts index 921c85bad3..4e358c2dab 100644 --- a/packages/shader-ast/src/ast/sym.ts +++ b/packages/shader-ast/src/ast/sym.ts @@ -1,6 +1,6 @@ -import { assert } from "@thi.ng/api"; -import { isString } from "@thi.ng/checks"; -import { illegalArgs } from "@thi.ng/errors"; +import { assert } from "@thi.ng/api/assert"; +import { isString } from "@thi.ng/checks/is-string"; +import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; import type { Lit, Sym, Term } from "../api/nodes"; import type { SymOpts } from "../api/syms"; import type { ArrayTypeMap, Type } from "../api/types"; diff --git a/packages/shader-ast/src/builtin/texture.ts b/packages/shader-ast/src/builtin/texture.ts index b8f4060af4..a03ed2af8b 100644 --- a/packages/shader-ast/src/builtin/texture.ts +++ b/packages/shader-ast/src/builtin/texture.ts @@ -1,4 +1,4 @@ -import { illegalArgs } from "@thi.ng/errors"; +import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; import type { FnCall, Sym, Term } from "../api/nodes"; import type { FloatTerm, diff --git a/packages/shader-ast/src/logger.ts b/packages/shader-ast/src/logger.ts index c67c890f11..a0c4c5369e 100644 --- a/packages/shader-ast/src/logger.ts +++ b/packages/shader-ast/src/logger.ts @@ -1,4 +1,5 @@ -import { ILogger, NULL_LOGGER } from "@thi.ng/api"; +import type { ILogger } from "@thi.ng/api"; +import { NULL_LOGGER } from "@thi.ng/api/logger"; export let LOGGER = NULL_LOGGER; diff --git a/packages/shader-ast/src/optimize.ts b/packages/shader-ast/src/optimize.ts index 7b12d98223..1441b69574 100644 --- a/packages/shader-ast/src/optimize.ts +++ b/packages/shader-ast/src/optimize.ts @@ -1,6 +1,11 @@ -import { Fn, IObjectOf, LogLevel } from "@thi.ng/api"; -import { DEFAULT, defmulti } from "@thi.ng/defmulti"; -import { clamp, deg, fract, mix, mod, rad } from "@thi.ng/math"; +import type { Fn, IObjectOf } from "@thi.ng/api"; +import { LogLevel } from "@thi.ng/api/api/logger"; +import { DEFAULT } from "@thi.ng/defmulti/constants"; +import { defmulti } from "@thi.ng/defmulti/defmulti"; +import { deg, rad } from "@thi.ng/math/angle"; +import { clamp } from "@thi.ng/math/interval"; +import { mix } from "@thi.ng/math/mix"; +import { fract, mod } from "@thi.ng/math/prec"; import type { FnCall, Lit, Op1, Op2, Swizzle, Term } from "./api/nodes"; import type { Operator } from "./api/ops"; import type { Swizzle4_1 } from "./api/swizzles"; diff --git a/packages/shader-ast/src/target.ts b/packages/shader-ast/src/target.ts index 8d96b6bba3..4ea3f369b9 100644 --- a/packages/shader-ast/src/target.ts +++ b/packages/shader-ast/src/target.ts @@ -1,6 +1,7 @@ import type { Fn } from "@thi.ng/api"; -import { DEFAULT, defmulti } from "@thi.ng/defmulti"; -import { unsupported } from "@thi.ng/errors"; +import { DEFAULT } from "@thi.ng/defmulti/constants"; +import { defmulti } from "@thi.ng/defmulti/defmulti"; +import { unsupported } from "@thi.ng/errors/unsupported"; import type { Term } from "./api/nodes"; import type { TargetImpl } from "./api/target"; diff --git a/packages/simd/src/index.ts b/packages/simd/src/index.ts index d5c0b8d4a1..ec3354165a 100644 --- a/packages/simd/src/index.ts +++ b/packages/simd/src/index.ts @@ -1,4 +1,4 @@ -import { base64Decode } from "@thi.ng/transducers-binary"; +import { base64Decode } from "@thi.ng/transducers-binary/base64"; import { BINARY } from "./binary"; import type { SIMD } from "./api"; diff --git a/packages/soa/src/aos.ts b/packages/soa/src/aos.ts index 7aed161db3..b8f176a2a2 100644 --- a/packages/soa/src/aos.ts +++ b/packages/soa/src/aos.ts @@ -1,5 +1,6 @@ -import { SIZEOF } from "@thi.ng/api"; -import { align, Pow2 } from "@thi.ng/binary"; +import { SIZEOF } from "@thi.ng/api/api/typedarray"; +import type { Pow2 } from "@thi.ng/binary"; +import { align } from "@thi.ng/binary/align"; import type { AOSSpecs, SOASpecs } from "./api"; import { SOA } from "./soa"; import { prepareSpec } from "./utils"; diff --git a/packages/soa/src/serialize.ts b/packages/soa/src/serialize.ts index c410315af3..458a1dc5e0 100644 --- a/packages/soa/src/serialize.ts +++ b/packages/soa/src/serialize.ts @@ -1,5 +1,5 @@ -import { assert } from "@thi.ng/api"; -import { utf8Decode, utf8Encode } from "@thi.ng/transducers-binary"; +import { assert } from "@thi.ng/api/assert"; +import { utf8Decode, utf8Encode } from "@thi.ng/transducers-binary/utf8"; import type { Vec } from "@thi.ng/vectors"; import type { SerializedTuple, diff --git a/packages/soa/src/soa.ts b/packages/soa/src/soa.ts index b92013c7a3..ab74365c08 100644 --- a/packages/soa/src/soa.ts +++ b/packages/soa/src/soa.ts @@ -1,5 +1,7 @@ -import { assert, ILength, SIZEOF, TypedArray, typedArray } from "@thi.ng/api"; -import { ensureIndex } from "@thi.ng/errors"; +import type { ILength } from "@thi.ng/api"; +import { SIZEOF, TypedArray, typedArray } from "@thi.ng/api/api/typedarray"; +import { assert } from "@thi.ng/api/assert"; +import { ensureIndex } from "@thi.ng/errors/out-of-bounds"; import type { ReadonlyVec, Vec } from "@thi.ng/vectors"; import type { SOAAttribSpec, SOASpecs, SOATuple } from "./api"; import { prepareSpec } from "./utils"; diff --git a/packages/sparse/src/amatrix.ts b/packages/sparse/src/amatrix.ts index e1f123b4b6..cb07f43551 100644 --- a/packages/sparse/src/amatrix.ts +++ b/packages/sparse/src/amatrix.ts @@ -1,4 +1,4 @@ -import { assert } from "@thi.ng/api"; +import { assert } from "@thi.ng/api/assert"; import type { NzEntry } from "./api"; export abstract class ASparseMatrix { diff --git a/packages/sparse/src/coo.ts b/packages/sparse/src/coo.ts index 48c7d81672..d4152b2f1a 100644 --- a/packages/sparse/src/coo.ts +++ b/packages/sparse/src/coo.ts @@ -1,5 +1,5 @@ -import { ensureIndex2 } from "@thi.ng/errors"; -import { partition } from "@thi.ng/transducers"; +import { ensureIndex2 } from "@thi.ng/errors/out-of-bounds"; +import { partition } from "@thi.ng/transducers/xform/partition"; import { ASparseMatrix } from "./amatrix"; import type { NzEntry } from "./api"; import { CSC } from "./csc"; diff --git a/packages/sparse/src/csc.ts b/packages/sparse/src/csc.ts index 6f63e2cea0..89b6c40174 100644 --- a/packages/sparse/src/csc.ts +++ b/packages/sparse/src/csc.ts @@ -1,5 +1,5 @@ -import { assert } from "@thi.ng/api"; -import { ensureIndex2 } from "@thi.ng/errors"; +import { assert } from "@thi.ng/api/assert"; +import { ensureIndex2 } from "@thi.ng/errors/out-of-bounds"; import { ASparseMatrix } from "./amatrix"; import type { NzEntry } from "./api"; import { at, compress, diag, setAt } from "./compressed"; diff --git a/packages/sparse/src/csr.ts b/packages/sparse/src/csr.ts index e2608eabfb..15bd2f620b 100644 --- a/packages/sparse/src/csr.ts +++ b/packages/sparse/src/csr.ts @@ -1,5 +1,5 @@ -import { assert } from "@thi.ng/api"; -import { ensureIndex2 } from "@thi.ng/errors"; +import { assert } from "@thi.ng/api/assert"; +import { ensureIndex2 } from "@thi.ng/errors/out-of-bounds"; import { ASparseMatrix } from "./amatrix"; import type { NzEntry } from "./api"; import { at, compress, diag, remove, setAt } from "./compressed"; diff --git a/packages/sparse/src/diag.ts b/packages/sparse/src/diag.ts index e24590c07e..8a56e103fe 100644 --- a/packages/sparse/src/diag.ts +++ b/packages/sparse/src/diag.ts @@ -1,5 +1,5 @@ -import { assert } from "@thi.ng/api"; -import { ensureIndex2 } from "@thi.ng/errors"; +import { assert } from "@thi.ng/api/assert"; +import { ensureIndex2 } from "@thi.ng/errors/out-of-bounds"; import { ASparseMatrix } from "./amatrix"; import type { NzEntry } from "./api"; import { CSC } from "./csc"; diff --git a/packages/sparse/src/vec.ts b/packages/sparse/src/vec.ts index 87581d5d8f..c5cf179cac 100644 --- a/packages/sparse/src/vec.ts +++ b/packages/sparse/src/vec.ts @@ -1,5 +1,6 @@ -import { assert, FnN2 } from "@thi.ng/api"; -import { ensureIndex } from "@thi.ng/errors"; +import type { FnN2 } from "@thi.ng/api"; +import { assert } from "@thi.ng/api/assert"; +import { ensureIndex } from "@thi.ng/errors/out-of-bounds"; import type { NzEntry } from "./api"; export type BinOp = FnN2; diff --git a/packages/strings/src/center.ts b/packages/strings/src/center.ts index 3ecab1fccb..1bce346830 100644 --- a/packages/strings/src/center.ts +++ b/packages/strings/src/center.ts @@ -1,4 +1,4 @@ -import { memoizeJ } from "@thi.ng/memoize"; +import { memoizeJ } from "@thi.ng/memoize/memoizej"; import type { Stringer } from "./api"; import { repeat } from "./repeat"; import { truncate } from "./truncate"; diff --git a/packages/strings/src/float.ts b/packages/strings/src/float.ts index f518a496c0..14d9beb814 100644 --- a/packages/strings/src/float.ts +++ b/packages/strings/src/float.ts @@ -1,4 +1,4 @@ -import { memoizeJ } from "@thi.ng/memoize"; +import { memoizeJ } from "@thi.ng/memoize/memoizej"; import type { Stringer } from "./api"; import { padLeft } from "./pad-left"; @@ -12,14 +12,12 @@ import { padLeft } from "./pad-left"; * @param len - number of fractional digits * @param special - true, if special handling for NaN/Infinity values */ -export const float: ( - prec: number, - special?: boolean -) => Stringer = memoizeJ((prec, special = false) => - special - ? (x: number) => nanOrInf(x) || x.toFixed(prec) - : (x: number) => x.toFixed(prec) -); +export const float: (prec: number, special?: boolean) => Stringer = + memoizeJ((prec, special = false) => + special + ? (x: number) => nanOrInf(x) || x.toFixed(prec) + : (x: number) => x.toFixed(prec) + ); /** * Similar to `float`, returns {@link Stringer} which formats numbers to given diff --git a/packages/strings/src/int.ts b/packages/strings/src/int.ts index 9e7d2a55eb..a4425d8c99 100644 --- a/packages/strings/src/int.ts +++ b/packages/strings/src/int.ts @@ -1,10 +1,8 @@ -import { memoizeJ } from "@thi.ng/memoize"; +import { memoizeJ } from "@thi.ng/memoize/memoizej"; import type { Stringer } from "./api"; export const int: Stringer = (x) => String(Math.trunc(x)); -export const intLocale: ( - locale?: string -) => Stringer = memoizeJ((locale) => (x) => - Math.trunc(x).toLocaleString(locale) +export const intLocale: (locale?: string) => Stringer = memoizeJ( + (locale) => (x) => Math.trunc(x).toLocaleString(locale) ); diff --git a/packages/strings/src/interpolate.ts b/packages/strings/src/interpolate.ts index 77a86c1097..06a81a5486 100644 --- a/packages/strings/src/interpolate.ts +++ b/packages/strings/src/interpolate.ts @@ -1,5 +1,5 @@ import type { IObjectOf, NumOrString } from "@thi.ng/api"; -import { illegalArgs } from "@thi.ng/errors"; +import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; const TPL = /\{(\d+)\}/g; const TPL_K = /\{([a-z0-9_.-]+)\}/gi; diff --git a/packages/strings/src/join.ts b/packages/strings/src/join.ts index c492bd219f..156b3d025b 100644 --- a/packages/strings/src/join.ts +++ b/packages/strings/src/join.ts @@ -1,4 +1,4 @@ -import { memoize1 } from "@thi.ng/memoize"; +import { memoize1 } from "@thi.ng/memoize/memoize1"; import type { Stringer } from "./api"; /** @@ -21,6 +21,6 @@ import type { Stringer } from "./api"; * // "f 1/2 3/4 5/6" * ``` */ -export const join = memoize1>((sep) => (x) => - x.join(sep) +export const join = memoize1>( + (sep) => (x) => x.join(sep) ); diff --git a/packages/strings/src/pad-left.ts b/packages/strings/src/pad-left.ts index ce21563659..b2c24ad35d 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"; +import { memoizeJ } from "@thi.ng/memoize/memoizej"; import type { Stringer } from "./api"; import { repeat } from "./repeat"; diff --git a/packages/strings/src/pad-right.ts b/packages/strings/src/pad-right.ts index cbf65e18d6..f8b38c1397 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"; +import { memoizeJ } from "@thi.ng/memoize/memoizej"; import type { Stringer } from "./api"; import { repeat } from "./repeat"; diff --git a/packages/strings/src/radix.ts b/packages/strings/src/radix.ts index 0488e4a211..4981b4480a 100644 --- a/packages/strings/src/radix.ts +++ b/packages/strings/src/radix.ts @@ -5,7 +5,7 @@ import { U64HL, U8 as $8, } from "@thi.ng/hex"; -import { memoizeJ } from "@thi.ng/memoize"; +import { memoizeJ } from "@thi.ng/memoize/memoizej"; import type { Stringer } from "./api"; import { repeat } from "./repeat"; diff --git a/packages/strings/src/repeat.ts b/packages/strings/src/repeat.ts index 89f09b4b9a..1d239d7021 100644 --- a/packages/strings/src/repeat.ts +++ b/packages/strings/src/repeat.ts @@ -1,4 +1,4 @@ -import { memoizeJ } from "@thi.ng/memoize"; +import { memoizeJ } from "@thi.ng/memoize/memoizej"; /** * @param ch - character diff --git a/packages/strings/src/splice.ts b/packages/strings/src/splice.ts index 1b7e650a54..58e7821e70 100644 --- a/packages/strings/src/splice.ts +++ b/packages/strings/src/splice.ts @@ -1,4 +1,4 @@ -import { illegalArgs } from "@thi.ng/errors"; +import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; /** * Forms a new strings which inserts given `insert` string into `src` diff --git a/packages/strings/src/trim.ts b/packages/strings/src/trim.ts index 7ac502783a..d875f696f9 100644 --- a/packages/strings/src/trim.ts +++ b/packages/strings/src/trim.ts @@ -1,4 +1,4 @@ -import { memoize1 } from "@thi.ng/memoize"; +import { memoize1 } from "@thi.ng/memoize/memoize1"; import type { Stringer } from "./api"; /** diff --git a/packages/strings/src/truncate-left.ts b/packages/strings/src/truncate-left.ts index 98ef1bee4c..810c203941 100644 --- a/packages/strings/src/truncate-left.ts +++ b/packages/strings/src/truncate-left.ts @@ -1,9 +1,11 @@ -import { memoizeJ } from "@thi.ng/memoize"; +import { memoizeJ } from "@thi.ng/memoize/memoizej"; import type { Stringer } from "./api"; -export const truncateLeft: ( - n: number, - prefix?: string -) => Stringer = memoizeJ((n: number, prefix = "") => (x) => - x.length > n ? prefix + x.substr(x.length - n + prefix.length) : x -); +export const truncateLeft: (n: number, prefix?: string) => Stringer = + memoizeJ( + (n: number, prefix = "") => + (x) => + x.length > n + ? prefix + x.substr(x.length - n + prefix.length) + : x + ); diff --git a/packages/strings/src/truncate.ts b/packages/strings/src/truncate.ts index bc81b20001..ce50c97050 100644 --- a/packages/strings/src/truncate.ts +++ b/packages/strings/src/truncate.ts @@ -1,12 +1,12 @@ -import { memoizeJ } from "@thi.ng/memoize"; +import { memoizeJ } from "@thi.ng/memoize/memoizej"; import type { Stringer } from "./api"; -export const truncate: ( - n: number, - suffix?: string -) => Stringer = memoizeJ((n: number, suffix = "") => (x) => - x.length > n ? x.substr(0, n - suffix.length) + suffix : x -); +export const truncate: (n: number, suffix?: string) => Stringer = + memoizeJ( + (n: number, suffix = "") => + (x) => + x.length > n ? x.substr(0, n - suffix.length) + suffix : x + ); /** * Alias for {@link truncate} diff --git a/packages/strings/src/units.ts b/packages/strings/src/units.ts index 667b93b0c6..3050076687 100644 --- a/packages/strings/src/units.ts +++ b/packages/strings/src/units.ts @@ -1,4 +1,4 @@ -import { memoizeJ } from "@thi.ng/memoize"; +import { memoizeJ } from "@thi.ng/memoize/memoizej"; import type { Stringer } from "./api"; type UnitDefs = [number, string, number?][]; diff --git a/packages/strings/src/vector.ts b/packages/strings/src/vector.ts index 66f4571c02..54c859abbd 100644 --- a/packages/strings/src/vector.ts +++ b/packages/strings/src/vector.ts @@ -1,4 +1,4 @@ -import { memoizeJ } from "@thi.ng/memoize"; +import { memoizeJ } from "@thi.ng/memoize/memoizej"; import type { Stringer } from "./api"; import { float } from "./float"; diff --git a/packages/strings/src/wrap.ts b/packages/strings/src/wrap.ts index c915deaa6d..a2c34640c9 100644 --- a/packages/strings/src/wrap.ts +++ b/packages/strings/src/wrap.ts @@ -1,10 +1,10 @@ -import { memoizeJ } from "@thi.ng/memoize"; +import { memoizeJ } from "@thi.ng/memoize/memoizej"; import type { Stringer } from "./api"; /** * Returns a {@link Stringer} which wrap inputs with given `pad` string on * both sides. */ -export const wrap: ( - pad: string -) => Stringer = memoizeJ((pad: string) => (x: any) => pad + x + pad); +export const wrap: (pad: string) => Stringer = memoizeJ( + (pad: string) => (x: any) => pad + x + pad +); diff --git a/packages/system/src/api.ts b/packages/system/src/api.ts index 53385620b8..898a93740c 100644 --- a/packages/system/src/api.ts +++ b/packages/system/src/api.ts @@ -1,4 +1,5 @@ -import { Fn, ILogger, Keys, NULL_LOGGER } from "@thi.ng/api"; +import type { Fn, ILogger, Keys } from "@thi.ng/api"; +import { NULL_LOGGER } from "@thi.ng/api/logger"; export interface ILifecycle { /** diff --git a/packages/text-canvas/src/bars.ts b/packages/text-canvas/src/bars.ts index baa5307acf..177285df0a 100644 --- a/packages/text-canvas/src/bars.ts +++ b/packages/text-canvas/src/bars.ts @@ -1,6 +1,9 @@ -import { fitClamped, fract } from "@thi.ng/math"; -import { padLeft, padRight, repeat } from "@thi.ng/strings"; -import { map } from "@thi.ng/transducers"; +import { fitClamped } from "@thi.ng/math/fit"; +import { fract } from "@thi.ng/math/prec"; +import { padLeft } from "@thi.ng/strings/pad-left"; +import { padRight } from "@thi.ng/strings/pad-right"; +import { repeat } from "@thi.ng/strings/repeat"; +import { map } from "@thi.ng/transducers/xform/map"; import { BARS_H, BARS_V } from "./api"; export const barChartHLines = ( diff --git a/packages/text-canvas/src/canvas.ts b/packages/text-canvas/src/canvas.ts index 20395aa028..261548b4bb 100644 --- a/packages/text-canvas/src/canvas.ts +++ b/packages/text-canvas/src/canvas.ts @@ -1,6 +1,6 @@ import type { Fn0, NumOrString } from "@thi.ng/api"; -import { peek } from "@thi.ng/arrays"; -import { clamp } from "@thi.ng/math"; +import { peek } from "@thi.ng/arrays/peek"; +import { clamp } from "@thi.ng/math/interval"; import { ClipRect, NONE, StrokeStyle, STYLE_ASCII } from "./api"; import { charCode, intersectRect } from "./utils"; diff --git a/packages/text-canvas/src/circle.ts b/packages/text-canvas/src/circle.ts index e3aa0d5e64..73ee2f00b5 100644 --- a/packages/text-canvas/src/circle.ts +++ b/packages/text-canvas/src/circle.ts @@ -1,5 +1,5 @@ import type { NumOrString } from "@thi.ng/api"; -import { peek } from "@thi.ng/arrays"; +import { peek } from "@thi.ng/arrays/peek"; import type { Canvas } from "./canvas"; import { hline } from "./hvline"; import { charCode, intersectRectCircle } from "./utils"; diff --git a/packages/text-canvas/src/format.ts b/packages/text-canvas/src/format.ts index 6093dda796..ac805141d8 100644 --- a/packages/text-canvas/src/format.ts +++ b/packages/text-canvas/src/format.ts @@ -1,5 +1,5 @@ -import { memoize1 } from "@thi.ng/memoize"; -import { U8 } from "@thi.ng/strings"; +import { memoize1 } from "@thi.ng/memoize/memoize1"; +import { U8 } from "@thi.ng/strings/radix"; import type { HtmlFormatOpts, StringFormat } from "./api"; import { defFormat } from "./string"; diff --git a/packages/text-canvas/src/hvline.ts b/packages/text-canvas/src/hvline.ts index 23e3f1767f..9fec61c45b 100644 --- a/packages/text-canvas/src/hvline.ts +++ b/packages/text-canvas/src/hvline.ts @@ -1,5 +1,5 @@ import type { NumOrString } from "@thi.ng/api"; -import { peek } from "@thi.ng/arrays"; +import { peek } from "@thi.ng/arrays/peek"; import type { Canvas } from "./canvas"; import { charCode } from "./utils"; diff --git a/packages/text-canvas/src/image.ts b/packages/text-canvas/src/image.ts index 9dd4dfa501..bba92663bb 100644 --- a/packages/text-canvas/src/image.ts +++ b/packages/text-canvas/src/image.ts @@ -1,7 +1,7 @@ import type { UIntArray } from "@thi.ng/api"; -import { peek } from "@thi.ng/arrays"; -import { isNumber } from "@thi.ng/checks"; -import { clamp0 } from "@thi.ng/math"; +import { peek } from "@thi.ng/arrays/peek"; +import { isNumber } from "@thi.ng/checks/is-number"; +import { clamp0 } from "@thi.ng/math/interval"; import { ClipRect, ImageOpts, SHADES_BLOCK } from "./api"; import { canvas, Canvas } from "./canvas"; import { FMT_ANSI565 } from "./format"; diff --git a/packages/text-canvas/src/line.ts b/packages/text-canvas/src/line.ts index 91b0766717..fd3abe7301 100644 --- a/packages/text-canvas/src/line.ts +++ b/packages/text-canvas/src/line.ts @@ -1,6 +1,6 @@ import type { NumOrString } from "@thi.ng/api"; -import { peek } from "@thi.ng/arrays"; -import { liangBarsky2Raw } from "@thi.ng/geom-clip-line"; +import { peek } from "@thi.ng/arrays/peek"; +import { liangBarsky2Raw } from "@thi.ng/geom-clip-line/liang-barsky"; import type { Canvas } from "./canvas"; import { charCode } from "./utils"; diff --git a/packages/text-canvas/src/rect.ts b/packages/text-canvas/src/rect.ts index e3b4736e8f..a6c42dcc08 100644 --- a/packages/text-canvas/src/rect.ts +++ b/packages/text-canvas/src/rect.ts @@ -1,5 +1,5 @@ import type { NumOrString } from "@thi.ng/api"; -import { peek } from "@thi.ng/arrays"; +import { peek } from "@thi.ng/arrays/peek"; import type { Canvas } from "./canvas"; import { hline, vline } from "./hvline"; import { charCode } from "./utils"; diff --git a/packages/text-canvas/src/table.ts b/packages/text-canvas/src/table.ts index aec9d23ca1..f61974a905 100644 --- a/packages/text-canvas/src/table.ts +++ b/packages/text-canvas/src/table.ts @@ -1,6 +1,6 @@ -import { peek } from "@thi.ng/arrays"; -import { isString } from "@thi.ng/checks"; -import { wordWrapLines } from "@thi.ng/strings"; +import { peek } from "@thi.ng/arrays/peek"; +import { isString } from "@thi.ng/checks/is-string"; +import { wordWrapLines } from "@thi.ng/strings/word-wrap"; import { Border, TableOpts } from "./api"; import { beginClip, diff --git a/packages/text-canvas/src/text.ts b/packages/text-canvas/src/text.ts index 5e22779bc3..b785677fa6 100644 --- a/packages/text-canvas/src/text.ts +++ b/packages/text-canvas/src/text.ts @@ -1,6 +1,6 @@ -import { peek } from "@thi.ng/arrays"; -import { clamp0 } from "@thi.ng/math"; -import { wordWrapLines } from "@thi.ng/strings"; +import { peek } from "@thi.ng/arrays/peek"; +import { clamp0 } from "@thi.ng/math/interval"; +import { wordWrapLines } from "@thi.ng/strings/word-wrap"; import type { TextBoxOpts } from "./api"; import { beginClip, beginStyle, Canvas, endClip, endStyle } from "./canvas"; import { fillRect, strokeRect } from "./rect"; diff --git a/packages/transducers-binary/src/base64.ts b/packages/transducers-binary/src/base64.ts index 9f38e42f15..44303a7809 100644 --- a/packages/transducers-binary/src/base64.ts +++ b/packages/transducers-binary/src/base64.ts @@ -1,13 +1,7 @@ -import { - $iter, - compR, - isReduced, - iterator, - iterator1, - reduced, - Reducer, - Transducer, -} from "@thi.ng/transducers"; +import type { Reducer, Transducer } from "@thi.ng/transducers"; +import { compR } from "@thi.ng/transducers/func/compr"; +import { $iter, iterator, iterator1 } from "@thi.ng/transducers/iterator"; +import { isReduced, reduced } from "@thi.ng/transducers/reduced"; const B64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; diff --git a/packages/transducers-binary/src/bits.ts b/packages/transducers-binary/src/bits.ts index 96b9ab2886..7afd26cd19 100644 --- a/packages/transducers-binary/src/bits.ts +++ b/packages/transducers-binary/src/bits.ts @@ -1,11 +1,7 @@ -import { - $iter, - compR, - isReduced, - iterator, - Reducer, - Transducer, -} from "@thi.ng/transducers"; +import type { Reducer, Transducer } from "@thi.ng/transducers"; +import { compR } from "@thi.ng/transducers/func/compr"; +import { $iter, iterator } from "@thi.ng/transducers/iterator"; +import { isReduced } from "@thi.ng/transducers/reduced"; /** * Transforms incoming numbers into their bitstream using specified diff --git a/packages/transducers-binary/src/bytes.ts b/packages/transducers-binary/src/bytes.ts index fe699ca2bb..74a6592514 100644 --- a/packages/transducers-binary/src/bytes.ts +++ b/packages/transducers-binary/src/bytes.ts @@ -1,12 +1,15 @@ -import { bytes16, bytes24, bytes32, bytesF32, bytesF64 } from "@thi.ng/binary"; -import { unsupported } from "@thi.ng/errors"; import { - iterator, - mapcat, - reduce, - Reducer, - Transducer, -} from "@thi.ng/transducers"; + bytes16, + bytes24, + bytes32, + bytesF32, + bytesF64, +} from "@thi.ng/binary/bytes"; +import { unsupported } from "@thi.ng/errors/unsupported"; +import type { Reducer, Transducer } from "@thi.ng/transducers"; +import { iterator } from "@thi.ng/transducers/iterator"; +import { reduce } from "@thi.ng/transducers/reduce"; +import { mapcat } from "@thi.ng/transducers/xform/mapcat"; import type { BinStructItem } from "./api"; import { utf8Encode } from "./utf8"; diff --git a/packages/transducers-binary/src/hex-dump.ts b/packages/transducers-binary/src/hex-dump.ts index 310c11f955..d16da9a7ac 100644 --- a/packages/transducers-binary/src/hex-dump.ts +++ b/packages/transducers-binary/src/hex-dump.ts @@ -1,15 +1,12 @@ -import { juxt } from "@thi.ng/compose"; +import { juxt } from "@thi.ng/compose/juxt"; import { U32, U8 } from "@thi.ng/hex"; -import { - $iter, - comp, - iterator, - map, - mapIndexed, - padLast, - partition, - Transducer, -} from "@thi.ng/transducers"; +import type { Transducer } from "@thi.ng/transducers"; +import { comp } from "@thi.ng/transducers/func/comp"; +import { $iter, iterator } from "@thi.ng/transducers/iterator"; +import { map } from "@thi.ng/transducers/xform/map"; +import { mapIndexed } from "@thi.ng/transducers/xform/map-indexed"; +import { padLast } from "@thi.ng/transducers/xform/pad-last"; +import { partition } from "@thi.ng/transducers/xform/partition"; import type { HexDumpOpts } from "./api"; /** diff --git a/packages/transducers-binary/src/partition-bits.ts b/packages/transducers-binary/src/partition-bits.ts index 3ba86d18c7..50829d8ebd 100644 --- a/packages/transducers-binary/src/partition-bits.ts +++ b/packages/transducers-binary/src/partition-bits.ts @@ -1,10 +1,6 @@ -import { - $iter, - isReduced, - iterator, - Reducer, - Transducer, -} from "@thi.ng/transducers"; +import type { Reducer, Transducer } from "@thi.ng/transducers"; +import { $iter, iterator } from "@thi.ng/transducers/iterator"; +import { isReduced } from "@thi.ng/transducers/reduced"; /** * Transducer. diff --git a/packages/transducers-binary/src/random-bits.ts b/packages/transducers-binary/src/random-bits.ts index 5ff86434d4..fd749f7b99 100644 --- a/packages/transducers-binary/src/random-bits.ts +++ b/packages/transducers-binary/src/random-bits.ts @@ -1,5 +1,6 @@ -import { IRandom, SYSTEM } from "@thi.ng/random"; -import { repeatedly } from "@thi.ng/transducers"; +import type { IRandom } from "@thi.ng/random"; +import { SYSTEM } from "@thi.ng/random/system"; +import { repeatedly } from "@thi.ng/transducers/iter/repeatedly"; /** * Returns an iterator of random bits, with 1's occurring w/ given diff --git a/packages/transducers-binary/src/utf8.ts b/packages/transducers-binary/src/utf8.ts index 913e55f85e..ded3f45683 100644 --- a/packages/transducers-binary/src/utf8.ts +++ b/packages/transducers-binary/src/utf8.ts @@ -1,11 +1,7 @@ -import { - compR, - isReduced, - iterator, - iterator1, - Reducer, - Transducer, -} from "@thi.ng/transducers"; +import type { Reducer, Transducer } from "@thi.ng/transducers"; +import { compR } from "@thi.ng/transducers/func/compr"; +import { iterator, iterator1 } from "@thi.ng/transducers/iterator"; +import { isReduced } from "@thi.ng/transducers/reduced"; /** * Transducer which decodes a byte input sequence into UTF-8 characters. diff --git a/packages/transducers-fsm/src/index.ts b/packages/transducers-fsm/src/index.ts index 256faf2f0c..6d50de25f1 100644 --- a/packages/transducers-fsm/src/index.ts +++ b/packages/transducers-fsm/src/index.ts @@ -1,11 +1,7 @@ import type { Fn0, IObjectOf } from "@thi.ng/api"; -import { - compR, - ensureReduced, - isReduced, - Reducer, - Transducer, -} from "@thi.ng/transducers"; +import type { Reducer, Transducer } from "@thi.ng/transducers"; +import { compR } from "@thi.ng/transducers/func/compr"; +import { ensureReduced, isReduced } from "@thi.ng/transducers/reduced"; export interface FSMState { state: PropertyKey; @@ -101,25 +97,25 @@ export interface FSMOpts { * * @param opts - */ -export const fsm = ( - opts: FSMOpts -): Transducer => (rfn: Reducer) => { - const states = opts.states; - const state = opts.init(); - const r = rfn[2]; - return compR(rfn, (acc, x) => { - const res: any = states[state.state](state, x); - if (res != null) { - for (let i = 0, n = (res).length; i < n; i++) { - acc = r(acc, res[i]); - if (isReduced(acc)) { - break; +export const fsm = + (opts: FSMOpts): Transducer => + (rfn: Reducer) => { + const states = opts.states; + const state = opts.init(); + const r = rfn[2]; + return compR(rfn, (acc, x) => { + const res: any = states[state.state](state, x); + if (res != null) { + for (let i = 0, n = (res).length; i < n; i++) { + acc = r(acc, res[i]); + if (isReduced(acc)) { + break; + } } } - } - if (state.state === opts.terminate) { - return ensureReduced(acc); - } - return acc; - }); -}; + if (state.state === opts.terminate) { + return ensureReduced(acc); + } + return acc; + }); + }; diff --git a/packages/transducers-hdom/src/index.ts b/packages/transducers-hdom/src/index.ts index b02fdfd135..6c00fb1b64 100644 --- a/packages/transducers-hdom/src/index.ts +++ b/packages/transducers-hdom/src/index.ts @@ -4,8 +4,9 @@ import { HDOMOpts, resolveRoot, } from "@thi.ng/hdom"; -import { derefContext } from "@thi.ng/hiccup"; -import { scan, Transducer } from "@thi.ng/transducers"; +import { derefContext } from "@thi.ng/hiccup/deref"; +import type { Transducer } from "@thi.ng/transducers"; +import { scan } from "@thi.ng/transducers/xform/scan"; /** * Side-effecting & stateful transducer which receives {@link diff --git a/packages/transducers-patch/src/patch-array.ts b/packages/transducers-patch/src/patch-array.ts index cb46af8abe..858b56f11f 100644 --- a/packages/transducers-patch/src/patch-array.ts +++ b/packages/transducers-patch/src/patch-array.ts @@ -1,6 +1,8 @@ -import { isString } from "@thi.ng/checks"; -import { illegalArgs, illegalArity } from "@thi.ng/errors"; -import { reduce, reducer, Reducer } from "@thi.ng/transducers"; +import { isString } from "@thi.ng/checks/is-string"; +import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; +import { illegalArity } from "@thi.ng/errors/illegal-arity"; +import type { Reducer } from "@thi.ng/transducers"; +import { reduce, reducer } from "@thi.ng/transducers/reduce"; import type { PatchArrayOp } from "./api"; /** diff --git a/packages/transducers-patch/src/patch-obj.ts b/packages/transducers-patch/src/patch-obj.ts index b4454040b2..dba33de833 100644 --- a/packages/transducers-patch/src/patch-obj.ts +++ b/packages/transducers-patch/src/patch-obj.ts @@ -1,7 +1,10 @@ -import { isString } from "@thi.ng/checks"; -import { illegalArgs } from "@thi.ng/errors"; -import { deleteInUnsafe, setInUnsafe, updateInUnsafe } from "@thi.ng/paths"; -import { reduce, reducer, Reducer } from "@thi.ng/transducers"; +import { isString } from "@thi.ng/checks/is-string"; +import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; +import { deleteInUnsafe } from "@thi.ng/paths/delete-in"; +import { setInUnsafe } from "@thi.ng/paths/set-in"; +import { updateInUnsafe } from "@thi.ng/paths/update-in"; +import type { Reducer } from "@thi.ng/transducers"; +import { reduce, reducer } from "@thi.ng/transducers/reduce"; import type { PatchObjOp } from "./api"; /** diff --git a/packages/transducers-stats/src/bollinger.ts b/packages/transducers-stats/src/bollinger.ts index 0d388b6879..8426f41c46 100644 --- a/packages/transducers-stats/src/bollinger.ts +++ b/packages/transducers-stats/src/bollinger.ts @@ -1,12 +1,10 @@ -import { - $iter, - comp, - drop, - map, - multiplex, - partition, - Transducer, -} from "@thi.ng/transducers"; +import type { Transducer } from "@thi.ng/transducers"; +import { comp } from "@thi.ng/transducers/func/comp"; +import { $iter } 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 { partition } from "@thi.ng/transducers/xform/partition"; 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 6a945a890f..1b972467d5 100644 --- a/packages/transducers-stats/src/donchian.ts +++ b/packages/transducers-stats/src/donchian.ts @@ -1,10 +1,8 @@ -import { - comp, - iterator, - map, - partition, - Transducer, -} from "@thi.ng/transducers"; +import type { Transducer } from "@thi.ng/transducers"; +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 { bounds } from "./bounds"; /** diff --git a/packages/transducers-stats/src/ema.ts b/packages/transducers-stats/src/ema.ts index 5b591707c7..ead3a0dc7e 100644 --- a/packages/transducers-stats/src/ema.ts +++ b/packages/transducers-stats/src/ema.ts @@ -1,5 +1,7 @@ -import { illegalArgs } from "@thi.ng/errors"; -import { compR, iterator1, Reducer, Transducer } from "@thi.ng/transducers"; +import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; +import type { Reducer, Transducer } from "@thi.ng/transducers"; +import { compR } from "@thi.ng/transducers/func/compr"; +import { iterator1 } from "@thi.ng/transducers/iterator"; /** * {@link 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 eb580e87e1..d933f9edbb 100644 --- a/packages/transducers-stats/src/hma.ts +++ b/packages/transducers-stats/src/hma.ts @@ -1,11 +1,9 @@ -import { - comp, - drop, - iterator1, - map, - multiplex, - Transducer, -} from "@thi.ng/transducers"; +import type { Transducer } from "@thi.ng/transducers"; +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 { wma } from "./wma"; /** diff --git a/packages/transducers-stats/src/macd.ts b/packages/transducers-stats/src/macd.ts index 6b11900d0d..6a293538f4 100644 --- a/packages/transducers-stats/src/macd.ts +++ b/packages/transducers-stats/src/macd.ts @@ -1,4 +1,7 @@ -import { $iter, compR, Reducer, step, Transducer } from "@thi.ng/transducers"; +import type { Reducer, Transducer } from "@thi.ng/transducers"; +import { compR } from "@thi.ng/transducers/func/compr"; +import { $iter } from "@thi.ng/transducers/iterator"; +import { step } from "@thi.ng/transducers/step"; import { ema } from "./ema"; export interface MACD { diff --git a/packages/transducers-stats/src/momentum.ts b/packages/transducers-stats/src/momentum.ts index ca43914331..fc077702da 100644 --- a/packages/transducers-stats/src/momentum.ts +++ b/packages/transducers-stats/src/momentum.ts @@ -1,6 +1,8 @@ -import { DCons } from "@thi.ng/dcons"; -import { illegalArgs } from "@thi.ng/errors"; -import { compR, iterator1, Reducer, Transducer } from "@thi.ng/transducers"; +import { DCons } from "@thi.ng/dcons/dcons"; +import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; +import type { Reducer, Transducer } from "@thi.ng/transducers"; +import { compR } from "@thi.ng/transducers/func/compr"; +import { iterator1 } from "@thi.ng/transducers/iterator"; /** * {@link en.wikipedia.org/wiki/Momentum_(technical_analysis)} diff --git a/packages/transducers-stats/src/roc.ts b/packages/transducers-stats/src/roc.ts index 0684edcd7d..555c66ce7e 100644 --- a/packages/transducers-stats/src/roc.ts +++ b/packages/transducers-stats/src/roc.ts @@ -1,6 +1,8 @@ -import { DCons } from "@thi.ng/dcons"; -import { illegalArgs } from "@thi.ng/errors"; -import { compR, iterator1, Reducer, Transducer } from "@thi.ng/transducers"; +import { DCons } from "@thi.ng/dcons/dcons"; +import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; +import type { Reducer, Transducer } from "@thi.ng/transducers"; +import { compR } from "@thi.ng/transducers/func/compr"; +import { iterator1 } from "@thi.ng/transducers/iterator"; /** * Rate of change. diff --git a/packages/transducers-stats/src/rsi.ts b/packages/transducers-stats/src/rsi.ts index 5617af669c..2e0217a34c 100644 --- a/packages/transducers-stats/src/rsi.ts +++ b/packages/transducers-stats/src/rsi.ts @@ -1,11 +1,9 @@ -import { - comp, - drop, - iterator1, - map, - multiplex, - Transducer, -} from "@thi.ng/transducers"; +import type { Transducer } from "@thi.ng/transducers"; +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 { momentum } from "./momentum"; import { sma } from "./sma"; diff --git a/packages/transducers-stats/src/sd.ts b/packages/transducers-stats/src/sd.ts index aebfd33c35..6b3d1478b0 100644 --- a/packages/transducers-stats/src/sd.ts +++ b/packages/transducers-stats/src/sd.ts @@ -1,12 +1,10 @@ -import { - $iter, - comp, - drop, - map, - multiplex, - partition, - Transducer, -} from "@thi.ng/transducers"; +import type { Transducer } from "@thi.ng/transducers"; +import { comp } from "@thi.ng/transducers/func/comp"; +import { $iter } 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 { partition } from "@thi.ng/transducers/xform/partition"; import { mse } from "./mse"; import { sma } from "./sma"; diff --git a/packages/transducers-stats/src/sma.ts b/packages/transducers-stats/src/sma.ts index f6db1fa68e..1bed51b475 100644 --- a/packages/transducers-stats/src/sma.ts +++ b/packages/transducers-stats/src/sma.ts @@ -1,6 +1,8 @@ -import { DCons } from "@thi.ng/dcons"; -import { illegalArgs } from "@thi.ng/errors"; -import { compR, iterator1, Reducer, Transducer } from "@thi.ng/transducers"; +import { DCons } from "@thi.ng/dcons/dcons"; +import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; +import type { Reducer, Transducer } from "@thi.ng/transducers"; +import { compR } from "@thi.ng/transducers/func/compr"; +import { iterator1 } from "@thi.ng/transducers/iterator"; /** * Like {@link @thi.ng/transducers#(movingAverage:1)}, but using more diff --git a/packages/transducers-stats/src/stochastic.ts b/packages/transducers-stats/src/stochastic.ts index 2d91d4edfb..e7725e1a36 100644 --- a/packages/transducers-stats/src/stochastic.ts +++ b/packages/transducers-stats/src/stochastic.ts @@ -1,4 +1,7 @@ -import { $iter, compR, Reducer, step, Transducer } from "@thi.ng/transducers"; +import type { Reducer, Transducer } from "@thi.ng/transducers"; +import { compR } from "@thi.ng/transducers/func/compr"; +import { $iter } from "@thi.ng/transducers/iterator"; +import { step } from "@thi.ng/transducers/step"; 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 5c2c9138c1..f6f1d07a18 100644 --- a/packages/transducers-stats/src/trix.ts +++ b/packages/transducers-stats/src/trix.ts @@ -1,4 +1,6 @@ -import { comp, iterator1, Transducer } from "@thi.ng/transducers"; +import type { Transducer } from "@thi.ng/transducers"; +import { comp } from "@thi.ng/transducers/func/comp"; +import { iterator1 } from "@thi.ng/transducers/iterator"; 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 715b36d5ef..b700956edd 100644 --- a/packages/transducers-stats/src/wma.ts +++ b/packages/transducers-stats/src/wma.ts @@ -1,12 +1,10 @@ -import { isNumber } from "@thi.ng/checks"; -import { - comp, - iterator1, - map, - partition, - range, - Transducer, -} from "@thi.ng/transducers"; +import { isNumber } from "@thi.ng/checks/is-number"; +import type { Transducer } from "@thi.ng/transducers"; +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 { dot } from "./dot"; /** diff --git a/packages/transducers/src/func/comp.ts b/packages/transducers/src/func/comp.ts index 6881b97164..c642c298e4 100644 --- a/packages/transducers/src/func/comp.ts +++ b/packages/transducers/src/func/comp.ts @@ -1,4 +1,4 @@ -import { comp as _comp } from "@thi.ng/compose"; +import { comp as _comp } from "@thi.ng/compose/comp"; import type { Transducer, TxLike } from "../api"; import { ensureTransducer } from "../internal/ensure"; diff --git a/packages/transducers/src/func/deep-transform.ts b/packages/transducers/src/func/deep-transform.ts index b164268ffc..93621c884e 100644 --- a/packages/transducers/src/func/deep-transform.ts +++ b/packages/transducers/src/func/deep-transform.ts @@ -1,4 +1,4 @@ -import { isFunction } from "@thi.ng/checks"; +import { isFunction } from "@thi.ng/checks/is-function"; import type { TransformSpec } from "../api"; /** diff --git a/packages/transducers/src/internal/drain.ts b/packages/transducers/src/internal/drain.ts index f0e9078e6e..7d513c36c2 100644 --- a/packages/transducers/src/internal/drain.ts +++ b/packages/transducers/src/internal/drain.ts @@ -12,13 +12,11 @@ import { isReduced } from "../reduced"; * * @internal */ -export const __drain = ( - buf: T[], - complete: Fn, - reduce: ReductionFn -) => (acc: T[]) => { - while (buf.length && !isReduced(acc)) { - acc = reduce(acc, buf.shift()!); - } - return complete(acc); -}; +export const __drain = + (buf: T[], complete: Fn, reduce: ReductionFn) => + (acc: T[]) => { + while (buf.length && !isReduced(acc)) { + acc = reduce(acc, buf.shift()!); + } + return complete(acc); + }; diff --git a/packages/transducers/src/internal/ensure.ts b/packages/transducers/src/internal/ensure.ts index 63abdd6a1d..f0e55c2ca7 100644 --- a/packages/transducers/src/internal/ensure.ts +++ b/packages/transducers/src/internal/ensure.ts @@ -1,4 +1,4 @@ -import { implementsFunction } from "@thi.ng/checks"; +import { implementsFunction } from "@thi.ng/checks/implements-function"; import type { Transducer, TxLike } from "../api"; export const ensureTransducer = (x: TxLike) => diff --git a/packages/transducers/src/internal/group-opts.ts b/packages/transducers/src/internal/group-opts.ts index e0938d956a..86d5b27e26 100644 --- a/packages/transducers/src/internal/group-opts.ts +++ b/packages/transducers/src/internal/group-opts.ts @@ -1,4 +1,3 @@ -import { identity } from "@thi.ng/compose"; import type { GroupByOpts } from "../api"; import { push } from "../rfn/push"; @@ -13,7 +12,7 @@ export const __groupByOpts = ( opts?: Partial> ) => >{ - key: identity, + key: (x: any) => x, group: push(), ...opts, }; diff --git a/packages/transducers/src/internal/sort-opts.ts b/packages/transducers/src/internal/sort-opts.ts index c4533372a7..291c0612bd 100644 --- a/packages/transducers/src/internal/sort-opts.ts +++ b/packages/transducers/src/internal/sort-opts.ts @@ -1,5 +1,4 @@ -import { compare } from "@thi.ng/compare"; -import { identity } from "@thi.ng/compose"; +import { compare } from "@thi.ng/compare/compare"; import type { SortOpts } from "../api"; /** @@ -11,7 +10,7 @@ import type { SortOpts } from "../api"; */ export const __sortOpts = (opts?: Partial>) => >{ - key: identity, + key: (x: any) => x, compare, ...opts, }; diff --git a/packages/transducers/src/iter/choices.ts b/packages/transducers/src/iter/choices.ts index 6aec6bfc7a..754649eb2a 100644 --- a/packages/transducers/src/iter/choices.ts +++ b/packages/transducers/src/iter/choices.ts @@ -1,5 +1,7 @@ -import { ensureArray } from "@thi.ng/arrays"; -import { IRandom, SYSTEM, weightedRandom } from "@thi.ng/random"; +import { ensureArray } from "@thi.ng/arrays/ensure-array"; +import type { IRandom } from "@thi.ng/random"; +import { SYSTEM } from "@thi.ng/random/system"; +import { weightedRandom } from "@thi.ng/random/weighted-random"; import { repeatedly } from "./repeatedly"; /** diff --git a/packages/transducers/src/iter/concat.ts b/packages/transducers/src/iter/concat.ts index 0de3a8c8f2..eba9a137ca 100644 --- a/packages/transducers/src/iter/concat.ts +++ b/packages/transducers/src/iter/concat.ts @@ -1,5 +1,5 @@ import type { Nullable } from "@thi.ng/api"; -import { ensureIterable } from "@thi.ng/arrays"; +import { ensureIterable } from "@thi.ng/arrays/ensure-iterable"; /** * Yields iterator producing concatenation of given iterables. diff --git a/packages/transducers/src/iter/dup.ts b/packages/transducers/src/iter/dup.ts index b6a4839a43..260c93dbb0 100644 --- a/packages/transducers/src/iter/dup.ts +++ b/packages/transducers/src/iter/dup.ts @@ -1,5 +1,6 @@ -import { ensureArray } from "@thi.ng/arrays"; -import { isArray, isString } from "@thi.ng/checks"; +import { ensureArray } from "@thi.ng/arrays/ensure-array"; +import { isArray } from "@thi.ng/checks/is-array"; +import { isString } from "@thi.ng/checks/is-string"; import { concat } from "./concat"; /** diff --git a/packages/transducers/src/iter/extend-sides.ts b/packages/transducers/src/iter/extend-sides.ts index 31d1e4fe37..4bbeefda84 100644 --- a/packages/transducers/src/iter/extend-sides.ts +++ b/packages/transducers/src/iter/extend-sides.ts @@ -1,4 +1,4 @@ -import { SEMAPHORE } from "@thi.ng/api"; +import { SEMAPHORE } from "@thi.ng/api/constants"; import { repeat } from "./repeat"; /** diff --git a/packages/transducers/src/iter/palindrome.ts b/packages/transducers/src/iter/palindrome.ts index c316fe483d..f153789511 100644 --- a/packages/transducers/src/iter/palindrome.ts +++ b/packages/transducers/src/iter/palindrome.ts @@ -1,5 +1,6 @@ -import { ensureArray } from "@thi.ng/arrays"; -import { isArray, isString } from "@thi.ng/checks"; +import { ensureArray } from "@thi.ng/arrays/ensure-array"; +import { isArray } from "@thi.ng/checks/is-array"; +import { isString } from "@thi.ng/checks/is-string"; import { str } from "../rfn/str"; import { concat } from "./concat"; import { reverse } from "./reverse"; diff --git a/packages/transducers/src/iter/permutations.ts b/packages/transducers/src/iter/permutations.ts index a7add9342e..a44fcf75af 100644 --- a/packages/transducers/src/iter/permutations.ts +++ b/packages/transducers/src/iter/permutations.ts @@ -1,5 +1,5 @@ -import { ensureArrayLike } from "@thi.ng/arrays"; -import { illegalArgs } from "@thi.ng/errors"; +import { ensureArrayLike } from "@thi.ng/arrays/ensure-array"; +import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; import { range } from "./range"; /** diff --git a/packages/transducers/src/iter/range2d.ts b/packages/transducers/src/iter/range2d.ts index 699f7a860b..6d447bb029 100644 --- a/packages/transducers/src/iter/range2d.ts +++ b/packages/transducers/src/iter/range2d.ts @@ -1,4 +1,4 @@ -import { illegalArity } from "@thi.ng/errors"; +import { illegalArity } from "@thi.ng/errors/illegal-arity"; import { range } from "./range"; export function range2d( diff --git a/packages/transducers/src/iter/range3d.ts b/packages/transducers/src/iter/range3d.ts index 27f2d08a3f..f0e31548d5 100644 --- a/packages/transducers/src/iter/range3d.ts +++ b/packages/transducers/src/iter/range3d.ts @@ -1,4 +1,4 @@ -import { illegalArity } from "@thi.ng/errors"; +import { illegalArity } from "@thi.ng/errors/illegal-arity"; import { range } from "./range"; export function range3d( diff --git a/packages/transducers/src/iter/reverse.ts b/packages/transducers/src/iter/reverse.ts index 1fc60385c3..1b29272d51 100644 --- a/packages/transducers/src/iter/reverse.ts +++ b/packages/transducers/src/iter/reverse.ts @@ -1,4 +1,4 @@ -import { ensureArray } from "@thi.ng/arrays"; +import { ensureArray } from "@thi.ng/arrays/ensure-array"; /** * Yields iterator which consumes input and yield its values in reverse diff --git a/packages/transducers/src/iter/sorted-keys.ts b/packages/transducers/src/iter/sorted-keys.ts index e4364da5b8..89b1aa1930 100644 --- a/packages/transducers/src/iter/sorted-keys.ts +++ b/packages/transducers/src/iter/sorted-keys.ts @@ -1,5 +1,5 @@ import type { Comparator } from "@thi.ng/api"; -import { compare } from "@thi.ng/compare"; +import { compare } from "@thi.ng/compare/compare"; /** * Syntax sugar for `Object.keys(x).sort()` with support for custom diff --git a/packages/transducers/src/iter/wrap-sides.ts b/packages/transducers/src/iter/wrap-sides.ts index ae46c4ab96..2e32ed5d99 100644 --- a/packages/transducers/src/iter/wrap-sides.ts +++ b/packages/transducers/src/iter/wrap-sides.ts @@ -1,6 +1,6 @@ -import { ensureArray } from "@thi.ng/arrays"; -import { illegalArgs } from "@thi.ng/errors"; -import { inRange } from "@thi.ng/math"; +import { ensureArray } from "@thi.ng/arrays/ensure-array"; +import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; +import { inRange } from "@thi.ng/math/interval"; /** * Yields iterator of `src` with the last `numLeft` values of `src` diff --git a/packages/transducers/src/iterator.ts b/packages/transducers/src/iterator.ts index 2ee5329ee1..c0b12d529d 100644 --- a/packages/transducers/src/iterator.ts +++ b/packages/transducers/src/iterator.ts @@ -1,5 +1,6 @@ -import { FnAny, NO_OP, SEMAPHORE } from "@thi.ng/api"; -import { isIterable } from "@thi.ng/checks"; +import type { FnAny } from "@thi.ng/api"; +import { NO_OP, SEMAPHORE } from "@thi.ng/api/constants"; +import { isIterable } from "@thi.ng/checks/is-iterable"; import type { Reducer, Transducer, TxLike } from "./api"; import { ensureTransducer } from "./internal/ensure"; import { isReduced, unreduced } from "./reduced"; diff --git a/packages/transducers/src/reduce.ts b/packages/transducers/src/reduce.ts index 2381fdb527..86322ae30f 100644 --- a/packages/transducers/src/reduce.ts +++ b/packages/transducers/src/reduce.ts @@ -1,6 +1,8 @@ import type { Fn0, FnAny } from "@thi.ng/api"; -import { implementsFunction, isArrayLike, isIterable } from "@thi.ng/checks"; -import { illegalArity } from "@thi.ng/errors"; +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 type { IReducible, Reducer, ReductionFn } from "./api"; import { isReduced, unreduced } from "./reduced"; diff --git a/packages/transducers/src/rfn/frequencies.ts b/packages/transducers/src/rfn/frequencies.ts index 0559a9aebd..b523ebe75d 100644 --- a/packages/transducers/src/rfn/frequencies.ts +++ b/packages/transducers/src/rfn/frequencies.ts @@ -1,5 +1,5 @@ import type { Fn } from "@thi.ng/api"; -import { identity } from "@thi.ng/compose"; +import { identity } from "@thi.ng/compose/identity"; import type { Reducer } from "../api"; import { $$reduce } from "../reduce"; import { count } from "./count"; diff --git a/packages/transducers/src/rfn/group-binary.ts b/packages/transducers/src/rfn/group-binary.ts index fa3483bca9..f5f94f1027 100644 --- a/packages/transducers/src/rfn/group-binary.ts +++ b/packages/transducers/src/rfn/group-binary.ts @@ -3,12 +3,10 @@ import type { Reducer } from "../api"; import { groupByObj } from "./group-by-obj"; import { push } from "./push"; -const branchPred = ( - key: Fn, - b: number, - l: PropertyKey, - r: PropertyKey -) => (x: T) => (key(x) & b ? r : l); +const branchPred = + (key: Fn, b: number, l: PropertyKey, r: PropertyKey) => + (x: T) => + key(x) & b ? r : l; /** * Creates a bottom-up, unbalanced binary tree of desired depth and diff --git a/packages/transducers/src/rfn/last.ts b/packages/transducers/src/rfn/last.ts index 3ead601e3e..9d9dcdff2b 100644 --- a/packages/transducers/src/rfn/last.ts +++ b/packages/transducers/src/rfn/last.ts @@ -1,4 +1,4 @@ -import { NO_OP } from "@thi.ng/api"; +import { NO_OP } from "@thi.ng/api/constants"; import type { Reducer } from "../api"; import { reduce, reducer } from "../reduce"; diff --git a/packages/transducers/src/rfn/max-compare.ts b/packages/transducers/src/rfn/max-compare.ts index 4c075b40b2..3fafc4349f 100644 --- a/packages/transducers/src/rfn/max-compare.ts +++ b/packages/transducers/src/rfn/max-compare.ts @@ -1,5 +1,5 @@ import type { Comparator, Fn0 } from "@thi.ng/api"; -import { compare } from "@thi.ng/compare"; +import { compare } from "@thi.ng/compare/compare"; import type { 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 fe9bd4b086..14e08f9546 100644 --- a/packages/transducers/src/rfn/min-compare.ts +++ b/packages/transducers/src/rfn/min-compare.ts @@ -1,5 +1,5 @@ import type { Comparator, Fn0 } from "@thi.ng/api"; -import { compare } from "@thi.ng/compare"; +import { compare } from "@thi.ng/compare/compare"; import type { Reducer } from "../api"; import { $$reduce, reducer } from "../reduce"; diff --git a/packages/transducers/src/rfn/norm-frequencies.ts b/packages/transducers/src/rfn/norm-frequencies.ts index 74812a8cbd..4941246ecd 100644 --- a/packages/transducers/src/rfn/norm-frequencies.ts +++ b/packages/transducers/src/rfn/norm-frequencies.ts @@ -1,5 +1,5 @@ import type { Fn } from "@thi.ng/api"; -import { identity } from "@thi.ng/compose"; +import { identity } from "@thi.ng/compose/identity"; import type { Reducer } from "../api"; import { $$reduce } from "../reduce"; import { groupByMap } from "./group-by-map"; diff --git a/packages/transducers/src/rfn/push-sort.ts b/packages/transducers/src/rfn/push-sort.ts index ac6765f17a..e2656f0eca 100644 --- a/packages/transducers/src/rfn/push-sort.ts +++ b/packages/transducers/src/rfn/push-sort.ts @@ -1,5 +1,5 @@ import type { Comparator } from "@thi.ng/api"; -import { compare } from "@thi.ng/compare"; +import { compare } from "@thi.ng/compare/compare"; import type { Reducer } from "../api"; /** diff --git a/packages/transducers/src/run.ts b/packages/transducers/src/run.ts index dc1df5d92d..941db7da55 100644 --- a/packages/transducers/src/run.ts +++ b/packages/transducers/src/run.ts @@ -1,4 +1,5 @@ -import { Fn, NO_OP } from "@thi.ng/api"; +import type { Fn } from "@thi.ng/api"; +import { NO_OP } from "@thi.ng/api/constants"; import type { IReducible, Reducer, TxLike } from "./api"; import { transduce } from "./transduce"; diff --git a/packages/transducers/src/transduce.ts b/packages/transducers/src/transduce.ts index 30dcb1015b..f62a8009e8 100644 --- a/packages/transducers/src/transduce.ts +++ b/packages/transducers/src/transduce.ts @@ -1,5 +1,5 @@ import type { FnAny } from "@thi.ng/api"; -import { illegalArity } from "@thi.ng/errors"; +import { illegalArity } from "@thi.ng/errors/illegal-arity"; import type { IReducible, Reducer, Transducer, TxLike } from "./api"; import { ensureTransducer } from "./internal/ensure"; import { reduce, reduceRight } from "./reduce"; diff --git a/packages/transducers/src/xform/benchmark.ts b/packages/transducers/src/xform/benchmark.ts index f67d80270e..0493ba75fd 100644 --- a/packages/transducers/src/xform/benchmark.ts +++ b/packages/transducers/src/xform/benchmark.ts @@ -1,4 +1,4 @@ -import { isIterable } from "@thi.ng/checks"; +import { isIterable } from "@thi.ng/checks/is-iterable"; import type { Reducer, Transducer } from "../api"; import { compR } from "../func/compr"; import { iterator1 } from "../iterator"; diff --git a/packages/transducers/src/xform/cat.ts b/packages/transducers/src/xform/cat.ts index 6740b13d8d..33797a2897 100644 --- a/packages/transducers/src/xform/cat.ts +++ b/packages/transducers/src/xform/cat.ts @@ -40,19 +40,19 @@ import { ensureReduced, isReduced, unreduced } from "../reduced"; * * @param rfn - */ -export const cat = (): Transducer>, T> => ( - rfn: Reducer -) => { - const r = rfn[2]; - return compR(rfn, (acc, x: Iterable | null | undefined) => { - if (x) { - for (let y of unreduced(x)) { - acc = r(acc, y); - if (isReduced(acc)) { - break; +export const cat = + (): Transducer>, T> => + (rfn: Reducer) => { + const r = rfn[2]; + return compR(rfn, (acc, x: Iterable | null | undefined) => { + if (x) { + for (let y of unreduced(x)) { + acc = r(acc, y); + if (isReduced(acc)) { + break; + } } } - } - return isReduced(x) ? ensureReduced(acc) : acc; - }); -}; + return isReduced(x) ? ensureReduced(acc) : acc; + }); + }; diff --git a/packages/transducers/src/xform/converge.ts b/packages/transducers/src/xform/converge.ts index 34a286bb66..879c31e53f 100644 --- a/packages/transducers/src/xform/converge.ts +++ b/packages/transducers/src/xform/converge.ts @@ -1,4 +1,5 @@ -import { Predicate2, SEMAPHORE } from "@thi.ng/api"; +import type { Predicate2 } from "@thi.ng/api"; +import { SEMAPHORE } from "@thi.ng/api/constants"; import type { Reducer, Transducer } from "../api"; import { compR } from "../func/compr"; import { $iter } from "../iterator"; diff --git a/packages/transducers/src/xform/convolve.ts b/packages/transducers/src/xform/convolve.ts index fd006287fe..6f1e2ebdcd 100644 --- a/packages/transducers/src/xform/convolve.ts +++ b/packages/transducers/src/xform/convolve.ts @@ -1,5 +1,5 @@ import type { Fn, Fn0 } from "@thi.ng/api"; -import { illegalArgs } from "@thi.ng/errors"; +import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; import type { Reducer, Transducer } from "../api"; import { range } from "../iter/range"; import { range2d } from "../iter/range2d"; diff --git a/packages/transducers/src/xform/dedupe.ts b/packages/transducers/src/xform/dedupe.ts index eecb1235a0..d72339939b 100644 --- a/packages/transducers/src/xform/dedupe.ts +++ b/packages/transducers/src/xform/dedupe.ts @@ -1,4 +1,5 @@ -import { Predicate2, SEMAPHORE } from "@thi.ng/api"; +import type { Predicate2 } from "@thi.ng/api"; +import { SEMAPHORE } from "@thi.ng/api/constants"; import type { Reducer, Transducer } from "../api"; import { compR } from "../func/compr"; import { $iter } from "../iterator"; diff --git a/packages/transducers/src/xform/delayed.ts b/packages/transducers/src/xform/delayed.ts index 09e35ce494..93eb6ef5d3 100644 --- a/packages/transducers/src/xform/delayed.ts +++ b/packages/transducers/src/xform/delayed.ts @@ -1,4 +1,4 @@ -import { delayed as _delayed } from "@thi.ng/compose"; +import { delayed as _delayed } from "@thi.ng/compose/delayed"; import type { Transducer } from "../api"; import { map } from "./map"; diff --git a/packages/transducers/src/xform/drop-nth.ts b/packages/transducers/src/xform/drop-nth.ts index 239de4c57e..08ff994539 100644 --- a/packages/transducers/src/xform/drop-nth.ts +++ b/packages/transducers/src/xform/drop-nth.ts @@ -1,5 +1,5 @@ -import { isIterable } from "@thi.ng/checks"; -import { clamp0 } from "@thi.ng/math"; +import { isIterable } from "@thi.ng/checks/is-iterable"; +import { clamp0 } from "@thi.ng/math/interval"; import type { Transducer } from "../api"; import { iterator1 } from "../iterator"; import { throttle } from "./throttle"; diff --git a/packages/transducers/src/xform/drop.ts b/packages/transducers/src/xform/drop.ts index e9d4f4ebca..5cfa131059 100644 --- a/packages/transducers/src/xform/drop.ts +++ b/packages/transducers/src/xform/drop.ts @@ -1,4 +1,4 @@ -import { isIterable } from "@thi.ng/checks"; +import { isIterable } from "@thi.ng/checks/is-iterable"; import type { Reducer, Transducer } from "../api"; import { compR } from "../func/compr"; import { iterator1 } from "../iterator"; diff --git a/packages/transducers/src/xform/duplicate.ts b/packages/transducers/src/xform/duplicate.ts index bdca4f5966..79a5d97e6c 100644 --- a/packages/transducers/src/xform/duplicate.ts +++ b/packages/transducers/src/xform/duplicate.ts @@ -1,4 +1,4 @@ -import { isIterable } from "@thi.ng/checks"; +import { isIterable } from "@thi.ng/checks/is-iterable"; import type { Reducer, Transducer } from "../api"; import { compR } from "../func/compr"; import { iterator } from "../iterator"; diff --git a/packages/transducers/src/xform/filter-fuzzy.ts b/packages/transducers/src/xform/filter-fuzzy.ts index c7ceff99c1..ff53a2cbde 100644 --- a/packages/transducers/src/xform/filter-fuzzy.ts +++ b/packages/transducers/src/xform/filter-fuzzy.ts @@ -1,5 +1,5 @@ import type { Fn, Predicate2 } from "@thi.ng/api"; -import { fuzzyMatch } from "@thi.ng/arrays"; +import { fuzzyMatch } from "@thi.ng/arrays/fuzzy-match"; import type { Transducer } from "../api"; import { $iter } from "../iterator"; import { filter } from "./filter"; diff --git a/packages/transducers/src/xform/filter.ts b/packages/transducers/src/xform/filter.ts index 6ce6b61d34..9819cf50f8 100644 --- a/packages/transducers/src/xform/filter.ts +++ b/packages/transducers/src/xform/filter.ts @@ -1,5 +1,5 @@ import type { Predicate } from "@thi.ng/api"; -import { isIterable } from "@thi.ng/checks"; +import { isIterable } from "@thi.ng/checks/is-iterable"; import type { Reducer, Transducer } from "../api"; import { compR } from "../func/compr"; import { iterator1 } from "../iterator"; diff --git a/packages/transducers/src/xform/flatten-with.ts b/packages/transducers/src/xform/flatten-with.ts index c90ef40db3..754996920b 100644 --- a/packages/transducers/src/xform/flatten-with.ts +++ b/packages/transducers/src/xform/flatten-with.ts @@ -1,5 +1,6 @@ import type { DeepArrayValue, Fn, Nullable } from "@thi.ng/api"; -import { isIterable, isString } from "@thi.ng/checks"; +import { isIterable } from "@thi.ng/checks/is-iterable"; +import { isString } from "@thi.ng/checks/is-string"; import type { Reducer, Transducer } from "../api"; import { compR } from "../func/compr"; import { iterator } from "../iterator"; diff --git a/packages/transducers/src/xform/flatten.ts b/packages/transducers/src/xform/flatten.ts index 99111ad0dc..79f55e9f7b 100644 --- a/packages/transducers/src/xform/flatten.ts +++ b/packages/transducers/src/xform/flatten.ts @@ -1,5 +1,5 @@ import type { DeepArrayValue } from "@thi.ng/api"; -import { isNotStringAndIterable } from "@thi.ng/checks"; +import { isNotStringAndIterable } from "@thi.ng/checks/is-not-string-iterable"; import type { Transducer } from "../api"; import { flattenWith } from "./flatten-with"; diff --git a/packages/transducers/src/xform/interleave.ts b/packages/transducers/src/xform/interleave.ts index 8d7086f55d..8998b227ac 100644 --- a/packages/transducers/src/xform/interleave.ts +++ b/packages/transducers/src/xform/interleave.ts @@ -1,5 +1,5 @@ import type { Fn0 } from "@thi.ng/api"; -import { isIterable } from "@thi.ng/checks"; +import { isIterable } from "@thi.ng/checks/is-iterable"; import type { Reducer, Transducer } from "../api"; import { compR } from "../func/compr"; import { iterator } from "../iterator"; diff --git a/packages/transducers/src/xform/interpolate-hermite.ts b/packages/transducers/src/xform/interpolate-hermite.ts index 7131cfe4db..531dbe7561 100644 --- a/packages/transducers/src/xform/interpolate-hermite.ts +++ b/packages/transducers/src/xform/interpolate-hermite.ts @@ -1,4 +1,4 @@ -import { mixHermite } from "@thi.ng/math"; +import { mixHermite } from "@thi.ng/math/mix"; import type { Transducer } from "../api"; import { interpolate } from "./interpolate"; diff --git a/packages/transducers/src/xform/interpolate-linear.ts b/packages/transducers/src/xform/interpolate-linear.ts index dba20daf30..e8e9451b68 100644 --- a/packages/transducers/src/xform/interpolate-linear.ts +++ b/packages/transducers/src/xform/interpolate-linear.ts @@ -1,4 +1,4 @@ -import { mix } from "@thi.ng/math"; +import { mix } from "@thi.ng/math/mix"; import type { Transducer } from "../api"; import { interpolate } from "./interpolate"; diff --git a/packages/transducers/src/xform/interpolate.ts b/packages/transducers/src/xform/interpolate.ts index cdc8efbc13..ea338ad5c2 100644 --- a/packages/transducers/src/xform/interpolate.ts +++ b/packages/transducers/src/xform/interpolate.ts @@ -1,5 +1,5 @@ import type { Fn2 } from "@thi.ng/api"; -import { isIterable } from "@thi.ng/checks"; +import { isIterable } from "@thi.ng/checks/is-iterable"; import type { Transducer } from "../api"; import { comp } from "../func/comp"; import { normRange } from "../iter/norm-range"; diff --git a/packages/transducers/src/xform/interpose.ts b/packages/transducers/src/xform/interpose.ts index 6b46b26a4a..d709902374 100644 --- a/packages/transducers/src/xform/interpose.ts +++ b/packages/transducers/src/xform/interpose.ts @@ -1,5 +1,5 @@ import type { Fn0 } from "@thi.ng/api"; -import { isIterable } from "@thi.ng/checks"; +import { isIterable } from "@thi.ng/checks/is-iterable"; import type { Reducer, Transducer } from "../api"; import { compR } from "../func/compr"; import { iterator } from "../iterator"; diff --git a/packages/transducers/src/xform/keep.ts b/packages/transducers/src/xform/keep.ts index e27b5ea147..cbeb2c90ab 100644 --- a/packages/transducers/src/xform/keep.ts +++ b/packages/transducers/src/xform/keep.ts @@ -1,5 +1,5 @@ import type { Fn, Nullable } from "@thi.ng/api"; -import { identity } from "@thi.ng/compose"; +import { identity } from "@thi.ng/compose/identity"; import type { Reducer, Transducer } from "../api"; import { compR } from "../func/compr"; import { $iter } from "../iterator"; diff --git a/packages/transducers/src/xform/labeled.ts b/packages/transducers/src/xform/labeled.ts index d336c887c5..3876f06f08 100644 --- a/packages/transducers/src/xform/labeled.ts +++ b/packages/transducers/src/xform/labeled.ts @@ -1,4 +1,5 @@ -import { isFunction, isIterable } from "@thi.ng/checks"; +import { isFunction } from "@thi.ng/checks/is-function"; +import { isIterable } from "@thi.ng/checks/is-iterable"; import type { Transducer } from "../api"; import { iterator1 } from "../iterator"; import { map } from "./map"; diff --git a/packages/transducers/src/xform/map-deep.ts b/packages/transducers/src/xform/map-deep.ts index 2377cf258a..bbd79a49ec 100644 --- a/packages/transducers/src/xform/map-deep.ts +++ b/packages/transducers/src/xform/map-deep.ts @@ -1,4 +1,4 @@ -import { isIterable } from "@thi.ng/checks"; +import { isIterable } from "@thi.ng/checks/is-iterable"; import type { Transducer, TransformSpec } from "../api"; import { deepTransform } from "../func/deep-transform"; import { iterator1 } from "../iterator"; diff --git a/packages/transducers/src/xform/map.ts b/packages/transducers/src/xform/map.ts index 786371d2a1..72121e5e45 100644 --- a/packages/transducers/src/xform/map.ts +++ b/packages/transducers/src/xform/map.ts @@ -1,5 +1,5 @@ import type { Fn } from "@thi.ng/api"; -import { isIterable } from "@thi.ng/checks"; +import { isIterable } from "@thi.ng/checks/is-iterable"; import type { 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 2f6bfcf6ea..9bd0eaf7d2 100644 --- a/packages/transducers/src/xform/mapcat.ts +++ b/packages/transducers/src/xform/mapcat.ts @@ -1,5 +1,5 @@ import type { Fn } from "@thi.ng/api"; -import { isIterable } from "@thi.ng/checks"; +import { isIterable } from "@thi.ng/checks/is-iterable"; import type { Transducer } from "../api"; import { comp } from "../func/comp"; import { iterator } from "../iterator"; diff --git a/packages/transducers/src/xform/match-first.ts b/packages/transducers/src/xform/match-first.ts index 7acd449e9b..e8216ca013 100644 --- a/packages/transducers/src/xform/match-first.ts +++ b/packages/transducers/src/xform/match-first.ts @@ -1,5 +1,5 @@ import type { Predicate } from "@thi.ng/api"; -import { isIterable } from "@thi.ng/checks"; +import { isIterable } from "@thi.ng/checks/is-iterable"; import type { Transducer } from "../api"; import { comp } from "../func/comp"; import { iterator1 } from "../iterator"; diff --git a/packages/transducers/src/xform/match-last.ts b/packages/transducers/src/xform/match-last.ts index 18d272d676..87bede5ea0 100644 --- a/packages/transducers/src/xform/match-last.ts +++ b/packages/transducers/src/xform/match-last.ts @@ -1,5 +1,5 @@ import type { Predicate } from "@thi.ng/api"; -import { isIterable } from "@thi.ng/checks"; +import { isIterable } from "@thi.ng/checks/is-iterable"; import type { 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 5cdaf49fc6..9709df2e1b 100644 --- a/packages/transducers/src/xform/moving-average.ts +++ b/packages/transducers/src/xform/moving-average.ts @@ -1,5 +1,5 @@ -import { isIterable } from "@thi.ng/checks"; -import { illegalArgs } from "@thi.ng/errors"; +import { isIterable } from "@thi.ng/checks/is-iterable"; +import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; import type { Reducer, Transducer } from "../api"; import { compR } from "../func/compr"; import { iterator1 } from "../iterator"; diff --git a/packages/transducers/src/xform/multiplex.ts b/packages/transducers/src/xform/multiplex.ts index ff6154bb30..df6aa8aaa7 100644 --- a/packages/transducers/src/xform/multiplex.ts +++ b/packages/transducers/src/xform/multiplex.ts @@ -1,4 +1,4 @@ -import { juxt } from "@thi.ng/compose"; +import { juxt } from "@thi.ng/compose/juxt"; import type { Transducer, TxLike } from "../api"; import { step } from "../step"; import { map } from "./map"; diff --git a/packages/transducers/src/xform/pad-last.ts b/packages/transducers/src/xform/pad-last.ts index 14f58523c6..c1b3f00494 100644 --- a/packages/transducers/src/xform/pad-last.ts +++ b/packages/transducers/src/xform/pad-last.ts @@ -1,4 +1,4 @@ -import { isIterable } from "@thi.ng/checks"; +import { isIterable } from "@thi.ng/checks/is-iterable"; import type { Reducer, Transducer } from "../api"; import { iterator } from "../iterator"; import { isReduced } from "../reduced"; diff --git a/packages/transducers/src/xform/partition-by.ts b/packages/transducers/src/xform/partition-by.ts index d3d8d0c095..c9d41f8658 100644 --- a/packages/transducers/src/xform/partition-by.ts +++ b/packages/transducers/src/xform/partition-by.ts @@ -1,4 +1,5 @@ -import { Fn, SEMAPHORE } from "@thi.ng/api"; +import type { Fn } from "@thi.ng/api"; +import { SEMAPHORE } from "@thi.ng/api/constants"; import type { Reducer, Transducer } from "../api"; import { $iter, iterator } from "../iterator"; import { isReduced } from "../reduced"; diff --git a/packages/transducers/src/xform/partition-of.ts b/packages/transducers/src/xform/partition-of.ts index 92bdc9c78a..ae77f6fce8 100644 --- a/packages/transducers/src/xform/partition-of.ts +++ b/packages/transducers/src/xform/partition-of.ts @@ -1,4 +1,4 @@ -import { isIterable } from "@thi.ng/checks"; +import { isIterable } from "@thi.ng/checks/is-iterable"; import type { Transducer } from "../api"; import { iterator } from "../iterator"; import { partitionBy } from "./partition-by"; diff --git a/packages/transducers/src/xform/partition-sync.ts b/packages/transducers/src/xform/partition-sync.ts index 6624e2361e..2893560362 100644 --- a/packages/transducers/src/xform/partition-sync.ts +++ b/packages/transducers/src/xform/partition-sync.ts @@ -1,7 +1,7 @@ import type { Fn, IObjectOf } from "@thi.ng/api"; -import { isArray } from "@thi.ng/checks"; -import { identity } from "@thi.ng/compose"; -import { illegalState } from "@thi.ng/errors"; +import { isArray } from "@thi.ng/checks/is-array"; +import { identity } from "@thi.ng/compose/identity"; +import { illegalState } from "@thi.ng/errors/illegal-state"; import type { Reducer, Transducer } from "../api"; import { $iter, iterator } from "../iterator"; import { isReduced } from "../reduced"; diff --git a/packages/transducers/src/xform/partition-time.ts b/packages/transducers/src/xform/partition-time.ts index bcd8553b38..76b3428d9d 100644 --- a/packages/transducers/src/xform/partition-time.ts +++ b/packages/transducers/src/xform/partition-time.ts @@ -1,4 +1,4 @@ -import { isIterable } from "@thi.ng/checks"; +import { isIterable } from "@thi.ng/checks/is-iterable"; import type { Transducer } from "../api"; import { iterator } from "../iterator"; import { partitionBy } from "./partition-by"; diff --git a/packages/transducers/src/xform/peek.ts b/packages/transducers/src/xform/peek.ts index 7bdcefacda..8356e80f40 100644 --- a/packages/transducers/src/xform/peek.ts +++ b/packages/transducers/src/xform/peek.ts @@ -1,4 +1,4 @@ -import { peek as _peek } from "@thi.ng/arrays"; +import { peek as _peek } from "@thi.ng/arrays/peek"; import type { Transducer } from "../api"; import { map } from "./map"; diff --git a/packages/transducers/src/xform/pluck.ts b/packages/transducers/src/xform/pluck.ts index bc5e77a4aa..2bfa85a6bf 100644 --- a/packages/transducers/src/xform/pluck.ts +++ b/packages/transducers/src/xform/pluck.ts @@ -1,4 +1,4 @@ -import { isIterable } from "@thi.ng/checks"; +import { isIterable } from "@thi.ng/checks/is-iterable"; import type { Transducer } from "../api"; import { iterator1 } from "../iterator"; import { map } from "./map"; diff --git a/packages/transducers/src/xform/rename.ts b/packages/transducers/src/xform/rename.ts index 4099f9d2d7..b10a2f22c7 100644 --- a/packages/transducers/src/xform/rename.ts +++ b/packages/transducers/src/xform/rename.ts @@ -1,5 +1,5 @@ import type { IObjectOf } from "@thi.ng/api"; -import { isArray } from "@thi.ng/checks"; +import { isArray } from "@thi.ng/checks/is-array"; import type { Reducer, Transducer } from "../api"; import { comp } from "../func/comp"; import { renamer } from "../func/renamer"; diff --git a/packages/transducers/src/xform/sample.ts b/packages/transducers/src/xform/sample.ts index 5f3691f50b..3a31c20d69 100644 --- a/packages/transducers/src/xform/sample.ts +++ b/packages/transducers/src/xform/sample.ts @@ -1,4 +1,5 @@ -import { IRandom, SYSTEM } from "@thi.ng/random"; +import type { IRandom } from "@thi.ng/random"; +import { SYSTEM } from "@thi.ng/random/system"; import type { Reducer, Transducer } from "../api"; import { compR } from "../func/compr"; import { $iter } from "../iterator"; diff --git a/packages/transducers/src/xform/select-keys.ts b/packages/transducers/src/xform/select-keys.ts index 3e14f5e022..5ee0715aa1 100644 --- a/packages/transducers/src/xform/select-keys.ts +++ b/packages/transducers/src/xform/select-keys.ts @@ -1,4 +1,4 @@ -import { isIterable } from "@thi.ng/checks"; +import { isIterable } from "@thi.ng/checks/is-iterable"; import type { Transducer } from "../api"; import { keySelector } from "../func/key-selector"; import { iterator1 } from "../iterator"; diff --git a/packages/transducers/src/xform/sliding-window.ts b/packages/transducers/src/xform/sliding-window.ts index e339c9d1e7..6d42a1e759 100644 --- a/packages/transducers/src/xform/sliding-window.ts +++ b/packages/transducers/src/xform/sliding-window.ts @@ -1,4 +1,4 @@ -import { deref, MaybeDeref } from "@thi.ng/api"; +import { deref, MaybeDeref } from "@thi.ng/api/api/deref"; import type { Reducer, Transducer } from "../api"; import { compR } from "../func/compr"; import { $iter } from "../iterator"; diff --git a/packages/transducers/src/xform/stream-shuffle.ts b/packages/transducers/src/xform/stream-shuffle.ts index 0a9ea0e930..87a6cd6e07 100644 --- a/packages/transducers/src/xform/stream-shuffle.ts +++ b/packages/transducers/src/xform/stream-shuffle.ts @@ -1,4 +1,4 @@ -import { shuffle } from "@thi.ng/arrays"; +import { shuffle } from "@thi.ng/arrays/shuffle"; import type { Reducer, Transducer } from "../api"; import { $iter, iterator } from "../iterator"; import { isReduced } from "../reduced"; diff --git a/packages/transducers/src/xform/stream-sort.ts b/packages/transducers/src/xform/stream-sort.ts index ddb9960ec4..b6e2897a83 100644 --- a/packages/transducers/src/xform/stream-sort.ts +++ b/packages/transducers/src/xform/stream-sort.ts @@ -1,4 +1,4 @@ -import { binarySearch } from "@thi.ng/arrays"; +import { binarySearch } from "@thi.ng/arrays/binary-search"; import type { Reducer, SortOpts, Transducer } from "../api"; import { __drain } from "../internal/drain"; import { __sortOpts } from "../internal/sort-opts"; diff --git a/packages/transducers/src/xform/struct.ts b/packages/transducers/src/xform/struct.ts index d44d1eb09b..1b7b51a136 100644 --- a/packages/transducers/src/xform/struct.ts +++ b/packages/transducers/src/xform/struct.ts @@ -1,5 +1,5 @@ import type { Fn } from "@thi.ng/api"; -import { isIterable } from "@thi.ng/checks"; +import { isIterable } from "@thi.ng/checks/is-iterable"; import type { Transducer } from "../api"; import { comp } from "../func/comp"; import { iterator } from "../iterator"; diff --git a/packages/transducers/src/xform/swizzle.ts b/packages/transducers/src/xform/swizzle.ts index f3d7810832..3651b308cc 100644 --- a/packages/transducers/src/xform/swizzle.ts +++ b/packages/transducers/src/xform/swizzle.ts @@ -1,5 +1,5 @@ -import { swizzle as _swizzle } from "@thi.ng/arrays"; -import { isIterable } from "@thi.ng/checks"; +import { swizzle as _swizzle } from "@thi.ng/arrays/swizzle"; +import { isIterable } from "@thi.ng/checks/is-iterable"; import type { Transducer } from "../api"; import { iterator1 } from "../iterator"; import { map } from "./map"; diff --git a/packages/transducers/src/xform/take-last.ts b/packages/transducers/src/xform/take-last.ts index 1053646d8e..066635e950 100644 --- a/packages/transducers/src/xform/take-last.ts +++ b/packages/transducers/src/xform/take-last.ts @@ -1,4 +1,4 @@ -import { isIterable } from "@thi.ng/checks"; +import { isIterable } from "@thi.ng/checks/is-iterable"; import type { Reducer, Transducer } from "../api"; import { __drain } from "../internal/drain"; import { iterator } from "../iterator"; diff --git a/packages/transducers/src/xform/take-nth.ts b/packages/transducers/src/xform/take-nth.ts index a68ca14dd5..234f47cd3a 100644 --- a/packages/transducers/src/xform/take-nth.ts +++ b/packages/transducers/src/xform/take-nth.ts @@ -1,5 +1,5 @@ -import { isIterable } from "@thi.ng/checks"; -import { clamp0 } from "@thi.ng/math"; +import { isIterable } from "@thi.ng/checks/is-iterable"; +import { clamp0 } from "@thi.ng/math/interval"; import type { Transducer } from "../api"; import { iterator1 } from "../iterator"; import { throttle } from "./throttle"; diff --git a/packages/transducers/src/xform/take.ts b/packages/transducers/src/xform/take.ts index 59272f8524..fa2d3eb0ec 100644 --- a/packages/transducers/src/xform/take.ts +++ b/packages/transducers/src/xform/take.ts @@ -1,4 +1,4 @@ -import { isIterable } from "@thi.ng/checks"; +import { isIterable } from "@thi.ng/checks/is-iterable"; import type { Reducer, Transducer } from "../api"; import { compR } from "../func/compr"; import { iterator } from "../iterator"; diff --git a/packages/transducers/src/xform/throttle-time.ts b/packages/transducers/src/xform/throttle-time.ts index b957207cb6..25223e40d9 100644 --- a/packages/transducers/src/xform/throttle-time.ts +++ b/packages/transducers/src/xform/throttle-time.ts @@ -1,4 +1,4 @@ -import { isIterable } from "@thi.ng/checks"; +import { isIterable } from "@thi.ng/checks/is-iterable"; import type { Transducer } from "../api"; import { iterator1 } from "../iterator"; import { throttle } from "./throttle"; diff --git a/packages/transducers/src/xform/throttle.ts b/packages/transducers/src/xform/throttle.ts index 75d27ce932..55f6d2f9be 100644 --- a/packages/transducers/src/xform/throttle.ts +++ b/packages/transducers/src/xform/throttle.ts @@ -1,5 +1,5 @@ import type { StatefulPredicate } from "@thi.ng/api"; -import { isIterable } from "@thi.ng/checks"; +import { isIterable } from "@thi.ng/checks/is-iterable"; import type { Reducer, Transducer } from "../api"; import { compR } from "../func/compr"; import { iterator1 } from "../iterator"; diff --git a/packages/transducers/src/xform/toggle.ts b/packages/transducers/src/xform/toggle.ts index b915d8faa5..8102196e50 100644 --- a/packages/transducers/src/xform/toggle.ts +++ b/packages/transducers/src/xform/toggle.ts @@ -1,4 +1,4 @@ -import { isIterable } from "@thi.ng/checks"; +import { isIterable } from "@thi.ng/checks/is-iterable"; import type { Reducer, Transducer } from "../api"; import { iterator1 } from "../iterator"; diff --git a/packages/vector-pools/src/attrib-pool.ts b/packages/vector-pools/src/attrib-pool.ts index 7b54fe106b..81dffb04e8 100644 --- a/packages/vector-pools/src/attrib-pool.ts +++ b/packages/vector-pools/src/attrib-pool.ts @@ -1,16 +1,13 @@ -import { - assert, - IObjectOf, - IRelease, - sizeOf, - TypedArray, - typedArray, -} from "@thi.ng/api"; -import { align, Pow2 } from "@thi.ng/binary"; -import { isNumber } from "@thi.ng/checks"; -import { MemPool } from "@thi.ng/malloc"; -import { range } from "@thi.ng/transducers"; -import { ReadonlyVec, Vec, zeroes } from "@thi.ng/vectors"; +import type { IObjectOf, IRelease } from "@thi.ng/api"; +import { sizeOf, TypedArray, typedArray } from "@thi.ng/api/api/typedarray"; +import { assert } from "@thi.ng/api/assert"; +import type { Pow2 } from "@thi.ng/binary"; +import { align } from "@thi.ng/binary/align"; +import { isNumber } from "@thi.ng/checks/is-number"; +import { MemPool } from "@thi.ng/malloc/pool"; +import { range } from "@thi.ng/transducers/iter/range"; +import type { ReadonlyVec, Vec } from "@thi.ng/vectors"; +import { zeroes } from "@thi.ng/vectors/setn"; import { AttribPoolOpts, AttribSpec, LOGGER } from "./api"; /* diff --git a/packages/vector-pools/src/vec-pool.ts b/packages/vector-pools/src/vec-pool.ts index 86b569d3cb..0969d08039 100644 --- a/packages/vector-pools/src/vec-pool.ts +++ b/packages/vector-pools/src/vec-pool.ts @@ -1,6 +1,12 @@ -import { asNativeType, GLType, Type, TypedArray } from "@thi.ng/api"; -import { isTypedArray } from "@thi.ng/checks"; -import { MemPool, MemPoolOpts, MemPoolStats } from "@thi.ng/malloc"; +import { + asNativeType, + GLType, + Type, + TypedArray, +} from "@thi.ng/api/api/typedarray"; +import { isTypedArray } from "@thi.ng/checks/is-typedarray"; +import type { MemPoolOpts, MemPoolStats } from "@thi.ng/malloc"; +import { MemPool } from "@thi.ng/malloc/pool"; import type { StridedVec } from "@thi.ng/vectors"; import type { IVecPool } from "./api"; import { wrap } from "./wrap"; diff --git a/packages/vector-pools/src/wrap.ts b/packages/vector-pools/src/wrap.ts index a29f80b528..70a447acde 100644 --- a/packages/vector-pools/src/wrap.ts +++ b/packages/vector-pools/src/wrap.ts @@ -1,5 +1,9 @@ import type { NumericArray } from "@thi.ng/api"; -import { gvec, IVector, Vec2, Vec3, Vec4 } from "@thi.ng/vectors"; +import type { IVector } from "@thi.ng/vectors"; +import { gvec } from "@thi.ng/vectors/gvec"; +import { Vec2 } from "@thi.ng/vectors/vec2"; +import { Vec3 } from "@thi.ng/vectors/vec3"; +import { Vec4 } from "@thi.ng/vectors/vec4"; export const wrap = ( buf: NumericArray, diff --git a/packages/vectors/src/angle-between.ts b/packages/vectors/src/angle-between.ts index 7df8810d08..900ecc26dc 100644 --- a/packages/vectors/src/angle-between.ts +++ b/packages/vectors/src/angle-between.ts @@ -1,5 +1,5 @@ import type { FnU2 } from "@thi.ng/api"; -import { absInnerAngle } from "@thi.ng/math"; +import { absInnerAngle } from "@thi.ng/math/angle"; import type { ReadonlyVec } from "./api"; import { cross2 } from "./cross"; import { dot } from "./dot"; diff --git a/packages/vectors/src/bisect.ts b/packages/vectors/src/bisect.ts index 94c45a5d41..78b539fcf1 100644 --- a/packages/vectors/src/bisect.ts +++ b/packages/vectors/src/bisect.ts @@ -1,4 +1,4 @@ -import { HALF_PI, PI } from "@thi.ng/math"; +import { HALF_PI, PI } from "@thi.ng/math/api"; import { addmN } from "./addmn"; import type { ReadonlyVec, Vec, VecOpRoVV } from "./api"; import { direction } from "./direction"; diff --git a/packages/vectors/src/buffer.ts b/packages/vectors/src/buffer.ts index b3302b4342..cfae1c053c 100644 --- a/packages/vectors/src/buffer.ts +++ b/packages/vectors/src/buffer.ts @@ -1,10 +1,5 @@ -import { - NumericArray, - SIZEOF, - Type, - typedArray, - TypedArrayTypeMap, -} from "@thi.ng/api"; +import type { NumericArray, TypedArrayTypeMap } from "@thi.ng/api"; +import { SIZEOF, Type, typedArray } from "@thi.ng/api/api/typedarray"; import type { ReadonlyVec, Vec, VecOpSV, VectorConstructor } from "./api"; /** diff --git a/packages/vectors/src/cartesian.ts b/packages/vectors/src/cartesian.ts index 0848184a73..b63c33c675 100644 --- a/packages/vectors/src/cartesian.ts +++ b/packages/vectors/src/cartesian.ts @@ -1,4 +1,4 @@ -import { cossin } from "@thi.ng/math"; +import { cossin } from "@thi.ng/math/angle"; import { MultiVecOpVO, ReadonlyVec, ZERO2, ZERO3 } from "./api"; import { vop } from "./internal/vop"; import { maddN2 } from "./maddn"; diff --git a/packages/vectors/src/clamp.ts b/packages/vectors/src/clamp.ts index f540197544..a46fc67a45 100644 --- a/packages/vectors/src/clamp.ts +++ b/packages/vectors/src/clamp.ts @@ -2,7 +2,7 @@ import { clamp as _clamp, clamp01 as _clamp01, clamp11 as _clamp11, -} from "@thi.ng/math"; +} from "@thi.ng/math/interval"; import type { MultiVecOpVVV, VecOpVVV } from "./api"; import { ARGS_VVV, defHofOp } from "./internal/codegen"; import { FN3 } from "./internal/templates"; diff --git a/packages/vectors/src/clampn.ts b/packages/vectors/src/clampn.ts index efd4b15a36..b25d4a0472 100644 --- a/packages/vectors/src/clampn.ts +++ b/packages/vectors/src/clampn.ts @@ -1,4 +1,4 @@ -import { clamp as _clamp } from "@thi.ng/math"; +import { clamp as _clamp } from "@thi.ng/math/interval"; import type { MultiVecOpVNN, VecOpVNN } from "./api"; import { defHofOp } from "./internal/codegen"; diff --git a/packages/vectors/src/clockwise.ts b/packages/vectors/src/clockwise.ts index b9a4252f30..85b9ec2f5e 100644 --- a/packages/vectors/src/clockwise.ts +++ b/packages/vectors/src/clockwise.ts @@ -1,4 +1,5 @@ -import { EPS, sign } from "@thi.ng/math"; +import { sign } from "@thi.ng/math/abs"; +import { EPS } from "@thi.ng/math/api"; import type { ReadonlyVec } from "./api"; import { signedArea2 } from "./signed-area"; diff --git a/packages/vectors/src/copy.ts b/packages/vectors/src/copy.ts index 3f160fdfb5..9211875f3b 100644 --- a/packages/vectors/src/copy.ts +++ b/packages/vectors/src/copy.ts @@ -1,4 +1,4 @@ -import { implementsFunction } from "@thi.ng/checks"; +import { implementsFunction } from "@thi.ng/checks/implements-function"; import type { ReadonlyVec, Vec } from "./api"; import { set } from "./set"; diff --git a/packages/vectors/src/degrees.ts b/packages/vectors/src/degrees.ts index ed33890e86..c50775a92e 100644 --- a/packages/vectors/src/degrees.ts +++ b/packages/vectors/src/degrees.ts @@ -1,4 +1,4 @@ -import { deg } from "@thi.ng/math"; +import { deg } from "@thi.ng/math/angle"; import type { MultiVecOpV, VecOpV } from "./api"; import { defHofOp } from "./internal/codegen"; import { FN } from "./internal/templates"; diff --git a/packages/vectors/src/empty.ts b/packages/vectors/src/empty.ts index 5e8f9a8ba4..377472c0b2 100644 --- a/packages/vectors/src/empty.ts +++ b/packages/vectors/src/empty.ts @@ -1,4 +1,4 @@ -import { implementsFunction } from "@thi.ng/checks"; +import { implementsFunction } from "@thi.ng/checks/implements-function"; import type { ReadonlyVec, Vec } from "./api"; import { zeroes } from "./setn"; diff --git a/packages/vectors/src/eqdelta.ts b/packages/vectors/src/eqdelta.ts index 5c946fe708..b156cb751b 100644 --- a/packages/vectors/src/eqdelta.ts +++ b/packages/vectors/src/eqdelta.ts @@ -1,5 +1,6 @@ -import { implementsFunction } from "@thi.ng/checks"; -import { EPS, eqDelta as _eq } from "@thi.ng/math"; +import { implementsFunction } from "@thi.ng/checks/implements-function"; +import { EPS } from "@thi.ng/math/api"; +import { eqDelta as _eq } from "@thi.ng/math/eqdelta"; import type { MultiVecOpRoVVO, ReadonlyVec } from "./api"; import { compileHOF } from "./internal/codegen"; import { vop } from "./internal/vop"; diff --git a/packages/vectors/src/fit.ts b/packages/vectors/src/fit.ts index 614eba399e..efc4ee1127 100644 --- a/packages/vectors/src/fit.ts +++ b/packages/vectors/src/fit.ts @@ -1,4 +1,8 @@ -import { fit as _fit, fit01 as _fit01, fit11 as _fit11 } from "@thi.ng/math"; +import { + fit as _fit, + fit01 as _fit01, + fit11 as _fit11, +} from "@thi.ng/math/fit"; import type { MultiVecOpVVV, MultiVecOpVVVVV, diff --git a/packages/vectors/src/fract.ts b/packages/vectors/src/fract.ts index a2c6b83eb1..f9fc31fcaf 100644 --- a/packages/vectors/src/fract.ts +++ b/packages/vectors/src/fract.ts @@ -1,4 +1,4 @@ -import { fract as _fract } from "@thi.ng/math"; +import { fract as _fract } from "@thi.ng/math/prec"; import type { MultiVecOpV, VecOpV } from "./api"; import { defHofOp } from "./internal/codegen"; diff --git a/packages/vectors/src/gvec.ts b/packages/vectors/src/gvec.ts index c50c725a78..599e9e8663 100644 --- a/packages/vectors/src/gvec.ts +++ b/packages/vectors/src/gvec.ts @@ -1,7 +1,8 @@ import type { NumericArray, StringOrSym } from "@thi.ng/api"; -import { EPS } from "@thi.ng/math"; -import { memoize1 } from "@thi.ng/memoize"; -import { map, range } from "@thi.ng/transducers"; +import { EPS } from "@thi.ng/math/api"; +import { memoize1 } from "@thi.ng/memoize/memoize1"; +import { range } from "@thi.ng/transducers/iter/range"; +import { map } from "@thi.ng/transducers/xform/map"; import type { IVector } from "./api"; import { eqDeltaS } from "./eqdelta"; import { stridedValues } from "./internal/vec-utils"; diff --git a/packages/vectors/src/hash.ts b/packages/vectors/src/hash.ts index 99f1176c07..ea17a23a6c 100644 --- a/packages/vectors/src/hash.ts +++ b/packages/vectors/src/hash.ts @@ -1,5 +1,6 @@ import type { FnN2 } from "@thi.ng/api"; -import { floatToUintBits, rotateLeft } from "@thi.ng/binary"; +import { floatToUintBits } from "@thi.ng/binary/float"; +import { rotateLeft } from "@thi.ng/binary/rotate"; import type { ReadonlyVec } from "./api"; /** diff --git a/packages/vectors/src/heading-segment.ts b/packages/vectors/src/heading-segment.ts index b8c0fdc883..78d35d33c0 100644 --- a/packages/vectors/src/heading-segment.ts +++ b/packages/vectors/src/heading-segment.ts @@ -1,9 +1,11 @@ import type { FnU2 } from "@thi.ng/api"; -import { atan2Abs } from "@thi.ng/math"; +import { atan2Abs } from "@thi.ng/math/angle"; import type { ReadonlyVec } from "./api"; -const $ = (u: number, v: number): FnU2 => (a, b) => - atan2Abs(b[u] - a[u], b[v] - a[v]); +const $ = + (u: number, v: number): FnU2 => + (a, b) => + atan2Abs(b[u] - a[u], b[v] - a[v]); /** * Computes direction angle (in radians) of line segment `a` -> `b` in diff --git a/packages/vectors/src/heading.ts b/packages/vectors/src/heading.ts index 4ff2dbf200..dd00f92f9b 100644 --- a/packages/vectors/src/heading.ts +++ b/packages/vectors/src/heading.ts @@ -1,4 +1,4 @@ -import { atan2Abs } from "@thi.ng/math"; +import { atan2Abs } from "@thi.ng/math/angle"; import type { ReadonlyVec } from "./api"; /** diff --git a/packages/vectors/src/internal/codegen.ts b/packages/vectors/src/internal/codegen.ts index a27981e382..a18e097682 100644 --- a/packages/vectors/src/internal/codegen.ts +++ b/packages/vectors/src/internal/codegen.ts @@ -1,14 +1,12 @@ import type { FnU2 } from "@thi.ng/api"; -import { - comp, - map, - mapIndexed, - range, - str, - take, - transduce, - zip, -} from "@thi.ng/transducers"; +import { comp } from "@thi.ng/transducers/func/comp"; +import { range } from "@thi.ng/transducers/iter/range"; +import { zip } from "@thi.ng/transducers/iter/zip"; +import { str } from "@thi.ng/transducers/rfn/str"; +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 { take } from "@thi.ng/transducers/xform/take"; import type { MultiVecOpVN, MultiVecOpVV, diff --git a/packages/vectors/src/internal/ensure.ts b/packages/vectors/src/internal/ensure.ts index a8d84d8d2c..d8fcb09b4b 100644 --- a/packages/vectors/src/internal/ensure.ts +++ b/packages/vectors/src/internal/ensure.ts @@ -1,4 +1,4 @@ -import { assert } from "@thi.ng/api"; +import { assert } from "@thi.ng/api/assert"; /** * Asserts that `src` has at least 1 item. diff --git a/packages/vectors/src/internal/vop.ts b/packages/vectors/src/internal/vop.ts index 7edb8fb487..459f8bc731 100644 --- a/packages/vectors/src/internal/vop.ts +++ b/packages/vectors/src/internal/vop.ts @@ -1,4 +1,4 @@ -import { unsupported } from "@thi.ng/errors"; +import { unsupported } from "@thi.ng/errors/unsupported"; /** * Specialized / optimized version of {@link @thi.ng/defmulti# | @thi.ng/defmulti} for diff --git a/packages/vectors/src/jitter.ts b/packages/vectors/src/jitter.ts index 7e82ab8943..8738b146b0 100644 --- a/packages/vectors/src/jitter.ts +++ b/packages/vectors/src/jitter.ts @@ -1,4 +1,5 @@ -import { IRandom, SYSTEM } from "@thi.ng/random"; +import type { IRandom } from "@thi.ng/random"; +import { SYSTEM } from "@thi.ng/random/system"; import { add } from "./add"; import type { ReadonlyVec, Vec } from "./api"; import { randNorm } from "./random"; diff --git a/packages/vectors/src/major.ts b/packages/vectors/src/major.ts index b935f97569..2f876672a7 100644 --- a/packages/vectors/src/major.ts +++ b/packages/vectors/src/major.ts @@ -1,4 +1,4 @@ -import { max2id, max3id, max4id } from "@thi.ng/math"; +import { max2id, max3id, max4id } from "@thi.ng/math/interval"; import type { MultiVecOpRoV } from "./api"; import { vop } from "./internal/vop"; diff --git a/packages/vectors/src/map-vectors.ts b/packages/vectors/src/map-vectors.ts index f3017940f4..94b5d0cf6b 100644 --- a/packages/vectors/src/map-vectors.ts +++ b/packages/vectors/src/map-vectors.ts @@ -6,7 +6,7 @@ import type { VecOpVVV, VecOpVVN, } from "./api"; -import { isNumber } from "@thi.ng/checks"; +import { isNumber } from "@thi.ng/checks/is-number"; /** * Takes a vec op `fn`, output array (or null) and a combination of the diff --git a/packages/vectors/src/minor.ts b/packages/vectors/src/minor.ts index 3e64a90dfe..d3ffab396a 100644 --- a/packages/vectors/src/minor.ts +++ b/packages/vectors/src/minor.ts @@ -1,4 +1,4 @@ -import { min2id, min3id, min4id } from "@thi.ng/math"; +import { min2id, min3id, min4id } from "@thi.ng/math/interval"; import type { MultiVecOpRoV } from "./api"; import { vop } from "./internal/vop"; diff --git a/packages/vectors/src/mix-bilinear.ts b/packages/vectors/src/mix-bilinear.ts index 13fe2c9446..c0b9670475 100644 --- a/packages/vectors/src/mix-bilinear.ts +++ b/packages/vectors/src/mix-bilinear.ts @@ -1,4 +1,4 @@ -import { mixBilinear as _mix } from "@thi.ng/math"; +import { mixBilinear as _mix } from "@thi.ng/math/mix"; import type { MultiVecOpVVVVNN, VecOpVVVVNN } from "./api"; import { defHofOp } from "./internal/codegen"; diff --git a/packages/vectors/src/mod.ts b/packages/vectors/src/mod.ts index f462ab4e37..ab032f805a 100644 --- a/packages/vectors/src/mod.ts +++ b/packages/vectors/src/mod.ts @@ -1,4 +1,4 @@ -import { mod as _mod } from "@thi.ng/math"; +import { mod as _mod } from "@thi.ng/math/prec"; import type { MultiVecOpVV, VecOpVV } from "./api"; import { ARGS_VV, defHofOp } from "./internal/codegen"; import { FN2 } from "./internal/templates"; diff --git a/packages/vectors/src/modn.ts b/packages/vectors/src/modn.ts index 32316c897e..e91b88de2f 100644 --- a/packages/vectors/src/modn.ts +++ b/packages/vectors/src/modn.ts @@ -1,4 +1,4 @@ -import { mod as _mod } from "@thi.ng/math"; +import { mod as _mod } from "@thi.ng/math/prec"; import type { MultiVecOpVN, VecOpVN } from "./api"; import { ARGS_V, ARGS_VN, defHofOp } from "./internal/codegen"; import { FN_N } from "./internal/templates"; diff --git a/packages/vectors/src/normalize.ts b/packages/vectors/src/normalize.ts index 219398625a..3f5f4f1e40 100644 --- a/packages/vectors/src/normalize.ts +++ b/packages/vectors/src/normalize.ts @@ -1,4 +1,4 @@ -import { EPS } from "@thi.ng/math"; +import { EPS } from "@thi.ng/math/api"; import type { VecOpVO } from "./api"; import { mag } from "./mag"; import { mulN } from "./muln"; diff --git a/packages/vectors/src/normalizes.ts b/packages/vectors/src/normalizes.ts index 50825e5cc3..5fc9374b48 100644 --- a/packages/vectors/src/normalizes.ts +++ b/packages/vectors/src/normalizes.ts @@ -1,4 +1,4 @@ -import { EPS } from "@thi.ng/math"; +import { EPS } from "@thi.ng/math/api"; import type { VecOpSGVO, VecOpSVO } from "./api"; import { magS, magS2, magS3, magS4 } from "./mags"; import { mulNS, mulNS2, mulNS3, mulNS4 } from "./mulns"; diff --git a/packages/vectors/src/radians.ts b/packages/vectors/src/radians.ts index 9e6410f586..7f3525ae41 100644 --- a/packages/vectors/src/radians.ts +++ b/packages/vectors/src/radians.ts @@ -1,4 +1,4 @@ -import { rad } from "@thi.ng/math"; +import { rad } from "@thi.ng/math/angle"; import type { MultiVecOpV, VecOpV } from "./api"; import { defHofOp } from "./internal/codegen"; import { FN } from "./internal/templates"; diff --git a/packages/vectors/src/random.ts b/packages/vectors/src/random.ts index f2e1839df3..91a7d39095 100644 --- a/packages/vectors/src/random.ts +++ b/packages/vectors/src/random.ts @@ -1,4 +1,5 @@ -import { IRandom, SYSTEM } from "@thi.ng/random"; +import type { IRandom } from "@thi.ng/random"; +import { SYSTEM } from "@thi.ng/random/system"; import type { MultiVecOpOOO, ReadonlyVec, Vec, VecOpOOO } from "./api"; import { defHofOp } from "./internal/codegen"; import { normalize } from "./normalize"; diff --git a/packages/vectors/src/randoms.ts b/packages/vectors/src/randoms.ts index b60fa14550..110ac20377 100644 --- a/packages/vectors/src/randoms.ts +++ b/packages/vectors/src/randoms.ts @@ -1,4 +1,5 @@ -import { IRandom, SYSTEM } from "@thi.ng/random"; +import type { IRandom } from "@thi.ng/random"; +import { SYSTEM } from "@thi.ng/random/system"; import type { VecOpSGOO, VecOpSGOOO, diff --git a/packages/vectors/src/remainder.ts b/packages/vectors/src/remainder.ts index 4f47f9a902..a8193887ae 100644 --- a/packages/vectors/src/remainder.ts +++ b/packages/vectors/src/remainder.ts @@ -1,4 +1,4 @@ -import { remainder as _remainder } from "@thi.ng/math"; +import { remainder as _remainder } from "@thi.ng/math/libc"; import type { MultiVecOpVV, VecOpVV } from "./api"; import { ARGS_VV, defHofOp } from "./internal/codegen"; import { FN2 } from "./internal/templates"; diff --git a/packages/vectors/src/remaindern.ts b/packages/vectors/src/remaindern.ts index ac53ca591c..e04fa45c8c 100644 --- a/packages/vectors/src/remaindern.ts +++ b/packages/vectors/src/remaindern.ts @@ -1,4 +1,4 @@ -import { remainder as _remainder } from "@thi.ng/math"; +import { remainder as _remainder } from "@thi.ng/math/libc"; import type { MultiVecOpVN, VecOpVN } from "./api"; import { ARGS_V, ARGS_VN, defHofOp } from "./internal/codegen"; import { FN_N } from "./internal/templates"; diff --git a/packages/vectors/src/round.ts b/packages/vectors/src/round.ts index 4cf7163358..7c8ed5562f 100644 --- a/packages/vectors/src/round.ts +++ b/packages/vectors/src/round.ts @@ -1,4 +1,4 @@ -import { roundTo as _round } from "@thi.ng/math"; +import { roundTo as _round } from "@thi.ng/math/prec"; import type { MultiVecOpVO, MultiVecOpVV, VecOpVO, VecOpVV } from "./api"; import { ARGS_VV, defHofOp } from "./internal/codegen"; import { FN2, FN_N } from "./internal/templates"; diff --git a/packages/vectors/src/safe-div.ts b/packages/vectors/src/safe-div.ts index f2cb1266af..cdae89e42f 100644 --- a/packages/vectors/src/safe-div.ts +++ b/packages/vectors/src/safe-div.ts @@ -1,4 +1,4 @@ -import { safeDiv as _div } from "@thi.ng/math"; +import { safeDiv as _div } from "@thi.ng/math/safe-div"; import type { MultiVecOpVV, VecOpVV } from "./api"; import { ARGS_VV, defHofOp } from "./internal/codegen"; import { FN2 } from "./internal/templates"; diff --git a/packages/vectors/src/smoothstep.ts b/packages/vectors/src/smoothstep.ts index 6263017bef..69b97afcd8 100644 --- a/packages/vectors/src/smoothstep.ts +++ b/packages/vectors/src/smoothstep.ts @@ -1,4 +1,4 @@ -import { smoothStep as _step } from "@thi.ng/math"; +import { smoothStep as _step } from "@thi.ng/math/step"; import type { MultiVecOpVVV, VecOpVVV } from "./api"; import { DEFAULT_OUT, defHofOp } from "./internal/codegen"; import { FN3 } from "./internal/templates"; diff --git a/packages/vectors/src/step.ts b/packages/vectors/src/step.ts index 14be3a850f..9ba5ae40bb 100644 --- a/packages/vectors/src/step.ts +++ b/packages/vectors/src/step.ts @@ -1,4 +1,4 @@ -import { step as _step } from "@thi.ng/math"; +import { step as _step } from "@thi.ng/math/step"; import type { MultiVecOpVV, VecOpVV } from "./api"; import { DEFAULT_OUT, defHofOp } from "./internal/codegen"; import { FN2 } from "./internal/templates"; diff --git a/packages/vectors/src/string.ts b/packages/vectors/src/string.ts index 7fb549fb43..cb233ed505 100644 --- a/packages/vectors/src/string.ts +++ b/packages/vectors/src/string.ts @@ -1,5 +1,6 @@ -import { isFunction } from "@thi.ng/checks"; -import { float, floatFixedWidth, Stringer } from "@thi.ng/strings"; +import { isFunction } from "@thi.ng/checks/is-function"; +import type { Stringer } from "@thi.ng/strings"; +import { float, floatFixedWidth } from "@thi.ng/strings/float"; import type { ToStringOpts } from "./api"; /** diff --git a/packages/vectors/src/sum.ts b/packages/vectors/src/sum.ts index be6d93b602..789e72f7c1 100644 --- a/packages/vectors/src/sum.ts +++ b/packages/vectors/src/sum.ts @@ -1,4 +1,5 @@ -import { add, reduce } from "@thi.ng/transducers"; +import { reduce } from "@thi.ng/transducers/reduce"; +import { add } from "@thi.ng/transducers/rfn/add"; import type { MultiVecOpRoV } from "./api"; import { vop } from "./internal/vop"; diff --git a/packages/vectors/src/vec2.ts b/packages/vectors/src/vec2.ts index 476fc6330b..83bc2f720c 100644 --- a/packages/vectors/src/vec2.ts +++ b/packages/vectors/src/vec2.ts @@ -1,5 +1,5 @@ import type { IHash, NumericArray } from "@thi.ng/api"; -import { EPS } from "@thi.ng/math"; +import { EPS } from "@thi.ng/math/api"; import { IVector, MAX2, diff --git a/packages/vectors/src/vec3.ts b/packages/vectors/src/vec3.ts index b8e9f78095..65aefef7d1 100644 --- a/packages/vectors/src/vec3.ts +++ b/packages/vectors/src/vec3.ts @@ -1,5 +1,5 @@ import type { IHash, NumericArray } from "@thi.ng/api"; -import { EPS } from "@thi.ng/math"; +import { EPS } from "@thi.ng/math/api"; import { IVector, MAX3, diff --git a/packages/vectors/src/vec4.ts b/packages/vectors/src/vec4.ts index ce9a71476d..7bada29eca 100644 --- a/packages/vectors/src/vec4.ts +++ b/packages/vectors/src/vec4.ts @@ -1,5 +1,5 @@ import type { IHash, NumericArray } from "@thi.ng/api"; -import { EPS } from "@thi.ng/math"; +import { EPS } from "@thi.ng/math/api"; import { IVector, MAX4, diff --git a/packages/vectors/src/wrap.ts b/packages/vectors/src/wrap.ts index 26d505061e..f9ec419e7d 100644 --- a/packages/vectors/src/wrap.ts +++ b/packages/vectors/src/wrap.ts @@ -1,4 +1,4 @@ -import { wrap as _wrap } from "@thi.ng/math"; +import { wrap as _wrap } from "@thi.ng/math/interval"; import type { MultiVecOpVVV, VecOpVVV } from "./api"; import { ARGS_VVV, defHofOp } from "./internal/codegen"; import { FN3 } from "./internal/templates"; diff --git a/packages/viz/src/axis/common.ts b/packages/viz/src/axis/common.ts index a97f7d1dae..28b74b711d 100644 --- a/packages/viz/src/axis/common.ts +++ b/packages/viz/src/axis/common.ts @@ -1,4 +1,4 @@ -import { float } from "@thi.ng/strings"; +import { float } from "@thi.ng/strings/float"; import type { AxisSpec } from "../api"; export const axisDefaults = (extra?: any): Partial => ({ diff --git a/packages/viz/src/axis/lens.ts b/packages/viz/src/axis/lens.ts index e94c72dfd3..7ef3156a4b 100644 --- a/packages/viz/src/axis/lens.ts +++ b/packages/viz/src/axis/lens.ts @@ -1,5 +1,6 @@ -import { mergeDeepObj } from "@thi.ng/associative"; -import { lens, mix, safeDiv } from "@thi.ng/math"; +import { mergeDeepObj } from "@thi.ng/associative/merge-deep"; +import { lens, mix } from "@thi.ng/math/mix"; +import { safeDiv } from "@thi.ng/math/safe-div"; import type { AxisSpec, Domain, InitialAxisSpec, Range, ScaleFn } from "../api"; import { axisDefaults } from "./common"; diff --git a/packages/viz/src/axis/linear.ts b/packages/viz/src/axis/linear.ts index 96b97b9508..760c8f39c9 100644 --- a/packages/viz/src/axis/linear.ts +++ b/packages/viz/src/axis/linear.ts @@ -1,12 +1,16 @@ -import { mergeDeepObj } from "@thi.ng/associative"; -import { fit, inRange, roundTo } from "@thi.ng/math"; -import { filter, range } from "@thi.ng/transducers"; +import { mergeDeepObj } from "@thi.ng/associative/merge-deep"; +import { fit } from "@thi.ng/math/fit"; +import { inRange } from "@thi.ng/math/interval"; +import { roundTo } from "@thi.ng/math/prec"; +import { range } from "@thi.ng/transducers/iter/range"; +import { filter } from "@thi.ng/transducers/xform/filter"; import type { AxisSpec, Domain, InitialAxisSpec, Range, ScaleFn } from "../api"; import { axisDefaults } from "./common"; -export const linearScale = ([d1, d2]: Domain, [r1, r2]: Range): ScaleFn => ( - x -) => fit(x, d1, d2, r1, r2); +export const linearScale = + ([d1, d2]: Domain, [r1, r2]: Range): ScaleFn => + (x) => + fit(x, d1, d2, r1, r2); export const linearAxis = (src: InitialAxisSpec) => { const spec = mergeDeepObj(axisDefaults(), src); @@ -14,9 +18,12 @@ export const linearAxis = (src: InitialAxisSpec) => { return spec; }; -export const linearTicks = (step: number) => ([d1, d2]: Domain) => [ - ...filter( - (x) => inRange(x, d1, d2), - range(roundTo(d1, step), d2 + step, step) - ), -]; +export const linearTicks = + (step: number) => + ([d1, d2]: Domain) => + [ + ...filter( + (x) => inRange(x, d1, d2), + range(roundTo(d1, step), d2 + step, step) + ), + ]; diff --git a/packages/viz/src/axis/log.ts b/packages/viz/src/axis/log.ts index a3e32e16b2..d5d49b7def 100644 --- a/packages/viz/src/axis/log.ts +++ b/packages/viz/src/axis/log.ts @@ -1,14 +1,13 @@ import type { FnN, FnU3 } from "@thi.ng/api"; -import { mergeDeepObj } from "@thi.ng/associative"; -import { inRange, mix } from "@thi.ng/math"; -import { - comp, - filter, - iterator, - map, - range, - range2d, -} from "@thi.ng/transducers"; +import { mergeDeepObj } from "@thi.ng/associative/merge-deep"; +import { inRange } from "@thi.ng/math/interval"; +import { mix } from "@thi.ng/math/mix"; +import { comp } from "@thi.ng/transducers/func/comp"; +import { range } from "@thi.ng/transducers/iter/range"; +import { range2d } from "@thi.ng/transducers/iter/range2d"; +import { iterator } from "@thi.ng/transducers/iterator"; +import { filter } from "@thi.ng/transducers/xform/filter"; +import { map } from "@thi.ng/transducers/xform/map"; import type { AxisSpec, Domain, InitialAxisSpec, Range, ScaleFn } from "../api"; import { axisDefaults } from "./common"; @@ -51,28 +50,32 @@ export const logDomain: FnU3 = (d1, d2, base) => { return [Math.floor($(d1)), Math.ceil($(d2))]; }; -export const logTicksMajor = (base = 10) => ([d1, d2]: Domain) => { - const [d1l, d2l] = logDomain(d1, d2, base); - return [ - ...iterator( - comp( - map((x) => Math.pow(base, x)), - filter((x) => inRange(x, d1, d2)) +export const logTicksMajor = + (base = 10) => + ([d1, d2]: Domain) => { + const [d1l, d2l] = logDomain(d1, d2, base); + return [ + ...iterator( + comp( + map((x) => Math.pow(base, x)), + filter((x) => inRange(x, d1, d2)) + ), + range(d1l, d2l + 1) ), - range(d1l, d2l + 1) - ), - ]; -}; + ]; + }; -export const logTicksMinor = (base = 10) => ([d1, d2]: Domain) => { - const [d1l, d2l] = logDomain(d1, d2, base); - return [ - ...iterator( - comp( - map(([m, n]) => (m * Math.pow(base, n)) / base), - filter((x) => inRange(x, d1, d2)) +export const logTicksMinor = + (base = 10) => + ([d1, d2]: Domain) => { + const [d1l, d2l] = logDomain(d1, d2, base); + return [ + ...iterator( + comp( + map(([m, n]) => (m * Math.pow(base, n)) / base), + filter((x) => inRange(x, d1, d2)) + ), + range2d(1, base, d1l, d2l + 1) ), - range2d(1, base, d1l, d2l + 1) - ), - ]; -}; + ]; + }; diff --git a/packages/viz/src/domain.ts b/packages/viz/src/domain.ts index ff6c030017..5a1030bca9 100644 --- a/packages/viz/src/domain.ts +++ b/packages/viz/src/domain.ts @@ -1,7 +1,11 @@ import type { Fn } from "@thi.ng/api"; -import { ensureArray } from "@thi.ng/arrays"; -import { mix } from "@thi.ng/math"; -import { juxtR, map, max, min, transduce } from "@thi.ng/transducers"; +import { ensureArray } from "@thi.ng/arrays/ensure-array"; +import { mix } from "@thi.ng/math/mix"; +import { max } from "@thi.ng/transducers/rfn/max"; +import { min } from "@thi.ng/transducers/rfn/min"; +import { minMax } from "@thi.ng/transducers/rfn/min-max"; +import { transduce } from "@thi.ng/transducers/transduce"; +import { map } from "@thi.ng/transducers/xform/map"; import type { DomainValueFn } from "./api"; export const uniformDomain = (src: Iterable): DomainValueFn => { @@ -13,7 +17,7 @@ export const uniformDomain = (src: Iterable): DomainValueFn => { }; export const dataBounds = (fn: Fn, src: T[], pad = 0) => { - const b = transduce(map(fn), juxtR(min(), max()), src); + const b = transduce(map(fn), minMax(), src); b[0] -= pad; b[1] += pad; return b; diff --git a/packages/viz/src/plot.ts b/packages/viz/src/plot.ts index a03208d707..bb137148d6 100644 --- a/packages/viz/src/plot.ts +++ b/packages/viz/src/plot.ts @@ -1,6 +1,9 @@ import type { Fn } from "@thi.ng/api"; -import { eqDelta } from "@thi.ng/math"; -import { comp, filter, iterator, mapcat } from "@thi.ng/transducers"; +import { eqDelta } from "@thi.ng/math/eqdelta"; +import { comp } from "@thi.ng/transducers/func/comp"; +import { iterator } from "@thi.ng/transducers/iterator"; +import { filter } from "@thi.ng/transducers/xform/filter"; +import { mapcat } from "@thi.ng/transducers/xform/mapcat"; import type { AxisSpec, VizSpec } from "./api"; const gridAxis = ( @@ -98,10 +101,11 @@ export const cartesianAxisX = (spec: AxisSpec) => { labelOffset: [lx, ly], range: [r1, r2], } = spec; - const tick = (dy: number) => (x: number) => [ - ["M", [scale(x), pos]], - ["v", dy], - ]; + const tick = (dy: number) => (x: number) => + [ + ["M", [scale(x), pos]], + ["v", dy], + ]; return axisCommon( spec, [ @@ -127,10 +131,11 @@ export const cartesianAxisY = (spec: AxisSpec) => { labelOffset: [lx, ly], range: [r1, r2], } = spec; - const tick = (dx: number) => (y: number) => [ - ["M", [pos, scale(y)]], - ["h", dx], - ]; + const tick = (dx: number) => (y: number) => + [ + ["M", [pos, scale(y)]], + ["h", dx], + ]; return axisCommon( spec, [ diff --git a/packages/viz/src/plot/area.ts b/packages/viz/src/plot/area.ts index f25cb269ad..15cf47efd8 100644 --- a/packages/viz/src/plot/area.ts +++ b/packages/viz/src/plot/area.ts @@ -1,4 +1,4 @@ -import { ensureArray } from "@thi.ng/arrays"; +import { ensureArray } from "@thi.ng/arrays/ensure-array"; import type { DomainValues, PlotFn } from "../api"; import { processedPoints, valueMapper } from "./utils"; @@ -6,20 +6,19 @@ export interface AreaPlotOpts { attribs: any; } -export const areaPlot = ( - data: DomainValues, - opts: Partial = {} -): PlotFn => (spec) => { - const $data = ensureArray(data); - const mapper = valueMapper(spec.xaxis, spec.yaxis, spec.project); - const y0 = spec.yaxis.domain[0]; - return [ - "polygon", - opts.attribs || {}, - [ - mapper([$data[0][0], y0]), - ...processedPoints(spec, data, true), - mapper([$data[$data.length - 1][0], y0]), - ], - ]; -}; +export const areaPlot = + (data: DomainValues, opts: Partial = {}): PlotFn => + (spec) => { + const $data = ensureArray(data); + const mapper = valueMapper(spec.xaxis, spec.yaxis, spec.project); + const y0 = spec.yaxis.domain[0]; + return [ + "polygon", + opts.attribs || {}, + [ + mapper([$data[0][0], y0]), + ...processedPoints(spec, data, true), + mapper([$data[$data.length - 1][0], y0]), + ], + ]; + }; diff --git a/packages/viz/src/plot/bar.ts b/packages/viz/src/plot/bar.ts index cb395111f1..8370f28b7b 100644 --- a/packages/viz/src/plot/bar.ts +++ b/packages/viz/src/plot/bar.ts @@ -1,6 +1,6 @@ import type { Fn3 } from "@thi.ng/api"; -import { isFunction } from "@thi.ng/checks"; -import { map } from "@thi.ng/transducers"; +import { isFunction } from "@thi.ng/checks/is-function"; +import { map } from "@thi.ng/transducers/xform/map"; import type { DomainValues, PlotFn } from "../api"; import { valueMapper } from "./utils"; @@ -12,34 +12,33 @@ export interface BarPlotOpts { shape: Fn3; } -export const barPlot = ( - data: DomainValues, - opts: Partial = {} -): PlotFn => (spec) => { - opts = { - interleave: 1, - offset: 0, - width: 5, - shape: (_, a, b) => ["line", {}, a, b], - ...opts, +export const barPlot = + (data: DomainValues, opts: Partial = {}): PlotFn => + (spec) => { + opts = { + interleave: 1, + offset: 0, + width: 5, + shape: (_, a, b) => ["line", {}, a, b], + ...opts, + }; + const mapper = valueMapper(spec.xaxis, spec.yaxis, spec.project); + const offset = + (opts.offset! + 0.5) * opts.width! - + 0.5 * opts.interleave! * opts.width!; + const y0 = spec.yaxis.domain[0]; + return [ + "g", + { weight: opts.width!, ...opts.attribs }, + ...map( + ([x, val]) => { + const a = mapper([x, y0]); + a[0] += offset; + const b = mapper([x, val]); + b[0] += offset; + return opts.shape!(val, a, b); + }, + isFunction(data) ? data(spec.xaxis.domain) : data + ), + ]; }; - const mapper = valueMapper(spec.xaxis, spec.yaxis, spec.project); - const offset = - (opts.offset! + 0.5) * opts.width! - - 0.5 * opts.interleave! * opts.width!; - const y0 = spec.yaxis.domain[0]; - return [ - "g", - { weight: opts.width!, ...opts.attribs }, - ...map( - ([x, val]) => { - const a = mapper([x, y0]); - a[0] += offset; - const b = mapper([x, val]); - b[0] += offset; - return opts.shape!(val, a, b); - }, - isFunction(data) ? data(spec.xaxis.domain) : data - ), - ]; -}; diff --git a/packages/viz/src/plot/candle.ts b/packages/viz/src/plot/candle.ts index e240f5f4dd..deea9e641b 100644 --- a/packages/viz/src/plot/candle.ts +++ b/packages/viz/src/plot/candle.ts @@ -1,6 +1,6 @@ import type { Fn2, Fn4, NumOrString } from "@thi.ng/api"; -import { isFunction } from "@thi.ng/checks"; -import { map } from "@thi.ng/transducers"; +import { isFunction } from "@thi.ng/checks/is-function"; +import { map } from "@thi.ng/transducers/xform/map"; import type { DomainValues, PlotFn } from "../api"; import { valueMapper } from "./utils"; @@ -21,33 +21,35 @@ export interface CandleShapeOpts { width: number; } -export const candlePlot = ( - data: DomainValues, - opts: CandlePlotOpts = { shape: candle() } -): PlotFn => (spec) => { - const mapper = valueMapper(spec.xaxis, spec.yaxis, spec.project); - return [ - "g", - {}, - ...map( - ([x, candle]) => { - const { o, h, l, c } = candle; - return opts.shape( - candle, - { - o: mapper([x, o]), - h: mapper([x, h]), - l: mapper([x, l]), - c: mapper([x, c]), - }, - x, - c >= o - ); - }, - isFunction(data) ? data(spec.xaxis.domain) : data - ), - ]; -}; +export const candlePlot = + ( + data: DomainValues, + opts: CandlePlotOpts = { shape: candle() } + ): PlotFn => + (spec) => { + const mapper = valueMapper(spec.xaxis, spec.yaxis, spec.project); + return [ + "g", + {}, + ...map( + ([x, candle]) => { + const { o, h, l, c } = candle; + return opts.shape( + candle, + { + o: mapper([x, o]), + h: mapper([x, h]), + l: mapper([x, l]), + c: mapper([x, c]), + }, + x, + c >= o + ); + }, + isFunction(data) ? data(spec.xaxis.domain) : data + ), + ]; + }; export const candle = (opts?: Partial) => { const { up, down, title, width } = { diff --git a/packages/viz/src/plot/stacked-intervals.ts b/packages/viz/src/plot/stacked-intervals.ts index 3de201c732..5399da7e58 100644 --- a/packages/viz/src/plot/stacked-intervals.ts +++ b/packages/viz/src/plot/stacked-intervals.ts @@ -1,14 +1,12 @@ import type { Fn, Fn2 } from "@thi.ng/api"; -import { - comp, - filter, - iterator, - map, - mapcatIndexed, - push, - some, - transduce, -} from "@thi.ng/transducers"; +import { comp } from "@thi.ng/transducers/func/comp"; +import { iterator } from "@thi.ng/transducers/iterator"; +import { push } from "@thi.ng/transducers/rfn/push"; +import { some } from "@thi.ng/transducers/rfn/some"; +import { transduce } from "@thi.ng/transducers/transduce"; +import { filter } from "@thi.ng/transducers/xform/filter"; +import { map } from "@thi.ng/transducers/xform/map"; +import { mapcatIndexed } from "@thi.ng/transducers/xform/mapcat-indexed"; import type { Domain, PlotFn } from "../api"; import { valueMapper } from "./utils"; @@ -37,46 +35,44 @@ const rowStacking = (data: [number[], T][], pad = 0) => } }, []>[]); -const processRow = (mapper: Fn, [d1, d2]: Domain) => ( - i: number, - row: Row -) => - map( - ([[a, b], item]) => - <[number[], number[], T, number]>[ - mapper([Math.max(d1, a), i]), - mapper([Math.min(d2, b), i]), - item, - i, - ], - row - ); +const processRow = + (mapper: Fn, [d1, d2]: Domain) => + (i: number, row: Row) => + map( + ([[a, b], item]) => + <[number[], number[], T, number]>[ + mapper([Math.max(d1, a), i]), + mapper([Math.min(d2, b), i]), + item, + i, + ], + row + ); -export const stackedIntervals = ( - data: T[], - opts: StackedIntervalOpts -): PlotFn => (spec) => { - const mapper = valueMapper(spec.xaxis, spec.yaxis, spec.project); - const domain = spec.xaxis.domain; - return [ - "g", - opts.attribs, - ...iterator( - comp( - mapcatIndexed(processRow(mapper, domain)), - map((x) => opts.shape(x, mapper)) +export const stackedIntervals = + (data: T[], opts: StackedIntervalOpts): PlotFn => + (spec) => { + const mapper = valueMapper(spec.xaxis, spec.yaxis, spec.project); + const domain = spec.xaxis.domain; + return [ + "g", + opts.attribs, + ...iterator( + comp( + mapcatIndexed(processRow(mapper, domain)), + map((x) => opts.shape(x, mapper)) + ), + rowStacking( + transduce( + comp( + map((x) => <[number[], T]>[opts.interval(x), x]), + filter(([x]) => overlap(domain, x, opts.overlap)) + ), + push<[number[], T]>(), + data + ).sort(opts.sort || ((a, b) => a[0][0] - b[0][0])), + opts.overlap + ) ), - rowStacking( - transduce( - comp( - map((x) => <[number[], T]>[opts.interval(x), x]), - filter(([x]) => overlap(domain, x, opts.overlap)) - ), - push<[number[], T]>(), - data - ).sort(opts.sort || ((a, b) => a[0][0] - b[0][0])), - opts.overlap - ) - ), - ]; -}; + ]; + }; diff --git a/packages/viz/src/plot/utils.ts b/packages/viz/src/plot/utils.ts index c44a0254a3..6e1aad44b9 100644 --- a/packages/viz/src/plot/utils.ts +++ b/packages/viz/src/plot/utils.ts @@ -1,14 +1,17 @@ import type { Fn } from "@thi.ng/api"; -import { isFunction } from "@thi.ng/checks"; -import { clamp, inRange } from "@thi.ng/math"; +import { isFunction } from "@thi.ng/checks/is-function"; +import { clamp, inRange } from "@thi.ng/math/interval"; import type { AxisSpec, DomainValues, PlotFn, VizSpec } from "../api"; /** @internal */ -export const valueMapper = ( - { scale: scaleX }: AxisSpec, - { scale: scaleY, domain: [dmin, dmax] }: AxisSpec, - project: Fn = (x) => x -) => ([x, y]: number[]) => project([scaleX(x), scaleY(clamp(y, dmin, dmax))]); +export const valueMapper = + ( + { scale: scaleX }: AxisSpec, + { scale: scaleY, domain: [dmin, dmax] }: AxisSpec, + project: Fn = (x) => x + ) => + ([x, y]: number[]) => + project([scaleX(x), scaleY(clamp(y, dmin, dmax))]); /** @internal */ export function processedPoints( @@ -41,11 +44,8 @@ export function* processedPoints( * * @internal */ -export const defSimplePlotFn = (shape: string) => ( - data: DomainValues, - opts: Partial = {} -): PlotFn => (spec) => [ - shape, - opts.attribs || {}, - [...processedPoints(spec, data, true)], -]; +export const defSimplePlotFn = + (shape: string) => + (data: DomainValues, opts: Partial = {}): PlotFn => + (spec) => + [shape, opts.attribs || {}, [...processedPoints(spec, data, true)]]; diff --git a/packages/webgl-msdf/src/shader.ts b/packages/webgl-msdf/src/shader.ts index f9d7c60855..b7a88a15ea 100644 --- a/packages/webgl-msdf/src/shader.ts +++ b/packages/webgl-msdf/src/shader.ts @@ -29,8 +29,9 @@ import { Vec2Sym, vec4, } from "@thi.ng/shader-ast"; -import { ONE4, ZERO4 } from "@thi.ng/vectors"; -import { BLEND_NORMAL, GLVec4, ShaderSpec } from "@thi.ng/webgl"; +import { ONE4, ZERO4 } from "@thi.ng/vectors/api"; +import type { GLVec4, ShaderSpec } from "@thi.ng/webgl"; +import { BLEND_NORMAL } from "@thi.ng/webgl/api/blend"; export interface MSDFShaderOpts { color: boolean; diff --git a/packages/webgl-msdf/src/text.ts b/packages/webgl-msdf/src/text.ts index 19f3b3f8ac..1c0dd5c356 100644 --- a/packages/webgl-msdf/src/text.ts +++ b/packages/webgl-msdf/src/text.ts @@ -1,6 +1,14 @@ -import { add, map, mapcat, range, transduce } from "@thi.ng/transducers"; -import { AttribPool } from "@thi.ng/vector-pools"; -import { addm2, invert2, madd2, mul2, ONE4 } from "@thi.ng/vectors"; +import { range } from "@thi.ng/transducers/iter/range"; +import { add } from "@thi.ng/transducers/rfn/add"; +import { transduce } from "@thi.ng/transducers/transduce"; +import { map } from "@thi.ng/transducers/xform/map"; +import { mapcat } from "@thi.ng/transducers/xform/mapcat"; +import { AttribPool } from "@thi.ng/vector-pools/attrib-pool"; +import { addm2 } from "@thi.ng/vectors/addm"; +import { ONE4 } from "@thi.ng/vectors/api"; +import { invert2 } from "@thi.ng/vectors/invert"; +import { madd2 } from "@thi.ng/vectors/madd"; +import { mul2 } from "@thi.ng/vectors/mul"; import type { GLVec4, ModelSpec } from "@thi.ng/webgl"; import type { MSDFFont, TextAlign, TextOpts } from "./api"; diff --git a/packages/webgl-shadertoy/src/shadertoy.ts b/packages/webgl-shadertoy/src/shadertoy.ts index 2e0f2b0d84..ceee740abe 100644 --- a/packages/webgl-shadertoy/src/shadertoy.ts +++ b/packages/webgl-shadertoy/src/shadertoy.ts @@ -1,12 +1,10 @@ -import { - assign, - defMain, - defn, - FLOAT0, - FLOAT1, - vec4, -} from "@thi.ng/shader-ast"; -import { compileModel, defQuadModel, defShader, draw } from "@thi.ng/webgl"; +import { assign } from "@thi.ng/shader-ast/ast/assign"; +import { defMain, defn } from "@thi.ng/shader-ast/ast/function"; +import { FLOAT0, FLOAT1, vec4 } from "@thi.ng/shader-ast/ast/lit"; +import { compileModel } from "@thi.ng/webgl/buffer"; +import { draw } from "@thi.ng/webgl/draw"; +import { defQuadModel } from "@thi.ng/webgl/geo/quad"; +import { defShader } from "@thi.ng/webgl/shader"; import type { MainImageFn, ShaderToy, diff --git a/packages/webgl/src/api/logger.ts b/packages/webgl/src/api/logger.ts index 76c7927ec3..92c522c956 100644 --- a/packages/webgl/src/api/logger.ts +++ b/packages/webgl/src/api/logger.ts @@ -1,4 +1,5 @@ -import { ILogger, NULL_LOGGER } from "@thi.ng/api"; +import type { ILogger } from "@thi.ng/api"; +import { NULL_LOGGER } from "@thi.ng/api/logger"; export let LOGGER: ILogger = NULL_LOGGER; diff --git a/packages/webgl/src/buffer.ts b/packages/webgl/src/buffer.ts index d912f9b064..40166e2e28 100644 --- a/packages/webgl/src/buffer.ts +++ b/packages/webgl/src/buffer.ts @@ -1,4 +1,4 @@ -import { asGLType, TypedArray } from "@thi.ng/api"; +import { asGLType, TypedArray } from "@thi.ng/api/api/typedarray"; import type { AttribPool } from "@thi.ng/vector-pools"; import type { IndexBufferSpec, IWebGLBuffer } from "./api/buffers"; import { diff --git a/packages/webgl/src/canvas.ts b/packages/webgl/src/canvas.ts index 92e7772bb1..ba4e520553 100644 --- a/packages/webgl/src/canvas.ts +++ b/packages/webgl/src/canvas.ts @@ -1,5 +1,5 @@ import { adaptDPI } from "@thi.ng/adapt-dpi"; -import { isString } from "@thi.ng/checks"; +import { isString } from "@thi.ng/checks/is-string"; import type { WeblGLCanvasOpts } from "./api/canvas"; import type { WebGLExtensionMap } from "./api/ext"; import { error } from "./error"; diff --git a/packages/webgl/src/draw.ts b/packages/webgl/src/draw.ts index 083558d022..71f3d5939a 100644 --- a/packages/webgl/src/draw.ts +++ b/packages/webgl/src/draw.ts @@ -1,4 +1,4 @@ -import { isArray } from "@thi.ng/checks"; +import { isArray } from "@thi.ng/checks/is-array"; import type { ModelSpec } from "./api/model"; import { isGL2Context } from "./checks"; import { error } from "./error"; diff --git a/packages/webgl/src/fbo.ts b/packages/webgl/src/fbo.ts index 238d07a456..47d49d5d9e 100644 --- a/packages/webgl/src/fbo.ts +++ b/packages/webgl/src/fbo.ts @@ -1,4 +1,4 @@ -import { assert } from "@thi.ng/api"; +import { assert } from "@thi.ng/api/assert"; import type { FboOpts, IFbo } from "./api/buffers"; import { ITexture, TEX_FORMATS } from "./api/texture"; import { isGL2Context } from "./checks"; diff --git a/packages/webgl/src/matrices.ts b/packages/webgl/src/matrices.ts index 3f743b4321..3ca6a8376a 100644 --- a/packages/webgl/src/matrices.ts +++ b/packages/webgl/src/matrices.ts @@ -1,6 +1,9 @@ import type { IObjectOf } from "@thi.ng/api"; -import { isNumber } from "@thi.ng/checks"; -import { IDENT44, mulM44, normal44, ortho } from "@thi.ng/matrices"; +import { isNumber } from "@thi.ng/checks/is-number"; +import { IDENT44 } from "@thi.ng/matrices/constants"; +import { mulM44 } from "@thi.ng/matrices/mulm"; +import { normal44 } from "@thi.ng/matrices/normal-mat"; +import { ortho } from "@thi.ng/matrices/ortho"; import type { ReadonlyVec } from "@thi.ng/vectors"; import type { GLMat4 } from "./api/glsl"; import type { ShaderUniforms } from "./api/shader"; @@ -13,10 +16,10 @@ const $ = (a: any, b: any, id: string) => a[id] || b[id].defaultVal || IDENT44; * * @param model - */ -export const autoNormalMatrix1 = (model = "model") => ( - shaderU: ShaderUniforms, - specU: IObjectOf -) => normal44([], $(specU, shaderU, model)); +export const autoNormalMatrix1 = + (model = "model") => + (shaderU: ShaderUniforms, specU: IObjectOf) => + normal44([], $(specU, shaderU, model)); /** * Computes the inverse transpose of the matrix product of given 4x4 @@ -25,16 +28,15 @@ export const autoNormalMatrix1 = (model = "model") => ( * @param model - * @param view - */ -export const autoNormalMatrix2 = (model = "model", view = "view") => ( - shaderU: ShaderUniforms, - specU: IObjectOf -) => - ( - normal44( - null, - mulM44([], $(specU, shaderU, view), $(specU, shaderU, model)) - ) - ); +export const autoNormalMatrix2 = + (model = "model", view = "view") => + (shaderU: ShaderUniforms, specU: IObjectOf) => + ( + normal44( + null, + mulM44([], $(specU, shaderU, view), $(specU, shaderU, model)) + ) + ); /** * Constructs a orthographic projection matrix for using 2D screen diff --git a/packages/webgl/src/multipass.ts b/packages/webgl/src/multipass.ts index ba9183843d..f829cabc31 100644 --- a/packages/webgl/src/multipass.ts +++ b/packages/webgl/src/multipass.ts @@ -1,4 +1,5 @@ -import { assert, IObjectOf } from "@thi.ng/api"; +import type { IObjectOf } from "@thi.ng/api"; +import { assert } from "@thi.ng/api/assert"; import { $xy, assign, @@ -7,7 +8,11 @@ import { ivec2, texelFetch, } from "@thi.ng/shader-ast"; -import { assocObj, map, range, some, transduce } from "@thi.ng/transducers"; +import { range } from "@thi.ng/transducers/iter/range"; +import { assocObj } from "@thi.ng/transducers/rfn/assoc-obj"; +import { some } from "@thi.ng/transducers/rfn/some"; +import { transduce } from "@thi.ng/transducers/transduce"; +import { map } from "@thi.ng/transducers/xform/map"; import type { ExtensionBehaviors } from "./api/ext"; import type { Multipass, MultipassOpts, PassOpts } from "./api/multipass"; import type { diff --git a/packages/webgl/src/shader.ts b/packages/webgl/src/shader.ts index 021522a737..9eae3384ef 100644 --- a/packages/webgl/src/shader.ts +++ b/packages/webgl/src/shader.ts @@ -1,12 +1,12 @@ -import { asGLType, deref, Fn3, IObjectOf } from "@thi.ng/api"; -import { - existsAndNotNull, - isArray, - isBoolean, - isFunction, -} from "@thi.ng/checks"; -import { unsupported } from "@thi.ng/errors"; -import { doOnce } from "@thi.ng/memoize"; +import type { Fn3, IObjectOf } from "@thi.ng/api"; +import { deref } from "@thi.ng/api/api/deref"; +import { asGLType } from "@thi.ng/api/api/typedarray"; +import { existsAndNotNull } from "@thi.ng/checks/exists-not-null"; +import { isArray } from "@thi.ng/checks/is-array"; +import { isBoolean } from "@thi.ng/checks/is-boolean"; +import { isFunction } from "@thi.ng/checks/is-function"; +import { unsupported } from "@thi.ng/errors/unsupported"; +import { doOnce } from "@thi.ng/memoize/do-once"; import { input, output, @@ -17,8 +17,9 @@ import { Type, uniform, } from "@thi.ng/shader-ast"; -import { GLSLVersion, targetGLSL } from "@thi.ng/shader-ast-glsl"; -import { vals } from "@thi.ng/transducers"; +import { GLSLVersion } from "@thi.ng/shader-ast-glsl/api"; +import { targetGLSL } from "@thi.ng/shader-ast-glsl/target"; +import { vals } from "@thi.ng/transducers/iter/vals"; import { ExtensionBehavior, ExtensionBehaviors, diff --git a/packages/webgl/src/shaders/lambert.ts b/packages/webgl/src/shaders/lambert.ts index 716a22c0f7..920f9f6cbb 100644 --- a/packages/webgl/src/shaders/lambert.ts +++ b/packages/webgl/src/shaders/lambert.ts @@ -11,9 +11,9 @@ import { diffuseLighting, halfLambert, lambert, - surfaceNormal, - transformMVP, -} from "@thi.ng/shader-ast-stdlib"; +} from "@thi.ng/shader-ast-stdlib/light/lambert"; +import { transformMVP } from "@thi.ng/shader-ast-stdlib/matrix/mvp"; +import { surfaceNormal } from "@thi.ng/shader-ast-stdlib/matrix/normal"; import type { Material } from "../api/material"; import type { ShaderOpts, ShaderSpec } from "../api/shader"; import { defMaterial } from "../material"; diff --git a/packages/webgl/src/shaders/phong.ts b/packages/webgl/src/shaders/phong.ts index 64683288fe..c6fbcfa1cb 100644 --- a/packages/webgl/src/shaders/phong.ts +++ b/packages/webgl/src/shaders/phong.ts @@ -16,7 +16,8 @@ import { ternary, vec4, } from "@thi.ng/shader-ast"; -import { diffuseLighting, surfaceNormal } from "@thi.ng/shader-ast-stdlib"; +import { diffuseLighting } from "@thi.ng/shader-ast-stdlib/light/lambert"; +import { surfaceNormal } from "@thi.ng/shader-ast-stdlib/matrix/normal"; import type { Material } from "../api/material"; import type { ShaderOpts, ShaderSpec } from "../api/shader"; import { defMaterial } from "../material"; diff --git a/packages/webgl/src/syntax.ts b/packages/webgl/src/syntax.ts index 5423694b45..554f9665b9 100644 --- a/packages/webgl/src/syntax.ts +++ b/packages/webgl/src/syntax.ts @@ -1,5 +1,5 @@ -import { isArray } from "@thi.ng/checks"; -import { GLSLVersion } from "@thi.ng/shader-ast-glsl"; +import { isArray } from "@thi.ng/checks/is-array"; +import { GLSLVersion } from "@thi.ng/shader-ast-glsl/api"; import type { GLSL } from "./api/glsl"; import type { GLSLDeclPrefixes, GLSLSyntax } from "./api/shader"; diff --git a/packages/webgl/src/texture.ts b/packages/webgl/src/texture.ts index 2146182d5d..90adeee96c 100644 --- a/packages/webgl/src/texture.ts +++ b/packages/webgl/src/texture.ts @@ -1,5 +1,5 @@ -import { withoutKeysObj } from "@thi.ng/associative"; -import { isArray } from "@thi.ng/checks"; +import { withoutKeysObj } from "@thi.ng/associative/without-keys"; +import { isArray } from "@thi.ng/checks/is-array"; import { ITexture, TextureFilter, diff --git a/packages/webgl/src/textures/checkerboard.ts b/packages/webgl/src/textures/checkerboard.ts index 76a0749302..6d7a6abb5a 100644 --- a/packages/webgl/src/textures/checkerboard.ts +++ b/packages/webgl/src/textures/checkerboard.ts @@ -1,4 +1,5 @@ -import { ARGB8888, canvasPixels } from "@thi.ng/pixel"; +import { canvasPixels } from "@thi.ng/pixel/canvas"; +import { ARGB8888 } from "@thi.ng/pixel/format/argb8888"; export interface CheckerboardOpts { size: number; diff --git a/packages/webgl/src/textures/stripes.ts b/packages/webgl/src/textures/stripes.ts index a28dd32874..5b23f394ac 100644 --- a/packages/webgl/src/textures/stripes.ts +++ b/packages/webgl/src/textures/stripes.ts @@ -1,4 +1,5 @@ -import { ARGB8888, canvasPixels } from "@thi.ng/pixel"; +import { canvasPixels } from "@thi.ng/pixel/canvas"; +import { ARGB8888 } from "@thi.ng/pixel/format/argb8888"; export interface StripeOpts { size: number; diff --git a/packages/webgl/src/uniforms.ts b/packages/webgl/src/uniforms.ts index 348feea39c..c514d8e7bb 100644 --- a/packages/webgl/src/uniforms.ts +++ b/packages/webgl/src/uniforms.ts @@ -1,7 +1,7 @@ import type { Fn, Fn3, IObjectOf } from "@thi.ng/api"; import { equivArrayLike } from "@thi.ng/equiv"; -import { IDENT22, IDENT33, IDENT44 } from "@thi.ng/matrices"; -import { ReadonlyVec, ZERO2, ZERO3, ZERO4 } from "@thi.ng/vectors"; +import { IDENT22, IDENT33, IDENT44 } from "@thi.ng/matrices/constants"; +import { ReadonlyVec, ZERO2, ZERO3, ZERO4 } from "@thi.ng/vectors/api"; import type { GLVec } from "./api/glsl"; import type { UniformValue } from "./api/shader"; @@ -23,59 +23,63 @@ type SetterV = type SetterM = "2fv" | "3fv" | "4fv"; -const uniformS = (fn: SetterS) => ( - gl: WebGLRenderingContext, - loc: WebGLUniformLocation, - defaultVal = 0 -) => { - let prev: number; - return (x?: number) => { - x = x === undefined ? defaultVal : x; - if (x !== prev) { - (gl)["uniform1" + fn](loc, x); - prev = x; - } +const uniformS = + (fn: SetterS) => + (gl: WebGLRenderingContext, loc: WebGLUniformLocation, defaultVal = 0) => { + let prev: number; + return (x?: number) => { + x = x === undefined ? defaultVal : x; + if (x !== prev) { + (gl)["uniform1" + fn](loc, x); + prev = x; + } + }; }; -}; -const uniformV = (fn: SetterV, sysDefault: ReadonlyVec) => ( - gl: WebGLRenderingContext, - loc: WebGLUniformLocation, - defaultVal = sysDefault -) => { - let prev: GLVec = []; - return (x?: ReadonlyVec) => { - x = x === undefined ? defaultVal : x; - if (!equivArrayLike(prev, x)) { - (gl)["uniform" + fn](loc, x); - prev = [...x]; - } +const uniformV = + (fn: SetterV, sysDefault: ReadonlyVec) => + ( + gl: WebGLRenderingContext, + loc: WebGLUniformLocation, + defaultVal = sysDefault + ) => { + let prev: GLVec = []; + return (x?: ReadonlyVec) => { + x = x === undefined ? defaultVal : x; + if (!equivArrayLike(prev, x)) { + (gl)["uniform" + fn](loc, x); + prev = [...x]; + } + }; }; -}; -const uniformM = (fn: SetterM, sysDefault?: ReadonlyVec) => ( - gl: WebGLRenderingContext, - loc: WebGLUniformLocation, - defaultVal = sysDefault -) => { - let prev: GLVec = []; - return (x?: any) => { - x = x === undefined ? defaultVal : x; - if (!equivArrayLike(prev, x)) { - (gl)["uniformMatrix" + fn](loc, false, x); - prev = [...x]; - } +const uniformM = + (fn: SetterM, sysDefault?: ReadonlyVec) => + ( + gl: WebGLRenderingContext, + loc: WebGLUniformLocation, + defaultVal = sysDefault + ) => { + let prev: GLVec = []; + return (x?: any) => { + x = x === undefined ? defaultVal : x; + if (!equivArrayLike(prev, x)) { + (gl)["uniformMatrix" + fn](loc, false, x); + prev = [...x]; + } + }; }; -}; const Z1 = [0]; -export const UNIFORM_SETTERS: IObjectOf ->> = { +export const UNIFORM_SETTERS: IObjectOf< + Fn3< + WebGLRenderingContext, + WebGLUniformLocation, + number | ReadonlyVec | undefined, + Fn + > +> = { bool: uniformS("i"), float: uniformS("f"), int: uniformS("i"), diff --git a/packages/zipper/src/zipper.ts b/packages/zipper/src/zipper.ts index 6448a6a7a5..5a663ec34b 100644 --- a/packages/zipper/src/zipper.ts +++ b/packages/zipper/src/zipper.ts @@ -1,6 +1,7 @@ -import { assert, FnO } from "@thi.ng/api"; -import { peek } from "@thi.ng/arrays"; -import { isArray } from "@thi.ng/checks"; +import type { FnO } from "@thi.ng/api"; +import { assert } from "@thi.ng/api/assert"; +import { peek } from "@thi.ng/arrays/peek"; +import { isArray } from "@thi.ng/checks/is-array"; import type { Path, ZipperOps } from "./api"; const newPath = (