@hyperframes/core 0.9.101 → 0.9.102

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.
@@ -2,6 +2,7 @@
2
2
  // decodes. An ask names a path on the frame's own server and the proxy options it played, never a URL: Studio
3
3
  // resolves it against its own project before reading anything.
4
4
  import { sourceFactsOfSrc } from "../mediaSourceLookup.js";
5
+ import { isMessageList } from "../protocol.js";
5
6
  /** The query options the runtime's media proxy adds to a src; any other key never leaves the frame. */
6
7
  export const PAUSED_FRAME_PARAMS = [
7
8
  "hf-proxy",
@@ -49,7 +50,7 @@ export function parsePausedFrameAsk(data) {
49
50
  return null;
50
51
  if (data.type === "abort" || data.type === "suspend")
51
52
  return { type: data.type, id: data.id };
52
- if (data.type !== "decode" || !Array.isArray(data.asks))
53
+ if (data.type !== "decode" || !isMessageList(data.asks, PAUSED_FRAME_SOURCES))
53
54
  return null;
54
55
  const asks = data.asks.map(parseAsk);
55
56
  return asks.every((ask) => ask !== null)
@@ -124,6 +125,8 @@ export function portPausedVideoProvider(port) {
124
125
  const provider = {
125
126
  async decode(requests, signal) {
126
127
  signal.throwIfAborted();
128
+ if (requests.length > PAUSED_FRAME_SOURCES)
129
+ throw new Error("Preview decode over budget");
127
130
  const asks = requests.map(pausedFrameAsk);
128
131
  if (asks.some((a) => a === null))
129
132
  throw new Error("Preview source is not on the preview server");
@@ -178,12 +178,19 @@ export function createPausedVideoFrames() {
178
178
  refresh(entry);
179
179
  }
180
180
  });
181
- observer.observe(document.body, {
182
- childList: true,
183
- subtree: true,
184
- attributes: true,
185
- attributeFilter: ["src", "style", "class", "hidden", "data-hidden"],
186
- });
181
+ const mountStyle = () => {
182
+ if (!style.isConnected)
183
+ (document.head ?? document.documentElement)?.append(style);
184
+ };
185
+ const observeRoot = document.body ?? document.documentElement;
186
+ if (observeRoot) {
187
+ observer.observe(observeRoot, {
188
+ childList: true,
189
+ subtree: true,
190
+ attributes: true,
191
+ attributeFilter: ["src", "style", "class", "hidden", "data-hidden"],
192
+ });
193
+ }
187
194
  const clear = (keep, current) => {
188
195
  for (const entry of [...presented.values()]) {
189
196
  if (!keep?.has(entry.video)) {
@@ -242,8 +249,7 @@ export function createPausedVideoFrames() {
242
249
  markFrameCanvas(canvas);
243
250
  presented.set(video, entry);
244
251
  video.setAttribute(PREVIEW_VIDEO_SOURCE_ATTR, "");
245
- if (!style.isConnected)
246
- document.head.append(style);
252
+ mountStyle();
247
253
  refresh(entry);
248
254
  }
249
255
  return () => {
@@ -345,8 +351,7 @@ export function createPausedVideoFrames() {
345
351
  for (const entry of [...presented.values()])
346
352
  if (!wanted.has(entry.video))
347
353
  remove(entry);
348
- if (!style.isConnected)
349
- document.head.append(style);
354
+ mountStyle();
350
355
  for (const [index, next] of staged.entries()) {
351
356
  adoptStagedFrame(next, reusable.get(next));
352
357
  const { timestamp, width, height } = frames[index];
@@ -295,7 +295,8 @@ export function collectRuntimeTimelinePayload(params) {
295
295
  const mediaWindowEnd = resolveMediaWindowEndSeconds();
296
296
  const mediaWindowDuration = mediaWindowEnd != null ? Math.max(0, mediaWindowEnd - Math.max(0, rootCompositionStart)) : null;
297
297
  const rootDurationFromTimeline = resolveTimelineDurationSeconds(rootCompositionId);
298
- const rootDurationFromAttr = parseElementDurationAttr(root ?? document.body);
298
+ const rootDurationNode = root ?? document.body ?? document.documentElement;
299
+ const rootDurationFromAttr = rootDurationNode ? parseElementDurationAttr(rootDurationNode) : null;
299
300
  const compositionWindowEnd = maxDefinedNumber(...compositionNodes
300
301
  .filter((node) => node !== root)
301
302
  .map((node) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperframes/core",
3
- "version": "0.9.101",
3
+ "version": "0.9.102",
4
4
  "description": "",
5
5
  "repository": {
6
6
  "type": "git",
@@ -525,9 +525,9 @@
525
525
  "linkedom": "^0.18.12",
526
526
  "postcss": "^8.5.8",
527
527
  "wawoff2": "^2.0.1",
528
- "@hyperframes/lint": "0.9.101",
529
- "@hyperframes/parsers": "0.9.101",
530
- "@hyperframes/studio-server": "0.9.101"
528
+ "@hyperframes/lint": "0.9.102",
529
+ "@hyperframes/studio-server": "0.9.102",
530
+ "@hyperframes/parsers": "0.9.102"
531
531
  },
532
532
  "devDependencies": {
533
533
  "@fontsource/archivo-black": "^5.2.8",