@mionjs/run-types 0.8.7 → 0.8.10

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 (396) hide show
  1. package/.dist/cjs/index.d.ts +1 -0
  2. package/.dist/cjs/index.d.ts.map +1 -0
  3. package/.dist/cjs/src/constants.d.ts +1 -0
  4. package/.dist/cjs/src/constants.d.ts.map +1 -0
  5. package/.dist/cjs/src/constants.functions.d.ts +1 -0
  6. package/.dist/cjs/src/constants.functions.d.ts.map +1 -0
  7. package/.dist/cjs/src/constants.kind.d.ts +1 -0
  8. package/.dist/cjs/src/constants.kind.d.ts.map +1 -0
  9. package/.dist/cjs/src/createRunType.cjs +3 -1
  10. package/.dist/cjs/src/createRunType.cjs.map +1 -1
  11. package/.dist/cjs/src/createRunType.d.ts +1 -0
  12. package/.dist/cjs/src/createRunType.d.ts.map +1 -0
  13. package/.dist/cjs/src/createRunTypeFunctions.d.ts +1 -0
  14. package/.dist/cjs/src/createRunTypeFunctions.d.ts.map +1 -0
  15. package/.dist/cjs/src/formats.runtype.d.ts +1 -0
  16. package/.dist/cjs/src/formats.runtype.d.ts.map +1 -0
  17. package/.dist/cjs/src/jitCompilers/binary/binarySpec/binaryHelpers.d.ts +1 -0
  18. package/.dist/cjs/src/jitCompilers/binary/binarySpec/binaryHelpers.d.ts.map +1 -0
  19. package/.dist/cjs/src/jitCompilers/binary/fromBinary.cjs +1 -1
  20. package/.dist/cjs/src/jitCompilers/binary/fromBinary.cjs.map +1 -1
  21. package/.dist/cjs/src/jitCompilers/binary/fromBinary.d.ts +1 -0
  22. package/.dist/cjs/src/jitCompilers/binary/fromBinary.d.ts.map +1 -0
  23. package/.dist/cjs/src/jitCompilers/binary/toBinary.cjs +1 -1
  24. package/.dist/cjs/src/jitCompilers/binary/toBinary.cjs.map +1 -1
  25. package/.dist/cjs/src/jitCompilers/binary/toBinary.d.ts +1 -0
  26. package/.dist/cjs/src/jitCompilers/binary/toBinary.d.ts.map +1 -0
  27. package/.dist/cjs/src/jitCompilers/equalsHelpers.d.ts +1 -0
  28. package/.dist/cjs/src/jitCompilers/equalsHelpers.d.ts.map +1 -0
  29. package/.dist/cjs/src/jitCompilers/json/jsonSpec/jsonHelpers.d.ts +1 -0
  30. package/.dist/cjs/src/jitCompilers/json/jsonSpec/jsonHelpers.d.ts.map +1 -0
  31. package/.dist/cjs/src/jitCompilers/json/stringifyJson.cjs +1 -1
  32. package/.dist/cjs/src/jitCompilers/json/stringifyJson.cjs.map +1 -1
  33. package/.dist/cjs/src/jitCompilers/json/stringifyJson.d.ts +1 -0
  34. package/.dist/cjs/src/jitCompilers/json/stringifyJson.d.ts.map +1 -0
  35. package/.dist/cjs/src/jitCompilers/json/stringifySpec/stringifyHelpers.d.ts +1 -0
  36. package/.dist/cjs/src/jitCompilers/json/stringifySpec/stringifyHelpers.d.ts.map +1 -0
  37. package/.dist/cjs/src/jitCompilers/json/toJsCode.d.ts +1 -0
  38. package/.dist/cjs/src/jitCompilers/json/toJsCode.d.ts.map +1 -0
  39. package/.dist/cjs/src/lib/baseRunTypeFormat.d.ts +1 -0
  40. package/.dist/cjs/src/lib/baseRunTypeFormat.d.ts.map +1 -0
  41. package/.dist/cjs/src/lib/baseRunTypes.d.ts +1 -0
  42. package/.dist/cjs/src/lib/baseRunTypes.d.ts.map +1 -0
  43. package/.dist/cjs/src/lib/createJitFunction.d.ts +1 -0
  44. package/.dist/cjs/src/lib/createJitFunction.d.ts.map +1 -0
  45. package/.dist/cjs/src/lib/dkProxy.d.ts +1 -0
  46. package/.dist/cjs/src/lib/dkProxy.d.ts.map +1 -0
  47. package/.dist/cjs/src/lib/formats.d.ts +1 -0
  48. package/.dist/cjs/src/lib/formats.d.ts.map +1 -0
  49. package/.dist/cjs/src/lib/guards.d.ts +1 -0
  50. package/.dist/cjs/src/lib/guards.d.ts.map +1 -0
  51. package/.dist/cjs/src/lib/jitFnCompiler.d.ts +1 -0
  52. package/.dist/cjs/src/lib/jitFnCompiler.d.ts.map +1 -0
  53. package/.dist/cjs/src/lib/jitFnsRegistry.d.ts +1 -0
  54. package/.dist/cjs/src/lib/jitFnsRegistry.d.ts.map +1 -0
  55. package/.dist/cjs/src/lib/typeId.d.ts +1 -0
  56. package/.dist/cjs/src/lib/typeId.d.ts.map +1 -0
  57. package/.dist/cjs/src/lib/utils.d.ts +1 -0
  58. package/.dist/cjs/src/lib/utils.d.ts.map +1 -0
  59. package/.dist/cjs/src/mocking/constants.mock.d.ts +1 -0
  60. package/.dist/cjs/src/mocking/constants.mock.d.ts.map +1 -0
  61. package/.dist/cjs/src/mocking/mockRegistry.d.ts +1 -0
  62. package/.dist/cjs/src/mocking/mockRegistry.d.ts.map +1 -0
  63. package/.dist/cjs/src/mocking/mockType.cjs +46 -1
  64. package/.dist/cjs/src/mocking/mockType.cjs.map +1 -1
  65. package/.dist/cjs/src/mocking/mockType.d.ts +1 -0
  66. package/.dist/cjs/src/mocking/mockType.d.ts.map +1 -0
  67. package/.dist/cjs/src/mocking/mockUtils.d.ts +1 -0
  68. package/.dist/cjs/src/mocking/mockUtils.d.ts.map +1 -0
  69. package/.dist/cjs/src/nodes/atomic/any.d.ts +1 -0
  70. package/.dist/cjs/src/nodes/atomic/any.d.ts.map +1 -0
  71. package/.dist/cjs/src/nodes/atomic/bigInt.d.ts +1 -0
  72. package/.dist/cjs/src/nodes/atomic/bigInt.d.ts.map +1 -0
  73. package/.dist/cjs/src/nodes/atomic/boolean.d.ts +1 -0
  74. package/.dist/cjs/src/nodes/atomic/boolean.d.ts.map +1 -0
  75. package/.dist/cjs/src/nodes/atomic/date.d.ts +1 -0
  76. package/.dist/cjs/src/nodes/atomic/date.d.ts.map +1 -0
  77. package/.dist/cjs/src/nodes/atomic/enum.d.ts +1 -0
  78. package/.dist/cjs/src/nodes/atomic/enum.d.ts.map +1 -0
  79. package/.dist/cjs/src/nodes/atomic/enumMember.d.ts +1 -0
  80. package/.dist/cjs/src/nodes/atomic/enumMember.d.ts.map +1 -0
  81. package/.dist/cjs/src/nodes/atomic/literal.d.ts +1 -0
  82. package/.dist/cjs/src/nodes/atomic/literal.d.ts.map +1 -0
  83. package/.dist/cjs/src/nodes/atomic/never.d.ts +1 -0
  84. package/.dist/cjs/src/nodes/atomic/never.d.ts.map +1 -0
  85. package/.dist/cjs/src/nodes/atomic/null.d.ts +1 -0
  86. package/.dist/cjs/src/nodes/atomic/null.d.ts.map +1 -0
  87. package/.dist/cjs/src/nodes/atomic/number.d.ts +1 -0
  88. package/.dist/cjs/src/nodes/atomic/number.d.ts.map +1 -0
  89. package/.dist/cjs/src/nodes/atomic/object.d.ts +1 -0
  90. package/.dist/cjs/src/nodes/atomic/object.d.ts.map +1 -0
  91. package/.dist/cjs/src/nodes/atomic/regexp.d.ts +1 -0
  92. package/.dist/cjs/src/nodes/atomic/regexp.d.ts.map +1 -0
  93. package/.dist/cjs/src/nodes/atomic/string.d.ts +1 -0
  94. package/.dist/cjs/src/nodes/atomic/string.d.ts.map +1 -0
  95. package/.dist/cjs/src/nodes/atomic/symbol.d.ts +1 -0
  96. package/.dist/cjs/src/nodes/atomic/symbol.d.ts.map +1 -0
  97. package/.dist/cjs/src/nodes/atomic/undefined.d.ts +1 -0
  98. package/.dist/cjs/src/nodes/atomic/undefined.d.ts.map +1 -0
  99. package/.dist/cjs/src/nodes/atomic/unknown.d.ts +1 -0
  100. package/.dist/cjs/src/nodes/atomic/unknown.d.ts.map +1 -0
  101. package/.dist/cjs/src/nodes/atomic/void.d.ts +1 -0
  102. package/.dist/cjs/src/nodes/atomic/void.d.ts.map +1 -0
  103. package/.dist/cjs/src/nodes/collection/class.d.ts +1 -0
  104. package/.dist/cjs/src/nodes/collection/class.d.ts.map +1 -0
  105. package/.dist/cjs/src/nodes/collection/functionParams.d.ts +1 -0
  106. package/.dist/cjs/src/nodes/collection/functionParams.d.ts.map +1 -0
  107. package/.dist/cjs/src/nodes/collection/interface.d.ts +1 -0
  108. package/.dist/cjs/src/nodes/collection/interface.d.ts.map +1 -0
  109. package/.dist/cjs/src/nodes/collection/intersection.d.ts +1 -0
  110. package/.dist/cjs/src/nodes/collection/intersection.d.ts.map +1 -0
  111. package/.dist/cjs/src/nodes/collection/templateLiteral.cjs +73 -0
  112. package/.dist/cjs/src/nodes/collection/templateLiteral.cjs.map +1 -0
  113. package/.dist/cjs/src/nodes/collection/templateLiteral.d.ts +16 -0
  114. package/.dist/cjs/src/nodes/collection/templateLiteral.d.ts.map +1 -0
  115. package/.dist/cjs/src/nodes/collection/tuple.d.ts +1 -0
  116. package/.dist/cjs/src/nodes/collection/tuple.d.ts.map +1 -0
  117. package/.dist/cjs/src/nodes/collection/union.d.ts +1 -0
  118. package/.dist/cjs/src/nodes/collection/union.d.ts.map +1 -0
  119. package/.dist/cjs/src/nodes/collection/unionDiscriminator.d.ts +1 -0
  120. package/.dist/cjs/src/nodes/collection/unionDiscriminator.d.ts.map +1 -0
  121. package/.dist/cjs/src/nodes/function/function.d.ts +1 -0
  122. package/.dist/cjs/src/nodes/function/function.d.ts.map +1 -0
  123. package/.dist/cjs/src/nodes/member/array.d.ts +1 -0
  124. package/.dist/cjs/src/nodes/member/array.d.ts.map +1 -0
  125. package/.dist/cjs/src/nodes/member/callSignature.d.ts +1 -0
  126. package/.dist/cjs/src/nodes/member/callSignature.d.ts.map +1 -0
  127. package/.dist/cjs/src/nodes/member/genericMember.d.ts +1 -0
  128. package/.dist/cjs/src/nodes/member/genericMember.d.ts.map +1 -0
  129. package/.dist/cjs/src/nodes/member/indexProperty.cjs +69 -22
  130. package/.dist/cjs/src/nodes/member/indexProperty.cjs.map +1 -1
  131. package/.dist/cjs/src/nodes/member/indexProperty.d.ts +2 -0
  132. package/.dist/cjs/src/nodes/member/indexProperty.d.ts.map +1 -0
  133. package/.dist/cjs/src/nodes/member/method.d.ts +1 -0
  134. package/.dist/cjs/src/nodes/member/method.d.ts.map +1 -0
  135. package/.dist/cjs/src/nodes/member/methodSignature.d.ts +1 -0
  136. package/.dist/cjs/src/nodes/member/methodSignature.d.ts.map +1 -0
  137. package/.dist/cjs/src/nodes/member/param.d.ts +1 -0
  138. package/.dist/cjs/src/nodes/member/param.d.ts.map +1 -0
  139. package/.dist/cjs/src/nodes/member/property.d.ts +1 -0
  140. package/.dist/cjs/src/nodes/member/property.d.ts.map +1 -0
  141. package/.dist/cjs/src/nodes/member/restParams.d.ts +1 -0
  142. package/.dist/cjs/src/nodes/member/restParams.d.ts.map +1 -0
  143. package/.dist/cjs/src/nodes/member/tupleMember.d.ts +1 -0
  144. package/.dist/cjs/src/nodes/member/tupleMember.d.ts.map +1 -0
  145. package/.dist/cjs/src/nodes/native/Iterable.d.ts +1 -0
  146. package/.dist/cjs/src/nodes/native/Iterable.d.ts.map +1 -0
  147. package/.dist/cjs/src/nodes/native/map.d.ts +1 -0
  148. package/.dist/cjs/src/nodes/native/map.d.ts.map +1 -0
  149. package/.dist/cjs/src/nodes/native/nonSerializable.d.ts +1 -0
  150. package/.dist/cjs/src/nodes/native/nonSerializable.d.ts.map +1 -0
  151. package/.dist/cjs/src/nodes/native/promise.d.ts +1 -0
  152. package/.dist/cjs/src/nodes/native/promise.d.ts.map +1 -0
  153. package/.dist/cjs/src/nodes/native/set.d.ts +1 -0
  154. package/.dist/cjs/src/nodes/native/set.d.ts.map +1 -0
  155. package/.dist/cjs/src/run-types-pure-fns.d.ts +1 -0
  156. package/.dist/cjs/src/run-types-pure-fns.d.ts.map +1 -0
  157. package/.dist/cjs/src/types.d.ts +1 -0
  158. package/.dist/cjs/src/types.d.ts.map +1 -0
  159. package/.dist/esm/index.d.ts +1 -0
  160. package/.dist/esm/index.d.ts.map +1 -0
  161. package/.dist/esm/src/constants.d.ts +1 -0
  162. package/.dist/esm/src/constants.d.ts.map +1 -0
  163. package/.dist/esm/src/constants.functions.d.ts +1 -0
  164. package/.dist/esm/src/constants.functions.d.ts.map +1 -0
  165. package/.dist/esm/src/constants.kind.d.ts +1 -0
  166. package/.dist/esm/src/constants.kind.d.ts.map +1 -0
  167. package/.dist/esm/src/createRunType.d.ts +1 -0
  168. package/.dist/esm/src/createRunType.d.ts.map +1 -0
  169. package/.dist/esm/src/createRunType.js +3 -1
  170. package/.dist/esm/src/createRunType.js.map +1 -1
  171. package/.dist/esm/src/createRunTypeFunctions.d.ts +1 -0
  172. package/.dist/esm/src/createRunTypeFunctions.d.ts.map +1 -0
  173. package/.dist/esm/src/formats.runtype.d.ts +1 -0
  174. package/.dist/esm/src/formats.runtype.d.ts.map +1 -0
  175. package/.dist/esm/src/jitCompilers/binary/binarySpec/binaryHelpers.d.ts +1 -0
  176. package/.dist/esm/src/jitCompilers/binary/binarySpec/binaryHelpers.d.ts.map +1 -0
  177. package/.dist/esm/src/jitCompilers/binary/fromBinary.d.ts +1 -0
  178. package/.dist/esm/src/jitCompilers/binary/fromBinary.d.ts.map +1 -0
  179. package/.dist/esm/src/jitCompilers/binary/fromBinary.js +1 -1
  180. package/.dist/esm/src/jitCompilers/binary/fromBinary.js.map +1 -1
  181. package/.dist/esm/src/jitCompilers/binary/toBinary.d.ts +1 -0
  182. package/.dist/esm/src/jitCompilers/binary/toBinary.d.ts.map +1 -0
  183. package/.dist/esm/src/jitCompilers/binary/toBinary.js +1 -1
  184. package/.dist/esm/src/jitCompilers/binary/toBinary.js.map +1 -1
  185. package/.dist/esm/src/jitCompilers/equalsHelpers.d.ts +1 -0
  186. package/.dist/esm/src/jitCompilers/equalsHelpers.d.ts.map +1 -0
  187. package/.dist/esm/src/jitCompilers/json/jsonSpec/jsonHelpers.d.ts +1 -0
  188. package/.dist/esm/src/jitCompilers/json/jsonSpec/jsonHelpers.d.ts.map +1 -0
  189. package/.dist/esm/src/jitCompilers/json/stringifyJson.d.ts +1 -0
  190. package/.dist/esm/src/jitCompilers/json/stringifyJson.d.ts.map +1 -0
  191. package/.dist/esm/src/jitCompilers/json/stringifyJson.js +1 -1
  192. package/.dist/esm/src/jitCompilers/json/stringifyJson.js.map +1 -1
  193. package/.dist/esm/src/jitCompilers/json/stringifySpec/stringifyHelpers.d.ts +1 -0
  194. package/.dist/esm/src/jitCompilers/json/stringifySpec/stringifyHelpers.d.ts.map +1 -0
  195. package/.dist/esm/src/jitCompilers/json/toJsCode.d.ts +1 -0
  196. package/.dist/esm/src/jitCompilers/json/toJsCode.d.ts.map +1 -0
  197. package/.dist/esm/src/lib/baseRunTypeFormat.d.ts +1 -0
  198. package/.dist/esm/src/lib/baseRunTypeFormat.d.ts.map +1 -0
  199. package/.dist/esm/src/lib/baseRunTypes.d.ts +1 -0
  200. package/.dist/esm/src/lib/baseRunTypes.d.ts.map +1 -0
  201. package/.dist/esm/src/lib/createJitFunction.d.ts +1 -0
  202. package/.dist/esm/src/lib/createJitFunction.d.ts.map +1 -0
  203. package/.dist/esm/src/lib/dkProxy.d.ts +1 -0
  204. package/.dist/esm/src/lib/dkProxy.d.ts.map +1 -0
  205. package/.dist/esm/src/lib/formats.d.ts +1 -0
  206. package/.dist/esm/src/lib/formats.d.ts.map +1 -0
  207. package/.dist/esm/src/lib/guards.d.ts +1 -0
  208. package/.dist/esm/src/lib/guards.d.ts.map +1 -0
  209. package/.dist/esm/src/lib/jitFnCompiler.d.ts +1 -0
  210. package/.dist/esm/src/lib/jitFnCompiler.d.ts.map +1 -0
  211. package/.dist/esm/src/lib/jitFnsRegistry.d.ts +1 -0
  212. package/.dist/esm/src/lib/jitFnsRegistry.d.ts.map +1 -0
  213. package/.dist/esm/src/lib/typeId.d.ts +1 -0
  214. package/.dist/esm/src/lib/typeId.d.ts.map +1 -0
  215. package/.dist/esm/src/lib/utils.d.ts +1 -0
  216. package/.dist/esm/src/lib/utils.d.ts.map +1 -0
  217. package/.dist/esm/src/mocking/constants.mock.d.ts +1 -0
  218. package/.dist/esm/src/mocking/constants.mock.d.ts.map +1 -0
  219. package/.dist/esm/src/mocking/mockRegistry.d.ts +1 -0
  220. package/.dist/esm/src/mocking/mockRegistry.d.ts.map +1 -0
  221. package/.dist/esm/src/mocking/mockType.d.ts +1 -0
  222. package/.dist/esm/src/mocking/mockType.d.ts.map +1 -0
  223. package/.dist/esm/src/mocking/mockType.js +47 -2
  224. package/.dist/esm/src/mocking/mockType.js.map +1 -1
  225. package/.dist/esm/src/mocking/mockUtils.d.ts +1 -0
  226. package/.dist/esm/src/mocking/mockUtils.d.ts.map +1 -0
  227. package/.dist/esm/src/mocking/mockUtils.js +1 -1
  228. package/.dist/esm/src/nodes/atomic/any.d.ts +1 -0
  229. package/.dist/esm/src/nodes/atomic/any.d.ts.map +1 -0
  230. package/.dist/esm/src/nodes/atomic/bigInt.d.ts +1 -0
  231. package/.dist/esm/src/nodes/atomic/bigInt.d.ts.map +1 -0
  232. package/.dist/esm/src/nodes/atomic/boolean.d.ts +1 -0
  233. package/.dist/esm/src/nodes/atomic/boolean.d.ts.map +1 -0
  234. package/.dist/esm/src/nodes/atomic/date.d.ts +1 -0
  235. package/.dist/esm/src/nodes/atomic/date.d.ts.map +1 -0
  236. package/.dist/esm/src/nodes/atomic/enum.d.ts +1 -0
  237. package/.dist/esm/src/nodes/atomic/enum.d.ts.map +1 -0
  238. package/.dist/esm/src/nodes/atomic/enumMember.d.ts +1 -0
  239. package/.dist/esm/src/nodes/atomic/enumMember.d.ts.map +1 -0
  240. package/.dist/esm/src/nodes/atomic/literal.d.ts +1 -0
  241. package/.dist/esm/src/nodes/atomic/literal.d.ts.map +1 -0
  242. package/.dist/esm/src/nodes/atomic/never.d.ts +1 -0
  243. package/.dist/esm/src/nodes/atomic/never.d.ts.map +1 -0
  244. package/.dist/esm/src/nodes/atomic/null.d.ts +1 -0
  245. package/.dist/esm/src/nodes/atomic/null.d.ts.map +1 -0
  246. package/.dist/esm/src/nodes/atomic/number.d.ts +1 -0
  247. package/.dist/esm/src/nodes/atomic/number.d.ts.map +1 -0
  248. package/.dist/esm/src/nodes/atomic/object.d.ts +1 -0
  249. package/.dist/esm/src/nodes/atomic/object.d.ts.map +1 -0
  250. package/.dist/esm/src/nodes/atomic/regexp.d.ts +1 -0
  251. package/.dist/esm/src/nodes/atomic/regexp.d.ts.map +1 -0
  252. package/.dist/esm/src/nodes/atomic/string.d.ts +1 -0
  253. package/.dist/esm/src/nodes/atomic/string.d.ts.map +1 -0
  254. package/.dist/esm/src/nodes/atomic/symbol.d.ts +1 -0
  255. package/.dist/esm/src/nodes/atomic/symbol.d.ts.map +1 -0
  256. package/.dist/esm/src/nodes/atomic/undefined.d.ts +1 -0
  257. package/.dist/esm/src/nodes/atomic/undefined.d.ts.map +1 -0
  258. package/.dist/esm/src/nodes/atomic/unknown.d.ts +1 -0
  259. package/.dist/esm/src/nodes/atomic/unknown.d.ts.map +1 -0
  260. package/.dist/esm/src/nodes/atomic/void.d.ts +1 -0
  261. package/.dist/esm/src/nodes/atomic/void.d.ts.map +1 -0
  262. package/.dist/esm/src/nodes/collection/class.d.ts +1 -0
  263. package/.dist/esm/src/nodes/collection/class.d.ts.map +1 -0
  264. package/.dist/esm/src/nodes/collection/functionParams.d.ts +1 -0
  265. package/.dist/esm/src/nodes/collection/functionParams.d.ts.map +1 -0
  266. package/.dist/esm/src/nodes/collection/interface.d.ts +1 -0
  267. package/.dist/esm/src/nodes/collection/interface.d.ts.map +1 -0
  268. package/.dist/esm/src/nodes/collection/intersection.d.ts +1 -0
  269. package/.dist/esm/src/nodes/collection/intersection.d.ts.map +1 -0
  270. package/.dist/esm/src/nodes/collection/templateLiteral.d.ts +16 -0
  271. package/.dist/esm/src/nodes/collection/templateLiteral.d.ts.map +1 -0
  272. package/.dist/esm/src/nodes/collection/templateLiteral.js +73 -0
  273. package/.dist/esm/src/nodes/collection/templateLiteral.js.map +1 -0
  274. package/.dist/esm/src/nodes/collection/tuple.d.ts +1 -0
  275. package/.dist/esm/src/nodes/collection/tuple.d.ts.map +1 -0
  276. package/.dist/esm/src/nodes/collection/union.d.ts +1 -0
  277. package/.dist/esm/src/nodes/collection/union.d.ts.map +1 -0
  278. package/.dist/esm/src/nodes/collection/unionDiscriminator.d.ts +1 -0
  279. package/.dist/esm/src/nodes/collection/unionDiscriminator.d.ts.map +1 -0
  280. package/.dist/esm/src/nodes/function/function.d.ts +1 -0
  281. package/.dist/esm/src/nodes/function/function.d.ts.map +1 -0
  282. package/.dist/esm/src/nodes/member/array.d.ts +1 -0
  283. package/.dist/esm/src/nodes/member/array.d.ts.map +1 -0
  284. package/.dist/esm/src/nodes/member/callSignature.d.ts +1 -0
  285. package/.dist/esm/src/nodes/member/callSignature.d.ts.map +1 -0
  286. package/.dist/esm/src/nodes/member/genericMember.d.ts +1 -0
  287. package/.dist/esm/src/nodes/member/genericMember.d.ts.map +1 -0
  288. package/.dist/esm/src/nodes/member/indexProperty.d.ts +2 -0
  289. package/.dist/esm/src/nodes/member/indexProperty.d.ts.map +1 -0
  290. package/.dist/esm/src/nodes/member/indexProperty.js +70 -23
  291. package/.dist/esm/src/nodes/member/indexProperty.js.map +1 -1
  292. package/.dist/esm/src/nodes/member/method.d.ts +1 -0
  293. package/.dist/esm/src/nodes/member/method.d.ts.map +1 -0
  294. package/.dist/esm/src/nodes/member/methodSignature.d.ts +1 -0
  295. package/.dist/esm/src/nodes/member/methodSignature.d.ts.map +1 -0
  296. package/.dist/esm/src/nodes/member/param.d.ts +1 -0
  297. package/.dist/esm/src/nodes/member/param.d.ts.map +1 -0
  298. package/.dist/esm/src/nodes/member/property.d.ts +1 -0
  299. package/.dist/esm/src/nodes/member/property.d.ts.map +1 -0
  300. package/.dist/esm/src/nodes/member/restParams.d.ts +1 -0
  301. package/.dist/esm/src/nodes/member/restParams.d.ts.map +1 -0
  302. package/.dist/esm/src/nodes/member/tupleMember.d.ts +1 -0
  303. package/.dist/esm/src/nodes/member/tupleMember.d.ts.map +1 -0
  304. package/.dist/esm/src/nodes/native/Iterable.d.ts +1 -0
  305. package/.dist/esm/src/nodes/native/Iterable.d.ts.map +1 -0
  306. package/.dist/esm/src/nodes/native/map.d.ts +1 -0
  307. package/.dist/esm/src/nodes/native/map.d.ts.map +1 -0
  308. package/.dist/esm/src/nodes/native/nonSerializable.d.ts +1 -0
  309. package/.dist/esm/src/nodes/native/nonSerializable.d.ts.map +1 -0
  310. package/.dist/esm/src/nodes/native/promise.d.ts +1 -0
  311. package/.dist/esm/src/nodes/native/promise.d.ts.map +1 -0
  312. package/.dist/esm/src/nodes/native/set.d.ts +1 -0
  313. package/.dist/esm/src/nodes/native/set.d.ts.map +1 -0
  314. package/.dist/esm/src/run-types-pure-fns.d.ts +1 -0
  315. package/.dist/esm/src/run-types-pure-fns.d.ts.map +1 -0
  316. package/.dist/esm/src/types.d.ts +1 -0
  317. package/.dist/esm/src/types.d.ts.map +1 -0
  318. package/index.ts +70 -0
  319. package/package.json +8 -4
  320. package/src/constants.functions.ts +196 -0
  321. package/src/constants.kind.ts +76 -0
  322. package/src/constants.ts +85 -0
  323. package/src/createRunType.ts +322 -0
  324. package/src/createRunTypeFunctions.ts +93 -0
  325. package/src/formats.runtype.ts +35 -0
  326. package/src/jitCompilers/binary/binarySPEC.md +138 -0
  327. package/src/jitCompilers/binary/binarySpec/binaryHelpers.ts +118 -0
  328. package/src/jitCompilers/binary/fromBinary.ts +493 -0
  329. package/src/jitCompilers/binary/toBinary.ts +436 -0
  330. package/src/jitCompilers/equalsHelpers.ts +62 -0
  331. package/src/jitCompilers/json/jsonSpec/jsonHelpers.ts +64 -0
  332. package/src/jitCompilers/json/stringifyJson.ts +476 -0
  333. package/src/jitCompilers/json/stringifySpec/stringifyHelpers.ts +59 -0
  334. package/src/jitCompilers/json/toJsCode.ts +182 -0
  335. package/src/jitCompilers/serialization-suite.ts +1689 -0
  336. package/src/jitCompilers/xyz-Template/fromXYZ.ts +212 -0
  337. package/src/jitCompilers/xyz-Template/toXYZ.ts +217 -0
  338. package/src/jitCompilers/xyz-Template/xyzReadme.md +6 -0
  339. package/src/jitCompilers/xyz-Template/xyzSpec/xyzHelpers.ts +66 -0
  340. package/src/lib/baseRunTypeFormat.ts +320 -0
  341. package/src/lib/baseRunTypes.ts +367 -0
  342. package/src/lib/createJitFunction.ts +87 -0
  343. package/src/lib/dkProxy.ts +47 -0
  344. package/src/lib/formats.ts +144 -0
  345. package/src/lib/guards.ts +290 -0
  346. package/src/lib/jitFnCompiler.ts +783 -0
  347. package/src/lib/jitFnsRegistry.ts +53 -0
  348. package/src/lib/typeId.ts +225 -0
  349. package/src/lib/utils.ts +402 -0
  350. package/src/mocking/constants.mock.ts +87 -0
  351. package/src/mocking/mockRegistry.ts +20 -0
  352. package/src/mocking/mockType.ts +409 -0
  353. package/src/mocking/mockUtils.ts +82 -0
  354. package/src/nodes/atomic/any.ts +22 -0
  355. package/src/nodes/atomic/bigInt.ts +26 -0
  356. package/src/nodes/atomic/boolean.ts +26 -0
  357. package/src/nodes/atomic/date.ts +26 -0
  358. package/src/nodes/atomic/enum.ts +23 -0
  359. package/src/nodes/atomic/enumMember.ts +29 -0
  360. package/src/nodes/atomic/literal.ts +125 -0
  361. package/src/nodes/atomic/never.ts +26 -0
  362. package/src/nodes/atomic/null.ts +26 -0
  363. package/src/nodes/atomic/number.ts +26 -0
  364. package/src/nodes/atomic/object.ts +20 -0
  365. package/src/nodes/atomic/regexp.ts +29 -0
  366. package/src/nodes/atomic/string.ts +20 -0
  367. package/src/nodes/atomic/symbol.ts +31 -0
  368. package/src/nodes/atomic/undefined.ts +23 -0
  369. package/src/nodes/atomic/unknown.ts +10 -0
  370. package/src/nodes/atomic/void.ts +26 -0
  371. package/src/nodes/collection/class.ts +36 -0
  372. package/src/nodes/collection/functionParams.ts +42 -0
  373. package/src/nodes/collection/interface.ts +300 -0
  374. package/src/nodes/collection/intersection.ts +30 -0
  375. package/src/nodes/collection/templateLiteral.ts +87 -0
  376. package/src/nodes/collection/tuple.ts +80 -0
  377. package/src/nodes/collection/union.ts +205 -0
  378. package/src/nodes/collection/unionDiscriminator.ts +259 -0
  379. package/src/nodes/function/function.ts +166 -0
  380. package/src/nodes/member/array.ts +150 -0
  381. package/src/nodes/member/callSignature.ts +34 -0
  382. package/src/nodes/member/genericMember.ts +63 -0
  383. package/src/nodes/member/indexProperty.ts +174 -0
  384. package/src/nodes/member/method.ts +30 -0
  385. package/src/nodes/member/methodSignature.ts +31 -0
  386. package/src/nodes/member/param.ts +22 -0
  387. package/src/nodes/member/property.ts +75 -0
  388. package/src/nodes/member/restParams.ts +22 -0
  389. package/src/nodes/member/tupleMember.ts +93 -0
  390. package/src/nodes/native/Iterable.ts +153 -0
  391. package/src/nodes/native/map.ts +91 -0
  392. package/src/nodes/native/nonSerializable.ts +42 -0
  393. package/src/nodes/native/promise.ts +43 -0
  394. package/src/nodes/native/set.ts +56 -0
  395. package/src/run-types-pure-fns.ts +116 -0
  396. package/src/types.ts +206 -0
