@hyperframes/core 0.9.94 → 0.9.96

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.
Files changed (61) hide show
  1. package/dist/atomicFile.js +14 -9
  2. package/dist/audibleVideo.d.ts +10 -0
  3. package/dist/audibleVideo.js +37 -0
  4. package/dist/compiler/htmlBundler.js +2 -0
  5. package/dist/compiler/index.d.ts +1 -0
  6. package/dist/compiler/index.js +1 -0
  7. package/dist/compiler/inlineSubCompositions.js +2 -1
  8. package/dist/compositionSource.d.ts +1 -0
  9. package/dist/compositionSource.js +22 -1
  10. package/dist/generated/runtime-inline.js +1 -1
  11. package/dist/hyperframe.runtime.iife.js +67 -67
  12. package/dist/index.d.ts +1 -1
  13. package/dist/runtime/adapters/seek-dispatch.d.ts +40 -0
  14. package/dist/runtime/adapters/seek-dispatch.js +164 -0
  15. package/dist/runtime/assetUrl.d.ts +6 -0
  16. package/dist/runtime/assetUrl.js +8 -0
  17. package/dist/runtime/audioFx.d.ts +77 -0
  18. package/dist/runtime/audioFx.js +277 -0
  19. package/dist/runtime/bridge.d.ts +6 -0
  20. package/dist/runtime/bridge.js +20 -0
  21. package/dist/runtime/decodesFirst.d.ts +4 -0
  22. package/dist/runtime/decodesFirst.js +14 -0
  23. package/dist/runtime/drawnBox.d.ts +29 -0
  24. package/dist/runtime/drawnBox.js +100 -0
  25. package/dist/runtime/editingDraft.d.ts +0 -11
  26. package/dist/runtime/editingDraft.js +1 -61
  27. package/dist/runtime/editingElement.js +3 -3
  28. package/dist/runtime/editingGestureStart.d.ts +2 -6
  29. package/dist/runtime/editingGestureStart.js +1 -40
  30. package/dist/runtime/editingHandles.d.ts +4 -0
  31. package/dist/runtime/editingHandles.js +9 -0
  32. package/dist/runtime/editingPort.d.ts +5 -0
  33. package/dist/runtime/editingPort.js +5 -1
  34. package/dist/runtime/media.d.ts +113 -0
  35. package/dist/runtime/media.js +820 -0
  36. package/dist/runtime/mediaLoadFailure.d.ts +8 -0
  37. package/dist/runtime/mediaLoadFailure.js +58 -0
  38. package/dist/runtime/mediaProxy.d.ts +91 -0
  39. package/dist/runtime/mediaProxy.js +803 -0
  40. package/dist/runtime/playbackHealth.d.ts +31 -0
  41. package/dist/runtime/playbackHealth.js +137 -0
  42. package/dist/runtime/preloadMedia.d.ts +16 -0
  43. package/dist/runtime/preloadMedia.js +266 -0
  44. package/dist/runtime/previewCopies.d.ts +13 -0
  45. package/dist/runtime/previewCopies.js +80 -0
  46. package/dist/runtime/proxyWait.d.ts +3 -0
  47. package/dist/runtime/proxyWait.js +51 -0
  48. package/dist/runtime/runtimeLoad.d.ts +3 -0
  49. package/dist/runtime/runtimeLoad.js +13 -0
  50. package/dist/runtime/state.d.ts +7 -0
  51. package/dist/runtime/state.js +3 -0
  52. package/dist/runtime/timedClipHide.d.ts +12 -0
  53. package/dist/runtime/timedClipHide.js +94 -0
  54. package/dist/runtime/types.d.ts +29 -18
  55. package/dist/runtime/webAudioTransport.d.ts +241 -0
  56. package/dist/runtime/webAudioTransport.js +1162 -0
  57. package/dist/safePath.d.ts +2 -0
  58. package/dist/safePath.js +41 -13
  59. package/dist/studioPreviewMark.js +2 -4
  60. package/dist/utils/inlineTextStyleRead.js +2 -4
  61. package/package.json +16 -4
