@es-joy/jsoe 0.24.3 → 0.25.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (524) hide show
  1. package/.claude/settings.local.json +9 -0
  2. package/.ncurc.cjs +2 -2
  3. package/CHANGES.md +51 -0
  4. package/README.md +23 -13
  5. package/badges/coverage-badge.svg +1 -1
  6. package/dist/eslint.config.d.ts +3 -0
  7. package/dist/eslint.config.d.ts.map +1 -0
  8. package/dist/formatAndTypeChoices.d.ts +28 -30
  9. package/dist/formatAndTypeChoices.d.ts.map +1 -1
  10. package/dist/formats/indexedDBKey.d.ts.map +1 -1
  11. package/dist/formats/schema.d.ts +46 -3
  12. package/dist/formats/schema.d.ts.map +1 -1
  13. package/dist/formats/structuredCloning.d.ts +3 -0
  14. package/dist/formats/structuredCloning.d.ts.map +1 -1
  15. package/dist/formats.d.ts +24 -6
  16. package/dist/formats.d.ts.map +1 -1
  17. package/dist/fundamentalTypes/BooleanObjectType.d.ts.map +1 -1
  18. package/dist/fundamentalTypes/NumberObjectType.d.ts.map +1 -1
  19. package/dist/fundamentalTypes/StringObjectType.d.ts.map +1 -1
  20. package/dist/fundamentalTypes/arrayReferenceType.d.ts.map +1 -1
  21. package/dist/fundamentalTypes/arrayType.d.ts +7 -0
  22. package/dist/fundamentalTypes/arrayType.d.ts.map +1 -1
  23. package/dist/fundamentalTypes/bigintObjectType.d.ts.map +1 -1
  24. package/dist/fundamentalTypes/bigintType.d.ts +10 -0
  25. package/dist/fundamentalTypes/bigintType.d.ts.map +1 -1
  26. package/dist/fundamentalTypes/blobType.d.ts.map +1 -1
  27. package/dist/fundamentalTypes/booleanType.d.ts.map +1 -1
  28. package/dist/fundamentalTypes/catchType.d.ts +2 -2
  29. package/dist/fundamentalTypes/catchType.d.ts.map +1 -1
  30. package/dist/fundamentalTypes/dateType.d.ts.map +1 -1
  31. package/dist/fundamentalTypes/domexceptionType.d.ts.map +1 -1
  32. package/dist/fundamentalTypes/enumType.d.ts +2 -2
  33. package/dist/fundamentalTypes/enumType.d.ts.map +1 -1
  34. package/dist/fundamentalTypes/errorType.d.ts.map +1 -1
  35. package/dist/fundamentalTypes/fileType.d.ts +6 -0
  36. package/dist/fundamentalTypes/fileType.d.ts.map +1 -1
  37. package/dist/fundamentalTypes/functionType.d.ts.map +1 -1
  38. package/dist/fundamentalTypes/literalType.d.ts +3 -2
  39. package/dist/fundamentalTypes/literalType.d.ts.map +1 -1
  40. package/dist/fundamentalTypes/looseRecordType.d.ts +6 -0
  41. package/dist/fundamentalTypes/looseRecordType.d.ts.map +1 -0
  42. package/dist/fundamentalTypes/nanType.d.ts.map +1 -1
  43. package/dist/fundamentalTypes/neverType.d.ts +2 -2
  44. package/dist/fundamentalTypes/neverType.d.ts.map +1 -1
  45. package/dist/fundamentalTypes/noneditableType.d.ts.map +1 -1
  46. package/dist/fundamentalTypes/nullType.d.ts.map +1 -1
  47. package/dist/fundamentalTypes/numberType.d.ts.map +1 -1
  48. package/dist/fundamentalTypes/promiseType.d.ts.map +1 -1
  49. package/dist/fundamentalTypes/regexpType.d.ts.map +1 -1
  50. package/dist/fundamentalTypes/stringType.d.ts.map +1 -1
  51. package/dist/fundamentalTypes/symbolType.d.ts.map +1 -1
  52. package/dist/fundamentalTypes/undefinedType.d.ts.map +1 -1
  53. package/dist/fundamentalTypes/voidType.d.ts +2 -2
  54. package/dist/fundamentalTypes/voidType.d.ts.map +1 -1
  55. package/dist/index.d.ts.map +1 -1
  56. package/dist/index.js +6 -1
  57. package/dist/index.js.map +1 -1
  58. package/dist/rollup.config.d.ts +30 -0
  59. package/dist/rollup.config.d.ts.map +1 -0
  60. package/dist/server.d.ts +2 -0
  61. package/dist/server.d.ts.map +1 -0
  62. package/dist/src/formatAndTypeChoices.d.ts +108 -0
  63. package/dist/src/formatAndTypeChoices.d.ts.map +1 -0
  64. package/dist/src/formats/arbitraryJS.d.ts +4 -0
  65. package/dist/src/formats/arbitraryJS.d.ts.map +1 -0
  66. package/dist/src/formats/indexedDBKey.d.ts +4 -0
  67. package/dist/src/formats/indexedDBKey.d.ts.map +1 -0
  68. package/dist/src/formats/json.d.ts +4 -0
  69. package/dist/src/formats/json.d.ts.map +1 -0
  70. package/dist/src/formats/schema.d.ts +17 -0
  71. package/dist/src/formats/schema.d.ts.map +1 -0
  72. package/dist/src/formats/structuredCloning.d.ts +19 -0
  73. package/dist/src/formats/structuredCloning.d.ts.map +1 -0
  74. package/dist/src/formats.d.ts +135 -0
  75. package/dist/src/formats.d.ts.map +1 -0
  76. package/dist/src/fundamentalTypes/BooleanObjectType.d.ts +8 -0
  77. package/dist/src/fundamentalTypes/BooleanObjectType.d.ts.map +1 -0
  78. package/dist/src/fundamentalTypes/NumberObjectType.d.ts +6 -0
  79. package/dist/src/fundamentalTypes/NumberObjectType.d.ts.map +1 -0
  80. package/dist/src/fundamentalTypes/StringObjectType.d.ts +6 -0
  81. package/dist/src/fundamentalTypes/StringObjectType.d.ts.map +1 -0
  82. package/dist/src/fundamentalTypes/arrayReferenceType.d.ts +8 -0
  83. package/dist/src/fundamentalTypes/arrayReferenceType.d.ts.map +1 -0
  84. package/dist/src/fundamentalTypes/arrayType.d.ts +29 -0
  85. package/dist/src/fundamentalTypes/arrayType.d.ts.map +1 -0
  86. package/dist/src/fundamentalTypes/bigintObjectType.d.ts +6 -0
  87. package/dist/src/fundamentalTypes/bigintObjectType.d.ts.map +1 -0
  88. package/dist/src/fundamentalTypes/bigintType.d.ts +6 -0
  89. package/dist/src/fundamentalTypes/bigintType.d.ts.map +1 -0
  90. package/dist/src/fundamentalTypes/blobType.d.ts +11 -0
  91. package/dist/src/fundamentalTypes/blobType.d.ts.map +1 -0
  92. package/dist/src/fundamentalTypes/booleanType.d.ts +8 -0
  93. package/dist/src/fundamentalTypes/booleanType.d.ts.map +1 -0
  94. package/dist/src/fundamentalTypes/catchType.d.ts +6 -0
  95. package/dist/src/fundamentalTypes/catchType.d.ts.map +1 -0
  96. package/dist/src/fundamentalTypes/dateType.d.ts +26 -0
  97. package/dist/src/fundamentalTypes/dateType.d.ts.map +1 -0
  98. package/dist/src/fundamentalTypes/domexceptionType.d.ts +6 -0
  99. package/dist/src/fundamentalTypes/domexceptionType.d.ts.map +1 -0
  100. package/dist/src/fundamentalTypes/enumType.d.ts +6 -0
  101. package/dist/src/fundamentalTypes/enumType.d.ts.map +1 -0
  102. package/dist/src/fundamentalTypes/errorType.d.ts +6 -0
  103. package/dist/src/fundamentalTypes/errorType.d.ts.map +1 -0
  104. package/dist/src/fundamentalTypes/fileType.d.ts +13 -0
  105. package/dist/src/fundamentalTypes/fileType.d.ts.map +1 -0
  106. package/dist/src/fundamentalTypes/filelistType.d.ts +6 -0
  107. package/dist/src/fundamentalTypes/filelistType.d.ts.map +1 -0
  108. package/dist/src/fundamentalTypes/functionType.d.ts +7 -0
  109. package/dist/src/fundamentalTypes/functionType.d.ts.map +1 -0
  110. package/dist/src/fundamentalTypes/literalType.d.ts +6 -0
  111. package/dist/src/fundamentalTypes/literalType.d.ts.map +1 -0
  112. package/dist/src/fundamentalTypes/mapType.d.ts +6 -0
  113. package/dist/src/fundamentalTypes/mapType.d.ts.map +1 -0
  114. package/dist/src/fundamentalTypes/nanType.d.ts +6 -0
  115. package/dist/src/fundamentalTypes/nanType.d.ts.map +1 -0
  116. package/dist/src/fundamentalTypes/neverType.d.ts +6 -0
  117. package/dist/src/fundamentalTypes/neverType.d.ts.map +1 -0
  118. package/dist/src/fundamentalTypes/noneditableType.d.ts +6 -0
  119. package/dist/src/fundamentalTypes/noneditableType.d.ts.map +1 -0
  120. package/dist/src/fundamentalTypes/nullType.d.ts +6 -0
  121. package/dist/src/fundamentalTypes/nullType.d.ts.map +1 -0
  122. package/dist/src/fundamentalTypes/numberType.d.ts +6 -0
  123. package/dist/src/fundamentalTypes/numberType.d.ts.map +1 -0
  124. package/dist/src/fundamentalTypes/objectReferenceType.d.ts +8 -0
  125. package/dist/src/fundamentalTypes/objectReferenceType.d.ts.map +1 -0
  126. package/dist/src/fundamentalTypes/objectType.d.ts +6 -0
  127. package/dist/src/fundamentalTypes/objectType.d.ts.map +1 -0
  128. package/dist/src/fundamentalTypes/promiseType.d.ts +6 -0
  129. package/dist/src/fundamentalTypes/promiseType.d.ts.map +1 -0
  130. package/dist/src/fundamentalTypes/recordType.d.ts +6 -0
  131. package/dist/src/fundamentalTypes/recordType.d.ts.map +1 -0
  132. package/dist/src/fundamentalTypes/regexpType.d.ts +8 -0
  133. package/dist/src/fundamentalTypes/regexpType.d.ts.map +1 -0
  134. package/dist/src/fundamentalTypes/setType.d.ts +6 -0
  135. package/dist/src/fundamentalTypes/setType.d.ts.map +1 -0
  136. package/dist/src/fundamentalTypes/sparseUndefinedType.d.ts +6 -0
  137. package/dist/src/fundamentalTypes/sparseUndefinedType.d.ts.map +1 -0
  138. package/dist/src/fundamentalTypes/stringType.d.ts +6 -0
  139. package/dist/src/fundamentalTypes/stringType.d.ts.map +1 -0
  140. package/dist/src/fundamentalTypes/symbolType.d.ts +8 -0
  141. package/dist/src/fundamentalTypes/symbolType.d.ts.map +1 -0
  142. package/dist/src/fundamentalTypes/tupleType.d.ts +6 -0
  143. package/dist/src/fundamentalTypes/tupleType.d.ts.map +1 -0
  144. package/dist/src/fundamentalTypes/undefinedType.d.ts +6 -0
  145. package/dist/src/fundamentalTypes/undefinedType.d.ts.map +1 -0
  146. package/dist/src/fundamentalTypes/voidType.d.ts +6 -0
  147. package/dist/src/fundamentalTypes/voidType.d.ts.map +1 -0
  148. package/dist/src/index.d.ts +12 -0
  149. package/dist/src/index.d.ts.map +1 -0
  150. package/dist/src/subTypes/blobHTMLType.d.ts +20 -0
  151. package/dist/src/subTypes/blobHTMLType.d.ts.map +1 -0
  152. package/dist/src/subTypes/falseType.d.ts +8 -0
  153. package/dist/src/subTypes/falseType.d.ts.map +1 -0
  154. package/dist/src/subTypes/trueType.d.ts +8 -0
  155. package/dist/src/subTypes/trueType.d.ts.map +1 -0
  156. package/dist/src/superTypes/SpecialNumberType.d.ts +6 -0
  157. package/dist/src/superTypes/SpecialNumberType.d.ts.map +1 -0
  158. package/dist/src/superTypes/SpecialRealNumberType.d.ts +6 -0
  159. package/dist/src/superTypes/SpecialRealNumberType.d.ts.map +1 -0
  160. package/dist/src/superTypes/buffersourceType.d.ts +8 -0
  161. package/dist/src/superTypes/buffersourceType.d.ts.map +1 -0
  162. package/dist/src/superTypes/dommatrixType.d.ts +6 -0
  163. package/dist/src/superTypes/dommatrixType.d.ts.map +1 -0
  164. package/dist/src/superTypes/dompointType.d.ts +6 -0
  165. package/dist/src/superTypes/dompointType.d.ts.map +1 -0
  166. package/dist/src/superTypes/domrectType.d.ts +6 -0
  167. package/dist/src/superTypes/domrectType.d.ts.map +1 -0
  168. package/dist/src/superTypes/errorsSpecialType.d.ts +8 -0
  169. package/dist/src/superTypes/errorsSpecialType.d.ts.map +1 -0
  170. package/dist/src/typeChoices.d.ts +140 -0
  171. package/dist/src/typeChoices.d.ts.map +1 -0
  172. package/dist/src/types.d.ts +758 -0
  173. package/dist/src/types.d.ts.map +1 -0
  174. package/dist/src/utils/FileList.d.ts +26 -0
  175. package/dist/src/utils/FileList.d.ts.map +1 -0
  176. package/dist/src/utils/dialogs.d.ts +111 -0
  177. package/dist/src/utils/dialogs.d.ts.map +1 -0
  178. package/dist/src/utils/jsonPointer.d.ts +46 -0
  179. package/dist/src/utils/jsonPointer.d.ts.map +1 -0
  180. package/dist/src/utils/media.d.ts +18 -0
  181. package/dist/src/utils/media.d.ts.map +1 -0
  182. package/dist/src/utils/objects.d.ts +16 -0
  183. package/dist/src/utils/objects.d.ts.map +1 -0
  184. package/dist/src/utils/templateUtils.d.ts +59 -0
  185. package/dist/src/utils/templateUtils.d.ts.map +1 -0
  186. package/dist/src/utils/types.d.ts +2 -0
  187. package/dist/src/utils/types.d.ts.map +1 -0
  188. package/dist/src/vendor-imports.d.ts +4 -0
  189. package/dist/src/vendor-imports.d.ts.map +1 -0
  190. package/dist/subTypes/blobHTMLType.d.ts.map +1 -1
  191. package/dist/superTypes/SpecialRealNumberType.d.ts.map +1 -1
  192. package/dist/superTypes/buffersourceType.d.ts.map +1 -1
  193. package/dist/superTypes/dommatrixType.d.ts.map +1 -1
  194. package/dist/superTypes/dompointType.d.ts.map +1 -1
  195. package/dist/superTypes/domrectType.d.ts.map +1 -1
  196. package/dist/superTypes/errorsSpecialType.d.ts.map +1 -1
  197. package/dist/typeChoices.d.ts +21 -87
  198. package/dist/typeChoices.d.ts.map +1 -1
  199. package/dist/types.d.ts +90 -64
  200. package/dist/types.d.ts.map +1 -1
  201. package/dist/utils/FileList.d.ts +4 -3
  202. package/dist/utils/FileList.d.ts.map +1 -1
  203. package/dist/utils/dialogs.d.ts +4 -4
  204. package/dist/utils/dialogs.d.ts.map +1 -1
  205. package/dist/utils/media.d.ts.map +1 -1
  206. package/dist/utils/schemaMeta.d.ts +92 -0
  207. package/dist/utils/schemaMeta.d.ts.map +1 -0
  208. package/dist/utils/templateUtils.d.ts +3 -3
  209. package/dist/utils/templateUtils.d.ts.map +1 -1
  210. package/dist/utils/timing.d.ts +2 -0
  211. package/dist/utils/timing.d.ts.map +1 -0
  212. package/dist/utils/types.d.ts +1 -0
  213. package/dist/utils/types.d.ts.map +1 -1
  214. package/dist/vendor-imports.d.ts +3 -1
  215. package/docs/proposals/schema-meta.md +233 -0
  216. package/eslint.config.js +51 -4
  217. package/licenseInfo.json +1 -1
  218. package/package.json +52 -42
  219. package/pnpm-workspace.yaml +57 -0
  220. package/rollup.config.js +20 -18
  221. package/server.js +3 -3
  222. package/src/deepEqual.js.map +1 -1
  223. package/src/formatAndTypeChoices.js +62 -58
  224. package/src/formats/indexedDBKey.js +3 -4
  225. package/src/formats/schema.js +824 -475
  226. package/src/formats/structuredCloning.js +189 -79
  227. package/src/formats.js +17 -5
  228. package/src/fundamentalTypes/BooleanObjectType.js +4 -5
  229. package/src/fundamentalTypes/NumberObjectType.js +4 -4
  230. package/src/fundamentalTypes/StringObjectType.js +3 -4
  231. package/src/fundamentalTypes/arrayReferenceType.js +0 -2
  232. package/src/fundamentalTypes/arrayType.js +624 -389
  233. package/src/fundamentalTypes/bigintObjectType.js +3 -2
  234. package/src/fundamentalTypes/bigintType.js +79 -17
  235. package/src/fundamentalTypes/blobType.js +35 -35
  236. package/src/fundamentalTypes/booleanType.js +16 -8
  237. package/src/fundamentalTypes/dateType.js +6 -8
  238. package/src/fundamentalTypes/domexceptionType.js +5 -4
  239. package/src/fundamentalTypes/errorType.js +39 -32
  240. package/src/fundamentalTypes/fileType.js +238 -52
  241. package/src/fundamentalTypes/functionType.js +61 -41
  242. package/src/fundamentalTypes/nanType.js +5 -4
  243. package/src/fundamentalTypes/noneditableType.js +4 -3
  244. package/src/fundamentalTypes/nullType.js +3 -2
  245. package/src/fundamentalTypes/numberType.js +72 -20
  246. package/src/fundamentalTypes/promiseType.js +16 -40
  247. package/src/fundamentalTypes/regexpType.js +7 -13
  248. package/src/fundamentalTypes/stringType.js +176 -110
  249. package/src/fundamentalTypes/symbolType.js +3 -2
  250. package/src/fundamentalTypes/undefinedType.js +3 -2
  251. package/src/index.js +6 -5
  252. package/src/jsoe.css +107 -8
  253. package/src/subTypes/blobHTMLType.js +23 -10
  254. package/src/superTypes/SpecialNumberType.js +6 -6
  255. package/src/superTypes/SpecialRealNumberType.js +10 -9
  256. package/src/superTypes/buffersourceType.js +86 -75
  257. package/src/superTypes/dommatrixType.js +6 -5
  258. package/src/superTypes/dompointType.js +6 -5
  259. package/src/superTypes/domrectType.js +6 -5
  260. package/src/superTypes/errorsSpecialType.js +54 -35
  261. package/src/typeChoices.js +399 -54
  262. package/src/types.js +157 -97
  263. package/src/utils/FileList.js +3 -3
  264. package/src/utils/dialogs.js +5 -7
  265. package/src/utils/jsonPointer.js +1 -1
  266. package/src/utils/media.js +1 -0
  267. package/src/utils/schemaMeta.js +257 -0
  268. package/src/utils/templateUtils.js +3 -3
  269. package/src/utils/timing.js +12 -0
  270. package/src/utils/types.js +19 -0
  271. package/src/vendor-imports.js +10 -2
  272. package/tsconfig.json +2 -0
  273. package/vendor/acorn/dist/acorn.d.mts +46 -5
  274. package/vendor/acorn/dist/acorn.d.ts +46 -5
  275. package/vendor/acorn/dist/acorn.js +394 -117
  276. package/vendor/acorn/dist/acorn.mjs +394 -117
  277. package/vendor/acorn/dist/bin.js +1 -1
  278. package/vendor/jamilih/dist/{jml-es.js → jml.mjs} +590 -312
  279. package/vendor/jamilih/package.json +1 -1
  280. package/vendor/mime/dist/types/other.js +719 -0
  281. package/vendor/mime/dist/types/standard.js +366 -0
  282. package/vendor/typeson-registry/dist/index.js +519 -99
  283. package/vendor/zod/classic/checks.d.ts +1 -0
  284. package/vendor/zod/classic/checks.js +1 -0
  285. package/vendor/zod/classic/coerce.d.ts +17 -0
  286. package/vendor/zod/classic/coerce.js +17 -0
  287. package/vendor/zod/classic/compat.d.ts +48 -0
  288. package/vendor/zod/classic/compat.js +31 -0
  289. package/vendor/zod/classic/deep-partial.d.ts +14 -0
  290. package/vendor/zod/classic/deep-partial.js +13 -0
  291. package/vendor/zod/classic/errors.d.ts +29 -0
  292. package/vendor/zod/classic/errors.js +57 -0
  293. package/vendor/zod/classic/external.d.ts +19 -0
  294. package/vendor/zod/classic/external.js +17 -0
  295. package/vendor/zod/classic/from-json-schema.d.ts +12 -0
  296. package/vendor/zod/classic/from-json-schema.js +660 -0
  297. package/vendor/zod/classic/in-out.d.ts +8 -0
  298. package/vendor/zod/classic/in-out.js +36 -0
  299. package/vendor/zod/classic/index.d.ts +3 -0
  300. package/vendor/zod/classic/index.js +4 -0
  301. package/vendor/zod/classic/iso.d.ts +7 -0
  302. package/vendor/zod/classic/iso.js +15 -0
  303. package/vendor/zod/classic/package.json +7 -0
  304. package/vendor/zod/classic/parse.d.ts +44 -0
  305. package/vendor/zod/classic/parse.js +16 -0
  306. package/vendor/zod/classic/schemas.d.ts +802 -0
  307. package/vendor/zod/classic/schemas.js +1491 -0
  308. package/vendor/zod/core/api.d.ts +329 -0
  309. package/vendor/zod/core/api.js +1104 -0
  310. package/vendor/zod/core/checks.d.ts +278 -0
  311. package/vendor/zod/core/checks.js +581 -0
  312. package/vendor/zod/core/compile.d.ts +51 -0
  313. package/vendor/zod/core/compile.js +1783 -0
  314. package/vendor/zod/core/core.d.ts +82 -0
  315. package/vendor/zod/core/core.js +141 -0
  316. package/vendor/zod/core/doc.d.ts +16 -0
  317. package/vendor/zod/core/doc.js +33 -0
  318. package/vendor/zod/core/errors.d.ts +225 -0
  319. package/vendor/zod/core/errors.js +270 -0
  320. package/vendor/zod/core/index.d.ts +19 -0
  321. package/vendor/zod/core/index.js +19 -0
  322. package/vendor/zod/core/json-schema-generator.d.ts +65 -0
  323. package/vendor/zod/core/json-schema-generator.js +99 -0
  324. package/vendor/zod/core/json-schema-processors.d.ts +49 -0
  325. package/vendor/zod/core/json-schema-processors.js +747 -0
  326. package/vendor/zod/core/json-schema.d.ts +89 -0
  327. package/vendor/zod/core/memoizer.d.ts +15 -0
  328. package/vendor/zod/core/memoizer.js +265 -0
  329. package/vendor/zod/core/package.json +7 -0
  330. package/vendor/zod/core/parse.d.ts +52 -0
  331. package/vendor/zod/core/parse.js +154 -0
  332. package/vendor/zod/core/regexes.d.ts +87 -0
  333. package/vendor/zod/core/regexes.js +150 -0
  334. package/vendor/zod/core/registries.d.ts +35 -0
  335. package/vendor/zod/core/registries.js +51 -0
  336. package/vendor/zod/core/schemas.d.ts +1253 -0
  337. package/vendor/zod/core/schemas.js +2440 -0
  338. package/vendor/zod/core/standard-schema.d.ts +126 -0
  339. package/vendor/zod/core/to-json-schema.d.ts +153 -0
  340. package/vendor/zod/core/to-json-schema.js +650 -0
  341. package/vendor/zod/core/util.d.ts +257 -0
  342. package/vendor/zod/core/util.js +846 -0
  343. package/vendor/zod/core/versions.d.ts +5 -0
  344. package/vendor/zod/core/versions.js +5 -0
  345. package/vendor/zod/core/visit.d.ts +30 -0
  346. package/vendor/zod/core/visit.js +169 -0
  347. package/vendor/zod/index.d.ts +3 -0
  348. package/vendor/zod/index.js +4 -0
  349. package/vendor/zod/locales/ar.d.ts +4 -0
  350. package/vendor/zod/locales/ar.js +109 -0
  351. package/vendor/zod/locales/az.d.ts +4 -0
  352. package/vendor/zod/locales/az.js +108 -0
  353. package/vendor/zod/locales/be.d.ts +4 -0
  354. package/vendor/zod/locales/be.js +166 -0
  355. package/vendor/zod/locales/bg.d.ts +4 -0
  356. package/vendor/zod/locales/bg.js +123 -0
  357. package/vendor/zod/locales/bn.d.ts +4 -0
  358. package/vendor/zod/locales/bn.js +111 -0
  359. package/vendor/zod/locales/ca.d.ts +4 -0
  360. package/vendor/zod/locales/ca.js +110 -0
  361. package/vendor/zod/locales/ckb.d.ts +4 -0
  362. package/vendor/zod/locales/ckb.js +131 -0
  363. package/vendor/zod/locales/cs.d.ts +4 -0
  364. package/vendor/zod/locales/cs.js +114 -0
  365. package/vendor/zod/locales/da.d.ts +4 -0
  366. package/vendor/zod/locales/da.js +118 -0
  367. package/vendor/zod/locales/de.d.ts +4 -0
  368. package/vendor/zod/locales/de.js +111 -0
  369. package/vendor/zod/locales/el.d.ts +4 -0
  370. package/vendor/zod/locales/el.js +110 -0
  371. package/vendor/zod/locales/en.d.ts +4 -0
  372. package/vendor/zod/locales/en.js +123 -0
  373. package/vendor/zod/locales/eo.d.ts +4 -0
  374. package/vendor/zod/locales/eo.js +112 -0
  375. package/vendor/zod/locales/es.d.ts +4 -0
  376. package/vendor/zod/locales/es.js +134 -0
  377. package/vendor/zod/locales/fa.d.ts +4 -0
  378. package/vendor/zod/locales/fa.js +117 -0
  379. package/vendor/zod/locales/fi.d.ts +4 -0
  380. package/vendor/zod/locales/fi.js +115 -0
  381. package/vendor/zod/locales/fr-CA.d.ts +4 -0
  382. package/vendor/zod/locales/fr-CA.js +110 -0
  383. package/vendor/zod/locales/fr.d.ts +4 -0
  384. package/vendor/zod/locales/fr.js +127 -0
  385. package/vendor/zod/locales/gu.d.ts +4 -0
  386. package/vendor/zod/locales/gu.js +111 -0
  387. package/vendor/zod/locales/he.d.ts +4 -0
  388. package/vendor/zod/locales/he.js +219 -0
  389. package/vendor/zod/locales/hi.d.ts +4 -0
  390. package/vendor/zod/locales/hi.js +109 -0
  391. package/vendor/zod/locales/hr.d.ts +4 -0
  392. package/vendor/zod/locales/hr.js +124 -0
  393. package/vendor/zod/locales/hu.d.ts +4 -0
  394. package/vendor/zod/locales/hu.js +111 -0
  395. package/vendor/zod/locales/hy.d.ts +4 -0
  396. package/vendor/zod/locales/hy.js +156 -0
  397. package/vendor/zod/locales/id.d.ts +4 -0
  398. package/vendor/zod/locales/id.js +109 -0
  399. package/vendor/zod/locales/index.d.ts +62 -0
  400. package/vendor/zod/locales/index.js +62 -0
  401. package/vendor/zod/locales/is.d.ts +4 -0
  402. package/vendor/zod/locales/is.js +112 -0
  403. package/vendor/zod/locales/it.d.ts +4 -0
  404. package/vendor/zod/locales/it.js +111 -0
  405. package/vendor/zod/locales/ja.d.ts +4 -0
  406. package/vendor/zod/locales/ja.js +110 -0
  407. package/vendor/zod/locales/ka.d.ts +4 -0
  408. package/vendor/zod/locales/ka.js +115 -0
  409. package/vendor/zod/locales/kh.d.ts +5 -0
  410. package/vendor/zod/locales/kh.js +5 -0
  411. package/vendor/zod/locales/km.d.ts +4 -0
  412. package/vendor/zod/locales/km.js +113 -0
  413. package/vendor/zod/locales/kn.d.ts +4 -0
  414. package/vendor/zod/locales/kn.js +114 -0
  415. package/vendor/zod/locales/ko.d.ts +4 -0
  416. package/vendor/zod/locales/ko.js +114 -0
  417. package/vendor/zod/locales/lt.d.ts +4 -0
  418. package/vendor/zod/locales/lt.js +205 -0
  419. package/vendor/zod/locales/mk.d.ts +4 -0
  420. package/vendor/zod/locales/mk.js +112 -0
  421. package/vendor/zod/locales/ms.d.ts +4 -0
  422. package/vendor/zod/locales/ms.js +110 -0
  423. package/vendor/zod/locales/ne.d.ts +4 -0
  424. package/vendor/zod/locales/ne.js +109 -0
  425. package/vendor/zod/locales/nl.d.ts +4 -0
  426. package/vendor/zod/locales/nl.js +113 -0
  427. package/vendor/zod/locales/nn.d.ts +4 -0
  428. package/vendor/zod/locales/nn.js +111 -0
  429. package/vendor/zod/locales/no.d.ts +4 -0
  430. package/vendor/zod/locales/no.js +111 -0
  431. package/vendor/zod/locales/ota.d.ts +4 -0
  432. package/vendor/zod/locales/ota.js +112 -0
  433. package/vendor/zod/locales/package.json +7 -0
  434. package/vendor/zod/locales/pl.d.ts +4 -0
  435. package/vendor/zod/locales/pl.js +112 -0
  436. package/vendor/zod/locales/ps.d.ts +4 -0
  437. package/vendor/zod/locales/ps.js +117 -0
  438. package/vendor/zod/locales/pt-BR.d.ts +4 -0
  439. package/vendor/zod/locales/pt-BR.js +141 -0
  440. package/vendor/zod/locales/pt.d.ts +4 -0
  441. package/vendor/zod/locales/pt.js +140 -0
  442. package/vendor/zod/locales/ro.d.ts +4 -0
  443. package/vendor/zod/locales/ro.js +120 -0
  444. package/vendor/zod/locales/ru.d.ts +4 -0
  445. package/vendor/zod/locales/ru.js +166 -0
  446. package/vendor/zod/locales/sk.d.ts +4 -0
  447. package/vendor/zod/locales/sk.js +114 -0
  448. package/vendor/zod/locales/sl.d.ts +4 -0
  449. package/vendor/zod/locales/sl.js +112 -0
  450. package/vendor/zod/locales/sv.d.ts +4 -0
  451. package/vendor/zod/locales/sv.js +113 -0
  452. package/vendor/zod/locales/ta.d.ts +4 -0
  453. package/vendor/zod/locales/ta.js +113 -0
  454. package/vendor/zod/locales/th.d.ts +4 -0
  455. package/vendor/zod/locales/th.js +113 -0
  456. package/vendor/zod/locales/tk.d.ts +4 -0
  457. package/vendor/zod/locales/tk.js +105 -0
  458. package/vendor/zod/locales/tr.d.ts +4 -0
  459. package/vendor/zod/locales/tr.js +108 -0
  460. package/vendor/zod/locales/ua.d.ts +5 -0
  461. package/vendor/zod/locales/ua.js +5 -0
  462. package/vendor/zod/locales/uk.d.ts +4 -0
  463. package/vendor/zod/locales/uk.js +111 -0
  464. package/vendor/zod/locales/ur.d.ts +4 -0
  465. package/vendor/zod/locales/ur.js +113 -0
  466. package/vendor/zod/locales/uz.d.ts +4 -0
  467. package/vendor/zod/locales/uz.js +111 -0
  468. package/vendor/zod/locales/vi.d.ts +4 -0
  469. package/vendor/zod/locales/vi.js +111 -0
  470. package/vendor/zod/locales/yo.d.ts +4 -0
  471. package/vendor/zod/locales/yo.js +110 -0
  472. package/vendor/zod/locales/zh-CN.d.ts +4 -0
  473. package/vendor/zod/locales/zh-CN.js +112 -0
  474. package/vendor/zod/locales/zh-TW.d.ts +4 -0
  475. package/vendor/zod/locales/zh-TW.js +110 -0
  476. package/vendor/zod/mini/checks.d.ts +1 -0
  477. package/vendor/zod/mini/checks.js +1 -0
  478. package/vendor/zod/mini/coerce.d.ts +7 -0
  479. package/vendor/zod/mini/coerce.js +22 -0
  480. package/vendor/zod/mini/deep-partial.d.ts +14 -0
  481. package/vendor/zod/mini/deep-partial.js +13 -0
  482. package/vendor/zod/mini/external.d.ts +16 -0
  483. package/vendor/zod/mini/external.js +16 -0
  484. package/vendor/zod/mini/in-out.d.ts +8 -0
  485. package/vendor/zod/mini/in-out.js +36 -0
  486. package/vendor/zod/mini/index.d.ts +3 -0
  487. package/vendor/zod/mini/index.js +3 -0
  488. package/vendor/zod/mini/iso.d.ts +22 -0
  489. package/vendor/zod/mini/iso.js +34 -0
  490. package/vendor/zod/mini/package.json +7 -0
  491. package/vendor/zod/mini/parse.d.ts +1 -0
  492. package/vendor/zod/mini/parse.js +1 -0
  493. package/vendor/zod/mini/schemas.d.ts +475 -0
  494. package/vendor/zod/mini/schemas.js +987 -0
  495. package/vendor/zod/package.json +7 -0
  496. package/vendor/zodexy/dist/esm/index.js +1274 -0
  497. package/vendor/zodexy/dist/index.js +1088 -0
  498. package/vendor/zodexy/dist/schema.zodexy.json +1036 -0
  499. package/dist/fundamentalTypes/nativeEnumType.d.ts +0 -6
  500. package/dist/fundamentalTypes/nativeEnumType.d.ts.map +0 -1
  501. package/src/fundamentalTypes/catchType.js +0 -140
  502. package/src/fundamentalTypes/enumType.js +0 -52
  503. package/src/fundamentalTypes/literalType.js +0 -81
  504. package/src/fundamentalTypes/nativeEnumType.js +0 -157
  505. package/src/fundamentalTypes/neverType.js +0 -49
  506. package/src/fundamentalTypes/recordType.js +0 -42
  507. package/src/fundamentalTypes/tupleType.js +0 -39
  508. package/src/fundamentalTypes/voidType.js +0 -48
  509. package/vendor/zod/lib/index.mjs +0 -4236
  510. package/vendor/zodex/dist/esm/dezerialize.d.ts +0 -26
  511. package/vendor/zodex/dist/esm/dezerialize.js +0 -393
  512. package/vendor/zodex/dist/esm/index.d.ts +0 -9
  513. package/vendor/zodex/dist/esm/index.js +0 -4
  514. package/vendor/zodex/dist/esm/infer.d.ts +0 -29
  515. package/vendor/zodex/dist/esm/package.json +0 -1
  516. package/vendor/zodex/dist/esm/types.d.ts +0 -201
  517. package/vendor/zodex/dist/esm/types.js +0 -13
  518. package/vendor/zodex/dist/esm/ui.d.ts +0 -23
  519. package/vendor/zodex/dist/esm/ui.js +0 -10
  520. package/vendor/zodex/dist/esm/zerialize.d.ts +0 -50
  521. package/vendor/zodex/dist/esm/zerialize.js +0 -417
  522. package/vendor/zodex/dist/esm/zod-types.d.ts +0 -11
  523. /package/vendor/{zodex/dist/esm/infer.js → zod/core/json-schema.js} +0 -0
  524. /package/vendor/{zodex/dist/esm/zod-types.js → zod/core/standard-schema.js} +0 -0
