@bitbybit-dev/base 1.5.0 → 1.6.0

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 (314) hide show
  1. package/lib/api/GlobalCDNProvider.js +1 -1
  2. package/lib/api/bearings/ansi-bearings.constants.d.ts +2 -0
  3. package/lib/api/bearings/ansi-bearings.constants.js +26 -0
  4. package/lib/api/bearings/ansi-bearings.d.ts +4 -0
  5. package/lib/api/bearings/ansi-bearings.js +14 -0
  6. package/lib/api/bearings/bearing-types.d.ts +25 -0
  7. package/lib/api/bearings/bearing-types.js +1 -0
  8. package/lib/api/bearings/bearings.constants.d.ts +1 -0
  9. package/lib/api/bearings/bearings.constants.js +1 -0
  10. package/lib/api/bearings/iso-bearings.constants.d.ts +2 -0
  11. package/lib/api/bearings/iso-bearings.constants.js +30 -0
  12. package/lib/api/bearings/iso-bearings.d.ts +4 -0
  13. package/lib/api/bearings/iso-bearings.js +14 -0
  14. package/lib/api/color-space.d.ts +2 -0
  15. package/lib/api/color-space.js +5 -8
  16. package/lib/api/fasteners/ansi-fasteners.constants.d.ts +16 -0
  17. package/lib/api/fasteners/ansi-fasteners.constants.js +118 -0
  18. package/lib/api/fasteners/ansi-fasteners.d.ts +8 -0
  19. package/lib/api/fasteners/ansi-fasteners.js +64 -0
  20. package/lib/api/fasteners/fastener-types.d.ts +161 -0
  21. package/lib/api/fasteners/fastener-types.js +1 -0
  22. package/lib/api/fasteners/fasteners.constants.d.ts +5 -0
  23. package/lib/api/fasteners/fasteners.constants.js +5 -0
  24. package/lib/api/fasteners/fasteners.d.ts +2 -0
  25. package/lib/api/fasteners/fasteners.js +9 -0
  26. package/lib/api/fasteners/iso-fasteners.constants.d.ts +23 -0
  27. package/lib/api/fasteners/iso-fasteners.constants.js +110 -0
  28. package/lib/api/fasteners/iso-fasteners.d.ts +9 -0
  29. package/lib/api/fasteners/iso-fasteners.js +61 -0
  30. package/lib/api/gears/bevel-gears.d.ts +6 -0
  31. package/lib/api/gears/bevel-gears.js +69 -0
  32. package/lib/api/gears/gear-checks.d.ts +8 -0
  33. package/lib/api/gears/gear-checks.js +69 -0
  34. package/lib/api/gears/gear-pairs.d.ts +4 -0
  35. package/lib/api/gears/gear-pairs.js +140 -0
  36. package/lib/api/gears/gear-types.d.ts +425 -0
  37. package/lib/api/gears/gear-types.js +1 -0
  38. package/lib/api/gears/gears.constants.d.ts +19 -0
  39. package/lib/api/gears/gears.constants.js +19 -0
  40. package/lib/api/gears/gears.d.ts +10 -0
  41. package/lib/api/gears/gears.js +156 -0
  42. package/lib/api/gears/helical-gears.d.ts +5 -0
  43. package/lib/api/gears/helical-gears.js +33 -0
  44. package/lib/api/gears/involute-flank.d.ts +26 -0
  45. package/lib/api/gears/involute-flank.js +158 -0
  46. package/lib/api/gears/racks.d.ts +3 -0
  47. package/lib/api/gears/racks.js +64 -0
  48. package/lib/api/index.d.ts +10 -1
  49. package/lib/api/index.js +0 -1
  50. package/lib/api/inputs/base-inputs.d.ts +450 -3
  51. package/lib/api/inputs/base-inputs.js +12 -0
  52. package/lib/api/inputs/color-inputs.d.ts +14 -0
  53. package/lib/api/inputs/color-inputs.js +19 -0
  54. package/lib/api/inputs/engineering-inputs.d.ts +1539 -0
  55. package/lib/api/inputs/engineering-inputs.js +2181 -0
  56. package/lib/api/inputs/index.d.ts +2 -0
  57. package/lib/api/inputs/index.js +2 -0
  58. package/lib/api/inputs/io-inputs.d.ts +8 -1
  59. package/lib/api/inputs/io-inputs.js +4 -1
  60. package/lib/api/inputs/math-inputs.d.ts +61 -0
  61. package/lib/api/inputs/math-inputs.js +85 -0
  62. package/lib/api/inputs/mesh-inputs.d.ts +170 -0
  63. package/lib/api/inputs/mesh-inputs.js +206 -0
  64. package/lib/api/inputs/point-inputs.d.ts +4 -4
  65. package/lib/api/inputs/polyline-inputs.d.ts +144 -0
  66. package/lib/api/inputs/polyline-inputs.js +151 -0
  67. package/lib/api/inputs/recipes-inputs.d.ts +76 -0
  68. package/lib/api/inputs/recipes-inputs.js +74 -0
  69. package/lib/api/inputs/transforms-inputs.d.ts +34 -0
  70. package/lib/api/inputs/transforms-inputs.js +35 -0
  71. package/lib/api/keys/ansi-keys.constants.d.ts +3 -0
  72. package/lib/api/keys/ansi-keys.constants.js +16 -0
  73. package/lib/api/keys/ansi-keys.d.ts +3 -0
  74. package/lib/api/keys/ansi-keys.js +14 -0
  75. package/lib/api/keys/din-keys.constants.d.ts +3 -0
  76. package/lib/api/keys/din-keys.constants.js +14 -0
  77. package/lib/api/keys/din-keys.d.ts +3 -0
  78. package/lib/api/keys/din-keys.js +13 -0
  79. package/lib/api/keys/key-types.d.ts +17 -0
  80. package/lib/api/keys/key-types.js +1 -0
  81. package/lib/api/keys/keys.constants.d.ts +1 -0
  82. package/lib/api/keys/keys.constants.js +1 -0
  83. package/lib/api/knurls/ansi-knurls.constants.d.ts +4 -0
  84. package/lib/api/knurls/ansi-knurls.constants.js +8 -0
  85. package/lib/api/knurls/ansi-knurls.d.ts +3 -0
  86. package/lib/api/knurls/ansi-knurls.js +20 -0
  87. package/lib/api/knurls/din-knurls.constants.d.ts +2 -0
  88. package/lib/api/knurls/din-knurls.constants.js +2 -0
  89. package/lib/api/knurls/din-knurls.d.ts +3 -0
  90. package/lib/api/knurls/din-knurls.js +19 -0
  91. package/lib/api/knurls/knurl-types.d.ts +24 -0
  92. package/lib/api/knurls/knurl-types.js +1 -0
  93. package/lib/api/knurls/knurls.constants.d.ts +1 -0
  94. package/lib/api/knurls/knurls.constants.js +1 -0
  95. package/lib/api/knurls/knurls.d.ts +2 -0
  96. package/lib/api/knurls/knurls.js +9 -0
  97. package/lib/api/recipes/checks.d.ts +15 -0
  98. package/lib/api/recipes/checks.js +85 -0
  99. package/lib/api/recipes/limits.constants.d.ts +4 -0
  100. package/lib/api/recipes/limits.constants.js +4 -0
  101. package/lib/api/recipes/sources.d.ts +0 -13
  102. package/lib/api/recipes/sources.js +3 -15
  103. package/lib/api/recipes/surface-mesh.d.ts +0 -14
  104. package/lib/api/recipes/surface-mesh.js +8 -21
  105. package/lib/api/recipes/validate-brep.d.ts +2 -0
  106. package/lib/api/recipes/validate-brep.js +330 -0
  107. package/lib/api/recipes/validate.d.ts +0 -31
  108. package/lib/api/recipes/validate.js +7 -115
  109. package/lib/api/resolved-inputs/index.d.ts +80 -0
  110. package/lib/api/retaining-rings/ansi-retaining-rings.constants.d.ts +4 -0
  111. package/lib/api/retaining-rings/ansi-retaining-rings.constants.js +93 -0
  112. package/lib/api/retaining-rings/ansi-retaining-rings.d.ts +4 -0
  113. package/lib/api/retaining-rings/ansi-retaining-rings.js +20 -0
  114. package/lib/api/retaining-rings/din-retaining-rings.constants.d.ts +3 -0
  115. package/lib/api/retaining-rings/din-retaining-rings.constants.js +115 -0
  116. package/lib/api/retaining-rings/din-retaining-rings.d.ts +4 -0
  117. package/lib/api/retaining-rings/din-retaining-rings.js +20 -0
  118. package/lib/api/retaining-rings/retaining-ring-types.d.ts +30 -0
  119. package/lib/api/retaining-rings/retaining-ring-types.js +1 -0
  120. package/lib/api/retaining-rings/retaining-rings.constants.d.ts +1 -0
  121. package/lib/api/retaining-rings/retaining-rings.constants.js +1 -0
  122. package/lib/api/retaining-rings/retaining-rings.d.ts +2 -0
  123. package/lib/api/retaining-rings/retaining-rings.js +9 -0
  124. package/lib/api/services/base-bitbybit.d.ts +42 -0
  125. package/lib/api/services/base-bitbybit.js +43 -0
  126. package/lib/api/services/color.d.ts +35 -2
  127. package/lib/api/services/color.js +48 -12
  128. package/lib/api/services/engineering/engineering.d.ts +12 -0
  129. package/lib/api/services/engineering/engineering.js +13 -0
  130. package/lib/api/services/engineering/index.d.ts +2 -0
  131. package/lib/api/services/engineering/index.js +2 -0
  132. package/lib/api/services/engineering/mechanical/bearings-ansi.d.ts +40 -0
  133. package/lib/api/services/engineering/mechanical/bearings-ansi.js +47 -0
  134. package/lib/api/services/engineering/mechanical/bearings-iso.d.ts +39 -0
  135. package/lib/api/services/engineering/mechanical/bearings-iso.js +46 -0
  136. package/lib/api/services/engineering/mechanical/bearings.d.ts +14 -0
  137. package/lib/api/services/engineering/mechanical/bearings.js +15 -0
  138. package/lib/api/services/engineering/mechanical/fasteners-ansi.d.ts +109 -0
  139. package/lib/api/services/engineering/mechanical/fasteners-ansi.js +133 -0
  140. package/lib/api/services/engineering/mechanical/fasteners-iso.d.ts +123 -0
  141. package/lib/api/services/engineering/mechanical/fasteners-iso.js +151 -0
  142. package/lib/api/services/engineering/mechanical/fasteners.d.ts +13 -0
  143. package/lib/api/services/engineering/mechanical/fasteners.js +14 -0
  144. package/lib/api/services/engineering/mechanical/gears.d.ts +267 -0
  145. package/lib/api/services/engineering/mechanical/gears.js +318 -0
  146. package/lib/api/services/engineering/mechanical/index.d.ts +24 -0
  147. package/lib/api/services/engineering/mechanical/index.js +24 -0
  148. package/lib/api/services/engineering/mechanical/keys-ansi.d.ts +27 -0
  149. package/lib/api/services/engineering/mechanical/keys-ansi.js +32 -0
  150. package/lib/api/services/engineering/mechanical/keys-din.d.ts +26 -0
  151. package/lib/api/services/engineering/mechanical/keys-din.js +31 -0
  152. package/lib/api/services/engineering/mechanical/keys.d.ts +14 -0
  153. package/lib/api/services/engineering/mechanical/keys.js +15 -0
  154. package/lib/api/services/engineering/mechanical/knurls-ansi.d.ts +26 -0
  155. package/lib/api/services/engineering/mechanical/knurls-ansi.js +31 -0
  156. package/lib/api/services/engineering/mechanical/knurls-din.d.ts +26 -0
  157. package/lib/api/services/engineering/mechanical/knurls-din.js +31 -0
  158. package/lib/api/services/engineering/mechanical/knurls.d.ts +14 -0
  159. package/lib/api/services/engineering/mechanical/knurls.js +15 -0
  160. package/lib/api/services/engineering/mechanical/mechanical.d.ts +29 -0
  161. package/lib/api/services/engineering/mechanical/mechanical.js +30 -0
  162. package/lib/api/services/engineering/mechanical/retaining-rings-ansi.d.ts +43 -0
  163. package/lib/api/services/engineering/mechanical/retaining-rings-ansi.js +51 -0
  164. package/lib/api/services/engineering/mechanical/retaining-rings-din.d.ts +43 -0
  165. package/lib/api/services/engineering/mechanical/retaining-rings-din.js +51 -0
  166. package/lib/api/services/engineering/mechanical/retaining-rings.d.ts +13 -0
  167. package/lib/api/services/engineering/mechanical/retaining-rings.js +14 -0
  168. package/lib/api/services/engineering/mechanical/splines-ansi.d.ts +27 -0
  169. package/lib/api/services/engineering/mechanical/splines-ansi.js +32 -0
  170. package/lib/api/services/engineering/mechanical/splines-din.d.ts +26 -0
  171. package/lib/api/services/engineering/mechanical/splines-din.js +31 -0
  172. package/lib/api/services/engineering/mechanical/splines.d.ts +13 -0
  173. package/lib/api/services/engineering/mechanical/splines.js +14 -0
  174. package/lib/api/services/engineering/mechanical/springs.d.ts +27 -0
  175. package/lib/api/services/engineering/mechanical/springs.js +31 -0
  176. package/lib/api/services/engineering/mechanical/threads-ansi.d.ts +40 -0
  177. package/lib/api/services/engineering/mechanical/threads-ansi.js +48 -0
  178. package/lib/api/services/engineering/mechanical/threads-iso.d.ts +40 -0
  179. package/lib/api/services/engineering/mechanical/threads-iso.js +48 -0
  180. package/lib/api/services/engineering/mechanical/threads.d.ts +13 -0
  181. package/lib/api/services/engineering/mechanical/threads.js +14 -0
  182. package/lib/api/services/frame.js +3 -3
  183. package/lib/api/services/geometry-helper.js +8 -111
  184. package/lib/api/services/helpers/color/color-space.d.ts +2 -0
  185. package/lib/api/services/helpers/color/color-space.js +12 -0
  186. package/lib/api/services/helpers/{nurbs.d.ts → curves/nurbs.d.ts} +1 -1
  187. package/lib/api/services/helpers/{surface-triangulation.d.ts → curves/surface-triangulation.d.ts} +2 -2
  188. package/lib/api/services/helpers/{surface-triangulation.js → curves/surface-triangulation.js} +14 -8
  189. package/lib/api/services/helpers/{dxf → files/dxf}/dxf-generator.d.ts +2 -1
  190. package/lib/api/services/helpers/{dxf → files/dxf}/dxf-generator.js +19 -5
  191. package/lib/api/services/helpers/files/dxf/dxf.constants.d.ts +4 -0
  192. package/lib/api/services/helpers/files/dxf/dxf.constants.js +4 -0
  193. package/lib/api/services/helpers/{dxf → files/dxf}/dxf.d.ts +1 -1
  194. package/lib/api/services/helpers/{dxf → files/dxf}/dxf.js +2 -2
  195. package/lib/api/services/helpers/files/glb.constants.d.ts +11 -0
  196. package/lib/api/services/helpers/files/glb.constants.js +11 -0
  197. package/lib/api/services/helpers/files/glb.d.ts +1 -0
  198. package/lib/api/services/helpers/files/glb.js +69 -0
  199. package/lib/api/services/helpers/files/gzip.constants.d.ts +11 -0
  200. package/lib/api/services/helpers/files/gzip.constants.js +11 -0
  201. package/lib/api/services/helpers/files/gzip.d.ts +2 -0
  202. package/lib/api/services/helpers/files/gzip.js +50 -0
  203. package/lib/api/services/helpers/{inflate.constants.d.ts → files/inflate.constants.d.ts} +2 -0
  204. package/lib/api/services/helpers/{inflate.constants.js → files/inflate.constants.js} +2 -0
  205. package/lib/api/services/helpers/{inflate.d.ts → files/inflate.d.ts} +2 -2
  206. package/lib/api/services/helpers/{inflate.js → files/inflate.js} +16 -7
  207. package/lib/api/services/helpers/{zip.constants.d.ts → files/zip.constants.d.ts} +8 -0
  208. package/lib/api/services/helpers/{zip.constants.js → files/zip.constants.js} +8 -0
  209. package/lib/api/services/helpers/files/zip.d.ts +8 -0
  210. package/lib/api/services/helpers/files/zip.js +226 -0
  211. package/lib/api/services/helpers/geometry/arcs.d.ts +9 -0
  212. package/lib/api/services/helpers/{arcs.js → geometry/arcs.js} +7 -0
  213. package/lib/api/services/helpers/{frame-axes.d.ts → geometry/frame-axes.d.ts} +8 -5
  214. package/lib/api/services/helpers/{frame-axes.js → geometry/frame-axes.js} +21 -9
  215. package/lib/api/services/helpers/geometry/lengths.constants.d.ts +4 -0
  216. package/lib/api/services/helpers/geometry/lengths.constants.js +3 -0
  217. package/lib/api/services/helpers/geometry/lengths.d.ts +7 -0
  218. package/lib/api/services/helpers/geometry/lengths.js +20 -0
  219. package/lib/api/services/helpers/geometry/matrices.constants.d.ts +8 -0
  220. package/lib/api/services/helpers/geometry/matrices.constants.js +7 -0
  221. package/lib/api/services/helpers/geometry/matrices.d.ts +17 -0
  222. package/lib/api/services/helpers/{matrices.js → geometry/matrices.js} +28 -17
  223. package/lib/api/services/helpers/{paths.d.ts → geometry/paths.d.ts} +2 -1
  224. package/lib/api/services/helpers/{paths.js → geometry/paths.js} +36 -30
  225. package/lib/api/services/helpers/{polygons.d.ts → geometry/polygons.d.ts} +1 -1
  226. package/lib/api/services/helpers/geometry/polygons.js +111 -0
  227. package/lib/api/services/helpers/geometry/scalars.d.ts +9 -0
  228. package/lib/api/services/helpers/geometry/scalars.js +34 -0
  229. package/lib/api/services/helpers/{triangulation.js → geometry/triangulation.js} +11 -6
  230. package/lib/api/services/helpers/geometry/vector-grid.d.ts +12 -0
  231. package/lib/api/services/helpers/geometry/vector-grid.js +149 -0
  232. package/lib/api/services/helpers/{vectors.d.ts → geometry/vectors.d.ts} +8 -1
  233. package/lib/api/services/helpers/geometry/vectors.js +43 -0
  234. package/lib/api/services/helpers/helper-types.d.ts +77 -0
  235. package/lib/api/services/helpers/mesh/mesh-normals.d.ts +21 -0
  236. package/lib/api/services/helpers/{mesh-normals.js → mesh/mesh-normals.js} +54 -65
  237. package/lib/api/services/helpers/mesh/mesh-orientation.d.ts +24 -0
  238. package/lib/api/services/helpers/mesh/mesh-orientation.js +104 -0
  239. package/lib/api/services/helpers/{mesh-primitives.d.ts → mesh/mesh-primitives.d.ts} +1 -1
  240. package/lib/api/services/helpers/{mesh-primitives.js → mesh/mesh-primitives.js} +6 -5
  241. package/lib/api/services/helpers/mesh/mesh-proximity.constants.d.ts +7 -0
  242. package/lib/api/services/helpers/mesh/mesh-proximity.constants.js +11 -0
  243. package/lib/api/services/helpers/mesh/mesh-proximity.d.ts +11 -0
  244. package/lib/api/services/helpers/mesh/mesh-proximity.js +382 -0
  245. package/lib/api/services/index.d.ts +3 -0
  246. package/lib/api/services/index.js +3 -0
  247. package/lib/api/services/io.d.ts +1 -1
  248. package/lib/api/services/io.js +1 -1
  249. package/lib/api/services/line.js +2 -3
  250. package/lib/api/services/math.d.ts +47 -0
  251. package/lib/api/services/math.js +77 -10
  252. package/lib/api/services/mesh.d.ts +174 -2
  253. package/lib/api/services/mesh.js +305 -7
  254. package/lib/api/services/point.js +4 -10
  255. package/lib/api/services/polyline-types.d.ts +6 -0
  256. package/lib/api/services/polyline-types.js +1 -0
  257. package/lib/api/services/polyline.d.ts +163 -1
  258. package/lib/api/services/polyline.js +270 -13
  259. package/lib/api/services/recipes.d.ts +80 -0
  260. package/lib/api/services/recipes.js +107 -0
  261. package/lib/api/services/transforms.d.ts +74 -2
  262. package/lib/api/services/transforms.js +100 -3
  263. package/lib/api/services/vector.d.ts +4 -3
  264. package/lib/api/services/vector.js +14 -14
  265. package/lib/api/splines/ansi-splines.constants.d.ts +9 -0
  266. package/lib/api/splines/ansi-splines.constants.js +9 -0
  267. package/lib/api/splines/ansi-splines.d.ts +3 -0
  268. package/lib/api/splines/ansi-splines.js +28 -0
  269. package/lib/api/splines/din-splines.constants.d.ts +12 -0
  270. package/lib/api/splines/din-splines.constants.js +12 -0
  271. package/lib/api/splines/din-splines.d.ts +3 -0
  272. package/lib/api/splines/din-splines.js +38 -0
  273. package/lib/api/splines/spline-types.d.ts +32 -0
  274. package/lib/api/splines/spline-types.js +1 -0
  275. package/lib/api/splines/splines.constants.d.ts +1 -0
  276. package/lib/api/splines/splines.constants.js +1 -0
  277. package/lib/api/springs/spring-types.d.ts +26 -0
  278. package/lib/api/springs/spring-types.js +1 -0
  279. package/lib/api/springs/springs.constants.d.ts +9 -0
  280. package/lib/api/springs/springs.constants.js +9 -0
  281. package/lib/api/springs/springs.d.ts +2 -0
  282. package/lib/api/springs/springs.js +50 -0
  283. package/lib/api/threads/ansi-threads.constants.d.ts +6 -0
  284. package/lib/api/threads/ansi-threads.constants.js +27 -0
  285. package/lib/api/threads/ansi-threads.d.ts +4 -0
  286. package/lib/api/threads/ansi-threads.js +50 -0
  287. package/lib/api/threads/iso-threads.constants.d.ts +5 -0
  288. package/lib/api/threads/iso-threads.constants.js +20 -0
  289. package/lib/api/threads/iso-threads.d.ts +4 -0
  290. package/lib/api/threads/iso-threads.js +32 -0
  291. package/lib/api/threads/thread-profile.constants.d.ts +3 -0
  292. package/lib/api/threads/thread-profile.constants.js +3 -0
  293. package/lib/api/threads/thread-types.d.ts +66 -0
  294. package/lib/api/threads/thread-types.js +1 -0
  295. package/package.json +1 -1
  296. package/lib/api/recipes/index.d.ts +0 -4
  297. package/lib/api/recipes/index.js +0 -3
  298. package/lib/api/services/helpers/arcs.d.ts +0 -6
  299. package/lib/api/services/helpers/matrices.constants.d.ts +0 -2
  300. package/lib/api/services/helpers/matrices.constants.js +0 -2
  301. package/lib/api/services/helpers/matrices.d.ts +0 -25
  302. package/lib/api/services/helpers/mesh-normals.d.ts +0 -11
  303. package/lib/api/services/helpers/polygons.js +0 -59
  304. package/lib/api/services/helpers/vectors.js +0 -17
  305. package/lib/api/services/helpers/zip.d.ts +0 -4
  306. package/lib/api/services/helpers/zip.js +0 -89
  307. /package/lib/api/services/helpers/{nurbs.js → curves/nurbs.js} +0 -0
  308. /package/lib/api/services/helpers/{crc32.d.ts → files/crc32.d.ts} +0 -0
  309. /package/lib/api/services/helpers/{crc32.js → files/crc32.js} +0 -0
  310. /package/lib/api/services/helpers/{triangulation.d.ts → geometry/triangulation.d.ts} +0 -0
  311. /package/lib/api/services/helpers/{mesh-measures.d.ts → mesh/mesh-measures.d.ts} +0 -0
  312. /package/lib/api/services/helpers/{mesh-measures.js → mesh/mesh-measures.js} +0 -0
  313. /package/lib/api/services/helpers/{mesh-primitives.constants.d.ts → mesh/mesh-primitives.constants.d.ts} +0 -0
  314. /package/lib/api/services/helpers/{mesh-primitives.constants.js → mesh/mesh-primitives.constants.js} +0 -0
