npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@cadview/dwg

v0.2.0

Published

DWG file format support for @cadview/core via LibreDWG WASM

Readme

@cadview/dwg

DWG file format support for @cadview/core via LibreDWG compiled to WebAssembly.

Converts DWG files to DXF entirely in the browser — no server required.

License

GPL-3.0-only — This package uses LibreDWG which is GPL-licensed. Using @cadview/dwg in your application makes the combined work subject to GPL-3.0 terms. If you cannot comply with the GPL, do not use this package.

@cadview/core and the framework wrappers (@cadview/react, @cadview/svelte, @cadview/vue) remain MIT-licensed and have zero dependency on this package.

Installation

npm install @cadview/dwg @cadview/core

Quick Start

Register the dwgConverter with CadViewer to automatically handle DWG files alongside DXF:

import { CadViewer } from '@cadview/core';
import { dwgConverter } from '@cadview/dwg';

const viewer = new CadViewer(canvas, {
  formatConverters: [dwgConverter],
});

// loadFile() and loadBuffer() now handle both DXF and DWG
await viewer.loadFile(file);

With framework wrappers:

// React
import { CadViewer } from '@cadview/react';
import { dwgConverter } from '@cadview/dwg';

<CadViewer file={file} formatConverters={[dwgConverter]} />
<!-- Svelte -->
<script>
  import { CadViewer } from '@cadview/svelte';
  import { dwgConverter } from '@cadview/dwg';
</script>

<CadViewer {file} formatConverters={[dwgConverter]} />
<!-- Vue -->
<script setup>
import { CadViewer } from '@cadview/vue';
import { dwgConverter } from '@cadview/dwg';
</script>

<CadViewer :file="file" :format-converters="[dwgConverter]" />

Standalone Usage

You can use the conversion functions directly without CadViewer:

import { convertDwgToDxf, isDwg, getDwgVersion } from '@cadview/dwg';
import { parseDxf } from '@cadview/core';

// Check if a buffer is a DWG file
const buffer = await file.arrayBuffer();
if (isDwg(buffer)) {
  const version = getDwgVersion(buffer); // e.g. "AC1032"
  const dxfString = await convertDwgToDxf(buffer);
  const doc = parseDxf(dxfString);
}

WASM Preloading

The LibreDWG WASM module (~2-5 MB) is lazy-loaded on the first DWG conversion. To avoid the delay when the user first opens a DWG file, preload it on app startup:

import { initWasm } from '@cadview/dwg';

// Preload on app startup
initWasm();

// Or from a CDN
initWasm({ wasmUrl: 'https://cdn.example.com/libredwg.wasm' });

API

dwgConverter: FormatConverter

Pre-configured format converter for use with CadViewer's formatConverters option. Detects DWG files by magic bytes and converts via LibreDWG WASM.

isDwg(buffer: ArrayBuffer): boolean

Detect DWG format by checking magic bytes (AC10 prefix + two ASCII digits). Returns false on any error.

getDwgVersion(buffer: ArrayBuffer): string | null

Extract the 6-character DWG version string (e.g. "AC1032"). Returns null for non-DWG buffers.

getDwgReleaseName(version: string): string | null

Get the human-readable AutoCAD release name for a version string (e.g. "AC1032""R2018").

convertDwgToDxf(buffer: ArrayBuffer, options?: ConvertOptions): Promise<string>

Convert a DWG buffer to a DXF string. Lazily initializes the WASM module on first call.

Options:

| Option | Type | Default | Description | |--------|------|---------|-------------| | timeout | number | 30000 | Conversion timeout in ms (0 = no timeout) | | wasmUrl | string | — | Custom URL for the .wasm file (e.g. CDN) |

initWasm(options?: WasmOptions): Promise<void>

Pre-initialize the WASM module. Safe to call multiple times. Automatically retries on failure.

isWasmReady(): boolean

Check if the WASM module is loaded and ready.

DWG_VERSIONS: Record<string, string>

Map of known DWG version strings to AutoCAD release names:

| Version | Release | |---------|---------| | AC1009 | R11/R12 | | AC1012 | R13 | | AC1014 | R14 | | AC1015 | R2000 | | AC1018 | R2004 | | AC1021 | R2007 | | AC1024 | R2010 | | AC1027 | R2013 | | AC1032 | R2018 |

Minimum supported version: AC1012 (R13).

Building the WASM Module

The WASM module must be compiled from LibreDWG using Emscripten before DWG conversion will work at runtime.

Prerequisites:

# Add LibreDWG as a git submodule (one-time)
git submodule add https://github.com/LibreDWG/libredwg.git packages/dwg/wasm/libredwg/

# Build the WASM module
pnpm --filter @cadview/dwg build:wasm

This generates dist/libredwg.js and dist/libredwg.wasm.

License

GPL-3.0-only. See LICENSE.