@opengis/gis 0.1.11 → 0.1.13
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/package.json +6 -4
- package/plugin.js +0 -1
- package/server/plugins/vite.js +68 -0
- package/dist/import-file.cjs +0 -845
- package/dist/import-file.css +0 -1
- package/dist/import-file.js +0 -34154
- package/dist/vite.svg +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opengis/gis",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.13",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "Softpro",
|
|
6
6
|
"main": "import-file.js",
|
|
@@ -15,9 +15,10 @@
|
|
|
15
15
|
"LICENSE"
|
|
16
16
|
],
|
|
17
17
|
"scripts": {
|
|
18
|
-
"dev": "
|
|
19
|
-
"build": "vite build",
|
|
18
|
+
"dev": "node server",
|
|
19
|
+
"build": "vite build && vite build admin",
|
|
20
20
|
"preview": "vite preview",
|
|
21
|
+
"prod": "set NODE_ENV=production&& node server",
|
|
21
22
|
"docs:install": "npm install --prefix ./docs",
|
|
22
23
|
"docs:dev": "npm run --prefix ./docs docs:dev",
|
|
23
24
|
"docs:build": "npm run --prefix ./docs docs:build",
|
|
@@ -43,7 +44,8 @@
|
|
|
43
44
|
"vue3-smooth-dnd": "0.0.6"
|
|
44
45
|
},
|
|
45
46
|
"devDependencies": {
|
|
46
|
-
"@vitejs/plugin-vue": "5.2.3",
|
|
47
|
+
"@vitejs/plugin-vue": "^5.2.3",
|
|
48
|
+
"vite": "^6.3.5",
|
|
47
49
|
"eslint": "8.49.0",
|
|
48
50
|
"eslint-config-airbnb": "19.0.4",
|
|
49
51
|
"sass-embedded": "1.86.3"
|
package/plugin.js
CHANGED
|
@@ -10,7 +10,6 @@ config.auth.disable = true; // if fastify-auth not registered, then auth is disa
|
|
|
10
10
|
|
|
11
11
|
async function plugin(app, opts = config) {
|
|
12
12
|
// API
|
|
13
|
-
app.register(import('@opengis/fastify-table/index.js'), opts);
|
|
14
13
|
app.register(import('./server/routes/map/index.mjs'), opts);
|
|
15
14
|
app.register(import('./server/routes/gis/index.mjs'), opts);
|
|
16
15
|
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { createServer } from 'vite';
|
|
4
|
+
|
|
5
|
+
const isProduction = process.env.NODE_ENV === 'production';
|
|
6
|
+
|
|
7
|
+
console.log({ isProduction });
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
async function plugin(fastify, opts) {
|
|
11
|
+
|
|
12
|
+
const viteServer = !isProduction ? await createServer({
|
|
13
|
+
root: `admin`,
|
|
14
|
+
server: {
|
|
15
|
+
middlewareMode: true,
|
|
16
|
+
},
|
|
17
|
+
}) : null;
|
|
18
|
+
|
|
19
|
+
if (!isProduction) {
|
|
20
|
+
const dir1 = process.cwd();
|
|
21
|
+
viteServer.watcher.add(dir1);
|
|
22
|
+
viteServer.watcher.on('all', (d, t) => {
|
|
23
|
+
|
|
24
|
+
if (!t.includes('module')) return;
|
|
25
|
+
console.log(d, t);
|
|
26
|
+
viteServer.ws.send({ type: 'full-reload' });
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// this is middleware for vite's dev server
|
|
30
|
+
fastify.addHook('onRequest', async (request, reply) => {
|
|
31
|
+
const next = () => new Promise((resolve) => {
|
|
32
|
+
viteServer.middlewares(request.raw, reply.raw, () => resolve());
|
|
33
|
+
});
|
|
34
|
+
await next();
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async function staticFile(req, reply) {
|
|
39
|
+
const assetsDir = 'admin/dist';
|
|
40
|
+
|
|
41
|
+
const filePathDist = path.join(assetsDir, req.url.replace('/public/', '/'));
|
|
42
|
+
const filePathAssets = path.join('assets', req.url.replace('/assets', ''));
|
|
43
|
+
|
|
44
|
+
const filePath = fs.existsSync(filePathDist) ? filePathDist : filePathAssets; // check dist or assets
|
|
45
|
+
const ext = path.extname(filePath);
|
|
46
|
+
|
|
47
|
+
if (!fs.existsSync(filePath)) return { status: 404, message: 'not found' }
|
|
48
|
+
const mime = {
|
|
49
|
+
'.js': 'text/javascript', '.css': 'text/css', '.woff2': 'application/font-woff', '.png': 'image/png', '.svg': 'image/svg+xml', '.jpg': 'image/jpg',
|
|
50
|
+
}[ext];
|
|
51
|
+
reply.headers({ 'Cache-control': 'max-age=3600, public', 'Content-Encoding': 'identity' });
|
|
52
|
+
|
|
53
|
+
const stream = fs.createReadStream(filePath);
|
|
54
|
+
return mime ? reply.type(mime).send(stream) : stream;
|
|
55
|
+
}
|
|
56
|
+
fastify.get('/assets/*', staticFile);
|
|
57
|
+
fastify.get('/public/*', staticFile);
|
|
58
|
+
|
|
59
|
+
fastify.get('*', async (req, reply) => {
|
|
60
|
+
if (!isProduction) return null; // admin vite
|
|
61
|
+
const stream = fs.createReadStream('admin/dist/index.html');
|
|
62
|
+
return reply.type('text/html').send(stream);
|
|
63
|
+
|
|
64
|
+
})
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export default plugin;
|
|
68
|
+
|