@hyperframes/core 0.9.34 → 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.
@@ -57,7 +57,14 @@ export interface BundleOptions {
57
57
  staticGuard?: boolean;
58
58
  /** Called once per build for each project file the build reads or looks for. */
59
59
  onRead?: (filePath: string) => void;
60
+ /**
61
+ * Project files the build never reads; a refused file keeps its authored reference. Git metadata and env files
62
+ * always; `"studio"` also refuses the app's records under `.hyperframes/`, as Studio's file routes do.
63
+ */
64
+ privateFiles?: BundlePrivateFiles;
60
65
  }
66
+ /** Plain data, so the option crosses to a build thread and keys a shared build. */
67
+ export type BundlePrivateFiles = "vcs-and-secrets" | "studio";
61
68
  export declare function bundleToSingleHtml(projectDir: string, options?: BundleOptions): Promise<string>;
62
69
  /**
63
70
  * Compile-time counterpart of the runtime's injectCompositionCssVariables:
@@ -26,7 +26,7 @@ import { validateHyperframeHtmlContract } from "./staticGuard.js";
26
26
  import { getHyperframeRuntimeScript } from "../generated/runtime-inline.js";
27
27
  import { readDeclaredDefaults } from "../runtime/getVariables.js";
28
28
  import { ensureExternalLinkTag, inlineSubCompositions, isLibraryCopy, refuseSwapsReachedByRootScripts, } from "./inlineSubCompositions.js";
29
- import { isSafePath, resolveWithinProject } from "../safePath.js";
29
+ import { isPrivateFileUnder, isSafePath, isStudioPrivatePath, isVcsOrSecretPath, resolveWithinProject, } from "../safePath.js";
30
30
  import { ensureHfIds } from "@hyperframes/parsers/hf-ids";
31
31
  import { readTextFile } from "@hyperframes/parsers/asset-resolution";
32
32
  import { HF_COLOR_GRADING_ATTR } from "../colorGrading.js";
@@ -65,11 +65,18 @@ function isRelativeUrl(url) {
65
65
  }
66
66
  const bundleReads = new AsyncLocalStorage();
67
67
  function noteRead(filePath) {
68
- bundleReads.getStore()?.(filePath);
68
+ bundleReads.getStore()?.noteRead(filePath);
69
+ }
70
+ function readAllowed(filePath) {
71
+ const scope = bundleReads.getStore();
72
+ if (!scope)
73
+ return true;
74
+ const isPrivate = scope.privateFiles === "studio" ? isStudioPrivatePath : isVcsOrSecretPath;
75
+ return !isPrivateFileUnder(scope.projectDir, filePath, isPrivate);
69
76
  }
70
77
  function safeReadFile(filePath) {
71
78
  noteRead(filePath);
72
- if (!existsSync(filePath))
79
+ if (!readAllowed(filePath) || !existsSync(filePath))
73
80
  return null;
74
81
  try {
75
82
  return readTextFile(filePath);
@@ -222,7 +229,7 @@ function inlineCssFile(css, cssFileDir, projectDir, activeImports) {
222
229
  }
223
230
  function safeReadFileBuffer(filePath) {
224
231
  noteRead(filePath);
225
- if (!existsSync(filePath))
232
+ if (!readAllowed(filePath) || !existsSync(filePath))
226
233
  return null;
227
234
  try {
228
235
  return readFileSync(filePath);
@@ -828,18 +835,20 @@ function hoistCompositionScripts(container, opts) {
828
835
  }
829
836
  }
830
837
  export function bundleToSingleHtml(projectDir, options) {
831
- const bundle = () => bundleProject(projectDir, options);
832
838
  const onRead = options?.onRead;
833
- if (!onRead)
834
- return bundle();
835
839
  const noted = new Set();
836
- const noteOnce = (filePath) => {
840
+ const noteRead = (filePath) => {
837
841
  if (noted.has(filePath))
838
842
  return;
839
843
  noted.add(filePath);
840
- onRead(filePath);
844
+ onRead?.(filePath);
845
+ };
846
+ const scope = {
847
+ projectDir,
848
+ privateFiles: options?.privateFiles ?? "vcs-and-secrets",
849
+ noteRead,
841
850
  };
842
- return bundleReads.run(noteOnce, bundle);
851
+ return bundleReads.run(scope, () => bundleProject(projectDir, options));
843
852
  }
844
853
  // A <template> scene has no root or GSAP of its own: bundle it inside the index that mounts it, as render does.
845
854
  function readMountedSceneShell(projectDir, entryFile, entryHtml) {
@@ -853,7 +862,7 @@ function readMountedSceneShell(projectDir, entryFile, entryHtml) {
853
862
  async function bundleProject(projectDir, options) {
854
863
  const entryFile = options?.entryFile ?? "index.html";
855
864
  const indexPath = resolveWithinProject(projectDir, entryFile);
856
- if (!indexPath || !existsSync(indexPath)) {
865
+ if (!indexPath || !readAllowed(indexPath) || !existsSync(indexPath)) {
857
866
  throw new Error(`${entryFile} not found in project directory`);
858
867
  }
859
868
  noteRead(indexPath);
@@ -1,7 +1,7 @@
1
1
  export { resolveTimings, type WordTiming, type ElementAnchor, type AuthoredTiming, type ResolvedTiming, type ResolveTimingsInput, type ResolveTimingsResult, } from "./timingResolver.js";
2
2
  export { compileTimingAttrs, injectDurations, extractResolvedMedia, clampDurations, shouldClampMediaDuration, shouldClampResolvedMediaDuration, type UnresolvedElement, type ResolvedDuration, type ResolvedMediaElement, type CompilationResult, } from "./timingCompiler.js";
3
3
  export { compileHtml, type MediaDurationProber } from "./htmlCompiler.js";
4
- export { assignBundledRuntimeCompositionIds, type BundledHostCompositionIdentity, bundleToSingleHtml, type BundleOptions, type BundleScriptProvenance, prepareFlattenedInnerRoot, FLATTENED_INNER_ROOT_STRIP_ATTRS, emitRootCompositionVariableStyles, parsesAsScript, } from "./htmlBundler.js";
4
+ export { assignBundledRuntimeCompositionIds, type BundledHostCompositionIdentity, bundleToSingleHtml, type BundleOptions, type BundlePrivateFiles, type BundleScriptProvenance, prepareFlattenedInnerRoot, FLATTENED_INNER_ROOT_STRIP_ATTRS, emitRootCompositionVariableStyles, parsesAsScript, } from "./htmlBundler.js";
5
5
  export { readDeclaredDefaults, parseHostVariableValues } from "../runtime/getVariables.js";
6
6
  export { boundMediaSrc } from "../runtime/applyVariableBindings.js";
7
7
  export { extractCompiledHtmlParityContract, type CompiledHtmlParityContract, type HtmlParityComposition, type HtmlParityResource, type HtmlParityTimedElement, } from "./htmlParityContract.js";