@@ -1,39 +1,51 @@
1
+ /* eslint-disable unicorn/prefer-global-this -- Easier */
2
+ /* eslint-disable unicorn/no-break-in-nested-loop -- Performance to avoid function? */
3
+ /* eslint-disable sonarjs/no-control-regex -- Intentional */
4
+ /* eslint-disable unicorn/no-top-level-assignment-in-function -- Only need module level */
1
5
  /*
2
6
  Possible todos:
3
7
  0. Add XSLT to JML-string stylesheet (or even vice versa)
4
- 0. IE problem: Add JsonML code to handle name attribute (during element creation)
5
- 0. Element-specific: IE object-param handling
6
8
 
7
9
  Todos inspired by JsonML: https://github.com/mckamey/jsonml/blob/master/jsonml-html.js
8
-
9
- 0. duplicate attributes?
10
10
  0. expand ATTR_MAP
11
- 0. equivalent of markup, to allow strings to be embedded within an object (e.g., {$value: '<div>id</div>'}); advantage over innerHTML in that it wouldn't need to work as the entire contents (nor destroy any existing content or handlers)
12
- 0. More validation?
13
- 0. JsonML DOM Level 0 listener
14
- 0. Whitespace trimming?
15
-
16
- JsonML element-specific:
17
- 0. table appending
18
- 0. canHaveChildren necessary? (attempts to append to script and img)
19
11
 
20
12
  Other Todos:
21
13
  0. Note to self: Integrate research from other jml notes
22
- 0. Allow Jamilih to be seeded with an existing element, so as to be able to add/modify attributes and children
14
+ 0. Allow Jamilih to be seeded with an existing element, so as to be able to
15
+ add/modify attributes and children
23
16
  0. Allow array as single first argument
24
- 0. Settle on whether need to use null as last argument to return array (or fragment) or other way to allow appending? Options object at end instead to indicate whether returning array, fragment, first element, etc.?
17
+ 0. Settle on whether need to use null as last argument to return array (or
18
+ fragment) or other way to allow appending? Options object at end instead
19
+ to indicate whether returning array, fragment, first element, etc.?
25
20
  0. Allow building of generic XML (pass configuration object)
26
21
  0. Allow building content internally as a string (though allowing DOM methods, etc.?)
27
22
  0. Support JsonML empty string element name to represent fragments?
28
- 0. Redo browser testing of jml (including ensuring IE7 can work even if test framework can't work)
23
+ 0. Redo browser testing of jml
29
24
  */
