@fgv/ts-extras 5.1.0-4 → 5.1.0-41

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 (368) hide show
  1. package/dist/index.browser.js +4 -2
  2. package/dist/index.browser.js.map +1 -0
  3. package/dist/index.js.map +1 -0
  4. package/dist/packlets/ai-assist/apiClient.js +886 -158
  5. package/dist/packlets/ai-assist/apiClient.js.map +1 -0
  6. package/dist/packlets/ai-assist/chatRequestBuilders.js +282 -0
  7. package/dist/packlets/ai-assist/chatRequestBuilders.js.map +1 -0
  8. package/dist/packlets/ai-assist/converters.js +47 -3
  9. package/dist/packlets/ai-assist/converters.js.map +1 -0
  10. package/dist/packlets/ai-assist/embeddingClient.js +345 -0
  11. package/dist/packlets/ai-assist/embeddingClient.js.map +1 -0
  12. package/dist/packlets/ai-assist/endpoint.js +78 -0
  13. package/dist/packlets/ai-assist/endpoint.js.map +1 -0
  14. package/dist/packlets/ai-assist/http.js +75 -0
  15. package/dist/packlets/ai-assist/http.js.map +1 -0
  16. package/dist/packlets/ai-assist/imageOptionsResolver.js +193 -0
  17. package/dist/packlets/ai-assist/imageOptionsResolver.js.map +1 -0
  18. package/dist/packlets/ai-assist/index.js +10 -4
  19. package/dist/packlets/ai-assist/index.js.map +1 -0
  20. package/dist/packlets/ai-assist/jsonCompletion.js +93 -0
  21. package/dist/packlets/ai-assist/jsonCompletion.js.map +1 -0
  22. package/dist/packlets/ai-assist/jsonResponse.js +149 -0
  23. package/dist/packlets/ai-assist/jsonResponse.js.map +1 -0
  24. package/dist/packlets/ai-assist/model.js +193 -9
  25. package/dist/packlets/ai-assist/model.js.map +1 -0
  26. package/dist/packlets/ai-assist/registry.js +314 -12
  27. package/dist/packlets/ai-assist/registry.js.map +1 -0
  28. package/dist/packlets/ai-assist/sseParser.js +123 -0
  29. package/dist/packlets/ai-assist/sseParser.js.map +1 -0
  30. package/dist/packlets/ai-assist/streamingAdapters/anthropic.js +368 -0
  31. package/dist/packlets/ai-assist/streamingAdapters/anthropic.js.map +1 -0
  32. package/dist/packlets/ai-assist/streamingAdapters/clientToolContinuationBuilder.js +687 -0
  33. package/dist/packlets/ai-assist/streamingAdapters/clientToolContinuationBuilder.js.map +1 -0
  34. package/dist/packlets/ai-assist/streamingAdapters/common.js +187 -0
  35. package/dist/packlets/ai-assist/streamingAdapters/common.js.map +1 -0
  36. package/dist/packlets/ai-assist/streamingAdapters/gemini.js +204 -0
  37. package/dist/packlets/ai-assist/streamingAdapters/gemini.js.map +1 -0
  38. package/dist/packlets/ai-assist/streamingAdapters/openaiChat.js +170 -0
  39. package/dist/packlets/ai-assist/streamingAdapters/openaiChat.js.map +1 -0
  40. package/dist/packlets/ai-assist/streamingAdapters/openaiResponses.js +386 -0
  41. package/dist/packlets/ai-assist/streamingAdapters/openaiResponses.js.map +1 -0
  42. package/dist/packlets/ai-assist/streamingAdapters/proxy.js +173 -0
  43. package/dist/packlets/ai-assist/streamingAdapters/proxy.js.map +1 -0
  44. package/dist/packlets/ai-assist/streamingClient.js +140 -0
  45. package/dist/packlets/ai-assist/streamingClient.js.map +1 -0
  46. package/dist/packlets/ai-assist/thinkingOptionsResolver.js +288 -0
  47. package/dist/packlets/ai-assist/thinkingOptionsResolver.js.map +1 -0
  48. package/dist/packlets/ai-assist/toolFormats.js +106 -10
  49. package/dist/packlets/ai-assist/toolFormats.js.map +1 -0
  50. package/dist/packlets/conversion/converters.js +35 -1
  51. package/dist/packlets/conversion/converters.js.map +1 -0
  52. package/dist/packlets/conversion/index.js.map +1 -0
  53. package/dist/packlets/crypto-utils/constants.js.map +1 -0
  54. package/dist/packlets/crypto-utils/converters.js +42 -4
  55. package/dist/packlets/crypto-utils/converters.js.map +1 -0
  56. package/dist/packlets/crypto-utils/directEncryptionProvider.js.map +1 -0
  57. package/dist/packlets/crypto-utils/encryptedFile.js.map +1 -0
  58. package/dist/packlets/crypto-utils/hpkeProvider.js +355 -0
  59. package/dist/packlets/crypto-utils/hpkeProvider.js.map +1 -0
  60. package/dist/packlets/crypto-utils/index.browser.js +10 -2
  61. package/dist/packlets/crypto-utils/index.browser.js.map +1 -0
  62. package/dist/packlets/crypto-utils/index.js +6 -0
  63. package/dist/packlets/crypto-utils/index.js.map +1 -0
  64. package/dist/packlets/crypto-utils/keyPairAlgorithmParams.js +71 -0
  65. package/dist/packlets/crypto-utils/keyPairAlgorithmParams.js.map +1 -0
  66. package/dist/packlets/crypto-utils/keystore/converters.js +105 -14
  67. package/dist/packlets/crypto-utils/keystore/converters.js.map +1 -0
  68. package/dist/packlets/crypto-utils/keystore/encryptedFilePrivateKeyStorage.js +287 -0
  69. package/dist/packlets/crypto-utils/keystore/encryptedFilePrivateKeyStorage.js.map +1 -0
  70. package/dist/packlets/crypto-utils/keystore/index.browser.js +36 -0
  71. package/dist/packlets/crypto-utils/keystore/index.browser.js.map +1 -0
  72. package/dist/packlets/crypto-utils/keystore/index.js +3 -0
  73. package/dist/packlets/crypto-utils/keystore/index.js.map +1 -0
  74. package/dist/packlets/crypto-utils/keystore/keyStore.js +773 -119
  75. package/dist/packlets/crypto-utils/keystore/keyStore.js.map +1 -0
  76. package/dist/packlets/crypto-utils/keystore/model.js +30 -4
  77. package/dist/packlets/crypto-utils/keystore/model.js.map +1 -0
  78. package/dist/packlets/crypto-utils/keystore/privateKeyStorage.js +21 -0
  79. package/dist/packlets/crypto-utils/keystore/privateKeyStorage.js.map +1 -0
  80. package/dist/packlets/crypto-utils/model.js +32 -0
  81. package/dist/packlets/crypto-utils/model.js.map +1 -0
  82. package/dist/packlets/crypto-utils/nodeCryptoProvider.js +336 -1
  83. package/dist/packlets/crypto-utils/nodeCryptoProvider.js.map +1 -0
  84. package/dist/packlets/crypto-utils/spkiHelpers.js +240 -0
  85. package/dist/packlets/crypto-utils/spkiHelpers.js.map +1 -0
  86. package/dist/packlets/csv/csvFileHelpers.js +0 -14
  87. package/dist/packlets/csv/csvFileHelpers.js.map +1 -0
  88. package/dist/packlets/csv/csvHelpers.js +14 -0
  89. package/dist/packlets/csv/csvHelpers.js.map +1 -0
  90. package/dist/packlets/csv/index.browser.js +1 -3
  91. package/dist/packlets/csv/index.browser.js.map +1 -0
  92. package/dist/packlets/csv/index.js.map +1 -0
  93. package/dist/packlets/experimental/extendedArray.js.map +1 -0
  94. package/dist/packlets/experimental/formatter.js.map +1 -0
  95. package/dist/packlets/experimental/index.js.map +1 -0
  96. package/dist/packlets/experimental/rangeOf.js.map +1 -0
  97. package/dist/packlets/hash/index.browser.js.map +1 -0
  98. package/dist/packlets/hash/index.js.map +1 -0
  99. package/dist/packlets/hash/index.node.js.map +1 -0
  100. package/dist/packlets/hash/md5Normalizer.browser.js.map +1 -0
  101. package/dist/packlets/hash/md5Normalizer.js.map +1 -0
  102. package/dist/packlets/mustache/index.js.map +1 -0
  103. package/dist/packlets/mustache/interfaces.js.map +1 -0
  104. package/dist/packlets/mustache/mustacheTemplate.js +42 -4
  105. package/dist/packlets/mustache/mustacheTemplate.js.map +1 -0
  106. package/dist/packlets/record-jar/index.browser.js +1 -3
  107. package/dist/packlets/record-jar/index.browser.js.map +1 -0
  108. package/dist/packlets/record-jar/index.js.map +1 -0
  109. package/dist/packlets/record-jar/recordJarFileHelpers.js +0 -18
  110. package/dist/packlets/record-jar/recordJarFileHelpers.js.map +1 -0
  111. package/dist/packlets/record-jar/recordJarHelpers.js +18 -0
  112. package/dist/packlets/record-jar/recordJarHelpers.js.map +1 -0
  113. package/dist/packlets/yaml/converters.js.map +1 -0
  114. package/dist/packlets/yaml/index.js +1 -0
  115. package/dist/packlets/yaml/index.js.map +1 -0
  116. package/dist/packlets/yaml/serializers.js +48 -0
  117. package/dist/packlets/yaml/serializers.js.map +1 -0
  118. package/dist/packlets/zip-file-tree/index.js.map +1 -0
  119. package/dist/packlets/zip-file-tree/zipFileTreeAccessors.js +2 -2
  120. package/dist/packlets/zip-file-tree/zipFileTreeAccessors.js.map +1 -0
  121. package/dist/packlets/zip-file-tree/zipFileTreeWriter.js.map +1 -0
  122. package/dist/ts-extras.d.ts +4342 -285
  123. package/dist/tsdoc-metadata.json +1 -1
  124. package/lib/index.browser.d.ts +4 -2
  125. package/lib/index.browser.d.ts.map +1 -0
  126. package/lib/index.browser.js +8 -3
  127. package/lib/index.browser.js.map +1 -0
  128. package/lib/index.d.ts.map +1 -0
  129. package/lib/index.js.map +1 -0
  130. package/lib/packlets/ai-assist/apiClient.d.ts +115 -32
  131. package/lib/packlets/ai-assist/apiClient.d.ts.map +1 -0
  132. package/lib/packlets/ai-assist/apiClient.js +888 -156
  133. package/lib/packlets/ai-assist/apiClient.js.map +1 -0
  134. package/lib/packlets/ai-assist/chatRequestBuilders.d.ts +149 -0
  135. package/lib/packlets/ai-assist/chatRequestBuilders.d.ts.map +1 -0
  136. package/lib/packlets/ai-assist/chatRequestBuilders.js +293 -0
  137. package/lib/packlets/ai-assist/chatRequestBuilders.js.map +1 -0
  138. package/lib/packlets/ai-assist/converters.d.ts +15 -1
  139. package/lib/packlets/ai-assist/converters.d.ts.map +1 -0
  140. package/lib/packlets/ai-assist/converters.js +47 -3
  141. package/lib/packlets/ai-assist/converters.js.map +1 -0
  142. package/lib/packlets/ai-assist/embeddingClient.d.ts +69 -0
  143. package/lib/packlets/ai-assist/embeddingClient.d.ts.map +1 -0
  144. package/lib/packlets/ai-assist/embeddingClient.js +349 -0
  145. package/lib/packlets/ai-assist/embeddingClient.js.map +1 -0
  146. package/lib/packlets/ai-assist/endpoint.d.ts +28 -0
  147. package/lib/packlets/ai-assist/endpoint.d.ts.map +1 -0
  148. package/lib/packlets/ai-assist/endpoint.js +82 -0
  149. package/lib/packlets/ai-assist/endpoint.js.map +1 -0
  150. package/lib/packlets/ai-assist/http.d.ts +24 -0
  151. package/lib/packlets/ai-assist/http.d.ts.map +1 -0
  152. package/lib/packlets/ai-assist/http.js +78 -0
  153. package/lib/packlets/ai-assist/http.js.map +1 -0
  154. package/lib/packlets/ai-assist/imageOptionsResolver.d.ts +66 -0
  155. package/lib/packlets/ai-assist/imageOptionsResolver.d.ts.map +1 -0
  156. package/lib/packlets/ai-assist/imageOptionsResolver.js +197 -0
  157. package/lib/packlets/ai-assist/imageOptionsResolver.js.map +1 -0
  158. package/lib/packlets/ai-assist/index.d.ts +10 -4
  159. package/lib/packlets/ai-assist/index.d.ts.map +1 -0
  160. package/lib/packlets/ai-assist/index.js +36 -1
  161. package/lib/packlets/ai-assist/index.js.map +1 -0
  162. package/lib/packlets/ai-assist/jsonCompletion.d.ts +93 -0
  163. package/lib/packlets/ai-assist/jsonCompletion.d.ts.map +1 -0
  164. package/lib/packlets/ai-assist/jsonCompletion.js +97 -0
  165. package/lib/packlets/ai-assist/jsonCompletion.js.map +1 -0
  166. package/lib/packlets/ai-assist/jsonResponse.d.ts +91 -0
  167. package/lib/packlets/ai-assist/jsonResponse.d.ts.map +1 -0
  168. package/lib/packlets/ai-assist/jsonResponse.js +154 -0
  169. package/lib/packlets/ai-assist/jsonResponse.js.map +1 -0
  170. package/lib/packlets/ai-assist/model.d.ts +1202 -12
  171. package/lib/packlets/ai-assist/model.d.ts.map +1 -0
  172. package/lib/packlets/ai-assist/model.js +198 -10
  173. package/lib/packlets/ai-assist/model.js.map +1 -0
  174. package/lib/packlets/ai-assist/registry.d.ts +56 -1
  175. package/lib/packlets/ai-assist/registry.d.ts.map +1 -0
  176. package/lib/packlets/ai-assist/registry.js +319 -13
  177. package/lib/packlets/ai-assist/registry.js.map +1 -0
  178. package/lib/packlets/ai-assist/sseParser.d.ts +45 -0
  179. package/lib/packlets/ai-assist/sseParser.d.ts.map +1 -0
  180. package/lib/packlets/ai-assist/sseParser.js +128 -0
  181. package/lib/packlets/ai-assist/sseParser.js.map +1 -0
  182. package/lib/packlets/ai-assist/streamingAdapters/anthropic.d.ts +72 -0
  183. package/lib/packlets/ai-assist/streamingAdapters/anthropic.d.ts.map +1 -0
  184. package/lib/packlets/ai-assist/streamingAdapters/anthropic.js +371 -0
  185. package/lib/packlets/ai-assist/streamingAdapters/anthropic.js.map +1 -0
  186. package/lib/packlets/ai-assist/streamingAdapters/clientToolContinuationBuilder.d.ts +260 -0
  187. package/lib/packlets/ai-assist/streamingAdapters/clientToolContinuationBuilder.d.ts.map +1 -0
  188. package/lib/packlets/ai-assist/streamingAdapters/clientToolContinuationBuilder.js +694 -0
  189. package/lib/packlets/ai-assist/streamingAdapters/clientToolContinuationBuilder.js.map +1 -0
  190. package/lib/packlets/ai-assist/streamingAdapters/common.d.ts +154 -0
  191. package/lib/packlets/ai-assist/streamingAdapters/common.d.ts.map +1 -0
  192. package/lib/packlets/ai-assist/streamingAdapters/common.js +193 -0
  193. package/lib/packlets/ai-assist/streamingAdapters/common.js.map +1 -0
  194. package/lib/packlets/ai-assist/streamingAdapters/gemini.d.ts +43 -0
  195. package/lib/packlets/ai-assist/streamingAdapters/gemini.d.ts.map +1 -0
  196. package/lib/packlets/ai-assist/streamingAdapters/gemini.js +207 -0
  197. package/lib/packlets/ai-assist/streamingAdapters/gemini.js.map +1 -0
  198. package/lib/packlets/ai-assist/streamingAdapters/openaiChat.d.ts +19 -0
  199. package/lib/packlets/ai-assist/streamingAdapters/openaiChat.d.ts.map +1 -0
  200. package/lib/packlets/ai-assist/streamingAdapters/openaiChat.js +173 -0
  201. package/lib/packlets/ai-assist/streamingAdapters/openaiChat.js.map +1 -0
  202. package/lib/packlets/ai-assist/streamingAdapters/openaiResponses.d.ts +33 -0
  203. package/lib/packlets/ai-assist/streamingAdapters/openaiResponses.d.ts.map +1 -0
  204. package/lib/packlets/ai-assist/streamingAdapters/openaiResponses.js +389 -0
  205. package/lib/packlets/ai-assist/streamingAdapters/openaiResponses.js.map +1 -0
  206. package/lib/packlets/ai-assist/streamingAdapters/proxy.d.ts +34 -0
  207. package/lib/packlets/ai-assist/streamingAdapters/proxy.d.ts.map +1 -0
  208. package/lib/packlets/ai-assist/streamingAdapters/proxy.js +176 -0
  209. package/lib/packlets/ai-assist/streamingAdapters/proxy.js.map +1 -0
  210. package/lib/packlets/ai-assist/streamingClient.d.ts +50 -0
  211. package/lib/packlets/ai-assist/streamingClient.d.ts.map +1 -0
  212. package/lib/packlets/ai-assist/streamingClient.js +146 -0
  213. package/lib/packlets/ai-assist/streamingClient.js.map +1 -0
  214. package/lib/packlets/ai-assist/thinkingOptionsResolver.d.ts +87 -0
  215. package/lib/packlets/ai-assist/thinkingOptionsResolver.d.ts.map +1 -0
  216. package/lib/packlets/ai-assist/thinkingOptionsResolver.js +294 -0
  217. package/lib/packlets/ai-assist/thinkingOptionsResolver.js.map +1 -0
  218. package/lib/packlets/ai-assist/toolFormats.d.ts +40 -9
  219. package/lib/packlets/ai-assist/toolFormats.d.ts.map +1 -0
  220. package/lib/packlets/ai-assist/toolFormats.js +107 -10
  221. package/lib/packlets/ai-assist/toolFormats.js.map +1 -0
  222. package/lib/packlets/conversion/converters.d.ts +8 -1
  223. package/lib/packlets/conversion/converters.d.ts.map +1 -0
  224. package/lib/packlets/conversion/converters.js +36 -2
  225. package/lib/packlets/conversion/converters.js.map +1 -0
  226. package/lib/packlets/conversion/index.d.ts.map +1 -0
  227. package/lib/packlets/conversion/index.js.map +1 -0
  228. package/lib/packlets/crypto-utils/constants.d.ts.map +1 -0
  229. package/lib/packlets/crypto-utils/constants.js.map +1 -0
  230. package/lib/packlets/crypto-utils/converters.d.ts +20 -1
  231. package/lib/packlets/crypto-utils/converters.d.ts.map +1 -0
  232. package/lib/packlets/crypto-utils/converters.js +43 -5
  233. package/lib/packlets/crypto-utils/converters.js.map +1 -0
  234. package/lib/packlets/crypto-utils/directEncryptionProvider.d.ts.map +1 -0
  235. package/lib/packlets/crypto-utils/directEncryptionProvider.js.map +1 -0
  236. package/lib/packlets/crypto-utils/encryptedFile.d.ts.map +1 -0
  237. package/lib/packlets/crypto-utils/encryptedFile.js.map +1 -0
  238. package/lib/packlets/crypto-utils/hpkeProvider.d.ts +150 -0
  239. package/lib/packlets/crypto-utils/hpkeProvider.d.ts.map +1 -0
  240. package/lib/packlets/crypto-utils/hpkeProvider.js +359 -0
  241. package/lib/packlets/crypto-utils/hpkeProvider.js.map +1 -0
  242. package/lib/packlets/crypto-utils/index.browser.d.ts +4 -1
  243. package/lib/packlets/crypto-utils/index.browser.d.ts.map +1 -0
  244. package/lib/packlets/crypto-utils/index.browser.js +22 -3
  245. package/lib/packlets/crypto-utils/index.browser.js.map +1 -0
  246. package/lib/packlets/crypto-utils/index.d.ts +3 -0
  247. package/lib/packlets/crypto-utils/index.d.ts.map +1 -0
  248. package/lib/packlets/crypto-utils/index.js +18 -1
  249. package/lib/packlets/crypto-utils/index.js.map +1 -0
  250. package/lib/packlets/crypto-utils/keyPairAlgorithmParams.d.ts +54 -0
  251. package/lib/packlets/crypto-utils/keyPairAlgorithmParams.d.ts.map +1 -0
  252. package/lib/packlets/crypto-utils/keyPairAlgorithmParams.js +74 -0
  253. package/lib/packlets/crypto-utils/keyPairAlgorithmParams.js.map +1 -0
  254. package/lib/packlets/crypto-utils/keystore/converters.d.ts +68 -6
  255. package/lib/packlets/crypto-utils/keystore/converters.d.ts.map +1 -0
  256. package/lib/packlets/crypto-utils/keystore/converters.js +103 -12
  257. package/lib/packlets/crypto-utils/keystore/converters.js.map +1 -0
  258. package/lib/packlets/crypto-utils/keystore/encryptedFilePrivateKeyStorage.d.ts +148 -0
  259. package/lib/packlets/crypto-utils/keystore/encryptedFilePrivateKeyStorage.d.ts.map +1 -0
  260. package/lib/packlets/crypto-utils/keystore/encryptedFilePrivateKeyStorage.js +324 -0
  261. package/lib/packlets/crypto-utils/keystore/encryptedFilePrivateKeyStorage.js.map +1 -0
  262. package/lib/packlets/crypto-utils/keystore/index.browser.d.ts +10 -0
  263. package/lib/packlets/crypto-utils/keystore/index.browser.d.ts.map +1 -0
  264. package/lib/packlets/crypto-utils/keystore/index.browser.js +76 -0
  265. package/lib/packlets/crypto-utils/keystore/index.browser.js.map +1 -0
  266. package/lib/packlets/crypto-utils/keystore/index.d.ts +2 -0
  267. package/lib/packlets/crypto-utils/keystore/index.d.ts.map +1 -0
  268. package/lib/packlets/crypto-utils/keystore/index.js +5 -1
  269. package/lib/packlets/crypto-utils/keystore/index.js.map +1 -0
  270. package/lib/packlets/crypto-utils/keystore/keyStore.d.ts +270 -13
  271. package/lib/packlets/crypto-utils/keystore/keyStore.d.ts.map +1 -0
  272. package/lib/packlets/crypto-utils/keystore/keyStore.js +778 -124
  273. package/lib/packlets/crypto-utils/keystore/keyStore.js.map +1 -0
  274. package/lib/packlets/crypto-utils/keystore/model.d.ts +350 -21
  275. package/lib/packlets/crypto-utils/keystore/model.d.ts.map +1 -0
  276. package/lib/packlets/crypto-utils/keystore/model.js +32 -5
  277. package/lib/packlets/crypto-utils/keystore/model.js.map +1 -0
  278. package/lib/packlets/crypto-utils/keystore/privateKeyStorage.d.ts +53 -0
  279. package/lib/packlets/crypto-utils/keystore/privateKeyStorage.d.ts.map +1 -0
  280. package/lib/packlets/crypto-utils/keystore/privateKeyStorage.js +22 -0
  281. package/lib/packlets/crypto-utils/keystore/privateKeyStorage.js.map +1 -0
  282. package/lib/packlets/crypto-utils/model.d.ts +437 -10
  283. package/lib/packlets/crypto-utils/model.d.ts.map +1 -0
  284. package/lib/packlets/crypto-utils/model.js +33 -1
  285. package/lib/packlets/crypto-utils/model.js.map +1 -0
  286. package/lib/packlets/crypto-utils/nodeCryptoProvider.d.ts +134 -2
  287. package/lib/packlets/crypto-utils/nodeCryptoProvider.d.ts.map +1 -0
  288. package/lib/packlets/crypto-utils/nodeCryptoProvider.js +335 -0
  289. package/lib/packlets/crypto-utils/nodeCryptoProvider.js.map +1 -0
  290. package/lib/packlets/crypto-utils/spkiHelpers.d.ts +125 -0
  291. package/lib/packlets/crypto-utils/spkiHelpers.d.ts.map +1 -0
  292. package/lib/packlets/crypto-utils/spkiHelpers.js +251 -0
  293. package/lib/packlets/crypto-utils/spkiHelpers.js.map +1 -0
  294. package/lib/packlets/csv/csvFileHelpers.d.ts +0 -10
  295. package/lib/packlets/csv/csvFileHelpers.d.ts.map +1 -0
  296. package/lib/packlets/csv/csvFileHelpers.js +0 -15
  297. package/lib/packlets/csv/csvFileHelpers.js.map +1 -0
  298. package/lib/packlets/csv/csvHelpers.d.ts +10 -0
  299. package/lib/packlets/csv/csvHelpers.d.ts.map +1 -0
  300. package/lib/packlets/csv/csvHelpers.js +15 -0
  301. package/lib/packlets/csv/csvHelpers.js.map +1 -0
  302. package/lib/packlets/csv/index.browser.d.ts +0 -1
  303. package/lib/packlets/csv/index.browser.d.ts.map +1 -0
  304. package/lib/packlets/csv/index.browser.js +1 -5
  305. package/lib/packlets/csv/index.browser.js.map +1 -0
  306. package/lib/packlets/csv/index.d.ts.map +1 -0
  307. package/lib/packlets/csv/index.js.map +1 -0
  308. package/lib/packlets/experimental/extendedArray.d.ts.map +1 -0
  309. package/lib/packlets/experimental/extendedArray.js.map +1 -0
  310. package/lib/packlets/experimental/formatter.d.ts.map +1 -0
  311. package/lib/packlets/experimental/formatter.js.map +1 -0
  312. package/lib/packlets/experimental/index.d.ts.map +1 -0
  313. package/lib/packlets/experimental/index.js.map +1 -0
  314. package/lib/packlets/experimental/rangeOf.d.ts.map +1 -0
  315. package/lib/packlets/experimental/rangeOf.js.map +1 -0
  316. package/lib/packlets/hash/index.browser.d.ts.map +1 -0
  317. package/lib/packlets/hash/index.browser.js.map +1 -0
  318. package/lib/packlets/hash/index.d.ts.map +1 -0
  319. package/lib/packlets/hash/index.js.map +1 -0
  320. package/lib/packlets/hash/index.node.d.ts.map +1 -0
  321. package/lib/packlets/hash/index.node.js.map +1 -0
  322. package/lib/packlets/hash/md5Normalizer.browser.d.ts.map +1 -0
  323. package/lib/packlets/hash/md5Normalizer.browser.js.map +1 -0
  324. package/lib/packlets/hash/md5Normalizer.d.ts.map +1 -0
  325. package/lib/packlets/hash/md5Normalizer.js.map +1 -0
  326. package/lib/packlets/mustache/index.d.ts +1 -1
  327. package/lib/packlets/mustache/index.d.ts.map +1 -0
  328. package/lib/packlets/mustache/index.js.map +1 -0
  329. package/lib/packlets/mustache/interfaces.d.ts +34 -0
  330. package/lib/packlets/mustache/interfaces.d.ts.map +1 -0
  331. package/lib/packlets/mustache/interfaces.js.map +1 -0
  332. package/lib/packlets/mustache/mustacheTemplate.d.ts +2 -0
  333. package/lib/packlets/mustache/mustacheTemplate.d.ts.map +1 -0
  334. package/lib/packlets/mustache/mustacheTemplate.js +42 -4
  335. package/lib/packlets/mustache/mustacheTemplate.js.map +1 -0
  336. package/lib/packlets/record-jar/index.browser.d.ts +0 -1
  337. package/lib/packlets/record-jar/index.browser.d.ts.map +1 -0
  338. package/lib/packlets/record-jar/index.browser.js +1 -5
  339. package/lib/packlets/record-jar/index.browser.js.map +1 -0
  340. package/lib/packlets/record-jar/index.d.ts.map +1 -0
  341. package/lib/packlets/record-jar/index.js.map +1 -0
  342. package/lib/packlets/record-jar/recordJarFileHelpers.d.ts +0 -11
  343. package/lib/packlets/record-jar/recordJarFileHelpers.d.ts.map +1 -0
  344. package/lib/packlets/record-jar/recordJarFileHelpers.js +0 -19
  345. package/lib/packlets/record-jar/recordJarFileHelpers.js.map +1 -0
  346. package/lib/packlets/record-jar/recordJarHelpers.d.ts +11 -0
  347. package/lib/packlets/record-jar/recordJarHelpers.d.ts.map +1 -0
  348. package/lib/packlets/record-jar/recordJarHelpers.js +19 -0
  349. package/lib/packlets/record-jar/recordJarHelpers.js.map +1 -0
  350. package/lib/packlets/yaml/converters.d.ts.map +1 -0
  351. package/lib/packlets/yaml/converters.js.map +1 -0
  352. package/lib/packlets/yaml/index.d.ts +1 -0
  353. package/lib/packlets/yaml/index.d.ts.map +1 -0
  354. package/lib/packlets/yaml/index.js +1 -0
  355. package/lib/packlets/yaml/index.js.map +1 -0
  356. package/lib/packlets/yaml/serializers.d.ts +45 -0
  357. package/lib/packlets/yaml/serializers.d.ts.map +1 -0
  358. package/lib/packlets/yaml/serializers.js +84 -0
  359. package/lib/packlets/yaml/serializers.js.map +1 -0
  360. package/lib/packlets/zip-file-tree/index.d.ts.map +1 -0
  361. package/lib/packlets/zip-file-tree/index.js.map +1 -0
  362. package/lib/packlets/zip-file-tree/zipFileTreeAccessors.d.ts +2 -2
  363. package/lib/packlets/zip-file-tree/zipFileTreeAccessors.d.ts.map +1 -0
  364. package/lib/packlets/zip-file-tree/zipFileTreeAccessors.js +2 -2
  365. package/lib/packlets/zip-file-tree/zipFileTreeAccessors.js.map +1 -0
  366. package/lib/packlets/zip-file-tree/zipFileTreeWriter.d.ts.map +1 -0
  367. package/lib/packlets/zip-file-tree/zipFileTreeWriter.js.map +1 -0
  368. package/package.json +20 -15
