html2pptx-local-mcp 1.1.33 → 1.1.34
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { spawn } from 'node:child_process';
|
|
2
|
-
import { existsSync
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
3
3
|
import net from 'node:net';
|
|
4
4
|
import { access } from 'node:fs/promises';
|
|
5
5
|
import { dirname, join, resolve } from 'node:path';
|
|
@@ -64,21 +64,6 @@ export function createLocalEditorServerManager(options = {}) {
|
|
|
64
64
|
const baseUrl = `http://localhost:${port}`;
|
|
65
65
|
const invocation = await resolveNextInvocation(appRoot, options);
|
|
66
66
|
|
|
67
|
-
// Give every editor instance its own Turbopack build dir. A shared `.next`
|
|
68
|
-
// gets corrupted two ways, both surfacing as a runtime ChunkLoadError:
|
|
69
|
-
// (a) npx reuses one cache dir across `@latest` version bumps, so a stale
|
|
70
|
-
// `.next` from the previous version is loaded against new source.
|
|
71
|
-
// (b) editors from different projects/sessions run `next dev` against the
|
|
72
|
-
// same appRoot concurrently and overwrite each other's chunks.
|
|
73
|
-
// The bundled next.config reads distDir from HTML2PPTX_EDITOR_DIST_DIR.
|
|
74
|
-
const distDir = `.next-${port}`;
|
|
75
|
-
await pruneStaleEditorDistDirs(appRoot);
|
|
76
|
-
try {
|
|
77
|
-
rmSync(join(appRoot, distDir), { recursive: true, force: true });
|
|
78
|
-
} catch {
|
|
79
|
-
// Best-effort: a fresh build dir is preferred but not required.
|
|
80
|
-
}
|
|
81
|
-
|
|
82
67
|
// Issue #78: do not pass `--webpack`. Next.js 16.2.x webpack mode fails
|
|
83
68
|
// to compile App Router `.jsx` files (next-swc-loader emits JSX that the
|
|
84
69
|
// webpack default parser then chokes on with "Unexpected token"). Use
|
|
@@ -94,7 +79,6 @@ export function createLocalEditorServerManager(options = {}) {
|
|
|
94
79
|
env: {
|
|
95
80
|
...process.env,
|
|
96
81
|
HTML2PPTX_EDITOR_BASE_URL: baseUrl,
|
|
97
|
-
HTML2PPTX_EDITOR_DIST_DIR: distDir,
|
|
98
82
|
NEXT_TELEMETRY_DISABLED: '1',
|
|
99
83
|
PORT: String(port),
|
|
100
84
|
},
|
|
@@ -222,30 +206,6 @@ export async function isEditorServer(port) {
|
|
|
222
206
|
}
|
|
223
207
|
}
|
|
224
208
|
|
|
225
|
-
// Remove per-instance `.next-<port>` build dirs whose editor server is gone, so
|
|
226
|
-
// isolated build caches from crashed/closed sessions do not accumulate. The dir
|
|
227
|
-
// for a still-listening editor is kept. Best-effort: never throws.
|
|
228
|
-
async function pruneStaleEditorDistDirs(appRoot) {
|
|
229
|
-
let entries;
|
|
230
|
-
try {
|
|
231
|
-
entries = readdirSync(appRoot, { withFileTypes: true });
|
|
232
|
-
} catch {
|
|
233
|
-
return;
|
|
234
|
-
}
|
|
235
|
-
for (const entry of entries) {
|
|
236
|
-
if (!entry.isDirectory()) continue;
|
|
237
|
-
const match = /^\.next-(\d+)$/.exec(entry.name);
|
|
238
|
-
if (!match) continue;
|
|
239
|
-
const port = Number.parseInt(match[1], 10);
|
|
240
|
-
if (await isEditorServer(port)) continue;
|
|
241
|
-
try {
|
|
242
|
-
rmSync(join(appRoot, entry.name), { recursive: true, force: true });
|
|
243
|
-
} catch {
|
|
244
|
-
// Best-effort cleanup.
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
|
|
249
209
|
function waitForEditorServer(session, timeoutMs) {
|
|
250
210
|
return new Promise((resolvePromise, rejectPromise) => {
|
|
251
211
|
const startedAt = Date.now();
|
|
@@ -22,7 +22,12 @@ const localEditorSecurityHeaders = [
|
|
|
22
22
|
];
|
|
23
23
|
|
|
24
24
|
export default {
|
|
25
|
-
|
|
25
|
+
// The App Router source ships as raw .jsx inside this npm package, so once
|
|
26
|
+
// installed it lives under node_modules/. Turbopack (and webpack) skip JSX/SWC
|
|
27
|
+
// transpilation for node_modules by default, emitting raw <html> into the SSR
|
|
28
|
+
// chunk -> `SyntaxError: Unexpected token '<'` surfaced as a ChunkLoadError.
|
|
29
|
+
// transpilePackages forces our own package to be transpiled like project code.
|
|
30
|
+
transpilePackages: ['html2pptx-local-mcp'],
|
|
26
31
|
async headers() {
|
|
27
32
|
return [
|
|
28
33
|
{ source: '/edit-slide', headers: localEditorSecurityHeaders },
|