@bendyline/squisq-react 2.11.18 → 2.11.19

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.
@@ -60,7 +60,7 @@ COMPONENTS
60
60
  - decode-named-character-reference@1.3.0 (MIT); files: license
61
61
  - delaunator@5.1.0 (ISC); files: LICENSE
62
62
  - devlop@1.1.0 (MIT); files: license
63
- - dompurify@3.4.14 ((MPL-2.0 OR Apache-2.0)); files: LICENSE, LICENSE-MPL
63
+ - dompurify@3.4.16 ((MPL-2.0 OR Apache-2.0)); files: LICENSE, LICENSE-MPL
64
64
  - entities@6.0.1 (BSD-2-Clause); files: LICENSE
65
65
  - es-toolkit@1.49.0 (MIT); files: LICENSE
66
66
  - escape-string-regexp@5.0.0 (MIT); files: license
@@ -1400,7 +1400,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
1400
1400
  SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1401
1401
 
1402
1402
  ==============================================================================
1403
- dompurify@3.4.14 - LICENSE
1403
+ dompurify@3.4.16 - LICENSE
1404
1404
  ==============================================================================
1405
1405
 
1406
1406
  Apache License
@@ -1606,7 +1606,7 @@ dompurify@3.4.14 - LICENSE
1606
1606
  limitations under the License.
1607
1607
 
1608
1608
  ==============================================================================
1609
- dompurify@3.4.14 - LICENSE-MPL
1609
+ dompurify@3.4.16 - LICENSE-MPL
1610
1610
  ==============================================================================
1611
1611
  Mozilla Public License Version 2.0
1612
1612
  ==================================
@@ -3,11 +3,12 @@ import {
3
3
  } from "./chunk-TT6ENR6T.js";
4
4
  import {
5
5
  InlineVideoPlayer,
6
- MarkdownRenderer
7
- } from "./chunk-2FZUFQO3.js";
6
+ MarkdownRenderer,
7
+ VideoEmbedFrame
8
+ } from "./chunk-YLFAOGJF.js";
8
9
  import {
9
10
  BlockRenderer
10
- } from "./chunk-5FJZDX7H.js";
11
+ } from "./chunk-KJZF2U3I.js";
11
12
  import {
12
13
  useMediaUrl
13
14
  } from "./chunk-63G5OJWY.js";
@@ -78,7 +79,7 @@ function CanvasSection({ section }) {
78
79
  }
79
80
 
80
81
  // src/page/sections.tsx
81
- import { sanitizeUrl } from "@bendyline/squisq/markdown";
82
+ import { parseVideoEmbedUrl, sanitizeUrl } from "@bendyline/squisq/markdown";
82
83
  import { Fragment, jsx as jsx2, jsxs } from "react/jsx-runtime";
83
84
  function PageImg({
84
85
  media,
@@ -122,12 +123,18 @@ function BackdropVideo({ media }) {
122
123
  }
123
124
  );
124
125
  }
126
+ function PageVideoEmbed({ media }) {
127
+ const embed = parseVideoEmbedUrl(media.url);
128
+ return embed ? /* @__PURE__ */ jsx2(VideoEmbedFrame, { embed, title: media.title, showCaption: false }) : null;
129
+ }
125
130
  function Eyebrow({ section }) {
126
131
  if (!section.slots.eyebrow) return null;
127
132
  return /* @__PURE__ */ jsx2("span", { className: "squisq-page-eyebrow", children: section.slots.eyebrow });
128
133
  }
