@hyperframes/studio 0.8.191 → 0.8.193
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/assets/{hyperframes-player-Bv9hQ3v7.js → hyperframes-player-BMcUdmDb.js} +3 -3
- package/dist/assets/{index-CBO8uz7-.css → index-CYbvOVp-.css} +1 -1
- package/dist/assets/{index-D_QqfWhx.js → index-Ca-mgTnS.js} +122 -122
- package/dist/assets/{index-Df14bh-L.js → index-Ci6GuloR.js} +1 -1
- package/dist/{chunk-FF5DM7BQ.js → chunk-7HZGKFFU.js} +18 -4
- package/dist/{chunk-IWO4UENE.js → chunk-ORLUDHTU.js} +4 -2
- package/dist/index.html +2 -2
- package/dist/index.js +53 -26
- package/dist/player.js +2 -2
- package/dist/styles.css +1 -1
- package/dist/ui.d.ts +3 -1
- package/dist/ui.js +1 -1
- package/package.json +9 -8
- package/src/captions/parser.test.ts +71 -1
- package/src/captions/parser.ts +76 -42
- package/src/components/ui/Tooltip.test.tsx +32 -0
- package/src/components/ui/Tooltip.tsx +23 -3
- package/src/player/sceneSwap.test.ts +22 -0
- package/src/player/sceneSwap.ts +3 -1
|
@@ -415,7 +415,12 @@ function MenuSeparator({ className, ...props }) {
|
|
|
415
415
|
|
|
416
416
|
// src/components/ui/Tooltip.tsx
|
|
417
417
|
import { Tooltip as BaseTooltip } from "@base-ui/react/tooltip";
|
|
418
|
-
import {
|
|
418
|
+
import {
|
|
419
|
+
cloneElement,
|
|
420
|
+
useId as useId2,
|
|
421
|
+
useRef as useRef2,
|
|
422
|
+
useState
|
|
423
|
+
} from "react";
|
|
419
424
|
import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
420
425
|
var SIDE_OFFSET2 = 6;
|
|
421
426
|
var VIEWPORT_MARGIN2 = 8;
|
|
@@ -424,7 +429,8 @@ function Tooltip({
|
|
|
424
429
|
children,
|
|
425
430
|
delay = 400,
|
|
426
431
|
side = "top",
|
|
427
|
-
disabled = false
|
|
432
|
+
disabled = false,
|
|
433
|
+
lines
|
|
428
434
|
}) {
|
|
429
435
|
const [open, setOpen] = useState(false);
|
|
430
436
|
const boxRef = useRef2(null);
|
|
@@ -447,10 +453,18 @@ function Tooltip({
|
|
|
447
453
|
id: tooltipId,
|
|
448
454
|
role: "tooltip",
|
|
449
455
|
className: cn(
|
|
450
|
-
"pointer-events-none rounded-md border border-border-input bg-surface px-2 py-1 text-step-10 font-medium text-text-1
|
|
456
|
+
"pointer-events-none rounded-md border border-border-input bg-surface px-2 py-1 text-step-10 font-medium text-text-1 shadow-menu",
|
|
457
|
+
lines ? "max-w-[300px] whitespace-normal break-words" : "whitespace-nowrap",
|
|
451
458
|
floatingMotion("duration-tooltip")
|
|
452
459
|
),
|
|
453
|
-
children:
|
|
460
|
+
children: lines ? /* @__PURE__ */ jsx7(
|
|
461
|
+
"span",
|
|
462
|
+
{
|
|
463
|
+
className: "line-clamp-(--tooltip-lines)",
|
|
464
|
+
style: { "--tooltip-lines": lines },
|
|
465
|
+
children: label
|
|
466
|
+
}
|
|
467
|
+
) : label
|
|
454
468
|
}
|
|
455
469
|
)
|
|
456
470
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
HyperframesLoader
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-7HZGKFFU.js";
|
|
4
4
|
import {
|
|
5
5
|
buildProjectApiPath,
|
|
6
6
|
splitTimelineElementKey,
|
|
@@ -1028,7 +1028,8 @@ function sceneSwapFor(iframe) {
|
|
|
1028
1028
|
() => deadline.abort(new Error("the preview took too long to swap")),
|
|
1029
1029
|
SCENE_SWAP_MS
|
|
1030
1030
|
);
|
|
1031
|
-
|
|
1031
|
+
const onCancel = () => deadline.abort(cancel?.reason);
|
|
1032
|
+
cancel?.addEventListener("abort", onCancel, { once: true });
|
|
1032
1033
|
const swapping = (async () => {
|
|
1033
1034
|
const response = await studioApiFetch(url, { signal: deadline.signal });
|
|
1034
1035
|
if (!response.ok) throw new Error(`preview request failed with ${response.status}`);
|
|
@@ -1043,6 +1044,7 @@ function sceneSwapFor(iframe) {
|
|
|
1043
1044
|
await Promise.race([swapping, expired]);
|
|
1044
1045
|
} finally {
|
|
1045
1046
|
clearTimeout(timer);
|
|
1047
|
+
cancel?.removeEventListener("abort", onCancel);
|
|
1046
1048
|
}
|
|
1047
1049
|
iframe.dispatchEvent(new Event(SCENES_SWAPPED));
|
|
1048
1050
|
};
|
package/dist/index.html
CHANGED
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
document.documentElement.dataset.theme = "paper";
|
|
15
15
|
}
|
|
16
16
|
</script>
|
|
17
|
-
<script type="module" crossorigin src="/assets/index-
|
|
18
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
17
|
+
<script type="module" crossorigin src="/assets/index-Ca-mgTnS.js"></script>
|
|
18
|
+
<link rel="stylesheet" crossorigin href="/assets/index-CYbvOVp-.css">
|
|
19
19
|
</head>
|
|
20
20
|
<body>
|
|
21
21
|
<div data-hf-id="hf-aph5" id="root"></div>
|
package/dist/index.js
CHANGED
|
@@ -48,7 +48,7 @@ import {
|
|
|
48
48
|
usePreviewVariablesStore,
|
|
49
49
|
whenPreviewBooted,
|
|
50
50
|
writeStudioUiPreferences
|
|
51
|
-
} from "./chunk-
|
|
51
|
+
} from "./chunk-ORLUDHTU.js";
|
|
52
52
|
import {
|
|
53
53
|
Button,
|
|
54
54
|
ContextMenu,
|
|
@@ -80,7 +80,7 @@ import {
|
|
|
80
80
|
fieldBase,
|
|
81
81
|
fieldText,
|
|
82
82
|
popupSurface
|
|
83
|
-
} from "./chunk-
|
|
83
|
+
} from "./chunk-7HZGKFFU.js";
|
|
84
84
|
import {
|
|
85
85
|
DOM_EDIT_LAYER_OBSERVER_INIT,
|
|
86
86
|
buildDefaultDomEditTextField,
|
|
@@ -88831,6 +88831,12 @@ function useClipboard({
|
|
|
88831
88831
|
// src/hooks/useCaptionDetection.ts
|
|
88832
88832
|
import { useEffect as useEffect129, useRef as useRef161 } from "react";
|
|
88833
88833
|
|
|
88834
|
+
// src/captions/parser.ts
|
|
88835
|
+
import {
|
|
88836
|
+
parseExpressionAt,
|
|
88837
|
+
tokenizer
|
|
88838
|
+
} from "acorn";
|
|
88839
|
+
|
|
88834
88840
|
// src/captions/types.ts
|
|
88835
88841
|
var DEFAULT_STYLE = {
|
|
88836
88842
|
fontFamily: "sans-serif",
|
|
@@ -88962,14 +88968,18 @@ function readTranscriptGroups(transcript, groupEls) {
|
|
|
88962
88968
|
return offset === transcript.length ? wordGroups : null;
|
|
88963
88969
|
}
|
|
88964
88970
|
function extractTranscript(source) {
|
|
88965
|
-
const varPattern =
|
|
88966
|
-
const match =
|
|
88971
|
+
const varPattern = /\b(?:const|let|var)\s+(?:TRANSCRIPT|script)\s*=\s*(?=\[)/;
|
|
88972
|
+
const match = varPattern.exec(source);
|
|
88967
88973
|
if (!match) {
|
|
88968
88974
|
return [];
|
|
88969
88975
|
}
|
|
88970
|
-
const arrayLiteral = match[1];
|
|
88971
88976
|
try {
|
|
88972
|
-
|
|
88977
|
+
const options = { ecmaVersion: "latest" };
|
|
88978
|
+
const expression = parseExpressionAt(source, match.index + match[0].length, options);
|
|
88979
|
+
if (expression.type !== "ArrayExpression") return [];
|
|
88980
|
+
const nextToken = tokenizer(source.slice(expression.end), options).getToken();
|
|
88981
|
+
if (nextToken.type.label !== ";") return [];
|
|
88982
|
+
return parseTranscriptArray(readStaticValue(expression));
|
|
88973
88983
|
} catch {
|
|
88974
88984
|
return [];
|
|
88975
88985
|
}
|
|
@@ -89053,32 +89063,49 @@ function parseCaptionComposition(iframeDoc, iframeWin, source, compositionWidth,
|
|
|
89053
89063
|
}
|
|
89054
89064
|
return model;
|
|
89055
89065
|
}
|
|
89056
|
-
function
|
|
89057
|
-
|
|
89058
|
-
|
|
89059
|
-
|
|
89060
|
-
|
|
89061
|
-
|
|
89062
|
-
|
|
89063
|
-
|
|
89064
|
-
return
|
|
89065
|
-
|
|
89066
|
-
|
|
89067
|
-
normalized = normalized.replace(/,(\s*[}\]])/g, "$1");
|
|
89068
|
-
parsed = JSON.parse(normalized);
|
|
89066
|
+
function readStaticValue(node) {
|
|
89067
|
+
switch (node?.type) {
|
|
89068
|
+
case "Literal":
|
|
89069
|
+
if ("regex" in node || "bigint" in node) break;
|
|
89070
|
+
return node.value;
|
|
89071
|
+
case "UnaryExpression":
|
|
89072
|
+
return readSignedNumber(node);
|
|
89073
|
+
case "ArrayExpression":
|
|
89074
|
+
return node.elements.map(readStaticValue);
|
|
89075
|
+
case "ObjectExpression":
|
|
89076
|
+
return Object.fromEntries(node.properties.map(readStaticProperty));
|
|
89069
89077
|
}
|
|
89078
|
+
throw new SyntaxError("Transcript values must be static literals");
|
|
89079
|
+
}
|
|
89080
|
+
function readSignedNumber(node) {
|
|
89081
|
+
if (node.operator !== "-" && node.operator !== "+" || node.argument.type !== "Literal" || typeof node.argument.value !== "number") {
|
|
89082
|
+
throw new SyntaxError("Transcript unary expressions must be signed numeric literals");
|
|
89083
|
+
}
|
|
89084
|
+
return node.operator === "-" ? -node.argument.value : node.argument.value;
|
|
89085
|
+
}
|
|
89086
|
+
function readStaticProperty(property) {
|
|
89087
|
+
if (property.type !== "Property" || property.kind !== "init" || property.method || property.shorthand || property.computed) {
|
|
89088
|
+
throw new SyntaxError("Transcript properties must be static data");
|
|
89089
|
+
}
|
|
89090
|
+
const key2 = property.key.type === "Identifier" ? property.key.name : readStaticValue(property.key);
|
|
89091
|
+
if (typeof key2 !== "string" && typeof key2 !== "number") {
|
|
89092
|
+
throw new SyntaxError("Transcript property keys must be names or literals");
|
|
89093
|
+
}
|
|
89094
|
+
return [key2, readStaticValue(property.value)];
|
|
89095
|
+
}
|
|
89096
|
+
function parseTranscriptArray(parsed) {
|
|
89070
89097
|
if (!Array.isArray(parsed)) {
|
|
89071
89098
|
return [];
|
|
89072
89099
|
}
|
|
89073
89100
|
const words = [];
|
|
89074
|
-
|
|
89075
|
-
|
|
89076
|
-
|
|
89101
|
+
const items = parsed;
|
|
89102
|
+
for (const item of items) {
|
|
89103
|
+
if (item !== null && typeof item === "object" && "text" in item && typeof item.text === "string" && "start" in item && typeof item.start === "number" && "end" in item && typeof item.end === "number") {
|
|
89077
89104
|
words.push({
|
|
89078
|
-
...typeof
|
|
89079
|
-
text:
|
|
89080
|
-
start:
|
|
89081
|
-
end:
|
|
89105
|
+
..."id" in item && typeof item.id === "string" ? { id: item.id } : {},
|
|
89106
|
+
text: item.text,
|
|
89107
|
+
start: item.start,
|
|
89108
|
+
end: item.end
|
|
89082
89109
|
});
|
|
89083
89110
|
}
|
|
89084
89111
|
}
|