@@ -0,0 +1,150 @@
1
+ /* ########
2
+ * 2024 mion
3
+ * Author: Ma-jerez
4
+ * License: MIT
5
+ * The software is provided "as is", without warranty of any kind.
6
+ * ######## */
7
+
8
+ import type {Type, TypeArray} from '@deepkit/type';
9
+ import type {JitCode} from '../../types.ts';
10
+ import type {JitFnCompiler, JitErrorsFnCompiler} from '../../lib/jitFnCompiler.ts';
11
+ import {MemberRunType} from '../../lib/baseRunTypes.ts';
12
+ import {childIsExpression} from '../../lib/utils.ts';
13
+
14
+ export class ArrayRunType<T extends Type = TypeArray> extends MemberRunType<T> {
15
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
16
+ startIndex(comp: JitFnCompiler): number {
17
+ return 0;
18
+ }
19
+ getChildVarName(comp: JitFnCompiler): string {
20
+ return comp.getLocalVarName('i', this);
21
+ }
22
+ getChildLiteral(comp: JitFnCompiler): string {
23
+ return this.getChildVarName(comp);
24
+ }
25
+ useArrayAccessor(): true {
26
+ return true;
27
+ }
28
+ isOptional(): boolean {
29
+ return false;
30
+ }
31
+
32
+ // #### jit code ####
33
+ emitIsType(comp: JitFnCompiler): JitCode {
34
+ this.checkNonSkipTypes(comp);
35
+ const resultVal = comp.getLocalVarName('res', this);
36
+ const index = this.getChildVarName(comp);
37
+ const child = this.getJitChild(comp);
38
+ const childJit = comp.compileIsType(child, 'E');
39
+ if (!childJit?.code && comp.opts.noIsArrayCheck) return {code: undefined, type: 'E'};
40
+ if (!childJit?.code) return {code: `Array.isArray(${comp.vλl})`, type: 'E'};
41
+ const isArrayCheckCode = comp.opts.noIsArrayCheck ? '' : `if (!Array.isArray(${comp.vλl})) return false;`;
42
+ return {
43
+ code: `
44
+ ${isArrayCheckCode}
45
+ for (let ${index} = ${this.startIndex(comp)}; ${index} < ${comp.vλl}.length; ${index}++) {
46
+ const ${resultVal} = ${childJit.code};
47
+ if (!(${resultVal})) return false;
48
+ }
49
+ return true;
50
+ `,
51
+ type: 'RB',
52
+ };
53
+ }
54
+ emitTypeErrors(comp: JitErrorsFnCompiler): JitCode {
55
+ this.checkNonSkipTypes(comp);
56
+ const index = this.getChildVarName(comp);
57
+ const child = this.getJitChild(comp);
58
+ const childJit = comp.compileTypeErrors(child, 'S');
59
+ if (!childJit?.code && comp.opts.noIsArrayCheck) return {code: undefined, type: 'E'};
60
+ if (!childJit?.code) return {code: `if (!Array.isArray(${comp.vλl})) ${comp.callJitErr(this)};`, type: 'S'};
61
+ const itemsCode = `for (let ${index} = ${this.startIndex(comp)}; ${index} < ${comp.vλl}.length; ${index}++) {${childJit.code}}`;
62
+ if (comp.opts.noIsArrayCheck) return {code: itemsCode, type: 'S'};
63
+ return {
64
+ code: `if (!Array.isArray(${comp.vλl})) {${comp.callJitErr(this)}} else {${itemsCode}}`,
65
+ type: 'S',
66
+ };
67
+ }
68
+ emitPrepareForJson(comp: JitFnCompiler): JitCode {
69
+ this.checkNonSkipTypes(comp);
70
+ const index = this.getChildVarName(comp);
71
+ const child = this.getJitChild(comp);
72
+ const childJit = comp.compilePrepareForJson(child, 'S');
73
+ if (!childJit?.code || !child) return {code: undefined, type: 'S'};
74
+ const isExpression = childIsExpression(childJit, child);
75
+ const code = isExpression ? `${comp.getChildVλl()} = ${childJit.code};` : childJit.code || '';
76
+ return {
77
+ code: `for (let ${index} = ${this.startIndex(comp)}; ${index} < ${comp.vλl}.length; ${index}++) {${code}}`,
78
+ type: 'S',
79
+ };
80
+ }
81
+ emitRestoreFromJson(comp: JitFnCompiler): JitCode {
82
+ this.checkNonSkipTypes(comp);
83
+ const index = this.getChildVarName(comp);
84
+ const child = this.getJitChild(comp);
85
+ const childJit = comp.compileRestoreFromJson(child, 'S');
86
+ if (!childJit?.code || !child) return {code: undefined, type: 'S'};
87
+ const isExpression = childIsExpression(childJit, child);
88
+ const code = isExpression ? `${comp.getChildVλl()} = ${childJit.code};` : childJit.code || '';
89
+ return {
90
+ code: `for (let ${index} = ${this.startIndex(comp)}; ${index} < ${comp.vλl}.length; ${index}++) {${code}}`,
91
+ type: 'S',
92
+ };
93
+ }
94
+ emitHasUnknownKeys(comp: JitFnCompiler): JitCode {
95
+ this.checkNonSkipTypes(comp);
96
+ if (this.getMemberType().getFamily() === 'A') return {code: undefined, type: 'E'};
97
+ const child = this.getJitChild(comp);
98
+ const childJit = comp.compileHasUnknownKeys(child, 'E');
99
+ if (!childJit?.code) return {code: undefined, type: 'E'};
100
+ const resultVal = comp.getLocalVarName('res', this);
101
+ const index = this.getChildVarName(comp);
102
+
103
+ return {
104
+ code: `
105
+ if (!Array.isArray(${comp.vλl})) return false;
106
+ for (let ${index} = ${this.startIndex(comp)}; ${index} < ${comp.vλl}.length; ${index}++) {
107
+ const ${resultVal} = ${childJit.code};
108
+ if (${resultVal}) return true;
109
+ }
110
+ return false;
111
+ `,
112
+ type: 'RB',
113
+ };
114
+ }
115
+ emitUnknownKeyErrors(comp: JitErrorsFnCompiler): JitCode {
116
+ this.checkNonSkipTypes(comp);
117
+ if (this.getMemberType().getFamily() === 'A') return {code: '', type: 'E'};
118
+ const child = this.getJitChild(comp);
119
+ const childJit = comp.compileUnknownKeyErrors(child, 'S');
120
+ return this.traverseCode(comp, childJit);
121
+ }
122
+ emitStripUnknownKeys(comp: JitFnCompiler): JitCode {
123
+ this.checkNonSkipTypes(comp);
124
+ if (this.getMemberType().getFamily() === 'A') return {code: '', type: 'E'};
125
+ const child = this.getJitChild(comp);
126
+ const childJit = comp.compileStripUnknownKeys(child, 'S');
127
+ return this.traverseCode(comp, childJit);
128
+ }
129
+ emitUnknownKeysToUndefined(comp: JitFnCompiler): JitCode {
130
+ this.checkNonSkipTypes(comp);
131
+ if (this.getMemberType().getFamily() === 'A') return {code: '', type: 'E'};
132
+ const child = this.getJitChild(comp);
133
+ const childJit = comp.compileUnknownKeysToUndefined(child, 'S');
134
+ return this.traverseCode(comp, childJit);
135
+ }
136
+
137
+ traverseCode(comp: JitFnCompiler, childJit: JitCode | undefined): {code: string | undefined; type: 'S'} {
138
+ if (!childJit?.code) return {code: undefined, type: 'S'};
139
+ const index = this.getChildVarName(comp);
140
+ return {
141
+ code: `for (let ${index} = ${this.startIndex(comp)}; ${index} < ${comp.vλl}.length; ${index}++) {${childJit.code}}`,
142
+ type: 'S',
143
+ };
144
+ }
145
+
146
+ checkNonSkipTypes(comp: JitFnCompiler) {
147
+ const child = this.getMemberType();
148
+ if (child.skipJit(comp)) throw new Error(`Arrays can not have non serializable types, ie: Symbol[], Function[], etc.`);
149
+ }
150
+ }
@@ -0,0 +1,34 @@
1
+ /* ########
2
+ * 2024 mion
3
+ * Author: Ma-jerez
4
+ * License: MIT
5
+ * The software is provided "as is", without warranty of any kind.
6
+ * ######## */
7
+ import {TypeCallSignature} from '@deepkit/type';
8
+ import {RunTypeChildAccessor} from '../../types.ts';
9
+ import {getPropIndex} from '../../lib/utils.ts';
10
+ import {FunctionRunType} from '../function/function.ts';
11
+ import type {JitFnCompiler} from '../../lib/jitFnCompiler.ts';
12
+
13
+ /**
14
+ * Represents a call signature.
15
+ * Call signature is an special node within in interface or object literal that represents a function signature but can have extra properties.
16
+ * ie:
17
+ * type = {
18
+ * (a: number, b: boolean): string; // call signature node
19
+ * popA: number;
20
+ * }
21
+ *
22
+ * So when a call signature is present the parent object literal or interface is considered a function.
23
+ */
24
+ export class CallSignatureRunType extends FunctionRunType<TypeCallSignature> implements RunTypeChildAccessor {
25
+ getChildIndex = (comp: JitFnCompiler) => {
26
+ const start = comp?.opts?.paramsSlice?.start;
27
+ if (start) return getPropIndex(this.src) - start;
28
+ return getPropIndex(this.src);
29
+ };
30
+ getChildVarName = () => '';
31
+ getChildLiteral = () => '""';
32
+ useArrayAccessor = () => false;
33
+ isOptional = () => false;
34
+ }
@@ -0,0 +1,63 @@
1
+ /* ########
2
+ * 2024 mion
3
+ * Author: Ma-jerez
4
+ * License: MIT
5
+ * The software is provided "as is", without warranty of any kind.
6
+ * ######## */
7
+ import type {JitFnCompiler, JitErrorsFnCompiler} from '../../lib/jitFnCompiler.ts';
8
+ import {MemberRunType} from '../../lib/baseRunTypes.ts';
9
+ import type {JitCode, SrcMember} from '../../types.ts';
10
+ import {childIsExpression} from '../../lib/utils.ts';
11
+
12
+ // TODO: investigate is other member types cloud extend this class instead of MemberRunType
13
+ export class GenericMemberRunType<T extends SrcMember> extends MemberRunType<T> {
14
+ index = 0;
15
+ getChildIndex() {
16
+ return this.index;
17
+ }
18
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
19
+ getChildVarName(comp: JitFnCompiler): string | number {
20
+ return this.index;
21
+ }
22
+ getChildLiteral(comp: JitFnCompiler) {
23
+ return this.getChildVarName(comp);
24
+ }
25
+ useArrayAccessor() {
26
+ return true;
27
+ }
28
+ isOptional() {
29
+ return false;
30
+ }
31
+ emitIsType(comp: JitFnCompiler): JitCode {
32
+ const child = this.getJitChild(comp);
33
+ const childJit = comp.compileIsType(child, 'E');
34
+ if (!childJit?.code) return {code: undefined, type: 'E'};
35
+ if (this.isOptional()) return {code: `${comp.getChildVλl()} === undefined || (${childJit.code})`, type: 'E'};
36
+ return childJit;
37
+ }
38
+ emitTypeErrors(comp: JitErrorsFnCompiler): JitCode {
39
+ const child = this.getJitChild(comp);
40
+ const childJit = comp.compileTypeErrors(child, 'S');
41
+ if (!childJit?.code) return {code: undefined, type: 'S'};
42
+ if (this.isOptional()) return {code: `if (${comp.getChildVλl()} !== undefined) {${childJit.code}}`, type: 'S'};
43
+ return childJit;
44
+ }
45
+ emitPrepareForJson(comp: JitFnCompiler): JitCode {
46
+ const child = this.getJitChild(comp);
47
+ const childJit = comp.compilePrepareForJson(child, 'S');
48
+ if (!childJit?.code || !child) return {code: undefined, type: 'S'};
49
+ const isExpression = childIsExpression(childJit, child); // expressions must be assigned to a variable
50
+ const code = isExpression ? `${comp.getChildVλl()} = ${childJit.code}` : childJit.code || '';
51
+ if (this.isOptional()) return {code: `if (${comp.getChildVλl()} !== undefined) {${code}}`, type: 'S'};
52
+ return {code, type: 'S'};
53
+ }
54
+ emitRestoreFromJson(comp: JitFnCompiler): JitCode {
55
+ const child = this.getJitChild(comp);
56
+ const childJit = comp.compileRestoreFromJson(child, 'S');
57
+ if (!childJit?.code || !child) return {code: undefined, type: 'S'};
58
+ const isExpression = childIsExpression(childJit, child);
59
+ const code = isExpression ? `${comp.getChildVλl()} = ${childJit.code};` : childJit.code || '';
60
+ if (this.isOptional()) return {code: `if (${comp.getChildVλl()} !== undefined) {${code}}`, type: 'S'};
61
+ return {code, type: 'S'};
62
+ }
63
+ }
@@ -0,0 +1,174 @@
1
+ import {ReflectionKind, type TypeIndexSignature, type TypeTemplateLiteral} from '@deepkit/type';
2
+ import {MemberRunType} from '../../lib/baseRunTypes.ts';
3
+ import {type JitCode} from '../../types.ts';
4
+ import {JitFunctions} from '../../constants.functions.ts';
5
+ import type {JitFnCompiler, JitErrorsFnCompiler} from '../../lib/jitFnCompiler.ts';
6
+ import {InterfaceRunType} from '../collection/interface.ts';
7
+ import {childIsExpression} from '../../lib/utils.ts';
8
+ import {buildAnchoredTemplateRegexSource} from '../collection/templateLiteral.ts';
9
+
10
+ /* ########
11
+ * 2024 mion
12
+ * Author: Ma-jerez
13
+ * License: MIT
14
+ * The software is provided "as is", without warranty of any kind.
15
+ * ######## */
16
+
17
+ export class IndexSignatureRunType extends MemberRunType<TypeIndexSignature> {
18
+ isOptional(): boolean {
19
+ return true;
20
+ }
21
+ getChildVarName(comp: JitFnCompiler): string {
22
+ return comp.getLocalVarName('p', this);
23
+ }
24
+ getChildLiteral(comp: JitFnCompiler): string {
25
+ return this.getChildVarName(comp);
26
+ }
27
+ useArrayAccessor(): true {
28
+ return true;
29
+ }
30
+ skipJit(comp: JitFnCompiler): boolean {
31
+ const index = (this.src as TypeIndexSignature).index?.kind;
32
+ if (index === ReflectionKind.symbol) {
33
+ return comp?.fnID !== JitFunctions.toJSCode.id;
34
+ }
35
+ return false;
36
+ }
37
+
38
+ /** if the index key is a template literal type, return the JIT context var holding the compiled key-pattern regex */
39
+ private getKeyPatternVar(comp: JitFnCompiler): string | undefined {
40
+ const idx = this.src.index;
41
+ if (idx?.kind !== ReflectionKind.templateLiteral) return undefined;
42
+ const varName = comp.getLocalVarName('reIdx', this);
43
+ if (!comp.hasContextItem(varName)) {
44
+ const src = buildAnchoredTemplateRegexSource((idx as TypeTemplateLiteral).types || []);
45
+ comp.setContextItem(varName, `const ${varName} = new RegExp(${JSON.stringify(src)})`);
46
+ }
47
+ return varName;
48
+ }
49
+
50
+ // #### jit code ####
51
+ emitIsType(comp: JitFnCompiler): JitCode {
52
+ const child = this.getJitChild(comp);
53
+ const childJit = comp.compileIsType(child, 'E');
54
+ const prop = this.getChildVarName(comp);
55
+ const reVar = this.getKeyPatternVar(comp);
56
+ const skipCode = this.getSkipCode(comp, prop);
57
+ const keyCheck = reVar ? `if (!${reVar}.test(${prop})) return false;` : '';
58
+ if (!childJit?.code && !keyCheck) return {code: undefined, type: 'E'};
59
+ const valueCheck = childJit?.code ? `if (!(${childJit.code})) return false;` : '';
60
+ return {
61
+ code: `for (const ${prop} in ${comp.vλl}){${skipCode} ${keyCheck} ${valueCheck}} return true;`,
62
+ type: 'RB',
63
+ };
64
+ }
65
+ emitTypeErrors(comp: JitErrorsFnCompiler): JitCode {
66
+ const child = this.getJitChild(comp);
67
+ const childJit = comp.compileTypeErrors(child, 'S');
68
+ const prop = this.getChildVarName(comp);
69
+ const reVar = this.getKeyPatternVar(comp);
70
+ const skipCode = this.getSkipCode(comp, prop);
71
+ // when the key fails the template literal pattern, report it (with the offending key in the path)
72
+ // and skip the value check to avoid compounding errors on values whose key was already invalid
73
+ const keyErr = reVar ? `if (!${reVar}.test(${prop})) {${comp.callJitErrWithPath(this, prop)}; continue;}` : '';
74
+ if (!childJit?.code && !keyErr) return {code: undefined, type: 'S'};
75
+ return {code: `for (const ${prop} in ${comp.vλl}) {${skipCode} ${keyErr} ${childJit?.code || ''}}`, type: 'S'};
76
+ }
77
+ emitPrepareForJson(comp: JitFnCompiler): JitCode {
78
+ const child = this.getJitChild(comp);
79
+ const childJit = comp.compilePrepareForJson(child, 'S');
80
+ if (!child || !childJit?.code) return {code: undefined, type: 'S'};
81
+ const varName = comp.vλl;
82
+ const prop = this.getChildVarName(comp);
83
+ const skipCode = this.getSkipCode(comp, prop);
84
+ const reVar = this.getKeyPatternVar(comp);
85
+ const patternSkip = reVar ? `if (!${reVar}.test(${prop})) continue;` : '';
86
+ const isExpression = childIsExpression(childJit, child);
87
+ const code = isExpression ? `${comp.getChildVλl()} = ${childJit.code};` : childJit.code || '';
88
+ return {code: `for (const ${prop} in ${varName}){${skipCode} ${patternSkip} ${code}}`, type: 'S'};
89
+ }
90
+ emitRestoreFromJson(comp: JitFnCompiler): JitCode {
91
+ const child = this.getJitChild(comp);
92
+ const childJit = comp.compileRestoreFromJson(child, 'S');
93
+ if (!child || !childJit?.code) return {code: undefined, type: 'S'};
94
+ const varName = comp.vλl;
95
+ const prop = this.getChildVarName(comp);
96
+ const skipCode = this.getSkipCode(comp, prop);
97
+ const reVar = this.getKeyPatternVar(comp);
98
+ const patternSkip = reVar ? `if (!${reVar}.test(${prop})) continue;` : '';
99
+ const isExpression = childIsExpression(childJit, child);
100
+ const code = isExpression ? `${comp.getChildVλl()} = ${childJit.code};` : childJit.code || '';
101
+ return {code: `for (const ${prop} in ${varName}){${skipCode} ${patternSkip} ${code}}`, type: 'S'};
102
+ }
103
+ emitHasUnknownKeys(comp: JitFnCompiler): JitCode {
104
+ const reVar = this.getKeyPatternVar(comp);
105
+ const child = this.getJitChild(comp);
106
+ const childJit = comp.compileHasUnknownKeys(child, 'E');
107
+ // when the value is atomic and there's no key pattern, every key is "known" -> no check needed
108
+ if (this.getMemberType().getFamily() === 'A' && !reVar) return {code: undefined, type: 'E'};
109
+ const varName = comp.vλl;
110
+ const prop = this.getChildVarName(comp);
111
+ const skipCode = this.getSkipCode(comp, prop);
112
+ const patternCheck = reVar ? `if (!${reVar}.test(${prop})) return true;` : '';
113
+ const childCheck = childJit?.code
114
+ ? `const ${comp.getLocalVarName('res', this)} = ${childJit.code};if (${comp.getLocalVarName('res', this)}) return true;`
115
+ : '';
116
+ if (!patternCheck && !childCheck) return {code: '', type: 'E'};
117
+ return {
118
+ code: `for (const ${prop} in ${varName}) {${skipCode} ${patternCheck} ${childCheck}}return false;`,
119
+ type: 'RB',
120
+ };
121
+ }
122
+ emitUnknownKeyErrors(comp: JitErrorsFnCompiler): JitCode {
123
+ const reVar = this.getKeyPatternVar(comp);
124
+ const child = this.getJitChild(comp);
125
+ const childJit = comp.compileUnknownKeyErrors(child, 'S');
126
+ if (this.getMemberType().getFamily() === 'A' && !reVar) return {code: undefined, type: 'S'};
127
+ const prop = this.getChildVarName(comp);
128
+ const skipCode = this.getSkipCode(comp, prop);
129
+ const patternErr = reVar ? `if (!${reVar}.test(${prop})) {${comp.callJitErrWithPath('never', prop)}; continue;}` : '';
130
+ if (!patternErr && !childJit?.code) return {code: undefined, type: 'S'};
131
+ return {code: `for (const ${prop} in ${comp.vλl}) {${skipCode} ${patternErr} ${childJit?.code || ''}}`, type: 'S'};
132
+ }
133
+ emitStripUnknownKeys(comp: JitFnCompiler): JitCode {
134
+ const reVar = this.getKeyPatternVar(comp);
135
+ const child = this.getJitChild(comp);
136
+ const childJit = comp.compileStripUnknownKeys(child, 'S');
137
+ if (this.getMemberType().getFamily() === 'A' && !reVar) return {code: undefined, type: 'S'};
138
+ const prop = this.getChildVarName(comp);
139
+ const skipCode = this.getSkipCode(comp, prop);
140
+ const patternStrip = reVar ? `if (!${reVar}.test(${prop})) {delete ${comp.vλl}[${prop}]; continue;}` : '';
141
+ if (!patternStrip && !childJit?.code) return {code: undefined, type: 'S'};
142
+ return {code: `for (const ${prop} in ${comp.vλl}) {${skipCode} ${patternStrip} ${childJit?.code || ''}}`, type: 'S'};
143
+ }
144
+ emitUnknownKeysToUndefined(comp: JitFnCompiler): JitCode {
145
+ const reVar = this.getKeyPatternVar(comp);
146
+ const child = this.getJitChild(comp);
147
+ const childJit = comp.compileUnknownKeysToUndefined(child, 'S');
148
+ if (this.getMemberType().getFamily() === 'A' && !reVar) return {code: undefined, type: 'S'};
149
+ const prop = this.getChildVarName(comp);
150
+ const skipCode = this.getSkipCode(comp, prop);
151
+ const patternUndef = reVar ? `if (!${reVar}.test(${prop})) {${comp.vλl}[${prop}] = undefined; continue;}` : '';
152
+ if (!patternUndef && !childJit?.code) return {code: undefined, type: 'S'};
153
+ return {code: `for (const ${prop} in ${comp.vλl}) {${skipCode} ${patternUndef} ${childJit?.code || ''}}`, type: 'S'};
154
+ }
155
+ traverseCode(comp: JitFnCompiler, childJit: JitCode | undefined): JitCode {
156
+ if (!childJit?.code) return {code: undefined, type: 'S'};
157
+ const prop = this.getChildVarName(comp);
158
+ return {code: `for (const ${prop} in ${comp.vλl}) {${childJit.code}}`, type: 'S'};
159
+ }
160
+ /**
161
+ * if index property should be skipped then it output some code to skip it,
162
+ * this happen when an object/interface has an index property but also has named properties
163
+ * that might collide with the index property. ie {[key: string]: string, a: string}
164
+ * when executing the logic for the index property we need to skip the named properties.
165
+ */
166
+ getSkipCode(comp: JitFnCompiler, prop: string): string {
167
+ const parent = this.getParent() as InterfaceRunType;
168
+ const namedChildren = parent.getNamedChildren(comp);
169
+ const skipNames = namedChildren.length
170
+ ? namedChildren.map((child) => `${child.getChildLiteral(comp)} === ${prop}`).join(' || ')
171
+ : '';
172
+ return namedChildren.length ? `if (${skipNames}) continue;` : '';
173
+ }
174
+ }
@@ -0,0 +1,30 @@
1
+ /* ########
2
+ * 2024 mion
3
+ * Author: Ma-jerez
4
+ * License: MIT
5
+ * The software is provided "as is", without warranty of any kind.
6
+ * ######## */
7
+ import {TypeMethod} from '@deepkit/type';
8
+ import {FunctionRunType} from '../function/function.ts';
9
+ import {RunTypeChildAccessor} from '../../types.ts';
10
+ import {getPropIndex, getPropLiteral, getPropVarName, useArrayAccessorForProp} from '../../lib/utils.ts';
11
+ import type {JitFnCompiler} from '../../lib/jitFnCompiler.ts';
12
+
13
+ export class MethodRunType extends FunctionRunType<TypeMethod> implements RunTypeChildAccessor {
14
+ getChildIndex = (comp: JitFnCompiler) => {
15
+ const start = comp?.opts?.paramsSlice?.start;
16
+ if (start) return getPropIndex(this.src) - start;
17
+ return getPropIndex(this.src);
18
+ };
19
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
20
+ getChildVarName(comp: JitFnCompiler) {
21
+ return getPropVarName(this.src.name);
22
+ }
23
+ getChildLiteral(comp: JitFnCompiler) {
24
+ return getPropLiteral(this.getChildVarName(comp));
25
+ }
26
+ useArrayAccessor() {
27
+ return useArrayAccessorForProp(this.src.name);
28
+ }
29
+ isOptional = () => !!this.src.optional;
30
+ }
@@ -0,0 +1,31 @@
1
+ /* ########
2
+ * 2024 mion
3
+ * Author: Ma-jerez
4
+ * License: MIT
5
+ * The software is provided "as is", without warranty of any kind.
6
+ * ######## */
7
+ import {TypeMethodSignature} from '@deepkit/type';
8
+ import {RunTypeChildAccessor} from '../../types.ts';
9
+ import {FunctionRunType} from '../function/function.ts';
10
+ import {getPropIndex, getPropLiteral, getPropVarName, useArrayAccessorForProp} from '../../lib/utils.ts';
11
+ import type {JitFnCompiler} from '../../lib/jitFnCompiler.ts';
12
+
13
+ export class MethodSignatureRunType extends FunctionRunType<TypeMethodSignature> implements RunTypeChildAccessor {
14
+ getChildIndex = (comp: JitFnCompiler) => {
15
+ const start = comp?.opts?.paramsSlice?.start;
16
+ if (start) return getPropIndex(this.src) - start;
17
+ return getPropIndex(this.src);
18
+ };
19
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
20
+ getChildVarName(comp: JitFnCompiler) {
21
+ return getPropVarName(this.src.name);
22
+ }
23
+ getChildLiteral(comp: JitFnCompiler) {
24
+ return getPropLiteral(this.getChildVarName(comp));
25
+ }
26
+ useArrayAccessor() {
27
+ return useArrayAccessorForProp(this.src.name);
28
+ }
29
+ isOptional = () => !!this.src.optional;
30
+ skipCommas = false;
31
+ }
@@ -0,0 +1,22 @@
1
+ /* ########
2
+ * 2024 mion
3
+ * Author: Ma-jerez
4
+ * License: MIT
5
+ * The software is provided "as is", without warranty of any kind.
6
+ * ######## */
7
+
8
+ import type {TypeParameter} from '@deepkit/type';
9
+ import type {JitFnCompiler} from '../../lib/jitFnCompiler.ts';
10
+ import {TupleMemberRunType} from './tupleMember.ts';
11
+
12
+ export class ParameterRunType<T extends TypeParameter = TypeParameter> extends TupleMemberRunType<T> {
13
+ getParamName() {
14
+ return this.src.name;
15
+ }
16
+ getChildVarName(comp: JitFnCompiler): number {
17
+ return this.getChildIndex(comp);
18
+ }
19
+ getChildLiteral(comp: JitFnCompiler): number {
20
+ return this.getChildIndex(comp);
21
+ }
22
+ }
@@ -0,0 +1,75 @@
1
+ /* ########
2
+ * 2024 mion
3
+ * Author: Ma-jerez
4
+ * License: MIT
5
+ * The software is provided "as is", without warranty of any kind.
6
+ * ######## */
7
+
8
+ import type {TypeProperty, TypePropertySignature} from '@deepkit/type';
9
+ import type {JitFnCompiler, JitErrorsFnCompiler} from '../../lib/jitFnCompiler.ts';
10
+ import type {JitCode} from '../../types.ts';
11
+ import {childIsExpression, getPropLiteral, getPropVarName, useArrayAccessorForProp} from '../../lib/utils.ts';
12
+ import {MemberRunType} from '../../lib/baseRunTypes.ts';
13
+ import {InterfaceRunType} from '../collection/interface.ts';
14
+ import {JitFunctions} from '../../constants.functions.ts';
15
+
16
+ export class PropertyRunType extends MemberRunType<TypePropertySignature | TypeProperty> {
17
+ isUnionDiscriminator = false;
18
+ /** this is set by the parent interface if prop is optional, when optional properties are sorted */
19
+ optionalIndex = -1;
20
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
21
+ getPropertyName() {
22
+ return getPropVarName(this.src.name);
23
+ }
24
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
25
+ getChildVarName(comp: JitFnCompiler) {
26
+ return getPropVarName(this.src.name);
27
+ }
28
+ getChildLiteral(comp: JitFnCompiler) {
29
+ return getPropLiteral(this.getChildVarName(comp));
30
+ }
31
+ useArrayAccessor() {
32
+ return useArrayAccessorForProp(this.src.name);
33
+ }
34
+ getJitChildIndex = (comp: JitFnCompiler) => (this.getParent() as InterfaceRunType).getJitChildren(comp).indexOf(this);
35
+ isOptional = () => !!this.src.optional;
36
+ skipJit(comp: JitFnCompiler): boolean {
37
+ const name = (this.src as TypeProperty).name;
38
+ if (typeof name === 'symbol') {
39
+ return comp?.fnID !== JitFunctions.toJSCode.id;
40
+ }
41
+ return false;
42
+ }
43
+ // #### jit code ####
44
+
45
+ emitIsType(comp: JitFnCompiler): JitCode {
46
+ const child = this.getJitChild(comp);
47
+ const childJit = comp.compileIsType(child, 'E');
48
+ if (!childJit?.code) return {code: undefined, type: 'E'};
49
+ return this.src.optional ? {code: `(${comp.getChildVλl()} === undefined || ${childJit.code})`, type: 'E'} : childJit;
50
+ }
51
+ emitTypeErrors(comp: JitErrorsFnCompiler): JitCode {
52
+ const child = this.getJitChild(comp);
53
+ const childJit = comp.compileTypeErrors(child, 'S');
54
+ if (!childJit?.code) return {code: undefined, type: 'S'};
55
+ return this.src.optional ? {code: `if (${comp.getChildVλl()} !== undefined) {${childJit.code}}`, type: 'S'} : childJit;
56
+ }
57
+ emitPrepareForJson(comp: JitFnCompiler): JitCode {
58
+ const child = this.getJitChild(comp);
59
+ const childJit = comp.compilePrepareForJson(child, 'S');
60
+ if (!child || !childJit?.code) return {code: undefined, type: 'S'};
61
+ const isExpression = childIsExpression(childJit, child);
62
+ const code = isExpression ? `${comp.getChildVλl()} = ${childJit.code};` : childJit.code || '';
63
+ if (this.src.optional) return {code: `if (${comp.getChildVλl()} !== undefined) {${code}}`, type: 'S'};
64
+ return {code, type: 'S'};
65
+ }
66
+ emitRestoreFromJson(comp: JitFnCompiler): JitCode {
67
+ const child = this.getJitChild(comp);
68
+ const childJit = comp.compileRestoreFromJson(child, 'S');
69
+ if (!child || !childJit?.code) return {code: undefined, type: 'S'};
70
+ const isExpression = childIsExpression(childJit, child);
71
+ const code = isExpression ? `${comp.getChildVλl()} = ${childJit.code};` : childJit.code || '';
72
+ if (this.src.optional) return {code: `if (${comp.getChildVλl()} !== undefined) {${code}}`, type: 'S'};
73
+ return {code, type: 'S'};
74
+ }
75
+ }
@@ -0,0 +1,22 @@
1
+ /* ########
2
+ * 2024 mion
3
+ * Author: Ma-jerez
4
+ * License: MIT
5
+ * The software is provided "as is", without warranty of any kind.
6
+ * ######## */
7
+
8
+ import type {TypeRest} from '@deepkit/type';
9
+ import type {ParameterRunType} from './param.ts';
10
+ import type {TupleMemberRunType} from './tupleMember.ts';
11
+ import {ArrayRunType} from './array.ts';
12
+ import type {JitFnCompiler} from '../../lib/jitFnCompiler.ts';
13
+
14
+ export class RestParamsRunType extends ArrayRunType<TypeRest> {
15
+ getChildIndex(comp: JitFnCompiler): number {
16
+ const parent = this.getParent() as ParameterRunType | TupleMemberRunType;
17
+ return parent.getChildIndex(comp);
18
+ }
19
+ startIndex(comp: JitFnCompiler): number {
20
+ return this.getChildIndex(comp);
21
+ }
22
+ }