@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,982 @@
1
+ //
2
+ // tokens.ts - the JSE tokenizer. TS twin of JSE.swift / Jse.kt `tokenize` — same token
3
+ // kinds, same regex-literal heuristic, same dotted-ident rule (a.b.c is ONE token).
4
+ //
5
+ // Syntax wave 1 (OpenSource/Conformance/jse/syntax-001.json): every tokenize entry runs
6
+ // the shared source PREPROCESSOR first — comments stripped (`// …` to EOL, `/* … */` to
7
+ // one space; regex literals and `://` protocol slashes are never comments), then the ASI
8
+ // pass (a statement-boundary newline becomes `;` — the jsLeaf continuation heuristic,
9
+ // so `x = 1\ny = 2` splits but `1 +\n2` and any line BEGINNING with a binary operator
10
+ // (`+ - * / % . ? : ?? && ||`) join, as JavaScript reads them). String
11
+ // literals carry the JS escape grammar; `` ` `` templates lex as one token with tokenized
12
+ // `${ }` holes; numeric literals take exponents, 0x/0b/0o radix forms and `_` separators.
13
+ //
14
+ import { swiftDouble } from "./values.js";
15
+ /** Check complete input before evaluation; literals and comments are already tokenized. */
16
+ export function delimiterError(tokens) {
17
+ const stack = [];
18
+ const pairs = { ")": "(", "]": "[", "}": "{" };
19
+ for (const token of tokens) {
20
+ if (token.kind === "template") {
21
+ for (const part of token.parts)
22
+ if ("toks" in part) {
23
+ const error = delimiterError(part.toks);
24
+ if (error !== null)
25
+ return error;
26
+ }
27
+ }
28
+ else if (token.kind === "op") {
29
+ if (["(", "[", "{"].includes(token.v))
30
+ stack.push(token.v);
31
+ else if (pairs[token.v] !== undefined && stack.pop() !== pairs[token.v]) {
32
+ return `unexpected closing '${token.v}'`;
33
+ }
34
+ }
35
+ }
36
+ return stack.length === 0 ? null : `unclosed '${stack.at(-1)}'`;
37
+ }
38
+ const threeCharOps = ["===", "!==", ">>>", "**=", "..."];
39
+ const twoCharOps = [
40
+ "==", "!=", "<=", ">=", "&&", "||", "=>",
41
+ "**", "??", "?.", "<<", ">>", "++", "--", "+=", "-=", "*=", "/=", "%=",
42
+ ];
43
+ function isDigit(c) { return c >= "0" && c <= "9"; }
44
+ function isHexDigit(c) {
45
+ return isDigit(c) || (c >= "a" && c <= "f") || (c >= "A" && c <= "F");
46
+ }
47
+ function isLetter(c) { return /\p{L}/u.test(c); }
48
+ function isWordChar(c) { return isLetter(c) || isDigit(c) || c === "_"; }
49
+ // ── the shared source preprocessor (comments, then ASI) ─────────────────────────────
50
+ // The twins run the SAME two passes inside tokenize (JSE.swift / Jse.kt preprocessSource);
51
+ // the native statement runners additionally run pass 1 at the string level before jsLeaf.
52
+ /** `/` at `i` starts a regex literal — the standard JS lexer heuristic at CHAR level:
53
+ * prefix position = no previous significant char, or an operator char that is not a
54
+ * value terminator (`)`, `]`, quote, word). Mirrors the token-level rule below. */
55
+ function charAllowsRegex(prev) {
56
+ if (prev === null)
57
+ return true;
58
+ if (isWordChar(prev))
59
+ return false;
60
+ return prev !== ")" && prev !== "]" && prev !== "'" && prev !== "\"" && prev !== "`";
61
+ }
62
+ /** Keywords a regex literal may DIRECTLY follow (`return /ab/.test(s)`, `case /a/…`,
63
+ * `typeof /x/`) — shared by the char-level scanners and the token-level rule. */
64
+ const regexKeywords = new Set(["return", "case", "typeof", "in", "of", "do", "else", "throw"]);
65
+ /** Char-level companion to charAllowsRegex: when the previous significant char is a word
66
+ * char, scan the word back in the emitted buffer (bounded) — a keyword still puts the
67
+ * `/` in regex position (`return /ab/`), an ident/number does not (`x / 2`). */
68
+ function regexAfterKeyword(out, end = out.length) {
69
+ let t = end - 1;
70
+ while (t >= 0 && /\s/.test(out[t]))
71
+ t -= 1;
72
+ let w = "";
73
+ while (t >= 0 && isWordChar(out[t]) && w.length <= 8) {
74
+ w = out[t] + w;
75
+ t -= 1;
76
+ }
77
+ if (t >= 0 && isWordChar(out[t]))
78
+ return false; // longer word — not one of ours
79
+ return regexKeywords.has(w);
80
+ }
81
+ /** Scan a regex literal starting at the `/` at `i` (backslash pairs + [class] aware).
82
+ * Returns the index one past the flags, or -1 if unterminated (→ it was division). */
83
+ function scanRegexEnd(c, i) {
84
+ let j = i + 1;
85
+ let inClass = false;
86
+ let closed = false;
87
+ while (j < c.length) {
88
+ const rc = c[j];
89
+ if (rc === "\\" && j + 1 < c.length) {
90
+ j += 2;
91
+ continue;
92
+ }
93
+ if (rc === "[")
94
+ inClass = true;
95
+ if (rc === "]")
96
+ inClass = false;
97
+ if (rc === "/" && !inClass) {
98
+ closed = true;
99
+ j += 1;
100
+ break;
101
+ }
102
+ if (rc === "\n")
103
+ break; // literals don't span lines
104
+ j += 1;
105
+ }
106
+ if (!closed || j === i + 1)
107
+ return -1;
108
+ while (j < c.length && isLetter(c[j]))
109
+ j += 1;
110
+ return j;
111
+ }
112
+ /** Copy a quoted span (`'` / `"`) verbatim, honoring backslash pairs. `i` is at the
113
+ * open quote; returns the index one past the close quote (or end). */
114
+ function copyQuoted(c, i, out) {
115
+ const q = c[i];
116
+ out.push(q);
117
+ let j = i + 1;
118
+ while (j < c.length) {
119
+ const ch = c[j];
120
+ if (ch === "\\" && j + 1 < c.length) {
121
+ out.push(ch, c[j + 1]);
122
+ j += 2;
123
+ continue;
124
+ }
125
+ out.push(ch);
126
+ j += 1;
127
+ if (ch === q)
128
+ break;
129
+ }
130
+ return j;
131
+ }
132
+ /** Copy a template span verbatim (`\`` … `\``), honoring backslash pairs and `${ }`
133
+ * hole depth so a `}` inside a hole and a backtick inside a hole don't close it.
134
+ * Inside a hole, quoted spans delegate to copyQuoted and nested backticks recurse (a
135
+ * `'{'` string literal in a hole must not skew the depth); recursion is depth-capped
136
+ * (past ~32 a backtick copies as a plain char — bounded, never a stack overflow). */
137
+ function copyTemplate(c, i, out, depth = 0) {
138
+ out.push("`");
139
+ let j = i + 1;
140
+ let hole = 0;
141
+ while (j < c.length) {
142
+ const ch = c[j];
143
+ if (ch === "\\" && j + 1 < c.length) {
144
+ out.push(ch, c[j + 1]);
145
+ j += 2;
146
+ continue;
147
+ }
148
+ if (hole === 0 && ch === "`") {
149
+ out.push(ch);
150
+ j += 1;
151
+ break;
152
+ }
153
+ if (hole > 0 && (ch === "'" || ch === "\"")) {
154
+ j = copyQuoted(c, j, out);
155
+ continue;
156
+ }
157
+ if (hole > 0 && ch === "`" && depth < 32) {
158
+ j = copyTemplate(c, j, out, depth + 1);
159
+ continue;
160
+ }
161
+ if (ch === "$" && j + 1 < c.length && c[j + 1] === "{") {
162
+ out.push("$", "{");
163
+ hole += 1;
164
+ j += 2;
165
+ continue;
166
+ }
167
+ if (hole > 0 && ch === "{")
168
+ hole += 1;
169
+ if (hole > 0 && ch === "}")
170
+ hole -= 1;
171
+ out.push(ch);
172
+ j += 1;
173
+ }
174
+ return j;
175
+ }
176
+ /** THE ONE LITERAL SKIPPER, and every char-level scanner in the engine rides it: given the
177
+ * source chars, an index and the previous significant char, it answers the index one PAST
178
+ * the literal or comment that starts at `i`, or -1 when nothing does.
179
+ *
180
+ * It exists because a second scanner counted delimiters without it. `scanFunctions` walked
181
+ * a `<script>` body counting `{` and `}` with no idea what a string is, so ONE brace inside
182
+ * a literal closed the declaration early and every function declared AFTER it was never
183
+ * registered - a call to one answered null, with no error, no log and every static gate
184
+ * green. The repair is not a second lexer: it is this function, which is the same
185
+ * copyQuoted / copyTemplate / scanRegexEnd trio `stripComments` and `decodeOperatorEntities`
186
+ * already agreed on, so a literal means one thing in the engine rather than three.
187
+ *
188
+ * A template is skipped WHOLE, holes included, because `copyTemplate` tracks hole depth and
189
+ * nested literals inside a hole. A `//` after `:` is protocol syntax, never a comment, which
190
+ * is `stripComments`' own rule kept here rather than re-decided. */
191
+ export function skipLiteralOrComment(c, i, prevSig) {
192
+ const ch = c[i];
193
+ if (ch === undefined)
194
+ return -1;
195
+ const sink = [];
196
+ if (ch === "'" || ch === "\"")
197
+ return copyQuoted(c, i, sink);
198
+ if (ch === "`")
199
+ return copyTemplate(c, i, sink);
200
+ if (ch === "/" && c[i + 1] === "/" && prevSig !== ":") {
201
+ let j = i;
202
+ while (j < c.length && c[j] !== "\n")
203
+ j += 1; // the newline itself is the statement break
204
+ return j;
205
+ }
206
+ if (ch === "/" && c[i + 1] === "*") {
207
+ let j = i + 2;
208
+ while (j + 1 < c.length && !(c[j] === "*" && c[j + 1] === "/"))
209
+ j += 1;
210
+ return Math.min(j + 2, c.length);
211
+ }
212
+ // regex-literal lexing rides __DSX_OPTIONAL_REGEX__ exactly as the two passes above do.
213
+ if (globalThis
214
+ .__DSX_OPTIONAL_REGEX__ !== false && ch === "/"
215
+ && (charAllowsRegex(prevSig) || (prevSig !== null && isWordChar(prevSig) && regexAfterKeyword(c, i)))) {
216
+ const end = scanRegexEnd(c, i);
217
+ if (end > 0)
218
+ return end;
219
+ }
220
+ return -1;
221
+ }
222
+ /** Pass 1 — strip JS comments: `// …` to end of line (newline kept — it is the statement
223
+ * break) and `/* … *​/` to ONE space. Quote-, template- and regex-literal-aware, so
224
+ * `replace(/\//g, '-')` and `'https://x'` survive; `://` outside a string is protocol
225
+ * syntax (the fetch-effect URL form), never a comment. */
226
+ export function stripComments(s) {
227
+ if (!s.includes("//") && !s.includes("/*"))
228
+ return s;
229
+ const c = Array.from(s);
230
+ const out = [];
231
+ let i = 0;
232
+ let prevSig = null; // last significant (non-whitespace) char copied
233
+ while (i < c.length) {
234
+ const ch = c[i];
235
+ if (ch === "'" || ch === "\"") {
236
+ i = copyQuoted(c, i, out);
237
+ prevSig = ch;
238
+ continue;
239
+ }
240
+ if (ch === "`") {
241
+ i = copyTemplate(c, i, out);
242
+ prevSig = "`";
243
+ continue;
244
+ }
245
+ if (ch === "/" && i + 1 < c.length && c[i + 1] === "/" && prevSig !== ":") {
246
+ while (i < c.length && c[i] !== "\n")
247
+ i += 1; // drop to EOL (keep the newline)
248
+ continue;
249
+ }
250
+ if (ch === "/" && i + 1 < c.length && c[i + 1] === "*") {
251
+ i += 2;
252
+ while (i + 1 < c.length && !(c[i] === "*" && c[i + 1] === "/"))
253
+ i += 1;
254
+ i = Math.min(i + 2, c.length);
255
+ out.push(" "); // never glue the surrounding tokens
256
+ continue;
257
+ }
258
+ // regex-literal lexing rides __DSX_OPTIONAL_REGEX__ (regex.ts): the detection is
259
+ // slash-SUPERSET, so a folded build's sources carry no `/` at all — the branch
260
+ // (and scanRegexEnd behind it) is unreachable there.
261
+ if (globalThis
262
+ .__DSX_OPTIONAL_REGEX__ !== false
263
+ && ch === "/" && (charAllowsRegex(prevSig) || (prevSig !== null && isWordChar(prevSig) && regexAfterKeyword(out)))) {
264
+ const end = scanRegexEnd(c, i);
265
+ if (end > 0) {
266
+ for (let k = i; k < end; k++)
267
+ out.push(c[k]);
268
+ i = end;
269
+ prevSig = c[end - 1];
270
+ continue;
271
+ }
272
+ }
273
+ out.push(ch);
274
+ if (!/\s/.test(ch))
275
+ prevSig = ch;
276
+ i += 1;
277
+ }
278
+ return out.join("");
279
+ }
280
+ /** Pass 0 — decode the XML OPERATOR entities. A code body arrives RAW from the markup
281
+ * reader on every renderer (code tags are lifted 1:1 — xml.ts, StackNode.liftCode, the
282
+ * Kotlin reader), so an author who spells `&&` as `&amp;&amp;` (attribute muscle memory
283
+ * — the flagship starter did) hands the lexer `& amp ; & amp ;`: bitwise ops over an
284
+ * `amp` identifier that silently evaluate to 0 (the wave-7 F4 "0" write). The three
285
+ * entities with OPERATOR meaning decode here, outside string/template/regex literals
286
+ * only. `&quot;`/`&apos;` stay untouched (decoding them would move literal boundaries)
287
+ * and a bare `&` stays literal — the markup reader's smart-entity rule, mirrored.
288
+ * Corpus: OpenSource/Conformance/jse/syntax-006.json (three runners). */
289
+ export function decodeOperatorEntities(s) {
290
+ if (!s.includes("&amp;") && !s.includes("&lt;") && !s.includes("&gt;"))
291
+ return s;
292
+ const c = Array.from(s);
293
+ const out = [];
294
+ let i = 0;
295
+ let prevSig = null;
296
+ while (i < c.length) {
297
+ const ch = c[i];
298
+ if (ch === "'" || ch === "\"") {
299
+ i = copyQuoted(c, i, out);
300
+ prevSig = ch;
301
+ continue;
302
+ }
303
+ if (ch === "`") {
304
+ i = copyTemplate(c, i, out);
305
+ prevSig = "`";
306
+ continue;
307
+ }
308
+ // COMMENTS ARE COPIED VERBATIM, never read as code. This pass runs BEFORE stripComments, so
309
+ // without these two branches an apostrophe in prose (`// the owner's rule`) opened a quoted
310
+ // span that ran on into the code below it, and every `&amp;&amp;` / `&lt;` / `&gt;` inside
311
+ // that span stayed undecoded: a guard like `a == 'owner' &amp;&amp; b != 'owner'` then lexed as
312
+ // bitwise ops over `amp` and was silently false. Same rules as stripComments (a `//` after
313
+ // `:` is protocol syntax), so the two passes agree on where every comment is.
314
+ if (ch === "/" && i + 1 < c.length && c[i + 1] === "/" && prevSig !== ":") {
315
+ while (i < c.length && c[i] !== "\n") {
316
+ out.push(c[i]);
317
+ i += 1;
318
+ }
319
+ continue;
320
+ }
321
+ if (ch === "/" && i + 1 < c.length && c[i + 1] === "*") {
322
+ let j = i + 2;
323
+ while (j + 1 < c.length && !(c[j] === "*" && c[j + 1] === "/"))
324
+ j += 1;
325
+ const end = Math.min(j + 2, c.length);
326
+ for (let k = i; k < end; k++)
327
+ out.push(c[k]);
328
+ i = end;
329
+ continue;
330
+ }
331
+ if (globalThis
332
+ .__DSX_OPTIONAL_REGEX__ !== false
333
+ && ch === "/" && (charAllowsRegex(prevSig) || (prevSig !== null && isWordChar(prevSig) && regexAfterKeyword(out)))) {
334
+ const end = scanRegexEnd(c, i);
335
+ if (end > 0) {
336
+ for (let k = i; k < end; k++)
337
+ out.push(c[k]);
338
+ i = end;
339
+ prevSig = c[end - 1];
340
+ continue;
341
+ }
342
+ }
343
+ if (ch === "&") {
344
+ const rest = c.slice(i + 1, i + 5).join("");
345
+ const op = rest.startsWith("amp;") ? "&" : rest.startsWith("lt;") ? "<" : rest.startsWith("gt;") ? ">" : null;
346
+ if (op !== null) {
347
+ out.push(op);
348
+ prevSig = op;
349
+ i += op === "&" ? 5 : 4;
350
+ continue;
351
+ }
352
+ }
353
+ out.push(ch);
354
+ if (!/\s/.test(ch))
355
+ prevSig = ch;
356
+ i += 1;
357
+ }
358
+ return out.join("");
359
+ }
360
+ /** The jsLeaf continuation heuristic (the native runners' ASI rule), char-level:
361
+ * a depth-0 newline ends the statement UNLESS the line is clearly unfinished
362
+ * (ends in a binary operator / dot / comma — but not `++`/`--`) or the next line can
363
+ * only be a continuation, which is any line BEGINNING with a binary operator:
364
+ * `+ - * / % . ? : ?? && ||`, as JavaScript reads it.
365
+ *
366
+ * THE HALF THAT WAS MISSING, and what it cost. A leading `.` / `?` / `:` / `&&` / `||` joined;
367
+ * a leading `+` did not, so a string built across two lines with the operator at the START of the
368
+ * second line stopped at the break. No error and no warning: the value was the first line's half.
369
+ * That is the layout every formatter and every style guide produces for a long concatenation, and
370
+ * two refusals of the Despia platform API shipped truncated exactly at the break, losing the half
371
+ * that said what to do about it:
372
+ *
373
+ * seat DSP-2ST2-N4BY-Z3FB is a compose lane seat and com.acme.fitness is ios
374
+ *
375
+ * JavaScript has no ASI before a binary operator (ASI needs an offending token, and an operator
376
+ * that can continue the expression is not one), so joining is the reading every engine gives it
377
+ * and silently taking the prefix was the one answer that should not have been available.
378
+ *
379
+ * `++` and `--` at the start of a line stay SPLIT, because JavaScript splits them too: they are a
380
+ * restricted production, and `x = 1 \n ++y` is two statements in every engine. */
381
+ function lineContinues(out, c, after) {
382
+ let t = out.length - 1;
383
+ while (t >= 0 && (out[t] === " " || out[t] === "\t" || out[t] === "\r"))
384
+ t -= 1;
385
+ if (t >= 0) {
386
+ const last = out[t];
387
+ const isIncDec = (last === "+" || last === "-") && t >= 1 && out[t - 1] === last;
388
+ if (!isIncDec && "+-*/%&|<>=!?:,.".includes(last))
389
+ return true;
390
+ }
391
+ let j = after + 1;
392
+ while (j < c.length && /\s/.test(c[j]))
393
+ j += 1;
394
+ if (j >= c.length)
395
+ return false;
396
+ const ch = c[j];
397
+ if (ch === "." || ch === "?" || ch === ":" || ch === "*" || ch === "/" || ch === "%")
398
+ return true;
399
+ if (ch === "+" || ch === "-")
400
+ return c[j + 1] !== ch; // `++x` / `--x` is a new statement, as in JS
401
+ if ((ch === "&" || ch === "|") && j + 1 < c.length && c[j + 1] === ch)
402
+ return true;
403
+ return false;
404
+ }
405
+ /** Scan the WORD that starts the next line (past whitespace) — bounded. */
406
+ function nextWord(c, after) {
407
+ let j = after + 1;
408
+ while (j < c.length && /\s/.test(c[j]))
409
+ j += 1;
410
+ let w = "";
411
+ while (j < c.length && isWordChar(c[j]) && w.length <= 8) {
412
+ w += c[j];
413
+ j += 1;
414
+ }
415
+ return w;
416
+ }
417
+ /** True when the `{` being pushed opens a `do` block (the word before it is `do`). */
418
+ function braceOpensDo(out) {
419
+ let t = out.length - 1;
420
+ while (t >= 0 && /\s/.test(out[t]))
421
+ t -= 1;
422
+ if (t < 1 || out[t] !== "o" || out[t - 1] !== "d")
423
+ return false;
424
+ return t - 2 < 0 || !isWordChar(out[t - 2]);
425
+ }
426
+ /** The word that ends `out` (past trailing whitespace), and the index it starts at — bounded.
427
+ * A word reached through a `.` is a member name, never a keyword: answers "". */
428
+ function wordBefore(out, end) {
429
+ let t = end - 1;
430
+ while (t >= 0 && /\s/.test(out[t]))
431
+ t -= 1;
432
+ let w = "";
433
+ while (t >= 0 && isWordChar(out[t]) && w.length <= 8) {
434
+ w = out[t] + w;
435
+ t -= 1;
436
+ }
437
+ let u = t;
438
+ while (u >= 0 && /\s/.test(out[u]))
439
+ u -= 1;
440
+ if (u >= 0 && out[u] === ".")
441
+ return ["", t + 1];
442
+ return [w, t + 1];
443
+ }
444
+ /** True when the `(` being pushed opens a control HEAD — `if (…)`, `while (…)`, `for (…)` —
445
+ * whose statement continues past the `)`: the body may start on the next line, so the newline
446
+ * after that `)` is never a boundary. The `while` of a `do { } while (…)` is not a head (it
447
+ * ends the statement); `doCloseAt` is where the last do-closing `}` was written. */
448
+ function parenOpensHead(out, doCloseAt) {
449
+ const [w, start] = wordBefore(out, out.length);
450
+ if (w !== "if" && w !== "while" && w !== "for")
451
+ return false;
452
+ if (w !== "while")
453
+ return true;
454
+ let t = start - 1;
455
+ while (t >= 0 && /\s/.test(out[t]))
456
+ t -= 1;
457
+ return !(t >= 0 && t === doCloseAt);
458
+ }
459
+ /** A newline here must NOT become `;` because the next line's keyword ATTACHES to the
460
+ * just-closed `{ }` block: `}` + `else`/`catch`/`finally` (an if/try branch), and `}` +
461
+ * `while` when that brace closed a `do` block. Braceless branches keep the `;` — there
462
+ * the separator is load-bearing (the statement capture stops at it). */
463
+ function keywordJoinsBlock(c, after, prevSig, closedDo) {
464
+ if (prevSig !== "}")
465
+ return false;
466
+ const w = nextWord(c, after);
467
+ if (w === "else" || w === "catch" || w === "finally")
468
+ return true;
469
+ return w === "while" && closedDo;
470
+ }
471
+ /** A newline here must NOT become `;` because no statement is open or the one that is has
472
+ * not reached its body, exactly as in JavaScript, where ASI only ever ends an unfinished
473
+ * statement: after a `;` the statement already ended (a second `;` is an empty statement,
474
+ * and before `else` it detaches the else from its `if`); after the `)` of an if/while/for
475
+ * head, or after a bare `else`/`do`, the body is on the next line. */
476
+ function statementOpen(out, prevSig, closedHead) {
477
+ if (prevSig === ";" || closedHead)
478
+ return true;
479
+ if (prevSig !== "e" && prevSig !== "o")
480
+ return false;
481
+ const [w] = wordBefore(out, out.length);
482
+ return w === "else" || w === "do";
483
+ }
484
+ /** Pass 2 — ASI: replace each statement-boundary newline with `;`. A newline is a
485
+ * boundary only where a statement can end: at bracket-stack depth zero or directly
486
+ * inside a `{ }` body (never inside `( )` / `[ ]`, where newlines stay soft), and only
487
+ * when the continuation heuristic says the statement is complete. Never before a line
488
+ * whose `else`/`while`/`catch`/`finally` attaches to the `}` block just closed. */
489
+ export function asiSemicolons(s) {
490
+ if (!s.includes("\n"))
491
+ return s;
492
+ const c = Array.from(s);
493
+ const out = [];
494
+ const stack = []; // "(" / "[" / "{" / "D" (a `{` opened by `do`) / "H" (a control head's `(`)
495
+ let i = 0;
496
+ let prevSig = null;
497
+ let justClosedDo = false; // the last significant char was a `}` closing a do-block
498
+ let justClosedHead = false; // the last significant char was the `)` of an if/while/for head
499
+ let doCloseAt = -1; // where the last do-closing `}` was written
500
+ while (i < c.length) {
501
+ const ch = c[i];
502
+ if (ch === "'" || ch === "\"") {
503
+ i = copyQuoted(c, i, out);
504
+ prevSig = ch;
505
+ justClosedDo = false;
506
+ justClosedHead = false;
507
+ continue;
508
+ }
509
+ if (ch === "`") {
510
+ i = copyTemplate(c, i, out);
511
+ prevSig = "`";
512
+ justClosedDo = false;
513
+ justClosedHead = false;
514
+ continue;
515
+ }
516
+ if (globalThis
517
+ .__DSX_OPTIONAL_REGEX__ !== false
518
+ && ch === "/" && (charAllowsRegex(prevSig) || (prevSig !== null && isWordChar(prevSig) && regexAfterKeyword(out)))) {
519
+ const end = scanRegexEnd(c, i);
520
+ if (end > 0) {
521
+ for (let k = i; k < end; k++)
522
+ out.push(c[k]);
523
+ prevSig = c[end - 1];
524
+ justClosedDo = false;
525
+ justClosedHead = false;
526
+ i = end;
527
+ continue;
528
+ }
529
+ }
530
+ let closesDo = false;
531
+ let closesHead = false;
532
+ if (ch === "{")
533
+ stack.push(braceOpensDo(out) ? "D" : ch);
534
+ // The two control rules only matter where a control word can stand: `if`/`else`
535
+ // (__DSX_OPTIONAL_IF_STATEMENTS__) or `while`/`for`/`do` (__DSX_OPTIONAL_BLOCK_ITERATION__).
536
+ // Read inline so an embed slice that folds both drops parenOpensHead/statementOpen (G10).
537
+ else if (ch === "(")
538
+ stack.push((globalThis.__DSX_OPTIONAL_IF_STATEMENTS__ !== false
539
+ || globalThis.__DSX_OPTIONAL_BLOCK_ITERATION__ !== false)
540
+ && parenOpensHead(out, doCloseAt) ? "H" : ch);
541
+ else if (ch === "[")
542
+ stack.push(ch);
543
+ else if (ch === ")" || ch === "]" || ch === "}") {
544
+ const p = stack.pop();
545
+ closesDo = ch === "}" && p === "D";
546
+ closesHead = ch === ")" && p === "H";
547
+ if (closesDo)
548
+ doCloseAt = out.length;
549
+ }
550
+ else if (ch === "\n") {
551
+ const innermost = stack.length > 0 ? stack[stack.length - 1] : null;
552
+ if ((innermost === null || innermost === "{" || innermost === "D") && !lineContinues(out, c, i) &&
553
+ !keywordJoinsBlock(c, i, prevSig, justClosedDo)
554
+ && !((globalThis.__DSX_OPTIONAL_IF_STATEMENTS__ !== false
555
+ || globalThis.__DSX_OPTIONAL_BLOCK_ITERATION__ !== false)
556
+ && statementOpen(out, prevSig, justClosedHead))) {
557
+ out.push(";");
558
+ prevSig = ";";
559
+ justClosedDo = false;
560
+ justClosedHead = false;
561
+ i += 1;
562
+ continue;
563
+ }
564
+ }
565
+ out.push(ch);
566
+ if (!/\s/.test(ch)) {
567
+ prevSig = ch;
568
+ justClosedDo = closesDo;
569
+ justClosedHead = closesHead;
570
+ }
571
+ i += 1;
572
+ }
573
+ return out.join("");
574
+ }
575
+ /** The shared entry: lone `\r` line endings normalized, operator entities decoded,
576
+ * comments out, then statement-boundary newlines to `;`. */
577
+ export function preprocessSource(s) {
578
+ const normalized = s.includes("\r") ? s.replace(/\r(?!\n)/g, "\n") : s;
579
+ return asiSemicolons(stripComments(decodeOperatorEntities(normalized)));
580
+ }
581
+ // ── string-literal escapes (the JS set; unknown escape = the char itself) ───────────
582
+ function unescapeInto(str, c, j) {
583
+ // `c[j]` is the char AFTER the backslash; returns the next index to resume at.
584
+ const e = c[j];
585
+ switch (e) {
586
+ case "n":
587
+ str.push("\n");
588
+ return j + 1;
589
+ case "t":
590
+ str.push("\t");
591
+ return j + 1;
592
+ case "r":
593
+ str.push("\r");
594
+ return j + 1;
595
+ case "b":
596
+ str.push("\b");
597
+ return j + 1;
598
+ case "f":
599
+ str.push("\f");
600
+ return j + 1;
601
+ case "v":
602
+ str.push("\v");
603
+ return j + 1;
604
+ case "0":
605
+ str.push("\0");
606
+ return j + 1;
607
+ case "\n": return j + 1; // line continuation
608
+ case "x": {
609
+ if (j + 2 < c.length && isHexDigit(c[j + 1]) && isHexDigit(c[j + 2])) {
610
+ str.push(String.fromCharCode(parseInt(c[j + 1] + c[j + 2], 16)));
611
+ return j + 3;
612
+ }
613
+ str.push(e);
614
+ return j + 1;
615
+ }
616
+ case "u": {
617
+ if (j + 1 < c.length && c[j + 1] === "{") {
618
+ let k = j + 2;
619
+ let hex = "";
620
+ while (k < c.length && isHexDigit(c[k])) {
621
+ hex += c[k];
622
+ k += 1;
623
+ }
624
+ if (k < c.length && c[k] === "}" && hex.length >= 1 && hex.length <= 6) {
625
+ const cp = parseInt(hex, 16);
626
+ if (cp <= 0x10ffff) {
627
+ str.push(String.fromCodePoint(cp));
628
+ return k + 1;
629
+ }
630
+ }
631
+ str.push(e);
632
+ return j + 1;
633
+ }
634
+ if (j + 4 < c.length && isHexDigit(c[j + 1]) && isHexDigit(c[j + 2]) &&
635
+ isHexDigit(c[j + 3]) && isHexDigit(c[j + 4])) {
636
+ str.push(String.fromCharCode(parseInt(c.slice(j + 1, j + 5).join(""), 16)));
637
+ return j + 5;
638
+ }
639
+ str.push(e);
640
+ return j + 1;
641
+ }
642
+ default:
643
+ str.push(e);
644
+ return j + 1; // \' \" \` \\ \/ and every unknown → the char
645
+ }
646
+ }
647
+ // ── numeric literals ─────────────────────────────────────────────────────────────────
648
+ /** Scan a numeric literal at `i` (a digit, or `.` + digit). Underscore separators are
649
+ * consumed only BETWEEN digits of the active alphabet. Returns [value, nextIndex]. */
650
+ function scanNumber(c, i) {
651
+ const radix = (pfx, digit, base) => {
652
+ if (!(c[i] === "0" && i + 1 < c.length && (c[i + 1] === pfx || c[i + 1] === pfx.toUpperCase())))
653
+ return null;
654
+ let j = i + 2;
655
+ let any = false;
656
+ let v = 0;
657
+ while (j < c.length) {
658
+ const ch = c[j];
659
+ if (digit(ch)) {
660
+ v = v * base + parseInt(ch, base);
661
+ any = true;
662
+ j += 1;
663
+ continue;
664
+ }
665
+ if (ch === "_" && any && j + 1 < c.length && digit(c[j + 1])) {
666
+ j += 1;
667
+ continue;
668
+ }
669
+ break;
670
+ }
671
+ if (!any)
672
+ return null; // bare `0x` → the plain 0, `x…` lexes on
673
+ return [v, j];
674
+ };
675
+ const hex = radix("x", isHexDigit, 16);
676
+ if (hex)
677
+ return hex;
678
+ const bin = radix("b", (ch) => ch === "0" || ch === "1", 2);
679
+ if (bin)
680
+ return bin;
681
+ const oct = radix("o", (ch) => ch >= "0" && ch <= "7", 8);
682
+ if (oct)
683
+ return oct;
684
+ // decimal: digits [. digits] [ (e|E) [+-] digits ] with `_` between digits
685
+ let j = i;
686
+ let n = "";
687
+ let seenDot = false;
688
+ while (j < c.length) {
689
+ const ch = c[j];
690
+ if (isDigit(ch)) {
691
+ n += ch;
692
+ j += 1;
693
+ continue;
694
+ }
695
+ if (ch === "." && !seenDot && j + 1 < c.length && isDigit(c[j + 1])) {
696
+ seenDot = true;
697
+ n += ch;
698
+ j += 1;
699
+ continue;
700
+ }
701
+ if (ch === "." && !seenDot && n.length > 0) {
702
+ seenDot = true;
703
+ n += ch;
704
+ j += 1;
705
+ continue;
706
+ } // trailing `1.`
707
+ if (ch === "_" && n.length > 0 && isDigit(c[j - 1]) && j + 1 < c.length && isDigit(c[j + 1])) {
708
+ j += 1;
709
+ continue;
710
+ }
711
+ break;
712
+ }
713
+ if (j < c.length && (c[j] === "e" || c[j] === "E")) {
714
+ let k = j + 1;
715
+ if (k < c.length && (c[k] === "+" || c[k] === "-"))
716
+ k += 1;
717
+ if (k < c.length && isDigit(c[k])) {
718
+ let exp = c[j];
719
+ let m = j + 1;
720
+ while (m < c.length && (isDigit(c[m]) || ((c[m] === "+" || c[m] === "-") && m === j + 1))) {
721
+ exp += c[m];
722
+ m += 1;
723
+ }
724
+ n += exp;
725
+ j = m;
726
+ }
727
+ }
728
+ return [swiftDouble(n) ?? 0, j];
729
+ }
730
+ /** Where the runner's numeric literal ENDS, measured on a plain string. Exported so a second
731
+ * reader of JSE splits a number exactly where the language does. The highlighter's
732
+ * `endOfNumber` paints a deliberately different span (it never eats a trailing `.`, and it
733
+ * is happy with a bare `0x`), which is right for colouring and wrong for meaning: a reader
734
+ * using it disagrees with the language about where `1.map(f)` and `0x` divide. */
735
+ export function endOfJseNumber(src, at) {
736
+ return scanNumber(src, at)[1];
737
+ }
738
+ // ── the tokenizer ────────────────────────────────────────────────────────────────────
739
+ export function tokenize(s) {
740
+ return tokenizeRaw(preprocessSource(s));
741
+ }
742
+ function tokenizeRaw(s, holeDepth = 0, spans = null) {
743
+ const toks = [];
744
+ const c = Array.from(s); // per-code-point, like the Kotlin CharArray walk on BMP text
745
+ let i = 0;
746
+ // Span bookkeeping for tokenizeSpans: EXACTLY ONE token leaves each turn of this loop (a
747
+ // whitespace turn leaves none), so a turn's token ends where the next turn begins. Recording
748
+ // it here rather than at the nine push sites keeps the walk itself untouched, and with
749
+ // `spans` null it is two comparisons a turn and nothing else.
750
+ let spanFrom = 0;
751
+ let spanned = 0;
752
+ while (i < c.length) {
753
+ if (spans !== null) {
754
+ if (toks.length > spanned) {
755
+ spans.push([spanFrom, i]);
756
+ spanned = toks.length;
757
+ }
758
+ spanFrom = i;
759
+ }
760
+ const ch = c[i];
761
+ if (/\s/.test(ch)) {
762
+ i += 1;
763
+ continue;
764
+ }
765
+ if (ch === "'" || ch === '"') {
766
+ // string literal — the JS escape grammar (unknown escape = the char itself)
767
+ const q = ch;
768
+ i += 1;
769
+ const str = [];
770
+ while (i < c.length && c[i] !== q) {
771
+ if (c[i] === "\\" && i + 1 < c.length) {
772
+ i = unescapeInto(str, c, i + 1);
773
+ continue;
774
+ }
775
+ str.push(c[i]);
776
+ i += 1;
777
+ }
778
+ if (i < c.length)
779
+ i += 1; // closing quote
780
+ toks.push({ kind: "str", v: str.join("") });
781
+ continue;
782
+ }
783
+ if (ch === "`") {
784
+ // template literal — literal parts (escaped) + tokenized `${ }` holes
785
+ i += 1;
786
+ const parts = [];
787
+ let lit = [];
788
+ while (i < c.length && c[i] !== "`") {
789
+ if (c[i] === "\\" && i + 1 < c.length) {
790
+ i = unescapeInto(lit, c, i + 1);
791
+ continue;
792
+ }
793
+ if (c[i] === "$" && i + 1 < c.length && c[i + 1] === "{") {
794
+ if (lit.length > 0) {
795
+ parts.push({ s: lit.join("") });
796
+ lit = [];
797
+ }
798
+ i += 2;
799
+ let depth = 1;
800
+ const src = [];
801
+ while (i < c.length) {
802
+ const hc = c[i];
803
+ if (hc === "'" || hc === "\"") {
804
+ i = copyQuoted(c, i, src);
805
+ continue;
806
+ }
807
+ if (hc === "`") {
808
+ i = copyTemplate(c, i, src);
809
+ continue;
810
+ }
811
+ if (hc === "{")
812
+ depth += 1;
813
+ else if (hc === "}") {
814
+ depth -= 1;
815
+ if (depth === 0) {
816
+ i += 1;
817
+ break;
818
+ }
819
+ }
820
+ src.push(hc);
821
+ i += 1;
822
+ }
823
+ // hole recursion is depth-capped (~32): past it the hole rides as literal
824
+ // text — bounded, never a stack overflow on adversarial nesting
825
+ if (holeDepth < 32)
826
+ parts.push({ toks: tokenizeRaw(src.join(""), holeDepth + 1) });
827
+ else
828
+ parts.push({ s: src.join("") });
829
+ continue;
830
+ }
831
+ lit.push(c[i]);
832
+ i += 1;
833
+ }
834
+ if (i < c.length)
835
+ i += 1; // closing backtick
836
+ if (lit.length > 0)
837
+ parts.push({ s: lit.join("") });
838
+ toks.push({ kind: "template", parts });
839
+ continue;
840
+ }
841
+ if (isDigit(ch) || (ch === "." && i + 1 < c.length && isDigit(c[i + 1]))) {
842
+ const [v, next] = scanNumber(c, i);
843
+ toks.push({ kind: "num", v });
844
+ i = next;
845
+ continue;
846
+ }
847
+ if (isLetter(ch) || ch === "_") {
848
+ // identifier / dotted path (dsx.this, item.index…) — dots stay in the token
849
+ let id = "";
850
+ while (i < c.length && (isLetter(c[i]) || isDigit(c[i]) || c[i] === "_" || c[i] === ".")) {
851
+ id += c[i];
852
+ i += 1;
853
+ }
854
+ toks.push({ kind: "ident", v: id });
855
+ continue;
856
+ }
857
+ if (globalThis
858
+ .__DSX_OPTIONAL_REGEX__ !== false && ch === "/") {
859
+ // Regex literal vs division — the standard JS lexer heuristic: `/` in PREFIX
860
+ // position starts a regex; after a value (or postfix `++`/`--`) it's division.
861
+ // A keyword ident (`return` / `case` / `typeof` / …) is prefix position too.
862
+ // `//` and `/*` never start a regex (they are comments, already stripped).
863
+ const last = toks.length > 0 ? toks[toks.length - 1] : null;
864
+ const prevAllowsRegex = last === null ||
865
+ (last.kind === "op" && last.v !== ")" && last.v !== "]" && last.v !== "++" && last.v !== "--") ||
866
+ (last.kind === "ident" && regexKeywords.has(last.v));
867
+ if (prevAllowsRegex && i + 1 < c.length && c[i + 1] !== "/" && c[i + 1] !== "*") {
868
+ let j = i + 1;
869
+ let pat = "";
870
+ let inClass = false;
871
+ let closed = false;
872
+ while (j < c.length) {
873
+ const rc = c[j];
874
+ if (rc === "\\" && j + 1 < c.length) {
875
+ pat += rc + c[j + 1];
876
+ j += 2;
877
+ continue;
878
+ }
879
+ if (rc === "[")
880
+ inClass = true;
881
+ if (rc === "]")
882
+ inClass = false;
883
+ if (rc === "/" && !inClass) {
884
+ closed = true;
885
+ j += 1;
886
+ break;
887
+ }
888
+ if (rc === "\n")
889
+ break; // literals don't span lines
890
+ pat += rc;
891
+ j += 1;
892
+ }
893
+ if (closed && pat.length > 0) {
894
+ let flags = "";
895
+ while (j < c.length && isLetter(c[j])) {
896
+ flags += c[j];
897
+ j += 1;
898
+ }
899
+ toks.push({ kind: "regex", pattern: pat, flags });
900
+ i = j;
901
+ continue;
902
+ }
903
+ }
904
+ }
905
+ const three = c.slice(i, i + 3).join("");
906
+ if (three.length === 3 && threeCharOps.includes(three)) {
907
+ toks.push({ kind: "op", v: three });
908
+ i += 3;
909
+ continue;
910
+ }
911
+ const two = c.slice(i, i + 2).join("");
912
+ if (two.length === 2 && twoCharOps.includes(two)) {
913
+ // `?.` followed by a digit is a ternary + number (`x ?.5 : y`), the JS lookahead rule
914
+ if (two === "?." && i + 2 < c.length && isDigit(c[i + 2])) {
915
+ toks.push({ kind: "op", v: "?" });
916
+ i += 1;
917
+ continue;
918
+ }
919
+ toks.push({ kind: "op", v: two });
920
+ i += 2;
921
+ continue;
922
+ }
923
+ toks.push({ kind: "op", v: ch }); // single-char op / paren
924
+ i += 1;
925
+ }
926
+ if (spans !== null && toks.length > spanned)
927
+ spans.push([spanFrom, i]);
928
+ return toks;
929
+ }
930
+ /**
931
+ * THE TOKEN STREAM AS DATA, for a reader that ANALYSES JSE source rather than evaluating it.
932
+ *
933
+ * A tool that structures a formula - the logic editor's lift, an outline, a completion, a
934
+ * dependency list - needs the same two things an evaluator does not: where each token began
935
+ * and where it ended, so an unrecognized span can be carried back out as its own exact source
936
+ * text. That need is why every such tool so far grew its own little tokenizer, and a second
937
+ * tokenizer is a second opinion about where a number ends, whether `===` is one token, whether
938
+ * a `/` opened a regex and whether `a.b` is one name. This door removes the reason: the
939
+ * language decides, and the tool reads the answer.
940
+ *
941
+ * `source` is the PREPROCESSED source - comments stripped and the ASI pass applied - because
942
+ * that is the text the tokenizer read and the only text the spans can index. Slice it, not the
943
+ * caller's original: a span is `[start, end)` in UTF-16 code units of `source`, so
944
+ * `source.slice(t.start, t.end)` is exactly the token's own text.
945
+ */
946
+ export function tokenizeSpans(s) {
947
+ const source = preprocessSource(s);
948
+ const spans = [];
949
+ const tokens = tokenizeRaw(source, 0, spans);
950
+ // tokenizeRaw walks CODE POINTS; a caller slices UTF-16. Map one index space onto the other
951
+ // once, here, so a formula containing an astral character cannot hand a tool a span that
952
+ // cuts a surrogate pair in half.
953
+ const cp = Array.from(source);
954
+ const offsets = new Array(cp.length + 1);
955
+ let at = 0;
956
+ for (let k = 0; k < cp.length; k++) {
957
+ offsets[k] = at;
958
+ at += cp[k].length;
959
+ }
960
+ offsets[cp.length] = at;
961
+ return {
962
+ source,
963
+ tokens: tokens.map((token, k) => ({
964
+ token,
965
+ start: offsets[spans[k][0]],
966
+ end: offsets[spans[k][1]],
967
+ })),
968
+ };
969
+ }
970
+ // ── the token pre-parse cache (same key, same bound, same eviction as the twins) ──
971
+ const tokenCache = new Map();
972
+ export function cachedTokens(s) {
973
+ const hit = tokenCache.get(s);
974
+ if (hit)
975
+ return hit;
976
+ const toks = tokenize(s);
977
+ if (tokenCache.size > 512)
978
+ tokenCache.clear();
979
+ tokenCache.set(s, toks);
980
+ return toks;
981
+ }
982
+ //# sourceMappingURL=tokens.js.map