@ref0/git 0.12.0 → 0.20.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 (436) hide show
  1. package/dist/access/private-refs.mjs +3 -3
  2. package/dist/auth/access-jwt.mjs +2 -2
  3. package/dist/auth/auth.d.mts +2 -2
  4. package/dist/auth/auth.mjs +3 -6
  5. package/dist/auth/authorize.mjs +4 -20
  6. package/dist/auth/fences.d.mts +1 -2
  7. package/dist/auth/fences.mjs +3 -3
  8. package/dist/auth/grants.mjs +4 -4
  9. package/dist/auth/helpers.mjs +3 -11
  10. package/dist/auth/host-function.mjs +18 -1
  11. package/dist/auth/host-services.mjs +11 -0
  12. package/dist/auth/identify.d.mts +1 -1
  13. package/dist/auth/identify.mjs +3 -3
  14. package/dist/auth/policy.d.mts +27 -7
  15. package/dist/auth/policy.mjs +8 -4
  16. package/dist/auth/token-cleanup.mjs +67 -0
  17. package/dist/auth/token-rows.mjs +1 -1
  18. package/dist/auth/token-text.mjs +9 -1
  19. package/dist/auth/tokens-base.d.mts +35 -0
  20. package/dist/auth/tokens-base.mjs +13 -0
  21. package/dist/auth/tokens-layer.d.mts +2 -28
  22. package/dist/auth/tokens-layer.mjs +6 -12
  23. package/dist/auth/tokens-public.d.mts +3 -3
  24. package/dist/auth/tokens.d.mts +7 -17
  25. package/dist/auth/tokens.mjs +9 -87
  26. package/dist/auth.d.mts +1 -4
  27. package/dist/auth.mjs +1 -3
  28. package/dist/client/answer.mjs +21 -42
  29. package/dist/client/client.d.mts +2 -4
  30. package/dist/client/git-http.mjs +35 -11
  31. package/dist/client/local.mjs +14 -13
  32. package/dist/client/push-upload.mjs +39 -12
  33. package/dist/client/remote.mjs +95 -31
  34. package/dist/client/run-remote-helper.d.mts +1 -0
  35. package/dist/client/run-remote-helper.mjs +58 -24
  36. package/dist/client/slice-push.d.mts +1 -1
  37. package/dist/client/transport.mjs +105 -46
  38. package/dist/contracts/access.d.mts +8 -8
  39. package/dist/contracts/actors.d.mts +2 -34
  40. package/dist/contracts/blobs.d.mts +57 -10
  41. package/dist/contracts/blobs.mjs +16 -2
  42. package/dist/contracts/call-allowance.d.mts +13 -0
  43. package/dist/contracts/call-allowance.mjs +44 -0
  44. package/dist/contracts/calls-spent.mjs +8 -3
  45. package/dist/contracts/client.d.mts +23 -19
  46. package/dist/contracts/commits.d.mts +34 -26
  47. package/dist/contracts/commits.mjs +9 -1
  48. package/dist/contracts/engine.d.mts +6 -1
  49. package/dist/contracts/engine.mjs +10 -1
  50. package/dist/contracts/files.d.mts +12 -12
  51. package/dist/contracts/forks.d.mts +27 -17
  52. package/dist/contracts/git-events.d.mts +29 -1
  53. package/dist/contracts/git-hooks.d.mts +1 -1
  54. package/dist/contracts/git.d.mts +39 -7
  55. package/dist/contracts/git.mjs +3 -2
  56. package/dist/contracts/grants.d.mts +24 -4
  57. package/dist/contracts/handlers.d.mts +1 -1
  58. package/dist/contracts/lfs.d.mts +28 -9
  59. package/dist/contracts/merges.d.mts +3 -2
  60. package/dist/contracts/objects.d.mts +103 -35
  61. package/dist/contracts/operations.d.mts +3 -0
  62. package/dist/contracts/operations.mjs +12 -2
  63. package/dist/contracts/push-uploads.d.mts +44 -5
  64. package/dist/contracts/push-uploads.mjs +7 -3
  65. package/dist/contracts/queue.d.mts +40 -12
  66. package/dist/contracts/queue.mjs +3 -4
  67. package/dist/contracts/refs.d.mts +50 -25
  68. package/dist/contracts/remote.d.mts +6 -7
  69. package/dist/contracts/remote.mjs +5 -4
  70. package/dist/contracts/repo-records.d.mts +1 -0
  71. package/dist/contracts/repos.d.mts +106 -127
  72. package/dist/contracts/repos.mjs +33 -4
  73. package/dist/contracts/result.d.mts +49 -25
  74. package/dist/contracts/result.mjs +52 -11
  75. package/dist/contracts/rules.d.mts +22 -22
  76. package/dist/contracts/server.d.mts +37 -111
  77. package/dist/contracts/services.d.mts +1 -1
  78. package/dist/contracts/signin.d.mts +1 -1
  79. package/dist/contracts/store.d.mts +6 -5
  80. package/dist/contracts/sync.d.mts +90 -26
  81. package/dist/contracts/sync.mjs +45 -11
  82. package/dist/contracts/tags.d.mts +10 -10
  83. package/dist/contracts/time.d.mts +3 -0
  84. package/dist/contracts/{promises.mjs → time.mjs} +1 -1
  85. package/dist/contracts/tokens.d.mts +15 -22
  86. package/dist/contracts/tokens.mjs +3 -3
  87. package/dist/contracts/topics.d.mts +1 -6
  88. package/dist/contracts/trees.d.mts +12 -12
  89. package/dist/contracts/work.d.mts +87 -12
  90. package/dist/contracts/work.mjs +8 -1
  91. package/dist/core/access.d.mts +1 -2
  92. package/dist/core/access.mjs +46 -13
  93. package/dist/core/ancestry.d.mts +10 -0
  94. package/dist/core/ancestry.mjs +6 -6
  95. package/dist/core/asked.mjs +43 -5
  96. package/dist/core/call-names.mjs +7 -1
  97. package/dist/core/call-services.mjs +13 -4
  98. package/dist/core/events/deliver.d.mts +1 -2
  99. package/dist/core/events/deliver.mjs +48 -33
  100. package/dist/core/events/retired.mjs +119 -0
  101. package/dist/core/forks.mjs +931 -435
  102. package/dist/core/hooks/groups.mjs +1 -1
  103. package/dist/core/imports.mjs +159 -15
  104. package/dist/core/index-job.mjs +128 -37
  105. package/dist/core/index-lost.d.mts +1 -2
  106. package/dist/core/index-lost.mjs +2 -2
  107. package/dist/core/job-view.mjs +8 -9
  108. package/dist/core/loose-tally.mjs +1 -1
  109. package/dist/core/mirror-rows.mjs +19 -4
  110. package/dist/core/objects/blobs.mjs +129 -3
  111. package/dist/core/objects/commits.mjs +16 -6
  112. package/dist/core/objects/lines.mjs +2 -2
  113. package/dist/core/objects/merges.mjs +4 -1
  114. package/dist/core/objects/objects-layer.d.mts +1 -1
  115. package/dist/core/objects/objects-layer.mjs +3 -3
  116. package/dist/core/objects/reading.mjs +24 -13
  117. package/dist/core/objects/tags.mjs +4 -1
  118. package/dist/core/objects/trees.mjs +2 -2
  119. package/dist/core/objects/writing.mjs +2 -2
  120. package/dist/core/own-writes.mjs +1 -1
  121. package/dist/core/parts.d.mts +10 -6
  122. package/dist/core/parts.mjs +3 -11
  123. package/dist/core/promise.mjs +9 -12
  124. package/dist/core/purge.mjs +316 -42
  125. package/dist/core/push-decide.mjs +3 -1
  126. package/dist/core/push-files.d.mts +12 -0
  127. package/dist/core/push-files.mjs +225 -0
  128. package/dist/core/push-repo.d.mts +8 -0
  129. package/dist/core/push-repo.mjs +56 -0
  130. package/dist/core/push.d.mts +17 -0
  131. package/dist/core/push.mjs +153 -70
  132. package/dist/core/receipts.mjs +34 -13
  133. package/dist/core/ref-index-job.mjs +4 -4
  134. package/dist/core/ref-view.mjs +61 -7
  135. package/dist/core/refs.mjs +18 -13
  136. package/dist/core/registered-rows.mjs +2 -2
  137. package/dist/core/repack.mjs +46 -28
  138. package/dist/core/repo-info.mjs +19 -12
  139. package/dist/core/repos.mjs +50 -22
  140. package/dist/core/rules/commit-changes.d.mts +0 -1
  141. package/dist/core/saved-caller-views.d.mts +7 -2
  142. package/dist/core/saved-caller-views.mjs +2 -2
  143. package/dist/core/saved-callers.d.mts +19 -2
  144. package/dist/core/seam.d.mts +16 -26
  145. package/dist/core/seam.mjs +7 -28
  146. package/dist/core/tokens.mjs +1 -1
  147. package/dist/core/view.d.mts +6 -0
  148. package/dist/core/view.mjs +51 -26
  149. package/dist/core/work.mjs +105 -35
  150. package/dist/effect.d.mts +5 -12
  151. package/dist/effect.mjs +3 -10
  152. package/dist/engine/failures.mjs +2 -1
  153. package/dist/engine/reads.mjs +17 -10
  154. package/dist/engine/walk.mjs +4 -4
  155. package/dist/event-streams/event-streams.d.mts +1 -1
  156. package/dist/event-streams/event-streams.mjs +1 -1
  157. package/dist/event-streams/stream.d.mts +3 -3
  158. package/dist/event-streams/stream.mjs +38 -15
  159. package/dist/extend.d.mts +4 -5
  160. package/dist/extend.mjs +3 -2
  161. package/dist/http/answers.mjs +12 -7
  162. package/dist/http/core-parts.mjs +129 -64
  163. package/dist/http/handler.mjs +36 -9
  164. package/dist/http/node.d.mts +14 -1
  165. package/dist/http/node.mjs +61 -31
  166. package/dist/http/parts.d.mts +2 -0
  167. package/dist/http/push-upload-job.mjs +507 -0
  168. package/dist/http/push-uploads.d.mts +1 -0
  169. package/dist/http/push-uploads.mjs +142 -69
  170. package/dist/http/upload-pack.mjs +10 -9
  171. package/dist/index.d.mts +27 -28
  172. package/dist/index.mjs +5 -8
  173. package/dist/lfs/answer.mjs +37 -0
  174. package/dist/lfs/base.d.mts +9 -3
  175. package/dist/lfs/base.mjs +27 -2
  176. package/dist/lfs/copy.d.mts +60 -0
  177. package/dist/lfs/copy.mjs +109 -0
  178. package/dist/lfs/layer.d.mts +15 -1
  179. package/dist/lfs/layer.mjs +28 -13
  180. package/dist/lfs/locks.mjs +2 -2
  181. package/dist/lfs/objects.d.mts +7 -0
  182. package/dist/lfs/objects.mjs +152 -55
  183. package/dist/lfs/pointers.mjs +2 -2
  184. package/dist/lfs/rows.d.mts +13 -0
  185. package/dist/lfs/rows.mjs +42 -8
  186. package/dist/lfs/service.d.mts +1 -7
  187. package/dist/lfs/service.mjs +1 -9
  188. package/dist/lfs/upkeep.mjs +48 -14
  189. package/dist/lfs/upload-most.mjs +5 -5
  190. package/dist/lfs/wire.mjs +6 -31
  191. package/dist/merges/merges.mjs +2 -2
  192. package/dist/node.d.mts +3 -3
  193. package/dist/protocol/bytes/buffers.mjs +13 -5
  194. package/dist/protocol/bytes/reader.mjs +6 -1
  195. package/dist/protocol/bytes/sha256-hasher.d.mts +15 -0
  196. package/dist/protocol/bytes/sha256.d.mts +32 -0
  197. package/dist/protocol/bytes/sha256.mjs +105 -49
  198. package/dist/protocol/bytes/streams.mjs +27 -1
  199. package/dist/protocol/diff/read.d.mts +4 -3
  200. package/dist/protocol/diff/read.mjs +8 -3
  201. package/dist/protocol/objects/lfs-pointer.d.mts +14 -2
  202. package/dist/protocol/objects/lfs-pointer.mjs +1 -3
  203. package/dist/protocol/objects/links-raw.mjs +24 -10
  204. package/dist/protocol/objects/tag.d.mts +1 -1
  205. package/dist/protocol/objects/tree.mjs +23 -6
  206. package/dist/protocol/packs/delta.d.mts +6 -3
  207. package/dist/protocol/packs/delta.mjs +96 -32
  208. package/dist/protocol/packs/idx.d.mts +2 -1
  209. package/dist/protocol/packs/idx.mjs +22 -3
  210. package/dist/protocol/packs/parts.d.mts +4 -1
  211. package/dist/protocol/packs/parts.mjs +10 -7
  212. package/dist/protocol/packs/reader.d.mts +5 -0
  213. package/dist/protocol/packs/reader.mjs +3 -2
  214. package/dist/protocol/packs/writer.mjs +26 -8
  215. package/dist/protocol/wire/advertisement.mjs +9 -4
  216. package/dist/protocol/wire/lines.d.mts +4 -2
  217. package/dist/protocol/wire/lines.mjs +11 -5
  218. package/dist/protocol/wire/push-uploads.mjs +13 -1
  219. package/dist/protocol/wire/v2.mjs +2 -2
  220. package/dist/protocol.d.mts +3 -1
  221. package/dist/protocol.mjs +3 -1
  222. package/dist/queue/advance.mjs +22 -25
  223. package/dist/queue/base.d.mts +55 -0
  224. package/dist/queue/base.mjs +44 -0
  225. package/dist/queue/calls.mjs +51 -54
  226. package/dist/queue/commit.mjs +1 -1
  227. package/dist/queue/host.d.mts +2 -22
  228. package/dist/queue/host.mjs +2 -13
  229. package/dist/queue/layer.d.mts +2 -1
  230. package/dist/queue/layer.mjs +11 -4
  231. package/dist/queue/limits.mjs +2 -0
  232. package/dist/queue/push-option.mjs +9 -24
  233. package/dist/queue/schedule.mjs +1 -1
  234. package/dist/queue/state.mjs +2 -10
  235. package/dist/queue/trim.mjs +6 -4
  236. package/dist/rest/blobs.mjs +29 -5
  237. package/dist/rest/caller.d.mts +4 -4231
  238. package/dist/rest/caller.mjs +5 -1
  239. package/dist/rest/client.d.mts +15 -5
  240. package/dist/rest/client.mjs +23 -2
  241. package/dist/rest/events.mjs +1 -2
  242. package/dist/rest/handler.mjs +4 -57
  243. package/dist/rest/handlers.mjs +68 -9
  244. package/dist/rest/layer.d.mts +2 -2
  245. package/dist/rest/layer.mjs +7 -13
  246. package/dist/rest/me.d.mts +3 -428
  247. package/dist/rest/paths.mjs +1 -0
  248. package/dist/rest/work.mjs +8 -0
  249. package/dist/server/check-fetch.mjs +3 -3
  250. package/dist/server/edge-node.d.mts +14 -15
  251. package/dist/server/edge-node.mjs +12 -12
  252. package/dist/server/edge.d.mts +21 -7
  253. package/dist/server/edge.mjs +32 -11
  254. package/dist/server/extension.mjs +1 -1
  255. package/dist/server/git-layer.d.mts +6 -11
  256. package/dist/server/git-layer.mjs +29 -23
  257. package/dist/server/git-namespace.d.mts +5 -4
  258. package/dist/server/git-namespace.mjs +3 -2
  259. package/dist/server/joined.d.mts +21 -40
  260. package/dist/server/joined.mjs +11 -62
  261. package/dist/server/lifecycle.mjs +65 -69
  262. package/dist/server/registry.mjs +28 -3
  263. package/dist/server/server.mjs +245 -465
  264. package/dist/signin/context.d.mts +1 -2
  265. package/dist/signin/layer.d.mts +1 -1
  266. package/dist/signin/layer.mjs +1 -1
  267. package/dist/storage/allotted.mjs +18 -3
  268. package/dist/storage/batch-upkeep.mjs +274 -0
  269. package/dist/{core/purge.d.mts → storage/batches.d.mts} +4 -4
  270. package/dist/storage/batches.mjs +344 -0
  271. package/dist/storage/budget.mjs +2 -2
  272. package/dist/storage/calls.d.mts +1 -2
  273. package/dist/storage/calls.mjs +144 -158
  274. package/dist/storage/chunks.d.mts +9 -0
  275. package/dist/storage/chunks.mjs +297 -0
  276. package/dist/storage/clean-up.mjs +85 -19
  277. package/dist/storage/counted-bucket.mjs +4 -4
  278. package/dist/storage/fetch.d.mts +1 -0
  279. package/dist/storage/fetch.mjs +298 -216
  280. package/dist/storage/file-limits.mjs +24 -0
  281. package/dist/storage/host-bucket.mjs +1 -2
  282. package/dist/storage/id-mix.mjs +19 -5
  283. package/dist/storage/index-bitmaps.mjs +9 -2
  284. package/dist/storage/index-build.d.mts +1 -1
  285. package/dist/storage/index-build.mjs +185 -84
  286. package/dist/storage/index-fetch.mjs +128 -74
  287. package/dist/storage/index-files.d.mts +3 -0
  288. package/dist/storage/index-files.mjs +10 -5
  289. package/dist/storage/index-graph.mjs +72 -22
  290. package/dist/storage/index-reach.mjs +33 -5
  291. package/dist/storage/index-remap.mjs +208 -65
  292. package/dist/storage/index-shallow.mjs +5 -3
  293. package/dist/storage/index-whole.mjs +127 -0
  294. package/dist/storage/largest-files.mjs +48 -0
  295. package/dist/storage/layout.mjs +23 -0
  296. package/dist/storage/lfs-pointers.mjs +10 -1
  297. package/dist/storage/loose.d.mts +7 -4
  298. package/dist/storage/loose.mjs +214 -67
  299. package/dist/storage/memory-budget.mjs +44 -8
  300. package/dist/storage/merge-plan.mjs +3 -2
  301. package/dist/storage/merge-row.mjs +7 -1
  302. package/dist/storage/merge-stream.mjs +164 -25
  303. package/dist/storage/merge-walk.mjs +8 -4
  304. package/dist/storage/merge-write.mjs +1 -1
  305. package/dist/storage/merge.d.mts +1 -1
  306. package/dist/storage/merge.mjs +1 -1
  307. package/dist/storage/object-rows.d.mts +1 -0
  308. package/dist/storage/object-rows.mjs +385 -65
  309. package/dist/storage/oid-table.mjs +171 -0
  310. package/dist/storage/pack-order.mjs +8 -4
  311. package/dist/storage/pack-ranges.d.mts +1 -2
  312. package/dist/storage/pack-ranges.mjs +4 -5
  313. package/dist/storage/pack-reads.d.mts +2 -1
  314. package/dist/storage/pack-reads.mjs +165 -49
  315. package/dist/storage/pack-receive.d.mts +1 -1
  316. package/dist/storage/pack-receive.mjs +85 -27
  317. package/dist/storage/packs.d.mts +1 -1
  318. package/dist/storage/packs.mjs +172 -86
  319. package/dist/storage/placed-reads.mjs +1 -1
  320. package/dist/storage/plan-columns.d.mts +4 -0
  321. package/dist/storage/plan-columns.mjs +238 -0
  322. package/dist/storage/prune-keep.mjs +299 -37
  323. package/dist/storage/prune-walk.mjs +240 -62
  324. package/dist/storage/prune.mjs +749 -213
  325. package/dist/storage/push-allotment.mjs +91 -12
  326. package/dist/storage/push-uploads.mjs +40 -16
  327. package/dist/storage/pushed-commits.mjs +4 -2
  328. package/dist/storage/quarantine.d.mts +1 -1
  329. package/dist/storage/quarantine.mjs +9 -9
  330. package/dist/storage/range-cache.mjs +125 -8
  331. package/dist/storage/ready.d.mts +1 -1
  332. package/dist/storage/ready.mjs +55 -25
  333. package/dist/storage/receive-bounds.mjs +51 -15
  334. package/dist/storage/receive-state.mjs +8 -0
  335. package/dist/storage/receive-steps.mjs +71 -18
  336. package/dist/storage/repack-backlog.mjs +6 -3
  337. package/dist/storage/repack.d.mts +2 -2
  338. package/dist/storage/repack.mjs +1 -8
  339. package/dist/storage/rows.d.mts +1 -1
  340. package/dist/storage/rows.mjs +13 -2
  341. package/dist/storage/runs.mjs +195 -43
  342. package/dist/storage/send-list.d.mts +1 -0
  343. package/dist/storage/send-list.mjs +54 -10
  344. package/dist/storage/shallow.d.mts +1 -0
  345. package/dist/storage/shallow.mjs +26 -4
  346. package/dist/storage/single-flight.mjs +13 -7
  347. package/dist/storage/stream-whole.mjs +132 -28
  348. package/dist/storage/unpack.mjs +371 -79
  349. package/dist/storage/visible.mjs +31 -3
  350. package/dist/storage/walk.mjs +194 -39
  351. package/dist/storage/wants.mjs +5 -5
  352. package/dist/store/bodies.mjs +38 -0
  353. package/dist/store/call-count.d.mts +8 -12
  354. package/dist/store/call-count.mjs +34 -46
  355. package/dist/store/catalogue.d.mts +2 -2
  356. package/dist/store/catalogue.mjs +146 -35
  357. package/dist/store/crossing.mjs +1 -3
  358. package/dist/store/cursor-seal-namespace.d.mts +2 -0
  359. package/dist/store/cursor-seal-public.d.mts +5 -0
  360. package/dist/store/cursor-seal-public.mjs +5 -0
  361. package/dist/store/cursor-seal.d.mts +16 -3
  362. package/dist/store/cursor-seal.mjs +40 -18
  363. package/dist/store/door.mjs +183 -0
  364. package/dist/store/errors.d.mts +3 -4
  365. package/dist/store/errors.mjs +24 -34
  366. package/dist/store/git-store.mjs +25 -7
  367. package/dist/store/job-try.mjs +9 -32
  368. package/dist/store/list-job.mjs +44 -8
  369. package/dist/store/records.d.mts +5 -0
  370. package/dist/store/records.mjs +12 -6
  371. package/dist/store/repo-record.d.mts +10 -9
  372. package/dist/store/repo-record.mjs +123 -28
  373. package/dist/store/reservations.mjs +1 -1
  374. package/dist/store/scopes.mjs +21 -2
  375. package/dist/store/settle.mjs +4 -4
  376. package/dist/sync/bound.d.mts +2 -0
  377. package/dist/sync/bound.mjs +11 -2
  378. package/dist/sync/github.d.mts +6 -1
  379. package/dist/sync/github.mjs +56 -44
  380. package/dist/sync/http.mjs +36 -1
  381. package/dist/sync/import.mjs +32 -18
  382. package/dist/sync/layer.mjs +6 -2
  383. package/dist/sync/lfs-batch.mjs +118 -0
  384. package/dist/sync/lfs-copy.mjs +262 -0
  385. package/dist/sync/mirror.mjs +227 -151
  386. package/dist/sync/said.mjs +16 -37
  387. package/dist/sync/smart-http.mjs +4 -2
  388. package/dist/sync/step.mjs +58 -30
  389. package/dist/sync/tries.mjs +52 -21
  390. package/dist/sync.d.mts +2 -2
  391. package/dist/topics/advance.mjs +10 -11
  392. package/dist/topics/base.d.mts +15 -0
  393. package/dist/topics/base.mjs +8 -0
  394. package/dist/topics/host.mjs +2 -20
  395. package/dist/topics/layer.d.mts +4 -9
  396. package/dist/topics/layer.mjs +3 -4
  397. package/dist/topics/members.mjs +4 -4
  398. package/dist/topics/public.d.mts +2 -1
  399. package/dist/topics/topic.mjs +2 -2
  400. package/package.json +5 -9
  401. package/dist/auth/bridge.mjs +0 -30
  402. package/dist/auth/helpers.d.mts +0 -17
  403. package/dist/contracts/promises.d.mts +0 -39
  404. package/dist/core/call-names.d.mts +0 -3
  405. package/dist/core/clock.mjs +0 -18
  406. package/dist/core/registered-rows.d.mts +0 -5
  407. package/dist/core/repack.d.mts +0 -11
  408. package/dist/http/handler.d.mts +0 -2
  409. package/dist/lfs/calls.mjs +0 -26
  410. package/dist/rest/api.d.mts +0 -23
  411. package/dist/rest/blobs.d.mts +0 -825
  412. package/dist/rest/commits.d.mts +0 -3510
  413. package/dist/rest/errors.d.mts +0 -2104
  414. package/dist/rest/events.d.mts +0 -423
  415. package/dist/rest/files.d.mts +0 -1330
  416. package/dist/rest/forks.d.mts +0 -2136
  417. package/dist/rest/handler.d.mts +0 -21
  418. package/dist/rest/handlers.d.mts +0 -8
  419. package/dist/rest/merges.d.mts +0 -473
  420. package/dist/rest/queue.d.mts +0 -5861
  421. package/dist/rest/refs.d.mts +0 -2959
  422. package/dist/rest/repos.d.mts +0 -2539
  423. package/dist/rest/tags.d.mts +0 -1304
  424. package/dist/rest/tokens.d.mts +0 -2590
  425. package/dist/rest/topics.d.mts +0 -2204
  426. package/dist/rest/trees.d.mts +0 -1693
  427. package/dist/rest/work.d.mts +0 -1248
  428. package/dist/rest.d.mts +0 -2
  429. package/dist/rest.mjs +0 -1
  430. package/dist/server/lifecycle.d.mts +0 -2
  431. package/dist/server/registry.d.mts +0 -16
  432. package/dist/server/server.d.mts +0 -36
  433. package/dist/storage/repack-job.d.mts +0 -3
  434. package/dist/store/promises.d.mts +0 -11
  435. package/dist/store/promises.mjs +0 -327
  436. package/dist/topics/host.d.mts +0 -7
