@nuxt/bridge-edge 3.0.0-27489107.bc7627d → 3.0.0-27490192.4253d2e

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.
@@ -200,12 +200,9 @@ async function setupNitroBridge() {
200
200
  crawlLinks: nuxt.options.generate.crawler,
201
201
  routes: nuxt.options.generate.routes
202
202
  },
203
- output: {
204
- dir: nuxt.options.dev ? join$1(nuxt.options.buildDir, "nitro") : resolve(nuxt.options.rootDir, ".output")
205
- },
206
203
  externals: {
207
204
  inline: [
208
- ...nuxt.options.dev ? [] : [nuxt.options.buildDir],
205
+ ...nuxt.options.dev ? [] : ["vue", "@vue/", "@nuxt/", nuxt.options.buildDir],
209
206
  "@nuxt/bridge/dist",
210
207
  "@nuxt/bridge-edge/dist"
211
208
  ]
@@ -220,21 +217,16 @@ async function setupNitroBridge() {
220
217
  "#vue-renderer": resolve(distDir$1, "runtime/nitro/vue2"),
221
218
  "#vue2-server-renderer": "vue-server-renderer/" + (nuxt.options.dev ? "build.dev.js" : "build.prod.js"),
222
219
  "#nitro/error": resolve(distDir$1, "runtime/nitro/error"),
223
- "#paths": resolve(distDir$1, "runtime/nitro/paths")
220
+ "#paths": resolve(distDir$1, "runtime/nitro/paths"),
221
+ ...nuxt.options.alias
224
222
  }
225
223
  });
224
+ delete nitroConfig.alias["#build"];
226
225
  await nuxt.callHook("nitro:config", nitroConfig);
227
226
  const nitro = await createNitro(nitroConfig);
228
227
  await nuxt.callHook("nitro:init", nitro);
229
228
  nitro.vfs = nuxt.vfs = nitro.vfs || nuxt.vfs || {};
230
229
  nuxt.hook("close", () => nitro.hooks.callHook("close"));
231
- nitro.hooks.hook("nitro:document", (template) => nuxt.callHook("nitro:document", template));
232
- if (nuxt.options.appTemplatePath) {
233
- nuxt.hook("nitro:document", async (template) => {
234
- template.src = nuxt.options.appTemplatePath;
235
- template.contents = await promises.readFile(nuxt.options.appTemplatePath, "utf-8");
236
- });
237
- }
238
230
  async function updateViteBase() {
239
231
  const clientDist = resolve(nuxt.options.buildDir, "dist/client");
240
232
  const publicDir = join$1(nuxt.options.srcDir, nuxt.options.dir.static);
@@ -256,7 +248,6 @@ async function setupNitroBridge() {
256
248
  }
257
249
  }
258
250
  }
259
- nuxt.hook("nitro:generate", updateViteBase);
260
251
  nuxt.hook("generate:before", updateViteBase);
261
252
  nuxt.options.extensions.push("ts");
