Commit Graph
229 Commits
Author SHA1 Message Date
lambert.li 6606ca7b5d ci: upgrade GitHub Pages actions to Node 24 2026-07-13 16:32:13 +08:00
CoderLambert 1d72b2c2c4 docs: improve GitHub and npm discoverability (#16)
Improve repository and npm discoverability, add bilingual onboarding and community metadata, and upgrade GitHub Actions to Node 24 runtimes.
2026-07-13 16:24:45 +08:00
github-actions[bot] c671b5d813 chore(release): version packages (#15)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@lamberl-lee/file-preview@0.7.9
2026-07-13 14:35:56 +08:00
CoderLambertandlambert.li cedc68a2c6 fix(file-preview): portal XLSX comment tooltips (#14)
Co-authored-by: lambert.li <lambert.li@jtexpress.com>
2026-07-13 14:34:26 +08:00
github-actions[bot] 3e63587875 chore(release): version packages (#13)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@lamberl-lee/file-preview@0.7.8
2026-07-13 14:17:26 +08:00
CoderLambertandlambert.li 5dd8d450b8 fix(file-preview): correct XLSX comment tooltip positioning (#12)
Co-authored-by: lambert.li <lambert.li@jtexpress.com>
2026-07-13 14:14:42 +08:00
CoderLambert 1feed9aec7 Merge pull request #11 from CoderLambert/changeset-release/main
chore(release): version packages
@lamberl-lee/file-preview@0.7.7
2026-07-13 10:57:32 +08:00
github-actions[bot] 513651afe3 chore(release): version packages 2026-07-13 02:55:48 +00:00
lambert.li 00fe0a9a74 fix(file-preview): remove unstable XLSX canvas renderer 2026-07-13 10:54:43 +08:00
CoderLambert e04230e55e Merge pull request #10 from CoderLambert/changeset-release/main
chore(release): version packages
@lamberl-lee/file-preview@0.7.6
2026-07-13 10:22:42 +08:00
github-actions[bot] 05ba3f77c0 chore(release): version packages 2026-07-13 02:21:54 +00:00
lambert.li d6b1292828 fix(file-preview): stabilize XLSX renderer scrolling 2026-07-13 10:20:44 +08:00
CoderLambert c6f9f5b677 Merge pull request #9 from CoderLambert/changeset-release/main
chore(release): version packages
@lamberl-lee/file-preview@0.7.5
2026-07-13 09:52:44 +08:00
github-actions[bot] 8de8a76840 chore(release): version packages 2026-07-13 01:51:15 +00:00
lambert.li 0fb01ac42a chore(release): add XLSX compatibility changeset 2026-07-13 09:48:28 +08:00
lambert.li e9b8a77744 fix(file-preview): improve XLSX preview compatibility 2026-07-13 09:48:03 +08:00
CoderLambert 70e8e4aee6 chore(release): version packages (#8)
chore(release): version packages
@lamberl-lee/file-preview@0.7.4
2026-07-10 17:31:16 +08:00
github-actions[bot] dd9f0d034b chore(release): version packages 2026-07-10 09:23:07 +00:00
CoderLambert 7f08aff8cf fix(file-preview): harden XLSX comment fallback 2026-07-10 17:22:05 +08:00
CoderLambert b17e07d410 chore(release): version packages (#7)
Release @lamberl-lee/file-preview@0.7.3
@lamberl-lee/file-preview@0.7.3
2026-07-10 17:01:43 +08:00
github-actions[bot] 872f90b42a chore(release): version packages 2026-07-10 08:59:25 +00:00
CoderLambert 0b71cf7b8d chore(changeset): release XLSX comment compatibility 2026-07-10 16:58:17 +08:00
CoderLambert 883a8a706f fix(file-preview): support nonstandard XLSX comments 2026-07-10 16:47:01 +08:00
lambert.li dcd7914fd8 fix(file-preview): fit fixed-canvas HTML previews @lamberl-lee/file-preview@0.7.2 2026-07-10 10:43:08 +08:00
lambert.li 419fd14d53 fix(file-preview): improve PDF zoom rendering @lamberl-lee/file-preview@0.7.1 2026-07-08 13:42:40 +08:00
lambert.li 58d0ec2392 feat(file-preview): add HTML full preview confirmation @lamberl-lee/file-preview@0.7.0 2026-07-07 14:46:37 +08:00
CoderLambert 8a7fb2b28d Merge pull request #6 from CoderLambert/changeset-release/main
chore(release): version packages
@lamberl-lee/file-preview@0.6.1
2026-07-07 09:26:59 +08:00
github-actions[bot] e4374ee7b6 chore(release): version packages 2026-07-07 01:26:27 +00:00
lambert.liandClaude Opus 4.7 966083b240 fix(file-preview): reload HTML iframe on securityMode toggle
Toggling HtmlPreview's securityMode updated the iframe `sandbox`
attribute but left `src` unchanged, so the browser did not reload
the iframe content — the new sandbox policy was never actually
applied. In `safe → trusted`, scripts stayed blocked; in the
reverse direction, already-running scripts kept running.

Use `key={securityMode}` to force React to unmount/remount the
iframe on mode switch, guaranteeing the new sandbox takes effect
on a freshly loaded document.

Also guard against the empty-`src` warning: render the iframe
only after `blobUrl` is set (the blob URL effect runs after the
first paint), instead of passing `src=""` on the first frame.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-07-07 09:25:37 +08:00
CoderLambert 4ec25ff411 Merge pull request #5 from CoderLambert/changeset-release/main
chore(release): version packages
@lamberl-lee/file-preview@0.6.0
2026-07-06 15:04:46 +08:00
github-actions[bot] e25882f750 chore(release): version packages 2026-07-06 07:01:30 +00:00
lambert.liandClaude Opus 4.7 5c48b0b3a2 feat(file-preview): add createRemoteFileInfo() for backend-driven large-file gate
Build a FileInfo for a remote URL using metadata the caller already has
(name + size), so LargeFileGate can apply warning / confirm / block
thresholds before any network traffic starts. Unlike processRemoteUrl(),
this does not fetch — the download happens lazily when a preview plugin
calls readSourceAsArrayBuffer(source).

Trade-offs vs processRemoteUrl(): no magic-byte MIME sniffing (extension
only, or caller-supplied mimeType), no onProgress, no built-in 100 MB
hard cap (caller controls via largeFilePolicy.maxBytes), errors are
plain Error instead of typed RemoteUrlError.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-07-06 15:00:34 +08:00
CoderLambert 1ac872b7e4 Merge pull request #4 from CoderLambert/changeset-release/main
chore(release): version packages
@lamberl-lee/file-preview@0.5.1
2026-07-06 13:43:01 +08:00
github-actions[bot] 02e92e023a chore(release): version packages 2026-07-06 05:42:18 +00:00
lambert.liandClaude Opus 4.7 9bbc85593a chore: add changeset for html preview fixes
Patch-level changeset covering the blob URL leak fix, ExcelJS ESM interop
fix, and the new HTML security toggle. Bumps
@lamberl-lee/file-preview from 0.5.0 → 0.5.1 once the Version Packages PR
is merged.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-07-06 13:41:22 +08:00
lambert.liandClaude Opus 4.7 2efeba2392 fix(file-preview): blob URL leak, ExcelJS ESM interop, HTML security toggle
Three issues addressed:

1. HtmlPreview leaked blob URLs when `content` changed. The old `useMemo`
   returned a fresh URL each render but the `useEffect` cleanup ran on
   `[blobUrl]` so React StrictMode's double-invoke revoked URLs that were
   still mounted, causing iframe flashes. Switched to `useState + useEffect`
   with `[content]` deps so cleanup runs exactly once per content change.

2. ExcelJS dynamic import returned a `{ default: Module }` wrapper under
   some bundler configs, making `EJS.Workbook` undefined and crashing
   XLSX preview. Now resolves `mod.default?.Workbook ?? EJS.Workbook`
   with a typed cast to handle both ESM-namespace and CJS-wrapper shapes.

3. HtmlPreview's `securityMode` was `useState<HtmlSecurityMode>("safe")`
   with no setter exported — users had no way to enable scripts for trusted
   HTML files. Added an explicit toggle in the view-mode bar (default
   "safe", opt-in "trusted"). When trusted, a warning banner explains the
   risk. Three new i18n strings: htmlEnableScripts / htmlDisableScripts /
   htmlTrustedModeHint (zh-CN and en-US).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-07-06 13:41:22 +08:00
CoderLambert 33e2971027 Merge pull request #3 from CoderLambert/changeset-release/main
chore(release): version packages
@lamberl-lee/file-preview@0.5.0
2026-07-06 11:41:01 +08:00
github-actions[bot] 9b53e4179b chore(release): version packages 2026-07-06 03:26:31 +00:00
lambert.liandClaude Opus 4.7 077365161a chore: add changeset for large file policy + detached buffer fix
Covers the minor bump for the configurable largeFilePolicy API (5f88b11)
and the patch-level detached-ArrayBuffer fix (14a429f). Changesets bot
will open a "Version Packages" PR on push to main that bumps
@lamberl-lee/file-preview from 0.4.0 → 0.5.0 and regenerates CHANGELOG.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-07-06 11:25:30 +08:00
lambert.liandClaude Opus 4.7 188c3e2029 chore(playground): load HTML demos, tune large-file policy to 2/3/5 MB
Two demo-app improvements:

1. fetchBinaryDemoFiles previously logged `console.error` and skipped any
   file under public/demo/ whose head looked like HTML — including the
   legit `order-detail.html` preview target. HTML now flows through as
   UTF-8 text (encoding: "utf8"), and page.tsx encodes it to an ArrayBuffer
   via TextEncoder so it fits the same arrayBuffer source shape.

2. PluginPreviewRenderer's largeFilePolicy was the default 20/50/100 MB.
   For a demo that ships small fixtures this is too lax — bumped down to
   2 MB warn / 3 MB confirm / 5 MB block so users can see all three gate
   states without needing multi-MB uploads.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-07-06 11:24:45 +08:00
lambert.liandClaude Opus 4.7 14a429fbcf fix(file-preview): copy arrayBuffer source to avoid detached-ArrayBuffer crash
`readSourceAsArrayBuffer` returned `source.buffer` directly for arrayBuffer
sources. Downstream consumers (pdf.js via `getDocument({ data })`) transfer
the buffer to a Web Worker, which detaches the original ArrayBuffer. A second
read on the same source — React StrictMode double-invoke, file re-selection,
source reuse across previews — then crashed with:

  TypeError: Cannot perform Construct on a detached ArrayBuffer

The `file` and `blob` branches already returned fresh ArrayBuffers per call
(`File.arrayBuffer()` / `Blob.arrayBuffer()`); the arrayBuffer branch now
matches that behavior via `source.buffer.slice(0)`.

Tests cover both the copy semantics and the post-detach re-read path
(simulates worker transfer via `MessageChannel.postMessage(..., [buf])`).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-07-06 11:24:23 +08:00
lambert.liandClaude Opus 4.7 4aeff5b706 docs: add change record for configurable large file policy
Records the Stage 18.2 follow-up to the large file gate: configurable
LargeFilePolicy API, onError/renderLargeFileFallback props, i18n
externalization, downloadSource refactor, and bug fixes found in review
(blockReportedRef dedup, mimeType override, validate Infinity/NaN guard).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-07-06 10:51:27 +08:00
lambert.liandClaude Opus 4.7 5f88b11a8a feat(file-preview): configurable large file policy with i18n and error reporting
- Add LargeFilePolicy union type ("default" | "off" | PreviewSizePolicyConfig)
  with validatePreviewSizePolicy / resolvePreviewSizePolicy helpers; validator
  rejects Infinity/NaN and inverted thresholds
- LargeFileGate accepts policy / onError / renderBlockedFallback props; all
  UI strings externalized via useLocale (5 new locale fields); block report
  dedup keyed on id+size+name so contract-violating id reuse still re-reports
- PluginPreviewRenderer passes through largeFilePolicy and
  renderLargeFileFallback; unsupported branch now also goes through gate
- downloadSource refactored by source kind (file/blob/arrayBuffer/url);
  caller mimeType overrides response Content-Type; network/HTTP errors
  normalized to PreviewError (REMOTE_CORS_ERROR / REMOTE_HTTP_ERROR)
- Tests cover custom maxBytes, tiered policy, FILE_TOO_LARGE onError,
  custom renderLargeFileFallback; tests pin LocaleProvider value={zhCN}
- Demo app shows 4 policy variants with onError telemetry pattern and
  policy-derived UI label (no hardcoded strings to drift)
- README documents the largeFilePolicy API and user-input safety pattern

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-07-06 10:50:28 +08:00
lambert.li e3a86fd25e fix: add OOXML ZIP integrity check in CI and HTML response detection in frontend
- Verify Office demo archives (.xlsx/.docx/.pptx/.epub) are valid
  ZIP packages during CI build, catching corruption before deploy
- Detect HTML responses in fetchBinaryDemoFiles to surface path
  misconfiguration or 404 fallback pages early
- Log response status/statusText/url on fetch failure for easier
  debugging
2026-06-23 08:58:31 +08:00
lambert.li ae43d492d9 docs: add change record for Git LFS GitHub Pages fix 2026-06-22 18:26:19 +08:00
lambert.li 4f486b1004 fix: enable Git LFS checkout in GitHub Pages workflow
GitHub Pages deployed LFS pointer files (xlsx, pptx, docx, pdf, epub)
instead of actual binaries because actions/checkout@v4 defaults lfs:
to false. Browsers received the pointer text (200 OK), causing JSZip
"Can't find end of central directory" errors.

- Enable lfs: true in the checkout step
- Add verification step that scans public/demo/ for leftover pointers
- Add frontend LFS guard in fetchBinaryDemoFiles to skip/raise on
  pointer content
- Improve FileReader error handling with explicit reject paths
2026-06-22 18:25:51 +08:00
lambert.liandClaude 3a4bbb66ee fix(pptx): harden fallback, isolate root entry, bump to 0.4.0
Address PPTX review findings (issues 1-10):

- Reset semanticDeck/insight/isModeSwitching at source-mount start to
  prevent cross-file fallback state bleed.
- View-mode effect depends only on viewMode via activeViewModeRef,
  eliminating duplicate render after activeViewMode catches up.
- Enforce per-slide + total XML code-unit limits (break, not warn) in
  readPptxInsight and readPptxSemanticDeck; rename constants to
  ...CodeUnits to reflect UTF-16 semantics.
- Skip readPptxInsight when semantic deck succeeds (avoid double parse).
- orderSlidesByPresentation appends rels-unmatched slides instead of
  dropping them; readAttribute accepts single-quoted XML attrs.
- Sync latest initialZoom onto viewer after open so mid-load prop
  updates are not lost.
- Promote safelyInvoke to core/ and apply to PluginPreviewRenderer
  onError, PreviewErrorBoundary, and PptxPreviewAdapter reportError.
- Localized fallback description as primary text; raw error.message
  moved into expandable details; add color-mix rgba fallback.
- Clean root entry: remove builtin/heavy plugin exports so the module
  graph no longer reaches optional peers; heavy plugins live under
  /full and /plugins/*. Playground switched to createFullPreviewRegistry.
- Bump version to 0.4.0; update README with base/full split and
  migration note; add CHANGELOG entry.

Co-Authored-By: Claude <noreply@anthropic.com>
@lamberl-lee/file-preview@0.4.0
2026-06-22 18:24:06 +08:00
lambert.liandClaude 2ec80e1b71 docs: add change record for PPTX review 19-issue fix
Documents the 19 review items addressed across 7 commits — package
entry split, async lifecycle, error propagation, state consistency,
fallback ordering and aspect ratio, browser compat, i18n, fallback
performance limits, 'use client' rollout, and supporting tests.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-22 17:44:13 +08:00
lambert.li 383262c1b8 docs: update PPTX dependency info in supported-formats.md 2026-06-22 17:42:56 +08:00
lambert.liandClaude b2bd7a7ac1 test(pptx): add lifecycle and order-slides test coverage
- order-slides.test.ts: 6 unit tests covering sldIdLst-driven ordering,
  filename-fallback when sldIdLst/rels are missing, missing slide skip,
  Target path normalisation, and unknown-rId fallback.

- PptxPreview.lifecycle.test.tsx: 4 jsdom tests using a vi.mock'd
  @aiden0z/pptx-renderer to verify:
  * destroy() is called when PptxViewer.open() rejects mid-construction
  * a thrown onReady does NOT trigger fallback or onError
  * renderList failure triggers onError (mode rollback path)
  * onError fires exactly once after fallback completes

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-22 17:42:41 +08:00