lawspec 0.31.0 → 0.31.3

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 (437) hide show
  1. package/CHANGELOG.md +116 -1
  2. package/README.md +86 -4
  3. package/api.mjs +14 -9
  4. package/authoring.mjs +899 -0
  5. package/beam-coverage.mjs +190 -65
  6. package/beam-doctor.mjs +343 -124
  7. package/bin/lawspec.mjs +1955 -657
  8. package/build.json +135 -129
  9. package/component-packages.mjs +662 -176
  10. package/component.d.ts +82 -20
  11. package/component.mjs +317 -94
  12. package/core.wasm +2 -2
  13. package/core_jsffi.js +5 -5
  14. package/doctor.mjs +558 -299
  15. package/examples-command.mjs +44 -23
  16. package/failure-database.mjs +60 -17
  17. package/files.mjs +122 -62
  18. package/index.d.ts +585 -312
  19. package/input-files.mjs +90 -25
  20. package/launcher.mjs +72 -31
  21. package/learn/adapters.mjs +226 -0
  22. package/learn/app.mjs +1279 -0
  23. package/learn/assert.mjs +33 -0
  24. package/learn/assets.mjs +15 -0
  25. package/learn/browser-runtime.mjs +58 -0
  26. package/learn/bundle.mjs +118 -0
  27. package/learn/compile-worker.mjs +106 -0
  28. package/learn/compiler.mjs +230 -0
  29. package/learn/coverage.json +8259 -0
  30. package/learn/curriculum.json +2955 -0
  31. package/learn/fantomas-worker.mjs +25 -0
  32. package/learn/format-worker.mjs +148 -0
  33. package/learn/fsharp.mjs +83 -0
  34. package/learn/harness-host.mjs +22 -0
  35. package/learn/index.html +326 -0
  36. package/learn/lawspec-core.mjs +223 -0
  37. package/learn/lawspec-language.mjs +69 -0
  38. package/learn/node-test.mjs +11 -0
  39. package/learn/presentation.mjs +73 -0
  40. package/learn/runner.mjs +72 -0
  41. package/learn/sandbox-frame.html +34 -0
  42. package/learn/sandbox.mjs +91 -0
  43. package/learn/store.mjs +141 -0
  44. package/learn/story.mjs +42 -0
  45. package/learn/style-options.json +16 -0
  46. package/learn/style.css +1023 -0
  47. package/learn/theme.js +77 -0
  48. package/learn/typescript.mjs +53 -0
  49. package/learn/vendor/@fontsource-atkinson-hyperlegible-LICENSE.txt +93 -0
  50. package/learn/vendor/@fontsource-atkinson-hyperlegible-mono-LICENSE.txt +93 -0
  51. package/learn/vendor/@fontsource-overpass-LICENSE.txt +93 -0
  52. package/learn/vendor/assemblies.json +1 -0
  53. package/learn/vendor/editor-worker.js +30 -0
  54. package/learn/vendor/editor.css +1 -0
  55. package/learn/vendor/editor.mjs +931 -0
  56. package/learn/vendor/esbuild-wasm-LICENSE.txt +21 -0
  57. package/learn/vendor/esbuild.mjs +2683 -0
  58. package/learn/vendor/esbuild.wasm +0 -0
  59. package/learn/vendor/fable-library/Array.js +1347 -0
  60. package/learn/vendor/fable-library/Async.js +134 -0
  61. package/learn/vendor/fable-library/AsyncBuilder.js +183 -0
  62. package/learn/vendor/fable-library/BigInt.js +306 -0
  63. package/learn/vendor/fable-library/BitConverter.js +138 -0
  64. package/learn/vendor/fable-library/Boolean.js +22 -0
  65. package/learn/vendor/fable-library/CHANGELOG.md +242 -0
  66. package/learn/vendor/fable-library/Char.js +202 -0
  67. package/learn/vendor/fable-library/Choice.js +184 -0
  68. package/learn/vendor/fable-library/CollectionUtil.js +182 -0
  69. package/learn/vendor/fable-library/ConditionalWeakTable.js +21 -0
  70. package/learn/vendor/fable-library/Date.js +841 -0
  71. package/learn/vendor/fable-library/DateOffset.js +261 -0
  72. package/learn/vendor/fable-library/DateOnly.js +124 -0
  73. package/learn/vendor/fable-library/Decimal.js +238 -0
  74. package/learn/vendor/fable-library/Double.js +47 -0
  75. package/learn/vendor/fable-library/Encoding.js +185 -0
  76. package/learn/vendor/fable-library/Event.js +93 -0
  77. package/learn/vendor/fable-library/FSharp.Collections.js +45 -0
  78. package/learn/vendor/fable-library/FSharp.Core.CompilerServices.js +27 -0
  79. package/learn/vendor/fable-library/FSharp.Core.js +156 -0
  80. package/learn/vendor/fable-library/Global.js +29 -0
  81. package/learn/vendor/fable-library/Guid.js +161 -0
  82. package/learn/vendor/fable-library/Int32.js +135 -0
  83. package/learn/vendor/fable-library/List.js +1323 -0
  84. package/learn/vendor/fable-library/Long.js +47 -0
  85. package/learn/vendor/fable-library/MailboxProcessor.js +94 -0
  86. package/learn/vendor/fable-library/Map.js +1396 -0
  87. package/learn/vendor/fable-library/MapUtil.js +130 -0
  88. package/learn/vendor/fable-library/MutableMap.js +339 -0
  89. package/learn/vendor/fable-library/MutableSet.js +233 -0
  90. package/learn/vendor/fable-library/Native.js +14 -0
  91. package/learn/vendor/fable-library/Numeric.js +75 -0
  92. package/learn/vendor/fable-library/Observable.js +113 -0
  93. package/learn/vendor/fable-library/Option.js +104 -0
  94. package/learn/vendor/fable-library/README.md +3 -0
  95. package/learn/vendor/fable-library/Random.js +172 -0
  96. package/learn/vendor/fable-library/Range.js +45 -0
  97. package/learn/vendor/fable-library/Reflection.js +479 -0
  98. package/learn/vendor/fable-library/RegExp.js +141 -0
  99. package/learn/vendor/fable-library/Result.js +165 -0
  100. package/learn/vendor/fable-library/Seq.js +1417 -0
  101. package/learn/vendor/fable-library/Seq2.js +111 -0
  102. package/learn/vendor/fable-library/Set.js +1816 -0
  103. package/learn/vendor/fable-library/String.js +674 -0
  104. package/learn/vendor/fable-library/System.Collections.Generic.js +333 -0
  105. package/learn/vendor/fable-library/System.Text.js +200 -0
  106. package/learn/vendor/fable-library/System.js +289 -0
  107. package/learn/vendor/fable-library/TimeOnly.js +122 -0
  108. package/learn/vendor/fable-library/TimeSpan.js +180 -0
  109. package/learn/vendor/fable-library/Timer.js +67 -0
  110. package/learn/vendor/fable-library/Types.js +198 -0
  111. package/learn/vendor/fable-library/Unicode.13.0.0.js +4 -0
  112. package/learn/vendor/fable-library/Uri.js +165 -0
  113. package/learn/vendor/fable-library/Util.js +796 -0
  114. package/learn/vendor/fable-library/big.d.ts +338 -0
  115. package/learn/vendor/fable-library/lib/big.js +825 -0
  116. package/learn/vendor/fable-library/package.json +24 -0
  117. package/learn/vendor/fable-library/quotation.js +618 -0
  118. package/learn/vendor/fable.js +430 -0
  119. package/learn/vendor/fantomas/FSharp.Core.uawo19tl4c.wasm +0 -0
  120. package/learn/vendor/fantomas/Fantomas.Core.stnanlnpyw.wasm +0 -0
  121. package/learn/vendor/fantomas/Fantomas.FCS.lqohfu5o9y.wasm +0 -0
  122. package/learn/vendor/fantomas/LawSpec.Learn.Formatter.poiijdbsl9.wasm +0 -0
  123. package/learn/vendor/fantomas/Microsoft.CSharp.mp8lhr6rez.wasm +0 -0
  124. package/learn/vendor/fantomas/Microsoft.VisualBasic.0e5fchkecn.wasm +0 -0
  125. package/learn/vendor/fantomas/Microsoft.VisualBasic.Core.17wn27qal2.wasm +0 -0
  126. package/learn/vendor/fantomas/Microsoft.Win32.Primitives.9d566sle9e.wasm +0 -0
  127. package/learn/vendor/fantomas/Microsoft.Win32.Registry.52dy96yk8i.wasm +0 -0
  128. package/learn/vendor/fantomas/System.AppContext.jwujeh069z.wasm +0 -0
  129. package/learn/vendor/fantomas/System.Buffers.y0isk1x97h.wasm +0 -0
  130. package/learn/vendor/fantomas/System.Collections.Concurrent.x5koi7bzem.wasm +0 -0
  131. package/learn/vendor/fantomas/System.Collections.Immutable.diwg7advch.wasm +0 -0
  132. package/learn/vendor/fantomas/System.Collections.NonGeneric.4089xs440e.wasm +0 -0
  133. package/learn/vendor/fantomas/System.Collections.Specialized.hj81u7zblb.wasm +0 -0
  134. package/learn/vendor/fantomas/System.Collections.nvrdeoknr1.wasm +0 -0
  135. package/learn/vendor/fantomas/System.ComponentModel.Annotations.yatcnfjeuk.wasm +0 -0
  136. package/learn/vendor/fantomas/System.ComponentModel.DataAnnotations.led9l5awu3.wasm +0 -0
  137. package/learn/vendor/fantomas/System.ComponentModel.EventBasedAsync.hpvp6cf4de.wasm +0 -0
  138. package/learn/vendor/fantomas/System.ComponentModel.Primitives.v7cajwpaqo.wasm +0 -0
  139. package/learn/vendor/fantomas/System.ComponentModel.TypeConverter.xk1hnyt762.wasm +0 -0
  140. package/learn/vendor/fantomas/System.ComponentModel.rrnda1lucx.wasm +0 -0
  141. package/learn/vendor/fantomas/System.Configuration.bn9vghjcq8.wasm +0 -0
  142. package/learn/vendor/fantomas/System.Console.09ajpiafhz.wasm +0 -0
  143. package/learn/vendor/fantomas/System.Core.wc649o5mw9.wasm +0 -0
  144. package/learn/vendor/fantomas/System.Data.Common.s4cowzd9a9.wasm +0 -0
  145. package/learn/vendor/fantomas/System.Data.DataSetExtensions.5fm360ikxl.wasm +0 -0
  146. package/learn/vendor/fantomas/System.Data.fsu4j4t4jw.wasm +0 -0
  147. package/learn/vendor/fantomas/System.Diagnostics.Contracts.p74re5oxzn.wasm +0 -0
  148. package/learn/vendor/fantomas/System.Diagnostics.Debug.622sixg49n.wasm +0 -0
  149. package/learn/vendor/fantomas/System.Diagnostics.DiagnosticSource.2j35bc2g2b.wasm +0 -0
  150. package/learn/vendor/fantomas/System.Diagnostics.FileVersionInfo.7n0wdvltaa.wasm +0 -0
  151. package/learn/vendor/fantomas/System.Diagnostics.Process.8iffh49mew.wasm +0 -0
  152. package/learn/vendor/fantomas/System.Diagnostics.StackTrace.1yz88vico8.wasm +0 -0
  153. package/learn/vendor/fantomas/System.Diagnostics.TextWriterTraceListener.ua8iuh2vhj.wasm +0 -0
  154. package/learn/vendor/fantomas/System.Diagnostics.Tools.roy5445ugj.wasm +0 -0
  155. package/learn/vendor/fantomas/System.Diagnostics.TraceSource.6qx1ldzz7g.wasm +0 -0
  156. package/learn/vendor/fantomas/System.Diagnostics.Tracing.b4799zpaas.wasm +0 -0
  157. package/learn/vendor/fantomas/System.Drawing.8gcjjqj0pu.wasm +0 -0
  158. package/learn/vendor/fantomas/System.Drawing.Primitives.y2uveru2yk.wasm +0 -0
  159. package/learn/vendor/fantomas/System.Dynamic.Runtime.023zrvzh9x.wasm +0 -0
  160. package/learn/vendor/fantomas/System.Formats.Asn1.znpklkbgqv.wasm +0 -0
  161. package/learn/vendor/fantomas/System.Formats.Tar.5yybjepfi2.wasm +0 -0
  162. package/learn/vendor/fantomas/System.Globalization.Calendars.10g6hyjy3k.wasm +0 -0
  163. package/learn/vendor/fantomas/System.Globalization.Extensions.hrinfrismg.wasm +0 -0
  164. package/learn/vendor/fantomas/System.Globalization.uvs4rah8fk.wasm +0 -0
  165. package/learn/vendor/fantomas/System.IO.4j645gw40d.wasm +0 -0
  166. package/learn/vendor/fantomas/System.IO.Compression.2z7vdt6tfb.wasm +0 -0
  167. package/learn/vendor/fantomas/System.IO.Compression.Brotli.fv80xs79j3.wasm +0 -0
  168. package/learn/vendor/fantomas/System.IO.Compression.FileSystem.88jdddz3sw.wasm +0 -0
  169. package/learn/vendor/fantomas/System.IO.Compression.ZipFile.jkn9avr4vo.wasm +0 -0
  170. package/learn/vendor/fantomas/System.IO.FileSystem.AccessControl.yme0uhbu37.wasm +0 -0
  171. package/learn/vendor/fantomas/System.IO.FileSystem.DriveInfo.qas7wf73rs.wasm +0 -0
  172. package/learn/vendor/fantomas/System.IO.FileSystem.Primitives.d1jmhkzu0e.wasm +0 -0
  173. package/learn/vendor/fantomas/System.IO.FileSystem.Watcher.z570derp0d.wasm +0 -0
  174. package/learn/vendor/fantomas/System.IO.FileSystem.o6jtz51fup.wasm +0 -0
  175. package/learn/vendor/fantomas/System.IO.IsolatedStorage.hqyeyb5ipe.wasm +0 -0
  176. package/learn/vendor/fantomas/System.IO.MemoryMappedFiles.zhamjnusxd.wasm +0 -0
  177. package/learn/vendor/fantomas/System.IO.Pipelines.wrmw5vws31.wasm +0 -0
  178. package/learn/vendor/fantomas/System.IO.Pipes.AccessControl.qcancj8gj2.wasm +0 -0
  179. package/learn/vendor/fantomas/System.IO.Pipes.zhcyguvwkr.wasm +0 -0
  180. package/learn/vendor/fantomas/System.IO.UnmanagedMemoryStream.o8cpjnlard.wasm +0 -0
  181. package/learn/vendor/fantomas/System.Linq.AsyncEnumerable.hyc0b7okjw.wasm +0 -0
  182. package/learn/vendor/fantomas/System.Linq.Expressions.ldibvm0efj.wasm +0 -0
  183. package/learn/vendor/fantomas/System.Linq.Parallel.2buevezvch.wasm +0 -0
  184. package/learn/vendor/fantomas/System.Linq.Queryable.cvq43g1awj.wasm +0 -0
  185. package/learn/vendor/fantomas/System.Linq.lz6mvi0hm2.wasm +0 -0
  186. package/learn/vendor/fantomas/System.Memory.3jekerw0ga.wasm +0 -0
  187. package/learn/vendor/fantomas/System.Net.Http.Json.8k237kkwec.wasm +0 -0
  188. package/learn/vendor/fantomas/System.Net.Http.cityx2bvcl.wasm +0 -0
  189. package/learn/vendor/fantomas/System.Net.HttpListener.s1jreclykx.wasm +0 -0
  190. package/learn/vendor/fantomas/System.Net.Mail.cmlj4c0gto.wasm +0 -0
  191. package/learn/vendor/fantomas/System.Net.NameResolution.q3gf18q13l.wasm +0 -0
  192. package/learn/vendor/fantomas/System.Net.NetworkInformation.xaz5tjw7d0.wasm +0 -0
  193. package/learn/vendor/fantomas/System.Net.Ping.a40atim1h0.wasm +0 -0
  194. package/learn/vendor/fantomas/System.Net.Primitives.i88i20r8sr.wasm +0 -0
  195. package/learn/vendor/fantomas/System.Net.Quic.hx06eo5xkj.wasm +0 -0
  196. package/learn/vendor/fantomas/System.Net.Requests.hkjxlfe5f5.wasm +0 -0
  197. package/learn/vendor/fantomas/System.Net.Security.ch34yya69o.wasm +0 -0
  198. package/learn/vendor/fantomas/System.Net.ServerSentEvents.0u7o0jk3p1.wasm +0 -0
  199. package/learn/vendor/fantomas/System.Net.ServicePoint.xbhxnytx4l.wasm +0 -0
  200. package/learn/vendor/fantomas/System.Net.Sockets.hzgzlvkc9l.wasm +0 -0
  201. package/learn/vendor/fantomas/System.Net.WebClient.84i8nwzbgu.wasm +0 -0
  202. package/learn/vendor/fantomas/System.Net.WebHeaderCollection.326nl7s9g3.wasm +0 -0
  203. package/learn/vendor/fantomas/System.Net.WebProxy.oq3mgkkqef.wasm +0 -0
  204. package/learn/vendor/fantomas/System.Net.WebSockets.2cx1v74vg8.wasm +0 -0
  205. package/learn/vendor/fantomas/System.Net.WebSockets.Client.rafzkktw8j.wasm +0 -0
  206. package/learn/vendor/fantomas/System.Net.w1hpj3bo6r.wasm +0 -0
  207. package/learn/vendor/fantomas/System.Numerics.Vectors.oyv7biw9ux.wasm +0 -0
  208. package/learn/vendor/fantomas/System.Numerics.lyu36wqn19.wasm +0 -0
  209. package/learn/vendor/fantomas/System.ObjectModel.kxu80demuu.wasm +0 -0
  210. package/learn/vendor/fantomas/System.Private.CoreLib.1vy46s12u6.wasm +0 -0
  211. package/learn/vendor/fantomas/System.Private.DataContractSerialization.ao8k9iu77a.wasm +0 -0
  212. package/learn/vendor/fantomas/System.Private.Uri.itn0n2zjd0.wasm +0 -0
  213. package/learn/vendor/fantomas/System.Private.Xml.19nzpxrx8w.wasm +0 -0
  214. package/learn/vendor/fantomas/System.Private.Xml.Linq.tw5eq1hjvo.wasm +0 -0
  215. package/learn/vendor/fantomas/System.Reflection.DispatchProxy.7lajnj8s8c.wasm +0 -0
  216. package/learn/vendor/fantomas/System.Reflection.Emit.7liz9zln06.wasm +0 -0
  217. package/learn/vendor/fantomas/System.Reflection.Emit.ILGeneration.1ut3qgacw8.wasm +0 -0
  218. package/learn/vendor/fantomas/System.Reflection.Emit.Lightweight.d0gvllb1jj.wasm +0 -0
  219. package/learn/vendor/fantomas/System.Reflection.Extensions.zr5bhwfczd.wasm +0 -0
  220. package/learn/vendor/fantomas/System.Reflection.Metadata.ff6np6mz2j.wasm +0 -0
  221. package/learn/vendor/fantomas/System.Reflection.Primitives.igpmvwv78c.wasm +0 -0
  222. package/learn/vendor/fantomas/System.Reflection.TypeExtensions.qouojzlnp9.wasm +0 -0
  223. package/learn/vendor/fantomas/System.Reflection.mk3jyxvh13.wasm +0 -0
  224. package/learn/vendor/fantomas/System.Resources.Reader.41ppfyz2vc.wasm +0 -0
  225. package/learn/vendor/fantomas/System.Resources.ResourceManager.sfwvfmw1ea.wasm +0 -0
  226. package/learn/vendor/fantomas/System.Resources.Writer.3uvs9tp38z.wasm +0 -0
  227. package/learn/vendor/fantomas/System.Runtime.CompilerServices.Unsafe.puz1xm53oc.wasm +0 -0
  228. package/learn/vendor/fantomas/System.Runtime.CompilerServices.VisualC.9qdau315py.wasm +0 -0
  229. package/learn/vendor/fantomas/System.Runtime.Extensions.i7gntui96b.wasm +0 -0
  230. package/learn/vendor/fantomas/System.Runtime.Handles.00oxj4o6ov.wasm +0 -0
  231. package/learn/vendor/fantomas/System.Runtime.InteropServices.JavaScript.9kq1vofond.wasm +0 -0
  232. package/learn/vendor/fantomas/System.Runtime.InteropServices.RuntimeInformation.my7qeqbhfh.wasm +0 -0
  233. package/learn/vendor/fantomas/System.Runtime.InteropServices.vqp80tnwc7.wasm +0 -0
  234. package/learn/vendor/fantomas/System.Runtime.Intrinsics.u0samjybfo.wasm +0 -0
  235. package/learn/vendor/fantomas/System.Runtime.Loader.n6zxw1b98a.wasm +0 -0
  236. package/learn/vendor/fantomas/System.Runtime.Numerics.o40sjhz59x.wasm +0 -0
  237. package/learn/vendor/fantomas/System.Runtime.Serialization.Formatters.1esvva4te3.wasm +0 -0
  238. package/learn/vendor/fantomas/System.Runtime.Serialization.Json.4n7u09advh.wasm +0 -0
  239. package/learn/vendor/fantomas/System.Runtime.Serialization.Primitives.xs2bo91wvk.wasm +0 -0
  240. package/learn/vendor/fantomas/System.Runtime.Serialization.Xml.ny21jmziti.wasm +0 -0
  241. package/learn/vendor/fantomas/System.Runtime.Serialization.qcxaur5wqs.wasm +0 -0
  242. package/learn/vendor/fantomas/System.Runtime.odq454d6j9.wasm +0 -0
  243. package/learn/vendor/fantomas/System.Security.AccessControl.8yfnzmqzaq.wasm +0 -0
  244. package/learn/vendor/fantomas/System.Security.Claims.8ogy0860de.wasm +0 -0
  245. package/learn/vendor/fantomas/System.Security.Cryptography.Algorithms.8zijp1svfw.wasm +0 -0
  246. package/learn/vendor/fantomas/System.Security.Cryptography.Cng.yxagtt77no.wasm +0 -0
  247. package/learn/vendor/fantomas/System.Security.Cryptography.Csp.uhfbvvau84.wasm +0 -0
  248. package/learn/vendor/fantomas/System.Security.Cryptography.Encoding.2ywrusvy8q.wasm +0 -0
  249. package/learn/vendor/fantomas/System.Security.Cryptography.OpenSsl.oa268u7i92.wasm +0 -0
  250. package/learn/vendor/fantomas/System.Security.Cryptography.Primitives.5uhvqe8puk.wasm +0 -0
  251. package/learn/vendor/fantomas/System.Security.Cryptography.X509Certificates.6i7pxilopt.wasm +0 -0
  252. package/learn/vendor/fantomas/System.Security.Cryptography.d0quqk1iyr.wasm +0 -0
  253. package/learn/vendor/fantomas/System.Security.Principal.Windows.gpqua4rz29.wasm +0 -0
  254. package/learn/vendor/fantomas/System.Security.Principal.i20kfklf3g.wasm +0 -0
  255. package/learn/vendor/fantomas/System.Security.SecureString.x2y8tzci3c.wasm +0 -0
  256. package/learn/vendor/fantomas/System.Security.e83vvh6sl2.wasm +0 -0
  257. package/learn/vendor/fantomas/System.ServiceModel.Web.poglliv2no.wasm +0 -0
  258. package/learn/vendor/fantomas/System.ServiceProcess.yro5uj2opo.wasm +0 -0
  259. package/learn/vendor/fantomas/System.Text.Encoding.CodePages.2wchx40i7z.wasm +0 -0
  260. package/learn/vendor/fantomas/System.Text.Encoding.Extensions.8utaw61kn5.wasm +0 -0
  261. package/learn/vendor/fantomas/System.Text.Encoding.cxdyfepnpj.wasm +0 -0
  262. package/learn/vendor/fantomas/System.Text.Encodings.Web.37ehbi7cye.wasm +0 -0
  263. package/learn/vendor/fantomas/System.Text.Json.ixiaa8hd3h.wasm +0 -0
  264. package/learn/vendor/fantomas/System.Text.RegularExpressions.2fhfmkk6vf.wasm +0 -0
  265. package/learn/vendor/fantomas/System.Threading.6pry74a050.wasm +0 -0
  266. package/learn/vendor/fantomas/System.Threading.AccessControl.76zfdfy8go.wasm +0 -0
  267. package/learn/vendor/fantomas/System.Threading.Channels.gpxnr01lmp.wasm +0 -0
  268. package/learn/vendor/fantomas/System.Threading.Overlapped.aqpl8tzdyc.wasm +0 -0
  269. package/learn/vendor/fantomas/System.Threading.Tasks.Dataflow.ytwttt7fzh.wasm +0 -0
  270. package/learn/vendor/fantomas/System.Threading.Tasks.Extensions.0deavcb00v.wasm +0 -0
  271. package/learn/vendor/fantomas/System.Threading.Tasks.Parallel.tjwtxugso0.wasm +0 -0
  272. package/learn/vendor/fantomas/System.Threading.Tasks.fu4qd5h3qy.wasm +0 -0
  273. package/learn/vendor/fantomas/System.Threading.Thread.klaua2by9m.wasm +0 -0
  274. package/learn/vendor/fantomas/System.Threading.ThreadPool.mkzm212njz.wasm +0 -0
  275. package/learn/vendor/fantomas/System.Threading.Timer.yp49llu5h2.wasm +0 -0
  276. package/learn/vendor/fantomas/System.Transactions.Local.vz6cgeh4w7.wasm +0 -0
  277. package/learn/vendor/fantomas/System.Transactions.ipwm3rsy66.wasm +0 -0
  278. package/learn/vendor/fantomas/System.ValueTuple.7ol6ljuhx8.wasm +0 -0
  279. package/learn/vendor/fantomas/System.Web.HttpUtility.itlvncjd96.wasm +0 -0
  280. package/learn/vendor/fantomas/System.Web.np8uzzakvl.wasm +0 -0
  281. package/learn/vendor/fantomas/System.Windows.18nzio44t3.wasm +0 -0
  282. package/learn/vendor/fantomas/System.Xml.45jprtg1pa.wasm +0 -0
  283. package/learn/vendor/fantomas/System.Xml.Linq.v9v8udncm1.wasm +0 -0
  284. package/learn/vendor/fantomas/System.Xml.ReaderWriter.a9mr08uzci.wasm +0 -0
  285. package/learn/vendor/fantomas/System.Xml.Serialization.03juoguwgc.wasm +0 -0
  286. package/learn/vendor/fantomas/System.Xml.XDocument.c9dhjnzqjb.wasm +0 -0
  287. package/learn/vendor/fantomas/System.Xml.XPath.XDocument.138b12i1pm.wasm +0 -0
  288. package/learn/vendor/fantomas/System.Xml.XPath.pvxm9341ce.wasm +0 -0
  289. package/learn/vendor/fantomas/System.Xml.XmlDocument.450wsyxvl0.wasm +0 -0
  290. package/learn/vendor/fantomas/System.Xml.XmlSerializer.y3t2n0tce7.wasm +0 -0
  291. package/learn/vendor/fantomas/System.gjriafnqmz.wasm +0 -0
  292. package/learn/vendor/fantomas/WindowsBase.8zsce9qxfb.wasm +0 -0
  293. package/learn/vendor/fantomas/cs/FSharp.Core.resources.9ehmavdel7.wasm +0 -0
  294. package/learn/vendor/fantomas/de/FSharp.Core.resources.2ofmxloa01.wasm +0 -0
  295. package/learn/vendor/fantomas/dotnet.js +1233 -0
  296. package/learn/vendor/fantomas/dotnet.native.b6l13xorvf.js +16 -0
  297. package/learn/vendor/fantomas/dotnet.native.rw4kynp763.wasm +0 -0
  298. package/learn/vendor/fantomas/dotnet.runtime.v06hirbjsv.js +4 -0
  299. package/learn/vendor/fantomas/es/FSharp.Core.resources.hkr5ggb4tr.wasm +0 -0
  300. package/learn/vendor/fantomas/fr/FSharp.Core.resources.43soen28ow.wasm +0 -0
  301. package/learn/vendor/fantomas/icudt_CJK.tjcz0u77k5.dat +0 -0
  302. package/learn/vendor/fantomas/icudt_EFIGS.tptq2av103.dat +0 -0
  303. package/learn/vendor/fantomas/icudt_no_CJK.lfu7j35m59.dat +0 -0
  304. package/learn/vendor/fantomas/it/FSharp.Core.resources.m60n5ls7oq.wasm +0 -0
  305. package/learn/vendor/fantomas/ja/FSharp.Core.resources.o6oof69v14.wasm +0 -0
  306. package/learn/vendor/fantomas/ko/FSharp.Core.resources.q6l4snlu9o.wasm +0 -0
  307. package/learn/vendor/fantomas/mscorlib.8ptuc08eli.wasm +0 -0
  308. package/learn/vendor/fantomas/netstandard.eymp85mooh.wasm +0 -0
  309. package/learn/vendor/fantomas/pl/FSharp.Core.resources.8bni0w6j8b.wasm +0 -0
  310. package/learn/vendor/fantomas/pt-BR/FSharp.Core.resources.k849vqm41u.wasm +0 -0
  311. package/learn/vendor/fantomas/ru/FSharp.Core.resources.jz9rhhtsla.wasm +0 -0
  312. package/learn/vendor/fantomas/tr/FSharp.Core.resources.wn6vbvjm1u.wasm +0 -0
  313. package/learn/vendor/fantomas/zh-Hans/FSharp.Core.resources.z7zzbso094.wasm +0 -0
  314. package/learn/vendor/fantomas/zh-Hant/FSharp.Core.resources.iammfsi7ls.wasm +0 -0
  315. package/learn/vendor/fast-check-LICENSE.txt +21 -0
  316. package/learn/vendor/fast-check.mjs +37 -0
  317. package/learn/vendor/fonts/atkinson-hyperlegible-latin-400-normal.woff2 +0 -0
  318. package/learn/vendor/fonts/atkinson-hyperlegible-latin-700-normal.woff2 +0 -0
  319. package/learn/vendor/fonts/atkinson-hyperlegible-mono-latin-400-normal.woff2 +0 -0
  320. package/learn/vendor/fonts/overpass-latin-600-normal.woff2 +0 -0
  321. package/learn/vendor/fonts/overpass-latin-700-normal.woff2 +0 -0
  322. package/learn/vendor/formatter-licenses/DotNet-LICENSE.txt +23 -0
  323. package/learn/vendor/formatter-licenses/DotNet-THIRD-PARTY-NOTICES.txt +1418 -0
  324. package/learn/vendor/formatter-licenses/FSharp-LICENSE.txt +23 -0
  325. package/learn/vendor/formatter-licenses/Fantomas-LICENSE.txt +202 -0
  326. package/learn/vendor/formatter-licenses/README.md +12 -0
  327. package/learn/vendor/manifest.json +1354 -0
  328. package/learn/vendor/metadata/Browser.Blob.dll +0 -0
  329. package/learn/vendor/metadata/Browser.Dom.dll +0 -0
  330. package/learn/vendor/metadata/Browser.Event.dll +0 -0
  331. package/learn/vendor/metadata/Browser.Gamepad.dll +0 -0
  332. package/learn/vendor/metadata/Browser.WebGL.dll +0 -0
  333. package/learn/vendor/metadata/Browser.WebStorage.dll +0 -0
  334. package/learn/vendor/metadata/FSharp.Core.dll +0 -0
  335. package/learn/vendor/metadata/Fable.Core.dll +0 -0
  336. package/learn/vendor/metadata/Fable.Repl.Lib.dll +0 -0
  337. package/learn/vendor/metadata/System.Collections.Concurrent.dll +0 -0
  338. package/learn/vendor/metadata/System.Collections.dll +0 -0
  339. package/learn/vendor/metadata/System.ComponentModel.Primitives.dll +0 -0
  340. package/learn/vendor/metadata/System.ComponentModel.TypeConverter.dll +0 -0
  341. package/learn/vendor/metadata/System.ComponentModel.dll +0 -0
  342. package/learn/vendor/metadata/System.Console.dll +0 -0
  343. package/learn/vendor/metadata/System.Core.dll +0 -0
  344. package/learn/vendor/metadata/System.Diagnostics.Debug.dll +0 -0
  345. package/learn/vendor/metadata/System.Diagnostics.Tools.dll +0 -0
  346. package/learn/vendor/metadata/System.Diagnostics.Tracing.dll +0 -0
  347. package/learn/vendor/metadata/System.Globalization.dll +0 -0
  348. package/learn/vendor/metadata/System.IO.dll +0 -0
  349. package/learn/vendor/metadata/System.Net.Requests.dll +0 -0
  350. package/learn/vendor/metadata/System.Net.WebClient.dll +0 -0
  351. package/learn/vendor/metadata/System.Numerics.dll +0 -0
  352. package/learn/vendor/metadata/System.Reflection.Extensions.dll +0 -0
  353. package/learn/vendor/metadata/System.Reflection.Metadata.dll +0 -0
  354. package/learn/vendor/metadata/System.Reflection.Primitives.dll +0 -0
  355. package/learn/vendor/metadata/System.Reflection.TypeExtensions.dll +0 -0
  356. package/learn/vendor/metadata/System.Reflection.dll +0 -0
  357. package/learn/vendor/metadata/System.Runtime.Extensions.dll +0 -0
  358. package/learn/vendor/metadata/System.Runtime.InteropServices.dll +0 -0
  359. package/learn/vendor/metadata/System.Runtime.Numerics.dll +0 -0
  360. package/learn/vendor/metadata/System.Runtime.dll +0 -0
  361. package/learn/vendor/metadata/System.Text.Encoding.Extensions.dll +0 -0
  362. package/learn/vendor/metadata/System.Text.Encoding.dll +0 -0
  363. package/learn/vendor/metadata/System.Text.RegularExpressions.dll +0 -0
  364. package/learn/vendor/metadata/System.Threading.Tasks.dll +0 -0
  365. package/learn/vendor/metadata/System.Threading.Thread.dll +0 -0
  366. package/learn/vendor/metadata/System.Threading.dll +0 -0
  367. package/learn/vendor/metadata/System.ValueTuple.dll +0 -0
  368. package/learn/vendor/metadata/System.dll +0 -0
  369. package/learn/vendor/metadata/mscorlib.dll +0 -0
  370. package/learn/vendor/metadata/netstandard.dll +0 -0
  371. package/learn/vendor/monaco-editor-LICENSE.txt +21 -0
  372. package/learn/vendor/prettier/babel.mjs +16 -0
  373. package/learn/vendor/prettier/brace-style.mjs +376 -0
  374. package/learn/vendor/prettier/estree.mjs +44 -0
  375. package/learn/vendor/prettier/standalone.mjs +29 -0
  376. package/learn/vendor/prettier/typescript.mjs +22 -0
  377. package/learn/vendor/prettier-LICENSE.txt +7 -0
  378. package/learn/vendor/prettier-plugin-brace-style-LICENSE.txt +21 -0
  379. package/learn/vendor/typescript-LICENSE.txt +55 -0
  380. package/learn/vendor/typescript-libs.json +1 -0
  381. package/learn/vendor/typescript.mjs +451 -0
  382. package/learn/vendor/zod-LICENSE.txt +21 -0
  383. package/learn/web-format.mjs +8 -0
  384. package/learn.mjs +126 -0
  385. package/lsp.mjs +444 -133
  386. package/mcp.mjs +250 -0
  387. package/native-evidence.mjs +668 -182
  388. package/native-examples.mjs +56 -19
  389. package/native-host.mjs +136 -42
  390. package/native-parsers/clojure.LICENSE +121 -0
  391. package/native-parsers/clojure.wasm +0 -0
  392. package/native-parsers/csharp.LICENSE +21 -0
  393. package/native-parsers/csharp.wasm +0 -0
  394. package/native-parsers/elixir.LICENSE +176 -0
  395. package/native-parsers/elixir.wasm +0 -0
  396. package/native-parsers/erlang.LICENSE +201 -0
  397. package/native-parsers/erlang.wasm +0 -0
  398. package/native-parsers/fsharp.LICENSE +21 -0
  399. package/native-parsers/fsharp.wasm +0 -0
  400. package/native-parsers/gleam.LICENSE +202 -0
  401. package/native-parsers/gleam.wasm +0 -0
  402. package/native-parsers/go.LICENSE +21 -0
  403. package/native-parsers/go.wasm +0 -0
  404. package/native-parsers/groovy.LICENSE +21 -0
  405. package/native-parsers/groovy.wasm +0 -0
  406. package/native-parsers/haskell.LICENSE +21 -0
  407. package/native-parsers/haskell.wasm +0 -0
  408. package/native-parsers/java.LICENSE +21 -0
  409. package/native-parsers/java.wasm +0 -0
  410. package/native-parsers/javascript.LICENSE +21 -0
  411. package/native-parsers/javascript.wasm +0 -0
  412. package/native-parsers/kotlin.LICENSE +9 -0
  413. package/native-parsers/kotlin.wasm +0 -0
  414. package/native-parsers/lock.json +114 -0
  415. package/native-parsers/prolog.LICENSE +21 -0
  416. package/native-parsers/prolog.wasm +0 -0
  417. package/native-parsers/python.LICENSE +21 -0
  418. package/native-parsers/python.wasm +0 -0
  419. package/native-parsers/rust.LICENSE +21 -0
  420. package/native-parsers/rust.wasm +0 -0
  421. package/native-parsers/scala.LICENSE +21 -0
  422. package/native-parsers/scala.wasm +0 -0
  423. package/native-parsers/swift.LICENSE +21 -0
  424. package/native-parsers/swift.wasm +0 -0
  425. package/native-parsers/typescript.LICENSE +21 -0
  426. package/native-parsers/typescript.wasm +0 -0
  427. package/node-events-reporter.mjs +41 -17
  428. package/package.json +5 -3
  429. package/project.mjs +338 -0
  430. package/proof.d.ts +93 -19
  431. package/proof.mjs +1538 -447
  432. package/read-only-hpack.mjs +6 -5
  433. package/scala-build-state.mjs +131 -41
  434. package/scala-coverage.mjs +57 -34
  435. package/scalars.mjs +23 -8
  436. package/templates.mjs +566 -617
  437. package/test-command.mjs +1671 -521
