@ref0/git 0.0.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/LICENSE +202 -0
- package/dist/access/private-refs.d.mts +27 -0
- package/dist/access/private-refs.mjs +173 -0
- package/dist/access.d.mts +2 -0
- package/dist/access.mjs +1 -0
- package/dist/auth/access-jwt.d.mts +21 -0
- package/dist/auth/access-jwt.mjs +102 -0
- package/dist/auth/acting.mjs +15 -0
- package/dist/auth/authorize.d.mts +5 -0
- package/dist/auth/authorize.mjs +292 -0
- package/dist/auth/credentials.mjs +57 -0
- package/dist/auth/fences.d.mts +5 -0
- package/dist/auth/fences.mjs +65 -0
- package/dist/auth/grants.mjs +61 -0
- package/dist/auth/helpers.d.mts +17 -0
- package/dist/auth/helpers.mjs +25 -0
- package/dist/auth/host-function.d.mts +4 -0
- package/dist/auth/host-function.mjs +69 -0
- package/dist/auth/identify.d.mts +6 -0
- package/dist/auth/identify.mjs +97 -0
- package/dist/auth/token-rows.mjs +100 -0
- package/dist/auth/token-text.mjs +66 -0
- package/dist/auth/tokens.d.mts +10 -0
- package/dist/auth/tokens.mjs +347 -0
- package/dist/auth.d.mts +7 -0
- package/dist/auth.mjs +6 -0
- package/dist/client/answer.mjs +141 -0
- package/dist/client/client.d.mts +23 -0
- package/dist/client/client.mjs +51 -0
- package/dist/client/git-http.mjs +201 -0
- package/dist/client/helper-node.mjs +19 -0
- package/dist/client/local.mjs +160 -0
- package/dist/client/negotiate.mjs +170 -0
- package/dist/client/push-upload.mjs +53 -0
- package/dist/client/remote-helper.mjs +129 -0
- package/dist/client/remote.mjs +398 -0
- package/dist/client/run-remote-helper.d.mts +35 -0
- package/dist/client/run-remote-helper.mjs +259 -0
- package/dist/client/scrub.d.mts +18 -0
- package/dist/client/scrub.mjs +38 -0
- package/dist/client/transport.d.mts +2 -0
- package/dist/client/transport.mjs +211 -0
- package/dist/contracts/access.d.mts +87 -0
- package/dist/contracts/actors.d.mts +144 -0
- package/dist/contracts/blobs.d.mts +38 -0
- package/dist/contracts/calls-spent.d.mts +11 -0
- package/dist/contracts/calls-spent.mjs +150 -0
- package/dist/contracts/client.d.mts +90 -0
- package/dist/contracts/commits.d.mts +126 -0
- package/dist/contracts/engine.d.mts +134 -0
- package/dist/contracts/events.d.mts +276 -0
- package/dist/contracts/files.d.mts +75 -0
- package/dist/contracts/forks.d.mts +78 -0
- package/dist/contracts/grants.d.mts +60 -0
- package/dist/contracts/handlers.d.mts +10 -0
- package/dist/contracts/ids.d.mts +15 -0
- package/dist/contracts/ids.mjs +15 -0
- package/dist/contracts/lfs.d.mts +27 -0
- package/dist/contracts/merges.d.mts +33 -0
- package/dist/contracts/objects.d.mts +645 -0
- package/dist/contracts/objects.mjs +54 -0
- package/dist/contracts/operations.d.mts +133 -0
- package/dist/contracts/promises.d.mts +63 -0
- package/dist/contracts/push-uploads.d.mts +44 -0
- package/dist/contracts/queue.d.mts +401 -0
- package/dist/contracts/refs.d.mts +95 -0
- package/dist/contracts/remote.d.mts +50 -0
- package/dist/contracts/repos.d.mts +153 -0
- package/dist/contracts/result.d.mts +126 -0
- package/dist/contracts/result.mjs +34 -0
- package/dist/contracts/rules.d.mts +159 -0
- package/dist/contracts/server.d.mts +245 -0
- package/dist/contracts/services.d.mts +36 -0
- package/dist/contracts/services.mjs +13 -0
- package/dist/contracts/signin.d.mts +126 -0
- package/dist/contracts/store.d.mts +41 -0
- package/dist/contracts/sync.d.mts +210 -0
- package/dist/contracts/sync.mjs +8 -0
- package/dist/contracts/tags.d.mts +50 -0
- package/dist/contracts/tags.mjs +6 -0
- package/dist/contracts/tokens.d.mts +87 -0
- package/dist/contracts/tokens.mjs +15 -0
- package/dist/contracts/topics.d.mts +174 -0
- package/dist/contracts/trees.d.mts +84 -0
- package/dist/contracts/work.d.mts +31 -0
- package/dist/core/access.d.mts +22 -0
- package/dist/core/access.mjs +262 -0
- package/dist/core/ancestry.mjs +235 -0
- package/dist/core/clock.mjs +18 -0
- package/dist/core/events/deliver.mjs +468 -0
- package/dist/core/events/stream.d.mts +19 -0
- package/dist/core/events/stream.mjs +290 -0
- package/dist/core/forks.mjs +1027 -0
- package/dist/core/hooks/post-receive.mjs +204 -0
- package/dist/core/hooks/pre-receive.d.mts +5 -0
- package/dist/core/hooks/pre-receive.mjs +34 -0
- package/dist/core/index-job.mjs +198 -0
- package/dist/core/names.mjs +30 -0
- package/dist/core/objects/blobs.mjs +60 -0
- package/dist/core/objects/commit-writes.mjs +185 -0
- package/dist/core/objects/commits.mjs +172 -0
- package/dist/core/objects/files.mjs +211 -0
- package/dist/core/objects/lines.mjs +42 -0
- package/dist/core/objects/merges.mjs +83 -0
- package/dist/core/objects/peel.mjs +166 -0
- package/dist/core/objects/reading.mjs +284 -0
- package/dist/core/objects/tags.mjs +96 -0
- package/dist/core/objects/tree-edits.mjs +266 -0
- package/dist/core/objects/trees.mjs +229 -0
- package/dist/core/objects/writing.mjs +266 -0
- package/dist/core/own-writes.mjs +94 -0
- package/dist/core/promise.mjs +46 -0
- package/dist/core/publish.mjs +142 -0
- package/dist/core/push-decide.mjs +206 -0
- package/dist/core/push.mjs +1069 -0
- package/dist/core/receipts.d.mts +7 -0
- package/dist/core/receipts.mjs +234 -0
- package/dist/core/ref-conflicts.mjs +27 -0
- package/dist/core/refs.mjs +359 -0
- package/dist/core/repack.mjs +521 -0
- package/dist/core/repos.mjs +752 -0
- package/dist/core/rules/changes.mjs +57 -0
- package/dist/core/rules/check.mjs +101 -0
- package/dist/core/rules/commit-changes.mjs +216 -0
- package/dist/core/rules/context.d.mts +9 -0
- package/dist/core/rules/context.mjs +120 -0
- package/dist/core/rules/define.d.mts +5 -0
- package/dist/core/rules/define.mjs +13 -0
- package/dist/core/rules/facts.mjs +13 -0
- package/dist/core/rules/fetch.d.mts +5 -0
- package/dist/core/rules/fetch.mjs +59 -0
- package/dist/core/rules/file-globs.mjs +55 -0
- package/dist/core/rules/files.mjs +142 -0
- package/dist/core/rules/patterns.mjs +23 -0
- package/dist/core/rules/protect.d.mts +9 -0
- package/dist/core/rules/protect.mjs +116 -0
- package/dist/core/seam.d.mts +24 -0
- package/dist/core/seam.mjs +41 -0
- package/dist/core/sight.mjs +99 -0
- package/dist/core/tokens.mjs +95 -0
- package/dist/core/view.d.mts +9 -0
- package/dist/core/view.mjs +221 -0
- package/dist/core/work.mjs +92 -0
- package/dist/effect.d.mts +20 -0
- package/dist/effect.mjs +18 -0
- package/dist/engine/allotted-xdiff.d.mts +4 -0
- package/dist/engine/allotted-xdiff.mjs +80 -0
- package/dist/engine/attribute-patterns.mjs +163 -0
- package/dist/engine/attributes.mjs +226 -0
- package/dist/engine/combined.mjs +653 -0
- package/dist/engine/commits.mjs +90 -0
- package/dist/engine/content.d.mts +4 -0
- package/dist/engine/content.mjs +221 -0
- package/dist/engine/diff.mjs +49 -0
- package/dist/engine/engine.d.mts +25 -0
- package/dist/engine/engine.mjs +49 -0
- package/dist/engine/failures.d.mts +4 -0
- package/dist/engine/failures.mjs +23 -0
- package/dist/engine/line-count.mjs +23 -0
- package/dist/engine/merge-base-walk.d.mts +2 -0
- package/dist/engine/merge-base-walk.mjs +265 -0
- package/dist/engine/merge-bases.mjs +27 -0
- package/dist/engine/merge-renames.mjs +165 -0
- package/dist/engine/merge.mjs +1125 -0
- package/dist/engine/parts.d.mts +8 -0
- package/dist/engine/parts.mjs +9 -0
- package/dist/engine/reads.d.mts +5 -0
- package/dist/engine/reads.mjs +105 -0
- package/dist/engine/walk.mjs +328 -0
- package/dist/engine/xdiff/NOTICE.md +63 -0
- package/dist/engine/xdiff/compiled.d.mts +7 -0
- package/dist/engine/xdiff/compiled.mjs +9 -0
- package/dist/engine/xdiff/embedded.mjs +4 -0
- package/dist/engine/xdiff/node.d.mts +7 -0
- package/dist/engine/xdiff/node.mjs +10 -0
- package/dist/engine/xdiff/upstream/LGPL-2.1 +511 -0
- package/dist/engine/xdiff/xdiff.wasm +0 -0
- package/dist/engine/xdiff.d.mts +34 -0
- package/dist/engine/xdiff.mjs +380 -0
- package/dist/engine.d.mts +3 -0
- package/dist/engine.mjs +3 -0
- package/dist/extend.d.mts +3 -0
- package/dist/extend.mjs +1 -0
- package/dist/http/answers.mjs +74 -0
- package/dist/http/bodies.mjs +143 -0
- package/dist/http/core-parts.mjs +252 -0
- package/dist/http/fetch-depth.mjs +26 -0
- package/dist/http/handler.mjs +94 -0
- package/dist/http/node.d.mts +70 -0
- package/dist/http/node.mjs +178 -0
- package/dist/http/paths.d.mts +9 -0
- package/dist/http/paths.mjs +118 -0
- package/dist/http/push-uploads.mjs +286 -0
- package/dist/http/receive-pack.mjs +235 -0
- package/dist/http/upload-pack.mjs +229 -0
- package/dist/index.d.mts +46 -0
- package/dist/index.mjs +16 -0
- package/dist/lfs/calls.mjs +16 -0
- package/dist/lfs/locks.mjs +161 -0
- package/dist/lfs/objects.mjs +370 -0
- package/dist/lfs/pointers.mjs +141 -0
- package/dist/lfs/repo.mjs +42 -0
- package/dist/lfs/rows.mjs +108 -0
- package/dist/lfs/service.mjs +34 -0
- package/dist/lfs/upkeep.mjs +162 -0
- package/dist/lfs/wire.mjs +102 -0
- package/dist/node.d.mts +3 -0
- package/dist/node.mjs +3 -0
- package/dist/protocol/bytes/buffers.d.mts +38 -0
- package/dist/protocol/bytes/buffers.mjs +62 -0
- package/dist/protocol/bytes/crc32.d.mts +4 -0
- package/dist/protocol/bytes/crc32.mjs +14 -0
- package/dist/protocol/bytes/deflate.d.mts +78 -0
- package/dist/protocol/bytes/deflate.mjs +175 -0
- package/dist/protocol/bytes/errors.d.mts +20 -0
- package/dist/protocol/bytes/errors.mjs +19 -0
- package/dist/protocol/bytes/hex.mjs +16 -0
- package/dist/protocol/bytes/hmac-sha256.mjs +91 -0
- package/dist/protocol/bytes/inflate.d.mts +40 -0
- package/dist/protocol/bytes/inflate.mjs +109 -0
- package/dist/protocol/bytes/joined.d.mts +2 -0
- package/dist/protocol/bytes/joined.mjs +25 -0
- package/dist/protocol/bytes/sha1-hasher.d.mts +20 -0
- package/dist/protocol/bytes/sha1-hasher.mjs +72 -0
- package/dist/protocol/bytes/sha1.d.mts +35 -0
- package/dist/protocol/bytes/sha1.mjs +409 -0
- package/dist/protocol/bytes/sha256.mjs +156 -0
- package/dist/protocol/bytes/streams.mjs +11 -0
- package/dist/protocol/bytes/text.mjs +19 -0
- package/dist/protocol/diff/diff-raw.d.mts +29 -0
- package/dist/protocol/diff/diff-raw.mjs +73 -0
- package/dist/protocol/diff/patch.mjs +92 -0
- package/dist/protocol/diff/paths.mjs +67 -0
- package/dist/protocol/diff/read.d.mts +62 -0
- package/dist/protocol/diff/read.mjs +342 -0
- package/dist/protocol/diff/rename-similarity.mjs +428 -0
- package/dist/protocol/diff/text.mjs +12 -0
- package/dist/protocol/diff/tree-diff.d.mts +41 -0
- package/dist/protocol/diff/tree-diff.mjs +607 -0
- package/dist/protocol/framing/band.d.mts +10 -0
- package/dist/protocol/framing/band.mjs +16 -0
- package/dist/protocol/framing/pkt-line.d.mts +48 -0
- package/dist/protocol/framing/pkt-line.mjs +92 -0
- package/dist/protocol/objects/checked-blobs.mjs +127 -0
- package/dist/protocol/objects/commit.d.mts +25 -0
- package/dist/protocol/objects/commit.mjs +138 -0
- package/dist/protocol/objects/fsck-gitmodules.mjs +296 -0
- package/dist/protocol/objects/fsck-names.mjs +189 -0
- package/dist/protocol/objects/fsck.mjs +297 -0
- package/dist/protocol/objects/headers.mjs +109 -0
- package/dist/protocol/objects/held.mjs +56 -0
- package/dist/protocol/objects/iconv.mjs +145 -0
- package/dist/protocol/objects/ident.mjs +111 -0
- package/dist/protocol/objects/lfs-pointer.d.mts +8 -0
- package/dist/protocol/objects/lfs-pointer.mjs +63 -0
- package/dist/protocol/objects/links-raw.mjs +89 -0
- package/dist/protocol/objects/object-rules.mjs +75 -0
- package/dist/protocol/objects/object.d.mts +16 -0
- package/dist/protocol/objects/object.mjs +29 -0
- package/dist/protocol/objects/tag.d.mts +21 -0
- package/dist/protocol/objects/tag.mjs +96 -0
- package/dist/protocol/objects/tree.d.mts +43 -0
- package/dist/protocol/objects/tree.mjs +162 -0
- package/dist/protocol/objects/utf8-verify.mjs +71 -0
- package/dist/protocol/packs/delta.d.mts +57 -0
- package/dist/protocol/packs/delta.mjs +229 -0
- package/dist/protocol/packs/graph.mjs +78 -0
- package/dist/protocol/packs/idx.d.mts +54 -0
- package/dist/protocol/packs/idx.mjs +274 -0
- package/dist/protocol/packs/indexer.d.mts +167 -0
- package/dist/protocol/packs/indexer.mjs +507 -0
- package/dist/protocol/packs/parts.d.mts +40 -0
- package/dist/protocol/packs/parts.mjs +89 -0
- package/dist/protocol/packs/pos.mjs +51 -0
- package/dist/protocol/packs/reader.d.mts +180 -0
- package/dist/protocol/packs/reader.mjs +414 -0
- package/dist/protocol/packs/rev.d.mts +32 -0
- package/dist/protocol/packs/rev.mjs +99 -0
- package/dist/protocol/packs/step.d.mts +10 -0
- package/dist/protocol/packs/step.mjs +12 -0
- package/dist/protocol/packs/write-error.d.mts +12 -0
- package/dist/protocol/packs/write-error.mjs +27 -0
- package/dist/protocol/packs/writer.d.mts +157 -0
- package/dist/protocol/packs/writer.mjs +353 -0
- package/dist/protocol/wire/advertisement.d.mts +72 -0
- package/dist/protocol/wire/advertisement.mjs +161 -0
- package/dist/protocol/wire/fetch.d.mts +155 -0
- package/dist/protocol/wire/fetch.mjs +458 -0
- package/dist/protocol/wire/lines.mjs +107 -0
- package/dist/protocol/wire/push-uploads.mjs +43 -0
- package/dist/protocol/wire/receive-pack.d.mts +71 -0
- package/dist/protocol/wire/receive-pack.mjs +157 -0
- package/dist/protocol/wire/report-status.d.mts +47 -0
- package/dist/protocol/wire/report-status.mjs +119 -0
- package/dist/protocol/wire/v2.d.mts +90 -0
- package/dist/protocol/wire/v2.mjs +185 -0
- package/dist/protocol.d.mts +31 -0
- package/dist/protocol.mjs +31 -0
- package/dist/queue/advance.mjs +1036 -0
- package/dist/queue/callers.mjs +134 -0
- package/dist/queue/calls.mjs +1154 -0
- package/dist/queue/commit.mjs +85 -0
- package/dist/queue/host.d.mts +15 -0
- package/dist/queue/host.mjs +88 -0
- package/dist/queue/ids.d.mts +5 -0
- package/dist/queue/ids.mjs +21 -0
- package/dist/queue/lanes.mjs +86 -0
- package/dist/queue/limits.mjs +99 -0
- package/dist/queue/pages.mjs +76 -0
- package/dist/queue/push-option.mjs +62 -0
- package/dist/queue/rows.mjs +206 -0
- package/dist/queue/schedule.mjs +132 -0
- package/dist/queue/search.mjs +315 -0
- package/dist/queue/state.mjs +325 -0
- package/dist/queue/steps.mjs +317 -0
- package/dist/remote-helper.d.mts +3 -0
- package/dist/remote-helper.mjs +3 -0
- package/dist/rest/api.d.mts +23 -0
- package/dist/rest/api.mjs +27 -0
- package/dist/rest/blobs.d.mts +58 -0
- package/dist/rest/blobs.mjs +41 -0
- package/dist/rest/caller.d.mts +102 -0
- package/dist/rest/caller.mjs +18 -0
- package/dist/rest/client.d.mts +18 -0
- package/dist/rest/client.mjs +587 -0
- package/dist/rest/commits.d.mts +435 -0
- package/dist/rest/commits.mjs +140 -0
- package/dist/rest/errors.d.mts +44 -0
- package/dist/rest/errors.mjs +186 -0
- package/dist/rest/events.d.mts +38 -0
- package/dist/rest/events.mjs +74 -0
- package/dist/rest/files.d.mts +179 -0
- package/dist/rest/files.mjs +92 -0
- package/dist/rest/forks.d.mts +205 -0
- package/dist/rest/forks.mjs +51 -0
- package/dist/rest/handler.d.mts +17 -0
- package/dist/rest/handler.mjs +106 -0
- package/dist/rest/handlers.d.mts +8 -0
- package/dist/rest/handlers.mjs +592 -0
- package/dist/rest/listen.d.mts +24 -0
- package/dist/rest/listen.mjs +142 -0
- package/dist/rest/me.d.mts +55 -0
- package/dist/rest/me.mjs +21 -0
- package/dist/rest/merges.d.mts +90 -0
- package/dist/rest/merges.mjs +39 -0
- package/dist/rest/paths.mjs +86 -0
- package/dist/rest/queue.d.mts +486 -0
- package/dist/rest/queue.mjs +228 -0
- package/dist/rest/refs.d.mts +232 -0
- package/dist/rest/refs.mjs +86 -0
- package/dist/rest/repos.d.mts +223 -0
- package/dist/rest/repos.mjs +93 -0
- package/dist/rest/tags.d.mts +153 -0
- package/dist/rest/tags.mjs +72 -0
- package/dist/rest/tokens.d.mts +297 -0
- package/dist/rest/tokens.mjs +88 -0
- package/dist/rest/topics.d.mts +257 -0
- package/dist/rest/topics.mjs +116 -0
- package/dist/rest/trees.d.mts +158 -0
- package/dist/rest/trees.mjs +118 -0
- package/dist/rest/wire.mjs +57 -0
- package/dist/rest/work.d.mts +107 -0
- package/dist/rest/work.mjs +77 -0
- package/dist/rest.d.mts +8 -0
- package/dist/rest.mjs +5 -0
- package/dist/server/extension.d.mts +14 -0
- package/dist/server/extension.mjs +85 -0
- package/dist/server/routes.d.mts +25 -0
- package/dist/server/routes.mjs +67 -0
- package/dist/server/server.d.mts +2 -0
- package/dist/server/server.mjs +439 -0
- package/dist/signin/codes.mjs +47 -0
- package/dist/signin/context.d.mts +9 -0
- package/dist/signin/context.mjs +121 -0
- package/dist/signin/device.mjs +122 -0
- package/dist/signin/forms.mjs +157 -0
- package/dist/signin/grants.d.mts +5 -0
- package/dist/signin/grants.mjs +257 -0
- package/dist/signin/route.mjs +68 -0
- package/dist/signin/web.mjs +125 -0
- package/dist/signin/wire.d.mts +42 -0
- package/dist/signin/wire.mjs +43 -0
- package/dist/storage/allotted.mjs +102 -0
- package/dist/storage/budget.mjs +96 -0
- package/dist/storage/calls.d.mts +18 -0
- package/dist/storage/calls.mjs +273 -0
- package/dist/storage/clean-up.mjs +124 -0
- package/dist/storage/distinct-ids.mjs +39 -0
- package/dist/storage/ewah.mjs +97 -0
- package/dist/storage/fetch.d.mts +13 -0
- package/dist/storage/fetch.mjs +792 -0
- package/dist/storage/fsck.mjs +77 -0
- package/dist/storage/held-memo.mjs +188 -0
- package/dist/storage/index-bitmaps.d.mts +4 -0
- package/dist/storage/index-bitmaps.mjs +654 -0
- package/dist/storage/index-build.d.mts +15 -0
- package/dist/storage/index-build.mjs +1433 -0
- package/dist/storage/index-fetch.d.mts +9 -0
- package/dist/storage/index-fetch.mjs +756 -0
- package/dist/storage/index-files.mjs +232 -0
- package/dist/storage/index-graph.d.mts +3 -0
- package/dist/storage/index-graph.mjs +1049 -0
- package/dist/storage/index-layers.mjs +317 -0
- package/dist/storage/index-reach.mjs +216 -0
- package/dist/storage/index-remap.d.mts +8 -0
- package/dist/storage/index-remap.mjs +592 -0
- package/dist/storage/layout.mjs +69 -0
- package/dist/storage/lfs-pointers.d.mts +21 -0
- package/dist/storage/lfs-pointers.mjs +175 -0
- package/dist/storage/link-join.mjs +106 -0
- package/dist/storage/links.mjs +105 -0
- package/dist/storage/loose.d.mts +15 -0
- package/dist/storage/loose.mjs +120 -0
- package/dist/storage/memory-budget.d.mts +8 -0
- package/dist/storage/memory-budget.mjs +546 -0
- package/dist/storage/merge.mjs +416 -0
- package/dist/storage/object-rows.d.mts +6 -0
- package/dist/storage/object-rows.mjs +211 -0
- package/dist/storage/pack-order.d.mts +8 -0
- package/dist/storage/pack-order.mjs +779 -0
- package/dist/storage/pack-ranges.d.mts +5 -0
- package/dist/storage/pack-ranges.mjs +284 -0
- package/dist/storage/pack-reads.d.mts +11 -0
- package/dist/storage/pack-reads.mjs +990 -0
- package/dist/storage/pack-receive.d.mts +11 -0
- package/dist/storage/pack-receive.mjs +449 -0
- package/dist/storage/packs.d.mts +56 -0
- package/dist/storage/packs.mjs +600 -0
- package/dist/storage/prune.mjs +506 -0
- package/dist/storage/push-allotment.mjs +109 -0
- package/dist/storage/push-uploads.mjs +151 -0
- package/dist/storage/pushed-commits.mjs +136 -0
- package/dist/storage/quarantine.mjs +98 -0
- package/dist/storage/raw-ids.mjs +44 -0
- package/dist/storage/ready.d.mts +19 -0
- package/dist/storage/ready.mjs +328 -0
- package/dist/storage/receive-links.mjs +297 -0
- package/dist/storage/repack-job.mjs +48 -0
- package/dist/storage/repack.d.mts +31 -0
- package/dist/storage/repack.mjs +182 -0
- package/dist/storage/roots.mjs +42 -0
- package/dist/storage/rows.d.mts +3 -0
- package/dist/storage/rows.mjs +71 -0
- package/dist/storage/shallow.d.mts +5 -0
- package/dist/storage/shallow.mjs +128 -0
- package/dist/storage/stream-whole.mjs +236 -0
- package/dist/storage/unpack.mjs +236 -0
- package/dist/storage/visible.mjs +137 -0
- package/dist/storage/walk.d.mts +7 -0
- package/dist/storage/walk.mjs +170 -0
- package/dist/storage/wants.mjs +362 -0
- package/dist/store/call-count.d.mts +47 -0
- package/dist/store/call-count.mjs +207 -0
- package/dist/store/catalogue.d.mts +7 -0
- package/dist/store/catalogue.mjs +643 -0
- package/dist/store/crossing.mjs +66 -0
- package/dist/store/cursor-seal.d.mts +2 -0
- package/dist/store/cursor-seal.mjs +85 -0
- package/dist/store/errors.d.mts +12 -0
- package/dist/store/errors.mjs +129 -0
- package/dist/store/git-store.mjs +75 -0
- package/dist/store/list-job.mjs +35 -0
- package/dist/store/outbox.d.mts +7 -0
- package/dist/store/outbox.mjs +295 -0
- package/dist/store/queue-jobs.mjs +43 -0
- package/dist/store/random.mjs +28 -0
- package/dist/store/records.d.mts +4 -0
- package/dist/store/records.mjs +192 -0
- package/dist/store/ref-rows.d.mts +4 -0
- package/dist/store/ref-rows.mjs +30 -0
- package/dist/store/repo-record.mjs +100 -0
- package/dist/store/reservations.mjs +82 -0
- package/dist/store/scopes.mjs +170 -0
- package/dist/store/settle.mjs +63 -0
- package/dist/store/topic-jobs.mjs +62 -0
- package/dist/sync/bound.d.mts +7 -0
- package/dist/sync/bound.mjs +29 -0
- package/dist/sync/github.d.mts +12 -0
- package/dist/sync/github.mjs +297 -0
- package/dist/sync/import.d.mts +8 -0
- package/dist/sync/import.mjs +154 -0
- package/dist/sync/jobs.d.mts +9 -0
- package/dist/sync/jobs.mjs +80 -0
- package/dist/sync/mirror.d.mts +9 -0
- package/dist/sync/mirror.mjs +227 -0
- package/dist/sync/publish.d.mts +5 -0
- package/dist/sync/publish.mjs +117 -0
- package/dist/sync/records.mjs +73 -0
- package/dist/sync/smart-http.d.mts +8 -0
- package/dist/sync/smart-http.mjs +23 -0
- package/dist/sync/step.mjs +334 -0
- package/dist/sync/tries.mjs +126 -0
- package/dist/sync.d.mts +8 -0
- package/dist/sync.mjs +8 -0
- package/dist/topics/advance.mjs +554 -0
- package/dist/topics/calls.mjs +346 -0
- package/dist/topics/directory.mjs +107 -0
- package/dist/topics/host.d.mts +11 -0
- package/dist/topics/host.mjs +71 -0
- package/dist/topics/members.mjs +177 -0
- package/dist/topics/rows.mjs +99 -0
- package/dist/topics/topic.mjs +126 -0
- package/package.json +86 -5
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { allotOrFail, allotScoped, capacityOf } from "./buffers.mjs";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Schema from "effect/Schema";
|
|
4
|
+
import untyped from "pako/lib/zlib/deflate.js";
|
|
5
|
+
// src/protocol/bytes/deflate.ts
|
|
6
|
+
/**
|
|
7
|
+
* One zlib member deflated at a time, as a pack holds one per entry, at zlib's defaults: level 6,
|
|
8
|
+
* method 8, window 15, memory level 8, strategy 0, and no flush but the last. Two ways, by size:
|
|
9
|
+
*
|
|
10
|
+
* - An object up to `wholeObjectBytes` is deflated whole by `deflateWhole`, through pako 2.1.0's
|
|
11
|
+
* low-level deflater into one buffer of `deflatedMost` its length, in one synchronous call.
|
|
12
|
+
* A `CompressionStream` costs about 27 ms of waiting in workerd for each one made, written and
|
|
13
|
+
* read, whatever its size, which a pack of small objects paid an object (ref0 #3222).
|
|
14
|
+
* - A larger one is streamed by `memberDeflater`, through the runtime's
|
|
15
|
+
* `CompressionStream('deflate')`, so what the writer holds never grows with an object's size.
|
|
16
|
+
*
|
|
17
|
+
* pako is a port of plain zlib, and Node and workerd build Chromium's, so the two can write other
|
|
18
|
+
* bytes for one object. Both are zlib members any inflater reads; nothing compares compressed
|
|
19
|
+
* bytes, only what they inflate to.
|
|
20
|
+
*
|
|
21
|
+
* The stream's pieces are each awaited with a read always pending, so a stream that accepts input
|
|
22
|
+
* only as its output is read never stalls, and output the compressor hasn't given yet when a write
|
|
23
|
+
* settles is taken by the next write or the finish: the stream's own backpressure limits what it
|
|
24
|
+
* queues, which `deflaterBytes` counts. No timer is waited on, since a timer's turn costs
|
|
25
|
+
* milliseconds in workerd. Each output piece's whole buffer is held by the meter until the sink
|
|
26
|
+
* it's handed to returns.
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* The bytes one compressor keeps in the runtime's native memory, which no buffer here shows: zlib's
|
|
30
|
+
* deflate state at window 15 and memory level 8, as `deflate.c` sizes it: a 64 KiB window, a
|
|
31
|
+
* 64 KiB `prev` and a 64 KiB `head` table, and a 64 KiB pending buffer, with its state struct.
|
|
32
|
+
* An estimate, held on the meter under `deflater` while a compressor lives.
|
|
33
|
+
*/
|
|
34
|
+
const deflaterBytes = 262144;
|
|
35
|
+
/**
|
|
36
|
+
* The most bytes zlib deflates `size` bytes into at these settings, above `deflateBound`'s in
|
|
37
|
+
* `deflate.c`: bytes it can't shrink go in stored blocks of a few bytes' header each, and the
|
|
38
|
+
* member's header and Adler-32 fit in the rest.
|
|
39
|
+
*/
|
|
40
|
+
const deflatedMost = (size) => size + Math.ceil(size / 2048) + 64;
|
|
41
|
+
/**
|
|
42
|
+
* The largest object deflated whole: its body and one output buffer of `deflatedMost` its length,
|
|
43
|
+
* beside pako's state, about 768 KiB at most. Deflating 256 KiB at level 6 costs a few
|
|
44
|
+
* milliseconds of CPU, well under the stream's wait it replaces, and a call that size keeps a cut
|
|
45
|
+
* by the writer's turn or time bound within milliseconds.
|
|
46
|
+
*/
|
|
47
|
+
const wholeObjectBytes = 262144;
|
|
48
|
+
const zlib = untyped;
|
|
49
|
+
/**
|
|
50
|
+
* A compressor that failed: `compressor` for the runtime's error, and `early end` for a stream
|
|
51
|
+
* that ended before it was closed.
|
|
52
|
+
*/
|
|
53
|
+
var DeflateError = class extends Schema.TaggedError()("DeflateError", {
|
|
54
|
+
fault: Schema.Literals(["compressor", "early end"]),
|
|
55
|
+
message: Schema.String
|
|
56
|
+
}) {};
|
|
57
|
+
const compressorFailed = (cause) => new DeflateError({
|
|
58
|
+
fault: "compressor",
|
|
59
|
+
message: cause instanceof Error ? cause.message : String(cause)
|
|
60
|
+
});
|
|
61
|
+
/**
|
|
62
|
+
* A compressor for one member, its output handed to `emit` a piece at a time, each held by
|
|
63
|
+
* `meter` under `deflated` until `emit` returns. It holds `deflaterBytes` under `deflater` while
|
|
64
|
+
* it lives, so a meter that can't fit it fails before it starts, and makes at most one at a time
|
|
65
|
+
* per meter: a second made while one lives dies, since its allotment would take the first's place
|
|
66
|
+
* and its end let go of it. When its scope closes, an unfinished one is aborted, without waiting
|
|
67
|
+
* for it.
|
|
68
|
+
*/
|
|
69
|
+
const memberDeflater = (meter, emit) => Effect.gen(function* () {
|
|
70
|
+
if (meter.allotted("deflater")) return yield* Effect.die(/* @__PURE__ */ new Error("a meter allots one deflater"));
|
|
71
|
+
yield* allotScoped(meter, "deflater", deflaterBytes);
|
|
72
|
+
const stream = new CompressionStream("deflate");
|
|
73
|
+
const writer = stream.writable.getWriter();
|
|
74
|
+
const reader = stream.readable.getReader();
|
|
75
|
+
let pending;
|
|
76
|
+
let ended = false;
|
|
77
|
+
yield* Effect.addFinalizer(() => Effect.sync(() => {
|
|
78
|
+
if (ended) return;
|
|
79
|
+
pending = void 0;
|
|
80
|
+
writer.abort().catch(() => void 0);
|
|
81
|
+
reader.cancel().catch(() => void 0);
|
|
82
|
+
}));
|
|
83
|
+
const nextRead = () => {
|
|
84
|
+
pending ??= reader.read();
|
|
85
|
+
return pending;
|
|
86
|
+
};
|
|
87
|
+
/** Emits one piece the compressor gave, held while `emit` has it. */
|
|
88
|
+
const handOn = (read) => Effect.gen(function* () {
|
|
89
|
+
pending = void 0;
|
|
90
|
+
if (read.done) {
|
|
91
|
+
ended = true;
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
yield* allotOrFail(meter, "deflated", capacityOf(read.value));
|
|
95
|
+
yield* emit(read.value).pipe(Effect.ensuring(Effect.sync(() => meter.free("deflated"))));
|
|
96
|
+
});
|
|
97
|
+
/** The next piece the compressor gives, or how its stream failed. */
|
|
98
|
+
const readNext = () => nextRead().then((read) => ({
|
|
99
|
+
kind: "read",
|
|
100
|
+
read
|
|
101
|
+
}), (cause) => ({
|
|
102
|
+
kind: "failed",
|
|
103
|
+
cause
|
|
104
|
+
}));
|
|
105
|
+
/**
|
|
106
|
+
* Reads, emitting each piece, until `settled` settles, the member's end allowed only if
|
|
107
|
+
* `closing`: a read is always pending meanwhile, so a compressor that accepts input only as
|
|
108
|
+
* its output is read goes on.
|
|
109
|
+
*/
|
|
110
|
+
const readUntil = (settled, closing) => Effect.gen(function* () {
|
|
111
|
+
const marked = settled.then(() => ({ kind: "settled" }), (cause) => ({
|
|
112
|
+
kind: "failed",
|
|
113
|
+
cause
|
|
114
|
+
}));
|
|
115
|
+
for (;;) {
|
|
116
|
+
const next = yield* Effect.promise(() => ended ? marked : Promise.race([readNext(), marked]));
|
|
117
|
+
if (next.kind === "failed") return yield* Effect.fail(compressorFailed(next.cause));
|
|
118
|
+
if (next.kind === "settled") return;
|
|
119
|
+
if (next.read.done && !closing) return yield* Effect.fail(new DeflateError({
|
|
120
|
+
fault: "early end",
|
|
121
|
+
message: "the compressor ended early"
|
|
122
|
+
}));
|
|
123
|
+
yield* handOn(next.read);
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
const write = (bytes) => Effect.suspend(() => bytes.byteLength === 0 ? Effect.void : readUntil(writer.write(bytes), false));
|
|
127
|
+
return {
|
|
128
|
+
write,
|
|
129
|
+
finish: Effect.gen(function* () {
|
|
130
|
+
yield* readUntil(writer.close(), true);
|
|
131
|
+
while (!ended) {
|
|
132
|
+
const next = yield* Effect.promise(readNext);
|
|
133
|
+
if (next.kind === "failed") return yield* Effect.fail(compressorFailed(next.cause));
|
|
134
|
+
yield* handOn(next.read);
|
|
135
|
+
}
|
|
136
|
+
})
|
|
137
|
+
};
|
|
138
|
+
});
|
|
139
|
+
/** zlib's codes and settings, as `lib/zlib/constants.js` gives them. */
|
|
140
|
+
const zOk = 0;
|
|
141
|
+
const zStreamEnd = 1;
|
|
142
|
+
const zFinish = 4;
|
|
143
|
+
const zDeflated = 8;
|
|
144
|
+
/**
|
|
145
|
+
* One member of `bytes`, deflated whole into one buffer of `deflatedMost` their length and given
|
|
146
|
+
* as a view of what it wrote: a call that can't finish in it fails as `compressor`. Its caller
|
|
147
|
+
* holds `deflaterBytes` and `deflatedMost` of their length on its meter while it runs.
|
|
148
|
+
*/
|
|
149
|
+
const deflateWhole = (bytes) => Effect.suspend(() => {
|
|
150
|
+
const stream = {
|
|
151
|
+
input: bytes,
|
|
152
|
+
next_in: 0,
|
|
153
|
+
avail_in: bytes.byteLength,
|
|
154
|
+
total_in: 0,
|
|
155
|
+
output: new Uint8Array(deflatedMost(bytes.byteLength)),
|
|
156
|
+
next_out: 0,
|
|
157
|
+
avail_out: deflatedMost(bytes.byteLength),
|
|
158
|
+
total_out: 0,
|
|
159
|
+
msg: "",
|
|
160
|
+
state: null,
|
|
161
|
+
data_type: 2,
|
|
162
|
+
adler: 0
|
|
163
|
+
};
|
|
164
|
+
if (zlib.deflateInit2(stream, 6, zDeflated, 15, 8, 0) !== zOk) return Effect.fail(compressorFailed(`pako's deflater didn't start`));
|
|
165
|
+
const status = zlib.deflate(stream, zFinish);
|
|
166
|
+
const output = stream.output;
|
|
167
|
+
const written = stream.next_out;
|
|
168
|
+
const message = stream.msg;
|
|
169
|
+
zlib.deflateEnd(stream);
|
|
170
|
+
stream.input = null;
|
|
171
|
+
stream.output = null;
|
|
172
|
+
if (status !== zStreamEnd || output === null) return Effect.fail(compressorFailed(message === "" ? `zlib ${status}` : message));
|
|
173
|
+
return Effect.succeed(output.subarray(0, written));
|
|
174
|
+
});
|
|
175
|
+
export { DeflateError, deflateWhole, deflatedMost, deflaterBytes, memberDeflater, wholeObjectBytes };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as Schema from "effect/Schema";
|
|
2
|
+
declare const WireDecodeError_base: Schema.Class<WireDecodeError, Schema.TaggedStruct<"WireDecodeError", {
|
|
3
|
+
readonly what: Schema.String;
|
|
4
|
+
readonly message: Schema.String;
|
|
5
|
+
}>, import("effect/Cause").YieldableError>;
|
|
6
|
+
/**
|
|
7
|
+
* Bytes from outside that aren't what their format allows, such as a commit with no tree or a
|
|
8
|
+
* tree out of Git's order: `what` names the format, and `message` what's wrong with them.
|
|
9
|
+
*/
|
|
10
|
+
export declare class WireDecodeError extends WireDecodeError_base {}
|
|
11
|
+
declare const WireEncodeError_base: Schema.Class<WireEncodeError, Schema.TaggedStruct<"WireEncodeError", {
|
|
12
|
+
readonly what: Schema.String;
|
|
13
|
+
readonly message: Schema.String;
|
|
14
|
+
}>, import("effect/Cause").YieldableError>;
|
|
15
|
+
/**
|
|
16
|
+
* A value its format can't hold, refused before any byte is written, such as a pkt-line past
|
|
17
|
+
* 65,516 bytes or an identity holding a NUL: `what` names the format, and `message` what's wrong.
|
|
18
|
+
*/
|
|
19
|
+
export declare class WireEncodeError extends WireEncodeError_base {}
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as Schema from "effect/Schema";
|
|
2
|
+
// src/protocol/bytes/errors.ts
|
|
3
|
+
/**
|
|
4
|
+
* Bytes from outside that aren't what their format allows, such as a commit with no tree or a
|
|
5
|
+
* tree out of Git's order: `what` names the format, and `message` what's wrong with them.
|
|
6
|
+
*/
|
|
7
|
+
var WireDecodeError = class extends Schema.TaggedError()("WireDecodeError", {
|
|
8
|
+
what: Schema.String,
|
|
9
|
+
message: Schema.String
|
|
10
|
+
}) {};
|
|
11
|
+
/**
|
|
12
|
+
* A value its format can't hold, refused before any byte is written, such as a pkt-line past
|
|
13
|
+
* 65,516 bytes or an identity holding a NUL: `what` names the format, and `message` what's wrong.
|
|
14
|
+
*/
|
|
15
|
+
var WireEncodeError = class extends Schema.TaggedError()("WireEncodeError", {
|
|
16
|
+
what: Schema.String,
|
|
17
|
+
message: Schema.String
|
|
18
|
+
}) {};
|
|
19
|
+
export { WireDecodeError, WireEncodeError };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// src/protocol/bytes/hex.ts
|
|
2
|
+
/** Each byte's two hex digits. */
|
|
3
|
+
const hexPairs = Array.from({ length: 256 }, (_, byte) => byte.toString(16).padStart(2, "0"));
|
|
4
|
+
/**
|
|
5
|
+
* `bytes` as hex, its digit pairs joined into one flat string: `hexOf` where there's no `toHex`. A
|
|
6
|
+
* loop fills the pairs, since `Array.from`'s mapping took 0.7 µs an ID on Node 24, against 0.3.
|
|
7
|
+
*/
|
|
8
|
+
const joinedHexOf = (bytes) => {
|
|
9
|
+
const pairs = [];
|
|
10
|
+
for (const byte of bytes) pairs.push(hexPairs[byte] ?? "");
|
|
11
|
+
return pairs.join("");
|
|
12
|
+
};
|
|
13
|
+
const { toHex } = Uint8Array.prototype;
|
|
14
|
+
/** `bytes` as lowercase hex, one flat string: the platform's `toHex`, or `joinedHexOf`. */
|
|
15
|
+
const hexOf = toHex === void 0 ? joinedHexOf : (bytes) => toHex.call(bytes);
|
|
16
|
+
export { hexOf, joinedHexOf };
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { Sha256 } from "./sha256.mjs";
|
|
2
|
+
// src/protocol/bytes/hmac-sha256.ts
|
|
3
|
+
const platform = globalThis;
|
|
4
|
+
/** This runtime's hashes. */
|
|
5
|
+
const runtime = {
|
|
6
|
+
createHmac: platform.process?.getBuiltinModule?.("node:crypto").createHmac,
|
|
7
|
+
DigestStream: platform.crypto?.DigestStream
|
|
8
|
+
};
|
|
9
|
+
/** SHA-256's block, which RFC 2104 pads the key to. */
|
|
10
|
+
const blockBytes = 64;
|
|
11
|
+
const ipad = 54;
|
|
12
|
+
const opad = 92;
|
|
13
|
+
/** `hash`'s digest, as bytes: `Sha256` answers it as hex. */
|
|
14
|
+
const digestOf = (hash) => Uint8Array.from(hash.hex().match(/../g) ?? [], (pair) => Number.parseInt(pair, 16));
|
|
15
|
+
const subtleDigest = async (bytes) => new Uint8Array(await crypto.subtle.digest("SHA-256", bytes));
|
|
16
|
+
/** `key` as a block: a key longer than a block is hashed first, then each is padded with zeros. */
|
|
17
|
+
const keyBlock = (key) => {
|
|
18
|
+
const block = new Uint8Array(blockBytes);
|
|
19
|
+
if (key.length > blockBytes) {
|
|
20
|
+
const hash = new Sha256();
|
|
21
|
+
hash.update(key);
|
|
22
|
+
block.set(digestOf(hash));
|
|
23
|
+
} else block.set(key);
|
|
24
|
+
return block;
|
|
25
|
+
};
|
|
26
|
+
/** `block`, each byte XORed with `pad`. */
|
|
27
|
+
const padded = (block, pad) => block.map((byte) => byte ^ pad);
|
|
28
|
+
/** An `HmacSha256` through Node's `createHmac`. */
|
|
29
|
+
const nodeHmac = (createHmac, key) => {
|
|
30
|
+
const hmac = createHmac("sha256", key);
|
|
31
|
+
return {
|
|
32
|
+
update: async (bytes) => {
|
|
33
|
+
hmac.update(bytes);
|
|
34
|
+
},
|
|
35
|
+
digest: async () => Uint8Array.from(hmac.digest()),
|
|
36
|
+
abandon: () => void 0,
|
|
37
|
+
via: "createHmac"
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* An `HmacSha256` whose inner hash streams through `DigestStream`, each write awaited so that it
|
|
42
|
+
* holds none of the caller's bytes, and whose outer hash is `crypto.subtle.digest`'s.
|
|
43
|
+
*/
|
|
44
|
+
const streamedHmac = async (DigestStream, key) => {
|
|
45
|
+
const block = keyBlock(key);
|
|
46
|
+
const stream = new DigestStream("SHA-256");
|
|
47
|
+
const writer = stream.getWriter();
|
|
48
|
+
await writer.write(padded(block, ipad));
|
|
49
|
+
return {
|
|
50
|
+
update: (bytes) => writer.write(bytes),
|
|
51
|
+
digest: async () => {
|
|
52
|
+
await writer.close();
|
|
53
|
+
const inner = new Uint8Array(await stream.digest);
|
|
54
|
+
const outer = new Uint8Array(blockBytes + inner.length);
|
|
55
|
+
outer.set(padded(block, opad));
|
|
56
|
+
outer.set(inner, blockBytes);
|
|
57
|
+
return subtleDigest(outer);
|
|
58
|
+
},
|
|
59
|
+
abandon: () => {
|
|
60
|
+
stream.digest.catch(() => void 0);
|
|
61
|
+
writer.abort().catch(() => void 0);
|
|
62
|
+
},
|
|
63
|
+
via: "DigestStream"
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
/** An `HmacSha256` through `Sha256`, in JavaScript. */
|
|
67
|
+
const scriptHmac = (key) => {
|
|
68
|
+
const block = keyBlock(key);
|
|
69
|
+
const inner = new Sha256();
|
|
70
|
+
inner.update(padded(block, ipad));
|
|
71
|
+
return {
|
|
72
|
+
update: async (bytes) => inner.update(bytes),
|
|
73
|
+
digest: async () => {
|
|
74
|
+
const outer = new Sha256();
|
|
75
|
+
outer.update(padded(block, opad));
|
|
76
|
+
outer.update(digestOf(inner));
|
|
77
|
+
return digestOf(outer);
|
|
78
|
+
},
|
|
79
|
+
abandon: () => void 0,
|
|
80
|
+
via: "Sha256"
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
/** An `HmacSha256` under `key`, through the first `on` has: `createHmac`, `DigestStream`, `Sha256`. */
|
|
84
|
+
const hmacSha256On = async (on, key) => {
|
|
85
|
+
if (on.createHmac !== void 0) return nodeHmac(on.createHmac, key);
|
|
86
|
+
if (on.DigestStream !== void 0) return streamedHmac(on.DigestStream, key);
|
|
87
|
+
return scriptHmac(key);
|
|
88
|
+
};
|
|
89
|
+
/** `hmacSha256On` through this runtime's own hashes, or `Sha256` where it has none. */
|
|
90
|
+
const hmacSha256 = (key) => hmacSha256On(runtime, key);
|
|
91
|
+
export { hmacSha256, hmacSha256On };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import * as Schema from "effect/Schema";
|
|
3
|
+
import * as Scope from "effect/Scope";
|
|
4
|
+
/** The bytes an inflater keeps between calls, at most: its window, its tables and its state. */
|
|
5
|
+
export declare const inflaterBytes: number;
|
|
6
|
+
declare const InflateError_base: Schema.Class<InflateError, Schema.TaggedStruct<"InflateError", {
|
|
7
|
+
readonly fault: Schema.Literals<readonly ["zlib", "no progress", "start"]>;
|
|
8
|
+
readonly message: Schema.String;
|
|
9
|
+
}>, import("effect/Cause").YieldableError>;
|
|
10
|
+
/**
|
|
11
|
+
* A member that couldn't be inflated: `zlib` for bytes zlib refused, `no progress` for a call
|
|
12
|
+
* that neither used its input nor filled its output, and `start` for an inflater that didn't
|
|
13
|
+
* start.
|
|
14
|
+
*/
|
|
15
|
+
export declare class InflateError extends InflateError_base {}
|
|
16
|
+
/**
|
|
17
|
+
* What one call made of its input: `more` used all of it and wants the next; `full` filled the
|
|
18
|
+
* output, and the rest of the input waits for the next call; `end` reached the member's end, its
|
|
19
|
+
* checksum checked, the input after it unread. Each counts the bytes it consumed and produced.
|
|
20
|
+
*/
|
|
21
|
+
export interface Inflated {
|
|
22
|
+
readonly kind: 'more' | 'full' | 'end';
|
|
23
|
+
readonly consumed: number;
|
|
24
|
+
readonly produced: number;
|
|
25
|
+
}
|
|
26
|
+
export interface MemberInflater {
|
|
27
|
+
/**
|
|
28
|
+
* Inflates from `input` into `output` until one of them is used up or the member ends. Neither
|
|
29
|
+
* is kept after the call, so a transport buffer is never held by the inflater.
|
|
30
|
+
*/
|
|
31
|
+
readonly inflate: (input: Uint8Array, output: Uint8Array) => Effect.Effect<Inflated, InflateError>;
|
|
32
|
+
/** Ready for the next member, with a window of its own: none of the last member's history. */
|
|
33
|
+
readonly reset: Effect.Effect<void, InflateError>;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* An inflater of zlib members, one after another, `reset` between them, its window and tables let
|
|
37
|
+
* go when its scope closes.
|
|
38
|
+
*/
|
|
39
|
+
export declare const memberInflater: Effect.Effect<MemberInflater, InflateError, Scope.Scope>;
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import * as Schema from "effect/Schema";
|
|
3
|
+
import untyped from "pako/lib/zlib/inflate.js";
|
|
4
|
+
// src/protocol/bytes/inflate.ts
|
|
5
|
+
const zlib = untyped;
|
|
6
|
+
/** zlib's codes, as `lib/zlib/constants.js` gives them. */
|
|
7
|
+
const zOk = 0;
|
|
8
|
+
const zStreamEnd = 1;
|
|
9
|
+
const zBufError = -5;
|
|
10
|
+
const zNoFlush = 0;
|
|
11
|
+
/** A zlib wrapper and the largest window, 32 KiB: Git's, and the only kind a pack holds. */
|
|
12
|
+
const zlibWindowBits = 15;
|
|
13
|
+
/** The bytes an inflater keeps between calls, at most: its window, its tables and its state. */
|
|
14
|
+
const inflaterBytes = 49152;
|
|
15
|
+
/**
|
|
16
|
+
* A member that couldn't be inflated: `zlib` for bytes zlib refused, `no progress` for a call
|
|
17
|
+
* that neither used its input nor filled its output, and `start` for an inflater that didn't
|
|
18
|
+
* start.
|
|
19
|
+
*/
|
|
20
|
+
var InflateError = class extends Schema.TaggedError()("InflateError", {
|
|
21
|
+
fault: Schema.Literals([
|
|
22
|
+
"zlib",
|
|
23
|
+
"no progress",
|
|
24
|
+
"start"
|
|
25
|
+
]),
|
|
26
|
+
message: Schema.String
|
|
27
|
+
}) {};
|
|
28
|
+
const freshStream = () => ({
|
|
29
|
+
input: null,
|
|
30
|
+
next_in: 0,
|
|
31
|
+
avail_in: 0,
|
|
32
|
+
total_in: 0,
|
|
33
|
+
output: null,
|
|
34
|
+
next_out: 0,
|
|
35
|
+
avail_out: 0,
|
|
36
|
+
total_out: 0,
|
|
37
|
+
msg: "",
|
|
38
|
+
state: null,
|
|
39
|
+
data_type: 2,
|
|
40
|
+
adler: 0
|
|
41
|
+
});
|
|
42
|
+
/** zlib's state for `stream`, made afresh: its window allocated at the first output. */
|
|
43
|
+
const start = (stream) => Effect.suspend(() => zlib.inflateInit2(stream, zlibWindowBits) === zOk ? Effect.void : Effect.fail(new InflateError({
|
|
44
|
+
fault: "start",
|
|
45
|
+
message: "pako's inflater didn't start"
|
|
46
|
+
})));
|
|
47
|
+
/** One call of zlib's `inflate`, its outcome named, neither buffer kept after it. */
|
|
48
|
+
const inflateOnce = (stream, input, output) => {
|
|
49
|
+
stream.input = input;
|
|
50
|
+
stream.next_in = 0;
|
|
51
|
+
stream.avail_in = input.byteLength;
|
|
52
|
+
stream.output = output;
|
|
53
|
+
stream.next_out = 0;
|
|
54
|
+
stream.avail_out = output.byteLength;
|
|
55
|
+
const status = zlib.inflate(stream, zNoFlush);
|
|
56
|
+
const consumed = stream.next_in;
|
|
57
|
+
const produced = stream.next_out;
|
|
58
|
+
const left = stream.avail_in;
|
|
59
|
+
const room = stream.avail_out;
|
|
60
|
+
const message = stream.msg;
|
|
61
|
+
stream.input = null;
|
|
62
|
+
stream.output = null;
|
|
63
|
+
stream.avail_in = 0;
|
|
64
|
+
if (status === zStreamEnd) return Effect.succeed({
|
|
65
|
+
kind: "end",
|
|
66
|
+
consumed,
|
|
67
|
+
produced
|
|
68
|
+
});
|
|
69
|
+
if (status === zOk || status === zBufError) {
|
|
70
|
+
if (left === 0) return Effect.succeed({
|
|
71
|
+
kind: "more",
|
|
72
|
+
consumed,
|
|
73
|
+
produced
|
|
74
|
+
});
|
|
75
|
+
if (room === 0) return Effect.succeed({
|
|
76
|
+
kind: "full",
|
|
77
|
+
consumed,
|
|
78
|
+
produced
|
|
79
|
+
});
|
|
80
|
+
return Effect.fail(new InflateError({
|
|
81
|
+
fault: "no progress",
|
|
82
|
+
message: "zlib made no progress"
|
|
83
|
+
}));
|
|
84
|
+
}
|
|
85
|
+
return Effect.fail(new InflateError({
|
|
86
|
+
fault: "zlib",
|
|
87
|
+
message: message === "" ? `zlib ${status}` : message
|
|
88
|
+
}));
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* An inflater of zlib members, one after another, `reset` between them, its window and tables let
|
|
92
|
+
* go when its scope closes.
|
|
93
|
+
*/
|
|
94
|
+
const memberInflater = Effect.acquireRelease(Effect.suspend(() => {
|
|
95
|
+
const stream = freshStream();
|
|
96
|
+
return Effect.as(start(stream), stream);
|
|
97
|
+
}), (stream) => Effect.sync(() => zlib.inflateEnd(stream))).pipe(Effect.map((stream) => ({
|
|
98
|
+
inflate: (input, output) => Effect.suspend(() => inflateOnce(stream, input, output)),
|
|
99
|
+
reset: Effect.suspend(() => {
|
|
100
|
+
if (zlib.inflateReset(stream) !== zOk) return Effect.fail(new InflateError({
|
|
101
|
+
fault: "start",
|
|
102
|
+
message: "pako's inflater didn't reset"
|
|
103
|
+
}));
|
|
104
|
+
const state = stream.state;
|
|
105
|
+
if (state.window !== null) state.wsize = 1 << state.wbits;
|
|
106
|
+
return Effect.void;
|
|
107
|
+
})
|
|
108
|
+
})));
|
|
109
|
+
export { InflateError, inflaterBytes, memberInflater };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// src/protocol/bytes/joined.ts
|
|
2
|
+
/** Runs of bytes, one after another, as one, such as a request's pkt-lines or a Git object. */
|
|
3
|
+
function joinedBytes(parts) {
|
|
4
|
+
const all = new Uint8Array(parts.reduce((total, part) => total + part.byteLength, 0));
|
|
5
|
+
let at = 0;
|
|
6
|
+
for (const part of parts) {
|
|
7
|
+
all.set(part, at);
|
|
8
|
+
at += part.byteLength;
|
|
9
|
+
}
|
|
10
|
+
return all;
|
|
11
|
+
}
|
|
12
|
+
/** The first `most` bytes of runs one after another, copied only that far, such as a delta's sizes. */
|
|
13
|
+
function leadingBytes(parts, most) {
|
|
14
|
+
const total = parts.reduce((sum, part) => sum + part.byteLength, 0);
|
|
15
|
+
const head = new Uint8Array(Math.min(most, total));
|
|
16
|
+
let at = 0;
|
|
17
|
+
for (const part of parts) {
|
|
18
|
+
if (at === head.byteLength) break;
|
|
19
|
+
const taken = part.subarray(0, head.byteLength - at);
|
|
20
|
+
head.set(taken, at);
|
|
21
|
+
at += taken.byteLength;
|
|
22
|
+
}
|
|
23
|
+
return head;
|
|
24
|
+
}
|
|
25
|
+
export { joinedBytes, leadingBytes };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import "effect/Effect";
|
|
2
|
+
/** workerd's `crypto.DigestStream`: a writable stream whose `digest` settles once it's closed. */
|
|
3
|
+
interface DigestStream {
|
|
4
|
+
readonly digest: Promise<ArrayBuffer>;
|
|
5
|
+
getWriter(): {
|
|
6
|
+
write(bytes: Uint8Array): Promise<void>;
|
|
7
|
+
close(): Promise<void>;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
/** Node's `Hash`, as `createHash('sha1')` makes it. */
|
|
11
|
+
interface NodeHash {
|
|
12
|
+
update(bytes: Uint8Array): NodeHash;
|
|
13
|
+
digest(): Uint8Array;
|
|
14
|
+
}
|
|
15
|
+
/** The hashes a runtime has, each `undefined` where it has none. */
|
|
16
|
+
export interface Sha1Runtime {
|
|
17
|
+
readonly DigestStream: (new (algorithm: 'SHA-1') => DigestStream) | undefined;
|
|
18
|
+
readonly createHash: ((algorithm: 'sha1') => NodeHash) | undefined;
|
|
19
|
+
}
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Sha1 } from "./sha1.mjs";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
// src/protocol/bytes/sha1-hasher.ts
|
|
4
|
+
const platform = globalThis;
|
|
5
|
+
/** This runtime's hashes. */
|
|
6
|
+
const runtime = {
|
|
7
|
+
DigestStream: platform.crypto?.DigestStream,
|
|
8
|
+
createHash: platform.process?.getBuiltinModule?.("node:crypto").createHash
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* A `Sha1Hasher` through the first hash `on` has: `DigestStream`, whose writes are each awaited so
|
|
12
|
+
* that it holds none of the reader's bytes, then `createHash`, then `Sha1`. Its digest is read
|
|
13
|
+
* once.
|
|
14
|
+
*/
|
|
15
|
+
const sha1HasherOn = (on) => {
|
|
16
|
+
if (on.DigestStream !== void 0) {
|
|
17
|
+
const stream = new on.DigestStream("SHA-1");
|
|
18
|
+
const writer = stream.getWriter();
|
|
19
|
+
return {
|
|
20
|
+
write: (bytes) => Effect.promise(() => writer.write(bytes)),
|
|
21
|
+
digest: Effect.promise(async () => {
|
|
22
|
+
await writer.close();
|
|
23
|
+
return new Uint8Array(await stream.digest);
|
|
24
|
+
})
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
if (on.createHash !== void 0) {
|
|
28
|
+
const hash = on.createHash("sha1");
|
|
29
|
+
return {
|
|
30
|
+
write: (bytes) => Effect.sync(() => {
|
|
31
|
+
hash.update(bytes);
|
|
32
|
+
}),
|
|
33
|
+
digest: Effect.sync(() => Uint8Array.from(hash.digest()))
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
const sha = new Sha1();
|
|
37
|
+
return {
|
|
38
|
+
write: (bytes) => Effect.sync(() => sha.update(bytes)),
|
|
39
|
+
digest: Effect.sync(() => sha.digest())
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* A `Sha1Now` through `on`'s `createHash` where it has it, Node's and workerd's from compatibility
|
|
44
|
+
* date 2026-08-04 or under `nodejs_compat`, else a `Sha1`, never `DigestStream`, which only answers
|
|
45
|
+
* a promise. For an object small enough that a promise per object costs more than its hash: on
|
|
46
|
+
* Node, a walk over svelte's 120-commit range read through `crypto.subtle.digest` took a median
|
|
47
|
+
* 1,153 ms of CPU, against 702 ms hashed so (#559). Node's hashed svelte's object sizes at 1,120 to
|
|
48
|
+
* 1,171 MB/s, `Sha1` at 468 to 483 (#730).
|
|
49
|
+
*/
|
|
50
|
+
const sha1NowHasherOn = (on) => {
|
|
51
|
+
if (on.createHash === void 0) return new Sha1();
|
|
52
|
+
const hash = on.createHash("sha1");
|
|
53
|
+
return {
|
|
54
|
+
update: (bytes) => {
|
|
55
|
+
hash.update(bytes);
|
|
56
|
+
},
|
|
57
|
+
digest: () => Uint8Array.from(hash.digest())
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
/** The SHA-1 of `parts`, one after another, at once, through `sha1NowHasherOn`. */
|
|
61
|
+
const sha1NowOn = (on, parts) => {
|
|
62
|
+
const hash = sha1NowHasherOn(on);
|
|
63
|
+
for (const part of parts) hash.update(part);
|
|
64
|
+
return hash.digest();
|
|
65
|
+
};
|
|
66
|
+
/** `sha1NowOn` through this runtime's own hash. */
|
|
67
|
+
const sha1Now = (parts) => sha1NowOn(runtime, parts);
|
|
68
|
+
/** `sha1NowHasherOn` through this runtime's own hash, or a `Sha1` where it has none. */
|
|
69
|
+
const sha1NowHasher = () => sha1NowHasherOn(runtime);
|
|
70
|
+
/** A `Sha1Hasher` through this runtime's own hash, or `Sha1` where it has none. */
|
|
71
|
+
const nativeSha1Hasher = () => sha1HasherOn(runtime);
|
|
72
|
+
export { nativeSha1Hasher, sha1HasherOn, sha1Now, sha1NowHasher, sha1NowHasherOn, sha1NowOn };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import * as Schema from "effect/Schema";
|
|
3
|
+
/**
|
|
4
|
+
* A SHA-1's state between writes: its five words, the bytes it took, and the bytes past its last
|
|
5
|
+
* whole 64-byte block, as lowercase hex, as many as `length` leaves past a block. Decode stored state through it, so a damaged one fails by
|
|
6
|
+
* name before a `Sha1` goes on from it.
|
|
7
|
+
*/
|
|
8
|
+
export declare const Sha1State: Schema.Struct<{
|
|
9
|
+
readonly words: Schema.Tuple<readonly [Schema.Number, Schema.Number, Schema.Number, Schema.Number, Schema.Number]>;
|
|
10
|
+
readonly length: Schema.Int;
|
|
11
|
+
readonly pending: Schema.String;
|
|
12
|
+
}>;
|
|
13
|
+
export type Sha1State = typeof Sha1State.Type;
|
|
14
|
+
/** A stored state, checked: a typed failure for one no `Sha1` could have written. */
|
|
15
|
+
export declare const decodeSha1State: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<{
|
|
16
|
+
readonly words: readonly [number, number, number, number, number];
|
|
17
|
+
readonly length: number;
|
|
18
|
+
readonly pending: string;
|
|
19
|
+
}, Schema.SchemaError, never>;
|
|
20
|
+
export declare class Sha1 {
|
|
21
|
+
#private;
|
|
22
|
+
/**
|
|
23
|
+
* A hash from the start, or going on from `state`, which it trusts: one `decodeSha1State`
|
|
24
|
+
* hasn't checked and that holds a block or more of pending bytes throws a `RangeError`.
|
|
25
|
+
*/
|
|
26
|
+
constructor(state?: Sha1State);
|
|
27
|
+
/** Takes `bytes`, after every byte before them. */
|
|
28
|
+
update(bytes: Uint8Array): void;
|
|
29
|
+
/** The state to go on from, as plain data. */
|
|
30
|
+
state(): Sha1State;
|
|
31
|
+
/** The digest of every byte taken, padded as SHA-1 pads; the hash takes no more after it. */
|
|
32
|
+
digest(): Uint8Array<ArrayBuffer>;
|
|
33
|
+
}
|
|
34
|
+
/** The SHA-1 of `bytes`, through the runtime's digest, as 20 bytes. */
|
|
35
|
+
export declare const sha1Of: (bytes: Uint8Array<ArrayBuffer>) => Effect.Effect<Uint8Array<ArrayBuffer>>;
|