@native-sdk/cli 0.7.0 → 0.7.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 +8 -0
- package/build.zig +114 -103
- package/native-sdk.d.ts +6 -3
- package/package.json +9 -9
- package/packages/core/package-lock.json +2 -2
- package/packages/core/package.json +1 -1
- package/packages/core/sdk/text.ts +25 -14
- package/packages/core/src/checker.ts +39 -0
- package/packages/core/src/emitter.ts +125 -1
- package/skill-data/native-ui/SKILL.md +11 -7
- package/src/platform/macos/appkit_host.m +76 -4
- package/src/platform/macos/cef_host.mm +24 -2
- package/src/platform/macos/root.zig +13 -0
- 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 +501 -33
- package/src/primitives/canvas/code_tests.zig +1029 -6
- package/src/primitives/canvas/events.zig +111 -1
- package/src/primitives/canvas/frame.zig +45 -1
- package/src/primitives/canvas/gpu.zig +6 -0
- package/src/primitives/canvas/markdown_tests.zig +17 -18
- package/src/primitives/canvas/render_tests.zig +93 -0
- package/src/primitives/canvas/root.zig +6 -0
- package/src/primitives/canvas/serialization.zig +150 -21
- package/src/primitives/canvas/text.zig +6 -0
- package/src/primitives/canvas/themes/geist.zig +51 -5
- package/src/primitives/canvas/tokens.zig +33 -4
- package/src/primitives/canvas/ui.zig +160 -36
- package/src/primitives/canvas/ui_markup.zig +60 -9
- package/src/primitives/canvas/ui_markup_compiled.zig +41 -0
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +12 -0
- package/src/primitives/canvas/ui_markup_contract.zig +17 -1
- package/src/primitives/canvas/ui_markup_view.zig +44 -0
- package/src/primitives/canvas/ui_markup_view_tests.zig +80 -6
- package/src/primitives/canvas/ui_schema.zig +18 -0
- package/src/primitives/canvas/ui_schema_tests.zig +10 -7
- package/src/primitives/canvas/ui_tests.zig +40 -0
- package/src/primitives/canvas/widget_builtin_tests.zig +513 -13
- package/src/primitives/canvas/widget_invalidation.zig +12 -1
- package/src/primitives/canvas/widget_layout.zig +260 -21
- package/src/primitives/canvas/widget_metrics.zig +47 -6
- package/src/primitives/canvas/widget_render.zig +849 -78
- package/src/primitives/canvas/widget_render_controls.zig +83 -25
- package/src/primitives/canvas/widget_render_style.zig +52 -8
- package/src/primitives/canvas/widget_runtime.zig +2 -0
- package/src/primitives/canvas/widget_text_input.zig +167 -8
- package/src/primitives/canvas/widget_tree.zig +6 -5
- package/src/primitives/canvas/widgets.zig +78 -2
- package/src/runtime/canvas_budget_edge_tests.zig +3 -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_limits.zig +13 -6
- package/src/runtime/canvas_widget_clipboard_tests.zig +8 -5
- package/src/runtime/canvas_widget_context_menu.zig +7 -2
- package/src/runtime/canvas_widget_event_tests.zig +18 -14
- package/src/runtime/canvas_widget_events.zig +51 -20
- package/src/runtime/canvas_widget_runtime.zig +108 -4
- package/src/runtime/canvas_widget_scroll_driver_tests.zig +59 -0
- package/src/runtime/canvas_widget_split_tree_tests.zig +100 -0
- package/src/runtime/canvas_widget_state.zig +27 -0
- package/src/runtime/canvas_widget_text_tests.zig +326 -0
- package/src/runtime/core.zig +15 -5
- package/src/runtime/effects.zig +6 -0
- package/src/runtime/effects_tests.zig +30 -0
- package/src/runtime/gpu_surface_events.zig +50 -19
- package/src/runtime/media_surface_tests.zig +1 -1
- package/src/runtime/runtime_event_tests.zig +74 -0
- package/src/runtime/ui_app.zig +10 -8
- package/src/runtime/ui_app_tests.zig +67 -0
- package/src/runtime/view.zig +60 -16
- package/src/runtime/view_canvas.zig +15 -0
- package/src/runtime/view_widget_scroll.zig +48 -18
- package/src/runtime/view_widget_text.zig +59 -16
- package/src/runtime/window_view_runtime.zig +10 -0
- package/src/tooling/templates.zig +9 -6
|
@@ -269,7 +269,7 @@ const emittedFixtureNames = [
|
|
|
269
269
|
"jsPow", "tagEq", "tagIsNull",
|
|
270
270
|
"tagCast", "strEq", "strIsNull", "numEq", "numIsNull", "empty_bytes", "UpdateResult", "InitResult",
|
|
271
271
|
"CommitMode", "commitBytes", "commitScalars", "commitModelRoot",
|
|
272
|
-
"shouldCopy", "inOldHeap", "old_heap_base", "old_heap_len", "core_root",
|
|
272
|
+
"shouldCopy", "inOldHeap", "old_heap_base", "old_heap_len", "core_root", "type_origins",
|
|
273
273
|
] as const;
|
|
274
274
|
|
|
275
275
|
/// The `Cmd.audio*` control verbs and their zig enum literals (`resume` is a
|
|
@@ -375,6 +375,7 @@ export class Emitter {
|
|
|
375
375
|
this.fileSet = new Set(this.files);
|
|
376
376
|
this.sourceName = sourceName;
|
|
377
377
|
this.capacities = capacities;
|
|
378
|
+
this.validateGeneratedMetadataNames();
|
|
378
379
|
this.claimModuleNames();
|
|
379
380
|
this.computeExceptions();
|
|
380
381
|
}
|
|
@@ -520,6 +521,43 @@ export class Emitter {
|
|
|
520
521
|
return found;
|
|
521
522
|
}
|
|
522
523
|
|
|
524
|
+
/// Layer-3 re-derivation of the fixed names the contract extractor reads.
|
|
525
|
+
/// The checker gives the normal teaching; this fence prevents a direct
|
|
526
|
+
/// emitter caller from producing duplicate Zig declarations.
|
|
527
|
+
private validateGeneratedMetadataNames(): void {
|
|
528
|
+
const refuseTypeOrigins = (name: ts.Identifier): void => {
|
|
529
|
+
if (name.text === "type_origins") {
|
|
530
|
+
this.fail(name, "`type_origins` collides with the generated contract type-origin metadata declaration; rename the authored declaration.", "NS1038");
|
|
531
|
+
}
|
|
532
|
+
};
|
|
533
|
+
for (const file of this.files) {
|
|
534
|
+
for (const stmt of file.statements) {
|
|
535
|
+
if (
|
|
536
|
+
ts.isInterfaceDeclaration(stmt) ||
|
|
537
|
+
ts.isTypeAliasDeclaration(stmt) ||
|
|
538
|
+
ts.isClassDeclaration(stmt) ||
|
|
539
|
+
ts.isFunctionDeclaration(stmt)
|
|
540
|
+
) {
|
|
541
|
+
if (stmt.name) refuseTypeOrigins(stmt.name);
|
|
542
|
+
} else if (ts.isVariableStatement(stmt)) {
|
|
543
|
+
for (const decl of stmt.declarationList.declarations) {
|
|
544
|
+
if (ts.isIdentifier(decl.name)) refuseTypeOrigins(decl.name);
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
for (const binding of exportListBindings(this.tast, file)) {
|
|
549
|
+
if (binding.exportedName === "type_origins") {
|
|
550
|
+
this.fail(binding.spec.name, "`type_origins` collides with the generated contract type-origin metadata declaration; rename the export.", "NS1038");
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
for (const union of this.table.unions.values()) {
|
|
555
|
+
if (union.arms.some((arm) => arm.fields.length === 1) && union.arms.some((arm) => arm.tag === "payload_members")) {
|
|
556
|
+
this.fail(union.decl.name, `Union \`${union.name}\` has an arm named \`payload_members\`, which collides with its generated single-payload metadata declaration; rename the arm.`, "NS1038");
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
|
|
523
561
|
/// Claim every module-level name up front, across all files: fixture
|
|
524
562
|
/// names first, then types (never renamed), then exported values (never
|
|
525
563
|
/// renamed), then private values entry-first — a private collision takes
|
|
@@ -1014,10 +1052,68 @@ export class Emitter {
|
|
|
1014
1052
|
this.emitHoistedFunctions();
|
|
1015
1053
|
}
|
|
1016
1054
|
this.emitInstantiatedTypes();
|
|
1055
|
+
this.emitTypeOrigins();
|
|
1017
1056
|
this.emitCommitWalkers();
|
|
1018
1057
|
return this.out.join("\n") + "\n";
|
|
1019
1058
|
}
|
|
1020
1059
|
|
|
1060
|
+
/// The declaring module of every named type the contract tables can
|
|
1061
|
+
/// reach — a contract fact the sidecar extractor carries so a contract
|
|
1062
|
+
/// consumer can re-export each type from its own module. SDK library
|
|
1063
|
+
/// modules spell their shipped staging path (`sdk/<name>.ts`); the
|
|
1064
|
+
/// core's own modules spell their path relative to the entry module's
|
|
1065
|
+
/// directory, with POSIX separators because the sidecar/facade contract is
|
|
1066
|
+
/// platform-independent. Synthesized (anonymous) type names stay out:
|
|
1067
|
+
/// they are declared nowhere.
|
|
1068
|
+
private emitTypeOrigins(): void {
|
|
1069
|
+
const sdkDir = path.resolve(path.dirname(sdkCoreModulePath));
|
|
1070
|
+
const entryDir = path.dirname(path.resolve(this.file.fileName));
|
|
1071
|
+
const seen = new Set<string>();
|
|
1072
|
+
const entries: string[] = [];
|
|
1073
|
+
for (const file of this.files) {
|
|
1074
|
+
for (const stmt of file.statements) {
|
|
1075
|
+
if (!ts.isInterfaceDeclaration(stmt) && !ts.isTypeAliasDeclaration(stmt) && !ts.isClassDeclaration(stmt)) continue;
|
|
1076
|
+
if (!stmt.name) continue;
|
|
1077
|
+
const name = stmt.name.text;
|
|
1078
|
+
if (seen.has(name)) continue;
|
|
1079
|
+
if (!this.table.structs.has(name) && !this.table.enums.has(name) && !this.table.unions.has(name)) continue;
|
|
1080
|
+
if (this.table.genericStructTemplates.has(name) || this.table.genericAliasTemplates.has(name)) continue;
|
|
1081
|
+
seen.add(name);
|
|
1082
|
+
const fileName = path.resolve(file.fileName);
|
|
1083
|
+
const origin =
|
|
1084
|
+
path.dirname(fileName) === sdkDir
|
|
1085
|
+
? `sdk/${path.basename(fileName)}`
|
|
1086
|
+
: path.relative(entryDir, fileName).split(path.sep).join("/");
|
|
1087
|
+
const exported =
|
|
1088
|
+
hasExportModifier(stmt) ||
|
|
1089
|
+
file.statements.some(
|
|
1090
|
+
(candidate) =>
|
|
1091
|
+
ts.isExportDeclaration(candidate) &&
|
|
1092
|
+
candidate.moduleSpecifier === undefined &&
|
|
1093
|
+
candidate.exportClause !== undefined &&
|
|
1094
|
+
ts.isNamedExports(candidate.exportClause) &&
|
|
1095
|
+
candidate.exportClause.elements.some(
|
|
1096
|
+
(spec) => spec.name.text === name && this.tast.exportSpecifierTarget(spec) === stmt,
|
|
1097
|
+
),
|
|
1098
|
+
);
|
|
1099
|
+
// The third tuple field is additive and appears only for a private
|
|
1100
|
+
// declaration. Older extractors keep reading the two origin fields;
|
|
1101
|
+
// current ones use the marker to synthesize a structural facade type
|
|
1102
|
+
// instead of importing a name its module does not export.
|
|
1103
|
+
entries.push(` .{ ${zigString(name)}, ${zigString(origin)}${exported ? "" : ", false"} },`);
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
if (entries.length === 0) return;
|
|
1107
|
+
this.out.push(``);
|
|
1108
|
+
this.out.push(`// The declaring module of every named contract-table type (the sidecar`);
|
|
1109
|
+
this.out.push(`// extractor's origin facts; a third false field marks declarations the`);
|
|
1110
|
+
this.out.push(`// authored module does not export. Synthesized names are declared nowhere`);
|
|
1111
|
+
this.out.push(`// and stay out).`);
|
|
1112
|
+
this.out.push(`pub const type_origins = .{`);
|
|
1113
|
+
this.out.push(...entries);
|
|
1114
|
+
this.out.push(`};`);
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1021
1117
|
/// R15e: emit every queued generic instantiation under its resolved
|
|
1022
1118
|
/// type-parameter scope.
|
|
1023
1119
|
private emitGenericInstantiations(): void {
|
|
@@ -1953,6 +2049,18 @@ export class Emitter {
|
|
|
1953
2049
|
this.out.push(` ${zigId(arm.tag)}: struct { ${fields.join(", ")} },`);
|
|
1954
2050
|
}
|
|
1955
2051
|
}
|
|
2052
|
+
const singles = un.arms.filter((a) => a.fields.length === 1);
|
|
2053
|
+
if (singles.length > 0) {
|
|
2054
|
+
// The authored member name of each single-payload arm: the arm's
|
|
2055
|
+
// emitted payload spells the bare type, erasing the author's
|
|
2056
|
+
// spelling, so the sidecar extractor reads it from this table (a
|
|
2057
|
+
// contract consumer constructing arm values needs the author's
|
|
2058
|
+
// property names).
|
|
2059
|
+
this.out.push(``);
|
|
2060
|
+
this.out.push(
|
|
2061
|
+
` pub const payload_members = .{ ${singles.map((a) => `.${zigId(a.tag)} = ${zigString(a.fields[0].tsName)}`).join(", ")} };`,
|
|
2062
|
+
);
|
|
2063
|
+
}
|
|
1956
2064
|
if (name === "Msg" && this.unbound.msg.length > 0) {
|
|
1957
2065
|
// The dead-state lint opt-out `native check` reads (viewUnbound).
|
|
1958
2066
|
this.out.push(``);
|
|
@@ -1985,6 +2093,7 @@ export class Emitter {
|
|
|
1985
2093
|
const names = new Set<string>(emittedFixtureNames);
|
|
1986
2094
|
names.add("Thrown");
|
|
1987
2095
|
names.add("thrown_payload");
|
|
2096
|
+
names.add("type_origins");
|
|
1988
2097
|
names.add(THROWN_UNION_NAME);
|
|
1989
2098
|
for (const file of this.files) {
|
|
1990
2099
|
for (const stmt of file.statements) {
|
|
@@ -11611,6 +11720,21 @@ function zigId(name: string): string {
|
|
|
11611
11720
|
return /^[A-Za-z_][A-Za-z0-9_]*$/.test(name) ? name : `@"${name}"`;
|
|
11612
11721
|
}
|
|
11613
11722
|
|
|
11723
|
+
/// A Zig double-quoted string literal for an authored spelling (name
|
|
11724
|
+
/// tables the sidecar extractor reads).
|
|
11725
|
+
function zigString(text: string): string {
|
|
11726
|
+
let out = '"';
|
|
11727
|
+
for (const ch of text) {
|
|
11728
|
+
if (ch === '"') out += '\\"';
|
|
11729
|
+
else if (ch === "\\") out += "\\\\";
|
|
11730
|
+
else if (ch === "\n") out += "\\n";
|
|
11731
|
+
else if (ch === "\r") out += "\\r";
|
|
11732
|
+
else if (ch === "\t") out += "\\t";
|
|
11733
|
+
else out += ch;
|
|
11734
|
+
}
|
|
11735
|
+
return out + '"';
|
|
11736
|
+
}
|
|
11737
|
+
|
|
11614
11738
|
/// Zig keywords that are legal JS label identifiers — a TS label with one of
|
|
11615
11739
|
/// these names takes a suffix so the emitted `label: while` stays parseable.
|
|
11616
11740
|
const zigOnlyKeywords = new Set([
|
|
@@ -182,7 +182,7 @@ Automation drives the native path honestly: snapshots list every widget's declar
|
|
|
182
182
|
| `icon` | vector icon leaf | `name` picks the icon: a bare literal is a curated built-in stroke icon (compile-checked; 49 names: search, plus, x, x-circle, check, check-circle, chevron-up/down/left/right, arrow-up/down/right, menu, panel-left, panel-right, settings, terminal, wrench, trash, edit, copy, external-link, play, pause, skip-back/forward, shuffle, repeat, music, volume, info, alert, download, save, folder, folder-open, file-text, sun, moon, eye, clock, git-pull-request, git-merge, git-branch, circle-dot, archive, refresh-cw, send); `app:<name>` reaches an icon the app registered at boot with `canvas.icons.registerAppIcons` (declare the table as `pub const app_icons` on the app root so `native check` verifies the name against the model contract), and one `{binding}` defers the choice to model data - an unknown resolved name draws the missing-icon fallback (a slashed circle) with a Debug warning naming the value, never a silent gap; tint with `foreground`, size with `width`/`height` |
|
|
183
183
|
| `media-surface` | media surface leaf | composites a texture produced OUTSIDE the widget tree (video decoder, camera, an external renderer like mpv) into the layout like any widget — clipped, z-ordered, rounded. `surface="{binding}"` (required) binds the model-owned u64 surface id a Zig-tier producer targets (`runtime.acquireMediaSurfaceProducer` pushes RGBA8 frames, latest-wins, paced by the presented-frame clock; 0 = unbound, draws nothing; usable ids are nonzero values below the reserved bit 63). No intrinsic size — give it `width`/`height` or `grow`; display-only (presses fall through); `label` it (pictorial content). Texture contents are presentation chrome: goldens, reference screenshots, and session replay show the deterministic id-derived placeholder, never producer frames |
|
|
184
184
|
| `image` | runtime image leaf | draws a RUNTIME-REGISTERED image by its model-owned u64 ImageId — the id `Cmd.imageLoad` (TS) or `fx.loadImage`/`fx.registerImageBytes` (Zig) registered pixels under. `image="{binding}"` (required) binds a model field/fn; ids are model data, never markup literals, and 0 draws nothing (store the id only when the load reports loaded — see the Images section). No intrinsic size — give it `width`/`height` or `grow`; display-only (presses fall through); `label` it (pictorial content) |
|
|
185
|
-
| `code` | highlighted source
|
|
185
|
+
| `code` | bare highlighted source/editor | `source="{binding}"` (required) provides source text and `language="tsx"` selects a literal lexer name; the component supplies no background, border, radius, shadow, or padding, so wrap it in a panel/card when chrome is wanted. It is read-only by default; `editable on-input="edit"` opts into multiline editing while retaining highlighting. It wraps by default, `line-numbers` opts into logical line numbers, `added-lines="5"` / `removed-lines="2-4"` add Geist-style diff rows without changing copied source, and `wrap="false"` preserves lines inside one horizontal scroll region. HTML-family highlighting distinguishes HTML/XML/SVG and JSX/TSX tags, attributes, strings, comments, and embedded expressions. Zig builder: `ui.code(CodeOptions, source)` |
|
|
186
186
|
| `markdown` | rendered markdown subtree | leaf; `source` is one `{binding}` — see "Markdown in markup" |
|
|
187
187
|
| `stepper` > `step` | composite stage track | `active="{index}"` (required) derives each step's completed/active/pending state; steps are text leaves (no attributes) joined by connectors; stepper also takes `key`, `global-key`, `label` |
|
|
188
188
|
| `timeline` > `timeline-item` | composite ledger list | items only inside a timeline (for/if fine); items are leaves — `title` (required), `description`, `meta`, `indicator`, `variant`, `connector="false"` on the last item, `selected`; `on-press` makes the whole item pressable with a trailing chevron |
|
|
@@ -299,7 +299,7 @@ How the pieces fit, all model-owned (TEA):
|
|
|
299
299
|
|
|
300
300
|
### Select, then act: double press and row-level Enter
|
|
301
301
|
|
|
302
|
-
The desktop list convention — click selects, the primary action (open the record, play the track) rides the double click and Enter — is two bindings on the same row. `
|
|
302
|
+
The desktop list convention — click selects, the primary action (open the record, play the track) rides the double click and Enter — is two bindings on the same row. `on-double-press` in markup (`ElementOptions.on_double_press` in Zig) dispatches on the release whose runtime-derived click count reached 2, in place of a second press: the first click still dispatches `on-press` on its own release, so the pairing is additive, never a delay — no press timer, no swallowed first click. Like `on-press`, binding it makes the element a hit target; a widget with no double handler treats a double click as two single clicks. The keyboard mirror is row-level Enter: on a `list-item`, `on-submit` grows a second home beyond text entry — with a submit handler bound, plain Enter on a keyboard-focused row dispatches it as the row's PRIMARY action while Space keeps the select activation (`on-press`); rows without one resolve Enter as select, unchanged. Markup pairs the gestures directly (`<list-item on-press="select_track:{t.id}" on-double-press="play_track:{t.id}" on-submit="play_track:{t.id}">{t.title}</list-item>`), and tests drive the pointer half through `msgForPointerClick` and the keyboard half through `msgForKeyboard`. `examples/soundboard`'s Zig track rows remain the live builder reference: `on_press` select, `on_double_press` play, `on_submit` play.
|
|
303
303
|
|
|
304
304
|
## Widget budgets and virtualization
|
|
305
305
|
|
|
@@ -475,7 +475,7 @@ For `<if test>`, prefer an explicit boolean predicate method over numeric truthi
|
|
|
475
475
|
|
|
476
476
|
## Messages
|
|
477
477
|
|
|
478
|
-
`on-press`, `on-toggle`, `on-change`, `on-submit` (enter in a text field; primary+enter in a textarea, where enter inserts a newline), `on-dismiss` (dismissible surfaces: dialog, drawer, sheet, dropdown-menu — dispatched when Escape or a click outside dismisses the surface, so the model owns the close), `on-hold` (press-and-hold, see the Pickers section), and `on-hover-enter`/`on-hover-leave` (the pointer-hover containment pair, below) take `tag` or `tag:{payload}`. The tag must be a variant of your `Msg` union; payload bindings coerce to the variant's payload type: integers, floats, enums (from tag names), `[]const u8`, bool. `on-input` is special: name a `Msg` variant whose payload is `canvas.TextInputEvent` and the runtime delivers each text edit in it. `on-scroll` (the `scroll` element only) is the same shape: name a `Msg` variant whose payload is `canvas.ScrollState` and the runtime delivers the post-scroll state — `offset`, `viewport_extent`, `content_extent`, `maxOffset()` — after every user scroll (wheel, kinetic momentum steps, keyboard, accessibility). In Zig views the constructors are `Ui.inputMsg(.tag)` / `Ui.scrollMsg(.tag)` on `on_input` / `on_scroll`. `on-reach-end` (the `scroll` element only; `on_reach_end` in Zig views, any scroll container including the windowed virtual list) is a plain Msg dispatched when a user scroll comes within one viewport of the content end — the infinite-fetch signal, fired once per approach with hysteresis (re-arms past 1.5 viewports, which appending a batch causes by growing the extent). A programmatic jump to the end fires once and NEVER re-arms while the offset stays near the end — re-arming needs a post-scroll observation at least 1.5 viewports from it.
|
|
478
|
+
`on-press`, `on-double-press`, `on-toggle`, `on-change`, `on-submit` (enter in a text field; primary+enter in a textarea, where enter inserts a newline), `on-dismiss` (dismissible surfaces: dialog, drawer, sheet, dropdown-menu — dispatched when Escape or a click outside dismisses the surface, so the model owns the close), `on-hold` (press-and-hold, see the Pickers section), and `on-hover-enter`/`on-hover-leave` (the pointer-hover containment pair, below) take `tag` or `tag:{payload}`. The tag must be a variant of your `Msg` union; payload bindings coerce to the variant's payload type: integers, floats, enums (from tag names), `[]const u8`, bool. `on-input` is special: name a `Msg` variant whose payload is `canvas.TextInputEvent` and the runtime delivers each text edit in it. `on-scroll` (the `scroll` element only) is the same shape: name a `Msg` variant whose payload is `canvas.ScrollState` and the runtime delivers the post-scroll state — `offset`, `viewport_extent`, `content_extent`, `maxOffset()` — after every user scroll (wheel, kinetic momentum steps, keyboard, accessibility). In Zig views the constructors are `Ui.inputMsg(.tag)` / `Ui.scrollMsg(.tag)` on `on_input` / `on_scroll`. `on-reach-end` (the `scroll` element only; `on_reach_end` in Zig views, any scroll container including the windowed virtual list) is a plain Msg dispatched when a user scroll comes within one viewport of the content end — the infinite-fetch signal, fired once per approach with hysteresis (re-arms past 1.5 viewports, which appending a batch causes by growing the extent). A programmatic jump to the end fires once and NEVER re-arms while the offset stays near the end — re-arming needs a post-scroll observation at least 1.5 viewports from it.
|
|
479
479
|
|
|
480
480
|
Scroll offsets follow the same mirror discipline as text: the Msg carries the offset the runtime ALREADY applied, so store it in the model and echo it back through the scroll's `value` — the echoed source value equals the runtime offset, which the scroll reconcile rule treats as "unchanged", so rebuilds never stomp live scrolling. `on-scroll` is how long content pages or lazy-loads: keep a bounded window in the model and slide it from `offset` (near-end when `offset + viewport_extent` approaches `content_extent`).
|
|
481
481
|
|
|
@@ -483,7 +483,7 @@ Scroll offsets follow the same mirror discipline as text: the Msg carries the of
|
|
|
483
483
|
|
|
484
484
|
A handler or update error DEGRADES, it does not exit the app: dispatch catches it, records it in a bounded ring (`runtime.dispatchErrors()`, the `error event=... name=...` lines and `dispatch_errors=` count in automation snapshots, and a `dispatch.error` trace record at error level), and the app keeps running. Trace-sink capacity failures likewise never fail dispatch — dropped records are counted (`dropped_trace_records=`), not fatal. Design for it: an arm that can fail should still surface its own status in the model; the error ring is the safety net, not the UX.
|
|
485
485
|
|
|
486
|
-
Presses follow ONE rule: a click lands on the nearest pressable widget under the pointer — plain text, icons, images, badges, and layout containers let it fall through to their closest pressable ancestor, and dragging still selects text. "Pressable" means an interactive kind (button, checkbox, list-item, ...) or ANY element with a bound `on-press`/`on-toggle` — the handler itself makes the element a hit target, so a pressable row is just `<panel on-press="open:{id}">` (or `<row on-press=...>`, `ui.row(.{ .on_press = ... })`) with plain text children: no empty-text overlays, no duplicating the handler onto every text leaf. Nested pressables resolve to the deepest one (a button inside a pressable row wins over the row); editable text fields, scroll containers, and modal surfaces (dialog, drawer, sheet, popover, menus) always claim their own presses, so a click in a field inside a pressable row places the caret instead of activating the row. The value/text handlers (`on-change`, `on-submit`, `on-input`) still only belong on controls — both engines and `markup check` reject them on layout/decoration elements with a teaching error.
|
|
486
|
+
Presses follow ONE rule: a click lands on the nearest pressable widget under the pointer — plain text, icons, images, badges, and layout containers let it fall through to their closest pressable ancestor, and dragging still selects text. "Pressable" means an interactive kind (button, checkbox, list-item, ...) or ANY element with a bound `on-press`/`on-double-press`/`on-toggle` — the handler itself makes the element a hit target, so a pressable row is just `<panel on-press="open:{id}">` (or `<row on-press=...>`, `ui.row(.{ .on_press = ... })`) with plain text children: no empty-text overlays, no duplicating the handler onto every text leaf. Nested pressables resolve to the deepest one (a button inside a pressable row wins over the row); editable text fields, scroll containers, and modal surfaces (dialog, drawer, sheet, popover, menus) always claim their own presses, so a click in a field inside a pressable row places the caret instead of activating the row. The value/text handlers (`on-change`, `on-submit`, `on-input`) still only belong on controls — both engines and `markup check` reject them on layout/decoration elements with a teaching error.
|
|
487
487
|
|
|
488
488
|
### Keys: quiet list rows and the app-level fallback
|
|
489
489
|
|
|
@@ -970,17 +970,21 @@ Both engines implement templates, defaults, slots, and imports: the interpreter
|
|
|
970
970
|
|
|
971
971
|
## Code in markup: `<code>`
|
|
972
972
|
|
|
973
|
-
|
|
973
|
+
Bare source-bound highlighted content shared with Markdown fences:
|
|
974
974
|
|
|
975
975
|
```html
|
|
976
976
|
<code source="{snippet}" language="tsx" line-numbers wrap="false" width="480" label="Component source" />
|
|
977
|
+
<code source="{migration}" language="javascript" line-numbers added-lines="5" removed-lines="2-4" wrap="false" width="480" label="Configuration migration" />
|
|
977
978
|
```
|
|
978
979
|
|
|
979
980
|
- `source` is one required `{binding}` producing `[]const u8`; the element has no children.
|
|
980
981
|
- `language` is a literal lexer name: Zig, JS/TS, JSX/TSX, JSON, shell, Python, Rust, C-family, Go, HTML/XML/SVG, CSS-family, or SQL. Omit it for plain monospace.
|
|
982
|
+
- The component owns highlighting, line numbers, clipping, and scrolling, but no background, border, radius, shadow, or padding. Compose those choices outside it, for example `<panel padding="12"><code source="{snippet}" language="tsx" /></panel>`.
|
|
983
|
+
- Code is selectable/read-only by default. Add `editable on-input="edit"` to use the multiline editor path; the message carries `canvas.TextInputEvent`, so apply it to the same model-owned `TextBuffer` that supplies `source`. Editing retains syntax highlighting and does not add textarea chrome.
|
|
981
984
|
- Wrapping is on by default. `wrap="false"` keeps logical lines intact inside one horizontal scroll region. A definite `height` makes overflow scroll vertically; with wrapping off, that constrained region scrolls on both axes.
|
|
982
985
|
- `line-numbers` is off by default. Wrapped logical lines stay paired with their number. Numbered mode is limited to 128 logical lines and a reserved share of the per-view node and text-span budgets; sources that exceed any bound preserve all code and omit the gutter.
|
|
983
|
-
-
|
|
986
|
+
- `added-lines` and `removed-lines` take one-based comma lists/inclusive ranges up to line 128 (`"2-4, 7"`) or one text binding in that form. They apply Geist's full-width green/red washes and renderer-owned `+`/`-`; the markers never enter source, selection, editing, or clipboard bytes. A line cannot be both added and removed. Read-only sources longer than 128 lines preserve all code and omit diff decoration.
|
|
987
|
+
- Zig builder: `ui.code(.{ .language = .html, .editable = true, .on_input = Ui.inputMsg(.edit), .line_numbers = true, .added_lines = &.{5}, .removed_lines = &.{ 2, 3, 4 }, .wrap = false }, model.snippet)`. Omit `editable`/`on_input` for read-only code. The public lexer helpers are under `native_sdk.canvas.code`.
|
|
984
988
|
|
|
985
989
|
## Markdown in markup: `<markdown>`
|
|
986
990
|
|
|
@@ -1138,7 +1142,7 @@ Two `msgForPointer` traps: a **disabled** control yields `null` (assert `== null
|
|
|
1138
1142
|
|
|
1139
1143
|
One widget-field trap: there is no `Widget.enabled` — enabled-ness is spelled `widget.state.disabled` (a `bool`, disabled-positive), so a test asserts `try testing.expect(!button.state.disabled);` for an enabled control and `try testing.expect(save.state.disabled);` for a disabled one.
|
|
1140
1144
|
|
|
1141
|
-
`msgForPointer` has a sibling for every handler channel — use the one matching the interaction under test, all on the finalized `Tree`: `msgForKeyboard(id, keyboard_event)` (activation keys, slider steps, enter-to-submit, text edits), `msgForResize(id, fraction)` (the split-divider round-trip: dispatch the fraction, assert the model stored it, rebuild, assert the `value` echo), `msgForDismiss(id)` (an anchored surface's `on-dismiss`), `msgForHold(id)` (`on-hold`), `msgForTextEdit(id, edit)` (text entry), `msgForValue(id, value)` (BUILDER views only — it fires the `on_value` constructor, so it returns null for a markup slider; a markup slider binds a plain `on-change`, so assert its dispatch with `msgFor(id, .change)` — the accessibility set-value intent falls back to the same handler), `msgForScroll(id, state)`, and `msgForContextMenu(id, item_index)`. For tree keyboard NAVIGATION there is nothing app-side to unit test: Up/Down/Left/Right/Home/End run engine-side over `role="treeitem"` rows and dispatch the landed row's `on-press`/`on-toggle` — assert those Msgs (via `msgForPointer`/`msgFor(id, .toggle)`) and the model transitions; the keymap itself is runtime behavior (drive it live with `native automate widget-key`).
|
|
1145
|
+
`msgForPointer` has a sibling for every handler channel — use the one matching the interaction under test, all on the finalized `Tree`: `msgForPointerClick(id, .up, click_count)` (double-click resolution: the second release prefers `on-double-press`), `msgForKeyboard(id, keyboard_event)` (activation keys, slider steps, enter-to-submit, text edits), `msgForResize(id, fraction)` (the split-divider round-trip: dispatch the fraction, assert the model stored it, rebuild, assert the `value` echo), `msgForDismiss(id)` (an anchored surface's `on-dismiss`), `msgForHold(id)` (`on-hold`), `msgForTextEdit(id, edit)` (text entry), `msgForValue(id, value)` (BUILDER views only — it fires the `on_value` constructor, so it returns null for a markup slider; a markup slider binds a plain `on-change`, so assert its dispatch with `msgFor(id, .change)` — the accessibility set-value intent falls back to the same handler), `msgForScroll(id, state)`, and `msgForContextMenu(id, item_index)`. For tree keyboard NAVIGATION there is nothing app-side to unit test: Up/Down/Left/Right/Home/End run engine-side over `role="treeitem"` rows and dispatch the landed row's `on-press`/`on-toggle` — assert those Msgs (via `msgForPointer`/`msgFor(id, .toggle)`) and the model transitions; the keymap itself is runtime behavior (drive it live with `native automate widget-key`).
|
|
1142
1146
|
|
|
1143
1147
|
Runtime-integration tests use `native_sdk.TestHarness()` on the null platform; heap-allocate both the harness and the app struct (they are multi-megabyte; stack allocation crashes).
|
|
1144
1148
|
|
|
@@ -2958,7 +2958,7 @@ static NSRect NativeSdkPacketAlignRectToPixels(NSRect rect, CGFloat scale, NSUIn
|
|
|
2958
2958
|
}
|
|
2959
2959
|
|
|
2960
2960
|
/* ---------------------------------------------------------------------------
|
|
2961
|
-
* Compact binary gpu-surface packet decoding (wire format
|
|
2961
|
+
* Compact binary gpu-surface packet decoding (wire format v5).
|
|
2962
2962
|
*
|
|
2963
2963
|
* Little-endian, length-prefixed, mirror of the engine's binary packet
|
|
2964
2964
|
* encoder (serialization.zig, `writeCanvasGpuPacketBinary` and the patch
|
|
@@ -2973,7 +2973,8 @@ static NSRect NativeSdkPacketAlignRectToPixels(NSRect rect, CGFloat scale, NSUIn
|
|
|
2973
2973
|
* keyed upserts + the full draw-order vector) against the view's retained
|
|
2974
2974
|
* command dictionary; v3 added the flag-gated dirty rect list after the
|
|
2975
2975
|
* scissor; v4 added the per-command stroke end-cap code after
|
|
2976
|
-
* stroke_width
|
|
2976
|
+
* stroke_width; v5 added compact positioned glyph runs after text UTF-8.
|
|
2977
|
+
* The version this comment names and the encoder's spec
|
|
2977
2978
|
* comment must agree with `binary_packet_version` (serialization.zig);
|
|
2978
2979
|
* the `test-wire-format-version-prose` build check pins all three.
|
|
2979
2980
|
*/
|
|
@@ -3005,6 +3006,14 @@ static uint8_t NativeSdkBinaryReadU8(NativeSdkBinaryPacketReader *reader) {
|
|
|
3005
3006
|
return reader->bytes[reader->offset++];
|
|
3006
3007
|
}
|
|
3007
3008
|
|
|
3009
|
+
static uint16_t NativeSdkBinaryReadU16(NativeSdkBinaryPacketReader *reader) {
|
|
3010
|
+
if (!NativeSdkBinaryHasBytes(reader, 2)) return 0;
|
|
3011
|
+
uint16_t value = 0;
|
|
3012
|
+
memcpy(&value, reader->bytes + reader->offset, 2);
|
|
3013
|
+
reader->offset += 2;
|
|
3014
|
+
return CFSwapInt16LittleToHost(value);
|
|
3015
|
+
}
|
|
3016
|
+
|
|
3008
3017
|
static uint32_t NativeSdkBinaryReadU32(NativeSdkBinaryPacketReader *reader) {
|
|
3009
3018
|
if (!NativeSdkBinaryHasBytes(reader, 4)) return 0;
|
|
3010
3019
|
uint32_t value = 0;
|
|
@@ -3209,6 +3218,45 @@ static NSDictionary *NativeSdkBinaryReadText(NativeSdkBinaryPacketReader *reader
|
|
|
3209
3218
|
@"color" : color,
|
|
3210
3219
|
@"text" : text,
|
|
3211
3220
|
}];
|
|
3221
|
+
uint8_t hasPositionedGlyphs = NativeSdkBinaryReadU8(reader);
|
|
3222
|
+
if (reader->failed) return nil;
|
|
3223
|
+
if (hasPositionedGlyphs) {
|
|
3224
|
+
uint32_t glyphCount = NativeSdkBinaryReadU32(reader);
|
|
3225
|
+
if (reader->failed || glyphCount > 65536 || glyphCount > (reader->length - reader->offset) / 15) {
|
|
3226
|
+
reader->failed = YES;
|
|
3227
|
+
return nil;
|
|
3228
|
+
}
|
|
3229
|
+
NSMutableArray *glyphs = [NSMutableArray arrayWithCapacity:glyphCount];
|
|
3230
|
+
for (uint32_t index = 0; index < glyphCount; index++) {
|
|
3231
|
+
uint16_t glyphId = NativeSdkBinaryReadU16(reader);
|
|
3232
|
+
uint8_t flags = NativeSdkBinaryReadU8(reader);
|
|
3233
|
+
if (flags > 1) {
|
|
3234
|
+
reader->failed = YES;
|
|
3235
|
+
return nil;
|
|
3236
|
+
}
|
|
3237
|
+
uint64_t glyphFontId = (flags & 1) != 0 ? NativeSdkBinaryReadU64(reader) : fontId;
|
|
3238
|
+
NSNumber *x = NativeSdkBinaryReadF32Number(reader);
|
|
3239
|
+
NSNumber *baseline = NativeSdkBinaryReadF32Number(reader);
|
|
3240
|
+
NSNumber *advance = NativeSdkBinaryReadF32Number(reader);
|
|
3241
|
+
if (reader->failed) return nil;
|
|
3242
|
+
[glyphs addObject:@{ @"id" : @(glyphId), @"font" : @(glyphFontId), @"x" : x, @"baseline" : baseline, @"advance" : advance }];
|
|
3243
|
+
}
|
|
3244
|
+
uint32_t fragmentCount = NativeSdkBinaryReadU32(reader);
|
|
3245
|
+
if (reader->failed || fragmentCount > 64 || fragmentCount > (reader->length - reader->offset) / 12) {
|
|
3246
|
+
reader->failed = YES;
|
|
3247
|
+
return nil;
|
|
3248
|
+
}
|
|
3249
|
+
NSMutableArray *fragments = [NSMutableArray arrayWithCapacity:fragmentCount];
|
|
3250
|
+
for (uint32_t index = 0; index < fragmentCount; index++) {
|
|
3251
|
+
NSNumber *x = NativeSdkBinaryReadF32Number(reader);
|
|
3252
|
+
NSNumber *baseline = NativeSdkBinaryReadF32Number(reader);
|
|
3253
|
+
NSString *fragmentText = NativeSdkBinaryReadString(reader);
|
|
3254
|
+
if (reader->failed || !fragmentText) return nil;
|
|
3255
|
+
[fragments addObject:@{ @"x" : x, @"baseline" : baseline, @"text" : fragmentText }];
|
|
3256
|
+
}
|
|
3257
|
+
result[@"positionedGlyphs"] = glyphs;
|
|
3258
|
+
result[@"positionedFragments"] = fragments;
|
|
3259
|
+
}
|
|
3212
3260
|
uint8_t hasLayout = NativeSdkBinaryReadU8(reader);
|
|
3213
3261
|
if (reader->failed) return nil;
|
|
3214
3262
|
if (!hasLayout) return result;
|
|
@@ -3358,7 +3406,7 @@ static NSDictionary *NativeSdkPacketDictionaryFromBinary(const uint8_t *bytes, N
|
|
|
3358
3406
|
if (memcmp(bytes, "NSGP", 4) != 0) return nil;
|
|
3359
3407
|
reader.offset = 4;
|
|
3360
3408
|
uint8_t version = NativeSdkBinaryReadU8(&reader);
|
|
3361
|
-
if (version !=
|
|
3409
|
+
if (version != 5) return nil;
|
|
3362
3410
|
uint8_t loadActionCode = NativeSdkBinaryReadU8(&reader);
|
|
3363
3411
|
uint8_t packetFlags = NativeSdkBinaryReadU8(&reader);
|
|
3364
3412
|
(void)NativeSdkBinaryReadU8(&reader); /* reserved */
|
|
@@ -7352,6 +7400,30 @@ static BOOL NativeSdkScrollDriverCanConsumeHorizontally(NativeSdkScrollDriverVie
|
|
|
7352
7400
|
}
|
|
7353
7401
|
if (!restoreFrame) {
|
|
7354
7402
|
[window center];
|
|
7403
|
+
// AppKit centers every new window by default, which leaves a
|
|
7404
|
+
// model-declared secondary window exactly covering the editor that
|
|
7405
|
+
// opened it. Cascade from the active window like Win32's default
|
|
7406
|
+
// placement so repeated Command+N windows stay visibly distinct.
|
|
7407
|
+
NSWindow *referenceWindow = NSApp.keyWindow ?: self.window;
|
|
7408
|
+
if (!makeMain && referenceWindow) {
|
|
7409
|
+
NSRect referenceFrame = referenceWindow.frame;
|
|
7410
|
+
NSRect cascadedFrame = window.frame;
|
|
7411
|
+
cascadedFrame.origin.x = NSMinX(referenceFrame) + 24.0;
|
|
7412
|
+
cascadedFrame.origin.y = NSMaxY(referenceFrame) - 24.0 - NSHeight(cascadedFrame);
|
|
7413
|
+
|
|
7414
|
+
// A maximized or edge-positioned reference must not push the new
|
|
7415
|
+
// window beyond the usable screen. Fit the complete frame when
|
|
7416
|
+
// possible; an oversized window keeps its leading/bottom edge.
|
|
7417
|
+
NSScreen *referenceScreen = referenceWindow.screen ?: window.screen ?: NSScreen.mainScreen;
|
|
7418
|
+
if (referenceScreen) {
|
|
7419
|
+
NSRect visibleFrame = referenceScreen.visibleFrame;
|
|
7420
|
+
CGFloat maxOriginX = MAX(NSMinX(visibleFrame), NSMaxX(visibleFrame) - NSWidth(cascadedFrame));
|
|
7421
|
+
CGFloat maxOriginY = MAX(NSMinY(visibleFrame), NSMaxY(visibleFrame) - NSHeight(cascadedFrame));
|
|
7422
|
+
cascadedFrame.origin.x = MIN(MAX(NSMinX(cascadedFrame), NSMinX(visibleFrame)), maxOriginX);
|
|
7423
|
+
cascadedFrame.origin.y = MIN(MAX(NSMinY(cascadedFrame), NSMinY(visibleFrame)), maxOriginY);
|
|
7424
|
+
}
|
|
7425
|
+
[window setFrame:cascadedFrame display:NO];
|
|
7426
|
+
}
|
|
7355
7427
|
}
|
|
7356
7428
|
if (makeMain) NativeSdkLaunchLap("window_chrome_ready");
|
|
7357
7429
|
|
|
@@ -12243,7 +12315,7 @@ native_sdk_appkit_open_dialog_result_t native_sdk_appkit_show_open_dialog(native
|
|
|
12243
12315
|
NSString *path = [[NSString alloc] initWithBytes:opts->default_path length:opts->default_path_len encoding:NSUTF8StringEncoding];
|
|
12244
12316
|
panel.directoryURL = [NSURL fileURLWithPath:path];
|
|
12245
12317
|
}
|
|
12246
|
-
panel.canChooseFiles =
|
|
12318
|
+
panel.canChooseFiles = opts->allow_directories == 0;
|
|
12247
12319
|
panel.canChooseDirectories = opts->allow_directories != 0;
|
|
12248
12320
|
panel.allowsMultipleSelection = opts->allow_multiple != 0;
|
|
12249
12321
|
NativeSdkConfigurePanelExtensions(panel, NativeSdkParseExtensions(opts->extensions, opts->extensions_len));
|
|
@@ -946,7 +946,29 @@ static const char *NativeSdkCefBridgeScript() {
|
|
|
946
946
|
if ((windowFlags & (1u << 2)) != 0) window.ignoresMouseEvents = YES;
|
|
947
947
|
if ((windowFlags & (1u << 3)) != 0) [self.passiveShowWindows addObject:key];
|
|
948
948
|
[window setTitle:title.length > 0 ? title : @"native-sdk"];
|
|
949
|
-
if (!restoreFrame)
|
|
949
|
+
if (!restoreFrame) {
|
|
950
|
+
[window center];
|
|
951
|
+
// Match the system-WebView host and Win32's default placement:
|
|
952
|
+
// secondary windows should reveal the window that opened them,
|
|
953
|
+
// not land directly on top of it.
|
|
954
|
+
NSWindow *referenceWindow = NSApp.keyWindow ?: self.window;
|
|
955
|
+
if (!makeMain && referenceWindow) {
|
|
956
|
+
NSRect referenceFrame = referenceWindow.frame;
|
|
957
|
+
NSRect cascadedFrame = window.frame;
|
|
958
|
+
cascadedFrame.origin.x = NSMinX(referenceFrame) + 24.0;
|
|
959
|
+
cascadedFrame.origin.y = NSMaxY(referenceFrame) - 24.0 - NSHeight(cascadedFrame);
|
|
960
|
+
|
|
961
|
+
NSScreen *referenceScreen = referenceWindow.screen ?: window.screen ?: NSScreen.mainScreen;
|
|
962
|
+
if (referenceScreen) {
|
|
963
|
+
NSRect visibleFrame = referenceScreen.visibleFrame;
|
|
964
|
+
CGFloat maxOriginX = MAX(NSMinX(visibleFrame), NSMaxX(visibleFrame) - NSWidth(cascadedFrame));
|
|
965
|
+
CGFloat maxOriginY = MAX(NSMinY(visibleFrame), NSMaxY(visibleFrame) - NSHeight(cascadedFrame));
|
|
966
|
+
cascadedFrame.origin.x = MIN(MAX(NSMinX(cascadedFrame), NSMinX(visibleFrame)), maxOriginX);
|
|
967
|
+
cascadedFrame.origin.y = MIN(MAX(NSMinY(cascadedFrame), NSMinY(visibleFrame)), maxOriginY);
|
|
968
|
+
}
|
|
969
|
+
[window setFrame:cascadedFrame display:NO];
|
|
970
|
+
}
|
|
971
|
+
}
|
|
950
972
|
|
|
951
973
|
NSView *stackRoot = [[NSView alloc] initWithFrame:NSMakeRect(0, 0, width, height)];
|
|
952
974
|
stackRoot.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
|
|
@@ -3128,7 +3150,7 @@ native_sdk_appkit_open_dialog_result_t native_sdk_appkit_show_open_dialog(native
|
|
|
3128
3150
|
NSString *path = [[NSString alloc] initWithBytes:opts->default_path length:opts->default_path_len encoding:NSUTF8StringEncoding];
|
|
3129
3151
|
panel.directoryURL = [NSURL fileURLWithPath:path];
|
|
3130
3152
|
}
|
|
3131
|
-
panel.canChooseFiles =
|
|
3153
|
+
panel.canChooseFiles = opts->allow_directories == 0;
|
|
3132
3154
|
panel.canChooseDirectories = opts->allow_directories != 0;
|
|
3133
3155
|
panel.allowsMultipleSelection = opts->allow_multiple != 0;
|
|
3134
3156
|
NativeSdkConfigurePanelExtensions(panel, NativeSdkParseExtensions(opts->extensions, opts->extensions_len));
|
|
@@ -2471,6 +2471,19 @@ test "mac active implicit show activates before making the window key" {
|
|
|
2471
2471
|
) != null);
|
|
2472
2472
|
}
|
|
2473
2473
|
|
|
2474
|
+
test "mac unrestored secondary windows cascade within the active screen" {
|
|
2475
|
+
for ([_][]const u8{ @embedFile("appkit_host.m"), @embedFile("cef_host.mm") }) |host_source| {
|
|
2476
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "NSWindow *referenceWindow = NSApp.keyWindow ?: self.window;") != null);
|
|
2477
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "NSMinX(referenceFrame) + 24.0") != null);
|
|
2478
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "NSMaxY(referenceFrame) - 24.0") != null);
|
|
2479
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "if (!makeMain && referenceWindow)") != null);
|
|
2480
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "NSRect visibleFrame = referenceScreen.visibleFrame;") != null);
|
|
2481
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "NSMaxX(visibleFrame) - NSWidth(cascadedFrame)") != null);
|
|
2482
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "NSMaxY(visibleFrame) - NSHeight(cascadedFrame)") != null);
|
|
2483
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "[window setFrame:cascadedFrame display:NO]") != null);
|
|
2484
|
+
}
|
|
2485
|
+
}
|
|
2486
|
+
|
|
2474
2487
|
test "mac explicit focus activates before making the window key" {
|
|
2475
2488
|
const host_source = @embedFile("appkit_host.m");
|
|
2476
2489
|
try std.testing.expect(std.mem.indexOf(u8, host_source,
|
package/src/platform/types.zig
CHANGED
|
@@ -766,6 +766,10 @@ pub const ViewKind = enum {
|
|
|
766
766
|
pub const GpuSurfaceBackend = enum {
|
|
767
767
|
none,
|
|
768
768
|
metal,
|
|
769
|
+
/// Direct2D retained rendering on Windows. The application-facing
|
|
770
|
+
/// backend request remains portable; frame events report the concrete
|
|
771
|
+
/// renderer that actually completed the present.
|
|
772
|
+
direct2d,
|
|
769
773
|
/// CPU rasterization (reference renderer) presented through the
|
|
770
774
|
/// platform's pixel blit path. Platforms without a GPU packet renderer
|
|
771
775
|
/// (Linux/GTK) report this backend in their frame events; manifests
|