nuxt-files-sdk 0.0.4 → 0.1.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/LICENSE +1 -1
- package/README.md +44 -3
- package/dist/config/load.js +67 -0
- package/dist/config/load.js.map +1 -0
- package/dist/config/merge.d.ts +5 -0
- package/dist/config/merge.js +22 -0
- package/dist/config/merge.js.map +1 -0
- package/dist/config/prune.js +55 -0
- package/dist/config/prune.js.map +1 -0
- package/dist/config.d.ts +103 -91
- package/dist/config.js +1 -0
- package/dist/config.js.map +1 -1
- package/dist/devtools/auth.js +49 -0
- package/dist/devtools/auth.js.map +1 -0
- package/dist/devtools/client/app.js +8 -0
- package/dist/devtools/client/browser-agent-rpc-BXhoSh1z-DRoP5jHQ.js +1 -0
- package/dist/devtools/client/index.html +392 -72
- package/dist/devtools/devframe.js +66 -7
- package/dist/devtools/devframe.js.map +1 -1
- package/dist/devtools/diagnostics.d.ts +37 -0
- package/dist/devtools/diagnostics.js +39 -0
- package/dist/devtools/diagnostics.js.map +1 -0
- package/dist/devtools/enabled.d.ts +9 -0
- package/dist/devtools/enabled.js +3 -2
- package/dist/devtools/enabled.js.map +1 -1
- package/dist/devtools/files-read.d.ts +5 -0
- package/dist/devtools/files-read.js +7 -0
- package/dist/devtools/files-read.js.map +1 -0
- package/dist/devtools/files-write.d.ts +5 -0
- package/dist/devtools/files-write.js +7 -0
- package/dist/devtools/files-write.js.map +1 -0
- package/dist/devtools/files.js +51 -0
- package/dist/devtools/files.js.map +1 -0
- package/dist/devtools/index.js +30 -5
- package/dist/devtools/index.js.map +1 -1
- package/dist/devtools/nuxt-v3-handler.js +16 -4
- package/dist/devtools/nuxt-v3-handler.js.map +1 -1
- package/dist/devtools/nuxt-v3.js +1 -1
- package/dist/devtools/nuxt-v3.js.map +1 -1
- package/dist/devtools/nuxt-v4.js +37 -6
- package/dist/devtools/nuxt-v4.js.map +1 -1
- package/dist/devtools/snapshot.d.ts +12 -7
- package/dist/devtools/snapshot.js +15 -3
- package/dist/devtools/snapshot.js.map +1 -1
- package/dist/devtools/token.d.ts +14 -0
- package/dist/devtools/token.js +17 -0
- package/dist/devtools/token.js.map +1 -0
- package/dist/integration/nitro.d.ts +12 -1
- package/dist/integration/nitro.js +162 -41
- package/dist/integration/nitro.js.map +1 -1
- package/dist/module.d.ts +4 -6
- package/dist/module.js +37 -14
- package/dist/module.js.map +1 -1
- package/dist/nitro.d.ts +2 -4
- package/dist/nitro.js +2 -4
- package/dist/nitro.js.map +1 -1
- package/dist/package.js +1 -1
- package/dist/runtime/internal.d.ts +11 -0
- package/dist/runtime/internal.js +30 -0
- package/dist/runtime/internal.js.map +1 -0
- package/dist/runtime/normalize.js +29 -0
- package/dist/runtime/normalize.js.map +1 -0
- package/dist/runtime/provider-types.d.ts +53 -0
- package/dist/runtime/registry.d.ts +55 -8
- package/dist/runtime/registry.js +130 -63
- package/dist/runtime/registry.js.map +1 -1
- package/dist/runtime.d.ts +8 -9
- package/dist/runtime.js +8 -20
- package/dist/runtime.js.map +1 -1
- package/package.json +25 -19
- package/dist/plugins/versioning.d.ts +0 -3
- package/dist/plugins/versioning.js +0 -2
- package/dist/plugins.d.ts +0 -31
- package/dist/plugins.js +0 -16
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
//#region src/devtools/diagnostics.ts
|
|
2
|
+
const troubleshooting = "https://github.com/liria24/nuxt-files-sdk/blob/main/docs/content/4.reference/4.troubleshooting.md";
|
|
3
|
+
const FILES_DEVTOOLS_DIAGNOSTICS = {
|
|
4
|
+
NUXT_FILES_NOT_CONFIGURED: {
|
|
5
|
+
level: "warning",
|
|
6
|
+
message: "The Files registry has not been configured.",
|
|
7
|
+
hint: "Check that files.config.ts is loaded by the Nuxt or Nitro integration.",
|
|
8
|
+
docs: troubleshooting
|
|
9
|
+
},
|
|
10
|
+
NUXT_FILES_INVALID_CONFIG: {
|
|
11
|
+
level: "error",
|
|
12
|
+
message: "The Files registry rejected the storage configuration.",
|
|
13
|
+
hint: "Check the storage shape in the active files.config.ts environment.",
|
|
14
|
+
docs: troubleshooting
|
|
15
|
+
},
|
|
16
|
+
NUXT_FILES_ADAPTER_INIT_FAILED: {
|
|
17
|
+
level: "error",
|
|
18
|
+
message: "A configured storage adapter could not be initialized.",
|
|
19
|
+
hint: "Check the provider package, runtime support, and required configuration.",
|
|
20
|
+
docs: troubleshooting
|
|
21
|
+
},
|
|
22
|
+
NUXT_FILES_GATEWAY_FAILED: {
|
|
23
|
+
level: "error",
|
|
24
|
+
message: "The Files DevTools gateway could not complete a request.",
|
|
25
|
+
hint: "Check the Nitro development server and the Files registry diagnostics.",
|
|
26
|
+
docs: troubleshooting
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
const createFilesDevtoolsDiagnostic = (code, message) => ({
|
|
30
|
+
code,
|
|
31
|
+
...FILES_DEVTOOLS_DIAGNOSTICS[code],
|
|
32
|
+
...message ? { message } : {}
|
|
33
|
+
});
|
|
34
|
+
const isFilesDevtoolsDiagnostic = (value) => Boolean(value && typeof value === "object" && "code" in value && typeof value.code === "string" && Object.hasOwn(FILES_DEVTOOLS_DIAGNOSTICS, value.code) && "level" in value && (value.level === "info" || value.level === "warning" || value.level === "error") && "message" in value && typeof value.message === "string");
|
|
35
|
+
const isFilesDevtoolsFailure = (value) => Boolean(value && typeof value === "object" && "kind" in value && (value.kind === "upload" || value.kind === "delete" || value.kind === "initialization" || value.kind === "gateway") && "message" in value && typeof value.message === "string" && (!("target" in value) || value.target === void 0 || typeof value.target === "string"));
|
|
36
|
+
//#endregion
|
|
37
|
+
export { FILES_DEVTOOLS_DIAGNOSTICS, createFilesDevtoolsDiagnostic, isFilesDevtoolsDiagnostic, isFilesDevtoolsFailure };
|
|
38
|
+
|
|
39
|
+
//# sourceMappingURL=diagnostics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostics.js","names":[],"sources":["../../src/devtools/diagnostics.ts"],"sourcesContent":["const troubleshooting =\n 'https://github.com/liria24/nuxt-files-sdk/blob/main/docs/content/4.reference/4.troubleshooting.md'\n\nexport interface FilesDevtoolsDiagnostic {\n code: FilesDevtoolsDiagnosticCode\n level: 'info' | 'warning' | 'error'\n message: string\n hint?: string\n docs?: string\n}\n\nexport const FILES_DEVTOOLS_DIAGNOSTICS = {\n NUXT_FILES_NOT_CONFIGURED: {\n level: 'warning',\n message: 'The Files registry has not been configured.',\n hint: 'Check that files.config.ts is loaded by the Nuxt or Nitro integration.',\n docs: troubleshooting,\n },\n NUXT_FILES_INVALID_CONFIG: {\n level: 'error',\n message: 'The Files registry rejected the storage configuration.',\n hint: 'Check the storage shape in the active files.config.ts environment.',\n docs: troubleshooting,\n },\n NUXT_FILES_ADAPTER_INIT_FAILED: {\n level: 'error',\n message: 'A configured storage adapter could not be initialized.',\n hint: 'Check the provider package, runtime support, and required configuration.',\n docs: troubleshooting,\n },\n NUXT_FILES_GATEWAY_FAILED: {\n level: 'error',\n message: 'The Files DevTools gateway could not complete a request.',\n hint: 'Check the Nitro development server and the Files registry diagnostics.',\n docs: troubleshooting,\n },\n} as const satisfies Record<string, Omit<FilesDevtoolsDiagnostic, 'code'>>\n\nexport type FilesDevtoolsDiagnosticCode = keyof typeof FILES_DEVTOOLS_DIAGNOSTICS\n\nexport const createFilesDevtoolsDiagnostic = (\n code: FilesDevtoolsDiagnosticCode,\n message?: string,\n): FilesDevtoolsDiagnostic => ({ code, ...FILES_DEVTOOLS_DIAGNOSTICS[code], ...(message ? { message } : {}) })\n\nexport const isFilesDevtoolsDiagnostic = (value: unknown): value is FilesDevtoolsDiagnostic =>\n Boolean(\n value &&\n typeof value === 'object' &&\n 'code' in value &&\n typeof value.code === 'string' &&\n Object.hasOwn(FILES_DEVTOOLS_DIAGNOSTICS, value.code) &&\n 'level' in value &&\n (value.level === 'info' || value.level === 'warning' || value.level === 'error') &&\n 'message' in value &&\n typeof value.message === 'string',\n )\n\nexport type FilesDevtoolsFailureKind = 'upload' | 'delete' | 'initialization' | 'gateway'\n\nexport interface FilesDevtoolsFailure {\n kind: FilesDevtoolsFailureKind\n message: string\n target?: string\n}\n\nexport const isFilesDevtoolsFailure = (value: unknown): value is FilesDevtoolsFailure =>\n Boolean(\n value &&\n typeof value === 'object' &&\n 'kind' in value &&\n (value.kind === 'upload' ||\n value.kind === 'delete' ||\n value.kind === 'initialization' ||\n value.kind === 'gateway') &&\n 'message' in value &&\n typeof value.message === 'string' &&\n (!('target' in value) || value.target === undefined || typeof value.target === 'string'),\n )\n"],"mappings":";AAAA,MAAM,kBACF;AAUJ,MAAa,6BAA6B;CACtC,2BAA2B;EACvB,OAAO;EACP,SAAS;EACT,MAAM;EACN,MAAM;CACV;CACA,2BAA2B;EACvB,OAAO;EACP,SAAS;EACT,MAAM;EACN,MAAM;CACV;CACA,gCAAgC;EAC5B,OAAO;EACP,SAAS;EACT,MAAM;EACN,MAAM;CACV;CACA,2BAA2B;EACvB,OAAO;EACP,SAAS;EACT,MAAM;EACN,MAAM;CACV;AACJ;AAIA,MAAa,iCACT,MACA,aAC2B;CAAE;CAAM,GAAG,2BAA2B;CAAO,GAAI,UAAU,EAAE,QAAQ,IAAI,CAAC;AAAG;AAE5G,MAAa,6BAA6B,UACtC,QACI,SACA,OAAO,UAAU,YACjB,UAAU,SACV,OAAO,MAAM,SAAS,YACtB,OAAO,OAAO,4BAA4B,MAAM,IAAI,KACpD,WAAW,UACV,MAAM,UAAU,UAAU,MAAM,UAAU,aAAa,MAAM,UAAU,YACxE,aAAa,SACb,OAAO,MAAM,YAAY,QAC7B;AAUJ,MAAa,0BAA0B,UACnC,QACI,SACA,OAAO,UAAU,YACjB,UAAU,UACT,MAAM,SAAS,YACZ,MAAM,SAAS,YACf,MAAM,SAAS,oBACf,MAAM,SAAS,cACnB,aAAa,SACb,OAAO,MAAM,YAAY,aACxB,EAAE,YAAY,UAAU,MAAM,WAAW,KAAA,KAAa,OAAO,MAAM,WAAW,SACnF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/devtools/enabled.d.ts
|
|
2
|
+
export interface FilesDevtoolsOptions {
|
|
3
|
+
/** Enable Files SDK development tools when Nuxt DevTools is available. */
|
|
4
|
+
enabled?: boolean;
|
|
5
|
+
/** Allow uploads and deletes from the development-only file browser. Defaults to true. */
|
|
6
|
+
write?: boolean;
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
//# sourceMappingURL=enabled.d.ts.map
|
package/dist/devtools/enabled.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
//#region src/devtools/enabled.ts
|
|
2
|
-
const shouldEnableFilesDevtools = (development,
|
|
2
|
+
const shouldEnableFilesDevtools = (development, moduleDevtools, nuxtDevtools) => development && (typeof moduleDevtools === "boolean" ? moduleDevtools : moduleDevtools.enabled !== false) && (typeof nuxtDevtools === "boolean" ? nuxtDevtools : nuxtDevtools?.enabled !== false);
|
|
3
|
+
const filesDevtoolsWriteEnabled = (setting) => typeof setting === "boolean" ? setting : setting.enabled !== false && setting.write !== false;
|
|
3
4
|
//#endregion
|
|
4
|
-
export { shouldEnableFilesDevtools };
|
|
5
|
+
export { filesDevtoolsWriteEnabled, shouldEnableFilesDevtools };
|
|
5
6
|
|
|
6
7
|
//# sourceMappingURL=enabled.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enabled.js","names":[],"sources":["../../src/devtools/enabled.ts"],"sourcesContent":["export const shouldEnableFilesDevtools = (\n development: boolean,\n
|
|
1
|
+
{"version":3,"file":"enabled.js","names":[],"sources":["../../src/devtools/enabled.ts"],"sourcesContent":["export interface FilesDevtoolsOptions {\n /** Enable Files SDK development tools when Nuxt DevTools is available. */\n enabled?: boolean\n /** Allow uploads and deletes from the development-only file browser. Defaults to true. */\n write?: boolean\n}\n\nexport type FilesDevtoolsSetting = boolean | FilesDevtoolsOptions\n\nexport const shouldEnableFilesDevtools = (\n development: boolean,\n moduleDevtools: FilesDevtoolsSetting,\n nuxtDevtools?: boolean | { enabled?: boolean },\n): boolean =>\n development &&\n (typeof moduleDevtools === 'boolean' ? moduleDevtools : moduleDevtools.enabled !== false) &&\n (typeof nuxtDevtools === 'boolean' ? nuxtDevtools : nuxtDevtools?.enabled !== false)\n\nexport const filesDevtoolsWriteEnabled = (setting: FilesDevtoolsSetting): boolean =>\n typeof setting === 'boolean' ? setting : setting.enabled !== false && setting.write !== false\n"],"mappings":";AASA,MAAa,6BACT,aACA,gBACA,iBAEA,gBACC,OAAO,mBAAmB,YAAY,iBAAiB,eAAe,YAAY,WAClF,OAAO,iBAAiB,YAAY,eAAe,cAAc,YAAY;AAElF,MAAa,6BAA6B,YACtC,OAAO,YAAY,YAAY,UAAU,QAAQ,YAAY,SAAS,QAAQ,UAAU"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files-read.js","names":[],"sources":["../../src/devtools/files-read.ts"],"sourcesContent":["import { createFilesDevtoolsHandler } from './files'\n\nexport default createFilesDevtoolsHandler(false)\n"],"mappings":";;AAEA,IAAA,qBAAe,2BAA2B,KAAK"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files-write.js","names":[],"sources":["../../src/devtools/files-write.ts"],"sourcesContent":["import { createFilesDevtoolsHandler } from './files'\n\nexport default createFilesDevtoolsHandler(true)\n"],"mappings":";;AAEA,IAAA,sBAAe,2BAA2B,IAAI"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { inspectFiles } from "../runtime/internal.js";
|
|
2
|
+
import { useServerFiles } from "../runtime.js";
|
|
3
|
+
import { authorizeFilesDevtoolsRequest } from "./auth.js";
|
|
4
|
+
import { FILES_DEVTOOLS_MAX_UPLOAD_SIZE } from "./snapshot.js";
|
|
5
|
+
import { createFilesRouter } from "files-sdk/api";
|
|
6
|
+
import { createRouteHandler } from "files-sdk/nitro";
|
|
7
|
+
//#region src/devtools/files.ts
|
|
8
|
+
const readOperations = [
|
|
9
|
+
"capabilities",
|
|
10
|
+
"list",
|
|
11
|
+
"exists",
|
|
12
|
+
"download"
|
|
13
|
+
];
|
|
14
|
+
const writeOperations = [
|
|
15
|
+
...readOperations,
|
|
16
|
+
"upload",
|
|
17
|
+
"delete"
|
|
18
|
+
];
|
|
19
|
+
const filesDevtoolsOperations = (write) => write ? writeOperations : readOperations;
|
|
20
|
+
const getFiles = useServerFiles;
|
|
21
|
+
const resolveFiles = (request) => {
|
|
22
|
+
const requested = new URL(request.url).searchParams.get("storage") ?? void 0;
|
|
23
|
+
const storages = inspectFiles().storages;
|
|
24
|
+
if (storages.length === 1 && storages[0]?.name === void 0) {
|
|
25
|
+
if (requested !== void 0) throw new Error(`[nuxt-files-sdk:unknown-storage] Unknown storage "${requested}".`);
|
|
26
|
+
return getFiles();
|
|
27
|
+
}
|
|
28
|
+
if (requested === void 0 || !storages.some(({ name }) => name === requested)) throw new Error("[nuxt-files-sdk:unknown-storage] Select a configured storage.");
|
|
29
|
+
return getFiles(requested);
|
|
30
|
+
};
|
|
31
|
+
const createFilesDevtoolsHandler = (write) => {
|
|
32
|
+
const handleFiles = createRouteHandler(createFilesRouter({
|
|
33
|
+
files: resolveFiles,
|
|
34
|
+
operations: filesDevtoolsOperations(write),
|
|
35
|
+
maxUploadSize: FILES_DEVTOOLS_MAX_UPLOAD_SIZE,
|
|
36
|
+
secret: crypto.randomUUID()
|
|
37
|
+
}));
|
|
38
|
+
return async (event, secret) => {
|
|
39
|
+
if (!await authorizeFilesDevtoolsRequest(event.node.req, secret)) return new Response(null, { status: 401 });
|
|
40
|
+
const url = new URL(event.node.req.url ?? "/", "http://nuxt-files-sdk.local");
|
|
41
|
+
if (event.node.req.method === "GET" && url.searchParams.get("op") === "devtools") return Response.json({
|
|
42
|
+
write,
|
|
43
|
+
maxUploadSize: FILES_DEVTOOLS_MAX_UPLOAD_SIZE
|
|
44
|
+
});
|
|
45
|
+
return handleFiles(event);
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
//#endregion
|
|
49
|
+
export { createFilesDevtoolsHandler, filesDevtoolsOperations };
|
|
50
|
+
|
|
51
|
+
//# sourceMappingURL=files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.js","names":[],"sources":["../../src/devtools/files.ts"],"sourcesContent":["import type { Files } from 'files-sdk'\nimport { createFilesRouter, type FilesOperation } from 'files-sdk/api'\nimport { createRouteHandler } from 'files-sdk/nitro'\n\nimport { useServerFiles } from '../runtime'\nimport { inspectFiles } from '../runtime/internal'\nimport { authorizeFilesDevtoolsRequest } from './auth'\nimport { FILES_DEVTOOLS_MAX_UPLOAD_SIZE } from './snapshot'\n\nconst readOperations = ['capabilities', 'list', 'exists', 'download'] as const satisfies readonly FilesOperation[]\nconst writeOperations = [...readOperations, 'upload', 'delete'] as const satisfies readonly FilesOperation[]\nexport const filesDevtoolsOperations = (write: boolean): readonly FilesOperation[] =>\n write ? writeOperations : readOperations\nconst getFiles: (name?: string) => Files = useServerFiles\n\nconst resolveFiles = (request: Request): Files => {\n const requested = new URL(request.url).searchParams.get('storage') ?? undefined\n const storages = inspectFiles().storages\n if (storages.length === 1 && storages[0]?.name === undefined) {\n if (requested !== undefined) throw new Error(`[nuxt-files-sdk:unknown-storage] Unknown storage \"${requested}\".`)\n return getFiles()\n }\n if (requested === undefined || !storages.some(({ name }) => name === requested)) {\n throw new Error('[nuxt-files-sdk:unknown-storage] Select a configured storage.')\n }\n return getFiles(requested)\n}\n\nexport const createFilesDevtoolsHandler = (write: boolean) => {\n const handleFiles = createRouteHandler(\n createFilesRouter({\n files: resolveFiles,\n operations: filesDevtoolsOperations(write),\n maxUploadSize: FILES_DEVTOOLS_MAX_UPLOAD_SIZE,\n secret: crypto.randomUUID(),\n }),\n )\n return async (event: Parameters<typeof handleFiles>[0], secret: string): Promise<Response> => {\n if (!(await authorizeFilesDevtoolsRequest(event.node.req, secret))) {\n return new Response(null, { status: 401 })\n }\n const url = new URL(event.node.req.url ?? '/', 'http://nuxt-files-sdk.local')\n if (event.node.req.method === 'GET' && url.searchParams.get('op') === 'devtools') {\n return Response.json({ write, maxUploadSize: FILES_DEVTOOLS_MAX_UPLOAD_SIZE })\n }\n return handleFiles(event)\n }\n}\n"],"mappings":";;;;;;;AASA,MAAM,iBAAiB;CAAC;CAAgB;CAAQ;CAAU;AAAU;AACpE,MAAM,kBAAkB;CAAC,GAAG;CAAgB;CAAU;AAAQ;AAC9D,MAAa,2BAA2B,UACpC,QAAQ,kBAAkB;AAC9B,MAAM,WAAqC;AAE3C,MAAM,gBAAgB,YAA4B;CAC9C,MAAM,YAAY,IAAI,IAAI,QAAQ,GAAG,CAAC,CAAC,aAAa,IAAI,SAAS,KAAK,KAAA;CACtE,MAAM,WAAW,aAAa,CAAC,CAAC;CAChC,IAAI,SAAS,WAAW,KAAK,SAAS,EAAE,EAAE,SAAS,KAAA,GAAW;EAC1D,IAAI,cAAc,KAAA,GAAW,MAAM,IAAI,MAAM,qDAAqD,UAAU,GAAG;EAC/G,OAAO,SAAS;CACpB;CACA,IAAI,cAAc,KAAA,KAAa,CAAC,SAAS,MAAM,EAAE,WAAW,SAAS,SAAS,GAC1E,MAAM,IAAI,MAAM,+DAA+D;CAEnF,OAAO,SAAS,SAAS;AAC7B;AAEA,MAAa,8BAA8B,UAAmB;CAC1D,MAAM,cAAc,mBAChB,kBAAkB;EACd,OAAO;EACP,YAAY,wBAAwB,KAAK;EACzC,eAAe;EACf,QAAQ,OAAO,WAAW;CAC9B,CAAC,CACL;CACA,OAAO,OAAO,OAA0C,WAAsC;EAC1F,IAAI,CAAE,MAAM,8BAA8B,MAAM,KAAK,KAAK,MAAM,GAC5D,OAAO,IAAI,SAAS,MAAM,EAAE,QAAQ,IAAI,CAAC;EAE7C,MAAM,MAAM,IAAI,IAAI,MAAM,KAAK,IAAI,OAAO,KAAK,6BAA6B;EAC5E,IAAI,MAAM,KAAK,IAAI,WAAW,SAAS,IAAI,aAAa,IAAI,IAAI,MAAM,YAClE,OAAO,SAAS,KAAK;GAAE;GAAO,eAAe;EAA+B,CAAC;EAEjF,OAAO,YAAY,KAAK;CAC5B;AACJ"}
|
package/dist/devtools/index.js
CHANGED
|
@@ -1,17 +1,42 @@
|
|
|
1
|
+
import { FILES_DEVTOOLS_MAX_UPLOAD_SIZE, FILES_DEVTOOLS_PATH, FILES_GATEWAY_PATH, FILES_SNAPSHOT_PATH, FILES_TOKEN_PATH } from "./snapshot.js";
|
|
1
2
|
import nuxt_v3_handler_default from "./nuxt-v3-handler.js";
|
|
2
|
-
import
|
|
3
|
+
import token_default from "./token.js";
|
|
3
4
|
import { setupNuxtV3Devtools } from "./nuxt-v3.js";
|
|
4
5
|
import { setupNuxtV4Devtools } from "./nuxt-v4.js";
|
|
5
|
-
import { addDevServerHandler, addServerHandler } from "@nuxt/kit";
|
|
6
|
+
import { addDevServerHandler, addServerHandler, addServerTemplate } from "@nuxt/kit";
|
|
6
7
|
import { fileURLToPath } from "node:url";
|
|
7
8
|
//#region src/devtools/index.ts
|
|
8
|
-
const
|
|
9
|
+
const authenticatedHandler = (name, path, arguments_) => {
|
|
10
|
+
const filename = `#nuxt-files-sdk/${name}`;
|
|
11
|
+
addServerTemplate({
|
|
12
|
+
filename,
|
|
13
|
+
getContents: () => `import handler from ${JSON.stringify(path.replaceAll("\\", "/"))}\nexport default event => handler(event, ${arguments_.map((value) => JSON.stringify(value)).join(", ")})\n`
|
|
14
|
+
});
|
|
15
|
+
return filename;
|
|
16
|
+
};
|
|
17
|
+
const setupFilesDevtools = (nuxt, version, write, secrets) => {
|
|
9
18
|
addServerHandler({
|
|
10
19
|
route: FILES_SNAPSHOT_PATH,
|
|
11
|
-
handler: fileURLToPath(new URL("./snapshot.js", import.meta.url))
|
|
20
|
+
handler: authenticatedHandler("snapshot", fileURLToPath(new URL("./snapshot.js", import.meta.url)), [secrets.token])
|
|
21
|
+
});
|
|
22
|
+
addServerHandler({
|
|
23
|
+
route: FILES_GATEWAY_PATH,
|
|
24
|
+
handler: authenticatedHandler("files", fileURLToPath(new URL(write ? "./files-write.js" : "./files-read.js", import.meta.url)), [secrets.token])
|
|
25
|
+
});
|
|
26
|
+
if (Number.parseInt(version) >= 4) setupNuxtV4Devtools(nuxt, {
|
|
27
|
+
write,
|
|
28
|
+
maxUploadSize: FILES_DEVTOOLS_MAX_UPLOAD_SIZE,
|
|
29
|
+
tokenSecret: secrets.token
|
|
12
30
|
});
|
|
13
|
-
if (Number.parseInt(version) >= 4) setupNuxtV4Devtools(nuxt);
|
|
14
31
|
else {
|
|
32
|
+
addDevServerHandler({
|
|
33
|
+
route: FILES_TOKEN_PATH,
|
|
34
|
+
handler: (event) => token_default(event, secrets.token, async (token) => {
|
|
35
|
+
const host = "devtools" in nuxt ? nuxt.devtools : void 0;
|
|
36
|
+
if (!host || typeof host !== "object" || !("ensureDevAuthToken" in host) || typeof host.ensureDevAuthToken !== "function") throw new Error("Nuxt DevTools authentication is unavailable.");
|
|
37
|
+
await host.ensureDevAuthToken(token);
|
|
38
|
+
})
|
|
39
|
+
});
|
|
15
40
|
addDevServerHandler({
|
|
16
41
|
route: FILES_DEVTOOLS_PATH,
|
|
17
42
|
handler: nuxt_v3_handler_default
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["uiHandler"],"sources":["../../src/devtools/index.ts"],"sourcesContent":["import { fileURLToPath } from 'node:url'\n\nimport { addDevServerHandler, addServerHandler } from '@nuxt/kit'\nimport type { Nuxt } from '@nuxt/schema'\n\nimport { setupNuxtV3Devtools } from './nuxt-v3'\nimport uiHandler from './nuxt-v3-handler'\nimport { setupNuxtV4Devtools } from './nuxt-v4'\nimport {
|
|
1
|
+
{"version":3,"file":"index.js","names":["tokenHandler","uiHandler"],"sources":["../../src/devtools/index.ts"],"sourcesContent":["import { fileURLToPath } from 'node:url'\n\nimport { addDevServerHandler, addServerHandler, addServerTemplate } from '@nuxt/kit'\nimport type { Nuxt } from '@nuxt/schema'\n\nimport { setupNuxtV3Devtools } from './nuxt-v3'\nimport uiHandler from './nuxt-v3-handler'\nimport { setupNuxtV4Devtools } from './nuxt-v4'\nimport {\n FILES_DEVTOOLS_MAX_UPLOAD_SIZE,\n FILES_DEVTOOLS_PATH,\n FILES_GATEWAY_PATH,\n FILES_SNAPSHOT_PATH,\n FILES_TOKEN_PATH,\n} from './snapshot'\nimport tokenHandler from './token'\n\nconst authenticatedHandler = (name: string, path: string, arguments_: string[]): string => {\n const filename = `#nuxt-files-sdk/${name}`\n addServerTemplate({\n filename,\n getContents: () =>\n `import handler from ${JSON.stringify(path.replaceAll('\\\\', '/'))}\\nexport default event => handler(event, ${arguments_.map((value) => JSON.stringify(value)).join(', ')})\\n`,\n })\n return filename\n}\n\nexport const setupFilesDevtools = (nuxt: Nuxt, version: string, write: boolean, secrets: { token: string }): void => {\n // Snapshot must run inside Nitro's worker, where the runtime registry lives.\n addServerHandler({\n route: FILES_SNAPSHOT_PATH,\n handler: authenticatedHandler('snapshot', fileURLToPath(new URL('./snapshot.js', import.meta.url)), [\n secrets.token,\n ]),\n })\n addServerHandler({\n route: FILES_GATEWAY_PATH,\n handler: authenticatedHandler(\n 'files',\n fileURLToPath(new URL(write ? './files-write.js' : './files-read.js', import.meta.url)),\n [secrets.token],\n ),\n })\n if (Number.parseInt(version) >= 4) {\n setupNuxtV4Devtools(nuxt, {\n write,\n maxUploadSize: FILES_DEVTOOLS_MAX_UPLOAD_SIZE,\n tokenSecret: secrets.token,\n })\n } else {\n addDevServerHandler({\n route: FILES_TOKEN_PATH,\n handler: (event) =>\n tokenHandler(event, secrets.token, async (token) => {\n const host = 'devtools' in nuxt ? nuxt.devtools : undefined\n if (\n !host ||\n typeof host !== 'object' ||\n !('ensureDevAuthToken' in host) ||\n typeof host.ensureDevAuthToken !== 'function'\n ) {\n throw new Error('Nuxt DevTools authentication is unavailable.')\n }\n await host.ensureDevAuthToken(token)\n }),\n })\n addDevServerHandler({\n route: FILES_DEVTOOLS_PATH,\n handler: uiHandler,\n })\n setupNuxtV3Devtools(nuxt)\n }\n}\n"],"mappings":";;;;;;;;AAiBA,MAAM,wBAAwB,MAAc,MAAc,eAAiC;CACvF,MAAM,WAAW,mBAAmB;CACpC,kBAAkB;EACd;EACA,mBACI,uBAAuB,KAAK,UAAU,KAAK,WAAW,MAAM,GAAG,CAAC,EAAE,2CAA2C,WAAW,KAAK,UAAU,KAAK,UAAU,KAAK,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE;CACjL,CAAC;CACD,OAAO;AACX;AAEA,MAAa,sBAAsB,MAAY,SAAiB,OAAgB,YAAqC;CAEjH,iBAAiB;EACb,OAAO;EACP,SAAS,qBAAqB,YAAY,cAAc,IAAI,IAAI,iBAAiB,YAAY,GAAG,CAAC,GAAG,CAChG,QAAQ,KACZ,CAAC;CACL,CAAC;CACD,iBAAiB;EACb,OAAO;EACP,SAAS,qBACL,SACA,cAAc,IAAI,IAAI,QAAQ,qBAAqB,mBAAmB,YAAY,GAAG,CAAC,GACtF,CAAC,QAAQ,KAAK,CAClB;CACJ,CAAC;CACD,IAAI,OAAO,SAAS,OAAO,KAAK,GAC5B,oBAAoB,MAAM;EACtB;EACA,eAAe;EACf,aAAa,QAAQ;CACzB,CAAC;MACE;EACH,oBAAoB;GAChB,OAAO;GACP,UAAU,UACNA,cAAa,OAAO,QAAQ,OAAO,OAAO,UAAU;IAChD,MAAM,OAAO,cAAc,OAAO,KAAK,WAAW,KAAA;IAClD,IACI,CAAC,QACD,OAAO,SAAS,YAChB,EAAE,wBAAwB,SAC1B,OAAO,KAAK,uBAAuB,YAEnC,MAAM,IAAI,MAAM,8CAA8C;IAElE,MAAM,KAAK,mBAAmB,KAAK;GACvC,CAAC;EACT,CAAC;EACD,oBAAoB;GAChB,OAAO;GACP,SAASC;EACb,CAAC;EACD,oBAAoB,IAAI;CAC5B;AACJ"}
|
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
import { readFile } from "node:fs/promises";
|
|
2
2
|
//#region src/devtools/nuxt-v3-handler.ts
|
|
3
|
-
const html =
|
|
3
|
+
const html = {
|
|
4
|
+
contentType: "text/html; charset=utf-8",
|
|
5
|
+
content: readFile(new URL("./client/index.html", import.meta.url), "utf8")
|
|
6
|
+
};
|
|
7
|
+
const assets = /* @__PURE__ */ new Map([
|
|
8
|
+
["/", html],
|
|
9
|
+
["/index.html", html],
|
|
10
|
+
["/app.js", {
|
|
11
|
+
contentType: "text/javascript; charset=utf-8",
|
|
12
|
+
content: readFile(new URL("./client/app.js", import.meta.url), "utf8")
|
|
13
|
+
}]
|
|
14
|
+
]);
|
|
4
15
|
var nuxt_v3_handler_default = async (event) => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
16
|
+
const asset = assets.get(new URL(event.path, "http://localhost").pathname);
|
|
17
|
+
if (!asset) return void 0;
|
|
18
|
+
event.node.res.setHeader("content-type", asset.contentType);
|
|
19
|
+
return asset.content;
|
|
8
20
|
};
|
|
9
21
|
//#endregion
|
|
10
22
|
export { nuxt_v3_handler_default as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nuxt-v3-handler.js","names":[],"sources":["../../src/devtools/nuxt-v3-handler.ts"],"sourcesContent":["import { readFile } from 'node:fs/promises'\n\nconst html = readFile(new URL('./client/index.html', import.meta.url), 'utf8')\n\nexport default async (event: { path: string; node: { res: { setHeader(name: string, value: string): void } } }) => {\n
|
|
1
|
+
{"version":3,"file":"nuxt-v3-handler.js","names":[],"sources":["../../src/devtools/nuxt-v3-handler.ts"],"sourcesContent":["import { readFile } from 'node:fs/promises'\n\nconst html = {\n contentType: 'text/html; charset=utf-8',\n content: readFile(new URL('./client/index.html', import.meta.url), 'utf8'),\n}\nconst assets = new Map([\n ['/', html],\n ['/index.html', html],\n [\n '/app.js',\n {\n contentType: 'text/javascript; charset=utf-8',\n content: readFile(new URL('./client/app.js', import.meta.url), 'utf8'),\n },\n ],\n])\n\nexport default async (event: { path: string; node: { res: { setHeader(name: string, value: string): void } } }) => {\n const asset = assets.get(new URL(event.path, 'http://localhost').pathname)\n if (!asset) return undefined\n event.node.res.setHeader('content-type', asset.contentType)\n return asset.content\n}\n"],"mappings":";;AAEA,MAAM,OAAO;CACT,aAAa;CACb,SAAS,SAAS,IAAI,IAAI,uBAAuB,YAAY,GAAG,GAAG,MAAM;AAC7E;AACA,MAAM,yBAAS,IAAI,IAAI;CACnB,CAAC,KAAK,IAAI;CACV,CAAC,eAAe,IAAI;CACpB,CACI,WACA;EACI,aAAa;EACb,SAAS,SAAS,IAAI,IAAI,mBAAmB,YAAY,GAAG,GAAG,MAAM;CACzE,CACJ;AACJ,CAAC;AAED,IAAA,0BAAe,OAAO,UAA6F;CAC/G,MAAM,QAAQ,OAAO,IAAI,IAAI,IAAI,MAAM,MAAM,kBAAkB,CAAC,CAAC,QAAQ;CACzE,IAAI,CAAC,OAAO,OAAO,KAAA;CACnB,MAAM,KAAK,IAAI,UAAU,gBAAgB,MAAM,WAAW;CAC1D,OAAO,MAAM;AACjB"}
|
package/dist/devtools/nuxt-v3.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nuxt-v3.js","names":[],"sources":["../../src/devtools/nuxt-v3.ts"],"sourcesContent":["import type { Nuxt } from '@nuxt/schema'\n\nimport { FILES_DEVTOOLS_PATH } from './snapshot'\n\ninterface CustomTab {\n name: string\n title: string\n icon: string\n view: { type: 'iframe'; src: string }\n}\n\ndeclare module '@nuxt/schema' {\n interface NuxtHooks {\n 'devtools:customTabs': (tabs: CustomTab[]) => void\n }\n}\n\nexport const setupNuxtV3Devtools = (nuxt: Nuxt): void => {\n nuxt.hook('devtools:customTabs', (tabs) => {\n tabs.push({\n name: 'nuxt-files-sdk',\n title: 'Files',\n icon: 'ph:files-duotone',\n view: { type: 'iframe', src: FILES_DEVTOOLS_PATH },\n })\n })\n}\n"],"mappings":";;AAiBA,MAAa,uBAAuB,SAAqB;CACrD,KAAK,KAAK,wBAAwB,SAAS;EACvC,KAAK,KAAK;GACN,MAAM;GACN,OAAO;GACP,MAAM;GACN,MAAM;IAAE,MAAM;IAAU,KAAK;
|
|
1
|
+
{"version":3,"file":"nuxt-v3.js","names":[],"sources":["../../src/devtools/nuxt-v3.ts"],"sourcesContent":["import type { Nuxt } from '@nuxt/schema'\n\nimport { FILES_DEVTOOLS_PATH } from './snapshot'\n\ninterface CustomTab {\n name: string\n title: string\n icon: string\n view: { type: 'iframe'; src: string }\n}\n\ndeclare module '@nuxt/schema' {\n interface NuxtHooks {\n 'devtools:customTabs': (tabs: CustomTab[]) => void\n }\n}\n\nexport const setupNuxtV3Devtools = (nuxt: Nuxt): void => {\n nuxt.hook('devtools:customTabs', (tabs) => {\n tabs.push({\n name: 'nuxt-files-sdk',\n title: 'Files',\n icon: 'ph:files-duotone',\n view: { type: 'iframe', src: `${FILES_DEVTOOLS_PATH}?host=nuxt-v3` },\n })\n })\n}\n"],"mappings":";;AAiBA,MAAa,uBAAuB,SAAqB;CACrD,KAAK,KAAK,wBAAwB,SAAS;EACvC,KAAK,KAAK;GACN,MAAM;GACN,OAAO;GACP,MAAM;GACN,MAAM;IAAE,MAAM;IAAU,KAAK,GAAG,oBAAoB;GAAe;EACvE,CAAC;CACL,CAAC;AACL"}
|
package/dist/devtools/nuxt-v4.js
CHANGED
|
@@ -1,19 +1,50 @@
|
|
|
1
1
|
import { FILES_DEVTOOLS_PATH } from "./snapshot.js";
|
|
2
|
-
import
|
|
2
|
+
import { createFilesDevframe } from "./devframe.js";
|
|
3
|
+
import { NUXT_DEVTOOLS_GROUP_ID, onDevtoolsReady } from "@nuxt/devtools-kit";
|
|
3
4
|
import { createEmbedded } from "devframe/adapters/embedded";
|
|
4
5
|
//#region src/devtools/nuxt-v4.ts
|
|
5
|
-
const setupNuxtV4Devtools = (nuxt) => {
|
|
6
|
-
|
|
7
|
-
await createEmbedded(
|
|
6
|
+
const setupNuxtV4Devtools = (nuxt, options) => {
|
|
7
|
+
onDevtoolsReady(async (context) => {
|
|
8
|
+
await createEmbedded(createFilesDevframe({
|
|
9
|
+
...options,
|
|
10
|
+
notifyFailure: (message) => context.messages.add(message)
|
|
11
|
+
}), { ctx: context });
|
|
8
12
|
context.docks.register({
|
|
9
13
|
id: "nuxt-files-sdk",
|
|
10
14
|
title: "Files",
|
|
11
15
|
icon: "ph:files-duotone",
|
|
12
16
|
type: "iframe",
|
|
13
17
|
url: FILES_DEVTOOLS_PATH,
|
|
14
|
-
groupId:
|
|
18
|
+
groupId: NUXT_DEVTOOLS_GROUP_ID
|
|
15
19
|
});
|
|
16
|
-
|
|
20
|
+
const broadcast = (method) => context.scope("nuxt-files-sdk").rpc.broadcast({
|
|
21
|
+
method,
|
|
22
|
+
args: [],
|
|
23
|
+
optional: true,
|
|
24
|
+
event: true
|
|
25
|
+
});
|
|
26
|
+
context.commands.register({
|
|
27
|
+
id: "nuxt-files-sdk:open",
|
|
28
|
+
title: "Files: Open",
|
|
29
|
+
icon: "ph:files-duotone",
|
|
30
|
+
category: "tools",
|
|
31
|
+
handler: () => context.docks.activate("nuxt-files-sdk")
|
|
32
|
+
});
|
|
33
|
+
context.commands.register({
|
|
34
|
+
id: "nuxt-files-sdk:refresh",
|
|
35
|
+
title: "Files: Refresh",
|
|
36
|
+
icon: "ph:arrow-clockwise-duotone",
|
|
37
|
+
category: "tools",
|
|
38
|
+
handler: () => broadcast("refresh")
|
|
39
|
+
});
|
|
40
|
+
context.commands.register({
|
|
41
|
+
id: "nuxt-files-sdk:copy-diagnostics",
|
|
42
|
+
title: "Files: Copy Diagnostics",
|
|
43
|
+
icon: "ph:copy-duotone",
|
|
44
|
+
category: "tools",
|
|
45
|
+
handler: () => broadcast("copy-diagnostics")
|
|
46
|
+
});
|
|
47
|
+
}, nuxt);
|
|
17
48
|
};
|
|
18
49
|
//#endregion
|
|
19
50
|
export { setupNuxtV4Devtools };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nuxt-v4.js","names":[
|
|
1
|
+
{"version":3,"file":"nuxt-v4.js","names":[],"sources":["../../src/devtools/nuxt-v4.ts"],"sourcesContent":["import { NUXT_DEVTOOLS_GROUP_ID, onDevtoolsReady } from '@nuxt/devtools-kit'\nimport type { Nuxt } from '@nuxt/schema'\nimport { createEmbedded } from 'devframe/adapters/embedded'\n\nimport { createFilesDevframe } from './devframe'\nimport { FILES_DEVTOOLS_PATH } from './snapshot'\n\nexport const setupNuxtV4Devtools = (\n nuxt: Nuxt,\n options: { write: boolean; maxUploadSize: number; tokenSecret: string },\n): void => {\n onDevtoolsReady(async (context) => {\n await createEmbedded(\n createFilesDevframe({\n ...options,\n notifyFailure: (message) => context.messages.add(message),\n }),\n { ctx: context },\n )\n context.docks.register({\n id: 'nuxt-files-sdk',\n title: 'Files',\n icon: 'ph:files-duotone',\n type: 'iframe',\n url: FILES_DEVTOOLS_PATH,\n groupId: NUXT_DEVTOOLS_GROUP_ID,\n })\n\n const broadcast = (method: 'refresh' | 'copy-diagnostics') =>\n context.scope('nuxt-files-sdk').rpc.broadcast({ method, args: [], optional: true, event: true })\n context.commands.register({\n id: 'nuxt-files-sdk:open',\n title: 'Files: Open',\n icon: 'ph:files-duotone',\n category: 'tools',\n handler: () => context.docks.activate('nuxt-files-sdk'),\n })\n context.commands.register({\n id: 'nuxt-files-sdk:refresh',\n title: 'Files: Refresh',\n icon: 'ph:arrow-clockwise-duotone',\n category: 'tools',\n handler: () => broadcast('refresh'),\n })\n context.commands.register({\n id: 'nuxt-files-sdk:copy-diagnostics',\n title: 'Files: Copy Diagnostics',\n icon: 'ph:copy-duotone',\n category: 'tools',\n handler: () => broadcast('copy-diagnostics'),\n })\n }, nuxt)\n}\n"],"mappings":";;;;;AAOA,MAAa,uBACT,MACA,YACO;CACP,gBAAgB,OAAO,YAAY;EAC/B,MAAM,eACF,oBAAoB;GAChB,GAAG;GACH,gBAAgB,YAAY,QAAQ,SAAS,IAAI,OAAO;EAC5D,CAAC,GACD,EAAE,KAAK,QAAQ,CACnB;EACA,QAAQ,MAAM,SAAS;GACnB,IAAI;GACJ,OAAO;GACP,MAAM;GACN,MAAM;GACN,KAAK;GACL,SAAS;EACb,CAAC;EAED,MAAM,aAAa,WACf,QAAQ,MAAM,gBAAgB,CAAC,CAAC,IAAI,UAAU;GAAE;GAAQ,MAAM,CAAC;GAAG,UAAU;GAAM,OAAO;EAAK,CAAC;EACnG,QAAQ,SAAS,SAAS;GACtB,IAAI;GACJ,OAAO;GACP,MAAM;GACN,UAAU;GACV,eAAe,QAAQ,MAAM,SAAS,gBAAgB;EAC1D,CAAC;EACD,QAAQ,SAAS,SAAS;GACtB,IAAI;GACJ,OAAO;GACP,MAAM;GACN,UAAU;GACV,eAAe,UAAU,SAAS;EACtC,CAAC;EACD,QAAQ,SAAS,SAAS;GACtB,IAAI;GACJ,OAAO;GACP,MAAM;GACN,UAAU;GACV,eAAe,UAAU,kBAAkB;EAC/C,CAAC;CACL,GAAG,IAAI;AACX"}
|
|
@@ -1,21 +1,26 @@
|
|
|
1
|
+
import { FilesDevtoolsDiagnostic } from "./diagnostics.js";
|
|
1
2
|
//#region src/devtools/snapshot.d.ts
|
|
2
3
|
export interface FilesDevtoolsSnapshot {
|
|
3
4
|
storages: Array<{
|
|
4
5
|
name?: string;
|
|
5
6
|
adapter: string;
|
|
6
7
|
plugins: string[];
|
|
7
|
-
source: 'storage' | 'devStorage';
|
|
8
8
|
initialized: boolean;
|
|
9
9
|
}>;
|
|
10
|
-
diagnostics:
|
|
11
|
-
code: string;
|
|
12
|
-
level: 'info' | 'warning' | 'error';
|
|
13
|
-
message: string;
|
|
14
|
-
}>;
|
|
10
|
+
diagnostics: FilesDevtoolsDiagnostic[];
|
|
15
11
|
}
|
|
16
12
|
export declare const FILES_DEVTOOLS_PATH = "/__nuxt-files-sdk/";
|
|
17
13
|
export declare const FILES_SNAPSHOT_PATH = "/__nuxt-files-sdk/snapshot";
|
|
18
|
-
declare
|
|
14
|
+
export declare const FILES_GATEWAY_PATH = "/__nuxt-files-sdk/files";
|
|
15
|
+
export declare const FILES_TOKEN_PATH = "/__nuxt-files-sdk/token";
|
|
16
|
+
export declare const FILES_DEVTOOLS_MAX_UPLOAD_SIZE: number;
|
|
17
|
+
declare function _default(event: {
|
|
18
|
+
node: {
|
|
19
|
+
req: {
|
|
20
|
+
headers: Headers;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
}, secret: string): Promise<Response>;
|
|
19
24
|
//#endregion
|
|
20
25
|
export { _default as default };
|
|
21
26
|
//# sourceMappingURL=snapshot.d.ts.map
|
|
@@ -1,9 +1,21 @@
|
|
|
1
|
-
import { inspectFiles } from "../runtime.js";
|
|
1
|
+
import { inspectFiles } from "../runtime/internal.js";
|
|
2
|
+
import { authorizeFilesDevtoolsRequest } from "./auth.js";
|
|
3
|
+
import { createFilesDevtoolsDiagnostic } from "./diagnostics.js";
|
|
2
4
|
//#region src/devtools/snapshot.ts
|
|
3
5
|
const FILES_DEVTOOLS_PATH = "/__nuxt-files-sdk/";
|
|
4
6
|
const FILES_SNAPSHOT_PATH = `${FILES_DEVTOOLS_PATH}snapshot`;
|
|
5
|
-
|
|
7
|
+
const FILES_GATEWAY_PATH = `${FILES_DEVTOOLS_PATH}files`;
|
|
8
|
+
const FILES_TOKEN_PATH = `${FILES_DEVTOOLS_PATH}token`;
|
|
9
|
+
const FILES_DEVTOOLS_MAX_UPLOAD_SIZE = 10485760;
|
|
10
|
+
var snapshot_default = async (event, secret) => {
|
|
11
|
+
if (!await authorizeFilesDevtoolsRequest(event.node.req, secret)) return new Response(null, { status: 401 });
|
|
12
|
+
const snapshot = inspectFiles();
|
|
13
|
+
return Response.json({
|
|
14
|
+
...snapshot,
|
|
15
|
+
diagnostics: snapshot.diagnostics.map(({ code, name, adapter }) => createFilesDevtoolsDiagnostic(code, adapter ? `${name === void 0 ? "The single storage" : `Storage "${name}"`} (${adapter}) could not be initialized.` : void 0))
|
|
16
|
+
});
|
|
17
|
+
};
|
|
6
18
|
//#endregion
|
|
7
|
-
export { FILES_DEVTOOLS_PATH, FILES_SNAPSHOT_PATH, snapshot_default as default };
|
|
19
|
+
export { FILES_DEVTOOLS_MAX_UPLOAD_SIZE, FILES_DEVTOOLS_PATH, FILES_GATEWAY_PATH, FILES_SNAPSHOT_PATH, FILES_TOKEN_PATH, snapshot_default as default };
|
|
8
20
|
|
|
9
21
|
//# sourceMappingURL=snapshot.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snapshot.js","names":[],"sources":["../../src/devtools/snapshot.ts"],"sourcesContent":["import { inspectFiles } from '../runtime'\n\nexport interface FilesDevtoolsSnapshot {\n storages: Array<{\n name?: string\n adapter: string\n plugins: string[]\n
|
|
1
|
+
{"version":3,"file":"snapshot.js","names":[],"sources":["../../src/devtools/snapshot.ts"],"sourcesContent":["import { inspectFiles } from '../runtime/internal'\nimport { authorizeFilesDevtoolsRequest } from './auth'\nimport { createFilesDevtoolsDiagnostic, type FilesDevtoolsDiagnostic } from './diagnostics'\n\nexport interface FilesDevtoolsSnapshot {\n storages: Array<{\n name?: string\n adapter: string\n plugins: string[]\n initialized: boolean\n }>\n diagnostics: FilesDevtoolsDiagnostic[]\n}\n\nexport const FILES_DEVTOOLS_PATH = '/__nuxt-files-sdk/'\nexport const FILES_SNAPSHOT_PATH = `${FILES_DEVTOOLS_PATH}snapshot`\nexport const FILES_GATEWAY_PATH = `${FILES_DEVTOOLS_PATH}files`\nexport const FILES_TOKEN_PATH = `${FILES_DEVTOOLS_PATH}token`\nexport const FILES_DEVTOOLS_MAX_UPLOAD_SIZE = 10 * 1024 * 1024\n\nexport default async (event: { node: { req: { headers: Headers } } }, secret: string) => {\n if (!(await authorizeFilesDevtoolsRequest(event.node.req, secret))) {\n return new Response(null, { status: 401 })\n }\n const snapshot = inspectFiles()\n return Response.json({\n ...snapshot,\n diagnostics: snapshot.diagnostics.map(({ code, name, adapter }) =>\n createFilesDevtoolsDiagnostic(\n code,\n adapter\n ? `${name === undefined ? 'The single storage' : `Storage \"${name}\"`} (${adapter}) could not be initialized.`\n : undefined,\n ),\n ),\n })\n}\n"],"mappings":";;;;AAcA,MAAa,sBAAsB;AACnC,MAAa,sBAAsB,GAAG,oBAAoB;AAC1D,MAAa,qBAAqB,GAAG,oBAAoB;AACzD,MAAa,mBAAmB,GAAG,oBAAoB;AACvD,MAAa,iCAAiC;AAE9C,IAAA,mBAAe,OAAO,OAAgD,WAAmB;CACrF,IAAI,CAAE,MAAM,8BAA8B,MAAM,KAAK,KAAK,MAAM,GAC5D,OAAO,IAAI,SAAS,MAAM,EAAE,QAAQ,IAAI,CAAC;CAE7C,MAAM,WAAW,aAAa;CAC9B,OAAO,SAAS,KAAK;EACjB,GAAG;EACH,aAAa,SAAS,YAAY,KAAK,EAAE,MAAM,MAAM,cACjD,8BACI,MACA,UACM,GAAG,SAAS,KAAA,IAAY,uBAAuB,YAAY,KAAK,GAAG,IAAI,QAAQ,+BAC/E,KAAA,CACV,CACJ;CACJ,CAAC;AACL"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region src/devtools/token.d.ts
|
|
2
|
+
declare function _default(event: {
|
|
3
|
+
node: {
|
|
4
|
+
req: {
|
|
5
|
+
headers: {
|
|
6
|
+
get?: (name: string) => string | null | undefined;
|
|
7
|
+
[key: string]: unknown;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
}, secret: string, authorize: (token: string) => Promise<void>): Promise<Response>;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { _default as default };
|
|
14
|
+
//# sourceMappingURL=token.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { createFilesDevtoolsToken } from "./auth.js";
|
|
2
|
+
//#region src/devtools/token.ts
|
|
3
|
+
var token_default = async (event, secret, authorize) => {
|
|
4
|
+
const headers = event.node.req.headers;
|
|
5
|
+
const received = headers.get?.("x-nuxt-devtools-token") ?? headers["x-nuxt-devtools-token"];
|
|
6
|
+
if (typeof received !== "string" || !received) return new Response(null, { status: 401 });
|
|
7
|
+
try {
|
|
8
|
+
await authorize(received);
|
|
9
|
+
} catch {
|
|
10
|
+
return new Response(null, { status: 401 });
|
|
11
|
+
}
|
|
12
|
+
return Response.json(await createFilesDevtoolsToken(secret), { headers: { "cache-control": "no-store" } });
|
|
13
|
+
};
|
|
14
|
+
//#endregion
|
|
15
|
+
export { token_default as default };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=token.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token.js","names":[],"sources":["../../src/devtools/token.ts"],"sourcesContent":["import { createFilesDevtoolsToken } from './auth'\n\nexport default async (\n event: {\n node: { req: { headers: { get?: (name: string) => string | null | undefined; [key: string]: unknown } } }\n },\n secret: string,\n authorize: (token: string) => Promise<void>,\n) => {\n const headers = event.node.req.headers\n const received = headers.get?.('x-nuxt-devtools-token') ?? headers['x-nuxt-devtools-token']\n if (typeof received !== 'string' || !received) return new Response(null, { status: 401 })\n try {\n await authorize(received)\n } catch {\n return new Response(null, { status: 401 })\n }\n return Response.json(await createFilesDevtoolsToken(secret), { headers: { 'cache-control': 'no-store' } })\n}\n"],"mappings":";;AAEA,IAAA,gBAAe,OACX,OAGA,QACA,cACC;CACD,MAAM,UAAU,MAAM,KAAK,IAAI;CAC/B,MAAM,WAAW,QAAQ,MAAM,uBAAuB,KAAK,QAAQ;CACnE,IAAI,OAAO,aAAa,YAAY,CAAC,UAAU,OAAO,IAAI,SAAS,MAAM,EAAE,QAAQ,IAAI,CAAC;CACxF,IAAI;EACA,MAAM,UAAU,QAAQ;CAC5B,QAAQ;EACJ,OAAO,IAAI,SAAS,MAAM,EAAE,QAAQ,IAAI,CAAC;CAC7C;CACA,OAAO,SAAS,KAAK,MAAM,yBAAyB,MAAM,GAAG,EAAE,SAAS,EAAE,iBAAiB,WAAW,EAAE,CAAC;AAC7G"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import "../config.js";
|
|
2
1
|
import { ProviderSlug } from "files-sdk";
|
|
3
2
|
//#region src/integration/nitro.d.ts
|
|
4
3
|
export interface NitroIntegration {
|
|
@@ -9,13 +8,22 @@ export interface NitroIntegration {
|
|
|
9
8
|
rootDir: string;
|
|
10
9
|
buildDir: string;
|
|
11
10
|
dev?: boolean;
|
|
11
|
+
static?: boolean;
|
|
12
|
+
preset?: string;
|
|
12
13
|
plugins: string[];
|
|
14
|
+
handlers?: {
|
|
15
|
+
route: string;
|
|
16
|
+
handler: string;
|
|
17
|
+
}[];
|
|
13
18
|
alias?: Record<string, string>;
|
|
14
19
|
externals?: {
|
|
15
20
|
inline?: unknown[];
|
|
16
21
|
};
|
|
17
22
|
};
|
|
18
23
|
unimport?: {
|
|
24
|
+
injectImports(code: string, id?: string): Promise<{
|
|
25
|
+
code: string;
|
|
26
|
+
}>;
|
|
19
27
|
getInternalContext(): {
|
|
20
28
|
addons: {
|
|
21
29
|
name?: string;
|
|
@@ -27,6 +35,9 @@ export interface NitroIntegration {
|
|
|
27
35
|
hook(name: 'types:extend', callback: (types: {
|
|
28
36
|
tsConfig?: {
|
|
29
37
|
include?: string[];
|
|
38
|
+
compilerOptions?: {
|
|
39
|
+
paths?: Record<string, string[]>;
|
|
40
|
+
};
|
|
30
41
|
};
|
|
31
42
|
}) => void | Promise<void>): void;
|
|
32
43
|
};
|