@celljs/ta-web 4.34.0 → 4.36.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 (345) hide show
  1. package/README.en.md +1 -1
  2. package/README.md +1 -1
  3. package/esm/browser/apps/app-icon.d.ts +23 -0
  4. package/esm/browser/apps/app-icon.js +98 -0
  5. package/esm/browser/apps/app-settings.d.ts +6 -0
  6. package/esm/browser/apps/app-settings.js +67 -0
  7. package/esm/browser/apps/app-window-util.d.ts +23 -0
  8. package/esm/browser/apps/app-window-util.js +27 -0
  9. package/esm/browser/apps/app-window.d.ts +9 -0
  10. package/esm/browser/apps/app-window.js +90 -0
  11. package/esm/browser/apps/web-apps.d.ts +29 -0
  12. package/esm/browser/apps/web-apps.js +57 -0
  13. package/esm/browser/assistant/assistant-thread.js +2 -2
  14. package/esm/browser/assistant/call-keeper.d.ts +2 -5
  15. package/esm/browser/assistant/call-keeper.js +7 -11
  16. package/esm/browser/assistant/mic-capture.d.ts +34 -0
  17. package/esm/browser/assistant/mic-capture.js +87 -0
  18. package/esm/browser/assistant/realtime-voice.d.ts +2 -2
  19. package/esm/browser/assistant/realtime-voice.js +6 -15
  20. package/esm/browser/components/access-settings.d.ts +6 -0
  21. package/esm/browser/components/access-settings.js +52 -0
  22. package/esm/browser/components/app-root.d.ts +6 -0
  23. package/esm/browser/components/app-root.js +34 -0
  24. package/esm/browser/components/app-view.d.ts +8 -2
  25. package/esm/browser/components/app-view.js +1 -25
  26. package/esm/browser/components/board.d.ts +2 -2
  27. package/esm/browser/components/board.js +2 -2
  28. package/esm/browser/components/cloud-sign-in-view.d.ts +1 -1
  29. package/esm/browser/components/composer-box-hooks.d.ts +12 -0
  30. package/esm/browser/components/composer-box-hooks.js +12 -0
  31. package/esm/browser/components/composer-box-protocol.d.ts +12 -1
  32. package/esm/browser/components/composer-box.js +14 -11
  33. package/esm/browser/components/composer.js +69 -3
  34. package/esm/browser/components/extension-settings.d.ts +7 -0
  35. package/esm/browser/components/extension-settings.js +32 -0
  36. package/esm/browser/components/host-view.d.ts +1 -1
  37. package/esm/browser/components/message-list.js +3 -3
  38. package/esm/browser/components/message-steps.js +3 -3
  39. package/esm/browser/components/phone-shell.d.ts +2 -2
  40. package/esm/browser/components/request-error.d.ts +9 -0
  41. package/esm/browser/components/request-error.js +21 -0
  42. package/esm/browser/components/settings-more.js +13 -24
  43. package/esm/browser/components/storage-settings.d.ts +17 -0
  44. package/esm/browser/components/storage-settings.js +145 -0
  45. package/esm/browser/device/screen-awake.d.ts +16 -0
  46. package/esm/browser/device/screen-awake.js +37 -0
  47. package/esm/browser/device/sheet-swipe.js +4 -0
  48. package/esm/browser/extension/icons.js +2 -1
  49. package/esm/browser/extension/web-access.d.ts +16 -0
  50. package/esm/browser/extension/web-access.js +75 -0
  51. package/esm/browser/extension/web-api-contributions.d.ts +6 -7
  52. package/esm/browser/extension/web-api-desktop.d.ts +23 -0
  53. package/esm/browser/extension/web-api-spec.d.ts +70 -0
  54. package/esm/browser/extension/web-api-spec.js +225 -0
  55. package/esm/browser/extension/web-api-targets.d.ts +11 -0
  56. package/esm/browser/extension/web-api-targets.js +2 -0
  57. package/esm/browser/extension/web-extension-api.d.ts +11 -1
  58. package/esm/browser/extension/web-extension-context.d.ts +3 -2
  59. package/esm/browser/extension/web-extension-context.js +22 -17
  60. package/esm/browser/extension/web-extension-run.d.ts +8 -1
  61. package/esm/browser/extension/web-extension-run.js +37 -0
  62. package/esm/browser/extension/web-extensions-running.d.ts +20 -1
  63. package/esm/browser/extension/web-extensions-running.js +107 -9
  64. package/esm/browser/extension/web-extensions.js +1 -0
  65. package/esm/browser/extension/web-pages.d.ts +5 -0
  66. package/esm/browser/extension/web-pages.js +3 -0
  67. package/esm/browser/game/game-control.d.ts +6 -0
  68. package/esm/browser/game/game-control.js +28 -0
  69. package/esm/browser/game/game-host.d.ts +9 -2
  70. package/esm/browser/game/game-host.js +5 -1
  71. package/esm/browser/game/game-protocol.d.ts +8 -0
  72. package/esm/browser/game/game-runner.d.ts +7 -1
  73. package/esm/browser/game/game-runner.js +24 -2
  74. package/esm/browser/game/game-target.d.ts +22 -0
  75. package/esm/browser/game/game-target.js +84 -0
  76. package/esm/browser/game/game-util.d.ts +2 -0
  77. package/esm/browser/game/game-util.js +2 -0
  78. package/esm/browser/game/game-view.d.ts +5 -2
  79. package/esm/browser/game/game-view.js +4 -4
  80. package/esm/browser/game/game3d-protocol.d.ts +3 -1
  81. package/esm/browser/game/game3d-runner.d.ts +6 -1
  82. package/esm/browser/game/game3d-runner.js +26 -2
  83. package/esm/browser/i18n/en/chat.d.ts +4 -0
  84. package/esm/browser/i18n/en/chat.js +4 -0
  85. package/esm/browser/i18n/en/common.d.ts +1 -0
  86. package/esm/browser/i18n/en/common.js +1 -0
  87. package/esm/browser/i18n/en/discover.d.ts +11 -0
  88. package/esm/browser/i18n/en/discover.js +11 -0
  89. package/esm/browser/i18n/en/settings.d.ts +43 -0
  90. package/esm/browser/i18n/en/settings.js +43 -0
  91. package/esm/browser/i18n/ja/chat.js +4 -0
  92. package/esm/browser/i18n/ja/common.js +1 -0
  93. package/esm/browser/i18n/ja/discover.js +11 -0
  94. package/esm/browser/i18n/ja/settings.js +43 -0
  95. package/esm/browser/i18n/locales.d.ts +60 -3
  96. package/esm/browser/i18n/messages.d.ts +59 -2
  97. package/esm/browser/i18n/zh/chat.js +4 -0
  98. package/esm/browser/i18n/zh/common.js +1 -0
  99. package/esm/browser/i18n/zh/discover.js +11 -0
  100. package/esm/browser/i18n/zh/settings.js +43 -0
  101. package/esm/browser/i18n/zh-tw/chat.js +4 -0
  102. package/esm/browser/i18n/zh-tw/common.js +1 -0
  103. package/esm/browser/i18n/zh-tw/discover.js +11 -0
  104. package/esm/browser/i18n/zh-tw/settings.js +43 -0
  105. package/esm/browser/index.d.ts +3 -0
  106. package/esm/browser/index.js +3 -0
  107. package/esm/browser/notices/notices.js +1 -0
  108. package/esm/browser/sandbox/channel/channel.d.ts +56 -0
  109. package/esm/browser/sandbox/channel/channel.js +124 -0
  110. package/esm/browser/sandbox/channel/codec.d.ts +80 -0
  111. package/esm/browser/sandbox/channel/codec.js +251 -0
  112. package/esm/browser/sandbox/hook-host.d.ts +23 -0
  113. package/esm/browser/sandbox/hook-host.js +61 -0
  114. package/esm/browser/sandbox/isolated-host.d.ts +105 -0
  115. package/esm/browser/sandbox/isolated-host.js +395 -0
  116. package/esm/browser/sandbox/remote/remote-copy.d.ts +57 -0
  117. package/esm/browser/sandbox/remote/remote-copy.js +318 -0
  118. package/esm/browser/sandbox/remote/remote-mirror.d.ts +61 -0
  119. package/esm/browser/sandbox/remote/remote-mirror.js +341 -0
  120. package/esm/browser/sandbox/remote/remote-protocol.d.ts +79 -0
  121. package/esm/browser/sandbox/remote/remote-protocol.js +54 -0
  122. package/esm/browser/sandbox/remote/remote-styles.d.ts +10 -0
  123. package/esm/browser/sandbox/remote/remote-styles.js +113 -0
  124. package/esm/browser/sandbox/remote-root.d.ts +11 -0
  125. package/esm/browser/sandbox/remote-root.js +81 -0
  126. package/esm/browser/sandbox/runtime/frame-api.d.ts +28 -0
  127. package/esm/browser/sandbox/runtime/frame-api.js +147 -0
  128. package/esm/browser/sandbox/runtime/frame-features.d.ts +6 -0
  129. package/esm/browser/sandbox/runtime/frame-features.js +50 -0
  130. package/esm/browser/sandbox/runtime/frame-parts.d.ts +36 -0
  131. package/esm/browser/sandbox/runtime/frame-parts.js +69 -0
  132. package/esm/browser/sandbox/runtime/frame-roots.d.ts +26 -0
  133. package/esm/browser/sandbox/runtime/frame-roots.js +76 -0
  134. package/esm/browser/sandbox/runtime/frame-store.d.ts +9 -0
  135. package/esm/browser/sandbox/runtime/frame-store.js +18 -0
  136. package/esm/browser/sandbox/runtime/sandbox-runtime.d.ts +11 -0
  137. package/esm/browser/sandbox/runtime/sandbox-runtime.js +45 -0
  138. package/esm/browser/sandbox/sandbox-features.d.ts +25 -0
  139. package/esm/browser/sandbox/sandbox-features.js +32 -0
  140. package/esm/browser/sandbox/sandbox-frame.d.ts +21 -0
  141. package/esm/browser/sandbox/sandbox-frame.js +75 -0
  142. package/esm/browser/sandbox/sandbox-guards.d.ts +19 -0
  143. package/esm/browser/sandbox/sandbox-guards.js +74 -0
  144. package/esm/browser/sandbox/sandbox-protocol.d.ts +57 -0
  145. package/esm/browser/sandbox/sandbox-protocol.js +49 -0
  146. package/esm/browser/sandbox/sandbox-runtime-code.d.ts +1 -0
  147. package/esm/browser/sandbox/sandbox-runtime-code.js +3 -0
  148. package/esm/browser/sandbox/web-sandbox.d.ts +28 -0
  149. package/esm/browser/sandbox/web-sandbox.js +44 -0
  150. package/esm/browser/settings/agent-settings.js +5 -1
  151. package/esm/browser/settings/settings-protocol.d.ts +2 -0
  152. package/esm/browser/settings/settings-protocol.js +2 -0
  153. package/esm/browser/style/pages.d.ts +1 -1
  154. package/esm/browser/style/pages.js +2 -0
  155. package/esm/browser/style/surfaces.d.ts +1 -1
  156. package/esm/browser/style/surfaces.js +4 -0
  157. package/esm/browser/style/tints.d.ts +2 -0
  158. package/esm/browser/style/tints.js +10 -0
  159. package/esm/browser/targets/targets-protocol.d.ts +54 -0
  160. package/esm/browser/targets/targets-protocol.js +34 -0
  161. package/esm/browser/targets/targets.d.ts +13 -0
  162. package/esm/browser/targets/targets.js +64 -0
  163. package/esm/browser/util/composer.d.ts +4 -2
  164. package/esm/browser/util/composer.js +7 -1
  165. package/esm/browser/util/desktop.d.ts +31 -1
  166. package/esm/browser/util/desktop.js +20 -0
  167. package/esm/browser/util/message.d.ts +6 -0
  168. package/esm/browser/util/message.js +21 -0
  169. package/esm/browser/util/process.d.ts +1 -0
  170. package/esm/browser/util/process.js +6 -1
  171. package/esm/browser/util/progress.d.ts +2 -1
  172. package/esm/browser/util/progress.js +2 -11
  173. package/esm/browser/view.js +1 -1
  174. package/lib/browser/apps/app-icon.d.ts +24 -0
  175. package/lib/browser/apps/app-icon.js +134 -0
  176. package/lib/browser/apps/app-settings.d.ts +7 -0
  177. package/lib/browser/apps/app-settings.js +103 -0
  178. package/lib/browser/apps/app-window-util.d.ts +24 -0
  179. package/lib/browser/apps/app-window-util.js +30 -0
  180. package/lib/browser/apps/app-window.d.ts +10 -0
  181. package/lib/browser/apps/app-window.js +126 -0
  182. package/lib/browser/apps/web-apps.d.ts +30 -0
  183. package/lib/browser/apps/web-apps.js +61 -0
  184. package/lib/browser/assistant/assistant-thread.js +2 -2
  185. package/lib/browser/assistant/call-keeper.d.ts +2 -5
  186. package/lib/browser/assistant/call-keeper.js +6 -10
  187. package/lib/browser/assistant/mic-capture.d.ts +35 -0
  188. package/lib/browser/assistant/mic-capture.js +91 -0
  189. package/lib/browser/assistant/realtime-voice.d.ts +2 -2
  190. package/lib/browser/assistant/realtime-voice.js +6 -15
  191. package/lib/browser/components/access-settings.d.ts +7 -0
  192. package/lib/browser/components/access-settings.js +88 -0
  193. package/lib/browser/components/app-root.d.ts +7 -0
  194. package/lib/browser/components/app-root.js +70 -0
  195. package/lib/browser/components/app-view.d.ts +8 -2
  196. package/lib/browser/components/app-view.js +1 -25
  197. package/lib/browser/components/board.d.ts +2 -2
  198. package/lib/browser/components/board.js +2 -2
  199. package/lib/browser/components/cloud-sign-in-view.d.ts +1 -1
  200. package/lib/browser/components/composer-box-hooks.d.ts +12 -0
  201. package/lib/browser/components/composer-box-hooks.js +13 -0
  202. package/lib/browser/components/composer-box-protocol.d.ts +12 -1
  203. package/lib/browser/components/composer-box.js +13 -10
  204. package/lib/browser/components/composer.js +69 -3
  205. package/lib/browser/components/extension-settings.d.ts +8 -0
  206. package/lib/browser/components/extension-settings.js +69 -0
  207. package/lib/browser/components/host-view.d.ts +1 -1
  208. package/lib/browser/components/message-list.js +3 -3
  209. package/lib/browser/components/message-steps.js +3 -3
  210. package/lib/browser/components/phone-shell.d.ts +2 -2
  211. package/lib/browser/components/request-error.d.ts +10 -0
  212. package/lib/browser/components/request-error.js +57 -0
  213. package/lib/browser/components/settings-more.js +12 -23
  214. package/lib/browser/components/storage-settings.d.ts +18 -0
  215. package/lib/browser/components/storage-settings.js +182 -0
  216. package/lib/browser/device/screen-awake.d.ts +16 -0
  217. package/lib/browser/device/screen-awake.js +39 -1
  218. package/lib/browser/device/sheet-swipe.js +4 -0
  219. package/lib/browser/extension/icons.js +1 -0
  220. package/lib/browser/extension/web-access.d.ts +17 -0
  221. package/lib/browser/extension/web-access.js +78 -0
  222. package/lib/browser/extension/web-api-contributions.d.ts +6 -7
  223. package/lib/browser/extension/web-api-desktop.d.ts +23 -0
  224. package/lib/browser/extension/web-api-spec.d.ts +71 -0
  225. package/lib/browser/extension/web-api-spec.js +228 -0
  226. package/lib/browser/extension/web-api-targets.d.ts +12 -0
  227. package/lib/browser/extension/web-api-targets.js +3 -0
  228. package/lib/browser/extension/web-extension-api.d.ts +11 -1
  229. package/lib/browser/extension/web-extension-context.d.ts +3 -2
  230. package/lib/browser/extension/web-extension-context.js +22 -17
  231. package/lib/browser/extension/web-extension-run.d.ts +8 -1
  232. package/lib/browser/extension/web-extension-run.js +37 -0
  233. package/lib/browser/extension/web-extensions-running.d.ts +20 -1
  234. package/lib/browser/extension/web-extensions-running.js +107 -9
  235. package/lib/browser/extension/web-extensions.js +1 -0
  236. package/lib/browser/extension/web-pages.d.ts +5 -0
  237. package/lib/browser/extension/web-pages.js +3 -0
  238. package/lib/browser/game/game-control.d.ts +6 -0
  239. package/lib/browser/game/game-control.js +28 -0
  240. package/lib/browser/game/game-host.d.ts +9 -2
  241. package/lib/browser/game/game-host.js +5 -1
  242. package/lib/browser/game/game-protocol.d.ts +8 -0
  243. package/lib/browser/game/game-runner.d.ts +7 -1
  244. package/lib/browser/game/game-runner.js +24 -2
  245. package/lib/browser/game/game-target.d.ts +23 -0
  246. package/lib/browser/game/game-target.js +87 -0
  247. package/lib/browser/game/game-util.d.ts +2 -0
  248. package/lib/browser/game/game-util.js +2 -0
  249. package/lib/browser/game/game-view.d.ts +5 -2
  250. package/lib/browser/game/game-view.js +4 -4
  251. package/lib/browser/game/game3d-protocol.d.ts +3 -1
  252. package/lib/browser/game/game3d-runner.d.ts +6 -1
  253. package/lib/browser/game/game3d-runner.js +26 -2
  254. package/lib/browser/i18n/en/chat.d.ts +4 -0
  255. package/lib/browser/i18n/en/chat.js +4 -0
  256. package/lib/browser/i18n/en/common.d.ts +1 -0
  257. package/lib/browser/i18n/en/common.js +1 -0
  258. package/lib/browser/i18n/en/discover.d.ts +11 -0
  259. package/lib/browser/i18n/en/discover.js +11 -0
  260. package/lib/browser/i18n/en/settings.d.ts +43 -0
  261. package/lib/browser/i18n/en/settings.js +43 -0
  262. package/lib/browser/i18n/ja/chat.js +4 -0
  263. package/lib/browser/i18n/ja/common.js +1 -0
  264. package/lib/browser/i18n/ja/discover.js +11 -0
  265. package/lib/browser/i18n/ja/settings.js +43 -0
  266. package/lib/browser/i18n/locales.d.ts +60 -3
  267. package/lib/browser/i18n/messages.d.ts +59 -2
  268. package/lib/browser/i18n/zh/chat.js +4 -0
  269. package/lib/browser/i18n/zh/common.js +1 -0
  270. package/lib/browser/i18n/zh/discover.js +11 -0
  271. package/lib/browser/i18n/zh/settings.js +43 -0
  272. package/lib/browser/i18n/zh-tw/chat.js +4 -0
  273. package/lib/browser/i18n/zh-tw/common.js +1 -0
  274. package/lib/browser/i18n/zh-tw/discover.js +11 -0
  275. package/lib/browser/i18n/zh-tw/settings.js +43 -0
  276. package/lib/browser/index.d.ts +3 -0
  277. package/lib/browser/index.js +3 -0
  278. package/lib/browser/notices/notices.js +1 -0
  279. package/lib/browser/sandbox/channel/channel.d.ts +57 -0
  280. package/lib/browser/sandbox/channel/channel.js +128 -0
  281. package/lib/browser/sandbox/channel/codec.d.ts +81 -0
  282. package/lib/browser/sandbox/channel/codec.js +256 -0
  283. package/lib/browser/sandbox/hook-host.d.ts +24 -0
  284. package/lib/browser/sandbox/hook-host.js +98 -0
  285. package/lib/browser/sandbox/isolated-host.d.ts +106 -0
  286. package/lib/browser/sandbox/isolated-host.js +432 -0
  287. package/lib/browser/sandbox/remote/remote-copy.d.ts +58 -0
  288. package/lib/browser/sandbox/remote/remote-copy.js +322 -0
  289. package/lib/browser/sandbox/remote/remote-mirror.d.ts +62 -0
  290. package/lib/browser/sandbox/remote/remote-mirror.js +345 -0
  291. package/lib/browser/sandbox/remote/remote-protocol.d.ts +80 -0
  292. package/lib/browser/sandbox/remote/remote-protocol.js +57 -0
  293. package/lib/browser/sandbox/remote/remote-styles.d.ts +11 -0
  294. package/lib/browser/sandbox/remote/remote-styles.js +116 -0
  295. package/lib/browser/sandbox/remote-root.d.ts +12 -0
  296. package/lib/browser/sandbox/remote-root.js +117 -0
  297. package/lib/browser/sandbox/runtime/frame-api.d.ts +29 -0
  298. package/lib/browser/sandbox/runtime/frame-api.js +183 -0
  299. package/lib/browser/sandbox/runtime/frame-features.d.ts +7 -0
  300. package/lib/browser/sandbox/runtime/frame-features.js +53 -0
  301. package/lib/browser/sandbox/runtime/frame-parts.d.ts +37 -0
  302. package/lib/browser/sandbox/runtime/frame-parts.js +106 -0
  303. package/lib/browser/sandbox/runtime/frame-roots.d.ts +27 -0
  304. package/lib/browser/sandbox/runtime/frame-roots.js +113 -0
  305. package/lib/browser/sandbox/runtime/frame-store.d.ts +10 -0
  306. package/lib/browser/sandbox/runtime/frame-store.js +22 -0
  307. package/lib/browser/sandbox/runtime/sandbox-runtime.d.ts +12 -0
  308. package/lib/browser/sandbox/runtime/sandbox-runtime.js +47 -0
  309. package/lib/browser/sandbox/sandbox-features.d.ts +26 -0
  310. package/lib/browser/sandbox/sandbox-features.js +35 -0
  311. package/lib/browser/sandbox/sandbox-frame.d.ts +22 -0
  312. package/lib/browser/sandbox/sandbox-frame.js +79 -0
  313. package/lib/browser/sandbox/sandbox-guards.d.ts +20 -0
  314. package/lib/browser/sandbox/sandbox-guards.js +77 -0
  315. package/lib/browser/sandbox/sandbox-protocol.d.ts +58 -0
  316. package/lib/browser/sandbox/sandbox-protocol.js +52 -0
  317. package/lib/browser/sandbox/sandbox-runtime-code.d.ts +2 -0
  318. package/lib/browser/sandbox/sandbox-runtime-code.js +6 -0
  319. package/lib/browser/sandbox/web-sandbox.d.ts +29 -0
  320. package/lib/browser/sandbox/web-sandbox.js +47 -0
  321. package/lib/browser/settings/agent-settings.js +5 -1
  322. package/lib/browser/settings/settings-protocol.d.ts +2 -0
  323. package/lib/browser/settings/settings-protocol.js +2 -0
  324. package/lib/browser/style/pages.d.ts +1 -1
  325. package/lib/browser/style/pages.js +2 -0
  326. package/lib/browser/style/surfaces.d.ts +1 -1
  327. package/lib/browser/style/surfaces.js +4 -0
  328. package/lib/browser/style/tints.d.ts +2 -0
  329. package/lib/browser/style/tints.js +10 -0
  330. package/lib/browser/targets/targets-protocol.d.ts +55 -0
  331. package/lib/browser/targets/targets-protocol.js +37 -0
  332. package/lib/browser/targets/targets.d.ts +14 -0
  333. package/lib/browser/targets/targets.js +67 -0
  334. package/lib/browser/util/composer.d.ts +4 -2
  335. package/lib/browser/util/composer.js +7 -1
  336. package/lib/browser/util/desktop.d.ts +31 -1
  337. package/lib/browser/util/desktop.js +20 -0
  338. package/lib/browser/util/message.d.ts +6 -0
  339. package/lib/browser/util/message.js +21 -0
  340. package/lib/browser/util/process.d.ts +1 -0
  341. package/lib/browser/util/process.js +6 -1
  342. package/lib/browser/util/progress.d.ts +2 -1
  343. package/lib/browser/util/progress.js +2 -11
  344. package/lib/browser/view.js +2 -2
  345. package/package.json +8 -8
