@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,837 @@
1
+ //
2
+ // phase-plan.ts - WHERE EACH STATEMENT OF A PAGE'S LOAD RUNS: on the server before the first byte, or on the client.
3
+ //
4
+ // A page's LOADS are its mount-time logic, in the order the client runs them: each `<watch immediate>`, each
5
+ // `<attribute on:change immediate>`, then the root's `on:appear` (the page-load hook). The author never says where a
6
+ // load runs. This plan derives it from the JSE itself: a statement whose every reach is answerable on the server (the
7
+ // page's server-resolved `<api>` blocks, its own variables, the route, the cookies, a package's declared server read)
8
+ // runs in the server pass and seeds the store; the first statement that reaches anything else (a device call, a timer,
9
+ // `dsx.global`, `dsx.screen`, an unknown name) and everything after it stay the client's.
10
+ //
11
+ // STATIC AND CONSERVATIVE. Tokens only, never an evaluation. Anything this file cannot read with certainty is the
12
+ // client's, which is the page as it ran before the server phase existed. The server enforces the same table at run time
13
+ // (server-phase), so a statement this plan wrongly calls server-safe is refused there and the phase is abandoned.
14
+ //
15
+ // ORDER IS KEPT. The client runs one load after another; once a load is not wholly the server's, every later load is the
16
+ // client's, so no remainder ever runs after a later load the server already ran.
17
+ //
18
+ import { builtinFns } from "./jse/dispatch.js";
19
+ import { preprocessSource, tokenizeSpans } from "./jse/tokens.js";
20
+ /** Every mount-time load of a document, in the client's order, with where each statement runs. */
21
+ export function phasePlan(doc, facts) {
22
+ const loads = [];
23
+ doc.watches.forEach((w, i) => { if (w.immediate === true)
24
+ loads.push(planLoad(`watch:${i}`, w.handler, w.detail === true ? "detail watch" : null, w.value, doc, facts, true)); });
25
+ for (const a of doc.attributes) {
26
+ // the client mounts an attribute watch only for a lowercase attribute name (dom mount.ts)
27
+ if (a.change !== undefined && a.immediate === true && !/[A-Z]/.test(a.as))
28
+ loads.push(planLoad(`attribute:${a.as}`, a.change, null, `dsx.attribute.${a.as}`, doc, facts, true));
29
+ }
30
+ if (doc.appear !== undefined && doc.appear.trim() !== "")
31
+ loads.push(planLoad("appear", doc.appear, null, undefined, doc, facts, false));
32
+ let open = true;
33
+ for (const load of loads) {
34
+ if (!open) {
35
+ demote(load, "an earlier load runs on the client");
36
+ continue;
37
+ }
38
+ if (load.verdict !== "server")
39
+ open = false;
40
+ }
41
+ return { loads };
42
+ }
43
+ function demote(load, reason) {
44
+ load.verdict = "client";
45
+ load.at = 0;
46
+ load.reason = reason;
47
+ for (const s of load.statements)
48
+ s.server = false;
49
+ }
50
+ function planLoad(id, handler, refused, value, doc, facts, payload) {
51
+ const entrySource = entryOf(handler, doc);
52
+ const { source, tokens } = tokenizeSpans(entrySource);
53
+ const base = { id, handler, entry: source, ...(value !== undefined ? { value } : {}), statements: [], verdict: "client", at: 0 };
54
+ if (refused !== null)
55
+ return { ...base, reason: refused };
56
+ const spans = topStatements(tokens);
57
+ if (spans === null)
58
+ return { ...base, reason: "a statement form the plan does not read" };
59
+ const scan = new Scanner(doc, facts, payload, declaredNames(tokens.map((t) => t.token)));
60
+ const statements = spans.map(([from, to]) => {
61
+ const r = scan.range(tokens, from, to);
62
+ return { start: tokens[from].start, end: tokens[to - 1].end, server: r.reason === null, handover: r.reason === null && r.handover };
63
+ });
64
+ const first = statements.findIndex((s) => !s.server);
65
+ const plan = { ...base, statements };
66
+ if (first < 0)
67
+ return { ...plan, verdict: statements.length === 0 ? "client" : "server", at: statements.length, ...(statements.length === 0 ? { reason: "empty" } : {}) };
68
+ const reason = scan.reasonAt(tokens, spans[first]);
69
+ for (let k = first; k < statements.length; k += 1)
70
+ statements[k].server = false;
71
+ if (first === 0)
72
+ return { ...plan, verdict: "client", at: 0, reason };
73
+ // a split hands its top-level locals to the client: only names it can hand over (no destructuring)
74
+ for (let k = 0; k < first; k += 1) {
75
+ if (destructures(tokens, spans[k])) {
76
+ for (const s of statements)
77
+ s.server = false;
78
+ return { ...plan, verdict: "client", at: 0, reason: "a destructured local before the client's statement" };
79
+ }
80
+ }
81
+ return { ...plan, verdict: "split", at: first, reason };
82
+ }
83
+ /** The source a load's statements are counted in: the handler, or, when the handler is exactly one call of a
84
+ * no-input action (`dsx.action.open()`), that action's body, so the split can fall between its statements. */
85
+ function entryOf(handler, doc) {
86
+ const m = /^\s*dsx\.action\.([A-Za-z_$][\w$]*)\s*\(\s*\)\s*;?\s*$/.exec(handler);
87
+ if (m === null)
88
+ return handler;
89
+ const action = doc.actions.find((a) => a.as === m[1]);
90
+ if (action === undefined || Object.keys(action.inputs ?? {}).length > 0)
91
+ return handler;
92
+ return action.body;
93
+ }
94
+ const isOp = (t, v) => t !== undefined && t.kind === "op" && t.v === v;
95
+ const isId = (t, v) => t !== undefined && t.kind === "ident" && t.v === v;
96
+ /** Token ranges [from, to) of the body's top-level statements, or null for a form this plan does not read. */
97
+ export function topStatements(tokens) {
98
+ const t = tokens.map((s) => s.token);
99
+ const out = [];
100
+ let i = 0;
101
+ const balanced = (open, close) => {
102
+ if (!isOp(t[i], open))
103
+ return false;
104
+ let d = 0;
105
+ for (; i < t.length; i += 1) {
106
+ if (isOp(t[i], open))
107
+ d += 1;
108
+ else if (isOp(t[i], close)) {
109
+ d -= 1;
110
+ if (d === 0) {
111
+ i += 1;
112
+ return true;
113
+ }
114
+ }
115
+ }
116
+ return false;
117
+ };
118
+ const simple = () => {
119
+ let d = 0;
120
+ for (; i < t.length; i += 1) {
121
+ const k = t[i];
122
+ if (k.kind === "op" && (k.v === "(" || k.v === "[" || k.v === "{"))
123
+ d += 1;
124
+ else if (k.kind === "op" && (k.v === ")" || k.v === "]" || k.v === "}")) {
125
+ d -= 1;
126
+ if (d < 0)
127
+ return false;
128
+ }
129
+ else if (d === 0 && isOp(k, ";")) {
130
+ i += 1;
131
+ return true;
132
+ }
133
+ }
134
+ return d === 0;
135
+ };
136
+ const body = () => (isOp(t[i], "{") ? balanced("{", "}") : statement());
137
+ const statement = () => {
138
+ const k = t[i];
139
+ if (k === undefined)
140
+ return true;
141
+ if (k.kind === "ident") {
142
+ switch (k.v) {
143
+ case "if": {
144
+ i += 1;
145
+ if (!balanced("(", ")") || !body())
146
+ return false;
147
+ while (isOp(t[i], ";") && isId(t[i + 1], "else"))
148
+ i += 1;
149
+ if (isId(t[i], "else")) {
150
+ i += 1;
151
+ return isId(t[i], "if") ? statement() : body();
152
+ }
153
+ return true;
154
+ }
155
+ case "for":
156
+ case "while":
157
+ case "switch":
158
+ i += 1;
159
+ return balanced("(", ")") && body();
160
+ case "do":
161
+ i += 1;
162
+ if (!body())
163
+ return false;
164
+ while (isOp(t[i], ";"))
165
+ i += 1;
166
+ if (!isId(t[i], "while"))
167
+ return false;
168
+ i += 1;
169
+ return balanced("(", ")");
170
+ case "try":
171
+ i += 1;
172
+ if (!balanced("{", "}"))
173
+ return false;
174
+ while (isOp(t[i], ";") && (isId(t[i + 1], "catch") || isId(t[i + 1], "finally")))
175
+ i += 1;
176
+ if (isId(t[i], "catch")) {
177
+ i += 1;
178
+ if (isOp(t[i], "(") && !balanced("(", ")"))
179
+ return false;
180
+ if (!balanced("{", "}"))
181
+ return false;
182
+ }
183
+ while (isOp(t[i], ";") && isId(t[i + 1], "finally"))
184
+ i += 1;
185
+ if (isId(t[i], "finally")) {
186
+ i += 1;
187
+ if (!balanced("{", "}"))
188
+ return false;
189
+ }
190
+ return true;
191
+ case "function":
192
+ case "class":
193
+ case "else":
194
+ case "catch":
195
+ case "finally":
196
+ case "case":
197
+ case "default":
198
+ return false;
199
+ default:
200
+ // a label (`name:`) is a form the plan does not read
201
+ if (isOp(t[i + 1], ":") && !k.v.includes("."))
202
+ return false;
203
+ return simple();
204
+ }
205
+ }
206
+ if (isOp(k, "{"))
207
+ return balanced("{", "}");
208
+ return simple();
209
+ };
210
+ while (i < t.length) {
211
+ if (isOp(t[i], ";")) {
212
+ i += 1;
213
+ continue;
214
+ }
215
+ const from = i;
216
+ if (!statement())
217
+ return null;
218
+ if (i === from)
219
+ return null;
220
+ let to = i;
221
+ while (to > from && isOp(t[to - 1], ";"))
222
+ to -= 1;
223
+ if (to > from)
224
+ out.push([from, to]);
225
+ }
226
+ return out;
227
+ }
228
+ /** True when the statement declares a top-level local by destructuring (`const { a } = ...`). */
229
+ function destructures(tokens, [from]) {
230
+ const k = tokens[from]?.token;
231
+ const next = tokens[from + 1]?.token;
232
+ return (isId(k, "const") || isId(k, "let") || isId(k, "var")) && (isOp(next, "{") || isOp(next, "["));
233
+ }
234
+ /** Every name the body declares anywhere: `const`/`let`/`var` bindings, arrow and catch parameters, loop bindings. */
235
+ function declaredNames(t) {
236
+ const out = new Set();
237
+ const plain = (k) => k !== undefined && k.kind === "ident" && !k.v.includes(".");
238
+ for (let i = 0; i < t.length; i += 1) {
239
+ const k = t[i];
240
+ if (isId(k, "const") || isId(k, "let") || isId(k, "var")) {
241
+ const n = t[i + 1];
242
+ if (plain(n))
243
+ out.add(n.v);
244
+ else if (isOp(n, "{") || isOp(n, "[")) {
245
+ // the names inside a destructuring pattern
246
+ let d = 0;
247
+ for (let j = i + 1; j < t.length; j += 1) {
248
+ if (isOp(t[j], "{") || isOp(t[j], "["))
249
+ d += 1;
250
+ else if (isOp(t[j], "}") || isOp(t[j], "]")) {
251
+ d -= 1;
252
+ if (d === 0)
253
+ break;
254
+ }
255
+ else if (plain(t[j]) && !isOp(t[j + 1], ":"))
256
+ out.add(t[j].v);
257
+ }
258
+ }
259
+ }
260
+ if (isOp(k, "=>")) {
261
+ const p = t[i - 1];
262
+ if (plain(p))
263
+ out.add(p.v);
264
+ else if (isOp(p, ")")) {
265
+ let d = 0;
266
+ for (let j = i - 1; j >= 0; j -= 1) {
267
+ if (isOp(t[j], ")"))
268
+ d += 1;
269
+ else if (isOp(t[j], "(")) {
270
+ d -= 1;
271
+ if (d === 0)
272
+ break;
273
+ }
274
+ else if (plain(t[j]) && (isOp(t[j + 1], ",") || isOp(t[j + 1], ")") || isOp(t[j + 1], "=")))
275
+ out.add(t[j].v);
276
+ }
277
+ }
278
+ }
279
+ if (isId(k, "catch") && isOp(t[i + 1], "(") && plain(t[i + 2]))
280
+ out.add(t[i + 2].v);
281
+ }
282
+ return out;
283
+ }
284
+ const KEYWORDS = new Set([
285
+ "if", "else", "for", "while", "do", "switch", "case", "default", "break", "continue", "return", "const", "let", "var",
286
+ "of", "in", "typeof", "instanceof", "try", "catch", "finally", "throw", "await", "async", "true", "false", "null",
287
+ "undefined", "void",
288
+ ]);
289
+ /** JS globals the expression tier answers purely (JSECore); `Math.random`, `Date`, `crypto`, `performance` and
290
+ * `console` are deliberately absent. */
291
+ const PURE_GLOBALS = new Set(["Math", "JSON", "Object", "Array", "Number", "String", "Boolean", "parseInt", "parseFloat",
292
+ "isNaN", "isFinite", "encodeURIComponent", "decodeURIComponent", "encodeURI", "decodeURI", "NaN", "Infinity"]);
293
+ const IMPURE_MEMBERS = new Set(["Math.random"]);
294
+ /** Methods that read a value without changing it, the only ones the plan lets a store or local value take. */
295
+ const PURE_METHODS = new Set(["map", "filter", "reduce", "reduceRight", "find", "findIndex", "findLast", "findLastIndex",
296
+ "some", "every", "includes", "indexOf", "lastIndexOf", "slice", "concat", "join", "flat", "flatMap", "at", "keys",
297
+ "values", "entries", "toFixed", "toString", "toUpperCase", "toLowerCase", "trim", "trimStart", "trimEnd", "split",
298
+ "startsWith", "endsWith", "replace", "replaceAll", "padStart", "padEnd", "charAt", "substring", "toLocaleString",
299
+ "localeCompare", "toSorted", "toReversed", "with", "length", "assign", "fromEntries", "stringify", "parse", "isArray",
300
+ "from", "of", "abs", "round", "floor", "ceil", "min", "max", "pow", "sqrt", "trunc", "sign", "log", "exp", "hypot",
301
+ "isInteger", "isFinite", "isNaN", "isSafeInteger", "parseInt", "parseFloat", "fromCharCode", "fromCodePoint"]);
302
+ /** Array mutators: on a local they rebuild the local by copy (never alias the store); on a variable they write it. */
303
+ const MUTATORS = new Set(["push", "pop", "shift", "unshift", "splice", "sort", "reverse", "fill"]);
304
+ const ASSIGN = new Set(["=", "+=", "-=", "*=", "/=", "%=", "**=", "??=", "||=", "&&="]);
305
+ const LIBRARIES = new Set(["format", "decimal", "bytes", "pattern"]);
306
+ const ROUTE_DECISIONS = new Set(["replace", "reset", "push", "notFound"]);
307
+ /** Route calls that only present the page (the route bar): a probe answers them as done. */
308
+ const ROUTE_PRESENTATION = new Set(["chrome"]);
309
+ /** Promise combinators a probe waits through: they only wait for what their arguments already started. */
310
+ const PROBE_COMBINATORS = new Set(["Promise.all", "Promise.allSettled"]);
311
+ /** Constructors a pure helper may call in a probe: none reads the clock, the device or a random source. */
312
+ const PURE_CONSTRUCTORS = new Set(["URL", "URLSearchParams", "Map", "Set", "Error", "RegExp", "Array", "Object"]);
313
+ const READ_ONLY_ROOTS = new Set(["formula", "attribute", "const", "route", "params", "query", "path"]);
314
+ class Scanner {
315
+ seedable;
316
+ actions;
317
+ verdicts = new Map();
318
+ facts;
319
+ payload;
320
+ locals;
321
+ decide;
322
+ constructor(doc, facts, payload, locals, decide = null) {
323
+ this.facts = facts;
324
+ this.payload = payload;
325
+ this.locals = locals;
326
+ this.decide = decide;
327
+ this.seedable = new Set(doc.variables.filter((v) => !v.computed && v.persist === undefined).map((v) => v.as));
328
+ this.actions = new Map(doc.actions.map((a) => [a.as, a.body]));
329
+ }
330
+ /** Why the first reach in [from, to) is not the server's, or null; and whether the range hands over at a read. */
331
+ range(tokens, from, to) {
332
+ const t = tokens.slice(from, to).map((s) => s.token);
333
+ return this.tokens(t, this.locals, 0);
334
+ }
335
+ reasonAt(tokens, [from, to]) {
336
+ return this.range(tokens, from, to).reason ?? "client";
337
+ }
338
+ tokens(t, locals, depth) {
339
+ let handover = false;
340
+ let effectSeen = false;
341
+ let nesting = 0;
342
+ for (let i = 0; i < t.length; i += 1) {
343
+ const k = t[i];
344
+ if (k.kind === "op") {
345
+ if (k.v === "(" || k.v === "[" || k.v === "{")
346
+ nesting += 1;
347
+ else if (k.v === ")" || k.v === "]" || k.v === "}")
348
+ nesting -= 1;
349
+ continue;
350
+ }
351
+ if (k.kind === "template") {
352
+ for (const part of k.parts) {
353
+ if ("toks" in part) {
354
+ const r = this.tokens(part.toks, locals, depth);
355
+ if (r.reason !== null)
356
+ return r;
357
+ }
358
+ }
359
+ continue;
360
+ }
361
+ if (k.kind !== "ident")
362
+ continue;
363
+ // a member after `.` / `?.` belongs to the value in front of it
364
+ if (isOp(t[i - 1], ".") || isOp(t[i - 1], "?.")) {
365
+ if (isOp(t[i + 1], "(") && !PURE_METHODS.has(k.v))
366
+ return { reason: `the method ${k.v}() may change a value`, handover };
367
+ continue;
368
+ }
369
+ // an object literal's key names no value
370
+ if (isOp(t[i + 1], ":") && (isOp(t[i - 1], "{") || isOp(t[i - 1], ",")))
371
+ continue;
372
+ const name = k.v;
373
+ const head = name.split(".")[0];
374
+ const call = isOp(t[i + 1], "(");
375
+ const write = writes(t, i);
376
+ if (KEYWORDS.has(name))
377
+ continue;
378
+ // a decision probe constructs the values a pure helper builds (`new URL(raw)`), never the clock (`new Date()`)
379
+ if (this.decide !== null && name === "new" && t[i + 1]?.kind === "ident" && PURE_CONSTRUCTORS.has(t[i + 1].v)) {
380
+ i += 1;
381
+ continue;
382
+ }
383
+ if (name === "new" || name === "function" || name === "class" || name === "this" || name === "delete" || name === "yield" || name === "eval") {
384
+ return { reason: `${name} is not read by the plan`, handover };
385
+ }
386
+ if (head !== "dsx") {
387
+ if (locals.has(head)) {
388
+ const method = name.slice(name.lastIndexOf(".") + 1);
389
+ if (call && name.includes(".") && !PURE_METHODS.has(method) && !MUTATORS.has(method))
390
+ return { reason: `${name}() may change a value`, handover };
391
+ continue;
392
+ }
393
+ if (IMPURE_MEMBERS.has(name))
394
+ return { reason: `${name} differs between the server and the client`, handover };
395
+ if (PURE_GLOBALS.has(head) || builtinFns.has(name) || (builtinFns.has(head) && !name.includes("."))) {
396
+ if (write)
397
+ return { reason: `a write to ${name}`, handover };
398
+ continue;
399
+ }
400
+ if (this.decide !== null && !write) {
401
+ // the probe's own transport answers a same-origin GET with the reader's cookies, anything else never settles
402
+ if (name === "fetch" && call) {
403
+ effectSeen = true;
404
+ continue;
405
+ }
406
+ // waiting for several reads at once is the reads' own reach (`await Promise.allSettled([dsx.action.a(), ...])`)
407
+ if (call && PROBE_COMBINATORS.has(name))
408
+ continue;
409
+ if (call && !name.includes(".") && this.decide.functions.has(name)) {
410
+ const why = this.functionVerdict(name, depth);
411
+ if (why !== null)
412
+ return { reason: why, handover };
413
+ continue;
414
+ }
415
+ }
416
+ return { reason: `the name ${head} is not known on the server`, handover };
417
+ }
418
+ // `dsx.variable['name']` with a literal name is that variable (the converter's spelling of a set by name)
419
+ const keyed = name === "dsx.variable" && isOp(t[i + 1], "[") && t[i + 2]?.kind === "str" && isOp(t[i + 3], "]")
420
+ ? `dsx.variable.${t[i + 2].v}` : name;
421
+ const verdict = this.dsxReach(keyed, call, write, depth);
422
+ if (verdict.reason !== null)
423
+ return { reason: verdict.reason, handover };
424
+ if (verdict.effect) {
425
+ if (!effectSeen && verdict.read && nesting === 0)
426
+ handover = true;
427
+ effectSeen = true;
428
+ }
429
+ }
430
+ return { reason: null, handover };
431
+ }
432
+ /** One `dsx.` reach: null when the server answers it, with whether it is an effect and whether it is a server read. */
433
+ dsxReach(name, call, write, depth) {
434
+ const ok = (effect = false, read = false) => ({ reason: null, effect, read });
435
+ const no = (reason) => ({ reason, effect: false, read: false });
436
+ const segs = name.split(".");
437
+ const root = segs[1] ?? "";
438
+ switch (root) {
439
+ case "api": {
440
+ const as = segs[2] ?? "";
441
+ if (write || (call && segs.length <= 4))
442
+ return no(`dsx.api.${as} is called or written`);
443
+ if (!this.facts.serverApis.has(as))
444
+ return no(`dsx.api.${as} is not resolved on the server`);
445
+ const field = segs[3];
446
+ if (field !== undefined && !["data", "status", "error", "loading", "refreshing", "fetchedAt"].includes(field))
447
+ return no(`dsx.api.${as}.${field} is not a server field`);
448
+ if (segs.length > 4 && field !== "data" && field !== "error")
449
+ return no(`dsx.api.${as}.${field} is not a server field`);
450
+ if (call && !PURE_METHODS.has(segs[segs.length - 1]))
451
+ return no(`${name}() may change a value`);
452
+ return ok();
453
+ }
454
+ case "variable": {
455
+ const v = segs[2] ?? "";
456
+ const mutates = call && segs.length > 3 && MUTATORS.has(segs[segs.length - 1]);
457
+ if (write || mutates)
458
+ return this.seedable.has(v) ? ok(true) : no(`dsx.variable.${v} is computed, persisted or undeclared`);
459
+ if (call && !PURE_METHODS.has(segs[segs.length - 1]))
460
+ return no(`${name}() may change a value`);
461
+ // a decision reads a variable only when its own value is the server's too (its body reaches nothing the client owns)
462
+ if (this.decide !== null) {
463
+ const why = this.variableVerdict(v, depth);
464
+ if (why !== null)
465
+ return no(why);
466
+ }
467
+ return ok();
468
+ }
469
+ case "cookie":
470
+ if (call)
471
+ return no("dsx.cookie is not callable");
472
+ return ok(write);
473
+ case "this":
474
+ if (!this.payload)
475
+ return no("dsx.this has no server value here");
476
+ if (write || (call && !PURE_METHODS.has(segs[segs.length - 1])))
477
+ return no("dsx.this is written");
478
+ return ok();
479
+ case "event": {
480
+ // the event a load runs for (D59 step 0): its name and data are the server's, bound as the client binds them
481
+ // (server ssr-loads.ts); its elements, a whole read and the emission are the client's
482
+ const member = segs[2] ?? "";
483
+ if (member !== "name" && member !== "data")
484
+ return no(segs.length === 2 ? "dsx.event is an emission or a whole read" : `dsx.event.${member} is the client's`);
485
+ if (write || (call && !PURE_METHODS.has(segs[segs.length - 1])))
486
+ return no("dsx.event is written");
487
+ return ok();
488
+ }
489
+ case "action": {
490
+ const action = segs[2] ?? "";
491
+ if (!call || segs.length !== 3)
492
+ return no(`dsx.action.${action}${segs.length > 3 ? "." + segs.slice(3).join(".") : ""} is not a call`);
493
+ // a probe runs each action's own server prefix (decisionPlan), so the call itself is always the server's
494
+ if (this.decide !== null)
495
+ return this.decide.actions.has(action) ? ok(true) : no(`dsx.action.${action} is not declared`);
496
+ return this.actionVerdict(action, depth);
497
+ }
498
+ case "module": {
499
+ const scheme = (segs[2] ?? "").toLowerCase();
500
+ if (segs[3] === "context" && !call && !write) {
501
+ return this.facts.contexts?.has(scheme) === true ? ok() : no(`dsx.module.${scheme}.context has no server value`);
502
+ }
503
+ if (!call || segs.length !== 4)
504
+ return no(`${name} is not a module call`);
505
+ const action = segs[3];
506
+ if (scheme === "route" && ROUTE_DECISIONS.has(action))
507
+ return ok(true);
508
+ if (this.facts.serverReads.has(`${scheme}.${action}`))
509
+ return ok(true, true);
510
+ // a probe answers the route bar's presentation as done and never settles any other module call (its effect is
511
+ // the client's, and nothing after an awaited one runs)
512
+ if (this.decide !== null && (scheme !== "route" || ROUTE_PRESENTATION.has(action)))
513
+ return ok(true);
514
+ return no(`dsx.module.${scheme}.${action} has no server read`);
515
+ }
516
+ default:
517
+ if (READ_ONLY_ROOTS.has(root)) {
518
+ if (write)
519
+ return no(`dsx.${root} is read-only`);
520
+ if (call && !PURE_METHODS.has(segs[segs.length - 1]))
521
+ return no(`${name}() may change a value`);
522
+ return ok();
523
+ }
524
+ if (LIBRARIES.has(root))
525
+ return write ? no(`a write to dsx.${root}`) : ok();
526
+ return no(`dsx.${root} is the client's`);
527
+ }
528
+ }
529
+ /** Why a script function is not the probe's (null: its body, with its parameters as locals, reaches only the server's). */
530
+ functionVerdict(name, depth) {
531
+ const ctx = this.decide;
532
+ if (ctx.functionVerdicts.has(name))
533
+ return ctx.functionVerdicts.get(name);
534
+ const fn = ctx.functions.get(name);
535
+ if (fn.params === null) {
536
+ ctx.functionVerdicts.set(name, `${name}() has a parameter form the plan does not read`);
537
+ return ctx.functionVerdicts.get(name);
538
+ }
539
+ if (depth > 16)
540
+ return "functions nest too deep";
541
+ // a recursive helper reads as the client's until its body is decided
542
+ ctx.functionVerdicts.set(name, `${name}() calls itself`);
543
+ const tokens = tokenizeSpans(fn.body).tokens.map((x) => x.token);
544
+ const inner = new Scanner(ctx.doc, this.facts, true, new Set([...fn.params, ...declaredNames(tokens)]), ctx);
545
+ const r = inner.tokens(tokens, inner.locals, depth + 1);
546
+ ctx.functionVerdicts.set(name, r.reason);
547
+ return r.reason;
548
+ }
549
+ /** Why a variable's value is not the server's for a probe (null: its body reaches only the server's). */
550
+ variableVerdict(v, depth) {
551
+ const ctx = this.decide;
552
+ if (ctx.variableVerdicts.has(v))
553
+ return ctx.variableVerdicts.get(v);
554
+ const decl = ctx.variables.get(v);
555
+ if (decl === undefined)
556
+ return null;
557
+ if (decl.persist !== undefined) {
558
+ ctx.variableVerdicts.set(v, `dsx.variable.${v} is persisted on the device`);
559
+ return ctx.variableVerdicts.get(v);
560
+ }
561
+ if (depth > 16)
562
+ return "variables nest too deep";
563
+ ctx.variableVerdicts.set(v, `dsx.variable.${v} reads itself`);
564
+ const tokens = tokenizeSpans(decl.body ?? "").tokens.map((x) => x.token);
565
+ const inner = new Scanner(ctx.doc, this.facts, false, new Set(declaredNames(tokens)), ctx);
566
+ const r = inner.tokens(tokens, inner.locals, depth + 1);
567
+ ctx.variableVerdicts.set(v, r.reason);
568
+ return r.reason;
569
+ }
570
+ actionVerdict(action, depth) {
571
+ if (this.verdicts.has(action)) {
572
+ const held = this.verdicts.get(action);
573
+ return { reason: held, effect: true, read: false };
574
+ }
575
+ const body = this.actions.get(action);
576
+ if (body === undefined)
577
+ return { reason: `dsx.action.${action} is not declared`, effect: false, read: false };
578
+ if (depth > 16)
579
+ return { reason: "actions nest too deep", effect: false, read: false };
580
+ // a cycle reads as the client's until the body is decided
581
+ this.verdicts.set(action, `dsx.action.${action} calls itself`);
582
+ const tokens = tokenizeSpans(body).tokens.map((s) => s.token);
583
+ const r = this.tokens(tokens, new Set([...this.locals, ...declaredNames(tokens)]), depth + 1);
584
+ this.verdicts.set(action, r.reason);
585
+ return { reason: r.reason, effect: true, read: false };
586
+ }
587
+ }
588
+ /** Does the reach at `i` write: a postfix chain ending in an assignment, `++`/`--` after it, or `++`/`--` before it. */
589
+ function writes(t, i) {
590
+ if (isOp(t[i - 1], "++") || isOp(t[i - 1], "--"))
591
+ return true;
592
+ let j = i + 1;
593
+ for (;;) {
594
+ const k = t[j];
595
+ if (k === undefined)
596
+ return false;
597
+ if (isOp(k, ".") || isOp(k, "?.")) {
598
+ j += 2;
599
+ continue;
600
+ }
601
+ if (isOp(k, "[") || isOp(k, "(")) {
602
+ const open = isOp(k, "[") ? "[" : "(", close = open === "[" ? "]" : ")";
603
+ let d = 0;
604
+ for (; j < t.length; j += 1) {
605
+ if (isOp(t[j], open))
606
+ d += 1;
607
+ else if (isOp(t[j], close)) {
608
+ d -= 1;
609
+ if (d === 0) {
610
+ j += 1;
611
+ break;
612
+ }
613
+ }
614
+ }
615
+ continue;
616
+ }
617
+ return k.kind === "op" && (ASSIGN.has(k.v) || k.v === "++" || k.v === "--");
618
+ }
619
+ }
620
+ const DECISION_CALL = /\bdsx\.module\.route\.(?:replace|reset|push|notFound)\s*\(/;
621
+ /** The variable names a source reads (`write` false) or writes (`write` true); `*` for a write it cannot name. */
622
+ function variableNames(src, write) {
623
+ const out = new Set();
624
+ const re = /\bdsx\.variable(?:\.([A-Za-z_$][\w$]*)|\s*\[\s*(['"])([^'"]+)\2\s*\]|\s*\[)/g;
625
+ for (const m of src.matchAll(re)) {
626
+ const name = m[1] ?? m[3] ?? "*";
627
+ if (!write) {
628
+ out.add(name);
629
+ continue;
630
+ }
631
+ const rest = src.slice(m.index + m[0].length);
632
+ if (/^(?:\s*(?:\.[A-Za-z_$][\w$]*|\[[^\]]*\]))*\s*(?:[-+*/%&|^?]{0,3}=(?!=)|\+\+|--|\.(?:push|pop|shift|unshift|splice|sort|reverse|fill)\s*\()/.test(rest))
633
+ out.add(name);
634
+ }
635
+ return out;
636
+ }
637
+ /** True when every call of `dsx.action.<name>(` in the source is a statement of its own (its value unused). */
638
+ function statementCallsOnly(src, name) {
639
+ const re = new RegExp(`\\bdsx\\.action\\.${name.replace(/\$/g, "\\$")}\\s*\\(`, "g");
640
+ for (const m of src.matchAll(re)) {
641
+ const before = src.slice(0, m.index).replace(/\s+$/, "");
642
+ if (before !== "" && !/[;{}]$/.test(before))
643
+ return false;
644
+ }
645
+ return true;
646
+ }
647
+ const ACTION_CALL = /\bdsx\.action\.([A-Za-z_$][\w$]*)\s*\(/g;
648
+ /** The function declarations of a script source: name, simple parameter names (null for any other form) and body. */
649
+ export function scriptFunctions(scripts) {
650
+ const out = new Map();
651
+ for (const script of scripts) {
652
+ const { source, tokens } = tokenizeSpans(script);
653
+ for (let i = 0; i + 2 < tokens.length; i += 1) {
654
+ if (!isId(tokens[i].token, "function"))
655
+ continue;
656
+ const nameTok = tokens[i + 1].token;
657
+ if (nameTok.kind !== "ident" || nameTok.v.includes(".") || !isOp(tokens[i + 2].token, "("))
658
+ continue;
659
+ let j = i + 3;
660
+ const params = [];
661
+ let simple = true;
662
+ for (; j < tokens.length && !isOp(tokens[j].token, ")"); j += 1) {
663
+ const k = tokens[j].token;
664
+ if (isOp(k, ","))
665
+ continue;
666
+ if (k.kind === "ident" && !k.v.includes("."))
667
+ params.push(k.v);
668
+ else
669
+ simple = false;
670
+ }
671
+ if (!isOp(tokens[j + 1]?.token, "{"))
672
+ continue;
673
+ let d = 0, end = -1;
674
+ for (let m = j + 1; m < tokens.length; m += 1) {
675
+ if (isOp(tokens[m].token, "{"))
676
+ d += 1;
677
+ else if (isOp(tokens[m].token, "}")) {
678
+ d -= 1;
679
+ if (d === 0) {
680
+ end = m;
681
+ break;
682
+ }
683
+ }
684
+ }
685
+ if (end < 0)
686
+ break;
687
+ out.set(nameTok.v, { params: simple ? params : null, body: source.slice(tokens[j + 1].end, tokens[end].start) });
688
+ i = end;
689
+ }
690
+ }
691
+ return out;
692
+ }
693
+ /** The decision probe's plan for one page component. Static and conservative, like the phase plan. */
694
+ export function decisionPlan(doc, facts) {
695
+ const ctx = {
696
+ doc,
697
+ actions: new Set(doc.actions.map((a) => a.as)),
698
+ functions: scriptFunctions(doc.scripts ?? []),
699
+ variables: new Map(doc.variables.map((v) => [v.as, { ...(v.body !== undefined ? { body: v.body } : {}), ...(v.persist !== undefined ? { persist: v.persist } : {}) }])),
700
+ functionVerdicts: new Map(),
701
+ variableVerdicts: new Map(),
702
+ };
703
+ const prefix = (raw, payload) => {
704
+ const { source, tokens } = tokenizeSpans(raw);
705
+ const spans = topStatements(tokens);
706
+ if (spans === null)
707
+ return { source: "", whole: false, reason: "a statement form the plan does not read" };
708
+ const scan = new Scanner(doc, facts, payload, declaredNames(tokens.map((t) => t.token)), ctx);
709
+ for (const span of spans) {
710
+ const r = scan.range(tokens, span[0], span[1]);
711
+ if (r.reason !== null)
712
+ return { source: source.slice(0, tokens[span[0]].start), whole: false, reason: r.reason };
713
+ }
714
+ return { source, whole: true };
715
+ };
716
+ const actions = new Map();
717
+ for (const a of doc.actions)
718
+ actions.set(a.as, prefix(a.body, true));
719
+ const loads = [];
720
+ doc.watches.forEach((w, i) => { if (w.immediate === true && w.detail !== true)
721
+ loads.push({ id: `watch:${i}`, value: w.value, body: prefix(w.handler, true) }); });
722
+ for (const a of doc.attributes) {
723
+ if (a.change !== undefined && a.immediate === true && !/[A-Z]/.test(a.as))
724
+ loads.push({ id: `attribute:${a.as}`, value: `dsx.attribute.${a.as}`, body: prefix(a.change, true) });
725
+ }
726
+ if (doc.appear !== undefined && doc.appear.trim() !== "")
727
+ loads.push({ id: "appear", body: prefix(doc.appear, false) });
728
+ // the probe runs a body only while every load before it ran whole
729
+ const reachable = [];
730
+ for (const load of loads) {
731
+ reachable.push(load.body.source);
732
+ if (!load.body.whole)
733
+ break;
734
+ }
735
+ // and an action only when a body it runs calls it
736
+ const seen = new Set();
737
+ for (let k = 0; k < reachable.length; k += 1) {
738
+ for (const m of reachable[k].matchAll(ACTION_CALL)) {
739
+ const body = actions.get(m[1]);
740
+ if (body !== undefined && !seen.has(m[1])) {
741
+ seen.add(m[1]);
742
+ reachable.push(body.source);
743
+ }
744
+ }
745
+ }
746
+ // an action the probe cannot run blocks its caller (the client waits for it), unless its outcome cannot reach anything
747
+ // the probe runs: then the probe passes over it, as if it had already finished
748
+ const bodies = new Map(doc.actions.map((a) => [a.as, preprocessSource(a.body)]));
749
+ const read = new Set();
750
+ for (const src of [...reachable, ...doc.variables.map((v) => v.body ?? "")])
751
+ for (const n of variableNames(src, false))
752
+ read.add(n);
753
+ const passable = new Set();
754
+ for (const [name, body] of actions) {
755
+ if (body.whole)
756
+ continue;
757
+ const written = new Set();
758
+ const visit = new Set([name]);
759
+ const queue = [name];
760
+ while (queue.length > 0) {
761
+ const src = bodies.get(queue.pop()) ?? "";
762
+ for (const n of variableNames(src, true))
763
+ written.add(n);
764
+ for (const m of src.matchAll(ACTION_CALL))
765
+ if (!visit.has(m[1])) {
766
+ visit.add(m[1]);
767
+ queue.push(m[1]);
768
+ }
769
+ }
770
+ if ([...written].some((n) => read.has(n)) || written.has("*"))
771
+ continue;
772
+ if (!reachable.every((src) => statementCallsOnly(src, name)))
773
+ continue;
774
+ passable.add(name);
775
+ }
776
+ // A STOPPED BODY'S REST STILL RUNS ON THE CLIENT, before or beside whatever follows its call (JSE async follows
777
+ // JavaScript: an unawaited call runs to its first await while the caller carries on). When that rest may write a
778
+ // variable the probe reads, or its value is used, a decision taken after the stop could differ from the client's.
779
+ const writesOf = (src) => {
780
+ const written = new Set();
781
+ const visit = new Set();
782
+ const queue = [src];
783
+ while (queue.length > 0) {
784
+ const text = queue.pop();
785
+ for (const n of variableNames(text, true))
786
+ written.add(n);
787
+ for (const m of text.matchAll(ACTION_CALL))
788
+ if (!visit.has(m[1])) {
789
+ visit.add(m[1]);
790
+ queue.push(bodies.get(m[1]) ?? "");
791
+ }
792
+ }
793
+ return written;
794
+ };
795
+ // WHAT A DECISION CAN DEPEND ON: the variables the deciding bodies read, and what those variables' own bodies read.
796
+ // A stopped body whose rest writes none of them cannot change a decision; it never settles, so a caller that waits for
797
+ // it waits forever and a caller that does not cannot see its value.
798
+ const varBodies = new Map(doc.variables.map((v) => [v.as, v.body ?? ""]));
799
+ const decisive = new Set();
800
+ const pendingVars = [];
801
+ for (const src of bodies.values()) {
802
+ if (!DECISION_CALL.test(src))
803
+ continue;
804
+ for (const n of variableNames(src, false))
805
+ if (!decisive.has(n)) {
806
+ decisive.add(n);
807
+ pendingVars.push(n);
808
+ }
809
+ }
810
+ while (pendingVars.length > 0) {
811
+ for (const n of variableNames(varBodies.get(pendingVars.pop()) ?? "", false))
812
+ if (!decisive.has(n)) {
813
+ decisive.add(n);
814
+ pendingVars.push(n);
815
+ }
816
+ }
817
+ const reaches = (written) => written.has("*") || [...written].some((n) => decisive.has(n));
818
+ const halts = new Set();
819
+ for (const [name, body] of actions) {
820
+ if (body.whole || passable.has(name))
821
+ continue;
822
+ const rest = (bodies.get(name) ?? "").slice(body.source.length);
823
+ if (reaches(writesOf(rest)))
824
+ halts.add(name);
825
+ }
826
+ for (const load of loads) {
827
+ if (load.body.whole)
828
+ continue;
829
+ const raw = load.id === "appear" ? doc.appear ?? "" : "";
830
+ const full = preprocessSource(raw.length > 0 ? raw : load.body.source);
831
+ if (raw.length === 0 || reaches(writesOf(full.slice(load.body.source.length))))
832
+ halts.add(`load:${load.id}`);
833
+ }
834
+ const decides = reachable.some((src) => DECISION_CALL.test(src));
835
+ return { decides, loads, actions, passable, halts };
836
+ }
837
+ //# sourceMappingURL=phase-plan.js.map