@native-sdk/cli 0.8.3 → 0.9.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 +905 -61
- package/build.zig +674 -373
- package/build.zig.zon +1 -0
- package/native-sdk.d.ts +6 -0
- package/package.json +12 -11
- package/packages/core/compile-surface/core.ts +455 -3
- package/packages/core/package-lock.json +11 -11
- package/packages/core/package.json +2 -2
- package/packages/core/scripts/compiler_typecheck.mjs +116 -15
- package/packages/core/scripts/gen_service_surface.mjs +268 -0
- package/packages/core/scripts/npm_static_spike.mjs +64 -0
- package/packages/core/scripts/run_external_core_compiler.mjs +77 -6
- package/packages/core/scripts/run_external_service_compiler.mjs +240 -0
- package/packages/core/scripts/stage_external_core.mjs +9 -1
- package/packages/core/scripts/stage_external_services.mjs +172 -0
- package/packages/core/scripts/surface_manifest_diff.mjs +253 -0
- package/packages/core/scripts/vendor_service_packages.mjs +189 -0
- package/packages/core/sdk/core.d.ts +214 -2
- package/packages/core/sdk/core.ts +715 -42
- package/packages/core/sdk/events.d.ts +50 -0
- package/packages/core/sdk/events.ts +75 -0
- package/packages/core/src/checker.ts +528 -15
- package/packages/core/src/cli.ts +143 -3
- package/packages/core/src/contract.ts +26 -5
- package/packages/core/src/devhost.ts +1849 -18
- package/packages/core/src/devhost_journal.mjs +181 -0
- package/packages/core/src/devhost_resolver.mjs +17 -1
- package/packages/core/src/devhost_service_worker.mjs +90 -0
- package/packages/core/src/diagnostics.ts +84 -18
- package/packages/core/src/frontend.ts +204 -34
- package/packages/core/src/modules.ts +129 -80
- package/packages/core/src/service_contract.ts +597 -0
- package/packages/core/src/sqlite_cli.ts +93 -0
- package/packages/core/src/sqlite_codegen.ts +806 -0
- package/packages/core/src/sqlite_runtime_policy.ts +364 -0
- package/packages/core/src/typed_ast.ts +36 -8
- package/skill-data/core/SKILL.md +4 -2
- package/skill-data/core/references/project-anatomy.md +3 -2
- package/skill-data/core/references/web-engines-packaging-debugging.md +3 -1
- package/skill-data/native-ui/SKILL.md +55 -8
- package/skill-data/ts-core/SKILL.md +92 -40
- package/skill-data/ts-services/SKILL.md +126 -0
- package/skill-data/ts-services/references/service-surface.md +603 -0
- package/skill-data/zig/SKILL.md +1 -1
- package/skills/native-sdk/SKILL.md +1 -1
- package/src/app_runner/no_migrations.zig +3 -0
- package/src/app_runner/no_services.zig +20 -0
- package/src/app_runner/root.zig +104 -4
- package/src/app_runner/ts_core_main.zig +268 -4
- package/src/automation/snapshot.zig +23 -5
- package/src/embed/app_exports.zig +11 -1
- package/src/embed/c_api.zig +48 -2
- package/src/embed/conversions.zig +4 -5
- package/src/embed/host.zig +115 -1
- package/src/embed/root.zig +7 -0
- package/src/embed/tests.zig +213 -0
- package/src/embed/types.zig +51 -0
- package/src/embed/ui_host.zig +121 -5
- package/src/platform/android/NativeSdkActivity.java +131 -0
- package/src/platform/android/android_host.c +182 -1
- package/src/platform/android/native_sdk_app.h +17 -0
- package/src/platform/ios/native_sdk_app.h +17 -0
- package/src/platform/ios/uikit_host.m +115 -0
- package/src/platform/linux/cef_host.cpp +1 -1
- package/src/platform/linux/gtk_host.c +89 -17
- package/src/platform/linux/gtk_host.h +3 -0
- package/src/platform/linux/root.zig +41 -18
- package/src/platform/macos/appkit_host.h +26 -3
- package/src/platform/macos/appkit_host.m +1051 -129
- package/src/platform/macos/capture_info_plist.c +25 -0
- package/src/platform/macos/cef_host.mm +270 -36
- package/src/platform/macos/root.zig +312 -34
- package/src/platform/null_platform.zig +281 -19
- package/src/platform/null_platform_tests.zig +74 -0
- package/src/platform/root.zig +16 -0
- package/src/platform/types.zig +279 -15
- package/src/platform/windows/root.zig +243 -21
- package/src/platform/windows/webview2_host.cpp +464 -46
- package/src/primitives/app_manifest/comptime_scene.zig +2 -0
- package/src/primitives/app_manifest/root.zig +4 -0
- package/src/primitives/app_manifest/tests.zig +3 -0
- package/src/primitives/app_manifest/types.zig +34 -0
- package/src/primitives/app_manifest/validation.zig +19 -1
- package/src/primitives/canvas/code_tests.zig +9 -9
- package/src/primitives/canvas/events.zig +12 -11
- package/src/primitives/canvas/frame.zig +44 -9
- package/src/primitives/canvas/icons/mic.svg +1 -0
- package/src/primitives/canvas/icons.zig +2 -0
- package/src/primitives/canvas/root.zig +8 -0
- package/src/primitives/canvas/text_span_tests.zig +39 -0
- package/src/primitives/canvas/ui.zig +23 -4
- package/src/primitives/canvas/ui_markup.zig +15 -0
- package/src/primitives/canvas/ui_markup_compiled.zig +9 -0
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +1 -1
- package/src/primitives/canvas/ui_markup_tests.zig +5 -0
- package/src/primitives/canvas/ui_markup_view.zig +9 -0
- package/src/primitives/canvas/ui_markup_view_tests.zig +9 -6
- package/src/primitives/canvas/ui_schema.zig +19 -10
- package/src/primitives/canvas/ui_schema_tests.zig +5 -3
- package/src/primitives/canvas/ui_tests.zig +18 -4
- package/src/primitives/canvas/widget_invalidation.zig +9 -2
- package/src/primitives/canvas/widget_render.zig +296 -114
- package/src/primitives/canvas/widget_runtime_tests.zig +133 -0
- package/src/primitives/canvas/widget_text_input.zig +10 -10
- package/src/primitives/canvas/widget_tree.zig +1 -1
- package/src/primitives/canvas/widgets.zig +29 -5
- package/src/root.zig +56 -0
- package/src/runtime/api.zig +11 -0
- package/src/runtime/automation_snapshot.zig +4 -0
- package/src/runtime/automation_widget_dispatch.zig +1 -0
- package/src/runtime/bridge_payload.zig +2 -0
- package/src/runtime/bridge_permission_tests.zig +23 -2
- package/src/runtime/bridge_responses.zig +3 -1
- package/src/runtime/canvas_frame.zig +31 -13
- package/src/runtime/canvas_frame_animation_tests.zig +4 -0
- package/src/runtime/canvas_frame_invalidation_tests.zig +35 -10
- package/src/runtime/canvas_widget_anchored_tests.zig +83 -0
- package/src/runtime/canvas_widget_events.zig +69 -24
- package/src/runtime/canvas_widget_runtime.zig +101 -6
- package/src/runtime/canvas_widget_scroll_driver_tests.zig +47 -4
- package/src/runtime/canvas_widget_scroll_drivers.zig +3 -3
- package/src/runtime/canvas_widget_semantics_tests.zig +2 -0
- package/src/runtime/canvas_widget_split_tree_tests.zig +228 -0
- package/src/runtime/canvas_widget_state.zig +6 -1
- package/src/runtime/canvas_widget_text_tests.zig +112 -3
- package/src/runtime/clock.zig +13 -1
- package/src/runtime/core.zig +133 -1
- package/src/runtime/credentials_store.zig +115 -0
- package/src/runtime/effects.zig +2568 -75
- package/src/runtime/effects_audio_capture_tests.zig +251 -0
- package/src/runtime/effects_credentials_tests.zig +332 -0
- package/src/runtime/effects_host_tests.zig +208 -1
- package/src/runtime/effects_relational_tests.zig +314 -0
- package/src/runtime/effects_store_tests.zig +211 -0
- package/src/runtime/flow.zig +14 -1
- package/src/runtime/gpu_surface_events.zig +6 -1
- package/src/runtime/native_command_event_tests.zig +42 -0
- package/src/runtime/persist_store.zig +666 -0
- package/src/runtime/record_store.zig +788 -0
- package/src/runtime/relational_store.zig +854 -0
- package/src/runtime/root.zig +52 -0
- package/src/runtime/runtime_event_tests.zig +70 -0
- package/src/runtime/service_host.zig +711 -0
- package/src/runtime/service_pool.zig +1314 -0
- package/src/runtime/session_blobs.zig +1 -1
- package/src/runtime/session_journal.zig +102 -0
- package/src/runtime/session_record.zig +177 -0
- package/src/runtime/session_replay.zig +109 -4
- package/src/runtime/shell_layout.zig +1 -0
- package/src/runtime/shell_layout_tests.zig +120 -0
- package/src/runtime/sqlite_engine.zig +474 -0
- package/src/runtime/state.zig +6 -0
- package/src/runtime/system_services.zig +49 -10
- package/src/runtime/tests.zig +5 -0
- package/src/runtime/ts_core_host.zig +1189 -118
- package/src/runtime/ts_core_host_tests.zig +638 -11
- package/src/runtime/ts_ui_app.zig +537 -1
- package/src/runtime/ui_app.zig +160 -19
- package/src/runtime/ui_app_tests.zig +203 -5
- package/src/runtime/validation.zig +22 -0
- package/src/runtime/view.zig +11 -0
- package/src/runtime/view_widget_scroll.zig +56 -5
- package/src/runtime/view_widget_text.zig +24 -5
- package/src/runtime/view_widget_tree.zig +1 -1
- package/src/runtime/window_storage.zig +1 -0
- package/src/runtime/window_view_runtime.zig +2 -3
- package/src/runtime/window_views.zig +19 -0
- package/src/tooling/android.zig +21 -16
- package/src/tooling/db.zig +160 -0
- package/src/tooling/ios.zig +7 -1
- package/src/tooling/manifest.zig +1248 -2
- package/src/tooling/package.zig +953 -6
- package/src/tooling/raw_manifest.zig +65 -0
- package/src/tooling/root.zig +1 -0
- package/src/tooling/templates.zig +216 -4
- package/src/tooling/ts_core.zig +283 -17
- package/src/tooling/verbs.zig +7 -0
- package/third_party/sqlite/README.md +13 -0
- package/third_party/sqlite/sqlite3.c +269649 -0
- package/third_party/sqlite/sqlite3.h +14349 -0
- package/tools/corewire/core_abi.zig +14 -2
- package/tools/corewire/emit.zig +98 -29
- package/tools/corewire/emit_facade.zig +414 -23
- package/tools/corewire/emit_profile.zig +6 -2
- package/tools/corewire/emit_service.zig +924 -0
- package/tools/corewire/main.zig +122 -0
- package/tools/corewire/service_contract.zig +250 -0
- package/tools/corewire/sidecar.zig +26 -15
|
@@ -206,6 +206,9 @@ fn emitWidgetLayoutDragPreview(builder: *Builder, layout: anytype, tokens: Desig
|
|
|
206
206
|
|
|
207
207
|
var preview_state = WidgetRenderState{
|
|
208
208
|
.rendering_drag_preview = true,
|
|
209
|
+
.drag_preview_id = source_id,
|
|
210
|
+
.drag_preview_origin = state.drag_preview_origin,
|
|
211
|
+
.drag_preview_offset = state.drag_preview_offset,
|
|
209
212
|
};
|
|
210
213
|
// Keep disclosure content in the preview in the same visible phase as
|
|
211
214
|
// the standing tree, while dropping focus/hover/press chrome from the
|
|
@@ -215,18 +218,31 @@ fn emitWidgetLayoutDragPreview(builder: *Builder, layout: anytype, tokens: Desig
|
|
|
215
218
|
const ancestor_transform = widgetLayoutNodeAncestorEmissionTransform(layout, source_index) orelse return error.InvalidTransform;
|
|
216
219
|
const wrap_ancestor_transform = !affinesEqual(ancestor_transform, Affine.identity());
|
|
217
220
|
const inverse_ancestor_transform = if (wrap_ancestor_transform) ancestor_transform.inverse() orelse return error.InvalidTransform else Affine.identity();
|
|
218
|
-
const
|
|
219
|
-
const current_origin = ancestor_transform.transformPoint(geometry.PointF.init(current_frame.x, current_frame.y));
|
|
220
|
-
const source_layout_origin = state.drag_preview_origin orelse geometry.PointF.init(current_frame.x, current_frame.y);
|
|
221
|
-
const source_origin = ancestor_transform.transformPoint(source_layout_origin);
|
|
222
|
-
const translate_x = source_origin.x + state.drag_preview_offset.dx - current_origin.x;
|
|
223
|
-
const translate_y = source_origin.y + state.drag_preview_offset.dy - current_origin.y;
|
|
224
|
-
const translation = Affine.translate(translate_x, translate_y);
|
|
221
|
+
const translation = widgetLayoutDragPreviewTranslation(layout, source_index, state, ancestor_transform);
|
|
225
222
|
try builder.transform(translation);
|
|
226
223
|
if (wrap_ancestor_transform) try builder.transform(ancestor_transform);
|
|
227
224
|
try emitWidgetLayoutNode(builder, layout, source_index, tokens, preview_state, .none);
|
|
228
225
|
if (wrap_ancestor_transform) try builder.transform(inverse_ancestor_transform);
|
|
229
|
-
try builder.transform(Affine.translate(-
|
|
226
|
+
try builder.transform(Affine.translate(-translation.tx, -translation.ty));
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/// The window-space translation around a floating drag preview. The same
|
|
230
|
+
/// value drives both the builder stack and span visibility below, so a rich
|
|
231
|
+
/// text child is culled at its lifted pose rather than its standing slot.
|
|
232
|
+
fn widgetLayoutDragPreviewTranslation(
|
|
233
|
+
layout: anytype,
|
|
234
|
+
source_index: usize,
|
|
235
|
+
state: WidgetRenderState,
|
|
236
|
+
ancestor_transform: Affine,
|
|
237
|
+
) Affine {
|
|
238
|
+
const current_frame = layout.nodes[source_index].frame.normalized();
|
|
239
|
+
const current_origin = ancestor_transform.transformPoint(geometry.PointF.init(current_frame.x, current_frame.y));
|
|
240
|
+
const source_layout_origin = state.drag_preview_origin orelse geometry.PointF.init(current_frame.x, current_frame.y);
|
|
241
|
+
const source_origin = ancestor_transform.transformPoint(source_layout_origin);
|
|
242
|
+
return Affine.translate(
|
|
243
|
+
source_origin.x + state.drag_preview_offset.dx - current_origin.x,
|
|
244
|
+
source_origin.y + state.drag_preview_offset.dy - current_origin.y,
|
|
245
|
+
);
|
|
230
246
|
}
|
|
231
247
|
|
|
232
248
|
/// The union of the layout's root-node frames: the whole laid-out
|
|
@@ -265,6 +281,46 @@ fn widgetLayoutNodeEmissionTransform(layout: anytype, node_index: usize) ?Affine
|
|
|
265
281
|
return transform;
|
|
266
282
|
}
|
|
267
283
|
|
|
284
|
+
/// The transform active while `node_index` paints in this frame. Unlike the
|
|
285
|
+
/// standing emission transform above, this includes presentation-only layout
|
|
286
|
+
/// motion and the window-level translation around a floating drag preview.
|
|
287
|
+
fn widgetLayoutNodePresentationTransform(
|
|
288
|
+
layout: anytype,
|
|
289
|
+
node_index: usize,
|
|
290
|
+
state: WidgetRenderState,
|
|
291
|
+
outer_transform: Affine,
|
|
292
|
+
) ?Affine {
|
|
293
|
+
// Static/ordinary frames are overwhelmingly common. Keep their culling
|
|
294
|
+
// path byte-for-byte with the standing transform walk; only late passes
|
|
295
|
+
// and active layout motion pay for presentation-state lookups.
|
|
296
|
+
if (!state.rendering_drag_preview and state.layout_motions.len == 0) {
|
|
297
|
+
return widgetLayoutNodeEmissionTransform(layout, node_index);
|
|
298
|
+
}
|
|
299
|
+
if (node_index >= layout.nodes.len) return null;
|
|
300
|
+
var indices: [widget_layout.max_widget_depth]usize = undefined;
|
|
301
|
+
var len: usize = 0;
|
|
302
|
+
var current: ?usize = node_index;
|
|
303
|
+
while (current) |index| {
|
|
304
|
+
if (index >= layout.nodes.len or len >= indices.len) return null;
|
|
305
|
+
indices[len] = index;
|
|
306
|
+
len += 1;
|
|
307
|
+
if (widget_tree.widgetIsAnchored(layout.nodes[index].widget)) break;
|
|
308
|
+
current = layout.nodes[index].parent_index;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
var transform = outer_transform;
|
|
312
|
+
while (len > 0) {
|
|
313
|
+
len -= 1;
|
|
314
|
+
const widget = layout.nodes[indices[len]].widget;
|
|
315
|
+
const motion = state.layoutMotionOffset(widget.id);
|
|
316
|
+
if (motion.dx != 0 or motion.dy != 0) {
|
|
317
|
+
transform = transform.multiply(Affine.translate(motion.dx, motion.dy));
|
|
318
|
+
}
|
|
319
|
+
transform = transform.multiply(widgetTransform(widget));
|
|
320
|
+
}
|
|
321
|
+
return transform;
|
|
322
|
+
}
|
|
323
|
+
|
|
268
324
|
/// The transform stack a node inherits at its ordinary paint position. A
|
|
269
325
|
/// drag preview is hoisted to the window-level late pass to escape clipping,
|
|
270
326
|
/// so it must explicitly restore this stack before painting the source.
|
|
@@ -279,24 +335,45 @@ fn widgetLayoutNodeAncestorEmissionTransform(layout: anytype, node_index: usize)
|
|
|
279
335
|
|
|
280
336
|
/// The rectangular part of one layout node that can reach the surface,
|
|
281
337
|
/// returned in the node's untransformed layout coordinate space. Window
|
|
282
|
-
/// and ancestor clip bounds are intersected in device space, then
|
|
283
|
-
/// back through the exact transform stack
|
|
284
|
-
///
|
|
285
|
-
///
|
|
286
|
-
fn widgetLayoutNodeVisibleBounds(
|
|
338
|
+
/// and active ancestor clip bounds are intersected in device space, then
|
|
339
|
+
/// mapped back through the exact PRESENTATION transform stack. Floating
|
|
340
|
+
/// drag previews and clip-escaping landing motions stop at their lifted
|
|
341
|
+
/// subtree root, so the culling policy matches the late unclipped paint pass.
|
|
342
|
+
fn widgetLayoutNodeVisibleBounds(
|
|
343
|
+
layout: anytype,
|
|
344
|
+
node_index: usize,
|
|
345
|
+
bounds: geometry.RectF,
|
|
346
|
+
state: WidgetRenderState,
|
|
347
|
+
) ?geometry.RectF {
|
|
287
348
|
if (node_index >= layout.nodes.len) return null;
|
|
288
349
|
var device_visible = (widgetLayoutRootBounds(layout) orelse return null).normalized();
|
|
350
|
+
const has_layout_motion = state.layout_motions.len > 0;
|
|
351
|
+
const outer_transform = if (state.rendering_drag_preview) blk: {
|
|
352
|
+
const preview_id = state.drag_preview_id orelse return null;
|
|
353
|
+
const preview_index = widget_tree.widgetIndexById(layout, preview_id) orelse return null;
|
|
354
|
+
const ancestor_transform = widgetLayoutNodeAncestorEmissionTransform(layout, preview_index) orelse return null;
|
|
355
|
+
break :blk widgetLayoutDragPreviewTranslation(layout, preview_index, state, ancestor_transform);
|
|
356
|
+
} else Affine.identity();
|
|
289
357
|
|
|
290
358
|
var current = node_index;
|
|
291
359
|
while (true) {
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
360
|
+
const current_widget = layout.nodes[current].widget;
|
|
361
|
+
const is_drag_preview_root = state.rendering_drag_preview and
|
|
362
|
+
state.drag_preview_id != null and
|
|
363
|
+
state.drag_preview_id.? == current_widget.id;
|
|
364
|
+
// Every late window-level pass escapes clips ABOVE its lifted root,
|
|
365
|
+
// but nested clips inside that subtree still constrain descendants.
|
|
366
|
+
if (widget_tree.widgetIsAnchored(current_widget) or
|
|
367
|
+
is_drag_preview_root or
|
|
368
|
+
has_layout_motion and state.layoutMotionEscapesAncestorClips(current_widget.id))
|
|
369
|
+
{
|
|
370
|
+
break;
|
|
371
|
+
}
|
|
295
372
|
const parent_index = layout.nodes[current].parent_index orelse break;
|
|
296
373
|
if (parent_index >= layout.nodes.len) return null;
|
|
297
374
|
const parent = layout.nodes[parent_index];
|
|
298
375
|
if (widgetClipsContent(parent.widget)) {
|
|
299
|
-
const parent_transform =
|
|
376
|
+
const parent_transform = widgetLayoutNodePresentationTransform(layout, parent_index, state, outer_transform) orelse return null;
|
|
300
377
|
const device_clip = parent_transform.transformRect(parent.frame.normalized());
|
|
301
378
|
device_visible = geometry.RectF.intersection(device_visible, device_clip);
|
|
302
379
|
if (device_visible.isEmpty()) return null;
|
|
@@ -304,7 +381,7 @@ fn widgetLayoutNodeVisibleBounds(layout: anytype, node_index: usize, bounds: geo
|
|
|
304
381
|
current = parent_index;
|
|
305
382
|
}
|
|
306
383
|
|
|
307
|
-
const transform =
|
|
384
|
+
const transform = widgetLayoutNodePresentationTransform(layout, node_index, state, outer_transform) orelse return null;
|
|
308
385
|
const inverse = transform.inverse() orelse return null;
|
|
309
386
|
const local_visible = inverse.transformRect(device_visible);
|
|
310
387
|
const clipped = geometry.RectF.intersection(bounds.normalized(), local_visible.normalized());
|
|
@@ -397,6 +474,16 @@ fn emitWidgetDepthContent(builder: *Builder, widget: Widget, tokens: DesignToken
|
|
|
397
474
|
try emitVisibleCodeTextSpansWidget(builder, paint_widget, tokens, clipped, .{});
|
|
398
475
|
}
|
|
399
476
|
}
|
|
477
|
+
} else if (paint_widget.spans.len > 0) {
|
|
478
|
+
if (tree_visible_bounds) |visible_bounds| {
|
|
479
|
+
const clipped = geometry.RectF.intersection(
|
|
480
|
+
paint_widget.frame.normalized(),
|
|
481
|
+
visible_bounds.normalized(),
|
|
482
|
+
);
|
|
483
|
+
if (!clipped.isEmpty()) {
|
|
484
|
+
try emitVisibleTextSpansWidget(builder, paint_widget, tokens, clipped);
|
|
485
|
+
}
|
|
486
|
+
}
|
|
400
487
|
} else {
|
|
401
488
|
try emitTextWidget(builder, paint_widget, tokens);
|
|
402
489
|
}
|
|
@@ -411,7 +498,7 @@ fn emitWidgetDepthContent(builder: *Builder, widget: Widget, tokens: DesignToken
|
|
|
411
498
|
.icon_button => try widget_render_controls.emitIconButtonWidget(builder, paint_widget, tokens),
|
|
412
499
|
.select => try widget_render_controls.emitSelectWidget(builder, paint_widget, tokens),
|
|
413
500
|
.input, .text_field => try widget_render_controls.emitTextFieldWidget(builder, paint_widget, tokens),
|
|
414
|
-
.textarea => if (paint_widget.code_editor)
|
|
501
|
+
.textarea => if (paint_widget.runtime_flags.code_editor)
|
|
415
502
|
try emitCodeEditorWidget(builder, paint_widget, tokens)
|
|
416
503
|
else
|
|
417
504
|
try widget_render_controls.emitTextFieldWidget(builder, paint_widget, tokens),
|
|
@@ -714,7 +801,7 @@ fn emitWidgetLayoutNodeContent(
|
|
|
714
801
|
try emitWidgetLayoutChildren(builder, layout, node_index, tokens, state);
|
|
715
802
|
try builder.popClip();
|
|
716
803
|
// Native scroll drivers own the (OS overlay) scrollbar.
|
|
717
|
-
if (!paint_widget.native_scroll) {
|
|
804
|
+
if (!paint_widget.runtime_flags.native_scroll) {
|
|
718
805
|
try widget_render_scroll.emitScrollViewScrollbars(
|
|
719
806
|
builder,
|
|
720
807
|
paint_widget.frame,
|
|
@@ -780,9 +867,13 @@ fn emitWidgetLayoutNodeContent(
|
|
|
780
867
|
.menu_surface, .dropdown_menu => try widget_render_surfaces.emitMenuSurfaceWidgetChrome(builder, paint_widget, tokens),
|
|
781
868
|
.text => {
|
|
782
869
|
if (isSyntaxCodeParagraph(paint_widget)) {
|
|
783
|
-
if (widgetLayoutNodeVisibleBounds(layout, node_index, paint_widget.frame)) |visible_bounds| {
|
|
870
|
+
if (widgetLayoutNodeVisibleBounds(layout, node_index, paint_widget.frame, state)) |visible_bounds| {
|
|
784
871
|
try emitVisibleCodeTextSpansWidget(builder, paint_widget, tokens, visible_bounds, .{});
|
|
785
872
|
}
|
|
873
|
+
} else if (paint_widget.spans.len > 0) {
|
|
874
|
+
if (widgetLayoutNodeVisibleBounds(layout, node_index, paint_widget.frame, state)) |visible_bounds| {
|
|
875
|
+
try emitVisibleTextSpansWidget(builder, paint_widget, tokens, visible_bounds);
|
|
876
|
+
}
|
|
786
877
|
} else {
|
|
787
878
|
try emitTextWidget(builder, paint_widget, tokens);
|
|
788
879
|
}
|
|
@@ -797,7 +888,7 @@ fn emitWidgetLayoutNodeContent(
|
|
|
797
888
|
.icon_button => try widget_render_controls.emitIconButtonWidget(builder, paint_widget, tokens),
|
|
798
889
|
.select => try widget_render_controls.emitSelectWidget(builder, paint_widget, tokens),
|
|
799
890
|
.input, .text_field => try widget_render_controls.emitTextFieldWidget(builder, paint_widget, tokens),
|
|
800
|
-
.textarea => if (paint_widget.code_editor)
|
|
891
|
+
.textarea => if (paint_widget.runtime_flags.code_editor)
|
|
801
892
|
try emitCodeEditorWidget(builder, paint_widget, tokens)
|
|
802
893
|
else
|
|
803
894
|
try widget_render_controls.emitTextFieldWidget(builder, paint_widget, tokens),
|
|
@@ -871,7 +962,7 @@ fn emitWidgetLayoutScrollableChildren(
|
|
|
871
962
|
// Native scroll drivers own the (OS overlay) scrollbar. These are
|
|
872
963
|
// the virtualized containers — vertical machinery, so only the
|
|
873
964
|
// vertical bar can exist.
|
|
874
|
-
if (!widget.native_scroll) {
|
|
965
|
+
if (!widget.runtime_flags.native_scroll) {
|
|
875
966
|
try widget_render_scroll.emitScrollViewScrollbars(
|
|
876
967
|
builder,
|
|
877
968
|
widget.frame,
|
|
@@ -1114,7 +1205,7 @@ fn emitScrollViewWidget(builder: *Builder, widget: Widget, tokens: DesignTokens,
|
|
|
1114
1205
|
try emitWidgetChildren(builder, widget.children, tokens, depth);
|
|
1115
1206
|
try builder.popClip();
|
|
1116
1207
|
// Native scroll drivers own the (OS overlay) scrollbar.
|
|
1117
|
-
if (!widget.native_scroll) {
|
|
1208
|
+
if (!widget.runtime_flags.native_scroll) {
|
|
1118
1209
|
try widget_render_scroll.emitScrollViewScrollbars(
|
|
1119
1210
|
builder,
|
|
1120
1211
|
widget.frame,
|
|
@@ -1389,112 +1480,194 @@ fn emitStaticTextSelectionBounded(
|
|
|
1389
1480
|
}
|
|
1390
1481
|
}
|
|
1391
1482
|
|
|
1392
|
-
///
|
|
1393
|
-
///
|
|
1394
|
-
/// decorations get stable hashed command ids derived from the widget id
|
|
1395
|
-
/// and their ordinal, so retained diffing works across frames.
|
|
1483
|
+
/// Full-frame compatibility path for span-bearing composite leaves such
|
|
1484
|
+
/// as table cells. Ordinary `.text` nodes pass their real viewport below.
|
|
1396
1485
|
fn emitTextSpansWidget(builder: *Builder, widget: Widget, tokens: DesignTokens) Error!void {
|
|
1486
|
+
return emitVisibleTextSpansWidget(builder, widget, tokens, widget.frame);
|
|
1487
|
+
}
|
|
1488
|
+
|
|
1489
|
+
/// Draw the visible pages of an ordinary span paragraph: one single-line
|
|
1490
|
+
/// text command per laid-out run plus backgrounds and thin decoration
|
|
1491
|
+
/// rects. Layout keeps the full paragraph height, while painting pages the
|
|
1492
|
+
/// bounded run store through the current viewport. Without this split, a
|
|
1493
|
+
/// transcript longer than `max_text_span_lines_per_paragraph` reserved its
|
|
1494
|
+
/// real height but painted only its first page, leaving a blank tail after
|
|
1495
|
+
/// the scroll moved beyond line 128.
|
|
1496
|
+
fn emitVisibleTextSpansWidget(
|
|
1497
|
+
builder: *Builder,
|
|
1498
|
+
widget: Widget,
|
|
1499
|
+
tokens: DesignTokens,
|
|
1500
|
+
visible_bounds: geometry.RectF,
|
|
1501
|
+
) Error!void {
|
|
1397
1502
|
const content = widget_metrics.widgetTextSpanContentFrame(widget, tokens);
|
|
1398
1503
|
const layout_options = widget_metrics.widgetTextSpanLayoutOptions(
|
|
1399
1504
|
widget,
|
|
1400
1505
|
tokens,
|
|
1401
1506
|
textWrapMaxWidth(tokens, content.width),
|
|
1402
1507
|
);
|
|
1508
|
+
const line_height = text_spans_model.textSpanLineHeight(widget.spans, layout_options);
|
|
1509
|
+
if (line_height <= 0 or !std.math.isFinite(line_height)) return;
|
|
1510
|
+
|
|
1511
|
+
const first_visible_line: usize = if (std.math.isFinite(visible_bounds.y - content.y) and
|
|
1512
|
+
visible_bounds.y > content.y)
|
|
1513
|
+
@intFromFloat(@floor((visible_bounds.y - content.y) / line_height))
|
|
1514
|
+
else
|
|
1515
|
+
0;
|
|
1516
|
+
const last_visible_line: usize = if (std.math.isFinite(visible_bounds.maxY() - content.y) and
|
|
1517
|
+
visible_bounds.maxY() > content.y)
|
|
1518
|
+
@intFromFloat(@floor((visible_bounds.maxY() - content.y) / line_height))
|
|
1519
|
+
else
|
|
1520
|
+
first_visible_line;
|
|
1521
|
+
const lines_per_page = text_spans_model.max_text_span_lines_per_paragraph;
|
|
1522
|
+
const first_page_line = (first_visible_line / lines_per_page) * lines_per_page;
|
|
1523
|
+
|
|
1403
1524
|
var runs: [text_spans_model.max_text_span_runs_per_paragraph]text_spans_model.TextSpanRun = undefined;
|
|
1404
|
-
const layout = text_spans_model.layoutTextSpans(
|
|
1405
|
-
widget.spans,
|
|
1406
|
-
layout_options,
|
|
1407
|
-
&runs,
|
|
1408
|
-
);
|
|
1409
1525
|
|
|
1410
|
-
|
|
1411
|
-
//
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1526
|
+
// Backgrounds from every visible page stay behind the paragraph's
|
|
1527
|
+
// selection layer and glyphs, preserving the original paint order.
|
|
1528
|
+
var page_first_line = first_page_line;
|
|
1529
|
+
while (true) {
|
|
1530
|
+
const layout = text_spans_model.layoutTextSpansFromLine(
|
|
1531
|
+
widget.spans,
|
|
1532
|
+
layout_options,
|
|
1533
|
+
page_first_line,
|
|
1534
|
+
&runs,
|
|
1535
|
+
);
|
|
1536
|
+
const page_index = page_first_line / lines_per_page;
|
|
1537
|
+
const ordinal_base = page_index *| text_spans_model.max_text_span_runs_per_paragraph;
|
|
1538
|
+
for (layout.runs, 0..) |run, ordinal| {
|
|
1539
|
+
if (run.text.len == 0) continue;
|
|
1540
|
+
const background = widget.spans[run.span_index].background orelse continue;
|
|
1541
|
+
const bounds = text_spans_model.textSpanRunBounds(layout, run);
|
|
1542
|
+
const frame = geometry.RectF.init(
|
|
1423
1543
|
content.x + bounds.x,
|
|
1424
1544
|
content.y + bounds.y,
|
|
1425
1545
|
bounds.width,
|
|
1426
1546
|
bounds.height,
|
|
1427
|
-
)
|
|
1428
|
-
|
|
1429
|
-
|
|
1547
|
+
);
|
|
1548
|
+
if (!frame.intersects(visible_bounds)) continue;
|
|
1549
|
+
try builder.fillRect(.{
|
|
1550
|
+
// Page zero keeps the historical ids byte-for-byte; later
|
|
1551
|
+
// pages occupy disjoint ordinal bands.
|
|
1552
|
+
.id = textSpanBackgroundCommandId(widget.id, ordinal_base +| ordinal),
|
|
1553
|
+
.rect = pixelSnapGeometryRect(tokens, frame),
|
|
1554
|
+
.fill = colorFill(text_spans_model.textSpanColorValue(tokens.colors, background)),
|
|
1555
|
+
});
|
|
1556
|
+
}
|
|
1557
|
+
const next_first_line = page_first_line +| lines_per_page;
|
|
1558
|
+
if (next_first_line <= page_first_line or
|
|
1559
|
+
next_first_line > last_visible_line or
|
|
1560
|
+
next_first_line >= layout.line_count)
|
|
1561
|
+
{
|
|
1562
|
+
break;
|
|
1563
|
+
}
|
|
1564
|
+
page_first_line = next_first_line;
|
|
1430
1565
|
}
|
|
1431
1566
|
|
|
1432
1567
|
try emitStaticTextSelection(builder, widget, tokens);
|
|
1433
1568
|
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
.
|
|
1464
|
-
.
|
|
1465
|
-
.
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
},
|
|
1469
|
-
});
|
|
1569
|
+
page_first_line = first_page_line;
|
|
1570
|
+
while (true) {
|
|
1571
|
+
const layout = text_spans_model.layoutTextSpansFromLine(
|
|
1572
|
+
widget.spans,
|
|
1573
|
+
layout_options,
|
|
1574
|
+
page_first_line,
|
|
1575
|
+
&runs,
|
|
1576
|
+
);
|
|
1577
|
+
const page_index = page_first_line / lines_per_page;
|
|
1578
|
+
const ordinal_base = page_index *| text_spans_model.max_text_span_runs_per_paragraph;
|
|
1579
|
+
const decoration_base = page_index *| (text_spans_model.max_text_span_runs_per_paragraph * 2);
|
|
1580
|
+
var decoration_ordinal: usize = 0;
|
|
1581
|
+
for (layout.runs, 0..) |run, ordinal| {
|
|
1582
|
+
if (run.text.len == 0) continue;
|
|
1583
|
+
const span = widget.spans[run.span_index];
|
|
1584
|
+
const is_link = span.link.len > 0;
|
|
1585
|
+
const underline_ordinal: ?usize = if (span.underline or is_link) blk: {
|
|
1586
|
+
const value = decoration_base +| decoration_ordinal;
|
|
1587
|
+
decoration_ordinal += 1;
|
|
1588
|
+
break :blk value;
|
|
1589
|
+
} else null;
|
|
1590
|
+
const strikethrough_ordinal: ?usize = if (span.strikethrough) blk: {
|
|
1591
|
+
const value = decoration_base +| decoration_ordinal;
|
|
1592
|
+
decoration_ordinal += 1;
|
|
1593
|
+
break :blk value;
|
|
1594
|
+
} else null;
|
|
1595
|
+
const bounds = text_spans_model.textSpanRunBounds(layout, run);
|
|
1596
|
+
const run_frame = geometry.RectF.init(
|
|
1597
|
+
content.x + bounds.x,
|
|
1598
|
+
content.y + bounds.y,
|
|
1599
|
+
bounds.width,
|
|
1600
|
+
bounds.height,
|
|
1601
|
+
);
|
|
1602
|
+
if (!run_frame.intersects(visible_bounds)) continue;
|
|
1470
1603
|
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
.
|
|
1604
|
+
const color = if (span.color) |ref|
|
|
1605
|
+
text_spans_model.textSpanColorValue(tokens.colors, ref)
|
|
1606
|
+
else if (is_link)
|
|
1607
|
+
widgetForegroundColor(widget, tokens, tokens.colors.accent)
|
|
1608
|
+
else
|
|
1609
|
+
widgetForegroundColor(widget, tokens, tokens.colors.text);
|
|
1610
|
+
const origin = pixelSnapTextPoint(tokens, geometry.PointF.init(content.x + run.x, content.y + run.baseline));
|
|
1611
|
+
try builder.drawText(.{
|
|
1612
|
+
.id = textSpanRunCommandId(widget.id, ordinal_base +| ordinal),
|
|
1613
|
+
.font_id = run.font_id,
|
|
1614
|
+
.size = run.size,
|
|
1615
|
+
.origin = origin,
|
|
1616
|
+
.color = color,
|
|
1617
|
+
.text = run.text,
|
|
1618
|
+
// Wrapping already happened at the span level (each run is one
|
|
1619
|
+
// line segment), so the options carry no wrap work — they carry
|
|
1620
|
+
// the measurement seam. Renderers that walk per-cluster
|
|
1621
|
+
// advances (the reference renderer behind every automation
|
|
1622
|
+
// screenshot) then advance with the same provider layout
|
|
1623
|
+
// positioned the runs with; without it a provider-kerned prose
|
|
1624
|
+
// run repainted at estimator advances overran the next span's
|
|
1625
|
+
// x and visually swallowed the inter-span space
|
|
1626
|
+
// ("remaining`experimental_`" -> "remainingexperimental_").
|
|
1627
|
+
.text_layout = .{
|
|
1628
|
+
.max_width = 0,
|
|
1629
|
+
.line_height = layout.line_height,
|
|
1630
|
+
.wrap = .none,
|
|
1631
|
+
.alignment = .start,
|
|
1632
|
+
.measure = tokens.text_measure,
|
|
1633
|
+
},
|
|
1482
1634
|
});
|
|
1483
|
-
|
|
1635
|
+
|
|
1636
|
+
const thickness = @max(1, tokens.stroke.hairline);
|
|
1637
|
+
if (underline_ordinal) |decoration_id_ordinal| {
|
|
1638
|
+
try builder.fillRect(.{
|
|
1639
|
+
.id = textSpanDecorationCommandId(widget.id, decoration_id_ordinal),
|
|
1640
|
+
.rect = pixelSnapGeometryRect(tokens, geometry.RectF.init(
|
|
1641
|
+
content.x + run.x,
|
|
1642
|
+
content.y + run.baseline + @max(1, run.size * 0.1),
|
|
1643
|
+
run.width,
|
|
1644
|
+
thickness,
|
|
1645
|
+
)),
|
|
1646
|
+
.fill = colorFill(color),
|
|
1647
|
+
});
|
|
1648
|
+
}
|
|
1649
|
+
if (strikethrough_ordinal) |decoration_id_ordinal| {
|
|
1650
|
+
try builder.fillRect(.{
|
|
1651
|
+
.id = textSpanDecorationCommandId(widget.id, decoration_id_ordinal),
|
|
1652
|
+
.rect = pixelSnapGeometryRect(tokens, geometry.RectF.init(
|
|
1653
|
+
content.x + run.x,
|
|
1654
|
+
content.y + run.baseline - run.size * 0.3,
|
|
1655
|
+
run.width,
|
|
1656
|
+
thickness,
|
|
1657
|
+
)),
|
|
1658
|
+
.fill = colorFill(color),
|
|
1659
|
+
});
|
|
1660
|
+
}
|
|
1484
1661
|
}
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
thickness,
|
|
1493
|
-
)),
|
|
1494
|
-
.fill = colorFill(color),
|
|
1495
|
-
});
|
|
1496
|
-
decoration_ordinal += 1;
|
|
1662
|
+
|
|
1663
|
+
const next_first_line = page_first_line +| lines_per_page;
|
|
1664
|
+
if (next_first_line <= page_first_line or
|
|
1665
|
+
next_first_line > last_visible_line or
|
|
1666
|
+
next_first_line >= layout.line_count)
|
|
1667
|
+
{
|
|
1668
|
+
break;
|
|
1497
1669
|
}
|
|
1670
|
+
page_first_line = next_first_line;
|
|
1498
1671
|
}
|
|
1499
1672
|
}
|
|
1500
1673
|
|
|
@@ -1603,10 +1776,10 @@ fn emitVisibleCodeTextSpansWidget(
|
|
|
1603
1776
|
visible_bounds: geometry.RectF,
|
|
1604
1777
|
paint: CodeTextPaint,
|
|
1605
1778
|
) Error!void {
|
|
1606
|
-
if (widget.code_editor and widget.text_no_wrap) {
|
|
1779
|
+
if (widget.runtime_flags.code_editor and widget.text_no_wrap) {
|
|
1607
1780
|
return emitVisibleEditableCodeLines(builder, widget, tokens, visible_bounds, paint);
|
|
1608
1781
|
}
|
|
1609
|
-
if (widget.code_editor) {
|
|
1782
|
+
if (widget.runtime_flags.code_editor) {
|
|
1610
1783
|
return emitVisibleWrappedEditableCodeLines(builder, widget, tokens, visible_bounds, paint);
|
|
1611
1784
|
}
|
|
1612
1785
|
const spans = widget.spans;
|
|
@@ -2226,7 +2399,7 @@ fn emitCodeLineDecorations(
|
|
|
2226
2399
|
while (line_start <= widget.text.len) : (logical_line += 1) {
|
|
2227
2400
|
// A terminal newline closes the preceding painted line; the span
|
|
2228
2401
|
// breaker intentionally does not reserve another empty visual line.
|
|
2229
|
-
if (line_start == widget.text.len and widget.text.len > 0 and !widget.code_editor) break;
|
|
2402
|
+
if (line_start == widget.text.len and widget.text.len > 0 and !widget.runtime_flags.code_editor) break;
|
|
2230
2403
|
const newline = std.mem.indexOfScalarPos(u8, widget.text, line_start, '\n');
|
|
2231
2404
|
const line_end = newline orelse widget.text.len;
|
|
2232
2405
|
const line = widget.text[line_start..line_end];
|
|
@@ -4114,8 +4287,17 @@ fn widgetWithFrame(widget: Widget, frame: geometry.RectF) Widget {
|
|
|
4114
4287
|
fn widgetWithRenderState(widget: Widget, state: WidgetRenderState) Widget {
|
|
4115
4288
|
var copy = widget;
|
|
4116
4289
|
if (state.focused_id != null or state.focus_visible_id != null) {
|
|
4117
|
-
|
|
4118
|
-
|
|
4290
|
+
// A menu's active row is logical focus, regardless of whether
|
|
4291
|
+
// the menu was opened with the pointer or keyboard. Menu items
|
|
4292
|
+
// render that state as a quiet full-row wash and never as a
|
|
4293
|
+
// focus-ring outline. Every other widget keeps the modality-
|
|
4294
|
+
// aware focus-visible projection used for keyboard-only rings.
|
|
4295
|
+
const painted_focus_id = if (copy.kind == .menu_item)
|
|
4296
|
+
state.focused_id
|
|
4297
|
+
else
|
|
4298
|
+
state.focus_visible_id;
|
|
4299
|
+
copy.state.focused = if (painted_focus_id) |focused_id|
|
|
4300
|
+
copy.id != 0 and copy.id == focused_id
|
|
4119
4301
|
else
|
|
4120
4302
|
false;
|
|
4121
4303
|
}
|