Artifactspublic-v0

ply

main
ply4 git calls658 ms40 KiB2 cachedprotocol v2
115 lines5.5 KiBRaw
1// The package entry (#100): a consumer imports values and types from index, with no casts.
2import {
3 fetchPack, push, spliceDelta, zlibDeflate, Tracer, arrayExporter, createTransport, discover, lsRefs,
4 fetchObject, packStream, spInit, spStep, spFinish, inflate, commitView, entryType, lsMode, refCandidates,
5 isFilterRejection, isPlyCode, DEFAULT_LIMITS, parseRefname,
6 type Transport, type ExportLine, type Exporter, type Limits, type FetchOpts, type SpState, type PackObject, type OperationOpts,
7 type TransferRun, type LastPush, type LastStep,
8} from '../../src/index.js';
10// A paused transfer's two facts (LastPush and LastStep, public beside TransferRun). The unions and the paused shape are
11// written out here from README's transfer section, not read from src/transfer.ts: a member added, dropped or renamed
12// there, a field renamed, or either export removed from the entry fails this file (tsconfig.check.json compiles it).
13type Same<A, B> = (<T>() => T extends A ? 1 : 2) extends (<T>() => T extends B ? 1 : 2) ? true : false;
14const lastPushIs: Same<LastPush, 'none' | 'acknowledged' | 'refused' | 'unanswered'> = true;
15const lastStepIs: Same<LastStep, 'none' | 'landed' | 'not_shown'> = true;
16const pausedIs: Same<Extract<TransferRun, { readonly tag: 'paused' }>, {
17 readonly tag: 'paused'; readonly step: number; readonly pushes: number; readonly reason: 'max_steps' | 'settling';
18 readonly lastPush: 'none' | 'acknowledged' | 'refused' | 'unanswered'; readonly lastStep: 'none' | 'landed' | 'not_shown';
19}> = true;
20void lastPushIs; void lastStepIs; void pausedIs;
21// a consumer reads both fields off a pause with no cast, and a done run has neither
22const pauseFacts = (run: TransferRun): readonly [LastPush, LastStep] | null => (run.tag === 'paused' ? [run.lastPush, run.lastStep] : null);
23void pauseFacts;
24// @ts-expect-error a done run states no last push
25const doneFacts = (run: Extract<TransferRun, { readonly tag: 'done' }>): LastPush => run.lastPush;
26void doneFacts;
28declare const transport: Transport;
29declare const anyBytes: Uint8Array;
30declare const shared: Uint8Array<SharedArrayBuffer>;
32// @ts-expect-error kind is the literal 'http'
33const kind: Transport['kind'] = 1;
34void kind;
36const exporter: Exporter = line => {
37 const spans: number = line.resourceSpans.length;
38 void spans;
39};
40const tracer = new Tracer({ exporter, maxEvents: 8, resource: { 'service.name': 'ply' } });
41const collected = arrayExporter();
42const sample: ExportLine = { resourceSpans: [] };
43collected(sample);
44const stored: number = collected.lines.length;
45void stored;
47const limits: Limits = DEFAULT_LIMITS;
48const made = createTransport('https://example.test/repo.git', {
49 tracer, userAgent: 'ply-web', limits, signal: new AbortController().signal, fetchImpl: globalThis.fetch, quirks: {},
50});
51if (made.ok) { const madeT: Transport = made.value; void madeT; }
53const opts: OperationOpts = { tracer };
54void opts;
56const fetchOpts: FetchOpts = { wants: ['a'.repeat(40)], filter: 'blob:none' };
58// fetchPack → push, and spliceDelta → zlibDeflate, through the entry. SharedArrayBuffer views are inputs.
59const consumer = async (): Promise<void> => {
60 const fetchedR = await fetchPack(transport, fetchOpts);
61 if (!fetchedR.ok) return;
62 const fetched = fetchedR.value;
63 const objects: PackObject[] = [...(fetched.objects?.values() ?? [])].map(o => ({ type: o.type, data: o.data }));
64 // helper: unwrap a Result Ok (type-level)
65 const expectOk = <T, E>(r: { ok: true; value: T } | { ok: false; error: E }): T => (r.ok ? r.value : (null as unknown as T));
66 const ref = expectOk(parseRefname('refs/heads/x'));
67 await push(transport, { ref, oldOid: '0'.repeat(40), newOid: 'b'.repeat(40), objects });
68 const { delta } = spliceDelta({ baseLen: 8, off: 0, oldLen: 1, insert: anyBytes });
69 const deflated: Uint8Array<ArrayBuffer> = await zlibDeflate(delta);
70 await zlibDeflate(shared);
71 void deflated;
73 const infoR = await discover(transport);
74 if (!infoR.ok) return;
75 const info = infoR.value;
76 const caps: ReadonlyMap<string, string> | Map<string, string> = info.caps;
77 void caps;
78 const listedR = await lsRefs(transport, ['refs/heads/']);
79 if (!listedR.ok) return;
80 const head: string | null = listedR.value.head;
81 void head;
82 const objectR = await fetchObject(transport, { oid: 'c'.repeat(40), filter: 'blob:none' });
83 if (!objectR.ok) return;
84 const object = objectR.value;
85 const view = commitView(object.data, limits);
86 const tree: string | null = view.ok ? view.value.tree : null;
87 void tree;
88 const entry: string = entryType('100644');
89 const mode: string = lsMode('100644');
90 const names: readonly string[] = expectOk(refCandidates('main'));
91 void entry; void mode; void names;
92 const span = tracer.start('git.fetch');
93 for await (const chunk of packStream(transport, fetchOpts, span)) {
94 const bytes: Uint8Array = chunk;
95 void bytes;
96 }
97 let cursor: SpState = spInit();
98 const steppedR = spStep(cursor, anyBytes);
99 if (!steppedR.ok) return;
100 const stepped = steppedR.value;
101 const finished = spFinish(stepped.state);
102 if (!finished.ok) return;
103 cursor = finished.value;
104 const pieces: readonly Uint8Array[] = stepped.zlib;
105 void cursor; void pieces;
106 const inflated = inflate(anyBytes, 0, { expectedSize: 1, maxOutput: 8 });
107 if (!inflated.ok) return;
108 // `out` is a subarray of the growable buffer, so the published type is `Uint8Array` (any backing).
109 const out: Uint8Array = inflated.value.out;
110 void out;
111 const rejected: boolean = isFilterRejection(new Error('no'));
112 const known: boolean = isPlyCode('pack_corrupt');
113 void rejected; void known;
114};
115void consumer;
Diagnostics4 git calls · 658 ms
CallStatusSizeTime0658 ms
discover200152 B2 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=2
git.response.bytes=152
git.server.agent=gitty/1.0
git.server.object_format=sha1
git.server.caps=agent ls-refs fetch object-format
git.server.fetch=shallow filter sideband-all
git.protocol.version=2
git.pkt.frames=8
git.pkt.data=6
git.pkt.flush=2
git.pkt.delim=0
git.pkt.bytes=152
git.pkt.payload.max=34
ls-refs200145 B · hit2 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=2
git.response.bytes=145
git.response.cache=HIT
git.response.duration_ms=2
git.protocol.version=2
git.pkt.frames=3
git.pkt.data=2
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=145
git.pkt.payload.max=76
git.ls_refs.count=2
git.ls_refs.head=refs/heads/main
fetchblob:none · deepen 1020038 KiB · hit5 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=3
git.response.bytes=38434
git.response.cache=HIT
git.response.duration_ms=5
git.fetch.filter=blob:none
git.fetch.filter.requested=tree:0
git.fetch.filter.fallback=blob:none
git.fetch.filter.learned=false
git.fetch.wants=19912563f540228593df0c489082e5e2508e21e4
git.fetch.haves.count=0
git.fetch.deepen=10
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=6
git.pkt.data=4
git.pkt.flush=1
git.pkt.delim=1
git.pkt.bytes=38434
git.pkt.payload.max=38339
git.sideband.band1.bytes=38338
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=63
git.pack.bytes=38338
git.pack.ofs_delta=0
git.pack.ref_delta=8
git.pack.chain.max=8
git.pack.trailer=0bc36ab7adf82d3109177f11f1ea93f1ce071f77
git.pack.full=55
Open pack map
fetch2002.3 KiB651 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=651
git.response.bytes=2359
git.response.cache=MISS
git.response.duration_ms=651
git.fetch.wants=9cc0f56af5b2ba8daf91b6e40eb0f3a5c369ed08
git.fetch.haves.count=0
git.fetch.deepen=0
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=3
git.pkt.data=2
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=2359
git.pkt.payload.max=2338
git.sideband.band1.bytes=2337
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0

Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.

Remote
https://5ad2236b39de4c8bd8f6270ea63f3ea9.artifacts.cloudflare.net/git/public-v0/ply.git
Ref
refs/heads/main
Commit
19912563f540228593df0c489082e5e2508e21e4
cf-ray
a5e2f83aea4790c0
Request
ff79ab65…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format