main
ply4 git calls25 ms43 KiB3 cachedprotocol v2
175 lines6.7 KiBRaw
1import { deflateSync } from 'node:zlib'
3export type Rgb = readonly [number, number, number]
5export type ChartPoint = {
6 readonly x: string
7 readonly y: number
8}
10export type ChartSeries = {
11 readonly name: string
12 readonly rgb: Rgb
13 readonly points: readonly ChartPoint[]
16export type ChartSpec = {
17 readonly title: string
18 readonly series: readonly ChartSeries[]
19 readonly hLine?: { readonly y: number; readonly rgb: Rgb }
22const WIDTH = 720
23const HEIGHT = 400
24const LEFT = 56
25const RIGHT = 16
26const TOP = 36
27const BOTTOM = 48
29/** 5×7 glyphs, row-major, '.' off and '#' on. Unknown characters are skipped. */
30const GLYPH: Record<string, string> = {
31 ' ': '......./......./......./......./......./......./.......',
32 '.': '......./......./......./......./......./..#.#../.......',
33 '-': '......./......./......./#######/......./......./.......',
34 '/': '.....#./....#../...#.../..#..../.#...../#....../.......',
35 '%': '#...#../#..#.#./#.#.#../..#.#../.#.#.#./.#..#../#...#..',
36 '0': '.#####./#.....#/#.....#/#.....#/#.....#/#.....#/.#####.',
37 '1': '...#.../..##.../...#.../...#.../...#.../...#.../..###..',
38 '2': '.#####./#.....#/.....#./...#.../..#..../.#...../#######',
39 '3': '.#####./#.....#/.....#./..###../.....#./#.....#/.#####.',
40 '4': '...#.../..##.../.#.#.../#..#.../#######/....#.../....#..',
41 '5': '#######/#....../######./.....#./.....#./#.....#/.#####.',
42 '6': '.#####./#....../#....../######./#.....#/#.....#/.#####.',
43 '7': '#######/.....#./....#.../...#.../..#..../.#...../.#.....',
44 '8': '.#####./#.....#/.#####./#.....#/#.....#/#.....#/.#####.',
45 '9': '.#####./#.....#/#.....#/.######/.....#./.....#./.#####.',
46 'a': '.#####./#.....#/#.....#/#######/#.....#/#.....#/#.....#',
47 'b': '######./#.....#/######./#.....#/#.....#/#.....#/######.',
48 'c': '.#####./#.....#/#....../#....../#....../#.....#/.#####.',
49 'd': '######./#.....#/#.....#/#.....#/#.....#/#.....#/######.',
50 'e': '#######/#....../######./#....../#....../#....../#######',
51 'f': '#######/#....../######./#....../#....../#....../#......',
52 'g': '.#####./#.....#/#....../#..####/#.....#/#.....#/.#####.',
53 'h': '#.....#/#.....#/#######/#.....#/#.....#/#.....#/#.....#',
54 'i': '..###../...#.../...#.../...#.../...#.../...#.../..###..',
55 'l': '#....../#....../#....../#....../#....../#....../#######',
56 'm': '#.....#/##...##/#.#.#.#/#..#..#/#.....#/#.....#/#.....#',
57 'n': '#.....#/##....#/#.#...#/#..#..#/#...#.#/#....##/#.....#',
58 'o': '.#####./#.....#/#.....#/#.....#/#.....#/#.....#/.#####.',
59 'p': '######./#.....#/#.....#/######./#....../#....../#......',
60 'r': '######./#.....#/#.....#/######./#..#.../#...#../#.....#',
61 's': '.#####./#.....#/#....../.#####./.....#./#.....#/.#####.',
62 't': '#######/...#.../...#.../...#.../...#.../...#.../...#...',
63 'u': '#.....#/#.....#/#.....#/#.....#/#.....#/#.....#/.#####.',
64 'v': '#.....#/#.....#/#.....#/#.....#/.#...#./..#.#../...#...',
65 'w': '#.....#/#.....#/#.....#/#..#..#/#.#.#.#/##...##/#.....#',
66 'y': '#.....#/#.....#/.#...#./..#.#../...#.../...#.../...#...',
69function glyphRows(ch: string): string[] {
70 const raw = GLYPH[ch.toLowerCase()] ?? GLYPH[' '] ?? ''
71 return raw.split('/')
74function drawText(buf: Uint8Array, x: number, y: number, text: string, rgb: Rgb): void {
75 let cursor = x
76 for (const ch of text) {
77 const rows = glyphRows(ch)
78 for (let row = 0; row < rows.length; row++) {
79 const bits = rows[row] ?? ''
80 for (let col = 0; col < bits.length; col++) {
81 if (bits[col] !== '#') continue
82 set(buf, cursor + col, y + row, rgb)
83 }
84 }
85 cursor += 8
86 }
89function set(buf: Uint8Array, x: number, y: number, rgb: Rgb): void {
90 if (x < 0 || y < 0 || x >= WIDTH || y >= HEIGHT) return
91 const i = (y * WIDTH + x) * 3
92 buf[i] = rgb[0]
93 buf[i + 1] = rgb[1]
94 buf[i + 2] = rgb[2]
97function fill(buf: Uint8Array, x: number, y: number, w: number, h: number, rgb: Rgb): void {
98 for (let yy = y; yy < y + h; yy++) {
99 for (let xx = x; xx < x + w; xx++) set(buf, xx, yy, rgb)
100 }
103function hline(buf: Uint8Array, y: number, rgb: Rgb): void {
104 for (let x = LEFT; x < WIDTH - RIGHT; x++) set(buf, x, y, rgb)
107function crc32(data: Uint8Array): number {
108 let c = ~0
109 for (const byte of data) {
110 c ^= byte
111 for (let bit = 0; bit < 8; bit++) c = (c >>> 1) ^ (0xedb88320 & -(c & 1))
112 }
113 return ~c >>> 0
116function chunk(type: string, data: Uint8Array): Buffer {
117 const body = Buffer.concat([Buffer.from(type), Buffer.from(data)])
118 const len = Buffer.alloc(4)
119 len.writeUInt32BE(data.length)
120 const crc = Buffer.alloc(4)
121 crc.writeUInt32BE(crc32(body))
122 return Buffer.concat([len, body, crc])
125/** A small bar chart. Empty series still produce a titled PNG. */
126export function chartPng(spec: ChartSpec): Buffer {
127 const buf = new Uint8Array(WIDTH * HEIGHT * 3)
128 buf.fill(255)
129 const ink: Rgb = [15, 23, 42]
130 drawText(buf, 16, 12, spec.title, ink)
131 const plotW = WIDTH - LEFT - RIGHT
132 const plotH = HEIGHT - TOP - BOTTOM
133 fill(buf, LEFT, TOP, plotW, 1, ink)
134 fill(buf, LEFT, TOP + plotH, plotW, 1, ink)
135 fill(buf, LEFT, TOP, 1, plotH, ink)
136 const ys = spec.series.flatMap(series => series.points.map(point => point.y))
137 if (spec.hLine) ys.push(spec.hLine.y)
138 const max = Math.max(1, ...ys, 0)
139 const yOf = (value: number) => TOP + plotH - Math.round((value / max) * (plotH - 4))
140 if (spec.hLine) hline(buf, yOf(spec.hLine.y), spec.hLine.rgb)
141 const labels = spec.series[0]?.points.map(point => point.x) ?? []
142 const groups = Math.max(labels.length, 1)
143 const groupW = plotW / groups
144 const barW = Math.max(2, Math.floor((groupW * 0.8) / Math.max(spec.series.length, 1)))
145 spec.series.forEach((series, seriesIndex) => {
146 series.points.forEach((point, index) => {
147 const x = Math.round(LEFT + index * groupW + 4 + seriesIndex * barW)
148 const y = yOf(point.y)
149 const h = TOP + plotH - y
150 if (h > 0) fill(buf, x, y, barW - 1, h, series.rgb)
151 })
152 })
153 labels.forEach((label, index) => {
154 drawText(buf, Math.round(LEFT + index * groupW + 2), HEIGHT - 28, label, ink)
155 })
156 spec.series.forEach((series, index) => {
157 const x = LEFT + index * 120
158 fill(buf, x, HEIGHT - 16, 10, 8, series.rgb)
159 drawText(buf, x + 14, HEIGHT - 18, series.name, ink)
160 })
161 const ihdr = Buffer.alloc(13)
162 ihdr.writeUInt32BE(WIDTH, 0)
163 ihdr.writeUInt32BE(HEIGHT, 4)
164 ihdr[8] = 8
165 ihdr[9] = 2
166 const raw = Buffer.alloc(HEIGHT * (1 + WIDTH * 3))
167 for (let y = 0; y < HEIGHT; y++) {
168 const row = y * (1 + WIDTH * 3)
169 raw[row] = 0
170 Buffer.from(buf.buffer, buf.byteOffset + y * WIDTH * 3, WIDTH * 3).copy(raw, row + 1)
171 }
172 const idat = deflateSync(raw)
173 const signature = Buffer.from([137, 80, 78, 71, 13, 10, 26, 10])
174 return Buffer.concat([signature, chunk('IHDR', ihdr), chunk('IDAT', idat), chunk('IEND', new Uint8Array())])
Diagnostics4 git calls · 25 ms
CallStatusSizeTime025 ms
discover200152 B4 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=4
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 · hit4 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=4
git.response.bytes=145
git.response.cache=HIT
git.response.duration_ms=4
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 1020040 KiB · hit2 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=2
git.response.bytes=41349
git.response.cache=HIT
git.response.duration_ms=2
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=526b305930b8ef382f2d7a1f9c0238730a585921
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=41349
git.pkt.payload.max=41254
git.sideband.band1.bytes=41253
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=61
git.pack.bytes=41253
git.pack.ofs_delta=0
git.pack.ref_delta=0
git.pack.chain.max=0
git.pack.trailer=ab60efef4b7243678c75de64a4386986ee885c1c
git.pack.full=61
Open pack map
fetch2002.1 KiB · hit19 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=19
git.response.bytes=2144
git.response.cache=HIT
git.response.duration_ms=19
git.fetch.wants=c6ae025592b3edde2fd5eb071093d5d4e8d3f24e
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=2144
git.pkt.payload.max=2123
git.sideband.band1.bytes=2122
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-web.git
Ref
refs/heads/main
Commit
526b305930b8ef382f2d7a1f9c0238730a585921
cf-ray
a5e2f231ea4cfda9
Request
0a9492f1…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format