@@ -57,6 +57,8 @@ export declare function realProjectRoot(root: string): string;
57
57
  * A `dir` outside `root` is created recursively, but only while `root` exists.
58
58
  */
59
59
  export declare function mkdirWithinProject(root: string, dir: string): void;
60
+ /** {@link mkdirWithinProject} on fs/promises: a write the drive never answers holds a pool thread, not the caller's. */
61
+ export declare function mkdirWithinProjectAsync(root: string, dir: string): Promise<void>;
60
62
  /** The real path; for a path not there (yet, or any more), the nearest existing folder's real path plus the rest. */
61
63
  export declare function realFilePath(filePath: string): string;
62
64
  export type EntryKind = "file" | "folder";
package/dist/safePath.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { resolve, sep, join, dirname, basename, relative, isAbsolute, parse } from "node:path";
2
2
  import { lstatSync, mkdirSync, readdirSync, readFileSync, realpath as realpathWalk, realpathSync, statSync, } from "node:fs";
3
- import { realpath as realpathNative } from "node:fs/promises";
3
+ import { mkdir, realpath as realpathNative } from "node:fs/promises";
4
4
  import { promisify } from "node:util";
5
5
  import { isWithinProjectRoot } from "@hyperframes/parsers/asset-resolution";
6
6
  import { projectPathSegments } from "@hyperframes/parsers/private-path";
