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.
TypeScript agentic-aiaiai-agentsai-videocompilerdslffmpeggenerative-aillmmarkup-languagemonorepoplugin-systemprogramming-languagetext-to-videotypescriptvideovideo-automationvideo-clonevideo-editingvideo-generation
feat(interview-emoji-reveal): support preset items
kashorin56a8cb8b4a00
diff --git a/packages/interview-emoji-reveal/README.md b/packages/interview-emoji-reveal/README.mdindex f09e5841..aa0f5955 100644--- a/packages/interview-emoji-reveal/README.md+++ b/packages/interview-emoji-reveal/README.md@@ -2,11 +2,12 @@Reusable Hypit author vocabulary for a top-of-frame icon answer strip.-The strip owns one outer projected `TemporalWindow`. Each child answer accepts only an authored-Script `Moment`, projected outside this package to a traced `TemporalInstant`. Display order is source-order and must also be strict chronological order. The Track receives one placeholder image and every-Item receives one answer image: `n` answers therefore have exactly `n + 1` explicit image inputs. A-Moment replaces only its own slot, so earlier answers remain and later slots remain unanswered.+The strip owns one outer projected `TemporalWindow`. An Item is either preset from the first frame or+accepts one authored Script `Moment`, projected outside this package to a traced `TemporalInstant`.+Display order is source order: preset Items come first, then revealed Items in strict chronological+order. The Track receives one placeholder image and every Item receives one answer image: `n` answers+therefore have exactly `n + 1` explicit image inputs. A Moment replaces only its own slot, so earlier+answers remain and later slots remain unanswered.```xml<media:Image id="question-icon" src="./icons/rendered/question-mark.png"/>@@ -18,7 +19,7 @@ Moment replaces only its own slot, so earlier answers remain and later slots rem<emoji:Track id="rules" semantic={speech.semantic} canvas={vertical}style={emoji-strip} placeholder={question-icon} during="program">- <emoji:Item id="manifest" icon={manifest-icon} at={story.moment.manifest}/>+ <emoji:Item id="manifest" icon={manifest-icon} preset="true"/><emoji:Item id="real-estate" icon={real-estate-icon} at={story.moment.real-estate}/><emoji:Item id="bitcoin" icon={bitcoin-icon} at={story.moment.bitcoin}/></emoji:Track>diff --git a/packages/interview-emoji-reveal/src/component.ts b/packages/interview-emoji-reveal/src/component.tsindex c79797f3..14a71a97 100644--- a/packages/interview-emoji-reveal/src/component.ts+++ b/packages/interview-emoji-reveal/src/component.ts@@ -6,7 +6,7 @@ import type { CanvasSpace } from "@hypit/spatial";import type { TemporalInstant, TemporalWindow } from "@hypit/temporal";import { emojiRevealProducers, emojiRevealTypes } from "./manifest.js";-import { appendEmojiRevealItem, assertEmojiRevealProgram, createEmojiRevealSet, finalizeEmojiReveal, renderEmojiReveal } from "./program.js";+import { appendEmojiRevealItem, appendPresetEmojiRevealItem, assertEmojiRevealProgram, createEmojiRevealSet, finalizeEmojiReveal, renderEmojiReveal } from "./program.js";import type { EmojiRevealHeader, EmojiRevealItemSpec, EmojiRevealProgram, EmojiRevealSet, EmojiRevealStyle } from "./types.js";function inline<T>(value: StoredValue | undefined, label: string): T {@@ -27,6 +27,10 @@ export const emojiRevealComponent = {inline<EmojiRevealItemSpec>(inputs.spec?.value, "EmojiRevealItemSpec"), blob(inputs.icon?.value, "Emoji Reveal icon"),inline<TemporalInstant>(inputs.activation?.value, "TemporalInstant"),)) }, needs: {} }) },+ { producer: emojiRevealProducers.appendPresetItem, handler: ({ inputs }) => ({ outputs: { set: output(appendPresetEmojiRevealItem(+ inline<EmojiRevealSet>(inputs.set?.value, "EmojiRevealSet"),+ inline<EmojiRevealItemSpec>(inputs.spec?.value, "EmojiRevealItemSpec"), blob(inputs.icon?.value, "Emoji Reveal icon"),+ )) }, needs: {} }) },{ producer: emojiRevealProducers.finalize, handler: ({ inputs }) => ({ outputs: { program: output(finalizeEmojiReveal(inline<EmojiRevealHeader>(inputs.header?.value, "EmojiRevealHeader"), inline<ProgramSpace>(inputs.space?.value, "ProgramSpace"),inline<TemporalWindow>(inputs.outer?.value, "TemporalWindow"), inline<EmojiRevealStyle>(inputs.style?.value, "EmojiRevealStyle"),diff --git a/packages/interview-emoji-reveal/src/fragment.ts b/packages/interview-emoji-reveal/src/fragment.tsindex 75e34ea1..696660e4 100644--- a/packages/interview-emoji-reveal/src/fragment.ts+++ b/packages/interview-emoji-reveal/src/fragment.ts@@ -8,7 +8,11 @@ import { temporalTypes } from "@hypit/temporal";import { emojiRevealProducers, emojiRevealTypes } from "./manifest.js";-export type EmojiRevealFragmentItem = { readonly specName: string; readonly iconName: string; readonly activationName: string };+export type EmojiRevealFragmentItem = {+ readonly specName: string;+ readonly iconName: string;+ readonly activationName?: string;+};const input = (name: string) => ({ kind: "fragment-input" as const, name });const operation = (id: string) => ({ kind: "fragment-operation" as const, operation: id });@@ -21,9 +25,13 @@ export function createEmojiRevealFragment(items: readonly EmojiRevealFragmentItelet current = "emoji:set:empty";items.forEach((item, index) => {const id = `emoji:set:append:${String(index + 1).padStart(4, "0")}`;- operations.push({ id, producer: emojiRevealProducers.appendItem, inputs: {- set: operation(current), space: operation("emoji:space"), spec: input(item.specName), activation: input(item.activationName),- icon: input(item.iconName),+ operations.push({ id, producer: item.activationName === undefined+ ? emojiRevealProducers.appendPresetItem+ : emojiRevealProducers.appendItem, inputs: {+ set: operation(current), spec: input(item.specName), icon: input(item.iconName),+ ...(item.activationName === undefined ? {} : {+ space: operation("emoji:space"), activation: input(item.activationName),+ }),}, result: { kind: "output", name: "set" } });current = id;});@@ -43,7 +51,7 @@ export function createEmojiRevealFragment(items: readonly EmojiRevealFragmentIte{ name: "placeholder", type: artifactTypes.blob },...items.flatMap((item) => [{ name: item.specName, type: emojiRevealTypes.itemSpec }, { name: item.iconName, type: artifactTypes.blob },- { name: item.activationName, type: temporalTypes.instant },+ ...(item.activationName === undefined ? [] : [{ name: item.activationName, type: temporalTypes.instant }]),]),],operations,diff --git a/packages/interview-emoji-reveal/src/index.ts b/packages/interview-emoji-reveal/src/index.tsindex 41cd9ad3..e9091f1e 100644--- a/packages/interview-emoji-reveal/src/index.ts+++ b/packages/interview-emoji-reveal/src/index.ts@@ -7,7 +7,7 @@ export {emojiRevealSetSchema, emojiRevealStyleSchema, emojiRevealTypes,} from "./manifest.js";export {- appendEmojiRevealItem, assertEmojiRevealHeader, assertEmojiRevealItemSpec, assertEmojiRevealProgram,+ appendEmojiRevealItem, appendPresetEmojiRevealItem, assertEmojiRevealHeader, assertEmojiRevealItemSpec, assertEmojiRevealProgram,assertEmojiRevealSet, assertEmojiRevealStyle, createEmojiRevealSet, finalizeEmojiReveal,renderEmojiReveal, sealEmojiRevealHeader, sealEmojiRevealItemSpec,} from "./program.js";diff --git a/packages/interview-emoji-reveal/src/manifest.ts b/packages/interview-emoji-reveal/src/manifest.tsindex c2af48ec..07bfe3ea 100644--- a/packages/interview-emoji-reveal/src/manifest.ts+++ b/packages/interview-emoji-reveal/src/manifest.ts@@ -30,6 +30,7 @@ export const emojiRevealTypes = {export const emojiRevealProducers = {createSet: { module: emojiRevealModuleRef, name: "create-emoji-reveal-set" },appendItem: { module: emojiRevealModuleRef, name: "append-emoji-reveal-item" },+ appendPresetItem: { module: emojiRevealModuleRef, name: "append-preset-emoji-reveal-item" },finalize: { module: emojiRevealModuleRef, name: "finalize-emoji-reveal" },render: { module: emojiRevealModuleRef, name: "render-emoji-reveal" },} satisfies Record<string, ProducerRef>;@@ -50,7 +51,7 @@ const blob = object({export const emojiRevealHeaderSchema: ValueSchema = object({ id: { schema: string } });export const emojiRevealItemSpecSchema: ValueSchema = object({- id: { schema: string },+ id: { schema: string }, preset: { schema: { kind: "boolean" } },});export const emojiRevealStyleSchema: ValueSchema = object({id: { schema: string },@@ -62,7 +63,7 @@ export const emojiRevealStyleSchema: ValueSchema = object({iconSizePx: { schema: positive }, revealFrames: { schema: positiveInteger }, stackingOrder: { schema: integer },});const emojiRevealItemSchema: ValueSchema = object({- spec: { schema: emojiRevealItemSpecSchema }, icon: { schema: blob }, activation: { schema: temporalInstantSchema },+ spec: { schema: emojiRevealItemSpecSchema }, icon: { schema: blob }, activation: { schema: temporalInstantSchema, optional: true },});export const emojiRevealSetSchema: ValueSchema = object({items: { schema: { kind: "array", items: emojiRevealItemSchema } },@@ -110,8 +111,8 @@ export const emojiRevealMarkupSurfaces = [{ name: "track", tag: "Track", mode: "structured",outputs: [emojiRevealTypes.header, emojiRevealTypes.itemSpec, temporalTypes.instantSpec, temporalTypes.windowSpec, temporalTypes.instant, temporalTypes.window, emojiRevealTypes.program, compositionTypes.visualTrack],vocabulary: {- summary: "Draws one adaptive row of placeholder icon slots and replaces them from left to right at authored semantic Moments.",- appearance: "A compact rounded rectangle centered near the top of the frame, with a dark outline and a hard lower-right shadow. Its width is computed from the number of fixed-size slots. Every slot starts with the same supplied placeholder icon. At each item's semantic Moment that slot is replaced by its supplied icon with a brief overshoot and settle, while earlier answers remain visible and later slots remain unanswered.",+ summary: "Draws one adaptive row of preset or progressively revealed icon slots.",+ appearance: "A compact rounded rectangle centered near the top of the frame, with a dark outline and a hard lower-right shadow. Its width is computed from the number of fixed-size slots. Preset slots are settled from the first frame. Every other slot starts with the same supplied placeholder icon, then its semantic Moment replaces that slot with a brief overshoot and settle while earlier answers remain visible and later slots remain unanswered.",preview: previewImage("Track.png"),attributes: [{ name: "id", kind: "identifier", required: true, summary: "Names the reveal Program and Track." },@@ -121,23 +122,24 @@ export const emojiRevealMarkupSurfaces = [{ name: "placeholder", kind: "reference", required: true, accepts: [artifactTypes.blob], summary: "Supplies the one image drawn in every unrevealed slot." },...temporalWindowAttributeVocabulary,],- children: [{ tag: "Item", cardinality: "many", summary: "One left-to-right answer slot revealed at exactly one semantic Moment.", attributes: [+ children: [{ tag: "Item", cardinality: "many", summary: "One answer slot, either settled from the start or revealed at exactly one semantic Moment.", attributes: [{ name: "id", kind: "identifier", required: true, summary: "Names this answer slot and the timing subject it owns." },{ name: "icon", kind: "reference", required: true, accepts: [artifactTypes.blob], summary: "Supplies this answer as an image Artifact from the same visual icon family as the placeholder." },- { name: "at", kind: "reference", required: true, accepts: [narrativeTypes.moment], summary: "Chooses the only legal reveal authority: an authored semantic Moment." },+ { name: "preset", kind: "literal", required: false, values: ["true", "false"], summary: "Settles this Item from the start of the Track Window; preset Items have no at." },+ { name: "at", kind: "reference", required: false, accepts: [narrativeTypes.moment], summary: "Chooses this non-preset Item's reveal Moment; required unless preset is true." },] }],ports: [{ name: "program", type: emojiRevealTypes.program, summary: "The adaptive strip with its projected outer Window and fully traced Moment activations." },{ name: "track", type: compositionTypes.visualTrack, summary: "That Program rendered as an ordinary VisualTrack." },],example: `<emoji:Track id="rules" semantic={speech.semantic} canvas={vertical} style={emoji-strip} placeholder={question-icon} during="program">- <emoji:Item id="manifest" icon={manifest-icon} at={story.moment.manifest}/>+ <emoji:Item id="manifest" icon={manifest-icon} preset="true"/><emoji:Item id="real-estate" icon={real-estate-icon} at={story.moment.real-estate}/><emoji:Item id="bitcoin" icon={bitcoin-icon} at={story.moment.bitcoin}/></emoji:Track>`,notes: [- "Item order is display order and must also be strict chronological reveal order.",- "Item.at accepts only a Moment: Selection boundaries, numeric instants and boundary fallbacks are intentionally absent.",+ "Item order is display order: preset Items come first, then non-preset Items in strict chronological reveal order.",+ "A non-preset Item.at accepts only a Moment: Selection boundaries, numeric instants and boundary fallbacks are intentionally absent.","The outer Track Window is separate from the child reveal Moments and uses the shared temporal Window protocol.",],} },@@ -156,6 +158,9 @@ export const emojiRevealManifest: ModuleManifest = {{ name: emojiRevealProducers.appendItem.name,inputs: [{ name: "set", type: emojiRevealTypes.set }, { name: "space", type: programSpaceTypes.programSpace }, { name: "spec", type: emojiRevealTypes.itemSpec }, { name: "icon", type: artifactTypes.blob }, { name: "activation", type: temporalTypes.instant }],outputs: [{ name: "set", type: emojiRevealTypes.set }], needs: [] },+ { name: emojiRevealProducers.appendPresetItem.name,+ inputs: [{ name: "set", type: emojiRevealTypes.set }, { name: "spec", type: emojiRevealTypes.itemSpec }, { name: "icon", type: artifactTypes.blob }],+ outputs: [{ name: "set", type: emojiRevealTypes.set }], needs: [] },{ name: emojiRevealProducers.finalize.name,inputs: [{ name: "header", type: emojiRevealTypes.header }, { name: "space", type: programSpaceTypes.programSpace }, { name: "outer", type: temporalTypes.window }, { name: "style", type: emojiRevealTypes.style }, { name: "placeholder", type: artifactTypes.blob }, { name: "set", type: emojiRevealTypes.set }],outputs: [{ name: "program", type: emojiRevealTypes.program }], needs: [] },diff --git a/packages/interview-emoji-reveal/src/program.ts b/packages/interview-emoji-reveal/src/program.tsindex c437ac4b..d7805c70 100644--- a/packages/interview-emoji-reveal/src/program.ts+++ b/packages/interview-emoji-reveal/src/program.ts@@ -29,6 +29,7 @@ export function sealEmojiRevealItemSpec(value: EmojiRevealItemSpec): EmojiReveal}export function assertEmojiRevealItemSpec(value: EmojiRevealItemSpec): void {identity(value.id, "EmojiRevealItemSpec.id");+ assert(typeof value.preset === "boolean", "EmojiRevealItemSpec.preset is invalid.");}function assertIconImage(value: BlobRef, label: string): void {@@ -56,19 +57,33 @@ export function assertEmojiRevealSet(value: EmojiRevealSet): void {assert(Array.isArray(value.items), "EmojiRevealSet is invalid.");const ids = new Set<string>();for (const item of value.items) {- assertEmojiRevealItemSpec(item.spec); assertIconImage(item.icon, `Emoji Reveal Item ${item.spec.id} icon`); identity(item.activation.id, "Emoji Reveal activation id");+ assertEmojiRevealItemSpec(item.spec); assertIconImage(item.icon, `Emoji Reveal Item ${item.spec.id} icon`);+ if (item.spec.preset) assert(!("activation" in item), `Preset Emoji Reveal Item ${item.spec.id} cannot have an activation.`);+ else {+ assert("activation" in item, `Emoji Reveal Item ${item.spec.id} requires an activation.`);+ identity(item.activation.id, "Emoji Reveal activation id");+ }assert(!ids.has(item.spec.id), `Duplicate Emoji Reveal Item ${item.spec.id}.`); ids.add(item.spec.id);}}export function appendEmojiRevealItem(set: EmojiRevealSet, space: ProgramSpace, spec: EmojiRevealItemSpec, icon: BlobRef, activation: TemporalInstant): EmojiRevealSet {assertEmojiRevealSet(set); assertProgramSpaceIdentity(space); assertEmojiRevealItemSpec(spec);+ assert(!spec.preset, `Emoji Reveal Item ${spec.id} with preset=true cannot have an activation.`);assertIconImage(icon, `Emoji Reveal Item ${spec.id} icon`);assertTemporalInstantFor(activation, { subjectId: spec.id, space });assert(!set.items.some((item) => item.spec.id === spec.id), `Duplicate Emoji Reveal Item ${spec.id}.`);return { items: [...set.items, { spec: structuredClone(spec), icon: structuredClone(icon), activation: structuredClone(activation) }] };}+export function appendPresetEmojiRevealItem(set: EmojiRevealSet, spec: EmojiRevealItemSpec, icon: BlobRef): EmojiRevealSet {+ assertEmojiRevealSet(set); assertEmojiRevealItemSpec(spec);+ assert(spec.preset, `Preset Emoji Reveal Item ${spec.id} requires preset=true.`);+ assertIconImage(icon, `Emoji Reveal Item ${spec.id} icon`);+ assert(!set.items.some((item) => item.spec.id === spec.id), `Duplicate Emoji Reveal Item ${spec.id}.`);+ return { items: [...set.items, { spec: structuredClone(spec), icon: structuredClone(icon) }] };+}+export function finalizeEmojiReveal(header: EmojiRevealHeader, space: ProgramSpace, outer: TemporalWindow, style: EmojiRevealStyle, placeholder: BlobRef, set: EmojiRevealSet,): EmojiRevealProgram {@@ -77,7 +92,13 @@ export function finalizeEmojiReveal(assertTemporalWindowFor(outer, { subjectId: header.id, space });assert(set.items.length > 0, "Emoji Reveal requires at least one Item.");let previous = outer.span.startFrame - 1;+ let revealStarted = false;for (const item of set.items) {+ if (!("activation" in item)) {+ assert(!revealStarted, `Preset Emoji Reveal Item ${item.spec.id} cannot appear after a reveal Item.`);+ continue;+ }+ revealStarted = true;const frame = item.activation.frame;assert(frame >= outer.span.startFrame && frame < outer.span.endFrameExclusive,`Emoji Reveal Item ${item.spec.id} must activate inside the Track Window.`);@@ -99,7 +120,13 @@ export function assertEmojiRevealProgram(value: EmojiRevealProgram): void {assert(value.items.length > 0, "EmojiRevealProgram requires Items.");assert(value.outer.span.endFrameExclusive > value.outer.span.startFrame, "EmojiRevealProgram outer Window is empty.");let previous = value.outer.span.startFrame - 1;+ let revealStarted = false;for (const item of value.items) {+ if (!("activation" in item)) {+ assert(!revealStarted, `EmojiRevealProgram preset Item ${item.spec.id} appears after a reveal Item.`);+ continue;+ }+ revealStarted = true;assert(item.activation.frame >= value.outer.span.startFrame && item.activation.frame < value.outer.span.endFrameExclusive,`Emoji Reveal Item ${item.spec.id} is outside the outer Window.`);assert(item.activation.frame > previous, `Emoji Reveal Item ${item.spec.id} is not in strict reveal order.`);@@ -134,6 +161,14 @@ function questionAnimation(atFrame: number, duration: number): VisualAnimation {})) };}+function settledAnimation(duration: number, visible: boolean): VisualAnimation {+ const style = [{ name: "opacity", value: visible ? 1 : 0 }, { name: "transform", value: scale(1) }];+ return { keyframes: [+ { atFrame: 0, easing: "linear", style },+ { atFrame: duration, easing: "linear", style },+ ] };+}+function iconElement(input: {readonly id: string; readonly parent: string; readonly order: number; readonly artifact: BlobRef;readonly x: number; readonly y: number; readonly size: number; readonly animation: VisualAnimation;@@ -180,7 +215,8 @@ export function renderEmojiReveal(canvas: CanvasSpace, space: ProgramSpace, prog}];program.items.forEach((item, index) => {const x = style.paddingXPx + index * (style.slotSizePx + style.gapPx);- const atFrame = item.activation.frame - program.outer.span.startFrame;+ const preset = !("activation" in item);+ const atFrame = preset ? 0 : item.activation.frame - program.outer.span.startFrame;const parentId = `slot-${index + 1}`;elements.push({id: parentId, parent: "root", order: 2 + index * 3, kind: "box", style: [@@ -191,10 +227,10 @@ export function renderEmojiReveal(canvas: CanvasSpace, space: ProgramSpace, progelements.push(iconElement({ id: `${parentId}-placeholder`, parent: parentId, order: 3 + index * 3, artifact: program.placeholder,x: (style.slotSizePx - style.iconSizePx) / 2, y: (style.slotSizePx - style.iconSizePx) / 2,- size: style.iconSizePx, animation: questionAnimation(atFrame, duration) }),+ size: style.iconSizePx, animation: preset ? settledAnimation(duration, false) : questionAnimation(atFrame, duration) }),iconElement({ id: `${parentId}-icon`, parent: parentId, order: 4 + index * 3, artifact: item.icon,x: (style.slotSizePx - style.iconSizePx) / 2, y: (style.slotSizePx - style.iconSizePx) / 2,- size: style.iconSizePx, animation: revealAnimation(atFrame, duration, style.revealFrames) }),+ size: style.iconSizePx, animation: preset ? settledAnimation(duration, true) : revealAnimation(atFrame, duration, style.revealFrames) }),);});const track = sealVisualTrack({diff --git a/packages/interview-emoji-reveal/src/surface.ts b/packages/interview-emoji-reveal/src/surface.tsindex 75323b7a..f62b6fc5 100644--- a/packages/interview-emoji-reveal/src/surface.ts+++ b/packages/interview-emoji-reveal/src/surface.ts@@ -1,5 +1,5 @@import {- assertAttributes, assertEmptyElement, textAttribute, type MarkupAttributeValue, type StructuredSurfaceHandler,+ assertAttributes, assertEmptyElement, optionalTextAttribute, textAttribute, type MarkupAttributeValue, type StructuredSurfaceHandler,type SurfaceComponentDraft, type SurfaceRecordDraft, type SurfaceResolvedReference,} from "@hypit/markup";import { artifactTypes } from "@hypit/artifact";@@ -31,6 +31,14 @@ function inline<T>(value: SurfaceResolvedReference, label: string): T {return value.record.value.value as unknown as T;}+function boolean(element: Parameters<StructuredSurfaceHandler>[0]["element"], name: string, fallback: boolean): boolean {+ const source = optionalTextAttribute(element, name);+ if (source === undefined) return fallback;+ if (source === "true") return true;+ if (source === "false") return false;+ throw new Error(`${element.name}.${name} must be true or false.`);+}+export const decodeEmojiRevealStyleSurface: StructuredSurfaceHandler = ({ element, resolveReference }) => {assertAttributes(element, ["id", "recipe"]); assertEmptyElement(element);const id = textAttribute(element, "id");@@ -54,7 +62,7 @@ export const decodeEmojiRevealTrackSurface: StructuredSurfaceHandler = ({ elemen}];const temporalComponents: SurfaceComponentDraft[] = [...outer.components];const temporalFragments = [...outer.fragments];- const items: { specName: string; iconName: string; activationName: string }[] = [];+ const items: { specName: string; iconName: string; activationName?: string }[] = [];const inputs: Record<string, typeof semantic.ref> = {header: { kind: "record", id: headerId }, semantic: semantic.ref, canvas: canvas.ref, style: style.ref,placeholder: placeholder.ref, outer: outer.ref,@@ -64,24 +72,33 @@ export const decodeEmojiRevealTrackSurface: StructuredSurfaceHandler = ({ elemenfor (const child of element.children) {if (child.kind === "text") { if (child.value.trim().length > 0) throw new Error(`${element.name} accepts only Item children.`); continue; }if (child.name.split(":").at(-1) !== "Item") throw new Error(`${element.name} accepts only Item children.`);- assertAttributes(child, ["id", "icon", "at"]); assertEmptyElement(child);+ assertAttributes(child, ["id", "icon", "preset", "at"]); assertEmptyElement(child);index += 1;const itemId = textAttribute(child, "id");if (ids.has(itemId)) throw new Error(`${element.name} contains duplicate Item id ${itemId}.`); ids.add(itemId);- reference(child.attributes.at, `${child.name}.at`, narrativeTypes.moment, resolveReference);+ const preset = boolean(child, "preset", false);+ const timed = child.attributes.at !== undefined;+ if (preset && timed) throw new Error(`${child.name} cannot combine preset=true with at.`);+ if (!preset && !timed) throw new Error(`${child.name} requires at unless preset=true.`);const icon = reference(child.attributes.icon, `${child.name}.icon`, artifactTypes.blob, resolveReference);- const spec = sealEmojiRevealItemSpec({ id: itemId });- const activation = createTemporalInstantProjection({- id: `${id}.item.${String(index).padStart(4, "0")}.activation`, subjectId: itemId,- element: child, semantic, resolveReference, semanticAttribute: "at", projectedAttribute: false,- });- records.push(...activation.records); temporalComponents.push(...activation.components); temporalFragments.push(...activation.fragments);+ const spec = sealEmojiRevealItemSpec({ id: itemId, preset });const suffix = String(index).padStart(4, "0");const specId = `${id}.item.${suffix}.spec`; const specName = `item-${suffix}-spec`;- const iconName = `item-${suffix}-icon`; const activationName = `item-${suffix}-activation`;+ const iconName = `item-${suffix}-icon`;records.push({ id: specId, type: emojiRevealTypes.itemSpec, value: { kind: "inline", value: spec as unknown as CanonicalValue }, range: child.range });- inputs[specName] = { kind: "record", id: specId }; inputs[iconName] = icon.ref; inputs[activationName] = activation.ref;- items.push({ specName, iconName, activationName });+ inputs[specName] = { kind: "record", id: specId }; inputs[iconName] = icon.ref;+ if (preset) items.push({ specName, iconName });+ else {+ reference(child.attributes.at, `${child.name}.at`, narrativeTypes.moment, resolveReference);+ const activation = createTemporalInstantProjection({+ id: `${id}.item.${suffix}.activation`, subjectId: itemId,+ element: child, semantic, resolveReference, semanticAttribute: "at", projectedAttribute: false,+ });+ records.push(...activation.records); temporalComponents.push(...activation.components); temporalFragments.push(...activation.fragments);+ const activationName = `item-${suffix}-activation`;+ inputs[activationName] = activation.ref;+ items.push({ specName, iconName, activationName });+ }}if (items.length === 0) throw new Error(`${element.name} requires at least one Item.`);const fragment = createEmojiRevealFragment(items);diff --git a/packages/interview-emoji-reveal/src/types.ts b/packages/interview-emoji-reveal/src/types.tsindex 9cc9ff3e..e3548e8b 100644--- a/packages/interview-emoji-reveal/src/types.ts+++ b/packages/interview-emoji-reveal/src/types.ts@@ -3,9 +3,9 @@ import type { TemporalInstant, TemporalWindow } from "@hypit/temporal";export type EmojiRevealHeader = { readonly id: string };-export type EmojiRevealItemSpec = {- readonly id: string;-};+export type EmojiRevealItemSpec =+ | { readonly id: string; readonly preset: true }+ | { readonly id: string; readonly preset: false };export type EmojiRevealStyle = {readonly id: string;@@ -29,11 +29,16 @@ export type EmojiRevealStyle = {readonly stackingOrder: number;};-export type EmojiRevealItem = {- readonly spec: EmojiRevealItemSpec;- readonly icon: BlobRef;- readonly activation: TemporalInstant;-};+export type EmojiRevealItem =+ | {+ readonly spec: EmojiRevealItemSpec & { readonly preset: true };+ readonly icon: BlobRef;+ }+ | {+ readonly spec: EmojiRevealItemSpec & { readonly preset: false };+ readonly icon: BlobRef;+ readonly activation: TemporalInstant;+ };export type EmojiRevealSet = { readonly items: readonly EmojiRevealItem[] };