@ibgib/core-gib 0.0.4

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 (330) hide show
  1. package/.vscode/core-gib-snippets.code-snippets +189 -0
  2. package/.vscode/launch.json +24 -0
  3. package/.vscode/settings.json +56 -0
  4. package/.vscode/tasks.json +37 -0
  5. package/CHANGELOG.md +11 -0
  6. package/README.md +215 -0
  7. package/dist/common/aws-constants.d.mts +7 -0
  8. package/dist/common/aws-constants.d.mts.map +1 -0
  9. package/dist/common/aws-constants.mjs +7 -0
  10. package/dist/common/aws-constants.mjs.map +1 -0
  11. package/dist/common/bin/bin-types.d.mts +17 -0
  12. package/dist/common/bin/bin-types.d.mts.map +1 -0
  13. package/dist/common/bin/bin-types.mjs +3 -0
  14. package/dist/common/bin/bin-types.mjs.map +1 -0
  15. package/dist/common/cache/cache-types.d.mts +57 -0
  16. package/dist/common/cache/cache-types.d.mts.map +1 -0
  17. package/dist/common/cache/cache-types.mjs +2 -0
  18. package/dist/common/cache/cache-types.mjs.map +1 -0
  19. package/dist/common/comment/comment-constants.d.mts +11 -0
  20. package/dist/common/comment/comment-constants.d.mts.map +1 -0
  21. package/dist/common/comment/comment-constants.mjs +11 -0
  22. package/dist/common/comment/comment-constants.mjs.map +1 -0
  23. package/dist/common/comment/comment-helper.d.mts +59 -0
  24. package/dist/common/comment/comment-helper.d.mts.map +1 -0
  25. package/dist/common/comment/comment-helper.mjs +173 -0
  26. package/dist/common/comment/comment-helper.mjs.map +1 -0
  27. package/dist/common/comment/comment-types.d.mts +16 -0
  28. package/dist/common/comment/comment-types.d.mts.map +1 -0
  29. package/dist/common/comment/comment-types.mjs +2 -0
  30. package/dist/common/comment/comment-types.mjs.map +1 -0
  31. package/dist/common/display/display-helper.d.mts +19 -0
  32. package/dist/common/display/display-helper.d.mts.map +1 -0
  33. package/dist/common/display/display-helper.mjs +68 -0
  34. package/dist/common/display/display-helper.mjs.map +1 -0
  35. package/dist/common/display/display-types.d.mts +97 -0
  36. package/dist/common/display/display-types.d.mts.map +1 -0
  37. package/dist/common/display/display-types.mjs +37 -0
  38. package/dist/common/display/display-types.mjs.map +1 -0
  39. package/dist/common/encrypt/encrypt-constants.d.mts +27 -0
  40. package/dist/common/encrypt/encrypt-constants.d.mts.map +1 -0
  41. package/dist/common/encrypt/encrypt-constants.mjs +27 -0
  42. package/dist/common/encrypt/encrypt-constants.mjs.map +1 -0
  43. package/dist/common/encrypt/encrypt-types.d.mts +116 -0
  44. package/dist/common/encrypt/encrypt-types.d.mts.map +1 -0
  45. package/dist/common/encrypt/encrypt-types.mjs +9 -0
  46. package/dist/common/encrypt/encrypt-types.mjs.map +1 -0
  47. package/dist/common/error/error-constants.d.mts +9 -0
  48. package/dist/common/error/error-constants.d.mts.map +1 -0
  49. package/dist/common/error/error-constants.mjs +9 -0
  50. package/dist/common/error/error-constants.mjs.map +1 -0
  51. package/dist/common/error/error-helper.d.mts +43 -0
  52. package/dist/common/error/error-helper.d.mts.map +1 -0
  53. package/dist/common/error/error-helper.mjs +167 -0
  54. package/dist/common/error/error-helper.mjs.map +1 -0
  55. package/dist/common/error/error-types.d.mts +58 -0
  56. package/dist/common/error/error-types.d.mts.map +1 -0
  57. package/dist/common/error/error-types.mjs +2 -0
  58. package/dist/common/error/error-types.mjs.map +1 -0
  59. package/dist/common/form/form-helper.d.mts +97 -0
  60. package/dist/common/form/form-helper.d.mts.map +1 -0
  61. package/dist/common/form/form-helper.mjs +185 -0
  62. package/dist/common/form/form-helper.mjs.map +1 -0
  63. package/dist/common/form/form-items.d.mts +229 -0
  64. package/dist/common/form/form-items.d.mts.map +1 -0
  65. package/dist/common/form/form-items.mjs +63 -0
  66. package/dist/common/form/form-items.mjs.map +1 -0
  67. package/dist/common/import-export/import-export-types.d.mts +18 -0
  68. package/dist/common/import-export/import-export-types.d.mts.map +1 -0
  69. package/dist/common/import-export/import-export-types.mjs +2 -0
  70. package/dist/common/import-export/import-export-types.mjs.map +1 -0
  71. package/dist/common/legacy/legacy-types.d.mts +2 -0
  72. package/dist/common/legacy/legacy-types.d.mts.map +1 -0
  73. package/dist/common/legacy/legacy-types.mjs +2 -0
  74. package/dist/common/legacy/legacy-types.mjs.map +1 -0
  75. package/dist/common/link/link-constants.d.mts +2 -0
  76. package/dist/common/link/link-constants.d.mts.map +1 -0
  77. package/dist/common/link/link-constants.mjs +2 -0
  78. package/dist/common/link/link-constants.mjs.map +1 -0
  79. package/dist/common/link/link-helper.d.mts +37 -0
  80. package/dist/common/link/link-helper.d.mts.map +1 -0
  81. package/dist/common/link/link-helper.mjs +143 -0
  82. package/dist/common/link/link-helper.mjs.map +1 -0
  83. package/dist/common/link/link-types.d.mts +14 -0
  84. package/dist/common/link/link-types.d.mts.map +1 -0
  85. package/dist/common/link/link-types.mjs +2 -0
  86. package/dist/common/link/link-types.mjs.map +1 -0
  87. package/dist/common/other/graph-helper.d.mts +166 -0
  88. package/dist/common/other/graph-helper.d.mts.map +1 -0
  89. package/dist/common/other/graph-helper.mjs +710 -0
  90. package/dist/common/other/graph-helper.mjs.map +1 -0
  91. package/dist/common/other/ibgib-helper.d.mts +245 -0
  92. package/dist/common/other/ibgib-helper.d.mts.map +1 -0
  93. package/dist/common/other/ibgib-helper.mjs +641 -0
  94. package/dist/common/other/ibgib-helper.mjs.map +1 -0
  95. package/dist/common/other/other-constants.d.mts +53 -0
  96. package/dist/common/other/other-constants.d.mts.map +1 -0
  97. package/dist/common/other/other-constants.mjs +67 -0
  98. package/dist/common/other/other-constants.mjs.map +1 -0
  99. package/dist/common/other/other-types.d.mts +166 -0
  100. package/dist/common/other/other-types.d.mts.map +1 -0
  101. package/dist/common/other/other-types.mjs +30 -0
  102. package/dist/common/other/other-types.mjs.map +1 -0
  103. package/dist/common/other/svg-constants.d.mts +2 -0
  104. package/dist/common/other/svg-constants.d.mts.map +1 -0
  105. package/dist/common/other/svg-constants.mjs +2 -0
  106. package/dist/common/other/svg-constants.mjs.map +1 -0
  107. package/dist/common/other/svg-helper.d.mts +54 -0
  108. package/dist/common/other/svg-helper.d.mts.map +1 -0
  109. package/dist/common/other/svg-helper.mjs +170 -0
  110. package/dist/common/other/svg-helper.mjs.map +1 -0
  111. package/dist/common/pic/pic-constants.d.mts +13 -0
  112. package/dist/common/pic/pic-constants.d.mts.map +1 -0
  113. package/dist/common/pic/pic-constants.mjs +13 -0
  114. package/dist/common/pic/pic-constants.mjs.map +1 -0
  115. package/dist/common/pic/pic-helper.d.mts +70 -0
  116. package/dist/common/pic/pic-helper.d.mts.map +1 -0
  117. package/dist/common/pic/pic-helper.mjs +235 -0
  118. package/dist/common/pic/pic-helper.mjs.map +1 -0
  119. package/dist/common/pic/pic-types.d.mts +23 -0
  120. package/dist/common/pic/pic-types.d.mts.map +1 -0
  121. package/dist/common/pic/pic-types.mjs +2 -0
  122. package/dist/common/pic/pic-types.mjs.map +1 -0
  123. package/dist/common/root/root-constants.d.mts +40 -0
  124. package/dist/common/root/root-constants.d.mts.map +1 -0
  125. package/dist/common/root/root-constants.mjs +40 -0
  126. package/dist/common/root/root-constants.mjs.map +1 -0
  127. package/dist/common/root/root-types.d.mts +9 -0
  128. package/dist/common/root/root-types.d.mts.map +1 -0
  129. package/dist/common/root/root-types.mjs +2 -0
  130. package/dist/common/root/root-types.mjs.map +1 -0
  131. package/dist/common/tag/tag-constants.d.mts +21 -0
  132. package/dist/common/tag/tag-constants.d.mts.map +1 -0
  133. package/dist/common/tag/tag-constants.mjs +28 -0
  134. package/dist/common/tag/tag-constants.mjs.map +1 -0
  135. package/dist/common/tag/tag-types.d.mts +14 -0
  136. package/dist/common/tag/tag-types.d.mts.map +1 -0
  137. package/dist/common/tag/tag-types.mjs +2 -0
  138. package/dist/common/tag/tag-types.mjs.map +1 -0
  139. package/dist/core-constants.d.mts +89 -0
  140. package/dist/core-constants.d.mts.map +1 -0
  141. package/dist/core-constants.mjs +484 -0
  142. package/dist/core-constants.mjs.map +1 -0
  143. package/dist/core-helper.d.mts +6 -0
  144. package/dist/core-helper.d.mts.map +1 -0
  145. package/dist/core-helper.mjs +28 -0
  146. package/dist/core-helper.mjs.map +1 -0
  147. package/dist/core-types.d.mts +520 -0
  148. package/dist/core-types.d.mts.map +1 -0
  149. package/dist/core-types.mjs +2 -0
  150. package/dist/core-types.mjs.map +1 -0
  151. package/dist/index.d.mts +2 -0
  152. package/dist/index.d.mts.map +1 -0
  153. package/dist/index.mjs +3 -0
  154. package/dist/index.mjs.map +1 -0
  155. package/dist/witness/app/app-base-v1.d.mts +130 -0
  156. package/dist/witness/app/app-base-v1.d.mts.map +1 -0
  157. package/dist/witness/app/app-base-v1.mjs +462 -0
  158. package/dist/witness/app/app-base-v1.mjs.map +1 -0
  159. package/dist/witness/app/app-constants.d.mts +10 -0
  160. package/dist/witness/app/app-constants.d.mts.map +1 -0
  161. package/dist/witness/app/app-constants.mjs +13 -0
  162. package/dist/witness/app/app-constants.mjs.map +1 -0
  163. package/dist/witness/app/app-helper.d.mts +85 -0
  164. package/dist/witness/app/app-helper.d.mts.map +1 -0
  165. package/dist/witness/app/app-helper.mjs +258 -0
  166. package/dist/witness/app/app-helper.mjs.map +1 -0
  167. package/dist/witness/app/app-types.d.mts +211 -0
  168. package/dist/witness/app/app-types.d.mts.map +1 -0
  169. package/dist/witness/app/app-types.mjs +49 -0
  170. package/dist/witness/app/app-types.mjs.map +1 -0
  171. package/dist/witness/app/chat-app/chat-app-types.d.mts +18 -0
  172. package/dist/witness/app/chat-app/chat-app-types.d.mts.map +1 -0
  173. package/dist/witness/app/chat-app/chat-app-types.mjs +25 -0
  174. package/dist/witness/app/chat-app/chat-app-types.mjs.map +1 -0
  175. package/dist/witness/app/flash-app/flash-app-types.d.mts +16 -0
  176. package/dist/witness/app/flash-app/flash-app-types.d.mts.map +1 -0
  177. package/dist/witness/app/flash-app/flash-app-types.mjs +23 -0
  178. package/dist/witness/app/flash-app/flash-app-types.mjs.map +1 -0
  179. package/dist/witness/app/raw-app/raw-app-types.d.mts +18 -0
  180. package/dist/witness/app/raw-app/raw-app-types.d.mts.map +1 -0
  181. package/dist/witness/app/raw-app/raw-app-types.mjs +25 -0
  182. package/dist/witness/app/raw-app/raw-app-types.mjs.map +1 -0
  183. package/dist/witness/app/todo-app/todo-app-types.d.ts +33 -0
  184. package/dist/witness/app/todo-app/todo-app-types.d.ts.map +1 -0
  185. package/dist/witness/app/todo-app/todo-app-types.js +31 -0
  186. package/dist/witness/app/todo-app/todo-app-types.js.map +1 -0
  187. package/dist/witness/robbot/robbot-base-v1.d.ts +432 -0
  188. package/dist/witness/robbot/robbot-base-v1.d.ts.map +1 -0
  189. package/dist/witness/robbot/robbot-base-v1.js +1407 -0
  190. package/dist/witness/robbot/robbot-base-v1.js.map +1 -0
  191. package/dist/witness/robbot/robbot-constants.d.mts +24 -0
  192. package/dist/witness/robbot/robbot-constants.d.mts.map +1 -0
  193. package/dist/witness/robbot/robbot-constants.mjs +24 -0
  194. package/dist/witness/robbot/robbot-constants.mjs.map +1 -0
  195. package/dist/witness/robbot/robbot-helper.d.mts +152 -0
  196. package/dist/witness/robbot/robbot-helper.d.mts.map +1 -0
  197. package/dist/witness/robbot/robbot-helper.mjs +609 -0
  198. package/dist/witness/robbot/robbot-helper.mjs.map +1 -0
  199. package/dist/witness/robbot/robbot-types.d.mts +539 -0
  200. package/dist/witness/robbot/robbot-types.d.mts.map +1 -0
  201. package/dist/witness/robbot/robbot-types.mjs +294 -0
  202. package/dist/witness/robbot/robbot-types.mjs.map +1 -0
  203. package/dist/witness/space/bootstrap/bootstrap-constants.d.mts +14 -0
  204. package/dist/witness/space/bootstrap/bootstrap-constants.d.mts.map +1 -0
  205. package/dist/witness/space/bootstrap/bootstrap-constants.mjs +15 -0
  206. package/dist/witness/space/bootstrap/bootstrap-constants.mjs.map +1 -0
  207. package/dist/witness/space/inner-space-v1.d.ts +63 -0
  208. package/dist/witness/space/inner-space-v1.d.ts.map +1 -0
  209. package/dist/witness/space/inner-space-v1.js +356 -0
  210. package/dist/witness/space/inner-space-v1.js.map +1 -0
  211. package/dist/witness/space/outer-space/outer-space-constants.d.mts +2 -0
  212. package/dist/witness/space/outer-space/outer-space-constants.d.mts.map +1 -0
  213. package/dist/witness/space/outer-space/outer-space-constants.mjs +2 -0
  214. package/dist/witness/space/outer-space/outer-space-constants.mjs.map +1 -0
  215. package/dist/witness/space/outer-space/outer-space-helper.d.mts +28 -0
  216. package/dist/witness/space/outer-space/outer-space-helper.d.mts.map +1 -0
  217. package/dist/witness/space/outer-space/outer-space-helper.mjs +87 -0
  218. package/dist/witness/space/outer-space/outer-space-helper.mjs.map +1 -0
  219. package/dist/witness/space/outer-space/outer-space-types.d.mts +548 -0
  220. package/dist/witness/space/outer-space/outer-space-types.d.mts.map +1 -0
  221. package/dist/witness/space/outer-space/outer-space-types.mjs +118 -0
  222. package/dist/witness/space/outer-space/outer-space-types.mjs.map +1 -0
  223. package/dist/witness/space/space-base-v1.d.mts +147 -0
  224. package/dist/witness/space/space-base-v1.d.mts.map +1 -0
  225. package/dist/witness/space/space-base-v1.mjs +350 -0
  226. package/dist/witness/space/space-base-v1.mjs.map +1 -0
  227. package/dist/witness/space/space-constants.d.mts +181 -0
  228. package/dist/witness/space/space-constants.d.mts.map +1 -0
  229. package/dist/witness/space/space-constants.mjs +192 -0
  230. package/dist/witness/space/space-constants.mjs.map +1 -0
  231. package/dist/witness/space/space-helper.d.mts +666 -0
  232. package/dist/witness/space/space-helper.d.mts.map +1 -0
  233. package/dist/witness/space/space-helper.mjs +2830 -0
  234. package/dist/witness/space/space-helper.mjs.map +1 -0
  235. package/dist/witness/space/space-types.d.mts +422 -0
  236. package/dist/witness/space/space-types.d.mts.map +1 -0
  237. package/dist/witness/space/space-types.mjs +52 -0
  238. package/dist/witness/space/space-types.mjs.map +1 -0
  239. package/dist/witness/witness-base-v1.d.ts +144 -0
  240. package/dist/witness/witness-base-v1.d.ts.map +1 -0
  241. package/dist/witness/witness-base-v1.js +300 -0
  242. package/dist/witness/witness-base-v1.js.map +1 -0
  243. package/dist/witness/witness-constants.d.mts +3 -0
  244. package/dist/witness/witness-constants.d.mts.map +1 -0
  245. package/dist/witness/witness-constants.mjs +3 -0
  246. package/dist/witness/witness-constants.mjs.map +1 -0
  247. package/dist/witness/witness-form-builder.d.mts +45 -0
  248. package/dist/witness/witness-form-builder.d.mts.map +1 -0
  249. package/dist/witness/witness-form-builder.mjs +95 -0
  250. package/dist/witness/witness-form-builder.mjs.map +1 -0
  251. package/dist/witness/witness-helper.d.mts +89 -0
  252. package/dist/witness/witness-helper.d.mts.map +1 -0
  253. package/dist/witness/witness-helper.mjs +229 -0
  254. package/dist/witness/witness-helper.mjs.map +1 -0
  255. package/dist/witness/witness-types.d.mts +211 -0
  256. package/dist/witness/witness-types.d.mts.map +1 -0
  257. package/dist/witness/witness-types.mjs +2 -0
  258. package/dist/witness/witness-types.mjs.map +1 -0
  259. package/jasmine-browser.json +18 -0
  260. package/jasmine.json +6 -0
  261. package/package.json +67 -0
  262. package/src/assumptions.spec.mts +45 -0
  263. package/src/common/aws-constants.mts +5 -0
  264. package/src/common/bin/bin-types.mts +17 -0
  265. package/src/common/cache/cache-types.mts +53 -0
  266. package/src/common/comment/comment-constants.mts +10 -0
  267. package/src/common/comment/comment-helper.mts +211 -0
  268. package/src/common/comment/comment-types.mts +19 -0
  269. package/src/common/display/display-helper.mts +88 -0
  270. package/src/common/display/display-types.mts +108 -0
  271. package/src/common/encrypt/encrypt-constants.mts +28 -0
  272. package/src/common/encrypt/encrypt-types.mts +130 -0
  273. package/src/common/error/error-constants.mts +8 -0
  274. package/src/common/error/error-helper.mts +155 -0
  275. package/src/common/error/error-types.mts +62 -0
  276. package/src/common/form/form-helper.mts +253 -0
  277. package/src/common/form/form-items.mts +236 -0
  278. package/src/common/import-export/import-export-types.mts +18 -0
  279. package/src/common/legacy/about-legacy.md +0 -0
  280. package/src/common/legacy/legacy-types.mts +0 -0
  281. package/src/common/link/link-constants.mts +1 -0
  282. package/src/common/link/link-helper.mts +155 -0
  283. package/src/common/link/link-types.mts +16 -0
  284. package/src/common/other/graph-helper.mts +853 -0
  285. package/src/common/other/ibgib-helper.mts +671 -0
  286. package/src/common/other/other-constants.mts +76 -0
  287. package/src/common/other/other-types.mts +186 -0
  288. package/src/common/other/svg-constants.mts +1 -0
  289. package/src/common/other/svg-helper.mts +238 -0
  290. package/src/common/pic/pic-constants.mts +13 -0
  291. package/src/common/pic/pic-helper.mts +295 -0
  292. package/src/common/pic/pic-types.mts +29 -0
  293. package/src/common/root/root-constants.mts +41 -0
  294. package/src/common/root/root-types.mts +8 -0
  295. package/src/common/tag/tag-constants.mts +34 -0
  296. package/src/common/tag/tag-types.mts +19 -0
  297. package/src/core-constants.mts +506 -0
  298. package/src/core-helper.mts +33 -0
  299. package/src/core-types.mts +519 -0
  300. package/src/helper.spec.mts +64 -0
  301. package/src/index.mts +1 -0
  302. package/src/witness/app/app-base-v1.mts +584 -0
  303. package/src/witness/app/app-constants.mts +16 -0
  304. package/src/witness/app/app-helper.mts +322 -0
  305. package/src/witness/app/app-types.mts +252 -0
  306. package/src/witness/app/chat-app/chat-app-types.mts +40 -0
  307. package/src/witness/app/flash-app/flash-app-types.mts +38 -0
  308. package/src/witness/app/raw-app/raw-app-types.mts +40 -0
  309. package/src/witness/app/todo-app/todo-app-types.ts +59 -0
  310. package/src/witness/robbot/robbot-base-v1.ts +1531 -0
  311. package/src/witness/robbot/robbot-constants.mts +25 -0
  312. package/src/witness/robbot/robbot-helper.mts +676 -0
  313. package/src/witness/robbot/robbot-helper.spec.mts +135 -0
  314. package/src/witness/robbot/robbot-types.mts +797 -0
  315. package/src/witness/space/bootstrap/bootstrap-constants.mts +15 -0
  316. package/src/witness/space/inner-space-v1.ts +372 -0
  317. package/src/witness/space/outer-space/outer-space-constants.mts +1 -0
  318. package/src/witness/space/outer-space/outer-space-helper.mts +91 -0
  319. package/src/witness/space/outer-space/outer-space-types.mts +627 -0
  320. package/src/witness/space/space-base-v1.mts +414 -0
  321. package/src/witness/space/space-constants.mts +208 -0
  322. package/src/witness/space/space-helper.mts +3242 -0
  323. package/src/witness/space/space-types.mts +476 -0
  324. package/src/witness/witness-base-v1.ts +325 -0
  325. package/src/witness/witness-constants.mts +2 -0
  326. package/src/witness/witness-form-builder.mts +128 -0
  327. package/src/witness/witness-helper.mts +256 -0
  328. package/src/witness/witness-types.mts +249 -0
  329. package/tsconfig.json +15 -0
  330. package/tsconfig.test.json +10 -0