@@ -0,0 +1 @@
1
+ {"version":3,"file":"csvHelpers.js","sourceRoot":"","sources":["../../../src/packlets/csv/csvHelpers.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;AAsBH,wCAYC;AAUD,0CASC;AAnDD,4CAAsD;AAEtD,yCAAkC;AAWlC;;;;;;GAMG;AACH,SAAgB,cAAc,CAAC,IAAY,EAAE,OAAoB;IAC/D,OAAO,IAAA,wBAAa,EAAC,GAAG,EAAE;QACxB,OAAO,GAAG,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,EAAE,CAAC;QAExB,OAAO,IAAA,iBAAK,EAAC,IAAI,kBACf,SAAS,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,EAClC,MAAM,EAAE,KAAK,EACb,aAAa,EAAE,KAAK,EACpB,cAAc,EAAE,QAAQ,IACrB,OAAO,EACV,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACnB,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,eAAe,CAC7B,QAA2B,EAC3B,QAAgB,EAChB,OAAoB;IAEpB,OAAO,QAAQ;SACZ,OAAO,CAAC,QAAQ,CAAC;SACjB,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC;SAC1C,SAAS,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,cAAc,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;AAChE,CAAC","sourcesContent":["/*\n * Copyright (c) 2020 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Result, captureResult } from '@fgv/ts-utils';\nimport { FileTree } from '@fgv/ts-json-base';\nimport { parse } from 'papaparse';\n\n/**\n * Options for {@link Csv.readCsvFileSync | readCsvFileSync}\n * @beta\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport interface CsvOptions {\n delimiter?: string;\n}\n\n/**\n * Parses CSV data from a string.\n * @param body - The CSV string to parse.\n * @param options - optional parameters to control the processing\n * @returns The parsed CSV data.\n * @beta\n */\nexport function parseCsvString(body: string, options?: CsvOptions): Result<unknown> {\n return captureResult(() => {\n options = options ?? {};\n\n return parse(body, {\n transform: (s: string) => s.trim(),\n header: false,\n dynamicTyping: false,\n skipEmptyLines: 'greedy',\n ...options\n }).data.slice(1);\n });\n}\n\n/**\n * Reads a CSV file from a FileTree.\n * @param fileTree - The FileTree to read from.\n * @param filePath - Path of the file within the tree.\n * @param options - optional parameters to control the processing\n * @returns The parsed CSV data.\n * @beta\n */\nexport function readCsvFromTree(\n fileTree: FileTree.FileTree,\n filePath: string,\n options?: CsvOptions\n): Result<unknown> {\n return fileTree\n .getFile(filePath)\n .onSuccess((file) => file.getRawContents())\n .onSuccess((contents) => parseCsvString(contents, options));\n}\n"]}
@@ -1,3 +1,2 @@
1
1
  export * from './csvHelpers';
2
- export { readCsvFromTree } from './csvFileHelpers';
3
2
  //# sourceMappingURL=index.browser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.browser.d.ts","sourceRoot":"","sources":["../../../src/packlets/csv/index.browser.ts"],"names":[],"mappings":"AAyBA,cAAc,cAAc,CAAC"}
@@ -35,13 +35,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
35
35
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
36
36
  };
