@hyperframes/parsers 0.9.93 → 0.9.94

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.
@@ -65,7 +65,7 @@ declare function resolveExistingLocalAsset(projectDir: string, url: string): {
65
65
  /** The project file a `src` authored in `compositionFile` loads in preview and render; null when none exists. */
66
66
  declare function resolveAuthoredAssetFile(projectDir: string, compositionFile: string, src: string): string | null;
67
67
  /** Resolves a media `src` like a browser URL (`..` clamps at the project root); a miss returns the base-dir join. */
68
- declare function resolveProjectRelativeSrc(src: string, baseDir: string, compiledDir?: string): string;
68
+ declare function resolveProjectRelativeSrc(src: string, relativeOrAbsoluteBase: string, relativeOrAbsoluteCompiled?: string): string;
69
69
  /** Blanks out comments, `<style>`, and `<script>` bodies so tag-scanning
70
70
  * regexes don't false-positive on commented-out or scripted markup. */
71
71
  declare function maskNonScannableRanges(html: string): string;
@@ -269,7 +269,9 @@ function gitBashFile(src) {
269
269
  const path = resolve3(`${src[1]}:${src.slice(2)}`);
270
270
  return existsSync(path) ? path : void 0;
271
271
  }
272
- function resolveProjectRelativeSrc(src, baseDir, compiledDir) {
272
+ function resolveProjectRelativeSrc(src, relativeOrAbsoluteBase, relativeOrAbsoluteCompiled) {
273
+ const baseDir = resolve3(relativeOrAbsoluteBase);
274
+ const compiledDir = relativeOrAbsoluteCompiled && resolve3(relativeOrAbsoluteCompiled);
273
275
  const cleanSrc = fileUrlAsPath(cleanAssetUrl(src));
274
276
  if (isAbsolute2(cleanSrc) && !namesAnotherNetworkRoot(baseDir, cleanSrc) && existsSync(cleanSrc)) {
275
277
  return cleanSrc;
@@ -61,11 +61,14 @@ declare const SELF_CONTAINED_FORMATS = "mov,matroska,mxf,avi,mpeg,mpegts,mpegvid
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. Playlists only with `playlists: true`; anything but an http(s) URL reads as a local file. */
64
+ /** The `-format_whitelist` pair for `input` (no playlists unless `playlists: true`); callers read it by position. */
65
65
  declare function mediaInputFormatArgs(listingBinary: string, input: string, { playlists }?: {
66
66
  playlists?: boolean;
67
67
  }): string[];
68
+ declare function mediaInputArgs(listingBinary: string, input: string, options?: {
69
+ playlists?: boolean;
70
+ }): string[];
68
71
  /** Hears the furthest output time, in seconds, that ffmpeg's `-progress pipe:1` lines on `stream` report. */
69
72
  declare function followFfmpegProgress(stream: Readable, onSeconds: (seconds: number) => void): void;
70
73
 
71
- export { FFMPEG_PATH_ENV, FFPROBE_PATH_ENV, type FfBinaryName, type FindFfBinaryOptions, SELF_CONTAINED_FORMATS, _setDemuxerListingForTests, clearFfBinaryLookupCache, concatListInputArgs, concatListText, executableIn, findFfBinary, findTrustedExecutable, followFfmpegProgress, getSkippedX86Binary, isTrustedDirectory, isTrustedExecutablePath, isX86OnlyMachO, localContainerInputArgs, mediaInputFormatArgs, pathEntries, requireFfBinary, trustedPathDirs };
74
+ export { FFMPEG_PATH_ENV, FFPROBE_PATH_ENV, type FfBinaryName, type FindFfBinaryOptions, SELF_CONTAINED_FORMATS, _setDemuxerListingForTests, clearFfBinaryLookupCache, concatListInputArgs, concatListText, executableIn, findFfBinary, findTrustedExecutable, followFfmpegProgress, getSkippedX86Binary, isTrustedDirectory, isTrustedExecutablePath, isX86OnlyMachO, localContainerInputArgs, mediaInputArgs, mediaInputFormatArgs, pathEntries, requireFfBinary, trustedPathDirs };
@@ -142,11 +142,10 @@ function findTrustedExecutable(name) {
142
142
  // src/literalMediaInput.ts
143
143
  var PATTERN_IMAGE2_EXPANDS = /%\d*[d%*?[\]{}]/;
144
144
  var WILDCARD_MAKES_ANY_PERCENT_A_PATTERN = /[*?[{]/;
145
- var URL_SCHEME = /^[a-z][a-z0-9+.-]+:/i;
145
+ var FORWARDED = /^https?:/i;
146
146
  function refusePattern(path, use) {
147
- const local = !URL_SCHEME.test(path) || /^file:/i.test(path);
148
147
  const pattern = PATTERN_IMAGE2_EXPANDS.test(path) || path.includes("%") && WILDCARD_MAKES_ANY_PERCENT_A_PATTERN.test(path);
149
- if (!local || !pattern) return;
148
+ if (FORWARDED.test(path) || !pattern) return;
150
149
  throw new Error(
151
150
  `[FFmpeg] refused media path "${path.split(/[\\/]/).pop()}": a "%" followed by "d", another "%" or a wildcard, with or without digits between, or a "%" and a wildcard (*, ?, [ or {) anywhere in the path, would make ffmpeg ${use} it as a pattern of other files. Rename the file or folder.`
152
151
  );
@@ -365,7 +364,6 @@ function localContainerInputArgs(container) {
365
364
  var PLAYLIST_DEMUXERS = /* @__PURE__ */ new Set(["hls", "applehttp", "concat"]);
366
365
  function mediaInputFormatArgs(listingBinary, input, { playlists = false } = {}) {
367
366
  assertLiteralMediaInput(input);
368
- const local = /^https?:\/\//i.test(input) ? [] : ["-protocol_whitelist", "file"];
369
367
  const allowed = (formats2) => playlists ? formats2 : formats2.split(",").filter((name) => !PLAYLIST_DEMUXERS.has(name)).join(",");
370
368
  let formats = demuxerLists.get(listingBinary);
371
369
  if (formats === void 0) {
@@ -381,10 +379,14 @@ function mediaInputFormatArgs(listingBinary, input, { playlists = false } = {})
381
379
  } catch {
382
380
  formats = void 0;
383
381
  }
384
- if (formats === void 0) return [...local, "-format_whitelist", SELF_CONTAINED_FORMATS];
382
+ if (formats === void 0) return ["-format_whitelist", SELF_CONTAINED_FORMATS];
385
383
  demuxerLists.set(listingBinary, formats);
386
384
  }
387
- return [...local, "-format_whitelist", allowed(formats)];
385
+ return ["-format_whitelist", allowed(formats)];
386
+ }
387
+ function mediaInputArgs(listingBinary, input, options = {}) {
388
+ const local = /^https?:\/\//i.test(input) ? [] : ["-protocol_whitelist", "file"];
389
+ return [...local, ...mediaInputFormatArgs(listingBinary, input, options)];
388
390
  }
389
391
  var OUT_TIME = /^out_time_(?:us|ms)=(\d+)$/;
390
392
  function followFfmpegProgress(stream, onSeconds) {
@@ -421,6 +423,7 @@ export {
421
423
  isTrustedExecutablePath,
422
424
  isX86OnlyMachO,
423
425
  localContainerInputArgs,
426
+ mediaInputArgs,
424
427
  mediaInputFormatArgs,
425
428
  pathEntries,
426
429
  requireFfBinary,
package/dist/hfIds.d.ts CHANGED
@@ -1,4 +1,7 @@
1
1
  declare const EXCLUDED_TAGS: Set<string>;
2
+ declare const isNonContentElement: (el: {
3
+ tagName: string;
4
+ }) => boolean;
2
5
  declare function mintHfId(el: Element, assigned: Set<string>): string;
3
6
  declare function isCompositionTemplate(el: Element): boolean;
4
7
  /**
@@ -14,4 +17,4 @@ declare function ensureHfIds(html: string): string;
14
17
  * Markup whose tags the parser did not keep one-to-one falls back to ensureHfIds. */
15
18
  declare function stampHfIdsInPlace(html: string): string;
16
19
 
17
- export { EXCLUDED_TAGS, ensureHfIds, isCompositionTemplate, mintHfId, stampHfIdsInPlace, walkCompositionDescendants };
20
+ export { EXCLUDED_TAGS, ensureHfIds, isCompositionTemplate, isNonContentElement, mintHfId, stampHfIdsInPlace, walkCompositionDescendants };
package/dist/hfIds.js CHANGED
@@ -1,5 +1,74 @@
1
- // src/hfIds.ts
2
- import { parseHTML } from "linkedom";
1
+ // src/linkedom.ts
2
+ import {
3
+ DOMParser as LinkedomDOMParser,
4
+ HTMLElement,
5
+ HTMLTextAreaElement,
6
+ HTMLTitleElement,
7
+ parseHTML as linkedomParseHTML
8
+ } from "linkedom";
9
+ var escapeDecodedTitleText = (text) => text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
10
+ var neutraliseTextareaEndTag = (text) => text.replace(/<(\/textarea)/gi, "&lt;$1");
11
+ var writeEmptyElement = HTMLElement.prototype.toString;
12
+ var installed = false;
13
+ function escapeTextOnWrite() {
14
+ if (installed) return;
15
+ installed = true;
16
+ for (const [Element, escape] of [
17
+ [HTMLTitleElement, escapeDecodedTitleText],
18
+ [HTMLTextAreaElement, neutraliseTextareaEndTag]
19
+ ]) {
20
+ Object.defineProperty(Element.prototype, "toString", {
21
+ configurable: true,
22
+ writable: true,
23
+ value() {
24
+ const empty = writeEmptyElement.call(this.cloneNode());
25
+ const close = empty.lastIndexOf("</");
26
+ return empty.slice(0, close) + escape(this.textContent ?? "") + empty.slice(close);
27
+ }
28
+ });
29
+ }
30
+ }
31
+ var READ_AS_TEXT = /* @__PURE__ */ new Set(["title", "style", "script", "textarea", "xmp"]);
32
+ var FOREIGN = /* @__PURE__ */ new Set(["svg", "math"]);
33
+ var BACK_TO_HTML = /* @__PURE__ */ new Set(["foreignobject", "desc"]);
34
+ var TAG_OR_COMMENT = /<[A-Za-z!/?]/;
35
+ var CDATA = /<!\[CDATA\[[\s\S]*?\]\]>/g;
36
+ var HtmlReadUnlikeBrowserError = class extends Error {
37
+ constructor() {
38
+ super(
39
+ "This HTML has tags or comments inside an SVG or MathML title, style, script, textarea or xmp element, which can't be read the way a browser reads them."
40
+ );
41
+ this.name = "HtmlReadUnlikeBrowserError";
42
+ }
43
+ };
44
+ function insideForeign(element) {
45
+ for (let up = element.parentElement; up; up = up.parentElement) {
46
+ const name = up.localName.toLowerCase();
47
+ if (BACK_TO_HTML.has(name)) return false;
48
+ if (FOREIGN.has(name)) return true;
49
+ }
50
+ return false;
51
+ }
52
+ function readAsTextUnlikeBrowser(element) {
53
+ return READ_AS_TEXT.has(element.localName.toLowerCase()) && insideForeign(element) && TAG_OR_COMMENT.test((element.textContent ?? "").replace(CDATA, ""));
54
+ }
55
+ function nextInDocumentOrder(element) {
56
+ if (element.firstElementChild) return element.firstElementChild;
57
+ for (let at = element; at; at = at.parentElement)
58
+ if (at.nextElementSibling) return at.nextElementSibling;
59
+ return null;
60
+ }
61
+ function readsUnlikeBrowser(root) {
62
+ for (let element = root.firstElementChild; element; element = nextInDocumentOrder(element))
63
+ if (readAsTextUnlikeBrowser(element)) return true;
64
+ return false;
65
+ }
66
+ function parseHTML(html, globals) {
67
+ escapeTextOnWrite();
68
+ const parsed = linkedomParseHTML(html, globals);
69
+ if (readsUnlikeBrowser(parsed.document)) throw new HtmlReadUnlikeBrowserError();
70
+ return parsed;
71
+ }
3
72
 
4
73
  // src/subCompositionValidity.ts
5
74
  function isHtmlTemplate(el) {
@@ -19,6 +88,7 @@ var EXCLUDED_TAGS = /* @__PURE__ */ new Set([
19
88
  "noscript",
20
89
  "base"
21
90
  ]);
91
+ var isNonContentElement = (el) => EXCLUDED_TAGS.has(el.tagName.toLowerCase());
22
92
  function fnv1a(str) {
23
93
  let h = 2166136261;
24
94
  for (let i = 0; i < str.length; i++) {
@@ -263,6 +333,7 @@ export {
263
333
  EXCLUDED_TAGS,
264
334
  ensureHfIds,
265
335
  isCompositionTemplate,
336
+ isNonContentElement,
266
337
  mintHfId,
267
338
  stampHfIdsInPlace,
268
339
  walkCompositionDescendants
package/dist/index.d.ts CHANGED
@@ -5,7 +5,7 @@ export { isStudioHoldSet } from './gsapParser.js';
5
5
  export { getObjectArrayKeyframeTiming } from './gsapParserExports.js';
6
6
  export { SPRING_PRESETS, SpringPreset, generateSpringEaseData } from './springEase.js';
7
7
  export { parseGsapScriptAcorn as parseGsapScript } from './gsapParserAcorn.js';
8
- export { EXCLUDED_TAGS, ensureHfIds, isCompositionTemplate, mintHfId, stampHfIdsInPlace, walkCompositionDescendants } from './hfIds.js';
8
+ export { EXCLUDED_TAGS, ensureHfIds, isCompositionTemplate, isNonContentElement, mintHfId, stampHfIdsInPlace, walkCompositionDescendants } from './hfIds.js';
9
9
  export { ParsableDocumentLike, SceneTemplateLike, SubCompositionValidity, SubCompositionValidityReason, checkSubCompositionUsability, findSceneTemplate, firstHtmlTemplate, firstTemplateContent, isHtmlTemplate, resolveSubCompositionContent, templateContent } from './subCompositionValidity.js';
10
10
  export { CANONICAL_AUTHORED_TIMING_ATTRIBUTES, COMPOSITION_ATTRIBUTES, COMPOSITION_CONTRACT_VERSION, ClipAttributeReader, ClipAttributeWriter, ClipTiming, ClipTimingDiagnostic, ClipTimingDiagnosticCode, ClipTimingUpdate, ClipTimingWriteError, DERIVED_TIMING_ATTRIBUTES, LEGACY_TIMING_ATTRIBUTES, ReadClipTimingOptions, ReferenceExpression, SPLIT_BOUNDARY_EPSILON_S, parseNumeric, parseStartExpression, readClipTiming, writeClipTiming } from './compositionContract.js';
11
11
  export { C as CANONICAL_FONT_DISPLAY_NAMES, a as CanvasScaffoldMatch, F as FONT_ALIAS_KEYS, b as FONT_ALIAS_MAP, M as MediaSrcMutation, V as VariableUsageScan, e as extractMediaSrcMutations, m as matchHtmlBodyCssHeightFirst, h as matchHtmlBodyCssWidthFirst, j as matchViewportMetaSize, p as parseCompositionVariables, k as replaceCanvasScaffoldSize, l as resolveAliasDisplayName, s as scanVariableUsage } from './fontAliases-6Aft6tHT.js';
package/dist/index.js CHANGED
@@ -2468,8 +2468,77 @@ function parseCompositionVariables(htmlEl) {
2468
2468
  return readCompositionVariables(htmlEl.getAttribute("data-composition-variables")).declarations;
2469
2469
  }
2470
2470
 
2471
- // src/hfIds.ts
2472
- import { parseHTML } from "linkedom";
2471
+ // src/linkedom.ts
2472
+ import {
2473
+ DOMParser as LinkedomDOMParser,
2474
+ HTMLElement,
2475
+ HTMLTextAreaElement,
2476
+ HTMLTitleElement,
2477
+ parseHTML as linkedomParseHTML
2478
+ } from "linkedom";
2479
+ var escapeDecodedTitleText = (text) => text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
2480
+ var neutraliseTextareaEndTag = (text) => text.replace(/<(\/textarea)/gi, "&lt;$1");
2481
+ var writeEmptyElement = HTMLElement.prototype.toString;
2482
+ var installed = false;
2483
+ function escapeTextOnWrite() {
2484
+ if (installed) return;
2485
+ installed = true;
2486
+ for (const [Element, escape] of [
2487
+ [HTMLTitleElement, escapeDecodedTitleText],
2488
+ [HTMLTextAreaElement, neutraliseTextareaEndTag]
2489
+ ]) {
2490
+ Object.defineProperty(Element.prototype, "toString", {
2491
+ configurable: true,
2492
+ writable: true,
2493
+ value() {
2494
+ const empty = writeEmptyElement.call(this.cloneNode());
2495
+ const close = empty.lastIndexOf("</");
2496
+ return empty.slice(0, close) + escape(this.textContent ?? "") + empty.slice(close);
2497
+ }
2498
+ });
2499
+ }
2500
+ }
2501
+ var READ_AS_TEXT = /* @__PURE__ */ new Set(["title", "style", "script", "textarea", "xmp"]);
2502
+ var FOREIGN = /* @__PURE__ */ new Set(["svg", "math"]);
2503
+ var BACK_TO_HTML = /* @__PURE__ */ new Set(["foreignobject", "desc"]);
2504
+ var TAG_OR_COMMENT = /<[A-Za-z!/?]/;
2505
+ var CDATA = /<!\[CDATA\[[\s\S]*?\]\]>/g;
2506
+ var HtmlReadUnlikeBrowserError = class extends Error {
2507
+ constructor() {
2508
+ super(
2509
+ "This HTML has tags or comments inside an SVG or MathML title, style, script, textarea or xmp element, which can't be read the way a browser reads them."
2510
+ );
2511
+ this.name = "HtmlReadUnlikeBrowserError";
2512
+ }
2513
+ };
2514
+ function insideForeign(element) {
2515
+ for (let up = element.parentElement; up; up = up.parentElement) {
2516
+ const name = up.localName.toLowerCase();
2517
+ if (BACK_TO_HTML.has(name)) return false;
2518
+ if (FOREIGN.has(name)) return true;
2519
+ }
2520
+ return false;
2521
+ }
2522
+ function readAsTextUnlikeBrowser(element) {
2523
+ return READ_AS_TEXT.has(element.localName.toLowerCase()) && insideForeign(element) && TAG_OR_COMMENT.test((element.textContent ?? "").replace(CDATA, ""));
2524
+ }
2525
+ function nextInDocumentOrder(element) {
2526
+ if (element.firstElementChild) return element.firstElementChild;
2527
+ for (let at = element; at; at = at.parentElement)
2528
+ if (at.nextElementSibling) return at.nextElementSibling;
2529
+ return null;
2530
+ }
2531
+ function readsUnlikeBrowser(root) {
2532
+ for (let element = root.firstElementChild; element; element = nextInDocumentOrder(element))
2533
+ if (readAsTextUnlikeBrowser(element)) return true;
2534
+ return false;
2535
+ }
2536
+ function parseHTML(html, globals) {
2537
+ escapeTextOnWrite();
2538
+ const parsed = linkedomParseHTML(html, globals);
2539
+ if (readsUnlikeBrowser(parsed.document)) throw new HtmlReadUnlikeBrowserError();
2540
+ return parsed;
2541
+ }
2473
2542
 
2474
2543
  // src/subCompositionValidity.ts
2475
2544
  function isHtmlTemplate(el) {
@@ -2551,6 +2620,7 @@ var EXCLUDED_TAGS = /* @__PURE__ */ new Set([
2551
2620
  "noscript",
2552
2621
  "base"
2553
2622
  ]);
2623
+ var isNonContentElement = (el) => EXCLUDED_TAGS.has(el.tagName.toLowerCase());
2554
2624
  function fnv1a(str) {
2555
2625
  let h = 2166136261;
2556
2626
  for (let i = 0; i < str.length; i++) {
@@ -4230,9 +4300,6 @@ function trackKindOf(node) {
4230
4300
  return { kind: "graphics", source: "tag" };
4231
4301
  }
4232
4302
 
4233
- // src/timingMismatches.ts
4234
- import { parseHTML as parseHTML2 } from "linkedom";
4235
-
4236
4303
  // src/compositionDuration.ts
4237
4304
  var TIMING_TOLERANCE_SECONDS = 0.05;
4238
4305
  var isPositiveFinite = (value) => value !== null && Number.isFinite(value) && value > 0;
@@ -4346,7 +4413,7 @@ function checkTween(anim, root, layout, seenUntimed, report) {
4346
4413
  }
4347
4414
  function timingMismatches(html) {
4348
4415
  const report = { findings: [], unresolved: [] };
4349
- const { document } = parseHTML2(html);
4416
+ const { document } = parseHTML(html);
4350
4417
  const root = document.querySelector("[data-composition-id]");
4351
4418
  if (!root) return report;
4352
4419
  const layout = rowMembership(root);
@@ -5001,6 +5068,7 @@ export {
5001
5068
  isCompositionTemplate,
5002
5069
  isHtmlTemplate,
5003
5070
  isMediaElement,
5071
+ isNonContentElement,
5004
5072
  isStudioHoldSet,
5005
5073
  isSubCompositionHost,
5006
5074
  isTextElement,
@@ -0,0 +1,11 @@
1
+ declare class HtmlReadUnlikeBrowserError extends Error {
2
+ constructor();
3
+ }
4
+ /** linkedom's `parseHTML`, refusing HTML that a browser would read as a different tree. */
5
+ declare function parseHTML(html: string, globals?: unknown): Window & typeof globalThis;
6
+ /** linkedom's `DOMParser`, with the same refusal for `text/html`. */
7
+ declare const DOMParser: {
8
+ new (): globalThis.DOMParser;
9
+ };
10
+
11
+ export { DOMParser, HtmlReadUnlikeBrowserError, parseHTML };
@@ -0,0 +1,88 @@
1
+ // src/linkedom.ts
2
+ import {
3
+ DOMParser as LinkedomDOMParser,
4
+ HTMLElement,
5
+ HTMLTextAreaElement,
6
+ HTMLTitleElement,
7
+ parseHTML as linkedomParseHTML
8
+ } from "linkedom";
9
+ var escapeDecodedTitleText = (text) => text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
10
+ var neutraliseTextareaEndTag = (text) => text.replace(/<(\/textarea)/gi, "&lt;$1");
11
+ var writeEmptyElement = HTMLElement.prototype.toString;
12
+ var installed = false;
13
+ function escapeTextOnWrite() {
14
+ if (installed) return;
15
+ installed = true;
16
+ for (const [Element, escape] of [
17
+ [HTMLTitleElement, escapeDecodedTitleText],
18
+ [HTMLTextAreaElement, neutraliseTextareaEndTag]
19
+ ]) {
20
+ Object.defineProperty(Element.prototype, "toString", {
21
+ configurable: true,
22
+ writable: true,
23
+ value() {
24
+ const empty = writeEmptyElement.call(this.cloneNode());
25
+ const close = empty.lastIndexOf("</");
26
+ return empty.slice(0, close) + escape(this.textContent ?? "") + empty.slice(close);
27
+ }
28
+ });
29
+ }
30
+ }
31
+ var READ_AS_TEXT = /* @__PURE__ */ new Set(["title", "style", "script", "textarea", "xmp"]);
32
+ var FOREIGN = /* @__PURE__ */ new Set(["svg", "math"]);
33
+ var BACK_TO_HTML = /* @__PURE__ */ new Set(["foreignobject", "desc"]);
34
+ var TAG_OR_COMMENT = /<[A-Za-z!/?]/;
35
+ var CDATA = /<!\[CDATA\[[\s\S]*?\]\]>/g;
36
+ var HtmlReadUnlikeBrowserError = class extends Error {
37
+ constructor() {
38
+ super(
39
+ "This HTML has tags or comments inside an SVG or MathML title, style, script, textarea or xmp element, which can't be read the way a browser reads them."
40
+ );
41
+ this.name = "HtmlReadUnlikeBrowserError";
42
+ }
43
+ };
44
+ function insideForeign(element) {
45
+ for (let up = element.parentElement; up; up = up.parentElement) {
46
+ const name = up.localName.toLowerCase();
47
+ if (BACK_TO_HTML.has(name)) return false;
48
+ if (FOREIGN.has(name)) return true;
49
+ }
50
+ return false;
51
+ }
52
+ function readAsTextUnlikeBrowser(element) {
53
+ return READ_AS_TEXT.has(element.localName.toLowerCase()) && insideForeign(element) && TAG_OR_COMMENT.test((element.textContent ?? "").replace(CDATA, ""));
54
+ }
55
+ function nextInDocumentOrder(element) {
56
+ if (element.firstElementChild) return element.firstElementChild;
57
+ for (let at = element; at; at = at.parentElement)
58
+ if (at.nextElementSibling) return at.nextElementSibling;
59
+ return null;
60
+ }
61
+ function readsUnlikeBrowser(root) {
62
+ for (let element = root.firstElementChild; element; element = nextInDocumentOrder(element))
63
+ if (readAsTextUnlikeBrowser(element)) return true;
64
+ return false;
65
+ }
66
+ function parseHTML(html, globals) {
67
+ escapeTextOnWrite();
68
+ const parsed = linkedomParseHTML(html, globals);
69
+ if (readsUnlikeBrowser(parsed.document)) throw new HtmlReadUnlikeBrowserError();
70
+ return parsed;
71
+ }
72
+ var DOMParser = class extends LinkedomDOMParser {
73
+ constructor() {
74
+ super();
75
+ escapeTextOnWrite();
76
+ }
77
+ parseFromString(markup, mimeType, globals) {
78
+ const parsed = super.parseFromString(markup, mimeType, globals);
79
+ if (mimeType === "text/html" && readsUnlikeBrowser(parsed))
80
+ throw new HtmlReadUnlikeBrowserError();
81
+ return parsed;
82
+ }
83
+ };
84
+ export {
85
+ DOMParser,
86
+ HtmlReadUnlikeBrowserError,
87
+ parseHTML
88
+ };
@@ -1,11 +1,10 @@
1
1
  // src/literalMediaInput.ts
2
2
  var PATTERN_IMAGE2_EXPANDS = /%\d*[d%*?[\]{}]/;
3
3
  var WILDCARD_MAKES_ANY_PERCENT_A_PATTERN = /[*?[{]/;
4
- var URL_SCHEME = /^[a-z][a-z0-9+.-]+:/i;
4
+ var FORWARDED = /^https?:/i;
5
5
  function refusePattern(path, use) {
6
- const local = !URL_SCHEME.test(path) || /^file:/i.test(path);
7
6
  const pattern = PATTERN_IMAGE2_EXPANDS.test(path) || path.includes("%") && WILDCARD_MAKES_ANY_PERCENT_A_PATTERN.test(path);
8
- if (!local || !pattern) return;
7
+ if (FORWARDED.test(path) || !pattern) return;
9
8
  throw new Error(
10
9
  `[FFmpeg] refused media path "${path.split(/[\\/]/).pop()}": a "%" followed by "d", another "%" or a wildcard, with or without digits between, or a "%" and a wildcard (*, ?, [ or {) anywhere in the path, would make ffmpeg ${use} it as a pattern of other files. Rename the file or folder.`
11
10
  );
@@ -4,6 +4,7 @@
4
4
  * `:stream` suffix.
5
5
  */
6
6
  declare function projectPathSegments(relPath: string): string[];
7
+ declare const portablePrivatePattern: string;
7
8
  declare function isVcsOrSecretPath(relPath: string): boolean;
8
9
  /** Credential files and tool or agent state, for a project-relative path in any spelling Windows opens. */
9
10
  declare function isCredentialOrToolStatePath(relPath: string): boolean;
@@ -12,4 +13,4 @@ declare function isStudioPrivatePath(relPath: string): boolean;
12
13
  /** Whether `isPrivate` holds for a file under `projectDir`, spelled as given or with its links resolved. */
13
14
  declare function isPrivateFileUnder(projectDir: string, filePath: string, isPrivate: (relPath: string) => boolean): boolean;
14
15
 
15
- export { isCredentialOrToolStatePath, isPrivateFileUnder, isStudioPrivatePath, isVcsOrSecretPath, projectPathSegments };
16
+ export { isCredentialOrToolStatePath, isPrivateFileUnder, isStudioPrivatePath, isVcsOrSecretPath, portablePrivatePattern, projectPathSegments };
@@ -17,18 +17,9 @@ function withoutTrailingDotsOrSpaces(segment) {
17
17
  while (end > 0 && (segment[end - 1] === "." || segment[end - 1] === " ")) end--;
18
18
  return segment.slice(0, end);
19
19
  }
20
- function isVcsOrSecretPath(relPath) {
21
- return projectPathSegments(relPath).some(
22
- (segment) => segment === ".git" || segment.startsWith(".env")
23
- );
24
- }
25
- var STUDIO_FILES = /* @__PURE__ */ new Set([
26
- ".hyperframes/studio-motion.json",
27
- ".hyperframes/studio-manual-edits.json"
28
- ]);
29
- var STUDIO_FOLDERS = [".hyperframes/prepared-assets", ".hyperframes/requests"];
30
- var UNCONVERTED_PREVIEW_DOWNLOADS = ".hyperframes/prepared-assets/downloads";
31
- var CREDENTIAL_FILES = /* @__PURE__ */ new Set([
20
+ var anyDepth = String.raw`(?:[^/]*/)*`;
21
+ var vcsOrEnv = String.raw`(?:\.git|\.env[^/]*)(?:/.*)?`;
22
+ var credentialNames = [
32
23
  ".npmrc",
33
24
  ".yarnrc",
34
25
  ".yarnrc.yml",
@@ -44,8 +35,8 @@ var CREDENTIAL_FILES = /* @__PURE__ */ new Set([
44
35
  "serviceaccountkey.json",
45
36
  "service-account.json",
46
37
  "service_account.json"
47
- ]);
48
- var CREDENTIAL_FOLDERS = /* @__PURE__ */ new Set([
38
+ ];
39
+ var toolFolders = [
49
40
  ".ssh",
50
41
  ".aws",
51
42
  ".gnupg",
@@ -59,16 +50,25 @@ var CREDENTIAL_FOLDERS = /* @__PURE__ */ new Set([
59
50
  ".gemini",
60
51
  ".vscode",
61
52
  ".idea"
53
+ ];
54
+ var alternatives = (names) => names.map((name) => name.replaceAll(".", "\\.")).join("|");
55
+ var keyOrStore = String.raw`id_(?:rsa|dsa|ecdsa|ed25519)[^/]*|[^/]*\.(?:pem|key|p12|pfx|p8|ppk|jks|keystore|kdbx|tfstate(?:\.backup)?|tfvars(?:\.json)?)`;
56
+ var folders = String.raw`(?:${alternatives(toolFolders)}|\.config/(?:gcloud|gh))(?:/.*)?`;
57
+ var credentials = [alternatives(credentialNames), keyOrStore, folders].join("|");
58
+ var portablePrivatePattern = `${anyDepth}(?:${vcsOrEnv}|${credentials})`;
59
+ var vcsOrSecret = new RegExp(`^${anyDepth}(?:${vcsOrEnv})$`, "su");
60
+ var credentialOrToolState = new RegExp(`^${anyDepth}(?:${credentials})$`, "su");
61
+ function isVcsOrSecretPath(relPath) {
62
+ return vcsOrSecret.test(projectPathSegments(relPath).join("/"));
63
+ }
64
+ var STUDIO_FILES = /* @__PURE__ */ new Set([
65
+ ".hyperframes/studio-motion.json",
66
+ ".hyperframes/studio-manual-edits.json"
62
67
  ]);
63
- var CREDENTIAL_CONFIG_FOLDERS = /* @__PURE__ */ new Set(["gcloud", "gh"]);
64
- var KEY_FILE = /^(?:id_(?:rsa|dsa|ecdsa|ed25519).*|.*\.(?:pem|key|p12|pfx|p8|ppk|jks|keystore|kdbx))$/;
65
- var SECRET_STORE_FILE = /\.(?:tfstate(?:\.backup)?|tfvars(?:\.json)?)$/;
68
+ var STUDIO_FOLDERS = [".hyperframes/prepared-assets", ".hyperframes/requests"];
69
+ var UNCONVERTED_PREVIEW_DOWNLOADS = ".hyperframes/prepared-assets/downloads";
66
70
  function isCredentialOrToolStatePath(relPath) {
67
- const segments = projectPathSegments(relPath);
68
- const name = segments.at(-1) ?? "";
69
- return CREDENTIAL_FILES.has(name) || KEY_FILE.test(name) || SECRET_STORE_FILE.test(name) || segments.some(
70
- (segment, at) => CREDENTIAL_FOLDERS.has(segment) || segment === ".config" && CREDENTIAL_CONFIG_FOLDERS.has(segments[at + 1] ?? "")
71
- );
71
+ return credentialOrToolState.test(projectPathSegments(relPath).join("/"));
72
72
  }
73
73
  function isStudioPrivatePath(relPath) {
74
74
  if (isVcsOrSecretPath(relPath) || isCredentialOrToolStatePath(relPath)) return true;
@@ -118,5 +118,6 @@ export {
118
118
  isPrivateFileUnder,
119
119
  isStudioPrivatePath,
120
120
  isVcsOrSecretPath,
121
+ portablePrivatePattern,
121
122
  projectPathSegments
122
123
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperframes/parsers",
3
- "version": "0.9.93",
3
+ "version": "0.9.94",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/heygen-com/hyperframes",
@@ -44,6 +44,10 @@
44
44
  "import": "./dist/hfIds.js",
45
45
  "types": "./dist/hfIds.d.ts"
46
46
  },
47
+ "./linkedom": {
48
+ "import": "./dist/linkedom.js",
49
+ "types": "./dist/linkedom.d.ts"
50
+ },
47
51
  "./gsap-parser-recast": {
48
52
  "import": "./dist/gsapParser.js",
49
53
  "types": "./dist/gsapParser.d.ts"
@@ -151,7 +155,7 @@
151
155
  "tsx": "^4.21.0",
152
156
  "typescript": "^5.0.0",
153
157
  "vitest": "^4.1.12",
154
- "@hyperframes/core": "0.9.93"
158
+ "@hyperframes/core": "0.9.94"
155
159
  },
156
160
  "scripts": {
157
161
  "build": "tsup",