@stacksjs/stx 0.2.421 → 0.2.423

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 (251) hide show
  1. package/dist/{chunk-ep5jnqdb.js → chunk-02n071n7.js} +6 -6
  2. package/dist/chunk-03n23sh6.js +2 -0
  3. package/dist/chunk-07mxghsz.js +2 -0
  4. package/dist/{chunk-kjkwycce.js → chunk-0bmc75w6.js} +4 -4
  5. package/dist/{chunk-hyak4dzg.js → chunk-0hhq9hbq.js} +3 -3
  6. package/dist/{chunk-66k7yxnr.js → chunk-12pvnn1e.js} +4 -4
  7. package/dist/chunk-1497wcxc.js +2 -0
  8. package/dist/chunk-17n9e5wk.js +2 -0
  9. package/dist/chunk-1p8hc1ve.js +2 -0
  10. package/dist/chunk-1r3ghgsz.js +2 -0
  11. package/dist/{chunk-r8wze9ym.js → chunk-24e7qjb8.js} +2 -2
  12. package/dist/chunk-259ecbwa.js +2 -0
  13. package/dist/chunk-26gfsa9w.js +2 -0
  14. package/dist/{chunk-3ynkg5dz.js → chunk-2bpjq1qz.js} +2 -2
  15. package/dist/{chunk-11ra3sbc.js → chunk-2x9jd5w0.js} +3 -3
  16. package/dist/{chunk-k31fwm2w.js → chunk-3hmy75tw.js} +5 -5
  17. package/dist/{chunk-12b8akfg.js → chunk-3pxp0r0a.js} +3 -3
  18. package/dist/{chunk-x5ks23vx.js → chunk-3ry9ca1s.js} +2 -2
  19. package/dist/{chunk-th9s15es.js → chunk-45rfv3a5.js} +2 -2
  20. package/dist/chunk-47apfsxp.js +2 -0
  21. package/dist/{chunk-ax58cds3.js → chunk-48kgnqpk.js} +4 -4
  22. package/dist/{chunk-rsxvbnp4.js → chunk-4hd5wb8x.js} +3 -3
  23. package/dist/chunk-535nrr6j.js +2 -0
  24. package/dist/chunk-5mfhk69g.js +2 -0
  25. package/dist/{chunk-aync8qmk.js → chunk-5vwg3h5g.js} +2 -2
  26. package/dist/{chunk-tspmynvh.js → chunk-62chbqev.js} +1 -1
  27. package/dist/chunk-6c7294j8.js +2 -0
  28. package/dist/{chunk-z0ck9t6j.js → chunk-6cbvx87h.js} +5 -5
  29. package/dist/{chunk-kea18wnc.js → chunk-6fsbny9m.js} +3 -3
  30. package/dist/chunk-6gh2rvyz.js +2 -0
  31. package/dist/chunk-6j6gbp0y.js +2 -0
  32. package/dist/chunk-6jgjmycb.js +2 -0
  33. package/dist/{chunk-hjp990p8.js → chunk-6t278w29.js} +2 -2
  34. package/dist/{chunk-5vfyxxrp.js → chunk-6t7mxb0b.js} +2 -2
  35. package/dist/chunk-6wmxrn6x.js +2 -0
  36. package/dist/chunk-6wweqfg7.js +2 -0
  37. package/dist/{chunk-h1h6xe1k.js → chunk-7a9h7ycs.js} +5 -5
  38. package/dist/chunk-7pbv9mg7.js +2 -0
  39. package/dist/{chunk-09hhrjk9.js → chunk-89b2r1q0.js} +6 -6
  40. package/dist/{chunk-0varh725.js → chunk-8a0r2j8f.js} +3 -3
  41. package/dist/{chunk-pzngjk81.js → chunk-8nsbf2mz.js} +1074 -1074
  42. package/dist/{chunk-mg13q1kd.js → chunk-8zf5q1m3.js} +2 -2
  43. package/dist/chunk-9d53d0t6.js +2 -0
  44. package/dist/chunk-9j72har9.js +2 -0
  45. package/dist/chunk-9yqz5ge5.js +2 -0
  46. package/dist/chunk-a5c9n7an.js +2 -0
  47. package/dist/chunk-a836zn7c.js +2 -0
  48. package/dist/{chunk-8vq0qjq9.js → chunk-a8g6y9kw.js} +5 -5
  49. package/dist/{chunk-21a7p956.js → chunk-acwgap78.js} +1 -1
  50. package/dist/{chunk-qx3js9tk.js → chunk-aen2baze.js} +1 -1
  51. package/dist/chunk-ahgrkva8.js +2 -0
  52. package/dist/chunk-akbb6j7s.js +2 -0
  53. package/dist/chunk-avakcrbs.js +2 -0
  54. package/dist/{chunk-tafebmtg.js → chunk-axydabse.js} +2 -2
  55. package/dist/{chunk-4n6c5rp5.js → chunk-b7973zvk.js} +2 -2
  56. package/dist/{chunk-debz86rr.js → chunk-bxwe7wxj.js} +10 -10
  57. package/dist/{chunk-2ewa2sg5.js → chunk-c1dmr865.js} +3 -3
  58. package/dist/chunk-cenq2n6e.js +2 -0
  59. package/dist/{chunk-zvh2nnzr.js → chunk-cf6htz63.js} +1 -1
  60. package/dist/chunk-cnmz9543.js +2 -0
  61. package/dist/{chunk-bh4x090w.js → chunk-cx2rdew4.js} +13 -13
  62. package/dist/{chunk-wg1ttvs5.js → chunk-cznsm2n3.js} +2 -2
  63. package/dist/chunk-d1qzhawc.js +2 -0
  64. package/dist/chunk-d6hnvwre.js +2 -0
  65. package/dist/{chunk-014gmm8w.js → chunk-dcwjxq8n.js} +2 -2
  66. package/dist/chunk-dhqwg62x.js +2 -0
  67. package/dist/{chunk-z521cyfv.js → chunk-dmd6yk2x.js} +5 -5
  68. package/dist/chunk-e18qfegt.js +2 -0
  69. package/dist/chunk-eej89wkt.js +2 -0
  70. package/dist/chunk-ekxffxbd.js +2 -0
  71. package/dist/{chunk-hy9e3ny6.js → chunk-ex0tq6x2.js} +1 -1
  72. package/dist/{chunk-8drvzsk1.js → chunk-fg5ve6ey.js} +2 -2
  73. package/dist/{chunk-3kmhv1kf.js → chunk-fnt1q1sp.js} +11 -11
  74. package/dist/chunk-g67gg66e.js +2 -0
  75. package/dist/chunk-gq16fxc2.js +2 -0
  76. package/dist/{chunk-4e101kjp.js → chunk-h3c7z73m.js} +2 -2
  77. package/dist/chunk-h4avjh3q.js +2 -0
  78. package/dist/chunk-h7qte7ye.js +2 -0
  79. package/dist/{chunk-4mew0ae3.js → chunk-hb9gxad0.js} +3 -3
  80. package/dist/{chunk-0y7x0hvr.js → chunk-hg4k3nkr.js} +1 -1
  81. package/dist/{chunk-dhxbjw6k.js → chunk-hnep9jbj.js} +2 -2
  82. package/dist/chunk-hwycbxg7.js +2 -0
  83. package/dist/{chunk-34gy5zjm.js → chunk-j1q65enz.js} +2 -2
  84. package/dist/chunk-j5myfxe8.js +18 -0
  85. package/dist/{chunk-8jqy69td.js → chunk-j7zywbq0.js} +2 -2
  86. package/dist/{chunk-32y3767j.js → chunk-jbrdebzs.js} +7 -7
  87. package/dist/{chunk-1336h4sv.js → chunk-jj4pyeyj.js} +1 -1
  88. package/dist/{chunk-g1fxmp9z.js → chunk-k8sqs7j2.js} +4 -4
  89. package/dist/chunk-mg7jhx5v.js +2 -0
  90. package/dist/chunk-n16wa755.js +2 -0
  91. package/dist/chunk-ngv1c807.js +2 -0
  92. package/dist/{chunk-krr2vb0s.js → chunk-p2x7tjbt.js} +3 -3
  93. package/dist/{chunk-62r4fa4q.js → chunk-ptjqacjd.js} +2 -2
  94. package/dist/{chunk-rj3hyqff.js → chunk-qm1tt8g1.js} +2334 -2334
  95. package/dist/chunk-r7r5h2eh.js +2 -0
  96. package/dist/chunk-rhkx17d9.js +2 -0
  97. package/dist/{chunk-b1fg9vg7.js → chunk-s28eh0jn.js} +2 -2
  98. package/dist/{chunk-10967rws.js → chunk-s295vp9x.js} +3 -3
  99. package/dist/chunk-sazpw71r.js +4 -0
  100. package/dist/{chunk-20tdz0zs.js → chunk-sbdzqqr1.js} +6 -6
  101. package/dist/{chunk-qby6wxat.js → chunk-spx27cs4.js} +2 -2
  102. package/dist/{chunk-m16h8ea0.js → chunk-stxmwytg.js} +2 -2
  103. package/dist/{chunk-2tfe2g58.js → chunk-t3wh1jbk.js} +6 -6
  104. package/dist/{chunk-802pr252.js → chunk-tfexmdkt.js} +2 -2
  105. package/dist/{chunk-6aqcgrhw.js → chunk-tfz95n7j.js} +5 -5
  106. package/dist/chunk-thdbqsxq.js +2 -0
  107. package/dist/chunk-tpnfcb83.js +2 -0
  108. package/dist/chunk-tqkv4th9.js +2 -0
  109. package/dist/chunk-tznejj9h.js +2 -0
  110. package/dist/{chunk-ap6fehea.js → chunk-vfk725vm.js} +5 -5
  111. package/dist/chunk-vsrm9k7p.js +2 -0
  112. package/dist/chunk-vwms759h.js +2 -0
  113. package/dist/{chunk-xvzxrt9a.js → chunk-w2085fwx.js} +5 -5
  114. package/dist/chunk-w252cgnv.js +30 -0
  115. package/dist/chunk-whdw6dhb.js +2 -0
  116. package/dist/chunk-wtms9jhs.js +3 -0
  117. package/dist/chunk-wtqjfar3.js +2 -0
  118. package/dist/chunk-wx7kfet5.js +2 -0
  119. package/dist/chunk-wy873fy8.js +2 -0
  120. package/dist/{chunk-a4r19yxm.js → chunk-xa3wsmt5.js} +11 -11
  121. package/dist/chunk-xrbqf77j.js +2 -0
  122. package/dist/{chunk-757ec865.js → chunk-yaebdyfr.js} +2 -2
  123. package/dist/chunk-ycpq3gxc.js +2 -0
  124. package/dist/chunk-yd50awqp.js +3 -0
  125. package/dist/{chunk-csjw5esc.js → chunk-ydz7w2mt.js} +2 -2
  126. package/dist/chunk-yjgbxf26.js +2 -0
  127. package/dist/{chunk-jjnfj9nf.js → chunk-yqsza22w.js} +2 -2
  128. package/dist/{chunk-8j8k27xb.js → chunk-zbr333kf.js} +115 -31
  129. package/dist/chunk-zcyjdcpx.js +33 -0
  130. package/dist/{chunk-tqnysw0k.js → chunk-zfzcedw4.js} +4 -4
  131. package/dist/chunk-zm73n103.js +2 -0
  132. package/dist/cli.js +21 -21
  133. package/dist/component-renderer.js +54 -2
  134. package/dist/composables/use-outbox.d.ts +1 -0
  135. package/dist/composables/use-outbox.js +14 -4
  136. package/dist/craft-entry.js +2 -2
  137. package/dist/craft.js +2 -2
  138. package/dist/database.js +2 -2
  139. package/dist/native/bridge/protocol.d.ts +5 -0
  140. package/dist/native/bridge/protocol.js +3 -0
  141. package/dist/native/cli.js +12 -2
  142. package/dist/native/compiler/bundle.d.ts +4 -3
  143. package/dist/native/compiler/bundle.js +46 -51
  144. package/dist/native/compiler/component-mapping.d.ts +5 -0
  145. package/dist/native/compiler/component-mapping.js +90 -0
  146. package/dist/native/compiler/html-to-ir.js +42 -6
  147. package/dist/native/compiler/ir.d.ts +2 -0
  148. package/dist/native/compiler/render-screen.d.ts +4 -0
  149. package/dist/native/compiler/render-screen.js +10 -2
  150. package/dist/native/compiler/setup-script.d.ts +6 -0
  151. package/dist/native/compiler/setup-script.js +10 -0
  152. package/dist/native/components/primitives.d.ts +10 -0
  153. package/dist/native/index.d.ts +6 -24
  154. package/dist/native/index.js +1 -17
  155. package/dist/native/primitives/Button.stx +2 -1
  156. package/dist/native/primitives/Text.stx +2 -1
  157. package/dist/native/primitives/TextInput.stx +3 -1
  158. package/dist/native/prop-names.d.ts +2 -0
  159. package/dist/native/prop-names.js +71 -0
  160. package/dist/native/runtime/binding-tree.d.ts +31 -0
  161. package/dist/native/runtime/binding-tree.js +100 -0
  162. package/dist/native/runtime/craft-bridge.d.ts +9 -0
  163. package/dist/native/runtime/craft-bridge.js +231 -0
  164. package/dist/native/runtime/craft.d.ts +28 -3
  165. package/dist/native/runtime/jsc-globals.d.ts +16 -0
  166. package/dist/native/runtime/jsc-globals.js +64 -0
  167. package/dist/native/runtime/native-host.d.ts +3 -1
  168. package/dist/native/runtime/native-host.js +183 -33
  169. package/dist/native/runtime/shared-screen.d.ts +15 -0
  170. package/dist/native/runtime/shared-screen.js +41 -0
  171. package/dist/pwa.js +3 -3
  172. package/dist/signal-processing.d.ts +3 -1
  173. package/dist/signal-processing.js +4 -3
  174. package/dist/signals.js +104 -20
  175. package/dist/ssg.js +28 -28
  176. package/dist/variable-extractor.js +4 -1
  177. package/package.json +5 -5
  178. package/dist/chunk-0n76c3g8.js +0 -2
  179. package/dist/chunk-10fh9qhe.js +0 -2
  180. package/dist/chunk-18awnp9d.js +0 -2
  181. package/dist/chunk-2hswgxpb.js +0 -2
  182. package/dist/chunk-3zye6eh1.js +0 -2
  183. package/dist/chunk-4488r5j1.js +0 -2
  184. package/dist/chunk-4amznxaq.js +0 -2
  185. package/dist/chunk-5akd7qsb.js +0 -2
  186. package/dist/chunk-5eqd40k0.js +0 -2
  187. package/dist/chunk-6r9y4p81.js +0 -2
  188. package/dist/chunk-75zcwcrt.js +0 -2
  189. package/dist/chunk-89e1d0rz.js +0 -4
  190. package/dist/chunk-8nsqac4z.js +0 -2
  191. package/dist/chunk-8ttvazck.js +0 -2
  192. package/dist/chunk-8y4bqsxz.js +0 -2
  193. package/dist/chunk-ac033b93.js +0 -2
  194. package/dist/chunk-aj43359g.js +0 -2
  195. package/dist/chunk-aj8yq228.js +0 -2
  196. package/dist/chunk-as72dvvm.js +0 -2
  197. package/dist/chunk-awtrcb5m.js +0 -18
  198. package/dist/chunk-b01jqb5f.js +0 -2
  199. package/dist/chunk-b7z2yegr.js +0 -2
  200. package/dist/chunk-bfvaxrq0.js +0 -2
  201. package/dist/chunk-bkaw7sgz.js +0 -2
  202. package/dist/chunk-bmk0s261.js +0 -2
  203. package/dist/chunk-bvbank3z.js +0 -2
  204. package/dist/chunk-cvzkbsds.js +0 -2
  205. package/dist/chunk-cw6j75ck.js +0 -30
  206. package/dist/chunk-d2c5727w.js +0 -2
  207. package/dist/chunk-d5amzers.js +0 -2
  208. package/dist/chunk-dfchrqw5.js +0 -2
  209. package/dist/chunk-dscsvkfa.js +0 -2
  210. package/dist/chunk-eav0pt6d.js +0 -2
  211. package/dist/chunk-hahzjyxc.js +0 -2
  212. package/dist/chunk-hgqcqg1h.js +0 -2
  213. package/dist/chunk-hjdwf9gp.js +0 -2
  214. package/dist/chunk-jjm0ekw8.js +0 -2
  215. package/dist/chunk-jjtzm6dn.js +0 -3
  216. package/dist/chunk-k1am0dyg.js +0 -2
  217. package/dist/chunk-m2jphkdv.js +0 -2
  218. package/dist/chunk-mk7b3qdz.js +0 -2
  219. package/dist/chunk-ncvfjcr2.js +0 -2
  220. package/dist/chunk-p083sckk.js +0 -2
  221. package/dist/chunk-p7b17yr0.js +0 -2
  222. package/dist/chunk-pc178389.js +0 -2
  223. package/dist/chunk-q1v0jwr4.js +0 -2
  224. package/dist/chunk-r5gjb55x.js +0 -2
  225. package/dist/chunk-rj8rdd8n.js +0 -2
  226. package/dist/chunk-s0pmn48x.js +0 -2
  227. package/dist/chunk-s58yz9q0.js +0 -2
  228. package/dist/chunk-srdzwtsq.js +0 -2
  229. package/dist/chunk-tf44jyrh.js +0 -2
  230. package/dist/chunk-tfypkw4y.js +0 -3
  231. package/dist/chunk-vwxasbtx.js +0 -2
  232. package/dist/chunk-wynvh7dc.js +0 -2
  233. package/dist/chunk-x8rckpyz.js +0 -2
  234. package/dist/chunk-y4xs4m7p.js +0 -2
  235. package/dist/chunk-y8rpk1b9.js +0 -2
  236. package/dist/chunk-y9m93qkk.js +0 -2
  237. package/dist/chunk-ya0qecph.js +0 -27
  238. package/dist/chunk-ya9c8nec.js +0 -2
  239. package/dist/chunk-yvq1f313.js +0 -2
  240. package/dist/chunk-yy3dgwfm.js +0 -2
  241. package/dist/chunk-zpcz2kh6.js +0 -2
  242. package/dist/native/compiler/codegen.d.ts +0 -10
  243. package/dist/native/compiler/codegen.js +0 -145
  244. package/dist/native/compiler/parser.d.ts +0 -88
  245. package/dist/native/compiler/parser.js +0 -753
  246. package/dist/native/runtime/entry.d.ts +0 -1
  247. package/dist/native/runtime/entry.js +0 -3
  248. package/dist/native/runtime/index.d.ts +0 -45
  249. package/dist/native/runtime/index.js +0 -165
  250. package/dist/native/runtime/screen.d.ts +0 -43
  251. package/dist/native/runtime/screen.js +0 -808