@@ -1,5 +1,15 @@
1
1
  // Generated from templates/npm/component-packages.mjs by lawspec-dev generate. Do not edit.
2
- import {readFile, writeFile, mkdir, readdir, lstat, realpath, rename, rm, mkdtemp} from 'node:fs/promises';
2
+ import {
3
+ readFile,
4
+ writeFile,
5
+ mkdir,
6
+ readdir,
7
+ lstat,
8
+ realpath,
9
+ rename,
10
+ rm,
11
+ mkdtemp,
12
+ } from 'node:fs/promises';
3
13
  import {execFile} from 'node:child_process';
4
14
  import {promisify} from 'node:util';
5
15
  import {Readable} from 'node:stream';
@@ -8,136 +18,303 @@ import os from 'node:os';
8
18
  import {randomUUID} from 'node:crypto';
9
19
  import path from 'node:path';
10
20
  import * as tar from 'tar';
11
- import {readManifest, parseManifest, writeManifest, manifestName, lockName, packageVersions, dependencyRanges, contentDigest, canonical} from './component.mjs';
21
+ import {
22
+ readManifest,
23
+ parseManifest,
24
+ writeManifest,
25
+ manifestName,
26
+ lockName,
27
+ packageVersions,
28
+ dependencyRanges,
29
+ contentDigest,
30
+ canonical,
31
+ } from './component.mjs';
12
32
  import {collectSources, atomicWrite} from './files.mjs';
