@native-sdk/cli 0.8.0 → 0.8.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@native-sdk/cli",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
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": {
@@ -34,14 +34,14 @@
34
34
  "scriptc": "0.0.22"
35
35
  },
36
36
  "optionalDependencies": {
37
- "@native-sdk/cli-darwin-arm64": "0.8.0",
38
- "@native-sdk/cli-darwin-x64": "0.8.0",
39
- "@native-sdk/cli-linux-arm64-gnu": "0.8.0",
40
- "@native-sdk/cli-linux-arm64-musl": "0.8.0",
41
- "@native-sdk/cli-linux-x64-gnu": "0.8.0",
42
- "@native-sdk/cli-linux-x64-musl": "0.8.0",
43
- "@native-sdk/cli-win32-arm64": "0.8.0",
44
- "@native-sdk/cli-win32-x64": "0.8.0"
37
+ "@native-sdk/cli-darwin-arm64": "0.8.1",
38
+ "@native-sdk/cli-darwin-x64": "0.8.1",
39
+ "@native-sdk/cli-linux-arm64-gnu": "0.8.1",
40
+ "@native-sdk/cli-linux-arm64-musl": "0.8.1",
41
+ "@native-sdk/cli-linux-x64-gnu": "0.8.1",
42
+ "@native-sdk/cli-linux-x64-musl": "0.8.1",
43
+ "@native-sdk/cli-win32-arm64": "0.8.1",
44
+ "@native-sdk/cli-win32-x64": "0.8.1"
45
45
  },