37
37
  Object.defineProperty(exports, "__esModule", { value: true });
38
- exports.readCsvFromTree = void 0;
39
38
  // Browser-safe CSV exports - excludes Node.js filesystem dependencies
40
- // Export all browser-safe parsing functionality
39
+ // Export all browser-safe parsing functionality (includes readCsvFromTree)
41
40
  __exportStar(require("./csvHelpers"), exports);
42
- // Export FileTree-based reading (web-compatible)
43
- var csvFileHelpers_1 = require("./csvFileHelpers");
44
- Object.defineProperty(exports, "readCsvFromTree", { enumerable: true, get: function () { return csvFileHelpers_1.readCsvFromTree; } });
45
41
  // Exclude:
46
42
  // - readCsvFileSync (requires Node.js fs/path)
47
43
  //# sourceMappingURL=index.browser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.browser.js","sourceRoot":"","sources":["../../../src/packlets/csv/index.browser.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;AAEH,sEAAsE;AAEtE,2EAA2E;AAC3E,+CAA6B;AAE7B,WAAW;AACX,+CAA+C","sourcesContent":["/*\n * Copyright (c) 2020 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n// Browser-safe CSV exports - excludes Node.js filesystem dependencies\n\n// Export all browser-safe parsing functionality (includes readCsvFromTree)\nexport * from './csvHelpers';\n\n// Exclude:\n// - readCsvFileSync (requires Node.js fs/path)\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/packlets/csv/index.ts"],"names":[],"mappings":"AAuBA,cAAc,cAAc,CAAC;AAE7B,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/packlets/csv/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;AAEH,kCAAkC;AAClC,+CAA6B;AAC7B,yDAAyD;AACzD,mDAAiC","sourcesContent":["/*\n * Copyright (c) 2020 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n// Export tree-shakeable functions\nexport * from './csvHelpers';\n// Filesystem helpers in separate module for tree-shaking\nexport * from './csvFileHelpers';\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extendedArray.d.ts","sourceRoot":"","sources":["../../../src/packlets/experimental/extendedArray.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,MAAM,EAAiB,MAAM,eAAe,CAAC;AAEtD;;;;GAIG;AACH,qBAAa,aAAa,CAAC,CAAC,CAAE,SAAQ,KAAK,CAAC,CAAC,CAAC;IAC5C,SAAgB,eAAe,EAAE,MAAM,CAAC;IAExC;;;;OAIG;gBACgB,eAAe,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,CAAC,EAAE;IAKzD;;;;;;OAMG;WACW,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,IAAI,aAAa,CAAC,CAAC,CAAC;IAIhE;;;;;;;OAOG;IACI,MAAM,CAA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I,EAAC,GAAG,IAAI,CAAC,eAAe,YAAY,KAAK,CAAC,MAAM,QAAQ,CAAC,CAAC;IACvE,CAAC;IAED;;;;;;OAMG;IACI,KAAK,CAAC,WAAoB;QAC/B,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACpB,OAAO,IAAA,kBAAO,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1B,CAAC;QACD,OAAO,IAAA,eAAI,EAAC,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,GAAG,IAAI,CAAC,eAAe,YAAY,CAAC,CAAC;IAClE,CAAC;IAED;;;;;;;OAOG;IACI,UAAU,CAAC,WAAoB;QACpC,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACpB,OAAO,IAAA,kBAAO,EAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QACnC,CAAC;QACD,OAAO,IAAA,eAAI,EAAC,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,GAAG,IAAI,CAAC,eAAe,YAAY,CAAC,CAAC;IAClE,CAAC;IAED;;;;OAIG;IACI,GAAG;QACR,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;CACF;AAhFD,sCAgFC","sourcesContent":["/*\r\n * Copyright (c) 2020 Erik Fortune\r\n *\r\n * Permission is hereby granted, free of charge, to any person obtaining a copy\r\n * of this software and associated documentation files (the \"Software\"), to deal\r\n * in the Software without restriction, including without limitation the rights\r\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n * copies of the Software, and to permit persons to whom the Software is\r\n * furnished to do so, subject to the following conditions:\r\n *\r\n * The above copyright notice and this permission notice shall be included in all\r\n * copies or substantial portions of the Software.\r\n *\r\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\n * SOFTWARE.\r\n */\r\n\r\nimport { Result, fail, succeed } from '@fgv/ts-utils';\r\n\r\n/**\r\n * An experimental array template which extend built-in `Array` to include a handful\r\n * of predicates which return `Result<T>`.\r\n * @beta\r\n */\r\nexport class ExtendedArray<T> extends Array<T> {\r\n public readonly itemDescription: string;\r\n\r\n /**\r\n * Constructs an {@link Experimental.ExtendedArray | ExtendedArray}.\r\n * @param itemDescription - Brief description of the type of each item in this array.\r\n * @param items - The initial contents of the array.\r\n */\r\n public constructor(itemDescription: string, ...items: T[]) {\r\n super(...items);\r\n this.itemDescription = itemDescription;\r\n }\r\n\r\n /**\r\n * Type guard to determine if some arbitrary array is an\r\n * {@link Experimental.ExtendedArray}\r\n * @param a - The `Array` to be tested.\r\n * @returns Returns `true` if `a` is an {@link Experimental.ExtendedArray | ExtendedArray},\r\n * `false` otherwise.\r\n */\r\n public static isExtendedArray<T>(a?: T[]): a is ExtendedArray<T> {\r\n return a instanceof ExtendedArray;\r\n }\r\n\r\n /**\r\n * Determines if this array contains exactly one element which matches\r\n * a supplied predicate.\r\n * @param predicate - The predicate function to be applied.\r\n * @returns Returns `Success<T>` with the single matching\r\n * result if exactly one item matches `predicate`. Returns `Failure<T>`\r\n * with an error message if there are no matches or more than one match.\r\n */\r\n public single(predicate?: (item: T) => boolean): Result<T> {\r\n const match = predicate ? this.filter(predicate) : this;\r\n if (match.length === 1) {\r\n return succeed(match[0]);\r\n }\r\n if (match.length === 0) {\r\n return fail(`${this.itemDescription} not found`);\r\n }\r\n return fail(`${this.itemDescription} matches ${match.length} items`);\r\n }\r\n\r\n /**\r\n * Returns the first element of an {@link Experimental.ExtendedArray | ExtendedArray}. Fails with an\r\n * error message if the array is empty.\r\n * @param failMessage - Optional message to be displayed in the event of failure.\r\n * @returns Returns `Success<T>` with the value of the first element\r\n * in the array, or `Failure<T>` with an error message if the array is empty.\r\n */\r\n public first(failMessage?: string): Result<T> {\r\n if (this.length > 0) {\r\n return succeed(this[0]);\r\n }\r\n return fail(failMessage ?? `${this.itemDescription} not found`);\r\n }\r\n\r\n /**\r\n * Returns an array containing all elements of an {@link Experimental.ExtendedArray | ExtendedArray}.\r\n * Fails with an error message if the array is empty.\r\n * @param failMessage - Optional message to be displayed in the event of failure.\r\n * @returns Returns `Success<T>` with a new (non-extended) `Array`\r\n * containing the elements of this array, or `Failure<T>` with an error message\r\n * if the array is empty.\r\n */\r\n public atLeastOne(failMessage?: string): Result<T[]> {\r\n if (this.length > 0) {\r\n return succeed(Array.from(this));\r\n }\r\n return fail(failMessage ?? `${this.itemDescription} not found`);\r\n }\r\n\r\n /**\r\n * Gets a new (non-extended) `Array` containing all of the elements from this\r\n * {@link Experimental.ExtendedArray | ExtendedArray}.\r\n * @returns A new (non-extended) `Array<T>`.\r\n */\r\n public all(): T[] {\r\n return Array.from(this);\r\n }\r\n}\r\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatter.d.ts","sourceRoot":"","sources":["../../../src/packlets/experimental/formatter.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,MAAM,EAAsC,MAAM,eAAe,CAAC;AAK3E;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,UAAU,GAAG,OAAO,CAAC;AAE1D;;;GAGG;AAEH,MAAM,WAAW,WAAW;IAC1B;;;;;OAKG;IACH,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;CACxC;AAED;;;GAGG;AACH,qBAAa,eAAe;IAC1B;;;;;;OAMG;IACH,SAAS,CA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AAK,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;YAC7C,OAAO,CAAC,IAAI,CAAC,GAAG,MAAM,IAAI,KAAK,EAAE,CAAC,CAAC;QACrC,CAAC;IACH,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,QAAgB;QAC5B,OAAO,IAAA,wBAAa,EAAC,GAAG,EAAE,CAAC,kBAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC;IAC9D,CAAC;CACF;AArBD,0CAqBC;AAsBD;;;;;;;;GAQG;AACH,SAAgB,UAAU,CAAI,MAAc,EAAE,KAAU,EAAE,aAA2B;IACnF,OAAO,IAAA,qBAAU,EACf,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACjB,OAAO,aAAa,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACrC,CAAC,CAAC,CACH,CAAC,SAAS,CAAC,CAAC,OAAiB,EAAE,EAAE;QAChC,MAAM,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;QACjD,OAAO,IAAA,kBAAO,EAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACtC,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["/*\n * Copyright (c) 2020 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Result, captureResult, mapResults, succeed } from '@fgv/ts-utils';\nimport Mustache from 'mustache';\n\nMustache.escape = (s: string) => s;\n\n/**\n * Destination format for some formatted string.\n * @beta\n */\nexport type FormatTargets = 'text' | 'markdown' | 'embed';\n\n/**\n * Interface for an object that can be formatted.\n * @beta\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport interface Formattable {\n /**\n * Formats an object using the supplied mustache template.\n * @param format - A mustache template used to format the object.\n * @returns `Success<string>` with the resulting string, or `Failure<string>`\n * with an error message if an error occurs.\n */\n format(format: string): Result<string>;\n}\n\n/**\n * Base class which adds common formatting.\n * @beta\n */\nexport class FormattableBase {\n /**\n * Helper enables derived classes to add named details to a formatted presentation.\n * @param details - An array of detail description strings.\n * @param label - Label to use for the new detail.\n * @param value - Value to use for the new detail.\n * @internal\n */\n protected static _tryAddDetail(details: string[], label: string, value: string | undefined): void {\n if (value !== undefined) {\n const padded = ` ${label}:`.padEnd(20, ' ');\n details.push(`${padded} ${value}`);\n }\n }\n\n /**\n * {@inheritDoc Experimental.Formattable.format}\n */\n public format(template: string): Result<string> {\n return captureResult(() => Mustache.render(template, this));\n }\n}\n\n/**\n * Type definition for a formatting function, which takes a `string` and an\n * item and returns `Result<string>`.\n * @beta\n */\nexport type Formatter<T> = (format: string, item: T) => Result<string>;\n\n/**\n * A collection of {@link Experimental.Formatter | formatters} indexed by target name, to enable\n * different format methods per output target.\n * @beta\n */\nexport type FormattersByExtendedTarget<TFT extends FormatTargets, T> = Record<TFT, Formatter<T>>;\n/**\n * A collection of {@link Experimental.Formatter | formatters} indexed by the\n * {@link Experimental.FormatTargets | default supported target formats}.\n * @beta\n */\nexport type FormattersByTarget<T> = FormattersByExtendedTarget<FormatTargets, T>;\n\n/**\n * Formats a list of items using the supplied template and formatter, one result\n * per output line.\n * @param format - A mustache template used to format each item.\n * @param items - The items to be formatted.\n * @param itemFormatter - The {@link Experimental.Formatter | Formatter<T>} used to format each item.\n * @returns The resulting string.\n * @beta\n */\nexport function formatList<T>(format: string, items: T[], itemFormatter: Formatter<T>): Result<string> {\n return mapResults(\n items.map((item) => {\n return itemFormatter(format, item);\n })\n ).onSuccess((results: string[]) => {\n const filtered = results.filter((s) => s !== '');\n return succeed(filtered.join('\\n'));\n });\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/packlets/experimental/index.ts"],"names":[],"mappings":"AAsBA,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/packlets/experimental/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;AAEH,kDAAgC;AAChC,8CAA4B;AAC5B,4CAA0B","sourcesContent":["/*\n * Copyright (c) 2023 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nexport * from './extendedArray';\nexport * from './formatter';\nexport * from './rangeOf';\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rangeOf.d.ts","sourceRoot":"","sources":["../../../src/packlets/experimental/rangeOf.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,MAAM,EAAiB,MAAM,eAAe,CAAC;AAGtD;;;GAGG;AAEH,MAAM,WAAW,iBAAiB,CAAC,CAAC;IAClC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACjB,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;CAClB;AAED;;;;;GAKG;AAEH,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,EAAE,cAIrC,CAAC;AAEF;;;;GAIG;AACH,qBAAa,OAAO,CAAC,CAAC,CAAE,YAAW,iBAAiB,CAAC,CAAC,CAAC;IACrD;;OAEG;IACH,SAAgB,GAAG,CAAC,EAAE,CAAC,CAAC;IACxB;;OAEG;IACH,SAAgB,GAAG,CAAC,EAAE,CAAC,CAAC;IAExB;;;;OAIG;gBACgB,GAAG,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC;IAQnC;;;;OAIG;WACW,WAAW,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,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C;YAClB,KAAK,UAAU;gBACb,OAAO,IAAI,CAAC,GAAG,CAAC;QACpB,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;;;;;;OAOG;IACI,qBAAqB,CAAC,MAAwC;QACnE,OAAO;YACL,GAAG,EAAE,IAAI,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS;YAC1D,GAAG,EAAE,IAAI,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS;SAC3D,CAAC;IACJ,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,MAAwC,EAAE,OAAwB;QAC9E,OAAO,OAAO,CAAC,kBAAkB,CAAC,IAAI,CAAC,qBAAqB,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,CAAC;IACjF,CAAC;IAED;;;;;;;OAOG;IACO,QAAQ,CAAC,EAAK,EAAE,EAAK;QAC7B,OAAO,OAAO,CAAC,eAAe,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IACzC,CAAC;CACF;AA7JD,0BA6JC","sourcesContent":["/*\n * Copyright (c) 2020 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Result, captureResult } from '@fgv/ts-utils';\nimport Mustache from 'mustache';\n\n/**\n * Represents a generic range of some comparable type `<T>`.\n * @public\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport interface RangeOfProperties<T> {\n readonly min?: T;\n readonly max?: T;\n}\n\n/**\n * Format strings (in mustache format) to\n * use for both open-ended and complete\n * {@link Experimental.RangeOf | RangeOf<T>}.\n * @public\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport interface RangeOfFormats {\n minOnly: string;\n maxOnly: string;\n minMax: string;\n}\n\n/**\n * Default {@link Experimental.RangeOfFormats | formats} to use for both\n * open-ended and complete {@link Experimental.RangeOf | RangeOf<T>}.\n * @public\n */\nexport const DEFAULT_RANGEOF_FORMATS: RangeOfFormats = {\n minOnly: '{{min}}-',\n maxOnly: '-{{max}}',\n minMax: '{{min}}-{{max}}'\n};\n\n/**\n * Simple implementation of a possibly open-ended range of some comparable\n * type `<T>` with test and formatting.\n * @public\n */\nexport class RangeOf<T> implements RangeOfProperties<T> {\n /**\n * Minimum extent of the range.\n */\n public readonly min?: T;\n /**\n * Maximum extent of the range.\n */\n public readonly max?: T;\n\n /**\n * Creates a new {@link Experimental.RangeOf | RangeOf<T>}.\n * @param min - Optional minimum extent of the range.\n * @param max - Optional maximum extent of the range.\n */\n public constructor(min?: T, max?: T) {\n if (min !== undefined && max !== undefined && this._compare(min, max) === 'greater') {\n throw new Error(`Inverted range - ${JSON.stringify(min)} must be <= ${JSON.stringify(max)}.`);\n }\n this.min = min;\n this.max = max;\n }\n\n /**\n * Static constructor for a {@link Experimental.RangeOf | RangeOf<T>}.\n * @param init - {@link Experimental.RangeOfProperties | Range initializer}.\n * @returns A new {@link Experimental.RangeOf | RangeOf<T>}.\n */\n public static createRange<T>(init?: RangeOfProperties<T>): Result<RangeOf<T>> {\n return captureResult(() => new RangeOf<T>(init?.min, init?.max));\n }\n\n /**\n * Gets a formatted description of a {@link Experimental.RangeOfProperties | RangeOfProperties<T>} given an\n * optional set of formats and 'empty' value to use.\n * @param range - The {@link Experimental.RangeOfProperties | RangeOfProperties<T>} to be formatted.\n * @param formats - Optional {@link Experimental.RangeOfFormats | formats} to use. Default is\n * {@link Experimental.DEFAULT_RANGEOF_FORMATS | DEFAULT_RANGEOF_FORMATS}.\n * @param emptyValue - Value which represents unbounded minimum or maximum for this range. Default is `undefined`.\n * @returns A string representation of the range.\n */\n public static propertiesToString<T>(\n range: RangeOfProperties<T>,\n formats?: RangeOfFormats,\n emptyValue?: T\n ): string | undefined {\n formats = formats ?? DEFAULT_RANGEOF_FORMATS;\n if (range.min !== undefined && range.min !== emptyValue) {\n if (range.max !== undefined && range.max !== emptyValue) {\n return Mustache.render(formats.minMax, range);\n } else {\n return Mustache.render(formats.minOnly, range);\n }\n } else if (range.max !== undefined && range.max !== emptyValue) {\n return Mustache.render(formats.maxOnly, range);\n }\n return undefined;\n }\n\n /**\n * Default comparison uses javascript built-in comparison.\n * @param t1 - First value to be compared.\n * @param t2 - Second value to be compared.\n * @returns `'less'` if `t1` is less than `t2`, `'greater'` if `t1` is larger\n * and `'equal'` if `t1` and `t2` are equal.\n * @internal\n */\n protected static _defaultCompare<T>(t1: T, t2: T): 'less' | 'equal' | 'greater' {\n if (t1 < t2) {\n return 'less';\n } else if (t1 > t2) {\n return 'greater';\n }\n return 'equal';\n }\n\n /**\n * Checks if a supplied value is within this range.\n * @param t - The value to be tested.\n * @returns `'included'` if `t` falls within the range, `'less'` if `t` falls\n * below the minimum extent of the range and `'greater'` if `t` is above the\n * maximum extent.\n */\n public check(t: T): 'less' | 'included' | 'greater' {\n if (this.min !== undefined && this._compare(t, this.min) === 'less') {\n return 'less';\n }\n if (this.max !== undefined && this._compare(t, this.max) !== 'less') {\n return 'greater';\n }\n return 'included';\n }\n\n /**\n * Determines if a supplied value is within this range.\n * @param t - The value to be tested.\n * @returns Returns `true` if `t` falls within the range, `false` otherwise.\n */\n public includes(t: T): boolean {\n return this.check(t) === 'included';\n }\n\n /**\n * Finds the transition value that would bring a supplied value `t` into\n * range.\n * @param t - The value to be tested.\n * @returns The minimum extent of the range if `t` is below the range or\n * the maximum extent of the range if `t` is above the range. Returns\n * `undefined` if `t` already falls within the range.\n */\n public findTransition(t: T): T | undefined {\n switch (this.check(t)) {\n case 'less':\n return this.min;\n case 'included':\n return this.max;\n }\n return undefined;\n }\n\n /**\n * Formats the minimum and maximum values of this range.\n * @param format - A format function used to format the values.\n * @returns A {@link Experimental.RangeOfProperties | RangeOfProperties<string>} containing the\n * formatted representation of the {@link Experimental.RangeOf.min | minimum} and\n * {@link Experimental.RangeOf.max | maximum}\n * extent of the range, or `undefined` for an extent that is not present.\n */\n public toFormattedProperties(format: (value: T) => string | undefined): RangeOfProperties<string> {\n return {\n min: this.min !== undefined ? format(this.min) : undefined,\n max: this.max !== undefined ? format(this.max) : undefined\n };\n }\n\n /**\n * Formats this range using the supplied format function.\n * @param format - Format function used to format minimum and maximum extent values.\n * @param formats - The {@link Experimental.RangeOfFormats | format strings} used to format the range\n * (default {@link Experimental.DEFAULT_RANGEOF_FORMATS}).\n * @returns Returns a formatted representation of this range.\n */\n public format(format: (value: T) => string | undefined, formats?: RangeOfFormats): string | undefined {\n return RangeOf.propertiesToString(this.toFormattedProperties(format), formats);\n }\n\n /**\n * Inner compare method can be overridden by a derived class.\n * @param t1 - First value to compare.\n * @param t2 - Second value to compare.\n * @returns `'less'` if `t1` is less than `t2`, `'greater'` if `t1` is larger\n * and `'equal'` if `t1` and `t2` are equal.\n * @internal\n */\n protected _compare(t1: T, t2: T): 'less' | 'equal' | 'greater' {\n return RangeOf._defaultCompare(t1, t2);\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.browser.d.ts","sourceRoot":"","sources":["../../../src/packlets/hash/index.browser.ts"],"names":[],"mappings":"AAuBA,cAAc,yBAAyB,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.browser.js","sourceRoot":"","sources":["../../../src/packlets/hash/index.browser.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;AAEH,mEAAmE;AACnE,0DAAwC","sourcesContent":["/*\n * Copyright (c) 2020 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n// Browser-safe hash exports - excludes Node.js crypto dependencies\nexport * from './md5Normalizer.browser';\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/packlets/hash/index.ts"],"names":[],"mappings":"AAsBA,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/packlets/hash/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;AAEH,kDAAgC","sourcesContent":["/*\n * Copyright (c) 2020 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nexport * from './md5Normalizer';\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.node.d.ts","sourceRoot":"","sources":["../../../src/packlets/hash/index.node.ts"],"names":[],"mappings":"AAwBA,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.node.js","sourceRoot":"","sources":["../../../src/packlets/hash/index.node.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;AAEH,kFAAkF;AAClF,+DAA+D;AAC/D,kDAAgC;AAChC,oBAAoB","sourcesContent":["/*\n * Copyright (c) 2020 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n/* c8 ignore start - Node.js-specific export used conditionally in package.json */\n// Node.js hash exports - includes crypto-based implementations\nexport * from './md5Normalizer';\n/* c8 ignore stop */\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"md5Normalizer.browser.d.ts","sourceRoot":"","sources":["../../../src/packlets/hash/md5Normalizer.browser.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAErC;;;;;;;;GAQG;AACH,qBAAa,aAAc,SAAQ,IAAI,CAAC,eAAe;CAGtD"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"md5Normalizer.browser.js","sourceRoot":"","sources":["../../../src/packlets/hash/md5Normalizer.browser.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,4CAAqC;AAErC;;;;;;;;GAQG;AACH,MAAa,aAAc,SAAQ,eAAI,CAAC,eAAe;CAGtD;AAHD,sCAGC","sourcesContent":["/*\n * Copyright (c) 2023 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Hash } from '@fgv/ts-utils';\n\n/**\n * Browser-compatible MD5 normalizer that uses CRC32 hashing for cross-platform compatibility.\n * This provides the same interface as the Node.js MD5 version but uses CRC32 algorithm\n * which works consistently across both Node.js and browser environments.\n *\n * Note: While this is named Md5Normalizer for API compatibility, it actually uses CRC32\n * hashing to ensure cross-platform compatibility between Node.js and browser environments.\n * @public\n */\nexport class Md5Normalizer extends Hash.Crc32Normalizer {\n // CRC32 normalizer is already cross-platform compatible\n // No additional implementation needed - inherits everything from Crc32Normalizer\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"md5Normalizer.d.ts","sourceRoot":"","sources":["../../../src/packlets/hash/md5Normalizer.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAErC;;;;GAIG;AACH,qBAAa,aAAc,SAAQ,IAAI,CAAC,iBAAiB;;WAKzC,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM;CAG/C"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"md5Normalizer.js","sourceRoot":"","sources":["../../../src/packlets/hash/md5Normalizer.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,4CAAqC;AACrC,+CAAiC;AACjC;;;;GAIG;AACH,MAAa,aAAc,SAAQ,eAAI,CAAC,iBAAiB;IACvD;QACE,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAC/B,CAAC;IAEM,MAAM,CAAC,OAAO,CAAC,KAAe;QACnC,OAAO,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAChF,CAAC;CACF;AARD,sCAQC","sourcesContent":["/*\n * Copyright (c) 2023 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Hash } from '@fgv/ts-utils';\nimport * as crypto from 'crypto';\n/**\n * A hashing normalizer which computes object\n * hash using the MD5 algorithm.\n * @public\n */\nexport class Md5Normalizer extends Hash.HashingNormalizer {\n public constructor() {\n super(Md5Normalizer.md5Hash);\n }\n\n public static md5Hash(parts: string[]): string {\n return crypto.createHash('md5').update(parts.join('|'), 'utf8').digest('hex');\n }\n}\n"]}
