44 * Loading domain transitions
55 * Handles welcome screen, model loading, and warmup phases
66 *
7- * Actions and guards are bound to StateMachine context, so 'this' refers to the StateMachine instance
7+ * Functions are bound to StateMachine context at initialization,
8+ * so 'this' refers to the StateMachine instance.
9+ * @see state-machine.js defineTransitions() for binding logic
810 */
911
10- /** @type {import('./index').StateTransition[] } */
12+ /**
13+ * @typedef {import('../state-machine.js').StateTransition } StateTransition
14+ */
15+
16+ /** @type {StateTransition[] } */
1117export const loadingTransitions = [
1218 // Welcome flow - normal path with WebGPU
1319 {
1420 event : 'START' ,
1521 from : 'welcome' ,
1622 to : 'permission' ,
23+ /** @this {import('../state-machine.js').default} */
1724 guard : function ( ) {
1825 return this . state . hasWebGPU ;
1926 }
@@ -24,6 +31,7 @@ export const loadingTransitions = [
2431 event : 'START_FALLBACK' ,
2532 from : 'welcome' ,
2633 to : 'image-upload' ,
34+ /** @this {import('../state-machine.js').default} */
2735 guard : function ( ) {
2836 return ! this . state . hasWebGPU ;
2937 }
@@ -34,6 +42,7 @@ export const loadingTransitions = [
3442 event : 'WGPU_READY' ,
3543 from : 'loading' ,
3644 to : 'loading' ,
45+ /** @this {import('../state-machine.js').default} */
3746 action : function ( ) {
3847 this . state . loadingPhase = 'loading-model' ;
3948 }
@@ -44,6 +53,7 @@ export const loadingTransitions = [
4453 event : 'MODEL_LOADED' ,
4554 from : 'loading' ,
4655 to : 'loading' ,
56+ /** @this {import('../state-machine.js').default} */
4757 action : function ( ) {
4858 this . state . loadingPhase = 'warming-up' ;
4959 this . state . runtimeState = 'warming' ;
@@ -55,9 +65,11 @@ export const loadingTransitions = [
5565 event : 'WARMUP_COMPLETE' ,
5666 from : 'loading' ,
5767 to : 'runtime' ,
68+ /** @this {import('../state-machine.js').default} */
5869 guard : function ( ) {
5970 return this . state . isVideoReady ;
6071 } ,
72+ /** @this {import('../state-machine.js').default} */
6173 action : function ( ) {
6274 this . state . loadingPhase = 'complete' ;
6375 this . state . runtimeState = 'running' ;
@@ -77,6 +89,7 @@ export const loadingTransitions = [
7789 event : 'MODEL_FAILED' ,
7890 from : 'loading' ,
7991 to : 'error' ,
92+ /** @this {import('../state-machine.js').default} */
8093 action : function ( data ) {
8194 this . state . runtimeState = 'failed' ;
8295 this . state . error = {
0 commit comments