@hyperframes/core 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.
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export declare function getVariables<T extends Record<string, unknown> = Record<string, unknown>>(): Partial<T>;
|
|
2
|
+
/** The raw `data-composition-variables` text of each top-level declarer, in precedence order (later wins). */
|
|
3
|
+
export declare function getDeclaredVariableSources(): string[];
|
|
2
4
|
export declare function warnUnknownEnumValues(declarer: Element | null | undefined, resolved: Record<string, unknown>, compositionId?: string): void;
|
|
3
5
|
/** Test-only: clear the per-page dedupe set. */
|
|
4
6
|
export declare function resetUnknownEnumWarnings(): void;
|
|
@@ -24,16 +24,7 @@ import { scopedVariablesFor } from "./variableScope.js";
|
|
|
24
24
|
export function getVariables() {
|
|
25
25
|
if (typeof document === "undefined")
|
|
26
26
|
return {};
|
|
27
|
-
|
|
28
|
-
// overrides. A sub-composition's declaration is its own scope's, read from its scoped table.
|
|
29
|
-
const declarers = new Set();
|
|
30
|
-
if (document.documentElement?.hasAttribute("data-composition-variables")) {
|
|
31
|
-
declarers.add(document.documentElement);
|
|
32
|
-
}
|
|
33
|
-
for (const el of Array.from(document.querySelectorAll("[data-composition-variables]"))) {
|
|
34
|
-
if (!scopedVariablesFor(el))
|
|
35
|
-
declarers.add(el);
|
|
36
|
-
}
|
|
27
|
+
const declarers = topLevelDeclarers();
|
|
37
28
|
const declaredDefaults = {};
|
|
38
29
|
for (const el of declarers) {
|
|
39
30
|
Object.assign(declaredDefaults, readDeclaredDefaults(el));
|
|
@@ -44,6 +35,27 @@ export function getVariables() {
|
|
|
44
35
|
warnUnknownEnumValues(el, merged);
|
|
45
36
|
return merged;
|
|
46
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Top-level declarers: `<html>` first, then others outside a sub-composition's scope; a later one wins.
|
|
40
|
+
* `getVariables` merges these, and `getDeclaredVariableSources` hands the same elements to a strict render.
|
|
41
|
+
*/
|
|
42
|
+
function topLevelDeclarers() {
|
|
43
|
+
const declarers = new Set();
|
|
44
|
+
if (document.documentElement?.hasAttribute("data-composition-variables")) {
|
|
45
|
+
declarers.add(document.documentElement);
|
|
46
|
+
}
|
|
47
|
+
for (const el of Array.from(document.querySelectorAll("[data-composition-variables]"))) {
|
|
48
|
+
if (!scopedVariablesFor(el))
|
|
49
|
+
declarers.add(el);
|
|
50
|
+
}
|
|
51
|
+
return declarers;
|
|
52
|
+
}
|
|
53
|
+
/** The raw `data-composition-variables` text of each top-level declarer, in precedence order (later wins). */
|
|
54
|
+
export function getDeclaredVariableSources() {
|
|
55
|
+
if (typeof document === "undefined")
|
|
56
|
+
return [];
|
|
57
|
+
return Array.from(topLevelDeclarers(), (el) => el.getAttribute("data-composition-variables") ?? "");
|
|
58
|
+
}
|
|
47
59
|
/**
|
|
48
60
|
* An enum variable given a value outside its declared `options` is coerced to
|
|
49
61
|
* the composition's default by the composition's own guard. That fallback is
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyperframes/core",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.34",
|
|
4
4
|
"description": "",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -437,9 +437,9 @@
|
|
|
437
437
|
"linkedom": "^0.18.12",
|
|
438
438
|
"postcss": "^8.5.8",
|
|
439
439
|
"wawoff2": "^2.0.1",
|
|
440
|
-
"@hyperframes/lint": "0.9.
|
|
441
|
-
"@hyperframes/studio-server": "0.9.
|
|
442
|
-
"@hyperframes/parsers": "0.9.
|
|
440
|
+
"@hyperframes/lint": "0.9.34",
|
|
441
|
+
"@hyperframes/studio-server": "0.9.34",
|
|
442
|
+
"@hyperframes/parsers": "0.9.34"
|
|
443
443
|
},
|
|
444
444
|
"devDependencies": {
|
|
445
445
|
"@fontsource/archivo-black": "^5.2.8",
|