@@ -0,0 +1,330 @@
1
+ import { isRecord } from "../kernel-calls/unknown-values";
2
+ import { cross3, length3 } from "../services/helpers/geometry/vectors";
3
+ import { COORDINATE_RANGE, coordinates, extent, isCount, range, reference, report, vector } from "./checks";
4
+ import { MAX_BREP_DEGREE, MAX_BREP_ITEMS, PARALLEL_SINE, POINT3_SIZE, QUARTER_TURN } from "./limits.constants";
5
+ const SOLID = ["solid"];
6
+ function list(checker, value, path, minimum) {
7
+ if (!Array.isArray(value) || value.length < minimum || value.length > MAX_BREP_ITEMS) {
8
+ report(checker.issues, path, `must be a list of ${minimum > 0 ? `at least ${minimum} and ` : ""}at most ${MAX_BREP_ITEMS} items`);
9
+ return [];
10
+ }
11
+ return value;
12
+ }
13
+ function index(checker, value, count, path, what) {
14
+ if (!isCount(value) || value >= count) {
15
+ report(checker.issues, path, count === 0 ? `must be the index of one of the node's ${what}, and it has none` : `must be the index of one of the node's ${what}, from 0 to ${count - 1}`);
16
+ return false;
17
+ }
18
+ return true;
19
+ }
20
+ function nonNegative(checker, value, path) {
21
+ if (typeof value !== "number" || !Number.isFinite(value) || value < 0 || value > Number.MAX_SAFE_INTEGER) {
22
+ report(checker.issues, path, "must be a finite number of zero or more");
23
+ }
24
+ }
25
+ function checkPlacement(checker, value, path) {
26
+ if (!coordinates(value["origin"], POINT3_SIZE)) {
27
+ report(checker.issues, `${path}.origin`, `must be three numbers, each ${COORDINATE_RANGE}`);
28
+ }
29
+ vector(checker.issues, value["axis"], `${path}.axis`, true);
30
+ vector(checker.issues, value["xDirection"], `${path}.xDirection`, true);
31
+ const axis = value["axis"];
32
+ const x = value["xDirection"];
33
+ if (coordinates(axis, POINT3_SIZE) && coordinates(x, POINT3_SIZE)) {
34
+ const [along, across] = [axis, x];
35
+ const sine = length3(cross3(along, across)) / (length3(along) * length3(across));
36
+ if (!(sine > PARALLEL_SINE)) {
37
+ report(checker.issues, `${path}.xDirection`, "lies along the axis, so it gives no X direction");
38
+ }
39
+ }
40
+ }
41
+ function isMultiplicity(value, highest) {
42
+ return typeof value === "number" && Number.isSafeInteger(value) && value >= 1 && value <= highest;
43
+ }
44
+ function checkKnots(checker, knots, multiplicities, degree, count, path, names) {
45
+ const [knotsName, multiplicitiesName] = names;
46
+ const knotRange = range(checker, knots, checker.buffers.f64.length, 1, 2, `${path}.${knotsName}`);
47
+ if (!Array.isArray(multiplicities) || multiplicities.length > MAX_BREP_ITEMS || !multiplicities.every((value, at) => isMultiplicity(value, at === 0 || at === multiplicities.length - 1 ? degree + 1 : degree))) {
48
+ report(checker.issues, `${path}.${multiplicitiesName}`, `must be a list of whole numbers, one per knot: from 1 to ${degree + 1} at the ends and at most ${degree} between them`);
49
+ return;
50
+ }
51
+ if (knotRange === undefined) {
52
+ return;
53
+ }
54
+ const [start, length] = knotRange;
55
+ if (multiplicities.length !== length) {
56
+ report(checker.issues, `${path}.${multiplicitiesName}`, `must hold one multiplicity per knot, ${length}`);
57
+ return;
58
+ }
59
+ for (let at = start + 1; at < start + length; at++) {
60
+ if (!(checker.buffers.f64[at] > checker.buffers.f64[at - 1])) {
61
+ report(checker.issues, `${path}.${knotsName}`, "must rise from one knot to the next");
62
+ return;
63
+ }
64
+ }
65
+ const total = multiplicities.reduce((sum, value) => sum + value, 0);
66
+ if (total !== count + degree + 1) {
67
+ report(checker.issues, `${path}.${multiplicitiesName}`, `must add up to ${count + degree + 1}, the ${count} control points plus the degree plus one, not ${total}`);
68
+ }
69
+ }
70
+ function checkWeights(checker, weights, count, path) {
71
+ if (weights === undefined) {
72
+ return;
73
+ }
74
+ const weightRange = range(checker, weights, checker.buffers.f64.length, 1, 1, path);
75
+ if (weightRange === undefined) {
76
+ return;
77
+ }
78
+ const [start, length] = weightRange;
79
+ if (length !== count) {
80
+ report(checker.issues, path, `must hold one weight per control point, ${count}`);
81
+ return;
82
+ }
83
+ for (let at = start; at < start + length; at++) {
84
+ if (!(checker.buffers.f64[at] > 0)) {
85
+ report(checker.issues, path, "must hold weights above zero");
86
+ return;
87
+ }
88
+ }
89
+ }
90
+ function degreeOf(checker, value, path) {
91
+ if (!isMultiplicity(value, MAX_BREP_DEGREE)) {
92
+ report(checker.issues, path, `must be a whole number from 1 to ${MAX_BREP_DEGREE}`);
93
+ return 0;
94
+ }
95
+ return value;
96
+ }
97
+ function checkSplineCurve(checker, curve, path) {
98
+ const degree = degreeOf(checker, curve["degree"], `${path}.degree`);
99
+ const points = range(checker, curve["points"], checker.buffers.f64.length, POINT3_SIZE, POINT3_SIZE * (degree + 1), `${path}.points`);
100
+ if (degree === 0 || points === undefined) {
101
+ return;
102
+ }
103
+ const count = points[1] / POINT3_SIZE;
104
+ checkWeights(checker, curve["weights"], count, `${path}.weights`);
105
+ checkKnots(checker, curve["knots"], curve["multiplicities"], degree, count, path, ["knots", "multiplicities"]);
106
+ }
107
+ function checkCurve(checker, curve, path) {
108
+ if (!isRecord(curve)) {
109
+ report(checker.issues, path, "must be an object with a kind");
110
+ return;
111
+ }
112
+ switch (curve["kind"]) {
113
+ case "line":
114
+ if (!coordinates(curve["origin"], POINT3_SIZE)) {
115
+ report(checker.issues, `${path}.origin`, `must be three numbers, each ${COORDINATE_RANGE}`);
116
+ }
117
+ vector(checker.issues, curve["direction"], `${path}.direction`, true);
118
+ return;
119
+ case "circle":
120
+ checkPlacement(checker, curve, path);
121
+ extent(checker.issues, curve["radius"], `${path}.radius`);
122
+ return;
123
+ case "ellipse":
124
+ checkPlacement(checker, curve, path);
125
+ extent(checker.issues, curve["xRadius"], `${path}.xRadius`);
126
+ extent(checker.issues, curve["yRadius"], `${path}.yRadius`);
127
+ return;
128
+ case "bspline":
129
+ checkSplineCurve(checker, curve, path);
130
+ return;
131
+ default:
132
+ report(checker.issues, `${path}.kind`, `'${String(curve["kind"])}' is not a curve a brep node knows`);
133
+ }
134
+ }
135
+ function checkSplineSurface(checker, surface, path) {
136
+ const uDegree = degreeOf(checker, surface["uDegree"], `${path}.uDegree`);
137
+ const vDegree = degreeOf(checker, surface["vDegree"], `${path}.vDegree`);
138
+ const uCount = surface["uCount"];
139
+ const vCount = surface["vCount"];
140
+ if (!isCount(uCount) || uCount < uDegree + 1) {
141
+ report(checker.issues, `${path}.uCount`, `must be a whole number of at least ${uDegree + 1}, the degree along u plus one`);
142
+ return;
143
+ }
144
+ if (!isCount(vCount) || vCount < vDegree + 1) {
145
+ report(checker.issues, `${path}.vCount`, `must be a whole number of at least ${vDegree + 1}, the degree along v plus one`);
146
+ return;
147
+ }
148
+ const points = range(checker, surface["points"], checker.buffers.f64.length, POINT3_SIZE, POINT3_SIZE, `${path}.points`);
149
+ if (points !== undefined && points[1] !== uCount * vCount * POINT3_SIZE) {
150
+ report(checker.issues, `${path}.points`, `must hold uCount times vCount control points, ${uCount * vCount}`);
151
+ }
152
+ checkWeights(checker, surface["weights"], uCount * vCount, `${path}.weights`);
153
+ if (uDegree > 0) {
154
+ checkKnots(checker, surface["uKnots"], surface["uMultiplicities"], uDegree, uCount, path, ["uKnots", "uMultiplicities"]);
155
+ }
156
+ if (vDegree > 0) {
157
+ checkKnots(checker, surface["vKnots"], surface["vMultiplicities"], vDegree, vCount, path, ["vKnots", "vMultiplicities"]);
158
+ }
159
+ }
160
+ function checkSurface(checker, surface, curves, path) {
161
+ if (!isRecord(surface)) {
162
+ report(checker.issues, path, "must be an object with a kind");
163
+ return;
164
+ }
165
+ switch (surface["kind"]) {
166
+ case "plane":
167
+ checkPlacement(checker, surface, path);
168
+ return;
169
+ case "cylinder":
170
+ case "sphere":
171
+ checkPlacement(checker, surface, path);
172
+ extent(checker.issues, surface["radius"], `${path}.radius`);
173
+ return;
174
+ case "cone": {
175
+ checkPlacement(checker, surface, path);
176
+ nonNegative(checker, surface["radius"], `${path}.radius`);
177
+ const angle = surface["semiAngle"];
178
+ if (typeof angle !== "number" || !(angle > 0) || !(angle < QUARTER_TURN)) {
179
+ report(checker.issues, `${path}.semiAngle`, "must be an angle in radians above zero and below a quarter turn");
180
+ }
181
+ return;
182
+ }
183
+ case "torus":
184
+ checkPlacement(checker, surface, path);
185
+ extent(checker.issues, surface["majorRadius"], `${path}.majorRadius`);
186
+ extent(checker.issues, surface["minorRadius"], `${path}.minorRadius`);
187
+ return;
188
+ case "bspline":
189
+ checkSplineSurface(checker, surface, path);
190
+ return;
191
+ case "revolution":
192
+ index(checker, surface["curve"], curves, `${path}.curve`, "curves");
193
+ if (!coordinates(surface["origin"], POINT3_SIZE)) {
194
+ report(checker.issues, `${path}.origin`, `must be three numbers, each ${COORDINATE_RANGE}`);
195
+ }
196
+ vector(checker.issues, surface["axis"], `${path}.axis`, true);
197
+ return;
198
+ case "extrusion":
199
+ index(checker, surface["curve"], curves, `${path}.curve`, "curves");
200
+ vector(checker.issues, surface["direction"], `${path}.direction`, true);
201
+ return;
202
+ default:
203
+ report(checker.issues, `${path}.kind`, `'${String(surface["kind"])}' is not a surface a brep node knows`);
204
+ }
205
+ }
206
+ function checkEdge(checker, edge, sizes, path) {
207
+ if (!isRecord(edge)) {
208
+ report(checker.issues, path, "must be an object with a curve, a start and an end");
209
+ return undefined;
210
+ }
211
+ index(checker, edge["curve"], sizes.curves, `${path}.curve`, "curves");
212
+ const start = index(checker, edge["start"], sizes.vertices, `${path}.start`, "vertices") ? edge["start"] : undefined;
213
+ const end = index(checker, edge["end"], sizes.vertices, `${path}.end`, "vertices") ? edge["end"] : undefined;
214
+ if (edge["sameSense"] !== undefined && typeof edge["sameSense"] !== "boolean") {
215
+ report(checker.issues, `${path}.sameSense`, "must be true or false, or be left out");
216
+ }
217
+ const parameters = edge["parameters"];
218
+ if (parameters !== undefined && (!Array.isArray(parameters) || parameters.length !== 2 || !parameters.every((value) => typeof value === "number" && Number.isFinite(value)) || parameters[0] === parameters[1])) {
219
+ report(checker.issues, `${path}.parameters`, "must be two different finite numbers, or be left out");
220
+ }
221
+ return start === undefined || end === undefined ? undefined : { start, end };
222
+ }
223
+ function checkBound(checker, bound, ends, path) {
224
+ if (!isRecord(bound)) {
225
+ report(checker.issues, path, "must be an object with outer, edges and forward");
226
+ return false;
227
+ }
228
+ if (typeof bound["outer"] !== "boolean") {
229
+ report(checker.issues, `${path}.outer`, "must be true or false");
230
+ }
231
+ const edges = list(checker, bound["edges"], `${path}.edges`, 1);
232
+ const forward = bound["forward"];
233
+ if (!Array.isArray(forward) || forward.length !== edges.length || !forward.every((value) => typeof value === "boolean")) {
234
+ report(checker.issues, `${path}.forward`, `must be a list of ${edges.length} true or false values, one per edge`);
235
+ return bound["outer"] === true;
236
+ }
237
+ const uses = edges.map((edge, at) => {
238
+ if (!index(checker, edge, ends.length, `${path}.edges[${at}]`, "edges")) {
239
+ return undefined;
240
+ }
241
+ const known = ends[edge];
242
+ return known && (forward[at] ? known : { start: known.end, end: known.start });
243
+ });
244
+ for (let at = 0; at < uses.length; at++) {
245
+ const here = uses[at];
246
+ const next = uses[(at + 1) % uses.length];
247
+ if (here && next && here.end !== next.start) {
248
+ report(checker.issues, `${path}.edges[${at}]`, `ends at vertex ${here.end}, but the next edge of the loop starts at vertex ${next.start}`);
249
+ break;
250
+ }
251
+ }
252
+ return bound["outer"] === true;
253
+ }
254
+ function checkFace(checker, face, sizes, ends, path) {
255
+ if (!isRecord(face)) {
256
+ report(checker.issues, path, "must be an object with a surface, sameSense and bounds");
257
+ return;
258
+ }
259
+ index(checker, face["surface"], sizes.surfaces, `${path}.surface`, "surfaces");
260
+ if (typeof face["sameSense"] !== "boolean") {
261
+ report(checker.issues, `${path}.sameSense`, "must be true or false");
262
+ }
263
+ const bounds = list(checker, face["bounds"], `${path}.bounds`, 1);
264
+ let outer = 0;
265
+ bounds.forEach((bound, at) => {
266
+ outer += checkBound(checker, bound, ends, `${path}.bounds[${at}]`) ? 1 : 0;
267
+ });
268
+ if (outer > 1) {
269
+ report(checker.issues, `${path}.bounds`, `must hold at most one outer bound, not ${outer}`);
270
+ }
271
+ }
272
+ function checkShell(checker, shell, faces, used, path) {
273
+ const listed = list(checker, shell, path, 1);
274
+ listed.forEach((face, at) => {
275
+ if (index(checker, face, faces, `${path}[${at}]`, "faces")) {
276
+ if (used.has(face)) {
277
+ report(checker.issues, `${path}[${at}]`, `names face ${face}, which another shell already holds`);
278
+ }
279
+ used.add(face);
280
+ }
281
+ });
282
+ }
283
+ function checkSolids(checker, value, faces, path, closed) {
284
+ if (!closed) {
285
+ report(checker.issues, path, "must be left out of a node whose faces do not close a volume");
286
+ return;
287
+ }
288
+ const used = new Set();
289
+ list(checker, value, path, 1).forEach((solid, at) => {
290
+ if (!isRecord(solid)) {
291
+ report(checker.issues, `${path}[${at}]`, "must be an object with an outer shell");
292
+ return;
293
+ }
294
+ checkShell(checker, solid["outer"], faces, used, `${path}[${at}].outer`);
295
+ if (solid["voids"] !== undefined) {
296
+ list(checker, solid["voids"], `${path}[${at}].voids`, 0).forEach((shell, shellAt) => {
297
+ checkShell(checker, shell, faces, used, `${path}[${at}].voids[${shellAt}]`);
298
+ });
299
+ }
300
+ });
301
+ const missing = Array.isArray(value) ? Array.from({ length: faces }, (_, face) => face).find((face) => !used.has(face)) : undefined;
302
+ if (missing !== undefined) {
303
+ report(checker.issues, path, `must place each of the node's faces in a shell, and leaves face ${missing} out`);
304
+ }
305
+ }
306
+ export function checkBrep(checker, node, at, path) {
307
+ const vertices = range(checker, node["vertices"], checker.buffers.f64.length, POINT3_SIZE, POINT3_SIZE, `${path}.vertices`);
308
+ const curves = list(checker, node["curves"], `${path}.curves`, 0);
309
+ const surfaces = list(checker, node["surfaces"], `${path}.surfaces`, 0);
310
+ const edges = list(checker, node["edges"], `${path}.edges`, 0);
311
+ const faces = list(checker, node["faces"], `${path}.faces`, 1);
312
+ const sizes = { vertices: vertices === undefined ? 0 : vertices[1] / POINT3_SIZE, curves: curves.length, surfaces: surfaces.length, edges: edges.length };
313
+ curves.forEach((curve, item) => {
314
+ checkCurve(checker, curve, `${path}.curves[${item}]`);
315
+ });
316
+ surfaces.forEach((surface, item) => {
317
+ checkSurface(checker, surface, sizes.curves, `${path}.surfaces[${item}]`);
318
+ });
319
+ const ends = edges.map((edge, item) => checkEdge(checker, edge, sizes, `${path}.edges[${item}]`));
320
+ faces.forEach((face, item) => {
321
+ checkFace(checker, face, sizes, ends, `${path}.faces[${item}]`);
322
+ });
323
+ if (typeof node["closed"] !== "boolean") {
324
+ report(checker.issues, `${path}.closed`, "must be true or false");
325
+ }
326
+ if (node["solids"] !== undefined) {
327
+ checkSolids(checker, node["solids"], faces.length, `${path}.solids`, node["closed"] === true);
328
+ }
329
+ return node["fallback"] === undefined ? 0 : reference(checker, node["fallback"], at, SOLID, `${path}.fallback`);
330
+ }
@@ -1,36 +1,5 @@
1
1
  import type { Base } from "../inputs/base-inputs";
