@repdf/preview 0.0.21 → 0.0.23

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.
Files changed (48) hide show
  1. package/dist/index.js +80 -36
  2. package/dist/preview/.next/BUILD_ID +1 -1
  3. package/dist/preview/.next/build-manifest.json +11 -5
  4. package/dist/preview/.next/cache/.tsbuildinfo +1 -1
  5. package/dist/preview/.next/cache/webpack/client-production/0.pack +0 -0
  6. package/dist/preview/.next/cache/webpack/client-production/index.pack +0 -0
  7. package/dist/preview/.next/cache/webpack/edge-server-production/index.pack +0 -0
  8. package/dist/preview/.next/cache/webpack/server-production/0.pack +0 -0
  9. package/dist/preview/.next/cache/webpack/server-production/index.pack +0 -0
  10. package/dist/preview/.next/next-minimal-server.js.nft.json +1 -1
  11. package/dist/preview/.next/next-server.js.nft.json +1 -1
  12. package/dist/preview/.next/prerender-manifest.json +1 -1
  13. package/dist/preview/.next/routes-manifest.json +1 -1
  14. package/dist/preview/.next/server/chunks/370.js +1 -0
  15. package/dist/preview/.next/server/chunks/476.js +1 -0
  16. package/dist/preview/.next/server/chunks/787.js +1 -1
  17. package/dist/preview/.next/server/chunks/81.js +1 -0
  18. package/dist/preview/.next/server/middleware-build-manifest.js +1 -1
  19. package/dist/preview/.next/server/pages/_app.js +1 -1
  20. package/dist/preview/.next/server/pages/_app.js.nft.json +1 -1
  21. package/dist/preview/.next/server/pages/_error.js +1 -1
  22. package/dist/preview/.next/server/pages/_error.js.nft.json +1 -1
  23. package/dist/preview/.next/server/pages/api/component.js +2 -2
  24. package/dist/preview/.next/server/pages/api/component.js.nft.json +1 -1
  25. package/dist/preview/.next/server/pages/api/pdf.js +1 -1
  26. package/dist/preview/.next/server/pages/api/pdf.js.nft.json +1 -1
  27. package/dist/preview/.next/server/pages/api/trpc/[trpc].js +4 -1
  28. package/dist/preview/.next/server/pages/api/trpc/[trpc].js.nft.json +1 -1
  29. package/dist/preview/.next/server/pages/en/404.html +1 -1
  30. package/dist/preview/.next/server/pages/en/500.html +1 -1
  31. package/dist/preview/.next/server/pages/en/test.html +1 -0
  32. package/dist/preview/.next/server/pages/index.js +1 -1
  33. package/dist/preview/.next/server/pages/index.js.nft.json +1 -1
  34. package/dist/preview/.next/server/pages/preview/[...relTemplatePath].js +1 -1
  35. package/dist/preview/.next/server/pages/preview/[...relTemplatePath].js.nft.json +1 -1
  36. package/dist/preview/.next/server/pages/test.js.nft.json +1 -0
  37. package/dist/preview/.next/server/pages-manifest.json +1 -1
  38. package/dist/preview/.next/server/webpack-api-runtime.js +1 -1
  39. package/dist/preview/.next/static/G5Y7PYRjqbJufl3zkbmmE/_buildManifest.js +1 -0
  40. package/dist/preview/.next/static/chunks/pages/{_app-2de82f9e83b4c360.js → _app-0f9241fc03d167e5.js} +3 -3
  41. package/dist/preview/.next/static/chunks/pages/preview/{[...relTemplatePath]-21a4afde50569413.js → [...relTemplatePath]-54953a42a234e88f.js} +1 -1
  42. package/dist/preview/.next/static/chunks/pages/test-6c9d6a5f356c21ea.js +1 -0
  43. package/dist/preview/.next/static/css/e697c978240c2fce.css +3 -0
  44. package/dist/preview/.next/trace +16 -14
  45. package/package.json +11 -11
  46. package/dist/preview/.next/static/css/1f6d59b4f8c0fd6a.css +0 -3
  47. package/dist/preview/.next/static/fz9ql8-57k-jJMz9gYIxr/_buildManifest.js +0 -1
  48. /package/dist/preview/.next/static/{fz9ql8-57k-jJMz9gYIxr → G5Y7PYRjqbJufl3zkbmmE}/_ssgManifest.js +0 -0
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import { program } from "commander";
6
6
  // package.json
