Files
breeze/apps/practice/practice.zi
T
waozi f25b4dfd5e Build Apps and Crypto as locked packages and take the node-app ABI from Apps
Apps and Crypto are now ordinary Ziran dependencies, pinned in ziran.lock
and linked by scripts/packages.sh, instead of local checkouts handed to the
build. Every dependency and the toolchain are on their latest revisions.

scripts/package-paths.sh is the one list of NAME=DIR package paths; the
native, web, Windows and Android builds, the source check, the bundle
scripts and the tests all use it, so they resolve packages the same way.
The shared Apps controller bundle is built from the locked Apps package,
and its reviewed digest matches that build.

Node apps, the feature cells and the host import the module ABI and the
node-app types and codec from the Apps package. Inner Breeze no longer
keeps its own copies, its codec generator, or the unused protocol module.

Test hosts include zir_string.h for the string helpers they call.
2026-10-18 23:20:13 -03:00

72 lines
3.0 KiB
Ziran

// The live practice clocks run in this bundle; the unified host performs
// audio, notification, session-save and mobile lifecycle effects.
#import, file "../../src/cells/practice_types.zi";
#import, file "../../src/core/breath_timing.zi";
#import, file "../../src/practices/meditation/meditation_timing.zi";
#import, file "../../src/practices/patterns/patterns_clock.zi";
#import, file "../../src/cells/module_types.zi";
#import "apps/node_types"
#import, file "../../src/core/types.zi";
#import, file "../../src/practices/sun_salutation/sun_salutation_rules.zi";
host_api :: #system_library "host_api";
ReadPracticeHost :: () -> PracticeMessage #foreign host_api;
WritePracticeHost :: (message: PracticeMessage) #foreign host_api;
SunSalutationStoredFrame :: (timeline_frame: s32) -> s32 #foreign host_api;
PracticeApply :: (message: PracticeMessage) -> PracticeMessage {
message.succeeded = true
if message.action == PRACTICE_ROUTE {
message.succeeded = message.screen == ScreenStart || message.screen == ScreenSession ||
message.screen == ScreenMeditation || message.screen == ScreenSunSalutation ||
message.screen == ScreenPatterns || message.screen == ScreenTaiChi || message.screen == ScreenAstralProjection ||
message.screen == ScreenResults || message.screen == ScreenPracticeConfig ||
message.screen == ScreenManual
return message
}
if message.paused {
return message
}
if message.action == PRACTICE_BREATH_STEP {
message.breathing = BreathSessionStep(message.breathing)
message.completed = message.breathing.completed != 0
} else if message.action == PRACTICE_MEDITATION_STEP {
next := AdvanceMeditationTime(message.remaining_seconds,
message.remainder_ms, message.elapsed_ms)
message.remaining_seconds = next.remaining_seconds
message.remainder_ms = next.remainder_ms
message.elapsed_seconds = next.elapsed_seconds
message.completed = next.completed
} else if message.action == PRACTICE_SALUTATION_STEP {
next := SalutationAdvance(message.salutation, message.elapsed)
message.salutation = next.state
message.completed = next.completed != 0
} else if message.action == PRACTICE_PATTERNS_STEP {
next := PatternsAdvance(message.patterns)
message.patterns = next.state
message.cue = next.cue
message.completed = next.completed
} else {
message.succeeded = false
}
return message
}
#program_export "PracticeMain"
Main :: () -> s32 {
message := ReadPracticeHost()
if message.abi != MODULE_ABI {
return -1
}
if message.action == MODULE_IDENTIFY {
// The smaller frame inventory needs the wrapper's frame mapping.
// Older wrappers reject this required capability before replacing
// their working package.
if SunSalutationStoredFrame(0) != 0 {
return -1
}
return MODULE_PRACTICE
}
WritePracticeHost(PracticeApply(message))
return 0
}