@design-edito/tools 0.1.60 → 0.1.62

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 (572) hide show
  1. package/agnostic/arrays/index.js +6 -6
  2. package/agnostic/arrays/random-pick/index.js +4 -4
  3. package/agnostic/css/bem/index.js +2 -2
  4. package/agnostic/css/index.js +11 -11
  5. package/agnostic/css/styles-set/index.js +4 -4
  6. package/agnostic/html/hyper-json/cast/index.js +5 -5
  7. package/agnostic/html/hyper-json/index.js +6 -6
  8. package/agnostic/html/hyper-json/smart-tags/coalesced/add/index.js +5 -5
  9. package/agnostic/html/hyper-json/smart-tags/coalesced/addclass/index.js +5 -5
  10. package/agnostic/html/hyper-json/smart-tags/coalesced/and/index.js +5 -5
  11. package/agnostic/html/hyper-json/smart-tags/coalesced/append/index.js +5 -5
  12. package/agnostic/html/hyper-json/smart-tags/coalesced/at/index.js +5 -5
  13. package/agnostic/html/hyper-json/smart-tags/coalesced/call/index.js +5 -5
  14. package/agnostic/html/hyper-json/smart-tags/coalesced/clone/index.js +5 -5
  15. package/agnostic/html/hyper-json/smart-tags/coalesced/deleteproperties/index.js +5 -5
  16. package/agnostic/html/hyper-json/smart-tags/coalesced/equals/index.js +5 -5
  17. package/agnostic/html/hyper-json/smart-tags/coalesced/getattribute/index.js +5 -5
  18. package/agnostic/html/hyper-json/smart-tags/coalesced/getproperties/index.js +5 -5
  19. package/agnostic/html/hyper-json/smart-tags/coalesced/getproperty/index.js +5 -5
  20. package/agnostic/html/hyper-json/smart-tags/coalesced/if/index.js +5 -5
  21. package/agnostic/html/hyper-json/smart-tags/coalesced/initialize/index.js +5 -5
  22. package/agnostic/html/hyper-json/smart-tags/coalesced/join/index.js +5 -5
  23. package/agnostic/html/hyper-json/smart-tags/coalesced/length/index.js +5 -5
  24. package/agnostic/html/hyper-json/smart-tags/coalesced/map/index.js +5 -5
  25. package/agnostic/html/hyper-json/smart-tags/coalesced/negate/index.js +5 -5
  26. package/agnostic/html/hyper-json/smart-tags/coalesced/notrailing/index.js +5 -5
  27. package/agnostic/html/hyper-json/smart-tags/coalesced/or/index.js +5 -5
  28. package/agnostic/html/hyper-json/smart-tags/coalesced/pickrandom/index.js +5 -5
  29. package/agnostic/html/hyper-json/smart-tags/coalesced/populate/index.js +5 -5
  30. package/agnostic/html/hyper-json/smart-tags/coalesced/print/index.js +5 -5
  31. package/agnostic/html/hyper-json/smart-tags/coalesced/push/index.js +5 -5
  32. package/agnostic/html/hyper-json/smart-tags/coalesced/pusheach/index.js +5 -5
  33. package/agnostic/html/hyper-json/smart-tags/coalesced/recordtoarray/index.js +5 -5
  34. package/agnostic/html/hyper-json/smart-tags/coalesced/removeattribute/index.js +5 -5
  35. package/agnostic/html/hyper-json/smart-tags/coalesced/removeclass/index.js +5 -5
  36. package/agnostic/html/hyper-json/smart-tags/coalesced/renameproperty/index.js +5 -5
  37. package/agnostic/html/hyper-json/smart-tags/coalesced/replace/index.js +5 -5
  38. package/agnostic/html/hyper-json/smart-tags/coalesced/select/index.js +5 -5
  39. package/agnostic/html/hyper-json/smart-tags/coalesced/set/index.js +5 -5
  40. package/agnostic/html/hyper-json/smart-tags/coalesced/setattribute/index.js +5 -5
  41. package/agnostic/html/hyper-json/smart-tags/coalesced/setproperty/index.js +5 -5
  42. package/agnostic/html/hyper-json/smart-tags/coalesced/sorton/index.js +5 -5
  43. package/agnostic/html/hyper-json/smart-tags/coalesced/split/index.js +5 -5
  44. package/agnostic/html/hyper-json/smart-tags/coalesced/spread/index.js +5 -5
  45. package/agnostic/html/hyper-json/smart-tags/coalesced/toarray/index.js +5 -5
  46. package/agnostic/html/hyper-json/smart-tags/coalesced/toboolean/index.js +5 -5
  47. package/agnostic/html/hyper-json/smart-tags/coalesced/toelement/index.js +5 -5
  48. package/agnostic/html/hyper-json/smart-tags/coalesced/toggleclass/index.js +5 -5
  49. package/agnostic/html/hyper-json/smart-tags/coalesced/tonodelist/index.js +5 -5
  50. package/agnostic/html/hyper-json/smart-tags/coalesced/tonull/index.js +5 -5
  51. package/agnostic/html/hyper-json/smart-tags/coalesced/tonumber/index.js +5 -5
  52. package/agnostic/html/hyper-json/smart-tags/coalesced/torecord/index.js +5 -5
  53. package/agnostic/html/hyper-json/smart-tags/coalesced/toref/index.js +5 -5
  54. package/agnostic/html/hyper-json/smart-tags/coalesced/tostring/index.js +5 -5
  55. package/agnostic/html/hyper-json/smart-tags/coalesced/totext/index.js +5 -5
  56. package/agnostic/html/hyper-json/smart-tags/coalesced/transformselected/index.js +5 -5
  57. package/agnostic/html/hyper-json/smart-tags/coalesced/trim/index.js +5 -5
  58. package/agnostic/html/hyper-json/smart-tags/isolated/boolean/index.js +5 -5
  59. package/agnostic/html/hyper-json/smart-tags/isolated/element/index.js +5 -5
  60. package/agnostic/html/hyper-json/smart-tags/isolated/get/index.js +5 -5
  61. package/agnostic/html/hyper-json/smart-tags/isolated/global/index.js +5 -5
  62. package/agnostic/html/hyper-json/smart-tags/isolated/guess/index.js +5 -5
  63. package/agnostic/html/hyper-json/smart-tags/isolated/nodelist/index.js +5 -5
  64. package/agnostic/html/hyper-json/smart-tags/isolated/number/index.js +5 -5
  65. package/agnostic/html/hyper-json/smart-tags/isolated/record/index.js +5 -5
  66. package/agnostic/html/hyper-json/smart-tags/isolated/ref/index.js +5 -5
  67. package/agnostic/html/hyper-json/smart-tags/isolated/string/index.js +5 -5
  68. package/agnostic/html/hyper-json/smart-tags/isolated/text/index.js +5 -5
  69. package/agnostic/html/hyper-json/tree/index.js +5 -5
  70. package/agnostic/html/hyper-json/utils/index.js +5 -5
  71. package/agnostic/html/index.js +20 -20
  72. package/agnostic/html/sanitize/index.js +4 -4
  73. package/agnostic/html/selector-to-element/index.js +4 -4
  74. package/agnostic/html/string-to-nodes/index.js +5 -5
  75. package/agnostic/misc/crossenv/index.js +2 -2
  76. package/agnostic/misc/index.js +22 -22
  77. package/agnostic/misc/lorem-ipsum/index.js +7 -7
  78. package/agnostic/numbers/index.js +6 -6
  79. package/agnostic/objects/index.js +14 -14
  80. package/agnostic/strings/index.js +6 -6
  81. package/agnostic/time/index.js +3 -3
  82. package/chunks/{chunk-5UM7HYXS.js → chunk-2JKV6KXE.js} +1 -1
  83. package/chunks/{chunk-6A7GLDXD.js → chunk-4HLAM4RP.js} +3 -3
  84. package/chunks/chunk-BGSJ5XCH.js +20 -0
  85. package/chunks/{chunk-OOETQRTY.js → chunk-HGQGQLLC.js} +1 -1
  86. package/chunks/{chunk-UL6OZKRF.js → chunk-ISFXCV7D.js} +2 -2
  87. package/chunks/chunk-JTJA7DGW.js +36 -0
  88. package/chunks/{chunk-344X5RHV.js → chunk-MZKZI6JL.js} +1 -1
  89. package/chunks/{chunk-5KEIMXTB.js → chunk-PDHAMES3.js} +1 -1
  90. package/chunks/{chunk-ITECXQUB.js → chunk-QPT6R6CL.js} +6 -6
  91. package/chunks/{chunk-EHOZ6VCE.js → chunk-R7J7Q2UL.js} +4 -4
  92. package/chunks/chunk-REZC75LB.js +55 -0
  93. package/chunks/{chunk-BX6M7WBE.js → chunk-V4KSJHTU.js} +1 -1
  94. package/chunks/{chunk-XC2YGMNJ.js → chunk-YVEMIEOT.js} +1 -1
  95. package/node/@aws-s3/index.js +3 -3
  96. package/node/@aws-s3/storage/file/index.js +4 -4
  97. package/node/@aws-s3/storage/index.js +3 -3
  98. package/node/@design-edito/index.js +3 -3
  99. package/node/@design-edito/thumbnails/index.js +7 -7
  100. package/node/@design-edito/thumbnails/layout/index.js +2 -2
  101. package/node/@google-cloud/index.js +7 -7
  102. package/node/@google-cloud/storage/file/index.js +12 -12
  103. package/node/@google-cloud/storage/file/revoke-signed-urls/index.js +2 -2
  104. package/node/@google-cloud/storage/index.js +7 -7
  105. package/node/cloud-storage/index.js +9 -9
  106. package/node/cloud-storage/operations/download/index.js +2 -2
  107. package/node/cloud-storage/operations/index.js +10 -10
  108. package/node/cloud-storage/operations/upload/index.js +2 -2
  109. package/node/encryption/@aes-256-gcm/buffer/index.d.ts +20 -0
  110. package/node/encryption/@aes-256-gcm/buffer/index.js +12 -0
  111. package/node/encryption/@aes-256-gcm/index.d.ts +3 -0
  112. package/node/encryption/@aes-256-gcm/index.js +14 -0
  113. package/node/encryption/@aes-256-gcm/uint8-array/index.d.ts +21 -0
  114. package/node/encryption/@aes-256-gcm/uint8-array/index.js +11 -0
  115. package/node/encryption/index.d.ts +2 -3
  116. package/node/encryption/index.js +6 -8
  117. package/node/files/index.js +3 -3
  118. package/node/ftps/file/index.js +4 -4
  119. package/node/ftps/index.js +2 -2
  120. package/node/images/index.js +8 -8
  121. package/node/images/prepare/index.js +6 -6
  122. package/node/images/transform/area-composition/index.js +4 -4
  123. package/node/images/transform/index.js +5 -5
  124. package/node/sftp/file/index.js +4 -4
  125. package/node/sftp/index.js +2 -2
  126. package/package.json +5 -5
  127. package/agnostic/html/hyper-json/smart-tags/coalesced/setproperties/index.d.ts +0 -4
  128. package/agnostic/html/hyper-json/smart-tags/coalesced/setproperties/index.js +0 -21
  129. package/agnostic/html/hyper-json/transformers/append/index.d.ts +0 -2
  130. package/agnostic/html/hyper-json/transformers/append/index.js +0 -16
  131. package/agnostic/html/hyper-json/transformers/classList/index.d.ts +0 -2
  132. package/agnostic/html/hyper-json/transformers/classList/index.js +0 -16
  133. package/agnostic/html/hyper-json/transformers/index.d.ts +0 -4
  134. package/agnostic/html/hyper-json/transformers/index.js +0 -16
  135. package/agnostic/html/hyper-json/transformers/join/index.d.ts +0 -2
  136. package/agnostic/html/hyper-json/transformers/join/index.js +0 -16
  137. package/agnostic/html/hyper-json/transformers/length/index.d.ts +0 -2
  138. package/agnostic/html/hyper-json/transformers/length/index.js +0 -16
  139. package/agnostic/html/hyper-json/transformers/print/index.d.ts +0 -2
  140. package/agnostic/html/hyper-json/transformers/print/index.js +0 -16
  141. package/agnostic/html/hyper-json/transformers/push/index.d.ts +0 -2
  142. package/agnostic/html/hyper-json/transformers/push/index.js +0 -16
  143. package/agnostic/html/hyper-json/transformers/querySelector/index.d.ts +0 -2
  144. package/agnostic/html/hyper-json/transformers/querySelector/index.js +0 -16
  145. package/agnostic/html/hyper-json/transformers/ref/index.d.ts +0 -2
  146. package/agnostic/html/hyper-json/transformers/ref/index.js +0 -16
  147. package/agnostic/html/hyper-json/transformers/replace/index.d.ts +0 -2
  148. package/agnostic/html/hyper-json/transformers/replace/index.js +0 -16
  149. package/agnostic/html/hyper-json/transformers/split/index.d.ts +0 -2
  150. package/agnostic/html/hyper-json/transformers/split/index.js +0 -16
  151. package/agnostic/html/hyper-json/transformers/toArray/index.d.ts +0 -2
  152. package/agnostic/html/hyper-json/transformers/toArray/index.js +0 -16
  153. package/agnostic/html/hyper-json/transformers/toBoolean/index.d.ts +0 -2
  154. package/agnostic/html/hyper-json/transformers/toBoolean/index.js +0 -16
  155. package/agnostic/html/hyper-json/transformers/toElement/index.d.ts +0 -2
  156. package/agnostic/html/hyper-json/transformers/toElement/index.js +0 -16
  157. package/agnostic/html/hyper-json/transformers/toNodeList/index.d.ts +0 -2
  158. package/agnostic/html/hyper-json/transformers/toNodeList/index.js +0 -16
  159. package/agnostic/html/hyper-json/transformers/toNull/index.d.ts +0 -2
  160. package/agnostic/html/hyper-json/transformers/toNull/index.js +0 -16
  161. package/agnostic/html/hyper-json/transformers/toNumber/index.d.ts +0 -2
  162. package/agnostic/html/hyper-json/transformers/toNumber/index.js +0 -16
  163. package/agnostic/html/hyper-json/transformers/toRecord/index.d.ts +0 -2
  164. package/agnostic/html/hyper-json/transformers/toRecord/index.js +0 -16
  165. package/agnostic/html/hyper-json/transformers/toRef/index.d.ts +0 -2
  166. package/agnostic/html/hyper-json/transformers/toRef/index.js +0 -16
  167. package/agnostic/html/hyper-json/transformers/toString/index.d.ts +0 -2
  168. package/agnostic/html/hyper-json/transformers/toString/index.js +0 -16
  169. package/agnostic/html/hyper-json/transformers/toText/index.d.ts +0 -2
  170. package/agnostic/html/hyper-json/transformers/toText/index.js +0 -16
  171. package/agnostic/html/hyper-json/transformers/toTransformer/index.d.ts +0 -2
  172. package/agnostic/html/hyper-json/transformers/toTransformer/index.js +0 -16
  173. package/agnostic/html/hyper-json/transformers/transformSelected/index.d.ts +0 -2
  174. package/agnostic/html/hyper-json/transformers/transformSelected/index.js +0 -16
  175. package/agnostic/html/hyper-json/transformers/trim/index.d.ts +0 -2
  176. package/agnostic/html/hyper-json/transformers/trim/index.js +0 -16
  177. package/agnostic/objects/record-filter/index.d.ts +0 -1
  178. package/agnostic/objects/record-filter/index.js +0 -6
  179. package/chunks/chunk-22Q6VKLR.js +0 -2369
  180. package/chunks/chunk-27HRTQ7Z.js +0 -20
  181. package/chunks/chunk-2G5MFJ66.js +0 -2420
  182. package/chunks/chunk-2HU2AWWJ.js +0 -35
  183. package/chunks/chunk-2IV3O7FX.js +0 -27
  184. package/chunks/chunk-2KCKWG7R.js +0 -104
  185. package/chunks/chunk-2KT7AKRW.js +0 -17
  186. package/chunks/chunk-2U2J4P3O.js +0 -31
  187. package/chunks/chunk-2UJYUMTT.js +0 -37
  188. package/chunks/chunk-35W7XRC3.js +0 -173
  189. package/chunks/chunk-365LSZZ7.js +0 -37
  190. package/chunks/chunk-36CTYZYA.js +0 -28
  191. package/chunks/chunk-3C3MXKEW.js +0 -31
  192. package/chunks/chunk-3GTGE66Y.js +0 -32
  193. package/chunks/chunk-3N2LP2TN.js +0 -191
  194. package/chunks/chunk-3OMANUYH.js +0 -211
  195. package/chunks/chunk-3SSUHWUD.js +0 -56
  196. package/chunks/chunk-3TX6SJRO.js +0 -31
  197. package/chunks/chunk-3UAAYFXA.js +0 -56
  198. package/chunks/chunk-42ZKFWKF.js +0 -2369
  199. package/chunks/chunk-44XPTCIO.js +0 -49
  200. package/chunks/chunk-4EFX53Y4.js +0 -31
  201. package/chunks/chunk-4FOK7DUZ.js +0 -35
  202. package/chunks/chunk-4HPUOADZ.js +0 -37
  203. package/chunks/chunk-4LCL2RIC.js +0 -209
  204. package/chunks/chunk-4OH2EX3D.js +0 -191
  205. package/chunks/chunk-4WOAFIVN.js +0 -31
  206. package/chunks/chunk-4WOYAD35.js +0 -31
  207. package/chunks/chunk-53MBV4TG.js +0 -6212
  208. package/chunks/chunk-55MT7BMY.js +0 -16
  209. package/chunks/chunk-57RPA6DU.js +0 -56
  210. package/chunks/chunk-57YCNOX7.js +0 -15
  211. package/chunks/chunk-5CYZ66VE.js +0 -31
  212. package/chunks/chunk-5E7N4BDI.js +0 -186
  213. package/chunks/chunk-5GI5G45R.js +0 -27
  214. package/chunks/chunk-5HWYTIYR.js +0 -211
  215. package/chunks/chunk-5JMTDJWX.js +0 -37
  216. package/chunks/chunk-5P7LHIDR.js +0 -37
  217. package/chunks/chunk-5QVKJGTN.js +0 -95
  218. package/chunks/chunk-5RSHXPTG.js +0 -21
  219. package/chunks/chunk-5VHXL242.js +0 -37
  220. package/chunks/chunk-5ZTW4PHE.js +0 -173
  221. package/chunks/chunk-64SYLWJ7.js +0 -37
  222. package/chunks/chunk-65YZMVWZ.js +0 -35
  223. package/chunks/chunk-66X6D4HF.js +0 -191
  224. package/chunks/chunk-6DA4S65P.js +0 -37
  225. package/chunks/chunk-6FRKSLBC.js +0 -2369
  226. package/chunks/chunk-6GZXU2Z3.js +0 -191
  227. package/chunks/chunk-6JRUZYTL.js +0 -211
  228. package/chunks/chunk-6KWNKTNI.js +0 -173
  229. package/chunks/chunk-6PNTQUTX.js +0 -20
  230. package/chunks/chunk-6Z6GDMOR.js +0 -28
  231. package/chunks/chunk-72NLUT3X.js +0 -29
  232. package/chunks/chunk-72U4TDEB.js +0 -127
  233. package/chunks/chunk-75DDEILC.js +0 -191
  234. package/chunks/chunk-7DNQ6RM2.js +0 -211
  235. package/chunks/chunk-7ICUR6QY.js +0 -31
  236. package/chunks/chunk-7K2EL46G.js +0 -2391
  237. package/chunks/chunk-7KHJKCA7.js +0 -2369
  238. package/chunks/chunk-7NO34XJI.js +0 -26
  239. package/chunks/chunk-7QIYI4CK.js +0 -209
  240. package/chunks/chunk-7VL2O6SQ.js +0 -211
  241. package/chunks/chunk-7VTVA56L.js +0 -37
  242. package/chunks/chunk-7W5LABV2.js +0 -37
  243. package/chunks/chunk-7YW5HL6N.js +0 -168
  244. package/chunks/chunk-A4FSJC46.js +0 -58
  245. package/chunks/chunk-AF2MI5O5.js +0 -29
  246. package/chunks/chunk-AM26FWT6.js +0 -31
  247. package/chunks/chunk-APRHU5KY.js +0 -31
  248. package/chunks/chunk-ARDAQZRR.js +0 -239
  249. package/chunks/chunk-AXMMBQRD.js +0 -191
  250. package/chunks/chunk-B446JIN3.js +0 -29
  251. package/chunks/chunk-BLAAWANI.js +0 -191
  252. package/chunks/chunk-BNNAZPI2.js +0 -191
  253. package/chunks/chunk-BPOJYE4X.js +0 -1108
  254. package/chunks/chunk-BQV4DOSE.js +0 -1108
  255. package/chunks/chunk-BV67SWXG.js +0 -20
  256. package/chunks/chunk-BVCWBTHQ.js +0 -35
  257. package/chunks/chunk-BW3XNPCJ.js +0 -191
  258. package/chunks/chunk-C2VF2MJV.js +0 -60
  259. package/chunks/chunk-C5753KUP.js +0 -127
  260. package/chunks/chunk-C5CIYEMD.js +0 -191
  261. package/chunks/chunk-C7SRAQMW.js +0 -29
  262. package/chunks/chunk-CAMYGA44.js +0 -22
  263. package/chunks/chunk-CB52KVOZ.js +0 -22
  264. package/chunks/chunk-CHUOCTRP.js +0 -26
  265. package/chunks/chunk-CIJQHLIW.js +0 -31
  266. package/chunks/chunk-CK73EBO5.js +0 -35
  267. package/chunks/chunk-CMKKX7WQ.js +0 -56
  268. package/chunks/chunk-CNPV4DFI.js +0 -20
  269. package/chunks/chunk-COLNKMBN.js +0 -35
  270. package/chunks/chunk-CQ3R7BEH.js +0 -173
  271. package/chunks/chunk-CQEDNACN.js +0 -28
  272. package/chunks/chunk-CRGU2EHQ.js +0 -31
  273. package/chunks/chunk-CRGUZBZX.js +0 -37
  274. package/chunks/chunk-CRZMH2K5.js +0 -2369
  275. package/chunks/chunk-CSYW7AAI.js +0 -191
  276. package/chunks/chunk-CWRRSS4V.js +0 -27
  277. package/chunks/chunk-D2JMITOU.js +0 -37
  278. package/chunks/chunk-D2NTUAFE.js +0 -4284
  279. package/chunks/chunk-D2V6SYYA.js +0 -191
  280. package/chunks/chunk-D5E2CIDK.js +0 -20
  281. package/chunks/chunk-D6VWX3D6.js +0 -186
  282. package/chunks/chunk-DCKTGQOX.js +0 -29
  283. package/chunks/chunk-DCSNQUVT.js +0 -56
  284. package/chunks/chunk-DHMARF6D.js +0 -62
  285. package/chunks/chunk-DHWHB53F.js +0 -191
  286. package/chunks/chunk-DLGA4UD5.js +0 -37
  287. package/chunks/chunk-DLSXW4NB.js +0 -2369
  288. package/chunks/chunk-DMR2WE3C.js +0 -62
  289. package/chunks/chunk-DZME4OQW.js +0 -2369
  290. package/chunks/chunk-E4FJHD5R.js +0 -67
  291. package/chunks/chunk-ECKOTCS4.js +0 -2369
  292. package/chunks/chunk-EEIJDUNV.js +0 -209
  293. package/chunks/chunk-EHVYR4OU.js +0 -56
  294. package/chunks/chunk-EI6W5HLB.js +0 -56
  295. package/chunks/chunk-EJEG2LDE.js +0 -2427
  296. package/chunks/chunk-ERAFJXWH.js +0 -20
  297. package/chunks/chunk-EUY4OBBI.js +0 -100
  298. package/chunks/chunk-EVOTJ7SU.js +0 -35
  299. package/chunks/chunk-EWM3VOPO.js +0 -191
  300. package/chunks/chunk-EX7FS6IR.js +0 -28
  301. package/chunks/chunk-F5DWWSOB.js +0 -31
  302. package/chunks/chunk-F5GXXF3A.js +0 -31
  303. package/chunks/chunk-FCU6IHKD.js +0 -15
  304. package/chunks/chunk-FDPPGRBY.js +0 -211
  305. package/chunks/chunk-FEFY3V6P.js +0 -31
  306. package/chunks/chunk-FG53JEP2.js +0 -31
  307. package/chunks/chunk-FHEUGVMU.js +0 -37
  308. package/chunks/chunk-FJTOFK3C.js +0 -203
  309. package/chunks/chunk-FOLCH72D.js +0 -211
  310. package/chunks/chunk-FONURDTX.js +0 -211
  311. package/chunks/chunk-FQD3VK47.js +0 -37
  312. package/chunks/chunk-FTIDPZZ5.js +0 -209
  313. package/chunks/chunk-FWZSMFVA.js +0 -211
  314. package/chunks/chunk-GARJTJ6V.js +0 -6
  315. package/chunks/chunk-GB4UQS6V.js +0 -35
  316. package/chunks/chunk-GBMHGF7P.js +0 -20
  317. package/chunks/chunk-GDFWDU4Q.js +0 -2369
  318. package/chunks/chunk-GGT2PUZH.js +0 -21
  319. package/chunks/chunk-GKG3UQH3.js +0 -191
  320. package/chunks/chunk-GL54CDM2.js +0 -20
  321. package/chunks/chunk-GNZY3ZTH.js +0 -14
  322. package/chunks/chunk-GP44TBRI.js +0 -39
  323. package/chunks/chunk-GPWFYPER.js +0 -211
  324. package/chunks/chunk-GQMFBT5T.js +0 -191
  325. package/chunks/chunk-GWXVHCAB.js +0 -31
  326. package/chunks/chunk-H7WUTMKQ.js +0 -31
  327. package/chunks/chunk-HDNYKGJM.js +0 -31
  328. package/chunks/chunk-HE6F5XJQ.js +0 -20
  329. package/chunks/chunk-HNB6B4FO.js +0 -37
  330. package/chunks/chunk-HP3OH2K7.js +0 -27
  331. package/chunks/chunk-HP722G2E.js +0 -211
  332. package/chunks/chunk-HQACEDCF.js +0 -37
  333. package/chunks/chunk-HTNLTDQT.js +0 -28
  334. package/chunks/chunk-I2ILSLBK.js +0 -32
  335. package/chunks/chunk-I4EBRCSJ.js +0 -20
  336. package/chunks/chunk-I66DPQN2.js +0 -31
  337. package/chunks/chunk-IECKIGM7.js +0 -2391
  338. package/chunks/chunk-IGHRNHVK.js +0 -16
  339. package/chunks/chunk-IJ7SOXLA.js +0 -107
  340. package/chunks/chunk-ILG6VQTL.js +0 -100
  341. package/chunks/chunk-IMR3ZNXR.js +0 -211
  342. package/chunks/chunk-IMZIWMCE.js +0 -191
  343. package/chunks/chunk-IOWZMFCU.js +0 -28
  344. package/chunks/chunk-IPON4W2H.js +0 -31
  345. package/chunks/chunk-ISAIFQAY.js +0 -100
  346. package/chunks/chunk-IUFAHY2R.js +0 -38
  347. package/chunks/chunk-IYHWMMQE.js +0 -37
  348. package/chunks/chunk-JBSS64SA.js +0 -6
  349. package/chunks/chunk-JJ5ME3A2.js +0 -191
  350. package/chunks/chunk-JJK5733Z.js +0 -211
  351. package/chunks/chunk-JKWNIKHN.js +0 -37
  352. package/chunks/chunk-JNXO4QEM.js +0 -56
  353. package/chunks/chunk-JRXEHYIE.js +0 -37
  354. package/chunks/chunk-JRXTMXKV.js +0 -15967
  355. package/chunks/chunk-JSYVAPV6.js +0 -6
  356. package/chunks/chunk-JUIKU4XP.js +0 -191
  357. package/chunks/chunk-JWF5EKM2.js +0 -127
  358. package/chunks/chunk-JWKI6G6E.js +0 -102
  359. package/chunks/chunk-JYW5L62E.js +0 -211
  360. package/chunks/chunk-KB4BPJBE.js +0 -2369
  361. package/chunks/chunk-KD627A47.js +0 -191
  362. package/chunks/chunk-KEYRP27F.js +0 -191
  363. package/chunks/chunk-KFW3ORPQ.js +0 -20
  364. package/chunks/chunk-KQZK54ZT.js +0 -2369
  365. package/chunks/chunk-KTB7NX4Q.js +0 -56
  366. package/chunks/chunk-KUIQRVIC.js +0 -100
  367. package/chunks/chunk-KYMCGWPM.js +0 -31
  368. package/chunks/chunk-L2L27BLX.js +0 -56
  369. package/chunks/chunk-L5JWJRZ7.js +0 -484
  370. package/chunks/chunk-LAA2DQDK.js +0 -31
  371. package/chunks/chunk-LATEK24U.js +0 -31
  372. package/chunks/chunk-LDLSU4OG.js +0 -191
  373. package/chunks/chunk-LLGU4W6F.js +0 -37
  374. package/chunks/chunk-LLSKBXT7.js +0 -14
  375. package/chunks/chunk-LOFELEU3.js +0 -1108
  376. package/chunks/chunk-LVXK54LL.js +0 -27
  377. package/chunks/chunk-LWWXPVXY.js +0 -25173
  378. package/chunks/chunk-LXPG32TV.js +0 -31
  379. package/chunks/chunk-M6WWIEQJ.js +0 -37
  380. package/chunks/chunk-M737IMZM.js +0 -37
  381. package/chunks/chunk-M7YNPJYY.js +0 -173
  382. package/chunks/chunk-MAP7OSVR.js +0 -37
  383. package/chunks/chunk-MBWRDYGE.js +0 -191
  384. package/chunks/chunk-MC5RLVK5.js +0 -4284
  385. package/chunks/chunk-MF56TTC5.js +0 -15
  386. package/chunks/chunk-MMNQZ2IM.js +0 -20
  387. package/chunks/chunk-MMPJODO2.js +0 -31
  388. package/chunks/chunk-MOA6JFUQ.js +0 -2369
  389. package/chunks/chunk-MQPY7A3O.js +0 -211
  390. package/chunks/chunk-MTT7TVR3.js +0 -127
  391. package/chunks/chunk-MUYZV5F3.js +0 -2369
  392. package/chunks/chunk-MUZGZ3ZF.js +0 -50
  393. package/chunks/chunk-MV7CCO4Y.js +0 -4430
  394. package/chunks/chunk-MW3KNVTG.js +0 -29
  395. package/chunks/chunk-MY4VMHSH.js +0 -191
  396. package/chunks/chunk-MZ2RAM5Y.js +0 -62
  397. package/chunks/chunk-MZSIKE3H.js +0 -211
  398. package/chunks/chunk-N2AOS7WW.js +0 -20
  399. package/chunks/chunk-N37FT2RW.js +0 -2391
  400. package/chunks/chunk-N4BZJOGW.js +0 -56
  401. package/chunks/chunk-N4LMP4UM.js +0 -31
  402. package/chunks/chunk-NGYJGQT3.js +0 -25002
  403. package/chunks/chunk-NHQVXC4Y.js +0 -2391
  404. package/chunks/chunk-NIOOIUSD.js +0 -104
  405. package/chunks/chunk-NLHFSJYR.js +0 -15
  406. package/chunks/chunk-NQ5ESZNO.js +0 -191
  407. package/chunks/chunk-NRRDPNOH.js +0 -100
  408. package/chunks/chunk-NWFX6TEY.js +0 -28
  409. package/chunks/chunk-O2WG3EMN.js +0 -2369
  410. package/chunks/chunk-O6NULFZI.js +0 -37
  411. package/chunks/chunk-OAQG5VAW.js +0 -211
  412. package/chunks/chunk-OJI6SN6F.js +0 -31
  413. package/chunks/chunk-OJXN5JW7.js +0 -37
  414. package/chunks/chunk-OVMNSJOW.js +0 -6
  415. package/chunks/chunk-P2H6PV4O.js +0 -26
  416. package/chunks/chunk-PEEPNNRS.js +0 -173
  417. package/chunks/chunk-PEOXR2Q6.js +0 -191
  418. package/chunks/chunk-PIIE3634.js +0 -37
  419. package/chunks/chunk-PJDZMLNG.js +0 -127
  420. package/chunks/chunk-PM7FWQYD.js +0 -20
  421. package/chunks/chunk-PMYUC6VD.js +0 -37
  422. package/chunks/chunk-PPHUIOHO.js +0 -28
  423. package/chunks/chunk-PPK2JEO6.js +0 -28
  424. package/chunks/chunk-PVHLWKA6.js +0 -31
  425. package/chunks/chunk-PYVUC6EN.js +0 -191
  426. package/chunks/chunk-Q7HA7IAA.js +0 -20
  427. package/chunks/chunk-QAJYFNPZ.js +0 -211
  428. package/chunks/chunk-QHGZBCFZ.js +0 -1108
  429. package/chunks/chunk-QI67BXO6.js +0 -2370
  430. package/chunks/chunk-QIXAGMCI.js +0 -211
  431. package/chunks/chunk-QLJBBAQ5.js +0 -37
  432. package/chunks/chunk-QMWX2A56.js +0 -56
  433. package/chunks/chunk-QN3UAKIU.js +0 -21
  434. package/chunks/chunk-QPBY235R.js +0 -239
  435. package/chunks/chunk-QTTNO4T6.js +0 -37
  436. package/chunks/chunk-QUWGF5WZ.js +0 -191
  437. package/chunks/chunk-QZPBUDX2.js +0 -20
  438. package/chunks/chunk-R23B2MRN.js +0 -2405
  439. package/chunks/chunk-R57V5HA7.js +0 -211
  440. package/chunks/chunk-RDQJSWRC.js +0 -127
  441. package/chunks/chunk-REBANVPP.js +0 -104
  442. package/chunks/chunk-RHV7UOXD.js +0 -211
  443. package/chunks/chunk-RI37ZSKY.js +0 -2369
  444. package/chunks/chunk-ROJZUEYL.js +0 -37
  445. package/chunks/chunk-RORBHBEN.js +0 -20
  446. package/chunks/chunk-RRSHCFEP.js +0 -191
  447. package/chunks/chunk-RSMUYH5H.js +0 -31
  448. package/chunks/chunk-RTFKMYT7.js +0 -2369
  449. package/chunks/chunk-RVVJ4QD4.js +0 -173
  450. package/chunks/chunk-RWWYR54P.js +0 -31
  451. package/chunks/chunk-RX3BKRJU.js +0 -2407
  452. package/chunks/chunk-S7MJLTCR.js +0 -211
  453. package/chunks/chunk-SA2IY5LN.js +0 -35
  454. package/chunks/chunk-SBAY4ZKE.js +0 -211
  455. package/chunks/chunk-SEB7TFUB.js +0 -20
  456. package/chunks/chunk-SFYYQPAK.js +0 -37
  457. package/chunks/chunk-SJLH36CH.js +0 -26
  458. package/chunks/chunk-SJQNLCGS.js +0 -173
  459. package/chunks/chunk-SOAU5CRO.js +0 -56
  460. package/chunks/chunk-SPMF4X5X.js +0 -31
  461. package/chunks/chunk-SR2YFPJZ.js +0 -2419
  462. package/chunks/chunk-SYD5FZEO.js +0 -20
  463. package/chunks/chunk-T5C73QJF.js +0 -56
  464. package/chunks/chunk-TAVCC26N.js +0 -37
  465. package/chunks/chunk-TEB7KZWB.js +0 -21
  466. package/chunks/chunk-TL3JMADI.js +0 -2391
  467. package/chunks/chunk-TLTLM47Y.js +0 -27
  468. package/chunks/chunk-TOZXS7ZY.js +0 -2369
  469. package/chunks/chunk-TSQVG7GA.js +0 -31
  470. package/chunks/chunk-TXOUGP37.js +0 -62
  471. package/chunks/chunk-TYJOCMG7.js +0 -37
  472. package/chunks/chunk-U32YPAPW.js +0 -2369
  473. package/chunks/chunk-U6W7BPH4.js +0 -2369
  474. package/chunks/chunk-U6YRINXJ.js +0 -22
  475. package/chunks/chunk-UBFLFJMH.js +0 -37
  476. package/chunks/chunk-UDY37VIJ.js +0 -22
  477. package/chunks/chunk-UFKH5WD2.js +0 -21
  478. package/chunks/chunk-UG36UPJK.js +0 -31
  479. package/chunks/chunk-UHH75BZP.js +0 -56
  480. package/chunks/chunk-UMJX4S4M.js +0 -56
  481. package/chunks/chunk-UODICVLG.js +0 -173
  482. package/chunks/chunk-UT75PSLP.js +0 -20
  483. package/chunks/chunk-UXM54YBI.js +0 -68
  484. package/chunks/chunk-VDNIN3V5.js +0 -23
  485. package/chunks/chunk-VEKKX6Z5.js +0 -173
  486. package/chunks/chunk-VH4FK3TX.js +0 -31
  487. package/chunks/chunk-VHCD3Z4T.js +0 -20
  488. package/chunks/chunk-VHFMQI7Z.js +0 -20
  489. package/chunks/chunk-VKURVIRV.js +0 -28
  490. package/chunks/chunk-VLHSIIPO.js +0 -20
  491. package/chunks/chunk-VP3Y6EMX.js +0 -190
  492. package/chunks/chunk-VQEP2EQF.js +0 -100
  493. package/chunks/chunk-VV35APGM.js +0 -2369
  494. package/chunks/chunk-VV72XGJJ.js +0 -58
  495. package/chunks/chunk-VXSOUAUT.js +0 -100
  496. package/chunks/chunk-VZQ4WCBH.js +0 -2391
  497. package/chunks/chunk-W4OFHYWN.js +0 -1108
  498. package/chunks/chunk-W6BFU7Y5.js +0 -56
  499. package/chunks/chunk-W7YBGJ4H.js +0 -28
  500. package/chunks/chunk-WABWQCFE.js +0 -127
  501. package/chunks/chunk-WC2LQPQP.js +0 -26
  502. package/chunks/chunk-WDWDHE7I.js +0 -31
  503. package/chunks/chunk-WFED6NDN.js +0 -28
  504. package/chunks/chunk-WJMBLQRX.js +0 -29
  505. package/chunks/chunk-WKW34B3A.js +0 -2369
  506. package/chunks/chunk-WLHJM76F.js +0 -2369
  507. package/chunks/chunk-WNLP6R5Y.js +0 -191
  508. package/chunks/chunk-WO2R3QFK.js +0 -20
  509. package/chunks/chunk-WP7L5ZFP.js +0 -173
  510. package/chunks/chunk-WTAMA5WX.js +0 -37
  511. package/chunks/chunk-WTPUSGMJ.js +0 -104
  512. package/chunks/chunk-WXXW6YLW.js +0 -127
  513. package/chunks/chunk-WYY3N6PO.js +0 -2369
  514. package/chunks/chunk-WZC2HZ5W.js +0 -27
  515. package/chunks/chunk-X4XXZ44B.js +0 -37
  516. package/chunks/chunk-X5HMM3LD.js +0 -35
  517. package/chunks/chunk-XCBH6NLF.js +0 -42
  518. package/chunks/chunk-XDYRPW7Q.js +0 -37
  519. package/chunks/chunk-XDZD6C76.js +0 -37
  520. package/chunks/chunk-XETVQW6S.js +0 -56
  521. package/chunks/chunk-XGOWRHVM.js +0 -37
  522. package/chunks/chunk-XH6TZMNR.js +0 -211
  523. package/chunks/chunk-XI2XIH6L.js +0 -2391
  524. package/chunks/chunk-XK2PI5WI.js +0 -31
  525. package/chunks/chunk-XL7AQDAE.js +0 -31
  526. package/chunks/chunk-XPRBKRSB.js +0 -37
  527. package/chunks/chunk-XRUSQWPJ.js +0 -173
  528. package/chunks/chunk-XSOBXDGQ.js +0 -191
  529. package/chunks/chunk-XT6XKGKK.js +0 -20
  530. package/chunks/chunk-XWLQR4UY.js +0 -25
  531. package/chunks/chunk-XWU7O5KD.js +0 -211
  532. package/chunks/chunk-XXDQWJP3.js +0 -56
  533. package/chunks/chunk-YBYXIDGC.js +0 -20
  534. package/chunks/chunk-YCZQAM7E.js +0 -2407
  535. package/chunks/chunk-YDNQHZRS.js +0 -31
  536. package/chunks/chunk-YGJHHWBJ.js +0 -37
  537. package/chunks/chunk-YHT73ULP.js +0 -2369
  538. package/chunks/chunk-YKECGAIJ.js +0 -37
  539. package/chunks/chunk-YMNBUQVR.js +0 -2420
  540. package/chunks/chunk-YO5KOEJF.js +0 -27
  541. package/chunks/chunk-YRKWVEWA.js +0 -20
  542. package/chunks/chunk-YRSNU7IX.js +0 -49
  543. package/chunks/chunk-YTS4JME6.js +0 -2369
  544. package/chunks/chunk-YVHJ7TUJ.js +0 -211
  545. package/chunks/chunk-YVSS4IT2.js +0 -37
  546. package/chunks/chunk-YYE7TVB6.js +0 -2420
  547. package/chunks/chunk-YYYRFMNZ.js +0 -191
  548. package/chunks/chunk-YZDZQ7AZ.js +0 -37
  549. package/chunks/chunk-Z352MSRL.js +0 -127
  550. package/chunks/chunk-Z4SQDCFG.js +0 -37
  551. package/chunks/chunk-ZCPGE7H7.js +0 -64
  552. package/chunks/chunk-ZGYU6F7Q.js +0 -13
  553. package/chunks/chunk-ZLQUBC5B.js +0 -31
  554. package/chunks/chunk-ZNPRJEP5.js +0 -28
  555. package/chunks/chunk-ZS5OHINP.js +0 -31
  556. package/index.d.ts +0 -3
  557. package/node/encryption/buffer/index.d.ts +0 -56
  558. package/node/encryption/buffer/index.js +0 -16
  559. package/node/encryption/generate-key/index.d.ts +0 -16
  560. package/node/encryption/generate-key/index.js +0 -7
  561. package/node/encryption/uint8-array/index.d.ts +0 -57
  562. package/node/encryption/uint8-array/index.js +0 -15
  563. package/chunks/{chunk-3DJI3JTM.js → chunk-3CQON3DO.js} +9 -9
  564. package/chunks/{chunk-OPO25SDO.js → chunk-DW4ILX77.js} +3 -3
  565. package/chunks/{chunk-VKNWPV5T.js → chunk-FIVB3FON.js} +3 -3
  566. package/chunks/{chunk-EFLJJ5VF.js → chunk-FVFYLT5T.js} +6 -6
  567. package/chunks/{chunk-222367I5.js → chunk-HZGGYNZ5.js} +9 -9
  568. package/chunks/{chunk-GBBM5DLR.js → chunk-JSKVNOTW.js} +3 -3
  569. package/chunks/{chunk-AE6L2HYA.js → chunk-K4Q2MG65.js} +3 -3
  570. package/chunks/{chunk-EZFHN4ST.js → chunk-KTK3BMX2.js} +11 -11
  571. package/chunks/{chunk-EIU72AEZ.js → chunk-VWLJ5IEE.js} +7 -7
  572. package/chunks/{chunk-HQGZVWBB.js → chunk-XAZT2MME.js} +5 -5
