@native-sdk/cli 0.8.4 → 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 +859 -62
- package/build.zig +543 -13
- package/build.zig.zon +1 -0
- package/native-sdk.d.ts +2 -0
- package/package.json +12 -11
- package/packages/core/compile-surface/core.ts +365 -2
- 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 +149 -0
- package/packages/core/sdk/core.ts +529 -12
- package/packages/core/sdk/events.d.ts +36 -0
- package/packages/core/sdk/events.ts +57 -0
- package/packages/core/src/checker.ts +468 -15
- package/packages/core/src/cli.ts +143 -3
- package/packages/core/src/contract.ts +26 -5
- package/packages/core/src/devhost.ts +1847 -16
- 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 +82 -16
- 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/references/project-anatomy.md +1 -1
- package/skill-data/native-ui/SKILL.md +47 -0
- package/skill-data/ts-core/SKILL.md +80 -31
- 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 +249 -8
- 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 +109 -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 +119 -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 +40 -18
- package/src/platform/macos/appkit_host.h +16 -3
- package/src/platform/macos/appkit_host.m +536 -36
- package/src/platform/macos/cef_host.mm +248 -36
- package/src/platform/macos/root.zig +244 -34
- package/src/platform/null_platform.zig +223 -19
- package/src/platform/null_platform_tests.zig +74 -0
- package/src/platform/root.zig +9 -0
- package/src/platform/types.zig +179 -15
- package/src/platform/windows/root.zig +187 -21
- package/src/platform/windows/webview2_host.cpp +293 -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 +32 -0
- package/src/primitives/app_manifest/validation.zig +19 -1
- package/src/root.zig +46 -0
- package/src/runtime/api.zig +11 -0
- package/src/runtime/automation_snapshot.zig +4 -0
- package/src/runtime/bridge_permission_tests.zig +23 -2
- package/src/runtime/bridge_responses.zig +3 -1
- package/src/runtime/canvas_frame.zig +18 -11
- package/src/runtime/canvas_frame_animation_tests.zig +4 -0
- 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 +2295 -113
- 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 +49 -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 +4 -0
- package/src/runtime/ts_core_host.zig +788 -86
- package/src/runtime/ts_core_host_tests.zig +231 -11
- package/src/runtime/ts_ui_app.zig +499 -1
- package/src/runtime/ui_app.zig +142 -16
- package/src/runtime/ui_app_tests.zig +155 -5
- package/src/runtime/validation.zig +22 -0
- package/src/runtime/view.zig +9 -0
- 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 +214 -2
- package/src/tooling/package.zig +116 -0
- package/src/tooling/raw_manifest.zig +30 -0
- package/src/tooling/root.zig +1 -0
- package/src/tooling/templates.zig +161 -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 +378 -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
|
@@ -5,7 +5,17 @@
|
|
|
5
5
|
//! (window 1, label "mobile-surface").
|
|
6
6
|
|
|
7
7
|
const native_sdk = @import("native_sdk");
|
|
8
|
+
const mobile_build_options = @import("mobile_build_options");
|
|
9
|
+
const relational_migrations = @import("relational_migrations");
|
|
8
10
|
|
|
9
11
|
comptime {
|
|
10
|
-
native_sdk.embed.exportMobileCApi(native_sdk.embed.
|
|
12
|
+
native_sdk.embed.exportMobileCApi(native_sdk.embed.UiAppHostWithStorageAndCredentials(
|
|
13
|
+
@import("app"),
|
|
14
|
+
mobile_build_options.store_capability,
|
|
15
|
+
mobile_build_options.relational_capability,
|
|
16
|
+
&relational_migrations.migrations,
|
|
17
|
+
mobile_build_options.credentials_capability,
|
|
18
|
+
mobile_build_options.credentials_permission,
|
|
19
|
+
mobile_build_options.credentials_service,
|
|
20
|
+
));
|
|
11
21
|
}
|
package/src/embed/c_api.zig
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
//! for a host type: the fixed WebView shell (`MobileHostApp`, this module's
|
|
5
5
|
//! re-exported default) or a user-app canvas host
|
|
6
6
|
//! (`ui_host.UiAppHost(AppDef)` in libs built via `addMobileLib`). A host
|
|
7
|
-
//! must expose `create`/`destroy`/`start`/`frame
|
|
7
|
+
//! must expose `create`/`destroy`/`start`/`frame` (`destroy` reports whether
|
|
8
|
+
//! callback context must survive), an `embedded`
|
|
8
9
|
//! `EmbeddedApp`, and the error/command/asset bookkeeping fields both
|
|
9
10
|
//! hosts share. `exportMobileCApi(Host)` exports every function under its
|
|
10
11
|
//! canonical symbol name for a static library root.
|
|
@@ -57,7 +58,16 @@ pub fn MobileCApi(comptime Host: type) type {
|
|
|
57
58
|
|
|
58
59
|
pub fn native_sdk_app_destroy(app: ?*anyopaque) callconv(.c) void {
|
|
59
60
|
const self = hostApp(Host, app) orelse return;
|
|
60
|
-
self.destroy();
|
|
61
|
+
_ = self.destroy();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/// Destroy the app and report whether teardown had to preserve the
|
|
65
|
+
/// host because a detached platform callback may still be running.
|
|
66
|
+
/// A mobile shim that owns the callback context must preserve that
|
|
67
|
+
/// context too when this returns 1.
|
|
68
|
+
pub fn native_sdk_app_destroy_with_status(app: ?*anyopaque) callconv(.c) c_int {
|
|
69
|
+
const self = hostApp(Host, app) orelse return 0;
|
|
70
|
+
return if (self.destroy()) 1 else 0;
|
|
61
71
|
}
|
|
62
72
|
|
|
63
73
|
pub fn native_sdk_app_start(app: ?*anyopaque) callconv(.c) void {
|
|
@@ -195,6 +205,20 @@ pub fn MobileCApi(comptime Host: type) type {
|
|
|
195
205
|
return 1;
|
|
196
206
|
}
|
|
197
207
|
|
|
208
|
+
/// Register or clear the mobile host's OS-backed credential store.
|
|
209
|
+
/// This supplies platform backing only; app.zon capability and
|
|
210
|
+
/// permission gates are still enforced by the runtime.
|
|
211
|
+
pub fn native_sdk_app_set_credential_service(app: ?*anyopaque, service: ?*const types.MobileCredentialService, context: ?*anyopaque) callconv(.c) c_int {
|
|
212
|
+
const self = hostApp(Host, app) orelse return 0;
|
|
213
|
+
const table: types.MobileCredentialService = if (service) |value| value.* else .{};
|
|
214
|
+
host.setCredentialService(self, table, context) catch |err| {
|
|
215
|
+
recordError(self, err);
|
|
216
|
+
return 0;
|
|
217
|
+
};
|
|
218
|
+
self.last_error = null;
|
|
219
|
+
return 1;
|
|
220
|
+
}
|
|
221
|
+
|
|
198
222
|
/// One report from the shim's audio player (kind ordinals: 0
|
|
199
223
|
/// loaded, 1 position, 2 completed, 3 failed), dispatched into the
|
|
200
224
|
/// embedded runtime exactly like a desktop platform's `.audio`
|
|
@@ -242,6 +266,25 @@ pub fn MobileCApi(comptime Host: type) type {
|
|
|
242
266
|
return 1;
|
|
243
267
|
}
|
|
244
268
|
|
|
269
|
+
/// Supply the OS-owned app-data directory before start. Hosts call
|
|
270
|
+
/// this for every app; non-store host types accept it as a no-op so
|
|
271
|
+
/// the mobile ABI does not vary with capability shedding.
|
|
272
|
+
pub fn native_sdk_app_set_data_root(app: ?*anyopaque, path: ?[*]const u8, len: usize) callconv(.c) c_int {
|
|
273
|
+
const self = hostApp(Host, app) orelse return 0;
|
|
274
|
+
const dir = inputSlice(path, len) catch |err| {
|
|
275
|
+
recordError(self, err);
|
|
276
|
+
return 0;
|
|
277
|
+
};
|
|
278
|
+
if (comptime @hasDecl(Host, "setDataRoot")) {
|
|
279
|
+
self.setDataRoot(dir) catch |err| {
|
|
280
|
+
recordError(self, err);
|
|
281
|
+
return 0;
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
self.last_error = null;
|
|
285
|
+
return 1;
|
|
286
|
+
}
|
|
287
|
+
|
|
245
288
|
pub fn native_sdk_app_touch(app: ?*anyopaque, id: u64, phase: c_int, x: f32, y: f32, pressure: f32) callconv(.c) void {
|
|
246
289
|
const self = hostApp(Host, app) orelse return;
|
|
247
290
|
self.embedded.touch(id, phase, x, y, pressure) catch |err| {
|
|
@@ -748,6 +791,7 @@ const FixedShellApi = MobileCApi(MobileHostApp);
|
|
|
748
791
|
|
|
749
792
|
pub const native_sdk_app_create = FixedShellApi.native_sdk_app_create;
|
|
750
793
|
pub const native_sdk_app_destroy = FixedShellApi.native_sdk_app_destroy;
|
|
794
|
+
pub const native_sdk_app_destroy_with_status = FixedShellApi.native_sdk_app_destroy_with_status;
|
|
751
795
|
pub const native_sdk_app_start = FixedShellApi.native_sdk_app_start;
|
|
752
796
|
pub const native_sdk_app_activate = FixedShellApi.native_sdk_app_activate;
|
|
753
797
|
pub const native_sdk_app_deactivate = FixedShellApi.native_sdk_app_deactivate;
|
|
@@ -759,9 +803,11 @@ pub const native_sdk_app_gpu_frame_state = FixedShellApi.native_sdk_app_gpu_fram
|
|
|
759
803
|
pub const native_sdk_app_text_input_state = FixedShellApi.native_sdk_app_text_input_state;
|
|
760
804
|
pub const native_sdk_app_set_text_measure = FixedShellApi.native_sdk_app_set_text_measure;
|
|
761
805
|
pub const native_sdk_app_set_audio_service = FixedShellApi.native_sdk_app_set_audio_service;
|
|
806
|
+
pub const native_sdk_app_set_credential_service = FixedShellApi.native_sdk_app_set_credential_service;
|
|
762
807
|
pub const native_sdk_app_audio_event = FixedShellApi.native_sdk_app_audio_event;
|
|
763
808
|
pub const native_sdk_app_set_image_service = FixedShellApi.native_sdk_app_set_image_service;
|
|
764
809
|
pub const native_sdk_app_set_automation_dir = FixedShellApi.native_sdk_app_set_automation_dir;
|
|
810
|
+
pub const native_sdk_app_set_data_root = FixedShellApi.native_sdk_app_set_data_root;
|
|
765
811
|
pub const native_sdk_app_touch = FixedShellApi.native_sdk_app_touch;
|
|
766
812
|
pub const native_sdk_app_scroll = FixedShellApi.native_sdk_app_scroll;
|
|
767
813
|
pub const native_sdk_app_key = FixedShellApi.native_sdk_app_key;
|
|
@@ -350,10 +350,9 @@ pub fn mobileTextRangeEnd(range: ?canvas.TextRange) isize {
|
|
|
350
350
|
const value = range orelse return -1;
|
|
351
351
|
return mobileOptionalIndex(value.end);
|
|
352
352
|
}
|
|
353
|
-
///
|
|
354
|
-
///
|
|
355
|
-
///
|
|
353
|
+
/// Monotonic nanoseconds for embed input and frame timestamps. These values
|
|
354
|
+
/// participate in GPU latency and frame-interval subtraction, so they must
|
|
355
|
+
/// share the duration clock used by desktop hosts and runtime presentation.
|
|
356
356
|
pub fn nowNanoseconds() u64 {
|
|
357
|
-
|
|
358
|
-
return if (ns > 0) @intCast(ns) else 0;
|
|
357
|
+
return runtime.monotonicNanoseconds();
|
|
359
358
|
}
|
package/src/embed/host.zig
CHANGED
|
@@ -169,6 +169,98 @@ pub fn setAudioService(self: anytype, service: types.MobileAudioService, context
|
|
|
169
169
|
self.null_platform.system_audio_capture = false;
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
+
/// Host-owned callback table for the mobile OS credential store.
|
|
173
|
+
pub const MobileCredentials = struct {
|
|
174
|
+
service: types.MobileCredentialService = .{},
|
|
175
|
+
context: ?*anyopaque = null,
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
fn MobileCredentialBridge(comptime Host: type) type {
|
|
179
|
+
return struct {
|
|
180
|
+
fn hostFromContext(context: ?*anyopaque) *Host {
|
|
181
|
+
const null_platform: *platform.NullPlatform = @ptrCast(@alignCast(context.?));
|
|
182
|
+
return @alignCast(@fieldParentPtr("null_platform", null_platform));
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
fn setCredential(context: ?*anyopaque, credential: platform.Credential) anyerror!void {
|
|
186
|
+
const store = &hostFromContext(context).credentials;
|
|
187
|
+
const set_fn = store.service.set orelse return error.UnsupportedService;
|
|
188
|
+
return switch (set_fn(
|
|
189
|
+
store.context,
|
|
190
|
+
credential.service.ptr,
|
|
191
|
+
credential.service.len,
|
|
192
|
+
credential.account.ptr,
|
|
193
|
+
credential.account.len,
|
|
194
|
+
credential.secret.ptr,
|
|
195
|
+
credential.secret.len,
|
|
196
|
+
)) {
|
|
197
|
+
1 => {},
|
|
198
|
+
-2 => error.CredentialStoreLocked,
|
|
199
|
+
-3 => error.AccessDenied,
|
|
200
|
+
else => error.CredentialStoreFailed,
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
fn getCredential(context: ?*anyopaque, key: platform.CredentialKey, output: []u8) anyerror![]const u8 {
|
|
205
|
+
const store = &hostFromContext(context).credentials;
|
|
206
|
+
const get_fn = store.service.get orelse return error.UnsupportedService;
|
|
207
|
+
const result = get_fn(
|
|
208
|
+
store.context,
|
|
209
|
+
key.service.ptr,
|
|
210
|
+
key.service.len,
|
|
211
|
+
key.account.ptr,
|
|
212
|
+
key.account.len,
|
|
213
|
+
output.ptr,
|
|
214
|
+
output.len,
|
|
215
|
+
);
|
|
216
|
+
return switch (result) {
|
|
217
|
+
-1 => error.CredentialNotFound,
|
|
218
|
+
-2 => error.CredentialStoreLocked,
|
|
219
|
+
-3 => error.AccessDenied,
|
|
220
|
+
-4 => error.NoSpaceLeft,
|
|
221
|
+
else => if (result < 0 or result > output.len)
|
|
222
|
+
error.CredentialStoreFailed
|
|
223
|
+
else
|
|
224
|
+
output[0..@intCast(result)],
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
fn deleteCredential(context: ?*anyopaque, key: platform.CredentialKey) anyerror!void {
|
|
229
|
+
const store = &hostFromContext(context).credentials;
|
|
230
|
+
const delete_fn = store.service.delete orelse return error.UnsupportedService;
|
|
231
|
+
return switch (delete_fn(
|
|
232
|
+
store.context,
|
|
233
|
+
key.service.ptr,
|
|
234
|
+
key.service.len,
|
|
235
|
+
key.account.ptr,
|
|
236
|
+
key.account.len,
|
|
237
|
+
)) {
|
|
238
|
+
1 => {},
|
|
239
|
+
0 => error.CredentialNotFound,
|
|
240
|
+
-2 => error.CredentialStoreLocked,
|
|
241
|
+
-3 => error.AccessDenied,
|
|
242
|
+
else => error.CredentialStoreFailed,
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/// Install or clear the mobile OS credential service. Partial tables are
|
|
249
|
+
/// refused so a successful set can never be paired with an unavailable get
|
|
250
|
+
/// or delete. Registration only supplies the backing; the manifest
|
|
251
|
+
/// capability and permission remain independent runtime gates.
|
|
252
|
+
pub fn setCredentialService(self: anytype, service: types.MobileCredentialService, context: ?*anyopaque) anyerror!void {
|
|
253
|
+
const Host = std.meta.Child(@TypeOf(self));
|
|
254
|
+
const Bridge = MobileCredentialBridge(Host);
|
|
255
|
+
const complete = service.complete();
|
|
256
|
+
if (!complete and !service.empty()) return error.InvalidCommand;
|
|
257
|
+
self.credentials = .{ .service = service, .context = if (complete) context else null };
|
|
258
|
+
const services = &self.embedded.runtime.options.platform.services;
|
|
259
|
+
services.set_credential_fn = if (complete) Bridge.setCredential else null;
|
|
260
|
+
services.get_credential_fn = if (complete) Bridge.getCredential else null;
|
|
261
|
+
services.delete_credential_fn = if (complete) Bridge.deleteCredential else null;
|
|
262
|
+
}
|
|
263
|
+
|
|
172
264
|
/// Host-owned storage for the shim's registered image-decode service
|
|
173
265
|
/// (callback table + shim context). Lives on the (heap-allocated) host
|
|
174
266
|
/// beside the audio store so the platform-services bridge can reach it
|
|
@@ -696,6 +788,7 @@ pub const MobileHostApp = struct {
|
|
|
696
788
|
automation_io: ?*std.Io.Threaded = null,
|
|
697
789
|
text_measure: MobileTextMeasure = .{},
|
|
698
790
|
audio: MobileAudio = .{},
|
|
791
|
+
credentials: MobileCredentials = .{},
|
|
699
792
|
// Image decode stays declined until the shim registers a real codec
|
|
700
793
|
// (`native_sdk_app_set_image_service`): the null platform's strict
|
|
701
794
|
// test decoder is opt-in (`image_decode`, default off), so with no
|
|
@@ -771,6 +864,7 @@ pub const MobileHostApp = struct {
|
|
|
771
864
|
self.automation_io = null;
|
|
772
865
|
self.text_measure = .{};
|
|
773
866
|
self.audio = .{};
|
|
867
|
+
self.credentials = .{};
|
|
774
868
|
self.image = .{};
|
|
775
869
|
self.form_factor = .unknown;
|
|
776
870
|
self.chrome_tabs_projected = false;
|
|
@@ -783,10 +877,18 @@ pub const MobileHostApp = struct {
|
|
|
783
877
|
.source_fn = mobileSource,
|
|
784
878
|
.event_fn = handleEvent,
|
|
785
879
|
}, self.null_platform.platform());
|
|
880
|
+
// A real mobile host must register Keychain/Keystore backing before
|
|
881
|
+
// start. Do not expose the NullPlatform's hermetic test map to an
|
|
882
|
+
// installed app while that registration is absent.
|
|
883
|
+
try setCredentialService(self, .{}, null);
|
|
786
884
|
return self;
|
|
787
885
|
}
|
|
788
886
|
|
|
789
|
-
|
|
887
|
+
/// Returns true when teardown deliberately preserves the host because an
|
|
888
|
+
/// abandoned platform callback may still enter it. Mobile shims that own
|
|
889
|
+
/// callback context use the companion C ABI result to preserve that
|
|
890
|
+
/// context under the same condition.
|
|
891
|
+
pub fn destroy(self: *MobileHostApp) bool {
|
|
790
892
|
disableAutomation(self);
|
|
791
893
|
// One lifecycle owner: the embedded app's own deinit returns
|
|
792
894
|
// the runtime's heap-owned storage (registered canvas font
|
|
@@ -795,7 +897,13 @@ pub const MobileHostApp = struct {
|
|
|
795
897
|
// embedding app keeps past destroy can never wake the freed
|
|
796
898
|
// host storage (the embedded null platform included).
|
|
797
899
|
self.embedded.deinit();
|
|
900
|
+
// Effects reports any detached platform call through the null
|
|
901
|
+
// platform's abandon latch. Such a call still resolves this wrapper
|
|
902
|
+
// from the services context, so preserve the complete host block just
|
|
903
|
+
// as desktop platform destroy paths preserve theirs.
|
|
904
|
+
if (self.null_platform.channel_wake_abandoned.load(.seq_cst)) return true;
|
|
798
905
|
std.heap.page_allocator.destroy(self);
|
|
906
|
+
return false;
|
|
799
907
|
}
|
|
800
908
|
|
|
801
909
|
pub fn start(self: *MobileHostApp) anyerror!void {
|
package/src/embed/root.zig
CHANGED
|
@@ -18,6 +18,7 @@ pub const MobileGpuFrameState = types.MobileGpuFrameState;
|
|
|
18
18
|
pub const MobileCanvasPixels = types.MobileCanvasPixels;
|
|
19
19
|
pub const MobileCanvasPixelsDamage = types.MobileCanvasPixelsDamage;
|
|
20
20
|
pub const MobileAudioService = types.MobileAudioService;
|
|
21
|
+
pub const MobileCredentialService = types.MobileCredentialService;
|
|
21
22
|
pub const MobileImageService = types.MobileImageService;
|
|
22
23
|
pub const MobileChromeItem = chrome.MobileChromeItem;
|
|
23
24
|
pub const renderChromeIconPixels = chrome.renderIconPixels;
|
|
@@ -26,12 +27,16 @@ pub const mobile_gpu_surface_label = types.mobile_gpu_surface_label;
|
|
|
26
27
|
pub const EmbeddedApp = host.EmbeddedApp;
|
|
27
28
|
pub const MobileHostApp = host.MobileHostApp;
|
|
28
29
|
pub const UiAppHost = ui_host.UiAppHost;
|
|
30
|
+
pub const UiAppHostWithRecordStore = ui_host.UiAppHostWithRecordStore;
|
|
31
|
+
pub const UiAppHostWithStorage = ui_host.UiAppHostWithStorage;
|
|
32
|
+
pub const UiAppHostWithStorageAndCredentials = ui_host.UiAppHostWithStorageAndCredentials;
|
|
29
33
|
pub const mobile_shell_scene = ui_host.mobile_shell_scene;
|
|
30
34
|
pub const MobileCApi = c_api.MobileCApi;
|
|
31
35
|
pub const exportMobileCApi = c_api.exportMobileCApi;
|
|
32
36
|
|
|
33
37
|
pub const native_sdk_app_create = c_api.native_sdk_app_create;
|
|
34
38
|
pub const native_sdk_app_destroy = c_api.native_sdk_app_destroy;
|
|
39
|
+
pub const native_sdk_app_destroy_with_status = c_api.native_sdk_app_destroy_with_status;
|
|
35
40
|
pub const native_sdk_app_start = c_api.native_sdk_app_start;
|
|
36
41
|
pub const native_sdk_app_activate = c_api.native_sdk_app_activate;
|
|
37
42
|
pub const native_sdk_app_deactivate = c_api.native_sdk_app_deactivate;
|
|
@@ -42,9 +47,11 @@ pub const native_sdk_app_viewport_state = c_api.native_sdk_app_viewport_state;
|
|
|
42
47
|
pub const native_sdk_app_gpu_frame_state = c_api.native_sdk_app_gpu_frame_state;
|
|
43
48
|
pub const native_sdk_app_text_input_state = c_api.native_sdk_app_text_input_state;
|
|
44
49
|
pub const native_sdk_app_set_audio_service = c_api.native_sdk_app_set_audio_service;
|
|
50
|
+
pub const native_sdk_app_set_credential_service = c_api.native_sdk_app_set_credential_service;
|
|
45
51
|
pub const native_sdk_app_audio_event = c_api.native_sdk_app_audio_event;
|
|
46
52
|
pub const native_sdk_app_set_image_service = c_api.native_sdk_app_set_image_service;
|
|
47
53
|
pub const native_sdk_app_set_automation_dir = c_api.native_sdk_app_set_automation_dir;
|
|
54
|
+
pub const native_sdk_app_set_data_root = c_api.native_sdk_app_set_data_root;
|
|
48
55
|
pub const native_sdk_app_touch = c_api.native_sdk_app_touch;
|
|
49
56
|
pub const native_sdk_app_scroll = c_api.native_sdk_app_scroll;
|
|
50
57
|
pub const native_sdk_app_key = c_api.native_sdk_app_key;
|
package/src/embed/tests.zig
CHANGED
|
@@ -29,6 +29,7 @@ const mobileWidgetActions = conversions.mobileWidgetActions;
|
|
|
29
29
|
const mobileWidgetActionKindFromInt = conversions.mobileWidgetActionKindFromInt;
|
|
30
30
|
const native_sdk_app_create = c_api.native_sdk_app_create;
|
|
31
31
|
const native_sdk_app_destroy = c_api.native_sdk_app_destroy;
|
|
32
|
+
const native_sdk_app_destroy_with_status = c_api.native_sdk_app_destroy_with_status;
|
|
32
33
|
const native_sdk_app_start = c_api.native_sdk_app_start;
|
|
33
34
|
const native_sdk_app_activate = c_api.native_sdk_app_activate;
|
|
34
35
|
const native_sdk_app_deactivate = c_api.native_sdk_app_deactivate;
|
|
@@ -266,6 +267,17 @@ test "mobile C ABI destroy returns registered font bytes through the embedded de
|
|
|
266
267
|
native_sdk_app_destroy(app);
|
|
267
268
|
}
|
|
268
269
|
|
|
270
|
+
test "mobile C ABI destroy status reports whether callback context must survive" {
|
|
271
|
+
const normal = native_sdk_app_create() orelse return error.TestUnexpectedResult;
|
|
272
|
+
try std.testing.expectEqual(@as(c_int, 0), native_sdk_app_destroy_with_status(normal));
|
|
273
|
+
|
|
274
|
+
const preserved = native_sdk_app_create() orelse return error.TestUnexpectedResult;
|
|
275
|
+
mobileApp(preserved).?.null_platform.channel_wake_abandoned.store(true, .seq_cst);
|
|
276
|
+
// The host is deliberately process-lived after this call, exactly like a
|
|
277
|
+
// real detached callback's context. Do not touch or destroy it again.
|
|
278
|
+
try std.testing.expectEqual(@as(c_int, 1), native_sdk_app_destroy_with_status(preserved));
|
|
279
|
+
}
|
|
280
|
+
|
|
269
281
|
test "mobile C ABI can load packaged asset source" {
|
|
270
282
|
const app = native_sdk_app_create() orelse return error.TestUnexpectedResult;
|
|
271
283
|
defer native_sdk_app_destroy(app);
|
|
@@ -1019,6 +1031,136 @@ const MobileCounterDef = struct {
|
|
|
1019
1031
|
|
|
1020
1032
|
const MobileCounterHost = ui_host.UiAppHost(MobileCounterDef);
|
|
1021
1033
|
const MobileCounterApi = c_api.MobileCApi(MobileCounterHost);
|
|
1034
|
+
const MobileStoreHost = ui_host.UiAppHostWithRecordStore(MobileCounterDef, true);
|
|
1035
|
+
const MobileStoreApi = c_api.MobileCApi(MobileStoreHost);
|
|
1036
|
+
const MobileRelationalHost = ui_host.UiAppHostWithStorage(MobileCounterDef, false, true, &.{});
|
|
1037
|
+
const MobileRelationalApi = c_api.MobileCApi(MobileRelationalHost);
|
|
1038
|
+
const MobileBothStorageHost = ui_host.UiAppHostWithStorage(MobileCounterDef, true, true, &.{});
|
|
1039
|
+
const MobileBothStorageApi = c_api.MobileCApi(MobileBothStorageHost);
|
|
1040
|
+
const MobileCredentialHost = ui_host.UiAppHostWithStorageAndCredentials(
|
|
1041
|
+
MobileCounterDef,
|
|
1042
|
+
false,
|
|
1043
|
+
false,
|
|
1044
|
+
&.{},
|
|
1045
|
+
true,
|
|
1046
|
+
true,
|
|
1047
|
+
"dev.native-sdk.mobile-credentials",
|
|
1048
|
+
);
|
|
1049
|
+
const MobileCredentialApi = c_api.MobileCApi(MobileCredentialHost);
|
|
1050
|
+
|
|
1051
|
+
const MobileCredentialRecorder = struct {
|
|
1052
|
+
secret: [64]u8 = undefined,
|
|
1053
|
+
secret_len: usize = 0,
|
|
1054
|
+
present: bool = false,
|
|
1055
|
+
};
|
|
1056
|
+
|
|
1057
|
+
fn mobileCredentialRecorder(context: ?*anyopaque) *MobileCredentialRecorder {
|
|
1058
|
+
return @ptrCast(@alignCast(context.?));
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1061
|
+
fn mobileCredentialSet(
|
|
1062
|
+
context: ?*anyopaque,
|
|
1063
|
+
service: ?[*]const u8,
|
|
1064
|
+
service_len: usize,
|
|
1065
|
+
account: ?[*]const u8,
|
|
1066
|
+
account_len: usize,
|
|
1067
|
+
secret: ?[*]const u8,
|
|
1068
|
+
secret_len: usize,
|
|
1069
|
+
) callconv(.c) c_int {
|
|
1070
|
+
_ = service;
|
|
1071
|
+
_ = service_len;
|
|
1072
|
+
_ = account;
|
|
1073
|
+
_ = account_len;
|
|
1074
|
+
const recorder = mobileCredentialRecorder(context);
|
|
1075
|
+
if (secret_len > recorder.secret.len) return -5;
|
|
1076
|
+
if (secret_len > 0) @memcpy(recorder.secret[0..secret_len], secret.?[0..secret_len]);
|
|
1077
|
+
recorder.secret_len = secret_len;
|
|
1078
|
+
recorder.present = true;
|
|
1079
|
+
return 1;
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
fn mobileCredentialGet(
|
|
1083
|
+
context: ?*anyopaque,
|
|
1084
|
+
service: ?[*]const u8,
|
|
1085
|
+
service_len: usize,
|
|
1086
|
+
account: ?[*]const u8,
|
|
1087
|
+
account_len: usize,
|
|
1088
|
+
output: ?[*]u8,
|
|
1089
|
+
output_len: usize,
|
|
1090
|
+
) callconv(.c) i64 {
|
|
1091
|
+
_ = service;
|
|
1092
|
+
_ = service_len;
|
|
1093
|
+
_ = account;
|
|
1094
|
+
_ = account_len;
|
|
1095
|
+
const recorder = mobileCredentialRecorder(context);
|
|
1096
|
+
if (!recorder.present) return -1;
|
|
1097
|
+
if (recorder.secret_len > output_len) return -4;
|
|
1098
|
+
if (recorder.secret_len > 0) @memcpy(output.?[0..recorder.secret_len], recorder.secret[0..recorder.secret_len]);
|
|
1099
|
+
return @intCast(recorder.secret_len);
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
fn mobileCredentialDelete(
|
|
1103
|
+
context: ?*anyopaque,
|
|
1104
|
+
service: ?[*]const u8,
|
|
1105
|
+
service_len: usize,
|
|
1106
|
+
account: ?[*]const u8,
|
|
1107
|
+
account_len: usize,
|
|
1108
|
+
) callconv(.c) c_int {
|
|
1109
|
+
_ = service;
|
|
1110
|
+
_ = service_len;
|
|
1111
|
+
_ = account;
|
|
1112
|
+
_ = account_len;
|
|
1113
|
+
const recorder = mobileCredentialRecorder(context);
|
|
1114
|
+
if (!recorder.present) return 0;
|
|
1115
|
+
recorder.present = false;
|
|
1116
|
+
recorder.secret_len = 0;
|
|
1117
|
+
return 1;
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
test "mobile credential service uses app identity and preserves misses" {
|
|
1121
|
+
const app = MobileCredentialApi.native_sdk_app_create() orelse return error.TestUnexpectedResult;
|
|
1122
|
+
defer MobileCredentialApi.native_sdk_app_destroy(app);
|
|
1123
|
+
const self: *MobileCredentialHost = @ptrCast(@alignCast(app));
|
|
1124
|
+
|
|
1125
|
+
try std.testing.expect(self.embedded.runtime.options.credentials_enabled);
|
|
1126
|
+
try std.testing.expectEqualStrings(
|
|
1127
|
+
"dev.native-sdk.mobile-credentials",
|
|
1128
|
+
self.embedded.runtime.options.platform.app_info.bundle_id,
|
|
1129
|
+
);
|
|
1130
|
+
try std.testing.expect(self.embedded.runtime.options.platform.services.set_credential_fn == null);
|
|
1131
|
+
|
|
1132
|
+
var recorder = MobileCredentialRecorder{};
|
|
1133
|
+
const service: types.MobileCredentialService = .{
|
|
1134
|
+
.set = mobileCredentialSet,
|
|
1135
|
+
.get = mobileCredentialGet,
|
|
1136
|
+
.delete = mobileCredentialDelete,
|
|
1137
|
+
};
|
|
1138
|
+
try std.testing.expectEqual(
|
|
1139
|
+
@as(c_int, 1),
|
|
1140
|
+
MobileCredentialApi.native_sdk_app_set_credential_service(app, &service, &recorder),
|
|
1141
|
+
);
|
|
1142
|
+
|
|
1143
|
+
const services = self.embedded.runtime.options.platform.services;
|
|
1144
|
+
try services.setCredential(.{
|
|
1145
|
+
.service = "dev.native-sdk.mobile-credentials",
|
|
1146
|
+
.account = "token",
|
|
1147
|
+
.secret = "secret-bytes",
|
|
1148
|
+
});
|
|
1149
|
+
var output: [64]u8 = undefined;
|
|
1150
|
+
const secret = try services.getCredential(.{
|
|
1151
|
+
.service = "dev.native-sdk.mobile-credentials",
|
|
1152
|
+
.account = "token",
|
|
1153
|
+
}, &output);
|
|
1154
|
+
try std.testing.expectEqualStrings("secret-bytes", secret);
|
|
1155
|
+
try services.deleteCredential(.{
|
|
1156
|
+
.service = "dev.native-sdk.mobile-credentials",
|
|
1157
|
+
.account = "token",
|
|
1158
|
+
});
|
|
1159
|
+
try std.testing.expectError(error.CredentialNotFound, services.getCredential(.{
|
|
1160
|
+
.service = "dev.native-sdk.mobile-credentials",
|
|
1161
|
+
.account = "token",
|
|
1162
|
+
}, &output));
|
|
1163
|
+
}
|
|
1022
1164
|
|
|
1023
1165
|
fn expectNoUiHostError(app: ?*anyopaque) !void {
|
|
1024
1166
|
try std.testing.expectEqualStrings("", std.mem.span(MobileCounterApi.native_sdk_app_last_error_name(app)));
|
|
@@ -1052,6 +1194,77 @@ fn tapMobileWidget(app: ?*anyopaque, node: MobileWidgetSemantics) !void {
|
|
|
1052
1194
|
try expectNoUiHostError(app);
|
|
1053
1195
|
}
|
|
1054
1196
|
|
|
1197
|
+
test "mobile store capability requires and binds the OS app-data root before start" {
|
|
1198
|
+
const app = MobileStoreApi.native_sdk_app_create() orelse return error.TestUnexpectedResult;
|
|
1199
|
+
defer MobileStoreApi.native_sdk_app_destroy(app);
|
|
1200
|
+
const self: *MobileStoreHost = @ptrCast(@alignCast(app));
|
|
1201
|
+
|
|
1202
|
+
MobileStoreApi.native_sdk_app_start(app);
|
|
1203
|
+
try std.testing.expectEqualStrings("StoreDataDirUnavailable", std.mem.span(MobileStoreApi.native_sdk_app_last_error_name(app)));
|
|
1204
|
+
|
|
1205
|
+
var tmp = std.testing.tmpDir(.{});
|
|
1206
|
+
defer tmp.cleanup();
|
|
1207
|
+
var path_buffer: [256]u8 = undefined;
|
|
1208
|
+
const path = try std.fmt.bufPrint(&path_buffer, ".zig-cache/tmp/{s}/mobile-store", .{tmp.sub_path[0..]});
|
|
1209
|
+
try std.Io.Dir.cwd().createDirPath(std.testing.io, path);
|
|
1210
|
+
try std.testing.expectEqual(@as(c_int, 1), MobileStoreApi.native_sdk_app_set_data_root(app, path.ptr, path.len));
|
|
1211
|
+
try std.testing.expect(self.record_store_open);
|
|
1212
|
+
try std.testing.expect(self.embedded.runtime.options.record_store != null);
|
|
1213
|
+
|
|
1214
|
+
MobileStoreApi.native_sdk_app_start(app);
|
|
1215
|
+
try std.testing.expectEqualStrings("", std.mem.span(MobileStoreApi.native_sdk_app_last_error_name(app)));
|
|
1216
|
+
var surface_token: u8 = 0;
|
|
1217
|
+
MobileStoreApi.native_sdk_app_viewport(app, 390, 844, 1, &surface_token, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
1218
|
+
MobileStoreApi.native_sdk_app_frame(app);
|
|
1219
|
+
try self.ui.dispatch(&self.embedded.runtime, 1, .increment);
|
|
1220
|
+
try std.testing.expect(self.ui.effects.record_store_binding != null);
|
|
1221
|
+
MobileStoreApi.native_sdk_app_stop(app);
|
|
1222
|
+
}
|
|
1223
|
+
|
|
1224
|
+
test "mobile relational capability opens app.db from the OS app-data root" {
|
|
1225
|
+
const app = MobileRelationalApi.native_sdk_app_create() orelse return error.TestUnexpectedResult;
|
|
1226
|
+
defer MobileRelationalApi.native_sdk_app_destroy(app);
|
|
1227
|
+
const self: *MobileRelationalHost = @ptrCast(@alignCast(app));
|
|
1228
|
+
|
|
1229
|
+
MobileRelationalApi.native_sdk_app_start(app);
|
|
1230
|
+
try std.testing.expectEqualStrings("SqliteDataDirUnavailable", std.mem.span(MobileRelationalApi.native_sdk_app_last_error_name(app)));
|
|
1231
|
+
|
|
1232
|
+
var tmp = std.testing.tmpDir(.{});
|
|
1233
|
+
defer tmp.cleanup();
|
|
1234
|
+
var path_buffer: [256]u8 = undefined;
|
|
1235
|
+
const path = try std.fmt.bufPrint(&path_buffer, ".zig-cache/tmp/{s}/mobile-relational", .{tmp.sub_path[0..]});
|
|
1236
|
+
try std.Io.Dir.cwd().createDirPath(std.testing.io, path);
|
|
1237
|
+
try std.testing.expectEqual(@as(c_int, 1), MobileRelationalApi.native_sdk_app_set_data_root(app, path.ptr, path.len));
|
|
1238
|
+
try std.testing.expect(self.relational_store_open);
|
|
1239
|
+
try std.testing.expect(self.embedded.runtime.options.relational_store != null);
|
|
1240
|
+
|
|
1241
|
+
MobileRelationalApi.native_sdk_app_start(app);
|
|
1242
|
+
try std.testing.expectEqualStrings("", std.mem.span(MobileRelationalApi.native_sdk_app_last_error_name(app)));
|
|
1243
|
+
var surface_token: u8 = 0;
|
|
1244
|
+
MobileRelationalApi.native_sdk_app_viewport(app, 390, 844, 1, &surface_token, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
1245
|
+
MobileRelationalApi.native_sdk_app_frame(app);
|
|
1246
|
+
try self.ui.dispatch(&self.embedded.runtime, 1, .increment);
|
|
1247
|
+
try std.testing.expect(self.ui.effects.relational_store_binding != null);
|
|
1248
|
+
MobileRelationalApi.native_sdk_app_stop(app);
|
|
1249
|
+
}
|
|
1250
|
+
|
|
1251
|
+
test "mobile host binds record and relational databases together" {
|
|
1252
|
+
const app = MobileBothStorageApi.native_sdk_app_create() orelse return error.TestUnexpectedResult;
|
|
1253
|
+
defer MobileBothStorageApi.native_sdk_app_destroy(app);
|
|
1254
|
+
const self: *MobileBothStorageHost = @ptrCast(@alignCast(app));
|
|
1255
|
+
|
|
1256
|
+
var tmp = std.testing.tmpDir(.{});
|
|
1257
|
+
defer tmp.cleanup();
|
|
1258
|
+
var path_buffer: [256]u8 = undefined;
|
|
1259
|
+
const path = try std.fmt.bufPrint(&path_buffer, ".zig-cache/tmp/{s}/mobile-both-storage", .{tmp.sub_path[0..]});
|
|
1260
|
+
try std.Io.Dir.cwd().createDirPath(std.testing.io, path);
|
|
1261
|
+
try std.testing.expectEqual(@as(c_int, 1), MobileBothStorageApi.native_sdk_app_set_data_root(app, path.ptr, path.len));
|
|
1262
|
+
try std.testing.expect(self.record_store_open);
|
|
1263
|
+
try std.testing.expect(self.relational_store_open);
|
|
1264
|
+
try std.testing.expect(self.embedded.runtime.options.record_store != null);
|
|
1265
|
+
try std.testing.expect(self.embedded.runtime.options.relational_store != null);
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1055
1268
|
test "mobile C ABI drives a user UiApp canvas scene end to end" {
|
|
1056
1269
|
const app = MobileCounterApi.native_sdk_app_create() orelse return error.TestUnexpectedResult;
|
|
1057
1270
|
defer MobileCounterApi.native_sdk_app_destroy(app);
|
package/src/embed/types.zig
CHANGED
|
@@ -267,6 +267,57 @@ pub const MobileAudioService = extern struct {
|
|
|
267
267
|
}
|
|
268
268
|
};
|
|
269
269
|
|
|
270
|
+
// ----------------------------------------------------------- credentials
|
|
271
|
+
//
|
|
272
|
+
// The secure credential service over the embed C ABI. Mobile toolkit hosts
|
|
273
|
+
// register an OS-backed implementation before app start: Keychain Services
|
|
274
|
+
// on iOS and an AndroidKeyStore-wrapped private preferences entry on Android.
|
|
275
|
+
// The callback result codes keep the closed core-effect outcomes intact:
|
|
276
|
+
// locked and denied remain distinguishable from ordinary I/O failure, and a
|
|
277
|
+
// missing get/delete remains a normal `miss` rather than an error.
|
|
278
|
+
|
|
279
|
+
pub const MobileCredentialSetFn = *const fn (
|
|
280
|
+
context: ?*anyopaque,
|
|
281
|
+
service: ?[*]const u8,
|
|
282
|
+
service_len: usize,
|
|
283
|
+
account: ?[*]const u8,
|
|
284
|
+
account_len: usize,
|
|
285
|
+
secret: ?[*]const u8,
|
|
286
|
+
secret_len: usize,
|
|
287
|
+
) callconv(.c) c_int;
|
|
288
|
+
|
|
289
|
+
pub const MobileCredentialGetFn = *const fn (
|
|
290
|
+
context: ?*anyopaque,
|
|
291
|
+
service: ?[*]const u8,
|
|
292
|
+
service_len: usize,
|
|
293
|
+
account: ?[*]const u8,
|
|
294
|
+
account_len: usize,
|
|
295
|
+
output: ?[*]u8,
|
|
296
|
+
output_len: usize,
|
|
297
|
+
) callconv(.c) i64;
|
|
298
|
+
|
|
299
|
+
pub const MobileCredentialDeleteFn = *const fn (
|
|
300
|
+
context: ?*anyopaque,
|
|
301
|
+
service: ?[*]const u8,
|
|
302
|
+
service_len: usize,
|
|
303
|
+
account: ?[*]const u8,
|
|
304
|
+
account_len: usize,
|
|
305
|
+
) callconv(.c) c_int;
|
|
306
|
+
|
|
307
|
+
pub const MobileCredentialService = extern struct {
|
|
308
|
+
set: ?MobileCredentialSetFn = null,
|
|
309
|
+
get: ?MobileCredentialGetFn = null,
|
|
310
|
+
delete: ?MobileCredentialDeleteFn = null,
|
|
311
|
+
|
|
312
|
+
pub fn complete(self: MobileCredentialService) bool {
|
|
313
|
+
return self.set != null and self.get != null and self.delete != null;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
pub fn empty(self: MobileCredentialService) bool {
|
|
317
|
+
return self.set == null and self.get == null and self.delete == null;
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
|
|
270
321
|
// ------------------------------------------------------------ image decode
|
|
271
322
|
//
|
|
272
323
|
// The platform image-decode service over the embed C ABI. A mobile shim
|