@ibgib/web-gib 0.0.1

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 (372) hide show
  1. package/.ibgibignore +30 -0
  2. package/.vscode/ibgib-snippets.code-snippets +309 -0
  3. package/.vscode/launch.json +25 -0
  4. package/.vscode/settings.json +68 -0
  5. package/.vscode/tasks.json +38 -0
  6. package/CHANGELOG.md +427 -0
  7. package/README.md +66 -0
  8. package/dist/agent-texts/common-agent-texts.d.mts +14 -0
  9. package/dist/agent-texts/common-agent-texts.d.mts.map +1 -0
  10. package/dist/agent-texts/common-agent-texts.mjs +51 -0
  11. package/dist/agent-texts/common-agent-texts.mjs.map +1 -0
  12. package/dist/agent-texts/primary-agent-texts.d.mts +16 -0
  13. package/dist/agent-texts/primary-agent-texts.d.mts.map +1 -0
  14. package/dist/agent-texts/primary-agent-texts.mjs +27 -0
  15. package/dist/agent-texts/primary-agent-texts.mjs.map +1 -0
  16. package/dist/agent-texts/project-agent-texts.d.mts +8 -0
  17. package/dist/agent-texts/project-agent-texts.d.mts.map +1 -0
  18. package/dist/agent-texts/project-agent-texts.mjs +29 -0
  19. package/dist/agent-texts/project-agent-texts.mjs.map +1 -0
  20. package/dist/agent-texts/project-child-text-agent-texts.d.mts +5 -0
  21. package/dist/agent-texts/project-child-text-agent-texts.d.mts.map +1 -0
  22. package/dist/agent-texts/project-child-text-agent-texts.mjs +26 -0
  23. package/dist/agent-texts/project-child-text-agent-texts.mjs.map +1 -0
  24. package/dist/agent-texts/projects-agent-texts.d.mts +4 -0
  25. package/dist/agent-texts/projects-agent-texts.d.mts.map +1 -0
  26. package/dist/agent-texts/projects-agent-texts.mjs +15 -0
  27. package/dist/agent-texts/projects-agent-texts.mjs.map +1 -0
  28. package/dist/agent-texts/raw-agent-texts.d.mts +4 -0
  29. package/dist/agent-texts/raw-agent-texts.d.mts.map +1 -0
  30. package/dist/agent-texts/raw-agent-texts.mjs +17 -0
  31. package/dist/agent-texts/raw-agent-texts.mjs.map +1 -0
  32. package/dist/agent-texts/text-editor-agent-texts.d.mts +6 -0
  33. package/dist/agent-texts/text-editor-agent-texts.d.mts.map +1 -0
  34. package/dist/agent-texts/text-editor-agent-texts.mjs +19 -0
  35. package/dist/agent-texts/text-editor-agent-texts.mjs.map +1 -0
  36. package/dist/api/api-constants.d.mts +9 -0
  37. package/dist/api/api-constants.d.mts.map +1 -0
  38. package/dist/api/api-constants.mjs +9 -0
  39. package/dist/api/api-constants.mjs.map +1 -0
  40. package/dist/api/api-index.d.mts +10 -0
  41. package/dist/api/api-index.d.mts.map +1 -0
  42. package/dist/api/api-index.mjs +121 -0
  43. package/dist/api/api-index.mjs.map +1 -0
  44. package/dist/api/api-types.d.mts +36 -0
  45. package/dist/api/api-types.d.mts.map +1 -0
  46. package/dist/api/api-types.mjs +2 -0
  47. package/dist/api/api-types.mjs.map +1 -0
  48. package/dist/api/commands/chat/chat-index.d.mts +3 -0
  49. package/dist/api/commands/chat/chat-index.d.mts.map +1 -0
  50. package/dist/api/commands/chat/chat-index.mjs +9 -0
  51. package/dist/api/commands/chat/chat-index.mjs.map +1 -0
  52. package/dist/api/commands/chat/get-context-info.d.mts +71 -0
  53. package/dist/api/commands/chat/get-context-info.d.mts.map +1 -0
  54. package/dist/api/commands/chat/get-context-info.mjs +130 -0
  55. package/dist/api/commands/chat/get-context-info.mjs.map +1 -0
  56. package/dist/api/commands/chat/hello-world.d.mts +63 -0
  57. package/dist/api/commands/chat/hello-world.d.mts.map +1 -0
  58. package/dist/api/commands/chat/hello-world.mjs +132 -0
  59. package/dist/api/commands/chat/hello-world.mjs.map +1 -0
  60. package/dist/api/commands/chat/tell-user.d.mts +57 -0
  61. package/dist/api/commands/chat/tell-user.d.mts.map +1 -0
  62. package/dist/api/commands/chat/tell-user.mjs +199 -0
  63. package/dist/api/commands/chat/tell-user.mjs.map +1 -0
  64. package/dist/api/commands/command-constants.d.mts +22 -0
  65. package/dist/api/commands/command-constants.d.mts.map +1 -0
  66. package/dist/api/commands/command-constants.mjs +17 -0
  67. package/dist/api/commands/command-constants.mjs.map +1 -0
  68. package/dist/api/commands/command-helpers.d.mts +47 -0
  69. package/dist/api/commands/command-helpers.d.mts.map +1 -0
  70. package/dist/api/commands/command-helpers.mjs +76 -0
  71. package/dist/api/commands/command-helpers.mjs.map +1 -0
  72. package/dist/api/commands/command-service-v1.d.mts +28 -0
  73. package/dist/api/commands/command-service-v1.d.mts.map +1 -0
  74. package/dist/api/commands/command-service-v1.mjs +122 -0
  75. package/dist/api/commands/command-service-v1.mjs.map +1 -0
  76. package/dist/api/commands/command-service.respec.d.mts +7 -0
  77. package/dist/api/commands/command-service.respec.d.mts.map +1 -0
  78. package/dist/api/commands/command-service.respec.mjs +66 -0
  79. package/dist/api/commands/command-service.respec.mjs.map +1 -0
  80. package/dist/api/commands/command-types.d.mts +48 -0
  81. package/dist/api/commands/command-types.d.mts.map +1 -0
  82. package/dist/api/commands/command-types.mjs +12 -0
  83. package/dist/api/commands/command-types.mjs.map +1 -0
  84. package/dist/api/commands/ibgib/get-ibgibs.d.mts +94 -0
  85. package/dist/api/commands/ibgib/get-ibgibs.d.mts.map +1 -0
  86. package/dist/api/commands/ibgib/get-ibgibs.mjs +219 -0
  87. package/dist/api/commands/ibgib/get-ibgibs.mjs.map +1 -0
  88. package/dist/api/commands/ibgib/ibgib-index.d.mts +3 -0
  89. package/dist/api/commands/ibgib/ibgib-index.d.mts.map +1 -0
  90. package/dist/api/commands/ibgib/ibgib-index.mjs +7 -0
  91. package/dist/api/commands/ibgib/ibgib-index.mjs.map +1 -0
  92. package/dist/api/commands/ibgib/mut8-ibgib.d.mts +135 -0
  93. package/dist/api/commands/ibgib/mut8-ibgib.d.mts.map +1 -0
  94. package/dist/api/commands/ibgib/mut8-ibgib.mjs +318 -0
  95. package/dist/api/commands/ibgib/mut8-ibgib.mjs.map +1 -0
  96. package/dist/api/commands/templates/api-function-info.template.d.mts +73 -0
  97. package/dist/api/commands/templates/api-function-info.template.d.mts.map +1 -0
  98. package/dist/api/commands/templates/api-function-info.template.mjs +161 -0
  99. package/dist/api/commands/templates/api-function-info.template.mjs.map +1 -0
  100. package/dist/api/commands/text/text-edit.d.mts +54 -0
  101. package/dist/api/commands/text/text-edit.d.mts.map +1 -0
  102. package/dist/api/commands/text/text-edit.mjs +170 -0
  103. package/dist/api/commands/text/text-edit.mjs.map +1 -0
  104. package/dist/api/commands/text/text-index.d.mts +3 -0
  105. package/dist/api/commands/text/text-index.d.mts.map +1 -0
  106. package/dist/api/commands/text/text-index.mjs +5 -0
  107. package/dist/api/commands/text/text-index.mjs.map +1 -0
  108. package/dist/api/commands/ui/ui-index.d.mts +3 -0
  109. package/dist/api/commands/ui/ui-index.d.mts.map +1 -0
  110. package/dist/api/commands/ui/ui-index.mjs +5 -0
  111. package/dist/api/commands/ui/ui-index.mjs.map +1 -0
  112. package/dist/api/commands/ui/update-css-variables.d.mts +48 -0
  113. package/dist/api/commands/ui/update-css-variables.d.mts.map +1 -0
  114. package/dist/api/commands/ui/update-css-variables.mjs +145 -0
  115. package/dist/api/commands/ui/update-css-variables.mjs.map +1 -0
  116. package/dist/api/function-infos.web.d.mts +15 -0
  117. package/dist/api/function-infos.web.d.mts.map +1 -0
  118. package/dist/api/function-infos.web.mjs +63 -0
  119. package/dist/api/function-infos.web.mjs.map +1 -0
  120. package/dist/assumptions.respec.d.mts +2 -0
  121. package/dist/assumptions.respec.d.mts.map +1 -0
  122. package/dist/assumptions.respec.mjs +41 -0
  123. package/dist/assumptions.respec.mjs.map +1 -0
  124. package/dist/common/project/project-constants.d.mts +38 -0
  125. package/dist/common/project/project-constants.d.mts.map +1 -0
  126. package/dist/common/project/project-constants.mjs +71 -0
  127. package/dist/common/project/project-constants.mjs.map +1 -0
  128. package/dist/common/project/project-helper.d.mts +127 -0
  129. package/dist/common/project/project-helper.d.mts.map +1 -0
  130. package/dist/common/project/project-helper.mjs +683 -0
  131. package/dist/common/project/project-helper.mjs.map +1 -0
  132. package/dist/common/project/project-types.d.mts +91 -0
  133. package/dist/common/project/project-types.d.mts.map +1 -0
  134. package/dist/common/project/project-types.mjs +31 -0
  135. package/dist/common/project/project-types.mjs.map +1 -0
  136. package/dist/common/prompt-functions.web.d.mts +90 -0
  137. package/dist/common/prompt-functions.web.d.mts.map +1 -0
  138. package/dist/common/prompt-functions.web.mjs +426 -0
  139. package/dist/common/prompt-functions.web.mjs.map +1 -0
  140. package/dist/common/settings/settings-constants.d.mts +33 -0
  141. package/dist/common/settings/settings-constants.d.mts.map +1 -0
  142. package/dist/common/settings/settings-constants.mjs +54 -0
  143. package/dist/common/settings/settings-constants.mjs.map +1 -0
  144. package/dist/common/settings/settings-helpers.d.mts +59 -0
  145. package/dist/common/settings/settings-helpers.d.mts.map +1 -0
  146. package/dist/common/settings/settings-helpers.mjs +253 -0
  147. package/dist/common/settings/settings-helpers.mjs.map +1 -0
  148. package/dist/common/settings/settings-types.d.mts +118 -0
  149. package/dist/common/settings/settings-types.d.mts.map +1 -0
  150. package/dist/common/settings/settings-types.mjs +13 -0
  151. package/dist/common/settings/settings-types.mjs.map +1 -0
  152. package/dist/constants.d.mts +34 -0
  153. package/dist/constants.d.mts.map +1 -0
  154. package/dist/constants.mjs +35 -0
  155. package/dist/constants.mjs.map +1 -0
  156. package/dist/foo.d.mts +2 -0
  157. package/dist/foo.d.mts.map +1 -0
  158. package/dist/foo.mjs +19 -0
  159. package/dist/foo.mjs.map +1 -0
  160. package/dist/helpers.d.mts +137 -0
  161. package/dist/helpers.d.mts.map +1 -0
  162. package/dist/helpers.mjs +514 -0
  163. package/dist/helpers.mjs.map +1 -0
  164. package/dist/helpers.web.d.mts +324 -0
  165. package/dist/helpers.web.d.mts.map +1 -0
  166. package/dist/helpers.web.mjs +1133 -0
  167. package/dist/helpers.web.mjs.map +1 -0
  168. package/dist/helpers.web.respec.d.mts +2 -0
  169. package/dist/helpers.web.respec.d.mts.map +1 -0
  170. package/dist/helpers.web.respec.mjs +12 -0
  171. package/dist/helpers.web.respec.mjs.map +1 -0
  172. package/dist/index.d.mts +2 -0
  173. package/dist/index.d.mts.map +1 -0
  174. package/dist/index.mjs +3 -0
  175. package/dist/index.mjs.map +1 -0
  176. package/dist/respec-gib.node.d.mts +2 -0
  177. package/dist/respec-gib.node.d.mts.map +1 -0
  178. package/dist/respec-gib.node.mjs +211 -0
  179. package/dist/respec-gib.node.mjs.map +1 -0
  180. package/dist/spec-helper.node.respec.d.mts +13 -0
  181. package/dist/spec-helper.node.respec.d.mts.map +1 -0
  182. package/dist/spec-helper.node.respec.mjs +50 -0
  183. package/dist/spec-helper.node.respec.mjs.map +1 -0
  184. package/dist/storage/storage-helpers.web.d.mts +108 -0
  185. package/dist/storage/storage-helpers.web.d.mts.map +1 -0
  186. package/dist/storage/storage-helpers.web.mjs +757 -0
  187. package/dist/storage/storage-helpers.web.mjs.map +1 -0
  188. package/dist/storage/storage-types.web.d.mts +30 -0
  189. package/dist/storage/storage-types.web.d.mts.map +1 -0
  190. package/dist/storage/storage-types.web.mjs +2 -0
  191. package/dist/storage/storage-types.web.mjs.map +1 -0
  192. package/dist/types.web.d.mts +42 -0
  193. package/dist/types.web.d.mts.map +1 -0
  194. package/dist/types.web.mjs +2 -0
  195. package/dist/types.web.mjs.map +1 -0
  196. package/dist/ui/component/component-types.d.mts +225 -0
  197. package/dist/ui/component/component-types.d.mts.map +1 -0
  198. package/dist/ui/component/component-types.mjs +2 -0
  199. package/dist/ui/component/component-types.mjs.map +1 -0
  200. package/dist/ui/component/ibgib-component-service.d.mts +70 -0
  201. package/dist/ui/component/ibgib-component-service.d.mts.map +1 -0
  202. package/dist/ui/component/ibgib-component-service.mjs +201 -0
  203. package/dist/ui/component/ibgib-component-service.mjs.map +1 -0
  204. package/dist/ui/component/ibgib-dynamic-component-bases.d.mts +338 -0
  205. package/dist/ui/component/ibgib-dynamic-component-bases.d.mts.map +1 -0
  206. package/dist/ui/component/ibgib-dynamic-component-bases.mjs +1304 -0
  207. package/dist/ui/component/ibgib-dynamic-component-bases.mjs.map +1 -0
  208. package/dist/ui/ui-constants.d.mts +12 -0
  209. package/dist/ui/ui-constants.d.mts.map +1 -0
  210. package/dist/ui/ui-constants.mjs +93 -0
  211. package/dist/ui/ui-constants.mjs.map +1 -0
  212. package/dist/ui/ui-helpers.d.mts +42 -0
  213. package/dist/ui/ui-helpers.d.mts.map +1 -0
  214. package/dist/ui/ui-helpers.mjs +198 -0
  215. package/dist/ui/ui-helpers.mjs.map +1 -0
  216. package/dist/ui/ui-types.d.mts +13 -0
  217. package/dist/ui/ui-types.d.mts.map +1 -0
  218. package/dist/ui/ui-types.mjs +2 -0
  219. package/dist/ui/ui-types.mjs.map +1 -0
  220. package/dist/witness/agent/agent-constants.d.mts +97 -0
  221. package/dist/witness/agent/agent-constants.d.mts.map +1 -0
  222. package/dist/witness/agent/agent-constants.mjs +98 -0
  223. package/dist/witness/agent/agent-constants.mjs.map +1 -0
  224. package/dist/witness/agent/agent-helpers.d.mts +106 -0
  225. package/dist/witness/agent/agent-helpers.d.mts.map +1 -0
  226. package/dist/witness/agent/agent-helpers.mjs +601 -0
  227. package/dist/witness/agent/agent-helpers.mjs.map +1 -0
  228. package/dist/witness/agent/agent-one-file.app.d.mts +2 -0
  229. package/dist/witness/agent/agent-one-file.app.d.mts.map +1 -0
  230. package/dist/witness/agent/agent-one-file.app.mjs +8 -0
  231. package/dist/witness/agent/agent-one-file.app.mjs.map +1 -0
  232. package/dist/witness/agent/agent-one-file.d.mts +478 -0
  233. package/dist/witness/agent/agent-one-file.d.mts.map +1 -0
  234. package/dist/witness/agent/agent-one-file.mjs +1462 -0
  235. package/dist/witness/agent/agent-one-file.mjs.map +1 -0
  236. package/dist/witness/agent/agent-types.d.mts +83 -0
  237. package/dist/witness/agent/agent-types.d.mts.map +1 -0
  238. package/dist/witness/agent/agent-types.mjs +2 -0
  239. package/dist/witness/agent/agent-types.mjs.map +1 -0
  240. package/dist/witness/agent/agents-service-v1.d.mts +99 -0
  241. package/dist/witness/agent/agents-service-v1.d.mts.map +1 -0
  242. package/dist/witness/agent/agents-service-v1.mjs +453 -0
  243. package/dist/witness/agent/agents-service-v1.mjs.map +1 -0
  244. package/dist/witness/agent/function-info/function-info-one-file.d.mts +192 -0
  245. package/dist/witness/agent/function-info/function-info-one-file.d.mts.map +1 -0
  246. package/dist/witness/agent/function-info/function-info-one-file.mjs +192 -0
  247. package/dist/witness/agent/function-info/function-info-one-file.mjs.map +1 -0
  248. package/dist/witness/agent/gemini/agent-witness-gemini-v1.d.mts +51 -0
  249. package/dist/witness/agent/gemini/agent-witness-gemini-v1.d.mts.map +1 -0
  250. package/dist/witness/agent/gemini/agent-witness-gemini-v1.mjs +928 -0
  251. package/dist/witness/agent/gemini/agent-witness-gemini-v1.mjs.map +1 -0
  252. package/dist/witness/agent/gemini/gemini-agent-factory.d.mts +27 -0
  253. package/dist/witness/agent/gemini/gemini-agent-factory.d.mts.map +1 -0
  254. package/dist/witness/agent/gemini/gemini-agent-factory.mjs +144 -0
  255. package/dist/witness/agent/gemini/gemini-agent-factory.mjs.map +1 -0
  256. package/dist/witness/agent/gemini/gemini-constants.d.mts +36 -0
  257. package/dist/witness/agent/gemini/gemini-constants.d.mts.map +1 -0
  258. package/dist/witness/agent/gemini/gemini-constants.mjs +47 -0
  259. package/dist/witness/agent/gemini/gemini-constants.mjs.map +1 -0
  260. package/dist/witness/agent/gemini/gemini-helpers.d.mts +58 -0
  261. package/dist/witness/agent/gemini/gemini-helpers.d.mts.map +1 -0
  262. package/dist/witness/agent/gemini/gemini-helpers.mjs +210 -0
  263. package/dist/witness/agent/gemini/gemini-helpers.mjs.map +1 -0
  264. package/dist/witness/agent/gemini/gemini-types.d.mts +82 -0
  265. package/dist/witness/agent/gemini/gemini-types.d.mts.map +1 -0
  266. package/dist/witness/agent/gemini/gemini-types.mjs +3 -0
  267. package/dist/witness/agent/gemini/gemini-types.mjs.map +1 -0
  268. package/dist/witness/live-proxy-ibgib/live-proxy-ibgib-one-file.d.mts +136 -0
  269. package/dist/witness/live-proxy-ibgib/live-proxy-ibgib-one-file.d.mts.map +1 -0
  270. package/dist/witness/live-proxy-ibgib/live-proxy-ibgib-one-file.mjs +334 -0
  271. package/dist/witness/live-proxy-ibgib/live-proxy-ibgib-one-file.mjs.map +1 -0
  272. package/dist/witness/space/metaspace/metaspace-webspace/metaspace-webspace-helper.d.mts +35 -0
  273. package/dist/witness/space/metaspace/metaspace-webspace/metaspace-webspace-helper.d.mts.map +1 -0
  274. package/dist/witness/space/metaspace/metaspace-webspace/metaspace-webspace-helper.mjs +267 -0
  275. package/dist/witness/space/metaspace/metaspace-webspace/metaspace-webspace-helper.mjs.map +1 -0
  276. package/dist/witness/space/metaspace/metaspace-webspace/metaspace-webspace.d.mts +134 -0
  277. package/dist/witness/space/metaspace/metaspace-webspace/metaspace-webspace.d.mts.map +1 -0
  278. package/dist/witness/space/metaspace/metaspace-webspace/metaspace-webspace.mjs +389 -0
  279. package/dist/witness/space/metaspace/metaspace-webspace/metaspace-webspace.mjs.map +1 -0
  280. package/dist/witness/space/web-filesystem-space/web-filesystem-space-constants.d.mts +2 -0
  281. package/dist/witness/space/web-filesystem-space/web-filesystem-space-constants.d.mts.map +1 -0
  282. package/dist/witness/space/web-filesystem-space/web-filesystem-space-constants.mjs +2 -0
  283. package/dist/witness/space/web-filesystem-space/web-filesystem-space-constants.mjs.map +1 -0
  284. package/dist/witness/space/web-filesystem-space/web-filesystem-space-helper.d.mts +104 -0
  285. package/dist/witness/space/web-filesystem-space/web-filesystem-space-helper.d.mts.map +1 -0
  286. package/dist/witness/space/web-filesystem-space/web-filesystem-space-helper.mjs +457 -0
  287. package/dist/witness/space/web-filesystem-space/web-filesystem-space-helper.mjs.map +1 -0
  288. package/dist/witness/space/web-filesystem-space/web-filesystem-space-types.d.mts +93 -0
  289. package/dist/witness/space/web-filesystem-space/web-filesystem-space-types.d.mts.map +1 -0
  290. package/dist/witness/space/web-filesystem-space/web-filesystem-space-types.mjs +98 -0
  291. package/dist/witness/space/web-filesystem-space/web-filesystem-space-types.mjs.map +1 -0
  292. package/dist/witness/space/web-filesystem-space/web-filesystem-space-v1.d.mts +73 -0
  293. package/dist/witness/space/web-filesystem-space/web-filesystem-space-v1.d.mts.map +1 -0
  294. package/dist/witness/space/web-filesystem-space/web-filesystem-space-v1.mjs +650 -0
  295. package/dist/witness/space/web-filesystem-space/web-filesystem-space-v1.mjs.map +1 -0
  296. package/generate-version-file.js +29 -0
  297. package/package.json +60 -0
  298. package/src/agent-texts/common-agent-texts.mts +61 -0
  299. package/src/agent-texts/primary-agent-texts.mts +32 -0
  300. package/src/agent-texts/project-agent-texts.mts +29 -0
  301. package/src/agent-texts/project-child-text-agent-texts.mts +30 -0
  302. package/src/agent-texts/projects-agent-texts.mts +17 -0
  303. package/src/agent-texts/raw-agent-texts.mts +18 -0
  304. package/src/agent-texts/text-editor-agent-texts.mts +20 -0
  305. package/src/api/api-constants.mts +8 -0
  306. package/src/api/api-index.mts +110 -0
  307. package/src/api/api-types.mts +36 -0
  308. package/src/api/commands/chat/chat-index.mts +10 -0
  309. package/src/api/commands/chat/get-context-info.mts +196 -0
  310. package/src/api/commands/chat/hello-world.mts +183 -0
  311. package/src/api/commands/chat/tell-user.mts +241 -0
  312. package/src/api/commands/command-constants.mts +17 -0
  313. package/src/api/commands/command-helpers.mts +105 -0
  314. package/src/api/commands/command-service-v1.mts +136 -0
  315. package/src/api/commands/command-service.respec.mts +72 -0
  316. package/src/api/commands/command-types.mts +71 -0
  317. package/src/api/commands/ibgib/get-ibgibs.mts +269 -0
  318. package/src/api/commands/ibgib/ibgib-index.mts +8 -0
  319. package/src/api/commands/ibgib/mut8-ibgib.mts +418 -0
  320. package/src/api/commands/templates/api-function-info.template.mts +212 -0
  321. package/src/api/commands/text/text-edit.mts +217 -0
  322. package/src/api/commands/text/text-index.mts +6 -0
  323. package/src/api/commands/ui/ui-index.mts +6 -0
  324. package/src/api/commands/ui/update-css-variables.mts +187 -0
  325. package/src/api/function-infos.web.mts +66 -0
  326. package/src/assets/fullscreen-dialog.html +18 -0
  327. package/src/assumptions.respec.mts +51 -0
  328. package/src/common/project/project-constants.mts +83 -0
  329. package/src/common/project/project-helper.mts +730 -0
  330. package/src/common/project/project-types.mts +121 -0
  331. package/src/common/prompt-functions.web.mts +447 -0
  332. package/src/common/settings/settings-constants.mts +72 -0
  333. package/src/common/settings/settings-helpers.mts +280 -0
  334. package/src/common/settings/settings-types.mts +137 -0
  335. package/src/constants.mts +39 -0
  336. package/src/foo.mts +13 -0
  337. package/src/helpers.mts +574 -0
  338. package/src/helpers.web.mts +1277 -0
  339. package/src/helpers.web.respec.mts +16 -0
  340. package/src/index.mts +3 -0
  341. package/src/respec-gib.node.mts +199 -0
  342. package/src/spec-helper.node.respec.mts +50 -0
  343. package/src/storage/storage-helpers.web.mts +728 -0
  344. package/src/storage/storage-types.web.mts +29 -0
  345. package/src/types.web.mts +42 -0
  346. package/src/ui/component/component-types.mts +241 -0
  347. package/src/ui/component/ibgib-component-service.mts +201 -0
  348. package/src/ui/component/ibgib-dynamic-component-bases.mts +1369 -0
  349. package/src/ui/ui-constants.mts +101 -0
  350. package/src/ui/ui-helpers.mts +222 -0
  351. package/src/ui/ui-types.mts +11 -0
  352. package/src/witness/agent/agent-constants.mts +122 -0
  353. package/src/witness/agent/agent-helpers.mts +681 -0
  354. package/src/witness/agent/agent-one-file.app.mts +8 -0
  355. package/src/witness/agent/agent-one-file.mts +1665 -0
  356. package/src/witness/agent/agent-types.mts +92 -0
  357. package/src/witness/agent/agents-service-v1.mts +482 -0
  358. package/src/witness/agent/function-info/function-info-one-file.mts +362 -0
  359. package/src/witness/agent/gemini/agent-witness-gemini-v1.mts +910 -0
  360. package/src/witness/agent/gemini/gemini-agent-factory.mts +135 -0
  361. package/src/witness/agent/gemini/gemini-constants.mts +79 -0
  362. package/src/witness/agent/gemini/gemini-helpers.mts +216 -0
  363. package/src/witness/agent/gemini/gemini-types.mts +88 -0
  364. package/src/witness/live-proxy-ibgib/live-proxy-ibgib-one-file.mts +321 -0
  365. package/src/witness/space/metaspace/metaspace-webspace/metaspace-webspace-helper.mts +290 -0
  366. package/src/witness/space/metaspace/metaspace-webspace/metaspace-webspace.mts +407 -0
  367. package/src/witness/space/web-filesystem-space/web-filesystem-space-constants.mts +1 -0
  368. package/src/witness/space/web-filesystem-space/web-filesystem-space-helper.mts +491 -0
  369. package/src/witness/space/web-filesystem-space/web-filesystem-space-types.mts +172 -0
  370. package/src/witness/space/web-filesystem-space/web-filesystem-space-v1.mts +670 -0
  371. package/tsconfig.json +17 -0
  372. package/tsconfig.test.json +10 -0