@@ -0,0 +1,231 @@
1
+ import { STXBridge } from "../bridge/protocol.js";
2
+ function capabilityFlags(capabilities) {
3
+ return {
4
+ haptics: capabilities.has("haptics"),
5
+ speechRecognition: !1,
6
+ share: !1,
7
+ camera: !1,
8
+ biometric: capabilities.has("biometric"),
9
+ pushNotifications: !1,
10
+ secureStorage: capabilities.has("secureStorage"),
11
+ storage: capabilities.has("storage"),
12
+ localDatabase: capabilities.has("database"),
13
+ lifecycle: capabilities.has("lifecycle"),
14
+ geolocation: !1,
15
+ clipboard: capabilities.has("clipboard"),
16
+ contacts: !1,
17
+ calendar: !1,
18
+ localNotifications: capabilities.has("notifications"),
19
+ inAppPurchase: !1,
20
+ keepAwake: !1,
21
+ orientationLock: !1,
22
+ deepLinks: capabilities.has("deepLinks"),
23
+ flashlight: !1,
24
+ speech: !1,
25
+ network: !1,
26
+ deviceInfo: capabilities.has("device"),
27
+ fetch: capabilities.has("fetch"),
28
+ badge: !1,
29
+ appReview: !1
30
+ };
31
+ }
32
+ export function installCraftBridge(protocol, nativeBridge, target = globalThis, options = {}) {
33
+ const craft = target.craft = target.craft || {}, capabilities = new Set(nativeBridge.capabilities || []), request = (module, method, args) => protocol.callNativeAPI(module, method, ...args);
34
+ let appState = nativeBridge.initialAppState || "active", initialDeepLinkClaimed = !1;
35
+ const appStateHandlers = new Set, deepLinkHandlers = new Set, navButtonHandlers = new Set, navButtonPresses = new Map, routeName = options.routeName || "main", routeNames = options.routeNames || [routeName];
36
+ craft.platform = nativeBridge.platform || "unknown";
37
+ craft.capabilityProtocolVersion = Number(nativeBridge.capabilityProtocolVersion || 0);
38
+ craft.capabilities = capabilityFlags(capabilities);
39
+ craft.route = { name: routeName, params: target.__stxNativeParams || {} };
40
+ craft.appearance = { colorScheme: () => nativeBridge.colorScheme === "dark" ? "dark" : "light" };
41
+ craft.device = { getInfo: () => request("Device", "getInfo", []) };
42
+ craft.clipboard = {
43
+ write: (value) => request("Clipboard", "write", [value]),
44
+ read: () => request("Clipboard", "read", [])
45
+ };
46
+ craft.haptic = (style) => request("Haptics", "impact", [style || "medium"]);
47
+ const feedback = (answer) => answer.then(() => {}, (error) => {
48
+ if (error?.code === "CAPABILITY_DISABLED")
49
+ return;
50
+ throw error;
51
+ });
52
+ craft.haptics = {
53
+ impact: (style) => feedback(craft.haptic(style)),
54
+ notification: (type) => feedback(craft.haptic(type === "error" ? "heavy" : type === "warning" ? "medium" : "light")),
55
+ selection: () => feedback(craft.haptic("soft"))
56
+ };
57
+ craft.storage = Object.assign({ getSync: () => null, setSync: () => {
58
+ return;
59
+ } }, craft.storage || {}, {
60
+ get: (key) => request("Storage", "get", [key]),
61
+ set: (key, value) => request("Storage", "set", [key, value]),
62
+ remove: (key) => request("Storage", "remove", [key]),
63
+ clear: () => request("Storage", "clear", []),
64
+ keys: () => request("Storage", "keys", [])
65
+ });
66
+ craft.secureStorage = Object.assign({ getSync: () => null }, craft.secureStorage || {}, {
67
+ get: (key) => request("SecureStorage", "get", [key]),
68
+ set: (key, value) => request("SecureStorage", "set", [key, value]),
69
+ remove: (key) => request("SecureStorage", "remove", [key]),
70
+ delete: (key) => request("SecureStorage", "remove", [key]),
71
+ clear: () => request("SecureStorage", "clear", [])
72
+ });
73
+ craft.snapshots = Object.assign({ get: () => null, set: () => Promise.resolve(!1) }, craft.snapshots || {});
74
+ craft.biometrics = {
75
+ isAvailable: () => request("Biometrics", "isAvailable", []),
76
+ getBiometricType: () => request("Biometrics", "getBiometricType", []),
77
+ authenticate: (reason) => request("Biometrics", "authenticate", [reason || "Authenticate to continue"])
78
+ };
79
+ craft.db = {
80
+ execute: (sql, params = []) => request("Database", "execute", [sql, params]),
81
+ query: (sql, params = []) => request("Database", "query", [sql, params]),
82
+ beginTransaction: () => request("Database", "beginTransaction", []),
83
+ commit: () => request("Database", "commit", []),
84
+ rollback: () => request("Database", "rollback", [])
85
+ };
86
+ craft.notifications = {
87
+ show: (notification) => request("Notifications", "schedule", [notification]),
88
+ schedule: (notification) => request("Notifications", "schedule", [notification]),
89
+ cancel: (id) => request("Notifications", "cancel", [id]),
90
+ cancelAll: () => request("Notifications", "cancelAll", []),
91
+ pending: () => request("Notifications", "pending", [])
92
+ };
93
+ craft.scheduleNotification = craft.notifications.schedule;
94
+ craft.cancelNotification = craft.notifications.cancel;
95
+ craft.cancelAllNotifications = craft.notifications.cancelAll;
96
+ craft.getPendingNotifications = craft.notifications.pending;
97
+ const navigate = (type, screen, params) => {
98
+ if (!routeNames.includes(screen))
99
+ throw Error(`Unknown native screen: ${screen}`);
100
+ if (params !== void 0 && (params === null || typeof params !== "object" || Array.isArray(params)))
101
+ throw TypeError("Navigation params must be an object");
102
+ return protocol.send(type, { screen, params: params || {} });
103
+ }, hostSetOptions = craft.navigation && typeof craft.navigation.setOptions === "function" ? craft.navigation.setOptions.bind(craft.navigation) : null;
104
+ craft.navigation = Object.assign(craft.navigation || {}, {
105
+ push: (screen, params) => navigate("NAVIGATE", screen, params),
106
+ replace: (screen, params) => navigate("NAVIGATE_REPLACE", screen, params),
107
+ back: () => protocol.goBack(),
108
+ open: (path) => {
109
+ if (typeof path !== "string" || !path.trim())
110
+ throw TypeError("navigation.open needs a path, such as /m/workout/42");
111
+ return protocol.send("NAVIGATE_OPEN", { path });
112
+ },
113
+ setOptions: (navigationOptions) => {
114
+ if (!navigationOptions || typeof navigationOptions !== "object")
115
+ throw TypeError("navigation.setOptions needs an object");
116
+ const payload = {};
117
+ for (const key of Object.keys(navigationOptions))
118
+ if (key === "rightButtons" && Array.isArray(navigationOptions.rightButtons)) {
119
+ navButtonPresses.clear();
120
+ payload.rightButtons = navigationOptions.rightButtons.map((button) => {
121
+ const { onPress, ...rest } = button || {};
122
+ if (typeof onPress === "function" && rest.id != null)
123
+ navButtonPresses.set(String(rest.id), onPress);
124
+ return rest;
125
+ });
126
+ } else if (typeof navigationOptions[key] !== "function")
127
+ payload[key] = navigationOptions[key];
128
+ return hostSetOptions ? hostSetOptions(payload) : protocol.send("NAVIGATION_SET_OPTIONS", payload);
129
+ },
130
+ onButton: (callback) => {
131
+ if (typeof callback !== "function")
132
+ throw TypeError("navigation.onButton needs a function");
133
+ navButtonHandlers.add(callback);
134
+ return () => navButtonHandlers.delete(callback);
135
+ }
136
+ });
137
+ const onAppStateChange = (callback) => {
138
+ if (typeof callback !== "function")
139
+ throw TypeError("lifecycle.onStateChange needs a function");
140
+ appStateHandlers.add(callback);
141
+ return () => appStateHandlers.delete(callback);
142
+ };
143
+ craft.lifecycle = { getState: () => appState, onStateChange: onAppStateChange, onChange: onAppStateChange };
144
+ craft.getAppState = craft.lifecycle.getState;
145
+ craft.onAppStateChange = onAppStateChange;
146
+ craft.deepLinks = {
147
+ getInitialURL: () => {
148
+ initialDeepLinkClaimed = !0;
149
+ return request("DeepLinks", "getInitialURL", []);
150
+ },
151
+ onLink: (callback) => {
152
+ if (typeof callback !== "function")
153
+ throw TypeError("deepLinks.onLink needs a function");
154
+ deepLinkHandlers.add(callback);
155
+ return () => deepLinkHandlers.delete(callback);
156
+ }
157
+ };
158
+ protocol.on("APP_STATE", ({ payload }) => {
159
+ if (payload.state === appState)
160
+ return;
161
+ appState = payload.state;
162
+ appStateHandlers.forEach((handler) => handler(appState));
163
+ });
164
+ protocol.on("DEEP_LINK", ({ payload }) => {
165
+ if (initialDeepLinkClaimed && payload.initial)
166
+ return;
167
+ deepLinkHandlers.forEach((handler) => handler(payload));
168
+ });
169
+ const dispatchNavButton = (event) => {
170
+ const id = event?.id == null ? "" : String(event.id);
171
+ navButtonPresses.get(id)?.({ id });
172
+ navButtonHandlers.forEach((handler) => handler({ id }));
173
+ };
174
+ protocol.on("NAV_BUTTON", ({ payload }) => dispatchNavButton(payload));
175
+ protocol.on("EVENT", ({ payload }) => {
176
+ if (payload?.handlerId === "navButton" || payload?.handlerName === "navButton")
177
+ dispatchNavButton(payload.nativeEvent || {});
178
+ });
179
+ if (capabilities.has("fetch") && typeof target.fetch !== "function")
180
+ target.fetch = (input, init = {}) => {
181
+ const source = input && typeof input === "object" ? input : {}, url = typeof input === "string" ? input : String(source.url || input), method = String(init.method || source.method || "GET").toUpperCase(), headers = {}, inputHeaders = init.headers || source.headers, addHeader = (name, value) => {
182
+ headers[String(name).toLowerCase()] = String(value);
183
+ };
184
+ if (Array.isArray(inputHeaders))
185
+ inputHeaders.forEach((pair) => addHeader(pair[0], pair[1]));
186
+ else if (inputHeaders && typeof inputHeaders.forEach === "function")
187
+ inputHeaders.forEach(addHeader);
188
+ else if (inputHeaders && typeof inputHeaders === "object")
189
+ Object.keys(inputHeaders).forEach((name) => addHeader(name, inputHeaders[name]));
190
+ const body = init.body !== void 0 ? init.body : source.body;
191
+ if (body != null && typeof body !== "string")
192
+ return Promise.reject(TypeError("fetch in a native screen sends string bodies only"));
193
+ if (body != null && (method === "GET" || method === "HEAD"))
194
+ return Promise.reject(TypeError("A GET or HEAD request cannot have a body"));
195
+ return request("Network", "fetch", [{ url, method, headers, body: body == null ? null : body }]).then((data) => {
196
+ const responseHeaders = data?.headers && typeof data.headers === "object" ? data.headers : {}, responseBody = data?.body == null ? "" : String(data.body);
197
+ let bodyUsed = !1;
198
+ const consume = () => {
199
+ if (bodyUsed)
200
+ return Promise.reject(TypeError("Body has already been consumed"));
201
+ bodyUsed = !0;
202
+ return Promise.resolve(responseBody);
203
+ };
204
+ return {
205
+ type: "basic",
206
+ url: data?.url || "",
207
+ status: Number(data?.status) || 0,
208
+ statusText: data?.statusText || "",
209
+ ok: Number(data?.status) >= 200 && Number(data?.status) < 300,
210
+ redirected: Boolean(data?.redirected),
211
+ headers: {
212
+ get: (name) => responseHeaders[String(name).toLowerCase()] == null ? null : String(responseHeaders[String(name).toLowerCase()]),
213
+ has: (name) => responseHeaders[String(name).toLowerCase()] != null,
214
+ forEach: (callback) => Object.keys(responseHeaders).forEach((name) => callback(String(responseHeaders[name]), name))
215
+ },
216
+ get bodyUsed() {
217
+ return bodyUsed;
218
+ },
219
+ text: consume,
220
+ json: () => consume().then(JSON.parse)
221
+ };
222
+ }, (error) => {
223
+ if (error?.code === "INVALID_ARGUMENT")
224
+ throw error;
225
+ const failure = TypeError(error?.message || "Network request failed");
226
+ failure.code = error?.code || "NETWORK_ERROR";
227
+ throw failure;
228
+ });
229
+ };
230
+ return craft;
231
+ }
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * The `craft` object a native screen's script sees, typed.
3
3
  *
