pdf-mapview 0.1.0

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.
package/LICENSE ADDED
@@ -0,0 +1,12 @@
1
+ Copyright (C) 2026 JR Bussard
2
+
3
+ Permission to use, copy, modify, and/or distribute this software for any
4
+ purpose with or without fee is hereby granted.
5
+
6
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
7
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
8
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
9
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
10
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
11
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
12
+ PERFORMANCE OF THIS SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,197 @@
1
+ # `pdf-mapview`
2
+
3
+ `pdf-mapview` is a React viewer and ingest toolkit for turning large PDFs, floorplans, and images into smooth, map-like experiences with static tiles, manifests, and normalized overlays.
4
+
5
+ ## What it ships
6
+
7
+ - `pdf-mapview`: shared types, manifest helpers, schemas
8
+ - `pdf-mapview/client`: React viewer runtime
9
+ - `pdf-mapview/ingest`: Node ingest APIs, storage adapters, CLI
10
+ - `pdf-mapview/server`: server-safe re-export of ingest utilities
11
+
12
+ This package is not a hosted service. You can generate static tiles locally, upload them anywhere, or plug in a custom storage adapter.
13
+
14
+ The ingest pipeline is pure Node and uses prebuilt npm modules. PDF pages are rasterized with `pdfjs-dist` plus `@napi-rs/canvas`, and image normalization, resizing, tile generation, and preview generation are handled by `sharp`. There is no required system CLI or hosted backend.
15
+
16
+ ## Install
17
+
18
+ ```bash
19
+ npm install pdf-mapview react react-dom
20
+ ```
21
+
22
+ ## Viewer usage
23
+
24
+ ### Tile source
25
+
26
+ ```tsx
27
+ import { TileMapViewer } from "pdf-mapview/client";
28
+
29
+ function Floorplan({ manifest }: { manifest: any }) {
30
+ return (
31
+ <div style={{ height: 720 }}>
32
+ <TileMapViewer
33
+ source={{
34
+ type: "tiles",
35
+ manifest,
36
+ baseUrl: "/maps/site-plan-001",
37
+ }}
38
+ />
39
+ </div>
40
+ );
41
+ }
42
+ ```
43
+
44
+ ### Image source
45
+
46
+ ```tsx
47
+ <TileMapViewer
48
+ source={{
49
+ type: "image",
50
+ src: "/floorplan.png",
51
+ width: 8000,
52
+ height: 6000,
53
+ }}
54
+ />
55
+ ```
56
+
57
+ ### PDF fallback source
58
+
59
+ ```tsx
60
+ <TileMapViewer
61
+ source={{
62
+ type: "pdf",
63
+ file: "/plan.pdf",
64
+ page: 1,
65
+ }}
66
+ />
67
+ ```
68
+
69
+ ### Regions
70
+
71
+ ```tsx
72
+ const regions = [
73
+ {
74
+ id: "suite-a",
75
+ label: "Suite A",
76
+ geometry: {
77
+ type: "rectangle",
78
+ rect: { x: 0.1, y: 0.2, width: 0.15, height: 0.12 },
79
+ },
80
+ },
81
+ ];
82
+
83
+ <TileMapViewer
84
+ source={{ type: "tiles", manifest }}
85
+ regions={regions}
86
+ onRegionClick={(region) => console.log(region.id)}
87
+ />
88
+ ```
89
+
90
+ ## Ingest usage
91
+
92
+ ### Local output
93
+
94
+ ```ts
95
+ import { ingestPdf, localStorageAdapter } from "pdf-mapview/ingest";
96
+
97
+ const result = await ingestPdf({
98
+ input: "./plans/site-plan.pdf",
99
+ page: 1,
100
+ id: "site-plan-001",
101
+ storage: localStorageAdapter({
102
+ baseDir: "./public/maps/site-plan-001",
103
+ clean: true,
104
+ }),
105
+ });
106
+ ```
107
+
108
+ ### In-memory / custom upload flow
109
+
110
+ ```ts
111
+ import { ingestImage, memoryStorageAdapter } from "pdf-mapview/ingest";
112
+
113
+ const result = await ingestImage({
114
+ input: imageBuffer,
115
+ id: "floor-02",
116
+ storage: memoryStorageAdapter(),
117
+ });
118
+ ```
119
+
120
+ ### S3-compatible storage
121
+
122
+ ```ts
123
+ import { ingestPdf, s3CompatibleStorageAdapter } from "pdf-mapview/ingest";
124
+
125
+ const storage = s3CompatibleStorageAdapter({
126
+ prefix: "maps/site-plan-001",
127
+ baseUrl: "https://cdn.example.com",
128
+ async putObject({ key, body, contentType, cacheControl }) {
129
+ await myObjectStore.put(key, body, { contentType, cacheControl });
130
+ return { url: `https://cdn.example.com/${key}` };
131
+ },
132
+ });
133
+
134
+ const result = await ingestPdf({
135
+ input: "./plans/site-plan.pdf",
136
+ id: "site-plan-001",
137
+ storage,
138
+ });
139
+ ```
140
+
141
+ ## CLI
142
+
143
+ ```bash
144
+ pdf-mapview ingest ./plans/site-plan.pdf \
145
+ --page 1 \
146
+ --id site-plan-001 \
147
+ --out-dir ./public/maps/site-plan-001
148
+ ```
149
+
150
+ ## Manifest
151
+
152
+ Generated manifests are versioned and viewer-complete. The viewer can load tiles from static hosting, object storage, or signed URL providers.
153
+
154
+ ```json
155
+ {
156
+ "version": 1,
157
+ "kind": "pdf-map",
158
+ "id": "site-plan-001",
159
+ "source": {
160
+ "type": "pdf",
161
+ "page": 1,
162
+ "width": 12000,
163
+ "height": 9000
164
+ },
165
+ "tiles": {
166
+ "tileSize": 256,
167
+ "format": "webp",
168
+ "minZoom": 0,
169
+ "maxZoom": 6,
170
+ "pathTemplate": "tiles/{z}/{x}/{y}.webp"
171
+ }
172
+ }
173
+ ```
174
+
175
+ ## TanStack Start
176
+
177
+ Client code should import only from `pdf-mapview/client`, and ingest code should live in server functions or build steps via `pdf-mapview/server`.
178
+
179
+ See the TanStack Start example notes:
180
+
181
+ - [examples/tanstack-start/README.md](https://github.com/pirut/pdf-mapview/blob/main/examples/tanstack-start/README.md)
182
+
183
+ ## Publishing
184
+
185
+ Before running `npm publish`, confirm:
186
+
187
+ ```bash
188
+ npm test
189
+ npm run build
190
+ npm pack --dry-run
191
+ ```
192
+
193
+ For an unscoped package:
194
+
195
+ ```bash
196
+ npm publish
197
+ ```