46
46
  "repository": {
47
47
  "type": "git",
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@native-sdk/core",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@native-sdk/core",
9
- "version": "0.8.0",
9
+ "version": "0.8.1",
10
10
  "dependencies": {
11
11
  "scriptc": "0.0.22"
12
12
  },
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@native-sdk/core",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "description": "The TypeScript authoring tier: the app-core subset, its checker and contract frontend, the exact-pinned core compiler dependency, and the SDK module cores import",
5
5
  "repository": {
6
6
  "type": "git",
@@ -991,15 +991,16 @@ Bare source-bound highlighted content shared with Markdown fences:
991
991
  A leaf element that renders a markdown string (the GFM subset below) as ordinary widgets, wiring `native_sdk.markdown` for you — both engines implement it identically:
992
992
 
993
993
  ```html
994
- <markdown source="{issue_body}" on-link="open_url" on-details="toggle_details" details-expanded="{details_expanded}" />
994
+ <markdown source="{issue_body}" images="{markdownImages}" on-link="open_url" on-details="toggle_details" details-expanded="{details_expanded}" />
995
995
  ```
996
996
 
997
997
  - `source` (required): one `{binding}` producing the markdown text — a `[]const u8` field, zero-arg fn, or arena-taking fn (compose the document into the build arena at view time).
998
+ - `images` (optional): one `{binding}` producing `[]const canvas.markdown.ResolvedImage`. Give `canvas.markdown.collectImageSources` caller-owned `[]canvas.markdown.CollectedImageSource` storage, consume each canonical source through `value()` while that storage is alive, load it through `fx.loadImage`, and retain the source, successful id, and decoded dimensions in the model. Return mappings from a model or arena-taking fn. The view never performs I/O; missing mappings keep the safe alt-text fallback.
998
999
  - `on-link` (optional): a BARE Msg tag — no `:{payload}` — whose payload is the pressed link URL; declare `open_url: []const u8` in `Msg`.
999
1000
  - `on-details` (optional): a bare Msg tag whose payload is the `<details>` block's document-order index; declare `toggle_details: usize`.
1000
1001
  - `details-expanded` (optional): one `{binding}` naming a `[]const bool` iterable (a model field, pub decl, or fn — the same sources `for each` accepts); flags are read in details-block document order. Keep a bounded `details_expanded: [8]bool` in the model and toggle it in `update`.
1001
1002
  - `issue-link-base` (optional): a literal URL prefix or one `{binding}` producing it; `#123` references at word boundaries become links to base ++ number (`issue-link-base="ghissue://"` links `#123` to `ghissue://123` — an app scheme your `on-link` handler intercepts, or a web base like `https://github.com/owner/repo/issues/`). Off by default: resolving a ref needs repo context.
1002
- - No children, no text content, no other attributes (teaching errors point at misuse). Without the details wiring, `<details>` blocks render collapsed and inert; without `on-link`, links render styled but inert.
1003
+ - No children and no text content (teaching errors point at misuse). Without the details wiring, `<details>` blocks render collapsed and inert; without `on-link`, links render styled but inert.
1003
1004
 
1004
1005
  ## Pipeline composites: stepper, timeline, nav
1005
1006
 
@@ -612,13 +612,13 @@ int native_sdk_appkit_register_font(uint64_t font_id, const uint8_t *bytes, size
612
612
  // already gone, which is the state the caller asked for. Returns 1 on
613
613
  // accept, 0 only for the invalid id 0.
614
614
  int native_sdk_appkit_unregister_font(uint64_t font_id, uint64_t token);
615
- /* Decode encoded image bytes (PNG, JPEG, ... — whatever ImageIO supports)
616
- * through CGImageSource into tightly packed, row-major, straight-alpha
615
+ /* Decode encoded image bytes (PNG, JPEG, ... through ImageIO; SVG through
616
+ * NSImage's system rasterizer) into tightly packed, row-major, straight-alpha
617
617
  * (non-premultiplied) RGBA8 written into `pixels`. Returns 1 on success
618
618
  * (with `out_width`/`out_height` set), 0 when the bytes cannot be decoded,
619
619
  * and -1 when the decoded pixels do not fit `pixels_len` (`out_width`/
620
- * `out_height` still report the decoded dimensions). Pure CoreGraphics —
621
- * no AppKit state — so it needs no host and is main-thread independent. */
620
+ * `out_height` still report the decoded dimensions). It retains no AppKit
621
+ * state, needs no host, and is main-thread independent. */
622
622
  int native_sdk_appkit_decode_image(const uint8_t *bytes, size_t bytes_len, uint8_t *pixels, size_t pixels_len, size_t *out_width, size_t *out_height);
623
623
  void native_sdk_appkit_clipboard_write(native_sdk_appkit_host_t *host, const char *text, size_t text_len);
624
624
  size_t native_sdk_appkit_clipboard_read_data(native_sdk_appkit_host_t *host, const char *mime_type, size_t mime_type_len, char *buffer, size_t buffer_len);
@@ -2454,7 +2454,9 @@ int native_sdk_appkit_measure_text_advances(uint64_t font_id, double size, const
2454
2454
  }
2455
2455
 
2456
2456
  // Platform image decoder: CGImageSource (ImageIO) handles PNG, JPEG, and
2457
- // every other codec the OS ships — the framework bundles none. The image
2457
+ // every other raster codec the OS ships. AppKit's NSImage adds the system SVG
2458
+ // representation/rasterizer when ImageIO cannot create a CGImage directly —
2459
+ // still an in-box codec, with no framework-bundled parser. The image
2458
2460
  // draws into a premultiplied RGBA8 bitmap context (the only RGBA layout
2459
2461
  // CGBitmapContext can render into) and is un-premultiplied in place,
2460
2462
  // because the canvas image pipeline — the reference renderer and the
@@ -2465,10 +2467,28 @@ int native_sdk_appkit_decode_image(const uint8_t *bytes, size_t bytes_len, uint8
2465
2467
  if (!bytes || bytes_len == 0 || !pixels) return 0;
2466
2468
  @autoreleasepool {
2467
2469
  NSData *data = [NSData dataWithBytesNoCopy:(void *)bytes length:bytes_len freeWhenDone:NO];
2470
+ CGImageRef image = NULL;
2468
2471
  CGImageSourceRef source = CGImageSourceCreateWithData((__bridge CFDataRef)data, NULL);
2469
- if (!source) return 0;
2470
- CGImageRef image = CGImageSourceCreateImageAtIndex(source, 0, NULL);
2471
- CFRelease(source);
2472
+ if (source) {
2473
+ image = CGImageSourceCreateImageAtIndex(source, 0, NULL);
2474
+ CFRelease(source);
2475
+ }
2476
+ if (!image) {
2477
+ NSImage *system_image = [[NSImage alloc] initWithData:data];
2478
+ NSSize size = system_image ? system_image.size : NSZeroSize;
2479
+ if (size.width > 0 && size.height > 0 && size.width <= 8192 && size.height <= 8192) {
2480
+ // SVG is resolution-independent, so cap the proposed point
2481
+ // extent before NSImage selects its Retina representation.
2482
+ // A 256pt square becomes at most the registry's 512px square
2483
+ // on macOS's 2x displays instead of materializing an
2484
+ // attacker-declared multi-hundred-megabyte bitmap first.
2485
+ const CGFloat max_raster_points = 256.0;
2486
+ const CGFloat raster_scale = MIN(1.0, MIN(max_raster_points / size.width, max_raster_points / size.height));
2487
+ NSRect proposed = NSMakeRect(0, 0, size.width * raster_scale, size.height * raster_scale);
2488
+ CGImageRef rendered = [system_image CGImageForProposedRect:&proposed context:nil hints:nil];
2489
+ if (rendered) image = CGImageRetain(rendered);
2490
+ }
2491
+ }
2472
2492
  if (!image) return 0;
2473
2493
 
2474
2494
  size_t width = CGImageGetWidth(image);
@@ -2909,19 +2909,35 @@ int native_sdk_appkit_measure_text_advances(uint64_t font_id, double size, const
2909
2909
  return 0;
2910
2910
  }
2911
2911
 
2912
- /* Mirror of the AppKit host's decoder: pure CoreGraphics/ImageIO with no
2913
- * host state, so both engines decode identically. See appkit_host.h for
2914
- * the pixel-format and return-value contract. */
2912
+ /* Mirror of the AppKit host's decoder: ImageIO raster codecs plus NSImage's
2913
+ * system SVG rasterizer, with no host state, so both engines decode
2914
+ * identically. See appkit_host.h for the pixel-format and return-value
2915
+ * contract. */
2915
2916
  int native_sdk_appkit_decode_image(const uint8_t *bytes, size_t bytes_len, uint8_t *pixels, size_t pixels_len, size_t *out_width, size_t *out_height) {
2916
2917
  if (out_width) *out_width = 0;
2917
2918
  if (out_height) *out_height = 0;
2918
2919
  if (!bytes || bytes_len == 0 || !pixels) return 0;
2919
2920
  @autoreleasepool {
2920
2921
  NSData *data = [NSData dataWithBytesNoCopy:(void *)bytes length:bytes_len freeWhenDone:NO];
2922
+ CGImageRef image = NULL;
2921
2923
  CGImageSourceRef source = CGImageSourceCreateWithData((__bridge CFDataRef)data, NULL);
2922
- if (!source) return 0;
2923
- CGImageRef image = CGImageSourceCreateImageAtIndex(source, 0, NULL);
2924
- CFRelease(source);
2924
+ if (source) {
2925
+ image = CGImageSourceCreateImageAtIndex(source, 0, NULL);
2926
+ CFRelease(source);
2927
+ }
2928
+ if (!image) {
2929
+ NSImage *system_image = [[NSImage alloc] initWithData:data];
2930
+ NSSize size = system_image ? system_image.size : NSZeroSize;
2931
+ if (size.width > 0 && size.height > 0 && size.width <= 8192 && size.height <= 8192) {
2932
+ // Bound SVG rasterization before NSImage materializes the
2933
+ // screen-scale representation; see the AppKit mirror.
2934
+ const CGFloat max_raster_points = 256.0;
2935
+ const CGFloat raster_scale = MIN(1.0, MIN(max_raster_points / size.width, max_raster_points / size.height));
2936
+ NSRect proposed = NSMakeRect(0, 0, size.width * raster_scale, size.height * raster_scale);
2937
+ CGImageRef rendered = [system_image CGImageForProposedRect:&proposed context:nil hints:nil];
2938
+ if (rendered) image = CGImageRetain(rendered);
2939
+ }
2940
+ }
2925
2941
  if (!image) return 0;
2926
2942
 
2927
2943
  size_t width = CGImageGetWidth(image);
@@ -1131,8 +1131,8 @@ fn measureTextAdvances(context: ?*anyopaque, font_id: u64, size: f32, text: []co
1131
1131
  return native_sdk_appkit_measure_text_advances(font_id, size, text.ptr, text.len, advances.ptr) == 1;
1132
1132
  }
1133
1133
 
1134
- /// CGImageSource-backed image decoding (PNG, JPEG, ... — every codec
1135
- /// ImageIO ships) into straight-alpha RGBA8.
1134
+ /// System image decoding (ImageIO raster codecs plus NSImage's SVG
1135
+ /// rasterizer) into straight-alpha RGBA8.
1136
1136
  fn decodeImage(context: ?*anyopaque, bytes: []const u8, buffer: []u8) anyerror!platform_mod.DecodedImage {
1137
1137
  _ = context;
1138
1138
  var width: usize = 0;