@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
|
@@ -1176,7 +1176,7 @@ pub fn RuntimeViewCanvasWidgetText(comptime RuntimeView: type) type {
|
|
|
1176
1176
|
}
|
|
1177
1177
|
const selected_index = point_index orelse return null;
|
|
1178
1178
|
const selected_widget = self.widget_layout_nodes[selected_index].widget;
|
|
1179
|
-
const focus = selected_widget.static_text_group_offset + point_offset;
|
|
1179
|
+
const focus = @as(usize, @intCast(selected_widget.static_text_group_offset)) + point_offset;
|
|
1180
1180
|
const anchor = if (extend)
|
|
1181
1181
|
self.canvas_widget_selected_text_group_anchor
|
|
1182
1182
|
else
|
|
@@ -1191,7 +1191,7 @@ pub fn RuntimeViewCanvasWidgetText(comptime RuntimeView: type) type {
|
|
|
1191
1191
|
if (candidate.static_text_group_id != group_id) {
|
|
1192
1192
|
continue;
|
|
1193
1193
|
}
|
|
1194
|
-
const source_start = candidate.static_text_group_offset;
|
|
1194
|
+
const source_start: usize = @intCast(candidate.static_text_group_offset);
|
|
1195
1195
|
const source_end = source_start +| candidate.text.len;
|
|
1196
1196
|
const next_selection: ?canvas.TextSelection = if (selection_start == selection_end)
|
|
1197
1197
|
if (candidate_index == selected_index)
|
|
@@ -1321,7 +1321,7 @@ pub fn RuntimeViewCanvasWidgetText(comptime RuntimeView: type) type {
|
|
|
1321
1321
|
if (widget.static_text_group_id != group_id) {
|
|
1322
1322
|
continue;
|
|
1323
1323
|
}
|
|
1324
|
-
const source_start = widget.static_text_group_offset;
|
|
1324
|
+
const source_start: usize = @intCast(widget.static_text_group_offset);
|
|
1325
1325
|
const source_end = source_start +| widget.text.len;
|
|
1326
1326
|
const copy_start = @max(start, source_start);
|
|
1327
1327
|
const copy_end = @min(end, source_end);
|
|
@@ -1378,7 +1378,9 @@ pub fn RuntimeViewCanvasWidgetText(comptime RuntimeView: type) type {
|
|
|
1378
1378
|
self.widget_layout_nodes[edited_index].widget.text_selection = next_state.selection;
|
|
1379
1379
|
self.widget_layout_nodes[edited_index].widget.text_composition = next_state.composition;
|
|
1380
1380
|
if (text_changed) {
|
|
1381
|
-
self.widget_layout_nodes[edited_index].widget.
|
|
1381
|
+
if (!self.widget_layout_nodes[edited_index].widget.hasCodeDiff()) {
|
|
1382
|
+
self.widget_layout_nodes[edited_index].widget.code_content_width_generation = 0;
|
|
1383
|
+
}
|
|
1382
1384
|
canvas.cacheTextInputContentWidthForWidget(
|
|
1383
1385
|
&self.widget_layout_nodes[edited_index].widget,
|
|
1384
1386
|
self.widget_tokens,
|
|
@@ -484,6 +484,7 @@ pub fn RuntimeWindowViewRuntime(comptime Runtime: type) type {
|
|
|
484
484
|
.transparent = options.transparent,
|
|
485
485
|
.bridge_enabled = options.bridge_enabled,
|
|
486
486
|
.gpu_size = if (options.kind == .gpu_surface) options.frame.size() else geometry.SizeF.init(0, 0),
|
|
487
|
+
.gpu_requested_backend = if (options.kind == .gpu_surface) options.gpu_surface.backend else .none,
|
|
487
488
|
.gpu_backend = if (options.kind == .gpu_surface) options.gpu_surface.backend else .none,
|
|
488
489
|
.gpu_pixel_format = if (options.kind == .gpu_surface) options.gpu_surface.pixel_format else .none,
|
|
489
490
|
.gpu_present_mode = if (options.kind == .gpu_surface) options.gpu_surface.present_mode else .none,
|
package/src/tooling/manifest.zig
CHANGED
|
@@ -28,6 +28,10 @@ pub const Metadata = struct {
|
|
|
28
28
|
/// inferred from the manifest's web declarations), "include", or
|
|
29
29
|
/// "exclude". See `webLayer` for the inference.
|
|
30
30
|
webview_layer: []const u8 = "auto",
|
|
31
|
+
/// How a TypeScript core compiles: "external" (the default and only
|
|
32
|
+
/// lane — the external core compiler). The removed transpiled
|
|
33
|
+
/// lane's spelling is refused with a teaching at validation.
|
|
34
|
+
core_compiler: []const u8 = "external",
|
|
31
35
|
/// The built-in theme pack the app selects (`theme = "geist"`).
|
|
32
36
|
/// Optional — absent keeps the house register. Validated against
|
|
33
37
|
/// the known pack names so a typo is a check error, never a silent
|
|
@@ -64,6 +68,7 @@ pub const Metadata = struct {
|
|
|
64
68
|
allocator.free(self.version);
|
|
65
69
|
allocator.free(self.web_engine);
|
|
66
70
|
allocator.free(self.webview_layer);
|
|
71
|
+
allocator.free(self.core_compiler);
|
|
67
72
|
allocator.free(self.cef.dir);
|
|
68
73
|
for (self.icons) |value| allocator.free(value);
|
|
69
74
|
if (self.icons.len > 0) allocator.free(self.icons);
|
|
@@ -430,6 +435,12 @@ pub fn validateFile(allocator: std.mem.Allocator, io: std.Io, path: []const u8)
|
|
|
430
435
|
defer allocator.free(url_schemes);
|
|
431
436
|
const manifest_web_engine = parseWebEngine(metadata.web_engine) catch return .{ .ok = false, .message = "app.zon web engine is invalid" };
|
|
432
437
|
const manifest_webview_layer = parseWebViewLayer(metadata.webview_layer) catch return .{ .ok = false, .message = "app.zon webview_layer is invalid - expected \"auto\", \"include\", or \"exclude\"" };
|
|
438
|
+
if (!std.mem.eql(u8, metadata.core_compiler, "external")) {
|
|
439
|
+
if (std.mem.eql(u8, metadata.core_compiler, "transpiler")) {
|
|
440
|
+
return .{ .ok = false, .message = "app.zon core_compiler = \"transpiler\" names the removed TS-to-Zig transpiled lane (v0.7.0 removed it) - TypeScript cores compile through the external core compiler now; delete the setting (or spell it \"external\")" };
|
|
441
|
+
}
|
|
442
|
+
return .{ .ok = false, .message = "app.zon core_compiler is invalid - expected \"external\" (the default and only lane)" };
|
|
443
|
+
}
|
|
433
444
|
const platform_settings = parsePlatformSettings(allocator, metadata.platforms) catch return .{ .ok = false, .message = "app.zon platforms are invalid" };
|
|
434
445
|
defer allocator.free(platform_settings);
|
|
435
446
|
|
|
@@ -514,6 +525,7 @@ pub fn parseText(allocator: std.mem.Allocator, source: []const u8) !Metadata {
|
|
|
514
525
|
.bridge_commands = try convertRawBridgeCommands(allocator, raw.bridge.commands),
|
|
515
526
|
.web_engine = try allocator.dupe(u8, raw.web_engine),
|
|
516
527
|
.webview_layer = try allocator.dupe(u8, raw.webview_layer),
|
|
528
|
+
.core_compiler = try allocator.dupe(u8, raw.core_compiler),
|
|
517
529
|
.cef = .{
|
|
518
530
|
.dir = try allocator.dupe(u8, raw.cef.dir),
|
|
519
531
|
.auto_install = raw.cef.auto_install,
|
|
@@ -1946,6 +1958,26 @@ test "manifest parser reads window close policies" {
|
|
|
1946
1958
|
try std.testing.expectEqual(app_manifest.WindowClosePolicy.hide, shell.windows[0].close_policy);
|
|
1947
1959
|
}
|
|
1948
1960
|
|
|
1961
|
+
test "manifest parser reads the core-compiler setting and defaults it to external" {
|
|
1962
|
+
const metadata = try parseText(std.testing.allocator,
|
|
1963
|
+
\\.{
|
|
1964
|
+
\\ .id = "com.example.app",
|
|
1965
|
+
\\ .name = "example",
|
|
1966
|
+
\\ .version = "1.2.3",
|
|
1967
|
+
\\ .core_compiler = "external",
|
|
1968
|
+
\\}
|
|
1969
|
+
);
|
|
1970
|
+
defer metadata.deinit(std.testing.allocator);
|
|
1971
|
+
try std.testing.expectEqualStrings("external", metadata.core_compiler);
|
|
1972
|
+
|
|
1973
|
+
// Undeclared is the external lane — the one lane there is.
|
|
1974
|
+
const defaulted = try parseText(std.testing.allocator,
|
|
1975
|
+
\\.{ .id = "com.example.app", .name = "example", .version = "1.2.3" }
|
|
1976
|
+
);
|
|
1977
|
+
defer defaulted.deinit(std.testing.allocator);
|
|
1978
|
+
try std.testing.expectEqualStrings("external", defaulted.core_compiler);
|
|
1979
|
+
}
|
|
1980
|
+
|
|
1949
1981
|
test "manifest parser rejects unknown window close policy" {
|
|
1950
1982
|
const metadata = try parseText(std.testing.allocator,
|
|
1951
1983
|
\\.{
|
|
@@ -13,6 +13,10 @@ pub const RawManifest = struct {
|
|
|
13
13
|
bridge: RawBridge = .{},
|
|
14
14
|
web_engine: []const u8 = @tagName(web_engine.default_engine),
|
|
15
15
|
webview_layer: []const u8 = "auto",
|
|
16
|
+
/// How a TypeScript core compiles: "external" (the default and only
|
|
17
|
+
/// lane — the external core compiler). The removed transpiled
|
|
18
|
+
/// lane's spelling is refused with a teaching at validation.
|
|
19
|
+
core_compiler: []const u8 = "external",
|
|
16
20
|
theme: ?[]const u8 = null,
|
|
17
21
|
theme_accent: ?[]const u8 = null,
|
|
18
22
|
cef: RawCef = .{},
|
|
@@ -184,8 +184,9 @@ fn slimGitignore() []const u8 {
|
|
|
184
184
|
|
|
185
185
|
/// The TypeScript-core zero-config scaffold - the `native init` default:
|
|
186
186
|
/// core.ts (logic), app.native (view), app.zon (manifest). ZERO Zig in the
|
|
187
|
-
/// tree; the build graph detects src/core.ts,
|
|
188
|
-
/// generated wiring outside the app
|
|
187
|
+
/// tree; the build graph detects src/core.ts, compiles it through the
|
|
188
|
+
/// external core compiler, and stages the generated wiring outside the app
|
|
189
|
+
/// on every build.
|
|
189
190
|
///
|
|
190
191
|
/// The tree also carries the EDITOR surface: package.json + tsconfig.json,
|
|
191
192
|
/// so stock editor TypeScript resolves `@native-sdk/core` with full
|
|
@@ -260,7 +261,7 @@ fn writeTsEditorSurface(allocator: std.mem.Allocator, io: std.Io, app_dir: std.I
|
|
|
260
261
|
/// The app's package.json: name + the pinned `@native-sdk/core` dependency,
|
|
261
262
|
/// nothing else. It exists for editors and versioning only — the `native`
|
|
262
263
|
/// verbs never read it (tree detection keys on src/core.ts; the build
|
|
263
|
-
///
|
|
264
|
+
/// checks and compiles against the SDK checkout) — and the pin is exact so the
|
|
264
265
|
/// post-publish `npm install` resolves the same content the CLI
|
|
265
266
|
/// materialized.
|
|
266
267
|
fn tsPackageJson(allocator: std.mem.Allocator, names: TemplateNames, sdk_version: []const u8) ![]const u8 {
|
|
@@ -339,7 +340,7 @@ fn tsGitignore() []const u8 {
|
|
|
339
340
|
fn tsCoreStarter() []const u8 {
|
|
340
341
|
return
|
|
341
342
|
\\// The app core: Model, Msg, update, and the pure helpers they call -
|
|
342
|
-
\\// plain TypeScript in the app-core subset, compiled to native
|
|
343
|
+
\\// plain TypeScript in the app-core subset, compiled to native code at
|
|
343
344
|
\\// build time (no JS runtime ships in the binary). The view lives in
|
|
344
345
|
\\// app.native and binds this model by its own field names exactly as
|
|
345
346
|
\\// written here (`tickCount` binds as `{tickCount}`).
|
|
@@ -384,9 +385,12 @@ fn tsCoreStarter() []const u8 {
|
|
|
384
385
|
\\export function update(model: Model, msg: Msg): Model | [Model, Cmd<Msg>] {
|
|
385
386
|
\\ switch (msg.kind) {
|
|
386
387
|
\\ case "increment":
|
|
387
|
-
\\
|
|
388
|
+
\\ // Bounded on purpose: integer model fields carry a compile-time
|
|
389
|
+
\\ // range proof, and the literal comparison is what makes `+ 1`
|
|
390
|
+
\\ // provable.
|
|
391
|
+
\\ return { ...model, count: model.count < 1000000 ? model.count + 1 : model.count };
|
|
388
392
|
\\ case "decrement":
|
|
389
|
-
\\ return { ...model, count: model.count - 1 };
|
|
393
|
+
\\ return { ...model, count: model.count > -1000000 ? model.count - 1 : model.count };
|
|
390
394
|
\\ case "reset":
|
|
391
395
|
\\ return { ...model, count: 0, tickCount: 0 };
|
|
392
396
|
\\ case "toggle_ticking":
|
|
@@ -398,7 +402,7 @@ fn tsCoreStarter() []const u8 {
|
|
|
398
402
|
\\ case "stamped":
|
|
399
403
|
\\ return { ...model, stampedMs: msg.at };
|
|
400
404
|
\\ case "tick":
|
|
401
|
-
\\ return { ...model, tickCount: model.tickCount + 1 };
|
|
405
|
+
\\ return { ...model, tickCount: model.tickCount < 1000000 ? model.tickCount + 1 : model.tickCount };
|
|
402
406
|
\\ }
|
|
403
407
|
\\}
|
|
404
408
|
\\
|
|
@@ -499,8 +503,9 @@ fn tsSlimReadme(allocator: std.mem.Allocator, names: TemplateNames) ![]const u8
|
|
|
499
503
|
\\
|
|
500
504
|
\\## Requirements
|
|
501
505
|
\\
|
|
502
|
-
\\Node.js 22.15+ (on the 23 line: 23.5+) on PATH (the TypeScript
|
|
503
|
-
\\
|
|
506
|
+
\\Node.js 22.15+ (on the 23 line: 23.5+) on PATH (the TypeScript frontend
|
|
507
|
+
\\and the core compiler run at build time; your shipped binary carries
|
|
508
|
+
\\none of it).
|
|
504
509
|
\\
|
|
505
510
|
);
|
|
506
511
|
return out.toOwnedSlice(allocator);
|
|
@@ -1150,9 +1155,9 @@ fn nativeReadme(allocator: std.mem.Allocator, names: TemplateNames, framework_pa
|
|
|
1150
1155
|
/// real binary and asserts on the accessibility snapshot. The generated
|
|
1151
1156
|
/// file belongs to the user, like everything init writes. A TypeScript
|
|
1152
1157
|
/// core adds the node tier to both jobs: setup-node plus one `npm ci` in
|
|
1153
|
-
/// the fetched SDK's packages/core, because the @native-sdk/core
|
|
1154
|
-
///
|
|
1155
|
-
///
|
|
1158
|
+
/// the fetched SDK's packages/core, because the @native-sdk/core frontend
|
|
1159
|
+
/// and the external core compiler run at build time and arrive with that
|
|
1160
|
+
/// one install — the same install `native build`'s teaching names.
|
|
1156
1161
|
fn nativeCiYaml(allocator: std.mem.Allocator, names: TemplateNames, framework_path: []const u8, core: CoreTemplate) ![]const u8 {
|
|
1157
1162
|
const node_setup =
|
|
1158
1163
|
\\ - uses: actions/setup-node@v4
|
|
@@ -1160,11 +1165,11 @@ fn nativeCiYaml(allocator: std.mem.Allocator, names: TemplateNames, framework_pa
|
|
|
1160
1165
|
\\ node-version: 22
|
|
1161
1166
|
\\
|
|
1162
1167
|
;
|
|
1163
|
-
const
|
|
1164
|
-
\\ - name: Install the core
|
|
1168
|
+
const compiler_install =
|
|
1169
|
+
\\ - name: Install the core compiler dependency
|
|
1165
1170
|
\\ # src/core.ts compiles to native code at build time: the
|
|
1166
|
-
\\ # @native-sdk/core
|
|
1167
|
-
\\ #
|
|
1171
|
+
\\ # @native-sdk/core frontend and the external core compiler
|
|
1172
|
+
\\ # run from the SDK dependency and arrive with one install.
|
|
1168
1173
|
\\ run: npm ci --prefix "$NATIVE_SDK_PATH/packages/core"
|
|
1169
1174
|
\\
|
|
1170
1175
|
;
|
|
@@ -1199,7 +1204,7 @@ fn nativeCiYaml(allocator: std.mem.Allocator, names: TemplateNames, framework_pa
|
|
|
1199
1204
|
\\ runs-on: ubuntu-latest
|
|
1200
1205
|
\\ steps:
|
|
1201
1206
|
\\ - uses: actions/checkout@v4
|
|
1202
|
-
\\ - uses:
|
|
1207
|
+
\\ - uses: vercel-labs/setup-zig@v1
|
|
1203
1208
|
\\ with:
|
|
1204
1209
|
\\ version: 0.16.0
|
|
1205
1210
|
\\
|
|
@@ -1213,7 +1218,7 @@ fn nativeCiYaml(allocator: std.mem.Allocator, names: TemplateNames, framework_pa
|
|
|
1213
1218
|
\\ fi
|
|
1214
1219
|
\\
|
|
1215
1220
|
);
|
|
1216
|
-
if (core == .ts) try out.appendSlice(allocator,
|
|
1221
|
+
if (core == .ts) try out.appendSlice(allocator, compiler_install);
|
|
1217
1222
|
try out.appendSlice(allocator,
|
|
1218
1223
|
\\ - run: zig build test -Dplatform=null
|
|
1219
1224
|
\\
|
|
@@ -1222,7 +1227,7 @@ fn nativeCiYaml(allocator: std.mem.Allocator, names: TemplateNames, framework_pa
|
|
|
1222
1227
|
\\ runs-on: ubuntu-latest
|
|
1223
1228
|
\\ steps:
|
|
1224
1229
|
\\ - uses: actions/checkout@v4
|
|
1225
|
-
\\ - uses:
|
|
1230
|
+
\\ - uses: vercel-labs/setup-zig@v1
|
|
1226
1231
|
\\ with:
|
|
1227
1232
|
\\ version: 0.16.0
|
|
1228
1233
|
\\
|
|
@@ -1242,7 +1247,7 @@ fn nativeCiYaml(allocator: std.mem.Allocator, names: TemplateNames, framework_pa
|
|
|
1242
1247
|
\\ fi
|
|
1243
1248
|
\\
|
|
1244
1249
|
);
|
|
1245
|
-
if (core == .ts) try out.appendSlice(allocator,
|
|
1250
|
+
if (core == .ts) try out.appendSlice(allocator, compiler_install);
|
|
1246
1251
|
try out.appendSlice(allocator,
|
|
1247
1252
|
\\ - name: Build the Native SDK CLI
|
|
1248
1253
|
\\ run: cd "$NATIVE_SDK_PATH" && zig build
|
|
@@ -1298,7 +1303,7 @@ fn frontendCiYaml(allocator: std.mem.Allocator, names: TemplateNames) ![]const u
|
|
|
1298
1303
|
\\ runs-on: ubuntu-latest
|
|
1299
1304
|
\\ steps:
|
|
1300
1305
|
\\ - uses: actions/checkout@v4
|
|
1301
|
-
\\ - uses:
|
|
1306
|
+
\\ - uses: vercel-labs/setup-zig@v1
|
|
1302
1307
|
\\ with:
|
|
1303
1308
|
\\ version: 0.16.0
|
|
1304
1309
|
\\ - name: Fetch native-sdk
|
|
@@ -1829,10 +1834,13 @@ fn buildZig(allocator: std.mem.Allocator, names: TemplateNames, framework_path:
|
|
|
1829
1834
|
\\ app_mod.addLibraryPath(b.path(b.fmt("{s}/Release", .{cef_dir})));
|
|
1830
1835
|
\\ },
|
|
1831
1836
|
\\ }
|
|
1837
|
+
\\ app_mod.addCSourceFile(.{ .file = nativeSdkPath(b, native_sdk_path, "src/platform/windows/gpu_surface_renderer.cpp"), .flags = &.{ "-std=c++17" } });
|
|
1832
1838
|
\\ app_mod.linkSystemLibrary("c", .{});
|
|
1833
1839
|
\\ app_mod.linkSystemLibrary("c++", .{});
|
|
1834
1840
|
\\ app_mod.linkSystemLibrary("user32", .{});
|
|
1835
1841
|
\\ app_mod.linkSystemLibrary("gdi32", .{});
|
|
1842
|
+
\\ app_mod.linkSystemLibrary("d2d1", .{});
|
|
1843
|
+
\\ app_mod.linkSystemLibrary("dwrite", .{});
|
|
1836
1844
|
\\ app_mod.linkSystemLibrary("imm32", .{});
|
|
1837
1845
|
\\ app_mod.linkSystemLibrary("comctl32", .{});
|
|
1838
1846
|
\\ app_mod.linkSystemLibrary("ole32", .{});
|
|
@@ -3924,7 +3932,7 @@ test "writeDefaultApp emits Vite project files" {
|
|
|
3924
3932
|
defer std.testing.allocator.free(ci_yaml_text);
|
|
3925
3933
|
try expectBasicYaml(ci_yaml_text);
|
|
3926
3934
|
try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, "zig build test -Dplatform=null -Dnative-sdk-path=\"$NATIVE_SDK_PATH\"") != null);
|
|
3927
|
-
try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, "
|
|
3935
|
+
try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, "vercel-labs/setup-zig@v1") != null);
|
|
3928
3936
|
// Web-frontend workflows stop at logic tests: the automation smoke
|
|
3929
3937
|
// recipe is native-app specific.
|
|
3930
3938
|
try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, "smoke:") == null);
|
|
@@ -4163,15 +4171,15 @@ test "writeDefaultApp --full ts-core emits a CI workflow with the node tier" {
|
|
|
4163
4171
|
// automation smoke, no WebKitGTK for a native-rendered app.
|
|
4164
4172
|
try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, " test:") != null);
|
|
4165
4173
|
try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, " smoke:") != null);
|
|
4166
|
-
try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, "
|
|
4174
|
+
try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, "vercel-labs/setup-zig@v1") != null);
|
|
4167
4175
|
try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, "zig build test -Dplatform=null") != null);
|
|
4168
4176
|
try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, "libgtk-4-dev xvfb") != null);
|
|
4169
4177
|
try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, "libwebkitgtk-6.0-dev") == null);
|
|
4170
4178
|
try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, "xvfb-run -a ./zig-out/bin/my-app &") != null);
|
|
4171
4179
|
try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, "git clone --depth 1 https://github.com/vercel-labs/native.git \"$NATIVE_SDK_PATH\"") != null);
|
|
4172
4180
|
// Plus the node tier the TS build needs: node on PATH and the
|
|
4173
|
-
//
|
|
4174
|
-
// in BOTH jobs (each builds the app, so each
|
|
4181
|
+
// frontend + compiler install inside the fetched SDK's packages/core,
|
|
4182
|
+
// in BOTH jobs (each builds the app, so each compiles the core).
|
|
4175
4183
|
try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, "actions/setup-node@v4") != null);
|
|
4176
4184
|
const npm_ci = "npm ci --prefix \"$NATIVE_SDK_PATH/packages/core\"";
|
|
4177
4185
|
const first = std.mem.indexOf(u8, ci_yaml_text, npm_ci).?;
|
|
@@ -4190,7 +4198,7 @@ test "writeDefaultApp emits a CI workflow for native apps" {
|
|
|
4190
4198
|
try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, "jobs:") != null);
|
|
4191
4199
|
try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, " test:") != null);
|
|
4192
4200
|
try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, " smoke:") != null);
|
|
4193
|
-
try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, "
|
|
4201
|
+
try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, "vercel-labs/setup-zig@v1") != null);
|
|
4194
4202
|
try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, "version: 0.16.0") != null);
|
|
4195
4203
|
try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, "zig build test -Dplatform=null") != null);
|
|
4196
4204
|
// The smoke job builds with automation, launches under Xvfb, and drives
|
package/src/tooling/ts_core.zig
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//! TypeScript-core plumbing for the `native` CLI: tree detection (which
|
|
2
|
-
//! core does this app carry?), the
|
|
2
|
+
//! core does this app carry?), the frontend check pass `native check`
|
|
3
3
|
//! runs over src/core.ts, and the node dev-harness `native dev --core`
|
|
4
4
|
//! launches. The build graph re-derives the same detection in
|
|
5
5
|
//! build/app.zig; the CLI checks first so a both-cores tree fails with one
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
//! Multi-file cores: src/core.ts stays the detection root AND the entry
|
|
9
9
|
//! module, but a core may split into modules under src/ (relative imports
|
|
10
10
|
//! with real .ts filenames) plus SDK library modules
|
|
11
|
-
//! ("@native-sdk/core/text"). The
|
|
11
|
+
//! ("@native-sdk/core/text"). The frontend walks that import graph
|
|
12
12
|
//! itself, so `native check` reports diagnostics with each module's own
|
|
13
13
|
//! path, and `native dev --core` runs the same graph under node (relative
|
|
14
14
|
//! imports are real files; the resolver hook maps only the SDK names).
|
|
@@ -68,7 +68,7 @@ pub fn failBothCores() Error {
|
|
|
68
68
|
|
|
69
69
|
fn nodeMissing() Error {
|
|
70
70
|
std.debug.print(
|
|
71
|
-
\\TypeScript app cores need node on PATH (the @native-sdk/core
|
|
71
|
+
\\TypeScript app cores need node on PATH (the @native-sdk/core frontend and the
|
|
72
72
|
\\core dev-harness run under it; the binary you ship carries no JS runtime).
|
|
73
73
|
\\Install Node.js 22.15+ (on the 23 line: 23.5+) - https://nodejs.org or
|
|
74
74
|
\\`brew install node` - and re-run.
|
|
@@ -87,7 +87,7 @@ fn transpilerPath(allocator: std.mem.Allocator, io: std.Io, framework_root: []co
|
|
|
87
87
|
return path;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
/// The layout-neutral runner for the
|
|
90
|
+
/// The layout-neutral runner for the frontend tier's .ts modules
|
|
91
91
|
/// (build/ts_run.mjs): a pass-through on a repo checkout, and the type
|
|
92
92
|
/// stripper for the npm-installed layout, where the same modules sit
|
|
93
93
|
/// inside node_modules and node refuses its builtin stripping. Every
|
|
@@ -103,7 +103,7 @@ fn tsRunnerPath(allocator: std.mem.Allocator, io: std.Io, framework_root: []cons
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
/// The install command the repo-checkout teaching names. `--include=dev`
|
|
106
|
-
/// is correctness, not style: @typescript/
|
|
106
|
+
/// is correctness, not style: @typescript/old is packages/core's
|
|
107
107
|
/// devDependency, and a plain `npm ci` under ambient production npm config
|
|
108
108
|
/// (NODE_ENV=production, `omit=dev` in an npmrc) skips devDependencies
|
|
109
109
|
/// while exiting 0 — the named command would "succeed" and install
|
|
@@ -131,19 +131,13 @@ pub const npm_ci_teaching_command = "npm ci --include=dev";
|
|
|
131
131
|
/// (nested under the CLI on global prefixes, hoisted to the project
|
|
132
132
|
/// root on local ones, pnpm's sibling node_modules)
|
|
133
133
|
///
|
|
134
|
-
///
|
|
135
|
-
///
|
|
136
|
-
///
|
|
137
|
-
///
|
|
138
|
-
///
|
|
139
|
-
///
|
|
140
|
-
///
|
|
141
|
-
/// hoisted wrapper) while our exact pin lands nested under the CLI — and
|
|
142
|
-
/// that nested copy is precisely what runtime loads from packages/core;
|
|
143
|
-
/// a consumer's own shadowing wrapper install must not sway the verdict
|
|
144
|
-
/// either. The wrapper stays a DECLARED dependency in both manifests
|
|
145
|
-
/// (continuity semantics, and it keeps npm shipping the package) — it is
|
|
146
|
-
/// just not what validation vouches for.
|
|
134
|
+
/// A stray `@typescript/typescript6` compat wrapper in a consumer tree
|
|
135
|
+
/// (a former dependency of this package, or the consumer's own) is
|
|
136
|
+
/// deliberately NOT probed: nothing imports it at run time, and holding
|
|
137
|
+
/// the alias's version as seen FROM a wrapper's origin against the pin
|
|
138
|
+
/// can only FALSE-REJECT healthy trees — a consumer's hoisted conflicting
|
|
139
|
+
/// `@typescript/old` wins the walk from there while the copy runtime
|
|
140
|
+
/// actually loads sits correctly pinned under packages/core.
|
|
147
141
|
///
|
|
148
142
|
/// Resolvable means the alias's manifest AND its entrypoint are present
|
|
149
143
|
/// and its installed version equals the pin — see
|
|
@@ -313,7 +307,7 @@ fn pinnedCompilerVersion(allocator: std.mem.Allocator, io: std.Io, framework_roo
|
|
|
313
307
|
/// `npm ci` there would teach mutating an npm-owned tree.
|
|
314
308
|
fn transpilerDepsMissing(framework_root: []const u8) Error {
|
|
315
309
|
std.debug.print(
|
|
316
|
-
\\the @native-sdk/core
|
|
310
|
+
\\the @native-sdk/core frontend's dependencies are not installed
|
|
317
311
|
\\(its TypeScript compiler, @typescript/old, resolves nowhere). Fix with:
|
|
318
312
|
\\ cd {s}/packages/core && {s}
|
|
319
313
|
\\
|
|
@@ -351,7 +345,7 @@ fn toolchainInstallBroken(framework_root: []const u8) Error {
|
|
|
351
345
|
/// conflict instead.
|
|
352
346
|
fn compilerVersionMismatch(resolved: []const u8, pinned: []const u8) Error {
|
|
353
347
|
std.debug.print(
|
|
354
|
-
\\the
|
|
348
|
+
\\the frontend's TypeScript compiler resolves at the wrong version:
|
|
355
349
|
\\@typescript/old resolves to typescript {s}, but the SDK pins npm:typescript@{s}.
|
|
356
350
|
\\Another package in this tree pins a conflicting @typescript/old - align it with
|
|
357
351
|
\\the SDK's pin (or remove it) and reinstall, so the SDK's exact pin is the copy
|
|
@@ -409,23 +403,21 @@ pub fn ensureResolvedTranspiler(allocator: std.mem.Allocator, io: std.Io, framew
|
|
|
409
403
|
return transpilerDepsMissing(resolved);
|
|
410
404
|
}
|
|
411
405
|
|
|
412
|
-
/// `native check` over a TypeScript core: run the
|
|
413
|
-
///
|
|
414
|
-
/// graph under src/ — and surface its NS diagnostics verbatim —
|
|
415
|
-
/// are the teaching layer, nothing wraps them (each diagnostic
|
|
416
|
-
/// the owning module's path).
|
|
417
|
-
///
|
|
418
|
-
/// typechecked, subset-clean, emitted.
|
|
406
|
+
/// `native check` over a TypeScript core: run the frontend in
|
|
407
|
+
/// check-only mode on src/core.ts — and, through it, the core's whole
|
|
408
|
+
/// import graph under src/ — and surface its NS diagnostics verbatim —
|
|
409
|
+
/// they are the teaching layer, nothing wraps them (each diagnostic
|
|
410
|
+
/// carries the owning module's path). Exit 0 = typechecked,
|
|
411
|
+
/// subset-clean.
|
|
419
412
|
pub fn checkCore(allocator: std.mem.Allocator, io: std.Io, base_env: *std.process.Environ.Map, framework_root: []const u8) !void {
|
|
420
413
|
const cli_path = try transpilerPath(allocator, io, framework_root, "src/cli.ts");
|
|
421
414
|
defer allocator.free(cli_path);
|
|
422
415
|
const runner_path = try tsRunnerPath(allocator, io, framework_root);
|
|
423
416
|
defer allocator.free(runner_path);
|
|
424
417
|
try ensureResolvedTranspiler(allocator, io, framework_root);
|
|
425
|
-
try std.Io.Dir.cwd().createDirPath(io, ".native/check");
|
|
426
418
|
|
|
427
419
|
var child = std.process.spawn(io, .{
|
|
428
|
-
.argv = &.{ "node", runner_path, cli_path, "src/core.ts"
|
|
420
|
+
.argv = &.{ "node", runner_path, cli_path, "src/core.ts" },
|
|
429
421
|
.stdin = .ignore,
|
|
430
422
|
.stdout = .inherit,
|
|
431
423
|
.stderr = .inherit,
|
|
@@ -436,12 +428,41 @@ pub fn checkCore(allocator: std.mem.Allocator, io: std.Io, base_env: *std.proces
|
|
|
436
428
|
.exited => |code| if (code == 0) return,
|
|
437
429
|
else => {},
|
|
438
430
|
}
|
|
439
|
-
// The
|
|
431
|
+
// The frontend's own diagnostics are already on screen; name the
|
|
440
432
|
// failing pass without burying them.
|
|
441
433
|
std.debug.print("native check: src/core.ts failed the @native-sdk/core checker (diagnostics above)\n", .{});
|
|
442
434
|
return error.CoreCheckFailed;
|
|
443
435
|
}
|
|
444
436
|
|
|
437
|
+
/// The compiler-truth pass `checkCore` chains after the frontend: the
|
|
438
|
+
/// pinned external core compiler's analyzer over the same entry, with
|
|
439
|
+
/// the shipped SDK declarations mapped — the check verdict and the
|
|
440
|
+
/// build verdict come from ONE compiler. Analyzer type errors fail the
|
|
441
|
+
/// check with the compiler's own diagnostics; a toolchain that cannot
|
|
442
|
+
/// reach a verdict defers to the build rather than wedging check.
|
|
443
|
+
pub fn compilerTypecheckCore(allocator: std.mem.Allocator, io: std.Io, base_env: *std.process.Environ.Map, framework_root: []const u8) !void {
|
|
444
|
+
const script_path = try transpilerPath(allocator, io, framework_root, "scripts/compiler_typecheck.mjs");
|
|
445
|
+
defer allocator.free(script_path);
|
|
446
|
+
var child = std.process.spawn(io, .{
|
|
447
|
+
.argv = &.{ "node", script_path, "src/core.ts" },
|
|
448
|
+
.stdin = .ignore,
|
|
449
|
+
.stdout = .inherit,
|
|
450
|
+
.stderr = .inherit,
|
|
451
|
+
.environ_map = base_env,
|
|
452
|
+
}) catch return nodeMissing();
|
|
453
|
+
const term = try child.wait(io);
|
|
454
|
+
switch (term) {
|
|
455
|
+
.exited => |code| switch (code) {
|
|
456
|
+
0 => return,
|
|
457
|
+
2 => return error.MissingTranspiler,
|
|
458
|
+
else => {},
|
|
459
|
+
},
|
|
460
|
+
else => {},
|
|
461
|
+
}
|
|
462
|
+
std.debug.print("native check: src/core.ts does not typecheck under the external core compiler (its diagnostics above are the build's verdict too)\n", .{});
|
|
463
|
+
return error.CoreCheckFailed;
|
|
464
|
+
}
|
|
465
|
+
|
|
445
466
|
pub const DevHostOptions = struct {
|
|
446
467
|
base_env: *std.process.Environ.Map,
|
|
447
468
|
/// NDJSON message script; null = interactive stdin.
|
|
@@ -463,7 +484,7 @@ pub fn runDevHost(allocator: std.mem.Allocator, io: std.Io, framework_root: []co
|
|
|
463
484
|
defer allocator.free(devhost_path);
|
|
464
485
|
const runner_path = try tsRunnerPath(allocator, io, framework_root);
|
|
465
486
|
defer allocator.free(runner_path);
|
|
466
|
-
// The harness runs the
|
|
487
|
+
// The harness runs the frontend tier under node, so it needs the
|
|
467
488
|
// TypeScript toolchain to resolve exactly like check/build do.
|
|
468
489
|
try ensureResolvedTranspiler(allocator, io, framework_root);
|
|
469
490
|
|
|
@@ -515,8 +536,8 @@ pub fn runDevHost(allocator: std.mem.Allocator, io: std.Io, framework_root: []co
|
|
|
515
536
|
// the `files: ["sdk"]` allowlist: sdk/core.ts, sdk/text.ts, sdk/events.ts,
|
|
516
537
|
// and the ambient bytes-text method surface core.ts references).
|
|
517
538
|
// The copy is
|
|
518
|
-
// EDITOR-AND-VERSIONING SURFACE ONLY: builds
|
|
519
|
-
// checkout's own sources and never read node_modules — delete it and
|
|
539
|
+
// EDITOR-AND-VERSIONING SURFACE ONLY: builds check and compile against the
|
|
540
|
+
// SDK checkout's own sources and never read node_modules — delete it and
|
|
520
541
|
// `native build|dev|check|test` still work; the next check/dev/build puts
|
|
521
542
|
// it back. Once the real package is published, a user-run `npm install`
|
|
522
543
|
// overwrites the copy with identical content; the refresh below compares
|
|
@@ -776,7 +797,7 @@ test "the checkout teaching's npm command survives production npm config" {
|
|
|
776
797
|
try std.testing.expect(std.mem.indexOf(u8, npm_ci_teaching_command, "--include=dev") != null);
|
|
777
798
|
}
|
|
778
799
|
|
|
779
|
-
/// The minimal manifest of
|
|
800
|
+
/// The minimal manifest of a stray @typescript/typescript6 wrapper a fake
|
|
780
801
|
/// COMPLETED install also lands (npm keeps installing it as a declared
|
|
781
802
|
/// dependency). The gate never probes it — validation tracks only the
|
|
782
803
|
/// aliased real compiler runtime loads — so tests land it exactly where
|
package/src/tooling/verbs.zig
CHANGED
|
@@ -64,7 +64,7 @@ pub fn run(allocator: std.mem.Allocator, io: std.Io, verb: Verb, options: Option
|
|
|
64
64
|
if (buildgraph.resolveFrameworkRoot(allocator, io, options.base_env) catch null) |framework_root| {
|
|
65
65
|
defer allocator.free(framework_root);
|
|
66
66
|
ts_core.selfHealEditorPackage(allocator, io, framework_root);
|
|
67
|
-
// The build graph runs the
|
|
67
|
+
// The build graph runs the frontend inside `zig build`; gate
|
|
68
68
|
// its toolchain resolution before any zig spawns — but ONLY
|
|
69
69
|
// for graphs the CLI itself generates (see the preflight's own
|
|
70
70
|
// doc for why ejected apps must flow past it).
|