13
33
 
14
34
  const exec = promisify(execFile);
15
- const git = async (args, options = {}) => (await exec('git', args, {maxBuffer: 128 * 1024 * 1024, ...options})).stdout;
16
- const optional = async file => readFile(file, 'utf8').catch(error => {if (error.code === 'ENOENT') return null; throw error;});
17
- const inside = (root, file) => file === root || file.startsWith(root + path.sep);
18
- const rangeOf = value => typeof value === 'string' ? value : value.version;
35
+ const git = async (args, options = {}) =>
36
+ (await exec('git', args, {maxBuffer: 128 * 1024 * 1024, ...options})).stdout;
37
+ const optional = async file =>
38
+ readFile(file, 'utf8').catch(error =>
39
+ {
40
+ if (error.code === 'ENOENT') return null;
41
+ throw error;
42
+ });
43
+ const inside = (root, file) =>
44
+ file === root || file.startsWith(root + path.sep);
45
+ const rangeOf = value => (typeof value === 'string' ? value : value.version);
19
46
 
20
- function validateLock(lock) {
21
- const map = value => value && typeof value === 'object' && !Array.isArray(value);
22
- const invalid = () => {throw new Error('Invalid LawSpec lockfile; regenerate it with lawspec fetch');};
23
- if (!map(lock) || lock.format !== 'lawspec-lock' || lock.version !== 1 ||
24
- !map(lock.roots) || !map(lock.selections) || !Array.isArray(lock.packages)) invalid();
47
+ function validateLock(lock)
48
+ {
49
+ const map = value =>
50
+ value && typeof value === 'object' && !Array.isArray(value);
51
+ const invalid = () =>
52
+ {
53
+ throw new Error(
54
+ 'Invalid LawSpec lockfile; regenerate it with lawspec fetch',
55
+ );
56
+ };
57
+ if (
58
+ !map(lock) ||
59
+ lock.format !== 'lawspec-lock' ||
60
+ lock.version !== 1 ||
61
+ !map(lock.roots) ||
62
+ !map(lock.selections) ||
63
+ !Array.isArray(lock.packages)
64
+ )
65
+ invalid();
25
66
  const ids = new Set();
26
- for (const entry of lock.packages) {
27
- if (!map(entry) || typeof entry.id !== 'string' || ids.has(entry.id) ||
28
- typeof entry.name !== 'string' || typeof entry.version !== 'string' ||
29
- !map(entry.dependencies) || !map(entry.source)) invalid();
67
+ for (const entry of lock.packages)
68
+ {
69
+ if (
70
+ !map(entry) ||
71
+ typeof entry.id !== 'string' ||
72
+ ids.has(entry.id) ||
73
+ typeof entry.name !== 'string' ||
74
+ typeof entry.version !== 'string' ||
75
+ !map(entry.dependencies) ||
76
+ !map(entry.source)
77
+ )
78
+ invalid();
30
79
  ids.add(entry.id);
31
80
  const source = entry.source;
32
- if (source.kind === 'path') {if (typeof source.path !== 'string') invalid();}
33
- else if (source.kind === 'embedded') {
34
- if (typeof source.parent !== 'string' || typeof source.path !== 'string' || !/^[a-f0-9]{64}$/.test(entry.digest)) invalid();
35
- } else if (['git', 'archive'].includes(source.kind)) {
36
- if (typeof source.url !== 'string' || !/^[a-f0-9]{64}$/.test(entry.digest)) invalid();
37
- if (source.kind === 'git' && !/^[a-f0-9]{40,64}$/.test(source.commit)) invalid();
38
- if (source.kind === 'archive' && !/^[a-f0-9]{64}$/.test(source.sha256)) invalid();
39
- } else invalid();
81
+ if (source.kind === 'path')
82
+ {
83
+ if (typeof source.path !== 'string') invalid();
84
+ }
85
+ else if (source.kind === 'embedded')
86
+ {
87
+ if (
88
+ typeof source.parent !== 'string' ||
89
+ typeof source.path !== 'string' ||
90
+ !/^[a-f0-9]{64}$/.test(entry.digest)
91
+ )
92
+ invalid();
93
+ }
94
+ else if (['git', 'archive'].includes(source.kind))
95
+ {
96
+ if (
97
+ typeof source.url !== 'string' ||
98
+ !/^[a-f0-9]{64}$/.test(entry.digest)
99
+ )
100
+ invalid();
101
+ if (source.kind === 'git' && !/^[a-f0-9]{40,64}$/.test(source.commit))
102
+ invalid();
103
+ if (source.kind === 'archive' && !/^[a-f0-9]{64}$/.test(source.sha256))
104
+ invalid();
105
+ }
106
+ else invalid();
40
107
  }
41
108
  for (const selection of Object.values(lock.selections))
42
- if (!map(selection) || !Object.hasOwn(selection, 'request') || !ids.has(selection.package)) invalid();
43
- for (const id of [...Object.values(lock.roots), ...lock.packages.flatMap(entry => Object.values(entry.dependencies))])
109
+ if (
110
+ !map(selection) ||
111
+ !Object.hasOwn(selection, 'request') ||
112
+ !ids.has(selection.package)
113
+ )
114
+ invalid();
115
+ for (const id of [
116
+ ...Object.values(lock.roots),
117
+ ...lock.packages.flatMap(entry => Object.values(entry.dependencies)),
118
+ ])
44
119
  if (!ids.has(id)) invalid();
45
120
  }
46
121
 
47
- async function filesUnder(root) {
122
+ async function filesUnder(root)
123
+ {
48
124
  const files = [];
49
- async function walk(file, relative) {
125
+ async function walk(file, relative)
126
+ {
50
127
  const info = await lstat(file);
51
- if (info.isSymbolicLink()) throw new Error(`Contract packages cannot contain symbolic links: ${relative}`);
52
- if (info.isDirectory()) {
53
- for (const name of (await readdir(file)).sort()) {
54
- if (['.git', '.lawspec', 'node_modules', 'target', 'bin', 'obj'].includes(name)) continue;
55
- await walk(path.join(file, name), relative ? `${relative}/${name}` : name);
128
+ if (info.isSymbolicLink())
129
+ throw new Error(
130
+ `Contract packages cannot contain symbolic links: ${relative}`,
131
+ );
132
+ if (info.isDirectory())
133
+ {
134
+ for (const name of (await readdir(file)).sort())
135
+ {
136
+ if (
137
+ ['.git', '.lawspec', 'node_modules', 'target', 'bin', 'obj'].includes(
138
+ name,
139
+ )
140
+ )
141
+ continue;
142
+ await walk(
143
+ path.join(file, name),
144
+ relative ? `${relative}/${name}` : name,
145
+ );
56
146
  }
57
- } else if (info.isFile()) files.push(relative);
147
+ }
148
+ else if (info.isFile()) files.push(relative);
58
149
  }
59
150
  await walk(root, '');
60
151
  return files;
61
152
  }
62
153
 
63
- export const resolvedPackageDigest = (content, dependencies) => Object.keys(dependencies).length ? contentDigest(canonical({content, dependencies})) : content;
154
+ export const resolvedPackageDigest = (content, dependencies) =>
155
+ Object.keys(dependencies).length
156
+ ? contentDigest(canonical({content, dependencies}))
157
+ : content;
64
158
 
65
- export async function packageDigest(root) {
159
+ export async function packageDigest(root)
160
+ {
66
161
  const manifest = await readManifest(path.join(root, manifestName));
67
162
  const files = await packageFiles(root, manifest);
68
- return contentDigest(canonical(await Promise.all(files.map(async file => [file, contentDigest(await readFile(path.join(root, file)))]))));
163
+ return contentDigest(
164
+ canonical(
165
+ await Promise.all(
166
+ files.map(async file => [
167
+ file,
168
+ contentDigest(await readFile(path.join(root, file))),
169
+ ]),
170
+ ),
171
+ ),
172
+ );
69
173
  }
70
174
 
71
- async function packageFiles(root, manifest, {publish = false, packageRoot = root} = {}, ancestry = []) {
72
- if (ancestry.includes(root)) throw new Error('Package dependency cycle while collecting published files');
175
+ async function packageFiles(
176
+ root,
177
+ manifest,
178
+ {publish = false, packageRoot = root} = {},
179
+ ancestry = [],
180
+ )
181
+ {
182
+ if (ancestry.includes(root))
183
+ throw new Error(
184
+ 'Package dependency cycle while collecting published files',
185
+ );
73
186
  ancestry = [...ancestry, root];
74
187
  const selected = new Set([manifestName]);
75
188
  const realRoot = await realpath(root);
76
- for (const entry of [...manifest.sources, ...(manifest.assets ?? [])]) {
189
+ for (const entry of [...manifest.sources, ...(manifest.assets ?? [])])
190
+ {
77
191
  const location = path.resolve(root, entry);
78
192
  if (!inside(root, location) || !inside(realRoot, await realpath(location)))
79
193
  throw new Error(`Published package path leaves its root: ${entry}`);
80
194
  await filesUnder(location);
81
195
  }
82
196
  const sources = await collectSources(root, manifest.sources, root);
83
- for (const source of sources) {
84
- if (!inside(root, path.resolve(root, source.path))) throw new Error(`Published package source leaves its root: ${source.path}`);
197
+ for (const source of sources)
198
+ {
199
+ if (!inside(root, path.resolve(root, source.path)))
200
+ throw new Error(
201
+ `Published package source leaves its root: ${source.path}`,
202
+ );
85
203
  selected.add(source.path);
86
204
  }
87
- for (const entry of manifest.assets ?? []) {
205
+ for (const entry of manifest.assets ?? [])
206
+ {
88
207
  const location = path.resolve(root, entry);
89
- if (!inside(root, location)) throw new Error(`Published package asset leaves its root: ${entry}`);
208
+ if (!inside(root, location))
209
+ throw new Error(`Published package asset leaves its root: ${entry}`);
90
210
  const info = await lstat(location);
91
- if (info.isSymbolicLink()) throw new Error(`Published package asset is a symbolic link: ${entry}`);
92
- if (info.isDirectory()) for (const nested of await filesUnder(location)) selected.add(path.relative(root, path.join(location, nested)));
211
+ if (info.isSymbolicLink())
212
+ throw new Error(`Published package asset is a symbolic link: ${entry}`);
213
+ if (info.isDirectory())
214
+ for (const nested of await filesUnder(location))
215
+ selected.add(path.relative(root, path.join(location, nested)));
93
216
  else selected.add(entry);
94
217
  }
95
- for (const dependency of Object.values(manifest.dependencies ?? {})) {
218
+ for (const dependency of Object.values(manifest.dependencies ?? {}))
219
+ {
96
220
  if (!dependency?.path) continue;
97
221
  const location = path.resolve(root, dependency.path);
98
- if (!inside(packageRoot, location)) {
99
- if (publish) throw new Error(`Published package dependency leaves its root: ${dependency.path}`);
222
+ if (!inside(packageRoot, location))
223
+ {
224
+ if (publish)
225
+ throw new Error(
226
+ `Published package dependency leaves its root: ${dependency.path}`,
227
+ );
100
228
  continue;
101
229
  }
102
- if (!inside(await realpath(packageRoot), await realpath(location))) throw new Error('Published dependency leaves its root through a symbolic link');
230
+ if (!inside(await realpath(packageRoot), await realpath(location)))
231
+ throw new Error(
232
+ 'Published dependency leaves its root through a symbolic link',
233
+ );
103
234
  const nested = await readManifest(path.join(location, manifestName));
104
- for (const file of await packageFiles(location, nested, {publish, packageRoot}, ancestry))
235
+ for (const file of await packageFiles(
236
+ location,
237
+ nested,
238
+ {publish, packageRoot},
239
+ ancestry,
240
+ ))
105
241
  selected.add(path.relative(root, path.join(location, file)));
106
242
  }
107
243
  return [...selected].sort();
108
244
  }
109
245
 
110
- async function unpack(bytes, directory) {
246
+ async function unpack(bytes, directory)
247
+ {
111
248
  await mkdir(directory, {recursive: true});
112
249
  let refused;
113
- await pipeline(Readable.from([bytes]), tar.x({cwd: directory, strict: true, preservePaths: false, filter(name, entry) {
114
- const normalized = path.resolve(directory, name);
115
- if (path.isAbsolute(name) || name.split(/[\\/]/).includes('..') || !inside(directory, normalized) || !['File', 'Directory', 'OldFile', 'ContiguousFile'].includes(entry.type)) {
116
- refused = `Unsafe package archive entry: ${name}`;
117
- return false;
118
- }
119
- return true;
120
- }}));
250
+ await pipeline(
251
+ Readable.from([bytes]),
252
+ tar.x({
253
+ cwd: directory,
254
+ strict: true,
255
+ preservePaths: false,
256
+ filter(name, entry)
257
+ {
258
+ const normalized = path.resolve(directory, name);
259
+ if (
260
+ path.isAbsolute(name) ||
261
+ name.split(/[\\/]/).includes('..') ||
262
+ !inside(directory, normalized) ||
263
+ !['File', 'Directory', 'OldFile', 'ContiguousFile'].includes(
264
+ entry.type,
265
+ )
266
+ )
267
+ {
268
+ refused = `Unsafe package archive entry: ${name}`;
269
+ return false;
270
+ }
271
+ return true;
272
+ },
273
+ }),
274
+ );
121
275
  if (refused) throw new Error(refused);
122
276
  }
123
277
 
124
- export async function resolveDependencies(file, manifest, options = {}) {
278
+ export async function resolveDependencies(file, manifest, options = {})
279
+ {
125
280
  const root = path.dirname(path.resolve(file));
126
- const cache = path.resolve(process.env.LAWSPEC_CACHE_DIR ?? path.join(process.env.XDG_CACHE_HOME ?? path.join(os.homedir(), '.cache'), 'lawspec', 'packages'));
127
- const locked = !!options.locked, offline = !!options.offline || process.env.LAWSPEC_OFFLINE === '1';
281
+ const cache = path.resolve(
282
+ process.env.LAWSPEC_CACHE_DIR ??
283
+ path.join(
284
+ process.env.XDG_CACHE_HOME ?? path.join(os.homedir(), '.cache'),
285
+ 'lawspec',
286
+ 'packages',
287
+ ),
288
+ );
289
+ const readOnly = !!options.readOnly;
290
+ const locked = !!options.locked,
291
+ offline =
292
+ readOnly || !!options.offline || process.env.LAWSPEC_OFFLINE === '1';
128
293
  const previousText = await optional(path.join(root, lockName));
129
- const previous = previousText === null ? null : parseManifest(previousText, path.join(root, lockName));
294
+ const previous =
295
+ previousText === null
296
+ ? null
297
+ : parseManifest(previousText, path.join(root, lockName));
130
298
  if (previous) validateLock(previous);
131
- const oldSelections = previous?.selections ?? {}, selections = {}, entries = new Map(), packages = new Map(), identities = new Map();
132
- const local = new Map(), localSeen = new Set(), locations = new Map();
299
+ const oldSelections = previous?.selections ?? {},
300
+ selections = {},
301
+ entries = new Map(),
302
+ packages = new Map(),
303
+ identities = new Map();
304
+ const local = new Map(),
305
+ localSeen = new Set(),
306
+ locations = new Map();
133
307
 
134
- async function localCandidates(directory, owner) {
135
- for (const name of owner.packages ?? []) {
308
+ async function localCandidates(directory, owner)
309
+ {
310
+ for (const name of owner.packages ?? [])
311
+ {
136
312
  const location = path.resolve(directory, name);
137
313
  if (localSeen.has(location)) continue;
138
314
  localSeen.add(location);
139
315
  const candidate = await readManifest(path.join(location, manifestName));
140
- if (!candidate.package) throw new Error(`${location}: expected a package identity`);
316
+ if (!candidate.package)
317
+ throw new Error(`${location}: expected a package identity`);
141
318
  const list = local.get(candidate.package.name) ?? [];
142
319
  list.push({directory: location, manifest: candidate});
143
320
  local.set(candidate.package.name, list);
@@ -146,194 +323,503 @@ export async function resolveDependencies(file, manifest, options = {}) {
146
323
  }
147
324
  await localCandidates(root, manifest);
148
325
 
149
- async function gitRepository(url) {
326
+ async function gitRepository(url)
327
+ {
150
328
  const repository = path.join(cache, 'git', contentDigest(url));
151
- if (await optional(path.join(repository, 'HEAD')) !== null) return repository;
329
+ if ((await optional(path.join(repository, 'HEAD'))) !== null)
330
+ return repository;
152
331
  await mkdir(path.dirname(repository), {recursive: true});
153
- const temporary = await mkdtemp(path.join(path.dirname(repository), '.initializing-'));
154
- try {
332
+ const temporary = await mkdtemp(
333
+ path.join(path.dirname(repository), '.initializing-'),
334
+ );
335
+ try
336
+ {
155
337
  await git(['init', '--bare', '--quiet', temporary]);
156
- try { await rename(temporary, repository); }
157
- catch (error) { if (!['EEXIST', 'ENOTEMPTY', 'EPERM'].includes(error.code)) throw error; }
158
- if (await optional(path.join(repository, 'HEAD')) === null)
159
- throw new Error(`Cached Git repository initialization did not complete: ${repository}`);
160
- } finally { await rm(temporary, {recursive: true, force: true}); }
338
+ try
339
+ {
340
+ await rename(temporary, repository);
341
+ }
342
+ catch (error)
343
+ {
344
+ if (!['EEXIST', 'ENOTEMPTY', 'EPERM'].includes(error.code)) throw error;
345
+ }
346
+ if ((await optional(path.join(repository, 'HEAD'))) === null)
347
+ throw new Error(
348
+ `Cached Git repository initialization did not complete: ${repository}`,
349
+ );
350
+ }
351
+ finally
352
+ {
353
+ await rm(temporary, {recursive: true, force: true});
354
+ }
161
355
  return repository;
162
356
  }
163
357
 
164
- async function gitCheckout(source) {
358
+ async function gitCheckout(source)
359
+ {
165
360
  const repository = await gitRepository(source.url);
166
- const present = await git(['--git-dir', repository, 'cat-file', '-e', `${source.commit}^{commit}`]).then(() => true, () => false);
167
- if (!present) {
168
- if (offline) throw new Error(`Offline: Git revision ${source.commit} is not cached`);
169
- await git(['--git-dir', repository, 'fetch', '--quiet', '--no-tags', '--no-write-fetch-head', '--', source.url, source.commit]);
361
+ const present = await git([
362
+ '--git-dir',
363
+ repository,
364
+ 'cat-file',
365
+ '-e',
366
+ `${source.commit}^{commit}`,
367
+ ]).then(
368
+ () => true,
369
+ () => false,
370
+ );
371
+ if (!present)
372
+ {
373
+ if (offline)
374
+ throw new Error(`Offline: Git revision ${source.commit} is not cached`);
375
+ await git([
376
+ '--git-dir',
377
+ repository,
378
+ 'fetch',
379
+ '--quiet',
380
+ '--no-tags',
381
+ '--no-write-fetch-head',
382
+ '--',
383
+ source.url,
384
+ source.commit,
385
+ ]);
170
386
  }
171
- return git(['--git-dir', repository, 'archive', '--format=tar', source.subdir ? `${source.commit}:${source.subdir}` : source.commit], {encoding: 'buffer'});
387
+ return git(
388
+ [
389
+ '--git-dir',
390
+ repository,
391
+ 'archive',
392
+ '--format=tar',
393
+ source.subdir ? `${source.commit}:${source.subdir}` : source.commit,
394
+ ],
395
+ {encoding: 'buffer'},
396
+ );
172
397
  }
173
398
 
174
- async function downloaded(source, known) {
175
- const id = contentDigest(canonical(source)), directory = path.join(cache, id), marker = path.join(cache, id + '.sha256');
176
- if (await optional(path.join(directory, manifestName)) !== null) {
399
+ async function downloaded(source, known)
400
+ {
401
+ const id = contentDigest(canonical(source)),
402
+ directory = path.join(cache, id),
403
+ marker = path.join(cache, id + '.sha256');
404
+ if ((await optional(path.join(directory, manifestName))) !== null)
405
+ {
177
406
  const expected = known?.digest ?? (await optional(marker))?.trim();
178
- if (expected) {
179
- if (!/^[a-f0-9]{64}$/.test(expected) || await packageDigest(directory) !== expected) throw new Error(`Cached contract content changed: ${known?.name ?? source.url}`);
180
- await atomicWrite(marker, expected + '\n');
407
+ if (expected)
408
+ {
409
+ if (
410
+ !/^[a-f0-9]{64}$/.test(expected) ||
411
+ (await packageDigest(directory)) !== expected
412
+ )
413
+ throw new Error(
414
+ `Cached contract content changed: ${known?.name ?? source.url}`,
415
+ );
416
+ if (!readOnly) await atomicWrite(marker, expected + '\n');
181
417
  return {directory, source};
182
418
  }
183
- if (offline) throw new Error(`Offline: cached contract integrity is unavailable for ${source.url}`);
419
+ if (offline)
420
+ throw new Error(
421
+ `Offline: cached contract integrity is unavailable for ${source.url}`,
422
+ );
184
423
  }
185
- if (offline && source.kind === 'archive') throw new Error(`Offline: ${source.url} is not cached`);
424
+ if (readOnly)
425
+ throw new Error(
426
+ `Read-only dependency resolution requires a verified unpacked cache for ${source.url}; run lawspec fetch separately`,
427
+ );
428
+ if (offline && source.kind === 'archive')
429
+ throw new Error(`Offline: ${source.url} is not cached`);
186
430
  let bytes;
187
431
  if (source.kind === 'git') bytes = await gitCheckout(source);
188
- else {
432
+ else
433
+ {
189
434
  const url = new URL(source.url);
190
- if (url.protocol !== 'https:' && !(url.protocol === 'http:' && ['127.0.0.1', 'localhost', '[::1]'].includes(url.hostname)))
435
+ if (
436
+ url.protocol !== 'https:' &&
437
+ !(
438
+ url.protocol === 'http:' &&
439
+ ['127.0.0.1', 'localhost', '[::1]'].includes(url.hostname)
440
+ )
441
+ )
191
442
  throw new Error('Contract archives must use HTTPS');
192
443
  const answer = await fetch(url);
193
- if (!answer.ok) throw new Error(`Contract download failed: HTTP ${answer.status} for ${url}`);
444
+ if (!answer.ok)
445
+ throw new Error(
446
+ `Contract download failed: HTTP ${answer.status} for ${url}`,
447
+ );
194
448
  bytes = Buffer.from(await answer.arrayBuffer());
195
- if (contentDigest(bytes) !== source.sha256) throw new Error(`Contract archive SHA-256 mismatch: ${url}`);
449
+ if (contentDigest(bytes) !== source.sha256)
450
+ throw new Error(`Contract archive SHA-256 mismatch: ${url}`);
196
451
  }
197
452
  await mkdir(cache, {recursive: true});
198
453
  const temporary = await mkdtemp(path.join(cache, '.unpack-'));
199
- try {
454
+ try
455
+ {
200
456
  await unpack(bytes, temporary);
201
457
  await readManifest(path.join(temporary, manifestName));
202
458
  const digest = await packageDigest(temporary);
203
- try { await rename(temporary, directory); }
204
- catch (error) { if (!['EEXIST', 'ENOTEMPTY'].includes(error.code)) throw error; }
205
- if (await packageDigest(directory) !== digest) throw new Error(`Cached contract content changed: ${source.url}`);
459
+ try
460
+ {
461
+ await rename(temporary, directory);
462
+ }
463
+ catch (error)
464
+ {
465
+ if (!['EEXIST', 'ENOTEMPTY'].includes(error.code)) throw error;
466
+ }
467
+ if ((await packageDigest(directory)) !== digest)
468
+ throw new Error(`Cached contract content changed: ${source.url}`);
206
469
  await atomicWrite(marker, digest + '\n');
207
- } finally { await rm(temporary, {recursive: true, force: true}); }
208
- if (known && await packageDigest(directory) !== known.digest) throw new Error(`Downloaded contract content differs from lock: ${known.name}`);
470
+ }
471
+ finally
472
+ {
473
+ await rm(temporary, {recursive: true, force: true});
474
+ }
475
+ if (known && (await packageDigest(directory)) !== known.digest)
476
+ throw new Error(
477
+ `Downloaded contract content differs from lock: ${known.name}`,
478
+ );
209
479
  return {directory, source};
210
480
  }
211
481
 
212
- function immutableOwner(owner) {
482
+ function immutableOwner(owner)
483
+ {
213
484
  let current = owner;
214
- while (entries.get(current)?.source.kind === 'embedded') current = entries.get(current).source.parent;
215
- return entries.has(current) && entries.get(current).source.kind !== 'path' ? current : null;
485
+ while (entries.get(current)?.source.kind === 'embedded')
486
+ current = entries.get(current).source.parent;
487
+ return entries.has(current) && entries.get(current).source.kind !== 'path'
488
+ ? current
489
+ : null;
216
490
  }
217
491
 
218
- async function localSource(location, owner) {
492
+ async function localSource(location, owner)
493
+ {
219
494
  const parent = immutableOwner(owner);
220
- if (!parent) return {directory: location, source: {kind: 'path', path: path.relative(root, location) || '.'}};
495
+ if (!parent)
496
+ return {
497
+ directory: location,
498
+ source: {kind: 'path', path: path.relative(root, location) || '.'},
499
+ };
221
500
  const directory = locations.get(parent);
222
- if (!inside(directory, location) || !inside(await realpath(directory), await realpath(location)))
223
- throw new Error('Published package dependency leaves its downloaded root');
224
- return {directory: location, source: {kind: 'embedded', parent, path: path.relative(directory, location) || '.'}};
501
+ if (
502
+ !inside(directory, location) ||
503
+ !inside(await realpath(directory), await realpath(location))
504
+ )
505
+ throw new Error(
506
+ 'Published package dependency leaves its downloaded root',
507
+ );
508
+ return {
509
+ directory: location,
510
+ source: {
511
+ kind: 'embedded',
512
+ parent,
513
+ path: path.relative(directory, location) || '.',
514
+ },
515
+ };
225
516
  }
226
517
 
227
- async function materialize(name, specification, directory, old, owner) {
518
+ async function materialize(name, specification, directory, old, owner)
519
+ {
228
520
  const refresh = options.update === true || options.update === name;
229
- if (old && !refresh && canonical(old.request) === canonical(specification)) {
521
+ if (
522
+ old &&
523
+ !refresh &&
524
+ canonical(old.request) === canonical(specification)
525
+ )
526
+ {
230
527
  const entry = previous.packages.find(item => item.id === old.package);
231
- if (!entry) throw new Error(`Lockfile references missing package ${old.package}`);
232
- if (entry.source.kind === 'path') {
233
- if (immutableOwner(owner)) throw new Error('Lockfile contains a non-portable published path; run lawspec update');
234
- return {directory: path.resolve(root, entry.source.path), source: entry.source};
528
+ if (!entry)
529
+ throw new Error(`Lockfile references missing package ${old.package}`);
530
+ if (entry.source.kind === 'path')
531
+ {
532
+ if (immutableOwner(owner))
533
+ throw new Error(
534
+ 'Lockfile contains a non-portable published path; run lawspec update',
535
+ );
536
+ return {
537
+ directory: path.resolve(root, entry.source.path),
538
+ source: entry.source,
539
+ };
235
540
  }
236
- if (entry.source.kind === 'embedded') {
541
+ if (entry.source.kind === 'embedded')
542
+ {
237
543
  const parent = locations.get(entry.source.parent);
238
- if (!parent || entry.source.parent !== immutableOwner(owner)) throw new Error('Invalid embedded package parent in lockfile');
239
- const loaded = await localSource(path.resolve(parent, entry.source.path), owner);
240
- if (await packageDigest(loaded.directory) !== entry.digest) throw new Error(`Cached embedded contract content changed: ${name}`);
544
+ if (!parent || entry.source.parent !== immutableOwner(owner))
545
+ throw new Error('Invalid embedded package parent in lockfile');
546
+ const loaded = await localSource(
547
+ path.resolve(parent, entry.source.path),
548
+ owner,
549
+ );
550
+ if ((await packageDigest(loaded.directory)) !== entry.digest)
551
+ throw new Error(`Cached embedded contract content changed: ${name}`);
241
552
  return loaded;
242
553
  }
243
554
  return downloaded(entry.source, entry);
244
555
  }
245
- if (locked) throw new Error(`Lockfile must change for ${name}; run lawspec fetch without --locked`);
246
- if (typeof specification === 'string') {
556
+ if (locked)
557
+ throw new Error(
558
+ `Lockfile must change for ${name}; run lawspec fetch without --locked`,
559
+ );
560
+ if (typeof specification === 'string')
561
+ {
247
562
  const candidates = local.get(name) ?? [];
248
- const accepted = await packageVersions(specification, candidates.map(item => item.manifest.package.version));
249
- const chosen = candidates.find(item => item.manifest.package.version === accepted[0]);
250
- if (!chosen) throw new Error(`requires ${name} ${specification}, but ${candidates.length === 1 ? 'version ' + candidates[0].manifest.package.version + ' is supplied' : 'no supplied version satisfies it'}`);
563
+ const accepted = await packageVersions(
564
+ specification,
565
+ candidates.map(item => item.manifest.package.version),
566
+ );
567
+ const chosen = candidates.find(
568
+ item => item.manifest.package.version === accepted[0],
569
+ );
570
+ if (!chosen)
571
+ throw new Error(
572
+ `requires ${name} ${specification}, but ${candidates.length === 1 ? 'version ' + candidates[0].manifest.package.version + ' is supplied' : 'no supplied version satisfies it'}`,
573
+ );
251
574
  return localSource(chosen.directory, owner);
252
575
  }
253
- if (specification.path) {
576
+ if (specification.path)
577
+ {
254
578
  const location = path.resolve(directory, specification.path);
255
579
  return localSource(location, owner);
256
580
  }
257
- if (specification.archive) return downloaded({kind: 'archive', url: specification.archive, sha256: specification.sha256});
258
- if (offline) throw new Error(`Offline: resolving ${name} requires a lockfile`);
259
- let ref = specification.rev, tagVersion;
260
- if (!ref) {
581
+ if (specification.archive)
582
+ return downloaded({
583
+ kind: 'archive',
584
+ url: specification.archive,
585
+ sha256: specification.sha256,
586
+ });
587
+ if (offline)
588
+ throw new Error(`Offline: resolving ${name} requires a lockfile`);
589
+ let ref = specification.rev,
590
+ tagVersion;
591
+ if (!ref)
592
+ {
261
593
  const prefix = specification.tagPrefix ?? 'v';
262
- const tags = (await git(['ls-remote', '--tags', '--refs', '--', specification.git])).trim().split('\n').filter(Boolean).map(line => {
263
- const [commit, tag] = line.split(/\s+/);
264
- return {commit, tag: tag.replace('refs/tags/', '')};
265
- }).filter(item => item.tag.startsWith(prefix) && /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/.test(item.tag.slice(prefix.length)));
266
- const versions = await packageVersions(specification.version, tags.map(item => item.tag.slice(prefix.length)));
267
- const chosen = tags.find(item => item.tag.slice(prefix.length) === versions[0]);
268
- if (!chosen) throw new Error(`No published Git version satisfies ${name} ${specification.version}`);
594
+ const tags = (
595
+ await git(['ls-remote', '--tags', '--refs', '--', specification.git])
596
+ )
597
+ .trim()
598
+ .split('\n')
599
+ .filter(Boolean)
600
+ .map(line =>
601
+ {
602
+ const [commit, tag] = line.split(/\s+/);
603
+ return {commit, tag: tag.replace('refs/tags/', '')};
604
+ })
605
+ .filter(
606
+ item =>
607
+ item.tag.startsWith(prefix) &&
608
+ /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/.test(
609
+ item.tag.slice(prefix.length),
610
+ ),
611
+ );
612
+ const versions = await packageVersions(
613
+ specification.version,
614
+ tags.map(item => item.tag.slice(prefix.length)),
615
+ );
616
+ const chosen = tags.find(
617
+ item => item.tag.slice(prefix.length) === versions[0],
618
+ );
619
+ if (!chosen)
620
+ throw new Error(
621
+ `No published Git version satisfies ${name} ${specification.version}`,
622
+ );
269
623
  ref = chosen.commit;
270
624
  tagVersion = chosen.tag.slice(prefix.length);
271
625
  }
272
626
  const repository = await gitRepository(specification.git);
273
627
  const fetched = 'refs/lawspec/' + randomUUID();
274
628
  let commit;
275
- try {
276
- await git(['--git-dir', repository, 'fetch', '--quiet', '--no-tags', '--no-write-fetch-head', '--', specification.git, ref + ':' + fetched]);
277
- commit = (await git(['--git-dir', repository, 'rev-parse', fetched + '^{commit}'])).trim();
278
- } finally { await git(['--git-dir', repository, 'update-ref', '-d', fetched]); }
279
- return downloaded({kind: 'git', url: specification.git, commit, ...(tagVersion ? {tagVersion} : {}), ...(specification.subdir ? {subdir: specification.subdir} : {})});
629
+ try
630
+ {
631
+ await git([
632
+ '--git-dir',
633
+ repository,
634
+ 'fetch',
635
+ '--quiet',
636
+ '--no-tags',
637
+ '--no-write-fetch-head',
638
+ '--',
639
+ specification.git,
640
+ ref + ':' + fetched,
641
+ ]);
642
+ commit = (
643
+ await git(['--git-dir', repository, 'rev-parse', fetched + '^{commit}'])
644
+ ).trim();
645
+ }
646
+ finally
647
+ {
648
+ await git(['--git-dir', repository, 'update-ref', '-d', fetched]);
649
+ }
650
+ return downloaded({
651
+ kind: 'git',
652
+ url: specification.git,
653
+ commit,
654
+ ...(tagVersion ? {tagVersion} : {}),
655
+ ...(specification.subdir ? {subdir: specification.subdir} : {}),
656
+ });
280
657
  }
281
658
 
282
- async function resolve(name, specification, directory, owner, ancestry) {
283
- const key = owner + '::' + name, old = oldSelections[key];
284
- const loaded = await materialize(name, specification, directory, old, owner);
285
- const described = await readManifest(path.join(loaded.directory, manifestName));
286
- if (!described.package || described.package.name !== name) throw new Error(`Dependency ${name} has a different package identity`);
659
+ async function resolve(name, specification, directory, owner, ancestry)
660
+ {
661
+ const key = owner + '::' + name,
662
+ old = oldSelections[key];
663
+ const loaded = await materialize(
664
+ name,
665
+ specification,
666
+ directory,
667
+ old,
668
+ owner,
669
+ );
670
+ const described = await readManifest(
671
+ path.join(loaded.directory, manifestName),
672
+ );
673
+ if (!described.package || described.package.name !== name)
674
+ throw new Error(`Dependency ${name} has a different package identity`);
287
675
  const version = described.package.version;
288
676
  if (loaded.source.tagVersion && loaded.source.tagVersion !== version)
289
- throw new Error(`Git tag version ${loaded.source.tagVersion} differs from ${name} manifest version ${version}`);
290
- if (!(await packageVersions(rangeOf(specification), [version])).length) throw new Error(`requires ${name} ${rangeOf(specification)}, but version ${version} is supplied`);
677
+ throw new Error(
678
+ `Git tag version ${loaded.source.tagVersion} differs from ${name} manifest version ${version}`,
679
+ );
680
+ if (!(await packageVersions(rangeOf(specification), [version])).length)
681
+ throw new Error(
682
+ `requires ${name} ${rangeOf(specification)}, but version ${version} is supplied`,
683
+ );
291
684
  const id = contentDigest(canonical({name, version, source: loaded.source}));
292
685
  selections[key] = {request: specification, package: id};
293
- if (ancestry.includes(id)) throw new Error(`Package dependency cycle: ${[...ancestry, id].join(' -> ')}`);
686
+ if (ancestry.includes(id))
687
+ throw new Error(
688
+ `Package dependency cycle: ${[...ancestry, id].join(' -> ')}`,
689
+ );
294
690
  if (entries.has(id)) return id;
295
- const digest = await packageDigest(loaded.directory), identity = {name, version, source: loaded.source, digest};
296
- const sameVersion = [...identities.values()].find(item => item.name === name && item.version === version);
297
- if (sameVersion && sameVersion.digest !== digest) throw new Error(`Ambiguous content for ${name} ${version}`);
298
- const entry = {id, name, version, source: loaded.source, ...(loaded.source.kind === 'path' ? {} : {digest}), dependencies: {}};
691
+ const digest = await packageDigest(loaded.directory),
692
+ identity = {name, version, source: loaded.source, digest};
693
+ const sameVersion = [...identities.values()].find(
694
+ item => item.name === name && item.version === version,
695
+ );
696
+ if (sameVersion && sameVersion.digest !== digest)
697
+ throw new Error(`Ambiguous content for ${name} ${version}`);
698
+ const entry = {
699
+ id,
700
+ name,
701
+ version,
702
+ source: loaded.source,
703
+ ...(loaded.source.kind === 'path' ? {} : {digest}),
704
+ dependencies: {},
705
+ };
299
706
  entries.set(id, entry);
300
707
  identities.set(id, identity);
301
708
  locations.set(id, loaded.directory);
302
709
  await localCandidates(loaded.directory, described);
303
- for (const [dependency, child] of Object.entries(described.dependencies ?? {}).sort())
304
- entry.dependencies[dependency] = await resolve(dependency, child, loaded.directory, id, [...ancestry, id]);
305
- packages.set(id, {name, version, dependencies: dependencyRanges(described), sources: await collectSources(loaded.directory, described.sources, root)});
710
+ for (const [dependency, child] of Object.entries(
711
+ described.dependencies ?? {},
712
+ ).sort())
713
+ entry.dependencies[dependency] = await resolve(
714
+ dependency,
715
+ child,
716
+ loaded.directory,
717
+ id,
718
+ [...ancestry, id],
719
+ );
720
+ packages.set(id, {
721
+ name,
722
+ version,
723
+ dependencies: dependencyRanges(described),
724
+ sources: await collectSources(loaded.directory, described.sources, root),
725
+ });
306
726
  return id;
307
727
  }
308
728
  const roots = {};
309
- for (const [name, specification] of Object.entries(manifest.dependencies ?? {}).sort())
729
+ for (const [name, specification] of Object.entries(
730
+ manifest.dependencies ?? {},
731
+ ).sort())
310
732
  roots[name] = await resolve(name, specification, root, '$', []);
311
- const lock = {format: 'lawspec-lock', version: 1, roots, selections, packages: [...entries.values()].sort((a,b) => a.id.localeCompare(b.id))};
312
- if (entries.size || previous) {
313
- if (locked && canonical(lock) !== canonical(previous)) throw new Error('Lockfile is out of date; run lawspec fetch');
314
- if (!locked && canonical(lock) !== canonical(previous)) await atomicWrite(path.join(root, lockName), writeManifest(lock));
733
+ const lock = {
734
+ format: 'lawspec-lock',
735
+ version: 1,
736
+ roots,
737
+ selections,
738
+ packages: [...entries.values()].sort((a, b) => a.id.localeCompare(b.id)),
739
+ };
740
+ if (entries.size || previous)
741
+ {
742
+ if (locked && canonical(lock) !== canonical(previous))
743
+ throw new Error('Lockfile is out of date; run lawspec fetch');
744
+ if (
745
+ !locked &&
746
+ !readOnly &&
747
+ options.writeLock !== false &&
748
+ canonical(lock) !== canonical(previous)
749
+ )
750
+ await atomicWrite(path.join(root, lockName), writeManifest(lock));
315
751
  }
316
752
  const semantic = new Map();
317
- const closure = id => {
318
- if (!semantic.has(id)) semantic.set(id, resolvedPackageDigest(identities.get(id).digest,
319
- Object.fromEntries(Object.entries(entries.get(id).dependencies).map(([name,child]) => [name, closure(child)]))));
753
+ const closure = id =>
754
+ {
755
+ if (!semantic.has(id))
756
+ semantic.set(
757
+ id,
758
+ resolvedPackageDigest(
759
+ identities.get(id).digest,
760
+ Object.fromEntries(
761
+ Object.entries(entries.get(id).dependencies).map(
762
+ ([name, child]) => [name, closure(child)],
763
+ ),
764
+ ),
765
+ ),
766
+ );
320
767
  return semantic.get(id);
321
768
  };
322
- const resolvedIdentities = [...identities].map(([id,value]) => ({...value, contentDigest: value.digest, digest: closure(id)}));
323
- for (const identity of resolvedIdentities) {
324
- const alternatives = resolvedIdentities.filter(other => other.name === identity.name && other.version === identity.version);
325
- if (alternatives.some(other => other.digest !== identity.digest)) throw new Error(`Ambiguous resolved contract closure for ${identity.name} ${identity.version}`);
769
+ const resolvedIdentities = [...identities].map(([id, value]) => ({
770
+ ...value,
771
+ contentDigest: value.digest,
772
+ digest: closure(id),
773
+ }));
774
+ for (const identity of resolvedIdentities)
775
+ {
776
+ const alternatives = resolvedIdentities.filter(
777
+ other =>
778
+ other.name === identity.name && other.version === identity.version,
779
+ );
780
+ if (alternatives.some(other => other.digest !== identity.digest))
781
+ throw new Error(
782
+ `Ambiguous resolved contract closure for ${identity.name} ${identity.version}`,
783
+ );
326
784
  }
327
- const ordered = values => [...values].sort((a,b) => a.name.localeCompare(b.name) || a.version.localeCompare(b.version));
328
- return {packages: ordered(packages.values()), identities: ordered(resolvedIdentities), lock};
785
+ const ordered = values =>
786
+ [...values].sort(
787
+ (a, b) =>
788
+ a.name.localeCompare(b.name) || a.version.localeCompare(b.version),
789
+ );
790
+ return {
791
+ packages: ordered(packages.values()),
792
+ identities: ordered(resolvedIdentities),
793
+ lock,
794
+ };
329
795
  }
330
796
 
331
- export async function packComponent(file, output) {
332
- if (path.basename(file) !== manifestName) throw new Error('Published packages require the canonical lawspec.edn filename');
333
- const manifest = await readManifest(file), root = path.dirname(path.resolve(file));
334
- if (!manifest.package) throw new Error('lawspec package --output requires a package identity');
797
+ export async function packComponent(file, output)
798
+ {
799
+ if (path.basename(file) !== manifestName)
800
+ throw new Error(
801
+ 'Published packages require the canonical lawspec.edn filename',
802
+ );
803
+ const manifest = await readManifest(file),
804
+ root = path.dirname(path.resolve(file));
805
+ if (!manifest.package)
806
+ throw new Error('lawspec package --output requires a package identity');
335
807
  const selected = await packageFiles(root, manifest, {publish: true});
336
808
  await mkdir(path.dirname(path.resolve(output)), {recursive: true});
337
- await tar.c({cwd: root, file: path.resolve(output), gzip: true, portable: true, mtime: new Date(0), noDirRecurse: true}, selected);
338
- return {file: path.resolve(output), sha256: contentDigest(await readFile(output)), package: manifest.package};
809
+ await tar.c(
810
+ {
811
+ cwd: root,
812
+ file: path.resolve(output),
813
+ gzip: true,
814
+ portable: true,
815
+ mtime: new Date(0),
816
+ noDirRecurse: true,
817
+ },
818
+ selected,
819
+ );
820
+ return {
821
+ file: path.resolve(output),
822
+ sha256: contentDigest(await readFile(output)),
823
+ package: manifest.package,
824
+ };
339
825
  }