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: separate temporal anchors from audiovisual composition

kashorin836349e8e899
diff --git a/packages/audio-track-studio/README.md b/packages/audio-track-studio/README.md
deleted file mode 100644
index dc718649..00000000
--- a/packages/audio-track-studio/README.md
+++ /dev/null
@@ -1,23 +0,0 @@
-# `@hypit/audio-track-studio`
-
-Hypit Studio Companion for `@hypit/audio-track`. The domain package does not depend on this package.
-
-Each Clip has a title and waveform body. An explicit author `id` supplies its
-title; otherwise the Companion displays the exact `source` reference. Display
-names do not replace the Clip's identity or writeback endpoint. This is the same
-rule as Visual Clips. For example, `id="soundtrack" source={music.media}` shows
-`soundtrack`; omitting the id shows `music.media`. Here `.media` is the source
-output port, not an Audio-specific name suffix.
-
-When contains the absolute Clip Window and its target-relative fades. How contains gain.
-Gain displays as a percentage (0–6400%) and writes back as a scalar; duration controls preserve
-their authored `f`, `ms` or `s` unit. Omitted gain and fade defaults remain editable; the first edit
-writes an explicit attribute.
-
-Source-time is a separate structural binding. It can be omitted for bounded partial identity or
-authored as one or more `Map` relations, but the Companion does not pretend an arbitrary piecewise
-function is one editable playback-mode dropdown. Final validation and lowering remain owned by
-Audio Track.
-
-Selecting an overlapping Clip raises it in the editing lane while all sounds
-continue to mix. Timing gestures follow the same absolute temporal bindings as Visual Track.
diff --git a/packages/audio-track-studio/package.json b/packages/audio-track-studio/package.json
deleted file mode 100644
index 70b73154..00000000
--- a/packages/audio-track-studio/package.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "name": "@hypit/audio-track-studio",
- "version": "0.0.0-dev",
- "license": "SEE LICENSE IN LICENSE",
- "private": true,
- "type": "module",
- "exports": { ".": "./src/index.ts" },
- "hypit": { "activation": "./src/activation.ts" },
- "dependencies": {
- "@hypit/audio-track": "workspace:*",
- "@hypit/composition": "workspace:*",
- "@hypit/studio-adapter": "workspace:*",
- "@hypit/temporal": "workspace:*"
- }
-}
diff --git a/packages/audio-track-studio/src/activation.ts b/packages/audio-track-studio/src/activation.ts
deleted file mode 100644
index b3274618..00000000
--- a/packages/audio-track-studio/src/activation.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { createStudioCompanionHostFacet } from "@hypit/studio-adapter";
-import { audioTrackStudioParameterCompanions, audioTrackStudioTrackCompanions } from "./index.js";
-
-export default {
- format: "hypit.node-package@1" as const,
- hostFacets: [createStudioCompanionHostFacet({
- tracks: audioTrackStudioTrackCompanions,
- parameters: audioTrackStudioParameterCompanions,
- })],
-};
diff --git a/packages/audio-track/README.md b/packages/audio-track/README.md
index 436ac0e1..217be45b 100644
--- a/packages/audio-track/README.md
+++ b/packages/audio-track/README.md
@@ -51,3 +51,16 @@ the base package and Core do not acquire a catalogue of sound roles or effects.
Using synchronized media here does not make its picture visible. Author picture independently with
[`@hypit/visual-track`](../visual-track/README.md).
+
+## Distribution and Studio
+
+Audio Track is an independently versioned official Author Package. The official Hypit video
+Distribution installs it by an ordinary npm dependency, while Source selects it explicitly with
+`<import from="@hypit/audio-track@1" .../>`. The package owns its Clip/Track authoring model, runtime
+facet and specialized Studio companion in one activation and one release lifecycle.
+
+The terminal `Composition.AudioTrack` ABI remains owned by Composition rather than this package.
+Other components can therefore publish an AudioTrack without depending on Audio Track, and Studio's
+generic terminal fallback can still display those contributions. Package managers and ordinary
+lockfiles select the physical package version; Hypit does not add another version or installation
+mechanism.
diff --git a/packages/audio-track/package.json b/packages/audio-track/package.json
index f8130b02..b3278764 100644
--- a/packages/audio-track/package.json
+++ b/packages/audio-track/package.json
@@ -1,34 +1,46 @@
{
"name": "@hypit/audio-track",
- "version": "0.0.0-dev",
+ "version": "0.1.0",
"license": "SEE LICENSE IN LICENSE",
"private": true,
"type": "module",
"exports": {
- ".": "./src/index.ts"
+ ".": "./src/index.ts",
+ "./studio": "./src/studio.ts"
},
+ "files": [
+ "dist",
+ "README.md"
+ ],
"hypit": {
"activation": "./src/activation.ts"
},
- "dependencies": {
- "@hypit/component-kit": "workspace:*",
- "@hypit/composition": "workspace:*",
- "@hypit/elaborator": "workspace:*",
- "@hypit/media": "workspace:*",
- "@hypit/protocol": "workspace:*",
- "@hypit/timeline": "workspace:*",
- "@hypit/temporal": "workspace:*",
- "@hypit/temporal-markup": "workspace:*",
- "@hypit/markup": "workspace:*"
+ "peerDependencies": {
+ "@hypit/hypit": "workspace:^",
+ "@hypit/studio-companion": "workspace:^"
},
"devDependencies": {
- "@hypit/artifact": "workspace:*",
- "@hypit/core": "workspace:*",
- "@hypit/media-pipeline": "workspace:*",
+ "@hypit/compiler": "workspace:*",
+ "@hypit/hypit": "workspace:*",
+ "@hypit/studio-companion": "workspace:*",
+ "@hypit/blob": "workspace:*",
+ "@hypit/producer": "workspace:*",
+ "@hypit/composition": "workspace:*",
+ "@hypit/kernel": "workspace:*",
+ "@hypit/author": "workspace:*",
+ "@hypit/source": "workspace:*",
+ "@hypit/markup": "workspace:*",
+ "@hypit/media-operations": "workspace:*",
"@hypit/spatial": "workspace:*",
- "@hypit/speech": "workspace:*",
"@hypit/speech-evidence": "workspace:*",
- "@hypit/validation": "workspace:*",
- "@hypit/visual-ir": "workspace:*"
+ "@hypit/admission": "workspace:*",
+ "@hypit/media": "workspace:*",
+ "@hypit/narrative": "workspace:*",
+ "@hypit/narrative-temporal": "workspace:*",
+ "@hypit/protocol": "workspace:*",
+ "@hypit/recipe": "workspace:*",
+ "@hypit/temporal": "workspace:*",
+ "@hypit/timeline": "workspace:*",
+ "typescript": "5.9.3"
}
}
diff --git a/packages/audio-track/src/activation.ts b/packages/audio-track/src/activation.ts
index a111f816..8e3c3857 100644
--- a/packages/audio-track/src/activation.ts
+++ b/packages/audio-track/src/activation.ts
@@ -1,4 +1,7 @@
-import { createMarkupSurfaceHostFacet } from "@hypit/markup";
+import { createAdmissionPackageFacet } from "@hypit/hypit/admission";
+import { createProducerPackageFacet } from "@hypit/hypit/producer";
+import { createMarkupSurfaceFacet } from "@hypit/hypit/markup";
+import { createStudioCompanionFacet } from "@hypit/studio-companion";
import {
audioTrackComponent,
audioTrackManifest,
@@ -7,22 +10,27 @@ import {
decodeAudioSourceTimeSurface,
audioTrackMarkupSurfaces,
} from "./index.js";
+import { audioTrackStudioParameterCompanions, audioTrackStudioTrackCompanions } from "./studio.js";
export const hypitPackage = {
- format: "hypit.node-package@1" as const,
+ format: "hypit.package@1" as const,
modules: [{ manifest: audioTrackManifest }],
- components: [audioTrackComponent],
- hostFacets: [
- createMarkupSurfaceHostFacet({
+ facets: [
+ ...[audioTrackComponent].flatMap((component) => [createProducerPackageFacet(component), createAdmissionPackageFacet(component)]),
+ createMarkupSurfaceFacet({
module: audioTrackModuleRef,
declaration: audioTrackMarkupSurfaces.find((item) => item.name === "track")!,
handler: decodeAudioTrackSurface,
}),
- createMarkupSurfaceHostFacet({
+ createMarkupSurfaceFacet({
module: audioTrackModuleRef,
declaration: audioTrackMarkupSurfaces.find((item) => item.name === "source-time")!,
handler: decodeAudioSourceTimeSurface,
}),
+ createStudioCompanionFacet({
+ tracks: audioTrackStudioTrackCompanions,
+ parameters: audioTrackStudioParameterCompanions,
+ }),
],
};
export default hypitPackage;
diff --git a/packages/audio-track/src/component.ts b/packages/audio-track/src/component.ts
index 573c9949..65c02f03 100644
--- a/packages/audio-track/src/component.ts
+++ b/packages/audio-track/src/component.ts
@@ -1,9 +1,10 @@
-import type { Timeline } from "@hypit/timeline";
-import type { ComponentPackage } from "@hypit/component-kit";
-import type { SynchronizedMedia } from "@hypit/media";
-import { canonicalize } from "@hypit/protocol";
-import type { StoredValue } from "@hypit/protocol";
-import type { TemporalWindow } from "@hypit/temporal";
+import type { ProducerPackage } from "@hypit/hypit/producer";
+import type { AdmissionPackage } from "@hypit/hypit/admission";
+import type { StoredValue } from "@hypit/hypit/protocol";
+import { canonicalize } from "@hypit/hypit/protocol";
+import type { SynchronizedMedia } from "@hypit/hypit/media";
+import type { TemporalWindow } from "@hypit/hypit/temporal";
+import type { Timeline } from "@hypit/hypit/timeline";
import { audioTrackProducers, audioTrackTypes } from "./manifest.js";
import {
@@ -47,4 +48,4 @@ export const audioTrackComponent = {
type: audioTrackTypes.program,
handler: ({ value }) => assertAudioTrackProgram(inline<AudioTrackProgram>(value, "AudioTrackProgram")),
}],
-} satisfies ComponentPackage;
+} satisfies ProducerPackage & AdmissionPackage;
diff --git a/packages/audio-track/src/fragment.ts b/packages/audio-track/src/fragment.ts
index e88ece4a..2e9f7271 100644
--- a/packages/audio-track/src/fragment.ts
+++ b/packages/audio-track/src/fragment.ts
@@ -1,10 +1,10 @@
-import { timelineTypes } from "@hypit/timeline";
+import { timelineTypes } from "@hypit/hypit/timeline";
-import { compositionTypes } from "@hypit/composition";
-import { sealGraphFragment } from "@hypit/elaborator";
-import type { FragmentOperation } from "@hypit/elaborator";
-import { mediaTypes } from "@hypit/media";
-import { temporalTypes } from "@hypit/temporal";
+import { compositionTypes } from "@hypit/hypit/composition";
+import { sealGraphFragment } from "@hypit/hypit/author";
+import type { FragmentOperation } from "@hypit/hypit/author";
+import { mediaTypes } from "@hypit/hypit/media";
+import { temporalTypes } from "@hypit/hypit/temporal";
import { audioTrackProducers, audioTrackTypes } from "./manifest.js";
diff --git a/packages/audio-track/src/manifest.ts b/packages/audio-track/src/manifest.ts
index c79d5951..eb644e98 100644
--- a/packages/audio-track/src/manifest.ts
+++ b/packages/audio-track/src/manifest.ts
@@ -1,13 +1,13 @@
-import { compositionDependency, compositionTypes } from "@hypit/composition";
-import { mediaDependency, mediaTypes } from "@hypit/media";
-import { blobRefObjectSchema } from "@hypit/protocol";
-import type { ModuleManifest, ProducerRef, TypeRef, ValueSchema } from "@hypit/protocol";
-import { temporalDependency, temporalTypes } from "@hypit/temporal";
+import { compositionDependency, compositionTypes } from "@hypit/hypit/composition";
+import { mediaDependency, mediaTypes } from "@hypit/hypit/media";
+import { blobRefObjectSchema } from "@hypit/hypit/protocol";
+import type { ModuleManifest, ProducerRef, TypeRef, ValueSchema } from "@hypit/hypit/protocol";
+import { temporalDependency, temporalTypes } from "@hypit/hypit/temporal";
import {
temporalContextAttributeVocabulary,
temporalWindowAttributeVocabulary,
-} from "@hypit/temporal-markup";
-import { timelineDependency, timelineTypes } from "@hypit/timeline";
+} from "@hypit/hypit/temporal/markup";
+import { timelineDependency, timelineTypes } from "@hypit/hypit/timeline";
export const audioTrackModuleRef = { name: "@hypit/audio-track", version: "1" } as const;
export const audioTrackTypes = {
diff --git a/packages/audio-track/src/program.ts b/packages/audio-track/src/program.ts
index c6ea4cd1..b11510ff 100644
--- a/packages/audio-track/src/program.ts
+++ b/packages/audio-track/src/program.ts
@@ -1,12 +1,12 @@
-import { assertTimelineIdentity, timelineFrameSampleBoundary, timelineSampleFrames } from "@hypit/timeline";
-import type { Timeline } from "@hypit/timeline";
-import { assertAudioTrackIdentity, sealAudioTrack } from "@hypit/composition";
-import type { AudioClip, AudioTrack } from "@hypit/composition";
-import { synchronizedMediaSampleFrames, verifySynchronizedMedia } from "@hypit/media";
-import type { SynchronizedMedia } from "@hypit/media";
-import { canonicalize, isResourceId } from "@hypit/protocol";
-import { assertTemporalWindowFor, temporalDurationInSamples } from "@hypit/temporal";
-import type { TemporalWindow, TemporalDuration } from "@hypit/temporal";
+import { assertTimelineIdentity, timelineFrameSampleBoundary, timelineSampleFrames } from "@hypit/hypit/timeline";
+import type { Timeline } from "@hypit/hypit/timeline";
+import { assertAudioTrackIdentity, sealAudioTrack } from "@hypit/hypit/composition";
+import type { AudioClip, AudioTrack } from "@hypit/hypit/composition";
+import { synchronizedMediaSampleFrames, verifySynchronizedMedia } from "@hypit/hypit/media";
+import type { SynchronizedMedia } from "@hypit/hypit/media";
+import { canonicalize, isResourceId } from "@hypit/hypit/protocol";
+import { assertTemporalWindowFor, temporalDurationInSamples } from "@hypit/hypit/temporal";
+import type { TemporalWindow, TemporalDuration } from "@hypit/hypit/temporal";
import type {
AudioClipSpec,
diff --git a/packages/audio-track/src/source-time.ts b/packages/audio-track/src/source-time.ts
index 6b9e6653..9a6350e1 100644
--- a/packages/audio-track/src/source-time.ts
+++ b/packages/audio-track/src/source-time.ts
@@ -2,9 +2,9 @@ import type {
AudioSourceTimeMap,
AudioSourceTimePiece,
AudioSourceTimeRational,
-} from "@hypit/composition";
-import { temporalDurationInSamples } from "@hypit/temporal";
-import type { Timeline } from "@hypit/timeline";
+} from "@hypit/hypit/composition";
+import { temporalDurationInSamples } from "@hypit/hypit/temporal";
+import type { Timeline } from "@hypit/hypit/timeline";
import type {
AudioSourceTimeBounds,
diff --git a/packages/audio-track-studio/src/index.ts b/packages/audio-track/src/studio.ts
similarity index 89%
rename from packages/audio-track-studio/src/index.ts
rename to packages/audio-track/src/studio.ts
index dc763ffa..8b26d0cd 100644
--- a/packages/audio-track-studio/src/index.ts
+++ b/packages/audio-track/src/studio.ts
@@ -1,7 +1,5 @@
-import { audioClipDefaults, audioTrackModuleRef, audioTrackTypes } from "@hypit/audio-track";
-import type { AudioTrackProgram } from "@hypit/audio-track";
-import { compositionTypes } from "@hypit/composition";
-import type { StudioTrackCompanion, StudioTrackCompanionContext } from "@hypit/studio-adapter";
+import { compositionTypes } from "@hypit/hypit/composition";
+import type { StudioTrackCompanion, StudioTrackCompanionContext } from "@hypit/studio-companion";
import {
artifactPreview,
authoredItemTitle,
@@ -10,7 +8,10 @@ import {
requiredSurfaceValue,
temporalLineageFor,
temporalDomainSource,
-} from "@hypit/studio-adapter";
+} from "@hypit/studio-companion";
+import { audioClipDefaults } from "./surface.js";
+import { audioTrackModuleRef, audioTrackTypes } from "./manifest.js";
+import type { AudioTrackProgram } from "./types.js";
function projectAudio(context: StudioTrackCompanionContext) {
const program = requiredSurfaceValue(context, "program") as AudioTrackProgram;
diff --git a/packages/audio-track/src/surface.ts b/packages/audio-track/src/surface.ts
index b1437929..7a2bf872 100644
--- a/packages/audio-track/src/surface.ts
+++ b/packages/audio-track/src/surface.ts
@@ -1,17 +1,11 @@
-import { mediaTypes } from "@hypit/media";
-import type {
- MarkupAttributeValue,
- StructuredElement,
- StructuredSurfaceHandler,
- SurfaceRecordDraft,
- SurfaceResolvedReference,
-} from "@hypit/markup";
-import type { TemporalDuration } from "@hypit/temporal";
+import { mediaTypes } from "@hypit/hypit/media";
+import type { MarkupAttributeValue, StructuredElement, StructuredSurfaceHandler, SurfaceRecordDraft, SurfaceResolvedReference } from "@hypit/hypit/markup";
+import type { TemporalDuration } from "@hypit/hypit/temporal";
import {
createTemporalWindowConstruction,
resolveTemporalContext,
temporalWindowAttributeNames,
-} from "@hypit/temporal-markup";
+} from "@hypit/hypit/temporal/markup";
import { createAudioTrackFragment } from "./fragment.js";
import { audioTrackTypes } from "./manifest.js";
diff --git a/packages/audio-track/src/types.ts b/packages/audio-track/src/types.ts
index 4ddf5ae7..5b4e786b 100644
--- a/packages/audio-track/src/types.ts
+++ b/packages/audio-track/src/types.ts
@@ -1,8 +1,8 @@
-import type { AudioSourceTimeMap, AudioSourceTimeRational, FrameSpan } from "@hypit/composition";
-import type { BlobRef } from "@hypit/protocol";
+import type { AudioSourceTimeMap, AudioSourceTimeRational, FrameSpan } from "@hypit/hypit/composition";
+import type { BlobRef } from "@hypit/hypit/protocol";
import type {
TemporalDuration,
-} from "@hypit/temporal";
+} from "@hypit/hypit/temporal";
export type AudioSourceTimePoint = {
readonly edge: "start" | "end";
diff --git a/packages/audio-track/test/audio-track.test.ts b/packages/audio-track/test/audio-track.test.ts
index 36eec001..ab4701e3 100644
--- a/packages/audio-track/test/audio-track.test.ts
+++ b/packages/audio-track/test/audio-track.test.ts
@@ -21,28 +21,28 @@ import {
decodeAudioTrackSurface,
} from "@hypit/audio-track";
import type { AudioClipSpec, AudioSourceTimeSpec, AudioTrackSet } from "@hypit/audio-track";
-import { artifactManifest } from "@hypit/artifact";
-import { registerTypeValidatorFacets } from "@hypit/component-kit";
+import { blobManifest } from "@hypit/blob";
+import { registerTypeValidatorFacets } from "@hypit/admission";
import { sealComposition, compositionManifest, compositionTypes } from "@hypit/composition";
-import { createResolvedClosure, sealBuildRequest, start } from "@hypit/core";
-import { AuthorFrontendRegistry, compileSourceClosure, resolveCompiledSourceExport } from "@hypit/elaborator";
+import { createResolvedClosure, sealBuildRequest, start } from "@hypit/kernel";
+import { AuthorFrontendRegistry, resolveCompiledSourceExport } from "@hypit/author";
+import { compileSourceClosure } from "@hypit/compiler";
import type { SynchronizedMedia } from "@hypit/media";
import { mediaComponent, mediaDependency, mediaManifest, mediaTypes } from "@hypit/media";
import type { NarrativeMomentRef, NarrativeSelectionRef } from "@hypit/narrative";
import { narrativeManifest } from "@hypit/narrative";
-import { compileAudioProgramPlan } from "@hypit/media-pipeline";
+import { compileAudioProgramPlan } from "@hypit/media-operations";
import type { ModuleManifest } from "@hypit/protocol";
import { temporalProducers } from "@hypit/temporal";
import type { TemporalDuration } from "@hypit/temporal";
import { speechEvidenceManifest } from "@hypit/speech-evidence";
-import { speechManifest } from "@hypit/speech";
import { narrativeTemporalManifest } from "@hypit/narrative-temporal";
import { spatialManifest } from "@hypit/spatial";
-import { svsManifest } from "@hypit/svs";
+import { recipeManifest } from "@hypit/recipe";
import { temporalManifest } from "@hypit/temporal";
import { MarkupSurfaceRegistry, createMarkupAuthorFrontend } from "@hypit/markup";
-import { createRecordAdmitter, TypeValidatorRegistry } from "@hypit/validation";
-import { visualIrManifest } from "@hypit/visual-ir";
+import { createRecordAdmitter, TypeValidatorRegistry } from "@hypit/admission";
+import { resolveSelfDescribedTextSource } from "@hypit/source/text";
const space = sealTimeline({ id: "test-space", frameCount: 300, frameRate: { numerator: 30, denominator: 1 },
});
@@ -324,17 +324,15 @@ test("the self-described Audio Surface parses into the same finite Producer grap
producers: [],
};
const closure = createResolvedClosure([
- artifactManifest,
+ blobManifest,
mediaManifest,
narrativeManifest,
timelineManifest,
- speechManifest,
narrativeTemporalManifest,
- svsManifest,
+ recipeManifest,
spatialManifest,
speechEvidenceManifest,
temporalManifest,
- visualIrManifest,
compositionManifest,
audioTrackManifest,
fixtureManifest,
@@ -361,7 +359,7 @@ test("the self-described Audio Surface parses into the same finite Producer grap
const validators = new TypeValidatorRegistry();
registerTypeValidatorFacets(validators, mediaComponent.validators ?? []);
const compiled = await compileSourceClosure({
- entry: {
+ entry: resolveSelfDescribedTextSource({
id: "/project/audio.svml",
name: "audio.svml",
text: `<?svml using="@hypit/markup@1"?>
@@ -375,7 +373,7 @@ test("the self-described Audio Surface parses into the same finite Producer grap
</audio:Clip>
</audio:Track>
</svml>`,
- },
+ }),
closure,
frontends,
admitRecord: createRecordAdmitter(validators),
diff --git a/packages/caption-fine-studio/README.md b/packages/caption-fine-studio/README.md
deleted file mode 100644
index 69920ce7..00000000
--- a/packages/caption-fine-studio/README.md
+++ /dev/null
@@ -1,25 +0,0 @@
-# Caption Fine Studio Companion
-
-One Caption Track contains Cue blocks and a bottom Uses band declared through the public ABI.
-Each Cue has a numbered title such as `#15` and complete subtitle text in its body.
-Cue ids remain the underlying identities; the number is a display label. Cues retain their measured
-times, including content currently hidden by a Use. Their read-only Range describes the content, independently of its visual treatment.
-
-The Uses band shows each authored Window once, with its Style name. A whole-Timeline Use remains one
-block across Segment changes and gaps. Hidden and overridden Uses stay selectable. The Companion
-reads the Track's `content`, `schedule` and `program` exports; it never reconstructs author windows
-from the rendered words.
-
-Use entities retain the actual child Source range and standard Temporal lineage. Timeline gestures
-therefore use the same writeback rules as Visual and Audio Clips. Selecting a Use exposes its
-referenced Style's font and Recipe fields. Shared Styles remain shared; changing a time window
-changes presentation without editing Script Cue breaks.
-
-Studio owns Track bands, block chrome, overlap selection and generic Inspector controls. This Companion owns
-Caption facts, field grouping and Source bindings. Content, Uses and their renderer stay independent
-of central Studio domain logic.
-
-Fine Style parameters are a separate `parameters` Companion matched to the Fine Style Surface.
-The Use band opts its `style` reference into the selected object's Companion. Custom Styles can
-provide their own field table through their project package. Supported omitted defaults appear
-in the Inspector and are inserted into the owning Recipe only when edited.
diff --git a/packages/caption-fine-studio/package.json b/packages/caption-fine-studio/package.json
deleted file mode 100644
index 5e607c90..00000000
--- a/packages/caption-fine-studio/package.json
+++ /dev/null
@@ -1,22 +0,0 @@
-{
- "name": "@hypit/caption-fine-studio",
- "version": "0.0.0-dev",
- "license": "SEE LICENSE IN LICENSE",
- "private": true,
- "type": "module",
- "exports": {
- ".": "./src/index.ts"
- },
- "hypit": {
- "activation": "./src/activation.ts"
- },
- "dependencies": {
- "@hypit/caption-fine": "workspace:*",
- "@hypit/composition": "workspace:*",
- "@hypit/caption": "workspace:*",
- "@hypit/studio-adapter": "workspace:*",
- "@hypit/fonts-open": "workspace:*",
- "@hypit/caption": "workspace:*",
- "@hypit/temporal": "workspace:*"
- }
-}
diff --git a/packages/caption-fine-studio/src/activation.ts b/packages/caption-fine-studio/src/activation.ts
deleted file mode 100644
index bda72776..00000000
--- a/packages/caption-fine-studio/src/activation.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-import { createStudioCompanionHostFacet } from "@hypit/studio-adapter";
-import { captionFineStudioTrackCompanions, captionFineStudioParameterCompanions } from "./index.js";
-
-export default {
- format: "hypit.node-package@1" as const,
- hostFacets: [createStudioCompanionHostFacet({ tracks: captionFineStudioTrackCompanions, parameters: captionFineStudioParameterCompanions })],
-};
diff --git a/packages/caption-fine/README.md b/packages/caption-fine/README.md
index c8e08473..c2c2da96 100644
--- a/packages/caption-fine/README.md
+++ b/packages/caption-fine/README.md
@@ -14,14 +14,14 @@ does not carry a private visual role.
</caption-fine:Caption>
```
-An optional Region Track supplies a moving placement point when the user's reference
+An optional Region Evidence supplies a moving placement point when the user's reference
visibly uses head-following Caption or the user asks for that treatment. Ordinary Caption uses the
-Style's placement without regions. Region Track is authored numeric input mapped from available picture
+Style's placement without regions. Region Evidence is authored numeric input mapped from available picture
evidence to the composition that consumes it; it is not a face-tracking request:
```xml
-<import as="region" from="@hypit/region-track@1"/>
-<region:Track id="heads" within={vertical.bounds} timeline={speech.timeline}
+<import as="region" from="@hypit/region-evidence@1"/>
+<region:Evidence id="heads" within={vertical.bounds} timeline={speech.timeline}
recipe={tracking.heads.default}/>
<caption-fine:Caption id="captions-track" document={story.caption} timing={story-captions}
timeline={speech.timeline} within={vertical.bounds} regions={heads}>
@@ -29,10 +29,10 @@ evidence to the composition that consumes it; it is not a face-tracking request:
</caption-fine:Caption>
```
-With `regions`, every Cue must carry one Script Role. When Region Track contains a measured region for that
+With `regions`, every Cue must carry one Script Role. When Region Evidence contains a measured region for that
Role and Frame, Fine places the Cue at the region's top center. When that Role has a series but
the current Frame is `null`, the Cue is not rendered: absence of evidence never becomes a guessed
-position. A Role with no Track uses the Style's authored `x` and `y`, so unrelated speakers remain
+position. A Role with no evidence series uses the Style's authored `x` and `y`, so unrelated speakers remain
ordinary fixed captions. The Style still owns its width and anchors, so `anchor-x: center;
anchor-y: bottom` puts the Caption immediately above a measured region. The Timeline is finished
external evidence: Fine does not detect people, associate identities, smooth motion, interpolate
@@ -40,7 +40,7 @@ missing Frames or invoke a Provider. Without `regions`, the ordinary Recipe `x`
unchanged.
This keeps placement inspectable and editable. If a tracked face needs padding or an above-head anchor,
-transform the measured numbers while authoring Region Track, then give Caption the result. Do
+transform the measured numbers while authoring Region Evidence, then give Caption the result. Do
not hide that transformation in a Provider or ask the Build to rediscover the face.
One SVS Recipe freezes three public dimensions:
@@ -105,7 +105,7 @@ lines are included. Padding and borders extend beyond those rectangles without c
overlapping line backgrounds share one outline and paint translucent color once. Cue motion then
moves text and decoration together.
-This decoration uses HyperFrames' existing local browser-program extension, owned by Fine. Its
+This decoration uses the HtmlProgram's local `HtmlVisual` extension, owned by Fine. Its
measurement copy uses the same exact-font text and available width, is removed synchronously after
measurement, and is recomputed when a frame is sought (including after fonts finish loading). It
adds no layout records to Script, Caption, Timeline or Runtime. Other backends must support the
@@ -145,7 +145,10 @@ The Hypit Skill's Caption craft page owns grouping and visual direction.
`font` accepts an exact face or ordered stack. A local file declared through `media:Font` can be the
primary face or a `<caption-fine:Fallback font={...}/>` child, just like a bundled face. See
-[Media font assets](../media/README.md#font-files) and [the open catalog](../fonts-open/README.md).
+[Media font assets](../media/README.md#font-files) and the independently installed
+[`@hypit/fontsource` adapter](../fontsource/README.md).
-The [Fine Studio Companion](../caption-fine-studio/src/index.ts) reads the same schedule and authored Use
-Style references. It presents the actual Cue timing and exposes Use timing and supported Style edits in the Inspector.
+The package's Studio facet, published as `@hypit/caption-fine/studio`, reads the same schedule and
+authored Use Style references. It presents the actual Cue timing and exposes Use timing and supported
+Style edits in the Inspector. Runtime and authoring support therefore ship as one versioned capability
+rather than as independently versioned packages.
diff --git a/packages/caption-fine/package.json b/packages/caption-fine/package.json
index 7b0d86c3..bdacecdd 100644
--- a/packages/caption-fine/package.json
+++ b/packages/caption-fine/package.json
@@ -1,32 +1,43 @@
{
"name": "@hypit/caption-fine",
- "version": "0.0.0-dev",
+ "version": "0.1.0",
"license": "SEE LICENSE IN LICENSE",
"private": true,
"type": "module",
"exports": {
- ".": "./src/index.ts"
+ ".": "./src/index.ts",
+ "./studio": "./src/studio.ts"
},
+ "files": [
+ "dist",
+ "preview",
+ "README.md"
+ ],
"hypit": {
"activation": "./src/activation.ts"
},
- "dependencies": {
+ "peerDependencies": {
+ "@hypit/hypit": "workspace:^",
+ "@hypit/studio-companion": "workspace:^"
+ },
+ "devDependencies": {
"@hypit/caption": "workspace:*",
- "@hypit/component-kit": "workspace:*",
+ "@hypit/hypit": "workspace:*",
+ "@hypit/studio-companion": "workspace:*",
+ "@hypit/producer": "workspace:*",
"@hypit/composition": "workspace:*",
- "@hypit/elaborator": "workspace:*",
- "@hypit/hyperframes": "workspace:*",
+ "@hypit/author": "workspace:*",
+ "@hypit/html-program": "workspace:*",
"@hypit/media": "workspace:*",
"@hypit/protocol": "workspace:*",
- "@hypit/region-track": "workspace:*",
+ "@hypit/region-evidence": "workspace:*",
"@hypit/timeline": "workspace:*",
"@hypit/spatial": "workspace:*",
- "@hypit/svs": "workspace:*",
+ "@hypit/recipe": "workspace:*",
"@hypit/markup": "workspace:*",
"@hypit/temporal": "workspace:*",
- "@hypit/temporal-markup": "workspace:*"
- },
- "devDependencies": {
- "@hypit/script": "workspace:*"
+ "@hypit/script": "workspace:*",
+ "@hypit/browser-capture": "workspace:*",
+ "sharp": "0.35.4"
}
}
diff --git a/packages/caption-fine/src/activation.ts b/packages/caption-fine/src/activation.ts
index 9341d6a4..b3dc1c50 100644
--- a/packages/caption-fine/src/activation.ts
+++ b/packages/caption-fine/src/activation.ts
@@ -1,4 +1,7 @@
-import { createMarkupSurfaceHostFacet } from "@hypit/markup";
+import { createAdmissionPackageFacet } from "@hypit/hypit/admission";
+import { createProducerPackageFacet } from "@hypit/hypit/producer";
+import { createMarkupSurfaceFacet } from "@hypit/hypit/markup";
+import { createStudioCompanionFacet } from "@hypit/studio-companion";
import {
captionFineComponent,
@@ -8,24 +11,29 @@ import {
decodeFineCaptionTrackSurface,
captionFineMarkupSurfaces,
} from "./index.js";
+import { captionFineStudioParameterCompanions, captionFineStudioTrackCompanions } from "./studio.js";
export const hypitPackage = {
- format: "hypit.node-package@1" as const,
+ format: "hypit.package@1" as const,
modules: [{
manifest: captionFineManifest,
}],
- components: [captionFineComponent],
- hostFacets: [
- createMarkupSurfaceHostFacet({
+ facets: [
+ ...[captionFineComponent].flatMap((component) => [createProducerPackageFacet(component), createAdmissionPackageFacet(component)]),
+ createMarkupSurfaceFacet({
module: captionFineModuleRef,
- declaration: captionFineMarkupSurfaces.find((item) => item.name === "style")!,
+ declaration: captionFineMarkupSurfaces.find((item) => item.name === "style")!,
handler: decodeFineCaptionStyleSurface,
}),
- createMarkupSurfaceHostFacet({
+ createMarkupSurfaceFacet({
module: captionFineModuleRef,
- declaration: captionFineMarkupSurfaces.find((item) => item.name === "caption")!,
+ declaration: captionFineMarkupSurfaces.find((item) => item.name === "caption")!,
handler: decodeFineCaptionTrackSurface,
}),
+ createStudioCompanionFacet({
+ tracks: captionFineStudioTrackCompanions,
+ parameters: captionFineStudioParameterCompanions,
+ }),
],
};
diff --git a/packages/caption-fine/src/component.ts b/packages/caption-fine/src/component.ts
index c3d77459..305a25f5 100644
--- a/packages/caption-fine/src/component.ts
+++ b/packages/caption-fine/src/component.ts
@@ -1,10 +1,11 @@
-import type { Timeline } from "@hypit/timeline";
-import type { CaptionDocument, CaptionProgram, CaptionTiming } from "@hypit/caption";
-import type { ComponentPackage } from "@hypit/component-kit";
-import type { StoredValue } from "@hypit/protocol";
-import { canonicalize } from "@hypit/protocol";
-import type { RegionTrack } from "@hypit/region-track";
-import type { SpatialFrame } from "@hypit/spatial";
+import type { Timeline } from "@hypit/hypit/timeline";
+import type { CaptionDocument, CaptionProgram, CaptionTiming } from "@hypit/hypit/caption";
+import type { ProducerPackage } from "@hypit/hypit/producer";
+import type { AdmissionPackage } from "@hypit/hypit/admission";
+import type { StoredValue } from "@hypit/hypit/protocol";
+import { canonicalize } from "@hypit/hypit/protocol";
+import type { RegionEvidence } from "@hypit/hypit/region-evidence";
+import type { SpatialFrame } from "@hypit/hypit/spatial";
import { captionFineProducers } from "./manifest.js";
import { renderFineCaption } from "./render.js";
@@ -51,10 +52,10 @@ export const captionFineComponent = {
inline<CaptionDocument>(inputs.document?.value, "CaptionDocument"),
inline<Timeline>(inputs.timeline?.value, "Timeline"),
inline<SpatialFrame>(inputs.within?.value, "SpatialFrame"),
- inline<RegionTrack>(inputs.regions?.value, "RegionTrack"),
+ inline<RegionEvidence>(inputs.regions?.value, "RegionEvidence"),
)) } },
needs: {},
}),
},
],
-} satisfies ComponentPackage;
+} satisfies ProducerPackage & AdmissionPackage;
diff --git a/packages/caption-fine/src/fragment.ts b/packages/caption-fine/src/fragment.ts
index db8c7b05..2ddc805c 100644
--- a/packages/caption-fine/src/fragment.ts
+++ b/packages/caption-fine/src/fragment.ts
@@ -1,9 +1,9 @@
-import { captionTypes } from "@hypit/caption";
-import { compositionTypes } from "@hypit/composition";
-import { sealGraphFragment } from "@hypit/elaborator";
-import { timelineTypes } from "@hypit/timeline";
-import { regionTrackTypes } from "@hypit/region-track";
-import { spatialTypes } from "@hypit/spatial";
+import { captionTypes } from "@hypit/hypit/caption";
+import { compositionTypes } from "@hypit/hypit/composition";
+import { sealGraphFragment } from "@hypit/hypit/author";
+import { timelineTypes } from "@hypit/hypit/timeline";
+import { regionEvidenceTypes } from "@hypit/hypit/region-evidence";
+import { spatialTypes } from "@hypit/hypit/spatial";
import { captionFineProducers, captionFineTypes } from "./manifest.js";
@@ -53,14 +53,14 @@ export const fineCaptionTrackFragment = sealGraphFragment({
});
/** The same Caption pipeline with one explicit, external spatial-evidence edge. */
-export const fineCaptionRegionTrackFragment = sealGraphFragment({
+export const fineCaptionRegionEvidenceFragment = sealGraphFragment({
inputs: [
{ name: "document", type: captionTypes.document },
{ name: "timeline", type: timelineTypes.timeline },
{ name: "within", type: spatialTypes.frame },
{ name: "timing", type: captionTypes.timing },
{ name: "program", type: captionTypes.program },
- { name: "regions", type: regionTrackTypes.track },
+ { name: "regions", type: regionEvidenceTypes.evidence },
],
operations: [
{
diff --git a/packages/caption-fine/src/index.ts b/packages/caption-fine/src/index.ts
index 4f510ed6..6cbf7f7d 100644
--- a/packages/caption-fine/src/index.ts
+++ b/packages/caption-fine/src/index.ts
@@ -1,5 +1,5 @@
export { captionFineComponent } from "./component.js";
-export { fineCaptionRegionTrackFragment, fineCaptionTrackFragment } from "./fragment.js";
+export { fineCaptionRegionEvidenceFragment, fineCaptionTrackFragment } from "./fragment.js";
export { captionFineManifest, captionFineMarkupSurfaces, captionFineModuleRef, captionFineProducers, captionFineTypes } from "./manifest.js";
export { renderFineCaption } from "./render.js";
export { assertFineCaptionSchedule, scheduleFineCaption } from "./schedule.js";
diff --git a/packages/caption-fine/src/manifest.ts b/packages/caption-fine/src/manifest.ts
index 11a96b7c..4bc78908 100644
--- a/packages/caption-fine/src/manifest.ts
+++ b/packages/caption-fine/src/manifest.ts
@@ -1,17 +1,17 @@
-import { temporalDependency, temporalTypes } from "@hypit/temporal";
-import { temporalContextAttributeVocabulary, temporalWindowAttributeVocabulary } from "@hypit/temporal-markup";
-import { timelineDependency, timelineTypes } from "@hypit/timeline";
-import type { Timeline } from "@hypit/timeline";
+import { temporalDependency, temporalTypes } from "@hypit/hypit/temporal";
+import { temporalContextAttributeVocabulary, temporalWindowAttributeVocabulary } from "@hypit/hypit/temporal/markup";
+import { timelineDependency, timelineTypes } from "@hypit/hypit/timeline";
+import type { Timeline } from "@hypit/hypit/timeline";
import { readFile } from "node:fs/promises";
-import { captionModuleRef, captionTypes } from "@hypit/caption";
-import { compositionDependency, compositionTypes } from "@hypit/composition";
-import { mediaDependency, mediaTypes } from "@hypit/media";
+import { captionModuleRef, captionTypes } from "@hypit/hypit/caption";
+import { compositionDependency, compositionTypes } from "@hypit/hypit/composition";
+import { mediaDependency, mediaTypes } from "@hypit/hypit/media";
-import type { ModuleManifest, ProducerRef } from "@hypit/protocol";
-import { regionTrackDependency, regionTrackTypes } from "@hypit/region-track";
-import { spatialDependency, spatialTypes } from "@hypit/spatial";
-import { svsRecipeType } from "@hypit/svs";
+import type { ModuleManifest, ProducerRef } from "@hypit/hypit/protocol";
+import { regionEvidenceDependency, regionEvidenceTypes } from "@hypit/hypit/region-evidence";
+import { spatialDependency, spatialTypes } from "@hypit/hypit/spatial";
+import { recipeType } from "@hypit/hypit/recipe";
import { fineCaptionOneShotMotions } from "./recipe.js";
@@ -39,7 +39,7 @@ export const captionFineMarkupSurfaces = [
attributes: [
{ name: "id", kind: "identifier", required: true,
summary: "Names this Style so a timed Use can select it." },
- { name: "recipe", kind: "reference", required: true, accepts: [svsRecipeType],
+ { name: "recipe", kind: "reference", required: true, accepts: [recipeType],
summary: "Chooses the Recipe that carries Cue geometry, Paint and local motion.",
recipe: [
{ name: "stack-order", required: true,
@@ -286,7 +286,7 @@ export const captionFineMarkupSurfaces = [
summary: "Chooses the single face this fallback contributes." },
] },
],
- example: `<fonts:Stack id="caption-font" family="inter" weight="800" style="normal"/>
+ example: `<fontsource:Face id="caption-font" package="@fontsource-variable/inter" weight="800" style="normal"/>
<caption-fine:Style id="primary-caption" recipe={recipes.caption.primary} font={caption-font}/>`,
notes: [
"Referencing a font stack in `font` and writing `<Fallback>` children are both allowed; the stack's faces come first.",
@@ -313,7 +313,7 @@ export const captionFineMarkupSurfaces = [
...temporalContextAttributeVocabulary,
{ name: "within", kind: "reference", required: true, accepts: [spatialTypes.frame],
summary: "Chooses the resolved picture-plane Frame used by Recipe x, y, width and height." },
- { name: "regions", kind: "reference", required: false, accepts: [regionTrackTypes.track],
+ { name: "regions", kind: "reference", required: false, accepts: [regionEvidenceTypes.evidence],
summary: "Optionally follows external, frame-exact regions whose ids equal Script Roles, placing a Cue at its measured speaker region's top center and hiding it on null Frames." },
],
children: [{ tag: "Use", cardinality: "many", summary: "Presents complete Cues inside a time window. Later matching Uses replace earlier ones.", attributes: [
@@ -335,7 +335,7 @@ export const captionFineMarkupSurfaces = [
notes: [
"Use without time attributes covers the whole Timeline. Role filters content without changing the window.",
"Script Cue breaks organize text; Use windows change presentation without cutting Cues or restarting word timing. A hidden Use still replaces earlier presentation.",
- "Without regions, Recipe x/y placement is unchanged. With regions, a measured region overrides x/y for that Frame; a null Frame on that Role track hides the Cue, while a missing Role track retains authored x/y.",
+ "Without regions, Recipe x/y placement is unchanged. With regions, a measured region overrides x/y for that Frame; a null Frame in that Role series hides the Cue, while a missing Role series retains authored x/y.",
"The tracked point replaces Recipe x/y while width and the Recipe anchor still decide the Caption box geometry; anchor-x=center and anchor-y=bottom place the box immediately above the measured region.",
],
},
@@ -353,7 +353,7 @@ export const captionFineManifest: ModuleManifest = {
mediaDependency,
spatialDependency,
timelineDependency,
- regionTrackDependency, temporalDependency,
+ regionEvidenceDependency, temporalDependency,
],
types: [{ name: captionFineTypes.schedule.name }],
capabilities: [],
@@ -388,7 +388,7 @@ export const captionFineManifest: ModuleManifest = {
{ name: "document", type: captionTypes.document },
{ name: "timeline", type: timelineTypes.timeline },
{ name: "within", type: spatialTypes.frame },
- { name: "regions", type: regionTrackTypes.track },
+ { name: "regions", type: regionEvidenceTypes.evidence },
],
outputs: [{ name: "track", type: compositionTypes.visualTrack }],
needs: [],
diff --git a/packages/caption-fine/src/recipe.ts b/packages/caption-fine/src/recipe.ts
index cd6d88c5..1a3afbb1 100644
--- a/packages/caption-fine/src/recipe.ts
+++ b/packages/caption-fine/src/recipe.ts
@@ -1,4 +1,4 @@
-import type { ValueSchema } from "@hypit/protocol";
+import type { ValueSchema } from "@hypit/hypit/protocol";
export const fineCaptionOneShotMotions = [
"none", "fade", "pop", "scale", "spring", "bounce", "elastic", "stamp", "tilt", "zoom-blur",
diff --git a/packages/caption-fine/src/render.ts b/packages/caption-fine/src/render.ts
index 17544cff..0abd7c2e 100644
--- a/packages/caption-fine/src/render.ts
+++ b/packages/caption-fine/src/render.ts
@@ -1,8 +1,8 @@
-import { assertTimelineIdentity, timelineFrameCount } from "@hypit/timeline";
-import type { Timeline } from "@hypit/timeline";
-import { assertCaptionProgramForDocument } from "@hypit/caption";
-import type { CaptionProgram } from "@hypit/caption";
-import { assertVisualTrackIdentity, sealVisualTrack } from "@hypit/composition";
+import { assertTimelineIdentity, timelineFrameCount } from "@hypit/hypit/timeline";
+import type { Timeline } from "@hypit/hypit/timeline";
+import { assertCaptionProgramForDocument } from "@hypit/hypit/caption";
+import type { CaptionProgram } from "@hypit/hypit/caption";
+import { assertVisualTrackIdentity, sealVisualTrack } from "@hypit/hypit/composition";
import type {
VisualAnimation,
VisualBoxElement,
@@ -14,17 +14,17 @@ import type {
VisualTextElement,
VisualTextPaintLayer,
VisualTrack,
-} from "@hypit/composition";
-import type { CaptionDocument, CaptionDisplayWord, CaptionUnit } from "@hypit/caption";
-import { assertRegionTrack } from "@hypit/region-track";
-import type { RegionTrack } from "@hypit/region-track";
-import { assertSpatialFrame } from "@hypit/spatial";
-import type { SpatialFrame } from "@hypit/spatial";
+} from "@hypit/hypit/composition";
+import type { CaptionDocument, CaptionDisplayWord, CaptionUnit } from "@hypit/hypit/caption";
+import { assertRegionEvidence } from "@hypit/hypit/region-evidence";
+import type { RegionEvidence } from "@hypit/hypit/region-evidence";
+import { assertSpatialFrame } from "@hypit/hypit/spatial";
+import type { SpatialFrame } from "@hypit/hypit/spatial";
import { assertFineCaptionParameters, FINE_CAPTION_FAMILY } from "./style.js";
import { assertFineCaptionSchedule } from "./schedule.js";
import { uniformGap, wordGaps } from "./spacing.js";
-import { browserProgram } from "@hypit/hyperframes";
+import { htmlVisual } from "@hypit/hypit/html-program";
import { joinedBoxSetup } from "./joined-box.js";
import type {
FineCaptionActiveUnderline,
@@ -806,7 +806,7 @@ function cueElements(
});
if (parameters.activeBox.mode === "trail" && parameters.activeBox.continuity === "joined") {
- // Fine owns this drawing program. The renderer only executes its existing browser-program
+ // Fine owns this drawing program. The renderer only executes its existing HtmlVisual
// format; it learns nothing about captions, activation units or their layout rules.
push({
id: "joined-boxes", parent: "cue", kind: "program",
@@ -814,7 +814,7 @@ function cueElements(
{ name: "position", value: "absolute" }, { name: "inset", value: "0" },
{ name: "padding", value: `${compactNumber(parameters.cueBox.paddingYPx)}px ${compactNumber(parameters.cueBox.paddingXPx)}px` },
],
- program: browserProgram({
+ program: htmlVisual({
html: "{{joined-layout}}" + atoms.map((_, index) => `{{joined-box-${index + 1}}}`).join(""),
setup: joinedBoxSetup,
css: ":scope { pointer-events: none; }",
@@ -1083,7 +1083,7 @@ export function renderFineCaption(
document: CaptionDocument,
timeline: Timeline,
within: SpatialFrame,
- regions?: RegionTrack,
+ regions?: RegionEvidence,
): VisualTrack {
assertFineCaptionSchedule(schedule);
assertCaptionProgramForDocument(program, document);
@@ -1105,8 +1105,8 @@ export function renderFineCaption(
assertFineCaptionParameters(style.rendering.parameters as unknown as FineCaptionParameters);
}
const totalFrames = timelineFrameCount(timeline);
- const regionTracks = regions === undefined ? undefined : (() => {
- assertRegionTrack(regions);
+ const regionSeriesById = regions === undefined ? undefined : (() => {
+ assertRegionEvidence(regions);
const regionFrameCount = regions.series[0]!.frames.length;
if (regions.timelineId !== timeline.id || regionFrameCount !== totalFrames) {
throw new Error(`Fine Caption regions do not cover Timeline ${timeline.id}'s ${totalFrames} Frames`);
@@ -1126,15 +1126,15 @@ export function renderFineCaption(
const endFrameExclusive = Math.min(totalFrames, Math.max(startFrame + 1, measuredEnd));
if (startFrame >= totalFrames || endFrameExclusive <= startFrame) return [];
const durationFrames = endFrameExclusive - startFrame;
- const trackedPlacement = regionTracks === undefined ? undefined : (() => {
+ const trackedPlacement = regionSeriesById === undefined ? undefined : (() => {
const role = resolvedAtoms[0]?.role;
if (role === undefined || resolvedAtoms.some((atom) => atom.role !== role)) {
throw new Error(`Fine Caption Cue ${cue.id} must contain exactly one Script Role to follow regions`);
}
- const track = regionTracks.get(role);
- if (track === undefined) return undefined;
+ const series = regionSeriesById.get(role);
+ if (series === undefined) return undefined;
return {
- frames: track.frames.slice(startFrame, endFrameExclusive),
+ frames: series.frames.slice(startFrame, endFrameExclusive),
};
})();
const atomFrames = new Map(cue.units.map((atom) => [atom.unitId, {
diff --git a/packages/caption-fine/src/schedule.ts b/packages/caption-fine/src/schedule.ts
index 556dbf19..833f85d8 100644
--- a/packages/caption-fine/src/schedule.ts
+++ b/packages/caption-fine/src/schedule.ts
@@ -1,6 +1,6 @@
-import { assertCaptionProgramForDocument, assertCaptionTiming, captionUseVisibility } from "@hypit/caption";
-import type { CaptionProgram, CaptionTiming } from "@hypit/caption";
-import type { CaptionDocument } from "@hypit/caption";
+import { assertCaptionProgramForDocument, assertCaptionTiming, captionUseVisibility } from "@hypit/hypit/caption";
+import type { CaptionProgram, CaptionTiming } from "@hypit/hypit/caption";
+import type { CaptionDocument } from "@hypit/hypit/caption";
import { assertFineCaptionParameters, FINE_CAPTION_FAMILY } from "./style.js";
import type { FineCaptionParameters, FineCaptionSchedule, FineCaptionScheduledCue } from "./types.js";
diff --git a/packages/caption-fine/src/spacing.ts b/packages/caption-fine/src/spacing.ts
index eefa2335..10dc5039 100644
--- a/packages/caption-fine/src/spacing.ts
+++ b/packages/caption-fine/src/spacing.ts
@@ -1,4 +1,4 @@
-import type { CaptionDisplayWord } from "@hypit/caption";
+import type { CaptionDisplayWord } from "@hypit/hypit/caption";
type Surface = Pick<CaptionDisplayWord, "text" | "separatorBefore">;
diff --git a/packages/caption-fine-studio/src/index.ts b/packages/caption-fine/src/studio.ts
similarity index 91%
rename from packages/caption-fine-studio/src/index.ts
rename to packages/caption-fine/src/studio.ts
index 5417030e..1314277b 100644
--- a/packages/caption-fine-studio/src/index.ts
+++ b/packages/caption-fine/src/studio.ts
@@ -1,23 +1,20 @@
-import { temporalTypes } from "@hypit/temporal";
-import type { CaptionProgram, CaptionTiming } from "@hypit/caption";
-import { openFontStudioFields } from "@hypit/fonts-open/studio";
-import { fineCaptionEditableDefaults, captionFineMarkupSurfaces, captionFineModuleRef } from "@hypit/caption-fine";
-import type { FineCaptionSchedule } from "@hypit/caption-fine";
-import { compositionTypes } from "@hypit/composition";
-import { captionTypes } from "@hypit/caption";
-import type { CaptionDocument } from "@hypit/caption";
+import { temporalTypes } from "@hypit/hypit/temporal";
+import type { CaptionDocument, CaptionProgram, CaptionTiming } from "@hypit/hypit/caption";
+import { captionTypes } from "@hypit/hypit/caption";
+import { compositionTypes } from "@hypit/hypit/composition";
+import { fineCaptionEditableDefaults } from "./recipe.js";
+import { captionFineMarkupSurfaces, captionFineModuleRef } from "./manifest.js";
+import type { FineCaptionSchedule } from "./types.js";
import type {
StudioTrackCompanion,
StudioTrackCompanionContext,
StudioEntityDraft,
StudioInspectorFieldDeclaration,
-} from "@hypit/studio-adapter";
-import { authoredChildFor, temporalLineageFor, temporalDomainSource, requiredReferencedValue, requiredSurfaceValue } from "@hypit/studio-adapter";
+} from "@hypit/studio-companion";
+import { authoredChildFor, temporalLineageFor, temporalDomainSource, requiredReferencedValue, requiredSurfaceValue } from "@hypit/studio-companion";
const styleSurface = captionFineMarkupSurfaces.find((surface) => surface.name === "style");
-const fontInspector = openFontStudioFields("style");
-
const recipeVocabulary = styleSurface?.vocabulary.attributes
.find((attribute) => attribute.name === "recipe")?.recipe ?? [];
@@ -170,13 +167,12 @@ export const captionFineStudioTrackCompanions: readonly StudioTrackCompanion[] =
},
];
-export const captionFineStudioParameterCompanions: readonly import("@hypit/studio-adapter").StudioParameterCompanion[] = [{
+export const captionFineStudioParameterCompanions: readonly import("@hypit/studio-companion").StudioParameterCompanion[] = [{
id: "style", match: { module: captionFineModuleRef, surface: "style" },
- bindings: [fontInspector.binding, { name: "recipe", recipe: { bindings: recipeVocabulary.map(({ name }) => ({ name,
+ bindings: [{ name: "font", companion: true }, { name: "recipe", recipe: { bindings: recipeVocabulary.map(({ name }) => ({ name,
...(Object.hasOwn(fineCaptionEditableDefaults, name) ? { fallback: fineCaptionEditableDefaults[name as keyof typeof fineCaptionEditableDefaults] } : {}),
})) } }],
inspector: [
- ...fontInspector.fields.map(field => ({ ...field, binding: field.binding.replace(/^style\./u, "") })),
...captionFineInspectorFields.map(field => ({ ...field, binding: field.binding.replace(/^style\./u, "recipe.") })),
],
}];
diff --git a/packages/caption-fine/src/style.ts b/packages/caption-fine/src/style.ts
index 2adaa3e0..eef3eb86 100644
--- a/packages/caption-fine/src/style.ts
+++ b/packages/caption-fine/src/style.ts
@@ -1,9 +1,9 @@
-import type { CaptionStyleIntent } from "@hypit/caption";
-import { sealCaptionStyle } from "@hypit/caption";
-import { assertFontArtifactRef } from "@hypit/media";
-import type { FontArtifactRef } from "@hypit/media";
-import { canonicalStringify } from "@hypit/protocol";
-import type { SvsRecipe } from "@hypit/svs";
+import type { CaptionStyleIntent } from "@hypit/hypit/caption";
+import { sealCaptionStyle } from "@hypit/hypit/caption";
+import { assertFontArtifactRef } from "@hypit/hypit/media";
+import type { FontArtifactRef } from "@hypit/hypit/media";
+import { canonicalStringify } from "@hypit/hypit/protocol";
+import type { Recipe } from "@hypit/hypit/recipe";
import type { FineCaptionGlyphPaint, FineCaptionParameters } from "./types.js";
import {
@@ -20,12 +20,12 @@ const ALLOWED_PROPERTIES = new Set<string>([
...fineCaptionOptionalRecipeProperties,
]);
-function required(value: SvsRecipe, name: string): unknown {
+function required(value: Recipe, name: string): unknown {
if (!Object.hasOwn(value.properties, name)) throw new Error(`Fine Caption Recipe requires ${name}`);
return value.properties[name];
}
-function number(value: SvsRecipe, name: string, fallback?: number): number {
+function number(value: Recipe, name: string, fallback?: number): number {
const property = Object.hasOwn(value.properties, name) ? value.properties[name] : fallback;
if (typeof property !== "number" || !Number.isFinite(property)) {
throw new Error(`Fine Caption Recipe ${name} must be a number`);
@@ -33,13 +33,13 @@ function number(value: SvsRecipe, name: string, fallback?: number): number {
return property;
}
-function integer(value: SvsRecipe, name: string, fallback?: number): number {
+function integer(value: Recipe, name: string, fallback?: number): number {
const property = number(value, name, fallback);
if (!Number.isSafeInteger(property)) throw new Error(`Fine Caption Recipe ${name} must be an integer`);
return property;
}
-function string(value: SvsRecipe, name: string, fallback?: string): string {
+function string(value: Recipe, name: string, fallback?: string): string {
const property = Object.hasOwn(value.properties, name) ? value.properties[name] : fallback;
if (typeof property !== "string" || !property.trim()) {
throw new Error(`Fine Caption Recipe ${name} must be a string`);
@@ -48,7 +48,7 @@ function string(value: SvsRecipe, name: string, fallback?: string): string {
}
function choice<const T extends readonly string[]>(
- value: SvsRecipe,
+ value: Recipe,
name: string,
choices: T,
fallback?: T[number],
@@ -58,7 +58,7 @@ function choice<const T extends readonly string[]>(
return property as T[number];
}
-function color(value: SvsRecipe, name: string, fallback?: string): string {
+function color(value: Recipe, name: string, fallback?: string): string {
const property = string(value, name, fallback);
if (!/^#[0-9a-f]{6}(?:[0-9a-f]{2})?$/iu.test(property)) {
throw new Error(`Fine Caption Recipe ${name} must be an RGB or RGBA hex color`);
@@ -75,7 +75,7 @@ function padding(value: string): { readonly x: number; readonly y: number } {
}
function optionalGradient(
- recipe: SvsRecipe,
+ recipe: Recipe,
prefix: "" | "active-",
base?: FineCaptionGlyphPaint["gradient"],
): FineCaptionGlyphPaint["gradient"] | undefined {
@@ -95,7 +95,7 @@ function optionalGradient(
};
}
-function glyphPaint(recipe: SvsRecipe, prefix: "" | "active-", base?: FineCaptionGlyphPaint): FineCaptionGlyphPaint {
+function glyphPaint(recipe: Recipe, prefix: "" | "active-", base?: FineCaptionGlyphPaint): FineCaptionGlyphPaint {
const fallback = <K extends keyof FineCaptionGlyphPaint>(key: K): FineCaptionGlyphPaint[K] | undefined => base?.[key];
const baseShadow = fallback("shadow") as FineCaptionGlyphPaint["shadow"] | undefined;
const baseGlow = fallback("glow") as FineCaptionGlyphPaint["glow"] | undefined;
@@ -171,7 +171,7 @@ function assertPaint(value: FineCaptionGlyphPaint, label: string): void {
}
export function fineCaptionParameters(
- recipe: SvsRecipe,
+ recipe: Recipe,
exactFonts: readonly FontArtifactRef[],
): FineCaptionParameters {
for (const name of fineCaptionRequiredRecipeProperties) required(recipe, name);
@@ -358,7 +358,7 @@ export function assertFineCaptionParameters(value: FineCaptionParameters): void
export function fineCaptionStyle(
id: string,
- recipe: SvsRecipe,
+ recipe: Recipe,
exactFonts: readonly FontArtifactRef[],
): CaptionStyleIntent {
return sealCaptionStyle({
diff --git a/packages/caption-fine/src/surface.ts b/packages/caption-fine/src/surface.ts
index 550c55d6..2d297f05 100644
--- a/packages/caption-fine/src/surface.ts
+++ b/packages/caption-fine/src/surface.ts
@@ -1,25 +1,20 @@
-import { captionProducers, captionTypes } from "@hypit/caption";
-import { assertFontArtifactRef, assertFontStackRef, mediaTypes } from "@hypit/media";
-import type { FontArtifactRef, FontStackRef } from "@hypit/media";
-import { timelineTypes } from "@hypit/timeline";
-import { regionTrackTypes } from "@hypit/region-track";
-import { spatialTypes } from "@hypit/spatial";
-import { svsRecipeType } from "@hypit/svs";
-import type { SvsRecipe } from "@hypit/svs";
-import type {
- StructuredElement,
- StructuredSurfaceHandler,
- SurfaceResolvedReference,
- MarkupAttributeValue,
-} from "@hypit/markup";
+import { captionProducers, captionTypes } from "@hypit/hypit/caption";
+import { assertFontArtifactRef, assertFontStackRef, mediaTypes } from "@hypit/hypit/media";
+import type { FontArtifactRef, FontStackRef } from "@hypit/hypit/media";
+import { timelineTypes } from "@hypit/hypit/timeline";
+import { regionEvidenceTypes } from "@hypit/hypit/region-evidence";
+import { spatialTypes } from "@hypit/hypit/spatial";
+import { recipeType } from "@hypit/hypit/recipe";
+import type { Recipe } from "@hypit/hypit/recipe";
+import type { StructuredElement, StructuredSurfaceHandler, SurfaceResolvedReference, MarkupAttributeValue } from "@hypit/hypit/markup";
-import { sealGraphFragment } from "@hypit/elaborator";
-import type { FragmentOperation } from "@hypit/elaborator";
-import type { SurfaceRecordDraft, SurfaceComponentDraft } from "@hypit/markup";
-import { assertEmptyElement, optionalTextAttribute } from "@hypit/markup";
-import { createTemporalWindowConstruction, resolveTemporalContext, temporalWindowAttributeNames } from "@hypit/temporal-markup";
-import { temporalTypes } from "@hypit/temporal";
-import { compositionTypes } from "@hypit/composition";
+import { sealGraphFragment } from "@hypit/hypit/author";
+import type { FragmentOperation } from "@hypit/hypit/author";
+import type { SurfaceRecordDraft, SurfaceComponentDraft } from "@hypit/hypit/markup";
+import { assertEmptyElement, optionalTextAttribute } from "@hypit/hypit/markup";
+import { createTemporalWindowConstruction, resolveTemporalContext, temporalWindowAttributeNames } from "@hypit/hypit/temporal/markup";
+import { temporalTypes } from "@hypit/hypit/temporal";
+import { compositionTypes } from "@hypit/hypit/composition";
import { captionFineProducers, captionFineTypes } from "./manifest.js";
const input = (name: string) => ({ kind: "fragment-input" as const, name });
const operation = (id: string) => ({ kind: "fragment-operation" as const, operation: id });
@@ -113,7 +108,7 @@ function exactFonts(
export const decodeFineCaptionStyleSurface: StructuredSurfaceHandler = ({ element, resolveReference }) => {
attributes(element, ["id", "recipe", "font"]);
const id = stringAttribute(element, "id");
- const recipe = inline<SvsRecipe>(reference(element, "recipe", svsRecipeType, resolveReference), `${element.name}.recipe`);
+ const recipe = inline<Recipe>(reference(element, "recipe", recipeType, resolveReference), `${element.name}.recipe`);
const style = fineCaptionStyle(id, recipe, exactFonts(element, resolveReference));
return {
records: [{ id, type: captionTypes.style, value: { kind: "inline", value: style }, range: element.range }],
@@ -129,7 +124,7 @@ export const decodeFineCaptionTrackSurface: StructuredSurfaceHandler = ({ elemen
const timing = reference(element, "timing", captionTypes.timing, resolveReference);
const within = reference(element, "within", spatialTypes.frame, resolveReference);
const context = resolveTemporalContext({ element, resolveReference });
- const regions = element.attributes.regions === undefined ? undefined : reference(element, "regions", regionTrackTypes.track, resolveReference);
+ const regions = element.attributes.regions === undefined ? undefined : reference(element, "regions", regionEvidenceTypes.evidence, resolveReference);
const records: SurfaceRecordDraft[] = [{ id: `${id}.header`, type: captionTypes.header,
value: { kind: "inline", value: { id } }, range: element.range }];
const components: SurfaceComponentDraft[] = [];
@@ -163,7 +158,7 @@ export const decodeFineCaptionTrackSurface: StructuredSurfaceHandler = ({ elemen
}
operations.push({ id: "schedule", producer: captionFineProducers.schedule,
inputs: { timing: input("timing"), document: input("document"), program: operation(previous) }, result: { kind: "output", name: "schedule" } });
- if (regions !== undefined) { inputs.push({ name: "regions", type: regionTrackTypes.track }); bindings.regions = regions.ref; }
+ if (regions !== undefined) { inputs.push({ name: "regions", type: regionEvidenceTypes.evidence }); bindings.regions = regions.ref; }
operations.push({ id: "render", producer: regions === undefined ? captionFineProducers.render : captionFineProducers.renderWithRegions,
inputs: { schedule: operation("schedule"), document: input("document"), timeline: input("timeline"), within: input("within"), program: operation(previous), ...(regions === undefined ? {} : { regions: input("regions") }) }, result: { kind: "output", name: "track" } });
const collector = sealGraphFragment({ inputs, operations, exports: [
diff --git a/packages/caption-fine/src/types.ts b/packages/caption-fine/src/types.ts
index 0f295bd3..b2839e8d 100644
--- a/packages/caption-fine/src/types.ts
+++ b/packages/caption-fine/src/types.ts
@@ -1,5 +1,5 @@
-import type { CaptionTimingUnit } from "@hypit/caption";
-import type { FontArtifactRef } from "@hypit/media";
+import type { CaptionTimingUnit } from "@hypit/hypit/caption";
+import type { FontArtifactRef } from "@hypit/hypit/media";
export type FineCaptionGlyphPaint = {
readonly fill: string;
diff --git a/packages/caption-fine/test/caption-fine.test.ts b/packages/caption-fine/test/caption-fine.test.ts
index 7eadf5f6..3a8eb7c9 100644
--- a/packages/caption-fine/test/caption-fine.test.ts
+++ b/packages/caption-fine/test/caption-fine.test.ts
@@ -7,8 +7,8 @@ import test from "node:test";
import type { CaptionProgram, CaptionTiming } from "@hypit/caption";
import type { FontArtifactRef } from "@hypit/media";
import { captionDocument, parseScript } from "@hypit/script";
-import type { RegionTrack } from "@hypit/region-track";
-import type { SvsRecipe } from "@hypit/svs";
+import type { RegionEvidence } from "@hypit/hypit/region-evidence";
+import type { Recipe } from "@hypit/recipe";
import { fixtureResource } from "../../../test/fixture-resource.js";
import {
@@ -25,7 +25,7 @@ function renderCaption(
program: CaptionProgram,
document: Parameters<typeof renderFineCaption>[2],
timeline: Timeline,
- regions?: RegionTrack,
+ regions?: RegionEvidence,
) {
return renderFineCaption(schedule, program, document, timeline, bounds, regions);
}
@@ -41,7 +41,7 @@ const font: FontArtifactRef = {
style: "normal",
};
-const recipe: SvsRecipe = {
+const recipe: Recipe = {
path: "caption.base",
properties: {
"stack-order": 70,
@@ -203,7 +203,7 @@ test("Fine Caption follows measured Role regions and hides null Frames", () => {
<BOY>one two || three four
</line>`);
const space = sealTimeline({ id: "test-space", frameCount: 90, frameRate: { numerator: 30, denominator: 1 } });
- const regions: RegionTrack = {
+ const regions: RegionEvidence = {
timelineId: space.id,
series: [{
id: "BOY",
@@ -224,12 +224,12 @@ test("Fine Caption follows measured Role regions and hides null Frames", () => {
assert.equal(declarationAt(2, "opacity"), 1);
});
-test("Fine Caption keeps authored placement when a Cue Role has no measured track", () => {
+test("Fine Caption keeps authored placement when a Cue Role has no measured evidence series", () => {
const { document, program, projection } = fixture(`<line>
<BOY>one two || three four
</line>`);
const space = sealTimeline({ id: "test-space", frameCount: 90, frameRate: { numerator: 30, denominator: 1 } });
- const regions: RegionTrack = {
+ const regions: RegionEvidence = {
timelineId: space.id,
series: [{ id: "WIFE", frames: Array.from({ length: 90 }, () => null) }],
};
@@ -316,7 +316,7 @@ test("Fine Caption gives overlapping acoustic Words one current Karaoke owner",
assert.equal(opacityAt(secondActive, 14), 1);
});
-function unevenChineseCaption(properties: SvsRecipe["properties"] = {}) {
+function unevenChineseCaption(properties: Recipe["properties"] = {}) {
const { document, program, projection } = fixture("<line>你真好看</line>");
const { "max-lines": _lines, "max-words-per-line": _words, ...flow } = recipe.properties;
const style = fineCaptionStyle("plain", {
@@ -458,10 +458,10 @@ test("Caption Surface wires one Timeline to both ordinary and tracked-region ren
const { decodeFineCaptionTrackSurface } = await import("../src/surface.js");
const { timelineTypes } = await import("@hypit/timeline");
const { captionTypes } = await import("@hypit/caption");
- const { regionTrackTypes } = await import("@hypit/region-track");
+ const { regionEvidenceTypes } = await import("@hypit/hypit/region-evidence");
const { spatialTypes } = await import("@hypit/spatial");
const types = { timeline: timelineTypes.timeline, document: captionTypes.document,
- timing: captionTypes.timing, within: spatialTypes.frame, program: captionTypes.program, regions: regionTrackTypes.track };
+ timing: captionTypes.timing, within: spatialTypes.frame, program: captionTypes.program, regions: regionEvidenceTypes.evidence };
for (const tracking of [false, true]) {
const names = tracking ? ["timeline", "document", "timing", "within", "regions"] as const
: ["timeline", "document", "timing", "within"] as const;
diff --git a/packages/caption-fine/test/layout.browser.test.ts b/packages/caption-fine/test/layout.browser.test.ts
index b71039a2..5a73d83a 100644
--- a/packages/caption-fine/test/layout.browser.test.ts
+++ b/packages/caption-fine/test/layout.browser.test.ts
@@ -1,20 +1,20 @@
import assert from "node:assert/strict";
import { existsSync } from "node:fs";
-import { compileHyperframesDocument, materializeHyperframesHtml } from "@hypit/hyperframes";
+import { compileHtmlProgram, materializeHtmlProgram } from "@hypit/html-program";
import { sealComposition } from "@hypit/composition";
import sharp from "sharp";
import test from "node:test";
import { captureBrowserExecutablePath, withCapture } from "@hypit/browser-capture";
import { captionDocument, parseScript } from "@hypit/script";
import { sealTimeline } from "@hypit/timeline";
-import type { SvsRecipe } from "@hypit/svs";
+import type { Recipe } from "@hypit/recipe";
import { projectProgramWindow } from "../../../test/temporal-fixture.js";
import { fixtureResource } from "../../../test/fixture-resource.js";
import { fineCaptionStyle, renderFineCaption, scheduleFineCaption } from "../src/index.js";
const executablePath = process.env.HYPIT_CAPTURE_TEST_BROWSER ?? await captureBrowserExecutablePath();
-function cueHtml(source: string, width: number, extra: SvsRecipe["properties"]): string {
+function cueHtml(source: string, width: number, extra: Recipe["properties"]): string {
const document = captionDocument(parseScript("layout", `<line>${source}</line>`), "caption", "story");
const timeline = sealTimeline({ id: "timeline", frameCount: 120, frameRate: { numerator: 30, denominator: 1 } });
const style = fineCaptionStyle("plain", { path: "caption", properties: {
@@ -31,10 +31,10 @@ function cueHtml(source: string, width: number, extra: SvsRecipe["properties"]):
}] };
const track = renderFineCaption(scheduleFineCaption(timed, program, document), program, document, timeline,
{ xPx: 0, yPx: 0, widthPx: width, heightPx: 500 });
- const compiled = compileHyperframesDocument(sealComposition({ id: "test",
+ const compiled = compileHtmlProgram(sealComposition({ id: "test",
canvas: { width, height: 500, clearColor: "#ffffff" }, tracks: [track] }), timeline);
// Both copies use the same face. Exact-font loading is exercised by renderer integration.
- return materializeHyperframesHtml(compiled, () => "data:font/woff2;base64,AA==")
+ return materializeHtmlProgram(compiled, () => "data:font/woff2;base64,AA==")
.replace("</head>", `<style>[data-hypit-element-id]{font-family:Arial!important}[data-composition-id]{width:${width}px;height:500px}</style></head>`);
}
@@ -76,13 +76,15 @@ test("joined backgrounds cover wrapped glyphs, preserve opacity and seek without
// Reverse/repeated seeks and a resized Cue exercise measurement after layout changes.
for (const [frame, scale, size] of [[0, 1, width], [20, 1, width], [5, .7, width],
[0, 1, width + 40], [20, 1, width]] as const) {
- const coverage = await page.evaluate(({ frame, scale, size }) => {
+ const coverage = await page.evaluate(async ({ frame, scale, size }) => {
const cue = document.querySelector<HTMLElement>('[data-hypit-element-id="cue"]')!;
cue.style.width = `${size}px`;
// The box is measured in its own coordinates even while its ancestors move.
cue.style.transform = `rotate(12deg) scale(${scale})`;
- window.dispatchEvent(new CustomEvent("hf-seek", { detail: { time: frame / 30 } }));
- const error = (window as unknown as { __hypitBrowserProgramError?: string }).__hypitBrowserProgramError;
+ await (window as typeof window & {
+ __hypitFrameProgram: { applyFrame(frame: number): Promise<void> };
+ }).__hypitFrameProgram.applyFrame(frame);
+ const error = (window as unknown as { __hypitHtmlVisualError?: string }).__hypitHtmlVisualError;
const layers = Array.from(document.querySelectorAll<HTMLElement>('[data-caption-active-box="joined"]'));
const index = Math.min(Math.floor(frame / 5), layers.length - 1);
const path = layers[index]!.querySelector<SVGPathElement>('path')!;
@@ -112,12 +114,14 @@ test("joined backgrounds cover wrapped glyphs, preserve opacity and seek without
await page.setContent(cueHtml("supercalifragilisticexpialidocious", 170, {
"active-box-padding": "12 8", "active-box-border-width": 2, "active-box-border-color": "#000000",
}));
- const samples = await page.evaluate(() => {
+ const samples = await page.evaluate(async () => {
const word = document.querySelector('[data-hypit-element-id="atom-1-base-1"]')!;
const range = document.createRange(); range.selectNodeContents(word);
const lines = Array.from(range.getClientRects());
for (const atom of Array.from(document.querySelectorAll<HTMLElement>('[data-caption-atom]'))) atom.style.visibility = "hidden";
- window.dispatchEvent(new CustomEvent("hf-seek", { detail: { time: 1 } }));
+ await (window as typeof window & {
+ __hypitFrameProgram: { applyFrame(frame: number): Promise<void> };
+ }).__hypitFrameProgram.applyFrame(30);
return {
count: lines.length,
points: lines.map(line => ({ x: (line.left + line.right) / 2, y: (line.top + line.bottom) / 2 })).concat(
diff --git a/packages/caption-fine-studio/test/adapter.test.ts b/packages/caption-fine/test/studio-companion.test.ts
similarity index 97%
rename from packages/caption-fine-studio/test/adapter.test.ts
rename to packages/caption-fine/test/studio-companion.test.ts
index aea2b98a..e91e05e4 100644
--- a/packages/caption-fine-studio/test/adapter.test.ts
+++ b/packages/caption-fine/test/studio-companion.test.ts
@@ -1,13 +1,13 @@
import assert from "node:assert/strict";
import test from "node:test";
-import type { FineCaptionSchedule } from "@hypit/caption-fine";
+import type { FineCaptionSchedule } from "../src/index.js";
import { captionTypes } from "@hypit/caption";
import type { CaptionDocument } from "@hypit/caption";
import { compositionTypes } from "@hypit/composition";
-import type { StudioTrackCompanionContext, StudioEntityDraft } from "@hypit/studio-adapter";
+import type { StudioTrackCompanionContext, StudioEntityDraft } from "@hypit/studio-companion";
-import { captionFineInspectorFields, projectCaptionContents } from "../src/index.js";
+import { captionFineInspectorFields, projectCaptionContents } from "../src/studio.js";
test("Caption Companion owns Inspector grouping", () => {
const declared = (name: string) => captionFineInspectorFields.find((field) => field.binding === `style.${name}`);
@@ -95,7 +95,7 @@ test("Caption Companion projects Cue text and Style from public domain values",
});
test("Caption Uses keep authored windows and child ownership even with no rendered content", async () => {
- const { projectCaption } = await import("../src/index.js");
+ const { projectCaption } = await import("../src/studio.js");
const { temporalTypes } = await import("@hypit/temporal");
const { timelineFixture } = await import("../../../test/timeline-fixture.js");
const { projectProgramWindow } = await import("../../../test/temporal-fixture.js");
diff --git a/packages/caption/README.md b/packages/caption/README.md
index ed6b748c..5d0f159d 100644
--- a/packages/caption/README.md
+++ b/packages/caption/README.md
@@ -29,7 +29,7 @@ actually needs and ordered `Use` children. Fine takes one placement Frame:
</caption-fine:Caption>
```
-Time attributes come from `@hypit/temporal-markup`: `during`, or exactly two of `from`, `until`, and
+Time attributes come from `@hypit/temporal/markup`: `during`, or exactly two of `from`, `until`, and
`for`, including resolved temporal references and explicit frame/second expressions. Omitted time
attributes mean the whole Timeline. Domain adapters must resolve semantic or other domain references
to ordinary absolute Windows/Instants before a Caption family consumes them. `role` filters content independently of time. Later matching
@@ -39,7 +39,7 @@ remain independent and can intentionally display simultaneous captions.
## Rendering-family extension
A family owns its Style, schedule, renderer and Track Surface. It can use ordinary VisualTrack
-objects or an explicit browser program; no central renderer dispatch is required.
+objects or an explicit HTML visual; no central renderer dispatch is required.
The public helpers and Types are in [index.ts](src/index.ts):
diff --git a/packages/caption/package.json b/packages/caption/package.json
index bdb39761..353fac85 100644
--- a/packages/caption/package.json
+++ b/packages/caption/package.json
@@ -11,10 +11,11 @@
"activation": "./src/activation.ts"
},
"dependencies": {
- "@hypit/component-kit": "workspace:*",
+ "@hypit/producer": "workspace:*",
"@hypit/protocol": "workspace:*",
"@hypit/markup": "workspace:*",
- "@hypit/temporal": "workspace:*"
+ "@hypit/temporal": "workspace:*",
+ "@hypit/admission": "workspace:*"
},
"devDependencies": {}
}
diff --git a/packages/caption/src/activation.ts b/packages/caption/src/activation.ts
index cce2649c..019b6b52 100644
--- a/packages/caption/src/activation.ts
+++ b/packages/caption/src/activation.ts
@@ -1,4 +1,6 @@
-import { createMarkupSurfaceHostFacet } from "@hypit/markup";
+import { createAdmissionPackageFacet } from "@hypit/admission";
+import { createProducerPackageFacet } from "@hypit/producer";
+import { createMarkupSurfaceFacet } from "@hypit/markup";
import {
captionComponent, captionManifest, captionModuleRef,
decodeHiddenCaptionStyleSurface,
@@ -6,11 +8,11 @@ import {
} from "./index.js";
export const hypitPackage = {
- format: "hypit.node-package@1" as const,
+ format: "hypit.package@1" as const,
modules: [{ manifest: captionManifest }],
- components: [captionComponent],
- hostFacets: [
- createMarkupSurfaceHostFacet({ module: captionModuleRef,
+ facets: [
+ ...[captionComponent].flatMap((component) => [createProducerPackageFacet(component), createAdmissionPackageFacet(component)]),
+ createMarkupSurfaceFacet({ module: captionModuleRef,
declaration: captionMarkupSurfaces.find((item) => item.name === "hidden")!, handler: decodeHiddenCaptionStyleSurface }),
],
};
diff --git a/packages/caption/src/component.ts b/packages/caption/src/component.ts
index fad0de1d..25dbd22e 100644
--- a/packages/caption/src/component.ts
+++ b/packages/caption/src/component.ts
@@ -1,5 +1,6 @@
+import type { AdmissionPackage } from "@hypit/admission";
import type { TemporalWindow } from "@hypit/temporal";
-import type { ComponentPackage } from "@hypit/component-kit";
+import type { ProducerPackage } from "@hypit/producer";
import type { StoredValue } from "@hypit/protocol";
import { canonicalize } from "@hypit/protocol";
@@ -41,4 +42,4 @@ export const captionComponent = {
{ type: captionTypes.program, handler: ({ value }) => assertCaptionProgram(inline<CaptionProgram>(value, "CaptionProgram")) },
{ type: captionTypes.timing, handler: ({ value }) => assertCaptionTiming(inline<CaptionTiming>(value, "CaptionTiming")) },
],
-} satisfies ComponentPackage;
+} satisfies ProducerPackage & AdmissionPackage;
diff --git a/packages/composition/README.md b/packages/composition/README.md
index 540cbabf..3b993b6f 100644
--- a/packages/composition/README.md
+++ b/packages/composition/README.md
@@ -2,6 +2,11 @@
Provider-neutral visual and audio Track contracts and their final Composition.
+Composition also owns the terminal structural visual vocabulary identified by `VISUAL_IR_V1`,
+including its supported CSS-shaped declarations and validation. There is no peer Visual IR Module:
+the vocabulary versions the visual representation carried by `VisualTrack`, while richer renderer
+program payloads remain explicitly owned by their rendering package.
+
## VisualTrack
`sealVisualTrack` accepts `id`, `timelineId`, `visualIr: VISUAL_IR_V1` and `presents` and returns
@@ -53,15 +58,15 @@ each selected Output explicitly.
A Composition carries its id, Canvas with clear color, and peer Tracks. The Tracks retain their
Timeline identity; assembly and rendering receive the corresponding Timeline separately.
`@hypit/film` is one author-facing way to assemble it;
-`@hypit/render-hyperframes` consumes it to produce a video.
+`@hypit/html-video` consumes it to produce a video.
### Visibility without a new source-time origin
A VisualPresent may supply `visibility`, an ordered list of non-overlapping subranges in program
frames, all inside its `span`. Omission means the full span; an empty list means never visible.
`span` continues to define local animation and media-sampling time. This permits rule overrides or
-other partial visibility without cutting a program into restarted copies. HyperFrames applies the
-visibility independently when seeking; custom HTML and typed media keep their original clocks.
+other partial visibility without cutting a program into restarted copies. The `HtmlProgram` applies
+visibility independently at each requested frame; custom HTML and typed media keep their original clocks.
## Audio level automation on the program clock
diff --git a/packages/composition/package.json b/packages/composition/package.json
index d947b34e..85172929 100644
--- a/packages/composition/package.json
+++ b/packages/composition/package.json
@@ -11,19 +11,18 @@
"activation": "./src/activation.ts"
},
"dependencies": {
- "@hypit/component-kit": "workspace:*",
+ "@hypit/admission": "workspace:*",
+ "@hypit/producer": "workspace:*",
"@hypit/media": "workspace:*",
"@hypit/protocol": "workspace:*",
- "@hypit/visual-ir": "workspace:*",
"@hypit/timeline": "workspace:*"
},
"devDependencies": {
- "@hypit/artifact": "workspace:*",
- "@hypit/core": "workspace:*",
+ "@hypit/blob": "workspace:*",
+ "@hypit/kernel": "workspace:*",
"@hypit/narrative": "workspace:*",
+ "@hypit/recipe": "workspace:*",
"@hypit/spatial": "workspace:*",
- "@hypit/speech": "workspace:*",
- "@hypit/speech-evidence": "workspace:*",
- "@hypit/validation": "workspace:*"
+ "@hypit/speech-evidence": "workspace:*"
}
}
diff --git a/packages/composition/src/activation.ts b/packages/composition/src/activation.ts
index 55b77274..1daef63b 100644
--- a/packages/composition/src/activation.ts
+++ b/packages/composition/src/activation.ts
@@ -1,3 +1,8 @@
+import { createAdmissionPackageFacet } from "@hypit/admission";
import { compositionComponent, compositionManifest } from "./index.js";
-export const hypitPackage = { format: "hypit.node-package@1" as const, modules: [{ manifest: compositionManifest }], components: [compositionComponent] };
+export const hypitPackage = {
+ format: "hypit.package@1" as const,
+ modules: [{ manifest: compositionManifest }],
+ facets: [createAdmissionPackageFacet(compositionComponent)],
+};
export default hypitPackage;
diff --git a/packages/composition/src/component.ts b/packages/composition/src/component.ts
index 820e1a59..f2209004 100644
--- a/packages/composition/src/component.ts
+++ b/packages/composition/src/component.ts
@@ -1,4 +1,5 @@
-import type { ComponentPackage } from "@hypit/component-kit";
+import type { AdmissionPackage } from "@hypit/admission";
+import type { ProducerPackage } from "@hypit/producer";
import { compositionTypes } from "./manifest.js";
import { assertAudioTrackIdentity, assertCompositionIdentity, assertVisualTrackIdentity } from "./track.js";
import type { AudioTrack, Composition, VisualTrack } from "./track.js";
@@ -7,4 +8,4 @@ export const compositionComponent = { validators: [
{ type: compositionTypes.visualTrack, handler: ({ value }) => assertVisualTrackIdentity(inline(value, "VisualTrack") as VisualTrack) },
{ type: compositionTypes.audioTrack, handler: ({ value }) => assertAudioTrackIdentity(inline(value, "AudioTrack") as AudioTrack) },
{ type: compositionTypes.composition, handler: ({ value }) => assertCompositionIdentity(inline(value, "Composition") as Composition) },
-] } satisfies ComponentPackage;
+] } satisfies ProducerPackage & AdmissionPackage;
diff --git a/packages/composition/src/index.ts b/packages/composition/src/index.ts
index 148395c7..c15b4234 100644
--- a/packages/composition/src/index.ts
+++ b/packages/composition/src/index.ts
@@ -15,7 +15,15 @@ export {
} from "./schema.js";
export { assertAudioTrackIdentity, assertCompositionIdentity, assertVisualTrackIdentity, sealAudioTrack, sealComposition, sealVisualTrack } from "./track.js";
export { animatableLocalStyles } from "./track.js";
+export { visualCompositionVocabulary } from "./introspection.js";
export type * from "./track.js";
export * from "./audio-level-automation.js";
export { audioSampleSpanSchema, audioGainEnvelopeSchema } from "./schema.js";
+export {
+ assertVisualStyleV1,
+ VISUAL_IR_V1,
+ VISUAL_STYLE_ENUM_VALUES_V1,
+ VISUAL_STYLE_NAMES_V1,
+} from "./visual.js";
+export type { VisualStyleNameV1 } from "./visual.js";
diff --git a/packages/composition/src/introspection.ts b/packages/composition/src/introspection.ts
new file mode 100644
index 00000000..f4dc48a4
--- /dev/null
+++ b/packages/composition/src/introspection.ts
@@ -0,0 +1,52 @@
+import type { ValueSchema } from "@hypit/protocol";
+
+import {
+ visualBoxSchema,
+ visualElementSchema,
+ visualImageSchema,
+ visualMaskSchema,
+ visualPathCommandSchema,
+ visualProgramSchema,
+ visualSurfaceSchema,
+ visualTextDocumentSchema,
+ visualTextFlowSchema,
+ visualTextPaintSchema,
+ visualTextSchema,
+ visualTextTypographySchema,
+ visualTrackSchema,
+ visualVideoSchema,
+} from "./schema.js";
+
+/** Named values and invariants owned by Composition, presented by any author-inspection surface. */
+export const visualCompositionVocabulary: {
+ readonly shapes: Readonly<Record<string, ValueSchema>>;
+ readonly rules: readonly string[];
+} = {
+ shapes: {
+ "visual-track": visualTrackSchema,
+ "visual-element": visualElementSchema,
+ program: visualProgramSchema,
+ box: visualBoxSchema,
+ mask: visualMaskSchema,
+ text: visualTextSchema,
+ image: visualImageSchema,
+ video: visualVideoSchema,
+ surface: visualSurfaceSchema,
+ "text-flow": visualTextFlowSchema,
+ "text-typography": visualTextTypographySchema,
+ "text-paint": visualTextPaintSchema,
+ "text-document": visualTextDocumentSchema,
+ "path-command": visualPathCommandSchema,
+ },
+ rules: [
+ "A Present holds exactly one element with no `parent`; every other element names one, and it must be a box, mask or program.",
+ "`order` is unique across the whole Present, not among siblings.",
+ "A child's position is measured from its parent's box, not from the Canvas.",
+ "An animation carries at least two keyframes, and every keyframe of one animation declares the same properties; `atFrame` is Present-relative.",
+ "A plain text element provides exact ordered font artifacts and cannot combine them with raw `font`, `font-family`, `font-style`, `font-synthesis` or `font-weight` styles.",
+ "A text element using glyph Paint cannot also declare raw stroke or paint-order styles.",
+ "A media element's artifact media type must match image/video, and still images cannot carry sampling.",
+ "A Surface with still timing cannot carry sampling; frame-based Surface sampling must match its typed timing.",
+ "Mask roots must be direct children of one Present and both mask/content references must resolve to owned elements.",
+ ],
+};
diff --git a/packages/composition/src/manifest.ts b/packages/composition/src/manifest.ts
index 90430c27..33e62c60 100644
--- a/packages/composition/src/manifest.ts
+++ b/packages/composition/src/manifest.ts
@@ -1,11 +1,10 @@
import { mediaDependency, timelineDependency } from "./schema.js";
-import { visualIrDependency } from "@hypit/visual-ir";
import type { ModuleManifest, TypeRef } from "@hypit/protocol";
import { audioTrackSchema, compositionSchema, visualTrackSchema } from "./schema.js";
export const compositionModuleRef = { name: "@hypit/composition", version: "1" } as const;
export const compositionTypes = { visualTrack: { module: compositionModuleRef, name: "VisualTrack" }, audioTrack: { module: compositionModuleRef, name: "AudioTrack" }, composition: { module: compositionModuleRef, name: "Composition" } } satisfies Record<string, TypeRef>;
export const compositionManifest: ModuleManifest = { format: "hypit.module@1", name: compositionModuleRef.name, version: compositionModuleRef.version,
- dependencies: [mediaDependency, timelineDependency, visualIrDependency], types: [
+ dependencies: [mediaDependency, timelineDependency], types: [
{ name: compositionTypes.visualTrack.name },
{ name: compositionTypes.audioTrack.name },
{ name: compositionTypes.composition.name },
diff --git a/packages/composition/src/schema.ts b/packages/composition/src/schema.ts
index c05c4d06..f4063ccd 100644
--- a/packages/composition/src/schema.ts
+++ b/packages/composition/src/schema.ts
@@ -1,7 +1,7 @@
import { compositableSurfaceSchema, fontArtifactSchema, mediaDependency } from "@hypit/media";
import { timelineDependency } from "@hypit/timeline";
import type { ValueSchema } from "@hypit/protocol";
-import { VISUAL_IR_V1, VISUAL_STYLE_ENUM_VALUES_V1, VISUAL_STYLE_NAMES_V1 } from "@hypit/visual-ir";
+import { VISUAL_IR_V1, VISUAL_STYLE_ENUM_VALUES_V1, VISUAL_STYLE_NAMES_V1 } from "./visual.js";
export { mediaDependency, timelineDependency };
const string = { kind: "string", minLength: 1 } as const; const number = { kind: "number", minimum: 0 } as const;
const integer = { kind: "number", integer: true, minimum: 0 } as const; const signedInteger = { kind: "number", integer: true } as const;
diff --git a/packages/composition/src/track.ts b/packages/composition/src/track.ts
index f0290151..12d07446 100644
--- a/packages/composition/src/track.ts
+++ b/packages/composition/src/track.ts
@@ -6,7 +6,7 @@ import type { BlobRef, CanonicalValue } from "@hypit/protocol";
import {
assertVisualStyleV1,
VISUAL_IR_V1,
-} from "@hypit/visual-ir";
+} from "./visual.js";
import { assertTimelineIdentity, timelineFrameCount, timelineSampleFrames } from "@hypit/timeline";
import type { Timeline } from "@hypit/timeline";
import { assertCompositableSurfaceRef, assertFontArtifactRef } from "@hypit/media";
diff --git a/packages/composition/src/visual.ts b/packages/composition/src/visual.ts
new file mode 100644
index 00000000..e4308dbb
--- /dev/null
+++ b/packages/composition/src/visual.ts
@@ -0,0 +1,222 @@
+/** Structural style vocabulary owned by Composition. Renderer programs own richer layout and code formats. */
+export const VISUAL_IR_V1 = "hypit.visual-ir@1" as const;
+
+/**
+ * Closed CSS-shaped vocabulary for public visual Visual IR v1.
+ *
+ * Values remain serialized declarations because the target is browser based,
+ * but components cannot silently extend the language by inventing another CSS
+ * property. New semantics require a versioned IR revision; unusual visuals use
+ * CompositableSurface instead.
+ */
+export const VISUAL_STYLE_NAMES_V1 = [
+ "-webkit-background-clip",
+ "-webkit-box-decoration-break",
+ "-webkit-box-orient",
+ "-webkit-line-clamp",
+ "-webkit-text-fill-color",
+ "-webkit-text-stroke",
+ "-webkit-text-stroke-color",
+ "-webkit-text-stroke-width",
+ "align-content",
+ "align-items",
+ "align-self",
+ "aspect-ratio",
+ "background",
+ "backdrop-filter",
+ "mix-blend-mode",
+ "isolation",
+ "background-clip",
+ "background-color",
+ "background-image",
+ "background-position",
+ "background-repeat",
+ "background-size",
+ "border",
+ "border-bottom",
+ "border-bottom-color",
+ "border-bottom-left-radius",
+ "border-bottom-right-radius",
+ "border-bottom-style",
+ "border-bottom-width",
+ "border-color",
+ "border-left",
+ "border-left-color",
+ "border-left-style",
+ "border-left-width",
+ "border-radius",
+ "border-right",
+ "border-right-color",
+ "border-right-style",
+ "border-right-width",
+ "border-style",
+ "border-top",
+ "border-top-color",
+ "border-top-left-radius",
+ "border-top-right-radius",
+ "border-top-style",
+ "border-top-width",
+ "border-width",
+ "bottom",
+ "box-decoration-break",
+ "box-shadow",
+ "box-sizing",
+ "clip-path",
+ "color",
+ "column-gap",
+ "column-count",
+ "direction",
+ "display",
+ "filter",
+ "flex",
+ "flex-basis",
+ "flex-direction",
+ "flex-grow",
+ "flex-shrink",
+ "flex-wrap",
+ "font-family",
+ "font-feature-settings",
+ "font-kerning",
+ "font-size",
+ "font-style",
+ "font-synthesis",
+ "font-variant-caps",
+ "font-variation-settings",
+ "font-weight",
+ "gap",
+ "grid-area",
+ "grid-template-columns",
+ "grid-template-rows",
+ "height",
+ "inset",
+ "justify-content",
+ "justify-items",
+ "justify-self",
+ "left",
+ "letter-spacing",
+ "line-height",
+ "margin",
+ "margin-bottom",
+ "margin-left",
+ "margin-right",
+ "margin-top",
+ "max-height",
+ "max-width",
+ "min-height",
+ "min-width",
+ "object-fit",
+ "object-position",
+ "opacity",
+ "outline",
+ "outline-color",
+ "outline-style",
+ "outline-width",
+ "overflow",
+ "overflow-wrap",
+ "overflow-x",
+ "overflow-y",
+ "padding",
+ "padding-bottom",
+ "padding-left",
+ "padding-right",
+ "padding-top",
+ "paint-order",
+ "perspective",
+ "perspective-origin",
+ "position",
+ "right",
+ "row-gap",
+ "text-align",
+ "text-decoration",
+ "text-decoration-color",
+ "text-decoration-line",
+ "text-decoration-skip-ink",
+ "text-decoration-style",
+ "text-decoration-thickness",
+ "text-overflow",
+ "text-indent",
+ "text-orientation",
+ "text-spacing-trim",
+ "text-shadow",
+ "text-transform",
+ "text-underline-offset",
+ "top",
+ "tab-size",
+ "transform",
+ "transform-origin",
+ "transform-style",
+ "vertical-align",
+ "visibility",
+ "white-space",
+ "width",
+ "word-break",
+ "word-spacing",
+ "writing-mode",
+] as const;
+
+export type VisualStyleNameV1 = typeof VISUAL_STYLE_NAMES_V1[number];
+
+const STYLE_NAMES = new Set<string>(VISUAL_STYLE_NAMES_V1);
+
+export const VISUAL_STYLE_ENUM_VALUES_V1 = {
+ "box-sizing": ["border-box", "content-box"],
+ direction: ["ltr", "rtl"],
+ display: ["block", "inline", "inline-block", "flex", "inline-flex", "grid", "inline-grid", "-webkit-box", "none"],
+ "flex-direction": ["row", "row-reverse", "column", "column-reverse"],
+ "flex-wrap": ["nowrap", "wrap", "wrap-reverse"],
+ "object-fit": ["contain", "cover", "fill", "none", "scale-down"],
+ overflow: ["visible", "hidden", "clip"],
+ "overflow-x": ["visible", "hidden", "clip"],
+ "overflow-y": ["visible", "hidden", "clip"],
+ position: ["absolute", "relative"],
+ "text-align": ["left", "right", "center", "start", "end", "justify"],
+ "text-transform": ["none", "capitalize", "uppercase", "lowercase"],
+ visibility: ["visible", "hidden"],
+ "white-space": ["normal", "nowrap", "pre", "pre-wrap", "pre-line", "break-spaces"],
+ "writing-mode": ["horizontal-tb", "vertical-rl", "vertical-lr"],
+} as const satisfies Partial<Record<VisualStyleNameV1, readonly string[]>>;
+
+const ENUM_VALUES = new Map<string, ReadonlySet<string>>(
+ Object.entries(VISUAL_STYLE_ENUM_VALUES_V1)
+ .map(([name, values]) => [name, new Set<string>(values)]),
+);
+
+export function assertVisualStyleV1(
+ name: string,
+ value: string | number,
+ label: string,
+): void {
+ if (!/^-?[a-z][a-z0-9-]*$/u.test(name)) {
+ throw new Error(`${label} contains invalid style name ${name}.`);
+ }
+ if (!STYLE_NAMES.has(name)) {
+ throw new Error(`${label} style ${name} is outside ${VISUAL_IR_V1}.`);
+ }
+ const values = ENUM_VALUES.get(name);
+ if (values !== undefined) {
+ if (typeof value !== "string" || !values.has(value)) {
+ throw new Error(`${label} style ${name} has unsupported value ${String(value)}.`);
+ }
+ return;
+ }
+ if (typeof value === "number") {
+ if (!Number.isFinite(value)) throw new Error(`${label} contains a non-finite style value.`);
+ return;
+ }
+ if (value.length === 0) throw new Error(`${label} contains an empty style value.`);
+ if (/url\s*\(/iu.test(value)) {
+ throw new Error(`${label} must use typed Artifact references instead of CSS url().`);
+ }
+ if (/(?:-webkit-)?image-set\s*\(/iu.test(value)) {
+ throw new Error(`${label} must use typed Artifact references instead of CSS image-set().`);
+ }
+ if (/[;{}]/u.test(value)) {
+ throw new Error(`${label} contains a style value that escapes its declaration.`);
+ }
+ if (/!important|[\u0000-\u001f\u007f]/iu.test(value)) {
+ throw new Error(`${label} contains an unsafe style value.`);
+ }
+ if (/(?:var|env|attr)\s*\(/iu.test(value)) {
+ throw new Error(`${label} contains an environment-dependent style value.`);
+ }
+}
diff --git a/packages/composition/test/track.test.ts b/packages/composition/test/track.test.ts
index 79e6d0fd..cd8417fc 100644
--- a/packages/composition/test/track.test.ts
+++ b/packages/composition/test/track.test.ts
@@ -2,21 +2,20 @@ import assert from "node:assert/strict";
import test from "node:test";
import { fixtureResource } from "../../../test/fixture-resource.js";
-import { registerTypeValidatorFacets } from "@hypit/component-kit";
-import { createResolvedClosure } from "@hypit/core";
+import { registerTypeValidatorFacets } from "@hypit/admission";
+import { createResolvedClosure } from "@hypit/kernel";
import { canonicalize } from "@hypit/protocol";
import type { BlobRef } from "@hypit/protocol";
-import { TypeValidatorRegistry, validateValue } from "@hypit/validation";
-import { artifactManifest } from "@hypit/artifact";
+import { TypeValidatorRegistry, validateValue } from "@hypit/admission";
+import { blobManifest } from "@hypit/blob";
import type { FontArtifactRef } from "@hypit/media";
import { mediaManifest } from "@hypit/media";
import { narrativeManifest } from "@hypit/narrative";
import { timelineManifest, sealTimeline } from "@hypit/timeline";
-import { speechManifest } from "@hypit/speech";
import { speechEvidenceManifest } from "@hypit/speech-evidence";
import { spatialManifest } from "@hypit/spatial";
-import { svsManifest } from "@hypit/svs";
-import { VISUAL_IR_V1, visualIrManifest } from "@hypit/visual-ir";
+import { recipeManifest } from "@hypit/recipe";
+import { VISUAL_IR_V1 } from "@hypit/composition";
import {
assertCompositionIdentity,
@@ -30,8 +29,8 @@ import {
} from "../src/index.js";
import type { VisualTrack } from "../src/index.js";
-const videoContractManifests = [artifactManifest, narrativeManifest, mediaManifest, timelineManifest,
- speechManifest, speechEvidenceManifest, svsManifest, spatialManifest, visualIrManifest, compositionManifest] as const;
+const videoContractManifests = [blobManifest, narrativeManifest, mediaManifest, timelineManifest,
+ speechEvidenceManifest, recipeManifest, spatialManifest, compositionManifest] as const;
const font: FontArtifactRef = {
sources: [{ artifact: { kind: "blob", resource: fixtureResource("track:test-font"), size: 1_024, mediaType: "font/woff2" } }],
diff --git a/packages/film-studio/package.json b/packages/film-studio/package.json
deleted file mode 100644
index 914aabf9..00000000
--- a/packages/film-studio/package.json
+++ /dev/null
@@ -1,19 +0,0 @@
-{
- "name": "@hypit/film-studio",
- "version": "0.0.0-dev",
- "license": "SEE LICENSE IN LICENSE",
- "private": true,
- "type": "module",
- "exports": {
- ".": "./src/index.ts"
- },
- "hypit": {
- "activation": "./src/activation.ts"
- },
- "dependencies": {
- "@hypit/composition": "workspace:*",
- "@hypit/film": "workspace:*",
- "@hypit/timeline": "workspace:*",
- "@hypit/studio-adapter": "workspace:*"
- }
-}
diff --git a/packages/film-studio/src/activation.ts b/packages/film-studio/src/activation.ts
deleted file mode 100644
index e3845808..00000000
--- a/packages/film-studio/src/activation.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import { createStudioCompanionHostFacet } from "@hypit/studio-adapter";
-
-import { filmStudioCompanions } from "./index.js";
-
-export default {
- format: "hypit.node-package@1" as const,
- hostFacets: [createStudioCompanionHostFacet({ films: filmStudioCompanions })],
-};
diff --git a/packages/film/README.md b/packages/film/README.md
index 9d613022..a8fa451c 100644
--- a/packages/film/README.md
+++ b/packages/film/README.md
@@ -7,6 +7,11 @@ Official package-owned assembly layer between peer Tracks and the generic Compos
Film is an ordinary author component and an optional Target, not a Core root or a privileged video
type.
+The official video Distribution installs Film as an ordinary default npm dependency. Film owns its
+author Surface, assembly Producers and Studio film companion together; the reusable companion is
+published as `@hypit/film/studio`. Composition remains the shared value below it, so another author
+package can assemble the same public result without importing Film.
+
The package lowers one concrete Film declaration into a finite `FilmTrackSet` fold, then compiles
that set into `Composition`. This supports any number and mix
of VisualTrack and AudioTrack inputs while every Core Operation retains a fixed manifest-declared
diff --git a/packages/film/package.json b/packages/film/package.json
index e4149ece..5393dfd2 100644
--- a/packages/film/package.json
+++ b/packages/film/package.json
@@ -1,33 +1,43 @@
{
"name": "@hypit/film",
- "version": "0.0.0-dev",
+ "version": "0.1.0",
"license": "SEE LICENSE IN LICENSE",
"private": true,
"type": "module",
"exports": {
- ".": "./src/index.ts"
+ ".": "./src/index.ts",
+ "./studio": "./src/studio.ts"
},
+ "files": [
+ "dist",
+ "README.md"
+ ],
"hypit": {
"activation": "./src/activation.ts"
},
- "dependencies": {
- "@hypit/component-kit": "workspace:*",
- "@hypit/composition": "workspace:*",
- "@hypit/elaborator": "workspace:*",
- "@hypit/protocol": "workspace:*",
- "@hypit/timeline": "workspace:*",
- "@hypit/spatial": "workspace:*",
- "@hypit/svs": "workspace:*",
- "@hypit/markup": "workspace:*",
- "@hypit/temporal-markup": "workspace:*"
+ "peerDependencies": {
+ "@hypit/hypit": "workspace:^",
+ "@hypit/studio-companion": "workspace:^"
},
"devDependencies": {
- "@hypit/core": "workspace:*",
- "@hypit/driver-node": "workspace:*",
- "@hypit/hyperframes": "workspace:*",
+ "@hypit/compiler": "workspace:*",
+ "@hypit/hypit": "workspace:*",
+ "@hypit/studio-companion": "workspace:*",
+ "@hypit/producer": "workspace:*",
+ "@hypit/composition": "workspace:*",
+ "@hypit/kernel": "workspace:*",
+ "@hypit/executor": "workspace:*",
+ "@hypit/author": "workspace:*",
+ "@hypit/source": "workspace:*",
+ "@hypit/html-program": "workspace:*",
+ "@hypit/markup": "workspace:*",
"@hypit/media": "workspace:*",
+ "@hypit/protocol": "workspace:*",
+ "@hypit/spatial": "workspace:*",
+ "@hypit/recipe": "workspace:*",
"@hypit/text": "workspace:*",
"@hypit/text-fine": "workspace:*",
- "@hypit/validation": "workspace:*"
+ "@hypit/timeline": "workspace:*",
+ "@hypit/admission": "workspace:*"
}
}
diff --git a/packages/film/src/activation.ts b/packages/film/src/activation.ts
index e6842587..53ff0b56 100644
--- a/packages/film/src/activation.ts
+++ b/packages/film/src/activation.ts
@@ -1,16 +1,23 @@
-import { createMarkupSurfaceHostFacet } from "@hypit/markup";
+import { createAdmissionPackageFacet } from "@hypit/hypit/admission";
+import { createProducerPackageFacet } from "@hypit/hypit/producer";
+import { createMarkupSurfaceFacet } from "@hypit/hypit/markup";
+import { createStudioCompanionFacet } from "@hypit/studio-companion";
import {
decodeFilmSurface, filmComponent, filmManifest, filmModuleRef,
filmMarkupSurfaces,
} from "./index.js";
+import { filmStudioCompanions } from "./studio.js";
export const hypitPackage = {
- format: "hypit.node-package@1" as const,
+ format: "hypit.package@1" as const,
modules: [{ manifest: filmManifest }],
- components: [filmComponent],
- hostFacets: [createMarkupSurfaceHostFacet({
- module: filmModuleRef,
- declaration: filmMarkupSurfaces.find((item) => item.name === "film")!, handler: decodeFilmSurface,
- })],
+ facets: [
+ ...[filmComponent].flatMap((component) => [createProducerPackageFacet(component), createAdmissionPackageFacet(component)]),
+ createMarkupSurfaceFacet({
+ module: filmModuleRef,
+ declaration: filmMarkupSurfaces.find((item) => item.name === "film")!, handler: decodeFilmSurface,
+ }),
+ createStudioCompanionFacet({ films: filmStudioCompanions }),
+ ],
};
export default hypitPackage;
diff --git a/packages/film/src/component.ts b/packages/film/src/component.ts
index 939393fc..2b77a18f 100644
--- a/packages/film/src/component.ts
+++ b/packages/film/src/component.ts
@@ -1,9 +1,10 @@
-import type { Timeline } from "@hypit/timeline";
-import type { ComponentPackage } from "@hypit/component-kit";
-import type { Canvas } from "@hypit/spatial";
-import type { AudioTrack, VisualTrack } from "@hypit/composition";
-import type { StoredValue } from "@hypit/protocol";
-import { canonicalize } from "@hypit/protocol";
+import { canonicalize } from "@hypit/hypit/protocol";
+import type { ProducerPackage } from "@hypit/hypit/producer";
+import type { AdmissionPackage } from "@hypit/hypit/admission";
+import type { StoredValue } from "@hypit/hypit/protocol";
+import type { AudioTrack, VisualTrack } from "@hypit/hypit/composition";
+import type { Canvas } from "@hypit/hypit/spatial";
+import type { Timeline } from "@hypit/hypit/timeline";
import { filmProducers } from "./manifest.js";
import { appendFilmAudioTrack, appendFilmVisualTrack, compileFilmComposition, createFilmTrackSet } from "./program.js";
@@ -58,4 +59,4 @@ export const filmComponent = {
}),
},
],
-} satisfies ComponentPackage;
+} satisfies ProducerPackage & AdmissionPackage;
diff --git a/packages/film/src/fragment.ts b/packages/film/src/fragment.ts
index 7c8ff830..1a136688 100644
--- a/packages/film/src/fragment.ts
+++ b/packages/film/src/fragment.ts
@@ -1,10 +1,9 @@
-import { timelineTypes } from "@hypit/timeline";
-
-import { spatialTypes } from "@hypit/spatial";
-import { compositionTypes } from "@hypit/composition";
-import type { Track } from "@hypit/composition";
-import { sealGraphFragment } from "@hypit/elaborator";
-import type { FragmentOperation } from "@hypit/elaborator";
+import { sealGraphFragment } from "@hypit/hypit/author";
+import type { FragmentOperation } from "@hypit/hypit/author";
+import { compositionTypes } from "@hypit/hypit/composition";
+import type { Track } from "@hypit/hypit/composition";
+import { spatialTypes } from "@hypit/hypit/spatial";
+import { timelineTypes } from "@hypit/hypit/timeline";
import { filmProducers, filmTypes } from "./manifest.js";
import type { FilmAssemblyFragmentOptions, FilmTrackInput } from "./types.js";
diff --git a/packages/film/src/manifest.ts b/packages/film/src/manifest.ts
index 504caf56..f7f10ec5 100644
--- a/packages/film/src/manifest.ts
+++ b/packages/film/src/manifest.ts
@@ -1,11 +1,10 @@
-import { timelineTypes, timelineDependency } from "@hypit/timeline";
-import type { Timeline } from "@hypit/timeline";
-import { temporalContextAttributeVocabulary } from "@hypit/temporal-markup";
-import { audioTrackSchema, compositionDependency, compositionTypes, visualTrackSchema } from "@hypit/composition";
-
-import type { ModuleManifest, ProducerRef, TypeRef, ValueSchema } from "@hypit/protocol";
-import { spatialDependency, spatialTypes } from "@hypit/spatial";
-import { svsManifest, svsModuleRef, svsRecipeType } from "@hypit/svs";
+import type { ModuleManifest, ProducerRef, TypeRef, ValueSchema } from "@hypit/hypit/protocol";
+import { audioTrackSchema, compositionDependency, compositionTypes, visualTrackSchema } from "@hypit/hypit/composition";
+import { spatialDependency, spatialTypes } from "@hypit/hypit/spatial";
+import { recipeManifest, recipeModuleRef, recipeType } from "@hypit/hypit/recipe";
+import { temporalContextAttributeVocabulary } from "@hypit/hypit/temporal/markup";
+import { timelineTypes, timelineDependency } from "@hypit/hypit/timeline";
+import type { Timeline } from "@hypit/hypit/timeline";
export const filmModuleRef = { name: "@hypit/film", version: "1" } as const;
export const filmTypes = {
@@ -59,7 +58,7 @@ export const filmMarkupSurfaces = [{
summary: "Selects the Canvas that decides the Composition's dimensions." },
...temporalContextAttributeVocabulary,
{ name: "appearance", kind: "reference", required: true,
- accepts: [svsRecipeType],
+ accepts: [recipeType],
summary: "Selects the SVS Recipe that decides the clear color behind every Track.",
recipe: [
{ name: "background", required: true,
@@ -103,7 +102,7 @@ export const filmManifest: ModuleManifest = {
timelineDependency,
spatialDependency,
compositionDependency,
- { module: svsModuleRef },
+ { module: recipeModuleRef },
],
types: [
{ name: filmTypes.program.name },
diff --git a/packages/film/src/program.ts b/packages/film/src/program.ts
index ef836bee..e87242d6 100644
--- a/packages/film/src/program.ts
+++ b/packages/film/src/program.ts
@@ -1,9 +1,9 @@
-import { assertTimelineIdentity } from "@hypit/timeline";
-import type { Timeline } from "@hypit/timeline";
-import { assertCanvas } from "@hypit/spatial";
-import type { Canvas } from "@hypit/spatial";
-import { assertAudioTrackIdentity, assertCompositionIdentity, assertVisualTrackIdentity, sealComposition } from "@hypit/composition";
-import type { AudioTrack, Composition, Track, VisualTrack } from "@hypit/composition";
+import { assertAudioTrackIdentity, assertCompositionIdentity, assertVisualTrackIdentity, sealComposition } from "@hypit/hypit/composition";
+import type { AudioTrack, Composition, Track, VisualTrack } from "@hypit/hypit/composition";
+import { assertCanvas } from "@hypit/hypit/spatial";
+import type { Canvas } from "@hypit/hypit/spatial";
+import { assertTimelineIdentity } from "@hypit/hypit/timeline";
+import type { Timeline } from "@hypit/hypit/timeline";
import type { FilmProgram, FilmTrackSet } from "./types.js";
diff --git a/packages/film/src/recipe.ts b/packages/film/src/recipe.ts
index 38db50f7..d72dc647 100644
--- a/packages/film/src/recipe.ts
+++ b/packages/film/src/recipe.ts
@@ -1,5 +1,5 @@
-import type { Timeline } from "@hypit/timeline";
-import type { SvsRecipe } from "@hypit/svs";
+import type { Recipe } from "@hypit/hypit/recipe";
+import type { Timeline } from "@hypit/hypit/timeline";
/**
* The Film Recipe owns Film appearance only. Canvas geometry and Timeline
@@ -8,14 +8,14 @@ import type { SvsRecipe } from "@hypit/svs";
export type FilmAppearance = { readonly clearColor: string };
-export function assertFilmRecipe(properties: SvsRecipe["properties"]): void {
+export function assertFilmRecipe(properties: Recipe["properties"]): void {
const actual = Object.keys(properties).sort().join(" ");
if (actual !== "background") {
throw new Error("Film Recipe requires exactly background");
}
}
-export function filmAppearanceFromRecipe(properties: SvsRecipe["properties"]): FilmAppearance {
+export function filmAppearanceFromRecipe(properties: Recipe["properties"]): FilmAppearance {
assertFilmRecipe(properties);
const background = properties["background"];
if (typeof background !== "string" || !/^#[0-9a-f]{6}(?:[0-9a-f]{2})?$/iu.test(background)) {
diff --git a/packages/film-studio/src/index.ts b/packages/film/src/studio.ts
similarity index 67%
rename from packages/film-studio/src/index.ts
rename to packages/film/src/studio.ts
index 31a3411b..0d3ffb6c 100644
--- a/packages/film-studio/src/index.ts
+++ b/packages/film/src/studio.ts
@@ -1,7 +1,8 @@
-import { timelineTypes } from "@hypit/timeline";
-import type { StudioFilmCompanion } from "@hypit/studio-adapter";
-import { compositionTypes } from "@hypit/composition";
-import { filmModuleRef } from "@hypit/film";
+import { compositionTypes } from "@hypit/hypit/composition";
+import type { StudioFilmCompanion } from "@hypit/studio-companion";
+import { timelineTypes } from "@hypit/hypit/timeline";
+
+import { filmModuleRef } from "./manifest.js";
/** Film owns the author vocabulary that selects its time source and peer Tracks. */
export const filmStudioCompanions: readonly StudioFilmCompanion[] = [{
diff --git a/packages/film/src/surface.ts b/packages/film/src/surface.ts
index 7ec715d3..8d224120 100644
--- a/packages/film/src/surface.ts
+++ b/packages/film/src/surface.ts
@@ -1,15 +1,10 @@
-import { resolveTemporalContext } from "@hypit/temporal-markup";
-import { spatialTypes } from "@hypit/spatial";
-import { compositionTypes } from "@hypit/composition";
-import type { AudioTrack, Track, VisualTrack } from "@hypit/composition";
-import { svsRecipeType } from "@hypit/svs";
-import type { SvsRecipe } from "@hypit/svs";
-import type {
- StructuredElement,
- StructuredSurfaceHandler,
- SurfaceResolvedReference,
- MarkupAttributeValue,
-} from "@hypit/markup";
+import { compositionTypes } from "@hypit/hypit/composition";
+import type { AudioTrack, Track, VisualTrack } from "@hypit/hypit/composition";
+import { spatialTypes } from "@hypit/hypit/spatial";
+import { recipeType } from "@hypit/hypit/recipe";
+import type { Recipe } from "@hypit/hypit/recipe";
+import { resolveTemporalContext } from "@hypit/hypit/temporal/markup";
+import type { StructuredElement, StructuredSurfaceHandler, SurfaceResolvedReference, MarkupAttributeValue } from "@hypit/hypit/markup";
import { createFilmAssemblyFragment } from "./fragment.js";
import { filmTypes } from "./manifest.js";
@@ -61,14 +56,14 @@ function requiredReference(
return resolved;
}
-function recipe(reference: SurfaceResolvedReference, label: string): SvsRecipe {
- if (!sameType(reference.type, svsRecipeType)) throw new Error(`${label} must reference an SVS Recipe`);
+function recipe(reference: SurfaceResolvedReference, label: string): Recipe {
+ if (!sameType(reference.type, recipeType)) throw new Error(`${label} must reference an SVS Recipe`);
const value = reference.record?.value;
if (value?.kind !== "inline" || value.value === null || Array.isArray(value.value)
|| typeof value.value !== "object") {
throw new Error(`${label} must reference an authored Recipe value`);
}
- return value.value as SvsRecipe;
+ return value.value as Recipe;
}
function trackChildren(element: StructuredElement): StructuredElement[] {
diff --git a/packages/film/src/types.ts b/packages/film/src/types.ts
index fc8e1e47..dd95c5a5 100644
--- a/packages/film/src/types.ts
+++ b/packages/film/src/types.ts
@@ -1,4 +1,4 @@
-import type { Track } from "@hypit/composition";
+import type { Track } from "@hypit/hypit/composition";
/** Package-owned authoring value. A future Film Surface may produce this record. */
export type FilmProgram = {
diff --git a/packages/film/test/film.test.ts b/packages/film/test/film.test.ts
index 22019dc7..ce758718 100644
--- a/packages/film/test/film.test.ts
+++ b/packages/film/test/film.test.ts
@@ -1,7 +1,7 @@
import { sealTimeline, timelineTypes } from "@hypit/timeline";
import type { Timeline } from "@hypit/timeline";
import { compositionComponent, spatialComponent, videoContractManifests } from "../../../test/support/video-domain.js";
-import { registerTypeValidatorFacets } from "@hypit/component-kit";
+import { registerTypeValidatorFacets } from "@hypit/admission";
import { compositionTypes, sealAudioTrack, sealVisualTrack } from "@hypit/composition";
import type { Composition, Track } from "@hypit/composition";
import type { FontArtifactRef } from "@hypit/media";
@@ -18,19 +18,19 @@ import {
sealCompiledGraph,
sealRecord,
start,
-} from "@hypit/core";
-import { ProducerRegistry, NodeDriver } from "@hypit/driver-node";
+} from "@hypit/kernel";
+import { ProducerRegistry, Executor } from "@hypit/executor";
import {
bindAuthorFragment,
elaborateGraphFragment,
mergeFragmentContributions,
-} from "@hypit/elaborator";
+} from "@hypit/author";
import { appendFilmAudioTrack, appendFilmVisualTrack, compileFilmComposition, createFilmAssemblyFragment, createFilmTrackSet, filmManifest, filmProducers, filmTypes, sealFilmProgram } from "@hypit/film";
-import { compileHyperframesDocument, hyperframesDocumentFragment, hyperframesManifest, hyperframesProducers, hyperframesTypes } from "@hypit/hyperframes";
+import { compileHtmlProgram, htmlProgramFragment, htmlProgramManifest, htmlProgramProducers, htmlProgramTypes } from "@hypit/html-program";
import type { CanonicalValue, CompiledGraph, StoredValue, TypedRecord } from "@hypit/protocol";
import { renderFineTextOccurrence, stillTextMotion } from "@hypit/text-fine";
import type { TextStyle } from "@hypit/text-fine";
-import { admitRecord, TypeValidatorRegistry } from "@hypit/validation";
+import { admitRecord, TypeValidatorRegistry } from "@hypit/admission";
const space = sealTimeline({ id: "test-space", frameCount: 120, frameRate: { numerator: 30, denominator: 1 },
});
@@ -116,7 +116,7 @@ function stored(value: CanonicalValue): StoredValue {
const closure = createResolvedClosure([
...videoContractManifests,
- hyperframesManifest,
+ htmlProgramManifest,
filmManifest,
]);
const records = await Promise.all([
@@ -153,21 +153,21 @@ const filmInstance = elaborateGraphFragment(linked, filmFragment, {
const filmContribution = bindAuthorFragment(filmInstance, {
composition: "main.composition",
});
-const hyperframesInstance = elaborateGraphFragment(linked, hyperframesDocumentFragment, {
+const htmlProgramInstance = elaborateGraphFragment(linked, htmlProgramFragment, {
id: "main-render",
- fragment: hyperframesDocumentFragment.id,
+ fragment: htmlProgramFragment.id,
inputs: {
composition: { kind: "logical-output", id: "main.composition" },
timeline: { kind: "record", id: "timeline" },
},
});
-const hyperframesContribution = bindAuthorFragment(hyperframesInstance, {
- document: "main.document",
+const htmlProgramContribution = bindAuthorFragment(htmlProgramInstance, {
+ program: "main.program",
});
const merged = mergeFragmentContributions(
{ outputs: [], candidates: [], operations: [] },
filmContribution,
- hyperframesContribution,
+ htmlProgramContribution,
);
const graph: CompiledGraph = sealCompiledGraph({ ...merged });
@@ -185,15 +185,15 @@ function producerModules(target: string): string[] {
return build(target).plan.steps.map((step) => step.producer.module.name);
}
-test("Film stops at Composition and Hyperframes remains an ordinary downstream Fragment", () => {
- assert.equal(producerModules("main.composition").includes(hyperframesProducers.compile.module.name), false);
+test("Film stops at Composition and HTML compilation remains an ordinary downstream Fragment", () => {
+ assert.equal(producerModules("main.composition").includes(htmlProgramProducers.compile.module.name), false);
assert.deepEqual(producerNames("main.composition").filter((name) => name.startsWith("append-")).sort(), [
filmProducers.appendAudioTrack.name,
filmProducers.appendVisualTrack.name,
filmProducers.appendVisualTrack.name,
].sort());
assert.equal(
- producerModules("main.document").filter((name) => name === hyperframesProducers.compile.module.name).length,
+ producerModules("main.program").filter((name) => name === htmlProgramProducers.compile.module.name).length,
1,
);
});
@@ -229,17 +229,17 @@ test("the Driver folds peer Tracks, then independently compiles the Composition"
)) },
needs: {},
}));
- registry.registerProducer(hyperframesProducers.compile, ({ inputs }) => ({
- outputs: { document: stored(compileHyperframesDocument(
+ registry.registerProducer(htmlProgramProducers.compile, ({ inputs }) => ({
+ outputs: { program: stored(compileHtmlProgram(
inline(inputs.composition) as never,
inline(inputs.timeline) as typeof space,
)) },
needs: {},
}));
- const result = await new NodeDriver({ producers: registry, validators: validatorRegistry() }).run(build("main.document"));
+ const result = await new Executor({ producers: registry, validators: validatorRegistry() }).run(build("main.program"));
assert.equal(result.status, "complete");
- const documentRecord = result.state.records.find((record) => record.type.module.name === hyperframesTypes.document.module.name);
+ const documentRecord = result.state.records.find((record) => record.type.module.name === htmlProgramTypes.program.module.name);
assert(documentRecord);
const document = inline(documentRecord) as { readonly html: string };
assert.match(document.html, /data-hypit-text-run="title-text"/u);
diff --git a/packages/film/test/surface.test.ts b/packages/film/test/surface.test.ts
index 295a64c8..0b4ae539 100644
--- a/packages/film/test/surface.test.ts
+++ b/packages/film/test/surface.test.ts
@@ -1,6 +1,6 @@
import { sealTimeline, timelineDependency, timelineTypes } from "@hypit/timeline";
import { compositionComponent, spatialComponent, videoContractManifests } from "../../../test/support/video-domain.js";
-import { registerTypeValidatorFacets } from "@hypit/component-kit";
+import { registerTypeValidatorFacets } from "@hypit/admission";
import { compositionDependency, compositionTypes, sealAudioTrack, sealVisualTrack } from "@hypit/composition";
import type { Track } from "@hypit/composition";
import assert from "node:assert/strict";
@@ -8,13 +8,14 @@ import test from "node:test";
import { fixtureResource } from "../../../test/fixture-resource.js";
import { timelineFixture } from "../../../test/timeline-fixture.js";
-import { createResolvedClosure, sealBuildRequest, start } from "@hypit/core";
+import { createResolvedClosure, sealBuildRequest, start } from "@hypit/kernel";
import {
AuthorFrontendRegistry,
- compileSourceClosure,
resolveCompiledSourceExport,
-} from "@hypit/elaborator";
-import type { AuthorSourceUnit } from "@hypit/elaborator";
+} from "@hypit/author";
+import { compileSourceClosure } from "@hypit/compiler";
+import type { ResolvedSource } from "@hypit/source";
+import { resolveSelfDescribedTextSource } from "@hypit/source/text";
import {
decodeFilmSurface,
filmManifest,
@@ -24,7 +25,7 @@ import {
filmTypes,
} from "@hypit/film";
import type { ModuleManifest } from "@hypit/protocol";
-import { svsFrontend, svsRecipeType } from "@hypit/svs";
+import { recipeFrontend, recipeType } from "@hypit/recipe";
import {
decodeCanvasSurface,
spatialManifest,
@@ -37,7 +38,7 @@ import {
createMarkupAuthorFrontend,
} from "@hypit/markup";
import type { StructuredElement, SurfaceResolvedReference } from "@hypit/markup";
-import { createRecordAdmitter, TypeValidatorRegistry } from "@hypit/validation";
+import { createRecordAdmitter, TypeValidatorRegistry } from "@hypit/admission";
const fixtureModule = { name: "example.film-fixture", version: "1" } as const;
const fixtureSurfaceDigest = fixtureResource("example.film-fixture/inputs-surface@1");
@@ -77,13 +78,13 @@ const closure = createResolvedClosure([
filmManifest,
]);
-function source(id: string, text: string): AuthorSourceUnit {
- const frontend = id.endsWith(".svs") ? "@hypit/svs@1" : "@hypit/markup@1";
- return {
+function source(id: string, text: string): ResolvedSource {
+ const frontend = id.endsWith(".svs") ? "@hypit/recipe@1" : "@hypit/markup@1";
+ return resolveSelfDescribedTextSource({
id,
name: id.split("/").at(-1) ?? id,
text: `<?svml using="${frontend}"?>\n${text}`,
- };
+ });
}
function validatorRegistry(): TypeValidatorRegistry {
@@ -129,7 +130,7 @@ async function compileFilm(options: { readonly styles?: string; readonly tracks?
return fixtureModule;
},
}));
- frontends.register(svsFrontend);
+ frontends.register(recipeFrontend);
return await compileSourceClosure({
entry: source("/project/main.svml", `<svml>
@@ -195,8 +196,8 @@ test("Film distinguishes component output ports and resolves duplicate aliases",
for (const [path, type] of [["canvas", spatialTypes.canvas], ["timeline", timelineTypes.timeline]] as const) {
refs.set(path, { path, type, ref: { kind: "record", id: path } });
}
- refs.set("appearance", { path: "appearance", type: svsRecipeType,
- ref: { kind: "record", id: "appearance" }, record: { id: "appearance", type: svsRecipeType,
+ refs.set("appearance", { path: "appearance", type: recipeType,
+ ref: { kind: "record", id: "appearance" }, record: { id: "appearance", type: recipeType,
value: { kind: "inline", value: { path: "film", properties: { background: "#000000" } } } } });
for (const [path, component, output, type] of [
["board.visual", "board", "visual", compositionTypes.visualTrack],
diff --git a/packages/media-pipeline/README.md b/packages/media-pipeline/README.md
deleted file mode 100644
index 379f392b..00000000
--- a/packages/media-pipeline/README.md
+++ /dev/null
@@ -1,121 +0,0 @@
-# `@hypit/media-pipeline`
-
-Provider-neutral media execution vocabulary. Ingestion contributes one ordinary finite Fragment:
-
-```text
-BlobArtifact
- -> inspect-media Need
- -> MediaInspection
- -> deterministic stream selection
- -> MediaStreamSelection
- -> normalize-media Need
- -> SynchronizedMedia
-```
-
-`MediaInspection` enumerates every container stream. The default moving-video policy excludes
-`attached_pic` streams, prefers one declared default, accepts one unambiguous remaining candidate,
-and otherwise fails closed. An explicit stream index is available when the author module genuinely
-knows which alternate stream it wants.
-
-Selecting embedded audio is a media fact only. This package never assigns Script meaning. A later
-speech alignment component may bind one normalized local domain to one authored Segment.
-
-The current normalization profile uses one source presentation origin, a requested rational video frame
-rate, and a 48 kHz stereo PCM render stem. It preserves input level: loudness/mastering remains a
-separate author policy. Its public `SynchronizedMedia` waist carries only the common frame domain,
-optional visual Artifact plus intrinsic extent, and optional audio Artifact. Stream indexes,
-authority choice and the trim/pad ledger remain in Selection and execution instead of travelling
-through every consumer. The field is named `frameDomain`, not `timeline`, because it describes the
-normalized source before any program placement.
-
-Normalization preserves transparency in the selected visual stream. The executing Provider owns
-the intermediate encoding; both opaque and transparent pictures use the same SynchronizedMedia
-value. Normalization also publishes the media's neutral local temporal domain. Speech alignment may
-describe Narrative boundaries on that domain; Timeline authoring may consume its Extent; a domain
-projector may map its boundaries through an equal-length Window. None of those relationships is embedded
-back into SynchronizedMedia.
-
-This package is the shared execution vocabulary. Speech authoring makes the boundary explicit:
-`<pipeline:Normalize>` produces `SynchronizedMedia + LocalTemporalDomain`; a speech provider and
-deterministic alignment produce `NarrativeAlignment`; Timeline authoring separately produces absolute
-Windows. Visual and Audio Tracks consume ordinary media plus the explicit Windows and sampling choices
-they declare; neither owns an implicit normalization policy.
-
-The frame clock is a separate program fact and can be shared by every Normalize and Timeline assembly:
-
-```svml
-<time:Clock id="clock" frame-rate="30"/>
-<pipeline:Normalize id="shot-media" source={shot.video}
- recipe={recipes.media.aroll} clock={clock}/>
-```
-
-An SVS recipe may centralize the stream policy (`video`, `audio` and `span-authority`); it does not
-hide the Normalize graph node or turn multiple sources into one opaque batch operation.
-
-A still image becomes ordinary video before it enters that waist:
-
-```svml
-<media:StillVideo id="opening-still" source={opening-head.image}
- duration="6" clock={clock}/>
-<pipeline:Normalize id="opening-media" source={opening-still.video}
- video="primary-moving" audio="none" span-authority="video" clock={clock}/>
-```
-
-Several images spread over one literal duration the same way, each held for its share of the frames:
-
-```svml
-<media:StillVideo id="kitchen-stills" duration="6" clock={clock}>
- <media:Still source={counter.image}/>
- <media:Still source={basil.image} weight="2"/>
- <media:Still source={board.image}/>
-</media:StillVideo>
-```
-
-`StillVideo` returns a video-only MP4 `BlobArtifact`, not `SynchronizedMedia`. The Surface publishes the
-duration and the weights as Records; `plan-still-video` divides the whole frame count among the
-pictures (every picture holds at least one frame, the rest go by weight with leftovers to the largest
-remainders, earlier first), `bind-still-video-source` attaches each picture in authored order, and
-encoding is one `render-still-video` Need. Pictures of different sizes are fitted into the first one's
-frame and letterboxed. Inspection and normalization remain the same explicit steps used by imported
-or generated moving video. The resulting Blob is ordinary time-bearing visual media. Its later role
-comes entirely from the downstream Source relationships; StillVideo itself owns only the authored
-images, duration and frame clock.
-
-The package also exposes the one-picture Run Fragment `still-video`. It takes `duration`, `clock`,
-`layout` and `source-0`. A Run can select its `video` export as a Candidate through `satisfy`.
-
-Four ordinary author operations reuse that same inspection/execution boundary:
-
-```xml
-<pipeline:Normalize id="shot-media" source={shot.video}
- video="primary-moving" audio="default" span-authority="video" clock={clock}/>
-<media:Transform id="prepared" source={shot-media.media}>
- <media:Trim tail="0.25s"/>
- <media:Retime rate="1.05"/>
-</media:Transform>
-
-<media:ExtractAudio id="voice-reference" source={prepared.video} audio="default"/>
-<media:ExtractFrame id="continuity" source={prepared.video} video="primary-moving" at="last"/>
-```
-
-Every result is an ordinary `BlobArtifact`. Audio extraction emits a deterministic 48 kHz stereo PCM
-WAV but makes no NarrativeAlignment, speaker or semantic claim; it can therefore feed a later model
-reference port directly. Frame extraction supports `first`, `last`, `frame:<index>` and
-`time:<seconds>`. Transform operations are ordered author meaning and never an arbitrary FFmpeg string.
-
-The same package also owns two provider-neutral media completion plans/capabilities:
-
-```text
-Composition -> pure AudioProgramPlan -> render-timeline-audio Need -> TimelineAudio
-RenderedVisual + TimelineAudio -> mux-program-media Need -> MuxedMedia
-```
-
-Compiling an `AudioProgramPlan` is ordinary deterministic code. Reading Artifact bytes, decoding,
-resampling, mixing, encoding or muxing is never a Producer shortcut: it is an explicit Provider
-Need. The plan fixes exact 48 kHz sample boundaries, source-time-derived piece rates, gain/fades and the absence
-of hidden normalization/limiting. The local FFmpeg Provider consumes the shared execution body. Other Providers implement the same
-public request and result semantics.
-
-AudioProgramPlan preserves AudioClip `gainEnvelope` and `audibility` on the full program sample
-clock. The [Composition definition](../composition/README.md#audio-presentation-on-the-program-clock)
-owns their semantics; the plan does not reinterpret source choice or presentation precedence.
diff --git a/packages/media-pipeline/package.json b/packages/media-pipeline/package.json
deleted file mode 100644
index 1f4b44a9..00000000
--- a/packages/media-pipeline/package.json
+++ /dev/null
@@ -1,29 +0,0 @@
-{
- "name": "@hypit/media-pipeline",
- "version": "0.0.0-dev",
- "license": "SEE LICENSE IN LICENSE",
- "private": true,
- "type": "module",
- "exports": {
- ".": "./src/index.ts"
- },
- "hypit": {
- "activation": "./src/activation.ts"
- },
- "dependencies": {
- "@hypit/artifact": "workspace:*",
- "@hypit/component-kit": "workspace:*",
- "@hypit/composition": "workspace:*",
- "@hypit/elaborator": "workspace:*",
- "@hypit/media": "workspace:*",
- "@hypit/narrative": "workspace:*",
- "@hypit/protocol": "workspace:*",
- "@hypit/run": "workspace:*",
- "@hypit/speech": "workspace:*",
- "@hypit/speech-evidence": "workspace:*",
- "@hypit/svs": "workspace:*",
- "@hypit/markup": "workspace:*",
- "@hypit/timeline": "workspace:*",
- "@hypit/temporal": "workspace:*"
- }
-}
diff --git a/packages/media-pipeline/src/activation.ts b/packages/media-pipeline/src/activation.ts
deleted file mode 100644
index c1de4191..00000000
--- a/packages/media-pipeline/src/activation.ts
+++ /dev/null
@@ -1,47 +0,0 @@
-import { createMarkupSurfaceHostFacet } from "@hypit/markup";
-import { createRunFragmentHostFacet } from "@hypit/run";
-import {
- decodeSynchronizedMediaSurface,
- decodeStillVideoSurface,
- decodeExtractAudioSurface,
- decodeExtractFrameSurface,
- decodeTransformMediaSurface,
- mediaPipelineComponent,
- mediaPipelineManifest,
- mediaPipelineModuleRef,
- mediaPipelineMarkupSurfaces,
- stillVideoFragment,
-} from "./index.js";
-
-export const hypitPackage = {
- format: "hypit.node-package@1" as const,
- modules: [{ manifest: mediaPipelineManifest }],
- components: [mediaPipelineComponent],
- hostFacets: [createRunFragmentHostFacet({
- name: "@hypit/media-pipeline@1",
- fragments: {
- "still-video": stillVideoFragment,
- },
- }), createMarkupSurfaceHostFacet({
- module: mediaPipelineModuleRef,
- declaration: mediaPipelineMarkupSurfaces.find((item) => item.name === "synchronized-media")!,
- handler: decodeSynchronizedMediaSurface,
- }), createMarkupSurfaceHostFacet({
- module: mediaPipelineModuleRef,
- declaration: mediaPipelineMarkupSurfaces.find((item) => item.name === "still-video")!,
- handler: decodeStillVideoSurface,
- }), createMarkupSurfaceHostFacet({
- module: mediaPipelineModuleRef,
- declaration: mediaPipelineMarkupSurfaces.find((item) => item.name === "transform-media")!,
- handler: decodeTransformMediaSurface,
- }), createMarkupSurfaceHostFacet({
- module: mediaPipelineModuleRef,
- declaration: mediaPipelineMarkupSurfaces.find((item) => item.name === "extract-audio")!,
- handler: decodeExtractAudioSurface,
- }), createMarkupSurfaceHostFacet({
- module: mediaPipelineModuleRef,
- declaration: mediaPipelineMarkupSurfaces.find((item) => item.name === "extract-frame")!,
- handler: decodeExtractFrameSurface,
- })],
-};
-export default hypitPackage;
diff --git a/packages/media-pipeline/src/audio-plan.ts b/packages/media-pipeline/src/audio-plan.ts
deleted file mode 100644
index b8a7825b..00000000
--- a/packages/media-pipeline/src/audio-plan.ts
+++ /dev/null
@@ -1,146 +0,0 @@
-import { clockFrameSampleBoundary, timelineFrameCount, timelineFrameSampleBoundary } from "@hypit/timeline";
-import type { Timeline } from "@hypit/timeline";
-import { assertAudioLevelAutomation, assertCompositionIdentity } from "@hypit/composition";
-import type { Composition } from "@hypit/composition";
-import { canonicalize, isResourceId } from "@hypit/protocol";
-
-import type { AudioProgramPlan } from "./types.js";
-
-function assert(condition: unknown, message: string): asserts condition {
- if (!condition) throw new Error(message);
-}
-
-function exactInteger(value: { readonly numerator: number; readonly denominator: number }, label: string): number {
- assert(Number.isSafeInteger(value.numerator) && Number.isSafeInteger(value.denominator) && value.denominator > 0
- && value.numerator % value.denominator === 0, `${label} must resolve to an exact source-sample boundary`);
- const result = value.numerator / value.denominator;
- assert(Number.isSafeInteger(result) && result >= 0, `${label} is invalid`);
- return result;
-}
-
-function exactSourceEnd(sourceAtStart: { readonly numerator: number; readonly denominator: number },
- rate: { readonly numerator: number; readonly denominator: number }, targetLength: number, label: string): number {
- const numerator = BigInt(sourceAtStart.numerator) * BigInt(rate.denominator)
- + BigInt(targetLength) * BigInt(rate.numerator) * BigInt(sourceAtStart.denominator);
- const denominator = BigInt(sourceAtStart.denominator) * BigInt(rate.denominator);
- assert(numerator % denominator === 0n, `${label} must resolve to an exact source-sample boundary`);
- const result = numerator / denominator;
- assert(result >= 0n && result <= BigInt(Number.MAX_SAFE_INTEGER), `${label} is invalid`);
- return Number(result);
-}
-
-export function sealAudioProgramPlan(value: AudioProgramPlan): AudioProgramPlan {
- return canonicalize(value) as unknown as AudioProgramPlan;
-}
-
-export function verifyAudioProgramPlan(value: unknown): asserts value is AudioProgramPlan {
- assert(value !== null && typeof value === "object" && !Array.isArray(value), "AudioProgramPlan must be an object");
- const item = value as AudioProgramPlan;
- assert(Number.isSafeInteger(item.frameRate?.numerator) && item.frameRate.numerator > 0
- && Number.isSafeInteger(item.frameRate?.denominator) && item.frameRate.denominator > 0,
- "AudioProgramPlan frame rate is invalid");
- assert(Number.isSafeInteger(item.frameCount) && item.frameCount > 0, "AudioProgramPlan frame count is invalid");
- assert(item.sampleRate === 48_000, "AudioProgramPlan sample rate must be 48000");
- assert(item.sampleFrames === clockFrameSampleBoundary({ frameRate: item.frameRate }, item.frameCount, 48_000),
- "AudioProgramPlan sample count differs from its frame domain");
- assert(Array.isArray(item.clips), "AudioProgramPlan clips are invalid");
- const ids = new Set<string>();
- for (const clip of item.clips) {
- assert(typeof clip.id === "string" && clip.id.length > 0 && !ids.has(clip.id),
- "AudioProgramPlan clip id is empty or repeated");
- ids.add(clip.id);
- assert(clip.artifact?.kind === "blob" && isResourceId(clip.artifact.resource)
- && Number.isSafeInteger(clip.artifact.size) && clip.artifact.size >= 0
- && clip.artifact.mediaType === "audio/wav",
- `AudioProgramPlan clip ${clip.id} must reference canonical WAV`);
- assert(Number.isSafeInteger(clip.targetStartSample) && clip.targetStartSample >= 0
- && Number.isSafeInteger(clip.targetEndSampleExclusive)
- && clip.targetEndSampleExclusive > clip.targetStartSample
- && clip.targetEndSampleExclusive <= item.sampleFrames,
- `AudioProgramPlan clip ${clip.id} target interval is invalid`);
- assert(Number.isSafeInteger(clip.sourceStartSample) && clip.sourceStartSample >= 0,
- `AudioProgramPlan clip ${clip.id} source start is invalid`);
- assert(Number.isSafeInteger(clip.sourceSampleFrames) && clip.sourceSampleFrames > 0
- && Number.isSafeInteger(clip.sourceEndSampleExclusive)
- && clip.sourceEndSampleExclusive > clip.sourceStartSample
- && clip.sourceEndSampleExclusive <= clip.sourceSampleFrames,
- `AudioProgramPlan clip ${clip.id} source interval is invalid`);
- const sourceLength = clip.sourceEndSampleExclusive - clip.sourceStartSample;
- assert(typeof clip.sourceLoop === "boolean"
- && Number.isSafeInteger(clip.sourcePhaseSample) && clip.sourcePhaseSample >= 0
- && clip.sourcePhaseSample < sourceLength
- && (clip.sourceLoop || clip.sourcePhaseSample === 0),
- `AudioProgramPlan clip ${clip.id} loop phase is invalid`);
- assert(Number.isFinite(clip.playbackRate) && clip.playbackRate > 0,
- `AudioProgramPlan clip ${clip.id} playback rate is invalid`);
- assert(Number.isSafeInteger(clip.mixStartSample) && clip.mixStartSample >= 0
- && Number.isSafeInteger(clip.mixEndSampleExclusive) && clip.mixEndSampleExclusive > clip.mixStartSample
- && clip.targetStartSample >= clip.mixStartSample && clip.targetEndSampleExclusive <= clip.mixEndSampleExclusive,
- `AudioProgramPlan clip ${clip.id} mix interval is invalid`);
- assert(Number.isFinite(clip.gain) && clip.gain >= 0 && clip.gain <= 64,
- `AudioProgramPlan clip ${clip.id} gain is invalid`);
- assertAudioLevelAutomation(clip, { startSample: clip.targetStartSample, endSampleExclusive: clip.targetEndSampleExclusive }, item.sampleFrames);
- const mixLength = clip.mixEndSampleExclusive - clip.mixStartSample;
- assert(Number.isSafeInteger(clip.fadeInSamples) && clip.fadeInSamples >= 0 && clip.fadeInSamples <= mixLength
- && Number.isSafeInteger(clip.fadeOutSamples) && clip.fadeOutSamples >= 0 && clip.fadeOutSamples <= mixLength,
- `AudioProgramPlan clip ${clip.id} fade is invalid`);
- }
- assert(item.mix?.normalize === false && item.mix?.limiter === "none",
- "AudioProgramPlan cannot hide normalization or limiting");
-}
-
-export function compileAudioProgramPlan(composition: Composition, timeline: Timeline): AudioProgramPlan {
- assertCompositionIdentity(composition, timeline);
- const frameCount = timelineFrameCount(timeline);
- const clips = composition.tracks
- .filter((track) => track.kind === "audio")
- .flatMap((track) => track.clips.flatMap((clip) => {
- if (clip.artifact.mediaType !== "audio/wav") {
- throw new Error(`Audio clip ${track.id}.${clip.id} must be normalized to canonical WAV before mixing`);
- }
- return clip.sourceTime.pieces.map((piece, pieceIndex) => {
- const targetLength = piece.target.endSampleExclusive - piece.target.startSample;
- const sourceAtStart = exactInteger(piece.sourceAtStart,
- `${track.id}.${clip.id} piece ${pieceIndex} source start`);
- const wrap = piece.wrap;
- return {
- id: `${track.id}:${clip.id}:${String(pieceIndex).padStart(4, "0")}`,
- artifact: {
- kind: "blob" as const,
- resource: clip.artifact.resource,
- size: clip.artifact.size,
- mediaType: clip.artifact.mediaType,
- },
- targetStartSample: clip.target.startSample + piece.target.startSample,
- targetEndSampleExclusive: clip.target.startSample + piece.target.endSampleExclusive,
- sourceSampleFrames: clip.sourceTime.sourceSampleFrames,
- sourceStartSample: wrap?.startSample ?? sourceAtStart,
- sourceEndSampleExclusive: wrap?.endSampleExclusive
- ?? exactSourceEnd(piece.sourceAtStart, piece.rate, targetLength,
- `${track.id}.${clip.id} piece ${pieceIndex} source end`),
- sourceLoop: wrap !== undefined,
- sourcePhaseSample: wrap === undefined ? 0 : sourceAtStart - wrap.startSample,
- playbackRate: piece.rate.numerator / piece.rate.denominator,
- mixStartSample: clip.target.startSample,
- mixEndSampleExclusive: clip.target.endSampleExclusive,
- gain: clip.gain,
- fadeInSamples: clip.fadeInSamples,
- fadeOutSamples: clip.fadeOutSamples,
- ...(clip.gainEnvelope === undefined ? {} : { gainEnvelope: clip.gainEnvelope }),
- ...(clip.audibility === undefined ? {} : { audibility: clip.audibility.flatMap((span) => {
- const startSample = Math.max(span.startSample, clip.target.startSample + piece.target.startSample);
- const endSampleExclusive = Math.min(span.endSampleExclusive, clip.target.startSample + piece.target.endSampleExclusive);
- return endSampleExclusive <= startSample ? [] : [{ startSample, endSampleExclusive }];
- }) }),
- };
- });
- }));
- return sealAudioProgramPlan({
- frameRate: { ...timeline.frameRate },
- frameCount,
- sampleRate: 48_000,
- sampleFrames: timelineFrameSampleBoundary(timeline, frameCount, 48_000),
- clips,
- mix: { normalize: false, limiter: "none" },
- });
-}
diff --git a/packages/media-pipeline/src/component.ts b/packages/media-pipeline/src/component.ts
deleted file mode 100644
index 3f27e73d..00000000
--- a/packages/media-pipeline/src/component.ts
+++ /dev/null
@@ -1,400 +0,0 @@
-import { mediaFrameRangeSamples, verifyMediaFrameRange } from "@hypit/media";
-import { mediaComponent } from "@hypit/media";
-import { plannedNeedInputs } from "@hypit/component-kit";
-import type { ComponentPackage, PlannedNeedFacet } from "@hypit/component-kit";
-import { synchronizedMediaSampleFrames, verifyMediaInspection, verifyMediaStreamSelection, verifyMuxedMedia, verifyRenderedVisual, verifySynchronizedMedia, verifyTimelineAudio } from "@hypit/media";
-import type { MediaInspection, MediaStreamSelection, MuxedMedia, RenderedVisual, SynchronizedMedia, TimelineAudio } from "@hypit/media";
-import { assertClockIdentity } from "@hypit/timeline";
-import type { Clock, Timeline } from "@hypit/timeline";
-import { assertSpeechDurationIdentity } from "@hypit/speech";
-import type { SpeechDuration } from "@hypit/speech";
-import { speechEvidenceSampleBoundary } from "@hypit/speech-evidence";
-import { assertLocalTemporalDomain } from "@hypit/temporal";
-import type { LocalTemporalDomain } from "@hypit/temporal";
-import type { Composition } from "@hypit/composition";
-import type { BlobRef, CanonicalValue, CapabilityRef, ProducerRef, StoredValue } from "@hypit/protocol";
-import { canonicalize } from "@hypit/protocol";
-
-import {
- compileAudioProgramPlan,
- verifyAudioProgramPlan,
-} from "./audio-plan.js";
-import { mediaPipelineCapabilities, mediaPipelineProducers, mediaPipelineTypes } from "./manifest.js";
-import {
- selectMediaStreams,
- verifyMediaSelectionRequest,
-} from "./selection.js";
-import {
- selectAudioStream,
- selectVideoStream,
- bindStillVideoSource,
- planStillVideoSegments,
- sealStillVideoRequest,
- verifyStillVideoLayout,
- verifyAudioExtractionRequest,
- verifyFrameExtractionRequest,
- verifyMediaTransformProgram,
- verifyStillVideoRequest,
-} from "./operations.js";
-import type {
- AudioExtractionRequest,
- ExtractAudioNeed,
- ExtractFrameNeed,
- FrameExtractionRequest,
- InspectMediaNeed,
- MuxMediaNeed,
- MediaSelectionRequest,
- NormalizeMediaNeed,
- ProjectSpeechEvidenceAudioNeed,
- RenderAudioNeed,
- RenderStillVideoNeed,
- StillVideoLayout,
- StillVideoRequest,
- TransformMediaNeed,
-} from "./types.js";
-
-function inline(value: StoredValue, subject: string): CanonicalValue {
- if (value.kind !== "inline") throw new Error(`${subject} must be inline`);
- return value.value;
-}
-
-function blob(value: StoredValue, subject: string): BlobRef {
- if (value.kind !== "blob") throw new Error(`${subject} must be a BlobArtifact`);
- return value;
-}
-
-/** Preserve unresolved graph inputs without pretending a structured value is a file. */
-function plannedMediaNeed(
- producer: ProducerRef,
- port: string,
- capability: CapabilityRef,
- roles: Readonly<Record<string, string>> = {},
- present?: PlannedNeedFacet["present"],
-): PlannedNeedFacet {
- return {
- producer,
- port,
- capability,
- plan({ state, step }) {
- return { constraints: {}, pendingInputs: plannedNeedInputs(state, step, roles) };
- },
- present(specification) {
- if (present !== undefined) return present(specification);
- const references: Record<string, number> = {};
- for (const item of specification.pendingInputs) {
- const role = item.role;
- if (role === undefined) continue;
- references[role] = (references[role] ?? 0) + 1;
- }
- return { fields: {}, references };
- },
- };
-}
-
-const presentAudioRender: NonNullable<PlannedNeedFacet["present"]> = (specification) => {
- const request = specification.constraints as Partial<RenderAudioNeed>;
- if (request.plan === undefined) return { fields: {}, references: {} };
- const { plan, range } = request;
- return { fields: {
- startFrame: [range?.startFrame ?? 0],
- endFrameExclusive: [range?.endFrameExclusive ?? plan.frameCount],
- frameRate: [`${plan.frameRate.numerator}/${plan.frameRate.denominator}`],
- sampleRate: [plan.sampleRate],
- }, references: {} };
-};
-
-export const mediaPipelineComponent = {
- validators: [
- {
- type: mediaPipelineTypes.selectionRequest,
- handler: ({ value }) => {
- verifyMediaSelectionRequest(inline(value, "MediaSelectionRequest"));
- },
- },
- {
- type: mediaPipelineTypes.audioProgramPlan,
- handler: ({ value }) => {
- verifyAudioProgramPlan(inline(value, "AudioProgramPlan"));
- },
- },
- {
- type: mediaPipelineTypes.transformProgram,
- handler: ({ value }) => {
- verifyMediaTransformProgram(inline(value, "MediaTransformProgram"));
- },
- },
- {
- type: mediaPipelineTypes.audioExtractionRequest,
- handler: ({ value }) => {
- verifyAudioExtractionRequest(inline(value, "AudioExtractionRequest"));
- },
- },
- {
- type: mediaPipelineTypes.frameExtractionRequest,
- handler: ({ value }) => {
- verifyFrameExtractionRequest(inline(value, "FrameExtractionRequest"));
- },
- },
- {
- type: mediaPipelineTypes.stillVideoLayout,
- handler: ({ value }) => {
- verifyStillVideoLayout(inline(value, "StillVideoLayout"));
- },
- },
- {
- type: mediaPipelineTypes.stillVideoRequest,
- handler: ({ value }) => {
- verifyStillVideoRequest(inline(value, "StillVideoRequest"));
- },
- },
- ],
- producers: [
- {
- producer: mediaPipelineProducers.inspect,
- handler: ({ inputs }) => {
- const source = blob(inputs.source!.value, "Media inspection source");
- const need: InspectMediaNeed = { source };
- return { outputs: {}, needs: { inspection: canonicalize(need) } };
- },
- },
- {
- producer: mediaPipelineProducers.select,
- handler: ({ inputs }) => {
- const inspection = inline(inputs.inspection!.value, "MediaInspection");
- const request = inline(inputs.request!.value, "MediaSelectionRequest");
- verifyMediaInspection(inspection);
- verifyMediaSelectionRequest(request);
- return {
- outputs: {
- selection: { kind: "inline", value: canonicalize(selectMediaStreams(inspection, request)) },
- },
- needs: {},
- };
- },
- },
- {
- producer: mediaPipelineProducers.normalize,
- handler: ({ inputs }) => {
- const source = blob(inputs.source!.value, "Media normalization source");
- const inspection = inline(inputs.inspection!.value, "MediaInspection");
- const selection = inline(inputs.selection!.value, "MediaStreamSelection");
- const request = inline(inputs.request!.value, "MediaSelectionRequest");
- verifyMediaInspection(inspection);
- verifyMediaStreamSelection(selection);
- verifyMediaSelectionRequest(request);
- const need: NormalizeMediaNeed = {
- source,
- inspection,
- selection,
- frameRate: request.frameRate,
- audio: { sampleRate: 48_000, channels: 2, codec: "pcm_s16le", loudness: "preserve" },
- };
- return { outputs: {}, needs: { media: canonicalize(need) } };
- },
- },
- {
- producer: mediaPipelineProducers.transform,
- handler: ({ inputs }) => {
- const media = inline(inputs.media!.value, "SynchronizedMedia");
- const program = inline(inputs.program!.value, "MediaTransformProgram");
- verifySynchronizedMedia(media);
- verifyMediaTransformProgram(program);
- if (media.visual === undefined) throw new Error("Media transform requires a visual stream");
- const need: TransformMediaNeed = {
- media,
- program,
- };
- return { outputs: {}, needs: { video: canonicalize(need) } };
- },
- },
- {
- producer: mediaPipelineProducers.extractAudio,
- handler: ({ inputs }) => {
- const source = blob(inputs.source!.value, "Audio extraction source");
- const inspection = inline(inputs.inspection!.value, "MediaInspection");
- const request = inline(inputs.request!.value, "AudioExtractionRequest") as unknown as AudioExtractionRequest;
- verifyMediaInspection(inspection);
- verifyAudioExtractionRequest(request);
- const selected = selectAudioStream(inspection, request.audio);
- const need: ExtractAudioNeed = {
- source,
- streamIndex: selected.index,
- output: request.output,
- };
- return { outputs: {}, needs: { audio: canonicalize(need) } };
- },
- },
- {
- producer: mediaPipelineProducers.extractFrame,
- handler: ({ inputs }) => {
- const source = blob(inputs.source!.value, "Frame extraction source");
- const inspection = inline(inputs.inspection!.value, "MediaInspection");
- const request = inline(inputs.request!.value, "FrameExtractionRequest") as unknown as FrameExtractionRequest;
- verifyMediaInspection(inspection);
- verifyFrameExtractionRequest(request);
- const selected = selectVideoStream(inspection, request.video);
- if (request.at.kind === "frame" && request.at.index >= selected.decodedUnitCount) {
- throw new Error(`Frame ${request.at.index} is outside the selected stream (${selected.decodedUnitCount} frames)`);
- }
- const need: ExtractFrameNeed = {
- source,
- streamIndex: selected.index,
- sourceFrameCount: selected.decodedUnitCount,
- at: request.at,
- output: request.output,
- };
- return { outputs: {}, needs: { image: canonicalize(need) } };
- },
- },
- {
- producer: mediaPipelineProducers.planStill,
- handler: ({ inputs }) => {
- const duration = inline(inputs.duration!.value, "SpeechDuration") as unknown as SpeechDuration;
- const clock = inline(inputs.clock!.value, "Clock") as unknown as Clock;
- assertSpeechDurationIdentity(duration);
- assertClockIdentity(clock);
- const layout = inline(inputs.layout!.value, "StillVideoLayout") as unknown as StillVideoLayout;
- verifyStillVideoLayout(layout);
- const frames = Math.round(duration * clock.frameRate.numerator / clock.frameRate.denominator);
- if (!Number.isSafeInteger(frames) || frames < 1) {
- throw new Error("Still video duration does not produce a positive safe frame count");
- }
- const request = sealStillVideoRequest({
- frameRate: clock.frameRate,
- frameCount: frames,
- output: { container: "mp4", codec: "h264", pixelFormat: "yuv420p" },
- segments: planStillVideoSegments(frames, layout.weights),
- });
- return { outputs: { request: { kind: "inline", value: canonicalize(request) } }, needs: {} };
- },
- },
- {
- producer: mediaPipelineProducers.bindStill,
- handler: ({ inputs }) => {
- const request = inline(inputs.request!.value, "StillVideoRequest") as unknown as StillVideoRequest;
- const source = blob(inputs.source!.value, "Still video source");
- const bound = bindStillVideoSource(request, source);
- return { outputs: { request: { kind: "inline", value: canonicalize(bound) } }, needs: {} };
- },
- },
- {
- producer: mediaPipelineProducers.renderStill,
- handler: ({ inputs }) => {
- const request = inline(inputs.request!.value, "StillVideoRequest") as unknown as StillVideoRequest;
- verifyStillVideoRequest(request);
- if (request.segments.some((segment) => segment.source === undefined)) {
- throw new Error("Still video has a segment without a picture");
- }
- const need: RenderStillVideoNeed = { request };
- return { outputs: {}, needs: { video: canonicalize(need) } };
- },
- },
- {
- producer: mediaPipelineProducers.projectSpeechEvidenceAudio,
- handler: ({ inputs }) => {
- const media = inline(inputs.media!.value, "SynchronizedMedia") as unknown as SynchronizedMedia;
- const domain = inline(inputs.domain!.value, "LocalTemporalDomain") as unknown as LocalTemporalDomain;
- verifySynchronizedMedia(media);
- assertLocalTemporalDomain(domain);
- if (domain.frameCount !== media.frameDomain.frameCount
- || domain.frameRate.numerator !== media.frameDomain.frameRate.numerator
- || domain.frameRate.denominator !== media.frameDomain.frameRate.denominator) {
- throw new Error(`Speech evidence domain ${domain.id} does not describe its normalized media`);
- }
- if (media.audio === undefined) throw new Error("Speech evidence requires normalized Take audio");
- const sourceSampleFrames = synchronizedMediaSampleFrames(media);
- const evidenceSampleFrames = speechEvidenceSampleBoundary(sourceSampleFrames);
- if (!Number.isSafeInteger(sourceSampleFrames) || sourceSampleFrames < 1
- || !Number.isSafeInteger(evidenceSampleFrames) || evidenceSampleFrames < 1) {
- throw new Error("Speech evidence audio sample domain is invalid");
- }
- const need: ProjectSpeechEvidenceAudioNeed = {
- domainId: domain.id,
- source: media.audio.artifact,
- sourceSampleFrames,
- evidenceSampleFrames,
- };
- return { outputs: {}, needs: { evidenceAudio: canonicalize(need) } };
- },
- },
- {
- producer: mediaPipelineProducers.planAudio,
- handler: ({ inputs }) => {
- const composition = inline(inputs.composition!.value, "Composition") as unknown as Composition;
- const timeline = inline(inputs.timeline!.value, "Timeline") as unknown as Timeline;
- return {
- outputs: { plan: { kind: "inline", value: canonicalize(compileAudioProgramPlan(composition, timeline)) } },
- needs: {},
- };
- },
- },
- {
- producer: mediaPipelineProducers.renderAudio,
- handler: ({ inputs }) => {
- const plan = inline(inputs.plan!.value, "AudioProgramPlan");
- verifyAudioProgramPlan(plan);
- const need: RenderAudioNeed = { plan };
- return { outputs: {}, needs: { audio: canonicalize(need) } };
- },
- },
- {
- producer: mediaPipelineProducers.renderAudioRange,
- handler: ({ inputs }) => {
- const plan = inline(inputs.plan!.value, "AudioProgramPlan");
- verifyAudioProgramPlan(plan);
- const range = inline(inputs.range!.value, "MediaFrameRange");
- verifyMediaFrameRange(range, plan.frameCount);
- const need: RenderAudioNeed = { plan, range };
- return { outputs: {}, needs: { audio: canonicalize(need) } };
- },
- },
- {
- producer: mediaPipelineProducers.mux,
- handler: ({ inputs }) => {
- const visual = inline(inputs.visual!.value, "RenderedVisual");
- const audio = inline(inputs.audio!.value, "TimelineAudio");
- verifyRenderedVisual(visual);
- verifyTimelineAudio(audio);
- const { sampleFrames } = mediaFrameRangeSamples(
- { startFrame: 0, endFrameExclusive: visual.frameCount }, visual.frameRate,
- );
- if (audio.sampleFrames !== sampleFrames) {
- throw new Error("Rendered visual and TimelineAudio have different presentation durations");
- }
- const need: MuxMediaNeed = { visual, audio };
- return { outputs: {}, needs: { media: canonicalize(need) } };
- },
- },
- {
- producer: mediaPipelineProducers.projectMuxed,
- handler: ({ inputs }) => {
- const media = inline(inputs.media!.value, "MuxedMedia");
- verifyMuxedMedia(media);
- return {
- outputs: { video: media.artifact },
- needs: {},
- };
- },
- },
- ],
- plannedNeeds: [
- plannedMediaNeed(mediaPipelineProducers.inspect, "inspection", mediaPipelineCapabilities.inspect, { source: "media" }),
- plannedMediaNeed(mediaPipelineProducers.normalize, "media", mediaPipelineCapabilities.normalize, { source: "media" }),
- plannedMediaNeed(mediaPipelineProducers.transform, "video", mediaPipelineCapabilities.transform, { media: "video" }),
- plannedMediaNeed(mediaPipelineProducers.extractAudio, "audio", mediaPipelineCapabilities.extractAudio, { source: "audio" }),
- plannedMediaNeed(mediaPipelineProducers.extractFrame, "image", mediaPipelineCapabilities.extractFrame, { source: "video" }),
- plannedMediaNeed(mediaPipelineProducers.renderStill, "video", mediaPipelineCapabilities.renderStill, { request: "image" }),
- plannedMediaNeed(
- mediaPipelineProducers.projectSpeechEvidenceAudio,
- "evidenceAudio",
- mediaPipelineCapabilities.projectSpeechEvidenceAudio,
- { media: "audio" },
- ),
- plannedMediaNeed(mediaPipelineProducers.renderAudio, "audio", mediaPipelineCapabilities.renderAudio, {}, presentAudioRender),
- plannedMediaNeed(mediaPipelineProducers.renderAudioRange, "audio", mediaPipelineCapabilities.renderAudio, {}, presentAudioRender),
- plannedMediaNeed(mediaPipelineProducers.mux, "media", mediaPipelineCapabilities.mux, { visual: "video", audio: "audio" }),
- ],
-} satisfies ComponentPackage;
-
-/** Convenience set: public media validators must accompany the pipeline Producers. */
-export const mediaPipelineComponents = [mediaComponent, mediaPipelineComponent] as const;
diff --git a/packages/media-pipeline/src/fragment.ts b/packages/media-pipeline/src/fragment.ts
deleted file mode 100644
index cd8d7bb2..00000000
--- a/packages/media-pipeline/src/fragment.ts
+++ /dev/null
@@ -1,189 +0,0 @@
-import { mediaProducers, mediaTypes } from "@hypit/media";
-import { temporalProducers, temporalTypes } from "@hypit/temporal";
-import { artifactTypes } from "@hypit/artifact";
-import { timelineTypes } from "@hypit/timeline";
-import { speechTypes } from "@hypit/speech";
-import { sealGraphFragment } from "@hypit/elaborator";
-
-import {
- mediaPipelineProducers,
- mediaPipelineTypes,
-} from "./manifest.js";
-
-const input = (name: string) => ({ kind: "fragment-input" as const, name });
-const operation = (id: string) => ({ kind: "fragment-operation" as const, operation: id });
-
-export const synchronizedMediaFragment = sealGraphFragment({
- inputs: [
- { name: "source", type: artifactTypes.blob },
- { name: "request", type: mediaPipelineTypes.selectionRequest },
- { name: "domain", type: mediaTypes.domainSpec },
- ],
- operations: [
- {
- id: "inspect",
- producer: mediaPipelineProducers.inspect,
- inputs: { source: input("source") },
- result: { kind: "need", name: "inspection" },
- },
- {
- id: "select",
- producer: mediaPipelineProducers.select,
- inputs: { inspection: operation("inspect"), request: input("request") },
- result: { kind: "output", name: "selection" },
- },
- {
- id: "normalize",
- producer: mediaPipelineProducers.normalize,
- inputs: {
- source: input("source"),
- inspection: operation("inspect"),
- selection: operation("select"),
- request: input("request"),
- },
- result: { kind: "need", name: "media" },
- },
- {
- id: "domain",
- producer: mediaProducers.localDomain,
- inputs: { media: operation("normalize"), spec: input("domain") },
- result: { kind: "output", name: "domain" },
- },
- {
- id: "extent",
- producer: temporalProducers.extentFromDomain,
- inputs: { domain: operation("domain") },
- result: { kind: "output", name: "extent" },
- },
- ],
- exports: [{
- name: "media",
- type: mediaTypes.synchronized,
- root: operation("normalize"),
- }, {
- name: "domain",
- type: temporalTypes.localDomain,
- root: operation("domain"),
- }, {
- name: "extent",
- type: temporalTypes.extent,
- root: operation("extent"),
- }],
-});
-
-export const transformMediaFragment = sealGraphFragment({
- inputs: [
- { name: "media", type: mediaTypes.synchronized },
- { name: "program", type: mediaPipelineTypes.transformProgram },
- ],
- operations: [
- {
- id: "transform",
- producer: mediaPipelineProducers.transform,
- inputs: { media: input("media"), program: input("program") },
- result: { kind: "need", name: "video" },
- },
- ],
- exports: [{
- name: "video",
- type: artifactTypes.blob,
- root: operation("transform"),
- }],
-});
-
-export const extractAudioFragment = sealGraphFragment({
- inputs: [
- { name: "source", type: artifactTypes.blob },
- { name: "request", type: mediaPipelineTypes.audioExtractionRequest },
- ],
- operations: [
- {
- id: "inspect",
- producer: mediaPipelineProducers.inspect,
- inputs: { source: input("source") },
- result: { kind: "need", name: "inspection" },
- },
- {
- id: "extract",
- producer: mediaPipelineProducers.extractAudio,
- inputs: { source: input("source"), inspection: operation("inspect"), request: input("request") },
- result: { kind: "need", name: "audio" },
- },
- ],
- exports: [{
- name: "audio",
- type: artifactTypes.blob,
- root: operation("extract"),
- }],
-});
-
-export const extractFrameFragment = sealGraphFragment({
- inputs: [
- { name: "source", type: artifactTypes.blob },
- { name: "request", type: mediaPipelineTypes.frameExtractionRequest },
- ],
- operations: [
- {
- id: "inspect",
- producer: mediaPipelineProducers.inspect,
- inputs: { source: input("source") },
- result: { kind: "need", name: "inspection" },
- },
- {
- id: "extract",
- producer: mediaPipelineProducers.extractFrame,
- inputs: { source: input("source"), inspection: operation("inspect"), request: input("request") },
- result: { kind: "need", name: "image" },
- },
- ],
- exports: [{
- name: "image",
- type: artifactTypes.blob,
- root: operation("extract"),
- }],
-});
-
-/**
- * A still video over `count` pictures: plan the frame split, bind each picture to its segment in
- * authored order, render once. The shape depends only on the count, so two elements with the same
- * number of pictures share one Fragment identity.
- */
-export function createStillVideoFragment(count: number) {
- if (!Number.isSafeInteger(count) || count < 1) throw new Error("A still video needs at least one picture");
- const sources = Array.from({ length: count }, (_, index) => `source-${index}`);
- return sealGraphFragment({
- inputs: [
- { name: "duration", type: speechTypes.duration },
- { name: "clock", type: timelineTypes.clock },
- { name: "layout", type: mediaPipelineTypes.stillVideoLayout },
- ...sources.map((name) => ({ name, type: artifactTypes.blob })),
- ],
- operations: [
- {
- id: "plan",
- producer: mediaPipelineProducers.planStill,
- inputs: { duration: input("duration"), clock: input("clock"), layout: input("layout") },
- result: { kind: "output", name: "request" },
- },
- ...sources.map((name, index) => ({
- id: `bind-${index}`,
- producer: mediaPipelineProducers.bindStill,
- inputs: { request: operation(index === 0 ? "plan" : `bind-${index - 1}`), source: input(name) },
- result: { kind: "output" as const, name: "request" },
- })),
- {
- id: "render",
- producer: mediaPipelineProducers.renderStill,
- inputs: { request: operation(`bind-${count - 1}`) },
- result: { kind: "need", name: "video" },
- },
- ],
- exports: [{
- name: "video",
- type: artifactTypes.blob,
- root: operation("render"),
- }],
- });
-}
-
-export const stillVideoFragment = createStillVideoFragment(1);
diff --git a/packages/media-pipeline/src/index.ts b/packages/media-pipeline/src/index.ts
deleted file mode 100644
index d172dd42..00000000
--- a/packages/media-pipeline/src/index.ts
+++ /dev/null
@@ -1,46 +0,0 @@
-export {
- mediaPipelineComponent,
- mediaPipelineComponents,
-} from "./component.js";
-export {
- extractAudioFragment,
- extractFrameFragment,
- synchronizedMediaFragment,
- stillVideoFragment,
- createStillVideoFragment,
- transformMediaFragment,
-} from "./fragment.js";
-export {
- compileAudioProgramPlan,
- sealAudioProgramPlan,
- verifyAudioProgramPlan,
-} from "./audio-plan.js";
-export { mediaPipelineCapabilities, mediaPipelineManifest, mediaPipelineMarkupSurfaces, mediaPipelineModuleRef, mediaPipelineProducers, mediaPipelineTypes, audioProgramPlanSchema, mediaSelectionRequestSchema, audioExtractionRequestSchema, frameExtractionRequestSchema, stillVideoRequestSchema, stillVideoLayoutSchema, mediaTransformProgramSchema } from "./manifest.js";
-export {
- sealMediaSelectionRequest,
- selectMediaStreams,
- verifyMediaSelectionRequest,
-} from "./selection.js";
-export { decodeSynchronizedMediaSurface, decodeStillVideoSurface } from "./surface.js";
-export {
- decodeExtractAudioSurface,
- decodeExtractFrameSurface,
- decodeTransformMediaSurface,
-} from "./surface.js";
-export {
- sealAudioExtractionRequest,
- sealFrameExtractionRequest,
- sealMediaTransformProgram,
- sealStillVideoLayout,
- sealStillVideoRequest,
- planStillVideoSegments,
- bindStillVideoSource,
- selectAudioStream,
- selectVideoStream,
- verifyAudioExtractionRequest,
- verifyFrameExtractionRequest,
- verifyMediaTransformProgram,
- verifyStillVideoLayout,
- verifyStillVideoRequest,
-} from "./operations.js";
-export type * from "./types.js";
diff --git a/packages/media-pipeline/src/manifest.ts b/packages/media-pipeline/src/manifest.ts
deleted file mode 100644
index 54a807b7..00000000
--- a/packages/media-pipeline/src/manifest.ts
+++ /dev/null
@@ -1,659 +0,0 @@
-import { artifactDependency } from "@hypit/artifact";
-import { mediaDependency, mediaTypes } from "@hypit/media";
-import { timelineDependency, timelineTypes } from "@hypit/timeline";
-import { svsModuleRef, svsRecipeType } from "@hypit/svs";
-import { speechDependency, speechTypes } from "@hypit/speech";
-import { speechEvidenceDependency, speechEvidenceTypes } from "@hypit/speech-evidence";
-import { compositionDependency, compositionTypes, audioSampleSpanSchema, audioGainEnvelopeSchema } from "@hypit/composition";
-import { temporalDependency, temporalTypes } from "@hypit/temporal";
-import { artifactTypes } from "@hypit/artifact";
-import type {
- CapabilityRef,
- ModuleManifest,
- ProducerRef,
- TypeRef,
- ValueSchema,
-} from "@hypit/protocol";
-
-export const mediaPipelineModuleRef = { name: "@hypit/media-pipeline", version: "1" } as const;
-export const mediaPipelineTypes = {
- selectionRequest: { module: mediaPipelineModuleRef, name: "MediaSelectionRequest" },
- audioProgramPlan: { module: mediaPipelineModuleRef, name: "AudioProgramPlan" },
- transformProgram: { module: mediaPipelineModuleRef, name: "MediaTransformProgram" },
- audioExtractionRequest: { module: mediaPipelineModuleRef, name: "AudioExtractionRequest" },
- frameExtractionRequest: { module: mediaPipelineModuleRef, name: "FrameExtractionRequest" },
- stillVideoRequest: { module: mediaPipelineModuleRef, name: "StillVideoRequest" },
- stillVideoLayout: { module: mediaPipelineModuleRef, name: "StillVideoLayout" },
-} satisfies Record<string, TypeRef>;
-export const mediaPipelineCapabilities = {
- inspect: { module: mediaPipelineModuleRef, name: "inspect-media" },
- normalize: { module: mediaPipelineModuleRef, name: "normalize-media" },
- transform: { module: mediaPipelineModuleRef, name: "transform-media" },
- extractAudio: { module: mediaPipelineModuleRef, name: "extract-media-audio" },
- extractFrame: { module: mediaPipelineModuleRef, name: "extract-media-frame" },
- renderStill: { module: mediaPipelineModuleRef, name: "render-still-video" },
- projectSpeechEvidenceAudio: { module: mediaPipelineModuleRef, name: "project-speech-evidence-audio" },
- renderAudio: { module: mediaPipelineModuleRef, name: "render-timeline-audio" },
- mux: { module: mediaPipelineModuleRef, name: "mux-program-media" },
-} satisfies Record<string, CapabilityRef>;
-export const mediaPipelineProducers = {
- inspect: { module: mediaPipelineModuleRef, name: "request-media-inspection" },
- select: { module: mediaPipelineModuleRef, name: "select-media-streams" },
- normalize: { module: mediaPipelineModuleRef, name: "request-media-normalization" },
- transform: { module: mediaPipelineModuleRef, name: "request-media-transform" },
- extractAudio: { module: mediaPipelineModuleRef, name: "request-audio-extraction" },
- extractFrame: { module: mediaPipelineModuleRef, name: "request-frame-extraction" },
- planStill: { module: mediaPipelineModuleRef, name: "plan-still-video" },
- renderStill: { module: mediaPipelineModuleRef, name: "request-still-video" },
- bindStill: { module: mediaPipelineModuleRef, name: "bind-still-video-source" },
- projectSpeechEvidenceAudio: { module: mediaPipelineModuleRef, name: "request-speech-evidence-audio" },
- planAudio: { module: mediaPipelineModuleRef, name: "compile-audio-program" },
- renderAudio: { module: mediaPipelineModuleRef, name: "request-audio-render" },
- renderAudioRange: { module: mediaPipelineModuleRef, name: "request-audio-range" },
- mux: { module: mediaPipelineModuleRef, name: "request-media-mux" },
- projectMuxed: { module: mediaPipelineModuleRef, name: "project-muxed-media" },
-} satisfies Record<string, ProducerRef>;
-
-const integer = { kind: "number", integer: true, minimum: 0 } as const;
-const mode = (name: string): ValueSchema => ({
- kind: "object",
- fields: { mode: { schema: { kind: "literal", value: name } } },
-});
-const streamMode: ValueSchema = {
- kind: "object",
- fields: {
- mode: { schema: { kind: "literal", value: "stream-index" } },
- streamIndex: { schema: integer },
- },
-};
-export const mediaSelectionRequestSchema: ValueSchema = {
- kind: "object",
- fields: {
- video: { schema: { kind: "oneOf", variants: [mode("primary-moving"), streamMode, mode("none")] } },
- audio: { schema: { kind: "oneOf", variants: [mode("default"), streamMode, mode("none")] } },
- spanAuthority: { schema: { kind: "string", enum: ["video", "audio"] } },
- frameRate: { schema: {
- kind: "object",
- fields: {
- numerator: { schema: { kind: "number", integer: true, minimum: 1 } },
- denominator: { schema: { kind: "number", integer: true, minimum: 1 } },
- },
- } },
- },
-};
-
-const videoSelectorSchema: ValueSchema = {
- kind: "oneOf",
- variants: [mode("primary-moving"), streamMode],
-};
-const audioSelectorSchema: ValueSchema = {
- kind: "oneOf",
- variants: [mode("default"), streamMode],
-};
-const nonNegativeNumber = { kind: "number", minimum: 0 } as const;
-const trimOperationSchema: ValueSchema = {
- kind: "object",
- fields: {
- kind: { schema: { kind: "literal", value: "trim" } },
- startSec: { schema: nonNegativeNumber, optional: true },
- endSec: { schema: nonNegativeNumber, optional: true },
- tailSec: { schema: nonNegativeNumber, optional: true },
- },
-};
-const retimeOperationSchema: ValueSchema = {
- kind: "object",
- fields: {
- kind: { schema: { kind: "literal", value: "retime" } },
- rate: { schema: { kind: "number", minimum: 0.000001, maximum: 100 } },
- },
-};
-export const mediaTransformProgramSchema: ValueSchema = {
- kind: "object",
- fields: {
- operations: { schema: { kind: "array", minItems: 1, items: {
- kind: "oneOf", variants: [trimOperationSchema, retimeOperationSchema],
- } } },
- },
-};
-export const audioExtractionRequestSchema: ValueSchema = {
- kind: "object",
- fields: {
- audio: { schema: audioSelectorSchema },
- output: { schema: {
- kind: "object",
- fields: {
- container: { schema: { kind: "literal", value: "wav" } },
- codec: { schema: { kind: "literal", value: "pcm_s16le" } },
- sampleRate: { schema: { kind: "literal", value: 48_000 } },
- channels: { schema: { kind: "literal", value: 2 } },
- },
- } },
- },
-};
-export const frameExtractionRequestSchema: ValueSchema = {
- kind: "object",
- fields: {
- video: { schema: videoSelectorSchema },
- at: { schema: { kind: "oneOf", variants: [
- { kind: "object", fields: { kind: { schema: { kind: "literal", value: "first" } } } },
- { kind: "object", fields: { kind: { schema: { kind: "literal", value: "last" } } } },
- { kind: "object", fields: {
- kind: { schema: { kind: "literal", value: "frame" } },
- index: { schema: integer },
- } },
- { kind: "object", fields: {
- kind: { schema: { kind: "literal", value: "time" } },
- seconds: { schema: nonNegativeNumber },
- } },
- ] } },
- output: { schema: {
- kind: "object",
- fields: { format: { schema: { kind: "literal", value: "png" } } },
- } },
- },
-};
-
-export const stillVideoRequestSchema: ValueSchema = {
- kind: "object",
- fields: {
- frameRate: { schema: {
- kind: "object",
- fields: {
- numerator: { schema: { kind: "number", integer: true, minimum: 1 } },
- denominator: { schema: { kind: "number", integer: true, minimum: 1 } },
- },
- } },
- frameCount: { schema: { kind: "number", integer: true, minimum: 1 } },
- output: { schema: {
- kind: "object",
- fields: {
- container: { schema: { kind: "literal", value: "mp4" } },
- codec: { schema: { kind: "literal", value: "h264" } },
- pixelFormat: { schema: { kind: "literal", value: "yuv420p" } },
- },
- } },
- segments: { schema: { kind: "array", items: {
- kind: "object",
- fields: {
- startFrame: { schema: { kind: "number", integer: true, minimum: 0 } },
- endFrameExclusive: { schema: { kind: "number", integer: true, minimum: 1 } },
- source: { optional: true, schema: {
- kind: "object",
- fields: {
- kind: { schema: { kind: "literal", value: "blob" } },
- resource: { schema: { kind: "string", minLength: 5, maxLength: 256 } },
- size: { schema: { kind: "number", integer: true, minimum: 0 } },
- mediaType: { schema: { kind: "string", minLength: 6 } },
- },
- } },
- },
- } } },
- },
-};
-
-export const stillVideoLayoutSchema: ValueSchema = {
- kind: "object",
- fields: {
- weights: { schema: { kind: "array", items: { kind: "number", minimum: 0 } } },
- },
-};
-
-const blobRefSchema: ValueSchema = {
- kind: "object",
- fields: {
- kind: { schema: { kind: "literal", value: "blob" } },
- resource: { schema: { kind: "string", minLength: 5, maxLength: 256 } },
- size: { schema: { kind: "number", integer: true, minimum: 0 } },
- mediaType: { schema: { kind: "literal", value: "audio/wav" } },
- },
-};
-
-export const audioProgramPlanSchema: ValueSchema = {
- kind: "object",
- fields: {
- frameRate: { schema: {
- kind: "object",
- fields: {
- numerator: { schema: { kind: "number", integer: true, minimum: 1 } },
- denominator: { schema: { kind: "number", integer: true, minimum: 1 } },
- },
- } },
- frameCount: { schema: { kind: "number", integer: true, minimum: 1 } },
- sampleRate: { schema: { kind: "literal", value: 48_000 } },
- sampleFrames: { schema: { kind: "number", integer: true, minimum: 1 } },
- clips: { schema: { kind: "array", items: {
- kind: "object",
- fields: {
- id: { schema: { kind: "string", minLength: 1 } },
- artifact: { schema: blobRefSchema },
- targetStartSample: { schema: integer },
- targetEndSampleExclusive: { schema: { kind: "number", integer: true, minimum: 1 } },
- sourceSampleFrames: { schema: { kind: "number", integer: true, minimum: 1 } },
- sourceStartSample: { schema: integer },
- sourceEndSampleExclusive: { schema: { kind: "number", integer: true, minimum: 1 } },
- sourceLoop: { schema: { kind: "boolean" } },
- sourcePhaseSample: { schema: integer },
- playbackRate: { schema: { kind: "number" } },
- mixStartSample: { schema: integer },
- mixEndSampleExclusive: { schema: { kind: "number", integer: true, minimum: 1 } },
- gain: { schema: { kind: "number", minimum: 0, maximum: 64 } },
- fadeInSamples: { schema: integer },
- fadeOutSamples: { schema: integer },
- gainEnvelope: { schema: audioGainEnvelopeSchema, optional: true },
- audibility: { schema: { kind: "array", items: audioSampleSpanSchema }, optional: true },
- },
- } } },
- mix: { schema: {
- kind: "object",
- fields: {
- normalize: { schema: { kind: "literal", value: false } },
- limiter: { schema: { kind: "literal", value: "none" } },
- },
- } },
- },
-};
-
-export const mediaPipelineMarkupSurfaces = [
- {
- name: "synchronized-media", tag: "Normalize", mode: "structured",
- outputs: [mediaPipelineTypes.selectionRequest, mediaTypes.domainSpec, mediaTypes.synchronized,
- temporalTypes.localDomain, temporalTypes.extent],
- vocabulary: {
- summary:
- "Inspects one BlobArtifact, selects its video and audio streams and normalizes them into SynchronizedMedia on one frame domain.",
- attributes: [
- { name: "id", kind: "identifier", required: true,
- summary: "Names the selection Record and the normalized media this element publishes." },
- { name: "source", kind: "reference", required: true,
- accepts: [artifactTypes.blob],
- summary: "Selects the media Artifact this element inspects and normalizes." },
- { name: "recipe", kind: "reference", required: false, accepts: [svsRecipeType],
- summary: "Selects a Recipe containing video, audio and span-authority stream policy." },
- { name: "video", kind: "literal", required: false,
- summary: "Decides which moving-image stream is carried: `primary-moving`, `none`, or `stream:<index>`." },
- { name: "audio", kind: "literal", required: false,
- summary: "Decides which audio stream is carried: `default`, `none`, or `stream:<index>`." },
- { name: "span-authority", kind: "literal", required: false,
- values: ["video", "audio"],
- summary: "Decides which selected stream defines the extent the other is trimmed or padded to." },
- { name: "clock", kind: "reference", required: true, accepts: [timelineTypes.clock],
- summary: "Selects the authored frame clock shared with the programme." },
- ],
- ports: [
- { name: "media", type: mediaTypes.synchronized,
- summary: "The normalized SynchronizedMedia, addressed as `<id>.media`." },
- { name: "domain", type: temporalTypes.localDomain,
- summary: "Its source-local frame domain, addressed as `<id>.domain`." },
- { name: "extent", type: temporalTypes.extent,
- summary: "Its unpositioned normalized length, addressed as `<id>.extent`." },
- ],
- example: `<pipeline:Normalize id="music-media" source={music}
- recipe={recipes.media.audio} clock={clock}/>`,
- notes: [
- "Write exactly one of recipe or the direct video/audio/span-authority attributes. Clock is always an explicit reference.",
- "`primary-moving` excludes attached-picture streams, prefers one declared default and fails closed on an ambiguous container; `stream:<index>` is for a container the author genuinely knows.",
- "Selecting embedded audio is a media fact only and makes no speaker or alignment claim.",
- ],
- },
- },
- {
- name: "still-video", tag: "StillVideo", mode: "structured",
- outputs: [speechTypes.duration, mediaPipelineTypes.stillVideoLayout, mediaPipelineTypes.stillVideoRequest, artifactTypes.blob],
- vocabulary: {
- summary: "Spreads one or more authored images over an explicit duration as an ordinary video-only MP4 Blob on a frame clock.",
- attributes: [
- { name: "id", kind: "identifier", required: true,
- summary: "Names the still-video operation and the MP4 Artifact it publishes." },
- { name: "source", kind: "reference", required: false, accepts: [artifactTypes.blob],
- summary: "Selects the one authored image held for the full video; write Still children instead for several images." },
- { name: "duration", kind: "literal", required: true,
- summary: "Sets the video's length in seconds, such as 6 or 2.5s; choose it from the visual passage this held image is meant to carry." },
- { name: "clock", kind: "reference", required: true, accepts: [timelineTypes.clock],
- summary: "Selects the frame clock used by the generated MP4." },
- ],
- children: [
- { tag: "Still", cardinality: "many",
- summary: "One image in authored order; the duration is divided among the Still children by weight, equally unless weights say otherwise.",
- attributes: [
- { name: "source", kind: "reference", required: true, accepts: [artifactTypes.blob],
- summary: "Selects the authored image whose first decoded frame is held for this share." },
- { name: "weight", kind: "literal", required: false,
- summary: "Sets this image's share of the duration relative to its siblings, such as 2; every Still weighs 1 unless written." },
- ] },
- ],
- ports: [{ name: "video", type: artifactTypes.blob,
- summary: "The ordinary video-only MP4 Artifact, addressed as `<id>.video`." }],
- example: `<media:StillVideo id="kitchen-stills" duration="6" clock={clock}>
- <media:Still source={counter}/>
- <media:Still source={basil} weight="2"/>
- <media:Still source={board}/>
-</media:StillVideo>`,
- notes: [
- "Write exactly one of source or Still children. Frames are whole: each image gets the floor of its share and the leftover frames go to the largest remainders, so the split is deterministic and every image holds at least one frame.",
- "Images of different sizes are fitted into the first image's frame, letterboxed on black.",
- "The result is a normal video Blob, not SynchronizedMedia or semantic evidence.",
- "Use Normalize afterward exactly as for generated or imported moving video.",
- "Encoding is a render-still-video Need fulfilled by the selected media Provider; this Surface never invokes FFmpeg itself.",
- ],
- },
- },
- {
- name: "transform-media", tag: "Transform", mode: "structured",
- outputs: [mediaPipelineTypes.transformProgram, artifactTypes.blob],
- vocabulary: {
- summary:
- "Runs an ordered trim and retime program over one already normalized SynchronizedMedia value.",
- attributes: [
- { name: "id", kind: "identifier", required: true,
- summary: "Names the transform program Record and the transformed video this element publishes." },
- { name: "source", kind: "reference", required: true,
- accepts: [mediaTypes.synchronized],
- summary: "Selects the prepared SynchronizedMedia this element transforms." },
- ],
- children: [
- { tag: "Trim", cardinality: "many",
- summary: "Removes time from the head or the tail, taking at least one of `start`, `end` or `tail` in seconds.",
- attributes: [
- { name: "start", kind: "literal", required: false,
- summary: "Decides where the kept span begins, as seconds from the current start, such as `0.25s` or `2`." },
- { name: "end", kind: "literal", required: false,
- summary: "Decides where the kept span ends, as positive seconds from the current start." },
- { name: "tail", kind: "literal", required: false,
- summary: "Decides how many seconds are removed from the current end." },
- ] },
- { tag: "Retime", cardinality: "many",
- summary: "Changes tempo by `rate` in the range (0, 100] while preserving pitch.",
- attributes: [
- { name: "rate", kind: "literal", required: true,
- summary: "Decides the playback speed multiplier, above `0` and at most `100`." },
- ] },
- ],
- ports: [
- { name: "video", type: artifactTypes.blob,
- summary: "The transformed media Artifact, addressed as `<id>.video`." },
- ],
- example: `<media:Transform id="prepared" source={shot-media.media}>
- <media:Trim tail="0.25s"/>
- <media:Retime rate="1.05"/>
-</media:Transform>`,
- notes: [
- "At least one `Trim` or `Retime` child is required, and children run in the order they are written.",
- "`Trim` cannot combine `end` and `tail`, and both children are written empty.",
- "Normalization and stream selection are explicit upstream operations rather than hidden Transform policy.",
- ],
- },
- },
- {
- name: "extract-audio", tag: "ExtractAudio", mode: "structured",
- outputs: [mediaPipelineTypes.audioExtractionRequest, artifactTypes.blob],
- vocabulary: {
- summary:
- "Extracts one audio stream from a BlobArtifact as a deterministic 48 kHz stereo PCM WAV Artifact.",
- attributes: [
- { name: "id", kind: "identifier", required: true,
- summary: "Names the extraction request Record and the extracted audio this element publishes." },
- { name: "source", kind: "reference", required: true,
- accepts: [artifactTypes.blob],
- summary: "Selects the media Artifact this element extracts audio from." },
- { name: "audio", kind: "literal", required: true,
- summary: "Decides which audio stream is extracted: `default` or `stream:<index>`." },
- ],
- ports: [
- { name: "audio", type: artifactTypes.blob,
- summary: "The extracted WAV Artifact, addressed as `<id>.audio`." },
- ],
- example: '<media:ExtractAudio id="voice-reference" source={prepared.video} audio="default"/>',
- notes: [
- "The element accepts no children and no text content, and the output container, codec, sample rate and channel count are fixed.",
- "The result makes no speaker or alignment claim, so it can feed a model reference port directly.",
- ],
- },
- },
- {
- name: "extract-frame", tag: "ExtractFrame", mode: "structured",
- outputs: [mediaPipelineTypes.frameExtractionRequest, artifactTypes.blob],
- vocabulary: {
- summary: "Extracts one still frame from a BlobArtifact as a PNG Artifact.",
- attributes: [
- { name: "id", kind: "identifier", required: true,
- summary: "Names the extraction request Record and the extracted image this element publishes." },
- { name: "source", kind: "reference", required: true,
- accepts: [artifactTypes.blob],
- summary: "Selects the media Artifact this element extracts a frame from." },
- { name: "video", kind: "literal", required: true,
- summary: "Decides which moving-image stream the frame is taken from: `primary-moving` or `stream:<index>`." },
- { name: "at", kind: "literal", required: true,
- summary: "Decides which frame is taken: `first`, `last`, `frame:<index>` or `time:<seconds>`." },
- ],
- ports: [
- { name: "image", type: artifactTypes.blob,
- summary: "The extracted PNG Artifact, addressed as `<id>.image`." },
- ],
- example: '<media:ExtractFrame id="continuity" source={prepared.video} video="primary-moving" at="last"/>',
- notes: [
- "The element accepts no children and no text content, and the output format is fixed to PNG.",
- "`time:<seconds>` is written as a non-negative number with an optional `s`, such as `time:0.25s`.",
- ],
- },
- },
- ] as const;
-
-
-export const mediaPipelineManifest: ModuleManifest = {
- format: "hypit.module@1",
- name: mediaPipelineModuleRef.name,
- version: mediaPipelineModuleRef.version,
- dependencies: [
- artifactDependency,
- mediaDependency,
- speechDependency,
- speechEvidenceDependency,
- timelineDependency,
- compositionDependency,
- temporalDependency,
- { module: svsModuleRef },
- ],
- types: [
- {
- name: mediaPipelineTypes.selectionRequest.name,
- },
- {
- name: mediaPipelineTypes.audioProgramPlan.name,
- },
- {
- name: mediaPipelineTypes.transformProgram.name,
- },
- {
- name: mediaPipelineTypes.audioExtractionRequest.name,
- },
- {
- name: mediaPipelineTypes.frameExtractionRequest.name,
- },
- {
- name: mediaPipelineTypes.stillVideoRequest.name,
- },
- {
- name: mediaPipelineTypes.stillVideoLayout.name,
- },
- ],
- capabilities: [
- { name: mediaPipelineCapabilities.inspect.name, returns: mediaTypes.inspection },
- { name: mediaPipelineCapabilities.normalize.name, returns: mediaTypes.synchronized },
- { name: mediaPipelineCapabilities.transform.name, returns: artifactTypes.blob },
- { name: mediaPipelineCapabilities.extractAudio.name, returns: artifactTypes.blob },
- { name: mediaPipelineCapabilities.extractFrame.name, returns: artifactTypes.blob },
- { name: mediaPipelineCapabilities.renderStill.name, returns: artifactTypes.blob },
- { name: mediaPipelineCapabilities.projectSpeechEvidenceAudio.name, returns: speechEvidenceTypes.audio },
- { name: mediaPipelineCapabilities.renderAudio.name, returns: mediaTypes.timelineAudio },
- { name: mediaPipelineCapabilities.mux.name, returns: mediaTypes.muxed },
- ],
- producers: [
- {
- name: mediaPipelineProducers.inspect.name,
- inputs: [{ name: "source", type: artifactTypes.blob }],
- outputs: [],
- needs: [{
- name: "inspection",
- capability: mediaPipelineCapabilities.inspect,
- returns: mediaTypes.inspection,
- }],
- },
- {
- name: mediaPipelineProducers.select.name,
- inputs: [
- { name: "inspection", type: mediaTypes.inspection },
- { name: "request", type: mediaPipelineTypes.selectionRequest },
- ],
- outputs: [{
- name: "selection",
- type: mediaTypes.streamSelection,
- }],
- needs: [],
- },
- {
- name: mediaPipelineProducers.normalize.name,
- inputs: [
- { name: "source", type: artifactTypes.blob },
- { name: "inspection", type: mediaTypes.inspection },
- { name: "selection", type: mediaTypes.streamSelection },
- { name: "request", type: mediaPipelineTypes.selectionRequest },
- ],
- outputs: [],
- needs: [{
- name: "media",
- capability: mediaPipelineCapabilities.normalize,
- returns: mediaTypes.synchronized,
- }],
- },
- {
- name: mediaPipelineProducers.transform.name,
- inputs: [
- { name: "media", type: mediaTypes.synchronized },
- { name: "program", type: mediaPipelineTypes.transformProgram },
- ],
- outputs: [],
- needs: [{
- name: "video",
- capability: mediaPipelineCapabilities.transform,
- returns: artifactTypes.blob,
- }],
- },
- {
- name: mediaPipelineProducers.extractAudio.name,
- inputs: [
- { name: "source", type: artifactTypes.blob },
- { name: "inspection", type: mediaTypes.inspection },
- { name: "request", type: mediaPipelineTypes.audioExtractionRequest },
- ],
- outputs: [],
- needs: [{
- name: "audio",
- capability: mediaPipelineCapabilities.extractAudio,
- returns: artifactTypes.blob,
- }],
- },
- {
- name: mediaPipelineProducers.extractFrame.name,
- inputs: [
- { name: "source", type: artifactTypes.blob },
- { name: "inspection", type: mediaTypes.inspection },
- { name: "request", type: mediaPipelineTypes.frameExtractionRequest },
- ],
- outputs: [],
- needs: [{
- name: "image",
- capability: mediaPipelineCapabilities.extractFrame,
- returns: artifactTypes.blob,
- }],
- },
- {
- name: mediaPipelineProducers.planStill.name,
- inputs: [
- { name: "duration", type: speechTypes.duration },
- { name: "clock", type: timelineTypes.clock },
- { name: "layout", type: mediaPipelineTypes.stillVideoLayout },
- ],
- outputs: [{ name: "request", type: mediaPipelineTypes.stillVideoRequest }],
- needs: [],
- },
- {
- name: mediaPipelineProducers.bindStill.name,
- inputs: [
- { name: "request", type: mediaPipelineTypes.stillVideoRequest },
- { name: "source", type: artifactTypes.blob },
- ],
- outputs: [{ name: "request", type: mediaPipelineTypes.stillVideoRequest }],
- needs: [],
- },
- {
- name: mediaPipelineProducers.renderStill.name,
- inputs: [
- { name: "request", type: mediaPipelineTypes.stillVideoRequest },
- ],
- outputs: [],
- needs: [{
- name: "video",
- capability: mediaPipelineCapabilities.renderStill,
- returns: artifactTypes.blob,
- }],
- },
- {
- name: mediaPipelineProducers.projectSpeechEvidenceAudio.name,
- inputs: [{ name: "media", type: mediaTypes.synchronized }, { name: "domain", type: temporalTypes.localDomain }],
- outputs: [],
- needs: [{
- name: "evidenceAudio",
- capability: mediaPipelineCapabilities.projectSpeechEvidenceAudio,
- returns: speechEvidenceTypes.audio,
- }],
- },
- {
- name: mediaPipelineProducers.planAudio.name,
- inputs: [
- { name: "composition", type: compositionTypes.composition },
- { name: "timeline", type: timelineTypes.timeline },
- ],
- outputs: [{ name: "plan", type: mediaPipelineTypes.audioProgramPlan }],
- needs: [],
- },
- {
- name: mediaPipelineProducers.renderAudio.name,
- inputs: [{ name: "plan", type: mediaPipelineTypes.audioProgramPlan }],
- outputs: [],
- needs: [{
- name: "audio",
- capability: mediaPipelineCapabilities.renderAudio,
- returns: mediaTypes.timelineAudio,
- }],
- },
- {
- name: mediaPipelineProducers.renderAudioRange.name,
- inputs: [{ name: "plan", type: mediaPipelineTypes.audioProgramPlan }, { name: "range", type: mediaTypes.frameRange }],
- outputs: [],
- needs: [{
- name: "audio",
- capability: mediaPipelineCapabilities.renderAudio,
- returns: mediaTypes.timelineAudio,
- }],
- },
- {
- name: mediaPipelineProducers.mux.name,
- inputs: [
- { name: "visual", type: mediaTypes.renderedVisual },
- { name: "audio", type: mediaTypes.timelineAudio },
- ],
- outputs: [],
- needs: [{
- name: "media",
- capability: mediaPipelineCapabilities.mux,
- returns: mediaTypes.muxed,
- }],
- },
- {
- name: mediaPipelineProducers.projectMuxed.name,
- inputs: [{ name: "media", type: mediaTypes.muxed }],
- outputs: [{ name: "video", type: artifactTypes.blob }],
- needs: [],
- },
- ],
-};
diff --git a/packages/media-pipeline/src/operations.ts b/packages/media-pipeline/src/operations.ts
deleted file mode 100644
index 91b0080a..00000000
--- a/packages/media-pipeline/src/operations.ts
+++ /dev/null
@@ -1,247 +0,0 @@
-import { verifyMediaInspection } from "@hypit/media";
-import type { MediaAudioStream, MediaInspection, MediaVideoStream } from "@hypit/media";
-import { canonicalize } from "@hypit/protocol";
-import type { BlobRef } from "@hypit/protocol";
-
-import type {
- AudioExtractionRequest,
- FrameExtractionRequest,
- MediaAudioSelector,
- MediaTransformProgram,
- MediaVideoSelector,
- StillVideoLayout,
- StillVideoRequest,
- StillVideoSegment,
-} from "./types.js";
-
-function assert(condition: unknown, message: string): asserts condition {
- if (!condition) throw new Error(message);
-}
-
-function finiteNonNegative(value: unknown, subject: string): number {
- assert(typeof value === "number" && Number.isFinite(value) && value >= 0,
- `${subject} must be a finite non-negative number`);
- return value;
-}
-
-function streamIndex(value: unknown, subject: string): number {
- assert(Number.isSafeInteger(value) && (value as number) >= 0, `${subject} must be a non-negative integer`);
- return value as number;
-}
-
-function object(value: unknown, subject: string): Record<string, unknown> {
- assert(value !== null && typeof value === "object" && !Array.isArray(value), `${subject} must be an object`);
- return value as Record<string, unknown>;
-}
-
-export function verifyMediaTransformProgram(value: unknown): asserts value is MediaTransformProgram {
- const program = object(value, "MediaTransformProgram");
- assert(Array.isArray(program.operations) && program.operations.length > 0,
- "MediaTransformProgram requires at least one operation");
- for (const [index, raw] of program.operations.entries()) {
- const operation = object(raw, `MediaTransformProgram operation ${index}`);
- if (operation.kind === "trim") {
- const start = operation.startSec;
- const end = operation.endSec;
- const tail = operation.tailSec;
- assert(start !== undefined || end !== undefined || tail !== undefined,
- `MediaTransformProgram trim ${index} must specify startSec, endSec or tailSec`);
- if (start !== undefined) finiteNonNegative(start, `MediaTransformProgram trim ${index}.startSec`);
- if (end !== undefined) finiteNonNegative(end, `MediaTransformProgram trim ${index}.endSec`);
- if (tail !== undefined) finiteNonNegative(tail, `MediaTransformProgram trim ${index}.tailSec`);
- assert(end === undefined || tail === undefined,
- `MediaTransformProgram trim ${index} cannot specify both endSec and tailSec`);
- if (start !== undefined && end !== undefined) {
- assert((end as number) > (start as number),
- `MediaTransformProgram trim ${index}.endSec must be after startSec`);
- }
- continue;
- }
- assert(operation.kind === "retime", `MediaTransformProgram operation ${index} kind is invalid`);
- assert(typeof operation.rate === "number" && Number.isFinite(operation.rate) && operation.rate > 0
- && operation.rate <= 100,
- `MediaTransformProgram retime ${index}.rate must be in (0, 100]`);
- }
-}
-
-export function sealMediaTransformProgram(value: MediaTransformProgram): MediaTransformProgram {
- const result = canonicalize(value) as unknown as MediaTransformProgram;
- verifyMediaTransformProgram(result);
- return result;
-}
-
-function verifyVideoSelector(value: unknown, subject: string): asserts value is MediaVideoSelector {
- const selector = object(value, subject);
- assert(selector.mode === "primary-moving" || selector.mode === "stream-index", `${subject}.mode is invalid`);
- if (selector.mode === "stream-index") streamIndex(selector.streamIndex, `${subject}.streamIndex`);
-}
-
-function verifyAudioSelector(value: unknown, subject: string, allowNone: boolean): asserts value is MediaAudioSelector {
- const selector = object(value, subject);
- assert(selector.mode === "default" || selector.mode === "stream-index" || (allowNone && selector.mode === "none"),
- `${subject}.mode is invalid`);
- if (selector.mode === "stream-index") streamIndex(selector.streamIndex, `${subject}.streamIndex`);
-}
-
-export function verifyAudioExtractionRequest(value: unknown): asserts value is AudioExtractionRequest {
- const request = object(value, "AudioExtractionRequest");
- verifyAudioSelector(request.audio, "AudioExtractionRequest.audio", false);
- const output = object(request.output, "AudioExtractionRequest.output");
- assert(output.container === "wav" && output.codec === "pcm_s16le"
- && output.sampleRate === 48_000 && output.channels === 2,
- "AudioExtractionRequest output profile is unsupported");
-}
-
-export function sealAudioExtractionRequest(value: AudioExtractionRequest): AudioExtractionRequest {
- const result = canonicalize(value) as unknown as AudioExtractionRequest;
- verifyAudioExtractionRequest(result);
- return result;
-}
-
-export function verifyFrameExtractionRequest(value: unknown): asserts value is FrameExtractionRequest {
- const request = object(value, "FrameExtractionRequest");
- verifyVideoSelector(request.video, "FrameExtractionRequest.video");
- const at = object(request.at, "FrameExtractionRequest.at");
- assert(at.kind === "first" || at.kind === "last" || at.kind === "frame" || at.kind === "time",
- "FrameExtractionRequest.at.kind is invalid");
- if (at.kind === "frame") streamIndex(at.index, "FrameExtractionRequest.at.index");
- if (at.kind === "time") finiteNonNegative(at.seconds, "FrameExtractionRequest.at.seconds");
- const output = object(request.output, "FrameExtractionRequest.output");
- assert(output.format === "png", "FrameExtractionRequest output format is unsupported");
-}
-
-export function sealFrameExtractionRequest(value: FrameExtractionRequest): FrameExtractionRequest {
- const result = canonicalize(value) as unknown as FrameExtractionRequest;
- verifyFrameExtractionRequest(result);
- return result;
-}
-
-export function verifyStillVideoLayout(value: unknown): asserts value is StillVideoLayout {
- const layout = object(value, "StillVideoLayout");
- assert(Array.isArray(layout.weights) && layout.weights.length > 0, "StillVideoLayout needs at least one weight");
- for (const weight of layout.weights) {
- assert(typeof weight === "number" && Number.isFinite(weight) && weight > 0, "StillVideoLayout weights must be positive");
- }
-}
-
-export function sealStillVideoLayout(value: StillVideoLayout): StillVideoLayout {
- const result = canonicalize(value) as unknown as StillVideoLayout;
- verifyStillVideoLayout(result);
- return result;
-}
-
-/**
- * Spread `frameCount` whole frames over the weights. Every picture first holds one frame; the rest
- * are shared by weight, each picture taking the floor of its share and the frames left over going
- * one each to the largest fractional remainders, earlier picture first on a tie. Deterministic, and
- * refused when there are fewer frames than pictures.
- */
-export function planStillVideoSegments(frameCount: number, weights: readonly number[]): readonly StillVideoSegment[] {
- assert(Number.isSafeInteger(frameCount) && frameCount > 0, "Still video frame count must be positive");
- assert(weights.length > 0, "Still video needs at least one picture");
- assert(frameCount >= weights.length, `Still video has ${frameCount} frames for ${weights.length} pictures; each picture needs at least one`);
- const total = weights.reduce((sum, weight) => sum + weight, 0);
- const shared = frameCount - weights.length;
- const exact = weights.map((weight) => shared * weight / total);
- const floors = exact.map((share) => 1 + Math.floor(share));
- let remaining = frameCount - floors.reduce((sum, item) => sum + item, 0);
- const order = exact.map((share, index) => ({ index, fraction: share - Math.floor(share) }))
- .sort((left, right) => right.fraction - left.fraction || left.index - right.index);
- for (const { index } of order) {
- if (remaining === 0) break;
- floors[index] = floors[index]! + 1;
- remaining -= 1;
- }
- const segments: StillVideoSegment[] = [];
- let start = 0;
- for (const frames of floors) {
- segments.push({ startFrame: start, endFrameExclusive: start + frames });
- start += frames;
- }
- return segments;
-}
-
-export function verifyStillVideoRequest(value: unknown): asserts value is StillVideoRequest {
- const request = object(value, "StillVideoRequest");
- const frameRate = object(request.frameRate, "StillVideoRequest.frameRate");
- assert(Number.isSafeInteger(frameRate.numerator) && (frameRate.numerator as number) > 0
- && Number.isSafeInteger(frameRate.denominator) && (frameRate.denominator as number) > 0,
- "StillVideoRequest.frameRate must be a positive rational");
- assert(Number.isSafeInteger(request.frameCount) && (request.frameCount as number) > 0,
- "StillVideoRequest.frameCount must be positive");
- const output = object(request.output, "StillVideoRequest.output");
- assert(output.container === "mp4" && output.codec === "h264" && output.pixelFormat === "yuv420p",
- "StillVideoRequest output profile is unsupported");
- assert(Array.isArray(request.segments) && request.segments.length > 0, "StillVideoRequest needs at least one segment");
- let cursor = 0;
- for (const item of request.segments) {
- const segment = object(item, "StillVideoRequest.segments[]");
- assert(segment.startFrame === cursor, "StillVideoRequest segments must be contiguous from frame 0");
- assert(Number.isSafeInteger(segment.endFrameExclusive) && (segment.endFrameExclusive as number) > cursor,
- "StillVideoRequest segments must each hold at least one frame");
- cursor = segment.endFrameExclusive as number;
- if (segment.source !== undefined) {
- const source = object(segment.source, "StillVideoRequest.segments[].source");
- assert(source.kind === "blob" && typeof source.mediaType === "string" && source.mediaType.startsWith("image/"),
- "StillVideoRequest segment source must be an image Artifact");
- }
- }
- assert(cursor === request.frameCount, "StillVideoRequest segments must cover exactly frameCount frames");
-}
-
-export function sealStillVideoRequest(value: StillVideoRequest): StillVideoRequest {
- const result = canonicalize(value) as unknown as StillVideoRequest;
- verifyStillVideoRequest(result);
- return result;
-}
-
-/** Attach one picture to the first segment that has none; the pictures arrive in authored order. */
-export function bindStillVideoSource(request: StillVideoRequest, source: BlobRef): StillVideoRequest {
- verifyStillVideoRequest(request);
- assert(source.kind === "blob" && source.mediaType.startsWith("image/"), "Still video source must be an image Artifact");
- const index = request.segments.findIndex((segment) => segment.source === undefined);
- assert(index >= 0, "Still video already has a picture for every segment");
- return sealStillVideoRequest({
- ...request,
- segments: request.segments.map((segment, at) => at === index ? { ...segment, source } : segment),
- });
-}
-
-function uniqueDefault<T extends { readonly disposition: { readonly default: boolean }; readonly index: number }>(
- values: readonly T[],
- subject: string,
-): T {
- assert(values.length > 0, `${subject} has no eligible stream`);
- const defaults = values.filter((item) => item.disposition.default);
- if (defaults.length === 1) return defaults[0]!;
- assert(defaults.length === 0, `${subject} has multiple default streams: ${defaults.map((item) => item.index).join(", ")}`);
- assert(values.length === 1, `${subject} is ambiguous: ${values.map((item) => item.index).join(", ")}`);
- return values[0]!;
-}
-
-export function selectVideoStream(inspection: MediaInspection, selector: MediaVideoSelector): MediaVideoStream {
- verifyMediaInspection(inspection);
- verifyVideoSelector(selector, "Video selector");
- const moving = inspection.streams.filter((item): item is MediaVideoStream =>
- item.kind === "video" && item.role === "moving" && !item.disposition.attachedPicture
- && item.timingStatus === "admissible" && item.startPts !== undefined && item.endPts !== undefined);
- if (selector.mode === "primary-moving") return uniqueDefault(moving, "Primary moving video");
- const result = moving.find((item) => item.index === selector.streamIndex);
- assert(result !== undefined, `Video stream ${selector.streamIndex} is not an eligible moving stream`);
- return result;
-}
-
-export function selectAudioStream(
- inspection: MediaInspection,
- selector: Exclude<MediaAudioSelector, { readonly mode: "none" }>,
-): MediaAudioStream {
- verifyMediaInspection(inspection);
- verifyAudioSelector(selector, "Audio selector", false);
- const audio = inspection.streams.filter((item): item is MediaAudioStream =>
- item.kind === "audio" && item.timingStatus === "admissible"
- && item.startPts !== undefined && item.endPts !== undefined);
- if (selector.mode === "default") return uniqueDefault(audio, "Default audio");
- const result = audio.find((item) => item.index === selector.streamIndex);
- assert(result !== undefined, `Audio stream ${selector.streamIndex} is not eligible`);
- return result;
-}
diff --git a/packages/media-pipeline/src/selection.ts b/packages/media-pipeline/src/selection.ts
deleted file mode 100644
index ca4cb2fb..00000000
--- a/packages/media-pipeline/src/selection.ts
+++ /dev/null
@@ -1,110 +0,0 @@
-import { sealMediaStreamSelection, verifyMediaInspection } from "@hypit/media";
-import type { MediaAudioStream, MediaInspection, MediaStreamSelection, MediaVideoStream } from "@hypit/media";
-import {
- canonicalize,
-} from "@hypit/protocol";
-
-import type { MediaSelectionRequest } from "./types.js";
-
-function assert(condition: unknown, message: string): asserts condition {
- if (!condition) throw new Error(message);
-}
-
-export function sealMediaSelectionRequest(value: MediaSelectionRequest): MediaSelectionRequest {
- return canonicalize(value) as unknown as MediaSelectionRequest;
-}
-
-export function verifyMediaSelectionRequest(value: unknown): asserts value is MediaSelectionRequest {
- assert(value !== null && typeof value === "object" && !Array.isArray(value), "MediaSelectionRequest must be an object");
- const item = value as MediaSelectionRequest;
- assert(item.video?.mode === "primary-moving" || item.video?.mode === "stream-index" || item.video?.mode === "none",
- "MediaSelectionRequest video mode is invalid");
- assert(item.audio?.mode === "default" || item.audio?.mode === "stream-index" || item.audio?.mode === "none",
- "MediaSelectionRequest audio mode is invalid");
- if (item.video.mode === "stream-index") {
- assert(Number.isSafeInteger(item.video.streamIndex) && item.video.streamIndex >= 0,
- "MediaSelectionRequest video stream index is invalid");
- }
- if (item.audio.mode === "stream-index") {
- assert(Number.isSafeInteger(item.audio.streamIndex) && item.audio.streamIndex >= 0,
- "MediaSelectionRequest audio stream index is invalid");
- }
- assert(item.spanAuthority === "video" || item.spanAuthority === "audio", "MediaSelectionRequest authority is invalid");
- assert(item.spanAuthority === "video" ? item.video.mode !== "none" : item.audio.mode !== "none",
- "MediaSelectionRequest authority stream is disabled");
- assert(Number.isSafeInteger(item.frameRate?.numerator) && item.frameRate.numerator > 0
- && Number.isSafeInteger(item.frameRate?.denominator) && item.frameRate.denominator > 0,
- "MediaSelectionRequest frame rate is invalid");
-}
-
-function selectUniqueDefault<T extends { readonly disposition: { readonly default: boolean }; readonly index: number }>(
- values: readonly T[],
- subject: string,
-): T {
- assert(values.length > 0, `${subject} has no eligible stream`);
- const defaults = values.filter((item) => item.disposition.default);
- if (defaults.length === 1) return defaults[0]!;
- if (defaults.length > 1) throw new Error(`${subject} has multiple default streams: ${defaults.map((item) => item.index).join(", ")}`);
- if (values.length === 1) return values[0]!;
- throw new Error(`${subject} is ambiguous: ${values.map((item) => item.index).join(", ")}`);
-}
-
-function selectedVideo(inspection: MediaInspection, request: MediaSelectionRequest): MediaVideoStream | undefined {
- if (request.video.mode === "none") return undefined;
- const videoRequest = request.video;
- const moving = inspection.streams.filter((stream): stream is MediaVideoStream =>
- stream.kind === "video"
- && stream.role === "moving"
- && stream.disposition.attachedPicture === false
- && stream.timingStatus === "admissible"
- && stream.startPts !== undefined
- && stream.endPts !== undefined);
- if (videoRequest.mode === "primary-moving") return selectUniqueDefault(moving, "Primary moving video");
- const selected = inspection.streams.find((stream): stream is MediaVideoStream =>
- stream.kind === "video" && stream.index === videoRequest.streamIndex);
- assert(selected !== undefined, `Video stream ${videoRequest.streamIndex} does not exist`);
- assert(selected.role === "moving" && selected.disposition.attachedPicture === false,
- `Video stream ${videoRequest.streamIndex} is not a moving visual stream`);
- assert(selected.timingStatus === "admissible", `Video stream ${videoRequest.streamIndex} timing is not admissible`);
- assert(selected.startPts !== undefined && selected.endPts !== undefined,
- `Video stream ${videoRequest.streamIndex} has no presentation interval`);
- return selected;
-}
-
-function selectedAudio(inspection: MediaInspection, request: MediaSelectionRequest): MediaAudioStream | undefined {
- if (request.audio.mode === "none") return undefined;
- const audioRequest = request.audio;
- const audio = inspection.streams.filter((stream): stream is MediaAudioStream =>
- stream.kind === "audio" && stream.timingStatus === "admissible"
- && stream.startPts !== undefined && stream.endPts !== undefined);
- if (audioRequest.mode === "default") return selectUniqueDefault(audio, "Default audio");
- const selected = audio.find((stream) => stream.index === audioRequest.streamIndex);
- assert(selected !== undefined, `Audio stream ${audioRequest.streamIndex} does not exist or has no presentation interval`);
- return selected;
-}
-
-/**
- * Selects container streams only. Choosing an audio stream never claims that it is narrated speech;
- * Narrative alignment remains a separate semantic Producer with an explicit Narrative edge.
- */
-export function selectMediaStreams(
- inspection: MediaInspection,
- request: MediaSelectionRequest,
-): MediaStreamSelection {
- verifyMediaInspection(inspection);
- verifyMediaSelectionRequest(request);
- const video = selectedVideo(inspection, request);
- const audio = selectedAudio(inspection, request);
- assert(video !== undefined || audio !== undefined, "Media stream selection is empty");
- const policy = request.video.mode === "stream-index" || request.audio.mode === "stream-index"
- ? "explicit-streams@1" as const
- : video !== undefined && audio !== undefined
- ? "primary-moving-default-audio@1" as const
- : video !== undefined ? "primary-moving@1" as const : "default-audio@1" as const;
- return sealMediaStreamSelection({
- ...(video === undefined ? {} : { videoStreamIndex: video.index }),
- ...(audio === undefined ? {} : { audioStreamIndex: audio.index }),
- spanAuthority: request.spanAuthority,
- policy,
- });
-}
diff --git a/packages/media-pipeline/src/surface.ts b/packages/media-pipeline/src/surface.ts
deleted file mode 100644
index 46e3f82e..00000000
--- a/packages/media-pipeline/src/surface.ts
+++ /dev/null
@@ -1,376 +0,0 @@
-import {
- assertEmptyElement as empty,
- localName,
- textAttribute as text,
- type StructuredElement,
- type StructuredSurfaceHandler,
- type SurfaceResolvedReference,
- type MarkupAttributeValue,
-} from "@hypit/markup";
-import { sameType, type CanonicalValue } from "@hypit/protocol";
-import { artifactTypes } from "@hypit/artifact";
-import { mediaTypes } from "@hypit/media";
-import { speechTypes } from "@hypit/speech";
-import { timelineTypes, type Clock } from "@hypit/timeline";
-import { svsRecipeType, type SvsRecipe } from "@hypit/svs";
-
-import {
- extractAudioFragment,
- extractFrameFragment,
- createStillVideoFragment,
- synchronizedMediaFragment,
- transformMediaFragment,
-} from "./fragment.js";
-import { mediaPipelineTypes } from "./manifest.js";
-import {
- sealAudioExtractionRequest,
- sealFrameExtractionRequest,
- sealMediaTransformProgram,
-} from "./operations.js";
-import { sealMediaSelectionRequest } from "./selection.js";
-import type {
- AudioExtractionRequest,
- FrameExtractionRequest,
- MediaSelectionRequest,
- MediaTransformOperation,
-} from "./types.js";
-
-function ref(
- raw: MarkupAttributeValue | undefined,
- label: string,
- resolve: (path: string) => SurfaceResolvedReference | undefined,
-): SurfaceResolvedReference {
- if (typeof raw !== "object" || raw.kind !== "reference") throw new Error(`${label} must be a reference.`);
- const value = resolve(raw.path);
- if (value === undefined || !sameType(value.type, artifactTypes.blob)) throw new Error(`${label} must resolve to BlobArtifact.`);
- return value;
-}
-
-function typedReference(
- raw: MarkupAttributeValue | undefined,
- label: string,
- expected: SurfaceResolvedReference["type"],
- resolve: (path: string) => SurfaceResolvedReference | undefined,
-): SurfaceResolvedReference {
- if (typeof raw !== "object" || raw.kind !== "reference") throw new Error(`${label} must be a reference.`);
- const value = resolve(raw.path);
- if (value === undefined || !sameType(value.type, expected)) throw new Error(`${label} has the wrong Type.`);
- return value;
-}
-
-function authoredRecipe(
- raw: MarkupAttributeValue | undefined,
- label: string,
- resolve: (path: string) => SurfaceResolvedReference | undefined,
-): SvsRecipe {
- const value = typedReference(raw, label, svsRecipeType, resolve);
- if (value.record?.value.kind !== "inline") throw new Error(`${label} must be an authored SVS Recipe.`);
- const recipe = value.record.value.value as unknown as SvsRecipe;
- const unknown = Object.keys(recipe.properties).filter((name) => !["audio", "span-authority", "video"].includes(name));
- if (unknown.length > 0) throw new Error(`${label} only accepts video, audio and span-authority; found ${unknown.join(", ")}.`);
- return recipe;
-}
-
-function recipeText(recipe: SvsRecipe, name: string, label: string): string {
- const value: CanonicalValue | undefined = recipe.properties[name];
- if (typeof value !== "string" || value.trim().length === 0) {
- throw new Error(`${label} requires string property ${name}.`);
- }
- return value;
-}
-
-function stream(value: string, kind: "video"): MediaSelectionRequest["video"];
-function stream(value: string, kind: "audio"): MediaSelectionRequest["audio"];
-function stream(value: string, kind: "video" | "audio"): MediaSelectionRequest["video"] | MediaSelectionRequest["audio"] {
- if (kind === "video" && value === "primary-moving") return { mode: "primary-moving" };
- if (kind === "audio" && value === "default") return { mode: "default" };
- if (value === "none") return { mode: "none" };
- const match = /^stream:(\d+)$/u.exec(value);
- if (match === null) throw new Error(`${kind} must be ${kind === "video" ? "primary-moving" : "default"}, none or stream:<index>.`);
- return { mode: "stream-index", streamIndex: Number(match[1]) };
-}
-
-function exactAttributes(element: StructuredElement, required: readonly string[], optional: readonly string[] = []): void {
- const expected = new Set([...required, ...optional]);
- const unknown = Object.keys(element.attributes).filter((name) => !expected.has(name));
- if (unknown.length > 0 || required.some((name) => element.attributes[name] === undefined)) {
- throw new Error(`${element.name} requires ${required.join(", ")}`
- + (optional.length === 0 ? "" : `; optional: ${optional.join(", ")}`));
- }
-}
-
-function seconds(value: string, subject: string, allowZero = true): number {
- const match = /^(\d+(?:\.\d+)?)(?:s)?$/u.exec(value.trim());
- if (match === null) throw new Error(`${subject} must be seconds such as 0.25s or 2`);
- const result = Number(match[1]);
- if (!Number.isFinite(result) || result < 0 || (!allowZero && result === 0)) {
- throw new Error(`${subject} must be ${allowZero ? "non-negative" : "positive"}`);
- }
- return result;
-}
-
-function audioSelector(value: string): AudioExtractionRequest["audio"] {
- if (value === "default") return { mode: "default" };
- const match = /^stream:(\d+)$/u.exec(value);
- if (match === null) throw new Error("ExtractAudio.audio must be default or stream:<index>.");
- return { mode: "stream-index", streamIndex: Number(match[1]) };
-}
-
-function videoSelector(value: string): FrameExtractionRequest["video"] {
- if (value === "primary-moving") return { mode: "primary-moving" };
- const match = /^stream:(\d+)$/u.exec(value);
- if (match === null) throw new Error("video must be primary-moving or stream:<index>.");
- return { mode: "stream-index", streamIndex: Number(match[1]) };
-}
-
-function transformOperations(element: StructuredElement): readonly MediaTransformOperation[] {
- const result: MediaTransformOperation[] = [];
- for (const child of element.children) {
- if (child.kind === "text") {
- if (child.value.trim().length > 0) throw new Error(`${element.name} accepts only Trim and Retime children.`);
- continue;
- }
- const name = localName(child.name);
- empty(child);
- if (name === "Trim") {
- exactAttributes(child, [], ["start", "end", "tail"]);
- const start = child.attributes.start;
- const end = child.attributes.end;
- const tail = child.attributes.tail;
- if (start === undefined && end === undefined && tail === undefined) {
- throw new Error(`${child.name} requires at least one of start, end or tail.`);
- }
- if (end !== undefined && tail !== undefined) throw new Error(`${child.name} cannot combine end and tail.`);
- for (const [attribute, value] of [["start", start], ["end", end], ["tail", tail]] as const) {
- if (value !== undefined && typeof value !== "string") throw new Error(`${child.name}.${attribute} must be text.`);
- }
- result.push({
- kind: "trim",
- ...(typeof start === "string" ? { startSec: seconds(start, `${child.name}.start`) } : {}),
- ...(typeof end === "string" ? { endSec: seconds(end, `${child.name}.end`, false) } : {}),
- ...(typeof tail === "string" ? { tailSec: seconds(tail, `${child.name}.tail`, false) } : {}),
- });
- continue;
- }
- if (name === "Retime") {
- exactAttributes(child, ["rate"]);
- const rate = Number(text(child, "rate"));
- if (!Number.isFinite(rate) || rate <= 0 || rate > 100) throw new Error(`${child.name}.rate must be in (0, 100].`);
- result.push({ kind: "retime", rate });
- continue;
- }
- throw new Error(`${element.name} accepts only Trim and Retime children.`);
- }
- if (result.length === 0) throw new Error(`${element.name} requires at least one Trim or Retime child.`);
- return result;
-}
-
-export const decodeSynchronizedMediaSurface: StructuredSurfaceHandler = ({ element, resolveReference }) => {
- const required = ["id", "source", "clock"];
- const optional = ["audio", "recipe", "span-authority", "video"];
- exactAttributes(element, required, optional);
- const hasRecipe = element.attributes.recipe !== undefined;
- const policyCount = ["video", "audio", "span-authority"].filter((name) => element.attributes[name] !== undefined).length;
- if ((hasRecipe && policyCount !== 0) || (!hasRecipe && policyCount !== 3)) {
- throw new Error(`${element.name} requires exactly one of recipe or video/audio/span-authority.`);
- }
- if (element.children.some((child) => child.kind === "element" || child.value.trim().length > 0)) {
- throw new Error(`${element.name} must be empty.`);
- }
- const id = text(element, "id");
- const source = ref(element.attributes.source, `${element.name}.source`, resolveReference);
- const clock = typedReference(element.attributes.clock, `${element.name}.clock`, timelineTypes.clock, resolveReference);
- const clockValue = clock.record?.value.kind === "inline"
- ? clock.record.value.value as unknown as Clock
- : undefined;
- if (clockValue === undefined) throw new Error(`${element.name}.clock must be an authored Clock record.`);
- const normalizationRecipe = hasRecipe ? authoredRecipe(element.attributes.recipe, `${element.name}.recipe`, resolveReference) : undefined;
- const video = stream(normalizationRecipe === undefined ? text(element, "video") : recipeText(normalizationRecipe, "video", `${element.name}.recipe`), "video");
- const audio = stream(normalizationRecipe === undefined ? text(element, "audio") : recipeText(normalizationRecipe, "audio", `${element.name}.recipe`), "audio");
- const spanAuthority = normalizationRecipe === undefined
- ? text(element, "span-authority")
- : recipeText(normalizationRecipe, "span-authority", `${element.name}.recipe`);
- if (spanAuthority !== "video" && spanAuthority !== "audio") throw new Error(`${element.name}.span-authority must be video or audio.`);
- const request = sealMediaSelectionRequest({
- video,
- audio,
- spanAuthority,
- frameRate: clockValue.frameRate,
- });
- const requestId = `${id}.request`;
- const domainId = `${id}.domain-spec`;
- return {
- records: [
- { id: requestId, type: mediaPipelineTypes.selectionRequest, value: { kind: "inline", value: request }, range: element.range },
- { id: domainId, type: mediaTypes.domainSpec, value: { kind: "inline", value: { id } }, range: element.range },
- ],
- components: [{
- id,
- fragment: synchronizedMediaFragment.id,
- inputs: { source: source.ref, request: { kind: "record", id: requestId }, domain: { kind: "record", id: domainId } },
- outputs: { media: `${id}.media`, domain: `${id}.domain`, extent: `${id}.extent` },
- range: element.range,
- }],
- fragments: [synchronizedMediaFragment],
- };
-};
-
-/** The pictures of a StillVideo in authored order, with their weights: one `source`, or Still children. */
-function stillPictures(
- element: StructuredElement,
- resolveReference: (path: string) => SurfaceResolvedReference | undefined,
-): readonly { readonly source: SurfaceResolvedReference; readonly weight: number }[] {
- const children = element.children.filter((child) => child.kind === "element" || child.value.trim().length > 0);
- if (element.attributes.source !== undefined) {
- if (children.length > 0) throw new Error(`${element.name} takes either source or Still children, not both.`);
- return [{ source: ref(element.attributes.source, `${element.name}.source`, resolveReference), weight: 1 }];
- }
- const pictures = children.map((child) => {
- if (child.kind !== "element" || localName(child.name) !== "Still") {
- throw new Error(`${element.name} accepts only Still children.`);
- }
- exactAttributes(child, ["source"], ["weight"]);
- empty(child);
- const rawWeight = child.attributes.weight;
- let weight = 1;
- if (rawWeight !== undefined) {
- if (typeof rawWeight !== "string") throw new Error(`${child.name}.weight must be text.`);
- weight = Number(rawWeight);
- if (!Number.isFinite(weight) || weight <= 0) throw new Error(`${child.name}.weight must be a positive number.`);
- }
- return { source: ref(child.attributes.source, `${child.name}.source`, resolveReference), weight };
- });
- if (pictures.length === 0) throw new Error(`${element.name} requires a source or at least one Still child.`);
- return pictures;
-}
-
-export const decodeStillVideoSurface: StructuredSurfaceHandler = ({ element, resolveReference }) => {
- exactAttributes(element, ["id", "duration", "clock"], ["source"]);
- const id = text(element, "id");
- const pictures = stillPictures(element, resolveReference);
- // The duration is the author's decision, written here; it is published as an ordinary
- // SpeechDuration Record so the fragment's plan step reads the same value a graph edge would carry.
- const durationSec = seconds(text(element, "duration"), `${element.name}.duration`, false);
- const durationId = `${id}.duration`;
- const layoutId = `${id}.layout`;
- const clock = typedReference(
- element.attributes.clock,
- `${element.name}.clock`,
- timelineTypes.clock,
- resolveReference,
- );
- const fragment = createStillVideoFragment(pictures.length);
- return {
- records: [{
- id: durationId,
- type: speechTypes.duration,
- value: { kind: "inline", value: durationSec },
- range: element.range,
- }, {
- id: layoutId,
- type: mediaPipelineTypes.stillVideoLayout,
- value: { kind: "inline", value: {
- weights: pictures.map((picture) => picture.weight),
- } },
- range: element.range,
- }],
- components: [{
- id,
- fragment: fragment.id,
- inputs: {
- duration: { kind: "record", id: durationId },
- clock: clock.ref,
- layout: { kind: "record", id: layoutId },
- ...Object.fromEntries(pictures.map((picture, index) => [`source-${index}`, picture.source.ref])),
- },
- outputs: { video: `${id}.video` },
- range: element.range,
- }],
- fragments: [fragment],
- };
-};
-
-export const decodeTransformMediaSurface: StructuredSurfaceHandler = ({ element, resolveReference }) => {
- exactAttributes(element, ["id", "source"]);
- const id = text(element, "id");
- const source = typedReference(element.attributes.source, `${element.name}.source`, mediaTypes.synchronized, resolveReference);
- const program = sealMediaTransformProgram({
- operations: transformOperations(element),
- });
- const programId = `${id}.program`;
- return {
- records: [
- { id: programId, type: mediaPipelineTypes.transformProgram, value: { kind: "inline", value: program }, range: element.range },
- ],
- components: [{
- id,
- fragment: transformMediaFragment.id,
- inputs: {
- media: source.ref,
- program: { kind: "record", id: programId },
- },
- outputs: { video: `${id}.video` },
- range: element.range,
- }],
- fragments: [transformMediaFragment],
- };
-};
-
-export const decodeExtractAudioSurface: StructuredSurfaceHandler = ({ element, resolveReference }) => {
- exactAttributes(element, ["id", "source", "audio"]);
- empty(element);
- const id = text(element, "id");
- const source = ref(element.attributes.source, `${element.name}.source`, resolveReference);
- const request = sealAudioExtractionRequest({
- audio: audioSelector(text(element, "audio")),
- output: { container: "wav", codec: "pcm_s16le", sampleRate: 48_000, channels: 2 },
- });
- const requestId = `${id}.request`;
- return {
- records: [{ id: requestId, type: mediaPipelineTypes.audioExtractionRequest,
- value: { kind: "inline", value: request }, range: element.range }],
- components: [{
- id,
- fragment: extractAudioFragment.id,
- inputs: { source: source.ref, request: { kind: "record", id: requestId } },
- outputs: { audio: `${id}.audio` },
- range: element.range,
- }],
- fragments: [extractAudioFragment],
- };
-};
-
-function frameSelector(value: string, subject: string): FrameExtractionRequest["at"] {
- if (value === "first") return { kind: "first" };
- if (value === "last") return { kind: "last" };
- const frame = /^frame:(\d+)$/u.exec(value);
- if (frame !== null) return { kind: "frame", index: Number(frame[1]) };
- const time = /^time:(.+)$/u.exec(value);
- if (time !== null) return { kind: "time", seconds: seconds(time[1]!, subject) };
- throw new Error(`${subject} must be first, last, frame:<index> or time:<seconds>.`);
-}
-
-export const decodeExtractFrameSurface: StructuredSurfaceHandler = ({ element, resolveReference }) => {
- exactAttributes(element, ["id", "source", "video", "at"]);
- empty(element);
- const id = text(element, "id");
- const source = ref(element.attributes.source, `${element.name}.source`, resolveReference);
- const request = sealFrameExtractionRequest({
- video: videoSelector(text(element, "video")),
- at: frameSelector(text(element, "at"), `${element.name}.at`),
- output: { format: "png" },
- });
- const requestId = `${id}.request`;
- return {
- records: [{ id: requestId, type: mediaPipelineTypes.frameExtractionRequest,
- value: { kind: "inline", value: request }, range: element.range }],
- components: [{
- id,
- fragment: extractFrameFragment.id,
- inputs: { source: source.ref, request: { kind: "record", id: requestId } },
- outputs: { image: `${id}.image` },
- range: element.range,
- }],
- fragments: [extractFrameFragment],
- };
-};
diff --git a/packages/media-pipeline/src/types.ts b/packages/media-pipeline/src/types.ts
deleted file mode 100644
index a8cdc794..00000000
--- a/packages/media-pipeline/src/types.ts
+++ /dev/null
@@ -1,179 +0,0 @@
-import type { AudioLevelAutomation } from "@hypit/composition";
-import type { BlobRef } from "@hypit/protocol";
-import type { MediaFrameRange, MediaInspection, MediaRational, MediaStreamSelection, RenderedVisual, TimelineAudio } from "@hypit/media";
-
-export type MediaSelectionRequest = {
- readonly video:
- | { readonly mode: "primary-moving" }
- | { readonly mode: "stream-index"; readonly streamIndex: number }
- | { readonly mode: "none" };
- readonly audio:
- | { readonly mode: "default" }
- | { readonly mode: "stream-index"; readonly streamIndex: number }
- | { readonly mode: "none" };
- readonly spanAuthority: "video" | "audio";
- readonly frameRate: MediaRational;
-};
-
-export type InspectMediaNeed = {
- readonly source: BlobRef;
-};
-
-export type MediaVideoSelector =
- | { readonly mode: "primary-moving" }
- | { readonly mode: "stream-index"; readonly streamIndex: number };
-
-export type MediaAudioSelector =
- | { readonly mode: "default" }
- | { readonly mode: "stream-index"; readonly streamIndex: number }
- | { readonly mode: "none" };
-
-export type MediaTransformOperation =
- | {
- readonly kind: "trim";
- /** Seconds in the operation's current timeline, not necessarily the source timeline. */
- readonly startSec?: number;
- readonly endSec?: number;
- readonly tailSec?: number;
- }
- | {
- readonly kind: "retime";
- /** Pitch-preserving tempo ratio; 2 means twice as fast and therefore half as long. */
- readonly rate: number;
- };
-
-/** Ordered, deterministic A/V operations over already synchronized media. */
-export type MediaTransformProgram = {
- readonly operations: readonly MediaTransformOperation[];
-};
-
-export type AudioExtractionRequest = {
- readonly audio: Exclude<MediaAudioSelector, { readonly mode: "none" }>;
- readonly output: {
- readonly container: "wav";
- readonly codec: "pcm_s16le";
- readonly sampleRate: 48_000;
- readonly channels: 2;
- };
-};
-
-export type FrameExtractionRequest = {
- readonly video: MediaVideoSelector;
- readonly at:
- | { readonly kind: "first" }
- | { readonly kind: "last" }
- | { readonly kind: "frame"; readonly index: number }
- | { readonly kind: "time"; readonly seconds: number };
- readonly output: { readonly format: "png" };
-};
-
-/** How the still video divides its literal duration among its pictures: one weight per picture, in order. */
-export type StillVideoLayout = {
- readonly weights: readonly number[];
-};
-
-/** One picture's span of the still video, in frames; `source` is bound one picture at a time. */
-export type StillVideoSegment = {
- readonly startFrame: number;
- readonly endFrameExclusive: number;
- readonly source?: BlobRef;
-};
-
-/** Exact video-only clip requested from one or more authored still images spread over a literal duration. */
-export type StillVideoRequest = {
- readonly frameRate: MediaRational;
- readonly frameCount: number;
- readonly output: {
- readonly container: "mp4";
- readonly codec: "h264";
- readonly pixelFormat: "yuv420p";
- };
- readonly segments: readonly StillVideoSegment[];
-};
-
-export type TransformMediaNeed = {
- readonly media: import("@hypit/media").SynchronizedMedia;
- readonly program: MediaTransformProgram;
-};
-
-export type ExtractAudioNeed = {
- readonly source: BlobRef;
- readonly streamIndex: number;
- readonly output: AudioExtractionRequest["output"];
-};
-
-export type ExtractFrameNeed = {
- readonly source: BlobRef;
- readonly streamIndex: number;
- readonly sourceFrameCount: number;
- readonly at: FrameExtractionRequest["at"];
- readonly output: FrameExtractionRequest["output"];
-};
-
-/** Every segment of the request carries its picture by the time the Need is made. */
-export type RenderStillVideoNeed = {
- readonly request: StillVideoRequest;
-};
-
-export type NormalizeMediaNeed = {
- readonly source: BlobRef;
- readonly inspection: MediaInspection;
- readonly selection: MediaStreamSelection;
- readonly frameRate: MediaRational;
- readonly audio: {
- readonly sampleRate: 48_000;
- readonly channels: 2;
- readonly codec: "pcm_s16le";
- readonly loudness: "preserve";
- };
-};
-
-export type ProjectSpeechEvidenceAudioNeed = {
- readonly domainId: string;
- readonly source: BlobRef;
- readonly sourceSampleFrames: number;
- readonly evidenceSampleFrames: number;
-};
-
-export type AudioProgramClip = AudioLevelAutomation & {
- readonly id: string;
- readonly artifact: BlobRef;
- readonly targetStartSample: number;
- readonly targetEndSampleExclusive: number;
- readonly sourceSampleFrames: number;
- readonly sourceStartSample: number;
- readonly sourceEndSampleExclusive: number;
- readonly sourceLoop: boolean;
- readonly sourcePhaseSample: number;
- /** Tempo ratio; Audio execution preserves pitch. */
- readonly playbackRate: number;
- /** Complete owning Clip Window; fades do not restart at source-time piece boundaries. */
- readonly mixStartSample: number;
- readonly mixEndSampleExclusive: number;
- readonly gain: number;
- readonly fadeInSamples: number;
- readonly fadeOutSamples: number;
-};
-
-/** Pure media plan. Executing it is always a Provider Need. */
-export type AudioProgramPlan = {
- readonly frameRate: MediaRational;
- readonly frameCount: number;
- readonly sampleRate: 48_000;
- readonly sampleFrames: number;
- readonly clips: readonly AudioProgramClip[];
- readonly mix: {
- readonly normalize: false;
- readonly limiter: "none";
- };
-};
-
-export type RenderAudioNeed = {
- readonly plan: AudioProgramPlan;
- readonly range?: MediaFrameRange;
-};
-
-export type MuxMediaNeed = {
- readonly visual: RenderedVisual;
- readonly audio: TimelineAudio;
-};
diff --git a/packages/media-pipeline/test/manifest.test.ts b/packages/media-pipeline/test/manifest.test.ts
deleted file mode 100644
index 8324ee99..00000000
--- a/packages/media-pipeline/test/manifest.test.ts
+++ /dev/null
@@ -1,222 +0,0 @@
-import { artifactTypes } from "@hypit/artifact";
-import { mediaTypes } from "@hypit/media";
-import { timelineTypes } from "@hypit/timeline";
-import { speechTypes } from "@hypit/speech";
-import { svsRecipeType } from "@hypit/svs";
-import { installRunFragmentHostFacets, RunFragmentRegistry } from "@hypit/run";
-import assert from "node:assert/strict";
-import test from "node:test";
-import { fixtureResource } from "../../../test/fixture-resource.js";
-
-import {
- mediaPipelineTypes,
- decodeSynchronizedMediaSurface,
- decodeExtractAudioSurface,
- decodeExtractFrameSurface,
- decodeTransformMediaSurface,
- decodeStillVideoSurface,
- createStillVideoFragment,
- planStillVideoSegments,
- bindStillVideoSource,
- extractAudioFragment,
- extractFrameFragment,
- synchronizedMediaFragment,
- transformMediaFragment,
- stillVideoFragment,
-} from "../src/index.js";
-import { hypitPackage } from "../src/activation.js";
-
-test("the package exposes StillVideo as an ordinary Run Fragment", () => {
- const fragments = new RunFragmentRegistry();
- installRunFragmentHostFacets(hypitPackage.hostFacets, fragments);
- assert.equal(fragments.resolve("@hypit/media-pipeline@1", "still-video"), stillVideoFragment);
-});
-
-test("the Normalize Surface makes inspection and normalization an explicit author graph branch", async () => {
- const range = { source: "normalize.svml", start: 0, end: 1 };
- const result = await decodeSynchronizedMediaSurface({
- sourceName: range.source,
- element: {
- kind: "element",
- name: "pipeline:Normalize",
- attributes: {
- id: "motion",
- source: { kind: "reference", path: "generated" },
- clock: { kind: "reference", path: "clock" },
- recipe: { kind: "reference", path: "policy" },
- },
- children: [],
- range,
- },
- resolveReference: (path) => path === "generated"
- ? { path, ref: { kind: "record", id: path }, type: artifactTypes.blob }
- : path === "clock"
- ? { path, ref: { kind: "record", id: path }, type: timelineTypes.clock,
- record: { value: { kind: "inline", value: { frameRate: { numerator: 30_000, denominator: 1_001 } } } } as never }
- : path === "policy"
- ? { path, ref: { kind: "record", id: path }, type: svsRecipeType,
- record: { value: { kind: "inline", value: { path, properties: { video: "primary-moving", audio: "none", "span-authority": "video" } } } } as never }
- : undefined,
- resolveAsset: async () => { throw new Error("no asset resolution expected"); },
- });
- assert.equal(result.fragments[0]?.id, synchronizedMediaFragment.id);
- assert.deepEqual(result.components[0]?.outputs, {
- media: "motion.media", domain: "motion.domain", extent: "motion.extent",
- });
- const request = result.records[0]?.value;
- assert.ok(request?.kind === "inline");
- assert.deepEqual(request.value, {
- video: { mode: "primary-moving" },
- audio: { mode: "none" },
- spanAuthority: "video",
- frameRate: { numerator: 30_000, denominator: 1_001 },
- });
-});
-
-test("media operations are ordinary graph branches over BlobArtifact", async () => {
- const range = { source: "operations.svml", start: 0, end: 1 };
- const resolveReference = (path: string) => path === "generated.media"
- ? { path, ref: { kind: "record" as const, id: path }, type: mediaTypes.synchronized }
- : path === "generated.video"
- ? { path, ref: { kind: "record" as const, id: path }, type: artifactTypes.blob }
- : undefined;
- const context = { sourceName: range.source, resolveReference,
- resolveAsset: async () => { throw new Error("no asset resolution expected"); } };
- const transform = await decodeTransformMediaSurface({
- ...context,
- element: {
- kind: "element", name: "media:Transform", range,
- attributes: {
- id: "prepared", source: { kind: "reference", path: "generated.media" },
- },
- children: [
- { kind: "element", name: "media:Trim", attributes: { tail: "0.25s" }, children: [], range },
- { kind: "element", name: "media:Retime", attributes: { rate: "1.05" }, children: [], range },
- ],
- },
- });
- assert.equal(transform.fragments[0]?.id, transformMediaFragment.id);
- assert.deepEqual(transform.components[0]?.outputs, { video: "prepared.video" });
- const program = transform.records.find((record) => record.id === "prepared.program");
- assert.ok(program?.value.kind === "inline");
- assert.deepEqual(program.value.value, {
- operations: [
- { kind: "trim", tailSec: 0.25 },
- { kind: "retime", rate: 1.05 },
- ],
- });
-
- const audio = await decodeExtractAudioSurface({
- ...context,
- element: {
- kind: "element", name: "media:ExtractAudio", range,
- attributes: { id: "voice-reference", source: { kind: "reference", path: "generated.video" }, audio: "default" },
- children: [],
- },
- });
- assert.equal(audio.fragments[0]?.id, extractAudioFragment.id);
- assert.deepEqual(audio.components[0]?.outputs, { audio: "voice-reference.audio" });
-
- const frame = await decodeExtractFrameSurface({
- ...context,
- element: {
- kind: "element", name: "media:ExtractFrame", range,
- attributes: { id: "continuity", source: { kind: "reference", path: "generated.video" },
- video: "primary-moving", at: "last" },
- children: [],
- },
- });
- assert.equal(frame.fragments[0]?.id, extractFrameFragment.id);
- assert.deepEqual(frame.components[0]?.outputs, { image: "continuity.image" });
-});
-
-test("StillVideo stops at an ordinary MP4 branch before Normalize", async () => {
- const range = { source: "still.svml", start: 0, end: 1 };
- const output = await decodeStillVideoSurface({
- sourceName: range.source,
- element: {
- kind: "element",
- name: "media:StillVideo",
- attributes: {
- id: "opening-still",
- source: { kind: "reference", path: "opening-head" },
- duration: "6",
- clock: { kind: "reference", path: "clock" },
- },
- children: [],
- range,
- },
- resolveReference: (path) => path === "opening-head"
- ? { path, ref: { kind: "record", id: path }, type: artifactTypes.blob }
- : path === "clock"
- ? { path, ref: { kind: "record", id: path }, type: timelineTypes.clock }
- : undefined,
- resolveAsset: async () => { throw new Error("no asset resolution expected"); },
- });
- assert.equal(output.fragments[0]?.id, stillVideoFragment.id);
- assert.deepEqual(output.components[0]?.outputs, { video: "opening-still.video" });
- assert.deepEqual(output.records[0], {
- id: "opening-still.duration", type: speechTypes.duration, value: { kind: "inline", value: 6 }, range,
- }, "the literal duration is the author's, published as an ordinary SpeechDuration Record");
- assert.deepEqual(output.components[0]?.inputs.duration, { kind: "record", id: "opening-still.duration" });
- assert.deepEqual(output.components[0]?.inputs["source-0"], { kind: "record", id: "opening-head" });
- assert.deepEqual(output.records[1]?.value, { kind: "inline", value: { weights: [1] } }, "one picture, one whole share");
- assert.equal(stillVideoFragment.exports[0]?.type.name, artifactTypes.blob.name);
-});
-
-test("StillVideo spreads several pictures over one literal duration by weight, in authored order", async () => {
- const range = { source: "still.svml", start: 0, end: 1 };
- const resolveReference = (path: string) => path === "clock"
- ? { path, ref: { kind: "record" as const, id: path }, type: timelineTypes.clock }
- : { path, ref: { kind: "record" as const, id: path }, type: artifactTypes.blob };
- const child = (source: string, weight?: string) => ({
- kind: "element" as const, name: "media:Still",
- attributes: { source: { kind: "reference" as const, path: source }, ...(weight === undefined ? {} : { weight }) },
- children: [], range,
- });
- const output = await decodeStillVideoSurface({
- sourceName: range.source,
- element: {
- kind: "element", name: "media:StillVideo",
- attributes: { id: "kitchen", duration: "6", clock: { kind: "reference", path: "clock" } },
- children: [child("counter"), child("basil", "2"), child("board")],
- range,
- },
- resolveReference,
- resolveAsset: async () => { throw new Error("no asset resolution expected"); },
- });
- assert.equal(output.fragments[0]?.id, createStillVideoFragment(3).id);
- assert.notEqual(output.fragments[0]?.id, stillVideoFragment.id, "three pictures are a different shape from one");
- assert.deepEqual(output.records[1]?.value, { kind: "inline", value: { weights: [1, 2, 1] } });
- assert.deepEqual(
- ["source-0", "source-1", "source-2"].map((name) => output.components[0]?.inputs[name]),
- [{ kind: "record", id: "counter" }, { kind: "record", id: "basil" }, { kind: "record", id: "board" }],
- );
- await assert.rejects(async () => await decodeStillVideoSurface({
- sourceName: range.source,
- element: {
- kind: "element", name: "media:StillVideo",
- attributes: { id: "both", source: { kind: "reference", path: "counter" }, duration: "6", clock: { kind: "reference", path: "clock" } },
- children: [child("basil")],
- range,
- },
- resolveReference,
- resolveAsset: async () => { throw new Error("no asset resolution expected"); },
- }), /either source or Still children/u);
-});
-
-test("still video frames are whole and every picture holds at least one", () => {
- assert.deepEqual(planStillVideoSegments(180, [1, 2, 1]).map((item) => item.endFrameExclusive - item.startFrame), [45, 90, 45]);
- assert.deepEqual(planStillVideoSegments(10, [1, 1, 1]).map((item) => item.endFrameExclusive - item.startFrame), [4, 3, 3],
- "the leftover frame goes to the earliest of equal remainders");
- assert.deepEqual(planStillVideoSegments(10, [1, 1.5, 1]).map((item) => item.endFrameExclusive - item.startFrame), [3, 4, 3]);
- assert.deepEqual(planStillVideoSegments(3, [100, 1, 1]).map((item) => item.endFrameExclusive - item.startFrame), [1, 1, 1]);
- assert.throws(() => planStillVideoSegments(2, [1, 1, 1]), /each picture needs at least one/u);
- const bound = bindStillVideoSource(
- { frameRate: { numerator: 30, denominator: 1 }, frameCount: 2, output: { container: "mp4", codec: "h264", pixelFormat: "yuv420p" },
- segments: [{ startFrame: 0, endFrameExclusive: 1 }, { startFrame: 1, endFrameExclusive: 2 }] },
- { kind: "blob", resource: fixtureResource("still:first"), size: 1, mediaType: "image/png" },
- );
- assert.equal(bound.segments[0]?.source?.mediaType, "image/png");
- assert.equal(bound.segments[1]?.source, undefined, "pictures bind in order, one per step");
-});
diff --git a/packages/media-pipeline/test/mux.test.ts b/packages/media-pipeline/test/mux.test.ts
deleted file mode 100644
index 00d8b548..00000000
--- a/packages/media-pipeline/test/mux.test.ts
+++ /dev/null
@@ -1,36 +0,0 @@
-import assert from "node:assert/strict";
-import test from "node:test";
-import { sealRenderedVisual, sealTimelineAudio } from "@hypit/media";
-import { fixtureResource } from "../../../test/fixture-resource.js";
-import { mediaPipelineComponent } from "../src/component.js";
-import { mediaPipelineProducers } from "../src/manifest.js";
-
-const mux = mediaPipelineComponent.producers.find((item) => item.producer.name === mediaPipelineProducers.mux.name)!;
-
-const cases = [
- { frameRate: { numerator: 30, denominator: 1 }, frameCount: 149, sampleFrames: 238400 },
- { frameRate: { numerator: 24000, denominator: 1001 }, frameCount: 149, sampleFrames: 298298 },
- { frameRate: { numerator: 30000, denominator: 1001 }, frameCount: 149, sampleFrames: 238638 },
- { frameRate: { numerator: 30000, denominator: 1001 }, frameCount: 1, sampleFrames: 1602 },
- { frameRate: { numerator: 60000, denominator: 1001 }, frameCount: 1, sampleFrames: 801 },
-];
-
-for (const { frameRate, frameCount, sampleFrames } of cases) {
- test(`mux accepts the nearest PCM sample boundary for ${frameCount} frames at ${frameRate.numerator}/${frameRate.denominator}`, async () => {
- const visual = sealRenderedVisual({ frameRate, frameCount, canvas: { width: 540, height: 960 },
- artifact: { kind: "blob", resource: fixtureResource("mux:visual"), size: 1, mediaType: "video/mp4" } });
- const run = (samples: number) => {
- const audio = sealTimelineAudio({ sampleFrames: samples,
- artifact: { kind: "blob", resource: fixtureResource("mux:audio"), size: 1, mediaType: "audio/wav" } });
- return mux.handler({ inputs: {
- visual: { value: { kind: "inline", value: visual } },
- audio: { value: { kind: "inline", value: audio } },
- } } as never);
- };
- const result = await run(sampleFrames);
- assert.deepEqual(Object.keys(result.needs), ["media"]);
- for (const incorrect of [sampleFrames - 1, sampleFrames + 1]) {
- await assert.rejects(async () => run(incorrect), /different presentation durations/u);
- }
- });
-}
diff --git a/packages/media-pipeline/test/presentation.test.ts b/packages/media-pipeline/test/presentation.test.ts
deleted file mode 100644
index 80883a29..00000000
--- a/packages/media-pipeline/test/presentation.test.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-import assert from "node:assert/strict";
-import test from "node:test";
-import { mediaPipelineComponent } from "../src/component.js";
-import { mediaPipelineProducers } from "../src/manifest.js";
-
-test("audio range request describes its own range without listing every clip", () => {
- const facet = mediaPipelineComponent.plannedNeeds.find((item) => item.producer.name === mediaPipelineProducers.renderAudioRange.name)!;
- const plan = { frameRate: { numerator: 30, denominator: 1 }, frameCount: 600, sampleRate: 48000,
- clips: Array.from({ length: 35 }, () => ({ source: "not a CLI output" })) };
- assert.deepEqual(facet.present!({ constraints: {}, pendingInputs: [] }), { fields: {}, references: {} });
- assert.deepEqual(facet.present!({ constraints: { plan, range: { startFrame: 30, endFrameExclusive: 91 } }, pendingInputs: [] }), {
- fields: { startFrame: [30], endFrameExclusive: [91], frameRate: ["30/1"], sampleRate: [48000] }, references: {},
- });
-});
diff --git a/packages/media-pipeline/test/selection.test.ts b/packages/media-pipeline/test/selection.test.ts
deleted file mode 100644
index 2a5af49d..00000000
--- a/packages/media-pipeline/test/selection.test.ts
+++ /dev/null
@@ -1,133 +0,0 @@
-import { sealMediaInspection, verifyMediaStreamSelection } from "@hypit/media";
-import type { MediaInspection, MediaVideoStream } from "@hypit/media";
-import assert from "node:assert/strict";
-import test from "node:test";
-import { fixtureResource } from "../../../test/fixture-resource.js";
-
-
-import {
- sealMediaSelectionRequest,
- selectMediaStreams,
-} from "../src/index.js";
-
-const source = {
- kind: "blob" as const,
- resource: fixtureResource("grok-container"),
- size: 123,
- mediaType: "video/mp4",
-};
-const timeBase = { numerator: 1, denominator: 12_288 } as const;
-const timestamp = (ticks: string) => ({ ticks, timeBase });
-
-function grokInspection(): MediaInspection {
- return sealMediaInspection({
- container: { formatNames: ["mov", "mp4"] },
- streams: [
- {
- kind: "video",
- index: 0,
- codecType: "video",
- codecName: "h264",
- disposition: { default: true, attachedPicture: false },
- timingStatus: "admissible",
- timeBase,
- startPts: timestamp("0"),
- endPts: timestamp("74240"),
- decodedUnitCount: 145,
- role: "moving",
- width: 464,
- height: 688,
- sampleAspectRatio: { numerator: 1, denominator: 1 },
- rotationDegrees: 0,
- averageFrameRate: { numerator: 24, denominator: 1 },
- nominalFrameRate: { numerator: 24, denominator: 1 },
- },
- {
- kind: "audio",
- index: 1,
- codecType: "audio",
- codecName: "aac",
- disposition: { default: true, attachedPicture: false },
- timingStatus: "admissible",
- timeBase: { numerator: 1, denominator: 48_000 },
- startPts: { ticks: "0", timeBase: { numerator: 1, denominator: 48_000 } },
- endPts: { ticks: "288000", timeBase: { numerator: 1, denominator: 48_000 } },
- decodedUnitCount: 283,
- sampleRate: 48_000,
- channels: 2,
- channelLayout: "stereo",
- decodedSampleFrames: 289_792,
- },
- {
- kind: "video",
- index: 2,
- codecType: "video",
- codecName: "mjpeg",
- disposition: { default: false, attachedPicture: true },
- timingStatus: "admissible",
- timeBase: { numerator: 1, denominator: 90_000 },
- startPts: { ticks: "0", timeBase: { numerator: 1, denominator: 90_000 } },
- endPts: { ticks: "543750", timeBase: { numerator: 1, denominator: 90_000 } },
- decodedUnitCount: 1,
- role: "attached-picture",
- width: 464,
- height: 688,
- sampleAspectRatio: { numerator: 1, denominator: 1 },
- rotationDegrees: 0,
- },
- ],
- });
-}
-
-test("primary stream selection excludes Grok's MJPEG attached picture and observes AAC without speech semantics", () => {
- const inspection = grokInspection();
- const request = sealMediaSelectionRequest({
- video: { mode: "primary-moving" },
- audio: { mode: "default" },
- spanAuthority: "video",
- frameRate: { numerator: 30, denominator: 1 },
- });
- const selection = selectMediaStreams(inspection, request);
- verifyMediaStreamSelection(selection);
- assert.equal(selection.videoStreamIndex, 0);
- assert.equal(selection.audioStreamIndex, 1);
- assert.equal(selection.spanAuthority, "video");
- assert.equal("basisResourceId" in selection, false);
- assert.equal("narrativeDigest" in selection, false);
-});
-
-test("multiple moving streams without one default fail closed instead of guessing by index or size", () => {
- const inspection = grokInspection();
- const primary = inspection.streams.find((stream): stream is MediaVideoStream => stream.kind === "video" && stream.index === 0)!;
- const ambiguous = sealMediaInspection({
- ...inspection,
- streams: [
- { ...primary, disposition: { default: false, attachedPicture: false } },
- { ...primary, index: 3, width: 1920, height: 1080, disposition: { default: false, attachedPicture: false } },
- ],
- });
- const request = sealMediaSelectionRequest({
- video: { mode: "primary-moving" },
- audio: { mode: "none" },
- spanAuthority: "video",
- frameRate: { numerator: 30, denominator: 1 },
- });
- assert.throws(() => selectMediaStreams(ambiguous, request), /ambiguous/u);
- const explicit = sealMediaSelectionRequest({
- video: { mode: "stream-index", streamIndex: 3 },
- audio: { mode: "none" },
- spanAuthority: "video",
- frameRate: { numerator: 30, denominator: 1 },
- });
- assert.equal(selectMediaStreams(ambiguous, explicit).videoStreamIndex, 3);
-});
-
-test("an attached picture cannot be forced into the moving-video normalization path", () => {
- const request = sealMediaSelectionRequest({
- video: { mode: "stream-index", streamIndex: 2 },
- audio: { mode: "none" },
- spanAuthority: "video",
- frameRate: { numerator: 30, denominator: 1 },
- });
- assert.throws(() => selectMediaStreams(grokInspection(), request), /not a moving visual stream/u);
-});
diff --git a/packages/media/README.md b/packages/media/README.md
index 2a764e47..48ff564d 100644
--- a/packages/media/README.md
+++ b/packages/media/README.md
@@ -3,10 +3,10 @@
Author-facing media declarations for the neutral `@hypit/media` contract module.
`<media:Image>`, `<media:Audio>`, `<media:Video>` and `<media:Font>` request bytes through the Host-owned source-asset
-capability. Image, Audio and Video emit one Resource-backed `BlobArtifact`; Font wraps the same immutable
+capability. Image, Audio and Video emit one Resource-backed `Blob`; Font wraps the same immutable
bytes with exact weight/style metadata as a one-source `FontArtifactRef`. A logical font face may
also contain several exact Unicode-range sources when another package, such as
-`@hypit/fonts-open`, owns a sharded installed font. `FontStackRef` is the generic ordered value
+`@hypit/fontsource`, adapts a sharded installed font. `FontStackRef` is the generic ordered value
for one primary face followed by exact glyph fallbacks. Media declarations do not open files themselves,
inspect media, call a Provider or promote declared audio to speech. The consuming author package
decides whether an audio artifact is a voice reference, soundtrack, evidence source or something
@@ -38,12 +38,25 @@ to Timeline construction is not observable downstream.
<media:Font id="caption-font" src="./assets/fonts/creator-bold.otf" weight="700" style="normal"/>
```
-The source can be a project font, a user-supplied file, or an installed font's file path. The Host
-stages its bytes as an ordinary resource; the render machine does not need that font installed.
+The source can be a project font, a user-supplied file, or an npm package resource such as
+`package:@company/brand-fonts/files/brand.woff2`. The Host stages its bytes as an ordinary resource;
+the render machine does not need that font installed.
Project-relative assets make the Source portable. The supported filename extensions are `.ttf`,
`.otf`, `.woff` and `.woff2`. The Surface has no selector for a face within a `.ttc`/`.otc` collection;
use the intended standalone face. Weight/style metadata describes that face, not a synthetic transform.
Caption Fine and Typography Styles can consume this value as their primary `font` or an explicit
-Fallback face. `@hypit/fonts-open` offers bundled faces through the same media types; its catalog
-does not limit which external fonts an author may supply.
+Fallback face. `@hypit/fontsource` adapts only packages the project explicitly installs; Media
+does not carry a font catalog or limit which package and project-owned files an author may supply.
+
+A face split across Unicode ranges uses `Source` children. A stack is a separate, generic value:
+
+```svml
+<media:Font id="latin" src="package:@company/type/files/latin.woff2" weight="600" style="normal"/>
+<media:Font id="han" weight="600" style="normal">
+ <media:Source src="./assets/fonts/han-1.woff2" unicode-range="U+4E00-9FFF"/>
+</media:Font>
+<media:FontStack id="caption" primary={latin}>
+ <media:Fallback font={han}/>
+</media:FontStack>
+```
diff --git a/packages/media/package.json b/packages/media/package.json
index e212f3de..6839378d 100644
--- a/packages/media/package.json
+++ b/packages/media/package.json
@@ -11,11 +11,11 @@
"activation": "./src/activation.ts"
},
"dependencies": {
- "@hypit/artifact": "workspace:*",
- "@hypit/component-kit": "workspace:*",
- "@hypit/elaborator": "workspace:*",
+ "@hypit/blob": "workspace:*",
+ "@hypit/producer": "workspace:*",
"@hypit/protocol": "workspace:*",
"@hypit/temporal": "workspace:*",
- "@hypit/markup": "workspace:*"
+ "@hypit/markup": "workspace:*",
+ "@hypit/admission": "workspace:*"
}
}
diff --git a/packages/media/src/activation.ts b/packages/media/src/activation.ts
index 13261311..b7a34a8a 100644
--- a/packages/media/src/activation.ts
+++ b/packages/media/src/activation.ts
@@ -1,37 +1,44 @@
-import { createMarkupSurfaceHostFacet } from "@hypit/markup";
+import { createAdmissionPackageFacet } from "@hypit/admission";
+import { createProducerPackageFacet } from "@hypit/producer";
+import { createMarkupSurfaceFacet } from "@hypit/markup";
import {
- decodeMediaAudioSurface, decodeMediaFontSurface, decodeMediaImageSurface, decodeMediaVideoSurface, mediaComponent,
+ decodeMediaAudioSurface, decodeMediaFontStackSurface, decodeMediaFontSurface, decodeMediaImageSurface, decodeMediaVideoSurface, mediaComponent,
mediaManifest,
mediaModuleRef,
mediaMarkupSurfaces,
} from "./index.js";
export const hypitPackage = {
- format: "hypit.node-package@1" as const,
+ format: "hypit.package@1" as const,
modules: [{ manifest: mediaManifest }],
- components: [mediaComponent],
- hostFacets: [
- createMarkupSurfaceHostFacet({
+ facets: [
+ ...[mediaComponent].flatMap((component) => [createProducerPackageFacet(component), createAdmissionPackageFacet(component)]),
+ createMarkupSurfaceFacet({
module: mediaModuleRef,
declaration: mediaMarkupSurfaces.find((item) => item.name === "image")!,
handler: decodeMediaImageSurface,
}),
- createMarkupSurfaceHostFacet({
+ createMarkupSurfaceFacet({
module: mediaModuleRef,
declaration: mediaMarkupSurfaces.find((item) => item.name === "audio")!,
handler: decodeMediaAudioSurface,
}),
- createMarkupSurfaceHostFacet({
+ createMarkupSurfaceFacet({
module: mediaModuleRef,
declaration: mediaMarkupSurfaces.find((item) => item.name === "video")!,
handler: decodeMediaVideoSurface,
}),
- createMarkupSurfaceHostFacet({
+ createMarkupSurfaceFacet({
module: mediaModuleRef,
declaration: mediaMarkupSurfaces.find((item) => item.name === "font")!,
handler: decodeMediaFontSurface,
}),
+ createMarkupSurfaceFacet({
+ module: mediaModuleRef,
+ declaration: mediaMarkupSurfaces.find((item) => item.name === "font-stack")!,
+ handler: decodeMediaFontStackSurface,
+ }),
],
};
diff --git a/packages/media/src/component.ts b/packages/media/src/component.ts
index 5f9f0eab..40ba5916 100644
--- a/packages/media/src/component.ts
+++ b/packages/media/src/component.ts
@@ -1,5 +1,6 @@
-import type { ComponentPackage } from "@hypit/component-kit";
-import { verifyMediaInspection, verifyMediaStreamSelection, verifyMuxedMedia, verifyRenderedVisual, verifySynchronizedMedia, verifyTimelineAudio } from "./identity.js";
+import type { AdmissionPackage } from "@hypit/admission";
+import type { ProducerPackage } from "@hypit/producer";
+import { verifyMediaInspection, verifyMediaStreamSelection, verifyMuxedMedia, verifyTimelineVisual, verifySynchronizedMedia, verifyTimelineAudio } from "./identity.js";
import { mediaLocalTemporalDomain } from "./domain.js";
import type { MediaDomainSpec, SynchronizedMedia } from "./types.js";
import { canonicalize } from "@hypit/protocol";
@@ -13,7 +14,7 @@ export const mediaComponent = {
{ type: mediaTypes.inspection, handler: ({ value }) => verifyMediaInspection(inline(value, "MediaInspection")) },
{ type: mediaTypes.streamSelection, handler: ({ value }) => verifyMediaStreamSelection(inline(value, "MediaStreamSelection")) },
{ type: mediaTypes.synchronized, handler: ({ value }) => verifySynchronizedMedia(inline(value, "SynchronizedMedia")) },
- { type: mediaTypes.renderedVisual, handler: ({ value }) => verifyRenderedVisual(inline(value, "RenderedVisual")) },
+ { type: mediaTypes.timelineVisual, handler: ({ value }) => verifyTimelineVisual(inline(value, "TimelineVisual")) },
{ type: mediaTypes.timelineAudio, handler: ({ value }) => verifyTimelineAudio(inline(value, "TimelineAudio")) },
{ type: mediaTypes.muxed, handler: ({ value }) => verifyMuxedMedia(inline(value, "MuxedMedia")) },
],
@@ -24,4 +25,4 @@ export const mediaComponent = {
return { outputs: { domain: { kind: "inline", value: canonicalize(mediaLocalTemporalDomain(spec.id, media)) } }, needs: {} };
} },
],
-} satisfies ComponentPackage;
+} satisfies ProducerPackage & AdmissionPackage;
diff --git a/packages/media/src/frame-range.ts b/packages/media/src/frame-range.ts
index 0eb63103..447eb55f 100644
--- a/packages/media/src/frame-range.ts
+++ b/packages/media/src/frame-range.ts
@@ -1,6 +1,6 @@
import type { MediaRational } from "./types.js";
-/** A half-open selection on the original programme frame clock. */
+/** A half-open selection on the original program frame clock. */
export type MediaFrameRange = {
readonly startFrame: number;
readonly endFrameExclusive: number;
diff --git a/packages/media/src/identity.ts b/packages/media/src/identity.ts
index 7e7c3a28..db417835 100644
--- a/packages/media/src/identity.ts
+++ b/packages/media/src/identity.ts
@@ -8,7 +8,7 @@ import type {
MediaInspection,
MuxedMedia,
MediaRational,
- RenderedVisual,
+ TimelineVisual,
MediaStream,
MediaStreamSelection,
MediaTimestamp,
@@ -185,18 +185,18 @@ export function verifySynchronizedMedia(value: unknown): asserts value is Synchr
}
}
-export function sealRenderedVisual(value: RenderedVisual): RenderedVisual {
- return canonicalize(value) as unknown as RenderedVisual;
+export function sealTimelineVisual(value: TimelineVisual): TimelineVisual {
+ return canonicalize(value) as unknown as TimelineVisual;
}
-export function verifyRenderedVisual(value: unknown): asserts value is RenderedVisual {
- const item = object(value, "RenderedVisual") as unknown as RenderedVisual;
- verifyRational(item.frameRate, "RenderedVisual.frameRate");
- positiveInteger(item.frameCount, "RenderedVisual.frameCount");
- positiveInteger(item.canvas?.width, "RenderedVisual.canvas.width");
- positiveInteger(item.canvas?.height, "RenderedVisual.canvas.height");
- verifyBlob(item.artifact, "RenderedVisual.artifact");
- assert(item.artifact.mediaType.startsWith("video/"), "RenderedVisual Artifact must be video");
+export function verifyTimelineVisual(value: unknown): asserts value is TimelineVisual {
+ const item = object(value, "TimelineVisual") as unknown as TimelineVisual;
+ verifyRational(item.frameRate, "TimelineVisual.frameRate");
+ positiveInteger(item.frameCount, "TimelineVisual.frameCount");
+ positiveInteger(item.canvas?.width, "TimelineVisual.canvas.width");
+ positiveInteger(item.canvas?.height, "TimelineVisual.canvas.height");
+ verifyBlob(item.artifact, "TimelineVisual.artifact");
+ assert(item.artifact.mediaType.startsWith("video/"), "TimelineVisual Artifact must be video");
}
export function sealTimelineAudio(value: TimelineAudio): TimelineAudio {
diff --git a/packages/media/src/index.ts b/packages/media/src/index.ts
index 01a8ca14..bd96c0a2 100644
--- a/packages/media/src/index.ts
+++ b/packages/media/src/index.ts
@@ -1,14 +1,15 @@
export {
decodeMediaAudioSurface,
decodeMediaFontSurface,
+ decodeMediaFontStackSurface,
decodeMediaImageSurface,
decodeMediaVideoSurface,
} from "./surface.js";
export { mediaComponent } from "./component.js";
-export { sealMediaInspection, sealMediaStreamSelection, sealMuxedMedia, sealRenderedVisual, sealSynchronizedMedia, sealTimelineAudio, synchronizedMediaSampleFrames, verifyMediaInspection, verifyMediaStreamSelection, verifyMuxedMedia, verifyRenderedVisual, verifySynchronizedMedia, verifyTimelineAudio } from "./identity.js";
+export { sealMediaInspection, sealMediaStreamSelection, sealMuxedMedia, sealTimelineVisual, sealSynchronizedMedia, sealTimelineAudio, synchronizedMediaSampleFrames, verifyMediaInspection, verifyMediaStreamSelection, verifyMuxedMedia, verifyTimelineVisual, verifySynchronizedMedia, verifyTimelineAudio } from "./identity.js";
export { mediaLocalTemporalDomain } from "./domain.js";
export { mediaDependency, mediaManifest, mediaMarkupSurfaces, mediaModuleRef, mediaProducers, mediaTypes } from "./manifest.js";
-export { compositableSurfaceSchema, fontArtifactSchema, fontStackSchema, mediaInspectionSchema, mediaStreamSelectionSchema, muxedMediaSchema, renderedVisualSchema, synchronizedMediaSchema, timelineAudioSchema } from "./schema.js";
+export { compositableSurfaceSchema, fontArtifactSchema, fontStackSchema, mediaInspectionSchema, mediaStreamSelectionSchema, muxedMediaSchema, timelineVisualSchema, synchronizedMediaSchema, timelineAudioSchema } from "./schema.js";
export { assertCompositableSurfaceRef, assertFontArtifactRef, assertFontStackRef } from "./render.js";
export type * from "./render.js";
export type * from "./types.js";
diff --git a/packages/media/src/manifest.ts b/packages/media/src/manifest.ts
index 3243d54a..85cf8325 100644
--- a/packages/media/src/manifest.ts
+++ b/packages/media/src/manifest.ts
@@ -1,6 +1,6 @@
-import { artifactDependency, artifactTypes } from "@hypit/artifact";
+import { blobDependency, blobTypes } from "@hypit/blob";
import type { ModuleManifest, ProducerRef, TypeRef } from "@hypit/protocol";
-import { compositableSurfaceSchema, fontArtifactSchema, fontStackSchema, mediaInspectionSchema, mediaStreamSelectionSchema, muxedMediaSchema, renderedVisualSchema, synchronizedMediaSchema, timelineAudioSchema } from "./schema.js";
+import { compositableSurfaceSchema, fontArtifactSchema, fontStackSchema, mediaInspectionSchema, mediaStreamSelectionSchema, muxedMediaSchema, timelineVisualSchema, synchronizedMediaSchema, timelineAudioSchema } from "./schema.js";
import { temporalDependency, temporalTypes } from "@hypit/temporal";
export const mediaModuleRef = { name: "@hypit/media", version: "1" } as const;
export const mediaTypes = {
@@ -8,12 +8,12 @@ export const mediaTypes = {
inspection: { module: mediaModuleRef, name: "MediaInspection" },
streamSelection: { module: mediaModuleRef, name: "MediaStreamSelection" }, synchronized: { module: mediaModuleRef, name: "SynchronizedMedia" },
domainSpec: { module: mediaModuleRef, name: "MediaDomainSpec" },
- renderedVisual: { module: mediaModuleRef, name: "RenderedVisual" }, timelineAudio: { module: mediaModuleRef, name: "TimelineAudio" },
+ timelineVisual: { module: mediaModuleRef, name: "TimelineVisual" }, timelineAudio: { module: mediaModuleRef, name: "TimelineAudio" },
muxed: { module: mediaModuleRef, name: "MuxedMedia" }, fontArtifact: { module: mediaModuleRef, name: "FontArtifactRef" },
fontStack: { module: mediaModuleRef, name: "FontStackRef" },
compositableSurface: { module: mediaModuleRef, name: "CompositableSurfaceRef" },
- /** Declared by `@hypit/artifact`. A Type is identified by the Module that owns it, not the one that re-exports it. */
- blobArtifact: artifactTypes.blob,
+ /** Declared by `@hypit/blob`. A Type is identified by the Module that owns it, not the one that re-exports it. */
+ blobArtifact: blobTypes.blob,
} satisfies Record<string, TypeRef>;
export const mediaProducers = {
localDomain: { module: mediaModuleRef, name: "local-domain" },
@@ -21,7 +21,7 @@ export const mediaProducers = {
export const mediaMarkupSurfaces = [
{
- name: "image", tag: "Image", mode: "structured", outputs: [artifactTypes.blob],
+ name: "image", tag: "Image", mode: "structured", outputs: [blobTypes.blob],
vocabulary: {
summary: "Requests one authored image file from the Host and publishes it as a byte Artifact.",
attributes: [
@@ -42,7 +42,7 @@ export const mediaMarkupSurfaces = [
},
},
{
- name: "audio", tag: "Audio", mode: "structured", outputs: [artifactTypes.blob],
+ name: "audio", tag: "Audio", mode: "structured", outputs: [blobTypes.blob],
vocabulary: {
summary: "Requests one authored audio file from the Host and publishes it as a byte Artifact.",
attributes: [
@@ -63,7 +63,7 @@ export const mediaMarkupSurfaces = [
},
},
{
- name: "video", tag: "Video", mode: "structured", outputs: [artifactTypes.blob],
+ name: "video", tag: "Video", mode: "structured", outputs: [blobTypes.blob],
vocabulary: {
summary: "Requests one authored video file from the Host and publishes it as a byte Artifact.",
attributes: [
@@ -86,12 +86,12 @@ export const mediaMarkupSurfaces = [
{
name: "font", tag: "Font", mode: "structured", outputs: [mediaTypes.fontArtifact],
vocabulary: {
- summary: "Requests one authored font file from the Host and publishes it with its exact weight and style as a one-source FontArtifact.",
+ summary: "Publishes one exact font face from one file or several Unicode-range files resolved by the Host.",
attributes: [
{ name: "id", kind: "identifier", required: true,
summary: "Names the FontArtifact Record this element publishes." },
- { name: "src", kind: "literal", required: true,
- summary: "Points at the font file, resolved by the Host against the source that declares it." },
+ { name: "src", kind: "literal", required: false,
+ summary: "Points at a single font file. Omit it when declaring Unicode-range Source children." },
{ name: "weight", kind: "literal", required: true,
summary: "States the exact weight the bytes carry, as a whole number from 1 to 1000." },
{ name: "style", kind: "literal", required: true, values: ["normal", "italic", "oblique"],
@@ -99,26 +99,59 @@ export const mediaMarkupSurfaces = [
{ name: "media-type", kind: "literal", required: false,
summary: "States the font media type when the src extension does not name one." },
],
+ children: [{
+ tag: "Source",
+ cardinality: "many",
+ summary: "Contributes one file shard of the exact face when src is not used.",
+ attributes: [
+ { name: "src", kind: "literal", required: true,
+ summary: "Points at one font file, including a Host-supported package: locator." },
+ { name: "media-type", kind: "literal", required: false,
+ summary: "States the font media type when the src extension does not name one." },
+ { name: "unicode-range", kind: "literal", required: false,
+ summary: "Limits this shard to the declared CSS Unicode range." },
+ ],
+ }],
example: `<media:Font id="brand" src="./assets/Brand-Semibold.woff2" weight="600" style="normal"/>`,
notes: [
- "The element is empty; it accepts no children and no text.",
+ "Use either the src attribute or one or more Source children; mixing the two is an error.",
"`.otf`, `.ttf`, `.woff` and `.woff2` name their own media type; any other file needs `media-type`.",
"One element declares one face, so `weight` and `style` describe these bytes rather than a family.",
"The FontArtifact is published under the bare `id`, and an invalid weight or style fails before any bytes are read.",
],
},
},
+ {
+ name: "font-stack", tag: "FontStack", mode: "structured", outputs: [mediaTypes.fontStack],
+ vocabulary: {
+ summary: "Orders already-authored exact font faces into one primary-plus-fallback stack.",
+ attributes: [
+ { name: "id", kind: "identifier", required: true,
+ summary: "Names the FontStack Record this element publishes." },
+ { name: "primary", kind: "reference", required: true, accepts: [mediaTypes.fontArtifact],
+ summary: "Selects the first exact face used for glyph lookup." },
+ ],
+ children: [{
+ tag: "Fallback",
+ cardinality: "many",
+ summary: "Appends one exact face to the ordered fallback chain.",
+ attributes: [{ name: "font", kind: "reference", required: true, accepts: [mediaTypes.fontArtifact],
+ summary: "References an authored exact FontArtifact." }],
+ }],
+ example: `<media:FontStack id="caption" primary={latin}><media:Fallback font={han}/></media:FontStack>`,
+ },
+ },
] as const;
export const mediaManifest: ModuleManifest = {
- format: "hypit.module@1", name: mediaModuleRef.name, version: mediaModuleRef.version, dependencies: [artifactDependency, temporalDependency],
+ format: "hypit.module@1", name: mediaModuleRef.name, version: mediaModuleRef.version, dependencies: [blobDependency, temporalDependency],
types: [
{ name: mediaTypes.frameRange.name },
{ name: mediaTypes.inspection.name },
{ name: mediaTypes.streamSelection.name },
{ name: mediaTypes.synchronized.name },
{ name: mediaTypes.domainSpec.name },
- { name: mediaTypes.renderedVisual.name },
+ { name: mediaTypes.timelineVisual.name },
{ name: mediaTypes.timelineAudio.name },
{ name: mediaTypes.muxed.name },
{ name: mediaTypes.fontArtifact.name }, { name: mediaTypes.fontStack.name },
diff --git a/packages/media/src/schema.ts b/packages/media/src/schema.ts
index 192f0a3d..5b24c6f3 100644
--- a/packages/media/src/schema.ts
+++ b/packages/media/src/schema.ts
@@ -46,7 +46,7 @@ export const synchronizedMediaSchema: ValueSchema = object({
audio: { schema: object({ artifact: { schema: blobArtifactSchema(["audio/wav"]) } }), optional: true },
});
-export const renderedVisualSchema: ValueSchema = object({ frameRate: { schema: rational }, frameCount: { schema: { kind: "number", integer: true, minimum: 1 } },
+export const timelineVisualSchema: ValueSchema = object({ frameRate: { schema: rational }, frameCount: { schema: { kind: "number", integer: true, minimum: 1 } },
canvas: { schema: object({ width: { schema: { kind: "number", integer: true, minimum: 1 } }, height: { schema: { kind: "number", integer: true, minimum: 1 } } }) },
artifact: { schema: blobArtifactSchema() } });
export const timelineAudioSchema: ValueSchema = object({ artifact: { schema: blobArtifactSchema(["audio/wav"]) },
diff --git a/packages/media/src/surface.ts b/packages/media/src/surface.ts
index 8a40b243..af087109 100644
--- a/packages/media/src/surface.ts
+++ b/packages/media/src/surface.ts
@@ -1,6 +1,7 @@
-import { artifactTypes } from "@hypit/artifact";
+import { blobTypes } from "@hypit/blob";
import type { StructuredElement, StructuredSurfaceHandler } from "@hypit/markup";
-import { assertFontArtifactRef } from "./render.js";
+import type { FontArtifactRef } from "./render.js";
+import { assertFontArtifactRef, assertFontStackRef } from "./render.js";
import { mediaTypes } from "./manifest.js";
const IMAGE_MEDIA_TYPES = new Map([
@@ -51,6 +52,24 @@ function assertChildrenEmpty(element: StructuredElement): void {
}
}
+function localName(name: string): string {
+ const colon = name.lastIndexOf(":");
+ return colon < 0 ? name : name.slice(colon + 1);
+}
+
+function assertAttributes(
+ element: StructuredElement,
+ required: readonly string[],
+ optional: readonly string[] = [],
+): void {
+ const allowed = new Set([...required, ...optional]);
+ const actual = Object.keys(element.attributes);
+ if (required.some((name) => element.attributes[name] === undefined) || actual.some((name) => !allowed.has(name))) {
+ const suffix = optional.length === 0 ? "" : `, with optional ${optional.join(", ")}`;
+ throw new Error(`${element.name} requires ${required.join(", ")}${suffix}`);
+ }
+}
+
function mediaTypeFor(
element: StructuredElement,
source: string,
@@ -95,7 +114,7 @@ async function decodeMediaAssetSurface(
return {
records: [{
id,
- type: artifactTypes.blob,
+ type: blobTypes.blob,
value: resolved.artifact,
range: element.range,
}],
@@ -114,13 +133,8 @@ export const decodeMediaVideoSurface: StructuredSurfaceHandler = async ({ elemen
await decodeMediaAssetSurface(element, resolveAsset, "video", VIDEO_MEDIA_TYPES);
export const decodeMediaFontSurface: StructuredSurfaceHandler = async ({ element, resolveAsset }) => {
- const names = Object.keys(element.attributes).sort();
- if (names.join(",") !== "id,src,style,weight" && names.join(",") !== "id,media-type,src,style,weight") {
- throw new Error(`${element.name} requires id, src, weight and style, with optional media-type`);
- }
- assertChildrenEmpty(element);
+ assertAttributes(element, ["id", "weight", "style"], ["src", "media-type"]);
const id = stringAttribute(element, "id");
- const source = stringAttribute(element, "src");
const weight = Number(stringAttribute(element, "weight"));
if (!Number.isSafeInteger(weight) || weight < 1 || weight > 1_000) {
throw new Error(`${element.name}.weight must be an integer from 1 to 1000`);
@@ -130,10 +144,45 @@ export const decodeMediaFontSurface: StructuredSurfaceHandler = async ({ element
throw new Error(`${element.name}.style must be normal, italic or oblique`);
}
const fontStyle = style as "normal" | "italic" | "oblique";
- const mediaType = mediaTypeFor(element, source, "font", FONT_MEDIA_TYPES);
- const resolved = await resolveAsset({ from: source, mediaType, range: element.range });
+ const sourceAttribute = element.attributes.src;
+ const sourceChildren = element.children.filter((child): child is StructuredElement => child.kind === "element");
+ if (element.children.some((child) => child.kind === "text" && child.value.trim().length > 0)) {
+ throw new Error(`${element.name} accepts only Source children`);
+ }
+ if (sourceAttribute !== undefined && sourceChildren.length > 0) {
+ throw new Error(`${element.name} must use either src or Source children, not both`);
+ }
+ if (sourceAttribute === undefined && sourceChildren.length === 0) {
+ throw new Error(`${element.name} requires src or one or more Source children`);
+ }
+ if (sourceAttribute === undefined && element.attributes["media-type"] !== undefined) {
+ throw new Error(`${element.name}.media-type belongs on each Source when the face has multiple sources`);
+ }
+ const declarations = sourceAttribute === undefined
+ ? sourceChildren.map((child) => {
+ if (localName(child.name) !== "Source") throw new Error(`${element.name} accepts only Source children`);
+ assertAttributes(child, ["src"], ["media-type", "unicode-range"]);
+ assertChildrenEmpty(child);
+ return {
+ element: child,
+ source: stringAttribute(child, "src"),
+ unicodeRange: child.attributes["unicode-range"] === undefined
+ ? undefined
+ : stringAttribute(child, "unicode-range"),
+ };
+ })
+ : [{ element, source: stringAttribute(element, "src"), unicodeRange: undefined }];
+ const sources: FontArtifactRef["sources"][number][] = [];
+ for (const declaration of declarations) {
+ const mediaType = mediaTypeFor(declaration.element, declaration.source, "font", FONT_MEDIA_TYPES);
+ const resolved = await resolveAsset({ from: declaration.source, mediaType, range: declaration.element.range });
+ sources.push({
+ artifact: resolved.artifact,
+ ...(declaration.unicodeRange === undefined ? {} : { unicodeRange: declaration.unicodeRange }),
+ });
+ }
const font = {
- sources: [{ artifact: resolved.artifact }],
+ sources,
weight,
style: fontStyle,
};
@@ -144,3 +193,44 @@ export const decodeMediaFontSurface: StructuredSurfaceHandler = async ({ element
fragments: [],
};
};
+
+function sameType(left: { readonly module: { readonly name: string; readonly version: string }; readonly name: string }, right: typeof mediaTypes.fontArtifact): boolean {
+ return left.module.name === right.module.name && left.module.version === right.module.version && left.name === right.name;
+}
+
+export const decodeMediaFontStackSurface: StructuredSurfaceHandler = ({ element, resolveReference }) => {
+ assertAttributes(element, ["id", "primary"]);
+ const id = stringAttribute(element, "id");
+ const faces: FontArtifactRef[] = [];
+ const append = (owner: StructuredElement, name: string): void => {
+ const raw = owner.attributes[name];
+ if (typeof raw !== "object" || raw.kind !== "reference") {
+ throw new Error(`${owner.name}.${name} must be a whole-value reference`);
+ }
+ const resolved = resolveReference(raw.path);
+ if (resolved === undefined) throw new Error(`${owner.name}.${name} cannot resolve ${raw.path}`);
+ if (!sameType(resolved.type, mediaTypes.fontArtifact)) throw new Error(`${owner.name}.${name} has the wrong type`);
+ if (resolved.record?.value.kind !== "inline") {
+ throw new Error(`${owner.name}.${name} must reference an authored inline FontArtifact`);
+ }
+ faces.push(resolved.record.value.value as unknown as FontArtifactRef);
+ };
+ append(element, "primary");
+ for (const child of element.children) {
+ if (child.kind === "text") {
+ if (child.value.trim()) throw new Error(`${element.name} accepts only Fallback children`);
+ continue;
+ }
+ if (localName(child.name) !== "Fallback") throw new Error(`${element.name} accepts only Fallback children`);
+ assertAttributes(child, ["font"]);
+ assertChildrenEmpty(child);
+ append(child, "font");
+ }
+ const stack = { faces };
+ assertFontStackRef(stack, `${element.name}.${id}`);
+ return {
+ records: [{ id, type: mediaTypes.fontStack, value: { kind: "inline", value: stack }, range: element.range }],
+ components: [],
+ fragments: [],
+ };
+};
diff --git a/packages/media/src/types.ts b/packages/media/src/types.ts
index 7f33e151..1edc0251 100644
--- a/packages/media/src/types.ts
+++ b/packages/media/src/types.ts
@@ -95,8 +95,8 @@ export type SynchronizedMedia = {
/** Identity for deriving an author-visible local temporal domain from normalized media. */
export type MediaDomainSpec = { readonly id: string };
-/** Silent, frame-exact visual output from a renderer such as HyperFrames. */
-export type RenderedVisual = {
+/** Silent, frame-exact visual output produced from a timeline composition. */
+export type TimelineVisual = {
readonly frameRate: MediaRational;
readonly frameCount: number;
readonly canvas: {
diff --git a/packages/media/test/asset-surface.test.ts b/packages/media/test/asset-surface.test.ts
index 40b0f61e..14351b19 100644
--- a/packages/media/test/asset-surface.test.ts
+++ b/packages/media/test/asset-surface.test.ts
@@ -15,7 +15,7 @@ for (const fixture of [
{ label: "Audio", decode: decodeMediaAudioSurface, src: "./reference.wav", mediaType: "audio/wav" },
{ label: "Video", decode: decodeMediaVideoSurface, src: "./reference.mp4", mediaType: "video/mp4" },
] as const) {
- test(`${fixture.label} Surface publishes the resolved BlobArtifact`, async () => {
+ test(`${fixture.label} Surface publishes the resolved Blob`, async () => {
const artifact = {
kind: "blob" as const,
resource: fixtureResource(`media:${fixture.label.toLowerCase()}`),
@@ -41,7 +41,7 @@ for (const fixture of [
assert.deepEqual(requests, [{ from: fixture.src, mediaType: fixture.mediaType, range }]);
assert.deepEqual(result.records, [{ id: "reference", type: {
- module: { name: "@hypit/artifact", version: "1" }, name: "BlobArtifact",
+ module: { name: "@hypit/blob", version: "1" }, name: "Blob",
}, value: artifact, range }]);
});
}
diff --git a/packages/media/test/font-surface.test.ts b/packages/media/test/font-surface.test.ts
index ccfa4768..bcaaa372 100644
--- a/packages/media/test/font-surface.test.ts
+++ b/packages/media/test/font-surface.test.ts
@@ -2,7 +2,7 @@ import assert from "node:assert/strict";
import test from "node:test";
import { fixtureResource } from "../../../test/fixture-resource.js";
-import { decodeMediaFontSurface, mediaTypes } from "@hypit/media";
+import { decodeMediaFontStackSurface, decodeMediaFontSurface, mediaTypes } from "@hypit/media";
const range = { start: 0, end: 80 };
@@ -63,3 +63,92 @@ test("Font Surface rejects ambiguous files and invalid face metadata before acce
await assert.rejects(async () => await decode({ id: "font", src: "./font.ttf", weight: "heavy", style: "normal" }), /integer/u);
await assert.rejects(async () => await decode({ id: "font", src: "./font.ttf", weight: "700", style: "slanted" }), /normal, italic or oblique/u);
});
+
+test("Font Surface preserves package assets and Unicode-range shards as one exact face", async () => {
+ const result = await decodeMediaFontSurface({
+ sourceName: "main.svml",
+ element: {
+ kind: "element",
+ name: "media:Font",
+ attributes: { id: "han", weight: "600", style: "normal" },
+ children: [{
+ kind: "element",
+ name: "media:Source",
+ attributes: {
+ src: "package:@company/type/files/han-1.woff2",
+ "unicode-range": "U+4E00-9FFF",
+ },
+ children: [],
+ range,
+ }],
+ range,
+ },
+ resolveReference: () => undefined,
+ resolveAsset: (request) => ({
+ artifact: {
+ kind: "blob",
+ resource: fixtureResource(`font:${request.from}`),
+ size: 1_024,
+ mediaType: request.mediaType,
+ },
+ }),
+ });
+ assert.deepEqual(result.records[0]!.value, {
+ kind: "inline",
+ value: {
+ sources: [{
+ artifact: {
+ kind: "blob",
+ resource: fixtureResource("font:package:@company/type/files/han-1.woff2"),
+ size: 1_024,
+ mediaType: "font/woff2",
+ },
+ unicodeRange: "U+4E00-9FFF",
+ }],
+ weight: 600,
+ style: "normal",
+ },
+ });
+});
+
+test("FontStack Surface orders generic FontArtifact records without knowing their source", async () => {
+ const face = (id: string) => ({
+ path: id,
+ ref: { kind: "record" as const, id },
+ type: mediaTypes.fontArtifact,
+ record: {
+ id,
+ type: mediaTypes.fontArtifact,
+ value: { kind: "inline" as const, value: {
+ sources: [{ artifact: {
+ kind: "blob" as const,
+ resource: fixtureResource(`font:${id}`),
+ size: 1_024,
+ mediaType: "font/woff2",
+ } }],
+ weight: 600,
+ style: "normal",
+ } },
+ },
+ });
+ const result = await decodeMediaFontStackSurface({
+ sourceName: "main.svml",
+ element: {
+ kind: "element",
+ name: "media:FontStack",
+ attributes: { id: "caption", primary: { kind: "reference", path: "latin" } },
+ children: [{
+ kind: "element",
+ name: "media:Fallback",
+ attributes: { font: { kind: "reference", path: "han" } },
+ children: [],
+ range,
+ }],
+ range,
+ },
+ resolveReference: (path) => path === "latin" || path === "han" ? face(path) : undefined,
+ resolveAsset: () => { throw new Error("FontStack resolves values, not assets"); },
+ });
+ assert.deepEqual(result.records[0]!.type, mediaTypes.fontStack);
+ assert.equal((result.records[0]!.value as unknown as { value: { faces: unknown[] } }).value.faces.length, 2);
+});
diff --git a/packages/narrative-alignment-adjust/package.json b/packages/narrative-alignment-adjust/package.json
deleted file mode 100644
index fe33975b..00000000
--- a/packages/narrative-alignment-adjust/package.json
+++ /dev/null
@@ -1,22 +0,0 @@
-{
- "name": "@hypit/narrative-alignment-adjust",
- "version": "0.0.0-dev",
- "license": "SEE LICENSE IN LICENSE",
- "private": true,
- "type": "module",
- "exports": {
- ".": "./src/index.ts"
- },
- "hypit": {
- "activation": "./src/activation.ts"
- },
- "dependencies": {
- "@hypit/component-kit": "workspace:*",
- "@hypit/elaborator": "workspace:*",
- "@hypit/markup": "workspace:*",
- "@hypit/narrative": "workspace:*",
- "@hypit/protocol": "workspace:*",
- "@hypit/narrative-temporal": "workspace:*",
- "@hypit/temporal": "workspace:*"
- }
-}
diff --git a/packages/narrative-alignment-adjust/src/activation.ts b/packages/narrative-alignment-adjust/src/activation.ts
deleted file mode 100644
index 83267b9d..00000000
--- a/packages/narrative-alignment-adjust/src/activation.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-import { createMarkupSurfaceHostFacet } from "@hypit/markup";
-
-import {
- decodeNarrativeAlignmentAdjustSurface,
- narrativeAlignmentAdjustComponent,
- narrativeAlignmentAdjustManifest,
- narrativeAlignmentAdjustMarkupSurfaces,
- narrativeAlignmentAdjustModuleRef,
-} from "./index.js";
-
-export const hypitPackage = {
- format: "hypit.node-package@1" as const,
- modules: [{ manifest: narrativeAlignmentAdjustManifest }],
- components: [narrativeAlignmentAdjustComponent],
- hostFacets: [createMarkupSurfaceHostFacet({
- module: narrativeAlignmentAdjustModuleRef,
- declaration: narrativeAlignmentAdjustMarkupSurfaces.find((item) => item.name === "narrative-alignment")!,
- handler: decodeNarrativeAlignmentAdjustSurface,
- })],
-};
-
-export default hypitPackage;
diff --git a/packages/narrative-alignment-adjust/src/component.ts b/packages/narrative-alignment-adjust/src/component.ts
deleted file mode 100644
index 51a03315..00000000
--- a/packages/narrative-alignment-adjust/src/component.ts
+++ /dev/null
@@ -1,33 +0,0 @@
-import type { ComponentPackage } from "@hypit/component-kit";
-import { canonicalize } from "@hypit/protocol";
-import type { StoredValue } from "@hypit/protocol";
-import type { NarrativeAlignment } from "@hypit/narrative-temporal";
-import type { LocalTemporalDomain } from "@hypit/temporal";
-
-import { narrativeAlignmentAdjustProducers } from "./manifest.js";
-import { adjustNarrativeAlignment } from "./program.js";
-import type { NarrativeAlignmentAdjustmentPlan } from "./types.js";
-
-function inline<T>(value: StoredValue | undefined, subject: string): T {
- if (value?.kind !== "inline") throw new Error(`${subject} must be inline.`);
- return value.value as unknown as T;
-}
-
-export const narrativeAlignmentAdjustComponent = {
- producers: [{
- producer: narrativeAlignmentAdjustProducers.adjust,
- handler: ({ inputs }) => ({
- outputs: {
- alignment: {
- kind: "inline",
- value: canonicalize(adjustNarrativeAlignment(
- inline<NarrativeAlignment>(inputs.source?.value, "NarrativeAlignment"),
- inline<LocalTemporalDomain>(inputs.domain?.value, "LocalTemporalDomain"),
- inline<NarrativeAlignmentAdjustmentPlan>(inputs.plan?.value, "NarrativeAlignment adjustment plan"),
- )),
- },
- },
- needs: {},
- }),
- }],
-} satisfies ComponentPackage;
diff --git a/packages/narrative-alignment-adjust/src/fragment.ts b/packages/narrative-alignment-adjust/src/fragment.ts
deleted file mode 100644
index c5ca3dbf..00000000
--- a/packages/narrative-alignment-adjust/src/fragment.ts
+++ /dev/null
@@ -1,26 +0,0 @@
-import { sealGraphFragment } from "@hypit/elaborator";
-import { narrativeTemporalTypes } from "@hypit/narrative-temporal";
-import { temporalTypes } from "@hypit/temporal";
-
-import { narrativeAlignmentAdjustProducers, narrativeAlignmentAdjustTypes } from "./manifest.js";
-
-const input = (name: string) => ({ kind: "fragment-input" as const, name });
-
-export const narrativeAlignmentAdjustFragment = sealGraphFragment({
- inputs: [
- { name: "source", type: narrativeTemporalTypes.narrativeAlignment },
- { name: "domain", type: temporalTypes.localDomain },
- { name: "plan", type: narrativeAlignmentAdjustTypes.plan },
- ],
- operations: [{
- id: "adjust",
- producer: narrativeAlignmentAdjustProducers.adjust,
- inputs: { source: input("source"), domain: input("domain"), plan: input("plan") },
- result: { kind: "output", name: "alignment" },
- }],
- exports: [{
- name: "alignment",
- type: narrativeTemporalTypes.narrativeAlignment,
- root: { kind: "fragment-operation", operation: "adjust" },
- }],
-});
diff --git a/packages/narrative-alignment-adjust/src/index.ts b/packages/narrative-alignment-adjust/src/index.ts
deleted file mode 100644
index ca93e1de..00000000
--- a/packages/narrative-alignment-adjust/src/index.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-export { narrativeAlignmentAdjustComponent } from "./component.js";
-export { narrativeAlignmentAdjustFragment } from "./fragment.js";
-export {
- narrativeAlignmentAdjustManifest,
- narrativeAlignmentAdjustMarkupSurfaces,
- narrativeAlignmentAdjustModuleRef,
- narrativeAlignmentAdjustProducers,
- narrativeAlignmentAdjustTypes,
-} from "./manifest.js";
-export { adjustNarrativeAlignment } from "./program.js";
-export { decodeNarrativeAlignmentAdjustSurface } from "./surface.js";
-export type { NarrativeAlignmentAdjustmentPlan, NarrativeBoundaryAdjustment } from "./types.js";
diff --git a/packages/narrative-alignment-adjust/src/manifest.ts b/packages/narrative-alignment-adjust/src/manifest.ts
deleted file mode 100644
index 6c731da5..00000000
--- a/packages/narrative-alignment-adjust/src/manifest.ts
+++ /dev/null
@@ -1,61 +0,0 @@
-import { narrativeDependency } from "@hypit/narrative";
-import type { ModuleManifest, ProducerRef, TypeRef } from "@hypit/protocol";
-import { narrativeTemporalDependency, narrativeTemporalTypes } from "@hypit/narrative-temporal";
-import { temporalDependency, temporalTypes } from "@hypit/temporal";
-
-export const narrativeAlignmentAdjustModuleRef = { name: "@hypit/narrative-alignment-adjust", version: "1" } as const;
-
-export const narrativeAlignmentAdjustTypes = {
- plan: { module: narrativeAlignmentAdjustModuleRef, name: "NarrativeAlignmentAdjustmentPlan" },
-} satisfies Record<string, TypeRef>;
-
-export const narrativeAlignmentAdjustProducers = {
- adjust: { module: narrativeAlignmentAdjustModuleRef, name: "adjust-narrative-alignment" },
-} satisfies Record<string, ProducerRef>;
-
-export const narrativeAlignmentAdjustMarkupSurfaces = [{
- name: "narrative-alignment",
- tag: "NarrativeAlignment",
- mode: "structured",
- outputs: [narrativeAlignmentAdjustTypes.plan, narrativeTemporalTypes.narrativeAlignment],
- vocabulary: {
- summary: "Applies explicit author corrections to measured NarrativeAlignment boundary frames.",
- attributes: [
- { name: "id", kind: "identifier", required: true,
- summary: "Names the corrected alignment." },
- { name: "source", kind: "reference", required: true, accepts: [narrativeTemporalTypes.narrativeAlignment],
- summary: "Selects the measured NarrativeAlignment being corrected." },
- { name: "domain", kind: "reference", required: true, accepts: [temporalTypes.localDomain],
- summary: "Selects the source-local domain that bounds the corrected frames." },
- ],
- ports: [{ name: "alignment", type: narrativeTemporalTypes.narrativeAlignment,
- summary: "The corrected NarrativeAlignment, addressed as `<id>.alignment`." }],
- example: `<adjust:NarrativeAlignment id="opening-corrected" source={opening.alignment} domain={opening.domain}>
- <adjust:Boundary at={story.moment.answer} frame="63"/>
-</adjust:NarrativeAlignment>`,
- notes: [
- "Each Boundary names an author-declared Script Moment and gives its exact source-local frame.",
- "This is an explicit correction layer over measured evidence; it does not guess timing or modify media.",
- "Segment and Token records refer to canonical boundaries, so no duplicate coordinates need synchronizing.",
- ],
- },
-}] as const;
-
-export const narrativeAlignmentAdjustManifest: ModuleManifest = {
- format: "hypit.module@1",
- name: narrativeAlignmentAdjustModuleRef.name,
- version: narrativeAlignmentAdjustModuleRef.version,
- dependencies: [narrativeDependency, narrativeTemporalDependency, temporalDependency],
- types: [{ name: narrativeAlignmentAdjustTypes.plan.name }],
- capabilities: [],
- producers: [{
- name: narrativeAlignmentAdjustProducers.adjust.name,
- inputs: [
- { name: "source", type: narrativeTemporalTypes.narrativeAlignment },
- { name: "domain", type: temporalTypes.localDomain },
- { name: "plan", type: narrativeAlignmentAdjustTypes.plan },
- ],
- outputs: [{ name: "alignment", type: narrativeTemporalTypes.narrativeAlignment }],
- needs: [],
- }],
-};
diff --git a/packages/narrative-alignment-adjust/src/program.ts b/packages/narrative-alignment-adjust/src/program.ts
deleted file mode 100644
index 3a4dc9ef..00000000
--- a/packages/narrative-alignment-adjust/src/program.ts
+++ /dev/null
@@ -1,42 +0,0 @@
-import { assertNarrativeAlignmentIdentity, sealNarrativeAlignment } from "@hypit/narrative-temporal";
-import type { NarrativeAlignment } from "@hypit/narrative-temporal";
-import { assertLocalTemporalDomain } from "@hypit/temporal";
-import type { LocalTemporalDomain } from "@hypit/temporal";
-
-import type { NarrativeAlignmentAdjustmentPlan } from "./types.js";
-
-export function adjustNarrativeAlignment(
- source: NarrativeAlignment,
- domain: LocalTemporalDomain,
- plan: NarrativeAlignmentAdjustmentPlan,
-): NarrativeAlignment {
- assertLocalTemporalDomain(domain);
- assertNarrativeAlignmentIdentity(source, domain);
- if (plan.narrativeId !== source.narrativeId) {
- throw new Error(`NarrativeAlignment adjustment belongs to Narrative ${plan.narrativeId}, not ${source.narrativeId}.`);
- }
- if (plan.boundaries.length === 0) throw new Error("NarrativeAlignment adjustment requires at least one boundary.");
-
- const sourceBoundaryIds = new Set(source.boundaries.map((boundary) => boundary.id));
- const adjusted = new Map<string, number>();
- for (const boundary of plan.boundaries) {
- if (!sourceBoundaryIds.has(boundary.boundaryId)) {
- throw new Error(`NarrativeAlignment does not contain boundary ${boundary.boundaryId}.`);
- }
- if (adjusted.has(boundary.boundaryId)) {
- throw new Error(`NarrativeAlignment boundary ${boundary.boundaryId} is adjusted more than once.`);
- }
- if (!Number.isSafeInteger(boundary.frame) || boundary.frame < 0 || boundary.frame > domain.frameCount) {
- throw new Error(`NarrativeAlignment boundary ${boundary.boundaryId} has an invalid adjusted frame.`);
- }
- adjusted.set(boundary.boundaryId, boundary.frame);
- }
-
- return sealNarrativeAlignment({
- ...source,
- boundaries: source.boundaries.map((boundary) => ({
- ...boundary,
- frame: adjusted.get(boundary.id) ?? boundary.frame,
- })),
- }, domain);
-}
diff --git a/packages/narrative-alignment-adjust/src/surface.ts b/packages/narrative-alignment-adjust/src/surface.ts
deleted file mode 100644
index f08f7e18..00000000
--- a/packages/narrative-alignment-adjust/src/surface.ts
+++ /dev/null
@@ -1,98 +0,0 @@
-import {
- assertExactAttributes,
- localName,
- textAttribute,
-} from "@hypit/markup";
-import type {
- MarkupAttributeValue,
- StructuredElement,
- StructuredSurfaceHandler,
- SurfaceResolvedReference,
-} from "@hypit/markup";
-import { narrativeTypes } from "@hypit/narrative";
-import type { NarrativeMomentRef } from "@hypit/narrative";
-import { canonicalize, sameType } from "@hypit/protocol";
-import { narrativeTemporalTypes } from "@hypit/narrative-temporal";
-import { temporalTypes } from "@hypit/temporal";
-
-import { narrativeAlignmentAdjustFragment } from "./fragment.js";
-import { narrativeAlignmentAdjustTypes } from "./manifest.js";
-import type { NarrativeAlignmentAdjustmentPlan } from "./types.js";
-
-function reference(
- element: StructuredElement,
- name: string,
- expected: SurfaceResolvedReference["type"],
- resolveReference: (path: string) => SurfaceResolvedReference | undefined,
-): SurfaceResolvedReference {
- const raw: MarkupAttributeValue | undefined = element.attributes[name];
- if (typeof raw !== "object" || raw.kind !== "reference") {
- throw new Error(`${element.name}.${name} must be a whole-value reference.`);
- }
- const resolved = resolveReference(raw.path);
- if (resolved === undefined) throw new Error(`${element.name}.${name} cannot resolve ${raw.path}.`);
- if (!sameType(resolved.type, expected)) throw new Error(`${element.name}.${name} has the wrong type.`);
- return resolved;
-}
-
-function inline<T>(value: SurfaceResolvedReference, subject: string): T {
- if (value.record?.value.kind !== "inline") throw new Error(`${subject} must reference an authored inline Record.`);
- return value.record.value.value as unknown as T;
-}
-
-function frameAttribute(element: StructuredElement): number {
- const value = Number(textAttribute(element, "frame"));
- if (!Number.isSafeInteger(value) || value < 0) throw new Error(`${element.name}.frame must be a non-negative integer.`);
- return value;
-}
-
-export const decodeNarrativeAlignmentAdjustSurface: StructuredSurfaceHandler = ({ element, resolveReference }) => {
- assertExactAttributes(element, ["id", "source", "domain"]);
- const id = textAttribute(element, "id");
- const source = reference(element, "source", narrativeTemporalTypes.narrativeAlignment, resolveReference);
- const domain = reference(element, "domain", temporalTypes.localDomain, resolveReference);
- const moments: NarrativeMomentRef[] = [];
- const boundaries: NarrativeAlignmentAdjustmentPlan["boundaries"][number][] = [];
-
- for (const child of element.children) {
- if (child.kind === "text") {
- if (child.value.trim()) throw new Error(`${element.name} accepts only Boundary children.`);
- continue;
- }
- if (localName(child.name) !== "Boundary") throw new Error(`${element.name} accepts only Boundary children.`);
- assertExactAttributes(child, ["at", "frame"]);
- if (child.children.some((item) => item.kind === "element" || item.value.trim())) {
- throw new Error(`${child.name} must be empty.`);
- }
- const moment = inline<NarrativeMomentRef>(
- reference(child, "at", narrativeTypes.moment, resolveReference),
- `${child.name}.at`,
- );
- moments.push(moment);
- boundaries.push({ boundaryId: moment.anchorId, frame: frameAttribute(child) });
- }
- if (boundaries.length === 0) throw new Error(`${element.name} requires at least one Boundary child.`);
- const narrativeId = moments[0]!.narrativeId;
- if (moments.some((moment) => moment.narrativeId !== narrativeId)) {
- throw new Error(`${element.name} cannot mix Moments from different Narratives.`);
- }
-
- const planId = `${id}.plan`;
- const plan: NarrativeAlignmentAdjustmentPlan = { narrativeId, boundaries };
- return {
- records: [{
- id: planId,
- type: narrativeAlignmentAdjustTypes.plan,
- value: { kind: "inline", value: canonicalize(plan) },
- range: element.range,
- }],
- components: [{
- id,
- fragment: narrativeAlignmentAdjustFragment.id,
- inputs: { source: source.ref, domain: domain.ref, plan: { kind: "record", id: planId } },
- outputs: { alignment: `${id}.alignment` },
- range: element.range,
- }],
- fragments: [narrativeAlignmentAdjustFragment],
- };
-};
diff --git a/packages/narrative-alignment-adjust/src/types.ts b/packages/narrative-alignment-adjust/src/types.ts
deleted file mode 100644
index e2ff828a..00000000
--- a/packages/narrative-alignment-adjust/src/types.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-export type NarrativeBoundaryAdjustment = {
- readonly boundaryId: string;
- readonly frame: number;
-};
-
-export type NarrativeAlignmentAdjustmentPlan = {
- readonly narrativeId: string;
- readonly boundaries: readonly NarrativeBoundaryAdjustment[];
-};
diff --git a/packages/narrative-alignment-adjust/test/narrative-alignment-adjust.test.ts b/packages/narrative-alignment-adjust/test/narrative-alignment-adjust.test.ts
deleted file mode 100644
index 5b05d0ba..00000000
--- a/packages/narrative-alignment-adjust/test/narrative-alignment-adjust.test.ts
+++ /dev/null
@@ -1,36 +0,0 @@
-import assert from "node:assert/strict";
-import test from "node:test";
-
-import { adjustNarrativeAlignment } from "../src/program.js";
-
-const domain = { id: "voice", frameRate: { numerator: 30, denominator: 1 }, frameCount: 90 };
-const alignment = {
- narrativeId: "story",
- domainId: "voice",
- segment: { segmentId: "opening", startBoundaryId: "opening:start", endBoundaryId: "opening:end" },
- tokens: [{ tokenId: "hello", segmentId: "opening", text: "hello", startBoundaryId: "hello:start", endBoundaryId: "hello:end" }],
- boundaries: [
- { id: "opening:start", frame: 0 },
- { id: "hello:start", frame: 10 },
- { id: "hello:end", frame: 40 },
- { id: "opening:end", frame: 90 },
- ],
-};
-
-test("alignment correction changes one canonical boundary and no media", () => {
- const adjusted = adjustNarrativeAlignment(alignment, domain, {
- narrativeId: "story", boundaries: [{ boundaryId: "hello:end", frame: 45 }],
- });
- assert.equal(adjusted.boundaries.find((item) => item.id === "hello:end")?.frame, 45);
- assert.deepEqual(adjusted.tokens, alignment.tokens);
- assert.equal("media" in adjusted, false);
-});
-
-test("alignment correction rejects unknown and out-of-domain boundaries", () => {
- assert.throws(() => adjustNarrativeAlignment(alignment, domain, {
- narrativeId: "story", boundaries: [{ boundaryId: "missing", frame: 1 }],
- }), /does not contain/);
- assert.throws(() => adjustNarrativeAlignment(alignment, domain, {
- narrativeId: "story", boundaries: [{ boundaryId: "hello:end", frame: 91 }],
- }), /invalid adjusted frame/);
-});
diff --git a/packages/narrative-caption/package.json b/packages/narrative-caption/package.json
index 3860f125..341b9ae8 100644
--- a/packages/narrative-caption/package.json
+++ b/packages/narrative-caption/package.json
@@ -12,11 +12,12 @@
},
"dependencies": {
"@hypit/caption": "workspace:*",
- "@hypit/component-kit": "workspace:*",
- "@hypit/elaborator": "workspace:*",
+ "@hypit/producer": "workspace:*",
+ "@hypit/author": "workspace:*",
"@hypit/markup": "workspace:*",
"@hypit/narrative": "workspace:*",
"@hypit/protocol": "workspace:*",
- "@hypit/narrative-temporal": "workspace:*"
+ "@hypit/narrative-temporal": "workspace:*",
+ "@hypit/admission": "workspace:*"
}
}
diff --git a/packages/narrative-caption/src/activation.ts b/packages/narrative-caption/src/activation.ts
index 6ddcf0a4..dbf6100d 100644
--- a/packages/narrative-caption/src/activation.ts
+++ b/packages/narrative-caption/src/activation.ts
@@ -1,4 +1,6 @@
-import { createMarkupSurfaceHostFacet } from "@hypit/markup";
+import { createAdmissionPackageFacet } from "@hypit/admission";
+import { createProducerPackageFacet } from "@hypit/producer";
+import { createMarkupSurfaceFacet } from "@hypit/markup";
import {
decodeNarrativeCaptionTimingSurface,
@@ -9,10 +11,10 @@ import {
} from "./index.js";
export const hypitPackage = {
- format: "hypit.node-package@1" as const,
+ format: "hypit.package@1" as const,
modules: [{ manifest: narrativeCaptionManifest }],
- components: [narrativeCaptionComponent],
- hostFacets: [createMarkupSurfaceHostFacet({
+ facets: [
+ ...[narrativeCaptionComponent].flatMap((component) => [createProducerPackageFacet(component), createAdmissionPackageFacet(component)]),createMarkupSurfaceFacet({
module: narrativeCaptionModuleRef,
declaration: narrativeCaptionTimingMarkupSurface,
handler: decodeNarrativeCaptionTimingSurface,
diff --git a/packages/narrative-caption/src/component.ts b/packages/narrative-caption/src/component.ts
index 020daee3..0d0c2759 100644
--- a/packages/narrative-caption/src/component.ts
+++ b/packages/narrative-caption/src/component.ts
@@ -1,5 +1,6 @@
+import type { AdmissionPackage } from "@hypit/admission";
import type { CaptionDocument, CaptionTiming } from "@hypit/caption";
-import type { ComponentPackage } from "@hypit/component-kit";
+import type { ProducerPackage } from "@hypit/producer";
import type { StoredValue } from "@hypit/protocol";
import { canonicalize } from "@hypit/protocol";
import type { NarrativeProjection } from "@hypit/narrative-temporal";
@@ -30,4 +31,4 @@ export const narrativeCaptionComponent = {
type: narrativeCaptionTypes.binding,
handler: ({ value }) => assertNarrativeCaptionBindingIdentity(inline<NarrativeCaptionBinding>(value, "NarrativeCaptionBinding")),
}],
-} satisfies ComponentPackage;
+} satisfies ProducerPackage & AdmissionPackage;
diff --git a/packages/narrative-caption/src/surface.ts b/packages/narrative-caption/src/surface.ts
index da7f9869..1461a823 100644
--- a/packages/narrative-caption/src/surface.ts
+++ b/packages/narrative-caption/src/surface.ts
@@ -1,5 +1,5 @@
import { captionTypes } from "@hypit/caption";
-import { sealGraphFragment } from "@hypit/elaborator";
+import { sealGraphFragment } from "@hypit/author";
import {
assertAttributes,
assertEmptyElement,
diff --git a/packages/speech-alignment/README.md b/packages/narrative-speech-alignment/README.md
similarity index 86%
rename from packages/speech-alignment/README.md
rename to packages/narrative-speech-alignment/README.md
index caa0793e..38a31770 100644
--- a/packages/speech-alignment/README.md
+++ b/packages/narrative-speech-alignment/README.md
@@ -1,4 +1,4 @@
-# `@hypit/speech-alignment`
+# `@hypit/narrative-speech-alignment`
Provider-neutral deterministic timing locator for one authored Segment on a normalized local temporal
domain. The package does not
@@ -6,6 +6,11 @@ invoke Python, read audio, call a speech provider, use an LLM, infer speakers or
candidate paths. A runtime adapter preserves its raw provider artifact and supplies the normalized
word, character, score and speech-activity evidence used here in exact 16 kHz sample coordinates.
+This is an independently versioned and packaged algorithm, not a root SDK facade and not a WhisperX
+implementation. The official Distribution obtains it through `@hypit/whisperx`'s ordinary npm
+dependency; another package producing the same provider-neutral evidence may depend on it directly.
+The project package manager and lockfile own the selected physical version.
+
The locator aligns one explicitly connected Script Segment against acoustic evidence carrying that
same local domain identity and exact evidence sample span. A bounded monotonic M:N dynamic
program accepts exact, split, merge, replacement, source-omission and evidence-insertion groups.
diff --git a/packages/narrative-speech-alignment/package.json b/packages/narrative-speech-alignment/package.json
new file mode 100644
index 00000000..9c8a68cc
--- /dev/null
+++ b/packages/narrative-speech-alignment/package.json
@@ -0,0 +1,26 @@
+{
+ "name": "@hypit/narrative-speech-alignment",
+ "version": "0.1.0",
+ "license": "SEE LICENSE IN LICENSE",
+ "private": true,
+ "type": "module",
+ "exports": {
+ ".": "./src/index.ts"
+ },
+ "hypit": {
+ "activation": "./src/activation.ts"
+ },
+ "files": [
+ "dist",
+ "README.md"
+ ],
+ "peerDependencies": {
+ "@hypit/hypit": "workspace:^"
+ },
+ "devDependencies": {
+ "@hypit/hypit": "workspace:*",
+ "@hypit/script": "workspace:*",
+ "@hypit/narrative": "workspace:*",
+ "@hypit/speech-evidence": "workspace:*"
+ }
+}
diff --git a/packages/narrative-speech-alignment/src/activation.ts b/packages/narrative-speech-alignment/src/activation.ts
new file mode 100644
index 00000000..50677851
--- /dev/null
+++ b/packages/narrative-speech-alignment/src/activation.ts
@@ -0,0 +1,10 @@
+import { createAdmissionPackageFacet } from "@hypit/hypit/admission";
+import { createProducerPackageFacet } from "@hypit/hypit/producer";
+import { speechAlignmentComponent, speechAlignmentManifest } from "./index.js";
+
+export const hypitPackage = {
+ format: "hypit.package@1" as const,
+ modules: [{ manifest: speechAlignmentManifest }],
+ facets: [...[speechAlignmentComponent].flatMap((component) => [createProducerPackageFacet(component), createAdmissionPackageFacet(component)])],
+};
+export default hypitPackage;
diff --git a/packages/speech-alignment/src/align.ts b/packages/narrative-speech-alignment/src/align.ts
similarity index 92%
rename from packages/speech-alignment/src/align.ts
rename to packages/narrative-speech-alignment/src/align.ts
index cfdbf3b7..fcbbd0c1 100644
--- a/packages/speech-alignment/src/align.ts
+++ b/packages/narrative-speech-alignment/src/align.ts
@@ -1,5 +1,5 @@
-import type { NarrativeToken } from "@hypit/narrative";
-import type { SpeechWordEvidence } from "@hypit/speech-evidence";
+import type { NarrativeToken } from "@hypit/hypit/narrative";
+import type { SpeechWordEvidence } from "@hypit/hypit/speech-evidence";
import { editDistance, normalizeForAlignment } from "./normalize.js";
import type { AlignmentGroup, AlignmentRelation } from "./types.js";
@@ -123,6 +123,20 @@ export function alignWordGroups(
evidence: readonly SpeechWordEvidence[],
maxGroupSize = DEFAULT_MAX_GROUP,
): AlignmentGroup[] {
+ // The overwhelmingly common exact transcript has one unambiguous zero-cost path. Returning that
+ // path directly keeps long authored Segments linear without weakening the complete fuzzy aligner
+ // used for tokenisation differences, omissions, insertions and recognition errors.
+ if (source.length === evidence.length && source.every((token, index) =>
+ token.normalized === normalizeForAlignment(evidence[index]!.text))) {
+ return source.map((token, index) => ({
+ sourceSegmentId,
+ sourceTokenIds: [token.id],
+ evidenceWordStart: index,
+ evidenceWordEndExclusive: index + 1,
+ relation: "exact",
+ cost: 0,
+ }));
+ }
const rows = Array.from({ length: source.length + 1 }, () =>
Array<Cell | undefined>(evidence.length + 1).fill(undefined));
rows[0]![0] = {
diff --git a/packages/speech-alignment/src/component.ts b/packages/narrative-speech-alignment/src/component.ts
similarity index 64%
rename from packages/speech-alignment/src/component.ts
rename to packages/narrative-speech-alignment/src/component.ts
index c5f8d764..19af80a4 100644
--- a/packages/speech-alignment/src/component.ts
+++ b/packages/narrative-speech-alignment/src/component.ts
@@ -1,9 +1,10 @@
-import type { ComponentPackage } from "@hypit/component-kit";
-import type { Narrative, NarrativeSegmentRef } from "@hypit/narrative";
-import type { StoredValue } from "@hypit/protocol";
-import { canonicalize } from "@hypit/protocol";
-import type { AlignedTranscriptEvidence } from "@hypit/speech-evidence";
-import type { LocalTemporalDomain } from "@hypit/temporal";
+import type { AdmissionPackage } from "@hypit/hypit/admission";
+import type { ProducerPackage } from "@hypit/hypit/producer";
+import type { Narrative, NarrativeSegmentRef } from "@hypit/hypit/narrative";
+import type { StoredValue } from "@hypit/hypit/protocol";
+import { canonicalize } from "@hypit/hypit/protocol";
+import type { AlignedTranscriptEvidence } from "@hypit/hypit/speech-evidence";
+import type { LocalTemporalDomain } from "@hypit/hypit/temporal";
import { alignNarrative } from "./local.js";
import { speechAlignmentProducers } from "./manifest.js";
@@ -28,4 +29,4 @@ export const speechAlignmentComponent = {
}, needs: {} };
},
}],
-} satisfies ComponentPackage;
+} satisfies ProducerPackage & AdmissionPackage;
diff --git a/packages/speech-alignment/src/error.ts b/packages/narrative-speech-alignment/src/error.ts
similarity index 100%
rename from packages/speech-alignment/src/error.ts
rename to packages/narrative-speech-alignment/src/error.ts
diff --git a/packages/speech-alignment/src/index.ts b/packages/narrative-speech-alignment/src/index.ts
similarity index 100%
rename from packages/speech-alignment/src/index.ts
rename to packages/narrative-speech-alignment/src/index.ts
diff --git a/packages/speech-alignment/src/local.ts b/packages/narrative-speech-alignment/src/local.ts
similarity index 88%
rename from packages/speech-alignment/src/local.ts
rename to packages/narrative-speech-alignment/src/local.ts
index 2f6e60a2..3a210ddd 100644
--- a/packages/speech-alignment/src/local.ts
+++ b/packages/narrative-speech-alignment/src/local.ts
@@ -1,7 +1,7 @@
-import type { Narrative, NarrativeSegmentRef } from "@hypit/narrative";
-import type { NarrativeAlignment } from "@hypit/narrative-temporal";
-import type { AlignedTranscriptEvidence } from "@hypit/speech-evidence";
-import type { LocalTemporalDomain } from "@hypit/temporal";
+import type { Narrative, NarrativeSegmentRef } from "@hypit/hypit/narrative";
+import type { NarrativeAlignment } from "@hypit/hypit/narrative-temporal";
+import type { AlignedTranscriptEvidence } from "@hypit/hypit/speech-evidence";
+import type { LocalTemporalDomain } from "@hypit/hypit/temporal";
import { locateAlignedSegmentTiming } from "./locate.js";
import { materializeNarrativeAlignment } from "./materialize.js";
diff --git a/packages/speech-alignment/src/locate.ts b/packages/narrative-speech-alignment/src/locate.ts
similarity index 99%
rename from packages/speech-alignment/src/locate.ts
rename to packages/narrative-speech-alignment/src/locate.ts
index 5b1ef73b..d5fae7db 100644
--- a/packages/speech-alignment/src/locate.ts
+++ b/packages/narrative-speech-alignment/src/locate.ts
@@ -1,4 +1,4 @@
-import type { Narrative, NarrativeToken } from "@hypit/narrative";
+import type { Narrative, NarrativeToken } from "@hypit/hypit/narrative";
import type { NarrativeAlignmentTiming } from "./types.js";
import type {
AlignedTranscriptEvidence,
@@ -6,7 +6,7 @@ import type {
SpeechCharacterEvidence,
SpeechTranscriptPassage,
SpeechWordEvidence,
-} from "@hypit/speech-evidence";
+} from "@hypit/hypit/speech-evidence";
import { alignWordGroups } from "./align.js";
import { SpeechAlignmentError } from "./error.js";
diff --git a/packages/speech-alignment/src/manifest.ts b/packages/narrative-speech-alignment/src/manifest.ts
similarity index 73%
rename from packages/speech-alignment/src/manifest.ts
rename to packages/narrative-speech-alignment/src/manifest.ts
index b847078f..14045657 100644
--- a/packages/speech-alignment/src/manifest.ts
+++ b/packages/narrative-speech-alignment/src/manifest.ts
@@ -1,10 +1,10 @@
-import { narrativeDependency, narrativeTypes } from "@hypit/narrative";
-import { narrativeTemporalDependency, narrativeTemporalTypes } from "@hypit/narrative-temporal";
-import { speechEvidenceDependency, speechEvidenceTypes } from "@hypit/speech-evidence";
-import { temporalDependency, temporalTypes } from "@hypit/temporal";
-import type { ModuleManifest, ProducerRef } from "@hypit/protocol";
+import { narrativeDependency, narrativeTypes } from "@hypit/hypit/narrative";
+import { narrativeTemporalDependency, narrativeTemporalTypes } from "@hypit/hypit/narrative-temporal";
+import { speechEvidenceDependency, speechEvidenceTypes } from "@hypit/hypit/speech-evidence";
+import { temporalDependency, temporalTypes } from "@hypit/hypit/temporal";
+import type { ModuleManifest, ProducerRef } from "@hypit/hypit/protocol";
-export const speechAlignmentModuleRef = { name: "@hypit/speech-alignment", version: "1" } as const;
+export const speechAlignmentModuleRef = { name: "@hypit/narrative-speech-alignment", version: "1" } as const;
export const speechAlignmentProducers = {
alignNarrative: { module: speechAlignmentModuleRef, name: "align-narrative" },
} satisfies Record<string, ProducerRef>;
diff --git a/packages/speech-alignment/src/materialize.ts b/packages/narrative-speech-alignment/src/materialize.ts
similarity index 88%
rename from packages/speech-alignment/src/materialize.ts
rename to packages/narrative-speech-alignment/src/materialize.ts
index e2f3aab1..99fb849a 100644
--- a/packages/speech-alignment/src/materialize.ts
+++ b/packages/narrative-speech-alignment/src/materialize.ts
@@ -1,8 +1,8 @@
-import type { Narrative, NarrativeSegmentRef } from "@hypit/narrative";
-import { sealNarrativeAlignment } from "@hypit/narrative-temporal";
-import type { NarrativeAlignment } from "@hypit/narrative-temporal";
-import { assertLocalTemporalDomain } from "@hypit/temporal";
-import type { LocalTemporalDomain } from "@hypit/temporal";
+import type { Narrative, NarrativeSegmentRef } from "@hypit/hypit/narrative";
+import { sealNarrativeAlignment } from "@hypit/hypit/narrative-temporal";
+import type { NarrativeAlignment } from "@hypit/hypit/narrative-temporal";
+import { assertLocalTemporalDomain } from "@hypit/hypit/temporal";
+import type { LocalTemporalDomain } from "@hypit/hypit/temporal";
import type { NarrativeAlignmentTiming } from "./types.js";
diff --git a/packages/speech-alignment/src/normalize.ts b/packages/narrative-speech-alignment/src/normalize.ts
similarity index 100%
rename from packages/speech-alignment/src/normalize.ts
rename to packages/narrative-speech-alignment/src/normalize.ts
diff --git a/packages/speech-alignment/src/types.ts b/packages/narrative-speech-alignment/src/types.ts
similarity index 96%
rename from packages/speech-alignment/src/types.ts
rename to packages/narrative-speech-alignment/src/types.ts
index 585493e8..3b2c0960 100644
--- a/packages/speech-alignment/src/types.ts
+++ b/packages/narrative-speech-alignment/src/types.ts
@@ -4,7 +4,7 @@ export type {
SpeechCharacterEvidence,
SpeechTranscriptPassage,
SpeechWordEvidence,
-} from "@hypit/speech-evidence";
+} from "@hypit/hypit/speech-evidence";
/** Private vocabulary of the alignment implementation, not part of the public alignment value. */
export type AlignmentRelation =
| "exact"
diff --git a/packages/speech-alignment/test/speech-align.test.ts b/packages/narrative-speech-alignment/test/speech-align.test.ts
similarity index 94%
rename from packages/speech-alignment/test/speech-align.test.ts
rename to packages/narrative-speech-alignment/test/speech-align.test.ts
index b2f1c7b0..ee06e0dc 100644
--- a/packages/speech-alignment/test/speech-align.test.ts
+++ b/packages/narrative-speech-alignment/test/speech-align.test.ts
@@ -1,4 +1,4 @@
-import type { Narrative } from "@hypit/narrative";
+import type { Narrative, NarrativeToken } from "@hypit/narrative";
import { sealAlignedTranscriptEvidence } from "@hypit/speech-evidence";
import type { AlignedTranscriptEvidence, SpeechCharacterEvidence, SpeechWordEvidence } from "@hypit/speech-evidence";
import assert from "node:assert/strict";
@@ -9,7 +9,7 @@ import {
SpeechAlignmentError,
alignWordGroups,
materializeNarrativeAlignment,
-} from "@hypit/speech-alignment";
+} from "@hypit/narrative-speech-alignment";
import { locateAlignedSegmentTiming } from "../src/locate.js";
import type { AlignmentBasis } from "../src/locate.js";
@@ -139,6 +139,25 @@ test("exact transcript words cover every Script and Segment anchor", () => {
assert.equal(new Set(map.boundaries.map((boundary) => boundary.id)).size, map.boundaries.length);
});
+test("a long exact transcript retains the same one-to-one semantic path", () => {
+ const count = 800;
+ const source: NarrativeToken[] = Array.from({ length: count }, (_, index) => ({
+ id: `token-${index}`,
+ segmentId: "long-line",
+ startAnchorId: `token-${index}:start`,
+ endAnchorId: `token-${index}:end`,
+ text: `word${index}`,
+ normalized: `word${index}`,
+ }));
+ const spoken = source.map((token) => ({ text: token.text }));
+ const groups = alignWordGroups("long-line", source, spoken);
+ assert.equal(groups.length, count);
+ assert.equal(groups.every((group, index) => group.relation === "exact"
+ && group.sourceTokenIds[0] === `token-${index}`
+ && group.evidenceWordStart === index
+ && group.evidenceWordEndExclusive === index + 1), true);
+});
+
test("a measured Segment-local map becomes a media-free NarrativeAlignment", () => {
const narrative = parseScript("materialize.svml", "<line>Hello world.</line>");
const basis = speechBasis(narrative, 2);
diff --git a/packages/narrative-temporal/README.md b/packages/narrative-temporal/README.md
index e7cf0119..abbb1b1b 100644
--- a/packages/narrative-temporal/README.md
+++ b/packages/narrative-temporal/README.md
@@ -26,6 +26,6 @@ values without receiving the Projection or learning Narrative source kinds. Sele
dispatch remain owned here. The completed Projection stores absolute boundaries and no reusable
local-to-absolute mapping identity.
-Speech Alignment is one producer of `NarrativeAlignment`; manually authored, imported or adjusted
+Speech Alignment is one producer of `NarrativeAlignment`; reviewed, manually authored or imported
relations use the same Type without pretending to be speech. Timeline and common Temporal packages
do not enumerate Narrative event kinds.
diff --git a/packages/narrative-temporal/package.json b/packages/narrative-temporal/package.json
index 2fbaf4eb..27196f52 100644
--- a/packages/narrative-temporal/package.json
+++ b/packages/narrative-temporal/package.json
@@ -11,13 +11,13 @@
"activation": "./src/activation.ts"
},
"dependencies": {
- "@hypit/component-kit": "workspace:*",
- "@hypit/elaborator": "workspace:*",
+ "@hypit/producer": "workspace:*",
+ "@hypit/author": "workspace:*",
"@hypit/markup": "workspace:*",
"@hypit/narrative": "workspace:*",
"@hypit/protocol": "workspace:*",
"@hypit/temporal": "workspace:*",
- "@hypit/temporal-markup": "workspace:*",
- "@hypit/timeline": "workspace:*"
+ "@hypit/timeline": "workspace:*",
+ "@hypit/admission": "workspace:*"
}
}
diff --git a/packages/narrative-temporal/src/activation.ts b/packages/narrative-temporal/src/activation.ts
index dd480433..58797c59 100644
--- a/packages/narrative-temporal/src/activation.ts
+++ b/packages/narrative-temporal/src/activation.ts
@@ -1,12 +1,14 @@
-import { createMarkupSurfaceHostFacet } from "@hypit/markup";
+import { createAdmissionPackageFacet } from "@hypit/admission";
+import { createProducerPackageFacet } from "@hypit/producer";
+import { createMarkupSurfaceFacet } from "@hypit/markup";
import { decodeNarrativeProjectionSurface, narrativeProjectionMarkupSurface, narrativeTemporalComponent,
narrativeTemporalManifest, narrativeTemporalModuleRef } from "./index.js";
export const hypitPackage = {
- format: "hypit.node-package@1" as const,
+ format: "hypit.package@1" as const,
modules: [{ manifest: narrativeTemporalManifest }],
- components: [narrativeTemporalComponent],
- hostFacets: [createMarkupSurfaceHostFacet({ module: narrativeTemporalModuleRef,
+ facets: [
+ ...[narrativeTemporalComponent].flatMap((component) => [createProducerPackageFacet(component), createAdmissionPackageFacet(component)]),createMarkupSurfaceFacet({ module: narrativeTemporalModuleRef,
declaration: narrativeProjectionMarkupSurface, handler: decodeNarrativeProjectionSurface })],
};
export default hypitPackage;
diff --git a/packages/narrative-temporal/src/component.ts b/packages/narrative-temporal/src/component.ts
index d32354ef..b94599d6 100644
--- a/packages/narrative-temporal/src/component.ts
+++ b/packages/narrative-temporal/src/component.ts
@@ -1,4 +1,5 @@
-import type { ComponentPackage } from "@hypit/component-kit";
+import type { AdmissionPackage } from "@hypit/admission";
+import type { ProducerPackage } from "@hypit/producer";
import type { Narrative, NarrativeSegmentRef, NarrativeMomentRef, NarrativeSelectionRef } from "@hypit/narrative";
import { canonicalize } from "@hypit/protocol";
import type { ProducerRef, StoredValue } from "@hypit/protocol";
@@ -59,10 +60,10 @@ export const narrativeTemporalComponent = {
projectionFacet(narrativeTemporalProducers.projectSegmentInstant, "segment", "segment"),
projectionFacet(narrativeTemporalProducers.projectMomentInstant, "moment", "moment"),
])],
-} satisfies ComponentPackage;
+} satisfies ProducerPackage & AdmissionPackage;
function projectionFacet(producer: ProducerRef, inputName: "selection" | "segment" | "moment",
- sourceKind: "selection" | "segment" | "moment"): NonNullable<ComponentPackage["producers"]>[number] {
+ sourceKind: "selection" | "segment" | "moment"): NonNullable<ProducerPackage["producers"]>[number] {
return { producer, handler: ({ inputs }) => {
const spec = inline<NarrativeInstantSpec>(inputs.spec?.value, "NarrativeInstantSpec");
return { outputs: { instant: { kind: "inline" as const, value: canonicalize(projectNarrativeInstant({
diff --git a/packages/narrative-temporal/src/surface.ts b/packages/narrative-temporal/src/surface.ts
index 81350815..0a593376 100644
--- a/packages/narrative-temporal/src/surface.ts
+++ b/packages/narrative-temporal/src/surface.ts
@@ -1,5 +1,5 @@
-import { sealGraphFragment } from "@hypit/elaborator";
-import type { FragmentOperation, GraphFragment } from "@hypit/elaborator";
+import { sealGraphFragment } from "@hypit/author";
+import type { FragmentOperation, GraphFragment } from "@hypit/author";
import {
assertAttributes, assertEmptyElement, localName, textAttribute,
type StructuredElement, type StructuredSurfaceHandler, type SurfaceComponentDraft,
@@ -9,7 +9,7 @@ import { narrativeTypes } from "@hypit/narrative";
import { canonicalize, sameType, type TypeRef } from "@hypit/protocol";
import { temporalProducers, temporalTypes } from "@hypit/temporal";
import type { TemporalDuration } from "@hypit/temporal";
-import { parseTemporalDuration } from "@hypit/temporal-markup";
+import { parseTemporalDuration } from "@hypit/temporal/markup";
import { timelineTypes } from "@hypit/timeline";
import { narrativeTemporalProducers, narrativeTemporalTypes } from "./manifest.js";
diff --git a/packages/narrative/package.json b/packages/narrative/package.json
index 780751e5..47e43902 100644
--- a/packages/narrative/package.json
+++ b/packages/narrative/package.json
@@ -11,7 +11,8 @@
"activation": "./src/activation.ts"
},
"dependencies": {
- "@hypit/component-kit": "workspace:*",
- "@hypit/protocol": "workspace:*"
+ "@hypit/producer": "workspace:*",
+ "@hypit/protocol": "workspace:*",
+ "@hypit/admission": "workspace:*"
}
}
diff --git a/packages/narrative/src/activation.ts b/packages/narrative/src/activation.ts
index 7a1b37e4..de8f5ce4 100644
--- a/packages/narrative/src/activation.ts
+++ b/packages/narrative/src/activation.ts
@@ -1,7 +1,9 @@
+import { createAdmissionPackageFacet } from "@hypit/admission";
+import { createProducerPackageFacet } from "@hypit/producer";
import { narrativeComponent, narrativeManifest } from "./index.js";
export const hypitPackage = {
- format: "hypit.node-package@1" as const,
+ format: "hypit.package@1" as const,
modules: [{ manifest: narrativeManifest }],
- components: [narrativeComponent],
+ facets: [...[narrativeComponent].flatMap((component) => [createProducerPackageFacet(component), createAdmissionPackageFacet(component)])],
};
export default hypitPackage;
diff --git a/packages/narrative/src/component.ts b/packages/narrative/src/component.ts
index 455579ed..01b5300a 100644
--- a/packages/narrative/src/component.ts
+++ b/packages/narrative/src/component.ts
@@ -1,4 +1,5 @@
-import type { ComponentPackage } from "@hypit/component-kit";
+import type { AdmissionPackage } from "@hypit/admission";
+import type { ProducerPackage } from "@hypit/producer";
import type { StoredValue } from "@hypit/protocol";
import {
@@ -27,4 +28,4 @@ export const narrativeComponent = {
{ type: narrativeTypes.selection, handler: ({ value }) => assertNarrativeSelectionRefIdentity(inline<NarrativeSelectionRef>(value, "NarrativeSelection")) },
{ type: narrativeTypes.moment, handler: ({ value }) => assertNarrativeMomentRefIdentity(inline<NarrativeMomentRef>(value, "NarrativeMoment")) },
],
-} satisfies ComponentPackage;
+} satisfies ProducerPackage & AdmissionPackage;
diff --git a/packages/svs/README.md b/packages/recipe/README.md
similarity index 92%
rename from packages/svs/README.md
rename to packages/recipe/README.md
index d0d32708..be5a0e14 100644
--- a/packages/svs/README.md
+++ b/packages/recipe/README.md
@@ -1,7 +1,7 @@
-# `@hypit/svs`
+# `@hypit/recipe`
Minimal official parameter-recipe Frontend normally used by `.svs` SourceUnits. The source must
-select it explicitly with `<?svml using="@hypit/svs@1"?>`; the suffix is only a human convention.
+select it explicitly with `<?svml using="@hypit/recipe@1"?>`; the suffix is only a human convention.
The SVS Frontend reads a `<sheet version="1">` containing named rule blocks and emits one immutable generic
`Recipe` Record per rule. It does not know Caption, Film, Track or Provider parameters and it does
@@ -14,7 +14,7 @@ JSON array/object syntax. SVS only parses and serializes those shapes. The
consuming domain package owns their schema and meaning.
```svs
-<?svml using="@hypit/svs@1"?>
+<?svml using="@hypit/recipe@1"?>
<sheet version="1">
ranking.column {
rank-colors: ["#ff3f56", "#ffa72d", "#eadc2a"];
diff --git a/packages/svs/package.json b/packages/recipe/package.json
similarity index 66%
rename from packages/svs/package.json
rename to packages/recipe/package.json
index c917a7db..a9f44da8 100644
--- a/packages/svs/package.json
+++ b/packages/recipe/package.json
@@ -1,5 +1,5 @@
{
- "name": "@hypit/svs",
+ "name": "@hypit/recipe",
"version": "0.0.0-dev",
"license": "SEE LICENSE IN LICENSE",
"private": true,
@@ -11,11 +11,13 @@
"activation": "./src/activation.ts"
},
"dependencies": {
- "@hypit/core": "workspace:*",
- "@hypit/elaborator": "workspace:*",
+ "@hypit/source": "workspace:*",
+ "@hypit/kernel": "workspace:*",
+ "@hypit/author": "workspace:*",
"@hypit/protocol": "workspace:*"
},
"devDependencies": {
+ "@hypit/compiler": "workspace:*",
"@hypit/markup": "workspace:*"
}
}
diff --git a/packages/recipe/src/activation.ts b/packages/recipe/src/activation.ts
new file mode 100644
index 00000000..47d2aea3
--- /dev/null
+++ b/packages/recipe/src/activation.ts
@@ -0,0 +1,11 @@
+import { createAuthorFrontendFacet } from "@hypit/author";
+
+import { recipeFrontend, recipeManifest } from "./index.js";
+
+export const hypitPackage = {
+ format: "hypit.package@1" as const,
+ modules: [{ manifest: recipeManifest }],
+ facets: [createAuthorFrontendFacet(recipeFrontend)],
+};
+
+export default hypitPackage;
diff --git a/packages/svs/src/format.ts b/packages/recipe/src/format.ts
similarity index 89%
rename from packages/svs/src/format.ts
rename to packages/recipe/src/format.ts
index 6be5cb83..8e51988b 100644
--- a/packages/svs/src/format.ts
+++ b/packages/recipe/src/format.ts
@@ -4,7 +4,7 @@ const BARE = /^[^\s;,\[\]{}"']+$/u;
const NUMBER = /^-?(?:0|[1-9][0-9]*)(?:\.[0-9]+)?$/u;
/** Serialize one canonical value without knowing which component consumes it. */
-export function formatSvsValue(value: CanonicalValue): string {
+export function formatRecipeValue(value: CanonicalValue): string {
if (value === null) return "null";
if (typeof value === "boolean" || typeof value === "number") return String(value);
if (typeof value === "string") {
diff --git a/packages/svs/src/frontend.ts b/packages/recipe/src/frontend.ts
similarity index 54%
rename from packages/svs/src/frontend.ts
rename to packages/recipe/src/frontend.ts
index 2959b3c8..a6f29965 100644
--- a/packages/svs/src/frontend.ts
+++ b/packages/recipe/src/frontend.ts
@@ -1,21 +1,22 @@
import {
sealRecord,
-} from "@hypit/core";
-import type { AuthorFrontend, AuthorSourceExport } from "@hypit/elaborator";
+} from "@hypit/kernel";
+import type { AuthorFrontend, AuthorSourceExport } from "@hypit/author";
+import { decodeSourceText } from "@hypit/source";
-import { svsFrontendId, svsModuleRef, svsRecipeType } from "./manifest.js";
-import { parseSvs } from "./parser.js";
+import { recipeFrontendId, recipeModuleRef, recipeType } from "./manifest.js";
+import { parseRecipe } from "./parser.js";
-export const svsFrontend: AuthorFrontend = {
- id: svsFrontendId,
+export const recipeFrontend: AuthorFrontend = {
+ id: recipeFrontendId,
discover() {
- return { modules: [`${svsModuleRef.name}@${svsModuleRef.version}`], sources: [] };
+ return { modules: [`${recipeModuleRef.name}@${recipeModuleRef.version}`], sources: [] };
},
decode(source, context) {
- const parsed = parseSvs(source.name, source.text);
+ const parsed = parseRecipe(source.name, decodeSourceText(source));
const records = parsed.recipes.map((recipe) => sealRecord({
id: recipe.value.path,
- type: svsRecipeType,
+ type: recipeType,
value: { kind: "inline", value: recipe.value },
}));
const exports: AuthorSourceExport[] = records.map((record) => ({
diff --git a/packages/recipe/src/index.ts b/packages/recipe/src/index.ts
new file mode 100644
index 00000000..f5c6262b
--- /dev/null
+++ b/packages/recipe/src/index.ts
@@ -0,0 +1,5 @@
+export { recipeFrontendId, recipeManifest, recipeModuleRef, recipeType } from "./manifest.js";
+export { RecipeSyntaxError, parseRecipe } from "./parser.js";
+export { formatRecipeValue } from "./format.js";
+export { recipeFrontend } from "./frontend.js";
+export type * from "./types.js";
diff --git a/packages/recipe/src/manifest.ts b/packages/recipe/src/manifest.ts
new file mode 100644
index 00000000..5379c849
--- /dev/null
+++ b/packages/recipe/src/manifest.ts
@@ -0,0 +1,17 @@
+import type { ModuleManifest, TypeRef } from "@hypit/protocol";
+
+export const recipeModuleRef = { name: "@hypit/recipe", version: "1" } as const;
+export const recipeType = { module: recipeModuleRef, name: "Recipe" } satisfies TypeRef;
+export const recipeFrontendId = "@hypit/recipe@1";
+
+export const recipeManifest: ModuleManifest = {
+ format: "hypit.module@1",
+ name: recipeModuleRef.name,
+ version: recipeModuleRef.version,
+ dependencies: [],
+ types: [{
+ name: recipeType.name,
+ }],
+ capabilities: [],
+ producers: [],
+};
diff --git a/packages/svs/src/parser.ts b/packages/recipe/src/parser.ts
similarity index 89%
rename from packages/svs/src/parser.ts
rename to packages/recipe/src/parser.ts
index db9d3416..584cfd11 100644
--- a/packages/svs/src/parser.ts
+++ b/packages/recipe/src/parser.ts
@@ -4,21 +4,21 @@ import type {
ParsedSvsProperty,
ParsedSvsRecipe,
ParsedSvsSheet,
- SvsRecipe,
+ Recipe,
} from "./types.js";
const RULE = /^[a-z][a-z0-9_-]*(?:\.[a-z][a-z0-9_-]*)+/u;
const PROPERTY = /^[a-z][a-z0-9-]*/u;
const SHEET_ID = /^[a-z][a-z0-9_-]{0,63}$/u;
-export class SvsSyntaxError extends Error {
+export class RecipeSyntaxError extends Error {
readonly code: string;
readonly sourceName: string;
readonly offset: number;
constructor(code: string, message: string, sourceName: string, offset: number) {
super(`${sourceName}:${offset}: ${message}`);
- this.name = "SvsSyntaxError";
+ this.name = "RecipeSyntaxError";
this.code = code;
this.sourceName = sourceName;
this.offset = offset;
@@ -26,7 +26,7 @@ export class SvsSyntaxError extends Error {
}
function fail(sourceName: string, code: string, message: string, offset: number): never {
- throw new SvsSyntaxError(code, message, sourceName, offset);
+ throw new RecipeSyntaxError(code, message, sourceName, offset);
}
function withoutComments(sourceName: string, text: string): string {
@@ -110,6 +110,33 @@ function skipSpace(text: string, start: number): number {
return cursor;
}
+/** Find the root terminator without treating quoted Recipe text as document structure. */
+function closingSheet(text: string, start: number): number {
+ let quote: "\"" | "'" | undefined;
+ let escaped = false;
+ for (let cursor = start; cursor < text.length; cursor += 1) {
+ const character = text[cursor];
+ if (escaped) {
+ escaped = false;
+ continue;
+ }
+ if (character === "\\" && quote !== undefined) {
+ escaped = true;
+ continue;
+ }
+ if (quote !== undefined) {
+ if (character === quote) quote = undefined;
+ continue;
+ }
+ if (character === "\"" || character === "'") {
+ quote = character;
+ continue;
+ }
+ if (text.startsWith("</sheet>", cursor)) return cursor;
+ }
+ return -1;
+}
+
function parseAttributes(
sourceName: string,
raw: string,
@@ -233,7 +260,7 @@ function parseProperties(
return { values: properties, parsed };
}
-export function parseSvs(sourceName: string, source: string): ParsedSvsSheet {
+export function parseRecipe(sourceName: string, source: string): ParsedSvsSheet {
const text = withoutComments(sourceName, source);
let cursor = skipSpace(text, 0);
if (!text.startsWith("<sheet", cursor)) fail(sourceName, "SVS_ROOT", "Source must open with <sheet>.", cursor);
@@ -241,7 +268,7 @@ export function parseSvs(sourceName: string, source: string): ParsedSvsSheet {
if (openEnd < 0) fail(sourceName, "SVS_ROOT", "Opening <sheet> is not closed.", cursor);
const attributes = parseAttributes(sourceName, text.slice(cursor + 6, openEnd), cursor + 6);
cursor = openEnd + 1;
- const close = text.indexOf("</sheet>", cursor);
+ const close = closingSheet(text, cursor);
if (close < 0) fail(sourceName, "SVS_ROOT_UNCLOSED", "Source is missing </sheet>.", source.length);
if (text.slice(close + "</sheet>".length).trim().length > 0) {
fail(sourceName, "SVS_TRAILING", "Only trivia may follow </sheet>.", close + "</sheet>".length);
@@ -264,7 +291,7 @@ export function parseSvs(sourceName: string, source: string): ParsedSvsSheet {
const blockEnd = closingBrace(text, blockStart, close);
if (blockEnd < 0 || blockEnd > close) fail(sourceName, "SVS_RULE_UNCLOSED", `Recipe ${path} is not closed.`, start);
const parsedProperties = parseProperties(sourceName, text.slice(blockStart, blockEnd), blockStart);
- const value: SvsRecipe = {
+ const value: Recipe = {
path,
properties: parsedProperties.values,
diff --git a/packages/svs/src/types.ts b/packages/recipe/src/types.ts
similarity index 93%
rename from packages/svs/src/types.ts
rename to packages/recipe/src/types.ts
index 7aaa2c3e..d7e134b7 100644
--- a/packages/svs/src/types.ts
+++ b/packages/recipe/src/types.ts
@@ -1,12 +1,12 @@
import type { CanonicalValue, SourceRange } from "@hypit/protocol";
-export type SvsRecipe = {
+export type Recipe = {
readonly path: string;
readonly properties: Readonly<Record<string, CanonicalValue>>;
};
export type ParsedSvsRecipe = {
- readonly value: SvsRecipe;
+ readonly value: Recipe;
readonly range: SourceRange;
/** Exact author-source spans, for editors that must preserve surrounding trivia. */
readonly properties: readonly ParsedSvsProperty[];
diff --git a/packages/svs/test/source-closure.test.ts b/packages/recipe/test/source-closure.test.ts
similarity index 80%
rename from packages/svs/test/source-closure.test.ts
rename to packages/recipe/test/source-closure.test.ts
index c0b6391d..97449900 100644
--- a/packages/svs/test/source-closure.test.ts
+++ b/packages/recipe/test/source-closure.test.ts
@@ -4,15 +4,15 @@ import {
createResolvedClosure,
sealBuildRequest,
start,
-} from "@hypit/core";
+} from "@hypit/kernel";
import {
AuthorFrontendRegistry,
- SourceClosureError,
- compileSourceClosure,
resolveCompiledSourceExport,
sealGraphFragment,
-} from "@hypit/elaborator";
-import type { AuthorSourceUnit } from "@hypit/elaborator";
+} from "@hypit/author";
+import { SourceClosureError, compileSourceClosure } from "@hypit/compiler";
+import type { ResolvedSource } from "@hypit/source";
+import { resolveSelfDescribedTextSource } from "@hypit/source/text";
import type {
ModuleManifest,
ProducerRef,
@@ -20,14 +20,14 @@ import type {
TypedRecord,
} from "@hypit/protocol";
import {
- formatSvsValue,
- SvsSyntaxError,
- parseSvs,
- svsFrontend,
- svsManifest,
- svsRecipeType,
-} from "@hypit/svs";
-import type { SvsRecipe } from "@hypit/svs";
+ formatRecipeValue,
+ RecipeSyntaxError,
+ parseRecipe,
+ recipeFrontend,
+ recipeManifest,
+ recipeType,
+} from "@hypit/recipe";
+import type { Recipe } from "@hypit/recipe";
import {
MarkupSurfaceRegistry,
createMarkupAuthorFrontend,
@@ -47,7 +47,7 @@ const manifest: ModuleManifest = {
format: "hypit.module@1",
name: laboratory.name,
version: laboratory.version,
- dependencies: [{ module: { name: svsManifest.name, version: svsManifest.version } }],
+ dependencies: [{ module: { name: recipeManifest.name, version: recipeManifest.version } }],
types: [
{ name: cardType.name },
{
@@ -92,15 +92,15 @@ function referenceAttribute(element: StructuredElement, name: string): string {
return value.path;
}
-function recipeValue(record: TypedRecord | undefined): SvsRecipe {
- if (record?.type.module.name !== svsRecipeType.module.name || record.type.name !== svsRecipeType.name) {
+function recipeValue(record: TypedRecord | undefined): Recipe {
+ if (record?.type.module.name !== recipeType.module.name || record.type.name !== recipeType.name) {
throw new Error("Card.appearance must reference an SVS Recipe");
}
if (record.value.kind !== "inline" || record.value.value === null
|| Array.isArray(record.value.value) || typeof record.value.value !== "object") {
throw new Error("Card.appearance Recipe must be inline");
}
- return record.value.value as SvsRecipe;
+ return record.value.value as Recipe;
}
function sourceRegistry(): MarkupSurfaceRegistry {
@@ -151,15 +151,15 @@ function sourceRegistry(): MarkupSurfaceRegistry {
return registry;
}
-const closure = createResolvedClosure([svsManifest, manifest]);
+const closure = createResolvedClosure([recipeManifest, manifest]);
-function unit(id: string, text: string, frontend?: string): AuthorSourceUnit {
- const selected = frontend ?? (id.endsWith(".svs") ? "@hypit/svs@1" : "@hypit/markup@1");
- return {
+function unit(id: string, text: string, frontend?: string): ResolvedSource {
+ const selected = frontend ?? (id.endsWith(".svs") ? "@hypit/recipe@1" : "@hypit/markup@1");
+ return resolveSelfDescribedTextSource({
id,
name: id.split("/").at(-1) ?? id,
text: `<?svml using="${selected}"?>\n${text}`,
- };
+ });
}
const styleText = `<sheet version="1" id="studio">
@@ -175,7 +175,7 @@ async function compileMain(alias: string, root = "/project", styles = styleText)
registry: sourceRegistry(),
resolveModule: () => laboratory,
}));
- frontends.register(svsFrontend);
+ frontends.register(recipeFrontend);
const entry = unit(`${root}/main.svml`, `<svml>
<import as="lab" from="example.recipe-card@1"/>
<import as="${alias}" source="./recipes.svs"/>
@@ -196,7 +196,7 @@ test("Text and SVS recursively compile one aliased Recipe into a Core BuildPlan"
const compiled = await compileMain("studio");
assert.equal(compiled.closure.units.length, 2);
assert.equal(compiled.program.records.length, 2);
- const recipe = compiled.program.records.find((record) => record.type.name === svsRecipeType.name);
+ const recipe = compiled.program.records.find((record) => record.type.name === recipeType.name);
const appearance = compiled.program.records.find((record) => record.type.name === cardAppearanceType.name);
assert.deepEqual(recipe?.value, {
kind: "inline",
@@ -267,7 +267,7 @@ test("Source Closure rejects duplicate aliases and unknown Frontends before deco
<import as="styles" source="./one.svs"/>
<import as="styles" source="./two.svs"/>
</svml>`);
- frontends.register(svsFrontend);
+ frontends.register(recipeFrontend);
await assert.rejects(
compileSourceClosure({
entry: duplicate,
@@ -296,23 +296,45 @@ test("Source Closure rejects duplicate aliases and unknown Frontends before deco
test("SVS rejects duplicate public recipes", () => {
assert.throws(
- () => parseSvs("duplicate.svs", `<sheet version="1"><x.y>{}</x.y></sheet>`),
- (error: unknown) => error instanceof SvsSyntaxError,
+ () => parseRecipe("duplicate.svs", `<sheet version="1"><x.y>{}</x.y></sheet>`),
+ (error: unknown) => error instanceof RecipeSyntaxError,
);
assert.throws(
- () => parseSvs("duplicate.svs", `<sheet version="1">x.y {} x.y {}</sheet>`),
- (error: unknown) => error instanceof SvsSyntaxError && error.code === "SVS_RULE_DUPLICATE",
+ () => parseRecipe("duplicate.svs", `<sheet version="1">x.y {} x.y {}</sheet>`),
+ (error: unknown) => error instanceof RecipeSyntaxError && error.code === "SVS_RULE_DUPLICATE",
);
});
test("quoted Recipe values may contain Prompt punctuation without changing SVS structure", () => {
- const sheet = parseSvs(
+ const sheet = parseRecipe(
"prompt.svs",
'<sheet version="1">demo.prompt { text: "first; second } /* literal */"; }</sheet>',
);
assert.equal(sheet.recipes[0]?.value.properties.text, "first; second } /* literal */");
});
+test("quoted Recipe values may contain the sheet closing text without ending the document", () => {
+ const sheet = parseRecipe(
+ "literal-close.svs",
+ '<sheet version="1">demo.prompt { text: "write </sheet> literally"; }</sheet>',
+ );
+ assert.equal(sheet.recipes[0]?.value.properties.text, "write </sheet> literally");
+ assert.throws(
+ () => parseRecipe(
+ "missing-close.svs",
+ '<sheet version="1">demo.prompt { text: "write </sheet> literally"; }',
+ ),
+ (error: unknown) => error instanceof RecipeSyntaxError && error.code === "SVS_ROOT_UNCLOSED",
+ );
+ assert.throws(
+ () => parseRecipe(
+ "trailing.svs",
+ '<sheet version="1">demo.prompt { text: "write </sheet> literally"; }</sheet> trailing',
+ ),
+ (error: unknown) => error instanceof RecipeSyntaxError && error.code === "SVS_TRAILING",
+ );
+});
+
test("SVS parses and serializes canonical arrays and objects as one Recipe value", () => {
const source = `<sheet version="1">
ranking.column {
@@ -320,10 +342,10 @@ test("SVS parses and serializes canonical arrays and objects as one Recipe value
rows: [{"id":"s","label":"S","color":"#EF4444"}];
}
</sheet>`;
- const recipe = parseSvs("structured.svs", source).recipes[0]!;
+ const recipe = parseRecipe("structured.svs", source).recipes[0]!;
assert.deepEqual(recipe.value.properties.colors, ["#FF3F56", "#FFA72D"]);
assert.deepEqual(recipe.value.properties.rows, [{ id: "s", label: "S", color: "#EF4444" }]);
- assert.equal(formatSvsValue(recipe.value.properties.colors!), '["#FF3F56","#FFA72D"]');
+ assert.equal(formatRecipeValue(recipe.value.properties.colors!), '["#FF3F56","#FFA72D"]');
});
test("SVS exposes exact property and value spans without inventing editor metadata", () => {
@@ -333,7 +355,7 @@ test("SVS exposes exact property and value spans without inventing editor metada
padding: 16 24;
}
</sheet>`;
- const recipe = parseSvs("editable.svs", source).recipes[0]!;
+ const recipe = parseRecipe("editable.svs", source).recipes[0]!;
const size = recipe.properties.find((property) => property.name === "size")!;
assert.equal(source.slice(size.range.start, size.range.end), "size : 58 ;");
assert.equal(source.slice(size.valueRange.start, size.valueRange.end), "58");
diff --git a/packages/region-track/README.md b/packages/region-evidence/README.md
similarity index 77%
rename from packages/region-track/README.md
rename to packages/region-evidence/README.md
index 525da44d..6d879c6b 100644
--- a/packages/region-track/README.md
+++ b/packages/region-evidence/README.md
@@ -1,12 +1,12 @@
-# `@hypit/region-track`
+# `@hypit/region-evidence`
Frame-exact external spatial evidence. The package relates prepared region observations to one
Timeline and resolves normalized boxes inside an explicit program-picture Frame. It performs no
detection, identity inference, interpolation or source-to-picture placement discovery.
```svml
-<import as="region" from="@hypit/region-track@1"/>
-<region:Track id="heads" within={vertical.bounds} timeline={program.timeline}
+<import as="region" from="@hypit/region-evidence@1"/>
+<region:Evidence id="heads" within={vertical.bounds} timeline={program.timeline}
recipe={tracking.heads.default}/>
```
@@ -19,7 +19,7 @@ heads.default {
```
Each series has exactly one normalized `[x, y, width, height]` box or `null` per Timeline Frame.
-The resulting `RegionTrack` contains resolved `SpatialFrame` values in the program picture plane.
+The resulting `RegionEvidence` contains resolved `SpatialFrame` values in the program picture plane.
The chosen Frame may be the Canvas bounds, an inset or any other explicit region.
Source-local observations must be projected through the actual visual presentation before they are
diff --git a/packages/region-track/package.json b/packages/region-evidence/package.json
similarity index 60%
rename from packages/region-track/package.json
rename to packages/region-evidence/package.json
index b8177742..c2c2c0d7 100644
--- a/packages/region-track/package.json
+++ b/packages/region-evidence/package.json
@@ -1,5 +1,5 @@
{
- "name": "@hypit/region-track",
+ "name": "@hypit/region-evidence",
"version": "0.0.0-dev",
"license": "SEE LICENSE IN LICENSE",
"private": true,
@@ -11,12 +11,13 @@
"activation": "./src/activation.ts"
},
"dependencies": {
- "@hypit/component-kit": "workspace:*",
- "@hypit/elaborator": "workspace:*",
+ "@hypit/producer": "workspace:*",
+ "@hypit/author": "workspace:*",
"@hypit/markup": "workspace:*",
"@hypit/protocol": "workspace:*",
"@hypit/spatial": "workspace:*",
- "@hypit/svs": "workspace:*",
- "@hypit/timeline": "workspace:*"
+ "@hypit/recipe": "workspace:*",
+ "@hypit/timeline": "workspace:*",
+ "@hypit/admission": "workspace:*"
}
}
diff --git a/packages/region-evidence/src/activation.ts b/packages/region-evidence/src/activation.ts
new file mode 100644
index 00000000..bea66bde
--- /dev/null
+++ b/packages/region-evidence/src/activation.ts
@@ -0,0 +1,23 @@
+import { createAdmissionPackageFacet } from "@hypit/admission";
+import { createProducerPackageFacet } from "@hypit/producer";
+import { createMarkupSurfaceFacet } from "@hypit/markup";
+
+import {
+ decodeRegionEvidenceSurface,
+ regionEvidenceComponent,
+ regionEvidenceManifest,
+ regionEvidenceMarkupSurface,
+ regionEvidenceModuleRef,
+} from "./index.js";
+
+export const hypitPackage = {
+ format: "hypit.package@1" as const,
+ modules: [{ manifest: regionEvidenceManifest }],
+ facets: [
+ ...[regionEvidenceComponent].flatMap((component) => [createProducerPackageFacet(component), createAdmissionPackageFacet(component)]),createMarkupSurfaceFacet({
+ module: regionEvidenceModuleRef,
+ declaration: regionEvidenceMarkupSurface,
+ handler: decodeRegionEvidenceSurface,
+ })],
+};
+export default hypitPackage;
diff --git a/packages/region-evidence/src/component.ts b/packages/region-evidence/src/component.ts
new file mode 100644
index 00000000..9ecb7dd9
--- /dev/null
+++ b/packages/region-evidence/src/component.ts
@@ -0,0 +1,26 @@
+import type { AdmissionPackage } from "@hypit/admission";
+import type { ProducerPackage } from "@hypit/producer";
+import { canonicalize } from "@hypit/protocol";
+import type { StoredValue } from "@hypit/protocol";
+import type { SpatialFrame } from "@hypit/spatial";
+import type { Recipe } from "@hypit/recipe";
+import type { Timeline } from "@hypit/timeline";
+
+import { regionEvidenceProducers, regionEvidenceTypes } from "./manifest.js";
+import { assertRegionEvidence, resolveRegionEvidence } from "./evidence.js";
+import type { RegionEvidence } from "./types.js";
+
+function inline<T>(value: StoredValue | undefined, label: string): T {
+ if (value?.kind !== "inline") throw new Error(`${label} must be inline.`);
+ return value.value as unknown as T;
+}
+const output = (value: unknown) => ({ kind: "inline" as const, value: canonicalize(value) });
+
+export const regionEvidenceComponent = {
+ producers: [{ producer: regionEvidenceProducers.resolve, handler: ({ inputs }) => ({ outputs: { evidence: output(resolveRegionEvidence(
+ inline<Recipe>(inputs.recipe?.value, "Recipe"),
+ inline<SpatialFrame>(inputs.within?.value, "SpatialFrame"),
+ inline<Timeline>(inputs.timeline?.value, "Timeline"),
+ )) }, needs: {} }) }],
+ validators: [{ type: regionEvidenceTypes.evidence, handler: ({ value }) => assertRegionEvidence(inline<RegionEvidence>(value, "RegionEvidence")) }],
+} satisfies ProducerPackage & AdmissionPackage;
diff --git a/packages/region-track/src/region.ts b/packages/region-evidence/src/evidence.ts
similarity index 81%
rename from packages/region-track/src/region.ts
rename to packages/region-evidence/src/evidence.ts
index 70abca91..a93f7957 100644
--- a/packages/region-track/src/region.ts
+++ b/packages/region-evidence/src/evidence.ts
@@ -1,11 +1,11 @@
import type { CanonicalValue } from "@hypit/protocol";
import { assertSpatialFrame } from "@hypit/spatial";
import type { SpatialFrame } from "@hypit/spatial";
-import type { SvsRecipe } from "@hypit/svs";
+import type { Recipe } from "@hypit/recipe";
import { assertTimelineIdentity, timelineFrameCount } from "@hypit/timeline";
import type { Timeline } from "@hypit/timeline";
-import type { RegionTrack } from "./types.js";
+import type { RegionEvidence } from "./types.js";
type CanonicalRecord = Readonly<Record<string, CanonicalValue>>;
@@ -36,31 +36,31 @@ function normalizedRegion(value: CanonicalValue, within: SpatialFrame, label: st
};
}
-export function assertRegionTrack(value: RegionTrack): void {
+export function assertRegionEvidence(value: RegionEvidence): void {
if (!value.timelineId.trim() || value.series.length === 0) {
- throw new Error("RegionTrack is empty or has no Timeline identity.");
+ throw new Error("RegionEvidence is empty or has no Timeline identity.");
}
const frameCount = value.series[0]?.frames.length ?? 0;
- if (frameCount === 0) throw new Error("RegionTrack has no Frames.");
+ if (frameCount === 0) throw new Error("RegionEvidence has no Frames.");
const ids = new Set<string>();
for (const series of value.series) {
- if (!series.id.trim() || ids.has(series.id)) throw new Error(`RegionTrack repeats or omits series id ${series.id}.`);
+ if (!series.id.trim() || ids.has(series.id)) throw new Error(`RegionEvidence repeats or omits series id ${series.id}.`);
ids.add(series.id);
if (series.frames.length !== frameCount) throw new Error(`Region series ${series.id} does not cover every Frame.`);
for (const frame of series.frames) if (frame !== null) assertSpatialFrame(frame);
}
}
-export function sealRegionTrack(value: RegionTrack): RegionTrack {
- assertRegionTrack(value);
+export function sealRegionEvidence(value: RegionEvidence): RegionEvidence {
+ assertRegionEvidence(value);
return structuredClone(value);
}
/** Resolve normalized author evidence into one program-picture Frame or null per Timeline Frame. */
-export function resolveRegionTrack(recipe: SvsRecipe, within: SpatialFrame, timeline: Timeline): RegionTrack {
+export function resolveRegionEvidence(recipe: Recipe, within: SpatialFrame, timeline: Timeline): RegionEvidence {
assertSpatialFrame(within);
assertTimelineIdentity(timeline);
- exact(recipe.properties, ["series"], `Region Track ${recipe.path}`);
+ exact(recipe.properties, ["series"], `Region Evidence ${recipe.path}`);
const frameCount = timelineFrameCount(timeline);
const seriesValue = recipe.properties.series;
if (!Array.isArray(seriesValue) || seriesValue.length === 0) throw new Error(`${recipe.path}.series must be a non-empty list.`);
@@ -78,5 +78,5 @@ export function resolveRegionTrack(recipe: SvsRecipe, within: SpatialFrame, time
frames: regions.map((region, frame) => normalizedRegion(region, within, `${recipe.path}.${id}.regions.${frame}`)),
};
});
- return sealRegionTrack({ timelineId: timeline.id, series });
+ return sealRegionEvidence({ timelineId: timeline.id, series });
}
diff --git a/packages/region-evidence/src/fragment.ts b/packages/region-evidence/src/fragment.ts
new file mode 100644
index 00000000..249f4ef2
--- /dev/null
+++ b/packages/region-evidence/src/fragment.ts
@@ -0,0 +1,20 @@
+import { sealGraphFragment } from "@hypit/author";
+import { spatialTypes } from "@hypit/spatial";
+import { recipeType } from "@hypit/recipe";
+import { timelineTypes } from "@hypit/timeline";
+
+import { regionEvidenceProducers, regionEvidenceTypes } from "./manifest.js";
+
+const input = (name: string) => ({ kind: "fragment-input" as const, name });
+
+export const regionEvidenceFragment = sealGraphFragment({
+ inputs: [
+ { name: "within", type: spatialTypes.frame },
+ { name: "timeline", type: timelineTypes.timeline },
+ { name: "recipe", type: recipeType },
+ ],
+ operations: [{ id: "resolve", producer: regionEvidenceProducers.resolve, inputs: {
+ within: input("within"), timeline: input("timeline"), recipe: input("recipe"),
+ }, result: { kind: "output", name: "evidence" } }],
+ exports: [{ name: "evidence", type: regionEvidenceTypes.evidence, root: { kind: "fragment-operation", operation: "resolve" } }],
+});
diff --git a/packages/region-evidence/src/index.ts b/packages/region-evidence/src/index.ts
new file mode 100644
index 00000000..0b15da4b
--- /dev/null
+++ b/packages/region-evidence/src/index.ts
@@ -0,0 +1,14 @@
+export { regionEvidenceComponent } from "./component.js";
+export { regionEvidenceFragment } from "./fragment.js";
+export {
+ regionEvidenceDependency,
+ regionEvidenceManifest,
+ regionEvidenceMarkupSurface,
+ regionEvidenceModuleRef,
+ regionEvidenceProducers,
+ regionEvidenceTypes,
+} from "./manifest.js";
+export { assertRegionEvidence, resolveRegionEvidence, sealRegionEvidence } from "./evidence.js";
+export { regionEvidenceSchema } from "./schema.js";
+export { decodeRegionEvidenceSurface } from "./surface.js";
+export type * from "./types.js";
diff --git a/packages/region-track/src/manifest.ts b/packages/region-evidence/src/manifest.ts
similarity index 53%
rename from packages/region-track/src/manifest.ts
rename to packages/region-evidence/src/manifest.ts
index cf2d9ff5..8301795c 100644
--- a/packages/region-track/src/manifest.ts
+++ b/packages/region-evidence/src/manifest.ts
@@ -1,29 +1,29 @@
import type { ModuleManifest, ProducerRef, TypeRef } from "@hypit/protocol";
import { spatialDependency, spatialTypes } from "@hypit/spatial";
-import { svsRecipeType } from "@hypit/svs";
+import { recipeType } from "@hypit/recipe";
import { timelineDependency, timelineTypes } from "@hypit/timeline";
-export const regionTrackModuleRef = { name: "@hypit/region-track", version: "1" } as const;
-export const regionTrackTypes = {
- track: { module: regionTrackModuleRef, name: "RegionTrack" },
+export const regionEvidenceModuleRef = { name: "@hypit/region-evidence", version: "1" } as const;
+export const regionEvidenceTypes = {
+ evidence: { module: regionEvidenceModuleRef, name: "RegionEvidence" },
} satisfies Record<string, TypeRef>;
-export const regionTrackProducers = {
- resolve: { module: regionTrackModuleRef, name: "resolve-region-track" },
+export const regionEvidenceProducers = {
+ resolve: { module: regionEvidenceModuleRef, name: "resolve-region-evidence" },
} satisfies Record<string, ProducerRef>;
-export const regionTrackMarkupSurface = {
- name: "track", tag: "Track", mode: "structured", outputs: [regionTrackTypes.track],
+export const regionEvidenceMarkupSurface = {
+ name: "evidence", tag: "Evidence", mode: "structured", outputs: [regionEvidenceTypes.evidence],
vocabulary: {
- summary: "Resolves externally prepared normalized regions into one frame-exact Region Track.",
+ summary: "Resolves externally prepared normalized regions into one frame-exact Region Evidence.",
attributes: [
- { name: "id", kind: "identifier", required: true, summary: "Names the RegionTrack value." },
+ { name: "id", kind: "identifier", required: true, summary: "Names the RegionEvidence value." },
{ name: "within", kind: "reference", required: true, accepts: [spatialTypes.frame], summary: "Chooses the program-picture Frame normalized regions occupy." },
{ name: "timeline", kind: "reference", required: true, accepts: [timelineTypes.timeline], summary: "Chooses the Timeline whose Frames index the evidence." },
- { name: "recipe", kind: "reference", required: true, accepts: [svsRecipeType], summary: "Chooses a Recipe with one or more named region series.", recipe: [
+ { name: "recipe", kind: "reference", required: true, accepts: [recipeType], summary: "Chooses a Recipe with one or more named region series.", recipe: [
{ name: "series", required: true, summary: "Lists {id, regions}; each regions array contains one normalized [x, y, width, height] or null per Timeline Frame." },
] },
],
- example: `<region:Track id="heads" within={vertical.bounds} timeline={program.timeline} recipe={tracking.heads.default}/>` ,
+ example: `<region:Evidence id="heads" within={vertical.bounds} timeline={program.timeline} recipe={tracking.heads.default}/>` ,
notes: [
"The element is empty; it accepts no children or text.",
"Detection, identity association, interpolation and source-to-picture projection remain explicit preparation choices.",
@@ -32,21 +32,21 @@ export const regionTrackMarkupSurface = {
},
} as const;
-export const regionTrackManifest: ModuleManifest = {
+export const regionEvidenceManifest: ModuleManifest = {
format: "hypit.module@1",
- name: regionTrackModuleRef.name,
- version: regionTrackModuleRef.version,
- dependencies: [spatialDependency, { module: svsRecipeType.module }, timelineDependency],
- types: [{ name: regionTrackTypes.track.name }],
+ name: regionEvidenceModuleRef.name,
+ version: regionEvidenceModuleRef.version,
+ dependencies: [spatialDependency, { module: recipeType.module }, timelineDependency],
+ types: [{ name: regionEvidenceTypes.evidence.name }],
capabilities: [],
producers: [{
- name: regionTrackProducers.resolve.name,
+ name: regionEvidenceProducers.resolve.name,
inputs: [
{ name: "within", type: spatialTypes.frame },
{ name: "timeline", type: timelineTypes.timeline },
- { name: "recipe", type: svsRecipeType },
+ { name: "recipe", type: recipeType },
],
- outputs: [{ name: "track", type: regionTrackTypes.track }], needs: [],
+ outputs: [{ name: "evidence", type: regionEvidenceTypes.evidence }], needs: [],
}],
};
-export const regionTrackDependency = { module: regionTrackModuleRef } as const;
+export const regionEvidenceDependency = { module: regionEvidenceModuleRef } as const;
diff --git a/packages/region-track/src/schema.ts b/packages/region-evidence/src/schema.ts
similarity index 93%
rename from packages/region-track/src/schema.ts
rename to packages/region-evidence/src/schema.ts
index 0ae90380..b825ecf2 100644
--- a/packages/region-track/src/schema.ts
+++ b/packages/region-evidence/src/schema.ts
@@ -3,7 +3,7 @@ import { spatialFrameSchema } from "@hypit/spatial";
const object = (fields: Readonly<Record<string, { readonly schema: ValueSchema; readonly optional?: boolean }>>): ValueSchema => ({ kind: "object", fields });
-export const regionTrackSchema = object({
+export const regionEvidenceSchema = object({
timelineId: { schema: { kind: "string", minLength: 1 } },
series: { schema: { kind: "array", minItems: 1, items: object({
id: { schema: { kind: "string", minLength: 1 } },
diff --git a/packages/region-track/src/surface.ts b/packages/region-evidence/src/surface.ts
similarity index 80%
rename from packages/region-track/src/surface.ts
rename to packages/region-evidence/src/surface.ts
index b513bbfb..371fd415 100644
--- a/packages/region-track/src/surface.ts
+++ b/packages/region-evidence/src/surface.ts
@@ -1,9 +1,9 @@
import { spatialTypes } from "@hypit/spatial";
-import { svsRecipeType } from "@hypit/svs";
+import { recipeType } from "@hypit/recipe";
import { timelineTypes } from "@hypit/timeline";
import type { StructuredElement, StructuredSurfaceHandler, SurfaceResolvedReference } from "@hypit/markup";
-import { regionTrackFragment } from "./fragment.js";
+import { regionEvidenceFragment } from "./fragment.js";
function sameType(left: SurfaceResolvedReference["type"], right: SurfaceResolvedReference["type"]): boolean {
return left.module.name === right.module.name && left.module.version === right.module.version && left.name === right.name;
@@ -21,7 +21,7 @@ function reference(element: StructuredElement, name: string, type: SurfaceResolv
return result;
}
-export const decodeRegionTrackSurface: StructuredSurfaceHandler = ({ element, resolveReference }) => {
+export const decodeRegionEvidenceSurface: StructuredSurfaceHandler = ({ element, resolveReference }) => {
const allowed = ["id", "within", "timeline", "recipe"];
const unknown = Object.keys(element.attributes).find((name) => !allowed.includes(name));
if (unknown !== undefined) throw new Error(`${element.name} does not accept ${unknown}.`);
@@ -29,12 +29,12 @@ export const decodeRegionTrackSurface: StructuredSurfaceHandler = ({ element, re
const id = text(element, "id");
const within = reference(element, "within", spatialTypes.frame, resolveReference);
const timeline = reference(element, "timeline", timelineTypes.timeline, resolveReference);
- const recipe = reference(element, "recipe", svsRecipeType, resolveReference);
+ const recipe = reference(element, "recipe", recipeType, resolveReference);
return {
records: [],
- components: [{ id, fragment: regionTrackFragment.id, inputs: {
+ components: [{ id, fragment: regionEvidenceFragment.id, inputs: {
within: within.ref, timeline: timeline.ref, recipe: recipe.ref,
- }, outputs: { track: id }, range: element.range }],
- fragments: [regionTrackFragment], exports: [id],
+ }, outputs: { evidence: id }, range: element.range }],
+ fragments: [regionEvidenceFragment], exports: [id],
};
};
diff --git a/packages/region-track/src/types.ts b/packages/region-evidence/src/types.ts
similarity index 92%
rename from packages/region-track/src/types.ts
rename to packages/region-evidence/src/types.ts
index d1655c2b..c6e61c6f 100644
--- a/packages/region-track/src/types.ts
+++ b/packages/region-evidence/src/types.ts
@@ -7,7 +7,7 @@ export type RegionSeries = {
};
/** External spatial evidence indexed directly by one Timeline's frames. */
-export type RegionTrack = {
+export type RegionEvidence = {
readonly timelineId: string;
readonly series: readonly RegionSeries[];
};
diff --git a/packages/region-track/test/region-track.test.ts b/packages/region-evidence/test/region-evidence.test.ts
similarity index 60%
rename from packages/region-track/test/region-track.test.ts
rename to packages/region-evidence/test/region-evidence.test.ts
index 34aa2e66..5f1a8cc9 100644
--- a/packages/region-track/test/region-track.test.ts
+++ b/packages/region-evidence/test/region-evidence.test.ts
@@ -3,25 +3,25 @@ import test from "node:test";
import { sealTimeline } from "@hypit/timeline";
-import { resolveRegionTrack } from "../src/index.js";
+import { resolveRegionEvidence } from "../src/index.js";
-test("Region Track resolves normalized evidence inside any explicit program Frame", () => {
+test("Region Evidence resolves normalized evidence inside any explicit program Frame", () => {
const timeline = sealTimeline({ id: "program", frameCount: 3, frameRate: { numerator: 30, denominator: 1 } });
- const track = resolveRegionTrack({
+ const evidence = resolveRegionEvidence({
path: "/project/tracking.svs#heads.default",
properties: {
series: [{ id: "GUEST", regions: [[0.5, 0.1, 0.2, 0.3], null, [0.52, 0.11, 0.2, 0.3]] }],
},
}, { xPx: 100, yPx: 200, widthPx: 400, heightPx: 800 }, timeline);
- assert.deepEqual(track.series[0]?.frames[0], { xPx: 300, yPx: 280, widthPx: 80, heightPx: 240 });
- assert.equal(track.series[0]?.frames[1], null);
- assert.equal(track.timelineId, timeline.id);
+ assert.deepEqual(evidence.series[0]?.frames[0], { xPx: 300, yPx: 280, widthPx: 80, heightPx: 240 });
+ assert.equal(evidence.series[0]?.frames[1], null);
+ assert.equal(evidence.timelineId, timeline.id);
});
-test("Region Track rejects implicit gaps and geometry outside its declared Frame", () => {
+test("Region Evidence rejects implicit gaps and geometry outside its declared Frame", () => {
const timeline = sealTimeline({ id: "program", frameCount: 1, frameRate: { numerator: 30, denominator: 1 } });
- assert.throws(() => resolveRegionTrack({
+ assert.throws(() => resolveRegionEvidence({
path: "/project/tracking.svs#heads.default",
properties: { series: [{ id: "GUEST", regions: [[0.9, 0.1, 0.2, 0.3]] }] },
}, { xPx: 0, yPx: 0, widthPx: 100, heightPx: 100 }, timeline), /inside its Frame/u);
diff --git a/packages/region-track/src/activation.ts b/packages/region-track/src/activation.ts
deleted file mode 100644
index b223fb06..00000000
--- a/packages/region-track/src/activation.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-import { createMarkupSurfaceHostFacet } from "@hypit/markup";
-
-import {
- decodeRegionTrackSurface,
- regionTrackComponent,
- regionTrackManifest,
- regionTrackMarkupSurface,
- regionTrackModuleRef,
-} from "./index.js";
-
-export const hypitPackage = {
- format: "hypit.node-package@1" as const,
- modules: [{ manifest: regionTrackManifest }],
- components: [regionTrackComponent],
- hostFacets: [createMarkupSurfaceHostFacet({
- module: regionTrackModuleRef,
- declaration: regionTrackMarkupSurface,
- handler: decodeRegionTrackSurface,
- })],
-};
-export default hypitPackage;
diff --git a/packages/region-track/src/component.ts b/packages/region-track/src/component.ts
deleted file mode 100644
index 66962a38..00000000
--- a/packages/region-track/src/component.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-import type { ComponentPackage } from "@hypit/component-kit";
-import { canonicalize } from "@hypit/protocol";
-import type { StoredValue } from "@hypit/protocol";
-import type { SpatialFrame } from "@hypit/spatial";
-import type { SvsRecipe } from "@hypit/svs";
-import type { Timeline } from "@hypit/timeline";
-
-import { regionTrackProducers, regionTrackTypes } from "./manifest.js";
-import { assertRegionTrack, resolveRegionTrack } from "./region.js";
-import type { RegionTrack } from "./types.js";
-
-function inline<T>(value: StoredValue | undefined, label: string): T {
- if (value?.kind !== "inline") throw new Error(`${label} must be inline.`);
- return value.value as unknown as T;
-}
-const output = (value: unknown) => ({ kind: "inline" as const, value: canonicalize(value) });
-
-export const regionTrackComponent = {
- producers: [{ producer: regionTrackProducers.resolve, handler: ({ inputs }) => ({ outputs: { track: output(resolveRegionTrack(
- inline<SvsRecipe>(inputs.recipe?.value, "Recipe"),
- inline<SpatialFrame>(inputs.within?.value, "SpatialFrame"),
- inline<Timeline>(inputs.timeline?.value, "Timeline"),
- )) }, needs: {} }) }],
- validators: [{ type: regionTrackTypes.track, handler: ({ value }) => assertRegionTrack(inline<RegionTrack>(value, "RegionTrack")) }],
-} satisfies ComponentPackage;
diff --git a/packages/region-track/src/fragment.ts b/packages/region-track/src/fragment.ts
deleted file mode 100644
index 7171e982..00000000
--- a/packages/region-track/src/fragment.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import { sealGraphFragment } from "@hypit/elaborator";
-import { spatialTypes } from "@hypit/spatial";
-import { svsRecipeType } from "@hypit/svs";
-import { timelineTypes } from "@hypit/timeline";
-
-import { regionTrackProducers, regionTrackTypes } from "./manifest.js";
-
-const input = (name: string) => ({ kind: "fragment-input" as const, name });
-
-export const regionTrackFragment = sealGraphFragment({
- inputs: [
- { name: "within", type: spatialTypes.frame },
- { name: "timeline", type: timelineTypes.timeline },
- { name: "recipe", type: svsRecipeType },
- ],
- operations: [{ id: "resolve", producer: regionTrackProducers.resolve, inputs: {
- within: input("within"), timeline: input("timeline"), recipe: input("recipe"),
- }, result: { kind: "output", name: "track" } }],
- exports: [{ name: "track", type: regionTrackTypes.track, root: { kind: "fragment-operation", operation: "resolve" } }],
-});
diff --git a/packages/region-track/src/index.ts b/packages/region-track/src/index.ts
deleted file mode 100644
index 905d0f2d..00000000
--- a/packages/region-track/src/index.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-export { regionTrackComponent } from "./component.js";
-export { regionTrackFragment } from "./fragment.js";
-export {
- regionTrackDependency,
- regionTrackManifest,
- regionTrackMarkupSurface,
- regionTrackModuleRef,
- regionTrackProducers,
- regionTrackTypes,
-} from "./manifest.js";
-export { assertRegionTrack, resolveRegionTrack, sealRegionTrack } from "./region.js";
-export { regionTrackSchema } from "./schema.js";
-export { decodeRegionTrackSurface } from "./surface.js";
-export type * from "./types.js";
diff --git a/packages/script-studio/package.json b/packages/script-studio/package.json
deleted file mode 100644
index 014e916c..00000000
--- a/packages/script-studio/package.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "name": "@hypit/script-studio",
- "version": "0.0.0-dev",
- "license": "SEE LICENSE IN LICENSE",
- "private": true,
- "type": "module",
- "exports": {
- ".": "./src/index.ts"
- },
- "hypit": {
- "activation": "./src/activation.ts"
- },
- "dependencies": {
- "@hypit/script": "workspace:*",
- "@hypit/studio-adapter": "workspace:*",
- "@hypit/narrative": "workspace:*",
- "@hypit/narrative-temporal": "workspace:*",
- "@hypit/protocol": "workspace:*"
- }
-}
diff --git a/packages/script-studio/src/activation.ts b/packages/script-studio/src/activation.ts
deleted file mode 100644
index 91ea3fa9..00000000
--- a/packages/script-studio/src/activation.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import { createStudioCompanionHostFacet } from "@hypit/studio-adapter";
-
-import { scriptStudioTemporalDomains } from "./index.js";
-
-export default {
- format: "hypit.node-package@1" as const,
- hostFacets: [createStudioCompanionHostFacet({ temporalDomains: scriptStudioTemporalDomains })],
-};
diff --git a/packages/script-studio/src/index.ts b/packages/script-studio/src/index.ts
deleted file mode 100644
index 90443983..00000000
--- a/packages/script-studio/src/index.ts
+++ /dev/null
@@ -1,79 +0,0 @@
-import { projectScriptTemporalDomain } from "./projection.js";
-import { adjustScriptMoment, adjustScriptSelection, parseScript, scriptModuleRef } from "@hypit/script";
-import { narrativeTypes } from "@hypit/narrative";
-import { narrativeTemporalTypes } from "@hypit/narrative-temporal";
-import { sameType } from "@hypit/protocol";
-import type { StudioTemporalDomainCompanion } from "@hypit/studio-adapter";
-
-const scriptTemporalSourceTypes = [narrativeTypes.segmentRef, narrativeTypes.selection, narrativeTypes.moment] as const;
-
-export const scriptStudioTemporalDomains: readonly StudioTemporalDomainCompanion[] = [{
- id: "script",
- match: { module: scriptModuleRef, surface: "script" },
- valueTypes: [narrativeTypes.narrative, narrativeTemporalTypes.narrativeProjection],
- sourceTypes: scriptTemporalSourceTypes,
- presentation: { family: "narrative", tone: "teal", label: "Narrative", icon: "brand" },
- identify({ type, value }) {
- if (!scriptTemporalSourceTypes.some((candidate) => sameType(candidate, type))) return undefined;
- const held = value as { readonly narrativeId?: unknown; readonly id?: unknown; readonly kind?: unknown };
- if (typeof held.narrativeId !== "string" || typeof held.id !== "string") return undefined;
- const kind = sameType(type, narrativeTypes.segmentRef) ? "segment"
- : sameType(type, narrativeTypes.selection) ? "selection"
- : sameType(type, narrativeTypes.moment) ? "moment"
- : typeof held.kind === "string" ? held.kind : undefined;
- return kind === undefined ? undefined : { domainId: held.narrativeId, kind, id: held.id };
- },
- project: projectScriptTemporalDomain,
- observe(input) {
- const narrativeId = input.attributes.id ?? "script";
- if (typeof narrativeId !== "string" || narrativeId.length === 0) return undefined;
- if (input.source === undefined || input.contentStart === undefined) return undefined;
- const closing = `</${input.tag}>`;
- const closeEnd = input.nextOffset;
- if (closeEnd === undefined) return undefined;
- const end = closeEnd - closing.length;
- if (end < input.contentStart || input.source.slice(end, closeEnd) !== closing) return undefined;
- const parsed = parseScript(
- input.sourceName,
- input.source.slice(input.contentStart, end), input.contentStart,
- );
- return {
- domainId: narrativeId,
- sourcePath: input.sourceName,
- range: { start: input.range.start, end: closeEnd },
- content: { start: input.contentStart, end },
- data: {
- segments: parsed.segments.map((segment) => ({ id: segment.id, range: segment.range })),
- selections: parsed.selections.map((selection) => ({
- id: selection.id,
- startAnchorId: selection.startAnchorId,
- endAnchorId: selection.endAnchorId,
- open: selection.open.range,
- close: selection.close.range,
- })),
- moments: parsed.moments.map((moment) => ({ id: moment.id, anchorId: moment.anchorId, range: moment.range })),
- tokens: parsed.tokens.map((token) => ({ id: token.id, range: token.range })),
- },
- };
- },
- adjust(input) {
- const parsed = parseScript(input.sourceName, input.source);
- return input.adjustment.kind === "span"
- ? adjustScriptSelection({
- sourceName: input.sourceName,
- source: input.source,
- parsed,
- adjustment: {
- id: input.adjustment.itemId,
- startAnchorId: input.adjustment.startAnchorId,
- endAnchorId: input.adjustment.endAnchorId,
- },
- })
- : adjustScriptMoment({
- sourceName: input.sourceName,
- source: input.source,
- parsed,
- adjustment: { id: input.adjustment.itemId, anchorId: input.adjustment.anchorId },
- });
- },
-}];
diff --git a/packages/script/README.md b/packages/script/README.md
index 36c05e2b..96313166 100644
--- a/packages/script/README.md
+++ b/packages/script/README.md
@@ -9,6 +9,11 @@ absolute work boundaries belong to Timeline.
The package is an ordinary statically declared Surface module. Core does not import it and does not
know that Script, Segment or Narrative exist.
+The official video Distribution installs this package as an ordinary default npm dependency. Script
+owns its parser, formatter, source inverse and Studio temporal-domain facet; `@hypit/script/studio`
+exposes that facet for reuse. Packages that need Script-specific parsing depend on this package,
+while consumers of the result depend on the public Narrative, Caption and Text values instead.
+
```svml
<script id="story">
@{answer}
@@ -204,28 +209,6 @@ requested boundary needs an interior insertion site.
Writeback reparses the result to retain the requested bindings and unchanged speech, display and
Narrative/Caption content. Source offsets remain parser-private; no formatting history is stored.
-## Explicit migration from 0.1
-
-The 0.2 parser rejects bare `@name` markers. Preview migration from the repository or installed
-Distribution root, then explicitly write the reviewed result:
-
-```sh
-node packages/script/bin/migrate-0.2.mjs /path/to/film.svml
-node packages/script/bin/migrate-0.2.mjs /path/to/film.svml --write
-```
-
-Use `--body` for a file containing a raw Script body rather than outer SVML. The tool converts
-markers only inside Script bodies, leaves comments and escapes intact, and does not touch provider
-prompt references such as `@image1`. It neither installs anything nor runs during a build.
-
-The tool changes marker spelling, not marker placement. Move a marker that separates a word from
-its attached quote or punctuation to the complete word boundary before using that source.
-
-Review authored whitespace after migration: spaces previously discarded by Chinese/punctuation
-normalization now appear. The tool preserves source spaces rather than guessing the author's intent.
-Regenerate affected Narrative, caption and Build results with the new reader/writer together;
-protocol identities remain `@1`. Existing rendered media is not modified by source migration.
-
## Complete authored content and narrow exports
The root `story` Record contains only the complete Narrative: speech structure and semantic
diff --git a/packages/script/bin/migrate-0.2.mjs b/packages/script/bin/migrate-0.2.mjs
deleted file mode 100644
index 65eb064f..00000000
--- a/packages/script/bin/migrate-0.2.mjs
+++ /dev/null
@@ -1,90 +0,0 @@
-#!/usr/bin/env node
-/** Explicit, one-time marker migration. Never called by parsing, building, or Studio. */
-import { readFile, writeFile } from "node:fs/promises";
-import { resolve } from "node:path";
-import { pathToFileURL } from "node:url";
-
-export function migrateScriptBody(source) {
- let result = "";
- for (let cursor = 0; cursor < source.length;) {
- if (source[cursor] === "\\") {
- result += source.slice(cursor, cursor + 2);
- cursor += 2;
- continue;
- }
- if (source.startsWith("<!--", cursor)) {
- const close = source.indexOf("-->", cursor + 4);
- if (close < 0) throw new Error("Unclosed Script comment");
- result += source.slice(cursor, close + 3);
- cursor = close + 3;
- continue;
- }
- if (source.startsWith("@{", cursor)) {
- const close = source.indexOf("}", cursor + 2);
- if (close < 0) throw new Error("Unclosed delimited Script marker");
- result += source.slice(cursor, close + 1);
- cursor = close + 1;
- continue;
- }
- const rest = source.slice(cursor);
- const match = /^@\/([a-z][a-z0-9_-]{0,63})(~)/u.exec(rest)
- ?? /^@\/([a-z][a-z0-9_-]{0,63})(?![A-Za-z0-9_-])/u.exec(rest);
- const open = match ? undefined : /^(~)?@([a-z][a-z0-9_-]{0,63})(!)/u.exec(rest)
- ?? /^(~)?@([a-z][a-z0-9_-]{0,63})(?![A-Za-z0-9_-])/u.exec(rest);
- if (match) {
- result += `@{/${match[1]}${match[2] ?? ""}}`;
- cursor += match[0].length;
- } else if (open) {
- result += `@{${open[1] ?? ""}${open[2]}${open[3] ?? ""}}`;
- cursor += open[0].length;
- } else {
- result += source[cursor++];
- }
- }
- return result;
-}
-
-/** Change Script raw bodies only; package references and generation prompt tags stay untouched. */
-export function migrateSvml(source) {
- let result = "";
- let cursor = 0;
- const token = /<!--[\s\S]*?-->|<(?:[A-Za-z_][\w.-]*:)?script(?=[\s/>])(?:"[^"]*"|'[^']*'|[^'">])*>/gu;
- for (let match = token.exec(source); match; match = token.exec(source)) {
- if (match[0].startsWith("<!--") || match[0].endsWith("/>")) continue;
- const name = /^<([^\s>]+)/u.exec(match[0])[1];
- const close = `</${name}>`;
- const start = match.index + match[0].length;
- let end = start;
- while (end < source.length) {
- if (source[end] === "\\") { end += 2; continue; }
- if (source.startsWith("<!--", end)) {
- const stop = source.indexOf("-->", end + 4);
- if (stop < 0) throw new Error("Unclosed Script comment");
- end = stop + 3;
- continue;
- }
- if (source.startsWith(close, end)) break;
- end++;
- }
- if (end >= source.length) throw new Error(`Missing ${close}`);
- result += source.slice(cursor, start) + migrateScriptBody(source.slice(start, end)) + close;
- cursor = end + close.length;
- token.lastIndex = cursor;
- }
- return result + source.slice(cursor);
-}
-
-if (process.argv[1] && import.meta.url === pathToFileURL(resolve(process.argv[1])).href) {
- const args = process.argv.slice(2);
- const flags = new Set(args.filter(arg => arg.startsWith("--")));
- const paths = args.filter(arg => !arg.startsWith("--"));
- if (paths.length !== 1 || [...flags].some(flag => !["--write", "--body"].includes(flag))) {
- console.error("Usage: node migrate-0.2.mjs <source.svml> [--body] [--write]\nDefault: print migrated SVML. --body: input is a raw Script body. --write: replace the named file.");
- process.exitCode = 2;
- } else {
- const source = await readFile(paths[0], "utf8");
- const migrated = flags.has("--body") ? migrateScriptBody(source) : migrateSvml(source);
- if (flags.has("--write")) await writeFile(paths[0], migrated);
- else process.stdout.write(migrated);
- }
-}
diff --git a/packages/script/package.json b/packages/script/package.json
index 6426a35f..bb5f8560 100644
--- a/packages/script/package.json
+++ b/packages/script/package.json
@@ -1,24 +1,35 @@
{
"name": "@hypit/script",
- "version": "0.0.0-dev",
+ "version": "0.1.0",
"license": "SEE LICENSE IN LICENSE",
"private": true,
"type": "module",
"exports": {
- ".": "./src/index.ts"
+ ".": "./src/index.ts",
+ "./studio": "./src/studio.ts"
},
+ "files": [
+ "dist",
+ "README.md"
+ ],
"hypit": {
"activation": "./src/activation.ts"
},
- "dependencies": {
+ "peerDependencies": {
+ "@hypit/hypit": "workspace:^",
+ "@hypit/studio-companion": "workspace:^"
+ },
+ "devDependencies": {
+ "@hypit/hypit": "workspace:*",
+ "@hypit/studio-companion": "workspace:*",
"@hypit/caption": "workspace:*",
+ "@hypit/kernel": "workspace:*",
+ "@hypit/speech-estimate": "workspace:*",
+ "@hypit/markup": "workspace:*",
"@hypit/narrative": "workspace:*",
"@hypit/narrative-caption": "workspace:*",
+ "@hypit/narrative-temporal": "workspace:*",
"@hypit/protocol": "workspace:*",
- "@hypit/text": "workspace:*",
- "@hypit/markup": "workspace:*"
- },
- "devDependencies": {
- "@hypit/core": "workspace:*"
+ "@hypit/text": "workspace:*"
}
}
diff --git a/packages/script/src/activation.ts b/packages/script/src/activation.ts
index b389871c..d15b4584 100644
--- a/packages/script/src/activation.ts
+++ b/packages/script/src/activation.ts
@@ -1,4 +1,5 @@
-import { createMarkupSurfaceHostFacet } from "@hypit/markup";
+import { createMarkupSurfaceFacet } from "@hypit/hypit/markup";
+import { createStudioCompanionFacet } from "@hypit/studio-companion";
import {
decodeScriptSurface,
@@ -6,15 +7,19 @@ import {
scriptModuleRef,
scriptMarkupSurfaces,
} from "./index.js";
+import { scriptStudioTemporalDomains } from "./studio.js";
export const hypitPackage = {
- format: "hypit.node-package@1" as const,
+ format: "hypit.package@1" as const,
modules: [{ manifest: scriptManifest }],
- hostFacets: [createMarkupSurfaceHostFacet({
- module: scriptModuleRef,
- declaration: scriptMarkupSurfaces.find((item) => item.name === "script")!,
- handler: decodeScriptSurface,
- })],
+ facets: [
+ createMarkupSurfaceFacet({
+ module: scriptModuleRef,
+ declaration: scriptMarkupSurfaces.find((item) => item.name === "script")!,
+ handler: decodeScriptSurface,
+ }),
+ createStudioCompanionFacet({ temporalDomains: scriptStudioTemporalDomains }),
+ ],
};
export default hypitPackage;
diff --git a/packages/script/src/edit.ts b/packages/script/src/edit.ts
index a80167f9..06f331e4 100644
--- a/packages/script/src/edit.ts
+++ b/packages/script/src/edit.ts
@@ -1,6 +1,5 @@
-import type { SourceRange } from "@hypit/protocol";
-
-import { canonicalStringify } from "@hypit/protocol";
+import { canonicalStringify } from "@hypit/hypit/protocol";
+import type { SourceRange } from "@hypit/hypit/protocol";
import { captionDocument, narrativeValue } from "./narrative.js";
import { parseScript } from "./parser.js";
import type { Affinity, ParsedNarrative, SemanticAnchor } from "./types.js";
diff --git a/packages/script/src/format.ts b/packages/script/src/format.ts
index eae70840..275dbe4f 100644
--- a/packages/script/src/format.ts
+++ b/packages/script/src/format.ts
@@ -1,4 +1,4 @@
-import { canonicalStringify } from "@hypit/protocol";
+import { canonicalStringify } from "@hypit/hypit/protocol";
import { ScriptSyntaxError } from "./error.js";
import { narrativeValue } from "./narrative.js";
diff --git a/packages/script/src/manifest.ts b/packages/script/src/manifest.ts
index e9d2e5dd..09ee3c1c 100644
--- a/packages/script/src/manifest.ts
+++ b/packages/script/src/manifest.ts
@@ -1,8 +1,8 @@
-import { captionDependency, captionTypes } from "@hypit/caption";
-import { narrativeDependency, narrativeSchema, narrativeTypes } from "@hypit/narrative";
-import { narrativeCaptionDependency, narrativeCaptionTypes } from "@hypit/narrative-caption";
-import { textDependency, textTypes } from "@hypit/text";
-import type { ModuleManifest, TypeRef } from "@hypit/protocol";
+import type { ModuleManifest, TypeRef } from "@hypit/hypit/protocol";
+import { captionDependency, captionTypes } from "@hypit/hypit/caption";
+import { narrativeDependency, narrativeSchema, narrativeTypes } from "@hypit/hypit/narrative";
+import { narrativeCaptionDependency, narrativeCaptionTypes } from "@hypit/hypit/narrative-caption";
+import { textDependency, textTypes } from "@hypit/hypit/text";
export const scriptModuleRef = { name: "@hypit/script", version: "1" } as const;
export const narrativeType: TypeRef = narrativeTypes.narrative;
diff --git a/packages/script/src/narrative.ts b/packages/script/src/narrative.ts
index 724dd429..53b0df22 100644
--- a/packages/script/src/narrative.ts
+++ b/packages/script/src/narrative.ts
@@ -1,8 +1,8 @@
-import { canonicalize } from "@hypit/protocol";
-import type { CanonicalValue } from "@hypit/protocol";
-import type { CaptionDocument, CaptionDisplayWord, CaptionUnit } from "@hypit/caption";
-import type { NarrativeCaptionBinding } from "@hypit/narrative-caption";
-import { sealText } from "@hypit/text";
+import { canonicalize } from "@hypit/hypit/protocol";
+import type { CanonicalValue } from "@hypit/hypit/protocol";
+import type { CaptionDocument, CaptionDisplayWord, CaptionUnit } from "@hypit/hypit/caption";
+import type { NarrativeCaptionBinding } from "@hypit/hypit/narrative-caption";
+import { sealText } from "@hypit/hypit/text";
import type { ParsedCaptionRegion, ParsedNarrative } from "./types.js";
import { cleanProjection, displaySurfaces, joinProjection, lexicalCount } from "./lexical.js";
diff --git a/packages/script/src/parser.ts b/packages/script/src/parser.ts
index 76ab5bfa..1c249ad3 100644
--- a/packages/script/src/parser.ts
+++ b/packages/script/src/parser.ts
@@ -505,7 +505,7 @@ export function parseScript(
}
const marker = parseMarker(raw, index);
if (!marker) {
- if (raw[index] === "@") fail("SCRIPT_MARKER", "Unescaped @ must begin a delimited @{...} marker; migrate bare markers from 0.1 explicitly.", absoluteStart + index);
+ if (raw[index] === "@") fail("SCRIPT_MARKER", "Unescaped @ must begin a delimited @{...} marker.", absoluteStart + index);
index += 1;
continue;
}
@@ -614,7 +614,7 @@ export function parseScript(
offset += marker.length;
continue;
}
- if (source[offset] === "@") fail("SCRIPT_MARKER", "Unescaped @ must begin a delimited @{...} marker; migrate bare markers from 0.1 explicitly.", offset);
+ if (source[offset] === "@") fail("SCRIPT_MARKER", "Unescaped @ must begin a delimited @{...} marker.", offset);
if (source[offset] === "<" && current) {
const end = findUnescaped(source, ">", offset + 1);
diff --git a/packages/script-studio/src/projection.ts b/packages/script/src/studio.ts
similarity index 62%
rename from packages/script-studio/src/projection.ts
rename to packages/script/src/studio.ts
index 4cce4609..3836d5c4 100644
--- a/packages/script-studio/src/projection.ts
+++ b/packages/script/src/studio.ts
@@ -1,8 +1,17 @@
-import { narrativeTypes } from "@hypit/narrative";
-import { narrativeTemporalTypes } from "@hypit/narrative-temporal";
-import type { NarrativeProjection } from "@hypit/narrative-temporal";
-import { sameType } from "@hypit/protocol";
-import type { Range, StudioTemporalDomainProjection, StudioTemporalDomainProjectionInput } from "@hypit/studio-adapter";
+import { narrativeTypes } from "@hypit/hypit/narrative";
+import { narrativeTemporalTypes } from "@hypit/hypit/narrative-temporal";
+import type { NarrativeProjection } from "@hypit/hypit/narrative-temporal";
+import { sameType } from "@hypit/hypit/protocol";
+import type {
+ Range,
+ StudioTemporalDomainCompanion,
+ StudioTemporalDomainProjection,
+ StudioTemporalDomainProjectionInput,
+} from "@hypit/studio-companion";
+
+import { adjustScriptMoment, adjustScriptSelection } from "./edit.js";
+import { scriptModuleRef } from "./manifest.js";
+import { parseScript } from "./parser.js";
type NarrativeValue = {
readonly id?: string;
@@ -85,3 +94,62 @@ export function projectScriptTemporalDomain(input: StudioTemporalDomainProjectio
...(selections.length + moments.length === 0 ? [] : [{ id: "intent", label: "Intent", heightPx: 26 }])],
anchors, items: [...segments, ...tokens, ...selections, ...moments] };
}
+
+const scriptTemporalSourceTypes = [narrativeTypes.segmentRef, narrativeTypes.selection, narrativeTypes.moment] as const;
+
+export const scriptStudioTemporalDomains: readonly StudioTemporalDomainCompanion[] = [{
+ id: "script",
+ match: { module: scriptModuleRef, surface: "script" },
+ valueTypes: [narrativeTypes.narrative, narrativeTemporalTypes.narrativeProjection],
+ sourceTypes: scriptTemporalSourceTypes,
+ presentation: { family: "narrative", tone: "teal", label: "Narrative", icon: "brand" },
+ identify({ type, value }) {
+ if (!scriptTemporalSourceTypes.some((candidate) => sameType(candidate, type))) return undefined;
+ const held = value as { readonly narrativeId?: unknown; readonly id?: unknown; readonly kind?: unknown };
+ if (typeof held.narrativeId !== "string" || typeof held.id !== "string") return undefined;
+ const kind = sameType(type, narrativeTypes.segmentRef) ? "segment"
+ : sameType(type, narrativeTypes.selection) ? "selection"
+ : sameType(type, narrativeTypes.moment) ? "moment"
+ : typeof held.kind === "string" ? held.kind : undefined;
+ return kind === undefined ? undefined : { domainId: held.narrativeId, kind, id: held.id };
+ },
+ project: projectScriptTemporalDomain,
+ observe(input) {
+ const narrativeId = input.attributes.id ?? "script";
+ if (typeof narrativeId !== "string" || narrativeId.length === 0) return undefined;
+ if (input.source === undefined || input.contentStart === undefined) return undefined;
+ const closing = `</${input.tag}>`;
+ const closeEnd = input.nextOffset;
+ if (closeEnd === undefined) return undefined;
+ const end = closeEnd - closing.length;
+ if (end < input.contentStart || input.source.slice(end, closeEnd) !== closing) return undefined;
+ const parsed = parseScript(input.sourceName, input.source.slice(input.contentStart, end), input.contentStart);
+ return {
+ domainId: narrativeId,
+ sourcePath: input.sourceName,
+ range: { start: input.range.start, end: closeEnd },
+ content: { start: input.contentStart, end },
+ data: {
+ segments: parsed.segments.map((segment) => ({ id: segment.id, range: segment.range })),
+ selections: parsed.selections.map((selection) => ({
+ id: selection.id,
+ startAnchorId: selection.startAnchorId,
+ endAnchorId: selection.endAnchorId,
+ open: selection.open.range,
+ close: selection.close.range,
+ })),
+ moments: parsed.moments.map((moment) => ({ id: moment.id, anchorId: moment.anchorId, range: moment.range })),
+ tokens: parsed.tokens.map((token) => ({ id: token.id, range: token.range })),
+ },
+ };
+ },
+ adjust(input) {
+ const parsed = parseScript(input.sourceName, input.source);
+ return input.adjustment.kind === "span"
+ ? adjustScriptSelection({ sourceName: input.sourceName, source: input.source, parsed,
+ adjustment: { id: input.adjustment.itemId, startAnchorId: input.adjustment.startAnchorId,
+ endAnchorId: input.adjustment.endAnchorId } })
+ : adjustScriptMoment({ sourceName: input.sourceName, source: input.source, parsed,
+ adjustment: { id: input.adjustment.itemId, anchorId: input.adjustment.anchorId } });
+ },
+}];
diff --git a/packages/script/src/surface.ts b/packages/script/src/surface.ts
index 12522c8b..ee480153 100644
--- a/packages/script/src/surface.ts
+++ b/packages/script/src/surface.ts
@@ -17,8 +17,8 @@ import {
narrativeSelectionType,
narrativeType,
} from "./manifest.js";
-import { canonicalize } from "@hypit/protocol";
-import { textTypes } from "@hypit/text";
+import { canonicalize } from "@hypit/hypit/protocol";
+import { textTypes } from "@hypit/hypit/text";
import { parseScript } from "./parser.js";
import type { ScriptSurfaceInput, ScriptSurfaceOutput } from "./types.js";
diff --git a/packages/script/src/types.ts b/packages/script/src/types.ts
index 90b182f9..26a9f264 100644
--- a/packages/script/src/types.ts
+++ b/packages/script/src/types.ts
@@ -1,9 +1,9 @@
-import type { CanonicalValue, SourceRange, StoredValue, TypeRef } from "@hypit/protocol";
-import type { CaptionWordAttribute } from "@hypit/caption";
-import type { Narrative, NarrativeMoment, NarrativeSegment, NarrativeSelection, NarrativeToken, NarrativeTurn } from "@hypit/narrative";
+import type { CanonicalValue, SourceRange, StoredValue, TypeRef } from "@hypit/hypit/protocol";
+import type { CaptionWordAttribute } from "@hypit/hypit/caption";
+import type { Narrative, NarrativeMoment, NarrativeSegment, NarrativeSelection, NarrativeToken, NarrativeTurn } from "@hypit/hypit/narrative";
-export type { CaptionWordAttribute } from "@hypit/caption";
-export type { Narrative, SemanticAnchor } from "@hypit/narrative";
+export type { CaptionWordAttribute } from "@hypit/hypit/caption";
+export type { Narrative, SemanticAnchor } from "@hypit/hypit/narrative";
export type Affinity = "left" | "right";
diff --git a/packages/script/test/display-spacing.test.ts b/packages/script/test/display-spacing.test.ts
index de464084..40620648 100644
--- a/packages/script/test/display-spacing.test.ts
+++ b/packages/script/test/display-spacing.test.ts
@@ -1,10 +1,5 @@
import assert from "node:assert/strict";
import test from "node:test";
-import { mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
-import { tmpdir } from "node:os";
-import { join } from "node:path";
-import { execFileSync } from "node:child_process";
-import { fileURLToPath } from "node:url";
import { adjustScriptSelection, captionDocument, narrativeCaptionBinding, parseScript, serializeCaption, serializeSpeech } from "@hypit/script";
function displayed(body: string) {
@@ -83,19 +78,3 @@ test("moving a Selection inside shared text preserves spelling, properties and u
assert.equal(serializeSpeech(after), serializeSpeech(parsed));
assert.deepEqual(captionDocument(after, "c", "s"), captionDocument(parsed, "c", "s"));
});
-
-test("explicit migration changes only Script markers and leaves the original file untouched by default", async () => {
- const directory = await mkdtemp(join(tmpdir(), "hypit-script-migrate-"));
- try {
- const path = join(directory, "film.svml");
- const source = '<prompt>@image1 stays</prompt>\n<script id="s">@whole<line>是的 @part <3D|>@/part @beat!好</line>@/whole~</script>';
- const expected = '<prompt>@image1 stays</prompt>\n<script id="s">@{whole}<line>是的 @{part} <3D|>@{/part} @{beat!}好</line>@{/whole~}</script>';
- await writeFile(path, source);
- const tool = fileURLToPath(new URL("../bin/migrate-0.2.mjs", import.meta.url));
- assert.equal(execFileSync(process.execPath, [tool, path], { encoding: "utf8" }), expected);
- assert.equal(await readFile(path, "utf8"), source);
- execFileSync(process.execPath, [tool, path, "--write"]);
- assert.equal(await readFile(path, "utf8"), expected);
- assert.equal(execFileSync(process.execPath, [tool, path], { encoding: "utf8" }), expected);
- } finally { await rm(directory, { recursive: true, force: true }); }
-});
diff --git a/packages/script/test/markup-integration.test.ts b/packages/script/test/markup-integration.test.ts
index 5712644b..d8dcae0d 100644
--- a/packages/script/test/markup-integration.test.ts
+++ b/packages/script/test/markup-integration.test.ts
@@ -6,7 +6,7 @@ import { textManifest } from "@hypit/text";
import assert from "node:assert/strict";
import test from "node:test";
-import { createResolvedClosure } from "@hypit/core";
+import { createResolvedClosure } from "@hypit/kernel";
import type { ModuleManifest } from "@hypit/protocol";
import {
decodeScriptSurface,
diff --git a/packages/script/test/narrative-views.test.ts b/packages/script/test/narrative-views.test.ts
index 356942a6..c14ea5f8 100644
--- a/packages/script/test/narrative-views.test.ts
+++ b/packages/script/test/narrative-views.test.ts
@@ -10,7 +10,7 @@ import type { CaptionDocument, CaptionProgram } from "@hypit/caption";
import { captionUnitsForNarrativeSelection } from "@hypit/narrative-caption";
import { parseStructuredElement } from "@hypit/markup";
import type { SurfaceResolvedReference } from "@hypit/markup";
-import { countSpeechEstimateUnits } from "@hypit/estimate";
+import { countSpeechEstimateUnits } from "@hypit/speech-estimate";
import type { Text } from "@hypit/text";
const body = `<intro><HOST>Try @{brand} <hypit|Hai-Pit> @{/brand} today. ||</intro>
diff --git a/packages/script-studio/test/script.test.ts b/packages/script/test/studio-companion.test.ts
similarity index 85%
rename from packages/script-studio/test/script.test.ts
rename to packages/script/test/studio-companion.test.ts
index 661c1b20..36339abe 100644
--- a/packages/script-studio/test/script.test.ts
+++ b/packages/script/test/studio-companion.test.ts
@@ -1,9 +1,9 @@
import assert from "node:assert/strict";
import test from "node:test";
-import { decodeScriptSurface, parseScript, captionDocument } from "@hypit/script";
import { narrativeTemporalTypes } from "@hypit/narrative-temporal";
-import { scriptStudioTemporalDomains } from "../src/index.js";
-import type { ScriptStudioObservation } from "../src/projection.js";
+import { captionDocument, decodeScriptSurface, parseScript } from "@hypit/script";
+import { scriptStudioTemporalDomains } from "@hypit/script/studio";
+import type { ScriptStudioObservation } from "@hypit/script/studio";
test("Studio observes and edits the compiler's Script body without changing its prose", () => {
const companion = scriptStudioTemporalDomains[0]!;
@@ -11,13 +11,13 @@ test("Studio observes and edits the compiler's Script body without changing its
const prefix = '<svml>\r\n<!-- 🎬 -->\r\n<script id="story">';
const source = `${prefix}${body}</script>\r\n</svml>`;
const input = { sourceName: "studio.svml", source, tag: "script", attributes: { id: "story" },
- openingStart: source.indexOf('<script'),
- range: { start: source.indexOf('<script'), end: source.length - "\r\n</svml>".length }, contentStart: prefix.length };
+ openingStart: source.indexOf("<script"),
+ range: { start: source.indexOf("<script"), end: source.length - "\r\n</svml>".length }, contentStart: prefix.length };
const decoded = decodeScriptSurface(input);
const observed = companion.observe({ ...input, nextOffset: decoded.nextOffset })!;
assert.equal(source.slice(observed.content.start, observed.content.end), body);
const observation = observed.data as ScriptStudioObservation;
- assert.equal(source.slice(observation.moments[0]!.range.start, observation.moments[0]!.range.end), '@{beat!}');
+ assert.equal(source.slice(observation.moments[0]!.range.start, observation.moments[0]!.range.end), "@{beat!}");
const parsed = parseScript("body", body);
const anchorId = parsed.tokens[0]!.startAnchorId;
@@ -25,7 +25,7 @@ test("Studio observes and edits the compiler's Script body without changing its
adjustment: { kind: "point", itemId: "beat", anchorId } });
const after = parseScript("body", changed);
assert.equal(after.moments[0]!.anchorId, anchorId);
- assert.equal(changed.replace('@{beat!}', ''), body.replace('@{beat!}', ''));
+ assert.equal(changed.replace("@{beat!}", ""), body.replace("@{beat!}", ""));
assert.equal(after.serializations.speech, parsed.serializations.speech);
assert.deepEqual(captionDocument(after, "caption", "story"), captionDocument(parsed, "caption", "story"));
diff --git a/packages/spatial/README.md b/packages/spatial/README.md
index a85c1253..98af364d 100644
--- a/packages/spatial/README.md
+++ b/packages/spatial/README.md
@@ -69,7 +69,7 @@ pure functions.
## Evidence over time is a peer package
-Frame-indexed observations do not belong to static geometry. `@hypit/region-track` relates prepared
+Frame-indexed observations do not belong to static geometry. `@hypit/region-evidence` relates prepared
regions to a Timeline and resolves them into picture-plane Frames. Detection, identity association,
interpolation and source-to-picture projection remain explicit preparation or project-package work.
This keeps Spatial reusable and prevents a central scene or evidence registry.
diff --git a/packages/spatial/package.json b/packages/spatial/package.json
index 134147e2..0f83ca4a 100644
--- a/packages/spatial/package.json
+++ b/packages/spatial/package.json
@@ -11,13 +11,16 @@
"activation": "./src/activation.ts"
},
"dependencies": {
- "@hypit/component-kit": "workspace:*",
- "@hypit/elaborator": "workspace:*",
+ "@hypit/producer": "workspace:*",
+ "@hypit/author": "workspace:*",
"@hypit/protocol": "workspace:*",
- "@hypit/markup": "workspace:*"
+ "@hypit/markup": "workspace:*",
+ "@hypit/admission": "workspace:*"
},
"devDependencies": {
- "@hypit/core": "workspace:*",
- "@hypit/validation": "workspace:*"
+ "@hypit/compiler": "workspace:*",
+ "@hypit/source": "workspace:*",
+ "@hypit/kernel": "workspace:*",
+ "@hypit/admission": "workspace:*"
}
}
diff --git a/packages/spatial/src/activation.ts b/packages/spatial/src/activation.ts
index 21216143..5203cfd9 100644
--- a/packages/spatial/src/activation.ts
+++ b/packages/spatial/src/activation.ts
@@ -1,4 +1,6 @@
-import { createMarkupSurfaceHostFacet } from "@hypit/markup";
+import { createAdmissionPackageFacet } from "@hypit/admission";
+import { createProducerPackageFacet } from "@hypit/producer";
+import { createMarkupSurfaceFacet } from "@hypit/markup";
import {
decodeAnchoredFrameSurface,
@@ -18,25 +20,25 @@ import {
import { spatialComponent } from "./component.js";
export const hypitPackage = {
- format: "hypit.node-package@1" as const,
+ format: "hypit.package@1" as const,
modules: [{ manifest: spatialManifest }],
- components: [spatialComponent],
- hostFacets: [
- createMarkupSurfaceHostFacet({ module: spatialModuleRef,
+ facets: [
+ ...[spatialComponent].flatMap((component) => [createProducerPackageFacet(component), createAdmissionPackageFacet(component)]),
+ createMarkupSurfaceFacet({ module: spatialModuleRef,
declaration: spatialMarkupSurfaces.find((item) => item.name === "canvas")!, handler: decodeCanvasSurface }),
- createMarkupSurfaceHostFacet({ module: spatialModuleRef,
+ createMarkupSurfaceFacet({ module: spatialModuleRef,
declaration: spatialMarkupSurfaces.find((item) => item.name === "point")!, handler: decodePointSurface }),
- createMarkupSurfaceHostFacet({ module: spatialModuleRef,
+ createMarkupSurfaceFacet({ module: spatialModuleRef,
declaration: spatialMarkupSurfaces.find((item) => item.name === "path")!, handler: decodePathSurface }),
- createMarkupSurfaceHostFacet({ module: spatialModuleRef,
+ createMarkupSurfaceFacet({ module: spatialModuleRef,
declaration: spatialMarkupSurfaces.find((item) => item.name === "extent")!, handler: decodeExtentSurface }),
- createMarkupSurfaceHostFacet({ module: spatialModuleRef,
+ createMarkupSurfaceFacet({ module: spatialModuleRef,
declaration: spatialMarkupSurfaces.find((item) => item.name === "map")!, handler: decodeMapSurface }),
- createMarkupSurfaceHostFacet({ module: spatialModuleRef,
+ createMarkupSurfaceFacet({ module: spatialModuleRef,
declaration: spatialMarkupSurfaces.find((item) => item.name === "frame")!, handler: decodeFrameSurface }),
- createMarkupSurfaceHostFacet({ module: spatialModuleRef,
+ createMarkupSurfaceFacet({ module: spatialModuleRef,
declaration: spatialMarkupSurfaces.find((item) => item.name === "anchored-frame")!, handler: decodeAnchoredFrameSurface }),
- createMarkupSurfaceHostFacet({ module: spatialModuleRef,
+ createMarkupSurfaceFacet({ module: spatialModuleRef,
declaration: spatialMarkupSurfaces.find((item) => item.name === "aspect-frame")!, handler: decodeAspectFrameSurface }),
],
};
diff --git a/packages/spatial/src/component.ts b/packages/spatial/src/component.ts
index 7dae8de1..79cb6fc1 100644
--- a/packages/spatial/src/component.ts
+++ b/packages/spatial/src/component.ts
@@ -1,4 +1,5 @@
-import type { ComponentPackage } from "@hypit/component-kit";
+import type { AdmissionPackage } from "@hypit/admission";
+import type { ProducerPackage } from "@hypit/producer";
import { canonicalize } from "@hypit/protocol";
import type { StoredValue } from "@hypit/protocol";
import { anchoredFrame, aspectFrame, assertCanvas, assertContentFit, assertIntrinsicExtent, assertSpatialFrame, assertSpatialMap2D, assertSpatialPath, assertSpatialPoint, frameFromEdges, resolveContentFit } from "./geometry.js";
@@ -38,4 +39,4 @@ export const spatialComponent = {
{ type: spatialTypes.map2D, handler: ({ value }) => assertSpatialMap2D(inline<SpatialMap2D>(value, "SpatialMap2D")) },
{ type: spatialTypes.fit, handler: ({ value }) => assertContentFit(inline<ContentFit>(value, "ContentFit")) },
],
-} satisfies ComponentPackage;
+} satisfies ProducerPackage & AdmissionPackage;
diff --git a/packages/spatial/src/fragment.ts b/packages/spatial/src/fragment.ts
index 7bdb58d7..128b33fb 100644
--- a/packages/spatial/src/fragment.ts
+++ b/packages/spatial/src/fragment.ts
@@ -1,4 +1,4 @@
-import { sealGraphFragment } from "@hypit/elaborator";
+import { sealGraphFragment } from "@hypit/author";
import { spatialProducers, spatialTypes } from "./manifest.js";
const input = (name: string) => ({ kind: "fragment-input" as const, name });
diff --git a/packages/spatial/src/surface.ts b/packages/spatial/src/surface.ts
index 271eb888..e8044834 100644
--- a/packages/spatial/src/surface.ts
+++ b/packages/spatial/src/surface.ts
@@ -1,5 +1,5 @@
import type { CanonicalValue } from "@hypit/protocol";
-import type { AuthorValueRef } from "@hypit/elaborator";
+import type { AuthorValueRef } from "@hypit/author";
import type {
StructuredElement,
StructuredSurfaceHandler,
diff --git a/packages/spatial/test/spatial.test.ts b/packages/spatial/test/spatial.test.ts
index e6a8a177..1dc7cc57 100644
--- a/packages/spatial/test/spatial.test.ts
+++ b/packages/spatial/test/spatial.test.ts
@@ -1,15 +1,17 @@
import assert from "node:assert/strict";
import test from "node:test";
-import { registerTypeValidatorFacets } from "@hypit/component-kit";
-import { createResolvedClosure, sealBuildRequest, start } from "@hypit/core";
-import { AuthorFrontendRegistry, compileSourceClosure, resolveCompiledSourceExport } from "@hypit/elaborator";
-import type { AuthorSourceUnit } from "@hypit/elaborator";
+import { registerTypeValidatorFacets } from "@hypit/admission";
+import { createResolvedClosure, sealBuildRequest, start } from "@hypit/kernel";
+import { AuthorFrontendRegistry, resolveCompiledSourceExport } from "@hypit/author";
+import { compileSourceClosure } from "@hypit/compiler";
+import type { ResolvedSource } from "@hypit/source";
+import { resolveSelfDescribedTextSource } from "@hypit/source/text";
import {
MarkupSurfaceRegistry,
createMarkupAuthorFrontend,
} from "@hypit/markup";
-import { createRecordAdmitter, TypeValidatorRegistry } from "@hypit/validation";
+import { createRecordAdmitter, TypeValidatorRegistry } from "@hypit/admission";
import {
anchoredFrame,
@@ -208,8 +210,8 @@ test("SpatialPath is typed geometry and rejects an empty or stateful command str
assert.throws(() => sealSpatialPath({ commands: [{ kind: "move", xPx: 0, yPx: 0 }, { kind: "close" }] }), /no drawable/u);
});
-function source(text: string): AuthorSourceUnit {
- return { id: "/project/main.svml", name: "main.svml", text: `<?svml using="@hypit/markup@1"?>\n${text}` };
+function source(text: string): ResolvedSource {
+ return resolveSelfDescribedTextSource({ id: "/project/main.svml", name: "main.svml", text: `<?svml using="@hypit/markup@1"?>\n${text}` });
}
test("self-described Spatial Surfaces produce explicit static geometry", async () => {
diff --git a/packages/speech-alignment/package.json b/packages/speech-alignment/package.json
deleted file mode 100644
index 50379b2f..00000000
--- a/packages/speech-alignment/package.json
+++ /dev/null
@@ -1,24 +0,0 @@
-{
- "name": "@hypit/speech-alignment",
- "version": "0.0.0-dev",
- "license": "SEE LICENSE IN LICENSE",
- "private": true,
- "type": "module",
- "exports": {
- ".": "./src/index.ts"
- },
- "hypit": {
- "activation": "./src/activation.ts"
- },
- "dependencies": {
- "@hypit/component-kit": "workspace:*",
- "@hypit/narrative": "workspace:*",
- "@hypit/narrative-temporal": "workspace:*",
- "@hypit/protocol": "workspace:*",
- "@hypit/speech-evidence": "workspace:*",
- "@hypit/temporal": "workspace:*"
- },
- "devDependencies": {
- "@hypit/script": "workspace:*"
- }
-}
diff --git a/packages/speech-alignment/src/activation.ts b/packages/speech-alignment/src/activation.ts
deleted file mode 100644
index 20009b05..00000000
--- a/packages/speech-alignment/src/activation.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import { speechAlignmentComponent, speechAlignmentManifest } from "./index.js";
-
-export const hypitPackage = {
- format: "hypit.node-package@1" as const,
- modules: [{ manifest: speechAlignmentManifest }],
- components: [speechAlignmentComponent],
-};
-export default hypitPackage;
diff --git a/packages/speech-evidence/README.md b/packages/speech-evidence/README.md
index 5fc9eee5..aeec3e81 100644
--- a/packages/speech-evidence/README.md
+++ b/packages/speech-evidence/README.md
@@ -10,3 +10,21 @@ Module identity remains `@hypit/speech-evidence@1`.
that domain identity and sample span while adding measured passages, words, characters and speech
activity. Providers therefore return evidence for the same explicit source domain rather than an
unidentified transcript that a later package must reconnect by inspecting Media.
+
+The package also owns the provider-neutral `project-speech-evidence-audio` Capability and its
+deterministic request Producer. That Producer verifies one `SynchronizedMedia` value against its
+explicit `LocalTemporalDomain`, then requests the exact 16 kHz mono projection. A media Provider may
+implement the bytes, but media operations do not own the acoustic-evidence contract.
+
+## Transcript evidence document
+
+`hypit.transcript@1` is the portable file view written by model-specific transcription tools. This
+package owns its parsing and its exact word/phrase range operations because those operations concern
+speech evidence, not FFmpeg and not a Timeline. A local-media inspection tool may use the returned
+seconds ranges to select frames, but it does not acquire ownership of transcript meaning.
+
+`wordsAt` uses half-open word spans and preserves overlaps. `phraseRanges` matches whole consecutive
+words, preserves repeated occurrences and returns each measured range; it never guesses which
+occurrence an author intended. Missing word times remain missing rather than being inferred as
+silence. These values stay on the transcript input's local clock until an explicit semantic mapping
+projects evidence onto authored Narrative.
diff --git a/packages/speech-evidence/package.json b/packages/speech-evidence/package.json
index aa4b59db..5fc5d2e9 100644
--- a/packages/speech-evidence/package.json
+++ b/packages/speech-evidence/package.json
@@ -11,8 +11,11 @@
"activation": "./src/activation.ts"
},
"dependencies": {
- "@hypit/component-kit": "workspace:*",
- "@hypit/protocol": "workspace:*"
+ "@hypit/producer": "workspace:*",
+ "@hypit/media": "workspace:*",
+ "@hypit/protocol": "workspace:*",
+ "@hypit/temporal": "workspace:*",
+ "@hypit/admission": "workspace:*"
},
"devDependencies": {
"@hypit/timeline": "workspace:*"
diff --git a/packages/speech-evidence/src/activation.ts b/packages/speech-evidence/src/activation.ts
index 173bd920..7ef86a95 100644
--- a/packages/speech-evidence/src/activation.ts
+++ b/packages/speech-evidence/src/activation.ts
@@ -1,8 +1,10 @@
+import { createAdmissionPackageFacet } from "@hypit/admission";
+import { createProducerPackageFacet } from "@hypit/producer";
import { speechEvidenceComponent } from "./component.js";
import { speechEvidenceManifest } from "./index.js";
export const hypitPackage = {
- format: "hypit.node-package@1" as const,
+ format: "hypit.package@1" as const,
modules: [{ manifest: speechEvidenceManifest }],
- components: [speechEvidenceComponent],
+ facets: [...[speechEvidenceComponent].flatMap((component) => [createProducerPackageFacet(component), createAdmissionPackageFacet(component)])],
};
export default hypitPackage;
diff --git a/packages/speech-evidence/src/component.ts b/packages/speech-evidence/src/component.ts
index c2b5dc7a..f82844b1 100644
--- a/packages/speech-evidence/src/component.ts
+++ b/packages/speech-evidence/src/component.ts
@@ -1,12 +1,22 @@
-import type { ComponentPackage } from "@hypit/component-kit";
+import type { AdmissionPackage } from "@hypit/admission";
+import { plannedNeedInputs } from "@hypit/producer";
+import type { ProducerPackage } from "@hypit/producer";
+import { synchronizedMediaSampleFrames, verifySynchronizedMedia } from "@hypit/media";
+import type { SynchronizedMedia } from "@hypit/media";
+import { canonicalize } from "@hypit/protocol";
import type { StoredValue } from "@hypit/protocol";
+import { assertLocalTemporalDomain } from "@hypit/temporal";
+import type { LocalTemporalDomain } from "@hypit/temporal";
import {
assertAlignedTranscriptEvidenceIdentity,
assertSpeechEvidenceAudioIdentity,
+ speechEvidenceCapabilities,
+ speechEvidenceProducers,
+ speechEvidenceSampleBoundary,
speechEvidenceTypes,
} from "./index.js";
-import type { AlignedTranscriptEvidence, SpeechEvidenceAudio } from "./index.js";
+import type { AlignedTranscriptEvidence, ProjectSpeechEvidenceAudioNeed, SpeechEvidenceAudio } from "./index.js";
function inline<T>(value: StoredValue, subject: string): T {
if (value.kind !== "inline") throw new Error(`${subject} must be inline.`);
@@ -20,4 +30,44 @@ export const speechEvidenceComponent = {
{ type: speechEvidenceTypes.alignedTranscript,
handler: ({ value }) => assertAlignedTranscriptEvidenceIdentity(inline<AlignedTranscriptEvidence>(value, "AlignedTranscriptEvidence")) },
],
-} satisfies ComponentPackage;
+ producers: [{
+ producer: speechEvidenceProducers.projectAudio,
+ handler: ({ inputs }) => {
+ const media = inline<SynchronizedMedia>(inputs.media!.value, "SynchronizedMedia");
+ const domain = inline<LocalTemporalDomain>(inputs.domain!.value, "LocalTemporalDomain");
+ verifySynchronizedMedia(media);
+ assertLocalTemporalDomain(domain);
+ if (domain.frameCount !== media.frameDomain.frameCount
+ || domain.frameRate.numerator !== media.frameDomain.frameRate.numerator
+ || domain.frameRate.denominator !== media.frameDomain.frameRate.denominator) {
+ throw new Error(`Speech evidence domain ${domain.id} does not describe its normalized media`);
+ }
+ if (media.audio === undefined) throw new Error("Speech evidence requires normalized media audio");
+ const sourceSampleFrames = synchronizedMediaSampleFrames(media);
+ const evidenceSampleFrames = speechEvidenceSampleBoundary(sourceSampleFrames);
+ if (!Number.isSafeInteger(sourceSampleFrames) || sourceSampleFrames < 1
+ || !Number.isSafeInteger(evidenceSampleFrames) || evidenceSampleFrames < 1) {
+ throw new Error("Speech evidence audio sample domain is invalid");
+ }
+ const need: ProjectSpeechEvidenceAudioNeed = {
+ domainId: domain.id,
+ source: media.audio.artifact,
+ sourceSampleFrames,
+ evidenceSampleFrames,
+ };
+ return { outputs: {}, needs: { evidenceAudio: canonicalize(need) } };
+ },
+ }],
+ plannedNeeds: [{
+ producer: speechEvidenceProducers.projectAudio,
+ port: "evidenceAudio",
+ capability: speechEvidenceCapabilities.projectAudio,
+ plan({ state, step }) {
+ return { constraints: {}, pendingInputs: plannedNeedInputs(state, step, { media: "audio" }) };
+ },
+ present(specification) {
+ const audio = specification.pendingInputs.filter((item) => item.role === "audio").length;
+ return { fields: {}, references: audio === 0 ? {} : { audio } };
+ },
+ }],
+} satisfies ProducerPackage & AdmissionPackage;
diff --git a/packages/speech-evidence/src/index.ts b/packages/speech-evidence/src/index.ts
index 5bfb800f..dcc04e02 100644
--- a/packages/speech-evidence/src/index.ts
+++ b/packages/speech-evidence/src/index.ts
@@ -1,5 +1,16 @@
import { isResourceId } from "@hypit/protocol";
-import type { BlobRef, ModuleManifest, TypeRef, ValueSchema } from "@hypit/protocol";
+import { mediaDependency, mediaTypes } from "@hypit/media";
+import { temporalDependency, temporalTypes } from "@hypit/temporal";
+import type { BlobRef, CapabilityRef, ModuleManifest, ProducerRef, TypeRef, ValueSchema } from "@hypit/protocol";
+export { parseTranscriptWords, phraseRanges, transcriptDocumentFromEvidence, wordsAt } from "./transcript-document.js";
+export type { FrameWords, TranscriptWord } from "./transcript-document.js";
+
+export type ProjectSpeechEvidenceAudioNeed = {
+ readonly domainId: string;
+ readonly source: BlobRef;
+ readonly sourceSampleFrames: number;
+ readonly evidenceSampleFrames: number;
+};
export type SpeechEvidenceAudio = {
/** The exact local temporal domain from which this evidence audio was projected. */
@@ -98,20 +109,39 @@ export const speechEvidenceTypes = {
audio: { module: speechEvidenceModuleRef, name: "SpeechEvidenceAudio" },
alignedTranscript: { module: speechEvidenceModuleRef, name: "AlignedTranscriptEvidence" },
} satisfies Record<string, TypeRef>;
+export const speechEvidenceCapabilities = {
+ projectAudio: { module: speechEvidenceModuleRef, name: "project-speech-evidence-audio" },
+} satisfies Record<string, CapabilityRef>;
+export const speechEvidenceProducers = {
+ projectAudio: { module: speechEvidenceModuleRef, name: "request-speech-evidence-audio" },
+} satisfies Record<string, ProducerRef>;
export const speechEvidenceManifest: ModuleManifest = {
format: "hypit.module@1",
name: speechEvidenceModuleRef.name,
version: speechEvidenceModuleRef.version,
- dependencies: [],
+ dependencies: [mediaDependency, temporalDependency],
types: [{ name: speechEvidenceTypes.audio.name }, { name: speechEvidenceTypes.alignedTranscript.name }],
- capabilities: [],
- producers: [],
+ capabilities: [{ name: speechEvidenceCapabilities.projectAudio.name, returns: speechEvidenceTypes.audio }],
+ producers: [{
+ name: speechEvidenceProducers.projectAudio.name,
+ inputs: [
+ { name: "media", type: mediaTypes.synchronized },
+ { name: "domain", type: temporalTypes.localDomain },
+ ],
+ outputs: [],
+ needs: [{
+ name: "evidenceAudio",
+ capability: speechEvidenceCapabilities.projectAudio,
+ returns: speechEvidenceTypes.audio,
+ }],
+ }],
};
export const speechEvidenceDependency = {
module: speechEvidenceModuleRef,
} as const;
export function sealAlignedTranscriptEvidence(value: AlignedTranscriptEvidence): AlignedTranscriptEvidence {
+ assertAlignedTranscriptEvidenceIdentity(value);
return structuredClone(value);
}
@@ -138,9 +168,51 @@ export function assertSpeechEvidenceAudioIdentity(value: SpeechEvidenceAudio): v
}
export function assertAlignedTranscriptEvidenceIdentity(value: AlignedTranscriptEvidence): void {
- if (typeof value.domainId !== "string" || value.domainId.length === 0
- || !Number.isSafeInteger(value.sampleFrames) || value.sampleFrames < 1
- || !Array.isArray(value.passages)) {
+ const item = value as AlignedTranscriptEvidence | null | undefined;
+ if (item === null || item === undefined
+ || typeof item.domainId !== "string" || item.domainId.length === 0
+ || !Number.isSafeInteger(item.sampleFrames) || item.sampleFrames < 1
+ || !Array.isArray(item.passages)) {
throw new Error("AlignedTranscriptEvidence identity is invalid.");
}
+ const window = (candidate: {
+ readonly startSample?: number;
+ readonly endSampleExclusive?: number;
+ }): boolean => {
+ if ((candidate.startSample === undefined) !== (candidate.endSampleExclusive === undefined)) return false;
+ if (candidate.startSample === undefined || candidate.endSampleExclusive === undefined) return true;
+ return Number.isSafeInteger(candidate.startSample)
+ && Number.isSafeInteger(candidate.endSampleExclusive)
+ && candidate.startSample >= 0
+ && candidate.endSampleExclusive >= 0
+ && candidate.startSample <= item.sampleFrames
+ && candidate.endSampleExclusive <= item.sampleFrames;
+ };
+ const score = (candidate: number | undefined): boolean => candidate === undefined
+ || (Number.isFinite(candidate) && candidate >= 0 && candidate <= 1);
+ for (const passage of item.passages) {
+ if (passage === null || typeof passage !== "object" || !window(passage)
+ || !Array.isArray(passage.words) || !Array.isArray(passage.chars)
+ || (passage.speechActivity !== undefined && !Array.isArray(passage.speechActivity))) {
+ throw new Error("AlignedTranscriptEvidence passage is invalid.");
+ }
+ for (const word of passage.words) {
+ if (word === null || typeof word !== "object" || typeof word.text !== "string"
+ || !window(word) || !score(word.score)) {
+ throw new Error("AlignedTranscriptEvidence word is invalid.");
+ }
+ }
+ for (const character of passage.chars) {
+ if (character === null || typeof character !== "object" || typeof character.char !== "string"
+ || !Number.isSafeInteger(character.wordIndex) || character.wordIndex < 0
+ || character.wordIndex >= passage.words.length || !window(character) || !score(character.score)) {
+ throw new Error("AlignedTranscriptEvidence character is invalid.");
+ }
+ }
+ for (const activity of passage.speechActivity ?? []) {
+ if (activity === null || typeof activity !== "object" || !window(activity)) {
+ throw new Error("AlignedTranscriptEvidence speech activity is invalid.");
+ }
+ }
+ }
}
diff --git a/packages/speech-evidence/src/transcript-document.ts b/packages/speech-evidence/src/transcript-document.ts
new file mode 100644
index 00000000..bca4348c
--- /dev/null
+++ b/packages/speech-evidence/src/transcript-document.ts
@@ -0,0 +1,111 @@
+/** A seconds projection of speech evidence for author inspection. Missing times stay missing. */
+export type TranscriptWord = {
+ readonly text: string;
+ readonly start?: number;
+ readonly end?: number;
+};
+export type FrameWords = {
+ readonly active: readonly TranscriptWord[];
+ readonly context: readonly TranscriptWord[];
+};
+
+const SAMPLE_RATE = 16_000;
+const seconds = (sample: number | undefined): number | undefined =>
+ sample === undefined ? undefined : Number((sample / SAMPLE_RATE).toFixed(3));
+
+/** Project exact sample evidence into the stable human/file view consumed by author tools. */
+export function transcriptDocumentFromEvidence(
+ evidence: {
+ readonly sampleFrames: number;
+ readonly passages: readonly {
+ readonly startSample?: number;
+ readonly endSampleExclusive?: number;
+ readonly words: readonly {
+ readonly text: string;
+ readonly startSample?: number;
+ readonly endSampleExclusive?: number;
+ readonly score?: number;
+ }[];
+ }[];
+ },
+ identity: { readonly source: string; readonly language: string },
+) {
+ return {
+ format: "hypit.transcript@1" as const,
+ ...identity,
+ audio_seconds: Number((evidence.sampleFrames / SAMPLE_RATE).toFixed(3)),
+ passages: evidence.passages.map((passage) => {
+ const words = passage.words.map((word) => ({
+ text: word.text,
+ ...(seconds(word.startSample) === undefined ? {} : { start_seconds: seconds(word.startSample) }),
+ ...(seconds(word.endSampleExclusive) === undefined ? {} : { end_seconds: seconds(word.endSampleExclusive) }),
+ ...(word.score === undefined ? {} : { score: word.score }),
+ }));
+ return {
+ text: words.map((word) => word.text).join(" "),
+ ...(seconds(passage.startSample) === undefined ? {} : { start_seconds: seconds(passage.startSample) }),
+ ...(seconds(passage.endSampleExclusive) === undefined ? {} : { end_seconds: seconds(passage.endSampleExclusive) }),
+ words,
+ };
+ }),
+ };
+}
+
+function assert(condition: unknown, message: string): asserts condition {
+ if (!condition) throw new Error(message);
+}
+
+export function parseTranscriptWords(value: unknown, subject = "transcript"): readonly TranscriptWord[] {
+ const raw = value as { readonly format?: unknown; readonly passages?: unknown } | null;
+ assert(raw?.format === "hypit.transcript@1" && Array.isArray(raw.passages), `${subject}: expected hypit.transcript@1`);
+ return raw.passages.flatMap((passage: { words?: unknown }) => {
+ assert(passage !== null && Array.isArray(passage.words), `${subject}: each passage needs words`);
+ return passage.words.map((word: Record<string, unknown>) => {
+ assert(word !== null && typeof word.text === "string", `${subject}: each word needs text`);
+ const start = word.start_seconds;
+ const end = word.end_seconds;
+ assert(start === undefined || (typeof start === "number" && Number.isFinite(start) && start >= 0), `${subject}: invalid word start`);
+ assert(end === undefined || (typeof end === "number" && Number.isFinite(end) && end >= 0), `${subject}: invalid word end`);
+ assert(start === undefined || end === undefined || end >= start, `${subject}: word end precedes start`);
+ return { text: word.text, ...(start === undefined ? {} : { start }), ...(end === undefined ? {} : { end }) };
+ });
+ });
+}
+
+export function wordsAt(words: readonly TranscriptWord[], at: number): FrameWords {
+ const active = words.filter((word) => word.start !== undefined && word.end !== undefined && word.start <= at && at < word.end);
+ let anchor = active.length > 0 ? words.indexOf(active[0]!) : -1;
+ if (anchor < 0) {
+ let distance = Infinity;
+ for (const [index, word] of words.entries()) {
+ const time = word.start ?? word.end;
+ if (time !== undefined && Math.abs(time - at) < distance) { anchor = index; distance = Math.abs(time - at); }
+ }
+ }
+ const last = active.length > 0 ? words.indexOf(active.at(-1)!) : anchor;
+ return { active, context: anchor < 0 ? [] : words.slice(Math.max(0, anchor - 3), last + 4) };
+}
+
+function searchable(text: string): string {
+ return text.normalize("NFKC").toLowerCase().replace(/[\p{P}\p{Z}\s]/gu, "");
+}
+
+/** Find whole, consecutive transcript words; punctuation and case do not affect matching. */
+export function phraseRanges(words: readonly TranscriptWord[], text: string): readonly { start: number; end: number }[] {
+ const query = searchable(text);
+ assert(query.length > 0, "--around needs a word or phrase");
+ const matches: { start: number; end: number }[] = [];
+ for (let first = 0; first < words.length; first += 1) {
+ if (searchable(words[first]!.text).length === 0) continue;
+ let joined = "";
+ for (let last = first; last < words.length && joined.length < query.length; last += 1) {
+ joined += searchable(words[last]!.text);
+ if (joined !== query) continue;
+ const start = words[first]!.start;
+ const end = words[last]!.end;
+ assert(start !== undefined && end !== undefined, `The phrase ${JSON.stringify(text)} has missing boundary times; inspect its passage and choose --start/--end`);
+ matches.push({ start, end });
+ }
+ }
+ return matches;
+}
diff --git a/packages/speech-evidence/test/evidence.test.ts b/packages/speech-evidence/test/evidence.test.ts
index 1af01a75..fe332644 100644
--- a/packages/speech-evidence/test/evidence.test.ts
+++ b/packages/speech-evidence/test/evidence.test.ts
@@ -1,12 +1,17 @@
import { timelineSampleFrames, sealTimeline } from "@hypit/timeline";
+import { sealSynchronizedMedia } from "@hypit/media";
import {
+ assertAlignedTranscriptEvidenceIdentity,
assertSpeechEvidenceAudioIdentity,
+ sealAlignedTranscriptEvidence,
sealSpeechEvidenceAudio,
speechEvidenceSampleBoundary,
+ speechEvidenceProducers,
} from "@hypit/speech-evidence";
import assert from "node:assert/strict";
import test from "node:test";
import { fixtureResource } from "../../../test/fixture-resource.js";
+import { speechEvidenceComponent } from "../src/component.js";
test("speech evidence uses integer rational boundary projection rather than floating duration arithmetic", () => {
assert.equal(speechEvidenceSampleBoundary(0), 0);
@@ -32,3 +37,57 @@ test("SpeechEvidenceAudio identifies its source domain and exact sample span", (
assert.throws(() => assertSpeechEvidenceAudioIdentity({ ...value, domainId: "" }), /identity/u);
assert.throws(() => assertSpeechEvidenceAudioIdentity({ ...value, sampleFrames: 0 }), /identity/u);
});
+
+test("AlignedTranscriptEvidence validates the complete provider-neutral observation", () => {
+ const value = sealAlignedTranscriptEvidence({
+ domainId: "speech-domain",
+ sampleFrames: 16_000,
+ passages: [{
+ startSample: 0,
+ endSampleExclusive: 16_000,
+ words: [{ text: "hello", startSample: 1_000, endSampleExclusive: 4_000, score: 0.9 }],
+ chars: [{ char: "h", wordIndex: 0, startSample: 1_000, endSampleExclusive: 1_500, score: 0.8 }],
+ speechActivity: [{ startSample: 800, endSampleExclusive: 4_200 }],
+ }],
+ });
+ assert.doesNotThrow(() => assertAlignedTranscriptEvidenceIdentity(value));
+ assert.throws(() => sealAlignedTranscriptEvidence({
+ ...value,
+ passages: [{ ...value.passages[0]!, words: [{ text: "hello", startSample: 1_000 }] }],
+ }), /word is invalid/u);
+ assert.throws(() => sealAlignedTranscriptEvidence({
+ ...value,
+ passages: [{ ...value.passages[0]!, chars: [{ char: "h", wordIndex: 2 }] }],
+ }), /character is invalid/u);
+ assert.throws(() => sealAlignedTranscriptEvidence({
+ ...value,
+ passages: [{ ...value.passages[0]!, speechActivity: [{ startSample: 0, endSampleExclusive: 16_001 }] }],
+ }), /speech activity is invalid/u);
+});
+
+test("Speech Evidence owns projection from one matching normalized media domain", async () => {
+ const project = speechEvidenceComponent.producers.find(
+ (item) => item.producer.name === speechEvidenceProducers.projectAudio.name,
+ )!;
+ const media = sealSynchronizedMedia({
+ frameDomain: { frameRate: { numerator: 30, denominator: 1 }, frameCount: 60 },
+ audio: { artifact: {
+ kind: "blob", resource: fixtureResource("speech-evidence:source"), size: 384_044, mediaType: "audio/wav",
+ } },
+ });
+ const run = (frameCount: number) => project.handler({ inputs: {
+ media: { value: { kind: "inline", value: media } },
+ domain: { value: { kind: "inline", value: {
+ id: "speech-domain", frameRate: media.frameDomain.frameRate, frameCount,
+ } } },
+ } } as never);
+
+ const result = await run(60);
+ assert.deepEqual(result.needs.evidenceAudio, {
+ domainId: "speech-domain",
+ source: media.audio!.artifact,
+ sourceSampleFrames: 96_000,
+ evidenceSampleFrames: 32_000,
+ });
+ await assert.rejects(async () => run(59), /does not describe its normalized media/u);
+});
diff --git a/packages/speech-evidence/test/transcript-document.test.ts b/packages/speech-evidence/test/transcript-document.test.ts
new file mode 100644
index 00000000..433a97da
--- /dev/null
+++ b/packages/speech-evidence/test/transcript-document.test.ts
@@ -0,0 +1,26 @@
+import assert from "node:assert/strict";
+import test from "node:test";
+import { phraseRanges, wordsAt } from "../src/transcript-document.js";
+
+test("word annotations retain missing times and distinguish word boundaries, overlap and gaps", () => {
+ const words = [
+ { text: "hello", start: 0, end: 0.4 }, { text: "world", start: 0.4, end: 0.8 },
+ { text: "yes", start: 0.6, end: 0.9 }, { text: "untimed" }, { text: "again", start: 1.2, end: 1.5 },
+ ];
+ assert.deepEqual(wordsAt(words, 0.4).active.map((word) => word.text), ["world"]);
+ assert.deepEqual(wordsAt(words, 0.7).active.map((word) => word.text), ["world", "yes"]);
+ assert.deepEqual(wordsAt(words, 1).active, []);
+ assert.ok(wordsAt(words, 1).context.some((word) => word.text === "untimed" && word.start === undefined));
+});
+
+test("phrase location preserves repeated occurrences and multilingual word boundaries", () => {
+ const words = [
+ { text: "Hello,", start: 0.1, end: 0.3 }, { text: "world!", start: 0.3, end: 0.8 },
+ { text: "hello", start: 2.1, end: 2.4 }, { text: "world", start: 2.4, end: 2.8 },
+ { text: "你好", start: 3, end: 3.2 }, { text: "世界。", start: 3.2, end: 3.5 },
+ ];
+ assert.deepEqual(phraseRanges(words, "HELLO world"), [{ start: 0.1, end: 0.8 }, { start: 2.1, end: 2.8 }]);
+ assert.deepEqual(phraseRanges(words, "你好世界"), [{ start: 3, end: 3.5 }]);
+ assert.deepEqual(phraseRanges(words, "hell"), []);
+ assert.throws(() => phraseRanges([{ text: "hello" }], "hello"), /missing boundary times/);
+});
diff --git a/packages/speech/README.md b/packages/speech/README.md
deleted file mode 100644
index 2daa61d0..00000000
--- a/packages/speech/README.md
+++ /dev/null
@@ -1,19 +0,0 @@
-# `@hypit/speech`
-
-Provider-neutral speech generation duration contracts.
-
-External components use `@hypit/hypit/speech` from their `@hypit/hypit` development dependency.
-Source imports retain the `@hypit/speech@1` Module identity.
-
-`@hypit/speech-evidence` owns canonical evidence audio plus provider-neutral word, character, score
-and speech-activity observations in exact sample coordinates. Evidence carries its local domain
-identity, but no Script, Segment, film Timeline or presentation identity.
-
-[`@hypit/speech-alignment`](../speech-alignment/README.md) deterministically combines acoustic
-evidence with one authored Segment and its `LocalTemporalDomain` to produce the
-`@hypit/narrative-temporal` `NarrativeAlignment`. The public Narrative timing contract is deliberately
-not owned here. An empty Segment needs no acoustic request: Narrative Temporal can materialize its
-boundaries directly over the supplied local domain with an empty token list.
-
-This package defines no provider, queue, credential, media normalization, Timeline assembly or
-visual/audio presentation policy.
diff --git a/packages/speech/package.json b/packages/speech/package.json
deleted file mode 100644
index 6dafac8d..00000000
--- a/packages/speech/package.json
+++ /dev/null
@@ -1,17 +0,0 @@
-{
- "name": "@hypit/speech",
- "version": "0.0.0-dev",
- "license": "SEE LICENSE IN LICENSE",
- "private": true,
- "type": "module",
- "exports": {
- ".": "./src/index.ts"
- },
- "hypit": {
- "activation": "./src/activation.ts"
- },
- "dependencies": {
- "@hypit/component-kit": "workspace:*",
- "@hypit/protocol": "workspace:*"
- }
-}
diff --git a/packages/speech/src/activation.ts b/packages/speech/src/activation.ts
deleted file mode 100644
index 9ef49130..00000000
--- a/packages/speech/src/activation.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-import { speechComponent, speechManifest } from "./index.js";
-export const hypitPackage = {
- format: "hypit.node-package@1" as const,
- modules: [{ manifest: speechManifest }],
- components: [speechComponent],
-};
-export default hypitPackage;
diff --git a/packages/speech/src/component.ts b/packages/speech/src/component.ts
deleted file mode 100644
index ce93f8f6..00000000
--- a/packages/speech/src/component.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-import type { ComponentPackage } from "@hypit/component-kit";
-import type { StoredValue } from "@hypit/protocol";
-
-import { assertSpeechDurationIdentity } from "./identity.js";
-import { speechTypes } from "./manifest.js";
-import type { SpeechDuration } from "./types.js";
-
-function inline<T>(value: StoredValue, subject: string): T {
- if (value.kind !== "inline") throw new Error(`${subject} must be inline.`);
- return value.value as T;
-}
-
-export const speechComponent = {
- validators: [
- { type: speechTypes.duration, handler: ({ value }) => assertSpeechDurationIdentity(inline<SpeechDuration>(value, "SpeechDuration")) },
- ],
-} satisfies ComponentPackage;
diff --git a/packages/speech/src/identity.ts b/packages/speech/src/identity.ts
deleted file mode 100644
index d7de8056..00000000
--- a/packages/speech/src/identity.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-import type { SpeechDuration } from "./types.js";
-
-export function sealSpeechDuration(value: SpeechDuration): SpeechDuration { return value; }
-export function assertSpeechDurationIdentity(value: SpeechDuration): void {
- if (!Number.isFinite(value) || value <= 0) throw new Error("SpeechDuration is invalid.");
-}
diff --git a/packages/speech/src/index.ts b/packages/speech/src/index.ts
deleted file mode 100644
index 1e541c47..00000000
--- a/packages/speech/src/index.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-export { assertSpeechDurationIdentity, sealSpeechDuration } from "./identity.js";
-export { speechComponent } from "./component.js";
-export { speechDependency, speechManifest, speechModuleRef, speechTypes } from "./manifest.js";
-export { speechDurationSchema, speechEvidenceAudioSchema } from "./schema.js";
-export type * from "./types.js";
diff --git a/packages/speech/src/manifest.ts b/packages/speech/src/manifest.ts
deleted file mode 100644
index 7e071298..00000000
--- a/packages/speech/src/manifest.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-import type { ModuleManifest, TypeRef } from "@hypit/protocol";
-
-export const speechModuleRef = { name: "@hypit/speech", version: "1" } as const;
-export const speechTypes = {
- duration: { module: speechModuleRef, name: "SpeechDuration" },
-} satisfies Record<string, TypeRef>;
-export const speechManifest: ModuleManifest = {
- format: "hypit.module@1", name: speechModuleRef.name, version: speechModuleRef.version,
- dependencies: [],
- types: [{ name: speechTypes.duration.name }],
- capabilities: [], producers: [],
-};
-export const speechDependency = { module: speechModuleRef } as const;
diff --git a/packages/speech/src/schema.ts b/packages/speech/src/schema.ts
deleted file mode 100644
index 189ebf0d..00000000
--- a/packages/speech/src/schema.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import type { ValueSchema } from "@hypit/protocol";
-const number = { kind: "number", minimum: 0 } as const;
-const integer = { kind: "number", integer: true, minimum: 0 } as const;
-const object = (fields: Readonly<Record<string, { readonly schema: ValueSchema; readonly optional?: boolean }>>): ValueSchema => ({ kind: "object", fields });
-const audioBlobRef = object({ kind: { schema: { kind: "literal", value: "blob" } },
- resource: { schema: { kind: "string", minLength: 5, maxLength: 256 } }, size: { schema: integer },
- mediaType: { schema: { kind: "literal", value: "audio/wav" } } });
-export const speechDurationSchema: ValueSchema = number;
-export const speechEvidenceAudioSchema: ValueSchema = object({ artifact: { schema: audioBlobRef },
- sampleFrames: { schema: { kind: "number", integer: true, minimum: 1 } } });
diff --git a/packages/speech/src/types.ts b/packages/speech/src/types.ts
deleted file mode 100644
index eccc76c0..00000000
--- a/packages/speech/src/types.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-/** Positive seconds. The graph port's TypeRef already carries the SpeechDuration identity. */
-export type SpeechDuration = number;
diff --git a/packages/svs/src/activation.ts b/packages/svs/src/activation.ts
deleted file mode 100644
index 9453a3d3..00000000
--- a/packages/svs/src/activation.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-import { createAuthorFrontendHostFacet } from "@hypit/elaborator";
-
-import { svsFrontend, svsManifest } from "./index.js";
-
-export const hypitPackage = {
- format: "hypit.node-package@1" as const,
- modules: [{ manifest: svsManifest }],
- hostFacets: [createAuthorFrontendHostFacet(svsFrontend)],
-};
-
-export default hypitPackage;
diff --git a/packages/svs/src/index.ts b/packages/svs/src/index.ts
deleted file mode 100644
index fa42a51e..00000000
--- a/packages/svs/src/index.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-export { svsFrontendId, svsManifest, svsModuleRef, svsRecipeType } from "./manifest.js";
-export { SvsSyntaxError, parseSvs } from "./parser.js";
-export { formatSvsValue } from "./format.js";
-export { svsFrontend } from "./frontend.js";
-export type * from "./types.js";
diff --git a/packages/svs/src/manifest.ts b/packages/svs/src/manifest.ts
deleted file mode 100644
index 766a42c1..00000000
--- a/packages/svs/src/manifest.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-import type { ModuleManifest, TypeRef } from "@hypit/protocol";
-
-export const svsModuleRef = { name: "@hypit/svs", version: "1" } as const;
-export const svsRecipeType = { module: svsModuleRef, name: "Recipe" } satisfies TypeRef;
-export const svsFrontendId = "@hypit/svs@1";
-
-export const svsManifest: ModuleManifest = {
- format: "hypit.module@1",
- name: svsModuleRef.name,
- version: svsModuleRef.version,
- dependencies: [],
- types: [{
- name: svsRecipeType.name,
- }],
- capabilities: [],
- producers: [],
-};
diff --git a/packages/temporal-markup/README.md b/packages/temporal-markup/README.md
deleted file mode 100644
index 726a7319..00000000
--- a/packages/temporal-markup/README.md
+++ /dev/null
@@ -1,98 +0,0 @@
-# `@hypit/temporal-markup`
-
-Shared SVML author helpers for constructing ordinary absolute `TemporalInstant` and
-`TemporalWindow` values. This package knows the Timeline clock. It does not know Narrative,
-speech, media, captions, beats, or any other source domain.
-
-The package exports `resolveTemporalContext`, `createTemporalWindowConstruction`,
-`createTemporalInstantConstruction`, their attribute vocabularies, and exact duration/instant
-parsers. They are helpers for component Surfaces, not a Track and not a second Timeline model.
-
-## The boundary
-
-A general component accepts:
-
-- `timeline={film.timeline}` for the absolute coordinate system;
-- a `TemporalWindow` when it occupies an interval; or
-- a `TemporalInstant` when it reacts to an event.
-
-It never receives a Narrative projector and never interprets Selection, Segment or Moment values.
-A source-domain package performs that projection once and publishes an ordinary absolute value.
-The same component can therefore consume time from Narrative, music analysis, imported edit data,
-or a literal clock position without knowing which source produced it.
-
-## Window forms
-
-The common Window vocabulary has four attributes and one rule:
-
-| Form | Result |
-| --- | --- |
-| `during="timeline"` | The complete Timeline Window. |
-| `during={story-time.proof}` | Reuse an already resolved Window. |
-| `from="2s" for="12f"` | Start at two seconds and last twelve frames. |
-| `until="3s" for="250ms"` | End at three seconds and extend 250 ms backwards. |
-| `from={cue} until="timeline.end"` | Compose two resolved or authored endpoints. |
-
-Outside `during`, supply exactly two of `from`, `until`, and `for`. `from` and `until` accept an
-existing `TemporalInstant` or an absolute expression. `for` accepts an exact duration literal or a
-resolved `TemporalExtent`.
-
-Absolute expressions are deliberately small: `start`, `end`, `timeline.start`, `timeline.end`, an
-absolute `12f`/`250ms`/`1.5s`, or one of those Timeline boundaries with a signed offset. There is no
-implicit lookup of domain names such as `moment.cue`; project that domain value upstream first.
-
-## Instant forms
-
-An event consumer uses `at`:
-
-| Form | Result |
-| --- | --- |
-| `at={story-time.claim}` | Reuse an already resolved Instant. |
-| `at="2.6s"` | An absolute point 2.6 seconds from Timeline start. |
-| `at="timeline.end-12f"` | Twelve frames before the exclusive end. |
-
-An Instant does not imply a visible duration. The receiving component decides whether the event
-starts an animation, changes persistent state, or ends an outer lifetime.
-
-## Surface implementation
-
-Resolve the required Timeline once:
-
-```ts
-const context = resolveTemporalContext({ element, resolveReference });
-const timing = createTemporalWindowConstruction({
- id: itemId,
- element: child,
- ...context,
- resolveReference,
-});
-```
-
-Preserve the returned records, components and fragments, then wire `timing.ref` to a
-`TemporalWindow` port. For an event, use `createTemporalInstantConstruction` and an Instant port.
-The consumer Producer receives only the completed value.
-
-`subjectId` identifies the authored occurrence for inspection; it is not a nominal ownership lock.
-A deliberately named Window can be reused by several components. Timeline identity and interval
-validity are still checked.
-
-## Domain projections
-
-Domain projection belongs to the domain package. For example,
-`@hypit/narrative-temporal` may publish:
-
-```svml
-<semantic:Projection id="story-time" narrative={story} timeline={film.timeline}>
- <semantic:Map alignment={speech.alignment} domain={speech-media.domain} window={film.speech}/>
- <semantic:Window id="proof" selection={story.selection.proof}/>
- <semantic:Instant id="claim" moment={story.moment.claim}/>
-</semantic:Projection>
-
-<visual:Clip media={proof-media.media} during={story-time.proof}
- frame={proof-frame} appearance={proof-appearance}/>
-<deck:Card at={story-time.claim} .../>
-```
-
-Only explicitly requested values cross that boundary. The completed projection contains absolute
-boundaries, not a reusable local-domain mapping. A visual, audio, caption, or typography component
-does not carry the projector merely to consume the resulting time.
diff --git a/packages/temporal-markup/package.json b/packages/temporal-markup/package.json
deleted file mode 100644
index 7dfde1c4..00000000
--- a/packages/temporal-markup/package.json
+++ /dev/null
@@ -1,16 +0,0 @@
-{
- "name": "@hypit/temporal-markup",
- "version": "0.0.0-dev",
- "license": "SEE LICENSE IN LICENSE",
- "private": true,
- "type": "module",
- "exports": {
- ".": "./src/index.ts"
- },
- "dependencies": {
- "@hypit/elaborator": "workspace:*",
- "@hypit/markup": "workspace:*",
- "@hypit/timeline": "workspace:*",
- "@hypit/temporal": "workspace:*"
- }
-}
diff --git a/packages/temporal-markup/EDITING.md b/packages/temporal/EDITING.md
similarity index 81%
rename from packages/temporal-markup/EDITING.md
rename to packages/temporal/EDITING.md
index 44e00cec..22fadf7f 100644
--- a/packages/temporal-markup/EDITING.md
+++ b/packages/temporal/EDITING.md
@@ -3,6 +3,12 @@
Studio edits the declaration that produced an absolute time value; it does not ask the consuming
component to reverse an arbitrary projection.
+The Markup helper records an optional, data-only `author` parameter on the exact `TemporalInstantSpec`
+or `TemporalShiftSpec` it creates. It names the owning binding and whether the endpoint is direct or
+derived from a duration. Studio reads that fact from the executed graph; it does not inspect component
+attribute names. A reference has no local parameter authority: its producer remains the only place
+that may declare an inverse.
+
## Direct absolute construction
| Author form | Move | Leading edge | Trailing edge |
@@ -34,7 +40,7 @@ recompilation.
This division is intentional:
-- `@hypit/temporal-markup` owns absolute literal/reference construction;
+- `@hypit/temporal/markup` owns absolute literal/reference construction;
- a domain package owns projection and domain-specific writeback;
- `@hypit/temporal` validates resolved absolute values;
- the component owns only what the value means for its behavior.
diff --git a/packages/temporal/README.md b/packages/temporal/README.md
index bb9e4d57..ddcd80cd 100644
--- a/packages/temporal/README.md
+++ b/packages/temporal/README.md
@@ -24,11 +24,15 @@ may map one complete finite source-local domain onto an equal-length Window at n
the pure exact-projection helper. This total one-to-one operation keeps every local boundary
projectable and produces no durable Placement value.
-Author syntax does not live here. `@hypit/temporal-markup` constructs absolute literals and composes
-Windows. Domain packages such as `@hypit/narrative-temporal` project their own values into these
+Author syntax does not live in the main contract entry. The same owner exposes
+`@hypit/hypit/temporal/markup` to construct absolute literals and compose Windows from Markup.
+Domain packages such as `@hypit/narrative-temporal` project their own values into these
common types. Visual, audio, caption, typography and project components receive only the completed
Instant or Window plus the Timeline they already consume.
Temporal rejects Instants outside Timeline, Windows whose endpoint Timelines or stored span disagree,
reversed or empty Windows, non-exact local-domain projection, and incompatible frame rates. It does not
clip, repair, infer meaning, perform rendering, or define Studio behavior.
+
+Author-directed editing follows the declaration that produced a value rather than asking a consumer
+to invert an arbitrary projection; see [EDITING.md](EDITING.md).
diff --git a/packages/temporal/package.json b/packages/temporal/package.json
index bfdc8f52..895684b9 100644
--- a/packages/temporal/package.json
+++ b/packages/temporal/package.json
@@ -5,14 +5,18 @@
"private": true,
"type": "module",
"exports": {
- ".": "./src/index.ts"
+ ".": "./src/index.ts",
+ "./markup": "./src/markup/index.ts"
},
"hypit": {
"activation": "./src/activation.ts"
},
"dependencies": {
- "@hypit/component-kit": "workspace:*",
+ "@hypit/author": "workspace:*",
+ "@hypit/markup": "workspace:*",
+ "@hypit/producer": "workspace:*",
"@hypit/protocol": "workspace:*",
- "@hypit/timeline": "workspace:*"
+ "@hypit/timeline": "workspace:*",
+ "@hypit/admission": "workspace:*"
}
}
diff --git a/packages/temporal/src/activation.ts b/packages/temporal/src/activation.ts
index 274661e6..ad518ab9 100644
--- a/packages/temporal/src/activation.ts
+++ b/packages/temporal/src/activation.ts
@@ -1,9 +1,11 @@
+import { createAdmissionPackageFacet } from "@hypit/admission";
+import { createProducerPackageFacet } from "@hypit/producer";
import { temporalManifest } from "./index.js";
import { temporalComponent } from "./component.js";
export const hypitPackage = {
- format: "hypit.node-package@1" as const,
+ format: "hypit.package@1" as const,
modules: [{ manifest: temporalManifest }],
- components: [temporalComponent],
+ facets: [...[temporalComponent].flatMap((component) => [createProducerPackageFacet(component), createAdmissionPackageFacet(component)])],
};
export default hypitPackage;
diff --git a/packages/temporal/src/component.ts b/packages/temporal/src/component.ts
index 75a5a343..208d9eff 100644
--- a/packages/temporal/src/component.ts
+++ b/packages/temporal/src/component.ts
@@ -1,4 +1,5 @@
-import type { ComponentPackage, ProducerHandlerContext } from "@hypit/component-kit";
+import type { AdmissionPackage } from "@hypit/admission";
+import type { ProducerPackage, ProducerHandlerContext } from "@hypit/producer";
import { canonicalize } from "@hypit/protocol";
import type { StoredValue } from "@hypit/protocol";
import type { Timeline } from "@hypit/timeline";
@@ -53,4 +54,4 @@ export const temporalComponent = {
inline<TemporalInstant>(inputs.end?.value, "TemporalInstant end"),
)) }, needs: {} }) },
],
-} satisfies ComponentPackage;
+} satisfies ProducerPackage & AdmissionPackage;
diff --git a/packages/temporal/src/index.ts b/packages/temporal/src/index.ts
index 4758b499..d3f96d94 100644
--- a/packages/temporal/src/index.ts
+++ b/packages/temporal/src/index.ts
@@ -103,14 +103,19 @@ export const temporalExtentSchema: ValueSchema = object({
frameCount: { schema: unsignedInteger },
});
export const temporalDurationSchema: ValueSchema = duration;
+const temporalAuthorParameterSchema: ValueSchema = object({
+ binding: { schema: string },
+ relation: { schema: { kind: "string", enum: ["direct", "after-start", "before-end"] } },
+});
export const temporalShiftSpecSchema: ValueSchema = object({
id: { schema: string }, subjectId: { schema: string },
direction: { schema: { kind: "oneOf", variants: [
{ kind: "literal", value: 1 }, { kind: "literal", value: -1 },
- ] } },
+ ] } }, author: { schema: temporalAuthorParameterSchema, optional: true },
});
export const temporalInstantSpecSchema: ValueSchema = object({
id: { schema: string }, subjectId: { schema: string }, projection: { schema: instant },
+ author: { schema: temporalAuthorParameterSchema, optional: true },
});
export const temporalInstantSchema: ValueSchema = object({
id: { schema: string }, subjectId: { schema: string }, timelineId: { schema: string }, frame: { schema: unsignedInteger },
diff --git a/packages/temporal-markup/src/context.ts b/packages/temporal/src/markup/context.ts
similarity index 100%
rename from packages/temporal-markup/src/context.ts
rename to packages/temporal/src/markup/context.ts
diff --git a/packages/temporal-markup/src/index.ts b/packages/temporal/src/markup/index.ts
similarity index 91%
rename from packages/temporal-markup/src/index.ts
rename to packages/temporal/src/markup/index.ts
index a43d881d..2038992b 100644
--- a/packages/temporal-markup/src/index.ts
+++ b/packages/temporal/src/markup/index.ts
@@ -1,22 +1,22 @@
-import { sealGraphFragment } from "@hypit/elaborator";
-import type { FragmentOperation, FragmentOperationRef, GraphFragment } from "@hypit/elaborator";
+import { sealGraphFragment } from "@hypit/author";
+import type { FragmentOperation, FragmentOperationRef, GraphFragment } from "@hypit/author";
import type {
MarkupAttributeValue, StructuredElement, SurfaceAttributeVocabulary, SurfaceComponentDraft,
SurfaceRecordDraft, SurfaceResolvedReference,
} from "@hypit/markup";
import { sameType, type TypeRef } from "@hypit/protocol";
import { temporalProducers, temporalTypes } from "@hypit/temporal";
-import type { TemporalDuration, TemporalInstantExpression } from "@hypit/temporal";
+import type { TemporalAuthorParameter, TemporalDuration, TemporalInstantExpression } from "@hypit/temporal";
import { timelineTypes } from "@hypit/timeline";
export * from "./context.js";
type ResolveReference = (path: string) => SurfaceResolvedReference | undefined;
type InstantDraft =
- | { readonly kind: "expression"; readonly expression: TemporalInstantExpression }
+ | { readonly kind: "expression"; readonly expression: TemporalInstantExpression; readonly author?: TemporalAuthorParameter }
| { readonly kind: "reference"; readonly reference: SurfaceResolvedReference };
type ExtentDraft =
- | { readonly kind: "duration"; readonly duration: TemporalDuration }
+ | { readonly kind: "duration"; readonly duration: TemporalDuration; readonly author?: TemporalAuthorParameter }
| { readonly kind: "reference"; readonly reference: SurfaceResolvedReference };
/** Absolute-only author vocabulary for a Window consumer. */
@@ -98,15 +98,15 @@ function resolvedReference(raw: MarkupAttributeValue, label: string, type: Surfa
return found;
}
-function instantDraft(raw: MarkupAttributeValue, label: string, resolveReference: ResolveReference): InstantDraft {
+function instantDraft(raw: MarkupAttributeValue, label: string, binding: string, resolveReference: ResolveReference): InstantDraft {
return typeof raw === "string"
- ? { kind: "expression", expression: parseTemporalInstant(raw, label) }
+ ? { kind: "expression", expression: parseTemporalInstant(raw, label), author: { binding, relation: "direct" } }
: { kind: "reference", reference: resolvedReference(raw, label, temporalTypes.instant, resolveReference) };
}
-function extentDraft(raw: MarkupAttributeValue, label: string, resolveReference: ResolveReference): ExtentDraft {
+function extentDraft(raw: MarkupAttributeValue, label: string, binding: string, resolveReference: ResolveReference): ExtentDraft {
return typeof raw === "string"
- ? { kind: "duration", duration: parseTemporalDuration(raw, label) }
+ ? { kind: "duration", duration: parseTemporalDuration(raw, label), author: { binding, relation: "direct" } }
: { kind: "reference", reference: resolvedReference(raw, label, temporalTypes.extent, resolveReference) };
}
@@ -148,6 +148,7 @@ function constructWindow(value: {
bindings[port] = { kind: "record", id: recordId };
records.push({ id: recordId, type: temporalTypes.instantSpec, value: { kind: "inline", value: {
id: `${value.id}.${name}`, subjectId: value.subjectId, projection: draft.expression,
+ ...(draft.author === undefined ? {} : { author: draft.author }),
} }, range: value.element.range });
const operationId = `materialize-${name}`;
operations.push({ id: operationId, producer: temporalProducers.projectProgramInstant,
@@ -181,6 +182,9 @@ function constructWindow(value: {
bindings["shift-spec"] = { kind: "record", id: shiftId };
records.push({ id: shiftId, type: temporalTypes.shiftSpec, value: { kind: "inline", value: {
id: `${value.id}.${direction === 1 ? "end" : "start"}`, subjectId: value.subjectId, direction,
+ ...(value.extent.kind !== "duration" || value.extent.author === undefined ? {} : {
+ author: { ...value.extent.author, relation: direction === 1 ? "after-start" : "before-end" },
+ }),
} }, range: value.element.range });
operations.push({ id: "shift", producer: temporalProducers.shiftInstant,
inputs: { timeline: fragmentInput("timeline"), instant: base, extent: extentRef, spec: fragmentInput("shift-spec") },
@@ -229,16 +233,16 @@ export function createTemporalWindowConstruction(value: {
rejectUnused(element, ["from", "until", "for"]);
const subjectId = value.subjectId ?? value.id;
if (from !== undefined && until !== undefined) return constructWindow({ ...value, subjectId,
- start: instantDraft(from, `${element.name}.from`, resolveReference),
- end: instantDraft(until, `${element.name}.until`, resolveReference) });
+ start: instantDraft(from, `${element.name}.from`, "from", resolveReference),
+ end: instantDraft(until, `${element.name}.until`, "until", resolveReference) });
if (from !== undefined && length !== undefined) return constructWindow({ ...value, subjectId,
- start: instantDraft(from, `${element.name}.from`, resolveReference),
- extent: extentDraft(length, `${element.name}.for`, resolveReference), direction: 1 });
+ start: instantDraft(from, `${element.name}.from`, "from", resolveReference),
+ extent: extentDraft(length, `${element.name}.for`, "for", resolveReference), direction: 1 });
if (until === undefined || length === undefined) throw new Error(`${element.name} Window form is incomplete.`);
return constructWindow({ ...value, subjectId,
start: { kind: "expression", expression: { ref: "timeline.start" } },
- end: instantDraft(until, `${element.name}.until`, resolveReference),
- extent: extentDraft(length, `${element.name}.for`, resolveReference), direction: -1 });
+ end: instantDraft(until, `${element.name}.until`, "until", resolveReference),
+ extent: extentDraft(length, `${element.name}.for`, "for", resolveReference), direction: -1 });
}
/** Construct or pass through one absolute Instant. */
@@ -262,6 +266,7 @@ export function createTemporalInstantConstruction(value: {
return { records: [{ id: specId, type: temporalTypes.instantSpec, value: { kind: "inline", value: {
id: value.id, subjectId: value.subjectId ?? value.id,
projection: parseTemporalInstant(raw, `${value.element.name}.${attribute}`),
+ author: { binding: attribute, relation: "direct" },
} }, range: value.element.range }], components: [{ id: componentId, fragment: fragment.id,
inputs: { timeline: value.timeline.ref, spec: { kind: "record", id: specId } },
outputs: { instant: `${value.id}.__temporal.instant.value` }, range: value.element.range }], fragments: [fragment],
diff --git a/packages/temporal/src/types.ts b/packages/temporal/src/types.ts
index 0d35ba5b..b30e7d85 100644
--- a/packages/temporal/src/types.ts
+++ b/packages/temporal/src/types.ts
@@ -10,12 +10,20 @@ export type TemporalInstantExpression =
| { readonly ref: "timeline.end"; readonly offset?: TemporalDuration }
| { readonly ref: "absolute"; readonly at: TemporalDuration; readonly offset?: TemporalDuration };
+/** Exact author parameter that owns one projected endpoint. Syntax owners may omit it for references. */
+export type TemporalAuthorParameter = {
+ readonly binding: string;
+ readonly relation: "direct" | "after-start" | "before-end";
+};
+
/** Input value for an Instant projection producer. */
export type TemporalInstantSpec = {
readonly id: string;
/** Author/domain entity whose timing this projection controls. */
readonly subjectId: string;
readonly projection: TemporalInstantExpression;
+ /** Optional inverse declared by the author syntax that created this Spec. */
+ readonly author?: TemporalAuthorParameter;
};
/** Input value for composing two resolved Instants into a Window. */
@@ -44,6 +52,8 @@ export type TemporalShiftSpec = {
readonly id: string;
readonly subjectId: string;
readonly direction: 1 | -1;
+ /** Optional duration inverse declared by the author syntax that created this shift. */
+ readonly author?: TemporalAuthorParameter;
};
/**
diff --git a/packages/temporal-markup/test/temporal-markup.test.ts b/packages/temporal/test/markup.test.ts
similarity index 89%
rename from packages/temporal-markup/test/temporal-markup.test.ts
rename to packages/temporal/test/markup.test.ts
index 5857400a..2790e6bc 100644
--- a/packages/temporal-markup/test/temporal-markup.test.ts
+++ b/packages/temporal/test/markup.test.ts
@@ -5,7 +5,7 @@ import type { MarkupAttributeValue, StructuredElement, SurfaceResolvedReference
import { temporalTypes } from "@hypit/temporal";
import { timelineTypes } from "@hypit/timeline";
-import { createTemporalInstantConstruction, createTemporalWindowConstruction, resolveTemporalContext } from "../src/index.js";
+import { createTemporalInstantConstruction, createTemporalWindowConstruction, resolveTemporalContext } from "../src/markup/index.js";
const range = { source: "main.svml", start: 0, end: 1 };
const reference = (path: string): MarkupAttributeValue => ({ kind: "reference", path });
@@ -38,6 +38,15 @@ test("whole Timeline and absolute literals lower without any domain projector",
const literal = createTemporalWindowConstruction({ id: "literal", element: element({ from: "2.5s", for: "8f" }), timeline, resolveReference });
assert.deepEqual(inlineValues(literal, "TemporalDuration"), [{ unit: "frames", value: 8 }]);
+ assert.deepEqual(inlineValues(literal, "TemporalInstantSpec"), [{
+ id: "literal.start", subjectId: "literal",
+ projection: { ref: "absolute", at: { unit: "seconds", numerator: 5, denominator: 2 } },
+ author: { binding: "from", relation: "direct" },
+ }]);
+ assert.deepEqual(inlineValues(literal, "TemporalShiftSpec"), [{
+ id: "literal.end", subjectId: "literal", direction: 1,
+ author: { binding: "for", relation: "after-start" },
+ }]);
assert.equal(literal.fragments[0]!.operations.some((operation) => operation.producer.name === "shift-instant"), true);
});
@@ -65,7 +74,8 @@ test("resolved Window and Instant references pass directly through", () => {
test("Instant literals use common Timeline arithmetic", () => {
const at = createTemporalInstantConstruction({ id: "message", element: element({ at: "2.5s" }), timeline, resolveReference });
assert.deepEqual(inlineValues(at, "TemporalInstantSpec"), [
- { id: "message", subjectId: "message", projection: { ref: "absolute", at: { unit: "seconds", numerator: 5, denominator: 2 } } },
+ { id: "message", subjectId: "message", projection: { ref: "absolute", at: { unit: "seconds", numerator: 5, denominator: 2 } },
+ author: { binding: "at", relation: "direct" } },
]);
});
diff --git a/packages/text-fine-studio/README.md b/packages/text-fine-studio/README.md
deleted file mode 100644
index 2a015f7a..00000000
--- a/packages/text-fine-studio/README.md
+++ /dev/null
@@ -1,8 +0,0 @@
-# `@hypit/text-fine-studio`
-
-Hypit Studio Companion for `@hypit/text-fine`.
-
-`Flow`, `Point` and `Path` are projected from their package-owned `.occurrence` value, so Studio can
-recover the authored text, absolute Window and spatial binding without reconstructing an aggregate
-Typography Track. The Inspector hides geometry-specific Recipe fields that the selected occurrence
-form cannot consume.
diff --git a/packages/text-fine-studio/package.json b/packages/text-fine-studio/package.json
deleted file mode 100644
index 4001f4ea..00000000
--- a/packages/text-fine-studio/package.json
+++ /dev/null
@@ -1,19 +0,0 @@
-{
- "name": "@hypit/text-fine-studio",
- "version": "0.0.0-dev",
- "license": "SEE LICENSE IN LICENSE",
- "private": true,
- "type": "module",
- "exports": {
- ".": "./src/index.ts"
- },
- "hypit": {
- "activation": "./src/activation.ts"
- },
- "dependencies": {
- "@hypit/composition": "workspace:*",
- "@hypit/studio-adapter": "workspace:*",
- "@hypit/text-fine": "workspace:*",
- "@hypit/fonts-open": "workspace:*"
- }
-}
diff --git a/packages/text-fine-studio/src/activation.ts b/packages/text-fine-studio/src/activation.ts
deleted file mode 100644
index 13c64434..00000000
--- a/packages/text-fine-studio/src/activation.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-import { createStudioTrackCompanionHostFacet } from "@hypit/studio-adapter";
-import { textFineStudioTrackCompanions } from "./index.js";
-
-export default {
- format: "hypit.node-package@1" as const,
- hostFacets: [createStudioTrackCompanionHostFacet(textFineStudioTrackCompanions)],
-};
diff --git a/packages/text-fine/README.md b/packages/text-fine/README.md
index baf0a58e..8d67ce9a 100644
--- a/packages/text-fine/README.md
+++ b/packages/text-fine/README.md
@@ -85,3 +85,7 @@ enter the reusable Style, so a paragraph or run cannot accidentally move or rest
There is no aggregate Typography Track or Typography-owned collection Program. Several independent
occurrences remain several explicit `.visual` contributions; a coordinated text-led visual role is
one project component rather than an accidental collection of unrelated strings.
+
+The package also publishes `@hypit/text-fine/studio`. That subpath describes the same Flow, Point and
+Path surfaces to Studio; it is part of this rendering family's release rather than a separately
+versioned companion package.
diff --git a/packages/text-fine/package.json b/packages/text-fine/package.json
index a285abdd..f2eff7f2 100644
--- a/packages/text-fine/package.json
+++ b/packages/text-fine/package.json
@@ -1,32 +1,44 @@
{
"name": "@hypit/text-fine",
- "version": "0.0.0-dev",
+ "version": "0.1.0",
"license": "SEE LICENSE IN LICENSE",
"private": true,
"type": "module",
"exports": {
- ".": "./src/index.ts"
+ ".": "./src/index.ts",
+ "./studio": "./src/studio.ts"
},
+ "files": [
+ "dist",
+ "preview",
+ "README.md"
+ ],
"hypit": {
"activation": "./src/activation.ts"
},
- "dependencies": {
- "@hypit/component-kit": "workspace:*",
+ "peerDependencies": {
+ "@hypit/hypit": "workspace:^",
+ "@hypit/studio-companion": "workspace:^"
+ },
+ "devDependencies": {
+ "@hypit/compiler": "workspace:*",
+ "@hypit/producer": "workspace:*",
"@hypit/composition": "workspace:*",
- "@hypit/elaborator": "workspace:*",
+ "@hypit/author": "workspace:*",
+ "@hypit/source": "workspace:*",
"@hypit/media": "workspace:*",
"@hypit/protocol": "workspace:*",
"@hypit/timeline": "workspace:*",
"@hypit/spatial": "workspace:*",
- "@hypit/svs": "workspace:*",
+ "@hypit/recipe": "workspace:*",
"@hypit/temporal": "workspace:*",
- "@hypit/temporal-markup": "workspace:*",
"@hypit/text": "workspace:*",
- "@hypit/visual-ir": "workspace:*",
- "@hypit/markup": "workspace:*"
- },
- "devDependencies": {
- "@hypit/core": "workspace:*",
- "@hypit/validation": "workspace:*"
+ "@hypit/markup": "workspace:*",
+ "@hypit/hypit": "workspace:*",
+ "@hypit/studio-companion": "workspace:*",
+ "@hypit/kernel": "workspace:*",
+ "@hypit/admission": "workspace:*",
+ "@hypit/html-program": "workspace:*",
+ "@hypit/narrative": "workspace:*"
}
}
diff --git a/packages/text-fine/src/activation.ts b/packages/text-fine/src/activation.ts
index 98263015..c72694fd 100644
--- a/packages/text-fine/src/activation.ts
+++ b/packages/text-fine/src/activation.ts
@@ -1,4 +1,7 @@
-import { createMarkupSurfaceHostFacet } from "@hypit/markup";
+import { createAdmissionPackageFacet } from "@hypit/hypit/admission";
+import { createProducerPackageFacet } from "@hypit/hypit/producer";
+import { createMarkupSurfaceFacet } from "@hypit/hypit/markup";
+import { createStudioCompanionFacet } from "@hypit/studio-companion";
import {
decodeTypographyMotionSurface,
decodeTypographyPathMotionSurface,
@@ -12,40 +15,42 @@ import {
textFineModuleRef,
textFineMarkupSurfaces,
} from "./index.js";
+import { textFineStudioTrackCompanions } from "./studio.js";
export const hypitPackage = {
- format: "hypit.node-package@1" as const,
+ format: "hypit.package@1" as const,
modules: [{ manifest: textFineManifest }],
- components: [textFineComponent],
- hostFacets: [
- createMarkupSurfaceHostFacet({
+ facets: [
+ ...[textFineComponent].flatMap((component) => [createProducerPackageFacet(component), createAdmissionPackageFacet(component)]),
+ createMarkupSurfaceFacet({
module: textFineModuleRef,
- declaration: textFineMarkupSurfaces.find((item) => item.name === "style")!, handler: decodeTypographyStyleSurface,
+ declaration: textFineMarkupSurfaces.find((item) => item.name === "style")!, handler: decodeTypographyStyleSurface,
}),
- createMarkupSurfaceHostFacet({
+ createMarkupSurfaceFacet({
module: textFineModuleRef,
- declaration: textFineMarkupSurfaces.find((item) => item.name === "motion")!, handler: decodeTypographyMotionSurface,
+ declaration: textFineMarkupSurfaces.find((item) => item.name === "motion")!, handler: decodeTypographyMotionSurface,
}),
- createMarkupSurfaceHostFacet({
+ createMarkupSurfaceFacet({
module: textFineModuleRef,
- declaration: textFineMarkupSurfaces.find((item) => item.name === "path-motion")!, handler: decodeTypographyPathMotionSurface,
+ declaration: textFineMarkupSurfaces.find((item) => item.name === "path-motion")!, handler: decodeTypographyPathMotionSurface,
}),
- createMarkupSurfaceHostFacet({
+ createMarkupSurfaceFacet({
module: textFineModuleRef,
- declaration: textFineMarkupSurfaces.find((item) => item.name === "flow")!, handler: decodeTypographyFlowSurface,
+ declaration: textFineMarkupSurfaces.find((item) => item.name === "flow")!, handler: decodeTypographyFlowSurface,
}),
- createMarkupSurfaceHostFacet({
+ createMarkupSurfaceFacet({
module: textFineModuleRef,
- declaration: textFineMarkupSurfaces.find((item) => item.name === "point")!, handler: decodeTypographyPointSurface,
+ declaration: textFineMarkupSurfaces.find((item) => item.name === "point")!, handler: decodeTypographyPointSurface,
}),
- createMarkupSurfaceHostFacet({
+ createMarkupSurfaceFacet({
module: textFineModuleRef,
- declaration: textFineMarkupSurfaces.find((item) => item.name === "path")!, handler: decodeTypographyPathSurface,
+ declaration: textFineMarkupSurfaces.find((item) => item.name === "path")!, handler: decodeTypographyPathSurface,
}),
- createMarkupSurfaceHostFacet({
+ createMarkupSurfaceFacet({
module: textFineModuleRef,
- declaration: textFineMarkupSurfaces.find((item) => item.name === "mask")!, handler: decodeTypographyMaskSurface,
+ declaration: textFineMarkupSurfaces.find((item) => item.name === "mask")!, handler: decodeTypographyMaskSurface,
}),
+ createStudioCompanionFacet({ tracks: textFineStudioTrackCompanions }),
],
};
export default hypitPackage;
diff --git a/packages/text-fine/src/component.ts b/packages/text-fine/src/component.ts
index cb52cdd7..1103a75a 100644
--- a/packages/text-fine/src/component.ts
+++ b/packages/text-fine/src/component.ts
@@ -1,10 +1,11 @@
-import type { Timeline } from "@hypit/timeline";
-import type { ComponentPackage } from "@hypit/component-kit";
-import type { CompositableSurfaceRef } from "@hypit/media";
-import type { SpatialFrame, SpatialPath, SpatialPoint } from "@hypit/spatial";
-import type { StoredValue } from "@hypit/protocol";
-import type { Text } from "@hypit/text";
-import { canonicalize } from "@hypit/protocol";
+import type { Timeline } from "@hypit/hypit/timeline";
+import type { ProducerPackage } from "@hypit/hypit/producer";
+import type { AdmissionPackage } from "@hypit/hypit/admission";
+import type { StoredValue } from "@hypit/hypit/protocol";
+import type { CompositableSurfaceRef } from "@hypit/hypit/media";
+import type { SpatialFrame, SpatialPath, SpatialPoint } from "@hypit/hypit/spatial";
+import type { Text } from "@hypit/hypit/text";
+import { canonicalize } from "@hypit/hypit/protocol";
import { textFineProducers } from "./manifest.js";
import { bindAreaTextPlacement, bindPathTextPlacement, bindPointTextPlacement, createFineTextOccurrence, renderFineTextMask, renderFineTextOccurrence, materializePlainTextItem } from "./program.js";
@@ -21,7 +22,7 @@ import type {
TextMaskSpec,
TextStyle,
} from "./types.js";
-import type { TemporalWindow } from "@hypit/temporal";
+import type { TemporalWindow } from "@hypit/hypit/temporal";
function inline<T>(value: StoredValue | undefined, subject: string): T {
if (value?.kind !== "inline") throw new Error(`${subject} must be inline.`);
@@ -89,4 +90,4 @@ export const textFineComponent = {
)) }, needs: {} }),
},
],
-} satisfies ComponentPackage;
+} satisfies ProducerPackage & AdmissionPackage;
diff --git a/packages/text-fine/src/manifest.ts b/packages/text-fine/src/manifest.ts
index 5b4f07aa..4b18f438 100644
--- a/packages/text-fine/src/manifest.ts
+++ b/packages/text-fine/src/manifest.ts
@@ -1,4 +1,4 @@
-import { timelineTypes, timelineDependency } from "@hypit/timeline";
+import { timelineTypes, timelineDependency } from "@hypit/hypit/timeline";
import { readFile } from "node:fs/promises";
import {
@@ -9,21 +9,21 @@ import {
visualTextPaintSchema,
visualTextSequenceSchema,
visualTextTypographySchema,
-} from "@hypit/composition";
+} from "@hypit/hypit/composition";
import {
spatialDependency,
spatialFrameSchema,
spatialPathSchema,
spatialPointSchema,
spatialTypes,
-} from "@hypit/spatial";
-import { VISUAL_STYLE_ENUM_VALUES_V1, VISUAL_STYLE_NAMES_V1 } from "@hypit/visual-ir";
-import { mediaDependency, mediaTypes } from "@hypit/media";
-import { svsRecipeType } from "@hypit/svs";
-import { textDependency, textTypes } from "@hypit/text";
-import type { ModuleManifest, ProducerRef, TypeRef, ValueSchema } from "@hypit/protocol";
-import { temporalDependency, temporalTypes } from "@hypit/temporal";
-import { temporalWindowAttributeVocabulary } from "@hypit/temporal-markup";
+} from "@hypit/hypit/spatial";
+import { VISUAL_STYLE_ENUM_VALUES_V1, VISUAL_STYLE_NAMES_V1 } from "@hypit/hypit/composition";
+import { mediaDependency, mediaTypes } from "@hypit/hypit/media";
+import { recipeType } from "@hypit/hypit/recipe";
+import { textDependency, textTypes } from "@hypit/hypit/text";
+import type { ModuleManifest, ProducerRef, TypeRef, ValueSchema } from "@hypit/hypit/protocol";
+import { temporalDependency, temporalTypes } from "@hypit/hypit/temporal";
+import { temporalWindowAttributeVocabulary } from "@hypit/hypit/temporal/markup";
const previewImage = (file: string) => ({
mediaType: "image/png",
@@ -196,7 +196,7 @@ export const textFineMarkupSurfaces = [
attributes: [
{ name: "id", kind: "identifier", required: true,
summary: "Names this Style, under which occurrences and Spans reference it." },
- { name: "recipe", kind: "reference", required: true, accepts: [svsRecipeType],
+ { name: "recipe", kind: "reference", required: true, accepts: [recipeType],
summary: "Chooses the Recipe that states reusable typography and Paint properties of this Style.",
recipe: [
{ name: "size", required: true,
diff --git a/packages/text-fine/src/program.ts b/packages/text-fine/src/program.ts
index 1570239a..76d4e94e 100644
--- a/packages/text-fine/src/program.ts
+++ b/packages/text-fine/src/program.ts
@@ -1,18 +1,18 @@
-import { assertTimelineIdentity, timelineFrameCount } from "@hypit/timeline";
-import type { Timeline } from "@hypit/timeline";
+import { assertTimelineIdentity, timelineFrameCount } from "@hypit/hypit/timeline";
+import type { Timeline } from "@hypit/hypit/timeline";
import {
assertSpatialFrame,
assertSpatialPath,
assertSpatialPoint,
resolveContentFit,
-} from "@hypit/spatial";
-import type { SpatialFrame, SpatialPath, SpatialPoint } from "@hypit/spatial";
-import { assertTemporalWindowFor } from "@hypit/temporal";
-import type { TemporalWindow } from "@hypit/temporal";
+} from "@hypit/hypit/spatial";
+import type { SpatialFrame, SpatialPath, SpatialPoint } from "@hypit/hypit/spatial";
+import { assertTemporalWindowFor } from "@hypit/hypit/temporal";
+import type { TemporalWindow } from "@hypit/hypit/temporal";
import {
assertVisualTrackIdentity,
sealVisualTrack,
-} from "@hypit/composition";
+} from "@hypit/hypit/composition";
import type {
VisualElement,
VisualPathTextElement,
@@ -20,12 +20,12 @@ import type {
VisualTextElement,
VisualTextFlowElement,
VisualTrack,
-} from "@hypit/composition";
-import { assertCompositableSurfaceRef } from "@hypit/media";
-import type { CompositableSurfaceRef } from "@hypit/media";
-import { canonicalize } from "@hypit/protocol";
-import { verifyText } from "@hypit/text";
-import type { Text } from "@hypit/text";
+} from "@hypit/hypit/composition";
+import { assertCompositableSurfaceRef } from "@hypit/hypit/media";
+import type { CompositableSurfaceRef } from "@hypit/hypit/media";
+import { canonicalize } from "@hypit/hypit/protocol";
+import { verifyText } from "@hypit/hypit/text";
+import type { Text } from "@hypit/hypit/text";
import type {
FineTextOccurrence,
diff --git a/packages/text-fine-studio/src/index.ts b/packages/text-fine/src/studio.ts
similarity index 94%
rename from packages/text-fine-studio/src/index.ts
rename to packages/text-fine/src/studio.ts
index 7bcc120d..8e3e1fa9 100644
--- a/packages/text-fine-studio/src/index.ts
+++ b/packages/text-fine/src/studio.ts
@@ -1,11 +1,8 @@
-import { openFontStudioFields } from "@hypit/fonts-open/studio";
-import { textFineMarkupSurfaces, textFineModuleRef, textFineTypes } from "@hypit/text-fine";
-import type { FineTextOccurrence, TextItem } from "@hypit/text-fine";
-import { compositionTypes } from "@hypit/composition";
-import type { StudioTrackCompanion, StudioTrackCompanionContext, StudioEntityDraft, StudioInspectorFieldDeclaration, StudioSourceBindingDeclaration } from "@hypit/studio-adapter";
-import { childEntities, requiredSurfaceValue, temporalLineageFor, textLayer } from "@hypit/studio-adapter";
-
-const fontInspector = openFontStudioFields("style");
+import { textFineMarkupSurfaces, textFineModuleRef, textFineTypes } from "./manifest.js";
+import type { FineTextOccurrence, TextItem } from "./types.js";
+import { compositionTypes } from "@hypit/hypit/composition";
+import type { StudioTrackCompanion, StudioTrackCompanionContext, StudioEntityDraft, StudioInspectorFieldDeclaration, StudioSourceBindingDeclaration } from "@hypit/studio-companion";
+import { childEntities, requiredSurfaceValue, temporalLineageFor, textLayer } from "@hypit/studio-companion";
const typographyProperties = (textFineMarkupSurfaces
.find((surface) => surface.name === "style")?.vocabulary.attributes
@@ -109,7 +106,7 @@ function occurrenceInspector(form: "flow" | "point" | "path"): readonly StudioIn
...(options === undefined ? {} : { options }),
};
});
- return [...direct, ...fontInspector.fields, ...typographyInspector];
+ return [...direct, ...typographyInspector];
}
function fineTextCompanion(form: "flow" | "point" | "path"): StudioTrackCompanion {
@@ -124,7 +121,7 @@ function fineTextCompanion(form: "flow" | "point" | "path"): StudioTrackCompanio
...placementBindings[form],
{
name: "style",
- referenced: [fontInspector.binding],
+ referenced: [{ name: "font", companion: true }],
recipe: { through: ["recipe"], bindings: typographyProperties.map(({ name }) => ({ name })) },
},
{ name: "motion" },
diff --git a/packages/text-fine/src/surface.ts b/packages/text-fine/src/surface.ts
index a3f78f6f..867e6abb 100644
--- a/packages/text-fine/src/surface.ts
+++ b/packages/text-fine/src/surface.ts
@@ -1,7 +1,7 @@
-import { timelineTypes } from "@hypit/timeline";
-import { resolveTemporalContext } from "@hypit/temporal-markup";
+import { timelineTypes } from "@hypit/hypit/timeline";
+import { resolveTemporalContext } from "@hypit/hypit/temporal/markup";
-import { compositionTypes } from "@hypit/composition";
+import { compositionTypes } from "@hypit/hypit/composition";
import type {
VisualColorPaint,
VisualStyleDeclaration,
@@ -10,27 +10,22 @@ import type {
VisualTextRunStyle,
VisualTextSequenceAnimation,
VisualTextTypography,
-} from "@hypit/composition";
+} from "@hypit/hypit/composition";
import {
assertFontArtifactRef,
assertFontStackRef,
mediaTypes,
-} from "@hypit/media";
-import type { FontArtifactRef, FontStackRef } from "@hypit/media";
-import { spatialTypes } from "@hypit/spatial";
-import { sealGraphFragment } from "@hypit/elaborator";
-import type { FragmentOperation, GraphFragment } from "@hypit/elaborator";
-import { svsRecipeType } from "@hypit/svs";
-import type { SvsRecipe } from "@hypit/svs";
-import { textTypes } from "@hypit/text";
-import type {
- StructuredElement,
- StructuredSurfaceHandler,
- SurfaceResolvedReference,
- MarkupAttributeValue,
-} from "@hypit/markup";
-import { temporalTypes } from "@hypit/temporal";
-import { createTemporalWindowConstruction } from "@hypit/temporal-markup";
+} from "@hypit/hypit/media";
+import type { FontArtifactRef, FontStackRef } from "@hypit/hypit/media";
+import { spatialTypes } from "@hypit/hypit/spatial";
+import { sealGraphFragment } from "@hypit/hypit/author";
+import type { FragmentOperation, GraphFragment } from "@hypit/hypit/author";
+import { recipeType } from "@hypit/hypit/recipe";
+import type { Recipe } from "@hypit/hypit/recipe";
+import { textTypes } from "@hypit/hypit/text";
+import type { StructuredElement, StructuredSurfaceHandler, SurfaceResolvedReference, MarkupAttributeValue } from "@hypit/hypit/markup";
+import { temporalTypes } from "@hypit/hypit/temporal";
+import { createTemporalWindowConstruction } from "@hypit/hypit/temporal/markup";
import { fineTextWindowAttributeVocabulary, textFineProducers, textFineTypes } from "./manifest.js";
import {
@@ -154,26 +149,26 @@ function inline<T>(value: SurfaceResolvedReference, label: string): T {
return value.record.value.value as unknown as T;
}
-function recipe(value: SurfaceResolvedReference, label: string): SvsRecipe {
- if (!sameType(value.type, svsRecipeType)) throw new Error(`${label} must reference an SVS Recipe.`);
- return inline<SvsRecipe>(value, label);
+function recipe(value: SurfaceResolvedReference, label: string): Recipe {
+ if (!sameType(value.type, recipeType)) throw new Error(`${label} must reference an SVS Recipe.`);
+ return inline<Recipe>(value, label);
}
-function propNumber(value: SvsRecipe, name: string, fallback?: number): number {
+function propNumber(value: Recipe, name: string, fallback?: number): number {
const result = value.properties[name];
if (result === undefined && fallback !== undefined) return fallback;
if (typeof result !== "number" || !Number.isFinite(result)) throw new Error(`Text Recipe ${name} must be a number.`);
return result;
}
-function propString(value: SvsRecipe, name: string, fallback?: string): string {
+function propString(value: Recipe, name: string, fallback?: string): string {
const result = value.properties[name];
if (result === undefined && fallback !== undefined) return fallback;
if (typeof result !== "string" || !result.trim()) throw new Error(`Text Recipe ${name} must be text.`);
return result.trim();
}
-function propBoolean(value: SvsRecipe, name: string, fallback: boolean): boolean {
+function propBoolean(value: Recipe, name: string, fallback: boolean): boolean {
return booleanValue(value.properties[name], `Text Recipe ${name}`, fallback);
}
@@ -359,7 +354,7 @@ const STYLE_PROPERTIES = new Set([
export const decodeTypographyStyleSurface: StructuredSurfaceHandler = ({ element, resolveReference }) => {
allowed(element, ["id", "recipe", "font"], ["id", "recipe", "font"]);
const id = text(element, "id");
- const value = recipe(reference(element.attributes.recipe, `${element.name}.recipe`, svsRecipeType, resolveReference), `${element.name}.recipe`);
+ const value = recipe(reference(element.attributes.recipe, `${element.name}.recipe`, recipeType, resolveReference), `${element.name}.recipe`);
const unknown = Object.keys(value.properties).filter((name) => !STYLE_PROPERTIES.has(name));
if (unknown.length > 0) throw new Error(`Text Recipe does not accept ${unknown[0]}.`);
const fonts = exactFonts(element, resolveReference);
diff --git a/packages/text-fine/src/types.ts b/packages/text-fine/src/types.ts
index 0812de24..216d9756 100644
--- a/packages/text-fine/src/types.ts
+++ b/packages/text-fine/src/types.ts
@@ -7,8 +7,8 @@ import type {
VisualTextPaintLayer,
VisualTextSequenceAnimation,
VisualTextTypography,
-} from "@hypit/composition";
-import type { SpatialFrame, SpatialPath, SpatialPoint } from "@hypit/spatial";
+} from "@hypit/hypit/composition";
+import type { SpatialFrame, SpatialPath, SpatialPoint } from "@hypit/hypit/spatial";
export type TextDocument = VisualTextDocument;
export type TextTypography = VisualTextTypography;
diff --git a/packages/text-fine/test/text-fine.test.ts b/packages/text-fine/test/text-fine.test.ts
index 5147bdf6..9b2bacbf 100644
--- a/packages/text-fine/test/text-fine.test.ts
+++ b/packages/text-fine/test/text-fine.test.ts
@@ -6,11 +6,12 @@ import { narrativeProjectionFixture, timelineFixture } from "../../../test/timel
import { projectSelectionWindow } from "../../../test/temporal-fixture.js";
import { spatialComponent, videoContractManifests } from "../../../test/support/video-domain.js";
-import { registerTypeValidatorFacets } from "@hypit/component-kit";
+import { registerTypeValidatorFacets } from "@hypit/admission";
import { compositionTypes, sealComposition } from "@hypit/composition";
-import { createResolvedClosure, sealBuildRequest, start } from "@hypit/core";
-import { AuthorFrontendRegistry, compileSourceClosure, resolveCompiledSourceExport } from "@hypit/elaborator";
-import { compileHyperframesDocument } from "@hypit/hyperframes";
+import { createResolvedClosure, sealBuildRequest, start } from "@hypit/kernel";
+import { AuthorFrontendRegistry, resolveCompiledSourceExport } from "@hypit/author";
+import { compileSourceClosure } from "@hypit/compiler";
+import { compileHtmlProgram } from "@hypit/html-program";
import { mediaDependency, mediaTypes } from "@hypit/media";
import type { CompositableSurfaceRef, FontArtifactRef } from "@hypit/media";
import type { NarrativeSelectionRef } from "@hypit/narrative";
@@ -42,10 +43,11 @@ import {
} from "@hypit/text-fine";
import type { TextStyle } from "@hypit/text-fine";
import { spatialDependency, spatialTypes } from "@hypit/spatial";
-import { svsManifest, svsRecipeType } from "@hypit/svs";
+import { recipeManifest, recipeType } from "@hypit/recipe";
import { sealText, textComponent, textDependency, textManifest, textTypes } from "@hypit/text";
import { MarkupSurfaceRegistry, createMarkupAuthorFrontend } from "@hypit/markup";
-import { createRecordAdmitter, TypeValidatorRegistry } from "@hypit/validation";
+import { createRecordAdmitter, TypeValidatorRegistry } from "@hypit/admission";
+import { resolveSelfDescribedTextSource } from "@hypit/source/text";
const space = sealTimeline({ id: "test-space", frameCount: 150, frameRate: { numerator: 30, denominator: 1 },
});
@@ -198,7 +200,7 @@ test("Text Mask explicitly consumes one fine Text occurrence and one owned still
assert.ok(track.presents[0]?.elements[2]?.style.some((entry) =>
entry.name === "transform" && entry.value === "matrix(2,0,0,2,0,-120)"));
assert.equal(track.presents[0]?.elements[2]?.style.some((entry) => entry.name === "object-fit"), false);
- const html = compileHyperframesDocument(sealComposition({
+ const html = compileHtmlProgram(sealComposition({
id: "owned-mask-composition",
canvas: { width: 1080, height: 1920, clearColor: "#000000" }, tracks: [track],
}), space).html;
@@ -264,7 +266,7 @@ test("the self-described Markup Surfaces compile Style, Motion and all three spa
const fixtureSurface = {
name: "inputs", tag: "Inputs", mode: "structured",
outputs: [
- svsRecipeType,
+ recipeType,
timelineTypes.timeline,
spatialTypes.point,
spatialTypes.frame,
@@ -283,7 +285,7 @@ test("the self-described Markup Surfaces compile Style, Motion and all three spa
spatialDependency,
mediaDependency,
{
- module: { name: svsManifest.name, version: svsManifest.version },
+ module: { name: recipeManifest.name, version: recipeManifest.version },
},
textDependency,
],
@@ -302,7 +304,7 @@ test("the self-described Markup Surfaces compile Style, Motion and all three spa
records: [
{
id: "editorial",
- type: svsRecipeType,
+ type: recipeType,
value: { kind: "inline", value: {
path: "text.editorial",
@@ -315,7 +317,7 @@ test("the self-described Markup Surfaces compile Style, Motion and all three spa
},
{
id: "mask-editorial",
- type: svsRecipeType,
+ type: recipeType,
value: { kind: "inline", value: {
path: "text.mask-editorial",
@@ -356,7 +358,7 @@ test("the self-described Markup Surfaces compile Style, Motion and all three spa
registerTypeValidatorFacets(validators, spatialComponent.validators ?? []);
registerTypeValidatorFacets(validators, textComponent.validators ?? []);
const compiled = await compileSourceClosure({
- entry: {
+ entry: resolveSelfDescribedTextSource({
id: "/project/text.svml",
name: "text.svml",
text: `<?svml using="@hypit/markup@1"?>
@@ -399,7 +401,7 @@ test("the self-described Markup Surfaces compile Style, Motion and all three spa
<text:Flow id="mask-shape" timeline={semantic} within={body-frame} style={mask-shape-style} z="75" wrap="none" during="timeline">MASK</text:Flow>
<text:Mask id="masked-titles" timeline={semantic} text={mask-shape.occurrence} material={material}/>
</svml>`,
- },
+ }),
closure,
frontends,
admitRecord: createRecordAdmitter(validators),
@@ -563,7 +565,7 @@ test("rich Text lowers ordered glyph layers, boxes, bounded flow, sequences and
sealTextItemSpec({ id: "path", document: document("Renderer-neutral Path Text") }),
pathStyle, stillTextMotion("path-still"), absoluteWindow("path", 0, 150),
);
- const rendered = compileHyperframesDocument(sealComposition({
+ const rendered = compileHtmlProgram(sealComposition({
id: "rich-text-film", canvas: { width: 1080, height: 900, clearColor: "#000000" },
tracks: [renderFineTextOccurrence(space, area), renderFineTextOccurrence(space, path)],
}), space);
@@ -582,14 +584,14 @@ test("a paragraph's source indentation is not part of its words", async () => {
const fixtureSurface = {
name: "inputs", tag: "Inputs", mode: "structured",
outputs: [
- svsRecipeType, timelineTypes.timeline, spatialTypes.frame,
+ recipeType, timelineTypes.timeline, spatialTypes.frame,
mediaTypes.fontArtifact, textTypes.text,
],
} as const;
const fixtureManifest: ModuleManifest = {
format: "hypit.module@1", name: fixtureModule.name, version: fixtureModule.version,
dependencies: [timelineDependency, spatialDependency, mediaDependency,
- { module: { name: svsManifest.name, version: svsManifest.version } }, textDependency],
+ { module: { name: recipeManifest.name, version: recipeManifest.version } }, textDependency],
types: [], capabilities: [], producers: [],
};
const closure = createResolvedClosure([
@@ -598,7 +600,7 @@ test("a paragraph's source indentation is not part of its words", async () => {
const surfaces = new MarkupSurfaceRegistry();
surfaces.registerStructured({ module: fixtureModule, declaration: fixtureSurface, handler: ({ element }) => ({
records: [
- { id: "editorial", type: svsRecipeType, value: { kind: "inline", value: {
+ { id: "editorial", type: recipeType, value: { kind: "inline", value: {
path: "text.editorial", properties: { size: 44, "line-height": 1.15 } } },
range: element.range },
{ id: "semantic", type: timelineTypes.timeline, value: { kind: "inline", value: semantic }, range: element.range },
@@ -618,7 +620,7 @@ test("a paragraph's source indentation is not part of its words", async () => {
registerTypeValidatorFacets(validators, spatialComponent.validators ?? []);
registerTypeValidatorFacets(validators, textComponent.validators ?? []);
const compiled = await compileSourceClosure({
- entry: {
+ entry: resolveSelfDescribedTextSource({
id: "/project/text.svml", name: "text.svml",
text: `<?svml using="@hypit/markup@1"?>
<svml>
@@ -635,7 +637,7 @@ test("a paragraph's source indentation is not part of its words", async () => {
</text:P>
</text:Flow>
</svml>`,
- },
+ }),
closure, frontends,
admitRecord: createRecordAdmitter(validators),
resolveSource() { throw new Error("Text fixture has no source imports."); },
diff --git a/packages/text/package.json b/packages/text/package.json
index 0528e9a1..ff74c874 100644
--- a/packages/text/package.json
+++ b/packages/text/package.json
@@ -11,11 +11,13 @@
"activation": "./src/activation.ts"
},
"dependencies": {
- "@hypit/component-kit": "workspace:*",
- "@hypit/core": "workspace:*",
- "@hypit/elaborator": "workspace:*",
+ "@hypit/producer": "workspace:*",
+ "@hypit/kernel": "workspace:*",
+ "@hypit/author": "workspace:*",
"@hypit/markup": "workspace:*",
"@hypit/protocol": "workspace:*",
- "@hypit/svs": "workspace:*"
+ "@hypit/recipe": "workspace:*",
+ "@hypit/source": "workspace:*",
+ "@hypit/admission": "workspace:*"
}
}
diff --git a/packages/text/src/activation.ts b/packages/text/src/activation.ts
index efed7dc9..cbac527e 100644
--- a/packages/text/src/activation.ts
+++ b/packages/text/src/activation.ts
@@ -1,5 +1,7 @@
-import { createAuthorFrontendHostFacet } from "@hypit/elaborator";
-import { createMarkupSurfaceHostFacet } from "@hypit/markup";
+import { createAdmissionPackageFacet } from "@hypit/admission";
+import { createProducerPackageFacet } from "@hypit/producer";
+import { createAuthorFrontendFacet } from "@hypit/author";
+import { createMarkupSurfaceFacet } from "@hypit/markup";
import {
decodeTextRenderSurface,
@@ -7,22 +9,22 @@ import {
textComponent,
textManifest,
textModuleRef,
- textSvsFrontend,
+ textRecipeFrontend,
textMarkupSurfaces,
} from "./index.js";
export const hypitPackage = {
- format: "hypit.node-package@1" as const,
+ format: "hypit.package@1" as const,
modules: [{ manifest: textManifest }],
- components: [textComponent],
- hostFacets: [
- createAuthorFrontendHostFacet(textSvsFrontend),
- createMarkupSurfaceHostFacet({
+ facets: [
+ ...[textComponent].flatMap((component) => [createProducerPackageFacet(component), createAdmissionPackageFacet(component)]),
+ createAuthorFrontendFacet(textRecipeFrontend),
+ createMarkupSurfaceFacet({
module: textModuleRef,
declaration: textMarkupSurfaces.find((item) => item.name === "value")!,
handler: decodeTextValueSurface,
}),
- createMarkupSurfaceHostFacet({
+ createMarkupSurfaceFacet({
module: textModuleRef,
declaration: textMarkupSurfaces.find((item) => item.name === "render")!,
handler: decodeTextRenderSurface,
diff --git a/packages/text/src/component.ts b/packages/text/src/component.ts
index df9622a1..35ce289d 100644
--- a/packages/text/src/component.ts
+++ b/packages/text/src/component.ts
@@ -1,4 +1,5 @@
-import type { ComponentPackage, ProducerHandlerContext } from "@hypit/component-kit";
+import type { AdmissionPackage } from "@hypit/admission";
+import type { ProducerPackage, ProducerHandlerContext } from "@hypit/producer";
import type { StoredValue } from "@hypit/protocol";
import {
@@ -69,4 +70,4 @@ export const textComponent = {
}),
},
],
-} satisfies ComponentPackage;
+} satisfies ProducerPackage & AdmissionPackage;
diff --git a/packages/text/src/fragment.ts b/packages/text/src/fragment.ts
index aff5af16..b762d8c2 100644
--- a/packages/text/src/fragment.ts
+++ b/packages/text/src/fragment.ts
@@ -1,4 +1,4 @@
-import { sealGraphFragment } from "@hypit/elaborator";
+import { sealGraphFragment } from "@hypit/author";
import { textProducers, textTypes } from "./manifest.js";
@@ -20,7 +20,7 @@ export function createTextRenderFragment(entries: readonly TextFragmentBinding[]
{ name: "template", type: textTypes.template },
{ name: "bindings", type: textTypes.bindings },
];
- const operations: Array<import("@hypit/elaborator").FragmentOperation> = [];
+ const operations: Array<import("@hypit/author").FragmentOperation> = [];
let bindings = input("bindings") as ReturnType<typeof input> | ReturnType<typeof operation>;
entries.forEach((entry, index) => {
const prefix = `binding:${entry.name}`;
diff --git a/packages/text/src/frontend.ts b/packages/text/src/frontend.ts
index d6d05dfc..b7e11892 100644
--- a/packages/text/src/frontend.ts
+++ b/packages/text/src/frontend.ts
@@ -1,28 +1,29 @@
import {
sealRecord,
-} from "@hypit/core";
-import type { AuthorFrontend, AuthorSourceExport } from "@hypit/elaborator";
-import { parseSvs } from "@hypit/svs";
+} from "@hypit/kernel";
+import type { AuthorFrontend, AuthorSourceExport } from "@hypit/author";
+import { parseRecipe } from "@hypit/recipe";
+import { decodeSourceText } from "@hypit/source";
import { textModuleRef, textTypes } from "./manifest.js";
-import { textTemplateFromSvsRecipes } from "./svs.js";
+import { textTemplateFromRecipes } from "./recipe.js";
-export const textSvsFrontendId = "@hypit/text/svs@1";
+export const textRecipeFrontendId = "@hypit/text/svs@1";
-export const textSvsFrontend: AuthorFrontend = {
- id: textSvsFrontendId,
+export const textRecipeFrontend: AuthorFrontend = {
+ id: textRecipeFrontendId,
discover() {
return { modules: [`${textModuleRef.name}@${textModuleRef.version}`], sources: [] };
},
decode(source, context) {
- const parsed = parseSvs(source.name, source.text);
+ const parsed = parseRecipe(source.name, decodeSourceText(source));
const recipes = parsed.recipes.map((item) => item.value);
const candidates = recipes
.map((recipe) => /^text-template\.([a-z][a-z0-9-]{0,95})$/u.exec(recipe.path)?.[1])
.filter((id): id is string => id !== undefined);
if (candidates.length !== 1) throw new Error(`${source.name} must declare exactly one root Recipe text-template.<id>`);
const id = candidates[0]!;
- const template = textTemplateFromSvsRecipes(recipes, id);
+ const template = textTemplateFromRecipes(recipes, id);
const record = sealRecord({
id,
type: textTypes.template,
diff --git a/packages/text/src/index.ts b/packages/text/src/index.ts
index 7ff90858..c58976b4 100644
--- a/packages/text/src/index.ts
+++ b/packages/text/src/index.ts
@@ -1,5 +1,5 @@
export { textComponent } from "./component.js";
-export { textSvsFrontend, textSvsFrontendId } from "./frontend.js";
+export { textRecipeFrontend, textRecipeFrontendId } from "./frontend.js";
export { createTextRenderFragment } from "./fragment.js";
export type { TextFragmentBinding } from "./fragment.js";
export {
@@ -22,6 +22,6 @@ export {
verifyTextBindings,
verifyTextTemplate,
} from "./program.js";
-export { textTemplateFromSvsRecipes } from "./svs.js";
+export { textTemplateFromRecipes } from "./recipe.js";
export { decodeTextRenderSurface, decodeTextValueSurface } from "./surface.js";
export type * from "./types.js";
diff --git a/packages/text/src/manifest.ts b/packages/text/src/manifest.ts
index 1dc34d76..7b4c2094 100644
--- a/packages/text/src/manifest.ts
+++ b/packages/text/src/manifest.ts
@@ -1,5 +1,5 @@
import type { ModuleManifest, ProducerRef, TypeRef } from "@hypit/protocol";
-import { svsRecipeType } from "@hypit/svs";
+import { recipeType } from "@hypit/recipe";
export const textModuleRef = { name: "@hypit/text", version: "1" } as const;
@@ -70,7 +70,7 @@ export const textMarkupSurfaces = [{
{ name: "when-select-<binding>", required: false,
summary: "States the same condition as `when-param-`, for a binding an author reads as a Selection." },
] },
- { name: "recipe", kind: "reference", required: false, accepts: [svsRecipeType],
+ { name: "recipe", kind: "reference", required: false, accepts: [recipeType],
summary: "Chooses the Recipe whose scalar properties fill the bindings the Template declares." },
],
children: [
diff --git a/packages/text/src/svs.ts b/packages/text/src/recipe.ts
similarity index 93%
rename from packages/text/src/svs.ts
rename to packages/text/src/recipe.ts
index 2c783a79..4e3adea5 100644
--- a/packages/text/src/svs.ts
+++ b/packages/text/src/recipe.ts
@@ -1,4 +1,4 @@
-import type { SvsRecipe } from "@hypit/svs";
+import type { Recipe } from "@hypit/recipe";
import { sealTextTemplate } from "./program.js";
import type {
@@ -20,13 +20,13 @@ type Block =
| { readonly kind: "variant"; readonly id: string; readonly order: number; readonly choices: readonly Choice[] }
| { readonly kind: "slot"; readonly id: string; readonly order: number; readonly slot: string; readonly optional: boolean; readonly label?: string };
-function text(recipe: SvsRecipe, name: string, fallback?: string): string {
+function text(recipe: Recipe, name: string, fallback?: string): string {
const value = recipe.properties[name] ?? fallback;
if (typeof value !== "string" || value.length === 0) throw new Error(`${recipe.path}.${name} must be non-empty text`);
return value;
}
-function integer(recipe: SvsRecipe, name: string): number {
+function integer(recipe: Recipe, name: string): number {
const value = recipe.properties[name];
if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0) {
throw new Error(`${recipe.path}.${name} must be a non-negative integer`);
@@ -34,20 +34,20 @@ function integer(recipe: SvsRecipe, name: string): number {
return value;
}
-function boolean(recipe: SvsRecipe, name: string, fallback: boolean): boolean {
+function boolean(recipe: Recipe, name: string, fallback: boolean): boolean {
const value = recipe.properties[name] ?? fallback;
if (typeof value !== "boolean") throw new Error(`${recipe.path}.${name} must be boolean`);
return value;
}
-function exactProperties(recipe: SvsRecipe, allowed: ReadonlySet<string>, prefixes: readonly string[] = []): void {
+function exactProperties(recipe: Recipe, allowed: ReadonlySet<string>, prefixes: readonly string[] = []): void {
const unknown = Object.keys(recipe.properties).filter(
(name) => !allowed.has(name) && !prefixes.some((prefix) => name.startsWith(prefix)),
);
if (unknown.length > 0) throw new Error(`${recipe.path} contains unknown property ${unknown[0]}`);
}
-function choice(recipe: SvsRecipe, id: string): Choice {
+function choice(recipe: Recipe, id: string): Choice {
exactProperties(recipe, new Set(["text"]), ["when-param-", "when-select-"]);
const conditions: Record<string, TextScalar> = {};
for (const [name, value] of Object.entries(recipe.properties)) {
@@ -112,8 +112,8 @@ function expression(block: Block): TextExpression {
* SVS remains inert data; this Frontend only lowers fixed/axis/variant/slot
* recipes into the ordinary domain-neutral Text expression language.
*/
-export function textTemplateFromSvsRecipes(
- recipes: readonly SvsRecipe[],
+export function textTemplateFromRecipes(
+ recipes: readonly Recipe[],
templateId: string,
): TextTemplate {
const prefix = `text-template.${templateId}`;
diff --git a/packages/text/src/surface.ts b/packages/text/src/surface.ts
index ec849d96..d9f7bff5 100644
--- a/packages/text/src/surface.ts
+++ b/packages/text/src/surface.ts
@@ -1,6 +1,6 @@
import type { CanonicalValue } from "@hypit/protocol";
-import { svsRecipeType } from "@hypit/svs";
-import type { SvsRecipe } from "@hypit/svs";
+import { recipeType } from "@hypit/recipe";
+import type { Recipe } from "@hypit/recipe";
import type {
MarkupAttributeValue,
StructuredElement,
@@ -129,8 +129,8 @@ export const decodeTextRenderSurface: StructuredSurfaceHandler = ({ element, res
const templateValue = inline<TextTemplate>(template, `${element.name}.template`);
verifyTextTemplate(templateValue);
const consumed = textTemplateBindingNames(templateValue);
- const recipe = reference(element, "recipe", svsRecipeType, resolveReference);
- const value = inline<SvsRecipe>(recipe, `${element.name}.recipe`);
+ const recipe = reference(element, "recipe", recipeType, resolveReference);
+ const value = inline<Recipe>(recipe, `${element.name}.recipe`);
for (const [name, item] of Object.entries(value.properties)) {
if (!consumed.has(name)) continue;
if (typeof item !== "string" && typeof item !== "boolean" && !(typeof item === "number" && Number.isFinite(item))) {
diff --git a/packages/text/test/text.test.ts b/packages/text/test/text.test.ts
index 04e1c02b..e1e848b3 100644
--- a/packages/text/test/text.test.ts
+++ b/packages/text/test/text.test.ts
@@ -2,7 +2,7 @@ import assert from "node:assert/strict";
import test from "node:test";
import { parseStructuredElement } from "@hypit/markup";
import type { SurfaceResolvedReference } from "@hypit/markup";
-import { svsRecipeType } from "@hypit/svs";
+import { recipeType } from "@hypit/recipe";
import {
bindText,
@@ -194,7 +194,7 @@ test("Text Render projects only declared SVS Recipe properties and lets explicit
record: { value: { kind: "inline", value: template } } as unknown as NonNullable<SurfaceResolvedReference["record"]>,
}],
["recipes.shot", {
- path: "recipes.shot", ref: { kind: "record", id: "recipes.shot" }, type: svsRecipeType,
+ path: "recipes.shot", ref: { kind: "record", id: "recipes.shot" }, type: recipeType,
record: { value: { kind: "inline", value: {
path: "recipes.shot",
diff --git a/packages/timeline-author/README.md b/packages/timeline-author/README.md
index 7cbc461f..5ade26ac 100644
--- a/packages/timeline-author/README.md
+++ b/packages/timeline-author/README.md
@@ -4,6 +4,11 @@ Construct one finite absolute Timeline from a small acyclic graph of named Insta
This package owns author syntax and lowering; [`@hypit/timeline`](../timeline/README.md) owns only the
completed value `{ id, frameRate, frameCount }`.
+The official video Distribution installs this package as an ordinary default npm dependency. Its
+parser and construction values remain package-owned; downstream components consume only the public
+Timeline, Window and Instant values. Core and the Timeline value package do not know this author
+syntax exists.
+
Timeline is not a media Track, clip list, semantic anchor registry or hidden schedule. Its author
graph does only two jobs:
diff --git a/packages/timeline-author/package.json b/packages/timeline-author/package.json
index 9ff3bd59..03a033bc 100644
--- a/packages/timeline-author/package.json
+++ b/packages/timeline-author/package.json
@@ -1,28 +1,31 @@
{
"name": "@hypit/timeline-author",
- "version": "0.0.0-dev",
+ "version": "0.1.0",
"license": "SEE LICENSE IN LICENSE",
"private": true,
"type": "module",
"exports": {
".": "./src/index.ts"
},
+ "files": [
+ "dist",
+ "README.md"
+ ],
"hypit": {
"activation": "./src/activation.ts"
},
- "dependencies": {
- "@hypit/component-kit": "workspace:*",
- "@hypit/elaborator": "workspace:*",
- "@hypit/protocol": "workspace:*",
- "@hypit/timeline": "workspace:*",
- "@hypit/markup": "workspace:*",
- "@hypit/temporal": "workspace:*",
- "@hypit/temporal-markup": "workspace:*"
+ "peerDependencies": {
+ "@hypit/hypit": "workspace:^"
},
"devDependencies": {
- "@hypit/core": "workspace:*",
+ "@hypit/hypit": "workspace:*",
+ "@hypit/kernel": "workspace:*",
+ "@hypit/author": "workspace:*",
+ "@hypit/markup": "workspace:*",
"@hypit/script": "workspace:*",
+ "@hypit/temporal": "workspace:*",
"@hypit/text": "workspace:*",
- "@hypit/validation": "workspace:*"
+ "@hypit/timeline": "workspace:*",
+ "@hypit/admission": "workspace:*"
}
}
diff --git a/packages/timeline-author/src/activation.ts b/packages/timeline-author/src/activation.ts
index ad7c855d..a752c1e2 100644
--- a/packages/timeline-author/src/activation.ts
+++ b/packages/timeline-author/src/activation.ts
@@ -1,4 +1,6 @@
-import { createMarkupSurfaceHostFacet } from "@hypit/markup";
+import { createAdmissionPackageFacet } from "@hypit/hypit/admission";
+import { createProducerPackageFacet } from "@hypit/hypit/producer";
+import { createMarkupSurfaceFacet } from "@hypit/hypit/markup";
import {
decodeAbsoluteInstantSurface, decodeAbsoluteWindowSurface, decodeClockSurface, decodeTimelineAuthorSurface, timelineAuthorComponent, timelineAuthorManifest,
timelineAuthorModuleRef,
@@ -6,19 +8,19 @@ import {
} from "./index.js";
export const hypitPackage = {
- format: "hypit.node-package@1" as const,
+ format: "hypit.package@1" as const,
modules: [{
manifest: timelineAuthorManifest,
}],
- components: [timelineAuthorComponent],
- hostFacets: [createMarkupSurfaceHostFacet({
+ facets: [
+ ...[timelineAuthorComponent].flatMap((component) => [createProducerPackageFacet(component), createAdmissionPackageFacet(component)]),createMarkupSurfaceFacet({
module: timelineAuthorModuleRef,
declaration: timelineAuthorMarkupSurfaces.find((item) => item.name === "timeline")!, handler: decodeTimelineAuthorSurface,
- }), createMarkupSurfaceHostFacet({ module: timelineAuthorModuleRef,
+ }), createMarkupSurfaceFacet({ module: timelineAuthorModuleRef,
declaration: timelineAuthorMarkupSurfaces.find(item => item.name === "clock")!, handler: decodeClockSurface,
- }), createMarkupSurfaceHostFacet({ module: timelineAuthorModuleRef,
+ }), createMarkupSurfaceFacet({ module: timelineAuthorModuleRef,
declaration: timelineAuthorMarkupSurfaces.find(item => item.name === "window")!, handler: decodeAbsoluteWindowSurface,
- }), createMarkupSurfaceHostFacet({ module: timelineAuthorModuleRef,
+ }), createMarkupSurfaceFacet({ module: timelineAuthorModuleRef,
declaration: timelineAuthorMarkupSurfaces.find(item => item.name === "instant")!, handler: decodeAbsoluteInstantSurface,
})],
};
diff --git a/packages/timeline-author/src/component.ts b/packages/timeline-author/src/component.ts
index 97ee1841..bf7cb973 100644
--- a/packages/timeline-author/src/component.ts
+++ b/packages/timeline-author/src/component.ts
@@ -1,8 +1,9 @@
-import type { ComponentPackage } from "@hypit/component-kit";
-import { canonicalize } from "@hypit/protocol";
-import type { StoredValue } from "@hypit/protocol";
-import type { LocalTemporalDomain, TemporalDuration, TemporalExtent, TemporalWindow } from "@hypit/temporal";
-import type { Clock, Timeline } from "@hypit/timeline";
+import { canonicalize } from "@hypit/hypit/protocol";
+import type { ProducerPackage } from "@hypit/hypit/producer";
+import type { AdmissionPackage } from "@hypit/hypit/admission";
+import type { StoredValue } from "@hypit/hypit/protocol";
+import type { LocalTemporalDomain, TemporalDuration, TemporalExtent, TemporalWindow } from "@hypit/hypit/temporal";
+import type { Clock, Timeline } from "@hypit/hypit/timeline";
import { timelineAuthorProducers } from "./manifest.js";
import {
@@ -40,4 +41,4 @@ export const timelineAuthorComponent = {
{ producer: timelineAuthorProducers.instant, handler: ({ inputs }) => ({ outputs: { instant: output(materializeInstant(inline<Timeline>(inputs.timeline?.value, "Timeline"), inline<ConstructionPoint>(inputs.point?.value, "ConstructionPoint"), inline<ConstructionIdentitySpec>(inputs.spec?.value, "ConstructionIdentitySpec"))) }, needs: {} }) },
{ producer: timelineAuthorProducers.window, handler: ({ inputs }) => ({ outputs: { window: output(materializeWindow(inline<Timeline>(inputs.timeline?.value, "Timeline"), inline<ConstructionSpan>(inputs.span?.value, "ConstructionSpan"), inline<ConstructionIdentitySpec>(inputs.spec?.value, "ConstructionIdentitySpec"))) }, needs: {} }) },
],
-} satisfies ComponentPackage;
+} satisfies ProducerPackage & AdmissionPackage;
diff --git a/packages/timeline-author/src/fragment.ts b/packages/timeline-author/src/fragment.ts
index 81553f58..16042aad 100644
--- a/packages/timeline-author/src/fragment.ts
+++ b/packages/timeline-author/src/fragment.ts
@@ -1,9 +1,9 @@
-import { sealGraphFragment } from "@hypit/elaborator";
-import type { FragmentOperation, FragmentOperationRef, GraphFragment } from "@hypit/elaborator";
-import type { TypeRef } from "@hypit/protocol";
-import { temporalTypes } from "@hypit/temporal";
-import type { TemporalDuration } from "@hypit/temporal";
-import { timelineTypes } from "@hypit/timeline";
+import { sealGraphFragment } from "@hypit/hypit/author";
+import type { FragmentOperation, FragmentOperationRef, GraphFragment } from "@hypit/hypit/author";
+import type { TypeRef } from "@hypit/hypit/protocol";
+import { temporalTypes } from "@hypit/hypit/temporal";
+import type { TemporalDuration } from "@hypit/hypit/temporal";
+import { timelineTypes } from "@hypit/hypit/timeline";
import { timelineAuthorProducers, timelineAuthorTypes } from "./manifest.js";
import type { TimelineAuthorDeclaration, TimelineAuthorFragmentOptions } from "./types.js";
diff --git a/packages/timeline-author/src/manifest.ts b/packages/timeline-author/src/manifest.ts
index 48dd69c6..87c7aed7 100644
--- a/packages/timeline-author/src/manifest.ts
+++ b/packages/timeline-author/src/manifest.ts
@@ -1,6 +1,6 @@
-import type { ModuleManifest, ProducerRef, TypeRef, ValueSchema } from "@hypit/protocol";
-import { temporalDependency, temporalTypes } from "@hypit/temporal";
-import { timelineDependency, timelineTypes } from "@hypit/timeline";
+import type { ModuleManifest, ProducerRef, TypeRef, ValueSchema } from "@hypit/hypit/protocol";
+import { temporalDependency, temporalTypes } from "@hypit/hypit/temporal";
+import { timelineDependency, timelineTypes } from "@hypit/hypit/timeline";
export const timelineAuthorModuleRef = { name: "@hypit/timeline-author", version: "1" } as const;
export const timelineAuthorTypes = {
diff --git a/packages/timeline-author/src/program.ts b/packages/timeline-author/src/program.ts
index 8df93a32..8b06ea1a 100644
--- a/packages/timeline-author/src/program.ts
+++ b/packages/timeline-author/src/program.ts
@@ -4,16 +4,16 @@ import {
composeTemporalWindow,
durationInFrames,
projectProgramInstant,
-} from "@hypit/temporal";
+} from "@hypit/hypit/temporal";
import type {
LocalTemporalDomain,
TemporalExtent,
TemporalDuration,
TemporalInstant,
TemporalWindow,
-} from "@hypit/temporal";
-import { assertClockIdentity, sealTimeline } from "@hypit/timeline";
-import type { Clock, Timeline } from "@hypit/timeline";
+} from "@hypit/hypit/temporal";
+import { assertClockIdentity, sealTimeline } from "@hypit/hypit/timeline";
+import type { Clock, Timeline } from "@hypit/hypit/timeline";
import type {
ConstructionExtent,
diff --git a/packages/timeline-author/src/surface.ts b/packages/timeline-author/src/surface.ts
index 3e11fac1..3eaf17f5 100644
--- a/packages/timeline-author/src/surface.ts
+++ b/packages/timeline-author/src/surface.ts
@@ -1,20 +1,12 @@
-import {
- assertAttributes,
- assertEmptyElement,
- localName,
- textAttribute,
- type StructuredElement,
- type StructuredSurfaceHandler,
- type SurfaceResolvedReference,
-} from "@hypit/markup";
-import { canonicalize, sameType } from "@hypit/protocol";
-import { temporalTypes } from "@hypit/temporal";
+import { assertAttributes, assertEmptyElement, localName, textAttribute, type StructuredElement, type StructuredSurfaceHandler, type SurfaceResolvedReference } from "@hypit/hypit/markup";
+import { canonicalize, sameType } from "@hypit/hypit/protocol";
+import { temporalTypes } from "@hypit/hypit/temporal";
import {
createTemporalInstantConstruction,
createTemporalWindowConstruction,
resolveTemporalContext,
-} from "@hypit/temporal-markup";
-import { timelineTypes } from "@hypit/timeline";
+} from "@hypit/hypit/temporal/markup";
+import { timelineTypes } from "@hypit/hypit/timeline";
import { compileTimelineAuthorFragment } from "./fragment.js";
import { timelineAuthorTypes } from "./manifest.js";
diff --git a/packages/timeline-author/src/types.ts b/packages/timeline-author/src/types.ts
index 60d00dba..44c032c7 100644
--- a/packages/timeline-author/src/types.ts
+++ b/packages/timeline-author/src/types.ts
@@ -1,4 +1,4 @@
-import type { TemporalDuration } from "@hypit/temporal";
+import type { TemporalDuration } from "@hypit/hypit/temporal";
export type TimelineAuthorHeader = { readonly id: string };
export type ConstructionPoint = { readonly frame: number };
diff --git a/packages/timeline-author/test/program.test.ts b/packages/timeline-author/test/program.test.ts
index 9f4e49c7..f3c2e8d0 100644
--- a/packages/timeline-author/test/program.test.ts
+++ b/packages/timeline-author/test/program.test.ts
@@ -1,7 +1,7 @@
import assert from "node:assert/strict";
import test from "node:test";
-import { createResolvedClosure, link } from "@hypit/core";
-import { verifyGraphFragment } from "@hypit/elaborator";
+import { createResolvedClosure, link } from "@hypit/kernel";
+import { verifyGraphFragment } from "@hypit/author";
import { temporalExtentFromDomain } from "@hypit/temporal";
import { videoContractManifests } from "../../../test/support/video-domain.js";
diff --git a/packages/timeline/package.json b/packages/timeline/package.json
index 3faf8296..a14ad8b5 100644
--- a/packages/timeline/package.json
+++ b/packages/timeline/package.json
@@ -11,7 +11,8 @@
"activation": "./src/activation.ts"
},
"dependencies": {
- "@hypit/component-kit": "workspace:*",
- "@hypit/protocol": "workspace:*"
+ "@hypit/producer": "workspace:*",
+ "@hypit/protocol": "workspace:*",
+ "@hypit/admission": "workspace:*"
}
}
diff --git a/packages/timeline/src/activation.ts b/packages/timeline/src/activation.ts
index ce78077a..56bfbbfb 100644
--- a/packages/timeline/src/activation.ts
+++ b/packages/timeline/src/activation.ts
@@ -1,8 +1,10 @@
+import { createAdmissionPackageFacet } from "@hypit/admission";
+import { createProducerPackageFacet } from "@hypit/producer";
import { timelineComponent, timelineManifest } from "./index.js";
export const hypitPackage = {
- format: "hypit.node-package@1" as const,
+ format: "hypit.package@1" as const,
modules: [{ manifest: timelineManifest }],
- components: [timelineComponent],
+ facets: [...[timelineComponent].flatMap((component) => [createProducerPackageFacet(component), createAdmissionPackageFacet(component)])],
};
export default hypitPackage;
diff --git a/packages/timeline/src/component.ts b/packages/timeline/src/component.ts
index e2da6767..945dbd50 100644
--- a/packages/timeline/src/component.ts
+++ b/packages/timeline/src/component.ts
@@ -1,4 +1,5 @@
-import type { ComponentPackage } from "@hypit/component-kit";
+import type { AdmissionPackage } from "@hypit/admission";
+import type { ProducerPackage } from "@hypit/producer";
import type { StoredValue } from "@hypit/protocol";
import { timelineTypes } from "./manifest.js";
import { assertTimelineIdentity } from "./identity.js";
@@ -15,4 +16,4 @@ export const timelineComponent = {
type: timelineTypes.timeline,
handler: ({ value }) => assertTimelineIdentity(track(value)),
}],
-} satisfies ComponentPackage;
+} satisfies ProducerPackage & AdmissionPackage;
diff --git a/packages/visual-track-studio/README.md b/packages/visual-track-studio/README.md
deleted file mode 100644
index f63cb1de..00000000
--- a/packages/visual-track-studio/README.md
+++ /dev/null
@@ -1,18 +0,0 @@
-# `@hypit/visual-track-studio`
-
-Hypit Studio Companion for `@hypit/visual-track`.
-
-Each Clip has a title and image or video body. An explicit author `id` supplies
-its title; otherwise the Companion displays its `image`, `media` or `surface`
-reference. Display names do not replace the Clip's identity or writeback
-endpoint.
-
-Visual and Audio Track share selection and temporal editing behavior. Visual
-Track composes Clips by draw order; Audio Track mixes overlapping Clips.
-
-The Inspector preserves the author model's orthogonal axes: Frame geometry,
-direct `z`/fit, source-time and treatment Recipe fields are separate bindings.
-Source-time is currently a read-only structural binding: Studio does not collapse an
-arbitrary piecewise relation back into a closed playback-mode control.
-`motion` is a typed Motion reference rather than a Recipe of named effects;
-Pose editing can evolve without restoring an enter/sustain/exit catalogue.
diff --git a/packages/visual-track-studio/package.json b/packages/visual-track-studio/package.json
deleted file mode 100644
index c80a05ae..00000000
--- a/packages/visual-track-studio/package.json
+++ /dev/null
@@ -1,16 +0,0 @@
-{
- "name": "@hypit/visual-track-studio",
- "version": "0.0.0-dev",
- "license": "SEE LICENSE IN LICENSE",
- "private": true,
- "type": "module",
- "exports": { ".": "./src/index.ts" },
- "hypit": { "activation": "./src/activation.ts" },
- "dependencies": {
- "@hypit/visual-track": "workspace:*",
- "@hypit/composition": "workspace:*",
- "@hypit/protocol": "workspace:*",
- "@hypit/studio-adapter": "workspace:*",
- "@hypit/temporal": "workspace:*"
- }
-}
diff --git a/packages/visual-track-studio/src/activation.ts b/packages/visual-track-studio/src/activation.ts
deleted file mode 100644
index 4b476549..00000000
--- a/packages/visual-track-studio/src/activation.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { createStudioCompanionHostFacet } from "@hypit/studio-adapter";
-import { visualTrackStudioTrackCompanions, visualTrackStudioParameterCompanions } from "./index.js";
-
-export default {
- format: "hypit.node-package@1" as const,
- hostFacets: [createStudioCompanionHostFacet({
- tracks: visualTrackStudioTrackCompanions,
- parameters: visualTrackStudioParameterCompanions,
- })],
-};
diff --git a/packages/visual-track/README.md b/packages/visual-track/README.md
index 40f80d08..8c000f32 100644
--- a/packages/visual-track/README.md
+++ b/packages/visual-track/README.md
@@ -120,3 +120,20 @@ today's effect names into tomorrow's ceiling.
Audio from synchronized media is never selected implicitly. Author the corresponding occurrence
independently through [`@hypit/audio-track`](../audio-track/README.md).
+
+## Distribution and Studio
+
+Visual Track is an official default Author Package, not a Core or terminal-ABI package. The Hypit
+video Distribution obtains it through an ordinary npm dependency so a default installation can use
+it immediately, while its code, version and activation remain owned by `@hypit/visual-track`.
+Projects select it explicitly with the logical `@hypit/visual-track@1` Module ABI. Package managers
+and the project lockfile select the physical implementation version.
+
+The stable terminal [`VisualTrack`](../composition/README.md) type is owned by Composition. Visual
+Track is one plain producer of that type; another project or published component may produce the same
+terminal value without depending on this package.
+
+The package's activation contributes both its authoring Surfaces and its Studio Companion. The
+Companion preserves Clip material, Frame, fit, source-time, treatment and typed Motion as separate
+author facts. Studio's generic terminal fallback can still display a Composition `VisualTrack` made
+by another package without interpreting it as a Visual Track Clip.
diff --git a/packages/visual-track/package.json b/packages/visual-track/package.json
index 58c0ebff..4325c7f2 100644
--- a/packages/visual-track/package.json
+++ b/packages/visual-track/package.json
@@ -1,28 +1,38 @@
{
"name": "@hypit/visual-track",
- "version": "0.0.0-dev",
+ "version": "0.1.0",
"license": "SEE LICENSE IN LICENSE",
"private": true,
"type": "module",
"exports": {
- ".": "./src/index.ts"
+ ".": "./src/index.ts",
+ "./studio": "./src/studio.ts"
},
+ "files": [
+ "dist",
+ "README.md"
+ ],
"hypit": {
"activation": "./src/activation.ts"
},
- "dependencies": {
- "@hypit/artifact": "workspace:*",
- "@hypit/component-kit": "workspace:*",
+ "peerDependencies": {
+ "@hypit/hypit": "workspace:^",
+ "@hypit/studio-companion": "workspace:^"
+ },
+ "devDependencies": {
+ "@hypit/blob": "workspace:*",
"@hypit/composition": "workspace:*",
- "@hypit/elaborator": "workspace:*",
+ "@hypit/html-program": "workspace:*",
+ "@hypit/hypit": "workspace:*",
"@hypit/media": "workspace:*",
+ "@hypit/studio-companion": "workspace:*",
+ "@hypit/markup": "workspace:*",
+ "@hypit/narrative": "workspace:*",
"@hypit/protocol": "workspace:*",
- "@hypit/timeline": "workspace:*",
+ "@hypit/recipe": "workspace:*",
"@hypit/spatial": "workspace:*",
- "@hypit/svs": "workspace:*",
- "@hypit/markup": "workspace:*",
"@hypit/temporal": "workspace:*",
- "@hypit/temporal-markup": "workspace:*",
- "@hypit/visual-ir": "workspace:*"
+ "@hypit/timeline": "workspace:*",
+ "typescript": "5.9.3"
}
}
diff --git a/packages/visual-track/preview/build.svrun b/packages/visual-track/preview/build.svrun
index f412b2c0..fadcb639 100644
--- a/packages/visual-track/preview/build.svrun
+++ b/packages/visual-track/preview/build.svrun
@@ -1,4 +1,4 @@
-<?svml using="@hypit/run-markup@1"?>
+<?svml using="@hypit/markup/run@1"?>
<svrun version="1">
<author source="./preview.svml"/>
<target output="final.video"/>
diff --git a/packages/visual-track/preview/preview.svml b/packages/visual-track/preview/preview.svml
index eb38b76d..8bad5872 100644
--- a/packages/visual-track/preview/preview.svml
+++ b/packages/visual-track/preview/preview.svml
@@ -4,12 +4,12 @@
padding, clipping and motion; build.svrun renders the same composition. -->
<svml>
<import as="media" from="@hypit/media@1"/>
- <import as="pipeline" from="@hypit/media-pipeline@1"/>
+ <import as="mediaop" from="@hypit/media-operations@1"/>
<import as="time" from="@hypit/timeline-author@1"/>
<import as="visual" from="@hypit/visual-track@1"/>
<import as="space" from="@hypit/spatial@1"/>
<import as="film" from="@hypit/film@1"/>
- <import as="render" from="@hypit/render-hyperframes@1"/>
+ <import as="html" from="@hypit/html-video@1"/>
<import as="recipes" source="./recipes.svs"/>
<space:Canvas id="vertical" width="720" height="1280"/>
@@ -23,8 +23,8 @@
<media:Image id="picture-a" src="./rounded.png"/>
<media:Image id="picture-b" src="./flush.png"/>
- <pipeline:StillVideo id="duration" source={picture-a} duration="5" clock={clock}/>
- <pipeline:Normalize id="duration-media" source={duration.video} clock={clock}
+ <mediaop:StillVideo id="duration" source={picture-a} duration="5s" clock={clock}/>
+ <mediaop:Normalize id="duration-media" source={duration.video} clock={clock}
video="primary-moving" audio="none" span-authority="video"/>
<time:Timeline id="speech" clock={clock} end="showcase.end">
<time:Window id="showcase" from="start" for={duration-media.extent}/>
@@ -46,5 +46,5 @@
<film:Film id="main" canvas={vertical.canvas} timeline={speech.timeline} appearance={recipes.film.vertical}>
<film:Track source={showcase.visual}/>
</film:Film>
- <render:Video id="final" composition={main.composition} timeline={speech.timeline}/>
+ <html:Video id="final" composition={main.composition} timeline={speech.timeline}/>
</svml>
diff --git a/packages/visual-track/preview/recipes.svs b/packages/visual-track/preview/recipes.svs
index 44d11283..5f664e15 100644
--- a/packages/visual-track/preview/recipes.svs
+++ b/packages/visual-track/preview/recipes.svs
@@ -1,4 +1,4 @@
-<?svml using="@hypit/svs@1"?>
+<?svml using="@hypit/recipe@1"?>
<sheet version="1">
film.vertical { background: #09090B; }
diff --git a/packages/visual-track/src/activation.ts b/packages/visual-track/src/activation.ts
index 3183d879..5f1dd56d 100644
--- a/packages/visual-track/src/activation.ts
+++ b/packages/visual-track/src/activation.ts
@@ -1,4 +1,7 @@
-import { createMarkupSurfaceHostFacet } from "@hypit/markup";
+import { createAdmissionPackageFacet } from "@hypit/hypit/admission";
+import { createProducerPackageFacet } from "@hypit/hypit/producer";
+import { createMarkupSurfaceFacet } from "@hypit/hypit/markup";
+import { createStudioCompanionFacet } from "@hypit/studio-companion";
import {
decodeVisualTrackSurface,
decodeVisualMotionSurface,
@@ -8,27 +11,32 @@ import {
visualTrackModuleRef,
visualTrackMarkupSurfaces,
} from "./index.js";
+import { visualTrackStudioParameterCompanions, visualTrackStudioTrackCompanions } from "./studio.js";
export const hypitPackage = {
- format: "hypit.node-package@1" as const,
+ format: "hypit.package@1" as const,
modules: [{ manifest: visualTrackManifest }],
- components: [visualTrackComponent],
- hostFacets: [
- createMarkupSurfaceHostFacet({
+ facets: [
+ ...[visualTrackComponent].flatMap((component) => [createProducerPackageFacet(component), createAdmissionPackageFacet(component)]),
+ createMarkupSurfaceFacet({
module: visualTrackModuleRef,
declaration: visualTrackMarkupSurfaces.find((item) => item.name === "track")!,
handler: decodeVisualTrackSurface,
}),
- createMarkupSurfaceHostFacet({
+ createMarkupSurfaceFacet({
module: visualTrackModuleRef,
declaration: visualTrackMarkupSurfaces.find((item) => item.name === "motion")!,
handler: decodeVisualMotionSurface,
}),
- createMarkupSurfaceHostFacet({
+ createMarkupSurfaceFacet({
module: visualTrackModuleRef,
declaration: visualTrackMarkupSurfaces.find((item) => item.name === "source-time")!,
handler: decodeVisualSourceTimeSurface,
}),
+ createStudioCompanionFacet({
+ tracks: visualTrackStudioTrackCompanions,
+ parameters: visualTrackStudioParameterCompanions,
+ }),
],
};
export default hypitPackage;
diff --git a/packages/visual-track/src/author.ts b/packages/visual-track/src/author.ts
index 9af03019..0c4909c5 100644
--- a/packages/visual-track/src/author.ts
+++ b/packages/visual-track/src/author.ts
@@ -1,6 +1,6 @@
-import type { SvsRecipe } from "@hypit/svs";
-import { decodeContentFitProperties } from "@hypit/spatial";
-import type { ContentFit } from "@hypit/spatial";
+import type { Recipe } from "@hypit/hypit/recipe";
+import { decodeContentFitProperties } from "@hypit/hypit/spatial";
+import type { ContentFit } from "@hypit/hypit/spatial";
import {
sealMediaPaintLayerSpec,
@@ -17,51 +17,51 @@ import type {
VisualSourceTimeSpec,
} from "./types.js";
-function fail(recipe: SvsRecipe, message: string): never {
+function fail(recipe: Recipe, message: string): never {
throw new Error(`Media Recipe ${recipe.path} ${message}`);
}
-function optionalNumber(recipe: SvsRecipe, name: string): number | undefined {
+function optionalNumber(recipe: Recipe, name: string): number | undefined {
const value = recipe.properties[name];
if (value === undefined) return undefined;
if (typeof value !== "number" || !Number.isFinite(value)) fail(recipe, `${name} must be a finite number.`);
return value;
}
-function number(recipe: SvsRecipe, name: string, fallback?: number): number {
+function number(recipe: Recipe, name: string, fallback?: number): number {
const value = optionalNumber(recipe, name);
if (value === undefined && fallback !== undefined) return fallback;
if (value === undefined) fail(recipe, `requires ${name}.`);
return value;
}
-function optionalString(recipe: SvsRecipe, name: string): string | undefined {
+function optionalString(recipe: Recipe, name: string): string | undefined {
const value = recipe.properties[name];
if (value === undefined) return undefined;
if (typeof value !== "string" || value.trim().length === 0) fail(recipe, `${name} must be text.`);
return value.trim();
}
-function string(recipe: SvsRecipe, name: string, fallback?: string): string {
+function string(recipe: Recipe, name: string, fallback?: string): string {
const value = optionalString(recipe, name);
if (value === undefined && fallback !== undefined) return fallback;
if (value === undefined) fail(recipe, `requires ${name}.`);
return value;
}
-function oneOf<T extends string>(recipe: SvsRecipe, name: string, values: readonly T[], fallback?: T): T {
+function oneOf<T extends string>(recipe: Recipe, name: string, values: readonly T[], fallback?: T): T {
const value = optionalString(recipe, name);
if (value === undefined && fallback !== undefined) return fallback;
if (value === undefined || !values.includes(value as T)) fail(recipe, `${name} must be ${values.join(" | ")}.`);
return value as T;
}
-function assertKeys(recipe: SvsRecipe, allowed: readonly string[]): void {
+function assertKeys(recipe: Recipe, allowed: readonly string[]): void {
const unknown = Object.keys(recipe.properties).filter((name) => !allowed.includes(name));
if (unknown.length > 0) fail(recipe, `does not accept ${unknown.join(", ")}.`);
}
-function scalarList(recipe: SvsRecipe, name: string, allowed: readonly number[]): number[] {
+function scalarList(recipe: Recipe, name: string, allowed: readonly number[]): number[] {
const source = optionalString(recipe, name);
if (source === undefined) return [];
const values = source.split(/\s+/u).map(Number);
@@ -71,7 +71,7 @@ function scalarList(recipe: SvsRecipe, name: string, allowed: readonly number[])
return values;
}
-function padding(recipe: SvsRecipe): VisualFrameTreatment["padding"] {
+function padding(recipe: Recipe): VisualFrameTreatment["padding"] {
const values = scalarList(recipe, "padding", [1, 2, 4]);
if (values.length === 0) return { topPx: 0, rightPx: 0, bottomPx: 0, leftPx: 0 };
if (values.length === 1) return { topPx: values[0]!, rightPx: values[0]!, bottomPx: values[0]!, leftPx: values[0]! };
@@ -79,7 +79,7 @@ function padding(recipe: SvsRecipe): VisualFrameTreatment["padding"] {
return { topPx: values[0]!, rightPx: values[1]!, bottomPx: values[2]!, leftPx: values[3]! };
}
-function gradientStops(recipe: SvsRecipe, source: string): readonly { readonly offset: number; readonly color: string }[] {
+function gradientStops(recipe: Recipe, source: string): readonly { readonly offset: number; readonly color: string }[] {
const stops = source.split(",").map((entry) => {
const match = /^(.+?)@((?:0(?:\.\d+)?)|(?:1(?:\.0+)?))$/u.exec(entry.trim());
if (match === null) fail(recipe, "gradient stops must be color@offset inside [0,1].");
@@ -89,7 +89,7 @@ function gradientStops(recipe: SvsRecipe, source: string): readonly { readonly o
return stops;
}
-function paint(recipe: SvsRecipe, property = "paint"): MediaPaint {
+function paint(recipe: Recipe, property = "paint"): MediaPaint {
const source = string(recipe, property);
const linear = /^linear\(([-+]?\d+(?:\.\d+)?);(.+)\)$/u.exec(source);
if (linear !== null) {
@@ -102,7 +102,7 @@ function paint(recipe: SvsRecipe, property = "paint"): MediaPaint {
return { kind: "solid", color: source };
}
-function shadows(recipe: SvsRecipe): VisualFrameTreatment["shadows"] {
+function shadows(recipe: Recipe): VisualFrameTreatment["shadows"] {
const source = optionalString(recipe, "shadows");
if (source === undefined || source === "none") return [];
return source.split(";").map((entry) => {
@@ -119,12 +119,12 @@ const FIT_KEYS = ["fit", "frame-x", "frame-y", "content-x", "content-y", "fit-of
const SAMPLE_KEYS = ["opacity", "blur", "brightness", "contrast", "saturation"] as const;
const FRAME_KEYS = ["clip", "radius", "padding", "border-width", "border-style", "border-color", "shadows", "frame-paint"] as const;
-export function decodeMediaFit(recipe: SvsRecipe): ContentFit {
+export function decodeMediaFit(recipe: Recipe): ContentFit {
return decodeContentFitProperties(recipe.properties, `Media Recipe ${recipe.path}`);
}
export function decodeMediaSampleSpec(
- recipe: SvsRecipe,
+ recipe: Recipe,
id: string,
sourceKind: "still" | "timed" | "surface",
samplingMotion?: MediaSampleLayerSpec["samplingMotion"],
@@ -148,7 +148,7 @@ export const visualTreatmentDefaults = {
clip: "frame", radius: 0,
} as const;
-export function decodeMediaSampleAppearance(recipe: SvsRecipe): MediaSampleAppearance {
+export function decodeMediaSampleAppearance(recipe: Recipe): MediaSampleAppearance {
return {
opacity: number(recipe, "opacity", visualTreatmentDefaults.opacity),
filter: {
@@ -158,7 +158,7 @@ export function decodeMediaSampleAppearance(recipe: SvsRecipe): MediaSampleAppea
};
}
-export function decodeVisualFrameTreatment(recipe: SvsRecipe): VisualFrameTreatment {
+export function decodeVisualFrameTreatment(recipe: Recipe): VisualFrameTreatment {
const clip = oneOf(recipe, "clip", ["none", "frame", "rounded"] as const, visualTreatmentDefaults.clip);
const borderWidth = number(recipe, "border-width", 0);
return {
@@ -174,7 +174,7 @@ export function decodeVisualFrameTreatment(recipe: SvsRecipe): VisualFrameTreatm
}
export function decodeVisualClipSpec(
- recipe: SvsRecipe,
+ recipe: Recipe,
input: Pick<VisualClipSpec, "id" | "motion" | "z">,
): VisualClipSpec {
assertKeys(recipe, [...SAMPLE_KEYS, ...FRAME_KEYS]);
@@ -187,14 +187,14 @@ export function decodeVisualClipSpec(
});
}
-export function decodeMediaFramePaint(recipe: SvsRecipe, id: string): MediaPaintLayerSpec | undefined {
+export function decodeMediaFramePaint(recipe: Recipe, id: string): MediaPaintLayerSpec | undefined {
const source = optionalString(recipe, "frame-paint");
if (source === undefined || source === "transparent") return undefined;
- const adapted: SvsRecipe = { ...recipe, properties: { paint: source } };
+ const adapted: Recipe = { ...recipe, properties: { paint: source } };
return sealMediaPaintLayerSpec({ id, paint: paint(adapted), opacity: 1 });
}
-export function decodeMediaPaintSpec(recipe: SvsRecipe, id: string): MediaPaintLayerSpec {
+export function decodeMediaPaintSpec(recipe: Recipe, id: string): MediaPaintLayerSpec {
assertKeys(recipe, ["paint", "opacity"]);
return sealMediaPaintLayerSpec({
id, paint: paint(recipe), opacity: number(recipe, "opacity", visualTreatmentDefaults.opacity),
diff --git a/packages/visual-track/src/component.ts b/packages/visual-track/src/component.ts
index 75d3cd22..e4183b37 100644
--- a/packages/visual-track/src/component.ts
+++ b/packages/visual-track/src/component.ts
@@ -1,10 +1,11 @@
-import type { ComponentPackage, ProducerHandlerContext } from "@hypit/component-kit";
-import type { CompositableSurfaceRef, SynchronizedMedia } from "@hypit/media";
-import { canonicalize } from "@hypit/protocol";
-import type { BlobRef, StoredValue } from "@hypit/protocol";
-import type { ContentFit, IntrinsicExtent, SpatialFrame, SpatialMap2D, SpatialPath } from "@hypit/spatial";
-import type { TemporalWindow } from "@hypit/temporal";
-import type { Timeline } from "@hypit/timeline";
+import type { ProducerPackage, ProducerHandlerContext } from "@hypit/hypit/producer";
+import type { AdmissionPackage } from "@hypit/hypit/admission";
+import type { CompositableSurfaceRef, SynchronizedMedia } from "@hypit/hypit/media";
+import { canonicalize } from "@hypit/hypit/protocol";
+import type { BlobRef, StoredValue } from "@hypit/hypit/protocol";
+import type { ContentFit, IntrinsicExtent, SpatialFrame, SpatialMap2D, SpatialPath } from "@hypit/hypit/spatial";
+import type { TemporalWindow } from "@hypit/hypit/temporal";
+import type { Timeline } from "@hypit/hypit/timeline";
import {
appendMediaPaintLayer,
@@ -43,7 +44,7 @@ function inline<T>(value: StoredValue | undefined, label: string): T {
}
function blob(value: StoredValue | undefined): BlobRef {
- if (value?.kind !== "blob") throw new Error("Visual source must be a BlobArtifact.");
+ if (value?.kind !== "blob") throw new Error("Visual source must be a Blob.");
return value;
}
@@ -119,4 +120,4 @@ export const visualTrackComponent = {
type: visualTrackTypes.program,
handler: ({ value }) => assertVisualTrackProgram(inline<VisualTrackProgram>(value, "VisualTrackProgram")),
}],
-} satisfies ComponentPackage;
+} satisfies ProducerPackage & AdmissionPackage;
diff --git a/packages/visual-track/src/fragment.ts b/packages/visual-track/src/fragment.ts
index bac6c9d8..b96eac47 100644
--- a/packages/visual-track/src/fragment.ts
+++ b/packages/visual-track/src/fragment.ts
@@ -1,10 +1,10 @@
-import { timelineTypes } from "@hypit/timeline";
+import { timelineTypes } from "@hypit/hypit/timeline";
-import { artifactTypes } from "@hypit/artifact";
-import { compositionTypes } from "@hypit/composition";
-import { sealGraphFragment } from "@hypit/elaborator";
-import { spatialTypes } from "@hypit/spatial";
-import { temporalTypes } from "@hypit/temporal";
+import { blobTypes } from "@hypit/hypit/blob";
+import { compositionTypes } from "@hypit/hypit/composition";
+import { sealGraphFragment } from "@hypit/hypit/author";
+import { spatialTypes } from "@hypit/hypit/spatial";
+import { temporalTypes } from "@hypit/hypit/temporal";
import { visualTrackProducers, visualTrackTypes } from "./manifest.js";
@@ -16,7 +16,7 @@ export const stillVisualTrackFragment = sealGraphFragment({
inputs: [
{ name: "header", type: visualTrackTypes.header },
{ name: "timeline", type: timelineTypes.timeline },
- { name: "source", type: artifactTypes.blob },
+ { name: "source", type: blobTypes.blob },
{ name: "extent", type: spatialTypes.extent },
{ name: "frame", type: spatialTypes.frame },
{ name: "fit", type: spatialTypes.fit },
diff --git a/packages/visual-track/src/frame-treatment.ts b/packages/visual-track/src/frame-treatment.ts
index d4538e96..30b51b8d 100644
--- a/packages/visual-track/src/frame-treatment.ts
+++ b/packages/visual-track/src/frame-treatment.ts
@@ -1,5 +1,5 @@
-import { assertSpatialFrame, assertSpatialPath } from "@hypit/spatial";
-import type { SpatialFrame } from "@hypit/spatial";
+import { assertSpatialFrame, assertSpatialPath } from "@hypit/hypit/spatial";
+import type { SpatialFrame } from "@hypit/hypit/spatial";
import type { VisualFrameTreatment } from "./types.js";
diff --git a/packages/visual-track/src/layers.ts b/packages/visual-track/src/layers.ts
index ad77a960..97bf36e3 100644
--- a/packages/visual-track/src/layers.ts
+++ b/packages/visual-track/src/layers.ts
@@ -1,16 +1,16 @@
import {
assertCompositableSurfaceRef,
verifySynchronizedMedia,
-} from "@hypit/media";
-import type { CompositableSurfaceRef, SynchronizedMedia } from "@hypit/media";
-import { canonicalize, isResourceId } from "@hypit/protocol";
-import type { BlobRef } from "@hypit/protocol";
+} from "@hypit/hypit/media";
+import type { CompositableSurfaceRef, SynchronizedMedia } from "@hypit/hypit/media";
+import { canonicalize, isResourceId } from "@hypit/hypit/protocol";
+import type { BlobRef } from "@hypit/hypit/protocol";
import {
assertContentFit,
assertIntrinsicExtent,
assertSpatialMap2D,
-} from "@hypit/spatial";
-import type { ContentFit, IntrinsicExtent, SpatialMap2D } from "@hypit/spatial";
+} from "@hypit/hypit/spatial";
+import type { ContentFit, IntrinsicExtent, SpatialMap2D } from "@hypit/hypit/spatial";
import type {
MediaGradientStop,
@@ -36,7 +36,7 @@ export function assertMediaIdentity(value: string, label: string): void {
function assertBlob(value: BlobRef, label: string, prefix?: string): void {
assert(value.kind === "blob" && isResourceId(value.resource)
&& Number.isSafeInteger(value.size) && value.size >= 0 && value.mediaType.length > 0,
- `${label} is not a valid BlobArtifact.`);
+ `${label} is not a valid Blob.`);
if (prefix !== undefined) assert(value.mediaType.startsWith(prefix), `${label} must be ${prefix} bytes.`);
}
diff --git a/packages/visual-track/src/lower.ts b/packages/visual-track/src/lower.ts
index 27887d67..61698882 100644
--- a/packages/visual-track/src/lower.ts
+++ b/packages/visual-track/src/lower.ts
@@ -1,12 +1,12 @@
-import type { Timeline } from "@hypit/timeline";
+import type { Timeline } from "@hypit/hypit/timeline";
import type {
VisualAnimation,
VisualElement,
VisualStyleDeclaration,
VisualSourceTimeMap,
-} from "@hypit/composition";
-import { mapSpatialPoint } from "@hypit/spatial";
-import type { SpatialFrame, SpatialPath } from "@hypit/spatial";
+} from "@hypit/hypit/composition";
+import { mapSpatialPoint } from "@hypit/hypit/spatial";
+import type { SpatialFrame, SpatialPath } from "@hypit/hypit/spatial";
import { poseAnimation, samplingAnimation } from "./motion.js";
import { resolveVisualSourceTime } from "./source-time.js";
diff --git a/packages/visual-track/src/manifest.ts b/packages/visual-track/src/manifest.ts
index 8055fe12..ac0666d0 100644
--- a/packages/visual-track/src/manifest.ts
+++ b/packages/visual-track/src/manifest.ts
@@ -1,18 +1,18 @@
-import { timelineDependency, timelineTypes } from "@hypit/timeline";
-import type { Timeline } from "@hypit/timeline";
-import { temporalContextAttributeVocabulary } from "@hypit/temporal-markup";
-import { visualSourceTimeMapSchema } from "@hypit/composition";
+import { timelineDependency, timelineTypes } from "@hypit/hypit/timeline";
+import type { Timeline } from "@hypit/hypit/timeline";
+import { temporalContextAttributeVocabulary } from "@hypit/hypit/temporal/markup";
+import { visualSourceTimeMapSchema } from "@hypit/hypit/composition";
import { readFile } from "node:fs/promises";
-import { artifactDependency, artifactTypes } from "@hypit/artifact";
-import { compositionDependency, compositionTypes } from "@hypit/composition";
+import { blobDependency, blobTypes } from "@hypit/hypit/blob";
+import { compositionDependency, compositionTypes } from "@hypit/hypit/composition";
import {
compositableSurfaceSchema,
mediaDependency,
mediaTypes,
-} from "@hypit/media";
+} from "@hypit/hypit/media";
-import type { ModuleManifest, ProducerRef, TypeRef, ValueSchema } from "@hypit/protocol";
+import type { ModuleManifest, ProducerRef, TypeRef, ValueSchema } from "@hypit/hypit/protocol";
import {
contentFitSchema,
intrinsicExtentSchema,
@@ -20,10 +20,10 @@ import {
spatialFrameSchema,
spatialMap2DSchema,
spatialTypes,
-} from "@hypit/spatial";
-import { svsRecipeType } from "@hypit/svs";
-import { temporalDependency, temporalTypes } from "@hypit/temporal";
-import { temporalWindowAttributeVocabulary } from "@hypit/temporal-markup";
+} from "@hypit/hypit/spatial";
+import { recipeType } from "@hypit/hypit/recipe";
+import { temporalDependency, temporalTypes } from "@hypit/hypit/temporal";
+import { temporalWindowAttributeVocabulary } from "@hypit/hypit/temporal/markup";
const previewImage = (file: string) => ({
mediaType: "image/png",
@@ -275,14 +275,14 @@ export const visualTrackMarkupSurfaces = [{
summary: "Chooses the Frame the Clip occupies in the program picture plane." },
{ name: "z", kind: "literal", required: true,
summary: "Sets this occurrence's absolute picture stacking order." },
- { name: "treatment", kind: "reference", required: false, accepts: [svsRecipeType],
+ { name: "treatment", kind: "reference", required: false, accepts: [recipeType],
summary: "Optionally chooses reusable image and Frame treatment; timing, fitting and stacking do not belong to it.",
recipe: treatmentRecipeProperties },
{ name: "motion", kind: "reference", required: false, accepts: [visualTrackTypes.motion],
summary: "Optionally applies a reusable typed Motion. Inline Pose children express the same value." },
{ name: "clip", kind: "reference", required: false, accepts: [spatialTypes.path],
summary: "Clips the Clip to an authored Path." },
- { name: "image", kind: "reference", required: false, accepts: [artifactTypes.blob],
+ { name: "image", kind: "reference", required: false, accepts: [blobTypes.blob],
summary: "Shows a durationless still image as the Clip's direct source." },
{ name: "media", kind: "reference", required: false, accepts: [mediaTypes.synchronized],
summary: "Shows an explicitly prepared timed source." },
@@ -399,7 +399,7 @@ export const visualTrackManifest: ModuleManifest = {
name: visualTrackModuleRef.name,
version: visualTrackModuleRef.version,
dependencies: [
- artifactDependency,
+ blobDependency,
mediaDependency,
timelineDependency,
temporalDependency,
@@ -421,8 +421,8 @@ export const visualTrackManifest: ModuleManifest = {
producers: [
{ name: visualTrackProducers.createLayers.name, inputs: [], outputs: [{ name: "layers", type: visualTrackTypes.layerSet }], needs: [] },
{ name: visualTrackProducers.appendPaintLayer.name, inputs: [{ name: "layers", type: visualTrackTypes.layerSet }, { name: "spec", type: visualTrackTypes.paintLayerSpec }], outputs: [{ name: "layers", type: visualTrackTypes.layerSet }], needs: [] },
- { name: visualTrackProducers.appendStillLayer.name, inputs: [{ name: "layers", type: visualTrackTypes.layerSet }, { name: "source", type: artifactTypes.blob }, { name: "extent", type: spatialTypes.extent }, { name: "fit", type: spatialTypes.fit }, { name: "spec", type: visualTrackTypes.sampleLayerSpec }], outputs: [{ name: "layers", type: visualTrackTypes.layerSet }], needs: [] },
- { name: visualTrackProducers.appendMappedStillLayer.name, inputs: [{ name: "layers", type: visualTrackTypes.layerSet }, { name: "source", type: artifactTypes.blob }, { name: "extent", type: spatialTypes.extent }, { name: "mapping", type: spatialTypes.map2D }, { name: "spec", type: visualTrackTypes.sampleLayerSpec }], outputs: [{ name: "layers", type: visualTrackTypes.layerSet }], needs: [] },
+ { name: visualTrackProducers.appendStillLayer.name, inputs: [{ name: "layers", type: visualTrackTypes.layerSet }, { name: "source", type: blobTypes.blob }, { name: "extent", type: spatialTypes.extent }, { name: "fit", type: spatialTypes.fit }, { name: "spec", type: visualTrackTypes.sampleLayerSpec }], outputs: [{ name: "layers", type: visualTrackTypes.layerSet }], needs: [] },
+ { name: visualTrackProducers.appendMappedStillLayer.name, inputs: [{ name: "layers", type: visualTrackTypes.layerSet }, { name: "source", type: blobTypes.blob }, { name: "extent", type: spatialTypes.extent }, { name: "mapping", type: spatialTypes.map2D }, { name: "spec", type: visualTrackTypes.sampleLayerSpec }], outputs: [{ name: "layers", type: visualTrackTypes.layerSet }], needs: [] },
{ name: visualTrackProducers.appendTimedLayer.name, inputs: [{ name: "layers", type: visualTrackTypes.layerSet }, { name: "source", type: mediaTypes.synchronized }, { name: "fit", type: spatialTypes.fit }, { name: "spec", type: visualTrackTypes.sampleLayerSpec }], outputs: [{ name: "layers", type: visualTrackTypes.layerSet }], needs: [] },
{ name: visualTrackProducers.appendMappedTimedLayer.name, inputs: [{ name: "layers", type: visualTrackTypes.layerSet }, { name: "source", type: mediaTypes.synchronized }, { name: "mapping", type: spatialTypes.map2D }, { name: "spec", type: visualTrackTypes.sampleLayerSpec }], outputs: [{ name: "layers", type: visualTrackTypes.layerSet }], needs: [] },
{ name: visualTrackProducers.appendSurfaceLayer.name, inputs: [{ name: "layers", type: visualTrackTypes.layerSet }, { name: "source", type: mediaTypes.compositableSurface }, { name: "fit", type: spatialTypes.fit }, { name: "spec", type: visualTrackTypes.sampleLayerSpec }], outputs: [{ name: "layers", type: visualTrackTypes.layerSet }], needs: [] },
diff --git a/packages/visual-track/src/motion.ts b/packages/visual-track/src/motion.ts
index 9a0e8c83..a3e1b8f1 100644
--- a/packages/visual-track/src/motion.ts
+++ b/packages/visual-track/src/motion.ts
@@ -1,8 +1,8 @@
import type {
VisualAnimation,
VisualStyleDeclaration,
-} from "@hypit/composition";
-import { canonicalize } from "@hypit/protocol";
+} from "@hypit/hypit/composition";
+import { canonicalize } from "@hypit/hypit/protocol";
import type {
MediaSamplingMotion,
diff --git a/packages/visual-track/src/program.ts b/packages/visual-track/src/program.ts
index 485f0c54..f81cb5bf 100644
--- a/packages/visual-track/src/program.ts
+++ b/packages/visual-track/src/program.ts
@@ -1,12 +1,12 @@
-import { assertVisualTrackIdentity, sealVisualTrack } from "@hypit/composition";
-import type { VisualTrack } from "@hypit/composition";
-import { canonicalize } from "@hypit/protocol";
-import { assertSpatialFrame, assertSpatialPath } from "@hypit/spatial";
-import type { SpatialPath } from "@hypit/spatial";
-import { assertTemporalWindowFor } from "@hypit/temporal";
-import type { TemporalWindow } from "@hypit/temporal";
-import { assertTimelineIdentity, timelineFrameCount } from "@hypit/timeline";
-import type { Timeline } from "@hypit/timeline";
+import { assertVisualTrackIdentity, sealVisualTrack } from "@hypit/hypit/composition";
+import type { VisualTrack } from "@hypit/hypit/composition";
+import { canonicalize } from "@hypit/hypit/protocol";
+import { assertSpatialFrame, assertSpatialPath } from "@hypit/hypit/spatial";
+import type { SpatialPath } from "@hypit/hypit/spatial";
+import { assertTemporalWindowFor } from "@hypit/hypit/temporal";
+import type { TemporalWindow } from "@hypit/hypit/temporal";
+import { assertTimelineIdentity, timelineFrameCount } from "@hypit/hypit/timeline";
+import type { Timeline } from "@hypit/hypit/timeline";
import {
assertMediaIdentity,
diff --git a/packages/visual-track/src/source-time.ts b/packages/visual-track/src/source-time.ts
index fe23b377..a8b663ea 100644
--- a/packages/visual-track/src/source-time.ts
+++ b/packages/visual-track/src/source-time.ts
@@ -2,9 +2,9 @@ import type {
VisualSourceTimeMap,
VisualSourceTimePiece,
VisualSourceTimeRational,
-} from "@hypit/composition";
-import { assertTimelineIdentity } from "@hypit/timeline";
-import type { Timeline } from "@hypit/timeline";
+} from "@hypit/hypit/composition";
+import { assertTimelineIdentity } from "@hypit/hypit/timeline";
+import type { Timeline } from "@hypit/hypit/timeline";
import type {
VisualSourceTimeBounds,
diff --git a/packages/visual-track/src/spatial.ts b/packages/visual-track/src/spatial.ts
index a067ad08..78ab72b5 100644
--- a/packages/visual-track/src/spatial.ts
+++ b/packages/visual-track/src/spatial.ts
@@ -2,8 +2,8 @@ import {
assertSpatialFrame,
assertSpatialMap2D,
resolveContentFit,
-} from "@hypit/spatial";
-import type { SpatialFrame } from "@hypit/spatial";
+} from "@hypit/hypit/spatial";
+import type { SpatialFrame } from "@hypit/hypit/spatial";
import { assertVisualFrameTreatment, visualContentFrame } from "./frame-treatment.js";
import {
diff --git a/packages/visual-track-studio/src/index.ts b/packages/visual-track/src/studio.ts
similarity index 95%
rename from packages/visual-track-studio/src/index.ts
rename to packages/visual-track/src/studio.ts
index 790c1014..e470a3c7 100644
--- a/packages/visual-track-studio/src/index.ts
+++ b/packages/visual-track/src/studio.ts
@@ -1,6 +1,4 @@
-import { visualTreatmentDefaults, visualTrackMarkupSurfaces, visualTrackModuleRef, visualTrackTypes } from "@hypit/visual-track";
-import type { MediaLayerProgram, VisualTrackProgram } from "@hypit/visual-track";
-import { compositionTypes } from "@hypit/composition";
+import { compositionTypes } from "@hypit/hypit/composition";
import type {
StudioTrackCompanion,
StudioTrackCompanionContext,
@@ -8,8 +6,11 @@ import type {
StudioInspectorFieldDeclaration,
StudioMaterialPreview,
StudioSourceBindingDeclaration,
-} from "@hypit/studio-adapter";
-import { artifactPreview, authoredItemTitle, childEntities, previewLayer, requiredSurfaceValue, temporalLineageFor, temporalDomainSource } from "@hypit/studio-adapter";
+} from "@hypit/studio-companion";
+import { artifactPreview, authoredItemTitle, childEntities, previewLayer, requiredSurfaceValue, temporalLineageFor, temporalDomainSource } from "@hypit/studio-companion";
+import { visualTreatmentDefaults } from "./author.js";
+import { visualTrackMarkupSurfaces, visualTrackModuleRef, visualTrackTypes } from "./manifest.js";
+import type { MediaLayerProgram, VisualTrackProgram } from "./types.js";
const frameParameters: readonly StudioSourceBindingDeclaration[] = [
{ name: "within" },
@@ -61,7 +62,7 @@ const mediaPercentProperties = new Set(["opacity", "brightness", "contrast", "sa
const mediaPixelProperties = new Set(["radius", "blur", "border-width"]);
function treatmentRecipe(): {
- readonly bindings: readonly import("@hypit/studio-adapter").StudioRecipeBindingDeclaration[];
+ readonly bindings: readonly import("@hypit/studio-companion").StudioRecipeBindingDeclaration[];
readonly inspector: readonly StudioInspectorFieldDeclaration[];
} {
const attribute = visualClipAttributes.find((candidate) => candidate.name === "treatment");
diff --git a/packages/visual-track/src/surface.ts b/packages/visual-track/src/surface.ts
index 34be7898..cb80c8e3 100644
--- a/packages/visual-track/src/surface.ts
+++ b/packages/visual-track/src/surface.ts
@@ -1,27 +1,16 @@
-import { resolveTemporalContext } from "@hypit/temporal-markup";
-import {
- assertEmptyElement as empty,
- assertAttributes as allowed,
- textAttribute as text,
- optionalTextAttribute as optionalText,
- type StructuredElement,
- type StructuredSurfaceHandler,
- type SurfaceComponentDraft,
- type SurfaceRecordDraft,
- type SurfaceResolvedReference,
- type MarkupAttributeValue,
-} from "@hypit/markup";
-import { sameType, type CanonicalValue, type TypeRef } from "@hypit/protocol";
-import { artifactTypes } from "@hypit/artifact";
-import { compositionTypes } from "@hypit/composition";
-import { sealGraphFragment } from "@hypit/elaborator";
-import type { FragmentOperation } from "@hypit/elaborator";
-import { mediaTypes } from "@hypit/media";
-import { spatialTypes } from "@hypit/spatial";
-import { svsRecipeType } from "@hypit/svs";
-import type { SvsRecipe } from "@hypit/svs";
-import { temporalTypes } from "@hypit/temporal";
-import { createTemporalWindowConstruction, temporalWindowAttributeNames } from "@hypit/temporal-markup";
+import { resolveTemporalContext } from "@hypit/hypit/temporal/markup";
+import { assertEmptyElement as empty, assertAttributes as allowed, textAttribute as text, optionalTextAttribute as optionalText, type StructuredElement, type StructuredSurfaceHandler, type SurfaceComponentDraft, type SurfaceRecordDraft, type SurfaceResolvedReference, type MarkupAttributeValue } from "@hypit/hypit/markup";
+import { sameType, type CanonicalValue, type TypeRef } from "@hypit/hypit/protocol";
+import { blobTypes } from "@hypit/hypit/blob";
+import { compositionTypes } from "@hypit/hypit/composition";
+import { sealGraphFragment } from "@hypit/hypit/author";
+import type { FragmentOperation } from "@hypit/hypit/author";
+import { mediaTypes } from "@hypit/hypit/media";
+import { spatialTypes } from "@hypit/hypit/spatial";
+import { recipeType } from "@hypit/hypit/recipe";
+import type { Recipe } from "@hypit/hypit/recipe";
+import { temporalTypes } from "@hypit/hypit/temporal";
+import { createTemporalWindowConstruction, temporalWindowAttributeNames } from "@hypit/hypit/temporal/markup";
import {
decodeMediaFit,
@@ -138,17 +127,17 @@ function reference(
return value;
}
-function recipe(value: SurfaceResolvedReference, label: string): SvsRecipe {
- if (!sameType(value.type, svsRecipeType) || value.record?.value.kind !== "inline") {
+function recipe(value: SurfaceResolvedReference, label: string): Recipe {
+ if (!sameType(value.type, recipeType) || value.record?.value.kind !== "inline") {
throw new Error(`${label} must be an authored SVS Recipe.`);
}
- return value.record.value.value as unknown as SvsRecipe;
+ return value.record.value.value as unknown as Recipe;
}
const FIT_ATTRIBUTES = ["fit", "frame-x", "frame-y", "content-x", "content-y", "fit-offset-x", "fit-offset-y", "fit-constraint"] as const;
const NUMERIC_CLIP_ATTRIBUTES = new Set(["frame-x", "frame-y", "content-x", "content-y", "fit-offset-x", "fit-offset-y"]);
-function sourceRecipe(element: StructuredElement, treatment: SvsRecipe): SvsRecipe {
+function sourceRecipe(element: StructuredElement, treatment: Recipe): Recipe {
const properties: Record<string, CanonicalValue> = { ...treatment.properties };
for (const name of FIT_ATTRIBUTES) {
const raw = optionalText(element, name);
@@ -284,9 +273,9 @@ export const decodeVisualSourceTimeSurface: StructuredSurfaceHandler = ({ elemen
function treatmentRecipe(
element: StructuredElement,
resolve: (path: string) => SurfaceResolvedReference | undefined,
-): SvsRecipe {
+): Recipe {
if (element.attributes.treatment === undefined) return { path: `${element.name}:default-treatment`, properties: {} };
- return recipe(reference(element.attributes.treatment, `${element.name}.treatment`, svsRecipeType, resolve), `${element.name}.treatment`);
+ return recipe(reference(element.attributes.treatment, `${element.name}.treatment`, recipeType, resolve), `${element.name}.treatment`);
}
type FragmentLayer =
@@ -422,7 +411,7 @@ function suffix(index: number): string {
type SourceLayerContext = {
readonly trackId: string;
readonly unitSuffix: string;
- readonly defaultRecipe: SvsRecipe;
+ readonly defaultRecipe: Recipe;
readonly sourceElement: StructuredElement;
readonly source?: DeclaredVisualSource;
readonly sourceTime?: VisualSourceTimeSpec;
@@ -456,7 +445,7 @@ function declaredVisualSource(
if (element.attributes.audio !== undefined) throw new Error(`${element.name}.audio is no longer accepted; normalize the source explicitly and use media={...}.`);
return {
kind,
- value: reference(element.attributes.image, `${element.name}.image`, artifactTypes.blob, resolve),
+ value: reference(element.attributes.image, `${element.name}.image`, blobTypes.blob, resolve),
extent: reference(element.attributes.extent, `${element.name}.extent`, spatialTypes.extent, resolve),
};
}
@@ -513,7 +502,7 @@ function sourceLayer(
const source = context.source ?? declaredVisualSource(element, resolve, true)!;
const appearance = element.attributes.appearance === undefined
? context.defaultRecipe
- : recipe(reference(element.attributes.appearance, `${element.name}.appearance`, svsRecipeType, resolve), `${element.name}.appearance`);
+ : recipe(reference(element.attributes.appearance, `${element.name}.appearance`, recipeType, resolve), `${element.name}.appearance`);
const motion = decodeSamplingMotion(element, context.ignoreSiblingChildren);
const layerSuffix = `${context.unitSuffix}-layer-${suffix(layerIndex)}`;
const layerId = context.defaultLayerId ?? optionalText(element, "id") ?? `${context.trackId}.${layerSuffix}`;
@@ -552,7 +541,7 @@ function unitLayers(
readonly trackId: string;
readonly unitSuffix: string;
readonly element: StructuredElement;
- readonly appearance: SvsRecipe;
+ readonly appearance: Recipe;
readonly directSource: DeclaredVisualSource;
readonly sourceTime?: VisualSourceTimeSpec;
readonly mapping?: SurfaceResolvedReference;
diff --git a/packages/visual-track/src/types.ts b/packages/visual-track/src/types.ts
index 0db7f065..b7737dff 100644
--- a/packages/visual-track/src/types.ts
+++ b/packages/visual-track/src/types.ts
@@ -1,13 +1,13 @@
-import type { FrameSpan, VisualEasing, VisualSourceTimeMap, VisualSourceTimeRational } from "@hypit/composition";
-import type { CompositableSurfaceRef, MediaRational } from "@hypit/media";
-import type { BlobRef } from "@hypit/protocol";
+import type { FrameSpan, VisualEasing, VisualSourceTimeMap, VisualSourceTimeRational } from "@hypit/hypit/composition";
+import type { CompositableSurfaceRef, MediaRational } from "@hypit/hypit/media";
+import type { BlobRef } from "@hypit/hypit/protocol";
import type {
ContentFit,
IntrinsicExtent,
SpatialFrame,
SpatialMap2D,
SpatialPath,
-} from "@hypit/spatial";
+} from "@hypit/hypit/spatial";
/** Intrinsic visual truth resolved before Media authoring; never a Provider or lineage envelope. */
export type MediaVisualSource =
diff --git a/packages/visual-track-studio/test/companion.test.ts b/packages/visual-track/test/studio-companion.test.ts
similarity index 97%
rename from packages/visual-track-studio/test/companion.test.ts
rename to packages/visual-track/test/studio-companion.test.ts
index 997b4311..feb47177 100644
--- a/packages/visual-track-studio/test/companion.test.ts
+++ b/packages/visual-track/test/studio-companion.test.ts
@@ -4,7 +4,7 @@ import test from "node:test";
import {
visualClipTreatmentStudioFields,
visualTrackStudioTrackCompanions,
-} from "../src/index.js";
+} from "../src/studio.js";
test("Visual Studio keeps occurrence facts, treatment and typed Motion separate", () => {
const companion = visualTrackStudioTrackCompanions[0]!;
diff --git a/packages/visual-track/test/visual-track.test.ts b/packages/visual-track/test/visual-track.test.ts
index 670f11c3..129949b4 100644
--- a/packages/visual-track/test/visual-track.test.ts
+++ b/packages/visual-track/test/visual-track.test.ts
@@ -7,10 +7,10 @@ import { projectMomentWindow, projectProgramWindow, projectSegmentWindow, projec
import type { TemporalWindowProjection } from "../../../test/temporal-fixture.js";
import { sealComposition } from "@hypit/composition";
-import { compileHyperframesDocument } from "@hypit/hyperframes";
+import { compileHtmlProgram } from "@hypit/html-program";
import { mediaTypes } from "@hypit/media";
import type { CompositableSurfaceRef, SynchronizedMedia } from "@hypit/media";
-import { artifactTypes } from "@hypit/artifact";
+import { blobTypes } from "@hypit/blob";
import { temporalTypes } from "@hypit/temporal";
import {
appendMediaPaintLayer,
@@ -40,8 +40,8 @@ import type { VisualClipSpec, MediaLayerSet, VisualSourceTimeSpec } from "@hypit
import type { NarrativeMomentRef, NarrativeSelectionRef } from "@hypit/narrative";
import type { BlobRef } from "@hypit/protocol";
import { spatialTypes } from "@hypit/spatial";
-import { svsRecipeType } from "@hypit/svs";
-import type { SvsRecipe } from "@hypit/svs";
+import { recipeType } from "@hypit/recipe";
+import type { Recipe } from "@hypit/recipe";
import type { StructuredElement, StructuredNode, SurfaceResolvedReference, MarkupAttributeValue } from "@hypit/markup";
const space = sealTimeline({ id: "test-space", frameCount: 120, frameRate: { numerator: 30, denominator: 1 },
@@ -304,7 +304,7 @@ test("self-blur is two explicit samples of one Resource and collection keeps one
const track = projectVisualTrack(space, finalizeVisualTrack(appendProgramVisualClip(
createVisualTrackSet(), header, semantic, layers, frame, clipSpec(),
), header, space));
- const document = compileHyperframesDocument(sealComposition({
+ const document = compileHtmlProgram(sealComposition({
id: "media",
canvas: { width: 1080, height: 1920, clearColor: "#000000" },
tracks: [track],
@@ -574,7 +574,7 @@ test("transparent, Paint, self-blur and alternate-source backing are only ordere
const track = projectVisualTrack(space, finalizeVisualTrack(appendProgramVisualClip(
createVisualTrackSet(), header, semantic, layers, frame, clipSpec(),
), header, space));
- const document = compileHyperframesDocument(sealComposition({
+ const document = compileHtmlProgram(sealComposition({
id: "layer-matrix", canvas: { width: 1080, height: 1920, clearColor: "#000000" }, tracks: [track],
}), space);
assert.deepEqual(track.presents[0]!.elements.filter((element) => element.kind === "image").map((element) => element.id),
@@ -647,10 +647,10 @@ test("the Visual author Surface emits explicit graph edges for layers, absolute
const node = (name: string, attributes: Record<string, MarkupAttributeValue>, children: StructuredNode[] = []): StructuredElement => ({
kind: "element", name, attributes, children, range,
});
- const appearance = (path: string, properties: SvsRecipe["properties"]): SurfaceResolvedReference => ({
+ const appearance = (path: string, properties: Recipe["properties"]): SurfaceResolvedReference => ({
path,
ref: { kind: "record", id: path },
- type: svsRecipeType,
+ type: recipeType,
record: { value: { kind: "inline", value: { path, properties } } } as never,
});
const plain = (path: string, type: SurfaceResolvedReference["type"]): SurfaceResolvedReference => ({
@@ -661,7 +661,7 @@ test("the Visual author Surface emits explicit graph edges for layers, absolute
["frame", plain("frame", spatialTypes.frame)],
["mapping", plain("mapping", spatialTypes.map2D)],
["clip-path", plain("clip-path", spatialTypes.path)],
- ["still", plain("still", artifactTypes.blob)],
+ ["still", plain("still", blobTypes.blob)],
["extent", plain("extent", spatialTypes.extent)],
["video", plain("video", mediaTypes.synchronized)],
["surface", plain("surface", mediaTypes.compositableSurface)],
@@ -712,7 +712,7 @@ test("the Visual author Surface emits explicit graph edges for layers, absolute
assert.equal(result.fragments.some((candidate) => candidate.operations.some((operation) =>
operation.producer.module.name === "@hypit/narrative-temporal")), false);
assert.equal(producers.some((name) => name.includes("sound") || name.includes("audio")), false);
- assert.ok(fragment.inputs.some((entry) => entry.type.name === artifactTypes.blob.name));
+ assert.ok(fragment.inputs.some((entry) => entry.type.name === blobTypes.blob.name));
assert.ok(fragment.inputs.some((entry) => entry.type.name === mediaTypes.synchronized.name));
assert.ok(fragment.inputs.some((entry) => entry.type.name === spatialTypes.path.name));
const clipSpecs = result.records.filter((entry) => entry.type.name === "VisualClipSpec");