@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,491 @@
1
+ /**
2
+ * @module web-filesystem-space-helper
3
+ */
4
+
5
+ import { extractErrorMsg, pretty, unique, } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
6
+ import { IbGibAddr } from '@ibgib/ts-gib/dist/types.mjs';
7
+ import { getIbAndGib, } from '@ibgib/ts-gib/dist/helper.mjs';
8
+ import { GIB, } from '@ibgib/ts-gib/dist/V1/index.mjs';
9
+ import { validateIbGibIntrinsically } from '@ibgib/ts-gib/dist/V1/validate-helper.mjs';
10
+ import { parseSpaceIb } from '@ibgib/core-gib/dist/witness/space/space-helper.mjs';
11
+ import { SPACE_NAME_REGEXP } from '@ibgib/core-gib/dist/witness/space/space-constants.mjs';
12
+
13
+ import { GLOBAL_LOG_A_LOT } from '../../../constants.mjs';
14
+ import { WebFilesystemSpace_V1 } from './web-filesystem-space-v1.mjs';
15
+ import { B2TFS_DEFAULT_ENCODINGS_TO_TRY, FILE_ENCODINGS, FileDataInfo, FileEncoding } from './web-filesystem-space-types.mjs';
16
+ import { getGlobalDbName, PathUtilsHelper, uint8ArrayToString } from '../../../helpers.web.mjs';
17
+ import { storageGet, storagePut, storageReaddir, storageRmRF, } from '../../../storage/storage-helpers.web.mjs';
18
+ import { Dirent } from '../../../storage/storage-types.web.mjs';
19
+
20
+ const logalot = GLOBAL_LOG_A_LOT;
21
+ const pathUtils = new PathUtilsHelper();
22
+
23
+ /**
24
+ * tries to read the given path. if fails **FOR ANY REASON**, @returns `null`.
25
+ *
26
+ * does not throw
27
+ *
28
+ * @returns file contents as string or `null`
29
+ */
30
+ export async function tryRead({
31
+ path,
32
+ directory,
33
+ encoding,
34
+ }: {
35
+ path: string,
36
+ directory: string,
37
+ encoding: string,
38
+ }): Promise<string | Uint8Array | null> {
39
+ const lc = `[${tryRead.name}]`;
40
+ try {
41
+ if (logalot) {
42
+ console.log(`${lc} starting...`);
43
+ // console.log(`${lc} cwd: ${cwd()}`);
44
+ if (path.includes('bootstrap^gib') || path.includes('gib/bootstrap.json')) { console.log(`${lc} trying bootstrap^gib... (I: cde10726c55737e5c5a2e0a66a188e24)`); }
45
+ }
46
+ const fullPath = pathUtils.join(directory, path);
47
+ if (logalot) { console.log(`${lc} fullPath: ${fullPath} (I: e5cfdd62247c6ba05dffb64d8f25d424)`); }
48
+ encoding ||= 'utf8';
49
+ let resRead: string | undefined = undefined;
50
+
51
+ let resRead_uncasted = await readFile(fullPath, { encoding });
52
+ if (resRead_uncasted instanceof Uint8Array) {
53
+ resRead = uint8ArrayToString(resRead_uncasted);
54
+ } else if (typeof resRead_uncasted === 'string') {
55
+ resRead = resRead_uncasted;
56
+ }
57
+
58
+ if (logalot) {
59
+ console.log(`${lc} record found. data length: ${resRead?.length ?? 0}. fullPath: ${fullPath}. console.dir(resRead)... (I: be5cfbf04874b4e8e4787ad966cb8424)`);
60
+ console.dir(resRead)
61
+ }
62
+ return resRead ?? null;
63
+ } catch (error) {
64
+ if (logalot) { console.log(`${lc} fullPath not found from directory (${directory}) and path (${path})\nerror:\n${extractErrorMsg(error)} (I: 8f93e583c048fac0682f55ca74df0324)`); }
65
+ return null;
66
+ } finally {
67
+ if (logalot) { console.log(`${lc} complete. (I: 22a6958aee350e4d99b76057ec8b9224)`); }
68
+ }
69
+ }
70
+
71
+ export async function tryRead_bin({
72
+ path,
73
+ directory,
74
+ encoding,
75
+ }: {
76
+ path: string,
77
+ directory: string,
78
+ encoding: string,
79
+ }): Promise<FileDataInfo | null> {
80
+ const lc = `[${tryRead_bin.name}]`;
81
+ try {
82
+ if (logalot) {
83
+ console.log(`${lc} starting...`);
84
+ // console.log(`${lc} cwd: ${cwd()}`);
85
+ if (path.includes('bootstrap^gib')) { console.log(`${lc} trying bootstrap^gib... (I: acdb59d399ca16c45456392d935c0524)`); }
86
+ }
87
+ const fullPath = pathUtils.join(directory, path);
88
+ if (logalot) { console.log(`${lc} fullPath: ${fullPath} (I: abef0200a4b823b446713349ca102924)`); }
89
+ encoding ||= 'utf8';
90
+ let resRead: string | Uint8Array | undefined = undefined;
91
+ let encodingsToTry: FileEncoding[] = unique<FileEncoding>([
92
+ encoding as FileEncoding,
93
+ ...FILE_ENCODINGS,
94
+ ]);
95
+ let { dataBuffer, dataString, inputPath, detectedEncoding } = await getFileDataAndEncoding({
96
+ inputPath: path,
97
+ encodingsToTry,
98
+ });
99
+ if (!dataBuffer) { throw new Error(`getFileDataAndEncoding yielded falsy dataBuffer (E: f748ffc8c71c92be06a3566102ba8e24)`); }
100
+ resRead = dataBuffer;
101
+
102
+ if (logalot) {
103
+ console.log(`${lc} record found. data length: ${resRead?.length ?? 0}. fullPath: ${fullPath}. console.dir(resRead)... (I: b0c1da7e3849edd3edef899d74b21a24)`);
104
+ console.dir(resRead)
105
+ }
106
+
107
+ return {
108
+ dataBuffer, dataString, inputPath, detectedEncoding
109
+ };
110
+ } catch (error) {
111
+ if (logalot) { console.log(`${lc} fullPath not found from directory (${directory}) and path (${path})\nerror:\n${extractErrorMsg(error)} (I: 04b11599387ab37adf2b18a5f767cd24)`); }
112
+ return null;
113
+ } finally {
114
+ if (logalot) { console.log(`${lc} complete. (I: baa1e9d18134bc451b56bb5a56150824)`); }
115
+ }
116
+ }
117
+
118
+ /**
119
+ * basic validation for a web fs space ibgib
120
+ */
121
+ export async function validateWebFilesystemSpace_V1Intrinsically({ space }: { space: WebFilesystemSpace_V1<any, any> }): Promise<string[] | null> {
122
+ const lc = `[${validateWebFilesystemSpace_V1Intrinsically.name}]`;
123
+ try {
124
+ if (logalot) { console.log(`${lc} starting... (I: 7dab564254813390c30b082da3c18224)`); }
125
+ const errors: string[] = (await validateIbGibIntrinsically({ ibGib: space })) ?? [];
126
+
127
+ const { ib, gib, data, rel8ns } = space;
128
+
129
+ if (!ib) { errors.push('ib required. (E: f86c9e618fb11b4ac6036e5ff494ba24)'); }
130
+ if (!gib) { errors.push('gib required. (E: 18481a93f7fa0b8e44617b8ef49b6a24)'); }
131
+ if (gib === GIB) { errors.push('gib cannot be primitive. (E: fe6a5111f6d1647458c5a60ed337ee24)'); }
132
+
133
+ if (!data) {
134
+ errors.push('data required. (E: 50d2f1aaa72f61f09efed2361e88d124)');
135
+ return errors;
136
+ }
137
+
138
+ if (data.name) {
139
+ if (!SPACE_NAME_REGEXP.test(data.name)) {
140
+ errors.push(`space name (${data.name}) does not match space name regexp (${SPACE_NAME_REGEXP.source}). (E: 2eb2399e14f11f66a5f06ff9855bf225)`);
141
+ }
142
+ } else {
143
+ errors.push('space name required. (E: 3f3f85315602ee06d1d371a4729f0624)')
144
+ }
145
+ // if (!data.classname) { errors.push('classname required. (E: 5078a2ce307cce02b11c9c393db7c224)') }
146
+ if (data.classname && data.classname !== WebFilesystemSpace_V1.name) {
147
+ errors.push(`unknown classname (${data.classname}). data.classname !== FilesystemSpace_V1.name (E: 251aee62590dd6894144d8b4f9b7ab24)`);
148
+ }
149
+ if (!data.baseDir) { errors.push(`data.baseDir required (E: 66d5467064c4b794bf91218b14d53e24).`) }
150
+ if (!data.baseSubPath) { errors.push(`data.baseSubPath required. (E: 8545b7e9ea9a9b6265f447d9da2bac24)`) }
151
+ if (!data.binSubPath) { errors.push(`data.binSubPath required. (E: c9ca181a8b7979470669e2f7a081d624)`) }
152
+ if (!data.dnaSubPath) { errors.push(`data.dnaSubPath required. (E: 25a3b7a4c4820efa2e092fb122d3fe24)`) }
153
+ if (!data.ibgibsSubPath) { errors.push(`data.ibgibsSubPath required. (E: 8c2552c720bc1470d3566e1b87fe3824)`) }
154
+ if (!data.metaSubPath) { errors.push(`data.metaSubPath required. (E: 5f4d2c846717d21908569dab4b09a224)`) }
155
+ if (data.n && typeof data.n !== 'number') { errors.push(`data.n must be a number. (E: 0e4a25fd447dc835c68ee8657e455724)`) }
156
+ if (data.n === undefined) {
157
+ // the very first space record (tjp) has an undefined n and no rel8ns
158
+ if (rel8ns) { errors.push(`rel8ns not expected when data.n is falsy (custom temporal junction point indicator I suppose...) (E: 43714a88a1f248cdc827a97644d1c124)`); }
159
+ }
160
+ if (!data.spaceSubPath) { errors.push(`data.spaceSubPath required. (E: a49c78b367c5d8b9ddba92d50db8a624)`) }
161
+ if (!data.uuid) { errors.push(`data.uuid required. (E: bf6997ccf542adc15bc31e84012e9524)`) }
162
+ if (!data.encoding) { errors.push(`data.encoding required. (E: 4c61e1a5acc41b5f15f53535177b9124)`) }
163
+ /** should probably get this from Capacitor... */
164
+ const validEncodings = ["utf8", "ascii", "utf16"];
165
+ if (!validEncodings.includes(data.encoding)) {
166
+ errors.push(`invalid encoding: ${data.encoding}. validEncodings: ${validEncodings.join(', ')} (E: 8d2ae9fed4f59ab72c0e7e17bdbda124)`);
167
+ }
168
+
169
+ // ensure ib matches up with internal data
170
+ const { spaceClassname, spaceId, spaceName } = parseSpaceIb({ spaceIb: ib });
171
+ if (data.classname && (spaceClassname !== data.classname)) {
172
+ errors.push(`ib's spaceClassname (${spaceClassname}) must match data.classname (${data.classname}) (E: 9d1fce5cf2d42de2d96b487ab3570a24)`);
173
+ }
174
+ if (spaceId !== data.uuid) {
175
+ errors.push(`ib's spaceId (${spaceId}) must match data.uuid (${data.uuid}) (E: 45f5b88a62ac830302e74b33270b0224)`);
176
+ }
177
+ if (spaceName !== data.name) {
178
+ errors.push(`ib's spaceName (${spaceName}) must match data.name (${data.name}) (E: a752c7bc00e251458dc72af76edcb924)`);
179
+ }
180
+
181
+ // ensure rel8ns make sense
182
+ if (data.n === undefined && (rel8ns?.past ?? []).length > 0) {
183
+ errors.push(`"past" rel8n not expected when data.n is falsy (E: f578bf87da6ab80144f8d879fa0d9724)`);
184
+ }
185
+ if (data.n && (rel8ns?.past ?? []).length === 0) {
186
+ errors.push(`"past" rel8n required when data.n is truthy (E: 7b1e06b911c6f4a1e313ea6cfcdc3a24)`);
187
+ }
188
+ if (data.n === 0 && (rel8ns?.past ?? []).length !== 1) {
189
+ errors.push(`"past" rel8n expected to have a single record when data.n === 0 (E: 47998507925497bb8b25dbf70e542a24)`);
190
+ }
191
+ if (rel8ns && (rel8ns.past?.length ?? -1) > 0) {
192
+ const pastAddrs = rel8ns.past as IbGibAddr[];
193
+ pastAddrs.forEach(x => {
194
+ const { ib: pastIb } = getIbAndGib({ ibGibAddr: x });
195
+ const pastIbInfo = parseSpaceIb({ spaceIb: pastIb });
196
+ if (pastIbInfo.spaceClassname && (pastIbInfo.spaceClassname !== spaceClassname)) {
197
+ errors.push(`rel8ns.past address classname (${pastIbInfo.spaceClassname}) must match current spaceClassname (${spaceClassname}) (E: 71bdfd2c7235c6854963a451ddcd9f24)`);
198
+ }
199
+ if (pastIbInfo.spaceId !== spaceId) {
200
+ errors.push(`rel8ns.past address spaceId (${pastIbInfo.spaceId}) must match current spaceId (${spaceId}) (E: 8b01f47268c34b8a638e397230331824)`);
201
+ }
202
+ // i want to allow this, but for now we're going to require not changing the name...
203
+ if (pastIbInfo.spaceName !== spaceName) {
204
+ errors.push(`rel8ns.past address spaceName (${pastIbInfo.spaceName}) must match current spaceName (${spaceName}) (E: 323ce598506b19ae791377a449aa8e24)`);
205
+ }
206
+ });
207
+ }
208
+
209
+ return errors;
210
+ } catch (error) {
211
+ console.error(`${lc} ${error.message}`);
212
+ throw error;
213
+ } finally {
214
+ if (logalot) { console.log(`${lc} complete.`); }
215
+ }
216
+ }
217
+
218
+ /**
219
+ * gets the data and encoding of a given {@link inputPath} if that file exists.
220
+ * if it doesn't exist, this will throw an ENOENT error, but this is not logged
221
+ * as an error.
222
+ *
223
+ * this is because atow (03/2024) this is only used in a tryRead_bin function
224
+ * where the file often does not exist.
225
+ */
226
+ export async function getFileDataAndEncoding({
227
+ inputPath,
228
+ encodingsToTry = B2TFS_DEFAULT_ENCODINGS_TO_TRY,
229
+ }: {
230
+ inputPath: string,
231
+ /**
232
+ * ignored in web version
233
+ */
234
+ encodingsToTry?: (FileEncoding | undefined)[],
235
+ }): Promise<FileDataInfo> {
236
+ const lc = `[${getFileDataAndEncoding.name}]`;
237
+ try {
238
+ if (logalot) { console.log(`${lc} starting... (I: be8a697780bd9f2dcc4e55ed557d3b24)`); }
239
+
240
+ if (encodingsToTry) {
241
+ console.warn(`${lc} encodingsToTry (${pretty(encodingsToTry)}) is ignored in this web version of this function. (W: 1dda04d8e0b7fb046cff5d89d3903924)`);
242
+ }
243
+
244
+ const resRead = await readFile(inputPath);
245
+ if (resRead instanceof Uint8Array) {
246
+ // uint8array
247
+ if (resRead.length === 0) {
248
+ console.warn(`${lc} file at inputPath (${inputPath}) has dataBuffer.length === 0, i.e., no data content. we are treating this as utf8. (W: 8159ac120ec276df17484c1d32870424)`)
249
+ return {
250
+ inputPath,
251
+ dataBuffer: resRead,
252
+ detectedEncoding: FileEncoding.utf8,
253
+ dataString: '',
254
+ };
255
+ } else {
256
+ const resRead_str = uint8ArrayToString(resRead);
257
+ return {
258
+ inputPath,
259
+ dataString: resRead_str,
260
+ detectedEncoding: FileEncoding.utf8,
261
+ dataBuffer: resRead,
262
+ };
263
+ }
264
+
265
+ // encodingsToTry ??= ['utf-8', 'utf8'];
266
+
267
+ // const tryEncoding = async (encoding: FileEncoding | undefined) => {
268
+ // let res: [boolean, string | undefined];
269
+ // try {
270
+
271
+ // // const str = resRead.toString(encoding ?? undefined);
272
+ // const str = uint8ArrayToString(resRead);
273
+ // /**
274
+ // * doesn't include the node.js replacement unicode char
275
+ // */
276
+ // const isProbablyCorrect = !str.includes('\ufffd');
277
+ // res = [isProbablyCorrect, str];
278
+ // return res;
279
+ // } catch (error) {
280
+ // res = [false, undefined];
281
+ // }
282
+ // return res;
283
+ // }
284
+
285
+ // for (let i = 0; i < encodingsToTry.length; i++) {
286
+ // const maybeEncoding = encodingsToTry[i];
287
+ // const [isProbablyCorrectEncoding, dataString] = await tryEncoding(maybeEncoding);
288
+ // if (isProbablyCorrectEncoding) {
289
+ // resDataAndEncoding = {
290
+ // inputPath,
291
+ // dataString,
292
+ // detectedEncoding: maybeEncoding,
293
+ // dataBuffer,
294
+ // };
295
+ // break;
296
+ // }
297
+ // }
298
+
299
+ } else if (typeof resRead === 'string') {
300
+ // utf8 on web
301
+ return {
302
+ inputPath,
303
+ dataString: resRead,
304
+ detectedEncoding: FileEncoding.utf8,
305
+ dataBuffer: undefined,
306
+ };
307
+ } else if (!resRead) {
308
+ // not found
309
+ return {
310
+ inputPath,
311
+ dataString: undefined,
312
+ detectedEncoding: undefined,
313
+ dataBuffer: undefined,
314
+ };
315
+ } else {
316
+ throw new Error(`(UNEXPECTED) resRead not Uint8Array, not string, not falsy? (E: bdeceb4c354da36708e31406adb30124)`);
317
+ }
318
+ } catch (error) {
319
+ // i'm just suppressing ENOENT at this time because in context, this is
320
+ // often the case. we do, however, rethrow the error for proper flow.
321
+ const emsg = extractErrorMsg(error);
322
+ if (!emsg.startsWith('ENOENT:')) { console.error(`${lc} ${emsg}`); }
323
+ throw error;
324
+ } finally {
325
+ if (logalot) { console.log(`${lc} complete.`); }
326
+ }
327
+ }
328
+
329
+ interface FullPathInfo {
330
+ dbName: string,
331
+ storeName: string,
332
+ key: string,
333
+ }
334
+
335
+ function parseFullPath(fullPath: string): FullPathInfo {
336
+ const lc = `[${parseFullPath.name}]`;
337
+ try {
338
+ if (logalot) { console.log(`${lc} starting... (I: c911bff0cb7333dfd45bde6925cce524)`); }
339
+
340
+ const pieces = fullPath.split('/');
341
+
342
+ // must be at least 3 pieces in path
343
+ if (pieces.length < 3) { throw new Error(`fullPath (${fullPath}) must have at least 3 pieces (E: d99c38d035551af3e85b7f767d911324)`); }
344
+
345
+ // dbName is the first piece
346
+ let dbName = pieces.shift()!;
347
+ if (dbName === '.') { dbName = getGlobalDbName(); }
348
+ // storeName is the second piece of the path
349
+ const storeName = pieces.shift()!;
350
+ // key is the rest of the path
351
+ const key = pieces.join('/');
352
+ return { dbName, storeName, key };
353
+ } catch (error) {
354
+ console.error(`${lc} ${extractErrorMsg(error)}`);
355
+ throw error;
356
+ } finally {
357
+ if (logalot) { console.log(`${lc} complete.`); }
358
+ }
359
+ }
360
+
361
+ /**
362
+ * Writes a "file" to the "filesystem" using IndexedDB.
363
+ *
364
+ * This overload in the node version is used for writing string files (i.e.
365
+ * non-binary utf-8 files).
366
+ *
367
+ * @param fullPath path to write to
368
+ * @param data data to write
369
+ * @param encoding ignored atow (11/2024) in this web version of this function.
370
+ */
371
+ export function writeFile(fullPath: string, data: any, encoding: any): Promise<void>;
372
+ /**
373
+ * Writes a "file" to the "filesystem" using IndexedDB.
374
+ *
375
+ * ATOW (12/2024) this assumes the fullPath is in the form of
376
+ *
377
+ * [dbName]/
378
+ *
379
+ * This overload in the node version is used for writing binary files.
380
+ *
381
+ * @param fullPath path to write to
382
+ * @param data data to write
383
+ */
384
+ export function writeFile(fullPath: string, data: any): Promise<void>;
385
+ export async function writeFile(fullPath: string, data: any, encoding?: any): Promise<void> {
386
+ const lc = `[${writeFile.name}]`;
387
+ try {
388
+ if (logalot) { console.log(`${lc} starting... (I: 18c4f3558ab1f150382948556ab5f924)`); }
389
+
390
+ const { dbName, storeName, key } = parseFullPath(fullPath);
391
+
392
+ if (typeof data === 'string' || data instanceof Uint8Array) {
393
+ // utf8/string/binary on web
394
+ // maybe separate this later if we want to log type?
395
+ await storagePut({ dbName, storeName, key, value: data, });
396
+ } else {
397
+ throw new Error(`(UNEXPECTED) data not string or Uint8Array? (E: ac3e1c15484dbc7188c75e62ab78b124)`);
398
+ }
399
+ } catch (error) {
400
+ console.error(`${lc} ${extractErrorMsg(error)}`);
401
+ throw error;
402
+ } finally {
403
+ if (logalot) { console.log(`${lc} complete.`); }
404
+ }
405
+ }
406
+
407
+
408
+ // export function readFile(fullPath: any, opts: { encoding: string; }): string | Promise<string | undefined> | undefined;
409
+ // export function readFile(fullPath: any): string | Promise<string | undefined> | Uint8Array | Promise<Uint8Array | undefined> | undefined;
410
+ export async function readFile(
411
+ fullPath: any,
412
+ opts?: { encoding: string; },
413
+ ): Promise<string | Uint8Array | undefined> {
414
+ const lc = `[${readFile.name}]`;
415
+ try {
416
+ if (logalot) { console.log(`${lc} starting... (I: 37fd6ea3d79fc1ab797049ef00f6e224)`); }
417
+ // implement the read complement to writeFile
418
+ const { dbName, storeName, key } = parseFullPath(fullPath);
419
+ const resGet = await storageGet({ dbName, storeName, key });
420
+ return resGet;
421
+ } catch (error) {
422
+ console.error(`${lc} ${extractErrorMsg(error)}`);
423
+ throw error;
424
+ } finally {
425
+ if (logalot) { console.log(`${lc} complete.`); }
426
+ }
427
+ }
428
+
429
+ export async function rm(fullPath: string, opts: {
430
+ /**
431
+ * ignored in web version atow (11/2024)
432
+ */
433
+ force: boolean
434
+ }): Promise<void> {
435
+ const lc = `[${rm.name}]`;
436
+ if (logalot) {
437
+ console.log(fullPath);
438
+ console.log(JSON.stringify(opts));
439
+ }
440
+ const { dbName, storeName, key: pathToRm } = parseFullPath(fullPath);
441
+ await storageRmRF({ dbName, storeName, pathToRm: pathToRm });
442
+ }
443
+
444
+ /**
445
+ * is this necessary in web version?
446
+ * @param fullPath
447
+ * @param opts
448
+ */
449
+ export function mkdirSync(fullPath: string, opts: { recursive: boolean }): void {
450
+ const lc = `[${mkdirSync.name}]`;
451
+ throw new Error(`${lc} not implemented (E: da4684557038657662e5d0d17a0c9224)`);
452
+ }
453
+
454
+ /**
455
+ * mimic node's readdir when `withFileTypes` is true.
456
+ *
457
+ * in this overload, returns mimicked `Dirent[]`
458
+ */
459
+ export async function readdir(
460
+ containingDir: string,
461
+ opts: { withFileTypes: true; recursive?: boolean }
462
+ ): Promise<Dirent[]>;
463
+ /**
464
+ * mimic node's readdir when `withFileTypes` is falsy.
465
+ *
466
+ * in this overload, returns `string[]`
467
+ */
468
+ export async function readdir(
469
+ containingDir: string,
470
+ opts?: { withFileTypes?: false; recursive?: boolean }
471
+ ): Promise<string[]>;
472
+ export async function readdir(
473
+ containingDir: string,
474
+ opts?: {
475
+ withFileTypes?: boolean;
476
+ recursive?: boolean;
477
+ }
478
+ ): Promise<string[] | Dirent[]> {
479
+ const lc = `[${readdir.name}]`;
480
+ const { dbName, storeName, key: dirPath } = parseFullPath(containingDir);
481
+
482
+ return await storageReaddir({
483
+ dbName, storeName, dirPath,
484
+ withFileTypes: opts?.withFileTypes ?? false,
485
+ });
486
+ }
487
+
488
+ // export function existsSync(fullPath: string): boolean {
489
+ // const lc = `[${existsSync.name}]`;
490
+ // throw new Error(`${lc} not implemented (E: 2e2577807b69b6f2e475783d59cd1c24)`);
491
+ // }
@@ -0,0 +1,172 @@
1
+ /**
2
+ * @module node-filesystem-space-types
3
+ *
4
+ * mostly interfaces, some constants
5
+ */
6
+
7
+ import { IbGibRel8ns_V1, } from '@ibgib/ts-gib/dist/V1/index.mjs';
8
+
9
+ // import { GLOBAL_LOG_A_LOT } from '../../../constants.mjs';
10
+ import { INDEXED_DB_LONG_PATH_LENGTH } from './web-filesystem-space-constants.mjs';
11
+ import { FilesystemSpaceData_V1, FilesystemSpaceOptionsData, FilesystemSpaceOptionsIbGib, FilesystemSpaceOptionsRel8ns, FilesystemSpaceResultData, FilesystemSpaceResultIbGib, FilesystemSpaceResultRel8ns } from '@ibgib/core-gib/dist/witness/space/filesystem-space/filesystem-space-v1.mjs';
12
+ import { DEFAULT_LOCAL_SPACE_POLLING_INTERVAL_MS, IBGIB_SPACE_NAME_DEFAULT, ZERO_SPACE_ID } from '@ibgib/core-gib/dist/witness/space/space-constants.mjs';
13
+ import { DEFAULT_FILESYSTEM_SPACE_DESCRIPTION, IBGIB_BASE_DIR, IBGIB_BASE_SUBPATH, IBGIB_BIN_SUBPATH, IBGIB_DNA_SUBPATH, IBGIB_ENCODING, IBGIB_IBGIBS_SUBPATH, IBGIB_LONG_SUBPATH, IBGIB_META_SUBPATH, IBGIB_SPACE_SUBPATH_DEFAULT } from '@ibgib/core-gib/dist/witness/space/filesystem-space/filesystem-constants.mjs';
14
+ import { getGlobalDbName } from '../../../helpers.web.mjs';
15
+
16
+
17
+ /**
18
+ * This is the shape of data about this space itself (not the contained ibgibs' spaces).
19
+ */
20
+ export interface WebFilesystemSpaceData_V1 extends FilesystemSpaceData_V1 {
21
+ }
22
+
23
+ /**
24
+ * Used in bootstrapping.
25
+ *
26
+ * If you change this, please bump the version
27
+ *
28
+ * (but of course won't be the end of the world when this doesn't happen).
29
+ *
30
+ * ## notes
31
+ *
32
+ * This is a terrible kluge port from NodeFilesystemSpaceData_V1. I am just
33
+ * moving "as fast as I can" (I can't move fast these days). Little of the
34
+ * filesystem internal details reallly matter I think, as this is just meant to
35
+ * be a local space living on indexeddb. The main thing is segregation of local
36
+ * spaces from each other, but I think this is covered to begin with via the
37
+ * space name used in the path somewhere.
38
+ */
39
+ export const DEFAULT_WEB_FILESYSTEM_SPACE_DATA_V1: WebFilesystemSpaceData_V1 = {
40
+ version: '1',
41
+ uuid: ZERO_SPACE_ID,
42
+ name: IBGIB_SPACE_NAME_DEFAULT,
43
+ classname: 'WebFilesystemSpace_V1',
44
+ // baseDir: IBGIB_BASE_DIR,
45
+ /**
46
+ * atow (12/2025), i am pulling out from blank-gib to web-gib, a more
47
+ * generic framework in the making. This baseDir is a question mark, but it
48
+ * seems that tying this to the consuming app's global db name is a good
49
+ * idea. But only time will tell.
50
+ *
51
+ * I'm considering atow (12/6/2024) using this baseDir as the db name, and
52
+ * the spaceId as the store. To effect this, the writeFile will use the two
53
+ * lowest directories as the db & store names, e.g.,
54
+ *
55
+ * blank^gib/[spaceId]/[other unnecessary paths from node port]/ib^gibaddr
56
+ *
57
+ * (This path will be spliced when "writing the file path".)
58
+ *
59
+ * So the db name is blank^gib, the store name is the spaceId. The other
60
+ * parts of the path are vestigial from node implementation, just as long as
61
+ * it resolves down to the right ibgib addr consistently. If something
62
+ * requires listing other spaces, then the indexed db.stores I think allows
63
+ * for this.
64
+ */
65
+ baseDir: getGlobalDbName(),
66
+ encoding: IBGIB_ENCODING,
67
+ baseSubPath: IBGIB_BASE_SUBPATH,
68
+ spaceSubPath: IBGIB_SPACE_SUBPATH_DEFAULT,
69
+ ibgibsSubPath: IBGIB_IBGIBS_SUBPATH,
70
+ metaSubPath: IBGIB_META_SUBPATH,
71
+ binSubPath: IBGIB_BIN_SUBPATH,
72
+ dnaSubPath: IBGIB_DNA_SUBPATH,
73
+ longSubPath: IBGIB_LONG_SUBPATH,
74
+ mitigateLongPaths: false,
75
+ longPathLength: INDEXED_DB_LONG_PATH_LENGTH,
76
+ persistOptsAndResultIbGibs: false,
77
+ validateIbGibAddrsMatchIbGibs: false,
78
+ longPollingIntervalMs: DEFAULT_LOCAL_SPACE_POLLING_INTERVAL_MS,
79
+ allowPrimitiveArgs: false,
80
+ catchAllErrors: true,
81
+ description: DEFAULT_FILESYSTEM_SPACE_DESCRIPTION,
82
+ trace: false,
83
+ }
84
+
85
+ /** Marker interface atm */
86
+ export interface WebFilesystemSpaceRel8ns_V1 extends IbGibRel8ns_V1 { }
87
+
88
+ /**
89
+ * Space options involve whether we're getting/putting ibgibs categorized as
90
+ * meta, bin, dna.
91
+ *
92
+ * We'll leverage the fact that we don't need to get dna very often, and that
93
+ * meta ibgibs act differently and are recorded differently.
94
+ *
95
+ * For example, we don't necessarily want to keep the past of certain meta
96
+ * objects, because it may change (and thus grow) too quickly.
97
+ */
98
+ export interface WebFilesystemSpaceOptionsData extends FilesystemSpaceOptionsData {
99
+ }
100
+
101
+ export interface WebFilesystemSpaceOptionsRel8ns extends FilesystemSpaceOptionsRel8ns {
102
+ }
103
+
104
+ /** Marker interface atm */
105
+ export interface WebFilesystemSpaceOptionsIbGib
106
+ extends FilesystemSpaceOptionsIbGib<WebFilesystemSpaceOptionsData, WebFilesystemSpaceOptionsRel8ns> {
107
+ }
108
+
109
+ /** Marker interface atm */
110
+ export interface WebFilesystemSpaceResultData extends FilesystemSpaceResultData {
111
+ }
112
+
113
+ export interface WebFilesystemSpaceResultRel8ns extends FilesystemSpaceResultRel8ns {
114
+ }
115
+
116
+ export interface WebFilesystemSpaceResultIbGib
117
+ extends FilesystemSpaceResultIbGib<WebFilesystemSpaceResultData, WebFilesystemSpaceResultRel8ns> {
118
+ }
119
+ /**
120
+ * currently i'm just taking this from the definition of node's `Buffer` type.
121
+ *
122
+ * ## notes
123
+ *
124
+ * * using this with handle-reify-file.mts when reading the file.
125
+ * * 'binary' may resolve to 'latin1' per SO
126
+ * * https://stackoverflow.com/questions/46441667/reading-binary-data-in-node-js
127
+ */
128
+ export type FileEncoding =
129
+ | 'ascii'
130
+ | 'utf8'
131
+ | 'utf-8'
132
+ | 'utf16le'
133
+ | 'ucs2'
134
+ | 'ucs-2'
135
+ | 'base64'
136
+ | 'base64url'
137
+ | 'latin1'
138
+ | 'binary'
139
+ | 'hex';
140
+ export const FileEncoding = {
141
+ ascii: 'ascii' as FileEncoding,
142
+ utf8: 'utf8' as FileEncoding,
143
+ utf_8: 'utf-8' as FileEncoding,
144
+ ['utf-8']: 'utf-8' as FileEncoding,
145
+ utf16le: 'utf16le' as FileEncoding,
146
+ ucs2: 'ucs2' as FileEncoding,
147
+ ucs_2: 'ucs-2' as FileEncoding,
148
+ ['ucs-2']: 'ucs-2' as FileEncoding,
149
+ base64: 'base64' as FileEncoding,
150
+ base64url: 'base64url' as FileEncoding,
151
+ latin1: 'latin1' as FileEncoding,
152
+ binary: 'binary' as FileEncoding,
153
+ hex: 'hex' as FileEncoding,
154
+ };
155
+ /**
156
+ * valid file encoding values per {@link FileEncoding}
157
+ */
158
+ export const FILE_ENCODINGS = Object.values(FileEncoding);
159
+
160
+ export interface FileDataInfo {
161
+ inputPath: string;
162
+ detectedEncoding?: FileEncoding | undefined;
163
+ dataString?: string | undefined;
164
+ dataBuffer?: Uint8Array | undefined;
165
+ }
166
+ export const B2TFS_DEFAULT_ENCODINGS_TO_TRY: (FileEncoding | undefined)[] = [
167
+ FileEncoding.utf8,
168
+ FileEncoding.utf16le,
169
+ FileEncoding.base64,
170
+ FileEncoding.binary,
171
+ undefined,
172
+ ];