@ixfx/components 0.2.4 → 0.2.6
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/bundle/index.d.ts +285 -159
- package/bundle/index.d.ts.map +1 -1
- package/bundle/index.js +3291 -2485
- package/bundle/index.js.map +1 -1
- package/dist/ac-text.d.ts +96 -0
- package/dist/ac-text.d.ts.map +1 -0
- package/dist/ac-text.js +484 -0
- package/dist/ac-text.js.map +1 -0
- package/dist/{button/button-styles.js → button-B9ztaKyl.js} +49 -3
- package/dist/button-B9ztaKyl.js.map +1 -0
- package/dist/button.d.ts +20 -0
- package/dist/button.d.ts.map +1 -0
- package/dist/button.js +3 -0
- package/dist/checkbox.d.ts +26 -57
- package/dist/checkbox.d.ts.map +1 -1
- package/dist/checkbox.js +74 -88
- package/dist/checkbox.js.map +1 -1
- package/dist/chunk-pbuEa-1d.js +13 -0
- package/dist/colour-C3MQIjFJ-BJV-QC-3.js +4138 -0
- package/dist/colour-C3MQIjFJ-BJV-QC-3.js.map +1 -0
- package/dist/colour-picker-BNqDz4wK.js +922 -0
- package/dist/colour-picker-BNqDz4wK.js.map +1 -0
- package/dist/colour-picker.d.ts +2 -0
- package/dist/colour-picker.js +2 -0
- package/dist/crumbs.d.ts +91 -0
- package/dist/crumbs.d.ts.map +1 -0
- package/dist/crumbs.js +789 -0
- package/dist/crumbs.js.map +1 -0
- package/dist/data-display.d.ts +22 -18
- package/dist/data-display.d.ts.map +1 -1
- package/dist/data-display.js +81 -108
- package/dist/data-display.js.map +1 -1
- package/dist/decorate-O4m1U4l3.js +25 -0
- package/dist/decorate-O4m1U4l3.js.map +1 -0
- package/dist/defaults-FEZaGiYZ.js +38 -0
- package/dist/defaults-FEZaGiYZ.js.map +1 -0
- package/dist/dist-By5URG0Y.js +1290 -0
- package/dist/dist-By5URG0Y.js.map +1 -0
- package/dist/dist-D7kJgnSE.js +1039 -0
- package/dist/dist-D7kJgnSE.js.map +1 -0
- package/dist/editable-label.d.ts +71 -0
- package/dist/editable-label.d.ts.map +1 -0
- package/dist/editable-label.js +279 -0
- package/dist/editable-label.js.map +1 -0
- package/dist/hex-editor-2_s0Ua5t.d.ts +130 -0
- package/dist/hex-editor-2_s0Ua5t.d.ts.map +1 -0
- package/dist/hex-editor-gH3mteMr.js +1147 -0
- package/dist/hex-editor-gH3mteMr.js.map +1 -0
- package/dist/hex.d.ts +2 -0
- package/dist/hex.js +2 -0
- package/dist/highlight-CAjwQ4GE.js +50 -0
- package/dist/highlight-CAjwQ4GE.js.map +1 -0
- package/dist/icon-CYACf6o8.js +100 -0
- package/dist/icon-CYACf6o8.js.map +1 -0
- package/dist/icon-CeTDJhC7.d.ts +35 -0
- package/dist/icon-CeTDJhC7.d.ts.map +1 -0
- package/dist/icons.d.ts +3 -0
- package/dist/icons.js +9 -0
- package/dist/icons.js.map +1 -0
- package/dist/incr-search-BZawvrfl.js +311 -0
- package/dist/incr-search-BZawvrfl.js.map +1 -0
- package/dist/incr-search.d.ts +2 -0
- package/dist/incr-search.js +3 -0
- package/dist/index-B1hNR7Z9.d.ts +36 -0
- package/dist/index-B1hNR7Z9.d.ts.map +1 -0
- package/dist/index-CnL9krsH.d.ts +1238 -0
- package/dist/index-CnL9krsH.d.ts.map +1 -0
- package/dist/index-CwGkb9s1.d.ts +395 -0
- package/dist/index-CwGkb9s1.d.ts.map +1 -0
- package/dist/index-DrQjA8Gs.d.ts +22 -0
- package/dist/index-DrQjA8Gs.d.ts.map +1 -0
- package/dist/index-V2cJorlA.d.ts +160 -0
- package/dist/index-V2cJorlA.d.ts.map +1 -0
- package/dist/index-kY5gxbkI.d.ts +182 -0
- package/dist/index-kY5gxbkI.d.ts.map +1 -0
- package/dist/index.d.ts +540 -53
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6519 -54
- package/dist/index.js.map +1 -1
- package/dist/interaction-CQDQJf2Q.js +1 -0
- package/dist/keyboard-De_vOHLg.js +20 -0
- package/dist/keyboard-De_vOHLg.js.map +1 -0
- package/dist/labelled-input-base-BvgH7ldm.js +155 -0
- package/dist/labelled-input-base-BvgH7ldm.js.map +1 -0
- package/dist/labelled-input-base-D-Y7agky.d.ts +42 -0
- package/dist/labelled-input-base-D-Y7agky.d.ts.map +1 -0
- package/dist/labelled-radial-input.d.ts +33 -0
- package/dist/labelled-radial-input.d.ts.map +1 -0
- package/dist/labelled-radial-input.js +188 -0
- package/dist/labelled-radial-input.js.map +1 -0
- package/dist/labelled-range-input.d.ts +2 -0
- package/dist/{labelled-range-input/labelled-range-input.js → labelled-range-input.js} +40 -45
- package/dist/labelled-range-input.js.map +1 -0
- package/dist/led.d.ts +20 -16
- package/dist/led.d.ts.map +1 -1
- package/dist/led.js +71 -79
- package/dist/led.js.map +1 -1
- package/dist/menu-C3eANB5M.js +813 -0
- package/dist/menu-C3eANB5M.js.map +1 -0
- package/dist/menu-item-6IU5weHi.js +766 -0
- package/dist/menu-item-6IU5weHi.js.map +1 -0
- package/dist/menu-item-ClQF2DKN.d.ts +127 -0
- package/dist/menu-item-ClQF2DKN.d.ts.map +1 -0
- package/dist/menu.d.ts +3 -0
- package/dist/menu.js +3 -0
- package/dist/miller.d.ts +323 -0
- package/dist/miller.d.ts.map +1 -0
- package/dist/miller.js +1343 -0
- package/dist/miller.js.map +1 -0
- package/dist/narrowed-text.d.ts +71 -0
- package/dist/narrowed-text.d.ts.map +1 -0
- package/dist/narrowed-text.js +571 -0
- package/dist/narrowed-text.js.map +1 -0
- package/dist/panel.d.ts +42 -0
- package/dist/panel.d.ts.map +1 -0
- package/dist/{panel/panel.js → panel.js} +82 -91
- package/dist/panel.js.map +1 -0
- package/dist/plots.d.ts +2 -0
- package/dist/plots.js +2 -0
- package/dist/polar-pad.d.ts +66 -0
- package/dist/polar-pad.d.ts.map +1 -0
- package/dist/polar-pad.js +537 -0
- package/dist/polar-pad.js.map +1 -0
- package/dist/popup-Ddx9LCzY.js +24 -0
- package/dist/popup-Ddx9LCzY.js.map +1 -0
- package/dist/prominence-CreDBdCs.js +98 -0
- package/dist/prominence-CreDBdCs.js.map +1 -0
- package/dist/radial-input-Dbc6fgCK.js +849 -0
- package/dist/radial-input-Dbc6fgCK.js.map +1 -0
- package/dist/radial-input-LUSBEycd.d.ts +69 -0
- package/dist/radial-input-LUSBEycd.d.ts.map +1 -0
- package/dist/radial-input.d.ts +2 -0
- package/dist/radial-input.js +2 -0
- package/dist/range-input.d.ts +42 -0
- package/dist/range-input.d.ts.map +1 -0
- package/dist/{range-input/range-input.js → range-input.js} +155 -168
- package/dist/range-input.js.map +1 -0
- package/dist/range.d.ts +27 -0
- package/dist/range.d.ts.map +1 -0
- package/dist/range.js +136 -0
- package/dist/range.js.map +1 -0
- package/dist/registry-CZEB1YI9.js +21 -0
- package/dist/registry-CZEB1YI9.js.map +1 -0
- package/dist/selecthorizontal.d.ts +12 -8
- package/dist/selecthorizontal.d.ts.map +1 -1
- package/dist/selecthorizontal.js +20 -24
- package/dist/selecthorizontal.js.map +1 -1
- package/dist/snap-container.d.ts +49 -0
- package/dist/snap-container.d.ts.map +1 -0
- package/dist/snap-container.js +297 -0
- package/dist/snap-container.js.map +1 -0
- package/dist/{split-layout/split-layout.d.ts → split-layout.d.ts} +29 -25
- package/dist/split-layout.d.ts.map +1 -0
- package/dist/split-layout.js +545 -0
- package/dist/split-layout.js.map +1 -0
- package/dist/style.css +133 -0
- package/dist/swipe.d.ts +48 -0
- package/dist/swipe.d.ts.map +1 -0
- package/dist/swipe.js +204 -0
- package/dist/swipe.js.map +1 -0
- package/dist/tab-list-BnqISNvO.d.ts +65 -0
- package/dist/tab-list-BnqISNvO.d.ts.map +1 -0
- package/dist/tabs.d.ts +2 -0
- package/dist/tabs.js +203 -0
- package/dist/tabs.js.map +1 -0
- package/dist/tickled-controller-Cq1Va0rR.d.ts +218 -0
- package/dist/tickled-controller-Cq1Va0rR.d.ts.map +1 -0
- package/dist/tickled-styles-Bg3QbcrD.js +327 -0
- package/dist/tickled-styles-Bg3QbcrD.js.map +1 -0
- package/dist/timeline-B62Sz6J_.js +1748 -0
- package/dist/timeline-B62Sz6J_.js.map +1 -0
- package/dist/timeline.d.ts +2 -0
- package/dist/timeline.js +2 -0
- package/dist/tooltip-CwGfb4lp.d.ts +25 -0
- package/dist/tooltip-CwGfb4lp.d.ts.map +1 -0
- package/dist/{styles/tooltip.js → tooltip-DMxmBNky.js} +6 -2
- package/dist/tooltip-DMxmBNky.js.map +1 -0
- package/dist/tree-component-CQpoPo4s.d.ts +326 -0
- package/dist/tree-component-CQpoPo4s.d.ts.map +1 -0
- package/dist/tree-data-model-DGvRVOFY.js +190 -0
- package/dist/tree-data-model-DGvRVOFY.js.map +1 -0
- package/dist/tree.d.ts +99 -0
- package/dist/tree.d.ts.map +1 -0
- package/dist/tree.js +1144 -0
- package/dist/tree.js.map +1 -0
- package/dist/types-BKaqnpwx.d.ts +8 -0
- package/dist/types-BKaqnpwx.d.ts.map +1 -0
- package/dist/xy-axis-C7fNxDwY.js +6243 -0
- package/dist/xy-axis-C7fNxDwY.js.map +1 -0
- package/dist/xy-axis-D9uwpGTT.d.ts +140 -0
- package/dist/xy-axis-D9uwpGTT.d.ts.map +1 -0
- package/dist/xy-pad.d.ts +73 -110
- package/dist/xy-pad.d.ts.map +1 -1
- package/dist/xy-pad.js +300 -320
- package/dist/xy-pad.js.map +1 -1
- package/package.json +24 -28
- package/dist/ac-text/ac-text.d.ts +0 -99
- package/dist/ac-text/ac-text.d.ts.map +0 -1
- package/dist/ac-text/ac-text.js +0 -571
- package/dist/ac-text/ac-text.js.map +0 -1
- package/dist/button/button-styles.d.ts +0 -2
- package/dist/button/button-styles.d.ts.map +0 -1
- package/dist/button/button-styles.js.map +0 -1
- package/dist/button/button.d.ts +0 -16
- package/dist/button/button.d.ts.map +0 -1
- package/dist/button/button.js +0 -58
- package/dist/button/button.js.map +0 -1
- package/dist/button/radio-group.d.ts +0 -44
- package/dist/button/radio-group.d.ts.map +0 -1
- package/dist/button/radio-group.js +0 -385
- package/dist/button/radio-group.js.map +0 -1
- package/dist/button/split-button.d.ts +0 -59
- package/dist/button/split-button.d.ts.map +0 -1
- package/dist/button/split-button.js +0 -480
- package/dist/button/split-button.js.map +0 -1
- package/dist/button/types.d.ts +0 -18
- package/dist/button/types.d.ts.map +0 -1
- package/dist/button/types.js +0 -2
- package/dist/button/types.js.map +0 -1
- package/dist/colour-picker/colour-picker-popup.d.ts +0 -102
- package/dist/colour-picker/colour-picker-popup.d.ts.map +0 -1
- package/dist/colour-picker/colour-picker-popup.js +0 -399
- package/dist/colour-picker/colour-picker-popup.js.map +0 -1
- package/dist/colour-picker/colour-picker.d.ts +0 -100
- package/dist/colour-picker/colour-picker.d.ts.map +0 -1
- package/dist/colour-picker/colour-picker.js +0 -567
- package/dist/colour-picker/colour-picker.js.map +0 -1
- package/dist/colour-picker/index.d.ts +0 -4
- package/dist/colour-picker/index.d.ts.map +0 -1
- package/dist/colour-picker/index.js +0 -3
- package/dist/colour-picker/index.js.map +0 -1
- package/dist/colour-picker/styles.d.ts +0 -2
- package/dist/colour-picker/styles.d.ts.map +0 -1
- package/dist/colour-picker/styles.js +0 -139
- package/dist/colour-picker/styles.js.map +0 -1
- package/dist/colour-picker/types.d.ts +0 -33
- package/dist/colour-picker/types.d.ts.map +0 -1
- package/dist/colour-picker/types.js +0 -2
- package/dist/colour-picker/types.js.map +0 -1
- package/dist/colour-picker/util.d.ts +0 -15
- package/dist/colour-picker/util.d.ts.map +0 -1
- package/dist/colour-picker/util.js +0 -35
- package/dist/colour-picker/util.js.map +0 -1
- package/dist/common/searchable.d.ts +0 -9
- package/dist/common/searchable.d.ts.map +0 -1
- package/dist/common/searchable.js +0 -9
- package/dist/common/searchable.js.map +0 -1
- package/dist/common/tree-component.d.ts +0 -172
- package/dist/common/tree-component.d.ts.map +0 -1
- package/dist/common/tree-component.js +0 -8
- package/dist/common/tree-component.js.map +0 -1
- package/dist/common/tree-data-model.d.ts +0 -100
- package/dist/common/tree-data-model.d.ts.map +0 -1
- package/dist/common/tree-data-model.js +0 -207
- package/dist/common/tree-data-model.js.map +0 -1
- package/dist/common/tree-item.d.ts +0 -7
- package/dist/common/tree-item.d.ts.map +0 -1
- package/dist/common/tree-item.js +0 -2
- package/dist/common/tree-item.js.map +0 -1
- package/dist/common/types.d.ts +0 -69
- package/dist/common/types.d.ts.map +0 -1
- package/dist/common/types.js +0 -6
- package/dist/common/types.js.map +0 -1
- package/dist/crumbs/crumb-navigation.d.ts +0 -96
- package/dist/crumbs/crumb-navigation.d.ts.map +0 -1
- package/dist/crumbs/crumb-navigation.js +0 -911
- package/dist/crumbs/crumb-navigation.js.map +0 -1
- package/dist/crumbs/crumb-path-controller.d.ts +0 -18
- package/dist/crumbs/crumb-path-controller.d.ts.map +0 -1
- package/dist/crumbs/crumb-path-controller.js +0 -81
- package/dist/crumbs/crumb-path-controller.js.map +0 -1
- package/dist/crumbs/crumb-path.d.ts +0 -65
- package/dist/crumbs/crumb-path.d.ts.map +0 -1
- package/dist/crumbs/crumb-path.js +0 -691
- package/dist/crumbs/crumb-path.js.map +0 -1
- package/dist/editable-label/editable-label.d.ts +0 -98
- package/dist/editable-label/editable-label.d.ts.map +0 -1
- package/dist/editable-label/editable-label.js +0 -348
- package/dist/editable-label/editable-label.js.map +0 -1
- package/dist/editable-label/editable-number.d.ts +0 -96
- package/dist/editable-label/editable-number.d.ts.map +0 -1
- package/dist/editable-label/editable-number.js +0 -702
- package/dist/editable-label/editable-number.js.map +0 -1
- package/dist/hex/colour.d.ts +0 -6
- package/dist/hex/colour.d.ts.map +0 -1
- package/dist/hex/colour.js +0 -33
- package/dist/hex/colour.js.map +0 -1
- package/dist/hex/data.d.ts +0 -18
- package/dist/hex/data.d.ts.map +0 -1
- package/dist/hex/data.js +0 -61
- package/dist/hex/data.js.map +0 -1
- package/dist/hex/diff.d.ts +0 -14
- package/dist/hex/diff.d.ts.map +0 -1
- package/dist/hex/diff.js +0 -31
- package/dist/hex/diff.js.map +0 -1
- package/dist/hex/hex-editor.d.ts +0 -101
- package/dist/hex/hex-editor.d.ts.map +0 -1
- package/dist/hex/hex-editor.js +0 -894
- package/dist/hex/hex-editor.js.map +0 -1
- package/dist/hex/selection.d.ts +0 -11
- package/dist/hex/selection.d.ts.map +0 -1
- package/dist/hex/selection.js +0 -218
- package/dist/hex/selection.js.map +0 -1
- package/dist/hex/types.d.ts +0 -34
- package/dist/hex/types.d.ts.map +0 -1
- package/dist/hex/types.js +0 -4
- package/dist/hex/types.js.map +0 -1
- package/dist/icons/defaults.d.ts +0 -27
- package/dist/icons/defaults.d.ts.map +0 -1
- package/dist/icons/defaults.js +0 -34
- package/dist/icons/defaults.js.map +0 -1
- package/dist/icons/icon.d.ts +0 -31
- package/dist/icons/icon.d.ts.map +0 -1
- package/dist/icons/icon.js +0 -125
- package/dist/icons/icon.js.map +0 -1
- package/dist/icons/index.d.ts +0 -5
- package/dist/icons/index.d.ts.map +0 -1
- package/dist/icons/index.js +0 -6
- package/dist/icons/index.js.map +0 -1
- package/dist/icons/registry.d.ts +0 -11
- package/dist/icons/registry.d.ts.map +0 -1
- package/dist/icons/registry.js +0 -17
- package/dist/icons/registry.js.map +0 -1
- package/dist/incr-search/ac-adapter.d.ts +0 -18
- package/dist/incr-search/ac-adapter.d.ts.map +0 -1
- package/dist/incr-search/ac-adapter.js +0 -29
- package/dist/incr-search/ac-adapter.js.map +0 -1
- package/dist/incr-search/controller-miller.d.ts +0 -9
- package/dist/incr-search/controller-miller.d.ts.map +0 -1
- package/dist/incr-search/controller-miller.js +0 -8
- package/dist/incr-search/controller-miller.js.map +0 -1
- package/dist/incr-search/controller-tree.d.ts +0 -55
- package/dist/incr-search/controller-tree.d.ts.map +0 -1
- package/dist/incr-search/controller-tree.js +0 -106
- package/dist/incr-search/controller-tree.js.map +0 -1
- package/dist/incr-search/element-search.d.ts +0 -15
- package/dist/incr-search/element-search.d.ts.map +0 -1
- package/dist/incr-search/element-search.js +0 -82
- package/dist/incr-search/element-search.js.map +0 -1
- package/dist/incr-search/fuzzy.d.ts +0 -3
- package/dist/incr-search/fuzzy.d.ts.map +0 -1
- package/dist/incr-search/fuzzy.js +0 -37
- package/dist/incr-search/fuzzy.js.map +0 -1
- package/dist/incr-search/highlight.d.ts +0 -5
- package/dist/incr-search/highlight.d.ts.map +0 -1
- package/dist/incr-search/highlight.js +0 -54
- package/dist/incr-search/highlight.js.map +0 -1
- package/dist/incr-search/incr-search.d.ts +0 -3
- package/dist/incr-search/incr-search.d.ts.map +0 -1
- package/dist/incr-search/incr-search.js +0 -73
- package/dist/incr-search/incr-search.js.map +0 -1
- package/dist/incr-search/index.d.ts +0 -12
- package/dist/incr-search/index.d.ts.map +0 -1
- package/dist/incr-search/index.js +0 -8
- package/dist/incr-search/index.js.map +0 -1
- package/dist/incr-search/types.d.ts +0 -59
- package/dist/incr-search/types.d.ts.map +0 -1
- package/dist/incr-search/types.js +0 -2
- package/dist/incr-search/types.js.map +0 -1
- package/dist/interaction/index.d.ts +0 -10
- package/dist/interaction/index.d.ts.map +0 -1
- package/dist/interaction/index.js +0 -10
- package/dist/interaction/index.js.map +0 -1
- package/dist/interaction/tickled-controller.d.ts +0 -186
- package/dist/interaction/tickled-controller.d.ts.map +0 -1
- package/dist/interaction/tickled-controller.js +0 -256
- package/dist/interaction/tickled-controller.js.map +0 -1
- package/dist/interaction/tickled-styles.d.ts +0 -53
- package/dist/interaction/tickled-styles.d.ts.map +0 -1
- package/dist/interaction/tickled-styles.js +0 -106
- package/dist/interaction/tickled-styles.js.map +0 -1
- package/dist/interaction/tree-keyboard-controller.d.ts +0 -30
- package/dist/interaction/tree-keyboard-controller.d.ts.map +0 -1
- package/dist/interaction/tree-keyboard-controller.js +0 -105
- package/dist/interaction/tree-keyboard-controller.js.map +0 -1
- package/dist/keyboard.d.ts +0 -16
- package/dist/keyboard.d.ts.map +0 -1
- package/dist/keyboard.js +0 -22
- package/dist/keyboard.js.map +0 -1
- package/dist/labelled-radial-input/index.d.ts +0 -2
- package/dist/labelled-radial-input/index.d.ts.map +0 -1
- package/dist/labelled-radial-input/index.js +0 -2
- package/dist/labelled-radial-input/index.js.map +0 -1
- package/dist/labelled-radial-input/labelled-radial-input.d.ts +0 -77
- package/dist/labelled-radial-input/labelled-radial-input.d.ts.map +0 -1
- package/dist/labelled-radial-input/labelled-radial-input.js +0 -214
- package/dist/labelled-radial-input/labelled-radial-input.js.map +0 -1
- package/dist/labelled-range-input/index.d.ts +0 -2
- package/dist/labelled-range-input/index.d.ts.map +0 -1
- package/dist/labelled-range-input/index.js +0 -2
- package/dist/labelled-range-input/index.js.map +0 -1
- package/dist/labelled-range-input/labelled-range-input.d.ts +0 -80
- package/dist/labelled-range-input/labelled-range-input.d.ts.map +0 -1
- package/dist/labelled-range-input/labelled-range-input.js.map +0 -1
- package/dist/menu/index.d.ts +0 -14
- package/dist/menu/index.d.ts.map +0 -1
- package/dist/menu/index.js +0 -13
- package/dist/menu/index.js.map +0 -1
- package/dist/menu/menu-bar.d.ts +0 -23
- package/dist/menu/menu-bar.d.ts.map +0 -1
- package/dist/menu/menu-bar.js +0 -110
- package/dist/menu/menu-bar.js.map +0 -1
- package/dist/menu/menu-check-item.d.ts +0 -33
- package/dist/menu/menu-check-item.d.ts.map +0 -1
- package/dist/menu/menu-check-item.js +0 -175
- package/dist/menu/menu-check-item.js.map +0 -1
- package/dist/menu/menu-command-controller.d.ts +0 -14
- package/dist/menu/menu-command-controller.d.ts.map +0 -1
- package/dist/menu/menu-command-controller.js +0 -22
- package/dist/menu/menu-command-controller.js.map +0 -1
- package/dist/menu/menu-container.d.ts +0 -36
- package/dist/menu/menu-container.d.ts.map +0 -1
- package/dist/menu/menu-container.js +0 -351
- package/dist/menu/menu-container.js.map +0 -1
- package/dist/menu/menu-from-tree.d.ts +0 -17
- package/dist/menu/menu-from-tree.d.ts.map +0 -1
- package/dist/menu/menu-from-tree.js +0 -103
- package/dist/menu/menu-from-tree.js.map +0 -1
- package/dist/menu/menu-header.d.ts +0 -12
- package/dist/menu/menu-header.d.ts.map +0 -1
- package/dist/menu/menu-header.js +0 -36
- package/dist/menu/menu-header.js.map +0 -1
- package/dist/menu/menu-item.d.ts +0 -41
- package/dist/menu/menu-item.d.ts.map +0 -1
- package/dist/menu/menu-item.js +0 -240
- package/dist/menu/menu-item.js.map +0 -1
- package/dist/menu/menu-radio-group.d.ts +0 -24
- package/dist/menu/menu-radio-group.d.ts.map +0 -1
- package/dist/menu/menu-radio-group.js +0 -71
- package/dist/menu/menu-radio-group.js.map +0 -1
- package/dist/menu/menu-radio-item.d.ts +0 -22
- package/dist/menu/menu-radio-item.d.ts.map +0 -1
- package/dist/menu/menu-radio-item.js +0 -116
- package/dist/menu/menu-radio-item.js.map +0 -1
- package/dist/menu/menu-separator.d.ts +0 -11
- package/dist/menu/menu-separator.d.ts.map +0 -1
- package/dist/menu/menu-separator.js +0 -29
- package/dist/menu/menu-separator.js.map +0 -1
- package/dist/menu/menu-sub-trigger.d.ts +0 -46
- package/dist/menu/menu-sub-trigger.d.ts.map +0 -1
- package/dist/menu/menu-sub-trigger.js +0 -302
- package/dist/menu/menu-sub-trigger.js.map +0 -1
- package/dist/menu/menu-trigger.d.ts +0 -57
- package/dist/menu/menu-trigger.d.ts.map +0 -1
- package/dist/menu/menu-trigger.js +0 -351
- package/dist/menu/menu-trigger.js.map +0 -1
- package/dist/miller/index.d.ts +0 -5
- package/dist/miller/index.d.ts.map +0 -1
- package/dist/miller/index.js +0 -5
- package/dist/miller/index.js.map +0 -1
- package/dist/miller/miller-base.d.ts +0 -184
- package/dist/miller/miller-base.d.ts.map +0 -1
- package/dist/miller/miller-base.js +0 -1249
- package/dist/miller/miller-base.js.map +0 -1
- package/dist/miller/miller-list.d.ts +0 -30
- package/dist/miller/miller-list.d.ts.map +0 -1
- package/dist/miller/miller-list.js +0 -192
- package/dist/miller/miller-list.js.map +0 -1
- package/dist/miller/miller-tree-controller.d.ts +0 -58
- package/dist/miller/miller-tree-controller.d.ts.map +0 -1
- package/dist/miller/miller-tree-controller.js +0 -134
- package/dist/miller/miller-tree-controller.js.map +0 -1
- package/dist/miller/types.d.ts +0 -63
- package/dist/miller/types.d.ts.map +0 -1
- package/dist/miller/types.js +0 -6
- package/dist/miller/types.js.map +0 -1
- package/dist/mixins/labelled-input-base.d.ts +0 -38
- package/dist/mixins/labelled-input-base.d.ts.map +0 -1
- package/dist/mixins/labelled-input-base.js +0 -171
- package/dist/mixins/labelled-input-base.js.map +0 -1
- package/dist/mixins/labelled-input-util.d.ts +0 -3
- package/dist/mixins/labelled-input-util.d.ts.map +0 -1
- package/dist/mixins/labelled-input-util.js +0 -10
- package/dist/mixins/labelled-input-util.js.map +0 -1
- package/dist/my-element.d.ts +0 -14
- package/dist/my-element.d.ts.map +0 -1
- package/dist/my-element.js +0 -44
- package/dist/my-element.js.map +0 -1
- package/dist/narrowed-text/index.d.ts +0 -3
- package/dist/narrowed-text/index.d.ts.map +0 -1
- package/dist/narrowed-text/index.js +0 -3
- package/dist/narrowed-text/index.js.map +0 -1
- package/dist/narrowed-text/narrowed-text.d.ts +0 -48
- package/dist/narrowed-text/narrowed-text.d.ts.map +0 -1
- package/dist/narrowed-text/narrowed-text.js +0 -668
- package/dist/narrowed-text/narrowed-text.js.map +0 -1
- package/dist/narrowed-text/types.d.ts +0 -20
- package/dist/narrowed-text/types.d.ts.map +0 -1
- package/dist/narrowed-text/types.js +0 -2
- package/dist/narrowed-text/types.js.map +0 -1
- package/dist/panel/panel-group.d.ts +0 -23
- package/dist/panel/panel-group.d.ts.map +0 -1
- package/dist/panel/panel-group.js +0 -109
- package/dist/panel/panel-group.js.map +0 -1
- package/dist/panel/panel.d.ts +0 -39
- package/dist/panel/panel.d.ts.map +0 -1
- package/dist/panel/panel.js.map +0 -1
- package/dist/plots/colour-map.d.ts +0 -31
- package/dist/plots/colour-map.d.ts.map +0 -1
- package/dist/plots/colour-map.js +0 -133
- package/dist/plots/colour-map.js.map +0 -1
- package/dist/plots/data.d.ts +0 -27
- package/dist/plots/data.d.ts.map +0 -1
- package/dist/plots/data.js +0 -47
- package/dist/plots/data.js.map +0 -1
- package/dist/plots/single-axis.d.ts +0 -41
- package/dist/plots/single-axis.d.ts.map +0 -1
- package/dist/plots/single-axis.js +0 -428
- package/dist/plots/single-axis.js.map +0 -1
- package/dist/plots/svg-utils.d.ts +0 -12
- package/dist/plots/svg-utils.d.ts.map +0 -1
- package/dist/plots/svg-utils.js +0 -64
- package/dist/plots/svg-utils.js.map +0 -1
- package/dist/plots/xy-axis.d.ts +0 -42
- package/dist/plots/xy-axis.d.ts.map +0 -1
- package/dist/plots/xy-axis.js +0 -307
- package/dist/plots/xy-axis.js.map +0 -1
- package/dist/polar-pad/polar-pad.d.ts +0 -132
- package/dist/polar-pad/polar-pad.d.ts.map +0 -1
- package/dist/polar-pad/polar-pad.js +0 -598
- package/dist/polar-pad/polar-pad.js.map +0 -1
- package/dist/radial-input/radial-input.d.ts +0 -45
- package/dist/radial-input/radial-input.d.ts.map +0 -1
- package/dist/radial-input/radial-input.js +0 -692
- package/dist/radial-input/radial-input.js.map +0 -1
- package/dist/radial-input/svg-utils.d.ts +0 -147
- package/dist/radial-input/svg-utils.d.ts.map +0 -1
- package/dist/radial-input/svg-utils.js +0 -346
- package/dist/radial-input/svg-utils.js.map +0 -1
- package/dist/radial-input/types.d.ts +0 -25
- package/dist/radial-input/types.d.ts.map +0 -1
- package/dist/radial-input/types.js +0 -5
- package/dist/radial-input/types.js.map +0 -1
- package/dist/range/range-multi.d.ts +0 -62
- package/dist/range/range-multi.d.ts.map +0 -1
- package/dist/range/range-multi.js +0 -652
- package/dist/range/range-multi.js.map +0 -1
- package/dist/range/range.d.ts +0 -23
- package/dist/range/range.d.ts.map +0 -1
- package/dist/range/range.js +0 -153
- package/dist/range/range.js.map +0 -1
- package/dist/range-input/index.d.ts +0 -2
- package/dist/range-input/index.d.ts.map +0 -1
- package/dist/range-input/index.js +0 -2
- package/dist/range-input/index.js.map +0 -1
- package/dist/range-input/range-input.d.ts +0 -92
- package/dist/range-input/range-input.d.ts.map +0 -1
- package/dist/range-input/range-input.js.map +0 -1
- package/dist/snap-container/snap-container.d.ts +0 -45
- package/dist/snap-container/snap-container.d.ts.map +0 -1
- package/dist/snap-container/snap-container.js +0 -352
- package/dist/snap-container/snap-container.js.map +0 -1
- package/dist/split-layout/split-layout.d.ts.map +0 -1
- package/dist/split-layout/split-layout.js +0 -674
- package/dist/split-layout/split-layout.js.map +0 -1
- package/dist/styles/popup.d.ts +0 -11
- package/dist/styles/popup.d.ts.map +0 -1
- package/dist/styles/popup.js +0 -20
- package/dist/styles/popup.js.map +0 -1
- package/dist/styles/prominence.d.ts +0 -58
- package/dist/styles/prominence.d.ts.map +0 -1
- package/dist/styles/prominence.js +0 -94
- package/dist/styles/prominence.js.map +0 -1
- package/dist/styles/tooltip.d.ts +0 -2
- package/dist/styles/tooltip.d.ts.map +0 -1
- package/dist/styles/tooltip.js.map +0 -1
- package/dist/svg-edit-label.d.ts +0 -2
- package/dist/svg-edit-label.d.ts.map +0 -1
- package/dist/svg-edit-label.js +0 -110
- package/dist/svg-edit-label.js.map +0 -1
- package/dist/swipe/index.d.ts +0 -2
- package/dist/swipe/index.d.ts.map +0 -1
- package/dist/swipe/index.js +0 -2
- package/dist/swipe/index.js.map +0 -1
- package/dist/swipe/swipe.d.ts +0 -65
- package/dist/swipe/swipe.d.ts.map +0 -1
- package/dist/swipe/swipe.js +0 -229
- package/dist/swipe/swipe.js.map +0 -1
- package/dist/tabs/tab-layout-item.d.ts +0 -10
- package/dist/tabs/tab-layout-item.d.ts.map +0 -1
- package/dist/tabs/tab-layout-item.js +0 -20
- package/dist/tabs/tab-layout-item.js.map +0 -1
- package/dist/tabs/tab-layout.d.ts +0 -10
- package/dist/tabs/tab-layout.d.ts.map +0 -1
- package/dist/tabs/tab-layout.js +0 -25
- package/dist/tabs/tab-layout.js.map +0 -1
- package/dist/tabs/tab-list-item.d.ts +0 -34
- package/dist/tabs/tab-list-item.d.ts.map +0 -1
- package/dist/tabs/tab-list-item.js +0 -195
- package/dist/tabs/tab-list-item.js.map +0 -1
- package/dist/tabs/tab-list.d.ts +0 -31
- package/dist/tabs/tab-list.d.ts.map +0 -1
- package/dist/tabs/tab-list.js +0 -257
- package/dist/tabs/tab-list.js.map +0 -1
- package/dist/tabs/tab-panel.d.ts +0 -11
- package/dist/tabs/tab-panel.d.ts.map +0 -1
- package/dist/tabs/tab-panel.js +0 -30
- package/dist/tabs/tab-panel.js.map +0 -1
- package/dist/tabs/tab-panels.d.ts +0 -30
- package/dist/tabs/tab-panels.d.ts.map +0 -1
- package/dist/tabs/tab-panels.js +0 -80
- package/dist/tabs/tab-panels.js.map +0 -1
- package/dist/timeline/index.d.ts +0 -9
- package/dist/timeline/index.d.ts.map +0 -1
- package/dist/timeline/index.js +0 -8
- package/dist/timeline/index.js.map +0 -1
- package/dist/timeline/timeline-controller.d.ts +0 -48
- package/dist/timeline/timeline-controller.d.ts.map +0 -1
- package/dist/timeline/timeline-controller.js +0 -81
- package/dist/timeline/timeline-controller.js.map +0 -1
- package/dist/timeline/timeline-draw.d.ts +0 -28
- package/dist/timeline/timeline-draw.d.ts.map +0 -1
- package/dist/timeline/timeline-draw.js +0 -330
- package/dist/timeline/timeline-draw.js.map +0 -1
- package/dist/timeline/timeline-element.d.ts +0 -140
- package/dist/timeline/timeline-element.d.ts.map +0 -1
- package/dist/timeline/timeline-element.js +0 -888
- package/dist/timeline/timeline-element.js.map +0 -1
- package/dist/timeline/timeline-interactions.d.ts +0 -40
- package/dist/timeline/timeline-interactions.d.ts.map +0 -1
- package/dist/timeline/timeline-interactions.js +0 -393
- package/dist/timeline/timeline-interactions.js.map +0 -1
- package/dist/timeline/timeline-styles.d.ts +0 -2
- package/dist/timeline/timeline-styles.d.ts.map +0 -1
- package/dist/timeline/timeline-styles.js +0 -153
- package/dist/timeline/timeline-styles.js.map +0 -1
- package/dist/timeline/timeline-track-tabs.d.ts +0 -30
- package/dist/timeline/timeline-track-tabs.d.ts.map +0 -1
- package/dist/timeline/timeline-track-tabs.js +0 -204
- package/dist/timeline/timeline-track-tabs.js.map +0 -1
- package/dist/timeline/types.d.ts +0 -144
- package/dist/timeline/types.d.ts.map +0 -1
- package/dist/timeline/types.js +0 -3
- package/dist/timeline/types.js.map +0 -1
- package/dist/tree/index.d.ts +0 -5
- package/dist/tree/index.d.ts.map +0 -1
- package/dist/tree/index.js +0 -5
- package/dist/tree/index.js.map +0 -1
- package/dist/tree/tree-base.d.ts +0 -70
- package/dist/tree/tree-base.d.ts.map +0 -1
- package/dist/tree/tree-base.js +0 -1028
- package/dist/tree/tree-base.js.map +0 -1
- package/dist/tree/tree-controller.d.ts +0 -14
- package/dist/tree/tree-controller.d.ts.map +0 -1
- package/dist/tree/tree-controller.js +0 -96
- package/dist/tree/tree-controller.js.map +0 -1
- package/dist/tree/tree-list.d.ts +0 -20
- package/dist/tree/tree-list.d.ts.map +0 -1
- package/dist/tree/tree-list.js +0 -174
- package/dist/tree/tree-list.js.map +0 -1
- package/dist/tree/types.d.ts +0 -14
- package/dist/tree/types.d.ts.map +0 -1
- package/dist/tree/types.js +0 -7
- package/dist/tree/types.js.map +0 -1
- package/dist/util/checkbox.d.ts +0 -2
- package/dist/util/checkbox.d.ts.map +0 -1
- package/dist/util/checkbox.js +0 -69
- package/dist/util/checkbox.js.map +0 -1
- package/dist/util/circle-arc.d.ts +0 -34
- package/dist/util/circle-arc.d.ts.map +0 -1
- package/dist/util/circle-arc.js +0 -85
- package/dist/util/circle-arc.js.map +0 -1
- package/dist/util/clamp.d.ts +0 -4
- package/dist/util/clamp.d.ts.map +0 -1
- package/dist/util/clamp.js +0 -23
- package/dist/util/clamp.js.map +0 -1
- package/dist/util/compare.d.ts +0 -53
- package/dist/util/compare.d.ts.map +0 -1
- package/dist/util/compare.js +0 -91
- package/dist/util/compare.js.map +0 -1
- package/dist/util/content-editable.d.ts +0 -2
- package/dist/util/content-editable.d.ts.map +0 -1
- package/dist/util/content-editable.js +0 -13
- package/dist/util/content-editable.js.map +0 -1
- package/dist/util/coordinates.d.ts +0 -3
- package/dist/util/coordinates.d.ts.map +0 -1
- package/dist/util/coordinates.js +0 -11
- package/dist/util/coordinates.js.map +0 -1
- package/dist/util/drag.d.ts +0 -16
- package/dist/util/drag.d.ts.map +0 -1
- package/dist/util/drag.js +0 -20
- package/dist/util/drag.js.map +0 -1
- package/dist/util/is-numeric.d.ts +0 -2
- package/dist/util/is-numeric.d.ts.map +0 -1
- package/dist/util/is-numeric.js +0 -9
- package/dist/util/is-numeric.js.map +0 -1
- package/dist/util/key-value.d.ts +0 -5
- package/dist/util/key-value.d.ts.map +0 -1
- package/dist/util/key-value.js +0 -29
- package/dist/util/key-value.js.map +0 -1
- package/dist/util/near.d.ts +0 -2
- package/dist/util/near.d.ts.map +0 -1
- package/dist/util/near.js +0 -6
- package/dist/util/near.js.map +0 -1
- package/dist/util/primitive-types.d.ts +0 -6
- package/dist/util/primitive-types.d.ts.map +0 -1
- package/dist/util/primitive-types.js +0 -2
- package/dist/util/primitive-types.js.map +0 -1
- package/dist/util/svg-editable-text.d.ts +0 -26
- package/dist/util/svg-editable-text.d.ts.map +0 -1
- package/dist/util/svg-editable-text.js +0 -119
- package/dist/util/svg-editable-text.js.map +0 -1
- package/dist/util/time.d.ts +0 -2
- package/dist/util/time.d.ts.map +0 -1
- package/dist/util/time.js +0 -2
- package/dist/util/time.js.map +0 -1
- package/dist/util/tooltip-controller.d.ts +0 -10
- package/dist/util/tooltip-controller.d.ts.map +0 -1
- package/dist/util/tooltip-controller.js +0 -237
- package/dist/util/tooltip-controller.js.map +0 -1
- package/dist/util/tooltip.d.ts +0 -21
- package/dist/util/tooltip.d.ts.map +0 -1
- package/dist/util/tooltip.js +0 -98
- package/dist/util/tooltip.js.map +0 -1
- package/dist/util/value-drag.d.ts +0 -33
- package/dist/util/value-drag.d.ts.map +0 -1
- package/dist/util/value-drag.js +0 -154
- package/dist/util/value-drag.js.map +0 -1
|
@@ -0,0 +1,1290 @@
|
|
|
1
|
+
import { C as resultThrow, T as testPlainObjectOrPrimitive, v as integerTest, x as numberTest, y as nullUndefTest } from "./dist-D7kJgnSE.js";
|
|
2
|
+
//#region node_modules/.pnpm/@ixfx+core@0.56.12/node_modules/@ixfx/core/dist/chunk-pbuEa-1d.js
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __exportAll = (all, no_symbols) => {
|
|
5
|
+
let target = {};
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
11
|
+
return target;
|
|
12
|
+
};
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region node_modules/.pnpm/@ixfx+core@0.56.12/node_modules/@ixfx/core/dist/maps-BqikhSVo.js
|
|
15
|
+
const removeCircularReferences = (value, replaceWith = null, seen = /* @__PURE__ */ new WeakSet(), path = ``) => {
|
|
16
|
+
if (value === null) return value;
|
|
17
|
+
if (typeof value !== `object`) throw new TypeError(`Param 'value' must be an object. Got type: ${typeof value}`);
|
|
18
|
+
seen.add(value);
|
|
19
|
+
const entries = Object.entries(value);
|
|
20
|
+
for (const entry of entries) {
|
|
21
|
+
if (entry[1] === null) continue;
|
|
22
|
+
if (typeof entry[1] !== `object`) continue;
|
|
23
|
+
if (seen.has(entry[1])) {
|
|
24
|
+
entry[1] = replaceWith;
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
entry[1] = removeCircularReferences(entry[1], replaceWith, seen, `${entry[0]}.`);
|
|
28
|
+
}
|
|
29
|
+
return Object.fromEntries(entries);
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* A default converter to string that uses JSON.stringify if its an object, or the thing itself if it's a string
|
|
33
|
+
*/
|
|
34
|
+
const toStringDefault = (itemToMakeStringFor) => typeof itemToMakeStringFor === `string` ? itemToMakeStringFor : JSON.stringify(itemToMakeStringFor);
|
|
35
|
+
/**
|
|
36
|
+
* Converts a value to string form.
|
|
37
|
+
* For simple objects, .toString() is used, other JSON.stringify is used.
|
|
38
|
+
* It is meant for creating debugging output or 'hash' versions of objects, and does
|
|
39
|
+
* not necessarily maintain full fidelity of the input
|
|
40
|
+
* @param value
|
|
41
|
+
* @returns
|
|
42
|
+
*/
|
|
43
|
+
const defaultToString = (value) => {
|
|
44
|
+
if (value === null) return `null`;
|
|
45
|
+
if (typeof value === `boolean` || typeof value === `number`) return value.toString();
|
|
46
|
+
if (typeof value === `string`) return value;
|
|
47
|
+
if (typeof value === `symbol`) throw new TypeError(`Symbol cannot be converted to string`);
|
|
48
|
+
try {
|
|
49
|
+
return JSON.stringify(value);
|
|
50
|
+
} catch (error) {
|
|
51
|
+
if (typeof value === `object`) return JSON.stringify(removeCircularReferences(value, `(circular)`));
|
|
52
|
+
else throw error;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Sort numbers in ascending order.
|
|
57
|
+
*
|
|
58
|
+
* ```js
|
|
59
|
+
* [10, 4, 5, 0].sort(numericComparer);
|
|
60
|
+
* // Yields: [0, 4, 5, 10]
|
|
61
|
+
* [10, 4, 5, 0].sort(comparerInverse(numericComparer));
|
|
62
|
+
* // Yields: [ 10, 5, 4, 0]
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* Returns:
|
|
66
|
+
* * 0: values are equal
|
|
67
|
+
* * negative: `a` should be before `b`
|
|
68
|
+
* * positive: `a` should come after `b`
|
|
69
|
+
* @param a
|
|
70
|
+
* @param b
|
|
71
|
+
* @returns
|
|
72
|
+
*/
|
|
73
|
+
const numericComparer = (a, b) => {
|
|
74
|
+
if (a === b) return 0;
|
|
75
|
+
if (a > b) return 1;
|
|
76
|
+
return -1;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Default sort comparer, following same sematics as Array.sort.
|
|
80
|
+
* Consider using {@link defaultComparer} to get more logical sorting of numbers.
|
|
81
|
+
*
|
|
82
|
+
* Note: numbers are sorted in alphabetical order, eg:
|
|
83
|
+
* ```js
|
|
84
|
+
* [ 10, 20, 5, 100 ].sort(jsComparer); // same as .sort()
|
|
85
|
+
* // Yields: [10, 100, 20, 5]
|
|
86
|
+
* ```
|
|
87
|
+
*
|
|
88
|
+
* Returns -1 if x is less than y
|
|
89
|
+
* Returns 1 if x is greater than y
|
|
90
|
+
* Returns 0 if x is the same as y
|
|
91
|
+
* @param x
|
|
92
|
+
* @param y
|
|
93
|
+
* @returns
|
|
94
|
+
*/
|
|
95
|
+
const jsComparer = (x, y) => {
|
|
96
|
+
if (x === void 0 && y === void 0) return 0;
|
|
97
|
+
if (x === void 0) return 1;
|
|
98
|
+
if (y === void 0) return -1;
|
|
99
|
+
const xString = defaultToString(x);
|
|
100
|
+
const yString = defaultToString(y);
|
|
101
|
+
if (xString < yString) return -1;
|
|
102
|
+
if (xString > yString) return 1;
|
|
103
|
+
return 0;
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* Compares numbers by numeric value, otherwise uses the default
|
|
107
|
+
* logic of string comparison.
|
|
108
|
+
*
|
|
109
|
+
* Is an ascending sort:
|
|
110
|
+
* * b, a, c -> a, b, c
|
|
111
|
+
* * 10, 5, 100 -> 5, 10, 100
|
|
112
|
+
*
|
|
113
|
+
* Returns -1 if x is less than y
|
|
114
|
+
* Returns 1 if x is greater than y
|
|
115
|
+
* Returns 0 if x is the same as y
|
|
116
|
+
* @param x
|
|
117
|
+
* @param y
|
|
118
|
+
* @see {@link comparerInverse} Inverted order
|
|
119
|
+
* @returns
|
|
120
|
+
*/
|
|
121
|
+
const defaultComparer = (x, y) => {
|
|
122
|
+
if (typeof x === `number` && typeof y === `number`) return numericComparer(x, y);
|
|
123
|
+
return jsComparer(x, y);
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* If input is a string, it is returned.
|
|
127
|
+
* Otherwise, it returns the result of JSON.stringify() with fields ordered.
|
|
128
|
+
*
|
|
129
|
+
* This allows for more consistent comparisons when object field orders are different but values the same.
|
|
130
|
+
* @param itemToMakeStringFor
|
|
131
|
+
* @returns
|
|
132
|
+
*/
|
|
133
|
+
const toStringOrdered = (itemToMakeStringFor) => {
|
|
134
|
+
if (typeof itemToMakeStringFor === `string`) return itemToMakeStringFor;
|
|
135
|
+
const allKeys = /* @__PURE__ */ new Set();
|
|
136
|
+
JSON.stringify(itemToMakeStringFor, (key, value) => (allKeys.add(key), value));
|
|
137
|
+
return JSON.stringify(itemToMakeStringFor, [...allKeys].sort());
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* Default comparer function is equiv to checking `a === b`.
|
|
141
|
+
* Use {@link isEqualValueDefault} to compare by value, via comparing JSON string representation.
|
|
142
|
+
*/
|
|
143
|
+
const isEqualDefault = (a, b) => a === b;
|
|
144
|
+
/**
|
|
145
|
+
* Comparer returns true if string representation of `a` and `b` are equal.
|
|
146
|
+
* Use {@link isEqualDefault} to compare using === semantics
|
|
147
|
+
* Uses `toStringDefault` to generate a string representation (via `JSON.stringify`).
|
|
148
|
+
*
|
|
149
|
+
* Returns _false_ if the ordering of fields is different, even though values are identical:
|
|
150
|
+
* ```js
|
|
151
|
+
* isEqualValueDefault({ a: 10, b: 20}, { b: 20, a: 10 }); // false
|
|
152
|
+
* ```
|
|
153
|
+
*
|
|
154
|
+
* Use {@link isEqualValueIgnoreOrder} to ignore order (with an overhead of additional processing).
|
|
155
|
+
* ```js
|
|
156
|
+
* isEqualValueIgnoreOrder({ a: 10, b: 20}, { b: 20, a: 10 }); // true
|
|
157
|
+
* ```
|
|
158
|
+
*
|
|
159
|
+
* Use {@link isEqualValuePartial} to partially match `b` against `a`.
|
|
160
|
+
* @returns True if the contents of `a` and `b` are equal
|
|
161
|
+
*/
|
|
162
|
+
const isEqualValueDefault = (a, b) => {
|
|
163
|
+
if (a === b) return true;
|
|
164
|
+
return toStringDefault(a) === toStringDefault(b);
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* Comparer returns true if string representation of `a` and `b` are equal, regardless of field ordering.
|
|
168
|
+
* Uses `toStringOrdered` to generate a string representation (via JSON.stringify`).
|
|
169
|
+
*
|
|
170
|
+
* ```js
|
|
171
|
+
* isEqualValueIgnoreOrder({ a: 10, b: 20}, { b: 20, a: 10 }); // true
|
|
172
|
+
* isEqualValue({ a: 10, b: 20}, { b: 20, a: 10 }); // false, fields are different order
|
|
173
|
+
* ```
|
|
174
|
+
*
|
|
175
|
+
* There is an overhead to ordering fields. Use {@link isEqualValueDefault} if it's not possible that field ordering will change.
|
|
176
|
+
* @returns True if the contents of `a` and `b` are equal
|
|
177
|
+
* @typeParam T - Type of objects being compared
|
|
178
|
+
*/
|
|
179
|
+
const isEqualValueIgnoreOrder = (a, b) => {
|
|
180
|
+
if (a === b) return true;
|
|
181
|
+
return toStringOrdered(a) === toStringOrdered(b);
|
|
182
|
+
};
|
|
183
|
+
/**
|
|
184
|
+
* @inheritDoc getOrGenerate
|
|
185
|
+
* @param map
|
|
186
|
+
* @param fn
|
|
187
|
+
* @returns
|
|
188
|
+
*/
|
|
189
|
+
const getOrGenerateSync = (map, fn) => (key, args) => {
|
|
190
|
+
let value = map.get(key);
|
|
191
|
+
if (value !== void 0) return value;
|
|
192
|
+
value = fn(key, args);
|
|
193
|
+
map.set(key, value);
|
|
194
|
+
return value;
|
|
195
|
+
};
|
|
196
|
+
//#endregion
|
|
197
|
+
//#region node_modules/.pnpm/@ixfx+core@0.56.12/node_modules/@ixfx/core/dist/text.js
|
|
198
|
+
/**
|
|
199
|
+
* Given a long string, abbreviates it with ...
|
|
200
|
+
* ```js
|
|
201
|
+
* abbreviate(`This is something`, 7); // `This is...`
|
|
202
|
+
* ```
|
|
203
|
+
*
|
|
204
|
+
* If `source` is under `maxLength` the original is returned.
|
|
205
|
+
* @param source
|
|
206
|
+
* @param maxLength Maximum length. Defaults to 20
|
|
207
|
+
* @returns
|
|
208
|
+
*/
|
|
209
|
+
const abbreviate = (source, maxLength = 15) => {
|
|
210
|
+
resultThrow(integerTest(maxLength, `aboveZero`, `maxLength`));
|
|
211
|
+
if (typeof source !== `string`) throw new Error(`Parameter 'source' is not a string`);
|
|
212
|
+
if (source.length > maxLength && source.length > 3) {
|
|
213
|
+
if (maxLength > 15) {
|
|
214
|
+
const chunk = Math.round((maxLength - 2) / 2);
|
|
215
|
+
return source.slice(0, chunk) + `...` + source.slice(-chunk);
|
|
216
|
+
}
|
|
217
|
+
return source.slice(0, maxLength) + `...`;
|
|
218
|
+
}
|
|
219
|
+
return source;
|
|
220
|
+
};
|
|
221
|
+
/**
|
|
222
|
+
* Uses JSON.toString() on `source`, but abbreviates result.
|
|
223
|
+
* @param source Object to stringify
|
|
224
|
+
* @param maxLength Default 20
|
|
225
|
+
* @returns
|
|
226
|
+
*/
|
|
227
|
+
const toStringAbbreviate = (source, maxLength = 20) => {
|
|
228
|
+
if (source === void 0) return `(undefined)`;
|
|
229
|
+
if (source === null) return `(null)`;
|
|
230
|
+
return abbreviate(JSON.stringify(source), maxLength);
|
|
231
|
+
};
|
|
232
|
+
//#endregion
|
|
233
|
+
//#region node_modules/.pnpm/@ixfx+core@0.56.12/node_modules/@ixfx/core/dist/src-rzH1dhIm.js
|
|
234
|
+
const cloneFromFields = (source) => {
|
|
235
|
+
const entries = [];
|
|
236
|
+
for (const field in source) {
|
|
237
|
+
const value = source[field];
|
|
238
|
+
if (testPlainObjectOrPrimitive(value)) entries.push([field, value]);
|
|
239
|
+
}
|
|
240
|
+
return Object.fromEntries(entries);
|
|
241
|
+
};
|
|
242
|
+
/**
|
|
243
|
+
* Maps the keys of an object, returning a transformed object.
|
|
244
|
+
* ```js
|
|
245
|
+
* const input = {
|
|
246
|
+
* hello: `there`,
|
|
247
|
+
* chap: `chappie`
|
|
248
|
+
* }
|
|
249
|
+
*
|
|
250
|
+
* mapObjectKeys(input, key => key.toUppercase());
|
|
251
|
+
*
|
|
252
|
+
* // Yields: { HELLO: `there`, CHAP: `chappie` }
|
|
253
|
+
* ```
|
|
254
|
+
* @param object
|
|
255
|
+
* @param mapFunction
|
|
256
|
+
* @returns
|
|
257
|
+
*/
|
|
258
|
+
const mapObjectKeys = (object, mapFunction) => {
|
|
259
|
+
const destinationObject = {};
|
|
260
|
+
for (const entries of Object.entries(object)) {
|
|
261
|
+
const key = mapFunction(entries[0]);
|
|
262
|
+
destinationObject[key] = entries[1];
|
|
263
|
+
}
|
|
264
|
+
return destinationObject;
|
|
265
|
+
};
|
|
266
|
+
/**
|
|
267
|
+
* Compares the keys of two objects, returning a set of those in
|
|
268
|
+
* common, and those in either A or B exclusively.
|
|
269
|
+
* ```js
|
|
270
|
+
* const a = { colour: `red`, intensity: 5 };
|
|
271
|
+
* const b = { colour: `pink`, size: 10 };
|
|
272
|
+
* const c = compareObjectKeys(a, b);
|
|
273
|
+
* // c.shared = [ `colour` ]
|
|
274
|
+
* // c.a = [ `intensity` ]
|
|
275
|
+
* // c.b = [ `size` ]
|
|
276
|
+
* ```
|
|
277
|
+
* @param a
|
|
278
|
+
* @param b
|
|
279
|
+
* @returns
|
|
280
|
+
*/
|
|
281
|
+
const compareObjectKeys = (a, b) => {
|
|
282
|
+
return compareIterableValuesShallow(Object.keys(a), Object.keys(b));
|
|
283
|
+
};
|
|
284
|
+
/**
|
|
285
|
+
* Returns the changed fields from A -> B. It's assumed that A and B have the same shape.
|
|
286
|
+
* ie. returns an object that only consists of fields which have changed in B compared to A.
|
|
287
|
+
*
|
|
288
|
+
* ```js
|
|
289
|
+
* const a = { msg: `hi`, v: 10 };
|
|
290
|
+
*
|
|
291
|
+
* changedProperties(a, { msg: `hi`, v: 10 }); // {}
|
|
292
|
+
* changedProperties(a, { msg: `hi!!`, v: 10 }); // { msg: `hi!!` }
|
|
293
|
+
* changedProperties(a, { msg: `hi!!` }); // { msg: `hi!!`, v: undefined }
|
|
294
|
+
* ```
|
|
295
|
+
*
|
|
296
|
+
* If B has additional or removed fields, this is considered an error.
|
|
297
|
+
*
|
|
298
|
+
* If a field is an array, the whole array is returned, rather than a diff.
|
|
299
|
+
* @param a
|
|
300
|
+
* @param b
|
|
301
|
+
*/
|
|
302
|
+
const changedProperties = (a, b) => {
|
|
303
|
+
const r = compareObjectData(a, b, true);
|
|
304
|
+
if (Object.entries(r.added).length > 0) throw new Error(`Shape of data has changed`);
|
|
305
|
+
if (Object.entries(r.removed).length > 0) throw new Error(`Shape of data has changed`);
|
|
306
|
+
return compareResultToObject(r, b);
|
|
307
|
+
};
|
|
308
|
+
const compareResultToObject = (r, b) => {
|
|
309
|
+
const output = {};
|
|
310
|
+
if (r.isArray) return b;
|
|
311
|
+
for (const entry of Object.entries(r.changed)) output[entry[0]] = entry[1];
|
|
312
|
+
for (const entry of Object.entries(r.added)) output[entry[0]] = entry[1];
|
|
313
|
+
for (const childEntry of Object.entries(r.children)) {
|
|
314
|
+
const childResult = childEntry[1];
|
|
315
|
+
if (childResult.hasChanged) output[childEntry[0]] = compareResultToObject(childResult, b[childEntry[0]]);
|
|
316
|
+
}
|
|
317
|
+
return output;
|
|
318
|
+
};
|
|
319
|
+
/**
|
|
320
|
+
* Produces a {@link CompareChangeSet} between two arrays.
|
|
321
|
+
*
|
|
322
|
+
* @param a Earlier array to compare
|
|
323
|
+
* @param b Later array to compare
|
|
324
|
+
* @param eq Equality comparison for values
|
|
325
|
+
* @returns Change set.
|
|
326
|
+
*/
|
|
327
|
+
const compareArrays = (a, b, eq = isEqualDefault) => {
|
|
328
|
+
if (!Array.isArray(a)) throw new Error(`Param 'a' is not an array`);
|
|
329
|
+
if (!Array.isArray(b)) throw new Error(`Param 'b' is not an array`);
|
|
330
|
+
const c = compareObjectData(a, b, false, eq);
|
|
331
|
+
if (!c.isArray) throw new Error(`Change set does not have arrays as parameters`);
|
|
332
|
+
const convert = (key) => {
|
|
333
|
+
if (key.startsWith(`_`)) return Number.parseInt(key.slice(1));
|
|
334
|
+
else throw new Error(`Unexpected key '${key}'`);
|
|
335
|
+
};
|
|
336
|
+
return {
|
|
337
|
+
...c,
|
|
338
|
+
added: mapObjectKeys(c.added, convert),
|
|
339
|
+
changed: mapObjectKeys(c.changed, convert),
|
|
340
|
+
removed: c.removed.map((v) => convert(v)),
|
|
341
|
+
summary: c.summary.map((value) => {
|
|
342
|
+
return [
|
|
343
|
+
value[0],
|
|
344
|
+
convert(value[1]),
|
|
345
|
+
value[2]
|
|
346
|
+
];
|
|
347
|
+
})
|
|
348
|
+
};
|
|
349
|
+
};
|
|
350
|
+
/**
|
|
351
|
+
* Compares A to B. Assumes they are simple objects, essentially key-value pairs, where the
|
|
352
|
+
* values are primitive values or other simple objects. It also works with arrays.
|
|
353
|
+
*
|
|
354
|
+
* Uses === equality semantics by default.
|
|
355
|
+
* @param a
|
|
356
|
+
* @param b
|
|
357
|
+
*/
|
|
358
|
+
const compareObjectData = (a, b, assumeSameShape = false, eq = isEqualDefault) => {
|
|
359
|
+
a ??= {};
|
|
360
|
+
b ??= {};
|
|
361
|
+
const entriesA = Object.entries(a);
|
|
362
|
+
const entriesB = Object.entries(b);
|
|
363
|
+
const scannedKeys = /* @__PURE__ */ new Set();
|
|
364
|
+
const changed = {};
|
|
365
|
+
const added = {};
|
|
366
|
+
const children = {};
|
|
367
|
+
const removed = [];
|
|
368
|
+
const isArray = Array.isArray(a);
|
|
369
|
+
const summary = new Array();
|
|
370
|
+
let hasChanged = false;
|
|
371
|
+
for (const entry of entriesA) {
|
|
372
|
+
const outputKey = isArray ? `_${entry[0]}` : entry[0];
|
|
373
|
+
const aValue = entry[1];
|
|
374
|
+
const bValue = b[entry[0]];
|
|
375
|
+
scannedKeys.add(entry[0]);
|
|
376
|
+
if (bValue === void 0) {
|
|
377
|
+
hasChanged = true;
|
|
378
|
+
if (assumeSameShape && !isArray) {
|
|
379
|
+
changed[outputKey] = bValue;
|
|
380
|
+
summary.push([
|
|
381
|
+
`mutate`,
|
|
382
|
+
outputKey,
|
|
383
|
+
bValue
|
|
384
|
+
]);
|
|
385
|
+
} else {
|
|
386
|
+
removed.push(outputKey);
|
|
387
|
+
summary.push([
|
|
388
|
+
`del`,
|
|
389
|
+
outputKey,
|
|
390
|
+
aValue
|
|
391
|
+
]);
|
|
392
|
+
}
|
|
393
|
+
continue;
|
|
394
|
+
}
|
|
395
|
+
if (typeof aValue === `object`) {
|
|
396
|
+
const r = compareObjectData(aValue, bValue, assumeSameShape, eq);
|
|
397
|
+
if (r.hasChanged) hasChanged = true;
|
|
398
|
+
children[outputKey] = r;
|
|
399
|
+
const childSummary = r.summary.map((sum) => {
|
|
400
|
+
return [
|
|
401
|
+
sum[0],
|
|
402
|
+
outputKey + `.` + sum[1],
|
|
403
|
+
sum[2]
|
|
404
|
+
];
|
|
405
|
+
});
|
|
406
|
+
summary.push(...childSummary);
|
|
407
|
+
} else if (!eq(aValue, bValue)) {
|
|
408
|
+
changed[outputKey] = bValue;
|
|
409
|
+
hasChanged = true;
|
|
410
|
+
summary.push([
|
|
411
|
+
`mutate`,
|
|
412
|
+
outputKey,
|
|
413
|
+
bValue
|
|
414
|
+
]);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
if (!assumeSameShape || isArray) for (const entry of entriesB) {
|
|
418
|
+
const key = isArray ? `_${entry[0]}` : entry[0];
|
|
419
|
+
if (scannedKeys.has(entry[0])) continue;
|
|
420
|
+
added[key] = entry[1];
|
|
421
|
+
hasChanged = true;
|
|
422
|
+
summary.push([
|
|
423
|
+
`add`,
|
|
424
|
+
key,
|
|
425
|
+
entry[1]
|
|
426
|
+
]);
|
|
427
|
+
}
|
|
428
|
+
return {
|
|
429
|
+
changed,
|
|
430
|
+
added,
|
|
431
|
+
removed,
|
|
432
|
+
children,
|
|
433
|
+
hasChanged,
|
|
434
|
+
isArray,
|
|
435
|
+
summary
|
|
436
|
+
};
|
|
437
|
+
};
|
|
438
|
+
/**
|
|
439
|
+
* Returns a copy of `object` with integer numbers as keys instead of whatever it has.
|
|
440
|
+
* ```js
|
|
441
|
+
* keysToNumbers({ '1': true }); // Yields: { 1: true }
|
|
442
|
+
* ```
|
|
443
|
+
*
|
|
444
|
+
* The `onInvalidKey` sets how to handle keys that cannot be converted to integers.
|
|
445
|
+
* * 'throw' (default): throws an exception
|
|
446
|
+
* * 'ignore': that key & value is ignored
|
|
447
|
+
* * 'keep': uses the string key instead
|
|
448
|
+
*
|
|
449
|
+
*
|
|
450
|
+
* ```js
|
|
451
|
+
* keysToNumber({ hello: 'there' }, `ignore`); // Yields: { }
|
|
452
|
+
* keysToNumber({ hello: 'there' }, `throw`); // Exception
|
|
453
|
+
* keysToNumber({ hello: 'there' }, `keep`); // Yields: { hello: 'there' }
|
|
454
|
+
* ```
|
|
455
|
+
*
|
|
456
|
+
* Floating-point numbers will be converted to integer by rounding.
|
|
457
|
+
* ```js
|
|
458
|
+
* keysToNumbers({ '2.4': 'hello' }); // Yields: { 2: 'hello' }
|
|
459
|
+
* ```
|
|
460
|
+
* @param object
|
|
461
|
+
* @param onInvalidKey
|
|
462
|
+
* @returns
|
|
463
|
+
*/
|
|
464
|
+
const keysToNumbers = (object, onInvalidKey = `throw`) => {
|
|
465
|
+
const returnObject = {};
|
|
466
|
+
for (const entry of Object.entries(object)) {
|
|
467
|
+
const asNumber = Number.parseInt(entry[0]);
|
|
468
|
+
if (Number.isNaN(asNumber)) switch (onInvalidKey) {
|
|
469
|
+
case `throw`: throw new TypeError(`Cannot convert key '${entry[0]}' to an integer`);
|
|
470
|
+
case `ignore`: continue;
|
|
471
|
+
case `keep`:
|
|
472
|
+
returnObject[entry[0]] = entry[1];
|
|
473
|
+
continue;
|
|
474
|
+
default: throw new Error(`Param 'onInvalidKey' should be: 'throw', 'ignore' or 'keep'.`);
|
|
475
|
+
}
|
|
476
|
+
returnObject[asNumber] = entry[1];
|
|
477
|
+
}
|
|
478
|
+
return returnObject;
|
|
479
|
+
};
|
|
480
|
+
/**
|
|
481
|
+
* Maps the top-level properties of an object through a map function.
|
|
482
|
+
* That is, run each of the values of an object through a function,
|
|
483
|
+
* setting the result onto the same key structure as original.
|
|
484
|
+
*
|
|
485
|
+
* It is NOT recursive.
|
|
486
|
+
*
|
|
487
|
+
* The mapping function gets a single args object, consisting of `{ value, field, index }`,
|
|
488
|
+
* where 'value' is the value of the field, 'field' the name, and 'index' a numeric count.
|
|
489
|
+
* @example Double the value of all fields
|
|
490
|
+
* ```js
|
|
491
|
+
* const rect = { width: 100, height: 250 };
|
|
492
|
+
* const doubled = mapObjectShallow(rect, args => {
|
|
493
|
+
* return args.value*2;
|
|
494
|
+
* });
|
|
495
|
+
* // Yields: { width: 200, height: 500 }
|
|
496
|
+
* ```
|
|
497
|
+
*
|
|
498
|
+
* Since the map callback gets the name of the property, it can do context-dependent things.
|
|
499
|
+
* ```js
|
|
500
|
+
* const rect = { width: 100, height: 250, colour: 'red' }
|
|
501
|
+
* const doubled = mapObjectShallow(rect, args => {
|
|
502
|
+
* if (args.field === 'width') return args.value*3;
|
|
503
|
+
* else if (typeof args.value === 'number') return args.value*2;
|
|
504
|
+
* return args.value;
|
|
505
|
+
* });
|
|
506
|
+
* // Yields: { width: 300, height: 500, colour: 'red' }
|
|
507
|
+
* ```
|
|
508
|
+
* In addition to bulk processing, it allows remapping of property types.
|
|
509
|
+
*
|
|
510
|
+
* In terms of type-safety, the mapped properties are assumed to have the
|
|
511
|
+
* same type.
|
|
512
|
+
*
|
|
513
|
+
* ```js
|
|
514
|
+
* const o = {
|
|
515
|
+
* x: 10,
|
|
516
|
+
* y: 20,
|
|
517
|
+
* width: 200,
|
|
518
|
+
* height: 200
|
|
519
|
+
* }
|
|
520
|
+
*
|
|
521
|
+
* // Make each property use an averager instead
|
|
522
|
+
* const oAvg = mapObjectShallow(o, args => {
|
|
523
|
+
* return movingAverage(10);
|
|
524
|
+
* });
|
|
525
|
+
*
|
|
526
|
+
* // Instead of { x:number, y:number... }, we now have { x:movingAverage(), y:movingAverage()... }
|
|
527
|
+
* // Add a value to the averager
|
|
528
|
+
* oAvg.x.add(20);
|
|
529
|
+
* ```
|
|
530
|
+
*/
|
|
531
|
+
const mapObjectShallow = (object, mapFunction) => {
|
|
532
|
+
const mapped = Object.entries(object).map(([sourceField, sourceFieldValue], index) => [sourceField, mapFunction({
|
|
533
|
+
value: sourceFieldValue,
|
|
534
|
+
field: sourceField,
|
|
535
|
+
index,
|
|
536
|
+
path: sourceField
|
|
537
|
+
})]);
|
|
538
|
+
return Object.fromEntries(mapped);
|
|
539
|
+
};
|
|
540
|
+
/**
|
|
541
|
+
* Maps the contents of `data` using `mapper` as a structured set of map functions.
|
|
542
|
+
* ```js
|
|
543
|
+
* const a = {
|
|
544
|
+
* person: {
|
|
545
|
+
* size: 20
|
|
546
|
+
* }
|
|
547
|
+
* hello: `there`
|
|
548
|
+
* }
|
|
549
|
+
* mapObjectByObject(a, {
|
|
550
|
+
* person: {
|
|
551
|
+
* size: (value, context) => {
|
|
552
|
+
* return value * 2
|
|
553
|
+
* }
|
|
554
|
+
* }
|
|
555
|
+
* });
|
|
556
|
+
* // Yields: { person: { size: 40 }, hello: `there` }
|
|
557
|
+
* ```
|
|
558
|
+
* @param data
|
|
559
|
+
* @param mapper
|
|
560
|
+
* @returns
|
|
561
|
+
*/
|
|
562
|
+
function mapObjectByObject(data, mapper) {
|
|
563
|
+
const entries = Object.entries(data);
|
|
564
|
+
for (const entry of entries) if (entry[0] in mapper) {
|
|
565
|
+
const m = mapper[entry[0]];
|
|
566
|
+
entry[1] = typeof m === `object` ? mapObjectByObject(entry[1], m) : m(entry[1], data);
|
|
567
|
+
}
|
|
568
|
+
return Object.fromEntries(entries);
|
|
569
|
+
}
|
|
570
|
+
/**
|
|
571
|
+
* Merges objects together, the rightmost objects overriding properties of earlier objects.
|
|
572
|
+
*
|
|
573
|
+
* The return type is the intersection of all properties
|
|
574
|
+
* ```js
|
|
575
|
+
* const a = { name: `jane`, age: 30 };
|
|
576
|
+
* const b = { name: `fred`, age: 31, colour: `blue` };
|
|
577
|
+
* const c = merge(a, b);
|
|
578
|
+
* // Yields:
|
|
579
|
+
* // { name: `fred`, age: 31, colour: `blue` }
|
|
580
|
+
* ```
|
|
581
|
+
*
|
|
582
|
+
* Alternatively, use {@link mergeSameShape} if the return shape
|
|
583
|
+
* should be based on the first object.
|
|
584
|
+
* @param a
|
|
585
|
+
* @returns Merged object
|
|
586
|
+
*/
|
|
587
|
+
function merge(...a) {
|
|
588
|
+
return Object.assign({}, ...a);
|
|
589
|
+
}
|
|
590
|
+
/**
|
|
591
|
+
* Merges objects together, conforming to the shape of the first object.
|
|
592
|
+
* Properties contained on later objects are ignored if they aren't part of the first.
|
|
593
|
+
*
|
|
594
|
+
* If a single object is passed in, a copy is returned.
|
|
595
|
+
*
|
|
596
|
+
* Use {@link merge} for object shape to be a union
|
|
597
|
+
* @param a Object arrays to merge
|
|
598
|
+
* @returns
|
|
599
|
+
*/
|
|
600
|
+
function mergeSameShape(...a) {
|
|
601
|
+
const aEntries = Object.entries(a[0]);
|
|
602
|
+
for (let index = 1; index < a.length; index++) {
|
|
603
|
+
const bEntries = Object.entries(a[index]);
|
|
604
|
+
for (const [key, value] of bEntries) {
|
|
605
|
+
const aEntry = aEntries.find(([aKey]) => aKey === key);
|
|
606
|
+
if (aEntry) aEntry[1] = value;
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
return Object.fromEntries(aEntries);
|
|
610
|
+
}
|
|
611
|
+
/**
|
|
612
|
+
* Returns a new object based on `data` but with all
|
|
613
|
+
* properties prefixed by `prefix`.
|
|
614
|
+
*
|
|
615
|
+
* ```js
|
|
616
|
+
* prefixProperties({ name: `x`, size: 10 }, `test-`);
|
|
617
|
+
*
|
|
618
|
+
* // Yields:
|
|
619
|
+
* // { test-name: `x`, test-size: 10 }
|
|
620
|
+
* ```
|
|
621
|
+
* @param data
|
|
622
|
+
* @param prefix
|
|
623
|
+
* @returns
|
|
624
|
+
*/
|
|
625
|
+
function prefixProperties(data, prefix) {
|
|
626
|
+
const changed = [];
|
|
627
|
+
for (const d of data) {
|
|
628
|
+
const entries = Object.entries(d);
|
|
629
|
+
const changedEntries = [];
|
|
630
|
+
for (const [key, value] of entries) changedEntries.push([prefix + key, value]);
|
|
631
|
+
changed.push(Object.fromEntries(changedEntries));
|
|
632
|
+
}
|
|
633
|
+
return changed;
|
|
634
|
+
}
|
|
635
|
+
/**
|
|
636
|
+
* Returns _true_ if `value` is number, string, bigint or boolean.
|
|
637
|
+
* Returns _false_ if `value` is an object, null, undefined
|
|
638
|
+
*
|
|
639
|
+
* Use {@link isPrimitiveOrObject} to also return true if `value` is an object.
|
|
640
|
+
* @param value Value to check
|
|
641
|
+
* @returns _True_ if value is number, string, bigint or boolean.
|
|
642
|
+
*/
|
|
643
|
+
function isPrimitive(value) {
|
|
644
|
+
if (typeof value === `number`) return true;
|
|
645
|
+
if (typeof value === `string`) return true;
|
|
646
|
+
if (typeof value === `bigint`) return true;
|
|
647
|
+
if (typeof value === `boolean`) return true;
|
|
648
|
+
return false;
|
|
649
|
+
}
|
|
650
|
+
/**
|
|
651
|
+
* Helper function to get a 'friendly' string representation of an array of {@link RecordEntry}.
|
|
652
|
+
* @param entries
|
|
653
|
+
* @returns
|
|
654
|
+
*/
|
|
655
|
+
function prettyPrintEntries(entries) {
|
|
656
|
+
if (entries.length === 0) return `(empty)`;
|
|
657
|
+
let t = ``;
|
|
658
|
+
for (const [index, entry] of entries.entries()) {
|
|
659
|
+
t += ` `.repeat(index);
|
|
660
|
+
t += `${entry.name} = ${JSON.stringify(entry.nodeValue)}\n`;
|
|
661
|
+
}
|
|
662
|
+
return t;
|
|
663
|
+
}
|
|
664
|
+
/**
|
|
665
|
+
* Returns a human-friendly debug string for a tree-like structure
|
|
666
|
+
* ```js
|
|
667
|
+
* console.log(Trees.prettyPrint(obj));
|
|
668
|
+
* ```
|
|
669
|
+
* @param indent
|
|
670
|
+
* @param node
|
|
671
|
+
* @param options
|
|
672
|
+
* @returns
|
|
673
|
+
*/
|
|
674
|
+
function recordEntryPrettyPrint(node, indent = 0, options = {}) {
|
|
675
|
+
resultThrow(nullUndefTest(node, `node`));
|
|
676
|
+
const entry = getNamedRecordEntry(node, options.name ?? `node`);
|
|
677
|
+
const t = `${` `.repeat(indent)} + name: ${entry.name} value: ${JSON.stringify(entry.nodeValue)}`;
|
|
678
|
+
const childrenAsArray = [...recordChildren(node, options)];
|
|
679
|
+
return childrenAsArray.length > 0 ? `${t}\n${childrenAsArray.map((d) => recordEntryPrettyPrint(d.nodeValue, indent + 1, {
|
|
680
|
+
...options,
|
|
681
|
+
name: d.name
|
|
682
|
+
})).join(`\n`)}` : t;
|
|
683
|
+
}
|
|
684
|
+
/**
|
|
685
|
+
* Returns the direct children of a tree-like object as a pairing
|
|
686
|
+
* of node name and value. Supports basic objects, Maps and arrays.
|
|
687
|
+
*
|
|
688
|
+
* Sub-children are included as an object blob.
|
|
689
|
+
*
|
|
690
|
+
* @example Simple object
|
|
691
|
+
* ```js
|
|
692
|
+
* const o = {
|
|
693
|
+
* colour: {
|
|
694
|
+
* r: 0.5, g: 0.5, b: 0.5
|
|
695
|
+
* }
|
|
696
|
+
* };
|
|
697
|
+
*
|
|
698
|
+
* const children = [ ...Trees.children(o) ];
|
|
699
|
+
* // Children:
|
|
700
|
+
* // [
|
|
701
|
+
* // { name: "colour", value: { b: 0.5, g: 0.5, r: 0.5 } }
|
|
702
|
+
* // ]
|
|
703
|
+
* const subChildren = [ ...Trees.children(o.colour) ];
|
|
704
|
+
* // [ { name: "r", value: 0.5 }, { name: "g", value: 0.5 }, { name: "b", value: 0.5 } ]
|
|
705
|
+
* ```
|
|
706
|
+
*
|
|
707
|
+
* Arrays are assigned a name based on index.
|
|
708
|
+
* @example Arrays
|
|
709
|
+
* ```js
|
|
710
|
+
* const colours = [ { r: 1, g: 0, b: 0 }, { r: 0, g: 1, b: 0 }, { r: 0, g: 0, b: 1 } ];
|
|
711
|
+
* // Children:
|
|
712
|
+
* // [
|
|
713
|
+
* // { name: "array[0]", value: {r:1,g:0,b:0} },
|
|
714
|
+
* // { name: "array[1]", value: {r:0,g:1,b:0} },
|
|
715
|
+
* // { name: "array[2]", value: {r:0,g:0,b:1} },
|
|
716
|
+
* // ]
|
|
717
|
+
* ```
|
|
718
|
+
*
|
|
719
|
+
* Pass in `options.name` (eg 'colours') to have names generated as 'colours[0]', etc.
|
|
720
|
+
* Options can also be used to filter children. By default all direct children are returned.
|
|
721
|
+
* @param node
|
|
722
|
+
* @param options
|
|
723
|
+
*/
|
|
724
|
+
function* recordChildren(node, options = {}) {
|
|
725
|
+
resultThrow(nullUndefTest(node, `node`));
|
|
726
|
+
const filter = options.filter ?? `none`;
|
|
727
|
+
const filterByValue = (v) => {
|
|
728
|
+
if (filter === `none`) return [true, isPrimitive(v)];
|
|
729
|
+
else if (filter === `leaves` && isPrimitive(v)) return [true, true];
|
|
730
|
+
else if (filter === `branches` && !isPrimitive(v)) return [true, false];
|
|
731
|
+
return [false, isPrimitive(v)];
|
|
732
|
+
};
|
|
733
|
+
if (Array.isArray(node)) for (const [index, element] of node.entries()) {
|
|
734
|
+
const f = filterByValue(element);
|
|
735
|
+
if (f[0]) yield {
|
|
736
|
+
name: index.toString(),
|
|
737
|
+
sourceValue: element,
|
|
738
|
+
nodeValue: f[1] ? element : void 0
|
|
739
|
+
};
|
|
740
|
+
}
|
|
741
|
+
else if (typeof node === `object`) if (options.withPrototype) for (const name in node) {
|
|
742
|
+
const value = node[name];
|
|
743
|
+
const f = filterByValue(value);
|
|
744
|
+
if (f[0]) yield {
|
|
745
|
+
name,
|
|
746
|
+
sourceValue: value,
|
|
747
|
+
nodeValue: f[1] ? value : void 0
|
|
748
|
+
};
|
|
749
|
+
}
|
|
750
|
+
else {
|
|
751
|
+
const entriesIter = `entries` in node ? node.entries() : Object.entries(node);
|
|
752
|
+
for (const [name, value] of entriesIter) {
|
|
753
|
+
const f = filterByValue(value);
|
|
754
|
+
if (f[0]) yield {
|
|
755
|
+
name,
|
|
756
|
+
sourceValue: value,
|
|
757
|
+
nodeValue: f[1] ? value : void 0
|
|
758
|
+
};
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
function* recordEntriesDepthFirst(node, options = {}, ancestors = []) {
|
|
763
|
+
if (node === null || node === void 0) return;
|
|
764
|
+
const opts = {
|
|
765
|
+
filter: options.filter ?? `none`,
|
|
766
|
+
name: options.name ?? ``,
|
|
767
|
+
withPrototype: options.withPrototype ?? false,
|
|
768
|
+
seen: options.seen ?? /* @__PURE__ */ new WeakSet()
|
|
769
|
+
};
|
|
770
|
+
if (typeof node === `object`) {
|
|
771
|
+
if (opts.seen.has(node)) return;
|
|
772
|
+
opts.seen.add(node);
|
|
773
|
+
}
|
|
774
|
+
for (const c of recordChildren(node, opts)) {
|
|
775
|
+
yield {
|
|
776
|
+
...c,
|
|
777
|
+
ancestors: [...ancestors]
|
|
778
|
+
};
|
|
779
|
+
yield* recordEntriesDepthFirst(c.sourceValue, opts, [...ancestors, c.name]);
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
/**
|
|
783
|
+
* Finds a given direct child by name
|
|
784
|
+
* @param name
|
|
785
|
+
* @param node
|
|
786
|
+
* @returns
|
|
787
|
+
*/
|
|
788
|
+
function recordEntryChildByName(name, node) {
|
|
789
|
+
for (const d of recordChildren(node)) if (d.name === name) return d;
|
|
790
|
+
}
|
|
791
|
+
/**
|
|
792
|
+
* Returns the closest matching entry, tracing `path` in an array, Map or simple object.
|
|
793
|
+
* Returns an entry with _undefined_ value at the point where tracing stopped.
|
|
794
|
+
* Use {@link traceRecordEntryByPath} to step through all the segments.
|
|
795
|
+
*
|
|
796
|
+
* ```js
|
|
797
|
+
* const people = {
|
|
798
|
+
* jane: {
|
|
799
|
+
* address: {
|
|
800
|
+
* postcode: 1000,
|
|
801
|
+
* street: 'West St',
|
|
802
|
+
* city: 'Blahville'
|
|
803
|
+
* },
|
|
804
|
+
* colour: 'red'
|
|
805
|
+
* }
|
|
806
|
+
* }
|
|
807
|
+
* Trees.getByPath('jane.address.postcode', people); // '.' default separator
|
|
808
|
+
* // ['postcode', 1000]
|
|
809
|
+
* Trees.getByPath('jane.address.country.state', people);
|
|
810
|
+
* // ['country', undefined] - since full path could not be resolved.
|
|
811
|
+
* ```
|
|
812
|
+
* @param path Path, eg `jane.address.postcode`
|
|
813
|
+
* @param node Node to look within
|
|
814
|
+
* @param options Options for parsing path. By default '.' is used as a separator
|
|
815
|
+
* @returns
|
|
816
|
+
*/
|
|
817
|
+
function getRecordEntryByPath(path, node, options = {}) {
|
|
818
|
+
const paths = [...traceRecordEntryByPath(path, node, options)];
|
|
819
|
+
if (paths.length === 0) throw new Error(`Could not trace path: ${path} `);
|
|
820
|
+
return paths.at(-1);
|
|
821
|
+
}
|
|
822
|
+
/**
|
|
823
|
+
* Enumerates over children of `node` towards the node named in `path`.
|
|
824
|
+
* This is useful if you want to get the interim steps to the target node.
|
|
825
|
+
*
|
|
826
|
+
* Use {@link getRecordEntryByPath} if you don't care about interim steps.
|
|
827
|
+
*
|
|
828
|
+
* ```js
|
|
829
|
+
* const people = {
|
|
830
|
+
* jane: {
|
|
831
|
+
* address: {
|
|
832
|
+
* postcode: 1000,
|
|
833
|
+
* street: 'West St',
|
|
834
|
+
* city: 'Blahville'
|
|
835
|
+
* },
|
|
836
|
+
* colour: 'red'
|
|
837
|
+
* }
|
|
838
|
+
* }
|
|
839
|
+
* for (const p of Trees.traceByPath('jane.address.street', people)) {
|
|
840
|
+
* // { name: "jane", value: { address: { postcode: 1000,street: 'West St', city: 'Blahville' }, colour: 'red'} },
|
|
841
|
+
* // { name: "address", value: { postcode: 1000, street: 'West St', city: 'Blahville' } },
|
|
842
|
+
* // { name: "street", value: "West St" } }
|
|
843
|
+
* }
|
|
844
|
+
* ```
|
|
845
|
+
*
|
|
846
|
+
* Results stop when the path can't be followed any further.
|
|
847
|
+
* The last entry will have a name of the last sought path segment, and _undefined_ as its value.
|
|
848
|
+
*
|
|
849
|
+
* @param path Path to traverse
|
|
850
|
+
* @param node Starting node
|
|
851
|
+
* @param options Options for path traversal logic
|
|
852
|
+
* @returns
|
|
853
|
+
*/
|
|
854
|
+
function* traceRecordEntryByPath(path, node, options = {}) {
|
|
855
|
+
resultThrow(nullUndefTest(path, `path`), nullUndefTest(node, `node`));
|
|
856
|
+
const separator = options.separator ?? `.`;
|
|
857
|
+
const pathSplit = path.split(separator);
|
|
858
|
+
const ancestors = [];
|
|
859
|
+
for (const p of pathSplit) {
|
|
860
|
+
const entry = recordEntryChildByName(p, node);
|
|
861
|
+
if (!entry) {
|
|
862
|
+
yield {
|
|
863
|
+
name: p,
|
|
864
|
+
sourceValue: void 0,
|
|
865
|
+
nodeValue: void 0,
|
|
866
|
+
ancestors
|
|
867
|
+
};
|
|
868
|
+
return;
|
|
869
|
+
}
|
|
870
|
+
node = entry.sourceValue;
|
|
871
|
+
yield {
|
|
872
|
+
...entry,
|
|
873
|
+
ancestors: [...ancestors]
|
|
874
|
+
};
|
|
875
|
+
ancestors.push(p);
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
/**
|
|
879
|
+
* Generates a name for a node.
|
|
880
|
+
* Uses the 'name' property if it exists, otherwise uses `defaultName`
|
|
881
|
+
* @param node
|
|
882
|
+
* @param defaultName
|
|
883
|
+
* @returns
|
|
884
|
+
*/
|
|
885
|
+
function getNamedRecordEntry(node, defaultName = ``) {
|
|
886
|
+
if (`name` in node && `nodeValue` in node && `sourceValue` in node) return node;
|
|
887
|
+
if (`name` in node) return {
|
|
888
|
+
name: node.name,
|
|
889
|
+
nodeValue: node,
|
|
890
|
+
sourceValue: node
|
|
891
|
+
};
|
|
892
|
+
return {
|
|
893
|
+
name: defaultName,
|
|
894
|
+
nodeValue: node,
|
|
895
|
+
sourceValue: node
|
|
896
|
+
};
|
|
897
|
+
}
|
|
898
|
+
/**
|
|
899
|
+
* Yields numerical values based on the an input of objects and the property to use.
|
|
900
|
+
*
|
|
901
|
+
* ```js
|
|
902
|
+
* const data = [
|
|
903
|
+
* { size: 10 }, { size: 20 }, { size: 0 }
|
|
904
|
+
* ]
|
|
905
|
+
* [...enumerateNumericalValues(data, `size`)]; // [ 10, 20, 0 ]
|
|
906
|
+
* ```
|
|
907
|
+
*
|
|
908
|
+
* If any of objects has a non numerical value for `propertyName`, a TypeError is thrown.
|
|
909
|
+
* @param records
|
|
910
|
+
* @param propertyName
|
|
911
|
+
* @returns
|
|
912
|
+
*/
|
|
913
|
+
function* enumerateNumericalValues(records, propertyName) {
|
|
914
|
+
for (const rec of records) {
|
|
915
|
+
const fieldValue = rec[propertyName];
|
|
916
|
+
if (typeof fieldValue !== `number`) throw new TypeError(`Property value was not a number. Property: ${propertyName} Value: ${fieldValue} Type: ${typeof fieldValue}`);
|
|
917
|
+
yield fieldValue;
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
/**
|
|
921
|
+
* Merge corresponding objects from arrays. This is assuming objects at the same array indices are connected.
|
|
922
|
+
*
|
|
923
|
+
* Arrays must be the same length. When merging objects, the properties of later objects override those of earlier objects.
|
|
924
|
+
*
|
|
925
|
+
* ```js
|
|
926
|
+
* const a = [ { name: `jane`, age: 30 }, { name: `bob`, age: 40 } ];
|
|
927
|
+
* const b = [ { name: `fred`, colour: `red` }, { name: `johanne` } ];
|
|
928
|
+
* const c = [...zip(a, b)];
|
|
929
|
+
* // Yields:
|
|
930
|
+
* // [
|
|
931
|
+
* // { name: `fred`, age: 30, colour: `red` },
|
|
932
|
+
* // { name: `johanne`, age: 40 }
|
|
933
|
+
* // ]
|
|
934
|
+
* ```
|
|
935
|
+
* @param toMerge Arrays to merge
|
|
936
|
+
* @throws {TypeError} If either parameter is not an array
|
|
937
|
+
* @throws {TypeError} If the arrays are not of the same length
|
|
938
|
+
* @returns Generator of merged records
|
|
939
|
+
*/
|
|
940
|
+
function* zip$1(...toMerge) {
|
|
941
|
+
let len = -1;
|
|
942
|
+
for (let index = 0; index < toMerge.length; index++) {
|
|
943
|
+
if (!Array.isArray(toMerge[index])) throw new TypeError(`Value at index ${index} is not an array as expected`);
|
|
944
|
+
if (len === -1) len = toMerge[index].length;
|
|
945
|
+
else if (toMerge[index].length !== len) throw new TypeError(`Array length mismatch. Expected: ${len} Actual: ${toMerge[index].length} Array: ${index}`);
|
|
946
|
+
}
|
|
947
|
+
for (let index = 0; index < len; index++) yield merge(...toMerge.map((arr) => arr[index]));
|
|
948
|
+
}
|
|
949
|
+
var records_exports = /* @__PURE__ */ __exportAll({
|
|
950
|
+
changedProperties: () => changedProperties,
|
|
951
|
+
cloneFromFields: () => cloneFromFields,
|
|
952
|
+
compareArrays: () => compareArrays,
|
|
953
|
+
compareObjectData: () => compareObjectData,
|
|
954
|
+
compareObjectKeys: () => compareObjectKeys,
|
|
955
|
+
enumerateNumericalValues: () => enumerateNumericalValues,
|
|
956
|
+
getRecordEntryByPath: () => getRecordEntryByPath,
|
|
957
|
+
keysToNumbers: () => keysToNumbers,
|
|
958
|
+
mapObjectByObject: () => mapObjectByObject,
|
|
959
|
+
mapObjectKeys: () => mapObjectKeys,
|
|
960
|
+
mapObjectShallow: () => mapObjectShallow,
|
|
961
|
+
merge: () => merge,
|
|
962
|
+
mergeSameShape: () => mergeSameShape,
|
|
963
|
+
prefixProperties: () => prefixProperties,
|
|
964
|
+
prettyPrintEntries: () => prettyPrintEntries,
|
|
965
|
+
recordChildren: () => recordChildren,
|
|
966
|
+
recordEntriesDepthFirst: () => recordEntriesDepthFirst,
|
|
967
|
+
recordEntryPrettyPrint: () => recordEntryPrettyPrint,
|
|
968
|
+
removeCircularReferences: () => removeCircularReferences,
|
|
969
|
+
traceRecordEntryByPath: () => traceRecordEntryByPath,
|
|
970
|
+
zip: () => zip$1
|
|
971
|
+
});
|
|
972
|
+
/**
|
|
973
|
+
* Returns a {@link Continuously} that continually executes `callback` at `interval` rate.
|
|
974
|
+
*
|
|
975
|
+
* By default, first the sleep period happens and then the callback happens.
|
|
976
|
+
*
|
|
977
|
+
* Call `start` to begin/reset loop. The looping stops when `cancel` is called, or when `callback` returns _false_.
|
|
978
|
+
*
|
|
979
|
+
* @example
|
|
980
|
+
* Animation loop
|
|
981
|
+
* ```js
|
|
982
|
+
* const draw = () => {
|
|
983
|
+
* // Draw on canvas
|
|
984
|
+
* }
|
|
985
|
+
*
|
|
986
|
+
* // Run draw() synchronised with monitor refresh rate via `window.requestAnimationFrame`
|
|
987
|
+
* continuously(draw).start();
|
|
988
|
+
* ```
|
|
989
|
+
*
|
|
990
|
+
* @example
|
|
991
|
+
* With delay
|
|
992
|
+
* ```js
|
|
993
|
+
* const fn = () => {
|
|
994
|
+
* // Runs after one minute
|
|
995
|
+
* }
|
|
996
|
+
* const c = continuously(fn, { mins: 1 } );
|
|
997
|
+
* c.start(); // Runs `fn` every minute
|
|
998
|
+
* ```
|
|
999
|
+
*
|
|
1000
|
+
* @example
|
|
1001
|
+
* Control a 'continuously'
|
|
1002
|
+
* ```js
|
|
1003
|
+
* c.cancel(); // Stop the loop, cancelling any up-coming calls to `fn`
|
|
1004
|
+
* c.elapsedMs; // How many milliseconds have elapsed since start
|
|
1005
|
+
* c.ticks; // How many iterations of loop since start
|
|
1006
|
+
* c.interval; // Get/set speed of loop. Change kicks-in at next loop.
|
|
1007
|
+
* // Use .start() to reset to new interval immediately
|
|
1008
|
+
* ```
|
|
1009
|
+
*
|
|
1010
|
+
* Asynchronous callback functions are supported too:
|
|
1011
|
+
* ```js
|
|
1012
|
+
* continuously(async () => { ..});
|
|
1013
|
+
* ```
|
|
1014
|
+
*
|
|
1015
|
+
* The `callback` function can receive a few arguments:
|
|
1016
|
+
*
|
|
1017
|
+
* ```js
|
|
1018
|
+
* continuously( (ticks, elapsedMs) => {
|
|
1019
|
+
* // ticks: how many times loop has run
|
|
1020
|
+
* // elapsedMs: how long since last loop
|
|
1021
|
+
* }).start();
|
|
1022
|
+
* ```
|
|
1023
|
+
*
|
|
1024
|
+
* If the callback explicitly returns _false_, the loop will be cancelled.
|
|
1025
|
+
*
|
|
1026
|
+
* ```js
|
|
1027
|
+
* continuously(ticks => {
|
|
1028
|
+
* // Stop after 100 iterations
|
|
1029
|
+
* if (ticks > 100) return false;
|
|
1030
|
+
* }).start();
|
|
1031
|
+
* ```
|
|
1032
|
+
*
|
|
1033
|
+
* You can intercept the logic for calls to `start()` with `onStartCalled`. It can determine
|
|
1034
|
+
* whether the `start()` proceeds, if the loop is cancelled, or the whole thing disposed,
|
|
1035
|
+
* so it can't run any longer.
|
|
1036
|
+
*
|
|
1037
|
+
* ```js
|
|
1038
|
+
* continuously(callback, intervalMs, {
|
|
1039
|
+
* onStartCalled:(ticks, elapsedMs) => {
|
|
1040
|
+
* // Cancel the loop after 1000ms has elapsed
|
|
1041
|
+
* if (elapsedMs > 1000) return `cancel`;
|
|
1042
|
+
* }
|
|
1043
|
+
* }).start();
|
|
1044
|
+
* ```
|
|
1045
|
+
*
|
|
1046
|
+
* To run `callback` *before* the sleep happens, set `fireBeforeWait`:
|
|
1047
|
+
* ```js
|
|
1048
|
+
* continuously(callback, intervalMs, { fireBeforeWait: true });
|
|
1049
|
+
* ```
|
|
1050
|
+
* @param callback - Function to run. If it returns _false_, loop exits.
|
|
1051
|
+
* @param options - {@link ContinuouslyOpts ContinuouslyOpts}
|
|
1052
|
+
* @param interval - Speed of loop (default: 0)
|
|
1053
|
+
* @returns Instance to control looping.
|
|
1054
|
+
* @see Flow.timeout if you want to trigger something once.
|
|
1055
|
+
*/
|
|
1056
|
+
const continuously = (callback, interval = 0, options = {}) => {
|
|
1057
|
+
let intervalMs = intervalToMs(interval, 0);
|
|
1058
|
+
resultThrow(integerTest(intervalMs, `positive`, `interval`));
|
|
1059
|
+
const fireBeforeWait = options.fireBeforeWait ?? false;
|
|
1060
|
+
const onStartCalled = options.onStartCalled;
|
|
1061
|
+
const signal = options.signal;
|
|
1062
|
+
let disposed = false;
|
|
1063
|
+
let runState = `idle`;
|
|
1064
|
+
let startCount = 0;
|
|
1065
|
+
let startCountTotal = 0;
|
|
1066
|
+
let startedAt = performance.now();
|
|
1067
|
+
let intervalUsed = interval ?? 0;
|
|
1068
|
+
let cancelled = false;
|
|
1069
|
+
let currentTimer;
|
|
1070
|
+
const deschedule = () => {
|
|
1071
|
+
if (currentTimer === void 0) return;
|
|
1072
|
+
globalThis.clearTimeout(currentTimer);
|
|
1073
|
+
currentTimer = void 0;
|
|
1074
|
+
startCount = 0;
|
|
1075
|
+
startedAt = NaN;
|
|
1076
|
+
};
|
|
1077
|
+
const schedule = (scheduledCallback) => {
|
|
1078
|
+
if (intervalMs === 0) if (typeof requestAnimationFrame === `undefined`) currentTimer = globalThis.setTimeout(scheduledCallback, 0);
|
|
1079
|
+
else {
|
|
1080
|
+
currentTimer = void 0;
|
|
1081
|
+
requestAnimationFrame(scheduledCallback);
|
|
1082
|
+
}
|
|
1083
|
+
else currentTimer = globalThis.setTimeout(scheduledCallback, intervalMs);
|
|
1084
|
+
};
|
|
1085
|
+
const cancel = () => {
|
|
1086
|
+
if (cancelled) return;
|
|
1087
|
+
cancelled = true;
|
|
1088
|
+
if (runState === `idle`) return;
|
|
1089
|
+
runState = `idle`;
|
|
1090
|
+
deschedule();
|
|
1091
|
+
};
|
|
1092
|
+
const loop = async () => {
|
|
1093
|
+
if (signal?.aborted) runState = `idle`;
|
|
1094
|
+
if (runState === `idle`) return;
|
|
1095
|
+
runState = `running`;
|
|
1096
|
+
startCount++;
|
|
1097
|
+
startCountTotal++;
|
|
1098
|
+
const valueOrPromise = callback(startCount, performance.now() - startedAt);
|
|
1099
|
+
const value = typeof valueOrPromise === `object` ? await valueOrPromise : valueOrPromise;
|
|
1100
|
+
if (cancelled) return;
|
|
1101
|
+
runState = `scheduled`;
|
|
1102
|
+
if (value !== void 0 && !value) {
|
|
1103
|
+
cancel();
|
|
1104
|
+
return;
|
|
1105
|
+
}
|
|
1106
|
+
if (cancelled) return;
|
|
1107
|
+
schedule(loop);
|
|
1108
|
+
};
|
|
1109
|
+
const start = () => {
|
|
1110
|
+
if (disposed) throw new Error(`Disposed`);
|
|
1111
|
+
cancelled = false;
|
|
1112
|
+
if (onStartCalled !== void 0) switch (onStartCalled(startCount, performance.now() - startedAt)) {
|
|
1113
|
+
case `cancel`:
|
|
1114
|
+
cancel();
|
|
1115
|
+
return;
|
|
1116
|
+
case `reset`:
|
|
1117
|
+
reset();
|
|
1118
|
+
return;
|
|
1119
|
+
case `dispose`:
|
|
1120
|
+
disposed = true;
|
|
1121
|
+
cancel();
|
|
1122
|
+
return;
|
|
1123
|
+
}
|
|
1124
|
+
if (runState === `idle`) {
|
|
1125
|
+
startCount = 0;
|
|
1126
|
+
startedAt = performance.now();
|
|
1127
|
+
runState = `scheduled`;
|
|
1128
|
+
if (fireBeforeWait) loop();
|
|
1129
|
+
else schedule(loop);
|
|
1130
|
+
}
|
|
1131
|
+
};
|
|
1132
|
+
const reset = () => {
|
|
1133
|
+
if (disposed) throw new Error(`Disposed`);
|
|
1134
|
+
cancelled = false;
|
|
1135
|
+
startCount = 0;
|
|
1136
|
+
startedAt = NaN;
|
|
1137
|
+
if (runState !== `idle`) cancel();
|
|
1138
|
+
start();
|
|
1139
|
+
};
|
|
1140
|
+
return {
|
|
1141
|
+
start,
|
|
1142
|
+
reset,
|
|
1143
|
+
cancel,
|
|
1144
|
+
get interval() {
|
|
1145
|
+
return intervalUsed;
|
|
1146
|
+
},
|
|
1147
|
+
get runState() {
|
|
1148
|
+
return runState;
|
|
1149
|
+
},
|
|
1150
|
+
get startCountTotal() {
|
|
1151
|
+
return startCountTotal;
|
|
1152
|
+
},
|
|
1153
|
+
get startCount() {
|
|
1154
|
+
return startCount;
|
|
1155
|
+
},
|
|
1156
|
+
set interval(interval) {
|
|
1157
|
+
const ms = intervalToMs(interval, 0);
|
|
1158
|
+
resultThrow(integerTest(ms, `positive`, `interval`));
|
|
1159
|
+
intervalMs = ms;
|
|
1160
|
+
intervalUsed = interval;
|
|
1161
|
+
},
|
|
1162
|
+
get isDisposed() {
|
|
1163
|
+
return disposed;
|
|
1164
|
+
},
|
|
1165
|
+
get elapsedMs() {
|
|
1166
|
+
return performance.now() - startedAt;
|
|
1167
|
+
}
|
|
1168
|
+
};
|
|
1169
|
+
};
|
|
1170
|
+
/**
|
|
1171
|
+
* Compares the values of two iterables, returning a list
|
|
1172
|
+
* of items they have in common and those unique in `a` or `b`.
|
|
1173
|
+
* Ignores ordering of values, and is NOT recursive.
|
|
1174
|
+
*
|
|
1175
|
+
* ```js
|
|
1176
|
+
* const a = ['apples', 'oranges', 'pears' ]
|
|
1177
|
+
* const b = ['pears', 'kiwis', 'bananas' ];
|
|
1178
|
+
*
|
|
1179
|
+
* const r = compareValuesShallow(a, b);
|
|
1180
|
+
* r.shared; // [ 'pears' ]
|
|
1181
|
+
* r.a; // [ 'apples', 'oranges' ]
|
|
1182
|
+
* r.b; // [ 'kiwis', 'bananas' ]
|
|
1183
|
+
* ```
|
|
1184
|
+
*
|
|
1185
|
+
* By default uses === semantics for comparison.
|
|
1186
|
+
* @param a
|
|
1187
|
+
* @param b
|
|
1188
|
+
* @param eq
|
|
1189
|
+
* @returns
|
|
1190
|
+
*/
|
|
1191
|
+
const compareIterableValuesShallow = (a, b, eq = isEqualDefault) => {
|
|
1192
|
+
const shared = [];
|
|
1193
|
+
const aUnique = [];
|
|
1194
|
+
const bUnique = [];
|
|
1195
|
+
for (const elementOfA of a) {
|
|
1196
|
+
let seenInB = false;
|
|
1197
|
+
for (const elementOfB of b) if (eq(elementOfA, elementOfB)) {
|
|
1198
|
+
seenInB = true;
|
|
1199
|
+
break;
|
|
1200
|
+
}
|
|
1201
|
+
if (seenInB) shared.push(elementOfA);
|
|
1202
|
+
else aUnique.push(elementOfA);
|
|
1203
|
+
}
|
|
1204
|
+
for (const elementOfB of b) {
|
|
1205
|
+
let seenInA = false;
|
|
1206
|
+
for (const elementOfA of a) if (eq(elementOfB, elementOfA)) seenInA = true;
|
|
1207
|
+
if (!seenInA) bUnique.push(elementOfB);
|
|
1208
|
+
}
|
|
1209
|
+
return {
|
|
1210
|
+
shared,
|
|
1211
|
+
isSame: aUnique.length === 0 && bUnique.length === 0,
|
|
1212
|
+
a: aUnique,
|
|
1213
|
+
b: bUnique
|
|
1214
|
+
};
|
|
1215
|
+
};
|
|
1216
|
+
/**
|
|
1217
|
+
* Return the millisecond value of an Interval.
|
|
1218
|
+
*
|
|
1219
|
+
* ```js
|
|
1220
|
+
* intervalToMs(100); // 100
|
|
1221
|
+
* intervalToMs({ millis: 100 }); // 100
|
|
1222
|
+
* ```
|
|
1223
|
+
*
|
|
1224
|
+
* Use `defaultNumber` to return a default in the case of
|
|
1225
|
+
* _undefined_ or invalid input.
|
|
1226
|
+
*
|
|
1227
|
+
* ```js
|
|
1228
|
+
* intervalToMs(undefined); // throws error
|
|
1229
|
+
* intervalToMs(undefined, 100); // 100
|
|
1230
|
+
* ```
|
|
1231
|
+
*
|
|
1232
|
+
* If no default is provided, an exception is thrown.
|
|
1233
|
+
* @param interval Interval
|
|
1234
|
+
* @param defaultNumber Default value if `interval` is _undefined_ or invalid
|
|
1235
|
+
* @returns Milliseconds
|
|
1236
|
+
*/
|
|
1237
|
+
function intervalToMs(interval, defaultNumber) {
|
|
1238
|
+
if (isInterval(interval)) {
|
|
1239
|
+
if (typeof interval === `number`) return interval;
|
|
1240
|
+
let ms = interval.millis ?? 0;
|
|
1241
|
+
ms += (interval.hours ?? 0) * 60 * 60 * 1e3;
|
|
1242
|
+
ms += (interval.mins ?? 0) * 60 * 1e3;
|
|
1243
|
+
ms += (interval.secs ?? 0) * 1e3;
|
|
1244
|
+
return ms;
|
|
1245
|
+
} else {
|
|
1246
|
+
if (typeof defaultNumber !== `undefined`) return defaultNumber;
|
|
1247
|
+
throw new Error(`Not a valid interval: ${JSON.stringify(interval)}`);
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1250
|
+
/**
|
|
1251
|
+
* Returns _true_ if `interval` matches the {@link Interval} type.
|
|
1252
|
+
* @param interval
|
|
1253
|
+
* @returns _True_ if `interval` is an {@link Interval}.
|
|
1254
|
+
*/
|
|
1255
|
+
function isInterval(interval) {
|
|
1256
|
+
if (typeof interval === `undefined`) return false;
|
|
1257
|
+
if (interval === null) return false;
|
|
1258
|
+
if (typeof interval === `number`) {
|
|
1259
|
+
if (Number.isNaN(interval)) return false;
|
|
1260
|
+
if (!Number.isFinite(interval)) return false;
|
|
1261
|
+
return true;
|
|
1262
|
+
}
|
|
1263
|
+
if (typeof interval !== `object`) return false;
|
|
1264
|
+
const hasMillis = `millis` in interval;
|
|
1265
|
+
const hasSecs = `secs` in interval;
|
|
1266
|
+
const hasMins = `mins` in interval;
|
|
1267
|
+
const hasHours = `hours` in interval;
|
|
1268
|
+
if (hasMillis && !numberTest(interval.millis).success) return false;
|
|
1269
|
+
if (hasSecs && !numberTest(interval.secs).success) return false;
|
|
1270
|
+
if (hasMins && !numberTest(interval.mins).success) return false;
|
|
1271
|
+
if (hasHours && !numberTest(interval.hours).success) return false;
|
|
1272
|
+
if (hasMillis || hasSecs || hasHours || hasMins) return true;
|
|
1273
|
+
return false;
|
|
1274
|
+
}
|
|
1275
|
+
/**
|
|
1276
|
+
* Returns a function that resolves `object`.
|
|
1277
|
+
*
|
|
1278
|
+
* Use {@link resolveFields} to resolve an object directly.
|
|
1279
|
+
* @param object
|
|
1280
|
+
* @returns
|
|
1281
|
+
*/
|
|
1282
|
+
if (typeof window === `undefined` || !(`requestAnimationFrame` in window)) {
|
|
1283
|
+
if (typeof window === `undefined`) globalThis.requestAnimationFrame = (callback) => {
|
|
1284
|
+
setTimeout(callback, 1);
|
|
1285
|
+
};
|
|
1286
|
+
}
|
|
1287
|
+
//#endregion
|
|
1288
|
+
export { toStringAbbreviate as a, isEqualDefault as c, records_exports as i, isEqualValueDefault as l, intervalToMs as n, defaultComparer as o, isPrimitive as r, getOrGenerateSync as s, continuously as t, isEqualValueIgnoreOrder as u };
|
|
1289
|
+
|
|
1290
|
+
//# sourceMappingURL=dist-By5URG0Y.js.map
|