@h-rig/cli 0.0.6-alpha.89 → 0.0.6-alpha.90

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 (231) hide show
  1. package/dist/bin/build-rig-binaries.js +8 -40
  2. package/dist/bin/rig.js +12519 -26675
  3. package/dist/src/app/board.js +74 -693
  4. package/dist/src/app/drone-ui.js +1 -1
  5. package/dist/src/app/theme.js +0 -1
  6. package/dist/src/commands/_async-ui.js +1 -1
  7. package/dist/src/commands/_authority-runs.d.ts +1 -1
  8. package/dist/src/commands/_authority-runs.js +12 -2
  9. package/dist/src/commands/_cli-format.d.ts +1 -10
  10. package/dist/src/commands/_cli-format.js +2 -5
  11. package/dist/src/commands/_connection-state.d.ts +1 -11
  12. package/dist/src/commands/_connection-state.js +5 -50
  13. package/dist/src/commands/_doctor-checks.js +40 -501
  14. package/dist/src/commands/_help-catalog.js +17 -99
  15. package/dist/src/commands/_json-output.js +0 -4
  16. package/dist/src/commands/_operator-view.js +54 -575
  17. package/dist/src/commands/_pi-frontend.d.ts +0 -27
  18. package/dist/src/commands/_pi-frontend.js +52 -576
  19. package/dist/src/commands/_preflight.js +66 -553
  20. package/dist/src/commands/_server-client.d.ts +0 -33
  21. package/dist/src/commands/_server-client.js +46 -541
  22. package/dist/src/commands/_snapshot-upload.js +42 -503
  23. package/dist/src/commands/_spinner.js +1 -1
  24. package/dist/src/commands/agent.js +12 -2
  25. package/dist/src/commands/browser.js +1 -1
  26. package/dist/src/commands/connect.js +15 -626
  27. package/dist/src/commands/doctor.js +41 -502
  28. package/dist/src/commands/github.js +51 -584
  29. package/dist/src/commands/inbox.js +41 -502
  30. package/dist/src/commands/init.js +74 -561
  31. package/dist/src/commands/inspect.js +41 -502
  32. package/dist/src/commands/run.js +54 -578
  33. package/dist/src/commands/server.js +163 -692
  34. package/dist/src/commands/setup.js +46 -507
  35. package/dist/src/commands/stats.js +58 -601
  36. package/dist/src/commands/task-run-driver.js +58 -509
  37. package/dist/src/commands/task.js +110 -729
  38. package/dist/src/commands.js +237 -1112
  39. package/dist/src/index.js +244 -1123
  40. package/dist/src/launcher.js +0 -4
  41. package/package.json +9 -13
  42. package/dist/src/app-opentui/adapters/command.d.ts +0 -2
  43. package/dist/src/app-opentui/adapters/command.js +0 -329
  44. package/dist/src/app-opentui/adapters/common.d.ts +0 -56
  45. package/dist/src/app-opentui/adapters/common.js +0 -153
  46. package/dist/src/app-opentui/adapters/doctor.d.ts +0 -9
  47. package/dist/src/app-opentui/adapters/doctor.js +0 -1217
  48. package/dist/src/app-opentui/adapters/family.d.ts +0 -62
  49. package/dist/src/app-opentui/adapters/family.js +0 -14855
  50. package/dist/src/app-opentui/adapters/fleet.d.ts +0 -14
  51. package/dist/src/app-opentui/adapters/fleet.js +0 -1335
  52. package/dist/src/app-opentui/adapters/inbox.d.ts +0 -43
  53. package/dist/src/app-opentui/adapters/inbox.js +0 -1944
  54. package/dist/src/app-opentui/adapters/init.d.ts +0 -11
  55. package/dist/src/app-opentui/adapters/init.js +0 -2818
  56. package/dist/src/app-opentui/adapters/inspect.d.ts +0 -52
  57. package/dist/src/app-opentui/adapters/inspect.js +0 -1455
  58. package/dist/src/app-opentui/adapters/pi-attach.d.ts +0 -32
  59. package/dist/src/app-opentui/adapters/pi-attach.js +0 -2101
  60. package/dist/src/app-opentui/adapters/pi.d.ts +0 -23
  61. package/dist/src/app-opentui/adapters/pi.js +0 -363
  62. package/dist/src/app-opentui/adapters/plugin.d.ts +0 -84
  63. package/dist/src/app-opentui/adapters/plugin.js +0 -544
  64. package/dist/src/app-opentui/adapters/repo.d.ts +0 -37
  65. package/dist/src/app-opentui/adapters/repo.js +0 -186
  66. package/dist/src/app-opentui/adapters/run-detail.d.ts +0 -27
  67. package/dist/src/app-opentui/adapters/run-detail.js +0 -1441
  68. package/dist/src/app-opentui/adapters/server.d.ts +0 -48
  69. package/dist/src/app-opentui/adapters/server.js +0 -1561
  70. package/dist/src/app-opentui/adapters/tasks.d.ts +0 -64
  71. package/dist/src/app-opentui/adapters/tasks.js +0 -4524
  72. package/dist/src/app-opentui/adapters/workspace.d.ts +0 -49
  73. package/dist/src/app-opentui/adapters/workspace.js +0 -333
  74. package/dist/src/app-opentui/autocomplete.d.ts +0 -20
  75. package/dist/src/app-opentui/autocomplete.js +0 -578
  76. package/dist/src/app-opentui/bootstrap.d.ts +0 -11
  77. package/dist/src/app-opentui/bootstrap.js +0 -27833
  78. package/dist/src/app-opentui/command-palette.d.ts +0 -3
  79. package/dist/src/app-opentui/command-palette.js +0 -1038
  80. package/dist/src/app-opentui/command-pty-host.d.ts +0 -62
  81. package/dist/src/app-opentui/command-pty-host.js +0 -248
  82. package/dist/src/app-opentui/drone.d.ts +0 -12
  83. package/dist/src/app-opentui/drone.js +0 -230
  84. package/dist/src/app-opentui/events.d.ts +0 -7
  85. package/dist/src/app-opentui/events.js +0 -28
  86. package/dist/src/app-opentui/fleet-stats.d.ts +0 -32
  87. package/dist/src/app-opentui/fleet-stats.js +0 -114
  88. package/dist/src/app-opentui/focus-manager.d.ts +0 -14
  89. package/dist/src/app-opentui/focus-manager.js +0 -24
  90. package/dist/src/app-opentui/index.d.ts +0 -8
  91. package/dist/src/app-opentui/index.js +0 -5260
  92. package/dist/src/app-opentui/intent.d.ts +0 -3
  93. package/dist/src/app-opentui/intent.js +0 -365
  94. package/dist/src/app-opentui/keymap.d.ts +0 -21
  95. package/dist/src/app-opentui/keymap.js +0 -1377
  96. package/dist/src/app-opentui/launch-routing.d.ts +0 -16
  97. package/dist/src/app-opentui/launch-routing.js +0 -55
  98. package/dist/src/app-opentui/layout.d.ts +0 -22
  99. package/dist/src/app-opentui/layout.js +0 -51
  100. package/dist/src/app-opentui/list-search.d.ts +0 -36
  101. package/dist/src/app-opentui/list-search.js +0 -130
  102. package/dist/src/app-opentui/pi-host-child.d.ts +0 -2
  103. package/dist/src/app-opentui/pi-host-child.js +0 -1299
  104. package/dist/src/app-opentui/pi-pty-host.d.ts +0 -28
  105. package/dist/src/app-opentui/pi-pty-host.js +0 -10
  106. package/dist/src/app-opentui/react/App.d.ts +0 -9
  107. package/dist/src/app-opentui/react/App.js +0 -3866
  108. package/dist/src/app-opentui/react/Backdrop.d.ts +0 -5
  109. package/dist/src/app-opentui/react/Backdrop.js +0 -823
  110. package/dist/src/app-opentui/react/ChromeHost.d.ts +0 -5
  111. package/dist/src/app-opentui/react/ChromeHost.js +0 -1539
  112. package/dist/src/app-opentui/react/SceneFrameView.d.ts +0 -7
  113. package/dist/src/app-opentui/react/SceneFrameView.js +0 -579
  114. package/dist/src/app-opentui/react/context.d.ts +0 -17
  115. package/dist/src/app-opentui/react/context.js +0 -37
  116. package/dist/src/app-opentui/react/launch.d.ts +0 -2
  117. package/dist/src/app-opentui/react/launch.js +0 -4897
  118. package/dist/src/app-opentui/react/nav.d.ts +0 -18
  119. package/dist/src/app-opentui/react/nav.js +0 -54
  120. package/dist/src/app-opentui/react/scroll.d.ts +0 -12
  121. package/dist/src/app-opentui/react/scroll.js +0 -21
  122. package/dist/src/app-opentui/react/syntax.d.ts +0 -2
  123. package/dist/src/app-opentui/react/syntax.js +0 -65
  124. package/dist/src/app-opentui/registry.d.ts +0 -4
  125. package/dist/src/app-opentui/registry.js +0 -22876
  126. package/dist/src/app-opentui/remote-link.d.ts +0 -10
  127. package/dist/src/app-opentui/remote-link.js +0 -47
  128. package/dist/src/app-opentui/render/ascii-fleet.d.ts +0 -15
  129. package/dist/src/app-opentui/render/ascii-fleet.js +0 -82
  130. package/dist/src/app-opentui/render/constants.d.ts +0 -30
  131. package/dist/src/app-opentui/render/constants.js +0 -64
  132. package/dist/src/app-opentui/render/graphics.d.ts +0 -40
  133. package/dist/src/app-opentui/render/graphics.js +0 -713
  134. package/dist/src/app-opentui/render/hover.d.ts +0 -11
  135. package/dist/src/app-opentui/render/hover.js +0 -34
  136. package/dist/src/app-opentui/render/native-host.d.ts +0 -37
  137. package/dist/src/app-opentui/render/native-host.js +0 -180
  138. package/dist/src/app-opentui/render/panel-layout.d.ts +0 -38
  139. package/dist/src/app-opentui/render/panel-layout.js +0 -48
  140. package/dist/src/app-opentui/render/panels.d.ts +0 -12
  141. package/dist/src/app-opentui/render/panels.js +0 -288
  142. package/dist/src/app-opentui/render/preloader.d.ts +0 -10
  143. package/dist/src/app-opentui/render/preloader.js +0 -166
  144. package/dist/src/app-opentui/render/scene.d.ts +0 -68
  145. package/dist/src/app-opentui/render/scene.js +0 -300
  146. package/dist/src/app-opentui/render/terminal-handoff.d.ts +0 -16
  147. package/dist/src/app-opentui/render/terminal-handoff.js +0 -14
  148. package/dist/src/app-opentui/render/text.d.ts +0 -29
  149. package/dist/src/app-opentui/render/text.js +0 -177
  150. package/dist/src/app-opentui/render/type-bar.d.ts +0 -15
  151. package/dist/src/app-opentui/render/type-bar.js +0 -212
  152. package/dist/src/app-opentui/runtime-resources.d.ts +0 -16
  153. package/dist/src/app-opentui/runtime-resources.js +0 -62
  154. package/dist/src/app-opentui/runtime.d.ts +0 -45
  155. package/dist/src/app-opentui/runtime.js +0 -5232
  156. package/dist/src/app-opentui/scenes/command.d.ts +0 -3
  157. package/dist/src/app-opentui/scenes/command.js +0 -118
  158. package/dist/src/app-opentui/scenes/doctor.d.ts +0 -3
  159. package/dist/src/app-opentui/scenes/doctor.js +0 -296
  160. package/dist/src/app-opentui/scenes/error.d.ts +0 -2
  161. package/dist/src/app-opentui/scenes/error.js +0 -277
  162. package/dist/src/app-opentui/scenes/family-domains/agent.d.ts +0 -2
  163. package/dist/src/app-opentui/scenes/family-domains/agent.js +0 -349
  164. package/dist/src/app-opentui/scenes/family-domains/browser.d.ts +0 -2
  165. package/dist/src/app-opentui/scenes/family-domains/browser.js +0 -196
  166. package/dist/src/app-opentui/scenes/family-domains/dist.d.ts +0 -2
  167. package/dist/src/app-opentui/scenes/family-domains/dist.js +0 -244
  168. package/dist/src/app-opentui/scenes/family-domains/git.d.ts +0 -2
  169. package/dist/src/app-opentui/scenes/family-domains/git.js +0 -196
  170. package/dist/src/app-opentui/scenes/family-domains/github.d.ts +0 -2
  171. package/dist/src/app-opentui/scenes/family-domains/github.js +0 -275
  172. package/dist/src/app-opentui/scenes/family-domains/harness.d.ts +0 -2
  173. package/dist/src/app-opentui/scenes/family-domains/harness.js +0 -153
  174. package/dist/src/app-opentui/scenes/family-domains/index.d.ts +0 -4
  175. package/dist/src/app-opentui/scenes/family-domains/index.js +0 -1680
  176. package/dist/src/app-opentui/scenes/family-domains/kit.d.ts +0 -76
  177. package/dist/src/app-opentui/scenes/family-domains/kit.js +0 -306
  178. package/dist/src/app-opentui/scenes/family-domains/profile.d.ts +0 -2
  179. package/dist/src/app-opentui/scenes/family-domains/profile.js +0 -213
  180. package/dist/src/app-opentui/scenes/family-domains/queue.d.ts +0 -2
  181. package/dist/src/app-opentui/scenes/family-domains/queue.js +0 -147
  182. package/dist/src/app-opentui/scenes/family-domains/remote.d.ts +0 -2
  183. package/dist/src/app-opentui/scenes/family-domains/remote.js +0 -519
  184. package/dist/src/app-opentui/scenes/family-domains/review.d.ts +0 -2
  185. package/dist/src/app-opentui/scenes/family-domains/review.js +0 -281
  186. package/dist/src/app-opentui/scenes/family-domains/setup.d.ts +0 -2
  187. package/dist/src/app-opentui/scenes/family-domains/setup.js +0 -268
  188. package/dist/src/app-opentui/scenes/family-domains/stats.d.ts +0 -2
  189. package/dist/src/app-opentui/scenes/family-domains/stats.js +0 -371
  190. package/dist/src/app-opentui/scenes/family.d.ts +0 -3
  191. package/dist/src/app-opentui/scenes/family.js +0 -2199
  192. package/dist/src/app-opentui/scenes/fleet.d.ts +0 -3
  193. package/dist/src/app-opentui/scenes/fleet.js +0 -766
  194. package/dist/src/app-opentui/scenes/handoff.d.ts +0 -2
  195. package/dist/src/app-opentui/scenes/handoff.js +0 -455
  196. package/dist/src/app-opentui/scenes/help.d.ts +0 -3
  197. package/dist/src/app-opentui/scenes/help.js +0 -725
  198. package/dist/src/app-opentui/scenes/inbox.d.ts +0 -3
  199. package/dist/src/app-opentui/scenes/inbox.js +0 -427
  200. package/dist/src/app-opentui/scenes/init.d.ts +0 -3
  201. package/dist/src/app-opentui/scenes/init.js +0 -181
  202. package/dist/src/app-opentui/scenes/inspect.d.ts +0 -3
  203. package/dist/src/app-opentui/scenes/inspect.js +0 -794
  204. package/dist/src/app-opentui/scenes/main.d.ts +0 -3
  205. package/dist/src/app-opentui/scenes/main.js +0 -332
  206. package/dist/src/app-opentui/scenes/pi.d.ts +0 -3
  207. package/dist/src/app-opentui/scenes/pi.js +0 -509
  208. package/dist/src/app-opentui/scenes/plugin.d.ts +0 -3
  209. package/dist/src/app-opentui/scenes/plugin.js +0 -487
  210. package/dist/src/app-opentui/scenes/repo.d.ts +0 -3
  211. package/dist/src/app-opentui/scenes/repo.js +0 -425
  212. package/dist/src/app-opentui/scenes/run-detail.d.ts +0 -3
  213. package/dist/src/app-opentui/scenes/run-detail.js +0 -467
  214. package/dist/src/app-opentui/scenes/server.d.ts +0 -3
  215. package/dist/src/app-opentui/scenes/server.js +0 -378
  216. package/dist/src/app-opentui/scenes/tasks.d.ts +0 -3
  217. package/dist/src/app-opentui/scenes/tasks.js +0 -768
  218. package/dist/src/app-opentui/scenes/workspace.d.ts +0 -3
  219. package/dist/src/app-opentui/scenes/workspace.js +0 -427
  220. package/dist/src/app-opentui/selectable.d.ts +0 -19
  221. package/dist/src/app-opentui/selectable.js +0 -80
  222. package/dist/src/app-opentui/state.d.ts +0 -4
  223. package/dist/src/app-opentui/state.js +0 -399
  224. package/dist/src/app-opentui/surface-catalog.d.ts +0 -20
  225. package/dist/src/app-opentui/surface-catalog.js +0 -542
  226. package/dist/src/app-opentui/theme.d.ts +0 -59
  227. package/dist/src/app-opentui/theme.js +0 -142
  228. package/dist/src/app-opentui/types.d.ts +0 -313
  229. package/dist/src/app-opentui/types.js +0 -1
  230. package/dist/src/commands/_server-events.d.ts +0 -26
  231. package/dist/src/commands/_server-events.js +0 -715
