@synnaxlabs/x 0.16.1 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +99 -7
- package/.vscode/settings.json +5 -1
- package/dist/base-B48bPNx5.cjs +1 -0
- package/dist/base-DnZzEvvz.js +38 -0
- package/dist/binary.cjs +3 -0
- package/dist/binary.js +100 -0
- package/dist/bounds-Bh_QBZZK.cjs +1 -0
- package/dist/bounds-Dmn-hd_-.js +129 -0
- package/dist/bounds.cjs +1 -0
- package/dist/bounds.js +4 -0
- package/dist/box-C92jYSNY.js +205 -0
- package/dist/box-m3dlc1kR.cjs +1 -0
- package/dist/box.cjs +1 -0
- package/dist/box.js +4 -0
- package/dist/caseconv.cjs +1 -0
- package/dist/caseconv.js +4 -0
- package/dist/change-C-YELKx6.cjs +1 -0
- package/dist/change-DLl6DccR.js +12 -0
- package/dist/change.cjs +1 -0
- package/dist/change.js +4 -0
- package/dist/compare.cjs +1 -0
- package/dist/compare.js +4 -0
- package/dist/debounce.cjs +1 -0
- package/dist/debounce.js +17 -0
- package/dist/deep.cjs +1 -0
- package/dist/deep.js +121 -0
- package/dist/destructor.cjs +1 -0
- package/dist/destructor.js +1 -0
- package/dist/dimensions-BAuHfd-b.js +44 -0
- package/dist/dimensions-zMcb9pMk.cjs +1 -0
- package/dist/dimensions.cjs +1 -0
- package/dist/dimensions.js +4 -0
- package/dist/direction-CScbfCdT.js +16 -0
- package/dist/direction-DZbN47uL.cjs +1 -0
- package/dist/direction.cjs +1 -0
- package/dist/direction.js +4 -0
- package/dist/external-B-DoBvh7.cjs +1 -0
- package/dist/external-DI9122wF.js +27 -0
- package/dist/identity.cjs +1 -0
- package/dist/identity.js +4 -0
- package/dist/index-BpCPHf78.cjs +1 -0
- package/dist/index-Bt5ivtN9.js +95 -0
- package/dist/index-BwkQTA-j.js +360 -0
- package/dist/index-CuG8fceO.cjs +1 -0
- package/dist/index.cjs +3 -0
- package/dist/index.js +178 -0
- package/dist/kv.cjs +1 -0
- package/dist/kv.js +6 -0
- package/dist/location-CfP9TAnW.js +94 -0
- package/dist/location-c3g6WKs-.cjs +1 -0
- package/dist/location.cjs +1 -0
- package/dist/location.js +4 -0
- package/dist/observe.cjs +1 -0
- package/dist/observe.js +43 -0
- package/dist/path-BO4pyGZf.cjs +1 -0
- package/dist/path-nTHmt_4i.js +65 -0
- package/dist/position-BBnkwGX1.cjs +1 -0
- package/dist/position-B_aphAR0.js +87 -0
- package/dist/position.cjs +1 -0
- package/dist/position.js +4 -0
- package/dist/record.cjs +1 -0
- package/dist/record.js +9 -0
- package/dist/runtime.cjs +1 -0
- package/dist/runtime.js +4 -0
- package/dist/scale-C8axypQ2.cjs +1 -0
- package/dist/scale-CgtgqlYU.js +205 -0
- package/dist/scale.cjs +1 -0
- package/dist/scale.js +4 -0
- package/dist/search.cjs +1 -0
- package/dist/search.js +15 -0
- package/dist/series-8E6FnWBU.cjs +11 -0
- package/dist/series-DCJSrg1P.js +1629 -0
- package/dist/spatial-BOhaO8xN.cjs +1 -0
- package/dist/spatial-DozyssiN.js +11 -0
- package/dist/spatial.cjs +1 -0
- package/dist/spatial.js +20 -0
- package/dist/{binary → src/binary}/encoder.d.ts +26 -2
- package/dist/src/binary/encoder.d.ts.map +1 -0
- package/dist/src/binary/encoder.spec.d.ts.map +1 -0
- package/dist/src/binary/index.d.ts.map +1 -0
- package/dist/src/caseconv/caseconv.d.ts +6 -0
- package/dist/src/caseconv/caseconv.d.ts.map +1 -0
- package/dist/src/caseconv/index.d.ts +2 -0
- package/dist/src/caseconv/index.d.ts.map +1 -0
- package/dist/{change → src/change}/change.d.ts +10 -9
- package/dist/src/change/change.d.ts.map +1 -0
- package/dist/src/change/index.d.ts.map +1 -0
- package/dist/src/clamp/clamp.d.ts.map +1 -0
- package/dist/src/clamp/index.d.ts +2 -0
- package/dist/src/clamp/index.d.ts.map +1 -0
- package/dist/{compare → src/compare}/compare.d.ts +6 -4
- package/dist/src/compare/compare.d.ts.map +1 -0
- package/dist/src/compare/compare.spec.d.ts +2 -0
- package/dist/src/compare/compare.spec.d.ts.map +1 -0
- package/dist/src/compare/index.d.ts.map +1 -0
- package/dist/src/control/control.d.ts +107 -0
- package/dist/src/control/control.d.ts.map +1 -0
- package/dist/src/control/index.d.ts +2 -0
- package/dist/src/control/index.d.ts.map +1 -0
- package/dist/src/debounce/debounce.d.ts.map +1 -0
- package/dist/src/debounce/debounce.spec.d.ts +2 -0
- package/dist/src/debounce/debounce.spec.d.ts.map +1 -0
- package/dist/src/debounce/index.d.ts +2 -0
- package/dist/src/debounce/index.d.ts.map +1 -0
- package/dist/src/deep/copy.d.ts.map +1 -0
- package/dist/{deep → src/deep}/delete.d.ts +2 -1
- package/dist/src/deep/delete.d.ts.map +1 -0
- package/dist/{deep → src/deep}/delete.spec.d.ts.map +1 -1
- package/dist/src/deep/difference.d.ts.map +1 -0
- package/dist/src/deep/difference.spec.d.ts.map +1 -0
- package/dist/src/deep/equal.d.ts.map +1 -0
- package/dist/{deep → src/deep}/equal.spec.d.ts.map +1 -1
- package/dist/{deep → src/deep}/external.d.ts +3 -4
- package/dist/src/deep/external.d.ts.map +1 -0
- package/dist/src/deep/index.d.ts.map +1 -0
- package/dist/src/deep/merge.d.ts +12 -0
- package/dist/src/deep/merge.d.ts.map +1 -0
- package/dist/{deep → src/deep}/merge.spec.d.ts.map +1 -1
- package/dist/src/deep/partial.d.ts.map +1 -0
- package/dist/src/deep/path.d.ts +54 -0
- package/dist/src/deep/path.d.ts.map +1 -0
- package/dist/{deep → src/deep}/path.spec.d.ts.map +1 -1
- package/dist/src/destructor.d.ts.map +1 -0
- package/dist/{identity.d.ts → src/identity.d.ts} +2 -1
- package/dist/src/identity.d.ts.map +1 -0
- package/dist/{index.d.ts → src/index.d.ts} +22 -20
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/invert.d.ts.map +1 -0
- package/dist/src/join.d.ts.map +1 -0
- package/dist/src/kv/index.d.ts.map +1 -0
- package/dist/src/kv/types.d.ts.map +1 -0
- package/dist/src/math/index.d.ts +2 -0
- package/dist/src/math/index.d.ts.map +1 -0
- package/dist/src/math/math.d.ts +11 -0
- package/dist/src/math/math.d.ts.map +1 -0
- package/dist/src/migrate/index.d.ts.map +1 -0
- package/dist/src/migrate/migrate.d.ts +29 -0
- package/dist/src/migrate/migrate.d.ts.map +1 -0
- package/dist/src/migrate/migrate.spec.d.ts.map +1 -0
- package/dist/{mock → src/mock}/MockGLBufferController.d.ts +2 -1
- package/dist/src/mock/MockGLBufferController.d.ts.map +1 -0
- package/dist/src/mock/index.d.ts.map +1 -0
- package/dist/src/observe/index.d.ts.map +1 -0
- package/dist/src/observe/observe.d.ts +24 -0
- package/dist/src/observe/observe.d.ts.map +1 -0
- package/dist/src/observe/obsever.spec.d.ts +2 -0
- package/dist/src/observe/obsever.spec.d.ts.map +1 -0
- package/dist/src/optional.d.ts.map +1 -0
- package/dist/{primitive.d.ts → src/primitive.d.ts} +2 -1
- package/dist/src/primitive.d.ts.map +1 -0
- package/dist/{record.d.ts → src/record.d.ts} +7 -8
- package/dist/src/record.d.ts.map +1 -0
- package/dist/{renderable.d.ts → src/renderable.d.ts} +2 -1
- package/dist/src/renderable.d.ts.map +1 -0
- package/dist/src/runtime/detect.d.ts.map +1 -0
- package/dist/src/runtime/external.d.ts.map +1 -0
- package/dist/src/runtime/index.d.ts.map +1 -0
- package/dist/src/runtime/os.d.ts +20 -0
- package/dist/src/runtime/os.d.ts.map +1 -0
- package/dist/{search.d.ts → src/search.d.ts} +5 -2
- package/dist/src/search.d.ts.map +1 -0
- package/dist/src/shallowCopy.d.ts +2 -0
- package/dist/src/shallowCopy.d.ts.map +1 -0
- package/dist/{spatial → src/spatial}/base.d.ts +30 -5
- package/dist/src/spatial/base.d.ts.map +1 -0
- package/dist/src/spatial/bounds/bounds.d.ts +148 -0
- package/dist/src/spatial/bounds/bounds.d.ts.map +1 -0
- package/dist/src/spatial/bounds/bounds.spec.d.ts.map +1 -0
- package/dist/src/spatial/bounds/index.d.ts.map +1 -0
- package/dist/{spatial → src/spatial}/box/box.d.ts +73 -24
- package/dist/src/spatial/box/box.d.ts.map +1 -0
- package/dist/src/spatial/box/box.spec.d.ts.map +1 -0
- package/dist/src/spatial/box/index.d.ts.map +1 -0
- package/dist/{spatial → src/spatial}/dimensions/dimensions.d.ts +4 -3
- package/dist/src/spatial/dimensions/dimensions.d.ts.map +1 -0
- package/dist/src/spatial/dimensions/dimensions.spec.d.ts.map +1 -0
- package/dist/src/spatial/dimensions/index.d.ts.map +1 -0
- package/dist/{spatial → src/spatial}/direction/direction.d.ts +4 -3
- package/dist/src/spatial/direction/direction.d.ts.map +1 -0
- package/dist/src/spatial/direction/direction.spec.d.ts.map +1 -0
- package/dist/src/spatial/direction/index.d.ts.map +1 -0
- package/dist/{spatial → src/spatial}/external.d.ts +2 -2
- package/dist/src/spatial/external.d.ts.map +1 -0
- package/dist/src/spatial/index.d.ts.map +1 -0
- package/dist/src/spatial/location/index.d.ts.map +1 -0
- package/dist/{spatial → src/spatial}/location/location.d.ts +4 -3
- package/dist/src/spatial/location/location.d.ts.map +1 -0
- package/dist/src/spatial/location/location.spec.d.ts.map +1 -0
- package/dist/src/spatial/position/index.d.ts.map +1 -0
- package/dist/{spatial → src/spatial}/position/position.d.ts +4 -4
- package/dist/src/spatial/position/position.d.ts.map +1 -0
- package/dist/src/spatial/position/position.spec.d.ts.map +1 -0
- package/dist/src/spatial/scale/index.d.ts.map +1 -0
- package/dist/{spatial → src/spatial}/scale/scale.d.ts +15 -62
- package/dist/src/spatial/scale/scale.d.ts.map +1 -0
- package/dist/src/spatial/scale/scale.spec.d.ts.map +1 -0
- package/dist/src/spatial/spatial.d.ts +2 -0
- package/dist/src/spatial/spatial.d.ts.map +1 -0
- package/dist/src/spatial/xy/index.d.ts.map +1 -0
- package/dist/{spatial → src/spatial}/xy/xy.d.ts +16 -25
- package/dist/src/spatial/xy/xy.d.ts.map +1 -0
- package/dist/{spatial → src/spatial}/xy/xy.spec.d.ts.map +1 -1
- package/dist/src/telem/generate.d.ts +4 -0
- package/dist/src/telem/generate.d.ts.map +1 -0
- package/dist/src/telem/gl.d.ts.map +1 -0
- package/dist/{telem → src/telem}/index.d.ts +1 -1
- package/dist/src/telem/index.d.ts.map +1 -0
- package/dist/{telem → src/telem}/series.d.ts +10 -8
- package/dist/src/telem/series.d.ts.map +1 -0
- package/dist/{telem → src/telem}/series.spec.d.ts.map +1 -1
- package/dist/{telem → src/telem}/telem.d.ts +19 -21
- package/dist/src/telem/telem.d.ts.map +1 -0
- package/dist/{telem → src/telem}/telem.spec.d.ts.map +1 -1
- package/dist/src/toArray.d.ts.map +1 -0
- package/dist/src/transform.d.ts +6 -0
- package/dist/src/transform.d.ts.map +1 -0
- package/dist/src/unique.d.ts.map +1 -0
- package/dist/src/url/index.d.ts +2 -0
- package/dist/src/url/index.d.ts.map +1 -0
- package/dist/src/url/url.d.ts.map +1 -0
- package/dist/{url → src/url}/url.spec.d.ts.map +1 -1
- package/dist/src/worker/index.d.ts +2 -0
- package/dist/src/worker/index.d.ts.map +1 -0
- package/dist/{worker → src/worker}/worker.d.ts +4 -4
- package/dist/src/worker/worker.d.ts.map +1 -0
- package/dist/src/worker/worker.spec.d.ts.map +1 -0
- package/dist/src/zodutil/index.d.ts +2 -0
- package/dist/src/zodutil/index.d.ts.map +1 -0
- package/dist/src/zodutil/zodutil.d.ts +6 -0
- package/dist/src/zodutil/zodutil.d.ts.map +1 -0
- package/dist/src/zodutil/zodutil.spec.d.ts +2 -0
- package/dist/src/zodutil/zodutil.spec.d.ts.map +1 -0
- package/dist/telem.cjs +1 -0
- package/dist/telem.js +17 -0
- package/dist/toArray.cjs +1 -0
- package/dist/toArray.js +5 -0
- package/dist/unique.cjs +1 -0
- package/dist/unique.js +4 -0
- package/dist/url.cjs +1 -0
- package/dist/url.js +54 -0
- package/dist/worker.cjs +1 -0
- package/dist/worker.js +47 -0
- package/dist/xy-D1ZbIqpT.js +90 -0
- package/dist/xy-cP-FXJtR.cjs +1 -0
- package/dist/xy.cjs +1 -0
- package/dist/xy.js +4 -0
- package/dist/zodutil.cjs +1 -0
- package/dist/zodutil.js +21 -0
- package/eslint.config.js +12 -0
- package/package.json +157 -13
- package/src/binary/encoder.spec.ts +150 -7
- package/src/binary/encoder.ts +110 -9
- package/src/binary/index.ts +1 -1
- package/src/caseconv/caseconv.ts +31 -0
- package/src/caseconv/index.ts +10 -0
- package/src/change/change.ts +7 -6
- package/src/change/index.ts +1 -1
- package/src/{clamp.ts → clamp/clamp.ts} +1 -1
- package/src/clamp/index.ts +10 -0
- package/src/compare/compare.spec.ts +49 -0
- package/src/compare/compare.ts +37 -10
- package/src/compare/index.ts +1 -1
- package/src/control/control.ts +77 -0
- package/src/control/index.ts +1 -0
- package/src/debounce/debounce.spec.ts +52 -0
- package/src/{debounce.ts → debounce/debounce.ts} +4 -4
- package/src/debounce/index.ts +10 -0
- package/src/deep/copy.ts +2 -3
- package/src/deep/delete.spec.ts +2 -2
- package/src/deep/delete.ts +3 -2
- package/src/deep/difference.spec.ts +28 -27
- package/src/deep/difference.ts +13 -11
- package/src/deep/equal.spec.ts +4 -4
- package/src/deep/equal.ts +5 -5
- package/src/deep/external.ts +4 -5
- package/src/deep/index.ts +1 -1
- package/src/deep/merge.spec.ts +120 -4
- package/src/deep/merge.ts +50 -6
- package/src/deep/partial.ts +1 -1
- package/src/deep/path.spec.ts +91 -39
- package/src/deep/path.ts +111 -46
- package/src/destructor.ts +2 -2
- package/src/identity.ts +1 -1
- package/src/index.ts +23 -21
- package/src/invert.ts +9 -0
- package/src/join.ts +1 -1
- package/src/kv/index.ts +1 -1
- package/src/kv/types.ts +1 -1
- package/src/math/index.ts +10 -0
- package/src/math/math.ts +33 -0
- package/src/migrate/index.ts +9 -0
- package/src/migrate/migrate.spec.ts +65 -54
- package/src/migrate/migrate.ts +126 -17
- package/src/mock/MockGLBufferController.ts +6 -6
- package/src/mock/index.ts +1 -1
- package/src/observe/index.ts +1 -1
- package/src/observe/observe.ts +37 -6
- package/src/observe/obsever.spec.ts +56 -0
- package/src/optional.ts +3 -4
- package/src/primitive.ts +1 -1
- package/src/record.ts +10 -6
- package/src/renderable.ts +1 -1
- package/src/runtime/detect.ts +3 -3
- package/src/runtime/external.ts +1 -1
- package/src/runtime/index.ts +1 -1
- package/src/runtime/os.ts +17 -5
- package/src/search.ts +3 -1
- package/src/shallowCopy.ts +5 -6
- package/src/spatial/base.ts +13 -5
- package/src/spatial/bounds/bounds.spec.ts +259 -180
- package/src/spatial/bounds/bounds.ts +200 -85
- package/src/spatial/bounds/index.ts +2 -2
- package/src/spatial/box/box.spec.ts +211 -2
- package/src/spatial/box/box.ts +97 -49
- package/src/spatial/box/index.ts +2 -2
- package/src/spatial/dimensions/dimensions.spec.ts +1 -1
- package/src/spatial/dimensions/dimensions.ts +4 -4
- package/src/spatial/dimensions/index.ts +2 -2
- package/src/spatial/direction/direction.spec.ts +1 -1
- package/src/spatial/direction/direction.ts +7 -7
- package/src/spatial/direction/index.ts +2 -2
- package/src/spatial/external.ts +3 -3
- package/src/spatial/index.ts +1 -1
- package/src/spatial/location/index.ts +2 -2
- package/src/spatial/location/location.spec.ts +1 -1
- package/src/spatial/location/location.ts +21 -21
- package/src/spatial/position/index.ts +1 -1
- package/src/spatial/position/position.spec.ts +1 -1
- package/src/spatial/position/position.ts +3 -20
- package/src/spatial/scale/index.ts +2 -2
- package/src/spatial/scale/scale.spec.ts +3 -3
- package/src/spatial/scale/scale.ts +3 -3
- package/src/spatial/spatial.ts +5 -5
- package/src/spatial/xy/index.ts +2 -2
- package/src/spatial/xy/xy.spec.ts +93 -44
- package/src/spatial/xy/xy.ts +20 -27
- package/src/telem/generate.ts +1 -1
- package/src/telem/gl.ts +1 -1
- package/src/telem/index.ts +2 -2
- package/src/telem/series.spec.ts +64 -5
- package/src/telem/series.ts +47 -35
- package/src/telem/telem.spec.ts +130 -2
- package/src/telem/telem.ts +63 -23
- package/src/toArray.ts +2 -2
- package/src/transform.ts +9 -2
- package/src/unique.ts +1 -1
- package/src/url/index.ts +2 -2
- package/src/url/url.spec.ts +2 -2
- package/src/url/url.ts +4 -4
- package/src/worker/index.ts +10 -0
- package/src/worker/worker.spec.ts +2 -2
- package/src/worker/worker.ts +13 -13
- package/src/zodutil/index.ts +10 -0
- package/src/zodutil/zodutil.spec.ts +103 -0
- package/src/zodutil/zodutil.ts +44 -0
- package/tsconfig.json +1 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/vite.config.ts +39 -3
- package/.eslintrc.cjs +0 -18
- package/dist/binary/encoder.d.ts.map +0 -1
- package/dist/binary/encoder.spec.d.ts.map +0 -1
- package/dist/binary/index.d.ts.map +0 -1
- package/dist/case.d.ts +0 -6
- package/dist/case.d.ts.map +0 -1
- package/dist/change/change.d.ts.map +0 -1
- package/dist/change/index.d.ts.map +0 -1
- package/dist/clamp.d.ts.map +0 -1
- package/dist/compare/compare.d.ts.map +0 -1
- package/dist/compare/index.d.ts.map +0 -1
- package/dist/debounce.d.ts.map +0 -1
- package/dist/deep/copy.d.ts.map +0 -1
- package/dist/deep/delete.d.ts.map +0 -1
- package/dist/deep/difference.d.ts.map +0 -1
- package/dist/deep/difference.spec.d.ts.map +0 -1
- package/dist/deep/equal.d.ts.map +0 -1
- package/dist/deep/external.d.ts.map +0 -1
- package/dist/deep/index.d.ts.map +0 -1
- package/dist/deep/memo.d.ts +0 -2
- package/dist/deep/memo.d.ts.map +0 -1
- package/dist/deep/merge.d.ts +0 -3
- package/dist/deep/merge.d.ts.map +0 -1
- package/dist/deep/partial.d.ts.map +0 -1
- package/dist/deep/path.d.ts +0 -37
- package/dist/deep/path.d.ts.map +0 -1
- package/dist/destructor.d.ts.map +0 -1
- package/dist/identity.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/invert.d.ts.map +0 -1
- package/dist/join.d.ts.map +0 -1
- package/dist/kv/index.d.ts.map +0 -1
- package/dist/kv/types.d.ts.map +0 -1
- package/dist/migrate/index.d.ts.map +0 -1
- package/dist/migrate/migrate.d.ts +0 -16
- package/dist/migrate/migrate.d.ts.map +0 -1
- package/dist/migrate/migrate.spec.d.ts.map +0 -1
- package/dist/mock/MockGLBufferController.d.ts.map +0 -1
- package/dist/mock/index.d.ts.map +0 -1
- package/dist/observe/index.d.ts.map +0 -1
- package/dist/observe/observe.d.ts +0 -12
- package/dist/observe/observe.d.ts.map +0 -1
- package/dist/optional.d.ts.map +0 -1
- package/dist/primitive.d.ts.map +0 -1
- package/dist/record.d.ts.map +0 -1
- package/dist/renderable.d.ts.map +0 -1
- package/dist/runtime/detect.d.ts.map +0 -1
- package/dist/runtime/external.d.ts.map +0 -1
- package/dist/runtime/index.d.ts.map +0 -1
- package/dist/runtime/os.d.ts +0 -10
- package/dist/runtime/os.d.ts.map +0 -1
- package/dist/search.d.ts.map +0 -1
- package/dist/shallowCopy.d.ts +0 -2
- package/dist/shallowCopy.d.ts.map +0 -1
- package/dist/spatial/base.d.ts.map +0 -1
- package/dist/spatial/bounds/bounds.d.ts +0 -71
- package/dist/spatial/bounds/bounds.d.ts.map +0 -1
- package/dist/spatial/bounds/bounds.spec.d.ts.map +0 -1
- package/dist/spatial/bounds/index.d.ts.map +0 -1
- package/dist/spatial/box/box.d.ts.map +0 -1
- package/dist/spatial/box/box.spec.d.ts.map +0 -1
- package/dist/spatial/box/index.d.ts.map +0 -1
- package/dist/spatial/dimensions/dimensions.d.ts.map +0 -1
- package/dist/spatial/dimensions/dimensions.spec.d.ts.map +0 -1
- package/dist/spatial/dimensions/index.d.ts.map +0 -1
- package/dist/spatial/direction/direction.d.ts.map +0 -1
- package/dist/spatial/direction/direction.spec.d.ts.map +0 -1
- package/dist/spatial/direction/index.d.ts.map +0 -1
- package/dist/spatial/external.d.ts.map +0 -1
- package/dist/spatial/index.d.ts.map +0 -1
- package/dist/spatial/location/index.d.ts.map +0 -1
- package/dist/spatial/location/location.d.ts.map +0 -1
- package/dist/spatial/location/location.spec.d.ts.map +0 -1
- package/dist/spatial/position/index.d.ts.map +0 -1
- package/dist/spatial/position/position.d.ts.map +0 -1
- package/dist/spatial/position/position.spec.d.ts.map +0 -1
- package/dist/spatial/scale/index.d.ts.map +0 -1
- package/dist/spatial/scale/scale.d.ts.map +0 -1
- package/dist/spatial/scale/scale.spec.d.ts.map +0 -1
- package/dist/spatial/spatial.d.ts +0 -2
- package/dist/spatial/spatial.d.ts.map +0 -1
- package/dist/spatial/xy/index.d.ts.map +0 -1
- package/dist/spatial/xy/xy.d.ts.map +0 -1
- package/dist/telem/generate.d.ts +0 -3
- package/dist/telem/generate.d.ts.map +0 -1
- package/dist/telem/gl.d.ts.map +0 -1
- package/dist/telem/index.d.ts.map +0 -1
- package/dist/telem/series.d.ts.map +0 -1
- package/dist/telem/telem.d.ts.map +0 -1
- package/dist/toArray.d.ts.map +0 -1
- package/dist/transform.d.ts +0 -2
- package/dist/transform.d.ts.map +0 -1
- package/dist/unique.d.ts.map +0 -1
- package/dist/url/index.d.ts +0 -2
- package/dist/url/index.d.ts.map +0 -1
- package/dist/url/url.d.ts.map +0 -1
- package/dist/worker/worker.d.ts.map +0 -1
- package/dist/worker/worker.spec.d.ts.map +0 -1
- package/dist/x.cjs +0 -12
- package/dist/x.cjs.map +0 -1
- package/dist/x.js +0 -5935
- package/dist/x.js.map +0 -1
- package/src/case.ts +0 -27
- package/src/deep/memo.ts +0 -24
- /package/dist/{binary → src/binary}/encoder.spec.d.ts +0 -0
- /package/dist/{binary → src/binary}/index.d.ts +0 -0
- /package/dist/{change → src/change}/index.d.ts +0 -0
- /package/dist/{clamp.d.ts → src/clamp/clamp.d.ts} +0 -0
- /package/dist/{compare → src/compare}/index.d.ts +0 -0
- /package/dist/{debounce.d.ts → src/debounce/debounce.d.ts} +0 -0
- /package/dist/{deep → src/deep}/copy.d.ts +0 -0
- /package/dist/{deep → src/deep}/delete.spec.d.ts +0 -0
- /package/dist/{deep → src/deep}/difference.d.ts +0 -0
- /package/dist/{deep → src/deep}/difference.spec.d.ts +0 -0
- /package/dist/{deep → src/deep}/equal.d.ts +0 -0
- /package/dist/{deep → src/deep}/equal.spec.d.ts +0 -0
- /package/dist/{deep → src/deep}/index.d.ts +0 -0
- /package/dist/{deep → src/deep}/merge.spec.d.ts +0 -0
- /package/dist/{deep → src/deep}/partial.d.ts +0 -0
- /package/dist/{deep → src/deep}/path.spec.d.ts +0 -0
- /package/dist/{destructor.d.ts → src/destructor.d.ts} +0 -0
- /package/dist/{invert.d.ts → src/invert.d.ts} +0 -0
- /package/dist/{join.d.ts → src/join.d.ts} +0 -0
- /package/dist/{kv → src/kv}/index.d.ts +0 -0
- /package/dist/{kv → src/kv}/types.d.ts +0 -0
- /package/dist/{migrate → src/migrate}/index.d.ts +0 -0
- /package/dist/{migrate → src/migrate}/migrate.spec.d.ts +0 -0
- /package/dist/{mock → src/mock}/index.d.ts +0 -0
- /package/dist/{observe → src/observe}/index.d.ts +0 -0
- /package/dist/{optional.d.ts → src/optional.d.ts} +0 -0
- /package/dist/{runtime → src/runtime}/detect.d.ts +0 -0
- /package/dist/{runtime → src/runtime}/external.d.ts +0 -0
- /package/dist/{runtime → src/runtime}/index.d.ts +0 -0
- /package/dist/{spatial → src/spatial}/bounds/bounds.spec.d.ts +0 -0
- /package/dist/{spatial → src/spatial}/bounds/index.d.ts +0 -0
- /package/dist/{spatial → src/spatial}/box/box.spec.d.ts +0 -0
- /package/dist/{spatial → src/spatial}/box/index.d.ts +0 -0
- /package/dist/{spatial → src/spatial}/dimensions/dimensions.spec.d.ts +0 -0
- /package/dist/{spatial → src/spatial}/dimensions/index.d.ts +0 -0
- /package/dist/{spatial → src/spatial}/direction/direction.spec.d.ts +0 -0
- /package/dist/{spatial → src/spatial}/direction/index.d.ts +0 -0
- /package/dist/{spatial → src/spatial}/index.d.ts +0 -0
- /package/dist/{spatial → src/spatial}/location/index.d.ts +0 -0
- /package/dist/{spatial → src/spatial}/location/location.spec.d.ts +0 -0
- /package/dist/{spatial → src/spatial}/position/index.d.ts +0 -0
- /package/dist/{spatial → src/spatial}/position/position.spec.d.ts +0 -0
- /package/dist/{spatial → src/spatial}/scale/index.d.ts +0 -0
- /package/dist/{spatial → src/spatial}/scale/scale.spec.d.ts +0 -0
- /package/dist/{spatial → src/spatial}/xy/index.d.ts +0 -0
- /package/dist/{spatial → src/spatial}/xy/xy.spec.d.ts +0 -0
- /package/dist/{telem → src/telem}/gl.d.ts +0 -0
- /package/dist/{telem → src/telem}/series.spec.d.ts +0 -0
- /package/dist/{telem → src/telem}/telem.spec.d.ts +0 -0
- /package/dist/{toArray.d.ts → src/toArray.d.ts} +0 -0
- /package/dist/{unique.d.ts → src/unique.d.ts} +0 -0
- /package/dist/{url → src/url}/url.d.ts +0 -0
- /package/dist/{url → src/url}/url.spec.d.ts +0 -0
- /package/dist/{worker → src/worker}/worker.spec.d.ts +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright 2024 Synnax Labs, Inc.
|
|
2
2
|
//
|
|
3
3
|
// Use of this software is governed by the Business Source License included in the file
|
|
4
4
|
// licenses/BSL.txt.
|
|
@@ -7,118 +7,231 @@
|
|
|
7
7
|
// License, use of this software will be governed by the Apache License, Version 2.0,
|
|
8
8
|
// included in the file licenses/APL.txt.
|
|
9
9
|
|
|
10
|
+
import { math } from "@/math";
|
|
10
11
|
import { type Bounds, bounds, type CrudeBounds } from "@/spatial/base";
|
|
11
12
|
|
|
12
13
|
export { type Bounds, bounds };
|
|
13
14
|
|
|
14
|
-
export type Crude = CrudeBounds
|
|
15
|
+
export type Crude<T extends number | bigint = number> = CrudeBounds<T>;
|
|
15
16
|
|
|
16
|
-
export
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
export interface Construct {
|
|
18
|
+
/**
|
|
19
|
+
* Constructs a bounds object from the given crude bounds.
|
|
20
|
+
*
|
|
21
|
+
* @param bounds - The crude bounds to construct. Can either be a strict bounds object
|
|
22
|
+
* with a 'lower' and 'upper' property or an array of length 2. If the bounds are
|
|
23
|
+
* invalid i.e., the lower bound is greater than the upper bound, the bounds are
|
|
24
|
+
* swapped.
|
|
25
|
+
*/ <T extends number | bigint = number>(bounds: Crude<T>): Bounds<T>;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Constructs a bounds object from the given lower and upper bounds.
|
|
29
|
+
* @param lower - The lower bound of the new bounds object.
|
|
30
|
+
* @param upper - The upper bound of the new bounds object.
|
|
31
|
+
*
|
|
32
|
+
* If only one argument is provided, it is assumed to be the upper bound and the lower
|
|
33
|
+
* bound is set to 0.
|
|
34
|
+
*
|
|
35
|
+
* If the lower bound is greater than the upper bound, the bounds are swapped.
|
|
36
|
+
*/ <T extends number | bigint = number>(lower: number, upper?: number): Bounds<T>;
|
|
37
|
+
|
|
38
|
+
<T extends number | bigint = number>(
|
|
39
|
+
lower: number | Crude,
|
|
40
|
+
upper?: number,
|
|
41
|
+
): Bounds<T>;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export const construct = <T extends bigint | number>(
|
|
45
|
+
lower: T | Crude<T>,
|
|
46
|
+
upper?: T,
|
|
47
|
+
): Bounds<T> => {
|
|
48
|
+
const b: Bounds<T> = {} as const as Bounds<T>;
|
|
49
|
+
if (typeof lower === "number" || typeof lower === "bigint") {
|
|
19
50
|
if (upper != null) {
|
|
20
51
|
b.lower = lower;
|
|
21
52
|
b.upper = upper;
|
|
22
53
|
} else {
|
|
23
|
-
b.lower = 0;
|
|
54
|
+
b.lower = (typeof lower === "bigint" ? 0n : 0) as T;
|
|
24
55
|
b.upper = lower;
|
|
25
56
|
}
|
|
26
57
|
} else if (Array.isArray(lower)) {
|
|
58
|
+
if (lower.length !== 2) throw new Error("bounds: expected array of length 2");
|
|
27
59
|
[b.lower, b.upper] = lower;
|
|
28
|
-
} else
|
|
29
|
-
b.lower = lower.lower;
|
|
30
|
-
b.upper = lower.upper;
|
|
31
|
-
}
|
|
60
|
+
} else return makeValid(lower);
|
|
32
61
|
return makeValid(b);
|
|
33
62
|
};
|
|
34
63
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
64
|
+
/** A lower and upper bound of 0. */
|
|
65
|
+
export const ZERO: Bounds = Object.freeze({ lower: 0, upper: 0 });
|
|
66
|
+
/** A lower bound of -Infinity and an upper bound of Infinity. */
|
|
67
|
+
export const INFINITE: Bounds = Object.freeze({ lower: -Infinity, upper: Infinity });
|
|
68
|
+
/** A lower bound of 0 and an upper bound of 1. */
|
|
69
|
+
export const DECIMAL: Bounds = Object.freeze({ lower: 0, upper: 1 });
|
|
70
|
+
/** Clip space bounds i.e. a lower bound of -1 and an upper bound of 1. */
|
|
71
|
+
export const CLIP = Object.freeze({ lower: -1, upper: 1 });
|
|
42
72
|
|
|
43
|
-
|
|
73
|
+
/**
|
|
74
|
+
* Checks whether the given bounds are equal.
|
|
75
|
+
*
|
|
76
|
+
* @param _a - The first bounds to compare.
|
|
77
|
+
* @param _b - The second bounds to compare.
|
|
78
|
+
* @returns True if the bounds are equal, false otherwise.
|
|
79
|
+
*/
|
|
80
|
+
export const equals = <T extends bigint | number = number>(
|
|
81
|
+
_a?: Crude<T>,
|
|
82
|
+
_b?: Crude<T>,
|
|
83
|
+
): boolean => {
|
|
44
84
|
if (_a == null && _b == null) return true;
|
|
45
85
|
if (_a == null || _b == null) return false;
|
|
46
86
|
const a = construct(_a);
|
|
47
87
|
const b = construct(_b);
|
|
48
88
|
return a?.lower === b?.lower && a?.upper === b?.upper;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Makes the given bounds valid by swapping the lower and upper bounds if the lower bound
|
|
92
|
+
* is greater than the upper bound.
|
|
93
|
+
* @param a - The bounds to make valid.
|
|
94
|
+
* @returns The valid bounds.
|
|
95
|
+
*/
|
|
96
|
+
export const makeValid = <T extends number | bigint = number>(
|
|
97
|
+
a: Bounds<T>,
|
|
98
|
+
): Bounds<T> => {
|
|
52
99
|
if (a.lower > a.upper) return { lower: a.upper, upper: a.lower };
|
|
53
100
|
return a;
|
|
54
101
|
};
|
|
55
102
|
|
|
56
|
-
|
|
57
|
-
|
|
103
|
+
/**
|
|
104
|
+
* Clamps the given target value to the given bounds. If the target is less than the lower
|
|
105
|
+
* bound, the lower bound is returned. If the target is greater than or equal to the upper
|
|
106
|
+
* bound, the upper bound minus 1 is returned. Otherwise, the target is returned.
|
|
107
|
+
*
|
|
108
|
+
* @param bounds - The bounds to clamp the target to.
|
|
109
|
+
* @param target - The target value to clamp.
|
|
110
|
+
* @returns The clamped target value.
|
|
111
|
+
*/
|
|
112
|
+
export const clamp = <T extends number | bigint>(bounds: Crude<T>, target: T): T => {
|
|
113
|
+
const _bounds = construct<T>(bounds);
|
|
58
114
|
if (target < _bounds.lower) return _bounds.lower;
|
|
59
|
-
if (target >= _bounds.upper)
|
|
115
|
+
if (target >= _bounds.upper)
|
|
116
|
+
return (_bounds.upper - ((typeof _bounds.upper === "number" ? 1 : 1n) as T)) as T;
|
|
60
117
|
return target;
|
|
61
118
|
};
|
|
62
119
|
|
|
63
|
-
|
|
120
|
+
/**
|
|
121
|
+
* Checks whether the given target value or bounds are within the given bounds.
|
|
122
|
+
*
|
|
123
|
+
* @param bounds - The bounds to check against.
|
|
124
|
+
* @param target - The target value to check. Can either be a number or a bounds object.
|
|
125
|
+
* @returns True if the target is within the bounds, false otherwise.
|
|
126
|
+
*/
|
|
127
|
+
export const contains = <T extends bigint | number>(
|
|
128
|
+
bounds: Crude<T>,
|
|
129
|
+
target: T | CrudeBounds<T>,
|
|
130
|
+
): boolean => {
|
|
64
131
|
const _bounds = construct(bounds);
|
|
65
|
-
if (typeof target === "number"
|
|
132
|
+
if (typeof target === "number" || typeof target === "bigint")
|
|
133
|
+
return target >= _bounds.lower && target < _bounds.upper;
|
|
66
134
|
const _target = construct(target);
|
|
67
135
|
return _target.lower >= _bounds.lower && _target.upper <= _bounds.upper;
|
|
68
|
-
}
|
|
136
|
+
};
|
|
69
137
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
138
|
+
/**
|
|
139
|
+
* Checks whether the given bounds overlap with each other.
|
|
140
|
+
*
|
|
141
|
+
* @param a - The first bounds to check.
|
|
142
|
+
* @param b - The second bounds to check.
|
|
143
|
+
* @returns True if the bounds overlap, false otherwise.
|
|
144
|
+
*/
|
|
145
|
+
export const overlapsWith = <T extends bigint | number>(
|
|
146
|
+
a: Crude<T>,
|
|
147
|
+
b: Crude<T>,
|
|
148
|
+
): boolean => {
|
|
149
|
+
const _a = construct<T>(a);
|
|
150
|
+
const _b = construct<T>(b);
|
|
151
|
+
if (_a.lower === _b.lower) return true;
|
|
152
|
+
if (_b.upper === _a.lower || _b.lower === _a.upper) return false;
|
|
153
|
+
return (
|
|
154
|
+
contains<T>(_a, _b.upper) ||
|
|
155
|
+
contains<T>(_a, _b.lower) ||
|
|
156
|
+
contains<T>(_b, _a.upper) ||
|
|
157
|
+
contains<T>(_b, _a.lower)
|
|
158
|
+
);
|
|
159
|
+
};
|
|
80
160
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
161
|
+
/** @returns the span of the given bounds i.e. upper - lower. */
|
|
162
|
+
export const span = <T extends number | bigint>(a: Crude<T>): T => {
|
|
163
|
+
const _a = construct<T>(a);
|
|
164
|
+
return (_a.upper - _a.lower) as T;
|
|
165
|
+
};
|
|
85
166
|
|
|
86
|
-
|
|
167
|
+
/** @returns true if both the lower and upper bounds are 0, false otherwise. */
|
|
168
|
+
export const isZero = <T extends number | bigint>(a: Crude<T>): boolean => {
|
|
87
169
|
const _a = construct(a);
|
|
170
|
+
if (typeof _a.lower === "bigint") return _a.lower === 0n && _a.upper === 0n;
|
|
88
171
|
return _a.lower === 0 && _a.upper === 0;
|
|
89
|
-
}
|
|
172
|
+
};
|
|
90
173
|
|
|
174
|
+
/**
|
|
175
|
+
* @returns true if the difference between the lower and upper bounds is 0,
|
|
176
|
+
* false otherwise.
|
|
177
|
+
*/
|
|
91
178
|
export const spanIsZero = (a: Crude): boolean => span(a) === 0;
|
|
92
179
|
|
|
180
|
+
/**
|
|
181
|
+
* @returns true if both the upper and lower bounds are not Infinity or -Infinity,
|
|
182
|
+
* false otherwise.
|
|
183
|
+
*/
|
|
93
184
|
export const isFinite = (a: Crude): boolean => {
|
|
94
185
|
const _a = construct(a);
|
|
95
186
|
return Number.isFinite(_a.lower) && Number.isFinite(_a.upper);
|
|
96
|
-
}
|
|
187
|
+
};
|
|
97
188
|
|
|
189
|
+
/**
|
|
190
|
+
* @returns bounds that have the maximum span of the given bounds i.e. the min of all
|
|
191
|
+
* of the lower bounds and the max of all of the upper bounds.
|
|
192
|
+
*/
|
|
98
193
|
export const max = (bounds: Crude[]): Bounds => ({
|
|
99
194
|
lower: Math.min(...bounds.map((b) => construct(b).lower)),
|
|
100
195
|
upper: Math.max(...bounds.map((b) => construct(b).upper)),
|
|
101
196
|
});
|
|
102
197
|
|
|
198
|
+
/**
|
|
199
|
+
* @returns bounds that have the minimum span of the given bounds i.e. the max of all
|
|
200
|
+
* of the lower bounds and the min of all of the upper bounds. Note that this function
|
|
201
|
+
* may create invalid bounds if the highest lower bound is greater than the lowest upper
|
|
202
|
+
* bound.
|
|
203
|
+
*/
|
|
103
204
|
export const min = (bounds: Crude[]): Bounds => ({
|
|
104
205
|
lower: Math.max(...bounds.map((b) => construct(b).lower)),
|
|
105
206
|
upper: Math.min(...bounds.map((b) => construct(b).upper)),
|
|
106
207
|
});
|
|
107
208
|
|
|
108
|
-
|
|
209
|
+
/**
|
|
210
|
+
* @returns an array of integers from the lower bound to the upper bound of the given
|
|
211
|
+
* bounds.
|
|
212
|
+
*/
|
|
213
|
+
export const linspace = <T extends bigint | number = number>(bounds: Crude<T>): T[] => {
|
|
109
214
|
const _bounds = construct(bounds);
|
|
110
|
-
|
|
111
|
-
}
|
|
215
|
+
const isBigInt = typeof _bounds.lower === "bigint";
|
|
216
|
+
return Array.from({ length: Number(span(bounds)) }, (_, i) => {
|
|
217
|
+
if (isBigInt) return ((_bounds.lower as bigint) + BigInt(i)) as T;
|
|
218
|
+
return (_bounds.lower as number) + i;
|
|
219
|
+
}) as T[];
|
|
220
|
+
};
|
|
112
221
|
|
|
113
|
-
export const findInsertPosition =
|
|
114
|
-
|
|
115
|
-
|
|
222
|
+
export const findInsertPosition = <T extends bigint | number>(
|
|
223
|
+
bounds: Array<Crude<T>>,
|
|
224
|
+
target: T,
|
|
225
|
+
): { index: number; position: number } => {
|
|
226
|
+
const _bounds = bounds.map((b) => construct<T>(b));
|
|
227
|
+
const index = _bounds.findIndex(
|
|
228
|
+
(b, i) => contains<T>(b, target) || target < _bounds[i].lower,
|
|
229
|
+
);
|
|
116
230
|
if (index === -1) return { index: bounds.length, position: 0 };
|
|
117
231
|
const b = _bounds[index];
|
|
118
|
-
if (contains(b, target)) return { index, position: target - b.lower };
|
|
119
|
-
return {
|
|
120
|
-
}
|
|
121
|
-
|
|
232
|
+
if (contains(b, target)) return { index, position: Number(target - b.lower) };
|
|
233
|
+
return { index, position: 0 };
|
|
234
|
+
};
|
|
122
235
|
|
|
123
236
|
/**
|
|
124
237
|
* A plan for inserting a new bound into an ordered array of bounds.
|
|
@@ -141,18 +254,18 @@ const ZERO_PLAN: InsertionPlan = {
|
|
|
141
254
|
removeAfter: 0,
|
|
142
255
|
insertInto: 0,
|
|
143
256
|
deleteInBetween: 0,
|
|
144
|
-
}
|
|
257
|
+
};
|
|
145
258
|
|
|
146
259
|
/**
|
|
147
260
|
* Build a plan for inserting a new bound into an ordered array of bounds. This function
|
|
148
261
|
* is particularly useful for inserting a new array into a sorted array of array of arrays
|
|
149
262
|
* that may overlap. The plan is used to determine how to splice the new array into the
|
|
150
263
|
* existing array. The following are important constraints:
|
|
151
|
-
*
|
|
152
|
-
*
|
|
264
|
+
*
|
|
265
|
+
*
|
|
153
266
|
* 1. If the new bound is entirely contained within an existing bound, the new bound
|
|
154
267
|
* is not inserted and the plan is null.
|
|
155
|
-
*
|
|
268
|
+
*
|
|
156
269
|
* @param bounds - An ordered array of bounds, where each bound is valid (i.e., lower <= upper)
|
|
157
270
|
* and the lower bound of each bound is less than the upper bound of the next bound.
|
|
158
271
|
* @param value - The new bound to insert.
|
|
@@ -160,56 +273,58 @@ const ZERO_PLAN: InsertionPlan = {
|
|
|
160
273
|
* new bound is entirely contained within an existing bound. See the {@link InsertionPlan}
|
|
161
274
|
* type for more details.
|
|
162
275
|
*/
|
|
163
|
-
export const buildInsertionPlan =
|
|
164
|
-
|
|
276
|
+
export const buildInsertionPlan = <T extends number | bigint>(
|
|
277
|
+
bounds: Array<Crude<T>>,
|
|
278
|
+
value: Crude<T>,
|
|
279
|
+
): InsertionPlan | null => {
|
|
280
|
+
const _bounds = bounds.map((b) => construct<T>(b));
|
|
165
281
|
const _target = construct(value);
|
|
166
282
|
// No bounds to insert into, so just insert the new bound at the beginning of the array.
|
|
167
283
|
if (_bounds.length === 0) return ZERO_PLAN;
|
|
168
|
-
const lower = findInsertPosition(
|
|
169
|
-
const upper = findInsertPosition(
|
|
284
|
+
const lower = findInsertPosition<T>(_bounds, _target.lower);
|
|
285
|
+
const upper = findInsertPosition<T>(_bounds, _target.upper);
|
|
170
286
|
// Greater than all bounds,
|
|
171
|
-
if (lower.index
|
|
287
|
+
if (lower.index === bounds.length) return { ...ZERO_PLAN, insertInto: bounds.length };
|
|
172
288
|
// Less than all bounds,
|
|
173
|
-
if (upper.index
|
|
174
|
-
...ZERO_PLAN,
|
|
175
|
-
removeAfter: upper.position
|
|
176
|
-
}
|
|
289
|
+
if (upper.index === 0) return { ...ZERO_PLAN, removeAfter: upper.position };
|
|
177
290
|
if (lower.index === upper.index) {
|
|
178
291
|
// The case where the bound is entirely contained within an existing bound.
|
|
179
|
-
if (lower.position !== 0 && upper.position !== 0)
|
|
180
|
-
return null;
|
|
292
|
+
if (lower.position !== 0 && upper.position !== 0) return null;
|
|
181
293
|
return {
|
|
182
294
|
removeAfter: upper.position,
|
|
183
295
|
removeBefore: lower.position,
|
|
184
296
|
insertInto: lower.index,
|
|
185
297
|
deleteInBetween: 0,
|
|
186
|
-
}
|
|
298
|
+
};
|
|
187
299
|
}
|
|
188
|
-
let deleteInBetween =
|
|
300
|
+
let deleteInBetween = upper.index - lower.index;
|
|
189
301
|
let insertInto = lower.index;
|
|
190
|
-
let removeBefore = span(_bounds[lower.index])
|
|
302
|
+
let removeBefore = math.sub(Number(span(_bounds[lower.index])), lower.position);
|
|
191
303
|
// If we're overlapping with the previous bound, we need to slice out one less
|
|
192
304
|
// and insert one further up.
|
|
193
|
-
if (lower.position
|
|
305
|
+
if (lower.position !== 0) {
|
|
194
306
|
deleteInBetween -= 1;
|
|
195
307
|
insertInto += 1;
|
|
196
|
-
|
|
308
|
+
// We're not overlapping with the previous bound, so don't need to remove anything
|
|
197
309
|
} else removeBefore = 0;
|
|
198
310
|
return {
|
|
199
311
|
removeBefore,
|
|
200
312
|
removeAfter: upper.position,
|
|
201
|
-
insertInto,
|
|
313
|
+
insertInto,
|
|
202
314
|
deleteInBetween,
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
|
|
315
|
+
};
|
|
316
|
+
};
|
|
206
317
|
|
|
207
|
-
export const insert =
|
|
318
|
+
export const insert = <T extends number | bigint = number>(
|
|
319
|
+
bounds: Array<Crude<T>>,
|
|
320
|
+
value: Crude<T>,
|
|
321
|
+
): Array<Bounds<T>> => {
|
|
208
322
|
const plan = buildInsertionPlan(bounds, value);
|
|
209
|
-
|
|
323
|
+
const out = bounds.map((b) => construct(b));
|
|
324
|
+
if (plan == null) return out;
|
|
210
325
|
const _target = construct(value);
|
|
211
|
-
_target.lower
|
|
212
|
-
_target.upper
|
|
213
|
-
|
|
214
|
-
return
|
|
215
|
-
}
|
|
326
|
+
_target.lower = math.add(_target.lower, plan.removeBefore);
|
|
327
|
+
_target.upper = math.sub(_target.upper, plan.removeAfter);
|
|
328
|
+
out.splice(plan.insertInto, plan.deleteInBetween, _target);
|
|
329
|
+
return out;
|
|
330
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright 2024 Synnax Labs, Inc.
|
|
2
2
|
//
|
|
3
3
|
// Use of this software is governed by the Business Source License included in the file
|
|
4
4
|
// licenses/BSL.txt.
|
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
// License, use of this software will be governed by the Apache License, Version 2.0,
|
|
8
8
|
// included in the file licenses/APL.txt.
|
|
9
9
|
|
|
10
|
-
export * as bounds from "@/spatial/bounds/bounds";
|
|
10
|
+
export * as bounds from "@/spatial/bounds/bounds";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright 2024 Synnax Labs, Inc.
|
|
2
2
|
//
|
|
3
3
|
// Use of this software is governed by the Business Source License included in the file
|
|
4
4
|
// licenses/BSL.txt.
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
// License, use of this software will be governed by the Apache License, Version 2.0,
|
|
8
8
|
// included in the file licenses/APL.txt.
|
|
9
9
|
|
|
10
|
-
import { describe,
|
|
10
|
+
import { describe, expect, it,test } from "vitest";
|
|
11
11
|
|
|
12
12
|
import * as box from "@/spatial/box/box";
|
|
13
13
|
import * as location from "@/spatial/location/location";
|
|
@@ -237,4 +237,213 @@ describe("Box", () => {
|
|
|
237
237
|
expect(box.bottomRight(b2)).toEqual({ x: 10, y: 20 });
|
|
238
238
|
});
|
|
239
239
|
});
|
|
240
|
+
describe("truncate", () => {
|
|
241
|
+
it("should truncte the precision of the coordinates", () => {
|
|
242
|
+
const b = box.construct(
|
|
243
|
+
{ x: 0.123456, y: 0.123456 },
|
|
244
|
+
{ x: 10.123456, y: 10.123456 },
|
|
245
|
+
);
|
|
246
|
+
const b2 = box.truncate(b, 2);
|
|
247
|
+
expect(box.topLeft(b2)).toEqual({ x: 0.12, y: 0.12 });
|
|
248
|
+
expect(box.topRight(b2)).toEqual({ x: 10.12, y: 0.12 });
|
|
249
|
+
expect(box.bottomLeft(b2)).toEqual({ x: 0.12, y: 10.12 });
|
|
250
|
+
expect(box.bottomRight(b2)).toEqual({ x: 10.12, y: 10.12 });
|
|
251
|
+
});
|
|
252
|
+
});
|
|
253
|
+
describe("intersection", () => {
|
|
254
|
+
it("should return the intersection of two boxes", () => {
|
|
255
|
+
const b = box.construct(0, 0, 10, 10);
|
|
256
|
+
const b2 = box.construct(5, 5, 15, 15);
|
|
257
|
+
const b3 = box.intersection(b, b2);
|
|
258
|
+
expect(box.topLeft(b3)).toEqual({ x: 5, y: 5 });
|
|
259
|
+
expect(box.topRight(b3)).toEqual({ x: 10, y: 5 });
|
|
260
|
+
expect(box.bottomLeft(b3)).toEqual({ x: 5, y: 10 });
|
|
261
|
+
expect(box.bottomRight(b3)).toEqual({ x: 10, y: 10 });
|
|
262
|
+
});
|
|
263
|
+
it("should return a zero box if there is no intersection", () => {
|
|
264
|
+
const b = box.construct(0, 0, 10, 10);
|
|
265
|
+
const b2 = box.construct(15, 15, 20, 20);
|
|
266
|
+
const b3 = box.intersection(b, b2);
|
|
267
|
+
expect(box.topLeft(b3)).toEqual({ x: 0, y: 0 });
|
|
268
|
+
expect(box.topRight(b3)).toEqual({ x: 0, y: 0 });
|
|
269
|
+
expect(box.bottomLeft(b3)).toEqual({ x: 0, y: 0 });
|
|
270
|
+
expect(box.bottomRight(b3)).toEqual({ x: 0, y: 0 });
|
|
271
|
+
});
|
|
272
|
+
});
|
|
273
|
+
describe("area", () => {
|
|
274
|
+
it("should return the area of the box", () => {
|
|
275
|
+
const b = box.construct(0, 0, 10, 10);
|
|
276
|
+
expect(box.area(b)).toBe(100);
|
|
277
|
+
});
|
|
278
|
+
});
|
|
279
|
+
describe("areaIsZero", () => {
|
|
280
|
+
it("should return true if the area is zero", () => {
|
|
281
|
+
const b = box.construct(0, 0, 0, 0);
|
|
282
|
+
expect(box.areaIsZero(b)).toBe(true);
|
|
283
|
+
});
|
|
284
|
+
it("should return false if the area is not zero", () => {
|
|
285
|
+
const b = box.construct(0, 0, 10, 10);
|
|
286
|
+
expect(box.areaIsZero(b)).toBe(false);
|
|
287
|
+
});
|
|
288
|
+
});
|
|
289
|
+
describe("isBox", () => {
|
|
290
|
+
it("should return true if the value is a box", () => {
|
|
291
|
+
const b = box.construct(0, 0, 10, 10);
|
|
292
|
+
expect(box.isBox(b)).toBe(true);
|
|
293
|
+
});
|
|
294
|
+
it("should return false if the value is not a box", () => {
|
|
295
|
+
expect(box.isBox({})).toBe(false);
|
|
296
|
+
});
|
|
297
|
+
});
|
|
298
|
+
describe("yBounds", () => {
|
|
299
|
+
it("should return the y bounds of the box", () => {
|
|
300
|
+
const b = box.construct(0, 0, 10, 10);
|
|
301
|
+
expect(box.yBounds(b)).toEqual({ lower: 0, upper: 10 });
|
|
302
|
+
});
|
|
303
|
+
});
|
|
304
|
+
describe("xBounds", () => {
|
|
305
|
+
it("should return the x bounds of the box", () => {
|
|
306
|
+
const b = box.construct(0, 0, 10, 10);
|
|
307
|
+
expect(box.xBounds(b)).toEqual({ lower: 0, upper: 10 });
|
|
308
|
+
});
|
|
309
|
+
});
|
|
310
|
+
describe("contains", () => {
|
|
311
|
+
describe("inclusive of border", () => {
|
|
312
|
+
it("should return true if the box completely contains the other box", () => {
|
|
313
|
+
const b = box.construct(0, 0, 20, 20);
|
|
314
|
+
const b2 = box.construct(5, 5, 15, 15);
|
|
315
|
+
expect(box.contains(b, b2)).toBe(true);
|
|
316
|
+
});
|
|
317
|
+
it("should return true if the box completely contains the other box", () => {
|
|
318
|
+
const b = box.construct(0, 0, 20, 20);
|
|
319
|
+
const b2 = box.construct(5, 5, 14, 14);
|
|
320
|
+
expect(box.contains(b, b2)).toBe(true);
|
|
321
|
+
});
|
|
322
|
+
it("should return false if the box does not completely contain the other box", () => {
|
|
323
|
+
const b = box.construct(0, 0, 10, 10);
|
|
324
|
+
const b2 = box.construct(5, 5, 15, 15);
|
|
325
|
+
expect(box.contains(b, b2)).toBe(false);
|
|
326
|
+
});
|
|
327
|
+
it("should return true if the two boxes are equal", () => {
|
|
328
|
+
const b = box.construct(0, 0, 10, 10);
|
|
329
|
+
expect(box.contains(b, b)).toBe(true);
|
|
330
|
+
});
|
|
331
|
+
it("should return true if the box contains the point", () => {
|
|
332
|
+
const b = box.construct(0, 0, 10, 10);
|
|
333
|
+
const p = { x: 5, y: 5 };
|
|
334
|
+
expect(box.contains(b, p)).toBe(true);
|
|
335
|
+
});
|
|
336
|
+
it("should return false if the box does not contain the point", () => {
|
|
337
|
+
const b = box.construct(0, 0, 10, 10);
|
|
338
|
+
const p = { x: 15, y: 15 };
|
|
339
|
+
expect(box.contains(b, p)).toBe(false);
|
|
340
|
+
});
|
|
341
|
+
it("should return true if the point is on the border", () => {
|
|
342
|
+
const b = box.construct(0, 0, 10, 10);
|
|
343
|
+
const p = { x: 10, y: 10 };
|
|
344
|
+
expect(box.contains(b, p)).toBe(true);
|
|
345
|
+
});
|
|
346
|
+
});
|
|
347
|
+
describe("exclusive of border", () => {
|
|
348
|
+
it("should return false if the box completely contains the other box", () => {
|
|
349
|
+
const b = box.construct(0, 0, 20, 20);
|
|
350
|
+
const b2 = box.construct(5, 5, 15, 15);
|
|
351
|
+
expect(box.contains(b, b2, false)).toBe(false);
|
|
352
|
+
});
|
|
353
|
+
it("should return true if the box completely contains the other box", () => {
|
|
354
|
+
const b = box.construct(0, 0, 20, 20);
|
|
355
|
+
const b2 = box.construct(5, 5, 14, 14);
|
|
356
|
+
expect(box.contains(b, b2, false)).toBe(true);
|
|
357
|
+
});
|
|
358
|
+
it("should return false if the box does not completely contain the other box", () => {
|
|
359
|
+
const b = box.construct(0, 0, 10, 10);
|
|
360
|
+
const b2 = box.construct(5, 5, 15, 15);
|
|
361
|
+
expect(box.contains(b, b2, false)).toBe(false);
|
|
362
|
+
});
|
|
363
|
+
it("should return false if the two boxes are equal", () => {
|
|
364
|
+
const b = box.construct(0, 0, 10, 10);
|
|
365
|
+
expect(box.contains(b, b, false)).toBe(false);
|
|
366
|
+
});
|
|
367
|
+
it("should return false if the box contains the point", () => {
|
|
368
|
+
const b = box.construct(0, 0, 10, 10);
|
|
369
|
+
const p = { x: 5, y: 5 };
|
|
370
|
+
expect(box.contains(b, p, false)).toBe(true);
|
|
371
|
+
});
|
|
372
|
+
it("should return false if the box does not contain the point", () => {
|
|
373
|
+
const b = box.construct(0, 0, 10, 10);
|
|
374
|
+
const p = { x: 15, y: 15 };
|
|
375
|
+
expect(box.contains(b, p, false)).toBe(false);
|
|
376
|
+
});
|
|
377
|
+
it("should return false if the point is on the border", () => {
|
|
378
|
+
const b = box.construct(0, 0, 10, 10);
|
|
379
|
+
const p = { x: 10, y: 10 };
|
|
380
|
+
expect(box.contains(b, p, false)).toBe(false);
|
|
381
|
+
});
|
|
382
|
+
});
|
|
383
|
+
});
|
|
384
|
+
describe("css", () => {
|
|
385
|
+
it("should return the box as an object of css properties", () => {
|
|
386
|
+
const b = box.construct(0, 0, 10, 10);
|
|
387
|
+
expect(box.css(b)).toEqual({
|
|
388
|
+
left: 0,
|
|
389
|
+
top: 0,
|
|
390
|
+
width: 10,
|
|
391
|
+
height: 10,
|
|
392
|
+
});
|
|
393
|
+
});
|
|
394
|
+
});
|
|
395
|
+
describe("copy", () => {
|
|
396
|
+
it("should return a copy of the box", () => {
|
|
397
|
+
const b = box.construct(0, 0, 10, 10);
|
|
398
|
+
const b2 = box.copy(b);
|
|
399
|
+
expect(box.equals(b, b2)).toBe(true);
|
|
400
|
+
});
|
|
401
|
+
});
|
|
402
|
+
describe("edgePoints", () => {
|
|
403
|
+
interface Spec {
|
|
404
|
+
box: box.Box;
|
|
405
|
+
loc: location.Location;
|
|
406
|
+
expected: [xy.XY, xy.XY];
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
const SPECS: Spec[] = [
|
|
410
|
+
{
|
|
411
|
+
box: box.construct(0, 0, 10, 10),
|
|
412
|
+
loc: "top",
|
|
413
|
+
expected: [
|
|
414
|
+
{ x: 0, y: 0 },
|
|
415
|
+
{ x: 10, y: 0 },
|
|
416
|
+
],
|
|
417
|
+
},
|
|
418
|
+
{
|
|
419
|
+
box: box.construct(0, 0, 10, 10),
|
|
420
|
+
loc: "bottom",
|
|
421
|
+
expected: [
|
|
422
|
+
{ x: 0, y: 10 },
|
|
423
|
+
{ x: 10, y: 10 },
|
|
424
|
+
],
|
|
425
|
+
},
|
|
426
|
+
{
|
|
427
|
+
box: box.construct(0, 0, 10, 10),
|
|
428
|
+
loc: "left",
|
|
429
|
+
expected: [
|
|
430
|
+
{ x: 0, y: 0 },
|
|
431
|
+
{ x: 0, y: 10 },
|
|
432
|
+
],
|
|
433
|
+
},
|
|
434
|
+
{
|
|
435
|
+
box: box.construct(0, 0, 10, 10),
|
|
436
|
+
loc: "right",
|
|
437
|
+
expected: [
|
|
438
|
+
{ x: 10, y: 0 },
|
|
439
|
+
{ x: 10, y: 10 },
|
|
440
|
+
],
|
|
441
|
+
},
|
|
442
|
+
];
|
|
443
|
+
SPECS.forEach(({ box: b, loc, expected }) => {
|
|
444
|
+
test(`edgePoints-${loc}`, () => {
|
|
445
|
+
expect(box.edgePoints(b, loc)).toEqual(expected);
|
|
446
|
+
});
|
|
447
|
+
});
|
|
448
|
+
});
|
|
240
449
|
});
|