@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,980 @@
1
+ //
2
+ // camera-core.ts - the pure laws of the capture layer (OpenSource/Conformance/camera/session.json,
3
+ // Phase 2 row cvr-corpora): the session document and planSession (device resolution, format
4
+ // selection, photo, controls, thermal step-down, analyzers), the update merge, the published ranges,
5
+ // the zoom ramp polyfill, the analysis publish budget, the photo and record.start arguments, and the
6
+ // one effect vocabulary the session and the timeline share. Core/Camera's engines apply these on
7
+ // every renderer; the corpus is OpenSource/Conformance/camera and the twins are Kotlin :core
8
+ // CameraCore.kt and Engine/Swift/CameraCore.swift. Nothing here opens a camera.
9
+ //
10
+ import { parseFilePath, fileRootWritable } from "./filepaths.js";
11
+ export const CAMERA_LENSES = [
12
+ "back.wide", "back.ultraWide", "back.tele", "back.dual", "back.triple", "back.lidar", "front.wide", "front.trueDepth", "external",
13
+ ];
14
+ export const CAMERA_MODES = ["photo", "video", "both"];
15
+ export const CAMERA_CODECS = ["h264", "hevc", "prores"];
16
+ export const CAMERA_HDR = ["off", "hlg", "dolbyVision", "hdr10"];
17
+ export const CAMERA_STABILIZATION = ["off", "standard", "cinematic", "cinematicExtended", "lowLatency"];
18
+ export const CAMERA_PHOTO_FORMATS = ["heif", "jpeg", "dng", "proraw"];
19
+ export const CAMERA_PHOTO_QUALITY = ["speed", "balanced", "quality"];
20
+ export const CAMERA_FLASH = ["auto", "on", "off"];
21
+ export const CAMERA_CONTROL_MODES = ["continuous", "auto", "locked", "manual"];
22
+ export const CAMERA_LOW_LIGHT = ["auto", "off"];
23
+ export const CAMERA_EXTENSIONS = ["night", "hdr", "bokeh", "faceRetouch", "auto"];
24
+ export const CAMERA_ORIENTATION = ["auto", "portrait", "portraitUpsideDown", "landscapeLeft", "landscapeRight"];
25
+ export const CAMERA_MIRROR = ["auto", "on", "off"];
26
+ export const CAMERA_CODE_FORMATS = [
27
+ "qr", "aztec", "dataMatrix", "pdf417", "ean13", "ean8", "upca", "upce", "code39", "code93", "code128", "codabar", "itf",
28
+ ];
29
+ export const CAMERA_THERMAL = ["nominal", "fair", "serious", "critical"];
30
+ export const CAMERA_INTERRUPTIONS = ["background", "call", "multitasking", "thermal", "another-app"];
31
+ export const CAMERA_VERBS = ["start", "update", "stop", "photo", "record.start", "record.stop"];
32
+ export const CAMERA_ERRORS = [
33
+ "invalid_config", "unsupported_config", "unavailable", "analyzer_unavailable", "thermal", "busy", "permission_denied", "unsupported_root",
34
+ ];
35
+ export const CAMERA_LIMITS = Object.freeze({
36
+ analyzeFloor: 33, thermalSerious: 30, thermalCritical: 15, tintMin: -150, tintMax: 150, maxBurst: 60,
37
+ });
38
+ export const CAMERA_ANALYZE_EVERY = Object.freeze({ default: 100, codes: 100, text: 250 });
39
+ export const CAMERA_ANALYSIS_CAPS = Object.freeze({ codes: 32, text: 200, faces: 16 });
40
+ export const CAMERA_LADDERS = Object.freeze({
41
+ stabilization: {
42
+ off: ["off"], standard: ["standard", "off"], cinematic: ["cinematic", "standard", "off"],
43
+ cinematicExtended: ["cinematicExtended", "cinematic", "standard", "off"], lowLatency: ["lowLatency", "standard", "off"],
44
+ },
45
+ photoFormat: { proraw: ["proraw", "dng", "heif", "jpeg"], dng: ["dng", "heif", "jpeg"], heif: ["heif", "jpeg"], jpeg: ["jpeg"] },
46
+ codec: ["hevc", "h264"],
47
+ hdrCodec: ["hevc", "prores"],
48
+ });
49
+ export const CAMERA_DESTINATION = "cache:despia-camera";
50
+ /** The session document with every default filled: what `{}` asks for. */
51
+ export const CAMERA_DEFAULTS = Object.freeze({
52
+ devices: [{ lens: "back.wide" }],
53
+ mode: "photo",
54
+ video: { width: 1920, height: 1080, fps: 30, codec: "hevc", hdr: "off", log: false, stabilization: "off", bitrate: null, bakeEffects: true },
55
+ photo: { format: "heif", raw: false, livePhoto: false, depth: false, quality: "balanced", flash: "auto", deferred: true, maxDimensions: null },
56
+ audio: { enabled: true, input: null },
57
+ controls: {
58
+ zoom: { to: 1, rate: null },
59
+ focus: { mode: "continuous", point: null, lens: null },
60
+ exposure: { mode: "continuous", point: null, bias: 0, iso: null, shutter: null },
61
+ whiteBalance: { mode: "continuous", kelvin: null, tint: null },
62
+ torch: 0,
63
+ lowLight: "auto",
64
+ extension: null,
65
+ },
66
+ orientation: "auto",
67
+ mirror: "auto",
68
+ effects: [],
69
+ analyze: [],
70
+ });
71
+ export const CAMERA_EFFECT_USES = ["color", "lut", "blur", "chromaKey", "overlay", "peaking", "zebra", "grid"];
72
+ export const CAMERA_EFFECT_PREVIEW_ONLY = ["peaking", "zebra", "grid"];
73
+ export const CAMERA_EFFECT_SCOPES = ["all", "preview"];
74
+ export const CAMERA_EFFECT_REGIONS = ["all", "background"];
75
+ export const CAMERA_EFFECT_CONTEXTS = ["live", "timeline"];
76
+ export const CAMERA_EFFECT_ERRORS = ["invalid_value", "invalid_source", "preview_only"];
77
+ export const CAMERA_EFFECT_LIMITS = Object.freeze({ maxEffects: 16 });
78
+ export const CAMERA_EFFECT_PARAMS = Object.freeze({
79
+ color: {
80
+ exposure: { default: 0, min: -4, max: 4 }, contrast: { default: 1, min: 0, max: 4 }, saturation: { default: 1, min: 0, max: 4 },
81
+ temperature: { default: 0, min: -5000, max: 5000 }, tint: { default: 0, min: -150, max: 150 },
82
+ },
83
+ lut: { mix: { default: 1, min: 0, max: 1 } },
84
+ blur: { radius: { default: 10, min: 0, max: 100 } },
85
+ chromaKey: { tolerance: { default: 0.4, min: 0, max: 1 } },
86
+ overlay: { opacity: { default: 1, min: 0, max: 1 } },
87
+ zebra: { threshold: { default: 0.95, min: 0, max: 1 } },
88
+ });
89
+ /** The keys of each effect after `use` and `scope`, in check order, with their kind. */
90
+ const EFFECT_FIELDS = {
91
+ color: [["exposure", "num"], ["contrast", "num"], ["saturation", "num"], ["temperature", "num"], ["tint", "num"]],
92
+ lut: [["src", "src"], ["mix", "num"]],
93
+ blur: [["radius", "num"], ["region", "region"]],
94
+ chromaKey: [["color", "color"], ["tolerance", "num"], ["background", "background"]],
95
+ overlay: [["src", "src"], ["frame", "frame"], ["opacity", "num"]],
96
+ peaking: [["color", "color"]],
97
+ zebra: [["threshold", "num"]],
98
+ grid: [],
99
+ };
100
+ const EFFECT_COLORS = { chromaKey: "#00ff00", peaking: "#ff0000" };
101
+ const TOP_KEYS = ["devices", "mode", "video", "photo", "audio", "controls", "orientation", "mirror", "effects", "analyze"];
102
+ const VIDEO_KEYS = ["width", "height", "fps", "codec", "hdr", "log", "stabilization", "bitrate", "bakeEffects"];
103
+ const PHOTO_KEYS = ["format", "raw", "livePhoto", "depth", "quality", "flash", "deferred", "maxDimensions"];
104
+ const CONTROL_KEYS = ["zoom", "focus", "exposure", "whiteBalance", "torch", "lowLight", "extension"];
105
+ const ANALYZE_KEYS = ["use", "every", "region", "formats"];
106
+ // ─── values ───────────────────────────────────────────────────────────────────────────────────
107
+ function isDict(v) {
108
+ return typeof v === "object" && v !== null && !Array.isArray(v);
109
+ }
110
+ function isNum(v) {
111
+ return typeof v === "number" && Number.isFinite(v);
112
+ }
113
+ function has(d, k) {
114
+ return Object.prototype.hasOwnProperty.call(d, k) && d[k] !== undefined;
115
+ }
116
+ /** The value for a key, JSON null and absence both reading as undefined. */
117
+ function val(d, k) {
118
+ if (!d)
119
+ return undefined;
120
+ const v = d[k];
121
+ return v === null ? undefined : v;
122
+ }
123
+ function clamp(x, lo, hi) {
124
+ return Math.min(Math.max(x, lo), hi);
125
+ }
126
+ function key(path, k) {
127
+ return path === "" ? k : `${path}.${k}`;
128
+ }
129
+ function nums(v, n) {
130
+ return Array.isArray(v) && v.length === n && v.every(isNum);
131
+ }
132
+ function isHex(v) {
133
+ return typeof v === "string" && /^#(?:[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/.test(v);
134
+ }
135
+ /** [x, y, w, h] normalised: x and y into 0..1, w and h into what is left; null when empty. */
136
+ export function cameraClampBox(box) {
137
+ const x = clamp(box[0], 0, 1);
138
+ const y = clamp(box[1], 0, 1);
139
+ const w = clamp(box[2], 0, 1 - x);
140
+ const h = clamp(box[3], 0, 1 - y);
141
+ return w > 0 && h > 0 ? [x, y, w, h] : null;
142
+ }
143
+ /** An https URL or a Core/Files path naming a file (the Files path law: six roots, escapes
144
+ * refused); never an absolute path, a file: URL or inline bytes. */
145
+ export function cameraIsSource(v) {
146
+ if (typeof v !== "string")
147
+ return false;
148
+ if (v.startsWith("https://"))
149
+ return v.length > "https://".length;
150
+ const parsed = parseFilePath(v);
151
+ return parsed.ok && parsed.value.relative !== "";
152
+ }
153
+ class Fatal extends Error {
154
+ refusal;
155
+ constructor(refusal) {
156
+ super(`${refusal.code}@${refusal.field}`);
157
+ this.refusal = refusal;
158
+ }
159
+ }
160
+ function fail(code, field) {
161
+ throw new Fatal({ code, field });
162
+ }
163
+ function checkKeys(d, allowed, path, code = "invalid_config") {
164
+ const unknown = Object.keys(d).filter((k) => !allowed.includes(k)).sort();
165
+ if (unknown.length > 0)
166
+ fail(code, key(path, unknown[0]));
167
+ }
168
+ function object(v, path) {
169
+ if (v === undefined)
170
+ return undefined;
171
+ if (!isDict(v))
172
+ fail("invalid_config", path);
173
+ return v;
174
+ }
175
+ // ─── effects ──────────────────────────────────────────────────────────────────────────────────
176
+ class Refused {
177
+ code;
178
+ field;
179
+ constructor(code, field) {
180
+ this.code = code;
181
+ this.field = field;
182
+ }
183
+ }
184
+ function planEffect(e, path, context) {
185
+ if (!isDict(e))
186
+ return new Refused("invalid_value", path);
187
+ const use = e["use"];
188
+ if (typeof use !== "string" || !CAMERA_EFFECT_USES.includes(use))
189
+ return new Refused("invalid_value", `${path}.use`);
190
+ const previewOnly = CAMERA_EFFECT_PREVIEW_ONLY.includes(use);
191
+ if (context === "timeline" && previewOnly)
192
+ return new Refused("preview_only", `${path}.use`);
193
+ const fields = EFFECT_FIELDS[use];
194
+ const unknown = Object.keys(e).filter((k) => k !== "use" && k !== "scope" && !fields.some(([f]) => f === k)).sort();
195
+ if (unknown.length > 0)
196
+ return new Refused("invalid_value", `${path}.${unknown[0]}`);
197
+ if (has(e, "scope") && (typeof e["scope"] !== "string" || !CAMERA_EFFECT_SCOPES.includes(e["scope"]))) {
198
+ return new Refused("invalid_value", `${path}.scope`);
199
+ }
200
+ const scope = e["scope"] ?? (previewOnly ? "preview" : "all");
201
+ if (previewOnly && scope !== "preview")
202
+ return new Refused("preview_only", `${path}.scope`);
203
+ if (context === "timeline" && scope === "preview")
204
+ return new Refused("preview_only", `${path}.scope`);
205
+ const out = { use, scope };
206
+ for (const [name, kind] of fields) {
207
+ const v = e[name];
208
+ const at = `${path}.${name}`;
209
+ if (kind === "num") {
210
+ const range = CAMERA_EFFECT_PARAMS[use][name];
211
+ if (v !== undefined && !isNum(v))
212
+ return new Refused("invalid_value", at);
213
+ out[name] = v === undefined ? range.default : clamp(v, range.min, range.max);
214
+ }
215
+ else if (kind === "src") {
216
+ if (!cameraIsSource(v))
217
+ return new Refused("invalid_source", at);
218
+ out[name] = v;
219
+ }
220
+ else if (kind === "background") {
221
+ if (v !== undefined && v !== null && !cameraIsSource(v))
222
+ return new Refused("invalid_source", at);
223
+ out[name] = v ?? null;
224
+ }
225
+ else if (kind === "region") {
226
+ if (v !== undefined && (typeof v !== "string" || !CAMERA_EFFECT_REGIONS.includes(v)))
227
+ return new Refused("invalid_value", at);
228
+ out[name] = v ?? "all";
229
+ }
230
+ else if (kind === "color") {
231
+ if (v !== undefined && !isHex(v))
232
+ return new Refused("invalid_value", at);
233
+ out[name] = v ?? EFFECT_COLORS[use];
234
+ }
235
+ else {
236
+ if (v !== undefined && !nums(v, 4))
237
+ return new Refused("invalid_value", at);
238
+ const box = cameraClampBox(v ?? [0, 0, 1, 1]);
239
+ if (!box)
240
+ return new Refused("invalid_value", at);
241
+ out[name] = box;
242
+ }
243
+ }
244
+ return out;
245
+ }
246
+ /** The effect law: closed keys per effect, defaults, clamps, sources, preview-only scope. Each
247
+ * entry reports its first refusal; any refusal makes the whole list ineffective. */
248
+ export function cameraPlanEffects(effects, context) {
249
+ if (!Array.isArray(effects) || effects.length > CAMERA_EFFECT_LIMITS.maxEffects) {
250
+ return { effective: null, refusals: [{ code: "invalid_value", field: "" }] };
251
+ }
252
+ const out = [];
253
+ const refusals = [];
254
+ effects.forEach((e, i) => {
255
+ const r = planEffect(e, `[${i}]`, context);
256
+ if (r instanceof Refused)
257
+ refusals.push({ code: r.code, field: r.field });
258
+ else
259
+ out.push(r);
260
+ });
261
+ return refusals.length > 0 ? { effective: null, refusals } : { effective: out, refusals: [] };
262
+ }
263
+ /** What the preview draws and what the recording bakes. */
264
+ export function cameraEffectTargets(effects, bakeEffects) {
265
+ return { preview: [...effects], record: bakeEffects ? effects.filter((e) => e["scope"] === "all") : [] };
266
+ }
267
+ // ─── the session: validation ──────────────────────────────────────────────────────────────────
268
+ function enumAt(d, k, words, path) {
269
+ if (!has(d, k))
270
+ return;
271
+ const v = d[k];
272
+ if (typeof v !== "string" || !words.includes(v))
273
+ fail("invalid_config", key(path, k));
274
+ }
275
+ function boolAt(d, k, path) {
276
+ if (has(d, k) && typeof d[k] !== "boolean")
277
+ fail("invalid_config", key(path, k));
278
+ }
279
+ function numAt(d, k, path, opts = {}) {
280
+ if (!has(d, k))
281
+ return;
282
+ const v = d[k];
283
+ if (v === null && opts.nullable)
284
+ return;
285
+ if (!isNum(v) || (opts.positive && v <= 0))
286
+ fail("invalid_config", key(path, k));
287
+ }
288
+ function pointAt(d, k, path) {
289
+ if (has(d, k) && d[k] !== null && !nums(d[k], 2))
290
+ fail("invalid_config", key(path, k));
291
+ }
292
+ function validateRequest(req) {
293
+ checkKeys(req, TOP_KEYS, "");
294
+ if (has(req, "devices")) {
295
+ const list = req["devices"];
296
+ if (!Array.isArray(list) || list.length === 0)
297
+ fail("invalid_config", "devices");
298
+ list.forEach((e, i) => {
299
+ const at = `devices[${i}]`;
300
+ if (!isDict(e))
301
+ fail("invalid_config", at);
302
+ checkKeys(e, ["lens", "id"], at);
303
+ if (has(e, "lens") === has(e, "id"))
304
+ fail("invalid_config", at);
305
+ if (has(e, "lens") && (typeof e["lens"] !== "string" || !CAMERA_LENSES.includes(e["lens"])))
306
+ fail("invalid_config", `${at}.lens`);
307
+ if (has(e, "id") && (typeof e["id"] !== "string" || e["id"] === ""))
308
+ fail("invalid_config", `${at}.id`);
309
+ });
310
+ }
311
+ enumAt(req, "mode", CAMERA_MODES, "");
312
+ const video = object(req["video"], "video");
313
+ if (video) {
314
+ checkKeys(video, VIDEO_KEYS, "video");
315
+ numAt(video, "width", "video", { nullable: true, positive: true });
316
+ numAt(video, "height", "video", { nullable: true, positive: true });
317
+ const w = val(video, "width") !== undefined;
318
+ const h = val(video, "height") !== undefined;
319
+ if (w && !h)
320
+ fail("invalid_config", "video.height");
321
+ if (h && !w)
322
+ fail("invalid_config", "video.width");
323
+ numAt(video, "fps", "video", { positive: true });
324
+ enumAt(video, "codec", CAMERA_CODECS, "video");
325
+ enumAt(video, "hdr", CAMERA_HDR, "video");
326
+ boolAt(video, "log", "video");
327
+ enumAt(video, "stabilization", CAMERA_STABILIZATION, "video");
328
+ numAt(video, "bitrate", "video", { nullable: true, positive: true });
329
+ boolAt(video, "bakeEffects", "video");
330
+ }
331
+ const photo = object(req["photo"], "photo");
332
+ if (photo) {
333
+ checkKeys(photo, PHOTO_KEYS, "photo");
334
+ enumAt(photo, "format", CAMERA_PHOTO_FORMATS, "photo");
335
+ boolAt(photo, "raw", "photo");
336
+ boolAt(photo, "livePhoto", "photo");
337
+ boolAt(photo, "depth", "photo");
338
+ enumAt(photo, "quality", CAMERA_PHOTO_QUALITY, "photo");
339
+ enumAt(photo, "flash", CAMERA_FLASH, "photo");
340
+ boolAt(photo, "deferred", "photo");
341
+ if (has(photo, "maxDimensions") && photo["maxDimensions"] !== null
342
+ && !(nums(photo["maxDimensions"], 2) && photo["maxDimensions"].every((n) => n > 0))) {
343
+ fail("invalid_config", "photo.maxDimensions");
344
+ }
345
+ }
346
+ const audio = object(req["audio"], "audio");
347
+ if (audio) {
348
+ checkKeys(audio, ["enabled", "input"], "audio");
349
+ boolAt(audio, "enabled", "audio");
350
+ if (has(audio, "input") && audio["input"] !== null && typeof audio["input"] !== "string")
351
+ fail("invalid_config", "audio.input");
352
+ }
353
+ const controls = object(req["controls"], "controls");
354
+ if (controls) {
355
+ checkKeys(controls, CONTROL_KEYS, "controls");
356
+ const zoom = object(controls["zoom"], "controls.zoom");
357
+ if (zoom) {
358
+ checkKeys(zoom, ["to", "rate"], "controls.zoom");
359
+ numAt(zoom, "to", "controls.zoom");
360
+ numAt(zoom, "rate", "controls.zoom", { nullable: true, positive: true });
361
+ }
362
+ const focus = object(controls["focus"], "controls.focus");
363
+ if (focus) {
364
+ checkKeys(focus, ["mode", "point", "lens"], "controls.focus");
365
+ enumAt(focus, "mode", CAMERA_CONTROL_MODES, "controls.focus");
366
+ pointAt(focus, "point", "controls.focus");
367
+ numAt(focus, "lens", "controls.focus", { nullable: true });
368
+ }
369
+ const exposure = object(controls["exposure"], "controls.exposure");
370
+ if (exposure) {
371
+ checkKeys(exposure, ["mode", "point", "bias", "iso", "shutter"], "controls.exposure");
372
+ enumAt(exposure, "mode", CAMERA_CONTROL_MODES, "controls.exposure");
373
+ pointAt(exposure, "point", "controls.exposure");
374
+ numAt(exposure, "bias", "controls.exposure");
375
+ numAt(exposure, "iso", "controls.exposure", { nullable: true });
376
+ numAt(exposure, "shutter", "controls.exposure", { nullable: true, positive: true });
377
+ }
378
+ const wb = object(controls["whiteBalance"], "controls.whiteBalance");
379
+ if (wb) {
380
+ checkKeys(wb, ["mode", "kelvin", "tint"], "controls.whiteBalance");
381
+ enumAt(wb, "mode", CAMERA_CONTROL_MODES, "controls.whiteBalance");
382
+ numAt(wb, "kelvin", "controls.whiteBalance", { nullable: true });
383
+ numAt(wb, "tint", "controls.whiteBalance", { nullable: true });
384
+ }
385
+ numAt(controls, "torch", "controls");
386
+ enumAt(controls, "lowLight", CAMERA_LOW_LIGHT, "controls");
387
+ if (has(controls, "extension") && controls["extension"] !== null)
388
+ enumAt(controls, "extension", CAMERA_EXTENSIONS, "controls");
389
+ }
390
+ enumAt(req, "orientation", CAMERA_ORIENTATION, "");
391
+ enumAt(req, "mirror", CAMERA_MIRROR, "");
392
+ if (has(req, "effects")) {
393
+ const plan = cameraPlanEffects(req["effects"], "live");
394
+ if (plan.refusals.length > 0)
395
+ fail(plan.refusals[0].code, `effects${plan.refusals[0].field}`);
396
+ }
397
+ if (has(req, "analyze")) {
398
+ const list = req["analyze"];
399
+ if (!Array.isArray(list))
400
+ fail("invalid_config", "analyze");
401
+ const seen = [];
402
+ list.forEach((e, i) => {
403
+ const at = `analyze[${i}]`;
404
+ if (!isDict(e))
405
+ fail("invalid_config", at);
406
+ checkKeys(e, ANALYZE_KEYS, at);
407
+ const use = e["use"];
408
+ if (typeof use !== "string" || use === "" || seen.includes(use))
409
+ fail("invalid_config", `${at}.use`);
410
+ seen.push(use);
411
+ numAt(e, "every", at);
412
+ if (has(e, "region") && !(nums(e["region"], 4) && cameraClampBox(e["region"])))
413
+ fail("invalid_config", `${at}.region`);
414
+ if (has(e, "formats")) {
415
+ if (use !== "codes" || !Array.isArray(e["formats"]))
416
+ fail("invalid_config", `${at}.formats`);
417
+ e["formats"].forEach((f, j) => {
418
+ if (typeof f !== "string" || !CAMERA_CODE_FORMATS.includes(f))
419
+ fail("invalid_config", `${at}.formats[${j}]`);
420
+ });
421
+ }
422
+ });
423
+ }
424
+ }
425
+ // ─── the session: the fold ────────────────────────────────────────────────────────────────────
426
+ function list(v, fallback) {
427
+ return Array.isArray(v) ? v : fallback;
428
+ }
429
+ function range(v) {
430
+ return nums(v, 2) ? [v[0], v[1]] : null;
431
+ }
432
+ function longSide(f) { return Math.max(f["width"], f["height"]); }
433
+ function shortSide(f) { return Math.min(f["width"], f["height"]); }
434
+ function area(f) { return f["width"] * f["height"]; }
435
+ /** fps first, then size, then dynamic range, then log; the smallest area, first in table order. */
436
+ function selectFormat(formats, fps, long, short, hdr, log) {
437
+ if (formats.length === 0)
438
+ return { format: null, fps, hdr, log, hdrLost: false, logLost: false };
439
+ let kept = formats.filter((f) => f["fpsMax"] >= fps);
440
+ if (kept.length === 0) {
441
+ fps = Math.max(...formats.map((f) => f["fpsMax"]));
442
+ kept = formats.filter((f) => f["fpsMax"] === fps);
443
+ }
444
+ let cover = kept.filter((f) => longSide(f) >= long && shortSide(f) >= short);
445
+ if (cover.length === 0) {
446
+ const most = Math.max(...kept.map(area));
447
+ cover = kept.filter((f) => area(f) === most);
448
+ }
449
+ let hdrLost = false;
450
+ let logLost = false;
451
+ if (hdr !== "off") {
452
+ const withHdr = cover.filter((f) => list(f["hdr"], []).includes(hdr));
453
+ if (withHdr.length > 0)
454
+ cover = withHdr;
455
+ else {
456
+ hdr = "off";
457
+ hdrLost = true;
458
+ }
459
+ }
460
+ if (log) {
461
+ const withLog = cover.filter((f) => f["log"] === true);
462
+ if (withLog.length > 0)
463
+ cover = withLog;
464
+ else {
465
+ log = false;
466
+ logLost = true;
467
+ }
468
+ }
469
+ const least = Math.min(...cover.map(area));
470
+ const format = cover.find((f) => area(f) === least);
471
+ return { format, fps: Math.min(fps, format["fpsMax"]), hdr, log, hdrLost, logLost };
472
+ }
473
+ function thermalCap(thermal) {
474
+ if (thermal === "serious")
475
+ return CAMERA_LIMITS.thermalSerious;
476
+ if (thermal === "critical")
477
+ return CAMERA_LIMITS.thermalCritical;
478
+ return null;
479
+ }
480
+ function fallbackMode(mode, modes) {
481
+ if (modes.includes(mode))
482
+ return mode;
483
+ if (modes.includes("continuous"))
484
+ return "continuous";
485
+ return modes[0] ?? "locked";
486
+ }
487
+ function explicit(req, path) {
488
+ let d = req;
489
+ for (const k of path) {
490
+ if (!isDict(d) || !has(d, k))
491
+ return false;
492
+ d = d[k];
493
+ }
494
+ return true;
495
+ }
496
+ /** context.devices + platform facts -> the effective session and its refusals (see session.json). */
497
+ export function cameraPlanSession(request, capabilities) {
498
+ const req = request === undefined || request === null ? {} : request;
499
+ const caps = isDict(capabilities) ? capabilities : {};
500
+ const refusals = [];
501
+ const refuse = (code, field, when = true) => {
502
+ if (when && !refusals.some((r) => r.code === code && r.field === field))
503
+ refusals.push({ code, field });
504
+ };
505
+ try {
506
+ if (!isDict(request ?? {}))
507
+ fail("invalid_config", "");
508
+ validateRequest(req);
509
+ const devices = (Array.isArray(caps["devices"]) ? caps["devices"] : []).filter(isDict);
510
+ if (devices.length === 0)
511
+ fail("unavailable", "devices");
512
+ const concurrent = isNum(caps["concurrent"]) ? caps["concurrent"] : 1;
513
+ const asked = has(req, "devices") ? req["devices"] : null;
514
+ if (asked && asked.length > concurrent)
515
+ fail("unsupported_config", "devices");
516
+ const fallback = () => devices.find((d) => d["lens"] === "back.wide") ?? devices.find((d) => d["position"] === "back") ?? devices[0];
517
+ const resolved = (asked ?? [null]).map((entry, i) => {
518
+ if (entry === null)
519
+ return fallback();
520
+ if (has(entry, "id")) {
521
+ const byId = devices.find((d) => d["id"] === entry["id"]);
522
+ if (byId)
523
+ return byId;
524
+ refuse("unsupported_config", `devices[${i}].id`);
525
+ return fallback();
526
+ }
527
+ const lens = entry["lens"];
528
+ const byLens = devices.find((d) => d["lens"] === lens);
529
+ if (byLens)
530
+ return byLens;
531
+ refuse("unsupported_config", `devices[${i}].lens`);
532
+ const position = lens.split(".")[0];
533
+ return devices.find((d) => d["lens"] === `${position}.wide`) ?? devices.find((d) => d["position"] === position) ?? fallback();
534
+ });
535
+ const ids = resolved.map((d) => d["id"]);
536
+ if (new Set(ids).size !== ids.length)
537
+ fail("unsupported_config", "devices");
538
+ const dev = resolved[0];
539
+ const D = CAMERA_DEFAULTS;
540
+ const mode = val(req, "mode") ?? D.mode;
541
+ const v = req["video"] ?? {};
542
+ const sized = val(v, "width") !== undefined;
543
+ const width = sized ? v["width"] : D.video.width;
544
+ const height = sized ? v["height"] : D.video.height;
545
+ const portrait = height > width;
546
+ const long = Math.max(width, height);
547
+ const short = Math.min(width, height);
548
+ const askedFps = Math.max(1, val(v, "fps") ?? D.video.fps);
549
+ const cap = thermalCap(caps["thermal"]);
550
+ const sel = selectFormat(list(dev["formats"], []), askedFps, long, short, val(v, "hdr") ?? D.video.hdr, val(v, "log") ?? D.video.log);
551
+ refuse("unsupported_config", "video.hdr", sel.hdrLost && explicit(req, ["video", "hdr"]));
552
+ refuse("unsupported_config", "video.log", sel.logLost && explicit(req, ["video", "log"]));
553
+ const f = sel.format;
554
+ const vw = f ? (portrait ? shortSide(f) : longSide(f)) : width;
555
+ const vh = f ? (portrait ? longSide(f) : shortSide(f)) : height;
556
+ let hdr = sel.hdr;
557
+ let codec = val(v, "codec") ?? D.video.codec;
558
+ if (f) {
559
+ const codecs = list(f["codecs"], ["h264"]);
560
+ if (!codecs.includes(codec)) {
561
+ codec = CAMERA_LADDERS.codec.find((c) => codecs.includes(c)) ?? codecs[0];
562
+ refuse("unsupported_config", "video.codec", explicit(req, ["video", "codec"]));
563
+ }
564
+ if (hdr !== "off" && codec === "h264") {
565
+ const alt = CAMERA_LADDERS.hdrCodec.find((c) => codecs.includes(c));
566
+ if (alt) {
567
+ codec = alt;
568
+ refuse("unsupported_config", "video.codec", explicit(req, ["video", "codec"]));
569
+ }
570
+ else {
571
+ hdr = "off";
572
+ refuse("unsupported_config", "video.hdr", explicit(req, ["video", "hdr"]));
573
+ }
574
+ }
575
+ }
576
+ const askedStab = val(v, "stabilization") ?? D.video.stabilization;
577
+ let stabilization = askedStab;
578
+ if (f) {
579
+ const modes = list(f["stabilization"], ["off"]);
580
+ stabilization = CAMERA_LADDERS.stabilization[askedStab].find((s) => modes.includes(s)) ?? "off";
581
+ refuse("unsupported_config", "video.stabilization", stabilization !== askedStab && explicit(req, ["video", "stabilization"]));
582
+ }
583
+ let fps = sel.fps;
584
+ if (cap !== null && fps > cap) {
585
+ fps = cap;
586
+ refuse("thermal", "video.fps");
587
+ }
588
+ const p = req["photo"] ?? {};
589
+ const askedFormat = val(p, "format") ?? D.photo.format;
590
+ const photoFormats = list(dev["photoFormats"], ["jpeg"]);
591
+ const format = CAMERA_LADDERS.photoFormat[askedFormat].find((x) => photoFormats.includes(x)) ?? photoFormats[0];
592
+ refuse("unsupported_config", "photo.format", format !== askedFormat && explicit(req, ["photo", "format"]));
593
+ const feature = (k) => {
594
+ const want = (val(p, k) ?? D.photo[k]);
595
+ const got = want && dev[k] === true;
596
+ refuse("unsupported_config", `photo.${k}`, want && !got && explicit(req, ["photo", k]));
597
+ return got;
598
+ };
599
+ const raw = feature("raw");
600
+ const livePhoto = feature("livePhoto");
601
+ const depth = feature("depth");
602
+ const deferred = (val(p, "deferred") ?? D.photo.deferred) && dev["deferred"] === true;
603
+ let flash = val(p, "flash") ?? D.photo.flash;
604
+ if (dev["flash"] !== true && flash !== "off") {
605
+ refuse("unsupported_config", "photo.flash", explicit(req, ["photo", "flash"]));
606
+ flash = "off";
607
+ }
608
+ const a = req["audio"] ?? {};
609
+ const c = req["controls"] ?? {};
610
+ const z = c["zoom"] ?? {};
611
+ const zr = isDict(dev["zoom"]) ? dev["zoom"] : {};
612
+ const zmin = isNum(zr["min"]) ? zr["min"] : 1;
613
+ const zmax = isNum(zr["max"]) ? zr["max"] : zmin;
614
+ const fo = c["focus"] ?? {};
615
+ const focusMode = fallbackMode(val(fo, "mode") ?? "continuous", list(dev["focusModes"], ["continuous"]));
616
+ refuse("unsupported_config", "controls.focus.mode", focusMode !== (val(fo, "mode") ?? "continuous") && explicit(req, ["controls", "focus", "mode"]));
617
+ const ex = c["exposure"] ?? {};
618
+ const exposureMode = fallbackMode(val(ex, "mode") ?? "continuous", list(dev["exposureModes"], ["continuous"]));
619
+ refuse("unsupported_config", "controls.exposure.mode", exposureMode !== (val(ex, "mode") ?? "continuous") && explicit(req, ["controls", "exposure", "mode"]));
620
+ const isoRange = range(dev["iso"]);
621
+ refuse("unsupported_config", "controls.exposure.iso", exposureMode === "manual" && isNum(ex["iso"]) && isoRange === null && explicit(req, ["controls", "exposure", "iso"]));
622
+ const wb = c["whiteBalance"] ?? {};
623
+ const wbMode = fallbackMode(val(wb, "mode") ?? "continuous", list(dev["whiteBalanceModes"], ["continuous"]));
624
+ refuse("unsupported_config", "controls.whiteBalance.mode", wbMode !== (val(wb, "mode") ?? "continuous") && explicit(req, ["controls", "whiteBalance", "mode"]));
625
+ const within = (x, r) => {
626
+ if (!isNum(x))
627
+ return null;
628
+ return r ? clamp(x, r[0], r[1]) : x;
629
+ };
630
+ const point = (x) => (nums(x, 2) ? [clamp(x[0], 0, 1), clamp(x[1], 0, 1)] : null);
631
+ const shutterRange = range(dev["shutter"]);
632
+ const recording = mode !== "photo";
633
+ const shutter = (x) => {
634
+ if (!isNum(x))
635
+ return null;
636
+ const lo = shutterRange ? shutterRange[0] : -Infinity;
637
+ const hi = shutterRange ? shutterRange[1] : Infinity;
638
+ return clamp(x, lo, recording ? Math.max(lo, Math.min(hi, 1 / fps)) : hi);
639
+ };
640
+ let torch = clamp(val(c, "torch") ?? 0, 0, 1);
641
+ if (dev["torch"] !== true && torch > 0) {
642
+ refuse("unsupported_config", "controls.torch", explicit(req, ["controls", "torch"]));
643
+ torch = 0;
644
+ }
645
+ // A torch without levels (the web, Android before API 35) is on or off: any level is on (section 10).
646
+ if (torch > 0 && dev["torchLevels"] !== true)
647
+ torch = 1;
648
+ let tint = wbMode === "manual" ? within(wb["tint"], [CAMERA_LIMITS.tintMin, CAMERA_LIMITS.tintMax]) : null;
649
+ if (tint !== null && dev["tint"] !== true) {
650
+ refuse("unsupported_config", "controls.whiteBalance.tint", explicit(req, ["controls", "whiteBalance", "tint"]));
651
+ tint = null;
652
+ }
653
+ let extension = val(c, "extension") ?? null;
654
+ if (extension !== null && !list(dev["extensions"], []).includes(extension)) {
655
+ refuse("unsupported_config", "controls.extension", explicit(req, ["controls", "extension"]));
656
+ extension = null;
657
+ }
658
+ const analyze = [];
659
+ const registered = list(caps["analyzers"], []);
660
+ (val(req, "analyze") ?? []).forEach((e, i) => {
661
+ const use = e["use"];
662
+ if (!registered.includes(use)) {
663
+ refuse("analyzer_unavailable", `analyze[${i}]`);
664
+ return;
665
+ }
666
+ const every = val(e, "every") ?? CAMERA_ANALYZE_EVERY[use] ?? CAMERA_ANALYZE_EVERY["default"];
667
+ const entry = {
668
+ use, every: Math.max(CAMERA_LIMITS.analyzeFloor, every),
669
+ region: cameraClampBox(val(e, "region") ?? [0, 0, 1, 1]),
670
+ };
671
+ if (use === "codes")
672
+ entry["formats"] = [...(val(e, "formats") ?? CAMERA_CODE_FORMATS)];
673
+ analyze.push(entry);
674
+ });
675
+ const effective = {
676
+ devices: resolved.map((d, i) => {
677
+ if (i === 0)
678
+ return { lens: d["lens"], id: d["id"] };
679
+ const s = selectFormat(list(d["formats"], []), askedFps, long, short, "off", false);
680
+ const sf = s.format;
681
+ return {
682
+ lens: d["lens"], id: d["id"],
683
+ format: {
684
+ width: sf ? (portrait ? shortSide(sf) : longSide(sf)) : width,
685
+ height: sf ? (portrait ? longSide(sf) : shortSide(sf)) : height,
686
+ fps: cap !== null ? Math.min(s.fps, cap) : s.fps,
687
+ },
688
+ };
689
+ }),
690
+ mode,
691
+ video: {
692
+ width: vw, height: vh, fps, codec, hdr, log: sel.log, stabilization,
693
+ bitrate: val(v, "bitrate") ?? null,
694
+ bakeEffects: val(v, "bakeEffects") ?? D.video.bakeEffects,
695
+ },
696
+ photo: {
697
+ format, raw, livePhoto, depth,
698
+ quality: val(p, "quality") ?? D.photo.quality,
699
+ flash, deferred,
700
+ maxDimensions: val(p, "maxDimensions") !== undefined ? [...p["maxDimensions"]] : null,
701
+ },
702
+ audio: {
703
+ enabled: mode === "photo" ? false : (val(a, "enabled") ?? D.audio.enabled),
704
+ input: val(a, "input") ?? null,
705
+ },
706
+ controls: {
707
+ zoom: { to: clamp(val(z, "to") ?? D.controls.zoom.to, zmin, zmax), rate: val(z, "rate") ?? null },
708
+ focus: { mode: focusMode, point: point(fo["point"]), lens: focusMode === "manual" ? within(fo["lens"], [0, 1]) : null },
709
+ exposure: {
710
+ mode: exposureMode, point: point(ex["point"]),
711
+ bias: within(val(ex, "bias") ?? 0, range(dev["bias"]) ?? [0, 0]),
712
+ iso: exposureMode === "manual" && isoRange !== null ? within(ex["iso"], isoRange) : null,
713
+ shutter: exposureMode === "manual" ? shutter(ex["shutter"]) : null,
714
+ },
715
+ whiteBalance: {
716
+ mode: wbMode,
717
+ kelvin: wbMode === "manual" ? within(wb["kelvin"], range(dev["kelvin"])) : null,
718
+ tint,
719
+ },
720
+ torch,
721
+ lowLight: val(c, "lowLight") ?? D.controls.lowLight,
722
+ extension,
723
+ },
724
+ orientation: val(req, "orientation") ?? D.orientation,
725
+ mirror: val(req, "mirror") ?? D.mirror,
726
+ effects: has(req, "effects") ? cameraPlanEffects(req["effects"], "live").effective : [],
727
+ analyze,
728
+ };
729
+ return { effective, refusals };
730
+ }
731
+ catch (e) {
732
+ if (e instanceof Fatal)
733
+ return { effective: null, refusals: [e.refusal] };
734
+ throw e;
735
+ }
736
+ }
737
+ /** camera.update: objects merge, arrays and scalars replace, null replaces. */
738
+ export function cameraMergeSession(base, patch) {
739
+ if (!isDict(base) || !isDict(patch))
740
+ return patch === undefined ? base : patch;
741
+ const out = { ...base };
742
+ for (const [k, v] of Object.entries(patch))
743
+ out[k] = isDict(v) && isDict(base[k]) ? cameraMergeSession(base[k], v) : v;
744
+ return out;
745
+ }
746
+ /** context.session.ranges: the active device's manual ranges, the shutter bounded by the frame
747
+ * duration while recording. */
748
+ export function cameraRanges(effective, capabilities) {
749
+ const caps = isDict(capabilities) ? capabilities : {};
750
+ const id = (effective["devices"][0] ?? {})["id"];
751
+ const dev = (Array.isArray(caps["devices"]) ? caps["devices"] : []).find((d) => d["id"] === id) ?? {};
752
+ const zr = isDict(dev["zoom"]) ? dev["zoom"] : {};
753
+ const zmin = isNum(zr["min"]) ? zr["min"] : 1;
754
+ const zmax = isNum(zr["max"]) ? zr["max"] : zmin;
755
+ const s = range(dev["shutter"]);
756
+ const fps = effective["video"]["fps"];
757
+ const shutter = s && effective["mode"] !== "photo" ? [s[0], Math.max(s[0], Math.min(s[1], 1 / fps))] : s;
758
+ return {
759
+ zoom: [zmin, zmax], iso: range(dev["iso"]), shutter, bias: range(dev["bias"]), kelvin: range(dev["kelvin"]),
760
+ focus: list(dev["focusModes"], ["continuous"]).includes("manual") ? [0, 1] : null,
761
+ };
762
+ }
763
+ /** 4.4 row liveness (session.json `liveness`): which mounted previews draw, and whether the session runs. A far row
764
+ * stops drawing; the session pauses when previews are mounted, none is near or active and nothing records. */
765
+ export function cameraPreviewLiveness(levels, recording) {
766
+ const draw = levels.map((l) => l !== "far");
767
+ return { draw, run: recording || levels.length === 0 || draw.some(Boolean) };
768
+ }
769
+ /** The zoom ramp polyfill (Android, web): `rate` doublings per second toward `to`, then held. */
770
+ export function cameraZoomAt(from, to, rate, t) {
771
+ if (rate === null || rate <= 0 || from === to)
772
+ return to;
773
+ const z = from * Math.pow(2, (to > from ? 1 : -1) * rate * Math.max(0, t));
774
+ return to > from ? Math.min(z, to) : Math.max(z, to);
775
+ }
776
+ /** The analysis budget: publish at most once per `every` ms, latest wins, payload capped. */
777
+ export function cameraAnalysisGate(use, every, last, now, count) {
778
+ const cap = CAMERA_ANALYSIS_CAPS[use];
779
+ return { publish: last === null || now - last >= every, keep: cap === undefined ? count : Math.min(count, cap) };
780
+ }
781
+ function destination(v) {
782
+ const parsed = parseFilePath(v);
783
+ if (!parsed.ok)
784
+ fail("unsupported_root", "to");
785
+ if (!fileRootWritable(parsed.value.root))
786
+ fail("permission_denied", "to");
787
+ return `${parsed.value.root}:${parsed.value.relative}`;
788
+ }
789
+ function verbArgs(args, allowed, body) {
790
+ try {
791
+ const a = args === undefined || args === null ? {} : args;
792
+ if (!isDict(a))
793
+ fail("invalid_config", "");
794
+ checkKeys(a, allowed, "");
795
+ return { effective: body(a), refusals: [] };
796
+ }
797
+ catch (e) {
798
+ if (e instanceof Fatal)
799
+ return { effective: null, refusals: [e.refusal] };
800
+ throw e;
801
+ }
802
+ }
803
+ /** photo({ count?, interval?, to?, prompt? }): count truncated and clamped to 1..maxBurst,
804
+ * interval (ms) at least 0, `to` a Files directory on a writable root. */
805
+ export function cameraPhotoArgs(args, maxBurst = CAMERA_LIMITS.maxBurst) {
806
+ return verbArgs(args, ["count", "interval", "to", "prompt"], (a) => {
807
+ numAt(a, "count", "");
808
+ numAt(a, "interval", "");
809
+ if (has(a, "to") && typeof a["to"] !== "string")
810
+ fail("invalid_config", "to");
811
+ const to = destination(a["to"] ?? CAMERA_DESTINATION);
812
+ boolAt(a, "prompt", "");
813
+ return {
814
+ count: clamp(Math.trunc(a["count"] ?? 1), 1, maxBurst),
815
+ interval: Math.max(0, a["interval"] ?? 0),
816
+ to, prompt: a["prompt"] ?? true,
817
+ };
818
+ });
819
+ }
820
+ /** record.start({ to?, maxDuration?, maxBytes?, prompt? }): limits positive or null. */
821
+ export function cameraRecordArgs(args) {
822
+ return verbArgs(args, ["to", "maxDuration", "maxBytes", "prompt"], (a) => {
823
+ if (has(a, "to") && typeof a["to"] !== "string")
824
+ fail("invalid_config", "to");
825
+ const to = destination(a["to"] ?? CAMERA_DESTINATION);
826
+ numAt(a, "maxDuration", "", { nullable: true, positive: true });
827
+ numAt(a, "maxBytes", "", { nullable: true, positive: true });
828
+ boolAt(a, "prompt", "");
829
+ return {
830
+ to, maxDuration: val(a, "maxDuration") ?? null,
831
+ maxBytes: val(a, "maxBytes") ?? null, prompt: a["prompt"] ?? true,
832
+ };
833
+ });
834
+ }
835
+ // ─── analyzers: the registry, the pump, the histogram fold (OpenSource/Conformance/camera/analyzers.json, row cvr-analyzers) ──
836
+ //
837
+ // An analyzer is code a recognition package REGISTERS under a `use` word (Vision: codes, text, faces, document;
838
+ // Camera: histogram). Core/Camera's session owns the pump. The registry and the pump are pure and shared:
839
+ // Conformance/camera/analyzers.json runs on Swift (CameraCore), Kotlin (CameraCore) and here. The runner is
840
+ // whatever the renderer's frames look like (an ImageBitmap or canvas on the web), so it is typed `unknown`.
841
+ export const CAMERA_ANALYSIS_BINS = 64;
842
+ const ANALYZER_NAME = /^[a-z][A-Za-z0-9]*$/;
843
+ const analyzerTable = new Map();
844
+ export const CameraAnalyzers = {
845
+ /** True when registered; a word that is not lower camelCase is refused. A later registration of a word wins. */
846
+ register(use, runner) {
847
+ if (typeof use !== "string" || !ANALYZER_NAME.test(use))
848
+ return false;
849
+ analyzerTable.set(use, runner);
850
+ return true;
851
+ },
852
+ unregister(use) {
853
+ analyzerTable.delete(use);
854
+ },
855
+ /** The sorted registered words: the capability table's `analyzers`. */
856
+ names() {
857
+ return [...analyzerTable.keys()].sort();
858
+ },
859
+ runner(use) {
860
+ return analyzerTable.has(use) ? analyzerTable.get(use) : null;
861
+ },
862
+ };
863
+ const round6 = (v) => Math.round(v * 1e6) / 1e6;
864
+ /** The sensor region to crop by: a mirrored preview shows the sensor frame reflected, so x reflects. */
865
+ function sensorRegion(region, mirror) {
866
+ return mirror ? [round6(1 - region[0] - region[2]), region[1], region[2], region[3]] : region;
867
+ }
868
+ function mapPoint(region, x, y, mirror) {
869
+ const px = round6(region[0] + x * region[2]);
870
+ return [mirror ? round6(1 - px) : px, round6(region[1] + y * region[3])];
871
+ }
872
+ /** One row with its `bounds` ([x, y, w, h]) and `quad` ([[x, y] x4]) mapped from the analysis region to the preview. */
873
+ function mapRow(region, mirror, row) {
874
+ if (!isDict(row))
875
+ return row;
876
+ const out = { ...row };
877
+ const b = out["bounds"];
878
+ if (Array.isArray(b) && b.length === 4 && b.every(isNum)) {
879
+ const w = round6(b[2] * region[2]);
880
+ const [x, y] = mapPoint(region, b[0], b[1], false);
881
+ out["bounds"] = [mirror ? round6(1 - x - w) : x, y, w, round6(b[3] * region[3])];
882
+ }
883
+ const q = out["quad"];
884
+ if (Array.isArray(q) && q.every((p) => Array.isArray(p) && p.length === 2 && p.every(isNum))) {
885
+ out["quad"] = q.map((p) => mapPoint(region, p[0], p[1], mirror));
886
+ }
887
+ return out;
888
+ }
889
+ function stable(v) {
890
+ if (Array.isArray(v))
891
+ return `[${v.map(stable).join(",")}]`;
892
+ if (isDict(v))
893
+ return `{${Object.keys(v).sort().map((k) => `${JSON.stringify(k)}:${stable(v[k])}`).join(",")}}`;
894
+ return JSON.stringify(v);
895
+ }
896
+ /** The budget law as a state machine: which analyzer runs on a frame, and what a settled run publishes. */
897
+ export class CameraAnalysisPump {
898
+ slots;
899
+ mirror;
900
+ constructor(analyze, options = {}) {
901
+ this.mirror = options.mirror === true;
902
+ this.slots = analyze.map((e) => ({
903
+ use: e.use, every: e.every, region: e.region ?? [0, 0, 1, 1], busy: false, started: null, published: null, last: null,
904
+ }));
905
+ }
906
+ /** The analyzers that run on a frame arriving at `now` ms, in session order; each is marked running. */
907
+ frame(now) {
908
+ const due = [];
909
+ for (const s of this.slots) {
910
+ if (s.busy || (s.started !== null && now - s.started < s.every))
911
+ continue;
912
+ s.busy = true;
913
+ s.started = now;
914
+ due.push(s.use);
915
+ }
916
+ return due;
917
+ }
918
+ /** The region (normalised [x, y, w, h] of the SENSOR frame) an analyzer crops by, or null when it is not in the session. */
919
+ region(use) {
920
+ const r = this.slots.find((s) => s.use === use)?.region;
921
+ return r ? sensorRegion(r, this.mirror) : null;
922
+ }
923
+ /** A run settled with `payload` (rows, or one object): `publish` with the capped, mapped value, or drop it. */
924
+ settle(use, payload, now) {
925
+ const s = this.slots.find((x) => x.use === use);
926
+ if (!s)
927
+ return { publish: false, value: null };
928
+ s.busy = false;
929
+ const count = Array.isArray(payload) ? payload.length : 1;
930
+ const gate = cameraAnalysisGate(use, s.every, s.published, now, count);
931
+ if (!gate.publish)
932
+ return { publish: false, value: null };
933
+ const value = Array.isArray(payload) ? payload.slice(0, gate.keep).map((r) => mapRow(sensorRegion(s.region, this.mirror), this.mirror, r)) : payload;
934
+ const key = stable(value);
935
+ if (key === s.last)
936
+ return { publish: false, value: null };
937
+ s.last = key;
938
+ s.published = now;
939
+ return { publish: true, value };
940
+ }
941
+ /** A run raised: idle again, nothing published. */
942
+ fail(use) {
943
+ const s = this.slots.find((x) => x.use === use);
944
+ if (s)
945
+ s.busy = false;
946
+ }
947
+ }
948
+ /** The pure fold behind the `histogram` analyzer: RGBA bytes -> { luma: 64 fractions, mean }. */
949
+ export function cameraHistogram(rgba) {
950
+ const bins = new Array(CAMERA_ANALYSIS_BINS).fill(0);
951
+ const pixels = Math.floor(rgba.length / 4);
952
+ if (pixels === 0)
953
+ return { luma: bins, mean: 0 };
954
+ let sum = 0;
955
+ for (let i = 0; i < pixels; i += 1) {
956
+ const luma = (54 * (rgba[i * 4] & 255) + 183 * (rgba[i * 4 + 1] & 255) + 19 * (rgba[i * 4 + 2] & 255)) >> 8;
957
+ bins[luma >> 2] += 1;
958
+ sum += luma;
959
+ }
960
+ return { luma: bins.map((n) => round6(n / pixels)), mean: round6(sum / pixels / 255) };
961
+ }
962
+ /** Every source's own barcode word for the closed code-format set (the corpus `formats` pins this table). */
963
+ export const CAMERA_CODE_WORDS = Object.freeze({
964
+ vision: { "VNBarcodeSymbologyQR": "qr", "VNBarcodeSymbologyAztec": "aztec", "VNBarcodeSymbologyDataMatrix": "dataMatrix", "VNBarcodeSymbologyPDF417": "pdf417", "VNBarcodeSymbologyEAN13": "ean13", "VNBarcodeSymbologyEAN8": "ean8", "VNBarcodeSymbologyUPCE": "upce", "VNBarcodeSymbologyCode39": "code39", "VNBarcodeSymbologyCode93": "code93", "VNBarcodeSymbologyCode128": "code128", "VNBarcodeSymbologyCodabar": "codabar", "VNBarcodeSymbologyITF14": "itf", "VNBarcodeSymbologyI2of5": "itf" },
965
+ mlkit: { "256": "qr", "4096": "aztec", "16": "dataMatrix", "2048": "pdf417", "32": "ean13", "64": "ean8", "512": "upca", "1024": "upce", "2": "code39", "4": "code93", "1": "code128", "8": "codabar", "128": "itf" },
966
+ detector: { "qr_code": "qr", "aztec": "aztec", "data_matrix": "dataMatrix", "pdf417": "pdf417", "ean_13": "ean13", "ean_8": "ean8", "upc_a": "upca", "upc_e": "upce", "code_39": "code39", "code_93": "code93", "code_128": "code128", "codabar": "codabar", "itf": "itf" },
967
+ zxing: { "QRCode": "qr", "QRCodeModel1": "qr", "QRCodeModel2": "qr", "MicroQRCode": "qr", "Aztec": "aztec", "DataMatrix": "dataMatrix", "PDF417": "pdf417", "EAN13": "ean13", "EAN8": "ean8", "UPCA": "upca", "UPCE": "upce", "Code39": "code39", "Code93": "code93", "Code128": "code128", "Codabar": "codabar", "ITF": "itf" },
968
+ zxingCore: { "QR_CODE": "qr", "AZTEC": "aztec", "DATA_MATRIX": "dataMatrix", "PDF_417": "pdf417", "EAN_13": "ean13", "EAN_8": "ean8", "UPC_A": "upca", "UPC_E": "upce", "CODE_39": "code39", "CODE_93": "code93", "CODE_128": "code128", "CODABAR": "codabar", "ITF": "itf" },
969
+ });
970
+ /** A source's own barcode word -> the session's code-format word, or null when the session names no such format. */
971
+ export function cameraCodeFormat(source, native) {
972
+ const row = Object.prototype.hasOwnProperty.call(CAMERA_CODE_WORDS, source) ? CAMERA_CODE_WORDS[source] : undefined;
973
+ return row && Object.prototype.hasOwnProperty.call(row, native) ? row[native] : null;
974
+ }
975
+ /** The source's own words for a session code-format word (the inverse of the table), sorted; empty when it cannot read it. */
976
+ export function cameraCodeNatives(source, word) {
977
+ const row = Object.prototype.hasOwnProperty.call(CAMERA_CODE_WORDS, source) ? CAMERA_CODE_WORDS[source] : undefined;
978
+ return row ? Object.keys(row).filter((n) => row[n] === word).sort() : [];
979
+ }
980
+ //# sourceMappingURL=camera-core.js.map