@hyperframes/core 0.9.15 → 0.9.17
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/cacheDir.d.ts +1 -0
- package/dist/cacheDir.js +3 -0
- package/dist/compiler/inlineSubCompositions.js +9 -2
- package/dist/compiler/staticGuard.js +2 -4
- package/dist/compiler/svgIdNamespacing.d.ts +3 -0
- package/dist/compiler/svgIdNamespacing.js +9 -0
- package/dist/compositionReadiness.js +0 -1
- package/dist/generated/position-edits-render-inline.js +1 -1
- package/dist/generated/runtime-inline.js +1 -1
- package/dist/hdrToneMap.d.ts +10 -1
- package/dist/hdrToneMap.js +27 -1
- package/dist/hyperframe.runtime.iife.js +68 -68
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/runtime/clipWindow.d.ts +2 -0
- package/dist/runtime/clipWindow.js +6 -0
- package/dist/runtime/diagnostics.d.ts +6 -0
- package/dist/runtime/diagnostics.js +19 -0
- package/dist/runtime/timeline.d.ts +0 -1
- package/dist/runtime/timeline.js +2 -7
- package/package.json +4 -4
package/dist/cacheDir.d.ts
CHANGED
package/dist/cacheDir.js
CHANGED
|
@@ -4,3 +4,6 @@ export function hyperframesCacheDir(...parts) {
|
|
|
4
4
|
const named = process.env["HYPERFRAMES_CACHE_DIR"];
|
|
5
5
|
return join(named ? resolve(named) : join(homedir(), ".cache", "hyperframes"), ...parts);
|
|
6
6
|
}
|
|
7
|
+
export function namedCacheDir(...parts) {
|
|
8
|
+
return process.env["HYPERFRAMES_CACHE_DIR"] ? hyperframesCacheDir(...parts) : undefined;
|
|
9
|
+
}
|
|
@@ -14,7 +14,7 @@ import { compositionStyle, cssStyleMergeKey, hasSameLink, } from "./scriptRuns.j
|
|
|
14
14
|
import { rewriteAssetPath, rewriteAssetPaths, rewriteCssAssetUrls, rewriteInlineStyleAssetUrls, } from "./rewriteSubCompPaths.js";
|
|
15
15
|
import { warnUnknownEnumValues } from "../runtime/getVariables.js";
|
|
16
16
|
import { createCompositionCssScoper, AUTHORED_SOURCE_BEGIN, AUTHORED_SOURCE_END, wrapInlineScriptWithErrorBoundary, scopedModulePrelude, wrapScopedCompositionScript, } from "./compositionScoping.js";
|
|
17
|
-
import { namespaceCollidingSvgIds, rewriteSvgIdReferencesInCss, } from "./svgIdNamespacing.js";
|
|
17
|
+
import { namespaceCollidingSvgIds, sceneClipRoots, rewriteSvgIdReferencesInCss, } from "./svgIdNamespacing.js";
|
|
18
18
|
import { checkSubCompositionUsability, resolveSubCompositionContent, } from "@hyperframes/parsers/sub-composition-validity";
|
|
19
19
|
import { enumerateNestedCompositionHosts, planCompositionAssembly, extractedCompositionAssets, } from "./compositionAssembly.js";
|
|
20
20
|
import { SCENE_NO_SWAP_ATTR, SCENE_PART_ATTR } from "../sceneParts.js";
|
|
@@ -544,6 +544,8 @@ export function inlineSubCompositions(document, hosts, options) {
|
|
|
544
544
|
// `<style>` text gets the same substitution its DOM just received. See
|
|
545
545
|
// svgIdNamespacing.ts for why this is a rename, unlike the sibling
|
|
546
546
|
// getElementById/media-id fixes.
|
|
547
|
+
const hostRoots = svgIdScopes.map(({ root }) => root);
|
|
548
|
+
const clips = sceneClipRoots(document, hostRoots);
|
|
547
549
|
const svgIdMaps = namespaceCollidingSvgIds(document, [
|
|
548
550
|
...svgIdScopes.map(({ root, namespace, exclude, styleStart, styleEnd }) => ({
|
|
549
551
|
root,
|
|
@@ -555,9 +557,14 @@ export function inlineSubCompositions(document, hosts, options) {
|
|
|
555
557
|
root: document.documentElement,
|
|
556
558
|
namespace: "",
|
|
557
559
|
referenceTarget: "document",
|
|
558
|
-
exclude:
|
|
560
|
+
exclude: [...hostRoots, ...clips],
|
|
559
561
|
cssTexts: rootStyles.map((style) => style.textContent ?? ""),
|
|
560
562
|
},
|
|
563
|
+
...clips.map((root, index) => ({
|
|
564
|
+
root,
|
|
565
|
+
namespace: `clip-${index}`,
|
|
566
|
+
exclude: hostRoots.filter((host) => root.contains(host)),
|
|
567
|
+
})),
|
|
561
568
|
]);
|
|
562
569
|
svgIdMaps.slice(0, svgIdScopes.length).forEach((idMap, index) => {
|
|
563
570
|
const { styleStart, styleEnd } = svgIdScopes[index];
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { linkedSources, lintHyperframeHtml } from "@hyperframes/lint";
|
|
2
2
|
export async function validateHyperframeHtmlContract(html, project) {
|
|
3
|
-
const result = await lintHyperframeHtml(html, project &&
|
|
4
|
-
externalStyles: collectExternalStyles(project.dir, html, project.compSrcPath),
|
|
5
|
-
});
|
|
3
|
+
const result = await lintHyperframeHtml(html, project && linkedSources(project.dir, html, project.compSrcPath));
|
|
6
4
|
const missingKeys = result.findings
|
|
7
5
|
.filter((finding) => finding.severity === "error")
|
|
8
6
|
.map((finding) => finding.message);
|
|
@@ -45,6 +45,9 @@ export interface SvgIdScope {
|
|
|
45
45
|
*/
|
|
46
46
|
cssTexts?: readonly string[];
|
|
47
47
|
}
|
|
48
|
+
/** The outermost timed clips holding an `<svg>` outside every composition host. Each is its own id scope, as an
|
|
49
|
+
* inlined composition is, so two scenes drawn with the same ids each resolve their own `url(#id)` and `href`. */
|
|
50
|
+
export declare function sceneClipRoots(document: SvgIdQueryable, hosts: readonly Element[]): Element[];
|
|
48
51
|
/**
|
|
49
52
|
* Rename every colliding, natively-referenced SVG id across the inlined
|
|
50
53
|
* composition instances in `scopes` and rewrite each instance's attribute
|
|
@@ -312,6 +312,15 @@ function applyRenames(resolved, idMap) {
|
|
|
312
312
|
rewriteElementIdReferences(el, idMap);
|
|
313
313
|
}
|
|
314
314
|
}
|
|
315
|
+
const CLIP_SELECTOR = "[data-start]:not([data-composition-id]):not([data-composition-src])";
|
|
316
|
+
/** The outermost timed clips holding an `<svg>` outside every composition host. Each is its own id scope, as an
|
|
317
|
+
* inlined composition is, so two scenes drawn with the same ids each resolve their own `url(#id)` and `href`. */
|
|
318
|
+
export function sceneClipRoots(document, hosts) {
|
|
319
|
+
return [...document.querySelectorAll(CLIP_SELECTOR)].filter((clip) => !clip.parentElement?.closest(CLIP_SELECTOR) &&
|
|
320
|
+
!!clip.parentElement?.closest("[data-composition-id]") &&
|
|
321
|
+
!isExcluded(clip, hosts) &&
|
|
322
|
+
!!clip.querySelector("svg"));
|
|
323
|
+
}
|
|
315
324
|
/**
|
|
316
325
|
* Rename every colliding, natively-referenced SVG id across the inlined
|
|
317
326
|
* composition instances in `scopes` and rewrite each instance's attribute
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Generated by scripts/build-position-edits-render.ts; do not edit.
|
|
2
|
-
const POSITION_EDITS_RENDER_IIFE = '"use strict";(()=>{function x(){return globalThis}function
|
|
2
|
+
const POSITION_EDITS_RENDER_IIFE = '"use strict";(()=>{function x(){return globalThis}function R(e,t){if(typeof window>"u")return;let o=x(),r=o.__hf?.onSwallowed;if(r)try{r({label:e,error:t})}catch(s){}(o.__hfDebug||o.__HYPERFRAMES_DEBUG)&&console.debug(`[hyperframes] ${e} swallowed:`,t)}var T=null;function P(e,t){if(T)try{T({source:"hf-preview",type:"analytics",event:e,properties:t??{}})}catch(o){R("runtime.analytics.site1",o)}}var I="http://www.w3.org/1999/xhtml";function N(e){return e!=null&&e.nodeType===1}function k(e){return N(e)&&(e.namespaceURI===I||e.namespaceURI==="http://www.w3.org/2000/svg")}var w="data-hf-edit-base-x",y="data-hf-edit-base-y",m="data-hf-edit-original-translate",_=e=>{let t=parseFloat(e??"");return Number.isFinite(t)?t:0},C=e=>{let t=[],o=0,r="";for(let s of e.trim())s==="("&&(o+=1),s===")"&&(o=Math.max(0,o-1)),/\\s/.test(s)&&o===0?(r&&t.push(r),r=""):r+=s;return r&&t.push(r),t},$=/^-?(?:\\d+(?:\\.\\d+)?|\\.\\d+)px$/,E=(e,t)=>$.test(e)&&$.test(t)?`${parseFloat(e)+parseFloat(t)}px`:`calc(${e} + ${t})`,O=(e,t,o)=>{if(!e||e==="none")return`${t} ${o}`;let[r,s,a]=C(e);if(r===void 0)return`${t} ${o}`;if(s===void 0)return`${E(r,t)} ${o}`;let i=a===void 0?"":` ${a}`;return`${E(r,t)} ${E(s,o)}${i}`},j=e=>{try{e.ownerDocument.defaultView?.gsap?.getProperty?.(e,"x")}catch{}},B=e=>{let t=e.style.getPropertyValue("translate").trim();if(t)return t==="none"?"":t;try{let o=e.ownerDocument.defaultView,r=o?o.getComputedStyle(e).getPropertyValue("translate").trim():"";return r==="none"?"":r}catch{return""}},b=new WeakMap;function V(e,t){let o=b.get(e);if(!t?.force&&o!==void 0&&e.style.getPropertyValue("translate")!==o){P("position_edit_fold_skipped",{hfId:e.getAttribute("data-hf-id")});return}let r=_(e.getAttribute("data-x"))-_(e.getAttribute(w)),s=_(e.getAttribute("data-y"))-_(e.getAttribute(y));e.hasAttribute(m)||e.setAttribute(m,B(e)),o===void 0&&j(e);let a=e.getAttribute(m)??"",i=O(a,`${r}px`,`${s}px`);e.style.setProperty("translate",i),b.set(e,e.style.getPropertyValue("translate"))}function h(e,t){let o=e.querySelectorAll(`[${m}]:not([${w}]):not([${y}])`);for(let a=0;a<o.length;a++){let i=o[a];if(i===void 0||!k(i))continue;let g=i.getAttribute(m)??"";g===""?i.style.removeProperty("translate"):i.style.setProperty("translate",g),i.removeAttribute(m),b.delete(i)}let r=e.querySelectorAll(`[${w}], [${y}]`),s=0;for(let a=0;a<r.length;a++){let i=r[a];i===void 0||!k(i)||(V(i,t),s+=1)}return s}var L="__hfPositionEditsSeekReapplyWrapped",D=new WeakSet,F=new WeakMap,H=new WeakMap;function W(e){let t=e,o=()=>{try{h(t.document)}catch{}},r=n=>typeof n=="function"&&(D.has(n)||!!n[L]),s=n=>{D.add(n);try{Object.defineProperty(n,L,{value:!0})}catch{}},a=n=>{if(typeof n!="function"||r(n))return n;let l=function(...u){let d=n.apply(this,u);return o(),d};return s(l),l},i=(n,l)=>{let u=F.get(n);if(u?.has(l))return!0;let d=Object.getOwnPropertyDescriptor(n,l);if(d?.configurable===!1){let c=n[l];return typeof c=="function"&&(n[l]=a(c),o()),!1}let p=n[l],f=d?.set;return Object.defineProperty(n,l,{configurable:!0,enumerable:d?.enumerable??!0,get:()=>p,set:c=>{p=a(c),f?.call(n,c)}}),p=a(p),u??(u=new Set),u.add(l),F.set(n,u),o(),!0},g=(n,l)=>{let u=H.get(t),d=Object.getOwnPropertyDescriptor(t,n);if(!u?.has(n)){if(d?.configurable===!1){let c=t[n];return c?i(c,l):!1}let f=t[n];Object.defineProperty(t,n,{configurable:!0,enumerable:d?.enumerable??!0,get:()=>f,set:c=>{f=c,f&&i(f,l)}}),u??(u=new Set),u.add(n),H.set(t,u)}let p=t[n];return p?i(p,l):!1},S=()=>{let n=g("__hf","seek"),l=g("__player","renderSeek");return n&&l};if(S())return;let v=120,A=t.setInterval(()=>{if(S()){t.clearInterval(A);return}v-=1,v<=0&&t.clearInterval(A)},50)}function M(){document.querySelector(`[${w}], [${y}]`)&&(h(document),W(window))}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",M,{once:!0}):M();})();\n';
|
|
3
3
|
/** Returns the pre-built position-edits render IIFE as a string constant. */
|
|
4
4
|
export function getPositionEditsRenderScript() {
|
|
5
5
|
return POSITION_EDITS_RENDER_IIFE;
|