@visactor/vgrammar-core 0.7.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/README.md +160 -0
- package/README.zh-CN.md +11 -0
- package/cjs/component/axis.d.ts +26 -0
- package/cjs/component/axis.js +164 -0
- package/cjs/component/axis.js.map +1 -0
- package/cjs/component/crosshair.d.ts +50 -0
- package/cjs/component/crosshair.js +281 -0
- package/cjs/component/crosshair.js.map +1 -0
- package/cjs/component/datazoom.d.ts +19 -0
- package/cjs/component/datazoom.js +166 -0
- package/cjs/component/datazoom.js.map +1 -0
- package/cjs/component/grid.d.ts +27 -0
- package/cjs/component/grid.js +190 -0
- package/cjs/component/grid.js.map +1 -0
- package/cjs/component/index.d.ts +11 -0
- package/cjs/component/index.js +105 -0
- package/cjs/component/index.js.map +1 -0
- package/cjs/component/label.d.ts +19 -0
- package/cjs/component/label.js +121 -0
- package/cjs/component/label.js.map +1 -0
- package/cjs/component/legend.d.ts +26 -0
- package/cjs/component/legend.js +170 -0
- package/cjs/component/legend.js.map +1 -0
- package/cjs/component/player.d.ts +25 -0
- package/cjs/component/player.js +138 -0
- package/cjs/component/player.js.map +1 -0
- package/cjs/component/scale.d.ts +8 -0
- package/cjs/component/scale.js +25 -0
- package/cjs/component/scale.js.map +1 -0
- package/cjs/component/scrollbar.d.ts +23 -0
- package/cjs/component/scrollbar.js +187 -0
- package/cjs/component/scrollbar.js.map +1 -0
- package/cjs/component/slider.d.ts +19 -0
- package/cjs/component/slider.js +86 -0
- package/cjs/component/slider.js.map +1 -0
- package/cjs/component/title.d.ts +15 -0
- package/cjs/component/title.js +56 -0
- package/cjs/component/title.js.map +1 -0
- package/cjs/component/tooltip.d.ts +62 -0
- package/cjs/component/tooltip.js +305 -0
- package/cjs/component/tooltip.js.map +1 -0
- package/cjs/core/factory.d.ts +35 -0
- package/cjs/core/factory.js +73 -0
- package/cjs/core/factory.js.map +1 -0
- package/cjs/glyph/boxplot.d.ts +10 -0
- package/cjs/glyph/boxplot.js +418 -0
- package/cjs/glyph/boxplot.js.map +1 -0
- package/cjs/glyph/index.d.ts +7 -0
- package/cjs/glyph/index.js +64 -0
- package/cjs/glyph/index.js.map +1 -0
- package/cjs/glyph/link-path.d.ts +7 -0
- package/cjs/glyph/link-path.js +138 -0
- package/cjs/glyph/link-path.js.map +1 -0
- package/cjs/glyph/ripple.d.ts +1 -0
- package/cjs/glyph/ripple.js +44 -0
- package/cjs/glyph/ripple.js.map +1 -0
- package/cjs/glyph/tree-path.d.ts +7 -0
- package/cjs/glyph/tree-path.js +152 -0
- package/cjs/glyph/tree-path.js.map +1 -0
- package/cjs/glyph/violin.d.ts +1 -0
- package/cjs/glyph/violin.js +165 -0
- package/cjs/glyph/violin.js.map +1 -0
- package/cjs/glyph/wave.d.ts +1 -0
- package/cjs/glyph/wave.js +67 -0
- package/cjs/glyph/wave.js.map +1 -0
- package/cjs/graph/animation/animate.d.ts +48 -0
- package/cjs/graph/animation/animate.js +250 -0
- package/cjs/graph/animation/animate.js.map +1 -0
- package/cjs/graph/animation/animation/clip.d.ts +4 -0
- package/cjs/graph/animation/animation/clip.js +54 -0
- package/cjs/graph/animation/animation/clip.js.map +1 -0
- package/cjs/graph/animation/animation/fade.d.ts +4 -0
- package/cjs/graph/animation/animation/fade.js +42 -0
- package/cjs/graph/animation/animation/fade.js.map +1 -0
- package/cjs/graph/animation/animation/grow-cartesian.d.ts +7 -0
- package/cjs/graph/animation/animation/grow-cartesian.js +288 -0
- package/cjs/graph/animation/animation/grow-cartesian.js.map +1 -0
- package/cjs/graph/animation/animation/grow-interval.d.ts +3 -0
- package/cjs/graph/animation/animation/grow-interval.js +194 -0
- package/cjs/graph/animation/animation/grow-interval.js.map +1 -0
- package/cjs/graph/animation/animation/grow-points.d.ts +7 -0
- package/cjs/graph/animation/animation/grow-points.js +118 -0
- package/cjs/graph/animation/animation/grow-points.js.map +1 -0
- package/cjs/graph/animation/animation/grow-polar.d.ts +5 -0
- package/cjs/graph/animation/animation/grow-polar.js +164 -0
- package/cjs/graph/animation/animation/grow-polar.js.map +1 -0
- package/cjs/graph/animation/animation/index.d.ts +11 -0
- package/cjs/graph/animation/animation/index.js +191 -0
- package/cjs/graph/animation/animation/index.js.map +1 -0
- package/cjs/graph/animation/animation/move.d.ts +3 -0
- package/cjs/graph/animation/animation/move.js +90 -0
- package/cjs/graph/animation/animation/move.js.map +1 -0
- package/cjs/graph/animation/animation/rotate.d.ts +3 -0
- package/cjs/graph/animation/animation/rotate.js +42 -0
- package/cjs/graph/animation/animation/rotate.js.map +1 -0
- package/cjs/graph/animation/animation/scale.d.ts +3 -0
- package/cjs/graph/animation/animation/scale.js +84 -0
- package/cjs/graph/animation/animation/scale.js.map +1 -0
- package/cjs/graph/animation/animation/update.d.ts +6 -0
- package/cjs/graph/animation/animation/update.js +22 -0
- package/cjs/graph/animation/animation/update.js.map +1 -0
- package/cjs/graph/animation/animator.d.ts +26 -0
- package/cjs/graph/animation/animator.js +88 -0
- package/cjs/graph/animation/animator.js.map +1 -0
- package/cjs/graph/animation/arranger.d.ts +13 -0
- package/cjs/graph/animation/arranger.js +38 -0
- package/cjs/graph/animation/arranger.js.map +1 -0
- package/cjs/graph/animation/attribute.d.ts +27 -0
- package/cjs/graph/animation/attribute.js +124 -0
- package/cjs/graph/animation/attribute.js.map +1 -0
- package/cjs/graph/animation/config.d.ts +5 -0
- package/cjs/graph/animation/config.js +92 -0
- package/cjs/graph/animation/config.js.map +1 -0
- package/cjs/graph/animation/morph.d.ts +12 -0
- package/cjs/graph/animation/morph.js +174 -0
- package/cjs/graph/animation/morph.js.map +1 -0
- package/cjs/graph/attributes/common.d.ts +2 -0
- package/cjs/graph/attributes/common.js +22 -0
- package/cjs/graph/attributes/common.js.map +1 -0
- package/cjs/graph/attributes/helpers.d.ts +17 -0
- package/cjs/graph/attributes/helpers.js +86 -0
- package/cjs/graph/attributes/helpers.js.map +1 -0
- package/cjs/graph/attributes/index.d.ts +10 -0
- package/cjs/graph/attributes/index.js +257 -0
- package/cjs/graph/attributes/index.js.map +1 -0
- package/cjs/graph/canvas-renderer.d.ts +34 -0
- package/cjs/graph/canvas-renderer.js +121 -0
- package/cjs/graph/canvas-renderer.js.map +1 -0
- package/cjs/graph/constants.d.ts +23 -0
- package/cjs/graph/constants.js +21 -0
- package/cjs/graph/constants.js.map +1 -0
- package/cjs/graph/element.d.ts +66 -0
- package/cjs/graph/element.js +297 -0
- package/cjs/graph/element.js.map +1 -0
- package/cjs/graph/enums.d.ts +153 -0
- package/cjs/graph/enums.js +85 -0
- package/cjs/graph/enums.js.map +1 -0
- package/cjs/graph/glyph-element.d.ts +53 -0
- package/cjs/graph/glyph-element.js +202 -0
- package/cjs/graph/glyph-element.js.map +1 -0
- package/cjs/graph/index.d.ts +3 -0
- package/cjs/graph/index.js +44 -0
- package/cjs/graph/index.js.map +1 -0
- package/cjs/graph/layout/grid.d.ts +3 -0
- package/cjs/graph/layout/grid.js +75 -0
- package/cjs/graph/layout/grid.js.map +1 -0
- package/cjs/graph/layout/layout.d.ts +3 -0
- package/cjs/graph/layout/layout.js +33 -0
- package/cjs/graph/layout/layout.js.map +1 -0
- package/cjs/graph/layout/relative.d.ts +3 -0
- package/cjs/graph/layout/relative.js +86 -0
- package/cjs/graph/layout/relative.js.map +1 -0
- package/cjs/graph/mark/differ.d.ts +20 -0
- package/cjs/graph/mark/differ.js +110 -0
- package/cjs/graph/mark/differ.js.map +1 -0
- package/cjs/graph/mark/encode.d.ts +10 -0
- package/cjs/graph/mark/encode.js +95 -0
- package/cjs/graph/mark/encode.js.map +1 -0
- package/cjs/graph/mark/large-rects.d.ts +10 -0
- package/cjs/graph/mark/large-rects.js +31 -0
- package/cjs/graph/mark/large-rects.js.map +1 -0
- package/cjs/graph/mark/large-symbols.d.ts +11 -0
- package/cjs/graph/mark/large-symbols.js +33 -0
- package/cjs/graph/mark/large-symbols.js.map +1 -0
- package/cjs/graph/mark-tree.d.ts +2 -0
- package/cjs/graph/mark-tree.js +21 -0
- package/cjs/graph/mark-tree.js.map +1 -0
- package/cjs/graph/util/element.d.ts +2 -0
- package/cjs/graph/util/element.js +10 -0
- package/cjs/graph/util/element.js.map +1 -0
- package/cjs/graph/util/env.d.ts +2 -0
- package/cjs/graph/util/env.js +14 -0
- package/cjs/graph/util/env.js.map +1 -0
- package/cjs/graph/util/events-extend.d.ts +5 -0
- package/cjs/graph/util/events-extend.js +18 -0
- package/cjs/graph/util/events-extend.js.map +1 -0
- package/cjs/graph/util/graphic.d.ts +9 -0
- package/cjs/graph/util/graphic.js +59 -0
- package/cjs/graph/util/graphic.js.map +1 -0
- package/cjs/graph/util/point.d.ts +1 -0
- package/cjs/graph/util/point.js +75 -0
- package/cjs/graph/util/point.js.map +1 -0
- package/cjs/index.d.ts +14 -0
- package/cjs/index.js +111 -0
- package/cjs/index.js.map +1 -0
- package/cjs/parse/coordinate.d.ts +7 -0
- package/cjs/parse/coordinate.js +70 -0
- package/cjs/parse/coordinate.js.map +1 -0
- package/cjs/parse/event.d.ts +8 -0
- package/cjs/parse/event.js +33 -0
- package/cjs/parse/event.js.map +1 -0
- package/cjs/parse/mark.d.ts +4 -0
- package/cjs/parse/mark.js +25 -0
- package/cjs/parse/mark.js.map +1 -0
- package/cjs/parse/option.d.ts +3 -0
- package/cjs/parse/option.js +19 -0
- package/cjs/parse/option.js.map +1 -0
- package/cjs/parse/scale.d.ts +8 -0
- package/cjs/parse/scale.js +365 -0
- package/cjs/parse/scale.js.map +1 -0
- package/cjs/parse/transform.d.ts +5 -0
- package/cjs/parse/transform.js +103 -0
- package/cjs/parse/transform.js.map +1 -0
- package/cjs/parse/util.d.ts +13 -0
- package/cjs/parse/util.js +82 -0
- package/cjs/parse/util.js.map +1 -0
- package/cjs/parse/view.d.ts +17 -0
- package/cjs/parse/view.js +108 -0
- package/cjs/parse/view.js.map +1 -0
- package/cjs/semantic-marks/cell.d.ts +13 -0
- package/cjs/semantic-marks/cell.js +61 -0
- package/cjs/semantic-marks/cell.js.map +1 -0
- package/cjs/semantic-marks/interval.d.ts +14 -0
- package/cjs/semantic-marks/interval.js +80 -0
- package/cjs/semantic-marks/interval.js.map +1 -0
- package/cjs/semantic-marks/text.d.ts +10 -0
- package/cjs/semantic-marks/text.js +25 -0
- package/cjs/semantic-marks/text.js.map +1 -0
- package/cjs/theme/common/component.d.ts +15 -0
- package/cjs/theme/common/component.js +493 -0
- package/cjs/theme/common/component.js.map +1 -0
- package/cjs/theme/common/constants.d.ts +1 -0
- package/cjs/theme/common/constants.js +6 -0
- package/cjs/theme/common/constants.js.map +1 -0
- package/cjs/theme/common/mark.d.ts +2 -0
- package/cjs/theme/common/mark.js +15 -0
- package/cjs/theme/common/mark.js.map +1 -0
- package/cjs/theme/dark.d.ts +2 -0
- package/cjs/theme/dark.js +94 -0
- package/cjs/theme/dark.js.map +1 -0
- package/cjs/theme/default.d.ts +2 -0
- package/cjs/theme/default.js +18 -0
- package/cjs/theme/default.js.map +1 -0
- package/cjs/theme/theme-manager.d.ts +8 -0
- package/cjs/theme/theme-manager.js +26 -0
- package/cjs/theme/theme-manager.js.map +1 -0
- package/cjs/transforms/data/bin.d.ts +2 -0
- package/cjs/transforms/data/bin.js +21 -0
- package/cjs/transforms/data/bin.js.map +1 -0
- package/cjs/transforms/data/circular-relation.d.ts +2 -0
- package/cjs/transforms/data/circular-relation.js +56 -0
- package/cjs/transforms/data/circular-relation.js.map +1 -0
- package/cjs/transforms/data/contour.d.ts +2 -0
- package/cjs/transforms/data/contour.js +115 -0
- package/cjs/transforms/data/contour.js.map +1 -0
- package/cjs/transforms/data/filter.d.ts +2 -0
- package/cjs/transforms/data/filter.js +10 -0
- package/cjs/transforms/data/filter.js.map +1 -0
- package/cjs/transforms/data/fold.d.ts +2 -0
- package/cjs/transforms/data/fold.js +24 -0
- package/cjs/transforms/data/fold.js.map +1 -0
- package/cjs/transforms/data/funnel.d.ts +2 -0
- package/cjs/transforms/data/funnel.js +25 -0
- package/cjs/transforms/data/funnel.js.map +1 -0
- package/cjs/transforms/data/join.d.ts +2 -0
- package/cjs/transforms/data/join.js +33 -0
- package/cjs/transforms/data/join.js.map +1 -0
- package/cjs/transforms/data/kde.d.ts +2 -0
- package/cjs/transforms/data/kde.js +90 -0
- package/cjs/transforms/data/kde.js.map +1 -0
- package/cjs/transforms/data/map.d.ts +2 -0
- package/cjs/transforms/data/map.js +23 -0
- package/cjs/transforms/data/map.js.map +1 -0
- package/cjs/transforms/data/pick.d.ts +2 -0
- package/cjs/transforms/data/pick.js +20 -0
- package/cjs/transforms/data/pick.js.map +1 -0
- package/cjs/transforms/data/pie.d.ts +2 -0
- package/cjs/transforms/data/pie.js +24 -0
- package/cjs/transforms/data/pie.js.map +1 -0
- package/cjs/transforms/data/range.d.ts +4 -0
- package/cjs/transforms/data/range.js +15 -0
- package/cjs/transforms/data/range.js.map +1 -0
- package/cjs/transforms/data/sort.d.ts +2 -0
- package/cjs/transforms/data/sort.js +17 -0
- package/cjs/transforms/data/sort.js.map +1 -0
- package/cjs/transforms/data/stack.d.ts +2 -0
- package/cjs/transforms/data/stack.js +74 -0
- package/cjs/transforms/data/stack.js.map +1 -0
- package/cjs/transforms/data/unfold.d.ts +2 -0
- package/cjs/transforms/data/unfold.js +49 -0
- package/cjs/transforms/data/unfold.js.map +1 -0
- package/cjs/transforms/index.d.ts +23 -0
- package/cjs/transforms/index.js +213 -0
- package/cjs/transforms/index.js.map +1 -0
- package/cjs/transforms/mark/dodge.d.ts +2 -0
- package/cjs/transforms/mark/dodge.js +81 -0
- package/cjs/transforms/mark/dodge.js.map +1 -0
- package/cjs/transforms/mark/jitter.d.ts +4 -0
- package/cjs/transforms/mark/jitter.js +53 -0
- package/cjs/transforms/mark/jitter.js.map +1 -0
- package/cjs/transforms/mark/lttb-sample.d.ts +2 -0
- package/cjs/transforms/mark/lttb-sample.js +68 -0
- package/cjs/transforms/mark/lttb-sample.js.map +1 -0
- package/cjs/transforms/mark/mark-overlap.d.ts +2 -0
- package/cjs/transforms/mark/mark-overlap.js +79 -0
- package/cjs/transforms/mark/mark-overlap.js.map +1 -0
- package/cjs/transforms/mark/symmetry.d.ts +2 -0
- package/cjs/transforms/mark/symmetry.js +25 -0
- package/cjs/transforms/mark/symmetry.js.map +1 -0
- package/cjs/transforms/util/util.d.ts +5 -0
- package/cjs/transforms/util/util.js +41 -0
- package/cjs/transforms/util/util.js.map +1 -0
- package/cjs/transforms/view/identifier.d.ts +2 -0
- package/cjs/transforms/view/identifier.js +17 -0
- package/cjs/transforms/view/identifier.js.map +1 -0
- package/cjs/types/animate.d.ts +224 -0
- package/cjs/types/animate.js +6 -0
- package/cjs/types/animate.js.map +1 -0
- package/cjs/types/base.d.ts +36 -0
- package/cjs/types/base.js +6 -0
- package/cjs/types/base.js.map +1 -0
- package/cjs/types/component.d.ts +240 -0
- package/cjs/types/component.js +6 -0
- package/cjs/types/component.js.map +1 -0
- package/cjs/types/coordinate.d.ts +15 -0
- package/cjs/types/coordinate.js +6 -0
- package/cjs/types/coordinate.js.map +1 -0
- package/cjs/types/data.d.ts +55 -0
- package/cjs/types/data.js +5 -0
- package/cjs/types/data.js.map +1 -0
- package/cjs/types/dataflow.d.ts +13 -0
- package/cjs/types/dataflow.js +6 -0
- package/cjs/types/dataflow.js.map +1 -0
- package/cjs/types/element.d.ts +117 -0
- package/cjs/types/element.js +6 -0
- package/cjs/types/element.js.map +1 -0
- package/cjs/types/event.d.ts +58 -0
- package/cjs/types/event.js +6 -0
- package/cjs/types/event.js.map +1 -0
- package/cjs/types/glyph.d.ts +29 -0
- package/cjs/types/glyph.js +6 -0
- package/cjs/types/glyph.js.map +1 -0
- package/cjs/types/grammar.d.ts +184 -0
- package/cjs/types/grammar.js +6 -0
- package/cjs/types/grammar.js.map +1 -0
- package/cjs/types/hooks.d.ts +45 -0
- package/cjs/types/hooks.js +6 -0
- package/cjs/types/hooks.js.map +1 -0
- package/cjs/types/index.d.ts +22 -0
- package/cjs/types/index.js +31 -0
- package/cjs/types/index.js.map +1 -0
- package/cjs/types/layout.d.ts +5 -0
- package/cjs/types/layout.js +6 -0
- package/cjs/types/layout.js.map +1 -0
- package/cjs/types/mark.d.ts +344 -0
- package/cjs/types/mark.js +6 -0
- package/cjs/types/mark.js.map +1 -0
- package/cjs/types/morph.d.ts +29 -0
- package/cjs/types/morph.js +6 -0
- package/cjs/types/morph.js.map +1 -0
- package/cjs/types/plot.d.ts +326 -0
- package/cjs/types/plot.js +6 -0
- package/cjs/types/plot.js.map +1 -0
- package/cjs/types/projection.d.ts +61 -0
- package/cjs/types/projection.js +6 -0
- package/cjs/types/projection.js.map +1 -0
- package/cjs/types/renderer.d.ts +19 -0
- package/cjs/types/renderer.js +6 -0
- package/cjs/types/renderer.js.map +1 -0
- package/cjs/types/scale.d.ts +111 -0
- package/cjs/types/scale.js +6 -0
- package/cjs/types/scale.js.map +1 -0
- package/cjs/types/signal.d.ts +20 -0
- package/cjs/types/signal.js +6 -0
- package/cjs/types/signal.js.map +1 -0
- package/cjs/types/theme.d.ts +41 -0
- package/cjs/types/theme.js +6 -0
- package/cjs/types/theme.js.map +1 -0
- package/cjs/types/transform.d.ts +291 -0
- package/cjs/types/transform.js +6 -0
- package/cjs/types/transform.js.map +1 -0
- package/cjs/types/view.d.ts +217 -0
- package/cjs/types/view.js +6 -0
- package/cjs/types/view.js.map +1 -0
- package/cjs/util/data.d.ts +3 -0
- package/cjs/util/data.js +64 -0
- package/cjs/util/data.js.map +1 -0
- package/cjs/util/grammar-heap.d.ts +14 -0
- package/cjs/util/grammar-heap.js +66 -0
- package/cjs/util/grammar-heap.js.map +1 -0
- package/cjs/util/text.d.ts +19 -0
- package/cjs/util/text.js +32 -0
- package/cjs/util/text.js.map +1 -0
- package/cjs/util/unique-list.d.ts +12 -0
- package/cjs/util/unique-list.js +37 -0
- package/cjs/util/unique-list.js.map +1 -0
- package/cjs/view/View.d.ts +157 -0
- package/cjs/view/View.js +800 -0
- package/cjs/view/View.js.map +1 -0
- package/cjs/view/animate.d.ts +20 -0
- package/cjs/view/animate.js +106 -0
- package/cjs/view/animate.js.map +1 -0
- package/cjs/view/component.d.ts +26 -0
- package/cjs/view/component.js +64 -0
- package/cjs/view/component.js.map +1 -0
- package/cjs/view/constants.d.ts +17 -0
- package/cjs/view/constants.js +13 -0
- package/cjs/view/constants.js.map +1 -0
- package/cjs/view/coordinate.d.ts +23 -0
- package/cjs/view/coordinate.js +59 -0
- package/cjs/view/coordinate.js.map +1 -0
- package/cjs/view/data.d.ts +37 -0
- package/cjs/view/data.js +198 -0
- package/cjs/view/data.js.map +1 -0
- package/cjs/view/dataflow.d.ts +32 -0
- package/cjs/view/dataflow.js +146 -0
- package/cjs/view/dataflow.js.map +1 -0
- package/cjs/view/events.d.ts +4 -0
- package/cjs/view/events.js +34 -0
- package/cjs/view/events.js.map +1 -0
- package/cjs/view/glyph-meta.d.ts +29 -0
- package/cjs/view/glyph-meta.js +45 -0
- package/cjs/view/glyph-meta.js.map +1 -0
- package/cjs/view/glyph.d.ts +14 -0
- package/cjs/view/glyph.js +29 -0
- package/cjs/view/glyph.js.map +1 -0
- package/cjs/view/grammar-base.d.ts +46 -0
- package/cjs/view/grammar-base.js +171 -0
- package/cjs/view/grammar-base.js.map +1 -0
- package/cjs/view/grammar-record.d.ts +39 -0
- package/cjs/view/grammar-record.js +180 -0
- package/cjs/view/grammar-record.js.map +1 -0
- package/cjs/view/group.d.ts +13 -0
- package/cjs/view/group.js +39 -0
- package/cjs/view/group.js.map +1 -0
- package/cjs/view/index.d.ts +1 -0
- package/cjs/view/index.js +21 -0
- package/cjs/view/index.js.map +1 -0
- package/cjs/view/mark.d.ts +112 -0
- package/cjs/view/mark.js +600 -0
- package/cjs/view/mark.js.map +1 -0
- package/cjs/view/scale.d.ts +26 -0
- package/cjs/view/scale.js +86 -0
- package/cjs/view/scale.js.map +1 -0
- package/cjs/view/signal.d.ts +18 -0
- package/cjs/view/signal.js +56 -0
- package/cjs/view/signal.js.map +1 -0
- package/es/component/axis.d.ts +26 -0
- package/es/component/axis.js +162 -0
- package/es/component/axis.js.map +1 -0
- package/es/component/crosshair.d.ts +50 -0
- package/es/component/crosshair.js +275 -0
- package/es/component/crosshair.js.map +1 -0
- package/es/component/datazoom.d.ts +19 -0
- package/es/component/datazoom.js +161 -0
- package/es/component/datazoom.js.map +1 -0
- package/es/component/grid.d.ts +27 -0
- package/es/component/grid.js +193 -0
- package/es/component/grid.js.map +1 -0
- package/es/component/index.d.ts +11 -0
- package/es/component/index.js +22 -0
- package/es/component/index.js.map +1 -0
- package/es/component/label.d.ts +19 -0
- package/es/component/label.js +124 -0
- package/es/component/label.js.map +1 -0
- package/es/component/legend.d.ts +26 -0
- package/es/component/legend.js +169 -0
- package/es/component/legend.js.map +1 -0
- package/es/component/player.d.ts +25 -0
- package/es/component/player.js +136 -0
- package/es/component/player.js.map +1 -0
- package/es/component/scale.d.ts +8 -0
- package/es/component/scale.js +19 -0
- package/es/component/scale.js.map +1 -0
- package/es/component/scrollbar.d.ts +23 -0
- package/es/component/scrollbar.js +184 -0
- package/es/component/scrollbar.js.map +1 -0
- package/es/component/slider.d.ts +19 -0
- package/es/component/slider.js +86 -0
- package/es/component/slider.js.map +1 -0
- package/es/component/title.d.ts +15 -0
- package/es/component/title.js +58 -0
- package/es/component/title.js.map +1 -0
- package/es/component/tooltip.d.ts +62 -0
- package/es/component/tooltip.js +303 -0
- package/es/component/tooltip.js.map +1 -0
- package/es/core/factory.d.ts +35 -0
- package/es/core/factory.js +67 -0
- package/es/core/factory.js.map +1 -0
- package/es/glyph/boxplot.d.ts +10 -0
- package/es/glyph/boxplot.js +410 -0
- package/es/glyph/boxplot.js.map +1 -0
- package/es/glyph/index.d.ts +7 -0
- package/es/glyph/index.js +11 -0
- package/es/glyph/index.js.map +1 -0
- package/es/glyph/link-path.d.ts +7 -0
- package/es/glyph/link-path.js +132 -0
- package/es/glyph/link-path.js.map +1 -0
- package/es/glyph/ripple.d.ts +1 -0
- package/es/glyph/ripple.js +38 -0
- package/es/glyph/ripple.js.map +1 -0
- package/es/glyph/tree-path.d.ts +7 -0
- package/es/glyph/tree-path.js +146 -0
- package/es/glyph/tree-path.js.map +1 -0
- package/es/glyph/violin.d.ts +1 -0
- package/es/glyph/violin.js +163 -0
- package/es/glyph/violin.js.map +1 -0
- package/es/glyph/wave.d.ts +1 -0
- package/es/glyph/wave.js +61 -0
- package/es/glyph/wave.js.map +1 -0
- package/es/graph/animation/animate.d.ts +48 -0
- package/es/graph/animation/animate.js +247 -0
- package/es/graph/animation/animate.js.map +1 -0
- package/es/graph/animation/animation/clip.d.ts +4 -0
- package/es/graph/animation/animation/clip.js +44 -0
- package/es/graph/animation/animation/clip.js.map +1 -0
- package/es/graph/animation/animation/fade.d.ts +4 -0
- package/es/graph/animation/animation/fade.js +32 -0
- package/es/graph/animation/animation/fade.js.map +1 -0
- package/es/graph/animation/animation/grow-cartesian.d.ts +7 -0
- package/es/graph/animation/animation/grow-cartesian.js +272 -0
- package/es/graph/animation/animation/grow-cartesian.js.map +1 -0
- package/es/graph/animation/animation/grow-interval.d.ts +3 -0
- package/es/graph/animation/animation/grow-interval.js +184 -0
- package/es/graph/animation/animation/grow-interval.js.map +1 -0
- package/es/graph/animation/animation/grow-points.d.ts +7 -0
- package/es/graph/animation/animation/grow-points.js +107 -0
- package/es/graph/animation/animation/grow-points.js.map +1 -0
- package/es/graph/animation/animation/grow-polar.d.ts +5 -0
- package/es/graph/animation/animation/grow-polar.js +160 -0
- package/es/graph/animation/animation/grow-polar.js.map +1 -0
- package/es/graph/animation/animation/index.d.ts +11 -0
- package/es/graph/animation/animation/index.js +22 -0
- package/es/graph/animation/animation/index.js.map +1 -0
- package/es/graph/animation/animation/move.d.ts +3 -0
- package/es/graph/animation/animation/move.js +78 -0
- package/es/graph/animation/animation/move.js.map +1 -0
- package/es/graph/animation/animation/rotate.d.ts +3 -0
- package/es/graph/animation/animation/rotate.js +32 -0
- package/es/graph/animation/animation/rotate.js.map +1 -0
- package/es/graph/animation/animation/scale.d.ts +3 -0
- package/es/graph/animation/animation/scale.js +74 -0
- package/es/graph/animation/animation/scale.js.map +1 -0
- package/es/graph/animation/animation/update.d.ts +6 -0
- package/es/graph/animation/animation/update.js +20 -0
- package/es/graph/animation/animation/update.js.map +1 -0
- package/es/graph/animation/animator.d.ts +26 -0
- package/es/graph/animation/animator.js +83 -0
- package/es/graph/animation/animator.js.map +1 -0
- package/es/graph/animation/arranger.d.ts +13 -0
- package/es/graph/animation/arranger.js +29 -0
- package/es/graph/animation/arranger.js.map +1 -0
- package/es/graph/animation/attribute.d.ts +27 -0
- package/es/graph/animation/attribute.js +114 -0
- package/es/graph/animation/attribute.js.map +1 -0
- package/es/graph/animation/config.d.ts +5 -0
- package/es/graph/animation/config.js +84 -0
- package/es/graph/animation/config.js.map +1 -0
- package/es/graph/animation/morph.d.ts +12 -0
- package/es/graph/animation/morph.js +171 -0
- package/es/graph/animation/morph.js.map +1 -0
- package/es/graph/attributes/common.d.ts +2 -0
- package/es/graph/attributes/common.js +13 -0
- package/es/graph/attributes/common.js.map +1 -0
- package/es/graph/attributes/helpers.d.ts +17 -0
- package/es/graph/attributes/helpers.js +75 -0
- package/es/graph/attributes/helpers.js.map +1 -0
- package/es/graph/attributes/index.d.ts +10 -0
- package/es/graph/attributes/index.js +231 -0
- package/es/graph/attributes/index.js.map +1 -0
- package/es/graph/canvas-renderer.d.ts +34 -0
- package/es/graph/canvas-renderer.js +115 -0
- package/es/graph/canvas-renderer.js.map +1 -0
- package/es/graph/constants.d.ts +23 -0
- package/es/graph/constants.js +47 -0
- package/es/graph/constants.js.map +1 -0
- package/es/graph/element.d.ts +66 -0
- package/es/graph/element.js +292 -0
- package/es/graph/element.js.map +1 -0
- package/es/graph/enums.d.ts +153 -0
- package/es/graph/enums.js +129 -0
- package/es/graph/enums.js.map +1 -0
- package/es/graph/glyph-element.d.ts +53 -0
- package/es/graph/glyph-element.js +206 -0
- package/es/graph/glyph-element.js.map +1 -0
- package/es/graph/index.d.ts +3 -0
- package/es/graph/index.js +6 -0
- package/es/graph/index.js.map +1 -0
- package/es/graph/layout/grid.d.ts +3 -0
- package/es/graph/layout/grid.js +66 -0
- package/es/graph/layout/grid.js.map +1 -0
- package/es/graph/layout/layout.d.ts +3 -0
- package/es/graph/layout/layout.js +33 -0
- package/es/graph/layout/layout.js.map +1 -0
- package/es/graph/layout/relative.d.ts +3 -0
- package/es/graph/layout/relative.js +85 -0
- package/es/graph/layout/relative.js.map +1 -0
- package/es/graph/mark/differ.d.ts +20 -0
- package/es/graph/mark/differ.js +104 -0
- package/es/graph/mark/differ.js.map +1 -0
- package/es/graph/mark/encode.d.ts +10 -0
- package/es/graph/mark/encode.js +92 -0
- package/es/graph/mark/encode.js.map +1 -0
- package/es/graph/mark/large-rects.d.ts +10 -0
- package/es/graph/mark/large-rects.js +23 -0
- package/es/graph/mark/large-rects.js.map +1 -0
- package/es/graph/mark/large-symbols.d.ts +11 -0
- package/es/graph/mark/large-symbols.js +27 -0
- package/es/graph/mark/large-symbols.js.map +1 -0
- package/es/graph/mark-tree.d.ts +2 -0
- package/es/graph/mark-tree.js +15 -0
- package/es/graph/mark-tree.js.map +1 -0
- package/es/graph/util/element.d.ts +2 -0
- package/es/graph/util/element.js +8 -0
- package/es/graph/util/element.js.map +1 -0
- package/es/graph/util/env.d.ts +2 -0
- package/es/graph/util/env.js +6 -0
- package/es/graph/util/env.js.map +1 -0
- package/es/graph/util/events-extend.d.ts +5 -0
- package/es/graph/util/events-extend.js +12 -0
- package/es/graph/util/events-extend.js.map +1 -0
- package/es/graph/util/graphic.d.ts +9 -0
- package/es/graph/util/graphic.js +59 -0
- package/es/graph/util/graphic.js.map +1 -0
- package/es/graph/util/point.d.ts +1 -0
- package/es/graph/util/point.js +67 -0
- package/es/graph/util/point.js.map +1 -0
- package/es/index.d.ts +14 -0
- package/es/index.js +27 -0
- package/es/index.js.map +1 -0
- package/es/parse/coordinate.d.ts +7 -0
- package/es/parse/coordinate.js +65 -0
- package/es/parse/coordinate.js.map +1 -0
- package/es/parse/event.d.ts +8 -0
- package/es/parse/event.js +23 -0
- package/es/parse/event.js.map +1 -0
- package/es/parse/mark.d.ts +4 -0
- package/es/parse/mark.js +19 -0
- package/es/parse/mark.js.map +1 -0
- package/es/parse/option.d.ts +3 -0
- package/es/parse/option.js +10 -0
- package/es/parse/option.js.map +1 -0
- package/es/parse/scale.d.ts +8 -0
- package/es/parse/scale.js +347 -0
- package/es/parse/scale.js.map +1 -0
- package/es/parse/transform.d.ts +5 -0
- package/es/parse/transform.js +102 -0
- package/es/parse/transform.js.map +1 -0
- package/es/parse/util.d.ts +13 -0
- package/es/parse/util.js +65 -0
- package/es/parse/util.js.map +1 -0
- package/es/parse/view.d.ts +17 -0
- package/es/parse/view.js +98 -0
- package/es/parse/view.js.map +1 -0
- package/es/semantic-marks/cell.d.ts +13 -0
- package/es/semantic-marks/cell.js +57 -0
- package/es/semantic-marks/cell.js.map +1 -0
- package/es/semantic-marks/interval.d.ts +14 -0
- package/es/semantic-marks/interval.js +87 -0
- package/es/semantic-marks/interval.js.map +1 -0
- package/es/semantic-marks/text.d.ts +10 -0
- package/es/semantic-marks/text.js +22 -0
- package/es/semantic-marks/text.js.map +1 -0
- package/es/theme/common/component.d.ts +15 -0
- package/es/theme/common/component.js +510 -0
- package/es/theme/common/component.js.map +1 -0
- package/es/theme/common/constants.d.ts +1 -0
- package/es/theme/common/constants.js +2 -0
- package/es/theme/common/constants.js.map +1 -0
- package/es/theme/common/mark.d.ts +2 -0
- package/es/theme/common/mark.js +11 -0
- package/es/theme/common/mark.js.map +1 -0
- package/es/theme/dark.d.ts +2 -0
- package/es/theme/dark.js +96 -0
- package/es/theme/dark.js.map +1 -0
- package/es/theme/default.d.ts +2 -0
- package/es/theme/default.js +16 -0
- package/es/theme/default.js.map +1 -0
- package/es/theme/theme-manager.d.ts +8 -0
- package/es/theme/theme-manager.js +22 -0
- package/es/theme/theme-manager.js.map +1 -0
- package/es/transforms/data/bin.d.ts +2 -0
- package/es/transforms/data/bin.js +16 -0
- package/es/transforms/data/bin.js.map +1 -0
- package/es/transforms/data/circular-relation.d.ts +2 -0
- package/es/transforms/data/circular-relation.js +44 -0
- package/es/transforms/data/circular-relation.js.map +1 -0
- package/es/transforms/data/contour.d.ts +2 -0
- package/es/transforms/data/contour.js +111 -0
- package/es/transforms/data/contour.js.map +1 -0
- package/es/transforms/data/filter.d.ts +2 -0
- package/es/transforms/data/filter.js +2 -0
- package/es/transforms/data/filter.js.map +1 -0
- package/es/transforms/data/fold.d.ts +2 -0
- package/es/transforms/data/fold.js +16 -0
- package/es/transforms/data/fold.js.map +1 -0
- package/es/transforms/data/funnel.d.ts +2 -0
- package/es/transforms/data/funnel.js +17 -0
- package/es/transforms/data/funnel.js.map +1 -0
- package/es/transforms/data/join.d.ts +2 -0
- package/es/transforms/data/join.js +26 -0
- package/es/transforms/data/join.js.map +1 -0
- package/es/transforms/data/kde.d.ts +2 -0
- package/es/transforms/data/kde.js +80 -0
- package/es/transforms/data/kde.js.map +1 -0
- package/es/transforms/data/map.d.ts +2 -0
- package/es/transforms/data/map.js +16 -0
- package/es/transforms/data/map.js.map +1 -0
- package/es/transforms/data/pick.d.ts +2 -0
- package/es/transforms/data/pick.js +15 -0
- package/es/transforms/data/pick.js.map +1 -0
- package/es/transforms/data/pie.d.ts +2 -0
- package/es/transforms/data/pie.js +18 -0
- package/es/transforms/data/pie.js.map +1 -0
- package/es/transforms/data/range.d.ts +4 -0
- package/es/transforms/data/range.js +9 -0
- package/es/transforms/data/range.js.map +1 -0
- package/es/transforms/data/sort.d.ts +2 -0
- package/es/transforms/data/sort.js +13 -0
- package/es/transforms/data/sort.js.map +1 -0
- package/es/transforms/data/stack.d.ts +2 -0
- package/es/transforms/data/stack.js +72 -0
- package/es/transforms/data/stack.js.map +1 -0
- package/es/transforms/data/unfold.d.ts +2 -0
- package/es/transforms/data/unfold.js +45 -0
- package/es/transforms/data/unfold.js.map +1 -0
- package/es/transforms/index.d.ts +23 -0
- package/es/transforms/index.js +205 -0
- package/es/transforms/index.js.map +1 -0
- package/es/transforms/mark/dodge.d.ts +2 -0
- package/es/transforms/mark/dodge.js +74 -0
- package/es/transforms/mark/dodge.js.map +1 -0
- package/es/transforms/mark/jitter.d.ts +4 -0
- package/es/transforms/mark/jitter.js +48 -0
- package/es/transforms/mark/jitter.js.map +1 -0
- package/es/transforms/mark/lttb-sample.d.ts +2 -0
- package/es/transforms/mark/lttb-sample.js +60 -0
- package/es/transforms/mark/lttb-sample.js.map +1 -0
- package/es/transforms/mark/mark-overlap.d.ts +2 -0
- package/es/transforms/mark/mark-overlap.js +71 -0
- package/es/transforms/mark/mark-overlap.js.map +1 -0
- package/es/transforms/mark/symmetry.d.ts +2 -0
- package/es/transforms/mark/symmetry.js +20 -0
- package/es/transforms/mark/symmetry.js.map +1 -0
- package/es/transforms/util/util.d.ts +5 -0
- package/es/transforms/util/util.js +33 -0
- package/es/transforms/util/util.js.map +1 -0
- package/es/transforms/view/identifier.d.ts +2 -0
- package/es/transforms/view/identifier.js +13 -0
- package/es/transforms/view/identifier.js.map +1 -0
- package/es/types/animate.d.ts +224 -0
- package/es/types/animate.js +2 -0
- package/es/types/animate.js.map +1 -0
- package/es/types/base.d.ts +36 -0
- package/es/types/base.js +2 -0
- package/es/types/base.js.map +1 -0
- package/es/types/component.d.ts +240 -0
- package/es/types/component.js +2 -0
- package/es/types/component.js.map +1 -0
- package/es/types/coordinate.d.ts +15 -0
- package/es/types/coordinate.js +2 -0
- package/es/types/coordinate.js.map +1 -0
- package/es/types/data.d.ts +55 -0
- package/es/types/data.js +1 -0
- package/es/types/data.js.map +1 -0
- package/es/types/dataflow.d.ts +13 -0
- package/es/types/dataflow.js +2 -0
- package/es/types/dataflow.js.map +1 -0
- package/es/types/element.d.ts +117 -0
- package/es/types/element.js +2 -0
- package/es/types/element.js.map +1 -0
- package/es/types/event.d.ts +58 -0
- package/es/types/event.js +2 -0
- package/es/types/event.js.map +1 -0
- package/es/types/glyph.d.ts +29 -0
- package/es/types/glyph.js +2 -0
- package/es/types/glyph.js.map +1 -0
- package/es/types/grammar.d.ts +184 -0
- package/es/types/grammar.js +2 -0
- package/es/types/grammar.js.map +1 -0
- package/es/types/hooks.d.ts +45 -0
- package/es/types/hooks.js +2 -0
- package/es/types/hooks.js.map +1 -0
- package/es/types/index.d.ts +22 -0
- package/es/types/index.js +44 -0
- package/es/types/index.js.map +1 -0
- package/es/types/layout.d.ts +5 -0
- package/es/types/layout.js +2 -0
- package/es/types/layout.js.map +1 -0
- package/es/types/mark.d.ts +344 -0
- package/es/types/mark.js +2 -0
- package/es/types/mark.js.map +1 -0
- package/es/types/morph.d.ts +29 -0
- package/es/types/morph.js +2 -0
- package/es/types/morph.js.map +1 -0
- package/es/types/plot.d.ts +326 -0
- package/es/types/plot.js +2 -0
- package/es/types/plot.js.map +1 -0
- package/es/types/projection.d.ts +61 -0
- package/es/types/projection.js +2 -0
- package/es/types/projection.js.map +1 -0
- package/es/types/renderer.d.ts +19 -0
- package/es/types/renderer.js +2 -0
- package/es/types/renderer.js.map +1 -0
- package/es/types/scale.d.ts +111 -0
- package/es/types/scale.js +2 -0
- package/es/types/scale.js.map +1 -0
- package/es/types/signal.d.ts +20 -0
- package/es/types/signal.js +2 -0
- package/es/types/signal.js.map +1 -0
- package/es/types/theme.d.ts +41 -0
- package/es/types/theme.js +2 -0
- package/es/types/theme.js.map +1 -0
- package/es/types/transform.d.ts +291 -0
- package/es/types/transform.js +2 -0
- package/es/types/transform.js.map +1 -0
- package/es/types/view.d.ts +217 -0
- package/es/types/view.js +2 -0
- package/es/types/view.js.map +1 -0
- package/es/util/data.d.ts +3 -0
- package/es/util/data.js +60 -0
- package/es/util/data.js.map +1 -0
- package/es/util/grammar-heap.d.ts +14 -0
- package/es/util/grammar-heap.js +58 -0
- package/es/util/grammar-heap.js.map +1 -0
- package/es/util/text.d.ts +19 -0
- package/es/util/text.js +25 -0
- package/es/util/text.js.map +1 -0
- package/es/util/unique-list.d.ts +12 -0
- package/es/util/unique-list.js +29 -0
- package/es/util/unique-list.js.map +1 -0
- package/es/view/View.d.ts +157 -0
- package/es/view/View.js +836 -0
- package/es/view/View.js.map +1 -0
- package/es/view/animate.d.ts +20 -0
- package/es/view/animate.js +98 -0
- package/es/view/animate.js.map +1 -0
- package/es/view/component.d.ts +26 -0
- package/es/view/component.js +64 -0
- package/es/view/component.js.map +1 -0
- package/es/view/constants.d.ts +17 -0
- package/es/view/constants.js +32 -0
- package/es/view/constants.js.map +1 -0
- package/es/view/coordinate.d.ts +23 -0
- package/es/view/coordinate.js +52 -0
- package/es/view/coordinate.js.map +1 -0
- package/es/view/data.d.ts +37 -0
- package/es/view/data.js +195 -0
- package/es/view/data.js.map +1 -0
- package/es/view/dataflow.d.ts +32 -0
- package/es/view/dataflow.js +141 -0
- package/es/view/dataflow.js.map +1 -0
- package/es/view/events.d.ts +4 -0
- package/es/view/events.js +26 -0
- package/es/view/events.js.map +1 -0
- package/es/view/glyph-meta.d.ts +29 -0
- package/es/view/glyph-meta.js +37 -0
- package/es/view/glyph-meta.js.map +1 -0
- package/es/view/glyph.d.ts +14 -0
- package/es/view/glyph.js +27 -0
- package/es/view/glyph.js.map +1 -0
- package/es/view/grammar-base.d.ts +46 -0
- package/es/view/grammar-base.js +165 -0
- package/es/view/grammar-base.js.map +1 -0
- package/es/view/grammar-record.d.ts +39 -0
- package/es/view/grammar-record.js +170 -0
- package/es/view/grammar-record.js.map +1 -0
- package/es/view/group.d.ts +13 -0
- package/es/view/group.js +39 -0
- package/es/view/group.js.map +1 -0
- package/es/view/index.d.ts +1 -0
- package/es/view/index.js +2 -0
- package/es/view/index.js.map +1 -0
- package/es/view/mark.d.ts +112 -0
- package/es/view/mark.js +604 -0
- package/es/view/mark.js.map +1 -0
- package/es/view/scale.d.ts +26 -0
- package/es/view/scale.js +82 -0
- package/es/view/scale.js.map +1 -0
- package/es/view/signal.d.ts +18 -0
- package/es/view/signal.js +52 -0
- package/es/view/signal.js.map +1 -0
- package/package.json +67 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { IGrammarBase, DataSpec, IData, GrammarType, DataFormatSpec, IView, TransformSpec, ParameterFunctionType, IDataFilter } from '../types';
|
|
2
|
+
import { GrammarBase } from './grammar-base';
|
|
3
|
+
import type { Nil } from '../types/base';
|
|
4
|
+
export declare class Data extends GrammarBase implements IData {
|
|
5
|
+
readonly grammarType: GrammarType;
|
|
6
|
+
protected spec: DataSpec;
|
|
7
|
+
private _dataIDKey;
|
|
8
|
+
private _input;
|
|
9
|
+
private _values;
|
|
10
|
+
private _isLoaded?;
|
|
11
|
+
private _loadTasks;
|
|
12
|
+
private _postFilters;
|
|
13
|
+
constructor(view: IView, values?: any, format?: DataFormatSpec);
|
|
14
|
+
parse(spec: DataSpec): this;
|
|
15
|
+
private parseDataSource;
|
|
16
|
+
private ingest;
|
|
17
|
+
private load;
|
|
18
|
+
private relay;
|
|
19
|
+
evaluate(upstream: any, parameters: any): Promise<this>;
|
|
20
|
+
evaluateSync: (upstream: any, parameters: any) => this;
|
|
21
|
+
output(): any[];
|
|
22
|
+
getDataIDKey(): string;
|
|
23
|
+
values(values: any | Nil, format?: ParameterFunctionType<DataFormatSpec>, load?: boolean): this;
|
|
24
|
+
url(url: ParameterFunctionType<string> | Nil, format?: ParameterFunctionType<DataFormatSpec>, load?: boolean): this;
|
|
25
|
+
source(source: string | string[] | IData | IData[] | Nil, format?: ParameterFunctionType<DataFormatSpec>, load?: boolean): this;
|
|
26
|
+
private parseLoad;
|
|
27
|
+
private setValues;
|
|
28
|
+
field(field: string): any[];
|
|
29
|
+
transform(transforms: TransformSpec[] | Nil): this;
|
|
30
|
+
getValue(): any[];
|
|
31
|
+
getInput(): any[];
|
|
32
|
+
addDataFilter(filter: IDataFilter | IDataFilter[]): this;
|
|
33
|
+
removeDataFilter(filter: IDataFilter | IDataFilter[]): this;
|
|
34
|
+
private _evaluateFilter;
|
|
35
|
+
reuse(grammar: IGrammarBase): this;
|
|
36
|
+
clear(): void;
|
|
37
|
+
}
|
package/es/view/data.js
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
var __awaiter = this && this.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
2
|
+
return new (P || (P = Promise))((function(resolve, reject) {
|
|
3
|
+
function fulfilled(value) {
|
|
4
|
+
try {
|
|
5
|
+
step(generator.next(value));
|
|
6
|
+
} catch (e) {
|
|
7
|
+
reject(e);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
function rejected(value) {
|
|
11
|
+
try {
|
|
12
|
+
step(generator.throw(value));
|
|
13
|
+
} catch (e) {
|
|
14
|
+
reject(e);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function step(result) {
|
|
18
|
+
var value;
|
|
19
|
+
result.done ? resolve(result.value) : (value = result.value, value instanceof P ? value : new P((function(resolve) {
|
|
20
|
+
resolve(value);
|
|
21
|
+
}))).then(fulfilled, rejected);
|
|
22
|
+
}
|
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
+
}));
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
import { array, isNil } from "@visactor/vutils";
|
|
28
|
+
|
|
29
|
+
import { GrammarBase } from "./grammar-base";
|
|
30
|
+
|
|
31
|
+
import { invokeParameterFunctionType, isGrammar, parseFunctionType } from "../parse/util";
|
|
32
|
+
|
|
33
|
+
import { parseTransformSpec } from "../parse/transform";
|
|
34
|
+
|
|
35
|
+
import { HOOK_EVENT } from "../graph/enums";
|
|
36
|
+
|
|
37
|
+
import { load, parseFormat } from "../util/data";
|
|
38
|
+
|
|
39
|
+
export class Data extends GrammarBase {
|
|
40
|
+
constructor(view, values, format) {
|
|
41
|
+
super(view), this.grammarType = "data", this.spec = {}, this._dataIDKey = `VGRAMMAR_DATA_ID_KEY_${this.uid}`,
|
|
42
|
+
this._loadTasks = [], this._postFilters = [], this.ingest = options => {
|
|
43
|
+
const format = invokeParameterFunctionType(options.format, this.parameters());
|
|
44
|
+
return this._input = parseFormat(options.values, format), this._input;
|
|
45
|
+
}, this.load = options => {
|
|
46
|
+
var _a;
|
|
47
|
+
if (options.values) return this.ingest(options);
|
|
48
|
+
const url = invokeParameterFunctionType(options.url, this.parameters()), format = null !== (_a = invokeParameterFunctionType(options.format, this.parameters())) && void 0 !== _a ? _a : {
|
|
49
|
+
type: "json"
|
|
50
|
+
};
|
|
51
|
+
return load(url).then((data => this.ingest({
|
|
52
|
+
values: data,
|
|
53
|
+
format: format
|
|
54
|
+
})));
|
|
55
|
+
}, this.relay = options => options[0], this.evaluateSync = (upstream, parameters) => {
|
|
56
|
+
this.view.emit(HOOK_EVENT.BEFORE_EVALUATE_DATA);
|
|
57
|
+
const tasks = this._isLoaded ? this.transforms : this._loadTasks.concat(this.transforms), values = this.evaluateTransformSync(tasks, this.grammarSource ? upstream : this._input, parameters), filteredValues = this._evaluateFilter(values, parameters);
|
|
58
|
+
return this.setValues(filteredValues), this._isLoaded = !0, this.view.emit(HOOK_EVENT.AFTER_EVALUATE_DATA),
|
|
59
|
+
this;
|
|
60
|
+
}, this._loadTasks = [], isNil(values) || this.values(values, format);
|
|
61
|
+
}
|
|
62
|
+
parse(spec) {
|
|
63
|
+
return super.parse(spec), this._isLoaded = !1, this.source(spec.source, spec.format, !1),
|
|
64
|
+
this.url(spec.url, spec.format, !1), this.values(spec.values, spec.format, !1),
|
|
65
|
+
this.transform(spec.transform), this.parseLoad(spec), this.commit(), this;
|
|
66
|
+
}
|
|
67
|
+
parseDataSource(spec) {
|
|
68
|
+
const refs = [], transforms = [], formatRef = spec.format ? parseFunctionType(spec.format, this.view)[0] : null;
|
|
69
|
+
if (formatRef && refs.push(formatRef), spec.values) {
|
|
70
|
+
const valuesRef = parseFunctionType(spec.values, this.view)[0];
|
|
71
|
+
valuesRef && refs.push(valuesRef), transforms.push({
|
|
72
|
+
type: "ingest",
|
|
73
|
+
transform: this.ingest,
|
|
74
|
+
isRawOptions: !0,
|
|
75
|
+
options: {
|
|
76
|
+
values: spec.values,
|
|
77
|
+
format: spec.format
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
} else if (spec.url) {
|
|
81
|
+
const urlRef = parseFunctionType(spec.url, this.view)[0];
|
|
82
|
+
urlRef && refs.push(urlRef), transforms.push({
|
|
83
|
+
type: "load",
|
|
84
|
+
transform: this.load,
|
|
85
|
+
options: {
|
|
86
|
+
url: null != urlRef ? urlRef : spec.url,
|
|
87
|
+
format: null != formatRef ? formatRef : spec.format
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
} else if (spec.source) {
|
|
91
|
+
const upstreamData = [];
|
|
92
|
+
array(spec.source).forEach((sourceId => {
|
|
93
|
+
const sourceData = isGrammar(sourceId) ? sourceId : this.view.getDataById(sourceId);
|
|
94
|
+
sourceData && (refs.push(sourceData), upstreamData.push(sourceData));
|
|
95
|
+
})), upstreamData.length && (transforms.push({
|
|
96
|
+
type: "relay",
|
|
97
|
+
transform: this.relay,
|
|
98
|
+
options: upstreamData
|
|
99
|
+
}), this.grammarSource = upstreamData[0]);
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
transforms: transforms,
|
|
103
|
+
refs: refs
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
evaluate(upstream, parameters) {
|
|
107
|
+
return __awaiter(this, void 0, void 0, (function*() {
|
|
108
|
+
this.view.emit(HOOK_EVENT.BEFORE_EVALUATE_DATA);
|
|
109
|
+
const tasks = this._isLoaded ? this.transforms : this._loadTasks.concat(this.transforms);
|
|
110
|
+
this.grammarSource && (this._input = upstream);
|
|
111
|
+
const values = yield this.evaluateTransform(tasks, this._input, parameters), filteredValues = this._evaluateFilter(values, parameters);
|
|
112
|
+
return this.setValues(filteredValues), this._isLoaded = !0, this.view.emit(HOOK_EVENT.AFTER_EVALUATE_DATA),
|
|
113
|
+
this;
|
|
114
|
+
}));
|
|
115
|
+
}
|
|
116
|
+
output() {
|
|
117
|
+
return this._values;
|
|
118
|
+
}
|
|
119
|
+
getDataIDKey() {
|
|
120
|
+
return this._dataIDKey;
|
|
121
|
+
}
|
|
122
|
+
values(values, format, load = !0) {
|
|
123
|
+
const spec = Object.assign({}, this.spec, {
|
|
124
|
+
values: values,
|
|
125
|
+
format: format
|
|
126
|
+
});
|
|
127
|
+
return isNil(values) || (spec.url = void 0, spec.source = void 0), load ? this.parseLoad(spec) : this;
|
|
128
|
+
}
|
|
129
|
+
url(url, format, load = !0) {
|
|
130
|
+
const spec = Object.assign({}, this.spec, {
|
|
131
|
+
url: url,
|
|
132
|
+
format: format
|
|
133
|
+
});
|
|
134
|
+
return isNil(url) || (spec.values = void 0, spec.source = void 0), load ? this.parseLoad(spec) : this;
|
|
135
|
+
}
|
|
136
|
+
source(source, format, load = !0) {
|
|
137
|
+
const spec = Object.assign({}, this.spec, {
|
|
138
|
+
source: source,
|
|
139
|
+
format: format
|
|
140
|
+
});
|
|
141
|
+
return isNil(source) || (spec.values = void 0, spec.url = void 0), load ? this.parseLoad(spec) : this;
|
|
142
|
+
}
|
|
143
|
+
parseLoad(spec) {
|
|
144
|
+
this.detach(this.parseDataSource(this.spec).refs), this.spec = spec;
|
|
145
|
+
const dataSourceResult = this.parseDataSource(this.spec);
|
|
146
|
+
return this.attach(dataSourceResult.refs), this._loadTasks = dataSourceResult.transforms,
|
|
147
|
+
this._isLoaded = !1, this.commit(), this;
|
|
148
|
+
}
|
|
149
|
+
setValues(data) {
|
|
150
|
+
this._values = array(data).map(((entry, index) => {
|
|
151
|
+
const datum = entry === Object(entry) ? entry : {
|
|
152
|
+
data: entry
|
|
153
|
+
};
|
|
154
|
+
return datum[this._dataIDKey] = index, datum;
|
|
155
|
+
}));
|
|
156
|
+
}
|
|
157
|
+
field(field) {
|
|
158
|
+
return this._values.map((value => value[field]));
|
|
159
|
+
}
|
|
160
|
+
transform(transforms) {
|
|
161
|
+
const prevTransforms = parseTransformSpec(this.spec.transform, this.view);
|
|
162
|
+
prevTransforms && (this.detach(prevTransforms.refs), this.transforms = []), this.spec.transform = transforms;
|
|
163
|
+
const nextTransforms = parseTransformSpec(this.spec.transform, this.view);
|
|
164
|
+
return nextTransforms && (this.attach(nextTransforms.refs), this.transforms = nextTransforms.transforms),
|
|
165
|
+
this.commit(), this;
|
|
166
|
+
}
|
|
167
|
+
getValue() {
|
|
168
|
+
return this._values;
|
|
169
|
+
}
|
|
170
|
+
getInput() {
|
|
171
|
+
return this._input;
|
|
172
|
+
}
|
|
173
|
+
addDataFilter(filter) {
|
|
174
|
+
return this._postFilters = this._postFilters.concat(array(filter)), this._postFilters.sort(((filterA, filterB) => {
|
|
175
|
+
var _a, _b;
|
|
176
|
+
return (null !== (_a = filterA.rank) && void 0 !== _a ? _a : 0) - (null !== (_b = filterB.rank) && void 0 !== _b ? _b : 0);
|
|
177
|
+
})), this;
|
|
178
|
+
}
|
|
179
|
+
removeDataFilter(filter) {
|
|
180
|
+
const filters = array(filter);
|
|
181
|
+
return this._postFilters = this._postFilters.filter((filter => !filters.includes(filter))),
|
|
182
|
+
this;
|
|
183
|
+
}
|
|
184
|
+
_evaluateFilter(value, parameters) {
|
|
185
|
+
return this._postFilters.reduce(((result, filter) => filter.filter(result, parameters)), value);
|
|
186
|
+
}
|
|
187
|
+
reuse(grammar) {
|
|
188
|
+
return grammar.grammarType !== this.grammarType || (this._isLoaded = !1, this._values = grammar.output()),
|
|
189
|
+
this;
|
|
190
|
+
}
|
|
191
|
+
clear() {
|
|
192
|
+
super.clear(), this._input = null, this._values = null;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
//# sourceMappingURL=data.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/view/data.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAahD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,2BAA2B,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAC1F,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;IAED,KAAK,CAAC,OAAqB;QACzB,IAAI,OAAO,CAAC,WAAW,KAAK,IAAI,CAAC,WAAW,EAAE;YAC5C,OAAO,IAAI,CAAC;SACb;QAED,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;QAChC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK;QACH,KAAK,CAAC,KAAK,EAAE,CAAC;QACd,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;IACtB,CAAC;CACF","file":"data.js","sourcesContent":["import { array, isNil } from '@visactor/vutils';\nimport type {\n IGrammarBase,\n DataSpec,\n IData,\n GrammarType,\n DataFormatSpec,\n IView,\n IGrammarTask,\n TransformSpec,\n ParameterFunctionType,\n IDataFilter\n} from '../types';\nimport { GrammarBase } from './grammar-base';\nimport { invokeParameterFunctionType, isGrammar, parseFunctionType } from '../parse/util';\nimport { parseTransformSpec } from '../parse/transform';\nimport type { Nil } from '../types/base';\nimport { HOOK_EVENT } from '../graph/enums';\nimport { load, parseFormat } from '../util/data';\n\nexport class Data extends GrammarBase implements IData {\n readonly grammarType: GrammarType = 'data';\n\n protected spec: DataSpec = {};\n\n private _dataIDKey = `VGRAMMAR_DATA_ID_KEY_${this.uid}`;\n\n /** 原始输入数据 */\n private _input: any[];\n\n /** 计算后的数据 */\n private _values: any[];\n\n private _isLoaded?: boolean;\n private _loadTasks: IGrammarTask[] = [];\n private _postFilters: IDataFilter[] = [];\n\n constructor(view: IView, values?: any, format?: DataFormatSpec) {\n super(view);\n this._loadTasks = [];\n\n if (!isNil(values)) {\n this.values(values, format);\n // this.ingest({ values });\n }\n }\n\n parse(spec: DataSpec) {\n super.parse(spec);\n this._isLoaded = false;\n\n this.source(spec.source, spec.format, false);\n this.url(spec.url, spec.format, false);\n this.values(spec.values, spec.format, false);\n this.transform(spec.transform);\n\n this.parseLoad(spec);\n\n this.commit();\n return this;\n }\n\n private parseDataSource(spec: DataSpec) {\n const refs: IGrammarBase[] = [];\n const transforms: IGrammarTask[] = [];\n\n const formatRef = spec.format ? parseFunctionType(spec.format, this.view)[0] : null;\n if (formatRef) {\n refs.push(formatRef);\n }\n\n if (spec.values) {\n const valuesRef = parseFunctionType(spec.values, this.view)[0];\n\n if (valuesRef) {\n refs.push(valuesRef);\n }\n\n transforms.push({\n type: 'ingest',\n transform: this.ingest,\n isRawOptions: true,\n options: {\n values: spec.values,\n format: spec.format\n }\n });\n } else if (spec.url) {\n const urlRef = parseFunctionType(spec.url, this.view)[0];\n if (urlRef) {\n refs.push(urlRef);\n }\n\n transforms.push({\n type: 'load',\n transform: this.load,\n options: {\n url: urlRef ?? spec.url,\n format: formatRef ?? spec.format\n }\n });\n } else if (spec.source) {\n const upstreamData: IData[] = [];\n\n array(spec.source).forEach(sourceId => {\n const sourceData = isGrammar(sourceId) ? sourceId : this.view.getDataById(sourceId);\n\n if (sourceData) {\n refs.push(sourceData);\n upstreamData.push(sourceData as IData);\n }\n });\n\n if (upstreamData.length) {\n transforms.push({\n type: 'relay',\n transform: this.relay,\n options: upstreamData\n });\n this.grammarSource = upstreamData[0];\n }\n }\n return { transforms, refs };\n }\n\n private ingest = (options: { values?: any; format?: ParameterFunctionType<DataFormatSpec> }) => {\n const format = invokeParameterFunctionType(options.format, this.parameters());\n this._input = parseFormat(options.values, format);\n return this._input;\n };\n\n private load = (\n options:\n | { url: ParameterFunctionType<string>; format?: ParameterFunctionType<DataFormatSpec> }\n | { values: any; format?: ParameterFunctionType<DataFormatSpec> }\n ) => {\n if ((options as { values: any; format?: ParameterFunctionType<DataFormatSpec> }).values) {\n return this.ingest(options as { values: any; format?: ParameterFunctionType<DataFormatSpec> });\n }\n const url = invokeParameterFunctionType((options as { url: ParameterFunctionType<string> }).url, this.parameters());\n // default format for loaded data is json\n const format = invokeParameterFunctionType(options.format, this.parameters()) ?? { type: 'json' };\n return load(url).then(data => this.ingest({ values: data, format }));\n };\n\n private relay = (options: any[]) => {\n return options[0];\n };\n\n async evaluate(upstream: any, parameters: any) {\n this.view.emit(HOOK_EVENT.BEFORE_EVALUATE_DATA);\n const tasks = this._isLoaded ? this.transforms : this._loadTasks.concat(this.transforms);\n if (this.grammarSource) {\n this._input = upstream;\n }\n\n const values = await this.evaluateTransform(tasks, this._input, parameters);\n const filteredValues = this._evaluateFilter(values, parameters);\n this.setValues(filteredValues);\n\n this._isLoaded = true;\n this.view.emit(HOOK_EVENT.AFTER_EVALUATE_DATA);\n\n return this;\n }\n\n evaluateSync = (upstream: any, parameters: any) => {\n this.view.emit(HOOK_EVENT.BEFORE_EVALUATE_DATA);\n const tasks = this._isLoaded ? this.transforms : this._loadTasks.concat(this.transforms);\n\n const values = this.evaluateTransformSync(tasks, this.grammarSource ? upstream : this._input, parameters);\n const filteredValues = this._evaluateFilter(values, parameters);\n this.setValues(filteredValues);\n\n this._isLoaded = true;\n\n this.view.emit(HOOK_EVENT.AFTER_EVALUATE_DATA);\n\n return this;\n };\n\n output() {\n return this._values;\n }\n\n getDataIDKey() {\n return this._dataIDKey;\n }\n\n values(values: any | Nil, format?: ParameterFunctionType<DataFormatSpec>, load: boolean = true) {\n const spec = Object.assign({}, this.spec, { values, format });\n if (!isNil(values)) {\n spec.url = undefined;\n spec.source = undefined;\n }\n return load ? this.parseLoad(spec) : this;\n }\n\n url(url: ParameterFunctionType<string> | Nil, format?: ParameterFunctionType<DataFormatSpec>, load: boolean = true) {\n const spec = Object.assign({}, this.spec, { url, format });\n if (!isNil(url)) {\n spec.values = undefined;\n spec.source = undefined;\n }\n return load ? this.parseLoad(spec) : this;\n }\n\n source(\n source: string | string[] | IData | IData[] | Nil,\n format?: ParameterFunctionType<DataFormatSpec>,\n load: boolean = true\n ) {\n const spec = Object.assign({}, this.spec, { source, format });\n if (!isNil(source)) {\n spec.values = undefined;\n spec.url = undefined;\n }\n return load ? this.parseLoad(spec) : this;\n }\n\n private parseLoad(spec: DataSpec) {\n this.detach(this.parseDataSource(this.spec).refs);\n\n this.spec = spec;\n\n const dataSourceResult = this.parseDataSource(this.spec);\n this.attach(dataSourceResult.refs);\n this._loadTasks = dataSourceResult.transforms;\n this._isLoaded = false;\n\n this.commit();\n return this;\n }\n\n private setValues(data: any[]) {\n this._values = array(data).map((entry, index) => {\n const datum = entry === Object(entry) ? entry : { data: entry };\n datum[this._dataIDKey] = index;\n return datum;\n });\n }\n\n field(field: string): any[] {\n return this._values.map((value: any) => value[field]);\n }\n\n transform(transforms: TransformSpec[] | Nil): this {\n const prevTransforms = parseTransformSpec(this.spec.transform, this.view);\n if (prevTransforms) {\n this.detach(prevTransforms.refs);\n this.transforms = [];\n }\n\n this.spec.transform = transforms;\n\n const nextTransforms = parseTransformSpec(this.spec.transform, this.view);\n if (nextTransforms) {\n this.attach(nextTransforms.refs);\n this.transforms = nextTransforms.transforms;\n }\n\n this.commit();\n return this;\n }\n\n getValue() {\n return this._values;\n }\n\n getInput() {\n return this._input;\n }\n\n addDataFilter(filter: IDataFilter | IDataFilter[]) {\n this._postFilters = this._postFilters.concat(array(filter));\n this._postFilters.sort((filterA, filterB) => (filterA.rank ?? 0) - (filterB.rank ?? 0));\n return this;\n }\n\n removeDataFilter(filter: IDataFilter | IDataFilter[]) {\n const filters = array(filter);\n this._postFilters = this._postFilters.filter(filter => !filters.includes(filter));\n return this;\n }\n\n private _evaluateFilter(value: any, parameters: any) {\n return this._postFilters.reduce((result, filter) => {\n return filter.filter(result, parameters);\n }, value);\n }\n\n reuse(grammar: IGrammarBase) {\n if (grammar.grammarType !== this.grammarType) {\n return this;\n }\n\n this._isLoaded = false;\n this._values = grammar.output();\n return this;\n }\n\n clear() {\n super.clear();\n this._input = null;\n this._values = null;\n }\n}\n"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ILogger } from '@visactor/vutils';
|
|
2
|
+
import type { IDataflow } from '../types/dataflow';
|
|
3
|
+
import type { IDataflowCallback, IGrammarBase } from '../types';
|
|
4
|
+
export default class Dataflow implements IDataflow {
|
|
5
|
+
logger: ILogger;
|
|
6
|
+
private grammars;
|
|
7
|
+
private _curRank;
|
|
8
|
+
private _committed?;
|
|
9
|
+
private _heap?;
|
|
10
|
+
private _beforeRunner?;
|
|
11
|
+
private _afterRunner?;
|
|
12
|
+
private _isRunning?;
|
|
13
|
+
private _updateCounter;
|
|
14
|
+
private _finishFirstRender?;
|
|
15
|
+
constructor();
|
|
16
|
+
asyncCallback(callback: (context: IDataflow) => any): Promise<void>;
|
|
17
|
+
add(grammar: IGrammarBase): boolean;
|
|
18
|
+
remove(grammar: IGrammarBase): void;
|
|
19
|
+
private _setRankOfGrammar;
|
|
20
|
+
private _reRank;
|
|
21
|
+
private _enqueue;
|
|
22
|
+
private _logGrammarRunInfo;
|
|
23
|
+
hasCommitted(): boolean;
|
|
24
|
+
commit(grammar: IGrammarBase): this;
|
|
25
|
+
private _beforeEvaluate;
|
|
26
|
+
private _enqueueTargets;
|
|
27
|
+
evaluate(): Promise<boolean>;
|
|
28
|
+
evaluateSync(): boolean;
|
|
29
|
+
runBefore(callback?: IDataflowCallback): void;
|
|
30
|
+
runAfter(callback?: IDataflowCallback): void;
|
|
31
|
+
release(): void;
|
|
32
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
var __awaiter = this && this.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
2
|
+
return new (P || (P = Promise))((function(resolve, reject) {
|
|
3
|
+
function fulfilled(value) {
|
|
4
|
+
try {
|
|
5
|
+
step(generator.next(value));
|
|
6
|
+
} catch (e) {
|
|
7
|
+
reject(e);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
function rejected(value) {
|
|
11
|
+
try {
|
|
12
|
+
step(generator.throw(value));
|
|
13
|
+
} catch (e) {
|
|
14
|
+
reject(e);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function step(result) {
|
|
18
|
+
var value;
|
|
19
|
+
result.done ? resolve(result.value) : (value = result.value, value instanceof P ? value : new P((function(resolve) {
|
|
20
|
+
resolve(value);
|
|
21
|
+
}))).then(fulfilled, rejected);
|
|
22
|
+
}
|
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
+
}));
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
import { isNil, Logger } from "@visactor/vutils";
|
|
28
|
+
|
|
29
|
+
import { Heap } from "../util/grammar-heap";
|
|
30
|
+
|
|
31
|
+
import { UniqueList } from "../util/unique-list";
|
|
32
|
+
|
|
33
|
+
export default class Dataflow {
|
|
34
|
+
constructor() {
|
|
35
|
+
this.grammars = [], this.logger = Logger.getInstance(), this._curRank = 0, this._committed = new UniqueList((grammar => grammar.uid)),
|
|
36
|
+
this._heap = new Heap(((a, b) => a.qrank - b.qrank)), this._beforeRunner = null,
|
|
37
|
+
this._afterRunner = null, this._isRunning = !1, this._updateCounter = 0, this._finishFirstRender = !1;
|
|
38
|
+
}
|
|
39
|
+
asyncCallback(callback) {
|
|
40
|
+
return __awaiter(this, void 0, void 0, (function*() {
|
|
41
|
+
try {
|
|
42
|
+
yield callback(this);
|
|
43
|
+
} catch (err) {
|
|
44
|
+
this.logger.error(err);
|
|
45
|
+
}
|
|
46
|
+
}));
|
|
47
|
+
}
|
|
48
|
+
add(grammar) {
|
|
49
|
+
if (grammar) return this._setRankOfGrammar(grammar), this.commit(grammar), !this.grammars.includes(grammar) && (this.grammars.push(grammar),
|
|
50
|
+
!0);
|
|
51
|
+
}
|
|
52
|
+
remove(grammar) {
|
|
53
|
+
grammar && (this._committed.remove(grammar), this._heap.remove(grammar), this.grammars = this.grammars.filter((storedGrammar => storedGrammar !== grammar)));
|
|
54
|
+
}
|
|
55
|
+
_setRankOfGrammar(grammar) {
|
|
56
|
+
grammar.rank = ++this._curRank;
|
|
57
|
+
}
|
|
58
|
+
_reRank(grammar) {
|
|
59
|
+
const queue = [ grammar ];
|
|
60
|
+
for (;queue.length; ) {
|
|
61
|
+
const cur = queue.pop();
|
|
62
|
+
this._setRankOfGrammar(cur);
|
|
63
|
+
const list = cur.targets;
|
|
64
|
+
list && list.forEach((entry => {
|
|
65
|
+
queue.push(entry), entry === grammar && this.logger.error("Cycle detected in dataflow graph.");
|
|
66
|
+
}), !0);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
_enqueue(grammar) {
|
|
70
|
+
grammar.qrank = grammar.rank, this._heap.push(grammar);
|
|
71
|
+
}
|
|
72
|
+
_logGrammarRunInfo(grammar) {
|
|
73
|
+
if (this.logger.canLogError()) {
|
|
74
|
+
const debugStr = [ {
|
|
75
|
+
key: "id",
|
|
76
|
+
value: grammar.id()
|
|
77
|
+
}, {
|
|
78
|
+
key: "name",
|
|
79
|
+
value: grammar.name()
|
|
80
|
+
} ].reduce(((str, entry, index) => isNil(entry.value) ? str : `${str}${index ? " , " : ""}${entry.key}: ${entry.value}`), "");
|
|
81
|
+
this.logger.debug("Run Operator: ", grammar, debugStr);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
hasCommitted() {
|
|
85
|
+
return !!this._committed.length;
|
|
86
|
+
}
|
|
87
|
+
commit(grammar) {
|
|
88
|
+
return this._isRunning ? this._enqueue(grammar) : this._committed.add(grammar),
|
|
89
|
+
this;
|
|
90
|
+
}
|
|
91
|
+
_beforeEvaluate() {
|
|
92
|
+
this.grammars.forEach((grammar => {
|
|
93
|
+
grammar.targets.some((target => target.rank < grammar.rank)) && this._reRank(grammar);
|
|
94
|
+
})), this._committed.forEach((grammar => this._enqueue(grammar))), this._committed = new UniqueList((grammar => grammar.uid));
|
|
95
|
+
}
|
|
96
|
+
_enqueueTargets(grammar) {
|
|
97
|
+
grammar.targets && grammar.targets.length && this._finishFirstRender && grammar.targets.forEach((target => this._enqueue(target)));
|
|
98
|
+
}
|
|
99
|
+
evaluate() {
|
|
100
|
+
return __awaiter(this, void 0, void 0, (function*() {
|
|
101
|
+
if (this._beforeRunner && (yield this.asyncCallback(this._beforeRunner)), !this._committed.length) return this.logger.info("Dataflow invoked, but nothing to do."),
|
|
102
|
+
!1;
|
|
103
|
+
this._isRunning = !0, this._updateCounter += 1;
|
|
104
|
+
let grammar, next, dt, error, count = 0;
|
|
105
|
+
this.logger.canLogInfo() && (dt = Date.now(), this.logger.debug(`-- START PROPAGATION (${this._updateCounter}) -----`)),
|
|
106
|
+
this._beforeEvaluate();
|
|
107
|
+
try {
|
|
108
|
+
for (;this._heap.size() > 0; ) grammar = this._heap.pop(), grammar.rank === grammar.qrank ? (next = grammar.run(),
|
|
109
|
+
next && next.then && (next = yield next), this._logGrammarRunInfo(grammar), this._enqueueTargets(grammar),
|
|
110
|
+
count += 1) : this._enqueue(grammar);
|
|
111
|
+
} catch (err) {
|
|
112
|
+
this._heap.clear(), error = err;
|
|
113
|
+
}
|
|
114
|
+
return this._isRunning = !1, this.logger.canLogInfo() && (dt = Date.now() - dt,
|
|
115
|
+
this.logger.info(`> ${count} grammars; ${dt} ms`)), error ? this.logger.error(error) : this._afterRunner && (yield this.asyncCallback(this._afterRunner)),
|
|
116
|
+
this._finishFirstRender = !0, !0;
|
|
117
|
+
}));
|
|
118
|
+
}
|
|
119
|
+
evaluateSync() {
|
|
120
|
+
if (this._beforeRunner && this._beforeRunner(this), !this._committed.length) return this.logger.info("Dataflow invoked, but nothing to do."),
|
|
121
|
+
!1;
|
|
122
|
+
this._isRunning = !0, this._updateCounter += 1;
|
|
123
|
+
let grammar, dt, count = 0;
|
|
124
|
+
for (this.logger.canLogInfo() && (dt = Date.now(), this.logger.debug(`-- START PROPAGATION (${this._updateCounter}) -----`)),
|
|
125
|
+
this._beforeEvaluate(); this._heap.size() > 0; ) grammar = this._heap.pop(), grammar.rank === grammar.qrank ? (grammar.runSync(),
|
|
126
|
+
this._logGrammarRunInfo(grammar), this._enqueueTargets(grammar), count += 1) : this._enqueue(grammar);
|
|
127
|
+
return this._isRunning = !1, this.logger.canLogInfo() && (dt = Date.now() - dt,
|
|
128
|
+
this.logger.info(`> ${count} grammars updated; ${dt} ms`)), this._afterRunner && this._afterRunner(this),
|
|
129
|
+
this._finishFirstRender = !0, !0;
|
|
130
|
+
}
|
|
131
|
+
runBefore(callback) {
|
|
132
|
+
this._beforeRunner = callback;
|
|
133
|
+
}
|
|
134
|
+
runAfter(callback) {
|
|
135
|
+
this._afterRunner = callback;
|
|
136
|
+
}
|
|
137
|
+
release() {
|
|
138
|
+
this._heap && (this._heap.clear(), this._heap = null), this.logger = null, this._committed = null;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=dataflow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/view/dataflow.ts"],"names":[],"mappings":";;;;;;;;;AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAMjD,MAAM,CAAC,OAAO,OAAO,QAAQ;IAgB3B;QAdQ,aAAQ,GAAmB,EAAE,CAAC;QAepC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC;QAEnC,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC;QAElB,IAAI,CAAC,UAAU,GAAG,IAAI,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAEzD,IAAI,CAAC,KAAK,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;QACnD,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;QAC1B,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;QACzB,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;QACxB,IAAI,CAAC,cAAc,GAAG,CAAC,CAAC;QACxB,IAAI,CA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AG,IAAI,CAAC;SACnB;QAED,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;IACzB,CAAC;CACF","file":"dataflow.js","sourcesContent":["import type { ILogger } from '@visactor/vutils';\nimport type { IDataflow } from '../types/dataflow';\nimport { isNil, Logger } from '@visactor/vutils';\nimport { Heap } from '../util/grammar-heap';\nimport { UniqueList } from '../util/unique-list';\nimport type { IDataflowCallback, IGrammarBase } from '../types';\n\n/**\n * A dataflow to run all the grammar elements\n */\nexport default class Dataflow implements IDataflow {\n logger: ILogger;\n private grammars: IGrammarBase[] = [];\n /** 当前排序 */\n private _curRank: number;\n /** 发生了变更的元素 */\n private _committed?: UniqueList<IGrammarBase>;\n private _heap?: Heap;\n private _beforeRunner?: IDataflowCallback;\n private _afterRunner?: IDataflowCallback;\n /** 正在运行dataflow */\n private _isRunning?: boolean;\n private _updateCounter: number;\n /** 是否完成初次渲染 */\n private _finishFirstRender?: boolean;\n\n constructor() {\n this.logger = Logger.getInstance();\n\n this._curRank = 0;\n\n this._committed = new UniqueList(grammar => grammar.uid);\n\n this._heap = new Heap((a, b) => a.qrank - b.qrank);\n this._beforeRunner = null;\n this._afterRunner = null;\n this._isRunning = false;\n this._updateCounter = 0;\n this._finishFirstRender = false;\n }\n\n async asyncCallback(callback: (context: IDataflow) => any) {\n try {\n await callback(this);\n } catch (err) {\n this.logger.error(err);\n }\n }\n\n add(grammar: IGrammarBase) {\n if (!grammar) {\n return;\n }\n this._setRankOfGrammar(grammar);\n this.commit(grammar);\n if (!this.grammars.includes(grammar)) {\n this.grammars.push(grammar);\n\n return true;\n }\n\n return false;\n }\n\n remove(grammar: IGrammarBase) {\n if (grammar) {\n this._committed.remove(grammar);\n this._heap.remove(grammar);\n this.grammars = this.grammars.filter(storedGrammar => storedGrammar !== grammar);\n }\n }\n\n private _setRankOfGrammar(grammar?: IGrammarBase) {\n grammar.rank = ++this._curRank;\n }\n\n private _reRank(grammar?: IGrammarBase) {\n const queue = [grammar];\n\n while (queue.length) {\n const cur = queue.pop();\n this._setRankOfGrammar(cur);\n const list = cur.targets;\n\n if (list) {\n list.forEach((entry: IGrammarBase) => {\n queue.push(entry);\n if (entry === grammar) {\n this.logger.error('Cycle detected in dataflow graph.');\n }\n }, true);\n }\n }\n }\n\n private _enqueue(grammar: IGrammarBase) {\n (grammar as any).qrank = grammar.rank;\n // push and reRank in the heap\n this._heap.push(grammar);\n }\n\n private _logGrammarRunInfo(grammar: IGrammarBase) {\n if (this.logger.canLogError()) {\n const debugInfos = [\n { key: 'id', value: grammar.id() },\n { key: 'name', value: grammar.name() }\n ];\n const debugStr = debugInfos.reduce((str, entry, index) => {\n if (!isNil(entry.value)) {\n return `${str}${index ? ' , ' : ''}${entry.key}: ${entry.value}`;\n }\n\n return str;\n }, '');\n\n this.logger.debug('Run Operator: ', grammar, debugStr);\n }\n }\n\n hasCommitted() {\n return !!this._committed.length;\n }\n\n // OPERATOR UPDATES\n commit(grammar: IGrammarBase) {\n if (this._isRunning) {\n // this may lead to a problem, the same op may be added to the queue multiple times\n // if in midst of propagation, add to priority queue\n this._enqueue(grammar);\n } else {\n // otherwise, queue for next propagation\n this._committed.add(grammar);\n }\n\n return this;\n }\n\n private _beforeEvaluate() {\n // reRank grammar element which has higher rank than its targets\n this.grammars.forEach(grammar => {\n if (grammar.targets.some(target => target.rank < grammar.rank)) {\n this._reRank(grammar);\n }\n });\n // initialize priority queue, reset committed grammars\n this._committed.forEach(grammar => this._enqueue(grammar));\n this._committed = new UniqueList(grammar => grammar.uid);\n }\n\n private _enqueueTargets(grammar: IGrammarBase) {\n if (grammar.targets && grammar.targets.length && this._finishFirstRender) {\n grammar.targets.forEach((target: IGrammarBase) => this._enqueue(target));\n }\n }\n\n async evaluate() {\n // invoke prerun function, if provided\n if (this._beforeRunner) {\n await this.asyncCallback(this._beforeRunner);\n }\n\n // exit early if there are no updates\n if (!this._committed.length) {\n this.logger.info('Dataflow invoked, but nothing to do.');\n return false;\n }\n\n this._isRunning = true;\n this._updateCounter += 1;\n let count = 0;\n let grammar;\n let next;\n let dt;\n let error;\n\n if (this.logger.canLogInfo()) {\n dt = Date.now();\n this.logger.debug(`-- START PROPAGATION (${this._updateCounter}) -----`);\n }\n\n this._beforeEvaluate();\n\n try {\n while (this._heap.size() > 0) {\n // dequeue grammar with highest priority\n grammar = this._heap.pop();\n\n // re-queue if rank changed\n if (grammar.rank !== grammar.qrank) {\n this._enqueue(grammar);\n continue;\n }\n\n next = grammar.run();\n\n // await if grammar returned a promise\n if (next && next.then) {\n next = await next;\n }\n\n this._logGrammarRunInfo(grammar);\n this._enqueueTargets(grammar);\n count += 1;\n }\n } catch (err) {\n this._heap.clear();\n error = err;\n }\n\n this._isRunning = false;\n\n if (this.logger.canLogInfo()) {\n dt = Date.now() - dt;\n this.logger.info(`> ${count} grammars; ${dt} ms`);\n }\n\n if (error) {\n this.logger.error(error);\n } else if (this._afterRunner) {\n // invoke callbacks queued via runAfter\n await this.asyncCallback(this._afterRunner);\n }\n\n this._finishFirstRender = true;\n\n return true;\n }\n\n evaluateSync() {\n // invoke prerun function, if provided\n if (this._beforeRunner) {\n this._beforeRunner(this);\n }\n\n // exit early if there are no updates\n if (!this._committed.length) {\n this.logger.info('Dataflow invoked, but nothing to do.');\n return false;\n }\n\n this._isRunning = true;\n this._updateCounter += 1;\n let count = 0;\n let grammar;\n let dt;\n let error;\n\n if (this.logger.canLogInfo()) {\n dt = Date.now();\n this.logger.debug(`-- START PROPAGATION (${this._updateCounter}) -----`);\n }\n\n this._beforeEvaluate();\n\n while (this._heap.size() > 0) {\n // dequeue grammar with highest priority\n grammar = this._heap.pop();\n\n // re-queue if rank changed\n if (grammar.rank !== grammar.qrank) {\n this._enqueue(grammar);\n continue;\n }\n\n grammar.runSync();\n\n this._logGrammarRunInfo(grammar);\n this._enqueueTargets(grammar);\n count += 1;\n }\n\n this._isRunning = false;\n\n if (this.logger.canLogInfo()) {\n dt = Date.now() - dt;\n this.logger.info(`> ${count} grammars updated; ${dt} ms`);\n }\n\n if (error) {\n this.logger.error(error);\n } else if (this._afterRunner) {\n this._afterRunner(this);\n }\n\n this._finishFirstRender = true;\n\n return true;\n }\n\n runBefore(callback?: IDataflowCallback) {\n this._beforeRunner = callback;\n }\n\n runAfter(callback?: IDataflowCallback) {\n this._afterRunner = callback;\n }\n\n release() {\n if (this._heap) {\n this._heap.clear();\n this._heap = null;\n }\n\n this.logger = null;\n this._committed = null;\n }\n}\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { IViewEventConfig } from '../types';
|
|
2
|
+
export declare function initializeEventConfig(config: any): any;
|
|
3
|
+
export declare function prevent(eventConfig: IViewEventConfig, type: string): any;
|
|
4
|
+
export declare function permit(eventConfig: IViewEventConfig, key: string, type: string): boolean;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { isArray, isObject } from "@visactor/vutils";
|
|
2
|
+
|
|
3
|
+
import { EVENT_SOURCE_VIEW, EVENT_SOURCE_WINDOW } from "./constants";
|
|
4
|
+
|
|
5
|
+
export function initializeEventConfig(config) {
|
|
6
|
+
const eventsConfig = Object.assign({
|
|
7
|
+
defaults: {}
|
|
8
|
+
}, config), unpack = (obj, keys) => {
|
|
9
|
+
keys.forEach((k => {
|
|
10
|
+
isArray(obj[k]) && (obj[k] = obj[k].reduce(((set, key) => (set[key] = !0, set)), {}));
|
|
11
|
+
}));
|
|
12
|
+
};
|
|
13
|
+
return unpack(eventsConfig.defaults, [ "prevent", "allow" ]), unpack(eventsConfig, [ EVENT_SOURCE_VIEW, EVENT_SOURCE_WINDOW ]),
|
|
14
|
+
eventsConfig;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function prevent(eventConfig, type) {
|
|
18
|
+
const def = eventConfig.defaults, prevent = def.prevent, allow = def.allow;
|
|
19
|
+
return !1 !== prevent && !0 !== allow && (!0 === prevent || !1 === allow || (prevent ? prevent[type] : !!allow && !allow[type]));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function permit(eventConfig, key, type) {
|
|
23
|
+
const rule = null == eventConfig ? void 0 : eventConfig[key];
|
|
24
|
+
return !(!1 === rule || isObject(rule) && !rule[type]);
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/view/events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAErD,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAQrE,MAAM,UAAU,qBAAqB,CAAC,MAAW;IAC/C,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;IAE7D,MAAM,MAAM,GAAG,CAAC,GAAQ,EAAE,IAAc,EAAE,EAAE;QAC1C,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;YACf,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE;gBACnB,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,GAAQ,EAAE,GAAQ,EAAE,EAAE;oBAC5C,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;oBAChB,OAAO,GAAG,CAAC;gBACb,CAAC,EAAE,EAAE,CAAC,CAAC;aACR;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC;IACpD,MAAM,CAAC,YAAY,EAAE,CAAC,iBAAiB,EAAE,mBAAmB,CAAC,CAAC,CAAC;IAE/D,OAAO,YAAY,CAAC;AACtB,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,WAA6B,EAAE,IAAY;IACjE,MAAM,GAAG,GAAG,WAAW,CAAC,QAAQ,CAAC;IACjC,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC;IAC5B,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC;IAExB,IAAI,OAAO,KAAK,KAAK,IAAI,KAAK,KAAK,IAAI,EAAE;QACvC,OAAO,KAAK,CAAC;KACd;IAED,IAAI,OAAO,KAAK,IAAI,IAAI,KAAK,KAAK,KAAK,EAAE;QACvC,OAAO,IAAI,CAAC;KACb;IAED,IAAI,OAAO,EAAE;QACX,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC;KACtB;IAED,IAAI,KAAK,EAAE;QACT,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;KACrB;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,WAA6B,EAAE,GAAW,EAAE,IAAY;IAC7E,MAAM,IAAI,GAAG,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAG,GAAG,CAAC,CAAC;IAEhC,IAAI,IAAI,KAAK,KAAK,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE;QACrD,OAAO,KAAK,CAAC;KACd;IAED,OAAO,IAAI,CAAC;AACd,CAAC","file":"events.js","sourcesContent":["import { isArray, isObject } from '@visactor/vutils';\nimport type { IViewEventConfig } from '../types';\nimport { EVENT_SOURCE_VIEW, EVENT_SOURCE_WINDOW } from './constants';\n\n/**\n * 初始化事件配置,将所有配置转化为 {[key: string]: boolean } 格式。\n * Initialize event handling configuration.\n * @param {object} config - The configuration settings.\n * @return {object}\n */\nexport function initializeEventConfig(config: any) {\n const eventsConfig = Object.assign({ defaults: {} }, config);\n\n const unpack = (obj: any, keys: string[]) => {\n keys.forEach(k => {\n if (isArray(obj[k])) {\n obj[k] = obj[k].reduce((set: any, key: any) => {\n set[key] = true;\n return set;\n }, {});\n }\n });\n };\n\n unpack(eventsConfig.defaults, ['prevent', 'allow']);\n unpack(eventsConfig, [EVENT_SOURCE_VIEW, EVENT_SOURCE_WINDOW]);\n\n return eventsConfig;\n}\n\nexport function prevent(eventConfig: IViewEventConfig, type: string) {\n const def = eventConfig.defaults;\n const prevent = def.prevent;\n const allow = def.allow;\n\n if (prevent === false || allow === true) {\n return false;\n }\n\n if (prevent === true || allow === false) {\n return true;\n }\n\n if (prevent) {\n return prevent[type];\n }\n\n if (allow) {\n return !allow[type];\n }\n\n return false;\n}\n\nexport function permit(eventConfig: IViewEventConfig, key: string, type: string) {\n const rule = eventConfig?.[key];\n\n if (rule === false || (isObject(rule) && !rule[type])) {\n return false;\n }\n\n return true;\n}\n"]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { GlyphDefaultEncoder, IGlyphMeta, GlyphChannelEncoder, MarkType, GlyphFunctionEncoder } from '../types';
|
|
2
|
+
export declare class GlyphMeta<EncodeValuesType = any, GlyphConfigType = any> implements IGlyphMeta<EncodeValuesType, GlyphConfigType> {
|
|
3
|
+
private marks;
|
|
4
|
+
private channelEncoder;
|
|
5
|
+
private defaultEncoder;
|
|
6
|
+
private functionEncoder;
|
|
7
|
+
private progressiveChannels;
|
|
8
|
+
constructor(marks: {
|
|
9
|
+
[markName: string]: MarkType;
|
|
10
|
+
}, encoders?: {
|
|
11
|
+
[markName: string]: GlyphChannelEncoder<any, EncodeValuesType, GlyphConfigType>;
|
|
12
|
+
}, defaultEncoder?: GlyphDefaultEncoder<GlyphConfigType>, progressiveChannels?: string | string[]);
|
|
13
|
+
getMarks(): {
|
|
14
|
+
[markName: string]: string;
|
|
15
|
+
};
|
|
16
|
+
registerChannelEncoder(encoders: {
|
|
17
|
+
[markName: string]: GlyphChannelEncoder<any, EncodeValuesType, GlyphConfigType>;
|
|
18
|
+
}): this;
|
|
19
|
+
registerChannelEncoder(channel: string, encoder: GlyphChannelEncoder<any, EncodeValuesType, GlyphConfigType>): this;
|
|
20
|
+
registerFunctionEncoder(encoder: GlyphFunctionEncoder<GlyphConfigType>): this;
|
|
21
|
+
registerDefaultEncoder(encoder: GlyphDefaultEncoder<GlyphConfigType>): this;
|
|
22
|
+
registerProgressiveChannels(channels: string | string[]): this;
|
|
23
|
+
getChannelEncoder(): {
|
|
24
|
+
[channel: string]: GlyphChannelEncoder<any, EncodeValuesType, GlyphConfigType>;
|
|
25
|
+
};
|
|
26
|
+
getFunctionEncoder(): GlyphFunctionEncoder<GlyphConfigType>;
|
|
27
|
+
getDefaultEncoder(): GlyphDefaultEncoder<GlyphConfigType>;
|
|
28
|
+
getProgressiveChannels(): string[];
|
|
29
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { array, isString } from "@visactor/vutils";
|
|
2
|
+
|
|
3
|
+
export class GlyphMeta {
|
|
4
|
+
constructor(marks, encoders, defaultEncoder, progressiveChannels) {
|
|
5
|
+
this.channelEncoder = {}, this.marks = marks, encoders && this.registerChannelEncoder(encoders),
|
|
6
|
+
defaultEncoder && this.registerDefaultEncoder(defaultEncoder), this.progressiveChannels && this.registerProgressiveChannels(progressiveChannels);
|
|
7
|
+
}
|
|
8
|
+
getMarks() {
|
|
9
|
+
return this.marks;
|
|
10
|
+
}
|
|
11
|
+
registerChannelEncoder(channel, encoder) {
|
|
12
|
+
return isString(channel) ? this.channelEncoder[channel] = encoder : Object.assign(this.channelEncoder, channel),
|
|
13
|
+
this;
|
|
14
|
+
}
|
|
15
|
+
registerFunctionEncoder(encoder) {
|
|
16
|
+
return this.functionEncoder = encoder, this;
|
|
17
|
+
}
|
|
18
|
+
registerDefaultEncoder(encoder) {
|
|
19
|
+
return this.defaultEncoder = encoder, this;
|
|
20
|
+
}
|
|
21
|
+
registerProgressiveChannels(channels) {
|
|
22
|
+
return this.progressiveChannels = array(channels), this;
|
|
23
|
+
}
|
|
24
|
+
getChannelEncoder() {
|
|
25
|
+
return this.channelEncoder;
|
|
26
|
+
}
|
|
27
|
+
getFunctionEncoder() {
|
|
28
|
+
return this.functionEncoder;
|
|
29
|
+
}
|
|
30
|
+
getDefaultEncoder() {
|
|
31
|
+
return this.defaultEncoder;
|
|
32
|
+
}
|
|
33
|
+
getProgressiveChannels() {
|
|
34
|
+
return this.progressiveChannels;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=glyph-meta.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/view/glyph-meta.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEnD,MAAM,OAAO,SAAS;IAUpB,YACE,KAAuC,EACvC,QAA8F,EAC9F,cAAqD,EACrD,mBAAuC;QATjC,mBAAc,GAAuF,EAAE,CAAC;QAW9G,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,QAAQ,EAAE;YACZ,IAAI,CAAC,sBAAsB,CAAC,QAAQ,CAAC,CAAC;SACvC;QACD,IAAI,cAAc,EAAE;YAClB,IAAI,CAAC,sBAAsB,CAAC,cAAc,CAAC,CAAC;SAC7C;QACD,IAAI,IAAI,CAAC,mBAAmB,EAAE;YAC5B,IAAI,CAAC,2BAA2B,CAAC,mBAAmB,CAAC,CAAC;SACvD;IACH,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAMD,sBAAsB,CACpB,OAAqG,EACrG,OAAqE;QAErE,IAAI,QAAQ,CAAC,OAAO,CAAC,EAAE;YACrB,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;SACxC;aAAM;YACL,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;SAC7C;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,uBAAuB,CAAC,OAA8C;QACpE,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC;QAC/B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,sBAAsB,CAAC,OAA6C;QAClE,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC;QAC9B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,2BAA2B,CAAC,QAA2B;QACrD,IAAI,CAAC,mBAAmB,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC;QAC3C,OAAO,IAAI,CAAC;IACd,CAAC;IAED,iBAAiB;QACf,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IACD,kBAAkB;QAChB,OAAO,IAAI,CAAC,eAAe,CAAC;IAC9B,CAAC;IAED,iBAAiB;QACf,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAED,sBAAsB;QACpB,OAAO,IAAI,CAAC,mBAAmB,CAAC;IAClC,CAAC;CACF","file":"glyph-meta.js","sourcesContent":["import { array, isString } from '@visactor/vutils';\nimport type { GlyphDefaultEncoder, IGlyphMeta, GlyphChannelEncoder, MarkType, GlyphFunctionEncoder } from '../types';\nexport class GlyphMeta<EncodeValuesType = any, GlyphConfigType = any>\n implements IGlyphMeta<EncodeValuesType, GlyphConfigType>\n{\n private marks: { [markName: string]: MarkType };\n\n private channelEncoder: { [channel: string]: GlyphChannelEncoder<any, EncodeValuesType, GlyphConfigType> } = {};\n private defaultEncoder: GlyphDefaultEncoder<GlyphConfigType>;\n private functionEncoder: GlyphFunctionEncoder<GlyphConfigType>;\n private progressiveChannels: string[];\n\n constructor(\n marks: { [markName: string]: MarkType },\n encoders?: { [markName: string]: GlyphChannelEncoder<any, EncodeValuesType, GlyphConfigType> },\n defaultEncoder?: GlyphDefaultEncoder<GlyphConfigType>,\n progressiveChannels?: string | string[]\n ) {\n this.marks = marks;\n if (encoders) {\n this.registerChannelEncoder(encoders);\n }\n if (defaultEncoder) {\n this.registerDefaultEncoder(defaultEncoder);\n }\n if (this.progressiveChannels) {\n this.registerProgressiveChannels(progressiveChannels);\n }\n }\n\n getMarks() {\n return this.marks;\n }\n\n registerChannelEncoder(encoders: {\n [markName: string]: GlyphChannelEncoder<any, EncodeValuesType, GlyphConfigType>;\n }): this;\n registerChannelEncoder(channel: string, encoder: GlyphChannelEncoder<any, EncodeValuesType, GlyphConfigType>): this;\n registerChannelEncoder(\n channel: string | { [markName: string]: GlyphChannelEncoder<any, EncodeValuesType, GlyphConfigType> },\n encoder?: GlyphChannelEncoder<any, EncodeValuesType, GlyphConfigType>\n ) {\n if (isString(channel)) {\n this.channelEncoder[channel] = encoder;\n } else {\n Object.assign(this.channelEncoder, channel);\n }\n return this;\n }\n registerFunctionEncoder(encoder: GlyphFunctionEncoder<GlyphConfigType>) {\n this.functionEncoder = encoder;\n return this;\n }\n\n registerDefaultEncoder(encoder: GlyphDefaultEncoder<GlyphConfigType>) {\n this.defaultEncoder = encoder;\n return this;\n }\n\n registerProgressiveChannels(channels: string | string[]) {\n this.progressiveChannels = array(channels);\n return this;\n }\n\n getChannelEncoder() {\n return this.channelEncoder;\n }\n getFunctionEncoder() {\n return this.functionEncoder;\n }\n\n getDefaultEncoder() {\n return this.defaultEncoder;\n }\n\n getProgressiveChannels() {\n return this.progressiveChannels;\n }\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { GrammarMarkType } from '../graph/enums';
|
|
2
|
+
import type { IGlyphMark, IGroupMark, IView, GlyphMarkSpec, IGlyphMeta } from '../types';
|
|
3
|
+
import { Mark } from './mark';
|
|
4
|
+
export declare class GlyphMark extends Mark implements IGlyphMark {
|
|
5
|
+
protected spec: GlyphMarkSpec;
|
|
6
|
+
markType: GrammarMarkType.glyph;
|
|
7
|
+
readonly glyphType: string;
|
|
8
|
+
private glyphMeta;
|
|
9
|
+
constructor(view: IView, glyphType: string, group?: IGroupMark);
|
|
10
|
+
configureGlyph(config: any): this;
|
|
11
|
+
getGlyphMeta(): IGlyphMeta<any, any>;
|
|
12
|
+
getGlyphConfig(): any;
|
|
13
|
+
addGraphicItem(attrs: any, groupKey?: string): any;
|
|
14
|
+
}
|
package/es/view/glyph.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { GrammarMarkType } from "../graph/enums";
|
|
2
|
+
|
|
3
|
+
import { createGlyphGraphicItem } from "../graph/util/graphic";
|
|
4
|
+
|
|
5
|
+
import { Mark } from "./mark";
|
|
6
|
+
|
|
7
|
+
import { Factory } from "../core/factory";
|
|
8
|
+
|
|
9
|
+
export class GlyphMark extends Mark {
|
|
10
|
+
constructor(view, glyphType, group) {
|
|
11
|
+
super(view, GrammarMarkType.glyph, group), this.glyphType = glyphType, this.glyphMeta = Factory.getGlyph(glyphType);
|
|
12
|
+
}
|
|
13
|
+
configureGlyph(config) {
|
|
14
|
+
return this.spec.glyphConfig = config, this.commit(), this;
|
|
15
|
+
}
|
|
16
|
+
getGlyphMeta() {
|
|
17
|
+
return this.glyphMeta;
|
|
18
|
+
}
|
|
19
|
+
getGlyphConfig() {
|
|
20
|
+
return this.spec.glyphConfig;
|
|
21
|
+
}
|
|
22
|
+
addGraphicItem(attrs, groupKey) {
|
|
23
|
+
const graphicItem = createGlyphGraphicItem(this, this.glyphMeta, attrs);
|
|
24
|
+
return super.addGraphicItem(attrs, groupKey, graphicItem);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=glyph.js.map
|