@native-sdk/cli 0.7.1 → 0.8.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.
Files changed (94) hide show
  1. package/build/app.zig +273 -65
  2. package/build/ts_run.mjs +6 -8
  3. package/build.zig +341 -361
  4. package/native-sdk.d.ts +6 -3
  5. package/package.json +13 -11
  6. package/packages/core/compile-surface/core.ts +559 -0
  7. package/packages/core/package-lock.json +375 -12
  8. package/packages/core/package.json +9 -6
  9. package/packages/core/scripts/compiler_typecheck.mjs +58 -0
  10. package/packages/core/scripts/gen_case_tables.mjs +130 -0
  11. package/packages/core/scripts/gen_declarations.mjs +97 -0
  12. package/packages/core/scripts/run_external_core_compiler.mjs +108 -0
  13. package/packages/core/scripts/stage_external_core.mjs +148 -0
  14. package/packages/core/sdk/core.d.ts +363 -0
  15. package/packages/core/sdk/events.d.ts +65 -0
  16. package/packages/core/sdk/text.d.ts +51 -0
  17. package/packages/core/src/checker.ts +3 -3
  18. package/packages/core/src/cli.ts +40 -38
  19. package/packages/core/src/contract.ts +749 -0
  20. package/packages/core/src/devhost.ts +4 -3
  21. package/packages/core/src/diagnostics.ts +5 -7
  22. package/packages/core/src/{transpile.ts → frontend.ts} +38 -50
  23. package/packages/core/src/infer.ts +1 -1
  24. package/packages/core/src/typed_ast.ts +16 -15
  25. package/packages/core/src/wyhash.ts +79 -0
  26. package/skill-data/native-ui/SKILL.md +4 -2
  27. package/skill-data/ts-core/SKILL.md +29 -29
  28. package/src/platform/macos/appkit_host.m +51 -3
  29. package/src/platform/types.zig +4 -0
  30. package/src/platform/windows/gpu_surface_renderer.cpp +2280 -0
  31. package/src/platform/windows/gpu_surface_renderer.h +86 -0
  32. package/src/platform/windows/root.zig +298 -20
  33. package/src/platform/windows/webview2_host.cpp +343 -33
  34. package/src/primitives/canvas/code.zig +50 -0
  35. package/src/primitives/canvas/code_tests.zig +174 -1
  36. package/src/primitives/canvas/frame.zig +45 -1
  37. package/src/primitives/canvas/gpu.zig +6 -0
  38. package/src/primitives/canvas/render_tests.zig +93 -0
  39. package/src/primitives/canvas/root.zig +2 -0
  40. package/src/primitives/canvas/serialization.zig +150 -21
  41. package/src/primitives/canvas/themes/geist.zig +51 -5
  42. package/src/primitives/canvas/tokens.zig +33 -4
  43. package/src/primitives/canvas/ui.zig +52 -7
  44. package/src/primitives/canvas/ui_markup.zig +38 -1
  45. package/src/primitives/canvas/ui_markup_compiled.zig +28 -0
  46. package/src/primitives/canvas/ui_markup_contract.zig +9 -0
  47. package/src/primitives/canvas/ui_markup_view.zig +28 -0
  48. package/src/primitives/canvas/ui_markup_view_tests.zig +10 -2
  49. package/src/primitives/canvas/ui_schema.zig +5 -0
  50. package/src/primitives/canvas/ui_schema_tests.zig +4 -3
  51. package/src/primitives/canvas/ui_tests.zig +14 -0
  52. package/src/primitives/canvas/widget_builtin_tests.zig +513 -13
  53. package/src/primitives/canvas/widget_invalidation.zig +11 -1
  54. package/src/primitives/canvas/widget_layout.zig +260 -21
  55. package/src/primitives/canvas/widget_metrics.zig +45 -9
  56. package/src/primitives/canvas/widget_render.zig +220 -70
  57. package/src/primitives/canvas/widget_render_controls.zig +79 -21
  58. package/src/primitives/canvas/widget_render_style.zig +52 -8
  59. package/src/primitives/canvas/widget_text_input.zig +2 -0
  60. package/src/primitives/canvas/widgets.zig +53 -2
  61. package/src/runtime/canvas_frame.zig +60 -7
  62. package/src/runtime/canvas_frame_invalidation_tests.zig +80 -0
  63. package/src/runtime/canvas_frame_packet_tests.zig +83 -9
  64. package/src/runtime/canvas_frame_patch_tests.zig +16 -0
  65. package/src/runtime/canvas_images.zig +8 -2
  66. package/src/runtime/canvas_widget_clipboard_tests.zig +1 -1
  67. package/src/runtime/canvas_widget_runtime.zig +11 -8
  68. package/src/runtime/effects.zig +6 -0
  69. package/src/runtime/effects_tests.zig +30 -0
  70. package/src/runtime/gpu_surface_events.zig +38 -7
  71. package/src/runtime/media_surface_tests.zig +1 -1
  72. package/src/runtime/runtime_event_tests.zig +74 -0
  73. package/src/runtime/ts_core_host.zig +38 -38
  74. package/src/runtime/ts_ui_app.zig +12 -12
  75. package/src/runtime/ui_app.zig +10 -8
  76. package/src/runtime/ui_app_tests.zig +67 -0
  77. package/src/runtime/view.zig +6 -0
  78. package/src/runtime/view_canvas.zig +15 -0
  79. package/src/runtime/view_widget_text.zig +6 -4
  80. package/src/runtime/window_view_runtime.zig +1 -0
  81. package/src/tooling/manifest.zig +32 -0
  82. package/src/tooling/raw_manifest.zig +4 -0
  83. package/src/tooling/templates.zig +34 -26
  84. package/src/tooling/ts_core.zig +55 -34
  85. package/src/tooling/verbs.zig +1 -1
  86. package/tools/corewire/core_abi.zig +169 -0
  87. package/tools/corewire/emit.zig +2418 -0
  88. package/tools/corewire/emit_facade.zig +3984 -0
  89. package/tools/corewire/emit_profile.zig +501 -0
  90. package/tools/corewire/main.zig +561 -0
  91. package/tools/corewire/shim_rt.zig +632 -0
  92. package/tools/corewire/sidecar.zig +2507 -0
  93. package/packages/core/rt/rt.zig +0 -1986
  94. package/packages/core/src/emitter.ts +0 -11898