@@ -1,3 +1,3 @@
1
- export { IContextValidationResult, IMissingVariableDetail, IMustacheTemplateOptions, IVariableRef, MustacheTokenType } from './interfaces';
1
+ export { IContextValidationResult, IMissingVariableDetail, IMustacheTemplateOptions, IVariableRef, MustacheEscapeStrategy, MustacheTokenType } from './interfaces';
2
2
  export { MustacheTemplate } from './mustacheTemplate';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/packlets/mustache/index.ts"],"names":[],"mappings":"AAsBA,OAAO,EACL,wBAAwB,EACxB,sBAAsB,EACtB,wBAAwB,EACxB,YAAY,EACZ,sBAAsB,EACtB,iBAAiB,EAClB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/packlets/mustache/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAWH,uDAAsD;AAA7C,oHAAA,gBAAgB,OAAA","sourcesContent":["/*\n * Copyright (c) 2020 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nexport {\n IContextValidationResult,\n IMissingVariableDetail,\n IMustacheTemplateOptions,\n IVariableRef,\n MustacheEscapeStrategy,\n MustacheTokenType\n} from './interfaces';\n\nexport { MustacheTemplate } from './mustacheTemplate';\n"]}
@@ -67,6 +67,22 @@ export interface IContextValidationResult {
67
67
  */
