@mintlify/previewing 4.0.1017 → 4.0.1019

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.
@@ -0,0 +1,82 @@
1
+ #!/usr/bin/env node
2
+ // Serves the exported docs folder as a local static site. This is shipped with the export zip from `mint export`.
3
+ const http = require('http');
4
+ const fs = require('fs');
5
+ const path = require('path');
6
+ const { execFile } = require('child_process');
7
+
8
+ const PORT = process.env.PORT || 3000;
9
+ const DIR = __dirname;
10
+
11
+ const MIME_TYPES = {
12
+ '.html': 'text/html',
13
+ '.css': 'text/css',
14
+ '.js': 'application/javascript',
15
+ '.json': 'application/json',
16
+ '.png': 'image/png',
17
+ '.jpg': 'image/jpeg',
18
+ '.jpeg': 'image/jpeg',
19
+ '.gif': 'image/gif',
20
+ '.svg': 'image/svg+xml',
21
+ '.ico': 'image/x-icon',
22
+ '.woff': 'font/woff',
23
+ '.woff2': 'font/woff2',
24
+ '.ttf': 'font/ttf',
25
+ '.webp': 'image/webp',
26
+ '.mp4': 'video/mp4',
27
+ '.webm': 'video/webm',
28
+ '.xml': 'application/xml',
29
+ '.txt': 'text/plain',
30
+ };
31
+
32
+ function openInBrowser(url) {
33
+ let command = 'xdg-open';
34
+ switch (process.platform) {
35
+ case 'darwin':
36
+ command = 'open';
37
+ break;
38
+ case 'win32':
39
+ command = 'explorer.exe';
40
+ break;
41
+ default:
42
+ command = 'xdg-open';
43
+ }
44
+
45
+ execFile(command, [url], () => undefined);
46
+ }
47
+
48
+ function resolveFile(urlPath) {
49
+ const filePath = path.resolve(DIR, urlPath.replace(/^\/+/, ''));
50
+ if (!filePath.startsWith(DIR + path.sep) && filePath !== DIR) return undefined;
51
+ const candidates = [filePath, path.join(filePath, 'index.html'), filePath + '.html'];
52
+ return candidates.find((c) => fs.existsSync(c) && fs.statSync(c).isFile());
53
+ }
54
+
55
+ http
56
+ .createServer((req, res) => {
57
+ let urlPath;
58
+ try {
59
+ const rawPath = (req.url || '/').split('?')[0];
60
+ urlPath = decodeURIComponent(rawPath);
61
+ } catch {
62
+ res.writeHead(404, { 'Content-Type': 'text/plain' });
63
+ res.end('404 Not Found');
64
+ return;
65
+ }
66
+
67
+ const file = resolveFile(urlPath);
68
+
69
+ if (file) {
70
+ const ext = path.extname(file).toLowerCase();
71
+ res.writeHead(200, { 'Content-Type': MIME_TYPES[ext] || 'application/octet-stream' });
72
+ fs.createReadStream(file).pipe(res);
73
+ } else {
74
+ res.writeHead(404, { 'Content-Type': 'text/plain' });
75
+ res.end('404 Not Found');
76
+ }
77
+ })
78
+ .listen(PORT, () => {
79
+ const url = 'http://localhost:' + PORT;
80
+ console.log('Serving docs at ' + url);
81
+ openInBrowser(url);
82
+ });
@@ -0,0 +1,10 @@
1
+ @echo off
2
+ cd /d "%~dp0"
3
+ where node >nul 2>nul
4
+ if %errorlevel%==0 (
5
+ node serve.js
6
+ ) else (
7
+ echo Error: Node.js is required to view these docs.
8
+ echo Install Node.js from https://nodejs.org
9
+ pause
10
+ )
@@ -0,0 +1,9 @@
1
+ #!/bin/bash
2
+ cd "$(dirname "$0")"
3
+ if command -v node &> /dev/null; then
4
+ node serve.js
5
+ else
6
+ echo "Error: Node.js is required to view these docs."
7
+ echo "Install Node.js from https://nodejs.org"
8
+ read -p "Press Enter to exit..."
9
+ fi
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mintlify/previewing",
3
- "version": "4.0.1017",
3
+ "version": "4.0.1019",
4
4
  "description": "Preview Mintlify docs locally",
5
5
  "engines": {
6
6
  "node": ">=18.0.0"
@@ -28,7 +28,8 @@
28
28
  "main": "./dist/index.js",
29
29
  "types": "./dist/index.d.ts",
30
30
  "files": [
31
- "dist"
31
+ "dist",
32
+ "export-scripts"
32
33
  ],
33
34
  "scripts": {
34
35
  "prepare": "npm run build",
@@ -43,9 +44,10 @@
43
44
  "type": "tsc --noEmit"
44
45
  },
45
46
  "dependencies": {
46
- "@mintlify/common": "1.0.818",
47
- "@mintlify/prebuild": "1.0.959",
48
- "@mintlify/validation": "0.1.643",
47
+ "@mintlify/common": "1.0.819",
48
+ "@mintlify/prebuild": "1.0.960",
49
+ "@mintlify/validation": "0.1.644",
50
+ "adm-zip": "0.5.16",
49
51
  "better-opn": "3.0.2",
50
52
  "chalk": "5.2.0",
51
53
  "chokidar": "3.5.3",
@@ -86,5 +88,5 @@
86
88
  "vitest": "2.1.9",
87
89
  "vitest-mock-process": "1.0.4"
88
90
  },
89
- "gitHead": "87821bd4fd4fd84aea3932e8ae0928bd15dc3c28"
91
+ "gitHead": "449627f27a66da94b3f6a851601ac2524ad1b71a"
90
92
  }