2
2
  import type { RecipeIssue } from "./recipe-types";
3
- /**
4
- * Checks that a value is a recipe an executor can safely run: every index refers to an earlier
5
- * node of the right kind, every range lies inside its buffer, every coordinate of a profile or an
6
- * extrusion is finite and between minus and plus one billion, every placement (a matrix or a
7
- * half-space's origin) between minus and plus ten trillion, every matrix moves, turns, mirrors and
8
- * scales without flattening, and no list, total or nesting exceeds its limit. A recipe that comes from another thread, a file or a caller is
9
- * checked before any kernel touches it.
10
- *
11
- * Experimental: the recipe format may still change before it is declared stable.
12
- * @param recipe - The value to check
13
- * @returns What is wrong with it, at most a hundred issues, empty when nothing is
14
- * @beta
15
- */
16
3
  export declare function checkRecipe(recipe: unknown): RecipeIssue[];
17
- /**
18
- * Throws an `InputError` when a value is not a recipe an executor can safely run, naming the first
19
- * three problems `checkRecipe` finds.
20
- *
21
- * Experimental: the recipe format may still change before it is declared stable.
22
- * @param recipe - The value to check
23
- * @beta
24
- */
25
4
  export declare function assertRecipe(recipe: unknown): asserts recipe is Base.Recipe;