68
68
  readonly missingDetails: readonly IMissingVariableDetail[];
69
69
  }
70
+ /**
71
+ * Strategy applied to double-brace `{{name}}` tokens at render time.
72
+ *
73
+ * - `'html'`: the standard mustache.js HTML escape (back-compat default).
74
+ * - `'none'`: verbatim passthrough — values are interpolated as-is
75
+ * (coerced to `String`). Suitable for LLM-prompt rendering and other
76
+ * non-HTML targets where `& → &amp;` corrupts the output.
77
+ * - `(value) => string`: caller-supplied escape function.
78
+ *
79
+ * Note: triple-brace `{{{name}}}` (and `{{&name}}`) tokens are always
80
+ * rendered unescaped regardless of this strategy — that is the standard
81
+ * mustache.js semantics and is not affected by this option.
82
+ *
83
+ * @public
84
+ */
85
+ export type MustacheEscapeStrategy = 'html' | 'none' | ((value: string) => string);
70
86
  /**
71
87
  * Options for template parsing and validation.
72
88
  * @public
@@ -84,6 +100,23 @@ export interface IMustacheTemplateOptions {
84
100
  * Whether to include partial references in variable extraction (default: false)
85
101
  */
86
102
  readonly includePartials?: boolean;
103
+ /**
104
+ * Escape strategy applied to double-brace `{{name}}` tokens at render
105
+ * time. Default `'html'` preserves the existing mustache.js behavior
106
+ * (back-compat).
107
+ *
108
+ * Pass `'none'` for LLM-prompt or other non-HTML targets where the
109
+ * default `& → &amp;` escape would corrupt the output. Pass a custom
110
+ * function for any other escape policy.
111
+ *
112
+ * The strategy is applied per-template via a private `Mustache.Writer`
113
+ * instance; no global state on the `mustache` module is mutated, so
114
+ * concurrent templates with different strategies are safe.
115
+ *
116
+ * Note: triple-brace `{{{name}}}` tokens are always rendered unescaped
117
+ * regardless of strategy (standard mustache.js semantics).
118
+ */
119
+ readonly escape?: MustacheEscapeStrategy;
87
120
  }