30
25
 
31
26
  /**
32
- * @typedef {Window & {DocumentFragment: any}} HTMLWindow
27
+ * @typedef {Window & {DocumentFragment: typeof DocumentFragment}} HTMLWindow
28
+ */
29
+
30
+ /**
31
+ * @typedef {unknown} ArbitraryValue
32
+ */
33
+
34
+ /**
35
+ * @typedef {unknown} StoredValue
36
+ */
37
+
38
+ /* eslint-disable jsdoc/reject-any-type -- user-defined callback arguments */
39
+ /**
40
+ * @typedef {any} UserArg
41
+ */
42
+ /**
43
+ * @typedef {any} ElementExpando
33
44
  */
45
+ /* eslint-enable jsdoc/reject-any-type */
34
46
 
35
47
  /**
36
- * @typedef {any} ArbitraryValue
48
+ * @typedef {HTMLElement & {[key: string]: ElementExpando}} ExpandoHTMLElement
37
49
  */
38
50
 
39
51
  /**
@@ -55,7 +67,7 @@ Other Todos:
55
67
  */
56
68
 
57
69
  /**
58
- * @type {import('jsdom').DOMWindow|HTMLWindow|undefined}
70
+ * @type {import('jsdom').DOMWindow|HTMLWindow|typeof globalThis|undefined}
59
71
  */
60
72
  let win;
61
73
 
@@ -74,7 +86,6 @@ const possibleOptions = ['$plugins',
74
86
  // '$state', // Used internally
75
87
  '$map' // Add any other options here
76
88
  ];
77
-
78
89
  const NS_HTML = 'http://www.w3.org/1999/xhtml',
79
90
  hyphenForCamelCase = /-([a-z])/gu;
80
91
  const ATTR_MAP = new Map([['maxlength', 'maxLength'], ['minlength', 'minLength'], ['readonly', 'readOnly']]);
@@ -87,7 +98,7 @@ const BOOL_ATTS = ['checked', 'defaultChecked', 'defaultSelected', 'disabled', '
87
98
  'readOnly', 'selected'];
88
99
 
89
100
  // From JsonML
90
- const ATTR_DOM = [...BOOL_ATTS, 'accessKey',
101
+ const ATTR_DOM = new Set([...BOOL_ATTS, 'accessKey',
91
102
  // HTMLElement
92
103
  'async', 'autocapitalize',
93
104
  // HTMLElement
@@ -105,17 +116,17 @@ const ATTR_DOM = [...BOOL_ATTS, 'accessKey',
105
116
  // HTMLElement
106
117
  'translate',
107
118
  // HTMLElement
108
- 'value', 'willvalidate'];
119
+ 'value', 'willvalidate']);
109
120
  // Todo: Add more to this as useful for templating
110
121
  // to avoid setting through nullish value
111
- const NULLABLES = ['autocomplete', 'dir',
122
+ const NULLABLES = new Set(['autocomplete', 'dir',
112
123
  // HTMLElement
113
124
  'integrity',
114
125
  // script, link
115
126
  'lang',
116
127
  // HTMLElement
117
128
  'max', 'min', 'minLength', 'maxLength', 'title' // HTMLElement
118
- ];
129
+ ]);
119
130
 
120
131
  /**
121
132
  * @param {string} sel
@@ -136,19 +147,9 @@ const $$ = sel => {
136
147
  if (!doc) {
137
148
  throw new Error('No document object');
138
149
  }
139
- return [... /** @type {NodeListOf<HTMLElement>} */doc.querySelectorAll(sel)];
150
+ return [...(/** @type {NodeListOf<HTMLElement>} */doc.querySelectorAll(sel))];
140
151
  };
141
152
 
142
- /**
143
- * Retrieve the (lower-cased) HTML name of a node.
144
- * @static
145
- * @param {Node} node The HTML node
146
- * @returns {string} The lower-cased node name
147
- */
148
- function _getHTMLNodeName(node) {
149
- return node.nodeName && node.nodeName.toLowerCase();
150
- }
151
-
152
153
  /**
153
154
  * @private
154
155
  * @static
@@ -158,7 +159,7 @@ function _getHTMLNodeName(node) {
158
159
  * @returns {void}
159
160
  */
