@celljs/ta-web 4.42.0 → 4.43.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 (314) hide show
  1. package/README.en.md +1 -1
  2. package/README.md +1 -1
  3. package/esm/browser/apps/web-apps.d.ts +4 -0
  4. package/esm/browser/apps/web-apps.js +14 -3
  5. package/esm/browser/assistant/ta-hearing.d.ts +85 -0
  6. package/esm/browser/assistant/ta-hearing.js +272 -0
  7. package/esm/browser/components/auth-view.js +1 -1
  8. package/esm/browser/components/board.js +9 -1
  9. package/esm/browser/components/clipboard-link-host.d.ts +2 -0
  10. package/esm/browser/components/clipboard-link-host.js +27 -0
  11. package/esm/browser/components/cloud-network.js +1 -1
  12. package/esm/browser/components/cloud-sign-in-view.d.ts +1 -1
  13. package/esm/browser/components/custom-provider-advanced.js +8 -8
  14. package/esm/browser/components/custom-provider-view.js +12 -12
  15. package/esm/browser/components/empty-state.d.ts +2 -1
  16. package/esm/browser/components/empty-state.js +6 -2
  17. package/esm/browser/components/folder-picker.js +2 -2
  18. package/esm/browser/components/gallery.js +8 -9
  19. package/esm/browser/components/hearing-host.d.ts +5 -0
  20. package/esm/browser/components/hearing-host.js +58 -0
  21. package/esm/browser/components/host-view.d.ts +1 -1
  22. package/esm/browser/components/link-dialog.js +4 -0
  23. package/esm/browser/components/loading.d.ts +3 -2
  24. package/esm/browser/components/loading.js +7 -3
  25. package/esm/browser/components/markdown.d.ts +3 -1
  26. package/esm/browser/components/markdown.js +10 -5
  27. package/esm/browser/components/media.d.ts +10 -4
  28. package/esm/browser/components/media.js +60 -14
  29. package/esm/browser/components/people-picker.d.ts +17 -0
  30. package/esm/browser/components/people-picker.js +129 -0
  31. package/esm/browser/components/relay-view.js +1 -1
  32. package/esm/browser/components/settings-parts.js +2 -0
  33. package/esm/browser/components/share-dialog.d.ts +2 -2
  34. package/esm/browser/components/share-dialog.js +7 -4
  35. package/esm/browser/components/share-friends.js +3 -10
  36. package/esm/browser/components/share-item-sheet.d.ts +12 -0
  37. package/esm/browser/components/share-item-sheet.js +39 -0
  38. package/esm/browser/components/share-sheet.d.ts +9 -2
  39. package/esm/browser/components/share-sheet.js +5 -4
  40. package/esm/browser/components/sign-in-setup.js +4 -4
  41. package/esm/browser/components/trusted-domains.js +1 -1
  42. package/esm/browser/components/view-room.d.ts +25 -0
  43. package/esm/browser/components/view-room.js +136 -0
  44. package/esm/browser/components/voice-services.js +6 -6
  45. package/esm/browser/device/device-protocol.d.ts +9 -6
  46. package/esm/browser/device/device-protocol.js +7 -4
  47. package/esm/browser/device/launch-screen.d.ts +11 -1
  48. package/esm/browser/device/launch-screen.js +22 -4
  49. package/esm/browser/extension/share-sheet-compat.d.ts +2 -0
  50. package/esm/browser/extension/share-sheet-compat.js +12 -2
  51. package/esm/browser/extension/web-api-code.d.ts +11 -0
  52. package/esm/browser/extension/web-api-components.d.ts +8 -1
  53. package/esm/browser/extension/web-api-contributions.d.ts +30 -1
  54. package/esm/browser/extension/web-api-desktop.d.ts +2 -1
  55. package/esm/browser/extension/web-api-file-views.d.ts +38 -0
  56. package/esm/browser/extension/web-api-file-views.js +2 -0
  57. package/esm/browser/extension/web-api-host.d.ts +47 -0
  58. package/esm/browser/extension/web-api-host.js +3 -0
  59. package/esm/browser/extension/web-api-menus.d.ts +46 -0
  60. package/esm/browser/extension/web-api-partners.d.ts +58 -1
  61. package/esm/browser/extension/web-api-spec.js +7 -0
  62. package/esm/browser/extension/web-extension-api.d.ts +10 -10
  63. package/esm/browser/extension/web-extension-context.d.ts +2 -8
  64. package/esm/browser/extension/web-extension-context.js +14 -39
  65. package/esm/browser/extension/web-extension-marks.d.ts +10 -0
  66. package/esm/browser/extension/web-extension-marks.js +29 -0
  67. package/esm/browser/extension/web-extension-protocol.d.ts +11 -1
  68. package/esm/browser/extension/web-extension-protocol.js +3 -0
  69. package/esm/browser/extension/web-extension-run.d.ts +15 -2
  70. package/esm/browser/extension/web-extension-run.js +77 -0
  71. package/esm/browser/extension/web-extensions-running.d.ts +5 -1
  72. package/esm/browser/extension/web-extensions-running.js +16 -0
  73. package/esm/browser/extension/web-extensions.d.ts +2 -1
  74. package/esm/browser/extension/web-extensions.js +3 -0
  75. package/esm/browser/extension/web-home.js +3 -1
  76. package/esm/browser/extension/web-host-values.d.ts +66 -0
  77. package/esm/browser/extension/web-host-values.js +191 -0
  78. package/esm/browser/extension/web-hosts.d.ts +7 -2
  79. package/esm/browser/extension/web-hosts.js +16 -4
  80. package/esm/browser/extension/web-share-ui.d.ts +7 -0
  81. package/esm/browser/extension/web-share-ui.js +15 -0
  82. package/esm/browser/extension/web-share.d.ts +18 -0
  83. package/esm/browser/extension/web-share.js +42 -0
  84. package/esm/browser/i18n/en/chat.d.ts +10 -0
  85. package/esm/browser/i18n/en/chat.js +10 -0
  86. package/esm/browser/i18n/en/common.d.ts +18 -0
  87. package/esm/browser/i18n/en/common.js +18 -0
  88. package/esm/browser/i18n/en/discover.d.ts +7 -0
  89. package/esm/browser/i18n/en/discover.js +7 -0
  90. package/esm/browser/i18n/en/settings.d.ts +2 -0
  91. package/esm/browser/i18n/en/settings.js +2 -0
  92. package/esm/browser/i18n/ja/chat.js +10 -0
  93. package/esm/browser/i18n/ja/common.js +18 -0
  94. package/esm/browser/i18n/ja/discover.js +7 -0
  95. package/esm/browser/i18n/ja/settings.js +2 -0
  96. package/esm/browser/i18n/locales.d.ts +38 -1
  97. package/esm/browser/i18n/messages.d.ts +37 -0
  98. package/esm/browser/i18n/zh/chat.js +10 -0
  99. package/esm/browser/i18n/zh/common.js +18 -0
  100. package/esm/browser/i18n/zh/discover.js +7 -0
  101. package/esm/browser/i18n/zh/settings.js +2 -0
  102. package/esm/browser/i18n/zh-tw/chat.js +10 -0
  103. package/esm/browser/i18n/zh-tw/common.js +18 -0
  104. package/esm/browser/i18n/zh-tw/discover.js +7 -0
  105. package/esm/browser/i18n/zh-tw/settings.js +2 -0
  106. package/esm/browser/launch-art/art-palette.d.ts +41 -0
  107. package/esm/browser/launch-art/art-palette.js +72 -0
  108. package/esm/browser/launch-art/cyclic-automaton.d.ts +45 -0
  109. package/esm/browser/launch-art/cyclic-automaton.js +176 -0
  110. package/esm/browser/launch-art/fractal-tree.d.ts +43 -0
  111. package/esm/browser/launch-art/fractal-tree.js +48 -0
  112. package/esm/browser/launch-art/launch-art.d.ts +98 -0
  113. package/esm/browser/launch-art/launch-art.js +420 -0
  114. package/esm/browser/launch-art/launch-sky.d.ts +66 -0
  115. package/esm/browser/launch-art/launch-sky.js +153 -0
  116. package/esm/browser/links/clipboard-links.d.ts +89 -0
  117. package/esm/browser/links/clipboard-links.js +303 -0
  118. package/esm/browser/links/link-text.d.ts +29 -0
  119. package/esm/browser/links/link-text.js +97 -0
  120. package/esm/browser/links/links-protocol.d.ts +12 -1
  121. package/esm/browser/links/links.d.ts +8 -2
  122. package/esm/browser/links/links.js +33 -3
  123. package/esm/browser/markdown/code-renderers.d.ts +4 -0
  124. package/esm/browser/markdown/code-renderers.js +4 -0
  125. package/esm/browser/partners/group-picker.js +23 -29
  126. package/esm/browser/sandbox/sandbox-runtime-code.js +1 -1
  127. package/esm/browser/sandbox/work/work-senses.js +1 -1
  128. package/esm/browser/settings/settings-protocol.d.ts +2 -0
  129. package/esm/browser/settings/settings-protocol.js +2 -0
  130. package/esm/browser/style/base.d.ts +1 -1
  131. package/esm/browser/style/base.js +10 -6
  132. package/esm/browser/style/chat-list.d.ts +1 -1
  133. package/esm/browser/style/chat-list.js +28 -15
  134. package/esm/browser/style/conversation-column.d.ts +1 -1
  135. package/esm/browser/style/conversation.d.ts +1 -1
  136. package/esm/browser/style/conversation.js +2 -2
  137. package/esm/browser/style/dialogs.d.ts +1 -1
  138. package/esm/browser/style/dialogs.js +2 -5
  139. package/esm/browser/style/forms.d.ts +5 -0
  140. package/esm/browser/style/forms.js +65 -0
  141. package/esm/browser/style/layout.d.ts +1 -1
  142. package/esm/browser/style/pages.d.ts +1 -1
  143. package/esm/browser/style/pages.js +14 -24
  144. package/esm/browser/style/phone.d.ts +1 -1
  145. package/esm/browser/style/shared.d.ts +1 -1
  146. package/esm/browser/style/shell.d.ts +1 -1
  147. package/esm/browser/style/shell.js +1 -6
  148. package/esm/browser/style/surfaces.d.ts +1 -1
  149. package/esm/browser/style/surfaces.js +0 -6
  150. package/esm/browser/style/tasks.d.ts +1 -1
  151. package/esm/browser/style.js +2 -0
  152. package/esm/browser/util/voice.d.ts +18 -0
  153. package/esm/browser/util/voice.js +111 -3
  154. package/esm/browser/workbench-protocol.d.ts +2 -0
  155. package/esm/browser/workbench-services.d.ts +2 -0
  156. package/esm/browser/workbench-services.js +5 -0
  157. package/esm/browser/workbench.js +5 -0
  158. package/lib/browser/apps/web-apps.d.ts +4 -0
  159. package/lib/browser/apps/web-apps.js +14 -3
  160. package/lib/browser/assistant/ta-hearing.d.ts +86 -0
  161. package/lib/browser/assistant/ta-hearing.js +277 -0
  162. package/lib/browser/components/auth-view.js +1 -1
  163. package/lib/browser/components/board.js +9 -1
  164. package/lib/browser/components/clipboard-link-host.d.ts +3 -0
  165. package/lib/browser/components/clipboard-link-host.js +63 -0
  166. package/lib/browser/components/cloud-network.js +1 -1
  167. package/lib/browser/components/cloud-sign-in-view.d.ts +1 -1
  168. package/lib/browser/components/custom-provider-advanced.js +8 -8
  169. package/lib/browser/components/custom-provider-view.js +12 -12
  170. package/lib/browser/components/empty-state.d.ts +2 -1
  171. package/lib/browser/components/empty-state.js +6 -2
  172. package/lib/browser/components/folder-picker.js +2 -2
  173. package/lib/browser/components/gallery.js +7 -8
  174. package/lib/browser/components/hearing-host.d.ts +6 -0
  175. package/lib/browser/components/hearing-host.js +94 -0
  176. package/lib/browser/components/host-view.d.ts +1 -1
  177. package/lib/browser/components/link-dialog.js +4 -0
  178. package/lib/browser/components/loading.d.ts +3 -2
  179. package/lib/browser/components/loading.js +7 -3
  180. package/lib/browser/components/markdown.d.ts +3 -1
  181. package/lib/browser/components/markdown.js +9 -4
  182. package/lib/browser/components/media.d.ts +10 -4
  183. package/lib/browser/components/media.js +61 -14
  184. package/lib/browser/components/people-picker.d.ts +18 -0
  185. package/lib/browser/components/people-picker.js +166 -0
  186. package/lib/browser/components/relay-view.js +1 -1
  187. package/lib/browser/components/settings-parts.js +2 -0
  188. package/lib/browser/components/share-dialog.d.ts +2 -2
  189. package/lib/browser/components/share-dialog.js +7 -4
  190. package/lib/browser/components/share-friends.js +3 -10
  191. package/lib/browser/components/share-item-sheet.d.ts +13 -0
  192. package/lib/browser/components/share-item-sheet.js +75 -0
  193. package/lib/browser/components/share-sheet.d.ts +9 -2
  194. package/lib/browser/components/share-sheet.js +5 -3
  195. package/lib/browser/components/sign-in-setup.js +4 -4
  196. package/lib/browser/components/trusted-domains.js +1 -1
  197. package/lib/browser/components/view-room.d.ts +26 -0
  198. package/lib/browser/components/view-room.js +173 -0
  199. package/lib/browser/components/voice-services.js +6 -6
  200. package/lib/browser/device/device-protocol.d.ts +9 -6
  201. package/lib/browser/device/device-protocol.js +7 -4
  202. package/lib/browser/device/launch-screen.d.ts +11 -1
  203. package/lib/browser/device/launch-screen.js +22 -4
  204. package/lib/browser/extension/share-sheet-compat.d.ts +2 -0
  205. package/lib/browser/extension/share-sheet-compat.js +13 -2
  206. package/lib/browser/extension/web-api-code.d.ts +11 -0
  207. package/lib/browser/extension/web-api-components.d.ts +8 -1
  208. package/lib/browser/extension/web-api-contributions.d.ts +30 -1
  209. package/lib/browser/extension/web-api-desktop.d.ts +2 -1
  210. package/lib/browser/extension/web-api-file-views.d.ts +39 -0
  211. package/lib/browser/extension/web-api-file-views.js +3 -0
  212. package/lib/browser/extension/web-api-host.d.ts +48 -0
  213. package/lib/browser/extension/web-api-host.js +4 -0
  214. package/lib/browser/extension/web-api-menus.d.ts +46 -0
  215. package/lib/browser/extension/web-api-partners.d.ts +58 -1
  216. package/lib/browser/extension/web-api-spec.js +7 -0
  217. package/lib/browser/extension/web-extension-api.d.ts +10 -10
  218. package/lib/browser/extension/web-extension-context.d.ts +2 -8
  219. package/lib/browser/extension/web-extension-context.js +14 -39
  220. package/lib/browser/extension/web-extension-marks.d.ts +11 -0
  221. package/lib/browser/extension/web-extension-marks.js +65 -0
  222. package/lib/browser/extension/web-extension-protocol.d.ts +11 -1
  223. package/lib/browser/extension/web-extension-protocol.js +3 -0
  224. package/lib/browser/extension/web-extension-run.d.ts +15 -2
  225. package/lib/browser/extension/web-extension-run.js +77 -0
  226. package/lib/browser/extension/web-extensions-running.d.ts +5 -1
  227. package/lib/browser/extension/web-extensions-running.js +16 -0
  228. package/lib/browser/extension/web-extensions.d.ts +2 -1
  229. package/lib/browser/extension/web-extensions.js +3 -0
  230. package/lib/browser/extension/web-home.js +3 -1
  231. package/lib/browser/extension/web-host-values.d.ts +67 -0
  232. package/lib/browser/extension/web-host-values.js +229 -0
  233. package/lib/browser/extension/web-hosts.d.ts +7 -2
  234. package/lib/browser/extension/web-hosts.js +16 -4
  235. package/lib/browser/extension/web-share-ui.d.ts +8 -0
  236. package/lib/browser/extension/web-share-ui.js +51 -0
  237. package/lib/browser/extension/web-share.d.ts +19 -0
  238. package/lib/browser/extension/web-share.js +45 -0
  239. package/lib/browser/i18n/en/chat.d.ts +10 -0
  240. package/lib/browser/i18n/en/chat.js +10 -0
  241. package/lib/browser/i18n/en/common.d.ts +18 -0
  242. package/lib/browser/i18n/en/common.js +18 -0
  243. package/lib/browser/i18n/en/discover.d.ts +7 -0
  244. package/lib/browser/i18n/en/discover.js +7 -0
  245. package/lib/browser/i18n/en/settings.d.ts +2 -0
  246. package/lib/browser/i18n/en/settings.js +2 -0
  247. package/lib/browser/i18n/ja/chat.js +10 -0
  248. package/lib/browser/i18n/ja/common.js +18 -0
  249. package/lib/browser/i18n/ja/discover.js +7 -0
  250. package/lib/browser/i18n/ja/settings.js +2 -0
  251. package/lib/browser/i18n/locales.d.ts +38 -1
  252. package/lib/browser/i18n/messages.d.ts +37 -0
  253. package/lib/browser/i18n/zh/chat.js +10 -0
  254. package/lib/browser/i18n/zh/common.js +18 -0
  255. package/lib/browser/i18n/zh/discover.js +7 -0
  256. package/lib/browser/i18n/zh/settings.js +2 -0
  257. package/lib/browser/i18n/zh-tw/chat.js +10 -0
  258. package/lib/browser/i18n/zh-tw/common.js +18 -0
  259. package/lib/browser/i18n/zh-tw/discover.js +7 -0
  260. package/lib/browser/i18n/zh-tw/settings.js +2 -0
  261. package/lib/browser/launch-art/art-palette.d.ts +42 -0
  262. package/lib/browser/launch-art/art-palette.js +76 -0
  263. package/lib/browser/launch-art/cyclic-automaton.d.ts +46 -0
  264. package/lib/browser/launch-art/cyclic-automaton.js +180 -0
  265. package/lib/browser/launch-art/fractal-tree.d.ts +44 -0
  266. package/lib/browser/launch-art/fractal-tree.js +52 -0
  267. package/lib/browser/launch-art/launch-art.d.ts +99 -0
  268. package/lib/browser/launch-art/launch-art.js +424 -0
  269. package/lib/browser/launch-art/launch-sky.d.ts +67 -0
  270. package/lib/browser/launch-art/launch-sky.js +157 -0
  271. package/lib/browser/links/clipboard-links.d.ts +90 -0
  272. package/lib/browser/links/clipboard-links.js +308 -0
  273. package/lib/browser/links/link-text.d.ts +30 -0
  274. package/lib/browser/links/link-text.js +100 -0
  275. package/lib/browser/links/links-protocol.d.ts +12 -1
  276. package/lib/browser/links/links.d.ts +8 -2
  277. package/lib/browser/links/links.js +33 -3
  278. package/lib/browser/markdown/code-renderers.d.ts +4 -0
  279. package/lib/browser/markdown/code-renderers.js +5 -1
  280. package/lib/browser/partners/group-picker.js +23 -29
  281. package/lib/browser/sandbox/sandbox-runtime-code.js +1 -1
  282. package/lib/browser/sandbox/work/work-senses.js +1 -1
  283. package/lib/browser/settings/settings-protocol.d.ts +2 -0
  284. package/lib/browser/settings/settings-protocol.js +2 -0
  285. package/lib/browser/style/base.d.ts +1 -1
  286. package/lib/browser/style/base.js +10 -6
  287. package/lib/browser/style/chat-list.d.ts +1 -1
  288. package/lib/browser/style/chat-list.js +28 -15
  289. package/lib/browser/style/conversation-column.d.ts +1 -1
  290. package/lib/browser/style/conversation.d.ts +1 -1
  291. package/lib/browser/style/conversation.js +2 -2
  292. package/lib/browser/style/dialogs.d.ts +1 -1
  293. package/lib/browser/style/dialogs.js +2 -5
  294. package/lib/browser/style/forms.d.ts +6 -0
  295. package/lib/browser/style/forms.js +68 -0
  296. package/lib/browser/style/layout.d.ts +1 -1
  297. package/lib/browser/style/pages.d.ts +1 -1
  298. package/lib/browser/style/pages.js +14 -24
  299. package/lib/browser/style/phone.d.ts +1 -1
  300. package/lib/browser/style/shared.d.ts +1 -1
  301. package/lib/browser/style/shell.d.ts +1 -1
  302. package/lib/browser/style/shell.js +1 -6
  303. package/lib/browser/style/surfaces.d.ts +1 -1
  304. package/lib/browser/style/surfaces.js +0 -6
  305. package/lib/browser/style/tasks.d.ts +1 -1
  306. package/lib/browser/style.js +2 -0
  307. package/lib/browser/util/voice.d.ts +18 -0
  308. package/lib/browser/util/voice.js +111 -3
  309. package/lib/browser/workbench-protocol.d.ts +2 -0
  310. package/lib/browser/workbench-services.d.ts +2 -0
  311. package/lib/browser/workbench-services.js +5 -0
  312. package/lib/browser/workbench.js +5 -0
  313. package/package.json +8 -8
  314. package/public/launch.svg +3 -3