88
121
  /**
89
122
  * Required version of options with all fields populated.
@@ -93,5 +126,6 @@ export interface IRequiredMustacheTemplateOptions {
93
126
  readonly tags: [string, string];
94
127
  readonly includeComments: boolean;
95
128
  readonly includePartials: boolean;
129
+ readonly escape: MustacheEscapeStrategy;
96
130
  }
97
131
  //# sourceMappingURL=interfaces.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/packlets/mustache/interfaces.ts"],"names":[],"mappings":"AAuBA;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GACzB,MAAM,GACN,MAAM,GACN,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,CAAC;AAER;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IAEjC;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,iBAAiB,CAAC;IAEtC;;;OAGG;IACH,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;CAC7B;AAED;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC;IAEhC;;;OAGG;IACH,QAAQ,CAAC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],"names":[],"mappings":";AAAA,8DAA8D;AAC9D;;;;;;;;;;;;;;;;;;;;GAoBG;;AA8JH,oBAAoB","sourcesContent":["/* c8 ignore start - Type definitions only, no runtime code */\n/*\n * Copyright (c) 2020 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n/**\n * Type of a Mustache token as returned by Mustache.parse()\n * @public\n */\nexport type MustacheTokenType =\n | 'text' // Raw text\n | 'name' // {{ variable }} - escaped value\n | '&' // {{{ variable }}} or {{& variable }} - unescaped value\n | '#' // {{# section }} - section start\n | '^' // {{^ section }} - inverted section\n | '!' // {{! comment }} - comment\n | '>' // {{> partial }} - partial\n | '='; // {{= =}} - set delimiter\n\n/**\n * Represents a variable reference extracted from a Mustache template.\n * @public\n */\nexport interface IVariableRef {\n /**\n * The raw variable name as it appears in the template (e.g., 'user.name')\n */\n readonly name: string;\n\n /**\n * The path segments parsed from the variable name (e.g., ['user', 'name'])\n */\n readonly path: readonly string[];\n\n /**\n * The type of token this variable was extracted from\n */\n readonly tokenType: MustacheTokenType;\n\n /**\n * Whether this variable is used in a section context (# or ^)\n * Section variables may reference arrays/objects for iteration\n */\n readonly isSection: boolean;\n}\n\n/**\n * Details about a missing variable in context validation.\n * @public\n */\nexport interface IMissingVariableDetail {\n /**\n * The variable reference that is missing\n */\n readonly variable: IVariableRef;\n\n /**\n * The path segment where the lookup failed\n * (e.g., for 'user.profile.name' if 'profile' is missing, this would be 'profile')\n */\n readonly failedAtSegment?: string;\n\n /**\n * The parent path that exists (e.g., ['user'] if 'user' exists but 'user.profile' does not)\n */\n readonly existingPath: readonly string[];\n}\n\n/**\n * Result of context validation, containing details about missing variables.\n * @public\n */\nexport interface IContextValidationResult {\n /**\n * Whether the context is valid (has all required variables)\n */\n readonly isValid: boolean;\n\n /**\n * Variables that are present in the context\n */\n readonly presentVariables: readonly string[];\n\n /**\n * Variables that are missing from the context\n */\n readonly missingVariables: readonly string[];\n\n /**\n * Detailed information about each missing variable\n */\n readonly missingDetails: readonly IMissingVariableDetail[];\n}\n\n/**\n * Strategy applied to double-brace `{{name}}` tokens at render time.\n *\n * - `'html'`: the standard mustache.js HTML escape (back-compat default).\n * - `'none'`: verbatim passthrough — values are interpolated as-is\n * (coerced to `String`). Suitable for LLM-prompt rendering and other\n * non-HTML targets where `& → &amp;` corrupts the output.\n * - `(value) => string`: caller-supplied escape function.\n *\n * Note: triple-brace `{{{name}}}` (and `{{&name}}`) tokens are always\n * rendered unescaped regardless of this strategy — that is the standard\n * mustache.js semantics and is not affected by this option.\n *\n * @public\n */\nexport type MustacheEscapeStrategy = 'html' | 'none' | ((value: string) => string);\n\n/**\n * Options for template parsing and validation.\n * @public\n */\nexport interface IMustacheTemplateOptions {\n /**\n * Custom opening and closing tags (default: `['{{', '}}']`)\n */\n readonly tags?: readonly [string, string];\n\n /**\n * Whether to include comment tokens in variable extraction (default: false)\n */\n readonly includeComments?: boolean;\n\n /**\n * Whether to include partial references in variable extraction (default: false)\n */\n readonly includePartials?: boolean;\n\n /**\n * Escape strategy applied to double-brace `{{name}}` tokens at render\n * time. Default `'html'` preserves the existing mustache.js behavior\n * (back-compat).\n *\n * Pass `'none'` for LLM-prompt or other non-HTML targets where the\n * default `& → &amp;` escape would corrupt the output. Pass a custom\n * function for any other escape policy.\n *\n * The strategy is applied per-template via a private `Mustache.Writer`\n * instance; no global state on the `mustache` module is mutated, so\n * concurrent templates with different strategies are safe.\n *\n * Note: triple-brace `{{{name}}}` tokens are always rendered unescaped\n * regardless of strategy (standard mustache.js semantics).\n */\n readonly escape?: MustacheEscapeStrategy;\n}\n\n/**\n * Required version of options with all fields populated.\n * @internal\n */\nexport interface IRequiredMustacheTemplateOptions {\n readonly tags: [string, string];\n readonly includeComments: boolean;\n readonly includePartials: boolean;\n readonly escape: MustacheEscapeStrategy;\n}\n\n/* c8 ignore stop */\n"]}
