anishshobithps / anishshobithps/snipshot

Vendor Monaco locally — drop the CDN, keep its built-ins

未關閉
#6 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
area: rendering effort: medium enhancement priority: high
主要語言
TypeScript
星號
1
分支
0
PR 合併指標
30 天內沒有已合併 PR

描述

**Keep Monaco — just stop loading it from a CDN.**

Today `src/snapshot.ts` loads Monaco Editor **and** require.js from the cdnjs CDN at render time (`EditorScript`/`Page`). Every screenshot therefore needs network access and can break if the CDN or the pinned tag changes.

**Decision:** keep Monaco. The rendering quality is excellent and we get the built-in **diff editor**, **decorations**, and tokenizers for free (see #12 and #11) — no reason to reinvent that with another engine. Just install it as a dependency and serve it to the headless page **offline**.

**Approach (decide during implementation)**
- `pnpm add monaco-editor` and pin the version (the CDN currently uses 0.44.0).
- Serve `node_modules/monaco-editor/min/vs` to Puppeteer offline. Options:
- Write the generated HTML to a temp dir, place `min/vs` beside it, and `page.goto('file://.../page.html')` using Monaco's own `vs/loader.js` (AMD) instead of the cdnjs require.js — smallest change to the current template.
- Or `page.setRequestInterception(true)` and fulfil the Monaco + loader URLs from local files (keeps `setContent`).
- Or bundle the ESM editor via tsdown and inline it (heavier; workers not needed for a read-only render).
- Short-circuit web workers (`MonacoEnvironment.getWorker`) — not needed for a static screenshot.

**Tasks**
- [ ] Add & pin `monaco-editor`
- [ ] Swap the cdnjs URLs (require.js + `vs`) for the local package
- [ ] Serve offline (file:// goto or request interception)
- [ ] Verify a render with networking disabled
- [ ] Confirm output is pixel-identical to the CDN version

Unblocks #11 (decorations) and #12 (Monaco diff editor).

貢獻指南

這個儲存庫沒有索引到貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。