26
- /**
27
- * Reads a value as a recipe an executor can run, taking its buffers as lists of numbers too, as JSON
28
- * carries them: such lists become the typed arrays the format holds, and the result is checked as
29
- * `assertRecipe` checks it. The value it is given is left as it was.
30
- *
31
- * Experimental: the recipe format may still change before it is declared stable.
32
- * @param value - The recipe, its buffers typed arrays or lists of numbers
33
- * @returns The recipe with typed buffers
34
- * @beta
35
- */
36
5
  export declare function toRecipe(value: unknown): Base.Recipe;
@@ -1,11 +1,12 @@
1
1
  import { InputError } from "../kernel-calls/errors";
2
2
  import { isRecord } from "../kernel-calls/unknown-values";
3
- import { linearDeterminant } from "../services/helpers/matrices";
4
- import { DEGENERATE_DETERMINANT, FULL_TURN, INT32_HIGHEST, INT32_LOWEST, ISSUES_IN_MESSAGE, MATRIX_SIZE, MAX_BUFFER_LENGTH, MAX_ISSUES, MAX_RECIPE_COORDINATE, MAX_RECIPE_DEPTH, MAX_RECIPE_NODES, MAX_RECIPE_PLACEMENT, MAX_RECIPE_GROUPS, MAX_RECIPE_ROOTS, MAX_REFERENCED_NUMBERS, MIN_INTERSECTED, MIN_LOFT_FRAMES, MIN_POLYGON_NUMBERS, POINT2_SIZE, POINT3_SIZE, RECIPE_FORMAT, RECIPE_VERSION, TRIANGLE_CORNERS, } from "./limits.constants";
3
+ import { linearDeterminant } from "../services/helpers/geometry/matrices";
4
+ import { checkBrep } from "./validate-brep";
5
+ import { COORDINATE_RANGE, coordinates, extent, isCoordinate, isCount, positive, range, reference, references, report, vector } from "./checks";
6
+ import { DEGENERATE_DETERMINANT, FULL_TURN, INT32_HIGHEST, INT32_LOWEST, ISSUES_IN_MESSAGE, MATRIX_SIZE, MAX_BUFFER_LENGTH, MAX_RECIPE_DEPTH, MAX_RECIPE_NODES, MAX_RECIPE_PLACEMENT, MAX_RECIPE_GROUPS, MAX_RECIPE_ROOTS, MAX_REFERENCED_NUMBERS, MIN_INTERSECTED, MIN_LOFT_FRAMES, MIN_POLYGON_NUMBERS, POINT2_SIZE, POINT3_SIZE, RECIPE_FORMAT, RECIPE_VERSION, TRIANGLE_CORNERS, } from "./limits.constants";
5
7
  const PROFILE = ["profile"];
