@bendyline/squisq-react 2.12.29 → 2.12.30
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/dist/{VideoLayer-sT0mrnNQ.d.ts → VideoLayer-Bg3TRIOb.d.ts} +3 -1
- package/dist/{chunk-NZHL2VKW.js → chunk-4ZSAQ266.js} +2 -2
- package/dist/{chunk-M4IUYVXU.js → chunk-6IQ72M4Y.js} +1 -1
- package/dist/{chunk-DRPMS5JK.js → chunk-755MBX5E.js} +543 -251
- package/dist/{chunk-3UITZDNL.js → chunk-TCBV3WXF.js} +50 -11
- package/dist/{chunk-Q66DDGKP.js → chunk-TWWZJWV4.js} +1 -1
- package/dist/diagram-pictures/index.js +2 -2
- package/dist/index.d.ts +3 -3
- package/dist/index.js +5 -5
- package/dist/layers/index.d.ts +1 -1
- package/dist/layers/index.js +1 -1
- package/dist/page/index.js +4 -4
- package/dist/player/index.d.ts +2 -2
- package/dist/player/index.js +4 -4
- package/dist/{player-B-2-utvs.d.ts → player-Wc6Nd4p5.d.ts} +14 -3
- package/dist/squisq-player.full.global.js +473 -473
- package/dist/squisq-player.global.js +90 -90
- package/dist/standalone-player-full.js +1 -1
- package/dist/standalone-source.js +1 -1
- package/package.json +2 -2
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
} from "@bendyline/squisq/doc";
|
|
23
23
|
|
|
24
24
|
// src/layers/ImageLayer.tsx
|
|
25
|
+
import { useId } from "react";
|
|
25
26
|
import { cssFilterForTreatment } from "@bendyline/squisq/doc";
|
|
26
27
|
|
|
27
28
|
// src/utils/layerUtils.ts
|
|
@@ -56,8 +57,81 @@ function paintsForeignObjectLayersUnscaled(userAgent = typeof navigator === "und
|
|
|
56
57
|
return /AppleWebKit\//.test(userAgent) && !/(Chrome|Chromium|jsdom)\/|Android/.test(userAgent);
|
|
57
58
|
}
|
|
58
59
|
|
|
60
|
+
// src/utils/svgFilter.tsx
|
|
61
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
62
|
+
function parseCssFilter(filter) {
|
|
63
|
+
const functions = [];
|
|
64
|
+
for (const match of filter.matchAll(/([a-z-]+)\(\s*(-?[\d.]+)(?:px|deg|%)?\s*\)/g)) {
|
|
65
|
+
const value = Number(match[2]);
|
|
66
|
+
if (Number.isFinite(value)) functions.push({ name: match[1], value });
|
|
67
|
+
}
|
|
68
|
+
return functions;
|
|
69
|
+
}
|
|
70
|
+
function sepiaMatrix(amount) {
|
|
71
|
+
const a = 1 - Math.min(1, Math.max(0, amount));
|
|
72
|
+
const rows = [
|
|
73
|
+
[0.393 + 0.607 * a, 0.769 - 0.769 * a, 0.189 - 0.189 * a],
|
|
74
|
+
[0.349 - 0.349 * a, 0.686 + 0.314 * a, 0.168 - 0.168 * a],
|
|
75
|
+
[0.272 - 0.272 * a, 0.534 - 0.534 * a, 0.131 + 0.869 * a]
|
|
76
|
+
];
|
|
77
|
+
return [...rows.map((row) => [...row, 0, 0].join(" ")), "0 0 0 1 0"].join(" ");
|
|
78
|
+
}
|
|
79
|
+
function primitive(fn, key) {
|
|
80
|
+
switch (fn.name) {
|
|
81
|
+
case "blur":
|
|
82
|
+
return fn.value > 0 ? /* @__PURE__ */ jsx("feGaussianBlur", { stdDeviation: fn.value }, key) : null;
|
|
83
|
+
case "grayscale":
|
|
84
|
+
return /* @__PURE__ */ jsx(
|
|
85
|
+
"feColorMatrix",
|
|
86
|
+
{
|
|
87
|
+
type: "saturate",
|
|
88
|
+
values: String(1 - Math.min(1, Math.max(0, fn.value)))
|
|
89
|
+
},
|
|
90
|
+
key
|
|
91
|
+
);
|
|
92
|
+
case "saturate":
|
|
93
|
+
return /* @__PURE__ */ jsx("feColorMatrix", { type: "saturate", values: String(fn.value) }, key);
|
|
94
|
+
case "hue-rotate":
|
|
95
|
+
return /* @__PURE__ */ jsx("feColorMatrix", { type: "hueRotate", values: String(fn.value) }, key);
|
|
96
|
+
case "sepia":
|
|
97
|
+
return /* @__PURE__ */ jsx("feColorMatrix", { type: "matrix", values: sepiaMatrix(fn.value) }, key);
|
|
98
|
+
case "contrast": {
|
|
99
|
+
const intercept = 0.5 - 0.5 * fn.value;
|
|
100
|
+
return /* @__PURE__ */ jsxs("feComponentTransfer", { children: [
|
|
101
|
+
/* @__PURE__ */ jsx("feFuncR", { type: "linear", slope: fn.value, intercept }),
|
|
102
|
+
/* @__PURE__ */ jsx("feFuncG", { type: "linear", slope: fn.value, intercept }),
|
|
103
|
+
/* @__PURE__ */ jsx("feFuncB", { type: "linear", slope: fn.value, intercept })
|
|
104
|
+
] }, key);
|
|
105
|
+
}
|
|
106
|
+
case "brightness":
|
|
107
|
+
return /* @__PURE__ */ jsxs("feComponentTransfer", { children: [
|
|
108
|
+
/* @__PURE__ */ jsx("feFuncR", { type: "linear", slope: fn.value }),
|
|
109
|
+
/* @__PURE__ */ jsx("feFuncG", { type: "linear", slope: fn.value }),
|
|
110
|
+
/* @__PURE__ */ jsx("feFuncB", { type: "linear", slope: fn.value })
|
|
111
|
+
] }, key);
|
|
112
|
+
default:
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
function svgFilterFromCss(id, cssFilter) {
|
|
117
|
+
if (!cssFilter) return null;
|
|
118
|
+
const primitives = parseCssFilter(cssFilter).map(primitive).filter((element) => element !== null);
|
|
119
|
+
if (primitives.length === 0) return null;
|
|
120
|
+
return /* @__PURE__ */ jsx("filter", { id, colorInterpolationFilters: "sRGB", x: "-10%", y: "-10%", width: "120%", height: "120%", children: primitives });
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// src/utils/defsId.ts
|
|
124
|
+
function defsIdFor(reactId, layerId) {
|
|
125
|
+
const raw = `${reactId}-${layerId}`;
|
|
126
|
+
const safe = raw.replace(/[^A-Za-z0-9_-]/g, "_");
|
|
127
|
+
if (safe === raw.replace(/:/g, "_")) return safe.replace(/^_+/, "d");
|
|
128
|
+
let hash = 0;
|
|
129
|
+
for (let i = 0; i < raw.length; i++) hash = hash * 31 + raw.charCodeAt(i) >>> 0;
|
|
130
|
+
return `${safe.replace(/^_+/, "d")}-${hash.toString(36)}`;
|
|
131
|
+
}
|
|
132
|
+
|
|
59
133
|
// src/layers/ImageLayer.tsx
|
|
60
|
-
import { jsx } from "react/jsx-runtime";
|
|
134
|
+
import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
61
135
|
function ImageLayer({
|
|
62
136
|
layer,
|
|
63
137
|
basePath,
|
|
@@ -67,6 +141,7 @@ function ImageLayer({
|
|
|
67
141
|
isStatic = false
|
|
68
142
|
}) {
|
|
69
143
|
const { content, position, animation } = layer;
|
|
144
|
+
const defsId = defsIdFor(useId(), layer.id);
|
|
70
145
|
const x = resolveValue(position.x, viewport.width);
|
|
71
146
|
const y = resolveValue(position.y, viewport.height);
|
|
72
147
|
const width = position.width ? resolveValue(position.width, viewport.width) : viewport.width;
|
|
@@ -79,83 +154,98 @@ function ImageLayer({
|
|
|
79
154
|
const filter = cssFilterForTreatment(content.treatment, content.blur);
|
|
80
155
|
const preserveAspectRatio = getPreserveAspectRatio(content.fit);
|
|
81
156
|
const isCover = content.fit === "cover";
|
|
157
|
+
const svgNative = paintsForeignObjectLayersUnscaled();
|
|
158
|
+
const gradeId = `${defsId}-grade`;
|
|
159
|
+
const svgGrade = svgNative ? svgFilterFromCss(gradeId, filter) : null;
|
|
160
|
+
const blurred = Boolean(content.blur && content.blur > 0);
|
|
161
|
+
const imgGrade = svgNative ? blurred ? {
|
|
162
|
+
width: `${width * BLUR_OVERSCAN}px`,
|
|
163
|
+
height: `${height * BLUR_OVERSCAN}px`,
|
|
164
|
+
margin: `${-height * (BLUR_OVERSCAN - 1) / 2}px 0 0 ${-width * (BLUR_OVERSCAN - 1) / 2}px`,
|
|
165
|
+
maxWidth: "none"
|
|
166
|
+
} : {} : {
|
|
167
|
+
...filter ? { filter } : {},
|
|
168
|
+
// Over-scan blurred imagery so the soft edges never reveal the frame
|
|
169
|
+
// behind the layer.
|
|
170
|
+
...blurred ? { transform: `scale(${BLUR_OVERSCAN})` } : {}
|
|
171
|
+
};
|
|
172
|
+
const graded = (children) => svgGrade ? /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
173
|
+
/* @__PURE__ */ jsx2("defs", { children: svgGrade }),
|
|
174
|
+
/* @__PURE__ */ jsx2("g", { filter: `url(#${gradeId})`, children })
|
|
175
|
+
] }) : children;
|
|
82
176
|
const isSpatialAnim = animation && SPATIAL_ANIMATION_TYPES.has(animation.type);
|
|
83
177
|
const usesPortraitPan = isCover && shouldUsePortraitPan(viewport, width, height, animationsEnabled, animation);
|
|
84
178
|
if (usesPortraitPan) {
|
|
85
179
|
const panClass = getPortraitPanClass(animation);
|
|
86
180
|
const panStyle = getPortraitPanStyle(isSpatialAnim ? animation : void 0);
|
|
87
181
|
const containerAnim = isSpatialAnim ? { className: "", style: {} } : animStyle;
|
|
88
|
-
return /* @__PURE__ */
|
|
182
|
+
return /* @__PURE__ */ jsx2(
|
|
89
183
|
"g",
|
|
90
184
|
{
|
|
91
185
|
className: `block-layer block-layer--image ${containerAnim.className}`,
|
|
92
186
|
style: containerAnim.style,
|
|
93
187
|
"data-layer-id": layer.id,
|
|
94
188
|
"data-image-framing": "portrait-pan",
|
|
95
|
-
children:
|
|
96
|
-
"
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
189
|
+
children: graded(
|
|
190
|
+
/* @__PURE__ */ jsx2("foreignObject", { x: finalX, y: finalY, width, height, children: /* @__PURE__ */ jsx2(
|
|
191
|
+
"div",
|
|
192
|
+
{
|
|
193
|
+
style: {
|
|
194
|
+
width: `${width}px`,
|
|
195
|
+
height: `${height}px`,
|
|
196
|
+
overflow: "hidden"
|
|
197
|
+
},
|
|
198
|
+
children: /* @__PURE__ */ jsx2(
|
|
199
|
+
"img",
|
|
200
|
+
{
|
|
201
|
+
src,
|
|
202
|
+
alt: content.alt || "",
|
|
203
|
+
className: panClass,
|
|
204
|
+
style: {
|
|
205
|
+
width: `${width}px`,
|
|
206
|
+
height: `${height}px`,
|
|
207
|
+
objectFit: "cover",
|
|
208
|
+
objectPosition: "center",
|
|
209
|
+
display: "block",
|
|
210
|
+
pointerEvents: "none",
|
|
211
|
+
...imgGrade,
|
|
212
|
+
...panStyle
|
|
213
|
+
}
|
|
119
214
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
)
|
|
215
|
+
)
|
|
216
|
+
}
|
|
217
|
+
) })
|
|
218
|
+
)
|
|
124
219
|
}
|
|
125
220
|
);
|
|
126
221
|
}
|
|
127
222
|
if (isCover && isSpatialAnim && animation) {
|
|
128
223
|
const kbAnim = remapToKenBurns(animation);
|
|
129
224
|
const kbStyle = getAnimationStyle(kbAnim, blockTime);
|
|
130
|
-
if (
|
|
131
|
-
return /* @__PURE__ */
|
|
225
|
+
if (svgNative) {
|
|
226
|
+
return /* @__PURE__ */ jsx2(
|
|
132
227
|
"g",
|
|
133
228
|
{
|
|
134
229
|
className: "block-layer block-layer--image",
|
|
135
230
|
"data-layer-id": layer.id,
|
|
136
231
|
"data-image-framing": "svg-ken-burns",
|
|
137
|
-
children: /* @__PURE__ */
|
|
138
|
-
|
|
232
|
+
children: /* @__PURE__ */ jsx2(
|
|
233
|
+
SvgCoverImage,
|
|
139
234
|
{
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
235
|
+
layerId: layer.id,
|
|
236
|
+
src,
|
|
237
|
+
alt: content.alt,
|
|
238
|
+
box: { x: finalX, y: finalY, width, height },
|
|
239
|
+
grade: svgGrade,
|
|
240
|
+
gradeId,
|
|
144
241
|
className: kbStyle.className,
|
|
145
|
-
|
|
146
|
-
style: {
|
|
147
|
-
pointerEvents: "none",
|
|
148
|
-
transformBox: "fill-box",
|
|
149
|
-
transformOrigin: "center center",
|
|
150
|
-
...filter ? { filter } : {},
|
|
151
|
-
...kbStyle.style
|
|
152
|
-
}
|
|
242
|
+
style: kbStyle.style
|
|
153
243
|
}
|
|
154
|
-
)
|
|
244
|
+
)
|
|
155
245
|
}
|
|
156
246
|
);
|
|
157
247
|
}
|
|
158
|
-
return /* @__PURE__ */
|
|
248
|
+
return /* @__PURE__ */ jsx2("g", { className: "block-layer block-layer--image", "data-layer-id": layer.id, children: /* @__PURE__ */ jsx2("foreignObject", { x: finalX, y: finalY, width, height, children: /* @__PURE__ */ jsx2(
|
|
159
249
|
"div",
|
|
160
250
|
{
|
|
161
251
|
style: {
|
|
@@ -163,7 +253,7 @@ function ImageLayer({
|
|
|
163
253
|
height: `${height}px`,
|
|
164
254
|
overflow: "hidden"
|
|
165
255
|
},
|
|
166
|
-
children: /* @__PURE__ */
|
|
256
|
+
children: /* @__PURE__ */ jsx2(
|
|
167
257
|
"img",
|
|
168
258
|
{
|
|
169
259
|
src,
|
|
@@ -186,55 +276,103 @@ function ImageLayer({
|
|
|
186
276
|
) }) });
|
|
187
277
|
}
|
|
188
278
|
if (isCover) {
|
|
189
|
-
return /* @__PURE__ */
|
|
279
|
+
return /* @__PURE__ */ jsx2(
|
|
190
280
|
"g",
|
|
191
281
|
{
|
|
192
282
|
className: `block-layer block-layer--image ${animStyle.className}`,
|
|
193
283
|
style: animStyle.style,
|
|
194
284
|
"data-layer-id": layer.id,
|
|
195
|
-
children:
|
|
196
|
-
"
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
...content.blur && content.blur > 0 ? { transform: "scale(1.06)" } : {}
|
|
285
|
+
children: graded(
|
|
286
|
+
/* @__PURE__ */ jsx2("foreignObject", { x: finalX, y: finalY, width, height, children: /* @__PURE__ */ jsx2(
|
|
287
|
+
"img",
|
|
288
|
+
{
|
|
289
|
+
src,
|
|
290
|
+
alt: content.alt || "",
|
|
291
|
+
style: {
|
|
292
|
+
width: `${width}px`,
|
|
293
|
+
height: `${height}px`,
|
|
294
|
+
objectFit: "cover",
|
|
295
|
+
objectPosition: "center",
|
|
296
|
+
display: "block",
|
|
297
|
+
pointerEvents: "none",
|
|
298
|
+
...imgGrade
|
|
299
|
+
}
|
|
211
300
|
}
|
|
212
|
-
}
|
|
213
|
-
)
|
|
301
|
+
) })
|
|
302
|
+
)
|
|
214
303
|
}
|
|
215
304
|
);
|
|
216
305
|
}
|
|
217
|
-
return /* @__PURE__ */
|
|
306
|
+
return /* @__PURE__ */ jsxs2(
|
|
218
307
|
"g",
|
|
219
308
|
{
|
|
220
309
|
className: `block-layer block-layer--image ${animStyle.className}`,
|
|
221
310
|
style: animStyle.style,
|
|
222
311
|
"data-layer-id": layer.id,
|
|
223
|
-
children:
|
|
224
|
-
"
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
312
|
+
children: [
|
|
313
|
+
svgGrade && /* @__PURE__ */ jsx2("defs", { children: svgGrade }),
|
|
314
|
+
/* @__PURE__ */ jsx2(
|
|
315
|
+
"image",
|
|
316
|
+
{
|
|
317
|
+
href: src,
|
|
318
|
+
x: finalX,
|
|
319
|
+
y: finalY,
|
|
320
|
+
width,
|
|
321
|
+
height,
|
|
322
|
+
preserveAspectRatio,
|
|
323
|
+
filter: svgGrade ? `url(#${defsId}-grade)` : void 0,
|
|
324
|
+
style: { pointerEvents: "none", ...filter && !svgGrade ? { filter } : {} }
|
|
325
|
+
}
|
|
326
|
+
)
|
|
327
|
+
]
|
|
235
328
|
}
|
|
236
329
|
);
|
|
237
330
|
}
|
|
331
|
+
function SvgCoverImage({
|
|
332
|
+
layerId,
|
|
333
|
+
src,
|
|
334
|
+
alt,
|
|
335
|
+
box,
|
|
336
|
+
grade,
|
|
337
|
+
gradeId,
|
|
338
|
+
className,
|
|
339
|
+
style
|
|
340
|
+
}) {
|
|
341
|
+
const { x, y, width, height } = box;
|
|
342
|
+
return /* @__PURE__ */ jsxs2(
|
|
343
|
+
"svg",
|
|
344
|
+
{
|
|
345
|
+
x,
|
|
346
|
+
y,
|
|
347
|
+
width,
|
|
348
|
+
height,
|
|
349
|
+
style: { overflow: "hidden" },
|
|
350
|
+
"data-image-layer": layerId,
|
|
351
|
+
children: [
|
|
352
|
+
grade && /* @__PURE__ */ jsx2("defs", { children: grade }),
|
|
353
|
+
/* @__PURE__ */ jsx2(
|
|
354
|
+
"image",
|
|
355
|
+
{
|
|
356
|
+
href: src,
|
|
357
|
+
width,
|
|
358
|
+
height,
|
|
359
|
+
preserveAspectRatio: "xMidYMid slice",
|
|
360
|
+
className,
|
|
361
|
+
filter: grade ? `url(#${gradeId})` : void 0,
|
|
362
|
+
...alt ? { role: "img", "aria-label": alt } : {},
|
|
363
|
+
style: {
|
|
364
|
+
pointerEvents: "none",
|
|
365
|
+
transformBox: "fill-box",
|
|
366
|
+
transformOrigin: "center center",
|
|
367
|
+
...style
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
)
|
|
371
|
+
]
|
|
372
|
+
}
|
|
373
|
+
);
|
|
374
|
+
}
|
|
375
|
+
var BLUR_OVERSCAN = 1.06;
|
|
238
376
|
function getPreserveAspectRatio(fit) {
|
|
239
377
|
switch (fit) {
|
|
240
378
|
case "cover":
|
|
@@ -281,8 +419,8 @@ function remapToKenBurns(anim) {
|
|
|
281
419
|
|
|
282
420
|
// src/layers/TextLayer.tsx
|
|
283
421
|
import {
|
|
284
|
-
Fragment,
|
|
285
|
-
useId,
|
|
422
|
+
Fragment as Fragment2,
|
|
423
|
+
useId as useId2,
|
|
286
424
|
useLayoutEffect,
|
|
287
425
|
useMemo,
|
|
288
426
|
useRef,
|
|
@@ -302,18 +440,8 @@ import {
|
|
|
302
440
|
iconClass
|
|
303
441
|
} from "@bendyline/squisq/icon-marker";
|
|
304
442
|
|
|
305
|
-
// src/utils/defsId.ts
|
|
306
|
-
function defsIdFor(reactId, layerId) {
|
|
307
|
-
const raw = `${reactId}-${layerId}`;
|
|
308
|
-
const safe = raw.replace(/[^A-Za-z0-9_-]/g, "_");
|
|
309
|
-
if (safe === raw.replace(/:/g, "_")) return safe.replace(/^_+/, "d");
|
|
310
|
-
let hash = 0;
|
|
311
|
-
for (let i = 0; i < raw.length; i++) hash = hash * 31 + raw.charCodeAt(i) >>> 0;
|
|
312
|
-
return `${safe.replace(/^_+/, "d")}-${hash.toString(36)}`;
|
|
313
|
-
}
|
|
314
|
-
|
|
315
443
|
// src/utils/fillStyle.tsx
|
|
316
|
-
import { jsx as
|
|
444
|
+
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
317
445
|
function borderDashArray(style, strokeWidth) {
|
|
318
446
|
if (!style || style === "solid") return void 0;
|
|
319
447
|
const w = Math.max(1, strokeWidth ?? 1);
|
|
@@ -339,9 +467,9 @@ function resolveFill(layerId, color, gradient, pattern) {
|
|
|
339
467
|
const v = gradientVector(gradient.angle);
|
|
340
468
|
return {
|
|
341
469
|
fill: `url(#${id})`,
|
|
342
|
-
def: /* @__PURE__ */
|
|
343
|
-
/* @__PURE__ */
|
|
344
|
-
/* @__PURE__ */
|
|
470
|
+
def: /* @__PURE__ */ jsxs3("linearGradient", { id, x1: v.x1, y1: v.y1, x2: v.x2, y2: v.y2, children: [
|
|
471
|
+
/* @__PURE__ */ jsx3("stop", { offset: "0%", stopColor: gradient.from }),
|
|
472
|
+
/* @__PURE__ */ jsx3("stop", { offset: "100%", stopColor: gradient.to })
|
|
345
473
|
] })
|
|
346
474
|
};
|
|
347
475
|
}
|
|
@@ -351,7 +479,7 @@ function patternDef(id, pattern) {
|
|
|
351
479
|
const size = pattern.size ?? 24;
|
|
352
480
|
const opacity = pattern.opacity ?? 1;
|
|
353
481
|
const color = pattern.color;
|
|
354
|
-
return /* @__PURE__ */
|
|
482
|
+
return /* @__PURE__ */ jsxs3(
|
|
355
483
|
"pattern",
|
|
356
484
|
{
|
|
357
485
|
id,
|
|
@@ -360,7 +488,7 @@ function patternDef(id, pattern) {
|
|
|
360
488
|
patternUnits: "userSpaceOnUse",
|
|
361
489
|
patternTransform: pattern.kind === "diagonal" ? "rotate(45)" : void 0,
|
|
362
490
|
children: [
|
|
363
|
-
pattern.kind === "dots" && /* @__PURE__ */
|
|
491
|
+
pattern.kind === "dots" && /* @__PURE__ */ jsx3(
|
|
364
492
|
"circle",
|
|
365
493
|
{
|
|
366
494
|
cx: size / 2,
|
|
@@ -370,7 +498,7 @@ function patternDef(id, pattern) {
|
|
|
370
498
|
opacity
|
|
371
499
|
}
|
|
372
500
|
),
|
|
373
|
-
pattern.kind === "grid" && /* @__PURE__ */
|
|
501
|
+
pattern.kind === "grid" && /* @__PURE__ */ jsx3(
|
|
374
502
|
"path",
|
|
375
503
|
{
|
|
376
504
|
d: `M ${size} 0 L 0 0 0 ${size}`,
|
|
@@ -380,7 +508,7 @@ function patternDef(id, pattern) {
|
|
|
380
508
|
opacity
|
|
381
509
|
}
|
|
382
510
|
),
|
|
383
|
-
pattern.kind === "diagonal" && /* @__PURE__ */
|
|
511
|
+
pattern.kind === "diagonal" && /* @__PURE__ */ jsx3("line", { x1: 0, y1: 0, x2: 0, y2: size, stroke: color, strokeWidth: 1, opacity })
|
|
384
512
|
]
|
|
385
513
|
}
|
|
386
514
|
);
|
|
@@ -391,8 +519,8 @@ function resolveShapeFilter(layerId, filter) {
|
|
|
391
519
|
const opacity = filter.opacity ?? 0.05;
|
|
392
520
|
return {
|
|
393
521
|
filterAttr: `url(#${id})`,
|
|
394
|
-
def: /* @__PURE__ */
|
|
395
|
-
/* @__PURE__ */
|
|
522
|
+
def: /* @__PURE__ */ jsxs3("filter", { id, x: "0%", y: "0%", width: "100%", height: "100%", children: [
|
|
523
|
+
/* @__PURE__ */ jsx3(
|
|
396
524
|
"feTurbulence",
|
|
397
525
|
{
|
|
398
526
|
type: "fractalNoise",
|
|
@@ -402,19 +530,19 @@ function resolveShapeFilter(layerId, filter) {
|
|
|
402
530
|
result: "noise"
|
|
403
531
|
}
|
|
404
532
|
),
|
|
405
|
-
/* @__PURE__ */
|
|
406
|
-
/* @__PURE__ */
|
|
407
|
-
/* @__PURE__ */
|
|
533
|
+
/* @__PURE__ */ jsx3("feColorMatrix", { in: "noise", type: "saturate", values: "0", result: "mono" }),
|
|
534
|
+
/* @__PURE__ */ jsx3("feComponentTransfer", { in: "mono", result: "faded", children: /* @__PURE__ */ jsx3("feFuncA", { type: "linear", slope: opacity, intercept: 0 }) }),
|
|
535
|
+
/* @__PURE__ */ jsx3("feComposite", { in: "faded", in2: "SourceGraphic", operator: "in" })
|
|
408
536
|
] })
|
|
409
537
|
};
|
|
410
538
|
}
|
|
411
539
|
|
|
412
540
|
// src/layers/TextLayer.tsx
|
|
413
|
-
import { Fragment as
|
|
541
|
+
import { Fragment as Fragment3, jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
414
542
|
function TextLayer(props) {
|
|
415
|
-
if (props.layer.content.html?.trim()) return /* @__PURE__ */
|
|
416
|
-
if (hasIconMarker(props.layer.content.text ?? "")) return /* @__PURE__ */
|
|
417
|
-
return /* @__PURE__ */
|
|
543
|
+
if (props.layer.content.html?.trim()) return /* @__PURE__ */ jsx4(RichTextLayer, { ...props });
|
|
544
|
+
if (hasIconMarker(props.layer.content.text ?? "")) return /* @__PURE__ */ jsx4(IconTextLayer, { ...props });
|
|
545
|
+
return /* @__PURE__ */ jsx4(PlainTextLayer, { ...props });
|
|
418
546
|
}
|
|
419
547
|
function escapeHtml(value) {
|
|
420
548
|
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
@@ -460,13 +588,13 @@ function IconTextLayer({ layer, viewport, blockTime, textScale = 1 }) {
|
|
|
460
588
|
...style.shadow ? { textShadow: "0 2px 3px rgba(0,0,0,0.7)" } : {},
|
|
461
589
|
...animStyle.style
|
|
462
590
|
};
|
|
463
|
-
return /* @__PURE__ */
|
|
591
|
+
return /* @__PURE__ */ jsx4(
|
|
464
592
|
"g",
|
|
465
593
|
{
|
|
466
594
|
className: `block-layer block-layer--text ${animStyle.className}`,
|
|
467
595
|
style: animStyle.style,
|
|
468
596
|
"data-layer-id": layer.id,
|
|
469
|
-
children: /* @__PURE__ */
|
|
597
|
+
children: /* @__PURE__ */ jsx4(
|
|
470
598
|
"foreignObject",
|
|
471
599
|
{
|
|
472
600
|
x: boxX,
|
|
@@ -474,14 +602,14 @@ function IconTextLayer({ layer, viewport, blockTime, textScale = 1 }) {
|
|
|
474
602
|
width: boxWidth,
|
|
475
603
|
height: boxHeight,
|
|
476
604
|
style: { overflow: "visible" },
|
|
477
|
-
children: /* @__PURE__ */
|
|
605
|
+
children: /* @__PURE__ */ jsx4(
|
|
478
606
|
"div",
|
|
479
607
|
{
|
|
480
608
|
...{ xmlns: "http://www.w3.org/1999/xhtml" },
|
|
481
609
|
"data-squisq-text-fit": "html",
|
|
482
610
|
"data-squisq-base-font-size": style.fontSize,
|
|
483
611
|
style: boxStyle,
|
|
484
|
-
children: /* @__PURE__ */
|
|
612
|
+
children: /* @__PURE__ */ jsx4(
|
|
485
613
|
"div",
|
|
486
614
|
{
|
|
487
615
|
"data-squisq-text-content": "true",
|
|
@@ -502,7 +630,7 @@ function IconTextLayer({ layer, viewport, blockTime, textScale = 1 }) {
|
|
|
502
630
|
);
|
|
503
631
|
}
|
|
504
632
|
function PlainTextLayer({ layer, viewport, blockTime, textScale = 1 }) {
|
|
505
|
-
const defsId = defsIdFor(
|
|
633
|
+
const defsId = defsIdFor(useId2(), layer.id);
|
|
506
634
|
const { content, position, animation } = layer;
|
|
507
635
|
const { text, style } = content;
|
|
508
636
|
const rawX = resolveValue(position.x, viewport.width);
|
|
@@ -512,6 +640,7 @@ function PlainTextLayer({ layer, viewport, blockTime, textScale = 1 }) {
|
|
|
512
640
|
const maxWidth = boxWidth;
|
|
513
641
|
const textAnchor = getTextAnchor(style.textAlign, position.anchor);
|
|
514
642
|
const dominantBaseline = getDominantBaseline(style.verticalAlign, position.anchor);
|
|
643
|
+
const tspanBaseline = dominantBaseline;
|
|
515
644
|
const anchor = position.anchor ?? "top-left";
|
|
516
645
|
const x = pivotX(rawX, boxWidth, anchor, textAnchor);
|
|
517
646
|
const y = pivotY(rawY, boxHeight, anchor, dominantBaseline);
|
|
@@ -599,21 +728,29 @@ function PlainTextLayer({ layer, viewport, blockTime, textScale = 1 }) {
|
|
|
599
728
|
const words = line.split(" ");
|
|
600
729
|
return words.map((word, w) => {
|
|
601
730
|
const delay = wordRevealDelay(animation, wordIndex++);
|
|
602
|
-
return /* @__PURE__ */
|
|
731
|
+
return /* @__PURE__ */ jsxs4(Fragment2, { children: [
|
|
603
732
|
w > 0 ? " " : null,
|
|
604
|
-
/* @__PURE__ */
|
|
733
|
+
/* @__PURE__ */ jsx4(
|
|
734
|
+
"tspan",
|
|
735
|
+
{
|
|
736
|
+
className: "anim-word",
|
|
737
|
+
dominantBaseline: tspanBaseline,
|
|
738
|
+
style: { "--anim-delay": `${delay}s` },
|
|
739
|
+
children: word
|
|
740
|
+
}
|
|
741
|
+
)
|
|
605
742
|
] }, w);
|
|
606
743
|
});
|
|
607
744
|
};
|
|
608
|
-
return /* @__PURE__ */
|
|
745
|
+
return /* @__PURE__ */ jsxs4(
|
|
609
746
|
"g",
|
|
610
747
|
{
|
|
611
748
|
className: `block-layer block-layer--text ${animStyle.className}`,
|
|
612
749
|
style: animStyle.style,
|
|
613
750
|
"data-layer-id": layer.id,
|
|
614
751
|
children: [
|
|
615
|
-
style.shadow && /* @__PURE__ */
|
|
616
|
-
/* @__PURE__ */
|
|
752
|
+
style.shadow && /* @__PURE__ */ jsx4("defs", { children: /* @__PURE__ */ jsx4("filter", { id: filterId, x: "-20%", y: "-20%", width: "140%", height: "140%", children: /* @__PURE__ */ jsx4("feDropShadow", { dx: "0", dy: "2", stdDeviation: "3", floodColor: "rgba(0,0,0,0.7)" }) }) }),
|
|
753
|
+
/* @__PURE__ */ jsx4(
|
|
617
754
|
TextBox,
|
|
618
755
|
{
|
|
619
756
|
layerId: defsId,
|
|
@@ -631,7 +768,7 @@ function PlainTextLayer({ layer, viewport, blockTime, textScale = 1 }) {
|
|
|
631
768
|
}
|
|
632
769
|
}
|
|
633
770
|
),
|
|
634
|
-
/* @__PURE__ */
|
|
771
|
+
/* @__PURE__ */ jsx4(
|
|
635
772
|
"g",
|
|
636
773
|
{
|
|
637
774
|
"data-squisq-text-fit": "svg",
|
|
@@ -642,7 +779,7 @@ function PlainTextLayer({ layer, viewport, blockTime, textScale = 1 }) {
|
|
|
642
779
|
transformOrigin: `${x}px ${y}px`,
|
|
643
780
|
transformBox: "view-box"
|
|
644
781
|
},
|
|
645
|
-
children: /* @__PURE__ */
|
|
782
|
+
children: /* @__PURE__ */ jsx4(
|
|
646
783
|
"text",
|
|
647
784
|
{
|
|
648
785
|
ref: textRef,
|
|
@@ -650,14 +787,24 @@ function PlainTextLayer({ layer, viewport, blockTime, textScale = 1 }) {
|
|
|
650
787
|
x,
|
|
651
788
|
y,
|
|
652
789
|
textAnchor,
|
|
653
|
-
dominantBaseline,
|
|
790
|
+
dominantBaseline: tspanBaseline,
|
|
791
|
+
textRendering: "geometricPrecision",
|
|
654
792
|
style: textStyles,
|
|
655
793
|
filter: filterId ? `url(#${filterId})` : void 0,
|
|
656
794
|
transform: fitTransform,
|
|
657
|
-
children: lines.map((line, i) => /* @__PURE__ */
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
795
|
+
children: lines.map((line, i) => /* @__PURE__ */ jsxs4(
|
|
796
|
+
"tspan",
|
|
797
|
+
{
|
|
798
|
+
x,
|
|
799
|
+
dy: i === 0 ? firstLineDy + baselineShiftPx : lineHeightPx,
|
|
800
|
+
dominantBaseline: tspanBaseline,
|
|
801
|
+
children: [
|
|
802
|
+
renderLine(line),
|
|
803
|
+
i < lines.length - 1 && /* @__PURE__ */ jsx4("tspan", { style: { fontSize: 0 }, children: " " })
|
|
804
|
+
]
|
|
805
|
+
},
|
|
806
|
+
i
|
|
807
|
+
))
|
|
661
808
|
}
|
|
662
809
|
)
|
|
663
810
|
}
|
|
@@ -708,19 +855,20 @@ function RichTextLayer({ layer, viewport, blockTime, textScale = 1 }) {
|
|
|
708
855
|
...animStyle.style
|
|
709
856
|
};
|
|
710
857
|
const cls = `squisq-rich-text-${cssId(layer.id)}`;
|
|
858
|
+
const stickyHeader = !paintsForeignObjectLayersUnscaled();
|
|
711
859
|
const listStylePosition = style.textAlign === "center" || style.textAlign === "right" ? "inside" : "outside";
|
|
712
860
|
const stopEmbeddedTableEvent = (event) => {
|
|
713
861
|
const target = event.target;
|
|
714
862
|
if (target?.closest?.("[data-squisq-table-scroll]")) event.stopPropagation();
|
|
715
863
|
};
|
|
716
|
-
const scopedCss = `.${cls}{margin:0}.${cls} p{margin:0 0 .4em}.${cls} h1,.${cls} h2,.${cls} h3,.${cls} h4,.${cls} h5,.${cls} h6{margin:0 0 .3em;line-height:1.2}.${cls} ul,.${cls} ol{margin:0 0 .7em;padding-left:1.2em;list-style-position:${listStylePosition}}.${cls} li{margin:0}.${cls} li[data-squisq-build-item]{list-style:none}.${cls} li[data-squisq-task]{list-style:none}.${cls} [data-squisq-build-row]{display:flex;gap:.35em}.${cls} [data-squisq-build-row]>span{flex:0 0 1.4em;text-align:right;margin-left:-1.75em}.${cls} [data-squisq-build-row]>div{min-width:0;flex:1}.${cls} li>p{display:inline;margin:0}.${cls} [data-squisq-table-scroll]{width:100%;max-height:20em;margin:.35em 0;overflow:auto;overscroll-behavior:contain;box-sizing:border-box}.${cls} table{width:100%;min-width:48em;margin:0;border-collapse:separate;border-spacing:0;table-layout:fixed;font-size:.76em;line-height:1.2}.${cls} th,.${cls} td{box-sizing:border-box;padding:.28em .45em;border:1px solid rgba(127,127,127,.55);border-color:color-mix(in srgb,currentColor 32%,transparent);vertical-align:top;white-space:normal;overflow-wrap:anywhere}.${cls} th{position:sticky;top:0;z-index:1;background:rgba(127,127,127,.16);background:color-mix(in srgb,currentColor 12%,transparent);font-weight:600}.${cls} tbody tr:nth-child(even){background:rgba(127,127,127,.07);background:color-mix(in srgb,currentColor 5%,transparent)}.${cls} *:first-child{margin-top:0}.${cls} *:last-child{margin-bottom:0}.${cls} a{color:inherit;text-decoration:underline}`;
|
|
717
|
-
return /* @__PURE__ */
|
|
864
|
+
const scopedCss = `.${cls}{margin:0}.${cls} p{margin:0 0 .4em}.${cls} h1,.${cls} h2,.${cls} h3,.${cls} h4,.${cls} h5,.${cls} h6{margin:0 0 .3em;line-height:1.2}.${cls} ul,.${cls} ol{margin:0 0 .7em;padding-left:1.2em;list-style-position:${listStylePosition}}.${cls} li{margin:0}.${cls} li[data-squisq-build-item]{list-style:none}.${cls} li[data-squisq-task]{list-style:none}.${cls} [data-squisq-build-row]{display:flex;gap:.35em}.${cls} [data-squisq-build-row]>span{flex:0 0 1.4em;text-align:right;margin-left:-1.75em}.${cls} [data-squisq-build-row]>div{min-width:0;flex:1}.${cls} li>p{display:inline;margin:0}.${cls} [data-squisq-table-scroll]{width:100%;max-height:20em;margin:.35em 0;overflow:auto;overscroll-behavior:contain;box-sizing:border-box}.${cls} table{width:100%;min-width:48em;margin:0;border-collapse:separate;border-spacing:0;table-layout:fixed;font-size:.76em;line-height:1.2}.${cls} th,.${cls} td{box-sizing:border-box;padding:.28em .45em;border:1px solid rgba(127,127,127,.55);border-color:color-mix(in srgb,currentColor 32%,transparent);vertical-align:top;white-space:normal;overflow-wrap:anywhere}.${cls} th{${stickyHeader ? "position:sticky;top:0;z-index:1;" : ""}background:rgba(127,127,127,.16);background:color-mix(in srgb,currentColor 12%,transparent);font-weight:600}.${cls} tbody tr:nth-child(even){background:rgba(127,127,127,.07);background:color-mix(in srgb,currentColor 5%,transparent)}.${cls} *:first-child{margin-top:0}.${cls} *:last-child{margin-bottom:0}.${cls} a{color:inherit;text-decoration:underline}`;
|
|
865
|
+
return /* @__PURE__ */ jsx4(
|
|
718
866
|
"g",
|
|
719
867
|
{
|
|
720
868
|
className: `block-layer block-layer--text ${animStyle.className}`,
|
|
721
869
|
style: animStyle.style,
|
|
722
870
|
"data-layer-id": layer.id,
|
|
723
|
-
children: /* @__PURE__ */
|
|
871
|
+
children: /* @__PURE__ */ jsx4(
|
|
724
872
|
"foreignObject",
|
|
725
873
|
{
|
|
726
874
|
x: boxX,
|
|
@@ -729,7 +877,7 @@ function RichTextLayer({ layer, viewport, blockTime, textScale = 1 }) {
|
|
|
729
877
|
height: boxHeight,
|
|
730
878
|
color: style.color,
|
|
731
879
|
style: { color: style.color },
|
|
732
|
-
children: /* @__PURE__ */
|
|
880
|
+
children: /* @__PURE__ */ jsxs4(
|
|
733
881
|
"div",
|
|
734
882
|
{
|
|
735
883
|
...{ xmlns: "http://www.w3.org/1999/xhtml" },
|
|
@@ -741,8 +889,8 @@ function RichTextLayer({ layer, viewport, blockTime, textScale = 1 }) {
|
|
|
741
889
|
onWheel: stopEmbeddedTableEvent,
|
|
742
890
|
onKeyDown: stopEmbeddedTableEvent,
|
|
743
891
|
children: [
|
|
744
|
-
/* @__PURE__ */
|
|
745
|
-
/* @__PURE__ */
|
|
892
|
+
/* @__PURE__ */ jsx4("style", { children: scopedCss }),
|
|
893
|
+
/* @__PURE__ */ jsx4(
|
|
746
894
|
"div",
|
|
747
895
|
{
|
|
748
896
|
"data-squisq-text-content": "true",
|
|
@@ -778,9 +926,9 @@ function TextBox({
|
|
|
778
926
|
if (!hasFill && !hasBorder) return null;
|
|
779
927
|
const { fill, def } = resolveFill(layerId, style.background, style.backgroundGradient);
|
|
780
928
|
const dash = borderDashArray(style.borderStyle, style.borderWidth);
|
|
781
|
-
return /* @__PURE__ */
|
|
782
|
-
def && /* @__PURE__ */
|
|
783
|
-
/* @__PURE__ */
|
|
929
|
+
return /* @__PURE__ */ jsxs4(Fragment3, { children: [
|
|
930
|
+
def && /* @__PURE__ */ jsx4("defs", { children: def }),
|
|
931
|
+
/* @__PURE__ */ jsx4(
|
|
784
932
|
"rect",
|
|
785
933
|
{
|
|
786
934
|
x: box.x,
|
|
@@ -875,12 +1023,12 @@ function wrapText(text, fontSize, maxWidth) {
|
|
|
875
1023
|
}
|
|
876
1024
|
|
|
877
1025
|
// src/layers/ShapeLayer.tsx
|
|
878
|
-
import { useId as
|
|
879
|
-
import { jsx as
|
|
1026
|
+
import { useId as useId3 } from "react";
|
|
1027
|
+
import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
880
1028
|
var FULL_BLEED_OVERSCAN = 1;
|
|
881
1029
|
function ShapeLayer({ layer, viewport, blockTime }) {
|
|
882
1030
|
const { content, position, animation } = layer;
|
|
883
|
-
const defsId = defsIdFor(
|
|
1031
|
+
const defsId = defsIdFor(useId3(), layer.id);
|
|
884
1032
|
const rawX = resolveValue(position.x, viewport.width);
|
|
885
1033
|
const rawY = resolveValue(position.y, viewport.height);
|
|
886
1034
|
const width = position.width ? resolveValue(position.width, viewport.width) : 100;
|
|
@@ -906,14 +1054,14 @@ function ShapeLayer({ layer, viewport, blockTime }) {
|
|
|
906
1054
|
// Shape layers are visual primitives. In particular, theme top-layers
|
|
907
1055
|
// can cover the whole slide; they must not shield interactive table,
|
|
908
1056
|
// map, or media layers underneath them from pointer/wheel input.
|
|
909
|
-
/* @__PURE__ */
|
|
1057
|
+
/* @__PURE__ */ jsx5(
|
|
910
1058
|
"g",
|
|
911
1059
|
{
|
|
912
1060
|
className: `block-layer block-layer--shape ${animStyle.className}`,
|
|
913
1061
|
style: animStyle.style,
|
|
914
1062
|
"data-layer-id": layer.id,
|
|
915
1063
|
pointerEvents: "none",
|
|
916
|
-
children: /* @__PURE__ */
|
|
1064
|
+
children: /* @__PURE__ */ jsx5("foreignObject", { x: paintX, y: paintY, width: paintWidth, height: paintHeight, children: /* @__PURE__ */ jsx5(
|
|
917
1065
|
"div",
|
|
918
1066
|
{
|
|
919
1067
|
style: {
|
|
@@ -949,7 +1097,7 @@ function ShapeLayer({ layer, viewport, blockTime }) {
|
|
|
949
1097
|
return (
|
|
950
1098
|
// Native SVG shapes follow the same visual-only interaction contract as
|
|
951
1099
|
// the foreignObject gradient branch above.
|
|
952
|
-
/* @__PURE__ */
|
|
1100
|
+
/* @__PURE__ */ jsxs5(
|
|
953
1101
|
"g",
|
|
954
1102
|
{
|
|
955
1103
|
className: `block-layer block-layer--shape ${animStyle.className}`,
|
|
@@ -957,11 +1105,11 @@ function ShapeLayer({ layer, viewport, blockTime }) {
|
|
|
957
1105
|
"data-layer-id": layer.id,
|
|
958
1106
|
pointerEvents: "none",
|
|
959
1107
|
children: [
|
|
960
|
-
(fillDef || filterDef) && /* @__PURE__ */
|
|
1108
|
+
(fillDef || filterDef) && /* @__PURE__ */ jsxs5("defs", { children: [
|
|
961
1109
|
fillDef,
|
|
962
1110
|
filterDef
|
|
963
1111
|
] }),
|
|
964
|
-
content.shape === "rect" && /* @__PURE__ */
|
|
1112
|
+
content.shape === "rect" && /* @__PURE__ */ jsx5(
|
|
965
1113
|
"rect",
|
|
966
1114
|
{
|
|
967
1115
|
x: paintX,
|
|
@@ -973,7 +1121,7 @@ function ShapeLayer({ layer, viewport, blockTime }) {
|
|
|
973
1121
|
...shapeProps
|
|
974
1122
|
}
|
|
975
1123
|
),
|
|
976
|
-
content.shape === "circle" && /* @__PURE__ */
|
|
1124
|
+
content.shape === "circle" && /* @__PURE__ */ jsx5(
|
|
977
1125
|
"circle",
|
|
978
1126
|
{
|
|
979
1127
|
cx: x + width / 2,
|
|
@@ -982,7 +1130,7 @@ function ShapeLayer({ layer, viewport, blockTime }) {
|
|
|
982
1130
|
...shapeProps
|
|
983
1131
|
}
|
|
984
1132
|
),
|
|
985
|
-
content.shape === "line" && /* @__PURE__ */
|
|
1133
|
+
content.shape === "line" && /* @__PURE__ */ jsx5(
|
|
986
1134
|
"line",
|
|
987
1135
|
{
|
|
988
1136
|
x1: x,
|
|
@@ -1001,9 +1149,9 @@ function ShapeLayer({ layer, viewport, blockTime }) {
|
|
|
1001
1149
|
}
|
|
1002
1150
|
|
|
1003
1151
|
// src/layers/PathLayer.tsx
|
|
1004
|
-
import { useId as
|
|
1152
|
+
import { useId as useId4 } from "react";
|
|
1005
1153
|
import { markerPath, shapePath } from "@bendyline/squisq/doc";
|
|
1006
|
-
import { jsx as
|
|
1154
|
+
import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1007
1155
|
function effectivePath(layer, viewport) {
|
|
1008
1156
|
const { content, position } = layer;
|
|
1009
1157
|
if (!content.shapeKind) return content.d;
|
|
@@ -1025,7 +1173,7 @@ function effectiveMarker(explicit, legacyArrow, end) {
|
|
|
1025
1173
|
}
|
|
1026
1174
|
function PathLayer({ layer, viewport, blockTime }) {
|
|
1027
1175
|
const { content, animation, id } = layer;
|
|
1028
|
-
const defsId = defsIdFor(
|
|
1176
|
+
const defsId = defsIdFor(useId4(), id);
|
|
1029
1177
|
const d = effectivePath(layer, viewport);
|
|
1030
1178
|
const stroke = content.stroke ?? "#1e293b";
|
|
1031
1179
|
const strokeWidth = content.strokeWidth ?? 2;
|
|
@@ -1040,19 +1188,19 @@ function PathLayer({ layer, viewport, blockTime }) {
|
|
|
1040
1188
|
const markerStart = start ? `url(#${startId})` : void 0;
|
|
1041
1189
|
const markerEnd = end ? `url(#${endId})` : void 0;
|
|
1042
1190
|
const drawOn = animation?.type === "drawOn";
|
|
1043
|
-
return /* @__PURE__ */
|
|
1191
|
+
return /* @__PURE__ */ jsxs6(
|
|
1044
1192
|
"g",
|
|
1045
1193
|
{
|
|
1046
1194
|
className: `block-layer block-layer--path ${animStyle.className}`,
|
|
1047
1195
|
style: animStyle.style,
|
|
1048
1196
|
"data-layer-id": id,
|
|
1049
1197
|
children: [
|
|
1050
|
-
/* @__PURE__ */
|
|
1198
|
+
/* @__PURE__ */ jsxs6("defs", { children: [
|
|
1051
1199
|
fillDef,
|
|
1052
|
-
end && /* @__PURE__ */
|
|
1053
|
-
start && /* @__PURE__ */
|
|
1200
|
+
end && /* @__PURE__ */ jsx6(MarkerDef, { id: endId, dir: "end", d: end.d, filled: end.filled, stroke }),
|
|
1201
|
+
start && /* @__PURE__ */ jsx6(MarkerDef, { id: startId, dir: "start", d: start.d, filled: start.filled, stroke })
|
|
1054
1202
|
] }),
|
|
1055
|
-
/* @__PURE__ */
|
|
1203
|
+
/* @__PURE__ */ jsx6(
|
|
1056
1204
|
"path",
|
|
1057
1205
|
{
|
|
1058
1206
|
d,
|
|
@@ -1067,7 +1215,7 @@ function PathLayer({ layer, viewport, blockTime }) {
|
|
|
1067
1215
|
markerEnd: drawOn ? void 0 : markerEnd
|
|
1068
1216
|
}
|
|
1069
1217
|
),
|
|
1070
|
-
drawOn && (markerStart || markerEnd) && /* @__PURE__ */
|
|
1218
|
+
drawOn && (markerStart || markerEnd) && /* @__PURE__ */ jsx6(
|
|
1071
1219
|
"path",
|
|
1072
1220
|
{
|
|
1073
1221
|
d,
|
|
@@ -1091,7 +1239,7 @@ function MarkerDef({
|
|
|
1091
1239
|
filled,
|
|
1092
1240
|
stroke
|
|
1093
1241
|
}) {
|
|
1094
|
-
return /* @__PURE__ */
|
|
1242
|
+
return /* @__PURE__ */ jsx6(
|
|
1095
1243
|
"marker",
|
|
1096
1244
|
{
|
|
1097
1245
|
id,
|
|
@@ -1102,7 +1250,7 @@ function MarkerDef({
|
|
|
1102
1250
|
markerHeight: 4,
|
|
1103
1251
|
orient: "auto-start-reverse",
|
|
1104
1252
|
markerUnits: "strokeWidth",
|
|
1105
|
-
children: /* @__PURE__ */
|
|
1253
|
+
children: /* @__PURE__ */ jsx6(
|
|
1106
1254
|
"path",
|
|
1107
1255
|
{
|
|
1108
1256
|
d,
|
|
@@ -1116,7 +1264,7 @@ function MarkerDef({
|
|
|
1116
1264
|
}
|
|
1117
1265
|
|
|
1118
1266
|
// src/layers/MapLayer.tsx
|
|
1119
|
-
import { useId as
|
|
1267
|
+
import { useId as useId5, useState as useState2, useEffect } from "react";
|
|
1120
1268
|
import { ResourcePolicyError as ResourcePolicyError2 } from "@bendyline/squisq/markdown";
|
|
1121
1269
|
|
|
1122
1270
|
// src/utils/mapTileUtils.ts
|
|
@@ -1311,10 +1459,10 @@ function drawAttribution(ctx, text, width, height) {
|
|
|
1311
1459
|
}
|
|
1312
1460
|
|
|
1313
1461
|
// src/layers/MapLayer.tsx
|
|
1314
|
-
import { jsx as
|
|
1462
|
+
import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1315
1463
|
function MapLayer({ layer, basePath, viewport, blockTime }) {
|
|
1316
1464
|
const { content, position, animation } = layer;
|
|
1317
|
-
const clipId = `map-clip-${
|
|
1465
|
+
const clipId = `map-clip-${useId5().replace(/:/g, "")}-${layer.id}`;
|
|
1318
1466
|
const staticSrc = useMediaUrl(content.staticSrc ?? "", basePath);
|
|
1319
1467
|
const [mapImageUrl, setMapImageUrl] = useState2(
|
|
1320
1468
|
() => content.staticSrc ? staticSrc || null : null
|
|
@@ -1381,15 +1529,15 @@ function MapLayer({ layer, basePath, viewport, blockTime }) {
|
|
|
1381
1529
|
]);
|
|
1382
1530
|
const animStyle = getAnimationStyle(animation, blockTime);
|
|
1383
1531
|
if (isLoading) {
|
|
1384
|
-
return /* @__PURE__ */
|
|
1532
|
+
return /* @__PURE__ */ jsxs7(
|
|
1385
1533
|
"g",
|
|
1386
1534
|
{
|
|
1387
1535
|
className: `block-layer block-layer--map ${animStyle.className}`,
|
|
1388
1536
|
style: animStyle.style,
|
|
1389
1537
|
"data-layer-id": layer.id,
|
|
1390
1538
|
children: [
|
|
1391
|
-
/* @__PURE__ */
|
|
1392
|
-
/* @__PURE__ */
|
|
1539
|
+
/* @__PURE__ */ jsx7("rect", { x: finalX, y: finalY, width, height, fill: "#e5e7eb" }),
|
|
1540
|
+
/* @__PURE__ */ jsx7(
|
|
1393
1541
|
"text",
|
|
1394
1542
|
{
|
|
1395
1543
|
x: finalX + width / 2,
|
|
@@ -1407,14 +1555,14 @@ function MapLayer({ layer, basePath, viewport, blockTime }) {
|
|
|
1407
1555
|
);
|
|
1408
1556
|
}
|
|
1409
1557
|
if (error || !mapImageUrl) {
|
|
1410
|
-
return /* @__PURE__ */
|
|
1558
|
+
return /* @__PURE__ */ jsxs7(
|
|
1411
1559
|
"g",
|
|
1412
1560
|
{
|
|
1413
1561
|
className: `block-layer block-layer--map ${animStyle.className}`,
|
|
1414
1562
|
style: animStyle.style,
|
|
1415
1563
|
"data-layer-id": layer.id,
|
|
1416
1564
|
children: [
|
|
1417
|
-
/* @__PURE__ */
|
|
1565
|
+
/* @__PURE__ */ jsx7(
|
|
1418
1566
|
"rect",
|
|
1419
1567
|
{
|
|
1420
1568
|
x: finalX,
|
|
@@ -1424,7 +1572,7 @@ function MapLayer({ layer, basePath, viewport, blockTime }) {
|
|
|
1424
1572
|
fill: blockedByPolicy ? "#f3f4f6" : "#fef2f2"
|
|
1425
1573
|
}
|
|
1426
1574
|
),
|
|
1427
|
-
/* @__PURE__ */
|
|
1575
|
+
/* @__PURE__ */ jsx7(
|
|
1428
1576
|
"text",
|
|
1429
1577
|
{
|
|
1430
1578
|
x: finalX + width / 2,
|
|
@@ -1441,15 +1589,15 @@ function MapLayer({ layer, basePath, viewport, blockTime }) {
|
|
|
1441
1589
|
}
|
|
1442
1590
|
);
|
|
1443
1591
|
}
|
|
1444
|
-
return /* @__PURE__ */
|
|
1592
|
+
return /* @__PURE__ */ jsxs7(
|
|
1445
1593
|
"g",
|
|
1446
1594
|
{
|
|
1447
1595
|
className: `block-layer block-layer--map ${animStyle.className}`,
|
|
1448
1596
|
style: animStyle.style,
|
|
1449
1597
|
"data-layer-id": layer.id,
|
|
1450
1598
|
children: [
|
|
1451
|
-
/* @__PURE__ */
|
|
1452
|
-
/* @__PURE__ */
|
|
1599
|
+
/* @__PURE__ */ jsx7("defs", { children: /* @__PURE__ */ jsx7("clipPath", { id: clipId, children: /* @__PURE__ */ jsx7("rect", { x: finalX, y: finalY, width, height }) }) }),
|
|
1600
|
+
/* @__PURE__ */ jsx7("g", { clipPath: `url(#${clipId})`, children: /* @__PURE__ */ jsx7(
|
|
1453
1601
|
"image",
|
|
1454
1602
|
{
|
|
1455
1603
|
href: mapImageUrl,
|
|
@@ -1467,14 +1615,60 @@ function MapLayer({ layer, basePath, viewport, blockTime }) {
|
|
|
1467
1615
|
}
|
|
1468
1616
|
|
|
1469
1617
|
// src/layers/VideoLayer.tsx
|
|
1470
|
-
import { useContext, useEffect as useEffect2, useMemo as useMemo2, useRef as useRef2 } from "react";
|
|
1618
|
+
import { useContext, useEffect as useEffect2, useMemo as useMemo2, useRef as useRef2, useState as useState4 } from "react";
|
|
1471
1619
|
import {
|
|
1472
1620
|
createMediaTimeMap,
|
|
1473
1621
|
hasRenderableFx,
|
|
1474
1622
|
serializeMediaCrop,
|
|
1475
1623
|
serializeMediaCuts
|
|
1476
1624
|
} from "@bendyline/squisq/mediaEdit";
|
|
1477
|
-
|
|
1625
|
+
|
|
1626
|
+
// src/utils/foreignObjectPlacement.ts
|
|
1627
|
+
import { useLayoutEffect as useLayoutEffect2, useState as useState3 } from "react";
|
|
1628
|
+
function measureSlidePlacement(svg) {
|
|
1629
|
+
const viewBox = svg.viewBox?.baseVal;
|
|
1630
|
+
const width = svg.clientWidth;
|
|
1631
|
+
const height = svg.clientHeight;
|
|
1632
|
+
if (!viewBox || viewBox.width <= 0 || viewBox.height <= 0 || width <= 0 || height <= 0) {
|
|
1633
|
+
return null;
|
|
1634
|
+
}
|
|
1635
|
+
const align = svg.preserveAspectRatio?.baseVal;
|
|
1636
|
+
if (align && (align.align !== align.SVG_PRESERVEASPECTRATIO_XMIDYMID || align.meetOrSlice !== align.SVG_MEETORSLICE_MEET)) {
|
|
1637
|
+
return null;
|
|
1638
|
+
}
|
|
1639
|
+
const scale = Math.min(width / viewBox.width, height / viewBox.height);
|
|
1640
|
+
return {
|
|
1641
|
+
scale,
|
|
1642
|
+
offsetX: (width - viewBox.width * scale) / 2 - viewBox.x * scale,
|
|
1643
|
+
offsetY: (height - viewBox.height * scale) / 2 - viewBox.y * scale
|
|
1644
|
+
};
|
|
1645
|
+
}
|
|
1646
|
+
function useForeignObjectScreenPlacement(ref, enabled) {
|
|
1647
|
+
const [placement, setPlacement] = useState3(null);
|
|
1648
|
+
const active = enabled && paintsForeignObjectLayersUnscaled();
|
|
1649
|
+
useLayoutEffect2(() => {
|
|
1650
|
+
const svg = ref.current?.ownerSVGElement;
|
|
1651
|
+
if (!active || !svg) {
|
|
1652
|
+
setPlacement(null);
|
|
1653
|
+
return;
|
|
1654
|
+
}
|
|
1655
|
+
const measure = () => {
|
|
1656
|
+
const next = measureSlidePlacement(svg);
|
|
1657
|
+
setPlacement(
|
|
1658
|
+
(current) => current && next && current.scale === next.scale && current.offsetX === next.offsetX && current.offsetY === next.offsetY ? current : next
|
|
1659
|
+
);
|
|
1660
|
+
};
|
|
1661
|
+
measure();
|
|
1662
|
+
if (typeof ResizeObserver === "undefined") return;
|
|
1663
|
+
const observer = new ResizeObserver(measure);
|
|
1664
|
+
observer.observe(svg);
|
|
1665
|
+
return () => observer.disconnect();
|
|
1666
|
+
}, [active, ref]);
|
|
1667
|
+
return placement;
|
|
1668
|
+
}
|
|
1669
|
+
|
|
1670
|
+
// src/layers/VideoLayer.tsx
|
|
1671
|
+
import { jsx as jsx8, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1478
1672
|
var VIDEO_SYNC_DRIFT_SECONDS = 0.2;
|
|
1479
1673
|
function VideoLayer({
|
|
1480
1674
|
layer,
|
|
@@ -1483,12 +1677,14 @@ function VideoLayer({
|
|
|
1483
1677
|
blockTime,
|
|
1484
1678
|
isPlaying,
|
|
1485
1679
|
muted = false,
|
|
1486
|
-
mode = "timed"
|
|
1680
|
+
mode = "timed",
|
|
1681
|
+
capture = false
|
|
1487
1682
|
}) {
|
|
1488
1683
|
const { content, position } = layer;
|
|
1489
1684
|
const edits = content.edits;
|
|
1490
1685
|
const videoRef = useRef2(null);
|
|
1491
1686
|
const audioRef = useRef2(null);
|
|
1687
|
+
const foreignObjectRef = useRef2(null);
|
|
1492
1688
|
const hasStartedRef = useRef2(false);
|
|
1493
1689
|
const isPlayer = mode === "player";
|
|
1494
1690
|
const startAt = content.startAt ?? 0;
|
|
@@ -1618,55 +1814,152 @@ function VideoLayer({
|
|
|
1618
1814
|
const heard = companion ? audioRef.current : videoRef.current;
|
|
1619
1815
|
if (heard) applyMediaLevel(heard, level);
|
|
1620
1816
|
}, [hasLevel, level, companion, src, processedUrl]);
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1817
|
+
const screen = useForeignObjectScreenPlacement(foreignObjectRef, !capture);
|
|
1818
|
+
const [viewerStarted, setViewerStarted] = useState4(false);
|
|
1819
|
+
const playing = isPlayer ? viewerStarted : Boolean(isPlaying) && !gated;
|
|
1820
|
+
const idlePoster = !capture && !playing && paintsForeignObjectLayersUnscaled();
|
|
1821
|
+
const startViewing = () => {
|
|
1822
|
+
const video = videoRef.current;
|
|
1823
|
+
if (!video) return;
|
|
1824
|
+
video.style.display = "block";
|
|
1825
|
+
setViewerStarted(true);
|
|
1826
|
+
void video.play()?.catch(() => void 0);
|
|
1827
|
+
};
|
|
1828
|
+
const box = screen ? {
|
|
1829
|
+
x: screen.offsetX + finalX * screen.scale,
|
|
1830
|
+
y: screen.offsetY + finalY * screen.scale,
|
|
1831
|
+
width: width * screen.scale,
|
|
1832
|
+
height: height * screen.scale
|
|
1833
|
+
} : { x: finalX, y: finalY, width, height };
|
|
1834
|
+
const playSize = Math.min(width, height) * 0.16;
|
|
1835
|
+
return /* @__PURE__ */ jsxs8("g", { className: "block-layer block-layer--video", "data-layer-id": layer.id, children: [
|
|
1836
|
+
idlePoster && /* @__PURE__ */ jsxs8("g", { "data-video-poster": "", children: [
|
|
1837
|
+
posterSrc ? (
|
|
1838
|
+
// A still <img> in a foreignObject is not composited, so WebKit
|
|
1839
|
+
// draws it where it belongs; object-fit crops any image format.
|
|
1840
|
+
/* @__PURE__ */ jsx8(
|
|
1841
|
+
"foreignObject",
|
|
1842
|
+
{
|
|
1843
|
+
x: finalX,
|
|
1844
|
+
y: finalY,
|
|
1845
|
+
width,
|
|
1846
|
+
height,
|
|
1847
|
+
style: { pointerEvents: "none" },
|
|
1848
|
+
children: /* @__PURE__ */ jsx8(
|
|
1849
|
+
"img",
|
|
1850
|
+
{
|
|
1851
|
+
src: posterSrc,
|
|
1852
|
+
alt: "",
|
|
1853
|
+
style: {
|
|
1854
|
+
width: `${width}px`,
|
|
1855
|
+
height: `${height}px`,
|
|
1856
|
+
objectFit: content.fit || "cover",
|
|
1857
|
+
objectPosition: "center",
|
|
1858
|
+
display: "block"
|
|
1859
|
+
}
|
|
1860
|
+
}
|
|
1861
|
+
)
|
|
1862
|
+
}
|
|
1863
|
+
)
|
|
1864
|
+
) : /* @__PURE__ */ jsx8("rect", { x: finalX, y: finalY, width, height, fill: "#000" }),
|
|
1865
|
+
isPlayer && /* @__PURE__ */ jsxs8(
|
|
1866
|
+
"g",
|
|
1867
|
+
{
|
|
1868
|
+
role: "button",
|
|
1869
|
+
tabIndex: 0,
|
|
1870
|
+
"aria-label": content.alt ? `Play ${content.alt}` : "Play video",
|
|
1871
|
+
"data-no-swipe": "",
|
|
1872
|
+
style: { cursor: "pointer" },
|
|
1873
|
+
onClick: startViewing,
|
|
1874
|
+
onKeyDown: (event) => {
|
|
1875
|
+
if (event.key !== "Enter" && event.key !== " ") return;
|
|
1876
|
+
event.preventDefault();
|
|
1877
|
+
startViewing();
|
|
1878
|
+
},
|
|
1879
|
+
children: [
|
|
1880
|
+
/* @__PURE__ */ jsx8(
|
|
1881
|
+
"circle",
|
|
1882
|
+
{
|
|
1883
|
+
cx: finalX + width / 2,
|
|
1884
|
+
cy: finalY + height / 2,
|
|
1885
|
+
r: playSize / 2,
|
|
1886
|
+
fill: "rgba(0,0,0,0.55)",
|
|
1887
|
+
stroke: "rgba(255,255,255,0.85)",
|
|
1888
|
+
strokeWidth: Math.max(1, playSize * 0.04)
|
|
1889
|
+
}
|
|
1890
|
+
),
|
|
1891
|
+
/* @__PURE__ */ jsx8(
|
|
1892
|
+
"path",
|
|
1893
|
+
{
|
|
1894
|
+
d: `M ${finalX + width / 2 - playSize * 0.14} ${finalY + height / 2 - playSize * 0.2} L ${finalX + width / 2 + playSize * 0.22} ${finalY + height / 2} L ${finalX + width / 2 - playSize * 0.14} ${finalY + height / 2 + playSize * 0.2} Z`,
|
|
1895
|
+
fill: "#fff"
|
|
1896
|
+
}
|
|
1897
|
+
)
|
|
1898
|
+
]
|
|
1652
1899
|
}
|
|
1653
|
-
|
|
1654
|
-
),
|
|
1655
|
-
|
|
1656
|
-
"
|
|
1900
|
+
)
|
|
1901
|
+
] }),
|
|
1902
|
+
/* @__PURE__ */ jsxs8(
|
|
1903
|
+
"foreignObject",
|
|
1657
1904
|
{
|
|
1658
|
-
ref:
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1905
|
+
ref: foreignObjectRef,
|
|
1906
|
+
x: box.x,
|
|
1907
|
+
y: box.y,
|
|
1908
|
+
width: box.width,
|
|
1909
|
+
height: box.height,
|
|
1910
|
+
"data-screen-placed": screen ? "" : void 0,
|
|
1911
|
+
children: [
|
|
1912
|
+
/* @__PURE__ */ jsx8(
|
|
1913
|
+
"video",
|
|
1914
|
+
{
|
|
1915
|
+
ref: videoRef,
|
|
1916
|
+
src,
|
|
1917
|
+
poster: posterSrc,
|
|
1918
|
+
muted: muted || companion,
|
|
1919
|
+
playsInline: true,
|
|
1920
|
+
"data-crop": edits?.crop ? serializeMediaCrop(edits.crop) : void 0,
|
|
1921
|
+
...isPlayer ? {
|
|
1922
|
+
controls: true,
|
|
1923
|
+
preload: "metadata",
|
|
1924
|
+
"aria-label": content.alt || void 0,
|
|
1925
|
+
// A drag on the seek bar scrubs the clip rather than swiping slides.
|
|
1926
|
+
"data-no-swipe": ""
|
|
1927
|
+
} : {
|
|
1928
|
+
preload: "auto",
|
|
1929
|
+
"data-clip-start": content.clipStart,
|
|
1930
|
+
"data-clip-end": content.clipEnd,
|
|
1931
|
+
"data-start-at": startAt,
|
|
1932
|
+
"data-cuts": cutsKey || void 0
|
|
1933
|
+
},
|
|
1934
|
+
style: {
|
|
1935
|
+
width: `${box.width}px`,
|
|
1936
|
+
height: `${box.height}px`,
|
|
1937
|
+
objectFit: content.fit || "cover",
|
|
1938
|
+
objectPosition: "center",
|
|
1939
|
+
display: idlePoster ? "none" : "block",
|
|
1940
|
+
pointerEvents: isPlayer ? void 0 : "none",
|
|
1941
|
+
...mediaCropStyle(edits?.crop)
|
|
1942
|
+
}
|
|
1943
|
+
}
|
|
1944
|
+
),
|
|
1945
|
+
companion && /* @__PURE__ */ jsx8(
|
|
1946
|
+
"audio",
|
|
1947
|
+
{
|
|
1948
|
+
ref: audioRef,
|
|
1949
|
+
src: processedUrl,
|
|
1950
|
+
preload: "auto",
|
|
1951
|
+
muted,
|
|
1952
|
+
"data-processed-audio": ""
|
|
1953
|
+
}
|
|
1954
|
+
)
|
|
1955
|
+
]
|
|
1663
1956
|
}
|
|
1664
1957
|
)
|
|
1665
|
-
] })
|
|
1958
|
+
] });
|
|
1666
1959
|
}
|
|
1667
1960
|
|
|
1668
1961
|
// src/layers/TableLayer.tsx
|
|
1669
|
-
import { jsx as
|
|
1962
|
+
import { jsx as jsx9, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1670
1963
|
function TableLayer({
|
|
1671
1964
|
block,
|
|
1672
1965
|
layer,
|
|
@@ -1690,12 +1983,13 @@ function TableLayer({
|
|
|
1690
1983
|
const a = align?.[ci];
|
|
1691
1984
|
return a ? { textAlign: a } : void 0;
|
|
1692
1985
|
};
|
|
1986
|
+
const stickyHeader = !paintsForeignObjectLayersUnscaled();
|
|
1693
1987
|
const borderRadius = style.borderRadius ?? 8;
|
|
1694
1988
|
const frame = `1px solid ${style.borderColor}`;
|
|
1695
1989
|
const verticalCellPadding = style.fontSize * 0.6;
|
|
1696
1990
|
const horizontalCellPadding = style.fontSize * 0.75;
|
|
1697
1991
|
const cellWrap = content.wrap ? { whiteSpace: "pre-line", overflowWrap: "break-word", verticalAlign: "top" } : { whiteSpace: "nowrap" };
|
|
1698
|
-
const nativeTable = /* @__PURE__ */
|
|
1992
|
+
const nativeTable = /* @__PURE__ */ jsxs9(
|
|
1699
1993
|
"table",
|
|
1700
1994
|
{
|
|
1701
1995
|
style: {
|
|
@@ -1708,7 +2002,7 @@ function TableLayer({
|
|
|
1708
2002
|
lineHeight: 1.2
|
|
1709
2003
|
},
|
|
1710
2004
|
children: [
|
|
1711
|
-
headers.length > 0 && /* @__PURE__ */
|
|
2005
|
+
headers.length > 0 && /* @__PURE__ */ jsx9("thead", { children: /* @__PURE__ */ jsx9("tr", { children: headers.map((header, ci) => /* @__PURE__ */ jsx9(
|
|
1712
2006
|
"th",
|
|
1713
2007
|
{
|
|
1714
2008
|
style: {
|
|
@@ -1717,9 +2011,7 @@ function TableLayer({
|
|
|
1717
2011
|
fontFamily: style.headerFontFamily ?? style.fontFamily ?? "system-ui, sans-serif",
|
|
1718
2012
|
fontWeight: 600,
|
|
1719
2013
|
padding: `${verticalCellPadding}px ${horizontalCellPadding}px`,
|
|
1720
|
-
position: "sticky",
|
|
1721
|
-
top: 0,
|
|
1722
|
-
zIndex: 1,
|
|
2014
|
+
...stickyHeader ? { position: "sticky", top: 0, zIndex: 1 } : {},
|
|
1723
2015
|
...cellWrap,
|
|
1724
2016
|
borderBottom: `2px solid ${style.borderColor}`,
|
|
1725
2017
|
borderRight: ci < headers.length - 1 ? `1px solid ${style.borderColor}` : void 0,
|
|
@@ -1729,7 +2021,7 @@ function TableLayer({
|
|
|
1729
2021
|
},
|
|
1730
2022
|
ci
|
|
1731
2023
|
)) }) }),
|
|
1732
|
-
rows.length > 0 && /* @__PURE__ */
|
|
2024
|
+
rows.length > 0 && /* @__PURE__ */ jsx9("tbody", { children: rows.map((row, ri) => /* @__PURE__ */ jsx9("tr", { children: row.map((cell, ci) => /* @__PURE__ */ jsx9(
|
|
1733
2025
|
"td",
|
|
1734
2026
|
{
|
|
1735
2027
|
style: {
|
|
@@ -1749,13 +2041,13 @@ function TableLayer({
|
|
|
1749
2041
|
}
|
|
1750
2042
|
);
|
|
1751
2043
|
const ContentRenderer = block ? contentRenderer : void 0;
|
|
1752
|
-
return /* @__PURE__ */
|
|
2044
|
+
return /* @__PURE__ */ jsx9(
|
|
1753
2045
|
"g",
|
|
1754
2046
|
{
|
|
1755
2047
|
className: `block-layer block-layer--table ${animStyle.className}`,
|
|
1756
2048
|
style: animStyle.style,
|
|
1757
2049
|
"data-layer-id": layer.id,
|
|
1758
|
-
children: /* @__PURE__ */
|
|
2050
|
+
children: /* @__PURE__ */ jsx9("foreignObject", { x: finalX, y: finalY, width, height, children: /* @__PURE__ */ jsx9(
|
|
1759
2051
|
"div",
|
|
1760
2052
|
{
|
|
1761
2053
|
...{ xmlns: "http://www.w3.org/1999/xhtml" },
|
|
@@ -1778,7 +2070,7 @@ function TableLayer({
|
|
|
1778
2070
|
borderRadius: `${borderRadius}px`,
|
|
1779
2071
|
background: ContentRenderer || content.wrap ? "transparent" : style.cellBackground
|
|
1780
2072
|
},
|
|
1781
|
-
children: ContentRenderer ? /* @__PURE__ */
|
|
2073
|
+
children: ContentRenderer ? /* @__PURE__ */ jsx9(
|
|
1782
2074
|
ContentRenderer,
|
|
1783
2075
|
{
|
|
1784
2076
|
block,
|
|
@@ -1790,7 +2082,7 @@ function TableLayer({
|
|
|
1790
2082
|
) : content.wrap ? (
|
|
1791
2083
|
// A fitted table is framed at its own height, so the spare room its
|
|
1792
2084
|
// box keeps for the type estimate stays invisible.
|
|
1793
|
-
/* @__PURE__ */
|
|
2085
|
+
/* @__PURE__ */ jsx9("div", { style: { border: frame, borderRadius: `${borderRadius}px`, overflow: "hidden" }, children: nativeTable })
|
|
1794
2086
|
) : nativeTable
|
|
1795
2087
|
}
|
|
1796
2088
|
) })
|
|
@@ -1799,8 +2091,8 @@ function TableLayer({
|
|
|
1799
2091
|
}
|
|
1800
2092
|
|
|
1801
2093
|
// src/layers/TreeLayer.tsx
|
|
1802
|
-
import { useState as
|
|
1803
|
-
import { jsx as
|
|
2094
|
+
import { useState as useState5 } from "react";
|
|
2095
|
+
import { jsx as jsx10, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1804
2096
|
function faClass(token, fallback) {
|
|
1805
2097
|
const name = token && token.trim() ? token.trim() : fallback;
|
|
1806
2098
|
const colon = name.indexOf(":");
|
|
@@ -1819,13 +2111,13 @@ function TreeLayer({ layer, viewport, blockTime }) {
|
|
|
1819
2111
|
const height = position.height ? resolveValue(position.height, viewport.height) : viewport.height;
|
|
1820
2112
|
const offset = getAnchorOffset(position.anchor, width, height);
|
|
1821
2113
|
const animStyle = getAnimationStyle(animation, blockTime);
|
|
1822
|
-
return /* @__PURE__ */
|
|
2114
|
+
return /* @__PURE__ */ jsx10(
|
|
1823
2115
|
"g",
|
|
1824
2116
|
{
|
|
1825
2117
|
className: `block-layer block-layer--tree ${animStyle.className}`,
|
|
1826
2118
|
style: animStyle.style,
|
|
1827
2119
|
"data-layer-id": layer.id,
|
|
1828
|
-
children: /* @__PURE__ */
|
|
2120
|
+
children: /* @__PURE__ */ jsx10("foreignObject", { x: x + offset.x, y: y + offset.y, width, height, children: /* @__PURE__ */ jsx10(
|
|
1829
2121
|
"div",
|
|
1830
2122
|
{
|
|
1831
2123
|
...{ xmlns: "http://www.w3.org/1999/xhtml" },
|
|
@@ -1843,7 +2135,7 @@ function TreeLayer({ layer, viewport, blockTime }) {
|
|
|
1843
2135
|
lineHeight: 1.7,
|
|
1844
2136
|
overflow: "hidden"
|
|
1845
2137
|
},
|
|
1846
|
-
children: /* @__PURE__ */
|
|
2138
|
+
children: /* @__PURE__ */ jsx10(TreeList, { items, depth: 0, style })
|
|
1847
2139
|
}
|
|
1848
2140
|
) })
|
|
1849
2141
|
}
|
|
@@ -1854,7 +2146,7 @@ function TreeList({
|
|
|
1854
2146
|
depth,
|
|
1855
2147
|
style
|
|
1856
2148
|
}) {
|
|
1857
|
-
return /* @__PURE__ */
|
|
2149
|
+
return /* @__PURE__ */ jsx10(
|
|
1858
2150
|
"ul",
|
|
1859
2151
|
{
|
|
1860
2152
|
style: {
|
|
@@ -1864,7 +2156,7 @@ function TreeList({
|
|
|
1864
2156
|
paddingLeft: depth === 0 ? 0 : `${style.indentPx}px`,
|
|
1865
2157
|
borderLeft: depth === 0 ? "none" : `1px solid ${style.connectorColor}`
|
|
1866
2158
|
},
|
|
1867
|
-
children: items.map((item) => /* @__PURE__ */
|
|
2159
|
+
children: items.map((item) => /* @__PURE__ */ jsx10(TreeRow, { item, style }, item.id))
|
|
1868
2160
|
}
|
|
1869
2161
|
);
|
|
1870
2162
|
}
|
|
@@ -1873,12 +2165,12 @@ function TreeRow({
|
|
|
1873
2165
|
style
|
|
1874
2166
|
}) {
|
|
1875
2167
|
const hasChildren = item.children.length > 0;
|
|
1876
|
-
const [collapsed, setCollapsed] =
|
|
2168
|
+
const [collapsed, setCollapsed] = useState5(false);
|
|
1877
2169
|
const isDir = item.isDir || hasChildren;
|
|
1878
2170
|
const iconCls = isDir ? faClass(style.folderIcon, collapsed ? "folder" : "folder-open") : faClass(style.fileIcon, "file");
|
|
1879
|
-
return /* @__PURE__ */
|
|
1880
|
-
/* @__PURE__ */
|
|
1881
|
-
hasChildren ? /* @__PURE__ */
|
|
2171
|
+
return /* @__PURE__ */ jsxs10("li", { style: { position: "relative" }, children: [
|
|
2172
|
+
/* @__PURE__ */ jsxs10("div", { style: { display: "flex", alignItems: "baseline", gap: "8px", padding: "1px 0" }, children: [
|
|
2173
|
+
hasChildren ? /* @__PURE__ */ jsx10(
|
|
1882
2174
|
"button",
|
|
1883
2175
|
{
|
|
1884
2176
|
type: "button",
|
|
@@ -1894,7 +2186,7 @@ function TreeRow({
|
|
|
1894
2186
|
padding: 0,
|
|
1895
2187
|
fontSize: "0.8em"
|
|
1896
2188
|
},
|
|
1897
|
-
children: /* @__PURE__ */
|
|
2189
|
+
children: /* @__PURE__ */ jsx10(
|
|
1898
2190
|
"i",
|
|
1899
2191
|
{
|
|
1900
2192
|
className: `fa-solid ${collapsed ? "fa-chevron-right" : "fa-chevron-down"}`,
|
|
@@ -1902,8 +2194,8 @@ function TreeRow({
|
|
|
1902
2194
|
}
|
|
1903
2195
|
)
|
|
1904
2196
|
}
|
|
1905
|
-
) : /* @__PURE__ */
|
|
1906
|
-
/* @__PURE__ */
|
|
2197
|
+
) : /* @__PURE__ */ jsx10("span", { style: { flex: "0 0 auto", width: "1em" } }),
|
|
2198
|
+
/* @__PURE__ */ jsx10(
|
|
1907
2199
|
"i",
|
|
1908
2200
|
{
|
|
1909
2201
|
className: iconCls,
|
|
@@ -1911,21 +2203,21 @@ function TreeRow({
|
|
|
1911
2203
|
style: { flex: "0 0 auto", color: style.iconColor, width: "1.2em", textAlign: "center" }
|
|
1912
2204
|
}
|
|
1913
2205
|
),
|
|
1914
|
-
/* @__PURE__ */
|
|
2206
|
+
/* @__PURE__ */ jsx10(
|
|
1915
2207
|
"span",
|
|
1916
2208
|
{
|
|
1917
2209
|
style: { color: isDir ? style.dirColor : style.rowColor, fontWeight: isDir ? 600 : 400 },
|
|
1918
2210
|
children: item.label
|
|
1919
2211
|
}
|
|
1920
2212
|
),
|
|
1921
|
-
item.comment ? /* @__PURE__ */
|
|
2213
|
+
item.comment ? /* @__PURE__ */ jsx10("span", { style: { color: style.commentColor, fontSize: "0.85em", fontStyle: "italic" }, children: item.comment }) : null
|
|
1922
2214
|
] }),
|
|
1923
|
-
hasChildren && !collapsed ? /* @__PURE__ */
|
|
2215
|
+
hasChildren && !collapsed ? /* @__PURE__ */ jsx10(TreeList, { items: item.children, depth: 1, style }) : null
|
|
1924
2216
|
] });
|
|
1925
2217
|
}
|
|
1926
2218
|
|
|
1927
2219
|
// src/layers/MermaidLayer.tsx
|
|
1928
|
-
import { jsx as
|
|
2220
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
1929
2221
|
function MermaidLayer({ layer, viewport, blockTime, theme }) {
|
|
1930
2222
|
const { position, content, animation } = layer;
|
|
1931
2223
|
const width = resolveValue(position.width ?? viewport.width, viewport.width);
|
|
@@ -1951,19 +2243,19 @@ function MermaidLayer({ layer, viewport, blockTime, theme }) {
|
|
|
1951
2243
|
color: content.foreground,
|
|
1952
2244
|
overflow: "hidden"
|
|
1953
2245
|
};
|
|
1954
|
-
return /* @__PURE__ */
|
|
2246
|
+
return /* @__PURE__ */ jsx11(
|
|
1955
2247
|
"g",
|
|
1956
2248
|
{
|
|
1957
2249
|
className: `block-layer block-layer--mermaid ${animStyle.className}`,
|
|
1958
2250
|
"data-layer-id": layer.id,
|
|
1959
2251
|
style: animStyle.style,
|
|
1960
|
-
children: /* @__PURE__ */
|
|
2252
|
+
children: /* @__PURE__ */ jsx11("foreignObject", { x, y, width, height, children: /* @__PURE__ */ jsx11(
|
|
1961
2253
|
"div",
|
|
1962
2254
|
{
|
|
1963
2255
|
...{ xmlns: "http://www.w3.org/1999/xhtml" },
|
|
1964
2256
|
className: "squisq-mermaid-layer-frame",
|
|
1965
2257
|
style: panelStyle,
|
|
1966
|
-
children: /* @__PURE__ */
|
|
2258
|
+
children: /* @__PURE__ */ jsx11(
|
|
1967
2259
|
MermaidDiagram,
|
|
1968
2260
|
{
|
|
1969
2261
|
source: content.source,
|
|
@@ -1980,7 +2272,7 @@ function MermaidLayer({ layer, viewport, blockTime, theme }) {
|
|
|
1980
2272
|
// src/layers/SvgLayer.tsx
|
|
1981
2273
|
import { useMemo as useMemo3 } from "react";
|
|
1982
2274
|
import { parseSvgIsland, svgIslandDataUrl } from "@bendyline/squisq/markdown";
|
|
1983
|
-
import { jsx as
|
|
2275
|
+
import { jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1984
2276
|
function SvgLayer({ layer, viewport, blockTime, isStatic = false }) {
|
|
1985
2277
|
const { position, content, animation } = layer;
|
|
1986
2278
|
const width = resolveValue(position.width ?? viewport.width, viewport.width);
|
|
@@ -1998,13 +2290,13 @@ function SvgLayer({ layer, viewport, blockTime, isStatic = false }) {
|
|
|
1998
2290
|
);
|
|
1999
2291
|
const animStyle = getAnimationStyle(animation, blockTime);
|
|
2000
2292
|
const label = content.alt ?? (result.ok ? result.island.title : void 0) ?? "Illustration";
|
|
2001
|
-
return /* @__PURE__ */
|
|
2293
|
+
return /* @__PURE__ */ jsx12(
|
|
2002
2294
|
"g",
|
|
2003
2295
|
{
|
|
2004
2296
|
className: `block-layer block-layer--svg ${animStyle.className}`,
|
|
2005
2297
|
"data-layer-id": layer.id,
|
|
2006
2298
|
style: animStyle.style,
|
|
2007
|
-
children: href ? /* @__PURE__ */
|
|
2299
|
+
children: href ? /* @__PURE__ */ jsx12(
|
|
2008
2300
|
"image",
|
|
2009
2301
|
{
|
|
2010
2302
|
href,
|
|
@@ -2017,8 +2309,8 @@ function SvgLayer({ layer, viewport, blockTime, isStatic = false }) {
|
|
|
2017
2309
|
"aria-label": label,
|
|
2018
2310
|
style: { pointerEvents: "none" }
|
|
2019
2311
|
}
|
|
2020
|
-
) : /* @__PURE__ */
|
|
2021
|
-
/* @__PURE__ */
|
|
2312
|
+
) : /* @__PURE__ */ jsxs11("g", { role: "img", "aria-label": "SVG that could not be rendered", children: [
|
|
2313
|
+
/* @__PURE__ */ jsx12(
|
|
2022
2314
|
"rect",
|
|
2023
2315
|
{
|
|
2024
2316
|
x,
|
|
@@ -2033,7 +2325,7 @@ function SvgLayer({ layer, viewport, blockTime, isStatic = false }) {
|
|
|
2033
2325
|
strokeDasharray: "8 6"
|
|
2034
2326
|
}
|
|
2035
2327
|
),
|
|
2036
|
-
/* @__PURE__ */
|
|
2328
|
+
/* @__PURE__ */ jsx12(
|
|
2037
2329
|
"text",
|
|
2038
2330
|
{
|
|
2039
2331
|
x: x + width / 2,
|