@bendyline/squisq-react 2.12.18 → 2.12.20

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.
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  LinearDocView
3
- } from "./chunk-PVCHPYJG.js";
3
+ } from "./chunk-6LM6HDKH.js";
4
4
  import {
5
5
  useAudioSync,
6
6
  useDocPlayback,
@@ -15,11 +15,11 @@ import {
15
15
  } from "./chunk-OWC7DNGJ.js";
16
16
  import {
17
17
  BlockRenderer
18
- } from "./chunk-GIJRQVYB.js";
18
+ } from "./chunk-4HVJHRL5.js";
19
19
  import {
20
20
  isCaptureDrivenVideo,
21
21
  seekVideoToFrame
22
- } from "./chunk-UTRO6ZZS.js";
22
+ } from "./chunk-IPB22WG3.js";
23
23
  import {
24
24
  useMediaProvider,
25
25
  useMediaUrl,
@@ -12,7 +12,7 @@ import {
12
12
  getAnchorOffset,
13
13
  getTransitionClass,
14
14
  resolveValue
15
- } from "./chunk-UTRO6ZZS.js";
15
+ } from "./chunk-IPB22WG3.js";
16
16
 
17
17
  // src/BlockRenderer.tsx
18
18
  import { useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
@@ -8,7 +8,7 @@ import {
8
8
  } from "./chunk-OWC7DNGJ.js";
9
9
  import {
10
10
  BlockRenderer
11
- } from "./chunk-GIJRQVYB.js";
11
+ } from "./chunk-4HVJHRL5.js";
12
12
  import {
13
13
  svgDataImageSrc,
14
14
  useMediaUrl
@@ -506,7 +506,7 @@ import {
506
506
  buildPageCssVars,
507
507
  pageStyleDataAttributes,
508
508
  PAGE_BASE_CSS,
509
- DEFAULT_THEME as DEFAULT_THEME2
509
+ resolveThemeForDoc
510
510
  } from "@bendyline/squisq/doc";
511
511
  import { parseMarkdown } from "@bendyline/squisq/markdown";
512
512
  import { fenceRendererLangs } from "@bendyline/squisq/fence";
@@ -542,9 +542,9 @@ function LinearDocView({
542
542
  const autoSurface = useAutoSurface(surface === "auto");
543
543
  const resolvedSurface = surface === "auto" ? autoSurface : surface;
544
544
  const activeTheme = useMemo2(() => {
545
- const baseTheme = theme ?? DEFAULT_THEME2;
545
+ const baseTheme = theme ?? resolveThemeForDoc(resolvedDoc);
546
546
  return resolvedSurface ? applySurface(baseTheme, resolvedSurface) : baseTheme;
547
- }, [theme, resolvedSurface]);
547
+ }, [theme, resolvedDoc, resolvedSurface]);
548
548
  const pageStyle = useMemo2(
549
549
  () => resolvePageStyle2(activeTheme, transformPage, variant),
550
550
  [activeTheme, transformPage, variant]
@@ -44,6 +44,11 @@ function getAnchorOffset(anchor, width, height) {
44
44
  }
45
45
  }
46
46
 
47
+ // src/utils/foreignObjectPaint.ts
48
+ function paintsForeignObjectLayersUnscaled(userAgent = typeof navigator === "undefined" ? "" : navigator.userAgent) {
49
+ return /AppleWebKit\//.test(userAgent) && !/(Chrome|Chromium|jsdom)\/|Android/.test(userAgent);
50
+ }
51
+
47
52
  // src/layers/ImageLayer.tsx
48
53
  import { jsx } from "react/jsx-runtime";
49
54
  function ImageLayer({
@@ -115,6 +120,34 @@ function ImageLayer({
115
120
  if (isCover && isSpatialAnim && animation) {
116
121
  const kbAnim = remapToKenBurns(animation);
117
122
  const kbStyle = getAnimationStyle(kbAnim, blockTime);
123
+ if (paintsForeignObjectLayersUnscaled()) {
124
+ return /* @__PURE__ */ jsx(
125
+ "g",
126
+ {
127
+ className: "block-layer block-layer--image",
128
+ "data-layer-id": layer.id,
129
+ "data-image-framing": "svg-ken-burns",
130
+ children: /* @__PURE__ */ jsx("svg", { x: finalX, y: finalY, width, height, style: { overflow: "hidden" }, children: /* @__PURE__ */ jsx(
131
+ "image",
132
+ {
133
+ href: src,
134
+ width,
135
+ height,
136
+ preserveAspectRatio: "xMidYMid slice",
137
+ className: kbStyle.className,
138
+ ...content.alt ? { role: "img", "aria-label": content.alt } : {},
139
+ style: {
140
+ pointerEvents: "none",
141
+ transformBox: "fill-box",
142
+ transformOrigin: "center center",
143
+ ...filter ? { filter } : {},
144
+ ...kbStyle.style
145
+ }
146
+ }
147
+ ) })
148
+ }
149
+ );
150
+ }
118
151
  return /* @__PURE__ */ jsx("g", { className: "block-layer block-layer--image", "data-layer-id": layer.id, children: /* @__PURE__ */ jsx("foreignObject", { x: finalX, y: finalY, width, height, children: /* @__PURE__ */ jsx(
119
152
  "div",
120
153
  {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  LinearDocView
3
- } from "./chunk-PVCHPYJG.js";
3
+ } from "./chunk-6LM6HDKH.js";
4
4
 
5
5
  // src/PaginatedDocView.tsx
6
6
  import {
@@ -33,7 +33,7 @@ interface DiagramPictureOptions {
33
33
  }
34
34
  /** The diagram description `@bendyline/squisq-formats/diagrams` passes. */
35
35
  interface DiagramToPicture {
36
- kind: 'mermaid' | 'diagram' | 'timeline' | 'tree' | 'container' | 'svg';
36
+ kind: 'mermaid' | 'diagram' | 'timeline' | 'tree' | 'container' | 'svg' | 'chart';
37
37
  markdown: string;
38
38
  source: string;
39
39
  }
@@ -52,14 +52,14 @@ declare function renderSvgIslandPicture(source: string, options?: DiagramPicture
52
52
  /** A file-tree fence as monospace text lines, exactly as written. */
53
53
  declare function renderTreePicture(source: string, options?: DiagramPictureOptions): Promise<DiagramPicturePng | null>;
54
54
  /**
55
- * A Squisq-rendered diagram — an ASCII diagram or timeline fence, or a
56
- * drawing, layout, or diagram heading block — as a PNG cropped to its
55
+ * A Squisq-rendered diagram — an ASCII diagram or timeline fence, a
56
+ * drawing, layout, or diagram heading block, or a chart — as a PNG cropped to its
57
57
  * content, or null when it has nothing to draw.
58
58
  */
59
59
  declare function renderSquisqDiagramPicture(markdown: string, options?: DiagramPictureOptions): Promise<DiagramPicturePng | null>;
60
60
  /**
61
61
  * A renderer for `rasterizeDiagrams` from `@bendyline/squisq-formats/diagrams`:
62
- * Mermaid, ASCII diagrams and timelines, file trees, and drawing, layout,
62
+ * Mermaid, ASCII diagrams and timelines, file trees, charts, and drawing, layout,
63
63
  * and diagram blocks.
64
64
  */
65
65
  declare function createDiagramPictureRenderer(options?: DiagramPictureOptions): (diagram: DiagramToPicture) => Promise<DiagramPicturePng | null>;
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  BlockRenderer
3
- } from "../chunk-GIJRQVYB.js";
4
- import "../chunk-UTRO6ZZS.js";
3
+ } from "../chunk-4HVJHRL5.js";
4
+ import "../chunk-IPB22WG3.js";
5
5
  import "../chunk-A65WPCGZ.js";
6
6
  import {
7
7
  renderMermaidSvgForExport
@@ -233,11 +233,26 @@ function createDiagramPictureRenderer(options = {}) {
233
233
  return renderTreePicture(diagram.source, options);
234
234
  case "svg":
235
235
  return renderSvgIslandPicture(diagram.source, options);
236
+ case "chart":
237
+ return renderSquisqDiagramPicture(diagram.markdown, {
238
+ ...options,
239
+ theme: withLargerLabels(settings(options).theme, CHART_LABEL_SCALE)
240
+ });
236
241
  default:
237
242
  return renderSquisqDiagramPicture(diagram.markdown, options);
238
243
  }
239
244
  };
240
245
  }
246
+ var CHART_LABEL_SCALE = 1.5;
247
+ function withLargerLabels(theme, scale) {
248
+ return {
249
+ ...theme,
250
+ typography: {
251
+ ...theme.typography,
252
+ bodyScale: (theme.typography.bodyScale ?? 1) * scale
253
+ }
254
+ };
255
+ }
241
256
  export {
242
257
  EXPORT_FONT_STACK,
243
258
  createDiagramPictureRenderer,
package/dist/index.js CHANGED
@@ -17,17 +17,17 @@ import {
17
17
  resolveDocPlayerAppearance,
18
18
  useBuildNavigation,
19
19
  useMediaClipDurations
20
- } from "./chunk-73MW4RJW.js";
20
+ } from "./chunk-2DUF6C7B.js";
21
21
  import {
22
22
  PaginatedDocView
23
- } from "./chunk-X67VFBAO.js";
23
+ } from "./chunk-MUYICTDA.js";
24
24
  import {
25
25
  CanvasSection,
26
26
  LinearDocView,
27
27
  PageSectionView,
28
28
  PageViewContext,
29
29
  usePageView
30
- } from "./chunk-PVCHPYJG.js";
30
+ } from "./chunk-6LM6HDKH.js";
31
31
  import {
32
32
  useModalDialog
33
33
  } from "./chunk-JP457U6N.js";
@@ -57,7 +57,7 @@ import {
57
57
  } from "./chunk-OWC7DNGJ.js";
58
58
  import {
59
59
  BlockRenderer
60
- } from "./chunk-GIJRQVYB.js";
60
+ } from "./chunk-4HVJHRL5.js";
61
61
  import {
62
62
  ImageLayer,
63
63
  MapLayer,
@@ -71,7 +71,7 @@ import {
71
71
  VideoLayer,
72
72
  getAnimationStyle,
73
73
  getTransitionClass
74
- } from "./chunk-UTRO6ZZS.js";
74
+ } from "./chunk-IPB22WG3.js";
75
75
  import {
76
76
  MermaidDiagram
77
77
  } from "./chunk-A65WPCGZ.js";
@@ -9,7 +9,7 @@ import {
9
9
  TextLayer,
10
10
  TreeLayer,
11
11
  VideoLayer
12
- } from "../chunk-UTRO6ZZS.js";
12
+ } from "../chunk-IPB22WG3.js";
13
13
  import "../chunk-A65WPCGZ.js";
14
14
  import "../chunk-OTYJ4MRH.js";
15
15
  export {
@@ -25,7 +25,7 @@ interface LinearDocViewProps {
25
25
  viewport?: ViewportConfig;
26
26
  /** Optional CSS class for the outer container */
27
27
  className?: string;
28
- /** Theme to use for rendering (default: DEFAULT_THEME from the theme library) */
28
+ /** Theme to use for rendering (default: the document's own theme, as the player resolves it) */
29
29
  theme?: Theme;
30
30
  /** Whether embedded canvas sections render their layer animations (default: true). */
31
31
  animationsEnabled?: boolean;
@@ -1,17 +1,17 @@
1
1
  import {
2
2
  PaginatedDocView
3
- } from "../chunk-X67VFBAO.js";
3
+ } from "../chunk-MUYICTDA.js";
4
4
  import {
5
5
  CanvasSection,
6
6
  LinearDocView,
7
7
  PageSectionView,
8
8
  PageViewContext,
9
9
  usePageView
10
- } from "../chunk-PVCHPYJG.js";
10
+ } from "../chunk-6LM6HDKH.js";
11
11
  import "../chunk-TT6ENR6T.js";
12
12
  import "../chunk-OWC7DNGJ.js";
13
- import "../chunk-GIJRQVYB.js";
14
- import "../chunk-UTRO6ZZS.js";
13
+ import "../chunk-4HVJHRL5.js";
14
+ import "../chunk-IPB22WG3.js";
15
15
  import "../chunk-A65WPCGZ.js";
16
16
  import "../chunk-OTYJ4MRH.js";
17
17
  export {
@@ -12,8 +12,8 @@ import {
12
12
  MediaClipLayer,
13
13
  SocialCaptionOverlay,
14
14
  formatTime
15
- } from "../chunk-73MW4RJW.js";
16
- import "../chunk-PVCHPYJG.js";
15
+ } from "../chunk-2DUF6C7B.js";
16
+ import "../chunk-6LM6HDKH.js";
17
17
  import "../chunk-TVYZINUR.js";
18
18
  import "../chunk-TT6ENR6T.js";
19
19
  import {
@@ -22,8 +22,8 @@ import {
22
22
  } from "../chunk-OWC7DNGJ.js";
23
23
  import {
24
24
  BlockRenderer
25
- } from "../chunk-GIJRQVYB.js";
26
- import "../chunk-UTRO6ZZS.js";
25
+ } from "../chunk-4HVJHRL5.js";
26
+ import "../chunk-IPB22WG3.js";
27
27
  import "../chunk-A65WPCGZ.js";
28
28
  import "../chunk-OTYJ4MRH.js";
29
29
  export {