@@ -0,0 +1,424 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LaunchArtUtil = exports.LaunchArt = void 0;
4
+ const state_protocol_1 = require("../state/state-protocol");
5
+ const art_palette_1 = require("./art-palette");
6
+ const fractal_tree_1 = require("./fractal-tree");
7
+ const launch_sky_1 = require("./launch-sky");
8
+ const GOLD = [232, 185, 74];
9
+ const css = (color, alpha = 1) => `rgba(${color[0]},${color[1]},${color[2]},${alpha})`;
10
+ /**
11
+ * The launch picture come alive, over the still one (`public/launch.svg`, which the native launch screen shows too): its
12
+ * night sky is painted, stroke by stroke, along the waves of a cyclic automaton (LaunchSky) that never comes to rest,
13
+ * whirling round its cores as Van Gogh's sky does, its colours and brush going from his night to Hokusai's wave, Klimt's
14
+ * gold, the green dawn of Ta and ink wash; and on the planet's rim, behind the dinosaur, a tree of life grows (FractalTree,
15
+ * Klimt's, its tips curls of gold) and sways. A tap sows a new whirl; a finger drawn across stirs the paint and the tree
16
+ * leans toward it; while a finger is down the launch screen stays (`held`). The canvases fade in over the still picture,
17
+ * so the native launch screen goes into it without a seam; the sky goes on at the next launch from where it was left.
18
+ */
19
+ class LaunchArt {
20
+ constructor(element, storage, random = Math.random) {
21
+ this.element = element;
22
+ this.storage = storage;
23
+ this.random = random;
24
+ this.held = false;
25
+ this.paint = document.createElement('canvas');
26
+ this.live = document.createElement('canvas');
27
+ this.mask = document.createElement('canvas');
28
+ this.veil = document.createElement('div');
29
+ this.palette = new art_palette_1.ArtPalette();
30
+ this.releases = [];
31
+ this.ripples = [];
32
+ this.view = { scale: 1, x: 0, y: 0 };
33
+ this.ratio = 1;
34
+ this.request = 0;
35
+ this.last = 0;
36
+ this.age = 0;
37
+ this.lean = 0;
38
+ this.leanTo = 0;
39
+ this.wind = 0;
40
+ this.stopped = false;
41
+ this.listeners = [];
42
+ this.tick = (now) => {
43
+ const seconds = Math.min(0.05, (now - this.last) / 1000);
44
+ this.last = now;
45
+ this.age += seconds;
46
+ this.lean += (this.leanTo - this.lean) * Math.min(1, seconds * 4);
47
+ this.wind *= Math.max(0, 1 - seconds * 1.5);
48
+ if (this.stir) {
49
+ this.stir.vx *= 0.85;
50
+ this.stir.vy *= 0.85;
51
+ }
52
+ this.lay(seconds);
53
+ this.grow(seconds);
54
+ this.request = requestAnimationFrame(this.tick);
55
+ };
56
+ this.sky = new launch_sky_1.LaunchSky(launch_sky_1.LaunchSky.parse(storage === null || storage === void 0 ? void 0 : storage.getItem(LaunchArt.KEY)), random);
57
+ const { launches } = this.sky;
58
+ this.tree = new fractal_tree_1.FractalTree(6 + (launches >= 10 ? 1 : 0) + (launches >= 30 ? 1 : 0), random);
59
+ }
60
+ /** Where `width` by `height` shows the picture, as `object-fit: contain`. */
61
+ static fit(width, height) {
62
+ const scale = Math.min(width / 360, height / 640);
63
+ return { scale, x: (width - 360 * scale) / 2, y: (height - 640 * scale) / 2 };
64
+ }
65
+ static multiply(m, n) {
66
+ return [
67
+ m[0] * n[0] + m[2] * n[1],
68
+ m[1] * n[0] + m[3] * n[1],
69
+ m[0] * n[2] + m[2] * n[3],
70
+ m[1] * n[2] + m[3] * n[3],
71
+ m[0] * n[4] + m[2] * n[5] + m[4],
72
+ m[1] * n[4] + m[3] * n[5] + m[5],
73
+ ];
74
+ }
75
+ /** The matrix of an SVG `transform` of translate, rotate (about the origin) and scale. */
76
+ static affine(transform) {
77
+ var _a, _b, _c;
78
+ let matrix = [1, 0, 0, 1, 0, 0];
79
+ for (const [, name, args] of transform.matchAll(/(\w+)\(([^)]*)\)/g)) {
80
+ const values = args
81
+ .split(/[\s,]+/)
82
+ .filter(Boolean)
83
+ .map(Number);
84
+ const turn = (((_a = values[0]) !== null && _a !== void 0 ? _a : 0) * Math.PI) / 180;
85
+ const step = name === 'translate'
86
+ ? [1, 0, 0, 1, values[0], (_b = values[1]) !== null && _b !== void 0 ? _b : 0]
87
+ : name === 'scale'
88
+ ? [values[0], 0, 0, (_c = values[1]) !== null && _c !== void 0 ? _c : values[0], 0, 0]
89
+ : name === 'rotate'
90
+ ? [Math.cos(turn), Math.sin(turn), -Math.sin(turn), Math.cos(turn), 0, 0]
91
+ : undefined;
92
+ if (step) {
93
+ matrix = LaunchArt.multiply(matrix, step);
94
+ }
95
+ }
96
+ return matrix;
97
+ }
98
+ /** The dinosaur of `launch.svg`: its outline and where the picture puts it, for the paint not to cover it. */
99
+ static dinosaur(svg) {
100
+ var _a, _b;
101
+ const path = (_a = /<path id="dino"[^>]*\sd="([^"]+)"/.exec(svg)) === null || _a === void 0 ? void 0 : _a[1];
102
+ const transform = (_b = /<g transform="([^"]+)">\s*<use href="#dino"/.exec(svg)) === null || _b === void 0 ? void 0 : _b[1];
103
+ return path && transform ? { path, matrix: LaunchArt.affine(transform) } : undefined;
104
+ }
105
+ /** The settings ask for less motion (Look.reduceMotion, kept by the page before), or the system does. */
106
+ static calm(storage, prefersReduced) {
107
+ var _a;
108
+ var _b;
109
+ try {
110
+ return prefersReduced || ((_a = JSON.parse((_b = storage === null || storage === void 0 ? void 0 : storage.getItem(state_protocol_1.StateUtil.localKey('look', 'device', undefined))) !== null && _b !== void 0 ? _b : 'null')) === null || _a === void 0 ? void 0 : _a.reduceMotion) === true;
111
+ }
112
+ catch (_c) {
113
+ return prefersReduced;
114
+ }
115
+ }
116
+ start(svg) {
117
+ var _a;
118
+ const { element } = this;
119
+ const width = element.clientWidth;
120
+ const height = element.clientHeight;
121
+ this.ratio = Math.min(LaunchArt.RATIO, window.devicePixelRatio || 1);
122
+ this.view = LaunchArt.fit(width, height);
123
+ for (const canvas of [this.paint, this.live, this.mask]) {
124
+ canvas.width = Math.round(width * this.ratio);
125
+ canvas.height = Math.round(height * this.ratio);
126
+ }
127
+ const { scale, x, y } = this.view;
128
+ // The vignette of launch.svg over the paint, so the paint fades into the night at the edges as the picture does.
129
+ this.veil.style.background = `radial-gradient(ellipse ${180 * scale}px ${320 * scale}px at ${x + 180 * scale}px ${y + 320 * scale}px, rgba(11,13,16,0) 62%, #0b0d10 97%)`;
130
+ for (const layer of [this.paint, this.live, this.veil]) {
131
+ layer.style.cssText += ';position:absolute;inset:0;width:100%;height:100%;opacity:0;transition:opacity 600ms ease;pointer-events:none';
132
+ element.appendChild(layer);
133
+ }
134
+ element.style.touchAction = 'none';
135
+ this.listen('pointerdown', event => this.down(event));
136
+ // A long press is held to play, not the menu of the system (Android's for a picture).
137
+ this.listen('contextmenu', event => event.preventDefault());
138
+ this.listen('pointermove', event => this.moved(event));
139
+ for (const name of ['pointerup', 'pointercancel', 'pointerleave']) {
140
+ this.listen(name, () => this.up());
141
+ }
142
+ (_a = this.storage) === null || _a === void 0 ? void 0 : _a.setItem(LaunchArt.KEY, JSON.stringify(this.sky.kept()));
143
+ const begin = (dinosaur) => {
144
+ if (this.stopped) {
145
+ return;
146
+ }
147
+ this.draw(dinosaur);
148
+ for (const layer of [this.paint, this.live, this.veil]) {
149
+ layer.style.opacity = '1';
150
+ }
151
+ this.last = performance.now();
152
+ this.request = requestAnimationFrame(this.tick);
153
+ };
154
+ svg.then(text => begin(LaunchArt.dinosaur(text)), () => begin(undefined));
155
+ }
156
+ /** `next` when the finger holding the launch screen lets go. */
157
+ onRelease(next) {
158
+ this.releases.push(next);
159
+ }
160
+ stop() {
161
+ var _a;
162
+ if (this.stopped) {
163
+ return;
164
+ }
165
+ this.stopped = true;
166
+ cancelAnimationFrame(this.request);
167
+ for (const [name, listener] of this.listeners) {
168
+ this.element.removeEventListener(name, listener);
169
+ }
170
+ (_a = this.storage) === null || _a === void 0 ? void 0 : _a.setItem(LaunchArt.KEY, JSON.stringify(this.sky.kept()));
171
+ }
172
+ listen(name, listener) {
173
+ this.listeners.push([name, listener]);
174
+ this.element.addEventListener(name, listener);
175
+ }
176
+ /** A point of the page in the units of the picture. */
177
+ point(event) {
178
+ const box = this.element.getBoundingClientRect();
179
+ return { x: (event.clientX - box.left - this.view.x) / this.view.scale, y: (event.clientY - box.top - this.view.y) / this.view.scale };
180
+ }
181
+ down(event) {
182
+ this.held = true;
183
+ const { x, y } = this.point(event);
184
+ this.sky.plant(x, y);
185
+ this.ripples.push({ x, y, age: 0 });
186
+ this.stir = { x, y, vx: 0, vy: 0 };
187
+ this.leanTo = Math.max(-1, Math.min(1, (x - LaunchArt.TREE_X) / 120));
188
+ }
189
+ moved(event) {
190
+ if (!this.held || !this.stir) {
191
+ return;
192
+ }
193
+ const { x, y } = this.point(event);
194
+ this.stir = { x, y, vx: (x - this.stir.x) * 30, vy: (y - this.stir.y) * 30 };
195
+ this.leanTo = Math.max(-1, Math.min(1, (x - LaunchArt.TREE_X) / 120));
196
+ this.wind = Math.max(-1, Math.min(1, this.wind + this.stir.vx / 600));
197
+ }
198
+ up() {
199
+ if (!this.held) {
200
+ return;
201
+ }
202
+ this.held = false;
203
+ this.stir = undefined;
204
+ this.leanTo = 0;
205
+ for (const next of this.releases.splice(0)) {
206
+ next();
207
+ }
208
+ }
209
+ /**
210
+ * What the paint never covers, as how much of it each frame wipes: the planet, the dinosaur and the moon all of it,
211
+ * toward the rim, where the dawn is, a little.
212
+ */
213
+ draw(dinosaur) {
214
+ const context = this.mask.getContext('2d');
215
+ if (!context) {
216
+ return;
217
+ }
218
+ const { PLANET } = launch_sky_1.LaunchSky;
219
+ this.place(context);
220
+ const dawn = context.createLinearGradient(0, 340, 0, 404);
221
+ dawn.addColorStop(0, 'rgba(0,0,0,0)');
222
+ dawn.addColorStop(1, 'rgba(0,0,0,0.12)');
223
+ context.fillStyle = dawn;
224
+ context.fillRect(0, 330, 360, 80);
225
+ context.fillStyle = '#000';
226
+ context.beginPath();
227
+ context.rect(-2000, -2000, 4360, 4640);
228
+ context.rect(0, 0, 360, 640);
229
+ context.fill('evenodd');
230
+ context.beginPath();
231
+ context.arc(PLANET.x, PLANET.y, PLANET.r + 1, 0, Math.PI * 2);
232
+ context.fill();
233
+ // The young moon of the picture, which the paint goes round.
234
+ const moon = context.createRadialGradient(76, 170, 10, 76, 170, 22);
235
+ moon.addColorStop(0, 'rgba(0,0,0,1)');
236
+ moon.addColorStop(1, 'rgba(0,0,0,0)');
237
+ context.fillStyle = moon;
238
+ context.fillRect(50, 144, 52, 52);
239
+ context.fillStyle = '#000';
240
+ if (dinosaur) {
241
+ context.save();
242
+ context.transform(...dinosaur.matrix);
243
+ context.lineWidth = 6;
244
+ context.strokeStyle = '#000';
245
+ const outline = new Path2D(dinosaur.path);
246
+ context.fill(outline);
247
+ context.stroke(outline);
248
+ context.restore();
249
+ }
250
+ }
251
+ place(context) {
252
+ const { scale, x, y } = this.view;
253
+ const { ratio } = this;
254
+ context.setTransform(ratio * scale, 0, 0, ratio * scale, ratio * x, ratio * y);
255
+ }
256
+ /** A frame of paint: the last frame's a little wiped, then each stroke drawn on along the fronts, in the colour of its phase. */
257
+ lay(seconds) {
258
+ const context = this.paint.getContext('2d');
259
+ if (!context) {
260
+ return;
261
+ }
262
+ const { sky, palette } = this;
263
+ sky.advance(seconds);
264
+ const brush = palette.brush(sky.clock);
265
+ const colors = palette.colors(sky.clock, launch_sky_1.LaunchSky.STATES);
266
+ sky.move(seconds, brush, this.stir);
267
+ context.setTransform(1, 0, 0, 1, 0, 0);
268
+ context.globalCompositeOperation = 'destination-out';
269
+ context.globalAlpha = 1 - (1 - LaunchArt.FADE) ** (seconds * 60);
270
+ context.fillRect(0, 0, this.paint.width, this.paint.height);
271
+ context.globalAlpha = 1;
272
+ context.drawImage(this.mask, 0, 0);
273
+ context.globalCompositeOperation = 'source-over';
274
+ this.place(context);
275
+ context.lineCap = 'round';
276
+ context.globalAlpha = brush.alpha;
277
+ const groups = Array.from({ length: launch_sky_1.LaunchSky.STATES * 3 }, () => []);
278
+ const tiles = Array.from({ length: launch_sky_1.LaunchSky.STATES }, () => []);
279
+ const frame = Math.floor(sky.clock * 30);
280
+ for (let index = 0; index < launch_sky_1.LaunchSky.STROKES; index++) {
281
+ if (Math.abs(sky.x[index] - sky.px[index]) + Math.abs(sky.y[index] - sky.py[index]) < 0.15) {
282
+ // Barely moved (just laid, or where the fronts stall): a round cap of nothing would be a dot.
283
+ continue;
284
+ }
285
+ const phase = sky.phase(index);
286
+ if (sky.pick[index] < brush.tiles) {
287
+ if ((frame + index) % 6 === 0) {
288
+ tiles[phase].push(index);
289
+ }
290
+ }
291
+ else {
292
+ groups[phase * 3 + sky.tone[index]].push(index);
293
+ }
294
+ }
295
+ for (let group = 0; group < groups.length; group++) {
296
+ const members = groups[group];
297
+ if (!members.length) {
298
+ continue;
299
+ }
300
+ const phase = Math.floor(group / 3);
301
+ const tone = group % 3;
302
+ context.strokeStyle = css(art_palette_1.ArtPalette.blend(colors[phase], colors[(phase + 1) % colors.length], tone * 0.22));
303
+ context.lineWidth = brush.width * [1.25, 1, 0.7][tone];
304
+ context.beginPath();
305
+ for (const index of members) {
306
+ context.moveTo(sky.px[index], sky.py[index]);
307
+ context.lineTo(sky.x[index], sky.y[index]);
308
+ }
309
+ context.stroke();
310
+ }
311
+ const side = brush.width * 1.6;
312
+ for (let phase = 0; phase < tiles.length; phase++) {
313
+ if (!tiles[phase].length) {
314
+ continue;
315
+ }
316
+ context.fillStyle = css(art_palette_1.ArtPalette.blend(colors[phase], GOLD, 0.35));
317
+ for (const index of tiles[phase]) {
318
+ context.fillRect(Math.round(sky.x[index] / side) * side - side / 2, Math.round(sky.y[index] / side) * side - side / 2, side * 0.86, side * 0.86);
319
+ }
320
+ }
321
+ context.globalAlpha = 1;
322
+ }
323
+ /** The tree on the rim and the rings of the taps, drawn anew each frame. */
324
+ grow(seconds) {
325
+ const context = this.live.getContext('2d');
326
+ if (!context) {
327
+ return;
328
+ }
329
+ context.setTransform(1, 0, 0, 1, 0, 0);
330
+ context.clearRect(0, 0, this.live.width, this.live.height);
331
+ this.place(context);
332
+ const { sky, palette, tree } = this;
333
+ const light = art_palette_1.ArtPalette.lightest(palette.colors(sky.clock, launch_sky_1.LaunchSky.STATES));
334
+ const gold = art_palette_1.ArtPalette.blend(GOLD, light, 0.35);
335
+ const into = Math.min(1, this.age / LaunchArt.GROW);
336
+ const segments = tree.segments({
337
+ x: LaunchArt.TREE_X,
338
+ y: launch_sky_1.LaunchSky.rim(LaunchArt.TREE_X) + 1.5,
339
+ size: Math.min(52, 30 + sky.launches * 0.6),
340
+ sway: Math.sin(this.age * 0.8) * 0.35 + Math.sin(this.age * 2.3) * 0.08 + this.wind,
341
+ lean: this.lean,
342
+ growth: 1 - (1 - into) ** 3,
343
+ });
344
+ // The halo of the young moon, as Van Gogh's: rings of the lightest colour round it, breathing.
345
+ const breath = 0.5 + 0.5 * Math.sin(this.age * 1.3);
346
+ for (let ring = 0; ring < 3; ring++) {
347
+ context.strokeStyle = css(light, (0.22 - ring * 0.06) * (0.7 + 0.3 * breath));
348
+ context.lineWidth = 1.6 - ring * 0.4;
349
+ context.beginPath();
350
+ context.arc(76, 170, 15 + ring * 4.5 + breath * 0.8, 0, Math.PI * 2);
351
+ context.stroke();
352
+ }
353
+ context.lineCap = 'round';
354
+ context.strokeStyle = '#030605';
355
+ for (let depth = 0; depth <= tree.depth; depth++) {
356
+ context.lineWidth = (tree.depth - depth + 1) * 0.42;
357
+ context.beginPath();
358
+ for (const segment of segments) {
359
+ if (segment.depth === depth) {
360
+ context.moveTo(segment.x0, segment.y0);
361
+ context.lineTo(segment.x1, segment.y1);
362
+ }
363
+ }
364
+ context.stroke();
365
+ }
366
+ context.strokeStyle = css(gold, 0.95);
367
+ context.lineWidth = 0.55;
368
+ context.beginPath();
369
+ let hand = 1;
370
+ for (const segment of segments) {
371
+ if (!segment.tip) {
372
+ continue;
373
+ }
374
+ hand = -hand;
375
+ let { x1: x, y1: y, angle } = segment;
376
+ context.moveTo(x, y);
377
+ for (let turn = 0; turn < 9; turn++) {
378
+ angle += hand * 0.55;
379
+ const step = 1.2 * (1 - turn / 10);
380
+ x += Math.cos(angle) * step;
381
+ y += Math.sin(angle) * step;
382
+ context.lineTo(x, y);
383
+ }
384
+ }
385
+ context.stroke();
386
+ for (const ripple of this.ripples) {
387
+ ripple.age += seconds;
388
+ const left = 1 - ripple.age / 0.9;
389
+ if (left > 0) {
390
+ context.strokeStyle = css(light, left * 0.8);
391
+ context.lineWidth = 1.2;
392
+ context.beginPath();
393
+ context.arc(ripple.x, ripple.y, 4 + ripple.age * 60, 0, Math.PI * 2);
394
+ context.stroke();
395
+ }
396
+ }
397
+ this.ripples.splice(0, this.ripples.length, ...this.ripples.filter(ripple => ripple.age < 0.9));
398
+ }
399
+ }
400
+ exports.LaunchArt = LaunchArt;
401
+ LaunchArt.KEY = state_protocol_1.StateUtil.localKey('launch-art', 'device', undefined);
402
+ LaunchArt.TREE_X = 262;
403
+ LaunchArt.GROW = 1.8;
404
+ /** Pixels a point at most: strokes of paint need no more, and the launch screen keeps its memory small. */
405
+ LaunchArt.RATIO = 1.5;
406
+ /** Of the paint left from the frame before, at 60 frames a second, what each frame wipes. */
407
+ LaunchArt.FADE = 0.025;
408
+ var LaunchArtUtil;
409
+ (function (LaunchArtUtil) {
410
+ /** The living launch picture over `element` (`#ta-launch`), unless less motion is asked for. */
411
+ function start(element) {
412
+ var _a;
413
+ var _b;
414
+ const storage = typeof localStorage === 'undefined' ? undefined : localStorage;
415
+ if (typeof window === 'undefined' || LaunchArt.calm(storage, (_b = (_a = window.matchMedia) === null || _a === void 0 ? void 0 : _a.call(window, '(prefers-reduced-motion: reduce)').matches) !== null && _b !== void 0 ? _b : false)) {
416
+ return undefined;
417
+ }
418
+ const art = new LaunchArt(element, storage);
419
+ art.start(fetch('launch.svg').then(response => response.text()));
420
+ return art;
421
+ }
422
+ LaunchArtUtil.start = start;
423
+ })(LaunchArtUtil || (exports.LaunchArtUtil = LaunchArtUtil = {}));
424
+ //# sourceMappingURL=launch-art.js.map
@@ -0,0 +1,67 @@
1
+ import type { ArtBrush } from './art-palette';
2
+ import { CyclicAutomaton } from './cyclic-automaton';
3
+ /** What a launch leaves for the next: the sky's cells, the clock of its eras, how many launches it has seen. */
4
+ export interface LaunchArtKept {
5
+ cells: string;
6
+ clock: number;
7
+ launches: number;
8
+ }
9
+ /** A hand stirring the paint: where (in the units of the picture) and how fast it moves. */
10
+ export interface LaunchStir {
11
+ x: number;
12
+ y: number;
13
+ vx: number;
14
+ vy: number;
15
+ }
16
+ /**
17
+ * The sky of the launch picture, without the page: a cyclic automaton over the sky of `public/launch.svg` (360 by 640,
18
+ * the planet's rim at y 400), the clock of the eras its colours go through, and the strokes painted along its wave fronts.
19
+ * It goes on from where the last launch left it (`kept`): each launch moves the clock on by PER_LAUNCH and the
20
+ * automaton by FIRST_STEPS, so no two launches open on the same sky.
21
+ */
22
+ export declare class LaunchSky {
23
+ protected readonly random: () => number;
24
+ static readonly COLS = 48;
25
+ static readonly ROWS = 55;
26
+ static readonly STATES = 8;
27
+ /** The side of a cell, in the units of the picture. */
28
+ static readonly CELL = 7.5;
29
+ /** Seconds between two steps of the automaton. */
30
+ static readonly STEP = 0.12;
31
+ static readonly PER_LAUNCH = 8;
32
+ static readonly FIRST_STEPS = 24;
33
+ static readonly STROKES = 900;
34
+ static readonly PLANET: {
35
+ x: number;
36
+ y: number;
37
+ r: number;
38
+ };
39
+ readonly automaton: CyclicAutomaton;
40
+ clock: number;
41
+ readonly launches: number;
42
+ /** Each stroke: where it is (x, y), where it was a frame ago (px, py), how long it has left, its pick (0 to 1) and tone (0, 1 or 2). */
43
+ readonly x: Float32Array<ArrayBuffer>;
44
+ readonly y: Float32Array<ArrayBuffer>;
45
+ readonly px: Float32Array<ArrayBuffer>;
46
+ readonly py: Float32Array<ArrayBuffer>;
47
+ readonly life: Float32Array<ArrayBuffer>;
48
+ readonly pick: Float32Array<ArrayBuffer>;
49
+ readonly tone: Uint8Array<ArrayBuffer>;
50
+ protected waiting: number;
51
+ constructor(kept: LaunchArtKept | undefined, random?: () => number);
52
+ static seed(random: () => number): CyclicAutomaton;
53
+ /** The height of the planet's rim at `x`. */
54
+ static rim(x: number): number;
55
+ static parse(text: string | null | undefined): LaunchArtKept | undefined;
56
+ kept(): LaunchArtKept;
57
+ /** `seconds` on: the clock, and the automaton a step every STEP (at most two a frame; a frozen sky is sown again). */
58
+ advance(seconds: number): void;
59
+ /** A new whirl where a finger touched the sky, `x`, `y` in the units of the picture; whether it was the sky. */
60
+ plant(x: number, y: number): boolean;
61
+ /** Every stroke `seconds` on along the fronts at the pace of `brush`, pushed by `stir` near it; those gone are laid anew. */
62
+ move(seconds: number, brush: ArtBrush, stir?: LaunchStir): void;
63
+ /** The phase of the automaton under a stroke. */
64
+ phase(index: number): number;
65
+ protected spawn(index: number): void;
66
+ }
67
+ //# sourceMappingURL=launch-sky.d.ts.map
@@ -0,0 +1,157 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LaunchSky = void 0;
4
+ const cyclic_automaton_1 = require("./cyclic-automaton");
5
+ /**
6
+ * The sky of the launch picture, without the page: a cyclic automaton over the sky of `public/launch.svg` (360 by 640,
7
+ * the planet's rim at y 400), the clock of the eras its colours go through, and the strokes painted along its wave fronts.
8
+ * It goes on from where the last launch left it (`kept`): each launch moves the clock on by PER_LAUNCH and the
9
+ * automaton by FIRST_STEPS, so no two launches open on the same sky.
10
+ */
11
+ class LaunchSky {
12
+ constructor(kept, random = Math.random) {
13
+ this.random = random;
14
+ /** Each stroke: where it is (x, y), where it was a frame ago (px, py), how long it has left, its pick (0 to 1) and tone (0, 1 or 2). */
15
+ this.x = new Float32Array(LaunchSky.STROKES);
16
+ this.y = new Float32Array(LaunchSky.STROKES);
17
+ this.px = new Float32Array(LaunchSky.STROKES);
18
+ this.py = new Float32Array(LaunchSky.STROKES);
19
+ this.life = new Float32Array(LaunchSky.STROKES);
20
+ this.pick = new Float32Array(LaunchSky.STROKES);
21
+ this.tone = new Uint8Array(LaunchSky.STROKES);
22
+ this.waiting = 0;
23
+ const { COLS, ROWS, STATES } = LaunchSky;
24
+ const automaton = kept && cyclic_automaton_1.CyclicAutomaton.decode(COLS, ROWS, kept.cells, STATES);
25
+ if (automaton && kept) {
26
+ this.automaton = automaton;
27
+ this.clock = kept.clock + LaunchSky.PER_LAUNCH;
28
+ this.launches = kept.launches + 1;
29
+ this.automaton.plant(random() * COLS, random() * ROWS * 0.8, 5, random() < 0.5 ? -1 : 1);
30
+ for (let step = 0; step < LaunchSky.FIRST_STEPS; step++) {
31
+ if (this.automaton.step() === 0) {
32
+ this.automaton = LaunchSky.seed(random);
33
+ break;
34
+ }
35
+ }
36
+ }
37
+ else {
38
+ this.automaton = LaunchSky.seed(random);
39
+ this.clock = random() * 200;
40
+ this.launches = 1;
41
+ }
42
+ for (let index = 0; index < LaunchSky.STROKES; index++) {
43
+ this.spawn(index);
44
+ this.life[index] *= random();
45
+ }
46
+ }
47
+ static seed(random) {
48
+ return cyclic_automaton_1.CyclicAutomaton.spirals(LaunchSky.COLS, LaunchSky.ROWS, 5 + Math.floor(random() * 3), random, LaunchSky.STATES);
49
+ }
50
+ /** The height of the planet's rim at `x`. */
51
+ static rim(x) {
52
+ const { PLANET } = LaunchSky;
53
+ const dx = Math.min(PLANET.r, Math.abs(x - PLANET.x));
54
+ return PLANET.y - Math.sqrt(PLANET.r * PLANET.r - dx * dx);
55
+ }
56
+ static parse(text) {
57
+ try {
58
+ const kept = JSON.parse(text !== null && text !== void 0 ? text : 'null');
59
+ return typeof (kept === null || kept === void 0 ? void 0 : kept.cells) === 'string' && Number.isFinite(kept.clock) && Number.isInteger(kept.launches) ? kept : undefined;
60
+ }
61
+ catch (_a) {
62
+ return undefined;
63
+ }
64
+ }
65
+ kept() {
66
+ return { cells: this.automaton.encode(), clock: this.clock, launches: this.launches };
67
+ }
68
+ /** `seconds` on: the clock, and the automaton a step every STEP (at most two a frame; a frozen sky is sown again). */
69
+ advance(seconds) {
70
+ this.clock += seconds;
71
+ this.waiting += seconds;
72
+ for (let steps = 0; this.waiting >= LaunchSky.STEP && steps < 2; steps++) {
73
+ this.waiting -= LaunchSky.STEP;
74
+ if (this.automaton.step() === 0) {
75
+ const fresh = LaunchSky.seed(this.random);
76
+ this.automaton.cells.set(fresh.cells);
77
+ }
78
+ }
79
+ this.waiting = Math.min(this.waiting, LaunchSky.STEP);
80
+ }
81
+ /** A new whirl where a finger touched the sky, `x`, `y` in the units of the picture; whether it was the sky. */
82
+ plant(x, y) {
83
+ if (x < 0 || x > 360 || y < 0 || y > LaunchSky.rim(x)) {
84
+ return false;
85
+ }
86
+ this.automaton.plant(x / LaunchSky.CELL, y / LaunchSky.CELL, 6, this.random() < 0.5 ? -1 : 1);
87
+ for (let index = 0; index < LaunchSky.STROKES; index += 8) {
88
+ this.x[index] = this.px[index] = x + (this.random() - 0.5) * 40;
89
+ this.y[index] = this.py[index] = Math.min(LaunchSky.rim(x) - 2, y + (this.random() - 0.5) * 40);
90
+ }
91
+ return true;
92
+ }
93
+ /** Every stroke `seconds` on along the fronts at the pace of `brush`, pushed by `stir` near it; those gone are laid anew. */
94
+ move(seconds, brush, stir) {
95
+ const { CELL } = LaunchSky;
96
+ const speed = 26 * brush.speed;
97
+ for (let index = 0; index < LaunchSky.STROKES; index++) {
98
+ const x = this.x[index];
99
+ const y = this.y[index];
100
+ let [fx, fy] = this.automaton.flow(x / CELL, y / CELL);
101
+ const strength = Math.hypot(fx, fy);
102
+ if (strength < 0.3) {
103
+ // Where the phases lie flat, a stroke runs on as it ran.
104
+ const dx = x - this.px[index];
105
+ const dy = y - this.py[index];
106
+ const ran = Math.hypot(dx, dy) || 1;
107
+ fx = fx + (dx / ran) * (1 - strength);
108
+ fy = fy + (dy / ran) * (1 - strength);
109
+ }
110
+ let vx = fx * speed;
111
+ let vy = fy * speed;
112
+ if (stir) {
113
+ const near = Math.exp(-((x - stir.x) ** 2 + (y - stir.y) ** 2) / 1800);
114
+ vx += stir.vx * near;
115
+ vy += stir.vy * near;
116
+ }
117
+ this.px[index] = x;
118
+ this.py[index] = y;
119
+ this.x[index] = x + vx * seconds;
120
+ this.y[index] = y + vy * seconds;
121
+ this.life[index] -= seconds;
122
+ if (this.life[index] <= 0 || this.x[index] < -4 || this.x[index] > 364 || this.y[index] < -4 || this.y[index] > LaunchSky.rim(this.x[index])) {
123
+ this.spawn(index);
124
+ }
125
+ }
126
+ }
127
+ /** The phase of the automaton under a stroke. */
128
+ phase(index) {
129
+ return this.automaton.phase(this.x[index] / LaunchSky.CELL, this.y[index] / LaunchSky.CELL);
130
+ }
131
+ spawn(index) {
132
+ const x = this.random() * 360;
133
+ const y = this.random() * (LaunchSky.rim(x) - 3);
134
+ const heading = this.random() * Math.PI * 2;
135
+ this.x[index] = x;
136
+ this.y[index] = y;
137
+ // A frame back along a heading of its own: a stroke laid where the phases lie flat runs on that way.
138
+ this.px[index] = x - Math.cos(heading) * 0.01;
139
+ this.py[index] = y - Math.sin(heading) * 0.01;
140
+ this.life[index] = 1.2 + this.random() * 1.8;
141
+ this.pick[index] = this.random();
142
+ this.tone[index] = Math.floor(this.random() * 3);
143
+ }
144
+ }
145
+ exports.LaunchSky = LaunchSky;
146
+ LaunchSky.COLS = 48;
147
+ LaunchSky.ROWS = 55;
148
+ LaunchSky.STATES = 8;
149
+ /** The side of a cell, in the units of the picture. */
150
+ LaunchSky.CELL = 7.5;
151
+ /** Seconds between two steps of the automaton. */
152
+ LaunchSky.STEP = 0.12;
153
+ LaunchSky.PER_LAUNCH = 8;
154
+ LaunchSky.FIRST_STEPS = 24;
155
+ LaunchSky.STROKES = 900;
156
+ LaunchSky.PLANET = { x: 180, y: 1040, r: 640 };
157
+ //# sourceMappingURL=launch-sky.js.map