Skip to content

feat: upgrade cad-viewer to v1.7.8 with open options - #3

Merged
mlightcad merged 1 commit into
mainfrom
feat/upgrade-cad-viewer-1.7.8
Nov 4, 2026
Merged

mlightcad merged 1 commit into
mainfrom
feat/upgrade-cad-viewer-1.7.8

Conversation

@mlightcad

Copy link
Copy Markdown
Owner

Upgrades the whole @mlightcad stack to 1.7.8 and exposes the new open-time options on the upload screen.

Dependencies

Package Before After
@mlightcad/cad-viewer (and plugins / simple-viewer) 1.6.0 1.7.8
@mlightcad/data-model ^1.13.0 1.15.21
@mlightcad/libredwg-converter ^3.13.0 3.15.21
three ^0.172.0 ^0.186.1

@mlightcad/cad-viewer 1.7.8 declares exact peers, so data-model / libredwg-converter are now pinned exactly instead of using ^ ranges. Two copies of data-model make the DWG converter register against a different AcDbDatabaseConverterManager than the one the viewer opens with.

Features

  • Curve quality — passes ACDB_DRAW_CIRCLE_SIDES_* as circleSides (Memory / Standard / Quality).
  • Paper background — sets sysVars.paperbkcolor via layoutBackgroundColorFromRgb() for new drawings.
  • Export toggle — forwards disableExport to MlCadViewer.
  • All open options are now one AcApOpenOptionsPayload instead of six positional emit arguments, so adding an option touches one interface.
  • Draw thread control is relabelled (Worker / Main thread) — it previously sat under a "Text rendering" heading, which was misleading. Default remains the main thread, matching the library default.

Integration fixes required by 1.7.x

  • Install the viewer's own vue-i18n instance once before mounting (app.use(i18n)), otherwise components throw Need to install with app.use function. Host command messages are merged into both AcApI18n and that instance.
  • Pin this demo's localStorage key with AcApSettingManager.configure({ storageKey }) so it stops sharing persisted prefs with other cad-* demos on the same origin.
  • Capture the Vue app context at setup time — getCurrentInstance() is null inside the async loader.
  • Resolve three / @mlightcad renderer peers from this package so imports inside the viewer's prebuilt dist bundle correctly under pnpm's isolated layout.

Bundling

The chunking rules moved to vite/rollupOutput.ts, next to the peer aliases. Two rules are load-bearing for the lazy import() of @mlightcad/cad-viewer and are easy to lose when tuning manualChunks:

  1. vue, @vue/*, lodash-es, lodash-unified → vendor. The upload screen imports Vue statically through element-plus; if Rollup folds Vue into a viewer package chunk, the entry statically depends on that whole chunk.
  2. Vite's \0 virtual helpers (preload-helper.js, commonjsHelpers.js) → vite-helpers. They are pulled in statically by modules that also use a dynamic import(), so wherever Rollup parks them, their importer follows.

Measured effect on the eager entry payload (entry + everything it statically imports):

Eager JS
main before this PR ~155 kB
main with upgrade but without the two rules ~5,274 kB
This PR 184 kB

The rest stays lazy: cad-viewer 1.4 MB, cad-simple-viewer 1.4 MB, data-model 1.4 MB, three-renderer 1.0 MB, cad-pdf-plugin 4.6 MB.

Also:

  • Copies the LibreDWG wasm next to its worker, and skips worker/runtime copies whose source is missing instead of failing the build.
  • Excludes lazily imported viewer packages from dev pre-bundling and pre-bundles the PDF stack, so the first PDF plugin import no longer forces a full-page reload.
  • Adds pnpm analyze (rollup-plugin-visualizer, stats.html is gitignored).
  • Restores the html/body/#app reset in index.html — it was dropped accidentally, and the upload screen relies on it for full-height layout.
  • Drops the unused vite-svg-loader plugin; nothing in this app or in the viewer dist imports an .svg file as a component.

Verification

  • pnpm install --frozen-lockfile — reproducible, single data-model copy.
  • vue-tsc --noEmit and pnpm build — clean.
  • pnpm analyze — writes stats.html.
  • Dev-server smoke test: upload screen renders at desktop and 390×640, no page scrollbars; New Drawing mounts the viewer, canvas present, File menu shows all export items (disableExport=false), zero console errors.

Upgrade the whole @mlightcad stack to 1.7.8 (data-model 1.15.21,
libredwg-converter 3.15.21, three 0.186.1) and expose the new open-time
options on the upload screen.

Features
- Curve quality: pass ACDB_DRAW_CIRCLE_SIDES_* as open options.circleSides.
- Paper background: set sysVars.paperbkcolor via
  layoutBackgroundColorFromRgb() for new drawings.
- Export toggle: forward disableExport to MlCadViewer.
- Group all open options into one AcApOpenOptionsPayload instead of six
  positional emit arguments.
- Draw thread control is now labelled by what it does (Worker / Main
  thread) rather than "Text rendering"; the default stays on the main
  thread, matching the library default.

Integration fixes required by 1.7.x
- Install the viewer's own vue-i18n instance once before mounting, and
  merge host command messages into both AcApI18n and that instance.
- Pin this demo's localStorage key through AcApSettingManager.configure()
  so it does not share persisted prefs with other cad-* demos.
- Capture the Vue app context at setup time; getCurrentInstance() is null
  inside the async loader.
- Resolve three / @mlightcad renderer peers from this package so imports
  inside the viewer's prebuilt dist bundle correctly under pnpm.

Bundling
- Move the Rollup chunking rules into vite/rollupOutput.ts alongside the
  peer aliases, and add vue / @vue/* / lodash to a vendor chunk plus
  Vite's \0 virtual helpers to their own chunk. Without those two rules
  Rollup folds the framework runtime into a viewer chunk, the entry
  statically depends on it, and eager JS grows from ~184 kB to ~5.2 MB.
- Copy the LibreDWG wasm next to its worker, and skip worker/runtime
  copies whose source is missing instead of failing the build.
- Exclude the lazily imported viewer packages from dev pre-bundling and
  pre-bundle the PDF stack so the first PDF plugin import does not force
  a full page reload.
- Add `pnpm analyze` (rollup-plugin-visualizer, output gitignored).

Also document the chunking invariants and the exact-peer version
alignment in the README.
@netlify

netlify Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for mlightcad ready!

Name Link
🔨 Latest commit d794fee
🔍 Latest deploy log https://app.netlify.com/projects/mlightcad/deploys/6aeb2e3d9cef18f7c7253cc1
😎 Deploy Preview https://deploy-preview-3--mlightcad.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@mlightcad
mlightcad merged commit 44fca6d into main Nov 4, 2026
6 checks passed
@mlightcad
mlightcad deleted the feat/upgrade-cad-viewer-1.7.8 branch November 4, 2026 13:16
@mlightcad mlightcad self-assigned this Nov 4, 2026
@mlightcad mlightcad added the enhancement New feature or request label Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant