gerbers-renderer 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +175 -3
  2. package/package.json +4 -2
package/README.md CHANGED
@@ -1,6 +1,178 @@
1
1
  # gerbers-renderer
2
- Renders PCB gerbers
3
2
 
3
+ Frontend-only Gerber viewer for the web.
4
+ Render PCB Gerbers directly in the browser. No backend. No CAM tools. No DFM.
5
+
6
+ 👉 Upload a gerbers.zip
7
+ 👉 View Top / Bottom copper, mask, silkscreen, drills
8
+ 👉 Pan, zoom, fit, grid
9
+ 👉 Download the original Gerbers ZIP
10
+
11
+ ## ✨ Features
12
+
13
+ - Fully client-side (runs in the browser)
14
+ - Accepts standard gerbers.zip exports
15
+ - Automatic layer classification
16
+ - Correct board masking and clipping
17
+ - Top / Bottom view toggle
18
+ - Grid overlay (mm / inch)
19
+ - Designed to embed into any website
20
+ - No framework dependency (not React/Vue/etc.)
21
+
22
+ ## 🚀 Installation
23
+
24
+ ### Install from npm (recommended)
25
+ ```bash
26
+ npm install gerbers-renderer
27
+ ```
28
+
29
+ ### 🌐 CDN Usage (No Build Tools)
30
+ ```html
31
+ <script src="https://unpkg.com/gerbers-renderer"></script>
32
+ <script>
33
+ const { createBoardViewer, renderGerbersZip } = window.GerbersRenderer;
34
+ </script>
35
+ ```
36
+
37
+ Pin a version if needed:
38
+
39
+ ```html
40
+ <script src="https://unpkg.com/gerbers-renderer@0.1.0"></script>
41
+ ```
42
+
43
+ ## 🧩 Minimal Usage Example
44
+
45
+ **HTML**
46
+ ```html
47
+ <input type="file" id="file" accept=".zip" />
48
+ <div id="viewer" style="width:100%; height:600px;"></div>
49
+ ```
50
+
51
+ **JavaScript / TypeScript**
52
+ ```typescript
53
+ import { renderGerbersZip, createBoardViewer } from "gerbers-renderer";
54
+
55
+ const input = document.getElementById("file") as HTMLInputElement;
56
+ const host = document.getElementById("viewer")!;
57
+
58
+ const viewer = createBoardViewer(host, {
59
+ onDownload: () => {
60
+ if (!lastZip) return;
61
+ const a = document.createElement("a");
62
+ const url = URL.createObjectURL(lastZip);
63
+ a.href = url;
64
+ a.download = lastZip.name;
65
+ a.click();
66
+ URL.revokeObjectURL(url);
67
+ }
68
+ });
69
+
70
+ let lastRender: any = null;
71
+ let lastZip: File | null = null;
72
+
73
+ input.addEventListener("change", async () => {
74
+ const file = input.files?.[0];
75
+ if (!file) return;
76
+
77
+ lastZip = file;
78
+ if (lastRender) lastRender.revoke();
79
+
80
+ const out = await renderGerbersZip(file);
81
+ lastRender = out;
82
+
83
+ viewer.setData({
84
+ boardGeom: out.boardGeom,
85
+ layers: out.layers
86
+ });
87
+ });
88
+ ```
89
+
90
+ That's it. No server. No workers. No build assumptions.
91
+
92
+ ## 🧠 Core API
93
+
94
+ ### `renderGerbersZip(file: File)`
95
+
96
+ Parses and renders a Gerbers ZIP entirely in the browser.
97
+
98
+ **Returns:**
99
+ ```typescript
100
+ {
101
+ boardGeom: {
102
+ widthMm: number;
103
+ heightMm: number;
104
+ },
105
+ layers: {
106
+ top_copper?: string;
107
+ bottom_copper?: string;
108
+ top_silk?: string;
109
+ bottom_silk?: string;
110
+ top_mask?: string;
111
+ bottom_mask?: string;
112
+ drills?: string;
113
+ top_board_mask?: string;
114
+ bottom_board_mask?: string;
115
+ },
116
+ revoke: () => void
117
+ }
4
118
  ```
5
- npm run dev
6
- ```
119
+
120
+ Layer values are blob URLs containing SVGs.
121
+
122
+ Call `revoke()` when replacing or discarding a render.
123
+
124
+ ### `createBoardViewer(host, options?)`
125
+
126
+ Mounts an interactive PCB viewer into a DOM element.
127
+
128
+ ```typescript
129
+ createBoardViewer(host, {
130
+ onDownload?: () => void
131
+ });
132
+ ```
133
+
134
+ The viewer handles:
135
+ - pan / zoom / fit
136
+ - Top / Bottom switching
137
+ - layer visibility
138
+ - board clipping mask
139
+
140
+ The viewer is intentionally stateless with respect to parsing.
141
+
142
+ ## 📦 Download Behavior
143
+
144
+ The viewer does not decide what "Download" means.
145
+
146
+ Instead, you supply a handler via `onDownload`.
147
+
148
+ Typical use:
149
+ - download the original gerbers.zip
150
+ - export SVG layers
151
+ - export screenshots
152
+ - pipe into manufacturing workflows
153
+
154
+ This keeps the viewer reusable across products.
155
+
156
+ ## 🧭 Design Philosophy
157
+
158
+ - Viewer ≠ parser ≠ renderer
159
+ - Frontend-only by design
160
+ - No assumptions about backend or manufacturing
161
+ - Safe to embed anywhere
162
+ - Easy to extend
163
+
164
+ This project is intentionally not a CAM tool or DFM checker.
165
+
166
+ ## ❌ What This Is Not
167
+
168
+ - Not a DFM rules engine
169
+ - Not a fabrication quote system
170
+ - Not a replacement for CAM software
171
+
172
+ It's a fast, embeddable Gerber viewer.
173
+
174
+ ## 📄 License
175
+
176
+ MIT
177
+
178
+ Use it freely in commercial or open-source projects.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gerbers-renderer",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "A frontend-only Gerber viewer for rendering PCB Gerbers directly in the browser.",
5
5
  "private": false,
6
6
  "type": "module",
@@ -16,7 +16,9 @@
16
16
  "unpkg": "./dist/gerbers-renderer.umd.js",
17
17
  "jsdelivr": "./dist/gerbers-renderer.umd.js",
18
18
  "files": [
19
- "dist"
19
+ "dist",
20
+ "README.md",
21
+ "LICENSE"
20
22
  ],
21
23
  "scripts": {
22
24
  "dev": "vite",