@native-sdk/cli 0.5.0 → 0.5.2
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 +198 -13
- package/build/ts_run.mjs +58 -19
- package/build.zig +42 -0
- package/package.json +13 -9
- package/packages/core/package-lock.json +4 -3
- package/packages/core/package.json +3 -2
- package/packages/core/src/typed_ast.ts +11 -1
- package/skill-data/native-ui/SKILL.md +2 -2
- package/src/platform/types.zig +9 -0
- package/src/platform/windows/webview2_host.cpp +24 -0
- package/src/primitives/canvas/layout_audit.zig +5 -5
- package/src/primitives/canvas/root.zig +6 -0
- package/src/primitives/canvas/tokens.zig +185 -7
- package/src/primitives/canvas/ui.zig +27 -5
- package/src/primitives/canvas/ui_markup.zig +27 -4
- package/src/primitives/canvas/ui_markup_compiled.zig +9 -1
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +127 -0
- package/src/primitives/canvas/ui_markup_tests.zig +47 -0
- package/src/primitives/canvas/ui_markup_view.zig +10 -1
- package/src/primitives/canvas/ui_markup_view_tests.zig +78 -0
- package/src/primitives/canvas/ui_schema.zig +15 -1
- package/src/primitives/canvas/ui_schema_tests.zig +5 -4
- package/src/primitives/canvas/widget_builtin_tests.zig +439 -5
- package/src/primitives/canvas/widget_layout.zig +142 -3
- package/src/primitives/canvas/widget_layout_tests.zig +82 -0
- package/src/primitives/canvas/widget_metrics.zig +16 -8
- package/src/primitives/canvas/widget_tree.zig +14 -2
- package/src/primitives/canvas/widgets.zig +12 -0
- package/src/runtime/automation_widget_dispatch.zig +95 -28
- package/src/runtime/canvas_frame.zig +15 -0
- package/src/runtime/canvas_widget_anchored_tests.zig +253 -65
- package/src/runtime/canvas_widget_context_menu.zig +3 -2
- package/src/runtime/canvas_widget_events.zig +1271 -3
- package/src/runtime/canvas_widget_floating_tests.zig +2801 -0
- package/src/runtime/canvas_widget_scroll_drivers.zig +1 -1
- package/src/runtime/canvas_widget_state.zig +82 -5
- package/src/runtime/core.zig +30 -0
- package/src/runtime/effects.zig +1037 -133
- package/src/runtime/effects_fetch_tests.zig +42 -0
- package/src/runtime/effects_file_tests.zig +220 -0
- package/src/runtime/effects_tests.zig +287 -0
- package/src/runtime/flow.zig +24 -1
- package/src/runtime/gpu_surface_events.zig +44 -5
- package/src/runtime/session_journal.zig +25 -13
- package/src/runtime/session_record.zig +166 -0
- package/src/runtime/session_tests.zig +453 -0
- package/src/runtime/ui_app.zig +137 -39
- package/src/runtime/ui_app_tests.zig +681 -0
- package/src/runtime/ui_app_window_tests.zig +182 -0
- package/src/runtime/view.zig +86 -0
- package/src/runtime/view_widget_text.zig +18 -1
- package/src/runtime/view_widget_tree.zig +339 -20
- package/src/runtime/widget_bridge.zig +26 -0
- package/src/runtime/window_storage.zig +61 -15
- package/src/runtime/window_view_runtime.zig +13 -0
- package/src/runtime/window_views.zig +6 -0
- package/src/tooling/package.zig +311 -8
- package/src/tooling/templates.zig +97 -9
- package/src/tooling/ts_core.zig +626 -13
- package/src/tooling/verbs.zig +88 -2
package/build/app.zig
CHANGED
|
@@ -70,6 +70,149 @@ const TsCoreStage = struct {
|
|
|
70
70
|
main_root: std.Build.LazyPath,
|
|
71
71
|
};
|
|
72
72
|
|
|
73
|
+
/// Whether the transpiler's TypeScript compiler (@typescript/old, the
|
|
74
|
+
/// exactly pinned npm alias of the real `typescript` package) RESOLVES
|
|
75
|
+
/// from the SDK's packages/core, by node's ancestor node_modules walk —
|
|
76
|
+
/// at the SDK's exactly pinned VERSION. The same semantics the CLI gates
|
|
77
|
+
/// on (src/tooling/ts_core.zig
|
|
78
|
+
/// transpilerResolution, this predicate's deliberate twin: keep the two
|
|
79
|
+
/// in lockstep).
|
|
80
|
+
///
|
|
81
|
+
/// Validation tracks ONLY what runtime loads, from the same origin
|
|
82
|
+
/// runtime resolves from: typed_ast.ts imports "@typescript/old" directly
|
|
83
|
+
/// and build/ts_run.mjs's load hook requires it from the target
|
|
84
|
+
/// packages/core/src module — src/ never carries a node_modules, so
|
|
85
|
+
/// packages/core is the walk origin that mirrors both. Covers every
|
|
86
|
+
/// layout: a repo checkout's packages/core/node_modules (nearest wins),
|
|
87
|
+
/// and the npm-installed CLI whose own `dependencies` carry the alias
|
|
88
|
+
/// (nested under the package on global prefixes, hoisted to the project
|
|
89
|
+
/// root on local ones, pnpm's sibling node_modules).
|
|
90
|
+
///
|
|
91
|
+
/// The @typescript/typescript6 wrapper is deliberately NOT probed:
|
|
92
|
+
/// nothing imports it at run time (typed_ast.ts bypasses its one-line
|
|
93
|
+
/// re-export on purpose), so holding the wrapper's resolution — or the
|
|
94
|
+
/// alias's version as seen FROM the wrapper's origin — against the pin
|
|
95
|
+
/// can only FALSE-REJECT healthy trees: npm's own conflict shape hoists
|
|
96
|
+
/// a consumer's conflicting `@typescript/old` at the project root while
|
|
97
|
+
/// our exact pin lands nested under the CLI, which is precisely the copy
|
|
98
|
+
/// runtime loads from packages/core; a consumer's own shadowing wrapper
|
|
99
|
+
/// must not sway the verdict either. The wrapper stays a DECLARED
|
|
100
|
+
/// dependency in both manifests — it is just not what validation vouches
|
|
101
|
+
/// for (see the twin's doc comment).
|
|
102
|
+
///
|
|
103
|
+
/// Resolvable means the alias's manifest AND its entrypoint are present
|
|
104
|
+
/// (see tsAliasedCompilerVersion for node's error shape and the
|
|
105
|
+
/// mid-extraction slivers) and its installed version equals the pin —
|
|
106
|
+
/// read from the SDK dependency's own packages/core/package.json (the
|
|
107
|
+
/// `npm:typescript@X.Y.Z` alias suffix in devDependencies —
|
|
108
|
+
/// tsParseAliasedCompilerPin, mirroring the twin's
|
|
109
|
+
/// parseAliasedCompilerPin), never hardcoded, so version bumps stay a
|
|
110
|
+
/// one-file change.
|
|
111
|
+
const TsToolchainResolution = union(enum) {
|
|
112
|
+
resolved,
|
|
113
|
+
unresolved,
|
|
114
|
+
/// The aliased compiler resolves, but at a version other than the
|
|
115
|
+
/// SDK's exact pin (strings allocated on b.allocator, freed never —
|
|
116
|
+
/// this is configure-time teaching data).
|
|
117
|
+
version_mismatch: struct { resolved: []const u8, pinned: []const u8 },
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
fn tsToolchainResolution(b: *std.Build, dep: *std.Build.Dependency) TsToolchainResolution {
|
|
121
|
+
const sdk_root = tsSdkRoot(b.allocator, b.graph.io, dep);
|
|
122
|
+
// The pin first: an SDK tree whose packages/core/package.json is
|
|
123
|
+
// missing or pinless is not one this gate can vouch for (the file
|
|
124
|
+
// ships in every layout), so it concludes unresolved and the teaching
|
|
125
|
+
// path acts.
|
|
126
|
+
const pinned = tsPinnedCompilerVersion(b, sdk_root) orelse return .unresolved;
|
|
127
|
+
const resolved = tsAliasedCompilerVersion(b, b.pathJoin(&.{ sdk_root, "packages", "core" })) orelse return .unresolved;
|
|
128
|
+
if (std.mem.eql(u8, resolved, pinned)) return .resolved;
|
|
129
|
+
return .{ .version_mismatch = .{ .resolved = resolved, .pinned = pinned } };
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/// How runtime's `import "@typescript/old"` resolves, by node's walk FROM
|
|
133
|
+
/// `origin_dir` upward: the nearest ancestor
|
|
134
|
+
/// `node_modules/@typescript/old` wins (skipping ancestors that are
|
|
135
|
+
/// themselves a node_modules directory, as node does). Callers pass the
|
|
136
|
+
/// SDK's packages/core — the origin typed_ast.ts and ts_run.mjs resolve
|
|
137
|
+
/// the alias from. The walk must be a real ancestor walk, not a
|
|
138
|
+
/// fixed-sibling probe: npm hoists the alias to the install root on flat
|
|
139
|
+
/// layouts and nests it under the CLI on version conflicts. Resolvable
|
|
140
|
+
/// means the alias's manifest AND its entrypoint — the alias is the real
|
|
141
|
+
/// `typescript` package, whose `"main"` is ./lib/typescript.js (no
|
|
142
|
+
/// `"exports"`): a bare directory (an interrupted install, a pruned
|
|
143
|
+
/// node_modules) is MODULE_NOT_FOUND at run time, and a manifest without
|
|
144
|
+
/// its entrypoint (npm extraction is not atomic; package.json rides
|
|
145
|
+
/// first in the tarball) fails just as opaquely. Hardcoding it is safe
|
|
146
|
+
/// because the alias is exactly pinned (`npm:typescript@X.Y.Z` in both
|
|
147
|
+
/// manifests plus the lockfile) and drift-checked by check-version-sync.
|
|
148
|
+
/// A manifest without its entrypoint THROWS in node rather than
|
|
149
|
+
/// consulting a deeper ancestor, so it concludes unresolvable here too
|
|
150
|
+
/// (this predicate's deliberate twin: src/tooling/ts_core.zig's
|
|
151
|
+
/// aliasedCompilerVersion — keep the two in lockstep).
|
|
152
|
+
///
|
|
153
|
+
/// Returns the resolved alias's installed VERSION so the caller can hold
|
|
154
|
+
/// it against the SDK's pin; a resolvable-looking alias whose manifest
|
|
155
|
+
/// carries no version field returns null (every real npm install writes
|
|
156
|
+
/// one — its absence is a corrupt sliver, not a compiler to vouch for).
|
|
157
|
+
fn tsAliasedCompilerVersion(b: *std.Build, origin_dir: []const u8) ?[]const u8 {
|
|
158
|
+
const io = b.graph.io;
|
|
159
|
+
var dir: []const u8 = origin_dir;
|
|
160
|
+
while (true) {
|
|
161
|
+
if (!std.mem.eql(u8, std.fs.path.basename(dir), "node_modules")) {
|
|
162
|
+
found: {
|
|
163
|
+
const manifest_path = b.pathJoin(&.{ dir, "node_modules", "@typescript", "old", "package.json" });
|
|
164
|
+
std.Io.Dir.cwd().access(io, manifest_path, .{}) catch break :found;
|
|
165
|
+
std.Io.Dir.cwd().access(io, b.pathJoin(&.{ dir, "node_modules", "@typescript", "old", "lib", "typescript.js" }), .{}) catch return null;
|
|
166
|
+
const manifest = std.Io.Dir.cwd().readFileAlloc(io, manifest_path, b.allocator, .limited(64 * 1024)) catch return null;
|
|
167
|
+
return tsParseQuotedManifestValue(manifest, "\"version\"", "");
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
dir = std.fs.path.dirname(dir) orelse return null;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/// The version the SDK pins its aliased compiler to, read from the SDK
|
|
175
|
+
/// dependency's own packages/core/package.json — the same manifest the
|
|
176
|
+
/// CLI's gate reads, so both surfaces learn a version bump from one file.
|
|
177
|
+
fn tsPinnedCompilerVersion(b: *std.Build, sdk_root: []const u8) ?[]const u8 {
|
|
178
|
+
const manifest = std.Io.Dir.cwd().readFileAlloc(b.graph.io, b.pathJoin(&.{ sdk_root, "packages", "core", "package.json" }), b.allocator, .limited(64 * 1024)) catch return null;
|
|
179
|
+
const pin = tsParseQuotedManifestValue(manifest, "\"@typescript/old\"", "npm:typescript@") orelse return null;
|
|
180
|
+
// Exact X.Y.Z only (check-version-sync's pin shape), mirroring the
|
|
181
|
+
// twin's parseAliasedCompilerPin: a range is not a pin.
|
|
182
|
+
if (pin.len == 0) return null;
|
|
183
|
+
for (pin) |c| {
|
|
184
|
+
if (!std.ascii.isDigit(c) and c != '.') return null;
|
|
185
|
+
}
|
|
186
|
+
if (std.mem.count(u8, pin, ".") != 2) return null;
|
|
187
|
+
return pin;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/// Targeted scan for a manifest key's string value (the twin of
|
|
191
|
+
/// ts_core.zig's parsePackageVersion/parseAliasedCompilerPin scanners):
|
|
192
|
+
/// find `key`, expect `: "<required_prefix><value>"`, return `value`.
|
|
193
|
+
fn tsParseQuotedManifestValue(manifest_json: []const u8, comptime key: []const u8, comptime required_prefix: []const u8) ?[]const u8 {
|
|
194
|
+
const key_at = std.mem.indexOf(u8, manifest_json, key) orelse return null;
|
|
195
|
+
var rest = manifest_json[key_at + key.len ..];
|
|
196
|
+
rest = std.mem.trimStart(u8, rest, " \t\r\n");
|
|
197
|
+
if (rest.len == 0 or rest[0] != ':') return null;
|
|
198
|
+
rest = std.mem.trimStart(u8, rest[1..], " \t\r\n");
|
|
199
|
+
if (rest.len == 0 or rest[0] != '"') return null;
|
|
200
|
+
rest = rest[1..];
|
|
201
|
+
const end = std.mem.indexOfScalar(u8, rest, '"') orelse return null;
|
|
202
|
+
const value = rest[0..end];
|
|
203
|
+
if (!std.mem.startsWith(u8, value, required_prefix)) return null;
|
|
204
|
+
const suffix = value[required_prefix.len..];
|
|
205
|
+
if (suffix.len == 0) return null;
|
|
206
|
+
return suffix;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/// The SDK dependency's real root, resolved the way both the toolchain
|
|
210
|
+
/// check and its teaching name it.
|
|
211
|
+
fn tsSdkRoot(allocator: std.mem.Allocator, io: std.Io, dep: *std.Build.Dependency) []const u8 {
|
|
212
|
+
const raw_root = dep.builder.build_root.path orelse ".";
|
|
213
|
+
return std.Io.Dir.cwd().realPathFileAlloc(io, raw_root, allocator) catch raw_root;
|
|
214
|
+
}
|
|
215
|
+
|
|
73
216
|
fn tsCoreStage(b: *std.Build, dep: *std.Build.Dependency, app_root: []const u8) TsCoreStage {
|
|
74
217
|
if (!appFileExists(b, app_root, "src/app.native")) {
|
|
75
218
|
@panic("\nthis app has a TypeScript core (src/core.ts) but no view: TS apps render markup," ++
|
|
@@ -77,20 +220,50 @@ fn tsCoreStage(b: *std.Build, dep: *std.Build.Dependency, app_root: []const u8)
|
|
|
77
220
|
}
|
|
78
221
|
const node = b.findProgram(&.{"node"}, &.{}) catch {
|
|
79
222
|
@panic("\nbuilding a TypeScript app core needs node on PATH (the @native-sdk/core transpiler runs at" ++
|
|
80
|
-
" build time; the binary it emits ships no JS runtime).\nInstall Node.js 22+
|
|
81
|
-
" or `brew install node` — and re-run.\n");
|
|
82
|
-
};
|
|
83
|
-
dep.builder.build_root.handle.access(
|
|
84
|
-
dep.builder.graph.io,
|
|
85
|
-
"packages/core/node_modules/@typescript/typescript6",
|
|
86
|
-
.{},
|
|
87
|
-
) catch {
|
|
88
|
-
// Name the SDK dependency's real location (a checkout or the
|
|
89
|
-
// npm-installed @native-sdk/cli package — both carry
|
|
90
|
-
// packages/core with its lockfile, so `npm ci` works in place).
|
|
91
|
-
std.debug.panic("\nthe SDK's @native-sdk/core transpiler is missing its installed dependency.\nFix with:" ++
|
|
92
|
-
" cd {s}/packages/core && npm ci\n", .{dep.builder.build_root.path orelse "<sdk>"});
|
|
223
|
+
" build time; the binary it emits ships no JS runtime).\nInstall Node.js 22.15+ (on the 23 line: 23.5+)" ++
|
|
224
|
+
" — https://nodejs.org or `brew install node` — and re-run.\n");
|
|
93
225
|
};
|
|
226
|
+
switch (tsToolchainResolution(b, dep)) {
|
|
227
|
+
.resolved => {},
|
|
228
|
+
.unresolved => {
|
|
229
|
+
// Safety net for direct `zig build` users: the `native` CLI
|
|
230
|
+
// gates this itself, so reaching here means zig was invoked by
|
|
231
|
+
// hand against an SDK whose toolchain resolves nowhere. Name
|
|
232
|
+
// the SDK dependency's real location as a RESOLVED path and
|
|
233
|
+
// fail the configure phase cleanly — a teaching message, never
|
|
234
|
+
// a panic stack trace.
|
|
235
|
+
const sdk_root = tsSdkRoot(dep.builder.allocator, dep.builder.graph.io, dep);
|
|
236
|
+
std.debug.print(
|
|
237
|
+
\\
|
|
238
|
+
\\error: the @native-sdk/core transpiler cannot resolve its TypeScript toolchain
|
|
239
|
+
\\(its compiler, @typescript/old). On a repo checkout, install it once with:
|
|
240
|
+
\\ cd {s}/packages/core && npm ci --include=dev
|
|
241
|
+
\\(An npm-installed @native-sdk/cli carries the toolchain automatically; if it
|
|
242
|
+
\\is missing there, the install is broken - reinstall @native-sdk/cli.)
|
|
243
|
+
\\
|
|
244
|
+
\\
|
|
245
|
+
, .{sdk_root});
|
|
246
|
+
std.process.exit(1);
|
|
247
|
+
},
|
|
248
|
+
.version_mismatch => |mismatch| {
|
|
249
|
+
// The wrong-VERSION shape gets its own teaching (the CLI's
|
|
250
|
+
// gate mirrors it): a conflicting consumer-tree
|
|
251
|
+
// @typescript/old shadows the SDK's exact pin, and no install
|
|
252
|
+
// command fixes what is already installed — the conflict has
|
|
253
|
+
// to move.
|
|
254
|
+
std.debug.print(
|
|
255
|
+
\\
|
|
256
|
+
\\error: the @native-sdk/core transpiler's TypeScript compiler resolves at the
|
|
257
|
+
\\wrong version: @typescript/old resolves to typescript {s}, but the SDK pins
|
|
258
|
+
\\npm:typescript@{s}. Another package in this tree pins a conflicting
|
|
259
|
+
\\@typescript/old - align it with the SDK's pin (or remove it) and reinstall,
|
|
260
|
+
\\so the SDK's exact pin is the copy that resolves.
|
|
261
|
+
\\
|
|
262
|
+
\\
|
|
263
|
+
, .{ mismatch.resolved, mismatch.pinned });
|
|
264
|
+
std.process.exit(1);
|
|
265
|
+
},
|
|
266
|
+
}
|
|
94
267
|
|
|
95
268
|
// The transpiler runs through build/ts_run.mjs, not as `node cli.ts`:
|
|
96
269
|
// on the npm-installed layout the transpiler's .ts sources live inside
|
|
@@ -388,6 +561,18 @@ pub fn addAppArtifacts(b: *std.Build, dep: *std.Build.Dependency, app_options: A
|
|
|
388
561
|
.name = app_options.name,
|
|
389
562
|
.root_module = app_mod,
|
|
390
563
|
});
|
|
564
|
+
// Windows subsystem posture: release-shaped exes (`native build`,
|
|
565
|
+
// and therefore everything `native package --target windows` wraps)
|
|
566
|
+
// are GUI-subsystem, so launching the app never flashes a console
|
|
567
|
+
// window behind it. Debug exes keep the console subsystem — the dev
|
|
568
|
+
// loop's logs live there, and a double-clicked Debug binary opening
|
|
569
|
+
// its own log console is a feature. Redirected logging still works
|
|
570
|
+
// on GUI exes (handles inherit; only console AUTO-allocation is
|
|
571
|
+
// gated by the subsystem), so automation harnesses that pipe
|
|
572
|
+
// `app.exe > log 2>&1` keep their logs either way.
|
|
573
|
+
if (target.result.os.tag == .windows and app_optimize != .Debug) {
|
|
574
|
+
exe.subsystem = .windows;
|
|
575
|
+
}
|
|
391
576
|
linkPlatform(b, dep, target, app_mod, exe, selected_platform, web_engine, web_layer, cef_dir, cef_auto_install);
|
|
392
577
|
const install = b.addInstallArtifact(exe, .{});
|
|
393
578
|
b.getInstallStep().dependOn(&install.step);
|
package/build/ts_run.mjs
CHANGED
|
@@ -5,21 +5,28 @@
|
|
|
5
5
|
//
|
|
6
6
|
// node ts_run.mjs <module.ts> [args...]
|
|
7
7
|
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
//
|
|
17
|
-
//
|
|
18
|
-
//
|
|
8
|
+
// ONE code path for every layout: a load hook strips EVERY .ts module with
|
|
9
|
+
// the transpiler's own pinned TypeScript compiler (shipped as a dependency
|
|
10
|
+
// of @native-sdk/cli, or a repo checkout's `npm ci` install inside
|
|
11
|
+
// packages/core — either way resolved from the target module's location by
|
|
12
|
+
// node's ancestor node_modules walk). Node's own type stripping is never
|
|
13
|
+
// relied on: it refuses node_modules-resident .ts by design
|
|
14
|
+
// (ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING), and outside node_modules
|
|
15
|
+
// it only became DEFAULT in node 22.18 — so a checkout target on
|
|
16
|
+
// 22.15-22.17 would die with ERR_UNKNOWN_FILE_EXTENSION if the hook let it
|
|
17
|
+
// "fall through". Hooking everything makes the 22.15 floor true for both
|
|
18
|
+
// layouts. Then the runner imports the requested module with argv
|
|
19
|
+
// respliced so the target sees its usual shape (its own path at argv[1],
|
|
20
|
+
// its arguments from argv[2]).
|
|
19
21
|
//
|
|
20
|
-
// On node builds without module.registerHooks (
|
|
21
|
-
//
|
|
22
|
-
//
|
|
22
|
+
// On node builds without module.registerHooks (pre-22.15, or 23.0-23.4 —
|
|
23
|
+
// the hook landed in 22.15 and 23.5, so ">=22.15" alone is not the
|
|
24
|
+
// capability line) NO .ts target can run — node_modules-resident
|
|
25
|
+
// stripping is refused by design and default stripping outside
|
|
26
|
+
// node_modules only landed in 22.18, which is above this tier anyway —
|
|
27
|
+
// so the runner fails fast with one teaching line (upgrade to Node.js
|
|
28
|
+
// 22.15+, on the 23 line 23.5+) before importing it, instead of
|
|
29
|
+
// surfacing node's raw extension/stripping error.
|
|
23
30
|
|
|
24
31
|
import module, { createRequire } from 'node:module';
|
|
25
32
|
import { readFileSync } from 'node:fs';
|
|
@@ -36,15 +43,47 @@ const targetPath = resolve(target);
|
|
|
36
43
|
// exactly as when node runs it directly.
|
|
37
44
|
process.argv.splice(1, 1);
|
|
38
45
|
|
|
39
|
-
if (typeof module.registerHooks
|
|
46
|
+
if (typeof module.registerHooks !== 'function') {
|
|
47
|
+
// No load hooks on this node (pre-22.15, or a 23.0-23.4 build). Every
|
|
48
|
+
// .ts target needs the hook — node_modules-resident stripping is
|
|
49
|
+
// refused by design, and native default stripping outside node_modules
|
|
50
|
+
// is 22.18+ — so any .ts target would fail deep inside node with a raw
|
|
51
|
+
// extension/stripping error. Teach the fix instead.
|
|
52
|
+
if (targetPath.endsWith('.ts')) {
|
|
53
|
+
console.error(
|
|
54
|
+
`TypeScript apps need Node.js 22.15+ (on the 23 line: 23.5+); you're running ${process.version} - upgrade node and re-run.`,
|
|
55
|
+
);
|
|
56
|
+
process.exit(1);
|
|
57
|
+
}
|
|
58
|
+
} else {
|
|
40
59
|
let ts = null;
|
|
41
60
|
module.registerHooks({
|
|
42
61
|
load(url, context, nextLoad) {
|
|
43
|
-
if (url.startsWith('file:') && url.endsWith('.ts')
|
|
62
|
+
if (url.startsWith('file:') && url.endsWith('.ts')) {
|
|
44
63
|
const filePath = fileURLToPath(url);
|
|
45
|
-
// The transpiler's own
|
|
46
|
-
// location (packages/core/node_modules after the taught
|
|
47
|
-
|
|
64
|
+
// The transpiler's own pinned compiler, resolved from the target
|
|
65
|
+
// module's location (packages/core/node_modules after the taught
|
|
66
|
+
// `npm ci`, or the dependency npm installed beside the CLI). The
|
|
67
|
+
// ALIAS is required directly — not the @typescript/typescript6
|
|
68
|
+
// wrapper — because the wrapper's re-export resolves
|
|
69
|
+
// "@typescript/old" from the WRAPPER's own location, where a
|
|
70
|
+
// consumer tree's conflicting hoisted copy would win nearest-wins
|
|
71
|
+
// over our exact pin; resolving from the target finds our own
|
|
72
|
+
// nested/hoisted pin first (same reasoning as typed_ast.ts).
|
|
73
|
+
if (ts === null) {
|
|
74
|
+
try {
|
|
75
|
+
ts = createRequire(targetPath)('@typescript/old');
|
|
76
|
+
} catch {
|
|
77
|
+
// A missing toolchain reaches here only on a direct
|
|
78
|
+
// `node ts_run.mjs` run: every CLI verb gates resolution with
|
|
79
|
+
// a fuller per-layout teaching before this runner is spawned.
|
|
80
|
+
// Keep the direct-run error sane and name the checkout fix.
|
|
81
|
+
console.error(
|
|
82
|
+
`ts_run.mjs: the transpiler's TypeScript toolchain (@typescript/old) does not resolve from ${targetPath} - on a repo checkout, run \`npm ci --include=dev\` in packages/core.`,
|
|
83
|
+
);
|
|
84
|
+
process.exit(1);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
48
87
|
const { outputText } = ts.transpileModule(readFileSync(filePath, 'utf8'), {
|
|
49
88
|
fileName: filePath,
|
|
50
89
|
compilerOptions: {
|
package/build.zig
CHANGED
|
@@ -462,6 +462,48 @@ pub fn build(b: *std.Build) void {
|
|
|
462
462
|
.{ .path = "packages/native-sdk/native-sdk.d.ts", .pattern = "\"gpuSurfaces\"" },
|
|
463
463
|
.{ .path = "packages/native-sdk/native-sdk.d.ts", .pattern = "gpuFirstFrameLatencyNs: number" },
|
|
464
464
|
});
|
|
465
|
+
addFileContainsCheckStep(b, file_contains_checker, test_step, "test-ts-toolchain-twins", "Verify the CLI's toolchain-resolution gate and its direct-`zig build` twin stay in lockstep (both resolve the aliased real compiler @typescript/old from packages/core — the same origin runtime imports it from — hold its resolved version against the manifest-read pin, never probe the unused @typescript/typescript6 wrapper, and teach instead of panicking)", &.{
|
|
466
|
+
// The resolution twins probe the aliased REAL compiler
|
|
467
|
+
// (@typescript/old — the package typed_ast.ts and ts_run.mjs
|
|
468
|
+
// actually load) — manifest AND entrypoint, in lockstep. The
|
|
469
|
+
// @typescript/typescript6 wrapper is never probed: nothing
|
|
470
|
+
// imports it at run time, and validating it false-rejects
|
|
471
|
+
// healthy conflict trees.
|
|
472
|
+
.{ .path = "src/tooling/ts_core.zig", .pattern = "\"node_modules\", \"@typescript\", \"old\", \"package.json\"" },
|
|
473
|
+
.{ .path = "src/tooling/ts_core.zig", .pattern = "\"node_modules\", \"@typescript\", \"old\", \"lib\", \"typescript.js\"" },
|
|
474
|
+
.{ .path = "build/app.zig", .pattern = "\"node_modules\", \"@typescript\", \"old\", \"package.json\"" },
|
|
475
|
+
.{ .path = "build/app.zig", .pattern = "\"node_modules\", \"@typescript\", \"old\", \"lib\", \"typescript.js\"" },
|
|
476
|
+
// The doctrine both twins document at their predicates: validate
|
|
477
|
+
// only what runtime loads, from runtime's own walk origin, and
|
|
478
|
+
// leave the declared-but-unimported wrapper out of the verdict.
|
|
479
|
+
.{ .path = "src/tooling/ts_core.zig", .pattern = "Validation tracks ONLY what runtime loads" },
|
|
480
|
+
.{ .path = "src/tooling/ts_core.zig", .pattern = "wrapper is deliberately NOT probed" },
|
|
481
|
+
.{ .path = "build/app.zig", .pattern = "Validation tracks ONLY what runtime loads" },
|
|
482
|
+
.{ .path = "build/app.zig", .pattern = "wrapper is deliberately NOT probed" },
|
|
483
|
+
// The reciprocal cross-references that keep the twins findable
|
|
484
|
+
// from each other.
|
|
485
|
+
.{ .path = "src/tooling/ts_core.zig", .pattern = "build/app.zig's tsToolchainResolution" },
|
|
486
|
+
.{ .path = "build/app.zig", .pattern = "transpilerResolution, this predicate's deliberate twin" },
|
|
487
|
+
// The version pin: both twins read the alias's RESOLVED
|
|
488
|
+
// package.json version and hold it against the exact
|
|
489
|
+
// `npm:typescript@X.Y.Z` pin read from the SDK's own
|
|
490
|
+
// packages/core/package.json (never hardcoded), and both carry
|
|
491
|
+
// the mismatch outcome plus its teaching naming the two versions.
|
|
492
|
+
.{ .path = "src/tooling/ts_core.zig", .pattern = "parseAliasedCompilerPin" },
|
|
493
|
+
.{ .path = "src/tooling/ts_core.zig", .pattern = "version_mismatch" },
|
|
494
|
+
.{ .path = "src/tooling/ts_core.zig", .pattern = "npm:typescript@{s}" },
|
|
495
|
+
.{ .path = "build/app.zig", .pattern = "tsPinnedCompilerVersion" },
|
|
496
|
+
.{ .path = "build/app.zig", .pattern = "version_mismatch" },
|
|
497
|
+
.{ .path = "build/app.zig", .pattern = "npm:typescript@{s}" },
|
|
498
|
+
// The teachings: the checkout's one production-config-safe npm ci
|
|
499
|
+
// command in both surfaces, the reinstall for npm layouts, and the
|
|
500
|
+
// build graph's clean configure-time failure (never a panic).
|
|
501
|
+
.{ .path = "src/tooling/ts_core.zig", .pattern = "pub const npm_ci_teaching_command = \"npm ci --include=dev\";" },
|
|
502
|
+
.{ .path = "src/tooling/ts_core.zig", .pattern = "reinstall @native-sdk/cli" },
|
|
503
|
+
.{ .path = "build/app.zig", .pattern = "npm ci --include=dev" },
|
|
504
|
+
.{ .path = "build/app.zig", .pattern = "cannot resolve its TypeScript toolchain" },
|
|
505
|
+
.{ .path = "build/app.zig", .pattern = "std.process.exit(1);" },
|
|
506
|
+
});
|
|
465
507
|
addFileContainsCheckStep(b, file_contains_checker, test_step, "test-app-test-entry-analysis", "Verify the managed app test step force-analyzes the entry point (UiApp.create's Model-defaults rule must teach at `native test`, not ambush at `native build`)", &.{
|
|
466
508
|
.{ .path = "build/app.zig", .pattern = "app_analysis.zig" },
|
|
467
509
|
.{ .path = "build/app.zig", .pattern = "if (@hasDecl(app, \"main\")) _ = &app.main;" },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@native-sdk/cli",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"description": "The Native SDK: the complete toolkit for building native desktop applications — declarative markup, native rendering, WebView surfaces, and OS capabilities",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -27,15 +27,19 @@
|
|
|
27
27
|
"README.md",
|
|
28
28
|
"LICENSE"
|
|
29
29
|
],
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@typescript/old": "npm:typescript@6.0.3",
|
|
32
|
+
"@typescript/typescript6": "6.0.2"
|
|
33
|
+
},
|
|
30
34
|
"optionalDependencies": {
|
|
31
|
-
"@native-sdk/cli-darwin-arm64": "0.5.
|
|
32
|
-
"@native-sdk/cli-darwin-x64": "0.5.
|
|
33
|
-
"@native-sdk/cli-linux-arm64-gnu": "0.5.
|
|
34
|
-
"@native-sdk/cli-linux-arm64-musl": "0.5.
|
|
35
|
-
"@native-sdk/cli-linux-x64-gnu": "0.5.
|
|
36
|
-
"@native-sdk/cli-linux-x64-musl": "0.5.
|
|
37
|
-
"@native-sdk/cli-win32-arm64": "0.5.
|
|
38
|
-
"@native-sdk/cli-win32-x64": "0.5.
|
|
35
|
+
"@native-sdk/cli-darwin-arm64": "0.5.2",
|
|
36
|
+
"@native-sdk/cli-darwin-x64": "0.5.2",
|
|
37
|
+
"@native-sdk/cli-linux-arm64-gnu": "0.5.2",
|
|
38
|
+
"@native-sdk/cli-linux-arm64-musl": "0.5.2",
|
|
39
|
+
"@native-sdk/cli-linux-x64-gnu": "0.5.2",
|
|
40
|
+
"@native-sdk/cli-linux-x64-musl": "0.5.2",
|
|
41
|
+
"@native-sdk/cli-win32-arm64": "0.5.2",
|
|
42
|
+
"@native-sdk/cli-win32-x64": "0.5.2"
|
|
39
43
|
},
|
|
40
44
|
"repository": {
|
|
41
45
|
"type": "git",
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@native-sdk/core",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@native-sdk/core",
|
|
9
|
-
"version": "0.5.
|
|
9
|
+
"version": "0.5.2",
|
|
10
10
|
"devDependencies": {
|
|
11
|
-
"@typescript/
|
|
11
|
+
"@typescript/old": "npm:typescript@6.0.3",
|
|
12
|
+
"@typescript/typescript6": "6.0.2"
|
|
12
13
|
}
|
|
13
14
|
},
|
|
14
15
|
"node_modules/@typescript/old": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@native-sdk/core",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"description": "The TypeScript authoring tier: the app-core subset, its dev-time transpiler to arena-backed Zig, and the SDK module cores import",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"gate": "node scripts/gate.mjs"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@typescript/
|
|
35
|
+
"@typescript/old": "npm:typescript@6.0.3",
|
|
36
|
+
"@typescript/typescript6": "6.0.2"
|
|
36
37
|
}
|
|
37
38
|
}
|
|
@@ -13,7 +13,17 @@
|
|
|
13
13
|
// - Every TYPE question goes through the named queries on `TypedAst` below.
|
|
14
14
|
// Checker/emitter code never touches `program.getTypeChecker()` directly.
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
// The IMPORT deliberately bypasses the `@typescript/typescript6` wrapper
|
|
17
|
+
// (which stays the declared dependency — it is the provider named above,
|
|
18
|
+
// and its own dependency IS this alias): the wrapper's lib/typescript.js
|
|
19
|
+
// re-exports "@typescript/old" resolved from the WRAPPER's location, so a
|
|
20
|
+
// consumer tree already carrying a conflicting hoisted @typescript/old
|
|
21
|
+
// would win node's nearest-wins walk there while our exactly pinned copy
|
|
22
|
+
// sat nested and unused. Importing the alias directly resolves it from
|
|
23
|
+
// THIS file — inside our package, where our own nested/hoisted exact pin
|
|
24
|
+
// is always the nearest — and the CLI's resolution gate additionally
|
|
25
|
+
// verifies the resolved version against the pin.
|
|
26
|
+
import tsImpl from "@typescript/old";
|
|
17
27
|
import path from "node:path";
|
|
18
28
|
import { fileURLToPath } from "node:url";
|
|
19
29
|
|
|
@@ -171,7 +171,7 @@ Automation drives the native path honestly: snapshots list every widget's declar
|
|
|
171
171
|
| `resizable` | resizable | engine-managed drag handle; `width` sets the initial width |
|
|
172
172
|
| `split` | split | two-pane horizontal splitter: exactly two element children (nest splits for more panes), the engine synthesizes the draggable divider between them. `value` binds the model-owned first-pane fraction (0 lays out at 0.5), `on-resize` names an f32 Msg variant dispatched with every applied fraction (echo it back through `value` — see Splitters), `min-width` on the panes bounds the drag, `gap` sets the divider band thickness. The divider is focusable: Left/Right (Shift for bigger steps) adjust, Home/End jump to the clamp edges |
|
|
173
173
|
| `tree` | tree | disclosure-tree container (vertical flow): descendant rows carrying `role="treeitem"` — at ANY nesting depth — form one roving keyboard focus set with the ARIA tree keymap. Up/Down walk visible rows (selection follows focus through each row's `on-press`), Left collapses an expanded row or moves to the parent row, Right expands a collapsed row or moves to the first child row, Home/End jump to the edges, Enter/Space activate. Expandable rows bind `expanded` and `on-toggle`; the model owns selection and expansion (collapsed children are simply not rendered) |
|
|
174
|
-
| `text`, `badge`, `tooltip` | text leaves | text content, `{}` interpolation allowed; `text` line policy via `wrap` (`"true"` word-wraps; `"false"`/unset paint one honest line, overflow eliding by default — `overflow="clip"` opts out), and `text` alone takes the typography rungs `size="heading"`/`size="display"` (themable token steps above title — section headings, hero stats, timer numerals) |
|
|
174
|
+
| `text`, `badge`, `tooltip` | text leaves | text content, `{}` interpolation allowed; `text` line policy via `wrap` (`"true"` word-wraps; `"false"`/unset paint one honest line, overflow eliding by default — `overflow="clip"` opts out), and `text` alone takes the typography rungs `size="heading"`/`size="display"` (themable token steps above title — section headings, hero stats, timer numerals). `tooltip` with `anchor="above\|below"` floats against its parent (the stack wrapping trigger + tooltip, the dropdown pattern) and the RUNTIME owns its visibility — hover intent on the trigger: shows after `tooltip-delay` ms (default 600; `"0"` = instant) and immediately on keyboard focus; hides on leave, focus departure, Escape, or a press of the trigger (a press also closes the warm window), and a shared 400ms warm window after a pointer-hovered tooltip hides on leave (the only hide that warms) shows the next trigger's tooltip instantly; the model never hears hover. These are shadcn/ui's defaults (Base UI). Without `anchor` it stays a static leaf that paints whenever the view renders it |
|
|
175
175
|
| `text` > `span` | inline styled runs | mixed-style text in ONE wrapped paragraph: span children style runs with `weight="regular\|medium\|bold"`, `mono`, `italic`, `scale` (a positive multiplier on the paragraph's base size — inline headings, hero stats), `underline`, `foreground` (token name); `{bindings}` interpolate inside spans; whitespace between runs collapses to a single space (none = the runs abut); spans do not nest, take no events, and the paragraph announces as one text run — see "Rich text" |
|
|
176
176
|
| `button`, `toggle-button`, `list-item`, `menu-item`, `toggle`, `switch`, `select`, `avatar` | text-bearing controls | label is the text content; `button`, `toggle-button`, `list-item`, and `menu-item` also take `icon="save"` — a vector icon drawn inline (buttons/toggle-buttons before the label, icon-only when the content is empty: add a `label`; list/menu items as a leading slot), ONE hit target whose icon follows the element's enabled/disabled tint (no overlay stacking, no duplicated `on-press`); tab strips are `toggle-button` children, so tabs get icons this way; `select` shows `placeholder` while empty and dispatches `on-press`; `avatar` renders initials, or a runtime image via `image="{binding}"` (see the Images section) |
|
|
177
177
|
| `checkbox`, `radio`, `slider`, `progress` | value controls | `checked`, `value` (a 0..1 fraction on slider and progress; progress clamps out-of-range values at render, never an error); the checkbox/radio label rides `text="..."` — these are not text-bearing elements, so text content is a teaching error (`label=` alone names one for accessibility without a visible label); a slider's `value` follows the source when it MOVES (model-driven progress renders every rebuild) and keeps the user's drag while the source replays the same value — use `slider` for seek bars, `progress` for display-only; a markup slider's `on-change` dispatches a PLAIN Msg with no value payload — mirror the applied value into the model with `Options.sync` (the Zig builder's `on_value = Ui.valueMsg(.tag)` does deliver the applied f32) |
|
|
@@ -191,7 +191,7 @@ Not markup-expressible (deliberately — write these as Zig view functions with
|
|
|
191
191
|
|
|
192
192
|
## Attributes
|
|
193
193
|
|
|
194
|
-
Layout: `gap` (flow containers only — stacking containers `stack`/`panel`/`card`/`alert`/`bubble`/`dialog`/`drawer`/`sheet`/`resizable` layer their children, so `gap` there is a validation error, not silence: wrap the children in a `column`/`row` inside; on `split` it sets the divider band thickness), `padding` (uniform), `grow`, `width`, `height` (definite: the element is exactly that size — intrinsic content neither shrinks nor silently overflows it; `resizable` treats `width` as the initial width), `min-width` (a floor WITHOUT `width`'s definite max — the element may grow past it but never shrink below; on split panes it bounds the divider drag), `wrap` (`text` only: `wrap="true"` word-wraps at the width the element receives and reserves the wrapped height in columns; `wrap="false"` and unset are honest single-line — one line whose overflow follows `overflow`), `overflow` (`text` only, a teaching error elsewhere: what a single line does with content that does not fit — `ellipsis`, the default, elides behind a trailing … measured with the same metrics paint uses, right for width-constrained list-row titles; `clip` hard-cuts at the frame for fixed-format content like a duration column where "1…" beats nothing; there is deliberately no overflow-visible), `text-alignment` (start|center|end — text leaves, status bars, surface titles; controls that own their label placement ignore it), `columns` (`grid` only: fixed column count, omit for the derived near-square grid; a teaching error elsewhere), `main` (start|center|end|space_between), `cross` (stretch|start|center|end), `virtualized`, `virtual-item-extent`, `anchor` (`dropdown-menu`
|
|
194
|
+
Layout: `gap` (flow containers only — stacking containers `stack`/`panel`/`card`/`alert`/`bubble`/`dialog`/`drawer`/`sheet`/`resizable` layer their children, so `gap` there is a validation error, not silence: wrap the children in a `column`/`row` inside; on `split` it sets the divider band thickness), `padding` (uniform), `grow`, `width`, `height` (definite: the element is exactly that size — intrinsic content neither shrinks nor silently overflows it; `resizable` treats `width` as the initial width), `min-width` (a floor WITHOUT `width`'s definite max — the element may grow past it but never shrink below; on split panes it bounds the divider drag), `wrap` (`text` only: `wrap="true"` word-wraps at the width the element receives and reserves the wrapped height in columns; `wrap="false"` and unset are honest single-line — one line whose overflow follows `overflow`), `overflow` (`text` only, a teaching error elsewhere: what a single line does with content that does not fit — `ellipsis`, the default, elides behind a trailing … measured with the same metrics paint uses, right for width-constrained list-row titles; `clip` hard-cuts at the frame for fixed-format content like a duration column where "1…" beats nothing; there is deliberately no overflow-visible), `text-alignment` (start|center|end — text leaves, status bars, surface titles; controls that own their label placement ignore it), `columns` (`grid` only: fixed column count, omit for the derived near-square grid; a teaching error elsewhere), `main` (start|center|end|space_between), `cross` (stretch|start|center|end), `virtualized`, `virtual-item-extent`, `anchor` (`dropdown-menu` and `tooltip`, literal `below`/`above`: floats the surface against its parent instead of the flow — auto-flips when the preferred side does not fit, height clamps to the chosen side, x clamps into the window; an anchored tooltip's visibility is runtime-owned hover intent, unlike the model-owned dropdown), `anchor-alignment` (with `anchor`: `start`/`end`/`stretch` — stretch also widens the surface to at least the anchor's width, the select-menu look), `anchor-offset` (with `anchor`: literal gap in points, default 4), `tooltip-delay` (`tooltip` only, beside `anchor` — a teaching error elsewhere or without it: hover-intent show delay in ms, default 600, `"0"` = instant; keyboard-focus reveals are always immediate), `overscroll` (`scroll` only, a teaching error elsewhere: `none` pins the region at its content edges — the shipped default via the `ScrollPhysics.overscroll` token — `rubber_band` lets it bounce past them on both the engine and native paths, `default` follows the token).
|
|
195
195
|
Appearance/state: `variant` (default|primary|secondary|outline|ghost|destructive), `size` (the control scale default|sm|lg|icon on every sized element; on `text` also the typography rungs heading|display — named typography token steps (`heading_size` 28, `display_size` 48, themable like every token) for section headings and hero stats/timer numerals. The two axes stay apart: heading/display on a control is a teaching error naming text as their home, unknown values list the vocabulary, and numeric sizes are refused by design — retheme the typography tokens to move the whole scale), `disabled`, `checked`, `selected`, `value`, `placeholder`, `icon` (`button`, `toggle-button`, `list-item`, `menu-item`: vector icon drawn inline — buttons/toggle-buttons before the label, list/menu items as a leading slot; a teaching error anywhere else. A built-in name, `app:<name>`, or one `{binding}` resolving to such a name). **One size register per row**: every control class shares the control height at a given register (default 36, sm 31.5, lg 40.5 before density), so a toolbar/filter row reads as one height exactly when every control in it carries the SAME `size` — mixing `size="sm"` buttons with a default field renders two heights in one row, and hand-sized pressable panels (`height="30"`) never land on the scale; compose rows from real controls at one register.
|
|
196
196
|
Focus: `autofocus` (focusable controls only — a teaching error elsewhere): moves keyboard focus to the element when it MOUNTS or when the bound value turns on, edge-triggered so holding it true never re-steals focus from the user. The TEA way to focus an editor on note-create (`<text-field autofocus="{editing}" ...>` or mount the field under an `<if>` with `autofocus="true"`; Zig views use `ElementOptions.autofocus`) and to give keyboard-first apps their first focus without a click.
|
|
197
197
|
Semantics: `role` (listitem, treeitem, button, ...; `treeitem` also makes the row part of its tree's roving keyboard focus set), `label` (accessible name — it REPLACES the element's text content as the announced name, so snapshot greps and screen readers see the label, never the text; don't `label` an element whose visible text you grep for), `expanded` (tree rows: disclosure state, model-owned — omit on leaves). Accessible names are ENFORCED: an interactive control with no text content, no `text=`, and no `label=` is a validation error (icon-only controls need `label`; text-entry controls need `label` or `placeholder`), unknown/misused literal roles are errors (`role="tree"` on a text leaf can never hold rows), unnamed avatars and labels duplicating the text content are warnings (`label=""` marks an image decorative). Zig-built trees get the same discipline from `canvas.expectA11yAuditSweepClean` (missing names as the bridges would announce them, focusables clipped out of keyboard reach, identically labeled siblings) — adopt it next to the layout sweep.
|
package/src/platform/types.zig
CHANGED
|
@@ -1817,6 +1817,15 @@ pub const WidgetAccessibilityActionKind = enum(c_int) {
|
|
|
1817
1817
|
drag = 8,
|
|
1818
1818
|
drop_files = 9,
|
|
1819
1819
|
dismiss = 10,
|
|
1820
|
+
// The composition verbs never arrive from desktop assistive-tech
|
|
1821
|
+
// bridges (AppKit has no AX composition action); they exist so the
|
|
1822
|
+
// DIRECT verb surfaces (embed hosts, automation commands) and the
|
|
1823
|
+
// session journal can carry every accessibility verb as one
|
|
1824
|
+
// `widget_accessibility_action` — replay re-runs the verb, focus
|
|
1825
|
+
// included, instead of replaying its untargeted ime children.
|
|
1826
|
+
set_composition = 11,
|
|
1827
|
+
commit_composition = 12,
|
|
1828
|
+
cancel_composition = 13,
|
|
1820
1829
|
};
|
|
1821
1830
|
|
|
1822
1831
|
pub const WidgetAccessibilityActionEvent = struct {
|
|
@@ -4480,6 +4480,23 @@ static bool windowsAppsUseDarkTheme() {
|
|
|
4480
4480
|
return dark;
|
|
4481
4481
|
}
|
|
4482
4482
|
|
|
4483
|
+
/* Standard-chrome titlebars follow the OS app color scheme: the
|
|
4484
|
+
* immersive-dark attribute flips the DWM caption to its dark palette,
|
|
4485
|
+
* so an app rendering the dark theme (apps follow the OS scheme through
|
|
4486
|
+
* the appearance channel by default) does not sit under a glaring white
|
|
4487
|
+
* titlebar. Hidden-titlebar windows own their caption fidelity already
|
|
4488
|
+
* (syncHiddenCaptionColor samples the presented header pixels — a
|
|
4489
|
+
* strictly better signal), and chromeless windows have no caption at
|
|
4490
|
+
* all, so both stay out of this. Older builds reject the attribute and
|
|
4491
|
+
* keep the system default. */
|
|
4492
|
+
static void applyStandardTitlebarColorScheme(Window &window) {
|
|
4493
|
+
if (!window.hwnd || windowUsesHiddenTitlebar(window) || windowIsChromeless(window)) return;
|
|
4494
|
+
const DwmApi &dwm = dwmApi();
|
|
4495
|
+
if (!dwm.set_window_attribute) return;
|
|
4496
|
+
const BOOL dark = windowsAppsUseDarkTheme() ? TRUE : FALSE;
|
|
4497
|
+
dwm.set_window_attribute(window.hwnd, kDwmwaUseImmersiveDarkMode, &dark, sizeof(dark));
|
|
4498
|
+
}
|
|
4499
|
+
|
|
4483
4500
|
/* Appearance from OS settings: the apps dark preference, disabled
|
|
4484
4501
|
* client-area animations as the reduce-motion signal, and the high
|
|
4485
4502
|
* contrast accessibility flag. Emitted once after START and again
|
|
@@ -4500,6 +4517,10 @@ static void emitAppearanceIfChanged(Host *host, bool force) {
|
|
|
4500
4517
|
host->appearance_color_scheme = dark;
|
|
4501
4518
|
host->appearance_reduce_motion = reduce_motion;
|
|
4502
4519
|
host->appearance_high_contrast = high_contrast;
|
|
4520
|
+
/* Standard-chrome captions track the scheme live: flipping the OS
|
|
4521
|
+
* theme flips the titlebar with the appearance event the app
|
|
4522
|
+
* re-themes from. */
|
|
4523
|
+
for (auto &entry : host->windows) applyStandardTitlebarColorScheme(entry.second);
|
|
4503
4524
|
WindowsEvent event = {};
|
|
4504
4525
|
event.kind = kAppearance;
|
|
4505
4526
|
event.color_scheme = dark;
|
|
@@ -4967,6 +4988,9 @@ static bool createNativeWindow(Host *host, Window &window) {
|
|
|
4967
4988
|
DragAcceptFiles(hwnd, TRUE);
|
|
4968
4989
|
window.hwnd = hwnd;
|
|
4969
4990
|
applyMenusToWindow(host, window);
|
|
4991
|
+
/* Before the first show, so a dark-scheme launch never flashes a
|
|
4992
|
+
* light caption. */
|
|
4993
|
+
applyStandardTitlebarColorScheme(window);
|
|
4970
4994
|
if (windowUsesHiddenTitlebar(window)) {
|
|
4971
4995
|
applyHiddenTitlebarFrame(window);
|
|
4972
4996
|
/* The create-time WM_NCCALCSIZE ran before this window was
|
|
@@ -69,11 +69,11 @@ pub const layout_audit_epsilon: f32 = 0.5;
|
|
|
69
69
|
/// call while the line breakers accumulate per-word measures, so an
|
|
70
70
|
/// exact-fit line can land one f32 ulp past its own frame (~1e-3 px) —
|
|
71
71
|
/// runtimes hide that under the pixel-snap wrap budget (`textWrapMaxWidth`
|
|
72
|
-
/// hands back
|
|
73
|
-
/// eighth of a point: far above accumulated float
|
|
74
|
-
/// smallest real overflow (a glyph) and below the
|
|
75
|
-
/// budget (
|
|
76
|
-
/// clean and genuine wraps still report.
|
|
72
|
+
/// hands back the full snap quantum, 1/scale). The audit widens its
|
|
73
|
+
/// simulated wrap by an eighth of a point: far above accumulated float
|
|
74
|
+
/// noise, below the smallest real overflow (a glyph) and below the
|
|
75
|
+
/// smallest runtime snap budget (1/scale at any real scale factor), so
|
|
76
|
+
/// exact-fit text stays clean and genuine wraps still report.
|
|
77
77
|
pub const layout_audit_wrap_slack: f32 = 0.125;
|
|
78
78
|
|
|
79
79
|
/// Findings reported per audit pass. A view with more than this many
|
|
@@ -371,6 +371,7 @@ pub const ControlVisualTokenOverrides = token_model.ControlVisualTokenOverrides;
|
|
|
371
371
|
pub const ControlTokenOverrides = token_model.ControlTokenOverrides;
|
|
372
372
|
pub const DesignTokenOverrides = token_model.DesignTokenOverrides;
|
|
373
373
|
pub const accentOverrides = token_model.accentOverrides;
|
|
374
|
+
pub const accentFocusRing = token_model.accentFocusRing;
|
|
374
375
|
pub const DesignTokens = token_model.DesignTokens;
|
|
375
376
|
|
|
376
377
|
// Canvas widget model and built-in factories live in `widgets.zig`; root keeps the public API stable.
|
|
@@ -695,6 +696,11 @@ pub const disclosureSettledOpen = @import("widget_tree.zig").disclosureSettledOp
|
|
|
695
696
|
pub const disclosureContentBottom = @import("widget_tree.zig").disclosureContentBottom;
|
|
696
697
|
pub const isWidgetConcealedByDisclosure = @import("widget_tree.zig").isWidgetConcealedByDisclosure;
|
|
697
698
|
pub const anchoredWidgetFrame = @import("widget_layout.zig").anchoredWidgetFrame;
|
|
699
|
+
/// Window-control reservation trigger (widget_layout.zig): true when a
|
|
700
|
+
/// laid-out tree left drag-header CONTENT under the OS window-control
|
|
701
|
+
/// cluster, so runtimes know to stamp `DesignTokens.window_controls`
|
|
702
|
+
/// and re-lay the view clear of it.
|
|
703
|
+
pub const windowDragContentUnderWindowControls = @import("widget_layout.zig").windowDragContentUnderWindowControls;
|
|
698
704
|
/// Split-pane geometry (widget_layout.zig): divider band width, the
|
|
699
705
|
/// fraction clamp band from the panes' min widths, and the in-place
|
|
700
706
|
/// subtree re-layout the runtime reconcile uses when it restores a
|