package/dist/lfs/wire.mjs CHANGED
@@ -1,17 +1,16 @@
1
- import { fail, httpStatus } from "../contracts/result.mjs";
1
+ import { fail } from "../contracts/result.mjs";
2
2
  import { decodeJson } from "../protocol/wire/json.mjs";
3
3
  import { boundedBytes } from "../protocol/bytes/reader.mjs";
4
4
  import { brokenRead, endedEarly, readBody } from "../store/errors.mjs";
5
+ import { lfsResponse } from "./answer.mjs";
5
6
  import * as Effect from "effect/Effect";
6
7
  import * as Schema from "effect/Schema";
7
8
  import * as Result from "effect/Result";
8
9
  // src/lfs/wire.ts
9
10
  /**
10
- * Git LFS's wire: its JSON bodies, as the batch and locking APIs name them, and its answers. A
11
- * refusal is LFS's `{ message }`, and a 401 asks for Basic credentials as `LFS-Authenticate`, so
12
- * the client asks Git's credential helper for the same ones a push sends.
11
+ * Git LFS's wire: its JSON bodies, as the batch and locking APIs name them, and its answers with
12
+ * them. A refusal's is `answer.ts`'s.
13
13
  */
14
- const lfsType = "application/vnd.git-lfs+json";
15
14
  /** The most a JSON body may hold: a batch of 1,000 objects is about 100 KiB. */