160
161
  function _appendNode(parent, child) {
161
- const parentName = _getHTMLNodeName(parent);
162
+ const parentName = parent.nodeName?.toLowerCase();
162
163
  if (parentName === 'template') {
163
164
  /** @type {HTMLTemplateElement} */parent.content.append(child);
164
165
  return;
@@ -169,9 +170,10 @@ function _appendNode(parent, child) {
169
170
  /**
170
171
  * Attach event in a cross-browser fashion.
171
172
  * @static
172
- * @param {HTMLElement} el DOM element to which to attach the event
173
+ * @template {HTMLElement} T
174
+ * @param {T} el DOM element to which to attach the event
173
175
  * @param {string} type The DOM event (without 'on') to attach to the element
174
- * @param {(evt: Event & {target: HTMLElement}) => void} handler The event handler to attach to the element
176
+ * @param {(evt: Event & {target: T}) => void} handler The event handler to attach to the element
175
177
  * @param {boolean} [capturing] Whether or not the event should be
176
178
  * capturing (W3C-browsers only); default is false; NOT IN USE
177
179
  * @returns {void}
@@ -182,13 +184,13 @@ function _addEvent(el, type, handler, capturing) {
182
184
  }
183
185
 
184
186
  /**
185
- * Creates a text node of the result of resolving an entity or character reference.
186
- * @param {'entity'|'decimal'|'hexadecimal'} type Type of reference
187
- * @param {string} prefix Text to prefix immediately after the "&"
188
- * @param {string} arg The body of the reference
189
- * @throws {TypeError}
190
- * @returns {Text} The text node of the resolved reference
191
- */
187
+ * Creates a text node of the result of resolving an entity or character reference.
188
+ * @param {'entity'|'decimal'|'hexadecimal'} type Type of reference
189
+ * @param {string} prefix Text to prefix immediately after the "&"
190
+ * @param {string} arg The body of the reference
191
+ * @throws {TypeError}
192
+ * @returns {Text} The text node of the resolved reference
193
+ */
192
194
  function _createSafeReference(type, prefix, arg) {
193
195
  /* c8 ignore next 3 */
194
196
  if (!doc) {
@@ -203,14 +205,15 @@ function _createSafeReference(type, prefix, arg) {
203
205
  // Todo: No workaround for XML?
204
206
  // eslint-disable-next-line no-unsanitized/property
205
207
  elContainer.innerHTML = '&' + prefix + arg + ';';
208
+ // eslint-disable-next-line unicorn/prefer-dom-node-html-methods -- No Safari support
206
209
  return doc.createTextNode(elContainer.innerHTML);
207
210
  }
208
211
 
209
212
  /**
210
- * @param {string} n0 Whole expression match (including "-")
211
- * @param {string} n1 Lower-case letter match
212
- * @returns {string} Uppercased letter
213
- */
213
+ * @param {string} n0 Whole expression match (including "-")
214
+ * @param {string} n1 Lower-case letter match
215
+ * @returns {string} Uppercased letter
216
+ */
214
217
  function _upperCase(n0, n1) {
215
218
  return n1.toUpperCase();
216
219
  }
@@ -224,24 +227,31 @@ function _isNullish(o) {
224
227
  return o === null || o === undefined;
225
228
  }
226
229
 
230
+ /**
231
+ * @param {unknown} item
232
+ * @returns {item is HTMLElement}
233
+ */
234
+ function _isHTMLElement(item) {
235
+ return Boolean(item && typeof item === 'object' && 'nodeType' in item && item.nodeType === 1);
236
+ }
237
+
227
238
  // Todo: Make as public utility, but also return types for undefined, boolean, number, document, etc.
228
239
  /**
229
- * @private
230
- * @static
231
- * @param {string|JamilihAttributes|JamilihArray|JamilihChildren|
232
- * JamilihDocumentFragment|JamilihAttributeNode|
233
- * JamilihOptions|HTMLElement|Document|DocumentFragment|null|undefined} item
234
- * @returns {"string"|"null"|"array"|"element"|"fragment"|"object"|
235
- * "symbol"|"bigint"|"function"|"number"|"boolean"|"undefined"|
236
- * "document"|"non-container node"}
237
- */
240
+ * @private
241
+ * @static
242
+ * @param {string|JamilihAttributes|JamilihArray|JamilihChildren|
243
+ * JamilihDocumentFragment|JamilihAttributeNode|
244
+ * JamilihOptions|HTMLElement|Document|DocumentFragment|null|undefined} item
245
+ * @returns {"string"|"null"|"array"|"element"|"fragment"|"object"|
246
+ * "symbol"|"bigint"|"function"|"number"|"boolean"|"undefined"|
247
+ * "document"|"processing-instruction"|"non-container node"}
248
+ */
238
249
  function _getType(item) {
239
- const type = typeof item;
240
-
241
250
  // Appease TS
242
251
  if (typeof item === 'string' || typeof item === 'undefined') {
243
252
  return 'string';
244
253
  }
254
+ const type = typeof item;
245
255
  switch (type) {
246
256
  case 'object':
247
257
  if (item === null) {
@@ -254,6 +264,8 @@ function _getType(item) {
254
264
  switch (item.nodeType) {
255
265
  case 1:
256
266
  return 'element';
267
+ case 7:
268
+ return 'processing-instruction';
257
269
  case 9:
258
270
  return 'document';
259
271
  case 11:
@@ -269,23 +281,31 @@ function _getType(item) {
269
281
  }
270
282
 
271
283
  /**
272
- * @private
273
- * @static
274
- * @param {DocumentFragment} frag
275
- * @param {Node} node
276
- * @returns {DocumentFragment}
277
- */
284
+ * @private
285
+ * @static
286
+ * @param {DocumentFragment} frag
287
+ * @param {Node} node
288
+ * @returns {DocumentFragment}
289
+ */
278
290
  function _fragReducer(frag, node) {
279
291
  frag.append(node);
280
292
  return frag;
281
293
  }
282
294
 
283
295
  /**
284
- * @private
285
- * @static
286
- * @param {Object<string, string>} xmlnsObj
287
- * @returns {(...n: string[]) => string}
288
- */
296
+ * @param {string} str
297
+ * @returns {string}
298
+ */
299
+ function escapeReplacer(str) {
300
+ return str.replaceAll('$', '$$$$');
301
+ }
302
+
303
+ /**
304
+ * @private
305
+ * @static
306
+ * @param {Object<string, string>} xmlnsObj
307
+ * @returns {(...n: string[]) => string}
308
+ */
289
309
  function _replaceDefiner(xmlnsObj) {
290
310
  /**
291
311
  * @param {string[]} n
@@ -293,10 +313,10 @@ function _replaceDefiner(xmlnsObj) {
293
313
  */
294
314
  return function (...n) {
295
315
  const n0 = n[0];
296
- let retStr = xmlnsObj[''] ? ' xmlns="' + xmlnsObj[''] + '"' : n0; // Preserve XHTML
316
+ let retStr = xmlnsObj[''] ? ' xmlns="' + escapeReplacer(xmlnsObj['']) + '"' : n0; // Preserve XHTML
297
317
  for (const [ns, xmlnsVal] of Object.entries(xmlnsObj)) {
298
318
  if (ns !== '') {
299
- retStr += ' xmlns:' + ns + '="' + xmlnsVal + '"';
319
+ retStr += ' xmlns:' + ns + '="' + escapeReplacer(xmlnsVal) + '"';
300
320
  }
301
321
  }
302
322
  return retStr;
@@ -319,7 +339,7 @@ function _replaceDefiner(xmlnsObj) {
319
339
  function _childrenToJML(node) {
320
340
  return function (childNodeJML, i) {
321
341
  const cn = node.childNodes[i];
322
- const j = Array.isArray(childNodeJML) ? jml(... /** @type {JamilihArray} */childNodeJML) : jml(childNodeJML);
342
+ const j = Array.isArray(childNodeJML) ? jml(...(/** @type {JamilihArray} */childNodeJML)) : jml(childNodeJML);
323
343
  cn.replaceWith(j);
324
344
  };
325
345
  }
@@ -327,30 +347,30 @@ function _childrenToJML(node) {
327
347
  /**
328
348
  * Keep this in sync with `JamilihArray`'s first argument (minus `Document`).
329
349
  * @typedef {JamilihDoc|JamilihDoctype|JamilihTextNode|
330
- * JamilihAttributeNode|JamilihOptions|ElementName|HTMLElement|
331
- * JamilihDocumentFragment
332
- * } JamilihFirstArg
333
- */
350
+ * JamilihAttributeNode|JamilihOptions|ElementName|HTMLElement|
351
+ * JamilihDocumentFragment
352
+ * } JamilihFirstArg
353
+ */
334
354
 
335
355
  /**
336
- * @callback JamilihAppender
337
- * @param {JamilihArray|JamilihFirstArg|Node|TextNodeString} childJML
338
- * @returns {void}
339
- */
356
+ * @callback JamilihAppender
357
+ * @param {JamilihArray|JamilihArrayLike|JamilihFirstArg|Node|TextNodeString} childJML
358
+ * @returns {void}
359
+ */
340
360
 
341
361
  /**
342
- * @private
343
- * @static
344
- * @param {ParentNode} node
345
- * @returns {JamilihAppender}
346
- */
362
+ * @private
363
+ * @static
364
+ * @param {ParentNode} node
365
+ * @returns {JamilihAppender}
366
+ */
347
367
  function _appendJML(node) {
348
368
  return function (childJML) {
349
369
  if (typeof childJML === 'string' || typeof childJML === 'number') {
350
370
  throw new TypeError('Unexpected text string/number in the head');
351
371
  }
352
372
  if (Array.isArray(childJML)) {
353
- node.append(jml(...childJML));
373
+ node.append(jml(...(/** @type {JamilihArray} */childJML)));
354
374
  } else if (typeof childJML === 'object' && 'nodeType' in childJML) {
355
375
  node.append(childJML);
356
376
  } else {
@@ -360,23 +380,23 @@ function _appendJML(node) {
360
380
  }
361
381
 
362
382
  /**
363
- * @callback appender
364
- * @param {JamilihArray|JamilihFirstArg|Node|TextNodeString} childJML
365
- * @returns {void}
366
- */
383
+ * @callback appender
384
+ * @param {JamilihArray|JamilihArrayLike|JamilihFirstArg|Node|TextNodeString} childJML
385
+ * @returns {void}
386
+ */
367
387
 
368
388
  /**
369
- * @private
370
- * @static
371
- * @param {ParentNode} node
372
- * @returns {appender}
373
- */
389
+ * @private
390
+ * @static
391
+ * @param {ParentNode} node
392
+ * @returns {appender}
393
+ */
374
394
  function _appendJMLOrText(node) {
375
395
  return function (childJML) {
376
396
  if (typeof childJML === 'string' || typeof childJML === 'number') {
377
397
  node.append(String(childJML));
378
398
  } else if (Array.isArray(childJML)) {
379
- node.append(jml(...childJML));
399
+ node.append(jml(...(/** @type {JamilihArray} */childJML)));
380
400
  } else if (typeof childJML === 'object' && 'nodeType' in childJML) {
381
401
  node.append(childJML);
382
402
  } else {
@@ -386,9 +406,9 @@ function _appendJMLOrText(node) {
386
406
  }
387
407
 
388
408
  /**
389
- * @private
390
- * @static
391
- */
409
+ * @private
410
+ * @static
411
+ */
392
412
  /*
393
413
  function _DOMfromJMLOrString (childNodeJML) {
394
414
  if (typeof childNodeJML === 'string') {
@@ -399,9 +419,9 @@ function _DOMfromJMLOrString (childNodeJML) {
399
419
  */
400
420
 
401
421
  /**
402
- * @typedef {HTMLElement|DocumentFragment|Comment|Attr|
403
- * Text|Document|DocumentType|ProcessingInstruction|CDATASection} JamilihReturn
404
- */
422
+ * @typedef {HTMLElement|DocumentFragment|Comment|Attr|
423
+ * Text|Document|DocumentType|ProcessingInstruction|CDATASection} JamilihReturn
424
+ */
405
425
  // 'string|JamilihOptions|JamilihDocumentFragment|JamilihAttributes|(string|JamilihArray)[]
406
426
 
407
427
  /**
@@ -418,11 +438,11 @@ function _DOMfromJMLOrString (childNodeJML) {
418
438
 
419
439
  /**
420
440
  * @typedef {{
421
- * open?: boolean|ShadowRootJamilihArrayContainer,
422
- * closed?: boolean|ShadowRootJamilihArrayContainer,
423
- * template?: string|HTMLTemplateElement|TemplateJamilihArray,
424
- * content?: ShadowRootJamilihArrayContainer|DocumentFragment
425
- * }} JamilihShadowRootObject
441
+ * open?: boolean|ShadowRootJamilihArrayContainer,
442
+ * closed?: boolean|ShadowRootJamilihArrayContainer,
443
+ * template?: string|HTMLTemplateElement|TemplateJamilihArray,
444
+ * content?: ShadowRootJamilihArrayContainer|DocumentFragment
445
+ * }} JamilihShadowRootObject
426
446
  */
427
447
 
428
448
  /**
@@ -444,18 +464,21 @@ function _DOMfromJMLOrString (childNodeJML) {
444
464
  */
445
465
 
446
466
  /**
447
- * @typedef {(this: HTMLElement, event: Event & {target: HTMLElement}) => void} EventHandler
467
+ * @template {HTMLElement} [T=HTMLElement]
468
+ * @typedef {(this: T, event: Event & {target: T}) => void} EventHandler
448
469
  */
449
470
 
450
471
  /**
472
+ * @template {HTMLElement} [T=HTMLElement]
451
473
  * @typedef {{
452
- * [key: string]: EventHandler|[EventHandler, boolean]
474
+ * [key: string]: EventHandler<T>|[EventHandler<T>, boolean]
453
475
  * }} OnAttributeObject
454
476
  */
455
477
 
456
478
  /**
479
+ * @template {HTMLElement} [T=HTMLElement]
457
480
  * @typedef {{
458
- * $on?: OnAttributeObject|null
481
+ * $on?: OnAttributeObject<T>|null
459
482
  * }} OnAttribute
460
483
  */
461
484
 
@@ -467,7 +490,6 @@ function _DOMfromJMLOrString (childNodeJML) {
467
490
  * @typedef {((this: HTMLElement, event?: Event) => void)} HandlerAttributeValue
468
491
  */
469
492
 
470
- /* eslint-disable jsdoc/valid-types -- jsdoc-type-pratt-parser Bug */
471
493
  /**
472
494
  * @typedef {{
473
495
  * [key: string]: HandlerAttributeValue
@@ -491,23 +513,22 @@ function _DOMfromJMLOrString (childNodeJML) {
491
513
  */
492
514
 
493
515
  /**
494
- * @typedef {{[key: string]: string|number|boolean|((this: DefineMixin, ...args: any[]) => any)}} DefineMixin
516
+ * @typedef {{[key: string]: unknown}} DefineMixin
495
517
  */
496
518
 
497
519
  /**
498
520
  * @typedef {{
499
521
  * new (): HTMLElement;
500
- * prototype: HTMLElement & {[key: string]: any}
522
+ * prototype: HTMLElement
501
523
  * }} DefineConstructor
502
524
  */
503
- /* eslint-enable jsdoc/valid-types -- https://github.com/jsdoc-type-pratt-parser/jsdoc-type-pratt-parser/issues/131 */
504
525
 
505
526
  /**
506
527
  * @typedef {(this: HTMLElement) => void} DefineUserConstructor
507
528
  */
508
529
 
509
530
  /**
510
- * @typedef {[DefineConstructor|DefineUserConstructor|DefineMixin, DefineOptions?]|[DefineConstructor|DefineUserConstructor, DefineMixin?, DefineOptions?]} DefineObjectArray
531
+ * @typedef {[DefineConstructor|DefineUserConstructor|DefineMixin, DefineOptions?]|[DefineMixin, DefineConstructor]|[DefineConstructor|DefineUserConstructor, DefineMixin?, DefineOptions?]} DefineObjectArray
511
532
  */
512
533
 
513
534
  /**
@@ -515,11 +536,27 @@ function _DOMfromJMLOrString (childNodeJML) {
515
536
  */
516
537
 
517
538
  /**
518
- * @typedef {{elem?: HTMLElement, [key: string]: any}} SymbolObject
539
+ * @template [T=ArbitraryValue]
540
+ * @template {HTMLElement} [U=HTMLElement]
541
+ * @typedef {T & {elem?: U}} SymbolObject
542
+ */
543
+
544
+ /**
545
+ * @template {HTMLElement} [T=HTMLElement]
546
+ * @typedef {(this: T, ...args: UserArg[]) => UserArg} SymbolMethod
547
+ */
548
+
549
+ /**
550
+ * @typedef {(...args: UserArg[]) => UserArg} BoundSymbolMethod
551
+ */
552
+
553
+ /**
554
+ * @template {HTMLElement} [T=HTMLElement]
555
+ * @typedef {[symbol|string, SymbolMethod<T>|SymbolObject<ArbitraryValue, T>]} SymbolArray
519
556
  */
520
557
 
521
558
  /**
522
- * @typedef {[symbol|string, ((this: HTMLElement, ...args: any[]) => any)|SymbolObject]} SymbolArray
559
+ * @typedef {BoundSymbolMethod|SymbolObject|ArbitraryValue} SymbolResult
523
560
  */
524
561
 
525
562
  /**
@@ -527,7 +564,7 @@ function _DOMfromJMLOrString (childNodeJML) {
527
564
  */
528
565
 
529
566
  /**
530
- * @typedef {[string, object]|string|{[key: string]: any}} PluginValue
567
+ * @typedef {[string, object]|string|object} PluginValue
531
568
  */
532
569
 
533
570
  /**
@@ -542,15 +579,15 @@ function _DOMfromJMLOrString (childNodeJML) {
542
579
 
543
580
  /**
544
581
  * @typedef {{
545
- * [key: string]: string|number|((this: HTMLElement, ...args: any[]) => any)
546
- * }} DataAttributeObject
547
- */
582
+ * [key: string]: string|number|((this: HTMLElement, ...args: UserArg[]) => UserArg)
583
+ * }} DataAttributeObject
584
+ */
548
585
 
549
586
  /**
550
587
  * @typedef {{
551
- * $data?: true|string[]|Map<any, any>|WeakMap<any, any>|DataAttributeObject|
588
+ * $data?: true|string[]|Map<HTMLElement, UserArg>|WeakMap<HTMLElement, UserArg>|DataAttributeObject|
552
589
  * [undefined, DataAttributeObject]|
553
- * [Map<any, any>|WeakMap<any, any>|undefined, DataAttributeObject]
590
+ * [Map<HTMLElement, UserArg>|WeakMap<HTMLElement, UserArg>|undefined, DataAttributeObject]
554
591
  * }} DataAttribute
555
592
  */
556
593
 
@@ -572,18 +609,16 @@ function _DOMfromJMLOrString (childNodeJML) {
572
609
  * }} JamilihShadowRootAttribute
573
610
  */
574
611
 
575
- /* eslint-disable jsdoc/valid-types -- jsdoc-type-pratt-parser Bug */
576
612
  /**
577
613
  * @typedef {{
578
614
  * is?: string|null,
579
615
  * $define?: DefineObject
580
616
  * }} DefineAttribute
581
617
  */
582
- /* eslint-enable jsdoc/valid-types -- jsdoc-type-pratt-parser Bug */
583
618
 
584
619
  /**
585
620
  * @typedef {{
586
- * $custom?: {[key: string]: any}
621
+ * $custom?: {[key: string]: unknown}
587
622
  * }} CustomAttribute
588
623
  */
589
624
 
@@ -613,6 +648,11 @@ function _DOMfromJMLOrString (childNodeJML) {
613
648
  /**
614
649
  * @typedef {{
615
650
  * title?: string,
651
+ * xmlDeclaration?: {
652
+ * version: string,
653
+ * encoding: string,
654
+ * standalone: boolean
655
+ * },
616
656
  * childNodes?: JamilihChildType[],
617
657
  * $DOCTYPE?: JamilihDocumentType,
618
658
  * head?: JamilihChildren
@@ -651,21 +691,30 @@ function _DOMfromJMLOrString (childNodeJML) {
651
691
  */
652
692
 
653
693
  /**
694
+ * @typedef {Document|ElementName|HTMLElement|DocumentFragment|
695
+ * JamilihDocumentFragment|JamilihDoc|JamilihDoctype|JamilihTextNode|
696
+ * JamilihAttributeNode} JamilihFirstArgument
697
+ */
698
+
699
+ /**
700
+ * Array-form Jamilih input whose tuple positions were widened by operations
701
+ * such as `Array#map`.
654
702
  * @typedef {(
655
- * JamilihArray|TextNodeString|HTMLElement|Comment|ProcessingInstruction|
656
- * Text|DocumentFragment|JamilihProcessingInstruction|JamilihDocumentFragment|
657
- * PluginReference
658
- * )[]} JamilihChildren
703
+ * JamilihFirstArg|JamilihAttributes|JamilihArrayLike|TextNodeString|
704
+ * ShadowRoot|null
705
+ * )[]} JamilihArrayLike
659
706
  */
660
707
 
661
- // Todo: DocumentType, Comment, ProcessingInstruction, Text
662
- // Todo: JamilihCDATANode, JamilihComment, JamilihProcessingInstruction
663
708
  /**
664
- * @typedef {Document|ElementName|HTMLElement|DocumentFragment|
665
- * JamilihDocumentFragment|JamilihDoc|JamilihDoctype|JamilihTextNode|
666
- * JamilihAttributeNode} JamilihFirstArgument
709
+ * @typedef {(
710
+ * JamilihArray|JamilihArrayLike|TextNodeString|HTMLElement|Comment|
711
+ * ProcessingInstruction|Text|DocumentFragment|JamilihProcessingInstruction|
712
+ * JamilihDocumentFragment|PluginReference
713
+ * )[]} JamilihChildren
667
714
  */
668
715
 
716
+ // Todo: DocumentType, Comment, ProcessingInstruction, Text
717
+ // Todo: JamilihCDATANode, JamilihComment, JamilihProcessingInstruction
669
718
  /**
670
719
  * This would be clearer with overrides, but using as typedef.
671
720
  *
@@ -711,8 +760,8 @@ function _DOMfromJMLOrString (childNodeJML) {
711
760
 
712
761
  /**
713
762
  * @typedef {{
714
- * root: [Map<HTMLElement,any>|WeakMap<HTMLElement,any>, any],
715
- * [key: string]: [Map<HTMLElement,any>|WeakMap<HTMLElement,any>, any]
763
+ * root: [Map<HTMLElement,UserArg>|WeakMap<HTMLElement,UserArg>, UserArg],
764
+ * [key: string]: [Map<HTMLElement,UserArg>|WeakMap<HTMLElement,UserArg>, UserArg]
716
765
  * }} MapWithRoot
717
766
  */
718
767
 
@@ -724,7 +773,7 @@ function _DOMfromJMLOrString (childNodeJML) {
724
773
  * @typedef {object} JamilihOptions
725
774
  * @property {TraversalState} [$state]
726
775
  * @property {JamilihPlugin[]} [$plugins]
727
- * @property {MapWithRoot|[Map<HTMLElement,any>|WeakMap<HTMLElement,any>, any]} [$map]
776
+ * @property {MapWithRoot|[Map<HTMLElement,UserArg>|WeakMap<HTMLElement,UserArg>, UserArg]} [$map]
728
777
  */
729
778
 
730
779
  /**
@@ -750,8 +799,7 @@ function checkPluginValue(elem, att, attVal, opts, state) {
750
799
  });
751
800
  }
752
801
  }
753
- return (/** @type {string} */attVal
754
- );
802
+ return /** @type {string} */attVal;
755
803
  }
756
804
 
757
805
  /**
@@ -765,27 +813,213 @@ function getMatchingPlugin(opts, pluginName) {
765
813
  });
766
814
  }
767
815
 
768
- /* eslint-disable jsdoc/valid-types -- pratt parser bug */
769
816
  /**
770
817
  * @template T
771
818
  * @typedef {T[keyof T]} ValueOf
772
819
  */
773
- /* eslint-enable jsdoc/valid-types -- pratt parser bug */
774
820
 
775
- /* eslint-disable jsdoc/valid-types -- pratt parser bug */
821
+ /**
822
+ * @template {JamilihArray} T
823
+ * @typedef {Extract<Extract<T[number], {$custom?: {[key: string]: unknown}}>['$custom'], object>} RawCustomFromJamilihArray
824
+ */
825
+
826
+ /**
827
+ * @template M
828
+ * @typedef {M extends object
829
+ * ? string extends keyof M
830
+ * ? object
831
+ * : M
832
+ * : object} SpecificDefineMixin
833
+ */
834
+
835
+ /**
836
+ * @template D
837
+ * @typedef {D extends [infer First, infer Second, ...ArbitraryValue[]]
838
+ * ? (First extends DefineMixin
839
+ * ? SpecificDefineMixin<First>
840
+ * : Second extends DefineMixin
841
+ * ? SpecificDefineMixin<Second>
842
+ * : object)
843
+ * : D extends [infer First]
844
+ * ? First extends DefineMixin
845
+ * ? SpecificDefineMixin<First>
846
+ * : object
847
+ * : D extends DefineMixin
848
+ * ? SpecificDefineMixin<D>
849
+ * : object} DefineMixinFromValue
850
+ */
851
+
852
+ /**
853
+ * @template {JamilihArray} T
854
+ * @typedef {T[number] extends infer Item
855
+ * ? Item extends {$define: infer D}
856
+ * ? DefineMixinFromValue<D>
857
+ * : never
858
+ * : never} RawDefineMixinFromJamilihArray
859
+ */
860
+
861
+ /**
862
+ * @template D
863
+ * @typedef {D extends [infer First, infer Second, ...ArbitraryValue[]]
864
+ * ? First extends DefineConstructor
865
+ * ? First['prototype']
866
+ * : Second extends DefineConstructor
867
+ * ? Second['prototype']
868
+ * : never
869
+ * : D extends DefineConstructor
870
+ * ? D['prototype']
871
+ * : never} ElementFromDefineValue
872
+ */
873
+
874
+ /**
875
+ * @template {JamilihArray} T
876
+ * @typedef {T[number] extends infer Item
877
+ * ? Item extends {$define: infer D}
878
+ * ? ElementFromDefineValue<D>
879
+ * : never
880
+ * : never} ElementFromJamilihDefine
881
+ */
882
+
883
+ /**
884
+ * @template {JamilihArray} T
885
+ * @typedef {Extract<T[number], {xmlns: unknown}> extends never ? false : true} HasXmlnsFromJamilihArray
886
+ */
887
+
888
+ /**
889
+ * @template {JamilihArray} T
890
+ * @typedef {T extends [infer K, ...ArbitraryValue[]]
891
+ * ? (HasXmlnsFromJamilihArray<T> extends true
892
+ * ? Element
893
+ * : ElementFromJamilihDefine<T> extends never
894
+ * ? K extends keyof HTMLElementTagNameMap
895
+ * ? HTMLElementTagNameMap[K]
896
+ * : HTMLElement
897
+ * : ElementFromJamilihDefine<T>)
898
+ * : Element} ElementFromJamilihArray
899
+ */
900
+
901
+ /**
902
+ * @template A
903
+ * @template {Element} E
904
+ * @template X
905
+ * @typedef {A extends {$custom: infer C}
906
+ * ? (C extends object
907
+ * ? Omit<A, '$custom'> & {$custom?: C & ThisType<E & C & X>}
908
+ * : A)
909
+ * : A} WithCustomThis
910
+ */
911
+
912
+ /**
913
+ * @template D
914
+ * @template {Element} E
915
+ * @template X
916
+ * @typedef {D extends [infer First, infer Second, ...infer Rest]
917
+ * ? (First extends DefineMixin
918
+ * ? [First & ThisType<E & First & X>, Second, ...Rest]
919
+ * : Second extends DefineMixin
920
+ * ? [First, Second & ThisType<E & Second & X>, ...Rest]
921
+ * : D)
922
+ * : D extends [infer First]
923
+ * ? First extends DefineMixin
924
+ * ? [First & ThisType<E & First & X>]
925
+ * : D
926
+ * : D extends DefineMixin
927
+ * ? D & ThisType<E & D & X>
928
+ * : D} WithDefineThisValue
929
+ */
930
+
931
+ /**
932
+ * @template A
933
+ * @template {Element} E
934
+ * @template X
935
+ * @typedef {A extends {$define: infer D}
936
+ * ? Omit<A, '$define'> & {$define?: WithDefineThisValue<D, E, X>}
937
+ * : A} WithDefineThis
938
+ */
939
+
940
+ /**
941
+ * @template A
942
+ * @typedef {A extends {$custom: infer C}
943
+ * ? C extends object ? C : object
944
+ * : object} CustomFromJamilihItem
945
+ */
946
+
947
+ /**
948
+ * @template A
949
+ * @typedef {A extends {$define: infer D}
950
+ * ? DefineMixinFromValue<D>
951
+ * : object} DefineMixinFromJamilihItem
952
+ */
953
+
954
+ /**
955
+ * @template {JamilihArray} T
956
+ * @template {Element} E
957
+ * @typedef {{[K in keyof T]: WithCustomThis<
958
+ * WithDefineThis<T[K], E, CustomFromJamilihItem<T[K]>>,
959
+ * E,
960
+ * DefineMixinFromJamilihItem<T[K]>
961
+ * >}} JamilihArrayWithCustomThis
962
+ */
963
+
964
+ /**
965
+ * @template A
966
+ * @typedef {A extends (infer Item)[]
967
+ * ? (Extract<Item, JamilihFirstArg> extends never ? never : A)
968
+ * : A} ValidateJamilihArrayLike
969
+ */
970
+
971
+ /**
972
+ * @template A
973
+ * @typedef {A extends (infer Child)[]
974
+ * ? A & (Child extends unknown[] ? ValidateJamilihArrayLike<Child> : Child)[]
975
+ * : A} ValidateJamilihChildContainer
976
+ */
977
+
978
+ /**
979
+ * @template {JamilihArray} T
980
+ * @typedef {{[K in keyof T]: ValidateJamilihChildContainer<T[K]>}} ValidateJamilihArrayLikes
981
+ */
982
+
983
+ /**
984
+ * @template {JamilihArray} T
985
+ * @typedef {(
986
+ * RawCustomFromJamilihArray<T> extends never
987
+ * ? object
988
+ * : RawCustomFromJamilihArray<T>
989
+ * )} CustomFromJamilihArray
990
+ */
991
+
992
+ /**
993
+ * @template {JamilihArray} T
994
+ * @typedef {(
995
+ * RawDefineMixinFromJamilihArray<T> extends never
996
+ * ? object
997
+ * : RawDefineMixinFromJamilihArray<T>
998
+ * )} DefineMixinFromJamilihArray
999
+ */
1000
+
1001
+ /**
1002
+ * @template U
1003
+ * @template W
1004
+ * @typedef {U extends void ? (ExpandoHTMLElement & W) : (U & W)} ResolvedElement
1005
+ */
1006
+
776
1007
  /**
777
1008
  * Creates an XHTML or HTML element (XHTML is preferred, but only in browsers
778
1009
  * that support); any element after element can be omitted, and any subsequent
779
1010
  * type or types added afterwards.
780
1011
  * @template {JamilihArray} T
781
- * @param {T} args
782
- * @returns {T extends [keyof HTMLElementTagNameMap, any?, any?, any?]
783
- * ? HTMLElementTagNameMap[T[0]] : JamilihReturn}
1012
+ * @template {T extends [infer K, ...ArbitraryValue[]] ? (HasXmlnsFromJamilihArray<T> extends true ? Element : ElementFromJamilihDefine<T> extends never ? K extends keyof HTMLElementTagNameMap ? HTMLElementTagNameMap[K] : K extends string ? HTMLElement : void : ElementFromJamilihDefine<T>) : void} U
1013
+ * @template {ElementFromJamilihArray<T>} E
1014
+ * @template {CustomFromJamilihArray<T>} W
1015
+ * @template {DefineMixinFromJamilihArray<T>} D
1016
+ * @param {JamilihArrayWithCustomThis<T, E> & ValidateJamilihArrayLikes<T>} args
1017
+ * @returns {U extends void ? JamilihReturn : ResolvedElement<U, W & D>}
784
1018
  * The newly created (and possibly already appended)
785
1019
  * element or array of elements
786
1020
  */
1021
+
787
1022
  const jml = function jml(...args) {
788
- /* eslint-enable jsdoc/valid-types -- pratt parser bug */
789
1023
  if (!win) {
790
1024
  throw new Error('No window object');
791
1025
  }
@@ -793,7 +1027,7 @@ const jml = function jml(...args) {
793
1027
  throw new Error('No document object');
794
1028
  }
795
1029
 
796
- /** @type {(Document|DocumentFragment|HTMLElement) & {[key: string]: any}} */
1030
+ /** @type {(Document|DocumentFragment|HTMLElement) & {[key: string]: ElementExpando}} */
797
1031
  let elem = doc.createDocumentFragment();
798
1032
  /**
799
1033
  *
@@ -807,21 +1041,16 @@ const jml = function jml(...args) {
807
1041
  throw new Error('No document object');
808
1042
  }
809
1043
  for (let [att, attVal] of Object.entries(atts)) {
810
- att = ATTR_MAP.get(att) ?? att;
811
-
812
- /**
813
- * @typedef {any} ElementExpando
814
- */
815
-
816
- if (NULLABLES.includes(att)) {
1044
+ att = ATTR_MAP.has(att) ? String(ATTR_MAP.get(att)) : att;
1045
+ if (NULLABLES.has(att)) {
817
1046
  attVal = checkPluginValue(elem, att, /** @type {string|JamilihArray} */attVal, opts);
818
1047
  if (!_isNullish(attVal)) {
819
- /** @type {ElementExpando} */elem[att] = attVal;
1048
+ elem[att] = attVal;
820
1049
  }
821
1050
  continue;
822
- } else if (ATTR_DOM.includes(att)) {
1051
+ }
1052
+ if (ATTR_DOM.has(att)) {
823
1053
  attVal = checkPluginValue(elem, att, /** @type {string|JamilihArray} */attVal, opts);
824
- /** @type {ElementExpando} */
825
1054
  elem[att] = attVal;
826
1055
  continue;
827
1056
  }
@@ -859,13 +1088,13 @@ const jml = function jml(...args) {
859
1088
  if (template) {
860
1089
  if (Array.isArray(template)) {
861
1090
  template = /** @type {HTMLTemplateElement} */
862
- _getType(template[0]) === 'object' ? jml('template', ...
1091
+ _getType(template[0]) === 'object' ? jml('template', ...(
863
1092
  /**
864
1093
  * @type {[
865
1094
  * JamilihAttributes, ...(JamilihArray[]|HTMLElement)[]
866
1095
  * ]}
867
1096
  */
868
- template, doc.body) : jml('template',
1097
+ template), doc.body) : jml('template',
869
1098
  /**
870
1099
  * @type {JamilihArray[]|HTMLElement}
871
1100
  */
@@ -873,7 +1102,7 @@ const jml = function jml(...args) {
873
1102
  } else if (typeof template === 'string') {
874
1103
  template = /** @type {HTMLTemplateElement} */$(template);
875
1104
  }
876
- jml( /** @type {HTMLTemplateElement} */
1105
+ jml(/** @type {HTMLTemplateElement} */
877
1106
  /** @type {HTMLTemplateElement} */template.content.cloneNode(true), shadowRoot);
878
1107
  } else {
879
1108
  if (!content) {
@@ -906,6 +1135,9 @@ const jml = function jml(...args) {
906
1135
  }
907
1136
  case '$custom':
908
1137
  {
1138
+ if (attVal !== null && (typeof attVal === 'object' || typeof attVal === 'function') && Object.prototype.propertyIsEnumerable.call(attVal, '__proto__')) {
1139
+ throw new TypeError('`$custom` may not define `__proto__`');
1140
+ }
909
1141
  Object.assign(elem, attVal);
910
1142
  break;
911
1143
  }
@@ -934,7 +1166,7 @@ const jml = function jml(...args) {
934
1166
  } = atts);
935
1167
  }
936
1168
  }
937
- const def = customizedBuiltIn ? /** @type {string} */is : localName;
1169
+ const def = customizedBuiltIn ? (/** @type {string} */is) : localName;
938
1170
  if (window.customElements.get(def)) {
939
1171
  break;
940
1172
  }
@@ -948,7 +1180,7 @@ const jml = function jml(...args) {
948
1180
  if (!doc) {
949
1181
  throw new Error('No document object');
950
1182
  }
951
- const baseClass = typeof options === 'object' && typeof options.extends === 'string' ? /** @type {typeof HTMLElement} */doc.createElement(options.extends).constructor : customizedBuiltIn ? /** @type {typeof HTMLElement} */doc.createElement(localName).constructor : window.HTMLElement;
1183
+ const baseClass = typeof options === 'object' && typeof options.extends === 'string' ? (/** @type {typeof HTMLElement} */doc.createElement(options.extends).constructor) : customizedBuiltIn ? (/** @type {typeof HTMLElement} */doc.createElement(localName).constructor) : window.HTMLElement;
952
1184
 
953
1185
  /**
954
1186
  * Class wrapping base class.
@@ -976,7 +1208,8 @@ const jml = function jml(...args) {
976
1208
  const defineObj = /** @type {DefineObject} */attVal;
977
1209
  if (Array.isArray(defineObj)) {
978
1210
  if (defineObj.length <= 2) {
979
- [cnstrctr, options] = defineObj;
1211
+ [cnstrctr] = defineObj;
1212
+ options = /** @type {DefineOptions|undefined} */defineObj[1];
980
1213
  if (typeof options === 'string') {
981
1214
  // Todo: Allow creating a definition without using it;
982
1215
  // that may be the only reason to have a string here which
@@ -1006,7 +1239,7 @@ const jml = function jml(...args) {
1006
1239
  cnstrctr = getConstructor();
1007
1240
  }
1008
1241
  if (!cnstrctr.toString().startsWith('class')) {
1009
- cnstrctr = getConstructor( /** @type {DefineUserConstructor} */cnstrctr);
1242
+ cnstrctr = getConstructor(/** @type {DefineUserConstructor} */cnstrctr);
1010
1243
  }
1011
1244
  if (!options && customizedBuiltIn) {
1012
1245
  options = {
@@ -1015,7 +1248,7 @@ const jml = function jml(...args) {
1015
1248
  }
1016
1249
  if (mixin) {
1017
1250
  Object.entries(mixin).forEach(([methodName, method]) => {
1018
- /** @type {DefineConstructor} */cnstrctr.prototype[methodName] = method;
1251
+ Reflect.set(/** @type {DefineConstructor} */cnstrctr.prototype, methodName, method);
1019
1252
  });
1020
1253
  }
1021
1254
  // console.log('def', def, '::', typeof options === 'object' ? options : undefined);
@@ -1024,9 +1257,13 @@ const jml = function jml(...args) {
1024
1257
  }
1025
1258
  case '$symbol':
1026
1259
  {
1027
- const [symbol, func] = /** @type {SymbolArray} */attVal;
1260
+ if (!_isHTMLElement(elem)) {
1261
+ throw new TypeError('Element expected for `$symbol`');
1262
+ }
1263
+ const symbolElem = /** @type {ResolvedElement<U, W>} */elem;
1264
+ const [symbol, func] = /** @type {SymbolArray<ResolvedElement<U, W>>} */attVal;
1028
1265
  if (typeof func === 'function') {
1029
- const funcBound = func.bind( /** @type {HTMLElement} */elem);
1266
+ const funcBound = func.bind(symbolElem);
1030
1267
  if (typeof symbol === 'string') {
1031
1268
  // @ts-expect-error
1032
1269
  elem[Symbol.for(symbol)] = funcBound;
@@ -1036,7 +1273,7 @@ const jml = function jml(...args) {
1036
1273
  }
1037
1274
  } else {
1038
1275
  const obj = func;
1039
- obj.elem = /** @type {HTMLElement} */elem;
1276
+ obj.elem = symbolElem;
1040
1277
  if (typeof symbol === 'string') {
1041
1278
  // @ts-expect-error
1042
1279
  elem[Symbol.for(symbol)] = obj;
@@ -1049,7 +1286,7 @@ const jml = function jml(...args) {
1049
1286
  }
1050
1287
  case '$data':
1051
1288
  {
1052
- setMap( /** @type {true|string[]|Map<any, any>|WeakMap<any, any>|DataAttributeObject} */
1289
+ setMap(/** @type {true|string[]|Map<HTMLElement, unknown>|WeakMap<HTMLElement, unknown>|DataAttributeObject} */
1053
1290
  attVal);
1054
1291
  break;
1055
1292
  }
@@ -1057,35 +1294,34 @@ const jml = function jml(...args) {
1057
1294
  {
1058
1295
  // Attribute node
1059
1296
  const attr = /** @type {JamilihAttributeNodeValue} */attVal;
1060
- const node = attr.length === 3 ? doc.createAttributeNS(attr[0], attr[1]) : doc.createAttribute( /** @type {string} */attr[0]);
1061
- node.value = /** @type {string} */attr[attr.length - 1];
1297
+ const node = attr.length === 3 ? doc.createAttributeNS(attr[0], attr[1]) : doc.createAttribute(/** @type {string} */attr[0]);
1298
+ node.value = /** @type {string} */attr.at(-1);
1062
1299
  nodes[nodes.length] = node;
1063
1300
  break;
1064
1301
  }
1065
1302
  case '$text':
1066
1303
  {
1067
1304
  // Todo: Also allow as jml(['a text node']) (or should that become a fragment)?
1068
- const node = doc.createTextNode( /** @type {string} */attVal);
1305
+ const node = doc.createTextNode(/** @type {string} */attVal);
1069
1306
  nodes[nodes.length] = node;
1070
1307
  break;
1071
1308
  }
1072
1309
  case '$document':
1073
1310
  {
1074
1311
  // Todo: Conditionally create XML document
1075
- const docNode = doc.implementation.createHTMLDocument();
1076
1312
  if (!attVal) {
1077
1313
  throw new Error('Bad attribute value');
1078
1314
  }
1315
+ const docNode = doc.implementation.createHTMLDocument();
1079
1316
  const jamlihDoc = /** @type {JamilihDocument} */attVal;
1080
1317
  if (jamlihDoc.childNodes) {
1081
1318
  // Remove any extra nodes created by createHTMLDocument().
1082
1319
  const j = jamlihDoc.childNodes.length;
1083
- while (docNode.childNodes[j]) {
1320
+ while (Object.hasOwn(docNode.childNodes, j)) {
1084
1321
  const cn = docNode.childNodes[j];
1085
1322
  cn.remove();
1086
1323
  // `j` should stay the same as removing will cause node to be present
1087
1324
  }
1088
-
1089
1325
  jamlihDoc.childNodes.forEach(_childrenToJML(docNode));
1090
1326
  } else {
1091
1327
  if (jamlihDoc.$DOCTYPE) {
@@ -1106,8 +1342,7 @@ const jml = function jml(...args) {
1106
1342
  if (jamlihDoc.title) {
1107
1343
  docNode.title = jamlihDoc.title; // Appends after meta
1108
1344
  }
1109
-
1110
- if (jamlihDoc.head && head) {
1345
+ if (head && jamlihDoc.head) {
1111
1346
  // each child of `head` is:
1112
1347
  // (JamilihArray|TextNodeString|HTMLElement|Comment|ProcessingInstruction|
1113
1348
  // Text|DocumentFragment|JamilihProcessingInstruction|JamilihDocumentFragment)
@@ -1121,10 +1356,20 @@ const jml = function jml(...args) {
1121
1356
  jamlihDoc.head.forEach(_appendJML(head));
1122
1357
  }
1123
1358
  }
1124
- if (jamlihDoc.body && body) {
1359
+ if (body && jamlihDoc.body) {
1125
1360
  jamlihDoc.body.forEach(_appendJMLOrText(body));
1126
1361
  }
1127
1362
  }
1363
+ if (jamlihDoc.xmlDeclaration) {
1364
+ const {
1365
+ version,
1366
+ encoding,
1367
+ standalone
1368
+ } = jamlihDoc.xmlDeclaration;
1369
+ const xmlDeclarationData = `${version ? ` version="${version}"` : ''}${encoding ? ` encoding="${encoding}"` : ''}${standalone ? ` standalone="yes"` : ''}`.slice(1);
1370
+ const xmlDeclaration = doc.createProcessingInstruction('xml', xmlDeclarationData);
1371
+ docNode.insertBefore(xmlDeclaration, docNode.firstChild);
1372
+ }
1128
1373
  nodes[nodes.length] = docNode;
1129
1374
  break;
1130
1375
  }
@@ -1138,17 +1383,18 @@ const jml = function jml(...args) {
1138
1383
  case '$on':
1139
1384
  {
1140
1385
  // Events
1386
+ const onElem = /** @type {ResolvedElement<U, W>} */elem;
1141
1387
  // Allow for no-op by defaulting to `{}`
1142
- for (let [p2, val] of Object.entries( /** @type {OnAttributeObject} */attVal || {})) {
1388
+ // eslint-disable-next-line prefer-const, unicorn/no-unreadable-for-of-expression -- Ok as mixed
1389
+ for (let [p2, val] of Object.entries(/** @type {OnAttributeObject<ResolvedElement<U, W>>} */attVal || {})) {
1143
1390
  if (typeof val === 'function') {
1144
1391
  val = [val, false];
1145
1392
  }
1146
1393
  if (typeof val[0] !== 'function') {
1147
1394
  throw new TypeError(`Expect a function for \`$on\`; args: ${JSON.stringify(args)}`);
1148
1395
  }
1149
- _addEvent( /** @type {HTMLElement} */elem, p2, val[0], val[1]); // element, event name, handler, capturing
1396
+ _addEvent(onElem, p2, val[0], val[1]); // element, event name, handler, capturing
1150
1397
  }
1151
-
1152
1398
  break;
1153
1399
  }
1154
1400
  case 'className':
@@ -1171,7 +1417,11 @@ const jml = function jml(...args) {
1171
1417
  const pastInitialProp = startProp !== '';
1172
1418
  Object.keys(atVal).forEach(key => {
1173
1419
  const value = atVal[key];
1174
- prop = pastInitialProp ? startProp + key.replace(hyphenForCamelCase, _upperCase).replace(/^([a-z])/u, _upperCase) : startProp + key.replace(hyphenForCamelCase, _upperCase);
1420
+ prop = startProp + (pastInitialProp
1421
+ // eslint-disable-next-line unicorn/no-unsafe-string-replacement -- Function
1422
+ ? key.replaceAll(hyphenForCamelCase, _upperCase).replace(/^([a-z])/u, _upperCase)
1423
+ // eslint-disable-next-line unicorn/no-unsafe-string-replacement -- Function
1424
+ : key.replaceAll(hyphenForCamelCase, _upperCase));
1175
1425
  if (value === null || typeof value !== 'object') {
1176
1426
  if (!_isNullish(value)) {
1177
1427
  elem.dataset[prop] = value;
@@ -1182,7 +1432,7 @@ const jml = function jml(...args) {
1182
1432
  recurse(value, prop);
1183
1433
  });
1184
1434
  };
1185
- recurse( /** @type {DatasetAttributeObject} */attVal, '');
1435
+ recurse(/** @type {DatasetAttributeObject} */attVal, '');
1186
1436
  break;
1187
1437
  // Todo: Disable this by default unless configuration explicitly allows (for security)
1188
1438
  }
@@ -1232,7 +1482,8 @@ const jml = function jml(...args) {
1232
1482
  elem.style.cssFloat = styleVal;
1233
1483
  elem.style.styleFloat = styleVal; // Harmless though we could make conditional on older IE instead
1234
1484
  } else {
1235
- elem.style[p2.replace(hyphenForCamelCase, _upperCase)] = styleVal;
1485
+ // eslint-disable-next-line unicorn/no-unsafe-string-replacement -- Function
1486
+ elem.style[p2.replaceAll(hyphenForCamelCase, _upperCase)] = styleVal;
1236
1487
  }
1237
1488
  }
1238
1489
  }
@@ -1256,10 +1507,10 @@ const jml = function jml(...args) {
1256
1507
  if (matchingPlugin) {
1257
1508
  matchingPlugin.set({
1258
1509
  opts,
1259
- element: /** @type {HTMLElement} */nodes[0],
1510
+ element: (/** @type {HTMLElement} */nodes[0]),
1260
1511
  attribute: {
1261
1512
  name: pluginName,
1262
- value: /** @type {PluginReference} */attVal
1513
+ value: (/** @type {PluginReference} */attVal)
1263
1514
  }
1264
1515
  });
1265
1516
  break;
@@ -1321,12 +1572,12 @@ const jml = function jml(...args) {
1321
1572
  const defaultMap = opts.$map && /** @type {MapWithRoot} */opts.$map.root;
1322
1573
 
1323
1574
  /**
1324
- * @param {true|string[]|Map<any, any>|WeakMap<any, any>|DataAttributeObject} dataVal
1575
+ * @param {true|string[]|Map<HTMLElement, UserArg>|WeakMap<HTMLElement, UserArg>|DataAttributeObject|[Map<HTMLElement, UserArg>|WeakMap<HTMLElement, UserArg>|undefined, DataAttributeObject|UserArg]} dataVal
1325
1576
  * @returns {void}
1326
1577
  */
1327
1578
  const setMap = dataVal => {
1328
1579
  let map, obj;
1329
- const defMap = /** @type {[Map<HTMLElement, any> | WeakMap<HTMLElement, any>, any]} */defaultMap;
1580
+ const defMap = /** @type {[Map<HTMLElement, UserArg> | WeakMap<HTMLElement, UserArg>, UserArg]} */defaultMap;
1330
1581
  // Boolean indicating use of default map and object
1331
1582
  if (dataVal === true) {
1332
1583
  [map, obj] = defMap;
@@ -1334,12 +1585,11 @@ const jml = function jml(...args) {
1334
1585
  // Array of strings mapping to default
1335
1586
  if (typeof dataVal[0] === 'string') {
1336
1587
  dataVal.forEach(dVal => {
1337
- setMap( /** @type {MapWithRoot} */opts.$map[dVal]);
1588
+ setMap(/** @type {MapWithRoot} */opts.$map[dVal]);
1338
1589
  });
1339
1590
  return;
1340
1591
  // Array of Map and non-map data object
1341
1592
  }
1342
-
1343
1593
  map = dataVal[0] || defMap[0];
1344
1594
  obj = dataVal[1] || defMap[1];
1345
1595
  // Map
@@ -1351,8 +1601,8 @@ const jml = function jml(...args) {
1351
1601
  map = defMap[0];
1352
1602
  obj = dataVal;
1353
1603
  }
1354
- /** @type {Map<HTMLElement, any> | WeakMap<HTMLElement, any>} */
1355
- map.set( /** @type {HTMLElement} */
1604
+ /** @type {Map<HTMLElement, UserArg> | WeakMap<HTMLElement, UserArg>} */
1605
+ map.set(/** @type {HTMLElement} */
1356
1606
  elem, obj);
1357
1607
  };
1358
1608
  for (let i = argStart; i < argc; i++) {
@@ -1363,18 +1613,16 @@ const jml = function jml(...args) {
1363
1613
  // null always indicates a place-holder (only needed for last argument if want array returned)
1364
1614
  if (i === argc - 1) {
1365
1615
  // Casting needing unless changing `jml()` signature with overloads
1366
- return (/** @type {ArbitraryValue} */nodes.length <= 1 ? nodes[0]
1367
- // eslint-disable-next-line unicorn/no-array-callback-reference
1368
- : nodes.reduce(_fragReducer, doc.createDocumentFragment())
1369
- ); // nodes;
1616
+ return /** @type {U extends void ? JamilihReturn : ResolvedElement<U, W & D>} */nodes.length <= 1 ? nodes[0]
1617
+ // eslint-disable-next-line unicorn/no-array-callback-reference
1618
+ : nodes.reduce(_fragReducer, doc.createDocumentFragment()); // nodes;
1370
1619
  }
1371
-
1372
1620
  throw new TypeError(`\`null\` values not allowed except as final Jamilih argument; index ${i} on args: ${JSON.stringify(args)}`);
1373
1621
  case 'string':
1374
1622
  // Strings normally indicate elements
1375
1623
  switch (arg) {
1376
1624
  case '!':
1377
- nodes[nodes.length] = doc.createComment( /** @type {string} */args[++i]);
1625
+ nodes[nodes.length] = doc.createComment(/** @type {string} */args[++i]);
1378
1626
  break;
1379
1627
  case '?':
1380
1628
  {
@@ -1384,9 +1632,9 @@ const jml = function jml(...args) {
1384
1632
  if (val && typeof val === 'object') {
1385
1633
  const procValues = [];
1386
1634
  for (const [p, procInstVal] of Object.entries(val)) {
1387
- procValues.push(p + '=' + '"' +
1635
+ procValues.push(p + '="' +
1388
1636
  // https://www.w3.org/TR/xml-stylesheet/#NT-PseudoAttValue
1389
- procInstVal.replace(/"/gu, '&quot;') + '"');
1637
+ procInstVal.replaceAll('"', '&quot;') + '"');
1390
1638
  }
1391
1639
  procValue = procValues.join(' ');
1392
1640
  }
@@ -1423,12 +1671,11 @@ const jml = function jml(...args) {
1423
1671
  // CDATA valid in XML only, so we'll just treat as text for mutual compatibility
1424
1672
  // Todo: config (or detection via some kind of doc.documentType property?) of whether in XML
1425
1673
  try {
1426
- nodes[nodes.length] = doc.createCDATASection( /** @type {string} */args[++i]);
1674
+ nodes[nodes.length] = doc.createCDATASection(/** @type {string} */args[++i]);
1427
1675
  } catch (e2) {
1428
- nodes[nodes.length] = doc.createTextNode( /** @type {string} */
1676
+ nodes[nodes.length] = doc.createTextNode(/** @type {string} */
1429
1677
  args[i]); // i already incremented
1430
1678
  }
1431
-
1432
1679
  break;
1433
1680
  case '':
1434
1681
  nodes[nodes.length] = elem = doc.createDocumentFragment();
@@ -1447,13 +1694,12 @@ const jml = function jml(...args) {
1447
1694
  /* c8 ignore next 4 */
1448
1695
  elem = doc.createElementNS
1449
1696
  // Should create separate file for this
1450
- /* eslint-disable object-shorthand -- Casting */ ? /** @type {HTMLElement} */doc.createElementNS(NS_HTML, elStr, {
1451
- is: /** @type {string} */is
1697
+ ? (/** @type {HTMLElement} */doc.createElementNS(NS_HTML, elStr, {
1698
+ is: (/** @type {string} */is)
1452
1699
  })
1453
- /* c8 ignore next 1 */ : doc.createElement(elStr, {
1454
- is: /** @type {string} */is
1700
+ /* c8 ignore next 1 */) : doc.createElement(elStr, {
1701
+ is: (/** @type {string} */is)
1455
1702
  });
1456
- /* eslint-enable object-shorthand -- Casting */
1457
1703
  } else /* c8 ignore next */if (doc.createElementNS) {
1458
1704
  elem = doc.createElementNS(NS_HTML, elStr);
1459
1705
  /* c8 ignore next 3 */
@@ -1481,25 +1727,26 @@ const jml = function jml(...args) {
1481
1727
  // elem.setAttribute('xmlns', atts.xmlns); // Doesn't work
1482
1728
  // Can't set namespaceURI dynamically, renameNode() is not supported, and setAttribute() doesn't work to change the namespace, so we resort to this hack
1483
1729
  const xmlnsObj = /** @type {XmlnsAttributeObject} */atts;
1484
- const replacer = xmlnsObj.xmlns && typeof xmlnsObj.xmlns === 'object' ? _replaceDefiner(xmlnsObj.xmlns) : ' xmlns="' + xmlnsObj.xmlns + '"';
1730
+ const replacer = xmlnsObj.xmlns && typeof xmlnsObj.xmlns === 'object' ? _replaceDefiner(xmlnsObj.xmlns) : ' xmlns="' + escapeReplacer(xmlnsObj.xmlns) + '"';
1485
1731
  // try {
1486
1732
  // Also fix DOMParser to work with text/html
1487
1733
  elem = nodes[nodes.length - 1] =
1488
1734
  // Why doesn't `HTMLWindow` have `DOMParser`?
1489
- new /** @type {import('jsdom').DOMWindow} */win.DOMParser().parseFromString(new /** @type {import('jsdom').DOMWindow} */win.XMLSerializer().serializeToString(elem)
1735
+ new /** @type {import('jsdom').DOMWindow} */win.DOMParser().parseFromString(new /** @type {import('jsdom').DOMWindow} */win.XMLSerializer().serializeToString(elem).
1490
1736
  // Mozilla adds XHTML namespace
1491
- .replace(' xmlns="' + NS_HTML + '"',
1737
+ replace(' xmlns="' + escapeReplacer(NS_HTML) + '"',
1492
1738
  // Needed to cast here, despite either overload working
1739
+ // eslint-disable-next-line unicorn/no-unsafe-string-replacement -- Escaped
1493
1740
  /** @type {string} */
1494
1741
  replacer), 'application/xml').documentElement;
1495
1742
  // Todo: Report to plugins
1496
1743
  opts.$state = 'element';
1497
1744
  // }catch(e) {alert(elem.outerHTML);throw e;}
1498
1745
  }
1499
-
1500
- _checkAtts( /** @type {JamilihAttributes} */atts);
1746
+ _checkAtts(/** @type {JamilihAttributes} */atts);
1501
1747
  break;
1502
1748
  }
1749
+ case 'processing-instruction':
1503
1750
  case 'document':
1504
1751
  case 'fragment':
1505
1752
  case 'element':
@@ -1517,7 +1764,7 @@ const jml = function jml(...args) {
1517
1764
  // parent
1518
1765
  const elsl = nodes.length;
1519
1766
  for (let k = 0; k < elsl; k++) {
1520
- _appendNode( /** @type {Document|DocumentFragment|HTMLElement} */arg, nodes[k]);
1767
+ _appendNode(/** @type {Document|DocumentFragment|HTMLElement} */arg, nodes[k]);
1521
1768
  }
1522
1769
  } else {
1523
1770
  nodes[nodes.length] = /** @type {Document|DocumentFragment|HTMLElement} */arg;
@@ -1528,12 +1775,19 @@ const jml = function jml(...args) {
1528
1775
  // Arrays or arrays of arrays indicate child nodes
1529
1776
  const child = /** @type {JamilihChildren} */arg;
1530
1777
  const cl = child.length;
1778
+ /**
1779
+ * @param {number} childIndex
1780
+ * @returns {TypeError}
1781
+ */
1782
+ const getBadChildrenError = childIndex => {
1783
+ return new TypeError(`Bad children (parent array: ${JSON.stringify(args)}; index ${childIndex} of child: ${JSON.stringify(child)})`);
1784
+ };
1531
1785
  for (let j = 0; j < cl; j++) {
1532
1786
  // Go through children array container to handle elements
1533
1787
  const childContent = child[j];
1534
1788
  const childContentType = typeof childContent;
1535
1789
  if (childContent === null || _isNullish(childContent)) {
1536
- throw new TypeError(`Bad children (parent array: ${JSON.stringify(args)}; index ${j} of child: ${JSON.stringify(child)})`);
1790
+ throw getBadChildrenError(j);
1537
1791
  }
1538
1792
  switch (childContentType) {
1539
1793
  // Todo: determine whether null or function should have special handling or be converted to text
@@ -1545,12 +1799,17 @@ const jml = function jml(...args) {
1545
1799
  default:
1546
1800
  // bigint, symbol, function
1547
1801
  if (typeof childContent !== 'object') {
1548
- throw new TypeError(`Bad children (parent array: ${JSON.stringify(args)}; index ${j} of child: ${JSON.stringify(child)})`);
1802
+ throw getBadChildrenError(j);
1549
1803
  }
1550
1804
  if (Array.isArray(childContent)) {
1551
1805
  // Arrays representing child elements
1806
+ const childHeadType = typeof childContent[0];
1807
+ if (childContent.length === 0 || childHeadType !== 'string' && childHeadType !== 'object' || childContent[0] === null) {
1808
+ throw getBadChildrenError(j);
1809
+ }
1552
1810
  opts.$state = 'children';
1553
- _appendNode(elem, jml(opts, ...childContent));
1811
+ const childArgs = /** @type {JamilihArray} */[opts, ...childContent];
1812
+ _appendNode(elem, jml(...childArgs));
1554
1813
  } else if ('#' in childContent) {
1555
1814
  // Fragment
1556
1815
  opts.$state = 'fragmentChildren';
@@ -1580,8 +1839,7 @@ const jml = function jml(...args) {
1580
1839
  }
1581
1840
 
1582
1841
  // Casting needing unless changing `jml()` signature with overloads
1583
- return (/** @type {ArbitraryValue} */ret
1584
- );
1842
+ return /** @type {U extends void ? JamilihReturn : ResolvedElement<U, W & D>} */ret;
1585
1843
  };
1586
1844
 
1587
1845
  /**
@@ -1651,8 +1909,8 @@ class DOMException extends Error {
1651
1909
 
1652
1910
  /**
1653
1911
  * @typedef {JamilihArray|JamilihDoctype|
1654
- * JamilihCDATANode|JamilihEntityReference|JamilihProcessingInstruction|
1655
- * JamilihComment|JamilihDocumentFragment} JamilihChildType
1912
+ * JamilihCDATANode|JamilihEntityReference|JamilihProcessingInstruction|
1913
+ * JamilihComment|JamilihDocumentFragment} JamilihChildType
1656
1914
  */
1657
1915
 
1658
1916
  /**
@@ -1660,15 +1918,15 @@ class DOMException extends Error {
1660
1918
  */
1661
1919
 
1662
1920
  /**
1663
- * Converts a DOM object or a string of HTML into a Jamilih object (or string).
1664
- * @param {string|HTMLElement|Node|Entity} nde If a string, will parse as document
1665
- * @param {ToJmlConfig} [config] Configuration object
1666
- * @throws {TypeError}
1667
- * @returns {JamilihType|string} Array containing the elements which represent
1668
- * a Jamilih object, or, if `stringOutput` is true, it will be the stringified
1669
- * version of such an object
1670
- */
1671
- jml.toJML = function (nde, {
1921
+ * Converts a DOM object or a string of HTML into a Jamilih object (or string).
1922
+ * @param {string|HTMLElement|Node|Entity} nde If a string, will parse as document
1923
+ * @param {ToJmlConfig} [config] Configuration object
1924
+ * @throws {TypeError}
1925
+ * @returns {JamilihType|string} Array containing the elements which represent
1926
+ * a Jamilih object, or, if `stringOutput` is true, it will be the stringified
1927
+ * version of such an object
1928
+ */
1929
+ const toJML = function (nde, {
1672
1930
  stringOutput = false,
1673
1931
  reportInvalidState = true,
1674
1932
  stripWhitespace = false
@@ -1679,12 +1937,11 @@ jml.toJML = function (nde, {
1679
1937
  if (typeof nde === 'string') {
1680
1938
  nde = new /** @type {import('jsdom').DOMWindow} */win.DOMParser().parseFromString(nde, 'text/html'); // todo: Give option for XML once implemented and change JSDoc to allow for Element
1681
1939
  }
1682
-
1683
1940
  const dom = /** @type {HTMLElement|Node|Entity} */nde;
1684
1941
 
1685
1942
  /**
1686
1943
  * @todo Find more specific type than `any`
1687
- * @typedef {{[key: (number|string)]: any}} IndexableObject
1944
+ * @typedef {{[key: (number|string)]: UserArg}} IndexableObject
1688
1945
  */
1689
1946
 
1690
1947
  const ret = /** @type {IndexableObject} */[];
@@ -1698,12 +1955,14 @@ jml.toJML = function (nde, {
1698
1955
  */
1699
1956
  function invalidStateError(msg) {
1700
1957
  // These are probably only necessary if working with text/html
1701
- if (reportInvalidState) {
1702
- // INVALID_STATE_ERR per section 9.3 XHTML 5: http://www.w3.org/TR/html5/the-xhtml-syntax.html
1703
- const e = new DOMException(msg, 'INVALID_STATE_ERR');
1704
- e.code = 11;
1705
- throw e;
1958
+ if (!reportInvalidState) {
1959
+ return;
1706
1960
  }
1961
+
1962
+ // INVALID_STATE_ERR per section 9.3 XHTML 5: https://www.w3.org/TR/html5/the-xhtml-syntax.html
1963
+ const e = new DOMException(msg, 'INVALID_STATE_ERR');
1964
+ e.code = 11;
1965
+ throw e;
1707
1966
  }
1708
1967
 
1709
1968
  /**
@@ -1790,8 +2049,13 @@ jml.toJML = function (nde, {
1790
2049
  namespaces = {
1791
2050
  ...namespaces
1792
2051
  };
1793
- const xmlChars = /^([\u0009\u000A\u000D\u0020-\uD7FF\uE000-\uFFFD]|[\uD800-\uDBFF][\uDC00-\uDFFF])*$/u; // eslint-disable-line no-control-regex
1794
- if ([2, 3, 4, 7, 8].includes(type) && /** @type {Node} */nodeOrEntity.nodeValue && !xmlChars.test( /** @type {Node} */nodeOrEntity.nodeValue)) {
2052
+ const xmlChars = /^([\u{9}\u{A}\u{D}\u{20}-\u{D7FF}\u{E000}-\u{FFFD}]|[\uD800-\uDBFF][\uDC00-\uDFFF])*$/u; // eslint-disable-line no-control-regex
2053
+
2054
+ // eslint-disable-next-line prefer-destructuring -- TS
2055
+ const nodeValue = /** @type {Node} */nodeOrEntity.nodeValue;
2056
+ if ([2, 3, 4, 7, 8].includes(type) &&
2057
+ // eslint-disable-next-line unicorn/prefer-simple-condition-first -- Safer
2058
+ nodeValue && !xmlChars.test(nodeValue)) {
1795
2059
  invalidStateError('Node has bad XML character value');
1796
2060
  }
1797
2061
 
@@ -1820,7 +2084,6 @@ jml.toJML = function (nde, {
1820
2084
  parentIdx = tmpParentIdx;
1821
2085
  parentIdx++; // Increment index in parent container of this element
1822
2086
  }
1823
-
1824
2087
  switch (type) {
1825
2088
  case 1:
1826
2089
  {
@@ -1896,6 +2159,7 @@ jml.toJML = function (nde, {
1896
2159
  {
1897
2160
  // CDATA
1898
2161
  const node = /** @type {CDATASection} */nodeOrEntity;
2162
+ // eslint-disable-next-line unicorn/no-useless-concat -- Safer if pasting
1899
2163
  if (node.nodeValue?.includes(']]' + '>')) {
1900
2164
  invalidStateError('CDATA cannot end with closing ]]>');
1901
2165
  }
@@ -1979,8 +2243,8 @@ jml.toJML = function (nde, {
1979
2243
  name: /** @type {DocumentType} */node.name
1980
2244
  }
1981
2245
  };
1982
- const pubIdChar = /^(\u0020|\u000D|\u000A|[a-zA-Z0-9]|[-'()+,./:=?;!*#@$_%])*$/u; // eslint-disable-line no-control-regex
1983
- if (!pubIdChar.test( /** @type {DocumentType} */node.publicId)) {
2246
+ const pubIdChar = /^(\u{20}|\u{D}|\u{A}|[a-zA-Z0-9]|[-'()+,./:=?;!*#@$_%])*$/u; // eslint-disable-line no-control-regex
2247
+ if (!pubIdChar.test(/** @type {DocumentType} */node.publicId)) {
1984
2248
  invalidStateError('A publicId must have valid characters.');
1985
2249
  }
1986
2250
  addExternalID(start.$DOCTYPE, node);
@@ -2021,36 +2285,37 @@ jml.toJML = function (nde, {
2021
2285
  }
2022
2286
  return ret[0];
2023
2287
  };
2288
+ jml.toJML = toJML;
2024
2289
 
2025
2290
  /**
2026
2291
  * @param {string|HTMLElement} dom
2027
2292
  * @param {ToJmlConfig} [config]
2028
2293
  * @returns {string}
2029
2294
  */
2030
- jml.toJMLString = function (dom, config) {
2031
- return (/** @type {string} */
2032
- jml.toJML(dom, Object.assign(config || {}, {
2033
- stringOutput: true
2034
- }))
2035
- );
2295
+ const toJMLString = function (dom, config) {
2296
+ return /** @type {string} */toJML(dom, Object.assign(config || {}, {
2297
+ stringOutput: true
2298
+ }));
2036
2299
  };
2300
+ jml.toJMLString = toJMLString;
2037
2301
 
2038
2302
  /**
2039
2303
  *
2040
2304
  * @param {JamilihArray} args
2041
2305
  * @returns {JamilihReturn}
2042
2306
  */
2043
- jml.toDOM = function (...args) {
2307
+ const toDOM = function (...args) {
2044
2308
  // Alias for jml()
2045
2309
  return jml(...args);
2046
2310
  };
2311
+ jml.toDOM = toDOM;
2047
2312
 
2048
2313
  /**
2049
2314
  *
2050
2315
  * @param {JamilihArray} args
2051
2316
  * @returns {string}
2052
2317
  */
2053
- jml.toHTML = function (...args) {
2318
+ const toHTML = function (...args) {
2054
2319
  // Todo: Replace this with version of jml() that directly builds a string
2055
2320
  const ret = jml(...args);
2056
2321
  switch (ret.nodeType) {
@@ -2060,33 +2325,34 @@ jml.toHTML = function (...args) {
2060
2325
  // Todo: deal with serialization of properties like 'selected',
2061
2326
  // 'checked', 'value', 'defaultValue', 'for', 'dataset', 'on*',
2062
2327
  // 'style'! (i.e., need to build a string ourselves)
2063
- return (/** @type {HTMLElement} */ret.outerHTML
2064
- );
2328
+ return /** @type {HTMLElement} */ret.outerHTML;
2065
2329
  }
2066
2330
  case 2:
2067
2331
  {
2068
2332
  // ATTR
2069
- return `${
2070
- /** @type {Attr} */ret.name}="${
2071
- /** @type {Attr} */ret.value.replace(/"/gu, '&quot;')}"`;
2333
+ return `${ /** @type {Attr} */ret.name}="${ /** @type {Attr} */ret.value.replaceAll('"', '&quot;')}"`;
2072
2334
  }
2073
2335
  case 3:
2074
2336
  {
2075
2337
  // TEXT
2076
2338
  // Fallthrough
2077
2339
  // } case 4: { // CDATA
2340
+ // eslint-disable-next-line prefer-destructuring -- TS
2341
+ const nodeValue = /** @type {Text|CDATASection} */ret.nodeValue;
2078
2342
  /* c8 ignore next 3 */
2079
- if (!ret.nodeValue) {
2343
+ if (!nodeValue) {
2080
2344
  throw new TypeError('Unexpected null Text node');
2081
2345
  }
2082
- return (/** @type {Text|CDATASection} */ret.nodeValue
2083
- );
2346
+ return nodeValue;
2084
2347
  // case 5: // Entity Reference Node
2085
2348
  // No 6: Entity Node
2086
2349
  // No 12: Notation Node
2087
- // } case 7: { // PROCESSING INSTRUCTION
2088
- // const node = /** @type {ProcessingInstruction} */ (ret);
2089
- // return `<?${node.target} ${node.data}?>`;
2350
+ }
2351
+ case 7:
2352
+ {
2353
+ // PROCESSING INSTRUCTION
2354
+ const node = /** @type {ProcessingInstruction} */ret;
2355
+ return `<?${node.target} ${node.data}?>`;
2090
2356
  // } case 8: { // Comment
2091
2357
  // return `<!--${ret.nodeValue}-->`;
2092
2358
  }
@@ -2096,7 +2362,7 @@ jml.toHTML = function (...args) {
2096
2362
  // DOCUMENT FRAGMENT
2097
2363
  const node = /** @type {DocumentFragment} */ret;
2098
2364
  return [...node.childNodes].map(childNode => {
2099
- return jml.toHTML( /** @type {JamilihFirstArgument} */childNode);
2365
+ return toHTML(/** @type {JamilihFirstArgument} */childNode);
2100
2366
  }).join('');
2101
2367
  }
2102
2368
  case 10:
@@ -2110,47 +2376,52 @@ jml.toHTML = function (...args) {
2110
2376
  throw new Error('Unexpected node type');
2111
2377
  }
2112
2378
  };
2379
+ jml.toHTML = toHTML;
2113
2380
 
2114
2381
  /**
2115
2382
  *
2116
2383
  * @param {JamilihArray} args
2117
2384
  * @returns {string}
2118
2385
  */
2119
- jml.toDOMString = function (...args) {
2386
+ const toDOMString = function (...args) {
2120
2387
  // Alias for jml.toHTML for parity with jml.toJMLString
2121
- return jml.toHTML(...args);
2388
+ return toHTML(...args);
2122
2389
  };
2390
+ jml.toDOMString = toDOMString;
2123
2391
 
2124
2392
  /**
2125
2393
  *
2126
2394
  * @param {JamilihArray} args
2127
2395
  * @returns {string}
2128
2396
  */
2129
- jml.toXML = function (...args) {
2397
+ const toXML = function (...args) {
2130
2398
  if (!win) {
2131
2399
  throw new Error('No window object set');
2132
2400
  }
2133
2401
  const ret = jml(...args);
2134
2402
  return new /** @type {import('jsdom').DOMWindow} */win.XMLSerializer().serializeToString(ret);
2135
2403
  };
2404
+ jml.toXML = toXML;
2136
2405
 
2137
2406
  /**
2138
2407
  *
2139
2408
  * @param {JamilihArray} args
2140
2409
  * @returns {string}
2141
2410
  */
2142
- jml.toXMLDOMString = function (...args) {
2411
+ const toXMLDOMString = function (...args) {
2143
2412
  // Alias for jml.toXML for parity with jml.toJMLString
2144
- return jml.toXML(...args);
2413
+ return toXML(...args);
2145
2414
  };
2415
+ jml.toXMLDOMString = toXMLDOMString;
2146
2416
 
2147
2417
  /**
2148
2418
  * Element-aware wrapper for `Map`.
2419
+ * @template V
2149
2420
  */
2150
2421
  class JamilihMap extends Map {
2151
2422
  /**
2152
2423
  * @param {?(string|HTMLElement)} element
2153
- * @returns {ArbitraryValue}
2424
+ * @returns {V}
2154
2425
  */
2155
2426
  get(element) {
2156
2427
  const elem = typeof element === 'string' ? $(element) : element;
@@ -2158,104 +2429,109 @@ class JamilihMap extends Map {
2158
2429
  }
2159
2430
  /**
2160
2431
  * @param {string|HTMLElement} element
2161
- * @param {ArbitraryValue} value
2162
- * @returns {ArbitraryValue}
2432
+ * @param {V} value
2433
+ * @returns {this}
2163
2434
  */
2164
2435
  set(element, value) {
2165
2436
  const elem = typeof element === 'string' ? $(element) : element;
2166
- return super.set.call(this, elem, value);
2437
+ super.set.call(this, elem, value);
2438
+ return this;
2167
2439
  }
2168
2440
  /**
2169
2441
  * @param {string|HTMLElement} element
2170
2442
  * @param {string} methodName
2171
- * @param {...ArbitraryValue} args
2172
- * @returns {ArbitraryValue}
2443
+ * @param {...UserArg} args
2444
+ * @returns {StoredValue}
2173
2445
  */
2174
2446
  invoke(element, methodName, ...args) {
2175
2447
  const elem = typeof element === 'string' ? $(element) : element;
2176
- return this.get(elem)[methodName](elem, ...args);
2448
+ return /** @type {UserArg} */this.get(elem)[methodName](elem, ...args);
2177
2449
  }
2178
2450
  }
2179
2451
 
2180
2452
  /**
2181
2453
  * Element-aware wrapper for `WeakMap`.
2182
- * @extends {WeakMap<any>}
2454
+ * @template V
2183
2455
  */
2184
2456
  class JamilihWeakMap extends WeakMap {
2185
2457
  /**
2186
- * @param {HTMLElement} element
2187
- * @returns {ArbitraryValue}
2458
+ * @param {?(string|object|symbol)} element
2459
+ * @returns {V}
2188
2460
  */
2189
2461
  get(element) {
2190
2462
  const elem = typeof element === 'string' ? $(element) : element;
2191
2463
  if (!elem) {
2192
2464
  throw new Error("Can't find the element");
2193
2465
  }
2194
- return super.get.call(this, elem);
2466
+ return super.get.call(this, /** @type {object} */elem);
2195
2467
  }
2196
2468
  /**
2197
- * @param {HTMLElement} element
2198
- * @param {ArbitraryValue} value
2199
- * @returns {ArbitraryValue}
2469
+ * @param {?(string|object|symbol)} element
2470
+ * @param {V} value
2471
+ * @returns {this}
2200
2472
  */
2201
2473
  set(element, value) {
2202
2474
  const elem = typeof element === 'string' ? $(element) : element;
2203
2475
  if (!elem) {
2204
2476
  throw new Error("Can't find the element");
2205
2477
  }
2206
- return super.set.call(this, elem, value);
2478
+ super.set.call(this, /** @type {object} */elem, value);
2479
+ return this;
2207
2480
  }
2208
2481
  /**
2209
2482
  * @param {string|HTMLElement} element
2210
2483
  * @param {string} methodName
2211
- * @param {...ArbitraryValue} args
2212
- * @returns {ArbitraryValue}
2484
+ * @param {...UserArg} args
2485
+ * @returns {StoredValue}
2213
2486
  */
2214
2487
  invoke(element, methodName, ...args) {
2215
2488
  const elem = typeof element === 'string' ? $(element) : element;
2216
2489
  if (!elem) {
2217
2490
  throw new Error("Can't find the element");
2218
2491
  }
2219
- return this.get(elem)[methodName](elem, ...args);
2492
+ return /** @type {UserArg} */this.get(elem)[methodName](elem, ...args);
2220
2493
  }
2221
2494
  }
2222
2495
  jml.Map = JamilihMap;
2223
2496
  jml.WeakMap = JamilihWeakMap;
2224
2497
 
2225
2498
  /**
2226
- * @typedef {[JamilihWeakMap|JamilihMap, HTMLElement]} MapAndElementArray
2499
+ * @template V
2500
+ * @typedef {[JamilihWeakMap<V>|JamilihMap<V>, HTMLElement]} MapAndElementArray
2227
2501
  */
2228
2502
 
2229
2503
  /**
2230
- * @param {{[key: string]: any}} obj
2504
+ * @template V
2505
+ * @param {V} obj
2231
2506
  * @param {JamilihArrayPostOptions} args
2232
- * @returns {MapAndElementArray}
2507
+ * @returns {MapAndElementArray<V>}
2233
2508
  */
2234
2509
  jml.weak = function (obj, ...args) {
2235
2510
  const map = new JamilihWeakMap();
2236
2511
  const elem = jml({
2237
2512
  $map: [map, obj]
2238
2513
  }, ...args);
2239
- return [map, /** @type {HTMLElement} */elem];
2514
+ return [map, (/** @type {HTMLElement} */elem)];
2240
2515
  };
2241
2516
 
2242
2517
  /**
2243
- * @param {ArbitraryValue} obj
2518
+ * @template V
2519
+ * @param {V} obj
2244
2520
  * @param {JamilihArrayPostOptions} args
2245
- * @returns {MapAndElementArray}
2521
+ * @returns {MapAndElementArray<V>}
2246
2522
  */
2247
2523
  jml.strong = function (obj, ...args) {
2248
2524
  const map = new JamilihMap();
2249
2525
  const elem = jml({
2250
2526
  $map: [map, obj]
2251
2527
  }, ...args);
2252
- return [map, /** @type {HTMLElement} */elem];
2528
+ return [map, (/** @type {HTMLElement} */elem)];
2253
2529
  };
2254
2530
 
2255
2531
  /**
2256
2532
  * @param {string|HTMLElement} element If a string, will be interpreted as a selector
2257
2533
  * @param {symbol|string} sym If a string, will be used with `Symbol.for`
2258
- * @returns {ArbitraryValue} The value associated with the symbol
2534
+ * @returns {SymbolResult} The value associated with the symbol
2259
2535
  */
2260
2536
  jml.symbol = jml.sym = jml.for = function (element, sym) {
2261
2537
  const elem = typeof element === 'string' ? $(element) : element;
@@ -2265,16 +2541,16 @@ jml.symbol = jml.sym = jml.for = function (element, sym) {
2265
2541
  };
2266
2542
 
2267
2543
  /**
2268
- * @typedef {((elem: HTMLElement, ...args: any[]) => void)|{[key: string]: (elem: HTMLElement, ...args: any[]) => void}} MapCommand
2544
+ * @typedef {((elem: HTMLElement, ...args: UserArg[]) => void)|{[key: string]: (elem: HTMLElement, ...args: UserArg[]) => void}} MapCommand
2269
2545
  */
2270
2546
 
2271
2547
  /**
2272
2548
  * @param {?(string|HTMLElement)} elem If a string, will be interpreted as a selector
2273
2549
  * @param {symbol|string|Map<HTMLElement, MapCommand>|WeakMap<HTMLElement, MapCommand>} symOrMap If a string, will be used with `Symbol.for`
2274
- * @param {string|any} methodName Can be `any` if the symbol or map directly
2550
+ * @param {string|UserArg} methodName Can be `UserArg` if the symbol or map directly
2275
2551
  * points to a function (it is then used as the first argument).
2276
- * @param {ArbitraryValue[]} args
2277
- * @returns {ArbitraryValue}
2552
+ * @param {UserArg[]} args
2553
+ * @returns {StoredValue}
2278
2554
  */
2279
2555
  jml.command = function (elem, symOrMap, methodName, ...args) {
2280
2556
  elem = typeof elem === 'string' ? $(elem) : elem;
@@ -2287,8 +2563,7 @@ jml.command = function (elem, symOrMap, methodName, ...args) {
2287
2563
  if (typeof func === 'function') {
2288
2564
  return func(methodName, ...args); // Already has `this` bound to `elem`
2289
2565
  }
2290
-
2291
- return func[methodName](...args);
2566
+ return /** @type {UserArg} */func[methodName](...args);
2292
2567
  }
2293
2568
  func = /** @type {Map<HTMLElement, MapCommand>|WeakMap<HTMLElement, MapCommand>} */symOrMap.get(elem);
2294
2569
  if (!func) {
@@ -2304,10 +2579,10 @@ jml.command = function (elem, symOrMap, methodName, ...args) {
2304
2579
  /**
2305
2580
  * Expects properties `document`, `XMLSerializer`, and `DOMParser`.
2306
2581
  * Also updates `body` with `document.body`.
2307
- * @param {import('jsdom').DOMWindow|HTMLWindow|undefined} wind
2582
+ * @param {import('jsdom').DOMWindow|HTMLWindow|typeof globalThis|undefined} wind
2308
2583
  * @returns {void}
2309
2584
  */
2310
- jml.setWindow = wind => {
2585
+ const setWindow = wind => {
2311
2586
  win = wind;
2312
2587
  doc = win?.document;
2313
2588
  if (doc && doc.body) {
@@ -2315,40 +2590,43 @@ jml.setWindow = wind => {
2315
2590
  body = /** @type {HTMLBodyElement} */doc.body;
2316
2591
  }
2317
2592
  };
2593
+ jml.setWindow = setWindow;
2318
2594
 
2319
2595
  /**
2320
- * @returns {import('jsdom').DOMWindow|HTMLWindow}
2596
+ * @returns {import('jsdom').DOMWindow|HTMLWindow|typeof globalThis}
2321
2597
  */
2322
- jml.getWindow = () => {
2598
+ const getWindow = () => {
2323
2599
  if (!win) {
2324
2600
  throw new Error('No window object set');
2325
2601
  }
2326
2602
  return win;
2327
2603
  };
2604
+ jml.getWindow = getWindow;
2328
2605
 
2329
2606
  /**
2330
2607
  * Does not run Jamilih so can be further processed.
2331
- * @param {ArbitraryValue[]} array
2332
- * @param {ArbitraryValue} glu
2333
- * @returns {ArbitraryValue[]}
2608
+ * @template T
2609
+ * @param {T[]} array
2610
+ * @param {T} glu
2611
+ * @returns {T[]}
2334
2612
  */
2335
2613
  function glue(array, glu) {
2336
2614
  return [...array].reduce((arr, item) => {
2337
2615
  arr.push(item, glu);
2338
2616
  return arr;
2339
- }, []).slice(0, -1);
2617
+ }, /** @type {T[]} */[]).slice(0, -1);
2340
2618
  }
2341
2619
 
2342
2620
  /**
2343
2621
  * @type {HTMLBodyElement}
2344
2622
  */
2345
- let body; // eslint-disable-line import/no-mutable-exports
2623
+ let body; // // eslint-disable-line import/no-mutable-exports
2346
2624
 
2347
2625
  /* c8 ignore next 4 */
2348
2626
  if (doc && doc.body) {
2349
2627
  // eslint-disable-next-line prefer-destructuring -- Needed for type
2350
2628
  body = /** @type {HTMLBodyElement} */doc.body;
2351
2629
  }
2352
- const nbsp = '\u00A0'; // Very commonly needed in templates
2630
+ const nbsp = '\u{A0}'; // Very commonly needed in templates
2353
2631
 
2354
- export { $, $$, DOMException, body, jml as default, glue, jml, nbsp };
2632
+ export { $, $$, DOMException, body, getWindow, glue, jml, nbsp, setWindow, toDOM, toDOMString, toHTML, toJML, toJMLString, toXML, toXMLDOMString };