@hyperframes/core 0.8.205 → 0.8.206
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/compiler/compositionScoping.d.ts +2 -0
- package/dist/compiler/compositionScoping.js +4 -0
- package/dist/compiler/htmlBundler.js +3 -1
- package/dist/compiler/inlineSubCompositions.js +2 -2
- package/dist/compiler/pngColourTags.d.ts +2 -0
- package/dist/compiler/pngColourTags.js +27 -0
- package/dist/generated/runtime-inline.js +1 -1
- package/dist/generators/hyperframes.js +4 -1
- package/dist/hyperframe.runtime.iife.js +66 -64
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/runtime/media.js +4 -3
- package/dist/runtime/mediaClock.d.ts +2 -0
- package/dist/runtime/mediaClock.js +4 -0
- package/dist/runtime/preloadMedia.js +2 -1
- package/dist/runtime/startResolver.js +6 -8
- package/package.json +12 -4
|
@@ -13,6 +13,8 @@ export declare function hoistFontFaceRules(styleTexts: string[]): {
|
|
|
13
13
|
styles: string[];
|
|
14
14
|
faces: string[];
|
|
15
15
|
};
|
|
16
|
+
export declare const AUTHORED_SOURCE_BEGIN = "/*hf-authored-begin*/";
|
|
17
|
+
export declare const AUTHORED_SOURCE_END = "/*hf-authored-end*/";
|
|
16
18
|
export declare function scopedModulePrelude(timelineCompositionId: string, compositionSrc?: string | null): string;
|
|
17
19
|
export declare function wrapScopedCompositionScript(source: string, compositionId: string, errorLabel?: string, scopeSelectorOverride?: string, timelineCompositionId?: string, authoredRootId?: string | null, compositionSrc?: string | null): string;
|
|
18
20
|
export declare function wrapInlineScriptWithErrorBoundary(source: string, errorLabel: string): string;
|
|
@@ -295,6 +295,8 @@ const SCOPED_HYPERFRAMES_EXPRESSION = `!__hfBaseHyperframes
|
|
|
295
295
|
return scoped ? Object.assign({}, scoped) : {};
|
|
296
296
|
},
|
|
297
297
|
})`;
|
|
298
|
+
export const AUTHORED_SOURCE_BEGIN = "/*hf-authored-begin*/";
|
|
299
|
+
export const AUTHORED_SOURCE_END = "/*hf-authored-end*/";
|
|
298
300
|
export function scopedModulePrelude(timelineCompositionId, compositionSrc) {
|
|
299
301
|
return `const __hyperframes = (function(__hfBaseHyperframes, __hfTimelineCompId, __hfCompositionSrc) {
|
|
300
302
|
return ${SCOPED_HYPERFRAMES_EXPRESSION};
|
|
@@ -581,7 +583,9 @@ export function wrapScopedCompositionScript(source, compositionId, errorLabel =
|
|
|
581
583
|
if (typeof report === "function") report("start", __hfCompositionSrc || "index.html");
|
|
582
584
|
try {
|
|
583
585
|
(function(document, gsap, window, __hyperframes) {
|
|
586
|
+
${AUTHORED_SOURCE_BEGIN}
|
|
584
587
|
${source.replace(/<\/(script)/gi, "<\\/$1")}
|
|
588
|
+
${AUTHORED_SOURCE_END}
|
|
585
589
|
}).call(window, __hfScopedDocument, __hfScopedGsap, __hfScopedWindow, __hfScopedHyperframes);
|
|
586
590
|
} catch (_err) {
|
|
587
591
|
console.error(__hfErrorLabel, __hfCompId, _err);
|
|
@@ -2,6 +2,7 @@ import { createHash } from "node:crypto";
|
|
|
2
2
|
import { compositionStyle, cssStyleMergeKey, deferScriptsUntilFonts, isAlwaysAppliedStyle, headStyleRuns, INLINED_FILE_ATTR, inlineScriptRuns, styleElementsFor, } from "./scriptRuns.js";
|
|
3
3
|
import { countPageRoot, executableScripts, isJavaScriptType, planCompositionAssembly, } from "./compositionAssembly.js";
|
|
4
4
|
import { SCENE_FONTS_ATTR, SCENE_PART_ATTR } from "../sceneParts.js";
|
|
5
|
+
import { stripSdrPngColourTags } from "./pngColourTags.js";
|
|
5
6
|
import { ensureExternalScriptTag, readExternalScriptAttributes, } from "./externalScripts.js";
|
|
6
7
|
import { emitMountedModuleScripts, parseImportMap } from "./importMaps.js";
|
|
7
8
|
import { markFlattenedInnerRoot } from "../runtime/flattenedRoot.js";
|
|
@@ -313,7 +314,8 @@ function createAssetInliner(resolveProjectPath, inlineAssets) {
|
|
|
313
314
|
const byteLength = safeStatSize(filePath);
|
|
314
315
|
if (byteLength !== null && byteLength > MAX_INLINE_ASSET_BYTES)
|
|
315
316
|
return { tooLarge: byteLength };
|
|
316
|
-
const
|
|
317
|
+
const read = safeReadFileBuffer(filePath);
|
|
318
|
+
const content = read && mimeType === "image/png" ? (stripSdrPngColourTags(read) ?? read) : read;
|
|
317
319
|
return {
|
|
318
320
|
dataUrl: content === null ? null : `data:${mimeType};base64,${content.toString("base64")}`,
|
|
319
321
|
};
|
|
@@ -13,7 +13,7 @@ import { compositionStyle, cssStyleMergeKey, hasSameLink, } from "./scriptRuns.j
|
|
|
13
13
|
*/
|
|
14
14
|
import { rewriteAssetPath, rewriteAssetPaths, rewriteCssAssetUrls, rewriteInlineStyleAssetUrls, } from "./rewriteSubCompPaths.js";
|
|
15
15
|
import { warnUnknownEnumValues } from "../runtime/getVariables.js";
|
|
16
|
-
import { createCompositionCssScoper, wrapInlineScriptWithErrorBoundary, scopedModulePrelude, wrapScopedCompositionScript, } from "./compositionScoping.js";
|
|
16
|
+
import { createCompositionCssScoper, AUTHORED_SOURCE_BEGIN, AUTHORED_SOURCE_END, wrapInlineScriptWithErrorBoundary, scopedModulePrelude, wrapScopedCompositionScript, } from "./compositionScoping.js";
|
|
17
17
|
import { namespaceCollidingSvgIds, rewriteSvgIdReferencesInCss, } from "./svgIdNamespacing.js";
|
|
18
18
|
import { checkSubCompositionUsability, resolveSubCompositionContent, } from "@hyperframes/parsers/sub-composition-validity";
|
|
19
19
|
import { enumerateNestedCompositionHosts, planCompositionAssembly, extractedCompositionAssets, } from "./compositionAssembly.js";
|
|
@@ -419,7 +419,7 @@ export function inlineSubCompositions(document, hosts, options) {
|
|
|
419
419
|
const prelude = scriptCompositionId
|
|
420
420
|
? scopedModulePrelude(runtimeCompId || scopeCompId || scriptCompositionId, src)
|
|
421
421
|
: "";
|
|
422
|
-
moduleScripts.push(prelude
|
|
422
|
+
moduleScripts.push(`${prelude}${AUTHORED_SOURCE_BEGIN}\n${scriptEl.textContent || ""}\n${AUTHORED_SOURCE_END}`);
|
|
423
423
|
}
|
|
424
424
|
else if (externalSrc) {
|
|
425
425
|
if (!externalScriptSrcs.includes(externalSrc)) {
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const PNG_SIGNATURE = Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]);
|
|
2
|
+
const PNG_SIGNATURE_BYTES = PNG_SIGNATURE.length;
|
|
3
|
+
const CHUNK_OVERHEAD_BYTES = 12;
|
|
4
|
+
const REMOVED_CHUNKS = new Set(["cICP", "gAMA", "cHRM"]);
|
|
5
|
+
const HDR_CICP_TRANSFERS = new Set([16, 18]);
|
|
6
|
+
/** An SDR PNG's copy without the tags that make Chrome re-map its pixels; null if none apply or it is HDR. */
|
|
7
|
+
export function stripSdrPngColourTags(png) {
|
|
8
|
+
const bytes = Buffer.from(png.buffer, png.byteOffset, png.byteLength);
|
|
9
|
+
if (!bytes.subarray(0, PNG_SIGNATURE_BYTES).equals(PNG_SIGNATURE))
|
|
10
|
+
return null;
|
|
11
|
+
const kept = [bytes.subarray(0, PNG_SIGNATURE_BYTES)];
|
|
12
|
+
let removed = false;
|
|
13
|
+
for (let at = PNG_SIGNATURE_BYTES; at + CHUNK_OVERHEAD_BYTES <= bytes.length;) {
|
|
14
|
+
const end = at + CHUNK_OVERHEAD_BYTES + bytes.readUInt32BE(at);
|
|
15
|
+
if (end > bytes.length)
|
|
16
|
+
return null;
|
|
17
|
+
const type = bytes.toString("latin1", at + 4, at + 8);
|
|
18
|
+
if (type === "cICP" && HDR_CICP_TRANSFERS.has(bytes[at + 9] ?? 0))
|
|
19
|
+
return null;
|
|
20
|
+
if (REMOVED_CHUNKS.has(type))
|
|
21
|
+
removed = true;
|
|
22
|
+
else
|
|
23
|
+
kept.push(bytes.subarray(at, end));
|
|
24
|
+
at = end;
|
|
25
|
+
}
|
|
26
|
+
return removed ? Buffer.concat(kept) : null;
|
|
27
|
+
}
|