@hyperframes/parsers 0.9.58 → 0.9.61
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/assetResolution.d.ts +5 -1
- package/dist/assetResolution.js +7 -0
- package/dist/assets.d.ts +2 -66
- package/dist/ffBinaries.d.ts +9 -9
- package/dist/ffBinaries.js +35 -2
- package/dist/literalMediaInput.d.ts +4 -0
- package/dist/literalMediaInput.js +13 -0
- package/dist/privatePath.d.ts +15 -0
- package/dist/privatePath.js +104 -0
- package/dist/rewriteSubCompPaths-DrZlWrIk.d.ts +66 -0
- package/package.json +10 -2
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { A as AssetExists } from './rewriteSubCompPaths-DrZlWrIk.js';
|
|
2
|
+
|
|
1
3
|
/** The subset of `node:path` that `isWithinProjectRoot` needs to run under
|
|
2
4
|
* an injected platform (tests pass `path.win32` / `path.posix`). */
|
|
3
5
|
interface PathModuleLike {
|
|
@@ -50,6 +52,8 @@ declare function cleanAssetUrl(url: string): string;
|
|
|
50
52
|
declare function isWithinProjectRoot(projectDir: string, candidate: string, pathModule?: PathModuleLike): boolean;
|
|
51
53
|
declare function resolveLocalAssetCandidates(projectDir: string, url: string): string[];
|
|
52
54
|
declare function namesAnotherNetworkRoot(base: string, target: string): boolean;
|
|
55
|
+
/** `AssetExists` for a project on disk; a path outside it (a share, another drive) is missing, never looked at. */
|
|
56
|
+
declare function projectAssetExists(projectDir: string): AssetExists;
|
|
53
57
|
declare function srcOnAnotherNetworkRoot(projectDir: string, src: string): boolean;
|
|
54
58
|
/** The project file a data-composition-src names, as the preview reads it; null when it leaves the project. */
|
|
55
59
|
declare function resolveCompositionSrc(projectDir: string, src: string): string | null;
|
|
@@ -78,4 +82,4 @@ declare const readTextFile: (path: string) => string;
|
|
|
78
82
|
/** Reads through one descriptor, so the file-type check and the read see the same file. */
|
|
79
83
|
declare function readProjectFile(path: string): ProjectFileRead;
|
|
80
84
|
|
|
81
|
-
export { type ProjectFileRead, cleanAssetUrl, collectSubCompositionSrcs, decodeTextHonoringBom, hasUnresolvedTemplatingToken, isRemoteOrInlineUrl, isUnresolvedAssetPlaceholder, isWithinProjectRoot, localAbsoluteAssetFile, maskNonScannableRanges, namesAnotherNetworkRoot, readProjectFile, readTextFile, resolveAuthoredAssetFile, resolveCompositionSrc, resolveExistingLocalAsset, resolveLocalAssetCandidates, resolveProjectRelativeSrc, srcOnAnotherNetworkRoot };
|
|
85
|
+
export { type ProjectFileRead, cleanAssetUrl, collectSubCompositionSrcs, decodeTextHonoringBom, hasUnresolvedTemplatingToken, isRemoteOrInlineUrl, isUnresolvedAssetPlaceholder, isWithinProjectRoot, localAbsoluteAssetFile, maskNonScannableRanges, namesAnotherNetworkRoot, projectAssetExists, readProjectFile, readTextFile, resolveAuthoredAssetFile, resolveCompositionSrc, resolveExistingLocalAsset, resolveLocalAssetCandidates, resolveProjectRelativeSrc, srcOnAnotherNetworkRoot };
|
package/dist/assetResolution.js
CHANGED
|
@@ -210,6 +210,12 @@ function namesAnotherNetworkRoot(base, target) {
|
|
|
210
210
|
const root = parse(resolve3(target)).root;
|
|
211
211
|
return /^[\\/]{2}/.test(root) && root.toLowerCase() !== parse(resolve3(base)).root.toLowerCase();
|
|
212
212
|
}
|
|
213
|
+
function projectAssetExists(projectDir) {
|
|
214
|
+
return (path) => {
|
|
215
|
+
const file = resolve3(projectDir, path);
|
|
216
|
+
return isWithinProjectRoot(projectDir, file) && existsSync(file);
|
|
217
|
+
};
|
|
218
|
+
}
|
|
213
219
|
function srcOnAnotherNetworkRoot(projectDir, src) {
|
|
214
220
|
const path = fileUrlAsPath(cleanAssetUrl(src));
|
|
215
221
|
return isAbsolute2(path) && namesAnotherNetworkRoot(projectDir, path);
|
|
@@ -338,6 +344,7 @@ export {
|
|
|
338
344
|
localAbsoluteAssetFile,
|
|
339
345
|
maskNonScannableRanges,
|
|
340
346
|
namesAnotherNetworkRoot,
|
|
347
|
+
projectAssetExists,
|
|
341
348
|
readProjectFile,
|
|
342
349
|
readTextFile,
|
|
343
350
|
resolveAuthoredAssetFile,
|
package/dist/assets.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { A as AssetExists, r as rewriteAssetPath, a as rewriteAssetPaths, b as rewriteCssAssetUrls, c as rewriteInlineStyleAssetUrls } from './rewriteSubCompPaths-DrZlWrIk.js';
|
|
1
2
|
export { a as decodeCssEscapes, b as decodeWellFormedEscapes, c as decodedUrlPath, e as encodeUrlPath, s as splitUrlSuffix } from './urlPath-CYK47t9W.js';
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -20,71 +21,6 @@ declare const PATH_ATTRS: readonly ["src", "href"];
|
|
|
20
21
|
declare function isNonRelativeUrl(val: string): boolean;
|
|
21
22
|
declare function isPathInside(childPath: string, parentPath: string): boolean;
|
|
22
23
|
|
|
23
|
-
/**
|
|
24
|
-
* Rewrite relative asset paths in sub-composition content so they resolve
|
|
25
|
-
* correctly after the content is inlined into the root document.
|
|
26
|
-
*
|
|
27
|
-
* A sub-composition at "compositions/scene.html" referencing "../icon.svg"
|
|
28
|
-
* means the project root — but after inlining into root index.html, the
|
|
29
|
-
* "../" escapes the project directory and causes 404s. This function
|
|
30
|
-
* resolves each relative path against the sub-composition's directory,
|
|
31
|
-
* then normalizes it to be relative to the project root.
|
|
32
|
-
*
|
|
33
|
-
* Used by both the core bundler (preview) and the producer compiler (render)
|
|
34
|
-
* to ensure consistent behavior.
|
|
35
|
-
*/
|
|
36
|
-
/**
|
|
37
|
-
* Probe for "does this project-root-relative path exist?", supplied by callers
|
|
38
|
-
* that can see the filesystem (the studio preview builder, the bundler, the
|
|
39
|
-
* producer). Keeps this module free of `node:fs` so it stays browser-safe.
|
|
40
|
-
*
|
|
41
|
-
* It disambiguates the two conventions for a plain relative path authored in a
|
|
42
|
-
* sub-composition that lives in a subdirectory:
|
|
43
|
-
*
|
|
44
|
-
* 1. A SIBLING file — `<link href="_shared.css">` next to the composition.
|
|
45
|
-
* This is what a browser resolves when the file is opened directly, and
|
|
46
|
-
* what an author means. Once the content moves into the project-root
|
|
47
|
-
* document it must become `design/styleframes/_shared.css` or it 404s.
|
|
48
|
-
* 2. A PROJECT-ROOT asset — registry blocks are installed into a
|
|
49
|
-
* subdirectory but reference `assets/logo.png` at the root. Already
|
|
50
|
-
* correct in the root document; rewriting would break it.
|
|
51
|
-
*
|
|
52
|
-
* A sibling that exists on disk means (1); anything else is left as authored.
|
|
53
|
-
* Without a probe the behavior is unchanged — plain relative paths pass through.
|
|
54
|
-
*/
|
|
55
|
-
type AssetExists = (projectRelativePath: string) => boolean;
|
|
56
|
-
/**
|
|
57
|
-
* Rewrite a single relative path from a sub-composition's context to the
|
|
58
|
-
* project root context.
|
|
59
|
-
*
|
|
60
|
-
* @param compSrcPath - The `data-composition-src` value (e.g. "compositions/scene.html")
|
|
61
|
-
* @param relativePath - The asset path to rewrite (e.g. "../icon.svg")
|
|
62
|
-
* @param assetExists - Optional filesystem probe; see `AssetExists`.
|
|
63
|
-
* @returns The rewritten path relative to project root (e.g. "icon.svg"), or
|
|
64
|
-
* the original path if no rewriting is needed.
|
|
65
|
-
*/
|
|
66
|
-
declare function rewriteAssetPath(compSrcPath: string, relativePath: string, assetExists?: AssetExists): string;
|
|
67
|
-
/**
|
|
68
|
-
* Rewrite all relative `src` and `href` attributes on elements within a
|
|
69
|
-
* DOM tree, adjusting paths from the sub-composition's directory context
|
|
70
|
-
* to the project root.
|
|
71
|
-
*
|
|
72
|
-
* @param elements - Iterable of DOM elements to scan (e.g. from querySelectorAll)
|
|
73
|
-
* @param compSrcPath - The `data-composition-src` value
|
|
74
|
-
* @param getAttr - Function to read an attribute from an element
|
|
75
|
-
* @param setAttr - Function to set an attribute on an element
|
|
76
|
-
*/
|
|
77
|
-
declare function rewriteAssetPaths<T>(elements: Iterable<T>, compSrcPath: string, getAttr: (el: T, attr: string) => string | null | undefined, setAttr: (el: T, attr: string, value: string) => void, assetExists?: AssetExists): void;
|
|
78
|
-
/**
|
|
79
|
-
* Rewrite CSS url(...) references inside inline style attributes.
|
|
80
|
-
*/
|
|
81
|
-
declare function rewriteInlineStyleAssetUrls<T>(elements: Iterable<T>, compSrcPath: string, getStyle: (el: T) => string | null | undefined, setStyle: (el: T, value: string) => void, assetExists?: AssetExists): void;
|
|
82
|
-
/**
|
|
83
|
-
* Rewrite CSS url(...) references in a sub-composition's inline styles so
|
|
84
|
-
* ../foo.woff2 remains valid after the CSS is hoisted into the root document.
|
|
85
|
-
*/
|
|
86
|
-
declare function rewriteCssAssetUrls(cssText: string, compSrcPath: string, assetExists?: AssetExists): string;
|
|
87
|
-
|
|
88
24
|
declare function rewriteSrcsetUrls(srcset: string, rewriteUrl: (url: string) => string): string;
|
|
89
25
|
|
|
90
|
-
export {
|
|
26
|
+
export { CSS_URL_RE, PATH_ATTRS, isNonRelativeUrl, isPathInside, rewriteSrcsetUrls };
|
package/dist/ffBinaries.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { Readable } from 'node:stream';
|
|
2
|
+
export { assertLiteralMediaInput } from './literalMediaInput.js';
|
|
3
|
+
|
|
1
4
|
/** Whether a program in `dir` may be run without the person naming it. */
|
|
2
5
|
declare function isTrustedDirectory(dir: string): boolean;
|
|
3
6
|
/** Whether `file` is an absolute path in a folder {@link isTrustedDirectory} accepts. */
|
|
@@ -10,12 +13,6 @@ declare function trustedPathDirs(pathValue?: string, platform?: NodeJS.Platform,
|
|
|
10
13
|
declare function executableIn(dir: string, name: string): string | undefined;
|
|
11
14
|
declare function findTrustedExecutable(name: string): string | undefined;
|
|
12
15
|
|
|
13
|
-
/**
|
|
14
|
-
* Shared FFmpeg/FFprobe binary resolution for every package that shells out
|
|
15
|
-
* to them (engine, cli, lint, studio-server). Node-only: import via the
|
|
16
|
-
* `@hyperframes/parsers/ff-binaries` subpath, never from a browser bundle.
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
16
|
declare const FFMPEG_PATH_ENV = "HYPERFRAMES_FFMPEG_PATH";
|
|
20
17
|
declare const FFPROBE_PATH_ENV = "HYPERFRAMES_FFPROBE_PATH";
|
|
21
18
|
type FfBinaryName = "ffmpeg" | "ffprobe";
|
|
@@ -50,7 +47,10 @@ declare function clearFfBinaryLookupCache(): void;
|
|
|
50
47
|
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";
|
|
51
48
|
/** Tests feed a `-demuxers` listing so none spawns a binary; no argument forgets it. */
|
|
52
49
|
declare function _setDemuxerListingForTests(listing?: string): void;
|
|
53
|
-
/** Every demuxer `listingBinary` reports that opens nothing by itself; one that cannot be asked gets the self-contained list, and is asked again. */
|
|
54
|
-
declare function mediaInputFormatArgs(listingBinary: string): string[];
|
|
55
50
|
|
|
56
|
-
|
|
51
|
+
/** 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. */
|
|
52
|
+
declare function mediaInputFormatArgs(listingBinary: string, input: string): string[];
|
|
53
|
+
/** Hears the furthest output time, in seconds, that ffmpeg's `-progress pipe:1` lines on `stream` report. */
|
|
54
|
+
declare function followFfmpegProgress(stream: Readable, onSeconds: (seconds: number) => void): void;
|
|
55
|
+
|
|
56
|
+
export { FFMPEG_PATH_ENV, FFPROBE_PATH_ENV, type FfBinaryName, type FindFfBinaryOptions, SELF_CONTAINED_FORMATS, _setDemuxerListingForTests, clearFfBinaryLookupCache, executableIn, findFfBinary, findTrustedExecutable, followFfmpegProgress, getSkippedX86Binary, isTrustedDirectory, isTrustedExecutablePath, isX86OnlyMachO, mediaInputFormatArgs, pathEntries, requireFfBinary, trustedPathDirs };
|
package/dist/ffBinaries.js
CHANGED
|
@@ -139,6 +139,17 @@ function findTrustedExecutable(name) {
|
|
|
139
139
|
return void 0;
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
+
// src/literalMediaInput.ts
|
|
143
|
+
var PATTERN_IMAGE2_EXPANDS = /%(?:\d*d|[%*?[\]{}])/;
|
|
144
|
+
var URL_SCHEME = /^[a-z][a-z0-9+.-]+:/i;
|
|
145
|
+
function assertLiteralMediaInput(input) {
|
|
146
|
+
const local = !URL_SCHEME.test(input) || /^file:/i.test(input);
|
|
147
|
+
if (!local || !PATTERN_IMAGE2_EXPANDS.test(input)) return;
|
|
148
|
+
throw new Error(
|
|
149
|
+
`[FFmpeg] refused media path "${input.split(/[\\/]/).pop()}": a "%" followed by a number and "d", another "%" or a wildcard would make ffmpeg read it as a pattern of other files. Rename the file or folder.`
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
|
|
142
153
|
// src/ffBinaries.ts
|
|
143
154
|
var FFMPEG_PATH_ENV = "HYPERFRAMES_FFMPEG_PATH";
|
|
144
155
|
var FFPROBE_PATH_ENV = "HYPERFRAMES_FFPROBE_PATH";
|
|
@@ -291,6 +302,7 @@ var PATH_OPENING_DEMUXERS = /* @__PURE__ */ new Set([
|
|
|
291
302
|
"vapoursynth",
|
|
292
303
|
"lavfi"
|
|
293
304
|
]);
|
|
305
|
+
var TEXT_ART_DEMUXERS = /* @__PURE__ */ new Set(["tty", "bin", "xbin", "idf", "adf"]);
|
|
294
306
|
function demuxersFromListing(listing) {
|
|
295
307
|
const row = /Is a device/.test(listing) ? /^ D[E ]([d ]) (\S+)/ : /^ D[E ]() (\S+)/;
|
|
296
308
|
const names = /* @__PURE__ */ new Set();
|
|
@@ -298,7 +310,8 @@ function demuxersFromListing(listing) {
|
|
|
298
310
|
const match = row.exec(line);
|
|
299
311
|
if (!match || match[1] === "d") continue;
|
|
300
312
|
const aliases = match[2].split(",");
|
|
301
|
-
if (aliases.some((alias) => PATH_OPENING_DEMUXERS.has(alias)))
|
|
313
|
+
if (aliases.some((alias) => PATH_OPENING_DEMUXERS.has(alias) || TEXT_ART_DEMUXERS.has(alias)))
|
|
314
|
+
continue;
|
|
302
315
|
for (const alias of aliases) names.add(alias);
|
|
303
316
|
}
|
|
304
317
|
return names.size > 0 ? [...names].join(",") : void 0;
|
|
@@ -309,7 +322,8 @@ function _setDemuxerListingForTests(listing) {
|
|
|
309
322
|
listingOverride = listing;
|
|
310
323
|
demuxerLists.clear();
|
|
311
324
|
}
|
|
312
|
-
function mediaInputFormatArgs(listingBinary) {
|
|
325
|
+
function mediaInputFormatArgs(listingBinary, input) {
|
|
326
|
+
assertLiteralMediaInput(input);
|
|
313
327
|
let formats = demuxerLists.get(listingBinary);
|
|
314
328
|
if (formats === void 0) {
|
|
315
329
|
try {
|
|
@@ -329,15 +343,34 @@ function mediaInputFormatArgs(listingBinary) {
|
|
|
329
343
|
}
|
|
330
344
|
return ["-format_whitelist", formats];
|
|
331
345
|
}
|
|
346
|
+
var OUT_TIME = /^out_time_(?:us|ms)=(\d+)$/;
|
|
347
|
+
function followFfmpegProgress(stream, onSeconds) {
|
|
348
|
+
let furthest = 0;
|
|
349
|
+
let lineTail = "";
|
|
350
|
+
stream.on("data", (chunk) => {
|
|
351
|
+
const lines = (lineTail + chunk.toString()).split("\n");
|
|
352
|
+
lineTail = lines.pop() ?? "";
|
|
353
|
+
for (const line of lines) {
|
|
354
|
+
const reached = OUT_TIME.exec(line.trim());
|
|
355
|
+
if (!reached) continue;
|
|
356
|
+
const seconds = Number(reached[1]) / 1e6;
|
|
357
|
+
if (seconds <= furthest) continue;
|
|
358
|
+
furthest = seconds;
|
|
359
|
+
onSeconds(seconds);
|
|
360
|
+
}
|
|
361
|
+
});
|
|
362
|
+
}
|
|
332
363
|
export {
|
|
333
364
|
FFMPEG_PATH_ENV,
|
|
334
365
|
FFPROBE_PATH_ENV,
|
|
335
366
|
SELF_CONTAINED_FORMATS,
|
|
336
367
|
_setDemuxerListingForTests,
|
|
368
|
+
assertLiteralMediaInput,
|
|
337
369
|
clearFfBinaryLookupCache,
|
|
338
370
|
executableIn,
|
|
339
371
|
findFfBinary,
|
|
340
372
|
findTrustedExecutable,
|
|
373
|
+
followFfmpegProgress,
|
|
341
374
|
getSkippedX86Binary,
|
|
342
375
|
isTrustedDirectory,
|
|
343
376
|
isTrustedExecutablePath,
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// src/literalMediaInput.ts
|
|
2
|
+
var PATTERN_IMAGE2_EXPANDS = /%(?:\d*d|[%*?[\]{}])/;
|
|
3
|
+
var URL_SCHEME = /^[a-z][a-z0-9+.-]+:/i;
|
|
4
|
+
function assertLiteralMediaInput(input) {
|
|
5
|
+
const local = !URL_SCHEME.test(input) || /^file:/i.test(input);
|
|
6
|
+
if (!local || !PATTERN_IMAGE2_EXPANDS.test(input)) return;
|
|
7
|
+
throw new Error(
|
|
8
|
+
`[FFmpeg] refused media path "${input.split(/[\\/]/).pop()}": a "%" followed by a number and "d", another "%" or a wildcard would make ffmpeg read it as a pattern of other files. Rename the file or folder.`
|
|
9
|
+
);
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
assertLiteralMediaInput
|
|
13
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Segments as a case-insensitive file system or Windows opens them: any case or Unicode form (a long s, a ligature or a
|
|
3
|
+
* full-width letter reads as its plain letters, an invisible character is dropped), no trailing dots or spaces, no
|
|
4
|
+
* `:stream` suffix.
|
|
5
|
+
*/
|
|
6
|
+
declare function projectPathSegments(relPath: string): string[];
|
|
7
|
+
declare function isVcsOrSecretPath(relPath: string): boolean;
|
|
8
|
+
/** Credential files and tool or agent state, for a project-relative path in any spelling Windows opens. */
|
|
9
|
+
declare function isCredentialOrToolStatePath(relPath: string): boolean;
|
|
10
|
+
/** Files no composition loads, in any spelling Windows opens: git, env, credentials, tool state, app records. */
|
|
11
|
+
declare function isStudioPrivatePath(relPath: string): boolean;
|
|
12
|
+
/** Whether `isPrivate` holds for a file under `projectDir`, spelled as given or with its links resolved. */
|
|
13
|
+
declare function isPrivateFileUnder(projectDir: string, filePath: string, isPrivate: (relPath: string) => boolean): boolean;
|
|
14
|
+
|
|
15
|
+
export { isCredentialOrToolStatePath, isPrivateFileUnder, isStudioPrivatePath, isVcsOrSecretPath, projectPathSegments };
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
// src/privatePath.ts
|
|
2
|
+
import { realpathSync } from "fs";
|
|
3
|
+
import { isAbsolute, relative, resolve, sep } from "path";
|
|
4
|
+
function realpath(path) {
|
|
5
|
+
try {
|
|
6
|
+
return realpathSync.native(path);
|
|
7
|
+
} catch (error) {
|
|
8
|
+
if (error.code === "EISDIR") return realpathSync(path);
|
|
9
|
+
throw error;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function projectPathSegments(relPath) {
|
|
13
|
+
return relPath.normalize("NFKC").toUpperCase().toLowerCase().replace(new RegExp("\\p{Default_Ignorable_Code_Point}", "gu"), "").split(/[\\/]/).map((segment) => withoutTrailingDotsOrSpaces(segment.split(":", 1)[0] ?? ""));
|
|
14
|
+
}
|
|
15
|
+
function withoutTrailingDotsOrSpaces(segment) {
|
|
16
|
+
let end = segment.length;
|
|
17
|
+
while (end > 0 && (segment[end - 1] === "." || segment[end - 1] === " ")) end--;
|
|
18
|
+
return segment.slice(0, end);
|
|
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([
|
|
32
|
+
".npmrc",
|
|
33
|
+
".yarnrc",
|
|
34
|
+
".yarnrc.yml",
|
|
35
|
+
".pypirc",
|
|
36
|
+
"pip.conf",
|
|
37
|
+
"pip.ini",
|
|
38
|
+
".netrc",
|
|
39
|
+
"_netrc",
|
|
40
|
+
".git-credentials",
|
|
41
|
+
".gitconfig",
|
|
42
|
+
".mcp.json"
|
|
43
|
+
]);
|
|
44
|
+
var CREDENTIAL_FOLDERS = /* @__PURE__ */ new Set([
|
|
45
|
+
".ssh",
|
|
46
|
+
".aws",
|
|
47
|
+
".gnupg",
|
|
48
|
+
".docker",
|
|
49
|
+
".kube",
|
|
50
|
+
".azure",
|
|
51
|
+
".claude",
|
|
52
|
+
".codex",
|
|
53
|
+
".cursor",
|
|
54
|
+
".agents",
|
|
55
|
+
".gemini",
|
|
56
|
+
".vscode",
|
|
57
|
+
".idea"
|
|
58
|
+
]);
|
|
59
|
+
var CREDENTIAL_CONFIG_FOLDERS = /* @__PURE__ */ new Set(["gcloud", "gh"]);
|
|
60
|
+
var KEY_FILE = /^(?:id_(?:rsa|dsa|ecdsa|ed25519).*|.*\.(?:pem|key|p12|pfx|p8|ppk|jks|keystore|kdbx))$/;
|
|
61
|
+
var SECRET_STORE_FILE = /\.(?:tfstate(?:\.backup)?|tfvars(?:\.json)?)$/;
|
|
62
|
+
function isCredentialOrToolStatePath(relPath) {
|
|
63
|
+
const segments = projectPathSegments(relPath);
|
|
64
|
+
const name = segments.at(-1) ?? "";
|
|
65
|
+
return CREDENTIAL_FILES.has(name) || KEY_FILE.test(name) || SECRET_STORE_FILE.test(name) || segments.some(
|
|
66
|
+
(segment, at) => CREDENTIAL_FOLDERS.has(segment) || segment === ".config" && CREDENTIAL_CONFIG_FOLDERS.has(segments[at + 1] ?? "")
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
function isStudioPrivatePath(relPath) {
|
|
70
|
+
if (isVcsOrSecretPath(relPath) || isCredentialOrToolStatePath(relPath)) return true;
|
|
71
|
+
const segments = projectPathSegments(relPath);
|
|
72
|
+
const inside = !isAbsolute(relPath) && !/^\.\.[. ]*$/.test(relPath.split(/[\\/]/, 1)[0] ?? "");
|
|
73
|
+
const loadedType = LOADED_ASSET_TYPE.test(segments.at(-1) ?? "");
|
|
74
|
+
return segments.some((segment, at) => {
|
|
75
|
+
const atRoot = segments.slice(0, at).every((before) => before === "");
|
|
76
|
+
if (segment === ".hyperframes")
|
|
77
|
+
return !atRoot || !isStudioOwnFile(segments.slice(at).join("/"));
|
|
78
|
+
const mediaFolder = atRoot && segment === MEDIA_FOLDER;
|
|
79
|
+
return inside && segment.startsWith(".") && !mediaFolder && !loadedType;
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
var MEDIA_FOLDER = ".media";
|
|
83
|
+
var LOADED_ASSET_TYPE = /.\.(?:png|jpe?g|gif|webp|avif|svg|ico|bmp|tiff?|heic|heif|mp4|m4v|mov|webm|mkv|mxf|avi|mp3|wav|m4a|aac|ogg|oga|opus|flac|woff2?|ttf|otf|css|m?js|cjs)$/;
|
|
84
|
+
function isStudioOwnFile(path) {
|
|
85
|
+
if (path === UNCONVERTED_PREVIEW_DOWNLOADS || path.startsWith(`${UNCONVERTED_PREVIEW_DOWNLOADS}/`))
|
|
86
|
+
return false;
|
|
87
|
+
return STUDIO_FILES.has(path) || STUDIO_FOLDERS.some((folder) => path === folder || path.startsWith(`${folder}/`));
|
|
88
|
+
}
|
|
89
|
+
function isPrivateFileUnder(projectDir, filePath, isPrivate) {
|
|
90
|
+
const rel = (from, to) => relative(from, to).split(sep).join("/");
|
|
91
|
+
if (isPrivate(rel(resolve(projectDir), resolve(filePath)))) return true;
|
|
92
|
+
try {
|
|
93
|
+
return isPrivate(rel(realpath(resolve(projectDir)), realpath(filePath)));
|
|
94
|
+
} catch {
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
export {
|
|
99
|
+
isCredentialOrToolStatePath,
|
|
100
|
+
isPrivateFileUnder,
|
|
101
|
+
isStudioPrivatePath,
|
|
102
|
+
isVcsOrSecretPath,
|
|
103
|
+
projectPathSegments
|
|
104
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rewrite relative asset paths in sub-composition content so they resolve
|
|
3
|
+
* correctly after the content is inlined into the root document.
|
|
4
|
+
*
|
|
5
|
+
* A sub-composition at "compositions/scene.html" referencing "../icon.svg"
|
|
6
|
+
* means the project root — but after inlining into root index.html, the
|
|
7
|
+
* "../" escapes the project directory and causes 404s. This function
|
|
8
|
+
* resolves each relative path against the sub-composition's directory,
|
|
9
|
+
* then normalizes it to be relative to the project root.
|
|
10
|
+
*
|
|
11
|
+
* Used by both the core bundler (preview) and the producer compiler (render)
|
|
12
|
+
* to ensure consistent behavior.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Probe for "does this project-root-relative path exist?", supplied by callers
|
|
16
|
+
* that can see the filesystem (the studio preview builder, the bundler, the
|
|
17
|
+
* producer). Keeps this module free of `node:fs` so it stays browser-safe.
|
|
18
|
+
*
|
|
19
|
+
* It disambiguates the two conventions for a plain relative path authored in a
|
|
20
|
+
* sub-composition that lives in a subdirectory:
|
|
21
|
+
*
|
|
22
|
+
* 1. A SIBLING file — `<link href="_shared.css">` next to the composition.
|
|
23
|
+
* This is what a browser resolves when the file is opened directly, and
|
|
24
|
+
* what an author means. Once the content moves into the project-root
|
|
25
|
+
* document it must become `design/styleframes/_shared.css` or it 404s.
|
|
26
|
+
* 2. A PROJECT-ROOT asset — registry blocks are installed into a
|
|
27
|
+
* subdirectory but reference `assets/logo.png` at the root. Already
|
|
28
|
+
* correct in the root document; rewriting would break it.
|
|
29
|
+
*
|
|
30
|
+
* A sibling that exists on disk means (1); anything else is left as authored.
|
|
31
|
+
* Without a probe the behavior is unchanged — plain relative paths pass through.
|
|
32
|
+
*/
|
|
33
|
+
type AssetExists = (projectRelativePath: string) => boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Rewrite a single relative path from a sub-composition's context to the
|
|
36
|
+
* project root context.
|
|
37
|
+
*
|
|
38
|
+
* @param compSrcPath - The `data-composition-src` value (e.g. "compositions/scene.html")
|
|
39
|
+
* @param relativePath - The asset path to rewrite (e.g. "../icon.svg")
|
|
40
|
+
* @param assetExists - Optional filesystem probe; see `AssetExists`.
|
|
41
|
+
* @returns The rewritten path relative to project root (e.g. "icon.svg"), or
|
|
42
|
+
* the original path if no rewriting is needed.
|
|
43
|
+
*/
|
|
44
|
+
declare function rewriteAssetPath(compSrcPath: string, relativePath: string, assetExists?: AssetExists): string;
|
|
45
|
+
/**
|
|
46
|
+
* Rewrite all relative `src` and `href` attributes on elements within a
|
|
47
|
+
* DOM tree, adjusting paths from the sub-composition's directory context
|
|
48
|
+
* to the project root.
|
|
49
|
+
*
|
|
50
|
+
* @param elements - Iterable of DOM elements to scan (e.g. from querySelectorAll)
|
|
51
|
+
* @param compSrcPath - The `data-composition-src` value
|
|
52
|
+
* @param getAttr - Function to read an attribute from an element
|
|
53
|
+
* @param setAttr - Function to set an attribute on an element
|
|
54
|
+
*/
|
|
55
|
+
declare function rewriteAssetPaths<T>(elements: Iterable<T>, compSrcPath: string, getAttr: (el: T, attr: string) => string | null | undefined, setAttr: (el: T, attr: string, value: string) => void, assetExists?: AssetExists): void;
|
|
56
|
+
/**
|
|
57
|
+
* Rewrite CSS url(...) references inside inline style attributes.
|
|
58
|
+
*/
|
|
59
|
+
declare function rewriteInlineStyleAssetUrls<T>(elements: Iterable<T>, compSrcPath: string, getStyle: (el: T) => string | null | undefined, setStyle: (el: T, value: string) => void, assetExists?: AssetExists): void;
|
|
60
|
+
/**
|
|
61
|
+
* Rewrite CSS url(...) references in a sub-composition's inline styles so
|
|
62
|
+
* ../foo.woff2 remains valid after the CSS is hoisted into the root document.
|
|
63
|
+
*/
|
|
64
|
+
declare function rewriteCssAssetUrls(cssText: string, compSrcPath: string, assetExists?: AssetExists): string;
|
|
65
|
+
|
|
66
|
+
export { type AssetExists as A, rewriteAssetPaths as a, rewriteCssAssetUrls as b, rewriteInlineStyleAssetUrls as c, rewriteAssetPath as r };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyperframes/parsers",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.61",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/heygen-com/hyperframes",
|
|
@@ -92,6 +92,10 @@
|
|
|
92
92
|
"import": "./dist/ffBinaries.js",
|
|
93
93
|
"types": "./dist/ffBinaries.d.ts"
|
|
94
94
|
},
|
|
95
|
+
"./literal-media-input": {
|
|
96
|
+
"import": "./dist/literalMediaInput.js",
|
|
97
|
+
"types": "./dist/literalMediaInput.d.ts"
|
|
98
|
+
},
|
|
95
99
|
"./media-alpha": {
|
|
96
100
|
"import": "./dist/mediaAlpha.js",
|
|
97
101
|
"types": "./dist/mediaAlpha.d.ts"
|
|
@@ -104,6 +108,10 @@
|
|
|
104
108
|
"import": "./dist/assetResolution.js",
|
|
105
109
|
"types": "./dist/assetResolution.d.ts"
|
|
106
110
|
},
|
|
111
|
+
"./private-path": {
|
|
112
|
+
"import": "./dist/privatePath.js",
|
|
113
|
+
"types": "./dist/privatePath.d.ts"
|
|
114
|
+
},
|
|
107
115
|
"./html-attribute-spans": {
|
|
108
116
|
"import": "./dist/htmlAttributeSpans.js",
|
|
109
117
|
"types": "./dist/htmlAttributeSpans.d.ts"
|
|
@@ -143,7 +151,7 @@
|
|
|
143
151
|
"tsx": "^4.21.0",
|
|
144
152
|
"typescript": "^5.0.0",
|
|
145
153
|
"vitest": "^4.1.12",
|
|
146
|
-
"@hyperframes/core": "0.9.
|
|
154
|
+
"@hyperframes/core": "0.9.61"
|
|
147
155
|
},
|
|
148
156
|
"scripts": {
|
|
149
157
|
"build": "tsup",
|