@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,54 @@
|
|
|
1
|
+
import { Oid } from "../../contracts/ids.mjs";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Schema from "effect/Schema";
|
|
4
|
+
export declare const PackIndexFault: Schema.Literals<readonly ["header", "version", "length", "fanout", "order", "offset", "checksum"]>;
|
|
5
|
+
export type PackIndexFault = typeof PackIndexFault.Type;
|
|
6
|
+
declare const PackIndexError_base: Schema.Class<PackIndexError, Schema.TaggedStruct<"PackIndexError", {
|
|
7
|
+
readonly fault: Schema.Literals<readonly ["header", "version", "length", "fanout", "order", "offset", "checksum"]>;
|
|
8
|
+
readonly message: Schema.String;
|
|
9
|
+
}>, import("effect/Cause").YieldableError>;
|
|
10
|
+
/** An index refused, or an object list that can't make one, by the rule it breaks. */
|
|
11
|
+
export declare class PackIndexError extends PackIndexError_base {}
|
|
12
|
+
/** One object an index lists: its ID, its entry's offset, and the CRC-32 of the entry's bytes. */
|
|
13
|
+
export interface IndexedObject {
|
|
14
|
+
readonly oid: Oid;
|
|
15
|
+
readonly offset: number;
|
|
16
|
+
readonly crc32: number;
|
|
17
|
+
}
|
|
18
|
+
/** How many bytes an index of `objects`, `large` of them past 2^31 - 1, takes. */
|
|
19
|
+
export declare const packIndexBytes: (objects: number, large: number) => number;
|
|
20
|
+
/** A pack's `.idx` as read and checked: each lookup a binary search inside its first byte's range. */
|
|
21
|
+
export declare class PackIndex {
|
|
22
|
+
#private;
|
|
23
|
+
/** How many objects it lists. */
|
|
24
|
+
readonly count: number;
|
|
25
|
+
/** The trailer of the pack it indexes. */
|
|
26
|
+
readonly packChecksum: Oid;
|
|
27
|
+
constructor(bytes: Uint8Array, count: number);
|
|
28
|
+
/** The IDs ranked `[rank, rank + length)`, 20 bytes each, as the index holds them: not a copy. */
|
|
29
|
+
idsAt(rank: number, length: number): Uint8Array;
|
|
30
|
+
/** The fanout: how many IDs are at or below each first byte. */
|
|
31
|
+
fanout(): Uint32Array;
|
|
32
|
+
/** The ID ranked `rank`th. */
|
|
33
|
+
oidAt(rank: number): Oid;
|
|
34
|
+
/** The offset of the object ranked `rank`th. */
|
|
35
|
+
offsetAt(rank: number): number;
|
|
36
|
+
/** The object ranked `rank`th by ID. */
|
|
37
|
+
object(rank: number): IndexedObject;
|
|
38
|
+
/**
|
|
39
|
+
* The rank of `oid`, if the index lists it: its 20 bytes decoded once and compared with each
|
|
40
|
+
* probe's in place, so a lookup makes no string of the IDs it passes.
|
|
41
|
+
*/
|
|
42
|
+
rankOf(oid: string): number | undefined;
|
|
43
|
+
/** Where `oid` is in the pack, if the index lists it. */
|
|
44
|
+
find(oid: string): IndexedObject | undefined;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* An `.idx` from its bytes, every rule checked before a lookup trusts it: its header, version and
|
|
48
|
+
* length, its own SHA-1, a fanout that counts its IDs, IDs strictly ascending under their first
|
|
49
|
+
* byte, and every offset an entry's, a large one's position in its table and each large offset
|
|
50
|
+
* used once. That no two objects share an offset is its `.rev`'s check. Each read is inside the
|
|
51
|
+
* bytes before it's made: a damaged index is refused by the table it breaks, never thrown on.
|
|
52
|
+
*/
|
|
53
|
+
export declare const readPackIndex: (bytes: Uint8Array) => Effect.Effect<PackIndex, PackIndexError>;
|
|
54
|
+
export {};
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import { hexOf } from "../bytes/hex.mjs";
|
|
2
|
+
import { Sha1 } from "../bytes/sha1.mjs";
|
|
3
|
+
import { isOid } from "../bytes/text.mjs";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as Result from "effect/Result";
|
|
6
|
+
import * as Schema from "effect/Schema";
|
|
7
|
+
import * as Hex from "effect/encoding/Hex";
|
|
8
|
+
// src/protocol/packs/idx.ts
|
|
9
|
+
/**
|
|
10
|
+
* A pack's index, Git's `.idx` version 2 byte for byte, as `git index-pack` writes it and
|
|
11
|
+
* `gitformat-pack` defines it, so Git reads ours and we read Git's. Big-endian throughout:
|
|
12
|
+
*
|
|
13
|
+
* - `\377tOc`, then version 2;
|
|
14
|
+
* - the fanout: for each first byte, how many IDs are at or below it;
|
|
15
|
+
* - each object's ID, ascending, 20 bytes;
|
|
16
|
+
* - each one's entry's CRC-32, 4 bytes;
|
|
17
|
+
* - each one's offset in the pack, 4 bytes, or, with the top bit set, the position of its offset
|
|
18
|
+
* in the next table, for an offset past 2^31 - 1, or for any offset Git was told to keep there;
|
|
19
|
+
* - those large offsets, 8 bytes each, in the order the IDs name them;
|
|
20
|
+
* - the pack's own trailer, then the SHA-1 of every byte before it.
|
|
21
|
+
*
|
|
22
|
+
* It lists every object a pack holds, so a pack with an entry its indexer couldn't resolve has
|
|
23
|
+
* no index. Its `.rev` (`rev.ts`) lists the same objects in the pack's order.
|
|
24
|
+
*/
|
|
25
|
+
/** An `.idx`'s first four bytes. */
|
|
26
|
+
const indexMagic = [
|
|
27
|
+
255,
|
|
28
|
+
116,
|
|
29
|
+
79,
|
|
30
|
+
99
|
|
31
|
+
];
|
|
32
|
+
const version = 2;
|
|
33
|
+
const headerBytes = 8;
|
|
34
|
+
/** An `.idx`'s header and fanout: what a reader by range reads first. */
|
|
35
|
+
const indexHeadBytes = 1032;
|
|
36
|
+
/** Each object's bytes in an index, besides a large offset: its ID, its CRC and its offset. */
|
|
37
|
+
const objectBytes = 28;
|
|
38
|
+
const largeBytes = 8;
|
|
39
|
+
/** What an index ends in: the pack's trailer, then its own SHA-1. */
|
|
40
|
+
const trailerBytes = 40;
|
|
41
|
+
/** The largest offset Git writes in 4 bytes; past it, the offset goes in the large table. */
|
|
42
|
+
const smallMost = 2147483647;
|
|
43
|
+
/** An offset's top bit: the rest is its place in the large table. */
|
|
44
|
+
const largeFlag = 2147483648;
|
|
45
|
+
const PackIndexFault = Schema.Literals([
|
|
46
|
+
"header",
|
|
47
|
+
"version",
|
|
48
|
+
"length",
|
|
49
|
+
"fanout",
|
|
50
|
+
"order",
|
|
51
|
+
"offset",
|
|
52
|
+
"checksum"
|
|
53
|
+
]);
|
|
54
|
+
/** An index refused, or an object list that can't make one, by the rule it breaks. */
|
|
55
|
+
var PackIndexError = class extends Schema.TaggedError()("PackIndexError", {
|
|
56
|
+
fault: PackIndexFault,
|
|
57
|
+
message: Schema.String
|
|
58
|
+
}) {};
|
|
59
|
+
const refuse = (fault, message) => new PackIndexError({
|
|
60
|
+
fault,
|
|
61
|
+
message
|
|
62
|
+
});
|
|
63
|
+
/** Whether `offset` can be an entry's: past the pack's 12-byte header, and exact as a number. */
|
|
64
|
+
const isEntryOffset = (offset) => Number.isSafeInteger(offset) && offset >= 12;
|
|
65
|
+
const isUint32 = (value) => Number.isInteger(value) && value >= 0 && value <= 4294967295;
|
|
66
|
+
/** An ID already checked as one, as its 20 bytes. */
|
|
67
|
+
const oidBytes = (oid) => Result.getOrThrow(Hex.decode(oid));
|
|
68
|
+
/** How many bytes an index of `objects`, `large` of them past 2^31 - 1, takes. */
|
|
69
|
+
const packIndexBytes = (objects, large) => 1032 + objects * objectBytes + large * largeBytes + trailerBytes;
|
|
70
|
+
/** An index's tables, where they start for `count` objects. */
|
|
71
|
+
/** Where an `.idx` of `count` objects keeps its IDs, CRCs, offsets and large offsets. */
|
|
72
|
+
const tablesOf = (count) => {
|
|
73
|
+
const ids = 1032;
|
|
74
|
+
const crcs = ids + count * 20;
|
|
75
|
+
const offsets = crcs + count * 4;
|
|
76
|
+
return {
|
|
77
|
+
ids,
|
|
78
|
+
crcs,
|
|
79
|
+
offsets,
|
|
80
|
+
large: offsets + count * 4
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
/** The bytes of a SHA-1 and of every byte before it, set after them. */
|
|
84
|
+
const sealed = (bytes) => {
|
|
85
|
+
const end = bytes.byteLength - 20;
|
|
86
|
+
const sha = new Sha1();
|
|
87
|
+
sha.update(bytes.subarray(0, end));
|
|
88
|
+
bytes.set(sha.digest(), end);
|
|
89
|
+
return bytes;
|
|
90
|
+
};
|
|
91
|
+
/** Whether `bytes` end in the SHA-1 of every byte before it. */
|
|
92
|
+
const isSealed = (bytes) => {
|
|
93
|
+
const end = bytes.byteLength - 20;
|
|
94
|
+
const sha = new Sha1();
|
|
95
|
+
sha.update(bytes.subarray(0, end));
|
|
96
|
+
return Hex.encode(sha.digest()) === Hex.encode(bytes.subarray(end));
|
|
97
|
+
};
|
|
98
|
+
/** Objects in ascending order of their IDs, as an index ranks them. */
|
|
99
|
+
const byOid = (a, b) => a.oid < b.oid ? -1 : a.oid > b.oid ? 1 : 0;
|
|
100
|
+
/**
|
|
101
|
+
* The `.idx` of `sorted`, by `byOid`, for the pack whose trailer is `packChecksum`: refused for
|
|
102
|
+
* an ID or a CRC that isn't one, an offset that can't be an entry's, or an ID out of order or
|
|
103
|
+
* listed twice.
|
|
104
|
+
*/
|
|
105
|
+
const writeIdx = (sorted, packChecksum) => Effect.gen(function* () {
|
|
106
|
+
if (!isOid(packChecksum)) return yield* refuse("checksum", "the pack's trailer isn't a SHA-1");
|
|
107
|
+
for (const object of sorted) {
|
|
108
|
+
if (!isOid(object.oid)) return yield* refuse("order", `${object.oid} isn't an ID`);
|
|
109
|
+
if (!isEntryOffset(object.offset)) return yield* refuse("offset", `${object.oid}'s offset ${object.offset} isn't an entry's`);
|
|
110
|
+
if (!isUint32(object.crc32)) return yield* refuse("offset", `${object.oid}'s CRC ${object.crc32} isn't a CRC-32`);
|
|
111
|
+
}
|
|
112
|
+
const large = sorted.filter((object) => object.offset > smallMost).length;
|
|
113
|
+
const bytes = new Uint8Array(packIndexBytes(sorted.length, large));
|
|
114
|
+
const view = new DataView(bytes.buffer);
|
|
115
|
+
const at = tablesOf(sorted.length);
|
|
116
|
+
const fanout = new Array(256).fill(0);
|
|
117
|
+
let largeAt = 0;
|
|
118
|
+
for (const [rank, object] of sorted.entries()) {
|
|
119
|
+
const previous = sorted[rank - 1]?.oid ?? "";
|
|
120
|
+
if (object.oid === previous) return yield* refuse("order", `${object.oid} is listed twice`);
|
|
121
|
+
if (object.oid < previous) return yield* refuse("order", `${object.oid} isn't past ${previous}`);
|
|
122
|
+
const first = Number.parseInt(object.oid.slice(0, 2), 16);
|
|
123
|
+
fanout[first] = (fanout[first] ?? 0) + 1;
|
|
124
|
+
bytes.set(oidBytes(object.oid), at.ids + rank * 20);
|
|
125
|
+
view.setUint32(at.crcs + rank * 4, object.crc32);
|
|
126
|
+
if (object.offset <= 2147483647) {
|
|
127
|
+
view.setUint32(at.offsets + rank * 4, object.offset);
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
view.setUint32(at.offsets + rank * 4, (largeFlag | largeAt) >>> 0);
|
|
131
|
+
view.setUint32(at.large + largeAt * 8, Math.floor(object.offset / 2 ** 32));
|
|
132
|
+
view.setUint32(at.large + largeAt * 8 + 4, object.offset % 2 ** 32);
|
|
133
|
+
largeAt += 1;
|
|
134
|
+
}
|
|
135
|
+
bytes.set(indexMagic);
|
|
136
|
+
view.setUint32(4, version);
|
|
137
|
+
let below = 0;
|
|
138
|
+
for (const [first, count] of fanout.entries()) {
|
|
139
|
+
below += count;
|
|
140
|
+
view.setUint32(headerBytes + first * 4, below);
|
|
141
|
+
}
|
|
142
|
+
bytes.set(oidBytes(packChecksum), bytes.byteLength - trailerBytes);
|
|
143
|
+
return sealed(bytes);
|
|
144
|
+
});
|
|
145
|
+
/** A pack's `.idx` as read and checked: each lookup a binary search inside its first byte's range. */
|
|
146
|
+
var PackIndex = class {
|
|
147
|
+
#bytes;
|
|
148
|
+
#view;
|
|
149
|
+
#at;
|
|
150
|
+
/** How many objects it lists. */
|
|
151
|
+
count;
|
|
152
|
+
/** The trailer of the pack it indexes. */
|
|
153
|
+
packChecksum;
|
|
154
|
+
constructor(bytes, count) {
|
|
155
|
+
this.#bytes = bytes;
|
|
156
|
+
this.#view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
157
|
+
this.#at = tablesOf(count);
|
|
158
|
+
this.count = count;
|
|
159
|
+
this.packChecksum = Hex.encode(bytes.subarray(bytes.byteLength - trailerBytes, bytes.byteLength - 20));
|
|
160
|
+
}
|
|
161
|
+
/** The IDs ranked `[rank, rank + length)`, 20 bytes each, as the index holds them: not a copy. */
|
|
162
|
+
idsAt(rank, length) {
|
|
163
|
+
const at = this.#at.ids + rank * 20;
|
|
164
|
+
return this.#bytes.subarray(at, at + length * 20);
|
|
165
|
+
}
|
|
166
|
+
/** The fanout: how many IDs are at or below each first byte. */
|
|
167
|
+
fanout() {
|
|
168
|
+
const fanout = /* @__PURE__ */ new Uint32Array(256);
|
|
169
|
+
for (let first = 0; first < 256; first += 1) fanout[first] = this.#view.getUint32(headerBytes + first * 4);
|
|
170
|
+
return fanout;
|
|
171
|
+
}
|
|
172
|
+
/** The ID ranked `rank`th. */
|
|
173
|
+
oidAt(rank) {
|
|
174
|
+
const at = this.#at.ids + rank * 20;
|
|
175
|
+
return hexOf(this.#bytes.subarray(at, at + 20));
|
|
176
|
+
}
|
|
177
|
+
/** The offset of the object ranked `rank`th. */
|
|
178
|
+
offsetAt(rank) {
|
|
179
|
+
const small = this.#view.getUint32(this.#at.offsets + rank * 4);
|
|
180
|
+
if ((small & 2147483648) === 0) return small;
|
|
181
|
+
const at = this.#at.large + (small & smallMost) * 8;
|
|
182
|
+
return this.#view.getUint32(at) * 2 ** 32 + this.#view.getUint32(at + 4);
|
|
183
|
+
}
|
|
184
|
+
/** The object ranked `rank`th by ID. */
|
|
185
|
+
object(rank) {
|
|
186
|
+
return {
|
|
187
|
+
oid: this.oidAt(rank),
|
|
188
|
+
offset: this.offsetAt(rank),
|
|
189
|
+
crc32: this.#view.getUint32(this.#at.crcs + rank * 4)
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* The rank of `oid`, if the index lists it: its 20 bytes decoded once and compared with each
|
|
194
|
+
* probe's in place, so a lookup makes no string of the IDs it passes.
|
|
195
|
+
*/
|
|
196
|
+
rankOf(oid) {
|
|
197
|
+
if (!isOid(oid)) return void 0;
|
|
198
|
+
const want = oidBytes(oid);
|
|
199
|
+
const bytes = this.#bytes;
|
|
200
|
+
const ids = this.#at.ids;
|
|
201
|
+
const first = want[0] ?? 0;
|
|
202
|
+
let low = first === 0 ? 0 : this.#view.getUint32(headerBytes + (first - 1) * 4);
|
|
203
|
+
let high = this.#view.getUint32(headerBytes + first * 4);
|
|
204
|
+
while (low < high) {
|
|
205
|
+
const middle = low + high >>> 1;
|
|
206
|
+
const at = ids + middle * 20;
|
|
207
|
+
let order = 0;
|
|
208
|
+
for (let byte = 0; byte < 20 && order === 0; byte += 1) order = (bytes[at + byte] ?? 0) - (want[byte] ?? 0);
|
|
209
|
+
if (order === 0) return middle;
|
|
210
|
+
if (order < 0) low = middle + 1;
|
|
211
|
+
else high = middle;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
/** Where `oid` is in the pack, if the index lists it. */
|
|
215
|
+
find(oid) {
|
|
216
|
+
const rank = this.rankOf(oid);
|
|
217
|
+
return rank === void 0 ? void 0 : this.object(rank);
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
/** The table an index of `count` objects ends inside, when it's `length` bytes, short of them all. */
|
|
221
|
+
const endsInside = (count, length) => {
|
|
222
|
+
const at = tablesOf(count);
|
|
223
|
+
return length < at.crcs ? "IDs" : length < at.offsets ? "CRCs" : length < at.large ? "offsets" : "trailer";
|
|
224
|
+
};
|
|
225
|
+
/**
|
|
226
|
+
* An `.idx` from its bytes, every rule checked before a lookup trusts it: its header, version and
|
|
227
|
+
* length, its own SHA-1, a fanout that counts its IDs, IDs strictly ascending under their first
|
|
228
|
+
* byte, and every offset an entry's, a large one's position in its table and each large offset
|
|
229
|
+
* used once. That no two objects share an offset is its `.rev`'s check. Each read is inside the
|
|
230
|
+
* bytes before it's made: a damaged index is refused by the table it breaks, never thrown on.
|
|
231
|
+
*/
|
|
232
|
+
const readPackIndex = (bytes) => Effect.gen(function* () {
|
|
233
|
+
if (bytes.byteLength < headerBytes || indexMagic.some((byte, at) => bytes[at] !== byte)) return yield* refuse("header", "the index doesn't start as a version 2 one");
|
|
234
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
235
|
+
if (view.getUint32(4) !== version) return yield* refuse("version", `index version ${view.getUint32(4)} isn't read`);
|
|
236
|
+
if (bytes.byteLength < 1032) return yield* refuse("length", `the index ends inside its fanout, at ${bytes.byteLength} bytes`);
|
|
237
|
+
const count = view.getUint32(1028);
|
|
238
|
+
const rest = bytes.byteLength - packIndexBytes(count, 0);
|
|
239
|
+
if (rest < 0) return yield* refuse("length", `an index of ${count} objects ends inside its ${endsInside(count, bytes.byteLength)}, at ${bytes.byteLength} bytes`);
|
|
240
|
+
if (rest % largeBytes !== 0 || rest / largeBytes > count) return yield* refuse("length", `an index of ${count} objects isn't ${bytes.byteLength} bytes: its large offsets or its trailer is cut or overlong`);
|
|
241
|
+
const large = rest / largeBytes;
|
|
242
|
+
if (!isSealed(bytes)) return yield* refuse("checksum", "the index's trailer isn't its SHA-1");
|
|
243
|
+
let below = 0;
|
|
244
|
+
for (let first = 0; first < 256; first += 1) {
|
|
245
|
+
const at = view.getUint32(headerBytes + first * 4);
|
|
246
|
+
if (at < below) return yield* refuse("fanout", "the fanout goes down");
|
|
247
|
+
below = at;
|
|
248
|
+
}
|
|
249
|
+
const at = tablesOf(count);
|
|
250
|
+
let previous = "";
|
|
251
|
+
let largeNext = 0;
|
|
252
|
+
for (let rank = 0; rank < count; rank += 1) {
|
|
253
|
+
const oid = hexOf(bytes.subarray(at.ids + rank * 20, at.ids + rank * 20 + 20));
|
|
254
|
+
if (oid <= previous) return yield* refuse("order", `${oid} isn't past ${previous}`);
|
|
255
|
+
const first = bytes[at.ids + rank * 20] ?? 0;
|
|
256
|
+
const start = first === 0 ? 0 : view.getUint32(headerBytes + (first - 1) * 4);
|
|
257
|
+
if (rank < start || rank >= view.getUint32(headerBytes + first * 4)) return yield* refuse("fanout", `${oid} is outside its first byte's range`);
|
|
258
|
+
const small = view.getUint32(at.offsets + rank * 4);
|
|
259
|
+
if ((small & 2147483648) === 0) {
|
|
260
|
+
if (small < 12) return yield* refuse("offset", `${oid}'s offset ${small} isn't an entry's`);
|
|
261
|
+
} else {
|
|
262
|
+
if ((small & 2147483647) !== largeNext) return yield* refuse("offset", `${oid}'s large offset isn't the next one`);
|
|
263
|
+
if (largeNext >= large) return yield* refuse("length", `${oid}'s large offset is past its large offsets, which hold ${large}`);
|
|
264
|
+
const high = view.getUint32(at.large + largeNext * 8);
|
|
265
|
+
const low = view.getUint32(at.large + largeNext * 8 + 4);
|
|
266
|
+
if (high >= 2 ** 21 || high === 0 && low < 12) return yield* refuse("offset", `${oid}'s large offset isn't an entry's`);
|
|
267
|
+
largeNext += 1;
|
|
268
|
+
}
|
|
269
|
+
previous = oid;
|
|
270
|
+
}
|
|
271
|
+
if (largeNext !== large) return yield* refuse("length", `the index holds ${large} large offsets, not ${largeNext}`);
|
|
272
|
+
return new PackIndex(bytes.slice(), count);
|
|
273
|
+
});
|
|
274
|
+
export { PackIndex, PackIndexError, PackIndexFault, byOid, indexHeadBytes, indexMagic, isEntryOffset, isSealed, largeFlag, oidBytes, packIndexBytes, readPackIndex, refuse, sealed, smallMost, tablesOf, writeIdx };
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { ObjectType } from "../../contracts/objects.mjs";
|
|
2
|
+
import { Oid } from "../../contracts/ids.mjs";
|
|
3
|
+
import { BufferError, BufferMeter } from "../bytes/buffers.mjs";
|
|
4
|
+
import { Sha1Runtime } from "../bytes/sha1-hasher.mjs";
|
|
5
|
+
import { DeltaError } from "./delta.mjs";
|
|
6
|
+
import { IndexedObject } from "./idx.mjs";
|
|
7
|
+
import { PackEntry, PackEntryEnd, PackError, PackLimits, PackSource } from "./reader.mjs";
|
|
8
|
+
import { Step } from "./step.mjs";
|
|
9
|
+
import * as Effect from "effect/Effect";
|
|
10
|
+
/** An object resolved: its kind and its bytes, whole. */
|
|
11
|
+
export interface ResolvedObject {
|
|
12
|
+
readonly kind: ObjectType;
|
|
13
|
+
readonly bytes: Uint8Array;
|
|
14
|
+
}
|
|
15
|
+
/** An entry read again by its offset: its header and its inflated data, whole. */
|
|
16
|
+
export interface PackEntryAt {
|
|
17
|
+
readonly entry: PackEntry;
|
|
18
|
+
readonly data: Uint8Array;
|
|
19
|
+
}
|
|
20
|
+
/** Why an entry has no place in its index. */
|
|
21
|
+
export type UnindexableWhy = 'too big' | 'too deep' | 'base not before';
|
|
22
|
+
/** An object at an offset, resolved, or why it can't be. */
|
|
23
|
+
export type Resolved = {
|
|
24
|
+
readonly kind: 'resolved';
|
|
25
|
+
readonly object: ResolvedObject;
|
|
26
|
+
} | {
|
|
27
|
+
readonly kind: 'unindexable';
|
|
28
|
+
readonly why: UnindexableWhy;
|
|
29
|
+
};
|
|
30
|
+
/** What the indexer made of an entry: its object, or why it has none. */
|
|
31
|
+
export type IndexedEntry = {
|
|
32
|
+
readonly kind: 'indexed';
|
|
33
|
+
readonly object: IndexedObject;
|
|
34
|
+
readonly type: ObjectType;
|
|
35
|
+
/** Its object's size, a delta's result's for a delta. */
|
|
36
|
+
readonly size: number;
|
|
37
|
+
/** Its delta base's offset, for a delta. */
|
|
38
|
+
readonly base: number | undefined;
|
|
39
|
+
} | {
|
|
40
|
+
readonly kind: 'unindexable';
|
|
41
|
+
readonly offset: number;
|
|
42
|
+
readonly why: UnindexableWhy;
|
|
43
|
+
/** Its object's ID, when its bytes could be hashed as they came. */
|
|
44
|
+
readonly oid: Oid | undefined;
|
|
45
|
+
};
|
|
46
|
+
/** How the indexer reads what it no longer holds, from the pack it indexes. */
|
|
47
|
+
export interface IndexerReads<E, R> {
|
|
48
|
+
/** The entry at `offset`, read again, `before` run on its header before its data is held. */
|
|
49
|
+
readonly entryAt: (offset: number, before: (entry: PackEntry) => Step<void, E, R>) => Effect.Effect<PackEntryAt | 'too big', E, R>;
|
|
50
|
+
/** Where an entry before the one being read holds `oid`, if one does. */
|
|
51
|
+
readonly offsetOf: (oid: Oid) => Step<number | undefined, E, R>;
|
|
52
|
+
/**
|
|
53
|
+
* Makes room for `bytes` held outside the cache at once, before the indexer holds them: the
|
|
54
|
+
* entry being read, a delta's instructions, its base and its result, sized from their headers.
|
|
55
|
+
* Each call says all it holds then, so one keeping its high-water grows only past it.
|
|
56
|
+
*/
|
|
57
|
+
readonly allot?: (bytes: number) => Step<void, E, R>;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The indexer's limits: its base cache, the largest object it resolves, and the most delta
|
|
61
|
+
* instructions it holds at once, one delta's or a chain's being resolved. An entry past either is
|
|
62
|
+
* unindexable, and none of its data is held, so it holds at most a base, its result and that many
|
|
63
|
+
* instructions besides its cache.
|
|
64
|
+
*/
|
|
65
|
+
export interface IndexerLimits extends PackLimits {
|
|
66
|
+
/** Its cache of resolved objects and of entries found unindexable, each mark `markBytes`. */
|
|
67
|
+
readonly cacheBytes: number;
|
|
68
|
+
/** The largest delta result hashed to name it, past `objectBytes`; one past it is unnamed. */
|
|
69
|
+
readonly nameBytes: number;
|
|
70
|
+
/** The most entries one entry's resolve reads again from the pack; past it, `too deep`. */
|
|
71
|
+
readonly chainReads: number;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* What a cache may hold: its allotment, which grows when there's room up to `most`, and shrinks
|
|
75
|
+
* when another allotment needs the room, the cache evicting to what `watch`'s callback is given
|
|
76
|
+
* before the shrink returns.
|
|
77
|
+
*/
|
|
78
|
+
export interface CacheRoom {
|
|
79
|
+
/** What the cache may hold now. */
|
|
80
|
+
readonly bytes: number;
|
|
81
|
+
/** What it may always hold: a shrink never takes it below this. */
|
|
82
|
+
readonly floor: number;
|
|
83
|
+
/** The most it may grow to. */
|
|
84
|
+
readonly most: number;
|
|
85
|
+
/** Asks for `bytes` more; `true` when they're granted. */
|
|
86
|
+
readonly grow: (bytes: number) => boolean;
|
|
87
|
+
/** `evict(bytes)` is called when the room shrinks: the cache holds no more than `bytes` after. */
|
|
88
|
+
readonly watch: (evict: (bytes: number) => void) => void;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Resolved objects and unindexable marks, by pack and offset, within its room: one indexer's, or
|
|
92
|
+
* shared by every indexer of an operation, so what it holds never grows with how many packs it
|
|
93
|
+
* reads. Each entry counts its overhead with its bytes. Least recent let go first.
|
|
94
|
+
*/
|
|
95
|
+
export declare class IndexerCache {
|
|
96
|
+
#private;
|
|
97
|
+
constructor(room: CacheRoom);
|
|
98
|
+
/** What it may hold now. */
|
|
99
|
+
get bytes(): number;
|
|
100
|
+
/** What it counts itself as holding. */
|
|
101
|
+
get cached(): number;
|
|
102
|
+
/** The largest object the cache keeps: a quarter of the most it may hold, so one never empties it. */
|
|
103
|
+
get most(): number;
|
|
104
|
+
/** A key space for one more pack's offsets. */
|
|
105
|
+
space(): number;
|
|
106
|
+
remember(key: number, held: Resolved): void;
|
|
107
|
+
/** Lets go of everything held. */
|
|
108
|
+
clear(): void;
|
|
109
|
+
recall(key: number): Resolved | undefined;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Resolves and hashes every entry of a pack as its reader hands them on: a whole object hashed as
|
|
113
|
+
* its data comes, never held unless it's small enough to cache; a delta applied to its base, from
|
|
114
|
+
* a cache of resolved objects bounded by bytes, or read again from the pack, its chain resolved
|
|
115
|
+
* from the nearest base it still holds. The entries it found unindexable share that cache, so what
|
|
116
|
+
* it holds never grows with the pack. One entry at a time, in the pack's order.
|
|
117
|
+
*/
|
|
118
|
+
export declare class PackIndexer<E, R> {
|
|
119
|
+
#private;
|
|
120
|
+
/** Entries read again from the pack, for a base the cache no longer held. */
|
|
121
|
+
rereads: number;
|
|
122
|
+
/**
|
|
123
|
+
* `cache` is its own of `limits.cacheBytes` unless one is given to share with other packs'.
|
|
124
|
+
* `named` false is for a pack whose IDs its `.idx` already lists: nothing is hashed, and each
|
|
125
|
+
* entry ends with `settle`, never `entryEnd`. `sha1` is the runtime whose hash names each object,
|
|
126
|
+
* this one's unless given: its `createHash`, Node's and workerd's from compatibility date
|
|
127
|
+
* 2026-08-04 or under `nodejs_compat`, or `Sha1` where it has none.
|
|
128
|
+
*/
|
|
129
|
+
constructor(reads: IndexerReads<E, R>, limits: IndexerLimits, cache?: IndexerCache, options?: {
|
|
130
|
+
readonly named?: boolean;
|
|
131
|
+
readonly sha1?: Sha1Runtime;
|
|
132
|
+
});
|
|
133
|
+
/**
|
|
134
|
+
* The object at `offset`, resolved from the nearest base the cache holds or one stored whole,
|
|
135
|
+
* each delta on the way cached as it's made; or why it can't be. Each base is before its delta,
|
|
136
|
+
* so the chain ends. One the cache holds, or holds as unindexable, is answered at once.
|
|
137
|
+
*/
|
|
138
|
+
resolve(offset: number): Step<Resolved, E | DeltaError, R>;
|
|
139
|
+
/**
|
|
140
|
+
* What `resolve` answers at once for the entry at `offset`, from the cache, with nothing read
|
|
141
|
+
* and no index asked; `undefined` when `resolve` would read.
|
|
142
|
+
*/
|
|
143
|
+
recalled(offset: number): Resolved | undefined;
|
|
144
|
+
/** An entry's header, as the pack's reader hands it on: room made for what it keeps of it. */
|
|
145
|
+
entry(entry: PackEntry): Step<void, E, R>;
|
|
146
|
+
/** A piece of the entry's inflated data: hashed, and kept if it's a delta's or cached. */
|
|
147
|
+
data(bytes: Uint8Array): void;
|
|
148
|
+
/**
|
|
149
|
+
* The entry's end, as the pack's reader hands it on: its object, resolved and hashed, with the
|
|
150
|
+
* entry's CRC-32, or why it can't be. A whole object, one past the limits, and a delta whose base
|
|
151
|
+
* can't be resolved are answered at once; the work is done as it's called, not when an Effect
|
|
152
|
+
* it answers is run.
|
|
153
|
+
*/
|
|
154
|
+
entryEnd(ended: PackEntryEnd): Step<IndexedEntry, E | DeltaError, R>;
|
|
155
|
+
/**
|
|
156
|
+
* A nameless indexer's entry end: its object, whole as it came or a delta applied to its base,
|
|
157
|
+
* cached as `entryEnd` caches it, with no ID made; or why it can't be. The work is done as it's
|
|
158
|
+
* called, as `entryEnd`'s is.
|
|
159
|
+
*/
|
|
160
|
+
settle(): Step<Resolved, E | DeltaError, R>;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* The one entry at `offset` from `source`, which gives the pack's bytes from there: its header
|
|
164
|
+
* and its data inflated whole, then the reading stopped; or `too big` for an entry past `limits`,
|
|
165
|
+
* none of whose data is read. `before` runs on its header, before its data is held.
|
|
166
|
+
*/
|
|
167
|
+
export declare const readEntryAt: <SE, SR, BE = never, BR = never>(source: PackSource<SE, SR>, offset: number, limits: PackLimits, meter: BufferMeter, before?: (entry: PackEntry) => Step<void, BE, BR>) => Effect.Effect<PackEntryAt | 'too big', PackError | BufferError | SE | BE, SR | BR>;
|