@@ -1,21 +1,37 @@
1
1
  {
2
2
  "name": "@native-sdk/core",
3
- "version": "0.7.1",
3
+ "version": "0.8.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@native-sdk/core",
9
- "version": "0.7.1",
9
+ "version": "0.8.0",
10
+ "dependencies": {
11
+ "scriptc": "0.0.22"
12
+ },
10
13
  "devDependencies": {
11
- "@typescript/old": "npm:typescript@6.0.3",
12
- "@typescript/typescript6": "6.0.2"
14
+ "@typescript/old": "npm:typescript@6.0.3"
13
15
  }
14
16
  },
17
+ "node_modules/@scriptc/compiler": {
18
+ "version": "0.0.22",
19
+ "integrity": "sha512-cZil7ZgK64yRpSk1X3BSq1Q2DBru53KfC4X0i/qa0vHNk/rvk3teDzykSP5l3nb5wY2ckh0Es3fojfD0kUp/gA==",
20
+ "license": "Apache-2.0",
21
+ "dependencies": {
22
+ "@scriptc/runtime": "0.0.22",
23
+ "typescript": "7.0.2",
24
+ "typescript5": "npm:typescript@5.9.3"
25
+ }
26
+ },
27
+ "node_modules/@scriptc/runtime": {
28
+ "version": "0.0.22",
29
+ "integrity": "sha512-UytlS/6vxWXYIpIO2lQYVh4xTzMoybX0Uz1wKA41ezq62sMeuhHT6JVappUG55DgVNAWGgMI/WAHun2TeRutNg==",
30
+ "license": "Apache-2.0"
31
+ },
15
32
  "node_modules/@typescript/old": {
16
33
  "name": "typescript",
17
34
  "version": "6.0.3",
18
- "resolved": "https://registry.npmjs.org/typescript/-/typescript-6.0.3.tgz",
19
35
  "integrity": "sha512-y2TvuxSZPDyQakkFRPZHKFm+KKVqIisdg9/CZwm9ftvKXLP8NRWj38/ODjNbr43SsoXqNuAisEf1GdCxqWcdBw==",
20
36
  "dev": true,
21
37
  "license": "Apache-2.0",
@@ -27,17 +43,364 @@
27
43
  "node": ">=14.17"
28
44
  }
29
45
  },
