@bendyline/squisq 2.11.10 → 2.11.11

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.
@@ -6152,6 +6152,13 @@ function treeBlock(input, context) {
6152
6152
  return layers;
6153
6153
  }
6154
6154
 
6155
+ // src/doc/utils/textMetrics.ts
6156
+ var AVERAGE_CHAR_WIDTH_EM = 0.62;
6157
+ var BOLD_CHAR_WIDTH_EM = 0.66;
6158
+ function estimateTextWidth(text, fontSize, charWidthEm = AVERAGE_CHAR_WIDTH_EM) {
6159
+ return text.length * fontSize * charWidthEm;
6160
+ }
6161
+
6155
6162
  // src/doc/templates/timelineBlock.ts
6156
6163
  var clamp012 = (value) => Math.max(0, Math.min(1, value));
6157
6164
  var clamp = (value, min, max) => Math.max(min, Math.min(max, value));
@@ -6298,7 +6305,14 @@ function timelineBlock(input, context) {
6298
6305
  }
6299
6306
  const hasTrackLabels = tracks.some((track) => !!track.label);
6300
6307
  const outerMargin = Math.max(48, viewport.width * 0.065);
6301
- const labelWidth = hasTrackLabels ? Math.min(280, viewport.width * 0.18) : 0;
6308
+ const labelGap = 32;
6309
+ const longestLabel = Math.max(
6310
+ 0,
6311
+ ...tracks.map(
6312
+ (track) => track.label ? estimateTextWidth(track.label, trackFontSize, BOLD_CHAR_WIDTH_EM) : 0
6313
+ )
6314
+ );
6315
+ const labelWidth = hasTrackLabels ? Math.min(Math.min(280, viewport.width * 0.18), Math.ceil(longestLabel) + labelGap) : 0;
6302
6316
  const axisStartX = outerMargin + labelWidth;
6303
6317
  const axisEndX = viewport.width - outerMargin;
6304
6318
  const axisWidth = Math.max(1, axisEndX - axisStartX);
@@ -6361,9 +6375,9 @@ function timelineBlock(input, context) {
6361
6375
  }
6362
6376
  },
6363
6377
  position: {
6364
- x: outerMargin + labelWidth / 2 - 16,
6378
+ x: outerMargin + (labelWidth - labelGap) / 2,
6365
6379
  y,
6366
- width: Math.max(1, labelWidth - 32),
6380
+ width: Math.max(1, labelWidth - labelGap),
6367
6381
  anchor: "center"
6368
6382
  },
6369
6383
  animation: motionEntrance(context, { type: "fadeIn", duration: 0.5, delay: trackDelay })
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  flattenRenderableBlocks,
3
3
  getBlockBodyText
4
- } from "./chunk-TYW5VMNP.js";
4
+ } from "./chunk-42IU2SJY.js";
5
5
  import {
6
6
  estimateSpokenWordCount
7
7
  } from "./chunk-GHOPHGOK.js";
@@ -5,7 +5,7 @@ import {
5
5
  } from "./chunk-SVN7T6BK.js";
6
6
  import {
7
7
  markdownToDoc
8
- } from "./chunk-TYW5VMNP.js";
8
+ } from "./chunk-42IU2SJY.js";
9
9
  import {
10
10
  cloneAndFreezeData,
11
11
  isTemplateBlock
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  buildNarrationScript,
3
3
  parseNarrationTimingJson
4
- } from "./chunk-PWCIJHZH.js";
4
+ } from "./chunk-BR7ZMDWW.js";
5
5
  import {
6
6
  SHAPE_NAMES,
7
7
  buildChartData,
@@ -32,7 +32,7 @@ import {
32
32
  templateRegistry,
33
33
  writeCustomTemplatesToFrontmatter,
34
34
  writeCustomThemesToFrontmatter
35
- } from "./chunk-TYW5VMNP.js";
35
+ } from "./chunk-42IU2SJY.js";
36
36
  import {
37
37
  ASCII_TREE_VOCAB,
38
38
  ASCII_VOCAB,
@@ -7,10 +7,10 @@ import {
7
7
  buildNarrationScript,
8
8
  expectedSyllablesAt,
9
9
  wordPosAtExpectedSyllables
10
- } from "./chunk-PWCIJHZH.js";
10
+ } from "./chunk-BR7ZMDWW.js";
11
11
  import {
12
12
  flattenRenderableBlocks
13
- } from "./chunk-TYW5VMNP.js";
13
+ } from "./chunk-42IU2SJY.js";
14
14
 
15
15
  // src/narration/types.ts
