@despia-native/kernel 0.0.0-coming-soon.0 → 0.3.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 (661) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +1414 -0
  3. package/README.md +16 -1
  4. package/dist/.dsx-build-stamp.json +7 -0
  5. package/dist/api-cohort.d.ts +27 -0
  6. package/dist/api-cohort.d.ts.map +1 -0
  7. package/dist/api-cohort.js +94 -0
  8. package/dist/api-cohort.js.map +1 -0
  9. package/dist/api.d.ts +454 -0
  10. package/dist/api.d.ts.map +1 -0
  11. package/dist/api.js +2442 -0
  12. package/dist/api.js.map +1 -0
  13. package/dist/app-consts.d.ts +10 -0
  14. package/dist/app-consts.d.ts.map +1 -0
  15. package/dist/app-consts.js +39 -0
  16. package/dist/app-consts.js.map +1 -0
  17. package/dist/app-update.d.ts +12 -0
  18. package/dist/app-update.d.ts.map +1 -0
  19. package/dist/app-update.js +32 -0
  20. package/dist/app-update.js.map +1 -0
  21. package/dist/aria.d.ts +152 -0
  22. package/dist/aria.d.ts.map +1 -0
  23. package/dist/aria.js +524 -0
  24. package/dist/aria.js.map +1 -0
  25. package/dist/audio-core.d.ts +260 -0
  26. package/dist/audio-core.d.ts.map +1 -0
  27. package/dist/audio-core.js +1440 -0
  28. package/dist/audio-core.js.map +1 -0
  29. package/dist/audio-edit.d.ts +100 -0
  30. package/dist/audio-edit.d.ts.map +1 -0
  31. package/dist/audio-edit.js +489 -0
  32. package/dist/audio-edit.js.map +1 -0
  33. package/dist/audio-mix.d.ts +84 -0
  34. package/dist/audio-mix.d.ts.map +1 -0
  35. package/dist/audio-mix.js +393 -0
  36. package/dist/audio-mix.js.map +1 -0
  37. package/dist/auth-proof.d.ts +145 -0
  38. package/dist/auth-proof.d.ts.map +1 -0
  39. package/dist/auth-proof.js +644 -0
  40. package/dist/auth-proof.js.map +1 -0
  41. package/dist/availability-explain.d.ts +3 -0
  42. package/dist/availability-explain.d.ts.map +1 -0
  43. package/dist/availability-explain.js +322 -0
  44. package/dist/availability-explain.js.map +1 -0
  45. package/dist/availability.d.ts +246 -0
  46. package/dist/availability.d.ts.map +1 -0
  47. package/dist/availability.js +615 -0
  48. package/dist/availability.js.map +1 -0
  49. package/dist/background.d.ts +116 -0
  50. package/dist/background.d.ts.map +1 -0
  51. package/dist/background.js +235 -0
  52. package/dist/background.js.map +1 -0
  53. package/dist/boot-tables-flag.d.ts +2 -0
  54. package/dist/boot-tables-flag.d.ts.map +1 -0
  55. package/dist/boot-tables-flag.js +16 -0
  56. package/dist/boot-tables-flag.js.map +1 -0
  57. package/dist/boot-tables.d.ts +40 -0
  58. package/dist/boot-tables.d.ts.map +1 -0
  59. package/dist/boot-tables.js +102 -0
  60. package/dist/boot-tables.js.map +1 -0
  61. package/dist/border-edges.d.ts +5 -0
  62. package/dist/border-edges.d.ts.map +1 -0
  63. package/dist/border-edges.js +47 -0
  64. package/dist/border-edges.js.map +1 -0
  65. package/dist/bus.d.ts +1203 -0
  66. package/dist/bus.d.ts.map +1 -0
  67. package/dist/bus.js +2647 -0
  68. package/dist/bus.js.map +1 -0
  69. package/dist/calendar-core.d.ts +143 -0
  70. package/dist/calendar-core.d.ts.map +1 -0
  71. package/dist/calendar-core.js +372 -0
  72. package/dist/calendar-core.js.map +1 -0
  73. package/dist/call-value.d.ts +16 -0
  74. package/dist/call-value.d.ts.map +1 -0
  75. package/dist/call-value.js +54 -0
  76. package/dist/call-value.js.map +1 -0
  77. package/dist/camera-core.d.ts +222 -0
  78. package/dist/camera-core.d.ts.map +1 -0
  79. package/dist/camera-core.js +980 -0
  80. package/dist/camera-core.js.map +1 -0
  81. package/dist/canvas-core.d.ts +404 -0
  82. package/dist/canvas-core.d.ts.map +1 -0
  83. package/dist/canvas-core.js +2186 -0
  84. package/dist/canvas-core.js.map +1 -0
  85. package/dist/capture-core.d.ts +74 -0
  86. package/dist/capture-core.d.ts.map +1 -0
  87. package/dist/capture-core.js +158 -0
  88. package/dist/capture-core.js.map +1 -0
  89. package/dist/compile/codegen.d.ts +146 -0
  90. package/dist/compile/codegen.d.ts.map +1 -0
  91. package/dist/compile/codegen.js +1949 -0
  92. package/dist/compile/codegen.js.map +1 -0
  93. package/dist/compile/jstier.d.ts +44 -0
  94. package/dist/compile/jstier.d.ts.map +1 -0
  95. package/dist/compile/jstier.js +181 -0
  96. package/dist/compile/jstier.js.map +1 -0
  97. package/dist/compile/tier-door.d.ts +41 -0
  98. package/dist/compile/tier-door.d.ts.map +1 -0
  99. package/dist/compile/tier-door.js +167 -0
  100. package/dist/compile/tier-door.js.map +1 -0
  101. package/dist/compile/tier-realm.d.ts +49 -0
  102. package/dist/compile/tier-realm.d.ts.map +1 -0
  103. package/dist/compile/tier-realm.js +368 -0
  104. package/dist/compile/tier-realm.js.map +1 -0
  105. package/dist/compile/tier.d.ts +23 -0
  106. package/dist/compile/tier.d.ts.map +1 -0
  107. package/dist/compile/tier.js +157 -0
  108. package/dist/compile/tier.js.map +1 -0
  109. package/dist/compose-core.d.ts +86 -0
  110. package/dist/compose-core.d.ts.map +1 -0
  111. package/dist/compose-core.js +112 -0
  112. package/dist/compose-core.js.map +1 -0
  113. package/dist/config-validate.d.ts +31 -0
  114. package/dist/config-validate.d.ts.map +1 -0
  115. package/dist/config-validate.js +147 -0
  116. package/dist/config-validate.js.map +1 -0
  117. package/dist/config-values.d.ts +106 -0
  118. package/dist/config-values.d.ts.map +1 -0
  119. package/dist/config-values.js +340 -0
  120. package/dist/config-values.js.map +1 -0
  121. package/dist/contacts-core.d.ts +127 -0
  122. package/dist/contacts-core.d.ts.map +1 -0
  123. package/dist/contacts-core.js +211 -0
  124. package/dist/contacts-core.js.map +1 -0
  125. package/dist/content-transition.d.ts +58 -0
  126. package/dist/content-transition.d.ts.map +1 -0
  127. package/dist/content-transition.js +94 -0
  128. package/dist/content-transition.js.map +1 -0
  129. package/dist/controls-core.d.ts +227 -0
  130. package/dist/controls-core.d.ts.map +1 -0
  131. package/dist/controls-core.js +652 -0
  132. package/dist/controls-core.js.map +1 -0
  133. package/dist/cookies.d.ts +78 -0
  134. package/dist/cookies.d.ts.map +1 -0
  135. package/dist/cookies.js +265 -0
  136. package/dist/cookies.js.map +1 -0
  137. package/dist/corner-shape-core.d.ts +69 -0
  138. package/dist/corner-shape-core.d.ts.map +1 -0
  139. package/dist/corner-shape-core.js +261 -0
  140. package/dist/corner-shape-core.js.map +1 -0
  141. package/dist/crypto-core.d.ts +57 -0
  142. package/dist/crypto-core.d.ts.map +1 -0
  143. package/dist/crypto-core.js +128 -0
  144. package/dist/crypto-core.js.map +1 -0
  145. package/dist/dataviz.d.ts +436 -0
  146. package/dist/dataviz.d.ts.map +1 -0
  147. package/dist/dataviz.js +956 -0
  148. package/dist/dataviz.js.map +1 -0
  149. package/dist/debug.d.ts +293 -0
  150. package/dist/debug.d.ts.map +1 -0
  151. package/dist/debug.js +767 -0
  152. package/dist/debug.js.map +1 -0
  153. package/dist/device-ownership.d.ts +50 -0
  154. package/dist/device-ownership.d.ts.map +1 -0
  155. package/dist/device-ownership.js +105 -0
  156. package/dist/device-ownership.js.map +1 -0
  157. package/dist/effects.d.ts +86 -0
  158. package/dist/effects.d.ts.map +1 -0
  159. package/dist/effects.js +98 -0
  160. package/dist/effects.js.map +1 -0
  161. package/dist/element.d.ts +108 -0
  162. package/dist/element.d.ts.map +1 -0
  163. package/dist/element.js +63 -0
  164. package/dist/element.js.map +1 -0
  165. package/dist/file-watch.d.ts +16 -0
  166. package/dist/file-watch.d.ts.map +1 -0
  167. package/dist/file-watch.js +49 -0
  168. package/dist/file-watch.js.map +1 -0
  169. package/dist/filepaths.d.ts +72 -0
  170. package/dist/filepaths.d.ts.map +1 -0
  171. package/dist/filepaths.js +271 -0
  172. package/dist/filepaths.js.map +1 -0
  173. package/dist/film.d.ts +264 -0
  174. package/dist/film.d.ts.map +1 -0
  175. package/dist/film.js +313 -0
  176. package/dist/film.js.map +1 -0
  177. package/dist/fonts.d.ts +66 -0
  178. package/dist/fonts.d.ts.map +1 -0
  179. package/dist/fonts.js +135 -0
  180. package/dist/fonts.js.map +1 -0
  181. package/dist/forms.d.ts +191 -0
  182. package/dist/forms.d.ts.map +1 -0
  183. package/dist/forms.js +663 -0
  184. package/dist/forms.js.map +1 -0
  185. package/dist/geo.d.ts +289 -0
  186. package/dist/geo.d.ts.map +1 -0
  187. package/dist/geo.js +460 -0
  188. package/dist/geo.js.map +1 -0
  189. package/dist/handler-announce.d.ts +46 -0
  190. package/dist/handler-announce.d.ts.map +1 -0
  191. package/dist/handler-announce.js +96 -0
  192. package/dist/handler-announce.js.map +1 -0
  193. package/dist/handoff.d.ts +71 -0
  194. package/dist/handoff.d.ts.map +1 -0
  195. package/dist/handoff.js +250 -0
  196. package/dist/handoff.js.map +1 -0
  197. package/dist/identity-durability.d.ts +76 -0
  198. package/dist/identity-durability.d.ts.map +1 -0
  199. package/dist/identity-durability.js +150 -0
  200. package/dist/identity-durability.js.map +1 -0
  201. package/dist/image-core.d.ts +240 -0
  202. package/dist/image-core.d.ts.map +1 -0
  203. package/dist/image-core.js +618 -0
  204. package/dist/image-core.js.map +1 -0
  205. package/dist/image-schemes.d.ts +10 -0
  206. package/dist/image-schemes.d.ts.map +1 -0
  207. package/dist/image-schemes.js +28 -0
  208. package/dist/image-schemes.js.map +1 -0
  209. package/dist/index.d.ts +143 -0
  210. package/dist/index.d.ts.map +1 -0
  211. package/dist/index.js +299 -0
  212. package/dist/index.js.map +1 -0
  213. package/dist/ink-core.d.ts +53 -0
  214. package/dist/ink-core.d.ts.map +1 -0
  215. package/dist/ink-core.js +119 -0
  216. package/dist/ink-core.js.map +1 -0
  217. package/dist/input.d.ts +148 -0
  218. package/dist/input.d.ts.map +1 -0
  219. package/dist/input.js +358 -0
  220. package/dist/input.js.map +1 -0
  221. package/dist/integrity.d.ts +63 -0
  222. package/dist/integrity.d.ts.map +1 -0
  223. package/dist/integrity.js +150 -0
  224. package/dist/integrity.js.map +1 -0
  225. package/dist/intents.d.ts +95 -0
  226. package/dist/intents.d.ts.map +1 -0
  227. package/dist/intents.js +282 -0
  228. package/dist/intents.js.map +1 -0
  229. package/dist/interpolate-core.d.ts +37 -0
  230. package/dist/interpolate-core.d.ts.map +1 -0
  231. package/dist/interpolate-core.js +443 -0
  232. package/dist/interpolate-core.js.map +1 -0
  233. package/dist/jse/color.d.ts +12 -0
  234. package/dist/jse/color.d.ts.map +1 -0
  235. package/dist/jse/color.js +196 -0
  236. package/dist/jse/color.js.map +1 -0
  237. package/dist/jse/core.d.ts +54 -0
  238. package/dist/jse/core.d.ts.map +1 -0
  239. package/dist/jse/core.js +1519 -0
  240. package/dist/jse/core.js.map +1 -0
  241. package/dist/jse/dispatch.d.ts +28 -0
  242. package/dist/jse/dispatch.d.ts.map +1 -0
  243. package/dist/jse/dispatch.js +116 -0
  244. package/dist/jse/dispatch.js.map +1 -0
  245. package/dist/jse/highlight-grammar.d.ts +15 -0
  246. package/dist/jse/highlight-grammar.d.ts.map +1 -0
  247. package/dist/jse/highlight-grammar.js +161 -0
  248. package/dist/jse/highlight-grammar.js.map +1 -0
  249. package/dist/jse/highlight-grammars.generated.d.ts +2 -0
  250. package/dist/jse/highlight-grammars.generated.d.ts.map +1 -0
  251. package/dist/jse/highlight-grammars.generated.js +4 -0
  252. package/dist/jse/highlight-grammars.generated.js.map +1 -0
  253. package/dist/jse/highlight.d.ts +37 -0
  254. package/dist/jse/highlight.d.ts.map +1 -0
  255. package/dist/jse/highlight.js +323 -0
  256. package/dist/jse/highlight.js.map +1 -0
  257. package/dist/jse/jse.d.ts +674 -0
  258. package/dist/jse/jse.d.ts.map +1 -0
  259. package/dist/jse/jse.js +5841 -0
  260. package/dist/jse/jse.js.map +1 -0
  261. package/dist/jse/pathmatch.d.ts +10 -0
  262. package/dist/jse/pathmatch.d.ts.map +1 -0
  263. package/dist/jse/pathmatch.js +73 -0
  264. package/dist/jse/pathmatch.js.map +1 -0
  265. package/dist/jse/regex.d.ts +33 -0
  266. package/dist/jse/regex.d.ts.map +1 -0
  267. package/dist/jse/regex.js +375 -0
  268. package/dist/jse/regex.js.map +1 -0
  269. package/dist/jse/stdlib.d.ts +8 -0
  270. package/dist/jse/stdlib.d.ts.map +1 -0
  271. package/dist/jse/stdlib.js +765 -0
  272. package/dist/jse/stdlib.js.map +1 -0
  273. package/dist/jse/tokens.d.ts +102 -0
  274. package/dist/jse/tokens.d.ts.map +1 -0
  275. package/dist/jse/tokens.js +982 -0
  276. package/dist/jse/tokens.js.map +1 -0
  277. package/dist/jse/values.d.ts +206 -0
  278. package/dist/jse/values.d.ts.map +1 -0
  279. package/dist/jse/values.js +846 -0
  280. package/dist/jse/values.js.map +1 -0
  281. package/dist/keyboard.d.ts +196 -0
  282. package/dist/keyboard.d.ts.map +1 -0
  283. package/dist/keyboard.js +186 -0
  284. package/dist/keyboard.js.map +1 -0
  285. package/dist/label-choices.d.ts +3 -0
  286. package/dist/label-choices.d.ts.map +1 -0
  287. package/dist/label-choices.js +168 -0
  288. package/dist/label-choices.js.map +1 -0
  289. package/dist/language.d.ts +33 -0
  290. package/dist/language.d.ts.map +1 -0
  291. package/dist/language.js +50 -0
  292. package/dist/language.js.map +1 -0
  293. package/dist/length-units.d.ts +30 -0
  294. package/dist/length-units.d.ts.map +1 -0
  295. package/dist/length-units.js +83 -0
  296. package/dist/length-units.js.map +1 -0
  297. package/dist/lightsensor.d.ts +48 -0
  298. package/dist/lightsensor.d.ts.map +1 -0
  299. package/dist/lightsensor.js +97 -0
  300. package/dist/lightsensor.js.map +1 -0
  301. package/dist/link-refresh.d.ts +27 -0
  302. package/dist/link-refresh.d.ts.map +1 -0
  303. package/dist/link-refresh.js +166 -0
  304. package/dist/link-refresh.js.map +1 -0
  305. package/dist/link.d.ts +57 -0
  306. package/dist/link.d.ts.map +1 -0
  307. package/dist/link.js +333 -0
  308. package/dist/link.js.map +1 -0
  309. package/dist/linkpreview.d.ts +114 -0
  310. package/dist/linkpreview.d.ts.map +1 -0
  311. package/dist/linkpreview.js +439 -0
  312. package/dist/linkpreview.js.map +1 -0
  313. package/dist/list-presence.d.ts +32 -0
  314. package/dist/list-presence.d.ts.map +1 -0
  315. package/dist/list-presence.js +48 -0
  316. package/dist/list-presence.js.map +1 -0
  317. package/dist/live-stream.d.ts +27 -0
  318. package/dist/live-stream.d.ts.map +1 -0
  319. package/dist/live-stream.js +274 -0
  320. package/dist/live-stream.js.map +1 -0
  321. package/dist/livelogs.d.ts +134 -0
  322. package/dist/livelogs.d.ts.map +1 -0
  323. package/dist/livelogs.js +409 -0
  324. package/dist/livelogs.js.map +1 -0
  325. package/dist/logs.d.ts +80 -0
  326. package/dist/logs.d.ts.map +1 -0
  327. package/dist/logs.js +206 -0
  328. package/dist/logs.js.map +1 -0
  329. package/dist/mcp/apps.d.ts +82 -0
  330. package/dist/mcp/apps.d.ts.map +1 -0
  331. package/dist/mcp/apps.js +219 -0
  332. package/dist/mcp/apps.js.map +1 -0
  333. package/dist/mcp/entities.d.ts +25 -0
  334. package/dist/mcp/entities.d.ts.map +1 -0
  335. package/dist/mcp/entities.js +71 -0
  336. package/dist/mcp/entities.js.map +1 -0
  337. package/dist/mcp/result.d.ts +73 -0
  338. package/dist/mcp/result.d.ts.map +1 -0
  339. package/dist/mcp/result.js +119 -0
  340. package/dist/mcp/result.js.map +1 -0
  341. package/dist/mcp/webmcp.d.ts +162 -0
  342. package/dist/mcp/webmcp.d.ts.map +1 -0
  343. package/dist/mcp/webmcp.js +214 -0
  344. package/dist/mcp/webmcp.js.map +1 -0
  345. package/dist/mcp.d.ts +5 -0
  346. package/dist/mcp.d.ts.map +1 -0
  347. package/dist/mcp.js +14 -0
  348. package/dist/mcp.js.map +1 -0
  349. package/dist/media-core.d.ts +191 -0
  350. package/dist/media-core.d.ts.map +1 -0
  351. package/dist/media-core.js +446 -0
  352. package/dist/media-core.js.map +1 -0
  353. package/dist/media-timeline-core.d.ts +94 -0
  354. package/dist/media-timeline-core.d.ts.map +1 -0
  355. package/dist/media-timeline-core.js +620 -0
  356. package/dist/media-timeline-core.js.map +1 -0
  357. package/dist/message.d.ts +42 -0
  358. package/dist/message.d.ts.map +1 -0
  359. package/dist/message.js +582 -0
  360. package/dist/message.js.map +1 -0
  361. package/dist/missing-element.d.ts +29 -0
  362. package/dist/missing-element.d.ts.map +1 -0
  363. package/dist/missing-element.js +76 -0
  364. package/dist/missing-element.js.map +1 -0
  365. package/dist/motion-core.d.ts +160 -0
  366. package/dist/motion-core.d.ts.map +1 -0
  367. package/dist/motion-core.js +752 -0
  368. package/dist/motion-core.js.map +1 -0
  369. package/dist/motion-pose.d.ts +65 -0
  370. package/dist/motion-pose.d.ts.map +1 -0
  371. package/dist/motion-pose.js +143 -0
  372. package/dist/motion-pose.js.map +1 -0
  373. package/dist/motion.d.ts +132 -0
  374. package/dist/motion.d.ts.map +1 -0
  375. package/dist/motion.js +260 -0
  376. package/dist/motion.js.map +1 -0
  377. package/dist/mount-core.d.ts +203 -0
  378. package/dist/mount-core.d.ts.map +1 -0
  379. package/dist/mount-core.js +437 -0
  380. package/dist/mount-core.js.map +1 -0
  381. package/dist/net-core.d.ts +110 -0
  382. package/dist/net-core.d.ts.map +1 -0
  383. package/dist/net-core.js +225 -0
  384. package/dist/net-core.js.map +1 -0
  385. package/dist/notify.d.ts +399 -0
  386. package/dist/notify.d.ts.map +1 -0
  387. package/dist/notify.js +964 -0
  388. package/dist/notify.js.map +1 -0
  389. package/dist/orientation-binding.d.ts +39 -0
  390. package/dist/orientation-binding.d.ts.map +1 -0
  391. package/dist/orientation-binding.js +64 -0
  392. package/dist/orientation-binding.js.map +1 -0
  393. package/dist/orientation.d.ts +55 -0
  394. package/dist/orientation.d.ts.map +1 -0
  395. package/dist/orientation.js +89 -0
  396. package/dist/orientation.js.map +1 -0
  397. package/dist/ota.d.ts +52 -0
  398. package/dist/ota.d.ts.map +1 -0
  399. package/dist/ota.js +122 -0
  400. package/dist/ota.js.map +1 -0
  401. package/dist/passkeys.d.ts +91 -0
  402. package/dist/passkeys.d.ts.map +1 -0
  403. package/dist/passkeys.js +307 -0
  404. package/dist/passkeys.js.map +1 -0
  405. package/dist/payment.d.ts +85 -0
  406. package/dist/payment.d.ts.map +1 -0
  407. package/dist/payment.js +270 -0
  408. package/dist/payment.js.map +1 -0
  409. package/dist/pending-presenter.d.ts +31 -0
  410. package/dist/pending-presenter.d.ts.map +1 -0
  411. package/dist/pending-presenter.js +119 -0
  412. package/dist/pending-presenter.js.map +1 -0
  413. package/dist/permission-core.d.ts +59 -0
  414. package/dist/permission-core.d.ts.map +1 -0
  415. package/dist/permission-core.js +102 -0
  416. package/dist/permission-core.js.map +1 -0
  417. package/dist/persist.d.ts +169 -0
  418. package/dist/persist.d.ts.map +1 -0
  419. package/dist/persist.js +361 -0
  420. package/dist/persist.js.map +1 -0
  421. package/dist/phase-plan.d.ts +114 -0
  422. package/dist/phase-plan.d.ts.map +1 -0
  423. package/dist/phase-plan.js +837 -0
  424. package/dist/phase-plan.js.map +1 -0
  425. package/dist/playback-core.d.ts +64 -0
  426. package/dist/playback-core.d.ts.map +1 -0
  427. package/dist/playback-core.js +176 -0
  428. package/dist/playback-core.js.map +1 -0
  429. package/dist/player-sources.d.ts +12 -0
  430. package/dist/player-sources.d.ts.map +1 -0
  431. package/dist/player-sources.js +44 -0
  432. package/dist/player-sources.js.map +1 -0
  433. package/dist/proxy-denylist.d.ts +11 -0
  434. package/dist/proxy-denylist.d.ts.map +1 -0
  435. package/dist/proxy-denylist.js +44 -0
  436. package/dist/proxy-denylist.js.map +1 -0
  437. package/dist/public-config.d.ts +20 -0
  438. package/dist/public-config.d.ts.map +1 -0
  439. package/dist/public-config.js +109 -0
  440. package/dist/public-config.js.map +1 -0
  441. package/dist/qoe-core.d.ts +72 -0
  442. package/dist/qoe-core.d.ts.map +1 -0
  443. package/dist/qoe-core.js +113 -0
  444. package/dist/qoe-core.js.map +1 -0
  445. package/dist/reactive-request.d.ts +80 -0
  446. package/dist/reactive-request.d.ts.map +1 -0
  447. package/dist/reactive-request.js +192 -0
  448. package/dist/reactive-request.js.map +1 -0
  449. package/dist/read-cache.d.ts +129 -0
  450. package/dist/read-cache.d.ts.map +1 -0
  451. package/dist/read-cache.js +566 -0
  452. package/dist/read-cache.js.map +1 -0
  453. package/dist/recorder-core.d.ts +57 -0
  454. package/dist/recorder-core.d.ts.map +1 -0
  455. package/dist/recorder-core.js +136 -0
  456. package/dist/recorder-core.js.map +1 -0
  457. package/dist/ref.d.ts +41 -0
  458. package/dist/ref.d.ts.map +1 -0
  459. package/dist/ref.js +98 -0
  460. package/dist/ref.js.map +1 -0
  461. package/dist/refusal.d.ts +82 -0
  462. package/dist/refusal.d.ts.map +1 -0
  463. package/dist/refusal.js +218 -0
  464. package/dist/refusal.js.map +1 -0
  465. package/dist/region-insets.d.ts +61 -0
  466. package/dist/region-insets.d.ts.map +1 -0
  467. package/dist/region-insets.js +67 -0
  468. package/dist/region-insets.js.map +1 -0
  469. package/dist/rive-core.d.ts +323 -0
  470. package/dist/rive-core.d.ts.map +1 -0
  471. package/dist/rive-core.js +677 -0
  472. package/dist/rive-core.js.map +1 -0
  473. package/dist/runner.d.ts +595 -0
  474. package/dist/runner.d.ts.map +1 -0
  475. package/dist/runner.js +4094 -0
  476. package/dist/runner.js.map +1 -0
  477. package/dist/scene/a11y.d.ts +11 -0
  478. package/dist/scene/a11y.d.ts.map +1 -0
  479. package/dist/scene/a11y.js +67 -0
  480. package/dist/scene/a11y.js.map +1 -0
  481. package/dist/scene/anim.d.ts +149 -0
  482. package/dist/scene/anim.d.ts.map +1 -0
  483. package/dist/scene/anim.js +396 -0
  484. package/dist/scene/anim.js.map +1 -0
  485. package/dist/scene/bind.d.ts +33 -0
  486. package/dist/scene/bind.d.ts.map +1 -0
  487. package/dist/scene/bind.js +66 -0
  488. package/dist/scene/bind.js.map +1 -0
  489. package/dist/scene/collide.d.ts +56 -0
  490. package/dist/scene/collide.d.ts.map +1 -0
  491. package/dist/scene/collide.js +146 -0
  492. package/dist/scene/collide.js.map +1 -0
  493. package/dist/scene/frame.d.ts +22 -0
  494. package/dist/scene/frame.d.ts.map +1 -0
  495. package/dist/scene/frame.js +57 -0
  496. package/dist/scene/frame.js.map +1 -0
  497. package/dist/scene/gltf.d.ts +79 -0
  498. package/dist/scene/gltf.d.ts.map +1 -0
  499. package/dist/scene/gltf.js +409 -0
  500. package/dist/scene/gltf.js.map +1 -0
  501. package/dist/scene/ir.d.ts +293 -0
  502. package/dist/scene/ir.d.ts.map +1 -0
  503. package/dist/scene/ir.js +692 -0
  504. package/dist/scene/ir.js.map +1 -0
  505. package/dist/scene/math.d.ts +50 -0
  506. package/dist/scene/math.d.ts.map +1 -0
  507. package/dist/scene/math.js +180 -0
  508. package/dist/scene/math.js.map +1 -0
  509. package/dist/scene/orbit.d.ts +19 -0
  510. package/dist/scene/orbit.d.ts.map +1 -0
  511. package/dist/scene/orbit.js +60 -0
  512. package/dist/scene/orbit.js.map +1 -0
  513. package/dist/scene/physics.d.ts +228 -0
  514. package/dist/scene/physics.d.ts.map +1 -0
  515. package/dist/scene/physics.js +1500 -0
  516. package/dist/scene/physics.js.map +1 -0
  517. package/dist/scene/registry.d.ts +85 -0
  518. package/dist/scene/registry.d.ts.map +1 -0
  519. package/dist/scene/registry.js +75 -0
  520. package/dist/scene/registry.js.map +1 -0
  521. package/dist/scene/skin.d.ts +82 -0
  522. package/dist/scene/skin.d.ts.map +1 -0
  523. package/dist/scene/skin.js +351 -0
  524. package/dist/scene/skin.js.map +1 -0
  525. package/dist/scene/sprite.d.ts +36 -0
  526. package/dist/scene/sprite.d.ts.map +1 -0
  527. package/dist/scene/sprite.js +107 -0
  528. package/dist/scene/sprite.js.map +1 -0
  529. package/dist/scene/viewer.d.ts +96 -0
  530. package/dist/scene/viewer.d.ts.map +1 -0
  531. package/dist/scene/viewer.js +235 -0
  532. package/dist/scene/viewer.js.map +1 -0
  533. package/dist/scoped-slots.d.ts +9 -0
  534. package/dist/scoped-slots.d.ts.map +1 -0
  535. package/dist/scoped-slots.js +42 -0
  536. package/dist/scoped-slots.js.map +1 -0
  537. package/dist/screen.d.ts +109 -0
  538. package/dist/screen.d.ts.map +1 -0
  539. package/dist/screen.js +309 -0
  540. package/dist/screen.js.map +1 -0
  541. package/dist/scroll.d.ts +525 -0
  542. package/dist/scroll.d.ts.map +1 -0
  543. package/dist/scroll.js +1226 -0
  544. package/dist/scroll.js.map +1 -0
  545. package/dist/settings-plane.d.ts +58 -0
  546. package/dist/settings-plane.d.ts.map +1 -0
  547. package/dist/settings-plane.js +86 -0
  548. package/dist/settings-plane.js.map +1 -0
  549. package/dist/share-inbox.d.ts +56 -0
  550. package/dist/share-inbox.d.ts.map +1 -0
  551. package/dist/share-inbox.js +114 -0
  552. package/dist/share-inbox.js.map +1 -0
  553. package/dist/shared-transition.d.ts +152 -0
  554. package/dist/shared-transition.d.ts.map +1 -0
  555. package/dist/shared-transition.js +257 -0
  556. package/dist/shared-transition.js.map +1 -0
  557. package/dist/sheet-content-padding.d.ts +24 -0
  558. package/dist/sheet-content-padding.d.ts.map +1 -0
  559. package/dist/sheet-content-padding.js +32 -0
  560. package/dist/sheet-content-padding.js.map +1 -0
  561. package/dist/shot-devices.d.ts +36 -0
  562. package/dist/shot-devices.d.ts.map +1 -0
  563. package/dist/shot-devices.js +90 -0
  564. package/dist/shot-devices.js.map +1 -0
  565. package/dist/shot-guards.d.ts +100 -0
  566. package/dist/shot-guards.d.ts.map +1 -0
  567. package/dist/shot-guards.js +260 -0
  568. package/dist/shot-guards.js.map +1 -0
  569. package/dist/shot-scope.d.ts +140 -0
  570. package/dist/shot-scope.d.ts.map +1 -0
  571. package/dist/shot-scope.js +302 -0
  572. package/dist/shot-scope.js.map +1 -0
  573. package/dist/slot-partition.d.ts +9 -0
  574. package/dist/slot-partition.d.ts.map +1 -0
  575. package/dist/slot-partition.js +38 -0
  576. package/dist/slot-partition.js.map +1 -0
  577. package/dist/snackbar.d.ts +165 -0
  578. package/dist/snackbar.d.ts.map +1 -0
  579. package/dist/snackbar.js +220 -0
  580. package/dist/snackbar.js.map +1 -0
  581. package/dist/socket.d.ts +96 -0
  582. package/dist/socket.d.ts.map +1 -0
  583. package/dist/socket.js +370 -0
  584. package/dist/socket.js.map +1 -0
  585. package/dist/spotlight.d.ts +77 -0
  586. package/dist/spotlight.d.ts.map +1 -0
  587. package/dist/spotlight.js +174 -0
  588. package/dist/spotlight.js.map +1 -0
  589. package/dist/state-primitive.d.ts +37 -0
  590. package/dist/state-primitive.d.ts.map +1 -0
  591. package/dist/state-primitive.js +91 -0
  592. package/dist/state-primitive.js.map +1 -0
  593. package/dist/store-query.d.ts +25 -0
  594. package/dist/store-query.d.ts.map +1 -0
  595. package/dist/store-query.js +88 -0
  596. package/dist/store-query.js.map +1 -0
  597. package/dist/store-value.d.ts +48 -0
  598. package/dist/store-value.d.ts.map +1 -0
  599. package/dist/store-value.js +264 -0
  600. package/dist/store-value.js.map +1 -0
  601. package/dist/store-versioning.d.ts +70 -0
  602. package/dist/store-versioning.d.ts.map +1 -0
  603. package/dist/store-versioning.js +188 -0
  604. package/dist/store-versioning.js.map +1 -0
  605. package/dist/store.d.ts +282 -0
  606. package/dist/store.d.ts.map +1 -0
  607. package/dist/store.js +1144 -0
  608. package/dist/store.js.map +1 -0
  609. package/dist/strings.d.ts +141 -0
  610. package/dist/strings.d.ts.map +1 -0
  611. package/dist/strings.js +581 -0
  612. package/dist/strings.js.map +1 -0
  613. package/dist/telemetry.d.ts +95 -0
  614. package/dist/telemetry.d.ts.map +1 -0
  615. package/dist/telemetry.js +255 -0
  616. package/dist/telemetry.js.map +1 -0
  617. package/dist/transform-core.d.ts +228 -0
  618. package/dist/transform-core.d.ts.map +1 -0
  619. package/dist/transform-core.js +921 -0
  620. package/dist/transform-core.js.map +1 -0
  621. package/dist/transition-core.d.ts +58 -0
  622. package/dist/transition-core.d.ts.map +1 -0
  623. package/dist/transition-core.js +352 -0
  624. package/dist/transition-core.js.map +1 -0
  625. package/dist/trim-trailing.d.ts +3 -0
  626. package/dist/trim-trailing.d.ts.map +1 -0
  627. package/dist/trim-trailing.js +14 -0
  628. package/dist/trim-trailing.js.map +1 -0
  629. package/dist/upload.d.ts +51 -0
  630. package/dist/upload.d.ts.map +1 -0
  631. package/dist/upload.js +68 -0
  632. package/dist/upload.js.map +1 -0
  633. package/dist/vendor-face.d.ts +44 -0
  634. package/dist/vendor-face.d.ts.map +1 -0
  635. package/dist/vendor-face.js +80 -0
  636. package/dist/vendor-face.js.map +1 -0
  637. package/dist/vendor-session.d.ts +166 -0
  638. package/dist/vendor-session.d.ts.map +1 -0
  639. package/dist/vendor-session.js +423 -0
  640. package/dist/vendor-session.js.map +1 -0
  641. package/dist/vendor-surface.d.ts +290 -0
  642. package/dist/vendor-surface.d.ts.map +1 -0
  643. package/dist/vendor-surface.js +439 -0
  644. package/dist/vendor-surface.js.map +1 -0
  645. package/dist/version-rules.generated.d.ts +17 -0
  646. package/dist/version-rules.generated.d.ts.map +1 -0
  647. package/dist/version-rules.generated.js +99 -0
  648. package/dist/version-rules.generated.js.map +1 -0
  649. package/dist/view-transition-core.d.ts +99 -0
  650. package/dist/view-transition-core.d.ts.map +1 -0
  651. package/dist/view-transition-core.js +127 -0
  652. package/dist/view-transition-core.js.map +1 -0
  653. package/dist/view-transition-door.d.ts +26 -0
  654. package/dist/view-transition-door.d.ts.map +1 -0
  655. package/dist/view-transition-door.js +88 -0
  656. package/dist/view-transition-door.js.map +1 -0
  657. package/dist/window-identity.d.ts +3 -0
  658. package/dist/window-identity.d.ts.map +1 -0
  659. package/dist/window-identity.js +27 -0
  660. package/dist/window-identity.js.map +1 -0
  661. package/package.json +141 -2