262
253
  nuxt.hook("webpack:config", (webpackConfigs) => {
@@ -334,19 +325,17 @@ async function setupNitroBridge() {
334
325
  if (nuxt.options._prepare) {
335
326
  return;
336
327
  }
328
+ await writeDocumentTemplate(nuxt);
337
329
  if (nuxt.options.dev) {
338
330
  await build(nitro);
339
331
  await waitUntilCompile;
340
332
  } else {
341
333
  await prepare(nitro);
342
334
  await copyPublicAssets(nitro);
343
- if (nuxt.options.target === "static") {
335
+ if (nuxt.options._generate || nuxt.options.target === "static") {
344
336
  await prerender(nitro);
345
337
  }
346
338
  await build(nitro);
347
- if (nuxt.options._generate) {
348
- await prerender(nitro);
349
- }
350
339
  }
351
340
  });
352
341
  if (nuxt.options.dev) {
@@ -444,6 +433,16 @@ async function resolveHandlers(nuxt) {
444
433
  devHandlers
445
434
  };
446
435
  }
436
+ async function writeDocumentTemplate(nuxt) {
437
+ const src = nuxt.options.appTemplatePath || resolve(nuxt.options.buildDir, "views/app.template.html");
438
+ const dst = src.replace(/.html$/, ".mjs").replace("app.template.mjs", "document.template.mjs");
439
+ const contents = nuxt.vfs[src] || await promises.readFile(src, "utf-8").catch(() => "");
440
+ if (contents) {
441
+ const compiled = `export default (params) => \`${contents.replace(/{{ (\w+) }}/g, "${params.$1}")}\``;
442
+ await promises.mkdir(dirname(dst), { recursive: true });
443
+ await promises.writeFile(dst, compiled, "utf8");
444
+ }
445
+ }
447
446
 
448
447
  const componentsTypeTemplate = {
449
448
  filename: "components.d.ts",
@@ -28,7 +28,7 @@ import 'unimport';
28
28
  import 'scule';
29
29
  import 'unplugin-vue2-script-setup/nuxt';
30
30
 
31
- const version = "3.0.0-27489107.bc7627d";
31
+ const version = "3.0.0-27490192.4253d2e";
32
32
 
33
33
  const middlewareTemplate = {
34
34
  filename: "middleware.js",
@@ -2,10 +2,7 @@ import { resolve, join } from 'pathe';
2
2
  import * as vite from 'vite';
3
3
  import { logger, isIgnored } from '@nuxt/kit';
4
4
  import { findExports, sanitizeFilePath } from 'mlly';
5
- import { createServer } from 'net';
6
- import { networkInterfaces } from 'os';
7
- import fs$1, { existsSync } from 'fs';
8
- import require$$1 from 'path';
5
+ import { getPort } from 'get-port-please';
9
6
  import { joinURL, withoutLeadingSlash } from 'ufo';
10
7
  import { d as distDir } from './module.mjs';
11
8
  import { createUnplugin } from 'unplugin';
@@ -14,6 +11,7 @@ import MagicString from 'magic-string';
14
11
  import { createVuePlugin } from 'vite-plugin-vue2';
15
12
  import PluginLegacy from '@vitejs/plugin-legacy';
16
13
  import { createHash } from 'crypto';
14
+ import { existsSync } from 'fs';
17
15
  import fse from 'fs-extra';
18
16
  import { debounce } from 'perfect-debounce';
19
17
  import { pathToFileURL } from 'url';
@@ -25,6 +23,7 @@ import defu from 'defu';
25
23
  import 'node-fetch';
26
24
  import 'nitropack';
27
25
  import 'h3';
26
+ import 'path';
28
27
  import 'untyped';
29
28
  import 'acorn';
30
29
  import 'estree-walker';
@@ -35,156 +34,6 @@ import 'unimport';
35
34
  import 'scule';
36
35
  import 'unplugin-vue2-script-setup/nuxt';
37
36
 
38
- var dist = {};
39
-
40
- Object.defineProperty(dist, '__esModule', { value: true });
41
-
42
- const fs = fs$1;
43
- const path = require$$1;
44
-
45
- const _memo = {
46
- _pid: process.pid
47
- };
48
- async function getMemo(config) {
49
- const options = getOptions(config);
50
- try {
51
- const memo = JSON.parse(await fs.promises.readFile(options.file, "utf-8")) || {};
52
- if (!memo._pid) {
53
- throw new Error("Memo lacks _pid");
54
- }
55
- if (memo._pid === _memo._pid || !isAlive(memo.pid)) {
56
- Object.assign(_memo, memo);
57
- _memo._pid = process.pid;
58
- }
59
- } catch (e) {
60
- }
61
- return _memo;
62
- }
63
- async function setMemo(memo, config) {
64
- const options = getOptions(config);
65
- Object.assign(_memo, memo);
66
- _memo._pid = process.pid;
67
- try {
68
- await fs.promises.mkdir(options.dir);
69
- } catch (e) {
70
- }
71
- try {
72
- await fs.promises.writeFile(options.file, JSON.stringify(_memo), "utf-8");
73
- } catch (e) {
74
- }
75
- }
76
- function getOptions(config) {
77
- const options = {...config};
78
- options.name = options.name || "default";
79
- options.dir = options.dir || path.resolve(process.cwd(), "node_modules/.cache/fs-memo");
80
- options.file = options.file || path.resolve(options.dir, options.name + ".json");
81
- return options;
82
- }
83
- function isAlive(pid) {
84
- try {
85
- process.kill(pid, 0);
86
- return true;
87
- } catch (e) {
88
- return e.code === "EPERM";
89
- }
90
- }
91
-
92
- var getMemo_1 = dist.getMemo = getMemo;
93
- var setMemo_1 = dist.setMemo = setMemo;
94
-
95
- async function getPort(config) {
96
- if (typeof config === "number" || typeof config === "string") {
97
- config = { port: parseInt(config + "") };
98
- }
99
- const options = {
100
- name: "default",
101
- random: false,
102
- port: parseInt(process.env.PORT || "") || 3e3,
103
- ports: [4e3, 5e3, 6e3, 7e3],
104
- host: void 0,
105
- memoName: "port",
106
- ...config
107
- };
108
- if (options.random) {
109
- return getRandomPort(options.host);
110
- }
111
- const portsToCheck = [
112
- options.port,
113
- ...options.ports
114
- ].filter(Boolean);
115
- const memoOptions = { name: options.memoName, dir: options.memoDir };
116
- const memoKey = "port_" + options.name;
117
- const memo = await getMemo_1(memoOptions);
118
- if (memo[memoKey]) {
119
- portsToCheck.push(memo[memoKey]);
120
- }
121
- const availablePort = await findPort(portsToCheck, options.host);
122
- await setMemo_1({ [memoKey]: availablePort }, memoOptions);
123
- return availablePort;
124
- }
125
- async function getRandomPort(host) {
126
- const port = await checkPort(0, host);
127
- if (port === false) {
128
- throw new Error("Unable to obtain an available random port number!");
129
- }
130
- return port;
131
- }
132
- async function checkPort(port, host = process.env.HOST) {
133
- if (!host) {
134
- host = getLocalHosts([void 0, "0.0.0.0"]);
135
- }
136
- if (!Array.isArray(host)) {
137
- return _checkPort(port, host);
138
- }
139
- for (const _host of host) {
140
- const _port = await _checkPort(port, _host);
141
- if (_port === false) {
142
- return false;
143
- }
144
- if (port === 0 && _port !== 0) {
145
- port = _port;
146
- }
147
- }
148
- return port;
149
- }
150
- function _checkPort(port, host) {
151
- return new Promise((resolve) => {
152
- const server = createServer();
153
- server.unref();
154
- server.on("error", (err) => {
155
- if (err.code === "EINVAL" || err.code === "EADDRNOTAVAIL") {
156
- resolve(port !== 0 ? port : false);
157
- } else {
158
- resolve(false);
159
- }
160
- });
161
- server.listen({ port, host }, () => {
162
- const { port: port2 } = server.address();
163
- server.close(() => {
164
- resolve(port2);
165
- });
166
- });
167
- });
168
- }
169
- function getLocalHosts(additional) {
170
- const hosts = new Set(additional);
171
- for (const _interface of Object.values(networkInterfaces())) {
172
- for (const config of _interface) {
173
- hosts.add(config.address);
174
- }
175
- }
176
- return Array.from(hosts);
177
- }
178
- async function findPort(ports, host) {
179
- for (const port of ports) {
180
- const r = await checkPort(port, host);
181
- if (r) {
182
- return r;
183
- }
184
- }
185
- return getRandomPort(host);
186
- }
187
-
188
37
  async function warmupViteServer(server, entries) {
189
38
  const warmedUrls = /* @__PURE__ */ new Set();
190
39
  const warmup = async (url) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxt/bridge-edge",
3
- "version": "3.0.0-27489107.bc7627d",
3
+ "version": "3.0.0-27490192.4253d2e",
4
4
  "repository": "nuxt/framework",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -21,9 +21,10 @@
21
21
  "@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.7",
22
22
  "@babel/plugin-proposal-optional-chaining": "^7.16.7",
23
23
  "@babel/plugin-transform-typescript": "^7.16.8",
24
- "@nuxt/kit": "npm:@nuxt/kit-edge@3.0.0-27489107.bc7627d",
24
+ "@nuxt/kit": "npm:@nuxt/kit-edge@3.0.0-27490192.4253d2e",
25
25
  "@nuxt/postcss8": "^1.1.3",
26
- "@nuxt/schema": "npm:@nuxt/schema-edge@3.0.0-27489107.bc7627d",
26
+ "@nuxt/schema": "npm:@nuxt/schema-edge@3.0.0-27490192.4253d2e",
27
+ "@nuxt/ui-templates": "npm:@nuxt/ui-templates-edge@latest",
27
28
  "@vitejs/plugin-legacy": "^1.8.0",
28
29
  "@vue/composition-api": "^1.4.9",
29
30
  "@vueuse/head": "^0.7.5",
@@ -36,6 +37,7 @@
36
37
  "estree-walker": "^3.0.1",
37
38
  "externality": "^0.2.1",
38
39
  "fs-extra": "^10.0.1",
40
+ "get-port-please": "^2.4.3",
39
41
  "globby": "^13.1.1",
40
42
  "h3": "^0.7.1",
41
43
  "hash-sum": "^2.0.0",
@@ -43,9 +45,9 @@
43
45
  "magic-string": "^0.26.1",
44
46
  "mlly": "^0.5.1",
45
47
  "murmurhash-es": "^0.1.1",
46
- "nitropack": "^0.1.2",
48
+ "nitropack": "^0.2.1",
47
49
  "node-fetch": "^3.2.3",
48
- "nuxi": "npm:nuxi-edge@3.0.0-27489107.bc7627d",
50
+ "nuxi": "npm:nuxi-edge@3.0.0-27490192.4253d2e",
49
51
  "ohash": "^0.1.0",
50
52
  "pathe": "^0.2.0",
51
53
  "perfect-debounce": "^0.1.3",