6
8
  const SOLID = ["solid"];
7
9
  const CUTTING_TOOL = ["solid", "halfSpace"];
8
- const COORDINATE_RANGE = `from -${MAX_RECIPE_COORDINATE} to ${MAX_RECIPE_COORDINATE}`;
9
10
  const PLACEMENT_RANGE = `from -${MAX_RECIPE_PLACEMENT} to ${MAX_RECIPE_PLACEMENT}`;
10
11
  const UNKNOWN_NODE = { kind: undefined, depth: 0 };
11
12
  const TYPED_ARRAY_PROTOTYPE = Object.getPrototypeOf(Int8Array.prototype);
@@ -18,46 +19,6 @@ function isFloat64Array(value) {
18
19
  function isInt32Array(value) {
19
20
  return value instanceof Int32Array || typedArrayNameOf(value) === "Int32Array";
20
21
  }
21
- function report(issues, path, message) {
22
- if (issues.length < MAX_ISSUES) {
23
- issues.push({ path, message });
24
- }
25
- }
26
- function isCoordinate(value, limit = MAX_RECIPE_COORDINATE) {
27
- return typeof value === "number" && Math.abs(value) <= limit;
28
- }
29
- function coordinates(value, size, limit = MAX_RECIPE_COORDINATE) {
30
- if (!Array.isArray(value) || value.length !== size) {
31
- return false;
32
- }
33
- for (let index = 0; index < size; index++) {
34
- if (!isCoordinate(value[index], limit)) {
35
- return false;
36
- }
37
- }
38
- return true;
39
- }
40
- function isCount(value) {
41
- return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
42
- }
43
- function positive(issues, value, path) {
44
- if (typeof value !== "number" || !Number.isFinite(value) || !(value > 0)) {
45
- report(issues, path, "must be a finite number above zero");
46
- }
47
- }
48
- function extent(issues, value, path) {
49
- if (!isCoordinate(value) || !(value > 0)) {
50
- report(issues, path, `must be a number above zero and at most ${MAX_RECIPE_COORDINATE}`);
51
- }
52
- }
53
- function vector(issues, value, path, nonZero) {
54
- if (!coordinates(value, POINT3_SIZE)) {
55
- report(issues, path, `must be three numbers, each ${COORDINATE_RANGE}`);
56
- }
57
- else if (nonZero && value.every((item) => item === 0)) {
58
- report(issues, path, "must not be a zero vector");
59
- }
60
- }
61
22
  function isAffine(matrix) {
62
23
  return matrix[3] === 0 && matrix[7] === 0 && matrix[11] === 0 && matrix[15] === 1;
63
24
  }
@@ -135,46 +96,6 @@ function checkCoordinates(issues, f64) {
135
96
  }
136
97
  }
