@motionscript/charts 0.1.0-alpha.5 → 0.1.0-alpha.7

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.
Files changed (146) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/README.md +30 -16
  3. package/dist/bar-chart/bar-chart.d.ts +133 -242
  4. package/dist/bar-chart/bar-chart.d.ts.map +1 -1
  5. package/dist/bar-chart/bar-chart.js +378 -569
  6. package/dist/bar-chart/bar-chart.js.map +1 -1
  7. package/dist/bar-chart/category-axis.d.ts +35 -41
  8. package/dist/bar-chart/category-axis.d.ts.map +1 -1
  9. package/dist/bar-chart/category-axis.js +93 -115
  10. package/dist/bar-chart/category-axis.js.map +1 -1
  11. package/dist/bar-chart/chart-bars.d.ts +50 -70
  12. package/dist/bar-chart/chart-bars.d.ts.map +1 -1
  13. package/dist/bar-chart/chart-bars.js +156 -210
  14. package/dist/bar-chart/chart-bars.js.map +1 -1
  15. package/dist/bar-chart/index.d.ts +2 -2
  16. package/dist/bar-chart/index.d.ts.map +1 -1
  17. package/dist/bar-chart/index.js +1 -1
  18. package/dist/bar-chart/index.js.map +1 -1
  19. package/dist/bar-chart/shared.d.ts +3 -3
  20. package/dist/bar-chart/shared.d.ts.map +1 -1
  21. package/dist/bar-chart/shared.js +3 -3
  22. package/dist/bar-chart/shared.js.map +1 -1
  23. package/dist/browser/chunks/chunk-XROBIRQK.js +2 -0
  24. package/dist/browser/chunks/chunk-XROBIRQK.js.map +7 -0
  25. package/dist/browser/index.js +1 -1
  26. package/dist/browser/index.js.map +3 -3
  27. package/dist/browser/kit.js +1 -1
  28. package/dist/browser/manifest.json +1 -1
  29. package/dist/engine.d.ts +8 -6
  30. package/dist/engine.d.ts.map +1 -1
  31. package/dist/engine.js +8 -6
  32. package/dist/engine.js.map +1 -1
  33. package/dist/kit/cartesian.d.ts +44 -0
  34. package/dist/kit/cartesian.d.ts.map +1 -0
  35. package/dist/kit/cartesian.js +59 -0
  36. package/dist/kit/cartesian.js.map +1 -0
  37. package/dist/kit/chart-border.d.ts +10 -11
  38. package/dist/kit/chart-border.d.ts.map +1 -1
  39. package/dist/kit/chart-border.js +15 -32
  40. package/dist/kit/chart-border.js.map +1 -1
  41. package/dist/kit/chart-canvas.d.ts +32 -21
  42. package/dist/kit/chart-canvas.d.ts.map +1 -1
  43. package/dist/kit/chart-canvas.js +33 -90
  44. package/dist/kit/chart-canvas.js.map +1 -1
  45. package/dist/kit/chart-legend.d.ts +123 -64
  46. package/dist/kit/chart-legend.d.ts.map +1 -1
  47. package/dist/kit/chart-legend.js +129 -154
  48. package/dist/kit/chart-legend.js.map +1 -1
  49. package/dist/kit/entries.d.ts +17 -0
  50. package/dist/kit/entries.d.ts.map +1 -0
  51. package/dist/kit/entries.js +19 -0
  52. package/dist/kit/entries.js.map +1 -0
  53. package/dist/kit/motion.d.ts +48 -0
  54. package/dist/kit/motion.d.ts.map +1 -0
  55. package/dist/kit/motion.js +63 -0
  56. package/dist/kit/motion.js.map +1 -0
  57. package/dist/kit/paints.d.ts +10 -0
  58. package/dist/kit/paints.d.ts.map +1 -0
  59. package/dist/kit/paints.js +12 -0
  60. package/dist/kit/paints.js.map +1 -0
  61. package/dist/kit/shared.d.ts +31 -3
  62. package/dist/kit/shared.d.ts.map +1 -1
  63. package/dist/kit/shared.js +42 -3
  64. package/dist/kit/shared.js.map +1 -1
  65. package/dist/kit/vertical-axis.d.ts +48 -61
  66. package/dist/kit/vertical-axis.d.ts.map +1 -1
  67. package/dist/kit/vertical-axis.js +97 -132
  68. package/dist/kit/vertical-axis.js.map +1 -1
  69. package/dist/line-chart/chart-line.d.ts +60 -77
  70. package/dist/line-chart/chart-line.d.ts.map +1 -1
  71. package/dist/line-chart/chart-line.js +100 -121
  72. package/dist/line-chart/chart-line.js.map +1 -1
  73. package/dist/line-chart/chart-region.d.ts +32 -33
  74. package/dist/line-chart/chart-region.d.ts.map +1 -1
  75. package/dist/line-chart/chart-region.js +31 -65
  76. package/dist/line-chart/chart-region.js.map +1 -1
  77. package/dist/line-chart/horizontal-axis.d.ts +58 -64
  78. package/dist/line-chart/horizontal-axis.d.ts.map +1 -1
  79. package/dist/line-chart/horizontal-axis.js +94 -123
  80. package/dist/line-chart/horizontal-axis.js.map +1 -1
  81. package/dist/line-chart/index.d.ts +2 -2
  82. package/dist/line-chart/index.d.ts.map +1 -1
  83. package/dist/line-chart/index.js +1 -1
  84. package/dist/line-chart/index.js.map +1 -1
  85. package/dist/line-chart/line-chart.d.ts +156 -319
  86. package/dist/line-chart/line-chart.d.ts.map +1 -1
  87. package/dist/line-chart/line-chart.js +403 -663
  88. package/dist/line-chart/line-chart.js.map +1 -1
  89. package/dist/line-chart/shared.d.ts +3 -3
  90. package/dist/line-chart/shared.d.ts.map +1 -1
  91. package/dist/line-chart/shared.js +3 -3
  92. package/dist/line-chart/shared.js.map +1 -1
  93. package/dist/nodes.d.ts +6 -9
  94. package/dist/nodes.d.ts.map +1 -1
  95. package/dist/nodes.js +7 -9
  96. package/dist/nodes.js.map +1 -1
  97. package/dist/pie-chart/index.d.ts +2 -2
  98. package/dist/pie-chart/index.d.ts.map +1 -1
  99. package/dist/pie-chart/index.js +1 -1
  100. package/dist/pie-chart/index.js.map +1 -1
  101. package/dist/pie-chart/pie-chart.d.ts +108 -132
  102. package/dist/pie-chart/pie-chart.d.ts.map +1 -1
  103. package/dist/pie-chart/pie-chart.js +200 -271
  104. package/dist/pie-chart/pie-chart.js.map +1 -1
  105. package/dist/pie-chart/pie-legend.d.ts +84 -31
  106. package/dist/pie-chart/pie-legend.d.ts.map +1 -1
  107. package/dist/pie-chart/pie-legend.js +93 -107
  108. package/dist/pie-chart/pie-legend.js.map +1 -1
  109. package/dist/pie-chart/pie-ring.d.ts +160 -131
  110. package/dist/pie-chart/pie-ring.d.ts.map +1 -1
  111. package/dist/pie-chart/pie-ring.js +333 -391
  112. package/dist/pie-chart/pie-ring.js.map +1 -1
  113. package/dist/pie-chart/shared.d.ts +2 -2
  114. package/dist/pie-chart/shared.d.ts.map +1 -1
  115. package/dist/pie-chart/shared.js +2 -2
  116. package/dist/pie-chart/shared.js.map +1 -1
  117. package/package.json +4 -4
  118. package/src/bar-chart/bar-chart.ts +415 -701
  119. package/src/bar-chart/category-axis.ts +95 -110
  120. package/src/bar-chart/chart-bars.ts +178 -200
  121. package/src/bar-chart/index.ts +2 -2
  122. package/src/bar-chart/shared.ts +3 -3
  123. package/src/engine.ts +8 -6
  124. package/src/kit/cartesian.ts +81 -0
  125. package/src/kit/chart-border.ts +22 -33
  126. package/src/kit/chart-canvas.ts +44 -79
  127. package/src/kit/chart-legend.ts +173 -189
  128. package/src/kit/entries.ts +20 -0
  129. package/src/kit/motion.ts +90 -0
  130. package/src/kit/paints.ts +15 -0
  131. package/src/kit/shared.ts +52 -3
  132. package/src/kit/vertical-axis.ts +110 -140
  133. package/src/line-chart/chart-line.ts +102 -154
  134. package/src/line-chart/chart-region.ts +35 -80
  135. package/src/line-chart/horizontal-axis.ts +101 -152
  136. package/src/line-chart/index.ts +2 -2
  137. package/src/line-chart/line-chart.ts +449 -825
  138. package/src/line-chart/shared.ts +3 -3
  139. package/src/nodes.ts +8 -10
  140. package/src/pie-chart/index.ts +2 -2
  141. package/src/pie-chart/pie-chart.ts +221 -311
  142. package/src/pie-chart/pie-legend.ts +124 -114
  143. package/src/pie-chart/pie-ring.ts +386 -473
  144. package/src/pie-chart/shared.ts +2 -2
  145. package/dist/browser/chunks/chunk-5ZPBV6BU.js +0 -2
  146. package/dist/browser/chunks/chunk-5ZPBV6BU.js.map +0 -7
