@edgeone/nuxt-pages 1.0.4 → 1.0.5

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.
@@ -7,9 +7,9 @@
7
7
  import {
8
8
  addNitroBuildOutputConfig,
9
9
  resetNitroConfig
10
- } from "../../esm-chunks/chunk-7JK67XZ2.js";
10
+ } from "../../esm-chunks/chunk-3YPB33TX.js";
11
11
  import "../../esm-chunks/chunk-V2LFVP3C.js";
12
- import "../../esm-chunks/chunk-5VJRCUAW.js";
12
+ import "../../esm-chunks/chunk-AX7OAFFE.js";
13
13
  import "../../esm-chunks/chunk-6BT4RYQJ.js";
14
14
  export {
15
15
  addNitroBuildOutputConfig,
@@ -8,8 +8,8 @@ import {
8
8
  EDGE_HANDLER_NAME,
9
9
  PluginContext,
10
10
  SERVER_HANDLER_NAME
11
- } from "../esm-chunks/chunk-ZYJTEPF7.js";
12
- import "../esm-chunks/chunk-5VJRCUAW.js";
11
+ } from "../esm-chunks/chunk-YLEWZSAK.js";
12
+ import "../esm-chunks/chunk-AX7OAFFE.js";
13
13
  import "../esm-chunks/chunk-6BT4RYQJ.js";
14
14
  export {
15
15
  EDGE_HANDLER_NAME,
@@ -8,8 +8,8 @@ import {
8
8
  convertNuxtRoutePattern,
9
9
  createNuxtApiRoutesMeta,
10
10
  createNuxtPagesRouteMeta
11
- } from "../esm-chunks/chunk-SS6G7FEH.js";
12
- import "../esm-chunks/chunk-5VJRCUAW.js";
11
+ } from "../esm-chunks/chunk-SAO2LN63.js";
12
+ import "../esm-chunks/chunk-AX7OAFFE.js";
13
13
  import "../esm-chunks/chunk-6BT4RYQJ.js";
