@native-sdk/cli 0.7.1 → 0.8.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/build/app.zig +273 -65
- package/build/ts_run.mjs +6 -8
- package/build.zig +341 -361
- package/native-sdk.d.ts +6 -3
- package/package.json +13 -11
- package/packages/core/compile-surface/core.ts +559 -0
- package/packages/core/package-lock.json +375 -12
- package/packages/core/package.json +9 -6
- package/packages/core/scripts/compiler_typecheck.mjs +58 -0
- package/packages/core/scripts/gen_case_tables.mjs +130 -0
- package/packages/core/scripts/gen_declarations.mjs +97 -0
- package/packages/core/scripts/run_external_core_compiler.mjs +108 -0
- package/packages/core/scripts/stage_external_core.mjs +148 -0
- package/packages/core/sdk/core.d.ts +363 -0
- package/packages/core/sdk/events.d.ts +65 -0
- package/packages/core/sdk/text.d.ts +51 -0
- package/packages/core/src/checker.ts +3 -3
- package/packages/core/src/cli.ts +40 -38
- package/packages/core/src/contract.ts +749 -0
- package/packages/core/src/devhost.ts +4 -3
- package/packages/core/src/diagnostics.ts +5 -7
- package/packages/core/src/{transpile.ts → frontend.ts} +38 -50
- package/packages/core/src/infer.ts +1 -1
- package/packages/core/src/typed_ast.ts +16 -15
- package/packages/core/src/wyhash.ts +79 -0
- package/skill-data/native-ui/SKILL.md +4 -2
- package/skill-data/ts-core/SKILL.md +29 -29
- package/src/platform/macos/appkit_host.m +51 -3
- package/src/platform/types.zig +4 -0
- package/src/platform/windows/gpu_surface_renderer.cpp +2280 -0
- package/src/platform/windows/gpu_surface_renderer.h +86 -0
- package/src/platform/windows/root.zig +298 -20
- package/src/platform/windows/webview2_host.cpp +343 -33
- package/src/primitives/canvas/code.zig +50 -0
- package/src/primitives/canvas/code_tests.zig +174 -1
- package/src/primitives/canvas/frame.zig +45 -1
- package/src/primitives/canvas/gpu.zig +6 -0
- package/src/primitives/canvas/render_tests.zig +93 -0
- package/src/primitives/canvas/root.zig +2 -0
- package/src/primitives/canvas/serialization.zig +150 -21
- package/src/primitives/canvas/themes/geist.zig +51 -5
- package/src/primitives/canvas/tokens.zig +33 -4
- package/src/primitives/canvas/ui.zig +52 -7
- package/src/primitives/canvas/ui_markup.zig +38 -1
- package/src/primitives/canvas/ui_markup_compiled.zig +28 -0
- package/src/primitives/canvas/ui_markup_contract.zig +9 -0
- package/src/primitives/canvas/ui_markup_view.zig +28 -0
- package/src/primitives/canvas/ui_markup_view_tests.zig +10 -2
- package/src/primitives/canvas/ui_schema.zig +5 -0
- package/src/primitives/canvas/ui_schema_tests.zig +4 -3
- package/src/primitives/canvas/ui_tests.zig +14 -0
- package/src/primitives/canvas/widget_builtin_tests.zig +513 -13
- package/src/primitives/canvas/widget_invalidation.zig +11 -1
- package/src/primitives/canvas/widget_layout.zig +260 -21
- package/src/primitives/canvas/widget_metrics.zig +45 -9
- package/src/primitives/canvas/widget_render.zig +220 -70
- package/src/primitives/canvas/widget_render_controls.zig +79 -21
- package/src/primitives/canvas/widget_render_style.zig +52 -8
- package/src/primitives/canvas/widget_text_input.zig +2 -0
- package/src/primitives/canvas/widgets.zig +53 -2
- package/src/runtime/canvas_frame.zig +60 -7
- package/src/runtime/canvas_frame_invalidation_tests.zig +80 -0
- package/src/runtime/canvas_frame_packet_tests.zig +83 -9
- package/src/runtime/canvas_frame_patch_tests.zig +16 -0
- package/src/runtime/canvas_images.zig +8 -2
- package/src/runtime/canvas_widget_clipboard_tests.zig +1 -1
- package/src/runtime/canvas_widget_runtime.zig +11 -8
- package/src/runtime/effects.zig +6 -0
- package/src/runtime/effects_tests.zig +30 -0
- package/src/runtime/gpu_surface_events.zig +38 -7
- package/src/runtime/media_surface_tests.zig +1 -1
- package/src/runtime/runtime_event_tests.zig +74 -0
- package/src/runtime/ts_core_host.zig +38 -38
- package/src/runtime/ts_ui_app.zig +12 -12
- package/src/runtime/ui_app.zig +10 -8
- package/src/runtime/ui_app_tests.zig +67 -0
- package/src/runtime/view.zig +6 -0
- package/src/runtime/view_canvas.zig +15 -0
- package/src/runtime/view_widget_text.zig +6 -4
- package/src/runtime/window_view_runtime.zig +1 -0
- package/src/tooling/manifest.zig +32 -0
- package/src/tooling/raw_manifest.zig +4 -0
- package/src/tooling/templates.zig +34 -26
- package/src/tooling/ts_core.zig +55 -34
- package/src/tooling/verbs.zig +1 -1
- package/tools/corewire/core_abi.zig +169 -0
- package/tools/corewire/emit.zig +2418 -0
- package/tools/corewire/emit_facade.zig +3984 -0
- package/tools/corewire/emit_profile.zig +501 -0
- package/tools/corewire/main.zig +561 -0
- package/tools/corewire/shim_rt.zig +632 -0
- package/tools/corewire/sidecar.zig +2507 -0
- package/packages/core/rt/rt.zig +0 -1986
- package/packages/core/src/emitter.ts +0 -11898
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
//! The extern-binding layer for a compiled core: every C-ABI symbol the
|
|
2
|
+
//! generated shim (core_shim.zig) may reference, in one module.
|
|
3
|
+
//!
|
|
4
|
+
//! ISOLATION IS THE POINT OF THIS FILE. The core ABI is a draft pending
|
|
5
|
+
//! cross-repo ratification; the shim generator emits no extern
|
|
6
|
+
//! declarations of its own, so a post-ratification symbol or signature
|
|
7
|
+
//! change is an edit HERE and a regeneration — never a generator-logic
|
|
8
|
+
//! change. The build stages this file (and shim_rt.zig) beside the
|
|
9
|
+
//! generated shim, exactly as the transpiler lane stages rt.zig beside
|
|
10
|
+
//! its emitted core.
|
|
11
|
+
//!
|
|
12
|
+
//! Contract summary (the header is the specification; this file only
|
|
13
|
+
//! binds it):
|
|
14
|
+
//! - Symbols are `prefix + suffix`, ccc calling convention, prefix
|
|
15
|
+
//! declared by the sidecar's abi section (canonical default
|
|
16
|
+
//! "nsc_core_").
|
|
17
|
+
//! - The identity getters are pure, callable before init, and MUST NOT
|
|
18
|
+
//! trap: they are the boot-time staleness fence.
|
|
19
|
+
//! - One dispatch entry per payload-descriptor class; `tag` is the
|
|
20
|
+
//! arm's declaration-order index in the sidecar's msg section (the
|
|
21
|
+
//! sidecar is the tag authority). Each entry runs one update+commit
|
|
22
|
+
//! and returns the cycle's command bytes.
|
|
23
|
+
//! - Inbound pointers are borrowed for the call; the core copies what
|
|
24
|
+
//! it keeps. Outbound buffers are core-owned: cmd/subs bytes live
|
|
25
|
+
//! until frame_reset, the snapshot until the next dispatch entry,
|
|
26
|
+
//! init, or collect. No alignment guarantee on any encoded buffer.
|
|
27
|
+
//! - Encoded buffers use the canonical value encoding (shim_rt.zig):
|
|
28
|
+
//! little-endian, headerless, schema-driven, record fields in sidecar
|
|
29
|
+
//! declaration order.
|
|
30
|
+
//! - Narrow integers in these signatures (u8 tags, u32 member/helper
|
|
31
|
+
//! indices, the sink's u64 address) are C-SIGNATURE PLUMBING for
|
|
32
|
+
//! host-produced values, never value-payload crossings: payload
|
|
33
|
+
//! numbers ride the two-class number model (f64/i64) exclusively.
|
|
34
|
+
//! - Four entries are runtime-owned mode symbols rather than ordinary
|
|
35
|
+
//! compiled-core exports: set_panic_sink, init, frame_reset, and
|
|
36
|
+
//! collect (which folds the transient-arena reset). The rest project
|
|
37
|
+
//! the core module's own surface.
|
|
38
|
+
|
|
39
|
+
const std = @import("std");
|
|
40
|
+
|
|
41
|
+
/// The C-ABI generation these bindings implement. The generator refuses
|
|
42
|
+
/// a sidecar declaring any other value; the generated shim re-checks the
|
|
43
|
+
/// object's own getter at boot (the out-of-graph pairing backstop).
|
|
44
|
+
pub const abi_version: u32 = 1;
|
|
45
|
+
|
|
46
|
+
/// The snapshot-encoding generation the shim's decoder implements.
|
|
47
|
+
pub const snapshot_format: u32 = 1;
|
|
48
|
+
|
|
49
|
+
/// The host-supplied trap sink. `msg` is a UTF-8 teaching message valid
|
|
50
|
+
/// only for the duration of the call; `address` is the faulting return
|
|
51
|
+
/// address (0 when unknown); `ctx` echoes the registered context
|
|
52
|
+
/// pointer. The sink must not return and must not call back into any
|
|
53
|
+
/// core entry point.
|
|
54
|
+
///
|
|
55
|
+
/// The sink covers DETECTED traps only: contract violations the core's
|
|
56
|
+
/// own checks catch throw with their teaching text, and an exception
|
|
57
|
+
/// that escapes the core reaches the sink with an "Uncaught " prefix on
|
|
58
|
+
/// its message. Hardware faults (SIGSEGV/SIGBUS) belong to the host's
|
|
59
|
+
/// process-wide handler — the core installs no signal handlers.
|
|
60
|
+
pub const PanicSinkFn = *const fn (
|
|
61
|
+
ctx: ?*anyopaque,
|
|
62
|
+
msg: [*]const u8,
|
|
63
|
+
msg_len: usize,
|
|
64
|
+
address: u64,
|
|
65
|
+
) callconv(.c) void;
|
|
66
|
+
|
|
67
|
+
// A conditional channel entry hands its whole result back as ONE bytes
|
|
68
|
+
// buffer on the ordinary out-pointer slot — the channel bytes envelope:
|
|
69
|
+
//
|
|
70
|
+
// [produced u8][tag u8][payload…]
|
|
71
|
+
//
|
|
72
|
+
// Byte 0 is 0 (nothing produced; the envelope is exactly two bytes) or
|
|
73
|
+
// 1. Byte 1 is the produced arm's declaration-order wire tag in the
|
|
74
|
+
// sidecar's msg section (meaningless when nothing was produced; the
|
|
75
|
+
// producer emits 0). The remainder is the arm's payload in the
|
|
76
|
+
// canonical value encoding of its mirror payload type (shim_rt.zig; an
|
|
77
|
+
// i64 arm rides as 8-byte two's-complement LE) — so the envelope's tail
|
|
78
|
+
// is byte-identical to the canonical union encoding of the produced
|
|
79
|
+
// message. Envelope bytes are valid until the next core entry call of
|
|
80
|
+
// any kind. One bytes return keeps the one-return-slot rule intact: the
|
|
81
|
+
// multi-value result needs no marshalling shape of its own.
|
|
82
|
+
|
|
83
|
+
/// The full symbol set of ABI version 1, bound under `prefix`. The
|
|
84
|
+
/// conditional channel entries are declared unconditionally here —
|
|
85
|
+
/// `@extern` binds lazily, so a symbol is required at link time only
|
|
86
|
+
/// when the generated shim actually references it, which it does
|
|
87
|
+
/// exactly when the sidecar's abi.exports lists it.
|
|
88
|
+
pub fn Bindings(comptime prefix: []const u8) type {
|
|
89
|
+
return struct {
|
|
90
|
+
fn Symbol(comptime T: type, comptime suffix: []const u8) *const T {
|
|
91
|
+
return @extern(*const T, .{ .name = prefix ++ suffix });
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// ---------------------------------------------------- identity
|
|
95
|
+
pub const abi_version_fn = Symbol(fn () callconv(.c) u32, "abi_version");
|
|
96
|
+
pub const build_id = Symbol(fn () callconv(.c) u64, "build_id");
|
|
97
|
+
|
|
98
|
+
// -------------------------------------------------- panic sink
|
|
99
|
+
pub const set_panic_sink = Symbol(fn (sink: PanicSinkFn, ctx: ?*anyopaque) callconv(.c) void, "set_panic_sink");
|
|
100
|
+
|
|
101
|
+
// --------------------------------------------------- lifecycle
|
|
102
|
+
/// Deterministic (re)initialization: resets all runtime state,
|
|
103
|
+
/// evaluates the core's init, commits the boot model. Callable
|
|
104
|
+
/// repeatedly (the session-replay re-init seam); invalidates
|
|
105
|
+
/// every previously returned pointer.
|
|
106
|
+
pub const init = Symbol(fn () callconv(.c) void, "init");
|
|
107
|
+
/// The boot command bytes produced by init (empty when the
|
|
108
|
+
/// core's init returns a bare model). Arena truth governs the
|
|
109
|
+
/// lifetime: valid until the next frame_reset, dispatch entry,
|
|
110
|
+
/// or init.
|
|
111
|
+
pub const boot_cmd = Symbol(fn (cmd: *[*]const u8, cmd_len: *usize) callconv(.c) void, "boot_cmd");
|
|
112
|
+
|
|
113
|
+
// ---------------------------------------------------- dispatch
|
|
114
|
+
pub const dispatch_void = Symbol(fn (tag: u8, cmd: *[*]const u8, cmd_len: *usize) callconv(.c) void, "dispatch_void");
|
|
115
|
+
pub const dispatch_bytes = Symbol(fn (tag: u8, ptr: [*]const u8, len: usize, cmd: *[*]const u8, cmd_len: *usize) callconv(.c) void, "dispatch_bytes");
|
|
116
|
+
/// The value crosses as f64; an i64-classed arm narrows
|
|
117
|
+
/// core-side by truncation toward zero (producers guarantee
|
|
118
|
+
/// integer-classed values are exact below 2^53).
|
|
119
|
+
pub const dispatch_number = Symbol(fn (tag: u8, value: f64, cmd: *[*]const u8, cmd_len: *usize) callconv(.c) void, "dispatch_number");
|
|
120
|
+
pub const dispatch_number_bytes = Symbol(fn (tag: u8, number: f64, ptr: [*]const u8, len: usize, cmd: *[*]const u8, cmd_len: *usize) callconv(.c) void, "dispatch_number_bytes");
|
|
121
|
+
pub const dispatch_bool = Symbol(fn (tag: u8, value: u8, cmd: *[*]const u8, cmd_len: *usize) callconv(.c) void, "dispatch_bool");
|
|
122
|
+
/// `member` is the declaration-order member index from the
|
|
123
|
+
/// sidecar's type table (= the wire value).
|
|
124
|
+
pub const dispatch_enum = Symbol(fn (tag: u8, member: u32, cmd: *[*]const u8, cmd_len: *usize) callconv(.c) void, "dispatch_enum");
|
|
125
|
+
/// A record OR non-text-input union payload in the canonical
|
|
126
|
+
/// value encoding (a union rides as its u8 declaration-order arm
|
|
127
|
+
/// index followed by that arm's payload — the same encoding the
|
|
128
|
+
/// snapshot uses, so one decoder serves both directions).
|
|
129
|
+
pub const dispatch_record = Symbol(fn (tag: u8, fields: [*]const u8, fields_len: usize, cmd: *[*]const u8, cmd_len: *usize) callconv(.c) void, "dispatch_record");
|
|
130
|
+
/// The declared text-input mirror union: [arm u8] + arm payload
|
|
131
|
+
/// in the canonical value encoding.
|
|
132
|
+
pub const dispatch_text_input = Symbol(fn (tag: u8, event: [*]const u8, event_len: usize, cmd: *[*]const u8, cmd_len: *usize) callconv(.c) void, "dispatch_text_input");
|
|
133
|
+
/// The declared scroll-state mirror record as direct scalars
|
|
134
|
+
/// (the hottest markup dispatch: per-frame during scrolls) —
|
|
135
|
+
/// the TWO-AXIS record's eight fields in declaration order.
|
|
136
|
+
pub const dispatch_scroll_state = Symbol(fn (tag: u8, offset_x: f64, offset_y: f64, velocity_x: f64, velocity_y: f64, viewport_extent_x: f64, viewport_extent_y: f64, content_extent_x: f64, content_extent_y: f64, cmd: *[*]const u8, cmd_len: *usize) callconv(.c) void, "dispatch_scroll_state");
|
|
137
|
+
|
|
138
|
+
// -------------------------------------------------- post-cycle
|
|
139
|
+
pub const subscriptions = Symbol(fn (subs: *[*]const u8, subs_len: *usize) callconv(.c) void, "subscriptions");
|
|
140
|
+
pub const frame_reset = Symbol(fn () callconv(.c) void, "frame_reset");
|
|
141
|
+
/// The committed model in the canonical value encoding of the
|
|
142
|
+
/// sidecar's model type (root record, declaration-order fields),
|
|
143
|
+
/// encoded on demand from the committed heap into a transient
|
|
144
|
+
/// buffer: valid until the next dispatch entry, frame_reset,
|
|
145
|
+
/// init, or collect (arena truth — the buffer does NOT survive a
|
|
146
|
+
/// frame reset; re-read after resetting).
|
|
147
|
+
pub const model_snapshot = Symbol(fn (snap: *[*]const u8, snap_len: *usize) callconv(.c) void, "model_snapshot");
|
|
148
|
+
/// Call the exported helper at `helper` (index into the
|
|
149
|
+
/// sidecar's model_helpers). An unknown index is a generator/
|
|
150
|
+
/// sidecar skew and TRAPS through the panic sink — it is never a
|
|
151
|
+
/// status the host is asked to check.
|
|
152
|
+
pub const helper_call = Symbol(fn (helper: u32, args: [*]const u8, args_len: usize, out: *[*]const u8, out_len: *usize) callconv(.c) void, "helper_call");
|
|
153
|
+
/// Reference-cycle collection over the model heap, with the
|
|
154
|
+
/// transient-arena reset folded in (a runtime-owned mode
|
|
155
|
+
/// symbol): observable model state unchanged, every previously
|
|
156
|
+
/// returned snapshot, helper, cmd, and subscription pointer
|
|
157
|
+
/// invalidated.
|
|
158
|
+
pub const collect = Symbol(fn () callconv(.c) void, "collect");
|
|
159
|
+
|
|
160
|
+
// -------------------------- conditional channel entries
|
|
161
|
+
//
|
|
162
|
+
// Each returns the channel bytes envelope (see the module doc
|
|
163
|
+
// above) through the ordinary out-pointer pair.
|
|
164
|
+
pub const command_msg = Symbol(fn (name: [*]const u8, name_len: usize, out: *[*]const u8, out_len: *usize) callconv(.c) void, "command_msg");
|
|
165
|
+
pub const frame_msg = Symbol(fn (width: f64, height: f64, timestamp_ms: f64, interval_ms: f64, out: *[*]const u8, out_len: *usize) callconv(.c) void, "frame_msg");
|
|
166
|
+
pub const key_msg = Symbol(fn (key: [*]const u8, key_len: usize, shift: u8, control: u8, alt: u8, super_mod: u8, out: *[*]const u8, out_len: *usize) callconv(.c) void, "key_msg");
|
|
167
|
+
pub const pinch_msg = Symbol(fn (window_id: f64, label: [*]const u8, label_len: usize, phase: u32, scale: f64, x: f64, y: f64, out: *[*]const u8, out_len: *usize) callconv(.c) void, "pinch_msg");
|
|
168
|
+
};
|
|
169
|
+
}
|