@@ -1 +1 @@
1
- {"version":3,"file":"chart-legend.js","sourceRoot":"","sources":["../../src/kit/chart-legend.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EACL,IAAI,EACJ,IAAI,EACJ,OAAO,EACP,OAAO,EACP,QAAQ,EACR,OAAO,GASR,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAiB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AE,CAAC,CAClF,CACJ,CAAA;IACH,CAAC;CACF;AAnK2D;IAAzD,QAAQ,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,EAAmB,EAAE,CAAC;2CAA8B;AAC5B;IAAlD,QAAQ,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,EAAY,EAAE,CAAC;6CAAyB;AACpB;IAA9C,QAAQ,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC;2CAA6B;AAsBN;IAA5D,QAAQ,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,EAAc,EAAE,CAAC;2CAAiC;AA6E7E;IADC,OAAO,EAAE;6CAIT;AAOD;IADC,OAAO,EAAE;6CAIT;AAkCD;IADC,OAAO,EAAE;kDAeT","sourcesContent":["import {\r\n Rect,\r\n Text,\r\n command,\r\n easeOut,\r\n property,\r\n textOps,\r\n type CommandArgs,\r\n type EasingFunction,\r\n type Fill,\r\n type MeasureContext2D,\r\n type NodeConfig,\r\n type RectProps,\r\n type Size2D,\r\n type SizeConstraints,\r\n} from \"@motionscript/sdk\"\r\n\r\nimport { drive, hold, together, type Seekable } from \"@motionscript/sdk/component\"\r\n\r\nimport {\r\n DEFAULT_LEGEND,\r\n SPOTLIGHT_DIM,\r\n type ChartSeries,\r\n type LegendConfig,\r\n} from \"./shared\"\r\n\r\nexport interface ChartLegendProps extends RectProps {\r\n /**\r\n * One entry per series: legend `label`, its `enabled` default, and — through\r\n * {@link ChartLegendProps.swatches} — the colour its chip is painted. A series\r\n * that starts enabled (the default) is added to the row up front; one that\r\n * starts `false` is hidden until a later {@link ChartLegend.showSeries}.\r\n */\r\n series: ChartSeries[]\r\n /**\r\n * The swatch colour for each series, by index — resolved by the chart, whose\r\n * business it is whether a series' colour comes out of a stroke palette (a\r\n * line) or a fill palette (a bar). Shorter than the series list means the\r\n * missing entries fall back to white.\r\n */\r\n swatches: Fill[]\r\n /** Padding, caption style, gaps, and swatch geometry — see {@link LegendConfig}. */\r\n legend: LegendConfig\r\n}\r\n\r\n/**\r\n * One legend entry. It hugs its caption and swatch; `shown` scales that width from\r\n * nothing to the whole of it.\r\n *\r\n * The width is taken from the content on every measure, at any reveal, so a frame\r\n * never depends on whether the entry was once seen fully shown. A collapse needs a\r\n * number to scale, and `\"hug\"` is not one until something measures it — this is\r\n * the something.\r\n */\r\nclass LegendEntry extends Rect {\r\n constructor(props: NodeConfig<Rect, RectProps>, private readonly _shown: () => number) {\r\n super(props)\r\n }\r\n\r\n override measure(constraints: SizeConstraints, scope: MeasureContext2D): Partial<Size2D> {\r\n const size = super.measure(constraints, scope)\r\n const shown = this._shown()\r\n return shown >= 1 ? size : { ...size, width: shown * (size.width ?? 0) }\r\n }\r\n}\r\n\r\n/**\r\n * The legend of a chart: a **horizontal-flow row of entries**, one per series, laid out\r\n * left-to-right with the theme's `itemGap`. Each entry pairs the series label\r\n * with a rounded colour swatch; only the swatch carries the series colour, the\r\n * caption reads in the legend's neutral ink.\r\n *\r\n * {@link showSeries}/{@link hideSeries} flip a series on or off — showing one\r\n * adds its entry back into the row at its stable series position and grows it\r\n * in, hiding one shrinks it away and removes it. So the row only ever holds the\r\n * currently-enabled series, in series order, and closes the gap when one leaves.\r\n *\r\n * This node *is* the row, so the parent places it (centred below the chart) and\r\n * it hugs its entries.\r\n */\r\nexport class ChartLegend extends Rect {\r\n @property({ default: () => [] as ChartSeries[] }) declare series: ChartSeries[]\r\n @property({ default: () => [] as Fill[] }) declare swatches: Fill[]\r\n @property({ default: DEFAULT_LEGEND }) declare legend: LegendConfig\r\n\r\n /** One entry per series. **Every** entry is a child — see {@link reveal}. */\r\n private items: LegendEntry[] = []\r\n /**\r\n * How far each entry is shown, `0`–`1`. Drives its width, opacity and gap\r\n * together, so `0` is an entry that takes no room and `1` is one at its\r\n * natural size.\r\n *\r\n * This replaces adding and removing the entry from the row, which is what\r\n * `showSeries`/`hideSeries` used to do. That could not be a command: a command\r\n * is asked what it looks like at a time, and \"is this node a child\" is not a\r\n * value a time can produce — the tree either contains it or it doesn't, and\r\n * getting there means having run the add. Collapsed-but-present is the same\r\n * picture reached by a route that *is* a function of `t`.\r\n *\r\n * One array in one slot, because the count is the series count, which is data.\r\n * It is replaced rather than mutated: a write is a slot write, so the timeline\r\n * sees it and restores it to the authored reveal before the command starts\r\n * and after a seek back. The entries' props are bound to it, so writing it\r\n * still moves the layout.\r\n */\r\n @property({ default: () => [] as number[] }) private declare reveal: number[]\r\n\r\n constructor(props?: NodeConfig<ChartLegend, ChartLegendProps>) {\r\n // `flow` after the spread, with the rest of the geometry: this class *is*\r\n // the row, so the direction is its own answer and not the caller's. It has\r\n // to be stated — a `Rect` given no flow lays its children out `freeform`,\r\n // which stacks every entry on the same spot. One series looks perfect that\r\n // way and three look like one smeared caption, so the failure only shows up\r\n // on the charts that most need a legend.\r\n super({\r\n ...(props as RectProps),\r\n flow: \"horizontal\",\r\n align: \"center\",\r\n width: \"hug\",\r\n height: \"hug\",\r\n })\r\n\r\n // Structure is one entry per series, so it's composed here from the resolved\r\n // props super() applied. Fixed row geometry last, so it wins over super().\r\n this.set({ gap: this.legend.itemGap, padding: this.legend.padding })\r\n\r\n this.reveal = this.series.map((s) => ((s.enabled ?? true) ? 1 : 0))\r\n this.items = this.series.map((s, i) => this.buildItem(s, i))\r\n\r\n // All of them, in series order. Order is now fixed rather than depending on\r\n // which siblings happen to be shown, so an entry always comes back where it\r\n // belongs and `insertionIndex` has nothing left to compute.\r\n for (const item of this.items) this.add(item)\r\n }\r\n\r\n /** One entry: the series caption beside its colour swatch. */\r\n private buildItem(series: ChartSeries, index: number): LegendEntry {\r\n const marker = this.legend.markerStyle\r\n const item = new LegendEntry({ flow: \"horizontal\",\r\n gap: 12,\r\n align: \"center\",\r\n // Bound to the reveal, so showing and hiding is a number moving rather\r\n // than a child arriving and leaving. The width follows it in `measure`.\r\n width: \"hug\",\r\n opacity: () => this.reveal[index] ?? 0,\r\n height: \"hug\",\r\n children: [\r\n new Text({\r\n ...textOps.styleProps(this.legend.textStyle),\r\n text: series.label,\r\n }),\r\n new Rect({\r\n width: marker.width,\r\n height: marker.height,\r\n cornerRadius: marker.borderRadius,\r\n fill: this.swatches[index] ?? \"white\",\r\n stroke: marker.stroke,\r\n shadow: marker.shadow,\r\n }),\r\n ],\r\n }, () => this.reveal[index] ?? 0)\r\n // `gapScale` is a `Node` prop rather than a container one, so it is bound here\r\n // instead of in the config. It tracks the reveal so the flanking gap closes\r\n // with the entry rather than snapping when it reaches zero.\r\n item.set({ gapScale: () => this.reveal[index] ?? 0 })\r\n return item\r\n }\r\n\r\n /** True if series `index` is showing at all — see {@link reveal}. */\r\n isEnabled(index: number): boolean {\r\n return (this.reveal[index] ?? 0) > 0\r\n }\r\n\r\n /**\r\n * Grow series `index`'s entry back in at its series-order position, the\r\n * siblings sliding over to make room.\r\n *\r\n * A reveal tween rather than an animated `addChildAt`. The entry never left —\r\n * see {@link reveal} — so there is no add to have happened, and the whole\r\n * thing is a function of `t`.\r\n */\r\n @command()\r\n showSeries(args: CommandArgs<{ index: number }>): Seekable {\r\n const { index = 0 } = args.data ?? {}\r\n return this.revealTo(index, 1, args.duration ?? 0.35, args.easing ?? easeOut())\r\n }\r\n\r\n /**\r\n * Shrink series `index`'s entry away, the gap closing behind it — the mirror\r\n * of {@link showSeries}.\r\n */\r\n @command()\r\n hideSeries(args: CommandArgs<{ index: number }>): Seekable {\r\n const { index = 0 } = args.data ?? {}\r\n return this.revealTo(index, 0, args.duration ?? 0.35, args.easing ?? easeOut())\r\n }\r\n\r\n /**\r\n * Ramp one entry's reveal to `target`.\r\n *\r\n * `from` is read when the command is built, which for a driven scene is with\r\n * the node in the state its own start time implies — so a hide that follows a\r\n * show starts where the show left it rather than at whatever the node happens\r\n * to hold now.\r\n */\r\n private revealTo(\r\n index: number,\r\n target: number,\r\n duration: number,\r\n easing: EasingFunction\r\n ): Seekable {\r\n if (this.items[index] === undefined) return hold(duration)\r\n const from = this.reveal[index] ?? 0\r\n return drive(duration, (t) => {\r\n const next = [...this.reveal]\r\n next[index] = from + (target - from) * easing(t)\r\n this.reveal = next\r\n })\r\n }\r\n\r\n /**\r\n * Dim every entry but series `index` to {@link SPOTLIGHT_DIM} and bring that\r\n * one back to full — the legend half of a chart's `spotlightSeries`. Entries\r\n * stay in place; only their opacity moves, so the row doesn't reflow.\r\n *\r\n * Only the currently-shown entries are touched — a hidden series' entry is\r\n * left as {@link hideSeries} left it.\r\n */\r\n @command()\r\n spotlightSeries(args: CommandArgs<{ index: number }>): Seekable {\r\n const { index = 0 } = args.data ?? {}\r\n const duration = args.duration ?? 0.35\r\n const easing = args.easing ?? easeOut()\r\n // Opacity only, on entries that are already in the row — no membership\r\n // changes, so unlike {@link showSeries} this is a plain function of `t`.\r\n return together(\r\n ...this.items\r\n .map((item, i) => ({ item, i }))\r\n .filter(({ i }) => this.isEnabled(i))\r\n .map(({ item, i }) =>\r\n item.to({ data: { opacity: i === index ? 1 : SPOTLIGHT_DIM }, duration, easing })\r\n )\r\n )\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"chart-legend.js","sourceRoot":"","sources":["../../src/kit/chart-legend.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,MAAM,EACN,IAAI,EACJ,KAAK,EACL,WAAW,EACX,OAAO,GAqBR,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAA;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AACpC,OAAO,EACL,cAAc,EACd,aAAa,GAGd,MAAM,UAAU,CAAA;AAqBjB,oFAAoF;AACpF,MAAM,GAAG,GAAG,EAAE,GAAG,KAAK,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,KAAK,EAAE,GAAG,MAAM,CAAC,OAAO,EAAE,CAAA;AAEhE;;;;;;;;GAQG;AACH,MAAM,WAAW,GAAG,WAAW,CAAC;IAC9B,GAAG,EAAE,aAAa;IAClB,KAAK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AAM,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAA;AACxC,CAAC","sourcesContent":["import {\r\n Flow,\r\n Paint,\r\n Rect,\r\n Shapes,\r\n Text,\r\n Types,\r\n component2d,\r\n textOps,\r\n type Fill,\r\n type NodeOf,\r\n type RectProps,\r\n // Named so the row's emitted type reaches the Rect surface it spreads through the sdk, not core.\r\n type Alignment as _Alignment,\r\n type CornerRadiusResolved as _CornerRadiusResolved,\r\n type CornerStyleResolved as _CornerStyleResolved,\r\n type FillResolved as _FillResolved,\r\n type FlowMode as _FlowMode,\r\n type FlowResolved as _FlowResolved,\r\n type GapSize as _GapSize,\r\n type Node2D as _Node2D,\r\n type Node2DProps as _Node2DProps,\r\n type RectCornerRadius as _RectCornerRadius,\r\n type RectCornerStyle as _RectCornerStyle,\r\n type Shadow as _Shadow,\r\n type ShadowResolved as _ShadowResolved,\r\n type Stroke as _Stroke,\r\n type StrokeResolved as _StrokeResolved,\r\n type Vector2 as _Vector2,\r\n} from \"@motionscript/sdk\"\r\n\r\nimport { fresh } from \"./entries\"\r\nimport { frameEase } from \"./motion\"\r\nimport {\r\n DEFAULT_LEGEND,\r\n SPOTLIGHT_DIM,\r\n type ChartSeries,\r\n type LegendConfig,\r\n} from \"./shared\"\r\n\r\nexport interface ChartLegendProps extends RectProps {\r\n /**\r\n * One entry per series: legend `label`, its `enabled` default, and — through\r\n * {@link ChartLegendProps.swatches} — the colour its chip is painted. A series\r\n * that starts enabled (the default) is added to the row up front; one that\r\n * starts `false` is hidden until a later `showSeries`.\r\n */\r\n series: ChartSeries[]\r\n /**\r\n * The swatch colour for each series, by index — resolved by the chart, whose\r\n * business it is whether a series' colour comes out of a stroke palette (a\r\n * line) or a fill palette (a bar). Shorter than the series list means the\r\n * missing entries fall back to white.\r\n */\r\n swatches: Fill[]\r\n /** Padding, caption style, gaps, and swatch geometry — see {@link LegendConfig}. */\r\n legend: LegendConfig\r\n}\r\n\r\n/** A row's entries are a `Rect`'s: paint, the flow of its children, its corners. */\r\nconst row = { ...Paint.state, ...Flow.state, ...Shapes.corners }\r\n\r\n/**\r\n * One legend entry. It hugs its caption and swatch; `shown` scales that width\r\n * from nothing to the whole of it.\r\n *\r\n * The width is taken from the content on every measure, at any reveal, so a frame\r\n * never depends on whether the entry was once seen fully shown. A collapse needs a\r\n * number to scale, and `\"hug\"` is not one until something measures it — this is\r\n * the something.\r\n */\r\nconst LegendEntry = component2d({\r\n key: \"legendEntry\",\r\n state: { ...row, shown: Types.number(1) },\r\n commands: { ...Paint.commands },\r\n measure: (measurer, state, children) => {\r\n const size = Flow.measure(measurer, state, children, Paint.inset(state))\r\n return state.shown >= 1 ? size : { ...size, width: state.shown * size.width }\r\n },\r\n layout: (box, state, children) => Flow.layout(box, state, children, Paint.inset(state)),\r\n render: (ctx, state) => Paint.draw(ctx, state, Shapes.rect(ctx.size, state)),\r\n})\r\n\r\n/**\r\n * How far each entry is shown, written whole (a document, a `set`) or one\r\n * entry at a time (a command, as `{ [index]: reveal }`), which leaves the others\r\n * as the frame left them — so two series moving at once each move their own.\r\n */\r\nfunction revealOf(value: readonly number[] | Readonly<Record<number, number>>, previous?: number[]): number[] {\r\n if (Array.isArray(value)) return value as number[]\r\n const next = [...(previous ?? [])]\r\n for (const [index, reveal] of Object.entries(value)) next[Number(index)] = reveal\r\n return next\r\n}\r\n\r\n/**\r\n * The legend of a chart: a **horizontal-flow row of entries**, one per series, laid out\r\n * left-to-right with the theme's `itemGap`. Each entry pairs the series label\r\n * with a rounded colour swatch; only the swatch carries the series colour, the\r\n * caption reads in the legend's neutral ink.\r\n *\r\n * `showSeries`/`hideSeries` flip a series on or off — showing one grows its\r\n * entry back in at its stable series position, hiding one shrinks it away. So\r\n * the row only ever shows the currently-enabled series, in series order, and\r\n * closes the gap when one leaves.\r\n *\r\n * This node *is* the row, so the parent places it (centred below the chart) and\r\n * it hugs its entries.\r\n */\r\nexport const ChartLegend = component2d({\r\n key: \"chartLegend\",\r\n state: {\r\n ...row,\r\n series: fresh<ChartSeries[]>(() => []),\r\n swatches: fresh<Fill[]>(() => []),\r\n legend: Types.custom<LegendConfig>(DEFAULT_LEGEND),\r\n /**\r\n * How far each entry is shown, `0`–`1`. Drives its width, opacity and gap\r\n * together, so `0` is an entry that takes no room and `1` is one at its\r\n * natural size.\r\n *\r\n * This replaces adding and removing the entry from the row: a command is\r\n * asked what it looks like at a time, and \"is this node a child\" is not a\r\n * value a time can produce. Collapsed-but-present is the same picture reached\r\n * by a route that *is* a function of `t`.\r\n */\r\n reveal: fresh<number[], number[] | Readonly<Record<number, number>>>(() => [], { resolve: revealOf }),\r\n },\r\n // This node *is* the row, so the direction is its own answer. It has to be\r\n // stated — a `Rect` given no flow lays its children out `freeform`, which\r\n // stacks every entry on the same spot. The gap and padding are the theme's.\r\n defaults: {\r\n flow: \"horizontal\",\r\n width: \"hug\",\r\n height: \"hug\",\r\n gap: (state) => state.legend.itemGap,\r\n padding: (state) => state.legend.padding,\r\n reveal: (state) => state.series.map((s) => ((s.enabled ?? true) ? 1 : 0)),\r\n },\r\n // One entry per series, in series order, every one a child for good: order is\r\n // fixed rather than depending on which siblings happen to be shown, so an entry\r\n // always comes back where it belongs.\r\n children: (state) => {\r\n const marker = state.legend.markerStyle\r\n return state.series.map((series, index) =>\r\n LegendEntry({\r\n flow: \"horizontal\",\r\n gap: 12,\r\n align: \"center\",\r\n width: \"hug\",\r\n height: \"hug\",\r\n // Bound to the reveal, so showing and hiding is a number moving rather\r\n // than a child arriving and leaving. The width follows it in `measure`,\r\n // and the flanking gap closes with the entry rather than snapping.\r\n opacity: () => state.reveal[index] ?? 0,\r\n gapScale: () => state.reveal[index] ?? 0,\r\n shown: () => state.reveal[index] ?? 0,\r\n children: [\r\n Text({ ...textOps.styleProps(state.legend.textStyle), text: series.label }),\r\n Rect({\r\n width: marker.width,\r\n height: marker.height,\r\n cornerRadius: marker.borderRadius,\r\n fill: state.swatches[index] ?? \"white\",\r\n stroke: marker.stroke,\r\n shadow: marker.shadow,\r\n }),\r\n ],\r\n })\r\n )\r\n },\r\n commands: {\r\n ...Paint.commands,\r\n /**\r\n * Grow series `index`'s entry back in at its series-order position, the\r\n * siblings sliding over to make room. A reveal tween rather than an animated\r\n * `addChildAt`: the entry never left, so the whole thing is a function of `t`.\r\n */\r\n showSeries: {\r\n args: { index: Types.number(0, { min: 0, step: 1 }) },\r\n // An index that is not a series takes its slot and moves nothing.\r\n run: (timeline, state) => (timeline.args.index in state.series\r\n ? timeline.animate(revealFrame(state, timeline.args.index, 1, frameEase(timeline)))\r\n : timeline.wait(timeline.duration)),\r\n },\r\n /** Shrink series `index`'s entry away, the gap closing behind it — the mirror of `showSeries`. */\r\n hideSeries: {\r\n args: { index: Types.number(0, { min: 0, step: 1 }) },\r\n run: (timeline, state) => (timeline.args.index in state.series\r\n ? timeline.animate(revealFrame(state, timeline.args.index, 0, frameEase(timeline)))\r\n : timeline.wait(timeline.duration)),\r\n },\r\n /**\r\n * Dim every entry but series `index` to {@link SPOTLIGHT_DIM} and bring that\r\n * one back to full — the legend half of a chart's `spotlightSeries`. Entries\r\n * stay in place; only their opacity moves, so the row doesn't reflow. Only\r\n * the entries shown when it is built are touched: a hidden series' entry is\r\n * left as `hideSeries` left it.\r\n */\r\n spotlightSeries: {\r\n args: { index: Types.number(0, { min: 0, step: 1 }) },\r\n run: (timeline, state, children) =>\r\n timeline.together(\r\n children.flatMap((entry, i) =>\r\n (state.reveal[i] ?? 0) > 0 ? [entry.to({ opacity: i === timeline.args.index ? 1 : SPOTLIGHT_DIM })] : []\r\n )\r\n ),\r\n },\r\n },\r\n measure: (measurer, state, children) => Flow.measure(measurer, state, children, Paint.inset(state)),\r\n layout: (box, state, children) => Flow.layout(box, state, children, Paint.inset(state)),\r\n render: (ctx, state) => Paint.draw(ctx, state, Shapes.rect(ctx.size, state)),\r\n})\r\n\r\n/**\r\n * One entry's reveal ramping to `target` from where the command finds it — so a\r\n * hide that follows a show starts where the show left it.\r\n */\r\nfunction revealFrame(state: { readonly reveal: readonly number[] }, index: number, target: number, ease: (t: number) => number) {\r\n const from = state.reveal[index] ?? 0\r\n return (t: number) => ({ reveal: { [index]: from + (target - from) * ease(t) } })\r\n}\r\n\r\n/** Whether series `index` is showing at all on `legend`. */\r\nexport function legendShows(legend: { readonly reveal: readonly number[] }, index: number): boolean {\r\n return (legend.reveal[index] ?? 0) > 0\r\n}\r\n\r\nexport type ChartLegend = NodeOf<typeof ChartLegend>\r\n"]}
@@ -0,0 +1,17 @@
1
+ import { type Element, type Node2D, type Type } from "@motionscript/sdk";
2
+ /**
3
+ * An entry made fresh for every node: each node gets its own array or box
4
+ * rather than one shared literal, and a host is told no default for it.
5
+ */
6
+ export declare function fresh<T, In = T>(make: () => T, options?: {
7
+ readonly resolve?: (value: In) => T;
8
+ readonly kind?: string;
9
+ }): Type<In, T>;
10
+ /**
11
+ * Nodes a `children` builder made with `new`, as the elements it returns. A
12
+ * part built that way can be read in a binding — its own box, or its parent's,
13
+ * which is the component it was built for — where a call would hand back only
14
+ * the element.
15
+ */
16
+ export declare function asParts(nodes: readonly Node2D[]): readonly Element[];
17
+ //# sourceMappingURL=entries.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entries.d.ts","sourceRoot":"","sources":["../../src/kit/entries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,IAAI,EAAE,MAAM,mBAAmB,CAAA;AAE/E;;;GAGG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,EAAE,GAAG,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,EAAE;IAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE,KAAK,CAAC,CAAC;IAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,CAGtI;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,OAAO,EAAE,CAEpE"}
@@ -0,0 +1,19 @@
1
+ import { Types } from "@motionscript/sdk";
2
+ /**
3
+ * An entry made fresh for every node: each node gets its own array or box
4
+ * rather than one shared literal, and a host is told no default for it.
5
+ */
6
+ export function fresh(make, options) {
7
+ // A function default is a factory: the component calls it once per node.
8
+ return Types.custom(make, options);
9
+ }
10
+ /**
11
+ * Nodes a `children` builder made with `new`, as the elements it returns. A
12
+ * part built that way can be read in a binding — its own box, or its parent's,
13
+ * which is the component it was built for — where a call would hand back only
14
+ * the element.
15
+ */
16
+ export function asParts(nodes) {
17
+ return nodes;
18
+ }
19
+ //# sourceMappingURL=entries.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entries.js","sourceRoot":"","sources":["../../src/kit/entries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAwC,MAAM,mBAAmB,CAAA;AAE/E;;;GAGG;AACH,MAAM,UAAU,KAAK,CAAY,IAAa,EAAE,OAAyE;IACvH,yEAAyE;IACzE,OAAO,KAAK,CAAC,MAAM,CAAQ,IAAqB,EAAE,OAAO,CAAC,CAAA;AAC5D,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,OAAO,CAAC,KAAwB;IAC9C,OAAO,KAAsC,CAAA;AAC/C,CAAC","sourcesContent":["import { Types, type Element, type Node2D, type Type } from \"@motionscript/sdk\"\r\n\r\n/**\r\n * An entry made fresh for every node: each node gets its own array or box\r\n * rather than one shared literal, and a host is told no default for it.\r\n */\r\nexport function fresh<T, In = T>(make: () => T, options?: { readonly resolve?: (value: In) => T; readonly kind?: string }): Type<In, T> {\r\n // A function default is a factory: the component calls it once per node.\r\n return Types.custom<In, T>(make as unknown as In, options)\r\n}\r\n\r\n/**\r\n * Nodes a `children` builder made with `new`, as the elements it returns. A\r\n * part built that way can be read in a binding — its own box, or its parent's,\r\n * which is the component it was built for — where a call would hand back only\r\n * the element.\r\n */\r\nexport function asParts(nodes: readonly Node2D[]): readonly Element[] {\r\n return nodes as unknown as readonly Element[]\r\n}\r\n"]}
@@ -0,0 +1,48 @@
1
+ import { type EasingFunction, type Piece, type Timeline } from "@motionscript/sdk";
2
+ /** Any component's timeline: these helpers only build pieces, which every timeline builds alike. */
3
+ type AnyTimeline = Timeline<any, any>;
4
+ /**
5
+ * The ease a part's own frames apply to `t`: none when its command was given
6
+ * one, which already eases every frame the command builds, and otherwise the
7
+ * ease-out every chart command defaults to.
8
+ */
9
+ export declare function frameEase(timeline: {
10
+ readonly easing: EasingFunction | undefined;
11
+ }): EasingFunction;
12
+ /** A piece of a command placed at its own time: from `at` seconds, for `duration` seconds. */
13
+ export interface Beat {
14
+ readonly at: number;
15
+ readonly duration: number;
16
+ readonly piece: Piece;
17
+ }
18
+ /**
19
+ * `beats` at their own offsets over the command, each eased on its own and held
20
+ * at its last frame once it is done. A beat ahead of the playhead writes nothing,
21
+ * so whatever stands before it is written by a piece ahead of these. Beats that
22
+ * run past the command are played faster to end with it.
23
+ */
24
+ export declare function beats(timeline: AnyTimeline, parts: readonly Beat[]): Piece;
25
+ /** How far one piece of a staggered entrance has come: its opacity, and how far it still sits off its place. */
26
+ export interface Arrival {
27
+ readonly opacity: number;
28
+ readonly shift: number;
29
+ }
30
+ /** Each piece's arrival, by key. An unlisted piece has landed. */
31
+ export type Arrivals = Readonly<Record<string, Arrival>>;
32
+ export declare const LANDED: Arrival;
33
+ /**
34
+ * A part's private record of its pieces' arrivals. A write merges into it, so
35
+ * beats placed apart each write their own piece and leave the others as the
36
+ * frame left them.
37
+ */
38
+ export declare function arrivalsEntry(): import("@motionscript/sdk").Type<Readonly<Record<string, Arrival>>, Readonly<Record<string, Arrival>>, false>;
39
+ export declare function arrivalOf(arrivals: Arrivals, key: string | number): Arrival;
40
+ /** Every piece in `keys` armed at `from`: the first frame of their entrance. */
41
+ export declare function armed(keys: readonly (string | number)[], from: Arrival): Arrivals;
42
+ /**
43
+ * A piece arriving from `from` over its beat: a part armed at `from` tweened to
44
+ * `{ opacity: 1, [axis]: 0 }`, eased by `ease`.
45
+ */
46
+ export declare function arrival(timeline: AnyTimeline, key: string | number, from: Arrival, ease: EasingFunction): Piece;
47
+ export {};
48
+ //# sourceMappingURL=motion.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"motion.d.ts","sourceRoot":"","sources":["../../src/kit/motion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,cAAc,EAAE,KAAK,KAAK,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAIlG,oGAAoG;AACpG,KAAK,WAAW,GAAG,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;AAErC;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,QAAQ,EAAE;IAAE,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,SAAS,CAAA;CAAE,GAAG,cAAc,CAEnG;AAED,8FAA8F;AAC9F,MAAM,WAAW,IAAI;IACnB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAA;CACtB;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,QAAQ,EAAE,WAAW,EAAE,KAAK,EAAE,SAAS,IAAI,EAAE,GAAG,KAAK,CAW1E;AAED,gHAAgH;AAChH,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CACvB;AAED,kEAAkE;AAClE,MAAM,MAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;AAExD,eAAO,MAAM,MAAM,EAAE,OAAkC,CAAA;AAEvD;;;;GAIG;AACH,wBAAgB,aAAa,kHAE5B;AAED,wBAAgB,SAAS,CAAC,QAAQ,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAE3E;AAED,gFAAgF;AAChF,wBAAgB,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,EAAE,IAAI,EAAE,OAAO,GAAG,QAAQ,CAIjF;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,QAAQ,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,cAAc,GAAG,KAAK,CAY/G"}
@@ -0,0 +1,63 @@
1
+ import { Types, easeOut } from "@motionscript/sdk";
2
+ const identity = (t) => t;
3
+ /**
4
+ * The ease a part's own frames apply to `t`: none when its command was given
5
+ * one, which already eases every frame the command builds, and otherwise the
6
+ * ease-out every chart command defaults to.
7
+ */
8
+ export function frameEase(timeline) {
9
+ return timeline.easing ? identity : easeOut();
10
+ }
11
+ /**
12
+ * `beats` at their own offsets over the command, each eased on its own and held
13
+ * at its last frame once it is done. A beat ahead of the playhead writes nothing,
14
+ * so whatever stands before it is written by a piece ahead of these. Beats that
15
+ * run past the command are played faster to end with it.
16
+ */
17
+ export function beats(timeline, parts) {
18
+ const total = timeline.duration;
19
+ const natural = parts.reduce((end, part) => Math.max(end, part.at + part.duration), 0);
20
+ const k = natural > total && natural > 0 ? total / natural : 1;
21
+ return timeline.together(parts.map(({ at, duration, piece }) => {
22
+ const start = at * k;
23
+ const length = duration * k;
24
+ return timeline.sequence([timeline.wait(start), piece, timeline.wait(Math.max(0, total - start - length))]);
25
+ }));
26
+ }
27
+ export const LANDED = { opacity: 1, shift: 0 };
28
+ /**
29
+ * A part's private record of its pieces' arrivals. A write merges into it, so
30
+ * beats placed apart each write their own piece and leave the others as the
31
+ * frame left them.
32
+ */
33
+ export function arrivalsEntry() {
34
+ return Types.custom({}, { private: true, resolve: (next, previous) => ({ ...previous, ...next }) });
35
+ }
36
+ export function arrivalOf(arrivals, key) {
37
+ return arrivals[key] ?? LANDED;
38
+ }
39
+ /** Every piece in `keys` armed at `from`: the first frame of their entrance. */
40
+ export function armed(keys, from) {
41
+ const record = {};
42
+ for (const key of keys)
43
+ record[key] = from;
44
+ return record;
45
+ }
46
+ /**
47
+ * A piece arriving from `from` over its beat: a part armed at `from` tweened to
48
+ * `{ opacity: 1, [axis]: 0 }`, eased by `ease`.
49
+ */
50
+ export function arrival(timeline, key, from, ease) {
51
+ return timeline.animate((t) => {
52
+ const e = ease(t);
53
+ return {
54
+ arrivals: {
55
+ [key]: {
56
+ opacity: from.opacity + (LANDED.opacity - from.opacity) * e,
57
+ shift: from.shift + (LANDED.shift - from.shift) * e,
58
+ },
59
+ },
60
+ };
61
+ });
62
+ }
63
+ //# sourceMappingURL=motion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"motion.js","sourceRoot":"","sources":["../../src/kit/motion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAkD,MAAM,mBAAmB,CAAA;AAElG,MAAM,QAAQ,GAAmB,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAA;AAKzC;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,QAAyD;IACjF,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,EAAE,CAAA;AAC/C,CAAC;AASD;;;;;GAKG;AACH,MAAM,UAAU,KAAK,CAAC,QAAqB,EAAE,KAAsB;IACjE,MAAM,KAAK,GAAG,QAAQ,CAAC,QAAQ,CAAA;IAC/B,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAA;IACtF,MAAM,CAAC,GAA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AAC,GAAG,IAAI,CAAA;IAC1C,OAAO,MAAM,CAAA;AACf,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAC,QAAqB,EAAE,GAAoB,EAAE,IAAa,EAAE,IAAoB;IACtG,OAAO,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;QAC5B,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;QACjB,OAAO;YACL,QAAQ,EAAE;gBACR,CAAC,GAAG,CAAC,EAAE;oBACL,OAAO,EAAE,IAAI,CAAC,OAAO,GAAG,CAAC,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC;oBAC3D,KAAK,EAAE,IAAI,CAAC,KAAK,GAAG,CAAC,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC;iBACpD;aACF;SACF,CAAA;IACH,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import { Types, easeOut, type EasingFunction, type Piece, type Timeline } from \"@motionscript/sdk\"\r\n\r\nconst identity: EasingFunction = (t) => t\r\n\r\n/** Any component's timeline: these helpers only build pieces, which every timeline builds alike. */\r\ntype AnyTimeline = Timeline<any, any>\r\n\r\n/**\r\n * The ease a part's own frames apply to `t`: none when its command was given\r\n * one, which already eases every frame the command builds, and otherwise the\r\n * ease-out every chart command defaults to.\r\n */\r\nexport function frameEase(timeline: { readonly easing: EasingFunction | undefined }): EasingFunction {\r\n return timeline.easing ? identity : easeOut()\r\n}\r\n\r\n/** A piece of a command placed at its own time: from `at` seconds, for `duration` seconds. */\r\nexport interface Beat {\r\n readonly at: number\r\n readonly duration: number\r\n readonly piece: Piece\r\n}\r\n\r\n/**\r\n * `beats` at their own offsets over the command, each eased on its own and held\r\n * at its last frame once it is done. A beat ahead of the playhead writes nothing,\r\n * so whatever stands before it is written by a piece ahead of these. Beats that\r\n * run past the command are played faster to end with it.\r\n */\r\nexport function beats(timeline: AnyTimeline, parts: readonly Beat[]): Piece {\r\n const total = timeline.duration\r\n const natural = parts.reduce((end, part) => Math.max(end, part.at + part.duration), 0)\r\n const k = natural > total && natural > 0 ? total / natural : 1\r\n return timeline.together(\r\n parts.map(({ at, duration, piece }) => {\r\n const start = at * k\r\n const length = duration * k\r\n return timeline.sequence([timeline.wait(start), piece, timeline.wait(Math.max(0, total - start - length))])\r\n })\r\n )\r\n}\r\n\r\n/** How far one piece of a staggered entrance has come: its opacity, and how far it still sits off its place. */\r\nexport interface Arrival {\r\n readonly opacity: number\r\n readonly shift: number\r\n}\r\n\r\n/** Each piece's arrival, by key. An unlisted piece has landed. */\r\nexport type Arrivals = Readonly<Record<string, Arrival>>\r\n\r\nexport const LANDED: Arrival = { opacity: 1, shift: 0 }\r\n\r\n/**\r\n * A part's private record of its pieces' arrivals. A write merges into it, so\r\n * beats placed apart each write their own piece and leave the others as the\r\n * frame left them.\r\n */\r\nexport function arrivalsEntry() {\r\n return Types.custom<Arrivals>({}, { private: true, resolve: (next: Arrivals, previous?: Arrivals) => ({ ...previous, ...next }) })\r\n}\r\n\r\nexport function arrivalOf(arrivals: Arrivals, key: string | number): Arrival {\r\n return arrivals[key] ?? LANDED\r\n}\r\n\r\n/** Every piece in `keys` armed at `from`: the first frame of their entrance. */\r\nexport function armed(keys: readonly (string | number)[], from: Arrival): Arrivals {\r\n const record: Record<string, Arrival> = {}\r\n for (const key of keys) record[key] = from\r\n return record\r\n}\r\n\r\n/**\r\n * A piece arriving from `from` over its beat: a part armed at `from` tweened to\r\n * `{ opacity: 1, [axis]: 0 }`, eased by `ease`.\r\n */\r\nexport function arrival(timeline: AnyTimeline, key: string | number, from: Arrival, ease: EasingFunction): Piece {\r\n return timeline.animate((t) => {\r\n const e = ease(t)\r\n return {\r\n arrivals: {\r\n [key]: {\r\n opacity: from.opacity + (LANDED.opacity - from.opacity) * e,\r\n shift: from.shift + (LANDED.shift - from.shift) * e,\r\n },\r\n },\r\n }\r\n })\r\n}\r\n"]}
@@ -0,0 +1,10 @@
1
+ import type { FillResolved, Loader, ShadowResolved, StrokeResolved } from "@motionscript/sdk";
2
+ /** Paints a chart part holds in entries of its own, which no paint entry loads for it. */
3
+ export interface PartPaints {
4
+ readonly fills?: readonly (readonly FillResolved[])[];
5
+ readonly strokes?: readonly (readonly StrokeResolved[])[];
6
+ readonly shadows?: readonly (readonly ShadowResolved[])[];
7
+ }
8
+ /** Declare `paints` from a component's `load`. */
9
+ export declare function loadPaints(loader: Loader, paints: PartPaints): void;
10
+ //# sourceMappingURL=paints.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paints.d.ts","sourceRoot":"","sources":["../../src/kit/paints.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAE7F,0FAA0F;AAC1F,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,YAAY,EAAE,CAAC,EAAE,CAAA;IACrD,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC,SAAS,cAAc,EAAE,CAAC,EAAE,CAAA;IACzD,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC,SAAS,cAAc,EAAE,CAAC,EAAE,CAAA;CAC1D;AAED,kDAAkD;AAClD,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,GAAG,IAAI,CAInE"}
@@ -0,0 +1,12 @@
1
+ /** Declare `paints` from a component's `load`. */
2
+ export function loadPaints(loader, paints) {
3
+ for (const fill of paints.fills ?? [])
4
+ loader.fill(fill);
5
+ for (const strokes of paints.strokes ?? [])
6
+ for (const stroke of strokes)
7
+ loader.fill(stroke.fill);
8
+ for (const shadows of paints.shadows ?? [])
9
+ for (const shadow of shadows)
10
+ loader.fill(shadow.fill);
11
+ }
12
+ //# sourceMappingURL=paints.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paints.js","sourceRoot":"","sources":["../../src/kit/paints.ts"],"names":[],"mappings":"AASA,kDAAkD;AAClD,MAAM,UAAU,UAAU,CAAC,MAAc,EAAE,MAAkB;IAC3D,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,KAAK,IAAI,EAAE;QAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACxD,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,OAAO,IAAI,EAAE;QAAE,KAAK,MAAM,MAAM,IAAI,OAAO;YAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAClG,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,OAAO,IAAI,EAAE;QAAE,KAAK,MAAM,MAAM,IAAI,OAAO;YAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;AACpG,CAAC","sourcesContent":["import type { FillResolved, Loader, ShadowResolved, StrokeResolved } from \"@motionscript/sdk\"\r\n\r\n/** Paints a chart part holds in entries of its own, which no paint entry loads for it. */\r\nexport interface PartPaints {\r\n readonly fills?: readonly (readonly FillResolved[])[]\r\n readonly strokes?: readonly (readonly StrokeResolved[])[]\r\n readonly shadows?: readonly (readonly ShadowResolved[])[]\r\n}\r\n\r\n/** Declare `paints` from a component's `load`. */\r\nexport function loadPaints(loader: Loader, paints: PartPaints): void {\r\n for (const fill of paints.fills ?? []) loader.fill(fill)\r\n for (const strokes of paints.strokes ?? []) for (const stroke of strokes) loader.fill(stroke.fill)\r\n for (const shadows of paints.shadows ?? []) for (const shadow of shadows) loader.fill(shadow.fill)\r\n}\r\n"]}
@@ -13,7 +13,7 @@
13
13
  * within one app.
14
14
  *
15
15
  * Kept renderer-agnostic (no `Node` imports) so a host's own inspector
16
- * mappings can build a partial theme without pulling the node classes in.
16
+ * mappings can build a partial theme without pulling the components in.
17
17
  *
18
18
  * **Two conventions run through every resolver and lerp below**, inherited from
19
19
  * the shape system's `resolveStroke`/`resolveShadow`:
@@ -79,14 +79,14 @@ export interface AxisDomainConfig {
79
79
  format?: string;
80
80
  }
81
81
  /**
82
- * An axis domain's @property mapper: merges the author's partial input onto
82
+ * An axis domain entry's resolve: merges the author's partial input onto
83
83
  * `previous`, so a later partial `.set({ yAxis: {...} })` patches
84
84
  * `label`/`range`/`ticks` independently. `range`/`ticks` staying `undefined`
85
85
  * after the merge is the auto-derive signal the scale getters read.
86
86
  */
87
87
  export declare function resolveAxisDomain(domain: AxisDomainConfig | undefined, previous?: AxisDomainConfig): AxisDomainConfig;
88
88
  /**
89
- * An axis domain's @property tween: interpolates `range`/`ticks` numerically
89
+ * An axis domain entry's lerp: interpolates `range`/`ticks` numerically
90
90
  * (pairwise by index for `ticks`), so a `to` command that restates a range
91
91
  * rescales the plot smoothly. `label`, and either field when one side is in
92
92
  * auto-derive mode, step at the midpoint.
@@ -106,6 +106,34 @@ export declare function lerpAxisDomain(from: AxisDomainConfig, to: AxisDomainCon
106
106
  * marker slides from its old value to its new one instead of the row popping.
107
107
  */
108
108
  export declare function axisTweenTarget(drawn: AxisDomainConfig, requested: AxisDomainConfig | undefined): AxisDomainConfig | undefined;
109
+ /**
110
+ * An axis domain part-way through a tween that leaves or reaches a `range` or
111
+ * `ticks` left to the data: both ends as stored, and how far along. Only the
112
+ * chart knows what an auto side draws as, so {@link settleAxisDomain} resolves
113
+ * it there. Its own fields are the plain {@link lerpAxisDomain} of its ends, so
114
+ * a mapper merging onto one still reads a domain.
115
+ */
116
+ export interface AxisDomainBlend extends AxisDomainConfig {
117
+ readonly blend: {
118
+ readonly from: AxisDomainConfig;
119
+ readonly to: AxisDomainConfig;
120
+ readonly t: number;
121
+ };
122
+ }
123
+ /**
124
+ * A chart's axis entry tween: what `to({ yAxis: { range } })` moves through.
125
+ * Between two explicit domains it is {@link lerpAxisDomain}, and a restated
126
+ * `range` without `ticks` spreads explicit ticks across it, keeping their count.
127
+ * When either end leaves `range` or `ticks` to the data, the value between is an
128
+ * {@link AxisDomainBlend}, which the chart draws as the blend of what each end
129
+ * draws: a rescale from an auto axis is continuous, not a cut at the midpoint.
130
+ */
131
+ export declare function lerpAxisEntry(from: AxisDomainConfig, to: AxisDomainConfig, t: number): AxisDomainConfig;
132
+ /**
133
+ * `domain` as the chart draws it: `drawn` resolves a plain domain's auto `range`
134
+ * and `ticks` off the data, and a blend is the lerp of what its two ends draw.
135
+ */
136
+ export declare function settleAxisDomain(domain: AxisDomainConfig, drawn: (domain: AxisDomainConfig) => AxisDomainConfig): AxisDomainConfig;
109
137
  /**
110
138
  * The low-level colour tokens the default themes are built from — a dark plot
111
139
  * panel with warm-grey axis furniture.
@@ -1 +1 @@
1
- {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/kit/shared.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAOL,KAAK,UAAU,EACf,KAAK,IAAI,EAET,KAAK,MAAM,EAEX,KAAK,MAAM,EAEX,KAAK,MAAM,EAEX,KAAK,SAAS,EACf,MAAM,mBAAmB,CAAA;AAE1B;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,WAAW;IAC1B,qDAAqD;IACrD,KAAK,EAAE,MAAM,CAAA;IACb,sCAAsC;IACtC,KAAK,EAAE,MAAM,CAAA;IACb;;;OAGG;IACH,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,+DAA+D;IAC/D,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,kDAAkD;AAClD,MAAM,MAAM,KAAK,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,CAAA;AAE9C;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,4EAA4E;IAC5E,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,4EAA4E;IAC5E,KAAK,CAAC,EAAE,KAAK,CAAA;IACb,8EAA8E;IAC9E,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;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EAAE,WAAW,EACnB,KAAK,EAAE,MAAM,GACZ,IAAI,CAGN;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,IAAI,EAAE,EACf,QAAQ,EAAE,IAAI,GAAG,SAAS,EAC1B,KAAK,EAAE,MAAM,GACZ,IAAI,CAIN;AAKD;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAIjE;AAaD,iGAAiG;AACjG,wBAAgB,UAAU,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,GAAG,SAAS,CAQzE;AAED,uFAAuF;AACvF,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAItD;AAED,mFAAmF;AACnF,wBAAgB,YAAY,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,CAG7E;AAKD,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA"}
@@ -13,7 +13,7 @@
13
13
  * within one app.
14
14
  *
15
15
  * Kept renderer-agnostic (no `Node` imports) so a host's own inspector
16
- * mappings can build a partial theme without pulling the node classes in.
16
+ * mappings can build a partial theme without pulling the components in.
17
17
  *
18
18
  * **Two conventions run through every resolver and lerp below**, inherited from
19
19
  * the shape system's `resolveStroke`/`resolveShadow`:
@@ -29,7 +29,7 @@
29
29
  */
30
30
  import { fillOps, lerpNumber, shadowOps, strokeOps, insetsOps, textOps, } from "@motionscript/sdk";
31
31
  /**
32
- * An axis domain's @property mapper: merges the author's partial input onto
32
+ * An axis domain entry's resolve: merges the author's partial input onto
33
33
  * `previous`, so a later partial `.set({ yAxis: {...} })` patches
34
34
  * `label`/`range`/`ticks` independently. `range`/`ticks` staying `undefined`
35
35
  * after the merge is the auto-derive signal the scale getters read.
@@ -43,7 +43,7 @@ export function resolveAxisDomain(domain, previous) {
43
43
  };
44
44
  }
45
45
  /**
46
- * An axis domain's @property tween: interpolates `range`/`ticks` numerically
46
+ * An axis domain entry's lerp: interpolates `range`/`ticks` numerically
47
47
  * (pairwise by index for `ticks`), so a `to` command that restates a range
48
48
  * rescales the plot smoothly. `label`, and either field when one side is in
49
49
  * auto-derive mode, step at the midpoint.
@@ -96,6 +96,45 @@ export function axisTweenTarget(drawn, requested) {
96
96
  }
97
97
  return target;
98
98
  }
99
+ function blendOf(domain) {
100
+ return domain.blend;
101
+ }
102
+ /**
103
+ * A chart's axis entry tween: what `to({ yAxis: { range } })` moves through.
104
+ * Between two explicit domains it is {@link lerpAxisDomain}, and a restated
105
+ * `range` without `ticks` spreads explicit ticks across it, keeping their count.
106
+ * When either end leaves `range` or `ticks` to the data, the value between is an
107
+ * {@link AxisDomainBlend}, which the chart draws as the blend of what each end
108
+ * draws: a rescale from an auto axis is continuous, not a cut at the midpoint.
109
+ */
110
+ export function lerpAxisEntry(from, to, t) {
111
+ // The mapper merged the request onto `from`, so a field it left unstated is `from`'s own, by identity.
112
+ const rangeMoved = to.range !== from.range;
113
+ const target = rangeMoved && to.range && to.ticks && to.ticks === from.ticks
114
+ ? { ...to, ticks: markerValues(to.range, Math.max(2, to.ticks.length) - 1) }
115
+ : to;
116
+ const blended = blendOf(from) !== undefined;
117
+ const moved = blended || rangeMoved || target.ticks !== from.ticks;
118
+ const auto = blended || from.range === undefined || from.ticks === undefined || target.range === undefined || target.ticks === undefined;
119
+ if (!moved || !auto)
120
+ return lerpAxisDomain(from, target, t);
121
+ if (t === 0)
122
+ return from;
123
+ if (t === 1)
124
+ return target;
125
+ const blend = { ...lerpAxisDomain(from, target, t), blend: { from, to: target, t } };
126
+ return blend;
127
+ }
128
+ /**
129
+ * `domain` as the chart draws it: `drawn` resolves a plain domain's auto `range`
130
+ * and `ticks` off the data, and a blend is the lerp of what its two ends draw.
131
+ */
132
+ export function settleAxisDomain(domain, drawn) {
133
+ const blend = blendOf(domain);
134
+ if (!blend)
135
+ return drawn(domain);
136
+ return lerpAxisDomain(settleAxisDomain(blend.from, drawn), settleAxisDomain(blend.to, drawn), blend.t);
137
+ }
99
138
  /**
100
139
  * The low-level colour tokens the default themes are built from — a dark plot
101
140
  * panel with warm-grey axis furniture.