@hashgraphonline/standards-sdk 0.1.143-feat-solana-register.canary.1c6f446.78 → 0.1.144-feat-solana-register.canary.d5edcec.80

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 (340) hide show
  1. package/dist/cjs/hcs-10/sdk.d.ts.map +1 -1
  2. package/dist/cjs/hcs-14/issuers/hiero.d.ts.map +1 -1
  3. package/dist/cjs/index.d.ts.map +1 -1
  4. package/dist/cjs/services/registry-broker/schemas.d.ts +153 -153
  5. package/dist/cjs/standards-sdk.cjs +2 -2
  6. package/dist/cjs/standards-sdk.cjs.map +1 -1
  7. package/dist/cjs/utils/dynamic-import.d.ts +5 -1
  8. package/dist/cjs/utils/dynamic-import.d.ts.map +1 -1
  9. package/dist/es/hcs-10/sdk.d.ts.map +1 -1
  10. package/dist/es/hcs-14/issuers/hiero.d.ts.map +1 -1
  11. package/dist/es/index.d.ts.map +1 -1
  12. package/dist/es/services/registry-broker/schemas.d.ts +153 -153
  13. package/dist/es/standards-sdk.es.js +134 -135
  14. package/dist/es/standards-sdk.es.js.map +1 -1
  15. package/dist/es/standards-sdk.es10.js +70 -90
  16. package/dist/es/standards-sdk.es10.js.map +1 -1
  17. package/dist/es/standards-sdk.es100.js +229 -27
  18. package/dist/es/standards-sdk.es100.js.map +1 -1
  19. package/dist/es/standards-sdk.es101.js +109 -228
  20. package/dist/es/standards-sdk.es101.js.map +1 -1
  21. package/dist/es/standards-sdk.es102.js +15 -94
  22. package/dist/es/standards-sdk.es102.js.map +1 -1
  23. package/dist/es/standards-sdk.es103.js +80 -30
  24. package/dist/es/standards-sdk.es103.js.map +1 -1
  25. package/dist/es/standards-sdk.es104.js +27 -80
  26. package/dist/es/standards-sdk.es104.js.map +1 -1
  27. package/dist/es/standards-sdk.es105.js +136 -25
  28. package/dist/es/standards-sdk.es105.js.map +1 -1
  29. package/dist/es/standards-sdk.es106.js +27 -140
  30. package/dist/es/standards-sdk.es106.js.map +1 -1
  31. package/dist/es/standards-sdk.es107.js +20 -27
  32. package/dist/es/standards-sdk.es107.js.map +1 -1
  33. package/dist/es/standards-sdk.es108.js +156 -18
  34. package/dist/es/standards-sdk.es108.js.map +1 -1
  35. package/dist/es/standards-sdk.es109.js +198 -148
  36. package/dist/es/standards-sdk.es109.js.map +1 -1
  37. package/dist/es/standards-sdk.es11.js +121 -45
  38. package/dist/es/standards-sdk.es11.js.map +1 -1
  39. package/dist/es/standards-sdk.es110.js +747 -167
  40. package/dist/es/standards-sdk.es110.js.map +1 -1
  41. package/dist/es/standards-sdk.es111.js +9 -786
  42. package/dist/es/standards-sdk.es111.js.map +1 -1
  43. package/dist/es/standards-sdk.es112.js +567 -13
  44. package/dist/es/standards-sdk.es112.js.map +1 -1
  45. package/dist/es/standards-sdk.es113.js +576 -541
  46. package/dist/es/standards-sdk.es113.js.map +1 -1
  47. package/dist/es/standards-sdk.es114.js +12 -601
  48. package/dist/es/standards-sdk.es114.js.map +1 -1
  49. package/dist/es/standards-sdk.es115.js +2 -13
  50. package/dist/es/standards-sdk.es115.js.map +1 -1
  51. package/dist/es/standards-sdk.es116.js +87 -2
  52. package/dist/es/standards-sdk.es116.js.map +1 -1
  53. package/dist/es/standards-sdk.es117.js +37 -84
  54. package/dist/es/standards-sdk.es117.js.map +1 -1
  55. package/dist/es/standards-sdk.es118.js +2 -40
  56. package/dist/es/standards-sdk.es118.js.map +1 -1
  57. package/dist/es/standards-sdk.es119.js +231 -2
  58. package/dist/es/standards-sdk.es119.js.map +1 -1
  59. package/dist/es/standards-sdk.es12.js +60 -159
  60. package/dist/es/standards-sdk.es12.js.map +1 -1
  61. package/dist/es/standards-sdk.es120.js +1110 -201
  62. package/dist/es/standards-sdk.es120.js.map +1 -1
  63. package/dist/es/standards-sdk.es121.js +225 -1059
  64. package/dist/es/standards-sdk.es121.js.map +1 -1
  65. package/dist/es/standards-sdk.es122.js +419 -303
  66. package/dist/es/standards-sdk.es122.js.map +1 -1
  67. package/dist/es/standards-sdk.es123.js +351 -418
  68. package/dist/es/standards-sdk.es123.js.map +1 -1
  69. package/dist/es/standards-sdk.es124.js +872 -347
  70. package/dist/es/standards-sdk.es124.js.map +1 -1
  71. package/dist/es/standards-sdk.es125.js +182 -854
  72. package/dist/es/standards-sdk.es125.js.map +1 -1
  73. package/dist/es/standards-sdk.es126.js +1512 -153
  74. package/dist/es/standards-sdk.es126.js.map +1 -1
  75. package/dist/es/standards-sdk.es127.js +157 -1547
  76. package/dist/es/standards-sdk.es127.js.map +1 -1
  77. package/dist/es/standards-sdk.es128.js +192 -162
  78. package/dist/es/standards-sdk.es128.js.map +1 -1
  79. package/dist/es/standards-sdk.es129.js +61 -164
  80. package/dist/es/standards-sdk.es129.js.map +1 -1
  81. package/dist/es/standards-sdk.es13.js +200 -60
  82. package/dist/es/standards-sdk.es13.js.map +1 -1
  83. package/dist/es/standards-sdk.es130.js +102 -85
  84. package/dist/es/standards-sdk.es130.js.map +1 -1
  85. package/dist/es/standards-sdk.es131.js +222 -96
  86. package/dist/es/standards-sdk.es131.js.map +1 -1
  87. package/dist/es/standards-sdk.es132.js +153 -220
  88. package/dist/es/standards-sdk.es132.js.map +1 -1
  89. package/dist/es/standards-sdk.es133.js +104 -162
  90. package/dist/es/standards-sdk.es133.js.map +1 -1
  91. package/dist/es/standards-sdk.es134.js +296 -92
  92. package/dist/es/standards-sdk.es134.js.map +1 -1
  93. package/dist/es/standards-sdk.es135.js +432 -294
  94. package/dist/es/standards-sdk.es135.js.map +1 -1
  95. package/dist/es/standards-sdk.es136.js +14 -461
  96. package/dist/es/standards-sdk.es136.js.map +1 -1
  97. package/dist/es/standards-sdk.es137.js +79 -15
  98. package/dist/es/standards-sdk.es137.js.map +1 -1
  99. package/dist/es/standards-sdk.es138.js +77 -71
  100. package/dist/es/standards-sdk.es138.js.map +1 -1
  101. package/dist/es/standards-sdk.es139.js +152 -80
  102. package/dist/es/standards-sdk.es139.js.map +1 -1
  103. package/dist/es/standards-sdk.es14.js +149 -178
  104. package/dist/es/standards-sdk.es14.js.map +1 -1
  105. package/dist/es/standards-sdk.es140.js +7 -159
  106. package/dist/es/standards-sdk.es140.js.map +1 -1
  107. package/dist/es/standards-sdk.es141.js +86 -7
  108. package/dist/es/standards-sdk.es141.js.map +1 -1
  109. package/dist/es/standards-sdk.es142.js +44 -65
  110. package/dist/es/standards-sdk.es142.js.map +1 -1
  111. package/dist/es/standards-sdk.es143.js +30 -65
  112. package/dist/es/standards-sdk.es143.js.map +1 -1
  113. package/dist/es/standards-sdk.es144.js +34 -30
  114. package/dist/es/standards-sdk.es144.js.map +1 -1
  115. package/dist/es/standards-sdk.es145.js +28 -34
  116. package/dist/es/standards-sdk.es145.js.map +1 -1
  117. package/dist/es/standards-sdk.es146.js +138 -28
  118. package/dist/es/standards-sdk.es146.js.map +1 -1
  119. package/dist/es/standards-sdk.es147.js +37 -133
  120. package/dist/es/standards-sdk.es147.js.map +1 -1
  121. package/dist/es/standards-sdk.es148.js +12280 -33
  122. package/dist/es/standards-sdk.es148.js.map +1 -1
  123. package/dist/es/standards-sdk.es149.js +1 -1
  124. package/dist/es/standards-sdk.es15.js +152 -151
  125. package/dist/es/standards-sdk.es15.js.map +1 -1
  126. package/dist/es/standards-sdk.es150.js +12 -12284
  127. package/dist/es/standards-sdk.es150.js.map +1 -1
  128. package/dist/es/standards-sdk.es151.js +54 -15
  129. package/dist/es/standards-sdk.es151.js.map +1 -1
  130. package/dist/es/standards-sdk.es152.js +72 -160
  131. package/dist/es/standards-sdk.es152.js.map +1 -1
  132. package/dist/es/standards-sdk.es153.js +139 -289
  133. package/dist/es/standards-sdk.es153.js.map +1 -1
  134. package/dist/es/standards-sdk.es154.js +274 -298
  135. package/dist/es/standards-sdk.es154.js.map +1 -1
  136. package/dist/es/standards-sdk.es155.js +262 -369
  137. package/dist/es/standards-sdk.es155.js.map +1 -1
  138. package/dist/es/standards-sdk.es156.js +316 -194
  139. package/dist/es/standards-sdk.es156.js.map +1 -1
  140. package/dist/es/standards-sdk.es157.js +319 -64
  141. package/dist/es/standards-sdk.es157.js.map +1 -1
  142. package/dist/es/standards-sdk.es158.js +69 -49
  143. package/dist/es/standards-sdk.es158.js.map +1 -1
  144. package/dist/es/standards-sdk.es159.js +222 -65
  145. package/dist/es/standards-sdk.es159.js.map +1 -1
  146. package/dist/es/standards-sdk.es16.js +917 -136
  147. package/dist/es/standards-sdk.es16.js.map +1 -1
  148. package/dist/es/standards-sdk.es160.js +223 -218
  149. package/dist/es/standards-sdk.es160.js.map +1 -1
  150. package/dist/es/standards-sdk.es17.js +23 -948
  151. package/dist/es/standards-sdk.es17.js.map +1 -1
  152. package/dist/es/standards-sdk.es18.js +2422 -24
  153. package/dist/es/standards-sdk.es18.js.map +1 -1
  154. package/dist/es/standards-sdk.es19.js +818 -2092
  155. package/dist/es/standards-sdk.es19.js.map +1 -1
  156. package/dist/es/standards-sdk.es2.js +654 -189
  157. package/dist/es/standards-sdk.es2.js.map +1 -1
  158. package/dist/es/standards-sdk.es20.js +205 -1092
  159. package/dist/es/standards-sdk.es20.js.map +1 -1
  160. package/dist/es/standards-sdk.es21.js +858 -221
  161. package/dist/es/standards-sdk.es21.js.map +1 -1
  162. package/dist/es/standards-sdk.es22.js +179 -903
  163. package/dist/es/standards-sdk.es22.js.map +1 -1
  164. package/dist/es/standards-sdk.es23.js +164 -179
  165. package/dist/es/standards-sdk.es23.js.map +1 -1
  166. package/dist/es/standards-sdk.es24.js +62 -118
  167. package/dist/es/standards-sdk.es24.js.map +1 -1
  168. package/dist/es/standards-sdk.es25.js +377 -57
  169. package/dist/es/standards-sdk.es25.js.map +1 -1
  170. package/dist/es/standards-sdk.es26.js +36 -394
  171. package/dist/es/standards-sdk.es26.js.map +1 -1
  172. package/dist/es/standards-sdk.es27.js +901 -50
  173. package/dist/es/standards-sdk.es27.js.map +1 -1
  174. package/dist/es/standards-sdk.es28.js +134 -922
  175. package/dist/es/standards-sdk.es28.js.map +1 -1
  176. package/dist/es/standards-sdk.es29.js +7 -134
  177. package/dist/es/standards-sdk.es29.js.map +1 -1
  178. package/dist/es/standards-sdk.es3.js +63 -680
  179. package/dist/es/standards-sdk.es3.js.map +1 -1
  180. package/dist/es/standards-sdk.es30.js +344 -7
  181. package/dist/es/standards-sdk.es30.js.map +1 -1
  182. package/dist/es/standards-sdk.es31.js +302 -287
  183. package/dist/es/standards-sdk.es31.js.map +1 -1
  184. package/dist/es/standards-sdk.es32.js +94 -322
  185. package/dist/es/standards-sdk.es32.js.map +1 -1
  186. package/dist/es/standards-sdk.es33.js +458 -101
  187. package/dist/es/standards-sdk.es33.js.map +1 -1
  188. package/dist/es/standards-sdk.es34.js +132 -451
  189. package/dist/es/standards-sdk.es34.js.map +1 -1
  190. package/dist/es/standards-sdk.es35.js +216 -130
  191. package/dist/es/standards-sdk.es35.js.map +1 -1
  192. package/dist/es/standards-sdk.es36.js +273 -196
  193. package/dist/es/standards-sdk.es36.js.map +1 -1
  194. package/dist/es/standards-sdk.es37.js +148 -87
  195. package/dist/es/standards-sdk.es37.js.map +1 -1
  196. package/dist/es/standards-sdk.es38.js +183 -320
  197. package/dist/es/standards-sdk.es38.js.map +1 -1
  198. package/dist/es/standards-sdk.es39.js +238 -161
  199. package/dist/es/standards-sdk.es39.js.map +1 -1
  200. package/dist/es/standards-sdk.es4.js +425 -63
  201. package/dist/es/standards-sdk.es4.js.map +1 -1
  202. package/dist/es/standards-sdk.es40.js +136 -254
  203. package/dist/es/standards-sdk.es40.js.map +1 -1
  204. package/dist/es/standards-sdk.es41.js +225 -176
  205. package/dist/es/standards-sdk.es41.js.map +1 -1
  206. package/dist/es/standards-sdk.es42.js +199 -261
  207. package/dist/es/standards-sdk.es42.js.map +1 -1
  208. package/dist/es/standards-sdk.es43.js +237 -199
  209. package/dist/es/standards-sdk.es43.js.map +1 -1
  210. package/dist/es/standards-sdk.es44.js +209 -201
  211. package/dist/es/standards-sdk.es44.js.map +1 -1
  212. package/dist/es/standards-sdk.es45.js +305 -201
  213. package/dist/es/standards-sdk.es45.js.map +1 -1
  214. package/dist/es/standards-sdk.es46.js +371 -261
  215. package/dist/es/standards-sdk.es46.js.map +1 -1
  216. package/dist/es/standards-sdk.es47.js +316 -372
  217. package/dist/es/standards-sdk.es47.js.map +1 -1
  218. package/dist/es/standards-sdk.es48.js +404 -336
  219. package/dist/es/standards-sdk.es48.js.map +1 -1
  220. package/dist/es/standards-sdk.es49.js +83 -449
  221. package/dist/es/standards-sdk.es49.js.map +1 -1
  222. package/dist/es/standards-sdk.es5.js +232 -354
  223. package/dist/es/standards-sdk.es5.js.map +1 -1
  224. package/dist/es/standards-sdk.es50.js +179 -89
  225. package/dist/es/standards-sdk.es50.js.map +1 -1
  226. package/dist/es/standards-sdk.es51.js +231 -165
  227. package/dist/es/standards-sdk.es51.js.map +1 -1
  228. package/dist/es/standards-sdk.es52.js +25 -262
  229. package/dist/es/standards-sdk.es52.js.map +1 -1
  230. package/dist/es/standards-sdk.es53.js +56 -26
  231. package/dist/es/standards-sdk.es53.js.map +1 -1
  232. package/dist/es/standards-sdk.es54.js +12 -57
  233. package/dist/es/standards-sdk.es54.js.map +1 -1
  234. package/dist/es/standards-sdk.es55.js +49 -12
  235. package/dist/es/standards-sdk.es55.js.map +1 -1
  236. package/dist/es/standards-sdk.es56.js +115 -43
  237. package/dist/es/standards-sdk.es56.js.map +1 -1
  238. package/dist/es/standards-sdk.es57.js +42 -115
  239. package/dist/es/standards-sdk.es57.js.map +1 -1
  240. package/dist/es/standards-sdk.es58.js +52 -43
  241. package/dist/es/standards-sdk.es58.js.map +1 -1
  242. package/dist/es/standards-sdk.es59.js +36 -50
  243. package/dist/es/standards-sdk.es59.js.map +1 -1
  244. package/dist/es/standards-sdk.es6.js +125 -246
  245. package/dist/es/standards-sdk.es6.js.map +1 -1
  246. package/dist/es/standards-sdk.es60.js +207 -39
  247. package/dist/es/standards-sdk.es60.js.map +1 -1
  248. package/dist/es/standards-sdk.es61.js +24 -201
  249. package/dist/es/standards-sdk.es61.js.map +1 -1
  250. package/dist/es/standards-sdk.es62.js +87 -25
  251. package/dist/es/standards-sdk.es62.js.map +1 -1
  252. package/dist/es/standards-sdk.es63.js +3 -51
  253. package/dist/es/standards-sdk.es63.js.map +1 -1
  254. package/dist/es/standards-sdk.es64.js +100 -3
  255. package/dist/es/standards-sdk.es64.js.map +1 -1
  256. package/dist/es/standards-sdk.es65.js +61 -62
  257. package/dist/es/standards-sdk.es65.js.map +1 -1
  258. package/dist/es/standards-sdk.es66.js +17 -98
  259. package/dist/es/standards-sdk.es66.js.map +1 -1
  260. package/dist/es/standards-sdk.es67.js +77 -19
  261. package/dist/es/standards-sdk.es67.js.map +1 -1
  262. package/dist/es/standards-sdk.es68.js +458 -77
  263. package/dist/es/standards-sdk.es68.js.map +1 -1
  264. package/dist/es/standards-sdk.es69.js +106 -240
  265. package/dist/es/standards-sdk.es69.js.map +1 -1
  266. package/dist/es/standards-sdk.es7.js +28 -183
  267. package/dist/es/standards-sdk.es7.js.map +1 -1
  268. package/dist/es/standards-sdk.es70.js +170 -286
  269. package/dist/es/standards-sdk.es70.js.map +1 -1
  270. package/dist/es/standards-sdk.es71.js +71 -207
  271. package/dist/es/standards-sdk.es71.js.map +1 -1
  272. package/dist/es/standards-sdk.es72.js +71 -72
  273. package/dist/es/standards-sdk.es72.js.map +1 -1
  274. package/dist/es/standards-sdk.es73.js +143 -71
  275. package/dist/es/standards-sdk.es73.js.map +1 -1
  276. package/dist/es/standards-sdk.es74.js +62 -136
  277. package/dist/es/standards-sdk.es74.js.map +1 -1
  278. package/dist/es/standards-sdk.es75.js +380 -45
  279. package/dist/es/standards-sdk.es75.js.map +1 -1
  280. package/dist/es/standards-sdk.es76.js +222 -130
  281. package/dist/es/standards-sdk.es76.js.map +1 -1
  282. package/dist/es/standards-sdk.es77.js +320 -444
  283. package/dist/es/standards-sdk.es77.js.map +1 -1
  284. package/dist/es/standards-sdk.es78.js +88 -371
  285. package/dist/es/standards-sdk.es78.js.map +1 -1
  286. package/dist/es/standards-sdk.es79.js +125 -89
  287. package/dist/es/standards-sdk.es79.js.map +1 -1
  288. package/dist/es/standards-sdk.es8.js +80 -29
  289. package/dist/es/standards-sdk.es8.js.map +1 -1
  290. package/dist/es/standards-sdk.es80.js +8 -125
  291. package/dist/es/standards-sdk.es80.js.map +1 -1
  292. package/dist/es/standards-sdk.es81.js +45 -6
  293. package/dist/es/standards-sdk.es81.js.map +1 -1
  294. package/dist/es/standards-sdk.es82.js +98 -44
  295. package/dist/es/standards-sdk.es82.js.map +1 -1
  296. package/dist/es/standards-sdk.es83.js +331 -84
  297. package/dist/es/standards-sdk.es83.js.map +1 -1
  298. package/dist/es/standards-sdk.es84.js +93 -160
  299. package/dist/es/standards-sdk.es84.js.map +1 -1
  300. package/dist/es/standards-sdk.es85.js +55 -275
  301. package/dist/es/standards-sdk.es85.js.map +1 -1
  302. package/dist/es/standards-sdk.es86.js +43 -55
  303. package/dist/es/standards-sdk.es86.js.map +1 -1
  304. package/dist/es/standards-sdk.es87.js +145 -44
  305. package/dist/es/standards-sdk.es87.js.map +1 -1
  306. package/dist/es/standards-sdk.es88.js +30 -113
  307. package/dist/es/standards-sdk.es88.js.map +1 -1
  308. package/dist/es/standards-sdk.es89.js +22 -59
  309. package/dist/es/standards-sdk.es89.js.map +1 -1
  310. package/dist/es/standards-sdk.es9.js +104 -80
  311. package/dist/es/standards-sdk.es9.js.map +1 -1
  312. package/dist/es/standards-sdk.es90.js +23 -28
  313. package/dist/es/standards-sdk.es90.js.map +1 -1
  314. package/dist/es/standards-sdk.es91.js +238 -23
  315. package/dist/es/standards-sdk.es91.js.map +1 -1
  316. package/dist/es/standards-sdk.es92.js +267 -225
  317. package/dist/es/standards-sdk.es92.js.map +1 -1
  318. package/dist/es/standards-sdk.es93.js +95 -220
  319. package/dist/es/standards-sdk.es93.js.map +1 -1
  320. package/dist/es/standards-sdk.es94.js +124 -136
  321. package/dist/es/standards-sdk.es94.js.map +1 -1
  322. package/dist/es/standards-sdk.es95.js +42 -138
  323. package/dist/es/standards-sdk.es95.js.map +1 -1
  324. package/dist/es/standards-sdk.es96.js +259 -43
  325. package/dist/es/standards-sdk.es96.js.map +1 -1
  326. package/dist/es/standards-sdk.es97.js +82 -245
  327. package/dist/es/standards-sdk.es97.js.map +1 -1
  328. package/dist/es/standards-sdk.es98.js +49 -50
  329. package/dist/es/standards-sdk.es98.js.map +1 -1
  330. package/dist/es/standards-sdk.es99.js +29 -100
  331. package/dist/es/standards-sdk.es99.js.map +1 -1
  332. package/dist/es/utils/dynamic-import.d.ts +5 -1
  333. package/dist/es/utils/dynamic-import.d.ts.map +1 -1
  334. package/package.json +4 -4
  335. package/dist/cjs/patches/topic-autorenew-patch.d.ts +0 -2
  336. package/dist/cjs/patches/topic-autorenew-patch.d.ts.map +0 -1
  337. package/dist/es/patches/topic-autorenew-patch.d.ts +0 -2
  338. package/dist/es/patches/topic-autorenew-patch.d.ts.map +0 -1
  339. package/dist/es/standards-sdk.es161.js +0 -247
  340. package/dist/es/standards-sdk.es161.js.map +0 -1