129
134
  function MediaCredit({ media }) {
130
- if (!media || media.type === "canvas" || !media.credit) return null;
135
+ if (!media || media.type === "canvas" || media.type === "videoEmbed" || !media.credit) {
136
+ return null;
137
+ }
131
138
  return /* @__PURE__ */ jsxs("span", { className: "squisq-page-media-credit", children: [
132
139
  media.credit,
133
140
  media.license ? ` \xB7 ${media.license}` : ""
@@ -193,7 +200,7 @@ function StatBandSection({ section }) {
193
200
  }
194
201
  function QuoteBandSection({ section }) {
195
202
  const media = section.slots.media;
196
- const backdrop = section.background === "media" && media && media.type !== "canvas";
203
+ const backdrop = section.background === "media" && media && media.type !== "canvas" && media.type !== "videoEmbed";
197
204
  return /* @__PURE__ */ jsxs(Fragment, { children: [
198
205
  backdrop && /* @__PURE__ */ jsx2("div", { className: "squisq-page-quote-backdrop", children: media.type === "image" ? /* @__PURE__ */ jsx2(PageImg, { media }) : /* @__PURE__ */ jsx2(BackdropVideo, { media }) }),
199
206
  section.slots.title && /* @__PURE__ */ jsx2("h2", { className: "squisq-page-section-title", children: section.slots.title }),
@@ -227,10 +234,10 @@ function MediaFigureSection({ section }) {
227
234
  const media = section.slots.media;
228
235
  if (!media || media.type === "canvas") return null;
229
236
  return /* @__PURE__ */ jsxs("figure", { className: "squisq-page-figure", children: [
230
- /* @__PURE__ */ jsx2("div", { className: "squisq-page-media-frame", children: media.type === "image" ? /* @__PURE__ */ jsx2(PageImg, { media }) : /* @__PURE__ */ jsx2(InlineVideoPlayer, { src: media.src, poster: media.posterSrc, basePath }) }),
231
- (section.slots.caption || media.credit) && /* @__PURE__ */ jsxs("figcaption", { children: [
237
+ /* @__PURE__ */ jsx2("div", { className: "squisq-page-media-frame", children: media.type === "image" ? /* @__PURE__ */ jsx2(PageImg, { media }) : media.type === "videoEmbed" ? /* @__PURE__ */ jsx2(PageVideoEmbed, { media }) : /* @__PURE__ */ jsx2(InlineVideoPlayer, { src: media.src, poster: media.posterSrc, basePath }) }),
238
+ (section.slots.caption || media.type !== "videoEmbed" && media.credit) && /* @__PURE__ */ jsxs("figcaption", { children: [
232
239
  section.slots.caption,
233
- media.credit && /* @__PURE__ */ jsxs(Fragment, { children: [
240
+ media.type !== "videoEmbed" && media.credit && /* @__PURE__ */ jsxs(Fragment, { children: [
234
241
  section.slots.caption ? " " : "",
235
242
  /* @__PURE__ */ jsx2(MediaCredit, { media })
236
243
  ] })
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-TT6ENR6T.js";
4
4
  import {
5
5
  MarkdownRenderer
6
- } from "./chunk-2FZUFQO3.js";
6
+ } from "./chunk-YLFAOGJF.js";
7
7
 
8
8
  // src/jsonView/useJsonViewTokens.ts
9
9
  import { useMemo } from "react";
@@ -8,14 +8,160 @@ import {
8
8
  TextLayer,
9
9
  TreeLayer,
10
10
  VideoLayer,
11
- getTransitionClass
12
- } from "./chunk-PZCWGBRQ.js";
11
+ getAnchorOffset,
12
+ getTransitionClass,
13
+ resolveValue
14
+ } from "./chunk-WG7ALU5G.js";
13
15
 
14
16
  // src/BlockRenderer.tsx
15
17
  import { useId, useLayoutEffect, useRef, useState } from "react";
16
18
  import { resolveTransitionDuration } from "@bendyline/squisq/schemas";
17
19
  import { isGeometryBoundTemplate } from "@bendyline/squisq/doc";
18
20
 
21
+ // src/layers/VideoEmbedLayer.tsx
22
+ import {
23
+ parseVideoEmbedUrl,
24
+ videoEmbedIframeAttributes
25
+ } from "@bendyline/squisq/markdown";
26
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
27
+ function containedBox(outer, aspectRatio) {
28
+ const width = Math.min(outer.width, outer.height * aspectRatio);
29
+ const height = width / aspectRatio;
30
+ return {
31
+ x: outer.x + (outer.width - width) / 2,
32
+ y: outer.y + (outer.height - height) / 2,
33
+ width,
34
+ height
35
+ };
36
+ }
37
+ function truncate(text, max) {
38
+ return text.length > max ? `${text.slice(0, max - 1).trimEnd()}\u2026` : text;
39
+ }
40
+ function Poster({
41
+ box,
42
+ embed,
43
+ title,
44
+ showThumbnail
45
+ }) {
46
+ const unit = Math.min(box.width, box.height);
47
+ const buttonW = unit * 0.3;
48
+ const buttonH = buttonW * 0.7;
49
+ const cx = box.x + box.width / 2;
50
+ const cy = box.y + box.height / 2;
51
+ const tri = buttonH * 0.42;
52
+ const fontSize = Math.max(10, unit * 0.055);
53
+ const radius = Math.max(4, unit * 0.02);
54
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
55
+ /* @__PURE__ */ jsx("rect", { x: box.x, y: box.y, width: box.width, height: box.height, rx: radius, fill: "#111318" }),
56
+ showThumbnail && embed.thumbnailUrl ? /* @__PURE__ */ jsx(
57
+ "image",
58
+ {
59
+ href: embed.thumbnailUrl,
60
+ x: box.x,
61
+ y: box.y,
62
+ width: box.width,
63
+ height: box.height,
64
+ preserveAspectRatio: "xMidYMid slice",
65
+ opacity: 0.85
66
+ }
67
+ ) : null,
68
+ /* @__PURE__ */ jsx(
69
+ "rect",
70
+ {
71
+ x: cx - buttonW / 2,
72
+ y: cy - buttonH / 2,
73
+ width: buttonW,
74
+ height: buttonH,
75
+ rx: buttonH * 0.24,
76
+ fill: "rgba(0, 0, 0, 0.55)",
77
+ stroke: "rgba(255, 255, 255, 0.35)",
78
+ strokeWidth: Math.max(1, unit * 4e-3)
79
+ }
80
+ ),
81
+ /* @__PURE__ */ jsx(
82
+ "path",
83
+ {
84
+ d: `M ${cx - tri * 0.36} ${cy - tri / 2} L ${cx + tri * 0.54} ${cy} L ${cx - tri * 0.36} ${cy + tri / 2} Z`,
85
+ fill: "#ffffff"
86
+ }
87
+ ),
88
+ /* @__PURE__ */ jsx(
89
+ "text",
90
+ {
91
+ x: box.x + fontSize * 0.9,
92
+ y: box.y + box.height - fontSize * 0.9,
93
+ fill: "#ffffff",
94
+ fontSize,
95
+ fontFamily: "system-ui, -apple-system, sans-serif",
96
+ fontWeight: 600,
97
+ style: { paintOrder: "stroke" },
98
+ stroke: "rgba(0, 0, 0, 0.6)",
99
+ strokeWidth: fontSize * 0.12,
100
+ children: truncate(title ? `${title} \xB7 ${embed.providerName}` : embed.providerName, 70)
101
+ }
102
+ )
103
+ ] });
104
+ }
105
+ function VideoEmbedLayer({ layer, viewport, mode = "poster" }) {
106
+ const embed = parseVideoEmbedUrl(layer.content.url);
107
+ if (!embed) return null;
108
+ const { position } = layer;
109
+ const width = position.width ? resolveValue(position.width, viewport.width) : viewport.width;
110
+ const height = position.height ? resolveValue(position.height, viewport.height) : viewport.height;
111
+ const offset = getAnchorOffset(position.anchor, width, height);
112
+ const box = containedBox(
113
+ {
114
+ x: resolveValue(position.x, viewport.width) + offset.x,
115
+ y: resolveValue(position.y, viewport.height) + offset.y,
116
+ width,
117
+ height
118
+ },
119
+ embed.aspectRatio
120
+ );
121
+ const title = layer.content.title?.trim() ?? "";
122
+ if (mode !== "player") {
123
+ return /* @__PURE__ */ jsx(
124
+ "g",
125
+ {
126
+ className: "block-layer block-layer--video-embed",
127
+ "data-layer-id": layer.id,
128
+ "data-provider": embed.provider,
129
+ role: "img",
130
+ "aria-label": title ? `${title} (${embed.providerName} video)` : `${embed.providerName} video`,
131
+ children: /* @__PURE__ */ jsx(Poster, { box, embed, title, showThumbnail: mode === "poster" })
132
+ }
133
+ );
134
+ }
135
+ const attrs = videoEmbedIframeAttributes(embed, title);
136
+ return /* @__PURE__ */ jsx(
137
+ "g",
138
+ {
139
+ className: "block-layer block-layer--video-embed",
140
+ "data-layer-id": layer.id,
141
+ "data-provider": embed.provider,
142
+ children: /* @__PURE__ */ jsx("foreignObject", { x: box.x, y: box.y, width: box.width, height: box.height, children: /* @__PURE__ */ jsx(
143
+ "iframe",
144
+ {
145
+ "data-no-swipe": "",
146
+ src: attrs.src,
147
+ title: attrs.title,
148
+ allow: attrs.allow,
149
+ allowFullScreen: true,
150
+ referrerPolicy: "strict-origin-when-cross-origin",
151
+ loading: "lazy",
152
+ style: {
153
+ display: "block",
154
+ width: `${box.width}px`,
155
+ height: `${box.height}px`,
156
+ border: 0,
157
+ background: "#000"
158
+ }
159
+ }
160
+ ) })
161
+ }
162
+ );
163
+ }
164
+
19
165
  // src/utils/textFit.ts
20
166
  function largestFittingTextScale(fits, maximum = 2) {
21
167
  if (maximum <= 1 || !fits(1)) return 1;
@@ -31,7 +177,7 @@ function largestFittingTextScale(fits, maximum = 2) {
31
177
  }
32
178
 
33
179
  // src/BlockRenderer.tsx
34
- import { jsx, jsxs } from "react/jsx-runtime";
180
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
35
181
  var DEFAULT_VIEWPORT = {
36
182
  width: 1920,
37
183
  height: 1080
@@ -113,7 +259,8 @@ function BlockRenderer({
113
259
  animationsEnabled = true,
114
260
  theme,
115
261
  tableContentRenderer,
116
- growTextToFit = false
262
+ growTextToFit = false,
263
+ videoEmbeds = "poster"
117
264
  }) {
118
265
  let transitionClass = "";
119
266
  const transitionStyle = {};
@@ -168,7 +315,7 @@ function BlockRenderer({
168
315
  cancelled = true;
169
316
  };
170
317
  }, [block.layers, growText, viewport.height, viewport.width]);
171
- return /* @__PURE__ */ jsxs(
318
+ return /* @__PURE__ */ jsxs2(
172
319
  "svg",
173
320
  {
174
321
  ref: svgRef,
@@ -180,8 +327,8 @@ function BlockRenderer({
180
327
  "data-block-id": block.id,
181
328
  "data-squisq-text-scale": growText ? textScale : void 0,
182
329
  children: [
183
- /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsx("clipPath", { id: clipId, children: /* @__PURE__ */ jsx("rect", { x: "0", y: "0", width: viewport.width, height: viewport.height }) }) }),
184
- /* @__PURE__ */ jsx("g", { clipPath: `url(#${clipId})`, children: (block.layers ?? []).map((layer) => /* @__PURE__ */ jsx(
330
+ /* @__PURE__ */ jsx2("defs", { children: /* @__PURE__ */ jsx2("clipPath", { id: clipId, children: /* @__PURE__ */ jsx2("rect", { x: "0", y: "0", width: viewport.width, height: viewport.height }) }) }),
331
+ /* @__PURE__ */ jsx2("g", { clipPath: `url(#${clipId})`, children: (block.layers ?? []).map((layer) => /* @__PURE__ */ jsx2(
185
332
  LayerRenderer,
186
333
  {
187
334
  block,
@@ -194,7 +341,8 @@ function BlockRenderer({
194
341
  animationsEnabled,
195
342
  theme,
196
343
  tableContentRenderer,
197
- textScale
344
+ textScale,
345
+ videoEmbeds
198
346
  },
199
347
  layer.id
200
348
  )) })
@@ -213,12 +361,13 @@ function LayerRenderer({
213
361
  animationsEnabled,
214
362
  theme,
215
363
  tableContentRenderer,
216
- textScale
364
+ textScale,
365
+ videoEmbeds
217
366
  }) {
218
367
  const renderedLayer = animationsEnabled || !layer.animation ? layer : { ...layer, animation: void 0 };
219
368
  switch (renderedLayer.type) {
220
369
  case "image":
221
- return /* @__PURE__ */ jsx(
370
+ return /* @__PURE__ */ jsx2(
222
371
  ImageLayer,
223
372
  {
224
373
  layer: renderedLayer,
@@ -229,7 +378,7 @@ function LayerRenderer({
229
378
  }
230
379
  );
231
380
  case "text":
232
- return /* @__PURE__ */ jsx(
381
+ return /* @__PURE__ */ jsx2(
233
382
  TextLayer,
234
383
  {
235
384
  layer: renderedLayer,
@@ -239,11 +388,11 @@ function LayerRenderer({
239
388
  }
240
389
  );
241
390
  case "shape":
242
- return /* @__PURE__ */ jsx(ShapeLayer, { layer: renderedLayer, viewport, blockTime });
391
+ return /* @__PURE__ */ jsx2(ShapeLayer, { layer: renderedLayer, viewport, blockTime });
243
392
  case "path":
244
- return /* @__PURE__ */ jsx(PathLayer, { layer: renderedLayer, viewport, blockTime });
393
+ return /* @__PURE__ */ jsx2(PathLayer, { layer: renderedLayer, viewport, blockTime });
245
394
  case "map":
246
- return /* @__PURE__ */ jsx(
395
+ return /* @__PURE__ */ jsx2(
247
396
  MapLayer,
248
397
  {
249
398
  layer: renderedLayer,
@@ -253,7 +402,7 @@ function LayerRenderer({
253
402
  }
254
403
  );
255
404
  case "video":
256
- return /* @__PURE__ */ jsx(
405
+ return /* @__PURE__ */ jsx2(
257
406
  VideoLayer,
258
407
  {
259
408
  layer: renderedLayer,
@@ -264,8 +413,10 @@ function LayerRenderer({
264
413
  muted
265
414
  }
266
415
  );
416
+ case "videoEmbed":
417
+ return /* @__PURE__ */ jsx2(VideoEmbedLayer, { layer: renderedLayer, viewport, mode: videoEmbeds });
267
418
  case "table":
268
- return /* @__PURE__ */ jsx(
419
+ return /* @__PURE__ */ jsx2(
269
420
  TableLayer,
270
421
  {
271
422
  block,
@@ -276,9 +427,9 @@ function LayerRenderer({
276
427
  }
277
428
  );
278
429
  case "tree":
279
- return /* @__PURE__ */ jsx(TreeLayer, { layer: renderedLayer, viewport, blockTime });
430
+ return /* @__PURE__ */ jsx2(TreeLayer, { layer: renderedLayer, viewport, blockTime });
280
431
  case "mermaid":
281
- return /* @__PURE__ */ jsx(
432
+ return /* @__PURE__ */ jsx2(
282
433
  MermaidLayer,
283
434
  {
284
435
  layer: renderedLayer,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  LinearDocView
3
- } from "./chunk-2VSD55NT.js";
3
+ } from "./chunk-BMQ3EGOP.js";
4
4
  import {
5
5
  useAudioSync,
6
6
  useDocPlayback,
@@ -12,14 +12,14 @@ import {
12
12
  } from "./chunk-TT6ENR6T.js";
13
13
  import {
14
14
  MarkdownRenderer
15
- } from "./chunk-2FZUFQO3.js";
15
+ } from "./chunk-YLFAOGJF.js";
16
16
  import {
17
17
  BlockRenderer
18
- } from "./chunk-5FJZDX7H.js";
18
+ } from "./chunk-KJZF2U3I.js";
19
19
  import {
20
20
  isCaptureDrivenVideo,
21
21
  seekVideoToFrame
22
- } from "./chunk-PZCWGBRQ.js";
22
+ } from "./chunk-WG7ALU5G.js";
23
23
  import {
24
24
  useMediaProvider,
25
25
  useMediaUrl,
@@ -1630,7 +1630,8 @@ function DashboardView({
1630
1630
  isPlaying: false,
1631
1631
  muted,
1632
1632
  animationsEnabled,
1633
- theme: activeTheme
1633
+ theme: activeTheme,
1634
+ videoEmbeds: renderMode ? "placeholder" : "player"
1634
1635
  }
1635
1636
  ),
1636
1637
  cell.frame && cell.frame.overlayLayers.length > 0 && // Borders and accents ride above the block: a template that
@@ -3617,7 +3618,8 @@ function DocPlayerContent({
3617
3618
  animationsEnabled,
3618
3619
  theme: effectiveTheme,
3619
3620
  tableContentRenderer,
3620
- growTextToFit: isSlideshowMode
3621
+ growTextToFit: isSlideshowMode,
3622
+ videoEmbeds: renderMode ? "placeholder" : "poster"
3621
3623
  }
3622
3624
  ) }),
3623
3625
  animationsEnabled && !showCoverBlock && previousBlock && isExiting && // Keyed by block id so each block is its own DOM subtree: React never
@@ -3637,7 +3639,8 @@ function DocPlayerContent({
3637
3639
  animationsEnabled,
3638
3640
  theme: effectiveTheme,
3639
3641
  tableContentRenderer,
3640
- growTextToFit: isSlideshowMode
3642
+ growTextToFit: isSlideshowMode,
3643
+ videoEmbeds: renderMode ? "placeholder" : "poster"
3641
3644
  }
3642
3645
  ) }, previousBlock.id),
3643
3646
  currentBlock && /* @__PURE__ */ jsx9(
@@ -3662,7 +3665,8 @@ function DocPlayerContent({
3662
3665
  animationsEnabled,
3663
3666
  theme: effectiveTheme,
3664
3667
  tableContentRenderer,
3665
- growTextToFit: isSlideshowMode
3668
+ growTextToFit: isSlideshowMode,
3669
+ videoEmbeds: renderMode ? "placeholder" : "player"
3666
3670
  }
3667
3671
  )
3668
3672
  },
@@ -2068,6 +2068,8 @@ export {
2068
2068
  seekVideoToFrame,
2069
2069
  getAnimationStyle,
2070
2070
  getTransitionClass,
2071
+ resolveValue,
2072
+ getAnchorOffset,
2071
2073
  ImageLayer,
2072
2074
  TextLayer,
2073
2075
  ShapeLayer,