@hyperframes/parsers 0.9.91 → 0.9.93

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.
@@ -181,10 +181,11 @@ function collectSubCompositionSrcs(html) {
181
181
  function cleanAssetUrl(url) {
182
182
  return url.trim().split(/[?#]/, 1)[0] ?? "";
183
183
  }
184
+ var LEADING_PARENT_SEGMENT = /^\.\.(?:[\\/]|$)/;
184
185
  function isWithinProjectRoot(projectDir, candidate, pathModule = { resolve: resolve3, relative: relative2, isAbsolute: isAbsolute2 }) {
185
186
  const projectRoot = pathModule.resolve(projectDir);
186
187
  const relativePath = pathModule.relative(projectRoot, candidate);
187
- return relativePath === "" || !relativePath.startsWith("..") && !pathModule.isAbsolute(relativePath);
188
+ return !LEADING_PARENT_SEGMENT.test(relativePath) && !pathModule.isAbsolute(relativePath);
188
189
  }
189
190
  function addCandidate(candidates, candidate) {
190
191
  if (!candidates.includes(candidate)) candidates.push(candidate);
@@ -222,17 +223,12 @@ function srcOnAnotherNetworkRoot(projectDir, src) {
222
223
  const path = fileUrlAsPath(cleanAssetUrl(src));
223
224
  return isAbsolute2(path) && namesAnotherNetworkRoot(projectDir, path);
224
225
  }
225
- var LEADING_PARENT_SEGMENT = /^\.\.(?:[\\/]|$)/;
226
- function staysInsideProject(projectDir, path) {
227
- const relativePath = relative2(resolve3(projectDir), path);
228
- return !LEADING_PARENT_SEGMENT.test(relativePath) && !isAbsolute2(relativePath);
229
- }
230
226
  function resolveCompositionSrc(projectDir, src) {
231
227
  const rooted = (value) => resolve3(projectDir, value.replace(/^(?:\.?[\\/])+/, ""));
232
228
  const decoded = rooted(decodedUrlPath(src));
233
- if (!staysInsideProject(projectDir, decoded)) return null;
229
+ if (!isWithinProjectRoot(projectDir, decoded)) return null;
234
230
  const raw = rooted(src);
235
- return !existsSync(decoded) && staysInsideProject(projectDir, raw) && existsSync(raw) ? raw : decoded;
231
+ return !existsSync(decoded) && isWithinProjectRoot(projectDir, raw) && existsSync(raw) ? raw : decoded;
236
232
  }
237
233
  function localAbsoluteAssetFile(projectDir, src) {
238
234
  const path = cleanAssetUrl(src);
@@ -286,7 +282,8 @@ function resolveProjectRelativeSrc(src, baseDir, compiledDir) {
286
282
  if (compiledDir) candidates.add(join2(compiledDir, variant));
287
283
  candidates.add(join2(baseDir, variant));
288
284
  }
289
- return [...candidates].find(existsSync) ?? gitBashFile(cleanSrc) ?? join2(baseDir, cleanSrc);
285
+ const inside = (path) => isWithinProjectRoot(baseDir, path) || compiledDir !== void 0 && isWithinProjectRoot(compiledDir, path);
286
+ return [...candidates].filter(inside).find(existsSync) ?? gitBashFile(cleanSrc) ?? join2(baseDir, cleanSrc);
290
287
  }
291
288
  function maskRange(src, pattern) {
292
289
  return src.replace(pattern, (m) => " ".repeat(m.length));
@@ -56,13 +56,15 @@ declare function concatListText(entries: readonly (string | {
56
56
  */
57
57
  declare function concatListInputArgs(concatListPath: string): string[];
58
58
  /** What a render service lets a media input open: containers that name no other file. */
59
- declare const SELF_CONTAINED_FORMATS = "mov,matroska,mxf,avi,mpeg,mpegts,mpegvideo,flv,asf,ogg,wav,mp3,aac,flac,aiff,gif,image2,png_pipe,jpeg_pipe,webp_pipe,bmp_pipe,tiff_pipe";
59
+ declare const SELF_CONTAINED_FORMATS = "mov,matroska,mxf,avi,mpeg,mpegts,mpegvideo,flv,asf,ogg,wav,mp3,aac,flac,aiff,caf,w64,wv,au,ac3,gif,image2,png_pipe,jpeg_pipe,webp_pipe,bmp_pipe,tiff_pipe";
60
60
  /** Tests feed a `-demuxers` listing so none spawns a binary; no argument forgets it. */
61
61
  declare function _setDemuxerListingForTests(listing?: string): void;
62
62
  declare function localContainerInputArgs(container: "mov" | "matroska" | undefined): string[];
63
63
 
64
- /** Every demuxer `listingBinary` reports that opens nothing by itself and is not text art, for reading `input`; one that cannot be asked gets the self-contained list, and is asked again. */
65
- declare function mediaInputFormatArgs(listingBinary: string, input: string): string[];
64
+ /** Every demuxer `listingBinary` reports that opens nothing by itself and is not text art, for reading `input`; one that cannot be asked gets the self-contained list, and is asked again. Playlists only with `playlists: true`; anything but an http(s) URL reads as a local file. */
65
+ declare function mediaInputFormatArgs(listingBinary: string, input: string, { playlists }?: {
66
+ playlists?: boolean;
67
+ }): string[];
66
68
  /** Hears the furthest output time, in seconds, that ffmpeg's `-progress pipe:1` lines on `stream` report. */
67
69
  declare function followFfmpegProgress(stream: Readable, onSeconds: (seconds: number) => void): void;
68
70
 
@@ -324,7 +324,7 @@ function concatListInputArgs(concatListPath) {
324
324
  concatListPath
325
325
  ];
326
326
  }
327
- var SELF_CONTAINED_FORMATS = "mov,matroska,mxf,avi,mpeg,mpegts,mpegvideo,flv,asf,ogg,wav,mp3,aac,flac,aiff,gif,image2,png_pipe,jpeg_pipe,webp_pipe,bmp_pipe,tiff_pipe";
327
+ var SELF_CONTAINED_FORMATS = "mov,matroska,mxf,avi,mpeg,mpegts,mpegvideo,flv,asf,ogg,wav,mp3,aac,flac,aiff,caf,w64,wv,au,ac3,gif,image2,png_pipe,jpeg_pipe,webp_pipe,bmp_pipe,tiff_pipe";
328
328
  var PATH_OPENING_DEMUXERS = /* @__PURE__ */ new Set([
329
329
  "dash",
330
330
  "imf",
@@ -362,8 +362,11 @@ function _setDemuxerListingForTests(listing) {
362
362
  function localContainerInputArgs(container) {
363
363
  return container ? ["-protocol_whitelist", "file", "-format_whitelist", container] : [];
364
364
  }
365
- function mediaInputFormatArgs(listingBinary, input) {
365
+ var PLAYLIST_DEMUXERS = /* @__PURE__ */ new Set(["hls", "applehttp", "concat"]);
366
+ function mediaInputFormatArgs(listingBinary, input, { playlists = false } = {}) {
366
367
  assertLiteralMediaInput(input);
368
+ const local = /^https?:\/\//i.test(input) ? [] : ["-protocol_whitelist", "file"];
369
+ const allowed = (formats2) => playlists ? formats2 : formats2.split(",").filter((name) => !PLAYLIST_DEMUXERS.has(name)).join(",");
367
370
  let formats = demuxerLists.get(listingBinary);
368
371
  if (formats === void 0) {
369
372
  try {
@@ -378,10 +381,10 @@ function mediaInputFormatArgs(listingBinary, input) {
378
381
  } catch {
379
382
  formats = void 0;
380
383
  }
381
- if (formats === void 0) return ["-format_whitelist", SELF_CONTAINED_FORMATS];
384
+ if (formats === void 0) return [...local, "-format_whitelist", SELF_CONTAINED_FORMATS];
382
385
  demuxerLists.set(listingBinary, formats);
383
386
  }
384
- return ["-format_whitelist", formats];
387
+ return [...local, "-format_whitelist", allowed(formats)];
385
388
  }
386
389
  var OUT_TIME = /^out_time_(?:us|ms)=(\d+)$/;
387
390
  function followFfmpegProgress(stream, onSeconds) {
@@ -76,8 +76,9 @@ function isStudioPrivatePath(relPath) {
76
76
  const inside = !isAbsolute(relPath) && !/^\.\.[. ]*$/.test(relPath.split(/[\\/]/, 1)[0] ?? "");
77
77
  const name = segments.at(-1) ?? "";
78
78
  const loadedType = !name.startsWith(".") && LOADED_ASSET_TYPE.test(name);
79
+ const firstNamed = segments.findIndex((segment) => segment !== "");
79
80
  return segments.some((segment, at) => {
80
- const atRoot = segments.slice(0, at).every((before) => before === "");
81
+ const atRoot = firstNamed === -1 || at <= firstNamed;
81
82
  if (segment === ".hyperframes")
82
83
  return !atRoot || !isStudioOwnFile(segments.slice(at).join("/"));
83
84
  if (BUILD_OUTPUT_FOLDERS.has(segment)) return inside;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperframes/parsers",
3
- "version": "0.9.91",
3
+ "version": "0.9.93",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/heygen-com/hyperframes",
@@ -151,7 +151,7 @@
151
151
  "tsx": "^4.21.0",
152
152
  "typescript": "^5.0.0",
153
153
  "vitest": "^4.1.12",
154
- "@hyperframes/core": "0.9.91"
154
+ "@hyperframes/core": "0.9.93"
155
155
  },
156
156
  "scripts": {
157
157
  "build": "tsup",