137
98
  }
138
- function range(checker, value, length, multiple, minimum, path) {
139
- if (!Array.isArray(value) || value.length !== 2 || !isCount(value[0]) || !isCount(value[1])) {
140
- report(checker.issues, path, "must be a range of two whole numbers, a start and a count");
141
- return undefined;
142
- }
143
- const checked = value;
144
- const [start, count] = checked;
145
- if (start + count > length) {
146
- report(checker.issues, path, `runs past the end of its buffer, which holds ${length} numbers`);
147
- return undefined;
148
- }
149
- if (count % multiple !== 0 || count < minimum) {
150
- report(checker.issues, path, `must hold a multiple of ${multiple} numbers, at least ${minimum}`);
151
- return undefined;
152
- }
153
- checker.referenced += count;
154
- return checked;
155
- }
156
- function reference(checker, value, at, accepted, path) {
157
- if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0 || value >= at) {
158
- report(checker.issues, path, at === 0 ? "must be the index of an earlier node, and none comes before it" : `must be the index of an earlier node, from 0 to ${at - 1}`);
159
- return 0;
160
- }
161
- const kind = checker.kinds[value];
162
- if (kind !== undefined && !accepted.includes(kind)) {
163
- report(checker.issues, path, `refers to a ${kind} node where ${accepted.join(" or ")} is needed`);
164
- }
165
- return checker.depths[value];
166
- }
167
- function references(checker, value, at, accepted, path, allowEmpty) {
168
- if (!Array.isArray(value) || (!allowEmpty && value.length === 0)) {
169
- report(checker.issues, path, allowEmpty ? "must be a list of node indices" : "must be a list of at least one node index");
170
- return 0;
171
- }
172
- let deepest = 0;
173
- for (let index = 0; index < value.length; index++) {
174
- deepest = Math.max(deepest, reference(checker, value[index], at, accepted, `${path}[${index}]`));
175
- }
176
- return deepest;
177
- }
178
99
  function checkCorners(checker, positions, indices, path) {
179
100
  const vertices = positions[1] / POINT3_SIZE;
180
101
  const [start, count] = indices;
@@ -268,6 +189,8 @@ function checkNode(checker, node, at) {
268
189
  return summary("solid", checkRevolve(checker, node, at, path));
269
190
  case "loft":
270
191
  return summary("solid", checkLoft(checker, node, at, path));
192
+ case "brep":
193
+ return summary("solid", checkBrep(checker, node, at, path));
271
194
  default:
272
195
  report(issues, `${path}.op`, `'${String(node["op"])}' is not an operation recipes know`);
273
196
  return UNKNOWN_NODE;
@@ -325,19 +248,6 @@ function checkGroups(issues, groups) {
325
248
  checkGroupIndex(issues, group["parent"], index, `${path}.parent`, index === 0 ? "no group comes before the first one" : "an earlier group");
326
249
  }
327
250
  }
328
- /**
329
- * Checks that a value is a recipe an executor can safely run: every index refers to an earlier
330
- * node of the right kind, every range lies inside its buffer, every coordinate of a profile or an
331
- * extrusion is finite and between minus and plus one billion, every placement (a matrix or a
332
- * half-space's origin) between minus and plus ten trillion, every matrix moves, turns, mirrors and
333
- * scales without flattening, and no list, total or nesting exceeds its limit. A recipe that comes from another thread, a file or a caller is
334
- * checked before any kernel touches it.
335
- *
336
- * Experimental: the recipe format may still change before it is declared stable.
337
- * @param recipe - The value to check
338
- * @returns What is wrong with it, at most a hundred issues, empty when nothing is
339
- * @beta
340
- */
341
251
  export function checkRecipe(recipe) {
342
252
  var _a;
343
253
  const issues = [];
@@ -349,7 +259,7 @@ export function checkRecipe(recipe) {
349
259
  report(issues, "format", `must be ${RECIPE_FORMAT} version ${RECIPE_VERSION}`);
350
260
  }
351
261
  positive(issues, recipe["millimetresPerUnit"], "millimetresPerUnit");
352
- positive(issues, recipe["tolerance"], "tolerance");
262
+ extent(issues, recipe["tolerance"], "tolerance");
353
263
  const buffers = recipe["buffers"];
354
264
  const f64 = isRecord(buffers) ? buffers["f64"] : undefined;
355
265
  const i32 = isRecord(buffers) ? buffers["i32"] : undefined;
@@ -383,14 +293,6 @@ export function checkRecipe(recipe) {
383
293
  checkRoots(checker, roots, nodes.length, groups.length);
384
294
  return issues;
385
295
  }
386
- /**
387
- * Throws an `InputError` when a value is not a recipe an executor can safely run, naming the first
388
- * three problems `checkRecipe` finds.
389
- *
390
- * Experimental: the recipe format may still change before it is declared stable.
391
- * @param recipe - The value to check
392
- * @beta
393
- */
394
296
  export function assertRecipe(recipe) {
395
297
  const issues = checkRecipe(recipe);
396
298
  if (issues.length) {
@@ -403,16 +305,6 @@ function isNumberList(value) {
403
305
  function isInt32List(value) {
404
306
  return isNumberList(value) && value.every((item) => Number.isInteger(item) && item >= INT32_LOWEST && item <= INT32_HIGHEST);
405
307
  }
406
- /**
407
- * Reads a value as a recipe an executor can run, taking its buffers as lists of numbers too, as JSON
408
- * carries them: such lists become the typed arrays the format holds, and the result is checked as
409
- * `assertRecipe` checks it. The value it is given is left as it was.
410
- *
411
- * Experimental: the recipe format may still change before it is declared stable.
412
- * @param value - The recipe, its buffers typed arrays or lists of numbers
413
- * @returns The recipe with typed buffers
414
- * @beta
415
- */
416
308
  export function toRecipe(value) {
417
309
  const buffers = isRecord(value) ? value["buffers"] : undefined;
418
310
  if (isRecord(value) && isRecord(buffers) && (isNumberList(buffers["f64"]) || isInt32List(buffers["i32"]))) {