16
16
  var DEFAULT_FEATURE_CONFIG = Object.freeze({
package/dist/doc/index.js CHANGED
@@ -74,8 +74,8 @@ import {
74
74
  validateMarkdownSource,
75
75
  wordRevealDelay,
76
76
  writeDashboardLayoutsToFrontmatter
77
- } from "../chunk-CPQCZUBW.js";
78
- import "../chunk-PWCIJHZH.js";
77
+ } from "../chunk-S4427XKY.js";
78
+ import "../chunk-BR7ZMDWW.js";
79
79
  import {
80
80
  ASCII_CHAR_H,
81
81
  ASCII_CHAR_W,
@@ -206,7 +206,7 @@ import {
206
206
  wrapWithPersistentLayers,
207
207
  writeCustomTemplatesToFrontmatter,
208
208
  writeCustomThemesToFrontmatter
209
- } from "../chunk-TYW5VMNP.js";
209
+ } from "../chunk-42IU2SJY.js";
210
210
  import {
211
211
  ASCII_DIAGRAM_FENCE_LANGS,
212
212
  ASCII_TIMELINE_FENCE_LANGS,
package/dist/index.js CHANGED
@@ -27,7 +27,7 @@ import {
27
27
  recordSlideShown,
28
28
  traceWordPosAt,
29
29
  vadStep
30
- } from "./chunk-BVQZCKXN.js";
30
+ } from "./chunk-X2TDC4E5.js";
31
31
  import {
32
32
  fenceRendererLangs
33
33
  } from "./chunk-PGI7HSWE.js";
@@ -65,7 +65,7 @@ import {
65
65
  getTransformStyleSummaries,
66
66
  resolveTransformStyle,
67
67
  transformNarratedSegment
68
- } from "./chunk-RV5OOBSV.js";
68
+ } from "./chunk-EWO2VLOS.js";
69
69
  import {
70
70
  extractContent,
71
71
  mapElementToBlock,
@@ -243,7 +243,7 @@ import {
243
243
  validateMarkdownSource,
244
244
  wordRevealDelay,
245
245
  writeDashboardLayoutsToFrontmatter
246
- } from "./chunk-CPQCZUBW.js";
246
+ } from "./chunk-S4427XKY.js";
247
247
  import {
248
248
  buildNarrationScript,
249
249
  buildNarrationTimingJson,
@@ -253,7 +253,7 @@ import {
253
253
  wordIndexAtChar,
254
254
  wordIndexAtTime,
255
255
  wordPosAtExpectedSyllables
256
- } from "./chunk-PWCIJHZH.js";
256
+ } from "./chunk-BR7ZMDWW.js";
257
257
  import {
258
258
  ASCII_CHAR_H,
259
259
  ASCII_CHAR_W,
@@ -384,7 +384,7 @@ import {
384
384
  wrapWithPersistentLayers,
385
385
  writeCustomTemplatesToFrontmatter,
386
386
  writeCustomThemesToFrontmatter
387
- } from "./chunk-TYW5VMNP.js";
387
+ } from "./chunk-42IU2SJY.js";
388
388
  import {
389
389
  ASCII_DIAGRAM_FENCE_LANGS,
390
390
  ASCII_TIMELINE_FENCE_LANGS,
@@ -27,7 +27,7 @@ import {
27
27
  recordSlideShown,
28
28
  traceWordPosAt,
29
29
  vadStep
30
- } from "../chunk-BVQZCKXN.js";
30
+ } from "../chunk-X2TDC4E5.js";
31
31
  import "../chunk-NEWNNLWN.js";
32
32
  import {
33
33
  buildNarrationScript,
@@ -38,8 +38,8 @@ import {
38
38
  wordIndexAtChar,
39
39
  wordIndexAtTime,
40
40
  wordPosAtExpectedSyllables
41
- } from "../chunk-PWCIJHZH.js";
42
- import "../chunk-TYW5VMNP.js";
41
+ } from "../chunk-BR7ZMDWW.js";
42
+ import "../chunk-42IU2SJY.js";
43
43
  import "../chunk-C3NAY5YP.js";
44
44
  import "../chunk-PUS54YU6.js";
45
45
  import "../chunk-PFH3WV6J.js";
@@ -9,9 +9,9 @@ import {
9
9
  getTransformStyleSummaries,
10
10
  resolveTransformStyle,
11
11
  transformNarratedSegment
12
- } from "../chunk-RV5OOBSV.js";
12
+ } from "../chunk-EWO2VLOS.js";
13
13
  import "../chunk-SVN7T6BK.js";
14
- import "../chunk-TYW5VMNP.js";
14
+ import "../chunk-42IU2SJY.js";
15
15
  import "../chunk-C3NAY5YP.js";
16
16
  import "../chunk-PUS54YU6.js";
17
17
  import "../chunk-PFH3WV6J.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bendyline/squisq",
3
- "version": "2.11.10",
3
+ "version": "2.11.11",
4
4
  "description": "Headless utilities for doc/block rendering, spatial math, Markdown, and storage",
5
5
  "license": "MIT",
6
6
  "author": "Bendyline",