16
15
  const bodyMost = 1048576;
17
16
  /** The most objects one batch names: git-lfs sends 100 at a time. */
@@ -73,7 +72,6 @@ const LfsLock = /* @__PURE__ */ Schema.Struct({
73
72
  locked_at: Schema.String,
74
73
  owner: Schema.Struct({ name: Schema.String })
75
74
  });
76
- const noStore = { "cache-control": "no-store" };
77
75
  /**
78
76
  * The bodies LFS's JSON answers carry: a batch's, a lock's, a page of locks, a verify's page split
79
77
  * into the caller's and others', or a refusal's `{ message }`. A union encodes as its first member
@@ -103,30 +101,7 @@ const LfsBody = /* @__PURE__ */ Schema.Union([
103
101
  ]);
104
102
  const lfsJson = /* @__PURE__ */ Schema.encodeSync(Schema.fromJsonString(LfsBody));
105
103
  /** A JSON answer of LFS's. */
106
- const lfsAnswer = (status, body, headers) => {
107
- const answer = new Headers(headers);
108
- answer.set("content-type", lfsType);
109
- answer.set("cache-control", noStore["cache-control"]);
110
- return new Response(lfsJson(body), {
111
- status,
112
- headers: answer
113
- });
114
- };
115
- /**
116
- * A refusal as LFS answers one. An anonymous caller is asked for Basic credentials; a repo a
117
- * caller can't read is a 404, as a missing one is, and so is a write's refusal for a caller
118
- * that can't read the repo, which the caller of `lfsRefusal` arranges. A body LFS can't take is
119
- * its validation error, 422, but one that ended early is a 400, as Git's is.
120
- */
121
- const lfsRefusal = (error) => {
122
- if (error.code === "UNAUTHENTICATED") return lfsAnswer(401, { message: error.message }, { "lfs-authenticate": "Basic realm=\"Git LFS\"" });
123
- if (error.code === "NOT_FOUND") return lfsAnswer(404, { message: error.message });
124
- const status = error.code === "INVALID_ARGUMENT" && error.context?.reason === "body-ended" ? httpStatus[error.code] : lfsStatus[error.code] ?? httpStatus[error.code];
125
- const retry = error.code === "UNAVAILABLE" ? { "retry-after": "1" } : void 0;
126
- return lfsAnswer(status, { message: error.message }, retry);
127
- };
128
- /** Where LFS's status differs from Git's: a body it can't take is its validation error. */
129
- const lfsStatus = { INVALID_ARGUMENT: 422 };
104
+ const lfsAnswer = (status, body, headers) => lfsResponse(status, lfsJson(body), headers);
130
105
  const unreadable = (why) => fail("INVALID_ARGUMENT", `The body is unreadable: ${why}`);