@@ -0,0 +1,295 @@
1
+ import { TransformResult, getIbGibAddr } from '@ibgib/ts-gib';
2
+ import { Factory_V1 as factory, IbGibRel8ns_V1, IBGIB_DELIMITER, IbGib_V1 } from '@ibgib/ts-gib/dist/V1/index.mjs';
3
+ import { getGib } from '@ibgib/ts-gib/dist/V1/transforms/transform-helper.mjs';
4
+ // import { hash, getIbGibAddr, getTimestamp, pretty } from '@ibgib/ts-gib/dist/helper.mjs';
5
+
6
+
7
+ import { GLOBAL_LOG_A_LOT } from '../../core-constants.mjs';
8
+ import { PicData_V1, PicIbGib_V1 } from './pic-types.mjs';
9
+ import { IbGibSpaceAny } from '../../witness/space/space-base-v1.mjs';
10
+ import { BinIbGib_V1 } from '../bin/bin-types.mjs';
11
+ import { persistTransformResult, putInSpace } from '../../witness/space/space-helper.mjs';
12
+ import { getBinIb } from '../other/ibgib-helper.mjs';
13
+ import { delay, getFileReaderHack, hash } from '@ibgib/helper-gib';
14
+ import { BINARY_REL8N_NAME } from './pic-constants.mjs';
15
+
16
+ const logalot = GLOBAL_LOG_A_LOT || false;
17
+
18
+ export interface PicDependencyGraph {
19
+ picIbGib: PicIbGib_V1;
20
+ binIbGib: BinIbGib_V1;
21
+ dependencies: IbGib_V1[];
22
+ }
23
+
24
+ export async function createBinIbGib({
25
+ base64Data,
26
+ binHash,
27
+ ext,
28
+ saveInSpace,
29
+ space,
30
+ }: {
31
+ /**
32
+ * base64-encoded binary data
33
+ */
34
+ base64Data: string,
35
+ /**
36
+ * Hash of data
37
+ */
38
+ binHash: string,
39
+ /**
40
+ * extension of the binary
41
+ *
42
+ * this will be included in the ib
43
+ */
44
+ ext?: string,
45
+ /**
46
+ * If true, will save the ibgibs created in the given `space`.
47
+
48
+ * @see {@link space}
49
+ */
50
+ saveInSpace?: boolean,
51
+ /**
52
+ * space to save the ibgib(s) if `saveInSpace` is truthy.
53
+ *
54
+ * @see {@link saveInSpace}
55
+ */
56
+ space?: IbGibSpaceAny,
57
+ }): Promise<TransformResult<BinIbGib_V1>> {
58
+ const lc = `[${createBinIbGib.name}]`;
59
+ try {
60
+ if (logalot) { console.log(`${lc} starting...`); }
61
+
62
+ if (!binHash) { throw new Error(`binHash required (E: 09da0190a9353089a9ed8a641fe0bc22)`); }
63
+
64
+ const binIb = getBinIb({ binHash, binExt: ext });
65
+ const binIbGib: BinIbGib_V1 = { ib: binIb, data: (base64Data as any) };
66
+
67
+ const binGib = await getGib({ ibGib: binIbGib, hasTjp: false });
68
+ binIbGib.gib = binGib;
69
+
70
+ if (saveInSpace) {
71
+ // prepare
72
+ if (!space) { throw new Error(`space required if saveInSpace is truthy. (E: b8a5ebbac47d757afce940d2f0af3122)`); }
73
+ if (logalot) { console.log(`${lc} saving binary ibgib in space... (I: 8235addb1b3e4e638ef568da5f219d29)`); }
74
+
75
+ // execute put
76
+ const resSaveBin = await putInSpace({ ibGib: binIbGib, space });
77
+
78
+ // if errored, throw
79
+ if (!resSaveBin.success) { throw new Error(resSaveBin.errorMsg || 'error saving pic (E: cf892bc62ab44ec58534d9881c9c4332)'); }
80
+
81
+ // cleanup
82
+ if (logalot) { console.log(`${lc} saving binary ibgib in space complete. (I: 4aa8d03088ad477dbee089394b3b9902)`); }
83
+ }
84
+
85
+ return { newIbGib: binIbGib };
86
+ } catch (error) {
87
+ console.error(`${lc} ${error.message}`);
88
+ throw error;
89
+ } finally {
90
+ if (logalot) { console.log(`${lc} complete.`); }
91
+ }
92
+ }
93
+
94
+ /**
95
+ * shared pic code between camera and loading image via picking a file.
96
+ */
97
+ export async function createPicAndBinIbGibs({
98
+ imageBase64,
99
+ binHash,
100
+ filename,
101
+ ext,
102
+ saveInSpace,
103
+ space,
104
+ }: {
105
+ imageBase64: string,
106
+ binHash: string,
107
+ filename?: string,
108
+ ext?: string,
109
+ /**
110
+ * If true, will save the ibgibs created in the given `space`.
111
+ */
112
+ saveInSpace?: boolean,
113
+ /**
114
+ * If `saveInSpace`, all ibgibs created in this function will be stored in
115
+ * this space.
116
+ */
117
+ space?: IbGibSpaceAny,
118
+ }): Promise<[TransformResult<PicIbGib_V1>, TransformResult<BinIbGib_V1>]> {
119
+ const lc = `[${createPicAndBinIbGibs.name}]`;
120
+
121
+ if (logalot) { console.log(`${lc} starting...`); }
122
+ try {
123
+ const resCreateBin =
124
+ await createBinIbGib({ base64Data: imageBase64, binHash, ext, saveInSpace, space });
125
+ const { newIbGib: binIbGib } = resCreateBin;
126
+ const binAddr = getIbGibAddr({ ibGib: binIbGib });
127
+
128
+ // todo: do thumbnail also
129
+
130
+ // NOTE: This is not the same filename that is saved in the bin folder!
131
+ // This is for when the picture is downloaded outside of the ibGib system
132
+ // or for display purposes.
133
+ const timestamp = (new Date).toUTCString();
134
+ filename = filename || timestamp
135
+ .replace(':', '-')
136
+ .replace(':', '-')
137
+ .replace(',', '')
138
+ // .replace(new RegExp(/\W/), '') // any remaining-non-word chars
139
+ ; // temporary eek.
140
+
141
+ if (logalot) { console.log(`${lc} binHash: ${binHash}`); }
142
+ if (logalot) { console.log(`${lc} ext: ${ext}`); }
143
+ const data: PicData_V1 = ext ?
144
+ { binHash, ext, filename, timestamp } :
145
+ { binHash, filename, timestamp };
146
+ const rel8ns: IbGibRel8ns_V1 = {
147
+ // 'pic on': [addr], // makes it more difficult to share/sync ibgibs
148
+ [BINARY_REL8N_NAME]: [binAddr],
149
+ };
150
+
151
+ // create an ibgib with the filename and ext
152
+ const resPicIbGib = await factory.firstGen({
153
+ parentIbGib: factory.primitive({ ib: 'pic' }),
154
+ ib: `pic ${binHash}`,
155
+ data,
156
+ rel8ns,
157
+ dna: true,
158
+ tjp: { uuid: true, timestamp: true },
159
+ nCounter: true,
160
+ }) as TransformResult<PicIbGib_V1>;
161
+
162
+ if (saveInSpace) {
163
+ if (!space) { throw new Error(`space required if saveInSpace is truthy (E: 966901041c9e166c0f5ed23114003722)`); }
164
+ await persistTransformResult({ resTransform: resPicIbGib, space });
165
+ }
166
+
167
+ return [resPicIbGib, resCreateBin];
168
+ } catch (error) {
169
+ console.error(`${lc} ${error.message}`);
170
+ throw error;
171
+ }
172
+ }
173
+
174
+ export async function createPicAndBinIbGibsFromInputFilePickedEvent({
175
+ event,
176
+ saveInSpace,
177
+ space,
178
+ }: {
179
+ event: any,
180
+ /**
181
+ * If true, will save the ibgibs created in the given `space`.
182
+
183
+ * @see {@link space}
184
+ */
185
+ saveInSpace?: boolean,
186
+ space: IbGibSpaceAny,
187
+ }): Promise<[TransformResult<PicIbGib_V1>, TransformResult<BinIbGib_V1>][]> {
188
+ const lc = `[${createPicAndBinIbGibsFromInputFilePickedEvent.name}]`;
189
+ try {
190
+ // validate incoming input picker result
191
+ // thanks https://edupala.com/capacitor-camera-example/
192
+ const target = event.target as HTMLInputElement;
193
+ if (!target) { throw new Error(`event.target required (E: a9ade57d4359d3b0bbc75c3fea093a22)`); }
194
+ if ((target.files ?? []).length === 0) { throw new Error(`target.files is falsy/empty (E: f2932f1012c9e04a5f06a521a381ff22)`); }
195
+
196
+ const result: [TransformResult<PicIbGib_V1>, TransformResult<BinIbGib_V1>][] = [];
197
+
198
+ // going to execute serially to maintain order of incoming target files
199
+ // IOW not going to do a Promise.all equivalent
200
+ for (let i = 0; i < target.files!.length; i++) {
201
+ const file = target.files![i];
202
+ if (!file) { throw new Error(`file required. (E: 24a8bf4cdf17dcae04b15438bc0a4522)`); }
203
+ const pattern = /image-*/;
204
+ if (!file.type.match(pattern)) { throw new Error(`File format not supported. file: ${file} (E: dca558def013c1c85c83f0ac088b2122)`); }
205
+ // wrap reader in promise for use with async/await
206
+ const resSingleCreate =
207
+ await new Promise<[TransformResult<PicIbGib_V1>, TransformResult<BinIbGib_V1>]>((resolve, reject) => {
208
+ // const reader = new FileReader();
209
+ const reader = getFileReaderHack();
210
+ reader.onload = async (_: any) => {
211
+ const lc2 = `${lc}[reader.onload]`;
212
+ try {
213
+ if (logalot) { console.log(`${lc2} starting... (I: 1e948476ca86b328a12700dc57be0a22)`); }
214
+ if (!reader.result) { throw new Error(`(UNEXPECTED) reader.result falsy but onload fired? (E: fdac6638fe6e2db3de1ac277bc29dc23)`); }
215
+ let imageBase64 = reader.result.toString().split('base64,')[1];
216
+ let binHash = await hash({ s: imageBase64 });
217
+ const filenameWithExt = file.name;
218
+ const filenamePieces = filenameWithExt.split('.');
219
+ const filename = filenamePieces.slice(0, filenamePieces.length - 1).join('.');
220
+ const ext = filenamePieces.slice(filenamePieces.length - 1)[0];
221
+ if (ext.includes(IBGIB_DELIMITER)) {
222
+ throw new Error(`file extension cannot contain the character ${IBGIB_DELIMITER} (E: f5bc9ef79f7efe01cd53abd49d9f6122)`);
223
+ }
224
+
225
+ await delay(32); // slight doProcesses UI thread hack - not sure how much it helps (if any)
226
+ const resCreate = await createPicAndBinIbGibs({
227
+ imageBase64, binHash, filename, ext, saveInSpace, space,
228
+ });
229
+ resolve(resCreate);
230
+
231
+ } catch (error) {
232
+ console.error(`${lc2} ${error.message}`);
233
+ reject(error);
234
+ } finally {
235
+ if (logalot) { console.log(`${lc2} complete. (I: d88dcaeb874c4f049d51d58655dc2b62)`); }
236
+ }
237
+ };
238
+ reader.readAsDataURL(file);
239
+ });
240
+
241
+ result.push(resSingleCreate);
242
+ }
243
+
244
+ return result;
245
+
246
+ } catch (error) {
247
+ console.error(`${lc} ${error.message}`);
248
+ throw error;
249
+ }
250
+ }
251
+
252
+ export function isPic({
253
+ ibGib,
254
+ }: {
255
+ ibGib: IbGib_V1,
256
+ }): boolean {
257
+ const lc = `[${isPic.name}]`;
258
+ try {
259
+ if (logalot) { console.log(`${lc} starting...`); }
260
+
261
+ if (!ibGib) { throw new Error(`ibGib required (E: 1237b2d4602a3d526f6b159cb6ad0922)`); }
262
+
263
+ const { ib, data, rel8ns } = ibGib;
264
+
265
+ // try rel8ns first
266
+ if (!rel8ns) {
267
+ if (logalot) { console.log(`${lc} rel8ns falsy, not a pic (I: 563a3e779b85b070550581e652e0ca22)`); }
268
+ return false;
269
+ }
270
+
271
+ // descends from pic^gib
272
+ const ancestors = rel8ns.ancestor || [];
273
+ if (ancestors && ancestors.includes('pic^gib')) {
274
+ return true;
275
+ }
276
+
277
+ // has binary qualities and ib contains 'pic'
278
+ if (!data) {
279
+ if (logalot) { console.log(`${lc} data falsy, not a pic (I: 6c05c03cdfca4085aef8f2a19df91690)`); }
280
+ return false;
281
+ }
282
+ if (data.binHash && data.ext && data.filename && ib?.includes('pic')) {
283
+ if (logalot) { console.log(`${lc} has binHash, ext, filename and ib has pic (I: f754b6b023d5379ee770038617edc722)`); }
284
+ return true;
285
+ }
286
+
287
+ if (logalot) { console.log(`${lc} reached end, doesn't have pic qualities. not a pic. (I: 298c5e9a2916445df1cdd22a96f57522)`); }
288
+ return false;
289
+ } catch (error) {
290
+ console.error(`${lc} ${error.message}`);
291
+ throw error;
292
+ } finally {
293
+ if (logalot) { console.log(`${lc} complete.`); }
294
+ }
295
+ }
@@ -0,0 +1,29 @@
1
+ import { IbGibAddr, TransformResult } from '@ibgib/ts-gib';
2
+ import { IbGibRel8ns_V1, IbGib_V1 } from '@ibgib/ts-gib/dist/V1/index.mjs';
3
+ import { BinIbGib_V1 } from '../bin/bin-types.mjs'; // js-doc reference
4
+ import { BINARY_REL8N_NAME } from './pic-constants.mjs';
5
+
6
+
7
+
8
+ /**
9
+ * Data for a pic ibGib
10
+ *
11
+ * @see {@link BinIbGib_V1}
12
+ */
13
+ export interface PicData_V1 {
14
+ binHash: string;
15
+ binHashThumb?: string;
16
+ ext?: string;
17
+ filename: string;
18
+ timestamp: string;
19
+ }
20
+
21
+ export interface PicRel8ns_V1 extends IbGibRel8ns_V1 {
22
+ [BINARY_REL8N_NAME]: IbGibAddr[];
23
+ }
24
+
25
+ export interface PicIbGib_V1 extends IbGib_V1<PicData_V1, PicRel8ns_V1> {
26
+
27
+ }
28
+
29
+ export type UpdatePicPromptResult = [TransformResult<PicIbGib_V1>, TransformResult<BinIbGib_V1>];
@@ -0,0 +1,41 @@
1
+ /**
2
+ * The main roots^gib ibgib uses this rel8n name to keep track of roots.
3
+ *
4
+ * NOTE: This is different than the rel8nName that a root ibgib uses to link to its ibgibs!
5
+ * {@link DEFAULT_ROOT_REL8N_NAME}
6
+ */
7
+ export const ROOT_REL8N_NAME = 'root';
8
+
9
+ /**
10
+ * rel8n name used inside the root to those ibgib it contains. (root.rel8ns.x = [pic1^gib, comment2^gib, ...])
11
+ *
12
+ *
13
+ * NOTE: This is different than the rel8nName 'root' that the roots^gib uses. (roots.rel8ns.root = [root1^gib, root2^gib, ...])
14
+ * {@link ROOT_REL8N_NAME}
15
+ *
16
+ * @example
17
+ * ```json
18
+ * {
19
+ * ib: root,
20
+ * gib: ABC123,
21
+ * data: {...},
22
+ * rel8ns: {
23
+ * [rel8nName]: ["a^1", "b^2"]
24
+ * }
25
+ * }
26
+ * ```
27
+ */
28
+ export const DEFAULT_ROOT_REL8N_NAME = 'x';
29
+
30
+ /**
31
+ *
32
+ */
33
+ export const DEFAULT_ROOT_TEXT = 'root';
34
+ /**
35
+ * Default icon specifically for roots.
36
+ */
37
+ export const DEFAULT_ROOT_ICON = 'analytics-outline';
38
+ /**
39
+ * Default description specifically for roots.
40
+ */
41
+ export const DEFAULT_ROOT_DESCRIPTION = 'This is a root ibgib, which is basically like a root folder that is primarily responsible for "containing" other ibgibs.';
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Should be refactored to be V1 as other data types.
3
+ */
4
+ export interface RootData {
5
+ text: string;
6
+ icon?: string;
7
+ description?: string;
8
+ }
@@ -0,0 +1,34 @@
1
+ // export const TAGS_IB = 'tags';
2
+ // export const TAGS_IBGIB_ADDR = `${TAGS_IB}^${GIB}`;
3
+ // export const TAGS_IBGIB_ADDR_KEY = `key ${TAGS_IBGIB_ADDR}`;
4
+
5
+ /**
6
+ * The main tags^gib ibgib uses this rel8n name to keep track of tags.
7
+ */
8
+ export const TAG_REL8N_NAME = 'tag';
9
+
10
+ /**
11
+ * A tag ibGib uses this rel8n name for the ibgibs that it targets.
12
+ */
13
+ export const TAGGED_REL8N_NAME = 'target';
14
+
15
+
16
+ export const ILLEGAL_TAG_TEXT_CHARS = [
17
+ '^', '?', '/', '\\', `|`,
18
+ ];
19
+
20
+ export const ILLEGAL_TAG_DESC_CHARS = [
21
+ '^',
22
+ ];
23
+
24
+ /**
25
+ * Default icon when creating a tag.
26
+ */
27
+ export const DEFAULT_TAG_ICON = 'pricetag-outline';
28
+ /**
29
+ * Default description when creating a tag.
30
+ */
31
+ export const DEFAULT_TAG_DESCRIPTION = 'This is a tag used for organizing data.';
32
+
33
+ export const TAG_TEXT_REGEXP = /^\w[\w .\-?!]{1,30}[\w.?!]$/;
34
+ export const TAG_TEXT_REGEXP_DESCRIPTION = `tag text must start and end with an alphanumeric, and can contain a hyphen, question mark, dot or space.`;
@@ -0,0 +1,19 @@
1
+ import { IbGibAddr } from '@ibgib/ts-gib';
2
+ import { IbGibRel8ns_V1, IbGib_V1 } from '@ibgib/ts-gib/dist/V1/index.mjs';
3
+ import { TAG_REL8N_NAME } from './tag-constants.mjs';
4
+
5
+
6
+
7
+ export interface TagData_V1 {
8
+ text: string;
9
+ icon?: string;
10
+ description?: string;
11
+ }
12
+
13
+ export interface TagRel8ns_V1 extends IbGibRel8ns_V1 {
14
+ [TAG_REL8N_NAME]?: IbGibAddr[];
15
+ }
16
+
17
+ export interface TagIbGib_V1 extends IbGib_V1<TagData_V1, TagRel8ns_V1> {
18
+
19
+ }