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.

refactor: remove the ranking Typewriter family

rpone47c7dff9ba2c
diff --git a/.agents/skills/hypit/references/playbooks/formats/ranking-listicle.md b/.agents/skills/hypit/references/playbooks/formats/ranking-listicle.md
index 034014a9..b71cde9f 100644
--- a/.agents/skills/hypit/references/playbooks/formats/ranking-listicle.md
+++ b/.agents/skills/hypit/references/playbooks/formats/ranking-listicle.md
@@ -17,8 +17,8 @@ explain why every item belongs where it is placed.
1. Build the speech program with accepted speaking or audio-only `speech:Take` inputs, then run
`whisperx:Alignment` so the Selection and Moments resolve against real audio.
2. Declare exact font bytes and the variant's package-owned Style.
-3. Choose exactly one primary component: `ranking:TierBoard`, `ranking:Column`,
- `ranking:TopThree`, or `ranking:TypewriterList`.
+3. Choose exactly one primary component: `ranking:TierBoard`, `ranking:Column`, or
+ `ranking:TopThree`.
4. Connect `map={timing.map}`, `space={speech.space}`, the outer `during` Selection, repeated
`triggers` Moment, terminal Moment, explicit frame, Style, and the complete ordered item list.
5. Add the component's `.visual` output to `film:Film`; add its optional `.audio` output only when
diff --git a/docs/guide/packages.md b/docs/guide/packages.md
index baf71d36..e2c524bc 100644
--- a/docs/guide/packages.md
+++ b/docs/guide/packages.md
@@ -99,7 +99,7 @@ specific Provider deployment.
@hypit/typography-track typography overlay Track
@hypit/audio-track arbitrary sample-domain Audio Track
@hypit/deck-track depth-stack collection Track
-@hypit/ranking four ranking component families
+@hypit/ranking three ranking component families
@hypit/screen-overlay self-contained full-canvas overlays
@hypit/film Film composition
@hypit/composition peer Track composition
diff --git a/docs/quickstart/tracks.md b/docs/quickstart/tracks.md
index 9bbcec15..154280fa 100644
--- a/docs/quickstart/tracks.md
+++ b/docs/quickstart/tracks.md
@@ -330,15 +330,14 @@ placement, timing, style and motion. Use inline `P`/`Span`/`Break` when the auth
## Ranking boards
A board animates an ordered list against the Script: it enters on a Selection, moves on Moments, and
-settles on a Moment that ends it. Four variants share one shape — a container, its own item tag, and
-its own style tag.
+settles on a Moment that ends it. Three variants share one shape — a container, its own item tag,
+and its own style tag.
| Container | Item | Style |
|---|---|---|
| `ranking:TierBoard` | `ranking:TierItem` | `ranking:TierBoardStyle` |
| `ranking:Column` | `ranking:ColumnItem` | `ranking:ColumnStyle` |
| `ranking:TopThree` | `ranking:TopThreeItem` | `ranking:TopThreeStyle` |
-| `ranking:TypewriterList` | `ranking:TypewriterItem` | `ranking:TypewriterListStyle` |
```svml
<import as="ranking" from="@hypit/ranking@1"/>
@@ -361,12 +360,11 @@ against the variant, so a Column recipe on a TierBoard is refused by name.
| `triggers` | a Moment — rows move on it |
| `terminal` | a Moment — the board settles on it |
| `style` | the matching style record, and only that variant's |
-| `title` | `TypewriterList` only, and required there: a string or a Text reference |
| `appear-sound`, `move-sound` | optional Synchronized Media |
`move-sound` is refused on `TopThree`, which has no move phase. On a `TierBoard` it needs at least
-one item with `entry="stage"`, and on a `TypewriterList` at least one `winner="true"` — a sound with
-nothing to sound on is an authoring mistake, not a silent no-op.
+one item with `entry="stage"` — a sound with nothing to sound on is an authoring mistake, not a
+silent no-op.
### The item tags
@@ -376,9 +374,6 @@ Each variant takes its own, at least one, and ids must be unique within a board.
`entry="direct" | "stage"` and `stack`. Row labels come from the recipe, not the tag.
- **`ColumnItem`** and **`TopThreeItem`** — `label` (required: a string or a Text reference), optional
`icon` and `stack`. `TopThree` takes at most three.
-- **`TypewriterItem`** — copy comes from `text=` or from the element's own text, one or the other;
- optional `winner="true"`, `stack`, and `emphasis-start` / `emphasis-end`, which are counted in
- graphemes and must be given together.
```svml
<ranking:ColumnStyle id="board-style" recipe={studio.ranking.board} font={ui-font}/>
diff --git a/docs/zh/guide/packages.md b/docs/zh/guide/packages.md
index a978c8a2..c15adc23 100644
--- a/docs/zh/guide/packages.md
+++ b/docs/zh/guide/packages.md
@@ -94,7 +94,7 @@ Frontend;不存在一个认识全部语法的中央解析器。
@hypit/typography-track typography overlay Track
@hypit/audio-track arbitrary sample-domain Audio Track
@hypit/deck-track depth-stack collection Track
-@hypit/ranking four ranking component families
+@hypit/ranking three ranking component families
@hypit/screen-overlay self-contained full-canvas overlays
@hypit/film Film composition
@hypit/composition peer Track composition
diff --git a/docs/zh/quickstart/tracks.md b/docs/zh/quickstart/tracks.md
index 95f31e50..a251b0d3 100644
--- a/docs/zh/quickstart/tracks.md
+++ b/docs/zh/quickstart/tracks.md
@@ -275,14 +275,13 @@ Run 时,继续使用内联 `P`/`Span`/`Break`。
## 榜单板
-榜单板让一份有序列表跟着 Script 动起来:在某个 Selection 期间出现,在 Moment 上移动,在另一个 Moment 上定格。四个变体共用同一套形状——一个容器、它专属的条目标签、以及它专属的样式标签。
+榜单板让一份有序列表跟着 Script 动起来:在某个 Selection 期间出现,在 Moment 上移动,在另一个 Moment 上定格。三个变体共用同一套形状——一个容器、它专属的条目标签、以及它专属的样式标签。
| 容器 | 条目 | 样式 |
|---|---|---|
| `ranking:TierBoard` | `ranking:TierItem` | `ranking:TierBoardStyle` |
| `ranking:Column` | `ranking:ColumnItem` | `ranking:ColumnStyle` |
| `ranking:TopThree` | `ranking:TopThreeItem` | `ranking:TopThreeStyle` |
-| `ranking:TypewriterList` | `ranking:TypewriterItem` | `ranking:TypewriterListStyle` |
```svml
<import as="ranking" from="@hypit/ranking@1"/>
@@ -303,10 +302,9 @@ Run 时,继续使用内联 `P`/`Span`/`Break`。
| `triggers` | 一个 Moment——行在它上面移动 |
| `terminal` | 一个 Moment——板在它上面定格 |
| `style` | 对应的样式记录,且只接受本变体的 |
-| `title` | 仅 `TypewriterList` 有,且必填:字符串或 Text 引用 |
| `appear-sound`、`move-sound` | 可选,Synchronized Media |
-`move-sound` 在 `TopThree` 上会被拒绝——它没有移动阶段。在 `TierBoard` 上它要求至少有一个 `entry="stage"` 的条目,在 `TypewriterList` 上要求至少有一个 `winner="true"`:声音没有可响之处是创作错误,而不是静默的空操作。
+`move-sound` 在 `TopThree` 上会被拒绝——它没有移动阶段。在 `TierBoard` 上它要求至少有一个 `entry="stage"` 的条目:声音没有可响之处是创作错误,而不是静默的空操作。
### 条目标签
@@ -314,7 +312,6 @@ Run 时,继续使用内联 `P`/`Span`/`Break`。
- **`TierItem`** —— `tier`(必填,须与 recipe 中某一行的 id 对上)、`icon`(必填),可选 `entry="direct" | "stage"` 与 `stack`。行的文字来自 recipe,不写在标签上。
- **`ColumnItem`** 与 **`TopThreeItem`** —— `label`(必填:字符串或 Text 引用),可选 `icon` 与 `stack`。`TopThree` 最多三条。
-- **`TypewriterItem`** —— 文案来自 `text=` 或元素自身的文字,二者取其一;可选 `winner="true"`、`stack`,以及 `emphasis-start` / `emphasis-end`,二者按字素计数且必须成对出现。
```svml
<ranking:ColumnStyle id="board-style" recipe={studio.ranking.board} font={ui-font}/>
diff --git a/packages/hyperframes/test/browser-visual.test.ts b/packages/hyperframes/test/browser-visual.test.ts
index 9ce2e550..63e189fd 100644
--- a/packages/hyperframes/test/browser-visual.test.ts
+++ b/packages/hyperframes/test/browser-visual.test.ts
@@ -1581,14 +1581,14 @@ test("DepthStack Deck reflow, exact labels and old-system layout survive partiti
}
});
-test("all four Ranking components paint frame-pure progressive states under partitioned browser rendering", {
+test("all three Ranking components paint frame-pure progressive states under partitioned browser rendering", {
skip: !enabled,
timeout: 120_000,
}, async () => {
const temp = await mkdtemp(path.join(os.tmpdir(), "hypit-ranking-visual-"));
try {
const width = 480;
- const height = 720;
+ const height = 512;
const fps = 12;
const frames = 24;
const installed = await installedOpenFont("inter", 700, "normal");
@@ -1696,26 +1696,10 @@ test("all four Ranking components paint frame-pure progressive states under part
schedule(topHeader, topSpecs), topStyle, topItems,
));
- const typeHeader = rankingTrack.sealRankingHeader({ id: "browser-typewriter", variant: "typewriter-list" });
- const typeSpecs = [
- { variant: "typewriter-list", id: "typed-one", text: "Fast", winner: false },
- { variant: "typewriter-list", id: "typed-two", text: "Clear", winner: false, emphasis: { start: 0, endExclusive: 2 } },
- { variant: "typewriter-list", id: "typed-three", text: "Best", winner: true },
- ] as const;
- let typeItems = rankingTrack.createTypewriterItemSet();
- typeSpecs.forEach((spec) => { typeItems = rankingTrack.appendTypewriterItem(typeItems, spec); });
- const typeStyle = rankingTrack.decodeTypewriterListStyle(recipe("browser.typewriter", {
- "title-font-size": 20, "item-font-size": 16, "appear-frames": 2, "move-frames": 2,
- padding: 12, "row-gap": 4, "title-gap": 5, "frames-per-grapheme": 1, "winner-frames": 1,
- }), font).style;
- const typeTrack = rankingTrack.renderTypewriterList(space, rankingTrack.buildTypewriterListProgram(
- typeHeader, "RANKING", { xPx: 20, yPx: 500, widthPx: 440, heightPx: 195 },
- schedule(typeHeader, typeSpecs), typeStyle, typeItems,
- ));
const document = compileHyperframesDocument(sealComposition({
id: "ranking-browser-proof",
canvas: { width, height, clearColor: "#090b12" },
- tracks: [tierTrack, columnTrack, topTrack, typeTrack],
+ tracks: [tierTrack, columnTrack, topTrack],
}), space);
await writeFile(path.join(temp, "index.html"), materializeHyperframesHtml(document, (artifact) => {
const materialized = paths.get(artifact.digest);
@@ -1774,7 +1758,7 @@ test("all four Ranking components paint frame-pure progressive states under part
assert.notDeepEqual(sequential[3], sequential[9], "Ranking stages produced no visual state change");
assert.notDeepEqual(sequential[9], sequential[15], "later Ranking triggers produced no visual state change");
const settled = sequential[22]!;
- for (const [name, top, bottom] of [["TierBoard", 20, 160], ["Column", 180, 320], ["TopThree", 340, 480], ["TypewriterList", 500, 695]] as const) {
+ for (const [name, top, bottom] of [["TierBoard", 20, 160], ["Column", 180, 320], ["TopThree", 340, 480]] as const) {
assert.ok(matchingPixels(settled, width, { left: 20, top, right: 460, bottom }, (red, green, blue) => red + green + blue > 120) > 500,
`${name} did not paint its settled suffix`);
}
diff --git a/packages/ranking/README.md b/packages/ranking/README.md
index 7b7b6c83..71c46178 100644
--- a/packages/ranking/README.md
+++ b/packages/ranking/README.md
@@ -1,11 +1,10 @@
# @hypit/ranking
-Four independent progressive-ranking author components over one private schedule utility:
+Three independent progressive-ranking author components over one private schedule utility:
- `TierBoard`
- `Column`
- `TopThree`
-- `TypewriterList`
The package owns variant-specific Programs and Styles. It consumes explicit Selection/Moment,
SemanticMap, ProgramSpace, SpatialFrame, font, image and optional sound edges, then lowers to peer
@@ -17,10 +16,10 @@ plus a private named `.sound` Style output. A Ranking component connects both ou
sound exists; no sound produces no audio branch.
Visible author copy may be literal or an ordinary graph `Text` reference. Column and TopThree use
-`label={copy}`, while Typewriter uses `title={copy}` and `text={copy}`. When a reference is used, the
-graph first materializes the package-owned item shell from that exact Text and then shares the one
-result across schedule, event and render work. Tier row names remain Style configuration because
-they define the board vocabulary rather than dynamic item copy.
+`label={copy}`. When a reference is used, the graph first materializes the package-owned item shell
+from that exact Text and then shares the one result across schedule, event and render work. Tier row
+names remain Style configuration because they define the board vocabulary rather than dynamic item
+copy.
```svml
<import as="copy" from="@hypit/text@1"/>
diff --git a/packages/ranking/src/activation.ts b/packages/ranking/src/activation.ts
index 3d9fb41a..cf9ef4fd 100644
--- a/packages/ranking/src/activation.ts
+++ b/packages/ranking/src/activation.ts
@@ -7,8 +7,6 @@ import {
decodeTierBoardSurface,
decodeTopThreeStyleSurface,
decodeTopThreeSurface,
- decodeTypewriterListStyleSurface,
- decodeTypewriterListSurface,
rankingComponent,
rankingManifest,
rankingMarkupSurfaces,
@@ -19,11 +17,9 @@ const facets = [
["tier-style", decodeTierBoardStyleSurface],
["column-style", decodeColumnStyleSurface],
["top-three-style", decodeTopThreeStyleSurface],
- ["typewriter-style", decodeTypewriterListStyleSurface],
["tier", decodeTierBoardSurface],
["column", decodeColumnSurface],
["top-three", decodeTopThreeSurface],
- ["typewriter", decodeTypewriterListSurface],
] as const;
export const hypitPackage = {
diff --git a/packages/ranking/src/component.ts b/packages/ranking/src/component.ts
index 71e8ac37..4345af96 100644
--- a/packages/ranking/src/component.ts
+++ b/packages/ranking/src/component.ts
@@ -9,13 +9,12 @@ import type { SpatialFrame } from "@hypit/spatial";
import type { Text } from "@hypit/text";
import { rankingProducers, rankingTypes } from "./manifest.js";
-import { appendColumnItem, appendRankingItemSpec, appendRankingSound, appendTierBoardItem, appendTopThreeItem, appendTypewriterItem, assertColumnProgram, assertRankingSchedule, assertRankingSoundEventPlan, assertTierBoardProgram, assertTopThreeProgram, assertTypewriterListProgram, buildColumnProgram, buildColumnSoundEvents, buildRankingSchedule, buildTierBoardProgram, buildTierBoardSoundEvents, buildTopThreeProgram, buildTopThreeSoundEvents, buildTypewriterListProgram, buildTypewriterSoundEvents, createColumnItemSet, createRankingItemSpecSet, createRankingSoundSet, createTierBoardItemSet, createTopThreeItemSet, createTypewriterItemSet, materializeRankingTextItem } from "./schedule.js";
+import { appendColumnItem, appendRankingItemSpec, appendRankingSound, appendTierBoardItem, appendTopThreeItem, assertColumnProgram, assertRankingSchedule, assertRankingSoundEventPlan, assertTierBoardProgram, assertTopThreeProgram, buildColumnProgram, buildColumnSoundEvents, buildRankingSchedule, buildTierBoardProgram, buildTierBoardSoundEvents, buildTopThreeProgram, buildTopThreeSoundEvents, createColumnItemSet, createRankingItemSpecSet, createRankingSoundSet, createTierBoardItemSet, createTopThreeItemSet, materializeRankingTextItem } from "./schedule.js";
import {
renderColumn,
renderRankingAudio,
renderTierBoard,
renderTopThree,
- renderTypewriterList,
} from "./render.js";
import type {
ColumnItemSet,
@@ -38,10 +37,6 @@ import type {
TopThreeItemSpec,
TopThreeProgram,
TopThreeStyle,
- TypewriterItemSet,
- TypewriterItemSpec,
- TypewriterListProgram,
- TypewriterListStyle,
} from "./types.js";
function inline<T>(value: StoredValue | undefined, label: string): T {
@@ -96,7 +91,6 @@ export const rankingComponent = {
[rankingProducers.createTierItems, createTierBoardItemSet],
[rankingProducers.createColumnItems, createColumnItemSet],
[rankingProducers.createTopThreeItems, createTopThreeItemSet],
- [rankingProducers.createTypewriterItems, createTypewriterItemSet],
] as const).map(([producer, create]) => ({
producer,
handler: () => ({ outputs: { set: output(create()) }, needs: {} }),
@@ -131,13 +125,6 @@ export const rankingComponent = {
...(hasIcon ? [blob(inputs.icon?.value, "TopThree icon")] : []),
)) }, needs: {} }),
})),
- {
- producer: rankingProducers.appendTypewriterItem,
- handler: ({ inputs }) => ({ outputs: { set: output(appendTypewriterItem(
- inline<TypewriterItemSet>(inputs.set?.value, "TypewriterItemSet"),
- inline<TypewriterItemSpec>(inputs.spec?.value, "TypewriterItemSpec"),
- )) }, needs: {} }),
- },
{
producer: rankingProducers.tierProgram,
handler: ({ inputs }) => {
@@ -162,20 +149,10 @@ export const rankingComponent = {
inline<TopThreeStyle>(inputs.style?.value, "TopThreeStyle"), inline<TopThreeItemSet>(inputs.set?.value, "TopThreeItemSet"))) }, needs: {} };
},
},
- {
- producer: rankingProducers.typewriterProgram,
- handler: ({ inputs }) => {
- const common = programInputs(inputs);
- const title = inline<Text>(inputs.title?.value, "Text");
- return { outputs: { program: output(buildTypewriterListProgram(common.header, title.value, common.frame, common.schedule,
- inline<TypewriterListStyle>(inputs.style?.value, "TypewriterListStyle"), inline<TypewriterItemSet>(inputs.set?.value, "TypewriterItemSet"))) }, needs: {} };
- },
- },
...([
[rankingProducers.tierEvents, buildTierBoardSoundEvents, "TierBoardStyle"],
[rankingProducers.columnEvents, buildColumnSoundEvents, "ColumnStyle"],
[rankingProducers.topThreeEvents, buildTopThreeSoundEvents, "TopThreeStyle"],
- [rankingProducers.typewriterEvents, buildTypewriterSoundEvents, "TypewriterListStyle"],
] as const).map(([producer, build, styleLabel]) => ({
producer,
handler: ({ inputs }: ProducerHandlerContext) => ({ outputs: { events: output(build(
@@ -211,7 +188,6 @@ export const rankingComponent = {
[rankingProducers.renderTier, renderTierBoard, "TierBoardProgram"],
[rankingProducers.renderColumn, renderColumn, "ColumnProgram"],
[rankingProducers.renderTopThree, renderTopThree, "TopThreeProgram"],
- [rankingProducers.renderTypewriter, renderTypewriterList, "TypewriterListProgram"],
] as const).map(([producer, render, label]) => ({
producer,
handler: ({ inputs }: ProducerHandlerContext) => ({ outputs: { track: output(render(
@@ -228,8 +204,6 @@ export const rankingComponent = {
handler: ({ value }) => assertColumnProgram(inline<ColumnProgram>(value, "ColumnProgram")) },
{ type: rankingTypes.topThreeProgram,
handler: ({ value }) => assertTopThreeProgram(inline<TopThreeProgram>(value, "TopThreeProgram")) },
- { type: rankingTypes.typewriterProgram,
- handler: ({ value }) => assertTypewriterListProgram(inline<TypewriterListProgram>(value, "TypewriterListProgram")) },
{ type: rankingTypes.soundEvents,
handler: ({ value }) => assertRankingSoundEventPlan(inline<RankingSoundEventPlan>(value, "RankingSoundEventPlan")) },
],
diff --git a/packages/ranking/src/fragment.ts b/packages/ranking/src/fragment.ts
index f041ee38..ae9db281 100644
--- a/packages/ranking/src/fragment.ts
+++ b/packages/ranking/src/fragment.ts
@@ -45,12 +45,7 @@ const definition = (variant: RankingVariant) => {
appendIcon: rankingProducers.appendTopThreeIconItem, build: rankingProducers.topThreeProgram,
events: rankingProducers.topThreeEvents, render: rankingProducers.renderTopThree,
} as const;
- return {
- style: rankingTypes.typewriterStyle, set: rankingTypes.typewriterItems, program: rankingTypes.typewriterProgram,
- create: rankingProducers.createTypewriterItems, append: rankingProducers.appendTypewriterItem,
- appendIcon: rankingProducers.appendTypewriterItem, build: rankingProducers.typewriterProgram,
- events: rankingProducers.typewriterEvents, render: rankingProducers.renderTypewriter,
- } as const;
+ throw new Error(`Ranking Fragment has no definition for variant ${variant as string}.`);
};
export function createRankingFragment(
@@ -70,7 +65,6 @@ export function createRankingFragment(
{ name: "frame", type: spatialTypes.frame },
{ name: "style", type: selected.style },
];
- if (variant === "typewriter-list") inputs.push({ name: "title", type: textTypes.text });
const operations: FragmentOperation[] = [
{ id: "specs", producer: rankingProducers.createSpecs, inputs: { header: input("header") }, result: { kind: "output", name: "set" } },
{ id: "resolved", producer: selected.create, inputs: {}, result: { kind: "output", name: "set" } },
@@ -124,7 +118,6 @@ export function createRankingFragment(
producer: selected.build,
inputs: {
header: input("header"),
- ...(variant === "typewriter-list" ? { title: input("title") } : {}),
frame: input("frame"), schedule: operation("schedule"), style: input("style"), set: resolved,
},
result: { kind: "output", name: "program" },
diff --git a/packages/ranking/src/index.ts b/packages/ranking/src/index.ts
index d90d95ba..13a2c929 100644
--- a/packages/ranking/src/index.ts
+++ b/packages/ranking/src/index.ts
@@ -1,16 +1,14 @@
-export { appendRankingItemSpec, appendRankingSound, appendColumnItem, appendTierBoardItem, appendTopThreeItem, appendTypewriterItem, assertColumnProgram, assertColumnStyle, assertRankingHeader, assertRankingItemSpec, assertRankingItemSpecSet, assertRankingTextItemShell, assertRankingSchedule, assertRankingSoundEventPlan, assertRankingSoundStyle, assertTierBoardProgram, assertTierBoardStyle, assertTopThreeProgram, assertTopThreeStyle, assertTypewriterListProgram, assertTypewriterListStyle, buildColumnProgram, buildColumnSoundEvents, buildRankingSchedule, buildTierBoardProgram, buildTierBoardSoundEvents, buildTopThreeProgram, buildTopThreeSoundEvents, buildTypewriterListProgram, buildTypewriterSoundEvents, createColumnItemSet, createRankingItemSpecSet, createRankingSoundSet, createTierBoardItemSet, createTopThreeItemSet, createTypewriterItemSet, graphemes, sealRankingHeader, sealRankingTextItemShell, materializeRankingTextItem } from "./schedule.js";
+export { appendRankingItemSpec, appendRankingSound, appendColumnItem, appendTierBoardItem, appendTopThreeItem, assertColumnProgram, assertColumnStyle, assertRankingHeader, assertRankingItemSpec, assertRankingItemSpecSet, assertRankingTextItemShell, assertRankingSchedule, assertRankingSoundEventPlan, assertRankingSoundStyle, assertTierBoardProgram, assertTierBoardStyle, assertTopThreeProgram, assertTopThreeStyle, buildColumnProgram, buildColumnSoundEvents, buildRankingSchedule, buildTierBoardProgram, buildTierBoardSoundEvents, buildTopThreeProgram, buildTopThreeSoundEvents, createColumnItemSet, createRankingItemSpecSet, createRankingSoundSet, createTierBoardItemSet, createTopThreeItemSet, sealRankingHeader, sealRankingTextItemShell, materializeRankingTextItem } from "./schedule.js";
export {
decodeColumnStyle,
decodeTierBoardStyle,
decodeTopThreeStyle,
- decodeTypewriterListStyle,
} from "./style.js";
export {
renderColumn,
renderRankingAudio,
renderTierBoard,
renderTopThree,
- renderTypewriterList,
} from "./render.js";
export { rankingComponent } from "./component.js";
export { createRankingFragment } from "./fragment.js";
@@ -23,7 +21,5 @@ export {
decodeTierBoardSurface,
decodeTopThreeStyleSurface,
decodeTopThreeSurface,
- decodeTypewriterListStyleSurface,
- decodeTypewriterListSurface,
} from "./surface.js";
export type * from "./types.js";
diff --git a/packages/ranking/src/manifest.ts b/packages/ranking/src/manifest.ts
index 64611c5e..c2929845 100644
--- a/packages/ranking/src/manifest.ts
+++ b/packages/ranking/src/manifest.ts
@@ -31,15 +31,12 @@ export const rankingTypes = {
tierStyle: { module: rankingModuleRef, name: "TierBoardStyle" },
columnStyle: { module: rankingModuleRef, name: "ColumnStyle" },
topThreeStyle: { module: rankingModuleRef, name: "TopThreeStyle" },
- typewriterStyle: { module: rankingModuleRef, name: "TypewriterListStyle" },
tierItems: { module: rankingModuleRef, name: "TierBoardItemSet" },
columnItems: { module: rankingModuleRef, name: "ColumnItemSet" },
topThreeItems: { module: rankingModuleRef, name: "TopThreeItemSet" },
- typewriterItems: { module: rankingModuleRef, name: "TypewriterItemSet" },
tierProgram: { module: rankingModuleRef, name: "TierBoardProgram" },
columnProgram: { module: rankingModuleRef, name: "ColumnProgram" },
topThreeProgram: { module: rankingModuleRef, name: "TopThreeProgram" },
- typewriterProgram: { module: rankingModuleRef, name: "TypewriterListProgram" },
} satisfies Record<string, TypeRef>;
export const rankingProducers = {
@@ -54,16 +51,12 @@ export const rankingProducers = {
createTopThreeItems: { module: rankingModuleRef, name: "create-top-three-items" },
appendTopThreeItem: { module: rankingModuleRef, name: "append-top-three-item" },
appendTopThreeIconItem: { module: rankingModuleRef, name: "append-top-three-icon-item" },
- createTypewriterItems: { module: rankingModuleRef, name: "create-typewriter-items" },
- appendTypewriterItem: { module: rankingModuleRef, name: "append-typewriter-item" },
tierProgram: { module: rankingModuleRef, name: "build-tier-board-program" },
columnProgram: { module: rankingModuleRef, name: "build-column-program" },
topThreeProgram: { module: rankingModuleRef, name: "build-top-three-program" },
- typewriterProgram: { module: rankingModuleRef, name: "build-typewriter-list-program" },
tierEvents: { module: rankingModuleRef, name: "build-tier-board-sound-events" },
columnEvents: { module: rankingModuleRef, name: "build-column-sound-events" },
topThreeEvents: { module: rankingModuleRef, name: "build-top-three-sound-events" },
- typewriterEvents: { module: rankingModuleRef, name: "build-typewriter-list-sound-events" },
createSounds: { module: rankingModuleRef, name: "create-ranking-sounds" },
appendAppearSound: { module: rankingModuleRef, name: "append-ranking-appear-sound" },
appendMoveSound: { module: rankingModuleRef, name: "append-ranking-move-sound" },
@@ -71,7 +64,6 @@ export const rankingProducers = {
renderTier: { module: rankingModuleRef, name: "render-tier-board" },
renderColumn: { module: rankingModuleRef, name: "render-column" },
renderTopThree: { module: rankingModuleRef, name: "render-top-three" },
- renderTypewriter: { module: rankingModuleRef, name: "render-typewriter-list" },
materializeTextItem: { module: rankingModuleRef, name: "materialize-text-item" },
} satisfies Record<string, ProducerRef>;
@@ -81,7 +73,7 @@ const unsigned = { kind: "number", integer: true, minimum: 0 } as const;
const object = (fields: Readonly<Record<string, { readonly schema: ValueSchema; readonly optional?: boolean }>>, allowUnknown = false): ValueSchema => ({
kind: "object", fields, ...(allowUnknown ? { allowUnknown: true } : {}),
});
-const variants = { kind: "string", enum: ["tier-board", "column", "top-three", "typewriter-list"] } as const;
+const variants = { kind: "string", enum: ["tier-board", "column", "top-three"] } as const;
const itemBase = {
id: { schema: string },
stackingOrder: { schema: integer, optional: true },
@@ -93,18 +85,10 @@ export const rankingItemSpecSchema: ValueSchema = { kind: "oneOf", variants: [
object({ variant: { schema: { kind: "literal", value: "tier-board" } }, ...itemBase, tier: { schema: string }, entry: { schema: { kind: "string", enum: ["direct", "stage"] } } }),
object({ variant: { schema: { kind: "literal", value: "column" } }, ...itemBase, label: { schema: string } }),
object({ variant: { schema: { kind: "literal", value: "top-three" } }, ...itemBase, label: { schema: string } }),
- object({ variant: { schema: { kind: "literal", value: "typewriter-list" } }, ...itemBase,
- text: { schema: string }, winner: { schema: { kind: "boolean" } },
- emphasis: { optional: true, schema: object({ start: { schema: unsigned }, endExclusive: { schema: unsigned } }) },
- }),
] };
export const rankingTextItemShellSchema: ValueSchema = { kind: "oneOf", variants: [
object({ variant: { schema: { kind: "literal", value: "column" } }, ...itemBase }),
object({ variant: { schema: { kind: "literal", value: "top-three" } }, ...itemBase }),
- object({ variant: { schema: { kind: "literal", value: "typewriter-list" } }, ...itemBase,
- winner: { schema: { kind: "boolean" } },
- emphasis: { optional: true, schema: object({ start: { schema: unsigned }, endExclusive: { schema: unsigned } }) },
- }),
] };
export const rankingItemSpecSetSchema: ValueSchema = object({
@@ -137,10 +121,9 @@ export const rankingSoundSetSchema: ValueSchema = object({
appear: { schema: object({}, true), optional: true }, move: { schema: object({}, true), optional: true },
});
const programDefinitions = [
- ["tier", rankingTypes.tierProgram, rankingTypes.tierStyle, rankingTypes.tierItems, rankingProducers.tierProgram, rankingProducers.tierEvents, rankingProducers.renderTier],
- ["column", rankingTypes.columnProgram, rankingTypes.columnStyle, rankingTypes.columnItems, rankingProducers.columnProgram, rankingProducers.columnEvents, rankingProducers.renderColumn],
- ["top-three", rankingTypes.topThreeProgram, rankingTypes.topThreeStyle, rankingTypes.topThreeItems, rankingProducers.topThreeProgram, rankingProducers.topThreeEvents, rankingProducers.renderTopThree],
- ["typewriter", rankingTypes.typewriterProgram, rankingTypes.typewriterStyle, rankingTypes.typewriterItems, rankingProducers.typewriterProgram, rankingProducers.typewriterEvents, rankingProducers.renderTypewriter],
+ [rankingTypes.tierProgram, rankingTypes.tierStyle, rankingTypes.tierItems, rankingProducers.tierProgram, rankingProducers.tierEvents, rankingProducers.renderTier],
+ [rankingTypes.columnProgram, rankingTypes.columnStyle, rankingTypes.columnItems, rankingProducers.columnProgram, rankingProducers.columnEvents, rankingProducers.renderColumn],
+ [rankingTypes.topThreeProgram, rankingTypes.topThreeStyle, rankingTypes.topThreeItems, rankingProducers.topThreeProgram, rankingProducers.topThreeEvents, rankingProducers.renderTopThree],
] as const;
export const rankingMarkupSurfaces = [
@@ -407,93 +390,6 @@ export const rankingMarkupSurfaces = [
"Every other property is refused by name, except the board Paint and `stage-stack` keys, which a podium accepts and never reads.",
],
} },
- { name: "typewriter-style", tag: "TypewriterListStyle", mode: "structured", outputs: [rankingTypes.typewriterStyle, rankingTypes.soundStyle],
- vocabulary: {
- summary: "Compiles one SVS Recipe and one exact font into the Style a TypewriterList is drawn in, and the private sound Style it connects.",
- attributes: [
- { name: "id", kind: "identifier", required: true,
- summary: "Names this Style so a TypewriterList can reference it." },
- { name: "recipe", kind: "reference", required: true, accepts: [svsRecipeType],
- summary: "Chooses the Recipe carrying the title and item type, the emphasis and winner colors, the typing rate, board Paint and motion.",
- recipe: [
- { name: "title-font-size", required: false, fallback: "34",
- summary: "Sets the size in pixels the title is set at." },
- { name: "title-font-weight", required: false, fallback: "800",
- summary: "Sets the weight the title is set at." },
- { name: "title-color", required: false, fallback: "#111827",
- summary: "Sets the color the title is drawn in." },
- { name: "title-line-height", required: false, fallback: "1.1",
- summary: "Sets the line height the title is set on, as a multiple of its size." },
- { name: "item-font-size", required: false, fallback: "26",
- summary: "Sets the size in pixels an Item's line is set at." },
- { name: "item-font-weight", required: false, fallback: "600",
- summary: "Sets the weight an Item's line is set at." },
- { name: "item-color", required: false, fallback: "#1f2937",
- summary: "Sets the color an Item's line is drawn in." },
- { name: "item-line-height", required: false, fallback: "1.2",
- summary: "Sets the line height an Item's line is set on, as a multiple of its size." },
- { name: "emphasis-color", required: false, fallback: "#dc2626",
- summary: "Sets the color the emphasized span of an Item is drawn in." },
- { name: "winner-color", required: false, fallback: "#eab308",
- summary: "Sets the color a winning Item is drawn in." },
- { name: "board-background", required: false, fallback: "#151821",
- summary: "Sets the color the paper fills with." },
- { name: "board-border-color", required: false, fallback: "#ffffff33",
- summary: "Sets the color of the paper's border." },
- { name: "board-border-width", required: false, fallback: "1",
- summary: "Sets the width in pixels of the paper's border." },
- { name: "board-radius", required: false, fallback: "18",
- summary: "Sets the corner radius in pixels of the paper." },
- { name: "board-shadow-x", required: false, fallback: "0",
- summary: "Offsets the paper's shadow horizontally in pixels." },
- { name: "board-shadow-y", required: false, fallback: "10",
- summary: "Offsets the paper's shadow vertically in pixels." },
- { name: "board-shadow-blur", required: false, fallback: "24",
- summary: "Sets the blur radius in pixels of the paper's shadow." },
- { name: "board-shadow-spread", required: false, fallback: "0",
- summary: "Sets the spread in pixels of the paper's shadow." },
- { name: "board-shadow-color", required: false, fallback: "#00000066",
- summary: "Sets the color of the paper's shadow." },
- { name: "padding", required: false, fallback: "28",
- summary: "Sets the inset in pixels between the paper's edge and its lines." },
- { name: "row-gap", required: false, fallback: "16",
- summary: "Sets the gap in pixels between Item lines." },
- { name: "title-gap", required: false, fallback: "22",
- summary: "Sets the gap in pixels between the title and the first Item line." },
- { name: "rotation", required: false, fallback: "-1.2",
- summary: "Tilts the whole paper by this many degrees." },
- { name: "frames-per-grapheme", required: false, fallback: "2",
- summary: "Sets how many frames each grapheme of an Item takes to type." },
- { name: "winner-frames", required: false, fallback: "5",
- summary: "Sets how many frames a winning Item's flourish runs for after it finishes typing." },
- { name: "board-stack", required: false, fallback: "20",
- summary: "Sets the draw order the paper itself is placed at." },
- { name: "item-stack", required: false, fallback: "30",
- summary: "Sets the draw order every Item line is placed at, unless the Item overrides it." },
- { name: "appear-gain", required: false, fallback: "1",
- summary: "Sets the gain the appear sound is played at." },
- { name: "move-gain", required: false, fallback: "1",
- summary: "Sets the gain the winner sound is played at." },
- { name: "sound-fade-frames", required: false, fallback: "0",
- summary: "Sets how many frames each sound fades in and out over." },
- ] },
- { name: "font", kind: "reference", required: true,
- accepts: [mediaTypes.fontArtifact, mediaTypes.fontStack],
- summary: "Chooses the exact face, or a whole stack that already carries its own fallbacks, the board copy is set in." },
- ],
- ports: [
- { name: "", type: rankingTypes.typewriterStyle,
- summary: "The compiled visual Style, addressed by the element's own id." },
- { name: "sound", type: rankingTypes.soundStyle,
- summary: "The compiled sound Style, connected only when the board authors a sound." },
- ],
- example: `<ranking:TypewriterListStyle id="list-style" recipe={studio.ranking.list} font={ui-font}/>`,
- notes: [
- "The element is empty; it accepts no children and no text.",
- "The Recipe is validated against the variant, so a Recipe holding another board's keys is refused by name.",
- "Every other property is refused by name, except the unprefixed type, motion and `stage-stack` keys, which a list accepts and never reads.",
- ],
- } },
{ name: "tier", tag: "TierBoard", mode: "structured", outputs: [rankingTypes.header, rankingTypes.itemSpec, rankingTypes.schedule, rankingTypes.tierProgram, compositionTypes.visualTrack, compositionTypes.audioTrack],
vocabulary: {
summary: "Places ordered Items into tier rows, one on each occurrence of a Moment, and publishes the board and the Tracks it renders to.",
@@ -693,81 +589,6 @@ export const rankingMarkupSurfaces = [
"Authoring the appear sound also connects the Style's `.sound` output, so `style` must name a TopThreeStyle written in this Source.",
],
} },
- { name: "typewriter", tag: "TypewriterList", mode: "structured", outputs: [rankingTypes.header, rankingTypes.itemSpec, rankingTypes.textItemShell, textTypes.text, rankingTypes.schedule, rankingTypes.typewriterProgram, compositionTypes.visualTrack, compositionTypes.audioTrack],
- vocabulary: {
- summary: "Types a titled list one line at a time, one on each occurrence of a Moment, and publishes the board and the Tracks it renders to.",
- appearance:
- "One sheet of paper filling its Frame and tilted a degree or so off square, with rounded corners, a thin border and a soft drop shadow; the title stands left-aligned across its top, and a faint hairline rule is drawn under every line the list will hold, so the empty sheet already shows how many lines are coming. Lines type themselves onto those rules from the top down, one line per trigger occurrence in document order, a grapheme at a time fading in from the left. A run marked for emphasis inside a line types in the emphasis color instead of the line color, and a line marked as the winner grows a star at the right end of its rule, scaling up from nothing once that line has finished typing. Typed lines stay on the paper, unmoved, while the ones below them are written.",
- preview: previewImage("TypewriterList.png"),
- attributes: [
- { name: "id", kind: "identifier", required: true,
- summary: "Names this board so its Schedule, Program and Tracks can be referenced elsewhere in the Source." },
- { name: "map", kind: "reference", required: true, accepts: [semanticMapTypes.complete],
- summary: "Chooses the measured SemanticMap that gives every trigger its frame." },
- { name: "space", kind: "reference", required: true, accepts: [programSpaceTypes.programSpace],
- summary: "Chooses the ProgramSpace the board is timed and rendered against." },
- { name: "frame", kind: "reference", required: true, accepts: [spatialTypes.frame],
- summary: "Chooses the Frame the whole board occupies." },
- { name: "during", kind: "reference", required: true, accepts: [narrativeTypes.selection],
- summary: "Chooses the Selection the board is on screen for." },
- { name: "triggers", kind: "reference", required: true, accepts: [narrativeTypes.moment],
- summary: "Chooses the Moment whose occurrences type one TypewriterItem each, in document order." },
- { name: "terminal", kind: "reference", required: true, accepts: [narrativeTypes.moment],
- summary: "Chooses the Moment the board settles on and ends after." },
- { name: "style", kind: "reference", required: true, accepts: [rankingTypes.typewriterStyle],
- summary: "Chooses the TypewriterListStyle this board is drawn in, and only that variant's." },
- { name: "title", kind: "expression", required: true, accepts: [textTypes.text],
- summary: "Sets the heading standing above the list, written literally or chosen from an existing Text." },
- { name: "appear-sound", kind: "reference", required: false, accepts: [mediaTypes.synchronized],
- summary: "Chooses the Synchronized Medium played as each line is typed." },
- { name: "move-sound", kind: "reference", required: false, accepts: [mediaTypes.synchronized],
- summary: "Chooses the Synchronized Medium played as the winner line is marked." },
- ],
- children: [
- { tag: "TypewriterItem", cardinality: "many",
- summary: "One line of the list, typed at its own trigger occurrence in document order.",
- attributes: [
- { name: "id", kind: "identifier", required: false,
- summary: "Names this line within the board; an omitted id is generated from the line's position." },
- { name: "text", kind: "expression", required: false, accepts: [textTypes.text],
- summary: "Sets the line's copy, written literally or chosen from an existing Text." },
- { name: "winner", kind: "literal", required: false, values: ["true", "false"],
- summary: "Decides whether the line is marked as the winner once it is typed, and defaults to false." },
- { name: "emphasis-start", kind: "literal", required: false,
- summary: "Sets the first grapheme of the emphasized run in the line's copy." },
- { name: "emphasis-end", kind: "literal", required: false,
- summary: "Sets the grapheme the emphasized run stops before." },
- { name: "stack", kind: "literal", required: false,
- summary: "Overrides the Style's draw order for this line alone." },
- ],
- text: "The line's copy, read only when `text` is absent." },
- ],
- ports: [
- { name: "schedule", type: rankingTypes.schedule,
- summary: "The resolved Schedule: each Item's trigger frame and its staged, cumulative and settled spans." },
- { name: "program", type: rankingTypes.typewriterProgram,
- summary: "The resolved board: its title, Frame, Style, Schedule and ordered Items." },
- { name: "visual", type: compositionTypes.visualTrack,
- summary: "The rendered board, an ordinary peer VisualTrack." },
- { name: "audio", type: compositionTypes.audioTrack,
- summary: "The rendered board sound, published only when a sound is authored." },
- ],
- example: `<ranking:TypewriterListStyle id="list-style" recipe={studio.ranking.list} font={ui-font}/>
-<ranking:TypewriterList id="list" map={timing.map} space={speech.space} frame={board-frame}
- during={story.selection.board} triggers={story.moment.place} terminal={story.moment.done}
- style={list-style} title="What survived">
- <ranking:TypewriterItem id="line-one" text="Deterministic timing"/>
- <ranking:TypewriterItem id="line-two" text="No hidden runtime choice" winner="true"
- emphasis-start="3" emphasis-end="9"/>
-</ranking:TypewriterList>`,
- notes: [
- "The board requires at least one TypewriterItem, accepts no other child and no text of its own, and Item ids must be unique within it.",
- "A TypewriterItem takes its copy from `text` or from its own element text; writing both is refused.",
- "`emphasis-start` and `emphasis-end` are written together or not at all, and the run they mark must be non-empty and inside the line's copy.",
- "`move-sound` requires at least one TypewriterItem written `winner=\"true\"`; a sound with nothing to sound on is refused.",
- "Authoring either sound also connects the Style's `.sound` output, so `style` must name a TypewriterListStyle written in this Source.",
- ],
- } },
] as const;
@@ -786,15 +607,12 @@ export const rankingManifest: ModuleManifest = {
{ name: rankingTypes.tierStyle.name },
{ name: rankingTypes.columnStyle.name },
{ name: rankingTypes.topThreeStyle.name },
- { name: rankingTypes.typewriterStyle.name },
{ name: rankingTypes.tierItems.name },
{ name: rankingTypes.columnItems.name },
{ name: rankingTypes.topThreeItems.name },
- { name: rankingTypes.typewriterItems.name },
{ name: rankingTypes.tierProgram.name },
{ name: rankingTypes.columnProgram.name },
{ name: rankingTypes.topThreeProgram.name },
- { name: rankingTypes.typewriterProgram.name },
],
capabilities: [],
producers: [
@@ -810,7 +628,6 @@ export const rankingManifest: ModuleManifest = {
[rankingProducers.createTierItems, rankingTypes.tierItems],
[rankingProducers.createColumnItems, rankingTypes.columnItems],
[rankingProducers.createTopThreeItems, rankingTypes.topThreeItems],
- [rankingProducers.createTypewriterItems, rankingTypes.typewriterItems],
] as const).map(([producer, type]) => ({
name: producer.name, inputs: [], outputs: [{ name: "set", type }], needs: [],
})),
@@ -827,11 +644,9 @@ export const rankingManifest: ModuleManifest = {
] as const).map(([producer, type]) => ({
name: producer.name, inputs: [{ name: "set", type }, { name: "spec", type: rankingTypes.itemSpec }, { name: "icon", type: mediaTypes.blobArtifact }], outputs: [{ name: "set", type }], needs: [],
})),
- { name: rankingProducers.appendTypewriterItem.name, inputs: [{ name: "set", type: rankingTypes.typewriterItems }, { name: "spec", type: rankingTypes.itemSpec }], outputs: [{ name: "set", type: rankingTypes.typewriterItems }], needs: [] },
- ...programDefinitions.flatMap(([name, programType, styleType, setType, programProducer, eventProducer, renderProducer]) => [
+ ...programDefinitions.flatMap(([programType, styleType, setType, programProducer, eventProducer, renderProducer]) => [
{ name: programProducer.name, inputs: [
{ name: "header", type: rankingTypes.header },
- ...(name === "typewriter" ? [{ name: "title", type: textTypes.text }] : []),
{ name: "frame", type: spatialTypes.frame }, { name: "schedule", type: rankingTypes.schedule },
{ name: "style", type: styleType }, { name: "set", type: setType },
], outputs: [{ name: "program", type: programType }], needs: [] },
diff --git a/packages/ranking/src/render.ts b/packages/ranking/src/render.ts
index 97248e5a..229d5229 100644
--- a/packages/ranking/src/render.ts
+++ b/packages/ranking/src/render.ts
@@ -11,10 +11,6 @@ import type {
VisualElement,
VisualPresent,
VisualStyleDeclaration,
- VisualTextDocument,
- VisualTextFlow,
- VisualTextPaintLayer,
- VisualTextTypography,
VisualTrack,
} from "@hypit/composition";
import { synchronizedMediaSampleFrames, verifySynchronizedMedia } from "@hypit/media";
@@ -31,10 +27,7 @@ import {
assertRankingSoundStyle,
assertTierBoardProgram,
assertTopThreeProgram,
- assertTypewriterListProgram,
fitRankingStageMotion,
- fitTypewriterStage,
- graphemes,
} from "./schedule.js";
import type {
ColumnItem,
@@ -48,8 +41,6 @@ import type {
TierBoardProgram,
TopThreeItem,
TopThreeProgram,
- TypewriterItem,
- TypewriterListProgram,
} from "./types.js";
function assert(condition: unknown, message: string): asserts condition {
@@ -530,138 +521,6 @@ export function renderTopThree(space: ProgramSpace, program: TopThreeProgram): V
return sealTrack(space, program.id, presents);
}
-function visualTypography(value: RankingTextStyle): VisualTextTypography {
- return {
- fonts: structuredClone(value.fonts), sizePx: value.sizePx, weight: value.weight, style: "normal",
- axes: [], features: [], synthesis: "none", kerning: "normal", trackingPx: 0, wordSpacingPx: 0,
- lineHeight: value.lineHeight, direction: "auto", writingMode: "horizontal-tb", baselineShiftPx: 0,
- tabSize: 4, indentationPx: 0, paragraphBeforePx: 0, paragraphAfterPx: 0, transform: "none",
- variantCaps: "normal", verticalAlign: "baseline", decorations: [],
- cjk: { textSpacing: "normal", punctuationTrim: "none" },
- };
-}
-
-const areaFlow: VisualTextFlow = {
- form: { kind: "area" }, inlineSize: "fixed", blockSize: "fixed",
- paddingPx: { inlineStart: 0, inlineEnd: 0, blockStart: 0, blockEnd: 0 },
- inlineAlign: "start", blockAlign: "center", wrap: "none", overflow: "clip", clipToFrame: true,
- columns: 1, columnGapPx: 0, metricEdge: "line-box",
-};
-
-function typewriterDocument(item: TypewriterItem, style: TypewriterListProgram["style"]): VisualTextDocument {
- const parts = graphemes(item.text);
- if (item.emphasis === undefined) {
- return { paragraphs: [{ id: `${item.id}-p`, inlines: [{ id: `${item.id}-text`, kind: "text", text: item.text }] }] };
- }
- const before = parts.slice(0, item.emphasis.start).join("");
- const emphasis = parts.slice(item.emphasis.start, item.emphasis.endExclusive).join("");
- const after = parts.slice(item.emphasis.endExclusive).join("");
- return { paragraphs: [{
- id: `${item.id}-p`,
- inlines: [
- ...(before.length === 0 ? [] : [{ id: `${item.id}-before`, kind: "text" as const, text: before }]),
- { id: `${item.id}-emphasis`, kind: "text", text: emphasis,
- style: { paints: [{ kind: "fill", paint: { kind: "solid", color: style.emphasisColor } }] } },
- ...(after.length === 0 ? [] : [{ id: `${item.id}-after`, kind: "text" as const, text: after }]),
- ],
- }] };
-}
-
-function paperRotation(program: TypewriterListProgram): VisualStyleDeclaration[] {
- return [
- { name: "transform", value: `rotate(${program.style.rotationDeg}deg)` },
- { name: "transform-origin", value: "center center" },
- ];
-}
-
-export function renderTypewriterList(space: ProgramSpace, program: TypewriterListProgram): VisualTrack {
- assertProgramSpaceIdentity(space);
- assertTypewriterListProgram(program);
- const { frame, style, schedule } = program;
- const titleHeight = style.title.sizePx * style.title.lineHeight;
- const rowHeight = style.item.sizePx * style.item.lineHeight;
- const firstRowY = style.paddingPx + titleHeight + style.titleGapPx;
- const paperElements: VisualElement[] = [absoluteBox({
- id: "paper", order: 0, x: frame.xPx, y: frame.yPx, width: frame.widthPx, height: frame.heightPx,
- style: [...boardStyle(style.paper), ...paperRotation(program)],
- }), simpleText({
- id: "title", parent: "paper", order: 1, text: program.title, typography: style.title,
- x: style.paddingPx, y: style.paddingPx, width: frame.widthPx - style.paddingPx * 2, height: titleHeight, align: "left",
- })];
- for (const [index] of program.items.entries()) {
- const y = firstRowY + index * (rowHeight + style.rowGapPx);
- assert(y + rowHeight <= frame.heightPx - style.paddingPx,
- `TypewriterList cannot fit row ${index + 1} inside its Frame.`);
- paperElements.push(absoluteBox({
- id: `row-rule-${index + 1}`, parent: "paper", order: paperElements.length,
- x: style.paddingPx, y: y + rowHeight - 1, width: frame.widthPx - style.paddingPx * 2, height: 1,
- style: [{ name: "background", value: `${style.item.color}22` }],
- }));
- }
- const presents: VisualPresent[] = [present({
- id: `${program.id}:paper`, start: schedule.outer.startFrame, end: schedule.outer.endFrameExclusive,
- stacking: style.boardStackingOrder, tieBreak: `${program.id}:0000:paper`, elements: paperElements,
- })];
- for (const [index, item] of program.items.entries()) {
- const entry = schedule.entries[index]!;
- const duration = entry.stage.endFrameExclusive - entry.triggerFrame;
- const count = graphemes(item.text).length;
- const fitted = fitTypewriterStage(duration, count, style.framesPerGrapheme, item.winner ? style.winnerFrames : 0);
- const root = `typewriter-item-${item.id}`;
- const y = firstRowY + index * (rowHeight + style.rowGapPx);
- const paints: VisualTextPaintLayer[] = [{ kind: "fill", paint: { kind: "solid", color: style.item.color } }];
- const itemElements = (active: boolean): VisualElement[] => {
- const elements: VisualElement[] = [absoluteBox({
- id: root, order: 0, x: frame.xPx, y: frame.yPx, width: frame.widthPx, height: frame.heightPx,
- style: paperRotation(program),
- }), {
- id: "row-text", parent: root, order: 1, kind: "text-flow",
- style: [
- { name: "height", value: px(rowHeight) }, { name: "left", value: px(style.paddingPx) },
- { name: "position", value: "absolute" }, { name: "top", value: px(y) },
- { name: "width", value: px(frame.widthPx - style.paddingPx * 2 - rowHeight) },
- ],
- document: typewriterDocument(item, style), typography: visualTypography(style.item), paints,
- flow: areaFlow,
- sequences: active && fitted.typingFrames > 0
- ? Array.from({ length: count }, (_, grapheme) => ({
- id: `${item.id}-typing-${grapheme + 1}`, unit: "grapheme" as const,
- range: { start: grapheme, endExclusive: grapheme + 1 }, order: "forward" as const,
- startFrame: Math.floor(grapheme * fitted.typingFrames / count),
- unitDurationFrames: 1, staggerFrames: 0, cycles: 1,
- keyframes: [
- { atProgress: 0, style: [{ name: "opacity", value: 0 }] },
- { atProgress: 1, style: [{ name: "opacity", value: 1 }] },
- ],
- }))
- : [],
- }];
- if (item.winner) elements.push(simpleText({
- id: "winner", parent: root, order: 2, text: "★",
- typography: { ...style.item, color: style.winnerColor },
- x: frame.widthPx - style.paddingPx - rowHeight, y, width: rowHeight, height: rowHeight,
- ...(active ? { animation: animation(duration, [
- { atFrame: 0, style: transformStyle("scale(0.5)", 0) },
- { atFrame: fitted.typingFrames, style: transformStyle("scale(0.5)", 0), easing: "ease-out" },
- { atFrame: fitted.typingFrames + fitted.winnerFrames, style: transformStyle("scale(1)", 1) },
- ]) } : {}),
- }));
- return elements;
- };
- presents.push(present({
- id: `${program.id}:item:${item.id}:stage`, start: entry.stage.startFrame, end: entry.stage.endFrameExclusive,
- stacking: item.stackingOrder ?? style.itemStackingOrder,
- tieBreak: `${program.id}:item:${String(index).padStart(4, "0")}:${item.id}:stage`, elements: itemElements(true),
- }));
- if (entry.settled.endFrameExclusive > entry.settled.startFrame) presents.push(present({
- id: `${program.id}:item:${item.id}:settled`, start: entry.settled.startFrame, end: entry.settled.endFrameExclusive,
- stacking: item.stackingOrder ?? style.itemStackingOrder,
- tieBreak: `${program.id}:item:${String(index).padStart(4, "0")}:${item.id}:settled`, elements: itemElements(false),
- }));
- }
- return sealTrack(space, program.id, presents);
-}
-
export function renderRankingAudio(
space: ProgramSpace,
plan: RankingSoundEventPlan,
diff --git a/packages/ranking/src/schedule.ts b/packages/ranking/src/schedule.ts
index 3d30b5fc..8b2d7eca 100644
--- a/packages/ranking/src/schedule.ts
+++ b/packages/ranking/src/schedule.ts
@@ -52,11 +52,6 @@ import type {
TopThreeItemSpec,
TopThreeProgram,
TopThreeStyle,
- TypewriterItem,
- TypewriterItemSet,
- TypewriterItemSpec,
- TypewriterListProgram,
- TypewriterListStyle,
} from "./types.js";
function assert(condition: unknown, message: string): asserts condition {
@@ -104,7 +99,7 @@ function assertBlobImage(value: { readonly digest: string; readonly size: number
export function assertRankingHeader(value: RankingHeader): void {
identity(value.id, "RankingHeader.id");
- assert(["tier-board", "column", "top-three", "typewriter-list"].includes(value.variant),
+ assert(["tier-board", "column", "top-three"].includes(value.variant),
"RankingHeader.variant is invalid.");
}
@@ -218,22 +213,6 @@ export function assertTopThreeStyle(value: TopThreeStyle): void {
nonNegative(value.labelGapPx, "TopThreeStyle.labelGapPx");
}
-export function assertTypewriterListStyle(value: TypewriterListStyle): void {
- assertRankingBoardPaint(value.paper, "TypewriterListStyle.paper");
- assertRankingTextStyle(value.title, "TypewriterListStyle.title");
- assertRankingTextStyle(value.item, "TypewriterListStyle.item");
- color(value.emphasisColor, "TypewriterListStyle.emphasisColor");
- color(value.winnerColor, "TypewriterListStyle.winnerColor");
- nonNegative(value.paddingPx, "TypewriterListStyle.paddingPx");
- nonNegative(value.rowGapPx, "TypewriterListStyle.rowGapPx");
- nonNegative(value.titleGapPx, "TypewriterListStyle.titleGapPx");
- finite(value.rotationDeg, "TypewriterListStyle.rotationDeg");
- integer(value.framesPerGrapheme, "TypewriterListStyle.framesPerGrapheme", 1);
- integer(value.winnerFrames, "TypewriterListStyle.winnerFrames", 1);
- stacking(value.boardStackingOrder, "TypewriterListStyle.boardStackingOrder");
- stacking(value.itemStackingOrder, "TypewriterListStyle.itemStackingOrder");
-}
-
export function assertRankingItemSpec(value: RankingItemSpec): void {
identity(value.id, "RankingItemSpec.id");
if (value.variant === "tier-board") {
@@ -241,35 +220,17 @@ export function assertRankingItemSpec(value: RankingItemSpec): void {
assert(value.entry === "direct" || value.entry === "stage", `TierBoardItemSpec.${value.id}.entry is invalid.`);
} else if (value.variant === "column") {
assert(value.label.trim().length > 0, `ColumnItemSpec.${value.id}.label is empty.`);
- } else if (value.variant === "top-three") {
- assert(value.label.trim().length > 0, `TopThreeItemSpec.${value.id}.label is empty.`);
} else {
- assert(value.variant === "typewriter-list", "TypewriterItemSpec variant is invalid.");
- assert(value.text.length > 0, `TypewriterItemSpec.${value.id}.text is empty.`);
- assert(typeof value.winner === "boolean", `TypewriterItemSpec.${value.id}.winner is invalid.`);
- if (value.emphasis !== undefined) {
- integer(value.emphasis.start, `TypewriterItemSpec.${value.id}.emphasis.start`);
- integer(value.emphasis.endExclusive, `TypewriterItemSpec.${value.id}.emphasis.endExclusive`, 1);
- assert(value.emphasis.endExclusive > value.emphasis.start,
- `TypewriterItemSpec.${value.id}.emphasis is empty.`);
- }
+ assert(value.variant === "top-three", "RankingItemSpec variant is invalid.");
+ assert(value.label.trim().length > 0, `TopThreeItemSpec.${value.id}.label is empty.`);
}
if (value.stackingOrder !== undefined) stacking(value.stackingOrder, `RankingItemSpec.${value.id}.stackingOrder`);
}
export function assertRankingTextItemShell(value: RankingTextItemShell): void {
identity(value.id, "RankingTextItemShell.id");
- assert(value.variant === "column" || value.variant === "top-three" || value.variant === "typewriter-list",
+ assert(value.variant === "column" || value.variant === "top-three",
"RankingTextItemShell variant is invalid.");
- if (value.variant === "typewriter-list") {
- assert(typeof value.winner === "boolean", `RankingTextItemShell.${value.id}.winner is invalid.`);
- if (value.emphasis !== undefined) {
- integer(value.emphasis.start, `RankingTextItemShell.${value.id}.emphasis.start`);
- integer(value.emphasis.endExclusive, `RankingTextItemShell.${value.id}.emphasis.endExclusive`, 1);
- assert(value.emphasis.endExclusive > value.emphasis.start,
- `RankingTextItemShell.${value.id}.emphasis is empty.`);
- }
- }
if (value.stackingOrder !== undefined) stacking(value.stackingOrder, `RankingTextItemShell.${value.id}.stackingOrder`);
}
@@ -283,14 +244,7 @@ export function materializeRankingTextItem(shell: RankingTextItemShell, content:
assertRankingTextItemShell(shell);
verifyText(content);
assert(content.value.trim().length > 0, `Ranking Text Item ${shell.id} content is empty.`);
- let result: RankingItemSpec;
- if (shell.variant === "column") {
- result = { ...shell, label: content.value };
- } else if (shell.variant === "top-three") {
- result = { ...shell, label: content.value };
- } else {
- result = { ...shell, text: content.value };
- }
+ const result: RankingItemSpec = { ...shell, label: content.value };
assertRankingItemSpec(result);
return canonicalize(result) as unknown as RankingItemSpec;
}
@@ -301,7 +255,7 @@ export function createRankingItemSpecSet(header: RankingHeader): RankingItemSpec
}
export function assertRankingItemSpecSet(value: RankingItemSpecSet): void {
- assert(["tier-board", "column", "top-three", "typewriter-list"].includes(value.variant),
+ assert(["tier-board", "column", "top-three"].includes(value.variant),
"RankingItemSpecSet.variant is invalid.");
const ids = new Set<string>();
for (const item of value.items) {
@@ -373,7 +327,7 @@ export function buildRankingSchedule(input: {
export function assertRankingSchedule(value: RankingSchedule, space?: ProgramSpace): void {
identity(value.id, "RankingSchedule.id");
- assert(["tier-board", "column", "top-three", "typewriter-list"].includes(value.variant),
+ assert(["tier-board", "column", "top-three"].includes(value.variant),
"RankingSchedule.variant is invalid.");
frame(value.outer.startFrame, "RankingSchedule.outer.startFrame");
frame(value.outer.endFrameExclusive, "RankingSchedule.outer.endFrameExclusive");
@@ -416,7 +370,6 @@ function emptySet<T extends { readonly items: readonly unknown[] }>(): T {
export const createTierBoardItemSet = (): TierBoardItemSet => emptySet();
export const createColumnItemSet = (): ColumnItemSet => emptySet();
export const createTopThreeItemSet = (): TopThreeItemSet => emptySet();
-export const createTypewriterItemSet = (): TypewriterItemSet => emptySet();
function ensureNew(items: readonly { readonly id: string }[], id: string): void {
assert(!items.some((item) => item.id === id), `Ranking Item ${id} is duplicated.`);
@@ -446,13 +399,6 @@ export function appendTopThreeItem(set: TopThreeItemSet, spec: TopThreeItemSpec,
return canonicalize({ ...set, items: [...set.items, { ...structuredClone(spec), ...(icon === undefined ? {} : { icon: structuredClone(icon) }) }] }) as unknown as TopThreeItemSet;
}
-export function appendTypewriterItem(set: TypewriterItemSet, spec: TypewriterItemSpec): TypewriterItemSet {
- assert(Array.isArray(set.items), "TypewriterItemSet is invalid.");
- assertRankingItemSpec(spec);
- ensureNew(set.items, spec.id);
- return canonicalize({ ...set, items: [...set.items, structuredClone(spec)] }) as unknown as TypewriterItemSet;
-}
-
function idsEqual(schedule: RankingSchedule, items: readonly { readonly id: string }[]): void {
assert(schedule.entries.length === items.length, "Ranking Program item count differs from its Schedule.");
for (const [index, item] of items.entries()) {
@@ -472,20 +418,6 @@ export function fitRankingStageMotion(
return { appearFrames: Math.min(preferredAppearFrames, durationFrames - moveFrames), moveFrames };
}
-export function fitTypewriterStage(
- durationFrames: number,
- graphemeCount: number,
- preferredFramesPerGrapheme: number,
- preferredWinnerFrames: number,
-): { readonly typingFrames: number; readonly winnerFrames: number } {
- assert(Number.isSafeInteger(durationFrames) && durationFrames > 0, "Typewriter stage duration is invalid.");
- const winnerFrames = Math.min(preferredWinnerFrames, durationFrames);
- return {
- typingFrames: Math.min(graphemeCount * preferredFramesPerGrapheme, durationFrames - winnerFrames),
- winnerFrames,
- };
-}
-
export function buildTierBoardProgram(header: RankingHeader, frameValue: import("@hypit/spatial").SpatialFrame, schedule: RankingSchedule, style: TierBoardStyle, set: TierBoardItemSet): TierBoardProgram {
assert(header.variant === "tier-board" && schedule.variant === "tier-board", "TierBoard variant is inconsistent.");
assertSpatialFrame(frameValue);
@@ -519,26 +451,6 @@ export function buildTopThreeProgram(header: RankingHeader, frameValue: import("
return canonicalize(result) as unknown as TopThreeProgram;
}
-export function graphemes(text: string): string[] {
- return [...new Intl.Segmenter(undefined, { granularity: "grapheme" }).segment(text)].map((value) => value.segment);
-}
-
-export function buildTypewriterListProgram(header: RankingHeader, title: string, frameValue: import("@hypit/spatial").SpatialFrame, schedule: RankingSchedule, style: TypewriterListStyle, set: TypewriterItemSet): TypewriterListProgram {
- assert(header.variant === "typewriter-list" && schedule.variant === "typewriter-list", "TypewriterList variant is inconsistent.");
- assert(title.trim().length > 0, "TypewriterList title is empty.");
- assertSpatialFrame(frameValue);
- assertTypewriterListStyle(style);
- idsEqual(schedule, set.items);
- for (const item of set.items) {
- const count = graphemes(item.text).length;
- if (item.emphasis !== undefined) assert(item.emphasis.endExclusive <= count,
- `Typewriter Item ${item.id} emphasis exceeds its grapheme count.`);
- }
- const result: TypewriterListProgram = { id: header.id, title, frame: structuredClone(frameValue), schedule: structuredClone(schedule), style: structuredClone(style), items: structuredClone(set.items) };
- assertTypewriterListProgram(result);
- return canonicalize(result) as unknown as TypewriterListProgram;
-}
-
export function assertTierBoardProgram(value: TierBoardProgram): void {
assertRankingSchedule(value.schedule);
assert(value.schedule.variant === "tier-board", "TierBoardProgram Schedule variant is invalid.");
@@ -567,16 +479,6 @@ export function assertTopThreeProgram(value: TopThreeProgram): void {
value.items.forEach((item) => { assertRankingItemSpec(item); if (item.icon !== undefined) assertBlobImage(item.icon, `TopThreeItem.${item.id}.icon`); });
}
-export function assertTypewriterListProgram(value: TypewriterListProgram): void {
- assert(value.title.trim().length > 0, "TypewriterListProgram title is empty.");
- assertRankingSchedule(value.schedule);
- assert(value.schedule.variant === "typewriter-list", "TypewriterListProgram Schedule variant is invalid.");
- assertSpatialFrame(value.frame);
- assertTypewriterListStyle(value.style);
- idsEqual(value.schedule, value.items);
- value.items.forEach(assertRankingItemSpec);
-}
-
function event(id: string, itemId: string, kind: "appear" | "move", eventFrame: number): RankingSoundEvent {
return { id: `${id}:${itemId}:${kind}`, itemId, kind, frame: eventFrame };
}
@@ -621,23 +523,9 @@ export function buildTopThreeSoundEvents(schedule: RankingSchedule, style: TopTh
schedule.entries.map((entry) => event(schedule.id, entry.itemId, "appear", entry.triggerFrame)));
}
-export function buildTypewriterSoundEvents(schedule: RankingSchedule, style: TypewriterListStyle, specs: RankingItemSpecSet): RankingSoundEventPlan {
- assert(schedule.variant === "typewriter-list" && specs.variant === "typewriter-list", "Typewriter event inputs disagree.");
- assertTypewriterListStyle(style);
- idsEqual(schedule, specs.items);
- return sealEvents(schedule.id, schedule.variant, schedule.entries.flatMap((entry, index) => {
- const spec = specs.items[index] as TypewriterItemSpec;
- const duration = entry.stage.endFrameExclusive - entry.triggerFrame;
- const fitted = fitTypewriterStage(duration, graphemes(spec.text).length, style.framesPerGrapheme,
- spec.winner ? style.winnerFrames : 0);
- return [event(schedule.id, entry.itemId, "appear", entry.triggerFrame),
- ...(spec.winner ? [event(schedule.id, entry.itemId, "move", entry.triggerFrame + fitted.typingFrames)] : [])];
- }));
-}
-
export function assertRankingSoundEventPlan(value: RankingSoundEventPlan): void {
identity(value.id, "RankingSoundEventPlan.id");
- assert(["tier-board", "column", "top-three", "typewriter-list"].includes(value.variant),
+ assert(["tier-board", "column", "top-three"].includes(value.variant),
"RankingSoundEventPlan.variant is invalid.");
const ids = new Set<string>();
for (const item of value.events) {
diff --git a/packages/ranking/src/style.ts b/packages/ranking/src/style.ts
index 0816ba1c..5a071ddd 100644
--- a/packages/ranking/src/style.ts
+++ b/packages/ranking/src/style.ts
@@ -14,7 +14,6 @@ import {
assertRankingSoundStyle,
assertTierBoardStyle,
assertTopThreeStyle,
- assertTypewriterListStyle,
} from "./schedule.js";
import type {
ColumnStyle,
@@ -25,7 +24,6 @@ import type {
TierBoardStyle,
TierRowStyle,
TopThreeStyle,
- TypewriterListStyle,
} from "./types.js";
const COMMON_KEYS = [
@@ -55,14 +53,6 @@ const TOP_KEYS = [
"ring-width", "label-gap",
] as const;
-const TYPEWRITER_KEYS = [
- ...COMMON_KEYS,
- "title-font-size", "title-font-weight", "title-color", "title-line-height",
- "item-font-size", "item-font-weight", "item-color", "item-line-height",
- "emphasis-color", "winner-color", "padding", "row-gap", "title-gap", "rotation",
- "frames-per-grapheme", "winner-frames",
-] as const;
-
function fail(recipe: SvsRecipe, message: string): never {
throw new Error(`Ranking Recipe ${recipe.path} ${message}`);
}
@@ -108,20 +98,13 @@ function exactFonts(value: FontStackRef | FontArtifactRef): FontArtifactRef[] {
return [structuredClone(value)];
}
-function typography(
- recipe: SvsRecipe,
- fonts: readonly FontArtifactRef[],
- prefix: "" | "title-" | "item-" = "",
- defaults: { readonly size: number; readonly weight: number; readonly color: string; readonly lineHeight: number } = {
- size: 28, weight: 700, color: "#ffffff", lineHeight: 1.15,
- },
-): RankingTextStyle {
+function typography(recipe: SvsRecipe, fonts: readonly FontArtifactRef[]): RankingTextStyle {
return {
fonts: structuredClone(fonts),
- sizePx: number(recipe, `${prefix}font-size`, defaults.size),
- weight: integer(recipe, `${prefix}font-weight`, defaults.weight),
- color: text(recipe, `${prefix}${prefix.length === 0 ? "text-color" : "color"}`, defaults.color),
- lineHeight: number(recipe, `${prefix}line-height`, defaults.lineHeight),
+ sizePx: number(recipe, "font-size", 28),
+ weight: integer(recipe, "font-weight", 700),
+ color: text(recipe, "text-color", "#ffffff"),
+ lineHeight: number(recipe, "line-height", 1.15),
};
}
@@ -258,29 +241,3 @@ export function decodeTopThreeStyle(
assertTopThreeStyle(style);
return { style: canonicalize(style) as unknown as TopThreeStyle, sound: sound(recipe) };
}
-
-export function decodeTypewriterListStyle(
- recipe: SvsRecipe,
- font: FontStackRef | FontArtifactRef,
-): { readonly style: TypewriterListStyle; readonly sound: RankingSoundStyle } {
- known(recipe, TYPEWRITER_KEYS);
- const fonts = exactFonts(font);
- const style: TypewriterListStyle = {
-
- paper: board(recipe),
- title: typography(recipe, fonts, "title-", { size: 34, weight: 800, color: "#111827", lineHeight: 1.1 }),
- item: typography(recipe, fonts, "item-", { size: 26, weight: 600, color: "#1f2937", lineHeight: 1.2 }),
- emphasisColor: text(recipe, "emphasis-color", "#dc2626"),
- winnerColor: text(recipe, "winner-color", "#eab308"),
- paddingPx: number(recipe, "padding", 28),
- rowGapPx: number(recipe, "row-gap", 16),
- titleGapPx: number(recipe, "title-gap", 22),
- rotationDeg: number(recipe, "rotation", -1.2),
- framesPerGrapheme: integer(recipe, "frames-per-grapheme", 2),
- winnerFrames: integer(recipe, "winner-frames", 5),
- boardStackingOrder: integer(recipe, "board-stack", 20),
- itemStackingOrder: integer(recipe, "item-stack", 30),
- };
- assertTypewriterListStyle(style);
- return { style: canonicalize(style) as unknown as TypewriterListStyle, sound: sound(recipe) };
-}
diff --git a/packages/ranking/src/surface.ts b/packages/ranking/src/surface.ts
index 270c13e9..b2dbe6bf 100644
--- a/packages/ranking/src/surface.ts
+++ b/packages/ranking/src/surface.ts
@@ -7,7 +7,7 @@ import { semanticMapTypes } from "@hypit/semantic-map";
import { spatialTypes } from "@hypit/spatial";
import { svsRecipeType } from "@hypit/svs";
import type { SvsRecipe } from "@hypit/svs";
-import { sealText, textTypes } from "@hypit/text";
+import { textTypes } from "@hypit/text";
import type {
StructuredElement,
StructuredSurfaceHandler,
@@ -28,7 +28,6 @@ import {
decodeColumnStyle,
decodeTierBoardStyle,
decodeTopThreeStyle,
- decodeTypewriterListStyle,
} from "./style.js";
import type {
ColumnItemSpec,
@@ -38,7 +37,6 @@ import type {
RankingVariant,
TierBoardItemSpec,
TopThreeItemSpec,
- TypewriterItemSpec,
} from "./types.js";
function sameType(left: TypeRef, right: TypeRef): boolean {
@@ -81,14 +79,6 @@ function integer(element: StructuredElement, name: string): number | undefined {
return value;
}
-function boolean(element: StructuredElement, name: string, fallback: boolean): boolean {
- const source = optionalText(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.`);
-}
-
function reference(
raw: MarkupAttributeValue | undefined,
label: string,
@@ -142,19 +132,11 @@ function styleSurface<T>(
export const decodeTierBoardStyleSurface = styleSurface(rankingTypes.tierStyle, decodeTierBoardStyle);
export const decodeColumnStyleSurface = styleSurface(rankingTypes.columnStyle, decodeColumnStyle);
export const decodeTopThreeStyleSurface = styleSurface(rankingTypes.topThreeStyle, decodeTopThreeStyle);
-export const decodeTypewriterListStyleSurface = styleSurface(rankingTypes.typewriterStyle, decodeTypewriterListStyle);
function localName(element: StructuredElement): string {
return element.name.slice(element.name.lastIndexOf(":") + 1);
}
-function plainChildText(element: StructuredElement): string {
- if (element.children.some((child) => child.kind === "element")) throw new Error(`${element.name} accepts plain text only.`);
- const value = element.children.map((child) => child.kind === "text" ? child.value : "").join("").trim();
- if (value.length === 0) throw new Error(`${element.name} text is empty.`);
- return value;
-}
-
function textValue(
raw: MarkupAttributeValue | undefined,
label: string,
@@ -186,52 +168,19 @@ function itemSpec(
variant, id, tier: text(element, "tier"), entry,
...(stackingOrder === undefined ? {} : { stackingOrder }),
} satisfies TierBoardItemSpec;
- assertRankingItemSpec(value);
- return { spec: value };
- } else if (variant === "column") {
+ } else if (variant === "column" || variant === "top-three") {
allowed(element, ["id", "label", "icon", "stack"]);
empty(element);
const label = textValue(element.attributes.label, `${element.name}.label`, resolve);
- if (typeof label === "string") value = {
- variant, id, label,
- ...(stackingOrder === undefined ? {} : { stackingOrder }),
- } satisfies ColumnItemSpec;
- else return { spec: sealRankingTextItemShell({
+ if (typeof label !== "string") return { spec: sealRankingTextItemShell({
variant, id,
...(stackingOrder === undefined ? {} : { stackingOrder }),
}), content: label };
- } else if (variant === "top-three") {
- allowed(element, ["id", "label", "icon", "stack"]);
- empty(element);
- const label = textValue(element.attributes.label, `${element.name}.label`, resolve);
- if (typeof label === "string") value = {
+ value = {
variant, id, label,
...(stackingOrder === undefined ? {} : { stackingOrder }),
- } satisfies TopThreeItemSpec;
- else return { spec: sealRankingTextItemShell({
- variant, id,
- ...(stackingOrder === undefined ? {} : { stackingOrder }),
- }), content: label };
- } else {
- allowed(element, ["id", "text", "winner", "emphasis-start", "emphasis-end", "stack"]);
- const raw = element.attributes.text;
- const content = raw === undefined ? plainChildText(element) : textValue(raw, `${element.name}.text`, resolve);
- if (raw !== undefined) empty(element);
- const start = integer(element, "emphasis-start");
- const endExclusive = integer(element, "emphasis-end");
- if ((start === undefined) !== (endExclusive === undefined)) throw new Error(`${element.name} emphasis requires both emphasis-start and emphasis-end.`);
- const rest = {
- variant, id, winner: boolean(element, "winner", false),
- ...(start === undefined || endExclusive === undefined ? {} : { emphasis: { start, endExclusive } }),
- ...(stackingOrder === undefined ? {} : { stackingOrder }),
- } as const;
- if (typeof content === "string") value = {
- ...rest, text: content,
- } satisfies TypewriterItemSpec;
- else return { spec: sealRankingTextItemShell({
- ...rest,
- }), content };
- }
+ } satisfies ColumnItemSpec | TopThreeItemSpec;
+ } else throw new Error(`${element.name} belongs to an unknown Ranking variant.`);
assertRankingItemSpec(value);
return { spec: value };
}
@@ -240,13 +189,11 @@ const variantDefinition = {
"tier-board": { tag: "TierItem", style: rankingTypes.tierStyle },
column: { tag: "ColumnItem", style: rankingTypes.columnStyle },
"top-three": { tag: "TopThreeItem", style: rankingTypes.topThreeStyle },
- "typewriter-list": { tag: "TypewriterItem", style: rankingTypes.typewriterStyle },
} as const;
function rankingSurface(variant: RankingVariant): StructuredSurfaceHandler {
return ({ element, resolveReference }) => {
- const common = ["id", "map", "space", "frame", "during", "triggers", "terminal", "style", "appear-sound", "move-sound"];
- allowed(element, variant === "typewriter-list" ? [...common, "title"] : common);
+ allowed(element, ["id", "map", "space", "frame", "during", "triggers", "terminal", "style", "appear-sound", "move-sound"]);
const id = text(element, "id");
const selected = variantDefinition[variant];
const map = reference(element.attributes.map, `${element.name}.map`, semanticMapTypes.complete, resolveReference);
@@ -268,19 +215,10 @@ function rankingSurface(variant: RankingVariant): StructuredSurfaceHandler {
header: { kind: "record", id: headerId }, map: map.ref, space: space.ref, frame: frame.ref,
outer: outer.ref, triggers: triggers.ref, terminal: terminal.ref, style: style.ref,
};
- if (variant === "typewriter-list") {
- const title = textValue(element.attributes.title, `${element.name}.title`, resolveReference);
- if (typeof title === "string") {
- const titleId = `${id}.title`;
- records.push({ id: titleId, type: textTypes.text, value: { kind: "inline", value: sealText(title) }, range: element.range });
- inputs.title = { kind: "record", id: titleId };
- } else inputs.title = title.ref;
- }
const items: RankingFragmentItem[] = [];
const itemIds = new Set<string>();
let index = 0;
let hasStage = false;
- let hasWinner = false;
for (const child of element.children) {
if (child.kind === "text") {
if (child.value.trim().length > 0) throw new Error(`${element.name} accepts ${selected.tag} children only.`);
@@ -294,7 +232,6 @@ function rankingSurface(variant: RankingVariant): StructuredSurfaceHandler {
if (itemIds.has(spec.id)) throw new Error(`${element.name} has duplicate Item id ${spec.id}.`);
itemIds.add(spec.id);
hasStage ||= spec.variant === "tier-board" && spec.entry === "stage";
- hasWinner ||= spec.variant === "typewriter-list" && spec.winner;
const specId = `${id}.item.${suffix}.spec`;
const specName = `item-${suffix}-spec`;
records.push({ id: specId, type: authored.content === undefined ? rankingTypes.itemSpec : rankingTypes.textItemShell, value: { kind: "inline", value: spec as unknown as CanonicalValue }, range: child.range });
@@ -316,7 +253,6 @@ function rankingSurface(variant: RankingVariant): StructuredSurfaceHandler {
};
if (sound.moveName !== undefined && variant === "top-three") throw new Error(`${element.name} has no move sound phase.`);
if (sound.moveName !== undefined && variant === "tier-board" && !hasStage) throw new Error(`${element.name}.move-sound requires one staged TierItem.`);
- if (sound.moveName !== undefined && variant === "typewriter-list" && !hasWinner) throw new Error(`${element.name}.move-sound requires one winner TypewriterItem.`);
for (const [attribute, inputName] of [["appear-sound", sound.appearName], ["move-sound", sound.moveName]] as const) {
if (inputName === undefined) continue;
inputs[inputName] = reference(element.attributes[attribute], `${element.name}.${attribute}`, mediaTypes.synchronized, resolveReference).ref;
@@ -348,4 +284,3 @@ function rankingSurface(variant: RankingVariant): StructuredSurfaceHandler {
export const decodeTierBoardSurface = rankingSurface("tier-board");
export const decodeColumnSurface = rankingSurface("column");
export const decodeTopThreeSurface = rankingSurface("top-three");
-export const decodeTypewriterListSurface = rankingSurface("typewriter-list");
diff --git a/packages/ranking/src/types.ts b/packages/ranking/src/types.ts
index 66d40507..f63ddf66 100644
--- a/packages/ranking/src/types.ts
+++ b/packages/ranking/src/types.ts
@@ -6,7 +6,7 @@ import type {
import type { BlobRef } from "@hypit/protocol";
import type { SpatialFrame } from "@hypit/spatial";
-export type RankingVariant = "tier-board" | "column" | "top-three" | "typewriter-list";
+export type RankingVariant = "tier-board" | "column" | "top-three";
export type RankingHeader = {
readonly id: string;
@@ -123,22 +123,6 @@ export type TopThreeStyle = {
readonly itemStackingOrder: number;
};
-export type TypewriterListStyle = {
- readonly paper: RankingBoardPaint;
- readonly title: RankingTextStyle;
- readonly item: RankingTextStyle;
- readonly emphasisColor: string;
- readonly winnerColor: string;
- readonly paddingPx: number;
- readonly rowGapPx: number;
- readonly titleGapPx: number;
- readonly rotationDeg: number;
- readonly framesPerGrapheme: number;
- readonly winnerFrames: number;
- readonly boardStackingOrder: number;
- readonly itemStackingOrder: number;
-};
-
export type TierBoardItemSpec = {
readonly variant: "tier-board";
readonly id: string;
@@ -161,22 +145,12 @@ export type TopThreeItemSpec = {
readonly stackingOrder?: number;
};
-export type TypewriterItemSpec = {
- readonly variant: "typewriter-list";
- readonly id: string;
- readonly text: string;
- readonly emphasis?: { readonly start: number; readonly endExclusive: number };
- readonly winner: boolean;
- readonly stackingOrder?: number;
-};
-
-export type RankingItemSpec = TierBoardItemSpec | ColumnItemSpec | TopThreeItemSpec | TypewriterItemSpec;
+export type RankingItemSpec = TierBoardItemSpec | ColumnItemSpec | TopThreeItemSpec;
/** Structural half of an Item whose visible copy arrives on a Text graph edge. */
export type RankingTextItemShell =
| Omit<ColumnItemSpec, "label">
- | Omit<TopThreeItemSpec, "label">
- | Omit<TypewriterItemSpec, "text">;
+ | Omit<TopThreeItemSpec, "label">;
export type RankingItemSpecSet = {
readonly variant: RankingVariant;
@@ -186,7 +160,6 @@ export type RankingItemSpecSet = {
export type TierBoardItem = TierBoardItemSpec & { readonly icon: BlobRef };
export type ColumnItem = ColumnItemSpec & { readonly icon?: BlobRef };
export type TopThreeItem = TopThreeItemSpec & { readonly icon?: BlobRef };
-export type TypewriterItem = TypewriterItemSpec;
export type TierBoardItemSet = {
readonly items: readonly TierBoardItem[];
@@ -197,9 +170,6 @@ export type ColumnItemSet = {
export type TopThreeItemSet = {
readonly items: readonly TopThreeItem[];
};
-export type TypewriterItemSet = {
- readonly items: readonly TypewriterItem[];
-};
export type TierBoardProgram = {
readonly id: string;
@@ -222,16 +192,7 @@ export type TopThreeProgram = {
readonly style: TopThreeStyle;
readonly items: readonly TopThreeItem[];
};
-export type TypewriterListProgram = {
- readonly id: string;
- readonly title: string;
- readonly frame: SpatialFrame;
- readonly schedule: RankingSchedule;
- readonly style: TypewriterListStyle;
- readonly items: readonly TypewriterItem[];
-};
-
-export type RankingProgram = TierBoardProgram | ColumnProgram | TopThreeProgram | TypewriterListProgram;
+export type RankingProgram = TierBoardProgram | ColumnProgram | TopThreeProgram;
export type RankingSoundEvent = {
readonly id: string;
diff --git a/packages/ranking/test/ranking.test.ts b/packages/ranking/test/ranking.test.ts
index 86b1d1ee..bf209641 100644
--- a/packages/ranking/test/ranking.test.ts
+++ b/packages/ranking/test/ranking.test.ts
@@ -18,7 +18,6 @@ import {
appendRankingSound,
appendTierBoardItem,
appendTopThreeItem,
- appendTypewriterItem,
buildColumnProgram,
buildColumnSoundEvents,
buildRankingSchedule,
@@ -26,14 +25,11 @@ import {
buildTierBoardSoundEvents,
buildTopThreeProgram,
buildTopThreeSoundEvents,
- buildTypewriterListProgram,
- buildTypewriterSoundEvents,
createColumnItemSet,
createRankingItemSpecSet,
createRankingSoundSet,
createTierBoardItemSet,
createTopThreeItemSet,
- createTypewriterItemSet,
decodeColumnStyle,
decodeColumnStyleSurface,
decodeColumnSurface,
@@ -43,15 +39,10 @@ import {
decodeTopThreeStyle,
decodeTopThreeStyleSurface,
decodeTopThreeSurface,
- decodeTypewriterListStyle,
- decodeTypewriterListStyleSurface,
- decodeTypewriterListSurface,
- graphemes,
renderColumn,
renderRankingAudio,
renderTierBoard,
renderTopThree,
- renderTypewriterList,
rankingComponent,
rankingManifest,
rankingMarkupSurfaces,
@@ -66,7 +57,6 @@ import type {
RankingSchedule,
TierBoardItemSpec,
TopThreeItemSpec,
- TypewriterItemSpec,
} from "@hypit/ranking";
import { narrativeTypes } from "@hypit/narrative";
import { programSpaceTypes } from "@hypit/program-space";
@@ -148,9 +138,6 @@ const columnSpec = (id: string): ColumnItemSpec => ({
const topSpec = (id: string): TopThreeItemSpec => ({
variant: "top-three", id, label: id.toUpperCase(),
});
-const typeSpec = (id: string, text: string, winner = false): TypewriterItemSpec => ({
- variant: "typewriter-list", id, text, winner,
-});
test("RankingSchedule zips authored item and Moment order and preserves a settled suffix", () => {
const owner = header("column", "tools");
@@ -189,7 +176,6 @@ test("variant Style decoders reject unknown Recipes and keep exact fonts and ind
assert.deepEqual([tier.style.boardStackingOrder, tier.style.stageStackingOrder, tier.style.itemStackingOrder], [8, 20, 31]);
assert.throws(() => decodeColumnStyle(recipe("ranking.column", { "tier-only": 1 }), font), /does not accept/u);
assert.equal(decodeTopThreeStyle(recipe("ranking.top"), font).style.slotColors.length, 3);
- assert.equal(decodeTypewriterListStyle(recipe("ranking.typewriter"), font).style.framesPerGrapheme, 2);
});
test("TierBoard owns cumulative direct/stage placement and rejects invalid schedule boundaries", () => {
@@ -251,38 +237,6 @@ test("TopThree accepts one to three optional-image Items and removes active acce
schedule(owner, [...semantic, fourth]), style, tooMany), /at most three/u);
});
-test("Typewriter uses Unicode graphemes, explicit emphasis and winner timing without generic Text masquerading", () => {
- const owner = header("typewriter-list", "list");
- const first: TypewriterItemSpec = {
- ...typeSpec("first", "A👩‍💻B", true), emphasis: { start: 1, endExclusive: 2 },
- };
- const semantic = [first, typeSpec("second", "Done")];
- const style = decodeTypewriterListStyle(recipe("ranking.typewriter", {
- "frames-per-grapheme": 2, "winner-frames": 4,
- }), font).style;
- assert.deepEqual(graphemes(first.text), ["A", "👩‍💻", "B"]);
- let set = createTypewriterItemSet();
- set = appendTypewriterItem(set, first);
- set = appendTypewriterItem(set, semantic[1]!);
- const program = buildTypewriterListProgram(owner, "Tools", frame, schedule(owner, semantic), style, set);
- const track = renderTypewriterList(space, program);
- const row = track.presents.find((item) => item.id.endsWith(":item:first:stage"))!;
- const text = row.elements.find((item) => item.kind === "text-flow");
- assert.equal(text?.kind, "text-flow");
- assert.deepEqual(text?.sequences.map((sequence) => sequence.range), [
- { start: 0, endExclusive: 1 },
- { start: 1, endExclusive: 2 },
- { start: 2, endExclusive: 3 },
- ]);
- const emphasis = text?.document.paragraphs[0]?.inlines[1];
- assert.equal(emphasis?.kind, "text");
- assert.equal(emphasis.kind === "text" ? emphasis.text : undefined, "👩‍💻");
- assert.ok(row.elements.some((item) => item.kind === "text" && item.text === "★"));
- assert.doesNotThrow(() => buildTypewriterListProgram(owner, "Tools", frame, schedule(owner, semantic), {
- ...style, framesPerGrapheme: 20,
- }, set));
-});
-
const sound = (id: string): SynchronizedMedia => ({
timeline: { frameRate: { numerator: 30, denominator: 1 }, frameCount: 3 },
audio: {
@@ -321,12 +275,6 @@ test("each component owns a distinct event law and repeated lowering is canonica
const top = decodeTopThreeStyle(recipe("ranking.top"), font).style;
assert.deepEqual(buildTopThreeSoundEvents(schedule(topOwner, topItems), top, specs(topOwner, topItems)).events.map((item) => item.kind), ["appear"]);
- const typeOwner = header("typewriter-list", "type-events");
- const typeItems = [typeSpec("winner", "ABC", true)];
- const type = decodeTypewriterListStyle(recipe("ranking.typewriter"), font).style;
- assert.deepEqual(buildTypewriterSoundEvents(schedule(typeOwner, typeItems), type, specs(typeOwner, typeItems)).events.map((item) => item.kind),
- ["appear", "move"]);
-
const columnOwner = header("column", "deterministic");
const columnItems = [columnSpec("one")];
const columnStyle = decodeColumnStyle(recipe("ranking.column"), font).style;
@@ -335,7 +283,7 @@ test("each component owns a distinct event law and repeated lowering is canonica
assert.deepEqual(renderColumn(space, program), renderColumn(space, program));
});
-test("all four author Surfaces preserve explicit semantic, spatial, font, image and optional sound graph edges", async () => {
+test("all three author Surfaces preserve explicit semantic, spatial, font, image and optional sound graph edges", async () => {
createResolvedClosure([...videoContractManifests, textManifest, rankingManifest]);
const range = { source: "ranking.svml", start: 0, end: 1 };
const ref = (path: string): MarkupAttributeValue => ({ kind: "reference", path });
@@ -363,7 +311,6 @@ test("all four author Surfaces preserve explicit semantic, spatial, font, image
["tier-style", rankingTypes.tierStyle, decodeTierBoardStyleSurface, { rows: "s:S:#ef4444|a:A:#22c55e" }],
["column-style", rankingTypes.columnStyle, decodeColumnStyleSurface, {}],
["top-style", rankingTypes.topThreeStyle, decodeTopThreeStyleSurface, {}],
- ["type-style", rankingTypes.typewriterStyle, decodeTypewriterListStyleSurface, {}],
] as const;
for (const [id, type, handler, properties] of styleCases) {
references.set(`${id}-recipe`, inlineReference(`${id}-recipe`, svsRecipeType, recipe(id, properties)));
@@ -393,10 +340,6 @@ test("all four author Surfaces preserve explicit semantic, spatial, font, image
id: "top", map: ref("map"), space: ref("space"), frame: ref("frame"), during: ref("outer"),
triggers: ref("triggers"), terminal: ref("terminal"), style: ref("top-style"),
}, [node("ranking:TopThreeItem", { label: "First" }), node("ranking:TopThreeItem", { label: "Second", icon: ref("icon-1") })])],
- [decodeTypewriterListSurface, node("ranking:TypewriterList", {
- id: "typed", title: "Proof", map: ref("map"), space: ref("space"), frame: ref("frame"), during: ref("outer"),
- triggers: ref("triggers"), terminal: ref("terminal"), style: ref("type-style"),
- }, [node("ranking:TypewriterItem", { winner: "true", "emphasis-start": "1", "emphasis-end": "2" }, [{ kind: "text", value: "A👩‍💻B", range }])])],
] as const;
for (const [handler, element] of cases) {
const result = await handler({
@@ -424,7 +367,7 @@ test("all four author Surfaces preserve explicit semantic, spatial, font, image
});
test("Ranking Surfaces declare their sealed Records and icon Producers consume Blob values", async () => {
- for (const name of ["tier", "column", "top-three", "typewriter"]) {
+ for (const name of ["tier", "column", "top-three"]) {
const surface = rankingMarkupSurfaces.find((item) => item.name === name);
assert.ok(surface?.outputs.some((type) => type.name === rankingTypes.header.name), `${name} header output`);
assert.ok(surface?.outputs.some((type) => type.name === rankingTypes.itemSpec.name), `${name} item output`);
diff --git a/packages/text/README.md b/packages/text/README.md
index 57c8a528..08a07b07 100644
--- a/packages/text/README.md
+++ b/packages/text/README.md
@@ -43,7 +43,7 @@ separate packages.
- exact model prompt ports;
- `@hypit/typography-track` Point, Area and Path content;
-- Ranking Column/TopThree labels and Typewriter title/rows;
+- Ranking Column/TopThree labels;
- Comment Sticker comment, author, header and metadata copy;
- Deck Card labels.