4
- * The runtime (`screen.ts`) and the Craft host install it on `globalThis`
5
- * before the script runs. A screen written in TypeScript can name it:
4
+ * The shared native screen adapter and the Craft host install it on
5
+ * `globalThis` before the script runs. A screen written in TypeScript can name it:
6
6
  *
7
7
  * ```ts
8
8
  * import type { NativeCraft } from '@stacksjs/stx/native'
@@ -57,6 +57,7 @@ export declare interface NativeSnapshots {
57
57
  }
58
58
  export declare interface NativeCraft {
59
59
  platform: string
60
+ capabilityProtocolVersion: number
60
61
  route: { name: string, params: Record<string, unknown> }
61
62
  capabilities: Record<string, boolean>
62
63
  navigation: NativeNavigation
@@ -69,8 +70,32 @@ export declare interface NativeCraft {
69
70
  notification: (type?: 'success' | 'warning' | 'error') => Promise<void>
70
71
  selection: () => Promise<void>
71
72
  }
73
+ haptic: (style?: string) => Promise<unknown>
72
74
  clipboard: { write: (text: string) => Promise<unknown>, read: () => Promise<string> }
73
75
  device: { getInfo: () => Promise<Record<string, unknown>> }
74
- lifecycle: { getState: () => 'active' | 'inactive' | 'background', onStateChange: (callback: (state: string) => unknown) => () => void }
76
+ biometrics: {
77
+ isAvailable: () => Promise<boolean>
78
+ getBiometricType: () => Promise<string | null>
79
+ authenticate: (reason?: string) => Promise<unknown>
80
+ }
81
+ db: {
82
+ execute: (sql: string, params?: unknown[]) => Promise<unknown>
83
+ query: <T = unknown>(sql: string, params?: unknown[]) => Promise<T[]>
84
+ beginTransaction: () => Promise<unknown>
85
+ commit: () => Promise<unknown>
86
+ rollback: () => Promise<unknown>
87
+ }
88
+ notifications: {
89
+ show: (notification: unknown) => Promise<unknown>
90
+ schedule: (notification: unknown) => Promise<unknown>
91
+ cancel: (id: string) => Promise<unknown>
92
+ cancelAll: () => Promise<unknown>
93
+ pending: () => Promise<unknown[]>
94
+ }
95
+ lifecycle: {
96
+ getState: () => 'active' | 'inactive' | 'background'
97
+ onStateChange: (callback: (state: string) => unknown) => () => void
98
+ onChange: (callback: (state: string) => unknown) => () => void
99
+ }
75
100
  deepLinks: { getInitialURL: () => Promise<string | null>, onLink: (callback: (link: unknown) => unknown) => () => void }
76
101
  }
@@ -0,0 +1,16 @@
1
+ /** Install only the browser-shaped globals the shared runtime needs to boot in JSC. */
2
+ export declare function installJSCGlobals(target?: AnyRecord): void;
3
+ declare type AnyRecord = Record<string, any> // eslint-disable-line ts/no-explicit-any;
4
+ declare class NativeEvent {
5
+ type: string;
6
+ detail: unknown;
7
+ target: unknown;
8
+ key: string;
9
+ ctrlKey: boolean;
10
+ altKey: boolean;
11
+ shiftKey: boolean;
12
+ metaKey: boolean;
13
+ constructor(type: string, options?: { detail?: unknown });
14
+ preventDefault(): void;
15
+ stopPropagation(): void;
16
+ }
@@ -0,0 +1,64 @@
1
+ class NativeEvent {
2
+ type;
3
+ detail;
4
+ target = null;
5
+ key = "";
6
+ ctrlKey = !1;
7
+ altKey = !1;
8
+ shiftKey = !1;
9
+ metaKey = !1;
10
+ constructor(type, options = {}) {
11
+ this.type = type;
12
+ this.detail = options.detail;
13
+ }
14
+ preventDefault() {}
15
+ stopPropagation() {}
16
+ }
17
+ export function installJSCGlobals(target = globalThis) {
18
+ const listeners = new Map, addEventListener = (name, listener) => {
19
+ const group = listeners.get(name) ?? new Set;
20
+ group.add(listener);
21
+ listeners.set(name, group);
22
+ }, removeEventListener = (name, listener) => {
23
+ listeners.get(name)?.delete(listener);
24
+ }, dispatchEvent = (event) => {
25
+ for (const listener of listeners.get(event.type) ?? [])
26
+ listener(event);
27
+ return !0;
28
+ }, emptyList = [], documentElement = { setAttribute() {}, removeAttribute() {}, getAttribute() {
29
+ return null;
30
+ } }, head = { appendChild() {} };
31
+ target.window = target;
32
+ target.Node ??= { ELEMENT_NODE: 1, TEXT_NODE: 3, COMMENT_NODE: 8 };
33
+ target.Event ??= NativeEvent;
34
+ target.CustomEvent ??= NativeEvent;
35
+ target.addEventListener ??= addEventListener;
36
+ target.removeEventListener ??= removeEventListener;
37
+ target.dispatchEvent ??= dispatchEvent;
38
+ target.performance ??= { now: () => Date.now() };
39
+ target.queueMicrotask ??= (callback) => Promise.resolve().then(callback);
40
+ target.requestAnimationFrame ??= (callback) => target.setTimeout(() => callback(Date.now()), 0);
41
+ target.cancelAnimationFrame ??= (id) => target.clearTimeout(id);
42
+ target.location ??= { href: "", pathname: "/", search: "", hash: "" };
43
+ target.history ??= { back() {}, forward() {}, pushState() {}, replaceState() {} };
44
+ target.navigator ??= { language: "en" };
45
+ target.document ??= {
46
+ body: null,
47
+ head,
48
+ hidden: !1,
49
+ documentElement,
50
+ addEventListener,
51
+ removeEventListener,
52
+ dispatchEvent,
53
+ querySelectorAll: () => emptyList,
54
+ querySelector: () => null,
55
+ getElementById: () => null,
56
+ createElement: () => ({
57
+ setAttribute() {},
58
+ removeAttribute() {},
59
+ appendChild() {},
60
+ style: {},
61
+ textContent: ""
62
+ })
63
+ };
64
+ }
@@ -1,4 +1,5 @@
1
1
  import type { NativeMutationOperation } from '../bridge/protocol';
2
+ import type { STXNode } from '../compiler/ir';
2
3
  export declare function createNativeHost(options: NativeHostOptions): NativeHost;
3
4
  /** Every method the DOM host in `signals.ts` defines. The contract, in one place. */
4
5
  export declare const HOST_METHODS: readonly string[];
@@ -17,6 +18,7 @@ export declare interface NativeHost {
17
18
  setText: (node: NativeNode, value: unknown) => void
18
19
  setAttribute: (node: NativeNode, name: string, value: unknown) => void
19
20
  removeAttribute: (node: NativeNode, name: string) => void
21
+ setStyle: (node: NativeNode, value: unknown) => void
20
22
  listen: (node: NativeNode, event: string, handler: (payload?: unknown) => void, options?: unknown) => void
21
23
  scopeOf: (node: NativeNode, from?: boolean) => NativeNode | null
22
24
  setVisible: (node: NativeNode, visible: boolean) => boolean
@@ -26,7 +28,7 @@ export declare interface NativeHost {
26
28
  remove: (node: NativeNode) => void
27
29
  descendants: (node: NativeNode) => NativeNode[]
28
30
  scopesIn: (node: NativeNode) => string[]
29
- adopt: (node: NativeNode, type: string, owner?: NativeNode | null) => NativeNode
31
+ adopt: (node: NativeNode, type: string, owner?: NativeNode | null, descriptor?: Pick<STXNode, 'props' | 'style' | 'events' | 'children'>) => NativeNode
30
32
  flush: () => void
31
33
  dispatch: (handlerId: string, payload?: unknown) => void
32
34
  pending: () => number