@native-sdk/cli 0.11.0 → 0.11.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/build/app.zig +73 -37
- package/build.zig +239 -5
- package/native-sdk.d.ts +5 -1
- package/package.json +13 -12
- package/packages/core/compile-surface/core.ts +30 -0
- package/packages/core/package-lock.json +6 -6
- package/packages/core/package.json +3 -3
- package/packages/core/scripts/scriptc-toolchain.json +44 -44
- package/packages/core/scripts/stage_external_core.mjs +27 -16
- package/packages/core/sdk/core.d.ts +24 -1
- package/packages/core/sdk/core.ts +51 -1
- package/packages/core/sdk/events.d.ts +5 -0
- package/packages/core/sdk/events.ts +10 -0
- package/packages/core/src/bridge_descriptors.ts +3 -3
- package/packages/core/src/checker.ts +20 -0
- package/packages/core/src/cli.ts +2 -11
- package/packages/core/src/context_menus.ts +76 -0
- package/packages/core/src/diagnostics.ts +7 -0
- package/packages/core/src/extent_program.ts +53 -0
- package/packages/core/src/frontend.ts +12 -10
- package/packages/core/src/markup_canonical.ts +140 -0
- package/packages/core/src/markup_construction.ts +189 -0
- package/packages/core/src/markup_display.ts +43 -0
- package/packages/core/src/markup_document.ts +226 -0
- package/packages/core/src/markup_elements.ts +225 -0
- package/packages/core/src/markup_expressions.ts +79 -0
- package/packages/core/src/markup_imports.ts +146 -0
- package/packages/core/src/markup_parser.ts +228 -0
- package/packages/core/src/markup_runtime.ts +93 -0
- package/packages/core/src/markup_scalars.ts +143 -0
- package/packages/core/src/markup_shapes.ts +243 -0
- package/packages/core/src/markup_specialized.ts +242 -0
- package/packages/core/src/markup_text.ts +86 -0
- package/packages/core/src/markup_values.ts +336 -0
- package/packages/core/src/portable_sources.json +24 -0
- package/packages/core/src/registered_font.ts +2 -3
- package/packages/core/src/runtime_policy.ts +24 -0
- package/packages/core/src/scalar_text.ts +1 -3
- package/packages/core/src/scroll_mutation.ts +86 -0
- package/packages/core/src/scroll_tree.ts +86 -0
- package/packages/core/src/service_contract.ts +53 -2
- package/packages/core/src/sqlite_cli.ts +3 -46
- package/packages/core/src/sqlite_codegen.ts +84 -0
- package/packages/core/src/staged_rebuild.ts +60 -0
- package/packages/core/src/view_bridge.ts +161 -0
- package/packages/core/src/view_check.ts +145 -0
- package/packages/core/src/view_evaluator.ts +823 -0
- package/packages/core/src/view_frontend.ts +340 -218
- package/packages/core/src/view_program.ts +221 -0
- package/packages/core/src/view_reload.ts +166 -0
- package/packages/core/src/view_reload_watch.ts +98 -0
- package/packages/core/src/view_sources.ts +34 -0
- package/packages/core/src/virtual_windows.ts +88 -0
- package/packages/core/src/web_panes.ts +67 -0
- package/packages/core/src/widget_continuity.ts +37 -0
- package/packages/core/src/widget_reconcile.ts +63 -0
- package/packages/core/src/widget_retention.ts +62 -0
- package/skill-data/native-ui/SKILL.md +2 -2
- package/skill-data/ts-core/SKILL.md +5 -3
- package/skill-data/ts-services/references/service-surface.md +29 -5
- package/src/app_runner/root.zig +14 -0
- package/src/app_runner/ts_compiled_view.zig +88 -17
- package/src/app_runner/ts_core_main.zig +43 -5
- package/src/app_runner/ts_core_mobile.zig +1 -1
- package/src/automation/server.zig +56 -3
- package/src/embed/host.zig +2 -0
- package/src/embed/tests.zig +2 -0
- package/src/embed/ui_host.zig +2 -0
- package/src/platform/keyboard_input.zig +32 -0
- package/src/platform/linux/root.zig +2 -0
- package/src/platform/macos/appkit_host.h +7 -2
- package/src/platform/macos/appkit_host.m +31 -9
- package/src/platform/macos/cef_host.mm +15 -1
- package/src/platform/macos/global_shortcuts.zig +138 -0
- package/src/platform/macos/key_codes.zig +102 -0
- package/src/platform/macos/keyboard_input.zig +81 -0
- package/src/platform/macos/root.zig +25 -3
- package/src/platform/macos/webview_inspection_test.m +106 -0
- package/src/platform/null_platform.zig +104 -0
- package/src/platform/root.zig +14 -0
- package/src/platform/types.zig +102 -0
- package/src/platform/windows/global_shortcuts.zig +157 -0
- package/src/platform/windows/key_codes.zig +63 -0
- package/src/platform/windows/keyboard_input.zig +136 -0
- package/src/platform/windows/root.zig +15 -0
- package/src/primitives/canvas/decision_reuse.zig +133 -0
- package/src/primitives/canvas/font_ttf.zig +27 -3
- package/src/primitives/canvas/fonts/Geist-Bold.ttf +0 -0
- package/src/primitives/canvas/fonts/Geist-Medium.ttf +0 -0
- package/src/primitives/canvas/fonts/OFL.txt +93 -0
- package/src/primitives/canvas/fonts/README.md +15 -0
- package/src/primitives/canvas/intrinsic_measure_policy.zig +4 -1
- package/src/primitives/canvas/markdown_tests.zig +3 -3
- package/src/primitives/canvas/reference.zig +3 -5
- package/src/primitives/canvas/reference_tests.zig +58 -0
- package/src/primitives/canvas/registered_font_policy.zig +1 -1
- package/src/primitives/canvas/root.zig +7 -4
- package/src/primitives/canvas/text_metrics.zig +32 -39
- package/src/primitives/canvas/text_metrics_tests.zig +52 -7
- package/src/primitives/canvas/text_query_policy.zig +142 -3
- package/src/primitives/canvas/text_scalar_policy.zig +80 -2
- package/src/primitives/canvas/tokens.zig +9 -0
- package/src/primitives/canvas/ui.zig +1 -0
- package/src/primitives/canvas/ui_markup.zig +69 -14
- package/src/primitives/canvas/ui_markup_canonical.zig +237 -0
- package/src/primitives/canvas/ui_markup_compiled.zig +1407 -23
- package/src/primitives/canvas/ui_markup_compiled_values.zig +76 -0
- package/src/primitives/canvas/ui_markup_construction.zig +146 -0
- package/src/primitives/canvas/ui_markup_display.zig +82 -0
- package/src/primitives/canvas/ui_markup_document.zig +196 -0
- package/src/primitives/canvas/ui_markup_elements.zig +163 -0
- package/src/primitives/canvas/ui_markup_expr.zig +192 -2
- package/src/primitives/canvas/ui_markup_imports.zig +262 -0
- package/src/primitives/canvas/ui_markup_parser.zig +117 -0
- package/src/primitives/canvas/ui_markup_runtime.zig +76 -0
- package/src/primitives/canvas/ui_markup_scalars.zig +115 -0
- package/src/primitives/canvas/ui_markup_shapes.zig +224 -0
- package/src/primitives/canvas/ui_markup_specialized.zig +106 -0
- package/src/primitives/canvas/ui_markup_text.zig +128 -0
- package/src/primitives/canvas/ui_markup_values.zig +368 -0
- package/src/primitives/canvas/ui_markup_view.zig +2817 -74
- package/src/primitives/canvas/virtual_extent_policy.zig +58 -0
- package/src/primitives/canvas/virtual_extents.zig +47 -33
- package/src/primitives/canvas/widget_metric_policy.zig +4 -1
- package/src/primitives/canvas/widget_runtime.zig +2 -1
- package/src/root.zig +5 -0
- package/src/runtime/api.zig +1 -0
- package/src/runtime/bridge_descriptor_policy.zig +1 -1
- package/src/runtime/bridge_payload.zig +2 -0
- package/src/runtime/canvas_widget_context_menu.zig +179 -0
- package/src/runtime/canvas_widget_context_menu_test_cases.zig +1147 -0
- package/src/runtime/canvas_widget_context_menu_tests.zig +23 -1098
- package/src/runtime/canvas_widget_runtime.zig +306 -92
- package/src/runtime/context_menu_policy.zig +112 -0
- package/src/runtime/core.zig +14 -0
- package/src/runtime/effects.zig +172 -4
- package/src/runtime/effects_host_tests.zig +25 -0
- package/src/runtime/flow.zig +1 -0
- package/src/runtime/flow_reference.zig +1 -0
- package/src/runtime/global_shortcuts.zig +75 -0
- package/src/runtime/keyboard_input.zig +86 -0
- package/src/runtime/root.zig +3 -0
- package/src/runtime/scroll_mutation_policy.zig +130 -0
- package/src/runtime/scroll_mutation_runtime.zig +158 -0
- package/src/runtime/scroll_tree_policy.zig +99 -0
- package/src/runtime/session_record.zig +7 -0
- package/src/runtime/staged_rebuild_policy.zig +83 -0
- package/src/runtime/system_services.zig +19 -0
- package/src/runtime/tests.zig +1 -0
- package/src/runtime/ts_core_host.zig +126 -0
- package/src/runtime/ts_ui_app.zig +24 -0
- package/src/runtime/ui_app.zig +274 -31
- package/src/runtime/ui_app_tests.zig +48 -179
- package/src/runtime/ui_app_window_tests.zig +133 -0
- package/src/runtime/view_reload.zig +226 -0
- package/src/runtime/view_widget_scroll.zig +30 -21
- package/src/runtime/view_widget_tree.zig +43 -13
- package/src/runtime/virtual_window_policy.zig +128 -0
- package/src/runtime/web_pane_policy.zig +111 -0
- package/src/runtime/web_pane_test_cases.zig +204 -0
- package/src/runtime/widget_continuity_policy.zig +73 -0
- package/src/runtime/widget_reconcile_policy.zig +81 -0
- package/src/runtime/widget_retention_policy.zig +75 -0
- package/src/runtime/window_views.zig +19 -4
- package/src/security/root.zig +1 -0
- package/src/tooling/templates.zig +8 -0
- package/src/tooling/ts_core.zig +84 -1
- package/src/tooling/verbs.zig +79 -15
- package/tools/corewire/core.test.ts +25 -3
- package/tools/corewire/core_abi.zig +4 -0
- package/tools/corewire/core_contract.ts +1 -1
- package/tools/corewire/core_goldens.json +75 -75
- package/tools/corewire/core_projection.ts +3 -2
- package/tools/corewire/emit_mirror.ts +19 -9
- package/tools/corewire/facade_templates.ts +1 -1
- package/tools/corewire/intake.test.ts +4 -0
- package/tools/corewire/intake_goldens.json +50 -50
- package/tools/corewire/invocation.test.ts +4 -0
- package/tools/corewire/invocation_goldens.json +3 -3
- package/tools/corewire/mirror_templates.ts +4 -0
- package/tools/corewire/profile_emission.ts +2 -0
- package/tools/corewire/sidecar.zig +2 -0
|
@@ -192,7 +192,22 @@ const ContextMenuRecord = struct {
|
|
|
192
192
|
enabled: bool,
|
|
193
193
|
separator: bool,
|
|
194
194
|
};
|
|
195
|
-
|
|
195
|
+
/// A view-reload build (Debug) decodes the development records: each node's
|
|
196
|
+
/// authored source and the markup files the view names, for `provenance`
|
|
197
|
+
/// and write-back. Every other build decodes exactly the release records.
|
|
198
|
+
const view_sources = @import("builtin").mode == .Debug and @hasDecl(core, "nativeDevViewPrepare");
|
|
199
|
+
const SourceSite = struct { file: []const u8, start: usize, end: usize, line: usize, column: usize };
|
|
200
|
+
const SourceEntry = struct { file: []const u8, start: usize, end: usize, line: usize, column: usize, chain: []const SourceSite };
|
|
201
|
+
const SourceFile = struct { path: []const u8, hash: []const u8 };
|
|
202
|
+
const Tree = if (view_sources) struct {
|
|
203
|
+
format: u32,
|
|
204
|
+
nodes: []const Record,
|
|
205
|
+
sources: []const i64 = &.{},
|
|
206
|
+
sourceTable: []const SourceEntry = &.{},
|
|
207
|
+
sourceFiles: []const SourceFile = &.{},
|
|
208
|
+
} else struct { format: u32, nodes: []const Record };
|
|
209
|
+
/// Per-record sources of the tree being decoded (view-reload builds only).
|
|
210
|
+
var decoding_sources: []const ?*const sdk.canvas.ui_provenance.NodeSource = &.{};
|
|
196
211
|
|
|
197
212
|
const VirtualRequest = struct {
|
|
198
213
|
id: []const u8,
|
|
@@ -231,7 +246,7 @@ fn virtualView(ui: *Ui, label: []const u8, video: []const u8) !Ui.Node {
|
|
|
231
246
|
.viewport_fallback = request.viewportFallback,
|
|
232
247
|
.index_base = request.indexBase,
|
|
233
248
|
.anchor = if (request.trailing) .trailing else .leading,
|
|
234
|
-
.extent_estimate = if (request.estimateHelper >= 0) core.
|
|
249
|
+
.extent_estimate = if (request.estimateHelper >= 0) core.virtualExtentEstimate else null,
|
|
235
250
|
.extent_context = if (request.estimateHelper >= 0) @ptrFromInt(@as(usize, @intCast(request.estimateHelper)) + 1) else null,
|
|
236
251
|
};
|
|
237
252
|
target.range = ui.virtualWindow(target.options);
|
|
@@ -245,8 +260,7 @@ fn virtualView(ui: *Ui, label: []const u8, video: []const u8) !Ui.Node {
|
|
|
245
260
|
return decodeVirtual(ui, core.nativeVirtualView(label, context, video, ui.arena), resolved);
|
|
246
261
|
}
|
|
247
262
|
|
|
248
|
-
/// Concrete callbacks for generated compiled-model apps
|
|
249
|
-
/// retain their full Model signature for independent reference fixtures.
|
|
263
|
+
/// Concrete callbacks for generated compiled-model apps.
|
|
250
264
|
pub fn buildRuntime(ui: *Ui, model: *const core.RuntimeModel) Ui.Node {
|
|
251
265
|
_ = model;
|
|
252
266
|
return buildCommitted(ui);
|
|
@@ -257,9 +271,21 @@ pub fn buildRuntimeWindow(ui: *Ui, model: *const core.RuntimeModel, label: []con
|
|
|
257
271
|
return buildCommittedWindow(ui, label);
|
|
258
272
|
}
|
|
259
273
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
274
|
+
/// Callbacks for any host model representation. The compiled view never
|
|
275
|
+
/// reads the model it is handed, so harnesses that keep another host model
|
|
276
|
+
/// install the same committed tree source as generated apps.
|
|
277
|
+
pub fn ViewFor(comptime HostModel: type) type {
|
|
278
|
+
return struct {
|
|
279
|
+
pub fn build(ui: *Ui, model: *const HostModel) Ui.Node {
|
|
280
|
+
_ = model;
|
|
281
|
+
return buildCommitted(ui);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
pub fn buildWindow(ui: *Ui, model: *const HostModel, label: []const u8) Ui.Node {
|
|
285
|
+
_ = model;
|
|
286
|
+
return buildCommittedWindow(ui, label);
|
|
287
|
+
}
|
|
288
|
+
};
|
|
263
289
|
}
|
|
264
290
|
|
|
265
291
|
fn buildCommitted(ui: *Ui) Ui.Node {
|
|
@@ -269,11 +295,6 @@ fn buildCommitted(ui: *Ui) Ui.Node {
|
|
|
269
295
|
return decode(ui, bytes) catch @panic("invalid compiled TypeScript view data");
|
|
270
296
|
}
|
|
271
297
|
|
|
272
|
-
pub fn buildWindow(ui: *Ui, model: *const core.Model, label: []const u8) Ui.Node {
|
|
273
|
-
_ = model;
|
|
274
|
-
return buildCommittedWindow(ui, label);
|
|
275
|
-
}
|
|
276
|
-
|
|
277
298
|
fn buildCommittedWindow(ui: *Ui, label: []const u8) Ui.Node {
|
|
278
299
|
var context: [20]u8 = undefined;
|
|
279
300
|
if (comptime @hasDecl(core, "nativeVirtualRequests")) return virtualView(ui, label, videoContext(ui, &context)) catch @panic("invalid compiled virtual window view data");
|
|
@@ -297,6 +318,7 @@ fn decode(ui: *Ui, bytes: []const u8) !Ui.Node {
|
|
|
297
318
|
|
|
298
319
|
fn decodeVirtual(ui: *Ui, bytes: []const u8, virtuals: []const ResolvedVirtual) !Ui.Node {
|
|
299
320
|
if (comptime @hasDecl(core, "nativeWindowPolicy")) {
|
|
321
|
+
sdk.canvas.decision_reuse.registerPurePolicy(core.nativeWindowPolicy);
|
|
300
322
|
ui.construction_policy = core.nativeWindowPolicy;
|
|
301
323
|
ui.composition_policy = core.nativeWindowPolicy;
|
|
302
324
|
ui.code_content_policy = core.nativeWindowPolicy;
|
|
@@ -318,10 +340,55 @@ fn decodeVirtual(ui: *Ui, bytes: []const u8, virtuals: []const ResolvedVirtual)
|
|
|
318
340
|
seen[window] = true;
|
|
319
341
|
};
|
|
320
342
|
for (seen[0..virtuals.len]) |present| if (!present) return error.InvalidView;
|
|
343
|
+
if (comptime view_sources) {
|
|
344
|
+
if (ui.provenance_sink != null) decoding_sources = try stampSources(ui, tree);
|
|
345
|
+
defer decoding_sources = &.{};
|
|
346
|
+
return node(ui, tree.nodes, 0, tree.nodes.len, 0, virtuals, null);
|
|
347
|
+
}
|
|
321
348
|
return node(ui, tree.nodes, 0, tree.nodes.len, 0, virtuals, null);
|
|
322
349
|
}
|
|
323
350
|
|
|
324
|
-
|
|
351
|
+
/// Resolve the development records' attribution into one source per record
|
|
352
|
+
/// (in the build arena) and publish the files the view names. A view
|
|
353
|
+
/// without attribution gets no sources, as builder-authored views do.
|
|
354
|
+
fn stampSources(ui: *Ui, tree: Tree) ![]const ?*const sdk.canvas.ui_provenance.NodeSource {
|
|
355
|
+
const provenance = sdk.canvas.ui_provenance;
|
|
356
|
+
const reload = sdk.view_reload;
|
|
357
|
+
if (tree.sources.len != tree.nodes.len) return &.{};
|
|
358
|
+
const entries = try ui.arena.alloc(provenance.NodeSource, tree.sourceTable.len);
|
|
359
|
+
for (tree.sourceTable, entries) |entry, *out| {
|
|
360
|
+
const chain = try ui.arena.alloc(provenance.UseSite, entry.chain.len);
|
|
361
|
+
for (entry.chain, chain) |site, *use| use.* = .{ .src_path = site.file, .span = .{ .start = site.start, .end = site.end }, .line = site.line, .column = site.column };
|
|
362
|
+
out.* = .{ .src_path = entry.file, .span = .{ .start = entry.start, .end = entry.end }, .line = entry.line, .column = entry.column, .chain = chain };
|
|
363
|
+
}
|
|
364
|
+
const stamped = try ui.arena.alloc(?*const provenance.NodeSource, tree.nodes.len);
|
|
365
|
+
for (tree.sources, stamped) |index, *out| {
|
|
366
|
+
if (index < 0 or index >= entries.len) return error.InvalidView;
|
|
367
|
+
out.* = &entries[@intCast(index)];
|
|
368
|
+
}
|
|
369
|
+
reload.view_files_len = 0;
|
|
370
|
+
for (tree.sourceFiles) |file| {
|
|
371
|
+
if (reload.view_files_len == reload.max_view_files) break;
|
|
372
|
+
const hash = std.fmt.parseUnsigned(u64, file.hash, 16) catch return error.InvalidView;
|
|
373
|
+
// Paths are stamped relative to the app's src/; the root view file is stamped empty.
|
|
374
|
+
const disk = try std.fmt.allocPrint(ui.arena, "src/{s}", .{if (file.path.len == 0) "app.native" else file.path});
|
|
375
|
+
reload.view_files[reload.view_files_len] = .{ .stamped = file.path, .disk = disk, .hash = hash };
|
|
376
|
+
reload.view_files_len += 1;
|
|
377
|
+
}
|
|
378
|
+
return stamped;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/// One record and its subtree. View-reload builds stamp each node with its
|
|
382
|
+
/// authored source; every other build decodes the records alone.
|
|
383
|
+
const node = if (view_sources) nodeWithSource else nodeRecord;
|
|
384
|
+
|
|
385
|
+
fn nodeWithSource(ui: *Ui, records: []const Record, index: usize, parent_end: usize, depth: usize, virtuals: []const ResolvedVirtual, parent_kind: ?@FieldType(Record, "kind")) anyerror!Ui.Node {
|
|
386
|
+
var built = try nodeRecord(ui, records, index, parent_end, depth, virtuals, parent_kind);
|
|
387
|
+
if (index < decoding_sources.len) built.source = decoding_sources[index];
|
|
388
|
+
return built;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
fn nodeRecord(ui: *Ui, records: []const Record, index: usize, parent_end: usize, depth: usize, virtuals: []const ResolvedVirtual, parent_kind: ?@FieldType(Record, "kind")) !Ui.Node {
|
|
325
392
|
if (depth > 64) return error.ViewTooDeep;
|
|
326
393
|
var value = records[index];
|
|
327
394
|
if (value.keyBytes != null and value.key != null or value.globalKeyBytes != null and value.globalKey != null) return error.InvalidView;
|
|
@@ -1225,6 +1292,10 @@ test "compiled code diff ordinals preserve every mask word and reject invalid tr
|
|
|
1225
1292
|
}
|
|
1226
1293
|
}
|
|
1227
1294
|
|
|
1295
|
+
/// Reference markup in these checks binds nothing, so it compiles against an
|
|
1296
|
+
/// empty model rather than the app's source model.
|
|
1297
|
+
const BindingFreeModel = struct {};
|
|
1298
|
+
|
|
1228
1299
|
// The native construction oracle supplies authored data. Compiled views also
|
|
1229
1300
|
// attach the appearance owner to every node; compare that callback explicitly
|
|
1230
1301
|
// instead of erasing it from the decoded tree.
|
|
@@ -1246,8 +1317,8 @@ test "compiled tooltip records match native anchored and static primitives" {
|
|
|
1246
1317
|
var actual = try decode(&ui, bytes);
|
|
1247
1318
|
@memset(bytes, 0);
|
|
1248
1319
|
var reference_ui = Ui.init(arena.allocator());
|
|
1249
|
-
const Reference = sdk.canvas.CompiledMarkupView(
|
|
1250
|
-
const model:
|
|
1320
|
+
const Reference = sdk.canvas.CompiledMarkupView(BindingFreeModel, core.Msg, "<stack><button>Run</button><tooltip anchor=\"above\" anchor-alignment=\"end\" anchor-offset=\"8\" tooltip-delay=\"250\">Run café</tooltip><tooltip>Static hint</tooltip></stack>");
|
|
1321
|
+
const model: BindingFreeModel = .{};
|
|
1251
1322
|
const expected = withCompiledAppearance(Reference.build(&reference_ui, &model));
|
|
1252
1323
|
// The runtime-only callback differs by frontend; every authored
|
|
1253
1324
|
// primitive field, child, owned string and anchor must match.
|
|
@@ -1422,10 +1493,10 @@ pub fn testInlineParagraphRecords() !void {
|
|
|
1422
1493
|
var actual = try decode(&ui, bytes);
|
|
1423
1494
|
@memset(bytes, 0);
|
|
1424
1495
|
var reference_ui = Ui.init(arena.allocator());
|
|
1425
|
-
const Reference = sdk.canvas.CompiledMarkupView(
|
|
1496
|
+
const Reference = sdk.canvas.CompiledMarkupView(BindingFreeModel, core.Msg,
|
|
1426
1497
|
\\<text text-alignment="end" size="display" key="readout" label="Result">Value <span weight="medium" mono="true" italic="true" underline="true" scale="1.5" foreground="accent">café</span>.</text>
|
|
1427
1498
|
);
|
|
1428
|
-
const model:
|
|
1499
|
+
const model: BindingFreeModel = .{};
|
|
1429
1500
|
const expected = withCompiledAppearance(Reference.build(&reference_ui, &model));
|
|
1430
1501
|
actual.widget.interaction_policy = null;
|
|
1431
1502
|
const actual_tree = try ui.finalize(actual);
|
|
@@ -73,15 +73,47 @@ const ts_view = @import("compiled_view.zig");
|
|
|
73
73
|
|
|
74
74
|
pub const panic = std.debug.FullPanic(native_sdk.debug.capturePanic);
|
|
75
75
|
|
|
76
|
-
/// Re-exported so the model-contract step (and any test) reflects the
|
|
77
|
-
/// core's real surface: `native check` verifies app.native against it.
|
|
78
|
-
pub const Model = core.Model;
|
|
79
76
|
pub const Msg = core.Msg;
|
|
80
77
|
|
|
81
78
|
const dev = builtin.mode == .Debug;
|
|
82
|
-
const Adapter = native_sdk.TsUiAppWithFeatures(core, .{ .runtime_markup = dev and !ts_view.enabled, .compiled_model = ts_view.enabled });
|
|
79
|
+
const Adapter = native_sdk.TsUiAppWithFeatures(core, .{ .runtime_markup = dev and !ts_view.enabled, .compiled_model = ts_view.enabled, .view_reload = view_reload_enabled });
|
|
83
80
|
const App = Adapter.App;
|
|
84
81
|
|
|
82
|
+
/// A Debug `native dev` build of compiled views (`-Dview-reload`)
|
|
83
|
+
/// stages the development view exports; every other build has neither the
|
|
84
|
+
/// exports nor this wiring.
|
|
85
|
+
const view_reload_enabled = dev and @hasDecl(core, "nativeDevViewPrepare");
|
|
86
|
+
var view_reload: if (view_reload_enabled) ViewReload else void = if (view_reload_enabled) .{} else {};
|
|
87
|
+
|
|
88
|
+
const ViewReload = struct {
|
|
89
|
+
driver: ?native_sdk.view_reload.Driver(core) = null,
|
|
90
|
+
|
|
91
|
+
/// Announce this session to the markup watcher and hook the app's
|
|
92
|
+
/// watch timer to its updates. Replays keep the views they recorded.
|
|
93
|
+
fn arm(self: *ViewReload, init: std.process.Init) void {
|
|
94
|
+
const dir = init.environ_map.get(native_sdk.view_reload.env_var) orelse return;
|
|
95
|
+
if (init.environ_map.get("NATIVE_SDK_SESSION_REPLAY") != null) return;
|
|
96
|
+
var session: [8]u8 = undefined;
|
|
97
|
+
init.io.random(&session);
|
|
98
|
+
self.driver = native_sdk.view_reload.Driver(core).init(std.heap.page_allocator, init.io, dir, std.mem.readInt(u64, &session, .little)) catch |err| {
|
|
99
|
+
std.debug.print("markup reload is off: could not open {s} ({t})\n", .{ dir, err });
|
|
100
|
+
return;
|
|
101
|
+
};
|
|
102
|
+
self.driver.?.announce(@embedFile("view_reload_contract.json")) catch |err| {
|
|
103
|
+
std.debug.print("markup reload is off: could not write {s}/{s} ({t})\n", .{ dir, native_sdk.view_reload.build_file, err });
|
|
104
|
+
self.disarm();
|
|
105
|
+
return;
|
|
106
|
+
};
|
|
107
|
+
native_sdk.view_reload.installed = self.driver.?.hook();
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
fn disarm(self: *ViewReload) void {
|
|
111
|
+
native_sdk.view_reload.installed = null;
|
|
112
|
+
if (self.driver) |*driver| driver.deinit();
|
|
113
|
+
self.driver = null;
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
|
|
85
117
|
const shell_scene = native_sdk.app_manifest.shellConfigFrom(manifest);
|
|
86
118
|
const canvas_label = native_sdk.app_manifest.firstGpuSurfaceLabel(shell_scene);
|
|
87
119
|
extern const native_sdk_app_markup: u8;
|
|
@@ -137,7 +169,7 @@ fn appOptions(io: ?std.Io) Adapter.Options {
|
|
|
137
169
|
.theme_accent = comptime runner.manifestThemeAccent(),
|
|
138
170
|
};
|
|
139
171
|
if (comptime ts_view.enabled) options.view = ts_view.buildRuntime else if (comptime !dev) options.view = CompiledAppView.build;
|
|
140
|
-
if (comptime
|
|
172
|
+
if (comptime core.has_windows) {
|
|
141
173
|
if (comptime ts_view.enabled) {
|
|
142
174
|
options.window_view = ts_view.buildRuntimeWindow;
|
|
143
175
|
} else {
|
|
@@ -370,6 +402,12 @@ pub fn main(init: std.process.Init) !void {
|
|
|
370
402
|
defer if (comptime manifestDeclaresPersist()) persist_restore_value.deinit(std.heap.page_allocator);
|
|
371
403
|
defer if (persist_coordinator_started) persist_coordinator_value.deinit();
|
|
372
404
|
|
|
405
|
+
// Markup reload from `native dev`: only a Debug build made with
|
|
406
|
+
// `-Dview-reload` has the development exports, and it arms only when
|
|
407
|
+
// the dev loop names its update directory.
|
|
408
|
+
if (comptime view_reload_enabled) view_reload.arm(init);
|
|
409
|
+
defer if (comptime view_reload_enabled) view_reload.disarm();
|
|
410
|
+
|
|
373
411
|
// The app struct (and any real model) is multi-MB: `create`
|
|
374
412
|
// heap-allocates and constructs in place, so neither rides the stack.
|
|
375
413
|
const app_state = try Adapter.create(std.heap.page_allocator, .{
|
|
@@ -101,7 +101,7 @@ pub fn initModel() Model {
|
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
pub fn mobileOptions() Adapter.Options {
|
|
104
|
-
if (comptime
|
|
104
|
+
if (comptime core.has_windows) {
|
|
105
105
|
@compileError("model-declared secondary windows are a desktop shell capability; omit windows(model) from mobile targets");
|
|
106
106
|
}
|
|
107
107
|
var options: Adapter.Options = .{
|
|
@@ -45,15 +45,15 @@ pub const Server = struct {
|
|
|
45
45
|
defer writer.deinit();
|
|
46
46
|
try snapshot.writeText(input_value, &writer.writer);
|
|
47
47
|
var path_buffer: [256]u8 = undefined;
|
|
48
|
-
try
|
|
48
|
+
try writePathAtomic(self.io, self.path("snapshot.txt", &path_buffer), writer.written());
|
|
49
49
|
var a11y_writer = try std.Io.Writer.Allocating.initCapacity(std.heap.page_allocator, snapshot_initial_capacity);
|
|
50
50
|
defer a11y_writer.deinit();
|
|
51
51
|
try snapshot.writeA11yText(input_value, &a11y_writer.writer);
|
|
52
|
-
try
|
|
52
|
+
try writePathAtomic(self.io, self.path("accessibility.txt", &path_buffer), a11y_writer.written());
|
|
53
53
|
var windows_writer = try std.Io.Writer.Allocating.initCapacity(std.heap.page_allocator, windows_initial_capacity);
|
|
54
54
|
defer windows_writer.deinit();
|
|
55
55
|
try snapshot.writeWindowsText(input_value, &windows_writer.writer);
|
|
56
|
-
try
|
|
56
|
+
try writePathAtomic(self.io, self.path("windows.txt", &path_buffer), windows_writer.written());
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
pub fn publishBridgeResponse(self: Server, response: []const u8) !void {
|
|
@@ -202,6 +202,15 @@ fn writePath(io: std.Io, path: []const u8, bytes: []const u8) !void {
|
|
|
202
202
|
try std.Io.Dir.cwd().writeFile(io, .{ .sub_path = path, .data = bytes });
|
|
203
203
|
}
|
|
204
204
|
|
|
205
|
+
/// Readers may hold a snapshot open while the next frame is published.
|
|
206
|
+
/// Replace the completed file so those readers keep their original bytes.
|
|
207
|
+
fn writePathAtomic(io: std.Io, path: []const u8, bytes: []const u8) !void {
|
|
208
|
+
var file = try std.Io.Dir.cwd().createFileAtomic(io, path, .{ .replace = true });
|
|
209
|
+
defer file.deinit(io);
|
|
210
|
+
try file.file.writePositionalAll(io, bytes, 0);
|
|
211
|
+
try file.replace(io);
|
|
212
|
+
}
|
|
213
|
+
|
|
205
214
|
fn readPath(io: std.Io, path: []const u8, buffer: []u8) ![]const u8 {
|
|
206
215
|
var file = try std.Io.Dir.cwd().openFile(io, path, .{});
|
|
207
216
|
defer file.close(io);
|
|
@@ -282,6 +291,50 @@ test "server publishes large retained widget snapshots" {
|
|
|
282
291
|
try std.testing.expect(std.mem.indexOf(u8, a11y, "@w1/components-canvas#1079 role=textbox") != null);
|
|
283
292
|
}
|
|
284
293
|
|
|
294
|
+
test "server snapshot readers retain a complete version across publication" {
|
|
295
|
+
const directory = ".zig-cache/test-webview-automation-snapshot-replacement";
|
|
296
|
+
try resetTestDirectory(std.testing.io, directory);
|
|
297
|
+
defer std.Io.Dir.cwd().deleteTree(std.testing.io, directory) catch {};
|
|
298
|
+
|
|
299
|
+
const server = Server.init(std.testing.io, directory, "Test");
|
|
300
|
+
const old_windows = [_]snapshot.Window{.{
|
|
301
|
+
.title = "Previous snapshot " ** 1024,
|
|
302
|
+
.bounds = geometry.RectF.init(0, 0, 720, 520),
|
|
303
|
+
}};
|
|
304
|
+
const new_windows = [_]snapshot.Window{.{
|
|
305
|
+
.title = "Replacement snapshot",
|
|
306
|
+
.bounds = geometry.RectF.init(0, 0, 640, 480),
|
|
307
|
+
}};
|
|
308
|
+
const replacement: snapshot.Input = .{ .windows = &new_windows };
|
|
309
|
+
|
|
310
|
+
inline for (.{ "snapshot.txt", "accessibility.txt", "windows.txt" }, 0..) |name, index| {
|
|
311
|
+
try server.publish(.{ .windows = &old_windows });
|
|
312
|
+
var path_buffer: [256]u8 = undefined;
|
|
313
|
+
const file_path = server.path(name, &path_buffer);
|
|
314
|
+
var previous_buffer: [32 * 1024]u8 = undefined;
|
|
315
|
+
const previous = try readPath(std.testing.io, file_path, &previous_buffer);
|
|
316
|
+
var reader = try std.Io.Dir.cwd().openFile(std.testing.io, file_path, .{});
|
|
317
|
+
defer reader.close(std.testing.io);
|
|
318
|
+
|
|
319
|
+
try server.publish(replacement);
|
|
320
|
+
var held_buffer: [32 * 1024]u8 = undefined;
|
|
321
|
+
const held = held_buffer[0..try reader.readPositionalAll(std.testing.io, &held_buffer, 0)];
|
|
322
|
+
try std.testing.expectEqualStrings(previous, held);
|
|
323
|
+
|
|
324
|
+
var expected: std.Io.Writer.Allocating = .init(std.testing.allocator);
|
|
325
|
+
defer expected.deinit();
|
|
326
|
+
switch (index) {
|
|
327
|
+
0 => try snapshot.writeText(replacement, &expected.writer),
|
|
328
|
+
1 => try snapshot.writeA11yText(replacement, &expected.writer),
|
|
329
|
+
2 => try snapshot.writeWindowsText(replacement, &expected.writer),
|
|
330
|
+
else => unreachable,
|
|
331
|
+
}
|
|
332
|
+
var current_buffer: [32 * 1024]u8 = undefined;
|
|
333
|
+
const current = try readPath(std.testing.io, file_path, ¤t_buffer);
|
|
334
|
+
try std.testing.expectEqualStrings(expected.written(), current);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
285
338
|
test "server writes screenshot artifacts atomically" {
|
|
286
339
|
const directory = ".zig-cache/test-webview-automation-screenshot";
|
|
287
340
|
try resetTestDirectory(std.testing.io, directory);
|
package/src/embed/host.zig
CHANGED
|
@@ -835,7 +835,9 @@ pub const MobileHostApp = struct {
|
|
|
835
835
|
// decoder yet, and the null platform's fake player belongs to
|
|
836
836
|
// hermetic tests — a load that "succeeds" but never decodes
|
|
837
837
|
// would be a lie. Apps hear one honest failed event instead.
|
|
838
|
+
self.null_platform.global_shortcuts = false;
|
|
838
839
|
self.null_platform.video_playback = false;
|
|
840
|
+
self.null_platform.keyboard_input = false;
|
|
839
841
|
self.last_error = null;
|
|
840
842
|
self.activation_count = 0;
|
|
841
843
|
self.deactivation_count = 0;
|
package/src/embed/tests.zig
CHANGED
|
@@ -2041,6 +2041,8 @@ test "mobile hosts decline audio until the shim registers a service" {
|
|
|
2041
2041
|
// the runtime's service table carries no audio entries.
|
|
2042
2042
|
try std.testing.expect(!self.embedded.runtime.options.platform.supports(.audio_playback));
|
|
2043
2043
|
try std.testing.expect(!self.embedded.runtime.options.platform.supports(.audio_streaming));
|
|
2044
|
+
try std.testing.expect(!self.embedded.runtime.options.platform.supports(.global_shortcuts));
|
|
2045
|
+
try std.testing.expect(!self.embedded.runtime.options.platform.supports(.keyboard_input));
|
|
2044
2046
|
try std.testing.expect(self.embedded.runtime.options.platform.services.audio_load_fn == null);
|
|
2045
2047
|
|
|
2046
2048
|
try startAudioHost(app);
|
package/src/embed/ui_host.zig
CHANGED
|
@@ -200,6 +200,7 @@ pub fn UiAppHostWithStorageCredentialsAndImages(
|
|
|
200
200
|
.bundle_id = credentials_service,
|
|
201
201
|
});
|
|
202
202
|
self.null_platform.gpu_surfaces = true;
|
|
203
|
+
self.null_platform.keyboard_input = false;
|
|
203
204
|
// Audio is declined until the shim registers a real service
|
|
204
205
|
// (`native_sdk_app_set_audio_service`): without one,
|
|
205
206
|
// `fx.playAudio` degrades to one explicit `.failed` Msg
|
|
@@ -210,6 +211,7 @@ pub fn UiAppHostWithStorageCredentialsAndImages(
|
|
|
210
211
|
self.null_platform.audio_streaming = false;
|
|
211
212
|
self.null_platform.microphone_capture = false;
|
|
212
213
|
self.null_platform.system_audio_capture = false;
|
|
214
|
+
self.null_platform.global_shortcuts = false;
|
|
213
215
|
// The null packet presenter records only counts; disabling it
|
|
214
216
|
// routes presentation through the CPU pixel path so frames
|
|
215
217
|
// produce real pixels (the buffer M2's surface blit consumes).
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//! Keyboard input shared by every host: the parsed key vocabulary, chords, and access status.
|
|
2
|
+
const std = @import("std");
|
|
3
|
+
const types = @import("types.zig");
|
|
4
|
+
|
|
5
|
+
/// One key press, posted as key down then key up with exactly these modifiers.
|
|
6
|
+
pub const KeyChord = struct {
|
|
7
|
+
name: [types.max_shortcut_key_bytes]u8 = @splat(0),
|
|
8
|
+
name_len: u8 = 0,
|
|
9
|
+
modifiers: types.ShortcutModifiers = .{},
|
|
10
|
+
|
|
11
|
+
/// Builds a chord from a shortcut-vocabulary key name, lowercased; null for any name `isValidShortcutKey` rejects.
|
|
12
|
+
pub fn init(key_name: []const u8, modifiers: types.ShortcutModifiers) ?KeyChord {
|
|
13
|
+
if (!types.isValidShortcutKey(key_name)) return null;
|
|
14
|
+
var chord: KeyChord = .{ .name_len = @intCast(key_name.len), .modifiers = modifiers };
|
|
15
|
+
_ = std.ascii.lowerString(&chord.name, key_name);
|
|
16
|
+
return chord;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
pub fn key(self: *const KeyChord) []const u8 {
|
|
20
|
+
return self.name[0..self.name_len];
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/// Whether the OS delivers input this process synthesizes; `not_required` means no grant exists to ask for.
|
|
25
|
+
pub const Access = enum { granted, denied, not_required };
|
|
26
|
+
|
|
27
|
+
test "chords keep the lowercased shortcut key and reject other names" {
|
|
28
|
+
try std.testing.expectEqualStrings("arrowleft", KeyChord.init("ArrowLeft", .{}).?.key());
|
|
29
|
+
for ([_][]const u8{ "", "f13", "ctrl", "vv", " ", "arrowleft " }) |name| {
|
|
30
|
+
try std.testing.expectEqual(@as(?KeyChord, null), KeyChord.init(name, .{}));
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -401,9 +401,11 @@ int native_sdk_update_verify_archive(const char *path, size_t path_len, uint64_t
|
|
|
401
401
|
// About panel, which also shows version and about_description when
|
|
402
402
|
// non-empty. has_web_content declares whether the app hosts a webview;
|
|
403
403
|
// web-only default menu items (Reload, Toggle Web Inspector, Undo/Redo)
|
|
404
|
-
// exist only when it is set.
|
|
404
|
+
// exist only when it is set. webview_inspection explicitly permits developer
|
|
405
|
+
// extras, the inspector menu, and Safari inspection for every system WebView;
|
|
406
|
+
// set it before creation. dock_visible selects Regular (nonzero) or
|
|
405
407
|
// Accessory (zero) before application configuration and window creation.
|
|
406
|
-
native_sdk_appkit_host_t *native_sdk_appkit_create(const char *app_name, size_t app_name_len, const char *display_name, size_t display_name_len, const char *version, size_t version_len, const char *about_description, size_t about_description_len, int has_web_content, int dock_visible, const char *window_title, size_t window_title_len, const char *bundle_id, size_t bundle_id_len, const char *icon_path, size_t icon_path_len, const char *window_label, size_t window_label_len, double x, double y, double width, double height, int restore_frame, int initial_placement, int restore_policy, int resizable, int titlebar_style, int show_policy, uint32_t window_flags);
|
|
408
|
+
native_sdk_appkit_host_t *native_sdk_appkit_create(const char *app_name, size_t app_name_len, const char *display_name, size_t display_name_len, const char *version, size_t version_len, const char *about_description, size_t about_description_len, int has_web_content, int webview_inspection, int dock_visible, const char *window_title, size_t window_title_len, const char *bundle_id, size_t bundle_id_len, const char *icon_path, size_t icon_path_len, const char *window_label, size_t window_label_len, double x, double y, double width, double height, int restore_frame, int initial_placement, int restore_policy, int resizable, int titlebar_style, int show_policy, uint32_t window_flags);
|
|
407
409
|
void native_sdk_appkit_destroy(native_sdk_appkit_host_t *host);
|
|
408
410
|
// Adopt pre-rendered straight-alpha RGBA8 pixels as the Dock icon (and
|
|
409
411
|
// the About panel copy). The pixels are copied before return, so the
|
|
@@ -450,6 +452,9 @@ int native_sdk_appkit_create_window(native_sdk_appkit_host_t *host, uint64_t win
|
|
|
450
452
|
// AppKit's default minimum. Returns 0 when the window id is unknown.
|
|
451
453
|
int native_sdk_appkit_set_window_content_min_size(native_sdk_appkit_host_t *host, uint64_t window_id, double min_width, double min_height);
|
|
452
454
|
int native_sdk_appkit_focus_window(native_sdk_appkit_host_t *host, uint64_t window_id);
|
|
455
|
+
// 0 follows the system, 1 forces Aqua, 2 forces Dark Aqua. Window-scoped;
|
|
456
|
+
// NSApp.effectiveAppearance remains the source of system appearance events.
|
|
457
|
+
int native_sdk_appkit_set_window_color_scheme(native_sdk_appkit_host_t *host, uint64_t window_id, int color_scheme);
|
|
453
458
|
int native_sdk_appkit_close_window(native_sdk_appkit_host_t *host, uint64_t window_id);
|
|
454
459
|
// The real OS minimize verb (NSWindow miniaturize:), for app-drawn
|
|
455
460
|
// window controls on chromeless windows. Returns 0 when the window id
|
|
@@ -1016,6 +1016,8 @@ static int NativeSdkCredentialStatus(OSStatus status, int missingCode) {
|
|
|
1016
1016
|
* menu items (Reload, Toggle Web Inspector, Undo/Redo) so canvas-only
|
|
1017
1017
|
* apps never ship menu items nothing answers. */
|
|
1018
1018
|
@property(nonatomic, assign) BOOL hasWebContent;
|
|
1019
|
+
/* Set before any WebView or default menu is created. */
|
|
1020
|
+
@property(nonatomic, assign) BOOL webViewInspection;
|
|
1019
1021
|
/* The decoded manifest icon (nil until the async decode lands, or when
|
|
1020
1022
|
* the file is missing). The About panel needs it passed explicitly:
|
|
1021
1023
|
* unbundled dev binaries have no bundle icon for the standard panel to
|
|
@@ -1061,7 +1063,7 @@ static int NativeSdkCredentialStatus(OSStatus status, int missingCode) {
|
|
|
1061
1063
|
@property(nonatomic, strong) NSArray<NSString *> *allowedNavigationOrigins;
|
|
1062
1064
|
@property(nonatomic, strong) NSArray<NSString *> *allowedExternalURLs;
|
|
1063
1065
|
@property(nonatomic, assign) NSInteger externalLinkAction;
|
|
1064
|
-
- (instancetype)initWithAppName:(NSString *)appName displayName:(NSString *)displayName version:(NSString *)version aboutDescription:(NSString *)aboutDescription hasWebContent:(BOOL)hasWebContent dockVisible:(BOOL)dockVisible windowTitle:(NSString *)windowTitle bundleIdentifier:(NSString *)bundleIdentifier iconPath:(NSString *)iconPath windowLabel:(NSString *)windowLabel x:(double)x y:(double)y width:(double)width height:(double)height restoreFrame:(BOOL)restoreFrame initialPlacement:(int)initialPlacement restorePolicy:(int)restorePolicy resizable:(BOOL)resizable titlebarStyle:(int)titlebarStyle showPolicy:(int)showPolicy windowFlags:(uint32_t)windowFlags;
|
|
1066
|
+
- (instancetype)initWithAppName:(NSString *)appName displayName:(NSString *)displayName version:(NSString *)version aboutDescription:(NSString *)aboutDescription hasWebContent:(BOOL)hasWebContent webViewInspection:(BOOL)webViewInspection dockVisible:(BOOL)dockVisible windowTitle:(NSString *)windowTitle bundleIdentifier:(NSString *)bundleIdentifier iconPath:(NSString *)iconPath windowLabel:(NSString *)windowLabel x:(double)x y:(double)y width:(double)width height:(double)height restoreFrame:(BOOL)restoreFrame initialPlacement:(int)initialPlacement restorePolicy:(int)restorePolicy resizable:(BOOL)resizable titlebarStyle:(int)titlebarStyle showPolicy:(int)showPolicy windowFlags:(uint32_t)windowFlags;
|
|
1065
1067
|
- (BOOL)createWindowWithId:(uint64_t)windowId title:(NSString *)title label:(NSString *)label x:(double)x y:(double)y width:(double)width height:(double)height restoreFrame:(BOOL)restoreFrame initialPlacement:(int)initialPlacement restorePolicy:(int)restorePolicy resizable:(BOOL)resizable titlebarStyle:(int)titlebarStyle showPolicy:(int)showPolicy windowFlags:(uint32_t)windowFlags makeMain:(BOOL)makeMain;
|
|
1066
1068
|
- (void)orderWindowForImplicitShow:(uint64_t)windowId;
|
|
1067
1069
|
- (void)showDeferredWindowIfPending:(uint64_t)windowId reason:(const char *)reason;
|
|
@@ -8086,7 +8088,7 @@ static float NativeSdkCaptureReadRemixedSample(const AudioBufferList *buffers, c
|
|
|
8086
8088
|
|
|
8087
8089
|
@implementation NativeSdkAppKitHost
|
|
8088
8090
|
|
|
8089
|
-
- (instancetype)initWithAppName:(NSString *)appName displayName:(NSString *)displayName version:(NSString *)version aboutDescription:(NSString *)aboutDescription hasWebContent:(BOOL)hasWebContent dockVisible:(BOOL)dockVisible windowTitle:(NSString *)windowTitle bundleIdentifier:(NSString *)bundleIdentifier iconPath:(NSString *)iconPath windowLabel:(NSString *)windowLabel x:(double)x y:(double)y width:(double)width height:(double)height restoreFrame:(BOOL)restoreFrame initialPlacement:(int)initialPlacement restorePolicy:(int)restorePolicy resizable:(BOOL)resizable titlebarStyle:(int)titlebarStyle showPolicy:(int)showPolicy windowFlags:(uint32_t)windowFlags {
|
|
8091
|
+
- (instancetype)initWithAppName:(NSString *)appName displayName:(NSString *)displayName version:(NSString *)version aboutDescription:(NSString *)aboutDescription hasWebContent:(BOOL)hasWebContent webViewInspection:(BOOL)webViewInspection dockVisible:(BOOL)dockVisible windowTitle:(NSString *)windowTitle bundleIdentifier:(NSString *)bundleIdentifier iconPath:(NSString *)iconPath windowLabel:(NSString *)windowLabel x:(double)x y:(double)y width:(double)width height:(double)height restoreFrame:(BOOL)restoreFrame initialPlacement:(int)initialPlacement restorePolicy:(int)restorePolicy resizable:(BOOL)resizable titlebarStyle:(int)titlebarStyle showPolicy:(int)showPolicy windowFlags:(uint32_t)windowFlags {
|
|
8090
8092
|
self = [super init];
|
|
8091
8093
|
if (!self) {
|
|
8092
8094
|
return nil;
|
|
@@ -8104,6 +8106,7 @@ static float NativeSdkCaptureReadRemixedSample(const AudioBufferList *buffers, c
|
|
|
8104
8106
|
self.appVersion = version ?: @"";
|
|
8105
8107
|
self.aboutDescription = aboutDescription ?: @"";
|
|
8106
8108
|
self.hasWebContent = hasWebContent;
|
|
8109
|
+
self.webViewInspection = webViewInspection;
|
|
8107
8110
|
NSString *configuredBundleIdentifier = bundleIdentifier.length > 0 ? bundleIdentifier : @"dev.native_sdk.app";
|
|
8108
8111
|
self.bundleIdentifier = NativeSdkPackagedBundleIdentifier() ?: configuredBundleIdentifier;
|
|
8109
8112
|
self.iconPath = iconPath ?: @"";
|
|
@@ -8643,7 +8646,7 @@ static float NativeSdkCaptureReadRemixedSample(const AudioBufferList *buffers, c
|
|
|
8643
8646
|
[userContentController addUserScript:bridgeScript];
|
|
8644
8647
|
configuration.userContentController = userContentController;
|
|
8645
8648
|
if ([configuration.preferences respondsToSelector:NSSelectorFromString(@"setDeveloperExtrasEnabled:")]) {
|
|
8646
|
-
[configuration.preferences setValue:@
|
|
8649
|
+
[configuration.preferences setValue:@(self.webViewInspection) forKey:@"developerExtrasEnabled"];
|
|
8647
8650
|
}
|
|
8648
8651
|
WKWebView *webView = [[NativeSdkWebView alloc] initWithFrame:container.bounds configuration:configuration];
|
|
8649
8652
|
((NativeSdkWebView *)webView).host = self;
|
|
@@ -8655,7 +8658,7 @@ static float NativeSdkCaptureReadRemixedSample(const AudioBufferList *buffers, c
|
|
|
8655
8658
|
webView.layer.backgroundColor = NSColor.clearColor.CGColor;
|
|
8656
8659
|
[webView setValue:@NO forKey:@"drawsBackground"];
|
|
8657
8660
|
if ([webView respondsToSelector:NSSelectorFromString(@"setInspectable:")]) {
|
|
8658
|
-
[webView setValue:@
|
|
8661
|
+
[webView setValue:@(self.webViewInspection) forKey:@"inspectable"];
|
|
8659
8662
|
}
|
|
8660
8663
|
webView.navigationDelegate = self;
|
|
8661
8664
|
webView.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
|
|
@@ -9326,7 +9329,7 @@ static float NativeSdkCaptureReadRemixedSample(const AudioBufferList *buffers, c
|
|
|
9326
9329
|
configuration.userContentController = controller;
|
|
9327
9330
|
}
|
|
9328
9331
|
if ([configuration.preferences respondsToSelector:NSSelectorFromString(@"setDeveloperExtrasEnabled:")]) {
|
|
9329
|
-
[configuration.preferences setValue:@
|
|
9332
|
+
[configuration.preferences setValue:@(self.webViewInspection) forKey:@"developerExtrasEnabled"];
|
|
9330
9333
|
}
|
|
9331
9334
|
|
|
9332
9335
|
WKWebView *webview = [[NativeSdkWebView alloc] initWithFrame:[self webViewFrameForWindow:window x:x y:y width:width height:height] configuration:configuration];
|
|
@@ -9341,7 +9344,7 @@ static float NativeSdkCaptureReadRemixedSample(const AudioBufferList *buffers, c
|
|
|
9341
9344
|
[webview setValue:@NO forKey:@"drawsBackground"];
|
|
9342
9345
|
}
|
|
9343
9346
|
if ([webview respondsToSelector:NSSelectorFromString(@"setInspectable:")]) {
|
|
9344
|
-
[webview setValue:@
|
|
9347
|
+
[webview setValue:@(self.webViewInspection) forKey:@"inspectable"];
|
|
9345
9348
|
}
|
|
9346
9349
|
webview.navigationDelegate = self;
|
|
9347
9350
|
webview.autoresizingMask = NSViewNotSizable;
|
|
@@ -10044,7 +10047,9 @@ static void NativeSdkApplyProcessDisplayName(NSString *displayName) {
|
|
|
10044
10047
|
[viewMenuItem setSubmenu:viewMenu];
|
|
10045
10048
|
if (self.hasWebContent) {
|
|
10046
10049
|
[viewMenu addItem:[self menuItem:@"Reload" action:@selector(reload:) key:@"r" modifiers:NSEventModifierFlagCommand]];
|
|
10047
|
-
|
|
10050
|
+
if (self.webViewInspection) {
|
|
10051
|
+
[viewMenu addItem:[self menuItem:@"Toggle Web Inspector" action:@selector(toggleWebInspector:) key:@"i" modifiers:(NSEventModifierFlagCommand | NSEventModifierFlagOption)]];
|
|
10052
|
+
}
|
|
10048
10053
|
[viewMenu addItem:[NSMenuItem separatorItem]];
|
|
10049
10054
|
}
|
|
10050
10055
|
[viewMenu addItem:[self menuItem:@"Enter Full Screen" action:@selector(toggleFullScreen:) key:@"f" modifiers:(NSEventModifierFlagCommand | NSEventModifierFlagControl)]];
|
|
@@ -12852,6 +12857,7 @@ static void NativeSdkVideoFittedSize(double naturalWidth, double naturalHeight,
|
|
|
12852
12857
|
|
|
12853
12858
|
- (void)toggleWebInspector:(id)sender {
|
|
12854
12859
|
(void)sender;
|
|
12860
|
+
if (!self.webViewInspection) return;
|
|
12855
12861
|
WKWebView *webView = [self mainWebViewForWindow:NSApp.keyWindow];
|
|
12856
12862
|
if (!webView) return;
|
|
12857
12863
|
SEL selector = NSSelectorFromString(@"_showInspector");
|
|
@@ -13114,7 +13120,7 @@ static BOOL NativeSdkPolicyListMatches(NSArray<NSString *> *values, NSURL *url)
|
|
|
13114
13120
|
return NO;
|
|
13115
13121
|
}
|
|
13116
13122
|
|
|
13117
|
-
native_sdk_appkit_host_t *native_sdk_appkit_create(const char *app_name, size_t app_name_len, const char *display_name, size_t display_name_len, const char *version, size_t version_len, const char *about_description, size_t about_description_len, int has_web_content, int dock_visible, const char *window_title, size_t window_title_len, const char *bundle_id, size_t bundle_id_len, const char *icon_path, size_t icon_path_len, const char *window_label, size_t window_label_len, double x, double y, double width, double height, int restore_frame, int initial_placement, int restore_policy, int resizable, int titlebar_style, int show_policy, uint32_t window_flags) {
|
|
13123
|
+
native_sdk_appkit_host_t *native_sdk_appkit_create(const char *app_name, size_t app_name_len, const char *display_name, size_t display_name_len, const char *version, size_t version_len, const char *about_description, size_t about_description_len, int has_web_content, int webview_inspection, int dock_visible, const char *window_title, size_t window_title_len, const char *bundle_id, size_t bundle_id_len, const char *icon_path, size_t icon_path_len, const char *window_label, size_t window_label_len, double x, double y, double width, double height, int restore_frame, int initial_placement, int restore_policy, int resizable, int titlebar_style, int show_policy, uint32_t window_flags) {
|
|
13118
13124
|
@autoreleasepool {
|
|
13119
13125
|
NSString *appNameString = [[NSString alloc] initWithBytes:app_name length:app_name_len encoding:NSUTF8StringEncoding] ?: @"native-sdk";
|
|
13120
13126
|
NSString *displayNameString = [[NSString alloc] initWithBytes:display_name length:display_name_len encoding:NSUTF8StringEncoding] ?: @"";
|
|
@@ -13124,7 +13130,7 @@ native_sdk_appkit_host_t *native_sdk_appkit_create(const char *app_name, size_t
|
|
|
13124
13130
|
NSString *bundleIdString = [[NSString alloc] initWithBytes:bundle_id length:bundle_id_len encoding:NSUTF8StringEncoding] ?: @"dev.native_sdk.app";
|
|
13125
13131
|
NSString *iconPathString = [[NSString alloc] initWithBytes:icon_path length:icon_path_len encoding:NSUTF8StringEncoding] ?: @"";
|
|
13126
13132
|
NSString *windowLabelString = [[NSString alloc] initWithBytes:window_label length:window_label_len encoding:NSUTF8StringEncoding] ?: @"main";
|
|
13127
|
-
NativeSdkAppKitHost *host = [[NativeSdkAppKitHost alloc] initWithAppName:appNameString displayName:displayNameString version:versionString aboutDescription:aboutDescriptionString hasWebContent:(has_web_content != 0) dockVisible:(dock_visible != 0) windowTitle:windowTitleString bundleIdentifier:bundleIdString iconPath:iconPathString windowLabel:windowLabelString x:x y:y width:width height:height restoreFrame:(restore_frame != 0) initialPlacement:initial_placement restorePolicy:restore_policy resizable:(resizable != 0) titlebarStyle:titlebar_style showPolicy:show_policy windowFlags:window_flags];
|
|
13133
|
+
NativeSdkAppKitHost *host = [[NativeSdkAppKitHost alloc] initWithAppName:appNameString displayName:displayNameString version:versionString aboutDescription:aboutDescriptionString hasWebContent:(has_web_content != 0) webViewInspection:(webview_inspection != 0) dockVisible:(dock_visible != 0) windowTitle:windowTitleString bundleIdentifier:bundleIdString iconPath:iconPathString windowLabel:windowLabelString x:x y:y width:width height:height restoreFrame:(restore_frame != 0) initialPlacement:initial_placement restorePolicy:restore_policy resizable:(resizable != 0) titlebarStyle:titlebar_style showPolicy:show_policy windowFlags:window_flags];
|
|
13128
13134
|
return (__bridge_retained native_sdk_appkit_host_t *)host;
|
|
13129
13135
|
}
|
|
13130
13136
|
}
|
|
@@ -13489,6 +13495,22 @@ int native_sdk_appkit_focus_window(native_sdk_appkit_host_t *host, uint64_t wind
|
|
|
13489
13495
|
return 1;
|
|
13490
13496
|
}
|
|
13491
13497
|
|
|
13498
|
+
int native_sdk_appkit_set_window_color_scheme(native_sdk_appkit_host_t *host, uint64_t window_id, int color_scheme) {
|
|
13499
|
+
NativeSdkAppKitHost *object = (__bridge NativeSdkAppKitHost *)host;
|
|
13500
|
+
NSWindow *window = object.windows[@(window_id)];
|
|
13501
|
+
if (!window || color_scheme < 0 || color_scheme > 2) return 0;
|
|
13502
|
+
NSAppearance *appearance = color_scheme == 0 ? nil : [NSAppearance appearanceNamed:
|
|
13503
|
+
color_scheme == 2 ? NSAppearanceNameDarkAqua : NSAppearanceNameAqua];
|
|
13504
|
+
if (window.appearance == appearance || [window.appearance isEqual:appearance]) return 1;
|
|
13505
|
+
// Keep NSApp's effective appearance untouched: the runtime must still
|
|
13506
|
+
// observe real OS changes while the app forces a window's scheme.
|
|
13507
|
+
window.appearance = appearance;
|
|
13508
|
+
// The canvas present owns backgroundColor (including transparent clear
|
|
13509
|
+
// colors). Changing appearance must not overwrite that retained color.
|
|
13510
|
+
[window.contentView setNeedsDisplay:YES];
|
|
13511
|
+
return 1;
|
|
13512
|
+
}
|
|
13513
|
+
|
|
13492
13514
|
int native_sdk_appkit_close_window(native_sdk_appkit_host_t *host, uint64_t window_id) {
|
|
13493
13515
|
NativeSdkAppKitHost *object = (__bridge NativeSdkAppKitHost *)host;
|
|
13494
13516
|
if (!object.windows[@(window_id)]) return 0;
|
|
@@ -2435,7 +2435,7 @@ static void NativeSdkApplyOverlayWindowFlags(NativeSdkChromiumHost *host, uint64
|
|
|
2435
2435
|
}
|
|
2436
2436
|
}
|
|
2437
2437
|
|
|
2438
|
-
native_sdk_appkit_host_t *native_sdk_appkit_create(const char *app_name, size_t app_name_len, const char *display_name, size_t display_name_len, const char *version, size_t version_len, const char *about_description, size_t about_description_len, int has_web_content, int dock_visible, const char *window_title, size_t window_title_len, const char *bundle_id, size_t bundle_id_len, const char *icon_path, size_t icon_path_len, const char *window_label, size_t window_label_len, double x, double y, double width, double height, int restore_frame, int initial_placement, int restore_policy, int resizable, int titlebar_style, int show_policy, uint32_t window_flags) {
|
|
2438
|
+
native_sdk_appkit_host_t *native_sdk_appkit_create(const char *app_name, size_t app_name_len, const char *display_name, size_t display_name_len, const char *version, size_t version_len, const char *about_description, size_t about_description_len, int has_web_content, int webview_inspection, int dock_visible, const char *window_title, size_t window_title_len, const char *bundle_id, size_t bundle_id_len, const char *icon_path, size_t icon_path_len, const char *window_label, size_t window_label_len, double x, double y, double width, double height, int restore_frame, int initial_placement, int restore_policy, int resizable, int titlebar_style, int show_policy, uint32_t window_flags) {
|
|
2439
2439
|
@autoreleasepool {
|
|
2440
2440
|
// A windowed CEF child cannot paint transparent pixels into its
|
|
2441
2441
|
// parent NSWindow. Refuse instead of accepting a flag that leaves
|
|
@@ -2451,6 +2451,7 @@ native_sdk_appkit_host_t *native_sdk_appkit_create(const char *app_name, size_t
|
|
|
2451
2451
|
// has_web_content is likewise ABI parity: this host always
|
|
2452
2452
|
// hosts web content, and its menus already assume it.
|
|
2453
2453
|
(void)has_web_content;
|
|
2454
|
+
(void)webview_inspection;
|
|
2454
2455
|
(void)bundle_id;
|
|
2455
2456
|
(void)bundle_id_len;
|
|
2456
2457
|
(void)icon_path;
|
|
@@ -2753,6 +2754,19 @@ int native_sdk_appkit_focus_window(native_sdk_appkit_host_t *host, uint64_t wind
|
|
|
2753
2754
|
return 1;
|
|
2754
2755
|
}
|
|
2755
2756
|
|
|
2757
|
+
int native_sdk_appkit_set_window_color_scheme(native_sdk_appkit_host_t *host, uint64_t window_id, int color_scheme) {
|
|
2758
|
+
NativeSdkChromiumHost *object = (__bridge NativeSdkChromiumHost *)host;
|
|
2759
|
+
NSWindow *window = object.windows[@(window_id)];
|
|
2760
|
+
if (!window || color_scheme < 0 || color_scheme > 2) return 0;
|
|
2761
|
+
NSAppearance *appearance = color_scheme == 0 ? nil : [NSAppearance appearanceNamed:
|
|
2762
|
+
color_scheme == 2 ? NSAppearanceNameDarkAqua : NSAppearanceNameAqua];
|
|
2763
|
+
if (window.appearance == appearance || [window.appearance isEqual:appearance]) return 1;
|
|
2764
|
+
// Keep system observation independent from the app's window override.
|
|
2765
|
+
window.appearance = appearance;
|
|
2766
|
+
[window.contentView setNeedsDisplay:YES];
|
|
2767
|
+
return 1;
|
|
2768
|
+
}
|
|
2769
|
+
|
|
2756
2770
|
int native_sdk_appkit_close_window(native_sdk_appkit_host_t *host, uint64_t window_id) {
|
|
2757
2771
|
NativeSdkChromiumHost *object = (__bridge NativeSdkChromiumHost *)host;
|
|
2758
2772
|
if (!object.windows[@(window_id)]) return 0;
|