@hyperframes/parsers 0.9.33 → 0.9.35
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/composition.d.ts +1 -1
- package/dist/composition.js +11 -11
- package/dist/ffBinaries.d.ts +15 -4
- package/dist/ffBinaries.js +100 -42
- package/dist/{fontAliases-CjqNyywH.d.ts → fontAliases-o-I_DVRP.d.ts} +7 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +10 -11
- package/package.json +2 -2
package/dist/composition.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { A as AddElementData, a as Asset, B as BooleanVariable, C as CANVAS_DIMENSIONS, b as COMPOSITION_VARIABLE_TYPES, c as CanvasResolution, d as ColorVariable, e as CompositionAPI, f as CompositionAsset, g as CompositionSpec, h as CompositionVariable, i as CompositionVariableBase, j as CompositionVariableType, D as DEFAULT_DURATIONS, E as ElementKeyframes, k as EnumVariable, F as FontValue, l as FontVariable, I as ImageValue, m as ImageVariable, K as Keyframe, n as KeyframeProperties, M as MediaElementType, o as MediaFile, N as NumberVariable, P as PlayerAPI, R as ResolvedResolutionFlag, S as StageZoom, p as StageZoomKeyframe, q as StringVariable, T as TIMELINE_COLORS, r as TimelineCompositionElement, s as TimelineElement, t as TimelineElementBase, u as TimelineElementType, v as TimelineMediaElement, w as TimelineTextElement, V as VALID_CANVAS_RESOLUTIONS, x as ValidationResult, W as WaveformData, y as getDefaultStageZoom, z as isAspectAgnosticResolutionAlias, G as isCompositionElement, H as isMediaElement, J as isTextElement, L as normalizeResolutionFlag, O as resolveResolutionFlagPair } from './types-C1bWHQbs.js';
|
|
2
|
-
export { C as CANONICAL_FONT_DISPLAY_NAMES, F as FONT_ALIAS_KEYS, a as FONT_ALIAS_MAP, H as HTML_BODY_CSS_HEIGHT_FIRST_RE, b as HTML_BODY_CSS_WIDTH_FIRST_RE, M as MediaSrcMutation, V as VIEWPORT_META_SIZE_RE, c as VariableUsageScan, e as extractMediaSrcMutations, i as isCompositionVariable, d as isFontValue, f as isImageValue, g as isSafeMediaUrl, h as isScalarVariableValue, p as parseCompositionVariables, r as resolveAliasDisplayName, s as scanVariableUsage } from './fontAliases-
|
|
2
|
+
export { C as CANONICAL_FONT_DISPLAY_NAMES, F as FONT_ALIAS_KEYS, a as FONT_ALIAS_MAP, H as HTML_BODY_CSS_HEIGHT_FIRST_RE, b as HTML_BODY_CSS_WIDTH_FIRST_RE, M as MediaSrcMutation, R as ReadCompositionVariables, V as VIEWPORT_META_SIZE_RE, c as VariableUsageScan, e as extractMediaSrcMutations, i as isCompositionVariable, d as isFontValue, f as isImageValue, g as isSafeMediaUrl, h as isScalarVariableValue, p as parseCompositionVariables, r as readCompositionVariables, j as resolveAliasDisplayName, s as scanVariableUsage } from './fontAliases-o-I_DVRP.js';
|
|
3
3
|
export { d as decodeUrlPathVariants } from './urlPath-CYK47t9W.js';
|
|
4
4
|
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';
|
|
5
5
|
|
package/dist/composition.js
CHANGED
|
@@ -338,21 +338,20 @@ function isCompositionVariable(v) {
|
|
|
338
338
|
if (v.type === "enum" && !Array.isArray(v.options)) return false;
|
|
339
339
|
return true;
|
|
340
340
|
}
|
|
341
|
-
function
|
|
342
|
-
|
|
343
|
-
if (!variablesAttr) {
|
|
344
|
-
return [];
|
|
345
|
-
}
|
|
341
|
+
function readCompositionVariables(raw) {
|
|
342
|
+
if (!raw) return { declarations: [], complete: true };
|
|
346
343
|
try {
|
|
347
|
-
const parsed = JSON.parse(
|
|
348
|
-
if (!Array.isArray(parsed)) {
|
|
349
|
-
|
|
350
|
-
}
|
|
351
|
-
return parsed.filter(isCompositionVariable);
|
|
344
|
+
const parsed = JSON.parse(raw);
|
|
345
|
+
if (!Array.isArray(parsed)) return { declarations: [], complete: false };
|
|
346
|
+
const declarations = parsed.filter(isCompositionVariable);
|
|
347
|
+
return { declarations, complete: declarations.length === parsed.length };
|
|
352
348
|
} catch {
|
|
353
|
-
return [];
|
|
349
|
+
return { declarations: [], complete: false };
|
|
354
350
|
}
|
|
355
351
|
}
|
|
352
|
+
function parseCompositionVariables(htmlEl) {
|
|
353
|
+
return readCompositionVariables(htmlEl.getAttribute("data-composition-variables")).declarations;
|
|
354
|
+
}
|
|
356
355
|
function isSafeMediaUrl(url) {
|
|
357
356
|
const normalized = url.replace(/[\u0000-\u0020]/g, "");
|
|
358
357
|
const scheme = /^([a-z][a-z0-9+.-]*):/i.exec(normalized);
|
|
@@ -977,6 +976,7 @@ export {
|
|
|
977
976
|
parseNumeric,
|
|
978
977
|
parseStartExpression,
|
|
979
978
|
readClipTiming,
|
|
979
|
+
readCompositionVariables,
|
|
980
980
|
resolveAliasDisplayName,
|
|
981
981
|
resolveResolutionFlagPair,
|
|
982
982
|
scanVariableUsage,
|
package/dist/ffBinaries.d.ts
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
|
+
/** Whether a program in `dir` may be run without the person naming it. */
|
|
2
|
+
declare function isTrustedDirectory(dir: string): boolean;
|
|
3
|
+
/** Whether `file` is an absolute path in a folder {@link isTrustedDirectory} accepts. */
|
|
4
|
+
declare function isTrustedExecutablePath(file: string): boolean;
|
|
5
|
+
/** The PATH folders a helper program may come from, in PATH order. */
|
|
6
|
+
declare function trustedPathDirs(pathValue?: string): string[];
|
|
7
|
+
declare function findTrustedExecutable(name: string): string | undefined;
|
|
8
|
+
|
|
1
9
|
/**
|
|
2
10
|
* Shared FFmpeg/FFprobe binary resolution for every package that shells out
|
|
3
11
|
* to them (engine, cli, lint, studio-server). Node-only: import via the
|
|
4
12
|
* `@hyperframes/parsers/ff-binaries` subpath, never from a browser bundle.
|
|
5
13
|
*/
|
|
14
|
+
|
|
6
15
|
declare const FFMPEG_PATH_ENV = "HYPERFRAMES_FFMPEG_PATH";
|
|
7
16
|
declare const FFPROBE_PATH_ENV = "HYPERFRAMES_FFPROBE_PATH";
|
|
8
17
|
type FfBinaryName = "ffmpeg" | "ffprobe";
|
|
@@ -21,15 +30,17 @@ interface FindFfBinaryOptions {
|
|
|
21
30
|
}
|
|
22
31
|
/**
|
|
23
32
|
* Resolve an FFmpeg-family binary: env override first, then a native
|
|
24
|
-
* PATH scan
|
|
25
|
-
* then
|
|
26
|
-
*
|
|
33
|
+
* in-process PATH scan, then well-known Unix install dirs,
|
|
34
|
+
* then an `@ffmpeg-installer`/`@ffprobe-installer` package installed next to HyperFrames.
|
|
35
|
+
* Discovery never returns a file in the working directory (see trustedExecutable.ts).
|
|
27
36
|
* A found binary is cached for the process lifetime; a miss only for a few
|
|
28
37
|
* seconds, so a long-running server sees an install made after it started. The env
|
|
29
38
|
* override is re-read on every call.
|
|
30
39
|
*/
|
|
31
40
|
declare function findFfBinary(name: FfBinaryName, options?: FindFfBinaryOptions): string | undefined;
|
|
41
|
+
/** {@link findFfBinary}, or an ENOENT error naming the override. Never the bare name for the OS to look up. */
|
|
42
|
+
declare function requireFfBinary(name: FfBinaryName): string;
|
|
32
43
|
/** Test hook: drop cached system lookups so resolution can be re-exercised. */
|
|
33
44
|
declare function clearFfBinaryLookupCache(): void;
|
|
34
45
|
|
|
35
|
-
export { FFMPEG_PATH_ENV, FFPROBE_PATH_ENV, type FfBinaryName, type FindFfBinaryOptions, clearFfBinaryLookupCache, findFfBinary, getSkippedX86Binary, isX86OnlyMachO };
|
|
46
|
+
export { FFMPEG_PATH_ENV, FFPROBE_PATH_ENV, type FfBinaryName, type FindFfBinaryOptions, clearFfBinaryLookupCache, findFfBinary, findTrustedExecutable, getSkippedX86Binary, isTrustedDirectory, isTrustedExecutablePath, isX86OnlyMachO, requireFfBinary, trustedPathDirs };
|
package/dist/ffBinaries.js
CHANGED
|
@@ -1,8 +1,76 @@
|
|
|
1
1
|
// src/ffBinaries.ts
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import {
|
|
3
|
+
accessSync as accessSync2,
|
|
4
|
+
closeSync,
|
|
5
|
+
constants as constants2,
|
|
6
|
+
existsSync as existsSync2,
|
|
7
|
+
openSync,
|
|
8
|
+
readSync,
|
|
9
|
+
statSync as statSync2
|
|
10
|
+
} from "fs";
|
|
4
11
|
import { createRequire } from "module";
|
|
5
|
-
import { basename,
|
|
12
|
+
import { basename, dirname as dirname2, join as join2, resolve as resolve2 } from "path";
|
|
13
|
+
|
|
14
|
+
// src/trustedExecutable.ts
|
|
15
|
+
import { accessSync, constants, existsSync, realpathSync, statSync } from "fs";
|
|
16
|
+
import { homedir } from "os";
|
|
17
|
+
import { delimiter, dirname, isAbsolute, join, relative, resolve, sep } from "path";
|
|
18
|
+
function comparable(path) {
|
|
19
|
+
let full = resolve(path);
|
|
20
|
+
try {
|
|
21
|
+
full = realpathSync.native(full);
|
|
22
|
+
} catch {
|
|
23
|
+
full = resolve(path);
|
|
24
|
+
}
|
|
25
|
+
return process.platform === "win32" ? full.toLowerCase() : full;
|
|
26
|
+
}
|
|
27
|
+
function contains(parent, child) {
|
|
28
|
+
const rel = relative(parent, child);
|
|
29
|
+
return rel === "" || rel !== ".." && !rel.startsWith(`..${sep}`) && !isAbsolute(rel);
|
|
30
|
+
}
|
|
31
|
+
function isTrustedDirectory(dir) {
|
|
32
|
+
if (!dir || !isAbsolute(dir)) return false;
|
|
33
|
+
const target = comparable(dir);
|
|
34
|
+
const cwd = comparable(process.cwd());
|
|
35
|
+
if (target === cwd) return false;
|
|
36
|
+
return contains(cwd, comparable(homedir())) || !contains(cwd, target);
|
|
37
|
+
}
|
|
38
|
+
function isTrustedExecutablePath(file) {
|
|
39
|
+
return isAbsolute(file) && isTrustedDirectory(dirname(file));
|
|
40
|
+
}
|
|
41
|
+
function expandHome(dir) {
|
|
42
|
+
if (process.platform === "win32" || !(dir === "~" || dir.startsWith("~/"))) return dir;
|
|
43
|
+
return join(homedir(), dir.slice(1));
|
|
44
|
+
}
|
|
45
|
+
function trustedPathDirs(pathValue = process.env.PATH ?? "") {
|
|
46
|
+
const entries = pathValue.split(delimiter).map(expandHome);
|
|
47
|
+
return [...new Set(entries.filter((dir) => isTrustedDirectory(dir)))];
|
|
48
|
+
}
|
|
49
|
+
function windowsExtensions() {
|
|
50
|
+
const listed = (process.env.PATHEXT ?? ".COM;.EXE;.BAT;.CMD").split(";").map((ext) => ext.trim().toLowerCase()).filter(Boolean);
|
|
51
|
+
return [.../* @__PURE__ */ new Set([".exe", ...listed])];
|
|
52
|
+
}
|
|
53
|
+
function isExecutableFile(file) {
|
|
54
|
+
if (process.platform === "win32") return existsSync(file);
|
|
55
|
+
try {
|
|
56
|
+
accessSync(file, constants.X_OK);
|
|
57
|
+
return statSync(file).isFile();
|
|
58
|
+
} catch {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function findTrustedExecutable(name) {
|
|
63
|
+
const extensions = process.platform === "win32" ? windowsExtensions() : [""];
|
|
64
|
+
for (const dir of trustedPathDirs()) {
|
|
65
|
+
for (const ext of extensions) {
|
|
66
|
+
const candidate = join(dir, `${name}${ext}`);
|
|
67
|
+
if (isExecutableFile(candidate)) return candidate;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return void 0;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// src/ffBinaries.ts
|
|
6
74
|
var FFMPEG_PATH_ENV = "HYPERFRAMES_FFMPEG_PATH";
|
|
7
75
|
var FFPROBE_PATH_ENV = "HYPERFRAMES_FFPROBE_PATH";
|
|
8
76
|
var ENV_BY_NAME = {
|
|
@@ -36,7 +104,7 @@ function isX86OnlyMachO(file) {
|
|
|
36
104
|
return header.readUInt32LE(0) === 4277009103 && header.readUInt32LE(4) === MACHO_CPU_X86_64;
|
|
37
105
|
}
|
|
38
106
|
function runsOnThisMac(candidate) {
|
|
39
|
-
if (process.platform !== "darwin" || process.arch !== "arm64" ||
|
|
107
|
+
if (process.platform !== "darwin" || process.arch !== "arm64" || existsSync2(ROSETTA_RUNTIME)) {
|
|
40
108
|
return true;
|
|
41
109
|
}
|
|
42
110
|
if (!isX86OnlyMachO(candidate)) return true;
|
|
@@ -49,17 +117,16 @@ function getSkippedX86Binary(name) {
|
|
|
49
117
|
return skippedX86Binaries.get(name);
|
|
50
118
|
}
|
|
51
119
|
function isExecutablePathCandidate(candidate) {
|
|
52
|
-
if (process.platform === "win32") return
|
|
120
|
+
if (process.platform === "win32") return existsSync2(candidate);
|
|
53
121
|
try {
|
|
54
|
-
|
|
55
|
-
return runsOnThisMac(candidate);
|
|
122
|
+
accessSync2(candidate, constants2.X_OK);
|
|
123
|
+
return statSync2(candidate).isFile() && runsOnThisMac(candidate);
|
|
56
124
|
} catch {
|
|
57
125
|
return false;
|
|
58
126
|
}
|
|
59
127
|
}
|
|
60
128
|
function scanPath(name) {
|
|
61
|
-
const
|
|
62
|
-
const searchDirs = (pathValue ? pathValue.split(delimiter) : []).filter((dir) => isAbsolute(dir));
|
|
129
|
+
const searchDirs = trustedPathDirs();
|
|
63
130
|
if (searchDirs.length === 0) return void 0;
|
|
64
131
|
const extensions = process.platform === "win32" ? [
|
|
65
132
|
".exe",
|
|
@@ -69,9 +136,9 @@ function scanPath(name) {
|
|
|
69
136
|
""
|
|
70
137
|
] : [""];
|
|
71
138
|
const candidates = [];
|
|
72
|
-
for (const dir of
|
|
139
|
+
for (const dir of searchDirs) {
|
|
73
140
|
for (const ext of extensions) {
|
|
74
|
-
const candidate =
|
|
141
|
+
const candidate = join2(dir, `${name}${ext}`);
|
|
75
142
|
if (isExecutablePathCandidate(candidate)) candidates.push(candidate);
|
|
76
143
|
}
|
|
77
144
|
}
|
|
@@ -81,17 +148,15 @@ var COMMON_BIN_DIRS = process.platform === "win32" ? [] : ["/opt/homebrew/bin",
|
|
|
81
148
|
function findInCommonDirsOrInstallerPackage(name) {
|
|
82
149
|
for (const dir of COMMON_BIN_DIRS) {
|
|
83
150
|
const candidate = `${dir}/${name}`;
|
|
84
|
-
if (
|
|
151
|
+
if (isTrustedExecutablePath(candidate) && existsSync2(candidate) && runsOnThisMac(candidate)) {
|
|
152
|
+
return candidate;
|
|
153
|
+
}
|
|
85
154
|
}
|
|
86
155
|
return findInInstallerPackage(name);
|
|
87
156
|
}
|
|
88
157
|
function binaryFileName(name) {
|
|
89
158
|
return process.platform === "win32" ? `${name}.exe` : name;
|
|
90
159
|
}
|
|
91
|
-
function findInProjectLocalBin(name) {
|
|
92
|
-
const candidate = resolve(".hyperframes", "bin", binaryFileName(name));
|
|
93
|
-
return existsSync(candidate) && runsOnThisMac(candidate) ? candidate : void 0;
|
|
94
|
-
}
|
|
95
160
|
function tryResolve(fromFile, request) {
|
|
96
161
|
try {
|
|
97
162
|
return createRequire(fromFile).resolve(request);
|
|
@@ -100,33 +165,15 @@ function tryResolve(fromFile, request) {
|
|
|
100
165
|
}
|
|
101
166
|
}
|
|
102
167
|
function findInInstallerPackage(name) {
|
|
103
|
-
const project =
|
|
168
|
+
const project = import.meta.url;
|
|
104
169
|
const platformManifest = `@${name}-installer/${process.platform}-${process.arch}/package.json`;
|
|
105
170
|
const installer = tryResolve(project, `@${name}-installer/${name}/package.json`);
|
|
106
171
|
const manifest = (installer && tryResolve(installer, platformManifest)) ?? tryResolve(project, platformManifest);
|
|
107
|
-
const candidate = manifest &&
|
|
108
|
-
return candidate && isExecutablePathCandidate(candidate) ? candidate : void 0;
|
|
172
|
+
const candidate = manifest && join2(dirname2(manifest), binaryFileName(name));
|
|
173
|
+
return candidate && isTrustedExecutablePath(candidate) && isExecutablePathCandidate(candidate) ? candidate : void 0;
|
|
109
174
|
}
|
|
110
175
|
function searchSystem(name) {
|
|
111
|
-
|
|
112
|
-
if (process.platform === "win32") {
|
|
113
|
-
found = scanPath(name);
|
|
114
|
-
} else {
|
|
115
|
-
try {
|
|
116
|
-
const output = execFileSync("which", [name], {
|
|
117
|
-
encoding: "utf-8",
|
|
118
|
-
stdio: ["pipe", "pipe", "pipe"],
|
|
119
|
-
timeout: 5e3
|
|
120
|
-
});
|
|
121
|
-
const candidate = chooseBestPathCandidate(name, output.split(/\r?\n/));
|
|
122
|
-
found = candidate && isExecutablePathCandidate(candidate) ? candidate : scanPath(name);
|
|
123
|
-
} catch {
|
|
124
|
-
found = scanPath(name);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
found ??= findInProjectLocalBin(name);
|
|
128
|
-
found ??= findInCommonDirsOrInstallerPackage(name);
|
|
129
|
-
return found;
|
|
176
|
+
return scanPath(name) ?? findInCommonDirsOrInstallerPackage(name);
|
|
130
177
|
}
|
|
131
178
|
function lookupOnSystem(name) {
|
|
132
179
|
const cached = pathLookupCache.get(name);
|
|
@@ -137,18 +184,24 @@ function lookupOnSystem(name) {
|
|
|
137
184
|
lastMissAt.set(name, Date.now());
|
|
138
185
|
return void 0;
|
|
139
186
|
}
|
|
140
|
-
const resolved =
|
|
187
|
+
const resolved = resolve2(found);
|
|
141
188
|
pathLookupCache.set(name, resolved);
|
|
142
189
|
return resolved;
|
|
143
190
|
}
|
|
144
191
|
function findFfBinary(name, options = {}) {
|
|
145
192
|
const configured = process.env[ENV_BY_NAME[name]]?.trim();
|
|
146
193
|
if (configured) {
|
|
147
|
-
if (options.configuredMustExist && !
|
|
148
|
-
return
|
|
194
|
+
if (options.configuredMustExist && !existsSync2(configured)) return void 0;
|
|
195
|
+
return resolve2(configured);
|
|
149
196
|
}
|
|
150
197
|
return lookupOnSystem(name);
|
|
151
198
|
}
|
|
199
|
+
function requireFfBinary(name) {
|
|
200
|
+
const found = findFfBinary(name);
|
|
201
|
+
if (found) return found;
|
|
202
|
+
const message = `[FFmpeg] ${name} not found. Install FFmpeg or set ${ENV_BY_NAME[name]} to its absolute path.`;
|
|
203
|
+
throw Object.assign(new Error(message), { code: "ENOENT" });
|
|
204
|
+
}
|
|
152
205
|
function clearFfBinaryLookupCache() {
|
|
153
206
|
pathLookupCache.clear();
|
|
154
207
|
lastMissAt.clear();
|
|
@@ -159,6 +212,11 @@ export {
|
|
|
159
212
|
FFPROBE_PATH_ENV,
|
|
160
213
|
clearFfBinaryLookupCache,
|
|
161
214
|
findFfBinary,
|
|
215
|
+
findTrustedExecutable,
|
|
162
216
|
getSkippedX86Binary,
|
|
163
|
-
|
|
217
|
+
isTrustedDirectory,
|
|
218
|
+
isTrustedExecutablePath,
|
|
219
|
+
isX86OnlyMachO,
|
|
220
|
+
requireFfBinary,
|
|
221
|
+
trustedPathDirs
|
|
164
222
|
};
|
|
@@ -23,6 +23,12 @@ declare function isImageValue(value: unknown): value is ImageValue;
|
|
|
23
23
|
* (SDK declaration ops, Studio forms) can validate before persisting.
|
|
24
24
|
*/
|
|
25
25
|
declare function isCompositionVariable(v: unknown): v is CompositionVariable;
|
|
26
|
+
interface ReadCompositionVariables {
|
|
27
|
+
declarations: CompositionVariable[];
|
|
28
|
+
complete: boolean;
|
|
29
|
+
}
|
|
30
|
+
/** Valid declarations in the raw attribute text; `complete` is false when anything in it was dropped or unreadable. */
|
|
31
|
+
declare function readCompositionVariables(raw: string | null | undefined): ReadCompositionVariables;
|
|
26
32
|
/**
|
|
27
33
|
* Parse the typed variable declarations from an element's
|
|
28
34
|
* `data-composition-variables` attribute. Malformed entries (wrong shape,
|
|
@@ -182,4 +188,4 @@ declare const CANONICAL_FONT_DISPLAY_NAMES: Readonly<Record<string, string>>;
|
|
|
182
188
|
*/
|
|
183
189
|
declare function resolveAliasDisplayName(alias: string): string | undefined;
|
|
184
190
|
|
|
185
|
-
export { CANONICAL_FONT_DISPLAY_NAMES as C, FONT_ALIAS_KEYS as F, HTML_BODY_CSS_HEIGHT_FIRST_RE as H, type MediaSrcMutation as M, VIEWPORT_META_SIZE_RE as V, FONT_ALIAS_MAP as a, HTML_BODY_CSS_WIDTH_FIRST_RE as b, type VariableUsageScan as c, isFontValue as d, extractMediaSrcMutations as e, isImageValue as f, isSafeMediaUrl as g, isScalarVariableValue as h, isCompositionVariable as i, parseCompositionVariables as p,
|
|
191
|
+
export { CANONICAL_FONT_DISPLAY_NAMES as C, FONT_ALIAS_KEYS as F, HTML_BODY_CSS_HEIGHT_FIRST_RE as H, type MediaSrcMutation as M, type ReadCompositionVariables as R, VIEWPORT_META_SIZE_RE as V, FONT_ALIAS_MAP as a, HTML_BODY_CSS_WIDTH_FIRST_RE as b, type VariableUsageScan as c, isFontValue as d, extractMediaSrcMutations as e, isImageValue as f, isSafeMediaUrl as g, isScalarVariableValue as h, isCompositionVariable as i, resolveAliasDisplayName as j, parseCompositionVariables as p, readCompositionVariables as r, scanVariableUsage as s };
|
package/dist/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export { parseGsapScriptAcorn as parseGsapScript } from './gsapParserAcorn.js';
|
|
|
8
8
|
export { EXCLUDED_TAGS, ensureHfIds, isCompositionTemplate, mintHfId, stampHfIdsInPlace, walkCompositionDescendants } from './hfIds.js';
|
|
9
9
|
export { ParsableDocumentLike, SceneTemplateLike, SubCompositionValidity, SubCompositionValidityReason, checkSubCompositionUsability, findSceneTemplate, resolveSubCompositionContent } 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
|
-
export { C as CANONICAL_FONT_DISPLAY_NAMES, F as FONT_ALIAS_KEYS, a as FONT_ALIAS_MAP, H as HTML_BODY_CSS_HEIGHT_FIRST_RE, b as HTML_BODY_CSS_WIDTH_FIRST_RE, M as MediaSrcMutation, V as VIEWPORT_META_SIZE_RE, c as VariableUsageScan, e as extractMediaSrcMutations, p as parseCompositionVariables,
|
|
11
|
+
export { C as CANONICAL_FONT_DISPLAY_NAMES, F as FONT_ALIAS_KEYS, a as FONT_ALIAS_MAP, H as HTML_BODY_CSS_HEIGHT_FIRST_RE, b as HTML_BODY_CSS_WIDTH_FIRST_RE, M as MediaSrcMutation, V as VIEWPORT_META_SIZE_RE, c as VariableUsageScan, e as extractMediaSrcMutations, p as parseCompositionVariables, j as resolveAliasDisplayName, s as scanVariableUsage } from './fontAliases-o-I_DVRP.js';
|
|
12
12
|
export { StructureNode, TrackKind, TrackKindSource, isSubCompositionHost, isTimedElement, topLevelElements, trackKindOf } from './topLevelElements.js';
|
|
13
13
|
export { AttrReader, DEFAULT_IMAGE_TIMELINE_DURATION_SECONDS, MAX_PLAYBACK_RATE, MIN_PLAYBACK_RATE, MediaDurationResult, MediaDurationSource, MediaTag, PENDING_MEDIA_DURATION_READERS, ResolveMediaDurationInput, clampPlaybackRate, readAuthoredDurationSeconds, readDataDurationSeconds, readMediaOffsetSeconds, readPlaybackRate, resolveMediaDuration, resolveNaturalDurationSeconds } from './mediaDuration.js';
|
|
14
14
|
export { CompositionDurationResult, CompositionDurationSource, ResolveCompositionDurationInput, TIMING_TOLERANCE_SECONDS, resolveCompositionDuration } from './compositionDuration.js';
|
package/dist/index.js
CHANGED
|
@@ -2418,21 +2418,20 @@ function isCompositionVariable(v) {
|
|
|
2418
2418
|
if (v.type === "enum" && !Array.isArray(v.options)) return false;
|
|
2419
2419
|
return true;
|
|
2420
2420
|
}
|
|
2421
|
-
function
|
|
2422
|
-
|
|
2423
|
-
if (!variablesAttr) {
|
|
2424
|
-
return [];
|
|
2425
|
-
}
|
|
2421
|
+
function readCompositionVariables(raw) {
|
|
2422
|
+
if (!raw) return { declarations: [], complete: true };
|
|
2426
2423
|
try {
|
|
2427
|
-
const parsed = JSON.parse(
|
|
2428
|
-
if (!Array.isArray(parsed)) {
|
|
2429
|
-
|
|
2430
|
-
}
|
|
2431
|
-
return parsed.filter(isCompositionVariable);
|
|
2424
|
+
const parsed = JSON.parse(raw);
|
|
2425
|
+
if (!Array.isArray(parsed)) return { declarations: [], complete: false };
|
|
2426
|
+
const declarations = parsed.filter(isCompositionVariable);
|
|
2427
|
+
return { declarations, complete: declarations.length === parsed.length };
|
|
2432
2428
|
} catch {
|
|
2433
|
-
return [];
|
|
2429
|
+
return { declarations: [], complete: false };
|
|
2434
2430
|
}
|
|
2435
2431
|
}
|
|
2432
|
+
function parseCompositionVariables(htmlEl) {
|
|
2433
|
+
return readCompositionVariables(htmlEl.getAttribute("data-composition-variables")).declarations;
|
|
2434
|
+
}
|
|
2436
2435
|
|
|
2437
2436
|
// src/hfIds.ts
|
|
2438
2437
|
import { parseHTML } from "linkedom";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyperframes/parsers",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.35",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/heygen-com/hyperframes",
|
|
@@ -139,7 +139,7 @@
|
|
|
139
139
|
"tsx": "^4.21.0",
|
|
140
140
|
"typescript": "^5.0.0",
|
|
141
141
|
"vitest": "^4.1.11",
|
|
142
|
-
"@hyperframes/core": "0.9.
|
|
142
|
+
"@hyperframes/core": "0.9.35"
|
|
143
143
|
},
|
|
144
144
|
"scripts": {
|
|
145
145
|
"build": "tsup",
|