@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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@native-sdk/core",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.1",
|
|
4
4
|
"description": "The TypeScript authoring tier: the app-core subset, its checker and contract frontend, the exact-pinned core compiler dependency, and the SDK module cores import",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -56,10 +56,10 @@
|
|
|
56
56
|
"@typescript/old": "npm:typescript@6.0.3"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@scriptc/types": "0.3.
|
|
59
|
+
"@scriptc/types": "0.3.2",
|
|
60
60
|
"tar": "7.5.22"
|
|
61
61
|
},
|
|
62
62
|
"nativeToolchain": {
|
|
63
|
-
"scriptc": "0.3.
|
|
63
|
+
"scriptc": "0.3.2"
|
|
64
64
|
}
|
|
65
65
|
}
|
|
@@ -1,51 +1,51 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
3
|
"installationFormat": 2,
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.2",
|
|
5
5
|
"repository": "vercel-labs/scriptc",
|
|
6
6
|
"releases": {
|
|
7
7
|
"darwin-arm64": {
|
|
8
|
-
"url": "https://github.com/vercel-labs/scriptc/releases/download/v0.3.
|
|
9
|
-
"bytes":
|
|
10
|
-
"sha256": "
|
|
8
|
+
"url": "https://github.com/vercel-labs/scriptc/releases/download/v0.3.2/scriptc-0.3.2-darwin-arm64.tar.gz",
|
|
9
|
+
"bytes": 61103733,
|
|
10
|
+
"sha256": "a915c1d5e1236b9b871e6b9f3eda4006486b147566af9a52b59aeeed09e2512f"
|
|
11
11
|
},
|
|
12
12
|
"darwin-x64": {
|
|
13
|
-
"url": "https://github.com/vercel-labs/scriptc/releases/download/v0.3.
|
|
14
|
-
"bytes":
|
|
15
|
-
"sha256": "
|
|
13
|
+
"url": "https://github.com/vercel-labs/scriptc/releases/download/v0.3.2/scriptc-0.3.2-darwin-x64.tar.gz",
|
|
14
|
+
"bytes": 63256126,
|
|
15
|
+
"sha256": "dad6ff96e80473fdd612f5648c7697300860623cebdabb7a0ab02898f6c293b8"
|
|
16
16
|
},
|
|
17
17
|
"linux-arm64-gnu": {
|
|
18
|
-
"url": "https://github.com/vercel-labs/scriptc/releases/download/v0.3.
|
|
19
|
-
"bytes":
|
|
20
|
-
"sha256": "
|
|
18
|
+
"url": "https://github.com/vercel-labs/scriptc/releases/download/v0.3.2/scriptc-0.3.2-linux-arm64-gnu.tar.gz",
|
|
19
|
+
"bytes": 72765037,
|
|
20
|
+
"sha256": "33e380e0c7cff941eda57966b18c1be9f22da4fb5c6770f49f50af1b66868df4"
|
|
21
21
|
},
|
|
22
22
|
"linux-arm64-musl": {
|
|
23
|
-
"url": "https://github.com/vercel-labs/scriptc/releases/download/v0.3.
|
|
24
|
-
"bytes":
|
|
25
|
-
"sha256": "
|
|
23
|
+
"url": "https://github.com/vercel-labs/scriptc/releases/download/v0.3.2/scriptc-0.3.2-linux-arm64-musl.tar.gz",
|
|
24
|
+
"bytes": 63971343,
|
|
25
|
+
"sha256": "9fc6e33cdd54962c7c3f53f009a13a9ac2c67ae139b1ae306d5e647cfe3911ad"
|
|
26
26
|
},
|
|
27
27
|
"linux-x64-gnu": {
|
|
28
|
-
"url": "https://github.com/vercel-labs/scriptc/releases/download/v0.3.
|
|
29
|
-
"bytes":
|
|
30
|
-
"sha256": "
|
|
28
|
+
"url": "https://github.com/vercel-labs/scriptc/releases/download/v0.3.2/scriptc-0.3.2-linux-x64-gnu.tar.gz",
|
|
29
|
+
"bytes": 75664254,
|
|
30
|
+
"sha256": "b6255ab2456b7afaee384cfca54f94b1d9aa5e7d8d5e343be6c558a9dcf4c13b"
|
|
31
31
|
},
|
|
32
32
|
"linux-x64-musl": {
|
|
33
|
-
"url": "https://github.com/vercel-labs/scriptc/releases/download/v0.3.
|
|
34
|
-
"bytes":
|
|
35
|
-
"sha256": "
|
|
33
|
+
"url": "https://github.com/vercel-labs/scriptc/releases/download/v0.3.2/scriptc-0.3.2-linux-x64-musl.tar.gz",
|
|
34
|
+
"bytes": 66837074,
|
|
35
|
+
"sha256": "33790ceac5227eb3f5bae6f04e17baba3e2f95db5ddc05bdb39b310d4180bbc2"
|
|
36
36
|
},
|
|
37
37
|
"win32-x64-msvc": {
|
|
38
|
-
"url": "https://github.com/vercel-labs/scriptc/releases/download/v0.3.
|
|
39
|
-
"bytes":
|
|
40
|
-
"sha256": "
|
|
38
|
+
"url": "https://github.com/vercel-labs/scriptc/releases/download/v0.3.2/scriptc-0.3.2-win32-x64-msvc.tar.gz",
|
|
39
|
+
"bytes": 74275594,
|
|
40
|
+
"sha256": "20af007e7b894ddcf22471c5f7b3a3e1a87f1c08e4e3d99baea3b7dd6e29285e"
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
43
|
"packages": {
|
|
44
44
|
"compiler": {
|
|
45
45
|
"name": "@scriptc/compiler",
|
|
46
|
-
"version": "0.3.
|
|
47
|
-
"url": "https://registry.npmjs.org/@scriptc/compiler/-/compiler-0.3.
|
|
48
|
-
"integrity": "sha512-
|
|
46
|
+
"version": "0.3.2",
|
|
47
|
+
"url": "https://registry.npmjs.org/@scriptc/compiler/-/compiler-0.3.2.tgz",
|
|
48
|
+
"integrity": "sha512-mSBaJdJVRu1DvFAV/N06lilhwf8I0xiaW6+rRsvBn1ezG9uNXygVkyBD+WBVW2VGx7D6zd6KezzLiWI6QfHqEQ=="
|
|
49
49
|
},
|
|
50
50
|
"typescript": {
|
|
51
51
|
"name": "typescript",
|
|
@@ -61,41 +61,41 @@
|
|
|
61
61
|
},
|
|
62
62
|
"runtime-ios-arm64": {
|
|
63
63
|
"name": "@scriptc/runtime-ios-arm64",
|
|
64
|
-
"version": "0.3.
|
|
65
|
-
"url": "https://registry.npmjs.org/@scriptc/runtime-ios-arm64/-/runtime-ios-arm64-0.3.
|
|
66
|
-
"integrity": "sha512-
|
|
64
|
+
"version": "0.3.2",
|
|
65
|
+
"url": "https://registry.npmjs.org/@scriptc/runtime-ios-arm64/-/runtime-ios-arm64-0.3.2.tgz",
|
|
66
|
+
"integrity": "sha512-rRqnQLoGzi0uUmJXe7nPyTxRt0vBzauoPQJPixQKK+LWKJPk2YsU0GMYcbLfCXHkZ8uVMeVoP9qD1Wzhvn+2qQ=="
|
|
67
67
|
},
|
|
68
68
|
"runtime-ios-simulator-arm64": {
|
|
69
69
|
"name": "@scriptc/runtime-ios-simulator-arm64",
|
|
70
|
-
"version": "0.3.
|
|
71
|
-
"url": "https://registry.npmjs.org/@scriptc/runtime-ios-simulator-arm64/-/runtime-ios-simulator-arm64-0.3.
|
|
72
|
-
"integrity": "sha512
|
|
70
|
+
"version": "0.3.2",
|
|
71
|
+
"url": "https://registry.npmjs.org/@scriptc/runtime-ios-simulator-arm64/-/runtime-ios-simulator-arm64-0.3.2.tgz",
|
|
72
|
+
"integrity": "sha512-+mTut4yurH/gxU4aMEaxUU6IfDAj9WTf6mqSdDudqs/kPhZ7bhg3hqSQe05Mwg4fB5KHPpYX5E7Rbj5nBp27GQ=="
|
|
73
73
|
},
|
|
74
74
|
"runtime-android-arm64": {
|
|
75
75
|
"name": "@scriptc/runtime-android-arm64",
|
|
76
|
-
"version": "0.3.
|
|
77
|
-
"url": "https://registry.npmjs.org/@scriptc/runtime-android-arm64/-/runtime-android-arm64-0.3.
|
|
78
|
-
"integrity": "sha512-
|
|
76
|
+
"version": "0.3.2",
|
|
77
|
+
"url": "https://registry.npmjs.org/@scriptc/runtime-android-arm64/-/runtime-android-arm64-0.3.2.tgz",
|
|
78
|
+
"integrity": "sha512-x2bKlP3Qiy3A93MVWpqdUlX+klIjWIZYUt5Ucys7SxXQuWWIkt9qRYojn0Ni9XtstJ8n/ZCMQVi5Mol5Q1A7+w=="
|
|
79
79
|
},
|
|
80
80
|
"runtime-wasm32-wasi": {
|
|
81
81
|
"name": "@scriptc/runtime-wasm32-wasi",
|
|
82
|
-
"version": "0.3.
|
|
83
|
-
"url": "https://registry.npmjs.org/@scriptc/runtime-wasm32-wasi/-/runtime-wasm32-wasi-0.3.
|
|
84
|
-
"integrity": "sha512-
|
|
82
|
+
"version": "0.3.2",
|
|
83
|
+
"url": "https://registry.npmjs.org/@scriptc/runtime-wasm32-wasi/-/runtime-wasm32-wasi-0.3.2.tgz",
|
|
84
|
+
"integrity": "sha512-J4tqKQYWS8pbqZ1YhydCmcf6/4rRoi9TMUMV6xJE3k5gJk0/nsKx4pashMZowXBOQ4CZsoVchlzwyB1kTxdsDg=="
|
|
85
85
|
},
|
|
86
86
|
"types": {
|
|
87
87
|
"name": "@scriptc/types",
|
|
88
|
-
"version": "0.3.
|
|
89
|
-
"url": "https://registry.npmjs.org/@scriptc/types/-/types-0.3.
|
|
90
|
-
"integrity": "sha512-
|
|
88
|
+
"version": "0.3.2",
|
|
89
|
+
"url": "https://registry.npmjs.org/@scriptc/types/-/types-0.3.2.tgz",
|
|
90
|
+
"integrity": "sha512-cHoAZJOpJxfYDWcYsTIZvJGCtpQWbMqqO0Z+BBqk+dbkRtMrcRXiepPzN0vSsV9PMdAyBvYIdAIzdJ5X8jSLqA=="
|
|
91
91
|
},
|
|
92
92
|
"threads": {
|
|
93
93
|
"name": "@scriptc/threads",
|
|
94
|
-
"version": "0.3.
|
|
95
|
-
"url": "https://registry.npmjs.org/@scriptc/threads/-/threads-0.3.
|
|
96
|
-
"integrity": "sha512-
|
|
94
|
+
"version": "0.3.2",
|
|
95
|
+
"url": "https://registry.npmjs.org/@scriptc/threads/-/threads-0.3.2.tgz",
|
|
96
|
+
"integrity": "sha512-CE3cvQ7LfgxX+9F9elf27ThGD2rArCI9C2ticx6WvqPsBsHWUYH9e4xNQ+Ci0dTFdJgwp0lplE2TdlkiqdPIKQ=="
|
|
97
97
|
}
|
|
98
98
|
},
|
|
99
|
-
"runtimeAbi":
|
|
99
|
+
"runtimeAbi": 20,
|
|
100
100
|
"typescriptNativeVersion": "7.0.2"
|
|
101
101
|
}
|
|
@@ -24,16 +24,28 @@
|
|
|
24
24
|
// node stage_external_core.mjs --src <app src dir> --sdk <sdk dir>
|
|
25
25
|
// --static <compile-surface core.ts> --facade <core_facade.ts>
|
|
26
26
|
// --profile <core_profile.json> --out <stage dir>
|
|
27
|
+
// [--view-markup <app.native> --view-contract <core.contract.json>
|
|
28
|
+
// [--view-reload]]
|
|
29
|
+
//
|
|
30
|
+
// --view-reload (Debug builds for `native dev` only) also stages the
|
|
31
|
+
// development view evaluator and its two exports, so the running app can
|
|
32
|
+
// replace its views from markup edits without a rebuild.
|
|
27
33
|
|
|
28
34
|
import fs from "node:fs";
|
|
29
35
|
import path from "node:path";
|
|
30
|
-
import {
|
|
36
|
+
import { compileViewProgram } from "../src/view_frontend.ts";
|
|
37
|
+
import { appViewSources } from "../src/view_sources.ts";
|
|
31
38
|
import { stageContractTypes } from "./scriptc_toolchain.mjs";
|
|
32
39
|
|
|
33
40
|
function parseArgs(argv) {
|
|
34
41
|
const args = {};
|
|
35
42
|
for (let i = 2; i < argv.length; i += 2) {
|
|
36
43
|
const key = argv[i];
|
|
44
|
+
if (key === "--view-reload") {
|
|
45
|
+
args["view-reload"] = true;
|
|
46
|
+
i -= 1;
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
37
49
|
const value = argv[i + 1];
|
|
38
50
|
if (!key.startsWith("--") || value === undefined) {
|
|
39
51
|
console.error("usage: stage_external_core.mjs --src <dir> --sdk <dir> --static <file> --facade <file> --profile <file> --out <dir>");
|
|
@@ -157,25 +169,20 @@ fs.writeFileSync(path.join(args.out, "sdk", "core.ts"), dedupeAliases(fs.readFil
|
|
|
157
169
|
// the profile's entry spelling expects.
|
|
158
170
|
fs.copyFileSync(args.facade, path.join(args.out, "core_facade.ts"));
|
|
159
171
|
fs.copyFileSync(args.profile, path.join(args.out, "profile.json"));
|
|
172
|
+
if (args["view-reload"] && !args["view-markup"]) throw new Error("--view-reload requires compiled views (--view-markup)");
|
|
160
173
|
if (args["view-markup"]) {
|
|
161
174
|
if (!args["view-contract"]) throw new Error("compiled views require --view-contract");
|
|
162
175
|
const contract = JSON.parse(fs.readFileSync(args["view-contract"], "utf8"));
|
|
163
|
-
const sources =
|
|
164
|
-
const
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
if (entry.isDirectory() && rel !== "services") markupFiles(path.join(dir, entry.name), rel + "/");
|
|
168
|
-
else if (entry.isFile() && rel.endsWith(".native")) sources.set(rel, fs.readFileSync(path.join(dir, entry.name), "utf8"));
|
|
169
|
-
}
|
|
170
|
-
};
|
|
171
|
-
markupFiles(args.src);
|
|
172
|
-
const windowSources = new Map([...sources].filter(([name]) => name.startsWith("windows/"))
|
|
173
|
-
.map(([name, source]) => [name.slice("windows/".length), source]));
|
|
174
|
-
const windows = [...windowSources].filter(([name]) => !name.includes("/"))
|
|
175
|
-
.sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0)
|
|
176
|
-
.map(([entry, source]) => ({ label: entry.slice(0, -".native".length), entry, source, sources: windowSources }));
|
|
177
|
-
const view = compileViewBundle(fs.readFileSync(args["view-markup"], "utf8"), contract, { sources }, windows);
|
|
176
|
+
const { sources, windows } = appViewSources(args.src);
|
|
177
|
+
const reload = args["view-reload"] === true;
|
|
178
|
+
const compiled = compileViewProgram(fs.readFileSync(args["view-markup"], "utf8"), contract, { sources }, windows, undefined, reload);
|
|
179
|
+
const view = compiled.text;
|
|
178
180
|
fs.appendFileSync(path.join(args.out, "core_facade.ts"), resolveSpecifiers(view, "core_facade.ts"));
|
|
181
|
+
if (reload) {
|
|
182
|
+
const { viewReloadFacade, viewReloadIdentity } = await import("../src/view_reload.ts");
|
|
183
|
+
const identity = viewReloadIdentity(contract, { windows: windows.map((window) => window.label), virtual: compiled.virtual });
|
|
184
|
+
fs.appendFileSync(path.join(args.out, "core_facade.ts"), viewReloadFacade(contract, identity));
|
|
185
|
+
}
|
|
179
186
|
const profile = JSON.parse(fs.readFileSync(args.profile, "utf8"));
|
|
180
187
|
profile.exports.push({ export: "native_view", symbol: `${profile.abi.prefix}native_view`, params: [], returns: "bytes" });
|
|
181
188
|
if (windows.length) profile.exports.push({ export: "native_window_view", symbol: `${profile.abi.prefix}native_window_view`, params: ["bytes"], returns: "bytes" });
|
|
@@ -204,6 +211,10 @@ if (args["view-markup"]) {
|
|
|
204
211
|
profile.exports.push({ export: "native_virtual_requests", symbol: `${profile.abi.prefix}native_virtual_requests`, params: ["bytes", "bytes"], returns: "bytes" });
|
|
205
212
|
profile.exports.push({ export: "native_virtual_view", symbol: `${profile.abi.prefix}native_virtual_view`, params: ["bytes", "bytes", "bytes"], returns: "bytes" });
|
|
206
213
|
}
|
|
214
|
+
if (reload) {
|
|
215
|
+
profile.exports.push({ export: "native_dev_view_prepare", symbol: `${profile.abi.prefix}native_dev_view_prepare`, params: ["bytes"], returns: "bytes" });
|
|
216
|
+
profile.exports.push({ export: "native_dev_view_reset", symbol: `${profile.abi.prefix}native_dev_view_reset`, params: [], returns: "bytes" });
|
|
217
|
+
}
|
|
207
218
|
fs.writeFileSync(path.join(args.out, "profile.json"), JSON.stringify(profile, null, 2) + "\n");
|
|
208
219
|
}
|
|
209
220
|
if (args["services-client"]) {
|
|
@@ -13,7 +13,7 @@ export { asciiBytes, utf8Bytes } from "./bytes.js";
|
|
|
13
13
|
export type Msgish = {
|
|
14
14
|
readonly kind: string;
|
|
15
15
|
};
|
|
16
|
-
import { type WindowDescriptor, type WindowDescriptorSpec } from "./events.js";
|
|
16
|
+
import { type GlobalShortcutEvent, type GlobalShortcutState, type WindowDescriptor, type WindowDescriptorSpec } from "./events.js";
|
|
17
17
|
export declare function windowDescriptor(spec: WindowDescriptorSpec): WindowDescriptor;
|
|
18
18
|
/** Cooperative cancellation capability supplied by generated service hosts. */
|
|
19
19
|
export interface ServiceCancellation {
|
|
@@ -113,6 +113,15 @@ export type ChannelSourceArm = {
|
|
|
113
113
|
readonly bytes: Uint8Array;
|
|
114
114
|
};
|
|
115
115
|
export type ChannelSourceKind<M extends Msgish> = M extends Msgish ? [Exclude<keyof M, "kind">] extends [keyof ChannelSourceArm] ? [keyof ChannelSourceArm] extends [Exclude<keyof M, "kind">] ? M extends Msgish & ChannelSourceArm ? [ChannelSourceState] extends [M["state"]] ? M["kind"] : never : never : never : never : never;
|
|
116
|
+
export type GlobalShortcutKind<M extends Msgish> = M extends Msgish ? [Exclude<keyof M, "kind">] extends [keyof GlobalShortcutEvent] ? [keyof GlobalShortcutEvent] extends [Exclude<keyof M, "kind">] ? M extends Msgish & GlobalShortcutEvent ? [GlobalShortcutState] extends [M["state"]] ? M["kind"] : never : never : never : never : never;
|
|
117
|
+
export interface GlobalShortcutBinding {
|
|
118
|
+
readonly key: Uint8Array;
|
|
119
|
+
readonly primary?: boolean;
|
|
120
|
+
readonly command?: boolean;
|
|
121
|
+
readonly control?: boolean;
|
|
122
|
+
readonly option?: boolean;
|
|
123
|
+
readonly shift?: boolean;
|
|
124
|
+
}
|
|
116
125
|
export type AudioCaptureSource = "microphone" | "system";
|
|
117
126
|
export type AudioCaptureState = "started" | "data" | "failed" | "stopped" | "rejected";
|
|
118
127
|
export type AudioCaptureSampleRate = 16000 | 24000 | 48000;
|
|
@@ -407,6 +416,7 @@ export interface NotificationSpec {
|
|
|
407
416
|
readonly actionCommand?: Uint8Array;
|
|
408
417
|
}
|
|
409
418
|
export type LocalTimeStyle = "date" | "time" | "datetime";
|
|
419
|
+
export type KeyChord = GlobalShortcutBinding;
|
|
410
420
|
export type Cmd<M extends Msgish> = {
|
|
411
421
|
readonly op: "none";
|
|
412
422
|
} | {
|
|
@@ -868,6 +878,12 @@ export declare const Cmd: {
|
|
|
868
878
|
showNotification(spec: NotificationSpec): Cmd<never>;
|
|
869
879
|
openExternalUrl(url: Uint8Array): Cmd<never>;
|
|
870
880
|
revealPath(path: Uint8Array): Cmd<never>;
|
|
881
|
+
keyboard: {
|
|
882
|
+
sendChord<M extends Msgish>(chord: KeyChord, route: RequestRoute<M>): Cmd<M>;
|
|
883
|
+
accessStatus<M extends Msgish>(options: {
|
|
884
|
+
readonly prompt?: boolean;
|
|
885
|
+
}, route: RequestRoute<M>): Cmd<M>;
|
|
886
|
+
};
|
|
871
887
|
formatLocalTime<M extends Msgish>(timestampMs: number, style: LocalTimeStyle, route: RequestRoute<M>): Cmd<M>;
|
|
872
888
|
delay<M extends Msgish>(key: string, ms: number, msgKind: TimestampKind<M>): Cmd<M>;
|
|
873
889
|
spawn<M extends Msgish>(argv: readonly Uint8Array[], route: SpawnRoute<M> | SpawnCollectRoute<M>): Cmd<M>;
|
|
@@ -945,6 +961,12 @@ export type Sub<M extends Msgish> = {
|
|
|
945
961
|
readonly key: string;
|
|
946
962
|
readonly everyMs: number;
|
|
947
963
|
readonly msgKind: string;
|
|
964
|
+
} | {
|
|
965
|
+
readonly op: "global_shortcut";
|
|
966
|
+
readonly id: string;
|
|
967
|
+
readonly key: Uint8Array;
|
|
968
|
+
readonly modifiers: number;
|
|
969
|
+
readonly msgKind: string;
|
|
948
970
|
} | {
|
|
949
971
|
readonly op: "db_live";
|
|
950
972
|
readonly key: string;
|
|
@@ -961,5 +983,6 @@ export type Sub<M extends Msgish> = {
|
|
|
961
983
|
export declare const Sub: {
|
|
962
984
|
none: Sub<never>;
|
|
963
985
|
timer<M extends Msgish>(key: string, everyMs: number, msgKind: TimestampKind<M>): Sub<M>;
|
|
986
|
+
globalShortcut<M extends Msgish>(id: string, binding: GlobalShortcutBinding, msgKind: GlobalShortcutKind<M>): Sub<M>;
|
|
964
987
|
batch<M extends Msgish>(subs: readonly Sub<M>[]): Sub<M>;
|
|
965
988
|
};
|
|
@@ -302,7 +302,7 @@ export { asciiBytes, utf8Bytes } from "./bytes.ts";
|
|
|
302
302
|
/// Every app Msg is a discriminated union on a string `kind` tag.
|
|
303
303
|
export type Msgish = { readonly kind: string };
|
|
304
304
|
|
|
305
|
-
import { type WindowDescriptor, type WindowDescriptorSpec } from "./events.ts";
|
|
305
|
+
import { type GlobalShortcutEvent, type GlobalShortcutState, type WindowDescriptor, type WindowDescriptorSpec } from "./events.ts";
|
|
306
306
|
|
|
307
307
|
/// Fill the canonical defaults for a model-declared secondary window.
|
|
308
308
|
export function windowDescriptor(spec: WindowDescriptorSpec): WindowDescriptor {
|
|
@@ -700,6 +700,27 @@ export type ChannelSourceKind<M extends Msgish> = M extends Msgish
|
|
|
700
700
|
: never
|
|
701
701
|
: never;
|
|
702
702
|
|
|
703
|
+
export type GlobalShortcutKind<M extends Msgish> = M extends Msgish
|
|
704
|
+
? [Exclude<keyof M, "kind">] extends [keyof GlobalShortcutEvent]
|
|
705
|
+
? [keyof GlobalShortcutEvent] extends [Exclude<keyof M, "kind">]
|
|
706
|
+
? M extends Msgish & GlobalShortcutEvent
|
|
707
|
+
? [GlobalShortcutState] extends [M["state"]] ? M["kind"] : never
|
|
708
|
+
: never
|
|
709
|
+
: never
|
|
710
|
+
: never
|
|
711
|
+
: never;
|
|
712
|
+
|
|
713
|
+
/// A key from the app shortcut vocabulary plus modifiers. `primary` is
|
|
714
|
+
/// Command on macOS and Control elsewhere.
|
|
715
|
+
export interface GlobalShortcutBinding {
|
|
716
|
+
readonly key: Uint8Array;
|
|
717
|
+
readonly primary?: boolean;
|
|
718
|
+
readonly command?: boolean;
|
|
719
|
+
readonly control?: boolean;
|
|
720
|
+
readonly option?: boolean;
|
|
721
|
+
readonly shift?: boolean;
|
|
722
|
+
}
|
|
723
|
+
|
|
703
724
|
/// The native capture source. "microphone" captures the selected/default
|
|
704
725
|
/// input device; "system" captures the process-independent desktop output
|
|
705
726
|
/// mix (the OS may present a screen/audio consent prompt).
|
|
@@ -1221,6 +1242,9 @@ export interface NotificationSpec {
|
|
|
1221
1242
|
/// effect because the user's locale and time zone are ambient host state.
|
|
1222
1243
|
export type LocalTimeStyle = "date" | "time" | "datetime";
|
|
1223
1244
|
|
|
1245
|
+
/// A chord to send, shaped like a global shortcut binding; it may have no modifier.
|
|
1246
|
+
export type KeyChord = GlobalShortcutBinding;
|
|
1247
|
+
|
|
1224
1248
|
/// An inert command value, parameterized by the app's Msg union so the
|
|
1225
1249
|
/// factories can validate message targets. Opaque to app code: build with
|
|
1226
1250
|
/// the `Cmd.*` factories, return from `update`/`initialModel`, never inspect
|
|
@@ -1541,6 +1565,11 @@ export function hostRecordBytes(payload: HostRecord): Uint8Array {
|
|
|
1541
1565
|
return out;
|
|
1542
1566
|
}
|
|
1543
1567
|
|
|
1568
|
+
function shortcutModifierBits(binding: GlobalShortcutBinding): number {
|
|
1569
|
+
return ((binding.primary ?? false) ? 1 : 0) + ((binding.command ?? false) ? 2 : 0) + ((binding.control ?? false) ? 4 : 0) +
|
|
1570
|
+
((binding.option ?? false) ? 8 : 0) + ((binding.shift ?? false) ? 16 : 0);
|
|
1571
|
+
}
|
|
1572
|
+
|
|
1544
1573
|
function serviceU32(value: number): Uint8Array {
|
|
1545
1574
|
const out = new Uint8Array(4);
|
|
1546
1575
|
out[0] = value & 255;
|
|
@@ -1982,6 +2011,19 @@ export const Cmd = {
|
|
|
1982
2011
|
return { op: "host_bytes", name: "native-sdk.os.revealPath", payload: path };
|
|
1983
2012
|
},
|
|
1984
2013
|
|
|
2014
|
+
/// Keyboard input for whichever app has focus; requires the `keyboard_input` permission.
|
|
2015
|
+
keyboard: {
|
|
2016
|
+
/// Press one chord, such as `{ key: asciiBytes("v"), primary: true }` to paste; ok carries empty bytes.
|
|
2017
|
+
sendChord<M extends Msgish>(chord: KeyChord, route: RequestRoute<M>): Cmd<M> {
|
|
2018
|
+
return Cmd.request("native-sdk.keyboard.sendChord", { key: chord.key, modifiers: shortcutModifierBits(chord) }, route);
|
|
2019
|
+
},
|
|
2020
|
+
|
|
2021
|
+
/// Ok carries `granted`, `denied`, or `not_required`; `prompt` lets the OS show its grant prompt.
|
|
2022
|
+
accessStatus<M extends Msgish>(options: { readonly prompt?: boolean }, route: RequestRoute<M>): Cmd<M> {
|
|
2023
|
+
return Cmd.request("native-sdk.keyboard.accessStatus", new Uint8Array([options.prompt === true ? 1 : 0]), route);
|
|
2024
|
+
},
|
|
2025
|
+
},
|
|
2026
|
+
|
|
1985
2027
|
/// Format an epoch timestamp (milliseconds, the same unit as `Cmd.now`) in
|
|
1986
2028
|
/// the host's current locale and local time zone. The localized UTF-8 text
|
|
1987
2029
|
/// arrives on ok; invalid timestamps or unavailable services route err.
|
|
@@ -2457,6 +2499,7 @@ export const Cmd = {
|
|
|
2457
2499
|
export type Sub<M extends Msgish> =
|
|
2458
2500
|
| { readonly op: "none" }
|
|
2459
2501
|
| { readonly op: "timer"; readonly key: string; readonly everyMs: number; readonly msgKind: string }
|
|
2502
|
+
| { readonly op: "global_shortcut"; readonly id: string; readonly key: Uint8Array; readonly modifiers: number; readonly msgKind: string }
|
|
2460
2503
|
| {
|
|
2461
2504
|
readonly op: "db_live";
|
|
2462
2505
|
readonly key: string;
|
|
@@ -2480,6 +2523,13 @@ export const Sub = {
|
|
|
2480
2523
|
return { op: "timer", key, everyMs, msgKind };
|
|
2481
2524
|
},
|
|
2482
2525
|
|
|
2526
|
+
/// A system-wide shortcut that fires while other apps have focus. It is
|
|
2527
|
+
/// registered while declared and re-registered when the binding changes;
|
|
2528
|
+
/// every report dispatches the named arm with `id` and a GlobalShortcutState.
|
|
2529
|
+
globalShortcut<M extends Msgish>(id: string, binding: GlobalShortcutBinding, msgKind: GlobalShortcutKind<M>): Sub<M> {
|
|
2530
|
+
return { op: "global_shortcut", id, key: binding.key, modifiers: shortcutModifierBits(binding), msgKind };
|
|
2531
|
+
},
|
|
2532
|
+
|
|
2483
2533
|
// @native-sqlite-generated-subs
|
|
2484
2534
|
|
|
2485
2535
|
/// Several subscriptions at once.
|
|
@@ -447,6 +447,11 @@ export interface AudioCaptureEvent {
|
|
|
447
447
|
readonly droppedPending: number;
|
|
448
448
|
readonly droppedTotal: number;
|
|
449
449
|
}
|
|
450
|
+
export type GlobalShortcutState = "registered" | "pressed" | "released" | "conflict" | "unsupported" | "rejected";
|
|
451
|
+
export interface GlobalShortcutEvent {
|
|
452
|
+
readonly id: Uint8Array;
|
|
453
|
+
readonly state: GlobalShortcutState;
|
|
454
|
+
}
|
|
450
455
|
/** Retained viewport facts supplied to a windowed-list row query. */
|
|
451
456
|
export interface VirtualListRange {
|
|
452
457
|
readonly start_index: number;
|
|
@@ -624,6 +624,16 @@ export interface AudioCaptureEvent {
|
|
|
624
624
|
readonly droppedTotal: number;
|
|
625
625
|
}
|
|
626
626
|
|
|
627
|
+
/// The `Sub.globalShortcut` arm record. "registered" means the OS accepted the
|
|
628
|
+
/// binding; "conflict", "unsupported", and "rejected" mean another app or the OS
|
|
629
|
+
/// owns it, the platform has no global shortcuts, or the binding is invalid.
|
|
630
|
+
export type GlobalShortcutState = "registered" | "pressed" | "released" | "conflict" | "unsupported" | "rejected";
|
|
631
|
+
|
|
632
|
+
export interface GlobalShortcutEvent {
|
|
633
|
+
readonly id: Uint8Array;
|
|
634
|
+
readonly state: GlobalShortcutState;
|
|
635
|
+
}
|
|
636
|
+
|
|
627
637
|
/** Retained viewport facts supplied to a windowed-list row query. */
|
|
628
638
|
export interface VirtualListRange {
|
|
629
639
|
readonly start_index: number;
|
|
@@ -17,11 +17,11 @@ function nscvBridgeDescriptors(request: Uint8Array): Uint8Array {
|
|
|
17
17
|
: family === 4 ? ["none", "timer"]
|
|
18
18
|
: family === 5 ? ["none", "opaque", "premultiplied"]
|
|
19
19
|
: family === 6 ? ["none", "srgb", "display_p3"]
|
|
20
|
-
: ["main_webview", "child_webviews", "native_views", "native_control_commands", "menus", "tray", "shortcuts", "dialogs", "clipboard_text", "clipboard_rich_data", "open_url", "reveal_path", "notifications", "recent_documents", "credentials", "file_drops", "app_activation_events", "gpu_surfaces", "gpu_surface_scroll_drivers", "context_menus", "view_surface_adoption", "audio_playback", "audio_streaming", "audio_spectrum", "microphone_capture", "system_audio_capture", "window_hide_on_close", "video_playback"];
|
|
20
|
+
: ["main_webview", "child_webviews", "native_views", "native_control_commands", "menus", "tray", "shortcuts", "dialogs", "clipboard_text", "clipboard_rich_data", "open_url", "reveal_path", "notifications", "recent_documents", "credentials", "file_drops", "app_activation_events", "gpu_surfaces", "gpu_surface_scroll_drivers", "context_menus", "view_surface_adoption", "audio_playback", "audio_streaming", "audio_spectrum", "microphone_capture", "system_audio_capture", "window_hide_on_close", "video_playback", "global_shortcuts", "keyboard_input"];
|
|
21
21
|
const aliases = family === 0 ? ["titlebarAccessory", "iconButton", "listItem", "segmentedControl", "textField", "searchField", "gpuSurface", "progressIndicator"]
|
|
22
22
|
: family === 1 ? ["hiddenInset", "hiddenInsetTall"]
|
|
23
|
-
: family === 7 ? ["mainWebView", "childWebViews", "nativeViews", "nativeControlCommands", "clipboardText", "clipboardRichData", "openUrl", "revealPath", "recentDocuments", "fileDrops", "appActivationEvents", "gpuSurfaces", "gpuSurfaceScrollDrivers", "contextMenus", "viewSurfaceAdoption", "audioPlayback", "audioStreaming", "audioSpectrum", "microphoneCapture", "systemAudioCapture", "windowHideOnClose", "videoPlayback"] : [];
|
|
24
|
-
const ordinals = family === 0 ? [2, 8, 9, 12, 13, 14, 17, 18] : family === 1 ? [1, 2] : family === 7 ? [0, 1, 2, 3, 8, 9, 10, 11, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27] : [];
|
|
23
|
+
: family === 7 ? ["mainWebView", "childWebViews", "nativeViews", "nativeControlCommands", "clipboardText", "clipboardRichData", "openUrl", "revealPath", "recentDocuments", "fileDrops", "appActivationEvents", "gpuSurfaces", "gpuSurfaceScrollDrivers", "contextMenus", "viewSurfaceAdoption", "audioPlayback", "audioStreaming", "audioSpectrum", "microphoneCapture", "systemAudioCapture", "windowHideOnClose", "videoPlayback", "globalShortcuts", "keyboardInput"] : [];
|
|
24
|
+
const ordinals = family === 0 ? [2, 8, 9, 12, 13, 14, 17, 18] : family === 1 ? [1, 2] : family === 7 ? [0, 1, 2, 3, 8, 9, 10, 11, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29] : [];
|
|
25
25
|
let selected = 0;
|
|
26
26
|
if (word(12) === 0) for (let group = 0; group < 2; group++) {
|
|
27
27
|
const values = group === 0 ? names : aliases;
|
|
@@ -3337,6 +3337,26 @@ export class SubsetChecker {
|
|
|
3337
3337
|
}
|
|
3338
3338
|
}
|
|
3339
3339
|
|
|
3340
|
+
if (
|
|
3341
|
+
!this.permissions.has("keyboard_input") &&
|
|
3342
|
+
((ts.isPropertyAccessExpression(node) &&
|
|
3343
|
+
node.name.text === "keyboard" &&
|
|
3344
|
+
ts.isIdentifier(node.expression) &&
|
|
3345
|
+
this.cmdNames.has(node.expression.text) &&
|
|
3346
|
+
this.isSdkReference(node.expression)) ||
|
|
3347
|
+
(ts.isCallExpression(node) &&
|
|
3348
|
+
ts.isPropertyAccessExpression(node.expression) &&
|
|
3349
|
+
node.expression.name.text === "request" &&
|
|
3350
|
+
ts.isIdentifier(node.expression.expression) &&
|
|
3351
|
+
this.cmdNames.has(node.expression.expression.text) &&
|
|
3352
|
+
this.isSdkReference(node.expression.expression) &&
|
|
3353
|
+
node.arguments[0] !== undefined &&
|
|
3354
|
+
ts.isStringLiteralLike(node.arguments[0]) &&
|
|
3355
|
+
node.arguments[0].text.startsWith("native-sdk.keyboard.")))
|
|
3356
|
+
) {
|
|
3357
|
+
this.report("NS1075", "`Cmd.keyboard.*` and `native-sdk.keyboard.*` requests require the `keyboard_input` permission in app.zon.", node);
|
|
3358
|
+
}
|
|
3359
|
+
|
|
3340
3360
|
// NS1073 — the core credential wire names belong to the typed factory.
|
|
3341
3361
|
// Raw Cmd.request payloads are app-controlled bytes and cannot state
|
|
3342
3362
|
// the credential record contract safely at the authoring boundary.
|
package/packages/core/src/cli.ts
CHANGED
|
@@ -19,7 +19,6 @@ import { checkFile, formatDiagnostic, type FrontendOptions } from "./frontend.ts
|
|
|
19
19
|
import type { ServicePackage } from "./service_contract.ts";
|
|
20
20
|
import fs from "node:fs";
|
|
21
21
|
import path from "node:path";
|
|
22
|
-
import ts from "@typescript/old";
|
|
23
22
|
|
|
24
23
|
function main(argv: string[]): number {
|
|
25
24
|
const args = argv.slice(2);
|
|
@@ -199,16 +198,8 @@ function main(argv: string[]): number {
|
|
|
199
198
|
const sourcePrefix = path.relative(path.resolve(editorDir), path.dirname(path.resolve(entry))).split(path.sep).join("/");
|
|
200
199
|
const editorSource = result.servicesClient.replaceAll('from "./', `from "${sourcePrefix}/`);
|
|
201
200
|
fs.writeFileSync(servicesEditorClientOut, editorSource);
|
|
202
|
-
const
|
|
203
|
-
|
|
204
|
-
compilerOptions: { target: ts.ScriptTarget.ESNext, module: ts.ModuleKind.ESNext },
|
|
205
|
-
reportDiagnostics: true,
|
|
206
|
-
});
|
|
207
|
-
if (declaration.diagnostics?.some((diagnostic) => diagnostic.category === ts.DiagnosticCategory.Error)) {
|
|
208
|
-
console.error("internal: the generated editor service client could not emit declarations");
|
|
209
|
-
return 1;
|
|
210
|
-
}
|
|
211
|
-
fs.writeFileSync(`${editorDir}/index.d.ts`, declaration.outputText);
|
|
201
|
+
const declarations = result.servicesClientDeclarations!.replaceAll('from "./', `from "${sourcePrefix}/`);
|
|
202
|
+
fs.writeFileSync(`${editorDir}/index.d.ts`, declarations);
|
|
212
203
|
fs.writeFileSync(`${editorDir}/package.json`, `${JSON.stringify({
|
|
213
204
|
name: "@native-sdk/services",
|
|
214
205
|
private: true,
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/** Context-menu coordination. Operation 98 uses copied integer words and
|
|
2
|
+
* bounded ordinals; no callback, widget or label storage crosses this seam.
|
|
3
|
+
* Modes: route (0), default presentation (1), next token (2), superseded
|
|
4
|
+
* notice (3), post-notice admission (4), action admission (5), action (6).
|
|
5
|
+
* Native executes the OS presenter, clipboard, text and app capabilities.
|
|
6
|
+
*/
|
|
7
|
+
function nscvContextMenus(request: Uint8Array): Uint8Array {
|
|
8
|
+
if (request.length < 16 || request[0] !== 98 || request[1]! > 6 || request[2] !== 0 || request[3] !== 0)
|
|
9
|
+
throw new Error("invalid context menu header");
|
|
10
|
+
const w = new DataView(request.buffer, request.byteOffset, request.byteLength);
|
|
11
|
+
const word = (at: number): number => w.getUint32(at, true);
|
|
12
|
+
const equal = (a: number, b: number): boolean => word(a) === word(b) && word(a + 4) === word(b + 4);
|
|
13
|
+
const scalar = (value: number): Uint8Array => { const out = new Uint8Array(4); new DataView(out.buffer).setUint32(0, value, true); return out; };
|
|
14
|
+
const mode = request[1]!;
|
|
15
|
+
if (mode === 0) {
|
|
16
|
+
const nodes = word(4), routes = word(8), missing = 4294967295;
|
|
17
|
+
if (nodes > 1024 || routes > 1024 || word(12) !== 0 || request.length !== 16 + nodes * 16 + routes * 8)
|
|
18
|
+
throw new Error("invalid context menu route");
|
|
19
|
+
for (let i = 0; i < nodes; i++) if (word(28 + i * 16) > 1) throw new Error("invalid context menu node");
|
|
20
|
+
let selected = missing, low = 0, high = 0;
|
|
21
|
+
for (let i = 0; i < routes; i++) {
|
|
22
|
+
const at = 16 + nodes * 16 + i * 8, slot = word(at);
|
|
23
|
+
if (word(at + 4) !== 0 || slot >= nodes) continue;
|
|
24
|
+
const node = 16 + slot * 16, dl = word(node), dh = word(node + 4);
|
|
25
|
+
if (word(node + 8) === 0 || word(node + 12) !== 0) continue;
|
|
26
|
+
if (selected === missing || dh > high || dh === high && dl >= low) { selected = slot; low = dl; high = dh; }
|
|
27
|
+
}
|
|
28
|
+
return scalar(selected);
|
|
29
|
+
}
|
|
30
|
+
if (mode === 1) {
|
|
31
|
+
// Flags: target, editable, disabled, terminal, presenter, edit selection,
|
|
32
|
+
// select-all, terminal selection, live PTY, selected-node/group present.
|
|
33
|
+
const flags = word(4);
|
|
34
|
+
if (request.length !== 56 || flags > 2047 || word(8) !== 0 || word(12) !== 0)
|
|
35
|
+
throw new Error("invalid context menu presentation");
|
|
36
|
+
let kind = 1;
|
|
37
|
+
if ((flags & 1) !== 0) {
|
|
38
|
+
if ((flags & 6) === 2) kind = (flags & 16) !== 0 ? 2 : 0;
|
|
39
|
+
else if ((flags & 12) === 8) kind = (flags & 16) !== 0 ? 3 : 0;
|
|
40
|
+
else if ((word(24) !== 0 || word(28) !== 0) && (equal(16, 24) || (flags & 1024) !== 0 &&
|
|
41
|
+
(word(32) !== 0 || word(36) !== 0) && equal(32, 40))) kind = (flags & 16) !== 0 ? 4 : 0;
|
|
42
|
+
}
|
|
43
|
+
if (word(48) !== 0 || word(52) !== 0) throw new Error("invalid context menu presentation reserved bytes");
|
|
44
|
+
const count = kind === 2 ? 5 : kind === 3 ? 2 : kind === 4 ? 1 : 0;
|
|
45
|
+
const out = new Uint8Array(8 + count * 4); out[0] = kind; out[1] = count;
|
|
46
|
+
if (kind === 2) {
|
|
47
|
+
out.set([1, 1, (flags & 32) !== 0 ? 1 : 0, 0, 2, 2, (flags & 32) !== 0 ? 1 : 0, 0,
|
|
48
|
+
3, 3, 1, 0, 0, 0, 1, 1, 4, 4, (flags & 64) !== 0 ? 1 : 0, 0], 8);
|
|
49
|
+
} else if (kind === 3) out.set([2, 2, (flags & 128) !== 0 ? 1 : 0, 0, 3, 3, (flags & 256) !== 0 ? 1 : 0, 0], 8);
|
|
50
|
+
else if (kind === 4) out.set([2, 2, 1, 0], 8);
|
|
51
|
+
return out;
|
|
52
|
+
}
|
|
53
|
+
if (mode === 2) {
|
|
54
|
+
if (request.length !== 16 || word(4) !== 0) throw new Error("invalid context menu token");
|
|
55
|
+
let low = word(8) + 1, high = word(12);
|
|
56
|
+
if (low === 4294967296) { low = 0; high = high === 4294967295 ? 0 : high + 1; }
|
|
57
|
+
if (low === 0 && high === 0) low = 1;
|
|
58
|
+
const out = new Uint8Array(8), v = new DataView(out.buffer); v.setUint32(0, low, true); v.setUint32(4, high, true); return out;
|
|
59
|
+
}
|
|
60
|
+
if (mode === 3) {
|
|
61
|
+
if (request.length !== 16 || word(4) > 4 || word(8) !== 0 || word(12) !== 0) throw new Error("invalid context menu notice");
|
|
62
|
+
return scalar(word(4) === 1 ? 1 : 0);
|
|
63
|
+
}
|
|
64
|
+
if (mode === 4) {
|
|
65
|
+
if (request.length !== 32 || word(4) > 3 || word(24) !== 0 || word(28) !== 0) throw new Error("invalid context menu continuation");
|
|
66
|
+
return scalar((word(4) & 1) === 0 || !equal(8, 16) ? 0 : (word(4) & 2) === 0 ? 1 : 2);
|
|
67
|
+
}
|
|
68
|
+
if (mode === 5) {
|
|
69
|
+
if (request.length !== 48 || word(4) > 4 || word(44) !== 0) throw new Error("invalid context menu action admission");
|
|
70
|
+
return scalar(word(4) === 0 || !equal(8, 16) || !equal(24, 32) ? 0 : word(40) === 0 ? (word(4) === 1 ? 1 : 2) : 3);
|
|
71
|
+
}
|
|
72
|
+
if (request.length !== 16 || word(4) < 1 || word(4) > 4 || word(12) !== 0) throw new Error("invalid context menu action");
|
|
73
|
+
const kind = word(4), item = word(8);
|
|
74
|
+
return scalar(kind === 1 ? 1 : kind === 2 ? item >= 1 && item <= 4 ? item + 1 : 0 :
|
|
75
|
+
kind === 3 ? item === 2 ? 6 : item === 3 ? 7 : 0 : item === 2 ? 8 : 0);
|
|
76
|
+
}
|
|
@@ -548,6 +548,13 @@ export const rules = {
|
|
|
548
548
|
why: "The runtime canonicalizes raw paths and refuses access outside this app's data/config/cache/state/logs/temp roots unless the manifest grants filesystem access; catching literal external paths at check time avoids shipping a guaranteed rejection.",
|
|
549
549
|
class: "guarantee",
|
|
550
550
|
},
|
|
551
|
+
NS1075: {
|
|
552
|
+
id: "NS1075",
|
|
553
|
+
title: "keyboard input requires explicit permission",
|
|
554
|
+
fix: "Add `\"keyboard_input\"` to app.zon's `permissions`, or remove the `Cmd.keyboard.*` call or `native-sdk.keyboard.*` request.",
|
|
555
|
+
why: "Typing into other apps is default-deny: on hosts that can post input, the runtime answers every undeclared keyboard request with `rejected`, so a missing grant is caught at check time instead of shipping a command that can never succeed.",
|
|
556
|
+
class: "guarantee",
|
|
557
|
+
},
|
|
551
558
|
NS1420: {
|
|
552
559
|
id: "NS1420",
|
|
553
560
|
title: "declare stable SQL in src/queries.sql",
|