@ref0/git 0.0.0-stage → 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 +88 -3
- package/README.md +0 -3
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
import { linesOf } from "../protocol/diff/text.mjs";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Schema from "effect/Schema";
|
|
4
|
+
import * as Semaphore from "effect/Semaphore";
|
|
5
|
+
// src/engine/xdiff.ts
|
|
6
|
+
/**
|
|
7
|
+
* The defaults: inputs up to 16 MiB and 200,000 lines together, in at most 64 MiB of linear
|
|
8
|
+
* memory. Inputs within the first two whose `reservation` passes the third are refused as
|
|
9
|
+
* `memory`: 200,000 lines xdiff guesses well fit, with up to 6 MiB of bytes. A Durable Object
|
|
10
|
+
* shares 128 MB with everything else it holds, so its caller sets these from what it has left.
|
|
11
|
+
*/
|
|
12
|
+
const defaultXdiffBudget = {
|
|
13
|
+
maxBytes: 16777216,
|
|
14
|
+
maxLines: 2e5,
|
|
15
|
+
memoryBytes: 67108864,
|
|
16
|
+
retainBytes: 16777216
|
|
17
|
+
};
|
|
18
|
+
/** The module's own share of linear memory: its 2 MiB stack, then its data. */
|
|
19
|
+
const fixedBytes = 4194304;
|
|
20
|
+
/** Each input byte held at most this many times: the input, the result and xdiff's records. */
|
|
21
|
+
const perByte = 3;
|
|
22
|
+
/**
|
|
23
|
+
* Each input line at most this many bytes of xdiff's records, whatever it sized for: their
|
|
24
|
+
* store, both diffs' changes and the histogram's tables. The lines it sizes for cost the rest.
|
|
25
|
+
*/
|
|
26
|
+
const perLine = 128;
|
|
27
|
+
/**
|
|
28
|
+
* Each line xdiff sizes a file's indexes for at most this many bytes: `xdl_prepare_env` sizes its
|
|
29
|
+
* classifier and record arrays from `xdl_guess_lines`, not from the lines there are. Measured: 44
|
|
30
|
+
* for 20 short lines before a 1 MB one, which guess 500,000 lines; 30 plus 44 a line where the
|
|
31
|
+
* guess is right. `content.test.ts` checks the peak stays under the reservation for both.
|
|
32
|
+
*/
|
|
33
|
+
const perSizedLine = 64;
|
|
34
|
+
/**
|
|
35
|
+
* The lines Git's diff guesses a file holds, as `xdl_prepare_env` sizes for them:
|
|
36
|
+
* `xdl_guess_lines` over the first `sample`, 20 for the histogram diff and 256 for Myers, plus 1.
|
|
37
|
+
* A line has at least one byte, so it's at most the file's length plus 2.
|
|
38
|
+
*/
|
|
39
|
+
const guessedLinesOf = (buffer, sample = 20) => {
|
|
40
|
+
let lines = 0;
|
|
41
|
+
let cursor = 0;
|
|
42
|
+
while (lines < sample && cursor < buffer.length) {
|
|
43
|
+
lines += 1;
|
|
44
|
+
const newline = buffer.indexOf(10, cursor);
|
|
45
|
+
cursor = newline === -1 ? buffer.length : newline + 1;
|
|
46
|
+
}
|
|
47
|
+
if (lines === 0 || cursor === 0) return lines + 2;
|
|
48
|
+
return Math.floor(buffer.length / Math.floor(cursor / lines)) + 2;
|
|
49
|
+
};
|
|
50
|
+
/** The lines xdiff sizes `buffer`'s indexes for: its guess, or the lines there are if more. */
|
|
51
|
+
const sizedLinesOf = (buffer, sample = 20) => Math.max(linesOf(buffer), guessedLinesOf(buffer, sample));
|
|
52
|
+
/**
|
|
53
|
+
* The lines a merge's two diffs size their indexes for, which both live until it ends: the base
|
|
54
|
+
* in each, and each side in its own.
|
|
55
|
+
*/
|
|
56
|
+
const sizedLinesOfMerge = (base, ours, theirs) => 2 * sizedLinesOf(base) + sizedLinesOf(ours) + sizedLinesOf(theirs);
|
|
57
|
+
/**
|
|
58
|
+
* The most linear memory a merge of inputs this size reaches through its two diffs: `lines` as
|
|
59
|
+
* `linesOf` counts them over the three inputs, and `sized` as `sizedLinesOfMerge` does. A conflict
|
|
60
|
+
* xdiff refines diffs its two sides' lines again, sized from the conflict's own first lines, which
|
|
61
|
+
* no count of the whole files limits short of every byte. The heap's ceiling limits that: past
|
|
62
|
+
* it, the call is refused as `memory`, and linear memory never grows past `memoryBytes`.
|
|
63
|
+
*/
|
|
64
|
+
const reservation = (bytes, lines, sized) => fixedBytes + perByte * bytes + perLine * lines + perSizedLine * sized;
|
|
65
|
+
/** Each algorithm's xpparam flags, with XDF_INDENT_HEURISTIC, which `git diff` turns on. */
|
|
66
|
+
const algorithmFlags = {
|
|
67
|
+
myers: 1 << 23,
|
|
68
|
+
histogram: 8421376
|
|
69
|
+
};
|
|
70
|
+
/** `adapter.c`'s `xm_failure`: why its last call failed. */
|
|
71
|
+
const failures = {
|
|
72
|
+
none: 0,
|
|
73
|
+
memory: 1,
|
|
74
|
+
bug: 2
|
|
75
|
+
};
|
|
76
|
+
/** The stack's size, and where its pointer starts. */
|
|
77
|
+
const stackBytes = 2097152;
|
|
78
|
+
/** xdiff's XDL_MERGE_FAVOR_UNION. */
|
|
79
|
+
const favorUnion = 3;
|
|
80
|
+
/**
|
|
81
|
+
* xdiff hit a `BUG()` or a trap no limit explains, or the module isn't `xdiff.wasm`: a defect,
|
|
82
|
+
* never a refusal.
|
|
83
|
+
*/
|
|
84
|
+
var XdiffDefect = class extends Schema.TaggedError()("XdiffDefect", { message: Schema.String }) {};
|
|
85
|
+
const defect = (message) => new XdiffDefect({ message });
|
|
86
|
+
/** Each function `adapter.c` exports, by name. */
|
|
87
|
+
const functionNames = [
|
|
88
|
+
"xm_begin",
|
|
89
|
+
"xm_alloc",
|
|
90
|
+
"xm_merge",
|
|
91
|
+
"xm_names",
|
|
92
|
+
"xm_count",
|
|
93
|
+
"xm_patch",
|
|
94
|
+
"xm_result_ptr",
|
|
95
|
+
"xm_result_len",
|
|
96
|
+
"xm_failure",
|
|
97
|
+
"xm_peak"
|
|
98
|
+
];
|
|
99
|
+
/**
|
|
100
|
+
* `module` checked to export what `adapter.c` declares, without making an instance: loading takes
|
|
101
|
+
* no linear memory, and the first call makes the instance within what it was allotted.
|
|
102
|
+
*/
|
|
103
|
+
const checkedModule = (module) => {
|
|
104
|
+
const kinds = new Map(WebAssembly.Module.exports(module).map((each) => [each.name, each.kind]));
|
|
105
|
+
if (kinds.get("memory") !== "memory" || kinds.get("__stack_pointer") !== "global") throw defect("the module isn't xdiff.wasm: no memory or stack pointer");
|
|
106
|
+
for (const name of functionNames) if (kinds.get(name) !== "function") throw defect(`the module exports no ${name}`);
|
|
107
|
+
};
|
|
108
|
+
/** The instance's exports, each checked to be what `adapter.c` declares. */
|
|
109
|
+
const exportsOf = (instance) => {
|
|
110
|
+
const { memory, __stack_pointer: stack } = instance.exports;
|
|
111
|
+
if (!(memory instanceof WebAssembly.Memory) || !(stack instanceof WebAssembly.Global)) throw defect("the module isn't xdiff.wasm: no memory or stack pointer");
|
|
112
|
+
const functions = functionNames.map((name) => {
|
|
113
|
+
const value = instance.exports[name];
|
|
114
|
+
if (!(value instanceof Function)) throw defect(`the module exports no ${name}`);
|
|
115
|
+
return [name, value];
|
|
116
|
+
});
|
|
117
|
+
return Object.fromEntries([
|
|
118
|
+
["memory", memory],
|
|
119
|
+
["__stack_pointer", stack],
|
|
120
|
+
...functions
|
|
121
|
+
]);
|
|
122
|
+
};
|
|
123
|
+
/** A merge's inputs, counted: its two diffs' sized lines, `sizedLinesOfMerge`. */
|
|
124
|
+
const mergeSizes = (base, ours, theirs) => ({
|
|
125
|
+
bytes: base.length + ours.length + theirs.length,
|
|
126
|
+
lines: linesOf(base) + linesOf(ours) + linesOf(theirs),
|
|
127
|
+
sized: sizedLinesOfMerge(base, ours, theirs)
|
|
128
|
+
});
|
|
129
|
+
/** A two-file diff's inputs, counted: its own sized lines, by the algorithm's sample. */
|
|
130
|
+
const diffSizes = (one, two, algorithm) => {
|
|
131
|
+
const sample = algorithm === "histogram" ? 20 : 256;
|
|
132
|
+
return {
|
|
133
|
+
bytes: one.length + two.length,
|
|
134
|
+
lines: linesOf(one) + linesOf(two),
|
|
135
|
+
sized: sizedLinesOf(one, sample) + sizedLinesOf(two, sample)
|
|
136
|
+
};
|
|
137
|
+
};
|
|
138
|
+
const memoryOfSizes = ({ bytes, lines, sized }) => reservation(bytes, lines, sized);
|
|
139
|
+
/** What a call came to before it ran: a refusal, or nothing when the budget admits it. */
|
|
140
|
+
const admitted = (budget, sizes) => {
|
|
141
|
+
const { bytes, lines } = sizes;
|
|
142
|
+
if (bytes > budget.maxBytes) return refused("bytes", `${bytes} bytes, past ${budget.maxBytes}`);
|
|
143
|
+
if (lines > budget.maxLines) return refused("lines", `${lines} lines, past ${budget.maxLines}`);
|
|
144
|
+
const reserved = memoryOfSizes(sizes);
|
|
145
|
+
if (reserved > budget.memoryBytes) return refused("memory", `${reserved} bytes reserved, past ${budget.memoryBytes}`);
|
|
146
|
+
};
|
|
147
|
+
/** The linear memory a call admitted takes at most, or none when its admission refuses it. */
|
|
148
|
+
const admittedMemoryOf = (budget, sizes) => admitted(budget, sizes) === void 0 ? memoryOfSizes(sizes) : void 0;
|
|
149
|
+
/** What a two-file diff came to before it ran. */
|
|
150
|
+
const admittedDiff = (budget, one, two, algorithm) => admitted(budget, diffSizes(one, two, algorithm));
|
|
151
|
+
/**
|
|
152
|
+
* One module's calls, run one at a time by `Xdiff`'s permit, each synchronous once the instance
|
|
153
|
+
* is there. A defect is thrown as an `XdiffDefect`, which `Xdiff` fails with.
|
|
154
|
+
*/
|
|
155
|
+
var Machine = class {
|
|
156
|
+
#exports;
|
|
157
|
+
/** Set when the scope closes: an instance made after it is never kept. */
|
|
158
|
+
#closed = false;
|
|
159
|
+
/** The running call's ceiling on linear memory: the budget's, or less when the caller asks. */
|
|
160
|
+
#ceiling = 0;
|
|
161
|
+
usage = {
|
|
162
|
+
peakBytes: 0,
|
|
163
|
+
memoryBytes: 0
|
|
164
|
+
};
|
|
165
|
+
module;
|
|
166
|
+
budget;
|
|
167
|
+
constructor(module, budget) {
|
|
168
|
+
this.module = module;
|
|
169
|
+
this.budget = budget;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* The instance when the effect runs, made when there's none. It's read then, not when a call is
|
|
173
|
+
* built, so a call that waited its turn never runs on one an earlier call dropped. Making it
|
|
174
|
+
* can't be interrupted, so a call interrupted meanwhile gives its allotment back only once the
|
|
175
|
+
* instance is there to count, and one made after the scope closed is dropped, not kept.
|
|
176
|
+
*/
|
|
177
|
+
instance() {
|
|
178
|
+
return Effect.suspend(() => this.current());
|
|
179
|
+
}
|
|
180
|
+
current() {
|
|
181
|
+
const kept = this.#exports;
|
|
182
|
+
if (kept !== void 0) return Effect.succeed(kept);
|
|
183
|
+
return Effect.uninterruptible(Effect.tryPromise({
|
|
184
|
+
try: async () => {
|
|
185
|
+
const made = exportsOf(await WebAssembly.instantiate(this.module, {}));
|
|
186
|
+
if (this.#closed) throw defect("xdiff's scope closed while its instance was made");
|
|
187
|
+
this.#exports = made;
|
|
188
|
+
return made;
|
|
189
|
+
},
|
|
190
|
+
catch: (cause) => cause instanceof XdiffDefect ? cause : defect(`xdiff didn't instantiate: ${String(cause)}`)
|
|
191
|
+
}));
|
|
192
|
+
}
|
|
193
|
+
/** The linear memory the instance holds now: none once it's dropped. */
|
|
194
|
+
get heldBytes() {
|
|
195
|
+
return this.#exports?.memory.buffer.byteLength ?? 0;
|
|
196
|
+
}
|
|
197
|
+
/** Drops the instance, giving its memory back. */
|
|
198
|
+
drop() {
|
|
199
|
+
this.#exports = void 0;
|
|
200
|
+
}
|
|
201
|
+
/** Drops the instance for good, as the scope closes. */
|
|
202
|
+
close() {
|
|
203
|
+
this.#closed = true;
|
|
204
|
+
this.drop();
|
|
205
|
+
}
|
|
206
|
+
/** `ceiling` within 0 and the budget's, so no call reaches past `memoryBytes`. */
|
|
207
|
+
#begin(wasm, ceiling) {
|
|
208
|
+
this.#ceiling = Math.max(0, Math.min(ceiling, this.budget.memoryBytes));
|
|
209
|
+
wasm.xm_begin(this.#ceiling);
|
|
210
|
+
}
|
|
211
|
+
count(wasm, one, two, algorithm, ceiling) {
|
|
212
|
+
try {
|
|
213
|
+
this.#begin(wasm, ceiling);
|
|
214
|
+
const out = wasm.xm_alloc(8);
|
|
215
|
+
const [a = 0, b = 0] = [one, two].map((input) => {
|
|
216
|
+
const at = wasm.xm_alloc(input.length);
|
|
217
|
+
if (at !== 0) new Uint8Array(wasm.memory.buffer, at, input.length).set(input);
|
|
218
|
+
return at;
|
|
219
|
+
});
|
|
220
|
+
if (out === 0 || a === 0 || b === 0) return this.#failed(wasm, "placing the inputs");
|
|
221
|
+
if (wasm.xm_count(a, one.length, b, two.length, algorithmFlags[algorithm], out) < 0) return this.#failed(wasm, "counting");
|
|
222
|
+
const [added = 0, deleted = 0] = new Uint32Array(wasm.memory.buffer, out, 2);
|
|
223
|
+
this.#settle(wasm, false);
|
|
224
|
+
return {
|
|
225
|
+
kind: "counted",
|
|
226
|
+
added,
|
|
227
|
+
deleted
|
|
228
|
+
};
|
|
229
|
+
} catch (cause) {
|
|
230
|
+
return this.#caught(wasm, cause, "count");
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
patch(wasm, one, two, algorithm, ceiling) {
|
|
234
|
+
try {
|
|
235
|
+
this.#begin(wasm, ceiling);
|
|
236
|
+
const [a = 0, b = 0] = [one, two].map((input) => {
|
|
237
|
+
const at = wasm.xm_alloc(input.length);
|
|
238
|
+
if (at !== 0) new Uint8Array(wasm.memory.buffer, at, input.length).set(input);
|
|
239
|
+
return at;
|
|
240
|
+
});
|
|
241
|
+
if (a === 0 || b === 0) return this.#failed(wasm, "placing the inputs");
|
|
242
|
+
if (wasm.xm_patch(a, one.length, b, two.length, algorithmFlags[algorithm]) < 0) return this.#failed(wasm, "diffing");
|
|
243
|
+
const length = wasm.xm_result_len();
|
|
244
|
+
const text = length === 0 ? /* @__PURE__ */ new Uint8Array() : new Uint8Array(wasm.memory.buffer, wasm.xm_result_ptr(), length).slice();
|
|
245
|
+
this.#settle(wasm, false);
|
|
246
|
+
return {
|
|
247
|
+
kind: "patched",
|
|
248
|
+
text
|
|
249
|
+
};
|
|
250
|
+
} catch (cause) {
|
|
251
|
+
return this.#caught(wasm, cause, "patch");
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
merge(wasm, base, ours, theirs, favor, markers, ceiling) {
|
|
255
|
+
try {
|
|
256
|
+
this.#begin(wasm, ceiling);
|
|
257
|
+
const placed = [];
|
|
258
|
+
for (const input of [
|
|
259
|
+
base,
|
|
260
|
+
ours,
|
|
261
|
+
theirs
|
|
262
|
+
]) {
|
|
263
|
+
const at = wasm.xm_alloc(input.length);
|
|
264
|
+
if (at === 0) return this.#failed(wasm, "placing the inputs");
|
|
265
|
+
new Uint8Array(wasm.memory.buffer, at, input.length).set(input);
|
|
266
|
+
placed.push(at, input.length);
|
|
267
|
+
}
|
|
268
|
+
const [b = 0, bl = 0, o = 0, ol = 0, t = 0, tl = 0] = placed;
|
|
269
|
+
if (markers !== void 0) {
|
|
270
|
+
const labels = [];
|
|
271
|
+
for (const label of [markers.ours, markers.theirs]) {
|
|
272
|
+
const text = new Uint8Array(label.length + 1);
|
|
273
|
+
text.set(label);
|
|
274
|
+
const at = wasm.xm_alloc(text.length);
|
|
275
|
+
if (at === 0) return this.#failed(wasm, "placing the labels");
|
|
276
|
+
new Uint8Array(wasm.memory.buffer, at, text.length).set(text);
|
|
277
|
+
labels.push(at);
|
|
278
|
+
}
|
|
279
|
+
const size = markers.size > 0 && markers.size < 2 ** 31 ? markers.size : 7;
|
|
280
|
+
wasm.xm_names(size, labels[0] ?? 0, labels[1] ?? 0);
|
|
281
|
+
}
|
|
282
|
+
const status = wasm.xm_merge(b, bl, o, ol, t, tl, favor === "union" ? favorUnion : 0);
|
|
283
|
+
if (status < 0) return this.#failed(wasm, "merging");
|
|
284
|
+
const answer = {
|
|
285
|
+
kind: "merged",
|
|
286
|
+
bytes: new Uint8Array(wasm.memory.buffer, wasm.xm_result_ptr(), wasm.xm_result_len()).slice(),
|
|
287
|
+
conflicts: status
|
|
288
|
+
};
|
|
289
|
+
this.#settle(wasm, false);
|
|
290
|
+
return answer;
|
|
291
|
+
} catch (cause) {
|
|
292
|
+
return this.#caught(wasm, cause, "merge");
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
/** What a call threw: the host's stack, a trap, or a defect thrown on. */
|
|
296
|
+
#caught(wasm, cause, call) {
|
|
297
|
+
if (cause instanceof RangeError) {
|
|
298
|
+
this.#settle(wasm, true);
|
|
299
|
+
return refused("stack", `the ${call} ran past the host's stack: ${cause.message}`);
|
|
300
|
+
}
|
|
301
|
+
if (!(cause instanceof WebAssembly.RuntimeError)) {
|
|
302
|
+
this.#settle(wasm, true);
|
|
303
|
+
throw cause instanceof XdiffDefect ? cause : defect(`the ${call} threw: ${String(cause)}`);
|
|
304
|
+
}
|
|
305
|
+
return this.#trapped(wasm, cause);
|
|
306
|
+
}
|
|
307
|
+
/** A call xdiff failed: the ceiling, or a defect. */
|
|
308
|
+
#failed(wasm, step) {
|
|
309
|
+
const failure = wasm.xm_failure();
|
|
310
|
+
this.#settle(wasm, true);
|
|
311
|
+
if (failure === failures.memory) return refused("memory", `an allocation reached the ${this.#ceiling}-byte ceiling ${step}`);
|
|
312
|
+
throw defect(`xdiff failed ${step}, with failure ${failure}`);
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* A trap: past the ceiling, an allocation xdiff doesn't check can fault on its NULL, and past
|
|
316
|
+
* its stack a call faults below address 0. Either way the instance goes.
|
|
317
|
+
*/
|
|
318
|
+
#trapped(wasm, cause) {
|
|
319
|
+
const failure = wasm.xm_failure();
|
|
320
|
+
const stack = wasm.__stack_pointer.value;
|
|
321
|
+
this.#settle(wasm, true);
|
|
322
|
+
if (failure === failures.memory) return refused("memory", `an allocation reached the ${this.#ceiling}-byte ceiling`);
|
|
323
|
+
if (failure === failures.none && (stack < 1024 || stack > stackBytes)) return refused("stack", "the merge ran past its 2 MiB stack");
|
|
324
|
+
throw defect(`xdiff trapped: ${cause.message}`);
|
|
325
|
+
}
|
|
326
|
+
/** Records what the call used, and drops the instance when it failed or holds too much. */
|
|
327
|
+
#settle(wasm, failed) {
|
|
328
|
+
const memoryBytes = wasm.memory.buffer.byteLength;
|
|
329
|
+
this.usage = {
|
|
330
|
+
peakBytes: wasm.xm_peak(),
|
|
331
|
+
memoryBytes
|
|
332
|
+
};
|
|
333
|
+
if (failed || memoryBytes > this.budget.retainBytes) this.drop();
|
|
334
|
+
}
|
|
335
|
+
};
|
|
336
|
+
/** A synchronous call's answer, or the defect it threw. */
|
|
337
|
+
const ran = (call) => Effect.try({
|
|
338
|
+
try: call,
|
|
339
|
+
catch: (cause) => cause instanceof XdiffDefect ? cause : defect(String(cause))
|
|
340
|
+
});
|
|
341
|
+
/**
|
|
342
|
+
* `module`, checked now, for as long as the scope lasts: the first call makes its instance, and
|
|
343
|
+
* closing the scope drops it. Calls on it wait their turn.
|
|
344
|
+
*/
|
|
345
|
+
const loadXdiff = (module, budget = defaultXdiffBudget) => Effect.gen(function* () {
|
|
346
|
+
const machine = yield* Effect.acquireRelease(Effect.sync(() => new Machine(module, budget)), (made) => Effect.sync(() => made.close()));
|
|
347
|
+
yield* Effect.try({
|
|
348
|
+
try: () => checkedModule(module),
|
|
349
|
+
catch: (cause) => cause instanceof XdiffDefect ? cause : defect(String(cause))
|
|
350
|
+
});
|
|
351
|
+
const turn = (yield* Semaphore.make(1)).withPermits(1);
|
|
352
|
+
return {
|
|
353
|
+
budget,
|
|
354
|
+
memoryOf: (one, two, algorithm) => admittedMemoryOf(budget, diffSizes(one, two, algorithm)),
|
|
355
|
+
mergeMemoryOf: (base, ours, theirs) => admittedMemoryOf(budget, mergeSizes(base, ours, theirs)),
|
|
356
|
+
usage: () => machine.usage,
|
|
357
|
+
heldBytes: () => machine.heldBytes,
|
|
358
|
+
merge: (base, ours, theirs, favor, markers, ceiling = budget.memoryBytes) => {
|
|
359
|
+
const refusal = admitted(budget, mergeSizes(base, ours, theirs));
|
|
360
|
+
if (refusal !== void 0) return Effect.succeed(refusal);
|
|
361
|
+
return turn(Effect.flatMap(machine.instance(), (wasm) => ran(() => machine.merge(wasm, base, ours, theirs, favor, markers, ceiling))));
|
|
362
|
+
},
|
|
363
|
+
count: (one, two, algorithm, ceiling = budget.memoryBytes) => {
|
|
364
|
+
const refusal = admittedDiff(budget, one, two, algorithm);
|
|
365
|
+
if (refusal !== void 0) return Effect.succeed(refusal);
|
|
366
|
+
return turn(Effect.flatMap(machine.instance(), (wasm) => ran(() => machine.count(wasm, one, two, algorithm, ceiling))));
|
|
367
|
+
},
|
|
368
|
+
patch: (one, two, algorithm, ceiling = budget.memoryBytes) => {
|
|
369
|
+
const refusal = admittedDiff(budget, one, two, algorithm);
|
|
370
|
+
if (refusal !== void 0) return Effect.succeed(refusal);
|
|
371
|
+
return turn(Effect.flatMap(machine.instance(), (wasm) => ran(() => machine.patch(wasm, one, two, algorithm, ceiling))));
|
|
372
|
+
}
|
|
373
|
+
};
|
|
374
|
+
});
|
|
375
|
+
const refused = (limit, why) => ({
|
|
376
|
+
kind: "refused",
|
|
377
|
+
limit,
|
|
378
|
+
why
|
|
379
|
+
});
|
|
380
|
+
export { XdiffDefect, defaultXdiffBudget, guessedLinesOf, loadXdiff };
|
package/dist/engine.mjs
ADDED
package/dist/extend.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { extendGit } from "./server/extension.mjs";
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { httpStatus, refusalCodeHeader } from "../contracts/result.mjs";
|
|
2
|
+
// src/http/answers.ts
|
|
3
|
+
/**
|
|
4
|
+
* Smart HTTP's answers outside the protocol's own bytes: a refusal's status and code, the
|
|
5
|
+
* challenges a 401 carries, and the headers `gitprotocol-http` asks of every answer, which no cache may keep.
|
|
6
|
+
*/
|
|
7
|
+
/** `gitprotocol-http`'s headers for a dynamic answer: never cached. */
|
|
8
|
+
const noCache = {
|
|
9
|
+
expires: "Fri, 01 Jan 1980 00:00:00 GMT",
|
|
10
|
+
pragma: "no-cache",
|
|
11
|
+
"cache-control": "no-cache, max-age=0, must-revalidate"
|
|
12
|
+
};
|
|
13
|
+
/** The two schemes a 401 offers, in the order Git's credential helpers try them. */
|
|
14
|
+
const challenges = ["Basic realm=\"Git\"", "Bearer realm=\"Git\""];
|
|
15
|
+
/** A plain-text answer, uncached, with its message on one line. */
|
|
16
|
+
const told = (status, message, headers) => {
|
|
17
|
+
const answer = new Headers(headers);
|
|
18
|
+
answer.set("content-type", "text/plain; charset=utf-8");
|
|
19
|
+
for (const [name, value] of Object.entries(noCache)) answer.set(name, value);
|
|
20
|
+
return new Response(`${message}\n`, {
|
|
21
|
+
status,
|
|
22
|
+
headers: answer
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
/** A refusal's answer: `told`'s, with `code` in `refusalCodeHeader`, as a client reads it. */
|
|
26
|
+
const refused = (status, code, message, headers) => {
|
|
27
|
+
const answer = new Headers(headers);
|
|
28
|
+
answer.set(refusalCodeHeader, code);
|
|
29
|
+
return told(status, message, answer);
|
|
30
|
+
};
|
|
31
|
+
/** A 401 that asks for `Basic`, then `Bearer`. */
|
|
32
|
+
const signIn = (message) => {
|
|
33
|
+
const headers = new Headers();
|
|
34
|
+
for (const challenge of challenges) headers.append("www-authenticate", challenge);
|
|
35
|
+
return refused(401, "UNAUTHENTICATED", message, headers);
|
|
36
|
+
};
|
|
37
|
+
/** The answer for a repo a caller can't find, whether it's missing or hidden from them. */
|
|
38
|
+
const notFound = () => refused(404, "NOT_FOUND", "Repository not found");
|
|
39
|
+
/**
|
|
40
|
+
* A refusal before any protocol bytes: a caller to sign in gets the challenges; one refused a
|
|
41
|
+
* read gets the 404 a missing repo gets, so the repo's existence stays hidden. A push's
|
|
42
|
+
* `NOT_ALLOWED` is a 403, since a repo its caller can't read is already `NOT_FOUND`.
|
|
43
|
+
*/
|
|
44
|
+
const refusal = (error, pushing = false) => {
|
|
45
|
+
if (error.code === "UNAUTHENTICATED") return signIn(error.message);
|
|
46
|
+
if (error.code === "NOT_FOUND" || error.code === "NOT_ALLOWED" && !pushing) return notFound();
|
|
47
|
+
const rateLimited = error.code === "RESOURCE_EXHAUSTED" && error.context?.reason === "rate-limited";
|
|
48
|
+
return refused(rateLimited ? 429 : httpStatus[error.code], error.code, error.message);
|
|
49
|
+
};
|
|
50
|
+
/** A 301 to `location`, as a renamed repo's old `info/refs` answers. */
|
|
51
|
+
const moved = (location) => {
|
|
52
|
+
const headers = new Headers({ location });
|
|
53
|
+
for (const [name, value] of Object.entries(noCache)) headers.set(name, value);
|
|
54
|
+
return new Response(null, {
|
|
55
|
+
status: 301,
|
|
56
|
+
headers
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
/** `info/refs`' content type for `service`. */
|
|
60
|
+
const advertisementType = (service) => `application/x-${service}-advertisement`;
|
|
61
|
+
/** A POST's own content type for `service`. */
|
|
62
|
+
const requestType = (service) => `application/x-${service}-request`;
|
|
63
|
+
/** A POST's answer's content type for `service`. */
|
|
64
|
+
const resultType = (service) => `application/x-${service}-result`;
|
|
65
|
+
/** A Git answer: `body` as `type`, uncached. */
|
|
66
|
+
const gitAnswer = (type, body) => {
|
|
67
|
+
const headers = new Headers({ "content-type": type });
|
|
68
|
+
for (const [name, value] of Object.entries(noCache)) headers.set(name, value);
|
|
69
|
+
return new Response(body, {
|
|
70
|
+
status: 200,
|
|
71
|
+
headers
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
export { advertisementType, challenges, gitAnswer, moved, notFound, refusal, requestType, resultType, signIn, told };
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { brokenRead, endedEarly, gitError, readBody } from "../store/errors.mjs";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
// src/http/bodies.ts
|
|
4
|
+
/**
|
|
5
|
+
* A request's body, as smart HTTP sends it: gzip undone, chunked or not, which `Request` already
|
|
6
|
+
* hides. A negotiation is read whole, to a limit; a push only to the end of its start, so its pack
|
|
7
|
+
* streams on, and what a refused push leaves is read away so Git sees its answer.
|
|
8
|
+
*/
|
|
9
|
+
/** The most bytes a negotiation's body holds once gzip is undone: a fetch's wants and haves. */
|
|
10
|
+
const negotiationLimit = 10485760;
|
|
11
|
+
/** The most bytes a push's start holds: its commands and push options, before the pack. */
|
|
12
|
+
const pushStartLimit = 10485760;
|
|
13
|
+
/** The most bytes read away after a push is refused, so Git reads the answer; past it, cut. */
|
|
14
|
+
const drainLimit = 104857600;
|
|
15
|
+
const notGzip = (cause) => gitError("INVALID_ARGUMENT", "The request's body isn't the gzip it says it is", { cause });
|
|
16
|
+
const encodingOf = (request) => (request.headers.get("content-encoding") ?? "").trim().toLowerCase();
|
|
17
|
+
const gzipped = (encoding) => encoding === "gzip" || encoding === "x-gzip";
|
|
18
|
+
/**
|
|
19
|
+
* What a read of `request`'s body that breaks off fails with, as `brokenRead` tells it: nothing,
|
|
20
|
+
* when the client went away, else a body that ended early, or for gzip, one that isn't gzip,
|
|
21
|
+
* since a short gzip body can't be told from a broken one.
|
|
22
|
+
*/
|
|
23
|
+
const brokenBody = (request) => (cause) => brokenRead(request, cause, gzipped(encodingOf(request)) ? notGzip(cause) : endedEarly(cause));
|
|
24
|
+
/**
|
|
25
|
+
* `request`'s body with gzip undone, as Git sends it when it's big: `Content-Encoding` names
|
|
26
|
+
* `gzip`, or nothing. An empty body is an empty stream.
|
|
27
|
+
*/
|
|
28
|
+
const plainBody = (request) => {
|
|
29
|
+
const encoding = encodingOf(request);
|
|
30
|
+
const body = request.body ?? new ReadableStream({ start: (c) => c.close() });
|
|
31
|
+
if (encoding === "" || encoding === "identity") return Effect.succeed(body);
|
|
32
|
+
if (gzipped(encoding)) return Effect.succeed(body.pipeThrough(new DecompressionStream("gzip")));
|
|
33
|
+
return Effect.fail(gitError("INVALID_ARGUMENT", `A body in '${encoding}' can't be read`, { hint: "Send it plain or in gzip" }));
|
|
34
|
+
};
|
|
35
|
+
/** Bytes kept in one buffer, which doubles as they come. */
|
|
36
|
+
var Grown = class {
|
|
37
|
+
bytes = /* @__PURE__ */ new Uint8Array(4096);
|
|
38
|
+
length = 0;
|
|
39
|
+
add(chunk) {
|
|
40
|
+
if (this.length + chunk.length > this.bytes.length) {
|
|
41
|
+
const grown = new Uint8Array(Math.max(this.bytes.length * 2, this.length + chunk.length));
|
|
42
|
+
grown.set(this.bytes.subarray(0, this.length));
|
|
43
|
+
this.bytes = grown;
|
|
44
|
+
}
|
|
45
|
+
this.bytes.set(chunk, this.length);
|
|
46
|
+
this.length += chunk.length;
|
|
47
|
+
}
|
|
48
|
+
view() {
|
|
49
|
+
return this.bytes.subarray(0, this.length);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
const readChunk = (reader, broken) => readBody(() => reader.read(), broken);
|
|
53
|
+
const tooBig = (what, limit) => gitError("RESOURCE_EXHAUSTED", `${what} holds at most ${limit} bytes`, { context: { reason: "too-large" } });
|
|
54
|
+
/** A negotiation's whole body, refused past `limit` bytes; a read that breaks off is `broken`. */
|
|
55
|
+
const readWhole = (body, limit, broken) => Effect.gen(function* () {
|
|
56
|
+
const reader = body.getReader();
|
|
57
|
+
const read = new Grown();
|
|
58
|
+
for (;;) {
|
|
59
|
+
const chunk = yield* readChunk(reader, broken);
|
|
60
|
+
if (chunk.done) return read.view();
|
|
61
|
+
read.add(chunk.value);
|
|
62
|
+
if (read.length > limit) {
|
|
63
|
+
yield* Effect.promise(() => reader.cancel());
|
|
64
|
+
return yield* Effect.fail(tooBig("A request's body", limit));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
/**
|
|
69
|
+
* Reads `body` until `take` reads its start from the bytes so far, refusing a start that ends past
|
|
70
|
+
* `limit` bytes. `take` gives `undefined` while it needs more, and the start and where it ends once
|
|
71
|
+
* it has it. It's asked again only once the bytes have doubled, or the body ended or passed
|
|
72
|
+
* `limit`, so a start sent in many small chunks is read a bounded number of times. The bytes past
|
|
73
|
+
* the start go first in `rest`. A read that breaks off before the start is `broken`.
|
|
74
|
+
*/
|
|
75
|
+
const readStart = (body, limit, take, broken) => Effect.gen(function* () {
|
|
76
|
+
const reader = body.getReader();
|
|
77
|
+
const read = new Grown();
|
|
78
|
+
let ended = false;
|
|
79
|
+
let asked = 0;
|
|
80
|
+
for (;;) {
|
|
81
|
+
const due = ended || read.length > limit || read.length >= asked * 2;
|
|
82
|
+
const taken = due ? yield* take(read.view(), ended) : void 0;
|
|
83
|
+
if (due) asked = read.length;
|
|
84
|
+
if (taken !== void 0 && taken.end > limit) {
|
|
85
|
+
yield* Effect.promise(() => reader.cancel());
|
|
86
|
+
return yield* Effect.fail(tooBig("A push's start", limit));
|
|
87
|
+
}
|
|
88
|
+
if (taken !== void 0) {
|
|
89
|
+
const left = read.view().slice(taken.end);
|
|
90
|
+
return {
|
|
91
|
+
start: taken.start,
|
|
92
|
+
rest: restOf(reader, left),
|
|
93
|
+
drain: drainOf(reader)
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
if (ended) return yield* Effect.fail(endedEarly());
|
|
97
|
+
if (read.length > limit) {
|
|
98
|
+
yield* Effect.promise(() => reader.cancel());
|
|
99
|
+
return yield* Effect.fail(tooBig("A push's start", limit));
|
|
100
|
+
}
|
|
101
|
+
const chunk = yield* readChunk(reader, broken);
|
|
102
|
+
if (chunk.done) ended = true;
|
|
103
|
+
else read.add(chunk.value);
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
/**
|
|
107
|
+
* The stream after a start: `left` first, then whatever `reader` reads, only as it's pulled.
|
|
108
|
+
* Cancelling it leaves `reader` as it is, for the drain.
|
|
109
|
+
*/
|
|
110
|
+
const restOf = (reader, left) => {
|
|
111
|
+
let first = left.length > 0 ? left : void 0;
|
|
112
|
+
return new ReadableStream({
|
|
113
|
+
pull: async (controller) => {
|
|
114
|
+
if (first !== void 0) {
|
|
115
|
+
controller.enqueue(first);
|
|
116
|
+
first = void 0;
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const chunk = await reader.read();
|
|
120
|
+
if (chunk.done) controller.close();
|
|
121
|
+
else controller.enqueue(chunk.value);
|
|
122
|
+
},
|
|
123
|
+
cancel: () => void 0
|
|
124
|
+
}, { highWaterMark: 0 });
|
|
125
|
+
};
|
|
126
|
+
const drainOf = (reader) => (limit) => Effect.promise(async (signal) => {
|
|
127
|
+
const cut = () => {
|
|
128
|
+
reader.cancel().catch(() => void 0);
|
|
129
|
+
};
|
|
130
|
+
signal.addEventListener("abort", cut, { once: true });
|
|
131
|
+
let read = 0;
|
|
132
|
+
try {
|
|
133
|
+
while (read < limit) {
|
|
134
|
+
const chunk = await reader.read();
|
|
135
|
+
if (chunk.done) return;
|
|
136
|
+
read += chunk.value.length;
|
|
137
|
+
}
|
|
138
|
+
await reader.cancel();
|
|
139
|
+
} catch {} finally {
|
|
140
|
+
signal.removeEventListener("abort", cut);
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
export { brokenBody, drainLimit, negotiationLimit, plainBody, pushStartLimit, readStart, readWhole };
|