30
- "node_modules/@typescript/typescript6": {
31
- "version": "6.0.2",
32
- "resolved": "https://registry.npmjs.org/@typescript/typescript6/-/typescript6-6.0.2.tgz",
33
- "integrity": "sha512-mbCddXd+jm7hfx7w2YU64/Av4/NqqeG3GoRZgxPcgoTxYjhrcfJRw9ULch71SS4G+Q3bOXFhRvPqjguN0Hyp5w==",
34
- "dev": true,
46
+ "node_modules/@typescript/typescript-aix-ppc64": {
47
+ "version": "7.0.2",
48
+ "integrity": "sha512-MTKKkWB7p/0E9xi1d1tHtZ5PiLkGEMIq88pK2CubZjOsLtYTLqhgIgi6zepFa+9GHZ6h05NMCkQxGKiPXMxXtQ==",
49
+ "cpu": [
50
+ "ppc64"
51
+ ],
52
+ "license": "Apache-2.0",
53
+ "optional": true,
54
+ "os": [
55
+ "aix"
56
+ ],
57
+ "engines": {
58
+ "node": ">=16.20.0"
59
+ }
60
+ },
61
+ "node_modules/@typescript/typescript-darwin-arm64": {
62
+ "version": "7.0.2",
63
+ "integrity": "sha512-gowzar9MwS/aRWp6f3a4KUqzRjAZjOsmGNCM6LcTgXum+dBfgsBVMN+AgvOCCbguXyick6LJhpBszxMebJ8syA==",
64
+ "cpu": [
65
+ "arm64"
66
+ ],
67
+ "license": "Apache-2.0",
68
+ "optional": true,
69
+ "os": [
70
+ "darwin"
71
+ ],
72
+ "engines": {
73
+ "node": ">=16.20.0"
74
+ }
75
+ },
76
+ "node_modules/@typescript/typescript-darwin-x64": {
77
+ "version": "7.0.2",
78
+ "integrity": "sha512-SZ9xZInqApNlNGc9s0W1VSsktYSOe9cFqNOIqmN1Gs8SmkjKZYFt017G4VwPxASInODuAdbTW7sXiFUf893RgA==",
79
+ "cpu": [
80
+ "x64"
81
+ ],
82
+ "license": "Apache-2.0",
83
+ "optional": true,
84
+ "os": [
85
+ "darwin"
86
+ ],
87
+ "engines": {
88
+ "node": ">=16.20.0"
89
+ }
90
+ },
91
+ "node_modules/@typescript/typescript-freebsd-arm64": {
92
+ "version": "7.0.2",
93
+ "integrity": "sha512-W5NH4y/J0plIIS5b2xvTEkU7JFxyqdMAOgf+Ilhl0vHQXKO5dZoxd+C/jEtq56c4F3wk71RB4BMRQ2XdI+bwYQ==",
94
+ "cpu": [
95
+ "arm64"
96
+ ],
97
+ "license": "Apache-2.0",
98
+ "optional": true,
99
+ "os": [
100
+ "freebsd"
101
+ ],
102
+ "engines": {
103
+ "node": ">=16.20.0"
104
+ }
105
+ },
106
+ "node_modules/@typescript/typescript-freebsd-x64": {
107
+ "version": "7.0.2",
108
+ "integrity": "sha512-UMGDx5sTpzNw3WiPebH7l90IWfJggEd+egHt/q6p7/Cm3zqoV7VxkGXt+3DxPIw8CcmvAB0j3sVVfbhX+M4Tpw==",
109
+ "cpu": [
110
+ "x64"
111
+ ],
112
+ "license": "Apache-2.0",
113
+ "optional": true,
114
+ "os": [
115
+ "freebsd"
116
+ ],
117
+ "engines": {
118
+ "node": ">=16.20.0"
119
+ }
120
+ },
121
+ "node_modules/@typescript/typescript-linux-arm": {
122
+ "version": "7.0.2",
123
+ "integrity": "sha512-gffT3xPz9sR7j/YJExkyPntrI0P2EP9XbOyWzth2/Gs0RstK+90RBcO0ncXoXy/beYll1SXw846Nf2zdnEz0QQ==",
124
+ "cpu": [
125
+ "arm"
126
+ ],
127
+ "license": "Apache-2.0",
128
+ "optional": true,
129
+ "os": [
130
+ "linux"
131
+ ],
132
+ "engines": {
133
+ "node": ">=16.20.0"
134
+ }
135
+ },
136
+ "node_modules/@typescript/typescript-linux-arm64": {
137
+ "version": "7.0.2",
138
+ "integrity": "sha512-Qh4eU4/y3yDjnfjjyPYihMj5/ODIlmt+Bzu17OI+fiSRDW57QmU5SiN63exPRNJPKUzcc1INa1NXdrJ+MqHjUQ==",
139
+ "cpu": [
140
+ "arm64"
141
+ ],
142
+ "license": "Apache-2.0",
143
+ "optional": true,
144
+ "os": [
145
+ "linux"
146
+ ],
147
+ "engines": {
148
+ "node": ">=16.20.0"
149
+ }
150
+ },
151
+ "node_modules/@typescript/typescript-linux-loong64": {
152
+ "version": "7.0.2",
153
+ "integrity": "sha512-uEHck9i8hoAzXPiYRib1O7miOnz23SxIeVl6F4LXox+qov1K35jHcEW6VHKvZI+pyvl7fZEP4MCU5LYvIq1GuQ==",
154
+ "cpu": [
155
+ "loong64"
156
+ ],
157
+ "license": "Apache-2.0",
158
+ "optional": true,
159
+ "os": [
160
+ "linux"
161
+ ],
162
+ "engines": {
163
+ "node": ">=16.20.0"
164
+ }
165
+ },
166
+ "node_modules/@typescript/typescript-linux-mips64el": {
167
+ "version": "7.0.2",
168
+ "integrity": "sha512-R4KvAMnE43W5Qeqb0Ly56O3mWMWIAgsMyz36DCaycd5nbg/9kzm0liw3JocfRqyJY0KPmzFjbswozXyW0DnIYA==",
169
+ "cpu": [
170
+ "mips64el"
171
+ ],
172
+ "license": "Apache-2.0",
173
+ "optional": true,
174
+ "os": [
175
+ "linux"
176
+ ],
177
+ "engines": {
178
+ "node": ">=16.20.0"
179
+ }
180
+ },
181
+ "node_modules/@typescript/typescript-linux-ppc64": {
182
+ "version": "7.0.2",
183
+ "integrity": "sha512-DORx5b3sd/4S7eayxm4FQv+A7CrkUIGRaHiwI8oiHTAI1fAPWhF4J0vAlkC8biAlHSVVwxMQ3tjZ2/DVbnQiiA==",
184
+ "cpu": [
185
+ "ppc64"
186
+ ],
187
+ "license": "Apache-2.0",
188
+ "optional": true,
189
+ "os": [
190
+ "linux"
191
+ ],
192
+ "engines": {
193
+ "node": ">=16.20.0"
194
+ }
195
+ },
196
+ "node_modules/@typescript/typescript-linux-riscv64": {
197
+ "version": "7.0.2",
198
+ "integrity": "sha512-wf0jqEDOjrPRnKwYRyyJDRo11KMbvMFrU+q4zqKyChODBzvlkbhNQfKvLxQCcwTpdDaXSHZTVuh0JoCrKCUMHQ==",
199
+ "cpu": [
200
+ "riscv64"
201
+ ],
202
+ "license": "Apache-2.0",
203
+ "optional": true,
204
+ "os": [
205
+ "linux"
206
+ ],
207
+ "engines": {
208
+ "node": ">=16.20.0"
209
+ }
210
+ },
211
+ "node_modules/@typescript/typescript-linux-s390x": {
212
+ "version": "7.0.2",
213
+ "integrity": "sha512-IkwJc3L7yhytWd/ewjyxNDfOmswCm9GWMJT/ue/dU4aZNbwZeYAetq42VyLmsmSjvoX7z74X6ZaYCtzAr0EuGw==",
214
+ "cpu": [
215
+ "s390x"
216
+ ],
217
+ "license": "Apache-2.0",
218
+ "optional": true,
219
+ "os": [
220
+ "linux"
221
+ ],
222
+ "engines": {
223
+ "node": ">=16.20.0"
224
+ }
225
+ },
226
+ "node_modules/@typescript/typescript-linux-x64": {
227
+ "version": "7.0.2",
228
+ "integrity": "sha512-EYdf2cNg7rgCWJnxCdJ+F3V39O8ihb37eHAu1LK8oAFizgTQbPOK7zHHXbPt8rX24COqODXeI3sIf0fCXG7H/A==",
229
+ "cpu": [
230
+ "x64"
231
+ ],
232
+ "license": "Apache-2.0",
233
+ "optional": true,
234
+ "os": [
235
+ "linux"
236
+ ],
237
+ "engines": {
238
+ "node": ">=16.20.0"
239
+ }
240
+ },
241
+ "node_modules/@typescript/typescript-netbsd-arm64": {
242
+ "version": "7.0.2",
243
+ "integrity": "sha512-+polYF4MF04aPpO5FTkHran9yUQDSXqy5GiSDKpsll5jy3l3+g9QLhpf39T+ePtefhXLOGrLl0QIjkQP6VnelA==",
244
+ "cpu": [
245
+ "arm64"
246
+ ],
247
+ "license": "Apache-2.0",
248
+ "optional": true,
249
+ "os": [
250
+ "netbsd"
251
+ ],
252
+ "engines": {
253
+ "node": ">=16.20.0"
254
+ }
255
+ },
256
+ "node_modules/@typescript/typescript-netbsd-x64": {
257
+ "version": "7.0.2",
258
+ "integrity": "sha512-8YIT0EHM/3dq10ZOVF/A7pc/YSMtbcecct4rWtexrnSCHOPcpC2KTLXfTCR6vDpnSiY12heNb1GiN/wu+T/FyA==",
259
+ "cpu": [
260
+ "x64"
261
+ ],
262
+ "license": "Apache-2.0",
263
+ "optional": true,
264
+ "os": [
265
+ "netbsd"
266
+ ],
267
+ "engines": {
268
+ "node": ">=16.20.0"
269
+ }
270
+ },
271
+ "node_modules/@typescript/typescript-openbsd-arm64": {
272
+ "version": "7.0.2",
273
+ "integrity": "sha512-APT8+ClYnuYm1u9+kgGXoMj2VzWzcymwh2gNSQVySHfkRDGOTVkoWLjCmOQSaO+PoqQ57B0flRp9SA+7GnnkzQ==",
274
+ "cpu": [
275
+ "arm64"
276
+ ],
277
+ "license": "Apache-2.0",
278
+ "optional": true,
279
+ "os": [
280
+ "openbsd"
281
+ ],
282
+ "engines": {
283
+ "node": ">=16.20.0"
284
+ }
285
+ },
286
+ "node_modules/@typescript/typescript-openbsd-x64": {
287
+ "version": "7.0.2",
288
+ "integrity": "sha512-yX7s+Q0Dln0Dt9tEzZsAjXXR/+ytBM7AlglaqyeMPxQszJ1JhlJdZ6jLA+IzldHtflX81em7lDao1xXu+aRRkg==",
289
+ "cpu": [
290
+ "x64"
291
+ ],
292
+ "license": "Apache-2.0",
293
+ "optional": true,
294
+ "os": [
295
+ "openbsd"
296
+ ],
297
+ "engines": {
298
+ "node": ">=16.20.0"
299
+ }
300
+ },
301
+ "node_modules/@typescript/typescript-sunos-x64": {
302
+ "version": "7.0.2",
303
+ "integrity": "sha512-dLJDGaLZ1D4HPQn62u1n8mBDkJREwMsAkCdkwd4Ieqw+x3TUyTsqY0YiBCtE6H6OzzgGk3iuZ3vFWRS+E8/d1g==",
304
+ "cpu": [
305
+ "x64"
306
+ ],
307
+ "license": "Apache-2.0",
308
+ "optional": true,
309
+ "os": [
310
+ "sunos"
311
+ ],
312
+ "engines": {
313
+ "node": ">=16.20.0"
314
+ }
315
+ },
316
+ "node_modules/@typescript/typescript-win32-arm64": {
317
+ "version": "7.0.2",
318
+ "integrity": "sha512-Gyl1Vy6OsWesLzmq+EP0Fb7b4Nid5232AvcA2SFcdYreldpNtYFFofPjnt62y9hQy7VTaZp65ICJjuAQRaVcIQ==",
319
+ "cpu": [
320
+ "arm64"
321
+ ],
322
+ "license": "Apache-2.0",
323
+ "optional": true,
324
+ "os": [
325
+ "win32"
326
+ ],
327
+ "engines": {
328
+ "node": ">=16.20.0"
329
+ }
330
+ },
331
+ "node_modules/@typescript/typescript-win32-x64": {
332
+ "version": "7.0.2",
333
+ "integrity": "sha512-0BQ3HkAHHlKLSp1qRvf3SUhGpGsDuhB/jgFw75guyqbxJqEaS0Cw/VFO8i2nHglJUzQCRtMMR/IBAKE3ETMC4g==",
334
+ "cpu": [
335
+ "x64"
336
+ ],
337
+ "license": "Apache-2.0",
338
+ "optional": true,
339
+ "os": [
340
+ "win32"
341
+ ],
342
+ "engines": {
343
+ "node": ">=16.20.0"
344
+ }
345
+ },
346
+ "node_modules/scriptc": {
347
+ "version": "0.0.22",
348
+ "integrity": "sha512-gJQ5Johx477Al1EqZOTeXOPsPgwzSOvVljIc9l1S0BqhaffyZtxXa1Mm3YFKZaCV3u4YNAEMsbO9EBgvW1awDg==",
35
349
  "license": "Apache-2.0",
36
350
  "dependencies": {
37
- "@typescript/old": "npm:typescript@^6"
351
+ "@scriptc/compiler": "0.0.22"
352
+ },
353
+ "bin": {
354
+ "scriptc": "dist/main.js"
355
+ },
356
+ "engines": {
357
+ "node": ">=20"
358
+ }
359
+ },
360
+ "node_modules/typescript": {
361
+ "version": "7.0.2",
362
+ "integrity": "sha512-8FYau96o3NKOhbjKi/qNvG/W5jhzxkbdm5sj9AbZ/5T5sWqn3hJgLfGx27sRKZWTvyzCP8dLRBTf5tBTSRVUNA==",
363
+ "license": "Apache-2.0",
364
+ "bin": {
365
+ "tsc": "bin/tsc"
366
+ },
367
+ "engines": {
368
+ "node": ">=16.20.0"
38
369
  },
370
+ "optionalDependencies": {
371
+ "@typescript/typescript-aix-ppc64": "7.0.2",
372
+ "@typescript/typescript-darwin-arm64": "7.0.2",
373
+ "@typescript/typescript-darwin-x64": "7.0.2",
374
+ "@typescript/typescript-freebsd-arm64": "7.0.2",
375
+ "@typescript/typescript-freebsd-x64": "7.0.2",
376
+ "@typescript/typescript-linux-arm": "7.0.2",
377
+ "@typescript/typescript-linux-arm64": "7.0.2",
378
+ "@typescript/typescript-linux-loong64": "7.0.2",
379
+ "@typescript/typescript-linux-mips64el": "7.0.2",
380
+ "@typescript/typescript-linux-ppc64": "7.0.2",
381
+ "@typescript/typescript-linux-riscv64": "7.0.2",
382
+ "@typescript/typescript-linux-s390x": "7.0.2",
383
+ "@typescript/typescript-linux-x64": "7.0.2",
384
+ "@typescript/typescript-netbsd-arm64": "7.0.2",
385
+ "@typescript/typescript-netbsd-x64": "7.0.2",
386
+ "@typescript/typescript-openbsd-arm64": "7.0.2",
387
+ "@typescript/typescript-openbsd-x64": "7.0.2",
388
+ "@typescript/typescript-sunos-x64": "7.0.2",
389
+ "@typescript/typescript-win32-arm64": "7.0.2",
390
+ "@typescript/typescript-win32-x64": "7.0.2"
391
+ }
392
+ },
393
+ "node_modules/typescript5": {
394
+ "name": "typescript",
395
+ "version": "5.9.3",
396
+ "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
397
+ "license": "Apache-2.0",
39
398
  "bin": {
40
- "tsc6": "bin/tsc6"
399
+ "tsc": "bin/tsc",
400
+ "tsserver": "bin/tsserver"
401
+ },
402
+ "engines": {
403
+ "node": ">=14.17"
41
404
  }
42
405
  }
43
406
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@native-sdk/core",
3
- "version": "0.7.1",
4
- "description": "The TypeScript authoring tier: the app-core subset, its dev-time transpiler to arena-backed Zig, and the SDK module cores import",
3
+ "version": "0.8.0",
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",
7
7
  "url": "git+https://github.com/vercel-labs/native.git",
@@ -11,7 +11,8 @@
11
11
  "type": "module",
12
12
  "types": "./sdk/core.ts",
13
13
  "files": [
14
- "sdk"
14
+ "sdk",
15
+ "compile-surface"
15
16
  ],
16
17
  "exports": {
17
18
  ".": {
@@ -29,10 +30,12 @@
29
30
  },
30
31
  "scripts": {
31
32
  "test": "node --test \"test/*.test.ts\"",
32
- "gate": "node scripts/gate.mjs"
33
+ "build:declarations": "node scripts/gen_declarations.mjs"
33
34
  },
34
35
  "devDependencies": {
35
- "@typescript/old": "npm:typescript@6.0.3",
36
- "@typescript/typescript6": "6.0.2"
36
+ "@typescript/old": "npm:typescript@6.0.3"
37
+ },
38
+ "dependencies": {
39
+ "scriptc": "0.0.22"
37
40
  }
38
41
  }
@@ -0,0 +1,58 @@
1
+ // The compiler-truth typecheck: run the pinned external core compiler's
2
+ // analyzer over the author's entry with the shipped SDK declarations
3
+ // mapped, so `native check` answers with the SAME compiler that will
4
+ // build the core — a verdict the frontend's own checker can only
5
+ // approximate from a different TypeScript line.
6
+ //
7
+ // node compiler_typecheck.mjs <entry.ts>
8
+ //
9
+ // Exit 0: the compiler's analyzer accepts the program (its static-subset
10
+ // findings are compile-time concerns, not check failures). Exit 1: the
11
+ // program does not typecheck under the compiler — its errors, already
12
+ // printed verbatim, are the teaching. Exit 2: toolchain missing/broken.
13
+ import { spawnSync } from "node:child_process";
14
+ import fs from "node:fs";
15
+ import path from "node:path";
16
+ import { createRequire } from "node:module";
17
+ import { fileURLToPath } from "node:url";
18
+
19
+ const entry = process.argv[2];
20
+ if (!entry) {
21
+ console.error("usage: compiler_typecheck.mjs <entry.ts>");
22
+ process.exit(2);
23
+ }
24
+ const here = path.dirname(fileURLToPath(import.meta.url));
25
+ const coreRoot = path.resolve(here, "..");
26
+ let compilerJs;
27
+ try {
28
+ compilerJs = createRequire(path.join(coreRoot, "package.json")).resolve("scriptc/dist/main.js");
29
+ } catch {
30
+ console.error("the external core compiler is not installed — run `npm ci --include=dev` in the SDK's packages/core");
31
+ process.exit(2);
32
+ }
33
+ // The shipped declaration files stand in for the SDK's module surface;
34
+ // value imports stay external-host findings, which is correct — the
35
+ // compile stage links the real implementations.
36
+ const maps = [];
37
+ for (const [specifier, file] of [
38
+ ["@native-sdk/core", "sdk/core.d.ts"],
39
+ ["@native-sdk/core/text", "sdk/text.d.ts"],
40
+ ["@native-sdk/core/events", "sdk/events.d.ts"],
41
+ ]) {
42
+ const p = path.join(coreRoot, file);
43
+ if (fs.existsSync(p)) maps.push("--external-types", `${specifier}=${p}`);
44
+ }
45
+ const probe = spawnSync(process.execPath, [compilerJs, "coverage", entry, ...maps], { encoding: "utf8" });
46
+ const out = `${probe.stdout ?? ""}${probe.stderr ?? ""}`;
47
+ if (probe.status === 0) process.exit(0);
48
+ // Analyzer refusals for TYPE errors carry the compiler's own diagnostics;
49
+ // pass them through untouched and fail the check.
50
+ if (/TypeScript error/.test(out) || /error SC0001/.test(out)) {
51
+ process.stderr.write(out);
52
+ process.exit(1);
53
+ }
54
+ // Any other nonzero outcome (analyzer internal trouble) must not wedge
55
+ // `native check`: the compile stage will judge for real.
56
+ process.stderr.write(out);
57
+ console.error("native check: the external compiler's analyzer could not run to a verdict here; the build will judge for real");
58
+ process.exit(0);
@@ -0,0 +1,130 @@
1
+ // Generate the Unicode simple case-mapping tables the node devhost
2
+ // polyfill case-maps from. Reads UnicodeData.txt (fields 12/13: Simple
3
+ // Uppercase / Simple Lowercase — never SpecialCasing, never locale
4
+ // rules) and emits the compressed range tables:
5
+ //
6
+ // src/text_tables.ts the whole file (the node-polyfill source)
7
+ //
8
+ // Byte-honest contract: simple case mapping is code point -> code point,
9
+ // locale-independent, with no special casing (no ß -> SS, no context
10
+ // forms), so `.toUpperCase()`/`.toLowerCase()` on core bytes produce the
11
+ // same bytes under node as in the compiled core (the e2e batteries pin
12
+ // the native side against real archives).
13
+ //
14
+ // Compression: consecutive mapped code points sharing one delta collapse
15
+ // into {lo, count, stride, delta} runs (stride 2 covers the alternating
16
+ // upper/lower pairs like U+0100 Ā / U+0101 ā). Unicode 17.0.0 yields ~200
17
+ // ranges per direction at 8 bytes each — ~3.1 KiB total in the binary.
18
+ //
19
+ // Regenerate (a Unicode version bump is the only reason to):
20
+ //
21
+ // node scripts/gen_case_tables.mjs [path/to/UnicodeData.txt]
22
+ //
23
+ // Without a path the script downloads the PINNED version below from
24
+ // unicode.org. Both outputs are committed; CI never runs this.
25
+
26
+ import fs from "node:fs";
27
+ import path from "node:path";
28
+ import { fileURLToPath } from "node:url";
29
+
30
+ const UNICODE_VERSION = "17.0.0";
31
+ const UCD_URL = `https://www.unicode.org/Public/${UNICODE_VERSION}/ucd/UnicodeData.txt`;
32
+
33
+ const pkg = path.dirname(path.dirname(fileURLToPath(import.meta.url)));
34
+
35
+ async function loadUnicodeData() {
36
+ const arg = process.argv[2];
37
+ if (arg) return fs.readFileSync(arg, "utf8");
38
+ console.log(`downloading ${UCD_URL}`);
39
+ const res = await fetch(UCD_URL);
40
+ if (!res.ok) throw new Error(`download failed: ${res.status} ${res.statusText}`);
41
+ return res.text();
42
+ }
43
+
44
+ /// [codePoint, mappedCodePoint] pairs for one UnicodeData field
45
+ /// (12 = Simple_Uppercase_Mapping, 13 = Simple_Lowercase_Mapping).
46
+ function collectMappings(text, field) {
47
+ const out = [];
48
+ for (const line of text.split("\n")) {
49
+ if (!line) continue;
50
+ const fields = line.split(";");
51
+ const mapped = fields[field];
52
+ if (!mapped) continue;
53
+ out.push([parseInt(fields[0], 16), parseInt(mapped, 16)]);
54
+ }
55
+ out.sort((a, b) => a[0] - b[0]);
56
+ return out;
57
+ }
58
+
59
+ /// Collapse sorted [cp, mapped] pairs into {lo, count, stride, delta} runs.
60
+ /// A run holds `count` mapped code points at lo, lo+stride, ...; every one
61
+ /// maps to itself + delta. stride is 1 or 2 (2 = the alternating pairs).
62
+ function compressRanges(entries) {
63
+ const out = [];
64
+ for (const [cp, to] of entries) {
65
+ const delta = to - cp;
66
+ const last = out[out.length - 1];
67
+ if (last && last.delta === delta) {
68
+ const step = cp - (last.lo + (last.count - 1) * last.stride);
69
+ if (last.count === 1 && (step === 1 || step === 2)) {
70
+ last.stride = step;
71
+ last.count += 1;
72
+ continue;
73
+ }
74
+ if (last.count > 1 && step === last.stride) {
75
+ last.count += 1;
76
+ continue;
77
+ }
78
+ }
79
+ out.push({ lo: cp, delta, stride: 1, count: 1 });
80
+ }
81
+ for (const r of out) {
82
+ // The packed layouts below: lo u21, count u16, stride bit, delta i26.
83
+ if (r.lo > 0x10ffff || r.count > 0xffff || Math.abs(r.delta) >= 1 << 25) {
84
+ throw new Error(`range out of packed bounds: ${JSON.stringify(r)}`);
85
+ }
86
+ }
87
+ return out;
88
+ }
89
+
90
+ function tsRanges(name, ranges) {
91
+ // Flat quadruples [lo, count, stride, delta] — the same runs, same order.
92
+ const parts = ranges.map((r) => `${r.lo}, ${r.count}, ${r.stride}, ${r.delta}`);
93
+ const lines = [`export const ${name}: readonly number[] = [`];
94
+ for (const p of parts) lines.push(` ${p},`);
95
+ lines.push("];");
96
+ return lines.join("\n");
97
+ }
98
+
99
+ const text = await loadUnicodeData();
100
+ const upper = compressRanges(collectMappings(text, 12));
101
+ const lower = compressRanges(collectMappings(text, 13));
102
+ const tableBytes = (upper.length + lower.length) * 8;
103
+
104
+ const header = (comment) =>
105
+ [
106
+ `${comment} Unicode ${UNICODE_VERSION} simple case mappings (UnicodeData.txt fields 12/13).`,
107
+ `${comment} GENERATED by scripts/gen_case_tables.mjs — do not edit by hand; regenerate with:`,
108
+ `${comment} node scripts/gen_case_tables.mjs [path/to/UnicodeData.txt]`,
109
+ `${comment} ${upper.length} + ${lower.length} ranges, 8 bytes each = ${tableBytes} bytes of table data.`,
110
+ ].join("\n");
111
+
112
+ // ---------------------------------------------------------- text_tables.ts
113
+
114
+ const tsPath = path.join(pkg, "src", "text_tables.ts");
115
+ const tsOut = [
116
+ "// The devhost polyfill's simple case-mapping tables (text_polyfill.ts),",
117
+ "// generated from one UnicodeData.txt read.",
118
+ header("//"),
119
+ "",
120
+ "// Flat quadruples [lo, count, stride, delta]: `count` mapped code points",
121
+ "// at lo, lo+stride, ...; each maps to itself + delta (stride 2 covers the",
122
+ "// alternating upper/lower pairs like U+0100 Ā / U+0101 ā).",
123
+ "",
124
+ tsRanges("SIMPLE_UPPER_RANGES", upper),
125
+ "",
126
+ tsRanges("SIMPLE_LOWER_RANGES", lower),
127
+ "",
128
+ ].join("\n");
129
+ fs.writeFileSync(tsPath, tsOut);
130
+ console.log(`wrote ${tsPath}`);