Public: anyone can read this; the crew can change it.
Main is green again: the forge pill's script fits its 24 KB budget #10876
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/10869-main-is-green-again-the-forge-pill-s-scr → main 1 commit fork
2 files
changed +7
−2
src/apps/toolbar.ts +5 −2
| @@ -23,8 +23,8 @@ export const FRESHNESS_WORDS = { | ||
| 23 | 23 | behind: "Shows an older push than the pull's newest", |
| 24 | 24 | } as const; |
| 25 | 25 | |
| 26 | /** The client, as plain source: no `eval`, no inline handlers. */ | |
| 27 | export const toolbarJs = `(function () { | |
| 26 | /** The client, as plain source: no `eval`, no inline handlers. Its comments are for readers here. */ | |
| 27 | const toolbarSource = `(function () { | |
| 28 | 28 | if (window.__forgeToolbar) return; |
| 29 | 29 | window.__forgeToolbar = true; |
| 30 | 30 | var me = document.currentScript; |
| @@ -556,6 +556,9 @@ export const toolbarJs = `(function () { | ||
| 556 | 556 | })(); |
| 557 | 557 | `; |
| 558 | 558 | |
| 559 | /** What is served: the source without its whole-line comments, so the notes cost the pill none of its 24 KB (#10869). */ | |
| 560 | export const toolbarJs = toolbarSource.replace(/^[ \t]*\/\/[^\n]*\n/gm, ""); | |
| 561 | ||
| 559 | 562 | const hash = sha256(toolbarJs); |
| 560 | 563 | const name = `toolbar-${hash.slice(0, 16)}`; |
| 561 | 564 |
test/apps-toolbar.test.ts +2
| @@ -393,6 +393,8 @@ describe("the forge pill", () => { | ||
| 393 | 393 | expect(code.length).toBeLessThan(24 * 1024); |
| 394 | 394 | expect(code).not.toMatch(/\beval\b|new Function|\son[a-z]+\s*=/); |
| 395 | 395 | expect(code).toContain("attachShadow"); |
| 396 | // The source's whole-line comments are for readers, not shipped (#10869). | |
| 397 | expect(code).not.toMatch(/^[ \t]*\/\//m); | |
| 396 | 398 | }); |
| 397 | 399 | |
| 398 | 400 | test("the tag lands before the last </body>, whatever its case", () => { |