@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,73 @@
|
|
|
1
|
+
// src/protocol/diff/diff-raw.ts
|
|
2
|
+
const statuses = /* @__PURE__ */ new Map([
|
|
3
|
+
["A", "added"],
|
|
4
|
+
["M", "modified"],
|
|
5
|
+
["D", "deleted"],
|
|
6
|
+
["R", "renamed"],
|
|
7
|
+
["C", "copied"],
|
|
8
|
+
["T", "type"]
|
|
9
|
+
]);
|
|
10
|
+
const header = /^:([0-7]{6}) ([0-7]{6}) [0-9a-f]+ [0-9a-f]+ ([AMDRCT])([0-9]{0,3})$/;
|
|
11
|
+
const count = /^(?:[0-9]+|-)$/;
|
|
12
|
+
/**
|
|
13
|
+
* The changed paths in `text`, git's output read as UTF-8, or `undefined` for text that isn't
|
|
14
|
+
* this output: a record cut short, a status git wouldn't write, or numstat records that don't
|
|
15
|
+
* match the raw ones one for one.
|
|
16
|
+
*/
|
|
17
|
+
function parseDiffRaw(text) {
|
|
18
|
+
const fields = text.split("\0");
|
|
19
|
+
const raw = [];
|
|
20
|
+
let at = 0;
|
|
21
|
+
while (at < fields.length && (fields[at] ?? "").startsWith(":")) {
|
|
22
|
+
const matched = header.exec(fields[at] ?? "");
|
|
23
|
+
if (matched === null) return void 0;
|
|
24
|
+
const [, oldMode = "", newMode = "", letter = ""] = matched;
|
|
25
|
+
const status = statuses.get(letter);
|
|
26
|
+
if (status === void 0) return void 0;
|
|
27
|
+
const paired = status === "renamed" || status === "copied";
|
|
28
|
+
const first = fields[at + 1];
|
|
29
|
+
const second = paired ? fields[at + 2] : void 0;
|
|
30
|
+
if (first === void 0 || first === "" || paired && (second === void 0 || second === "")) return;
|
|
31
|
+
raw.push(paired ? {
|
|
32
|
+
path: second ?? "",
|
|
33
|
+
from: first,
|
|
34
|
+
status,
|
|
35
|
+
oldMode,
|
|
36
|
+
newMode
|
|
37
|
+
} : {
|
|
38
|
+
path: first,
|
|
39
|
+
from: void 0,
|
|
40
|
+
status,
|
|
41
|
+
oldMode,
|
|
42
|
+
newMode
|
|
43
|
+
});
|
|
44
|
+
at += paired ? 3 : 2;
|
|
45
|
+
}
|
|
46
|
+
const entries = [];
|
|
47
|
+
for (const each of raw) {
|
|
48
|
+
const record = fields[at] ?? "";
|
|
49
|
+
const firstTab = record.indexOf(" ");
|
|
50
|
+
const secondTab = record.indexOf(" ", firstTab + 1);
|
|
51
|
+
if (firstTab < 0 || secondTab < 0) return void 0;
|
|
52
|
+
const added = record.slice(0, firstTab);
|
|
53
|
+
const deleted = record.slice(firstTab + 1, secondTab);
|
|
54
|
+
const named = record.slice(secondTab + 1);
|
|
55
|
+
if (!count.test(added) || !count.test(deleted)) return void 0;
|
|
56
|
+
const paired = each.from !== void 0;
|
|
57
|
+
const path = paired ? fields[at + 2] : named;
|
|
58
|
+
const from = paired ? fields[at + 1] : void 0;
|
|
59
|
+
if (path !== each.path || from !== each.from || paired && named !== "") return void 0;
|
|
60
|
+
const binary = added === "-" || deleted === "-";
|
|
61
|
+
entries.push({
|
|
62
|
+
...each,
|
|
63
|
+
added: binary ? void 0 : Number(added),
|
|
64
|
+
deleted: binary ? void 0 : Number(deleted),
|
|
65
|
+
binary
|
|
66
|
+
});
|
|
67
|
+
at += paired ? 3 : 1;
|
|
68
|
+
}
|
|
69
|
+
const rest = fields.slice(at);
|
|
70
|
+
if (rest.length > 1 || (rest[0] ?? "") !== "") return void 0;
|
|
71
|
+
return entries;
|
|
72
|
+
}
|
|
73
|
+
export { parseDiffRaw };
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { joinedBytes } from "../bytes/joined.mjs";
|
|
2
|
+
import { sidesOf } from "./tree-diff.mjs";
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
// src/protocol/diff/patch.ts
|
|
5
|
+
const empty = /* @__PURE__ */ new Uint8Array();
|
|
6
|
+
/**
|
|
7
|
+
* A record's hunks as `git diff` writes them: none for a binary file, or where both sides hold
|
|
8
|
+
* the same content, as a rename or a mode change can. A type change is a deletion and then a
|
|
9
|
+
* creation, two patches Git writes one after the other, so its hunks are the old side's removed
|
|
10
|
+
* and then the new side's added.
|
|
11
|
+
*/
|
|
12
|
+
const patchOf = (reader, patcher, record) => Effect.gen(function* () {
|
|
13
|
+
const sides = yield* sidesOf(reader, record);
|
|
14
|
+
if (sides === "binary") return sides;
|
|
15
|
+
const { one, two } = sides;
|
|
16
|
+
if (record.status !== "T") return yield* patcher(one, two);
|
|
17
|
+
const removed = yield* patcher(one, empty);
|
|
18
|
+
const added = yield* patcher(empty, two);
|
|
19
|
+
return joinedBytes([removed, added]);
|
|
20
|
+
});
|
|
21
|
+
/** Whether `path` is one of `scopes` or under one, its parts matched by their bytes. */
|
|
22
|
+
const inScope = (path, scopes) => scopes.length === 0 || scopes.some((scope) => path.length >= scope.length && scope.every((byte, at) => path[at] === byte) && (path.length === scope.length || path[scope.length] === 47));
|
|
23
|
+
const header = /^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@ ?(.*)$/;
|
|
24
|
+
/** Each line's kind, by the prefix `git diff` writes it with. */
|
|
25
|
+
const kinds = /* @__PURE__ */ new Map([
|
|
26
|
+
[" ", "context"],
|
|
27
|
+
["+", "add"],
|
|
28
|
+
["-", "delete"]
|
|
29
|
+
]);
|
|
30
|
+
/** A side's start and count, as the header writes them: a count left out is 1. */
|
|
31
|
+
const rangeOf = (start, count) => ({
|
|
32
|
+
start: Number(start ?? "0"),
|
|
33
|
+
lines: count === void 0 ? 1 : Number(count)
|
|
34
|
+
});
|
|
35
|
+
/**
|
|
36
|
+
* A patch's hunks: each header's starts, counts and function context, then its lines without
|
|
37
|
+
* their prefixes or newlines. `` marks the line before it.
|
|
38
|
+
*/
|
|
39
|
+
const hunksOf = (text) => {
|
|
40
|
+
const hunks = [];
|
|
41
|
+
for (const line of text.split("\n")) {
|
|
42
|
+
const matched = header.exec(line);
|
|
43
|
+
if (matched !== null) {
|
|
44
|
+
const old = rangeOf(matched[1], matched[2]);
|
|
45
|
+
const now = rangeOf(matched[3], matched[4]);
|
|
46
|
+
hunks.push({
|
|
47
|
+
head: {
|
|
48
|
+
oldStart: old.start,
|
|
49
|
+
oldLines: old.lines,
|
|
50
|
+
newStart: now.start,
|
|
51
|
+
newLines: now.lines,
|
|
52
|
+
context: matched[5] ?? ""
|
|
53
|
+
},
|
|
54
|
+
lines: []
|
|
55
|
+
});
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
const current = hunks.at(-1);
|
|
59
|
+
if (current === void 0 || line === "") continue;
|
|
60
|
+
if (line.startsWith("\\")) {
|
|
61
|
+
const last = current.lines.pop();
|
|
62
|
+
if (last !== void 0) current.lines.push({
|
|
63
|
+
...last,
|
|
64
|
+
noNewline: true
|
|
65
|
+
});
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
const kind = kinds.get(line[0] ?? "");
|
|
69
|
+
if (kind !== void 0) current.lines.push({
|
|
70
|
+
kind,
|
|
71
|
+
text: line.slice(1)
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
return hunks.map((hunk) => ({
|
|
75
|
+
...hunk.head,
|
|
76
|
+
lines: hunk.lines
|
|
77
|
+
}));
|
|
78
|
+
};
|
|
79
|
+
/** A patch's added and deleted lines, as numstat counts the hunks it was written from. */
|
|
80
|
+
const countsOf = (patch) => {
|
|
81
|
+
let added = 0;
|
|
82
|
+
let deleted = 0;
|
|
83
|
+
for (let at = 0; at < patch.length; at = patch.indexOf(10, at) + 1 || patch.length) {
|
|
84
|
+
if (patch[at] === 43) added += 1;
|
|
85
|
+
if (patch[at] === 45) deleted += 1;
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
added,
|
|
89
|
+
deleted
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
export { countsOf, hunksOf, inScope, patchOf };
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
// src/protocol/diff/paths.ts
|
|
3
|
+
/**
|
|
4
|
+
* Paths inside a tree, as a call names them: `/`-separated from the tree's root, each part a
|
|
5
|
+
* name an entry may have, and the entry at one found by reading each folder on the way.
|
|
6
|
+
*/
|
|
7
|
+
const encoder = new TextEncoder();
|
|
8
|
+
/** How many bytes `keyOf` spreads into one call: far below any engine's argument limit. */
|
|
9
|
+
const keyChunk = 8192;
|
|
10
|
+
/**
|
|
11
|
+
* Decodes a name of bytes below 128 only, where UTF-8 gives each byte its own character, as
|
|
12
|
+
* `keyOf` does. Such a name holds no BOM, but `ignoreBOM` keeps one if the shortcut ever widens.
|
|
13
|
+
*/
|
|
14
|
+
const asciiDecoder = new TextDecoder("utf-8", {
|
|
15
|
+
fatal: false,
|
|
16
|
+
ignoreBOM: true
|
|
17
|
+
});
|
|
18
|
+
/**
|
|
19
|
+
* `String.fromCharCode` over an array-like of codes, as `apply` reads one: its `length` and
|
|
20
|
+
* indices, which a chunk of bytes holds, though TypeScript types `apply`'s arguments as an array.
|
|
21
|
+
*/
|
|
22
|
+
const charsOf = Function.prototype.apply.bind(String.fromCharCode);
|
|
23
|
+
/**
|
|
24
|
+
* A path's bytes as a key, one character a byte: decoded at once when every byte is below 128,
|
|
25
|
+
* else a chunk at a time however long the name. A plain loop finds the first byte past 127, and
|
|
26
|
+
* `apply` takes each chunk as it is: a callback a byte, or spreading the chunk, took five times
|
|
27
|
+
* as long on 5,000 names of 1,000 bytes.
|
|
28
|
+
*/
|
|
29
|
+
const keyOf = (bytes) => {
|
|
30
|
+
let at = 0;
|
|
31
|
+
while (at < bytes.length && (bytes[at] ?? 128) < 128) at += 1;
|
|
32
|
+
if (at === bytes.length) return asciiDecoder.decode(bytes);
|
|
33
|
+
let text = "";
|
|
34
|
+
for (let from = 0; from < bytes.length; from += keyChunk) text += charsOf(null, bytes.subarray(from, from + keyChunk));
|
|
35
|
+
return text;
|
|
36
|
+
};
|
|
37
|
+
/** A key's bytes again. */
|
|
38
|
+
const bytesOf = (key) => Uint8Array.from(key, (char) => char.charCodeAt(0));
|
|
39
|
+
/**
|
|
40
|
+
* A path's parts as bytes, a trailing `/` dropped: `undefined` for an empty path, one that starts
|
|
41
|
+
* with `/`, or one with an empty, `.` or `..` part, which no tree entry is named.
|
|
42
|
+
*/
|
|
43
|
+
const pathParts = (path) => {
|
|
44
|
+
const parts = (path.endsWith("/") ? path.slice(0, -1) : path).split("/");
|
|
45
|
+
if (parts.some((part) => part === "" || part === "." || part === "..")) return void 0;
|
|
46
|
+
return parts.map((part) => encoder.encode(part));
|
|
47
|
+
};
|
|
48
|
+
const sameBytes = (a, b) => a.length === b.length && a.every((byte, at) => byte === b[at]);
|
|
49
|
+
/** Whether an entry's mode is a folder's. */
|
|
50
|
+
const isFolder = (entry) => entry.mode === "040000";
|
|
51
|
+
/**
|
|
52
|
+
* The entry `parts` name under `tree`, a commit or a tag peeled to its tree, each folder on the
|
|
53
|
+
* way read through `reader`: `undefined` when no entry is there, or a part on the way isn't a
|
|
54
|
+
* folder.
|
|
55
|
+
*/
|
|
56
|
+
const entryAt = (reader, tree, parts) => Effect.gen(function* () {
|
|
57
|
+
let at;
|
|
58
|
+
let folder = tree;
|
|
59
|
+
for (const part of parts) {
|
|
60
|
+
if (at !== void 0 && !isFolder(at)) return void 0;
|
|
61
|
+
at = (yield* reader.treeToSearch(folder)).find((entry) => sameBytes(entry.name, part));
|
|
62
|
+
if (at === void 0) return void 0;
|
|
63
|
+
folder = at.oid;
|
|
64
|
+
}
|
|
65
|
+
return at;
|
|
66
|
+
});
|
|
67
|
+
export { bytesOf, entryAt, isFolder, keyOf, pathParts };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Allotment, GitObject, ObjectsRead } from "../../contracts/objects.mjs";
|
|
2
|
+
import { Oid } from "../../contracts/ids.mjs";
|
|
3
|
+
import "../objects/tree.mjs";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as Schema from "effect/Schema";
|
|
6
|
+
/**
|
|
7
|
+
* How a diff reads objects: through a caller's reader, every read counted, every object drained
|
|
8
|
+
* once and checked against its size and type, and every byte decoded charged to the diff's limits.
|
|
9
|
+
*/
|
|
10
|
+
/** Reads one object by its ID: `undefined` when the store doesn't hold it. */
|
|
11
|
+
export type DiffRead<E> = (oid: Oid) => Effect.Effect<GitObject | undefined, E>;
|
|
12
|
+
/**
|
|
13
|
+
* Reads objects whole, a batch at a time, each charged to `bytes` before it's kept, as
|
|
14
|
+
* `ObjectReader.objects` does: a diff's walk reads a level of trees so.
|
|
15
|
+
*/
|
|
16
|
+
export type DiffBatch<E> = (oids: readonly Oid[], bytes: Pick<Allotment, 'grow' | 'shrink'>) => Effect.Effect<ObjectsRead, E>;
|
|
17
|
+
/**
|
|
18
|
+
* The most a diff reads: objects; decoded bytes, path bytes and tree entries together; the tree
|
|
19
|
+
* entries a diff's walk decodes, in every tree it reads; and one object's size.
|
|
20
|
+
*/
|
|
21
|
+
export interface DiffLimits {
|
|
22
|
+
readonly objects: number;
|
|
23
|
+
readonly bytes: number;
|
|
24
|
+
readonly entries: number;
|
|
25
|
+
readonly fileBytes: number;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The engine's limits: 100,000 objects, 64 MiB in all, 71,000 tree entries a diff walks, and 16
|
|
29
|
+
* MiB an object. At 71,000 entries a diff's walk and rename pass held 47.0 MiB live at most on
|
|
30
|
+
* Node v26.12.0, all in one tree or split between two, 5.5 under `diffKeptMost`: a Worker's
|
|
31
|
+
* memory. At 97,800 in one tree its walk held 64.7 (Q615).
|
|
32
|
+
*/
|
|
33
|
+
export declare const defaultDiffLimits: DiffLimits;
|
|
34
|
+
declare const DiffError_base: Schema.Class<DiffError, Schema.TaggedStruct<"DiffError", {
|
|
35
|
+
readonly reason: Schema.Literals<readonly ["missing", "malformed", "unreadable", "diff-limit", "object-too-large"]>;
|
|
36
|
+
readonly oid: Schema.optionalKey<Schema.String>;
|
|
37
|
+
readonly message: Schema.String;
|
|
38
|
+
}>, import("effect/Cause").YieldableError>;
|
|
39
|
+
/**
|
|
40
|
+
* Why a diff stopped: an object `missing`, `malformed` or `unreadable`, a read or a charge past
|
|
41
|
+
* the diff's limits, `diff-limit`, or one object past its own, `object-too-large`.
|
|
42
|
+
*/
|
|
43
|
+
export declare class DiffError extends DiffError_base {}
|
|
44
|
+
/**
|
|
45
|
+
* A call's reads across its steps: each step's reader counts its objects and charges its bytes
|
|
46
|
+
* here as well as against its own limits, so a call of several steps, such as a comparison's
|
|
47
|
+
* merge base, walks and diff, reads and decodes within one budget.
|
|
48
|
+
*/
|
|
49
|
+
export declare class ReadTally {
|
|
50
|
+
#private;
|
|
51
|
+
readonly limits: DiffLimits;
|
|
52
|
+
constructor(limits: DiffLimits);
|
|
53
|
+
/** The objects the call has read. */
|
|
54
|
+
get objects(): number;
|
|
55
|
+
/** The bytes charged to the call. */
|
|
56
|
+
get bytes(): number;
|
|
57
|
+
/** One more object read: whether the call is still within its objects bound. */
|
|
58
|
+
object(): boolean;
|
|
59
|
+
/** `bytes` more charged: whether the call is still within its bytes bound. */
|
|
60
|
+
charge(bytes: number): boolean;
|
|
61
|
+
}
|
|
62
|
+
export {};
|
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
import { allotmentWithin, objectsReadMost } from "../../contracts/objects.mjs";
|
|
2
|
+
import { decodeCommit } from "../objects/commit.mjs";
|
|
3
|
+
import { emptyTree } from "../objects/object.mjs";
|
|
4
|
+
import { decodeTag } from "../objects/tag.mjs";
|
|
5
|
+
import { parseTreeBytes, treeEntriesIn } from "../objects/tree.mjs";
|
|
6
|
+
import { tryUnlessSpent } from "../../contracts/calls-spent.mjs";
|
|
7
|
+
import * as Effect from "effect/Effect";
|
|
8
|
+
import * as Schema from "effect/Schema";
|
|
9
|
+
// src/protocol/diff/read.ts
|
|
10
|
+
const mebibyte = 1048576;
|
|
11
|
+
/**
|
|
12
|
+
* The engine's limits: 100,000 objects, 64 MiB in all, 71,000 tree entries a diff walks, and 16
|
|
13
|
+
* MiB an object. At 71,000 entries a diff's walk and rename pass held 47.0 MiB live at most on
|
|
14
|
+
* Node v26.12.0, all in one tree or split between two, 5.5 under `diffKeptMost`: a Worker's
|
|
15
|
+
* memory. At 97,800 in one tree its walk held 64.7 (Q615).
|
|
16
|
+
*/
|
|
17
|
+
const defaultDiffLimits = {
|
|
18
|
+
objects: 1e5,
|
|
19
|
+
bytes: 64 * mebibyte,
|
|
20
|
+
entries: 71e3,
|
|
21
|
+
fileBytes: 16 * mebibyte
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Why a diff stopped: an object `missing`, `malformed` or `unreadable`, a read or a charge past
|
|
25
|
+
* the diff's limits, `diff-limit`, or one object past its own, `object-too-large`.
|
|
26
|
+
*/
|
|
27
|
+
var DiffError = class extends Schema.TaggedError()("DiffError", {
|
|
28
|
+
reason: Schema.Literals([
|
|
29
|
+
"missing",
|
|
30
|
+
"malformed",
|
|
31
|
+
"unreadable",
|
|
32
|
+
"diff-limit",
|
|
33
|
+
"object-too-large"
|
|
34
|
+
]),
|
|
35
|
+
oid: Schema.optionalKey(Schema.String),
|
|
36
|
+
message: Schema.String
|
|
37
|
+
}) {};
|
|
38
|
+
/** A batch's refusal of a byte past what the diff's bound has left, which `prefetch` reads as `diff-limit`. */
|
|
39
|
+
const pastBound = {
|
|
40
|
+
code: "RESOURCE_EXHAUSTED",
|
|
41
|
+
message: "The diff decodes past its bytes bound",
|
|
42
|
+
context: { reason: "diff-limit" }
|
|
43
|
+
};
|
|
44
|
+
const failed = (reason, message, oid) => Effect.fail(new DiffError(oid === void 0 ? {
|
|
45
|
+
reason,
|
|
46
|
+
message
|
|
47
|
+
} : {
|
|
48
|
+
reason,
|
|
49
|
+
oid,
|
|
50
|
+
message
|
|
51
|
+
}));
|
|
52
|
+
/**
|
|
53
|
+
* Whether `chunk` is `size` bytes over the whole of a fixed `ArrayBuffer`: no view of a pool or a
|
|
54
|
+
* larger buffer, which its stream may fill again, and no shared or resizable buffer.
|
|
55
|
+
*/
|
|
56
|
+
const ownsAll = (chunk, size) => chunk.length === size && chunk.buffer instanceof ArrayBuffer && chunk.buffer.byteLength === size && !("resizable" in chunk.buffer && chunk.buffer.resizable === true);
|
|
57
|
+
/**
|
|
58
|
+
* An object's bytes, drained from its stream at most `most` long: a size that isn't a whole
|
|
59
|
+
* number of bytes, or a stream that runs past or short of it, fails as `malformed`, and a stream
|
|
60
|
+
* that errors as `unreadable`. The stream is released either way, and cancelled when left
|
|
61
|
+
* unfinished.
|
|
62
|
+
*
|
|
63
|
+
* A stream of one chunk, the whole object over an `ArrayBuffer` of its own, is kept as it came,
|
|
64
|
+
* since a stream never writes into a chunk it has handed out (`GitObject.bytes`): a 16 MB blob
|
|
65
|
+
* isn't held twice (Q585). Any other is copied as each chunk comes, and every one when `copy` is
|
|
66
|
+
* set, as for a merge's writes, which a write keeps past the stream.
|
|
67
|
+
*/
|
|
68
|
+
const drained = (object, most, { copy = false } = {}) => {
|
|
69
|
+
if (!Number.isSafeInteger(object.size) || object.size < 0) {
|
|
70
|
+
object.bytes.cancel().catch(() => void 0);
|
|
71
|
+
return failed("malformed", `${object.type} ${object.oid} has a size of ${object.size} bytes`, object.oid);
|
|
72
|
+
}
|
|
73
|
+
if (object.size > most) {
|
|
74
|
+
object.bytes.cancel().catch(() => void 0);
|
|
75
|
+
return failed("object-too-large", `${object.type} ${object.oid} is ${object.size} bytes, past ${most}`, object.oid);
|
|
76
|
+
}
|
|
77
|
+
return Effect.acquireUseRelease(Effect.sync(() => ({
|
|
78
|
+
stream: object.bytes.getReader(),
|
|
79
|
+
done: false
|
|
80
|
+
})), (held) => Effect.gen(function* () {
|
|
81
|
+
let lone;
|
|
82
|
+
let bytes;
|
|
83
|
+
let length = 0;
|
|
84
|
+
while (length <= object.size) {
|
|
85
|
+
const next = yield* tryUnlessSpent(() => held.stream.read(), (cause) => new DiffError({
|
|
86
|
+
reason: "unreadable",
|
|
87
|
+
oid: object.oid,
|
|
88
|
+
message: `${object.type} ${object.oid} failed mid-read: ${String(cause)}`
|
|
89
|
+
}));
|
|
90
|
+
if (next.done) break;
|
|
91
|
+
if (length === 0 && !copy && ownsAll(next.value, object.size)) lone = next.value;
|
|
92
|
+
else if (lone === void 0 && length + next.value.length <= object.size) {
|
|
93
|
+
bytes ??= new Uint8Array(object.size);
|
|
94
|
+
bytes.set(next.value, length);
|
|
95
|
+
}
|
|
96
|
+
length += next.value.length;
|
|
97
|
+
}
|
|
98
|
+
held.done = length <= object.size;
|
|
99
|
+
if (length !== object.size) return yield* failed("malformed", `${object.type} ${object.oid} holds ${length} bytes, not its ${object.size}`, object.oid);
|
|
100
|
+
return lone ?? bytes ?? /* @__PURE__ */ new Uint8Array(0);
|
|
101
|
+
}), (held) => Effect.sync(() => {
|
|
102
|
+
if (!held.done) held.stream.cancel().catch(() => void 0);
|
|
103
|
+
held.stream.releaseLock();
|
|
104
|
+
}));
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* A call's reads across its steps: each step's reader counts its objects and charges its bytes
|
|
108
|
+
* here as well as against its own limits, so a call of several steps, such as a comparison's
|
|
109
|
+
* merge base, walks and diff, reads and decodes within one budget.
|
|
110
|
+
*/
|
|
111
|
+
var ReadTally = class {
|
|
112
|
+
#objects = 0;
|
|
113
|
+
#bytes = 0;
|
|
114
|
+
limits;
|
|
115
|
+
constructor(limits) {
|
|
116
|
+
this.limits = limits;
|
|
117
|
+
}
|
|
118
|
+
/** The objects the call has read. */
|
|
119
|
+
get objects() {
|
|
120
|
+
return this.#objects;
|
|
121
|
+
}
|
|
122
|
+
/** The bytes charged to the call. */
|
|
123
|
+
get bytes() {
|
|
124
|
+
return this.#bytes;
|
|
125
|
+
}
|
|
126
|
+
/** One more object read: whether the call is still within its objects bound. */
|
|
127
|
+
object() {
|
|
128
|
+
this.#objects += 1;
|
|
129
|
+
return this.#objects <= this.limits.objects;
|
|
130
|
+
}
|
|
131
|
+
/** `bytes` more charged: whether the call is still within its bytes bound. */
|
|
132
|
+
charge(bytes) {
|
|
133
|
+
this.#bytes += bytes;
|
|
134
|
+
return this.#bytes <= this.limits.bytes;
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
var DiffReader = class {
|
|
138
|
+
#objects = 0;
|
|
139
|
+
#bytes = 0;
|
|
140
|
+
#entries = 0;
|
|
141
|
+
#sizes = /* @__PURE__ */ new Map();
|
|
142
|
+
#trees = /* @__PURE__ */ new Map();
|
|
143
|
+
/** Objects `prefetch` read ahead, counted and charged, each until `rootOf` takes it. */
|
|
144
|
+
#fetched = /* @__PURE__ */ new Map();
|
|
145
|
+
read;
|
|
146
|
+
limits;
|
|
147
|
+
tally;
|
|
148
|
+
batch;
|
|
149
|
+
constructor(read, limits = defaultDiffLimits, tally, batch) {
|
|
150
|
+
this.read = read;
|
|
151
|
+
this.limits = limits;
|
|
152
|
+
this.tally = tally;
|
|
153
|
+
this.batch = batch;
|
|
154
|
+
}
|
|
155
|
+
/** The objects read so far. */
|
|
156
|
+
get objects() {
|
|
157
|
+
return this.#objects;
|
|
158
|
+
}
|
|
159
|
+
/** The bytes charged so far. */
|
|
160
|
+
get bytes() {
|
|
161
|
+
return this.#bytes;
|
|
162
|
+
}
|
|
163
|
+
/** The tree entries counted so far, in every tree read. */
|
|
164
|
+
get entries() {
|
|
165
|
+
return this.#entries;
|
|
166
|
+
}
|
|
167
|
+
/** Charges `bytes`, decoded or of a path, failing past the diff's bound or its call's. */
|
|
168
|
+
charge(bytes) {
|
|
169
|
+
this.#bytes += bytes;
|
|
170
|
+
if (this.#bytes > this.limits.bytes) return failed("diff-limit", `the diff decodes past ${this.limits.bytes} bytes`);
|
|
171
|
+
if (this.tally?.charge(bytes) === false) return failed("diff-limit", `the call decodes past ${this.tally.limits.bytes} bytes`);
|
|
172
|
+
return Effect.void;
|
|
173
|
+
}
|
|
174
|
+
/** An object, counted: a missing one fails, and so does one of another type than `type`. */
|
|
175
|
+
object(oid, type) {
|
|
176
|
+
return Effect.gen({ self: this }, function* () {
|
|
177
|
+
this.#objects += 1;
|
|
178
|
+
if (this.#objects > this.limits.objects) return yield* failed("diff-limit", `the diff reads past ${this.limits.objects} objects`);
|
|
179
|
+
if (this.tally?.object() === false) return yield* failed("diff-limit", `the call reads past ${this.tally.limits.objects} objects`);
|
|
180
|
+
const object = yield* this.read(oid);
|
|
181
|
+
if (object === void 0) return yield* failed("missing", `object ${oid} is missing`, oid);
|
|
182
|
+
this.#sizes.set(oid, object.size);
|
|
183
|
+
if (type !== void 0 && object.type !== type) {
|
|
184
|
+
object.bytes.cancel().catch(() => void 0);
|
|
185
|
+
return yield* failed("malformed", `${oid} is a ${object.type}, not a ${type}`, oid);
|
|
186
|
+
}
|
|
187
|
+
return object;
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
/** An object's bytes, of `type`, drained and charged. */
|
|
191
|
+
bytesOf(oid, type) {
|
|
192
|
+
return Effect.gen({ self: this }, function* () {
|
|
193
|
+
const object = yield* this.object(oid, type);
|
|
194
|
+
const bytes = yield* drained(object, this.limits.fileBytes);
|
|
195
|
+
yield* this.charge(bytes.length);
|
|
196
|
+
return bytes;
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
/** An object's size, read once and its stream cancelled unread. */
|
|
200
|
+
sizeOf(oid) {
|
|
201
|
+
return Effect.gen({ self: this }, function* () {
|
|
202
|
+
const kept = this.#sizes.get(oid);
|
|
203
|
+
if (kept !== void 0) return kept;
|
|
204
|
+
const object = yield* this.object(oid);
|
|
205
|
+
object.bytes.cancel().catch(() => void 0);
|
|
206
|
+
return object.size;
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Lets go of the trees kept so far: a diff's walk is done with them, and its rename pass reads
|
|
211
|
+
* none, so they'd sit beside the pass's own state, which `diffKeptMost` doesn't charge for them.
|
|
212
|
+
*/
|
|
213
|
+
forgetTrees() {
|
|
214
|
+
this.#trees.clear();
|
|
215
|
+
this.#fetched.clear();
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Reads `oids` ahead through `batch`, `objectsReadMost` at a time, for `rootOf` to take as it
|
|
219
|
+
* would have read them: each counted as an object read and charged to the diff's bytes bound,
|
|
220
|
+
* and a batch's bytes granted only while that bound has room, so the diff never holds a byte
|
|
221
|
+
* it hasn't charged. None is read twice: a tree kept, the empty tree and one read ahead before
|
|
222
|
+
* are passed over. Without `batch`, `rootOf` reads each on its own, as before.
|
|
223
|
+
*/
|
|
224
|
+
prefetch(oids) {
|
|
225
|
+
const { batch } = this;
|
|
226
|
+
if (batch === void 0) return Effect.void;
|
|
227
|
+
const asked = [...new Set(oids.filter((oid) => oid !== "4b825dc642cb6eb9a060e54bf8d69288fbee4904" && !this.#trees.has(oid) && !this.#fetched.has(oid)))];
|
|
228
|
+
if (asked.length === 0) return Effect.void;
|
|
229
|
+
return Effect.gen({ self: this }, function* () {
|
|
230
|
+
for (let at = 0; at < asked.length; at += objectsReadMost) {
|
|
231
|
+
let left = asked.slice(at, at + objectsReadMost);
|
|
232
|
+
while (left.length > 0) {
|
|
233
|
+
const read = yield* batch(left, this.#room()).pipe(Effect.catchIf((error) => error === pastBound, () => failed("diff-limit", `the diff decodes past ${this.limits.bytes} bytes`)));
|
|
234
|
+
for (const object of read.objects.values()) {
|
|
235
|
+
this.#objects += 1;
|
|
236
|
+
if (this.#objects > this.limits.objects) return yield* failed("diff-limit", `the diff reads past ${this.limits.objects} objects`);
|
|
237
|
+
if (this.tally?.object() === false) return yield* failed("diff-limit", `the call reads past ${this.tally.limits.objects} objects`);
|
|
238
|
+
this.#sizes.set(object.oid, object.bytes.length);
|
|
239
|
+
yield* this.charge(object.bytes.length);
|
|
240
|
+
this.#fetched.set(object.oid, object);
|
|
241
|
+
}
|
|
242
|
+
left = read.left;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
/** An allotment of what the diff's bytes bound has left, which a batch's bytes are charged to. */
|
|
248
|
+
#room() {
|
|
249
|
+
return allotmentWithin(this.limits.bytes - this.#bytes, pastBound);
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* A tree's entries, the empty tree's without a read, each counted and charged `entryBytes`
|
|
253
|
+
* before it's decoded, and failing `diff-limit` once the count passes `entriesMost`. A commit or
|
|
254
|
+
* a tag names the tree it peels to, as Git's `diff-tree` takes either. A tree read before, by its
|
|
255
|
+
* own ID or by the commit or tag that named it, comes back kept, not read again, but its entries
|
|
256
|
+
* are counted and charged again: a caller may make a record of each, as a diff of many folders
|
|
257
|
+
* that share one tree does for every folder.
|
|
258
|
+
*/
|
|
259
|
+
treeOf(oid, entriesMost = Infinity) {
|
|
260
|
+
return Effect.flatMap(this.rootOf(oid), (root) => this.entriesOf(root, entriesMost));
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* A tree's entries to find one name in, as `treeOf` reads them, but a kept tree counted and
|
|
264
|
+
* charged nothing more: a search holds nothing for each entry, so a call that looks up many
|
|
265
|
+
* paths in one folder pays for the folder once.
|
|
266
|
+
*/
|
|
267
|
+
treeToSearch(oid) {
|
|
268
|
+
return Effect.flatMap(this.rootOf(oid), (root) => this.entriesOf(root, Infinity, false));
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* The tree `oid` peels to, a commit or a tag read on the way: its entries if they're kept, else
|
|
272
|
+
* its bytes, read and charged but not yet counted or decoded, so a diff of two roots that peel
|
|
273
|
+
* to one tree decodes neither.
|
|
274
|
+
*/
|
|
275
|
+
rootOf(oid) {
|
|
276
|
+
return Effect.gen({ self: this }, function* () {
|
|
277
|
+
let at = oid;
|
|
278
|
+
while (at !== emptyTree) {
|
|
279
|
+
const kept = this.#trees.get(at);
|
|
280
|
+
if (kept !== void 0) {
|
|
281
|
+
this.#trees.set(oid, kept);
|
|
282
|
+
return {
|
|
283
|
+
oid: at,
|
|
284
|
+
named: oid,
|
|
285
|
+
kept
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
const fetched = this.#fetched.get(at);
|
|
289
|
+
this.#fetched.delete(at);
|
|
290
|
+
let object;
|
|
291
|
+
if (fetched === void 0) {
|
|
292
|
+
const read = yield* this.object(at);
|
|
293
|
+
const drainedBytes = yield* drained(read, this.limits.fileBytes);
|
|
294
|
+
yield* this.charge(drainedBytes.length);
|
|
295
|
+
object = {
|
|
296
|
+
type: read.type,
|
|
297
|
+
bytes: drainedBytes
|
|
298
|
+
};
|
|
299
|
+
} else object = fetched;
|
|
300
|
+
const { bytes } = object;
|
|
301
|
+
if (object.type === "tree") return {
|
|
302
|
+
oid: at,
|
|
303
|
+
named: oid,
|
|
304
|
+
bytes
|
|
305
|
+
};
|
|
306
|
+
if (object.type === "commit") at = (yield* malformedOn(at, decodeCommit(bytes))).tree;
|
|
307
|
+
else if (object.type === "tag") at = (yield* malformedOn(at, decodeTag(bytes))).object;
|
|
308
|
+
else return yield* failed("malformed", `${at} is a blob, not a tree`, at);
|
|
309
|
+
}
|
|
310
|
+
return {
|
|
311
|
+
oid: emptyTree,
|
|
312
|
+
named: oid,
|
|
313
|
+
kept: []
|
|
314
|
+
};
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* A peeled tree's entries, counted and charged as `treeOf` says, and kept by its ID and the one
|
|
319
|
+
* that named it. A kept tree is counted and charged again unless `again` is false.
|
|
320
|
+
*/
|
|
321
|
+
entriesOf(root, entriesMost = Infinity, again = true) {
|
|
322
|
+
return Effect.gen({ self: this }, function* () {
|
|
323
|
+
if (root.kept !== void 0 && !again) return root.kept;
|
|
324
|
+
const entries = root.kept === void 0 ? treeEntriesIn(root.bytes) : root.kept.length;
|
|
325
|
+
this.#entries += entries;
|
|
326
|
+
if (this.#entries > entriesMost) return yield* failed("diff-limit", `the diff decodes past ${entriesMost} tree entries, the most that fits a Worker's memory by default: a host with more can raise ReadLimits.entries`);
|
|
327
|
+
yield* this.charge(entries * 640);
|
|
328
|
+
const decoded = root.kept === void 0 ? yield* malformedOn(root.oid, parseTreeBytes(root.bytes)) : root.kept;
|
|
329
|
+
if (root.oid === "4b825dc642cb6eb9a060e54bf8d69288fbee4904") return decoded;
|
|
330
|
+
this.#trees.set(root.oid, decoded);
|
|
331
|
+
this.#trees.set(root.named, decoded);
|
|
332
|
+
return decoded;
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
};
|
|
336
|
+
/** A decoder's failure as the diff's `malformed`. */
|
|
337
|
+
const malformedOn = (oid, decoded) => Effect.mapError(decoded, (error) => new DiffError({
|
|
338
|
+
reason: "malformed",
|
|
339
|
+
oid,
|
|
340
|
+
message: `${oid}: ${error.message}`
|
|
341
|
+
}));
|
|
342
|
+
export { DiffError, DiffReader, ReadTally, defaultDiffLimits, drained };
|