131
106
  /**
132
107
  * `request`'s body, read whole up to 1 MiB, then decoded as `schema`'s JSON. A read that breaks
@@ -141,4 +116,4 @@ const bodyOf = /* @__PURE__ */ Effect.fnUntraced(function* (request, schema) {
141
116
  onSuccess: (value) => Effect.succeed(value)
142
117
  });
143
118
  });
144
- export { BatchRequest, LfsAction, LfsBody, LfsLock, LfsObjectAnswer, LockCreate, LockQuery, LockVerify, Unlock, VerifyRequest, batchMost, bodyOf, lfsAnswer, lfsRefusal, lfsType };
119
+ export { BatchRequest, LfsAction, LfsBody, LfsLock, LfsObjectAnswer, LockCreate, LockQuery, LockVerify, Unlock, VerifyRequest, batchMost, bodyOf, lfsAnswer };
@@ -2,7 +2,7 @@ import { MergeParts, Merges } from "../core/merge-parts.mjs";
2
2
  import { Objects } from "../core/objects/objects.mjs";
3
3
  import { loadedXdiff, mergeParts } from "../engine/parts.mjs";
4
4
  import { defaultXdiffBudget } from "../engine/xdiff.mjs";
5
- import { objectsFace, scopedReader } from "../storage/calls.mjs";
5
+ import { scopedReader } from "../storage/calls.mjs";
6
6
  import * as Effect from "effect/Effect";
