@ref0/git 0.0.0 → 0.3.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.
- package/dist/LICENSE +202 -0
- package/dist/access/private-refs.d.mts +27 -0
- package/dist/access/private-refs.mjs +173 -0
- package/dist/access.d.mts +2 -0
- package/dist/access.mjs +1 -0
- package/dist/auth/access-jwt.d.mts +21 -0
- package/dist/auth/access-jwt.mjs +102 -0
- package/dist/auth/acting.mjs +15 -0
- package/dist/auth/authorize.d.mts +5 -0
- package/dist/auth/authorize.mjs +292 -0
- package/dist/auth/credentials.mjs +57 -0
- package/dist/auth/fences.d.mts +5 -0
- package/dist/auth/fences.mjs +65 -0
- package/dist/auth/grants.mjs +61 -0
- package/dist/auth/helpers.d.mts +17 -0
- package/dist/auth/helpers.mjs +25 -0
- package/dist/auth/host-function.d.mts +4 -0
- package/dist/auth/host-function.mjs +69 -0
- package/dist/auth/identify.d.mts +6 -0
- package/dist/auth/identify.mjs +97 -0
- package/dist/auth/token-rows.mjs +100 -0
- package/dist/auth/token-text.mjs +66 -0
- package/dist/auth/tokens.d.mts +10 -0
- package/dist/auth/tokens.mjs +347 -0
- package/dist/auth.d.mts +7 -0
- package/dist/auth.mjs +6 -0
- package/dist/client/answer.mjs +141 -0
- package/dist/client/client.d.mts +23 -0
- package/dist/client/client.mjs +50 -0
- package/dist/client/git-http.mjs +201 -0
- package/dist/client/helper-node.mjs +19 -0
- package/dist/client/local.mjs +170 -0
- package/dist/client/negotiate.mjs +170 -0
- package/dist/client/push-upload.mjs +53 -0
- package/dist/client/remote-helper.mjs +129 -0
- package/dist/client/remote.mjs +398 -0
- package/dist/client/run-remote-helper.d.mts +35 -0
- package/dist/client/run-remote-helper.mjs +259 -0
- package/dist/client/scrub.d.mts +18 -0
- package/dist/client/scrub.mjs +38 -0
- package/dist/client/transport.d.mts +2 -0
- package/dist/client/transport.mjs +211 -0
- package/dist/contracts/access.d.mts +87 -0
- package/dist/contracts/actors.d.mts +144 -0
- package/dist/contracts/blobs.d.mts +38 -0
- package/dist/contracts/calls-spent.d.mts +11 -0
- package/dist/contracts/calls-spent.mjs +151 -0
- package/dist/contracts/client.d.mts +90 -0
- package/dist/contracts/commits.d.mts +126 -0
- package/dist/contracts/engine.d.mts +134 -0
- package/dist/contracts/events.d.mts +276 -0
- package/dist/contracts/files.d.mts +75 -0
- package/dist/contracts/forks.d.mts +78 -0
- package/dist/contracts/grants.d.mts +60 -0
- package/dist/contracts/handlers.d.mts +11 -0
- package/dist/contracts/ids.d.mts +15 -0
- package/dist/contracts/ids.mjs +15 -0
- package/dist/contracts/lfs.d.mts +27 -0
- package/dist/contracts/merges.d.mts +33 -0
- package/dist/contracts/objects.d.mts +645 -0
- package/dist/contracts/objects.mjs +54 -0
- package/dist/contracts/operations.d.mts +133 -0
- package/dist/contracts/promises.d.mts +38 -0
- package/dist/contracts/promises.mjs +13 -0
- package/dist/contracts/push-uploads.d.mts +44 -0
- package/dist/contracts/queue.d.mts +402 -0
- package/dist/contracts/refs.d.mts +95 -0
- package/dist/contracts/remote.d.mts +50 -0
- package/dist/contracts/repos.d.mts +153 -0
- package/dist/contracts/result.d.mts +133 -0
- package/dist/contracts/result.mjs +34 -0
- package/dist/contracts/rules.d.mts +159 -0
- package/dist/contracts/server.d.mts +272 -0
- package/dist/contracts/services.d.mts +36 -0
- package/dist/contracts/services.mjs +13 -0
- package/dist/contracts/signin.d.mts +126 -0
- package/dist/contracts/store.d.mts +41 -0
- package/dist/contracts/sync.d.mts +210 -0
- package/dist/contracts/sync.mjs +8 -0
- package/dist/contracts/tags.d.mts +50 -0
- package/dist/contracts/tags.mjs +6 -0
- package/dist/contracts/tokens.d.mts +87 -0
- package/dist/contracts/tokens.mjs +15 -0
- package/dist/contracts/topics.d.mts +180 -0
- package/dist/contracts/trees.d.mts +84 -0
- package/dist/contracts/work.d.mts +31 -0
- package/dist/core/access.d.mts +22 -0
- package/dist/core/access.mjs +262 -0
- package/dist/core/ancestry.mjs +235 -0
- package/dist/core/call-names.d.mts +1 -0
- package/dist/core/call-names.mjs +93 -0
- package/dist/core/clock.mjs +18 -0
- package/dist/core/events/deliver.mjs +475 -0
- package/dist/core/events/stream.d.mts +19 -0
- package/dist/core/events/stream.mjs +297 -0
- package/dist/core/forks.mjs +1027 -0
- package/dist/core/hooks/post-receive.mjs +212 -0
- package/dist/core/hooks/pre-receive.d.mts +5 -0
- package/dist/core/hooks/pre-receive.mjs +34 -0
- package/dist/core/index-job.mjs +198 -0
- package/dist/core/names.mjs +30 -0
- package/dist/core/objects/blobs.mjs +60 -0
- package/dist/core/objects/commit-writes.mjs +185 -0
- package/dist/core/objects/commits.mjs +172 -0
- package/dist/core/objects/files.mjs +211 -0
- package/dist/core/objects/lines.mjs +42 -0
- package/dist/core/objects/merges.mjs +83 -0
- package/dist/core/objects/peel.mjs +166 -0
- package/dist/core/objects/reading.mjs +284 -0
- package/dist/core/objects/tags.mjs +96 -0
- package/dist/core/objects/tree-edits.mjs +266 -0
- package/dist/core/objects/trees.mjs +229 -0
- package/dist/core/objects/writing.mjs +266 -0
- package/dist/core/own-writes.mjs +94 -0
- package/dist/core/promise.mjs +64 -0
- package/dist/core/publish.mjs +142 -0
- package/dist/core/push-decide.mjs +206 -0
- package/dist/core/push.mjs +1070 -0
- package/dist/core/receipts.d.mts +7 -0
- package/dist/core/receipts.mjs +234 -0
- package/dist/core/ref-conflicts.mjs +27 -0
- package/dist/core/refs.mjs +359 -0
- package/dist/core/repack.mjs +521 -0
- package/dist/core/repos.mjs +752 -0
- package/dist/core/rules/changes.mjs +57 -0
- package/dist/core/rules/check.mjs +101 -0
- package/dist/core/rules/commit-changes.mjs +216 -0
- package/dist/core/rules/context.d.mts +9 -0
- package/dist/core/rules/context.mjs +120 -0
- package/dist/core/rules/define.d.mts +5 -0
- package/dist/core/rules/define.mjs +13 -0
- package/dist/core/rules/facts.mjs +13 -0
- package/dist/core/rules/fetch.d.mts +5 -0
- package/dist/core/rules/fetch.mjs +59 -0
- package/dist/core/rules/file-globs.mjs +55 -0
- package/dist/core/rules/files.mjs +142 -0
- package/dist/core/rules/patterns.mjs +23 -0
- package/dist/core/rules/protect.d.mts +9 -0
- package/dist/core/rules/protect.mjs +116 -0
- package/dist/core/seam.d.mts +26 -0
- package/dist/core/seam.mjs +54 -0
- package/dist/core/sight.mjs +99 -0
- package/dist/core/tokens.mjs +95 -0
- package/dist/core/view.d.mts +9 -0
- package/dist/core/view.mjs +221 -0
- package/dist/core/work.mjs +92 -0
- package/dist/effect.d.mts +20 -0
- package/dist/effect.mjs +18 -0
- package/dist/engine/allotted-xdiff.d.mts +4 -0
- package/dist/engine/allotted-xdiff.mjs +80 -0
- package/dist/engine/attribute-patterns.mjs +163 -0
- package/dist/engine/attributes.mjs +226 -0
- package/dist/engine/combined.mjs +653 -0
- package/dist/engine/commits.mjs +90 -0
- package/dist/engine/content.d.mts +4 -0
- package/dist/engine/content.mjs +221 -0
- package/dist/engine/diff.mjs +49 -0
- package/dist/engine/engine.d.mts +25 -0
- package/dist/engine/engine.mjs +49 -0
- package/dist/engine/failures.d.mts +4 -0
- package/dist/engine/failures.mjs +23 -0
- package/dist/engine/line-count.mjs +23 -0
- package/dist/engine/merge-base-walk.d.mts +2 -0
- package/dist/engine/merge-base-walk.mjs +265 -0
- package/dist/engine/merge-bases.mjs +27 -0
- package/dist/engine/merge-renames.mjs +165 -0
- package/dist/engine/merge.mjs +1125 -0
- package/dist/engine/parts.d.mts +8 -0
- package/dist/engine/parts.mjs +9 -0
- package/dist/engine/reads.d.mts +5 -0
- package/dist/engine/reads.mjs +105 -0
- package/dist/engine/walk.mjs +328 -0
- package/dist/engine/xdiff/NOTICE.md +63 -0
- package/dist/engine/xdiff/compiled.d.mts +7 -0
- package/dist/engine/xdiff/compiled.mjs +9 -0
- package/dist/engine/xdiff/embedded.mjs +4 -0
- package/dist/engine/xdiff/node.d.mts +7 -0
- package/dist/engine/xdiff/node.mjs +10 -0
- package/dist/engine/xdiff/upstream/LGPL-2.1 +511 -0
- package/dist/engine/xdiff/xdiff.wasm +0 -0
- package/dist/engine/xdiff.d.mts +34 -0
- package/dist/engine/xdiff.mjs +380 -0
- package/dist/engine.d.mts +3 -0
- package/dist/engine.mjs +3 -0
- package/dist/extend.d.mts +4 -0
- package/dist/extend.mjs +3 -0
- package/dist/http/answers.mjs +74 -0
- package/dist/http/bodies.mjs +143 -0
- package/dist/http/core-parts.mjs +252 -0
- package/dist/http/fetch-depth.mjs +26 -0
- package/dist/http/handler.mjs +94 -0
- package/dist/http/node.d.mts +70 -0
- package/dist/http/node.mjs +178 -0
- package/dist/http/paths.d.mts +9 -0
- package/dist/http/paths.mjs +118 -0
- package/dist/http/push-uploads.mjs +286 -0
- package/dist/http/receive-pack.mjs +235 -0
- package/dist/http/upload-pack.mjs +229 -0
- package/dist/index.d.mts +46 -0
- package/dist/index.mjs +16 -0
- package/dist/lfs/calls.mjs +16 -0
- package/dist/lfs/locks.mjs +161 -0
- package/dist/lfs/objects.mjs +370 -0
- package/dist/lfs/pointers.mjs +141 -0
- package/dist/lfs/repo.mjs +42 -0
- package/dist/lfs/rows.mjs +108 -0
- package/dist/lfs/service.mjs +34 -0
- package/dist/lfs/upkeep.mjs +162 -0
- package/dist/lfs/wire.mjs +102 -0
- package/dist/node.d.mts +3 -0
- package/dist/node.mjs +3 -0
- package/dist/protocol/bytes/buffers.d.mts +38 -0
- package/dist/protocol/bytes/buffers.mjs +62 -0
- package/dist/protocol/bytes/crc32.d.mts +4 -0
- package/dist/protocol/bytes/crc32.mjs +14 -0
- package/dist/protocol/bytes/deflate.d.mts +78 -0
- package/dist/protocol/bytes/deflate.mjs +175 -0
- package/dist/protocol/bytes/errors.d.mts +20 -0
- package/dist/protocol/bytes/errors.mjs +19 -0
- package/dist/protocol/bytes/hex.mjs +16 -0
- package/dist/protocol/bytes/hmac-sha256.mjs +91 -0
- package/dist/protocol/bytes/inflate.d.mts +40 -0
- package/dist/protocol/bytes/inflate.mjs +109 -0
- package/dist/protocol/bytes/joined.d.mts +2 -0
- package/dist/protocol/bytes/joined.mjs +25 -0
- package/dist/protocol/bytes/sha1-hasher.d.mts +20 -0
- package/dist/protocol/bytes/sha1-hasher.mjs +72 -0
- package/dist/protocol/bytes/sha1.d.mts +35 -0
- package/dist/protocol/bytes/sha1.mjs +409 -0
- package/dist/protocol/bytes/sha256.mjs +156 -0
- package/dist/protocol/bytes/streams.mjs +11 -0
- package/dist/protocol/bytes/text.mjs +19 -0
- package/dist/protocol/diff/diff-raw.d.mts +29 -0
- package/dist/protocol/diff/diff-raw.mjs +73 -0
- package/dist/protocol/diff/patch.mjs +92 -0
- package/dist/protocol/diff/paths.mjs +67 -0
- package/dist/protocol/diff/read.d.mts +62 -0
- package/dist/protocol/diff/read.mjs +342 -0
- package/dist/protocol/diff/rename-similarity.mjs +428 -0
- package/dist/protocol/diff/text.mjs +12 -0
- package/dist/protocol/diff/tree-diff.d.mts +41 -0
- package/dist/protocol/diff/tree-diff.mjs +607 -0
- package/dist/protocol/framing/band.d.mts +10 -0
- package/dist/protocol/framing/band.mjs +16 -0
- package/dist/protocol/framing/pkt-line.d.mts +48 -0
- package/dist/protocol/framing/pkt-line.mjs +92 -0
- package/dist/protocol/objects/checked-blobs.mjs +127 -0
- package/dist/protocol/objects/commit.d.mts +25 -0
- package/dist/protocol/objects/commit.mjs +138 -0
- package/dist/protocol/objects/fsck-gitmodules.mjs +296 -0
- package/dist/protocol/objects/fsck-names.mjs +189 -0
- package/dist/protocol/objects/fsck.mjs +297 -0
- package/dist/protocol/objects/headers.mjs +109 -0
- package/dist/protocol/objects/held.mjs +56 -0
- package/dist/protocol/objects/iconv.mjs +145 -0
- package/dist/protocol/objects/ident.mjs +111 -0
- package/dist/protocol/objects/lfs-pointer.d.mts +8 -0
- package/dist/protocol/objects/lfs-pointer.mjs +63 -0
- package/dist/protocol/objects/links-raw.mjs +89 -0
- package/dist/protocol/objects/object-rules.mjs +75 -0
- package/dist/protocol/objects/object.d.mts +16 -0
- package/dist/protocol/objects/object.mjs +29 -0
- package/dist/protocol/objects/tag.d.mts +21 -0
- package/dist/protocol/objects/tag.mjs +96 -0
- package/dist/protocol/objects/tree.d.mts +43 -0
- package/dist/protocol/objects/tree.mjs +162 -0
- package/dist/protocol/objects/utf8-verify.mjs +71 -0
- package/dist/protocol/packs/delta.d.mts +57 -0
- package/dist/protocol/packs/delta.mjs +229 -0
- package/dist/protocol/packs/graph.mjs +78 -0
- package/dist/protocol/packs/idx.d.mts +54 -0
- package/dist/protocol/packs/idx.mjs +274 -0
- package/dist/protocol/packs/indexer.d.mts +167 -0
- package/dist/protocol/packs/indexer.mjs +507 -0
- package/dist/protocol/packs/parts.d.mts +40 -0
- package/dist/protocol/packs/parts.mjs +89 -0
- package/dist/protocol/packs/pos.mjs +51 -0
- package/dist/protocol/packs/reader.d.mts +180 -0
- package/dist/protocol/packs/reader.mjs +414 -0
- package/dist/protocol/packs/rev.d.mts +32 -0
- package/dist/protocol/packs/rev.mjs +99 -0
- package/dist/protocol/packs/step.d.mts +10 -0
- package/dist/protocol/packs/step.mjs +12 -0
- package/dist/protocol/packs/write-error.d.mts +12 -0
- package/dist/protocol/packs/write-error.mjs +27 -0
- package/dist/protocol/packs/writer.d.mts +157 -0
- package/dist/protocol/packs/writer.mjs +353 -0
- package/dist/protocol/wire/advertisement.d.mts +72 -0
- package/dist/protocol/wire/advertisement.mjs +161 -0
- package/dist/protocol/wire/fetch.d.mts +155 -0
- package/dist/protocol/wire/fetch.mjs +458 -0
- package/dist/protocol/wire/lines.mjs +107 -0
- package/dist/protocol/wire/push-uploads.mjs +43 -0
- package/dist/protocol/wire/receive-pack.d.mts +71 -0
- package/dist/protocol/wire/receive-pack.mjs +157 -0
- package/dist/protocol/wire/report-status.d.mts +47 -0
- package/dist/protocol/wire/report-status.mjs +119 -0
- package/dist/protocol/wire/v2.d.mts +90 -0
- package/dist/protocol/wire/v2.mjs +185 -0
- package/dist/protocol.d.mts +31 -0
- package/dist/protocol.mjs +31 -0
- package/dist/queue/advance.mjs +1037 -0
- package/dist/queue/callers.mjs +134 -0
- package/dist/queue/calls.mjs +1154 -0
- package/dist/queue/commit.mjs +85 -0
- package/dist/queue/host.d.mts +15 -0
- package/dist/queue/host.mjs +88 -0
- package/dist/queue/ids.d.mts +5 -0
- package/dist/queue/ids.mjs +21 -0
- package/dist/queue/lanes.mjs +86 -0
- package/dist/queue/limits.mjs +99 -0
- package/dist/queue/pages.mjs +76 -0
- package/dist/queue/push-option.mjs +62 -0
- package/dist/queue/rows.mjs +206 -0
- package/dist/queue/schedule.mjs +132 -0
- package/dist/queue/search.mjs +315 -0
- package/dist/queue/state.mjs +325 -0
- package/dist/queue/steps.mjs +317 -0
- package/dist/remote-helper.d.mts +3 -0
- package/dist/remote-helper.mjs +3 -0
- package/dist/rest/api.d.mts +23 -0
- package/dist/rest/api.mjs +27 -0
- package/dist/rest/blobs.d.mts +58 -0
- package/dist/rest/blobs.mjs +41 -0
- package/dist/rest/caller.d.mts +102 -0
- package/dist/rest/caller.mjs +18 -0
- package/dist/rest/client.d.mts +18 -0
- package/dist/rest/client.mjs +587 -0
- package/dist/rest/commits.d.mts +435 -0
- package/dist/rest/commits.mjs +140 -0
- package/dist/rest/errors.d.mts +44 -0
- package/dist/rest/errors.mjs +186 -0
- package/dist/rest/events.d.mts +38 -0
- package/dist/rest/events.mjs +74 -0
- package/dist/rest/files.d.mts +179 -0
- package/dist/rest/files.mjs +92 -0
- package/dist/rest/forks.d.mts +205 -0
- package/dist/rest/forks.mjs +51 -0
- package/dist/rest/handler.d.mts +18 -0
- package/dist/rest/handler.mjs +129 -0
- package/dist/rest/handlers.d.mts +8 -0
- package/dist/rest/handlers.mjs +592 -0
- package/dist/rest/listen.d.mts +24 -0
- package/dist/rest/listen.mjs +142 -0
- package/dist/rest/me.d.mts +55 -0
- package/dist/rest/me.mjs +21 -0
- package/dist/rest/merges.d.mts +90 -0
- package/dist/rest/merges.mjs +39 -0
- package/dist/rest/paths.mjs +86 -0
- package/dist/rest/queue.d.mts +486 -0
- package/dist/rest/queue.mjs +228 -0
- package/dist/rest/refs.d.mts +232 -0
- package/dist/rest/refs.mjs +86 -0
- package/dist/rest/repos.d.mts +223 -0
- package/dist/rest/repos.mjs +93 -0
- package/dist/rest/tags.d.mts +153 -0
- package/dist/rest/tags.mjs +72 -0
- package/dist/rest/tokens.d.mts +297 -0
- package/dist/rest/tokens.mjs +88 -0
- package/dist/rest/topics.d.mts +257 -0
- package/dist/rest/topics.mjs +116 -0
- package/dist/rest/trees.d.mts +158 -0
- package/dist/rest/trees.mjs +118 -0
- package/dist/rest/wire.mjs +57 -0
- package/dist/rest/work.d.mts +107 -0
- package/dist/rest/work.mjs +77 -0
- package/dist/rest.d.mts +8 -0
- package/dist/rest.mjs +5 -0
- package/dist/server/extension.d.mts +17 -0
- package/dist/server/extension.mjs +93 -0
- package/dist/server/lifecycle.d.mts +3 -0
- package/dist/server/lifecycle.mjs +89 -0
- package/dist/server/routes.d.mts +28 -0
- package/dist/server/routes.mjs +60 -0
- package/dist/server/server.d.mts +8 -0
- package/dist/server/server.mjs +615 -0
- package/dist/signin/codes.mjs +47 -0
- package/dist/signin/context.d.mts +9 -0
- package/dist/signin/context.mjs +121 -0
- package/dist/signin/device.mjs +122 -0
- package/dist/signin/forms.mjs +157 -0
- package/dist/signin/grants.d.mts +5 -0
- package/dist/signin/grants.mjs +257 -0
- package/dist/signin/route.mjs +68 -0
- package/dist/signin/web.mjs +125 -0
- package/dist/signin/wire.d.mts +42 -0
- package/dist/signin/wire.mjs +43 -0
- package/dist/storage/allotted.mjs +102 -0
- package/dist/storage/bits.mjs +41 -0
- package/dist/storage/budget.mjs +96 -0
- package/dist/storage/calls.d.mts +18 -0
- package/dist/storage/calls.mjs +273 -0
- package/dist/storage/clean-up.mjs +124 -0
- package/dist/storage/distinct-ids.mjs +39 -0
- package/dist/storage/ewah.mjs +97 -0
- package/dist/storage/fetch.d.mts +15 -0
- package/dist/storage/fetch.mjs +998 -0
- package/dist/storage/fsck.mjs +77 -0
- package/dist/storage/held-memo.mjs +188 -0
- package/dist/storage/index-bitmaps.d.mts +4 -0
- package/dist/storage/index-bitmaps.mjs +654 -0
- package/dist/storage/index-build.d.mts +15 -0
- package/dist/storage/index-build.mjs +1447 -0
- package/dist/storage/index-fetch.d.mts +10 -0
- package/dist/storage/index-fetch.mjs +677 -0
- package/dist/storage/index-files.mjs +232 -0
- package/dist/storage/index-graph.d.mts +3 -0
- package/dist/storage/index-graph.mjs +1049 -0
- package/dist/storage/index-layers.mjs +317 -0
- package/dist/storage/index-reach.mjs +216 -0
- package/dist/storage/index-remap.d.mts +8 -0
- package/dist/storage/index-remap.mjs +592 -0
- package/dist/storage/layout.mjs +69 -0
- package/dist/storage/lfs-pointers.d.mts +21 -0
- package/dist/storage/lfs-pointers.mjs +175 -0
- package/dist/storage/link-join.mjs +106 -0
- package/dist/storage/links.mjs +105 -0
- package/dist/storage/loose.d.mts +15 -0
- package/dist/storage/loose.mjs +121 -0
- package/dist/storage/memory-budget.d.mts +8 -0
- package/dist/storage/memory-budget.mjs +546 -0
- package/dist/storage/merge.mjs +416 -0
- package/dist/storage/object-rows.d.mts +6 -0
- package/dist/storage/object-rows.mjs +211 -0
- package/dist/storage/pack-order.d.mts +8 -0
- package/dist/storage/pack-order.mjs +781 -0
- package/dist/storage/pack-ranges.d.mts +5 -0
- package/dist/storage/pack-ranges.mjs +284 -0
- package/dist/storage/pack-reads.d.mts +11 -0
- package/dist/storage/pack-reads.mjs +1007 -0
- package/dist/storage/pack-receive.d.mts +11 -0
- package/dist/storage/pack-receive.mjs +449 -0
- package/dist/storage/packs.d.mts +56 -0
- package/dist/storage/packs.mjs +603 -0
- package/dist/storage/prune.mjs +506 -0
- package/dist/storage/push-allotment.mjs +109 -0
- package/dist/storage/push-uploads.mjs +152 -0
- package/dist/storage/pushed-commits.mjs +136 -0
- package/dist/storage/quarantine.mjs +98 -0
- package/dist/storage/raw-ids.mjs +44 -0
- package/dist/storage/ready.d.mts +19 -0
- package/dist/storage/ready.mjs +328 -0
- package/dist/storage/receive-links.mjs +297 -0
- package/dist/storage/repack-job.mjs +48 -0
- package/dist/storage/repack.d.mts +31 -0
- package/dist/storage/repack.mjs +182 -0
- package/dist/storage/roots.mjs +42 -0
- package/dist/storage/rows.d.mts +4 -0
- package/dist/storage/rows.mjs +71 -0
- package/dist/storage/send-list.d.mts +8 -0
- package/dist/storage/send-list.mjs +319 -0
- package/dist/storage/shallow.d.mts +4 -0
- package/dist/storage/shallow.mjs +128 -0
- package/dist/storage/stream-whole.mjs +236 -0
- package/dist/storage/unpack.mjs +238 -0
- package/dist/storage/visible.mjs +137 -0
- package/dist/storage/walk.d.mts +8 -0
- package/dist/storage/walk.mjs +176 -0
- package/dist/storage/wants.mjs +362 -0
- package/dist/store/call-count.d.mts +47 -0
- package/dist/store/call-count.mjs +207 -0
- package/dist/store/catalogue.d.mts +7 -0
- package/dist/store/catalogue.mjs +643 -0
- package/dist/store/closed.d.mts +21 -0
- package/dist/store/closed.mjs +34 -0
- package/dist/store/crossing.mjs +69 -0
- package/dist/store/cursor-seal.d.mts +2 -0
- package/dist/store/cursor-seal.mjs +88 -0
- package/dist/store/errors.d.mts +12 -0
- package/dist/store/errors.mjs +135 -0
- package/dist/store/git-store.mjs +75 -0
- package/dist/store/list-job.mjs +35 -0
- package/dist/store/outbox.d.mts +7 -0
- package/dist/store/outbox.mjs +297 -0
- package/dist/store/promises.d.mts +5 -0
- package/dist/store/promises.mjs +258 -0
- package/dist/store/queue-jobs.mjs +43 -0
- package/dist/store/random.mjs +28 -0
- package/dist/store/records.d.mts +4 -0
- package/dist/store/records.mjs +192 -0
- package/dist/store/ref-rows.d.mts +4 -0
- package/dist/store/ref-rows.mjs +30 -0
- package/dist/store/repo-record.mjs +100 -0
- package/dist/store/reservations.mjs +82 -0
- package/dist/store/scopes.mjs +170 -0
- package/dist/store/settle.mjs +63 -0
- package/dist/store/topic-jobs.mjs +62 -0
- package/dist/sync/bound.d.mts +7 -0
- package/dist/sync/bound.mjs +34 -0
- package/dist/sync/github.d.mts +12 -0
- package/dist/sync/github.mjs +297 -0
- package/dist/sync/import.d.mts +8 -0
- package/dist/sync/import.mjs +154 -0
- package/dist/sync/jobs.d.mts +9 -0
- package/dist/sync/jobs.mjs +83 -0
- package/dist/sync/mirror.d.mts +9 -0
- package/dist/sync/mirror.mjs +227 -0
- package/dist/sync/publish.d.mts +5 -0
- package/dist/sync/publish.mjs +117 -0
- package/dist/sync/records.mjs +73 -0
- package/dist/sync/smart-http.d.mts +8 -0
- package/dist/sync/smart-http.mjs +23 -0
- package/dist/sync/step.mjs +334 -0
- package/dist/sync/tries.mjs +126 -0
- package/dist/sync.d.mts +8 -0
- package/dist/sync.mjs +8 -0
- package/dist/topics/advance.mjs +555 -0
- package/dist/topics/calls.mjs +346 -0
- package/dist/topics/directory.mjs +107 -0
- package/dist/topics/host.d.mts +11 -0
- package/dist/topics/host.mjs +71 -0
- package/dist/topics/members.mjs +177 -0
- package/dist/topics/rows.mjs +99 -0
- package/dist/topics/topic.mjs +141 -0
- package/package.json +86 -5
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { ObjectType } from "../../contracts/objects.mjs";
|
|
2
|
+
import { Oid } from "../../contracts/ids.mjs";
|
|
3
|
+
import { BufferError, BufferMeter } from "../bytes/buffers.mjs";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as Schema from "effect/Schema";
|
|
6
|
+
/**
|
|
7
|
+
* A Git pack read as it streams, object by object, never held whole: its header, then each
|
|
8
|
+
* entry's type, size and delta base, its zlib member inflated into a bounded buffer and handed on
|
|
9
|
+
* a piece at a time, and its trailer checked against a SHA-1 of every byte before it, as Git's
|
|
10
|
+
* `pack-format` defines them. Versions 2 and 3 are read. Every byte the reader keeps is counted
|
|
11
|
+
* by a `BufferMeter`, and an allotment past its ceiling fails as a `BufferError`, so what it
|
|
12
|
+
* retains never grows with the pack's length, its entries or its objects' sizes. A pack after a
|
|
13
|
+
* fetch's `NAK` may end with the transport's flush, `0000`; any other byte past the trailer, or a
|
|
14
|
+
* pack that ends early, fails by name.
|
|
15
|
+
*/
|
|
16
|
+
/** Why a pack was refused, named. */
|
|
17
|
+
export declare const PackFault: Schema.Literals<readonly ["header", "version", "type", "size", "offset", "zlib", "length", "truncated", "checksum", "surplus", "too big"]>;
|
|
18
|
+
export type PackFault = typeof PackFault.Type;
|
|
19
|
+
declare const PackError_base: Schema.Class<PackError, Schema.TaggedStruct<"PackError", {
|
|
20
|
+
readonly fault: Schema.Literals<readonly ["header", "version", "type", "size", "offset", "zlib", "length", "truncated", "checksum", "surplus", "too big"]>;
|
|
21
|
+
readonly message: Schema.String;
|
|
22
|
+
/** An object past the size an entry may hold, `too big`: its own size, in bytes. */
|
|
23
|
+
readonly bytes: Schema.optionalKey<Schema.Int>;
|
|
24
|
+
}>, import("effect/Cause").YieldableError>;
|
|
25
|
+
export declare class PackError extends PackError_base {}
|
|
26
|
+
/** The four kinds of object a pack holds whole, and its two kinds of delta. */
|
|
27
|
+
export type PackEntryKind = ObjectType | 'ofs' | 'ref';
|
|
28
|
+
/** A delta's base: an earlier entry, by its offset in the pack, or an object by its ID. */
|
|
29
|
+
export type PackBase = {
|
|
30
|
+
readonly kind: 'offset';
|
|
31
|
+
readonly offset: number;
|
|
32
|
+
} | {
|
|
33
|
+
readonly kind: 'oid';
|
|
34
|
+
readonly oid: Oid;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* One entry's header: where it starts in the pack, its kind, the length of its inflated data,
|
|
38
|
+
* which for a delta is its instructions' length, not the object's, and a delta's base.
|
|
39
|
+
*/
|
|
40
|
+
export interface PackEntry {
|
|
41
|
+
readonly index: number;
|
|
42
|
+
readonly offset: number;
|
|
43
|
+
readonly kind: PackEntryKind;
|
|
44
|
+
readonly size: number;
|
|
45
|
+
readonly base: PackBase | undefined;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* An entry at its end: how many of the pack's bytes it took, header and zlib member, and their
|
|
49
|
+
* CRC-32, which a version 2 index keeps for it.
|
|
50
|
+
*/
|
|
51
|
+
export interface PackEntryEnd extends PackEntry {
|
|
52
|
+
readonly compressed: number;
|
|
53
|
+
readonly crc32: number;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Where a pack's reader hands what it reads, each awaited before it reads on, so a slow sink
|
|
57
|
+
* slows the read: the pack's version and count, each entry's header, its inflated data a piece at
|
|
58
|
+
* a time, and its end with the bytes it took and their CRC-32. An entry or a piece taken at once
|
|
59
|
+
* answers `undefined` and costs the reader no Effect step; one with I/O to wait on, or a failure,
|
|
60
|
+
* answers an Effect. That's a `Step` whose value is `undefined` and whose Effect's is `void`, so
|
|
61
|
+
* `Effect.void` serves, and a callback typed to answer `void`, which may answer anything, doesn't.
|
|
62
|
+
* A piece is the reader's own buffer, good only until the call returns, or until its Effect ends:
|
|
63
|
+
* a sink that keeps it copies it.
|
|
64
|
+
*/
|
|
65
|
+
export interface PackSink<E, R> {
|
|
66
|
+
readonly begin: (pack: {
|
|
67
|
+
readonly version: number;
|
|
68
|
+
readonly count: number;
|
|
69
|
+
}) => Effect.Effect<void, E, R>;
|
|
70
|
+
readonly entry: (entry: PackEntry) => undefined | Effect.Effect<void, E, R>;
|
|
71
|
+
readonly data: (bytes: Uint8Array) => undefined | Effect.Effect<void, E, R>;
|
|
72
|
+
readonly entryEnd: (entry: PackEntryEnd) => Effect.Effect<void, E, R>;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* A sink whose reading may pause between entries: an entry's end answering `pause` stops the
|
|
76
|
+
* reading there, every byte up to that entry's end hashed, and none past it.
|
|
77
|
+
*/
|
|
78
|
+
export interface PausingSink<E, R> extends Omit<PackSink<E, R>, 'entryEnd'> {
|
|
79
|
+
readonly entryEnd: (entry: PackEntryEnd) => Effect.Effect<void | 'pause', E, R>;
|
|
80
|
+
/**
|
|
81
|
+
* For an entry the sink won't read, where the next entry starts, from the pack's `.idx`: its
|
|
82
|
+
* bytes are passed over, never inflated or checked, and its end is `skipped`'s, not
|
|
83
|
+
* `entryEnd`'s. `undefined` reads the entry as any other.
|
|
84
|
+
*/
|
|
85
|
+
readonly skipTo?: (entry: PackEntry) => number | undefined;
|
|
86
|
+
/** A skipped entry's end, once the reader is at the next: `pause` stops the reading there. */
|
|
87
|
+
readonly skipped?: (entry: PackEntry) => void | 'pause';
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Where a paused reading goes on from: the pack's version and count from its header, the next
|
|
91
|
+
* entry's index, and its offset, the first byte the next reading's source gives.
|
|
92
|
+
*/
|
|
93
|
+
export interface PackResume {
|
|
94
|
+
readonly version: number;
|
|
95
|
+
readonly count: number;
|
|
96
|
+
readonly index: number;
|
|
97
|
+
readonly offset: number;
|
|
98
|
+
}
|
|
99
|
+
/** A reading paused between entries, and where the next goes on from. */
|
|
100
|
+
export interface PackPaused {
|
|
101
|
+
readonly paused: PackResume;
|
|
102
|
+
}
|
|
103
|
+
/** A SHA-1 written a piece at a time, each write awaited, as the runtime's `DigestStream` is. */
|
|
104
|
+
export interface PackHasher<E, R> {
|
|
105
|
+
readonly write: (bytes: Uint8Array) => Effect.Effect<void, E, R>;
|
|
106
|
+
readonly digest: Effect.Effect<Uint8Array, E, R>;
|
|
107
|
+
}
|
|
108
|
+
/** Where a pack's bytes come from: the next piece, or none at its end. */
|
|
109
|
+
export interface PackSource<E, R> {
|
|
110
|
+
readonly read: Effect.Effect<Uint8Array | undefined, E, R>;
|
|
111
|
+
}
|
|
112
|
+
/** How much a reader asks of its transport at a time, and the size of its inflate output. */
|
|
113
|
+
export declare const packReadBytes: number;
|
|
114
|
+
declare const PackTransportError_base: Schema.Class<PackTransportError, Schema.TaggedStruct<"PackTransportError", {
|
|
115
|
+
readonly cause: Schema.Unknown;
|
|
116
|
+
}>, import("effect/Cause").YieldableError>;
|
|
117
|
+
/** A transport's read that failed: a broken or cancelled body. */
|
|
118
|
+
export declare class PackTransportError extends PackTransportError_base {}
|
|
119
|
+
/**
|
|
120
|
+
* A body read a bounded piece at a time: through a BYOB reader into one buffer of `readBytes`,
|
|
121
|
+
* reused, where the body is a byte stream; otherwise through its default reader, each piece's
|
|
122
|
+
* whole buffer held by the meter before it's kept and let go before the next read, so a
|
|
123
|
+
* transport that hands over an oversized buffer fails by name rather than being retained. `start`,
|
|
124
|
+
* bytes a caller read before the pack began, comes first, held the same way. Cancelled with
|
|
125
|
+
* `cancel`, as an interrupted reader's end does.
|
|
126
|
+
*/
|
|
127
|
+
export declare const boundedSource: (body: ReadableStream<Uint8Array>, start: Uint8Array, meter: BufferMeter, readBytes?: number) => {
|
|
128
|
+
read: Effect.Effect<Uint8Array<ArrayBufferLike> | undefined, BufferError | PackTransportError, never>;
|
|
129
|
+
cancel: Effect.Effect<void, never, never>;
|
|
130
|
+
};
|
|
131
|
+
/** What a whole pack read came to. */
|
|
132
|
+
export interface PackRead {
|
|
133
|
+
readonly version: number;
|
|
134
|
+
readonly count: number;
|
|
135
|
+
/** Its bytes, header to trailer, and whether the transport's flush followed. */
|
|
136
|
+
readonly bytes: number;
|
|
137
|
+
readonly flushed: boolean;
|
|
138
|
+
/** Its trailer, as hex: SHA-1 of every byte before it. */
|
|
139
|
+
readonly checksum: string;
|
|
140
|
+
}
|
|
141
|
+
/** How large a reader lets an entry's inflated data be, by whether it's a delta's instructions. */
|
|
142
|
+
export interface PackLimits {
|
|
143
|
+
readonly objectBytes: number;
|
|
144
|
+
readonly deltaBytes: number;
|
|
145
|
+
}
|
|
146
|
+
type HeaderRead = {
|
|
147
|
+
readonly kind: 'incomplete';
|
|
148
|
+
} | {
|
|
149
|
+
readonly kind: 'invalid';
|
|
150
|
+
readonly fault: PackFault;
|
|
151
|
+
readonly message: string;
|
|
152
|
+
readonly bytes?: number;
|
|
153
|
+
} | {
|
|
154
|
+
readonly kind: 'entry';
|
|
155
|
+
readonly type: PackEntryKind;
|
|
156
|
+
readonly size: number;
|
|
157
|
+
readonly base: PackBase | undefined;
|
|
158
|
+
};
|
|
159
|
+
/**
|
|
160
|
+
* An entry's header from its first `length` bytes, at pack offset `offset`: its type and size as
|
|
161
|
+
* Git's varint gives them, then an offset delta's distance back or a ref delta's 20-byte ID. Every
|
|
162
|
+
* sum is checked against `Number.MAX_SAFE_INTEGER` before it's made.
|
|
163
|
+
*/
|
|
164
|
+
export declare const readEntryHeader: (bytes: Uint8Array, length: number, offset: number, limits: PackLimits) => HeaderRead;
|
|
165
|
+
/**
|
|
166
|
+
* Reads a pack from `source` to its end, handing `sink` each entry as it goes: header, then each
|
|
167
|
+
* entry, its data and its end, then the trailer, checked against `hasher`'s SHA-1 of every byte
|
|
168
|
+
* before it, then the transport's end, with at most its flush. Each byte is hashed as it's
|
|
169
|
+
* consumed, never past the last entry, so a split anywhere, the trailer's too, reads the same.
|
|
170
|
+
* Fails by name on anything that isn't a whole, well-formed pack.
|
|
171
|
+
*/
|
|
172
|
+
export declare const readPack: <E, R, HE, HR, SE, SR>(source: PackSource<SE, SR>, hasher: PackHasher<HE, HR>, sink: PackSink<E, R>, limits: PackLimits, meter: BufferMeter) => Effect.Effect<PackRead, PackError | BufferError | E | HE | SE, R | HR | SR>;
|
|
173
|
+
/**
|
|
174
|
+
* `readPack`, from `resume` where a paused reading left off, its source giving the pack's bytes
|
|
175
|
+
* from that offset and `hasher` going on from every byte before it; or from its first byte. Its
|
|
176
|
+
* sink may pause it between entries: then it answers where the next goes on from, with no
|
|
177
|
+
* trailer read.
|
|
178
|
+
*/
|
|
179
|
+
export declare const readPackFrom: <E, R, HE, HR, SE, SR>(source: PackSource<SE, SR>, hasher: PackHasher<HE, HR>, sink: PausingSink<E, R>, limits: PackLimits, meter: BufferMeter, resume: PackResume | undefined) => Effect.Effect<PackRead | PackPaused, PackError | BufferError | E | HE | SE, R | HR | SR>;
|
|
180
|
+
export {};
|
|
@@ -0,0 +1,414 @@
|
|
|
1
|
+
import { allotOrFail, allotScoped, capacityOf } from "../bytes/buffers.mjs";
|
|
2
|
+
import { crc32Update } from "../bytes/crc32.mjs";
|
|
3
|
+
import { hexOf } from "../bytes/hex.mjs";
|
|
4
|
+
import { inflaterBytes, memberInflater } from "../bytes/inflate.mjs";
|
|
5
|
+
import { flushPkt } from "../framing/pkt-line.mjs";
|
|
6
|
+
import { objectTypes } from "../objects/object.mjs";
|
|
7
|
+
import { stepEffect } from "./step.mjs";
|
|
8
|
+
import { tryUnlessSpent } from "../../contracts/calls-spent.mjs";
|
|
9
|
+
import * as Effect from "effect/Effect";
|
|
10
|
+
import * as Schema from "effect/Schema";
|
|
11
|
+
import * as Hex from "effect/encoding/Hex";
|
|
12
|
+
// src/protocol/packs/reader.ts
|
|
13
|
+
/**
|
|
14
|
+
* A Git pack read as it streams, object by object, never held whole: its header, then each
|
|
15
|
+
* entry's type, size and delta base, its zlib member inflated into a bounded buffer and handed on
|
|
16
|
+
* a piece at a time, and its trailer checked against a SHA-1 of every byte before it, as Git's
|
|
17
|
+
* `pack-format` defines them. Versions 2 and 3 are read. Every byte the reader keeps is counted
|
|
18
|
+
* by a `BufferMeter`, and an allotment past its ceiling fails as a `BufferError`, so what it
|
|
19
|
+
* retains never grows with the pack's length, its entries or its objects' sizes. A pack after a
|
|
20
|
+
* fetch's `NAK` may end with the transport's flush, `0000`; any other byte past the trailer, or a
|
|
21
|
+
* pack that ends early, fails by name.
|
|
22
|
+
*/
|
|
23
|
+
/** Why a pack was refused, named. */
|
|
24
|
+
const PackFault = Schema.Literals([
|
|
25
|
+
"header",
|
|
26
|
+
"version",
|
|
27
|
+
"type",
|
|
28
|
+
"size",
|
|
29
|
+
"offset",
|
|
30
|
+
"zlib",
|
|
31
|
+
"length",
|
|
32
|
+
"truncated",
|
|
33
|
+
"checksum",
|
|
34
|
+
"surplus",
|
|
35
|
+
"too big"
|
|
36
|
+
]);
|
|
37
|
+
var PackError = class extends Schema.TaggedError()("PackError", {
|
|
38
|
+
fault: PackFault,
|
|
39
|
+
message: Schema.String,
|
|
40
|
+
/** An object past the size an entry may hold, `too big`: its own size, in bytes. */
|
|
41
|
+
bytes: Schema.optionalKey(Schema.Int)
|
|
42
|
+
}) {};
|
|
43
|
+
const fail = (fault, message, bytes) => bytes === void 0 ? new PackError({
|
|
44
|
+
fault,
|
|
45
|
+
message
|
|
46
|
+
}) : new PackError({
|
|
47
|
+
fault,
|
|
48
|
+
message,
|
|
49
|
+
bytes
|
|
50
|
+
});
|
|
51
|
+
/** Each type number's kind, by its index: 0 and 5 are reserved. */
|
|
52
|
+
const entryKinds = [
|
|
53
|
+
void 0,
|
|
54
|
+
...objectTypes,
|
|
55
|
+
void 0,
|
|
56
|
+
"ofs",
|
|
57
|
+
"ref"
|
|
58
|
+
];
|
|
59
|
+
/** How much a reader asks of its transport at a time, and the size of its inflate output. */
|
|
60
|
+
const packReadBytes = 65536;
|
|
61
|
+
const sizeOfFlush = flushPkt.byteLength;
|
|
62
|
+
/** A transport's read that failed: a broken or cancelled body. */
|
|
63
|
+
var PackTransportError = class extends Schema.TaggedError()("PackTransportError", { cause: Schema.Unknown }) {};
|
|
64
|
+
/**
|
|
65
|
+
* A body read a bounded piece at a time: through a BYOB reader into one buffer of `readBytes`,
|
|
66
|
+
* reused, where the body is a byte stream; otherwise through its default reader, each piece's
|
|
67
|
+
* whole buffer held by the meter before it's kept and let go before the next read, so a
|
|
68
|
+
* transport that hands over an oversized buffer fails by name rather than being retained. `start`,
|
|
69
|
+
* bytes a caller read before the pack began, comes first, held the same way. Cancelled with
|
|
70
|
+
* `cancel`, as an interrupted reader's end does.
|
|
71
|
+
*/
|
|
72
|
+
const boundedSource = (body, start, meter, readBytes = packReadBytes) => {
|
|
73
|
+
const byob = byobReader(body);
|
|
74
|
+
const reader = byob === void 0 ? body.getReader() : void 0;
|
|
75
|
+
let buffer = byob === void 0 ? void 0 : new ArrayBuffer(readBytes);
|
|
76
|
+
let first = start.byteLength === 0 ? void 0 : start;
|
|
77
|
+
return {
|
|
78
|
+
read: Effect.gen(function* () {
|
|
79
|
+
meter.free("transport");
|
|
80
|
+
if (first !== void 0) {
|
|
81
|
+
const bytes = first;
|
|
82
|
+
first = void 0;
|
|
83
|
+
yield* allotOrFail(meter, "transport", capacityOf(bytes));
|
|
84
|
+
return bytes;
|
|
85
|
+
}
|
|
86
|
+
if (byob !== void 0 && buffer !== void 0) {
|
|
87
|
+
const view = new Uint8Array(buffer, 0, readBytes);
|
|
88
|
+
yield* allotOrFail(meter, "transport", readBytes);
|
|
89
|
+
const done = yield* tryUnlessSpent(async () => await byob.read(view), (cause) => new PackTransportError({ cause }));
|
|
90
|
+
if (done.done || done.value === void 0) return void 0;
|
|
91
|
+
buffer = done.value.buffer;
|
|
92
|
+
return done.value;
|
|
93
|
+
}
|
|
94
|
+
if (reader === void 0) return void 0;
|
|
95
|
+
const done = yield* tryUnlessSpent(async () => await reader.read(), (cause) => new PackTransportError({ cause }));
|
|
96
|
+
if (done.done) return void 0;
|
|
97
|
+
if (!(done.value instanceof Uint8Array)) return yield* Effect.fail(new PackTransportError({ cause: "a body's piece isn't bytes" }));
|
|
98
|
+
yield* allotOrFail(meter, "transport", capacityOf(done.value));
|
|
99
|
+
return done.value;
|
|
100
|
+
}),
|
|
101
|
+
cancel: Effect.promise(async () => {
|
|
102
|
+
meter.free("transport");
|
|
103
|
+
first = void 0;
|
|
104
|
+
buffer = void 0;
|
|
105
|
+
await (byob ?? reader)?.cancel().catch(() => void 0);
|
|
106
|
+
})
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
/** A BYOB reader of `body`, where its stream is a byte stream, or none. */
|
|
110
|
+
const byobReader = (body) => {
|
|
111
|
+
try {
|
|
112
|
+
return body.getReader({ mode: "byob" });
|
|
113
|
+
} catch {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
/** The most bytes an entry's header takes: its type and size, then a base's offset or ID. */
|
|
118
|
+
const headerBytesMost = 64;
|
|
119
|
+
/**
|
|
120
|
+
* An entry's header from its first `length` bytes, at pack offset `offset`: its type and size as
|
|
121
|
+
* Git's varint gives them, then an offset delta's distance back or a ref delta's 20-byte ID. Every
|
|
122
|
+
* sum is checked against `Number.MAX_SAFE_INTEGER` before it's made.
|
|
123
|
+
*/
|
|
124
|
+
const readEntryHeader = (bytes, length, offset, limits) => {
|
|
125
|
+
if (length === 0) return { kind: "incomplete" };
|
|
126
|
+
const first = bytes[0] ?? 0;
|
|
127
|
+
const type = entryKinds[first >> 4 & 7];
|
|
128
|
+
if (type === void 0) return {
|
|
129
|
+
kind: "invalid",
|
|
130
|
+
fault: "type",
|
|
131
|
+
message: `type ${first >> 4 & 7} isn't a pack's`
|
|
132
|
+
};
|
|
133
|
+
let size = first & 15;
|
|
134
|
+
let scale = 16;
|
|
135
|
+
let at = 1;
|
|
136
|
+
let more = (first & 128) !== 0;
|
|
137
|
+
while (more) {
|
|
138
|
+
if (at >= length) return { kind: "incomplete" };
|
|
139
|
+
if (scale > 2 ** 53) return {
|
|
140
|
+
kind: "invalid",
|
|
141
|
+
fault: "size",
|
|
142
|
+
message: "an entry's size takes more bytes than Git reads"
|
|
143
|
+
};
|
|
144
|
+
const byte = bytes[at] ?? 0;
|
|
145
|
+
const part = (byte & 127) * scale;
|
|
146
|
+
if (size + part > Number.MAX_SAFE_INTEGER) return {
|
|
147
|
+
kind: "invalid",
|
|
148
|
+
fault: "size",
|
|
149
|
+
message: "an entry's size is past what's safe"
|
|
150
|
+
};
|
|
151
|
+
size += part;
|
|
152
|
+
scale *= 128;
|
|
153
|
+
at += 1;
|
|
154
|
+
more = (byte & 128) !== 0;
|
|
155
|
+
}
|
|
156
|
+
const most = type === "ofs" || type === "ref" ? limits.deltaBytes : limits.objectBytes;
|
|
157
|
+
if (size > most) {
|
|
158
|
+
const message = `an entry of ${size} bytes is past ${most}`;
|
|
159
|
+
return type === "ofs" || type === "ref" ? {
|
|
160
|
+
kind: "invalid",
|
|
161
|
+
fault: "too big",
|
|
162
|
+
message
|
|
163
|
+
} : {
|
|
164
|
+
kind: "invalid",
|
|
165
|
+
fault: "too big",
|
|
166
|
+
message,
|
|
167
|
+
bytes: size
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
if (type === "ref") {
|
|
171
|
+
if (length < at + 20) return { kind: "incomplete" };
|
|
172
|
+
return {
|
|
173
|
+
kind: "entry",
|
|
174
|
+
type,
|
|
175
|
+
size,
|
|
176
|
+
base: {
|
|
177
|
+
kind: "oid",
|
|
178
|
+
oid: hexOf(bytes.subarray(at, at + 20))
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
if (type !== "ofs") return {
|
|
183
|
+
kind: "entry",
|
|
184
|
+
type,
|
|
185
|
+
size,
|
|
186
|
+
base: void 0
|
|
187
|
+
};
|
|
188
|
+
if (at >= length) return { kind: "incomplete" };
|
|
189
|
+
let byte = bytes[at] ?? 0;
|
|
190
|
+
let back = byte & 127;
|
|
191
|
+
at += 1;
|
|
192
|
+
while ((byte & 128) !== 0) {
|
|
193
|
+
if (at >= length) return { kind: "incomplete" };
|
|
194
|
+
byte = bytes[at] ?? 0;
|
|
195
|
+
if ((back + 1) * 128 + (byte & 127) > offset) return {
|
|
196
|
+
kind: "invalid",
|
|
197
|
+
fault: "offset",
|
|
198
|
+
message: "a delta's base is before the pack"
|
|
199
|
+
};
|
|
200
|
+
back = (back + 1) * 128 + (byte & 127);
|
|
201
|
+
at += 1;
|
|
202
|
+
}
|
|
203
|
+
if (back === 0 || offset - back < 12) return {
|
|
204
|
+
kind: "invalid",
|
|
205
|
+
fault: "offset",
|
|
206
|
+
message: "a delta's base isn't an earlier entry"
|
|
207
|
+
};
|
|
208
|
+
return {
|
|
209
|
+
kind: "entry",
|
|
210
|
+
type,
|
|
211
|
+
size,
|
|
212
|
+
base: {
|
|
213
|
+
kind: "offset",
|
|
214
|
+
offset: offset - back
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
};
|
|
218
|
+
/**
|
|
219
|
+
* Reads a pack from `source` to its end, handing `sink` each entry as it goes: header, then each
|
|
220
|
+
* entry, its data and its end, then the trailer, checked against `hasher`'s SHA-1 of every byte
|
|
221
|
+
* before it, then the transport's end, with at most its flush. Each byte is hashed as it's
|
|
222
|
+
* consumed, never past the last entry, so a split anywhere, the trailer's too, reads the same.
|
|
223
|
+
* Fails by name on anything that isn't a whole, well-formed pack.
|
|
224
|
+
*/
|
|
225
|
+
const readPack = (source, hasher, sink, limits, meter) => Effect.flatMap(readPackFrom(source, hasher, sink, limits, meter, void 0), (read) => "paused" in read ? Effect.die(/* @__PURE__ */ new Error("a sink that can't pause paused")) : Effect.succeed(read));
|
|
226
|
+
/**
|
|
227
|
+
* `readPack`, from `resume` where a paused reading left off, its source giving the pack's bytes
|
|
228
|
+
* from that offset and `hasher` going on from every byte before it; or from its first byte. Its
|
|
229
|
+
* sink may pause it between entries: then it answers where the next goes on from, with no
|
|
230
|
+
* trailer read.
|
|
231
|
+
*/
|
|
232
|
+
const readPackFrom = (source, hasher, sink, limits, meter, resume) => Effect.scoped(Effect.gen(function* () {
|
|
233
|
+
yield* allotScoped(meter, "inflater", inflaterBytes);
|
|
234
|
+
yield* allotScoped(meter, "inflated", packReadBytes);
|
|
235
|
+
yield* allotScoped(meter, "header", 96 + sizeOfFlush);
|
|
236
|
+
const inflater = yield* Effect.mapError(memberInflater, (error) => fail("zlib", error.message));
|
|
237
|
+
const output = new Uint8Array(packReadBytes);
|
|
238
|
+
const header = new Uint8Array(headerBytesMost);
|
|
239
|
+
const fixed = /* @__PURE__ */ new Uint8Array(12);
|
|
240
|
+
const trailer = /* @__PURE__ */ new Uint8Array(20);
|
|
241
|
+
const inflate = (input) => Effect.mapError(inflater.inflate(input, output), (error) => fail("zlib", error.message));
|
|
242
|
+
const reset = Effect.mapError(inflater.reset, (error) => fail("zlib", error.message));
|
|
243
|
+
let phase = resume === void 0 ? "header" : "entry";
|
|
244
|
+
let version = resume?.version ?? 0;
|
|
245
|
+
let count = resume?.count ?? 0;
|
|
246
|
+
let index = resume?.index ?? 0;
|
|
247
|
+
let consumed = resume?.offset ?? 0;
|
|
248
|
+
let headerLength = 0;
|
|
249
|
+
let fixedLength = 0;
|
|
250
|
+
let trailerLength = 0;
|
|
251
|
+
let afterLength = 0;
|
|
252
|
+
let entry;
|
|
253
|
+
let produced = 0;
|
|
254
|
+
let compressed = 0;
|
|
255
|
+
let crc = 0;
|
|
256
|
+
let checksum = "";
|
|
257
|
+
let skipLeft = 0;
|
|
258
|
+
let skipEnd = 0;
|
|
259
|
+
for (;;) {
|
|
260
|
+
const chunk = yield* source.read;
|
|
261
|
+
if (chunk === void 0) {
|
|
262
|
+
if (phase === "after" && (afterLength === 0 || afterLength === sizeOfFlush)) break;
|
|
263
|
+
if (phase === "after") return yield* fail("surplus", "the pack ends in part of a flush");
|
|
264
|
+
return yield* fail("truncated", `the pack ended in its ${phase}`);
|
|
265
|
+
}
|
|
266
|
+
let at = 0;
|
|
267
|
+
let hashFrom = 0;
|
|
268
|
+
while (at < chunk.byteLength) {
|
|
269
|
+
if (phase === "header") {
|
|
270
|
+
const take = Math.min(12 - fixedLength, chunk.byteLength - at);
|
|
271
|
+
fixed.set(chunk.subarray(at, at + take), fixedLength);
|
|
272
|
+
fixedLength += take;
|
|
273
|
+
at += take;
|
|
274
|
+
if (fixedLength < 12) continue;
|
|
275
|
+
if (String.fromCharCode(...fixed.subarray(0, 4)) !== "PACK") return yield* fail("header", "the pack doesn't start PACK");
|
|
276
|
+
version = readUint32(fixed, 4);
|
|
277
|
+
if (version !== 2 && version !== 3) return yield* fail("version", `pack version ${version} isn't read`);
|
|
278
|
+
count = readUint32(fixed, 8);
|
|
279
|
+
consumed = 12;
|
|
280
|
+
yield* sink.begin({
|
|
281
|
+
version,
|
|
282
|
+
count
|
|
283
|
+
});
|
|
284
|
+
phase = count === 0 ? "trailer" : "entry";
|
|
285
|
+
if (phase === "trailer") {
|
|
286
|
+
yield* hasher.write(chunk.subarray(hashFrom, at));
|
|
287
|
+
hashFrom = at;
|
|
288
|
+
}
|
|
289
|
+
continue;
|
|
290
|
+
}
|
|
291
|
+
if (phase === "entry") {
|
|
292
|
+
const byte = chunk[at] ?? 0;
|
|
293
|
+
if (headerLength >= headerBytesMost) return yield* fail("header", "an entry's header is too long");
|
|
294
|
+
header[headerLength] = byte;
|
|
295
|
+
headerLength += 1;
|
|
296
|
+
at += 1;
|
|
297
|
+
const read = readEntryHeader(header, headerLength, consumed, limits);
|
|
298
|
+
if (read.kind === "incomplete") continue;
|
|
299
|
+
if (read.kind === "invalid") return yield* fail(read.fault, read.message, read.bytes);
|
|
300
|
+
entry = {
|
|
301
|
+
index,
|
|
302
|
+
offset: consumed,
|
|
303
|
+
kind: read.type,
|
|
304
|
+
size: read.size,
|
|
305
|
+
base: read.base
|
|
306
|
+
};
|
|
307
|
+
compressed = headerLength;
|
|
308
|
+
crc = crc32Update(0, header.subarray(0, headerLength));
|
|
309
|
+
headerLength = 0;
|
|
310
|
+
produced = 0;
|
|
311
|
+
const began = sink.entry(entry);
|
|
312
|
+
if (began !== void 0) yield* stepEffect(began);
|
|
313
|
+
const skip = sink.skipTo?.(entry);
|
|
314
|
+
if (skip !== void 0) {
|
|
315
|
+
if (skip <= consumed + compressed) return yield* fail("offset", `a skipped entry at ${consumed} ends at ${skip}`);
|
|
316
|
+
skipEnd = skip;
|
|
317
|
+
skipLeft = skip - consumed - compressed;
|
|
318
|
+
phase = "skip";
|
|
319
|
+
continue;
|
|
320
|
+
}
|
|
321
|
+
phase = "data";
|
|
322
|
+
continue;
|
|
323
|
+
}
|
|
324
|
+
if (phase === "skip" && entry !== void 0) {
|
|
325
|
+
const take = Math.min(skipLeft, chunk.byteLength - at);
|
|
326
|
+
at += take;
|
|
327
|
+
skipLeft -= take;
|
|
328
|
+
if (skipLeft > 0) continue;
|
|
329
|
+
const paused = sink.skipped?.(entry);
|
|
330
|
+
consumed = skipEnd;
|
|
331
|
+
entry = void 0;
|
|
332
|
+
index += 1;
|
|
333
|
+
phase = index === count ? "trailer" : "entry";
|
|
334
|
+
if (paused === "pause" && phase === "entry") {
|
|
335
|
+
yield* hasher.write(chunk.subarray(hashFrom, at));
|
|
336
|
+
return { paused: {
|
|
337
|
+
version,
|
|
338
|
+
count,
|
|
339
|
+
index,
|
|
340
|
+
offset: consumed
|
|
341
|
+
} };
|
|
342
|
+
}
|
|
343
|
+
if (phase === "trailer") {
|
|
344
|
+
yield* hasher.write(chunk.subarray(hashFrom, at));
|
|
345
|
+
hashFrom = at;
|
|
346
|
+
}
|
|
347
|
+
continue;
|
|
348
|
+
}
|
|
349
|
+
if (phase === "data" && entry !== void 0) {
|
|
350
|
+
const inflated = yield* inflate(chunk.subarray(at));
|
|
351
|
+
crc = crc32Update(crc, chunk.subarray(at, at + inflated.consumed));
|
|
352
|
+
at += inflated.consumed;
|
|
353
|
+
compressed += inflated.consumed;
|
|
354
|
+
produced += inflated.produced;
|
|
355
|
+
if (produced > entry.size) return yield* fail("length", `an entry inflates past its ${entry.size} bytes`);
|
|
356
|
+
const took = inflated.produced > 0 ? sink.data(output.subarray(0, inflated.produced)) : void 0;
|
|
357
|
+
if (took !== void 0) yield* stepEffect(took);
|
|
358
|
+
if (inflated.kind !== "end") continue;
|
|
359
|
+
if (produced !== entry.size) return yield* fail("length", `an entry inflated to ${produced}, not ${entry.size}`);
|
|
360
|
+
const paused = yield* sink.entryEnd({
|
|
361
|
+
...entry,
|
|
362
|
+
compressed,
|
|
363
|
+
crc32: crc
|
|
364
|
+
});
|
|
365
|
+
yield* reset;
|
|
366
|
+
consumed = entry.offset + compressed;
|
|
367
|
+
entry = void 0;
|
|
368
|
+
index += 1;
|
|
369
|
+
phase = index === count ? "trailer" : "entry";
|
|
370
|
+
if (paused === "pause" && phase === "entry") {
|
|
371
|
+
yield* hasher.write(chunk.subarray(hashFrom, at));
|
|
372
|
+
return { paused: {
|
|
373
|
+
version,
|
|
374
|
+
count,
|
|
375
|
+
index,
|
|
376
|
+
offset: consumed
|
|
377
|
+
} };
|
|
378
|
+
}
|
|
379
|
+
if (phase === "trailer") {
|
|
380
|
+
yield* hasher.write(chunk.subarray(hashFrom, at));
|
|
381
|
+
hashFrom = at;
|
|
382
|
+
}
|
|
383
|
+
continue;
|
|
384
|
+
}
|
|
385
|
+
if (phase === "trailer") {
|
|
386
|
+
const take = Math.min(20 - trailerLength, chunk.byteLength - at);
|
|
387
|
+
trailer.set(chunk.subarray(at, at + take), trailerLength);
|
|
388
|
+
trailerLength += take;
|
|
389
|
+
at += take;
|
|
390
|
+
hashFrom = at;
|
|
391
|
+
if (trailerLength < 20) continue;
|
|
392
|
+
const sum = yield* hasher.digest;
|
|
393
|
+
checksum = Hex.encode(trailer);
|
|
394
|
+
if (Hex.encode(sum) !== checksum) return yield* fail("checksum", "the pack's trailer isn't its SHA-1");
|
|
395
|
+
phase = "after";
|
|
396
|
+
continue;
|
|
397
|
+
}
|
|
398
|
+
if (afterLength >= sizeOfFlush || chunk[at] !== flushPkt[afterLength]) return yield* fail("surplus", "bytes follow the pack");
|
|
399
|
+
afterLength += 1;
|
|
400
|
+
at += 1;
|
|
401
|
+
hashFrom = at;
|
|
402
|
+
}
|
|
403
|
+
if (phase !== "trailer" && phase !== "after" && hashFrom < chunk.byteLength) yield* hasher.write(chunk.subarray(hashFrom));
|
|
404
|
+
}
|
|
405
|
+
return {
|
|
406
|
+
version,
|
|
407
|
+
count,
|
|
408
|
+
bytes: consumed + 20,
|
|
409
|
+
flushed: afterLength === sizeOfFlush,
|
|
410
|
+
checksum
|
|
411
|
+
};
|
|
412
|
+
}));
|
|
413
|
+
const readUint32 = (bytes, at) => (bytes[at] ?? 0) * 2 ** 24 + ((bytes[at + 1] ?? 0) << 16) + ((bytes[at + 2] ?? 0) << 8) + (bytes[at + 3] ?? 0);
|
|
414
|
+
export { PackError, PackFault, PackTransportError, boundedSource, packReadBytes, readEntryHeader, readPack, readPackFrom };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Oid } from "../../contracts/ids.mjs";
|
|
2
|
+
import { IndexedObject, PackIndex, PackIndexError } from "./idx.mjs";
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
/** How many bytes a `.rev` of `objects` takes. */
|
|
5
|
+
export declare const packReverseBytes: (objects: number) => number;
|
|
6
|
+
/** A pack's `.rev` as read and checked against its `.idx`. */
|
|
7
|
+
export declare class PackReverse {
|
|
8
|
+
#private;
|
|
9
|
+
/** How many objects it lists, as its `.idx` does. */
|
|
10
|
+
readonly count: number;
|
|
11
|
+
constructor(bytes: Uint8Array, count: number);
|
|
12
|
+
/** The `.idx` rank of the pack's `at`th entry, in offset order. */
|
|
13
|
+
rankAt(at: number): number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A `.rev` from its bytes, checked against `index`, the `.idx` of the same pack: its header,
|
|
17
|
+
* version, hash function and length, its own SHA-1, the same pack's trailer, and ranks that name
|
|
18
|
+
* every object once, in strictly ascending offsets, so no two objects share one.
|
|
19
|
+
*/
|
|
20
|
+
export declare const readPackReverse: (bytes: Uint8Array, index: PackIndex) => Effect.Effect<PackReverse, PackIndexError>;
|
|
21
|
+
/** A pack's index files: its `.idx` and `.rev`, byte for byte Git's, and its `.pos`. */
|
|
22
|
+
export interface PackIndexFiles {
|
|
23
|
+
readonly index: Uint8Array;
|
|
24
|
+
readonly reverse: Uint8Array;
|
|
25
|
+
readonly positions: Uint8Array;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The `.idx`, `.rev` and `.pos` of a pack's `objects`, in any order, for the pack whose trailer is
|
|
29
|
+
* `packChecksum`: the first two byte for byte what Git writes for that pack. Every object the pack
|
|
30
|
+
* holds is listed, or the index isn't the pack's.
|
|
31
|
+
*/
|
|
32
|
+
export declare const writePackIndex: (objects: ReadonlyArray<IndexedObject>, packChecksum: Oid) => Effect.Effect<PackIndexFiles, PackIndexError>;
|