Files
breeze/tests/node_app_snapshot_behavior.zi
waozi 017d3565d3 Build on Ziran 0.5.0 and Kryon's namespaced widgets, with the Tao picture page
Pin only pushed commits, with no local overrides: Ziran v0.5.0
(f9f92b46), Kryon b45cc524 (one lock entry, ref master, shared with the
Css and Plot master edges), Apps 352901e, Entity b30dd4a and practices
893e5b6f, whose sharpened banners and regenerated Lumi guide clips the
narration check now matches.

The Library opens each Tao Te Ching chapter on its own picture page: the
chapter art and its title, centered together; the text pages follow.
The reader keeps the picture page across reflow, and a chapter start or
a Contents pick opens it. The 81 approved chapter pictures are included.

Breeze now uses Kryon's namespaced widgets (Text.Draw/Text.Props,
Button, Image, Modal.ActionModal, Layout, TabBar, LoadingScreen,
LoadingIndicator, Shape.Circle) instead of the removed Kryon/Widgets
facades. Hosted apps import std/text explicitly, since a short "text"
import now names Kryon's widget. AGENTS.md and the Text/Button API checks
describe the namespaced forms; two unused test doubles are removed.

Build fixes for the new toolchain: the bundle runtime carries Ziran's
instruction engine (no BOOTSTRAP=1) and takes the pinned host zi2c for
cross builds; the Apps controller's lock context has the manifest's
module roots; the app codec generator lists Kryon's raw modules only;
the package scripts read ZX revision 28 bundle assets. The Apps
controller digest matches the Apps 352901e build.

Also included: the stopped lanes' work in this tree (Radio download,
Photos install, Lists, Lumi, Habits shop rewards, astral exercise
selection, appearance and download recovery) and the raylib-free desktop
lane's host modules (app_trace, host_input, host_window, host_clock),
inactive unless DESKTOP_HOST is defined.

Not included: the crash-recovery lane's picture-window and storage
crash-safety changes, which that lane commits itself.

Local tests: zi-check (510 modules), native and Android source checks,
hosted app checks, build-laws, clean-text-api-check, button-api-check,
library-reader-test, library-ui-test, storage-crash-zi-test and
native-image-decode-test pass. The bundled Arcade is still ZX revision 26
and waits for an Arcade build on these pins.
2026-11-16 14:20:12 -03:00

588 lines
25 KiB
Ziran