7
7
  import * as Context from "effect/Context";
8
8
  import * as Layer from "effect/Layer";
@@ -19,7 +19,7 @@ const mergesContext = /* @__PURE__ */ Effect.fnUntraced(function* (options, obje
19
19
  view,
20
20
  at
21
21
  });
22
- const reader = yield* scopedReader(objectsFace(read), at.listed);
22
+ const reader = yield* scopedReader(read, at.listed);
23
23
  const allot = Effect.succeed((most, refusal) => reader.allotment(most, refusal));
24
24
  return yield* parts.mergeTrees((object) => reader.read(object), input, allot);
25
25
  }));
package/dist/node.d.mts CHANGED
@@ -1,3 +1,3 @@
1
- import { NodeAnswerer, toNodeHandler, toNodeMiddleware } from "./server/edge-node.mjs";
2
- import { NodeHandler, NodeMiddleware, NodeNext, NodeRequest, NodeResponse } from "./http/node.mjs";
3
- export { type NodeAnswerer, type NodeHandler, type NodeMiddleware, type NodeNext, type NodeRequest, type NodeResponse, toNodeHandler, toNodeMiddleware };
1
+ import { toNodeHandler, toNodeMiddleware } from "./server/edge-node.mjs";
2
+ import { NodeHandler, NodeMiddleware, NodeNext, NodeRequest, NodeResponse, NodeServeOptions } from "./http/node.mjs";
3
+ export { type NodeHandler, type NodeMiddleware, type NodeNext, type NodeRequest, type NodeResponse, type NodeServeOptions, toNodeHandler, toNodeMiddleware };
@@ -49,15 +49,23 @@ var BufferError = class extends Schema.TaggedError()("BufferError", {
49
49
  message: Schema.String
50
50
  }) {};
51
51
  /**
52
- * An allotment that fails by name past the meter's ceiling, made each time it runs: one built and
53
- * never run allots nothing, and one run twice allots twice.
52
+ * `bytes` allotted to `part` at once: nothing when they fit, or the error naming the ceiling they'd
53
+ * pass, with nothing allotted.
54
54
  */
55
- const allotOrFail = (meter, part, bytes) => Effect.suspend(() => meter.allot(part, bytes) ? Effect.void : Effect.fail(new BufferError({
55
+ const allotNow = (meter, part, bytes) => meter.allot(part, bytes) ? void 0 : new BufferError({
56
56
  part,
57
57
  bytes,
58
58
  ceiling: meter.ceiling,
59
59
  message: `${part} would retain ${bytes} bytes past ${meter.ceiling}`
60
- })));
60
+ });
61
+ /**
62
+ * An allotment that fails by name past the meter's ceiling, made each time it runs: one built and
63
+ * never run allots nothing, and one run twice allots twice.
64
+ */
65
+ const allotOrFail = (meter, part, bytes) => Effect.suspend(() => {
66
+ const refused = allotNow(meter, part, bytes);
67
+ return refused === void 0 ? Effect.void : Effect.fail(refused);
68
+ });
61
69
  /**
62
70
  * `bytes` allotted to `part` until the scope closes, failing by name past the meter's ceiling: each
63
71
  * run allots when it runs and lets go when its own scope closes.
@@ -65,4 +73,4 @@ const allotOrFail = (meter, part, bytes) => Effect.suspend(() => meter.allot(par
65
73
  const allotScoped = (meter, part, bytes) => Effect.acquireRelease(allotOrFail(meter, part, bytes), () => Effect.sync(() => meter.free(part)));
66
74
  /** The capacity a view keeps alive: its whole buffer's. */
67
75
  const capacityOf = (bytes) => bytes.buffer.byteLength;
68
- export { BufferError, BufferMeter, allotOrFail, allotScoped, capacityOf };
76
+ export { BufferError, BufferMeter, allotNow, allotOrFail, allotScoped, capacityOf };
@@ -12,6 +12,11 @@ const scopedReader = (body) => Effect.acquireRelease(Effect.sync(() => body.getR
12
12
  reader.releaseLock();
13
13
  }));
14
14
  /**
15
+ * `body` cancelled, unread, its cancel's own failure dropped: a body no one will read, let go so
16
+ * its sender stops. A `null` or `undefined` body has nothing to let go.
17
+ */
18
+ const dropBody = (body) => body === null || body === void 0 ? Effect.void : Effect.promise(() => body.cancel().catch(() => void 0));
19
+ /**
15
20
  * A whole body within `most` bytes, or undefined past it. Chunks are checked before they are
16
21
  * retained. The caller owns the byte bound and the errors; this scope owns the reader on every
17
22
  * exit, including a failure between reads. Without an explicit empty-chunk policy, a run of
@@ -58,4 +63,4 @@ const ownedReader = (body) => {
58
63
  }
59
64
  };
60
65
  };
61
- export { boundedBytes, ownedReader, scopedReader };
66
+ export { boundedBytes, dropBody, ownedReader, scopedReader };
@@ -0,0 +1,15 @@
1
+ import "./sha1-hasher.mjs";
2
+ import * as Effect from "effect/Effect";
3
+ /**
4
+ * A SHA-256 written a piece at a time as an upload's body streams through, as `@ref0/github`'s
5
+ * release asset in one request is (#2452), through the runtime's own hash: workerd's
6
+ * `crypto.DigestStream`, or Node's `createHash`, and `Sha256` where a runtime has neither.
7
+ * `sha1-hasher.ts` does the same for a pack's SHA-1.
8
+ */
9
+ /** A SHA-256 written a piece at a time, then its sum as 64 lowercase hex digits. */
10
+ export interface Sha256Hasher {
11
+ readonly write: (bytes: Uint8Array) => Effect.Effect<void>;
12
+ readonly hex: Effect.Effect<string>;
13
+ }
14
+ /** A `Sha256Hasher` through this runtime's own hash, or `Sha256` where it has none. */
15
+ export declare const nativeSha256Hasher: () => Sha256Hasher;
@@ -0,0 +1,32 @@
1
+ import * as Schema from "effect/Schema";
2
+ /**
3
+ * A SHA-256's state between writes: its eight words, the bytes it took, and the bytes past its last
4
+ * whole 64-byte block, as lowercase hex, as many as `length` leaves past a block. Decode stored
5
+ * state through it, so a damaged one fails by name before a `Sha256` goes on from it.
6
+ */
7
+ export declare const Sha256State: Schema.Struct<{
8
+ readonly words: Schema.Tuple<readonly [Schema.Number, Schema.Number, Schema.Number, Schema.Number, Schema.Number, Schema.Number, Schema.Number, Schema.Number]>;
9
+ readonly length: Schema.Int;
10
+ readonly pending: Schema.String;
11
+ }>;
12
+ export type Sha256State = typeof Sha256State.Type;
13
+ /** A stored state, checked: a typed failure for one no `Sha256` could have written. */
14
+ export declare const decodeSha256State: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => import("effect/Effect").Effect<{
15
+ readonly words: readonly [number, number, number, number, number, number, number, number];
16
+ readonly length: number;
17
+ readonly pending: string;
18
+ }, Schema.SchemaError, never>;
19
+ export declare class Sha256 {
20
+ #private;
21
+ /**
22
+ * A hash from the start, or going on from `state`, which it trusts: one `decodeSha256State`
23
+ * hasn't checked and that holds a block or more of pending bytes throws a `RangeError`.
24
+ */
25
+ constructor(state?: Sha256State);
26
+ /** Takes `bytes`, after every byte before them. */
27
+ update(bytes: Uint8Array): void;
28
+ /** The state to go on from, as plain data. */
29
+ state(): Sha256State;
30
+ /** The digest of every byte taken, as 64 lowercase hex digits; the hash takes no more after it. */
31
+ hex(): string;
32
+ }
@@ -1,9 +1,40 @@
1
+ import * as Schema from "effect/Schema";
2
+ import * as Result from "effect/Result";
3
+ import * as Hex from "effect/encoding/Hex";
1
4
  // src/protocol/bytes/sha256.ts