@@ -1,220 +1,685 @@
1
- const accountIdPattern = /^\d+\.\d+\.\d+$/u;
2
- const prototypeMarker = Symbol.for("standards-sdk.topic-auto-renew.patch");
3
- const accountMarker = Symbol.for("standards-sdk.account-id.patch");
4
- const nodeRequire = getNodeRequire();
5
- if (nodeRequire) {
6
- bootstrap(nodeRequire);
7
- } else {
8
- Reflect.set(globalThis, "__standardsSdkTopicAutoRenewPatched", false);
9
- }
10
- function bootstrap(requireFn) {
11
- const accountModule = safeRequire(
12
- requireFn,
13
- "@hashgraph/sdk/lib/account/AccountId.cjs"
14
- );
15
- const topicModule = safeRequire(
16
- requireFn,
17
- "@hashgraph/sdk/lib/topic/TopicCreateTransaction.cjs"
18
- );
19
- const sdkModule = safeRequire(requireFn, "@hashgraph/sdk");
20
- const candidates = [];
21
- if (accountModule?.default && topicModule?.default) {
22
- candidates.push({
23
- accountId: accountModule.default,
24
- topic: topicModule.default
25
- });
1
+ import { Logger } from "./standards-sdk.es105.js";
2
+ import { sleep } from "./standards-sdk.es115.js";
3
+ class HCS {
4
+ constructor() {
5
+ this.modelViewerLoaded = false;
6
+ this.modelViewerLoading = null;
7
+ this.config = {
8
+ cdnUrl: "https://kiloscribe.com/api/inscription-cdn/",
9
+ network: "mainnet",
10
+ retryAttempts: 3,
11
+ retryBackoff: 300,
12
+ debug: false,
13
+ showLoadingIndicator: false,
14
+ loadingCallbackName: null
15
+ };
16
+ this.configMapping = {
17
+ hcsCdnUrl: "cdnUrl",
18
+ hcsNetwork: "network",
19
+ hcsRetryAttempts: "retryAttempts",
20
+ hcsRetryBackoff: "retryBackoff",
21
+ hcsDebug: "debug",
22
+ hcsShowLoadingIndicator: "showLoadingIndicator",
23
+ hcsLoadingCallbackName: "loadingCallbackName"
24
+ };
25
+ this.LoadedScripts = {};
26
+ this.LoadedWasm = {};
27
+ this.LoadedImages = {};
28
+ this.LoadedVideos = {};
29
+ this.LoadedAudios = {};
30
+ this.LoadedAudioUrls = {};
31
+ this.LoadedGLBs = {};
32
+ this.scriptLoadedEvent = new Event("HCSScriptLoaded");
33
+ this.loadQueue = [];
34
+ this.isProcessingQueue = false;
35
+ try {
36
+ this.logger = Logger.getInstance({
37
+ module: "HCS-3",
38
+ level: this.config.debug ? "debug" : "error"
39
+ });
40
+ } catch (e) {
41
+ this.logger = this.createFallbackLogger();
42
+ }
26
43
  }
27
- if (sdkModule) {
28
- candidates.push({
29
- accountId: sdkModule.AccountId ?? sdkModule.default?.AccountId,
30
- topic: sdkModule.TopicCreateTransaction ?? sdkModule.default?.TopicCreateTransaction
31
- });
44
+ createFallbackLogger() {
45
+ const fallbackLogger = {
46
+ debug: (...args) => this.config.debug && console.debug("[HCS-3]", ...args),
47
+ info: (...args) => this.config.debug && console.info("[HCS-3]", ...args),
48
+ warn: (...args) => console.warn("[HCS-3]", ...args),
49
+ error: (...args) => console.error("[HCS-3]", ...args),
50
+ setLogLevel: (level) => {
51
+ this.config.debug = level === "debug";
52
+ }
53
+ };
54
+ return fallbackLogger;
32
55
  }
33
- for (const candidate of candidates) {
34
- patchTopicModule(candidate.topic, candidate.accountId);
56
+ log(...args) {
57
+ if (args.length === 0) {
58
+ this.logger.debug("");
59
+ } else if (args.length === 1) {
60
+ this.logger.debug(String(args[0]));
61
+ } else {
62
+ const message = String(args[0]);
63
+ const data = args.slice(1);
64
+ this.logger.debug(message, data);
65
+ }
35
66
  }
36
- Reflect.set(globalThis, "__standardsSdkTopicAutoRenewPatched", true);
37
- }
38
- function getNodeRequire() {
39
- const moduleConstructor = getModuleConstructor();
40
- if (moduleConstructor?.createRequire) {
41
- try {
42
- return moduleConstructor.createRequire(import.meta.url);
43
- } catch {
44
- return null;
67
+ error(...args) {
68
+ if (args.length === 0) {
69
+ this.logger.error("");
70
+ } else if (args.length === 1) {
71
+ this.logger.error(String(args[0]));
72
+ } else {
73
+ const message = String(args[0]);
74
+ const data = args.slice(1);
75
+ this.logger.error(message, data);
45
76
  }
46
77
  }
47
- if (typeof require === "function") {
48
- return require;
78
+ loadConfigFromHTML() {
79
+ const configScript = document.querySelector(
80
+ "script[data-hcs-config]"
81
+ );
82
+ if (configScript) {
83
+ Object.keys(this.configMapping).forEach((dataAttr) => {
84
+ if (configScript.dataset[dataAttr]) {
85
+ const configKey = this.configMapping[dataAttr];
86
+ let value = configScript.dataset[dataAttr];
87
+ if (value === "true") value = true;
88
+ if (value === "false") value = false;
89
+ if (!isNaN(Number(value)) && value !== "") value = Number(value);
90
+ this.config[configKey] = value;
91
+ }
92
+ });
93
+ this.logger.setLogLevel(this.config.debug ? "debug" : "error");
94
+ }
95
+ this.log("Loaded config:", this.config);
49
96
  }
50
- return null;
51
- }
52
- function getModuleConstructor() {
53
- try {
54
- if (typeof module !== "undefined" && module?.createRequire) {
55
- return module;
97
+ updateLoadingStatus(id, status) {
98
+ if (this.LoadedScripts[id] === "loaded") {
99
+ return;
100
+ }
101
+ if (this.config.showLoadingIndicator) {
102
+ console.log("[HCS Loading] " + id + " : " + status);
103
+ }
104
+ this.LoadedScripts[id] = status;
105
+ if (this.config.loadingCallbackName && typeof window[this.config.loadingCallbackName] === "function") {
106
+ const callback = window[this.config.loadingCallbackName];
107
+ if (typeof callback === "function") {
108
+ callback(id, status);
109
+ }
56
110
  }
57
- } catch {
58
111
  }
59
- try {
60
- if (typeof require === "function") {
61
- const requiredModule = require("module");
62
- if (requiredModule?.createRequire) {
63
- return requiredModule;
112
+ async fetchWithRetry(url, retries = this.config.retryAttempts, backoff = this.config.retryBackoff) {
113
+ try {
114
+ const response = await fetch(url);
115
+ if (!response.ok) {
116
+ throw new Error("HTTP error! status: " + response.status);
117
+ }
118
+ return response;
119
+ } catch (error) {
120
+ if (retries > 0) {
121
+ this.log(
122
+ "Retrying fetch for " + url + " Attempts left: " + (retries - 1)
123
+ );
124
+ await this.sleep(backoff);
125
+ return this.fetchWithRetry(url, retries - 1, backoff * 2);
64
126
  }
127
+ throw error;
65
128
  }
66
- } catch {
67
129
  }
68
- return null;
69
- }
70
- function safeRequire(requireFn, moduleId) {
71
- try {
72
- return requireFn(moduleId);
73
- } catch {
74
- return null;
130
+ sleep(ms) {
131
+ return sleep(ms);
75
132
  }
76
- }
77
- function patchTopicModule(topicCtor, accountCtor) {
78
- if (!topicCtor || !accountCtor) {
79
- return;
80
- }
81
- patchAccountId(accountCtor);
82
- const prototype = topicCtor.prototype;
83
- if (Reflect.get(prototype, prototypeMarker)) {
84
- return;
85
- }
86
- const originalSet = prototype.setAutoRenewAccountId;
87
- const originalFreeze = prototype.freezeWith;
88
- prototype.setAutoRenewAccountId = function setAutoRenewAccountIdPatched(autoRenewAccountId) {
89
- const resolved = resolveAccountId(autoRenewAccountId, accountCtor);
90
- if (resolved) {
91
- requireNotFrozen(this);
92
- this._autoRenewAccountId = resolved;
93
- return this;
94
- }
95
- return originalSet.call(
96
- this,
97
- autoRenewAccountId
133
+ isDuplicate(topicId) {
134
+ return !!this.LoadedScripts[topicId];
135
+ }
136
+ async retrieveHCS1Data(topicId, cdnUrl = this.config.cdnUrl, network = this.config.network) {
137
+ const cleanNetwork = network.replace(/['"]+/g, "");
138
+ const response = await this.fetchWithRetry(
139
+ cdnUrl + topicId + "?network=" + cleanNetwork
98
140
  );
99
- };
100
- prototype.freezeWith = function freezeWithPatched(client) {
101
- if (!this.getAutoRenewAccountId || typeof this.getAutoRenewAccountId !== "function") {
102
- return originalFreeze.call(this, client);
103
- }
104
- const current = this.getAutoRenewAccountId();
105
- if (!current) {
106
- const transactionAccountId = this.transactionId?.accountId;
107
- const operatorAccountId = client?.operatorAccountId;
108
- const resolved = resolveAccountId(transactionAccountId, accountCtor) ?? resolveAccountId(operatorAccountId, accountCtor);
109
- if (resolved) {
110
- this._autoRenewAccountId = resolved;
111
- }
112
- }
113
- return originalFreeze.call(this, client);
114
- };
115
- Reflect.set(prototype, prototypeMarker, true);
116
- }
117
- function patchAccountId(accountCtor) {
118
- if (Reflect.get(accountCtor, accountMarker)) {
119
- return;
120
- }
121
- const originalFromString = accountCtor.fromString.bind(accountCtor);
122
- accountCtor.fromString = function accountIdFromStringPatched(value) {
123
- if (typeof value === "string") {
124
- return originalFromString(value);
125
- }
126
- const extracted = extractAccountIdString(value);
127
- if (extracted) {
128
- return originalFromString(extracted);
129
- }
130
- if (isProtoAccountId(value)) {
131
- const shard = toNumericString(value.shard);
132
- const realm = toNumericString(value.realm);
133
- const num = toNumericString(value.num);
134
- if (shard && realm && num) {
135
- return originalFromString(`${shard}.${realm}.${num}`);
136
- }
137
- }
138
- return originalFromString(value);
139
- };
140
- Reflect.set(accountCtor, accountMarker, true);
141
- }
142
- function resolveAccountId(value, accountCtor) {
143
- if (value instanceof accountCtor) {
144
- return value;
141
+ return await response.blob();
145
142
  }
146
- if (typeof value === "string" && accountIdPattern.test(value)) {
147
- return accountCtor.fromString(value);
143
+ async loadScript(scriptElement) {
144
+ const src = scriptElement.getAttribute("data-src");
145
+ const scriptId = scriptElement.getAttribute("data-script-id");
146
+ const topicId = src?.split("/").pop();
147
+ const type = scriptElement.getAttribute("type");
148
+ const isRequired = scriptElement.hasAttribute("data-required");
149
+ const isModule = scriptElement.getAttribute("type") === "module";
150
+ if (this.isDuplicate(topicId || "")) {
151
+ return;
152
+ }
153
+ this.updateLoadingStatus(scriptId, "loading");
154
+ try {
155
+ const cdnUrl = scriptElement.getAttribute("data-cdn-url") || this.config.cdnUrl;
156
+ const network = scriptElement.getAttribute("data-network") || this.config.network;
157
+ const blob = await this.retrieveHCS1Data(topicId, cdnUrl, network);
158
+ if (type === "wasm") {
159
+ const arrayBuffer = await blob.arrayBuffer();
160
+ const wasmModule = await WebAssembly.compile(arrayBuffer);
161
+ this.LoadedWasm[scriptId] = await WebAssembly.instantiate(wasmModule, {
162
+ env: {},
163
+ ...scriptElement.dataset
164
+ });
165
+ this.updateLoadingStatus(scriptId, "loaded");
166
+ window.dispatchEvent(this.scriptLoadedEvent);
167
+ this.log("Loaded wasm: " + scriptId);
168
+ } else {
169
+ const content = await blob.text();
170
+ const script = document.createElement("script");
171
+ script.textContent = content;
172
+ script.className = "hcs-inline-script";
173
+ if (scriptId) {
174
+ script.setAttribute("data-loaded-script-id", scriptId);
175
+ }
176
+ if (isModule) {
177
+ script.type = "module";
178
+ const moduleBlob = new Blob([content], {
179
+ type: "application/javascript"
180
+ });
181
+ script.src = URL.createObjectURL(moduleBlob);
182
+ }
183
+ document.body.appendChild(script);
184
+ this.updateLoadingStatus(scriptId, "loaded");
185
+ window.dispatchEvent(this.scriptLoadedEvent);
186
+ this.log("Loaded script: " + scriptId);
187
+ script.onerror = (error) => {
188
+ this.error("Failed to load " + type + ": " + scriptId, error);
189
+ this.updateLoadingStatus(scriptId, "failed");
190
+ if (isRequired) {
191
+ throw error;
192
+ }
193
+ };
194
+ }
195
+ } catch (error) {
196
+ this.error("Failed to load " + type + ": " + scriptId, error);
197
+ this.updateLoadingStatus(scriptId, "failed");
198
+ if (isRequired) {
199
+ throw error;
200
+ }
201
+ }
148
202
  }
149
- const normalized = normalizeAutoRenewValue(value);
150
- if (normalized) {
151
- return accountCtor.fromString(normalized);
203
+ async loadModuleExports(scriptId) {
204
+ const script = document.querySelector(
205
+ 'script[data-loaded-script-id="' + scriptId + '"]'
206
+ );
207
+ if (!script) {
208
+ throw new Error("Module script with id " + scriptId + " not found");
209
+ }
210
+ const scriptSrc = script.getAttribute("src");
211
+ if (!scriptSrc) {
212
+ throw new Error("Module script " + scriptId + " has no src attribute");
213
+ }
214
+ try {
215
+ const importModule = new Function("url", "return import(url)");
216
+ return await importModule(scriptSrc);
217
+ } catch (error) {
218
+ this.error("Failed to import module", error);
219
+ throw error;
220
+ }
152
221
  }
153
- return null;
154
- }
155
- function normalizeAutoRenewValue(value) {
156
- if (typeof value === "string" && accountIdPattern.test(value)) {
157
- return value;
222
+ async loadStylesheet(linkElement) {
223
+ const src = linkElement.getAttribute("data-src");
224
+ const stylesheetId = linkElement.getAttribute("data-script-id");
225
+ const topicId = src?.split("/").pop();
226
+ const isRequired = linkElement.hasAttribute("data-required");
227
+ if (this.isDuplicate(topicId || "")) {
228
+ return;
229
+ }
230
+ this.updateLoadingStatus(stylesheetId, "loading");
231
+ try {
232
+ const cdnUrl = linkElement.getAttribute("data-cdn-url") || this.config.cdnUrl;
233
+ const network = linkElement.getAttribute("data-network") || this.config.network;
234
+ const blob = await this.retrieveHCS1Data(topicId, cdnUrl, network);
235
+ const cssContent = await blob.text();
236
+ const style = document.createElement("style");
237
+ style.textContent = cssContent;
238
+ document.head.appendChild(style);
239
+ this.updateLoadingStatus(stylesheetId, "loaded");
240
+ window.dispatchEvent(this.scriptLoadedEvent);
241
+ this.log("Loaded and inlined stylesheet: " + stylesheetId);
242
+ } catch (error) {
243
+ this.error("Failed to load stylesheet: " + stylesheetId, error);
244
+ this.updateLoadingStatus(stylesheetId, "failed");
245
+ if (isRequired) {
246
+ throw error;
247
+ }
248
+ }
158
249
  }
159
- const extracted = extractAccountIdString(value);
160
- if (extracted) {
161
- return extracted;
250
+ async loadImage(imageElement) {
251
+ const src = imageElement.getAttribute("data-src");
252
+ const topicId = src?.split("/").pop();
253
+ this.log("Loading image: " + topicId);
254
+ this.updateLoadingStatus("Image: " + topicId, "loaded");
255
+ try {
256
+ const cdnUrl = imageElement.getAttribute("data-cdn-url") || this.config.cdnUrl;
257
+ const network = imageElement.getAttribute("data-network") || this.config.network;
258
+ const blob = await this.retrieveHCS1Data(topicId, cdnUrl, network);
259
+ const objectURL = URL.createObjectURL(blob);
260
+ imageElement.src = objectURL;
261
+ this.LoadedImages[topicId] = objectURL;
262
+ this.updateLoadingStatus("Image: " + topicId, "loaded");
263
+ this.log("Loaded image: " + topicId);
264
+ } catch (error) {
265
+ this.error("Failed to load image: " + topicId, error);
266
+ this.updateLoadingStatus("Image: " + topicId, "failed");
267
+ }
162
268
  }
163
- if (isProtoAccountId(value)) {
164
- const shard = toNumericString(value.shard);
165
- const realm = toNumericString(value.realm);
166
- const num = toNumericString(value.num);
167
- if (shard && realm && num) {
168
- const composed = `${shard}.${realm}.${num}`;
169
- if (accountIdPattern.test(composed)) {
170
- return composed;
269
+ async loadMedia(mediaElement, mediaType) {
270
+ const src = mediaElement.getAttribute("data-src");
271
+ const topicId = src?.split("/").pop();
272
+ this.log("Loading " + mediaType + ": " + topicId);
273
+ this.updateLoadingStatus(mediaType + ": " + topicId, "loading");
274
+ try {
275
+ const cdnUrl = mediaElement.getAttribute("data-cdn-url") || this.config.cdnUrl;
276
+ const network = mediaElement.getAttribute("data-network") || this.config.network;
277
+ const blob = await this.retrieveHCS1Data(topicId, cdnUrl, network);
278
+ const objectURL = URL.createObjectURL(blob);
279
+ mediaElement.src = objectURL;
280
+ if (mediaType === "video") {
281
+ this.LoadedVideos[topicId] = objectURL;
282
+ } else {
283
+ this.LoadedAudioUrls[topicId] = objectURL;
171
284
  }
285
+ this.updateLoadingStatus(mediaType + ": " + topicId, "loaded");
286
+ this.log("Loaded " + mediaType + ": " + topicId);
287
+ } catch (error) {
288
+ this.error("Failed to load " + mediaType + ": " + topicId, error);
289
+ this.updateLoadingStatus(mediaType + ": " + topicId, "failed");
172
290
  }
173
291
  }
174
- return null;
175
- }
176
- function extractAccountIdString(value) {
177
- if (typeof value !== "object" || value === null) {
178
- return null;
292
+ async loadModelViewer() {
293
+ if (this.modelViewerLoading) return this.modelViewerLoading;
294
+ if (this.modelViewerLoaded) return Promise.resolve();
295
+ this.modelViewerLoading = new Promise((resolve) => {
296
+ const modelViewerScript = document.createElement("script");
297
+ modelViewerScript.setAttribute("data-src", "hcs://1/0.0.7293044");
298
+ modelViewerScript.setAttribute("data-script-id", "model-viewer");
299
+ modelViewerScript.setAttribute("type", "module");
300
+ window.addEventListener(
301
+ "HCSScriptLoaded",
302
+ () => {
303
+ this.modelViewerLoaded = true;
304
+ resolve();
305
+ },
306
+ { once: true }
307
+ );
308
+ this.loadScript(modelViewerScript);
309
+ });
310
+ return this.modelViewerLoading;
179
311
  }
180
- const candidate = value;
181
- const method = candidate.toString;
182
- if (typeof method !== "function") {
183
- return null;
312
+ async loadGLB(glbElement) {
313
+ await this.loadModelViewer();
314
+ const src = glbElement.getAttribute("data-src");
315
+ const topicId = src?.split("/").pop();
316
+ this.log("Loading GLB: " + topicId);
317
+ this.updateLoadingStatus("GLB: " + topicId, "loading");
318
+ try {
319
+ const cdnUrl = glbElement.getAttribute("data-cdn-url") || this.config.cdnUrl;
320
+ const network = glbElement.getAttribute("data-network") || this.config.network;
321
+ let modelViewer;
322
+ if (glbElement.tagName.toLowerCase() !== "model-viewer") {
323
+ modelViewer = document.createElement("model-viewer");
324
+ Array.from(glbElement.attributes).forEach((attr) => {
325
+ modelViewer.setAttribute(attr.name, attr.value);
326
+ });
327
+ modelViewer.setAttribute("camera-controls", "");
328
+ modelViewer.setAttribute("auto-rotate", "");
329
+ modelViewer.setAttribute("ar", "");
330
+ glbElement.parentNode?.replaceChild(modelViewer, glbElement);
331
+ } else {
332
+ modelViewer = glbElement;
333
+ }
334
+ const blob = await this.retrieveHCS1Data(topicId, cdnUrl, network);
335
+ const objectURL = URL.createObjectURL(blob);
336
+ modelViewer.setAttribute("src", objectURL);
337
+ this.LoadedGLBs[topicId] = objectURL;
338
+ this.updateLoadingStatus("GLB: " + topicId, "loaded");
339
+ this.log("Loaded GLB: " + topicId);
340
+ } catch (error) {
341
+ this.error("Failed to load GLB: " + topicId, error);
342
+ this.updateLoadingStatus("GLB: " + topicId, "failed");
343
+ }
184
344
  }
185
- const result = method.call(value);
186
- if (typeof result !== "string") {
187
- return null;
345
+ async loadResource(element, type, order) {
346
+ return new Promise((resolve) => {
347
+ this.loadQueue.push({ element, type, order, resolve });
348
+ this.processQueue();
349
+ });
188
350
  }
189
- return accountIdPattern.test(result) ? result : null;
190
- }
191
- function isProtoAccountId(value) {
192
- if (typeof value !== "object" || value === null) {
193
- return false;
351
+ async processQueue() {
352
+ if (this.isProcessingQueue) return;
353
+ this.isProcessingQueue = true;
354
+ while (this.loadQueue.length > 0) {
355
+ const item = this.loadQueue.shift();
356
+ try {
357
+ if (item.type === "script") {
358
+ await this.loadScript(item.element);
359
+ } else if (item.type === "image") {
360
+ await this.loadImage(item.element);
361
+ } else if (item.type === "video" || item.type === "audio") {
362
+ await this.loadMedia(item.element, item.type);
363
+ } else if (item.type === "glb") {
364
+ await this.loadGLB(item.element);
365
+ } else if (item.type === "css") {
366
+ await this.loadStylesheet(item.element);
367
+ }
368
+ item.resolve();
369
+ } catch (error) {
370
+ this.error("Error processing queue item:", error);
371
+ if (item.type === "script" && item.element.hasAttribute("data-required")) {
372
+ break;
373
+ }
374
+ }
375
+ }
376
+ this.isProcessingQueue = false;
194
377
  }
195
- const candidate = value;
196
- return hasToString(candidate.shard) && hasToString(candidate.realm) && hasToString(candidate.num);
197
- }
198
- function hasToString(value) {
199
- return typeof value === "object" && value !== null && typeof value.toString === "function";
200
- }
201
- function toNumericString(value) {
202
- if (typeof value === "number" && Number.isFinite(value)) {
203
- return String(Math.trunc(value));
378
+ async replaceHCSInStyle(styleContent) {
379
+ let newContent = styleContent;
380
+ let startIndex = newContent.indexOf("hcs://");
381
+ while (startIndex !== -1) {
382
+ let endIndex = startIndex;
383
+ while (endIndex < newContent.length && !["'", '"', " ", ")"].includes(newContent[endIndex])) {
384
+ endIndex++;
385
+ }
386
+ const hcsUrl = newContent.substring(startIndex, endIndex);
387
+ const topicId = hcsUrl.split("/").pop();
388
+ try {
389
+ const cdnUrl = this.config.cdnUrl;
390
+ const network = this.config.network;
391
+ const blob = await this.retrieveHCS1Data(topicId, cdnUrl, network);
392
+ const objectURL = URL.createObjectURL(blob);
393
+ newContent = newContent.substring(0, startIndex) + objectURL + newContent.substring(endIndex);
394
+ this.LoadedImages[topicId] = objectURL;
395
+ this.log("Replaced CSS HCS URL: " + hcsUrl + " with " + objectURL);
396
+ } catch (error) {
397
+ this.error("Failed to load CSS image: " + topicId, error);
398
+ }
399
+ startIndex = newContent.indexOf("hcs://", startIndex + 1);
400
+ }
401
+ return newContent;
204
402
  }
205
- if (typeof value === "bigint") {
206
- return value.toString();
403
+ async processInlineStyles() {
404
+ const elementsWithStyle = document.querySelectorAll('[style*="hcs://"]');
405
+ this.log(
406
+ "Found " + elementsWithStyle.length + " elements with HCS style references"
407
+ );
408
+ for (const element of Array.from(elementsWithStyle)) {
409
+ const style = element.getAttribute("style");
410
+ if (style) {
411
+ this.log("Processing style: " + style);
412
+ const newStyle = await this.replaceHCSInStyle(style);
413
+ if (style !== newStyle) {
414
+ element.setAttribute("style", newStyle);
415
+ this.log("Updated style to: " + newStyle);
416
+ }
417
+ }
418
+ }
419
+ const styleTags = document.querySelectorAll("style");
420
+ for (const styleTag of Array.from(styleTags)) {
421
+ if (styleTag.textContent?.includes("hcs://")) {
422
+ const newContent = await this.replaceHCSInStyle(styleTag.textContent);
423
+ if (styleTag.textContent !== newContent) {
424
+ styleTag.textContent = newContent;
425
+ }
426
+ }
427
+ }
428
+ }
429
+ async init() {
430
+ this.loadConfigFromHTML();
431
+ return new Promise((resolve) => {
432
+ const initializeObserver = async () => {
433
+ const scriptElements = document.querySelectorAll(
434
+ 'script[data-src^="hcs://"]'
435
+ );
436
+ const imageElements = document.querySelectorAll(
437
+ 'img[data-src^="hcs://"], img[src^="hcs://"]'
438
+ );
439
+ const videoElements = document.querySelectorAll(
440
+ 'video[data-src^="hcs://"], video[src^="hcs://"]'
441
+ );
442
+ const audioElements = document.querySelectorAll(
443
+ 'audio[data-src^="hcs://"], audio[src^="hcs://"]'
444
+ );
445
+ const glbElements = document.querySelectorAll(
446
+ 'model-viewer[data-src^="hcs://"]'
447
+ );
448
+ const cssElements = document.querySelectorAll(
449
+ 'link[data-src^="hcs://"]'
450
+ );
451
+ document.querySelectorAll('[src^="hcs://"]').forEach((element) => {
452
+ const src = element.getAttribute("src");
453
+ if (src) {
454
+ element.setAttribute("data-src", src);
455
+ element.removeAttribute("src");
456
+ }
457
+ });
458
+ await this.processInlineStyles();
459
+ const loadPromises = [];
460
+ [
461
+ { elements: scriptElements, type: "script" },
462
+ { elements: imageElements, type: "image" },
463
+ { elements: videoElements, type: "video" },
464
+ { elements: audioElements, type: "audio" },
465
+ { elements: glbElements, type: "glb" },
466
+ { elements: cssElements, type: "css" }
467
+ ].forEach(({ elements, type }) => {
468
+ elements.forEach((element) => {
469
+ const order = parseInt(element.getAttribute("data-load-order") || "") || Infinity;
470
+ loadPromises.push(
471
+ this.loadResource(
472
+ element,
473
+ type,
474
+ order
475
+ )
476
+ );
477
+ });
478
+ });
479
+ await Promise.all(loadPromises);
480
+ const observer = new MutationObserver((mutations) => {
481
+ mutations.forEach((mutation) => {
482
+ mutation.addedNodes.forEach((node) => {
483
+ if (node.nodeType === Node.ELEMENT_NODE) {
484
+ const element = node;
485
+ if (element.getAttribute("style")?.includes("hcs://")) {
486
+ this.processInlineStyles();
487
+ }
488
+ if (element.tagName.toLowerCase() === "style" && element.textContent?.includes("hcs://")) {
489
+ this.processInlineStyles();
490
+ }
491
+ if (element.getAttribute("src")?.startsWith("hcs://")) {
492
+ const src = element.getAttribute("src");
493
+ element.setAttribute("data-src", src);
494
+ element.removeAttribute("src");
495
+ const tagName = element.tagName.toLowerCase();
496
+ switch (tagName) {
497
+ case "img":
498
+ this.loadResource(element, "image", Infinity);
499
+ break;
500
+ case "video":
501
+ this.loadResource(element, "video", Infinity);
502
+ break;
503
+ case "audio":
504
+ this.loadResource(element, "audio", Infinity);
505
+ break;
506
+ case "script":
507
+ this.loadResource(element, "script", Infinity);
508
+ break;
509
+ }
510
+ }
511
+ if (element.matches('script[data-src^="hcs://"]')) {
512
+ this.loadResource(element, "script", Infinity);
513
+ } else if (element.matches('img[data-src^="hcs://"]')) {
514
+ this.loadResource(element, "image", Infinity);
515
+ } else if (element.matches('video[data-src^="hcs://"]')) {
516
+ this.loadResource(element, "video", Infinity);
517
+ } else if (element.matches('audio[data-src^="hcs://"]')) {
518
+ this.loadResource(element, "audio", Infinity);
519
+ } else if (element.matches('model-viewer[data-src^="hcs://"]')) {
520
+ this.loadResource(element, "glb", Infinity);
521
+ } else if (element.matches('link[data-src^="hcs://"]')) {
522
+ this.loadResource(element, "css", Infinity);
523
+ }
524
+ const childrenWithHCS = element.querySelectorAll(
525
+ '[data-src^="hcs://"], [src^="hcs://"]'
526
+ );
527
+ childrenWithHCS.forEach((child) => {
528
+ const childElement = child;
529
+ const tagName = childElement.tagName.toLowerCase();
530
+ const src = childElement.getAttribute("src");
531
+ if (src?.startsWith("hcs://")) {
532
+ childElement.setAttribute("data-src", src);
533
+ childElement.removeAttribute("src");
534
+ }
535
+ switch (tagName) {
536
+ case "script":
537
+ this.loadResource(childElement, "script", Infinity);
538
+ break;
539
+ case "img":
540
+ this.loadResource(childElement, "image", Infinity);
541
+ break;
542
+ case "video":
543
+ this.loadResource(childElement, "video", Infinity);
544
+ break;
545
+ case "audio":
546
+ this.loadResource(childElement, "audio", Infinity);
547
+ break;
548
+ case "model-viewer":
549
+ this.loadResource(childElement, "glb", Infinity);
550
+ break;
551
+ case "link":
552
+ this.loadResource(childElement, "css", Infinity);
553
+ break;
554
+ }
555
+ });
556
+ }
557
+ });
558
+ if (mutation.type === "attributes") {
559
+ const element = mutation.target;
560
+ if (mutation.attributeName === "style" && element.getAttribute("style")?.includes("hcs://")) {
561
+ this.processInlineStyles();
562
+ } else if (mutation.attributeName === "src") {
563
+ const src = element.getAttribute("src");
564
+ if (src?.startsWith("hcs://")) {
565
+ element.setAttribute("data-src", src);
566
+ element.removeAttribute("src");
567
+ const type = element.tagName.toLowerCase();
568
+ if (["img", "video", "audio"].includes(type)) {
569
+ this.loadResource(element, type, Infinity);
570
+ }
571
+ }
572
+ }
573
+ }
574
+ });
575
+ });
576
+ if (document.body) {
577
+ observer.observe(document.body, {
578
+ childList: true,
579
+ subtree: true,
580
+ attributes: true,
581
+ attributeFilter: ["style", "src", "data-src"]
582
+ });
583
+ } else {
584
+ document.addEventListener("DOMContentLoaded", () => {
585
+ observer.observe(document.body, {
586
+ childList: true,
587
+ subtree: true,
588
+ attributes: true,
589
+ attributeFilter: ["style", "src", "data-src"]
590
+ });
591
+ });
592
+ }
593
+ resolve();
594
+ };
595
+ if (document.readyState === "loading") {
596
+ document.addEventListener("DOMContentLoaded", initializeObserver);
597
+ } else {
598
+ initializeObserver();
599
+ }
600
+ });
207
601
  }
208
- if (hasToString(value)) {
209
- const result = value.toString();
210
- if (/^\d+$/u.test(result)) {
211
- return result;
602
+ async preloadImage(topicId) {
603
+ this.log("Loading image:" + topicId);
604
+ this.updateLoadingStatus("image: " + topicId, "loading");
605
+ const blob = await this.retrieveHCS1Data(topicId);
606
+ const objectURL = URL.createObjectURL(blob);
607
+ this.LoadedImages[topicId] = objectURL;
608
+ this.updateLoadingStatus("image: " + topicId, "loaded");
609
+ return objectURL;
610
+ }
611
+ async preloadAudio(topicId) {
612
+ const audioElement = document.createElement("audio");
613
+ audioElement.setAttribute("data-topic-id", topicId);
614
+ audioElement.setAttribute("data-src", "hcs://1/" + topicId);
615
+ document.body.appendChild(audioElement);
616
+ await this.loadMedia(audioElement, "audio");
617
+ const cachedAudio = document.querySelector(
618
+ 'audio[data-topic-id="' + topicId + '"]'
619
+ );
620
+ if (cachedAudio) {
621
+ this.LoadedAudioUrls[topicId] = cachedAudio.src;
622
+ } else {
623
+ console.error("Failed to preload audio: " + topicId);
624
+ }
625
+ return this.LoadedAudioUrls[topicId];
626
+ }
627
+ async playAudio(topicId, volume = 1) {
628
+ const audioUrl = this.LoadedAudioUrls[topicId];
629
+ if (audioUrl) {
630
+ const audio = new Audio(audioUrl);
631
+ audio.volume = volume;
632
+ this.LoadedAudios[topicId] = audio;
633
+ audio.play().catch((error) => {
634
+ console.error("Failed to play audio:", error);
635
+ });
636
+ audio.addEventListener("ended", () => {
637
+ audio.remove();
638
+ delete this.LoadedAudios[topicId];
639
+ });
640
+ } else {
641
+ console.error("Audio not preloaded: " + topicId);
642
+ }
643
+ }
644
+ async pauseAudio(topicId) {
645
+ const audioElement = document.querySelector(
646
+ 'audio[data-topic-id="' + topicId + '"]'
647
+ );
648
+ if (audioElement) {
649
+ console.log("found element", audioElement);
650
+ audioElement.pause();
651
+ this.LoadedAudios[topicId]?.pause();
652
+ } else {
653
+ this.LoadedAudios[topicId]?.pause();
654
+ }
655
+ }
656
+ async loadAndPlayAudio(topicId, autoplay = false, volume = 1) {
657
+ let existingAudioElement = document.querySelector(
658
+ 'audio[data-topic-id="' + topicId + '"]'
659
+ );
660
+ if (existingAudioElement) {
661
+ existingAudioElement.volume = volume;
662
+ await existingAudioElement.play();
663
+ } else {
664
+ const audioElement = document.createElement("audio");
665
+ audioElement.volume = volume;
666
+ if (autoplay) {
667
+ audioElement.setAttribute("autoplay", "autoplay");
668
+ }
669
+ audioElement.setAttribute("data-topic-id", topicId);
670
+ audioElement.setAttribute("data-src", "hcs://1/" + topicId);
671
+ document.body.appendChild(audioElement);
672
+ await this.loadMedia(audioElement, "audio");
673
+ existingAudioElement = document.querySelector(
674
+ 'audio[data-topic-id="' + topicId + '"]'
675
+ );
676
+ if (!autoplay) {
677
+ await existingAudioElement.play();
678
+ }
212
679
  }
213
680
  }
214
- return null;
215
- }
216
- function requireNotFrozen(target) {
217
- const candidate = target;
218
- candidate._requireNotFrozen?.();
219
681
  }
682
+ export {
683
+ HCS
684
+ };
220
685
  //# sourceMappingURL=standards-sdk.es2.js.map