@@ -9,14 +9,19 @@ var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  };
10
10
  import { Autowired, Optional, PostConstruct } from '@celljs/core';
11
11
  import { TaFiles } from '../files/files-protocol.js';
12
+ import { message } from '../i18n/messages.js';
12
13
  import { TaLinks } from '../links/links-protocol.js';
13
14
  import { TaNotices } from '../notices/notices-protocol.js';
14
15
  import { TaSessionNotices } from '../notices/session-notices.js';
15
16
  import { deviceValues } from '../offline/device-values.js';
17
+ import { SandboxOptionsUtil } from '../sandbox/sandbox-protocol.js';
18
+ import { WebSandbox } from '../sandbox/web-sandbox.js';
16
19
  import { TaScreen } from '../screen/screen-protocol.js';
17
20
  import { TaSettings } from '../settings/settings-protocol.js';
18
21
  import { TaState } from '../state/state-protocol.js';
22
+ import { TaTargets } from '../targets/targets-protocol.js';
19
23
  import { TaWorkbench } from '../workbench-protocol.js';
24
+ import { WebAccessUtil } from './web-access.js';
20
25
  import { WebEditorTabs } from './web-editor-tabs.js';
21
26
  import { WebExtensionCode } from './web-extension-code.js';
22
27
  import { BuiltinWebExtension, WebExtensionsStateUtil, } from './web-extension-protocol.js';