@@ -1,2420 +0,0 @@
1
- import {
2
- nullFunc
3
- } from "./chunk-QAVYONH6.js";
4
- import {
5
- Types
6
- } from "./chunk-XEQ2PBT2.js";
7
- import {
8
- array
9
- } from "./chunk-VDNIN3V5.js";
10
- import {
11
- any
12
- } from "./chunk-FHLCPVND.js";
13
- import {
14
- SmartTags
15
- } from "./chunk-UT2J62LH.js";
16
- import {
17
- Serialize
18
- } from "./chunk-SXRWMH3U.js";
19
- import {
20
- Transformer
21
- } from "./chunk-BKO7GLC2.js";
22
- import {
23
- Method
24
- } from "./chunk-RW7VAKJW.js";
25
- import {
26
- insertNode
27
- } from "./chunk-XA4HVHJ4.js";
28
- import {
29
- isInEnum
30
- } from "./chunk-E6MSDKON.js";
31
- import {
32
- recordMap
33
- } from "./chunk-XNF5MLCQ.js";
34
- import {
35
- isRecord
36
- } from "./chunk-YDIBNEGA.js";
37
- import {
38
- Outcome
39
- } from "./chunk-JMU5PDBD.js";
40
- import {
41
- replaceAll
42
- } from "./chunk-ZTDVUXPR.js";
43
- import {
44
- Window
45
- } from "./chunk-RLJOYG64.js";
46
-
47
- // src/agnostic/html/hyper-json/cast/index.ts
48
- var Cast;
49
- ((Cast2) => {
50
- Cast2.toNull = () => null;
51
- Cast2.toBoolean = (input) => {
52
- const { Text: Text2 } = Window.get();
53
- if (input === null) return false;
54
- if (typeof input === "boolean") return input;
55
- if (typeof input === "number") return input !== 0;
56
- if (typeof input === "string" || input instanceof Text2) {
57
- const strInput = (0, Cast2.toString)(input);
58
- if (strInput.trim() === "") return false;
59
- if (strInput.trim().toLowerCase() === "false") return false;
60
- return true;
61
- }
62
- return true;
63
- };
64
- Cast2.toNumber = (input) => {
65
- const { Text: Text2 } = Window.get();
66
- if (typeof input === "boolean") return input ? 1 : 0;
67
- if (typeof input === "number") return input;
68
- if (typeof input === "string") return parseFloat(`${input}`);
69
- if (input instanceof Text2) return parseFloat(`${input.textContent}`);
70
- return 0;
71
- };
72
- Cast2.toString = (input) => {
73
- if (typeof input === "string") return input;
74
- if (typeof input === "number" || typeof input === "boolean" || input === null) return `${input}`;
75
- const { Element: Element2, Text: Text2, NodeList } = Window.get();
76
- if (input instanceof Element2) return input.outerHTML;
77
- if (input instanceof Text2) return input.textContent ?? "";
78
- if (input instanceof NodeList) return Array.from(input).map((e) => {
79
- if (e instanceof Element2) return e.outerHTML;
80
- return e.textContent;
81
- }).join("");
82
- if (Array.isArray(input)) return input.map(Cast2.toString).join("");
83
- if (input instanceof Method) return `[Method:${input.transformer.name}]`;
84
- return `{${Object.entries(input).map(([key, val]) => `${key}:"${(0, Cast2.toString)(val)}"`).join(",")}}`;
85
- };
86
- Cast2.toText = (input) => {
87
- const { Text: Text2, document: document2 } = Window.get();
88
- if (input instanceof Text2) return input.cloneNode(true);
89
- return document2.createTextNode((0, Cast2.toString)(input));
90
- };
91
- Cast2.toElement = (input) => {
92
- const { Element: Element2, Text: Text2, NodeList, document: document2 } = Window.get();
93
- if (input instanceof Element2) return input.cloneNode(true);
94
- const returned = document2.createElement("div");
95
- if (input instanceof Text2) {
96
- returned.append(input.cloneNode(true));
97
- return returned;
98
- }
99
- if (input instanceof NodeList) {
100
- returned.append(...Array.from(input).map((e) => e.cloneNode(true)));
101
- return returned;
102
- }
103
- if (Array.isArray(input)) return returned;
104
- if (isRecord(input)) return returned;
105
- returned.innerHTML = `${input}`;
106
- return returned;
107
- };
108
- Cast2.toNodeList = (input) => {
109
- const { Element: Element2, Text: Text2, NodeList, document: document2 } = Window.get();
110
- const parentDiv = document2.createElement("div");
111
- if (input instanceof NodeList) {
112
- parentDiv.append(...Array.from(input).map((i) => i.cloneNode(true)));
113
- return parentDiv.childNodes;
114
- }
115
- if (input instanceof Element2 || input instanceof Text2) {
116
- parentDiv.append(input.cloneNode(true));
117
- return parentDiv.childNodes;
118
- }
119
- if (Array.isArray(input)) {
120
- input.forEach((item) => {
121
- if (typeof item === "number" || typeof item === "boolean" || item === null) parentDiv.append(`${item}`);
122
- else if (typeof item === "string" || item instanceof Text2 || item instanceof Element2) parentDiv.append(item);
123
- else if (item instanceof NodeList) parentDiv.append(...Array.from(item));
124
- else if (Array.isArray(item)) parentDiv.append(...Array.from((0, Cast2.toNodeList)(item)));
125
- else parentDiv.append((0, Cast2.toString)(item));
126
- });
127
- return parentDiv.childNodes;
128
- }
129
- if (isRecord(input)) {
130
- parentDiv.append((0, Cast2.toString)(input));
131
- return parentDiv.childNodes;
132
- }
133
- parentDiv.innerHTML = `${input}`;
134
- return parentDiv.childNodes;
135
- };
136
- Cast2.toArray = (input) => {
137
- const { NodeList } = Window.get();
138
- if (Array.isArray(input)) return [...input];
139
- if (input instanceof NodeList) return Array.from(input);
140
- return [input];
141
- };
142
- Cast2.toRecord = (input) => {
143
- const isRecord2 = Utils.Tree.TypeChecks.typeCheck(input, "record");
144
- if (isRecord2.success) return { ...isRecord2.payload };
145
- return {};
146
- };
147
- })(Cast || (Cast = {}));
148
-
149
- // src/agnostic/html/hyper-json/smart-tags/isolated/element/index.ts
150
- var element = SmartTags.makeSmartTag({
151
- name: "element",
152
- defaultMode: "isolation",
153
- isolationInitType: "array",
154
- mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "string", "text"),
155
- argsValueCheck: (a) => Utils.Tree.TypeChecks.typeCheckMany(a, "null", "boolean", "number", "string", "text", "element", "nodelist"),
156
- func: (main, args) => {
157
- const tagName = Cast.toString(main).trim().toLowerCase();
158
- const { document: document2, NodeList } = Window.get();
159
- const elt = document2.createElement(tagName);
160
- for (const argVal of args) {
161
- if (argVal instanceof NodeList) elt.append(...Array.from(argVal));
162
- else if (argVal instanceof Element) elt.append(argVal);
163
- else elt.append(Cast.toText(argVal));
164
- }
165
- return Outcome.makeSuccess(elt);
166
- }
167
- });
168
-
169
- // src/agnostic/html/hyper-json/smart-tags/isolated/get/index.ts
170
- var get = SmartTags.makeSmartTag({
171
- name: "get",
172
- defaultMode: "isolation",
173
- isolationInitType: "array",
174
- mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "string", "text"),
175
- argsValueCheck: (a) => Utils.SmartTags.expectEmptyArgs(a),
176
- func: (main, _args, { sourceTree }) => {
177
- const { makeSuccess, makeFailure } = Outcome;
178
- const { makeTransformationError } = Utils.SmartTags;
179
- const strName = Cast.toString(main);
180
- const found = sourceTree.getVariable(strName);
181
- if (found === void 0) return makeFailure(makeTransformationError(`No variable stored under the name '${strName}'`));
182
- return makeSuccess(found);
183
- }
184
- });
185
-
186
- // src/agnostic/html/hyper-json/smart-tags/isolated/global/index.ts
187
- var global = SmartTags.makeSmartTag({
188
- name: "global",
189
- defaultMode: "isolation",
190
- isolationInitType: "array",
191
- mainValueCheck: (m) => Outcome.makeSuccess(m),
192
- argsValueCheck: (a) => Utils.SmartTags.expectEmptyArgs(a),
193
- func: (_m, _a, { sourceTree }) => {
194
- const globalObject = sourceTree.options.globalObject ?? {};
195
- return Outcome.makeSuccess({ ...globalObject });
196
- }
197
- });
198
-
199
- // src/agnostic/html/hyper-json/smart-tags/isolated/guess/index.ts
200
- var guess = SmartTags.makeSmartTag({
201
- name: "guess",
202
- defaultMode: "isolation",
203
- isolationInitType: "string",
204
- mainValueCheck: (m) => Outcome.makeSuccess(m),
205
- argsValueCheck: (a) => Outcome.makeSuccess(a),
206
- func: (main, args) => {
207
- const { typeCheck } = Utils.Tree.TypeChecks;
208
- const { makeSuccess } = Outcome;
209
- let coalesced = main;
210
- for (const arg of args) coalesced = Utils.coalesceValues(coalesced, 0, arg);
211
- const { Text: Text2, Element: Element2, document: document2 } = Window.get();
212
- if (typeof coalesced !== "string" && !(coalesced instanceof Text2)) return makeSuccess(coalesced);
213
- const strCoalesced = Cast.toString(coalesced);
214
- if (strCoalesced.trim().toLowerCase() === "true") return makeSuccess(true);
215
- if (strCoalesced.trim().toLowerCase() === "false") return makeSuccess(false);
216
- if (strCoalesced.trim().toLowerCase().match(/^\s*-?\s*(\d+(\.\d*)?|\.\d+)\s*$/)) return makeSuccess(parseFloat(strCoalesced));
217
- if (strCoalesced.trim().toLowerCase() === "null") return makeSuccess(null);
218
- try {
219
- const parsed = JSON.parse(strCoalesced);
220
- const arrayChecked = typeCheck(parsed, "array");
221
- const recordChecked = typeCheck(parsed, "record");
222
- if (arrayChecked.success) return makeSuccess(arrayChecked.payload);
223
- if (recordChecked.success) return makeSuccess(recordChecked.payload);
224
- } catch (err) {
225
- }
226
- const div = document2.createElement("div");
227
- div.innerHTML = strCoalesced;
228
- const divChildren = div.childNodes;
229
- if (divChildren.length === 0) return makeSuccess(coalesced);
230
- const validDivChildren = Cast.toNodeList(Array.from(divChildren).filter((e) => {
231
- if (e instanceof Element2) return true;
232
- if (e instanceof Text2) return true;
233
- return false;
234
- }));
235
- if (validDivChildren.length > 1) return makeSuccess(validDivChildren);
236
- const validDivFirstchild = validDivChildren.item(0);
237
- if (validDivChildren.length === 1 && validDivFirstchild instanceof Element2) return makeSuccess(validDivFirstchild);
238
- return makeSuccess(coalesced);
239
- }
240
- });
241
-
242
- // src/agnostic/html/hyper-json/smart-tags/isolated/nodelist/index.ts
243
- var nodelist = SmartTags.makeSmartTag({
244
- name: "nodelist",
245
- defaultMode: "isolation",
246
- isolationInitType: "nodelist",
247
- mainValueCheck: (m) => Outcome.makeSuccess(m),
248
- argsValueCheck: (a) => Outcome.makeSuccess(a),
249
- func: (main, args) => {
250
- const { document: document2 } = Window.get();
251
- const returnedParent = document2.createDocumentFragment();
252
- returnedParent.append(
253
- ...Array.from(Cast.toNodeList(main)),
254
- ...Array.from(Cast.toNodeList(args))
255
- );
256
- const returned = returnedParent.childNodes;
257
- return Outcome.makeSuccess(returned);
258
- }
259
- });
260
-
261
- // src/agnostic/html/hyper-json/smart-tags/isolated/number/index.ts
262
- var number = SmartTags.makeSmartTag({
263
- name: "number",
264
- defaultMode: "isolation",
265
- isolationInitType: "number",
266
- mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "null", "boolean", "number", "string", "text"),
267
- argsValueCheck: (a) => Utils.Tree.TypeChecks.typeCheckMany(a, "null", "boolean", "number", "string", "text"),
268
- func: (main, args) => {
269
- const all = [main, ...args];
270
- const reduced = all.reduce((reduced2, curr) => {
271
- return reduced2 + Cast.toNumber(curr);
272
- }, 0);
273
- return Outcome.makeSuccess(reduced);
274
- }
275
- });
276
-
277
- // src/agnostic/html/hyper-json/smart-tags/isolated/record/index.ts
278
- var record = SmartTags.makeSmartTag({
279
- name: "record",
280
- defaultMode: "isolation",
281
- isolationInitType: "record",
282
- mainValueCheck: (i) => Utils.Tree.TypeChecks.typeCheck(i, "record"),
283
- argsValueCheck: (a) => Utils.Tree.TypeChecks.typeCheckMany(a, "record"),
284
- func: (main, args) => Outcome.makeSuccess(args.reduce((reduced, current) => ({
285
- ...reduced,
286
- ...current
287
- }), main))
288
- });
289
-
290
- // src/agnostic/html/hyper-json/smart-tags/isolated/ref/index.ts
291
- var func = (main, _args, { sourceTree }) => {
292
- const { makeFailure, makeSuccess } = Outcome;
293
- const { makeTransformationError } = Utils.SmartTags;
294
- const strMain = Cast.toString(main);
295
- const resolveFrom = strMain.startsWith("/") ? sourceTree.root : sourceTree;
296
- const splitted = strMain.split("/").filter((e) => e.trim() !== "").map((e) => {
297
- const looksLikeNumber = e.match(/^\d+$/igm);
298
- if (looksLikeNumber === null) return e;
299
- const parsed = parseInt(e);
300
- if (Number.isNaN(parsed)) return e;
301
- return parsed;
302
- });
303
- const resolved = resolveFrom.resolve(splitted);
304
- if (resolved === void 0) return makeFailure(makeTransformationError(`No value was found at path: ${strMain}`));
305
- if (resolved === sourceTree) return makeFailure(makeTransformationError("A ref node cannot reference itself."));
306
- if (resolved.parents.includes(sourceTree)) return makeFailure(makeTransformationError("A ref node cannot reference one of its parents."));
307
- if (sourceTree.parents.includes(resolved)) return makeFailure(makeTransformationError("A ref node cannot reference one of its children."));
308
- const evaluated = resolved.evaluate();
309
- const { getType } = Utils.Tree.TypeChecks;
310
- if (getType(evaluated) === "transformer") {
311
- const transformer = evaluated;
312
- return makeSuccess(transformer.toMethod());
313
- }
314
- return makeSuccess(evaluated);
315
- };
316
- var ref = SmartTags.makeSmartTag({
317
- name: "ref",
318
- defaultMode: "isolation",
319
- isolationInitType: "array",
320
- mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "string", "text"),
321
- argsValueCheck: (a) => Utils.SmartTags.expectEmptyArgs(a),
322
- func
323
- });
324
-
325
- // src/agnostic/html/hyper-json/smart-tags/isolated/string/index.ts
326
- var string = SmartTags.makeSmartTag({
327
- name: "string",
328
- defaultMode: "isolation",
329
- isolationInitType: "string",
330
- mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "null", "boolean", "number", "string", "text", "element", "nodelist"),
331
- argsValueCheck: (a) => Utils.Tree.TypeChecks.typeCheckMany(a, "null", "boolean", "number", "string", "text", "element", "nodelist"),
332
- func: (main, args) => {
333
- const all = [main, ...args];
334
- const reduced = all.reduce((reduced2, curr) => {
335
- return `${reduced2}${Cast.toString(curr)}`;
336
- }, "");
337
- return Outcome.makeSuccess(reduced);
338
- }
339
- });
340
-
341
- // src/agnostic/html/hyper-json/smart-tags/isolated/text/index.ts
342
- var text = SmartTags.makeSmartTag({
343
- name: "text",
344
- defaultMode: "isolation",
345
- isolationInitType: "text",
346
- mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "null", "boolean", "number", "string", "text", "element", "nodelist"),
347
- argsValueCheck: (a) => Utils.Tree.TypeChecks.typeCheckMany(a, "null", "boolean", "number", "string", "text", "element", "nodelist"),
348
- func: (main, args) => {
349
- const all = [main, ...args];
350
- const reduced = all.reduce((reduced2, curr) => {
351
- return Cast.toText(`${reduced2}${Cast.toText(curr)}`);
352
- }, Cast.toText(""));
353
- return Outcome.makeSuccess(reduced);
354
- }
355
- });
356
-
357
- // src/agnostic/html/hyper-json/smart-tags/coalesced/add/index.ts
358
- var add = SmartTags.makeSmartTag({
359
- name: "add",
360
- defaultMode: "coalescion",
361
- isolationInitType: "array",
362
- mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "number", "string", "text"),
363
- argsValueCheck: (a) => Utils.Tree.TypeChecks.typeCheckMany(a, "number", "string", "text"),
364
- func: (main, args) => {
365
- const numMain = Cast.toNumber(main);
366
- const numArgs = args.map(Cast.toNumber);
367
- return Outcome.makeSuccess(numArgs.reduce((reduced, arg) => reduced + arg, numMain));
368
- }
369
- });
370
-
371
- // src/agnostic/html/hyper-json/smart-tags/coalesced/addclass/index.ts
372
- var addclass = SmartTags.makeSmartTag({
373
- name: "addclass",
374
- defaultMode: "coalescion",
375
- isolationInitType: "array",
376
- mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "element"),
377
- argsValueCheck: (a) => Utils.Tree.TypeChecks.typeCheckMany(a, "string", "text"),
378
- func: (main, args) => {
379
- main.classList.add(...args.map((arg) => Cast.toString(arg)));
380
- return Outcome.makeSuccess(main);
381
- }
382
- });
383
-
384
- // src/agnostic/html/hyper-json/smart-tags/coalesced/and/index.ts
385
- var and = SmartTags.makeSmartTag({
386
- name: "and",
387
- defaultMode: "coalescion",
388
- isolationInitType: "array",
389
- mainValueCheck: (m) => Outcome.makeSuccess(m),
390
- argsValueCheck: (a) => Outcome.makeSuccess(a),
391
- func: (main, args) => {
392
- const all = [main, ...args];
393
- const returned = all.every(Cast.toBoolean);
394
- return Outcome.makeSuccess(returned);
395
- }
396
- });
397
-
398
- // src/agnostic/html/hyper-json/smart-tags/coalesced/append/index.ts
399
- var append = SmartTags.makeSmartTag({
400
- name: "append",
401
- defaultMode: "coalescion",
402
- isolationInitType: "array",
403
- mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "string", "text", "nodelist", "element", "array"),
404
- argsValueCheck: (a) => Utils.Tree.TypeChecks.typeCheckMany(a, "string", "text", "nodelist", "element", "array"),
405
- func: (main, args) => {
406
- const { makeSuccess } = Outcome;
407
- const { Text: Text2, Element: Element2, NodeList, document: document2 } = Window.get();
408
- if (Array.isArray(main)) return makeSuccess([...main, ...args]);
409
- if (main instanceof Element2) {
410
- main.append(...Array.from(Cast.toNodeList(args)));
411
- return makeSuccess(main);
412
- }
413
- if (main instanceof NodeList) {
414
- const frag = document2.createDocumentFragment();
415
- frag.append(
416
- ...Array.from(main),
417
- ...Array.from(Cast.toNodeList(args))
418
- );
419
- return makeSuccess(frag.childNodes);
420
- }
421
- if (main instanceof Text2) {
422
- const reducedString = args.reduce((reduced, arg) => {
423
- return `${reduced}${Cast.toString(arg)}`;
424
- }, Cast.toString(main));
425
- return makeSuccess(Cast.toText(reducedString));
426
- }
427
- return makeSuccess(args.reduce((reduced, arg) => {
428
- return `${reduced}${Cast.toString(arg)}`;
429
- }, main));
430
- }
431
- });
432
-
433
- // src/agnostic/html/hyper-json/smart-tags/coalesced/at/index.ts
434
- var at = SmartTags.makeSmartTag({
435
- name: "at",
436
- defaultMode: "coalescion",
437
- isolationInitType: "array",
438
- mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "string", "text", "array", "nodelist"),
439
- argsValueCheck: (a) => {
440
- const { makeFailure, makeSuccess } = Outcome;
441
- const { makeArgsValueError } = Utils.SmartTags;
442
- const { getType, typeCheckMany } = Utils.Tree.TypeChecks;
443
- if (a.length === 0) return makeFailure(makeArgsValueError("number | string | text", "undefined", 0));
444
- if (a.length > 1) return makeFailure(makeArgsValueError("undefined", getType(a[1]) ?? "undefined", 1));
445
- const checked = typeCheckMany(a, "number", "string", "text");
446
- if (checked.success) return makeSuccess(a);
447
- return checked;
448
- },
449
- func: (main, args) => {
450
- const { makeFailure, makeSuccess } = Outcome;
451
- const { makeTransformationError } = Utils.SmartTags;
452
- const pos = args[0];
453
- const numPos = Cast.toNumber(pos);
454
- let found;
455
- const { NodeList } = Window.get();
456
- if (typeof main === "string" || Array.isArray(main) || main instanceof NodeList) {
457
- found = main[numPos];
458
- } else {
459
- const strMain = Cast.toString(main);
460
- found = strMain[numPos];
461
- }
462
- if (found === void 0) return makeFailure(makeTransformationError({
463
- message: "Property does not exist"
464
- // [WIP] maybe more details here ?
465
- }));
466
- return makeSuccess(found);
467
- }
468
- });
469
-
470
- // src/agnostic/html/hyper-json/smart-tags/coalesced/call/index.ts
471
- var call = SmartTags.makeSmartTag({
472
- name: "call",
473
- defaultMode: "coalescion",
474
- isolationInitType: "array",
475
- mainValueCheck: (m) => {
476
- const { makeFailure } = Outcome;
477
- const { typeCheck, typeCheckMany, getType } = Utils.Tree.TypeChecks;
478
- const { makeMainValueError } = Utils.SmartTags;
479
- const isMethodCheck = typeCheck(m, "method");
480
- if (isMethodCheck.success) return isMethodCheck;
481
- if (!Array.isArray(m)) return makeFailure({
482
- expected: "method[]",
483
- found: getType(m) ?? "undefined"
484
- });
485
- const isMethodsArrayCheck = typeCheckMany(m, "method");
486
- if (isMethodsArrayCheck.success) return isMethodsArrayCheck;
487
- return makeFailure(makeMainValueError("method | method[]", getType(m) ?? "undefined"));
488
- },
489
- argsValueCheck: (a) => Utils.Tree.TypeChecks.typeCheckMany(a, "array"),
490
- func: (main, args) => {
491
- const { makeFailure, makeSuccess } = Outcome;
492
- const { makeTransformationError } = Utils.SmartTags;
493
- const mainArr = Array.isArray(main) ? main : [main];
494
- let reduced = args;
495
- for (const method of mainArr) {
496
- const { transformer } = method;
497
- const applied = transformer.apply(reduced);
498
- if (applied.success) {
499
- reduced = applied.payload;
500
- }
501
- return makeFailure(makeTransformationError({
502
- message: "Subtransformation failure.",
503
- onTransformed: reduced,
504
- transformerAt: mainArr.indexOf(method),
505
- transformerName: transformer.name,
506
- transformerOutput: applied
507
- }));
508
- }
509
- return makeSuccess(reduced);
510
- }
511
- });
512
-
513
- // src/agnostic/html/hyper-json/smart-tags/coalesced/clone/index.ts
514
- var clone = SmartTags.makeSmartTag({
515
- name: "clone",
516
- defaultMode: "coalescion",
517
- isolationInitType: "array",
518
- mainValueCheck: (m) => Outcome.makeSuccess(m),
519
- argsValueCheck: (a) => Utils.SmartTags.expectEmptyArgs(a),
520
- func: (main) => Outcome.makeSuccess(Utils.clone(main))
521
- });
522
-
523
- // src/agnostic/html/hyper-json/smart-tags/coalesced/deleteproperties/index.ts
524
- var deleteproperties = SmartTags.makeSmartTag({
525
- name: "deleteproperties",
526
- defaultMode: "coalescion",
527
- isolationInitType: "array",
528
- mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "record"),
529
- argsValueCheck: (a) => Utils.Tree.TypeChecks.typeCheckMany(a, "string", "text"),
530
- func: (main, args) => {
531
- const { makeFailure, makeSuccess } = Outcome;
532
- const { makeTransformationError } = Utils.SmartTags;
533
- let returned = Utils.clone(main);
534
- for (const arg of args) {
535
- const strArg = Cast.toString(arg);
536
- try {
537
- returned = deepDeleteProperty(returned, strArg);
538
- } catch (err) {
539
- return makeFailure(makeTransformationError(`Cannot access ${strArg} from input record`));
540
- }
541
- }
542
- return makeSuccess(returned);
543
- }
544
- });
545
- function deepDeleteProperty(record2, pathString) {
546
- const cloned = Utils.clone(record2);
547
- const pathChunks = pathString.split(".");
548
- let currentRecord = cloned;
549
- pathChunks.forEach((chunk, pos) => {
550
- const isLast = pos === pathChunks.length - 1;
551
- if (isLast) delete currentRecord[chunk];
552
- else {
553
- const found = currentRecord[chunk];
554
- if (isRecord(found)) currentRecord = found;
555
- else throw "not a record";
556
- }
557
- });
558
- return cloned;
559
- }
560
-
561
- // src/agnostic/html/hyper-json/smart-tags/coalesced/equals/index.ts
562
- var equals = SmartTags.makeSmartTag({
563
- name: "equals",
564
- defaultMode: "coalescion",
565
- isolationInitType: "array",
566
- mainValueCheck: (m) => Outcome.makeSuccess(m),
567
- argsValueCheck: (a) => {
568
- const [first, ...others] = a;
569
- if (first === void 0) return Outcome.makeFailure(Utils.SmartTags.makeArgsValueError(
570
- "value",
571
- "undefined",
572
- 0
573
- ));
574
- const returned = [first, ...others];
575
- return Outcome.makeSuccess(returned);
576
- },
577
- func: (main, args) => {
578
- const { Text: Text2 } = Window.get();
579
- const normalizedMain = main instanceof Text2 ? Cast.toString(main) : main;
580
- const normalizedArgs = args.map((a) => a instanceof Text2 ? Cast.toString(a) : a);
581
- return Outcome.makeSuccess(normalizedArgs.every((arg) => arg === normalizedMain));
582
- }
583
- });
584
-
585
- // src/agnostic/html/hyper-json/smart-tags/coalesced/getattribute/index.ts
586
- var getattribute = SmartTags.makeSmartTag({
587
- name: "getattribute",
588
- defaultMode: "coalescion",
589
- isolationInitType: "array",
590
- mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "element"),
591
- argsValueCheck: (a) => {
592
- const { makeFailure, makeSuccess } = Outcome;
593
- const { typeCheckMany, getType } = Utils.Tree.TypeChecks;
594
- const { makeArgsValueError } = Utils.SmartTags;
595
- if (a.length === 0) return makeFailure(makeArgsValueError("string | Text", "undefined", 0));
596
- if (a.length > 1) return makeFailure(makeArgsValueError("undefined", getType(a[2]) ?? "undefined", 1));
597
- const checked = typeCheckMany(a, "string", "text");
598
- if (checked.success) return makeSuccess(checked.payload);
599
- return checked;
600
- },
601
- func: (main, args) => {
602
- const name = Cast.toString(args[0]);
603
- const found = main.getAttribute(name);
604
- return Outcome.makeSuccess(found);
605
- }
606
- });
607
-
608
- // src/agnostic/html/hyper-json/smart-tags/coalesced/getproperties/index.ts
609
- var getproperties = SmartTags.makeSmartTag({
610
- name: "getproperties",
611
- defaultMode: "coalescion",
612
- isolationInitType: "array",
613
- mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "record"),
614
- argsValueCheck: (a) => Utils.Tree.TypeChecks.typeCheckMany(a, "string", "text"),
615
- func: (main, args) => {
616
- const reduced = args.reduce((reduced2, curr) => {
617
- const key = Cast.toString(curr);
618
- const val = main[key];
619
- if (val === void 0) return { ...reduced2 };
620
- return { ...reduced2, [key]: val };
621
- }, {});
622
- return Outcome.makeSuccess(reduced);
623
- }
624
- });
625
-
626
- // src/agnostic/html/hyper-json/smart-tags/coalesced/getproperty/index.ts
627
- var getproperty = SmartTags.makeSmartTag({
628
- name: "getproperty",
629
- defaultMode: "coalescion",
630
- isolationInitType: "array",
631
- mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "record"),
632
- argsValueCheck: (a) => {
633
- const { makeFailure, makeSuccess } = Outcome;
634
- const { makeArgsValueError } = Utils.SmartTags;
635
- const { getType, typeCheckMany } = Utils.Tree.TypeChecks;
636
- if (a.length === 0) return makeFailure(makeArgsValueError("string | Text", "undefined", 0));
637
- if (a.length !== 1) return makeFailure(makeArgsValueError("undefined", getType(a.at(1)) ?? "undefined", 1));
638
- const checked = typeCheckMany(a, "string", "text");
639
- if (!checked.success) return checked;
640
- return makeSuccess(checked.payload);
641
- },
642
- func: (main, args) => {
643
- const { getType } = Utils.Tree.TypeChecks;
644
- const { makeTransformationError } = Utils.SmartTags;
645
- const { makeFailure, makeSuccess } = Outcome;
646
- const [propName] = args;
647
- const strPropName = Cast.toString(propName);
648
- try {
649
- const found = deepGetProperty(main, strPropName);
650
- const foundType = getType(found);
651
- if (foundType !== "transformer") return makeSuccess(found);
652
- return makeFailure(makeTransformationError(`Forbidden access to key: '${strPropName}'`));
653
- } catch (err) {
654
- return makeFailure(makeTransformationError(`Impossible to access ${strPropName}`));
655
- }
656
- }
657
- });
658
- function deepGetProperty(record2, pathString) {
659
- const pathChunks = pathString.split(".").map((e) => e.trim()).filter((e) => e !== "");
660
- let currentRecord = record2;
661
- let returned = currentRecord;
662
- pathChunks.forEach((chunk, pos) => {
663
- const isLast = pos === pathChunks.length - 1;
664
- if (isLast) {
665
- const val = currentRecord[chunk];
666
- if (val === void 0) throw "PROP_UNDEFINED";
667
- returned = val;
668
- } else {
669
- const found = currentRecord[chunk];
670
- if (isRecord(found)) currentRecord = found;
671
- else throw "NOT_A_RECORD";
672
- }
673
- });
674
- return returned;
675
- }
676
-
677
- // src/agnostic/html/hyper-json/smart-tags/coalesced/if/index.ts
678
- var ifFunc = SmartTags.makeSmartTag({
679
- name: "if",
680
- defaultMode: "coalescion",
681
- isolationInitType: "array",
682
- mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "boolean"),
683
- argsValueCheck: (a) => {
684
- const { makeFailure, makeSuccess } = Outcome;
685
- const { makeArgsValueError } = Utils.SmartTags;
686
- if (a.length > 2) return makeFailure(makeArgsValueError("value", "undefined", a.length));
687
- if (a.length < 2) return makeFailure(makeArgsValueError("undefined", "value", 2));
688
- return makeSuccess(a);
689
- },
690
- func: (main, args) => {
691
- const [then, otherwise] = args;
692
- return Outcome.makeSuccess(main ? then : otherwise);
693
- }
694
- });
695
-
696
- // src/agnostic/html/hyper-json/smart-tags/coalesced/initialize/index.ts
697
- var initialize = SmartTags.makeSmartTag({
698
- name: "initialize",
699
- defaultMode: "coalescion",
700
- isolationInitType: "array",
701
- mainValueCheck: (m) => Outcome.makeSuccess(m),
702
- argsValueCheck: (a) => {
703
- const { makeFailure, makeSuccess } = Outcome;
704
- const { getType, typeCheck } = Utils.Tree.TypeChecks;
705
- const { makeArgsValueError } = Utils.SmartTags;
706
- const first = a[0];
707
- if (first === void 0) return makeFailure(makeArgsValueError("string | text", "undefined", 0));
708
- if (a.length > 1) return makeFailure(makeArgsValueError("undefined", getType(a[1]) ?? "undefined", 1));
709
- const firstChecked = typeCheck(first, "string", "text");
710
- if (!firstChecked.success) return makeFailure(makeArgsValueError(firstChecked.error.expected, firstChecked.error.found, 0));
711
- return makeSuccess(a);
712
- },
713
- func: (_main, args) => {
714
- const { makeFailure, makeSuccess } = Outcome;
715
- const { makeTransformationError } = Utils.SmartTags;
716
- const { getInitialValueFromTypeName } = Utils.Tree;
717
- const { isValueTypeName } = Utils.Tree.TypeChecks;
718
- const firstArg = args[0];
719
- const strFirstArg = Cast.toString(firstArg).trim().toLowerCase();
720
- const isValueType = isValueTypeName(strFirstArg);
721
- if (!isValueType || strFirstArg === "transformer" || strFirstArg === "method") return makeFailure(makeTransformationError(`${strFirstArg} is not a valid type`));
722
- const initialized = getInitialValueFromTypeName(strFirstArg);
723
- return makeSuccess(initialized);
724
- }
725
- });
726
-
727
- // src/agnostic/html/hyper-json/smart-tags/coalesced/join/index.ts
728
- var join = SmartTags.makeSmartTag({
729
- name: "join",
730
- defaultMode: "coalescion",
731
- isolationInitType: "array",
732
- mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "array", "nodelist"),
733
- argsValueCheck: (a) => Utils.Tree.TypeChecks.typeCheckMany(a, "string", "text"),
734
- func: (main, args) => {
735
- const { makeSuccess } = Outcome;
736
- const joiner = Cast.toString(args);
737
- if (Array.isArray(main)) return makeSuccess(main.map(Cast.toString).join(joiner));
738
- return makeSuccess(Array.from(main).map(Cast.toString).join(joiner));
739
- }
740
- });
741
-
742
- // src/agnostic/html/hyper-json/smart-tags/coalesced/length/index.ts
743
- var length = SmartTags.makeSmartTag({
744
- name: "length",
745
- defaultMode: "coalescion",
746
- isolationInitType: "array",
747
- mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "string", "nodelist"),
748
- argsValueCheck: (a) => Utils.SmartTags.expectEmptyArgs(a),
749
- func: (main) => {
750
- const { makeSuccess } = Outcome;
751
- const { Text: Text2, NodeList, Element: Element2 } = Window.get();
752
- if (typeof main === "string" || main instanceof NodeList || main instanceof Text2 || Array.isArray(main)) return makeSuccess(main.length);
753
- if (main instanceof Element2) return makeSuccess(main.childNodes.length);
754
- return makeSuccess(Object.keys(main).length);
755
- }
756
- });
757
-
758
- // src/agnostic/html/hyper-json/smart-tags/coalesced/map/index.ts
759
- var map = SmartTags.makeSmartTag({
760
- name: "map",
761
- defaultMode: "coalescion",
762
- isolationInitType: "array",
763
- mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "array"),
764
- argsValueCheck: (a) => Utils.Tree.TypeChecks.typeCheckMany(a, "method"),
765
- func: (main, args) => {
766
- const { makeTransformationError } = Utils.SmartTags;
767
- let mapped = [];
768
- for (const val of main) {
769
- let reduced = val;
770
- for (const arg of args) {
771
- const { transformer } = arg;
772
- const applied = transformer.apply(reduced);
773
- if (!applied.success) return Outcome.makeFailure(makeTransformationError({
774
- message: "Subtransformation failure.",
775
- onTransformed: reduced,
776
- transformerAt: args.indexOf(arg),
777
- transformerName: transformer.name,
778
- transformerInput: reduced,
779
- transformerOutput: applied
780
- }));
781
- reduced = applied.payload;
782
- }
783
- mapped.push(reduced);
784
- }
785
- return Outcome.makeSuccess(mapped);
786
- }
787
- });
788
-
789
- // src/agnostic/html/hyper-json/smart-tags/coalesced/negate/index.ts
790
- var negate = SmartTags.makeSmartTag({
791
- name: "negate",
792
- defaultMode: "coalescion",
793
- isolationInitType: "array",
794
- mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "boolean"),
795
- argsValueCheck: (a) => Utils.SmartTags.expectEmptyArgs(a),
796
- func: (main) => Outcome.makeSuccess(!main)
797
- });
798
-
799
- // src/agnostic/html/hyper-json/smart-tags/coalesced/notrailing/index.ts
800
- var notrailing = SmartTags.makeSmartTag({
801
- name: "notrailing",
802
- defaultMode: "coalescion",
803
- isolationInitType: "array",
804
- mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "string", "text"),
805
- argsValueCheck: (a) => {
806
- const { makeSuccess, makeFailure } = Outcome;
807
- const { makeArgsValueError } = Utils.SmartTags;
808
- const { getType, typeCheck } = Utils.Tree.TypeChecks;
809
- if (a.length === 0) return makeSuccess([]);
810
- if (a.length > 1) return makeFailure(makeArgsValueError("undefined", getType(a[1]) ?? "undefined", 1));
811
- const [first] = a;
812
- const firstChecked = typeCheck(first, "string", "text");
813
- if (!firstChecked.success) return makeFailure(makeArgsValueError(
814
- firstChecked.error.expected,
815
- firstChecked.error.found,
816
- 0
817
- ));
818
- return makeSuccess([firstChecked.payload]);
819
- },
820
- func: (main, args) => {
821
- const strMain = Cast.toString(main);
822
- const firstArg = args[0];
823
- const strFirstArg = Cast.toString(firstArg ?? "/");
824
- let strOutput = strMain;
825
- while (strOutput.endsWith(strFirstArg)) strOutput = strOutput.slice(0, -1);
826
- if (typeof main === "string") return Outcome.makeSuccess(strOutput);
827
- return Outcome.makeSuccess(Cast.toText(strOutput));
828
- }
829
- });
830
-
831
- // src/agnostic/html/hyper-json/smart-tags/coalesced/or/index.ts
832
- var or = SmartTags.makeSmartTag({
833
- name: "or",
834
- defaultMode: "coalescion",
835
- isolationInitType: "array",
836
- mainValueCheck: (m) => Outcome.makeSuccess(m),
837
- argsValueCheck: (a) => Outcome.makeSuccess(a),
838
- func: (main, args) => {
839
- const all = [main, ...args];
840
- const returned = all.some(Cast.toBoolean);
841
- return Outcome.makeSuccess(returned);
842
- }
843
- });
844
-
845
- // src/agnostic/html/hyper-json/smart-tags/coalesced/pickrandom/index.ts
846
- var pickrandom = SmartTags.makeSmartTag({
847
- name: "pickrandom",
848
- defaultMode: "coalescion",
849
- isolationInitType: "array",
850
- mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "array"),
851
- argsValueCheck: (a) => Utils.SmartTags.expectEmptyArgs(a),
852
- func: (main) => {
853
- const { makeSuccess, makeFailure } = Outcome;
854
- const { makeTransformationError } = Utils.SmartTags;
855
- const pos = Math.floor(Math.random() * main.length);
856
- const found = main[pos];
857
- if (found === void 0) return makeFailure(makeTransformationError("Cannot pick inside empty array"));
858
- return makeSuccess(found);
859
- }
860
- });
861
-
862
- // src/agnostic/html/hyper-json/smart-tags/coalesced/print/index.ts
863
- var print = SmartTags.makeSmartTag({
864
- name: "print",
865
- defaultMode: "coalescion",
866
- isolationInitType: "array",
867
- mainValueCheck: (m) => {
868
- const { getType } = Utils.Tree.TypeChecks;
869
- const { makeSuccess, makeFailure } = Outcome;
870
- const { makeMainValueError } = Utils.SmartTags;
871
- return getType(m) === "transformer" ? makeFailure(makeMainValueError("Exclude<value, transformer>", "transformer")) : makeSuccess(m);
872
- },
873
- argsValueCheck: (a) => Outcome.makeSuccess(a),
874
- func: (main, args, details) => {
875
- console.group("print");
876
- console.log("Main:", main);
877
- console.log("Args:", ...args);
878
- console.log("Tree:", details.sourceTree);
879
- console.groupEnd();
880
- return Outcome.makeSuccess(main);
881
- }
882
- });
883
-
884
- // src/agnostic/html/hyper-json/smart-tags/coalesced/populate/index.ts
885
- var populate = SmartTags.makeSmartTag({
886
- name: "populate",
887
- defaultMode: "coalescion",
888
- isolationInitType: "array",
889
- mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "record"),
890
- argsValueCheck: (a) => {
891
- const [first, ...others] = a;
892
- const { makeFailure, makeSuccess } = Outcome;
893
- const { makeArgsValueError } = Utils.SmartTags;
894
- const { typeCheck, typeCheckMany, getType } = Utils.Tree.TypeChecks;
895
- const firstChecked = typeCheck(first, "string", "text", "nodelist", "element");
896
- if (!firstChecked.success) return makeFailure(makeArgsValueError(
897
- firstChecked.error.expected,
898
- firstChecked.error.found,
899
- 0
900
- ));
901
- const othersChecked = typeCheckMany(others, "array");
902
- if (!othersChecked.success) return makeFailure(makeArgsValueError(
903
- othersChecked.error.expected,
904
- othersChecked.error.found,
905
- othersChecked.error.position + 1
906
- ));
907
- for (const [argPos, arg] of Object.entries(othersChecked.payload)) {
908
- const argPosNum = parseInt(argPos);
909
- const [first2, second] = arg;
910
- const firstChecked2 = typeCheck(first2, "string", "text");
911
- const secondChecked = typeCheck(second, "string", "text");
912
- if (!firstChecked2.success || !secondChecked.success) return makeFailure(makeArgsValueError(
913
- "[string | Text, string | Text]",
914
- `[${getType(first2)}, ${getType(second)}]`,
915
- argPosNum + 1
916
- ));
917
- }
918
- return makeSuccess(a);
919
- },
920
- func: (main, args) => {
921
- const { makeSuccess, makeFailure } = Outcome;
922
- const { makeTransformationError } = Utils.SmartTags;
923
- const record2 = main;
924
- const [template, ...actions] = args;
925
- let returnedStr = Cast.toString(template);
926
- for (const [propName, toReplace] of actions) {
927
- try {
928
- const value = deepGetProperty(record2, Cast.toString(propName));
929
- const replaced = replaceAll(returnedStr, Cast.toString(toReplace), Cast.toString(value));
930
- returnedStr = replaced;
931
- } catch (err) {
932
- return makeFailure(makeTransformationError({
933
- message: "Something went wrong",
934
- subTransformerError: err
935
- }));
936
- }
937
- }
938
- const { Text: Text2, NodeList } = Window.get();
939
- if (typeof template === "string") return makeSuccess(returnedStr);
940
- if (template instanceof Text2) return makeSuccess(Cast.toText(returnedStr));
941
- if (template instanceof NodeList) return makeSuccess(Cast.toNodeList(returnedStr));
942
- return makeSuccess(Cast.toElement(returnedStr));
943
- }
944
- });
945
-
946
- // src/agnostic/html/hyper-json/smart-tags/coalesced/push/index.ts
947
- var push = SmartTags.makeSmartTag({
948
- name: "push",
949
- defaultMode: "coalescion",
950
- isolationInitType: "array",
951
- mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "array"),
952
- argsValueCheck: (a) => Outcome.makeSuccess(a),
953
- func: (main, args) => Outcome.makeSuccess([...main, ...args])
954
- });
955
-
956
- // src/agnostic/html/hyper-json/smart-tags/coalesced/pusheach/index.ts
957
- var pusheach = SmartTags.makeSmartTag({
958
- name: "pusheach",
959
- defaultMode: "coalescion",
960
- isolationInitType: "array",
961
- mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "array"),
962
- argsValueCheck: (a) => {
963
- const { makeSuccess, makeFailure } = Outcome;
964
- const { typeCheck } = Utils.Tree.TypeChecks;
965
- const { makeArgsValueError } = Utils.SmartTags;
966
- for (const [argPos, arg] of Object.entries(a)) {
967
- const numPos = parseInt(argPos);
968
- const checked = typeCheck(arg, "array");
969
- if (!checked.success) return makeFailure(makeArgsValueError(
970
- checked.error.expected,
971
- checked.error.found,
972
- numPos
973
- ));
974
- }
975
- return makeSuccess(a);
976
- },
977
- func: (main, args) => {
978
- const returned = [...main];
979
- for (const arg of args) {
980
- returned.push(...arg);
981
- }
982
- return Outcome.makeSuccess(returned);
983
- }
984
- });
985
-
986
- // src/agnostic/html/hyper-json/smart-tags/coalesced/recordtoarray/index.ts
987
- var recordtoarray = SmartTags.makeSmartTag({
988
- name: "recordtoarray",
989
- defaultMode: "coalescion",
990
- isolationInitType: "array",
991
- mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "record"),
992
- argsValueCheck: (a) => Utils.SmartTags.expectEmptyArgs(a),
993
- func: (main) => Outcome.makeSuccess(Object.values(main))
994
- });
995
-
996
- // src/agnostic/html/hyper-json/smart-tags/coalesced/removeattribute/index.ts
997
- var removeattribute = SmartTags.makeSmartTag({
998
- name: "removeattribute",
999
- defaultMode: "coalescion",
1000
- isolationInitType: "array",
1001
- mainValueCheck: (m) => {
1002
- const { typeCheck, typeCheckMany } = Utils.Tree.TypeChecks;
1003
- if (Array.isArray(m)) return typeCheckMany(m, "element");
1004
- return typeCheck(m, "element");
1005
- },
1006
- argsValueCheck: (a) => {
1007
- const { makeFailure, makeSuccess } = Outcome;
1008
- const { typeCheckMany, getType } = Utils.Tree.TypeChecks;
1009
- const { makeArgsValueError } = Utils.SmartTags;
1010
- if (a.length === 0) return makeFailure(makeArgsValueError("string | Text", "undefined", 0));
1011
- if (a.length > 1) return makeFailure(makeArgsValueError("undefined", getType(a[2]) ?? "undefined", 1));
1012
- const checked = typeCheckMany(a, "string", "text");
1013
- if (checked.success) return makeSuccess(checked.payload);
1014
- return checked;
1015
- },
1016
- func: (main, args) => {
1017
- const { makeSuccess } = Outcome;
1018
- const mainArr = Array.isArray(main) ? main : [main];
1019
- const mainArrCloned = mainArr.map((e) => Utils.clone(e));
1020
- const name = Cast.toString(args[0]);
1021
- mainArrCloned.forEach((e) => e.removeAttribute(name));
1022
- if (Array.isArray(main)) return makeSuccess(mainArrCloned);
1023
- return makeSuccess(mainArrCloned[0]);
1024
- }
1025
- });
1026
-
1027
- // src/agnostic/html/hyper-json/smart-tags/coalesced/removeclass/index.ts
1028
- var removeclass = SmartTags.makeSmartTag({
1029
- name: "removeclass",
1030
- defaultMode: "coalescion",
1031
- isolationInitType: "array",
1032
- mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "element"),
1033
- argsValueCheck: (a) => Utils.Tree.TypeChecks.typeCheckMany(a, "string", "text"),
1034
- func: (main, args) => {
1035
- main.classList.remove(...args.map((arg) => Cast.toString(arg)));
1036
- return Outcome.makeSuccess(main);
1037
- }
1038
- });
1039
-
1040
- // src/agnostic/html/hyper-json/smart-tags/coalesced/renameproperty/index.ts
1041
- var renameproperty = SmartTags.makeSmartTag({
1042
- name: "renameproperty",
1043
- defaultMode: "coalescion",
1044
- isolationInitType: "array",
1045
- mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "record"),
1046
- argsValueCheck: (a) => {
1047
- const { makeFailure, makeSuccess } = Outcome;
1048
- const { typeCheck, typeCheckMany } = Utils.Tree.TypeChecks;
1049
- const checked = typeCheckMany(a, "string", "text");
1050
- if (!checked.success) return checked;
1051
- const [first, second] = a;
1052
- const firstChecked = typeCheck(first, "string", "text");
1053
- if (!firstChecked.success) return makeFailure(Utils.SmartTags.makeArgsValueError(
1054
- firstChecked.error.expected,
1055
- firstChecked.error.found,
1056
- 0
1057
- ));
1058
- const secondChecked = typeCheck(second, "string", "text");
1059
- if (!secondChecked.success) return makeFailure(Utils.SmartTags.makeArgsValueError(
1060
- secondChecked.error.expected,
1061
- secondChecked.error.found,
1062
- 0
1063
- ));
1064
- return makeSuccess([firstChecked.payload, secondChecked.payload]);
1065
- },
1066
- func: (main, args) => {
1067
- const [oldKey, newKey] = args.map(Cast.toString);
1068
- const returned = {};
1069
- Object.entries(main).forEach(([key, value]) => {
1070
- const targetKey = key === oldKey ? newKey : key;
1071
- returned[targetKey] = value;
1072
- });
1073
- return Outcome.makeSuccess(returned);
1074
- }
1075
- });
1076
-
1077
- // src/agnostic/html/hyper-json/smart-tags/coalesced/replace/index.ts
1078
- var replace = SmartTags.makeSmartTag({
1079
- name: "replace",
1080
- defaultMode: "coalescion",
1081
- isolationInitType: "array",
1082
- mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "string", "text", "nodelist", "element"),
1083
- argsValueCheck: (a) => {
1084
- const { makeFailure, makeSuccess } = Outcome;
1085
- const { getType, typeCheckMany } = Utils.Tree.TypeChecks;
1086
- const { makeArgsValueError } = Utils.SmartTags;
1087
- const expectedStr = "string | Text | NodeListOf<Element | Text> | Element";
1088
- if (a.length === 0) return makeFailure(makeArgsValueError(expectedStr, "undefined", 0));
1089
- if (a.length === 1) return makeFailure(makeArgsValueError(expectedStr, "undefined", 1));
1090
- if (a.length > 2) return makeFailure(makeArgsValueError("undefined", getType(a.at(2)) ?? "undefined", 3));
1091
- const checked = typeCheckMany(a, "string", "text", "nodelist", "element");
1092
- if (!checked.success) return checked;
1093
- return makeSuccess(checked.payload);
1094
- },
1095
- func: (main, args) => {
1096
- const [toReplace, replacer] = args;
1097
- const strMain = Cast.toString(main);
1098
- const strToReplace = Cast.toString(toReplace);
1099
- const strReplacer = Cast.toString(replacer);
1100
- const strReplaced = replaceAll(strMain, strToReplace, strReplacer);
1101
- let returned;
1102
- if (typeof main === "string") {
1103
- returned = strReplaced;
1104
- } else if (main instanceof Text) {
1105
- returned = Cast.toText(strReplaced);
1106
- } else if (main instanceof Element) {
1107
- returned = Cast.toElement(strReplaced);
1108
- } else {
1109
- returned = Cast.toNodeList(strReplaced);
1110
- }
1111
- return Outcome.makeSuccess(returned);
1112
- }
1113
- });
1114
-
1115
- // src/agnostic/html/hyper-json/smart-tags/coalesced/select/index.ts
1116
- var select = SmartTags.makeSmartTag({
1117
- name: "select",
1118
- defaultMode: "coalescion",
1119
- isolationInitType: "array",
1120
- mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "nodelist", "element"),
1121
- argsValueCheck: (a) => Utils.Tree.TypeChecks.typeCheckMany(a, "string", "text"),
1122
- func: (main, args) => {
1123
- const selectedFragment = document.createDocumentFragment();
1124
- if (main instanceof Window.get().Element) {
1125
- for (const arg of args) {
1126
- const selector = Cast.toString(arg);
1127
- const found = main.querySelectorAll(selector);
1128
- selectedFragment.append(...Array.from(found));
1129
- }
1130
- } else {
1131
- const divWrapper = Window.get().document.createElement("div");
1132
- divWrapper.append(...Array.from(main));
1133
- for (const arg of args) {
1134
- const selector = Cast.toString(arg);
1135
- const found = divWrapper.querySelectorAll(selector);
1136
- selectedFragment.append(...Array.from(found));
1137
- }
1138
- }
1139
- const selected = selectedFragment.childNodes;
1140
- return Outcome.makeSuccess(selected);
1141
- }
1142
- });
1143
-
1144
- // src/agnostic/html/hyper-json/smart-tags/coalesced/set/index.ts
1145
- var set = SmartTags.makeSmartTag({
1146
- name: "set",
1147
- defaultMode: "coalescion",
1148
- isolationInitType: "array",
1149
- mainValueCheck: (m) => Outcome.makeSuccess(m),
1150
- argsValueCheck: (a) => {
1151
- const { makeFailure, makeSuccess } = Outcome;
1152
- const { makeArgsValueError } = Utils.SmartTags;
1153
- const { getType, typeCheck } = Utils.Tree.TypeChecks;
1154
- const first = a[0];
1155
- if (first === void 0) return makeFailure(makeArgsValueError("string | text", "undefined", 0));
1156
- if (a.length > 2) return makeFailure(makeArgsValueError("undefined", getType(a[2]) ?? "undefined", 2));
1157
- const firstChecked = typeCheck(first, "string", "text");
1158
- if (!firstChecked.success) return firstChecked;
1159
- else return makeSuccess(a);
1160
- },
1161
- func: (main, args, { sourceTree }) => {
1162
- const [first, second] = args;
1163
- const strFirst = Cast.toString(first);
1164
- sourceTree.setVariable(strFirst, second === void 0 ? main : second);
1165
- return Outcome.makeSuccess(main);
1166
- }
1167
- });
1168
-
1169
- // src/agnostic/html/hyper-json/smart-tags/coalesced/setattribute/index.ts
1170
- var setattribute = SmartTags.makeSmartTag({
1171
- name: "setattribute",
1172
- defaultMode: "coalescion",
1173
- isolationInitType: "array",
1174
- mainValueCheck: (m) => {
1175
- const { typeCheck, typeCheckMany } = Utils.Tree.TypeChecks;
1176
- if (Array.isArray(m)) return typeCheckMany(m, "element");
1177
- return typeCheck(m, "element");
1178
- },
1179
- argsValueCheck: (a) => {
1180
- const { makeFailure, makeSuccess } = Outcome;
1181
- const { typeCheckMany, getType } = Utils.Tree.TypeChecks;
1182
- const { makeArgsValueError } = Utils.SmartTags;
1183
- if (a.length === 0) return makeFailure(makeArgsValueError("string | Text", "undefined", 0));
1184
- if (a.length > 2) return makeFailure(makeArgsValueError("undefined", getType(a[2]) ?? "undefined", 2));
1185
- const checked = typeCheckMany(a, "string", "text");
1186
- if (checked.success) return makeSuccess(checked.payload);
1187
- return checked;
1188
- },
1189
- func: (main, args) => {
1190
- const mainArr = Array.isArray(main) ? main : [main];
1191
- const mainArrCloned = mainArr.map((e) => Utils.clone(e));
1192
- const argsStr = args.map((e) => Cast.toString(e));
1193
- const [name, value = ""] = argsStr;
1194
- mainArrCloned.forEach((e) => e.setAttribute(name, value));
1195
- if (Array.isArray(main)) return Outcome.makeSuccess(mainArrCloned);
1196
- return Outcome.makeSuccess(mainArrCloned[0]);
1197
- }
1198
- });
1199
-
1200
- // src/agnostic/html/hyper-json/smart-tags/coalesced/setproperties/index.ts
1201
- var setproperties = SmartTags.makeSmartTag({
1202
- name: "setproperties",
1203
- defaultMode: "coalescion",
1204
- isolationInitType: "array",
1205
- mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "record"),
1206
- argsValueCheck: (a) => {
1207
- const { makeFailure, makeSuccess } = Outcome;
1208
- const { makeArgsValueError } = Utils.SmartTags;
1209
- const { getType, typeCheck } = Utils.Tree.TypeChecks;
1210
- if (a.length === 0) return makeFailure(makeArgsValueError("record", "undefined", 0));
1211
- if (a.length > 1) return makeFailure(makeArgsValueError("undefined", getType(a.at(1)) ?? "undefined", 1));
1212
- const [first] = a;
1213
- const firstChecked = typeCheck(first, "record");
1214
- if (!firstChecked.success) return makeFailure(makeArgsValueError(firstChecked.error.expected, firstChecked.error.found, 0));
1215
- return makeSuccess([firstChecked.payload]);
1216
- },
1217
- func: (main, args) => Outcome.makeSuccess({ ...main, ...args[0] })
1218
- });
1219
-
1220
- // src/agnostic/html/hyper-json/smart-tags/coalesced/setproperty/index.ts
1221
- var setproperty = SmartTags.makeSmartTag({
1222
- name: "setproperty",
1223
- defaultMode: "coalescion",
1224
- isolationInitType: "array",
1225
- mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "record"),
1226
- argsValueCheck: (a) => {
1227
- const { makeFailure, makeSuccess } = Outcome;
1228
- const { makeArgsValueError } = Utils.SmartTags;
1229
- const { getType, typeCheck } = Utils.Tree.TypeChecks;
1230
- if (a.length === 0) return makeFailure(makeArgsValueError("string | Text", "undefined", 0));
1231
- if (a.length === 1) return makeFailure(makeArgsValueError("value", "undefined", 1));
1232
- if (a.length !== 2) return makeFailure(makeArgsValueError("undefined", getType(a.at(2)) ?? "undefined", 2));
1233
- const [first, second] = a;
1234
- const firstChecked = typeCheck(first, "string", "text");
1235
- if (!firstChecked.success) return makeFailure(makeArgsValueError(firstChecked.error.expected, firstChecked.error.found, 0));
1236
- return makeSuccess([firstChecked.payload, second]);
1237
- },
1238
- func: (main, args) => {
1239
- const [key, val] = args;
1240
- const { makeSuccess, makeFailure } = Outcome;
1241
- const { makeTransformationError } = Utils.SmartTags;
1242
- try {
1243
- const withPropertySet = deepSetProperty(
1244
- Utils.clone(main),
1245
- Cast.toString(key),
1246
- val
1247
- );
1248
- return makeSuccess(withPropertySet);
1249
- } catch (err) {
1250
- return makeFailure(makeTransformationError(`Impossible to access property :${key}`));
1251
- }
1252
- }
1253
- });
1254
- function deepSetProperty(record2, pathString, value) {
1255
- const pathChunks = pathString.split(".");
1256
- const clone2 = Utils.clone(record2);
1257
- let currentRecord = clone2;
1258
- pathChunks.forEach((chunk, pos) => {
1259
- const isLast = pos === pathChunks.length - 1;
1260
- if (isLast) {
1261
- currentRecord[chunk] = value;
1262
- } else {
1263
- const found = currentRecord[chunk];
1264
- if (isRecord(found)) currentRecord = found;
1265
- else throw "NOT_A_RECORD";
1266
- }
1267
- });
1268
- return clone2;
1269
- }
1270
-
1271
- // src/agnostic/html/hyper-json/smart-tags/coalesced/sorton/index.ts
1272
- var sorton = SmartTags.makeSmartTag({
1273
- name: "sorton",
1274
- defaultMode: "coalescion",
1275
- isolationInitType: "array",
1276
- mainValueCheck: (m) => {
1277
- const { makeMainValueError } = Utils.SmartTags;
1278
- const { getType } = Utils.Tree.TypeChecks;
1279
- const { makeFailure, makeSuccess } = Outcome;
1280
- if (!Array.isArray(m)) return makeFailure(makeMainValueError("array<record>", getType(m) ?? "undefined"));
1281
- for (const [itemPos, itemVal] of Object.entries(m)) {
1282
- if (isRecord(itemVal)) continue;
1283
- return makeFailure(makeMainValueError("record", getType(itemVal), `At position ${parseInt(itemPos)} in main value`));
1284
- }
1285
- return makeSuccess(m);
1286
- },
1287
- argsValueCheck: (a) => {
1288
- const { makeFailure, makeSuccess } = Outcome;
1289
- const { makeArgsValueError } = Utils.SmartTags;
1290
- const { getType, typeCheckMany } = Utils.Tree.TypeChecks;
1291
- if (a.length === 0) return makeFailure(makeArgsValueError("[string | text]", "[]", 0));
1292
- if (a.length > 1) return makeFailure(makeArgsValueError("undefined", getType(a[1]) ?? "undefined", 2));
1293
- const checked = typeCheckMany(a, "string", "text");
1294
- if (checked.success) return makeSuccess(checked.payload);
1295
- return checked;
1296
- },
1297
- func: (main, args) => {
1298
- const { makeFailure, makeSuccess } = Outcome;
1299
- const strPropName = Cast.toString(args[0]);
1300
- const { getType } = Utils.Tree.TypeChecks;
1301
- const { makeTransformationError } = Utils.SmartTags;
1302
- const map2 = main.map((record2) => {
1303
- const prop = record2[strPropName];
1304
- const type = getType(prop);
1305
- return { record: record2, prop, type };
1306
- });
1307
- const firstItem = map2[0];
1308
- if (firstItem === void 0) return makeSuccess([]);
1309
- const firstItemType = firstItem.type;
1310
- if (firstItemType === void 0) return makeFailure(makeTransformationError({
1311
- message: "Invalid property type",
1312
- onItem: 0,
1313
- found: firstItemType
1314
- }));
1315
- for (const [daytumPos, daytumVal] of Object.entries(map2)) {
1316
- if (daytumVal.type !== firstItemType) return makeFailure(makeTransformationError({
1317
- message: "Invalid property type",
1318
- onItem: parseInt(daytumPos),
1319
- expected: firstItemType,
1320
- found: daytumVal.type
1321
- }));
1322
- }
1323
- const sorted = main.sort((a, b) => {
1324
- const { Text: Text2, NodeList } = Window.get();
1325
- const aProp = a[strPropName];
1326
- const bProp = b[strPropName];
1327
- if (aProp === null) return 0;
1328
- if (typeof aProp === "boolean") {
1329
- if (aProp === bProp) return 0;
1330
- if (aProp) return 1;
1331
- return -1;
1332
- }
1333
- if (typeof aProp === "string") return aProp.localeCompare(Cast.toString(bProp));
1334
- if (aProp instanceof Text2) return Cast.toString(aProp).localeCompare(Cast.toString(bProp));
1335
- if (typeof aProp === "number") return aProp - Cast.toNumber(bProp);
1336
- if (Array.isArray(aProp)) return aProp.length - Cast.toArray(bProp).length;
1337
- if (aProp instanceof NodeList) return aProp.length - Cast.toNodeList(bProp).length;
1338
- return 0;
1339
- });
1340
- return makeSuccess(sorted);
1341
- }
1342
- });
1343
-
1344
- // src/agnostic/html/hyper-json/smart-tags/coalesced/split/index.ts
1345
- var split = SmartTags.makeSmartTag({
1346
- name: "split",
1347
- defaultMode: "coalescion",
1348
- isolationInitType: "array",
1349
- mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "string", "text"),
1350
- argsValueCheck: (a) => Utils.Tree.TypeChecks.typeCheckMany(a, "string", "text"),
1351
- func: (main, args) => {
1352
- let strReturnedArr = [Cast.toString(main)];
1353
- for (const arg of args) {
1354
- strReturnedArr = strReturnedArr.map((e) => e.split(Cast.toString(arg))).flat();
1355
- }
1356
- if (typeof main === "string") return Outcome.makeSuccess(strReturnedArr);
1357
- return Outcome.makeSuccess(strReturnedArr.map(Cast.toText));
1358
- }
1359
- });
1360
-
1361
- // src/agnostic/html/hyper-json/smart-tags/coalesced/toarray/index.ts
1362
- var toarray = SmartTags.makeSmartTag({
1363
- name: "toarray",
1364
- defaultMode: "coalescion",
1365
- isolationInitType: "array",
1366
- mainValueCheck: (m) => Outcome.makeSuccess(m),
1367
- argsValueCheck: (a) => Utils.SmartTags.expectEmptyArgs(a),
1368
- func: (main) => Outcome.makeSuccess(Cast.toArray(main))
1369
- });
1370
-
1371
- // src/agnostic/html/hyper-json/smart-tags/coalesced/toboolean/index.ts
1372
- var toboolean = SmartTags.makeSmartTag({
1373
- name: "toboolean",
1374
- defaultMode: "coalescion",
1375
- isolationInitType: "array",
1376
- mainValueCheck: (m) => Outcome.makeSuccess(m),
1377
- argsValueCheck: (a) => Utils.SmartTags.expectEmptyArgs(a),
1378
- func: (m) => Outcome.makeSuccess(Cast.toBoolean(m))
1379
- });
1380
-
1381
- // src/agnostic/html/hyper-json/smart-tags/coalesced/toelement/index.ts
1382
- var toelement = SmartTags.makeSmartTag({
1383
- name: "toelement",
1384
- defaultMode: "coalescion",
1385
- isolationInitType: "array",
1386
- mainValueCheck: (m) => Outcome.makeSuccess(m),
1387
- argsValueCheck: (a) => Utils.SmartTags.expectEmptyArgs(a),
1388
- func: (m) => Outcome.makeSuccess(Cast.toElement(m))
1389
- });
1390
-
1391
- // src/agnostic/html/hyper-json/smart-tags/coalesced/toggleclass/index.ts
1392
- var toggleclass = SmartTags.makeSmartTag({
1393
- name: "toggleclass",
1394
- defaultMode: "coalescion",
1395
- isolationInitType: "array",
1396
- mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "element"),
1397
- argsValueCheck: (a) => Utils.Tree.TypeChecks.typeCheckMany(a, "string", "text"),
1398
- func: (main, args) => {
1399
- for (const arg of args) main.classList.toggle(Cast.toString(arg));
1400
- return Outcome.makeSuccess(main);
1401
- }
1402
- });
1403
-
1404
- // src/agnostic/html/hyper-json/smart-tags/coalesced/tonodelist/index.ts
1405
- var tonodelist = SmartTags.makeSmartTag({
1406
- name: "tonodelist",
1407
- defaultMode: "coalescion",
1408
- isolationInitType: "array",
1409
- mainValueCheck: (m) => Outcome.makeSuccess(m),
1410
- argsValueCheck: (a) => Utils.SmartTags.expectEmptyArgs(a),
1411
- func: (m) => Outcome.makeSuccess(Cast.toNodeList(m))
1412
- });
1413
-
1414
- // src/agnostic/html/hyper-json/smart-tags/coalesced/tonull/index.ts
1415
- var tonull = SmartTags.makeSmartTag({
1416
- name: "tonull",
1417
- defaultMode: "coalescion",
1418
- isolationInitType: "array",
1419
- mainValueCheck: (m) => Outcome.makeSuccess(m),
1420
- argsValueCheck: (a) => Utils.SmartTags.expectEmptyArgs(a),
1421
- func: () => Outcome.makeSuccess(null)
1422
- });
1423
-
1424
- // src/agnostic/html/hyper-json/smart-tags/coalesced/tonumber/index.ts
1425
- var tonumber = SmartTags.makeSmartTag({
1426
- name: "tonumber",
1427
- defaultMode: "coalescion",
1428
- isolationInitType: "array",
1429
- mainValueCheck: (m) => Outcome.makeSuccess(m),
1430
- argsValueCheck: (a) => Utils.SmartTags.expectEmptyArgs(a),
1431
- func: (m) => Outcome.makeSuccess(Cast.toNumber(m))
1432
- });
1433
-
1434
- // src/agnostic/html/hyper-json/smart-tags/coalesced/torecord/index.ts
1435
- var torecord = SmartTags.makeSmartTag({
1436
- name: "torecord",
1437
- defaultMode: "coalescion",
1438
- isolationInitType: "array",
1439
- mainValueCheck: (m) => Outcome.makeSuccess(m),
1440
- argsValueCheck: (a) => Utils.SmartTags.expectEmptyArgs(a),
1441
- func: (main) => Outcome.makeSuccess(Cast.toRecord(main))
1442
- });
1443
-
1444
- // src/agnostic/html/hyper-json/smart-tags/coalesced/toref/index.ts
1445
- var toref = SmartTags.makeSmartTag({
1446
- name: "toref",
1447
- defaultMode: "coalescion",
1448
- isolationInitType: "array",
1449
- mainValueCheck: (m) => Outcome.makeSuccess(m),
1450
- argsValueCheck: (a) => Utils.SmartTags.expectEmptyArgs(a),
1451
- func: (main, args, details) => func(Cast.toString(main), args, details)
1452
- });
1453
-
1454
- // src/agnostic/html/hyper-json/smart-tags/coalesced/tostring/index.ts
1455
- var tostring = SmartTags.makeSmartTag({
1456
- name: "tostring",
1457
- defaultMode: "coalescion",
1458
- isolationInitType: "array",
1459
- mainValueCheck: (m) => Outcome.makeSuccess(m),
1460
- argsValueCheck: (a) => Utils.SmartTags.expectEmptyArgs(a),
1461
- func: (m) => Outcome.makeSuccess(Cast.toString(m))
1462
- });
1463
-
1464
- // src/agnostic/html/hyper-json/smart-tags/coalesced/totext/index.ts
1465
- var totext = SmartTags.makeSmartTag({
1466
- name: "totext",
1467
- defaultMode: "coalescion",
1468
- isolationInitType: "array",
1469
- mainValueCheck: (m) => Outcome.makeSuccess(m),
1470
- argsValueCheck: (a) => Utils.SmartTags.expectEmptyArgs(a),
1471
- func: (m) => Outcome.makeSuccess(Cast.toText(m))
1472
- });
1473
-
1474
- // src/agnostic/html/hyper-json/smart-tags/coalesced/transformselected/index.ts
1475
- var transformselected = SmartTags.makeSmartTag({
1476
- name: "transformselected",
1477
- defaultMode: "coalescion",
1478
- isolationInitType: "array",
1479
- mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "element", "nodelist"),
1480
- argsValueCheck: (a) => {
1481
- const { makeFailure, makeSuccess } = Outcome;
1482
- const { typeCheck, typeCheckMany } = Utils.Tree.TypeChecks;
1483
- const [first, ...others] = a;
1484
- const firstChecked = typeCheck(first, "string", "text");
1485
- if (!firstChecked.success) return makeFailure({ ...firstChecked.error, position: 0 });
1486
- const othersChecked = typeCheckMany(others, "method");
1487
- if (!othersChecked.success) return makeFailure({
1488
- ...othersChecked.error,
1489
- position: othersChecked.error.position + 1
1490
- });
1491
- const returned = [firstChecked.payload, ...othersChecked.payload];
1492
- return makeSuccess(returned);
1493
- },
1494
- func: (main, args) => {
1495
- const { makeFailure, makeSuccess } = Outcome;
1496
- const { makeTransformationError } = Utils.SmartTags;
1497
- const { typeCheck } = Utils.Tree.TypeChecks;
1498
- const mainClone = Cast.toElement(main);
1499
- const [selector, ...methods] = args;
1500
- const selectedElements = Array.from(mainClone.querySelectorAll(Cast.toString(selector)));
1501
- const transformationMap = new Map(selectedElements.map((s) => [s, Utils.clone(s)]));
1502
- for (const method of methods) {
1503
- for (const [selected, value] of Array.from(transformationMap)) {
1504
- const transformer = method.transformer;
1505
- const applied = transformer.apply(value);
1506
- if (!applied.success) return makeFailure(makeTransformationError({
1507
- // [WIP] maybe a custom makeSubTransformationError ?
1508
- message: "Subtransformation failure.",
1509
- onSelected: selected,
1510
- onTransformed: value,
1511
- transformerAt: methods.indexOf(method),
1512
- transformerName: transformer.name,
1513
- transformerOutput: applied
1514
- }));
1515
- transformationMap.set(selected, applied.payload);
1516
- }
1517
- }
1518
- for (const [selected, transformed] of Array.from(transformationMap)) {
1519
- const transformedChecked = typeCheck(transformed, "element", "nodelist", "text", "string", "number", "boolean", "null");
1520
- if (!transformedChecked.success) return makeFailure(makeTransformationError({
1521
- // [WIP] maybe a custom makeBadTransformationOutputError ?
1522
- message: "Bad transformation output",
1523
- onSelected: selected,
1524
- onTransformed: transformed,
1525
- details: { ...transformedChecked.error }
1526
- }));
1527
- const { Element: Element2, NodeList, Text: Text2 } = Window.get();
1528
- const replacer = transformedChecked.payload;
1529
- if (replacer instanceof Element2 || replacer instanceof Text2) {
1530
- insertNode(replacer, "after", selected);
1531
- selected.remove();
1532
- } else if (replacer instanceof NodeList) {
1533
- replacer.forEach((item) => insertNode(item, "before", selected));
1534
- selected.remove();
1535
- } else {
1536
- insertNode(Cast.toText(replacer), "after", selected);
1537
- selected.remove();
1538
- }
1539
- transformedChecked.payload;
1540
- }
1541
- if (main instanceof Element) return makeSuccess(mainClone);
1542
- const safeChildren = Array.from(mainClone.childNodes).filter((e) => e instanceof Element || e instanceof Text);
1543
- return main instanceof Element ? makeSuccess(mainClone) : makeSuccess(Cast.toNodeList(safeChildren));
1544
- }
1545
- });
1546
-
1547
- // src/agnostic/html/hyper-json/smart-tags/coalesced/trim/index.ts
1548
- var trim = SmartTags.makeSmartTag({
1549
- name: "trim",
1550
- defaultMode: "coalescion",
1551
- isolationInitType: "array",
1552
- mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "string", "text"),
1553
- argsValueCheck: (a) => Utils.SmartTags.expectEmptyArgs(a),
1554
- func: (main) => {
1555
- return typeof main === "string" ? Outcome.makeSuccess(main.trim()) : Outcome.makeSuccess(Cast.toText(`${main}`.trim()));
1556
- }
1557
- });
1558
-
1559
- // src/agnostic/html/hyper-json/tree/index.ts
1560
- var SMART_TAGS_REGISTER = new Map([
1561
- any,
1562
- array,
1563
- boolean,
1564
- element,
1565
- get,
1566
- global,
1567
- guess,
1568
- nodelist,
1569
- nullFunc,
1570
- number,
1571
- record,
1572
- ref,
1573
- string,
1574
- text,
1575
- add,
1576
- addclass,
1577
- and,
1578
- append,
1579
- at,
1580
- call,
1581
- clone,
1582
- deleteproperties,
1583
- equals,
1584
- getattribute,
1585
- getproperties,
1586
- getproperty,
1587
- ifFunc,
1588
- initialize,
1589
- join,
1590
- length,
1591
- map,
1592
- negate,
1593
- notrailing,
1594
- or,
1595
- pickrandom,
1596
- print,
1597
- populate,
1598
- push,
1599
- pusheach,
1600
- recordtoarray,
1601
- removeattribute,
1602
- removeclass,
1603
- renameproperty,
1604
- replace,
1605
- select,
1606
- set,
1607
- setattribute,
1608
- setproperties,
1609
- setproperty,
1610
- sorton,
1611
- split,
1612
- toarray,
1613
- toboolean,
1614
- toelement,
1615
- toggleclass,
1616
- tonodelist,
1617
- tonull,
1618
- tonumber,
1619
- toref,
1620
- torecord,
1621
- tostring,
1622
- totext,
1623
- transformselected,
1624
- trim
1625
- ]);
1626
- var Tree;
1627
- ((_Tree) => {
1628
- class Tree2 {
1629
- node;
1630
- options;
1631
- parent;
1632
- parents;
1633
- pathFromParent;
1634
- root;
1635
- isRoot;
1636
- path;
1637
- pathString;
1638
- attributes;
1639
- isMethod;
1640
- tagName;
1641
- smartTagName;
1642
- smartTagData;
1643
- mode;
1644
- isPreserved;
1645
- isLiteral;
1646
- isolationInitType;
1647
- subtrees = /* @__PURE__ */ new Map();
1648
- static actionAttribute = "_action";
1649
- static keyAttribute = "_key";
1650
- static methodAttribute = "_method";
1651
- static initAttribute = "_init";
1652
- static modeAttribute = "_mode";
1653
- static preserveAttribute = "_preserve";
1654
- static literalAttribute = "_literal";
1655
- static defaultOptions = {
1656
- globalObject: {},
1657
- logger: null,
1658
- loggerThread: "hyperjson"
1659
- };
1660
- static from(nodes, options) {
1661
- const merged = Utils.Tree.mergeNodes(nodes);
1662
- return new Tree2(merged, null, null, options);
1663
- }
1664
- constructor(node, parent, pathFromParent, options) {
1665
- const { Element: Element2, Text: Text2 } = Window.get();
1666
- this.resolve = this.resolve.bind(this);
1667
- this.setVariable = this.setVariable.bind(this);
1668
- this.getVariable = this.getVariable.bind(this);
1669
- this.performSafetyChecks = this.performSafetyChecks.bind(this);
1670
- this.computeValue = this.computeValue.bind(this);
1671
- this.enforceEvaluation = this.enforceEvaluation.bind(this);
1672
- this.getCachedValue = this.getCachedValue.bind(this);
1673
- this.setCachedValue = this.setCachedValue.bind(this);
1674
- this.getPerfCounters = this.getPerfCounters.bind(this);
1675
- this.printPerfCounters = this.printPerfCounters.bind(this);
1676
- this.evaluate = this.evaluate.bind(this);
1677
- this.node = node;
1678
- this.options = options ?? Tree2.defaultOptions;
1679
- if (parent !== null && pathFromParent !== null) {
1680
- this.isRoot = false;
1681
- this.parent = parent;
1682
- this.parents = [parent, ...parent.parents];
1683
- this.pathFromParent = pathFromParent;
1684
- this.root = this.parent.root;
1685
- } else {
1686
- this.isRoot = true;
1687
- this.parent = null;
1688
- this.parents = [];
1689
- this.pathFromParent = null;
1690
- this.root = this;
1691
- }
1692
- this.path = this.isRoot ? [] : [...this.parent.path, this.pathFromParent];
1693
- this.pathString = `/${this.path.join("/")}`;
1694
- this.attributes = node instanceof Element2 ? Array.from(node.attributes) : null;
1695
- if (node instanceof Element2) {
1696
- const rawTagName = node.tagName.trim().toLowerCase();
1697
- const hasTrailingUnderscore = rawTagName.endsWith("_");
1698
- const hasMethodAttribute = this.attributes?.find((attr) => attr.name === Tree2.methodAttribute) !== void 0;
1699
- const isMethod = hasTrailingUnderscore || hasMethodAttribute;
1700
- this.isMethod = isMethod;
1701
- this.tagName = rawTagName;
1702
- this.smartTagName = hasTrailingUnderscore ? rawTagName.replace(/_+$/g, "") : rawTagName;
1703
- } else {
1704
- this.isMethod = false;
1705
- this.tagName = null;
1706
- this.smartTagName = null;
1707
- }
1708
- if (this.smartTagName === null) {
1709
- this.smartTagData = null;
1710
- } else {
1711
- this.smartTagData = SMART_TAGS_REGISTER.get(this.smartTagName) ?? null;
1712
- }
1713
- const hasModeAttribute = this.attributes?.find((attr) => {
1714
- return attr.name === Tree2.modeAttribute && Utils.Tree.TypeChecks.isTreeMode(attr.value);
1715
- });
1716
- this.mode = hasModeAttribute?.value ?? this.smartTagData?.defaultMode ?? "isolation";
1717
- const hasLiteralAttribute = this.attributes?.find((attr) => attr.name === Tree2.literalAttribute) !== void 0;
1718
- this.isLiteral = hasLiteralAttribute;
1719
- const hasPreservedAttribute = this.attributes?.find((attr) => attr.name === Tree2.preserveAttribute) !== void 0;
1720
- this.isPreserved = hasPreservedAttribute;
1721
- const hasInitAttribute = this.attributes?.find((attr) => {
1722
- if (attr.name !== Tree2.initAttribute) return false;
1723
- const val = attr.value.trim().toLowerCase();
1724
- if (!Utils.Tree.TypeChecks.isValueTypeName(val)) return false;
1725
- if (val === "transformer") return false;
1726
- if (val === "method") return false;
1727
- return true;
1728
- });
1729
- if (this.mode === "coalescion") {
1730
- this.isolationInitType = "array";
1731
- } else {
1732
- const initAttributeValue = hasInitAttribute?.value;
1733
- if (initAttributeValue !== void 0) {
1734
- this.isolationInitType = initAttributeValue;
1735
- } else if (this.smartTagData !== null) {
1736
- this.isolationInitType = this.smartTagData?.isolationInitType ?? "array";
1737
- } else {
1738
- this.isolationInitType = "nodelist";
1739
- }
1740
- }
1741
- const { childNodes } = node;
1742
- let positionnedChildrenCount = 0;
1743
- const mutableSubtrees = /* @__PURE__ */ new Map();
1744
- Array.from(childNodes).filter((child, _, childNodes2) => {
1745
- if (child instanceof Element2) return true;
1746
- if (!(child instanceof Text2)) return false;
1747
- const hasContent = (child.textContent ?? "").trim() !== "";
1748
- if (hasContent) return true;
1749
- if (childNodes2.some((n) => n instanceof Element2)) return false;
1750
- return true;
1751
- }).forEach((childNode) => {
1752
- if (childNode instanceof Text2) {
1753
- const hasContent = (childNode.textContent ?? "").trim() !== "";
1754
- if (hasContent) {
1755
- childNode.textContent = childNode.textContent?.trim() ?? "";
1756
- }
1757
- mutableSubtrees.set(
1758
- positionnedChildrenCount,
1759
- new Tree2(childNode, this, positionnedChildrenCount, this.options)
1760
- );
1761
- positionnedChildrenCount += 1;
1762
- } else {
1763
- const propertyName = childNode.getAttribute(Tree2.keyAttribute);
1764
- if (propertyName === null) {
1765
- mutableSubtrees.set(
1766
- positionnedChildrenCount,
1767
- new Tree2(childNode, this, positionnedChildrenCount, this.options)
1768
- );
1769
- positionnedChildrenCount += 1;
1770
- } else {
1771
- mutableSubtrees.set(
1772
- propertyName,
1773
- new Tree2(childNode, this, propertyName, this.options)
1774
- );
1775
- }
1776
- }
1777
- });
1778
- this.subtrees = mutableSubtrees;
1779
- }
1780
- resolve = function(path) {
1781
- let currentTree = this;
1782
- for (const chunk of path) {
1783
- if (chunk === ".") continue;
1784
- if (chunk === "..") {
1785
- currentTree = currentTree.parent ?? this;
1786
- continue;
1787
- }
1788
- const { subtrees } = currentTree;
1789
- const foundSubtree = subtrees.get(chunk);
1790
- if (foundSubtree === void 0) return void 0;
1791
- currentTree = foundSubtree;
1792
- }
1793
- return currentTree;
1794
- };
1795
- // [WIP] variablesStore is actually only used on root Tree
1796
- variablesStore = /* @__PURE__ */ new Map();
1797
- setVariable(name, value) {
1798
- const { root, isRoot, variablesStore } = this;
1799
- if (!isRoot) return root.setVariable(name, value);
1800
- variablesStore.set(name, Serialize.serialize(value));
1801
- }
1802
- getVariable(name) {
1803
- const { root } = this;
1804
- const found = root.variablesStore.get(name);
1805
- if (found === void 0) return void 0;
1806
- const deserialized = Serialize.deserialize(found);
1807
- if (deserialized instanceof Transformer) throw "A transformer should not be stored as a variable, this happening denotes an implementation error.";
1808
- return deserialized;
1809
- }
1810
- performSafetyChecks() {
1811
- const { node, smartTagData, isMethod, mode, isRoot } = this;
1812
- const { Text: Text2 } = Window.get();
1813
- if (node instanceof Text2 || smartTagData === null) {
1814
- if (isMethod) throw new Error(`A Text or HTMLElement node cannot be used as a method @ ${this.pathString}`);
1815
- if (mode === "coalescion") throw new Error(`A Text or HTMLElement node cannot be used in coalescion mode @ ${this.pathString}`);
1816
- }
1817
- if (isRoot && mode === "coalescion") throw new Error(`The root node cannot be used in coalescion mode @ ${this.pathString}`);
1818
- }
1819
- computeValue() {
1820
- const {
1821
- isolationInitType,
1822
- subtrees,
1823
- node,
1824
- smartTagData,
1825
- isMethod,
1826
- mode,
1827
- performSafetyChecks,
1828
- options
1829
- } = this;
1830
- performSafetyChecks();
1831
- const { Text: Text2 } = Window.get();
1832
- if (node instanceof Text2) return node.cloneNode(true);
1833
- const initialInnerValue = Utils.Tree.getInitialValueFromTypeName(isolationInitType);
1834
- const innerValue = Array.from(subtrees).reduce((reduced, [subpath, subtree]) => {
1835
- const subvalue = subtree.evaluate();
1836
- const coalesced = Utils.coalesceValues(reduced, subpath, subvalue);
1837
- return coalesced;
1838
- }, initialInnerValue);
1839
- if (smartTagData === null) {
1840
- const nodelist2 = Cast.toNodeList(innerValue);
1841
- const clone2 = node.cloneNode();
1842
- clone2.append(...Array.from(nodelist2));
1843
- return clone2;
1844
- }
1845
- const { transformer, method } = smartTagData.generator(innerValue, mode, this);
1846
- if (isMethod) return method;
1847
- if (mode === "isolation") {
1848
- const applied = transformer.apply(null);
1849
- if (applied.success) return applied.payload;
1850
- throw {
1851
- error: "Transformation error",
1852
- details: applied.error,
1853
- transformer: transformer.name,
1854
- path: this.pathString
1855
- };
1856
- }
1857
- return transformer;
1858
- }
1859
- enforceEvaluation() {
1860
- const { isPreserved, node, computeValue, isLiteral, attributes } = this;
1861
- const { Element: Element2 } = Window.get();
1862
- if (isPreserved) return Utils.clone(node);
1863
- const evaluated = computeValue();
1864
- if (!isLiteral) return evaluated;
1865
- const asLiteral = Utils.toHyperJson(evaluated);
1866
- if (asLiteral instanceof Element2) attributes?.forEach(({ name, value }) => asLiteral.setAttribute(name, value));
1867
- return asLiteral;
1868
- }
1869
- cachedValue = void 0;
1870
- getCachedValue() {
1871
- const { cachedValue } = this;
1872
- if (cachedValue === void 0) return void 0;
1873
- const deserialized = Serialize.deserialize(cachedValue);
1874
- return deserialized;
1875
- }
1876
- setCachedValue(evaluated) {
1877
- this.cachedValue = Serialize.serialize(evaluated);
1878
- }
1879
- perfCounters = {
1880
- computed: 0,
1881
- computeTime: 0,
1882
- computeTimeAvg: 0,
1883
- cached: 0,
1884
- cacheTime: 0,
1885
- cacheTimeAvg: 0,
1886
- totalTime: 0
1887
- };
1888
- // [WIP] bind this
1889
- getPerfCounters() {
1890
- const { subtrees, cachedValue, tagName, perfCounters } = this;
1891
- const subCounters = [];
1892
- subCounters.push([this.pathString, {
1893
- ...perfCounters,
1894
- tagName: tagName ?? "#text",
1895
- evaluated: cachedValue
1896
- }]);
1897
- subtrees.forEach((subtree) => subCounters.push(...subtree.getPerfCounters()));
1898
- return subCounters;
1899
- }
1900
- // [WIP] bind this
1901
- printPerfCounters() {
1902
- const perfCounters = this.getPerfCounters().sort((a, b) => {
1903
- const aCalls = a[1].computed + a[1].cached;
1904
- const bCalls = b[1].computed + b[1].cached;
1905
- return bCalls - aCalls;
1906
- }).map((e) => ({
1907
- tagName: e[1].tagName,
1908
- path: e[0],
1909
- totalMs: e[1].totalTime,
1910
- computeMs: e[1].computeTime,
1911
- cacheMs: e[1].cacheTime,
1912
- ops: `${e[1].computed}/${e[1].cached}`,
1913
- evaluated: e[1].evaluated
1914
- }));
1915
- console.table(perfCounters);
1916
- }
1917
- evaluate() {
1918
- const start = Date.now();
1919
- const {
1920
- getCachedValue,
1921
- setCachedValue,
1922
- enforceEvaluation,
1923
- perfCounters
1924
- } = this;
1925
- const cached = getCachedValue();
1926
- if (cached !== void 0) {
1927
- const end2 = Date.now();
1928
- const time2 = end2 - start;
1929
- perfCounters.cached++;
1930
- perfCounters.cacheTime += time2;
1931
- perfCounters.cacheTimeAvg = perfCounters.cacheTime / perfCounters.cached;
1932
- perfCounters.totalTime = perfCounters.computeTime + perfCounters.cacheTime;
1933
- return cached;
1934
- }
1935
- const evaluated = enforceEvaluation();
1936
- setCachedValue(evaluated);
1937
- const end = Date.now();
1938
- const time = end - start;
1939
- perfCounters.computed++;
1940
- perfCounters.computeTime += time;
1941
- perfCounters.computeTimeAvg = perfCounters.computeTime / perfCounters.computed;
1942
- perfCounters.totalTime = perfCounters.computeTime + perfCounters.cacheTime;
1943
- return evaluated;
1944
- }
1945
- }
1946
- _Tree.Tree = Tree2;
1947
- })(Tree || (Tree = {}));
1948
-
1949
- // src/agnostic/html/hyper-json/utils/index.ts
1950
- var Utils;
1951
- ((Utils2) => {
1952
- function clone2(value) {
1953
- const { Element: Element2, Text: Text2, NodeList, document: document2 } = Window.get();
1954
- if (typeof value === "string" || typeof value === "number" || typeof value === "boolean" || value === null) return value;
1955
- if (value instanceof Text2) return value.cloneNode(true);
1956
- if (value instanceof NodeList) {
1957
- const frag = document2.createDocumentFragment();
1958
- const nodes = Array.from(value).map((e) => e.cloneNode(true));
1959
- frag.append(...nodes);
1960
- return frag.childNodes;
1961
- }
1962
- if (value instanceof Element2) return value.cloneNode(true);
1963
- if (value instanceof Transformer) return Transformer.clone(value);
1964
- if (value instanceof Method) return Method.clone(value);
1965
- if (Array.isArray(value)) return [...value.map(clone2)];
1966
- if (isRecord(value)) return recordMap(value, (prop) => clone2(prop));
1967
- throw new Error(`Cannot clone value: ${value}`);
1968
- }
1969
- Utils2.clone = clone2;
1970
- function coalesceValues(currentValue, subpath, subvalue) {
1971
- const { Element: Element2, Text: Text2, NodeList, document: document2 } = Window.get();
1972
- let actualSubvalue = subvalue;
1973
- if (actualSubvalue instanceof Transformer) {
1974
- const transformer = actualSubvalue;
1975
- const transformationResult = transformer.apply(currentValue);
1976
- if (!transformationResult.success) {
1977
- console.warn({ ...transformationResult.error });
1978
- return currentValue;
1979
- }
1980
- const evaluated = transformationResult.payload;
1981
- if (transformer.mode === "isolation") {
1982
- actualSubvalue = evaluated;
1983
- } else {
1984
- return evaluated;
1985
- }
1986
- }
1987
- if (Array.isArray(currentValue)) return [...currentValue, actualSubvalue];
1988
- if (currentValue === null) return actualSubvalue;
1989
- if (typeof currentValue === "boolean") return actualSubvalue;
1990
- if (typeof currentValue === "number") return actualSubvalue;
1991
- if (currentValue instanceof Transformer) return actualSubvalue;
1992
- if (currentValue instanceof Method) return actualSubvalue;
1993
- if (typeof currentValue === "string") {
1994
- if (actualSubvalue === null || typeof actualSubvalue === "boolean" || typeof actualSubvalue === "number" || typeof actualSubvalue === "string") return `${currentValue}${actualSubvalue}`;
1995
- if (actualSubvalue instanceof Text2) return `${currentValue}${actualSubvalue.textContent}`;
1996
- if (actualSubvalue instanceof Element2) {
1997
- const frag = document2.createDocumentFragment();
1998
- frag.append(currentValue, Utils2.clone(actualSubvalue));
1999
- return frag.childNodes;
2000
- }
2001
- if (actualSubvalue instanceof NodeList) {
2002
- const frag = document2.createDocumentFragment();
2003
- frag.append(currentValue, ...Array.from(Utils2.clone(actualSubvalue)));
2004
- return frag.childNodes;
2005
- }
2006
- return actualSubvalue;
2007
- }
2008
- if (currentValue instanceof Text2) {
2009
- if (actualSubvalue === null || typeof actualSubvalue === "boolean" || typeof actualSubvalue === "number" || typeof actualSubvalue === "string") return document2.createTextNode(`${currentValue.textContent}${actualSubvalue}`);
2010
- if (actualSubvalue instanceof Text2) return document2.createTextNode(`${currentValue.textContent}${actualSubvalue.textContent}`);
2011
- if (actualSubvalue instanceof Element2) {
2012
- const frag = document2.createDocumentFragment();
2013
- frag.append(clone2(currentValue), clone2(actualSubvalue));
2014
- return frag.childNodes;
2015
- }
2016
- if (actualSubvalue instanceof NodeList) {
2017
- const frag = document2.createDocumentFragment();
2018
- frag.append(clone2(currentValue), ...Array.from(clone2(actualSubvalue)));
2019
- return frag.childNodes;
2020
- }
2021
- return actualSubvalue;
2022
- }
2023
- if (currentValue instanceof Element2) {
2024
- if (actualSubvalue === null || typeof actualSubvalue === "boolean" || typeof actualSubvalue === "number" || typeof actualSubvalue === "string") {
2025
- const frag = document2.createDocumentFragment();
2026
- frag.append(clone2(currentValue), `${actualSubvalue}`);
2027
- return frag.childNodes;
2028
- }
2029
- if (actualSubvalue instanceof Text2 || actualSubvalue instanceof Element2) {
2030
- const frag = document2.createDocumentFragment();
2031
- frag.append(clone2(currentValue), clone2(actualSubvalue));
2032
- return frag.childNodes;
2033
- }
2034
- if (actualSubvalue instanceof NodeList) {
2035
- const frag = document2.createDocumentFragment();
2036
- frag.append(clone2(currentValue), ...Array.from(clone2(actualSubvalue)));
2037
- return frag.childNodes;
2038
- }
2039
- return actualSubvalue;
2040
- }
2041
- if (currentValue instanceof NodeList) {
2042
- if (actualSubvalue === null || typeof actualSubvalue === "boolean" || typeof actualSubvalue === "number" || typeof actualSubvalue === "string") {
2043
- const frag = document2.createDocumentFragment();
2044
- frag.append(...Array.from(clone2(currentValue)), `${actualSubvalue}`);
2045
- return frag.childNodes;
2046
- }
2047
- if (actualSubvalue instanceof Text2 || actualSubvalue instanceof Element2) {
2048
- const frag = document2.createDocumentFragment();
2049
- frag.append(...Array.from(clone2(currentValue)), clone2(actualSubvalue));
2050
- return frag.childNodes;
2051
- }
2052
- if (actualSubvalue instanceof NodeList) {
2053
- const frag = document2.createDocumentFragment();
2054
- frag.append(...Array.from(clone2(currentValue)), ...Array.from(clone2(actualSubvalue)));
2055
- return frag.childNodes;
2056
- }
2057
- return actualSubvalue;
2058
- }
2059
- if (typeof subpath === "number") return { ...currentValue };
2060
- return {
2061
- ...currentValue,
2062
- [subpath]: actualSubvalue
2063
- };
2064
- }
2065
- Utils2.coalesceValues = coalesceValues;
2066
- Utils2.toHyperJson = (value) => {
2067
- const { document: document2, Element: Element2, Text: Text2, NodeList } = Window.get();
2068
- if (value instanceof Text2) {
2069
- const elt2 = document2.createElement("text");
2070
- elt2.innerHTML = value.textContent ?? "";
2071
- return elt2;
2072
- }
2073
- if (value instanceof Element2) return value.cloneNode(true);
2074
- if (value instanceof NodeList) {
2075
- const elt2 = document2.createElement("nodelist");
2076
- elt2.append(...Array.from(value).map((e) => e.cloneNode(true)));
2077
- return elt2;
2078
- }
2079
- if (value === null) return document2.createElement("null");
2080
- if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
2081
- const elt2 = document2.createElement(typeof value);
2082
- elt2.innerHTML = `${value}`;
2083
- return elt2;
2084
- }
2085
- if (Array.isArray(value)) {
2086
- const elt2 = document2.createElement("array");
2087
- elt2.append(...value.map((e) => (0, Utils2.toHyperJson)(e)));
2088
- return elt2;
2089
- }
2090
- if (value instanceof Transformer) return clone2(value.sourceTree.node);
2091
- if (value instanceof Method) return clone2(value.transformer.sourceTree.node);
2092
- const elt = document2.createElement("record");
2093
- Object.entries(value).forEach(([key, val]) => {
2094
- const hjVal = (0, Utils2.toHyperJson)(val);
2095
- if (hjVal instanceof Text2) return;
2096
- hjVal.setAttribute(Tree.Tree.keyAttribute, key);
2097
- elt.append(hjVal);
2098
- });
2099
- return elt;
2100
- };
2101
- let Transformations;
2102
- ((Transformations2) => {
2103
- let TypeChecks;
2104
- ((TypeChecks2) => {
2105
- function getType(value) {
2106
- if (singleTypeCheck(value, "null")) return "null";
2107
- if (singleTypeCheck(value, "boolean")) return "boolean";
2108
- if (singleTypeCheck(value, "number")) return "number";
2109
- if (singleTypeCheck(value, "string")) return "string";
2110
- if (singleTypeCheck(value, "element")) return "element";
2111
- if (singleTypeCheck(value, "text")) return "text";
2112
- if (singleTypeCheck(value, "nodelist")) return "nodelist";
2113
- if (singleTypeCheck(value, "method")) return "method";
2114
- if (singleTypeCheck(value, "array")) return "array";
2115
- if (singleTypeCheck(value, "record")) return "record";
2116
- return void 0;
2117
- }
2118
- TypeChecks2.getType = getType;
2119
- TypeChecks2.everyTypeName = [
2120
- "null",
2121
- "boolean",
2122
- "number",
2123
- "string",
2124
- "text",
2125
- "nodelist",
2126
- "element",
2127
- "method",
2128
- "array",
2129
- "record"
2130
- ];
2131
- function singleTypeCheck(value, type) {
2132
- const { Element: Element2, Text: Text2, NodeList } = Window.get();
2133
- if (type === "null" && value === null) return true;
2134
- if (type === "boolean" && typeof value === "boolean") return true;
2135
- if (type === "number" && typeof value === "number") return true;
2136
- if (type === "string" && typeof value === "string") return true;
2137
- if (type === "element" && value instanceof Element2) return true;
2138
- if (type === "text" && value instanceof Text2) return true;
2139
- if (type === "nodelist" && value instanceof NodeList) {
2140
- const children = Array.from(value);
2141
- return children.every((child) => child instanceof Element2 || child instanceof Text2);
2142
- }
2143
- if (type === "method" && value instanceof Method) return true;
2144
- if (type === "array" && Array.isArray(value)) {
2145
- const childrenOk = value.every((child) => typeCheck(child, ...TypeChecks2.everyTypeName).success);
2146
- return childrenOk;
2147
- }
2148
- if (type === "record" && isRecord(value)) {
2149
- const childrenOk = Object.values(value).every((child) => typeCheck(child, ...TypeChecks2.everyTypeName).success);
2150
- return childrenOk;
2151
- }
2152
- return false;
2153
- }
2154
- TypeChecks2.singleTypeCheck = singleTypeCheck;
2155
- function typeCheck(value, ...types) {
2156
- const matchesOneType = types.some((type) => singleTypeCheck(value, type));
2157
- if (matchesOneType) return Outcome.makeSuccess(value);
2158
- return Outcome.makeFailure({
2159
- expected: types.join(" | "),
2160
- found: getType(value) ?? "undefined"
2161
- });
2162
- }
2163
- TypeChecks2.typeCheck = typeCheck;
2164
- function typeCheckMany(values, ...types) {
2165
- for (const [pos, val] of Object.entries(values)) {
2166
- const checked = typeCheck(val, ...types);
2167
- if (checked.success) continue;
2168
- return Outcome.makeFailure({ position: parseInt(pos), ...checked.error });
2169
- }
2170
- return Outcome.makeSuccess(values);
2171
- }
2172
- TypeChecks2.typeCheckMany = typeCheckMany;
2173
- })(TypeChecks = Transformations2.TypeChecks || (Transformations2.TypeChecks = {}));
2174
- })(Transformations = Utils2.Transformations || (Utils2.Transformations = {}));
2175
- let Tree2;
2176
- ((Tree3) => {
2177
- function mergeNodes(nodes) {
2178
- const clones = nodes.map((node) => node.cloneNode(true));
2179
- const allChildren = [];
2180
- clones.forEach((node) => {
2181
- const actionAttribute = node.getAttribute(Tree.Tree.actionAttribute)?.trim().toLowerCase();
2182
- const actionAttrIsValid = isInEnum(Types.Tree.Merge.Action, actionAttribute ?? "");
2183
- const nodeAction = actionAttrIsValid ? actionAttribute : Types.Tree.Merge.Action.APPEND;
2184
- const { Element: Element2, Text: Text2 } = Window.get();
2185
- const children = Array.from(node.childNodes).filter((child) => child instanceof Text2 || child instanceof Element2).map((child) => {
2186
- if (child instanceof Text2) return { node: child, key: void 0 };
2187
- const childKey = child.getAttribute(Tree.Tree.keyAttribute) ?? void 0;
2188
- return { node: child, key: childKey };
2189
- });
2190
- if (nodeAction === Types.Tree.Merge.Action.REPLACE) {
2191
- allChildren.splice(0, allChildren.length);
2192
- } else if (nodeAction === Types.Tree.Merge.Action.PREPEND) {
2193
- allChildren.unshift(...children);
2194
- } else {
2195
- allChildren.push(...children);
2196
- }
2197
- });
2198
- const mergedChildren = [];
2199
- allChildren.forEach((childData) => {
2200
- if (childData.key === void 0) mergedChildren.push(childData);
2201
- else {
2202
- const childKey = childData.key;
2203
- const alreadyMerged = mergedChildren.find((dat) => dat.key === childKey);
2204
- if (alreadyMerged) return;
2205
- const toMerge = allChildren.filter((dat) => dat.key === childKey);
2206
- if (toMerge.length === 0) return;
2207
- const merged = mergeNodes(toMerge.map((dat) => dat.node));
2208
- mergedChildren.push({ node: merged, key: childKey });
2209
- }
2210
- });
2211
- const allAttributes = clones.reduce((attributes, node) => [
2212
- ...Array.from(attributes),
2213
- ...Array.from(node.attributes)
2214
- ], []);
2215
- const outWrapper = clones[0]?.cloneNode() ?? document.createElement("div");
2216
- allAttributes.forEach((attr) => outWrapper.setAttribute(attr.name, attr.value));
2217
- outWrapper.append(...mergedChildren.map((e) => e.node));
2218
- return outWrapper;
2219
- }
2220
- Tree3.mergeNodes = mergeNodes;
2221
- function getInitialValueFromTypeName(name) {
2222
- const { document: document2 } = Window.get();
2223
- if (name === "null") return null;
2224
- if (name === "boolean") return false;
2225
- if (name === "number") return 0;
2226
- if (name === "string") return "";
2227
- if (name === "text") return document2.createTextNode("");
2228
- if (name === "nodelist") return document2.createDocumentFragment().childNodes;
2229
- if (name === "element") return document2.createElement("div");
2230
- if (name === "array") return [];
2231
- if (name === "record") return {};
2232
- throw new Error(`Unknown value type name: ${name}`);
2233
- }
2234
- Tree3.getInitialValueFromTypeName = getInitialValueFromTypeName;
2235
- let TypeChecks;
2236
- ((TypeChecks2) => {
2237
- function getType(value) {
2238
- if (singleTypeCheck(value, "null")) return "null";
2239
- if (singleTypeCheck(value, "boolean")) return "boolean";
2240
- if (singleTypeCheck(value, "number")) return "number";
2241
- if (singleTypeCheck(value, "string")) return "string";
2242
- if (singleTypeCheck(value, "element")) return "element";
2243
- if (singleTypeCheck(value, "text")) return "text";
2244
- if (singleTypeCheck(value, "nodelist")) return "nodelist";
2245
- if (singleTypeCheck(value, "transformer")) return "transformer";
2246
- if (singleTypeCheck(value, "method")) return "method";
2247
- if (singleTypeCheck(value, "array")) return "array";
2248
- if (singleTypeCheck(value, "record")) return "record";
2249
- return void 0;
2250
- }
2251
- TypeChecks2.getType = getType;
2252
- TypeChecks2.everyTypeName = [
2253
- "null",
2254
- "boolean",
2255
- "number",
2256
- "string",
2257
- "text",
2258
- "nodelist",
2259
- "element",
2260
- "transformer",
2261
- "method",
2262
- "array",
2263
- "record"
2264
- ];
2265
- function singleTypeCheck(value, type) {
2266
- const { Element: Element2, Text: Text2, NodeList } = Window.get();
2267
- if (type === "null" && value === null) return true;
2268
- if (type === "boolean" && typeof value === "boolean") return true;
2269
- if (type === "number" && typeof value === "number") return true;
2270
- if (type === "string" && typeof value === "string") return true;
2271
- if (type === "element" && value instanceof Element2) return true;
2272
- if (type === "text" && value instanceof Text2) return true;
2273
- if (type === "nodelist" && value instanceof NodeList) {
2274
- const children = Array.from(value);
2275
- return children.every((child) => child instanceof Element2 || child instanceof Text2);
2276
- }
2277
- if (type === "transformer" && value instanceof Transformer) return true;
2278
- if (type === "method" && value instanceof Method) return true;
2279
- if (type === "array" && Array.isArray(value)) {
2280
- const childrenOk = value.every((child) => typeCheck(child, ...TypeChecks2.everyTypeName).success);
2281
- return childrenOk;
2282
- }
2283
- if (type === "record" && isRecord(value)) {
2284
- const childrenOk = Object.values(value).every((child) => typeCheck(child, ...TypeChecks2.everyTypeName).success);
2285
- return childrenOk;
2286
- }
2287
- return false;
2288
- }
2289
- TypeChecks2.singleTypeCheck = singleTypeCheck;
2290
- function typeCheck(value, ...types) {
2291
- const matchesOneType = types.some((type) => singleTypeCheck(value, type));
2292
- if (matchesOneType) return Outcome.makeSuccess(value);
2293
- return Outcome.makeFailure({
2294
- expected: types.join(" | "),
2295
- found: getType(value) ?? "undefined"
2296
- });
2297
- }
2298
- TypeChecks2.typeCheck = typeCheck;
2299
- function typeCheckMany(values, ...types) {
2300
- for (const [pos, val] of Object.entries(values)) {
2301
- const checked = typeCheck(val, ...types);
2302
- if (checked.success) continue;
2303
- return Outcome.makeFailure({ position: parseInt(pos), ...checked.error });
2304
- }
2305
- return Outcome.makeSuccess(values);
2306
- }
2307
- TypeChecks2.typeCheckMany = typeCheckMany;
2308
- TypeChecks2.isTreeMode = (name) => name === "isolation" || name === "coalescion";
2309
- TypeChecks2.isValueTypeName = (name) => {
2310
- const list = [
2311
- "null",
2312
- "boolean",
2313
- "number",
2314
- "string",
2315
- "text",
2316
- "nodelist",
2317
- "element",
2318
- "transformer",
2319
- "method",
2320
- "array",
2321
- "record"
2322
- ];
2323
- return list.includes(name);
2324
- };
2325
- })(TypeChecks = Tree3.TypeChecks || (Tree3.TypeChecks = {}));
2326
- })(Tree2 = Utils2.Tree || (Utils2.Tree = {}));
2327
- let SmartTags2;
2328
- ((SmartTags3) => {
2329
- SmartTags3.expectEmptyArgs = (args) => {
2330
- if (args.length === 0) return Outcome.makeSuccess([]);
2331
- return Outcome.makeFailure({
2332
- expected: "length: 0",
2333
- found: `length: ${args.length}`
2334
- });
2335
- };
2336
- SmartTags3.makeMainValueError = (expected, found, details) => ({ expected, found, details });
2337
- SmartTags3.makeArgsValueError = (expected, found, position, details) => ({ expected, found, position, details });
2338
- SmartTags3.makeTransformationError = (details) => ({ details });
2339
- })(SmartTags2 = Utils2.SmartTags || (Utils2.SmartTags = {}));
2340
- })(Utils || (Utils = {}));
2341
-
2342
- // src/agnostic/html/hyper-json/smart-tags/isolated/boolean/index.ts
2343
- var boolean = SmartTags.makeSmartTag({
2344
- name: "boolean",
2345
- defaultMode: "isolation",
2346
- isolationInitType: "boolean",
2347
- mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "null", "boolean", "number", "string", "text"),
2348
- argsValueCheck: (a) => Utils.Tree.TypeChecks.typeCheckMany(a, "null", "boolean", "number", "string", "text"),
2349
- func: (main, args) => Outcome.makeSuccess([main, ...args].every((item) => Cast.toBoolean(item)))
2350
- });
2351
-
2352
- export {
2353
- boolean,
2354
- element,
2355
- get,
2356
- global,
2357
- guess,
2358
- nodelist,
2359
- number,
2360
- record,
2361
- func,
2362
- ref,
2363
- string,
2364
- text,
2365
- add,
2366
- addclass,
2367
- and,
2368
- append,
2369
- at,
2370
- call,
2371
- clone,
2372
- deleteproperties,
2373
- equals,
2374
- getattribute,
2375
- getproperties,
2376
- getproperty,
2377
- deepGetProperty,
2378
- ifFunc,
2379
- initialize,
2380
- join,
2381
- length,
2382
- map,
2383
- negate,
2384
- notrailing,
2385
- or,
2386
- pickrandom,
2387
- print,
2388
- populate,
2389
- push,
2390
- pusheach,
2391
- recordtoarray,
2392
- removeattribute,
2393
- removeclass,
2394
- renameproperty,
2395
- replace,
2396
- select,
2397
- set,
2398
- setattribute,
2399
- setproperties,
2400
- setproperty,
2401
- sorton,
2402
- split,
2403
- toarray,
2404
- toboolean,
2405
- toelement,
2406
- toggleclass,
2407
- tonodelist,
2408
- tonull,
2409
- tonumber,
2410
- torecord,
2411
- toref,
2412
- tostring,
2413
- totext,
2414
- transformselected,
2415
- trim,
2416
- SMART_TAGS_REGISTER,
2417
- Tree,
2418
- Utils,
2419
- Cast
2420
- };