7
7
  var package_default = {
8
8
  name: "@repdf/preview",
9
- version: "0.0.21",
9
+ version: "0.0.22",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -27,7 +27,7 @@ var package_default = {
27
27
  scripts: {
28
28
  tsup: "tsup --tsconfig tsconfig.build.json && node build-preview-server.js",
29
29
  build: "next build",
30
- dev: "next dev -p 3005",
30
+ dev: "next dev",
31
31
  "dev:live": "tsx watch src/cli/index.ts dev",
32
32
  "dev:live:notused": "tsup --tsconfig tsconfig.build.json --watch",
33
33
  lint: "next lint",
@@ -38,8 +38,8 @@ var package_default = {
38
38
  },
39
39
  dependencies: {
40
40
  "@repdf/core": "workspace:*",
41
- "@react-email/render": "1.0.1",
42
- "@react-email/tailwind": "0.1.0",
41
+ "@react-email/render": "1.0.2",
42
+ "@react-email/tailwind": "1.0.0",
43
43
  "@tanstack/react-query": "^5.59.15",
44
44
  "@tanstack/react-query-devtools": "^5.59.15",
45
45
  "@trpc/client": "^11.0.0-rc.553",
@@ -68,27 +68,27 @@ var package_default = {
68
68
  "source-map-js": "^1.2.1",
69
69
  "stacktrace-parser": "^0.1.10",
70
70
  superjson: "^2.2.1",
71
- "tailwind-merge": "^2.5.2",
71
+ "tailwind-merge": "^2.5.4",
72
72
  webpack: "^5.95.0",
73
73
  ws: "^8.18.0",
74
74
  zod: "^3.23.8"
75
75
  },
76
76
  devDependencies: {
77
- tsx: "^4.19.1",
78
- tsup: "8.3.0",
77
+ tsx: "^4.19.2",
78
+ tsup: "8.3.5",
79
79
  "@changesets/cli": "2.27.9",
80
80
  "@arethetypeswrong/cli": "0.16.4",
81
81
  "@biomejs/biome": "1.9.3",
82
82
  "@types/express": "^5.0.0",
83
83
  "@types/js-beautify": "^1.14.3",
84
84
  "@types/node": "^20.14.10",
85
- "@types/react": "^18.3.11",
85
+ "@types/react": "^18.3.12",
86
86
  "@types/react-dom": "^18.3.1",
87
87
  "@types/ws": "^8.5.12",
88
88
  postcss: "^8.4.39",
89
89
  "react-email": "3.0.1",
90
- tailwindcss: "^3.4.13",
91
- typescript: "^5.6.3"
90
+ tailwindcss: "^3.4.14",
91
+ typescript: "5.5.4"
92
92
  },
93
93
  packageManager: "pnpm@9.7.1"
94
94
  };
@@ -217,31 +217,62 @@ function getPdfTemplates() {
217
217
 
218
218
  // src/utils/files/pdfTemplateWatcher.ts
219
219
  function pdfTemplateWatcher() {
220
+ console.log("running template watcher");
220
221
  const pdfTemplates = getPdfTemplates();
221
- const allFiles = /* @__PURE__ */ new Set();
222
- for (const pdfTemplate of pdfTemplates) {
223
- allFiles.add(pdfTemplate.absolutePath);
224
- const dependencyTree2 = getDependencyTree({
225
- relViewerPath: pdfTemplate.relViewerPath,
226
- outputType: "list"
227
- });
228
- for (const absoluteFilePath of dependencyTree2) {
229
- allFiles.add(absoluteFilePath);
222
+ try {
223
+ const allFiles = /* @__PURE__ */ new Set();
224
+ for (const pdfTemplate of pdfTemplates) {
225
+ allFiles.add(pdfTemplate.absolutePath);
226
+ const dependencyTree2 = getDependencyTree({
227
+ relViewerPath: pdfTemplate.relViewerPath,
228
+ outputType: "list"
229
+ });
230
+ for (const absoluteFilePath of dependencyTree2) {
231
+ allFiles.add(absoluteFilePath);
232
+ }
230
233
  }
234
+ const watcher2 = chokidar.watch(ABSOLUTE_PATH_TO_PDF_FOLDER(), {
235
+ persistent: true,
236
+ ignoreInitial: true,
237
+ ignored: /(^|[\/\\])\../
238
+ // Ignore dot files
239
+ });
240
+ watcher2.add(Array.from(allFiles));
241
+ console.log("added files to watcher", Array.from(allFiles));
242
+ watcher2.on("add", (filePath) => {
243
+ console.log(`File ${filePath} has been added`);
244
+ }).on("change", (filePath) => {
245
+ console.log(`File ${filePath} has been changed`);
246
+ }).on("unlink", (filePath) => {
247
+ console.log(`File ${filePath} has been removed`);
248
+ }).on("error", (error) => {
249
+ console.error(`Watcher error: ${error}`);
250
+ });
251
+ return watcher2;
252
+ } catch (error) {
253
+ console.error("issue", error);
254
+ throw error;
231
255
  }
232
- const watcher2 = chokidar.watch(ABSOLUTE_PATH_TO_PDF_FOLDER(), {
233
- persistent: true,
234
- ignoreInitial: true,
235
- ignored: /(^|[\/\\])\../
236
- // Ignore dot files
256
+ }
257
+
258
+ // src/utils/checkPortAvailability.ts
259
+ import http from "http";
260
+ function checkPortAvailability(port) {
261
+ return new Promise((resolve) => {
262
+ const server = http.createServer();
263
+ server.once("error", (err) => {
264
+ if (err.code === "EADDRINUSE") {
265
+ resolve(false);
266
+ } else {
267
+ resolve(false);
268
+ }
269
+ });
270
+ server.once("listening", () => {
271
+ server.close();
272
+ resolve(true);
273
+ });
274
+ server.listen(port);
237
275
  });
238
- watcher2.add(Array.from(allFiles));
239
- watcher2.on("add", (filePath) => {
240
- logger_default.debug(`File ${filePath} has been added`);
241
- }).on("change", (filePath) => {
242
- }).on("unlink", (filePath) => {
243
- }).on("error", (error) => logger_default.error(`Watcher error: ${error}`));
244
- return watcher2;
245
276
  }
246
277
 
247
278
  // src/cli/commands/server.ts
@@ -263,14 +294,19 @@ var previewServer;
263
294
  var clients = /* @__PURE__ */ new Set();
264
295
  var watcher;
265
296
  var startPreviewServer = async (pdfsDirRelativePath, port) => {
297
+ let actualPort = port;
298
+ while (!await checkPortAvailability(actualPort)) {
299
+ console.log("port is in use, trying next port");
300
+ actualPort++;
301
+ }
266
302
  previewServer = express();
267
- const server = previewServer.listen(port);
303
+ const server = previewServer.listen(actualPort);
268
304
  const wss = new WebSocketServer({ noServer: true });
269
305
  process.env = {
270
306
  ...process.env,
271
307
  NODE_ENV: isDev ? "development" : "production",
272
308
  // TODO: why is this set to devlopment and is that right?
273
- PORT: port.toString(),
309
+ PORT: actualPort.toString(),
274
310
  ...getEnvVariablesForPreviewApp(
275
311
  // If we don't do normalization here, stuff like https://github.com/resend/react-email/issues/1354 happens.
276
312
  path2.normalize(pdfsDirRelativePath),
@@ -286,12 +322,12 @@ var startPreviewServer = async (pdfsDirRelativePath, port) => {
286
322
  }
287
323
  },
288
324
  hostname: "localhost",
289
- port,
325
+ port: actualPort,
290
326
  dir: previewServerLocation
291
327
  });
292
328
  logger_default.info("preparing next app");
293
329
  nextApp.prepare().then(() => {
294
- const url = `http://localhost:${port}`;
330
+ const url = `http://localhost:${actualPort}`;
295
331
  const clickableUrl = `\x1B]8;;${url}\x07${url}\x1B]8;;\x07`;
296
332
  console.log(clickableUrl);
297
333
  previewServer.use((req, res, next2) => {
@@ -301,6 +337,7 @@ var startPreviewServer = async (pdfsDirRelativePath, port) => {
301
337
  watcher.on("all", () => {
302
338
  logger_default.info("watcher: file changed");
303
339
  for (const client of Array.from(clients)) {
340
+ logger_default.info("sending file changed message to client");
304
341
  client.send(`file changed ${(/* @__PURE__ */ new Date()).toISOString()}`);
305
342
  }
306
343
  watcher = pdfTemplateWatcher();
@@ -335,7 +372,7 @@ var startPreviewServer = async (pdfsDirRelativePath, port) => {
335
372
  }
336
373
  });
337
374
  });
338
- return previewServer;
375
+ return server;
339
376
  };
340
377
 
341
378
  // src/cli/commands/dev.ts
@@ -351,6 +388,13 @@ var dev = async ({
351
388
  relativePathToPdfFolder,
352
389
  parseInt(port)
353
390
  );
391
+ const shutdown = async () => {
392
+ logger_default.info("Shutting down preview server...");
393
+ await devServer?.close();
394
+ process.exit(0);
395
+ };
396
+ process.on("SIGINT", shutdown);
397
+ process.on("SIGTERM", shutdown);
354
398
  } catch (error) {
355
399
  logger_default.error(error);
356
400
  process.exit(1);
@@ -1 +1 @@
1
- fz9ql8-57k-jJMz9gYIxr
1
+ G5Y7PYRjqbJufl3zkbmmE
@@ -5,8 +5,8 @@
5
5
  "devFiles": [],
6
6
  "ampDevFiles": [],
7
7
  "lowPriorityFiles": [
8
- "static/fz9ql8-57k-jJMz9gYIxr/_buildManifest.js",
9
- "static/fz9ql8-57k-jJMz9gYIxr/_ssgManifest.js"
8
+ "static/G5Y7PYRjqbJufl3zkbmmE/_buildManifest.js",
9
+ "static/G5Y7PYRjqbJufl3zkbmmE/_ssgManifest.js"
10
10
  ],
11
11
  "rootMainFiles": [],
12
12
  "pages": {
@@ -21,8 +21,8 @@
21
21
  "static/chunks/webpack-b8f8d6679aaa5f42.js",
22
22
  "static/chunks/framework-e0f347a11a70369e.js",
23
23
  "static/chunks/main-58cc12cfc6868a7a.js",
24
- "static/css/1f6d59b4f8c0fd6a.css",
25
- "static/chunks/pages/_app-2de82f9e83b4c360.js"
24
+ "static/css/e697c978240c2fce.css",
25
+ "static/chunks/pages/_app-0f9241fc03d167e5.js"
26
26
  ],
27
27
  "/_error": [
28
28
  "static/chunks/webpack-b8f8d6679aaa5f42.js",
@@ -35,7 +35,13 @@
35
35
  "static/chunks/framework-e0f347a11a70369e.js",
36
36
  "static/chunks/main-58cc12cfc6868a7a.js",
37
37
  "static/chunks/138-c24eca17d1ad2527.js",
38
- "static/chunks/pages/preview/[...relTemplatePath]-21a4afde50569413.js"
38
+ "static/chunks/pages/preview/[...relTemplatePath]-54953a42a234e88f.js"
39
+ ],
40
+ "/test": [
41
+ "static/chunks/webpack-b8f8d6679aaa5f42.js",
42
+ "static/chunks/framework-e0f347a11a70369e.js",
43
+ "static/chunks/main-58cc12cfc6868a7a.js",
44
+ "static/chunks/pages/test-6c9d6a5f356c21ea.js"
39
45
  ]
40
46
  },
41
47
  "ampFirstPages": []