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

dwgviewer-forthtech

v1.0.1

Published

React component for viewing DWG (AutoCAD) files in web browsers using WebAssembly and Canvas.

Readme

@forthtech/dwgviewer

A React component for viewing DWG (AutoCAD) files in web browsers using WebAssembly.

Installation

npm install @forthtech/dwgviewer

Basic Usage

import React, { useRef } from 'react';
import { DwgViewer, DwgViewerRef } from '@forthtech/dwgviewer';

function App() {
  const dwgViewerRef = useRef<DwgViewerRef>(null);

  const handleFileLoad = (filename: string) => {
    console.log('File loaded:', filename);
  };

  const handleError = (error: Error) => {
    console.error('Error:', error);
  };

  return (
    <div style={{ height: '600px', width: '800px' }}>
      <DwgViewer
        ref={dwgViewerRef}
        onFileLoad={handleFileLoad}
        onError={handleError}
        showControls={true}
        showConsole={false}
      />
    </div>
  );
}

export default App;

Props

DwgViewerProps

| Prop | Type | Default | Description | |------|------|---------|-------------| | className | string | '' | CSS class name for the container | | style | React.CSSProperties | {} | Inline styles for the container | | onFileLoad | (filename: string) => void | - | Called when a DWG file is loaded | | onError | (error: Error) => void | - | Called when an error occurs | | onModuleReady | (module: DwgModule) => void | - | Called when WebAssembly module is ready | | showControls | boolean | true | Show file upload and download controls | | showConsole | boolean | false | Show console output textarea | | wasmPath | string | './DrawingWeb.wasm' | Path to WebAssembly file | | jsPath | string | './DrawingWeb.js' | Path to WebAssembly JS loader | | assetsPath | string | '/assets' | Path for uploaded files |

Imperative API

The component exposes methods through a ref:

const dwgViewerRef = useRef<DwgViewerRef>(null);

// Open a file programmatically
const file = new File([...], 'drawing.dwg');
await dwgViewerRef.current?.openFile(file);

// Zoom to fit all content
dwgViewerRef.current?.zoomExtents();

// Manual zoom
dwgViewerRef.current?.zoom(-0.1, mouseX, mouseY);

// Download current file
dwgViewerRef.current?.downloadFile('drawing.dwg');

// Get WebAssembly module
const module = dwgViewerRef.current?.getModule();

Drawing Tools

You can enable different drawing tools using the global enableDragger function:

// Enable drawing tools
window.enableDragger?.('line');     // Line drawing
window.enableDragger?.('circle');   // Circle drawing
window.enableDragger?.('point');    // Point placement
window.enableDragger?.('polyline'); // Polyline drawing
window.enableDragger?.('text');     // Text placement

File Requirements

Make sure to include the WebAssembly files in your public directory:

  • DrawingWeb.js - WebAssembly loader
  • DrawingWeb.wasm - WebAssembly binary
  • statemachine.js - Drawing state machine

Mouse Controls

  • Left Click + Drag: Pan the view
  • Right Click + Drag: Orbit around the model
  • Mouse Wheel: Zoom in/out
  • Middle Click: Zoom to fit all content

Advanced Usage

Custom File Handling

import { FileHandler } from '@forthtech/dwgviewer';

const module = dwgViewerRef.current?.getModule();
if (module) {
  const fileHandler = new FileHandler(module);
  
  // Validate DWG file
  const isValid = fileHandler.validateDwgFile(file);
  
  // Upload file manually
  const filename = await fileHandler.uploadFile(file);
  
  // Download file
  fileHandler.downloadFile(filename);
}

WebAssembly Module Loading

import { wasmLoader } from '@forthtech/dwgviewer';

// Load module manually
const module = await wasmLoader.loadModule('./DrawingWeb.js');
console.log('Module loaded:', module);

Example Application

See the example directory for a complete React application demonstrating all features.

License

MIT

Credits

Based on the original DWG HTML viewer project by jigo961257.