@native-sdk/cli 0.10.0 → 0.11.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 +8 -6
- package/bin/native.js +2 -1
- package/build/app.zig +320 -60
- package/build/corewire.zig +53 -0
- package/build/test_shards.zig +49 -0
- package/build/ts_run.mjs +3 -3
- package/build.zig +1818 -87
- package/package.json +19 -14
- package/packages/core/compile-surface/core.ts +134 -72
- package/packages/core/package-lock.json +75 -357
- package/packages/core/package.json +25 -4
- package/packages/core/scripts/compiler_command.mjs +17 -12
- package/packages/core/scripts/compiler_typecheck.mjs +1 -0
- package/packages/core/scripts/gen_declarations.mjs +3 -2
- package/packages/core/scripts/gen_service_surface.mjs +22 -10
- package/packages/core/scripts/install_scriptc.mjs +182 -0
- package/packages/core/scripts/invoke_scriptc.mjs +18 -0
- package/packages/core/scripts/merge_static_archives.mjs +6 -1
- package/packages/core/scripts/npm_static_spike.mjs +2 -2
- package/packages/core/scripts/run_external_core_compiler.mjs +22 -10
- package/packages/core/scripts/run_external_service_compiler.mjs +15 -15
- package/packages/core/scripts/run_library_compiler.mjs +51 -0
- package/packages/core/scripts/run_native_tests.mjs +22 -0
- package/packages/core/scripts/scriptc-toolchain.json +101 -0
- package/packages/core/scripts/scriptc_toolchain.mjs +121 -0
- package/packages/core/scripts/stage_external_core.mjs +57 -1
- package/packages/core/scripts/surface_manifest_diff.mjs +19 -12
- package/packages/core/sdk/bytes.d.ts +2 -0
- package/packages/core/sdk/bytes.ts +86 -0
- package/packages/core/sdk/core.d.ts +308 -4
- package/packages/core/sdk/core.ts +320 -84
- package/packages/core/sdk/events.d.ts +247 -0
- package/packages/core/sdk/events.ts +230 -2
- package/packages/core/sdk/internal/image_identity.d.ts +7 -0
- package/packages/core/sdk/internal/image_identity.ts +71 -0
- package/packages/core/sdk/internal/markdown_policy.d.ts +5 -0
- package/packages/core/sdk/internal/markdown_policy.ts +878 -0
- package/packages/core/sdk/text.d.ts +27 -0
- package/packages/core/sdk/text.ts +206 -15
- package/packages/core/sdk/theme.d.ts +251 -0
- package/packages/core/sdk/theme.ts +267 -0
- package/packages/core/src/authorization.ts +137 -0
- package/packages/core/src/automation_commands.ts +201 -0
- package/packages/core/src/automation_interactions.ts +92 -0
- package/packages/core/src/bridge_descriptors.ts +104 -0
- package/packages/core/src/builtin_coordination.ts +172 -0
- package/packages/core/src/canvas_frame_coordination.ts +81 -0
- package/packages/core/src/canvas_presentation_lifecycle.ts +84 -0
- package/packages/core/src/canvas_scene_observation.ts +145 -0
- package/packages/core/src/chart_content.ts +161 -0
- package/packages/core/src/chart_plans.ts +432 -0
- package/packages/core/src/checker.ts +166 -19
- package/packages/core/src/code_content.ts +580 -0
- package/packages/core/src/command_coordination.ts +140 -0
- package/packages/core/src/component_composition.ts +94 -0
- package/packages/core/src/component_construction.ts +149 -0
- package/packages/core/src/contract.ts +25 -7
- package/packages/core/src/control_appearance.ts +232 -0
- package/packages/core/src/control_commands.ts +115 -0
- package/packages/core/src/control_content.ts +105 -0
- package/packages/core/src/control_geometry.ts +107 -0
- package/packages/core/src/control_payloads.ts +119 -0
- package/packages/core/src/control_primitives.ts +134 -0
- package/packages/core/src/devhost.ts +82 -7
- package/packages/core/src/devhost_journal.mjs +30 -7
- package/packages/core/src/effect_plans.ts +71 -0
- package/packages/core/src/flow_measurement.ts +121 -0
- package/packages/core/src/font_registry.ts +37 -0
- package/packages/core/src/glyph_atlas.ts +86 -0
- package/packages/core/src/gpu_packet_preparation.ts +130 -0
- package/packages/core/src/gpu_planning.ts +123 -0
- package/packages/core/src/gpu_presentation.ts +55 -0
- package/packages/core/src/host_flow.ts +89 -0
- package/packages/core/src/host_input_regions.ts +165 -0
- package/packages/core/src/image_registry.ts +66 -0
- package/packages/core/src/indicator_plans.ts +132 -0
- package/packages/core/src/infer.ts +150 -8
- package/packages/core/src/input_composition.ts +116 -0
- package/packages/core/src/intrinsic_measure.ts +100 -0
- package/packages/core/src/layout_coordination.ts +207 -0
- package/packages/core/src/leaf_plans.ts +134 -0
- package/packages/core/src/markup_development.ts +160 -0
- package/packages/core/src/measurement_coordination.ts +185 -0
- package/packages/core/src/modules.ts +1 -1
- package/packages/core/src/motion_sampling.ts +100 -0
- package/packages/core/src/paragraph_layout.ts +192 -0
- package/packages/core/src/portable_sources.json +74 -0
- package/packages/core/src/portable_sources.ts +17 -0
- package/packages/core/src/registered_font.ts +93 -0
- package/packages/core/src/render_animation_lifecycle.ts +128 -0
- package/packages/core/src/render_coordination.ts +170 -0
- package/packages/core/src/render_resources.ts +234 -0
- package/packages/core/src/runtime_policy.ts +3930 -0
- package/packages/core/src/scalar_text.ts +84 -0
- package/packages/core/src/service_contract.ts +2 -1
- package/packages/core/src/session_codecs.ts +309 -0
- package/packages/core/src/shell_admission.ts +126 -0
- package/packages/core/src/shell_coordination.ts +93 -0
- package/packages/core/src/sqlite_cli.ts +11 -0
- package/packages/core/src/status_validation.ts +232 -0
- package/packages/core/src/stream_policy.ts +63 -0
- package/packages/core/src/surface_recipes.ts +136 -0
- package/packages/core/src/system_admission.ts +60 -0
- package/packages/core/src/terminal_paint.ts +436 -0
- package/packages/core/src/text_document_width.ts +81 -0
- package/packages/core/src/text_measurement_cache.ts +69 -0
- package/packages/core/src/text_query_layout.ts +179 -0
- package/packages/core/src/text_run_layout.ts +410 -0
- package/packages/core/src/text_span_queries.ts +355 -0
- package/packages/core/src/typed_ast.ts +18 -1
- package/packages/core/src/types.ts +7 -5
- package/packages/core/src/vector_effects.ts +98 -0
- package/packages/core/src/vector_raster.ts +243 -0
- package/packages/core/src/view_components.ts +2415 -0
- package/packages/core/src/view_coordination.ts +198 -0
- package/packages/core/src/view_frontend.ts +980 -0
- package/packages/core/src/widget_audits.ts +202 -0
- package/packages/core/src/widget_changes.ts +258 -0
- package/packages/core/src/widget_metrics.ts +139 -0
- package/packages/core/src/widget_motion.ts +171 -0
- package/packages/core/src/widget_paint.ts +272 -0
- package/packages/core/src/widget_paint_walk.ts +203 -0
- package/packages/core/src/widget_presentation.ts +141 -0
- package/packages/core/src/widget_routing.ts +262 -0
- package/packages/core/src/window_lifecycle.ts +92 -0
- package/packages/core/testing/index.ts +430 -0
- package/schemas/app.schema.json +13 -0
- package/skill-data/core/SKILL.md +2 -2
- package/skill-data/core/references/web-engines-packaging-debugging.md +2 -1
- package/skill-data/native-ui/SKILL.md +76 -17
- package/skill-data/ts-core/SKILL.md +113 -9
- package/skill-data/ts-services/SKILL.md +1 -1
- package/skill-data/ts-services/references/service-surface.md +264 -144
- package/src/app_runner/root.zig +25 -12
- package/src/app_runner/ts_compiled_view.zig +1631 -0
- package/src/app_runner/ts_core_main.zig +143 -10
- package/src/app_runner/ts_core_mobile.zig +24 -12
- package/src/automation/server.zig +1 -3
- package/src/automation/snapshot.zig +9 -637
- package/src/automation/snapshot_reference.zig +656 -0
- package/src/automation/snapshot_serialization.zig +566 -0
- package/src/platform/linux/gtk_host.c +36 -24
- package/src/platform/linux/gtk_pixels.h +118 -0
- package/src/platform/linux/gtk_pixels_test.c +241 -0
- package/src/platform/linux/root.zig +2 -0
- package/src/platform/macos/appkit_host.m +188 -30
- package/src/platform/macos/pointer_motion_test.m +96 -0
- package/src/platform/macos/scroll_driver_test.m +105 -0
- package/src/platform/macos/spectrum_bins.h +34 -0
- package/src/platform/macos/spectrum_bins_test.c +56 -0
- package/src/platform/macos/text_keyboard_test.m +80 -0
- package/src/platform/macos/widget_focus_test.m +66 -0
- package/src/platform/null_platform.zig +26 -2
- package/src/platform/null_platform_tests.zig +13 -0
- package/src/platform/root.zig +1 -0
- package/src/platform/types.zig +13 -0
- package/src/platform/windows/root.zig +2 -0
- package/src/platform/windows/webview2_host.cpp +7 -2
- package/src/primitives/app_manifest/comptime_scene.zig +1 -1
- package/src/primitives/app_manifest/root.zig +2 -0
- package/src/primitives/app_manifest/tests.zig +4 -1
- package/src/primitives/app_manifest/validation.zig +2 -0
- package/src/primitives/canvas/a11y_audit.zig +3 -1
- package/src/primitives/canvas/canvas_frame_coordination_policy.zig +134 -0
- package/src/primitives/canvas/chart_content_policy.zig +75 -0
- package/src/primitives/canvas/chart_plan_policy.zig +196 -0
- package/src/primitives/canvas/code_content_policy.zig +162 -0
- package/src/primitives/canvas/commands.zig +29 -1
- package/src/primitives/canvas/component_composition.zig +125 -0
- package/src/primitives/canvas/component_composition_policy.zig +44 -0
- package/src/primitives/canvas/component_construction_policy.zig +187 -0
- package/src/primitives/canvas/container_layout_policy.zig +87 -0
- package/src/primitives/canvas/control_appearance_policy.zig +142 -0
- package/src/primitives/canvas/control_command_policy.zig +75 -0
- package/src/primitives/canvas/control_content_policy.zig +90 -0
- package/src/primitives/canvas/control_geometry_policy.zig +165 -0
- package/src/primitives/canvas/control_payload_policy.zig +48 -0
- package/src/primitives/canvas/control_primitive_policy.zig +129 -0
- package/src/primitives/canvas/effect_plan_policy.zig +96 -0
- package/src/primitives/canvas/events.zig +1027 -1
- package/src/primitives/canvas/flow_measurement_policy.zig +237 -0
- package/src/primitives/canvas/frame.zig +92 -23
- package/src/primitives/canvas/glyph_atlas_policy.zig +40 -0
- package/src/primitives/canvas/gpu.zig +10 -0
- package/src/primitives/canvas/gpu_packet_preparation_policy.zig +325 -0
- package/src/primitives/canvas/gpu_planning_policy.zig +364 -0
- package/src/primitives/canvas/gpu_presentation_policy.zig +74 -0
- package/src/primitives/canvas/grid_layout_policy.zig +51 -0
- package/src/primitives/canvas/indicator_plan_policy.zig +128 -0
- package/src/primitives/canvas/intrinsic_layout_policy.zig +87 -0
- package/src/primitives/canvas/intrinsic_measure_policy.zig +128 -0
- package/src/primitives/canvas/layout_audit.zig +5 -2
- package/src/primitives/canvas/layout_coordination_policy.zig +262 -0
- package/src/primitives/canvas/leaf_plan_policy.zig +117 -0
- package/src/primitives/canvas/markdown.zig +13 -3
- package/src/primitives/canvas/markdown_content_policy.zig +227 -0
- package/src/primitives/canvas/markdown_image_binding.zig +81 -0
- package/src/primitives/canvas/measurement_coordination_policy.zig +288 -0
- package/src/primitives/canvas/numeric_capabilities.zig +14 -0
- package/src/primitives/canvas/reference.zig +12 -6
- package/src/primitives/canvas/registered_font_policy.zig +152 -0
- package/src/primitives/canvas/render.zig +48 -0
- package/src/primitives/canvas/render_cache_policy.zig +184 -0
- package/src/primitives/canvas/render_coordination_policy.zig +163 -0
- package/src/primitives/canvas/render_damage_policy.zig +160 -0
- package/src/primitives/canvas/render_effects.zig +14 -0
- package/src/primitives/canvas/render_generic_resources.zig +14 -0
- package/src/primitives/canvas/render_images.zig +14 -0
- package/src/primitives/canvas/render_layers.zig +14 -0
- package/src/primitives/canvas/render_override_policy.zig +119 -0
- package/src/primitives/canvas/render_paths.zig +14 -0
- package/src/primitives/canvas/render_plan_policy.zig +199 -0
- package/src/primitives/canvas/render_resource_policy.zig +476 -0
- package/src/primitives/canvas/root.zig +100 -0
- package/src/primitives/canvas/semantic_tree_policy.zig +158 -0
- package/src/primitives/canvas/serialization.zig +8 -1
- package/src/primitives/canvas/surface_layout_policy.zig +36 -0
- package/src/primitives/canvas/surface_recipe_policy.zig +231 -0
- package/src/primitives/canvas/terminal_grid.zig +10 -696
- package/src/primitives/canvas/terminal_grid_reference.zig +709 -0
- package/src/primitives/canvas/terminal_paint_policy.zig +191 -0
- package/src/primitives/canvas/text.zig +1 -0
- package/src/primitives/canvas/text_atlas.zig +113 -0
- package/src/primitives/canvas/text_cache_policy.zig +94 -0
- package/src/primitives/canvas/text_document_policy.zig +120 -0
- package/src/primitives/canvas/text_layout.zig +51 -2
- package/src/primitives/canvas/text_layout_cache.zig +29 -0
- package/src/primitives/canvas/text_layout_hash.zig +1 -0
- package/src/primitives/canvas/text_layout_types.zig +3 -0
- package/src/primitives/canvas/text_measure_cache.zig +46 -0
- package/src/primitives/canvas/text_measurement_policy.zig +124 -0
- package/src/primitives/canvas/text_metrics.zig +23 -0
- package/src/primitives/canvas/text_query_policy.zig +156 -0
- package/src/primitives/canvas/text_run_policy.zig +252 -0
- package/src/primitives/canvas/text_scalar_policy.zig +156 -0
- package/src/primitives/canvas/text_span_query_policy.zig +232 -0
- package/src/primitives/canvas/text_spans.zig +280 -8
- package/src/primitives/canvas/text_tests.zig +10 -0
- package/src/primitives/canvas/tokens.zig +38 -0
- package/src/primitives/canvas/ui.zig +250 -83
- package/src/primitives/canvas/ui_markup.zig +139 -33
- package/src/primitives/canvas/ui_markup_compiled.zig +319 -59
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +225 -0
- package/src/primitives/canvas/ui_markup_contract.zig +146 -14
- package/src/primitives/canvas/ui_markup_contract_tests.zig +77 -0
- package/src/primitives/canvas/ui_markup_reflect.zig +56 -0
- package/src/primitives/canvas/ui_markup_tests.zig +116 -0
- package/src/primitives/canvas/ui_markup_view.zig +258 -32
- package/src/primitives/canvas/ui_markup_view_tests.zig +142 -10
- package/src/primitives/canvas/ui_schema.zig +13 -1
- package/src/primitives/canvas/ui_schema_tests.zig +11 -7
- package/src/primitives/canvas/ui_tests.zig +1 -0
- package/src/primitives/canvas/vector.zig +36 -2
- package/src/primitives/canvas/vector_effect_policy.zig +236 -0
- package/src/primitives/canvas/vector_raster_policy.zig +190 -0
- package/src/primitives/canvas/virtual_extent_policy.zig +292 -0
- package/src/primitives/canvas/virtual_extents.zig +99 -3
- package/src/primitives/canvas/virtual_flow_policy.zig +108 -0
- package/src/primitives/canvas/widget_audit_policy.zig +293 -0
- package/src/primitives/canvas/widget_change_policy.zig +298 -0
- package/src/primitives/canvas/widget_invalidation.zig +113 -2
- package/src/primitives/canvas/widget_layout.zig +673 -128
- package/src/primitives/canvas/widget_layout_tests.zig +4 -0
- package/src/primitives/canvas/widget_metric_policy.zig +126 -0
- package/src/primitives/canvas/widget_metrics.zig +45 -6
- package/src/primitives/canvas/widget_paint_policy.zig +166 -0
- package/src/primitives/canvas/widget_paint_walk_policy.zig +252 -0
- package/src/primitives/canvas/widget_presentation_policy.zig +168 -0
- package/src/primitives/canvas/widget_render.zig +744 -74
- package/src/primitives/canvas/widget_render_controls.zig +1217 -133
- package/src/primitives/canvas/widget_render_scroll.zig +11 -3
- package/src/primitives/canvas/widget_render_style.zig +94 -0
- package/src/primitives/canvas/widget_render_surfaces.zig +61 -50
- package/src/primitives/canvas/widget_routing.zig +75 -0
- package/src/primitives/canvas/widget_routing_policy.zig +135 -0
- package/src/primitives/canvas/widget_runtime.zig +20 -1
- package/src/primitives/canvas/widget_semantics.zig +25 -0
- package/src/primitives/canvas/widget_text_input.zig +86 -23
- package/src/primitives/canvas/widget_text_select.zig +1 -0
- package/src/primitives/canvas/widget_tree.zig +8 -1
- package/src/primitives/canvas/widgets.zig +42 -12
- package/src/primitives/canvas/wrapped_layout_policy.zig +104 -0
- package/src/root.zig +21 -0
- package/src/runtime/accessibility_policy.zig +122 -0
- package/src/runtime/api.zig +28 -0
- package/src/runtime/app_dispatch_policy.zig +68 -0
- package/src/runtime/authorization_policy.zig +150 -0
- package/src/runtime/automation_command_policy.zig +241 -0
- package/src/runtime/automation_interaction_policy.zig +107 -0
- package/src/runtime/automation_snapshot.zig +52 -22
- package/src/runtime/automation_snapshot_reference.zig +290 -0
- package/src/runtime/automation_widget_dispatch.zig +267 -355
- package/src/runtime/automation_widget_dispatch_reference.zig +900 -0
- package/src/runtime/blob_policy.zig +58 -0
- package/src/runtime/blob_reference.zig +64 -0
- package/src/runtime/bridge_descriptor_policy.zig +206 -0
- package/src/runtime/builtin_bridge.zig +180 -44
- package/src/runtime/builtin_coordination_policy.zig +121 -0
- package/src/runtime/callback_policy_test_reference.zig +97 -0
- package/src/runtime/canvas_drag_policy.zig +94 -0
- package/src/runtime/canvas_fonts.zig +38 -10
- package/src/runtime/canvas_frame.zig +590 -134
- package/src/runtime/canvas_frame_helpers.zig +1 -0
- package/src/runtime/canvas_hover_policy.zig +131 -0
- package/src/runtime/canvas_images.zig +59 -30
- package/src/runtime/canvas_keyboard_focus_policy.zig +154 -0
- package/src/runtime/canvas_limits.zig +1 -1
- package/src/runtime/canvas_presentation_lifecycle_policy.zig +86 -0
- package/src/runtime/canvas_scene_observation_policy.zig +181 -0
- package/src/runtime/canvas_widget_context_menu.zig +4 -4
- package/src/runtime/canvas_widget_display.zig +110 -9
- package/src/runtime/canvas_widget_events.zig +718 -328
- package/src/runtime/canvas_widget_runtime.zig +437 -81
- package/src/runtime/canvas_widget_scroll_drivers.zig +39 -1
- package/src/runtime/canvas_widget_scroll_tests.zig +31 -0
- package/src/runtime/canvas_widget_state.zig +93 -56
- package/src/runtime/channel_sources.zig +80 -0
- package/src/runtime/command_policy.zig +161 -0
- package/src/runtime/component_policy.zig +83 -0
- package/src/runtime/core.zig +156 -6
- package/src/runtime/desktop_files.zig +189 -0
- package/src/runtime/effects.zig +466 -29
- package/src/runtime/effects_tests.zig +28 -0
- package/src/runtime/file_policy_test_reference.zig +113 -0
- package/src/runtime/flow.zig +418 -341
- package/src/runtime/flow_reference.zig +1426 -0
- package/src/runtime/font_registry_policy.zig +72 -0
- package/src/runtime/frame_profile.zig +24 -33
- package/src/runtime/gpu_surface_events.zig +97 -35
- package/src/runtime/host_event_pump.zig +303 -0
- package/src/runtime/host_event_pump_reference.zig +268 -0
- package/src/runtime/host_flow_policy.zig +155 -0
- package/src/runtime/host_input_regions_policy.zig +156 -0
- package/src/runtime/image_registry_policy.zig +94 -0
- package/src/runtime/input_composition_policy.zig +138 -0
- package/src/runtime/journal_policy.zig +66 -0
- package/src/runtime/journal_reference.zig +53 -0
- package/src/runtime/lifecycle_policy_test_reference.zig +97 -0
- package/src/runtime/markup_development_policy.zig +91 -0
- package/src/runtime/media_surface.zig +40 -1
- package/src/runtime/motion_sampling_policy.zig +159 -0
- package/src/runtime/recording_policy.zig +42 -0
- package/src/runtime/render_animation_policy.zig +206 -0
- package/src/runtime/replay_policy.zig +66 -0
- package/src/runtime/replay_policy_reference.zig +326 -0
- package/src/runtime/replay_progress_policy.zig +64 -0
- package/src/runtime/replay_progress_reference.zig +34 -0
- package/src/runtime/request_policy_test_reference.zig +188 -0
- package/src/runtime/root.zig +13 -0
- package/src/runtime/session_blobs.zig +157 -58
- package/src/runtime/session_blobs_reference.zig +692 -0
- package/src/runtime/session_codec.zig +361 -0
- package/src/runtime/session_codec_reference.zig +1027 -0
- package/src/runtime/session_journal.zig +246 -983
- package/src/runtime/session_record.zig +224 -45
- package/src/runtime/session_replay.zig +157 -415
- package/src/runtime/session_tests.zig +552 -0
- package/src/runtime/shell_admission_policy.zig +225 -0
- package/src/runtime/shell_coordination_policy.zig +138 -0
- package/src/runtime/shell_layout.zig +126 -1
- package/src/runtime/snapshot_policy.zig +60 -0
- package/src/runtime/snapshot_reference.zig +64 -0
- package/src/runtime/state.zig +16 -0
- package/src/runtime/status_validation.zig +190 -0
- package/src/runtime/system_admission_policy.zig +140 -0
- package/src/runtime/system_services.zig +46 -36
- package/src/runtime/tests.zig +1 -0
- package/src/runtime/ts_canvas_hooks.zig +261 -0
- package/src/runtime/ts_canvas_hooks_tests.zig +279 -0
- package/src/runtime/ts_canvas_icons.zig +234 -0
- package/src/runtime/ts_core_host.zig +2325 -411
- package/src/runtime/ts_core_host_tests.zig +1982 -0
- package/src/runtime/ts_test_host.zig +699 -0
- package/src/runtime/ts_ui_app.zig +1087 -45
- package/src/runtime/ui_app.zig +1117 -629
- package/src/runtime/ui_app_provenance.zig +147 -5
- package/src/runtime/ui_app_provenance_reference.zig +370 -0
- package/src/runtime/ui_app_tests.zig +619 -9
- package/src/runtime/ui_app_window_tests.zig +89 -0
- package/src/runtime/view.zig +25 -0
- package/src/runtime/view_canvas.zig +30 -6
- package/src/runtime/view_coordination_policy.zig +147 -0
- package/src/runtime/view_widget_control.zig +51 -14
- package/src/runtime/view_widget_scroll.zig +16 -5
- package/src/runtime/view_widget_text.zig +153 -68
- package/src/runtime/view_widget_tree.zig +460 -56
- package/src/runtime/webview_view_bridge_tests.zig +2 -0
- package/src/runtime/widget_motion_policy.zig +238 -0
- package/src/runtime/window_command_bridge_tests.zig +63 -0
- package/src/runtime/window_lifecycle_policy.zig +127 -0
- package/src/runtime/window_storage.zig +74 -8
- package/src/runtime/window_view_runtime.zig +148 -33
- package/src/runtime/window_views.zig +163 -10
- package/src/tooling/codesign.zig +125 -74
- package/src/tooling/components/identity_tests.zig +62 -36
- package/src/tooling/components/stepper.native +24 -0
- package/src/tooling/components/stepper.zig +0 -19
- package/src/tooling/components/timeline-item.native +22 -0
- package/src/tooling/components/timeline.native +5 -3
- package/src/tooling/components/timeline_item.zig +0 -32
- package/src/tooling/eject_components.zig +76 -8
- package/src/tooling/ios.zig +66 -12
- package/src/tooling/manifest.zig +35 -0
- package/src/tooling/package.zig +85 -1
- package/src/tooling/raw_manifest.zig +6 -0
- package/src/tooling/templates.zig +15 -3
- package/src/tooling/ts_core.zig +13 -3
- package/src/tooling/verbs.zig +22 -0
- package/tools/corewire/build_profile.mjs +54 -0
- package/tools/corewire/contract_intake.ts +303 -0
- package/tools/corewire/contract_intake.zig +82 -0
- package/tools/corewire/core.test.ts +166 -0
- package/tools/corewire/core_abi.zig +51 -0
- package/tools/corewire/core_cases.ts +233 -0
- package/tools/corewire/core_contract.ts +407 -0
- package/tools/corewire/core_emission.ts +136 -0
- package/tools/corewire/core_emission.zig +69 -0
- package/tools/corewire/core_goldens.json +3110 -0
- package/tools/corewire/core_policy.ts +14 -0
- package/tools/corewire/core_policy.zig +48 -0
- package/tools/corewire/core_projection.ts +360 -0
- package/tools/corewire/core_vocabulary.ts +6 -0
- package/tools/corewire/emit.zig +19 -1590
- package/tools/corewire/emit_facade.ts +714 -0
- package/tools/corewire/emit_facade.zig +10 -3752
- package/tools/corewire/emit_mirror.ts +290 -0
- package/tools/corewire/emit_profile.ts +50 -0
- package/tools/corewire/emit_service.ts +331 -0
- package/tools/corewire/emit_service.zig +23 -842
- package/tools/corewire/entry.test.ts +95 -0
- package/tools/corewire/entry_coordination.ts +127 -0
- package/tools/corewire/entry_coordination.zig +190 -0
- package/tools/corewire/facade_templates.ts +85 -0
- package/tools/corewire/filesystem.test.ts +166 -0
- package/tools/corewire/filesystem_coordination.ts +213 -0
- package/tools/corewire/filesystem_coordination.zig +245 -0
- package/tools/corewire/intake.test.ts +35 -0
- package/tools/corewire/intake_cases.ts +55 -0
- package/tools/corewire/intake_goldens.json +12237 -0
- package/tools/corewire/invocation.test.ts +24 -0
- package/tools/corewire/invocation.ts +175 -0
- package/tools/corewire/invocation.zig +136 -0
- package/tools/corewire/invocation_cases.ts +60 -0
- package/tools/corewire/invocation_fixture.ts +33 -0
- package/tools/corewire/invocation_goldens.json +1143 -0
- package/tools/corewire/invocation_tests.zig +111 -0
- package/tools/corewire/invocation_usage.ts +2 -0
- package/tools/corewire/lossless_projection.ts +96 -0
- package/tools/corewire/main.zig +7 -680
- package/tools/corewire/main_reference.zig +415 -0
- package/tools/corewire/mirror_templates.ts +55 -0
- package/tools/corewire/profile.test.ts +248 -0
- package/tools/corewire/profile.zig +56 -0
- package/tools/corewire/profile_emission.ts +202 -0
- package/tools/corewire/profile_library.json +29 -0
- package/tools/corewire/profile_tests.zig +136 -0
- package/tools/corewire/service.test.ts +75 -0
- package/tools/corewire/service_cases.ts +61 -0
- package/tools/corewire/service_contract.zig +40 -146
- package/tools/corewire/service_goldens.json +650 -0
- package/tools/corewire/service_projection.zig +52 -0
- package/tools/corewire/service_templates.ts +14 -0
- package/tools/corewire/shim_rt.zig +9 -0
- package/tools/corewire/sidecar.zig +267 -1438
- package/tools/corewire/emit_profile.zig +0 -521
|
@@ -0,0 +1,1027 @@
|
|
|
1
|
+
//! Independent session payload codec reference.
|
|
2
|
+
const std = @import("std");
|
|
3
|
+
const geometry = @import("geometry");
|
|
4
|
+
const platform = @import("../platform/root.zig");
|
|
5
|
+
const runtime_effects = @import("effects.zig");
|
|
6
|
+
const journal = @import("session_journal.zig");
|
|
7
|
+
const JournalError = journal.JournalError;
|
|
8
|
+
const EffectResultRecord = journal.EffectResultRecord;
|
|
9
|
+
const Header = journal.Header;
|
|
10
|
+
const Checkpoint = journal.Checkpoint;
|
|
11
|
+
const ScreenshotMark = journal.ScreenshotMark;
|
|
12
|
+
const WindowChromeRecord = journal.WindowChromeRecord;
|
|
13
|
+
const WindowChromeSource = journal.WindowChromeSource;
|
|
14
|
+
const End = journal.End;
|
|
15
|
+
const EventDecodeStorage = journal.EventDecodeStorage;
|
|
16
|
+
const max_session_drop_paths = journal.max_session_drop_paths;
|
|
17
|
+
|
|
18
|
+
const WriteCursor = struct {
|
|
19
|
+
buffer: []u8,
|
|
20
|
+
len: usize = 0,
|
|
21
|
+
|
|
22
|
+
fn remaining(self: *const WriteCursor) usize {
|
|
23
|
+
return self.buffer.len - self.len;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
fn writeBytes(self: *WriteCursor, bytes: []const u8) JournalError!void {
|
|
27
|
+
if (bytes.len > self.remaining()) return error.JournalRecordOverBudget;
|
|
28
|
+
@memcpy(self.buffer[self.len .. self.len + bytes.len], bytes);
|
|
29
|
+
self.len += bytes.len;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
fn writeByte(self: *WriteCursor, value: u8) JournalError!void {
|
|
33
|
+
try self.writeBytes(&.{value});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
fn writeBool(self: *WriteCursor, value: bool) JournalError!void {
|
|
37
|
+
try self.writeByte(@intFromBool(value));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
fn writeInt(self: *WriteCursor, comptime T: type, value: T) JournalError!void {
|
|
41
|
+
var bytes: [@divExact(@typeInfo(T).int.bits, 8)]u8 = undefined;
|
|
42
|
+
std.mem.writeInt(T, &bytes, value, .little);
|
|
43
|
+
try self.writeBytes(&bytes);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
fn writeF32(self: *WriteCursor, value: f32) JournalError!void {
|
|
47
|
+
try self.writeInt(u32, @bitCast(value));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
fn writeEnum(self: *WriteCursor, value: anytype) JournalError!void {
|
|
51
|
+
const int_value = @intFromEnum(value);
|
|
52
|
+
if (int_value < 0 or int_value > std.math.maxInt(u8)) return error.JournalRecordOverBudget;
|
|
53
|
+
try self.writeByte(@intCast(int_value));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
fn writeStr(self: *WriteCursor, bytes: []const u8) JournalError!void {
|
|
57
|
+
if (bytes.len > std.math.maxInt(u32)) return error.JournalRecordOverBudget;
|
|
58
|
+
try self.writeInt(u32, @intCast(bytes.len));
|
|
59
|
+
try self.writeBytes(bytes);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const ReadCursor = struct {
|
|
64
|
+
bytes: []const u8,
|
|
65
|
+
pos: usize = 0,
|
|
66
|
+
|
|
67
|
+
fn readBytes(self: *ReadCursor, len: usize) JournalError![]const u8 {
|
|
68
|
+
if (len > self.bytes.len - self.pos) return error.JournalCorrupt;
|
|
69
|
+
const slice = self.bytes[self.pos .. self.pos + len];
|
|
70
|
+
self.pos += len;
|
|
71
|
+
return slice;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
fn readByte(self: *ReadCursor) JournalError!u8 {
|
|
75
|
+
return (try self.readBytes(1))[0];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
fn readBool(self: *ReadCursor) JournalError!bool {
|
|
79
|
+
return switch (try self.readByte()) {
|
|
80
|
+
0 => false,
|
|
81
|
+
1 => true,
|
|
82
|
+
else => error.JournalCorrupt,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
fn readInt(self: *ReadCursor, comptime T: type) JournalError!T {
|
|
87
|
+
const size = @divExact(@typeInfo(T).int.bits, 8);
|
|
88
|
+
const bytes = try self.readBytes(size);
|
|
89
|
+
return std.mem.readInt(T, bytes[0..size], .little);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
fn readF32(self: *ReadCursor) JournalError!f32 {
|
|
93
|
+
return @bitCast(try self.readInt(u32));
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
fn readEnum(self: *ReadCursor, comptime T: type) JournalError!T {
|
|
97
|
+
return std.enums.fromInt(T, try self.readByte()) orelse error.JournalCorrupt;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
fn readStr(self: *ReadCursor) JournalError![]const u8 {
|
|
101
|
+
const len = try self.readInt(u32);
|
|
102
|
+
return self.readBytes(len);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
fn done(self: *const ReadCursor) bool {
|
|
106
|
+
return self.pos == self.bytes.len;
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
// ------------------------------------------------------- event codec
|
|
111
|
+
//
|
|
112
|
+
// Explicit stable tags per event variant (never `@intFromEnum` of the
|
|
113
|
+
// union tag, whose order is free to change).
|
|
114
|
+
|
|
115
|
+
const EventTag = enum(u8) {
|
|
116
|
+
app_start = 1,
|
|
117
|
+
app_activated = 2,
|
|
118
|
+
app_deactivated = 3,
|
|
119
|
+
appearance_changed = 4,
|
|
120
|
+
frame_requested = 5,
|
|
121
|
+
app_shutdown = 6,
|
|
122
|
+
surface_resized = 7,
|
|
123
|
+
window_frame_changed = 8,
|
|
124
|
+
window_focused = 9,
|
|
125
|
+
bridge_message = 10,
|
|
126
|
+
tray_action = 11,
|
|
127
|
+
shortcut = 12,
|
|
128
|
+
native_command = 13,
|
|
129
|
+
menu_command = 14,
|
|
130
|
+
timer = 15,
|
|
131
|
+
wake = 16,
|
|
132
|
+
files_dropped = 17,
|
|
133
|
+
gpu_surface_frame = 18,
|
|
134
|
+
gpu_surface_resized = 19,
|
|
135
|
+
gpu_surface_input = 20,
|
|
136
|
+
gpu_surface_scroll_driver = 21,
|
|
137
|
+
context_menu_action = 22,
|
|
138
|
+
widget_accessibility_action = 23,
|
|
139
|
+
audio = 24,
|
|
140
|
+
video = 25,
|
|
141
|
+
view_focused = 26,
|
|
142
|
+
tray_command = 27,
|
|
143
|
+
notification_command = 28,
|
|
144
|
+
widget_context_menu_action = 29,
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
// The bit assignments below are hand-written wire layout: they are
|
|
148
|
+
// stated in `formatLayoutDescription` (reflection sees the bool fields,
|
|
149
|
+
// not the bits), so changing a bit here means updating that line too.
|
|
150
|
+
fn writeModifiers(cursor: *WriteCursor, modifiers: platform.ShortcutModifiers) JournalError!void {
|
|
151
|
+
var bits: u8 = 0;
|
|
152
|
+
if (modifiers.primary) bits |= 1;
|
|
153
|
+
if (modifiers.command) bits |= 2;
|
|
154
|
+
if (modifiers.control) bits |= 4;
|
|
155
|
+
if (modifiers.option) bits |= 8;
|
|
156
|
+
if (modifiers.shift) bits |= 16;
|
|
157
|
+
try cursor.writeByte(bits);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
fn readModifiers(cursor: *ReadCursor) JournalError!platform.ShortcutModifiers {
|
|
161
|
+
const bits = try cursor.readByte();
|
|
162
|
+
if (bits > 31) return error.JournalCorrupt;
|
|
163
|
+
return .{
|
|
164
|
+
.primary = bits & 1 != 0,
|
|
165
|
+
.command = bits & 2 != 0,
|
|
166
|
+
.control = bits & 4 != 0,
|
|
167
|
+
.option = bits & 8 != 0,
|
|
168
|
+
.shift = bits & 16 != 0,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
fn writeInsets(cursor: *WriteCursor, insets: geometry.InsetsF) JournalError!void {
|
|
173
|
+
try cursor.writeF32(insets.top);
|
|
174
|
+
try cursor.writeF32(insets.right);
|
|
175
|
+
try cursor.writeF32(insets.bottom);
|
|
176
|
+
try cursor.writeF32(insets.left);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
fn readInsets(cursor: *ReadCursor) JournalError!geometry.InsetsF {
|
|
180
|
+
return .{
|
|
181
|
+
.top = try cursor.readF32(),
|
|
182
|
+
.right = try cursor.readF32(),
|
|
183
|
+
.bottom = try cursor.readF32(),
|
|
184
|
+
.left = try cursor.readF32(),
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
fn writeRect(cursor: *WriteCursor, rect: geometry.RectF) JournalError!void {
|
|
189
|
+
try cursor.writeF32(rect.x);
|
|
190
|
+
try cursor.writeF32(rect.y);
|
|
191
|
+
try cursor.writeF32(rect.width);
|
|
192
|
+
try cursor.writeF32(rect.height);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
fn readRect(cursor: *ReadCursor) JournalError!geometry.RectF {
|
|
196
|
+
const x = try cursor.readF32();
|
|
197
|
+
const y = try cursor.readF32();
|
|
198
|
+
const width = try cursor.readF32();
|
|
199
|
+
const height = try cursor.readF32();
|
|
200
|
+
return geometry.RectF.init(x, y, width, height);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/// Encode one platform event into `buffer`, returning the encoded
|
|
204
|
+
/// payload. `gpu_surface_frame` deliberately journals only the fields
|
|
205
|
+
/// dispatch semantics depend on (identity, geometry, frame index and
|
|
206
|
+
/// timestamps, full-repaint) — the rest of that struct is host render
|
|
207
|
+
/// telemetry about the PREVIOUS present, meaningless under replay's
|
|
208
|
+
/// null host; decode fills those with defaults.
|
|
209
|
+
pub fn encodeEvent(event: platform.Event, buffer: []u8) JournalError![]const u8 {
|
|
210
|
+
var cursor = WriteCursor{ .buffer = buffer };
|
|
211
|
+
switch (event) {
|
|
212
|
+
.app_start => try cursor.writeEnum(EventTag.app_start),
|
|
213
|
+
.app_activated => try cursor.writeEnum(EventTag.app_activated),
|
|
214
|
+
.app_deactivated => try cursor.writeEnum(EventTag.app_deactivated),
|
|
215
|
+
.frame_requested => try cursor.writeEnum(EventTag.frame_requested),
|
|
216
|
+
.app_shutdown => try cursor.writeEnum(EventTag.app_shutdown),
|
|
217
|
+
.wake => try cursor.writeEnum(EventTag.wake),
|
|
218
|
+
.appearance_changed => |appearance| {
|
|
219
|
+
try cursor.writeEnum(EventTag.appearance_changed);
|
|
220
|
+
try cursor.writeEnum(appearance.color_scheme);
|
|
221
|
+
try cursor.writeBool(appearance.reduce_motion);
|
|
222
|
+
try cursor.writeBool(appearance.high_contrast);
|
|
223
|
+
},
|
|
224
|
+
.surface_resized => |surface| {
|
|
225
|
+
try cursor.writeEnum(EventTag.surface_resized);
|
|
226
|
+
try cursor.writeInt(u64, surface.id);
|
|
227
|
+
try cursor.writeF32(surface.size.width);
|
|
228
|
+
try cursor.writeF32(surface.size.height);
|
|
229
|
+
try cursor.writeF32(surface.scale_factor);
|
|
230
|
+
try writeInsets(&cursor, surface.safe_area_insets);
|
|
231
|
+
try writeInsets(&cursor, surface.keyboard_insets);
|
|
232
|
+
// `native_handle` is process-local and never journaled.
|
|
233
|
+
},
|
|
234
|
+
.window_frame_changed => |state| {
|
|
235
|
+
try cursor.writeEnum(EventTag.window_frame_changed);
|
|
236
|
+
try cursor.writeInt(u64, state.id);
|
|
237
|
+
try cursor.writeStr(state.label);
|
|
238
|
+
try cursor.writeStr(state.title);
|
|
239
|
+
try writeRect(&cursor, state.frame);
|
|
240
|
+
try cursor.writeF32(state.scale_factor);
|
|
241
|
+
try cursor.writeBool(state.open);
|
|
242
|
+
try cursor.writeBool(state.focused);
|
|
243
|
+
try cursor.writeBool(state.maximized);
|
|
244
|
+
try cursor.writeBool(state.fullscreen);
|
|
245
|
+
// v6: alive-but-policy-hidden (`close_policy = .hide`).
|
|
246
|
+
try cursor.writeBool(state.hidden);
|
|
247
|
+
},
|
|
248
|
+
.window_focused => |window_id| {
|
|
249
|
+
try cursor.writeEnum(EventTag.window_focused);
|
|
250
|
+
try cursor.writeInt(u64, window_id);
|
|
251
|
+
},
|
|
252
|
+
.view_focused => |focus| {
|
|
253
|
+
try cursor.writeEnum(EventTag.view_focused);
|
|
254
|
+
try cursor.writeInt(u64, focus.window_id);
|
|
255
|
+
try cursor.writeStr(focus.label);
|
|
256
|
+
},
|
|
257
|
+
.bridge_message => |message| {
|
|
258
|
+
try cursor.writeEnum(EventTag.bridge_message);
|
|
259
|
+
try cursor.writeStr(message.bytes);
|
|
260
|
+
try cursor.writeStr(message.origin);
|
|
261
|
+
try cursor.writeInt(u64, message.window_id);
|
|
262
|
+
try cursor.writeStr(message.webview_label);
|
|
263
|
+
},
|
|
264
|
+
.tray_action => |action| {
|
|
265
|
+
try cursor.writeEnum(EventTag.tray_action);
|
|
266
|
+
try cursor.writeInt(u32, action.status_item_id);
|
|
267
|
+
try cursor.writeInt(u32, action.item_id);
|
|
268
|
+
},
|
|
269
|
+
.shortcut => |shortcut| {
|
|
270
|
+
try cursor.writeEnum(EventTag.shortcut);
|
|
271
|
+
try cursor.writeStr(shortcut.id);
|
|
272
|
+
try cursor.writeStr(shortcut.key);
|
|
273
|
+
try writeModifiers(&cursor, shortcut.modifiers);
|
|
274
|
+
try cursor.writeInt(u64, shortcut.window_id);
|
|
275
|
+
},
|
|
276
|
+
.native_command => |command| {
|
|
277
|
+
try cursor.writeEnum(EventTag.native_command);
|
|
278
|
+
try cursor.writeStr(command.name);
|
|
279
|
+
try cursor.writeInt(u64, command.window_id);
|
|
280
|
+
try cursor.writeStr(command.view_label);
|
|
281
|
+
},
|
|
282
|
+
.menu_command => |command| {
|
|
283
|
+
try cursor.writeEnum(EventTag.menu_command);
|
|
284
|
+
try cursor.writeStr(command.name);
|
|
285
|
+
try cursor.writeInt(u64, command.window_id);
|
|
286
|
+
},
|
|
287
|
+
.tray_command => |command| {
|
|
288
|
+
try cursor.writeEnum(EventTag.tray_command);
|
|
289
|
+
try cursor.writeStr(command.name);
|
|
290
|
+
try cursor.writeInt(u64, command.window_id);
|
|
291
|
+
try cursor.writeInt(u32, command.status_item_id);
|
|
292
|
+
},
|
|
293
|
+
.notification_command => |command| {
|
|
294
|
+
try cursor.writeEnum(EventTag.notification_command);
|
|
295
|
+
try cursor.writeStr(command.name);
|
|
296
|
+
try cursor.writeInt(u64, command.window_id);
|
|
297
|
+
},
|
|
298
|
+
.timer => |timer| {
|
|
299
|
+
try cursor.writeEnum(EventTag.timer);
|
|
300
|
+
try cursor.writeInt(u64, timer.id);
|
|
301
|
+
try cursor.writeInt(u64, timer.timestamp_ns);
|
|
302
|
+
},
|
|
303
|
+
// Recorded for stream fidelity. On replay this event pairs with
|
|
304
|
+
// its complete audio EFFECT record and delivers the recorded Msg
|
|
305
|
+
// synchronously, preserving the live rebuild/query boundary.
|
|
306
|
+
.audio => |audio| {
|
|
307
|
+
try cursor.writeEnum(EventTag.audio);
|
|
308
|
+
try cursor.writeEnum(audio.kind);
|
|
309
|
+
try cursor.writeInt(u64, audio.position_ms);
|
|
310
|
+
try cursor.writeInt(u64, audio.duration_ms);
|
|
311
|
+
try cursor.writeBool(audio.playing);
|
|
312
|
+
try cursor.writeBool(audio.buffering);
|
|
313
|
+
try cursor.writeBytes(&audio.bands);
|
|
314
|
+
},
|
|
315
|
+
// Recorded for stream fidelity like `.audio`. On replay the
|
|
316
|
+
// journaled video EFFECT records are the Msg source; the
|
|
317
|
+
// platform events steer only the channel MIRRORS (the house
|
|
318
|
+
// chrome's render state for handler-less playbacks), gated by
|
|
319
|
+
// the load token exactly as live (`Effects.takeVideoMsg`).
|
|
320
|
+
.video => |video| {
|
|
321
|
+
try cursor.writeEnum(EventTag.video);
|
|
322
|
+
try cursor.writeEnum(video.kind);
|
|
323
|
+
try cursor.writeInt(u64, video.token);
|
|
324
|
+
try cursor.writeInt(u64, video.position_ms);
|
|
325
|
+
try cursor.writeInt(u64, video.duration_ms);
|
|
326
|
+
try cursor.writeBool(video.playing);
|
|
327
|
+
try cursor.writeBool(video.buffering);
|
|
328
|
+
try cursor.writeInt(u64, video.width);
|
|
329
|
+
try cursor.writeInt(u64, video.height);
|
|
330
|
+
},
|
|
331
|
+
.files_dropped => |drop| {
|
|
332
|
+
try cursor.writeEnum(EventTag.files_dropped);
|
|
333
|
+
try cursor.writeInt(u64, drop.window_id);
|
|
334
|
+
try cursor.writeStr(drop.view_label);
|
|
335
|
+
try cursor.writeBool(drop.point != null);
|
|
336
|
+
if (drop.point) |point| {
|
|
337
|
+
try cursor.writeF32(point.x);
|
|
338
|
+
try cursor.writeF32(point.y);
|
|
339
|
+
}
|
|
340
|
+
if (drop.paths.len > max_session_drop_paths) return error.JournalRecordOverBudget;
|
|
341
|
+
try cursor.writeInt(u16, @intCast(drop.paths.len));
|
|
342
|
+
for (drop.paths) |path| try cursor.writeStr(path);
|
|
343
|
+
},
|
|
344
|
+
// This arm journals a deliberate SUBSET of the frame event (the
|
|
345
|
+
// fields dispatch semantics depend on — see the fn doc). The
|
|
346
|
+
// subset is stated by hand in `formatLayoutDescription`, so
|
|
347
|
+
// journaling another field here means adding it to that line in
|
|
348
|
+
// the same change.
|
|
349
|
+
.gpu_surface_frame => |frame| {
|
|
350
|
+
try cursor.writeEnum(EventTag.gpu_surface_frame);
|
|
351
|
+
try cursor.writeInt(u64, frame.window_id);
|
|
352
|
+
try cursor.writeStr(frame.label);
|
|
353
|
+
try cursor.writeF32(frame.size.width);
|
|
354
|
+
try cursor.writeF32(frame.size.height);
|
|
355
|
+
try cursor.writeF32(frame.scale_factor);
|
|
356
|
+
try cursor.writeInt(u64, frame.frame_index);
|
|
357
|
+
try cursor.writeInt(u64, frame.timestamp_ns);
|
|
358
|
+
try cursor.writeInt(u64, frame.frame_interval_ns);
|
|
359
|
+
try cursor.writeInt(u64, frame.input_timestamp_ns);
|
|
360
|
+
try cursor.writeBool(frame.canvas_frame_full_repaint);
|
|
361
|
+
},
|
|
362
|
+
.gpu_surface_resized => |resize| {
|
|
363
|
+
try cursor.writeEnum(EventTag.gpu_surface_resized);
|
|
364
|
+
try cursor.writeInt(u64, resize.window_id);
|
|
365
|
+
try cursor.writeStr(resize.label);
|
|
366
|
+
try writeRect(&cursor, resize.frame);
|
|
367
|
+
try cursor.writeF32(resize.scale_factor);
|
|
368
|
+
},
|
|
369
|
+
.gpu_surface_input => |input| {
|
|
370
|
+
try cursor.writeEnum(EventTag.gpu_surface_input);
|
|
371
|
+
try cursor.writeInt(u64, input.window_id);
|
|
372
|
+
try cursor.writeStr(input.label);
|
|
373
|
+
try cursor.writeEnum(input.kind);
|
|
374
|
+
try cursor.writeInt(u64, input.timestamp_ns);
|
|
375
|
+
try cursor.writeInt(u64, input.pointer_id);
|
|
376
|
+
try cursor.writeF32(input.x);
|
|
377
|
+
try cursor.writeF32(input.y);
|
|
378
|
+
try cursor.writeInt(i32, input.button);
|
|
379
|
+
try cursor.writeF32(input.pressure);
|
|
380
|
+
try cursor.writeF32(input.delta_x);
|
|
381
|
+
try cursor.writeF32(input.delta_y);
|
|
382
|
+
try cursor.writeBool(input.scroll_is_detented);
|
|
383
|
+
try cursor.writeStr(input.key);
|
|
384
|
+
try cursor.writeStr(input.text);
|
|
385
|
+
try cursor.writeBool(input.composition_cursor != null);
|
|
386
|
+
if (input.composition_cursor) |composition_cursor| {
|
|
387
|
+
try cursor.writeInt(u64, @intCast(composition_cursor));
|
|
388
|
+
}
|
|
389
|
+
try writeModifiers(&cursor, input.modifiers);
|
|
390
|
+
// v5: the pinch magnification delta (0 on non-pinch kinds).
|
|
391
|
+
try cursor.writeF32(input.scale);
|
|
392
|
+
},
|
|
393
|
+
.gpu_surface_scroll_driver => |driver| {
|
|
394
|
+
try cursor.writeEnum(EventTag.gpu_surface_scroll_driver);
|
|
395
|
+
try cursor.writeInt(u64, driver.window_id);
|
|
396
|
+
try cursor.writeStr(driver.label);
|
|
397
|
+
try cursor.writeInt(u64, driver.driver_id);
|
|
398
|
+
try cursor.writeF32(driver.offset_x);
|
|
399
|
+
try cursor.writeF32(driver.offset_y);
|
|
400
|
+
try cursor.writeInt(u64, driver.timestamp_ns);
|
|
401
|
+
},
|
|
402
|
+
.context_menu_action => |action| {
|
|
403
|
+
try cursor.writeEnum(EventTag.context_menu_action);
|
|
404
|
+
try cursor.writeInt(u64, action.window_id);
|
|
405
|
+
try cursor.writeStr(action.view_label);
|
|
406
|
+
try cursor.writeInt(u64, action.token);
|
|
407
|
+
try cursor.writeInt(u32, action.item_id);
|
|
408
|
+
},
|
|
409
|
+
.widget_context_menu_action => |action| {
|
|
410
|
+
try cursor.writeEnum(EventTag.widget_context_menu_action);
|
|
411
|
+
try cursor.writeInt(u64, action.window_id);
|
|
412
|
+
try cursor.writeStr(action.label);
|
|
413
|
+
try cursor.writeInt(u64, action.id);
|
|
414
|
+
try cursor.writeInt(u32, action.item_index);
|
|
415
|
+
},
|
|
416
|
+
.widget_accessibility_action => |action| {
|
|
417
|
+
try cursor.writeEnum(EventTag.widget_accessibility_action);
|
|
418
|
+
try cursor.writeInt(u64, action.window_id);
|
|
419
|
+
try cursor.writeStr(action.label);
|
|
420
|
+
try cursor.writeInt(u64, action.id);
|
|
421
|
+
// The verb rides i32, not the u8 every other enum takes — a
|
|
422
|
+
// hand-written width stated in `formatLayoutDescription`.
|
|
423
|
+
try cursor.writeInt(i32, @intFromEnum(action.action));
|
|
424
|
+
try cursor.writeStr(action.text);
|
|
425
|
+
try cursor.writeBool(action.selection != null);
|
|
426
|
+
if (action.selection) |selection| {
|
|
427
|
+
try cursor.writeInt(u64, @intCast(selection.start));
|
|
428
|
+
try cursor.writeInt(u64, @intCast(selection.end));
|
|
429
|
+
}
|
|
430
|
+
},
|
|
431
|
+
}
|
|
432
|
+
return buffer[0..cursor.len];
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
/// Decode one event payload. Returned slices reference `bytes` (and
|
|
436
|
+
/// `storage` for path lists) — valid until the caller's buffers move.
|
|
437
|
+
pub fn decodeEvent(bytes: []const u8, storage: *EventDecodeStorage) JournalError!platform.Event {
|
|
438
|
+
var cursor = ReadCursor{ .bytes = bytes };
|
|
439
|
+
const tag = try cursor.readEnum(EventTag);
|
|
440
|
+
const event: platform.Event = switch (tag) {
|
|
441
|
+
.app_start => .app_start,
|
|
442
|
+
.app_activated => .app_activated,
|
|
443
|
+
.app_deactivated => .app_deactivated,
|
|
444
|
+
.frame_requested => .frame_requested,
|
|
445
|
+
.app_shutdown => .app_shutdown,
|
|
446
|
+
.wake => .wake,
|
|
447
|
+
.appearance_changed => .{ .appearance_changed = .{
|
|
448
|
+
.color_scheme = try cursor.readEnum(platform.ColorScheme),
|
|
449
|
+
.reduce_motion = try cursor.readBool(),
|
|
450
|
+
.high_contrast = try cursor.readBool(),
|
|
451
|
+
} },
|
|
452
|
+
.surface_resized => blk: {
|
|
453
|
+
const id = try cursor.readInt(u64);
|
|
454
|
+
const width = try cursor.readF32();
|
|
455
|
+
const height = try cursor.readF32();
|
|
456
|
+
const scale_factor = try cursor.readF32();
|
|
457
|
+
const safe_area = try readInsets(&cursor);
|
|
458
|
+
const keyboard = try readInsets(&cursor);
|
|
459
|
+
break :blk .{ .surface_resized = .{
|
|
460
|
+
.id = id,
|
|
461
|
+
.size = geometry.SizeF.init(width, height),
|
|
462
|
+
.scale_factor = scale_factor,
|
|
463
|
+
.safe_area_insets = safe_area,
|
|
464
|
+
.keyboard_insets = keyboard,
|
|
465
|
+
} };
|
|
466
|
+
},
|
|
467
|
+
.window_frame_changed => blk: {
|
|
468
|
+
const id = try cursor.readInt(u64);
|
|
469
|
+
const label = try cursor.readStr();
|
|
470
|
+
const title = try cursor.readStr();
|
|
471
|
+
const frame = try readRect(&cursor);
|
|
472
|
+
const scale_factor = try cursor.readF32();
|
|
473
|
+
break :blk .{ .window_frame_changed = .{
|
|
474
|
+
.id = id,
|
|
475
|
+
.label = label,
|
|
476
|
+
.title = title,
|
|
477
|
+
.frame = frame,
|
|
478
|
+
.scale_factor = scale_factor,
|
|
479
|
+
.open = try cursor.readBool(),
|
|
480
|
+
.focused = try cursor.readBool(),
|
|
481
|
+
.maximized = try cursor.readBool(),
|
|
482
|
+
.fullscreen = try cursor.readBool(),
|
|
483
|
+
.hidden = try cursor.readBool(),
|
|
484
|
+
} };
|
|
485
|
+
},
|
|
486
|
+
.window_focused => .{ .window_focused = try cursor.readInt(u64) },
|
|
487
|
+
.view_focused => .{ .view_focused = .{
|
|
488
|
+
.window_id = try cursor.readInt(u64),
|
|
489
|
+
.label = try cursor.readStr(),
|
|
490
|
+
} },
|
|
491
|
+
.bridge_message => blk: {
|
|
492
|
+
const message_bytes = try cursor.readStr();
|
|
493
|
+
const origin = try cursor.readStr();
|
|
494
|
+
const window_id = try cursor.readInt(u64);
|
|
495
|
+
const webview_label = try cursor.readStr();
|
|
496
|
+
break :blk .{ .bridge_message = .{
|
|
497
|
+
.bytes = message_bytes,
|
|
498
|
+
.origin = origin,
|
|
499
|
+
.window_id = window_id,
|
|
500
|
+
.webview_label = webview_label,
|
|
501
|
+
} };
|
|
502
|
+
},
|
|
503
|
+
.tray_action => .{ .tray_action = .{
|
|
504
|
+
.status_item_id = try cursor.readInt(u32),
|
|
505
|
+
.item_id = try cursor.readInt(u32),
|
|
506
|
+
} },
|
|
507
|
+
.shortcut => blk: {
|
|
508
|
+
const id = try cursor.readStr();
|
|
509
|
+
const key = try cursor.readStr();
|
|
510
|
+
const modifiers = try readModifiers(&cursor);
|
|
511
|
+
break :blk .{ .shortcut = .{
|
|
512
|
+
.id = id,
|
|
513
|
+
.key = key,
|
|
514
|
+
.modifiers = modifiers,
|
|
515
|
+
.window_id = try cursor.readInt(u64),
|
|
516
|
+
} };
|
|
517
|
+
},
|
|
518
|
+
.native_command => blk: {
|
|
519
|
+
const name = try cursor.readStr();
|
|
520
|
+
const window_id = try cursor.readInt(u64);
|
|
521
|
+
break :blk .{ .native_command = .{
|
|
522
|
+
.name = name,
|
|
523
|
+
.window_id = window_id,
|
|
524
|
+
.view_label = try cursor.readStr(),
|
|
525
|
+
} };
|
|
526
|
+
},
|
|
527
|
+
.menu_command => blk: {
|
|
528
|
+
const name = try cursor.readStr();
|
|
529
|
+
break :blk .{ .menu_command = .{
|
|
530
|
+
.name = name,
|
|
531
|
+
.window_id = try cursor.readInt(u64),
|
|
532
|
+
} };
|
|
533
|
+
},
|
|
534
|
+
.tray_command => blk: {
|
|
535
|
+
const name = try cursor.readStr();
|
|
536
|
+
break :blk .{ .tray_command = .{
|
|
537
|
+
.name = name,
|
|
538
|
+
.window_id = try cursor.readInt(u64),
|
|
539
|
+
.status_item_id = try cursor.readInt(u32),
|
|
540
|
+
} };
|
|
541
|
+
},
|
|
542
|
+
.notification_command => blk: {
|
|
543
|
+
const name = try cursor.readStr();
|
|
544
|
+
break :blk .{ .notification_command = .{
|
|
545
|
+
.name = name,
|
|
546
|
+
.window_id = try cursor.readInt(u64),
|
|
547
|
+
} };
|
|
548
|
+
},
|
|
549
|
+
.timer => blk: {
|
|
550
|
+
const id = try cursor.readInt(u64);
|
|
551
|
+
break :blk .{ .timer = .{
|
|
552
|
+
.id = id,
|
|
553
|
+
.timestamp_ns = try cursor.readInt(u64),
|
|
554
|
+
} };
|
|
555
|
+
},
|
|
556
|
+
.audio => blk: {
|
|
557
|
+
const kind = try cursor.readEnum(platform.AudioEventKind);
|
|
558
|
+
var decoded: platform.AudioEvent = .{
|
|
559
|
+
.kind = kind,
|
|
560
|
+
.position_ms = try cursor.readInt(u64),
|
|
561
|
+
.duration_ms = try cursor.readInt(u64),
|
|
562
|
+
.playing = try cursor.readBool(),
|
|
563
|
+
.buffering = try cursor.readBool(),
|
|
564
|
+
};
|
|
565
|
+
@memcpy(&decoded.bands, try cursor.readBytes(decoded.bands.len));
|
|
566
|
+
break :blk .{ .audio = decoded };
|
|
567
|
+
},
|
|
568
|
+
.video => blk: {
|
|
569
|
+
const kind = try cursor.readEnum(platform.VideoEventKind);
|
|
570
|
+
break :blk .{ .video = .{
|
|
571
|
+
.kind = kind,
|
|
572
|
+
.token = try cursor.readInt(u64),
|
|
573
|
+
.position_ms = try cursor.readInt(u64),
|
|
574
|
+
.duration_ms = try cursor.readInt(u64),
|
|
575
|
+
.playing = try cursor.readBool(),
|
|
576
|
+
.buffering = try cursor.readBool(),
|
|
577
|
+
.width = try cursor.readInt(u64),
|
|
578
|
+
.height = try cursor.readInt(u64),
|
|
579
|
+
} };
|
|
580
|
+
},
|
|
581
|
+
.files_dropped => blk: {
|
|
582
|
+
const window_id = try cursor.readInt(u64);
|
|
583
|
+
const view_label = try cursor.readStr();
|
|
584
|
+
var point: ?geometry.PointF = null;
|
|
585
|
+
if (try cursor.readBool()) {
|
|
586
|
+
const x = try cursor.readF32();
|
|
587
|
+
const y = try cursor.readF32();
|
|
588
|
+
point = geometry.PointF.init(x, y);
|
|
589
|
+
}
|
|
590
|
+
const count = try cursor.readInt(u16);
|
|
591
|
+
if (count > max_session_drop_paths) return error.JournalCorrupt;
|
|
592
|
+
for (0..count) |index| {
|
|
593
|
+
storage.drop_paths[index] = try cursor.readStr();
|
|
594
|
+
}
|
|
595
|
+
break :blk .{ .files_dropped = .{
|
|
596
|
+
.window_id = window_id,
|
|
597
|
+
.view_label = view_label,
|
|
598
|
+
.point = point,
|
|
599
|
+
.paths = storage.drop_paths[0..count],
|
|
600
|
+
} };
|
|
601
|
+
},
|
|
602
|
+
.gpu_surface_frame => blk: {
|
|
603
|
+
const window_id = try cursor.readInt(u64);
|
|
604
|
+
const label = try cursor.readStr();
|
|
605
|
+
const width = try cursor.readF32();
|
|
606
|
+
const height = try cursor.readF32();
|
|
607
|
+
break :blk .{ .gpu_surface_frame = .{
|
|
608
|
+
.window_id = window_id,
|
|
609
|
+
.label = label,
|
|
610
|
+
.size = geometry.SizeF.init(width, height),
|
|
611
|
+
.scale_factor = try cursor.readF32(),
|
|
612
|
+
.frame_index = try cursor.readInt(u64),
|
|
613
|
+
.timestamp_ns = try cursor.readInt(u64),
|
|
614
|
+
.frame_interval_ns = try cursor.readInt(u64),
|
|
615
|
+
.input_timestamp_ns = try cursor.readInt(u64),
|
|
616
|
+
.canvas_frame_full_repaint = try cursor.readBool(),
|
|
617
|
+
} };
|
|
618
|
+
},
|
|
619
|
+
.gpu_surface_resized => blk: {
|
|
620
|
+
const window_id = try cursor.readInt(u64);
|
|
621
|
+
const label = try cursor.readStr();
|
|
622
|
+
const frame = try readRect(&cursor);
|
|
623
|
+
break :blk .{ .gpu_surface_resized = .{
|
|
624
|
+
.window_id = window_id,
|
|
625
|
+
.label = label,
|
|
626
|
+
.frame = frame,
|
|
627
|
+
.scale_factor = try cursor.readF32(),
|
|
628
|
+
} };
|
|
629
|
+
},
|
|
630
|
+
.gpu_surface_input => blk: {
|
|
631
|
+
const window_id = try cursor.readInt(u64);
|
|
632
|
+
const label = try cursor.readStr();
|
|
633
|
+
const kind = try cursor.readEnum(platform.GpuSurfaceInputKind);
|
|
634
|
+
const timestamp_ns = try cursor.readInt(u64);
|
|
635
|
+
const pointer_id = try cursor.readInt(u64);
|
|
636
|
+
const x = try cursor.readF32();
|
|
637
|
+
const y = try cursor.readF32();
|
|
638
|
+
const button = try cursor.readInt(i32);
|
|
639
|
+
const pressure = try cursor.readF32();
|
|
640
|
+
const delta_x = try cursor.readF32();
|
|
641
|
+
const delta_y = try cursor.readF32();
|
|
642
|
+
const scroll_is_detented = try cursor.readBool();
|
|
643
|
+
const key = try cursor.readStr();
|
|
644
|
+
const text = try cursor.readStr();
|
|
645
|
+
var composition_cursor: ?usize = null;
|
|
646
|
+
if (try cursor.readBool()) {
|
|
647
|
+
composition_cursor = std.math.cast(usize, try cursor.readInt(u64)) orelse return error.JournalCorrupt;
|
|
648
|
+
}
|
|
649
|
+
break :blk .{
|
|
650
|
+
.gpu_surface_input = .{
|
|
651
|
+
.window_id = window_id,
|
|
652
|
+
.label = label,
|
|
653
|
+
.kind = kind,
|
|
654
|
+
.timestamp_ns = timestamp_ns,
|
|
655
|
+
.pointer_id = pointer_id,
|
|
656
|
+
.x = x,
|
|
657
|
+
.y = y,
|
|
658
|
+
.button = button,
|
|
659
|
+
.pressure = pressure,
|
|
660
|
+
.delta_x = delta_x,
|
|
661
|
+
.delta_y = delta_y,
|
|
662
|
+
.scroll_is_detented = scroll_is_detented,
|
|
663
|
+
.key = key,
|
|
664
|
+
.text = text,
|
|
665
|
+
.composition_cursor = composition_cursor,
|
|
666
|
+
.modifiers = try readModifiers(&cursor),
|
|
667
|
+
// v5: the pinch magnification delta (0 on non-pinch kinds).
|
|
668
|
+
.scale = try cursor.readF32(),
|
|
669
|
+
},
|
|
670
|
+
};
|
|
671
|
+
},
|
|
672
|
+
.gpu_surface_scroll_driver => blk: {
|
|
673
|
+
const window_id = try cursor.readInt(u64);
|
|
674
|
+
const label = try cursor.readStr();
|
|
675
|
+
const driver_id = try cursor.readInt(u64);
|
|
676
|
+
const offset_x = try cursor.readF32();
|
|
677
|
+
const offset_y = try cursor.readF32();
|
|
678
|
+
break :blk .{ .gpu_surface_scroll_driver = .{
|
|
679
|
+
.window_id = window_id,
|
|
680
|
+
.label = label,
|
|
681
|
+
.driver_id = driver_id,
|
|
682
|
+
.offset_x = offset_x,
|
|
683
|
+
.offset_y = offset_y,
|
|
684
|
+
.timestamp_ns = try cursor.readInt(u64),
|
|
685
|
+
} };
|
|
686
|
+
},
|
|
687
|
+
.context_menu_action => blk: {
|
|
688
|
+
const window_id = try cursor.readInt(u64);
|
|
689
|
+
const view_label = try cursor.readStr();
|
|
690
|
+
const token = try cursor.readInt(u64);
|
|
691
|
+
break :blk .{ .context_menu_action = .{
|
|
692
|
+
.window_id = window_id,
|
|
693
|
+
.view_label = view_label,
|
|
694
|
+
.token = token,
|
|
695
|
+
.item_id = try cursor.readInt(u32),
|
|
696
|
+
} };
|
|
697
|
+
},
|
|
698
|
+
.widget_context_menu_action => blk: {
|
|
699
|
+
const window_id = try cursor.readInt(u64);
|
|
700
|
+
const label = try cursor.readStr();
|
|
701
|
+
const id = try cursor.readInt(u64);
|
|
702
|
+
const item_index = try cursor.readInt(u32);
|
|
703
|
+
break :blk .{ .widget_context_menu_action = .{ .window_id = window_id, .label = label, .id = id, .item_index = item_index } };
|
|
704
|
+
},
|
|
705
|
+
.widget_accessibility_action => blk: {
|
|
706
|
+
const window_id = try cursor.readInt(u64);
|
|
707
|
+
const label = try cursor.readStr();
|
|
708
|
+
const id = try cursor.readInt(u64);
|
|
709
|
+
const action = std.enums.fromInt(platform.WidgetAccessibilityActionKind, try cursor.readInt(i32)) orelse return error.JournalCorrupt;
|
|
710
|
+
const text = try cursor.readStr();
|
|
711
|
+
var selection: ?platform.WidgetAccessibilityTextRange = null;
|
|
712
|
+
if (try cursor.readBool()) {
|
|
713
|
+
const start = std.math.cast(usize, try cursor.readInt(u64)) orelse return error.JournalCorrupt;
|
|
714
|
+
const end = std.math.cast(usize, try cursor.readInt(u64)) orelse return error.JournalCorrupt;
|
|
715
|
+
selection = .{ .start = start, .end = end };
|
|
716
|
+
}
|
|
717
|
+
break :blk .{ .widget_accessibility_action = .{
|
|
718
|
+
.window_id = window_id,
|
|
719
|
+
.label = label,
|
|
720
|
+
.id = id,
|
|
721
|
+
.action = action,
|
|
722
|
+
.text = text,
|
|
723
|
+
.selection = selection,
|
|
724
|
+
} };
|
|
725
|
+
},
|
|
726
|
+
};
|
|
727
|
+
if (!cursor.done()) return error.JournalCorrupt;
|
|
728
|
+
return event;
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
// ------------------------------------------------------ effect codec
|
|
732
|
+
|
|
733
|
+
pub fn encodeEffect(record: EffectResultRecord, buffer: []u8) JournalError![]const u8 {
|
|
734
|
+
var cursor = WriteCursor{ .buffer = buffer };
|
|
735
|
+
try cursor.writeEnum(record.kind);
|
|
736
|
+
try cursor.writeInt(u64, record.key);
|
|
737
|
+
try cursor.writeStr(record.payload);
|
|
738
|
+
try cursor.writeStr(record.stderr_tail);
|
|
739
|
+
try cursor.writeBool(record.truncated);
|
|
740
|
+
try cursor.writeInt(u32, record.dropped);
|
|
741
|
+
try cursor.writeInt(i32, record.code);
|
|
742
|
+
try cursor.writeEnum(record.exit_reason);
|
|
743
|
+
try cursor.writeBool(record.output_truncated);
|
|
744
|
+
try cursor.writeBool(record.stderr_truncated);
|
|
745
|
+
try cursor.writeInt(u16, record.status);
|
|
746
|
+
try cursor.writeEnum(record.fetch_outcome);
|
|
747
|
+
try cursor.writeEnum(record.file_op);
|
|
748
|
+
try cursor.writeEnum(record.file_event);
|
|
749
|
+
try cursor.writeEnum(record.file_outcome);
|
|
750
|
+
try cursor.writeInt(u64, record.file_total);
|
|
751
|
+
try cursor.writeInt(i64, record.file_mtime_ms);
|
|
752
|
+
try cursor.writeBool(record.file_exists);
|
|
753
|
+
try cursor.writeBool(record.file_rejected_admission);
|
|
754
|
+
try cursor.writeEnum(record.clipboard_op);
|
|
755
|
+
try cursor.writeEnum(record.clipboard_outcome);
|
|
756
|
+
try cursor.writeInt(u64, record.timer_timestamp_ns);
|
|
757
|
+
try cursor.writeEnum(record.timer_outcome);
|
|
758
|
+
try cursor.writeInt(i64, record.clock_wall_ms);
|
|
759
|
+
try cursor.writeEnum(record.audio_kind);
|
|
760
|
+
try cursor.writeInt(u64, record.audio_position_ms);
|
|
761
|
+
try cursor.writeInt(u64, record.audio_duration_ms);
|
|
762
|
+
try cursor.writeBool(record.audio_playing);
|
|
763
|
+
try cursor.writeBool(record.audio_buffering);
|
|
764
|
+
try cursor.writeBytes(&record.file_blob_hash);
|
|
765
|
+
try cursor.writeInt(u64, record.file_blob_len);
|
|
766
|
+
try cursor.writeBytes(&record.audio_bands);
|
|
767
|
+
// v7: image terminals — outcome, decoded dimensions, and the blob
|
|
768
|
+
// store content address of the journaled source bytes.
|
|
769
|
+
try cursor.writeEnum(record.image_outcome);
|
|
770
|
+
try cursor.writeInt(u64, record.image_width);
|
|
771
|
+
try cursor.writeInt(u64, record.image_height);
|
|
772
|
+
try cursor.writeBytes(&record.image_blob_hash);
|
|
773
|
+
try cursor.writeInt(u64, record.image_blob_len);
|
|
774
|
+
// v8: channel events — the event kind and the occupancy's
|
|
775
|
+
// cumulative drop total (post bytes ride `payload` inline;
|
|
776
|
+
// dropped_pending rides the shared `dropped` field).
|
|
777
|
+
try cursor.writeEnum(record.channel_kind);
|
|
778
|
+
try cursor.writeInt(u32, record.channel_dropped_total);
|
|
779
|
+
// Video terminals — the delivered event, verbatim (fingerprint
|
|
780
|
+
// era: these fields move the format identity through reflection).
|
|
781
|
+
try cursor.writeEnum(record.video_kind);
|
|
782
|
+
try cursor.writeInt(u64, record.video_position_ms);
|
|
783
|
+
try cursor.writeInt(u64, record.video_duration_ms);
|
|
784
|
+
try cursor.writeBool(record.video_playing);
|
|
785
|
+
try cursor.writeBool(record.video_buffering);
|
|
786
|
+
try cursor.writeInt(u64, record.video_width);
|
|
787
|
+
try cursor.writeInt(u64, record.video_height);
|
|
788
|
+
// The producing load's identity, how replay routes the record
|
|
789
|
+
// (`EffectResultRecord.video_token`).
|
|
790
|
+
try cursor.writeInt(u64, record.video_token);
|
|
791
|
+
// `.video_load` records: the recording host's cascade resolution.
|
|
792
|
+
try cursor.writeEnum(record.video_source);
|
|
793
|
+
// `.video` records: whether the delivery dispatched a Msg.
|
|
794
|
+
try cursor.writeBool(record.video_handled);
|
|
795
|
+
// Pty events — the event kind, the terminating signal and refused
|
|
796
|
+
// writes, and the blob store content address of a journaled output
|
|
797
|
+
// batch (exit code and reason ride the shared fields).
|
|
798
|
+
try cursor.writeEnum(record.pty_kind);
|
|
799
|
+
try cursor.writeInt(i32, record.pty_signal);
|
|
800
|
+
try cursor.writeInt(u32, record.pty_dropped_writes);
|
|
801
|
+
try cursor.writeBytes(&record.pty_blob_hash);
|
|
802
|
+
try cursor.writeInt(u64, record.pty_blob_len);
|
|
803
|
+
// Model restore is the first kind-local suffix. Keeping it conditional
|
|
804
|
+
// preserves every established effect record's byte layout (tests and
|
|
805
|
+
// tooling deliberately patch those records at known offsets).
|
|
806
|
+
if (record.kind == .persist) {
|
|
807
|
+
try cursor.writeEnum(record.persist_outcome);
|
|
808
|
+
try cursor.writeBytes(&record.persist_blob_hash);
|
|
809
|
+
try cursor.writeInt(u64, record.persist_blob_len);
|
|
810
|
+
}
|
|
811
|
+
if (record.kind == .db) {
|
|
812
|
+
try cursor.writeBytes(&record.db_blob_hash);
|
|
813
|
+
try cursor.writeInt(u64, record.db_blob_len);
|
|
814
|
+
}
|
|
815
|
+
if (record.kind == .credentials) {
|
|
816
|
+
try cursor.writeEnum(record.credentials_operation);
|
|
817
|
+
try cursor.writeEnum(record.credentials_outcome);
|
|
818
|
+
try cursor.writeInt(u64, record.credentials_secret_len);
|
|
819
|
+
try cursor.writeBytes(&record.credentials_salt);
|
|
820
|
+
try cursor.writeBytes(&record.credentials_digest);
|
|
821
|
+
}
|
|
822
|
+
return buffer[0..cursor.len];
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
pub fn decodeEffect(bytes: []const u8) JournalError!EffectResultRecord {
|
|
826
|
+
var cursor = ReadCursor{ .bytes = bytes };
|
|
827
|
+
var record: EffectResultRecord = .{
|
|
828
|
+
.kind = try cursor.readEnum(runtime_effects.EffectResultKind),
|
|
829
|
+
.key = try cursor.readInt(u64),
|
|
830
|
+
.payload = try cursor.readStr(),
|
|
831
|
+
.stderr_tail = try cursor.readStr(),
|
|
832
|
+
.truncated = try cursor.readBool(),
|
|
833
|
+
.dropped = try cursor.readInt(u32),
|
|
834
|
+
.code = try cursor.readInt(i32),
|
|
835
|
+
.exit_reason = try cursor.readEnum(runtime_effects.EffectExitReason),
|
|
836
|
+
.output_truncated = try cursor.readBool(),
|
|
837
|
+
.stderr_truncated = try cursor.readBool(),
|
|
838
|
+
.status = try cursor.readInt(u16),
|
|
839
|
+
.fetch_outcome = try cursor.readEnum(runtime_effects.EffectFetchOutcome),
|
|
840
|
+
.file_op = try cursor.readEnum(runtime_effects.EffectFileOp),
|
|
841
|
+
.file_event = try cursor.readEnum(runtime_effects.EffectFileEvent),
|
|
842
|
+
.file_outcome = try cursor.readEnum(runtime_effects.EffectFileOutcome),
|
|
843
|
+
.file_total = try cursor.readInt(u64),
|
|
844
|
+
.file_mtime_ms = try cursor.readInt(i64),
|
|
845
|
+
.file_exists = try cursor.readBool(),
|
|
846
|
+
.file_rejected_admission = try cursor.readBool(),
|
|
847
|
+
.clipboard_op = try cursor.readEnum(runtime_effects.EffectClipboardOp),
|
|
848
|
+
.clipboard_outcome = try cursor.readEnum(runtime_effects.EffectClipboardOutcome),
|
|
849
|
+
.timer_timestamp_ns = try cursor.readInt(u64),
|
|
850
|
+
.timer_outcome = try cursor.readEnum(runtime_effects.EffectTimerOutcome),
|
|
851
|
+
.clock_wall_ms = try cursor.readInt(i64),
|
|
852
|
+
.audio_kind = try cursor.readEnum(runtime_effects.EffectAudioEventKind),
|
|
853
|
+
.audio_position_ms = try cursor.readInt(u64),
|
|
854
|
+
.audio_duration_ms = try cursor.readInt(u64),
|
|
855
|
+
.audio_playing = try cursor.readBool(),
|
|
856
|
+
.audio_buffering = try cursor.readBool(),
|
|
857
|
+
};
|
|
858
|
+
@memcpy(&record.file_blob_hash, try cursor.readBytes(record.file_blob_hash.len));
|
|
859
|
+
record.file_blob_len = try cursor.readInt(u64);
|
|
860
|
+
@memcpy(&record.audio_bands, try cursor.readBytes(record.audio_bands.len));
|
|
861
|
+
// v7: image terminals.
|
|
862
|
+
record.image_outcome = try cursor.readEnum(runtime_effects.EffectImageOutcome);
|
|
863
|
+
record.image_width = try cursor.readInt(u64);
|
|
864
|
+
record.image_height = try cursor.readInt(u64);
|
|
865
|
+
@memcpy(&record.image_blob_hash, try cursor.readBytes(record.image_blob_hash.len));
|
|
866
|
+
record.image_blob_len = try cursor.readInt(u64);
|
|
867
|
+
// v8: channel events.
|
|
868
|
+
record.channel_kind = try cursor.readEnum(runtime_effects.EffectChannelEventKind);
|
|
869
|
+
record.channel_dropped_total = try cursor.readInt(u32);
|
|
870
|
+
// Video terminals.
|
|
871
|
+
record.video_kind = try cursor.readEnum(runtime_effects.EffectVideoEventKind);
|
|
872
|
+
record.video_position_ms = try cursor.readInt(u64);
|
|
873
|
+
record.video_duration_ms = try cursor.readInt(u64);
|
|
874
|
+
record.video_playing = try cursor.readBool();
|
|
875
|
+
record.video_buffering = try cursor.readBool();
|
|
876
|
+
record.video_width = try cursor.readInt(u64);
|
|
877
|
+
record.video_height = try cursor.readInt(u64);
|
|
878
|
+
record.video_token = try cursor.readInt(u64);
|
|
879
|
+
record.video_source = try cursor.readEnum(runtime_effects.EffectVideoSource);
|
|
880
|
+
record.video_handled = try cursor.readBool();
|
|
881
|
+
// Pty events.
|
|
882
|
+
record.pty_kind = try cursor.readEnum(runtime_effects.EffectPtyEventKind);
|
|
883
|
+
record.pty_signal = try cursor.readInt(i32);
|
|
884
|
+
record.pty_dropped_writes = try cursor.readInt(u32);
|
|
885
|
+
@memcpy(&record.pty_blob_hash, try cursor.readBytes(record.pty_blob_hash.len));
|
|
886
|
+
record.pty_blob_len = try cursor.readInt(u64);
|
|
887
|
+
if (record.kind == .persist) {
|
|
888
|
+
record.persist_outcome = try cursor.readEnum(runtime_effects.EffectPersistOutcome);
|
|
889
|
+
@memcpy(&record.persist_blob_hash, try cursor.readBytes(record.persist_blob_hash.len));
|
|
890
|
+
record.persist_blob_len = try cursor.readInt(u64);
|
|
891
|
+
}
|
|
892
|
+
if (record.kind == .db) {
|
|
893
|
+
@memcpy(&record.db_blob_hash, try cursor.readBytes(record.db_blob_hash.len));
|
|
894
|
+
record.db_blob_len = try cursor.readInt(u64);
|
|
895
|
+
}
|
|
896
|
+
if (record.kind == .credentials) {
|
|
897
|
+
record.credentials_operation = try cursor.readEnum(runtime_effects.EffectCredentialsOperation);
|
|
898
|
+
record.credentials_outcome = try cursor.readEnum(runtime_effects.EffectCredentialsOutcome);
|
|
899
|
+
record.credentials_secret_len = try cursor.readInt(u64);
|
|
900
|
+
@memcpy(&record.credentials_salt, try cursor.readBytes(record.credentials_salt.len));
|
|
901
|
+
@memcpy(&record.credentials_digest, try cursor.readBytes(record.credentials_digest.len));
|
|
902
|
+
}
|
|
903
|
+
if (!cursor.done()) return error.JournalCorrupt;
|
|
904
|
+
return record;
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
// ----------------------------------------------------- other codecs
|
|
908
|
+
|
|
909
|
+
pub fn encodeHeader(header: Header, buffer: []u8) JournalError![]const u8 {
|
|
910
|
+
var cursor = WriteCursor{ .buffer = buffer };
|
|
911
|
+
try cursor.writeInt(u64, header.protocol_fingerprint);
|
|
912
|
+
try cursor.writeStr(header.platform_name);
|
|
913
|
+
try cursor.writeStr(header.app_name);
|
|
914
|
+
try cursor.writeInt(i64, header.recorded_at_wall_ms);
|
|
915
|
+
try cursor.writeF32(header.window_width);
|
|
916
|
+
try cursor.writeF32(header.window_height);
|
|
917
|
+
try cursor.writeEnum(header.window_chrome_source);
|
|
918
|
+
return buffer[0..cursor.len];
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
pub fn decodeHeader(bytes: []const u8) JournalError!Header {
|
|
922
|
+
var cursor = ReadCursor{ .bytes = bytes };
|
|
923
|
+
const header: Header = .{
|
|
924
|
+
.protocol_fingerprint = try cursor.readInt(u64),
|
|
925
|
+
.platform_name = try cursor.readStr(),
|
|
926
|
+
.app_name = try cursor.readStr(),
|
|
927
|
+
.recorded_at_wall_ms = try cursor.readInt(i64),
|
|
928
|
+
.window_width = try cursor.readF32(),
|
|
929
|
+
.window_height = try cursor.readF32(),
|
|
930
|
+
.window_chrome_source = try cursor.readEnum(WindowChromeSource),
|
|
931
|
+
};
|
|
932
|
+
if (!cursor.done()) return error.JournalCorrupt;
|
|
933
|
+
return header;
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
pub fn encodeCheckpoint(checkpoint: Checkpoint, buffer: []u8) JournalError![]const u8 {
|
|
937
|
+
var cursor = WriteCursor{ .buffer = buffer };
|
|
938
|
+
try cursor.writeInt(u64, checkpoint.event_ordinal);
|
|
939
|
+
try cursor.writeInt(u64, checkpoint.frame_index);
|
|
940
|
+
try cursor.writeInt(u64, checkpoint.fingerprint);
|
|
941
|
+
return buffer[0..cursor.len];
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
pub fn decodeCheckpoint(bytes: []const u8) JournalError!Checkpoint {
|
|
945
|
+
var cursor = ReadCursor{ .bytes = bytes };
|
|
946
|
+
const checkpoint: Checkpoint = .{
|
|
947
|
+
.event_ordinal = try cursor.readInt(u64),
|
|
948
|
+
.frame_index = try cursor.readInt(u64),
|
|
949
|
+
.fingerprint = try cursor.readInt(u64),
|
|
950
|
+
};
|
|
951
|
+
if (!cursor.done()) return error.JournalCorrupt;
|
|
952
|
+
return checkpoint;
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
pub fn encodeScreenshot(mark: ScreenshotMark, buffer: []u8) JournalError![]const u8 {
|
|
956
|
+
var cursor = WriteCursor{ .buffer = buffer };
|
|
957
|
+
try cursor.writeInt(u64, mark.event_ordinal);
|
|
958
|
+
try cursor.writeStr(mark.view_label);
|
|
959
|
+
try cursor.writeF32(mark.scale);
|
|
960
|
+
try cursor.writeInt(u64, mark.png_hash);
|
|
961
|
+
try cursor.writeInt(u64, mark.png_len);
|
|
962
|
+
return buffer[0..cursor.len];
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
pub fn decodeScreenshot(bytes: []const u8) JournalError!ScreenshotMark {
|
|
966
|
+
var cursor = ReadCursor{ .bytes = bytes };
|
|
967
|
+
const ordinal = try cursor.readInt(u64);
|
|
968
|
+
const label = try cursor.readStr();
|
|
969
|
+
const mark: ScreenshotMark = .{
|
|
970
|
+
.event_ordinal = ordinal,
|
|
971
|
+
.view_label = label,
|
|
972
|
+
.scale = try cursor.readF32(),
|
|
973
|
+
.png_hash = try cursor.readInt(u64),
|
|
974
|
+
.png_len = try cursor.readInt(u64),
|
|
975
|
+
};
|
|
976
|
+
if (!cursor.done()) return error.JournalCorrupt;
|
|
977
|
+
return mark;
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
pub fn encodeWindowChrome(record: WindowChromeRecord, buffer: []u8) JournalError![]const u8 {
|
|
981
|
+
var cursor = WriteCursor{ .buffer = buffer };
|
|
982
|
+
try cursor.writeInt(u64, record.window_id);
|
|
983
|
+
try writeInsets(&cursor, record.chrome.insets);
|
|
984
|
+
try writeRect(&cursor, record.chrome.buttons);
|
|
985
|
+
try cursor.writeEnum(record.chrome.form_factor);
|
|
986
|
+
try cursor.writeBool(record.chrome.tabs_projected);
|
|
987
|
+
return buffer[0..cursor.len];
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
pub fn decodeWindowChrome(bytes: []const u8) JournalError!WindowChromeRecord {
|
|
991
|
+
var cursor = ReadCursor{ .bytes = bytes };
|
|
992
|
+
const record: WindowChromeRecord = .{
|
|
993
|
+
.window_id = try cursor.readInt(u64),
|
|
994
|
+
.chrome = .{
|
|
995
|
+
.insets = try readInsets(&cursor),
|
|
996
|
+
.buttons = try readRect(&cursor),
|
|
997
|
+
.form_factor = try cursor.readEnum(platform.FormFactor),
|
|
998
|
+
.tabs_projected = try cursor.readBool(),
|
|
999
|
+
},
|
|
1000
|
+
};
|
|
1001
|
+
if (!cursor.done()) return error.JournalCorrupt;
|
|
1002
|
+
return record;
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1005
|
+
pub fn encodeEnd(end: End, buffer: []u8) JournalError![]const u8 {
|
|
1006
|
+
var cursor = WriteCursor{ .buffer = buffer };
|
|
1007
|
+
try cursor.writeInt(u64, end.event_count);
|
|
1008
|
+
try cursor.writeInt(u64, end.effect_count);
|
|
1009
|
+
try cursor.writeInt(u64, end.checkpoint_count);
|
|
1010
|
+
try cursor.writeInt(u64, end.screenshot_count);
|
|
1011
|
+
try cursor.writeInt(u64, end.window_chrome_count);
|
|
1012
|
+
return buffer[0..cursor.len];
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
pub fn decodeEnd(bytes: []const u8) JournalError!End {
|
|
1016
|
+
var cursor = ReadCursor{ .bytes = bytes };
|
|
1017
|
+
const end: End = .{
|
|
1018
|
+
.event_count = try cursor.readInt(u64),
|
|
1019
|
+
.effect_count = try cursor.readInt(u64),
|
|
1020
|
+
.checkpoint_count = try cursor.readInt(u64),
|
|
1021
|
+
.screenshot_count = try cursor.readInt(u64),
|
|
1022
|
+
.window_chrome_count = try cursor.readInt(u64),
|
|
1023
|
+
};
|
|
1024
|
+
if (!cursor.done()) return error.JournalCorrupt;
|
|
1025
|
+
return end;
|
|
1026
|
+
}
|
|
1027
|
+
|