@octostar/map-component 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.
- package/LICENSE +18 -0
- package/README.md +110 -0
- package/dist/index.cjs +11377 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.mjs +11358 -0
- package/dist/index.mjs.map +1 -0
- package/dist/styles.css +1353 -0
- package/fonts/Noto Sans Bold/0-255.pbf +0 -0
- package/fonts/Noto Sans Bold/1024-1279.pbf +0 -0
- package/fonts/Noto Sans Bold/256-511.pbf +0 -0
- package/fonts/Noto Sans Bold/512-767.pbf +0 -0
- package/fonts/Noto Sans Bold/768-1023.pbf +0 -0
- package/fonts/Noto Sans Bold/8192-8447.pbf +0 -0
- package/fonts/Noto Sans Italic/0-255.pbf +0 -0
- package/fonts/Noto Sans Italic/1024-1279.pbf +0 -0
- package/fonts/Noto Sans Italic/256-511.pbf +0 -0
- package/fonts/Noto Sans Italic/512-767.pbf +0 -0
- package/fonts/Noto Sans Italic/768-1023.pbf +0 -0
- package/fonts/Noto Sans Italic/8192-8447.pbf +0 -0
- package/fonts/Noto Sans Regular/0-255.pbf +0 -0
- package/fonts/Noto Sans Regular/1024-1279.pbf +0 -0
- package/fonts/Noto Sans Regular/256-511.pbf +0 -0
- package/fonts/Noto Sans Regular/512-767.pbf +0 -0
- package/fonts/Noto Sans Regular/768-1023.pbf +0 -0
- package/fonts/Noto Sans Regular/8192-8447.pbf +0 -0
- package/package.json +194 -0
- package/vite-plugin.d.mts +3 -0
- package/vite-plugin.mjs +74 -0
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@octostar/map-component",
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"license": "UNLICENSED",
|
|
6
|
+
"packageManager": "pnpm@9.15.0",
|
|
7
|
+
"description": "MapLibre-based map editor component",
|
|
8
|
+
"main": "./dist/index.cjs",
|
|
9
|
+
"module": "./dist/index.mjs",
|
|
10
|
+
"types": "./dist/types/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"import": {
|
|
14
|
+
"types": "./dist/types/index.d.ts",
|
|
15
|
+
"default": "./dist/index.mjs"
|
|
16
|
+
},
|
|
17
|
+
"require": {
|
|
18
|
+
"types": "./dist/types/index.d.ts",
|
|
19
|
+
"default": "./dist/index.cjs"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"./styles.css": "./dist/styles.css",
|
|
23
|
+
"./vite": {
|
|
24
|
+
"types": "./vite-plugin.d.mts",
|
|
25
|
+
"default": "./vite-plugin.mjs"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"dist",
|
|
30
|
+
"fonts",
|
|
31
|
+
"vite-plugin.mjs",
|
|
32
|
+
"vite-plugin.d.mts",
|
|
33
|
+
"README.md"
|
|
34
|
+
],
|
|
35
|
+
"sideEffects": [
|
|
36
|
+
"*.css"
|
|
37
|
+
],
|
|
38
|
+
"scripts": {
|
|
39
|
+
"dev": "NODE_ENV=development tsx server/index.ts",
|
|
40
|
+
"build": "tsx script/build.ts",
|
|
41
|
+
"build:lib": "vite build --config vite.config.lib.ts && tsc -p tsconfig.build.json",
|
|
42
|
+
"start": "NODE_ENV=production node dist-app/index.cjs",
|
|
43
|
+
"check": "tsc",
|
|
44
|
+
"typecheck": "tsc --noEmit",
|
|
45
|
+
"db:push": "drizzle-kit push",
|
|
46
|
+
"prepare": "pnpm run build:lib",
|
|
47
|
+
"prepublishOnly": "pnpm run build:lib"
|
|
48
|
+
},
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
51
|
+
"react-dom": "^18.0.0 || ^19.0.0"
|
|
52
|
+
},
|
|
53
|
+
"peerDependenciesMeta": {
|
|
54
|
+
"react": {
|
|
55
|
+
"optional": false
|
|
56
|
+
},
|
|
57
|
+
"react-dom": {
|
|
58
|
+
"optional": false
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"dependencies": {
|
|
62
|
+
"@ant-design/icons": "^6.0.0",
|
|
63
|
+
"@mapbox/mapbox-gl-draw": "^1.5.1",
|
|
64
|
+
"@mapbox/togeojson": "^0.16.2",
|
|
65
|
+
"@turf/turf": "^7.3.1",
|
|
66
|
+
"antd": "^5.27.2",
|
|
67
|
+
"class-variance-authority": "^0.7.1",
|
|
68
|
+
"clsx": "^2.1.1",
|
|
69
|
+
"date-fns": "^3.6.0",
|
|
70
|
+
"dayjs": "^1.11.19",
|
|
71
|
+
"file-saver": "^2.0.5",
|
|
72
|
+
"lucide-react": "^0.453.0",
|
|
73
|
+
"maplibre-gl": "^5.14.0",
|
|
74
|
+
"proj4": "^2.20.2",
|
|
75
|
+
"tailwind-merge": "^2.6.0",
|
|
76
|
+
"three": "^0.182.0",
|
|
77
|
+
"zustand": "^5.0.9"
|
|
78
|
+
},
|
|
79
|
+
"devDependencies": {
|
|
80
|
+
"@hookform/resolvers": "^3.10.0",
|
|
81
|
+
"@jridgewell/trace-mapping": "^0.3.25",
|
|
82
|
+
"@radix-ui/react-accordion": "^1.2.4",
|
|
83
|
+
"@radix-ui/react-alert-dialog": "^1.1.7",
|
|
84
|
+
"@radix-ui/react-aspect-ratio": "^1.1.3",
|
|
85
|
+
"@radix-ui/react-avatar": "^1.1.4",
|
|
86
|
+
"@radix-ui/react-checkbox": "^1.1.5",
|
|
87
|
+
"@radix-ui/react-collapsible": "^1.1.4",
|
|
88
|
+
"@radix-ui/react-context-menu": "^2.2.7",
|
|
89
|
+
"@radix-ui/react-dialog": "^1.1.7",
|
|
90
|
+
"@radix-ui/react-dropdown-menu": "^2.1.7",
|
|
91
|
+
"@radix-ui/react-hover-card": "^1.1.7",
|
|
92
|
+
"@radix-ui/react-label": "^2.1.3",
|
|
93
|
+
"@radix-ui/react-menubar": "^1.1.7",
|
|
94
|
+
"@radix-ui/react-navigation-menu": "^1.2.6",
|
|
95
|
+
"@radix-ui/react-popover": "^1.1.7",
|
|
96
|
+
"@radix-ui/react-progress": "^1.1.3",
|
|
97
|
+
"@radix-ui/react-radio-group": "^1.2.4",
|
|
98
|
+
"@radix-ui/react-scroll-area": "^1.2.4",
|
|
99
|
+
"@radix-ui/react-select": "^2.1.7",
|
|
100
|
+
"@radix-ui/react-separator": "^1.1.3",
|
|
101
|
+
"@radix-ui/react-slider": "^1.2.4",
|
|
102
|
+
"@radix-ui/react-slot": "^1.2.0",
|
|
103
|
+
"@radix-ui/react-switch": "^1.1.4",
|
|
104
|
+
"@radix-ui/react-tabs": "^1.1.4",
|
|
105
|
+
"@radix-ui/react-toast": "^1.2.7",
|
|
106
|
+
"@radix-ui/react-toggle": "^1.1.3",
|
|
107
|
+
"@radix-ui/react-toggle-group": "^1.1.3",
|
|
108
|
+
"@radix-ui/react-tooltip": "^1.2.0",
|
|
109
|
+
"@replit/vite-plugin-cartographer": "^0.4.4",
|
|
110
|
+
"@replit/vite-plugin-dev-banner": "^0.1.1",
|
|
111
|
+
"@replit/vite-plugin-runtime-error-modal": "^0.0.3",
|
|
112
|
+
"@tailwindcss/typography": "^0.5.15",
|
|
113
|
+
"@tailwindcss/vite": "^4.1.3",
|
|
114
|
+
"@tanstack/react-query": "^5.60.5",
|
|
115
|
+
"@types/connect-pg-simple": "^7.0.3",
|
|
116
|
+
"@types/express": "4.17.21",
|
|
117
|
+
"@types/express-session": "^1.18.0",
|
|
118
|
+
"@types/file-saver": "^2.0.7",
|
|
119
|
+
"@types/mapbox__mapbox-gl-draw": "^1.4.9",
|
|
120
|
+
"@types/node": "20.16.11",
|
|
121
|
+
"@types/passport": "^1.0.16",
|
|
122
|
+
"@types/passport-local": "^1.0.38",
|
|
123
|
+
"@types/proj4": "^2.5.6",
|
|
124
|
+
"@types/react": "^18.3.11",
|
|
125
|
+
"@types/react-dom": "^18.3.1",
|
|
126
|
+
"@types/three": "^0.182.0",
|
|
127
|
+
"@types/ws": "^8.5.13",
|
|
128
|
+
"@vitejs/plugin-react": "^4.7.0",
|
|
129
|
+
"autoprefixer": "^10.4.20",
|
|
130
|
+
"cmdk": "^1.1.1",
|
|
131
|
+
"connect-pg-simple": "^10.0.0",
|
|
132
|
+
"drizzle-kit": "^0.31.4",
|
|
133
|
+
"drizzle-orm": "^0.39.3",
|
|
134
|
+
"drizzle-zod": "^0.7.0",
|
|
135
|
+
"embla-carousel-react": "^8.6.0",
|
|
136
|
+
"esbuild": "^0.25.0",
|
|
137
|
+
"express": "^4.21.2",
|
|
138
|
+
"express-session": "^1.18.1",
|
|
139
|
+
"framer-motion": "^11.13.1",
|
|
140
|
+
"input-otp": "^1.4.2",
|
|
141
|
+
"memorystore": "^1.6.7",
|
|
142
|
+
"nanoid": "^5.0.9",
|
|
143
|
+
"next-themes": "^0.4.6",
|
|
144
|
+
"passport": "^0.7.0",
|
|
145
|
+
"passport-local": "^1.0.0",
|
|
146
|
+
"pg": "^8.16.3",
|
|
147
|
+
"postcss": "^8.4.47",
|
|
148
|
+
"prism-react-renderer": "^2.4.1",
|
|
149
|
+
"react": "^18.3.1",
|
|
150
|
+
"react-day-picker": "^8.10.1",
|
|
151
|
+
"react-dom": "^18.3.1",
|
|
152
|
+
"react-hook-form": "^7.55.0",
|
|
153
|
+
"react-icons": "^5.4.0",
|
|
154
|
+
"react-resizable-panels": "^2.1.7",
|
|
155
|
+
"recharts": "^2.15.2",
|
|
156
|
+
"tailwindcss": "^3.4.17",
|
|
157
|
+
"tailwindcss-animate": "^1.0.7",
|
|
158
|
+
"tsx": "^4.20.5",
|
|
159
|
+
"tw-animate-css": "^1.2.5",
|
|
160
|
+
"typescript": "5.6.3",
|
|
161
|
+
"vaul": "^1.1.2",
|
|
162
|
+
"vite": "^5.4.20",
|
|
163
|
+
"wouter": "^3.3.5",
|
|
164
|
+
"ws": "^8.18.0",
|
|
165
|
+
"zod": "^3.24.2",
|
|
166
|
+
"zod-validation-error": "^3.4.0"
|
|
167
|
+
},
|
|
168
|
+
"optionalDependencies": {
|
|
169
|
+
"bufferutil": "^4.0.8"
|
|
170
|
+
},
|
|
171
|
+
"repository": {
|
|
172
|
+
"type": "git",
|
|
173
|
+
"url": "https://github.com/octostarco/octostar-map-component.git"
|
|
174
|
+
},
|
|
175
|
+
"publishConfig": {
|
|
176
|
+
"access": "public",
|
|
177
|
+
"registry": "https://registry.npmjs.org"
|
|
178
|
+
},
|
|
179
|
+
"keywords": [
|
|
180
|
+
"map",
|
|
181
|
+
"maplibre",
|
|
182
|
+
"geojson",
|
|
183
|
+
"react",
|
|
184
|
+
"editor",
|
|
185
|
+
"drawing",
|
|
186
|
+
"gis"
|
|
187
|
+
],
|
|
188
|
+
"pnpm": {
|
|
189
|
+
"overrides": {
|
|
190
|
+
"esbuild@<=0.24.2": ">=0.25.0",
|
|
191
|
+
"qs@<6.14.1": ">=6.14.1"
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
package/vite-plugin.mjs
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { dirname, join } from 'node:path';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
|
|
5
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
6
|
+
const fontsDir = join(__dirname, 'fonts');
|
|
7
|
+
|
|
8
|
+
const FONT_VARIANTS = fs.existsSync(fontsDir)
|
|
9
|
+
? fs.readdirSync(fontsDir).filter(f => fs.statSync(join(fontsDir, f)).isDirectory())
|
|
10
|
+
: [];
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Map a composite font stack (e.g. "Montserrat Regular,Open Sans Regular,Noto Sans Regular")
|
|
14
|
+
* to the best locally available Noto Sans variant by inspecting keywords in the stack.
|
|
15
|
+
*/
|
|
16
|
+
function resolveFontStack(fontstack) {
|
|
17
|
+
const lower = fontstack.toLowerCase();
|
|
18
|
+
if (lower.includes('bold') || lower.includes('semibold') || lower.includes('medium')) {
|
|
19
|
+
return 'Noto Sans Bold';
|
|
20
|
+
}
|
|
21
|
+
if (lower.includes('italic') || lower.includes('oblique')) {
|
|
22
|
+
return 'Noto Sans Italic';
|
|
23
|
+
}
|
|
24
|
+
return 'Noto Sans Regular';
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function fontsMiddleware(req, res, next) {
|
|
28
|
+
const decoded = decodeURIComponent(req.url);
|
|
29
|
+
// Expected shape: /<fontstack>/<range>.pbf
|
|
30
|
+
const match = decoded.match(/^\/([^/]+)\/(\d+-\d+\.pbf)$/);
|
|
31
|
+
if (!match) return next();
|
|
32
|
+
|
|
33
|
+
const [, requestedStack, rangeFile] = match;
|
|
34
|
+
|
|
35
|
+
// Try exact match first, then fall back to resolved variant
|
|
36
|
+
let fontDir = requestedStack;
|
|
37
|
+
let filePath = join(fontsDir, fontDir, rangeFile);
|
|
38
|
+
|
|
39
|
+
if (!fs.existsSync(filePath)) {
|
|
40
|
+
fontDir = resolveFontStack(requestedStack);
|
|
41
|
+
filePath = join(fontsDir, fontDir, rangeFile);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (fs.existsSync(filePath)) {
|
|
45
|
+
res.setHeader('Content-Type', 'application/x-protobuf');
|
|
46
|
+
res.setHeader('Cache-Control', 'public, max-age=86400');
|
|
47
|
+
fs.createReadStream(filePath).pipe(res);
|
|
48
|
+
} else {
|
|
49
|
+
next();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Vite plugin that serves the map component's bundled glyph fonts at /fonts/.
|
|
55
|
+
* Works with the default glyphsUrl ('/fonts/{fontstack}/{range}.pbf').
|
|
56
|
+
*
|
|
57
|
+
* Composite font stacks from tile styles (e.g. "Montserrat Regular,Open Sans Regular")
|
|
58
|
+
* are automatically mapped to the bundled Noto Sans variants.
|
|
59
|
+
*
|
|
60
|
+
* Usage:
|
|
61
|
+
* import { mapFontsPlugin } from '@octostar/map-component/vite';
|
|
62
|
+
* export default defineConfig({ plugins: [react(), mapFontsPlugin()] });
|
|
63
|
+
*/
|
|
64
|
+
export function mapFontsPlugin() {
|
|
65
|
+
return {
|
|
66
|
+
name: 'octostar-map-fonts',
|
|
67
|
+
configureServer(server) {
|
|
68
|
+
server.middlewares.use('/fonts', fontsMiddleware);
|
|
69
|
+
},
|
|
70
|
+
configurePreviewServer(server) {
|
|
71
|
+
server.middlewares.use('/fonts', fontsMiddleware);
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
}
|