@hyperframes/parsers 0.9.33 → 0.9.34
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 +17 -4
- package/dist/ffBinaries.js +105 -25
- 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,19 @@
|
|
|
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
|
+
/** Windows walks PATH itself: `where` lists the working directory first. Elsewhere `which`
|
|
8
|
+
* answers, and an untrusted first hit falls through to the PATH walk. */
|
|
9
|
+
declare function findTrustedExecutable(name: string): string | undefined;
|
|
10
|
+
|
|
1
11
|
/**
|
|
2
12
|
* Shared FFmpeg/FFprobe binary resolution for every package that shells out
|
|
3
13
|
* to them (engine, cli, lint, studio-server). Node-only: import via the
|
|
4
14
|
* `@hyperframes/parsers/ff-binaries` subpath, never from a browser bundle.
|
|
5
15
|
*/
|
|
16
|
+
|
|
6
17
|
declare const FFMPEG_PATH_ENV = "HYPERFRAMES_FFMPEG_PATH";
|
|
7
18
|
declare const FFPROBE_PATH_ENV = "HYPERFRAMES_FFPROBE_PATH";
|
|
8
19
|
type FfBinaryName = "ffmpeg" | "ffprobe";
|
|
@@ -21,15 +32,17 @@ interface FindFfBinaryOptions {
|
|
|
21
32
|
}
|
|
22
33
|
/**
|
|
23
34
|
* Resolve an FFmpeg-family binary: env override first, then a native
|
|
24
|
-
* PATH scan on Windows or `which` plus PATH scan on Unix,
|
|
25
|
-
* then
|
|
26
|
-
*
|
|
35
|
+
* PATH scan on Windows or `which` plus PATH scan on Unix, then well-known Unix install dirs,
|
|
36
|
+
* then an `@ffmpeg-installer`/`@ffprobe-installer` package installed next to HyperFrames.
|
|
37
|
+
* Discovery never returns a file in the working directory (see trustedExecutable.ts).
|
|
27
38
|
* A found binary is cached for the process lifetime; a miss only for a few
|
|
28
39
|
* seconds, so a long-running server sees an install made after it started. The env
|
|
29
40
|
* override is re-read on every call.
|
|
30
41
|
*/
|
|
31
42
|
declare function findFfBinary(name: FfBinaryName, options?: FindFfBinaryOptions): string | undefined;
|
|
43
|
+
/** {@link findFfBinary}, or an ENOENT error naming the override. Never the bare name for the OS to look up. */
|
|
44
|
+
declare function requireFfBinary(name: FfBinaryName): string;
|
|
32
45
|
/** Test hook: drop cached system lookups so resolution can be re-exercised. */
|
|
33
46
|
declare function clearFfBinaryLookupCache(): void;
|
|
34
47
|
|
|
35
|
-
export { FFMPEG_PATH_ENV, FFPROBE_PATH_ENV, type FfBinaryName, type FindFfBinaryOptions, clearFfBinaryLookupCache, findFfBinary, getSkippedX86Binary, isX86OnlyMachO };
|
|
48
|
+
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,81 @@
|
|
|
1
1
|
// src/ffBinaries.ts
|
|
2
|
-
import { execFileSync } from "child_process";
|
|
3
|
-
import { accessSync, closeSync, constants, existsSync, openSync, readSync } from "fs";
|
|
2
|
+
import { execFileSync as execFileSync2 } from "child_process";
|
|
3
|
+
import { accessSync as accessSync2, closeSync, constants as constants2, existsSync as existsSync2, openSync, readSync } from "fs";
|
|
4
4
|
import { createRequire } from "module";
|
|
5
|
-
import { basename,
|
|
5
|
+
import { basename, dirname as dirname2, join as join2, resolve as resolve2 } from "path";
|
|
6
|
+
|
|
7
|
+
// src/trustedExecutable.ts
|
|
8
|
+
import { execFileSync } from "child_process";
|
|
9
|
+
import { accessSync, constants, existsSync, realpathSync } from "fs";
|
|
10
|
+
import { homedir } from "os";
|
|
11
|
+
import { delimiter, dirname, isAbsolute, join, relative, resolve, sep } from "path";
|
|
12
|
+
function comparable(path) {
|
|
13
|
+
let full = resolve(path);
|
|
14
|
+
try {
|
|
15
|
+
full = realpathSync.native(full);
|
|
16
|
+
} catch {
|
|
17
|
+
full = resolve(path);
|
|
18
|
+
}
|
|
19
|
+
return process.platform === "win32" ? full.toLowerCase() : full;
|
|
20
|
+
}
|
|
21
|
+
function contains(parent, child) {
|
|
22
|
+
const rel = relative(parent, child);
|
|
23
|
+
return rel === "" || rel !== ".." && !rel.startsWith(`..${sep}`) && !isAbsolute(rel);
|
|
24
|
+
}
|
|
25
|
+
function isTrustedDirectory(dir) {
|
|
26
|
+
if (!dir || !isAbsolute(dir)) return false;
|
|
27
|
+
const target = comparable(dir);
|
|
28
|
+
const cwd = comparable(process.cwd());
|
|
29
|
+
if (target === cwd) return false;
|
|
30
|
+
return contains(cwd, comparable(homedir())) || !contains(cwd, target);
|
|
31
|
+
}
|
|
32
|
+
function isTrustedExecutablePath(file) {
|
|
33
|
+
return isAbsolute(file) && isTrustedDirectory(dirname(file));
|
|
34
|
+
}
|
|
35
|
+
function trustedPathDirs(pathValue = process.env.PATH ?? "") {
|
|
36
|
+
const entries = pathValue.split(delimiter);
|
|
37
|
+
return [...new Set(entries.filter((dir) => isTrustedDirectory(dir)))];
|
|
38
|
+
}
|
|
39
|
+
function windowsExtensions() {
|
|
40
|
+
const listed = (process.env.PATHEXT ?? ".COM;.EXE;.BAT;.CMD").split(";").map((ext) => ext.trim().toLowerCase()).filter(Boolean);
|
|
41
|
+
return [.../* @__PURE__ */ new Set([".exe", ...listed])];
|
|
42
|
+
}
|
|
43
|
+
function isExecutableFile(file) {
|
|
44
|
+
if (process.platform === "win32") return existsSync(file);
|
|
45
|
+
try {
|
|
46
|
+
accessSync(file, constants.X_OK);
|
|
47
|
+
return true;
|
|
48
|
+
} catch {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function scanTrustedPath(name) {
|
|
53
|
+
const extensions = process.platform === "win32" ? windowsExtensions() : [""];
|
|
54
|
+
for (const dir of trustedPathDirs()) {
|
|
55
|
+
for (const ext of extensions) {
|
|
56
|
+
const candidate = join(dir, `${name}${ext}`);
|
|
57
|
+
if (isExecutableFile(candidate)) return candidate;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return void 0;
|
|
61
|
+
}
|
|
62
|
+
function findTrustedExecutable(name) {
|
|
63
|
+
if (process.platform === "win32") return scanTrustedPath(name);
|
|
64
|
+
let listed;
|
|
65
|
+
try {
|
|
66
|
+
listed = execFileSync("which", [name], {
|
|
67
|
+
encoding: "utf-8",
|
|
68
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
69
|
+
timeout: 5e3
|
|
70
|
+
}).split(/\r?\n/).map((line) => line.trim()).find(Boolean);
|
|
71
|
+
} catch {
|
|
72
|
+
return void 0;
|
|
73
|
+
}
|
|
74
|
+
if (!listed) return void 0;
|
|
75
|
+
return isTrustedExecutablePath(listed) ? listed : scanTrustedPath(name);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// src/ffBinaries.ts
|
|
6
79
|
var FFMPEG_PATH_ENV = "HYPERFRAMES_FFMPEG_PATH";
|
|
7
80
|
var FFPROBE_PATH_ENV = "HYPERFRAMES_FFPROBE_PATH";
|
|
8
81
|
var ENV_BY_NAME = {
|
|
@@ -36,7 +109,7 @@ function isX86OnlyMachO(file) {
|
|
|
36
109
|
return header.readUInt32LE(0) === 4277009103 && header.readUInt32LE(4) === MACHO_CPU_X86_64;
|
|
37
110
|
}
|
|
38
111
|
function runsOnThisMac(candidate) {
|
|
39
|
-
if (process.platform !== "darwin" || process.arch !== "arm64" ||
|
|
112
|
+
if (process.platform !== "darwin" || process.arch !== "arm64" || existsSync2(ROSETTA_RUNTIME)) {
|
|
40
113
|
return true;
|
|
41
114
|
}
|
|
42
115
|
if (!isX86OnlyMachO(candidate)) return true;
|
|
@@ -49,17 +122,16 @@ function getSkippedX86Binary(name) {
|
|
|
49
122
|
return skippedX86Binaries.get(name);
|
|
50
123
|
}
|
|
51
124
|
function isExecutablePathCandidate(candidate) {
|
|
52
|
-
if (process.platform === "win32") return
|
|
125
|
+
if (process.platform === "win32") return existsSync2(candidate);
|
|
53
126
|
try {
|
|
54
|
-
|
|
127
|
+
accessSync2(candidate, constants2.X_OK);
|
|
55
128
|
return runsOnThisMac(candidate);
|
|
56
129
|
} catch {
|
|
57
130
|
return false;
|
|
58
131
|
}
|
|
59
132
|
}
|
|
60
133
|
function scanPath(name) {
|
|
61
|
-
const
|
|
62
|
-
const searchDirs = (pathValue ? pathValue.split(delimiter) : []).filter((dir) => isAbsolute(dir));
|
|
134
|
+
const searchDirs = trustedPathDirs();
|
|
63
135
|
if (searchDirs.length === 0) return void 0;
|
|
64
136
|
const extensions = process.platform === "win32" ? [
|
|
65
137
|
".exe",
|
|
@@ -69,9 +141,9 @@ function scanPath(name) {
|
|
|
69
141
|
""
|
|
70
142
|
] : [""];
|
|
71
143
|
const candidates = [];
|
|
72
|
-
for (const dir of
|
|
144
|
+
for (const dir of searchDirs) {
|
|
73
145
|
for (const ext of extensions) {
|
|
74
|
-
const candidate =
|
|
146
|
+
const candidate = join2(dir, `${name}${ext}`);
|
|
75
147
|
if (isExecutablePathCandidate(candidate)) candidates.push(candidate);
|
|
76
148
|
}
|
|
77
149
|
}
|
|
@@ -81,17 +153,15 @@ var COMMON_BIN_DIRS = process.platform === "win32" ? [] : ["/opt/homebrew/bin",
|
|
|
81
153
|
function findInCommonDirsOrInstallerPackage(name) {
|
|
82
154
|
for (const dir of COMMON_BIN_DIRS) {
|
|
83
155
|
const candidate = `${dir}/${name}`;
|
|
84
|
-
if (
|
|
156
|
+
if (isTrustedExecutablePath(candidate) && existsSync2(candidate) && runsOnThisMac(candidate)) {
|
|
157
|
+
return candidate;
|
|
158
|
+
}
|
|
85
159
|
}
|
|
86
160
|
return findInInstallerPackage(name);
|
|
87
161
|
}
|
|
88
162
|
function binaryFileName(name) {
|
|
89
163
|
return process.platform === "win32" ? `${name}.exe` : name;
|
|
90
164
|
}
|
|
91
|
-
function findInProjectLocalBin(name) {
|
|
92
|
-
const candidate = resolve(".hyperframes", "bin", binaryFileName(name));
|
|
93
|
-
return existsSync(candidate) && runsOnThisMac(candidate) ? candidate : void 0;
|
|
94
|
-
}
|
|
95
165
|
function tryResolve(fromFile, request) {
|
|
96
166
|
try {
|
|
97
167
|
return createRequire(fromFile).resolve(request);
|
|
@@ -100,12 +170,12 @@ function tryResolve(fromFile, request) {
|
|
|
100
170
|
}
|
|
101
171
|
}
|
|
102
172
|
function findInInstallerPackage(name) {
|
|
103
|
-
const project =
|
|
173
|
+
const project = import.meta.url;
|
|
104
174
|
const platformManifest = `@${name}-installer/${process.platform}-${process.arch}/package.json`;
|
|
105
175
|
const installer = tryResolve(project, `@${name}-installer/${name}/package.json`);
|
|
106
176
|
const manifest = (installer && tryResolve(installer, platformManifest)) ?? tryResolve(project, platformManifest);
|
|
107
|
-
const candidate = manifest &&
|
|
108
|
-
return candidate && isExecutablePathCandidate(candidate) ? candidate : void 0;
|
|
177
|
+
const candidate = manifest && join2(dirname2(manifest), binaryFileName(name));
|
|
178
|
+
return candidate && isTrustedExecutablePath(candidate) && isExecutablePathCandidate(candidate) ? candidate : void 0;
|
|
109
179
|
}
|
|
110
180
|
function searchSystem(name) {
|
|
111
181
|
let found;
|
|
@@ -113,18 +183,17 @@ function searchSystem(name) {
|
|
|
113
183
|
found = scanPath(name);
|
|
114
184
|
} else {
|
|
115
185
|
try {
|
|
116
|
-
const output =
|
|
186
|
+
const output = execFileSync2("which", [name], {
|
|
117
187
|
encoding: "utf-8",
|
|
118
188
|
stdio: ["pipe", "pipe", "pipe"],
|
|
119
189
|
timeout: 5e3
|
|
120
190
|
});
|
|
121
191
|
const candidate = chooseBestPathCandidate(name, output.split(/\r?\n/));
|
|
122
|
-
found = candidate && isExecutablePathCandidate(candidate) ? candidate : scanPath(name);
|
|
192
|
+
found = candidate && isTrustedExecutablePath(candidate) && isExecutablePathCandidate(candidate) ? candidate : scanPath(name);
|
|
123
193
|
} catch {
|
|
124
194
|
found = scanPath(name);
|
|
125
195
|
}
|
|
126
196
|
}
|
|
127
|
-
found ??= findInProjectLocalBin(name);
|
|
128
197
|
found ??= findInCommonDirsOrInstallerPackage(name);
|
|
129
198
|
return found;
|
|
130
199
|
}
|
|
@@ -137,18 +206,24 @@ function lookupOnSystem(name) {
|
|
|
137
206
|
lastMissAt.set(name, Date.now());
|
|
138
207
|
return void 0;
|
|
139
208
|
}
|
|
140
|
-
const resolved =
|
|
209
|
+
const resolved = resolve2(found);
|
|
141
210
|
pathLookupCache.set(name, resolved);
|
|
142
211
|
return resolved;
|
|
143
212
|
}
|
|
144
213
|
function findFfBinary(name, options = {}) {
|
|
145
214
|
const configured = process.env[ENV_BY_NAME[name]]?.trim();
|
|
146
215
|
if (configured) {
|
|
147
|
-
if (options.configuredMustExist && !
|
|
148
|
-
return
|
|
216
|
+
if (options.configuredMustExist && !existsSync2(configured)) return void 0;
|
|
217
|
+
return resolve2(configured);
|
|
149
218
|
}
|
|
150
219
|
return lookupOnSystem(name);
|
|
151
220
|
}
|
|
221
|
+
function requireFfBinary(name) {
|
|
222
|
+
const found = findFfBinary(name);
|
|
223
|
+
if (found) return found;
|
|
224
|
+
const message = `[FFmpeg] ${name} not found. Install FFmpeg or set ${ENV_BY_NAME[name]} to its absolute path.`;
|
|
225
|
+
throw Object.assign(new Error(message), { code: "ENOENT" });
|
|
226
|
+
}
|
|
152
227
|
function clearFfBinaryLookupCache() {
|
|
153
228
|
pathLookupCache.clear();
|
|
154
229
|
lastMissAt.clear();
|
|
@@ -159,6 +234,11 @@ export {
|
|
|
159
234
|
FFPROBE_PATH_ENV,
|
|
160
235
|
clearFfBinaryLookupCache,
|
|
161
236
|
findFfBinary,
|
|
237
|
+
findTrustedExecutable,
|
|
162
238
|
getSkippedX86Binary,
|
|
163
|
-
|
|
239
|
+
isTrustedDirectory,
|
|
240
|
+
isTrustedExecutablePath,
|
|
241
|
+
isX86OnlyMachO,
|
|
242
|
+
requireFfBinary,
|
|
243
|
+
trustedPathDirs
|
|
164
244
|
};
|
|
@@ -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.34",
|
|
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.34"
|
|
143
143
|
},
|
|
144
144
|
"scripts": {
|
|
145
145
|
"build": "tsup",
|