2
5
  /**
3
- * SHA-256, as FIPS 180-4 defines it, written a piece at a time: LFS checks an upload's bytes as
4
- * they stream past, and the runtime's `crypto.subtle` takes only bytes held whole.
6
+ * SHA-256, as FIPS 180-4 defines it, written a piece at a time, whose state is plain data: LFS
7
+ * checks an upload's bytes as they stream past, and a release asset's parts, each put in a request
8
+ * of its own, hash on from the state the part before left. The runtime's `crypto.subtle` takes only
9
+ * bytes held whole, and its `DigestStream` keeps its state where nothing can save it.
5
10
  */
6
- const rounds = Uint32Array.from([
11
+ const Word = /* @__PURE__ */ Schema.Number.check(Schema.isUint32());
12
+ /**
13
+ * A SHA-256's state between writes: its eight words, the bytes it took, and the bytes past its last
14
+ * whole 64-byte block, as lowercase hex, as many as `length` leaves past a block. Decode stored
15
+ * state through it, so a damaged one fails by name before a `Sha256` goes on from it.
16
+ */
17
+ const Sha256State = /* @__PURE__ */ Schema.Struct({
18
+ words: Schema.Tuple([
19
+ Word,
20
+ Word,
21
+ Word,
22
+ Word,
23
+ Word,
24
+ Word,
25
+ Word,
26
+ Word
27
+ ]),
28
+ length: Schema.Int.check(Schema.isBetween({
29
+ minimum: 0,
30
+ maximum: Number.MAX_SAFE_INTEGER / 8
31
+ })),
32
+ pending: Schema.String.check(Schema.isPattern(/^(?:[0-9a-f]{2}){0,63}$/))
33
+ }).check(Schema.makeFilter((state) => state.pending.length / 2 === state.length % 64 || "its pending bytes are not the bytes past its last whole block"));
34
+ /** A stored state, checked: a typed failure for one no `Sha256` could have written. */
35
+ const decodeSha256State = /* @__PURE__ */ Schema.decodeUnknownEffect(Sha256State);
36
+ /** The 64 round constants, signed 32-bit, as the rounds add them. */
37
+ const rounds = Int32Array.from([
7
38
  1116352408,
8
39
  1899447441,
9
40
  3049323471,
@@ -79,26 +110,51 @@ const initial = [
79
110
  528734635,
80
111
  1541459225
81
112
  ];
82
- const rotate = (word, by) => word >>> by | word << 32 - by;
83
113
  var Sha256 = class {
84
- #words = Uint32Array.from(initial);
114
+ #words;
85
115
  #block = /* @__PURE__ */ new Uint8Array(64);
86
- #schedule = /* @__PURE__ */ new Uint32Array(64);
87
- #filled = 0;
88
- #length = 0;
116
+ #blockView = new DataView(this.#block.buffer);
117
+ #schedule = /* @__PURE__ */ new Int32Array(64);
118
+ #filled;
119
+ #length;
120
+ /**
121
+ * A hash from the start, or going on from `state`, which it trusts: one `decodeSha256State`
122
+ * hasn't checked and that holds a block or more of pending bytes throws a `RangeError`.
123
+ */
124
+ constructor(state) {
125
+ const pending = state === void 0 ? /* @__PURE__ */ new Uint8Array(0) : Result.getOrThrow(Hex.decode(state.pending));
126
+ if (pending.length >= 64) throw new RangeError("a SHA-256's pending bytes fill a block");
127
+ this.#words = [...state?.words ?? initial];
128
+ this.#block.set(pending);
129
+ this.#filled = pending.length;
130
+ this.#length = state?.length ?? 0;
131
+ }
89
132
  /** Takes `bytes`, after every byte before them. */
90
133
  update(bytes) {
134
+ let at = 0;
91
135
  this.#length += bytes.length;
92
- for (let at = 0; at < bytes.length;) {
93
- const take = Math.min(64 - this.#filled, bytes.length - at);
94
- this.#block.set(bytes.subarray(at, at + take), this.#filled);
95
- this.#filled += take;
96
- at += take;
97
- if (this.#filled === 64) {
98
- this.#compress();
99
- this.#filled = 0;
100
- }
136
+ if (this.#filled > 0) {
137
+ at = Math.min(64 - this.#filled, bytes.length);
138
+ this.#block.set(bytes.subarray(0, at), this.#filled);
139
+ this.#filled += at;
140
+ if (this.#filled < 64) return;
141
+ this.#compress(this.#blockView, 0);
142
+ this.#filled = 0;
101
143
  }
144
+ if (at + 64 <= bytes.length) {
145
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
146
+ for (; at + 64 <= bytes.length; at += 64) this.#compress(view, at);
147
+ }
148
+ this.#block.set(bytes.subarray(at));
149
+ this.#filled = bytes.length - at;
150
+ }
151
+ /** The state to go on from, as plain data. */
152
+ state() {
153
+ return {
154
+ words: [...this.#words],
155
+ length: this.#length,
156
+ pending: Hex.encode(this.#block.subarray(0, this.#filled))
157
+ };
102
158
  }
103
159
  /** The digest of every byte taken, as 64 lowercase hex digits; the hash takes no more after it. */
104
160
  hex() {
@@ -106,51 +162,51 @@ var Sha256 = class {
106
162
  this.#block[this.#filled] = 128;
107
163
  this.#block.fill(0, this.#filled + 1);
108
164
  if (this.#filled >= 56) {
109
- this.#compress();
165
+ this.#compress(this.#blockView, 0);
110
166
  this.#block.fill(0);
111
167
  }
112
- const view = new DataView(this.#block.buffer);
113
- view.setUint32(56, Math.floor(bits / 2 ** 32));
114
- view.setUint32(60, bits >>> 0);
115
- this.#compress();
116
- return Array.from(this.#words, (word) => word.toString(16).padStart(8, "0")).join("");
168
+ this.#blockView.setUint32(56, Math.floor(bits / 2 ** 32));
169
+ this.#blockView.setUint32(60, bits >>> 0);
170
+ this.#compress(this.#blockView, 0);
171
+ return this.#words.map((word) => word.toString(16).padStart(8, "0")).join("");
117
172
  }
118
- #compress() {
173
+ /**
174
+ * Hashes the 64 bytes of `view` from `from` into the words, its working words in locals and its
175
+ * schedule in one reused array, each signed 32-bit until it's stored: an array of words read
176
+ * back through `?? 0` held it to about 55 MiB/s in Node.
177
+ */
178
+ #compress(view, from) {
119
179
  const w = this.#schedule;
120
- const view = new DataView(this.#block.buffer);
121
- for (let t = 0; t < 16; t += 1) w[t] = view.getUint32(t * 4);
180
+ for (let t = 0; t < 16; t += 1) w[t] = view.getInt32(from + t * 4);
122
181
  for (let t = 16; t < 64; t += 1) {
123
- const back2 = w[t - 2] ?? 0;
124
- const back15 = w[t - 15] ?? 0;
125
- const s0 = rotate(back15, 7) ^ rotate(back15, 18) ^ back15 >>> 3;
126
- const s1 = rotate(back2, 17) ^ rotate(back2, 19) ^ back2 >>> 10;
127
- w[t] = (w[t - 16] ?? 0) + s0 + (w[t - 7] ?? 0) + s1;
182
+ const back2 = w[t - 2];
183
+ const back15 = w[t - 15];
184
+ const s0 = (back15 >>> 7 | back15 << 25) ^ (back15 >>> 18 | back15 << 14) ^ back15 >>> 3;
185
+ const s1 = (back2 >>> 17 | back2 << 15) ^ (back2 >>> 19 | back2 << 13) ^ back2 >>> 10;
186
+ w[t] = w[t - 16] + s0 + w[t - 7] + s1 | 0;
128
187
  }
129
- let [a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0] = this.#words;
188
+ let [a, b, c, d, e, f, g, h] = this.#words;
130
189
  for (let t = 0; t < 64; t += 1) {
131
- const s1 = rotate(e, 6) ^ rotate(e, 11) ^ rotate(e, 25);
132
- const choice = e & f ^ ~e & g;
133
- const first = h + s1 + choice + (rounds[t] ?? 0) + (w[t] ?? 0) >>> 0;
134
- const second = (rotate(a, 2) ^ rotate(a, 13) ^ rotate(a, 22)) + (a & b ^ a & c ^ b & c) >>> 0;
190
+ const s1 = (e >>> 6 | e << 26) ^ (e >>> 11 | e << 21) ^ (e >>> 25 | e << 7);
191
+ const first = h + s1 + (e & f ^ ~e & g) + rounds[t] + w[t] | 0;
192
+ const second = ((a >>> 2 | a << 30) ^ (a >>> 13 | a << 19) ^ (a >>> 22 | a << 10)) + (a & b ^ a & c ^ b & c) | 0;
135
193
  h = g;
136
194
  g = f;
137
195
  f = e;
138
- e = d + first >>> 0;
196
+ e = d + first | 0;
139
197
  d = c;
140
198
  c = b;
141
199
  b = a;
142
- a = first + second >>> 0;
200
+ a = first + second | 0;
143
201
  }
144
- for (const [at, word] of [
145
- a,
146
- b,
147
- c,
148
- d,
149
- e,
150
- f,
151
- g,
152
- h
153
- ].entries()) this.#words[at] = (this.#words[at] ?? 0) + word;
202
+ this.#words[0] = this.#words[0] + a >>> 0;
203
+ this.#words[1] = this.#words[1] + b >>> 0;
204
+ this.#words[2] = this.#words[2] + c >>> 0;
205
+ this.#words[3] = this.#words[3] + d >>> 0;
206
+ this.#words[4] = this.#words[4] + e >>> 0;
207
+ this.#words[5] = this.#words[5] + f >>> 0;
208
+ this.#words[6] = this.#words[6] + g >>> 0;
209
+ this.#words[7] = this.#words[7] + h >>> 0;
154
210
  }
155
211
  };
156
- export { Sha256 };
212
+ export { Sha256, Sha256State, decodeSha256State };
@@ -23,6 +23,32 @@ const streamOf = (bytes, piece = Math.max(1, bytes.length)) => {
23
23
  } });
24
24
  };
25
25
  /**
26
+ * `bytes` as a body read once, in one piece, `done` run once it's read to its end, cancelled, or
27
+ * ended unread by `expired`, which fails it with the signal's reason: what holds the bytes, such as
28
+ * a charge to a budget, is let go only then. No piece is pulled before a reader asks, since a pull
29
+ * on its own would end it unread.
30
+ */
31
+ const streamThen = (bytes, done, expired) => {
32
+ let ended = false;
33
+ const end = () => {
34
+ if (ended) return false;
35
+ ended = true;
36
+ done();
37
+ return true;
38
+ };
39
+ return new ReadableStream({
40
+ start: (controller) => {
41
+ expired?.addEventListener("abort", () => end() && controller.error(expired.reason), { once: true });
42
+ },
43
+ pull: (controller) => {
44
+ controller.enqueue(bytes);
45
+ controller.close();
46
+ end();
47
+ },
48
+ cancel: () => void end()
49
+ }, { highWaterMark: 0 });
50
+ };
51
+ /**
26
52
  * `body` gathered into pieces, each `pieceAt(given)` bytes, `given` the bytes it has handed on,
27
53
  * its last smaller, each copied from its chunks as they come, so code that pays for each chunk pays
28
54
  * once a piece: a client's body reaches a deployed Worker in chunks of at most 4,096 B (run
@@ -100,4 +126,4 @@ const gathered = (body, pieceAt) => {
100
126
  }
101
127
  }, { highWaterMark: 0 });
102
128
  };
103
- export { gathered, streamOf };
129
+ export { gathered, streamOf, streamThen };
@@ -33,13 +33,14 @@ export interface DiffLimits {
33
33
  */
34
34
  export declare const defaultDiffLimits: DiffLimits;
35
35
  declare const DiffError_base: Schema.Class<DiffError, Schema.TaggedStruct<"DiffError", {
36
- readonly reason: Schema.Literals<readonly ["missing", "malformed", "unreadable", "diff-limit", "object-too-large"]>;
36
+ readonly reason: Schema.Literals<readonly ["missing", "past-roots", "malformed", "unreadable", "diff-limit", "object-too-large"]>;
37
37
  readonly oid: Schema.optionalKey<Schema.String>;
38
38
  readonly message: Schema.String;
39
39
  }>, import("effect/Cause").YieldableError>;
40
40
  /**
41
- * Why a diff stopped: an object `missing`, `malformed` or `unreadable`, a read or a charge past
42
- * the diff's limits, `diff-limit`, or one object past its own, `object-too-large`.
41
+ * Why a diff stopped: an object `missing`, or `past-roots`, missing from a repo that holds roots,
42
+ * so it may be history past them; `malformed` or `unreadable`; a read or a charge past the diff's
43
+ * limits, `diff-limit`; or one object past its own, `object-too-large`.
43
44
  */
44
45
  export declare class DiffError extends DiffError_base {}
45
46
  /**
@@ -22,12 +22,14 @@ const defaultDiffLimits = {
22
22
  fileBytes: 16 * mebibyte
23
23
  };
24
24
  /**
25
- * Why a diff stopped: an object `missing`, `malformed` or `unreadable`, a read or a charge past
26
- * the diff's limits, `diff-limit`, or one object past its own, `object-too-large`.
25
+ * Why a diff stopped: an object `missing`, or `past-roots`, missing from a repo that holds roots,
26
+ * so it may be history past them; `malformed` or `unreadable`; a read or a charge past the diff's
27
+ * limits, `diff-limit`; or one object past its own, `object-too-large`.
27
28
  */
28
29
  var DiffError = class extends Schema.TaggedError()("DiffError", {
29
30
  reason: Schema.Literals([
30
31
  "missing",
32
+ "past-roots",
31
33
  "malformed",
32
34
  "unreadable",
33
35
  "diff-limit",
@@ -177,7 +179,10 @@ var DiffReader = class {
177
179
  if (this.#objects > this.limits.objects) return yield* failed("diff-limit", `the diff reads past ${this.limits.objects} objects`);
178
180
  if (this.tally?.object() === false) return yield* failed("diff-limit", `the call reads past ${this.tally.limits.objects} objects`);
179
181
  const object = yield* this.read(oid);
180
- if (object === void 0) return yield* failed("missing", `object ${oid} is missing`, oid);
182
+ if (object === void 0) {
183
+ const reason = this.roots.size === 0 ? "missing" : "past-roots";
184
+ return yield* failed(reason, `object ${oid} is missing`, oid);
185
+ }
181
186
  this.#sizes.set(oid, object.size);
182
187
  if (type !== void 0 && object.type !== type) {
183
188
  object.bytes.cancel().catch(() => void 0);
@@ -4,5 +4,17 @@
4
4
  */
5
5
  /** The most bytes a pointer file holds, as Git LFS's spec says. */
6
6
  export declare const maxLfsPointerBytes = 1024;
7
- /** The oid a Git LFS pointer names, as `lfsPointerOf` reads it. */
8
- export declare const lfsPointerOid: (text: string) => string | undefined;
7
+ /** What a pointer names: its object's oid and size. */
8
+ export interface LfsPointerTarget {
9
+ readonly oid: string;
10
+ /** As written, read as a number: past 2⁵³ it's the nearest one. */
11
+ readonly size: number;
12
+ }
13
+ /**
14
+ * What a Git LFS pointer names, or `undefined` for text that isn't one: its version line, its
15
+ * extensions in rising order, `oid sha256:<hex>`, `size <n>` within a signed 64-bit integer, each
16
+ * ending in a newline, and nothing else but blank lines, which git-lfs skips. Text that git-lfs
17
+ * reads as a pointer may still be refused here, as one with CRLFs, but never text that git-lfs
18
+ * refuses, so a plain file is never taken for a pointer.
19
+ */
20
+ export declare const lfsPointerOf: (text: string) => LfsPointerTarget | undefined;
@@ -40,8 +40,6 @@ const lfsPointerOf = (text) => {
40
40
  * Other texts may point at the same object, but this is the one `git lfs track` commits.
41
41
  */
42
42
  const lfsPointerText = (target) => `${pointerVersion}\noid sha256:${target.oid}\nsize ${target.size}\n`;
43
- /** The oid a Git LFS pointer names, as `lfsPointerOf` reads it. */
44
- const lfsPointerOid = (text) => lfsPointerOf(text)?.oid;
45
43
  const versionBytes = new TextEncoder().encode(pointerVersion);
46
44
  /**
47
45
  * Whether `bytes` may be a pointer: what `TextDecoder` reads them as, past its byte order mark and
@@ -65,4 +63,4 @@ const lfsPointerOfBlob = (bytes) => {
65
63
  size: pointer.size
66
64
  };
67
65
  };
68
- export { isLfsOid, lfsPointerOf, lfsPointerOfBlob, lfsPointerOid, lfsPointerText, maxLfsPointerBytes };
66
+ export { isLfsOid, lfsPointerOf, lfsPointerOfBlob, lfsPointerText, maxLfsPointerBytes };
@@ -1,4 +1,4 @@
1
- import { hexValue, modeKind, octalMode } from "./object-rules.mjs";
1
+ import { hexValue, modeKind } from "./object-rules.mjs";
2
2
  // src/protocol/objects/links-raw.ts
3
3
  /**
4
4
  * The IDs an object names, as 20 raw bytes each, with no string made: a tree's entries but its
@@ -15,17 +15,31 @@ const rawLinks = (kind, bytes, visit) => {
15
15
  const space = 32;
16
16
  const nul = 0;
17
17
  const newline = 10;
18
- /** A tree's entries: its mode's digits, a space, its name, a NUL, then its ID's 20 bytes. */
18
+ /**
19
+ * A tree's entries: its mode's digits, a space, its name, a NUL, then its ID's 20 bytes. Each
20
+ * entry is read in one pass, its mode's value made as its digits go by, `octalMode`'s rule and
21
+ * order, with no `indexOf` call for its space or its NUL: a call each was most of a read step's
22
+ * tree CPU (#664). `links-raw.fuzz.test.ts` holds it to `octalMode` and `modeKind`.
23
+ */
19
24
  const treeLinks = (bytes, visit) => {
25
+ const length = bytes.byteLength;
20
26
  let at = 0;
21
- while (at < bytes.byteLength) {
22
- const modeEnd = bytes.indexOf(space, at);
23
- if (modeEnd <= at) return `an entry at ${at} has no mode`;
24
- const nameEnd = bytes.indexOf(nul, modeEnd + 1);
25
- if (nameEnd <= modeEnd + 1) return `an entry at ${at} has no name`;
26
- if (nameEnd + 21 > bytes.byteLength) return `an entry at ${at} ends inside its ID`;
27
- const mode = octalMode(bytes, at, modeEnd);
28
- if (mode === void 0) return `an entry at ${at} has a mode that isn't octal`;
27
+ while (at < length) {
28
+ let modeEnd = at;
29
+ let mode = 0;
30
+ let octal = true;
31
+ for (; modeEnd < length; modeEnd += 1) {
32
+ const byte = bytes[modeEnd] ?? 0;
33
+ if (byte === space) break;
34
+ if (byte < 48 || byte > 55) octal = false;
35
+ mode = (mode << 3) + (byte - 48) >>> 0;
36
+ }
37
+ if (modeEnd === length || modeEnd === at) return `an entry at ${at} has no mode`;
38
+ let nameEnd = modeEnd + 1;
39
+ while (nameEnd < length && bytes[nameEnd] !== nul) nameEnd += 1;
40
+ if (nameEnd === length || nameEnd === modeEnd + 1) return `an entry at ${at} has no name`;
41
+ if (nameEnd + 21 > length) return `an entry at ${at} ends inside its ID`;
42
+ if (!octal) return `an entry at ${at} has a mode that isn't octal`;
29
43
  if (modeKind(mode) !== "gitlink") visit(bytes, nameEnd + 1);
30
44
  at = nameEnd + 21;
31
45
  }
@@ -18,6 +18,6 @@ export declare const decodeTag: (bytes: Uint8Array) => Effect.Effect<Omit<Tag, '
18
18
  * wouldn't write fails before any byte: an ID that isn't 40 lowercase hex, a type that isn't an
19
19
  * object's, a name Git can't put under `refs/tags/`, a tagger Git refuses, or a NUL in its message.
20
20
  */
21
- export declare const encodeTag: (tag: TagFields & {
21
+ export declare const encodeTag: (tag: Omit<TagFields, 'type'> & {
22
22
  readonly type: ObjectType;
23
23
  }) => Effect.Effect<Uint8Array<ArrayBuffer>, WireEncodeError>;
@@ -64,11 +64,12 @@ const parseTreeBytes = (bytes) => Effect.suspend(() => {
64
64
  });
65
65
  /**
66
66
  * A tree's entries one at a time, in order, as `parseTreeBytes` reads them, `undefined` past the
67
- * last: it holds none, so a tree as wide as a push may carry is read without an array of them. A
68
- * name is a view of `bytes`, so one kept is copied first. Fails as `parseTreeBytes` does, at the
69
- * entry at fault.
67
+ * last, each ID left where the tree holds it, so a caller that asks or copies IDs as bytes makes
68
+ * no text of them. It holds none, so a tree as wide as a push may carry is read without an array
69
+ * of them. A name is a view of `bytes`, so one kept is copied first. Fails as `parseTreeBytes`
70
+ * does, at the entry at fault.
70
71
  */
71
- const treeReader = (bytes) => {
72
+ const treeIdReader = (bytes) => {
72
73
  let previous;
73
74
  let at = 0;
74
75
  return () => {
@@ -83,7 +84,7 @@ const treeReader = (bytes) => {
83
84
  const entry = {
84
85
  mode: canonicalMode(mode),
85
86
  name,
86
- oid: hexOf(bytes.subarray(nul + 1, nul + 21))
87
+ idAt: nul + 1
87
88
  };
88
89
  if (previous !== void 0 && compareEntries(previous, entry) >= 0) return notATree(`the entry at byte ${at} is out of Git's order or named twice`);
89
90
  previous = entry;
@@ -91,6 +92,22 @@ const treeReader = (bytes) => {
91
92
  return Result.succeed(entry);
92
93
  };
93
94
  };
95
+ /** `treeIdReader`'s entries, each with its ID as text. */
96
+ const treeReader = (bytes) => {
97
+ const next = treeIdReader(bytes);
98
+ return () => {
99
+ const read = next();
100
+ if (Result.isFailure(read)) return Result.fail(read.failure);
101
+ const entry = read.success;
102
+ if (entry === void 0) return Result.succeed(void 0);
103
+ const { mode, name, idAt } = entry;
104
+ return Result.succeed({
105
+ mode,
106
+ name,
107
+ oid: hexOf(bytes.subarray(idAt, idAt + 20))
108
+ });
109
+ };
110
+ };
94
111
  const encoder = new TextEncoder();
95
112
  /** The modes a tree's entry can be written with: a file, an executable, a symlink, a gitlink. */
96
113
  const writableModes = /* @__PURE__ */ new Set([
@@ -159,4 +176,4 @@ const treeMatches = (oid, entries) => encodeTree(entries).pipe(Effect.flatMap((b
159
176
  type: "tree",
160
177
  bytes
161
178
  })), Effect.map((id) => id === oid));
162
- export { compareEntries, compareNames, encodeTree, parseTreeBytes, treeBytes, treeEntriesIn, treeMatches, treeReader };
179
+ export { compareEntries, compareNames, encodeTree, parseTreeBytes, treeBytes, treeEntriesIn, treeIdReader, treeMatches, treeReader };