@@ -15,6 +15,8 @@ export declare class MustacheTemplate {
15
15
  */
16
16
  readonly options: Readonly<IRequiredMustacheTemplateOptions>;
17
17
  private readonly _tokens;
18
+ private readonly _writer;
19
+ private readonly _escapeFn;
18
20
  private _variables?;
19
21
  private constructor();
20
22
  /**
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mustacheTemplate.d.ts","sourceRoot":"","sources":["../../../src/packlets/mustache/mustacheTemplate.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,MAAM,EAAgC,MAAM,eAAe,CAAC;AAGrE,OAAO,EACL,wBAAwB,EAExB,wBAAwB,EACxB,gCAAgC,EAChC,YAAY,EAGb,MAAM,cAAc,CAAC;AAmDtB;;;;GAIG;AACH,qBAAa,gBAAgB;IAC3B;;OAEG;IACH,SAAgB,QAAQ,EAAE,MAAM,CAAC;IAEjC;;OAEG;IACH,SAAgB,OAAO,EAAE,QAAQ,CAAC,gCAAgC,CAAC,CAAC;IAEpE,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAgB;IACxC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAiB;IAC3C,OAAO,CAAC,UAAU,CAAC,CAA0B;IAE7C,OAAO;IAQP;;;;;OAKG;WACW,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,wBAAwB,GAAG,MAAM,CAAC,gBAAgB,CAAC;IAOpG;;;;;OAKG;WACW,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,wBAAwB,GAAG,MAAM,CAAC,IAAI,CAAC;IAK1F;;;;OAIG;IACI,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC;IAI/B;;;OAGG;IACI,gBAAgB,IAAI,SAAS,YAAY,EAAE;IAOlD;;;OAGG;IACI,oBAAoB,IAAI,SAAS,MAAM,EAAE;IAehD;;;;OAIG;IACI,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAAC,wBAAwB,CAAC;IAmC1E;;;;;;OAMG;IACI,MAAM,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC;IAM/C;;;;OAIG;IACI,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC;IAU1D,OAAO,CAAC,MAAM,CAAC,eAAe;IAa9B,OAAO,CAAC,MAAM,CAAC,YAAY;IAO3B,OAAO,CAAC,2BAA2B;IA6CnC,OAAO,CAAC,UAAU;IAUlB,OAAO,CAAC,WAAW;CAgCpB"}
@@ -33,8 +33,43 @@ const mustache_1 = __importDefault(require("mustache"));
33
33
  const DEFAULT_OPTIONS = {
34
34
  tags: ['{{', '}}'],
35
35
  includeComments: false,
36
- includePartials: false
36
+ includePartials: false,
37
+ escape: 'html'
37
38
  };
39
+ /**
40
+ * HTML entity map matching mustache.js's internal `escapeHtml`. Held
41
+ * locally so the `'html'` escape strategy does not depend on the global
42
+ * `Mustache.escape` (which other packlets — notably `experimental` —
43
+ * mutate at module load and which mustache.js itself defines as
44
+ * mutable). Per-instance escape avoids that shared-state coupling.
45
+ */
46
+ const HTML_ENTITY_MAP = {
47
+ '&': '&amp;',
48
+ '<': '&lt;',
49
+ '>': '&gt;',
50
+ '"': '&quot;',
51
+ "'": '&#39;',
52
+ '/': '&#x2F;',
53
+ '`': '&#x60;',
54
+ '=': '&#x3D;'
55
+ };
56
+ const HTML_ESCAPE = (value) => String(value).replace(/[&<>"'`=/]/g, (ch) => HTML_ENTITY_MAP[ch]);
57
+ const PASSTHROUGH_ESCAPE = (value) => String(value);
58
+ /**
59
+ * Resolves a {@link MustacheEscapeStrategy} into the per-render
60
+ * `escape` function understood by `Mustache.Writer.render`. The
61
+ * resolved function is always non-`undefined` so the writer never
62
+ * consults the (mutable, process-global) `Mustache.escape`.
63
+ */
64
+ function _resolveEscapeFunction(strategy) {
65
+ if (strategy === 'html') {
66
+ return HTML_ESCAPE;
67
+ }
68
+ if (strategy === 'none') {
69
+ return PASSTHROUGH_ESCAPE;
70
+ }
71
+ return (value) => strategy(String(value));
72
+ }
38
73
  /**
39
74
  * A helper class for working with Mustache templates that provides
40
75
  * validation, variable extraction, and context validation utilities.
@@ -45,6 +80,8 @@ class MustacheTemplate {
45
80
  this.template = template;
46
81
  this._tokens = tokens;
47
82
  this.options = options;
83
+ this._writer = new mustache_1.default.Writer();
84
+ this._escapeFn = _resolveEscapeFunction(options.escape);
48
85
  }
49
86
  /**
50
87
  * Creates a new MustacheTemplate instance.
@@ -146,7 +183,7 @@ class MustacheTemplate {
146
183
  * @returns Success with the rendered string, or Failure if rendering fails
147
184
  */
148
185
  render(context) {
149
- return (0, ts_utils_1.captureResult)(() => mustache_1.default.render(this.template, context));
186
+ return (0, ts_utils_1.captureResult)(() => this._writer.render(this.template, context, undefined, { escape: this._escapeFn }));
150
187
  }
151
188
  /**
152
189
  * Validates the context and renders the template if validation passes.
@@ -163,14 +200,15 @@ class MustacheTemplate {
163
200
  });
164
201
  }
165
202
  static _resolveOptions(options) {
166
- var _a, _b;
203
+ var _a, _b, _c;
167
204
  if (options === undefined) {
168
205
  return DEFAULT_OPTIONS;
169
206
  }
170
207
  return {
171
208
  tags: options.tags ? [options.tags[0], options.tags[1]] : DEFAULT_OPTIONS.tags,
172
209
  includeComments: (_a = options.includeComments) !== null && _a !== void 0 ? _a : DEFAULT_OPTIONS.includeComments,
173
- includePartials: (_b = options.includePartials) !== null && _b !== void 0 ? _b : DEFAULT_OPTIONS.includePartials
210
+ includePartials: (_b = options.includePartials) !== null && _b !== void 0 ? _b : DEFAULT_OPTIONS.includePartials,
211
+ escape: (_c = options.escape) !== null && _c !== void 0 ? _c : DEFAULT_OPTIONS.escape
174
212
  };
175
213
  }
176
214
  static _parseTokens(template, options) {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mustacheTemplate.js","sourceRoot":"","sources":["../../../src/packlets/mustache/mustacheTemplate.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;AAEH,4CAAqE;AACrE,wDAA2E;AAY3E;;GAEG;AACH,MAAM,eAAe,GAAqC;IACxD,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC;IAClB,eAAe,EAAE,KAAK;IACtB,eAAe,EAAE,KAAK;IACtB,MAAM,EAAE,MAAM;CACf,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,eAAe,GAAqC;IACxD,GAAG,EAAE,OAAO;IACZ,GAAG,EAAE,MAAM;IACX,GAAG,EAAE,MAAM;IACX,GAAG,EAAE,QAAQ;IACb,GAAG,EAAE,OAAO;IACZ,GAAG,EAAE,QAAQ;IACb,GAAG,EAAE,QAAQ;IACb,GAAG,EAAE,QAAQ;CACd,CAAC;AAEF,MAAM,WAAW,GAAmB,CAAC,KAAK,EAAE,EAAE,CAC5C,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC,CAAC;AAEpE,MAAM,kBAAkB,GAAmB,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,K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/*\n * Copyright (c) 2020 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Result, captureResult, fail, succeed } from '@fgv/ts-utils';\nimport Mustache, { EscapeFunction, TemplateSpans, Writer } from 'mustache';\n\nimport {\n IContextValidationResult,\n IMissingVariableDetail,\n IMustacheTemplateOptions,\n IRequiredMustacheTemplateOptions,\n IVariableRef,\n MustacheEscapeStrategy,\n MustacheTokenType\n} from './interfaces';\n\n/**\n * Default options for MustacheTemplate\n */\nconst DEFAULT_OPTIONS: IRequiredMustacheTemplateOptions = {\n tags: ['{{', '}}'],\n includeComments: false,\n includePartials: false,\n escape: 'html'\n};\n\n/**\n * HTML entity map matching mustache.js's internal `escapeHtml`. Held\n * locally so the `'html'` escape strategy does not depend on the global\n * `Mustache.escape` (which other packlets — notably `experimental` —\n * mutate at module load and which mustache.js itself defines as\n * mutable). Per-instance escape avoids that shared-state coupling.\n */\nconst HTML_ENTITY_MAP: Readonly<Record<string, string>> = {\n '&': '&amp;',\n '<': '&lt;',\n '>': '&gt;',\n '\"': '&quot;',\n \"'\": '&#39;',\n '/': '&#x2F;',\n '`': '&#x60;',\n '=': '&#x3D;'\n};\n\nconst HTML_ESCAPE: EscapeFunction = (value) =>\n String(value).replace(/[&<>\"'`=/]/g, (ch) => HTML_ENTITY_MAP[ch]);\n\nconst PASSTHROUGH_ESCAPE: EscapeFunction = (value) => String(value);\n\n/**\n * Resolves a {@link MustacheEscapeStrategy} into the per-render\n * `escape` function understood by `Mustache.Writer.render`. The\n * resolved function is always non-`undefined` so the writer never\n * consults the (mutable, process-global) `Mustache.escape`.\n */\nfunction _resolveEscapeFunction(strategy: MustacheEscapeStrategy): EscapeFunction {\n if (strategy === 'html') {\n return HTML_ESCAPE;\n }\n if (strategy === 'none') {\n return PASSTHROUGH_ESCAPE;\n }\n return (value) => strategy(String(value));\n}\n\n/**\n * A helper class for working with Mustache templates that provides\n * validation, variable extraction, and context validation utilities.\n * @public\n */\nexport class MustacheTemplate {\n /**\n * The original template string\n */\n public readonly template: string;\n\n /**\n * The options used for parsing this template\n */\n public readonly options: Readonly<IRequiredMustacheTemplateOptions>;\n\n private readonly _tokens: TemplateSpans;\n private readonly _writer: Writer;\n private readonly _escapeFn: EscapeFunction;\n private _variables?: readonly IVariableRef[];\n\n private constructor(template: string, tokens: TemplateSpans, options: IRequiredMustacheTemplateOptions) {\n this.template = template;\n this._tokens = tokens;\n this.options = options;\n this._writer = new Mustache.Writer();\n this._escapeFn = _resolveEscapeFunction(options.escape);\n }\n\n /**\n * Creates a new MustacheTemplate instance.\n * @param template - The Mustache template string to parse\n * @param options - Optional parsing options\n * @returns Success with the template instance, or Failure if parsing fails\n */\n public static create(template: string, options?: IMustacheTemplateOptions): Result<MustacheTemplate> {\n const resolvedOptions = MustacheTemplate._resolveOptions(options);\n return MustacheTemplate._parseTokens(template, resolvedOptions).onSuccess((tokens) => {\n return succeed(new MustacheTemplate(template, tokens, resolvedOptions));\n });\n }\n\n /**\n * Validates that a template string has valid Mustache syntax.\n * @param template - The template string to validate\n * @param options - Optional parsing options\n * @returns Success with true if valid, or Failure with a descriptive error message\n */\n public static validate(template: string, options?: IMustacheTemplateOptions): Result<true> {\n const resolvedOptions = MustacheTemplate._resolveOptions(options);\n return MustacheTemplate._parseTokens(template, resolvedOptions).onSuccess(() => succeed(true as const));\n }\n\n /**\n * Checks if this template instance has valid syntax.\n * Always returns Success(true) since parsing succeeded in create().\n * @returns Success with true\n */\n public validate(): Result<true> {\n return succeed(true as const);\n }\n\n /**\n * Extracts all variable references from the template.\n * @returns An array of variable references found in the template\n */\n public extractVariables(): readonly IVariableRef[] {\n if (this._variables === undefined) {\n this._variables = this._extractVariablesFromTokens(this._tokens);\n }\n return this._variables;\n }\n\n /**\n * Extracts unique variable names from the template.\n * @returns An array of unique variable name strings (e.g., ['user.name', 'items'])\n */\n public extractVariableNames(): readonly string[] {\n const variables = this.extractVariables();\n const seen = new Set<string>();\n const names: string[] = [];\n\n for (const variable of variables) {\n if (!seen.has(variable.name)) {\n seen.add(variable.name);\n names.push(variable.name);\n }\n }\n\n return names;\n }\n\n /**\n * Validates that a context object has all required variables.\n * @param context - The context object to validate\n * @returns Success with validation result containing details about present/missing variables\n */\n public validateContext(context: unknown): Result<IContextValidationResult> {\n const variables = this.extractVariables();\n const presentVariables: string[] = [];\n const missingVariables: string[] = [];\n const missingDetails: IMissingVariableDetail[] = [];\n const checked = new Set<string>();\n\n for (const variable of variables) {\n if (checked.has(variable.name)) {\n continue;\n }\n checked.add(variable.name);\n\n const lookup = this._lookupPath(context, variable.path);\n\n if (lookup.found) {\n presentVariables.push(variable.name);\n } else {\n missingVariables.push(variable.name);\n missingDetails.push({\n variable,\n failedAtSegment: lookup.failedAt,\n existingPath: lookup.existingPath\n });\n }\n }\n\n return succeed({\n isValid: missingVariables.length === 0,\n presentVariables,\n missingVariables,\n missingDetails\n });\n }\n\n /**\n * Renders the template with the given context.\n * Use this for pre-validated contexts where you've already checked\n * that all required variables are present.\n * @param context - The context object for template rendering\n * @returns Success with the rendered string, or Failure if rendering fails\n */\n public render(context: unknown): Result<string> {\n return captureResult(() =>\n this._writer.render(this.template, context, undefined, { escape: this._escapeFn })\n );\n }\n\n /**\n * Validates the context and renders the template if validation passes.\n * @param context - The context object to validate and render with\n * @returns Success with the rendered string, or Failure with validation or render errors\n */\n public validateAndRender(context: unknown): Result<string> {\n return this.validateContext(context).onSuccess((validation) => {\n if (!validation.isValid) {\n const missing = validation.missingVariables.join(', ');\n return fail(`Missing required variables: ${missing}`);\n }\n return this.render(context);\n });\n }\n\n private static _resolveOptions(options?: IMustacheTemplateOptions): IRequiredMustacheTemplateOptions {\n if (options === undefined) {\n return DEFAULT_OPTIONS;\n }\n\n return {\n tags: options.tags ? [options.tags[0], options.tags[1]] : DEFAULT_OPTIONS.tags,\n includeComments: options.includeComments ?? DEFAULT_OPTIONS.includeComments,\n includePartials: options.includePartials ?? DEFAULT_OPTIONS.includePartials,\n escape: options.escape ?? DEFAULT_OPTIONS.escape\n };\n }\n\n private static _parseTokens(\n template: string,\n options: IRequiredMustacheTemplateOptions\n ): Result<TemplateSpans> {\n return captureResult(() => Mustache.parse(template, options.tags));\n }\n\n private _extractVariablesFromTokens(tokens: TemplateSpans): IVariableRef[] {\n const variables: IVariableRef[] = [];\n\n for (const token of tokens) {\n const type = token[0] as MustacheTokenType;\n const value = token[1] as string;\n\n // Skip text tokens\n if (type === 'text') {\n continue;\n }\n\n // Handle comments based on options\n if (type === '!' && !this.options.includeComments) {\n continue;\n }\n\n // Handle partials based on options\n if (type === '>' && !this.options.includePartials) {\n continue;\n }\n\n // Handle variable tokens: 'name', '&', '#', '^', and optionally '!', '>'\n if (type === 'name' || type === '&' || type === '#' || type === '^' || type === '!' || type === '>') {\n const isSection = type === '#' || type === '^';\n variables.push({\n name: value,\n path: this._parsePath(value),\n tokenType: type,\n isSection\n });\n }\n\n // Recursively extract from nested tokens in sections\n if ((type === '#' || type === '^') && token.length > 4) {\n const nestedTokens = token[4] as TemplateSpans;\n if (nestedTokens) {\n variables.push(...this._extractVariablesFromTokens(nestedTokens));\n }\n }\n }\n\n return variables;\n }\n\n private _parsePath(name: string): readonly string[] {\n // Handle special case of '.' which means current context\n if (name === '.') {\n return ['.'];\n }\n\n // Split on dots to get path segments\n return name.split('.').filter((segment) => segment.length > 0);\n }\n\n private _lookupPath(\n context: unknown,\n path: readonly string[]\n ): { found: boolean; existingPath: string[]; failedAt?: string } {\n // Handle '.' which always exists if context is not null/undefined\n if (path.length === 1 && path[0] === '.') {\n return { found: context !== undefined && context !== null, existingPath: [] };\n }\n\n let current: unknown = context;\n const existingPath: string[] = [];\n\n for (const segment of path) {\n if (current === undefined || current === null) {\n return { found: false, existingPath, failedAt: segment };\n }\n\n if (typeof current !== 'object') {\n return { found: false, existingPath, failedAt: segment };\n }\n\n const obj = current as Record<string, unknown>;\n if (!(segment in obj)) {\n return { found: false, existingPath, failedAt: segment };\n }\n\n current = obj[segment];\n existingPath.push(segment);\n }\n\n return { found: true, existingPath };\n }\n}\n"]}
@@ -1,3 +1,2 @@
1
1
  export * from './recordJarHelpers';
2
- export { readRecordJarFromTree } from './recordJarFileHelpers';
3
2
  //# sourceMappingURL=index.browser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.browser.d.ts","sourceRoot":"","sources":["../../../src/packlets/record-jar/index.browser.ts"],"names":[],"mappings":"AAyBA,cAAc,oBAAoB,CAAC"}
@@ -35,13 +35,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
35
35
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
36
36
  };
37
37
  Object.defineProperty(exports, "__esModule", { value: true });
38
- exports.readRecordJarFromTree = void 0;
39
38
  // Browser-safe RecordJar exports - excludes Node.js filesystem dependencies
40
- // Export all browser-safe parsing functionality
39
+ // Export all browser-safe parsing functionality (includes readRecordJarFromTree)
41
40
  __exportStar(require("./recordJarHelpers"), exports);
42
- // Export FileTree-based reading (web-compatible)
43
- var recordJarFileHelpers_1 = require("./recordJarFileHelpers");
44
- Object.defineProperty(exports, "readRecordJarFromTree", { enumerable: true, get: function () { return recordJarFileHelpers_1.readRecordJarFromTree; } });
45
41
  // Exclude:
46
42
  // - readRecordJarFileSync (requires Node.js fs/path)
47
43
  //# sourceMappingURL=index.browser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.browser.js","sourceRoot":"","sources":["../../../src/packlets/record-jar/index.browser.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;AAEH,4EAA4E;AAE5E,iFAAiF;AACjF,qDAAmC;AAEnC,WAAW;AACX,qDAAqD","sourcesContent":["/*\n * Copyright (c) 2023 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n// Browser-safe RecordJar exports - excludes Node.js filesystem dependencies\n\n// Export all browser-safe parsing functionality (includes readRecordJarFromTree)\nexport * from './recordJarHelpers';\n\n// Exclude:\n// - readRecordJarFileSync (requires Node.js fs/path)\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/packlets/record-jar/index.ts"],"names":[],"mappings":"AAuBA,cAAc,oBAAoB,CAAC;AAEnC,cAAc,wBAAwB,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/packlets/record-jar/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;AAEH,kCAAkC;AAClC,qDAAmC;AACnC,yDAAyD;AACzD,yDAAuC","sourcesContent":["/*\n * Copyright (c) 2023 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n// Export tree-shakeable functions\nexport * from './recordJarHelpers';\n// Filesystem helpers in separate module for tree-shaking\nexport * from './recordJarFileHelpers';\n"]}
@@ -1,5 +1,4 @@
1
1
  import { Result } from '@fgv/ts-utils';
2
- import { FileTree } from '@fgv/ts-json-base';
3
2
  import { JarRecord, JarRecordParserOptions } from './recordJarHelpers';
4
3
  /**
5
4
  * Reads a record-jar file from a supplied path.
@@ -10,14 +9,4 @@ import { JarRecord, JarRecordParserOptions } from './recordJarHelpers';
10
9
  * @public
11
10
  */
12
11
  export declare function readRecordJarFileSync(srcPath: string, options?: JarRecordParserOptions): Result<JarRecord[]>;
13
- /**
14
- * Reads a record-jar file from a FileTree.
15
- * @param fileTree - The FileTree to read from.
16
- * @param filePath - Path of the file within the tree.
17
- * @param options - Optional parser configuration
18
- * @returns The contents of the file as an array of `Record<string, string>`
19
- * @see https://datatracker.ietf.org/doc/html/draft-phillips-record-jar-01
20
- * @public
21
- */
22
- export declare function readRecordJarFromTree(fileTree: FileTree.FileTree, filePath: string, options?: JarRecordParserOptions): Result<JarRecord[]>;
23
12
  //# sourceMappingURL=recordJarFileHelpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recordJarFileHelpers.d.ts","sourceRoot":"","sources":["../../../src/packlets/record-jar/recordJarFileHelpers.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAE,MAAM,EAAiB,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,sBAAsB,EAAuB,MAAM,oBAAoB,CAAC;AAE5F;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,sBAAsB,GAC/B,MAAM,CAAC,SAAS,EAAE,CAAC,CAOrB"}
@@ -55,7 +55,6 @@ var __importStar = (this && this.__importStar) || (function () {
55
55
  })();
56
56
  Object.defineProperty(exports, "__esModule", { value: true });
57
57
  exports.readRecordJarFileSync = readRecordJarFileSync;
58
- exports.readRecordJarFromTree = readRecordJarFromTree;
59
58
  const fs = __importStar(require("fs"));
60
59
  const path = __importStar(require("path"));
61
60
  const ts_utils_1 = require("@fgv/ts-utils");
@@ -76,22 +75,4 @@ function readRecordJarFileSync(srcPath, options) {
76
75
  return (0, recordJarHelpers_1.parseRecordJarLines)(lines, options);
77
76
  });
