@native-sdk/cli 0.4.1 → 0.4.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/assets/native-sdk.manifest +17 -1
- package/build/app.zig +40 -1
- package/build.zig +49 -3
- package/package.json +10 -9
- package/src/platform/macos/appkit_host.m +21 -6
- package/src/platform/windows/webview2_host.cpp +377 -72
- package/src/primitives/canvas/chart.zig +8 -7
- package/src/primitives/canvas/chart_tests.zig +2 -2
- package/src/primitives/canvas/commands.zig +27 -0
- package/src/primitives/canvas/gpu.zig +8 -0
- package/src/primitives/canvas/markdown_tests.zig +1 -1
- package/src/primitives/canvas/reference.zig +82 -3
- package/src/primitives/canvas/reference_tests.zig +155 -1
- package/src/primitives/canvas/serialization.zig +16 -3
- package/src/primitives/canvas/themes/geist.zig +6 -0
- package/src/primitives/canvas/tokens.zig +7 -0
- package/src/primitives/canvas/widget_builtin_tests.zig +191 -0
- package/src/primitives/canvas/widget_render.zig +29 -41
- package/src/primitives/canvas/widget_render_controls.zig +55 -42
- package/src/primitives/canvas/widget_render_style.zig +53 -0
- package/src/primitives/canvas/widget_render_surfaces.zig +19 -18
- package/src/primitives/canvas/widget_runtime_tests.zig +20 -21
- package/src/runtime/canvas_frame_packet_tests.zig +9 -1
- package/src/runtime/canvas_frame_patch_tests.zig +39 -1
- package/src/runtime/canvas_widget_control_tests.zig +4 -4
- package/src/runtime/ui_app.zig +78 -10
- package/src/runtime/ui_app_tests.zig +109 -0
- package/src/runtime/ui_app_window_tests.zig +93 -0
- package/src/tooling/package.zig +45 -0
- package/src/tooling/templates.zig +42 -1
- package/third_party/webview2/LICENSE.txt +27 -0
- package/third_party/webview2/README.md +19 -0
- package/third_party/webview2/arm64/WebView2Loader.dll +0 -0
- package/third_party/webview2/include/EventToken.h +12 -0
- package/third_party/webview2/include/WebView2.h +60636 -0
- package/third_party/webview2/x64/WebView2Loader.dll +0 -0
|
@@ -2,11 +2,27 @@
|
|
|
2
2
|
<!-- Application manifest embedded into Windows app executables. Declaring
|
|
3
3
|
the common-controls v6 side-by-side dependency activates the modern
|
|
4
4
|
control styling and the v6-only exports (TaskDialogIndirect); without
|
|
5
|
-
it the loader binds the system-default v5 assembly.
|
|
5
|
+
it the loader binds the system-default v5 assembly. Declaring
|
|
6
|
+
per-monitor-v2 DPI awareness makes GetDpiForWindow report the real
|
|
7
|
+
monitor DPI (instead of a virtualized 96) so the canvas rasterizes
|
|
8
|
+
at device scale and Windows never bitmap-stretches the window.
|
|
9
|
+
dpiAwareness carries an ordered fallback list: readers take the first
|
|
10
|
+
value they recognize, so PerMonitorV2 degrades to PerMonitor where v2
|
|
11
|
+
is unknown. The dpiAwareness element itself is ignored before Windows
|
|
12
|
+
10 1607; there the legacy dpiAware element beside it picks up, and its
|
|
13
|
+
true/pm value requests per-monitor awareness where supported with
|
|
14
|
+
system-DPI awareness as the floor. Readers that understand dpiAwareness
|
|
15
|
+
prefer it over dpiAware, so the two elements coexist safely. -->
|
|
6
16
|
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
|
7
17
|
<dependency>
|
|
8
18
|
<dependentAssembly>
|
|
9
19
|
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*"/>
|
|
10
20
|
</dependentAssembly>
|
|
11
21
|
</dependency>
|
|
22
|
+
<application xmlns="urn:schemas-microsoft-com:asm.v3">
|
|
23
|
+
<windowsSettings>
|
|
24
|
+
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/pm</dpiAware>
|
|
25
|
+
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2, PerMonitor</dpiAwareness>
|
|
26
|
+
</windowsSettings>
|
|
27
|
+
</application>
|
|
12
28
|
</assembly>
|
package/build/app.zig
CHANGED
|
@@ -251,6 +251,7 @@ pub fn addAppArtifacts(b: *std.Build, dep: *std.Build.Dependency, app_options: A
|
|
|
251
251
|
|
|
252
252
|
const run = b.addRunArtifact(exe);
|
|
253
253
|
addCefRuntimeRunFiles(b, target, run, exe, web_engine, cef_dir);
|
|
254
|
+
addWebView2RuntimeRunFiles(dep, target, run, web_engine);
|
|
254
255
|
const run_step = b.step("run", "Run the app");
|
|
255
256
|
run_step.dependOn(&run.step);
|
|
256
257
|
|
|
@@ -315,6 +316,10 @@ pub fn addAppArtifacts(b: *std.Build, dep: *std.Build.Dependency, app_options: A
|
|
|
315
316
|
};
|
|
316
317
|
if (package_target) |package_target_name| {
|
|
317
318
|
const package_run = b.addRunArtifact(dep.artifact("native"));
|
|
319
|
+
// The CLI resolves SDK-owned package inputs (the vendored
|
|
320
|
+
// WebView2 loader) from the framework root; the cached artifact's
|
|
321
|
+
// own location cannot derive it, so hand it over explicitly.
|
|
322
|
+
package_run.setEnvironmentVariable("NATIVE_SDK_PATH", dep.builder.pathFromRoot("."));
|
|
318
323
|
package_run.addArgs(&.{ "package", "--target", package_target_name, "--manifest", "app.zon", "--output" });
|
|
319
324
|
package_run.addArg(if (host_os == .macos)
|
|
320
325
|
b.fmt("zig-out/package/{s}.app", .{app_options.name})
|
|
@@ -544,9 +549,24 @@ fn linkPlatform(b: *std.Build, dep: *std.Build.Dependency, target: std.Build.Res
|
|
|
544
549
|
// Common-controls v6 side-by-side dependency: without this
|
|
545
550
|
// manifest the loader binds the system-default v5 assembly, which
|
|
546
551
|
// renders classic-styled controls and lacks the v6-only exports.
|
|
552
|
+
// The manifest also declares per-monitor-v2 DPI awareness so the
|
|
553
|
+
// canvas rasterizes at real device scale instead of Windows
|
|
554
|
+
// bitmap-stretching a 96-DPI surface on scaled displays.
|
|
547
555
|
exe.win32_manifest = dep.path("assets/native-sdk.manifest");
|
|
548
556
|
switch (web_engine) {
|
|
549
|
-
.system =>
|
|
557
|
+
.system => {
|
|
558
|
+
// The vendored WebView2 SDK header (third_party/webview2)
|
|
559
|
+
// turns on the host's embedded-WebView layer; the host
|
|
560
|
+
// fails the compile by design if it cannot be found.
|
|
561
|
+
app_mod.addIncludePath(dep.path("third_party/webview2/include"));
|
|
562
|
+
app_mod.addCSourceFile(.{ .file = dep.path("src/platform/windows/webview2_host.cpp"), .flags = &.{"-std=c++17"} });
|
|
563
|
+
// WebView2Loader.dll rides next to the installed app
|
|
564
|
+
// executable: the host loads it at runtime to discover
|
|
565
|
+
// the machine's WebView2 runtime. Canvas apps never
|
|
566
|
+
// touch it.
|
|
567
|
+
const loader = b.addInstallBinFile(dep.path(webView2LoaderSubPath(target)), "WebView2Loader.dll");
|
|
568
|
+
b.getInstallStep().dependOn(&loader.step);
|
|
569
|
+
},
|
|
550
570
|
.chromium => {
|
|
551
571
|
const cef_check = addCefCheck(b, target, cef_dir);
|
|
552
572
|
if (cef_auto_install) {
|
|
@@ -579,6 +599,25 @@ fn linkPlatform(b: *std.Build, dep: *std.Build.Dependency, target: std.Build.Res
|
|
|
579
599
|
}
|
|
580
600
|
}
|
|
581
601
|
|
|
602
|
+
/// The vendored WebView2Loader.dll for the target architecture, relative
|
|
603
|
+
/// to the framework root.
|
|
604
|
+
fn webView2LoaderSubPath(target: std.Build.ResolvedTarget) []const u8 {
|
|
605
|
+
return if (target.result.cpu.arch == .aarch64)
|
|
606
|
+
"third_party/webview2/arm64/WebView2Loader.dll"
|
|
607
|
+
else
|
|
608
|
+
"third_party/webview2/x64/WebView2Loader.dll";
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
/// `zig build run` executes the cached artifact, which has no installed
|
|
612
|
+
/// WebView2Loader.dll beside it; the vendored loader's directory goes on
|
|
613
|
+
/// the run step's PATH so the host's LoadLibrary resolves it in dev runs.
|
|
614
|
+
fn addWebView2RuntimeRunFiles(dep: *std.Build.Dependency, target: std.Build.ResolvedTarget, run: *std.Build.Step.Run, web_engine: WebEngineOption) void {
|
|
615
|
+
if (web_engine != .system) return;
|
|
616
|
+
if (target.result.os.tag != .windows) return;
|
|
617
|
+
const loader_dir = std.fs.path.dirname(webView2LoaderSubPath(target)).?;
|
|
618
|
+
run.addPathDir(dep.builder.pathFromRoot(loader_dir));
|
|
619
|
+
}
|
|
620
|
+
|
|
582
621
|
fn addCefRuntimeRunFiles(b: *std.Build, target: std.Build.ResolvedTarget, run: *std.Build.Step.Run, exe: *std.Build.Step.Compile, web_engine: WebEngineOption, cef_dir: []const u8) void {
|
|
583
622
|
if (web_engine != .chromium) return;
|
|
584
623
|
if (target.result.os.tag != .macos) return;
|
package/build.zig
CHANGED
|
@@ -482,6 +482,26 @@ pub fn build(b: *std.Build) void {
|
|
|
482
482
|
.{ .path = "src/platform/linux/gtk_host.c", .pattern = "change != NATIVE_SDK_GST_STATE_CHANGE_ASYNC" },
|
|
483
483
|
.{ .path = "src/platform/linux/gtk_host.c", .pattern = "#define NATIVE_SDK_GST_STATE_CHANGE_ASYNC 2" },
|
|
484
484
|
});
|
|
485
|
+
// The embedded-WebView layer must stay real: the vendored WebView2
|
|
486
|
+
// SDK header turns the guard on, every first-party build graph puts
|
|
487
|
+
// it on the include path, and a build that cannot see it fails at
|
|
488
|
+
// compile time instead of quietly shipping the stubbed host (whose
|
|
489
|
+
// WebView loads report WebViewNotFound at runtime).
|
|
490
|
+
addFileContainsCheckStep(b, file_contains_checker, test_step, "test-windows-webview2-vendor", "Verify the vendored WebView2 SDK stays wired into every Windows build graph", &.{
|
|
491
|
+
.{ .path = "third_party/webview2/include/WebView2.h", .pattern = "CreateCoreWebView2EnvironmentWithOptions" },
|
|
492
|
+
.{ .path = "third_party/webview2/include/EventToken.h", .pattern = "EventRegistrationToken" },
|
|
493
|
+
.{ .path = "third_party/webview2/LICENSE.txt", .pattern = "Redistribution and use in source and binary forms" },
|
|
494
|
+
.{ .path = "src/platform/windows/webview2_host.cpp", .pattern = "#error \"WebView2.h not found" },
|
|
495
|
+
.{ .path = "src/platform/windows/webview2_host.cpp", .pattern = "LoadLibraryW(L\"WebView2Loader.dll\")" },
|
|
496
|
+
.{ .path = "build/app.zig", .pattern = "app_mod.addIncludePath(dep.path(\"third_party/webview2/include\"));" },
|
|
497
|
+
.{ .path = "build/app.zig", .pattern = "third_party/webview2/x64/WebView2Loader.dll" },
|
|
498
|
+
.{ .path = "src/tooling/templates.zig", .pattern = "third_party/webview2/include" },
|
|
499
|
+
.{ .path = "src/tooling/templates.zig", .pattern = "third_party/webview2/x64/WebView2Loader.dll" },
|
|
500
|
+
});
|
|
501
|
+
addLayoutCheckStep(b, test_step, "test-windows-webview2-loader-layout", "Verify the vendored WebView2 loader binaries are present", &.{
|
|
502
|
+
"third_party/webview2/x64/WebView2Loader.dll",
|
|
503
|
+
"third_party/webview2/arm64/WebView2Loader.dll",
|
|
504
|
+
});
|
|
485
505
|
addFileContainsCheckStep(b, file_contains_checker, test_step, "test-windows-packaged-assets-webview2", "Verify Windows packaged assets are served through WebView2 request interception", &.{
|
|
486
506
|
.{ .path = "src/platform/windows/webview2_host.cpp", .pattern = "constexpr const char *kAssetVirtualOrigin = \"https://native-sdk-app.localhost\";" },
|
|
487
507
|
.{ .path = "src/platform/windows/webview2_host.cpp", .pattern = "return virtualAssetEntryUrl(webview.asset_entry);" },
|
|
@@ -605,9 +625,9 @@ pub fn build(b: *std.Build) void {
|
|
|
605
625
|
// this step until the encoder comment, the host decoder comment, and
|
|
606
626
|
// the patterns below move with it.
|
|
607
627
|
addFileContainsCheckStep(b, file_contains_checker, test_step, "test-wire-format-version-prose", "Verify wire-format version prose matches the packet version constant", &.{
|
|
608
|
-
.{ .path = "src/primitives/canvas/serialization.zig", .pattern = "pub const binary_packet_version: u8 =
|
|
609
|
-
.{ .path = "src/primitives/canvas/serialization.zig", .pattern = "Compact binary gpu-surface packet encoding (wire format
|
|
610
|
-
.{ .path = "src/platform/macos/appkit_host.m", .pattern = "Compact binary gpu-surface packet decoding (wire format
|
|
628
|
+
.{ .path = "src/primitives/canvas/serialization.zig", .pattern = "pub const binary_packet_version: u8 = 4;" },
|
|
629
|
+
.{ .path = "src/primitives/canvas/serialization.zig", .pattern = "Compact binary gpu-surface packet encoding (wire format v4)." },
|
|
630
|
+
.{ .path = "src/platform/macos/appkit_host.m", .pattern = "Compact binary gpu-surface packet decoding (wire format v4)." },
|
|
611
631
|
});
|
|
612
632
|
addFileContainsCheckStep(b, file_contains_checker, test_step, "test-appkit-gpu-packet-blur-effects", "Verify AppKit GPU packet presenter applies blur effects", &.{
|
|
613
633
|
.{ .path = "src/platform/macos/appkit_host.m", .pattern = "NativeSdkPacketApplyBlur" },
|
|
@@ -688,6 +708,32 @@ pub fn build(b: *std.Build) void {
|
|
|
688
708
|
.{ .path = "src/platform/windows/webview2_host.cpp", .pattern = "gpuImeCommitAction(pending, result)" },
|
|
689
709
|
.{ .path = "src/platform/windows/webview2_host.cpp", .pattern = "ISC_SHOWUICOMPOSITIONWINDOW" },
|
|
690
710
|
});
|
|
711
|
+
addFileContainsCheckStep(b, file_contains_checker, test_step, "test-windows-view-frame-rounding", "Verify Windows native view frames accumulate logical coordinates before rounding and declare the full DPI awareness fallback chain", &.{
|
|
712
|
+
// The frame policy: every physical edge is the once-rounded
|
|
713
|
+
// product of an ACCUMULATED logical coordinate and the window
|
|
714
|
+
// scale, with width/height as edge differences. Per-level
|
|
715
|
+
// rounding drifts from the round of the sum (the static_asserts
|
|
716
|
+
// beside nativeViewCoord carry the numeric proof, compiled on
|
|
717
|
+
// every Windows host build).
|
|
718
|
+
.{ .path = "src/platform/windows/webview2_host.cpp", .pattern = "static void nativeViewLogicalOrigin(Host *host, const NativeView &view, double *logical_x, double *logical_y)" },
|
|
719
|
+
.{ .path = "src/platform/windows/webview2_host.cpp", .pattern = "frame.right = nativeViewCoord((logical_x + view.width) * scale);" },
|
|
720
|
+
.{ .path = "src/platform/windows/webview2_host.cpp", .pattern = "static_assert(nativeViewCoord(10.4 * 1.5) + nativeViewCoord(10.4 * 1.5) == 32 && nativeViewCoord((10.4 + 10.4) * 1.5) == 31," },
|
|
721
|
+
.{ .path = "src/platform/windows/webview2_host.cpp", .pattern = "MoveWindow(view.hwnd, frame.left, frame.top, frame.right - frame.left, frame.bottom - frame.top, TRUE);" },
|
|
722
|
+
// The embedded manifest's DPI declarations: the ordered
|
|
723
|
+
// dpiAwareness list degrades PerMonitorV2 to PerMonitor, and the
|
|
724
|
+
// legacy dpiAware element covers systems that ignore dpiAwareness
|
|
725
|
+
// entirely.
|
|
726
|
+
.{ .path = "assets/native-sdk.manifest", .pattern = "<dpiAware xmlns=\"http://schemas.microsoft.com/SMI/2005/WindowsSettings\">true/pm</dpiAware>" },
|
|
727
|
+
.{ .path = "assets/native-sdk.manifest", .pattern = "<dpiAwareness xmlns=\"http://schemas.microsoft.com/SMI/2016/WindowsSettings\">PerMonitorV2, PerMonitor</dpiAwareness>" },
|
|
728
|
+
// The host's runtime DPI resolution mirrors that manifest chain:
|
|
729
|
+
// GetDpiForWindow, then shcore's GetDpiForMonitor (per-monitor v1),
|
|
730
|
+
// then the system DPI. Without the per-monitor-v1 and system rungs
|
|
731
|
+
// an aware process on a pre-1607 system would render at real
|
|
732
|
+
// physical pixels while the host still scaled everything at 1x.
|
|
733
|
+
.{ .path = "src/platform/windows/webview2_host.cpp", .pattern = "GetProcAddress(shcore, \"GetDpiForMonitor\")" },
|
|
734
|
+
.{ .path = "src/platform/windows/webview2_host.cpp", .pattern = "MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST)" },
|
|
735
|
+
.{ .path = "src/platform/windows/webview2_host.cpp", .pattern = "return systemDpi();" },
|
|
736
|
+
});
|
|
691
737
|
addFileContainsCheckStep(b, file_contains_checker, test_step, "test-appkit-gpu-widget-text-command-bridge", "Verify AppKit GPU text widgets route native text commands", &.{
|
|
692
738
|
.{ .path = "src/platform/macos/appkit_host.m", .pattern = "- (void)selectAll:(id)sender" },
|
|
693
739
|
.{ .path = "src/platform/macos/appkit_host.m", .pattern = "@selector(selectAll:)" },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@native-sdk/cli",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.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": {
|
|
@@ -17,19 +17,20 @@
|
|
|
17
17
|
"build.zig",
|
|
18
18
|
"build.zig.zon",
|
|
19
19
|
"app.zon",
|
|
20
|
+
"third_party/webview2",
|
|
20
21
|
"native-sdk.d.ts",
|
|
21
22
|
"README.md",
|
|
22
23
|
"LICENSE"
|
|
23
24
|
],
|
|
24
25
|
"optionalDependencies": {
|
|
25
|
-
"@native-sdk/cli-darwin-arm64": "0.4.
|
|
26
|
-
"@native-sdk/cli-darwin-x64": "0.4.
|
|
27
|
-
"@native-sdk/cli-linux-arm64-gnu": "0.4.
|
|
28
|
-
"@native-sdk/cli-linux-arm64-musl": "0.4.
|
|
29
|
-
"@native-sdk/cli-linux-x64-gnu": "0.4.
|
|
30
|
-
"@native-sdk/cli-linux-x64-musl": "0.4.
|
|
31
|
-
"@native-sdk/cli-win32-arm64": "0.4.
|
|
32
|
-
"@native-sdk/cli-win32-x64": "0.4.
|
|
26
|
+
"@native-sdk/cli-darwin-arm64": "0.4.2",
|
|
27
|
+
"@native-sdk/cli-darwin-x64": "0.4.2",
|
|
28
|
+
"@native-sdk/cli-linux-arm64-gnu": "0.4.2",
|
|
29
|
+
"@native-sdk/cli-linux-arm64-musl": "0.4.2",
|
|
30
|
+
"@native-sdk/cli-linux-x64-gnu": "0.4.2",
|
|
31
|
+
"@native-sdk/cli-linux-x64-musl": "0.4.2",
|
|
32
|
+
"@native-sdk/cli-win32-arm64": "0.4.2",
|
|
33
|
+
"@native-sdk/cli-win32-x64": "0.4.2"
|
|
33
34
|
},
|
|
34
35
|
"repository": {
|
|
35
36
|
"type": "git",
|
|
@@ -2399,6 +2399,14 @@ static BOOL NativeSdkPacketDrawCommandBody(NSDictionary *command, NSString *kind
|
|
|
2399
2399
|
} else if ([kind isEqualToString:@"stroke_path"]) {
|
|
2400
2400
|
NSBezierPath *path = NativeSdkPacketShapePath(NativeSdkPacketDictionary(command[@"shape"]));
|
|
2401
2401
|
path.lineWidth = MAX(1, NativeSdkPacketNumber(command[@"strokeWidth"], path.lineWidth));
|
|
2402
|
+
/* End caps come from the command's cap channel (the engine's
|
|
2403
|
+
* reference renderer honors the same field); joins are always
|
|
2404
|
+
* round for path strokes — the engine rounds every stroke-path
|
|
2405
|
+
* join, so a default miter here would put a spur on the
|
|
2406
|
+
* checkbox mark's vee that no other engine draws. */
|
|
2407
|
+
NSString *cap = [command[@"cap"] isKindOfClass:[NSString class]] ? command[@"cap"] : @"butt";
|
|
2408
|
+
path.lineCapStyle = [cap isEqualToString:@"round"] ? NSLineCapStyleRound : NSLineCapStyleButt;
|
|
2409
|
+
path.lineJoinStyle = NSLineJoinStyleRound;
|
|
2402
2410
|
ok = NativeSdkPacketDrawPaintedPath(path, NativeSdkPacketDictionary(command[@"paint"]), opacity, YES);
|
|
2403
2411
|
} else if ([kind isEqualToString:@"draw_text"]) {
|
|
2404
2412
|
ok = NativeSdkPacketDrawText(NativeSdkPacketDictionary(command[@"text"]), opacity);
|
|
@@ -2478,7 +2486,7 @@ static NSRect NativeSdkPacketAlignRectToPixels(NSRect rect, CGFloat scale, NSUIn
|
|
|
2478
2486
|
}
|
|
2479
2487
|
|
|
2480
2488
|
/* ---------------------------------------------------------------------------
|
|
2481
|
-
* Compact binary gpu-surface packet decoding (wire format
|
|
2489
|
+
* Compact binary gpu-surface packet decoding (wire format v4).
|
|
2482
2490
|
*
|
|
2483
2491
|
* Little-endian, length-prefixed, mirror of the engine's binary packet
|
|
2484
2492
|
* encoder (serialization.zig, `writeCanvasGpuPacketBinary` and the patch
|
|
@@ -2492,9 +2500,10 @@ static NSRect NativeSdkPacketAlignRectToPixels(NSRect rect, CGFloat scale, NSUIn
|
|
|
2492
2500
|
* command, and the `patch` load action carrying an edit script (evicts +
|
|
2493
2501
|
* keyed upserts + the full draw-order vector) against the view's retained
|
|
2494
2502
|
* command dictionary; v3 added the flag-gated dirty rect list after the
|
|
2495
|
-
* scissor
|
|
2496
|
-
*
|
|
2497
|
-
*
|
|
2503
|
+
* scissor; v4 added the per-command stroke end-cap code after
|
|
2504
|
+
* stroke_width. The version this comment names and the encoder's spec
|
|
2505
|
+
* comment must agree with `binary_packet_version` (serialization.zig);
|
|
2506
|
+
* the `test-wire-format-version-prose` build check pins all three.
|
|
2498
2507
|
*/
|
|
2499
2508
|
|
|
2500
2509
|
/* Retained commands per view; pins the engine's
|
|
@@ -2808,7 +2817,12 @@ static NSDictionary *NativeSdkBinaryReadCommand(NativeSdkBinaryPacketReader *rea
|
|
|
2808
2817
|
NSArray *bounds = NativeSdkBinaryReadF32Array(reader, 4);
|
|
2809
2818
|
NSNumber *opacity = NativeSdkBinaryReadF32Number(reader);
|
|
2810
2819
|
NSNumber *strokeWidth = NativeSdkBinaryReadF32Number(reader);
|
|
2811
|
-
|
|
2820
|
+
uint8_t capCode = NativeSdkBinaryReadU8(reader);
|
|
2821
|
+
/* Same string values the JSON parse yields, so the draw functions
|
|
2822
|
+
* serve both encodings unchanged. Unknown codes are a framing
|
|
2823
|
+
* violation like any unknown tag. */
|
|
2824
|
+
NSString *cap = capCode == 0 ? @"butt" : (capCode == 1 ? @"round" : nil);
|
|
2825
|
+
if (reader->failed || !kind || !bounds || !cap) {
|
|
2812
2826
|
reader->failed = YES;
|
|
2813
2827
|
return nil;
|
|
2814
2828
|
}
|
|
@@ -2817,6 +2831,7 @@ static NSDictionary *NativeSdkBinaryReadCommand(NativeSdkBinaryPacketReader *rea
|
|
|
2817
2831
|
@"bounds" : bounds,
|
|
2818
2832
|
@"opacity" : opacity,
|
|
2819
2833
|
@"strokeWidth" : strokeWidth,
|
|
2834
|
+
@"cap" : cap,
|
|
2820
2835
|
}];
|
|
2821
2836
|
if (flags & NativeSdkBinaryCommandFlagId) command[@"id"] = @(NativeSdkBinaryReadU64(reader));
|
|
2822
2837
|
if (flags & NativeSdkBinaryCommandFlagClip) {
|
|
@@ -2871,7 +2886,7 @@ static NSDictionary *NativeSdkPacketDictionaryFromBinary(const uint8_t *bytes, N
|
|
|
2871
2886
|
if (memcmp(bytes, "NSGP", 4) != 0) return nil;
|
|
2872
2887
|
reader.offset = 4;
|
|
2873
2888
|
uint8_t version = NativeSdkBinaryReadU8(&reader);
|
|
2874
|
-
if (version !=
|
|
2889
|
+
if (version != 4) return nil;
|
|
2875
2890
|
uint8_t loadActionCode = NativeSdkBinaryReadU8(&reader);
|
|
2876
2891
|
uint8_t packetFlags = NativeSdkBinaryReadU8(&reader);
|
|
2877
2892
|
(void)NativeSdkBinaryReadU8(&reader); /* reserved */
|