@nuxt/devtools 0.2.4 → 0.3.0
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.
- package/README.md +3 -3
- package/dist/chunks/module-main.mjs +693 -207
- package/dist/chunks/plugin-metrics.mjs +54 -0
- package/dist/chunks/vite-inspect.mjs +12 -13
- package/dist/chunks/vscode.mjs +44 -26
- package/dist/chunks/vue-inspector.mjs +2 -2
- package/dist/cli.mjs +5 -4
- package/dist/client/200.html +2 -2
- package/dist/client/404.html +2 -2
- package/dist/client/__inspecting/index.html +2 -2
- package/dist/client/_nuxt/Badge.0f8d5f6f.js +1 -0
- package/dist/client/_nuxt/DrawerRight.vue.6b933252.js +1 -0
- package/dist/client/_nuxt/DurationDisplay.vue.5c57289e.js +1 -0
- package/dist/client/_nuxt/FilepathItem.vue.e8c3a52c.js +1 -0
- package/dist/client/_nuxt/LaunchPage.vue.87f21877.js +1 -0
- package/dist/client/_nuxt/NCheckbox.vue.4b9ea1cc.js +1 -0
- package/dist/client/_nuxt/NCodeBlock.vue.431c1fae.js +1 -0
- package/dist/client/_nuxt/NIconButton.vue.9bdc7adc.js +1 -0
- package/dist/client/_nuxt/NIconTitle.vue.f40c1405.js +1 -0
- package/dist/client/_nuxt/NMarkdown.vue.725d1f67.js +1 -0
- package/dist/client/_nuxt/NSectionBlock.aae79980.js +1 -0
- package/dist/client/_nuxt/NSelect.vue.b136ef78.js +1 -0
- package/dist/client/_nuxt/NSwitch.vue.73a2b8d5.js +1 -0
- package/dist/client/_nuxt/NTextInput.vue.543d16d0.js +1 -0
- package/dist/client/_nuxt/NTip.vue.130b714b.js +1 -0
- package/dist/client/_nuxt/NpmVersionCheck.vue.b49a7a81.js +1 -0
- package/dist/client/_nuxt/NuxtLogo.18339464.js +1 -0
- package/dist/client/_nuxt/PanelLeftRight.vue.b026a23a.js +1 -0
- package/dist/client/_nuxt/StateEditor.vue.dae03388.js +1 -0
- package/dist/client/_nuxt/TabIcon.vue.d87fc756.js +1 -0
- package/dist/client/_nuxt/{__inspecting.3eb70499.js → __inspecting.9a5a53c2.js} +1 -1
- package/dist/client/_nuxt/assets.a9e5a6b0.js +16 -0
- package/dist/client/_nuxt/components.70b3c3a4.js +1 -0
- package/dist/client/_nuxt/context.c8f67be1.js +1 -0
- package/dist/client/_nuxt/custom-_name_.54344ca3.js +1 -0
- package/dist/client/_nuxt/default.a8c4c373.js +1 -0
- package/dist/client/_nuxt/editor.e302ec86.js +1 -0
- package/dist/client/_nuxt/entry.654353dc.css +32 -0
- package/dist/client/_nuxt/entry.91db41b9.js +259 -0
- package/dist/client/_nuxt/error-404.6d04f9a0.js +1 -0
- package/dist/client/_nuxt/error-500.44287dc0.js +1 -0
- package/dist/client/_nuxt/error-component.a0e84e89.js +3 -0
- package/dist/client/_nuxt/hooks.784bc58b.js +1 -0
- package/dist/client/_nuxt/icons.43eaabec.js +1 -0
- package/dist/client/_nuxt/imports.2e67f433.js +1 -0
- package/dist/client/_nuxt/{index.a6656ecb.js → index.3b3b7aca.js} +5 -5
- package/dist/client/_nuxt/index.4213289c.js +1 -0
- package/dist/client/_nuxt/index.c769634a.js +3 -0
- package/dist/client/_nuxt/layouts.3ece608d.js +1 -0
- package/dist/client/_nuxt/middleware.c0b48cbf.js +1 -0
- package/dist/client/_nuxt/modules.b85b1f76.js +1 -0
- package/dist/client/_nuxt/none.d95ed4cd.js +1 -0
- package/dist/client/_nuxt/overview.c2dfff9d.js +1 -0
- package/dist/client/_nuxt/pages.c8f066b4.js +1 -0
- package/dist/client/_nuxt/payload.299d8527.js +1 -0
- package/dist/client/_nuxt/plugins.4b3cd1e3.js +1 -0
- package/dist/client/_nuxt/runtime-configs.0f55338b.js +1 -0
- package/dist/client/_nuxt/server-routes.e48a8508.js +1 -0
- package/dist/client/_nuxt/settings.b70bc182.js +1 -0
- package/dist/client/_nuxt/storage.adf41f3f.js +1 -0
- package/dist/client/_nuxt/terminals.2f58f3e7.js +1 -0
- package/dist/client/_nuxt/terminals.4329aeb9.css +1 -0
- package/dist/client/_nuxt/{unocss-runtime.6f823b2d.js → unocss-runtime.f654b492.js} +2 -2
- package/dist/client/_nuxt/virtual-files.dbe38c70.js +1 -0
- package/dist/client/index.html +2 -2
- package/dist/client/modules/assets/index.html +7 -0
- package/dist/client/modules/components/index.html +2 -2
- package/dist/client/modules/hooks/index.html +2 -2
- package/dist/client/modules/imports/index.html +2 -2
- package/dist/client/modules/layouts/index.html +2 -2
- package/dist/client/modules/middleware/index.html +2 -2
- package/dist/client/modules/modules/index.html +2 -2
- package/dist/client/modules/overview/index.html +2 -2
- package/dist/client/modules/pages/index.html +2 -2
- package/dist/client/modules/payload/index.html +2 -2
- package/dist/client/modules/plugins/index.html +2 -2
- package/dist/client/modules/runtime-configs/index.html +2 -2
- package/dist/client/modules/server-routes/index.html +2 -2
- package/dist/client/modules/storage/index.html +7 -0
- package/dist/client/modules/terminals/index.html +7 -0
- package/dist/client/modules/virtual-files/index.html +2 -2
- package/dist/client/settings/index.html +7 -0
- package/dist/dirs.mjs +2 -2
- package/dist/module.d.ts +3 -31
- package/dist/module.json +1 -1
- package/dist/module.mjs +2 -2
- package/dist/runtime/plugins/devtools.client.mjs +7 -1
- package/dist/shared/{devtools.b6178134.mjs → devtools.30090c6e.mjs} +1 -1
- package/dist/types.d.ts +5 -326
- package/dist/types.mjs +1 -1
- package/package.json +38 -37
- package/dist/client/_nuxt/Badge.35e3d75f.js +0 -1
- package/dist/client/_nuxt/FilepathItem.vue.70457130.js +0 -1
- package/dist/client/_nuxt/LaunchPage.vue.15ef3f8b.js +0 -1
- package/dist/client/_nuxt/NButton.a7fda268.css +0 -1
- package/dist/client/_nuxt/NButton.vue.1aeb67fb.js +0 -113
- package/dist/client/_nuxt/NCheckbox.vue.7252d00f.js +0 -1
- package/dist/client/_nuxt/NIcon.vue.6416325d.js +0 -1
- package/dist/client/_nuxt/NSectionBlock.7c35c1a8.js +0 -1
- package/dist/client/_nuxt/NSectionBlock.891fa081.css +0 -1
- package/dist/client/_nuxt/NTextInput.vue.0fd513ee.js +0 -1
- package/dist/client/_nuxt/NuxtLogo.3b286105.js +0 -1
- package/dist/client/_nuxt/StateEditor.ce27b0a9.css +0 -1
- package/dist/client/_nuxt/StateEditor.vue.4b3d62c1.js +0 -1
- package/dist/client/_nuxt/StateEditor.vue.b4b0d299.js +0 -137
- package/dist/client/_nuxt/TabIcon.vue.dd710d5f.js +0 -1
- package/dist/client/_nuxt/_plugin-vue_export-helper.c27b6911.js +0 -1
- package/dist/client/_nuxt/asyncData.f4eab2cf.js +0 -1
- package/dist/client/_nuxt/components.b8fa7f92.js +0 -1
- package/dist/client/_nuxt/composables.8ff5f6b6.js +0 -1
- package/dist/client/_nuxt/context.c1f50e17.js +0 -1
- package/dist/client/_nuxt/custom-_name_.681ffd04.js +0 -1
- package/dist/client/_nuxt/default.2963fb37.js +0 -1
- package/dist/client/_nuxt/editor.b5249ede.js +0 -1
- package/dist/client/_nuxt/entry.27ee4abf.css +0 -1
- package/dist/client/_nuxt/entry.53ee6248.js +0 -5
- package/dist/client/_nuxt/error-404.4d908286.js +0 -1
- package/dist/client/_nuxt/error-500.e65c4924.js +0 -1
- package/dist/client/_nuxt/error-component.1a84e289.js +0 -3
- package/dist/client/_nuxt/hooks.b85de4f3.js +0 -1
- package/dist/client/_nuxt/icons.7b11eba5.js +0 -1
- package/dist/client/_nuxt/imports.48d7ddd5.js +0 -1
- package/dist/client/_nuxt/index.747f17a4.js +0 -1
- package/dist/client/_nuxt/layouts.8029422d.js +0 -1
- package/dist/client/_nuxt/middleware.671f87b6.js +0 -1
- package/dist/client/_nuxt/modules.56768ce2.js +0 -1
- package/dist/client/_nuxt/none.fa32461d.js +0 -1
- package/dist/client/_nuxt/nuxt-link.bdfe480b.js +0 -1
- package/dist/client/_nuxt/overview.71ae3521.js +0 -1
- package/dist/client/_nuxt/pages.611146bd.js +0 -1
- package/dist/client/_nuxt/payload.e24f2347.js +0 -1
- package/dist/client/_nuxt/plugins.a24c21cb.js +0 -1
- package/dist/client/_nuxt/runtime-configs.9225ca28.js +0 -1
- package/dist/client/_nuxt/server-routes.7c4496d9.js +0 -1
- package/dist/client/_nuxt/state.647f0c35.js +0 -1
- package/dist/client/_nuxt/virtual-files.33ac3fab.js +0 -9
- package/dist/iframe-client.d.ts +0 -13
- package/dist/iframe-client.mjs +0 -30
- package/iframe-client.d.ts +0 -1
|
@@ -1,26 +1,35 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import require$$0$
|
|
6
|
-
import require$$0 from '
|
|
7
|
-
import require$$0$1 from 'buffer';
|
|
1
|
+
import { join as join$3 } from 'node:path';
|
|
2
|
+
import fs, { existsSync } from 'node:fs';
|
|
3
|
+
import { useNuxt, logger, addPlugin } from '@nuxt/kit';
|
|
4
|
+
import require$$0$3 from 'stream';
|
|
5
|
+
import require$$0$1 from 'zlib';
|
|
6
|
+
import require$$0$2 from 'buffer';
|
|
8
7
|
import require$$3 from 'net';
|
|
9
8
|
import require$$4 from 'tls';
|
|
10
9
|
import require$$5 from 'crypto';
|
|
11
|
-
import require$$0$
|
|
10
|
+
import require$$0$4 from 'events';
|
|
12
11
|
import require$$2 from 'https';
|
|
13
12
|
import require$$1 from 'http';
|
|
14
|
-
import require$$0$
|
|
13
|
+
import require$$0$5 from 'url';
|
|
15
14
|
import { searchForWorkspaceRoot } from 'vite';
|
|
15
|
+
import * as require$$0 from 'fs';
|
|
16
|
+
import { readdirSync, statSync } from 'fs';
|
|
17
|
+
import { resolve, join as join$1, normalize as normalize$1 } from 'path';
|
|
16
18
|
import * as qs from 'querystring';
|
|
17
|
-
import require$$0$
|
|
18
|
-
import { v as version } from '../shared/devtools.
|
|
19
|
+
import require$$0$6 from 'tty';
|
|
20
|
+
import { v as version } from '../shared/devtools.30090c6e.mjs';
|
|
19
21
|
import { createBirpcGroup } from 'birpc';
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import
|
|
22
|
+
import fsp, { readFile } from 'node:fs/promises';
|
|
23
|
+
import { resolve as resolve$1, join as join$2, dirname } from 'pathe';
|
|
24
|
+
import { imageMeta } from 'image-meta';
|
|
25
|
+
import fg from 'fast-glob';
|
|
26
|
+
import { startSubprocess } from '@nuxt/devtools-kit';
|
|
27
|
+
import isInstalledGlobally from 'is-installed-globally';
|
|
28
|
+
import 'node:child_process';
|
|
29
|
+
import { createRequire } from 'node:module';
|
|
23
30
|
import 'pkg-types';
|
|
31
|
+
import { getPackageInfo } from 'local-pkg';
|
|
32
|
+
import { resolvePreset } from 'unimport';
|
|
24
33
|
import { runtimeDir, clientDir, packageDir, isGlobalInstall } from '../dirs.mjs';
|
|
25
34
|
import { R as ROUTE_ENTRY, a as ROUTE_CLIENT } from '../shared/devtools.95cf6023.mjs';
|
|
26
35
|
|
|
@@ -237,7 +246,7 @@ let Limiter$1 = class Limiter {
|
|
|
237
246
|
|
|
238
247
|
var limiter = Limiter$1;
|
|
239
248
|
|
|
240
|
-
const zlib = require$$0;
|
|
249
|
+
const zlib = require$$0$1;
|
|
241
250
|
|
|
242
251
|
const bufferUtil = bufferUtilExports;
|
|
243
252
|
const Limiter = limiter;
|
|
@@ -758,7 +767,7 @@ var validation = {
|
|
|
758
767
|
|
|
759
768
|
var isValidUTF8_1;
|
|
760
769
|
|
|
761
|
-
const { isUtf8 } = require$$0$
|
|
770
|
+
const { isUtf8 } = require$$0$2;
|
|
762
771
|
|
|
763
772
|
//
|
|
764
773
|
// Allowed token characters:
|
|
@@ -887,7 +896,7 @@ if (isUtf8) {
|
|
|
887
896
|
}
|
|
888
897
|
}
|
|
889
898
|
|
|
890
|
-
const { Writable } = require$$0$
|
|
899
|
+
const { Writable } = require$$0$3;
|
|
891
900
|
|
|
892
901
|
const PerMessageDeflate$3 = permessageDeflate;
|
|
893
902
|
const {
|
|
@@ -2482,13 +2491,13 @@ var extension$1 = { format: format$1, parse: parse$b };
|
|
|
2482
2491
|
|
|
2483
2492
|
/* eslint no-unused-vars: ["error", { "varsIgnorePattern": "^Readable$" }] */
|
|
2484
2493
|
|
|
2485
|
-
const EventEmitter$1 = require$$0$
|
|
2494
|
+
const EventEmitter$1 = require$$0$4;
|
|
2486
2495
|
const https = require$$2;
|
|
2487
2496
|
const http$1 = require$$1;
|
|
2488
2497
|
const net = require$$3;
|
|
2489
2498
|
const tls = require$$4;
|
|
2490
2499
|
const { randomBytes, createHash: createHash$1 } = require$$5;
|
|
2491
|
-
const { URL } = require$$0$
|
|
2500
|
+
const { URL } = require$$0$5;
|
|
2492
2501
|
|
|
2493
2502
|
const PerMessageDeflate$1 = permessageDeflate;
|
|
2494
2503
|
const Receiver = receiver;
|
|
@@ -3468,7 +3477,11 @@ function initAsClient(websocket, address, protocols, options) {
|
|
|
3468
3477
|
});
|
|
3469
3478
|
});
|
|
3470
3479
|
|
|
3471
|
-
|
|
3480
|
+
if (opts.finishRequest) {
|
|
3481
|
+
opts.finishRequest(req, websocket);
|
|
3482
|
+
} else {
|
|
3483
|
+
req.end();
|
|
3484
|
+
}
|
|
3472
3485
|
}
|
|
3473
3486
|
|
|
3474
3487
|
/**
|
|
@@ -3848,7 +3861,7 @@ var subprotocol$1 = { parse: parse$9 };
|
|
|
3848
3861
|
|
|
3849
3862
|
/* eslint no-unused-vars: ["error", { "varsIgnorePattern": "^net|tls|https$" }] */
|
|
3850
3863
|
|
|
3851
|
-
const EventEmitter = require$$0$
|
|
3864
|
+
const EventEmitter = require$$0$4;
|
|
3852
3865
|
const http = require$$1;
|
|
3853
3866
|
const { createHash } = require$$5;
|
|
3854
3867
|
|
|
@@ -4384,11 +4397,11 @@ function totalist(dir, callback, pre='') {
|
|
|
4384
4397
|
let arr = readdirSync(dir);
|
|
4385
4398
|
let i=0, abs, stats;
|
|
4386
4399
|
for (; i < arr.length; i++) {
|
|
4387
|
-
abs = join(dir, arr[i]);
|
|
4400
|
+
abs = join$1(dir, arr[i]);
|
|
4388
4401
|
stats = statSync(abs);
|
|
4389
4402
|
stats.isDirectory()
|
|
4390
|
-
? totalist(abs, callback, join(pre, arr[i]))
|
|
4391
|
-
: callback(join(pre, arr[i]), abs, stats);
|
|
4403
|
+
? totalist(abs, callback, join$1(pre, arr[i]))
|
|
4404
|
+
: callback(join$1(pre, arr[i]), abs, stats);
|
|
4392
4405
|
}
|
|
4393
4406
|
}
|
|
4394
4407
|
|
|
@@ -4881,9 +4894,9 @@ function viaLocal(dir, isEtag, uri, extns) {
|
|
|
4881
4894
|
let i=0, arr=toAssume(uri, extns);
|
|
4882
4895
|
let abs, stats, name, headers;
|
|
4883
4896
|
for (; i < arr.length; i++) {
|
|
4884
|
-
abs = normalize(join(dir, name=arr[i]));
|
|
4885
|
-
if (abs.startsWith(dir) &&
|
|
4886
|
-
stats =
|
|
4897
|
+
abs = normalize$1(join$1(dir, name=arr[i]));
|
|
4898
|
+
if (abs.startsWith(dir) && require$$0.existsSync(abs)) {
|
|
4899
|
+
stats = require$$0.statSync(abs);
|
|
4887
4900
|
if (stats.isDirectory()) continue;
|
|
4888
4901
|
headers = toHeaders(name, stats, isEtag);
|
|
4889
4902
|
headers['Cache-Control'] = isEtag ? 'no-cache' : 'no-store';
|
|
@@ -4927,7 +4940,7 @@ function send(req, res, file, stats, headers) {
|
|
|
4927
4940
|
}
|
|
4928
4941
|
|
|
4929
4942
|
res.writeHead(code, headers);
|
|
4930
|
-
|
|
4943
|
+
require$$0.createReadStream(file, opts).pipe(res);
|
|
4931
4944
|
}
|
|
4932
4945
|
|
|
4933
4946
|
const ENCODING = {
|
|
@@ -5037,7 +5050,7 @@ var picocolors = {
|
|
|
5037
5050
|
set exports(v){ picocolorsExports = v; },
|
|
5038
5051
|
};
|
|
5039
5052
|
|
|
5040
|
-
let tty = require$$0$
|
|
5053
|
+
let tty = require$$0$6;
|
|
5041
5054
|
|
|
5042
5055
|
let isColorSupported =
|
|
5043
5056
|
!("NO_COLOR" in process.env || process.argv.includes("--no-color")) &&
|
|
@@ -5188,74 +5201,290 @@ const stringify = (value, replacer, space) => {
|
|
|
5188
5201
|
}
|
|
5189
5202
|
};
|
|
5190
5203
|
|
|
5191
|
-
|
|
5192
|
-
|
|
5193
|
-
|
|
5194
|
-
|
|
5195
|
-
|
|
5196
|
-
|
|
5197
|
-
|
|
5198
|
-
|
|
5199
|
-
|
|
5200
|
-
|
|
5201
|
-
|
|
5202
|
-
|
|
5203
|
-
|
|
5204
|
-
|
|
5205
|
-
|
|
5206
|
-
|
|
5207
|
-
|
|
5208
|
-
|
|
5209
|
-
|
|
5204
|
+
const IGNORE_STORAGE_MOUNTS = ["root", "build", "src", "cache"];
|
|
5205
|
+
const shouldIgnoreStorageKey = (key) => IGNORE_STORAGE_MOUNTS.includes(key.split(":")[0]);
|
|
5206
|
+
function setupStorageRPC({
|
|
5207
|
+
nuxt,
|
|
5208
|
+
rpc
|
|
5209
|
+
}) {
|
|
5210
|
+
const storageMounts = {};
|
|
5211
|
+
let storage;
|
|
5212
|
+
nuxt.hook("nitro:init", (nitro) => {
|
|
5213
|
+
storage = nitro.storage;
|
|
5214
|
+
nuxt.hook("ready", () => {
|
|
5215
|
+
storage.watch((event, key) => {
|
|
5216
|
+
if (shouldIgnoreStorageKey(key))
|
|
5217
|
+
return;
|
|
5218
|
+
rpc.broadcast.callHook.asEvent("storage:key:update", key, event);
|
|
5219
|
+
});
|
|
5220
|
+
});
|
|
5221
|
+
const mounts = {
|
|
5222
|
+
...nitro.options.storage,
|
|
5223
|
+
...nitro.options.devStorage
|
|
5224
|
+
};
|
|
5225
|
+
for (const name of Object.keys(mounts)) {
|
|
5226
|
+
if (shouldIgnoreStorageKey(name))
|
|
5227
|
+
continue;
|
|
5228
|
+
storageMounts[name] = mounts[name];
|
|
5210
5229
|
}
|
|
5211
5230
|
});
|
|
5212
|
-
|
|
5213
|
-
|
|
5214
|
-
|
|
5215
|
-
|
|
5216
|
-
|
|
5217
|
-
|
|
5218
|
-
|
|
5219
|
-
|
|
5220
|
-
|
|
5221
|
-
|
|
5222
|
-
|
|
5231
|
+
return {
|
|
5232
|
+
async getStorageMounts() {
|
|
5233
|
+
return storageMounts;
|
|
5234
|
+
},
|
|
5235
|
+
async getStorageKeys(base) {
|
|
5236
|
+
if (!storage)
|
|
5237
|
+
return [];
|
|
5238
|
+
try {
|
|
5239
|
+
const keys = await storage.getKeys(base);
|
|
5240
|
+
return keys.filter((key) => !shouldIgnoreStorageKey(key));
|
|
5241
|
+
} catch (err) {
|
|
5242
|
+
console.error(`Cloud not fetch storage keys for ${base}:`, err);
|
|
5243
|
+
return [];
|
|
5244
|
+
}
|
|
5245
|
+
},
|
|
5246
|
+
async getStorageItem(key) {
|
|
5247
|
+
if (!storage)
|
|
5248
|
+
return null;
|
|
5249
|
+
return await storage.getItem(key);
|
|
5250
|
+
},
|
|
5251
|
+
async setStorageItem(key, value) {
|
|
5252
|
+
if (!storage)
|
|
5253
|
+
return;
|
|
5254
|
+
return await storage.setItem(key, value);
|
|
5255
|
+
},
|
|
5256
|
+
async removeStorageItem(key) {
|
|
5257
|
+
if (!storage)
|
|
5258
|
+
return;
|
|
5259
|
+
return await storage.removeItem(key);
|
|
5260
|
+
}
|
|
5261
|
+
};
|
|
5223
5262
|
}
|
|
5224
5263
|
|
|
5225
|
-
|
|
5226
|
-
const
|
|
5227
|
-
|
|
5264
|
+
function setupAssetsRPC({ nuxt }) {
|
|
5265
|
+
const _imageMetaCache = /* @__PURE__ */ new Map();
|
|
5266
|
+
return {
|
|
5267
|
+
async getStaticAssets() {
|
|
5268
|
+
const dir = resolve$1(nuxt.options.srcDir, nuxt.options.dir.public);
|
|
5269
|
+
const baseURL = nuxt.options.app.baseURL;
|
|
5270
|
+
const files = await fg(["**/*"], {
|
|
5271
|
+
cwd: dir,
|
|
5272
|
+
onlyFiles: true
|
|
5273
|
+
});
|
|
5274
|
+
function guessType(path) {
|
|
5275
|
+
if (/\.(png|jpe?g|gif|svg|webp|avif|ico|bmp|tiff?)$/i.test(path))
|
|
5276
|
+
return "image";
|
|
5277
|
+
if (/\.(mp4|webm|ogv|mov|avi|flv|wmv|mpg|mpeg|mkv|3gp|3g2|ts|mts|m2ts|vob|ogm|ogx|rm|rmvb|asf|amv|divx|m4v|svi|viv|f4v|f4p|f4a|f4b)$/i.test(path))
|
|
5278
|
+
return "video";
|
|
5279
|
+
if (/\.(mp3|wav|ogg|flac|aac|wma|alac|ape|ac3|dts|tta|opus|amr|aiff|au|mid|midi|ra|rm|wv|weba|dss|spx|vox|tak|dsf|dff|dsd|cda)$/i.test(path))
|
|
5280
|
+
return "audio";
|
|
5281
|
+
if (/\.(woff2?|eot|ttf|otf|ttc|pfa|pfb|pfm|afm)/i.test(path))
|
|
5282
|
+
return "font";
|
|
5283
|
+
if (/\.(json[5c]?|te?xt|[mc]?[jt]sx?|md[cx]?|markdown)/i.test(path))
|
|
5284
|
+
return "text";
|
|
5285
|
+
return "other";
|
|
5286
|
+
}
|
|
5287
|
+
return await Promise.all(files.map(async (path) => {
|
|
5288
|
+
const filePath = resolve$1(dir, path);
|
|
5289
|
+
const stat = await fsp.lstat(filePath);
|
|
5290
|
+
return {
|
|
5291
|
+
path,
|
|
5292
|
+
publicPath: join$2(baseURL, path),
|
|
5293
|
+
filePath,
|
|
5294
|
+
type: guessType(path),
|
|
5295
|
+
size: stat.size,
|
|
5296
|
+
mtime: stat.mtimeMs
|
|
5297
|
+
};
|
|
5298
|
+
}));
|
|
5299
|
+
},
|
|
5300
|
+
async getImageMeta(filepath) {
|
|
5301
|
+
if (_imageMetaCache.has(filepath))
|
|
5302
|
+
return _imageMetaCache.get(filepath);
|
|
5303
|
+
try {
|
|
5304
|
+
const meta = imageMeta(await fsp.readFile(filepath));
|
|
5305
|
+
_imageMetaCache.set(filepath, meta);
|
|
5306
|
+
return meta;
|
|
5307
|
+
} catch (e) {
|
|
5308
|
+
_imageMetaCache.set(filepath, void 0);
|
|
5309
|
+
console.error(e);
|
|
5310
|
+
return void 0;
|
|
5311
|
+
}
|
|
5312
|
+
},
|
|
5313
|
+
async getTextAssetContent(filepath, limit = 300) {
|
|
5314
|
+
try {
|
|
5315
|
+
const content = await fsp.readFile(filepath, "utf-8");
|
|
5316
|
+
return content.slice(0, limit);
|
|
5317
|
+
} catch (e) {
|
|
5318
|
+
console.error(e);
|
|
5319
|
+
return void 0;
|
|
5320
|
+
}
|
|
5321
|
+
}
|
|
5322
|
+
};
|
|
5323
|
+
}
|
|
5228
5324
|
|
|
5229
|
-
|
|
5230
|
-
|
|
5231
|
-
|
|
5232
|
-
<p>Current route: {{ route.path }}</p>
|
|
5233
|
-
<a href="https://nuxt.com/docs/getting-started/routing" target="_blank">Learn more about Nuxt Routing</a>
|
|
5234
|
-
</div>
|
|
5235
|
-
</template>
|
|
5236
|
-
`;
|
|
5237
|
-
async function enablePages(nuxt) {
|
|
5238
|
-
const pathApp = join$1(nuxt.options.srcDir, "app.vue");
|
|
5239
|
-
const pathPageIndex = join$1(nuxt.options.srcDir, "pages/index.vue");
|
|
5240
|
-
if (fs__default.existsSync(pathPageIndex)) {
|
|
5241
|
-
logger.warn("pages/index.vue already exists, skipping");
|
|
5242
|
-
return;
|
|
5243
|
-
}
|
|
5244
|
-
let appContent = fs__default.existsSync(pathApp) ? await fsp.readFile(pathApp, "utf-8") : void 0;
|
|
5245
|
-
await fsp.mkdir(dirname(pathPageIndex), { recursive: true });
|
|
5246
|
-
await fsp.writeFile(pathPageIndex, pagesIndexTemplate, "utf-8");
|
|
5247
|
-
if (appContent && !appContent.includes("<NuxtPage")) {
|
|
5248
|
-
appContent = appContent.replace("</template>", " <NuxtPage />\n</template>").replace(/<NuxtWelcome\s*\/>/, "");
|
|
5249
|
-
await fsp.writeFile(pathApp, appContent, "utf-8");
|
|
5325
|
+
function normalizeWindowsPath(input = "") {
|
|
5326
|
+
if (!input || !input.includes("\\")) {
|
|
5327
|
+
return input;
|
|
5250
5328
|
}
|
|
5251
|
-
|
|
5329
|
+
return input.replace(/\\/g, "/");
|
|
5252
5330
|
}
|
|
5253
5331
|
|
|
5254
|
-
const
|
|
5255
|
-
|
|
5332
|
+
const _UNC_REGEX = /^[/\\]{2}/;
|
|
5333
|
+
const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
|
|
5334
|
+
const _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
|
|
5335
|
+
const normalize = function(path) {
|
|
5336
|
+
if (path.length === 0) {
|
|
5337
|
+
return ".";
|
|
5338
|
+
}
|
|
5339
|
+
path = normalizeWindowsPath(path);
|
|
5340
|
+
const isUNCPath = path.match(_UNC_REGEX);
|
|
5341
|
+
const isPathAbsolute = isAbsolute(path);
|
|
5342
|
+
const trailingSeparator = path[path.length - 1] === "/";
|
|
5343
|
+
path = normalizeString(path, !isPathAbsolute);
|
|
5344
|
+
if (path.length === 0) {
|
|
5345
|
+
if (isPathAbsolute) {
|
|
5346
|
+
return "/";
|
|
5347
|
+
}
|
|
5348
|
+
return trailingSeparator ? "./" : ".";
|
|
5349
|
+
}
|
|
5350
|
+
if (trailingSeparator) {
|
|
5351
|
+
path += "/";
|
|
5352
|
+
}
|
|
5353
|
+
if (_DRIVE_LETTER_RE.test(path)) {
|
|
5354
|
+
path += "/";
|
|
5355
|
+
}
|
|
5356
|
+
if (isUNCPath) {
|
|
5357
|
+
if (!isPathAbsolute) {
|
|
5358
|
+
return `//./${path}`;
|
|
5359
|
+
}
|
|
5360
|
+
return `//${path}`;
|
|
5361
|
+
}
|
|
5362
|
+
return isPathAbsolute && !isAbsolute(path) ? `/${path}` : path;
|
|
5363
|
+
};
|
|
5364
|
+
const join = function(...arguments_) {
|
|
5365
|
+
if (arguments_.length === 0) {
|
|
5366
|
+
return ".";
|
|
5367
|
+
}
|
|
5368
|
+
let joined;
|
|
5369
|
+
for (const argument of arguments_) {
|
|
5370
|
+
if (argument && argument.length > 0) {
|
|
5371
|
+
if (joined === void 0) {
|
|
5372
|
+
joined = argument;
|
|
5373
|
+
} else {
|
|
5374
|
+
joined += `/${argument}`;
|
|
5375
|
+
}
|
|
5376
|
+
}
|
|
5377
|
+
}
|
|
5378
|
+
if (joined === void 0) {
|
|
5379
|
+
return ".";
|
|
5380
|
+
}
|
|
5381
|
+
return normalize(joined.replace(/\/\/+/g, "/"));
|
|
5382
|
+
};
|
|
5383
|
+
function normalizeString(path, allowAboveRoot) {
|
|
5384
|
+
let res = "";
|
|
5385
|
+
let lastSegmentLength = 0;
|
|
5386
|
+
let lastSlash = -1;
|
|
5387
|
+
let dots = 0;
|
|
5388
|
+
let char = null;
|
|
5389
|
+
for (let index = 0; index <= path.length; ++index) {
|
|
5390
|
+
if (index < path.length) {
|
|
5391
|
+
char = path[index];
|
|
5392
|
+
} else if (char === "/") {
|
|
5393
|
+
break;
|
|
5394
|
+
} else {
|
|
5395
|
+
char = "/";
|
|
5396
|
+
}
|
|
5397
|
+
if (char === "/") {
|
|
5398
|
+
if (lastSlash === index - 1 || dots === 1) ; else if (dots === 2) {
|
|
5399
|
+
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
5400
|
+
if (res.length > 2) {
|
|
5401
|
+
const lastSlashIndex = res.lastIndexOf("/");
|
|
5402
|
+
if (lastSlashIndex === -1) {
|
|
5403
|
+
res = "";
|
|
5404
|
+
lastSegmentLength = 0;
|
|
5405
|
+
} else {
|
|
5406
|
+
res = res.slice(0, lastSlashIndex);
|
|
5407
|
+
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
|
5408
|
+
}
|
|
5409
|
+
lastSlash = index;
|
|
5410
|
+
dots = 0;
|
|
5411
|
+
continue;
|
|
5412
|
+
} else if (res.length > 0) {
|
|
5413
|
+
res = "";
|
|
5414
|
+
lastSegmentLength = 0;
|
|
5415
|
+
lastSlash = index;
|
|
5416
|
+
dots = 0;
|
|
5417
|
+
continue;
|
|
5418
|
+
}
|
|
5419
|
+
}
|
|
5420
|
+
if (allowAboveRoot) {
|
|
5421
|
+
res += res.length > 0 ? "/.." : "..";
|
|
5422
|
+
lastSegmentLength = 2;
|
|
5423
|
+
}
|
|
5424
|
+
} else {
|
|
5425
|
+
if (res.length > 0) {
|
|
5426
|
+
res += `/${path.slice(lastSlash + 1, index)}`;
|
|
5427
|
+
} else {
|
|
5428
|
+
res = path.slice(lastSlash + 1, index);
|
|
5429
|
+
}
|
|
5430
|
+
lastSegmentLength = index - lastSlash - 1;
|
|
5431
|
+
}
|
|
5432
|
+
lastSlash = index;
|
|
5433
|
+
dots = 0;
|
|
5434
|
+
} else if (char === "." && dots !== -1) {
|
|
5435
|
+
++dots;
|
|
5436
|
+
} else {
|
|
5437
|
+
dots = -1;
|
|
5438
|
+
}
|
|
5439
|
+
}
|
|
5440
|
+
return res;
|
|
5441
|
+
}
|
|
5442
|
+
const isAbsolute = function(p) {
|
|
5443
|
+
return _IS_ABSOLUTE_RE.test(p);
|
|
5256
5444
|
};
|
|
5257
5445
|
|
|
5258
|
-
const
|
|
5446
|
+
const packageManagerLocks = {
|
|
5447
|
+
"yarn.lock": "yarn",
|
|
5448
|
+
"package-lock.json": "npm",
|
|
5449
|
+
"pnpm-lock.yaml": "pnpm"
|
|
5450
|
+
};
|
|
5451
|
+
async function detectPackageManager(cwd, options = {}) {
|
|
5452
|
+
const detected = await findup(cwd, async (path) => {
|
|
5453
|
+
if (!options.ignorePackageJSON) {
|
|
5454
|
+
const packageJSONPath = join(path, "package.json");
|
|
5455
|
+
if (existsSync(packageJSONPath)) {
|
|
5456
|
+
const packageJSON = JSON.parse(await readFile(packageJSONPath, "utf8"));
|
|
5457
|
+
if (packageJSON?.packageManager) {
|
|
5458
|
+
const [name, version] = packageJSON.packageManager.split("@");
|
|
5459
|
+
return { name, version };
|
|
5460
|
+
}
|
|
5461
|
+
}
|
|
5462
|
+
}
|
|
5463
|
+
if (!options.ignoreLockFile) {
|
|
5464
|
+
for (const lockFile in packageManagerLocks) {
|
|
5465
|
+
if (existsSync(join(path, lockFile))) {
|
|
5466
|
+
return { name: packageManagerLocks[lockFile] };
|
|
5467
|
+
}
|
|
5468
|
+
}
|
|
5469
|
+
}
|
|
5470
|
+
});
|
|
5471
|
+
return {
|
|
5472
|
+
name: "npm",
|
|
5473
|
+
version: "latest",
|
|
5474
|
+
...detected
|
|
5475
|
+
};
|
|
5476
|
+
}
|
|
5477
|
+
async function findup(cwd, match) {
|
|
5478
|
+
const segments = normalize(cwd).split("/");
|
|
5479
|
+
while (segments.length > 0) {
|
|
5480
|
+
const path = segments.join("/");
|
|
5481
|
+
const result = await match(path);
|
|
5482
|
+
if (result) {
|
|
5483
|
+
return result;
|
|
5484
|
+
}
|
|
5485
|
+
segments.pop();
|
|
5486
|
+
}
|
|
5487
|
+
}
|
|
5259
5488
|
|
|
5260
5489
|
var reExports = {};
|
|
5261
5490
|
var re$3 = {
|
|
@@ -8164,113 +8393,98 @@ var semver = {
|
|
|
8164
8393
|
rcompareIdentifiers: identifiers.rcompareIdentifiers,
|
|
8165
8394
|
};
|
|
8166
8395
|
|
|
8167
|
-
async function checkForUpdateOf(
|
|
8396
|
+
async function checkForUpdateOf(name, current, nuxt = useNuxt()) {
|
|
8397
|
+
if (!current) {
|
|
8398
|
+
const require = createRequire(nuxt.options.rootDir);
|
|
8399
|
+
const info = await getPackageInfo(name, { paths: require.resolve.paths(name) || void 0 });
|
|
8400
|
+
if (!info)
|
|
8401
|
+
return;
|
|
8402
|
+
current = info.packageJson.version;
|
|
8403
|
+
}
|
|
8168
8404
|
const packument = await import('pacote').then((r) => r.default?.packument || r.packument);
|
|
8169
|
-
const manifest = await packument(
|
|
8405
|
+
const manifest = await packument(name);
|
|
8170
8406
|
const latest = manifest["dist-tags"].latest;
|
|
8171
|
-
const needsUpdate = latest !==
|
|
8407
|
+
const needsUpdate = latest !== current && semver.lt(current, latest);
|
|
8172
8408
|
return {
|
|
8173
|
-
|
|
8409
|
+
name,
|
|
8410
|
+
current,
|
|
8174
8411
|
latest,
|
|
8175
8412
|
needsUpdate
|
|
8176
8413
|
};
|
|
8177
8414
|
}
|
|
8178
|
-
|
|
8179
|
-
|
|
8180
|
-
|
|
8181
|
-
|
|
8182
|
-
|
|
8183
|
-
|
|
8184
|
-
|
|
8185
|
-
|
|
8186
|
-
|
|
8187
|
-
|
|
8415
|
+
|
|
8416
|
+
function setupNpmRPC({ nuxt }) {
|
|
8417
|
+
let detectPromise;
|
|
8418
|
+
const updatesPromise = /* @__PURE__ */ new Map();
|
|
8419
|
+
function getPackageManager() {
|
|
8420
|
+
detectPromise || (detectPromise = detectPackageManager(nuxt.options.rootDir).then((r) => r.name));
|
|
8421
|
+
return detectPromise;
|
|
8422
|
+
}
|
|
8423
|
+
async function getNpmCommand(command, packageName, options = {}) {
|
|
8424
|
+
const {
|
|
8425
|
+
dev = true,
|
|
8426
|
+
global = packageName === "@nuxt/devtools" && isInstalledGlobally
|
|
8427
|
+
} = options;
|
|
8428
|
+
const agent = await getPackageManager();
|
|
8429
|
+
if (command === "install" || command === "update")
|
|
8430
|
+
return [agent, agent === "npm" ? "install" : "add", `${packageName}@latest`, dev ? "-D" : "", global ? "-g" : "", "--ignore-scripts"].filter(Boolean);
|
|
8431
|
+
}
|
|
8432
|
+
async function runNpmCommand(command, packageName, options = {}) {
|
|
8433
|
+
const args = await getNpmCommand(command, packageName, options);
|
|
8434
|
+
if (!args)
|
|
8435
|
+
return;
|
|
8436
|
+
const processId = `npm:${command}:${packageName}`;
|
|
8437
|
+
startSubprocess({
|
|
8438
|
+
command: args[0],
|
|
8439
|
+
args: args.slice(1)
|
|
8440
|
+
}, {
|
|
8441
|
+
id: processId,
|
|
8442
|
+
name: `${command} ${packageName}`,
|
|
8443
|
+
icon: "i-mdi-npm-variant-outline text-rose",
|
|
8444
|
+
restartable: false
|
|
8445
|
+
});
|
|
8446
|
+
return {
|
|
8447
|
+
processId
|
|
8448
|
+
};
|
|
8449
|
+
}
|
|
8450
|
+
return {
|
|
8451
|
+
checkForUpdateFor(name) {
|
|
8452
|
+
if (!updatesPromise.has(name))
|
|
8453
|
+
updatesPromise.set(name, checkForUpdateOf(name, void 0, nuxt));
|
|
8454
|
+
return updatesPromise.get(name);
|
|
8455
|
+
},
|
|
8456
|
+
getPackageManager,
|
|
8457
|
+
getNpmCommand,
|
|
8458
|
+
runNpmCommand
|
|
8459
|
+
};
|
|
8188
8460
|
}
|
|
8189
8461
|
|
|
8190
|
-
function
|
|
8191
|
-
const components = [];
|
|
8192
|
-
const imports = [];
|
|
8193
|
-
const importPresets = [];
|
|
8194
|
-
const serverPages = [];
|
|
8462
|
+
function setupCustomTabRPC({ nuxt, options, refresh }) {
|
|
8195
8463
|
const iframeTabs = [];
|
|
8196
8464
|
const customTabs = [];
|
|
8197
|
-
|
|
8198
|
-
|
|
8199
|
-
|
|
8200
|
-
|
|
8201
|
-
|
|
8202
|
-
const serverFunctions = {};
|
|
8203
|
-
const clients = /* @__PURE__ */ new Set();
|
|
8204
|
-
const birpc = createBirpcGroup(serverFunctions, []);
|
|
8205
|
-
function refresh(event) {
|
|
8206
|
-
birpc.broadcast.refresh.asEvent(event);
|
|
8465
|
+
if (options.customTabs?.length)
|
|
8466
|
+
customTabs.push(...options.customTabs);
|
|
8467
|
+
async function initHooks() {
|
|
8468
|
+
nuxt.hook("devtools:customTabs:refresh", initCustomTabs);
|
|
8469
|
+
await initCustomTabs();
|
|
8207
8470
|
}
|
|
8208
|
-
|
|
8209
|
-
|
|
8210
|
-
|
|
8211
|
-
|
|
8212
|
-
|
|
8213
|
-
|
|
8214
|
-
|
|
8215
|
-
|
|
8216
|
-
|
|
8217
|
-
|
|
8218
|
-
|
|
8219
|
-
return serverPages;
|
|
8220
|
-
},
|
|
8221
|
-
getAutoImports() {
|
|
8222
|
-
return {
|
|
8223
|
-
imports: [
|
|
8224
|
-
...imports,
|
|
8225
|
-
...importPresets
|
|
8226
|
-
],
|
|
8227
|
-
metadata: unimport?.getMetadata()
|
|
8228
|
-
};
|
|
8229
|
-
},
|
|
8471
|
+
async function initCustomTabs() {
|
|
8472
|
+
customTabs.length = 0;
|
|
8473
|
+
if (options.customTabs?.length)
|
|
8474
|
+
customTabs.push(...options.customTabs);
|
|
8475
|
+
await nuxt.callHook("devtools:customTabs", customTabs);
|
|
8476
|
+
refresh("getCustomTabs");
|
|
8477
|
+
}
|
|
8478
|
+
nuxt.hook("app:resolve", async () => {
|
|
8479
|
+
await initHooks();
|
|
8480
|
+
});
|
|
8481
|
+
return {
|
|
8230
8482
|
getCustomTabs() {
|
|
8231
8483
|
return [
|
|
8232
8484
|
...iframeTabs,
|
|
8233
8485
|
...customTabs
|
|
8234
8486
|
];
|
|
8235
8487
|
},
|
|
8236
|
-
getServerLayouts() {
|
|
8237
|
-
return Object.values(app?.layouts || []);
|
|
8238
|
-
},
|
|
8239
|
-
getServerHooks() {
|
|
8240
|
-
return Object.values(serverHooks);
|
|
8241
|
-
},
|
|
8242
|
-
usePackageVersions() {
|
|
8243
|
-
checkForUpdatePromise = checkForUpdatePromise || checkForUpdates().then((v) => {
|
|
8244
|
-
versions = v;
|
|
8245
|
-
refresh("usePackageVersions");
|
|
8246
|
-
});
|
|
8247
|
-
return versions;
|
|
8248
|
-
},
|
|
8249
|
-
runWizard(name, ...args) {
|
|
8250
|
-
logger.info(LOG_PREFIX, `Running wizard ${picocolorsExports.green(name)}...`);
|
|
8251
|
-
return wizard[name](nuxt, ...args);
|
|
8252
|
-
},
|
|
8253
|
-
async openInEditor(input) {
|
|
8254
|
-
if (input.startsWith("./"))
|
|
8255
|
-
input = resolve$1(process.cwd(), input);
|
|
8256
|
-
const match = input.match(/^(.*?)([:\d]*)$/);
|
|
8257
|
-
let suffix = "";
|
|
8258
|
-
if (match) {
|
|
8259
|
-
input = match[1];
|
|
8260
|
-
suffix = match[2];
|
|
8261
|
-
}
|
|
8262
|
-
const file = [
|
|
8263
|
-
input,
|
|
8264
|
-
`${input}.js`,
|
|
8265
|
-
`${input}.mjs`,
|
|
8266
|
-
`${input}.ts`
|
|
8267
|
-
].find((i) => existsSync(i));
|
|
8268
|
-
if (file) {
|
|
8269
|
-
await import('launch-editor').then((r) => (r.default || r)(file + suffix));
|
|
8270
|
-
} else {
|
|
8271
|
-
console.error("File not found:", input);
|
|
8272
|
-
}
|
|
8273
|
-
},
|
|
8274
8488
|
async customTabAction(name, actionIndex) {
|
|
8275
8489
|
const tab = customTabs.find((i) => i.name === name);
|
|
8276
8490
|
if (!tab)
|
|
@@ -8289,7 +8503,51 @@ function setupRPC(nuxt, _options) {
|
|
|
8289
8503
|
nuxt.callHook("devtools:customTabs:refresh");
|
|
8290
8504
|
return true;
|
|
8291
8505
|
}
|
|
8506
|
+
};
|
|
8507
|
+
}
|
|
8508
|
+
|
|
8509
|
+
function setupHooksDebug(hooks) {
|
|
8510
|
+
const serverHooks = {};
|
|
8511
|
+
const now = typeof globalThis.performance === "undefined" ? () => Date.now() : () => performance.now();
|
|
8512
|
+
hooks.beforeEach((event) => {
|
|
8513
|
+
if (!serverHooks[event.name]) {
|
|
8514
|
+
serverHooks[event.name] = {
|
|
8515
|
+
name: event.name,
|
|
8516
|
+
start: now(),
|
|
8517
|
+
// @ts-expect-error private field
|
|
8518
|
+
listeners: hooks._hooks[event.name]?.length || 0,
|
|
8519
|
+
executions: []
|
|
8520
|
+
};
|
|
8521
|
+
} else {
|
|
8522
|
+
const hook = serverHooks[event.name];
|
|
8523
|
+
if (hook.duration != null)
|
|
8524
|
+
hook.executions.push(hook.duration);
|
|
8525
|
+
hook.start = now();
|
|
8526
|
+
hook.end = void 0;
|
|
8527
|
+
hook.duration = void 0;
|
|
8528
|
+
}
|
|
8292
8529
|
});
|
|
8530
|
+
hooks.afterEach((event) => {
|
|
8531
|
+
const hook = serverHooks[event.name];
|
|
8532
|
+
if (!hook)
|
|
8533
|
+
return;
|
|
8534
|
+
hook.end = now();
|
|
8535
|
+
hook.duration = hook.end - hook.start;
|
|
8536
|
+
const listeners = hooks._hooks[event.name]?.length;
|
|
8537
|
+
if (listeners != null)
|
|
8538
|
+
hook.listeners = listeners;
|
|
8539
|
+
});
|
|
8540
|
+
return serverHooks;
|
|
8541
|
+
}
|
|
8542
|
+
|
|
8543
|
+
function setupGeneralRPC({ nuxt, refresh }) {
|
|
8544
|
+
const components = [];
|
|
8545
|
+
const imports = [];
|
|
8546
|
+
const importPresets = [];
|
|
8547
|
+
const serverPages = [];
|
|
8548
|
+
const serverHooks = setupHooksDebug(nuxt.hooks);
|
|
8549
|
+
let unimport;
|
|
8550
|
+
let app;
|
|
8293
8551
|
nuxt.hook("components:extend", (v) => {
|
|
8294
8552
|
components.length = 0;
|
|
8295
8553
|
components.push(...v);
|
|
@@ -8311,7 +8569,7 @@ function setupRPC(nuxt, _options) {
|
|
|
8311
8569
|
page.children?.forEach(searchChildren);
|
|
8312
8570
|
}
|
|
8313
8571
|
v.forEach(searchChildren);
|
|
8314
|
-
serverPages.push(...Array.from(pagesSet).sort((a, b) => a.
|
|
8572
|
+
serverPages.push(...Array.from(pagesSet).sort((a, b) => a.path.localeCompare(b.path)));
|
|
8315
8573
|
refresh("getServerPages");
|
|
8316
8574
|
});
|
|
8317
8575
|
nuxt.hook("imports:sources", async (v) => {
|
|
@@ -8326,43 +8584,270 @@ function setupRPC(nuxt, _options) {
|
|
|
8326
8584
|
nuxt.hook("app:resolve", (v) => {
|
|
8327
8585
|
app = v;
|
|
8328
8586
|
});
|
|
8329
|
-
|
|
8587
|
+
return {
|
|
8588
|
+
getServerConfig() {
|
|
8589
|
+
return nuxt.options;
|
|
8590
|
+
},
|
|
8591
|
+
getComponents() {
|
|
8592
|
+
return components;
|
|
8593
|
+
},
|
|
8594
|
+
async getComponentsRelationships() {
|
|
8595
|
+
return [];
|
|
8596
|
+
},
|
|
8597
|
+
getServerPages() {
|
|
8598
|
+
return serverPages;
|
|
8599
|
+
},
|
|
8600
|
+
getAutoImports() {
|
|
8601
|
+
return {
|
|
8602
|
+
imports: [
|
|
8603
|
+
...imports,
|
|
8604
|
+
...importPresets
|
|
8605
|
+
],
|
|
8606
|
+
metadata: unimport?.getMetadata()
|
|
8607
|
+
};
|
|
8608
|
+
},
|
|
8609
|
+
getServerLayouts() {
|
|
8610
|
+
return Object.values(app?.layouts || []);
|
|
8611
|
+
},
|
|
8612
|
+
getServerHooks() {
|
|
8613
|
+
return Object.values(serverHooks);
|
|
8614
|
+
},
|
|
8615
|
+
async openInEditor(input) {
|
|
8616
|
+
if (input.startsWith("./"))
|
|
8617
|
+
input = resolve$1(process.cwd(), input);
|
|
8618
|
+
const match = input.match(/^(.*?)([:\d]*)$/);
|
|
8619
|
+
let suffix = "";
|
|
8620
|
+
if (match) {
|
|
8621
|
+
input = match[1];
|
|
8622
|
+
suffix = match[2];
|
|
8623
|
+
}
|
|
8624
|
+
const path = [
|
|
8625
|
+
input,
|
|
8626
|
+
`${input}.js`,
|
|
8627
|
+
`${input}.mjs`,
|
|
8628
|
+
`${input}.ts`
|
|
8629
|
+
].find((i) => existsSync(i));
|
|
8630
|
+
if (path) {
|
|
8631
|
+
await import('launch-editor').then((r) => (r.default || r)(path + suffix));
|
|
8632
|
+
} else {
|
|
8633
|
+
console.error("File not found:", input);
|
|
8634
|
+
}
|
|
8635
|
+
},
|
|
8636
|
+
restartNuxt(hard = true) {
|
|
8637
|
+
logger.info("Restarting Nuxt...");
|
|
8638
|
+
return nuxt.callHook("restart", { hard });
|
|
8639
|
+
}
|
|
8640
|
+
};
|
|
8641
|
+
}
|
|
8642
|
+
|
|
8643
|
+
const pagesIndexTemplate = `<script setup lang="ts">
|
|
8644
|
+
const route = useRoute()
|
|
8645
|
+
<\/script>
|
|
8646
|
+
|
|
8647
|
+
<template>
|
|
8648
|
+
<div>
|
|
8649
|
+
<h1>Nuxt Routing set up successfully!</h1>
|
|
8650
|
+
<p>Current route: {{ route.path }}</p>
|
|
8651
|
+
<a href="https://nuxt.com/docs/getting-started/routing" target="_blank">Learn more about Nuxt Routing</a>
|
|
8652
|
+
</div>
|
|
8653
|
+
</template>
|
|
8654
|
+
`;
|
|
8655
|
+
async function enablePages(nuxt) {
|
|
8656
|
+
const pathApp = join$2(nuxt.options.srcDir, "app.vue");
|
|
8657
|
+
const pathPageIndex = join$2(nuxt.options.srcDir, "pages/index.vue");
|
|
8658
|
+
if (fs.existsSync(pathPageIndex)) {
|
|
8659
|
+
logger.warn("pages/index.vue already exists, skipping");
|
|
8660
|
+
return;
|
|
8661
|
+
}
|
|
8662
|
+
let appContent = fs.existsSync(pathApp) ? await fsp.readFile(pathApp, "utf-8") : void 0;
|
|
8663
|
+
await fsp.mkdir(dirname(pathPageIndex), { recursive: true });
|
|
8664
|
+
await fsp.writeFile(pathPageIndex, pagesIndexTemplate, "utf-8");
|
|
8665
|
+
if (appContent && !appContent.includes("<NuxtPage")) {
|
|
8666
|
+
appContent = appContent.replace("</template>", " <NuxtPage />\n</template>").replace(/<NuxtWelcome\s*\/>/, "");
|
|
8667
|
+
await fsp.writeFile(pathApp, appContent, "utf-8");
|
|
8668
|
+
}
|
|
8669
|
+
logger.success("Routing creation wizard completed");
|
|
8670
|
+
}
|
|
8671
|
+
|
|
8672
|
+
const wizard = {
|
|
8673
|
+
enablePages
|
|
8674
|
+
};
|
|
8675
|
+
|
|
8676
|
+
const LOG_PREFIX = picocolorsExports.cyan("Nuxt DevTools:");
|
|
8677
|
+
|
|
8678
|
+
function setupWizardRPC({ nuxt }) {
|
|
8679
|
+
return {
|
|
8680
|
+
runWizard(name, ...args) {
|
|
8681
|
+
logger.info(LOG_PREFIX, `Running wizard ${picocolorsExports.green(name)}...`);
|
|
8682
|
+
return wizard[name](nuxt, ...args);
|
|
8683
|
+
}
|
|
8684
|
+
};
|
|
8685
|
+
}
|
|
8686
|
+
|
|
8687
|
+
function setupTerminalRPC({ nuxt, rpc, refresh }) {
|
|
8688
|
+
const terminals = /* @__PURE__ */ new Map();
|
|
8689
|
+
nuxt.hook("devtools:terminal:register", (terminal) => {
|
|
8690
|
+
terminals.set(terminal.id, terminal);
|
|
8691
|
+
refresh("getTerminals");
|
|
8692
|
+
return terminal.id;
|
|
8693
|
+
});
|
|
8694
|
+
nuxt.hook("devtools:terminal:remove", ({ id }) => {
|
|
8695
|
+
if (!terminals.has(id))
|
|
8696
|
+
return false;
|
|
8697
|
+
terminals.delete(id);
|
|
8698
|
+
refresh("getTerminals");
|
|
8699
|
+
return true;
|
|
8700
|
+
});
|
|
8701
|
+
nuxt.hook("devtools:terminal:write", ({ id, data }) => {
|
|
8702
|
+
const terminal = terminals.get(id);
|
|
8703
|
+
if (!terminal)
|
|
8704
|
+
return false;
|
|
8705
|
+
terminal.buffer || (terminal.buffer = "");
|
|
8706
|
+
terminal.buffer += data;
|
|
8707
|
+
rpc.broadcast.onTerminalData.asEvent({ id, data });
|
|
8708
|
+
return true;
|
|
8709
|
+
});
|
|
8710
|
+
nuxt.hook("devtools:terminal:exit", ({ id, code }) => {
|
|
8711
|
+
const terminal = terminals.get(id);
|
|
8712
|
+
if (!terminal)
|
|
8713
|
+
return false;
|
|
8714
|
+
terminal.isTerminated = true;
|
|
8715
|
+
rpc.broadcast.onTerminalExit.asEvent({ id, code });
|
|
8716
|
+
refresh("getTerminals");
|
|
8717
|
+
return true;
|
|
8718
|
+
});
|
|
8719
|
+
function serializeTerminal(terminal, buffer = false) {
|
|
8720
|
+
if (!terminal)
|
|
8721
|
+
return;
|
|
8722
|
+
return {
|
|
8723
|
+
id: terminal.id,
|
|
8724
|
+
name: terminal.name,
|
|
8725
|
+
description: terminal.description,
|
|
8726
|
+
icon: terminal.icon,
|
|
8727
|
+
terminatable: terminal.terminatable ?? !!terminal.onActionTerminate,
|
|
8728
|
+
restartable: terminal.restartable ?? !!terminal.onActionRestart,
|
|
8729
|
+
isTerminated: terminal.isTerminated,
|
|
8730
|
+
buffer: buffer ? terminal.buffer : void 0
|
|
8731
|
+
};
|
|
8732
|
+
}
|
|
8733
|
+
return {
|
|
8734
|
+
getTerminals() {
|
|
8735
|
+
return Array.from(terminals.values()).map((i) => serializeTerminal(i));
|
|
8736
|
+
},
|
|
8737
|
+
getTerminalDetail(id) {
|
|
8738
|
+
return serializeTerminal(terminals.get(id), true);
|
|
8739
|
+
},
|
|
8740
|
+
async runTerminalAction(id, action) {
|
|
8741
|
+
const terminal = terminals.get(id);
|
|
8742
|
+
if (!terminal)
|
|
8743
|
+
return false;
|
|
8744
|
+
switch (action) {
|
|
8745
|
+
case "restart":
|
|
8746
|
+
if (!terminal.onActionRestart)
|
|
8747
|
+
return false;
|
|
8748
|
+
await terminal.onActionRestart();
|
|
8749
|
+
return true;
|
|
8750
|
+
case "terminate":
|
|
8751
|
+
if (!terminal.onActionTerminate)
|
|
8752
|
+
return false;
|
|
8753
|
+
await terminal.onActionTerminate();
|
|
8754
|
+
return true;
|
|
8755
|
+
case "remove":
|
|
8756
|
+
if (!terminal.isTerminated)
|
|
8757
|
+
terminal.onActionTerminate?.();
|
|
8758
|
+
terminals.delete(id);
|
|
8759
|
+
refresh("getTerminals");
|
|
8760
|
+
return true;
|
|
8761
|
+
case "clear":
|
|
8762
|
+
terminal.buffer = "";
|
|
8763
|
+
refresh("getTerminals");
|
|
8764
|
+
return true;
|
|
8765
|
+
}
|
|
8766
|
+
}
|
|
8767
|
+
};
|
|
8768
|
+
}
|
|
8769
|
+
|
|
8770
|
+
function setupRPC(nuxt, options) {
|
|
8771
|
+
const serverFunctions = {};
|
|
8772
|
+
const extendedRpcMap = /* @__PURE__ */ new Map();
|
|
8773
|
+
const rpc = createBirpcGroup(
|
|
8774
|
+
serverFunctions,
|
|
8775
|
+
[],
|
|
8776
|
+
{
|
|
8777
|
+
resolver: (name, fn) => {
|
|
8778
|
+
if (fn)
|
|
8779
|
+
return fn;
|
|
8780
|
+
if (!name.includes(":"))
|
|
8781
|
+
return;
|
|
8782
|
+
const [namespace, fnName] = name.split(":");
|
|
8783
|
+
return extendedRpcMap.get(namespace)?.[fnName];
|
|
8784
|
+
},
|
|
8785
|
+
onError(error, name) {
|
|
8786
|
+
console.error(`[nuxt-devtools] RPC error on executing "${name}":`, error);
|
|
8787
|
+
}
|
|
8788
|
+
}
|
|
8789
|
+
);
|
|
8790
|
+
function refresh(event) {
|
|
8791
|
+
rpc.broadcast.refresh.asEvent(event);
|
|
8792
|
+
}
|
|
8793
|
+
function extendServerRpc(namespace, functions) {
|
|
8794
|
+
extendedRpcMap.set(namespace, functions);
|
|
8795
|
+
return {
|
|
8796
|
+
broadcast: new Proxy({}, {
|
|
8797
|
+
get: (_, key) => {
|
|
8798
|
+
if (typeof key !== "string")
|
|
8799
|
+
return;
|
|
8800
|
+
return rpc.broadcast[`${namespace}:${key}`];
|
|
8801
|
+
}
|
|
8802
|
+
})
|
|
8803
|
+
};
|
|
8804
|
+
}
|
|
8805
|
+
const ctx = {
|
|
8806
|
+
nuxt,
|
|
8807
|
+
options,
|
|
8808
|
+
rpc,
|
|
8809
|
+
refresh,
|
|
8810
|
+
extendServerRpc
|
|
8811
|
+
};
|
|
8812
|
+
nuxt.devtools = ctx;
|
|
8813
|
+
Object.assign(serverFunctions, {
|
|
8814
|
+
...setupGeneralRPC(ctx),
|
|
8815
|
+
...setupCustomTabRPC(ctx),
|
|
8816
|
+
...setupStorageRPC(ctx),
|
|
8817
|
+
...setupAssetsRPC(ctx),
|
|
8818
|
+
...setupNpmRPC(ctx),
|
|
8819
|
+
...setupWizardRPC(ctx),
|
|
8820
|
+
...setupTerminalRPC(ctx)
|
|
8821
|
+
});
|
|
8822
|
+
const wsClients = /* @__PURE__ */ new Set();
|
|
8823
|
+
const middleware = async (req, _res, next) => {
|
|
8330
8824
|
if (req.ws) {
|
|
8331
8825
|
const ws = await req.ws();
|
|
8332
|
-
|
|
8826
|
+
wsClients.add(ws);
|
|
8333
8827
|
const channel = {
|
|
8334
8828
|
post: (d) => ws.send(d),
|
|
8335
8829
|
on: (fn) => ws.on("message", fn),
|
|
8336
8830
|
serialize: stringify,
|
|
8337
8831
|
deserialize: parse$7
|
|
8338
8832
|
};
|
|
8339
|
-
|
|
8340
|
-
|
|
8833
|
+
rpc.updateChannels((c) => {
|
|
8834
|
+
c.push(channel);
|
|
8341
8835
|
});
|
|
8342
8836
|
ws.on("close", () => {
|
|
8343
|
-
|
|
8344
|
-
|
|
8345
|
-
const index =
|
|
8837
|
+
wsClients.delete(ws);
|
|
8838
|
+
rpc.updateChannels((c) => {
|
|
8839
|
+
const index = c.indexOf(channel);
|
|
8346
8840
|
if (index >= 0)
|
|
8347
|
-
|
|
8841
|
+
c.splice(index, 1);
|
|
8348
8842
|
});
|
|
8349
8843
|
});
|
|
8844
|
+
} else {
|
|
8845
|
+
next();
|
|
8350
8846
|
}
|
|
8351
8847
|
};
|
|
8352
|
-
async function initHooks() {
|
|
8353
|
-
nuxt.hook("devtools:customTabs:refresh", initCustomTabs);
|
|
8354
|
-
await initCustomTabs();
|
|
8355
|
-
}
|
|
8356
|
-
async function initCustomTabs() {
|
|
8357
|
-
customTabs.length = 0;
|
|
8358
|
-
await nuxt.callHook("devtools:customTabs", customTabs);
|
|
8359
|
-
refresh("getCustomTabs");
|
|
8360
|
-
}
|
|
8361
8848
|
return {
|
|
8362
|
-
serverFunctions,
|
|
8363
8849
|
middleware,
|
|
8364
|
-
|
|
8365
|
-
birpc
|
|
8850
|
+
...ctx
|
|
8366
8851
|
};
|
|
8367
8852
|
}
|
|
8368
8853
|
|
|
@@ -8378,14 +8863,13 @@ async function enableModule(options, nuxt) {
|
|
|
8378
8863
|
await nuxt.callHook("devtools:before");
|
|
8379
8864
|
nuxt.options.imports.collectMeta = true;
|
|
8380
8865
|
addPlugin({
|
|
8381
|
-
src: join(runtimeDir, "plugins/devtools.client"),
|
|
8866
|
+
src: join$3(runtimeDir, "plugins/devtools.client"),
|
|
8382
8867
|
mode: "client"
|
|
8383
8868
|
});
|
|
8384
8869
|
const {
|
|
8385
8870
|
middleware: rpcMiddleware,
|
|
8386
|
-
|
|
8387
|
-
|
|
8388
|
-
} = setupRPC(nuxt);
|
|
8871
|
+
...ctx
|
|
8872
|
+
} = setupRPC(nuxt, options);
|
|
8389
8873
|
const clientDirExists = existsSync(clientDir);
|
|
8390
8874
|
nuxt.hook("vite:extendConfig", (config) => {
|
|
8391
8875
|
var _a, _b;
|
|
@@ -8403,15 +8887,17 @@ async function enableModule(options, nuxt) {
|
|
|
8403
8887
|
server.middlewares.use(ROUTE_CLIENT, sirv(clientDir, { single: true, dev: true }));
|
|
8404
8888
|
});
|
|
8405
8889
|
const integrations = [
|
|
8406
|
-
|
|
8407
|
-
options.
|
|
8408
|
-
options.
|
|
8890
|
+
import('./plugin-metrics.mjs').then(({ setup }) => setup(ctx)),
|
|
8891
|
+
options.viteInspect !== false ? import('./vite-inspect.mjs').then(({ setup }) => setup(ctx)) : null,
|
|
8892
|
+
options.componentInspector !== false ? import('./vue-inspector.mjs').then(({ setup }) => setup(ctx)) : null,
|
|
8893
|
+
options.vscode?.enabled ? import('./vscode.mjs').then(({ setup }) => setup(ctx)) : null
|
|
8409
8894
|
];
|
|
8410
8895
|
await Promise.all(integrations);
|
|
8411
|
-
nuxt.
|
|
8412
|
-
|
|
8896
|
+
await nuxt.callHook("devtools:initialized", {
|
|
8897
|
+
version,
|
|
8898
|
+
packagePath: packageDir,
|
|
8899
|
+
isGlobalInstall: isGlobalInstall()
|
|
8413
8900
|
});
|
|
8414
|
-
await nuxt.callHook("devtools:initialized");
|
|
8415
8901
|
logger.success(`Nuxt Devtools is enabled ${picocolorsExports.dim(`v${version}`)}${isGlobalInstall() ? picocolorsExports.dim("[global]") : ""} ${picocolorsExports.yellow("(experimental)")}`);
|
|
8416
8902
|
}
|
|
8417
8903
|
|