@@ -1,713 +0,0 @@
1
- // @bun
2
- // packages/cli/src/app-opentui/render/graphics.ts
3
- import { FrameBufferRenderable, RGBA } from "@opentui/core";
4
-
5
- // packages/cli/src/app-opentui/theme.ts
6
- import {
7
- bold as otuiBold,
8
- dim as otuiDim,
9
- fg as otuiFg,
10
- t,
11
- TextAttributes
12
- } from "@opentui/core";
13
- var RIG_UI = {
14
- bg: "#070809",
15
- bg2: "#0b0c0e",
16
- panel: "#101115",
17
- panel2: "#14161b",
18
- hover: "#181b24",
19
- glass: "#1e2230",
20
- border: "#2a2e3a",
21
- ink: "#f4f5f8",
22
- ink2: "#c7c9d3",
23
- ink3: "#9aa0ae",
24
- ink4: "#787b86",
25
- lime: "#ccff4d",
26
- limeDim: "#a9d63f",
27
- cyan: "#56d8ff",
28
- cyanDim: "#3f9fbd",
29
- red: "#ff5d5d",
30
- yellow: "#ffd24d",
31
- magenta: "#ff79b0"
32
- };
33
- var styles = {
34
- ink: otuiFg(RIG_UI.ink),
35
- ink2: otuiFg(RIG_UI.ink2),
36
- ink3: otuiFg(RIG_UI.ink3),
37
- ink4: otuiFg(RIG_UI.ink4),
38
- lime: otuiFg(RIG_UI.lime),
39
- limeDim: otuiFg(RIG_UI.limeDim),
40
- cyan: otuiFg(RIG_UI.cyan),
41
- red: otuiFg(RIG_UI.red),
42
- yellow: otuiFg(RIG_UI.yellow),
43
- magenta: otuiFg(RIG_UI.magenta)
44
- };
45
-
46
- // packages/cli/src/app-opentui/render/ascii-fleet.ts
47
- var LEAD_DRONE = [
48
- " .-=-. .-=-. ",
49
- " ( !!! ) ( !!! ) ",
50
- " '-=-'._ _.'-=-' ",
51
- " '._ _.' ",
52
- " '=$$$$$$$=.' ",
53
- " =$$$$$$$$$$$= ",
54
- " $$$@@@@@@@@@@$$$ ",
55
- " $$$@@ @@$$$ ",
56
- " $$@ ? @$$$ ",
57
- " $$$@ '-' @$$$ ",
58
- " $$$@@ @@$$$ ",
59
- " $$$@@@@@@@@@@$$$ ",
60
- " =$$$$$$$$$$$= ",
61
- " '=$$$$$$$=.' ",
62
- " _.' '._ ",
63
- " .-=-.' '.-=-. ",
64
- " ( !!! ) ( !!! ) ",
65
- " '-=-' '-=-' "
66
- ];
67
- var MINI_DRONE = [
68
- "(!!!) (!!!)",
69
- " \\%==%/ ",
70
- " %%?%% ",
71
- " /%==%\\ ",
72
- "(!!!) (!!!)"
73
- ];
74
- var ROTORS = ["---", "\\\\\\", "|||", "///"];
75
- var FLEET_GRID_WIDTH = 52;
76
- var FLEET_GRID_HEIGHT = 27;
77
- var FLEET = [
78
- { art: MINI_DRONE, x: 0, y: 2, amp: 1, speed: 0.05, phase: 0, dx: 1, driftSpeed: 0.02 },
79
- { art: MINI_DRONE, x: 39, y: 2, amp: 1, speed: 0.044, phase: 2.1, dx: 1, driftSpeed: 0.017 },
80
- { art: MINI_DRONE, x: 1, y: 20, amp: 1, speed: 0.048, phase: 4.2, dx: 1, driftSpeed: 0.023 },
81
- { art: MINI_DRONE, x: 38, y: 20, amp: 1, speed: 0.041, phase: 1.3, dx: 1, driftSpeed: 0.015 },
82
- { art: LEAD_DRONE, x: 10, y: 5, amp: 2, speed: 0.04, phase: 0, dx: 0, driftSpeed: 0.011 }
83
- ];
84
- function fleetRows(tick, options = {}) {
85
- const animate = options.animate ?? true;
86
- const t2 = animate ? tick : 0;
87
- const blade = ROTORS[Math.floor(t2 / 4) % ROTORS.length];
88
- const pulse = Math.sin(t2 * 0.07);
89
- const eye = pulse > 0.45 ? "@" : pulse > -0.1 ? "o" : ".";
90
- const grid = Array.from({ length: FLEET_GRID_HEIGHT }, () => Array.from({ length: FLEET_GRID_WIDTH }, () => " "));
91
- for (const drone of FLEET) {
92
- const yOffset = drone.y + Math.round(drone.amp * Math.sin(t2 * drone.speed + drone.phase));
93
- const xOffset = drone.x + Math.round(drone.dx * Math.sin(t2 * drone.driftSpeed + drone.phase));
94
- for (let row = 0;row < drone.art.length; row += 1) {
95
- const source = drone.art[row];
96
- const targetY = yOffset + row;
97
- if (targetY < 0 || targetY >= FLEET_GRID_HEIGHT)
98
- continue;
99
- for (let col = 0;col < source.length; col += 1) {
100
- let char = source[col];
101
- if (char === " ")
102
- continue;
103
- const targetX = xOffset + col;
104
- if (targetX < 0 || targetX >= FLEET_GRID_WIDTH)
105
- continue;
106
- if (source.slice(col, col + 3) === "!!!") {
107
- for (let rotorIndex = 0;rotorIndex < 3; rotorIndex += 1) {
108
- if (targetX + rotorIndex < FLEET_GRID_WIDTH)
109
- grid[targetY][targetX + rotorIndex] = blade[rotorIndex];
110
- }
111
- col += 2;
112
- continue;
113
- }
114
- if (char === "?")
115
- char = eye;
116
- grid[targetY][targetX] = char;
117
- }
118
- }
119
- }
120
- return grid.map((row) => row.join("").replace(/\s+$/, ""));
121
- }
122
-
123
- // packages/cli/src/app-opentui/render/panel-layout.ts
124
- function panelCellRect(layout, panel) {
125
- const left = Math.max(0, Math.min(layout.width - 1, layout.centerLeft + (panel.left ?? 0)));
126
- const desiredWidth = panel.width ?? layout.centerWidth;
127
- const width = Math.max(1, Math.min(layout.width - left, desiredWidth));
128
- const top = Math.max(0, Math.min(layout.height - 1, layout.centerTop + panel.top));
129
- const height = Math.max(1, Math.min(layout.height - top, panel.height));
130
- if (width <= 3 || height <= 3)
131
- return null;
132
- const right = left + width - 1;
133
- const bottom = top + height - 1;
134
- const headerHeight = panel.chrome === "ad-terminal" ? Math.max(3, Math.min(height - 2, panel.headerHeight ?? 3)) : 0;
135
- const dividerY = headerHeight ? Math.min(bottom - 1, top + headerHeight) : top;
136
- return { left, top, width, height, right, bottom, headerHeight, dividerY };
137
- }
138
-
139
- // packages/cli/src/app-opentui/render/constants.ts
140
- var LCG_MULTIPLIER = 1664525;
141
- var LCG_INCREMENT = 1013904223;
142
- var LCG_DIVISOR = 4294967295;
143
- var PACKET_CYAN_PROBABILITY = 0.22;
144
- var LANE_INTERP_STEPS = 32;
145
- var LANE_LEN_BASE = 0.32;
146
- var LANE_LEN_SPREAD = 0.42;
147
- var LANE_CURVE_RANGE = 0.7;
148
- var PACKET_SPEED_BASE = 0.003;
149
- var PACKET_SPEED_SPREAD = 0.009;
150
- var DISPATCH_LANES_COMPACT = 7;
151
- var DISPATCH_LANES_WIDE = 12;
152
- var DISPATCH_PACKETS_COMPACT = 70;
153
- var DISPATCH_PACKETS_WIDE = 150;
154
- var CARRIER_NODES_COMPACT = 5;
155
- var CARRIER_NODES_WIDE = 7;
156
- var LOOP_GATES_COMPACT = 4;
157
- var LOOP_GATES_WIDE = 5;
158
- var DISPATCH_DRONES_COMPACT = 4;
159
- var DISPATCH_DRONES_WIDE = 8;
160
- var CORE_DISPATCH_X = 0.3;
161
- var CORE_DISPATCH_Y = 0.45;
162
- var CORE_CARRIER_X = 0.5;
163
- var CORE_CARRIER_Y = 0.54;
164
- var CORE_LOOP_X = 0.09;
165
- var CORE_LOOP_Y = 0.56;
166
- var RAIL_YS_LOOP = [0.18, 0.5, 0.82];
167
- var RAIL_YS_CARRIER = [0.24, 0.54, 0.82];
168
- var RAIL_YS_DISPATCH = [0.18, 0.58, 0.82];
169
- var GLOW_FALLOFF_EXP_ASCII = 2.2;
170
-
171
- // packages/cli/src/app-opentui/render/graphics.ts
172
- var BRAILLE_SAMPLES_X = 2;
173
- var BRAILLE_SAMPLES_Y = 4;
174
- var TRANSPARENT = RGBA.fromValues(0, 0, 0, 0);
175
- var BACKDROP = RGBA.fromHex(RIG_UI.bg);
176
- var PANEL_BG = RGBA.fromInts(16, 17, 21, 184);
177
- var PANEL_HEADER_BG = RGBA.fromInts(16, 17, 21, 188);
178
- var PANEL_LINE = RGBA.fromInts(255, 255, 255, 20);
179
- var PANEL_LINE_DIM = RGBA.fromInts(255, 255, 255, 8);
180
- var PANEL_TEXT_DIM = RGBA.fromInts(108, 110, 121, 255);
181
- var AC_RGB = [204, 255, 77];
182
- var C2_RGB = [86, 216, 255];
183
- var MG_RGB = [255, 121, 176];
184
- var INK_RGB = [108, 110, 121];
185
- var BRAILLE_BITS = [
186
- [1, 8],
187
- [2, 16],
188
- [4, 32],
189
- [64, 128]
190
- ];
191
- function sceneKind(scene) {
192
- if (scene === "tasks")
193
- return "loop";
194
- if (scene === "help")
195
- return "carrier";
196
- return "dispatch";
197
- }
198
- function seeded(seed) {
199
- let value = seed >>> 0;
200
- return () => {
201
- value = value * LCG_MULTIPLIER + LCG_INCREMENT >>> 0;
202
- return value / LCG_DIVISOR;
203
- };
204
- }
205
- function channelBuffer(canvas, channel) {
206
- switch (channel) {
207
- case 0:
208
- return canvas.ac;
209
- case 1:
210
- return canvas.c2;
211
- case 2:
212
- return canvas.mg;
213
- case 3:
214
- return canvas.ink;
215
- }
216
- }
217
- function addSample(canvas, channel, x, y, value) {
218
- const ix = Math.trunc(x);
219
- const iy = Math.trunc(y);
220
- if (ix < 0 || iy < 0 || ix >= canvas.width || iy >= canvas.height)
221
- return;
222
- const buffer = channelBuffer(canvas, channel);
223
- const index = iy * canvas.width + ix;
224
- buffer[index] = Math.min(1, buffer[index] + value);
225
- }
226
- function drawDot(canvas, channel, cx, cy, radius, value) {
227
- const minX = Math.floor(cx - radius);
228
- const maxX = Math.ceil(cx + radius);
229
- const minY = Math.floor(cy - radius);
230
- const maxY = Math.ceil(cy + radius);
231
- for (let y = minY;y <= maxY; y += 1) {
232
- for (let x = minX;x <= maxX; x += 1) {
233
- const dx = x - cx;
234
- const dy = y - cy;
235
- const distance = Math.sqrt(dx * dx + dy * dy);
236
- if (distance > radius)
237
- continue;
238
- const falloff = 1 - distance / Math.max(0.001, radius);
239
- addSample(canvas, channel, x, y, value * (0.28 + falloff * 0.72));
240
- }
241
- }
242
- }
243
- function drawGlow(canvas, channel, cx, cy, radius, value) {
244
- const minX = Math.floor(cx - radius);
245
- const maxX = Math.ceil(cx + radius);
246
- const minY = Math.floor(cy - radius);
247
- const maxY = Math.ceil(cy + radius);
248
- for (let y = minY;y <= maxY; y += 1) {
249
- for (let x = minX;x <= maxX; x += 1) {
250
- const dx = x - cx;
251
- const dy = y - cy;
252
- const distance = Math.sqrt(dx * dx + dy * dy);
253
- if (distance > radius)
254
- continue;
255
- const falloff = Math.pow(1 - distance / Math.max(0.001, radius), GLOW_FALLOFF_EXP_ASCII);
256
- addSample(canvas, channel, x, y, value * falloff);
257
- }
258
- }
259
- }
260
- function drawLine(canvas, channel, x0, y0, x1, y1, value, width = 0.8) {
261
- const dx = x1 - x0;
262
- const dy = y1 - y0;
263
- const steps = Math.max(1, Math.ceil(Math.hypot(dx, dy) * 1.7));
264
- for (let step = 0;step <= steps; step += 1) {
265
- const t2 = step / steps;
266
- const x = x0 + dx * t2;
267
- const y = y0 + dy * t2;
268
- drawDot(canvas, channel, x, y, width, value);
269
- }
270
- }
271
- function drawCircleStroke(canvas, channel, cx, cy, radius, value) {
272
- const steps = Math.max(18, Math.ceil(radius * 8));
273
- for (let step = 0;step < steps; step += 1) {
274
- const a = step / steps * Math.PI * 2;
275
- drawDot(canvas, channel, cx + Math.cos(a) * radius, cy + Math.sin(a) * radius, 0.72, value);
276
- }
277
- }
278
- function paletteColor(ac, c2, mg, ink) {
279
- const total = Math.max(0.001, ac + c2 + mg + ink);
280
- const r = (AC_RGB[0] * ac + C2_RGB[0] * c2 + MG_RGB[0] * mg + INK_RGB[0] * ink) / total;
281
- const g = (AC_RGB[1] * ac + C2_RGB[1] * c2 + MG_RGB[1] * mg + INK_RGB[1] * ink) / total;
282
- const b = (AC_RGB[2] * ac + C2_RGB[2] * c2 + MG_RGB[2] * mg + INK_RGB[2] * ink) / total;
283
- const intensity = Math.min(1, total / 4);
284
- const lift = 0.34 + intensity * 0.66;
285
- return RGBA.fromInts(Math.round(r * lift), Math.round(g * lift), Math.round(b * lift), 255);
286
- }
287
- function clearCanvas(canvas) {
288
- canvas.ac.fill(0);
289
- canvas.c2.fill(0);
290
- canvas.mg.fill(0);
291
- canvas.ink.fill(0);
292
- }
293
- function makeCanvas(layout) {
294
- const width = Math.max(1, layout.width * BRAILLE_SAMPLES_X);
295
- const height = Math.max(1, layout.height * BRAILLE_SAMPLES_Y);
296
- const size = width * height;
297
- return {
298
- width,
299
- height,
300
- ac: new Float32Array(size),
301
- c2: new Float32Array(size),
302
- mg: new Float32Array(size),
303
- ink: new Float32Array(size)
304
- };
305
- }
306
-
307
- class MarketingGlyphCanvas {
308
- rand = seeded(6221137);
309
- canvas;
310
- layout;
311
- activeKind = null;
312
- lanes = [];
313
- motes = [];
314
- packets = [];
315
- constructor(layout) {
316
- this.layout = layout;
317
- this.canvas = makeCanvas(layout);
318
- this.reset("dispatch");
319
- }
320
- resize(layout) {
321
- if (layout.width === this.layout.width && layout.height === this.layout.height)
322
- return;
323
- this.layout = layout;
324
- this.canvas = makeCanvas(layout);
325
- this.reset(this.activeKind ?? "dispatch");
326
- }
327
- render(layer, scene, tick) {
328
- const kind = sceneKind(scene);
329
- if (kind !== this.activeKind)
330
- this.reset(kind);
331
- clearCanvas(this.canvas);
332
- this.drawMarketingRails(kind, tick);
333
- if (kind === "loop")
334
- this.drawLoop(tick);
335
- else if (kind === "carrier")
336
- this.drawCarrier(tick);
337
- else
338
- this.drawDispatch(tick);
339
- this.blit(layer);
340
- }
341
- reset(kind) {
342
- this.activeKind = kind;
343
- this.lanes = [];
344
- this.motes = [];
345
- this.packets = [];
346
- if (kind === "dispatch")
347
- this.setupDispatch();
348
- else if (kind === "loop")
349
- this.setupLoop();
350
- else
351
- this.setupCarrier();
352
- }
353
- setupDispatch() {
354
- const count = this.layout.compact ? DISPATCH_LANES_COMPACT : DISPATCH_LANES_WIDE;
355
- for (let i = 0;i < count; i += 1) {
356
- const ang = (-0.9 + 1.8 * (i / Math.max(1, count - 1))) * (Math.PI * 0.5);
357
- this.lanes.push({ ang, len: this.canvas.width * (LANE_LEN_BASE + this.rand() * LANE_LEN_SPREAD), curve: (this.rand() - 0.5) * LANE_CURVE_RANGE, phase: this.rand() * Math.PI * 2 });
358
- }
359
- const packets = this.layout.compact ? DISPATCH_PACKETS_COMPACT : DISPATCH_PACKETS_WIDE;
360
- for (let i = 0;i < packets; i += 1)
361
- this.packets.push(this.packet(true));
362
- }
363
- setupLoop() {
364
- const lanes = this.layout.compact ? 4 : 7;
365
- for (let i = 0;i < lanes; i += 1)
366
- this.packets.push(this.packet(true));
367
- }
368
- setupCarrier() {
369
- const nodes = this.layout.compact ? CARRIER_NODES_COMPACT : CARRIER_NODES_WIDE;
370
- for (let i = 0;i < nodes * 6; i += 1)
371
- this.packets.push(this.packet(true));
372
- }
373
- packet(random = false) {
374
- return {
375
- lane: Math.floor(this.rand() * Math.max(1, this.lanes.length || 7)),
376
- p: random ? this.rand() : 0,
377
- spd: PACKET_SPEED_BASE + this.rand() * PACKET_SPEED_SPREAD,
378
- channel: this.rand() < PACKET_CYAN_PROBABILITY ? 1 : 0,
379
- wobble: (this.rand() - 0.5) * 7,
380
- size: 0.8 + this.rand() * 1.3
381
- };
382
- }
383
- core(kind) {
384
- if (kind === "dispatch")
385
- return { x: this.canvas.width * CORE_DISPATCH_X, y: this.canvas.height * CORE_DISPATCH_Y };
386
- if (kind === "carrier")
387
- return { x: this.canvas.width * CORE_CARRIER_X, y: this.canvas.height * CORE_CARRIER_Y };
388
- return { x: this.canvas.width * CORE_LOOP_X, y: this.canvas.height * CORE_LOOP_Y };
389
- }
390
- lanePoint(lane, p, kind = "dispatch") {
391
- const core = this.core(kind);
392
- const dist = lane.len * p;
393
- const bend = Math.sin(p * Math.PI) * lane.curve * 28;
394
- const ux = Math.cos(lane.ang);
395
- const uy = Math.sin(lane.ang);
396
- return { x: core.x + ux * dist + -uy * bend, y: core.y + uy * dist + ux * bend };
397
- }
398
- drawMotes(tick) {
399
- for (const mote of this.motes) {
400
- mote.x += 0.1 * mote.z;
401
- if (mote.x > this.canvas.width + 2)
402
- mote.x = -2;
403
- const alpha = (0.035 + 0.08 * mote.z) * (0.55 + 0.45 * Math.sin(tick * 0.03 + mote.tw));
404
- drawDot(this.canvas, mote.channel, mote.x, mote.y, 0.45 * mote.z, alpha);
405
- }
406
- }
407
- drawMarketingRails(kind, tick) {
408
- const ys = kind === "loop" ? RAIL_YS_LOOP : kind === "carrier" ? RAIL_YS_CARRIER : RAIL_YS_DISPATCH;
409
- ys.forEach((ratio, index) => {
410
- const y = this.canvas.height * ratio + Math.sin(tick * 0.018 + index) * 1.8;
411
- drawLine(this.canvas, index === 1 ? 0 : 1, this.canvas.width * 0.06, y, this.canvas.width * 0.94, y + Math.sin(index) * 2, index === 1 ? 0.11 : 0.07, 0.55);
412
- for (let p = (tick * 0.004 + index * 0.21) % 1;p < 1; p += 0.18 + index * 0.02) {
413
- const x = this.canvas.width * (0.06 + 0.88 * p);
414
- drawDot(this.canvas, index === 2 ? 1 : 0, x, y, 1 + index * 0.25, 0.24);
415
- drawGlow(this.canvas, index === 2 ? 1 : 0, x, y, 3.8, 0.035);
416
- }
417
- });
418
- }
419
- drawDispatch(tick) {
420
- const core = this.core("dispatch");
421
- drawGlow(this.canvas, 0, core.x, core.y, 30, 0.12);
422
- drawDot(this.canvas, 0, core.x, core.y, 2.2, 0.85);
423
- for (const lane of this.lanes) {
424
- let prev = this.lanePoint(lane, 0);
425
- for (let i = 1;i <= LANE_INTERP_STEPS; i += 1) {
426
- const next = this.lanePoint(lane, i / LANE_INTERP_STEPS);
427
- drawLine(this.canvas, lane.phase > Math.PI ? 1 : 0, prev.x, prev.y, next.x, next.y, 0.045, 0.38);
428
- prev = next;
429
- }
430
- }
431
- for (const packet of this.packets) {
432
- packet.p += packet.spd;
433
- if (packet.p > 1)
434
- Object.assign(packet, this.packet(false));
435
- const lane = this.lanes[packet.lane % Math.max(1, this.lanes.length)];
436
- if (!lane)
437
- continue;
438
- const pt = this.lanePoint(lane, packet.p);
439
- const fade = packet.p < 0.1 ? packet.p / 0.1 : packet.p > 0.88 ? (1 - packet.p) / 0.12 : 1;
440
- const y = pt.y + packet.wobble * Math.sin(packet.p * Math.PI * 2);
441
- drawLine(this.canvas, packet.channel, pt.x - 4, y - 1, pt.x, y, 0.08 * fade, 0.38);
442
- drawDot(this.canvas, packet.channel, pt.x, y, packet.size, 0.5 * fade);
443
- drawGlow(this.canvas, packet.channel, pt.x, y, packet.size * 4, 0.045 * fade);
444
- }
445
- for (let i = 0;i < (this.layout.compact ? DISPATCH_DRONES_COMPACT : DISPATCH_DRONES_WIDE); i += 1) {
446
- const lane = this.lanes[i % Math.max(1, this.lanes.length)];
447
- if (!lane)
448
- continue;
449
- const p = (tick * 0.002 + i * 0.13) % 1;
450
- const pt = this.lanePoint(lane, p);
451
- this.drawDrone(pt.x, pt.y + Math.sin(tick * 0.04 + i) * 2, 2.6 + i % 2 * 0.6, tick + i * 11, i % 3 === 0 ? 1 : 0);
452
- }
453
- }
454
- drawLoop(tick) {
455
- const y = this.canvas.height * 0.56;
456
- const x0 = this.canvas.width * 0.09;
457
- const x1 = this.canvas.width * 0.91;
458
- drawLine(this.canvas, 0, x0, y, x1, y, 0.12, 0.55);
459
- const gates = this.layout.compact ? LOOP_GATES_COMPACT : LOOP_GATES_WIDE;
460
- const active = Math.floor(tick / 16) % gates;
461
- for (let i = 0;i < gates; i += 1) {
462
- const x = x0 + (x1 - x0) * (i / Math.max(1, gates - 1));
463
- drawLine(this.canvas, i === active ? 0 : 3, x, y - 22, x, y + 22, i === active ? 0.25 : 0.08, i === active ? 0.7 : 0.42);
464
- drawDot(this.canvas, i <= active ? 0 : 3, x, y, i === active ? 2.2 : 1.2, i === active ? 0.72 : 0.25);
465
- drawCircleStroke(this.canvas, i <= active ? 0 : 3, x, y, i === active ? 4.2 : 2.4, i === active ? 0.18 : 0.08);
466
- }
467
- for (const packet of this.packets) {
468
- packet.p += packet.spd * 0.7;
469
- if (packet.p > 1)
470
- packet.p = 0;
471
- const x = x0 + (x1 - x0) * packet.p;
472
- const segment = Math.min(gates - 1, Math.floor(packet.p * gates));
473
- const channel = segment < active ? 0 : segment === active ? 1 : 3;
474
- const py = y + packet.wobble * Math.sin(packet.p * Math.PI * 2);
475
- drawLine(this.canvas, channel, x - 6, py, x, py, 0.1, 0.42);
476
- drawDot(this.canvas, channel, x, py, packet.size, channel === 3 ? 0.22 : 0.58);
477
- drawGlow(this.canvas, channel, x, py, 3.8, channel === 3 ? 0.02 : 0.04);
478
- }
479
- this.drawDrone(x0 + (x1 - x0) * (tick * 0.003 % 1), y - 18, 2.7, tick, 0);
480
- this.drawDrone(x0 + (x1 - x0) * ((tick * 0.002 + 0.5) % 1), y + 16, 2.2, tick + 40, 2);
481
- }
482
- drawCarrier(tick) {
483
- const core = this.core("carrier");
484
- drawGlow(this.canvas, 0, core.x, core.y, 26, 0.12);
485
- drawDot(this.canvas, 0, core.x, core.y, 2.4, 0.92);
486
- drawCircleStroke(this.canvas, 0, core.x, core.y, 8 + Math.sin(tick * 0.06) * 2, 0.14);
487
- const nodes = this.layout.compact ? CARRIER_NODES_COMPACT : CARRIER_NODES_WIDE;
488
- const rx = this.canvas.width * 0.36;
489
- const ry = this.canvas.height * 0.22;
490
- for (let i = 0;i < nodes; i += 1) {
491
- const a = i / nodes * Math.PI * 2 - Math.PI / 2 + tick * 0.006;
492
- const x = core.x + Math.cos(a) * rx;
493
- const y = core.y + Math.sin(a) * ry;
494
- drawLine(this.canvas, i % 2 ? 1 : 0, core.x, core.y, x, y, 0.055, 0.36);
495
- drawCircleStroke(this.canvas, i % 2 ? 1 : 0, x, y, 4.2, 0.15);
496
- drawDot(this.canvas, i % 2 ? 1 : 0, x, y, 1.7, 0.62);
497
- this.drawDrone(x, y - 8, 2.1, tick + i * 9, i % 2 ? 1 : 0);
498
- }
499
- for (const packet of this.packets) {
500
- packet.p += packet.spd;
501
- if (packet.p > 1)
502
- packet.p = 0;
503
- const lane = packet.lane % nodes;
504
- const a = lane / nodes * Math.PI * 2 - Math.PI / 2 + tick * 0.006;
505
- const nx = core.x + Math.cos(a) * rx;
506
- const ny = core.y + Math.sin(a) * ry;
507
- const x = core.x + (nx - core.x) * packet.p;
508
- const y = core.y + (ny - core.y) * packet.p;
509
- drawDot(this.canvas, packet.channel, x, y, packet.size, 0.48);
510
- drawGlow(this.canvas, packet.channel, x, y, 3.2, 0.035);
511
- }
512
- }
513
- drawDrone(x, y, scale, tick, channel) {
514
- const wobble = Math.sin(tick * 0.08) * 0.7;
515
- drawDot(this.canvas, channel, x, y + wobble, scale, 0.58);
516
- drawDot(this.canvas, 3, x, y + wobble, Math.max(0.6, scale * 0.28), 0.42);
517
- const rotor = scale * 1.75;
518
- const arms = [
519
- [-rotor, -rotor * 0.75],
520
- [rotor, -rotor * 0.75],
521
- [-rotor, rotor * 0.75],
522
- [rotor, rotor * 0.75]
523
- ];
524
- for (const [dx, dy] of arms) {
525
- drawLine(this.canvas, channel, x, y + wobble, x + dx, y + dy + wobble, 0.11, 0.38);
526
- drawCircleStroke(this.canvas, channel, x + dx, y + dy + wobble, scale * (0.65 + Math.abs(Math.sin(tick * 0.18)) * 0.25), 0.16);
527
- drawDot(this.canvas, channel, x + dx, y + dy + wobble, 0.7, 0.25);
528
- }
529
- drawLine(this.canvas, channel === 1 ? 0 : 1, x - rotor * 2.4, y + wobble + 1.2, x - rotor * 1.2, y + wobble, 0.05, 0.35);
530
- }
531
- blit(layer) {
532
- const fb = layer.frameBuffer;
533
- fb.clear(BACKDROP);
534
- const { width, height, ac, c2, mg, ink } = this.canvas;
535
- for (let cy = 0;cy < this.layout.height; cy += 1) {
536
- for (let cx = 0;cx < this.layout.width; cx += 1) {
537
- let bits = 0;
538
- let acSum = 0;
539
- let c2Sum = 0;
540
- let mgSum = 0;
541
- let inkSum = 0;
542
- for (let sy = 0;sy < BRAILLE_SAMPLES_Y; sy += 1) {
543
- for (let sx = 0;sx < BRAILLE_SAMPLES_X; sx += 1) {
544
- const px = cx * BRAILLE_SAMPLES_X + sx;
545
- const py = cy * BRAILLE_SAMPLES_Y + sy;
546
- if (px >= width || py >= height)
547
- continue;
548
- const index = py * width + px;
549
- const a = ac[index];
550
- const c = c2[index];
551
- const m = mg[index];
552
- const k = ink[index];
553
- const total2 = a + c + m + k;
554
- acSum += a;
555
- c2Sum += c;
556
- mgSum += m;
557
- inkSum += k;
558
- if (total2 > 0.11)
559
- bits |= BRAILLE_BITS[sy][sx];
560
- }
561
- }
562
- const total = acSum + c2Sum + mgSum + inkSum;
563
- if (bits === 0 || total <= 0.02)
564
- continue;
565
- const char = String.fromCharCode(10240 + bits);
566
- fb.setCellWithAlphaBlending(cx, cy, char, paletteColor(acSum, c2Sum, mgSum, inkSum), TRANSPARENT);
567
- }
568
- }
569
- }
570
- }
571
- function createGraphicsLayer(renderer, layout) {
572
- const layer = new FrameBufferRenderable(renderer, {
573
- id: "rig-marketing-glyph-canvas",
574
- width: layout.width,
575
- height: layout.height,
576
- position: "absolute",
577
- left: 0,
578
- top: 0,
579
- respectAlpha: true
580
- });
581
- layer.__rigMarketingCanvas = new MarketingGlyphCanvas(layout);
582
- return layer;
583
- }
584
- function resizeGraphicsLayer(layer, layout) {
585
- if (layer.width !== layout.width)
586
- layer.width = layout.width;
587
- if (layer.height !== layout.height)
588
- layer.height = layout.height;
589
- layer.__rigMarketingCanvas?.resize(layout);
590
- }
591
- function clearGraphicsLayer(layer) {
592
- layer.frameBuffer.clear(BACKDROP);
593
- layer.__rigAmbientKey = undefined;
594
- }
595
- function writeCell(layer, x, y, char, fg, bg) {
596
- layer.frameBuffer.setCellWithAlphaBlending(x, y, char, fg, bg);
597
- }
598
- function drawFullCell(layer, x, y, bg) {
599
- writeCell(layer, x, y, " ", TRANSPARENT, bg);
600
- }
601
- function drawPanelFill(layer, left, top, right, bottom, dividerY) {
602
- const bgForY = (y) => y < dividerY ? PANEL_HEADER_BG : PANEL_BG;
603
- for (let y = top;y <= bottom; y += 1) {
604
- const bg = bgForY(y);
605
- for (let x = left;x <= right; x += 1)
606
- drawFullCell(layer, x, y, bg);
607
- }
608
- }
609
- function drawAdTerminalPanel(layer, layout, panel) {
610
- const rect = panelCellRect(layout, panel);
611
- if (!rect)
612
- return;
613
- const { left, top, width, right, bottom, headerHeight, dividerY } = rect;
614
- drawPanelFill(layer, left, top, right, bottom, dividerY);
615
- if (dividerY > top && dividerY < bottom) {
616
- for (let x = left + 2;x < right - 1; x += 1) {
617
- writeCell(layer, x, dividerY, "\u2500", PANEL_LINE_DIM, PANEL_BG);
618
- }
619
- }
620
- if (panel.headerText) {
621
- const x = left + Math.max(2, Math.min(5, panel.paddingX ?? 4));
622
- const y = top + Math.max(1, Math.floor(headerHeight / 2));
623
- layer.frameBuffer.drawText(panel.headerText.slice(0, Math.max(0, width - 8)), x, y, PANEL_TEXT_DIM, TRANSPARENT);
624
- }
625
- }
626
- function drawPanelChrome(layer, layout, panels) {
627
- for (const panel of panels) {
628
- if (panel.chrome === "ad-terminal")
629
- drawAdTerminalPanel(layer, layout, panel);
630
- }
631
- }
632
- function staticFleetTick(scene) {
633
- let hash = 0;
634
- for (let index = 0;index < scene.length; index += 1)
635
- hash = hash * 33 + scene.charCodeAt(index) >>> 0;
636
- return 11 + hash % 97;
637
- }
638
- function withAlpha(hex, alpha) {
639
- const a = Math.max(0, Math.min(255, Math.round(alpha * 255)));
640
- const [r, g, b] = RGBA.fromHex(hex).toInts();
641
- return RGBA.fromInts(r, g, b, a);
642
- }
643
- function asciiFleetColor(char, row, alpha) {
644
- if (char === "@" || char === "$" || char === "o")
645
- return withAlpha(RIG_UI.lime, alpha);
646
- if (char === "%" || char === "!" || char === "/" || char === "\\" || char === "|")
647
- return withAlpha(RIG_UI.cyan, alpha);
648
- if (char === "." || char === "'" || char === "_" || row < 3 || row > FLEET_GRID_HEIGHT - 4) {
649
- return RGBA.fromInts(108, 110, 121, Math.min(170, Math.max(0, Math.min(255, Math.round(alpha * 255)))));
650
- }
651
- return withAlpha(RIG_UI.limeDim, alpha);
652
- }
653
- var AMBIENT_LOAD_BUCKETS = 5;
654
- function ambientLoadBucket(load) {
655
- if (!Number.isFinite(load))
656
- return 0;
657
- return Math.max(0, Math.min(AMBIENT_LOAD_BUCKETS, Math.round(load * AMBIENT_LOAD_BUCKETS)));
658
- }
659
- function drawAmbientField(layer, layout, _tick, scene = "fleet", load = 0, activeRuns = 0) {
660
- const bucket = ambientLoadBucket(load);
661
- const rows = fleetRows(staticFleetTick(scene), { animate: true });
662
- let droneTotal = 0;
663
- for (const line of rows)
664
- for (const char of line)
665
- if (char === "@" || char === "$" || char === "%")
666
- droneTotal += 1;
667
- const litTarget = Math.max(0, Math.min(droneTotal, Math.floor(activeRuns)));
668
- const key = `${layout.width}x${layout.height}|${scene}|l${bucket}|d${litTarget}`;
669
- if (layer.__rigAmbientKey === key)
670
- return;
671
- const fb = layer.frameBuffer;
672
- fb.clear(BACKDROP);
673
- const left = Math.floor((layout.width - FLEET_GRID_WIDTH) / 2);
674
- const top = Math.floor((layout.height - FLEET_GRID_HEIGHT) / 2);
675
- const baseAlpha = 0.62 + bucket / AMBIENT_LOAD_BUCKETS * 0.18;
676
- let droneIndex = 0;
677
- for (let row = 0;row < rows.length; row += 1) {
678
- const y = top + row;
679
- if (y < 0 || y >= layout.height)
680
- continue;
681
- const line = rows[row];
682
- for (let col = 0;col < line.length; col += 1) {
683
- const x = left + col;
684
- if (x < 0 || x >= layout.width)
685
- continue;
686
- const char = line[col];
687
- if (char === " ")
688
- continue;
689
- const isDrone = char === "@" || char === "$" || char === "%";
690
- const lit = isDrone && droneIndex < litTarget;
691
- if (isDrone)
692
- droneIndex += 1;
693
- const alpha = lit ? 1 : baseAlpha;
694
- fb.setCellWithAlphaBlending(x, y, char, asciiFleetColor(char, row, alpha), TRANSPARENT);
695
- }
696
- }
697
- layer.__rigAmbientKey = key;
698
- }
699
- function drawSparkline(layer, x, y, values, color = RGBA.fromHex(RIG_UI.cyan)) {
700
- const chars = ["\u2581", "\u2582", "\u2583", "\u2584", "\u2585", "\u2586", "\u2587", "\u2588"];
701
- values.forEach((value, index) => {
702
- const level = Math.max(0, Math.min(chars.length - 1, Math.round(value * (chars.length - 1))));
703
- layer.frameBuffer.setCell(x + index, y, chars[level], color, TRANSPARENT);
704
- });
705
- }
706
- export {
707
- resizeGraphicsLayer,
708
- drawSparkline,
709
- drawPanelChrome,
710
- drawAmbientField,
711
- createGraphicsLayer,
712
- clearGraphicsLayer
713
- };