@native-sdk/cli 0.8.4 → 0.9.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 +1178 -74
- package/build.zig +715 -17
- package/build.zig.zon +1 -0
- package/native-sdk.d.ts +10 -0
- package/package.json +12 -11
- package/packages/core/compile-surface/core.ts +435 -3
- package/packages/core/package-lock.json +11 -11
- package/packages/core/package.json +2 -2
- package/packages/core/scripts/compiler_typecheck.mjs +116 -15
- package/packages/core/scripts/gen_service_surface.mjs +268 -0
- package/packages/core/scripts/merge_static_archives.mjs +78 -0
- package/packages/core/scripts/npm_static_spike.mjs +64 -0
- package/packages/core/scripts/run_external_core_compiler.mjs +122 -6
- package/packages/core/scripts/run_external_service_compiler.mjs +280 -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 +224 -0
- package/packages/core/sdk/core.ts +694 -22
- package/packages/core/sdk/events.d.ts +89 -0
- package/packages/core/sdk/events.ts +128 -0
- package/packages/core/src/checker.ts +936 -15
- package/packages/core/src/cli.ts +156 -3
- package/packages/core/src/contract.ts +28 -5
- package/packages/core/src/devhost.ts +1876 -16
- package/packages/core/src/devhost_journal.mjs +183 -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 +179 -22
- package/packages/core/src/frontend.ts +210 -34
- package/packages/core/src/infer.ts +24 -0
- 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/automation/SKILL.md +1 -1
- package/skill-data/core/references/project-anatomy.md +1 -1
- package/skill-data/native-ui/SKILL.md +58 -5
- package/skill-data/ts-core/SKILL.md +123 -41
- package/skill-data/ts-services/SKILL.md +126 -0
- package/skill-data/ts-services/references/service-surface.md +604 -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 +133 -4
- package/src/app_runner/ts_core_main.zig +254 -8
- package/src/app_runner/ts_core_mobile.zig +241 -0
- package/src/automation/protocol.zig +5 -1
- package/src/automation/snapshot.zig +31 -11
- package/src/embed/app_exports.zig +12 -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 +8 -0
- package/src/embed/tests.zig +241 -0
- package/src/embed/types.zig +51 -0
- package/src/embed/ui_host.zig +185 -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 +8 -2
- package/src/platform/linux/gtk_host.c +289 -22
- package/src/platform/linux/gtk_host.h +5 -1
- package/src/platform/linux/root.zig +109 -22
- package/src/platform/macos/appkit_host.h +24 -7
- package/src/platform/macos/appkit_host.m +686 -64
- package/src/platform/macos/cef_host.mm +400 -66
- package/src/platform/macos/root.zig +304 -47
- package/src/platform/null_platform.zig +435 -48
- package/src/platform/null_platform_tests.zig +113 -0
- package/src/platform/root.zig +19 -0
- package/src/platform/types.zig +281 -28
- package/src/platform/windows/root.zig +207 -27
- package/src/platform/windows/webview2_host.cpp +334 -51
- 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 +53 -0
- package/src/runtime/api.zig +19 -0
- package/src/runtime/automation_commands.zig +35 -2
- package/src/runtime/automation_snapshot.zig +32 -20
- package/src/runtime/bridge_permission_tests.zig +58 -3
- package/src/runtime/bridge_responses.zig +4 -2
- package/src/runtime/builtin_bridge.zig +11 -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 +145 -7
- package/src/runtime/credentials_store.zig +115 -0
- package/src/runtime/effects.zig +3701 -231
- package/src/runtime/effects_credentials_tests.zig +332 -0
- package/src/runtime/effects_file_tests.zig +587 -0
- package/src/runtime/effects_host_tests.zig +208 -1
- package/src/runtime/effects_notification_tests.zig +11 -0
- package/src/runtime/effects_relational_tests.zig +314 -0
- package/src/runtime/effects_store_tests.zig +211 -0
- package/src/runtime/file_access.zig +400 -0
- package/src/runtime/file_effect_crash_helper.zig +28 -0
- package/src/runtime/file_effect_crash_tests.zig +37 -0
- package/src/runtime/flow.zig +35 -10
- package/src/runtime/gpu_surface_events.zig +6 -1
- package/src/runtime/native_command_event_tests.zig +86 -2
- package/src/runtime/persist_store.zig +666 -0
- package/src/runtime/pty.zig +5 -2
- package/src/runtime/record_store.zig +788 -0
- package/src/runtime/relational_store.zig +854 -0
- package/src/runtime/root.zig +54 -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 +4 -1
- package/src/runtime/session_journal.zig +158 -5
- package/src/runtime/session_record.zig +215 -0
- package/src/runtime/session_replay.zig +206 -11
- package/src/runtime/session_tests.zig +81 -0
- 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 +16 -0
- package/src/runtime/system_services.zig +170 -38
- package/src/runtime/tests.zig +4 -0
- package/src/runtime/ts_core_host.zig +1067 -95
- package/src/runtime/ts_core_host_tests.zig +325 -11
- package/src/runtime/ts_ui_app.zig +953 -2
- package/src/runtime/ui_app.zig +434 -96
- package/src/runtime/ui_app_tests.zig +287 -11
- package/src/runtime/ui_app_window_tests.zig +61 -7
- package/src/runtime/validation.zig +42 -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 +189 -4
- package/src/tooling/ts_core.zig +366 -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 +442 -27
- 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
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import ts from "@typescript/old";
|
|
5
|
+
import { analyzeSqlite, checkMigrationState, formatSqliteDiagnostic, generateCoreSurface, generateMigrationsZig } from "./sqlite_codegen.ts";
|
|
6
|
+
|
|
7
|
+
function argsOf(argv: string[]): Map<string, string> {
|
|
8
|
+
const out = new Map<string, string>();
|
|
9
|
+
for (let i = 2; i < argv.length; i += 2) {
|
|
10
|
+
const key = argv[i] ?? "";
|
|
11
|
+
const value = argv[i + 1];
|
|
12
|
+
if (!key.startsWith("--") || value === undefined) throw new Error("expected --name value arguments");
|
|
13
|
+
out.set(key.slice(2), value);
|
|
14
|
+
}
|
|
15
|
+
return out;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
try {
|
|
19
|
+
const args = argsOf(process.argv);
|
|
20
|
+
const src = args.get("src") ?? path.resolve("src");
|
|
21
|
+
const sdkIn = args.get("sdk-in");
|
|
22
|
+
const staticIn = args.get("static-in");
|
|
23
|
+
const sdkOut = args.get("sdk-out");
|
|
24
|
+
const staticOut = args.get("static-out");
|
|
25
|
+
const zigOut = args.get("zig-out");
|
|
26
|
+
const metadataOut = args.get("metadata-out");
|
|
27
|
+
const dtsOut = args.get("dts-out");
|
|
28
|
+
const state = args.get("state");
|
|
29
|
+
if (!zigOut) throw new Error("usage: sqlite_cli.ts --src <src> --zig-out <file> [--sdk-in <core.ts> --static-in <core.ts> --sdk-out <file> --static-out <file> --metadata-out <file>] [--state <file>]");
|
|
30
|
+
const surfaceArgs = [sdkIn, staticIn, sdkOut, staticOut];
|
|
31
|
+
const emitsSurface = surfaceArgs.every((value) => value !== undefined);
|
|
32
|
+
if (!emitsSurface && surfaceArgs.some((value) => value !== undefined)) throw new Error("SQLite SDK generation requires --sdk-in, --static-in, --sdk-out, and --static-out together");
|
|
33
|
+
const analysis = analyzeSqlite(src);
|
|
34
|
+
const diagnostics = [...analysis.diagnostics, ...(state ? checkMigrationState(analysis, state) : [])];
|
|
35
|
+
for (const diagnostic of [...diagnostics, ...analysis.warnings]) console.error(formatSqliteDiagnostic(diagnostic));
|
|
36
|
+
if (diagnostics.length > 0) process.exit(1);
|
|
37
|
+
if (emitsSurface) {
|
|
38
|
+
const sdkSource = generateCoreSurface(fs.readFileSync(sdkIn!, "utf8"), analysis);
|
|
39
|
+
fs.writeFileSync(sdkOut!, sdkSource);
|
|
40
|
+
if (dtsOut) {
|
|
41
|
+
const compilerOptions: ts.CompilerOptions = {
|
|
42
|
+
strict: true,
|
|
43
|
+
exactOptionalPropertyTypes: true,
|
|
44
|
+
target: ts.ScriptTarget.ESNext,
|
|
45
|
+
module: ts.ModuleKind.ESNext,
|
|
46
|
+
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
47
|
+
lib: ["lib.esnext.d.ts"],
|
|
48
|
+
types: [],
|
|
49
|
+
allowImportingTsExtensions: true,
|
|
50
|
+
rewriteRelativeImportExtensions: true,
|
|
51
|
+
declaration: true,
|
|
52
|
+
emitDeclarationOnly: true,
|
|
53
|
+
skipLibCheck: false,
|
|
54
|
+
};
|
|
55
|
+
const input = path.resolve(sdkIn!);
|
|
56
|
+
const host = ts.createCompilerHost(compilerOptions);
|
|
57
|
+
const getSourceFile = host.getSourceFile.bind(host);
|
|
58
|
+
host.getSourceFile = (fileName, languageVersion, onError, shouldCreateNewSourceFile) =>
|
|
59
|
+
path.resolve(fileName) === input
|
|
60
|
+
? ts.createSourceFile(fileName, sdkSource, languageVersion, true)
|
|
61
|
+
: getSourceFile(fileName, languageVersion, onError, shouldCreateNewSourceFile);
|
|
62
|
+
let output = "";
|
|
63
|
+
host.writeFile = (fileName, text) => {
|
|
64
|
+
if (fileName.endsWith("core.d.ts")) output = text;
|
|
65
|
+
};
|
|
66
|
+
const program = ts.createProgram([input], compilerOptions, host);
|
|
67
|
+
const errors = ts
|
|
68
|
+
.getPreEmitDiagnostics(program)
|
|
69
|
+
.filter((diagnostic) => diagnostic.category === ts.DiagnosticCategory.Error);
|
|
70
|
+
if (errors.length > 0) {
|
|
71
|
+
throw new Error(
|
|
72
|
+
errors
|
|
73
|
+
.map(
|
|
74
|
+
(diagnostic) =>
|
|
75
|
+
`TS${diagnostic.code} ${ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")}`,
|
|
76
|
+
)
|
|
77
|
+
.join("\n"),
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
const emit = program.emit();
|
|
81
|
+
if (emit.emitSkipped || output.length === 0) {
|
|
82
|
+
throw new Error("generated SQLite SDK declaration emit failed");
|
|
83
|
+
}
|
|
84
|
+
fs.writeFileSync(dtsOut, output.replace(/(from\s+")(\.\.?\/[^\"]+)\.ts(\")/g, "$1$2.js$3"));
|
|
85
|
+
}
|
|
86
|
+
fs.writeFileSync(staticOut!, generateCoreSurface(fs.readFileSync(staticIn!, "utf8"), analysis));
|
|
87
|
+
}
|
|
88
|
+
fs.writeFileSync(zigOut, generateMigrationsZig(analysis));
|
|
89
|
+
if (metadataOut) fs.writeFileSync(metadataOut, `${JSON.stringify({ format: 1, schema_hash: analysis.schemaHash, migrations: analysis.migrations.map(({ version, name, hash }) => ({ version, name, hash })), queries: analysis.queries }, null, 2)}\n`);
|
|
90
|
+
} catch (error) {
|
|
91
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
92
|
+
process.exit(2);
|
|
93
|
+
}
|