Conversation
…p-lib
Replaces the EXPORTER_NOT_READY stubs with working tier-1 implementations
for all three formats. Heavy runtime deps load lazily via dynamic import()
inside each exporter function so the Electron cold-start bundle remains
unchanged (PRINCIPLES §1).
- pdf.ts: puppeteer-core driving the user's installed Chrome (discovered
via chrome-discovery.ts on Mac/Win/Linux). Refuses to bundle Chromium —
a ~150 MB download would blow the 80 MB installer budget. Throws
EXPORTER_NO_CHROME (loud, with install link) when no Chromium-based
browser is present.
- pptx.ts: pptxgenjs with one slide per top-level <section> (or one for
the whole document if none exist). Sidesteps the dom-to-pptx CJK
word-wrap bug by keeping wrap=square + fit:'shrink' (research/04).
dom-to-pptx itself is deferred to tier 2.
- zip.ts: zip-lib bundling index.html + README.md + optional assets.
- index.ts: isExporterReady('pdf'|'pptx'|'zip') now true; exportArtifact
forwards htmlContent + destinationPath to the per-format modules.
- PreviewToolbar: flips the dropdown items from "Coming in Phase 2" to
per-format hover hints describing what each produces.
Hard rules respected:
- No silent fallbacks; each path throws CodesignError with a structured
code (EXPORTER_NO_CHROME / EXPORTER_PDF_FAILED / EXPORTER_PPTX_FAILED
/ EXPORTER_ZIP_FAILED).
- Lazy-load: index.ts imports zero heavy deps statically; verified
with `grep "^import .* from 'puppeteer-core|pptxgenjs|zip-lib'"`.
- Tests: chrome-discovery (6), pdf mocked via puppeteer-core (3), pptx
CJK round-trip with the real library (6), zip extract round-trip (3).
Signed-off-by: hqhq1025 <1506751656@qq.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Goal
Replace the
EXPORTER_NOT_READYstubs inpackages/exporters/src/{pdf,pptx,zip}.tswith working tier-1 implementations. All three formats ship as real exporters; the heavy runtime deps load lazily so the Electron cold-start bundle is unchanged (PRINCIPLES §1, §6).Files in / out
Modified
packages/exporters/src/pdf.ts— puppeteer-core driving the user's installed Chromepackages/exporters/src/pptx.ts— pptxgenjs, one slide per<section>(or one for the whole doc)packages/exporters/src/zip.ts— zip-lib bundlingindex.html+README.md+ optional assetspackages/exporters/src/index.ts—isExporterReady(...)returns true for all four formats;exportArtifactdispatches with payloadpackages/exporters/package.json— adds three prod deps (see below)apps/desktop/src/main/exporter-ipc.ts— comment update only (channel/payload unchanged)apps/desktop/src/renderer/src/components/PreviewToolbar.tsx— flips dropdown items from "Coming in Phase 2" to per-format hover hintsCreated
packages/exporters/src/chrome-discovery.ts— Mac/Win/Linux Chrome resolver +CODESIGN_CHROME_PATHoverridepackages/exporters/src/chrome-discovery.test.ts— 6 tests (per-OS path, override, EXPORTER_NO_CHROME)packages/exporters/src/pdf.test.ts— 3 tests, puppeteer-core mockedpackages/exporters/src/pptx.test.ts— 6 tests including'你好世界'CJK round-trip with the real librarypackages/exporters/src/zip.test.ts— 3 tests, real zip-lib extract round-tripUntouched (boundary respected)
apps/desktop/src/main/index.ts,apps/desktop/src/renderer/src/App.tsx,apps/desktop/src/renderer/src/store.ts,apps/desktop/src/preload/index.tsNew dependencies
puppeteer-core@^24.10.0await import('puppeteer-core')insideexportPdfpptxgenjs@^3.12.0await import('pptxgenjs')insideexportPptxzip-lib@^1.0.4await import('zip-lib')insideexportZipAll three are Apache-2.0-compatible. Lazy-load proof:
grep -E "^import .* from ['\"](puppeteer-core\|pptxgenjs\|zip-lib)['\"]" packages/exporters/src/*.tsreturns nothing — every reference is inside anasync functionvia dynamicimport(). Total impact stays well inside the 80 MB installer budget; no Chromium is bundled (we discover the system Chrome at runtime and throwEXPORTER_NO_CHROMEwith the install link if missing).Acceptance test outcomes
No silent fallbacks: each exporter throws
CodesignErrorwith a structuredcode(EXPORTER_NO_CHROME/EXPORTER_PDF_FAILED/EXPORTER_PPTX_FAILED/EXPORTER_ZIP_FAILED).§5b checklist
ExporterFormat,ExportResult, IPC channelcodesign:export, and the renderer'sExportItemshape are unchanged. Every error carries a versionedcodestring callers can pattern-match on.pptx.tsalready routes throughextractSlides(), so swapping indom-to-pptx(tier 2) or a Chromium screenshot fallback only touches that one helper.chrome-discovery.tsaccepts adepsinjection point so a future "managed Chrome download" path can plug in without touching exporters.PreviewToolbarkeeps existing tokens / spacing / easing; only the per-item hint copy changed. Each exporter is a single small function with a single throw site.How to test manually
pnpm i && pnpm dev<section>blocks → opens in PowerPoint / Keynote with one slide per section.index.html,README.md, and any assets.CODESIGN_CHROME_PATH=/nonexistent), PDF export shows theEXPORTER_NO_CHROMEtoast with the install link.