@escapeaihq/client-core 0.12.0 → 0.49.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -7
- package/dist/adapters/capabilities.d.ts +10 -0
- package/dist/adapters/capabilities.d.ts.map +1 -0
- package/dist/adapters/capabilities.js +2 -0
- package/dist/adapters/capabilities.js.map +1 -0
- package/dist/adapters/chatAdapter.d.ts +38 -0
- package/dist/adapters/chatAdapter.d.ts.map +1 -0
- package/dist/adapters/chatAdapter.js +88 -0
- package/dist/adapters/chatAdapter.js.map +1 -0
- package/dist/adapters/directorAdapter.d.ts +62 -0
- package/dist/adapters/directorAdapter.d.ts.map +1 -0
- package/dist/adapters/directorAdapter.js +71 -0
- package/dist/adapters/directorAdapter.js.map +1 -0
- package/dist/adapters/imageAdapter.d.ts +44 -0
- package/dist/adapters/imageAdapter.d.ts.map +1 -0
- package/dist/adapters/imageAdapter.js +73 -0
- package/dist/adapters/imageAdapter.js.map +1 -0
- package/dist/adapters/index.d.ts +47 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/index.js +41 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/adapters/registry.d.ts +98 -0
- package/dist/adapters/registry.d.ts.map +1 -0
- package/dist/adapters/registry.js +106 -0
- package/dist/adapters/registry.js.map +1 -0
- package/dist/adapters/worldAdapter.d.ts +142 -0
- package/dist/adapters/worldAdapter.d.ts.map +1 -0
- package/dist/adapters/worldAdapter.js +164 -0
- package/dist/adapters/worldAdapter.js.map +1 -0
- package/dist/admin.d.ts +323 -0
- package/dist/admin.d.ts.map +1 -0
- package/dist/admin.js +198 -0
- package/dist/admin.js.map +1 -0
- package/dist/api.d.ts +1512 -4
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +820 -52
- package/dist/api.js.map +1 -1
- package/dist/audio.d.ts +33 -1
- package/dist/audio.d.ts.map +1 -1
- package/dist/audio.js +4 -1
- package/dist/audio.js.map +1 -1
- package/dist/castProjection.d.ts +35 -0
- package/dist/castProjection.d.ts.map +1 -0
- package/dist/castProjection.js +80 -0
- package/dist/castProjection.js.map +1 -0
- package/dist/conversation/binding.d.ts +77 -0
- package/dist/conversation/binding.d.ts.map +1 -0
- package/dist/conversation/binding.js +57 -0
- package/dist/conversation/binding.js.map +1 -0
- package/dist/conversation/controller.d.ts +209 -0
- package/dist/conversation/controller.d.ts.map +1 -0
- package/dist/conversation/controller.js +350 -0
- package/dist/conversation/controller.js.map +1 -0
- package/dist/conversation/effectiveModel.d.ts +62 -0
- package/dist/conversation/effectiveModel.d.ts.map +1 -0
- package/dist/conversation/effectiveModel.js +73 -0
- package/dist/conversation/effectiveModel.js.map +1 -0
- package/dist/conversation/index.d.ts +27 -0
- package/dist/conversation/index.d.ts.map +1 -0
- package/dist/conversation/index.js +27 -0
- package/dist/conversation/index.js.map +1 -0
- package/dist/conversation/participant.d.ts +66 -0
- package/dist/conversation/participant.d.ts.map +1 -0
- package/dist/conversation/participant.js +36 -0
- package/dist/conversation/participant.js.map +1 -0
- package/dist/conversation/presence.d.ts +56 -0
- package/dist/conversation/presence.d.ts.map +1 -0
- package/dist/conversation/presence.js +34 -0
- package/dist/conversation/presence.js.map +1 -0
- package/dist/conversation/presenceBus.d.ts +42 -0
- package/dist/conversation/presenceBus.d.ts.map +1 -0
- package/dist/conversation/presenceBus.js +81 -0
- package/dist/conversation/presenceBus.js.map +1 -0
- package/dist/conversation/presenceRegistry.d.ts +49 -0
- package/dist/conversation/presenceRegistry.d.ts.map +1 -0
- package/dist/conversation/presenceRegistry.js +59 -0
- package/dist/conversation/presenceRegistry.js.map +1 -0
- package/dist/conversation/roster.d.ts +72 -0
- package/dist/conversation/roster.d.ts.map +1 -0
- package/dist/conversation/roster.js +69 -0
- package/dist/conversation/roster.js.map +1 -0
- package/dist/conversation/rosterProjection.d.ts +52 -0
- package/dist/conversation/rosterProjection.d.ts.map +1 -0
- package/dist/conversation/rosterProjection.js +74 -0
- package/dist/conversation/rosterProjection.js.map +1 -0
- package/dist/conversation/router.d.ts +74 -0
- package/dist/conversation/router.d.ts.map +1 -0
- package/dist/conversation/router.js +58 -0
- package/dist/conversation/router.js.map +1 -0
- package/dist/conversation/runtime.d.ts +64 -0
- package/dist/conversation/runtime.d.ts.map +1 -0
- package/dist/conversation/runtime.js +172 -0
- package/dist/conversation/runtime.js.map +1 -0
- package/dist/conversation/types.d.ts +99 -0
- package/dist/conversation/types.d.ts.map +1 -0
- package/dist/conversation/types.js +13 -0
- package/dist/conversation/types.js.map +1 -0
- package/dist/conversation/voice.d.ts +185 -0
- package/dist/conversation/voice.d.ts.map +1 -0
- package/dist/conversation/voice.js +307 -0
- package/dist/conversation/voice.js.map +1 -0
- package/dist/graphSchema.d.ts +201 -13
- package/dist/graphSchema.d.ts.map +1 -1
- package/dist/graphSchema.js +258 -9
- package/dist/graphSchema.js.map +1 -1
- package/dist/http.d.ts +20 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +57 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -1
- package/dist/platformAssistant.d.ts +155 -0
- package/dist/platformAssistant.d.ts.map +1 -0
- package/dist/platformAssistant.js +256 -0
- package/dist/platformAssistant.js.map +1 -0
- package/dist/reactor/chunkDistribution.d.ts +43 -0
- package/dist/reactor/chunkDistribution.d.ts.map +1 -0
- package/dist/reactor/chunkDistribution.js +85 -0
- package/dist/reactor/chunkDistribution.js.map +1 -0
- package/dist/reactor/index.d.ts +2 -0
- package/dist/reactor/index.d.ts.map +1 -1
- package/dist/reactor/index.js +5 -0
- package/dist/reactor/index.js.map +1 -1
- package/dist/reactor/longLiveCommandDispatcher.d.ts +103 -0
- package/dist/reactor/longLiveCommandDispatcher.d.ts.map +1 -0
- package/dist/reactor/longLiveCommandDispatcher.js +87 -0
- package/dist/reactor/longLiveCommandDispatcher.js.map +1 -0
- package/dist/reactor/scenesFromEnrichment.d.ts.map +1 -1
- package/dist/reactor/scenesFromEnrichment.js +2 -66
- package/dist/reactor/scenesFromEnrichment.js.map +1 -1
- package/dist/reactor/seedImageOrchestrator.d.ts +6 -9
- package/dist/reactor/seedImageOrchestrator.d.ts.map +1 -1
- package/dist/reactor/seedImageOrchestrator.js +12 -13
- package/dist/reactor/seedImageOrchestrator.js.map +1 -1
- package/dist/reactor/storyTimeline.d.ts +44 -0
- package/dist/reactor/storyTimeline.d.ts.map +1 -0
- package/dist/reactor/storyTimeline.js +95 -0
- package/dist/reactor/storyTimeline.js.map +1 -0
- package/dist/storyGraph.d.ts +70 -0
- package/dist/storyGraph.d.ts.map +1 -0
- package/dist/storyGraph.js +178 -0
- package/dist/storyGraph.js.map +1 -0
- package/dist/vision/VisionSourceController.d.ts +127 -0
- package/dist/vision/VisionSourceController.d.ts.map +1 -0
- package/dist/vision/VisionSourceController.js +284 -0
- package/dist/vision/VisionSourceController.js.map +1 -0
- package/dist/vision/index.d.ts +4 -0
- package/dist/vision/index.d.ts.map +1 -1
- package/dist/vision/index.js +2 -0
- package/dist/vision/index.js.map +1 -1
- package/dist/vision/sourceKinds.d.ts +65 -0
- package/dist/vision/sourceKinds.d.ts.map +1 -0
- package/dist/vision/sourceKinds.js +26 -0
- package/dist/vision/sourceKinds.js.map +1 -0
- package/dist/websocket.d.ts +92 -0
- package/dist/websocket.d.ts.map +1 -1
- package/dist/websocket.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/adapters-capabilities.test.ts +46 -0
- package/src/__tests__/adapters-chat.test.ts +172 -0
- package/src/__tests__/adapters-director.test.ts +95 -0
- package/src/__tests__/adapters-image.test.ts +133 -0
- package/src/__tests__/adapters-platform.test.ts +95 -0
- package/src/__tests__/adapters-registry.test.ts +189 -0
- package/src/__tests__/adapters-world.test.ts +296 -0
- package/src/__tests__/admin.test.ts +312 -0
- package/src/__tests__/adventures-party.test.ts +219 -0
- package/src/__tests__/adventures.test.ts +282 -0
- package/src/__tests__/api-pollers.test.ts +4 -0
- package/src/__tests__/api.clip-lookup.test.ts +64 -0
- package/src/__tests__/api.list-images-filters.test.ts +103 -0
- package/src/__tests__/api.test.ts +553 -0
- package/src/__tests__/audio.test.ts +65 -0
- package/src/__tests__/cast.test.ts +95 -0
- package/src/__tests__/castProjection.test.ts +167 -0
- package/src/__tests__/conversation/binding.test.ts +62 -0
- package/src/__tests__/conversation/controller.test.ts +732 -0
- package/src/__tests__/conversation/effectiveModel.test.ts +169 -0
- package/src/__tests__/conversation/headlessRenderer.ts +46 -0
- package/src/__tests__/conversation/presenceBus.test.ts +236 -0
- package/src/__tests__/conversation/presenceRegistry.test.ts +73 -0
- package/src/__tests__/conversation/roster.test.ts +100 -0
- package/src/__tests__/conversation/rosterProjection.test.ts +142 -0
- package/src/__tests__/conversation/router.test.ts +81 -0
- package/src/__tests__/conversation/runtime.test.ts +206 -0
- package/src/__tests__/conversation/voice.test.ts +440 -0
- package/src/__tests__/documents.test.ts +360 -0
- package/src/__tests__/graphSchema.test.ts +218 -9
- package/src/__tests__/longLiveCommandDispatcher.test.ts +185 -0
- package/src/__tests__/monitoring.test.ts +162 -0
- package/src/__tests__/persona-generation.test.ts +352 -0
- package/src/__tests__/platformAssistant.test.ts +484 -0
- package/src/__tests__/reactor/storyTimeline.test.ts +186 -0
- package/src/__tests__/regeneration.test.ts +486 -0
- package/src/__tests__/stories.test.ts +171 -0
- package/src/__tests__/storyGraph.test.ts +134 -0
- package/src/__tests__/tools-wrappers.test.ts +272 -0
- package/src/__tests__/videoGraph.test.ts +94 -0
- package/src/__tests__/websocket.test.ts +263 -0
- package/src/adapters/capabilities.ts +24 -0
- package/src/adapters/chatAdapter.ts +114 -0
- package/src/adapters/directorAdapter.ts +126 -0
- package/src/adapters/imageAdapter.ts +100 -0
- package/src/adapters/index.ts +67 -0
- package/src/adapters/registry.ts +159 -0
- package/src/adapters/worldAdapter.ts +272 -0
- package/src/admin.ts +517 -0
- package/src/api.ts +2215 -95
- package/src/audio.ts +35 -0
- package/src/castProjection.ts +95 -0
- package/src/conversation/binding.ts +100 -0
- package/src/conversation/controller.ts +447 -0
- package/src/conversation/effectiveModel.ts +111 -0
- package/src/conversation/index.ts +27 -0
- package/src/conversation/participant.ts +71 -0
- package/src/conversation/presence.ts +60 -0
- package/src/conversation/presenceBus.ts +109 -0
- package/src/conversation/presenceRegistry.ts +83 -0
- package/src/conversation/roster.ts +111 -0
- package/src/conversation/rosterProjection.ts +98 -0
- package/src/conversation/router.ts +96 -0
- package/src/conversation/runtime.ts +188 -0
- package/src/conversation/types.ts +100 -0
- package/src/conversation/voice.ts +402 -0
- package/src/graphSchema.ts +396 -13
- package/src/http.ts +72 -0
- package/src/index.ts +9 -0
- package/src/platformAssistant.ts +347 -0
- package/src/reactor/chunkDistribution.ts +98 -0
- package/src/reactor/index.ts +5 -0
- package/src/reactor/longLiveCommandDispatcher.ts +156 -0
- package/src/reactor/scenesFromEnrichment.ts +11 -76
- package/src/reactor/seedImageOrchestrator.ts +12 -13
- package/src/reactor/storyTimeline.ts +127 -0
- package/src/storyGraph.ts +298 -0
- package/src/vision/VisionSourceController.ts +354 -0
- package/src/vision/__tests__/VisionSourceController.test.ts +719 -0
- package/src/vision/index.ts +13 -0
- package/src/vision/sourceKinds.ts +75 -0
- package/src/websocket.ts +99 -3
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { STUDIO_NODE_LABELS, STUDIO_EDGE_TYPES, STUDIO_NODE_PROPERTIES, STUDIO_CHARACTER_TYPE, } from './graphSchema.js';
|
|
2
|
+
// ---------- property readers (constant-driven, no literals) ----------
|
|
3
|
+
function str(node, key) {
|
|
4
|
+
const v = node.properties[key];
|
|
5
|
+
return typeof v === 'string' ? v : null;
|
|
6
|
+
}
|
|
7
|
+
function num(node, key) {
|
|
8
|
+
const v = node.properties[key];
|
|
9
|
+
if (typeof v === 'number')
|
|
10
|
+
return v;
|
|
11
|
+
if (typeof v === 'string' && v.trim() !== '' && Number.isFinite(Number(v))) {
|
|
12
|
+
return Number(v);
|
|
13
|
+
}
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
function strList(node, key) {
|
|
17
|
+
const v = node.properties[key];
|
|
18
|
+
return Array.isArray(v) ? v.filter((x) => typeof x === 'string') : [];
|
|
19
|
+
}
|
|
20
|
+
/** First numeric value across `keys` (in order), or null. */
|
|
21
|
+
function numCoalesce(node, keys) {
|
|
22
|
+
for (const key of keys) {
|
|
23
|
+
const v = num(node, key);
|
|
24
|
+
if (v !== null)
|
|
25
|
+
return v;
|
|
26
|
+
}
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
function isCharacter(node) {
|
|
30
|
+
return (node.label === STUDIO_NODE_LABELS.ENTITY &&
|
|
31
|
+
str(node, STUDIO_NODE_PROPERTIES.ENTITY_TYPE) === STUDIO_CHARACTER_TYPE);
|
|
32
|
+
}
|
|
33
|
+
function isLocation(node) {
|
|
34
|
+
// A location entity is any non-character Entity reached by a SET_IN edge; we
|
|
35
|
+
// do not over-constrain on the exact `type` value (location vs place) — the
|
|
36
|
+
// SET_IN edge is the authoritative signal.
|
|
37
|
+
return node.label === STUDIO_NODE_LABELS.ENTITY && !isCharacter(node);
|
|
38
|
+
}
|
|
39
|
+
function businessIdOf(node, key) {
|
|
40
|
+
return str(node, key) ?? node.id;
|
|
41
|
+
}
|
|
42
|
+
function indexGraph(graph) {
|
|
43
|
+
const byId = new Map();
|
|
44
|
+
for (const node of graph.nodes)
|
|
45
|
+
byId.set(node.id, node);
|
|
46
|
+
return { byId, edges: graph.edges };
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* For a node id and a set of edge types, return the OTHER endpoint nodes of
|
|
50
|
+
* every matching edge, regardless of which side `nodeId` sits on.
|
|
51
|
+
*/
|
|
52
|
+
function neighbours(index, nodeId, edgeTypes) {
|
|
53
|
+
const types = new Set(edgeTypes);
|
|
54
|
+
const out = [];
|
|
55
|
+
const seen = new Set();
|
|
56
|
+
for (const edge of index.edges) {
|
|
57
|
+
if (!types.has(edge.type))
|
|
58
|
+
continue;
|
|
59
|
+
let otherId = null;
|
|
60
|
+
if (edge.source === nodeId)
|
|
61
|
+
otherId = edge.target;
|
|
62
|
+
else if (edge.target === nodeId)
|
|
63
|
+
otherId = edge.source;
|
|
64
|
+
if (otherId === null || seen.has(otherId))
|
|
65
|
+
continue;
|
|
66
|
+
const other = index.byId.get(otherId);
|
|
67
|
+
if (other) {
|
|
68
|
+
seen.add(otherId);
|
|
69
|
+
out.push(other);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return out;
|
|
73
|
+
}
|
|
74
|
+
/** Act→Scene and Scene→Shot containment is CONTAINS or INCLUDES. */
|
|
75
|
+
const CONTAINMENT_EDGES = [STUDIO_EDGE_TYPES.CONTAINS, STUDIO_EDGE_TYPES.INCLUDES];
|
|
76
|
+
// ---------- scene derivation ----------
|
|
77
|
+
export function deriveScenes(graph) {
|
|
78
|
+
const index = indexGraph(graph);
|
|
79
|
+
const P = STUDIO_NODE_PROPERTIES;
|
|
80
|
+
const sceneNodes = graph.nodes.filter((n) => n.label === STUDIO_NODE_LABELS.SCENE);
|
|
81
|
+
const scenes = sceneNodes.map((scene) => {
|
|
82
|
+
// Parent act (containment edge whose other endpoint is an Act node).
|
|
83
|
+
const actNode = neighbours(index, scene.id, CONTAINMENT_EDGES).find((n) => n.label === STUDIO_NODE_LABELS.ACT) ?? null;
|
|
84
|
+
// Shots in this scene (containment edges to Shot nodes), sorted by index.
|
|
85
|
+
const shots = neighbours(index, scene.id, CONTAINMENT_EDGES)
|
|
86
|
+
.filter((n) => n.label === STUDIO_NODE_LABELS.SHOT)
|
|
87
|
+
.map((sh) => ({
|
|
88
|
+
shotId: businessIdOf(sh, P.SHOT_ID),
|
|
89
|
+
caption: str(sh, P.CAPTION) ?? '',
|
|
90
|
+
index: num(sh, P.INDEX) ?? 0,
|
|
91
|
+
startTime: num(sh, P.START_TIME),
|
|
92
|
+
endTime: num(sh, P.END_TIME),
|
|
93
|
+
}))
|
|
94
|
+
.sort((a, b) => a.index - b.index);
|
|
95
|
+
// Featured characters (FEATURES edges to character entities).
|
|
96
|
+
const featuredCharacters = neighbours(index, scene.id, [
|
|
97
|
+
STUDIO_EDGE_TYPES.FEATURES,
|
|
98
|
+
])
|
|
99
|
+
.filter(isCharacter)
|
|
100
|
+
.map((c) => ({
|
|
101
|
+
nodeId: c.id,
|
|
102
|
+
entityId: businessIdOf(c, P.ENTITY_ID),
|
|
103
|
+
name: str(c, P.NAME) ?? businessIdOf(c, P.ENTITY_ID),
|
|
104
|
+
}))
|
|
105
|
+
.sort((a, b) => a.name.localeCompare(b.name));
|
|
106
|
+
// Location (SET_IN edge to a non-character entity).
|
|
107
|
+
const locNode = neighbours(index, scene.id, [STUDIO_EDGE_TYPES.SET_IN]).find(isLocation);
|
|
108
|
+
const location = locNode
|
|
109
|
+
? {
|
|
110
|
+
nodeId: locNode.id,
|
|
111
|
+
entityId: businessIdOf(locNode, P.ENTITY_ID),
|
|
112
|
+
name: str(locNode, P.NAME) ?? businessIdOf(locNode, P.ENTITY_ID),
|
|
113
|
+
}
|
|
114
|
+
: null;
|
|
115
|
+
return {
|
|
116
|
+
nodeId: scene.id,
|
|
117
|
+
sceneId: businessIdOf(scene, P.SCENE_ID),
|
|
118
|
+
title: str(scene, P.TITLE) ?? businessIdOf(scene, P.SCENE_ID),
|
|
119
|
+
index: num(scene, P.INDEX) ?? 0,
|
|
120
|
+
// Scene nodes store their time bounds as t0/t1 (MERGE_SCENE — the
|
|
121
|
+
// get_video_graph `detail=story` reader annotates `t0`/`t1`, NOT
|
|
122
|
+
// start/endTime; Shots use start/endTime). Read t0/t1 first, falling back
|
|
123
|
+
// to start/endTime defensively. Without this, every production SceneView
|
|
124
|
+
// had null times and deriveStoryTimeline (R8.1) lost proportional chunk
|
|
125
|
+
// placement (codex R8.1 P2).
|
|
126
|
+
startTime: numCoalesce(scene, [P.T0, P.START_TIME]),
|
|
127
|
+
endTime: numCoalesce(scene, [P.T1, P.END_TIME]),
|
|
128
|
+
summary: str(scene, P.SUMMARY),
|
|
129
|
+
actNodeId: actNode?.id ?? null,
|
|
130
|
+
actTitle: actNode ? str(actNode, P.TITLE) : null,
|
|
131
|
+
actIndex: actNode ? (num(actNode, P.INDEX) ?? 0) : Number.MAX_SAFE_INTEGER,
|
|
132
|
+
featuredCharacters,
|
|
133
|
+
location,
|
|
134
|
+
shots,
|
|
135
|
+
};
|
|
136
|
+
});
|
|
137
|
+
// Sort by act.index, then scene.index. Scenes with no act sort last.
|
|
138
|
+
scenes.sort((a, b) => a.actIndex - b.actIndex || a.index - b.index);
|
|
139
|
+
return scenes;
|
|
140
|
+
}
|
|
141
|
+
// ---------- cast derivation ----------
|
|
142
|
+
export function deriveCast(graph) {
|
|
143
|
+
const index = indexGraph(graph);
|
|
144
|
+
const P = STUDIO_NODE_PROPERTIES;
|
|
145
|
+
const characterNodes = graph.nodes.filter(isCharacter);
|
|
146
|
+
const cast = characterNodes.map((char) => {
|
|
147
|
+
// Scenes this character is featured in (FEATURES edges to Scene nodes).
|
|
148
|
+
const sceneIds = neighbours(index, char.id, [STUDIO_EDGE_TYPES.FEATURES])
|
|
149
|
+
.filter((n) => n.label === STUDIO_NODE_LABELS.SCENE)
|
|
150
|
+
.map((s) => businessIdOf(s, P.SCENE_ID));
|
|
151
|
+
// Character arcs (ON_ARC edges to CharacterArc nodes), sorted by index.
|
|
152
|
+
const arcs = neighbours(index, char.id, [STUDIO_EDGE_TYPES.ON_ARC])
|
|
153
|
+
.filter((n) => n.label === STUDIO_NODE_LABELS.CHARACTER_ARC)
|
|
154
|
+
.map((a) => ({
|
|
155
|
+
arcId: businessIdOf(a, P.ARC_ID),
|
|
156
|
+
title: str(a, P.TITLE) ?? businessIdOf(a, P.ARC_ID),
|
|
157
|
+
description: str(a, P.DESCRIPTION) ?? str(a, P.SUMMARY),
|
|
158
|
+
index: num(a, P.INDEX) ?? 0,
|
|
159
|
+
}))
|
|
160
|
+
.sort((x, y) => x.index - y.index);
|
|
161
|
+
// Related characters (RELATES_TO edges to other character entities).
|
|
162
|
+
const relatedCharacterIds = neighbours(index, char.id, [STUDIO_EDGE_TYPES.RELATES_TO])
|
|
163
|
+
.filter(isCharacter)
|
|
164
|
+
.map((c) => businessIdOf(c, P.ENTITY_ID));
|
|
165
|
+
return {
|
|
166
|
+
nodeId: char.id,
|
|
167
|
+
entityId: businessIdOf(char, P.ENTITY_ID),
|
|
168
|
+
name: str(char, P.NAME) ?? businessIdOf(char, P.ENTITY_ID),
|
|
169
|
+
aliases: strList(char, P.ALIASES),
|
|
170
|
+
sceneIds,
|
|
171
|
+
arcs,
|
|
172
|
+
relatedCharacterIds,
|
|
173
|
+
};
|
|
174
|
+
});
|
|
175
|
+
cast.sort((a, b) => a.name.localeCompare(b.name));
|
|
176
|
+
return cast;
|
|
177
|
+
}
|
|
178
|
+
//# sourceMappingURL=storyGraph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storyGraph.js","sourceRoot":"","sources":["../src/storyGraph.ts"],"names":[],"mappings":"AAoBA,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,eAAe,CAAC;AA+DvB,wEAAwE;AAExE,SAAS,GAAG,CAAC,IAAe,EAAE,GAAW;IACvC,MAAM,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IAC/B,OAAO,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAC1C,CAAC;AAED,SAAS,GAAG,CAAC,IAAe,EAAE,GAAW;IACvC,MAAM,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IAC/B,IAAI,OAAO,CAAC,KAAK,QAAQ;QAAE,OAAO,CAAC,CAAC;IACpC,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,IA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source into a published vision feed".
|
|
4
|
+
*
|
|
5
|
+
* R3a of the Platform Experience Restructure
|
|
6
|
+
* (`specs/platform-experience-restructure-phase-R3-vision-source-picker.md`).
|
|
7
|
+
*
|
|
8
|
+
* Today the two React call sites duplicate the same
|
|
9
|
+
* acquire→credentials→publish→teardown sequence and differ only in how the
|
|
10
|
+
* track is obtained (the fork `startVisionPublisher`'s header already calls
|
|
11
|
+
* out): the chat-ws page hardcodes `getUserMedia({ video: true })` and the
|
|
12
|
+
* watch hook hardcodes `<video>.captureStream()`. This controller owns the
|
|
13
|
+
* acquisition switch (webcam / playing-video / server-render) plus the full
|
|
14
|
+
* publisher lifecycle, and DELEGATES the publisher wiring to the existing
|
|
15
|
+
* `startVisionPublisher` helper — it does not duplicate it.
|
|
16
|
+
*
|
|
17
|
+
* Error discipline (matches the lifted call sites + this module's
|
|
18
|
+
* callbacks-not-throws convention): environmental/acquisition failures
|
|
19
|
+
* (no getUserMedia support, permission denied, captureStream unsupported,
|
|
20
|
+
* no video track, credential fetch failure) are reported via `onError` and
|
|
21
|
+
* `start()` RESOLVES with the controller back in the idle, restartable
|
|
22
|
+
* state. Programmer misuse (`start()` while a source is active or starting)
|
|
23
|
+
* THROWS fail-loud — use `switchSource()` to change sources.
|
|
24
|
+
*
|
|
25
|
+
* Zero React/DOM-query imports: descriptors carry any DOM element in, so a
|
|
26
|
+
* React hook (R3b) drives it today and a game-engine surface can later.
|
|
27
|
+
* Cross-device vision relay stays deferred — every source is local and the
|
|
28
|
+
* feed publishes over the caller's own authenticated `ChatWebSocket`
|
|
29
|
+
* exactly as today.
|
|
30
|
+
*/
|
|
31
|
+
import type { ApiClient } from '../api';
|
|
32
|
+
import type { ChatWebSocket } from '../websocket';
|
|
33
|
+
import type { VisionStatus } from './types';
|
|
34
|
+
import type { VisionSourceDescriptor, VisionSourceKind } from './sourceKinds';
|
|
35
|
+
/**
|
|
36
|
+
* The slice of `ApiClient` the controller needs (structural — a full
|
|
37
|
+
* `ApiClient` satisfies it; tests can pass a one-method stub).
|
|
38
|
+
*/
|
|
39
|
+
export type VisionCredentialsClient = Pick<ApiClient, 'getVisionRtcCredentials'>;
|
|
40
|
+
export interface VisionSourceControllerOptions {
|
|
41
|
+
/**
|
|
42
|
+
* The SAME authenticated `ChatWebSocket` the user's chat turns use —
|
|
43
|
+
* vision frames are keyed to the WS session ID server-side, so a fresh
|
|
44
|
+
* socket would land in a different `FrameBuffer`. Callers must keep this
|
|
45
|
+
* reference stable for the controller's lifetime (the identity-stability
|
|
46
|
+
* requirement lifted from the watch hook).
|
|
47
|
+
*/
|
|
48
|
+
ws: ChatWebSocket;
|
|
49
|
+
/** Mints vision-signaling credentials via
|
|
50
|
+
* `POST /api/v1/chat/vision-rtc/credentials`. */
|
|
51
|
+
apiClient: VisionCredentialsClient;
|
|
52
|
+
/** Frames-per-second cadence; clamped server-side to 0.5–3.0 fps. */
|
|
53
|
+
fps: number;
|
|
54
|
+
/** Publisher telemetry (drives the HUD line). */
|
|
55
|
+
onStatus?: (status: VisionStatus) => void;
|
|
56
|
+
/** Environmental/acquisition failures AND asynchronous publisher errors. */
|
|
57
|
+
onError?: (error: Error) => void;
|
|
58
|
+
/** Fired when `currentKind` changes: the new kind after a successful
|
|
59
|
+
* `start`, and `null` when an active source is stopped. */
|
|
60
|
+
onSourceChange?: (kind: VisionSourceKind | null) => void;
|
|
61
|
+
}
|
|
62
|
+
export declare class VisionSourceController {
|
|
63
|
+
private readonly ws;
|
|
64
|
+
private readonly apiClient;
|
|
65
|
+
private readonly fps;
|
|
66
|
+
private readonly onStatus?;
|
|
67
|
+
private readonly onError?;
|
|
68
|
+
private readonly onSourceChange?;
|
|
69
|
+
/** Bumped by every `stop()`; in-flight `start()` work compares its
|
|
70
|
+
* captured epoch after each await and bails (releasing anything it
|
|
71
|
+
* acquired) when stale. */
|
|
72
|
+
private epoch;
|
|
73
|
+
private phase;
|
|
74
|
+
private kind;
|
|
75
|
+
private stream;
|
|
76
|
+
private handle;
|
|
77
|
+
/** Cancels a pending waitForFrame `loadeddata` listener. */
|
|
78
|
+
private cancelWaitForFrame;
|
|
79
|
+
constructor(opts: VisionSourceControllerOptions);
|
|
80
|
+
/** The currently-published source kind, or `null` when idle/starting. */
|
|
81
|
+
get currentKind(): VisionSourceKind | null;
|
|
82
|
+
/** True while a `start()` is in flight (acquisition / first-frame gate /
|
|
83
|
+
* credentials). Lets a UI adapter render a loading state without
|
|
84
|
+
* probing the lifecycle. */
|
|
85
|
+
get isStarting(): boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Acquire the descriptor's track, mint credentials, and start publishing.
|
|
88
|
+
*
|
|
89
|
+
* Resolves when the publisher is started OR the attempt failed (failure
|
|
90
|
+
* reported via `onError`; controller back in the restartable idle state)
|
|
91
|
+
* OR a concurrent `stop()`/`switchSource()` cancelled it. Throws only on
|
|
92
|
+
* misuse: calling `start()` while a source is already active or starting.
|
|
93
|
+
*/
|
|
94
|
+
start(descriptor: VisionSourceDescriptor): Promise<void>;
|
|
95
|
+
/**
|
|
96
|
+
* Stop the current source (publisher + every acquired track), then start
|
|
97
|
+
* the new one. The teardown completes synchronously BEFORE the next
|
|
98
|
+
* acquisition begins, so e.g. the webcam light is off before the video
|
|
99
|
+
* capture starts. This is the net-new capability the hardwired call
|
|
100
|
+
* sites couldn't do.
|
|
101
|
+
*
|
|
102
|
+
* Single-caller by design: the phase passes through `idle` between the
|
|
103
|
+
* stop and the start, so a concurrent `start()` issued in that window
|
|
104
|
+
* would win and make this call's deferred `start()` throw. The React
|
|
105
|
+
* adapter (R3b) holds the controller on a `useRef` and serializes calls
|
|
106
|
+
* through one effect, which guarantees a single caller.
|
|
107
|
+
*/
|
|
108
|
+
switchSource(descriptor: VisionSourceDescriptor): Promise<void>;
|
|
109
|
+
/**
|
|
110
|
+
* Idempotent teardown: stops the publisher (via its handle), stops every
|
|
111
|
+
* acquired `MediaStreamTrack` (camera light off; no leaked captureStream
|
|
112
|
+
* tracks), cancels any pending first-frame gate, and aborts any in-flight
|
|
113
|
+
* `start()`.
|
|
114
|
+
*/
|
|
115
|
+
stop(): void;
|
|
116
|
+
/** Report a failed start attempt and return to idle (unless a stop()
|
|
117
|
+
* superseded this attempt — then the user cancelled, not an error). */
|
|
118
|
+
private failStart;
|
|
119
|
+
/** Per-kind track acquisition. Throws environmental errors; the caller
|
|
120
|
+
* routes them through `failStart`. */
|
|
121
|
+
private acquire;
|
|
122
|
+
/** Resolve once the `<video>` has decoded its first frame (or
|
|
123
|
+
* immediately for canvases / already-decoded videos). Cancellable by
|
|
124
|
+
* `stop()` via `cancelWaitForFrame`. */
|
|
125
|
+
private waitForFirstFrame;
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=VisionSourceController.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VisionSourceController.d.ts","sourceRoot":"","sources":["../../src/vision/VisionSourceController.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAoC,MAAM,QAAQ,CAAC;AAC1E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAGlD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,OAAO,KAAK,EAEV,sBAAsB,EACtB,gBAAgB,EACjB,MAAM,eAAe,CAAC;AAEvB;;;GAGG;AACH,MAAM,MAAM,uBAAuB,GAAG,IAAI,CAAC,SAAS,EAAE,yBAAyB,CAAC,CAAC;AAEjF,MAAM,WAAW,6BAA6B;IAC5C;;;;;;OAMG;IACH,EAAE,EAAE,aAAa,CAAC;IAClB;qDACiD;IACjD,SAAS,EAAE,uBAAuB,CAAC;IACnC,qEAAqE;IACrE,GAAG,EAAE,MAAM,CAAC;IACZ,iDAAiD;IACjD,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,CAAC;IAC1C,4EAA4E;IAC5E,OAAO,CAAC,EAA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framework-agnostic vision-SOURCE controller — the single source of truth
|
|
3
|
+
* for "turn a chosen local source into a published vision feed".
|
|
4
|
+
*
|
|
5
|
+
* R3a of the Platform Experience Restructure
|
|
6
|
+
* (`specs/platform-experience-restructure-phase-R3-vision-source-picker.md`).
|
|
7
|
+
*
|
|
8
|
+
* Today the two React call sites duplicate the same
|
|
9
|
+
* acquire→credentials→publish→teardown sequence and differ only in how the
|
|
10
|
+
* track is obtained (the fork `startVisionPublisher`'s header already calls
|
|
11
|
+
* out): the chat-ws page hardcodes `getUserMedia({ video: true })` and the
|
|
12
|
+
* watch hook hardcodes `<video>.captureStream()`. This controller owns the
|
|
13
|
+
* acquisition switch (webcam / playing-video / server-render) plus the full
|
|
14
|
+
* publisher lifecycle, and DELEGATES the publisher wiring to the existing
|
|
15
|
+
* `startVisionPublisher` helper — it does not duplicate it.
|
|
16
|
+
*
|
|
17
|
+
* Error discipline (matches the lifted call sites + this module's
|
|
18
|
+
* callbacks-not-throws convention): environmental/acquisition failures
|
|
19
|
+
* (no getUserMedia support, permission denied, captureStream unsupported,
|
|
20
|
+
* no video track, credential fetch failure) are reported via `onError` and
|
|
21
|
+
* `start()` RESOLVES with the controller back in the idle, restartable
|
|
22
|
+
* state. Programmer misuse (`start()` while a source is active or starting)
|
|
23
|
+
* THROWS fail-loud — use `switchSource()` to change sources.
|
|
24
|
+
*
|
|
25
|
+
* Zero React/DOM-query imports: descriptors carry any DOM element in, so a
|
|
26
|
+
* React hook (R3b) drives it today and a game-engine surface can later.
|
|
27
|
+
* Cross-device vision relay stays deferred — every source is local and the
|
|
28
|
+
* feed publishes over the caller's own authenticated `ChatWebSocket`
|
|
29
|
+
* exactly as today.
|
|
30
|
+
*/
|
|
31
|
+
import { startVisionPublisher } from './startVisionPublisher.js';
|
|
32
|
+
import { VISION_SOURCE_KINDS } from './sourceKinds.js';
|
|
33
|
+
/** First `readyState` where the `<video>` has a real decoded image; tracks
|
|
34
|
+
* pulled before then publish a black buffer (the watch-page guard). */
|
|
35
|
+
const HAVE_CURRENT_DATA = 2;
|
|
36
|
+
const toError = (err) => err instanceof Error ? err : new Error(String(err));
|
|
37
|
+
/**
|
|
38
|
+
* Module-private sentinel thrown to unwind `acquire()` when `stop()`
|
|
39
|
+
* cancels a pending first-frame gate. Handled explicitly in `start()`'s
|
|
40
|
+
* catch — it never reaches `onError` and is never user-visible.
|
|
41
|
+
*/
|
|
42
|
+
class StartCancelledError extends Error {
|
|
43
|
+
constructor() {
|
|
44
|
+
super('vision source start cancelled');
|
|
45
|
+
this.name = 'StartCancelledError';
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/** Duck-typed captureStream lookup — `HTMLVideoElement.captureStream` /
|
|
49
|
+
* `HTMLCanvasElement.captureStream` aren't in all lib.dom versions, so we
|
|
50
|
+
* cast locally rather than widening global types (same pattern as the
|
|
51
|
+
* watch hook this lifts). */
|
|
52
|
+
const captureStreamOf = (element) => {
|
|
53
|
+
const fn = element.captureStream;
|
|
54
|
+
return typeof fn === 'function' ? fn.bind(element) : undefined;
|
|
55
|
+
};
|
|
56
|
+
export class VisionSourceController {
|
|
57
|
+
ws;
|
|
58
|
+
apiClient;
|
|
59
|
+
fps;
|
|
60
|
+
onStatus;
|
|
61
|
+
onError;
|
|
62
|
+
onSourceChange;
|
|
63
|
+
/** Bumped by every `stop()`; in-flight `start()` work compares its
|
|
64
|
+
* captured epoch after each await and bails (releasing anything it
|
|
65
|
+
* acquired) when stale. */
|
|
66
|
+
epoch = 0;
|
|
67
|
+
phase = 'idle';
|
|
68
|
+
kind = null;
|
|
69
|
+
stream = null;
|
|
70
|
+
handle = null;
|
|
71
|
+
/** Cancels a pending waitForFrame `loadeddata` listener. */
|
|
72
|
+
cancelWaitForFrame = null;
|
|
73
|
+
constructor(opts) {
|
|
74
|
+
this.ws = opts.ws;
|
|
75
|
+
this.apiClient = opts.apiClient;
|
|
76
|
+
this.fps = opts.fps;
|
|
77
|
+
this.onStatus = opts.onStatus;
|
|
78
|
+
this.onError = opts.onError;
|
|
79
|
+
this.onSourceChange = opts.onSourceChange;
|
|
80
|
+
}
|
|
81
|
+
/** The currently-published source kind, or `null` when idle/starting. */
|
|
82
|
+
get currentKind() {
|
|
83
|
+
return this.kind;
|
|
84
|
+
}
|
|
85
|
+
/** True while a `start()` is in flight (acquisition / first-frame gate /
|
|
86
|
+
* credentials). Lets a UI adapter render a loading state without
|
|
87
|
+
* probing the lifecycle. */
|
|
88
|
+
get isStarting() {
|
|
89
|
+
return this.phase === 'starting';
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Acquire the descriptor's track, mint credentials, and start publishing.
|
|
93
|
+
*
|
|
94
|
+
* Resolves when the publisher is started OR the attempt failed (failure
|
|
95
|
+
* reported via `onError`; controller back in the restartable idle state)
|
|
96
|
+
* OR a concurrent `stop()`/`switchSource()` cancelled it. Throws only on
|
|
97
|
+
* misuse: calling `start()` while a source is already active or starting.
|
|
98
|
+
*/
|
|
99
|
+
async start(descriptor) {
|
|
100
|
+
if (this.phase !== 'idle') {
|
|
101
|
+
throw new Error(`VisionSourceController.start() called while a source is ${this.phase} — ` +
|
|
102
|
+
'use switchSource() to change sources');
|
|
103
|
+
}
|
|
104
|
+
this.phase = 'starting';
|
|
105
|
+
const epoch = this.epoch;
|
|
106
|
+
// 1. Acquire the source stream (the only step that differs per kind).
|
|
107
|
+
let stream;
|
|
108
|
+
try {
|
|
109
|
+
stream = await this.acquire(descriptor, epoch);
|
|
110
|
+
}
|
|
111
|
+
catch (err) {
|
|
112
|
+
if (err instanceof StartCancelledError)
|
|
113
|
+
return; // deliberate stop — not an error
|
|
114
|
+
this.failStart(epoch, toError(err));
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
if (epoch !== this.epoch) {
|
|
118
|
+
// stop()/switchSource() raced the acquisition — release what we
|
|
119
|
+
// acquired (the camera light must not linger) and bail silently:
|
|
120
|
+
// a deliberate stop is not an error.
|
|
121
|
+
stream.getTracks().forEach((t) => t.stop());
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
const track = stream.getVideoTracks()[0];
|
|
125
|
+
if (!track) {
|
|
126
|
+
// A live MediaStream with no video track: stop its tracks before
|
|
127
|
+
// bailing so we don't leak the capture (lifted verbatim from both
|
|
128
|
+
// call sites).
|
|
129
|
+
stream.getTracks().forEach((t) => t.stop());
|
|
130
|
+
this.failStart(epoch, new Error(descriptor.kind === VISION_SOURCE_KINDS.WEBCAM
|
|
131
|
+
? 'No video track available'
|
|
132
|
+
: 'No video track available from captureStream()'));
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
// Safe to publish the stream onto the instance only now: the no-track
|
|
136
|
+
// check above ran synchronously since acquisition (no await between),
|
|
137
|
+
// so no stop() can have interleaved.
|
|
138
|
+
this.stream = stream;
|
|
139
|
+
// 2. Mint signaling credentials AFTER acquisition succeeds — keeps the
|
|
140
|
+
// AWS round-trip off the cold-toggle path until we can produce frames.
|
|
141
|
+
let credentialsResponse;
|
|
142
|
+
try {
|
|
143
|
+
credentialsResponse = await this.apiClient.getVisionRtcCredentials();
|
|
144
|
+
}
|
|
145
|
+
catch (err) {
|
|
146
|
+
// Release unconditionally — if stop() raced this await it already
|
|
147
|
+
// stopped these tracks via this.stream, and double-stopping a
|
|
148
|
+
// MediaStreamTrack is a spec'd no-op. Either way the camera light
|
|
149
|
+
// goes off.
|
|
150
|
+
stream.getTracks().forEach((t) => t.stop());
|
|
151
|
+
if (epoch === this.epoch)
|
|
152
|
+
this.stream = null;
|
|
153
|
+
this.failStart(epoch, toError(err));
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
if (epoch !== this.epoch) {
|
|
157
|
+
// stop() already released this.stream; double-stopping a track is a
|
|
158
|
+
// spec'd no-op, so release unconditionally for safety.
|
|
159
|
+
stream.getTracks().forEach((t) => t.stop());
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
// 3. Delegate the publisher wiring to the existing helper (DRY — the
|
|
163
|
+
// construct→subscribe→start sequence has exactly one implementation).
|
|
164
|
+
// Defensively wrapped: a synchronous throw here would otherwise leave
|
|
165
|
+
// the phase stuck at 'starting' (non-restartable) with no onError.
|
|
166
|
+
try {
|
|
167
|
+
this.handle = startVisionPublisher({
|
|
168
|
+
ws: this.ws,
|
|
169
|
+
track,
|
|
170
|
+
credentialsResponse,
|
|
171
|
+
fps: this.fps,
|
|
172
|
+
onStatus: this.onStatus,
|
|
173
|
+
onError: this.onError,
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
catch (err) {
|
|
177
|
+
stream.getTracks().forEach((t) => t.stop());
|
|
178
|
+
this.stream = null;
|
|
179
|
+
this.failStart(epoch, toError(err));
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
this.phase = 'active';
|
|
183
|
+
this.kind = descriptor.kind;
|
|
184
|
+
this.onSourceChange?.(descriptor.kind);
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Stop the current source (publisher + every acquired track), then start
|
|
188
|
+
* the new one. The teardown completes synchronously BEFORE the next
|
|
189
|
+
* acquisition begins, so e.g. the webcam light is off before the video
|
|
190
|
+
* capture starts. This is the net-new capability the hardwired call
|
|
191
|
+
* sites couldn't do.
|
|
192
|
+
*
|
|
193
|
+
* Single-caller by design: the phase passes through `idle` between the
|
|
194
|
+
* stop and the start, so a concurrent `start()` issued in that window
|
|
195
|
+
* would win and make this call's deferred `start()` throw. The React
|
|
196
|
+
* adapter (R3b) holds the controller on a `useRef` and serializes calls
|
|
197
|
+
* through one effect, which guarantees a single caller.
|
|
198
|
+
*/
|
|
199
|
+
async switchSource(descriptor) {
|
|
200
|
+
this.stop();
|
|
201
|
+
await this.start(descriptor);
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Idempotent teardown: stops the publisher (via its handle), stops every
|
|
205
|
+
* acquired `MediaStreamTrack` (camera light off; no leaked captureStream
|
|
206
|
+
* tracks), cancels any pending first-frame gate, and aborts any in-flight
|
|
207
|
+
* `start()`.
|
|
208
|
+
*/
|
|
209
|
+
stop() {
|
|
210
|
+
this.epoch += 1;
|
|
211
|
+
this.cancelWaitForFrame?.();
|
|
212
|
+
this.handle?.stop();
|
|
213
|
+
this.handle = null;
|
|
214
|
+
this.stream?.getTracks().forEach((t) => t.stop());
|
|
215
|
+
this.stream = null;
|
|
216
|
+
this.phase = 'idle';
|
|
217
|
+
if (this.kind !== null) {
|
|
218
|
+
this.kind = null;
|
|
219
|
+
this.onSourceChange?.(null);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
// ── Internals ──────────────────────────────────────────────────────────
|
|
223
|
+
/** Report a failed start attempt and return to idle (unless a stop()
|
|
224
|
+
* superseded this attempt — then the user cancelled, not an error). */
|
|
225
|
+
failStart(epoch, error) {
|
|
226
|
+
if (epoch !== this.epoch)
|
|
227
|
+
return;
|
|
228
|
+
this.phase = 'idle';
|
|
229
|
+
this.onError?.(error);
|
|
230
|
+
}
|
|
231
|
+
/** Per-kind track acquisition. Throws environmental errors; the caller
|
|
232
|
+
* routes them through `failStart`. */
|
|
233
|
+
async acquire(descriptor, epoch) {
|
|
234
|
+
if (descriptor.kind === VISION_SOURCE_KINDS.WEBCAM) {
|
|
235
|
+
if (typeof navigator === 'undefined' ||
|
|
236
|
+
!navigator.mediaDevices?.getUserMedia) {
|
|
237
|
+
throw new Error('Browser does not support webcam access');
|
|
238
|
+
}
|
|
239
|
+
return navigator.mediaDevices.getUserMedia(descriptor.constraints ?? { video: true });
|
|
240
|
+
}
|
|
241
|
+
// playing-video / server-render: captureStream() off the supplied
|
|
242
|
+
// element, optionally gated on the first decoded frame for <video>.
|
|
243
|
+
const { element } = descriptor;
|
|
244
|
+
if (descriptor.waitForFrame) {
|
|
245
|
+
await this.waitForFirstFrame(element);
|
|
246
|
+
if (epoch !== this.epoch) {
|
|
247
|
+
// stop() cancelled the gate while we were waiting — unwind out of
|
|
248
|
+
// acquire(); start()'s catch swallows this sentinel explicitly.
|
|
249
|
+
throw new StartCancelledError();
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
const captureStream = captureStreamOf(element);
|
|
253
|
+
if (!captureStream) {
|
|
254
|
+
throw new Error('Browser does not support captureStream()');
|
|
255
|
+
}
|
|
256
|
+
return captureStream();
|
|
257
|
+
}
|
|
258
|
+
/** Resolve once the `<video>` has decoded its first frame (or
|
|
259
|
+
* immediately for canvases / already-decoded videos). Cancellable by
|
|
260
|
+
* `stop()` via `cancelWaitForFrame`. */
|
|
261
|
+
waitForFirstFrame(element) {
|
|
262
|
+
const video = element;
|
|
263
|
+
// Canvas elements have no readyState — capture immediately.
|
|
264
|
+
if (typeof video.readyState !== 'number')
|
|
265
|
+
return Promise.resolve();
|
|
266
|
+
if (video.readyState >= HAVE_CURRENT_DATA)
|
|
267
|
+
return Promise.resolve();
|
|
268
|
+
return new Promise((resolve) => {
|
|
269
|
+
const onReady = () => {
|
|
270
|
+
video.removeEventListener('loadeddata', onReady);
|
|
271
|
+
this.cancelWaitForFrame = null;
|
|
272
|
+
resolve();
|
|
273
|
+
};
|
|
274
|
+
video.addEventListener('loadeddata', onReady);
|
|
275
|
+
this.cancelWaitForFrame = () => {
|
|
276
|
+
video.removeEventListener('loadeddata', onReady);
|
|
277
|
+
this.cancelWaitForFrame = null;
|
|
278
|
+
// Resolve (not reject): the epoch check after the await bails out.
|
|
279
|
+
resolve();
|
|
280
|
+
};
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
//# sourceMappingURL=VisionSourceController.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VisionSourceController.js","sourceRoot":"","sources":["../../src/vision/VisionSourceController.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAIH,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAG9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAoCpD;uEACuE;AACvE,M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AE,CAAC;YAClC,CAAC;QACH,CAAC;QACD,MAAM,aAAa,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;QAC/C,IAAI,CAAC,aAAa,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;QAC9D,CAAC;QACD,OAAO,aAAa,EAAE,CAAC;IACzB,CAAC;IAED;;4CAEwC;IAChC,iBAAiB,CAAC,OAA6B;QACrD,MAAM,KAAK,GAAG,OAA2B,CAAC;QAC1C,4DAA4D;QAC5D,IAAI,OAAO,KAAK,CAAC,UAAU,KAAK,QAAQ;YAAE,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;QACnE,IAAI,KAAK,CAAC,UAAU,IAAI,iBAAiB;YAAE,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;QACpE,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;YACnC,MAAM,OAAO,GAAG,GAAS,EAAE;gBACzB,KAAK,CAAC,mBAAmB,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;gBACjD,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC;gBAC/B,OAAO,EAAE,CAAC;YACZ,CAAC,CAAC;YACF,KAAK,CAAC,gBAAgB,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;YAC9C,IAAI,CAAC,kBAAkB,GAAG,GAAS,EAAE;gBACnC,KAAK,CAAC,mBAAmB,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;gBACjD,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC;gBAC/B,mEAAmE;gBACnE,OAAO,EAAE,CAAC;YACZ,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
|
package/dist/vision/index.d.ts
CHANGED
|
@@ -11,4 +11,8 @@ export type { ComputeNextFpsInput, VisionScheduler, VisionSchedulerOptions, } fr
|
|
|
11
11
|
export { toVisionRtcCredentials } from './credentials';
|
|
12
12
|
export { startVisionPublisher } from './startVisionPublisher';
|
|
13
13
|
export type { StartVisionPublisherOptions, VisionPublisherHandle, } from './startVisionPublisher';
|
|
14
|
+
export { VISION_SOURCE_KINDS } from './sourceKinds';
|
|
15
|
+
export type { ElementSourceDescriptor, VisionCaptureElement, VisionSourceDescriptor, VisionSourceKind, WebcamSourceDescriptor, } from './sourceKinds';
|
|
16
|
+
export { VisionSourceController } from './VisionSourceController';
|
|
17
|
+
export type { VisionCredentialsClient, VisionSourceControllerOptions, } from './VisionSourceController';
|
|
14
18
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vision/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EACL,cAAc,EACd,qBAAqB,GACtB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACV,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,EACpB,YAAY,EACZ,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,SAAS,CAAC;AACjB,YAAY,EACV,mBAAmB,EACnB,eAAe,EACf,sBAAsB,GACvB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,YAAY,EACV,2BAA2B,EAC3B,qBAAqB,GACtB,MAAM,wBAAwB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vision/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EACL,cAAc,EACd,qBAAqB,GACtB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACV,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,EACpB,YAAY,EACZ,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,SAAS,CAAC;AACjB,YAAY,EACV,mBAAmB,EACnB,eAAe,EACf,sBAAsB,GACvB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,YAAY,EACV,2BAA2B,EAC3B,qBAAqB,GACtB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,YAAY,EACV,uBAAuB,EACvB,oBAAoB,EACpB,sBAAsB,EACtB,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,YAAY,EACV,uBAAuB,EACvB,6BAA6B,GAC9B,MAAM,0BAA0B,CAAC"}
|
package/dist/vision/index.js
CHANGED
|
@@ -8,4 +8,6 @@ export { VisionPublisher } from './VisionPublisher.js';
|
|
|
8
8
|
export { computeNextFps, createVisionScheduler, } from './visionScheduler.js';
|
|
9
9
|
export { toVisionRtcCredentials } from './credentials.js';
|
|
10
10
|
export { startVisionPublisher } from './startVisionPublisher.js';
|
|
11
|
+
export { VISION_SOURCE_KINDS } from './sourceKinds.js';
|
|
12
|
+
export { VisionSourceController } from './VisionSourceController.js';
|
|
11
13
|
//# sourceMappingURL=index.js.map
|
package/dist/vision/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/vision/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EACL,cAAc,EACd,qBAAqB,GACtB,MAAM,mBAAmB,CAAC;AAc3B,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/vision/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EACL,cAAc,EACd,qBAAqB,GACtB,MAAM,mBAAmB,CAAC;AAc3B,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAK9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAQpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC"}
|