78
77
  }
79
- /**
80
- * Reads a record-jar file from a FileTree.
81
- * @param fileTree - The FileTree to read from.
82
- * @param filePath - Path of the file within the tree.
83
- * @param options - Optional parser configuration
84
- * @returns The contents of the file as an array of `Record<string, string>`
85
- * @see https://datatracker.ietf.org/doc/html/draft-phillips-record-jar-01
86
- * @public
87
- */
88
- function readRecordJarFromTree(fileTree, filePath, options) {
89
- return fileTree
90
- .getFile(filePath)
91
- .onSuccess((file) => file.getRawContents())
92
- .onSuccess((contents) => {
93
- const lines = contents.split(/\r?\n/);
94
- return (0, recordJarHelpers_1.parseRecordJarLines)(lines, options);
95
- });
96
- }
97
78
  //# sourceMappingURL=recordJarFileHelpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recordJarFileHelpers.js","sourceRoot":"","sources":["../../../src/packlets/record-jar/recordJarFileHelpers.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBH,sDAUC;AAxBD,uCAAyB;AACzB,2CAA6B;AAE7B,4CAAsD;AACtD,yDAA4F;AAE5F;;;;;;;GAOG;AACH,SAAgB,qBAAqB,CACnC,OAAe,EACf,OAAgC;IAEhC,OAAO,IAAA,wBAAa,EAAC,GAAG,EAAE;QACxB,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACvC,OAAO,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACrE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE;QACrB,OAAO,IAAA,sCAAmB,EAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["/*\n * Copyright (c) 2022 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport * as fs from 'fs';\nimport * as path from 'path';\n\nimport { Result, captureResult } from '@fgv/ts-utils';\nimport { JarRecord, JarRecordParserOptions, parseRecordJarLines } from './recordJarHelpers';\n\n/**\n * Reads a record-jar file from a supplied path.\n * @param srcPath - Source path from which the file is read.\n * @param options - Optional parser configuration\n * @returns The contents of the file as an array of `Record<string, string>`\n * @see https://datatracker.ietf.org/doc/html/draft-phillips-record-jar-01\n * @public\n */\nexport function readRecordJarFileSync(\n srcPath: string,\n options?: JarRecordParserOptions\n): Result<JarRecord[]> {\n return captureResult(() => {\n const fullPath = path.resolve(srcPath);\n return fs.readFileSync(fullPath, 'utf8').toString().split(/\\r?\\n/);\n }).onSuccess((lines) => {\n return parseRecordJarLines(lines, options);\n });\n}\n\n"]}
@@ -1,4 +1,5 @@
1
1
  import { Result } from '@fgv/ts-utils';
2
+ import { FileTree } from '@fgv/ts-json-base';
2
3
  /**
3
4
  * Represents a single record in a JAR file
4
5
  * @public
@@ -25,4 +26,14 @@ export interface JarRecordParserOptions {
25
26
  * @public
26
27
  */
27
28
  export declare function parseRecordJarLines(lines: string[], options?: JarRecordParserOptions): Result<JarRecord[]>;
29
+ /**
30
+ * Reads a record-jar file from a FileTree.
31
+ * @param fileTree - The FileTree to read from.
32
+ * @param filePath - Path of the file within the tree.
33
+ * @param options - Optional parser configuration
34
+ * @returns The contents of the file as an array of `Record<string, string>`
35
+ * @see https://datatracker.ietf.org/doc/html/draft-phillips-record-jar-01
36
+ * @public
37
+ */
38
+ export declare function readRecordJarFromTree(fileTree: FileTree.FileTree, filePath: string, options?: JarRecordParserOptions): Result<JarRecord[]>;
28
39
  //# sourceMappingURL=recordJarHelpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recordJarHelpers.d.ts","sourceRoot":"","sources":["../../../src/packlets/record-jar/recordJarHelpers.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,MAAM,EAA0B,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAO7C;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;AAE1D;;GAEG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS,IAAI,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;AAEzF;;;GAGG;AAEH,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,GAAG,cAAc,CAAC;IACjD,QAAQ,CAAC,qBAAqB,CAAC,EAAE,MAAM,CAAC;CACzC;AAmMD;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,sBAAsB,GAAG,MAAM,CAAC,SAAS,EAAE,CAAC,CAE1G;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,QAAQ,CAAC,QAAQ,EAC3B,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,sBAAsB,GAC/B,MAAM,CAAC,SAAS,EAAE,CAAC,CAQrB"}