@@ -0,0 +1,1519 @@
1
+ //
2
+ // core.ts - JSECore + JSECrypto: the JS core globals (URL / Date / Intl / JSON / Math /
3
+ // Map / Set / parseInt / …) and the Web Crypto companions. TS twin of the Globals layer
4
+ // (Stack.swift on iOS, Globals.kt on Android) — same dispatch shape, same dict-shaped
5
+ // values ({__date: ms}, {__url,…}, {__params}, {__regex}…), so string coercion and
6
+ // structural equality carry across runtimes.
7
+ //
8
+ // On the web many of these are backed by the REAL platform objects (URL, Intl, crypto)
9
+ // — the values still travel as the portable dict shapes. crypto.subtle is async-only in
10
+ // browsers: it returns a real Promise the ACTION runner awaits (statement-await, per
11
+ // the runner contract); on the native twins it computes synchronously under the hood.
12
+ //
13
+ import { NSNull, isDict, isLambda, number, numberJS, string, truthy, jseEquals, jseStrictEquals, safeInt, setStringCoerce, activeLocaleTag, graphemes, matchArray, } from "./values.js";
14
+ import { DSXLogs, JSERedact } from "../logs.js";
15
+ // ── small helpers ────────────────────────────────────────────────────────────────────
16
+ /** The HOUSE log formatter — one value → one console token, shared by the `console.*`
17
+ * builtin, the `dsx.log` statement, and the module-handle `dsx.log` (logs corpus): a
18
+ * dict/array serializes as canonical minified JSON with credential-looking keys masked
19
+ * (the Stack.swift / Globals.kt console contract, which the old web console.* path
20
+ * lacked); anything else takes the JSE string coercion. */
21
+ export function formatLogValue(x) {
22
+ if (isDict(x) || Array.isArray(x)) {
23
+ return jsonStringify(JSERedact.mask(x), null) ?? string(x);
24
+ }
25
+ return string(x);
26
+ }
27
+ /** console.log-shaped variadic formatting: each argument through formatLogValue, joined
28
+ * by single spaces. */
29
+ export function formatLogArgs(a) {
30
+ return a.map((x) => formatLogValue(x)).join(" ");
31
+ }
32
+ function pad2(n) { return String(n).padStart(2, "0"); }
33
+ function pad3(n) { return String(n).padStart(3, "0"); }
34
+ /** THE DATE RANGE (JavaScript's TimeClip; logic parity, JSE-VS-JS item 12, corpus
35
+ * jse/date-range-001.json): a time value past 8.64e15 ms either side of the epoch is an
36
+ * invalid date, so every door that mints or moves one (the constructor, the setters) clips. */
37
+ function timeClip(ms) { return Math.abs(ms) <= 8.64e15 ? ms : NaN; }
38
+ function dateShape(ms) { return { __date: timeClip(ms) }; }
39
+ function isDateShape(d) { return typeof d["__date"] === "number"; }
40
+ /** Kotlin/Swift: NaN date → getTime NaN, other getters clamp to epoch. */
41
+ function dateOf(d) {
42
+ const ms = d["__date"];
43
+ return new Date(Number.isNaN(ms) ? 0 : ms);
44
+ }
45
+ /** Local-time Date setter arithmetic — replace the named components, return new ms. */
46
+ function dateSet(ms, m, a) {
47
+ const nn = (i) => (i < a.length ? number(a[i]) : null);
48
+ if (m === "setTime")
49
+ return timeClip(nn(0) ?? 0);
50
+ const dt = new Date(ms);
51
+ switch (m) {
52
+ case "setFullYear":
53
+ dt.setFullYear(nn(0) ?? dt.getFullYear(), nn(1) ?? dt.getMonth(), nn(2) ?? dt.getDate());
54
+ break;
55
+ case "setMonth":
56
+ dt.setMonth(nn(0) ?? dt.getMonth(), nn(1) ?? dt.getDate());
57
+ break;
58
+ case "setDate":
59
+ dt.setDate(nn(0) ?? dt.getDate());
60
+ break;
61
+ case "setHours":
62
+ dt.setHours(nn(0) ?? dt.getHours(), nn(1) ?? dt.getMinutes(), nn(2) ?? dt.getSeconds(), nn(3) ?? dt.getMilliseconds());
63
+ break;
64
+ case "setMinutes":
65
+ dt.setMinutes(nn(0) ?? dt.getMinutes(), nn(1) ?? dt.getSeconds(), nn(2) ?? dt.getMilliseconds());
66
+ break;
67
+ case "setSeconds":
68
+ dt.setSeconds(nn(0) ?? dt.getSeconds(), nn(1) ?? dt.getMilliseconds());
69
+ break;
70
+ case "setMilliseconds":
71
+ dt.setMilliseconds(nn(0) ?? dt.getMilliseconds());
72
+ break;
73
+ // THE UTC SETTERS (logic parity sweep 5, corpus jse/date-utc-setters-001.json): the same
74
+ // replacement over the UTC fields. Twins: Globals.kt / JSELibrary.swift `dateSetMS`.
75
+ case "setUTCFullYear":
76
+ dt.setUTCFullYear(nn(0) ?? dt.getUTCFullYear(), nn(1) ?? dt.getUTCMonth(), nn(2) ?? dt.getUTCDate());
77
+ break;
78
+ case "setUTCMonth":
79
+ dt.setUTCMonth(nn(0) ?? dt.getUTCMonth(), nn(1) ?? dt.getUTCDate());
80
+ break;
81
+ case "setUTCDate":
82
+ dt.setUTCDate(nn(0) ?? dt.getUTCDate());
83
+ break;
84
+ case "setUTCHours":
85
+ dt.setUTCHours(nn(0) ?? dt.getUTCHours(), nn(1) ?? dt.getUTCMinutes(), nn(2) ?? dt.getUTCSeconds(), nn(3) ?? dt.getUTCMilliseconds());
86
+ break;
87
+ case "setUTCMinutes":
88
+ dt.setUTCMinutes(nn(0) ?? dt.getUTCMinutes(), nn(1) ?? dt.getUTCSeconds(), nn(2) ?? dt.getUTCMilliseconds());
89
+ break;
90
+ case "setUTCSeconds":
91
+ dt.setUTCSeconds(nn(0) ?? dt.getUTCSeconds(), nn(1) ?? dt.getUTCMilliseconds());
92
+ break;
93
+ case "setUTCMilliseconds":
94
+ dt.setUTCMilliseconds(nn(0) ?? dt.getUTCMilliseconds());
95
+ break;
96
+ }
97
+ return timeClip(dt.getTime());
98
+ }
99
+ /** THE ONE DATE PARSER (Appendix E item 11). Three runners parsed a date string three
100
+ * ways: this runner handed the text to V8's `Date.parse`, which accepts month names,
101
+ * weekday forms and a long tail of implementation defined shapes; iOS ran an
102
+ * ISO8601DateFormatter ladder and then three DateFormatter patterns; Android ran a
103
+ * java.time list. The two natives did NOT agree either: `2026/09/19` came back as UTC
104
+ * midnight on iOS and local midnight on Android, measured by the record lane.
105
+ *
106
+ * So the law is ISO 8601 and nothing else, on every lane:
107
+ * `yyyy-MM-ddTHH:mm[:ss[.fff]]` followed by `Z` or `+HH:MM` / `-HH:MM`, and
108
+ * `yyyy-MM-dd`, which is UTC midnight (the JS rule for a date only form).
109
+ * Everything else is NaN, INCLUDING a date-time with no zone. A zone-less form has no
110
+ * single reading: it means the host's timezone, so the same markup answers a different
111
+ * instant on a phone in Dubai and a server in UTC, which is exactly the class of defect
112
+ * this item is about. A body that has local text converts it with the components form,
113
+ * where the locality is written down.
114
+ *
115
+ * `toISOString` emits a form this accepts, so the round trip is exact and pinned. */
116
+ function parseDateMS(text) {
117
+ const s = text.trim();
118
+ if (s.length === 0)
119
+ return NaN;
120
+ const iso = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,9}))?)?(Z|[+-]\d{2}:?\d{2})$/.exec(s);
121
+ if (iso !== null) {
122
+ // THE MILLISECONDS ARE THE FIRST THREE DIGITS, read as an integer: `0.123 * 1000` is
123
+ // 122.99999999999999 in a double, which is how iOS read `.123` as 122 (logic parity B13).
124
+ const frac = iso[7] === undefined ? 0 : Number(iso[7].substring(0, 3).padEnd(3, "0"));
125
+ if (!validDateParts(Number(iso[1]), Number(iso[2]), Number(iso[3]), Number(iso[4]), Number(iso[5]), iso[6] === undefined ? 0 : Number(iso[6])))
126
+ return NaN;
127
+ const zone = iso[8];
128
+ let offsetMin = 0;
129
+ if (zone !== "Z") {
130
+ const sign = zone.startsWith("-") ? -1 : 1;
131
+ const digits = zone.substring(1).replace(":", "");
132
+ offsetMin = sign * (Number(digits.substring(0, 2)) * 60 + Number(digits.substring(2)));
133
+ }
134
+ const ms = Date.UTC(Number(iso[1]), Number(iso[2]) - 1, Number(iso[3]), Number(iso[4]), Number(iso[5]), iso[6] === undefined ? 0 : Number(iso[6]), frac);
135
+ return ms - offsetMin * 60_000;
136
+ }
137
+ const dateOnly = /^(\d{4})-(\d{2})-(\d{2})$/.exec(s);
138
+ if (dateOnly !== null) {
139
+ if (!validDateParts(Number(dateOnly[1]), Number(dateOnly[2]), Number(dateOnly[3]), 0, 0, 0))
140
+ return NaN;
141
+ return Date.UTC(Number(dateOnly[1]), Number(dateOnly[2]) - 1, Number(dateOnly[3]));
142
+ }
143
+ return NaN;
144
+ }
145
+ /** A field out of its calendar range is an invalid date, as JavaScript's own ISO reader says
146
+ * (`new Date('2024-13-01')` is Invalid Date): `Date.UTC` would roll month 13 into the next
147
+ * year, which is the answer this runner gave while both natives answered NaN (logic parity B12). */
148
+ function validDateParts(y, mo, d, h, mi, sec) {
149
+ if (mo < 1 || mo > 12 || d < 1 || h > 23 || mi > 59 || sec > 59)
150
+ return false;
151
+ const leap = (y % 4 === 0 && y % 100 !== 0) || y % 400 === 0;
152
+ const days = [31, leap ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][mo - 1];
153
+ return d <= days;
154
+ }
155
+ /** A year outside 0000-9999 is the ISO extended form, a sign and six digits (`+275760`,
156
+ * `-000001`), as `toISOString` writes it (corpus jse/date-range-001.json). */
157
+ function isoYear(y) {
158
+ if (y >= 0 && y <= 9999)
159
+ return y.toString().padStart(4, "0");
160
+ return (y < 0 ? "-" : "+") + Math.abs(y).toString().padStart(6, "0");
161
+ }
162
+ function toISO(ms) {
163
+ if (Number.isNaN(ms))
164
+ return "";
165
+ const d = new Date(ms);
166
+ return (isoYear(d.getUTCFullYear()) + "-" + pad2(d.getUTCMonth() + 1) + "-" + pad2(d.getUTCDate()) +
167
+ "T" + pad2(d.getUTCHours()) + ":" + pad2(d.getUTCMinutes()) + ":" + pad2(d.getUTCSeconds()) +
168
+ "." + pad3(d.getUTCMilliseconds()) + "Z");
169
+ }
170
+ function formEncode(s) {
171
+ return encodeURIComponent(s).replace(/%20/g, "+");
172
+ }
173
+ function paramsToString(pairs) {
174
+ return pairs.map(([k, v]) => `${formEncode(k)}=${formEncode(v)}`).join("&");
175
+ }
176
+ function parseQuery(q) {
177
+ const out = [];
178
+ for (const part of q.replace(/^\?/, "").split("&")) {
179
+ if (part.length === 0)
180
+ continue;
181
+ const eq = part.indexOf("=");
182
+ const k = eq >= 0 ? part.substring(0, eq) : part;
183
+ const v = eq >= 0 ? part.substring(eq + 1) : "";
184
+ const dec = (x) => {
185
+ try {
186
+ return decodeURIComponent(x.replace(/\+/g, " "));
187
+ }
188
+ catch {
189
+ return x;
190
+ }
191
+ };
192
+ out.push([dec(k), dec(v)]);
193
+ }
194
+ return out;
195
+ }
196
+ function paramsShape(pairs) {
197
+ return { __params: pairs.map(([k, v]) => [k, v]) };
198
+ }
199
+ function paramsPairs(d) {
200
+ const raw = d["__params"];
201
+ if (!Array.isArray(raw))
202
+ return [];
203
+ return raw.map((p) => [string(p[0]), string(p[1])]);
204
+ }
205
+ function makeURL(href, base) {
206
+ // whitespace / control characters → null (the hand-rolled RFC 3986 twin rejects them)
207
+ if (/[\s\x00-\x1f]/.test(href))
208
+ return null;
209
+ let u;
210
+ try {
211
+ u = base !== undefined ? new URL(href, base) : new URL(href);
212
+ }
213
+ catch {
214
+ return null;
215
+ }
216
+ return {
217
+ __url: true,
218
+ href: u.href,
219
+ protocol: u.protocol,
220
+ hostname: u.hostname,
221
+ port: u.port,
222
+ host: u.host,
223
+ origin: u.origin,
224
+ pathname: u.pathname,
225
+ search: u.search,
226
+ hash: u.hash,
227
+ searchParams: paramsShape(parseQuery(u.search)),
228
+ };
229
+ }
230
+ /** Apply a mutating `searchParams` verb THROUGH its owning URL, so `href`/`search` stay true.
231
+ *
232
+ * This is the twin of the natives' parent-walk (`JseRunner.kt`'s `receiver.endsWith(".searchParams")`
233
+ * branch and `JSELibrary.swift`'s): mutating the params dict alone leaves the URL describing a
234
+ * query it no longer has, and `href` is what callers hand to fetch/navigate. Returns a NEW url
235
+ * dict for the caller to write back, or null when the receiver is not a URL-owned params dict —
236
+ * in which case the caller falls through to plain value semantics.
237
+ */
238
+ export function mutateURLSearchParams(url, verb, args) {
239
+ if (!isDict(url) || url["__url"] === undefined)
240
+ return null;
241
+ const next = { ...url };
242
+ const sp = next["searchParams"];
243
+ const pairs = isDict(sp) ? paramsPairs(sp) : [];
244
+ let out;
245
+ switch (verb) {
246
+ case "set": {
247
+ const k = string(args[0]);
248
+ const v = string(args[1]);
249
+ out = [...pairs.filter((p) => p[0] !== k), [k, v]];
250
+ break;
251
+ }
252
+ case "append":
253
+ out = [...pairs, [string(args[0]), string(args[1])]];
254
+ break;
255
+ case "delete": {
256
+ const k = string(args[0]);
257
+ out = pairs.filter((p) => p[0] !== k);
258
+ break;
259
+ }
260
+ default:
261
+ return null;
262
+ }
263
+ next["searchParams"] = paramsShape(out);
264
+ resyncURL(next);
265
+ return next;
266
+ }
267
+ /** After a searchParams mutation: resync href/search on the owning URL dict. */
268
+ export function resyncURL(u) {
269
+ const sp = u["searchParams"];
270
+ if (!isDict(sp))
271
+ return;
272
+ const q = paramsToString(paramsPairs(sp));
273
+ const href = string(u["href"]);
274
+ const parsed = (() => { try {
275
+ return new URL(href);
276
+ }
277
+ catch {
278
+ return null;
279
+ } })();
280
+ if (!parsed)
281
+ return;
282
+ parsed.search = q.length > 0 ? "?" + q : "";
283
+ u["search"] = parsed.search;
284
+ u["href"] = parsed.href;
285
+ }
286
+ // ── JSON with the JSE rules ──────────────────────────────────────────────────────────
287
+ // Authored JSON runs on the UI thread on every renderer. Keep it deliberately below
288
+ // the network response ceiling: this is large enough for application state, while a
289
+ // hostile component cannot recursively stringify an unbounded graph or parse a huge
290
+ // payload and monopolize the page. These limits mirror the <api> request graph guard.
291
+ const MAX_JSE_JSON_BYTES = 4 * 1024 * 1024;
292
+ const MAX_JSE_JSON_NODES = 250_000;
293
+ const MAX_JSE_JSON_DEPTH = 128;
294
+ function boundedUtf8Bytes(value, limit) {
295
+ let bytes = 0;
296
+ for (let index = 0; index < value.length; index += 1) {
297
+ const code = value.charCodeAt(index);
298
+ if (code <= 0x7f)
299
+ bytes += 1;
300
+ else if (code <= 0x7ff)
301
+ bytes += 2;
302
+ else if (code >= 0xd800 && code <= 0xdbff) {
303
+ const low = value.charCodeAt(index + 1);
304
+ if (low >= 0xdc00 && low <= 0xdfff) {
305
+ bytes += 4;
306
+ index += 1;
307
+ }
308
+ else
309
+ bytes += 3;
310
+ }
311
+ else
312
+ bytes += 3;
313
+ if (bytes > limit)
314
+ return bytes;
315
+ }
316
+ return bytes;
317
+ }
318
+ /** Exact byte cost of the JSE JSON string spelling (including quotes and the
319
+ * Foundation-compatible escaped slash). Stops as soon as the caller's budget is
320
+ * exceeded so a large hostile string is never copied merely to measure it. */
321
+ function escapedJsonBytes(value, limit) {
322
+ let bytes = 2;
323
+ for (let index = 0; index < value.length; index += 1) {
324
+ const code = value.charCodeAt(index);
325
+ if (code === 0x22 || code === 0x5c || code === 0x2f)
326
+ bytes += 2;
327
+ else if (code <= 0x1f)
328
+ bytes += 6;
329
+ else if (code <= 0x7f)
330
+ bytes += 1;
331
+ else if (code <= 0x7ff)
332
+ bytes += 2;
333
+ else if (code >= 0xd800 && code <= 0xdbff) {
334
+ const low = value.charCodeAt(index + 1);
335
+ if (low >= 0xdc00 && low <= 0xdfff) {
336
+ bytes += 4;
337
+ index += 1;
338
+ }
339
+ else
340
+ bytes += 6;
341
+ }
342
+ else if (code >= 0xdc00 && code <= 0xdfff)
343
+ bytes += 6;
344
+ else
345
+ bytes += 3;
346
+ if (bytes > limit)
347
+ return bytes;
348
+ }
349
+ return bytes;
350
+ }
351
+ /** Iterative graph and exact-output-size preflight. Besides bounding work, the
352
+ * ancestor ledger rejects cycles before the recursive encoder can overflow. */
353
+ function jsonStringifyAllowed(value, indent) {
354
+ const stack = [{ value, depth: 0 }];
355
+ const ancestors = new Set();
356
+ let nodes = 0;
357
+ let bytes = 0;
358
+ const add = (count) => {
359
+ bytes += count;
360
+ return bytes <= MAX_JSE_JSON_BYTES;
361
+ };
362
+ while (stack.length > 0) {
363
+ const frame = stack.pop();
364
+ if (frame.exit !== undefined) {
365
+ ancestors.delete(frame.exit);
366
+ continue;
367
+ }
368
+ nodes += 1;
369
+ if (nodes > MAX_JSE_JSON_NODES || frame.depth > MAX_JSE_JSON_DEPTH)
370
+ return false;
371
+ const next = frame.value;
372
+ if (next === null || next === undefined || next === NSNull || isLambda(next)) {
373
+ if (!add(4))
374
+ return false;
375
+ }
376
+ else if (typeof next === "boolean") {
377
+ if (!add(next ? 4 : 5))
378
+ return false;
379
+ }
380
+ else if (typeof next === "number") {
381
+ if (!add(Number.isFinite(next) ? String(next).length : 4))
382
+ return false;
383
+ }
384
+ else if (typeof next === "string") {
385
+ const cost = escapedJsonBytes(next, MAX_JSE_JSON_BYTES - bytes);
386
+ if (!add(cost))
387
+ return false;
388
+ }
389
+ else if (Array.isArray(next)) {
390
+ if (ancestors.has(next))
391
+ return false;
392
+ ancestors.add(next);
393
+ const count = next.length;
394
+ if (indent === 0) {
395
+ if (!add(2 + Math.max(0, count - 1)))
396
+ return false;
397
+ }
398
+ else if (!add(count === 0
399
+ ? 2
400
+ : 4 + count * indent * (frame.depth + 1) + (count - 1) * 2 + indent * frame.depth))
401
+ return false;
402
+ stack.push({ depth: frame.depth, exit: next });
403
+ for (let index = count - 1; index >= 0; index -= 1) {
404
+ stack.push({ value: next[index], depth: frame.depth + 1 });
405
+ }
406
+ }
407
+ else if (isDict(next)) {
408
+ if (ancestors.has(next))
409
+ return false;
410
+ ancestors.add(next);
411
+ const entries = Object.entries(next);
412
+ const count = entries.length;
413
+ if (indent === 0) {
414
+ if (!add(2 + Math.max(0, count - 1)))
415
+ return false;
416
+ }
417
+ else if (!add(count === 0
418
+ ? 2
419
+ : 4 + count * indent * (frame.depth + 1) + (count - 1) * 2 + indent * frame.depth))
420
+ return false;
421
+ stack.push({ depth: frame.depth, exit: next });
422
+ for (let index = count - 1; index >= 0; index -= 1) {
423
+ const [key, entryValue] = entries[index];
424
+ const keyCost = escapedJsonBytes(key, MAX_JSE_JSON_BYTES - bytes);
425
+ if (!add(keyCost + (indent > 0 ? 2 : 1)))
426
+ return false;
427
+ stack.push({ value: entryValue, depth: frame.depth + 1 });
428
+ }
429
+ }
430
+ else {
431
+ const cost = escapedJsonBytes(String(next), MAX_JSE_JSON_BYTES - bytes);
432
+ if (!add(cost))
433
+ return false;
434
+ }
435
+ }
436
+ return true;
437
+ }
438
+ /** THE SERIALIZED VIEW OF A CORE SHAPE, the twin of JSELibrary.jsonSanitize (iOS) and
439
+ * Globals.jsonSanitize (Android). A JSE value object is a plain dict carrying a `__`
440
+ * marker key, and the web encoder walked those markers straight into the text: a Date
441
+ * serialized as `{"__date":0}` where both natives wrote its ISO string, and a URL
442
+ * serialized its whole component table where both natives wrote its href. That is
443
+ * Appendix E item 4: one markup, two payloads, and every body that posts a date over
444
+ * fetch sends a different thing depending on the lane it runs on. The rules are the
445
+ * natives': Date to ISO, URL to href, params to the query string, a blob or a form to
446
+ * null, and any other `__` key dropped rather than published.
447
+ *
448
+ * FOLDED WITH THE JS GLOBALS LAYER. Every shape it rewrites is minted by JSECore, so in a
449
+ * build with `__DSX_OPTIONAL_JS_GLOBALS__` false no value object can exist and the pass is
450
+ * provably the identity. `jsonStringify` itself cannot fold, because the house log
451
+ * formatter calls it, so without this gate the whole walk rode into every widget: 213
452
+ * gzip bytes of the EmbedCard slice, measured. */
453
+ function jsonSanitize(v) {
454
+ if (isDict(v)) {
455
+ const d = v;
456
+ if (isDateShape(d))
457
+ return toISO(d["__date"]);
458
+ if (d["__url"] !== undefined)
459
+ return string(d["href"] ?? "");
460
+ if (d["__params"] !== undefined)
461
+ return paramsToString(paramsPairs(d));
462
+ if (d["__blob"] !== undefined || d["__formdata"] !== undefined)
463
+ return NSNull;
464
+ const out = {};
465
+ for (const [k, val] of Object.entries(d))
466
+ if (!k.startsWith("__"))
467
+ out[k] = jsonSanitize(val);
468
+ return out;
469
+ }
470
+ if (Array.isArray(v))
471
+ return v.map((e) => jsonSanitize(e));
472
+ return v;
473
+ }
474
+ function jsonStringify(raw, space) {
475
+ // The condition is spelled INLINE, exactly as the JSECore binding below spells it, and
476
+ // not through a named constant: a constant reads as a variable to the bundler and the
477
+ // reference survives, which is measured (41800 to 41813 gz on the EmbedCard slice, the
478
+ // wrong way). Written out, `false !== false ? … : raw` folds to `raw` and the whole walk
479
+ // leaves the widget.
480
+ const v = globalThis
481
+ .__DSX_OPTIONAL_JS_GLOBALS__ !== false ? jsonSanitize(raw) : raw;
482
+ // THE GAP: a number is that many spaces (at most 10), a text its first 10 characters, as
483
+ // JavaScript's JSON.stringify reads its third argument (logic parity sweep 5).
484
+ const gap = typeof space === "string" ? space.slice(0, 10)
485
+ : typeof space === "number" ? " ".repeat(Math.max(0, Math.min(10, Math.trunc(space)))) : "";
486
+ const indent = gap.length;
487
+ if (!jsonStringifyAllowed(v, indent))
488
+ return null;
489
+ const enc = (x, depth) => {
490
+ if (x === null || x === undefined || x === NSNull)
491
+ return "null";
492
+ if (typeof x === "boolean")
493
+ return x ? "true" : "false";
494
+ if (typeof x === "number") {
495
+ if (!Number.isFinite(x))
496
+ return "null"; // NaN/Inf → null
497
+ if (Math.floor(x) === x && Math.abs(x) < 1e15)
498
+ return String(x); // integral → int
499
+ return String(x);
500
+ }
501
+ if (typeof x === "string") {
502
+ // JSON escape as JavaScript writes it: `/` stays `/` (JSE-VS-JS #16)
503
+ return JSON.stringify(x);
504
+ }
505
+ if (Array.isArray(x)) {
506
+ const parts = x.map((e) => enc(e, depth + 1) ?? "null");
507
+ if (indent === 0)
508
+ return "[" + parts.join(",") + "]";
509
+ const pad = gap.repeat(depth + 1);
510
+ const end = gap.repeat(depth);
511
+ return parts.length === 0 ? "[]" : "[\n" + parts.map((p) => pad + p).join(",\n") + "\n" + end + "]";
512
+ }
513
+ if (isDict(x)) {
514
+ const d = x;
515
+ const keys = Object.keys(d);
516
+ const parts = keys.map((k) => {
517
+ const kk = JSON.stringify(k);
518
+ return `${kk}:${indent > 0 ? " " : ""}${enc(d[k], depth + 1) ?? "null"}`;
519
+ });
520
+ if (indent === 0)
521
+ return "{" + parts.join(",") + "}";
522
+ const pad = gap.repeat(depth + 1);
523
+ const end = gap.repeat(depth);
524
+ return parts.length === 0 ? "{}" : "{\n" + parts.map((p) => pad + p).join(",\n") + "\n" + end + "}";
525
+ }
526
+ if (isLambda(x))
527
+ return null;
528
+ return JSON.stringify(String(x));
529
+ };
530
+ return enc(v, 0);
531
+ }
532
+ function jsonParse(s) {
533
+ if (s.length > MAX_JSE_JSON_BYTES || boundedUtf8Bytes(s, MAX_JSE_JSON_BYTES) > MAX_JSE_JSON_BYTES)
534
+ return null;
535
+ try {
536
+ const raw = JSON.parse(s);
537
+ let nodes = 0;
538
+ const map = (x, depth) => {
539
+ nodes += 1;
540
+ if (nodes > MAX_JSE_JSON_NODES || depth > MAX_JSE_JSON_DEPTH)
541
+ throw new Error("json_too_complex");
542
+ if (x === null)
543
+ return NSNull; // present-but-null sentinel
544
+ if (Array.isArray(x))
545
+ return x.map((entry) => map(entry, depth + 1));
546
+ if (typeof x === "object") {
547
+ const out = {};
548
+ for (const [k, v] of Object.entries(x)) {
549
+ // Assignment to `out.__proto__` invokes Object.prototype's legacy setter.
550
+ // Define every JSON key as data so authored/untrusted JSON cannot forge an
551
+ // inherited JSE property while preserving normal JSON.parse key semantics.
552
+ Object.defineProperty(out, k, {
553
+ value: map(v, depth + 1),
554
+ enumerable: true,
555
+ configurable: true,
556
+ writable: true,
557
+ });
558
+ }
559
+ return out;
560
+ }
561
+ return x;
562
+ };
563
+ return map(raw, 0);
564
+ }
565
+ catch {
566
+ return null;
567
+ }
568
+ }
569
+ // ── base64 (host-agnostic — btoa/atob without window) ───────────────────────────────
570
+ const B64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
571
+ export function base64Encode(bytes) {
572
+ let out = "";
573
+ for (let i = 0; i < bytes.length; i += 3) {
574
+ const b0 = bytes[i];
575
+ const b1 = i + 1 < bytes.length ? bytes[i + 1] : 0;
576
+ const b2 = i + 2 < bytes.length ? bytes[i + 2] : 0;
577
+ out += B64[b0 >> 2] + B64[((b0 & 3) << 4) | (b1 >> 4)];
578
+ out += i + 1 < bytes.length ? B64[((b1 & 15) << 2) | (b2 >> 6)] : "=";
579
+ out += i + 2 < bytes.length ? B64[b2 & 63] : "=";
580
+ }
581
+ return out;
582
+ }
583
+ export function base64Decode(s) {
584
+ const clean = s.replace(/[\r\n\s]/g, "");
585
+ if (!/^[A-Za-z0-9+/]*={0,2}$/.test(clean) || clean.length % 4 === 1)
586
+ return null;
587
+ const body = clean.replace(/=+$/, "");
588
+ const out = [];
589
+ let buffer = 0;
590
+ let bits = 0;
591
+ for (const c of body) {
592
+ buffer = (buffer << 6) | B64.indexOf(c);
593
+ bits += 6;
594
+ if (bits >= 8) {
595
+ bits -= 8;
596
+ out.push((buffer >> bits) & 0xff);
597
+ }
598
+ }
599
+ return new Uint8Array(out);
600
+ }
601
+ // ── JSECrypto — byte plumbing + companions (WebCrypto under the hood) ────────────────
602
+ const JSE_CRYPTO_FULL = {
603
+ /** BufferSource coercion: a JSE number array (bytes), a String (UTF-8). */
604
+ data(v) {
605
+ if (Array.isArray(v)) {
606
+ const d = new Uint8Array(v.length);
607
+ for (let i = 0; i < v.length; i++) {
608
+ const n = number(v[i]);
609
+ if (n === null)
610
+ return null;
611
+ d[i] = safeInt(n) & 0xff; // low byte
612
+ }
613
+ return d;
614
+ }
615
+ if (typeof v === "string")
616
+ return new TextEncoder().encode(v);
617
+ return null;
618
+ },
619
+ /** Uint8Array → the JSE byte array ([number] 0–255) every result travels as. */
620
+ bytes(d) {
621
+ return Array.from(d, (b) => b);
622
+ },
623
+ base64(d) {
624
+ return base64Encode(d);
625
+ },
626
+ call(name, a) {
627
+ switch (name) {
628
+ case "Uint8Array": {
629
+ const arg = a[0];
630
+ const n = number(arg);
631
+ if (n !== null && !Array.isArray(arg))
632
+ return new Array(Math.max(0, Math.min(safeInt(n), 10_000_000))).fill(0);
633
+ const d = JSECrypto.data(arg);
634
+ return d ? JSECrypto.bytes(d) : [];
635
+ }
636
+ case "TextEncoder": return { __textEncoder: true };
637
+ case "TextDecoder": return { __textDecoder: true };
638
+ case "Array.from": {
639
+ const d = JSECrypto.data(a[0]);
640
+ return d ? JSECrypto.bytes(d) : [];
641
+ }
642
+ case "btoa": {
643
+ const s = string(a[0]);
644
+ const bytes = new Uint8Array(s.length);
645
+ for (let i = 0; i < s.length; i++)
646
+ bytes[i] = s.charCodeAt(i) & 0xff;
647
+ return base64Encode(bytes);
648
+ }
649
+ case "atob": {
650
+ const d = base64Decode(string(a[0]));
651
+ if (!d)
652
+ return null;
653
+ let out = "";
654
+ for (const b of d)
655
+ out += String.fromCharCode(b);
656
+ return out;
657
+ }
658
+ case "crypto.randomUUID":
659
+ return globalThis.crypto?.randomUUID?.() ?? null;
660
+ case "crypto.getRandomValues": {
661
+ const len = Array.isArray(a[0]) ? a[0].length : safeInt(number(a[0]) ?? 0);
662
+ const buf = new Uint8Array(Math.max(0, Math.min(len, 65536)));
663
+ globalThis.crypto?.getRandomValues?.(buf);
664
+ return JSECrypto.bytes(buf);
665
+ }
666
+ default:
667
+ if (name.startsWith("crypto.subtle.")) {
668
+ // async on the web — a real Promise the action runner awaits (statement-await)
669
+ return subtleCall(name.substring("crypto.subtle.".length), a);
670
+ }
671
+ console.warn(`[JSE crypto] unsupported: ${name}`);
672
+ return null;
673
+ }
674
+ },
675
+ };
676
+ /** the folded twin: no name in the slice can reach a crypto companion */
677
+ const JSE_CRYPTO_ABSENT = {
678
+ data: () => null,
679
+ bytes: () => [],
680
+ base64: () => "",
681
+ call: () => null,
682
+ };
683
+ export const JSECrypto = globalThis
684
+ .__DSX_OPTIONAL_JS_GLOBALS__ !== false ? JSE_CRYPTO_FULL : JSE_CRYPTO_ABSENT;
685
+ function subtleCall(method, a) {
686
+ const subtle = globalThis.crypto?.subtle;
687
+ if (!subtle)
688
+ return null;
689
+ if (method === "digest") {
690
+ const alg = string(a[0]);
691
+ const d = JSECrypto.data(a[1]);
692
+ if (!d)
693
+ return null;
694
+ return subtle.digest(alg, d).then((buf) => JSECrypto.bytes(new Uint8Array(buf)));
695
+ }
696
+ console.warn(`[JSE crypto] subtle.${method} pending on this runtime`);
697
+ return null;
698
+ }
699
+ // ── JSECore — routing (the exact reference switch) ───────────────────────────────────
700
+ const JSE_CORE_FULL = {
701
+ handles(name) {
702
+ if (name.startsWith("Math.") || name.startsWith("Intl.") || name.startsWith("JSON.") ||
703
+ name.startsWith("Date.") || name.startsWith("Promise.") ||
704
+ name.startsWith("Object.") || name.startsWith("console.") ||
705
+ name.startsWith("performance."))
706
+ return true;
707
+ switch (name) {
708
+ case "URL":
709
+ case "URLSearchParams":
710
+ case "Headers":
711
+ case "Request":
712
+ case "Blob":
713
+ case "File":
714
+ case "FormData":
715
+ case "Date":
716
+ case "AbortController":
717
+ case "structuredClone":
718
+ case "encodeURIComponent":
719
+ case "decodeURIComponent":
720
+ case "encodeURI":
721
+ case "decodeURI":
722
+ case "parseInt":
723
+ case "parseFloat":
724
+ case "isNaN":
725
+ case "isFinite":
726
+ case "Number":
727
+ case "String":
728
+ case "Boolean":
729
+ case "Map":
730
+ case "Set":
731
+ case "Error":
732
+ case "RegExp":
733
+ case "WebSocket":
734
+ case "Array":
735
+ return true;
736
+ default:
737
+ return false;
738
+ }
739
+ },
740
+ call(name, a) {
741
+ if (name.startsWith("Math."))
742
+ return coreMath(name.substring(5), a);
743
+ if (name.startsWith("JSON.")) {
744
+ if (name === "JSON.stringify")
745
+ return jsonStringify(a[0], typeof a[2] === "string" ? a[2] : number(a[2]) ?? (typeof a[1] === "number" ? a[1] : null));
746
+ if (name === "JSON.parse")
747
+ return jsonParse(string(a[0]));
748
+ return null;
749
+ }
750
+ if (name.startsWith("Object.")) {
751
+ const fn = name.substring(7);
752
+ const d = isDict(a[0]) ? a[0] : null;
753
+ switch (fn) {
754
+ // A `__` marker key is the value object's own machinery, never a property the
755
+ // author put there, and both natives filter it out of this trio (Appendix E item
756
+ // 4). Web did not, so `Object.keys(new Map())` answered `["__map","size"]` here
757
+ // and `["size"]` on a phone.
758
+ // AN ARRAY'S OWN KEYS ARE ITS INDICES, as strings (logic parity, JSE-VS-JS item 7;
759
+ // corpus jse/array-from-001.json): `Object.keys([4, 5])` is ['0', '1'], not [].
760
+ // A STRING'S OWN KEYS ARE ITS CHARACTERS' INDICES (logic parity sweep 5, corpus
761
+ // jse/members-003.json), counted in characters (the kept grapheme law).
762
+ case "keys":
763
+ if (typeof a[0] === "string")
764
+ return graphemes(a[0]).map((_, i) => String(i));
765
+ if (Array.isArray(a[0]))
766
+ return a[0].map((_, i) => String(i));
767
+ return d ? Object.keys(d).filter((k) => !k.startsWith("__")) : [];
768
+ case "values":
769
+ if (typeof a[0] === "string")
770
+ return graphemes(a[0]);
771
+ if (Array.isArray(a[0]))
772
+ return [...a[0]];
773
+ return d ? Object.entries(d).filter(([k]) => !k.startsWith("__")).map(([, v]) => v) : [];
774
+ case "entries":
775
+ if (typeof a[0] === "string")
776
+ return graphemes(a[0]).map((v, i) => [String(i), v]);
777
+ if (Array.isArray(a[0]))
778
+ return a[0].map((v, i) => [String(i), v]);
779
+ return d ? Object.entries(d).filter(([k]) => !k.startsWith("__")).map(([k, v]) => [k, v]) : [];
780
+ case "assign": {
781
+ const out = {};
782
+ for (const arg of a)
783
+ if (isDict(arg))
784
+ Object.assign(out, arg);
785
+ return out;
786
+ }
787
+ // SameValue (JSE-VS-JS item 15): NaN is itself, 0 is not -0, anything else strictly
788
+ case "is": {
789
+ const x = a[0], y = a[1];
790
+ if (typeof x === "number" && typeof y === "number")
791
+ return Object.is(x, y);
792
+ return jseStrictEquals(x ?? null, y ?? null);
793
+ }
794
+ case "hasOwn": {
795
+ const o = a[0];
796
+ return isDict(o) ? Object.prototype.hasOwnProperty.call(o, string(a[1])) : false;
797
+ }
798
+ case "fromEntries": {
799
+ const out = {};
800
+ for (const e of a[0] && Array.isArray(a[0]) ? a[0] : []) {
801
+ if (Array.isArray(e) && e.length >= 1)
802
+ out[string(e[0])] = e.length > 1 ? e[1] : NSNull;
803
+ }
804
+ return out;
805
+ }
806
+ default: return null;
807
+ }
808
+ }
809
+ if (name.startsWith("console.")) {
810
+ const level = name.substring(8);
811
+ const msg = formatLogArgs(a);
812
+ // the unified log ring (dsx.logs / the dev drawer) sees console.* too — the
813
+ // builtin has no scheme of its own, so entries attribute as "console"
814
+ DSXLogs.append({ scheme: "console", level, message: msg, at: Date.now() });
815
+ if (level === "error")
816
+ console.error("[dsx]", msg);
817
+ else if (level === "warn")
818
+ console.warn("[dsx]", msg);
819
+ else
820
+ console.log("[dsx]", msg);
821
+ return null;
822
+ }
823
+ if (name.startsWith("performance.")) {
824
+ if (name === "performance.now")
825
+ return globalThis.performance?.now?.() ?? Date.now();
826
+ return null;
827
+ }
828
+ if (name.startsWith("Date.")) {
829
+ if (name === "Date.now")
830
+ return Date.now();
831
+ if (name === "Date.UTC") {
832
+ const nn = (i) => (i < a.length ? (number(a[i]) ?? 0) : 0);
833
+ const ms = Date.UTC(nn(0), a.length > 1 ? nn(1) : 0, a.length > 2 ? nn(2) : 1, nn(3), nn(4), nn(5), nn(6));
834
+ return Number.isNaN(ms) ? null : ms;
835
+ }
836
+ if (name === "Date.parse") {
837
+ return parseDateMS(string(a[0])); // ms or NaN — the one ladder, see parseDateMS
838
+ }
839
+ return null;
840
+ }
841
+ if (name.startsWith("Intl."))
842
+ return intlCall(name.substring(5), a);
843
+ if (name.startsWith("Promise."))
844
+ return promiseCall(name.substring(8), a);
845
+ switch (name) {
846
+ case "URL": {
847
+ const base = a.length > 1 ? string(a[1]) : undefined;
848
+ return makeURL(string(a[0]), base);
849
+ }
850
+ case "URLSearchParams": {
851
+ const init = a[0];
852
+ if (typeof init === "string")
853
+ return paramsShape(parseQuery(init));
854
+ if (isDict(init)) {
855
+ if (isDict(init["__params"]) || Array.isArray(init["__params"])) {
856
+ return paramsShape(paramsPairs(init));
857
+ }
858
+ return paramsShape(Object.entries(init).map(([k, v]) => [k, string(v)]));
859
+ }
860
+ if (Array.isArray(init)) {
861
+ return paramsShape(init.map((e) => [string(e[0]), string(e[1])]));
862
+ }
863
+ return paramsShape([]);
864
+ }
865
+ case "Headers": {
866
+ const init = isDict(a[0]) ? a[0] : {};
867
+ const entries = {};
868
+ for (const [k, v] of Object.entries(init))
869
+ entries[k.toLowerCase()] = string(v);
870
+ return { __headers: true, ...entries };
871
+ }
872
+ case "Request": return { __request: true, url: string(a[0]), ...(isDict(a[1]) ? a[1] : {}) };
873
+ case "Blob":
874
+ case "File": {
875
+ const parts = Array.isArray(a[0]) ? a[0] : [];
876
+ let bytes = new Uint8Array(0);
877
+ for (const p of parts) {
878
+ const d = JSECrypto.data(p) ?? (typeof p === "string" ? new TextEncoder().encode(p) : null);
879
+ if (d) {
880
+ const merged = new Uint8Array(bytes.length + d.length);
881
+ merged.set(bytes);
882
+ merged.set(d, bytes.length);
883
+ bytes = merged;
884
+ }
885
+ }
886
+ const opts = isDict(name === "File" ? a[2] : a[1]) ? (name === "File" ? a[2] : a[1]) : {};
887
+ const shape = { __blob: base64Encode(bytes), type: string(opts["type"] ?? ""), size: bytes.length };
888
+ if (name === "File") {
889
+ shape["name"] = string(a[1]);
890
+ shape["lastModified"] = Date.now();
891
+ }
892
+ return shape;
893
+ }
894
+ case "FormData": return { __formData: true, entries: [] };
895
+ case "Date": {
896
+ if (a.length === 0)
897
+ return dateShape(Date.now());
898
+ if (a.length >= 2) {
899
+ // component form — LOCAL time: year, month0[, day[, h[, m[, s[, ms]]]]].
900
+ // Any non-finite component → an invalid date (NaN ms), matching the twins.
901
+ const nn = (i, def) => (i < a.length ? (number(a[i]) ?? NaN) : def);
902
+ const y = nn(0, 1970);
903
+ const parts = [y, nn(1, 0), nn(2, 1), nn(3, 0), nn(4, 0), nn(5, 0), nn(6, 0)];
904
+ if (parts.some((p) => !Number.isFinite(p)))
905
+ return dateShape(NaN);
906
+ const dt = new Date(parts[0], parts[1], parts[2], parts[3], parts[4], parts[5], parts[6]);
907
+ if (y >= 0 && y <= 99)
908
+ dt.setFullYear(y); // the literal year — no JS two-digit-year quirk (twin parity)
909
+ return dateShape(dt.getTime());
910
+ }
911
+ const v = a[0];
912
+ if (isDict(v) && isDateShape(v))
913
+ return dateShape(v["__date"]);
914
+ const n = typeof v === "number" ? v : null;
915
+ if (n !== null)
916
+ return dateShape(n);
917
+ return dateShape(parseDateMS(string(v)));
918
+ }
919
+ case "AbortController": return { __abortController: true, signal: { __abortSignal: true, aborted: false } };
920
+ case "structuredClone": return structuredCloneValue(a[0]);
921
+ case "encodeURIComponent": return encodeURIComponent(string(a[0]));
922
+ case "decodeURIComponent": {
923
+ try {
924
+ return decodeURIComponent(string(a[0]));
925
+ }
926
+ catch {
927
+ return null;
928
+ }
929
+ }
930
+ case "encodeURI": return encodeURI(string(a[0]));
931
+ case "decodeURI": {
932
+ try {
933
+ return decodeURI(string(a[0]));
934
+ }
935
+ catch {
936
+ return null;
937
+ }
938
+ }
939
+ case "parseInt": {
940
+ const s = string(a[0]).trim();
941
+ let radix = safeInt(number(a[1]) ?? 0);
942
+ let body = s;
943
+ let sign = 1;
944
+ if (body.startsWith("-")) {
945
+ sign = -1;
946
+ body = body.substring(1);
947
+ }
948
+ else if (body.startsWith("+"))
949
+ body = body.substring(1);
950
+ if ((radix === 0 || radix === 16) && /^0x/i.test(body)) {
951
+ radix = 16;
952
+ body = body.substring(2);
953
+ }
954
+ if (radix === 0)
955
+ radix = 10;
956
+ if (radix < 2 || radix > 36)
957
+ return NaN;
958
+ let out = 0;
959
+ let any = false;
960
+ for (const c of body) {
961
+ const d = parseInt(c, 36);
962
+ if (Number.isNaN(d) || d >= radix)
963
+ break;
964
+ out = out * radix + d;
965
+ any = true;
966
+ }
967
+ return any ? sign * out : NaN;
968
+ }
969
+ case "parseFloat": {
970
+ const text = string(a[0]).trim();
971
+ const inf = /^([+-]?)Infinity/.exec(text);
972
+ if (inf)
973
+ return inf[1] === "-" ? -Infinity : Infinity;
974
+ const m = /^[+-]?(\d+\.?\d*|\.\d+)(e[+-]?\d+)?/i.exec(text);
975
+ return m ? Number(m[0]) : NaN;
976
+ }
977
+ case "isNaN": {
978
+ const n = number(a[0]);
979
+ return n === null || Number.isNaN(n);
980
+ }
981
+ // The twin of isNaN, which shipped without it: an author reaching for one reaches for
982
+ // the other, and a missing global reads as `null` — silently falsy — not as an error.
983
+ case "isFinite": {
984
+ const n = number(a[0]);
985
+ return n !== null && Number.isFinite(n);
986
+ }
987
+ case "Number": return a.length === 0 ? 0 : numberJS(a[0]) ?? NaN;
988
+ case "String": return string(a[0]);
989
+ case "Boolean": return truthy(a[0]);
990
+ // `Array(n)` is n empty slots (JSE has no holes, so nulls), `Array(a, b)` its arguments
991
+ // (JSE-VS-JS item 8). The length is bounded like `new Array` elsewhere.
992
+ case "Array": {
993
+ if (a.length === 1 && typeof a[0] === "number") {
994
+ const n = a[0];
995
+ return Number.isInteger(n) && n >= 0 && n <= 10_000 ? new Array(n).fill(NSNull) : null;
996
+ }
997
+ return [...a];
998
+ }
999
+ case "Map": {
1000
+ const entries = [];
1001
+ if (Array.isArray(a[0]))
1002
+ for (const e of a[0])
1003
+ if (Array.isArray(e))
1004
+ entries.push([e[0], e.length > 1 ? e[1] : NSNull]);
1005
+ return { __map: entries, size: entries.length };
1006
+ }
1007
+ case "Set": {
1008
+ const values = [];
1009
+ if (Array.isArray(a[0]))
1010
+ for (const v of a[0])
1011
+ if (!values.some((x) => jseEquals(x, v)))
1012
+ values.push(v);
1013
+ return { __set: values, size: values.length };
1014
+ }
1015
+ case "Error": return { __error: true, name: "Error", message: string(a[0]) }; // native twins carry the marker (Globals.kt / Stack.swift)
1016
+ case "RegExp": return { __regex: true, source: string(a[0]), flags: string(a[1]) };
1017
+ case "WebSocket": return null; // statement-only (the action runner owns sockets)
1018
+ default: return null;
1019
+ }
1020
+ },
1021
+ /** Constants the evaluator can't reach as calls (bare member reads on a namespace). */
1022
+ constant(id) {
1023
+ switch (id) {
1024
+ case "Math.PI": return Math.PI;
1025
+ case "Math.E": return Math.E;
1026
+ case "Math.SQRT2": return Math.SQRT2;
1027
+ case "Math.SQRT1_2": return Math.SQRT1_2;
1028
+ case "Math.LN2": return Math.LN2;
1029
+ case "Math.LN10": return Math.LN10;
1030
+ case "Math.LOG2E": return Math.LOG2E;
1031
+ case "Math.LOG10E": return Math.LOG10E;
1032
+ case "Number.MAX_SAFE_INTEGER": return 9007199254740991;
1033
+ case "Number.MAX_VALUE": return Number.MAX_VALUE;
1034
+ case "Number.MIN_VALUE": return Number.MIN_VALUE;
1035
+ case "Number.MIN_SAFE_INTEGER": return -9007199254740991;
1036
+ case "Number.EPSILON": return Number.EPSILON;
1037
+ case "Infinity": return Infinity;
1038
+ case "NaN": return NaN;
1039
+ default: return builtinFunctionValue(id);
1040
+ }
1041
+ },
1042
+ /** applyMethod's first stop — claims the call only for ITS dict shapes.
1043
+ * Returns null = "not mine"; { value } = handled (value may be null). */
1044
+ method(m, base, a) {
1045
+ if (!isDict(base))
1046
+ return null;
1047
+ const d = base;
1048
+ if (d["__regex"] !== undefined && d["__regex"] !== null && m === "test") {
1049
+ // string-side match/replace/split live on the string cases
1050
+ return { value: regexTest(string(a[0]), d) };
1051
+ }
1052
+ // `re.exec(s)`: the first match as a match array, an unmatched group null (logic parity,
1053
+ // JSE-VS-JS item 9; corpus jse/regex-exec-001.json). It answered null for every input. A
1054
+ // JSE regex holds no lastIndex, so a /g pattern answers its first match too.
1055
+ if (d["__regex"] !== undefined && d["__regex"] !== null && m === "exec") {
1056
+ return { value: regexExec(string(a[0]), d) };
1057
+ }
1058
+ if (isDateShape(d)) {
1059
+ const ms = d["__date"];
1060
+ const dt = dateOf(d);
1061
+ switch (m) {
1062
+ case "getTime":
1063
+ case "valueOf": return { value: ms };
1064
+ case "toISOString":
1065
+ case "toJSON": return { value: toISO(ms) };
1066
+ case "getFullYear": return { value: dt.getFullYear() };
1067
+ case "getMonth": return { value: dt.getMonth() }; // 0-based
1068
+ case "getDate": return { value: dt.getDate() };
1069
+ case "getDay": return { value: dt.getDay() }; // 0 = Sunday
1070
+ case "getHours": return { value: dt.getHours() };
1071
+ case "getMinutes": return { value: dt.getMinutes() };
1072
+ case "getSeconds": return { value: dt.getSeconds() };
1073
+ case "getMilliseconds": return { value: dt.getMilliseconds() };
1074
+ case "getUTCFullYear": return { value: dt.getUTCFullYear() };
1075
+ case "getUTCMonth": return { value: dt.getUTCMonth() };
1076
+ case "getUTCDate": return { value: dt.getUTCDate() };
1077
+ case "getUTCDay": return { value: dt.getUTCDay() };
1078
+ case "getUTCHours": return { value: dt.getUTCHours() };
1079
+ case "getUTCMinutes": return { value: dt.getUTCMinutes() };
1080
+ case "getUTCSeconds": return { value: dt.getUTCSeconds() };
1081
+ case "getUTCMilliseconds": return { value: dt.getUTCMilliseconds() };
1082
+ case "getTimezoneOffset": return { value: dt.getTimezoneOffset() };
1083
+ case "setTime":
1084
+ case "setFullYear":
1085
+ case "setMonth":
1086
+ case "setDate":
1087
+ case "setHours":
1088
+ case "setMinutes":
1089
+ case "setSeconds":
1090
+ case "setMilliseconds":
1091
+ case "setUTCFullYear":
1092
+ case "setUTCMonth":
1093
+ case "setUTCDate":
1094
+ case "setUTCHours":
1095
+ case "setUTCMinutes":
1096
+ case "setUTCSeconds":
1097
+ case "setUTCMilliseconds": {
1098
+ const next = dateSet(ms, m, a);
1099
+ d["__date"] = next; // value-object mutation (statement position persists it)
1100
+ return { value: next };
1101
+ }
1102
+ case "toLocaleDateString": return { value: dt.toLocaleDateString(localeArg(a[0]), intlOpts(a[1])) };
1103
+ case "toLocaleTimeString": return { value: dt.toLocaleTimeString(localeArg(a[0]), intlOpts(a[1])) };
1104
+ case "toLocaleString": return { value: dt.toLocaleString(localeArg(a[0]), intlOpts(a[1])) };
1105
+ case "toString": return { value: dt.toString() };
1106
+ default: return null;
1107
+ }
1108
+ }
1109
+ if (d["__params"] !== undefined) {
1110
+ const pairs = paramsPairs(d);
1111
+ switch (m) {
1112
+ case "get": {
1113
+ const k = string(a[0]);
1114
+ const hit = pairs.find((p) => p[0] === k);
1115
+ return { value: hit ? hit[1] : null };
1116
+ }
1117
+ case "getAll": {
1118
+ const k = string(a[0]);
1119
+ return { value: pairs.filter((p) => p[0] === k).map((p) => p[1]) };
1120
+ }
1121
+ case "has": {
1122
+ const k = string(a[0]);
1123
+ return { value: pairs.some((p) => p[0] === k) };
1124
+ }
1125
+ case "set": { // value-semantics callers use the statement path; expression form mutates the dict copy
1126
+ const k = string(a[0]);
1127
+ const v = string(a[1]);
1128
+ const rest = pairs.filter((p) => p[0] !== k);
1129
+ d["__params"] = [...rest, [k, v]];
1130
+ return { value: null };
1131
+ }
1132
+ case "append": {
1133
+ d["__params"] = [...pairs, [string(a[0]), string(a[1])]];
1134
+ return { value: null };
1135
+ }
1136
+ case "delete": {
1137
+ const k = string(a[0]);
1138
+ d["__params"] = pairs.filter((p) => p[0] !== k);
1139
+ return { value: null };
1140
+ }
1141
+ case "toString": return { value: paramsToString(pairs) };
1142
+ default: return null;
1143
+ }
1144
+ }
1145
+ if (d["__map"] !== undefined) {
1146
+ const entries = Array.isArray(d["__map"]) ? d["__map"] : [];
1147
+ switch (m) {
1148
+ case "get": {
1149
+ const hit = entries.find((e) => jseEquals(e[0], a[0]));
1150
+ return { value: hit ? hit[1] : null };
1151
+ }
1152
+ case "has": return { value: entries.some((e) => jseEquals(e[0], a[0])) };
1153
+ case "set": {
1154
+ const rest = entries.filter((e) => !jseEquals(e[0], a[0]));
1155
+ d["__map"] = [...rest, [a[0], a[1]]];
1156
+ d["size"] = d["__map"].length;
1157
+ return { value: d };
1158
+ }
1159
+ case "delete": {
1160
+ const rest = entries.filter((e) => !jseEquals(e[0], a[0]));
1161
+ const removed = rest.length !== entries.length;
1162
+ d["__map"] = rest;
1163
+ d["size"] = rest.length;
1164
+ return { value: removed };
1165
+ }
1166
+ // THE ITERATION METHODS (Appendix E item 8). A Map answered `[]` for all three on
1167
+ // every runner, because the generic array arms downstream coerce a dict to the
1168
+ // empty array, so `for (const k of m.keys())` looped zero times and said nothing
1169
+ // about it. JSE has no lazy iterator, so each answers the ARRAY the spread already
1170
+ // produced: JS semantics, materialised.
1171
+ case "keys": return { value: entries.map((e) => e[0] ?? NSNull) };
1172
+ case "values": return { value: entries.map((e) => e[1] ?? NSNull) };
1173
+ case "entries": return { value: entries.map((e) => [e[0] ?? NSNull, e[1] ?? NSNull]) };
1174
+ default: return null;
1175
+ }
1176
+ }
1177
+ if (d["__set"] !== undefined) {
1178
+ const values = Array.isArray(d["__set"]) ? d["__set"] : [];
1179
+ switch (m) {
1180
+ case "has": return { value: values.some((x) => jseEquals(x, a[0])) };
1181
+ case "add": {
1182
+ if (!values.some((x) => jseEquals(x, a[0]))) {
1183
+ d["__set"] = [...values, a[0]];
1184
+ d["size"] = d["__set"].length;
1185
+ }
1186
+ return { value: d };
1187
+ }
1188
+ case "delete": {
1189
+ const rest = values.filter((x) => !jseEquals(x, a[0]));
1190
+ const removed = rest.length !== values.length;
1191
+ d["__set"] = rest;
1192
+ d["size"] = rest.length;
1193
+ return { value: removed };
1194
+ }
1195
+ // A Set's keys ARE its values in JS, and its entries pair each member with itself
1196
+ // (Appendix E item 8, the Map arm's twin).
1197
+ case "keys":
1198
+ case "values": return { value: [...values] };
1199
+ case "entries": return { value: values.map((x) => [x ?? NSNull, x ?? NSNull]) };
1200
+ default: return null;
1201
+ }
1202
+ }
1203
+ // A FETCH RESULT IS RESPONSE-SHAPED (jse.md fetch companions): `await r.json()` answers the
1204
+ // parsed body and `await r.text()` the raw one, as on the natives (Stack.swift / Globals.kt).
1205
+ if (d["__response"] !== undefined) {
1206
+ switch (m) {
1207
+ case "json": {
1208
+ const t = d["text"];
1209
+ if (typeof t !== "string")
1210
+ return { value: d["data"] ?? null };
1211
+ try {
1212
+ return { value: t.length === 0 ? null : JSON.parse(t) };
1213
+ }
1214
+ catch {
1215
+ return { value: null };
1216
+ }
1217
+ }
1218
+ case "text": return { value: typeof d["text"] === "string" ? d["text"] : "" };
1219
+ default: return null;
1220
+ }
1221
+ }
1222
+ if (d["__headers"] !== undefined) {
1223
+ switch (m) {
1224
+ case "get": return { value: d[string(a[0]).toLowerCase()] ?? null };
1225
+ case "has": return { value: d[string(a[0]).toLowerCase()] !== undefined };
1226
+ case "set": {
1227
+ d[string(a[0]).toLowerCase()] = string(a[1]);
1228
+ return { value: null };
1229
+ }
1230
+ case "append": {
1231
+ d[string(a[0]).toLowerCase()] = string(a[1]);
1232
+ return { value: null };
1233
+ }
1234
+ case "delete": {
1235
+ delete d[string(a[0]).toLowerCase()];
1236
+ return { value: null };
1237
+ }
1238
+ default: return null;
1239
+ }
1240
+ }
1241
+ if (d["__formData"] !== undefined) {
1242
+ const entries = Array.isArray(d["entries"]) ? d["entries"] : [];
1243
+ switch (m) {
1244
+ case "append":
1245
+ case "set": {
1246
+ const k = string(a[0]);
1247
+ const rest = m === "set" ? entries.filter((e) => string(e[0]) !== k) : entries;
1248
+ d["entries"] = [...rest, [k, a[1]]];
1249
+ return { value: null };
1250
+ }
1251
+ case "get": {
1252
+ const hit = entries.find((e) => string(e[0]) === string(a[0]));
1253
+ return { value: hit ? hit[1] : null };
1254
+ }
1255
+ case "has": return { value: entries.some((e) => string(e[0]) === string(a[0])) };
1256
+ case "delete": {
1257
+ d["entries"] = entries.filter((e) => string(e[0]) !== string(a[0]));
1258
+ return { value: null };
1259
+ }
1260
+ default: return null;
1261
+ }
1262
+ }
1263
+ if (d["__abortController"] !== undefined && m === "abort") {
1264
+ const sig = d["signal"];
1265
+ if (isDict(sig))
1266
+ sig["aborted"] = true;
1267
+ return { value: null };
1268
+ }
1269
+ // THE ACTIVE LOCALE is the default, not the device's. `Intl.NumberFormat()` with no tag
1270
+ // read `navigator.language`, so a computed formatting a coin price ignored the in-app
1271
+ // language switch that every string on the same screen obeyed. `intlLocale` reads the
1272
+ // one locale fact (DSXStrings.activeLocale - `global.locale` over the device), and it
1273
+ // reads it THROUGH THE TRACKED DOOR, so a computed that formats a number re-runs when
1274
+ // the locale flips. An explicitly passed tag still wins.
1275
+ if (d["__intlNumber"] !== undefined && m === "format") {
1276
+ const opts = d["__intlNumber"];
1277
+ try {
1278
+ return { value: new Intl.NumberFormat(intlLocale(d["locale"]), opts).format(number(a[0]) ?? 0) };
1279
+ }
1280
+ catch {
1281
+ return { value: string(a[0]) };
1282
+ }
1283
+ }
1284
+ if (d["__intlDate"] !== undefined && m === "format") {
1285
+ const opts = d["__intlDate"];
1286
+ const arg = a[0];
1287
+ const ms = isDict(arg) && isDateShape(arg) ? arg["__date"] : number(arg) ?? Date.now();
1288
+ try {
1289
+ return { value: new Intl.DateTimeFormat(intlLocale(d["locale"]), opts).format(new Date(ms)) };
1290
+ }
1291
+ catch {
1292
+ return { value: toISO(ms) };
1293
+ }
1294
+ }
1295
+ if (d["__intlRelative"] !== undefined && m === "format") {
1296
+ const opts = d["__intlRelative"];
1297
+ try {
1298
+ return { value: new Intl.RelativeTimeFormat(intlLocale(d["locale"]), opts).format(number(a[0]) ?? 0, string(a[1])) };
1299
+ }
1300
+ catch {
1301
+ return { value: string(a[0]) + " " + string(a[1]) };
1302
+ }
1303
+ }
1304
+ return null;
1305
+ },
1306
+ /** `'' + date` / `{{ url }}` string coercion for the core shapes. null = no coercion. */
1307
+ stringCoerce(d) {
1308
+ if (isDateShape(d))
1309
+ return toISO(d["__date"]);
1310
+ if (d["__url"] !== undefined)
1311
+ return string(d["href"]);
1312
+ if (d["__params"] !== undefined)
1313
+ return paramsToString(paramsPairs(d));
1314
+ if (d["__error"] !== undefined)
1315
+ return string(d["name"] ?? "Error") + ": " + string(d["message"]); // native-twin coercion
1316
+ return null;
1317
+ },
1318
+ };
1319
+ /** The folded twin. It still serves the two shapes this layer does NOT mint — a regex
1320
+ * literal's `.test()` and the error system's `{__error}` coercion — so the behavior an
1321
+ * embed can actually reach is identical with the layer gone. Everything else answers
1322
+ * "not mine", exactly as it does today for a name JSECore never handled. */
1323
+ const JSE_CORE_ABSENT = {
1324
+ handles: () => false,
1325
+ call: () => null,
1326
+ constant: () => null,
1327
+ method(m, base, a) {
1328
+ if (!isDict(base))
1329
+ return null;
1330
+ const d = base;
1331
+ if (d["__regex"] !== undefined && d["__regex"] !== null && m === "test") {
1332
+ return { value: regexTest(string(a[0]), d) };
1333
+ }
1334
+ // `re.exec(s)`: the first match as a match array, an unmatched group null (logic parity,
1335
+ // JSE-VS-JS item 9; corpus jse/regex-exec-001.json). It answered null for every input. A
1336
+ // JSE regex holds no lastIndex, so a /g pattern answers its first match too.
1337
+ if (d["__regex"] !== undefined && d["__regex"] !== null && m === "exec") {
1338
+ return { value: regexExec(string(a[0]), d) };
1339
+ }
1340
+ return null;
1341
+ },
1342
+ stringCoerce(d) {
1343
+ if (d["__error"] !== undefined)
1344
+ return string(d["name"] ?? "Error") + ": " + string(d["message"]);
1345
+ return null;
1346
+ },
1347
+ };
1348
+ export const JSECore = globalThis
1349
+ .__DSX_OPTIONAL_JS_GLOBALS__ !== false ? JSE_CORE_FULL : JSE_CORE_ABSENT;
1350
+ function regexTest(s, d) {
1351
+ try {
1352
+ let flags = "";
1353
+ const f = string(d["flags"]);
1354
+ if (f.includes("i"))
1355
+ flags += "i";
1356
+ if (f.includes("m"))
1357
+ flags += "m";
1358
+ if (f.includes("s"))
1359
+ flags += "s";
1360
+ if (f.includes("u"))
1361
+ flags += "u"; // Unicode case folding under i (corpus jse/regex-case-fold-001.json)
1362
+ return new RegExp(string(d["source"]), flags).test(s);
1363
+ }
1364
+ catch {
1365
+ return false;
1366
+ }
1367
+ }
1368
+ function regexExec(s, d) {
1369
+ try {
1370
+ let flags = "";
1371
+ const f = string(d["flags"]);
1372
+ if (f.includes("i"))
1373
+ flags += "i";
1374
+ if (f.includes("m"))
1375
+ flags += "m";
1376
+ if (f.includes("s"))
1377
+ flags += "s";
1378
+ if (f.includes("u"))
1379
+ flags += "u"; // Unicode case folding under i (corpus jse/regex-case-fold-001.json)
1380
+ const m = new RegExp(string(d["source"]), flags).exec(s);
1381
+ return m === null ? null : matchArray(m);
1382
+ }
1383
+ catch {
1384
+ return null;
1385
+ }
1386
+ }
1387
+ function coreMath(fn, a) {
1388
+ // ToNumber, as JavaScript's Math reads its arguments: null is 0, a numeric text its number
1389
+ // (logic parity sweep 5, corpus jse/members-003.json: `Math.min(null, 1)` was NaN).
1390
+ const nums = a.map((x) => numberJS(x) ?? NaN);
1391
+ const n = (i) => (i < nums.length ? nums[i] : NaN);
1392
+ switch (fn) {
1393
+ case "floor": return Math.floor(n(0));
1394
+ case "ceil": return Math.ceil(n(0));
1395
+ case "round": return Math.round(n(0)); // the platform's own: nearest, a tie toward +infinity (math-round-001)
1396
+ case "trunc": {
1397
+ const x = n(0);
1398
+ return Number.isNaN(x) ? x : Math.trunc(x);
1399
+ }
1400
+ case "abs": return Math.abs(n(0));
1401
+ case "sign": {
1402
+ const x = n(0);
1403
+ return x === 0 ? 0 : x > 0 ? 1 : -1;
1404
+ }
1405
+ case "min": return nums.length === 0 ? Infinity : nums.reduce((m, x) => (x < m ? x : m));
1406
+ case "max": return nums.length === 0 ? -Infinity : nums.reduce((m, x) => (m < x ? x : m));
1407
+ case "pow": return Math.pow(n(0), n(1));
1408
+ case "sqrt": return n(0) < 0 ? NaN : Math.sqrt(n(0));
1409
+ case "cbrt": return Math.cbrt(n(0));
1410
+ case "hypot": return Math.hypot(n(0), n(1));
1411
+ case "random": return Math.random();
1412
+ case "log": return Math.log(n(0));
1413
+ case "log2": return Math.log2(n(0));
1414
+ case "log10": return Math.log10(n(0));
1415
+ case "exp": return Math.exp(n(0));
1416
+ case "sin": return Math.sin(n(0));
1417
+ case "cos": return Math.cos(n(0));
1418
+ case "tan": return Math.tan(n(0));
1419
+ case "atan2": return Math.atan2(n(0), n(1));
1420
+ case "atan": return Math.atan(n(0));
1421
+ case "asin": return Math.asin(n(0));
1422
+ case "acos": return Math.acos(n(0));
1423
+ case "sinh": return Math.sinh(n(0));
1424
+ case "cosh": return Math.cosh(n(0));
1425
+ case "tanh": return Math.tanh(n(0));
1426
+ case "asinh": return Math.asinh(n(0));
1427
+ case "acosh": return Math.acosh(n(0));
1428
+ case "atanh": return Math.atanh(n(0));
1429
+ case "log1p": return Math.log1p(n(0));
1430
+ case "expm1": return Math.expm1(n(0));
1431
+ case "fround": return Math.fround(n(0));
1432
+ case "clz32": return Math.clz32(n(0));
1433
+ case "imul": return Math.imul(n(0), n(1));
1434
+ default: return null;
1435
+ }
1436
+ }
1437
+ function localeArg(v) {
1438
+ const s = string(v);
1439
+ return s.length > 0 ? s : undefined;
1440
+ }
1441
+ function intlOpts(v) {
1442
+ return isDict(v) ? v : undefined;
1443
+ }
1444
+ function intlCall(name, a) {
1445
+ const locale = string(a[0]);
1446
+ const opts = isDict(a[1]) ? a[1] : {};
1447
+ switch (name) {
1448
+ case "NumberFormat": return { __intlNumber: opts, locale };
1449
+ case "DateTimeFormat": return { __intlDate: opts, locale };
1450
+ case "RelativeTimeFormat": return { __intlRelative: opts, locale };
1451
+ default: return null;
1452
+ }
1453
+ }
1454
+ function promiseCall(name, a) {
1455
+ const items = Array.isArray(a[0]) ? a[0] : [];
1456
+ const asPromise = (v) => (v instanceof Promise ? v : Promise.resolve(v));
1457
+ switch (name) {
1458
+ case "all": return Promise.all(items.map(asPromise));
1459
+ case "allSettled":
1460
+ return Promise.allSettled(items.map(asPromise)).then((rs) => rs.map((r) => (r.status === "fulfilled" ? { status: "fulfilled", value: r.value } : { status: "rejected", reason: string(r.reason) })));
1461
+ case "race": return Promise.race(items.map(asPromise));
1462
+ case "any": return Promise.any(items.map(asPromise)).catch(() => null);
1463
+ case "resolve": return Promise.resolve(a[0]);
1464
+ default: return null;
1465
+ }
1466
+ }
1467
+ function structuredCloneValue(v) {
1468
+ if (Array.isArray(v))
1469
+ return v.map(structuredCloneValue);
1470
+ if (isDict(v)) {
1471
+ const out = {};
1472
+ for (const [k, val] of Object.entries(v))
1473
+ out[k] = structuredCloneValue(val);
1474
+ return out;
1475
+ }
1476
+ return v;
1477
+ }
1478
+ // wire the string-coercion hook (values.ts ⇄ core.ts cycle-breaker)
1479
+ setStringCoerce((d) => JSECore.stringCoerce(d));
1480
+ /** `Number.prototype.toLocaleString(locale, options)`: JavaScript defines it as
1481
+ * `new Intl.NumberFormat(locale, options).format(n)`, and so does JSE now (logic parity,
1482
+ * JSE-VS-JS item 1; corpus jse/number-locale-001.json). It
1483
+ * ignored both arguments and grouped the JSE string en-US style. Twins: JSELibrary.swift
1484
+ * `numberToLocaleString`, Globals.kt `numberToLocaleString`. */
1485
+ export function numberToLocaleString(n, locale, options) {
1486
+ try {
1487
+ return new Intl.NumberFormat(intlLocale(locale), intlOpts(options)).format(n);
1488
+ }
1489
+ catch {
1490
+ return string(n);
1491
+ }
1492
+ }
1493
+ /** A GLOBAL FUNCTION AS A VALUE (logic parity, JSE-VS-JS item 6; corpus
1494
+ * jse/builtin-values-001.json): `[1, 2].map(String)`, `rows.filter(Boolean)` and
1495
+ * `['1', '2'].map(parseInt)` pass the global itself, and a higher-order call hands it the
1496
+ * arguments JavaScript does. The bare name read null. Twins: Jse.kt / JSE.swift
1497
+ * `builtinFunctionValue`. */
1498
+ export const BUILTIN_FUNCTION_VALUES = new Set([
1499
+ "String", "Number", "Boolean", "parseInt", "parseFloat", "isNaN", "isFinite",
1500
+ "encodeURIComponent", "decodeURIComponent", "encodeURI", "decodeURI",
1501
+ ]);
1502
+ function builtinFunctionValue(name) {
1503
+ if (!BUILTIN_FUNCTION_VALUES.has(name))
1504
+ return null;
1505
+ return { __lambda: true, params: [], body: [], block: false, captured: {},
1506
+ native: (args) => JSECore.call(name, args) };
1507
+ }
1508
+ /** The tag an `Intl.*` object formats in: an explicitly passed one, else the app's ACTIVE
1509
+ * locale (`global.locale` over the device — DSXStrings), else the platform default. The
1510
+ * tag arrives through the values.ts seam rather than a direct import, because the module
1511
+ * graph runs strings → store → … → jse → core and a direct edge back closes the cycle. */
1512
+ function intlLocale(passed) {
1513
+ const explicit = string(passed);
1514
+ if (explicit.length > 0)
1515
+ return explicit;
1516
+ const active = activeLocaleTag();
1517
+ return active.length > 0 ? active : undefined;
1518
+ }
1519
+ //# sourceMappingURL=core.js.map