@@ -0,0 +1,1304 @@
1
+ /**
2
+ * @module component-one-file.mts contains all the types, helpers, constants and
3
+ * classes for the **shell** ui component system. the differentiating factor
4
+ * between this system and other front end ui frameworks is that this is
5
+ * ibgib-driven, with especially ibgib addresses driving components' backing
6
+ * model/data.
7
+ *
8
+ * this is not to be confused with "components" that may be dynamically
9
+ * generated within a blank-canvas environment that the canvas agents will
10
+ * build. this is for the old-school html shell.
11
+ *
12
+ * the ui component system is being built piecemeal as we go.
13
+ *
14
+ * ## approach
15
+ *
16
+ * there are two basic pieces to a component: the component metadata declaration
17
+ * and the concrete component instance that that declaration instantiates. these
18
+ * will be tightly coupled per use-case, with the intention that the meta object
19
+ * will not need to be a descendant class, whereas the component instance will
20
+ * most likely be the class that is extended from an abstract base class.
21
+ *
22
+ * @see {@link IbGibDynamicComponentMeta}
23
+ * @see {@link IbGibDynamicComponentInstance}
24
+ */
25
+ import { delay, extractErrorMsg, pickRandom_Letters, pretty } from "@ibgib/helper-gib/dist/helpers/utils-helper.mjs";
26
+ import { ROOT_ADDR } from "@ibgib/ts-gib/dist/V1/constants.mjs";
27
+ import { getGibInfo, isDna, isPrimitive } from "@ibgib/ts-gib/dist/V1/transforms/transform-helper.mjs";
28
+ import { getIbAndGib, getIbGibAddr } from "@ibgib/ts-gib/dist/helper.mjs";
29
+ import { Factory_V1 } from "@ibgib/ts-gib/dist/V1/factory.mjs";
30
+ import { fnObs } from "@ibgib/core-gib/dist/common/pubsub/observer/observer-helper.mjs";
31
+ import { getTimelinesGroupedByTjp, getTjpAddr, splitPerTjpAndOrDna, toDto } from "@ibgib/core-gib/dist/common/other/ibgib-helper.mjs";
32
+ import { mut8Timeline } from "@ibgib/core-gib/dist/timeline/timeline-api.mjs";
33
+ import { GLOBAL_LOG_A_LOT } from "../../constants.mjs";
34
+ import { exportIbGib, getDeterministicColorInfo, getRawExportIbGibAndGraphFromJsonString } from "../../helpers.web.mjs";
35
+ import { LiveProxyIbGib } from "../../witness/live-proxy-ibgib/live-proxy-ibgib-one-file.mjs";
36
+ import { getComponentSvc } from "./ibgib-component-service.mjs";
37
+ import { getAgentForDomainIbGib } from "../../witness/agent/agent-helpers.mjs";
38
+ import { createSettings, getSectionName, getSettingsScope, getSettingsSection } from "../../common/settings/settings-helpers.mjs";
39
+ import { SettingsType } from "../../common/settings/settings-constants.mjs";
40
+ import { coupleDomainIbGibWithLocalIbGibViaIndex, getLocalCoupledIbGibForDomainIbGib } from "../../helpers.mjs";
41
+ const logalot = GLOBAL_LOG_A_LOT;
42
+ /**
43
+ * Base class for the ibgib component Meta factory instance.
44
+ *
45
+ * @see {@link IbGibDynamicComponentMeta}
46
+ */
47
+ export class IbGibDynamicComponentMetaBase {
48
+ lc = `[${IbGibDynamicComponentMetaBase.name}]`;
49
+ componentName = '';
50
+ routeRegExp = undefined;
51
+ fnHandleRoute = undefined;
52
+ fnGetMetaspace;
53
+ bootstrapPromise;
54
+ /**
55
+ * ## usage
56
+ *
57
+ * I'm planning on creating a single ctor opts instance for this with the
58
+ * properties exposed on the consuming app's global ibgib object, which
59
+ * should have references to these properties.
60
+ *
61
+ * Then, the component meta initialization can be the same as it is atow
62
+ * (12/2025), but instead of empty ctors it will just have the `opts` there.
63
+ *
64
+ * ```
65
+ * const opts = {
66
+ * fnGetMetaspace: globalIbGib.getGlobalMetaspace,
67
+ * bootstrapPromise: globalIbGib.bootstrapPromise,
68
+ * }
69
+ *
70
+ * const componentsMeta: IbGibDynamicComponentMeta[] = [
71
+ * new MyComponentMeta1(opts),
72
+ * new MyComponentMeta2(opts),
73
+ * // other components
74
+ * ];
75
+ * ```
76
+ */
77
+ constructor({ fnGetMetaspace, bootstrapPromise, }) {
78
+ this.fnGetMetaspace = fnGetMetaspace;
79
+ this.bootstrapPromise = bootstrapPromise;
80
+ }
81
+ }
82
+ /**
83
+ * Base class for common ibgib component. This is the actual web component
84
+ * instance.
85
+ *
86
+ * ## regarding HTMLElement
87
+ *
88
+ * This class extends HTMLElement, so you have access to things, e.g., the
89
+ * parent element via the normal DOM interface.
90
+ *
91
+ * @see {@link IbGibDynamicComponentInstance}
92
+ */
93
+ export class IbGibDynamicComponentInstanceBase extends HTMLElement {
94
+ lc = `[${IbGibDynamicComponentInstanceBase.name}]`;
95
+ elements;
96
+ createdPromise;
97
+ settings;
98
+ /**
99
+ * main agent for this component
100
+ *
101
+ * atow (04/2025), this is derived from {@link agents}, being the first one
102
+ * in that array. So, other agents may exist for this component, but the
103
+ * first one should be the main one for this component.
104
+ */
105
+ get agent() { return this.agents.at(0); }
106
+ /**
107
+ * @see {@link agent}
108
+ */
109
+ agents = [];
110
+ get ib() {
111
+ const { ib } = getIbAndGib({ ibGibAddr: this.ibGibAddr ?? ROOT_ADDR });
112
+ return ib;
113
+ }
114
+ get gib() {
115
+ const { gib } = getIbAndGib({ ibGibAddr: this.ibGibAddr ?? ROOT_ADDR });
116
+ return gib;
117
+ }
118
+ ibGibAddr = ROOT_ADDR;
119
+ /**
120
+ * The proxy witness used for updating the backing ibGib.
121
+ */
122
+ ibGibProxy;
123
+ /**
124
+ * Backing ibgib getter via {@link ibGibProxy.ibGib}
125
+ */
126
+ get ibGib() {
127
+ const ibGibAddr = this.ibGibAddr ?? ROOT_ADDR;
128
+ const { ib, gib } = getIbAndGib({ ibGibAddr });
129
+ return this.ibGibAddr && !isPrimitive({ gib }) ?
130
+ this.ibGibProxy?.ibGib :
131
+ Factory_V1.primitive({ ib });
132
+ // undefined; // should we return undefined?
133
+ }
134
+ get tjpAddr() {
135
+ return this.ibGib ?
136
+ getTjpAddr({ ibGib: this.ibGib, defaultIfNone: "incomingAddr" }) :
137
+ undefined;
138
+ }
139
+ /**
140
+ * reference to the meta instance that created this component instance.
141
+ */
142
+ meta;
143
+ html;
144
+ css;
145
+ /**
146
+ * not really used yet, since we're only testing with web1 which has a
147
+ * static, primitive ibgib address.
148
+ */
149
+ static get observedAttributes() {
150
+ return ['ibGibAddr'];
151
+ }
152
+ _instanceId;
153
+ get instanceId() { return this._instanceId; }
154
+ /**
155
+ * we can initialize the agent(s) as soon as we load the ibgib, but we don't
156
+ * want to await it immediately.
157
+ */
158
+ agentsInitialized;
159
+ /**
160
+ * @internal number of times {@link connectedCallback} has been called.
161
+ *
162
+ * ## notes
163
+ *
164
+ * I'm making this because when the component is removed
165
+ */
166
+ connectedCount = 0;
167
+ /**
168
+ * override this as needed
169
+ */
170
+ get isBusy() { return false; }
171
+ async getMetaspace() {
172
+ const lc = `${this.lc}[${this.getMetaspace.name}]`;
173
+ try {
174
+ if (logalot) {
175
+ console.log(`${lc} starting... (I: 956418cf932823bc767ccc6a0fd2b325)`);
176
+ }
177
+ if (!this.meta) {
178
+ throw new Error(`(UNEXPECTED) this.meta falsy? (E: dd2bfae6c0e84b1d58c72e2922b51325)`);
179
+ }
180
+ return await this.meta.fnGetMetaspace();
181
+ }
182
+ catch (error) {
183
+ console.error(`${lc} ${extractErrorMsg(error)}`);
184
+ throw error;
185
+ }
186
+ finally {
187
+ if (logalot) {
188
+ console.log(`${lc} complete.`);
189
+ }
190
+ }
191
+ }
192
+ constructor() {
193
+ super();
194
+ this._instanceId = pickRandom_Letters({ count: 8 });
195
+ }
196
+ async initialize(opts) {
197
+ let { ibGibAddr, meta, html, css } = opts;
198
+ // maybe remove this try..catch..finally to speed up perf when this is
199
+ // more mature
200
+ const lc = `${this.lc}[${this.initialize.name}]`;
201
+ try {
202
+ if (logalot) {
203
+ console.log(`${lc} starting... (I: c9b94131bc2f0d20e1397c214dad6725)`);
204
+ }
205
+ this.ibGibAddr = ibGibAddr;
206
+ this.meta = meta;
207
+ this.html = html;
208
+ this.css = css;
209
+ // Attach shadow DOM
210
+ this.attachShadow({ mode: 'open' });
211
+ await this.meta.bootstrapPromise;
212
+ }
213
+ catch (error) {
214
+ console.error(`${lc} ${extractErrorMsg(error)}`);
215
+ throw error;
216
+ }
217
+ finally {
218
+ if (logalot) {
219
+ console.log(`${lc} complete.`);
220
+ }
221
+ }
222
+ }
223
+ async initAgents() {
224
+ const lc = `${this.lc}[${this.initAgents.name}]`;
225
+ if (logalot) {
226
+ console.log(`${lc} does nothing in base class (I: 0b31a650b942619a0e36a1a7f763e825)`);
227
+ }
228
+ }
229
+ async connectedCallback() {
230
+ const lc = `${this.lc}[${this.connectedCallback.name}]`;
231
+ try {
232
+ if (logalot) {
233
+ console.log(`${lc} starting... (I: 01bbbf69f1c75b03a29e7a85ebd2c725)`);
234
+ }
235
+ this.connectedCount++;
236
+ if (this.connectedCount === 1) {
237
+ // first time this component has been created, so do full
238
+ // template/styles/scripts init.
239
+ await this.connectedCallback_initComponent();
240
+ }
241
+ else {
242
+ await this.connectedCallback_reconnectComponent();
243
+ }
244
+ }
245
+ catch (error) {
246
+ console.error(`${lc} ${extractErrorMsg(error)}`);
247
+ throw error;
248
+ }
249
+ finally {
250
+ if (logalot) {
251
+ console.log(`${lc} complete.`);
252
+ }
253
+ }
254
+ }
255
+ async connectedCallback_initComponent() {
256
+ const lc = `${this.lc}[${this.connectedCallback_initComponent.name}]`;
257
+ try {
258
+ if (logalot) {
259
+ console.log(`${lc} starting... (I: bc4af3f6751d841f51bad19e334efa25)`);
260
+ }
261
+ if (!this.html) {
262
+ throw new Error(`(UNEXPECTED) this.html is falsy? (E: a0a0ab7c8f987d78058dd7cad09a5125)`);
263
+ }
264
+ // create template element and set innerHTML
265
+ const template = document.createElement('template');
266
+ template.innerHTML = this.css ?
267
+ `
268
+ <style>
269
+ ${this.css.join('\n')}
270
+ </style>
271
+ ${this.html}
272
+ ` :
273
+ this.html;
274
+ // append content to shadow DOM
275
+ if (!this.shadowRoot) {
276
+ throw new Error(`(UNEXPECTED) this.shadowRoot is falsy? (E: 1a3cf77d87767aaff37d31657ee73f25)`);
277
+ }
278
+ this.shadowRoot.appendChild(template.content);
279
+ this.createdPromise = this.created();
280
+ await this.createdPromise;
281
+ }
282
+ catch (error) {
283
+ console.error(`${lc} ${extractErrorMsg(error)}`);
284
+ throw error;
285
+ }
286
+ finally {
287
+ if (logalot) {
288
+ console.log(`${lc} complete.`);
289
+ }
290
+ }
291
+ }
292
+ async connectedCallback_reconnectComponent() {
293
+ const lc = `${this.lc}[${this.connectedCallback_reconnectComponent.name}]`;
294
+ try {
295
+ if (logalot) {
296
+ console.log(`${lc} starting... (I: 7fccefbeff68c0dda15642ebaa1eb525)`);
297
+ }
298
+ console.log(`${lc} does nothing in base class (I: 724bc670d4ccb0fde2b2fa49830cd425)`);
299
+ }
300
+ catch (error) {
301
+ console.error(`${lc} ${extractErrorMsg(error)}`);
302
+ throw error;
303
+ }
304
+ finally {
305
+ if (logalot) {
306
+ console.log(`${lc} complete.`);
307
+ }
308
+ }
309
+ }
310
+ async disconnectedCallback() {
311
+ const lc = `${this.lc}[${this.disconnectedCallback.name}]`;
312
+ try {
313
+ if (logalot) {
314
+ console.log(`${lc} starting... (I: 6f3b25c23fb874b1ac513e8f0d1f4e25)`);
315
+ }
316
+ await this.disconnected();
317
+ }
318
+ catch (error) {
319
+ console.error(`${lc} ${extractErrorMsg(error)}`);
320
+ throw error;
321
+ }
322
+ finally {
323
+ if (logalot) {
324
+ console.log(`${lc} complete.`);
325
+ }
326
+ }
327
+ }
328
+ /**
329
+ * untested so far.
330
+ *
331
+ * @param name
332
+ * @param oldValue
333
+ * @param newValue
334
+ */
335
+ async attributeChangedCallback(name, oldValue, newValue) {
336
+ const lc = `${this.lc}[attributeChangedCallback]`;
337
+ if (logalot) {
338
+ console.log(`${lc} starting... (I: 33cd68579171582166d25d8898640f25): ${name} ${oldValue} => ${newValue}`);
339
+ }
340
+ // handle attribute changes if needed
341
+ console.warn(`${lc} nothing done in base class atow (W: 9eb93eb8fde7c0058c79cea841936a25)`);
342
+ }
343
+ /**
344
+ * triggers {@link destroyed} handler
345
+ *
346
+ * Note there are NO web component lifecycles that trigger this. This must
347
+ * be called explicitly in code.
348
+ * @see {@link disconnected}
349
+ * @see {@link disconnectedCallback}
350
+ */
351
+ async destroy() {
352
+ const lc = `${this.lc}[${this.destroy.name}]`;
353
+ try {
354
+ if (logalot) {
355
+ console.log(`${lc} starting... (I: 536989c9491b544105b6d01a688fbb25)`);
356
+ }
357
+ await this.destroyed();
358
+ }
359
+ catch (error) {
360
+ console.error(`${lc} ${extractErrorMsg(error)}`);
361
+ throw error;
362
+ }
363
+ finally {
364
+ if (logalot) {
365
+ console.log(`${lc} complete.`);
366
+ }
367
+ }
368
+ }
369
+ async destroyed() {
370
+ const lc = `${this.lc}[${this.destroyed.name}]`;
371
+ try {
372
+ if (logalot) {
373
+ console.log(`${lc} starting... (I: f34f3ca04b06b1e00ebe04df22331125)`);
374
+ }
375
+ }
376
+ catch (error) {
377
+ console.error(`${lc} ${extractErrorMsg(error)}`);
378
+ throw error;
379
+ }
380
+ finally {
381
+ if (logalot) {
382
+ console.log(`${lc} complete.`);
383
+ }
384
+ }
385
+ if (logalot) {
386
+ console.log(`${lc} does nothing in the base class. (I: d9437f962e0aec40d69ad6159e7b5725)`);
387
+ }
388
+ return Promise.resolve();
389
+ }
390
+ async loadIbGib(opts) {
391
+ const lc = `${this.lc}[${this.loadIbGib.name}]`;
392
+ try {
393
+ if (logalot) {
394
+ console.log(`${lc} starting... (I: 4dcb1b7a3d86f3415ca7224c07126925)`);
395
+ }
396
+ const getLatest = opts?.getLatest ?? false;
397
+ if (this.ibGib) {
398
+ // this may be because we need to load the ibgib/have access to
399
+ // it before the web component is attached to the DOM (which
400
+ // triggers the component's created event)
401
+ console.warn(`${lc} this.ibGib already loaded. idempotently returning early without doing anything. (W: 15498d346a32e884acec108cb3c8ee25)`);
402
+ return; /* <<<< returns early */
403
+ }
404
+ if (isPrimitive({ gib: getIbAndGib({ ibGibAddr: this.ibGibAddr ?? ROOT_ADDR }).gib })) {
405
+ if (logalot) {
406
+ console.log(`${lc} component loading primitive ibgib (I: 3349796ef6139c1e718c8626c7935625)`);
407
+ }
408
+ // no need to load, this.ibGib will be derived from the primitive addr
409
+ return; /* <<<< returns early */
410
+ }
411
+ // live or not, we want to get the ibgib record itself.
412
+ const metaspace = await this.getMetaspace();
413
+ /**
414
+ * using default local space as the common shared space atow
415
+ * (04/2025)
416
+ */
417
+ const space = await metaspace.getLocalUserSpace({ lock: false });
418
+ if (!space) {
419
+ throw new Error(`(UNEXPECTED) local user space falsy? (E: bb093b7e9781064e8db9a4390b63bb25)`);
420
+ }
421
+ if (getLatest) {
422
+ const latestAddr = await metaspace.getLatestAddr({ addr: this.ibGibAddr, space });
423
+ if (latestAddr && latestAddr !== this.ibGibAddr) {
424
+ this.ibGibAddr = latestAddr;
425
+ }
426
+ }
427
+ const resGet = await metaspace.get({
428
+ addrs: [this.ibGibAddr],
429
+ space,
430
+ // space: undefined,
431
+ });
432
+ if (!resGet.success || resGet.ibGibs?.length !== 1) {
433
+ throw new Error(`couldn't get ibGib (${this.ibGibAddr}) in space (${space?.ib ?? 'undefined'}) (E: 59c3461bebf3e0065df72bd1bd8dc125)`);
434
+ }
435
+ // get the initial ibGib and wrap it in the "live" (updating) proxy
436
+ const ibGib = resGet.ibGibs.at(0);
437
+ const ibGibProxy = new LiveProxyIbGib();
438
+ await ibGibProxy.initialized;
439
+ if (!ibGibProxy.contextUpdated$) {
440
+ throw new Error(`(UNEXPECTED) ibGibProxy.contextUpdated$ falsy? (E: 351dfc898d2c3da2d7928079cec14925)`);
441
+ }
442
+ ibGibProxy.contextUpdated$.subscribe(fnObs({
443
+ next: async (nextIbGib) => {
444
+ const lcNext = `${lc}[ibGibProxy.contextUpdated$][next]`;
445
+ if (logalot) {
446
+ console.log(`${lcNext} nextIbGib: ${pretty(nextIbGib)} (I: 96c846357b94fda2cefa615aed88c325)`);
447
+ }
448
+ await this.handleContextUpdated();
449
+ },
450
+ error: async (e) => {
451
+ debugger; // error in component.ibGibProxy.contextUpdated$ observable?
452
+ console.error(`${lc}[ibGibProxy.contextUpdated$][error] what up? ${extractErrorMsg(e)}`);
453
+ },
454
+ }));
455
+ if (!ibGibProxy.newContextChild$) {
456
+ throw new Error(`(UNEXPECTED) ibGibProxy.newContextChild$ falsy? (E: 2cbde5ab402cc6d81259c74d68bca725)`);
457
+ }
458
+ ibGibProxy.newContextChild$.subscribe(fnObs({
459
+ next: async (childIbGib) => {
460
+ const lcNext = `${lc}[ibGibProxy.contextUpdated$][next]`;
461
+ if (logalot) {
462
+ console.log(`${lcNext} childIbGib: ${pretty(childIbGib)} (I: 96c846357b94fda2cefa615aed88c325)`);
463
+ }
464
+ await this.handleNewContextChild({ childIbGib });
465
+ },
466
+ error: async (e) => {
467
+ debugger; // error in component.ibGibProxy.contextUpdated$ observable?
468
+ console.error(`${lc}[ibGibProxy.contextUpdated$][error] what up? ${extractErrorMsg(e)}`);
469
+ },
470
+ }));
471
+ /**
472
+ * not necessary, I'm just putting this here to remind myself that
473
+ * we can dynamically assign a space (via spaceId) to a proxy ibgib.
474
+ */
475
+ const _ignoredSpace = await ibGibProxy.witness(space);
476
+ const _ignored = await ibGibProxy.witness(ibGib);
477
+ this.ibGibProxy = ibGibProxy;
478
+ // update the addr in case the proxy is newer than the ibgib addr
479
+ // that we started with.
480
+ this.ibGibAddr = getIbGibAddr({ ibGib: ibGibProxy.ibGib });
481
+ }
482
+ catch (error) {
483
+ console.error(`${lc} ${extractErrorMsg(error)}`);
484
+ throw error;
485
+ }
486
+ finally {
487
+ if (logalot) {
488
+ console.log(`${lc} complete.`);
489
+ }
490
+ }
491
+ }
492
+ /**
493
+ * in base class, this sets {@link ibGibAddr} to reflect the {@link nextIbGib}.
494
+ *
495
+ * override this in child classes to do more when next context happens
496
+ *
497
+ * @see {@link handleNewContextChild}
498
+ */
499
+ async handleContextUpdated() {
500
+ const lc = `${this.lc}[${this.handleContextUpdated.name}]`;
501
+ try {
502
+ const { ibGib } = this; // derived from ibGibProxy
503
+ this.ibGibAddr = ibGib ? getIbGibAddr({ ibGib }) : ROOT_ADDR;
504
+ if (logalot) {
505
+ console.log(`${lc} context updated. this.ibGibAddr (I: 64e5876f58cc54b5af777c94f13a4325)`);
506
+ }
507
+ }
508
+ catch (error) {
509
+ console.error(`${lc} ${extractErrorMsg(error)}`);
510
+ throw error;
511
+ }
512
+ }
513
+ /**
514
+ * does nothing (atow 04/2025) in base class
515
+ *
516
+ * override this to handle new children on {@link ibGibProxy}
517
+ * @see {@link handleContextUpdated}
518
+ */
519
+ async handleNewContextChild({ childIbGib }) {
520
+ const lc = `${this.lc}[${this.handleNewContextChild.name}]`;
521
+ try {
522
+ if (logalot) {
523
+ console.log(`${lc} child added to contextcontext updated. childIbGib: ${pretty(childIbGib)} (I: 07d02c9182c6629cbbacd39fd0ff7f25)`);
524
+ }
525
+ console.log(getIbGibAddr({ ibGib: childIbGib })); // debug
526
+ }
527
+ catch (error) {
528
+ console.error(`${lc} ${extractErrorMsg(error)}`);
529
+ throw error;
530
+ }
531
+ }
532
+ /**
533
+ * updates and renders the visual part of the component.
534
+ */
535
+ async renderUI() {
536
+ const lc = `${this.lc}[${this.renderUI.name}]`;
537
+ try {
538
+ if (logalot) {
539
+ console.log(`${lc} starting... (I: 7e5704afe17fb937c8473e7801f56e25)`);
540
+ }
541
+ if (this.ibGib) {
542
+ // const color = getUniqueColorInfo({ ibGib: this.ibGib, });
543
+ // this.style.setProperty('--ibgib-color', color);
544
+ const { punctiliarColor, punctiliarColorTranslucent, punctiliarColorContrast, tjpColor, tjpColorTranslucent, tjpColorContrast, errorMsg } = getDeterministicColorInfo({ ibGib: this.ibGib, translucentAlpha: 10 });
545
+ if (!errorMsg) {
546
+ this.style.setProperty('--ibgib-color', punctiliarColor);
547
+ this.style.setProperty('--ibgib-color-translucent', punctiliarColorTranslucent);
548
+ this.style.setProperty('--ibgib-color-contrast', punctiliarColorContrast);
549
+ this.style.setProperty('--tjp-color', tjpColor ?? punctiliarColor);
550
+ this.style.setProperty('--tjp-color-translucent', tjpColorTranslucent ?? punctiliarColorTranslucent);
551
+ this.style.setProperty('--tjp-color-contrast', tjpColorContrast ?? 'lime');
552
+ }
553
+ else {
554
+ // don't set anything
555
+ console.error(`${lc} ${errorMsg} (E: 65e0d330d029c1fe39f3d6280dda3725)`);
556
+ }
557
+ }
558
+ await this.renderUI_busy();
559
+ }
560
+ catch (error) {
561
+ console.error(`${lc} ${extractErrorMsg(error)}`);
562
+ throw error;
563
+ }
564
+ finally {
565
+ if (logalot) {
566
+ console.log(`${lc} complete.`);
567
+ }
568
+ }
569
+ }
570
+ async renderUI_busy() {
571
+ // does nothing in base
572
+ }
573
+ /**
574
+ * loads the agent(s) coupled to the domain ibgib (this.ibGib), if any.
575
+ */
576
+ async loadAgentsCoupledToIbGib({ dontThrowIfNone, } = {}) {
577
+ const lc = `${this.lc}[${this.loadAgentsCoupledToIbGib.name}]`;
578
+ try {
579
+ // #region init/validation
580
+ const metaspace = await this.getMetaspace();
581
+ // const { metaspace } = this;
582
+ // if (!metaspace) { throw new Error(`(UNEXPECTED) this.metaspace falsy? (E: 230f36ee774eaaecddabd42540160325)`); }
583
+ const space = await metaspace.getLocalUserSpace({ lock: false });
584
+ if (!space) {
585
+ throw new Error(`(UNEXPECTED) space falsy? we couldn't get the default local user space? (E: 06f5be2eec8abaa54d42ad982a155925)`);
586
+ }
587
+ // const domainIbGib = this.ibGib as (ProjectIbGib_V1 | undefined);
588
+ // if (!domainIbGib) { throw new Error(`(UNEXPECTED) this.ibGib (projectIbGib) falsy? (E: a0281854c6312eadaa3420015d0d0925)`); }
589
+ if (!this.ibGib) {
590
+ throw new Error(`(UNEXPECTED) this.ibGib falsy? (E: 9b24c4b4aa491a21b58fde9185eb9325)`);
591
+ }
592
+ // #endregion init/validation
593
+ const agent = await getAgentForDomainIbGib({
594
+ ibGib: this.ibGib,
595
+ metaspace,
596
+ space,
597
+ });
598
+ if (agent) {
599
+ const initialN = agent.data.n;
600
+ await agent.setActiveContext({ contextIbGib: this.ibGib, loggingInfo: this.lc }); // maybe too premature?
601
+ await delay(32); // allow update of data.n kluge
602
+ const afterN = agent.data.n;
603
+ if (initialN !== afterN) {
604
+ console.warn(`${lc} setting active context for agent changed agent.data.n.\nagent.data: ${pretty(toDto({ ibGib: agent }))}\nibGib.data: ${toDto({ ibGib: this.ibGib })} (W: cb22e8b064d8c2d7b3b2c488ed169225)`);
605
+ // debugger; // dynamic comp base...why did data.n change?
606
+ }
607
+ this.agents = [agent];
608
+ }
609
+ else {
610
+ // one day come back to visit this idea of mandatory agent per component, as some components seem small enough to warrant not requiring an agent.
611
+ if (dontThrowIfNone) {
612
+ console.warn(`(UNEXPECTED) agent falsy? an agent should have been created and registered with the ibGib (${getIbGibAddr({ ibGib: this.ibGib })}) (W: e4219903462baab438a23c786d714825)`);
613
+ }
614
+ else {
615
+ throw new Error(`(UNEXPECTED) agent falsy? an agent should have been created and registered with the ibGib (${getIbGibAddr({ ibGib: this.ibGib })}) (E: 7182d1aa070b9578c78a5b8b401d8425)`);
616
+ }
617
+ }
618
+ }
619
+ catch (error) {
620
+ console.error(`${lc} ${extractErrorMsg(error)}`);
621
+ throw error;
622
+ }
623
+ finally {
624
+ if (logalot) {
625
+ console.log(`${lc} complete.`);
626
+ }
627
+ }
628
+ }
629
+ /**
630
+ * Gets the settings section.
631
+ *
632
+ * NOTE: this.settings and this.settings.ibGib must be initialized before
633
+ * calling this, else will throw.
634
+ *
635
+ * @returns settings section corresponding to type/use case or undefined
636
+ *
637
+ * ## notes on settings
638
+ *
639
+ * AFAICT I have made this so that there is one single settings ibgib with
640
+ * individual sections in its data. So use this function to get a section
641
+ * within that settings ibgib that is based on a given domain ibgib (this.ibGib).
642
+ *
643
+ * So a component initializes/activates an ibGib (this.ibGib) and for those
644
+ * components that use the settings, this.initSettings must be called. Then
645
+ * you call getSettings or updateSettings (not implemented yet).
646
+ */
647
+ async getSettings({ settingsType, useCase, }) {
648
+ const lc = `${this.lc}[${this.getSettings.name}]`;
649
+ try {
650
+ if (logalot) {
651
+ console.log(`${lc} starting... (I: 00c8dbedd2e8a8b988cc45f4186efd25)`);
652
+ }
653
+ if (!this.settings) {
654
+ throw new Error(`(UNEXPECTED) this.settings falsy? shouldn't this be initialized by now? (E: ceae480e28fab1da38b8def8b1060d25 (E: dc7d984c1c64293a3c3e0628dedadb25)`);
655
+ }
656
+ if (!this.settings.ibGib) {
657
+ throw new Error(`(UNEXPECTED) this.settings.ibGib falsy? shouldn't this be initialized by now? especially since this.settings is truthy? (E: faef6878abaf00a4a6a6f6b85ce8c825)`);
658
+ }
659
+ const settingsSection = await getSettingsSection({
660
+ sectionName: await getSectionName({ settingsType, useCase, }),
661
+ settingsIbGib: this.settings.ibGib,
662
+ });
663
+ if (!settingsSection) {
664
+ if (logalot) {
665
+ console.log(`${lc} settingsSection does not exist. returning undefined. (I: 0462d83f5ae8049708274b88e9b0d825)`);
666
+ }
667
+ }
668
+ return settingsSection;
669
+ }
670
+ catch (error) {
671
+ console.error(`${lc} ${extractErrorMsg(error)}`);
672
+ throw error;
673
+ }
674
+ finally {
675
+ if (logalot) {
676
+ console.log(`${lc} complete.`);
677
+ }
678
+ }
679
+ }
680
+ async updateSettings({ settingsType, useCase, newSectionInfo, }) {
681
+ const lc = `${this.lc}[${this.updateSettings.name}]`;
682
+ try {
683
+ if (logalot) {
684
+ console.log(`${lc} starting... (I: 80ce98cf386e0c04d30e8b15ac0f2925)`);
685
+ }
686
+ const sectionName_current = await getSectionName({
687
+ settingsType,
688
+ useCase,
689
+ });
690
+ const _newSettings = await mut8Timeline({
691
+ timeline: this.settings.ibGib,
692
+ metaspace: await this.getMetaspace(),
693
+ mut8Opts: {
694
+ dataToAddOrPatch: {
695
+ sections: {
696
+ [sectionName_current]: newSectionInfo,
697
+ }
698
+ },
699
+ },
700
+ });
701
+ await delay(100); // cheap kluge to allow settings ibgib to update
702
+ }
703
+ catch (error) {
704
+ console.error(`${lc} ${extractErrorMsg(error)}`);
705
+ throw error;
706
+ }
707
+ finally {
708
+ if (logalot) {
709
+ console.log(`${lc} complete.`);
710
+ }
711
+ }
712
+ }
713
+ /**
714
+ * if this.ibGib has a coupled settings ibgib indexed in the local space,
715
+ * then {@link settings} should be loaded with it. This is a convenience
716
+ * fn to access the current settings section for the {@link settingsType}.
717
+ */
718
+ async getCurrentSettings({ settingsType }) {
719
+ const lc = `${this.lc}[${this.getCurrentSettings.name}]`;
720
+ try {
721
+ if (logalot) {
722
+ console.log(`${lc} starting... (I: da0baee73e386089a8c059f83cc43825)`);
723
+ }
724
+ if (!this.settings) {
725
+ return undefined; /* <<<< returns early */
726
+ }
727
+ const sectionName = await getSectionName({ settingsType, useCase: 'current' });
728
+ return getSettingsSection({ sectionName, settingsIbGib: this.settings.ibGib });
729
+ }
730
+ catch (error) {
731
+ console.error(`${lc} ${extractErrorMsg(error)}`);
732
+ throw error;
733
+ }
734
+ finally {
735
+ if (logalot) {
736
+ console.log(`${lc} complete.`);
737
+ }
738
+ }
739
+ }
740
+ async initSettings() {
741
+ const lc = `${this.lc}[${this.initSettings.name}]`;
742
+ try {
743
+ if (logalot) {
744
+ console.log(`${lc} starting... (I: acfee8787d32a6075442e2887a386a25)`);
745
+ }
746
+ // get the local space settings for this ibgib and update
747
+ // this.lensMode appropriately
748
+ if (!this.ibGib) {
749
+ throw new Error(`(UNEXPECTED) this.ibGib falsy? (E: 8ce2e73bea87b9330b131778a3981825)`);
750
+ }
751
+ const metaspace = await this.getMetaspace();
752
+ const space = await metaspace.getLocalUserSpace({ lock: false });
753
+ if (!space) {
754
+ throw new Error(`(UNEXPECTED) couldn't get default local user space? (E: f77ce7269a6f0d7ad8978349b4c6cd25)`);
755
+ }
756
+ if (isPrimitive({ ibGib: this.ibGib })) {
757
+ console.error(`${lc} this.ibGib is primitive, so what are we initializing settings for? (W: 9915089019b81c6935b32ae877095825)`);
758
+ return; /* <<<< returns early */
759
+ }
760
+ const scope = await getSettingsScope({ ibGib: this.ibGib });
761
+ let settingsIbGib = await getLocalCoupledIbGibForDomainIbGib({
762
+ scope,
763
+ // scope: this.getSettingsScope(),
764
+ // scope: PROJECT_SETTINGS_SCOPE,
765
+ ibGib: this.ibGib,
766
+ metaspace,
767
+ space,
768
+ });
769
+ // we want to get the *current* general settings to reload. if they
770
+ // do not exist, then we need to init the settings
771
+ if (!settingsIbGib) {
772
+ // create new project settings and couple to the project ibgib
773
+ // const defaultGeneral = await getDefaultSettings({ settingsType: SettingsType.general });
774
+ // const scope = await getSettingsScope({ ibGib: this.ibGib });
775
+ const resNewSettings = await createSettings({
776
+ scope,
777
+ metaspace,
778
+ space,
779
+ saveInSpace: true,
780
+ });
781
+ settingsIbGib = resNewSettings.newIbGib;
782
+ await coupleDomainIbGibWithLocalIbGibViaIndex({
783
+ scope,
784
+ domainIbGib: this.ibGib,
785
+ localIbGib: settingsIbGib,
786
+ metaspace,
787
+ space,
788
+ });
789
+ }
790
+ if (!settingsIbGib) {
791
+ throw new Error(`(UNEXPECTED) settings falsy still? should be initialized. (E: a179adcbbab800cff849b8aa95fbe425)`);
792
+ }
793
+ const settingsProxy = new LiveProxyIbGib();
794
+ await settingsProxy.setWrappedIbGib({ ibGib: settingsIbGib, space });
795
+ this.settings = settingsProxy;
796
+ const generalSettings = await this.getCurrentSettings({ settingsType: SettingsType.general });
797
+ // const sectionName_currentGeneral = await getSectionName({
798
+ // settingsType: SettingsType.general,
799
+ // useCase: 'current',
800
+ // });
801
+ // let generalSettings = await getSettingsSection<Settings_General>({
802
+ // sectionName: sectionName_currentGeneral,
803
+ // settingsIbGib: settingsIbGib,
804
+ // });
805
+ if (!generalSettings) {
806
+ throw new Error(`(UNEXPECTED) no current general settings? the settings should have been updated with this upon creation. (E: d10fd8d42b58d917180293a713009825)`);
807
+ }
808
+ }
809
+ catch (error) {
810
+ console.error(`${lc} ${extractErrorMsg(error)}`);
811
+ throw error;
812
+ }
813
+ finally {
814
+ if (logalot) {
815
+ console.log(`${lc} complete.`);
816
+ }
817
+ }
818
+ }
819
+ /**
820
+ * exports a given ibgib to the default local userspace in the metaspace.
821
+ */
822
+ async exportIbGib({ ibGib, compress, }) {
823
+ const lc = `${this.lc}[${this.exportIbGib.name}]`;
824
+ try {
825
+ if (logalot) {
826
+ console.log(`${lc} starting... (I: 623d9463d919683be81f749821a95825)`);
827
+ }
828
+ const metaspace = await this.getMetaspace();
829
+ if (!metaspace) {
830
+ throw new Error(`(UNEXPECTED) metaspace falsy? (E: 3d15dbd074ac0c15b834a788d0b57d25)`);
831
+ }
832
+ if (isPrimitive({ ibGib })) {
833
+ throw new Error(`ibGib is primitive. Can't export primitive. (E: dd42c42e9fda0707e81c692af1a2a225)`);
834
+ }
835
+ const space = await metaspace.getLocalUserSpace({ lock: false });
836
+ if (!space) {
837
+ throw new Error(`(UNEXPECTED) couldn't get default local user space? (E: 7bb735be58282f1bd7abe5d9ffabb525)`);
838
+ }
839
+ // const resGetExport = await getRawExportIbGib({
840
+ // ibGib,
841
+ // live: true,
842
+ // compress,
843
+ // metaspace: metaspace,
844
+ // space,
845
+ // });
846
+ // maybe can just dynamically add this anchor element with display: none and click it? hmm...i've done this, will test
847
+ // if (!this.shadowRoot) { throw new Error(`(UNEXPECTED) this.shadowRoot falsy? (E: 137f413b39a88fdc58c751c82efd3825)`); }
848
+ // const downloadAnchorElId = 'export-ibgib-anchor';
849
+ // const downloadAnchorEl = this.shadowRoot.getElementById(downloadAnchorElId) as HTMLAnchorElement;
850
+ // if (!downloadAnchorEl) { throw new Error(`(UNEXPECTED) dlAnchorElem falsy? should be an element with id ${downloadAnchorElId}? (E: 51dfe2d823eedeefb8b9c9580090e625)`); }
851
+ await exportIbGib({
852
+ ibGib,
853
+ compress,
854
+ // downloadAnchorEl,
855
+ metaspace,
856
+ space,
857
+ });
858
+ // THE FOLLOWING CODE WAS **MOSTLY** PUT INTO THE ABOVE HELPER FUNCTION.
859
+ // const { rawExportIbGib: exportIbGib, errors } = resGetExport;
860
+ // const exportErrors = resGetExport.errors ?? [];
861
+ // if (exportErrors.length > 0) {
862
+ // throw new Error(`Export had errors: ${exportErrors} (E: 05faf83f25d3449ab809dfd24eeaf825)`);
863
+ // }
864
+ // // at this point, we have a possibly quite large ibGib whose data includes
865
+ // // every single ibgib that this.ibGib relates to (its dependency graph). This
866
+ // // so now we can save this file and later import from it.
867
+ // /**
868
+ // * exportIbGib is guaranteed to have a serializable structure, i.e.,
869
+ // * the data has only primitives. (there are no Uint8Array)
870
+ // */
871
+ // const exportIbGibAsString = JSON.stringify(exportIbGib);
872
+ // // thank you SO, OP and volzotan at https://stackoverflow.com/questions/19721439/download-json-object-as-a-file-from-browser
873
+ // // set the anchor's href to a data stream
874
+ // const dataStr = "data:text/json;charset=utf-8," + encodeURIComponent(exportIbGibAsString);
875
+ // // get the filename for the anchor to suggest for the "download"
876
+ // const exportAddr = getIbGibAddr({ ibGib: exportIbGib });
877
+ // const filename = `${exportAddr}.json`;
878
+ // // // if (this.web) {
879
+ // // trigger the click
880
+ // if (!this.shadowRoot) { throw new Error(`(UNEXPECTED) this.shadowRoot falsy? (E: 137f413b39a88fdc58c751c82efd3825)`); }
881
+ // const downloadAnchorElId = 'export-ibgib-anchor';
882
+ // // const downloadAnchorEl = document.getElementById(downloadAnchorElId);
883
+ // const downloadAnchorEl = this.shadowRoot.getElementById(downloadAnchorElId);
884
+ // if (!downloadAnchorEl) { throw new Error(`(UNEXPECTED) dlAnchorElem falsy? should be an element with id ${downloadAnchorElId}? (E: 51dfe2d823eedeefb8b9c9580090e625)`); }
885
+ // downloadAnchorEl.setAttribute("href", dataStr);
886
+ // downloadAnchorEl.setAttribute("download", filename);
887
+ // downloadAnchorEl.click();
888
+ // // } else {
889
+ // // // let res = await Filesystem.requestPermissions();
890
+ // // await Filesystem.writeFile({
891
+ // // data: dataStr,
892
+ // // directory: Directory.ExternalStorage,
893
+ // // path: `/Download/${filename}`,
894
+ // // encoding: Encoding.UTF8,
895
+ // // recursive: true,
896
+ // // });
897
+ // // }
898
+ // // await Dialog.alert({ title: 'export succeeded', message: 'way to go, the export succeeded' });
899
+ // // throw new Error(`not implemented (E: d17d28b80f2576c6e81298fffc2e7825)`);
900
+ }
901
+ catch (error) {
902
+ console.error(`${lc} ${extractErrorMsg(error)}`);
903
+ throw error;
904
+ }
905
+ finally {
906
+ if (logalot) {
907
+ console.log(`${lc} complete.`);
908
+ }
909
+ }
910
+ }
911
+ /**
912
+ * imports a given ibgib into this.ibGib's
913
+ */
914
+ async importIbGib({ exportIbGibJsonString, rel8nName, force, skipRegisterTimelines, divergentTimelineStrategy, }) {
915
+ const lc = `${this.lc}[${this.importIbGib.name}]`;
916
+ try {
917
+ const metaspace = await this.getMetaspace();
918
+ const space = await metaspace.getLocalUserSpace({ lock: false });
919
+ if (!space) {
920
+ throw new Error(`(UNEXPECTED) couldn't get default local user space? (E: 947c983e57a91aa00c8c185320354325)`);
921
+ }
922
+ let [rawExportIbGib, ibGibGraph] = await getRawExportIbGibAndGraphFromJsonString({ exportIbGibJsonString, metaspace });
923
+ if (!rawExportIbGib.data) {
924
+ throw new Error(`(UNEXPECTED) rawExportIbGib.data falsy? this is assumed validated at this point. (E: 6bc4e84db08e3c6228b2c40c2ea50825)`);
925
+ }
926
+ /**
927
+ * this is the actual addr of the ibgib we're importing and should
928
+ * be the root of the export. if this exact addr already exists in the space, then the
929
+ * entire dependency graph is assumed to exist. if force is true, then we'll ignore this step
930
+ */
931
+ const exportRootAddr = rawExportIbGib.data.contextIbGibAddr;
932
+ let skipImportGraphIntoSpace = false;
933
+ if (!force) {
934
+ // double check to see if the import ibgib already exists in the
935
+ // space. if it does, then we don't need to do any
936
+ // saving/registering of the graph we're importing.
937
+ const resGetExisting = await metaspace.get({
938
+ addr: exportRootAddr,
939
+ space,
940
+ });
941
+ if (resGetExisting.success && (resGetExisting.ibGibs ?? []).length === 1) {
942
+ console.log(`${lc} export's ibGib addr (${exportRootAddr}) already exists in the space, so we're skipping doing any physical importing of the export's graph. (I: 429b5bdcd0585c697869f568c4673825)`);
943
+ skipImportGraphIntoSpace = true;
944
+ }
945
+ }
946
+ // before rel8ing the export to this.ibGib via rel8nName, we must
947
+ // save the import in the space.
948
+ if (!skipImportGraphIntoSpace) {
949
+ splitPerTjpAndOrDna;
950
+ const graphIbGibs_dna = [];
951
+ const graphIbGibs_nondna = [];
952
+ Object.values(ibGibGraph).forEach(x => {
953
+ if (isDna({ ibGib: x })) {
954
+ graphIbGibs_dna.push(x);
955
+ }
956
+ else {
957
+ graphIbGibs_nondna.push(x);
958
+ }
959
+ });
960
+ // do the dna first
961
+ const resPutDna = await metaspace.put({
962
+ ibGibs: graphIbGibs_dna,
963
+ isDna: true,
964
+ space, force,
965
+ });
966
+ if (!resPutDna.success || !!resPutDna.errorMsg) {
967
+ throw new Error(`there was an error putting the export's dna ibgibs into the space (${space.ib}). error: ${resPutDna.errorMsg || '[unknown error (E: 7c7ef8d5281399b1d8f3fbeefba1b825)]'} (E: ce3e8b982208afc4889164ba20a31825)`);
968
+ }
969
+ // dna done, but we still may have stones (non-timeline, i.e.,
970
+ // no tjp) so do those next (least amount of dependencies, no
971
+ // need to register timelines)
972
+ const { mapWithTjp_YesDna, mapWithTjp_NoDna, mapWithoutTjps } = splitPerTjpAndOrDna({ ibGibs: graphIbGibs_nondna });
973
+ const resPutNonDnaStones = await metaspace.put({
974
+ ibGibs: Object.values(mapWithoutTjps),
975
+ space, force,
976
+ });
977
+ if (!resPutNonDnaStones.success || !!resPutNonDnaStones.errorMsg) {
978
+ throw new Error(`there was an error putting the export's non-dna stone ibgibs (no-tjp) into the space (${space.ib}). error: ${resPutNonDnaStones.errorMsg || '[unknown error (E: dc17f8ee7aed5c445f8b827f274b0825)]'} (E: 9561364961e89c132818f6784a607825)`);
979
+ }
980
+ // at this point, we only have timelines left. With timelines,
981
+ // we need to not only put them in the space, but also register
982
+ // the most recent one. (maybe we should register all of them
983
+ // but that gets complicated.) since these are all imports,
984
+ // there shouldn't be anything listening specifically for
985
+ // updates to these timelines.
986
+ const timelineIbGibsMap = { ...mapWithTjp_YesDna, ...mapWithTjp_NoDna, };
987
+ const timelineIbGibs = Object.values(timelineIbGibsMap);
988
+ // first, let's persist them
989
+ const resPutTimelines = await metaspace.put({
990
+ ibGibs: timelineIbGibs,
991
+ space, force,
992
+ });
993
+ if (!resPutTimelines.success || !!resPutTimelines.errorMsg) {
994
+ throw new Error(`there was an error putting the export's timeline ibgibs into the space (${space.ib}). error: ${resPutTimelines.errorMsg || '[unknown error (E: be4a28961574765798c8d3686ae89c25)]'} (E: 066796a23da3c9f748558fd25bfdf525)`);
995
+ }
996
+ // now we want to register the latest in each timeline, so at
997
+ // the very least if we call get latest on any of the timeline
998
+ // ibgibs (at any point in time within one of those timelines),
999
+ // the metaspace has registered the latest one.
1000
+ if (!skipRegisterTimelines) {
1001
+ /**
1002
+ * from getTimelinesGroupedByTjp documentation:
1003
+ * > @returns filtered, sorted map of incoming `ibGibs` [tjpAddr] => timeline [ibgib0 (tjp), ibgib1, ibgib2, ..., ibgibN (latest)]
1004
+ */
1005
+ const timelineMap_groupdByTjp = getTimelinesGroupedByTjp({ ibGibs: timelineIbGibs });
1006
+ const timelines = Object.values(timelineMap_groupdByTjp);
1007
+ for (const timeline of timelines) {
1008
+ // we want to register the latest in the export's
1009
+ // timeline, BUT... there may be a more recent ibgib
1010
+ // already in the given space. ALSO there might even be
1011
+ // a divergent timeline, such that the space has a
1012
+ // different timeline evolutionary path than the one in
1013
+ // the given export's timeline.
1014
+ const latestIbGibInTimeline = timeline.at(-1);
1015
+ if (!latestIbGibInTimeline) {
1016
+ throw new Error(`(UNEXPECTED) latestInTimeline falsy? this would mean that we had an empty timeline, and this doesn't make sense... (E: 3bec09e79768cc39d8029f4fe3af9825)`);
1017
+ }
1018
+ const latestAddr = await metaspace.getLatestAddr({
1019
+ ibGib: latestIbGibInTimeline,
1020
+ space,
1021
+ });
1022
+ let spaceAlreadyHasMoreRecentThanLatest = false;
1023
+ if (latestAddr) {
1024
+ }
1025
+ else {
1026
+ // no addrs registered with space, so
1027
+ }
1028
+ if (!spaceAlreadyHasMoreRecentThanLatest) {
1029
+ await metaspace.registerNewIbGib({
1030
+ ibGib: latestIbGibInTimeline,
1031
+ space,
1032
+ });
1033
+ }
1034
+ }
1035
+ }
1036
+ }
1037
+ // what if the export's timeline is already related to this.ibGib via rel8nName?
1038
+ // what if the ibgib already exists in the space?
1039
+ // OK, I'm leaving off for the moment, because I need to rethink
1040
+ // this whole strategy. may need to spawn a new local space and
1041
+ // attempt to do it in that space. this may be where we should do
1042
+ // the local merge/sync timelines, because what if the import has
1043
+ // one or more divergent timelines?
1044
+ // so importing requires some more thinking, because an import can
1045
+ // essentially be seen as a merge.
1046
+ throw new Error(`not implemented (E: 66c308e420e848c8d7cd01c8fddf8425)`);
1047
+ }
1048
+ catch (error) {
1049
+ console.error(`${lc} ${extractErrorMsg(error)}`);
1050
+ throw error;
1051
+ }
1052
+ finally {
1053
+ if (logalot) {
1054
+ console.log(`${lc} complete.`);
1055
+ }
1056
+ }
1057
+ }
1058
+ }
1059
+ /**
1060
+ * Common plumbing for any component that is meant to contain other ibgib
1061
+ * components as children.
1062
+ */
1063
+ export class IbGibDynamicComponentInstanceBase_Parent extends IbGibDynamicComponentInstanceBase {
1064
+ childInfos = [];
1065
+ get activeChildInfo() {
1066
+ return this.childInfos.find(x => x.active);
1067
+ }
1068
+ /**
1069
+ * Drives loading a child component from an {@link addr} or {@link ibGib}.
1070
+ *
1071
+ * - If a tab is already created for the ibgib and active, then does nothing.
1072
+ * - If it's already created but inactive, then activates tab and loads content
1073
+ * - if no tab, then creates it, activates it, loads content.
1074
+ *
1075
+ * To do this, creates/hydrates a concrete descendant of {@link ChildInfoBase}
1076
+ * and activates it via {@link getLoadedChildInfo}
1077
+ *
1078
+ * @see {@link ChildInfoBase.active}
1079
+ * @see {@link activeChildInfo}
1080
+ */
1081
+ async activateIbGib({ addr, ibGib, }) {
1082
+ const lc = `${this.lc}[${this.activateIbGib.name}]`;
1083
+ try {
1084
+ if (logalot) {
1085
+ console.log(`${lc} starting... (I: 05015d78983488496dcca4fa36718725)`);
1086
+ }
1087
+ while (!this.createdPromise) {
1088
+ await delay(50);
1089
+ }
1090
+ await this.createdPromise;
1091
+ if (!this.elements) {
1092
+ throw new Error(`(UNEXPECTED) this.elements falsy? (E: fa221c138f211ee93c717c9dd0cf3225)`);
1093
+ }
1094
+ const { contentEl } = this.elements;
1095
+ // #region init/validate
1096
+ // if (!this.metaspace) { throw new Error(`(UNEXPECTED) this.metaspace falsy? (E: 0ddb82cc0f1550518fd57b65ee5d4625)`); }
1097
+ if (!ibGib && !addr) {
1098
+ throw new Error(`(UNEXPECTED) both ibGib and addr falsy? (E: 529fb88738cdacb10aea87b8450f2525)`);
1099
+ }
1100
+ if (ibGib && addr && getIbGibAddr({ ibGib }) !== addr) {
1101
+ throw new Error(`(UNEXPECTED) addr !== getIbGibAddr({ibGib})? (E: c99a94d8744e3a720cdbc094d53c4e25)`);
1102
+ }
1103
+ addr ??= getIbGibAddr({ ibGib });
1104
+ const componentSvc = await getComponentSvc();
1105
+ // #endregion init/validate
1106
+ /**
1107
+ * the point of this function is to populate this and make it active
1108
+ */
1109
+ let childInfo = await this.getLoadedChildInfo({ addr, ibGib });
1110
+ if (childInfo.active) {
1111
+ console.log(`${lc} same tab already active. returning early. childInfo.addr: ${childInfo.addr} (user just clicked on the same tab) (I: e67c0d02f3143c49c7a20c82d0730225)`);
1112
+ return; /* <<<< returns early */
1113
+ }
1114
+ // at this point, we are guaranteed to have a non-active childInfo, so
1115
+ // deactivate the old, and activate the new
1116
+ const currentlyActive = this.activeChildInfo;
1117
+ if (currentlyActive) {
1118
+ currentlyActive.childBtnEl.classList.remove('active');
1119
+ currentlyActive.active = false;
1120
+ contentEl.innerHTML = '';
1121
+ }
1122
+ // activate the new tab
1123
+ childInfo.childBtnEl.classList.add('active');
1124
+ childInfo.childBtnEl.scrollIntoView({ behavior: 'smooth' });
1125
+ childInfo.active = true;
1126
+ let gib = getIbAndGib({ ibGibAddr: addr }).gib;
1127
+ let gibInfo = getGibInfo({ gib });
1128
+ let tjpGib = gibInfo.tjpGib ?? gib;
1129
+ function tabInfoSharesTjpGib(tabInfo) {
1130
+ let tabGib = getIbAndGib({ ibGibAddr: tabInfo.addr }).gib;
1131
+ let tabGibInfo = getGibInfo({ gib: tabGib });
1132
+ let tabTjpGib = tabGibInfo.tjpGib ?? tabGib;
1133
+ return tabTjpGib === tjpGib;
1134
+ }
1135
+ // if (!this.childInfos.some(x => x.addr === childInfo.addr)) {
1136
+ if (!this.childInfos.some(x => tabInfoSharesTjpGib(x))) {
1137
+ this.childInfos.push(childInfo);
1138
+ }
1139
+ if (!childInfo.component) {
1140
+ throw new Error(`(UNEXPECTED) childInfo.component falsy? should be populated by this point in code (E: 77abfd1e8cd395605d46716bd087fb25)`);
1141
+ }
1142
+ await componentSvc.inject({
1143
+ parentEl: contentEl,
1144
+ componentToInject: childInfo.component,
1145
+ });
1146
+ }
1147
+ catch (error) {
1148
+ console.error(`${lc} ${extractErrorMsg(error)}`);
1149
+ throw error;
1150
+ }
1151
+ finally {
1152
+ if (logalot) {
1153
+ console.log(`${lc} complete.`);
1154
+ }
1155
+ }
1156
+ }
1157
+ }
1158
+ export class IbGibDynamicComponentInstanceBase_ParentOfTabs extends IbGibDynamicComponentInstanceBase_Parent {
1159
+ lc = `[${IbGibDynamicComponentInstanceBase_ParentOfTabs.name}]`;
1160
+ get isBusy() {
1161
+ // add other things to indicate busy
1162
+ return this._reloadingTabs;
1163
+ }
1164
+ _reloadingTabs = false;
1165
+ get reloadingTabs() { return this._reloadingTabs; }
1166
+ set reloadingTabs(value) {
1167
+ const valueIsDifferent = value !== this._reloadingTabs;
1168
+ this._reloadingTabs = value;
1169
+ if (valueIsDifferent) {
1170
+ this.renderUI_busy(); // spins off
1171
+ }
1172
+ }
1173
+ async closeTab({ ibGib }) {
1174
+ const lc = `${this.lc}[${this.closeTab.name}]`;
1175
+ try {
1176
+ if (logalot) {
1177
+ console.log(`${lc} starting... (I: e0d5f8ed67b8a7f43822fa3843fd4525)`);
1178
+ }
1179
+ const addrToClose = getIbGibAddr({ ibGib });
1180
+ const tjpAddrToClose = getTjpAddr({ ibGib, defaultIfNone: 'incomingAddr' });
1181
+ if (!tjpAddrToClose) {
1182
+ throw new Error(`(UNEXPECTED) tjpAddr false after incomingAddr default? ibGib: ${pretty(ibGib)} (E: 707988b4d22a27c1287aa5a815d88825)`);
1183
+ }
1184
+ const tabInfoToClose = await this.getLoadedChildInfo({ addr: addrToClose, ibGib });
1185
+ // if it's active, activate the tab to the left/right?
1186
+ // remove from project open tabs in settings for project ibgib
1187
+ // let projectSettings = await this.getCurrentProjectSettings();
1188
+ const settings_current = await this.getSettings({
1189
+ settingsType: this.settingsType,
1190
+ useCase: 'current',
1191
+ });
1192
+ if (!settings_current) {
1193
+ throw new Error(`(UNEXPECTED) settings_current falsy for this project? this.ibGib: ${pretty(this.ibGib)} (E: ecea08dcacd198bb38cc44a860cc6825)`);
1194
+ }
1195
+ if (!settings_current.openChildTjpAddrs.includes(tjpAddrToClose)) {
1196
+ throw new Error(`${lc} (UNEXPECTED) projectSettings didn't have the tjpAddr (${tjpAddrToClose})? projectSettings: ${pretty(settings_current)} (E: genuuid)`);
1197
+ }
1198
+ let newOpenChildTjpAddrs = settings_current.openChildTjpAddrs.filter(x => x !== tjpAddrToClose);
1199
+ let newActiveChildTjpAddr = undefined;
1200
+ // settings_current.openChildTjpAddrs.push(tjpAddrToClose); // ????
1201
+ if (settings_current.activeChildTjpAddr === tjpAddrToClose) {
1202
+ // get the addr just before the current one that we're closing.
1203
+ // if it doesn't exist, use the project's tjpAddr.
1204
+ if (newOpenChildTjpAddrs.length > 0) {
1205
+ // this implies that the old openChildTjpAddrs.length >= 2
1206
+ let newIndex = settings_current.openChildTjpAddrs.indexOf(tjpAddrToClose) - 1;
1207
+ if (newIndex < 0) {
1208
+ newIndex = 0;
1209
+ }
1210
+ newActiveChildTjpAddr = settings_current.openChildTjpAddrs.at(newIndex);
1211
+ }
1212
+ else {
1213
+ newActiveChildTjpAddr = this.tjpAddr;
1214
+ newOpenChildTjpAddrs.push(this.tjpAddr);
1215
+ }
1216
+ }
1217
+ const sectionName_current = await getSectionName({
1218
+ settingsType: this.settingsType,
1219
+ useCase: 'current',
1220
+ });
1221
+ const newSectionSettings = {
1222
+ ...settings_current,
1223
+ openChildTjpAddrs: newOpenChildTjpAddrs,
1224
+ };
1225
+ // if (!!newActiveChildTjpAddr) {
1226
+ // newProjectSettings.activeChildTjpAddr = newActiveChildTjpAddr;
1227
+ // }
1228
+ const metaspace = await this.getMetaspace();
1229
+ const _newSettings = await mut8Timeline({
1230
+ timeline: this.settings.ibGib,
1231
+ metaspace,
1232
+ mut8Opts: {
1233
+ dataToAddOrPatch: {
1234
+ sections: {
1235
+ [sectionName_current]: newSectionSettings,
1236
+ }
1237
+ },
1238
+ },
1239
+ });
1240
+ if (tabInfoToClose.active) {
1241
+ await this.activateIbGib({ addr: newActiveChildTjpAddr });
1242
+ }
1243
+ // physically remove component/tab btn
1244
+ this.childInfos = this.childInfos.filter(x => x.addr !== tabInfoToClose.addr);
1245
+ await this.removeTabBtn({ tabInfo: tabInfoToClose });
1246
+ // this.elements!.headerTabsEl!.removeChild(tabInfo.childBtnEl);
1247
+ }
1248
+ catch (error) {
1249
+ console.error(`${lc} ${extractErrorMsg(error)}`);
1250
+ throw error;
1251
+ }
1252
+ finally {
1253
+ if (logalot) {
1254
+ console.log(`${lc} complete.`);
1255
+ }
1256
+ }
1257
+ }
1258
+ async reopenOldTabs() {
1259
+ const lc = `${this.lc}[${this.reopenOldTabs.name}]`;
1260
+ try {
1261
+ if (logalot) {
1262
+ console.log(`${lc} starting... (I: 195e7d34b3f8b761aa78dd384011f825)`);
1263
+ }
1264
+ // let settings = await this.getCurrentProjectSettings();
1265
+ const settings = await this.getSettings({
1266
+ settingsType: this.settingsType,
1267
+ useCase: 'current',
1268
+ });
1269
+ if (!settings) {
1270
+ throw new Error(`(UNEXPECTED) settings falsy? these should be initialized before now. (E: 2003ab77e01448d638216fc82aff5f25)`);
1271
+ }
1272
+ this.reloadingTabs = true;
1273
+ await this.renderUI_busy();
1274
+ let currentChildTjpAddr;
1275
+ try {
1276
+ for (const childTjpAddr of settings.openChildTjpAddrs) {
1277
+ // slow kluge I think...maybe it's ok I dunno.
1278
+ currentChildTjpAddr = childTjpAddr;
1279
+ await this.activateIbGib({ addr: childTjpAddr });
1280
+ }
1281
+ }
1282
+ catch (error) {
1283
+ console.error(`${lc} error during activating child ibGib tabs. childTjpAddr: ${currentChildTjpAddr ?? '[unset?]'} (E: 0396b2e24d08f42ac94510bb718a1725)`);
1284
+ throw error;
1285
+ }
1286
+ finally {
1287
+ this.reloadingTabs = false;
1288
+ }
1289
+ // not reloading, so now we can activate the recently active one
1290
+ await this.activateIbGib({ addr: settings.activeChildTjpAddr });
1291
+ // await this.activateLensMode({ lensMode: settings.lensMode, skipInject: false });
1292
+ }
1293
+ catch (error) {
1294
+ console.error(`${lc} ${extractErrorMsg(error)}`);
1295
+ throw error;
1296
+ }
1297
+ finally {
1298
+ if (logalot) {
1299
+ console.log(`${lc} complete.`);
1300
+ }
1301
+ }
1302
+ }
1303
+ }
1304
+ //# sourceMappingURL=ibgib-dynamic-component-bases.mjs.map