@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
package/src/join.ts
CHANGED
package/src/kv/index.ts
CHANGED
package/src/kv/types.ts
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Copyright 2024 Synnax Labs, Inc.
|
|
2
|
+
//
|
|
3
|
+
// Use of this software is governed by the Business Source License included in the file
|
|
4
|
+
// licenses/BSL.txt.
|
|
5
|
+
//
|
|
6
|
+
// As of the Change Date specified in that file, in accordance with the Business Source
|
|
7
|
+
// License, use of this software will be governed by the Apache License, Version 2.0,
|
|
8
|
+
// included in the file licenses/APL.txt.
|
|
9
|
+
|
|
10
|
+
export * as math from "@/math/math";
|
package/src/math/math.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Copyright 2024 Synnax Labs, Inc.
|
|
2
|
+
//
|
|
3
|
+
// Use of this software is governed by the Business Source License included in the file
|
|
4
|
+
// licenses/BSL.txt.
|
|
5
|
+
//
|
|
6
|
+
// As of the Change Date specified in that file, in accordance with the Business Source
|
|
7
|
+
// License, use of this software will be governed by the Apache License, Version 2.0,
|
|
8
|
+
// included in the file licenses/APL.txt.
|
|
9
|
+
|
|
10
|
+
type Value = number | bigint;
|
|
11
|
+
|
|
12
|
+
/** @returns the product of a and b, coercing b to the type of a if necessary. */
|
|
13
|
+
export const sub = <V extends Value>(a: V, b: Value): V => {
|
|
14
|
+
if (typeof a === "bigint") return (a - BigInt(b)) as V;
|
|
15
|
+
return (a - Number(b)) as V;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/** @returns the sum of a and b, coercing b to the type of a if necessary. */
|
|
19
|
+
export const add = <V extends Value>(a: V, b: Value): V => {
|
|
20
|
+
if (typeof a === "bigint") return (a + BigInt(b)) as V;
|
|
21
|
+
// @ts-expect-error - a is a number but typescript doesn't recognize that.
|
|
22
|
+
return (a + Number(b)) as V;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/** @returns true if a is close to b within epsilon. */
|
|
26
|
+
export const closeTo = (a: number, b: number, epsilon = 0.0001): boolean =>
|
|
27
|
+
Math.abs(a - b) < epsilon;
|
|
28
|
+
|
|
29
|
+
/** @returns the nearest number to num with 1 significant digit. */
|
|
30
|
+
export const roundToNearestMagnitude = (num: number): number => {
|
|
31
|
+
const magnitude = Math.pow(10, Math.floor(Math.log10(num)));
|
|
32
|
+
return Math.round(num / magnitude) * magnitude;
|
|
33
|
+
};
|
package/src/migrate/index.ts
CHANGED
|
@@ -1 +1,10 @@
|
|
|
1
|
+
// Copyright 2024 Synnax Labs, Inc.
|
|
2
|
+
//
|
|
3
|
+
// Use of this software is governed by the Business Source License included in the file
|
|
4
|
+
// licenses/BSL.txt.
|
|
5
|
+
//
|
|
6
|
+
// As of the Change Date specified in that file, in accordance with the Business Source
|
|
7
|
+
// License, use of this software will be governed by the Apache License, Version 2.0,
|
|
8
|
+
// included in the file licenses/APL.txt.
|
|
9
|
+
|
|
1
10
|
export * as migrate from "@/migrate/migrate";
|
|
@@ -1,79 +1,90 @@
|
|
|
1
|
+
// Copyright 2024 Synnax Labs, Inc.
|
|
2
|
+
//
|
|
3
|
+
// Use of this software is governed by the Business Source License included in the file
|
|
4
|
+
// licenses/BSL.txt.
|
|
5
|
+
//
|
|
6
|
+
// As of the Change Date specified in that file, in accordance with the Business Source
|
|
7
|
+
// License, use of this software will be governed by the Apache License, Version 2.0,
|
|
8
|
+
// included in the file licenses/APL.txt.
|
|
9
|
+
|
|
1
10
|
import { describe, expect, it } from "vitest";
|
|
2
11
|
import { z } from "zod";
|
|
3
12
|
|
|
4
|
-
import {
|
|
5
|
-
type Migration,
|
|
6
|
-
migratable,
|
|
7
|
-
migrator,
|
|
8
|
-
type Migrations,
|
|
9
|
-
} from "@/migrate/migrate";
|
|
13
|
+
import { migrate } from "@/migrate";
|
|
10
14
|
|
|
11
|
-
const
|
|
15
|
+
const entityV0 = z.object({
|
|
16
|
+
version: z.literal("0.0.0"),
|
|
12
17
|
name: z.string(),
|
|
13
18
|
});
|
|
14
19
|
|
|
15
|
-
type
|
|
20
|
+
type EntityV0 = z.infer<typeof entityV0>;
|
|
16
21
|
|
|
17
|
-
const
|
|
22
|
+
const entityV1 = z.object({
|
|
23
|
+
version: z.literal("1.0.0"),
|
|
18
24
|
title: z.string(),
|
|
19
25
|
});
|
|
20
26
|
|
|
21
|
-
|
|
27
|
+
const migrateV1 = migrate.createMigration<EntityV0, EntityV1>({
|
|
28
|
+
name: "entity",
|
|
29
|
+
inputSchema: entityV0,
|
|
30
|
+
outputSchema: entityV1,
|
|
31
|
+
migrate: (entity) => {
|
|
32
|
+
const { name, ...rest } = entity;
|
|
33
|
+
return { ...rest, version: "1.0.0", title: entity.name };
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
type EntityV1 = z.infer<typeof entityV1>;
|
|
22
38
|
|
|
23
|
-
const
|
|
39
|
+
const entityV2 = z.object({
|
|
40
|
+
version: z.literal("2.0.0"),
|
|
24
41
|
title: z.string(),
|
|
25
42
|
description: z.string(),
|
|
26
43
|
});
|
|
27
44
|
|
|
28
|
-
type
|
|
45
|
+
type EntityV2 = z.infer<typeof entityV2>;
|
|
29
46
|
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
"0.0
|
|
40
|
-
return {
|
|
41
|
-
...entity,
|
|
42
|
-
version: "0.0.2",
|
|
43
|
-
description: "",
|
|
44
|
-
};
|
|
45
|
-
},
|
|
47
|
+
const migrateV2 = migrate.createMigration<EntityV1, EntityV2>({
|
|
48
|
+
name: "entity",
|
|
49
|
+
inputSchema: entityV1,
|
|
50
|
+
outputSchema: entityV2,
|
|
51
|
+
migrate: (entity) => ({ ...entity, version: "2.0.0", description: "" }),
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const migrations: migrate.Migrations = {
|
|
55
|
+
"0.0.0": migrateV1,
|
|
56
|
+
"1.0.0": migrateV2,
|
|
46
57
|
};
|
|
47
58
|
|
|
48
59
|
describe("migrator", () => {
|
|
49
|
-
it("should migrate an entity from v0
|
|
50
|
-
const entity:
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
description: "",
|
|
59
|
-
});
|
|
60
|
+
it("should migrate an entity from v0 to v2", () => {
|
|
61
|
+
const entity: EntityV0 = { version: "0.0.0", name: "foo" };
|
|
62
|
+
const DEFAULT: EntityV2 = { version: "2.0.0", title: "", description: "" };
|
|
63
|
+
const migrated = migrate.migrator({
|
|
64
|
+
name: "entity",
|
|
65
|
+
migrations,
|
|
66
|
+
def: DEFAULT,
|
|
67
|
+
})(entity);
|
|
68
|
+
expect(migrated).toEqual({ version: "2.0.0", title: "foo", description: "" });
|
|
60
69
|
});
|
|
61
|
-
it("should
|
|
62
|
-
const entity:
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
70
|
+
it("should migrate an entity from v1 to v2", () => {
|
|
71
|
+
const entity: EntityV1 = { version: "1.0.0", title: "foo" };
|
|
72
|
+
const DEFAULT: EntityV2 = { version: "2.0.0", title: "", description: "" };
|
|
73
|
+
const migrated = migrate.migrator({
|
|
74
|
+
name: "entity",
|
|
75
|
+
migrations,
|
|
76
|
+
def: DEFAULT,
|
|
77
|
+
})(entity);
|
|
78
|
+
expect(migrated).toEqual({ version: "2.0.0", title: "foo", description: "" });
|
|
69
79
|
});
|
|
70
|
-
it("should not migrate an entity from
|
|
71
|
-
const entity = {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
80
|
+
it("should not migrate an entity from v2 to v2", () => {
|
|
81
|
+
const entity: EntityV2 = { version: "2.0.0", title: "foo", description: "bar" };
|
|
82
|
+
const DEFAULT: EntityV2 = { version: "2.0.0", title: "", description: "" };
|
|
83
|
+
const migrated = migrate.migrator({
|
|
84
|
+
name: "entity",
|
|
85
|
+
migrations,
|
|
86
|
+
def: DEFAULT,
|
|
87
|
+
})(entity);
|
|
77
88
|
expect(migrated).toEqual(entity);
|
|
78
89
|
});
|
|
79
90
|
});
|
package/src/migrate/migrate.ts
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
// Copyright 2024 Synnax Labs, Inc.
|
|
2
|
+
//
|
|
3
|
+
// Use of this software is governed by the Business Source License included in the file
|
|
4
|
+
// licenses/BSL.txt.
|
|
5
|
+
//
|
|
6
|
+
// As of the Change Date specified in that file, in accordance with the Business Source
|
|
7
|
+
// License, use of this software will be governed by the Apache License, Version 2.0,
|
|
8
|
+
// included in the file licenses/APL.txt.
|
|
9
|
+
|
|
1
10
|
import { z } from "zod";
|
|
2
11
|
|
|
3
12
|
import { compare } from "@/compare";
|
|
@@ -6,6 +15,15 @@ export const semVerZ = z.string().regex(/^\d+\.\d+\.\d+$/);
|
|
|
6
15
|
|
|
7
16
|
export type SemVer = z.infer<typeof semVerZ>;
|
|
8
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Compares the two semantic versions.
|
|
20
|
+
*
|
|
21
|
+
* @param a The first semantic version.
|
|
22
|
+
* @param b The second semantic version.
|
|
23
|
+
* @returns a number, where the the number is compare.LESS_THAN (negative) if a is OLDER
|
|
24
|
+
* than B, compare.EQUAL (0) if a is the same as b, and compare.GREATER_THAN (positive)
|
|
25
|
+
* if a is NEWER than b.
|
|
26
|
+
*/
|
|
9
27
|
const compareSemVer: compare.CompareF<string> = (a, b) => {
|
|
10
28
|
const semA = semVerZ.parse(a);
|
|
11
29
|
const semB = semVerZ.parse(b);
|
|
@@ -16,32 +34,123 @@ const compareSemVer: compare.CompareF<string> = (a, b) => {
|
|
|
16
34
|
return aPatch - bPatch;
|
|
17
35
|
};
|
|
18
36
|
|
|
37
|
+
/**
|
|
38
|
+
* @returns true if the first semantic version is newer than the second.
|
|
39
|
+
* @param a The first semantic version.
|
|
40
|
+
* @param b The second semantic version.
|
|
41
|
+
*/
|
|
19
42
|
const semVerNewer = (a: SemVer, b: SemVer): boolean =>
|
|
20
43
|
compare.isGreaterThan(compareSemVer(a, b));
|
|
21
44
|
|
|
22
|
-
export
|
|
23
|
-
|
|
24
|
-
|
|
45
|
+
export type Migratable<V extends string = string> = { version: V };
|
|
46
|
+
|
|
47
|
+
export type Migration<I extends Migratable, O extends Migratable> = (input: I) => O;
|
|
25
48
|
|
|
26
|
-
export interface
|
|
49
|
+
export interface MigrationProps<
|
|
50
|
+
I extends Migratable,
|
|
51
|
+
O extends Migratable,
|
|
52
|
+
ZI extends z.ZodTypeAny,
|
|
53
|
+
ZO extends z.ZodTypeAny,
|
|
54
|
+
> {
|
|
55
|
+
name: string;
|
|
56
|
+
inputSchema?: ZI;
|
|
57
|
+
outputSchema?: ZO;
|
|
58
|
+
migrate: Migration<I, O>;
|
|
59
|
+
}
|
|
27
60
|
|
|
28
|
-
export
|
|
29
|
-
|
|
30
|
-
|
|
61
|
+
export const createMigration =
|
|
62
|
+
<
|
|
63
|
+
I extends Migratable,
|
|
64
|
+
O extends Migratable,
|
|
65
|
+
ZI extends z.ZodTypeAny = z.ZodTypeAny,
|
|
66
|
+
ZO extends z.ZodTypeAny = z.ZodTypeAny,
|
|
67
|
+
>({
|
|
68
|
+
name,
|
|
69
|
+
migrate,
|
|
70
|
+
}: MigrationProps<I, O, ZI, ZO>): Migration<I, O> =>
|
|
71
|
+
(input: I): O => {
|
|
72
|
+
try {
|
|
73
|
+
const out = migrate(input);
|
|
74
|
+
console.log(`${name} migrated: ${input.version} -> ${out.version}`);
|
|
75
|
+
return out;
|
|
76
|
+
} catch (e) {
|
|
77
|
+
console.log(`${name} failed to migrate from ${input.version}`);
|
|
78
|
+
console.error(e);
|
|
79
|
+
throw e;
|
|
80
|
+
}
|
|
81
|
+
};
|
|
31
82
|
|
|
83
|
+
/**
|
|
84
|
+
* A record of migrations to be applied, where the key of the record is the
|
|
85
|
+
* input version of the migration.
|
|
86
|
+
*/
|
|
32
87
|
export type Migrations = Record<string, Migration<any, any>>;
|
|
33
88
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
89
|
+
interface MigratorProps<O extends Migratable, ZO extends z.ZodTypeAny = z.ZodTypeAny> {
|
|
90
|
+
name: string;
|
|
91
|
+
migrations: Migrations;
|
|
92
|
+
def: O;
|
|
93
|
+
targetSchema?: ZO;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export const migrator = <O extends Migratable, ZO extends z.ZodTypeAny = z.ZodTypeAny>({
|
|
97
|
+
name,
|
|
98
|
+
migrations,
|
|
99
|
+
targetSchema,
|
|
100
|
+
def,
|
|
101
|
+
}: MigratorProps<O, ZO>): ((v: Migratable) => O) => {
|
|
102
|
+
const latestMigrationVersion = Object.keys(migrations).sort(compareSemVer).pop();
|
|
103
|
+
if (latestMigrationVersion == null)
|
|
104
|
+
return (v: Migratable) => {
|
|
105
|
+
if (v.version !== def.version) {
|
|
106
|
+
console.log(
|
|
107
|
+
`${name} version ${v.version} is newer than latest version of ${def.version}.
|
|
108
|
+
Returning default instead.
|
|
109
|
+
`,
|
|
110
|
+
);
|
|
111
|
+
return def;
|
|
112
|
+
}
|
|
113
|
+
try {
|
|
114
|
+
if (targetSchema != null) return targetSchema.parse(v);
|
|
115
|
+
return v;
|
|
116
|
+
} catch (e) {
|
|
117
|
+
console.log(`${name} failed to parse default. Exiting with default`);
|
|
118
|
+
console.error(e);
|
|
119
|
+
return def;
|
|
120
|
+
}
|
|
121
|
+
};
|
|
38
122
|
const migLength = Object.keys(migrations).length;
|
|
123
|
+
let migrationApplied = false;
|
|
39
124
|
const f = (old: Migratable): Migratable => {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
125
|
+
try {
|
|
126
|
+
if (migLength === 0 || semVerNewer(old.version, latestMigrationVersion)) {
|
|
127
|
+
if (migrationApplied) console.log(`${name} ${old.version} now up to date`);
|
|
128
|
+
else
|
|
129
|
+
console.log(
|
|
130
|
+
`${name} version ${old.version} is up to date with target version ${def.version}`,
|
|
131
|
+
);
|
|
132
|
+
return old;
|
|
133
|
+
}
|
|
134
|
+
const version = old.version;
|
|
135
|
+
const migrate = migrations[version];
|
|
136
|
+
const new_: Migratable = migrate(old);
|
|
137
|
+
migrationApplied = true;
|
|
138
|
+
return f(new_);
|
|
139
|
+
} catch (e) {
|
|
140
|
+
console.log(
|
|
141
|
+
`${name} failed to migrate from ${old.version} to ${latestMigrationVersion}`,
|
|
142
|
+
);
|
|
143
|
+
console.error(e);
|
|
144
|
+
return def;
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
return (v: Migratable): O => {
|
|
148
|
+
try {
|
|
149
|
+
return f(v) as O;
|
|
150
|
+
} catch (e) {
|
|
151
|
+
console.log(`${name} failed to parse final result. Exiting with default`);
|
|
152
|
+
console.error(e);
|
|
153
|
+
return def;
|
|
154
|
+
}
|
|
45
155
|
};
|
|
46
|
-
return f as unknown as Migration<I, O>;
|
|
47
156
|
};
|
|
@@ -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,9 +7,9 @@
|
|
|
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 {
|
|
10
|
+
import { type Mock,vi } from "vitest";
|
|
11
11
|
|
|
12
|
-
import { GLBufferController } from "@/telem/gl";
|
|
12
|
+
import { type GLBufferController } from "@/telem/gl";
|
|
13
13
|
|
|
14
14
|
export class MockGLBufferController implements GLBufferController {
|
|
15
15
|
ARRAY_BUFFER: number = 1;
|
|
@@ -27,7 +27,7 @@ export class MockGLBufferController implements GLBufferController {
|
|
|
27
27
|
deleteBufferMock: Mock<[WebGLBuffer | null]> = vi.fn();
|
|
28
28
|
|
|
29
29
|
deleteBuffer(buffer: WebGLBuffer | null): void {
|
|
30
|
-
|
|
30
|
+
|
|
31
31
|
if (buffer != null) delete this.buffers[buffer as number];
|
|
32
32
|
this.deleteBufferMock(buffer);
|
|
33
33
|
}
|
|
@@ -42,13 +42,13 @@ export class MockGLBufferController implements GLBufferController {
|
|
|
42
42
|
bufferData(
|
|
43
43
|
target: number,
|
|
44
44
|
dataOrSize: ArrayBufferLike | number,
|
|
45
|
-
usage: number
|
|
45
|
+
usage: number,
|
|
46
46
|
): void {
|
|
47
47
|
if (typeof dataOrSize === "number")
|
|
48
48
|
this.buffers[this.targets[target]] = new ArrayBuffer(dataOrSize);
|
|
49
49
|
else this.buffers[this.targets[target]] = dataOrSize;
|
|
50
50
|
|
|
51
|
-
this.bufferDataMock(target, dataOrSize
|
|
51
|
+
this.bufferDataMock(target, dataOrSize, usage);
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
bindBuffer(target: number, buffer: WebGLBuffer | null): void {
|
package/src/mock/index.ts
CHANGED
package/src/observe/index.ts
CHANGED
package/src/observe/observe.ts
CHANGED
|
@@ -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.
|
|
@@ -15,19 +15,50 @@ export interface Observable<T> {
|
|
|
15
15
|
onChange: (handler: Handler<T>) => Destructor;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
export
|
|
19
|
-
|
|
18
|
+
export interface ObservableAsyncCloseable<T> extends Observable<T> {
|
|
19
|
+
close: () => Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type Transform<I, O> = (value: I) => [O, true] | [O | null, false];
|
|
23
|
+
|
|
24
|
+
export class Observer<I, O = I> implements Observable<O> {
|
|
25
|
+
private readonly handlers: Map<Handler<O>, null>;
|
|
26
|
+
private readonly transform?: Transform<I, O>;
|
|
27
|
+
|
|
28
|
+
constructor(transform?: Transform<I, O>, handlers?: Map<Handler<O>, null>) {
|
|
29
|
+
this.transform = transform;
|
|
30
|
+
this.handlers = handlers ?? new Map();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
onChange(handler: Handler<O>): Destructor {
|
|
34
|
+
this.handlers.set(handler, null);
|
|
35
|
+
return () => this.handlers.delete(handler);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
notify(value: I): void {
|
|
39
|
+
let newValue: O = value as unknown as O;
|
|
40
|
+
if (this.transform != null) {
|
|
41
|
+
const [nv, changed] = this.transform(value);
|
|
42
|
+
if (!changed) return;
|
|
43
|
+
newValue = nv;
|
|
44
|
+
}
|
|
45
|
+
this.handlers.forEach((_, handler) => handler(newValue));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export class BaseObserver<V> implements Observable<V> {
|
|
50
|
+
private readonly handlers: Map<Handler<V>, null>;
|
|
20
51
|
|
|
21
|
-
constructor(handlers?: Map<Handler<
|
|
52
|
+
constructor(handlers?: Map<Handler<V>, null>) {
|
|
22
53
|
this.handlers = handlers ?? new Map();
|
|
23
54
|
}
|
|
24
55
|
|
|
25
|
-
onChange(handler: Handler<
|
|
56
|
+
onChange(handler: Handler<V>): Destructor {
|
|
26
57
|
this.handlers.set(handler, null);
|
|
27
58
|
return () => this.handlers.delete(handler);
|
|
28
59
|
}
|
|
29
60
|
|
|
30
|
-
notify(value:
|
|
61
|
+
notify(value: V): void {
|
|
31
62
|
this.handlers.forEach((_, handler) => handler(value));
|
|
32
63
|
}
|
|
33
64
|
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// Copyright 2024 Synnax Labs, Inc.
|
|
2
|
+
//
|
|
3
|
+
// Use of this software is governed by the Business Source License included in the file
|
|
4
|
+
// licenses/BSL.txt.
|
|
5
|
+
//
|
|
6
|
+
// As of the Change Date specified in that file, in accordance with the Business Source
|
|
7
|
+
// License, use of this software will be governed by the Apache License, Version 2.0,
|
|
8
|
+
// included in the file licenses/APL.txt.
|
|
9
|
+
|
|
10
|
+
import { describe, expect, it } from "vitest";
|
|
11
|
+
|
|
12
|
+
import { observe } from "@/observe";
|
|
13
|
+
|
|
14
|
+
describe("observe", () => {
|
|
15
|
+
describe("Observer", () => {
|
|
16
|
+
it("should correctly notify the receives of values", () => {
|
|
17
|
+
const observer = new observe.Observer<number>();
|
|
18
|
+
const values: number[] = [];
|
|
19
|
+
observer.onChange((value) => values.push(value));
|
|
20
|
+
observer.notify(1);
|
|
21
|
+
observer.notify(2);
|
|
22
|
+
expect(values).toEqual([1, 2]);
|
|
23
|
+
});
|
|
24
|
+
it("should stop notifying a handler after the destructor is called", () => {
|
|
25
|
+
const observer = new observe.Observer<number>();
|
|
26
|
+
const values: number[] = [];
|
|
27
|
+
const destructor = observer.onChange((value) => values.push(value));
|
|
28
|
+
observer.notify(1);
|
|
29
|
+
destructor();
|
|
30
|
+
observer.notify(2);
|
|
31
|
+
expect(values).toEqual([1]);
|
|
32
|
+
});
|
|
33
|
+
it("should correctly transform an observed value", () => {
|
|
34
|
+
const observer = new observe.Observer<number, string>((value) => [
|
|
35
|
+
value.toString(),
|
|
36
|
+
true,
|
|
37
|
+
]);
|
|
38
|
+
const values: string[] = [];
|
|
39
|
+
observer.onChange((value) => values.push(value));
|
|
40
|
+
observer.notify(1);
|
|
41
|
+
observer.notify(2);
|
|
42
|
+
expect(values).toEqual(["1", "2"]);
|
|
43
|
+
});
|
|
44
|
+
it("should not notify when the transform returns false", () => {
|
|
45
|
+
const observer = new observe.Observer<number, string>((value) => [
|
|
46
|
+
value.toString(),
|
|
47
|
+
false,
|
|
48
|
+
]);
|
|
49
|
+
const values: string[] = [];
|
|
50
|
+
observer.onChange((value) => values.push(value));
|
|
51
|
+
observer.notify(1);
|
|
52
|
+
observer.notify(2);
|
|
53
|
+
expect(values).toEqual([]);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
});
|
package/src/optional.ts
CHANGED
|
@@ -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.
|
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
|
|
10
10
|
export type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;
|
|
11
11
|
|
|
12
|
-
|
|
13
12
|
export type Required<T> = {
|
|
14
|
-
|
|
15
|
-
};
|
|
13
|
+
[P in keyof T]-?: T[P];
|
|
14
|
+
};
|
package/src/primitive.ts
CHANGED
package/src/record.ts
CHANGED
|
@@ -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.
|
|
@@ -11,18 +11,22 @@ import { z } from "zod";
|
|
|
11
11
|
|
|
12
12
|
export type Key = string | number | symbol;
|
|
13
13
|
|
|
14
|
-
export type UnknownRecord =
|
|
14
|
+
export type UnknownRecord = Record<Key, unknown>;
|
|
15
15
|
|
|
16
|
-
export
|
|
16
|
+
export interface Keyed<K extends Key> {
|
|
17
|
+
key: K;
|
|
18
|
+
}
|
|
17
19
|
|
|
18
20
|
export const unknownRecordZ = z.record(
|
|
19
21
|
z.union([z.number(), z.string(), z.symbol()]),
|
|
20
22
|
z.unknown(),
|
|
21
23
|
);
|
|
22
24
|
|
|
23
|
-
export type Entries<T> =
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
export type Entries<T> = Array<
|
|
26
|
+
{
|
|
27
|
+
[K in keyof T]: [K, T[K]];
|
|
28
|
+
}[keyof T]
|
|
29
|
+
>;
|
|
26
30
|
|
|
27
31
|
export const getEntries = <T extends Record<Key, unknown>>(obj: T): Entries<T> =>
|
|
28
32
|
Object.entries(obj) as Entries<T>;
|
package/src/renderable.ts
CHANGED
package/src/runtime/detect.ts
CHANGED
|
@@ -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.
|
|
@@ -17,14 +17,14 @@ export type Runtime = "browser" | "node" | "webworker";
|
|
|
17
17
|
*/
|
|
18
18
|
export const detect = (): Runtime => {
|
|
19
19
|
if (
|
|
20
|
-
|
|
20
|
+
|
|
21
21
|
typeof process !== "undefined" &&
|
|
22
22
|
process.versions != null &&
|
|
23
23
|
process.versions.node != null
|
|
24
24
|
)
|
|
25
25
|
return "node";
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
|
|
28
28
|
if (typeof window === "undefined" || window.document === undefined)
|
|
29
29
|
return "webworker";
|
|
30
30
|
|
package/src/runtime/external.ts
CHANGED