@@ -64,6 +69,9 @@ export class WebExtensionsRunning {
64
69
  /** The extensions of the list of the last time have started (startKept), once. */
65
70
  this.keptStarted = false;
66
71
  this.pageList = new WebPageList();
72
+ /** Versions the user did not allow in this page (`<id>:<hash>`): not asked again until it loads again or they change. */
73
+ this.refused = new Set();
74
+ this.asking = new Map();
67
75
  }
68
76
  get state() {
69
77
  return this.current;
@@ -94,13 +102,19 @@ export class WebExtensionsRunning {
94
102
  return WebPagesUtil.listedKinds([...this.current.onOpen.map(entry => entry.info), ...[...this.running.values()].map(run => run.loaded.info)]);
95
103
  }
96
104
  /** Loads and starts an extension started on open, as reconcile starts the others. */
97
- async launch(info) {
98
- var _a;
105
+ async launch(asked) {
106
+ var _a, _b;
107
+ const info = await this.allow(asked);
108
+ if (!info) {
109
+ return;
110
+ }
99
111
  const load = await this.loadPackage(info);
100
112
  // Gone or changed meanwhile: the next refresh has it.
101
113
  if (((_a = this.onDemand.get(info.id)) === null || _a === void 0 ? void 0 : _a.hash) === info.hash && !this.running.has(info.id)) {
102
114
  this.startPackage(info, load);
103
115
  this.publish();
116
+ // One in a sandbox registers its pages as it starts: they are there to show once it did.
117
+ await ('factory' in load ? (_b = load.factory.ready) === null || _b === void 0 ? void 0 : _b.catch(() => undefined) : undefined);
104
118
  }
105
119
  }
106
120
  /** Stops one started on open: it is still listed, to start again; its page, if shown, gives way to the conversation. */
@@ -150,8 +164,13 @@ export class WebExtensionsRunning {
150
164
  void this.code.keepOnly(infos.map(info => info.hash));
151
165
  // Those started on open wait to be opened (ta-launcher.md).
152
166
  this.onDemand.set(infos.filter(info => info.activation === 'open'));
153
- // Fetched together, started in the order of the list: the order of their views stays the same.
154
- const starting = infos.filter(info => { var _a; return ((_a = this.running.get(info.id)) === null || _a === void 0 ? void 0 : _a.hash) !== info.hash && info.activation !== 'open'; });
167
+ // Fetched together, started in the order of the list: the order of their views stays the same. One the user
168
+ // has not allowed (docs/design/ta-extension-access.md) waits to be asked; allowed, the list has it next time.
169
+ const differ = infos.filter(info => !this.same(this.running.get(info.id), info) && info.activation !== 'open');
170
+ const starting = differ.filter(info => WebAccessUtil.granted(info) !== undefined);
171
+ for (const info of differ.filter(waiting => WebAccessUtil.granted(waiting) === undefined)) {
172
+ void this.allow(info).then(allowed => allowed && this.refresh());
173
+ }
155
174
  const loads = await Promise.all(starting.map(info => this.loadPackage(info)));
156
175
  // Stopped only now, just before the new code starts: the views of the old one stay drawn until the next
157
176
  // publish, and stopped while the new code is read (after an update, over the relay) they would show
@@ -161,7 +180,7 @@ export class WebExtensionsRunning {
161
180
  return true;
162
181
  }
163
182
  const info = fresh.get(run.loaded.id);
164
- if (info && info.hash === run.hash) {
183
+ if (info && this.same(run, info)) {
165
184
  // Started from the list of the last time: what else it says is of now.
166
185
  run.loaded = { ...run.loaded, info };
167
186
  return true;
@@ -190,10 +209,12 @@ export class WebExtensionsRunning {
190
209
  return false;
191
210
  }
192
211
  this.keptStarted = true;
193
- const infos = this.code.list(host).filter(info => info.enabled !== false && info.activation !== 'open' && !this.running.has(info.id));
212
+ const infos = this.code
213
+ .list(host)
214
+ .filter(info => info.enabled !== false && info.activation !== 'open' && !this.running.has(info.id) && WebAccessUtil.granted(info) !== undefined);
194
215
  const loads = await Promise.all(infos.map(async (info) => {
195
216
  const code = await this.code.get(info.hash);
196
- return code === undefined ? undefined : WebExtensionUtil.load(code).catch(() => undefined);
217
+ return code === undefined ? undefined : this.factoryOf(info, code).catch(() => undefined);
197
218
  }));
198
219
  let started = false;
199
220
  for (const [index, info] of infos.entries()) {
@@ -208,6 +229,55 @@ export class WebExtensionsRunning {
208
229
  }
209
230
  return started;
210
231
  }
232
+ /** Whether what runs is that of the list: the same code, allowed as much. */
233
+ same(run, info) {
234
+ return !!run && run.hash === info.hash && WebAccessUtil.granted(run.loaded.info) === WebAccessUtil.granted(info);
235
+ }
236
+ /**
237
+ * It as it may start: allowed already, or allowed by the user now (docs/design/ta-extension-access.md); undefined
238
+ * when they did not allow it. Asked once at a time, and not again in this page once refused.
239
+ */
240
+ async allow(info) {
241
+ var _a;
242
+ if (WebAccessUtil.granted(info) !== undefined) {
243
+ return info;
244
+ }
245
+ const key = `${info.id}:${info.hash}`;
246
+ // Trusted only as far as a web page (3.6): not asked, its row in the list says why.
247
+ if (info.held || this.refused.has(key)) {
248
+ return undefined;
249
+ }
250
+ const asked = (_a = this.asking.get(key)) !== null && _a !== void 0 ? _a : this.askAccess(info).finally(() => this.asking.delete(key));
251
+ this.asking.set(key, asked);
252
+ return (await asked) ? { ...info, granted: info.access } : undefined;
253
+ }
254
+ async askAccess(info) {
255
+ var _a;
256
+ const language = this.settings.state.language;
257
+ const say = (id) => message(language, id);
258
+ const access = (_a = info.access) !== null && _a !== void 0 ? _a : 'full';
259
+ const yes = await this.notices.confirm({
260
+ title: say('ta.access.ask').replace('{name}', WebPagesUtil.title(info, language)),
261
+ message: [
262
+ say(info.regrant ? 'ta.access.updated' : 'ta.access.new'),
263
+ say(`ta.access.${access}`),
264
+ say('ta.access.from').replace('{source}', WebAccessUtil.source(info, say)),
265
+ ].join('\n'),
266
+ confirmLabel: say('ta.access.allow'),
267
+ });
268
+ if (!yes) {
269
+ this.refused.add(`${info.id}:${info.hash}`);
270
+ return false;
271
+ }
272
+ try {
273
+ await this.workbench.packages.grantAccess(info.id, access);
274
+ return true;
275
+ }
276
+ catch (error) {
277
+ this.notices.notify(say('ta.access.failed'), { level: 'error', detail: error instanceof Error ? error.message : String(error) });
278
+ return false;
279
+ }
280
+ }
211
281
  /** Stops and forgets the extensions running that `keep` does not keep; whether there were any. */
212
282
  stopUnless(keep) {
213
283
  let stopped = false;
@@ -225,11 +295,11 @@ export class WebExtensionsRunning {
225
295
  try {
226
296
  const kept = await this.code.get(info.hash);
227
297
  if (kept !== undefined) {
228
- return { factory: await WebExtensionUtil.load(kept), hash: info.hash };
298
+ return { factory: await this.factoryOf(info, kept), hash: info.hash };
229
299
  }
230
300
  const { code, hash } = await this.workbench.packages.readWebExtension(info.id);
231
301
  void this.code.set(hash, code);
232
- const factory = await WebExtensionUtil.load(code);
302
+ const factory = await this.factoryOf(info, code);
233
303
  // Read from the computer: what the user waits for the first time (kept code is quick).
234
304
  this.metrics.record(info.name, 'web:load', false, performance.now() - start);
235
305
  return { factory, hash };
@@ -239,6 +309,20 @@ export class WebExtensionsRunning {
239
309
  return { error: WebExtensionUtil.message(error) };
240
310
  }
241
311
  }
312
+ /**
313
+ * What starts an extension: its module, imported into the page; or, for one the user allowed less than all, its code
314
+ * to run in a sandbox, never imported here (docs/design/ta-extension-access.md 3).
315
+ */
316
+ async factoryOf(info, code) {
317
+ const granted = WebAccessUtil.granted(info);
318
+ if (!WebSandbox.applies(info, granted)) {
319
+ return WebExtensionUtil.load(code);
320
+ }
321
+ return WebSandbox.factory(code, info, granted, {
322
+ options: this.persisted.get(SandboxOptionsUtil.SPEC),
323
+ changes: listener => this.settings.subscribe(() => listener()),
324
+ });
325
+ }
242
326
  startPackage(info, load) {
243
327
  const loaded = { id: info.id, name: info.name, info };
244
328
  if ('error' in load) {
@@ -249,6 +333,7 @@ export class WebExtensionsRunning {
249
333
  }
250
334
  }
251
335
  start(loaded, factory, hash) {
336
+ var _a;
252
337
  const run = WebExtensionRunUtil.create(loaded, hash);
253
338
  this.running.set(loaded.id, run);
254
339
  try {
@@ -256,6 +341,15 @@ export class WebExtensionsRunning {
256
341
  run.dispose = typeof dispose === 'function' ? dispose : undefined;
257
342
  run.started = true;
258
343
  this.metrics.record(loaded.id, 'web:start');
344
+ // One in a sandbox that could not start says why where it is listed, as one that threw (3.7).
345
+ (_a = factory.ready) === null || _a === void 0 ? void 0 : _a.catch(error => {
346
+ if (this.running.get(loaded.id) === run && !run.stopped) {
347
+ this.metrics.record(loaded.id, 'web:start', true);
348
+ this.stop(run);
349
+ run.loaded = { ...loaded, error: WebExtensionUtil.message(error) };
350
+ this.publish();
351
+ }
352
+ });
259
353
  }
260
354
  catch (error) {
261
355
  this.metrics.record(loaded.id, 'web:start', true);
@@ -341,6 +435,10 @@ __decorate([
341
435
  Autowired(TaScreen),
342
436
  __metadata("design:type", Object)
343
437
  ], WebExtensionsRunning.prototype, "screen", void 0);
438
+ __decorate([
439
+ Autowired(TaTargets),
440
+ __metadata("design:type", Object)
441
+ ], WebExtensionsRunning.prototype, "targets", void 0);
344
442
  __decorate([
345
443
  Autowired(BuiltinWebExtension),
346
444
  Optional(),
@@ -259,6 +259,7 @@ let TaWebExtensionsImpl = class TaWebExtensionsImpl extends WebExtensionsRunning
259
259
  sessionNotices: this.sessionNotices,
260
260
  persisted: this.persisted,
261
261
  screen: this.screen,
262
+ targets: this.targets,
262
263
  };
263
264
  }
264
265
  };
@@ -17,6 +17,11 @@ export interface WebPageInfo {
17
17
  extension: string;
18
18
  title: string;
19
19
  icon?: WebIcon;
20
+ /**
21
+ * The colour of its tile, `--ta-tint-<tint>` and `--ta-tint-ink-<tint>` of the theme, the same for every page of its
22
+ * extension: the launcher's tile and the icon of its app (docs/design/ta-install-as-app.md). Newer than some Ta apps.
23
+ */
24
+ tint?: number;
20
25
  state: WebPageState;
21
26
  /** Its extension starts when it opens (`pi.webActivation`, or temporary): it is never in the navigation. */
22
27
  onOpen: boolean;
@@ -1,4 +1,5 @@
1
1
  import { TA_PAGES_USED, TaPackageTextUtil } from '@celljs/ta-protocol';
2
+ import { TintUtil } from '../style/tints.js';
2
3
  import { WEB_ICONS } from './icons.js';
3
4
  import { WebLabelUtil } from './web-extension-protocol.js';
4
5
  export var WebPagesUtil;
@@ -68,6 +69,7 @@ export var WebPagesUtil;
68
69
  extension: view.id.slice(0, view.id.lastIndexOf('/')),
69
70
  title: WebLabelUtil.text(view.title),
70
71
  icon: view.icon,
72
+ tint: TintUtil.of(view.id.slice(0, view.id.lastIndexOf('/'))),
71
73
  state: view.id === shown ? 'shown' : 'running',
72
74
  onOpen: false,
73
75
  place: placeOf(view),
@@ -83,6 +85,7 @@ export var WebPagesUtil;
83
85
  extension: info.name,
84
86
  title: title(info, language, first ? WebLabelUtil.text(first.title) : undefined),
85
87
  icon: (_a = (info.icon ? WEB_ICONS[info.icon] : undefined)) !== null && _a !== void 0 ? _a : first === null || first === void 0 ? void 0 : first.icon,
88
+ tint: TintUtil.of(info.name),
86
89
  state: isShown ? 'shown' : background ? 'background' : running ? 'running' : 'stopped',
87
90
  onOpen: true,
88
91
  place: info.temporary ? 'launcher' : listed(info, kinds) ? 'list' : 'discover',
@@ -93,6 +93,12 @@ export declare class GameControl {
93
93
  press(at: GamePoint, ms: number): Promise<void>;
94
94
  /** Presses a key for `ms`, on the game's element. */
95
95
  key(key: GameKey, ms?: number): Promise<void>;
96
+ /** Half a tap, the pointer pressed (`down`) or let go there: for a program that times its own presses. */
97
+ pointerPress(at: GamePoint, down: boolean): void;
98
+ /** The pointer moved by `dx`, `dy` CSS pixels where it is, as a locked pointer turns a view (`movementX`, `movementY`). */
99
+ nudge(dx: number, dy: number): void;
100
+ /** Half a key press, down or up, on the game's element. */
101
+ keyPress(key: GameKey, down: boolean): void;
96
102
  /** Where Ta's pointer is on the canvas, once it was there. */
97
103
  get at(): GamePoint | undefined;
98
104
  /**
@@ -185,6 +185,34 @@ export class GameControl {
185
185
  this.keyEvent('keyup', key);
186
186
  }
187
187
  }
188
+ /** Half a tap, the pointer pressed (`down`) or let go there: for a program that times its own presses. */
189
+ pointerPress(at, down) {
190
+ if (down) {
191
+ this.down(at);
192
+ }
193
+ else {
194
+ this.up(at, true);
195
+ }
196
+ }
197
+ /** The pointer moved by `dx`, `dy` CSS pixels where it is, as a locked pointer turns a view (`movementX`, `movementY`). */
198
+ nudge(dx, dy) {
199
+ var _a, _b;
200
+ const at = (_a = this.last) !== null && _a !== void 0 ? _a : { x: 0.5, y: 0.5 };
201
+ const canvas = this.canvas();
202
+ const view = this.view();
203
+ const init = { ...this.init(canvas, at, 0), movementX: dx, movementY: dy };
204
+ canvas.dispatchEvent(new ((_b = view.PointerEvent) !== null && _b !== void 0 ? _b : view.MouseEvent)('pointermove', {
205
+ ...init,
206
+ pointerId: GameControlUtil.POINTER_ID,
207
+ pointerType: 'mouse',
208
+ isPrimary: true,
209
+ }));
210
+ canvas.dispatchEvent(new view.MouseEvent('mousemove', init));
211
+ }
212
+ /** Half a key press, down or up, on the game's element. */
213
+ keyPress(key, down) {
214
+ this.keyEvent(down ? 'keydown' : 'keyup', key);
215
+ }
188
216
  /** Where Ta's pointer is on the canvas, once it was there. */
189
217
  get at() {
190
218
  return this.last;
@@ -1,7 +1,8 @@
1
1
  import * as React from 'react';
2
2
  import { type TaScreen } from '../screen/screen-protocol.js';
3
3
  import type { TaSettings } from '../settings/settings-protocol.js';
4
- import type { GamePage, GameState } from './game-protocol.js';
4
+ import type { TaTargets } from '../targets/targets-protocol.js';
5
+ import type { GameObservation, GamePage, GameState } from './game-protocol.js';
5
6
  /** What GameHost drives of a game of either engine (GameRunner, Game3DRunner). */
6
7
  export interface GameHostRunner {
7
8
  setPage(page: GamePage): void;
@@ -12,6 +13,10 @@ export interface GameHostRunner {
12
13
  readonly sleeping?: boolean;
13
14
  /** What the game says of its round (GameState). */
14
15
  state?(): GameState | undefined;
16
+ /** What is in it now, for a program that plays it (GameObservation). */
17
+ observe?(): GameObservation | undefined;
18
+ /** Waits for a slow player, and goes on. */
19
+ setPaused?(paused: boolean): void;
15
20
  dispose(): void;
16
21
  }
17
22
  /** Starts the game in `element` once its engine is loaded; `fail` for what goes wrong after it started. */
@@ -23,6 +28,8 @@ export interface GameHostProps {
23
28
  title?: string;
24
29
  /** The screen it is a part of, for Ta to see and play it; none on a page Ta does not work (a shared page). */
25
30
  screen?: TaScreen;
31
+ /** The targets of the page, for a program to play it frame by frame (docs/design/ta-reflex.md); none where none plays. */
32
+ targets?: TaTargets;
26
33
  className?: string;
27
34
  style?: React.CSSProperties;
28
35
  }
@@ -36,4 +43,4 @@ export interface GameHostProps {
36
43
  * It is a part of the screen (`game`, GameControl): Ta sees how it stands and taps, moves, presses keys and holds on it
37
44
  * for the user, by events on its canvas that no gesture of the shell starts from.
38
45
  */
39
- export declare function GameHost({ settings: store, start, title, screen, className, style }: GameHostProps): React.JSX.Element;
46
+ export declare function GameHost({ settings: store, start, title, screen, targets, className, style }: GameHostProps): React.JSX.Element;
@@ -6,6 +6,7 @@ import { OwnGestures } from '../device/own-gestures.js';
6
6
  import { useT } from '../i18n/use-t.js';
7
7
  import { ScreenUtil } from '../screen/screen-protocol.js';
8
8
  import { GameControl, GameControlUtil } from './game-control.js';
9
+ import { GameTarget } from './game-target.js';
9
10
  import { GameUtil } from './game-util.js';
10
11
  /**
11
12
  * The element of a game of a web extension (`ui.Game`, `ui.Game3D`): it fills its parent, starts the game
@@ -17,7 +18,7 @@ import { GameUtil } from './game-util.js';
17
18
  * It is a part of the screen (`game`, GameControl): Ta sees how it stands and taps, moves, presses keys and holds on it
18
19
  * for the user, by events on its canvas that no gesture of the shell starts from.
19
20
  */
20
- export function GameHost({ settings: store, start, title, screen, className, style }) {
21
+ export function GameHost({ settings: store, start, title, screen, targets, className, style }) {
21
22
  var _a;
22
23
  const t = useT();
23
24
  const settings = React.useSyncExternalStore(listener => store.subscribe(listener), () => store.state);
@@ -40,6 +41,9 @@ export function GameHost({ settings: store, start, title, screen, className, sty
40
41
  (_a = partId.current) !== null && _a !== void 0 ? _a : (partId.current = GameControlUtil.partId());
41
42
  part.current = GameControl.spec(partId.current, title || t('ta.game.label'), { point: t('ta.game.point'), move: t('ta.game.move'), key: t('ta.game.key'), hold: t('ta.game.hold') }, () => { var _a, _b, _c; return ({ started: !!runner.current, sleeping: (_a = runner.current) === null || _a === void 0 ? void 0 : _a.sleeping, error: errorOf.current, state: (_c = (_b = runner.current) === null || _b === void 0 ? void 0 : _b.state) === null || _c === void 0 ? void 0 : _c.call(_b) }); }, () => control.current);
42
43
  React.useEffect(() => screen === null || screen === void 0 ? void 0 : screen.register(() => part.current), [screen]);
44
+ const named = React.useRef(title);
45
+ named.current = title || t('ta.game.label');
46
+ React.useEffect(() => targets === null || targets === void 0 ? void 0 : targets.register(GameTarget.spec(partId.current, () => named.current, () => runner.current, () => control.current)), [targets]);
43
47
  React.useEffect(() => {
44
48
  const element = host.current;
45
49
  if (!element) {
@@ -1,3 +1,4 @@
1
+ import type { TargetObservation } from '@celljs/ta-protocol';
1
2
  import type * as PhaserModule from 'phaser';
2
3
  import type { Theme } from '../settings/settings-protocol.js';
3
4
  /**
@@ -43,6 +44,13 @@ export interface GameState {
43
44
  score?: number;
44
45
  over?: boolean;
45
46
  }
47
+ /**
48
+ * What is in a game now, for a program to play it frame by frame (docs/design/ta-reflex.md 4): its things as entities
49
+ * (`{ id, type, box }`, a box from 0 to 1 across and down the canvas, as the player sees it) and what else it says
50
+ * (`data`: the score, the round). A Phaser game sets a function giving it in its registry (GameUtil.OBSERVE_KEY), a
51
+ * 3D one returns it from `observe` of its loop. Read every frame while a program plays: cheap, no allocation it can spare.
52
+ */
53
+ export type GameObservation = Omit<TargetObservation, 't'>;
46
54
  /** A point of the canvas: `x` 0 at its left and 1 at its right, `y` 0 at its top and 1 at its bottom (GameControl). */
47
55
  export interface GamePoint {
48
56
  x: number;
@@ -1,4 +1,4 @@
1
- import type { GameConfig, GameEngine, GameInstance, GamePage, GameState } from './game-protocol.js';
1
+ import type { GameConfig, GameEngine, GameInstance, GameObservation, GamePage, GameState } from './game-protocol.js';
2
2
  /**
3
3
  * One game in an element of the page, from its start to its end: Phaser's Game made with the config of the
4
4
  * extension (GameUtil.config), asleep while the element is out of sight, destroyed with it.
@@ -12,15 +12,21 @@ export declare class GameRunner {
12
12
  readonly game: GameInstance;
13
13
  protected page?: GamePage;
14
14
  protected asleep: boolean;
15
+ protected paused: boolean;
15
16
  protected disposed: boolean;
16
17
  constructor(engine: GameEngine, config: GameConfig, element: HTMLElement, page: GamePage, fail?: (error: unknown) => void);
17
18
  /** Sets the page in the game's registry when it changed: scenes hear `changedata-page`. */
18
19
  setPage(page: GamePage): void;
19
20
  /** What the game set of its round in its registry (GameUtil.SCORE_KEY, GameUtil.OVER_KEY). */
20
21
  state(): GameState | undefined;
22
+ /** What the game says is in it now (GameUtil.OBSERVE_KEY); nothing when it says nothing or that throws. */
23
+ observe(): GameObservation | undefined;
21
24
  get sleeping(): boolean;
22
25
  /** Whether the element can be seen: the game sleeps while not. */
23
26
  setVisible(visible: boolean): void;
27
+ /** Waits for a slow player (a program's commander thinking): asleep as out of sight, till it goes on. */
28
+ setPaused(paused: boolean): void;
29
+ protected apply(): void;
24
30
  /**
25
31
  * Destroys the game and takes its canvas out. Phaser destroys it at the end of its next frame: a loop
26
32
  * asleep is woken for it, and a game not booted yet is destroyed as it boots.
@@ -12,6 +12,7 @@ export class GameRunner {
12
12
  constructor(engine, config, element, page, fail) {
13
13
  this.element = element;
14
14
  this.asleep = false;
15
+ this.paused = false;
15
16
  this.disposed = false;
16
17
  this.game = new engine.Game(GameUtil.config(engine, config, element, fail));
17
18
  this.setPage(page);
@@ -29,6 +30,16 @@ export class GameRunner {
29
30
  const { registry } = this.game;
30
31
  return this.disposed ? undefined : GameControlUtil.state({ score: registry.get(GameUtil.SCORE_KEY), over: registry.get(GameUtil.OVER_KEY) });
31
32
  }
33
+ /** What the game says is in it now (GameUtil.OBSERVE_KEY); nothing when it says nothing or that throws. */
34
+ observe() {
35
+ const observe = this.disposed ? undefined : this.game.registry.get(GameUtil.OBSERVE_KEY);
36
+ try {
37
+ return typeof observe === 'function' ? observe() : undefined;
38
+ }
39
+ catch (_a) {
40
+ return undefined;
41
+ }
42
+ }
32
43
  get sleeping() {
33
44
  return this.asleep;
34
45
  }
@@ -38,8 +49,19 @@ export class GameRunner {
38
49
  return;
39
50
  }
40
51
  this.asleep = !visible;
52
+ this.apply();
53
+ }
54
+ /** Waits for a slow player (a program's commander thinking): asleep as out of sight, till it goes on. */
55
+ setPaused(paused) {
56
+ if (this.disposed || paused === this.paused) {
57
+ return;
58
+ }
59
+ this.paused = paused;
60
+ this.apply();
61
+ }
62
+ apply() {
41
63
  const { loop, sound } = this.game;
42
- if (this.asleep) {
64
+ if (this.asleep || this.paused) {
43
65
  loop.sleep();
44
66
  sound === null || sound === void 0 ? void 0 : sound.pauseAll();
45
67
  }
@@ -58,7 +80,7 @@ export class GameRunner {
58
80
  }
59
81
  this.disposed = true;
60
82
  this.game.destroy(true);
61
- if (this.asleep && this.game.isRunning) {
83
+ if ((this.asleep || this.paused) && this.game.isRunning) {
62
84
  this.game.loop.wake();
63
85
  }
64
86
  }
@@ -0,0 +1,22 @@
1
+ import type { TargetAction } from '@celljs/ta-protocol';
2
+ import type { TargetSpec } from '../targets/targets-protocol.js';
3
+ import { type GameControl } from './game-control.js';
4
+ import type { GameObservation, GameState } from './game-protocol.js';
5
+ /** What GameTarget reads of a game while it runs: none before it started or after it ended. */
6
+ export interface GameTargetRunner {
7
+ observe?(): GameObservation | undefined;
8
+ state?(): GameState | undefined;
9
+ setPaused?(paused: boolean): void;
10
+ }
11
+ /**
12
+ * A game as a target (docs/design/ta-reflex.md 4): what it says is in it (GameObservation, its score and round besides),
13
+ * and the actions of every target done by its hands (GameControl), at once: a tap's release and a key's come after,
14
+ * by a timer, so that a program never waits on them.
15
+ */
16
+ export declare namespace GameTarget {
17
+ const HZ = 60;
18
+ function spec(id: string, title: () => string, runner: () => GameTargetRunner | undefined, control: () => GameControl | undefined): TargetSpec;
19
+ function observation(runner: GameTargetRunner | undefined): GameObservation;
20
+ /** One action of the vocabulary of targets on the game; throws for one it cannot take, as its part does. */
21
+ function act(hands: GameControl, action: TargetAction, later?: (run: () => void, ms: number) => void): void;
22
+ }
@@ -0,0 +1,84 @@
1
+ import { GameControlUtil } from './game-control.js';
2
+ const clamp = (value) => Math.min(1, Math.max(0, value));
3
+ /**
4
+ * A game as a target (docs/design/ta-reflex.md 4): what it says is in it (GameObservation, its score and round besides),
5
+ * and the actions of every target done by its hands (GameControl), at once: a tap's release and a key's come after,
6
+ * by a timer, so that a program never waits on them.
7
+ */
8
+ export var GameTarget;
9
+ (function (GameTarget) {
10
+ GameTarget.HZ = 60;
11
+ function spec(id, title, runner, control) {
12
+ return {
13
+ id,
14
+ kind: 'game',
15
+ title,
16
+ tier: 'state',
17
+ actions: ['pointer', 'key'],
18
+ hz: GameTarget.HZ,
19
+ describe: 'entities: what the game shows, each {id, type, box: {x, y, w, h} from 0 to 1 across and down the canvas}; data: its score, its round, what else it says',
20
+ observe: () => observation(runner()),
21
+ act: actions => {
22
+ const hands = control();
23
+ if (hands && runner()) {
24
+ for (const action of actions) {
25
+ act(hands, action);
26
+ }
27
+ }
28
+ },
29
+ pause: () => { var _a, _b; return (_b = (_a = runner()) === null || _a === void 0 ? void 0 : _a.setPaused) === null || _b === void 0 ? void 0 : _b.call(_a, true); },
30
+ resume: () => { var _a, _b; return (_b = (_a = runner()) === null || _a === void 0 ? void 0 : _a.setPaused) === null || _b === void 0 ? void 0 : _b.call(_a, false); },
31
+ };
32
+ }
33
+ GameTarget.spec = spec;
34
+ function observation(runner) {
35
+ var _a, _b;
36
+ var _c;
37
+ const seen = (_a = runner === null || runner === void 0 ? void 0 : runner.observe) === null || _a === void 0 ? void 0 : _a.call(runner);
38
+ const state = (_b = runner === null || runner === void 0 ? void 0 : runner.state) === null || _b === void 0 ? void 0 : _b.call(runner);
39
+ const data = { ...(state !== null && state !== void 0 ? state : {}), ...((_c = seen === null || seen === void 0 ? void 0 : seen.data) !== null && _c !== void 0 ? _c : {}) };
40
+ return { ...((seen === null || seen === void 0 ? void 0 : seen.entities) ? { entities: seen.entities } : {}), ...(Object.keys(data).length ? { data } : {}) };
41
+ }
42
+ GameTarget.observation = observation;
43
+ /** One action of the vocabulary of targets on the game; throws for one it cannot take, as its part does. */
44
+ function act(hands, action, later = (run, ms) => setTimeout(run, ms)) {
45
+ var _a, _b;
46
+ var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
47
+ if (action.kind === 'pointer') {
48
+ if (action.dx !== undefined || action.dy !== undefined) {
49
+ hands.nudge((_c = action.dx) !== null && _c !== void 0 ? _c : 0, (_d = action.dy) !== null && _d !== void 0 ? _d : 0);
50
+ return;
51
+ }
52
+ const at = action.x === undefined && action.y === undefined
53
+ ? ((_e = hands.at) !== null && _e !== void 0 ? _e : { x: 0.5, y: 0.5 })
54
+ : { x: clamp((_g = (_f = action.x) !== null && _f !== void 0 ? _f : (_a = hands.at) === null || _a === void 0 ? void 0 : _a.x) !== null && _g !== void 0 ? _g : 0.5), y: clamp((_j = (_h = action.y) !== null && _h !== void 0 ? _h : (_b = hands.at) === null || _b === void 0 ? void 0 : _b.y) !== null && _j !== void 0 ? _j : 0.5) };
55
+ const press = (_k = action.press) !== null && _k !== void 0 ? _k : 'click';
56
+ if (press === 'move') {
57
+ void hands.move(at);
58
+ }
59
+ else if (press === 'click') {
60
+ hands.pointerPress(at, true);
61
+ later(() => hands.pointerPress(at, false), GameControlUtil.TAP_MS);
62
+ }
63
+ else {
64
+ hands.pointerPress(at, press === 'down');
65
+ }
66
+ return;
67
+ }
68
+ if (action.kind === 'key') {
69
+ const key = GameControlUtil.key(action.key);
70
+ const press = (_l = action.press) !== null && _l !== void 0 ? _l : 'tap';
71
+ if (press === 'tap') {
72
+ hands.keyPress(key, true);
73
+ later(() => hands.keyPress(key, false), (_m = action.ms) !== null && _m !== void 0 ? _m : GameControlUtil.TAP_MS);
74
+ }
75
+ else {
76
+ hands.keyPress(key, press === 'down');
77
+ }
78
+ return;
79
+ }
80
+ throw new Error(`A game takes pointer and key actions, not ${action.kind}.`);
81
+ }
82
+ GameTarget.act = act;
83
+ })(GameTarget || (GameTarget = {}));
84
+ //# sourceMappingURL=game-target.js.map
@@ -6,6 +6,8 @@ export declare namespace GameUtil {
6
6
  /** The keys of the registry where a game says its score and whether its round is over (GameState): Ta tells the agent. */
7
7
  const SCORE_KEY = "score";
8
8
  const OVER_KEY = "over";
9
+ /** The key of the registry where a game sets a function giving what is in it now (GameObservation). */
10
+ const OBSERVE_KEY = "observe";
9
11
  /**
10
12
  * Phaser's config of a game drawn in `parent`: what the extension gave, over what a game in a page of Ta
11
13
  * needs. It fills `parent` unless sized; its background is the page's unless it has one; it hears the
@@ -31,6 +31,8 @@ export var GameUtil;
31
31
  /** The keys of the registry where a game says its score and whether its round is over (GameState): Ta tells the agent. */
32
32
  GameUtil.SCORE_KEY = 'score';
33
33
  GameUtil.OVER_KEY = 'over';
34
+ /** The key of the registry where a game sets a function giving what is in it now (GameObservation). */
35
+ GameUtil.OBSERVE_KEY = 'observe';
34
36
  /**
35
37
  * Phaser's config of a game drawn in `parent`: what the extension gave, over what a game in a page of Ta
36
38
  * needs. It fills `parent` unless sized; its background is the page's unless it has one; it hears the
@@ -1,15 +1,18 @@
1
1
  import * as React from 'react';
2
2
  import type { TaScreen } from '../screen/screen-protocol.js';
3
3
  import type { TaSettings } from '../settings/settings-protocol.js';
4
+ import type { TaTargets } from '../targets/targets-protocol.js';
4
5
  import type { GameProps } from './game-protocol.js';
5
6
  import type { Game3DProps } from './game3d-protocol.js';
6
7
  /** A game of a web extension on Phaser (`ui.Game`): GameRunner in a GameHost. */
7
- export declare function GameView({ settings, screen, config, onReady, title, className, style }: GameProps & {
8
+ export declare function GameView({ settings, screen, targets, config, onReady, title, className, style, }: GameProps & {
8
9
  settings: TaSettings;
9
10
  screen?: TaScreen;
11
+ targets?: TaTargets;
10
12
  }): React.JSX.Element;
11
13
  /** A 3D game of a web extension on Three.js (`ui.Game3D`): Game3DRunner in a GameHost. */
12
- export declare function Game3DView({ settings, screen, setup, onReady, title, className, style }: Game3DProps & {
14
+ export declare function Game3DView({ settings, screen, targets, setup, onReady, title, className, style, }: Game3DProps & {
13
15
  settings: TaSettings;
14
16
  screen?: TaScreen;
17
+ targets?: TaTargets;
15
18
  }): React.JSX.Element;