@ref0/git 0.0.0 → 0.2.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 +51 -0
- package/dist/client/git-http.mjs +201 -0
- package/dist/client/helper-node.mjs +19 -0
- package/dist/client/local.mjs +160 -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 +150 -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 +10 -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 +63 -0
- package/dist/contracts/push-uploads.d.mts +44 -0
- package/dist/contracts/queue.d.mts +401 -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 +126 -0
- package/dist/contracts/result.mjs +34 -0
- package/dist/contracts/rules.d.mts +159 -0
- package/dist/contracts/server.d.mts +245 -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 +174 -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/clock.mjs +18 -0
- package/dist/core/events/deliver.mjs +468 -0
- package/dist/core/events/stream.d.mts +19 -0
- package/dist/core/events/stream.mjs +290 -0
- package/dist/core/forks.mjs +1027 -0
- package/dist/core/hooks/post-receive.mjs +204 -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 +46 -0
- package/dist/core/publish.mjs +142 -0
- package/dist/core/push-decide.mjs +206 -0
- package/dist/core/push.mjs +1069 -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 +24 -0
- package/dist/core/seam.mjs +41 -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 +3 -0
- package/dist/extend.mjs +1 -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 +1036 -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 +17 -0
- package/dist/rest/handler.mjs +106 -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 +14 -0
- package/dist/server/extension.mjs +85 -0
- package/dist/server/routes.d.mts +25 -0
- package/dist/server/routes.mjs +67 -0
- package/dist/server/server.d.mts +2 -0
- package/dist/server/server.mjs +439 -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/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 +13 -0
- package/dist/storage/fetch.mjs +792 -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 +1433 -0
- package/dist/storage/index-fetch.d.mts +9 -0
- package/dist/storage/index-fetch.mjs +756 -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 +120 -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 +779 -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 +990 -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 +600 -0
- package/dist/storage/prune.mjs +506 -0
- package/dist/storage/push-allotment.mjs +109 -0
- package/dist/storage/push-uploads.mjs +151 -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 +3 -0
- package/dist/storage/rows.mjs +71 -0
- package/dist/storage/shallow.d.mts +5 -0
- package/dist/storage/shallow.mjs +128 -0
- package/dist/storage/stream-whole.mjs +236 -0
- package/dist/storage/unpack.mjs +236 -0
- package/dist/storage/visible.mjs +137 -0
- package/dist/storage/walk.d.mts +7 -0
- package/dist/storage/walk.mjs +170 -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/crossing.mjs +66 -0
- package/dist/store/cursor-seal.d.mts +2 -0
- package/dist/store/cursor-seal.mjs +85 -0
- package/dist/store/errors.d.mts +12 -0
- package/dist/store/errors.mjs +129 -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 +295 -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 +29 -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 +80 -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 +554 -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 +126 -0
- package/package.json +86 -5
|
@@ -0,0 +1,507 @@
|
|
|
1
|
+
import { hexOf } from "../bytes/hex.mjs";
|
|
2
|
+
import { joinedBytes, leadingBytes } from "../bytes/joined.mjs";
|
|
3
|
+
import { sha1NowHasher, sha1NowHasherOn } from "../bytes/sha1-hasher.mjs";
|
|
4
|
+
import { isObjectType, objectHeader } from "../objects/object.mjs";
|
|
5
|
+
import { applyDelta, deltaResultSize } from "./delta.mjs";
|
|
6
|
+
import { PackError, readPackFrom } from "./reader.mjs";
|
|
7
|
+
import { stepEffect, stepFlatMap } from "./step.mjs";
|
|
8
|
+
import * as Effect from "effect/Effect";
|
|
9
|
+
import * as Result from "effect/Result";
|
|
10
|
+
// src/protocol/packs/indexer.ts
|
|
11
|
+
/**
|
|
12
|
+
* What `git index-pack` does as a pack arrives, a pack at a time: each entry resolved, its object
|
|
13
|
+
* hashed for its ID, and listed for the pack's `.idx` with its offset and CRC-32. A whole object
|
|
14
|
+
* is hashed as its data comes; a delta is applied to its base, from a cache bounded by bytes or
|
|
15
|
+
* read again from the pack. An entry is unindexable when its object is past the indexer's cap,
|
|
16
|
+
* whole or as a delta, a delta of one that is, a delta whose base isn't an entry before it, or a
|
|
17
|
+
* delta whose chain is past what the indexer reads again for one entry. One past the cap whose
|
|
18
|
+
* bytes could be hashed as they came is named by its ID: a whole object, or a delta of a base
|
|
19
|
+
* that resolved whose result is within `nameBytes`. A pack with an unindexable entry has no
|
|
20
|
+
* index, since Git's lists every object.
|
|
21
|
+
*/
|
|
22
|
+
/** A whole entry's type as an object's, none for a delta. */
|
|
23
|
+
const objectTypeOf = (kind) => isObjectType(kind) ? kind : void 0;
|
|
24
|
+
/** The ID a named entry's hash gives; a named indexer always makes one. */
|
|
25
|
+
const nameOf = (sha) => {
|
|
26
|
+
if (sha === void 0) throw new Error("a named entry was not hashed");
|
|
27
|
+
return hexOf(sha.digest());
|
|
28
|
+
};
|
|
29
|
+
/** The bytes `pieces` hold together. */
|
|
30
|
+
const piecesBytes = (pieces) => pieces.reduce((sum, piece) => sum + piece.byteLength, 0);
|
|
31
|
+
/** The bytes the cache counts what it holds of an entry as: its bytes and its overhead. */
|
|
32
|
+
const heldBytes = (held) => 384 + (held.kind === "unindexable" ? 64 : held.object.bytes.byteLength);
|
|
33
|
+
/** A room of `bytes` that never grows or shrinks, for a cache outside any budget. */
|
|
34
|
+
const fixedRoom = (bytes) => ({
|
|
35
|
+
bytes,
|
|
36
|
+
floor: bytes,
|
|
37
|
+
most: bytes,
|
|
38
|
+
grow: () => false,
|
|
39
|
+
watch: () => void 0
|
|
40
|
+
});
|
|
41
|
+
/** The most bytes of a pack an offset in a shared cache may point past: 1 TiB. */
|
|
42
|
+
const spaceOffsets = 2 ** 40;
|
|
43
|
+
/**
|
|
44
|
+
* Resolved objects and unindexable marks, by pack and offset, within its room: one indexer's, or
|
|
45
|
+
* shared by every indexer of an operation, so what it holds never grows with how many packs it
|
|
46
|
+
* reads. Each entry counts its overhead with its bytes. Least recent let go first.
|
|
47
|
+
*/
|
|
48
|
+
var IndexerCache = class {
|
|
49
|
+
#room;
|
|
50
|
+
#held = /* @__PURE__ */ new Map();
|
|
51
|
+
#cached = 0;
|
|
52
|
+
#spaces = 0;
|
|
53
|
+
constructor(room) {
|
|
54
|
+
this.#room = room;
|
|
55
|
+
this.#room.watch((bytes) => this.#evictTo(bytes));
|
|
56
|
+
}
|
|
57
|
+
/** What it may hold now. */
|
|
58
|
+
get bytes() {
|
|
59
|
+
return this.#room.bytes;
|
|
60
|
+
}
|
|
61
|
+
/** What it counts itself as holding. */
|
|
62
|
+
get cached() {
|
|
63
|
+
return this.#cached;
|
|
64
|
+
}
|
|
65
|
+
/** The largest object the cache keeps: a quarter of the most it may hold, so one never empties it. */
|
|
66
|
+
get most() {
|
|
67
|
+
return Math.floor(this.#room.most / 4);
|
|
68
|
+
}
|
|
69
|
+
/** A key space for one more pack's offsets. */
|
|
70
|
+
space() {
|
|
71
|
+
this.#spaces += 1;
|
|
72
|
+
return (this.#spaces - 1) * spaceOffsets;
|
|
73
|
+
}
|
|
74
|
+
remember(key, held) {
|
|
75
|
+
if (heldBytes(held) - 384 > this.most) return;
|
|
76
|
+
const before = this.#held.get(key);
|
|
77
|
+
if (before !== void 0) {
|
|
78
|
+
this.#held.delete(key);
|
|
79
|
+
this.#cached -= heldBytes(before);
|
|
80
|
+
}
|
|
81
|
+
this.#held.set(key, held);
|
|
82
|
+
this.#cached += heldBytes(held);
|
|
83
|
+
const over = this.#cached - this.#room.bytes;
|
|
84
|
+
if (over > 0 && this.#room.grow(over)) return;
|
|
85
|
+
this.#evictTo(this.#room.bytes);
|
|
86
|
+
}
|
|
87
|
+
#evictTo(bytes) {
|
|
88
|
+
for (const [at, each] of this.#held) {
|
|
89
|
+
if (this.#cached <= bytes) break;
|
|
90
|
+
this.#held.delete(at);
|
|
91
|
+
this.#cached -= heldBytes(each);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/** Lets go of everything held. */
|
|
95
|
+
clear() {
|
|
96
|
+
this.#held.clear();
|
|
97
|
+
this.#cached = 0;
|
|
98
|
+
}
|
|
99
|
+
recall(key) {
|
|
100
|
+
const held = this.#held.get(key);
|
|
101
|
+
if (held !== void 0) {
|
|
102
|
+
this.#held.delete(key);
|
|
103
|
+
this.#held.set(key, held);
|
|
104
|
+
}
|
|
105
|
+
return held;
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* A delta of `base`, hashed into `sha` as it's made, if given, and kept whole when `keep` says
|
|
110
|
+
* so of its size; `too big` past `most`. Applied at once: a refusal other than `too big` is the
|
|
111
|
+
* one Effect it answers.
|
|
112
|
+
*/
|
|
113
|
+
const applied = (base, instructions, sha, keep, most) => {
|
|
114
|
+
let kept;
|
|
115
|
+
let written = 0;
|
|
116
|
+
let given = 0;
|
|
117
|
+
const made = applyDelta({
|
|
118
|
+
instructions: () => {
|
|
119
|
+
given += 1;
|
|
120
|
+
return instructions[given - 1];
|
|
121
|
+
},
|
|
122
|
+
baseSize: base.bytes.byteLength,
|
|
123
|
+
base: (at, length) => base.bytes.subarray(at, at + length)
|
|
124
|
+
}, {
|
|
125
|
+
size: (size) => {
|
|
126
|
+
sha?.update(objectHeader(base.kind, size));
|
|
127
|
+
kept = keep(size) ? new Uint8Array(size) : void 0;
|
|
128
|
+
},
|
|
129
|
+
write: (bytes) => {
|
|
130
|
+
sha?.update(bytes);
|
|
131
|
+
kept?.set(bytes, written);
|
|
132
|
+
written += bytes.byteLength;
|
|
133
|
+
}
|
|
134
|
+
}, most);
|
|
135
|
+
if (Result.isSuccess(made)) return {
|
|
136
|
+
kind: "made",
|
|
137
|
+
size: made.success,
|
|
138
|
+
bytes: kept
|
|
139
|
+
};
|
|
140
|
+
return made.failure.fault === "too big" ? { kind: "too big" } : Effect.fail(made.failure);
|
|
141
|
+
};
|
|
142
|
+
/**
|
|
143
|
+
* Resolves and hashes every entry of a pack as its reader hands them on: a whole object hashed as
|
|
144
|
+
* its data comes, never held unless it's small enough to cache; a delta applied to its base, from
|
|
145
|
+
* a cache of resolved objects bounded by bytes, or read again from the pack, its chain resolved
|
|
146
|
+
* from the nearest base it still holds. The entries it found unindexable share that cache, so what
|
|
147
|
+
* it holds never grows with the pack. One entry at a time, in the pack's order.
|
|
148
|
+
*/
|
|
149
|
+
var PackIndexer = class {
|
|
150
|
+
#reads;
|
|
151
|
+
#limits;
|
|
152
|
+
#cache;
|
|
153
|
+
#space;
|
|
154
|
+
#named;
|
|
155
|
+
#hash;
|
|
156
|
+
#reading;
|
|
157
|
+
/** Entries read again from the pack, for a base the cache no longer held. */
|
|
158
|
+
rereads = 0;
|
|
159
|
+
/**
|
|
160
|
+
* `cache` is its own of `limits.cacheBytes` unless one is given to share with other packs'.
|
|
161
|
+
* `named` false is for a pack whose IDs its `.idx` already lists: nothing is hashed, and each
|
|
162
|
+
* entry ends with `settle`, never `entryEnd`. `sha1` is the runtime whose hash names each object,
|
|
163
|
+
* this one's unless given: its `createHash`, Node's and workerd's from compatibility date
|
|
164
|
+
* 2026-08-04 or under `nodejs_compat`, or `Sha1` where it has none.
|
|
165
|
+
*/
|
|
166
|
+
constructor(reads, limits, cache = new IndexerCache(fixedRoom(limits.cacheBytes)), options = {}) {
|
|
167
|
+
this.#reads = reads;
|
|
168
|
+
this.#limits = limits;
|
|
169
|
+
this.#cache = cache;
|
|
170
|
+
this.#space = cache.space();
|
|
171
|
+
this.#named = options.named ?? true;
|
|
172
|
+
const on = options.sha1;
|
|
173
|
+
this.#hash = on === void 0 ? sha1NowHasher : () => sha1NowHasherOn(on);
|
|
174
|
+
}
|
|
175
|
+
get #cacheMost() {
|
|
176
|
+
return this.#cache.most;
|
|
177
|
+
}
|
|
178
|
+
#allot(bytes) {
|
|
179
|
+
return this.#reads.allot === void 0 ? void 0 : this.#reads.allot(bytes);
|
|
180
|
+
}
|
|
181
|
+
#remember(offset, held) {
|
|
182
|
+
this.#cache.remember(this.#space + offset, held);
|
|
183
|
+
}
|
|
184
|
+
#recall(offset) {
|
|
185
|
+
return this.#cache.recall(this.#space + offset);
|
|
186
|
+
}
|
|
187
|
+
#mark(offsets, why) {
|
|
188
|
+
const marked = {
|
|
189
|
+
kind: "unindexable",
|
|
190
|
+
why
|
|
191
|
+
};
|
|
192
|
+
for (const offset of offsets) this.#remember(offset, marked);
|
|
193
|
+
return marked;
|
|
194
|
+
}
|
|
195
|
+
/** The offset of a delta's base, or none when it isn't an entry before `offset`. */
|
|
196
|
+
#baseOf(offset, entry) {
|
|
197
|
+
const before = (at) => at !== void 0 && at < offset ? at : void 0;
|
|
198
|
+
if (entry.base === void 0) return void 0;
|
|
199
|
+
if (entry.base.kind === "offset") return before(entry.base.offset);
|
|
200
|
+
return stepFlatMap(this.#reads.offsetOf(entry.base.oid), before);
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* The object at `offset`, resolved from the nearest base the cache holds or one stored whole,
|
|
204
|
+
* each delta on the way cached as it's made; or why it can't be. Each base is before its delta,
|
|
205
|
+
* so the chain ends. One the cache holds, or holds as unindexable, is answered at once.
|
|
206
|
+
*/
|
|
207
|
+
resolve(offset) {
|
|
208
|
+
return this.#recall(offset) ?? this.#resolveRead(offset);
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* What `resolve` answers at once for the entry at `offset`, from the cache, with nothing read
|
|
212
|
+
* and no index asked; `undefined` when `resolve` would read.
|
|
213
|
+
*/
|
|
214
|
+
recalled(offset) {
|
|
215
|
+
return this.#recall(offset);
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* `resolve` of an object the cache doesn't hold: its chain read again from the pack, beside
|
|
219
|
+
* `beside` bytes the caller holds, a delta's own instructions.
|
|
220
|
+
*/
|
|
221
|
+
#resolveRead = (offset, beside = 0) => Effect.gen({ self: this }, function* () {
|
|
222
|
+
const chain = [];
|
|
223
|
+
let at = offset;
|
|
224
|
+
let base;
|
|
225
|
+
let held = beside;
|
|
226
|
+
let reads = 0;
|
|
227
|
+
while (base === void 0) {
|
|
228
|
+
const recalled = this.#recall(at);
|
|
229
|
+
if (recalled?.kind === "unindexable") return this.#mark(chain.map((link) => link.at), recalled.why);
|
|
230
|
+
base = recalled?.object;
|
|
231
|
+
if (base !== void 0) break;
|
|
232
|
+
if (reads >= this.#limits.chainReads) return {
|
|
233
|
+
kind: "unindexable",
|
|
234
|
+
why: "too deep"
|
|
235
|
+
};
|
|
236
|
+
const read = yield* this.#reads.entryAt(at, (entry) => this.#allot(held + entry.size));
|
|
237
|
+
this.rereads += 1;
|
|
238
|
+
reads += 1;
|
|
239
|
+
if (read === "too big") return this.#mark([at, ...chain.map((link) => link.at)], "too big");
|
|
240
|
+
const kind = objectTypeOf(read.entry.kind);
|
|
241
|
+
if (kind !== void 0) {
|
|
242
|
+
if (read.data.byteLength > this.#limits.objectBytes) return this.#mark([at, ...chain.map((link) => link.at)], "too big");
|
|
243
|
+
base = {
|
|
244
|
+
kind,
|
|
245
|
+
bytes: read.data
|
|
246
|
+
};
|
|
247
|
+
this.#remember(at, {
|
|
248
|
+
kind: "resolved",
|
|
249
|
+
object: base
|
|
250
|
+
});
|
|
251
|
+
break;
|
|
252
|
+
}
|
|
253
|
+
const next = yield* stepEffect(this.#baseOf(at, read.entry));
|
|
254
|
+
chain.push({
|
|
255
|
+
at,
|
|
256
|
+
data: read.data
|
|
257
|
+
});
|
|
258
|
+
held += read.data.byteLength;
|
|
259
|
+
if (held > this.#limits.deltaBytes) return {
|
|
260
|
+
kind: "unindexable",
|
|
261
|
+
why: "too deep"
|
|
262
|
+
};
|
|
263
|
+
if (next === void 0) return this.#mark(chain.map((link) => link.at), "base not before");
|
|
264
|
+
at = next;
|
|
265
|
+
}
|
|
266
|
+
const order = chain.reverse();
|
|
267
|
+
for (const [step, link] of order.entries()) {
|
|
268
|
+
const size = deltaResultSize(link.data.subarray(0, 20)) ?? 0;
|
|
269
|
+
yield* stepEffect(this.#allot(held + base.bytes.byteLength + size));
|
|
270
|
+
const made = yield* stepEffect(applied(base, [link.data], void 0, () => true, this.#limits.objectBytes));
|
|
271
|
+
if (made.kind === "too big") return this.#mark(order.slice(step).map((each) => each.at), "too big");
|
|
272
|
+
base = {
|
|
273
|
+
kind: base.kind,
|
|
274
|
+
bytes: made.bytes ?? /* @__PURE__ */ new Uint8Array(0)
|
|
275
|
+
};
|
|
276
|
+
this.#remember(link.at, {
|
|
277
|
+
kind: "resolved",
|
|
278
|
+
object: base
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
return {
|
|
282
|
+
kind: "resolved",
|
|
283
|
+
object: base
|
|
284
|
+
};
|
|
285
|
+
});
|
|
286
|
+
/** An entry's header, as the pack's reader hands it on: room made for what it keeps of it. */
|
|
287
|
+
entry(entry) {
|
|
288
|
+
const kind = objectTypeOf(entry.kind);
|
|
289
|
+
const over = entry.size > (kind === void 0 ? this.#limits.deltaBytes : this.#limits.objectBytes);
|
|
290
|
+
const whole = kind === void 0 ? void 0 : {
|
|
291
|
+
kind,
|
|
292
|
+
sha: this.#named ? this.#hash() : void 0
|
|
293
|
+
};
|
|
294
|
+
whole?.sha?.update(objectHeader(whole.kind, entry.size));
|
|
295
|
+
this.#reading = {
|
|
296
|
+
entry,
|
|
297
|
+
whole,
|
|
298
|
+
over,
|
|
299
|
+
pieces: [],
|
|
300
|
+
kept: !over && (whole === void 0 || !this.#named || entry.size <= this.#cacheMost)
|
|
301
|
+
};
|
|
302
|
+
return this.#allot(this.#reading.kept ? entry.size : 0);
|
|
303
|
+
}
|
|
304
|
+
/** A piece of the entry's inflated data: hashed, and kept if it's a delta's or cached. */
|
|
305
|
+
data(bytes) {
|
|
306
|
+
const reading = this.#reading;
|
|
307
|
+
if (reading === void 0) return;
|
|
308
|
+
reading.whole?.sha?.update(bytes);
|
|
309
|
+
if (reading.kept) reading.pieces.push(bytes.slice());
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* The entry's end, as the pack's reader hands it on: its object, resolved and hashed, with the
|
|
313
|
+
* entry's CRC-32, or why it can't be. A whole object, one past the limits, and a delta whose base
|
|
314
|
+
* can't be resolved are answered at once; the work is done as it's called, not when an Effect
|
|
315
|
+
* it answers is run.
|
|
316
|
+
*/
|
|
317
|
+
entryEnd(ended) {
|
|
318
|
+
const reading = this.#reading;
|
|
319
|
+
this.#reading = void 0;
|
|
320
|
+
if (reading === void 0) return Effect.die(/* @__PURE__ */ new Error("an entry ended unbegun"));
|
|
321
|
+
if (!this.#named) return Effect.die(/* @__PURE__ */ new Error("a nameless indexer ended an entry unsettled"));
|
|
322
|
+
const { entry, whole } = reading;
|
|
323
|
+
if (reading.over) {
|
|
324
|
+
this.#mark([entry.offset], "too big");
|
|
325
|
+
return {
|
|
326
|
+
kind: "unindexable",
|
|
327
|
+
offset: entry.offset,
|
|
328
|
+
why: "too big",
|
|
329
|
+
oid: whole?.sha === void 0 ? void 0 : hexOf(whole.sha.digest())
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
if (whole !== void 0) {
|
|
333
|
+
if (reading.kept) this.#remember(entry.offset, {
|
|
334
|
+
kind: "resolved",
|
|
335
|
+
object: {
|
|
336
|
+
kind: whole.kind,
|
|
337
|
+
bytes: joinedBytes(reading.pieces)
|
|
338
|
+
}
|
|
339
|
+
});
|
|
340
|
+
return {
|
|
341
|
+
kind: "indexed",
|
|
342
|
+
type: whole.kind,
|
|
343
|
+
size: entry.size,
|
|
344
|
+
object: {
|
|
345
|
+
oid: nameOf(whole.sha),
|
|
346
|
+
offset: entry.offset,
|
|
347
|
+
crc32: ended.crc32
|
|
348
|
+
},
|
|
349
|
+
base: void 0
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
return stepFlatMap(this.#baseOf(entry.offset, entry), (at) => stepFlatMap(at === void 0 ? this.#mark([entry.offset], "base not before") : this.#recall(at) ?? this.#resolveRead(at, piecesBytes(reading.pieces)), (base) => stepFlatMap(this.#allotDelta(reading, base), () => this.#deltaEnd(reading, ended, at, base))));
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* A nameless indexer's entry end: its object, whole as it came or a delta applied to its base,
|
|
356
|
+
* cached as `entryEnd` caches it, with no ID made; or why it can't be. The work is done as it's
|
|
357
|
+
* called, as `entryEnd`'s is.
|
|
358
|
+
*/
|
|
359
|
+
settle() {
|
|
360
|
+
const reading = this.#reading;
|
|
361
|
+
this.#reading = void 0;
|
|
362
|
+
if (reading === void 0) return Effect.die(/* @__PURE__ */ new Error("an entry ended unbegun"));
|
|
363
|
+
if (this.#named) return Effect.die(/* @__PURE__ */ new Error("a named indexer settled an entry"));
|
|
364
|
+
const { entry, whole } = reading;
|
|
365
|
+
if (reading.over) return this.#mark([entry.offset], "too big");
|
|
366
|
+
if (whole !== void 0) {
|
|
367
|
+
const object = {
|
|
368
|
+
kind: whole.kind,
|
|
369
|
+
bytes: joinedBytes(reading.pieces)
|
|
370
|
+
};
|
|
371
|
+
this.#remember(entry.offset, {
|
|
372
|
+
kind: "resolved",
|
|
373
|
+
object
|
|
374
|
+
});
|
|
375
|
+
return {
|
|
376
|
+
kind: "resolved",
|
|
377
|
+
object
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
return stepFlatMap(this.#baseOf(entry.offset, entry), (at) => stepFlatMap(at === void 0 ? this.#mark([entry.offset], "base not before") : this.#recall(at) ?? this.#resolveRead(at, piecesBytes(reading.pieces)), (base) => stepFlatMap(this.#allotDelta(reading, base), () => this.#settleDelta(reading, base))));
|
|
381
|
+
}
|
|
382
|
+
/** A nameless delta's end, once its base is resolved: its result made whole and cached. */
|
|
383
|
+
#settleDelta(reading, base) {
|
|
384
|
+
const { entry } = reading;
|
|
385
|
+
if (base.kind === "unindexable") {
|
|
386
|
+
if (base.why !== "too deep") this.#mark([entry.offset], base.why);
|
|
387
|
+
return base;
|
|
388
|
+
}
|
|
389
|
+
return stepFlatMap(applied(base.object, reading.pieces, void 0, () => true, this.#limits.objectBytes), (made) => {
|
|
390
|
+
if (made.kind === "too big") return this.#mark([entry.offset], "too big");
|
|
391
|
+
const object = {
|
|
392
|
+
kind: base.object.kind,
|
|
393
|
+
bytes: made.bytes ?? /* @__PURE__ */ new Uint8Array(0)
|
|
394
|
+
};
|
|
395
|
+
this.#remember(entry.offset, {
|
|
396
|
+
kind: "resolved",
|
|
397
|
+
object
|
|
398
|
+
});
|
|
399
|
+
return {
|
|
400
|
+
kind: "resolved",
|
|
401
|
+
object
|
|
402
|
+
};
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* Room for a delta's result, made beside its instructions and its base, which counts whether or
|
|
407
|
+
* not the cache holds it too; a result past what's kept is hashed as it's made, never held.
|
|
408
|
+
*/
|
|
409
|
+
#allotDelta(reading, base) {
|
|
410
|
+
if (base.kind === "unindexable") return void 0;
|
|
411
|
+
const instructions = piecesBytes(reading.pieces);
|
|
412
|
+
const head = leadingBytes(reading.pieces, 20);
|
|
413
|
+
const size = deltaResultSize(head) ?? 0;
|
|
414
|
+
const keeps = this.#named ? this.#cacheMost : this.#limits.objectBytes;
|
|
415
|
+
const kept = size <= Math.min(keeps, this.#limits.objectBytes) ? size : 0;
|
|
416
|
+
return this.#allot(instructions + base.object.bytes.byteLength + kept);
|
|
417
|
+
}
|
|
418
|
+
/** A delta's end, once its base is resolved, or why it can't be. */
|
|
419
|
+
#deltaEnd(reading, ended, at, base) {
|
|
420
|
+
const { entry } = reading;
|
|
421
|
+
if (base.kind === "unindexable") {
|
|
422
|
+
if (base.why !== "too deep") this.#mark([entry.offset], base.why);
|
|
423
|
+
return {
|
|
424
|
+
kind: "unindexable",
|
|
425
|
+
offset: entry.offset,
|
|
426
|
+
why: base.why,
|
|
427
|
+
oid: void 0
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
const sha = this.#hash();
|
|
431
|
+
return stepFlatMap(applied(base.object, reading.pieces, sha, (size) => size <= Math.min(this.#cacheMost, this.#limits.objectBytes), this.#limits.nameBytes), (made) => {
|
|
432
|
+
if (made.kind === "too big") {
|
|
433
|
+
this.#mark([entry.offset], "too big");
|
|
434
|
+
return {
|
|
435
|
+
kind: "unindexable",
|
|
436
|
+
offset: entry.offset,
|
|
437
|
+
why: "too big",
|
|
438
|
+
oid: void 0
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
if (made.size > this.#limits.objectBytes) {
|
|
442
|
+
this.#mark([entry.offset], "too big");
|
|
443
|
+
return {
|
|
444
|
+
kind: "unindexable",
|
|
445
|
+
offset: entry.offset,
|
|
446
|
+
why: "too big",
|
|
447
|
+
oid: hexOf(sha.digest())
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
if (made.bytes !== void 0) this.#remember(entry.offset, {
|
|
451
|
+
kind: "resolved",
|
|
452
|
+
object: {
|
|
453
|
+
kind: base.object.kind,
|
|
454
|
+
bytes: made.bytes
|
|
455
|
+
}
|
|
456
|
+
});
|
|
457
|
+
return {
|
|
458
|
+
kind: "indexed",
|
|
459
|
+
type: base.object.kind,
|
|
460
|
+
size: made.size,
|
|
461
|
+
object: {
|
|
462
|
+
oid: hexOf(sha.digest()),
|
|
463
|
+
offset: entry.offset,
|
|
464
|
+
crc32: ended.crc32
|
|
465
|
+
},
|
|
466
|
+
base: at
|
|
467
|
+
};
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
};
|
|
471
|
+
/**
|
|
472
|
+
* The one entry at `offset` from `source`, which gives the pack's bytes from there: its header
|
|
473
|
+
* and its data inflated whole, then the reading stopped; or `too big` for an entry past `limits`,
|
|
474
|
+
* none of whose data is read. `before` runs on its header, before its data is held.
|
|
475
|
+
*/
|
|
476
|
+
const readEntryAt = (source, offset, limits, meter, before = () => void 0) => Effect.gen(function* () {
|
|
477
|
+
let entry;
|
|
478
|
+
let data = /* @__PURE__ */ new Uint8Array(0);
|
|
479
|
+
let at = 0;
|
|
480
|
+
const read = yield* readPackFrom(source, {
|
|
481
|
+
write: () => Effect.void,
|
|
482
|
+
digest: Effect.succeed(/* @__PURE__ */ new Uint8Array(20))
|
|
483
|
+
}, {
|
|
484
|
+
begin: () => Effect.void,
|
|
485
|
+
entry: (header) => stepEffect(before(header)).pipe(Effect.map(() => {
|
|
486
|
+
entry = header;
|
|
487
|
+
data = new Uint8Array(header.size);
|
|
488
|
+
})),
|
|
489
|
+
data: (bytes) => Effect.sync(() => {
|
|
490
|
+
data.set(bytes, at);
|
|
491
|
+
at += bytes.byteLength;
|
|
492
|
+
}),
|
|
493
|
+
entryEnd: () => Effect.succeed("pause")
|
|
494
|
+
}, limits, meter, {
|
|
495
|
+
version: 2,
|
|
496
|
+
count: 2,
|
|
497
|
+
index: 0,
|
|
498
|
+
offset
|
|
499
|
+
}).pipe(Effect.map(() => "read"), Effect.catchIf((failed) => failed instanceof PackError && failed.fault === "too big", () => Effect.succeed("too big")));
|
|
500
|
+
if (read === "too big") return read;
|
|
501
|
+
if (entry === void 0) return yield* Effect.die(/* @__PURE__ */ new Error("no entry was read"));
|
|
502
|
+
return {
|
|
503
|
+
entry,
|
|
504
|
+
data
|
|
505
|
+
};
|
|
506
|
+
});
|
|
507
|
+
export { IndexerCache, PackIndexer, fixedRoom, readEntryAt };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { PackWriteFault } from "./write-error.mjs";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
/**
|
|
4
|
+
* Where a pack's encoding spends its wall time, part by part, and how many times each part ran:
|
|
5
|
+
* its source's pages and body ranges, each object's hash and digest, its compressor's writes and
|
|
6
|
+
* finish, the pack's own hash, the output's writes, the timer's turns, and a caller's index and
|
|
7
|
+
* sink completion beside them. Each part's milliseconds are its own: a part begun inside another,
|
|
8
|
+
* as the output's writes inside a compressor's, stops the other's clock until it ends, so the
|
|
9
|
+
* parts never count a millisecond twice. A runtime whose clock moves only when an await waits,
|
|
10
|
+
* as Cloudflare's does, counts in each part only the waits it made.
|
|
11
|
+
*/
|
|
12
|
+
export declare const packParts: readonly ['page', 'body', 'object_hash', 'object_digest', 'deflate', 'deflate_end', 'pack_hash', 'output', 'turn', 'index', 'complete'];
|
|
13
|
+
export type PackPart = (typeof packParts)[number];
|
|
14
|
+
/**
|
|
15
|
+
* How an encoding ended: written whole, refused by the writer for its fault, failed for another
|
|
16
|
+
* reason such as its fence or its output, or interrupted.
|
|
17
|
+
*/
|
|
18
|
+
export type PackEnd = 'written' | PackWriteFault | 'failed' | 'interrupted';
|
|
19
|
+
/**
|
|
20
|
+
* An encoding's parts, kept by its caller so a writing that fails, by its time bound say, leaves
|
|
21
|
+
* them as far as it got: the objects and bytes it had written, and how it ended once it did.
|
|
22
|
+
* Several encodings may add to one, as a merge's halved retries do.
|
|
23
|
+
*/
|
|
24
|
+
export declare class PackParts {
|
|
25
|
+
#private;
|
|
26
|
+
readonly millis: Record<"body" | "complete" | "deflate" | "deflate_end" | "index" | "object_digest" | "object_hash" | "output" | "pack_hash" | "page" | "turn", number>;
|
|
27
|
+
readonly counts: Record<"body" | "complete" | "deflate" | "deflate_end" | "index" | "object_digest" | "object_hash" | "output" | "pack_hash" | "page" | "turn", number>;
|
|
28
|
+
/** Objects whose entries were written whole, and the pack's bytes written, so far. */
|
|
29
|
+
objects: number;
|
|
30
|
+
bytes: number;
|
|
31
|
+
/** How the last encoding ended, once it has. */
|
|
32
|
+
ended: PackEnd | undefined;
|
|
33
|
+
/** `effect`, its time counted to `part`, its own time only while a part inside it runs. */
|
|
34
|
+
timed<A, E, R>(part: PackPart, effect: Effect.Effect<A, E, R>): Effect.Effect<A, E, R>;
|
|
35
|
+
/**
|
|
36
|
+
* `effect`, its whole wall time counted to `part`, apart from any other part: for work that runs
|
|
37
|
+
* beside another, as a pack's index beside its sink's completion.
|
|
38
|
+
*/
|
|
39
|
+
apart<A, E, R>(part: PackPart, effect: Effect.Effect<A, E, R>): Effect.Effect<A, E, R>;
|
|
40
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import * as Clock from "effect/Clock";
|
|
3
|
+
// src/protocol/packs/parts.ts
|
|
4
|
+
/**
|
|
5
|
+
* Where a pack's encoding spends its wall time, part by part, and how many times each part ran:
|
|
6
|
+
* its source's pages and body ranges, each object's hash and digest, its compressor's writes and
|
|
7
|
+
* finish, the pack's own hash, the output's writes, the timer's turns, and a caller's index and
|
|
8
|
+
* sink completion beside them. Each part's milliseconds are its own: a part begun inside another,
|
|
9
|
+
* as the output's writes inside a compressor's, stops the other's clock until it ends, so the
|
|
10
|
+
* parts never count a millisecond twice. A runtime whose clock moves only when an await waits,
|
|
11
|
+
* as Cloudflare's does, counts in each part only the waits it made.
|
|
12
|
+
*/
|
|
13
|
+
const packParts = [
|
|
14
|
+
"page",
|
|
15
|
+
"body",
|
|
16
|
+
"object_hash",
|
|
17
|
+
"object_digest",
|
|
18
|
+
"deflate",
|
|
19
|
+
"deflate_end",
|
|
20
|
+
"pack_hash",
|
|
21
|
+
"output",
|
|
22
|
+
"turn",
|
|
23
|
+
"index",
|
|
24
|
+
"complete"
|
|
25
|
+
];
|
|
26
|
+
const zeroes = () => ({
|
|
27
|
+
page: 0,
|
|
28
|
+
body: 0,
|
|
29
|
+
object_hash: 0,
|
|
30
|
+
object_digest: 0,
|
|
31
|
+
deflate: 0,
|
|
32
|
+
deflate_end: 0,
|
|
33
|
+
pack_hash: 0,
|
|
34
|
+
output: 0,
|
|
35
|
+
turn: 0,
|
|
36
|
+
index: 0,
|
|
37
|
+
complete: 0
|
|
38
|
+
});
|
|
39
|
+
/**
|
|
40
|
+
* An encoding's parts, kept by its caller so a writing that fails, by its time bound say, leaves
|
|
41
|
+
* them as far as it got: the objects and bytes it had written, and how it ended once it did.
|
|
42
|
+
* Several encodings may add to one, as a merge's halved retries do.
|
|
43
|
+
*/
|
|
44
|
+
var PackParts = class {
|
|
45
|
+
millis = zeroes();
|
|
46
|
+
counts = zeroes();
|
|
47
|
+
/** Objects whose entries were written whole, and the pack's bytes written, so far. */
|
|
48
|
+
objects = 0;
|
|
49
|
+
bytes = 0;
|
|
50
|
+
/** How the last encoding ended, once it has. */
|
|
51
|
+
ended = void 0;
|
|
52
|
+
/** The parts open now, innermost last, each with when its clock last started. */
|
|
53
|
+
#open = [];
|
|
54
|
+
#enter(part, now) {
|
|
55
|
+
const outer = this.#open.at(-1);
|
|
56
|
+
if (outer !== void 0) this.millis[outer.part] += now - outer.since;
|
|
57
|
+
this.counts[part] += 1;
|
|
58
|
+
this.#open.push({
|
|
59
|
+
part,
|
|
60
|
+
since: now
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
#leave(now) {
|
|
64
|
+
const inner = this.#open.pop();
|
|
65
|
+
if (inner !== void 0) this.millis[inner.part] += now - inner.since;
|
|
66
|
+
const outer = this.#open.at(-1);
|
|
67
|
+
if (outer !== void 0) outer.since = now;
|
|
68
|
+
}
|
|
69
|
+
/** `effect`, its time counted to `part`, its own time only while a part inside it runs. */
|
|
70
|
+
timed(part, effect) {
|
|
71
|
+
return Effect.flatMap(Clock.currentTimeMillis, (began) => {
|
|
72
|
+
this.#enter(part, began);
|
|
73
|
+
return effect.pipe(Effect.ensuring(Effect.map(Clock.currentTimeMillis, (now) => this.#leave(now))));
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* `effect`, its whole wall time counted to `part`, apart from any other part: for work that runs
|
|
78
|
+
* beside another, as a pack's index beside its sink's completion.
|
|
79
|
+
*/
|
|
80
|
+
apart(part, effect) {
|
|
81
|
+
return Effect.flatMap(Clock.currentTimeMillis, (began) => {
|
|
82
|
+
this.counts[part] += 1;
|
|
83
|
+
return effect.pipe(Effect.ensuring(Effect.map(Clock.currentTimeMillis, (now) => {
|
|
84
|
+
this.millis[part] += now - began;
|
|
85
|
+
})));
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
export { PackParts, packParts };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { oidBytes, refuse, sealed } from "./idx.mjs";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
// src/protocol/packs/pos.ts
|
|
4
|
+
/**
|
|
5
|
+
* A pack's positions, `.pos`: for each object its `.idx` ranks by ID, its entry's place in the
|
|
6
|
+
* pack's order, so an ID goes to its position by its rank. The inverse of its `.rev`. ref0's own
|
|
7
|
+
* format, beside Git's two. Big-endian:
|
|
8
|
+
*
|
|
9
|
+
* - `R0PS`, then version 1;
|
|
10
|
+
* - its object count;
|
|
11
|
+
* - for each rank, in rank order, its entry's position in the pack's order, 4 bytes;
|
|
12
|
+
* - the pack's own trailer, then the SHA-1 of every byte before it.
|
|
13
|
+
*
|
|
14
|
+
* It's read by range: its header once, then the positions of the ranks a reader needs.
|
|
15
|
+
*/
|
|
16
|
+
const magic = [
|
|
17
|
+
82,
|
|
18
|
+
48,
|
|
19
|
+
80,
|
|
20
|
+
83
|
|
21
|
+
];
|
|
22
|
+
const trailerBytes = 40;
|
|
23
|
+
/** How many bytes a `.pos` of `objects` takes. */
|
|
24
|
+
const packPositionsBytes = (objects) => 12 + objects * 4 + trailerBytes;
|
|
25
|
+
/** Where rank `rank`'s position is in a `.pos`. */
|
|
26
|
+
const positionAt = (rank) => 12 + rank * 4;
|
|
27
|
+
/**
|
|
28
|
+
* The `.pos` of a pack whose entries, in its order, are the ranks `ranks` name: `ranks[at]` is the
|
|
29
|
+
* rank of the pack's `at`th entry, as its `.rev` holds them.
|
|
30
|
+
*/
|
|
31
|
+
const writePositions = (ranks, packChecksum) => {
|
|
32
|
+
const bytes = new Uint8Array(packPositionsBytes(ranks.length));
|
|
33
|
+
const view = new DataView(bytes.buffer);
|
|
34
|
+
bytes.set(magic);
|
|
35
|
+
view.setUint32(4, 1);
|
|
36
|
+
view.setUint32(8, ranks.length);
|
|
37
|
+
for (const [at, rank] of ranks.entries()) view.setUint32(positionAt(rank), at);
|
|
38
|
+
bytes.set(oidBytes(packChecksum), bytes.byteLength - trailerBytes);
|
|
39
|
+
return sealed(bytes);
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* A `.pos`'s header read, its object count checked against the pack's `.idx`: its magic, its
|
|
43
|
+
* version and its count. Its positions are then read by range, never whole.
|
|
44
|
+
*/
|
|
45
|
+
const checkPositionsHeader = (head, count) => Effect.gen(function* () {
|
|
46
|
+
if (head.byteLength < 12 || magic.some((byte, at) => head[at] !== byte)) return yield* refuse("header", "the positions file doesn't start as one");
|
|
47
|
+
const view = new DataView(head.buffer, head.byteOffset, head.byteLength);
|
|
48
|
+
if (view.getUint32(4) !== 1) return yield* refuse("version", `positions version ${view.getUint32(4)} isn't read`);
|
|
49
|
+
if (view.getUint32(8) !== count) return yield* refuse("length", `the positions file lists ${view.getUint32(8)}, not ${count}`);
|
|
50
|
+
});
|
|
51
|
+
export { checkPositionsHeader, packPositionsBytes, positionAt, writePositions };
|