@@ -276,28 +276,56 @@ export function realProjectRoot(root) {
276
276
  * A `dir` outside `root` is created recursively, but only while `root` exists.
277
277
  */
278
278
  export function mkdirWithinProject(root, dir) {
279
- if (folderGone(root))
280
- throw new ProjectRootMissingError(root);
281
- const inside = relative(resolve(root), resolve(dir));
282
- if (inside === ".." || inside.startsWith(`..${sep}`) || isAbsolute(inside)) {
279
+ const folders = foldersToMake(root, dir);
280
+ if (folders === null) {
283
281
  mkdirSync(dir, { recursive: true });
284
282
  return;
285
283
  }
286
- let path = resolve(root);
287
- for (const part of inside.split(sep).filter(Boolean)) {
288
- path = join(path, part);
284
+ for (const path of folders) {
289
285
  try {
290
286
  mkdirSync(path);
291
287
  }
292
288
  catch (error) {
293
- const code = error.code;
294
- if (code === "ENOENT" && folderGone(root))
295
- throw new ProjectRootMissingError(root);
296
- if (code !== "EEXIST")
297
- throw error;
289
+ madeOrThrow(root, error);
298
290
  }
299
291
  }
300
292
  }
293
+ /** {@link mkdirWithinProject} on fs/promises: a write the drive never answers holds a pool thread, not the caller's. */
294
+ export async function mkdirWithinProjectAsync(root, dir) {
295
+ const folders = foldersToMake(root, dir);
296
+ if (folders === null) {
297
+ await mkdir(dir, { recursive: true });
298
+ return;
299
+ }
300
+ for (const path of folders) {
301
+ try {
302
+ await mkdir(path);
303
+ }
304
+ catch (error) {
305
+ madeOrThrow(root, error);
306
+ }
307
+ }
308
+ }
309
+ /** Each folder from below `root` down to `dir`, or null when `dir` is outside `root`. */
310
+ function foldersToMake(root, dir) {
311
+ if (folderGone(root))
312
+ throw new ProjectRootMissingError(root);
313
+ const inside = relative(resolve(root), resolve(dir));
314
+ if (inside === ".." || inside.startsWith(`..${sep}`) || isAbsolute(inside))
315
+ return null;
316
+ let path = resolve(root);
317
+ return inside
318
+ .split(sep)
319
+ .filter(Boolean)
320
+ .map((part) => (path = join(path, part)));
321
+ }
322
+ function madeOrThrow(root, error) {
323
+ const code = error.code;
324
+ if (code === "ENOENT" && folderGone(root))
325
+ throw new ProjectRootMissingError(root);
326
+ if (code !== "EEXIST")
327
+ throw error;
328
+ }
301
329
  /** The real path; for a path not there (yet, or any more), the nearest existing folder's real path plus the rest. */
302
330
  export function realFilePath(filePath) {
303
331
  try {
@@ -97,10 +97,8 @@ export function serviceWorkerScriptFetch(headers) {
97
97
  return headers.serviceWorker === "script" || headers.fetchDest === "serviceworker";
98
98
  }
99
99
  export function previewElementSourceFile(el) {
100
- const ownerRoot = el.parentElement?.closest("[data-composition-id]");
101
- return (ownerRoot?.getAttribute("data-composition-file") ??
102
- ownerRoot?.getAttribute("data-composition-src") ??
103
- undefined);
100
+ const host = el.parentElement?.closest("[data-composition-file]");
101
+ return host?.getAttribute("data-composition-file") || undefined;
104
102
  }
105
103
  export function previewElementFinder(doc, selector = "[data-hf-id], [id]") {
106
104
  const byKey = new Map();
@@ -47,14 +47,12 @@ export function readInlineStyleSpread(range, property) {
47
47
  // start or end next to a space.
48
48
  if (!char.trim())
49
49
  continue;
50
- if (style[property] === undefined)
51
- continue;
52
- // As painted, where `var()` and `currentColor` mean what they mean for the text.
50
+ // As painted: `var()`, `currentColor` and a stylesheet's colour mean what they mean for the text.
53
51
  const shown = painter?.ownerDocument.defaultView
54
52
  ?.getComputedStyle(painter)
55
53
  .getPropertyValue(property);
56
54
  const value = shown || style[property];
57
- if (seen.has(value))
55
+ if (!value || seen.has(value))
58
56
  continue;
59
57
  seen.add(value);
60
58
  spread.push(value);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperframes/core",
3
- "version": "0.9.94",
3
+ "version": "0.9.96",
4
4
  "description": "",
5
5
  "repository": {
6
6
  "type": "git",
@@ -120,6 +120,10 @@
120
120
  "import": "./dist/utils/richTextSanitize.js",
121
121
  "types": "./dist/utils/richTextSanitize.d.ts"
122
122
  },
123
+ "./drawn-box": {
124
+ "import": "./dist/runtime/drawnBox.js",
125
+ "types": "./dist/runtime/drawnBox.d.ts"
126
+ },
123
127
  "./inline-text-style": {
124
128
  "import": "./dist/utils/inlineTextStyleRead.js",
125
129
  "types": "./dist/utils/inlineTextStyleRead.d.ts"
@@ -365,6 +369,14 @@
365
369
  "import": "./dist/runtime/mediaSteer.js",
366
370
  "types": "./dist/runtime/mediaSteer.d.ts"
367
371
  },
372
+ "./runtime/web-audio-transport": {
373
+ "import": "./dist/runtime/webAudioTransport.js",
374
+ "types": "./dist/runtime/webAudioTransport.d.ts"
375
+ },
376
+ "./runtime/decodes-first": {
377
+ "import": "./dist/runtime/decodesFirst.js",
378
+ "types": "./dist/runtime/decodesFirst.d.ts"
379
+ },
368
380
  "./runtime/clip-reveal": {
369
381
  "import": "./dist/runtime/clipReveal.js",
370
382
  "types": "./dist/runtime/clipReveal.d.ts"
@@ -513,9 +525,9 @@
513
525
  "linkedom": "^0.18.12",
514
526
  "postcss": "^8.5.8",
515
527
  "wawoff2": "^2.0.1",
516
- "@hyperframes/lint": "0.9.94",
517
- "@hyperframes/studio-server": "0.9.94",
518
- "@hyperframes/parsers": "0.9.94"
528
+ "@hyperframes/lint": "0.9.96",
529
+ "@hyperframes/parsers": "0.9.96",
530
+ "@hyperframes/studio-server": "0.9.96"
519
531
  },
520
532
  "devDependencies": {
521
533
  "@fontsource/archivo-black": "^5.2.8",