14
14
  export {
15
15
  convertNuxtRoutePattern,
@@ -11,7 +11,7 @@ import {
11
11
  import {
12
12
  addCodeToGenerateEdgeoneWithAST,
13
13
  resetNitroConfigWithAST
14
- } from "./chunk-5VJRCUAW.js";
14
+ } from "./chunk-AX7OAFFE.js";
15
15
 
16
16
  // src/build/content/static.ts
17
17
  import { existsSync } from "node:fs";
@@ -14588,6 +14588,7 @@ var require_lib = __commonJS({
14588
14588
  // src/utils.ts
14589
14589
  var parser = __toESM(require_lib(), 1);
14590
14590
  import { createRequire } from "node:module";
14591
+ import { rm } from "node:fs/promises";
14591
14592
  var require2 = createRequire(import.meta.url);
14592
14593
  var traverse = require2("@babel/traverse").default;
14593
14594
  function astNodeToObject(node) {
@@ -15051,6 +15052,25 @@ function getModulesWithAST(code) {
15051
15052
  return [];
15052
15053
  }
15053
15054
  }
15055
+ function checkModules(modules) {
15056
+ const excludeModules = ["@nuxt/image"];
15057
+ const invalidModules = modules.filter((module) => excludeModules.includes(module));
15058
+ if (invalidModules.length > 0) {
15059
+ console.error("\x1B[31mThe following modules are not supported: \x1B[0m", invalidModules.join(", "));
15060
+ console.log("Further optimizations and adaptations are under development...");
15061
+ process.exit(1);
15062
+ }
15063
+ }
15064
+ function checkNuxtVersion(version) {
15065
+ const versionData = version.split(".");
15066
+ if (versionData.length === 3 && Number(versionData[0]) < 3) {
15067
+ console.error("Nuxt version must be greater than 3.16.0. Compatibility for lower versions is under development...");
15068
+ process.exit(1);
15069
+ }
15070
+ }
15071
+ var removeServerHandler = async (ctx) => {
15072
+ await rm(ctx.serverHandlerDir, { recursive: true, force: true });
15073
+ };
15054
15074
 
15055
15075
  export {
15056
15076
  getRouteRulesWithAST,
@@ -15059,5 +15079,8 @@ export {
15059
15079
  getHandlersArrayWithAST,
15060
15080
  addCodeToGenerateEdgeoneWithAST,
15061
15081
  resetNitroConfigWithAST,
15062
- getModulesWithAST
15082
+ getModulesWithAST,
15083
+ checkModules,
15084
+ checkNuxtVersion,
15085
+ removeServerHandler
15063
15086
  };
@@ -6,7 +6,7 @@
6
6
 
7
7
  import {
8
8
  getHandlersArrayWithAST
9
- } from "./chunk-5VJRCUAW.js";
9
+ } from "./chunk-AX7OAFFE.js";
10
10
 
11
11
  // src/build/routes.ts
12
12
  import * as fs from "fs";
@@ -60,9 +60,6 @@ var createNuxtPagesRouteMeta = async (ctx) => {
60
60
  if (!routeMap[route]) {
61
61
  routeMap[route] = {};
62
62
  }
63
- if (routeInfo.ssr !== void 0 && routeInfo.ssr) {
64
- routeMap[route].ssr = routeInfo.ssr;
65
- }
66
63
  if (routeInfo.prerender !== void 0) {
67
64
  routeMap[route].isStatic = routeInfo.prerender;
68
65
  }
@@ -160,7 +157,7 @@ var createNuxtApiRoutesMeta = async (ctx) => {
160
157
  frameworkRoutes: existingMetaData.routes.concat(apiRoutes.map((route) => ({ path: route.path })))
161
158
  };
162
159
  const excludeRoutes = ["/**"];
163
- const processedRoutes = mergedMetaData.frameworkRoutes.filter((route) => !excludeRoutes.includes(route.path)).map((route) => {
160
+ let processedRoutes = mergedMetaData.frameworkRoutes.filter((route) => !excludeRoutes.includes(route.path)).map((route) => {
164
161
  if (!route.path || route.path === "/**") {
165
162
  return {
166
163
  ...route,
@@ -192,6 +189,27 @@ var createNuxtApiRoutesMeta = async (ctx) => {
192
189
  processedRoutes.push({
193
190
  path: ".*-ssr-functions/:path*"
194
191
  });
192
+ processedRoutes = processedRoutes.map((route) => {
193
+ if (route.hasOwnProperty("ssr")) {
194
+ Reflect.deleteProperty(route, "ssr");
195
+ }
196
+ route.path = route.path.replace(/\(/g, "").replace(/\)/g, "");
197
+ return route;
198
+ });
199
+ processedRoutes = processedRoutes.map((route) => {
200
+ if (route.path.startsWith("/:")) {
201
+ if (route.hasOwnProperty("isStatic")) {
202
+ route.isStatic = true;
203
+ } else {
204
+ Reflect.defineProperty(route, "isStatic", {
205
+ value: true,
206
+ enumerable: true
207
+ });
208
+ }
209
+ return route;
210
+ }
211
+ return route;
212
+ });
195
213
  const finalMetaData = {
196
214
  frameworkRoutes: processedRoutes,
197
215
  conf: {
@@ -9,14 +9,13 @@ import {
9
9
  getPrerenderRoutesWithAST,
10
10
  getRouteRulesWithAST,
11
11
  getRoutesArrayWithAST
12
- } from "./chunk-5VJRCUAW.js";
12
+ } from "./chunk-AX7OAFFE.js";
13
13
 
14
14
  // src/build/plugin-context.ts
15
15
  import { existsSync, readFileSync } from "node:fs";
16
16
  import { readFile } from "node:fs/promises";
17
- import { createRequire } from "node:module";
17
+ import { execSync } from "node:child_process";
18
18
  import { join, relative, resolve } from "node:path";
19
- import { join as posixJoin } from "node:path/posix";
20
19
  import { fileURLToPath } from "node:url";
21
20
  var MODULE_DIR = fileURLToPath(new URL(".", import.meta.url));
22
21
  var PLUGIN_DIR = join(MODULE_DIR, "../..");
@@ -495,9 +494,17 @@ var PluginContext = class {
495
494
  get nuxtVersion() {
496
495
  if (this.#nuxtVersion === void 0) {
497
496
  try {
498
- const serverHandlerRequire = createRequire(posixJoin(this.outputRootDir, ":internal:"));
499
- const { version } = serverHandlerRequire("nuxt/package.json");
500
- this.#nuxtVersion = version;
497
+ const output = execSync("npx nuxt info", {
498
+ encoding: "utf-8",
499
+ cwd: process.cwd(),
500
+ stdio: ["pipe", "pipe", "pipe"]
501
+ });
502
+ const versionMatch = output.match(/(?:nuxt|version)[:\s]+(\d+\.\d+\.\d+)/i);
503
+ if (versionMatch && versionMatch[1]) {
504
+ this.#nuxtVersion = versionMatch[1];
505
+ } else {
506
+ this.#nuxtVersion = null;
507
+ }
501
508
  } catch {
502
509
  this.#nuxtVersion = null;
503
510
  }
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@
7
7
  import {
8
8
  addNitroBuildOutputConfig,
9
9
  resetNitroConfig
10
- } from "./esm-chunks/chunk-7JK67XZ2.js";
10
+ } from "./esm-chunks/chunk-3YPB33TX.js";
11
11
  import {
12
12
  createServerHandler,
13
13
  patchNitroHandler
@@ -16,31 +16,23 @@ import "./esm-chunks/chunk-NJ4SUJNF.js";
16
16
  import "./esm-chunks/chunk-V2LFVP3C.js";
17
17
  import {
18
18
  PluginContext
19
- } from "./esm-chunks/chunk-ZYJTEPF7.js";
19
+ } from "./esm-chunks/chunk-YLEWZSAK.js";
20
20
  import {
21
21
  createNuxtApiRoutesMeta,
22
22
  createNuxtPagesRouteMeta
23
- } from "./esm-chunks/chunk-SS6G7FEH.js";
24
- import "./esm-chunks/chunk-5VJRCUAW.js";
23
+ } from "./esm-chunks/chunk-SAO2LN63.js";
24
+ import {
25
+ checkNuxtVersion,
26
+ removeServerHandler
27
+ } from "./esm-chunks/chunk-AX7OAFFE.js";
25
28
  import "./esm-chunks/chunk-6BT4RYQJ.js";
26
29
 
27
30
  // src/index.ts
28
- import { rm } from "node:fs/promises";
29
- function checkNuxtVersion(version) {
30
- const versionData = version.split(".");
31
- if (versionData.length === 3 && Number(versionData[0]) < 3) {
32
- console.error("Nuxt version must be greater than 3.8.0. Compatibility for lower versions is under development...");
33
- process.exit(1);
34
- }
35
- }
36
- var removeServerHandler = async (ctx) => {
37
- await rm(ctx.serverHandlerDir, { recursive: true, force: true });
38
- };
39
31
  var recordOldNitroConfig = null;
40
32
  var onPreBuild = async (options) => {
41
33
  try {
42
34
  const ctx = new PluginContext(options);
43
- checkNuxtVersion(ctx.nuxtVersion || "0.0.0");
35
+ checkNuxtVersion(ctx.nuxtVersion || "1.0.0");
44
36
  recordOldNitroConfig = await addNitroBuildOutputConfig(ctx);
45
37
  } catch (error) {
46
38
  console.error("onPreBuild failed:", error);
@@ -199,7 +199,7 @@ var getMemoizedKeyValueStoreBackedByRegionalBlobStore = (...args) => {
199
199
 
200
200
  // package.json
201
201
  var name = "@edgeone/nuxt-pages";
202
- var version = "1.0.4";
202
+ var version = "1.0.5";
203
203
 
204
204
  // src/run/handlers/tags-handler.cts
205
205
  var purgeCacheUserAgent = `${name}@${version}`;
@@ -28,7 +28,7 @@ module.exports = __toCommonJS(tags_handler_exports);
28
28
 
29
29
  // package.json
30
30
  var name = "@edgeone/nuxt-pages";
31
- var version = "1.0.4";
31
+ var version = "1.0.5";
32
32
 
33
33
  // src/run/handlers/request-context.cts
34
34
  var import_node_async_hooks = require("node:async_hooks");
@@ -20,7 +20,7 @@ import { Buffer } from "node:buffer";
20
20
 
21
21
  // package.json
22
22
  var name = "@edgeone/nuxt-pages";
23
- var version = "1.0.4";
23
+ var version = "1.0.5";
24
24
 
25
25
  // src/run/handlers/tags-handler.cts
26
26
  var purgeCacheUserAgent = `${name}@${version}`;
package/dist/utils.js CHANGED
@@ -6,20 +6,26 @@
6
6
 
7
7
  import {
8
8
  addCodeToGenerateEdgeoneWithAST,
9
+ checkModules,
10
+ checkNuxtVersion,
9
11
  getHandlersArrayWithAST,
10
12
  getModulesWithAST,
11
13
  getPrerenderRoutesWithAST,
12
14
  getRouteRulesWithAST,
13
15
  getRoutesArrayWithAST,
16
+ removeServerHandler,
14
17
  resetNitroConfigWithAST
15
- } from "./esm-chunks/chunk-5VJRCUAW.js";
18
+ } from "./esm-chunks/chunk-AX7OAFFE.js";
16
19
  import "./esm-chunks/chunk-6BT4RYQJ.js";
17
20
  export {
18
21
  addCodeToGenerateEdgeoneWithAST,
22
+ checkModules,
23
+ checkNuxtVersion,
19
24
  getHandlersArrayWithAST,
20
25
  getModulesWithAST,
21
26
  getPrerenderRoutesWithAST,
22
27
  getRouteRulesWithAST,
23
28
  getRoutesArrayWithAST,
29
+ removeServerHandler,
24
30
  resetNitroConfigWithAST
25
31
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edgeone/nuxt-pages",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "main": "./dist/index.js",
5
5
  "scripts": {
6
6
  "test": "ts-node src/test.ts",