#import, file "../src/apps/module_host.zi";
#import, file "android_text_input_host.zi";
#import "kryon/session"
#import "kryon/geometry"
Ui :: #import "kryon/tree";
#import "kryon/tree_input"
#import "kryon/widget_host"
TextField :: #import "kryon/text_field";
PhotoLegacy :: #import "apps/node_types";
#import "apps/tree"
#import, file "../src/apps/package_manager.zi";
#import, file "../src/apps/node_apps.zi";
#import, file "../src/apps/node_app_tree.zi";
#import, file "../src/apps/node_app_runner.zi";
#import, file "../src/apps/media_compression_request.zi";
#import, file "../src/app/assets.zi";
#import "kryon/tree_draw"
#import "kryon/input_protocol"
// A canonical leaf can be installed through more than one verified root.
// Removing one root must preserve the remaining copy and its owned metadata.
#import "std/c_string"
#import "std/text_buffer"
#import "std/vec"
#import "std/byte_text_linux"
#import "std/bundle_host"
#import "hosted_values"
#import, file "../src/app/assets.zi";
#import, file "../src/apps/package_release.zi";
#import "apps/tree"
#import "apps/host"
#import "apps/catalog"
#import "apps/protocol"
#import "apps/preparation"
#import, file "delegate_account_host.zi";
#import, file "node_app_icons_behavior.zi";
#import, file "node_tree_images_behavior.zi";
#import, file "node_app_embedded_behavior.zi";
#import, file "background_audio_stub.zi";
#import, file "../src/apps/node_app_snapshot.zi";
#import, file "../src/apps/node_app_tree.zi";
#import, file "../src/apps/node_apps.zi";
#import, file "../src/apps/media_compression_request.zi";
#import, file "../src/apps/catalog.zi";
#import, file "../src/apps/node_app_runner.zi";
#import, file "../src/apps/node_app_open.zi";
#import, file "../src/apps/package_files.zi";
#import, file "../src/storage/db.zi";
#import, file "../src/storage/storage_settings.zi";
snapshot_opened: s32;
snapshot_fail_open: bool;
snapshot_fail_save: bool;
snapshot_remote_downloading: bool;
snapshot_c :: #system_library "c";
SnapshotNow :: () -> float64 #foreign snapshot_c "IconsNow";
SnapshotYield :: () #foreign snapshot_c "IconsYield";
SnapshotBlockParser :: (blocked: bool) #foreign snapshot_c "IconsBlockParser";
SnapshotParserStarted :: () -> bool #foreign snapshot_c "IconsParserStarted";
SnapshotOtherAccount :: (enabled: bool) #foreign snapshot_c "IconsOtherAccount";
// The native fixture has no browser filesystem to flush.
#program_export "app_web_storage_flush"
SnapshotWebStorageFlush :: (log_success: s32) {}
SnapshotOpen :: (context: *void, parent: *AppNode, entry: *AppEntry, candidate: *AppNode) -> bool {
snapshot_opened += 1
if snapshot_fail_open { return false }
return AppHostOpen(context, parent, entry, candidate)
}
SnapshotSave :: (context: *void, node: *AppNode) -> bool { return !snapshot_fail_save }
SnapshotEffect :: (context: *void, account: string, locator: *AppLocator,
operation: s32, reply: *AppsReply) -> bool { return false }
SnapshotDownload :: (context: *void, parent: *AppNode, entry: *AppEntry,
download: *AppDownload) -> bool {
if TextUntilNul(entry.id[:]) != "fixture.remote" { return false }
download.downloading = snapshot_remote_downloading
return true
}
// Discovery yields after opening each child. Its private traversal never
// drops the active child opened by navigation, even when discovery cancels.
SnapshotDiscoveryCheck :: () -> s32 {
host: AppHost
bytes := PackageRead(IconsEnvironmentPath("NODE_OPEN_ROOT_BUNDLE"), PackageMaximumBytes)
defer { PackageFree(bytes) }
if !AppHostStart(*host, bytes, "publisher", "fixture.root", "fixture",
IconsEnvironmentPath("NODE_OPEN_ROOT_SHA256"), NodeTreeAccount(),
AppPlatform.{.save = SnapshotSave, .download = SnapshotDownload}) { return 10 }
root := AppTreeNode(*host.tree, AppHandle.{0, 1})
root.collection = true
ids: [2]string = .["fixture.one", "fixture.two"]
for id: ids {
entry: AppEntry
unused CopyCString(id, entry.id[:])
unused CopyCString("fixture", entry.expected_id[:])
unused CopyCString("assets/fixture/leaf.zx", entry.bundle[:])
unused CopyCString(IconsEnvironmentPath("NODE_OPEN_LEAF_SHA256"), entry.sha256[:])
entry.protocol = APPS_CONTEXT_PROTOCOL
if !AppCatalogAppend(*root.catalog, entry) { return 11 }
}
missing: AppEntry
unused CopyCString("fixture.remote", missing.id[:])
unused CopyCString("fixture", missing.expected_id[:])
unused CopyCString("assets/fixture/missing.zx", missing.bundle[:])
unused CopyCString(IconsEnvironmentPath("NODE_OPEN_LEAF_SHA256"), missing.sha256[:])
missing.protocol = APPS_CONTEXT_PROTOCOL
if !AppCatalogAppend(*root.catalog, missing) { return 12 }
host.tree.provider.open = SnapshotOpen
slot := cast(s32)(NodeAppSlots - 1)
node_runners[slot].nested = *host
// A transfer already requested may finish; an untouched missing game
// is skipped without attempting to open it or closing its catalog.
if !NodeInstalledScanStart(slot) { return 21 }
node_snapshot_scans[slot].stack[0].next = 2
snapshot_remote_downloading = true
if !NodeInstalledScanStep(slot) || node_snapshot_scans[slot].stack[0].next != 2 ||
snapshot_opened != 0 || AppTreeNode(*host.tree, AppHandle.{0, 1}) == null { return 22 }
snapshot_remote_downloading = false
if !NodeInstalledScanStep(slot) || node_snapshot_scans[slot].stack[0].next != 3 ||
snapshot_opened != 0 { return 23 }
NodeInstalledScanCancel(slot)
if !NodeInstalledScanStart(slot) || snapshot_opened != 0 { return 13 }
deadline := SnapshotNow() + 10.0
while node_snapshot_scans[slot].stack.count > 0 && SnapshotNow() < deadline {
before := snapshot_opened
if !NodeInstalledScanStep(slot) || snapshot_opened - before > 1 ||
node_snapshot_scanning || !AppHandleEqual(host.tree.active, AppHandle.{0, 1}) { return 14 }
SnapshotYield()
}
if snapshot_opened != 2 || node_snapshot_scans[slot].stack.count != 0 { return 15 }
active: AppHandle
opened: s32
deadline = SnapshotNow() + 10.0
while opened == 0 && SnapshotNow() < deadline {
opened = AppHostOpenChild(*host, AppHandle.{0, 1}, "fixture.one", *active)
SnapshotYield()
}
if opened != 1 { return 16 }
if active.slot < 0 { return 16 }
host.tree.active = active
if !NodeInstalledScanStart(slot) || !NodeInstalledScanStep(slot) { return 17 }
NodeInstalledScanCancel(slot)
if node_snapshot_scans[slot].stack.count != 0 || AppTreeNode(*host.tree, active) == null ||
!AppHandleEqual(host.tree.active, active) || host.tree.nodes.count != 2 { return 18 }
snapshot_fail_open = true
if !NodeInstalledScanStart(slot) { return 19 }
healthy := true
deadline = SnapshotNow() + 10.0
while healthy && SnapshotNow() < deadline {
healthy = NodeInstalledScanStep(slot)
SnapshotYield()
}
if healthy || node_snapshot_scanning { return 19 }
NodeInstalledScanCancel(slot)
if AppTreeNode(*host.tree, active) == null { return 20 }
stopped := AppHostStop(*host)
deadline = SnapshotNow() + 10.0
while !stopped && SnapshotNow() < deadline {
stopped = AppHostStop(*host)
SnapshotYield()
}
if !stopped { return 20 }
node_runners[slot].nested = null
return 0
}
SnapshotWaitOpen :: (slot: s32) -> bool {
deadline := SnapshotNow() + 10.0
while NodeAppOpening(slot) && SnapshotNow() < deadline {
unused NodeOpenPump(true)
SnapshotYield()
}
return NodeAppRunning(slot) && !node_open_failed[slot]
}
SnapshotWaitClose :: (slot: s32) -> bool {
deadline := SnapshotNow() + 10.0
while !NodeAppClose(slot) && SnapshotNow() < deadline {
SnapshotYield()
}
return node_open_work == null && !NodeAppRunning(slot)
}
SnapshotWaitParser :: () -> bool {
deadline := SnapshotNow() + 10.0
while !SnapshotParserStarted() && SnapshotNow() < deadline {
unused NodeOpenPump(true)
SnapshotYield()
}
return SnapshotParserStarted()
}
// Actual packed programs exercise the loader, cancellation and save boundary.
// A held parser cannot block a frame or publish into a different account.
SnapshotRootOpenCheck :: () -> s32 {
slot := cast(s32)(NodeAppSlots - 2)
previous_path := node_local_path
previous_name := node_local_name
defer {
SnapshotBlockParser(false)
SnapshotOtherAccount(false)
node_local_path = previous_path
node_local_name = previous_name
}
unused CopyCString("fixture", node_local_name[:])
unused CopyCString(IconsEnvironmentPath("NODE_OPEN_ROOT_BUNDLE"), node_local_path[:])
NodeAppAssign(slot, "fixture")
SnapshotBlockParser(true)
if !NodeAppOpen(slot) || !SnapshotWaitParser() { return 100 }
// A local app still preparing is installed, so a route or a launcher
// shortcut opens its page, which says it loads.
if !NodeAppInstalled(slot) { return 115 }
start := SnapshotNow()
for frame: cast(s32)0..99 {
unused NodeOpenPump(true)
if NodeAppRunning(slot) { return 101 }
}
if SnapshotNow() - start > 0.05 || NodeAppClose(slot) || node_open_work == null {
return 102
}
SnapshotBlockParser(false)
if !SnapshotWaitClose(slot) { return 103 }
if !NodeAppOpen(slot) || !SnapshotWaitOpen(slot) { return 104 }
instance := node_runners[slot].app.instance
SnapshotBlockParser(true)
if !NodeOpenQueue(slot, true) || !SnapshotWaitParser() { return 105 }
SnapshotOtherAccount(true)
start = SnapshotNow()
for frame: cast(s32)0..99 {
unused NodeOpenPump(true)
if node_runners[slot].app.instance != instance { return 106 }
}
if SnapshotNow() - start > 0.05 || node_open_work == null { return 107 }
SnapshotBlockParser(false)
deadline := SnapshotNow() + 10.0
while node_open_work != null && SnapshotNow() < deadline {
unused NodeOpenPump(true)
SnapshotYield()
}
SnapshotOtherAccount(false)
if node_open_work != null || node_runners[slot].app.instance != instance ||
!SnapshotWaitClose(slot) { return 108 }
host: AppHost
bytes := PackageRead(IconsEnvironmentPath("NODE_OPEN_ROOT_BUNDLE"), PackageMaximumBytes)
defer { PackageFree(bytes) }
if !AppHostStart(*host, bytes, "publisher", "fixture.root", "fixture",
IconsEnvironmentPath("NODE_OPEN_ROOT_SHA256"), NodeTreeAccount(),
AppPlatform.{.save = SnapshotSave}) { return 109 }
node_runners[slot].nested = *host
snapshot_fail_save = true
defer { snapshot_fail_save = false }
if !NodeOpenQueue(slot, true) { return 110 }
deadline = SnapshotNow() + 10.0
while (node_open_preparation == null || !AppPreparationReady(node_open_preparation)) &&
SnapshotNow() < deadline {
unused NodeOpenPump(true)
SnapshotYield()
}
if node_open_preparation == null || !AppPreparationReady(node_open_preparation) { return 111 }
start = SnapshotNow()
for frame: cast(s32)0..99 {
unused NodeOpenPump(true)
if node_runners[slot].nested != *host || host.tree.nodes.count != 1 { return 112 }
}
if SnapshotNow() - start > 0.05 { return 113 }
snapshot_fail_save = false
if !SnapshotWaitOpen(slot) || node_runners[slot].nested != null ||
host.tree.nodes.count != 0 || !SnapshotWaitClose(slot) { return 114 }
NodeAppAssign(slot, "")
return 0
}
snapshot_package_node: AppNode;
SnapshotPublicationsHostCheck :: () -> s32 {
identities: [2]string = .["arcade.shovey-editor", "xyz.waozi.wurm-editor"]
for identity: identities {
runner: NodeAppRunner
nested: AppHost
node: AppNode
if !CopyCString("publisher", node.identity.authority[:]) ||
!CopyCString(identity, node.identity.id[:]) { return 120 }
function: [32]u8
if !CopyCString("AppServiceHost", function[:]) { return 123 }
arguments: [2]HostValue
arguments[0] = NodeAppString("publications")
arguments[1] = NodeAppString("{\"operation\":\"fetch\",\"id\":\"fixture\"}")
runner.nested = *nested
if !CopyCString("other-account", nested.tree.account[:]) ||
NodeTreeAllows(cast(*void)*runner, *node, "publications") ||
NodeTreeAllows(cast(*void)*runner, *node, "AppServiceHost") { return 121 }
mismatched: HostValue
if NodeTreeCall(cast(*void)*runner, *node, null, *function[0], *arguments[0], 2, *mismatched) != 0 { return 125 }
if !CopyCString(NodeTreeAccount(), nested.tree.account[:]) ||
!NodeTreeAllows(cast(*void)*runner, *node, "publications") ||
!NodeTreeAllows(cast(*void)*runner, *node, "AppServiceHost") { return 122 }
result: HostValue
if NodeTreeCall(cast(*void)*runner, *node, null, *function[0], *arguments[0], 2, *result) != 1 ||
result.kind != cast(s32)HostValueKind.HostString ||
NodeAppText(result) != "{\"status\":\"rejected\",\"error\":\"signed-out\"}" { return 124 }
}
return 0
}
snapshot_media_publishers: string;
SnapshotMediaAsset :: (path: string) -> AssetView {
if path == "apps/publishers.json" {
return AssetView.{.found = true, .data = snapshot_media_publishers}
}
return AssetView.{}
}
// Exercise actual nested host dispatch and publisher/account binding.
SnapshotMediaCompressionCheck :: () -> s32 {
slot := cast(s32)(NodeAppSlots - 3)
runner := *node_runners[slot]
nested: AppHost
node: AppNode
function: [32]u8
arguments: [2]HostValue
result: HostValue
NodeAppAssign(slot, "photos")
runner.nested = *nested
runner.embedded_release.valid = true
unused CopyCString("baseline", runner.embedded_release.key_id[:])
snapshot_media_publishers = PackageRead(IconsEnvironmentPath("NODE_EMBEDDED_PUBLISHERS"), 16384)
AssetBindProvider(SnapshotMediaAsset)
defer {
node_tree_validating = false
node_snapshot_scanning = false
unused MediaCompressionTakeRequest()
runner.nested = null
runner.embedded_release = PackageRelease.{}
NodeAppAssign(slot, "")
AssetUnbindProvider()
PackageFree(snapshot_media_publishers)
snapshot_media_publishers = ""
}
unused CopyCString(NodeTreeAccount(), nested.tree.account[:])
unused CopyCString("photos", node.entry.expected_id[:])
unused CopyCString("inbe.photos", node.identity.id[:])
unused CopyCString("1111111111111111111111111111111111111111111111111111111111111111", node.identity.authority[:])
unused CopyCString("AppServiceHost", function[:])
arguments[0] = NodeAppString("media.compression.open")
arguments[1] = NodeAppString("")
if NodeAppCapability("AppServiceHost") ||
!NodeTreeAllows(cast(*void)runner, *node, "media.compression.open") { return 130 }
if NodeTreeCall(cast(*void)runner, *node, null, *function[0], *arguments[0], 2, *result) != 1 ||
NodeAppText(result) != "queued" || !MediaCompressionTakeRequest() ||
MediaCompressionTakeRequest() { return 131 }
if NodeAppCallFor(runner, "diary", null, *function[0], *arguments[0], 2, *result) != 0 ||
MediaCompressionTakeRequest() { return 132 }
unused CopyCString("diary", node.entry.expected_id[:])
unused CopyCString("inbe.diary", node.identity.id[:])
if NodeTreeAllows(cast(*void)runner, *node, "media.compression.open") ||
NodeTreeCall(cast(*void)runner, *node, null, *function[0], *arguments[0], 2, *result) != 0 ||
MediaCompressionTakeRequest() { return 133 }
unused CopyCString("photos", node.entry.expected_id[:])
unused CopyCString("inbe.photos", node.identity.id[:])
// A Photos-shaped name without the trusted publisher gains nothing.
unused CopyCString("untrusted", node.identity.authority[:])
if NodeTreeAllows(cast(*void)runner, *node, "media.compression.open") ||
NodeTreeCall(cast(*void)runner, *node, null, *function[0], *arguments[0], 2, *result) != 0 ||
MediaCompressionTakeRequest() { return 134 }
unused CopyCString("1111111111111111111111111111111111111111111111111111111111111111", node.identity.authority[:])
unused CopyCString("other-account", nested.tree.account[:])
if NodeTreeCall(cast(*void)runner, *node, null, *function[0], *arguments[0], 2, *result) != 0 ||
MediaCompressionTakeRequest() { return 135 }
unused CopyCString(NodeTreeAccount(), nested.tree.account[:])
for phase: cast(s32)0..1 {
node_tree_validating = phase == 0
node_snapshot_scanning = phase == 1
if NodeTreeAllows(cast(*void)runner, *node, "media.compression.open") ||
NodeTreeCall(cast(*void)runner, *node, null, *function[0], *arguments[0], 2, *result) != 0 ||
NodeAppCallFor(runner, "photos", null, *function[0], *arguments[0], 2, *result) != 0 ||
MediaCompressionTakeRequest() { return 136 }
}
node_tree_validating = false
node_snapshot_scanning = false
arguments[1] = NodeAppString("unexpected")
if NodeTreeCall(cast(*void)runner, *node, null, *function[0], *arguments[0], 2, *result) != 0 ||
MediaCompressionTakeRequest() { return 137 }
arguments[1] = HostScalar("s32", 1)
unused NodeTreeCall(cast(*void)runner, *node, null, *function[0], *arguments[0], 2, *result)
if MediaCompressionTakeRequest() { return 138 }
return 0
}
// Other packages keep their own asset folder and canonical id, but can
// never stand in for an Inbe app.
SnapshotPackageOwnerCheck :: () -> s32 {
node := *snapshot_package_node
owner: [25]u8
unused CopyCString("xyz.waozi.choano", node.identity.id[:])
unused CopyCString("choano", node.entry.expected_id[:])
if !NodeInstalledPackageOwner(node, owner[:]) || TextUntilNul(owner[:]) != "choano" { return 110 }
unused CopyCString("inbe.photos", node.identity.id[:])
if NodeInstalledPackageOwner(node, owner[:]) { return 111 }
unused CopyCString("xyz.waozi.choano", node.identity.id[:])
unused CopyCString("../photos", node.entry.expected_id[:])
if NodeInstalledPackageOwner(node, owner[:]) { return 112 }
return 0
}
#program_export
Check :: () -> s32 {
root: [14]u8
unused CopyCString("APP_DATA_ROOT", root[:])
if storage_init(TextFromCString(DelegateFixtureEnvironment(*root[0]))) == 0 { return 1 }
NodeInstalledClear()
unused CopyCString(NodeTreeAccount(), node_installed_account[:])
first: NodeInstalledLeaf
unused CopyCString("publisher", first.identity.authority[:])
unused CopyCString("inbe.photos", first.identity.id[:])
unused CopyCString("photos", first.owner[:])
unused CopyCString("photos", first.root[:])
bytes: Vec(u8)
BuilderPrint(*bytes, "%", "{\"fixture\":1}")
first.assets[0] = BuilderFinish(bytes)
second: NodeInstalledLeaf
second.identity = first.identity
second.owner = first.owner
unused CopyCString("arcade", second.root[:])
other: Vec(u8)
BuilderPrint(*other, "%", "{\"fixture\":2}")
second.assets[0] = BuilderFinish(other)
if !VecPush(node_installed_leaves, first) || !VecPush(node_installed_leaves, second) { return 2 }
NodeAppSetMark("photos", true)
NodeAppSetMark("arcade", true)
before := NodeAppInstalledLeafRevision()
if NodeAppInstalledLeafCount() != 1 || NodeAppInstalledLeafName(0) != "photos" ||
NodeAppInstalledLeafID(0) != "inbe.photos" { return 3 }
NodeAppSetMark("arcade", false)
if NodeAppInstalledLeafCount() != 1 || NodeAppInstalledLeafRevision() == before { return 4 }
asset := NodeAppInstalledLeafAsset(0, "photos", "assets/photos/achievements.json")
if !asset.found || asset.data != "{\"fixture\":1}" { return 5 }
NodeAppSetMark("arcade", true)
NodeAppSetMark("photos", false)
if NodeAppInstalledLeafCount() != 1 { return 6 }
asset = NodeAppInstalledLeafAsset(0, "photos", "assets/photos/achievements.json")
if !asset.found || asset.data != "{\"fixture\":2}" { return 7 }
NodeAppSetMark("arcade", false)
if NodeAppInstalledLeafCount() != 0 { return 8 }
before = NodeAppInstalledLeafRevision()
NodeInstalledClear()
if NodeAppInstalledLeafRevision() == before { return 9 }
discovery := SnapshotDiscoveryCheck()
if discovery != 0 { return discovery }
opening := SnapshotRootOpenCheck()
if opening != 0 { return opening }
icons := NodeAppIconsCheck()
if icons != 0 { return icons }
images := NodeTreeImagesCheck()
if images != 0 { return images }
packages := SnapshotPackageOwnerCheck()
if packages != 0 { return packages }
publications := SnapshotPublicationsHostCheck()
if publications != 0 { return publications }
compression := SnapshotMediaCompressionCheck()
if compression != 0 { return compression }
embedded := NodeAppEmbeddedCheck()
if embedded != 0 { return embedded }
photos := PhotosClientCheck()
if photos != 0 { return photos }
storage_close()
return 0
}
photos_client_controller: string;
PhotosClientAsset :: (path: string) -> AssetView {
if path == "apps/publishers.json" {
return AssetView.{.found = true, .data = snapshot_media_publishers}
}
if path == "apps.zx" {
return AssetView.{.found = true, .data = photos_client_controller}
}
return AssetView.{}
}
PhotosClientFrame :: (slot: s32, session: Session, tick: u64, width: s32) -> bool {
BeginFrame(session, tick, Rectangle.{0.0, 0.0, cast(float32)width, 844.0})
WidgetHostBegin(session, NodeTreeAssetAllowed, NodeTreeAssetPath)
NodeAppUiBegin(WidgetHostCall, null)
NodeTreeFrame(slot, PhotoLegacy.AppUiFrame.{.session = session, .width = width,
.height = 844, .scale = 1.0, .font = 16}, 0, 0, TextField.Input.{})
message := NodeAppRunMessage(slot, PhotoLegacy.AppMessage.{
.action = PhotoLegacy.APP_FRAME, .name = "photos", .locale = "en"})
NodeAppUiEnd()
WidgetHostEnd()
unused EndFrame(session)
return message.succeeded
}
PhotosClientWrench :: (slot: s32, width: s32) -> bool {
session := SessionOpen()
defer { unused SessionClose(session) }
if !PhotosClientFrame(slot, session, 1, width) { return false }
bounds: Rectangle
for index: cast(s32)0..Ui.TreeCount(session) - 1 {
node := Ui.TreeNodeAt(session, index)
if node.focus_id == 7004 { bounds = node.bounds }
}
if bounds.width <= 0.0 || bounds.height <= 0.0 || bounds.x < 0.0 ||
bounds.x + bounds.width > cast(float32)width || bounds.y < 0.0 ||
bounds.y + bounds.height > 844.0 { return false }
unused TreePointerUpdate(session, PointerFrame.{
.x = bounds.x + bounds.width / 2.0, .y = bounds.y + bounds.height / 2.0,
.down = true, .pressed = true})
unused TreePointerUpdate(session, PointerFrame.{
.x = bounds.x + bounds.width / 2.0, .y = bounds.y + bounds.height / 2.0,
.released = true})
if !PhotosClientFrame(slot, session, 2, width) ||
!MediaCompressionTakeRequest() || MediaCompressionTakeRequest() { return false }
if !PhotosClientFrame(slot, session, 3, width) || MediaCompressionTakeRequest() { return false }
return true
}
PhotosClientCheck :: () -> s32 {
origin := IconsEnvironmentPath("PHOTOS_CLIENT_ORIGIN")
if origin.count == 0 { return 0 }
slot := cast(s32)(NodeAppSlots - 4)
snapshot_media_publishers = PackageRead(IconsEnvironmentPath("NODE_EMBEDDED_PUBLISHERS"), 16384)
photos_client_controller = PackageRead(IconsEnvironmentPath("NODE_EMBEDDED_CONTROLLER"), PackageMaximumBytes)
AssetBindProvider(PhotosClientAsset)
PackageCancel()
PackageInitialize()
unused CopyCString(origin, package_origin[:])
NodeAppAssign(slot, "photos")
index := NodeAppIndex(slot)
defer {
SnapshotOtherAccount(false)
unused SnapshotWaitClose(slot)
PackageCancel()
NodeAppAssign(slot, "")
AssetUnbindProvider()
PackageFree(snapshot_media_publishers)
PackageFree(photos_client_controller)
snapshot_media_publishers = ""
photos_client_controller = ""
unused CopyCString("https://api.waozi.xyz", package_origin[:])
}
if NodeAppLocal("photos") || PackageAvailable(index) { return 200 }
if NodeAppInstall("photos") != slot { return 201 }
deadline := SnapshotNow() + 20.0
while PackageStatus(index) != 3 && SnapshotNow() < deadline {
PackagePump(0, 0, false)
SnapshotYield()
}
if PackageStatus(index) != 3 || PackageAvailable(index) || NodeAppRunning(slot) { return 202 }
if NodeAppInstall("photos") != slot { return 203 }
deadline = SnapshotNow() + 20.0
while PackageStatus(index) != 2 && SnapshotNow() < deadline {
PackagePump(0, 0, false)
SnapshotYield()
}
if PackageStatus(index) != 2 || !PackageAvailable(index) { return 204 }
bytes := PackageInstalledBytes(index)
valid := PackageVerifyBytes(bytes, package_cached_releases[index]) && TextUntilNul(package_cached_releases[index].hash[:]) == IconsEnvironmentPath("PHOTOS_CLIENT_SHA256")
PackageFree(bytes)
if !valid || TextUntilNul(package_cached_releases[index].key_id[:]) != "photos-fixture" { return 205 }
if !NodeAppOpen(slot) || !SnapshotWaitOpen(slot) || node_runners[slot].nested == null { return 206 }
if !PhotosClientWrench(slot, 390) { return 207 }
SnapshotOtherAccount(true)
session := SessionOpen()
rejected := !PhotosClientFrame(slot, session, 4, 390)
unused SessionClose(session)
SnapshotOtherAccount(false)
if !rejected || MediaCompressionTakeRequest() { return 208 }
if !SnapshotWaitClose(slot) || !NodeAppOpen(slot) || !SnapshotWaitOpen(slot) { return 209 }
if !PhotosClientWrench(slot, 1280) { return 210 }
return 0
}
#program_export
ImageWidth :: (path: string) -> s32 { unused path; return 1 }
#program_export
ImageHeight :: (path: string) -> s32 { unused path; return 1 }