Skip to content

armgit / hypit

Public Imported from GitHub
0

Clone any viral video with AI agents. Not just a script, the whole workflow: swap the face, the words, the B-roll, ship 100 variants in one command, and get your 100M views.

1.1 KB
Raw Blame
import type { StructuredElement, SurfaceAttributeVocabulary, SurfaceResolvedReference } from "@hypit/hypit/markup";
import { sameType } from "@hypit/hypit/protocol";
import { timelineTypes } from "@hypit/timeline";

export type TemporalContext = { readonly timeline: SurfaceResolvedReference };

export const temporalContextAttributeVocabulary = [
  { name: "timeline", kind: "reference", required: true, accepts: [timelineTypes.timeline],
    summary: "The complete absolute film Timeline." },
] as const satisfies readonly SurfaceAttributeVocabulary[];

export function resolveTemporalContext(input: {
  readonly element: StructuredElement;
  readonly resolveReference: (path: string) => SurfaceResolvedReference | undefined;
}): TemporalContext {
  const raw = input.element.attributes.timeline;
  if (typeof raw !== "object" || raw.kind !== "reference") throw new Error(`${input.element.name}.timeline must be a reference.`);
  const found = input.resolveReference(raw.path);
  if (found === undefined || !sameType(found.type, timelineTypes.timeline)) {
    throw new Error(`${input.element.name}.timeline must reference a Timeline.`);
  }
  return { timeline: found };
}