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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@mlightcad/libdxfrw-web

v0.1.0

Published

a webassembly version of libdxfrw, which can read/write DXF files (in both formats, ascii and binary form) and read DWG files from AutoCAD R14 to AutoCAD 2020.

Downloads

229

Readme

libdxfrw-web

This is a webassembly version of libdxfrw which can be used in browser and Node.js environments. It supports the following features.

  • Read/write DXF files (in both formats, ascii and binary form).
  • Read DWG files from AutoCAD R14 to AutoCAD 2020.
  • Convert DWG file to DXF file.

You can play with it through this live demo.

Build WebAssembly

Download and install emscripten according to this doc.

Use auotmake

autoconf
automake --add-missing --force-missing
mkdir build
cd build
emconfigure ../configure
cd src
emmake make
emcc -O2 -lembind *.o intern/*.o -o libdxfrw.js -s ALLOW_MEMORY_GROWTH=1 -s MODULARIZE=1 -s EXPORT_NAME="createModule" --emit-tsd libdxfrw.d.ts

If you want to debug WebAssembly in Chrome DevTools. Please compile your application with DWARF debug information included. Run the latest Emscripten compiler and pass it the -g flag. For example:

emcc -g -lembind *.o intern/*.o -o libdxfrw.js -s ALLOW_MEMORY_GROWTH=1 -s MODULARIZE=1 -s EXPORT_NAME="createModule" --emit-tsd libdxfrw.d.ts

Use CMake

mkdir build
cd build
emcmake cmake .. -DCMAKE_BUILD_TYPE=Release
emmake make
emcc -O2 -lembind CMakeFiles/dxfrw.dir/src/*.o CMakeFiles/dxfrw.dir/src/intern/*.o -o libdxfrw.js -s ALLOW_MEMORY_GROWTH=1 -s MODULARIZE=1 -s EXPORT_NAME="createModule" --emit-tsd libdxfrw.d.ts

Usage

Please refer to example code in index.html. You can use the following command to install it as one of your package dependencies.

npm install @mlightcad/libdxfrw-web

How to iterate data represented by std::vector?

Emscripten doesn't convert std::vector to JavaScript array. So std::vector are converted to one seperated class. For example, std::vector are converted to the following class.

export interface DRW_DoubleList extends ClassHandle {
  push_back(_0: number): void;
  resize(_0: number, _1: number): void;
  size(): number;
  get(_0: number): number | undefined;
  set(_0: number, _1: number): boolean;
}

So it means you can't use JavaScript iterator to iterate them. For example, you need to iterate vertexes of one polyline as follows.

const vertexes = polyline.getVertexList();
for (let index = 0, size = vertexes.size(); index < size; ++index) {
  const vertex = vertexes.get(index);
  ......
}

Readonly list

I can't find one good way to expose property defined by one std container with std::shared_ptr. So one new public method is added for expose data defined by those properties. Values returned by those methods is are the copy of property data instead of the referernce. So it means that data stored in the property will not change after you changed data returned by those methods.

class DRW_Hatch : public DRW_Point {
  ......
public
  // Newly added method to expose data defined by property 'looplist'
  std::vector<DRW_HatchLoop*> getLoopList() const {
    std::vector<DRW_HatchLoop*> loopList;
    int loopnum = looplist.size();
    for (int i = 0; i< loopnum; i++){
      DRW_HatchLoop* loop = looplist.at(i).get();
      loopList.push_back(loop);
    }
    return loopList;
  }
  std::vector<std::shared_ptr<DRW_HatchLoop>> looplist;  /*!< polyline list */
  ......
}

The following methods use this pattern.

DRW_LWPolyline::getVertexList
DRW_Polyline::getVertexList
DRW_Spline::getControlList
DRW_Spline::getFitList
DRW_HatchLoop::getLoopList
DRW_Hatch::getLoopList

How to Debug?